19 #ifndef __itkOFFMeshIO_h
20 #define __itkOFFMeshIO_h
21 #include "ITKIOMeshExport.h"
60 virtual bool CanReadFile(
const char *FileNameToRead);
63 virtual void ReadMeshInformation();
66 virtual void ReadPoints(
void *buffer);
68 virtual void ReadCells(
void *buffer);
70 virtual void ReadPointData(
void *buffer);
72 virtual void ReadCellData(
void *buffer);
81 virtual bool CanWriteFile(
const char *FileNameToWrite);
84 virtual void WriteMeshInformation();
88 virtual void WritePoints(
void *buffer);
90 virtual void WriteCells(
void *buffer);
92 virtual void WritePointData(
void *buffer);
94 virtual void WriteCellData(
void *buffer);
100 template<
typename T >
104 unsigned int numberOfPoints = 0;
107 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
109 inputFile >> numberOfPoints;
110 buffer[index++] =
static_cast< T
>( numberOfPoints );
111 for (
unsigned int jj = 0; jj < numberOfPoints; jj++ )
113 inputFile >> buffer[index++];
115 std::getline(inputFile, line,
'\n');
122 template<
typename TInput,
typename TOutput >
125 if ( input && output )
129 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
132 unsigned int numberOfPoints =
static_cast< unsigned int >( input[indInput++] );
133 output[indOutput++] =
static_cast< TOutput
>( numberOfPoints );
134 for (
unsigned int jj = 0; jj < numberOfPoints; jj++ )
136 output[indOutput++] =
static_cast< TOutput
>( input[indInput++] );
143 template<
typename T >
148 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
151 unsigned int numberOfCellPoints =
static_cast< unsigned int >( buffer[index++] );
152 outputFile << numberOfCellPoints <<
" ";
154 for (
unsigned int jj = 0; jj < numberOfCellPoints; jj++ )
156 outputFile << buffer[index++] <<
" ";
163 template<
typename TOutput,
typename TInput >
166 TOutput *data =
new TOutput[m_CellBufferSize - this->m_NumberOfCells];
168 ReadCellsBuffer(buffer, data);
169 WriteBufferAsBinary< TOutput >(data, outputFile, m_CellBufferSize - this->m_NumberOfCells);
178 void PrintSelf(std::ostream & os,
Indent indent)
const;
186 void operator=(
const Self &);
void ReadCellsBuffer(TInput *input, TOutput *output)
void ReadCellsBufferAsAscii(T *buffer, std::ifstream &inputFile)
Light weight base class for most itk classes.
std::streamoff StreamOffsetType
StreamOffsetType m_PointsStartPosition
this class defines how to read and write Object file format.
SmartPointer< Self > Pointer
IdentifierType SizeValueType
unsigned long SizeValueType
void WriteCellsAsAscii(T *buffer, std::ofstream &outputFile)
std::ifstream m_InputFile
Superclass::StreamOffsetType StreamOffsetType
Control indentation during Print() invocation.
Abstract superclass defines mesh IO interface.
Superclass::SizeValueType SizeValueType
SmartPointer< const Self > ConstPointer
void WriteCellsAsBinary(TInput *buffer, std::ofstream &outputFile)