19 #ifndef __itkFreeSurferAsciiMeshIO_h
20 #define __itkFreeSurferAsciiMeshIO_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 >
102 outputFile.precision(6);
104 for (
SizeValueType ii = 0; ii < this->m_NumberOfPoints; ii++ )
106 for (
unsigned int jj = 0; jj < this->m_PointDimension; jj++ )
108 outputFile << std::fixed << buffer[index++] <<
" ";
110 outputFile << label <<
'\n';
115 template<
typename T >
118 const unsigned int numberOfCellPoints = 3;
121 T *data =
new T[this->m_NumberOfCells * numberOfCellPoints];
123 ReadCellsBuffer(buffer, data);
125 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
127 for (
unsigned int jj = 0; jj < numberOfCellPoints; jj++ )
129 outputFile << data[index++] <<
" ";
131 outputFile << label <<
'\n';
137 template<
typename TInput,
typename TOutput >
138 void ReadCellsBuffer(TInput *input, TOutput *output)
140 if ( input && output )
142 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
144 for (
unsigned int jj = 0; jj < 3; jj++ )
148 output[ii * 3 + jj] =
static_cast< TOutput
>( input[5 * ii + jj + 2] );
158 void PrintSelf(std::ostream & os,
Indent indent)
const;
166 void operator=(
const Self &);