19 #ifndef itkOFFMeshIO_h
20 #define itkOFFMeshIO_h
21 #include "ITKIOMeshOFFExport.h"
62 bool CanReadFile(
const char *FileNameToRead)
override;
65 void ReadMeshInformation()
override;
68 void ReadPoints(
void *buffer)
override;
70 void ReadCells(
void *buffer)
override;
72 void ReadPointData(
void *buffer)
override;
74 void ReadCellData(
void *buffer)
override;
83 bool CanWriteFile(
const char *FileNameToWrite)
override;
86 void WriteMeshInformation()
override;
90 void WritePoints(
void *buffer)
override;
92 void WriteCells(
void *buffer)
override;
94 void WritePointData(
void *buffer)
override;
96 void WriteCellData(
void *buffer)
override;
98 void Write()
override;
102 template<
typename T >
106 unsigned int numberOfPoints = 0;
109 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
111 inputFile >> numberOfPoints;
112 buffer[index++] =
static_cast< T
>( numberOfPoints );
113 for (
unsigned int jj = 0; jj < numberOfPoints; jj++ )
115 inputFile >> buffer[index++];
117 std::getline(inputFile, line,
'\n');
124 template<
typename TInput,
typename TOutput >
127 if ( input && output )
131 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
134 auto numberOfPoints =
static_cast< unsigned int >( input[indInput++] );
135 output[indOutput++] =
static_cast< TOutput
>( numberOfPoints );
136 for (
unsigned int jj = 0; jj < numberOfPoints; jj++ )
138 output[indOutput++] =
static_cast< TOutput
>( input[indInput++] );
145 template<
typename T >
150 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
153 auto numberOfCellPoints =
static_cast< unsigned int >( buffer[index++] );
154 outputFile << numberOfCellPoints <<
" ";
156 for (
unsigned int jj = 0; jj < numberOfCellPoints; jj++ )
158 outputFile << buffer[index++] <<
" ";
165 template<
typename TOutput,
typename TInput >
168 auto * data =
new TOutput[m_CellBufferSize - this->m_NumberOfCells];
170 ReadCellsBuffer(buffer, data);
171 WriteBufferAsBinary< TOutput >(data, outputFile, m_CellBufferSize - this->m_NumberOfCells);
180 void PrintSelf(std::ostream & os,
Indent indent)
const override;
void ReadCellsBuffer(TInput *input, TOutput *output)
void ReadCellsBufferAsAscii(T *buffer, std::ifstream &inputFile)
Light weight base class for most itk classes.
IdentifierType SizeValueType
StreamOffsetType m_PointsStartPosition
unsigned long SizeValueType
this class defines how to read and write Object file format.
void WriteCellsAsAscii(T *buffer, std::ofstream &outputFile)
std::streamoff StreamOffsetType
std::ifstream m_InputFile
Control indentation during Print() invocation.
Abstract superclass defines mesh IO interface.
Base class for most ITK classes.
void WriteCellsAsBinary(TInput *buffer, std::ofstream &outputFile)