19 #ifndef __itkOFFMeshIO_h
20 #define __itkOFFMeshIO_h
59 virtual bool CanReadFile(
const char *FileNameToRead);
62 virtual void ReadMeshInformation();
65 virtual void ReadPoints(
void *buffer);
67 virtual void ReadCells(
void *buffer);
69 virtual void ReadPointData(
void *buffer);
71 virtual void ReadCellData(
void *buffer);
80 virtual bool CanWriteFile(
const char *FileNameToWrite);
83 virtual void WriteMeshInformation();
87 virtual void WritePoints(
void *buffer);
89 virtual void WriteCells(
void *buffer);
91 virtual void WritePointData(
void *buffer);
93 virtual void WriteCellData(
void *buffer);
99 template<
typename T >
100 void ReadCellsBufferAsAscii(T *buffer, std::ifstream & inputFile)
103 unsigned int numberOfPoints = 0;
106 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
108 inputFile >> numberOfPoints;
109 buffer[index++] =
static_cast< T
>( numberOfPoints );
110 for (
unsigned int jj = 0; jj < numberOfPoints; jj++ )
112 inputFile >> buffer[index++];
114 std::getline(inputFile, line,
'\n');
121 template<
typename TInput,
typename TOutput >
122 void ReadCellsBuffer(TInput *input, TOutput *output)
124 if ( input && output )
128 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
131 unsigned int numberOfPoints =
static_cast< unsigned int >( input[indInput++] );
132 output[indOutput++] =
static_cast< TOutput
>( numberOfPoints );
133 for (
unsigned int jj = 0; jj < numberOfPoints; jj++ )
135 output[indOutput++] =
static_cast< TOutput
>( input[indInput++] );
142 template<
typename T >
143 void WriteCellsAsAscii(T *buffer, std::ofstream & outputFile)
147 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
150 unsigned int numberOfCellPoints =
static_cast< unsigned int >( buffer[index++] );
151 outputFile << numberOfCellPoints <<
" ";
153 for (
unsigned int jj = 0; jj < numberOfCellPoints; jj++ )
155 outputFile << buffer[index++] <<
" ";
162 template<
typename TOutput,
typename TInput >
163 void WriteCellsAsBinary(TInput *buffer, std::ofstream & outputFile)
165 TOutput *data =
new TOutput[m_CellBufferSize - this->m_NumberOfCells];
167 ReadCellsBuffer(buffer, data);
168 WriteBufferAsBinary< TOutput >(data, outputFile, m_CellBufferSize - this->m_NumberOfCells);
177 void PrintSelf(std::ostream & os,
Indent indent)
const;
185 void operator=(
const Self &);