19 #ifndef __itkFreeSurferBinaryMeshIO_h
20 #define __itkFreeSurferBinaryMeshIO_h
62 virtual bool CanReadFile(
const char *FileNameToRead);
65 virtual void ReadMeshInformation();
68 virtual void ReadPoints(
void *buffer);
70 virtual void ReadCells(
void *buffer);
72 virtual void ReadPointData(
void *buffer);
74 virtual void ReadCellData(
void *buffer);
83 virtual bool CanWriteFile(
const char *FileNameToWrite);
86 virtual void WriteMeshInformation();
90 virtual void WritePoints(
void *buffer);
92 virtual void WriteCells(
void *buffer);
94 virtual void WritePointData(
void *buffer);
96 virtual void WriteCellData(
void *buffer);
102 template<
typename T >
103 void WritePoints(T *buffer, std::ofstream & outputFile)
105 float *data =
new float[this->m_NumberOfPoints * this->m_PointDimension];
107 for (
SizeValueType ii = 0; ii < this->m_NumberOfPoints; ii++ )
109 for (
unsigned int jj = 0; jj < this->m_PointDimension; jj++ )
111 data[ii * this->m_PointDimension + jj] =
static_cast< float >( buffer[ii * this->m_PointDimension + jj] );
120 template<
typename T >
121 void WriteCells(T *buffer, std::ofstream & outputFile)
127 ReadCellsBuffer(buffer, data);
134 template<
typename TInput,
typename TOutput >
135 void ReadCellsBuffer(TInput *input, TOutput *output)
137 if ( input && output )
139 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
141 for (
unsigned int jj = 0; jj < 3; jj++ )
146 output[ii * 3 + jj] =
static_cast< TOutput
>( input[5 * ii + jj + 2] );
153 template<
typename T >
154 void WritePointData(T *buffer, std::ofstream & outputFile)
156 float *data =
new float[this->m_NumberOfPointPixels];
158 for (
SizeValueType ii = 0; ii < this->m_NumberOfPointPixels; ii++ )
160 data[ii] =
static_cast< float >( buffer[ii] );
171 void PrintSelf(std::ostream & os,
Indent indent)
const;
179 void operator=(
const Self &);