19 #ifndef itkOFFMeshIO_h
20 #define itkOFFMeshIO_h
21 #include "ITKIOMeshExport.h"
60 virtual bool CanReadFile(
const char *FileNameToRead) ITK_OVERRIDE;
63 virtual void ReadMeshInformation() ITK_OVERRIDE;
66 virtual
void ReadPoints(
void *buffer) ITK_OVERRIDE;
68 virtual
void ReadCells(
void *buffer) ITK_OVERRIDE;
70 virtual
void ReadPointData(
void *buffer) ITK_OVERRIDE;
72 virtual
void ReadCellData(
void *buffer) ITK_OVERRIDE;
81 virtual
bool CanWriteFile(const
char *FileNameToWrite) ITK_OVERRIDE;
84 virtual
void WriteMeshInformation() ITK_OVERRIDE;
88 virtual
void WritePoints(
void *buffer) ITK_OVERRIDE;
90 virtual
void WriteCells(
void *buffer) ITK_OVERRIDE;
92 virtual
void WritePointData(
void *buffer) ITK_OVERRIDE;
94 virtual
void WriteCellData(
void *buffer) ITK_OVERRIDE;
96 virtual
void Write() ITK_OVERRIDE;
100 template< typename T >
101 void ReadCellsBufferAsAscii(T *buffer, std::ifstream & inputFile)
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 virtual
void PrintSelf(std::ostream & os,
Indent indent) const ITK_OVERRIDE;
187 std::ifstream m_InputFile;
189 bool m_TriangleCellType;
void ReadCellsBuffer(TInput *input, TOutput *output)
Light weight base class for most itk classes.
std::streamoff StreamOffsetType
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)
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)