19 #ifndef itkFreeSurferAsciiMeshIO_h
20 #define itkFreeSurferAsciiMeshIO_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 WritePoints(T *buffer, std::ofstream & outputFile, T label = itk::
NumericTraits< T >::ZeroValue())
103 outputFile.precision(6);
105 for (
SizeValueType ii = 0; ii < this->m_NumberOfPoints; ii++ )
107 for (
unsigned int jj = 0; jj < this->m_PointDimension; jj++ )
109 outputFile << std::fixed << buffer[index++] <<
" ";
111 outputFile << label <<
'\n';
116 template<
typename T >
119 const unsigned int numberOfCellPoints = 3;
122 T *data =
new T[this->m_NumberOfCells * numberOfCellPoints];
124 ReadCellsBuffer(buffer, data);
126 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
128 for (
unsigned int jj = 0; jj < numberOfCellPoints; jj++ )
130 outputFile << data[index++] <<
" ";
132 outputFile << label <<
'\n';
138 template<
typename TInput,
typename TOutput >
141 if ( input && output )
143 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
145 for (
unsigned int jj = 0; jj < 3; jj++ )
149 output[ii * 3 + jj] =
static_cast< TOutput
>( input[5 * ii + jj + 2] );
158 virtual
void PrintSelf(std::ostream & os,
Indent indent) const ITK_OVERRIDE;
167 std::ifstream m_InputFile;
Light weight base class for most itk classes.
void WriteCells(T *buffer, std::ofstream &outputFile, T label=itk::NumericTraits< T >::ZeroValue())
SmartPointer< const Self > ConstPointer
FreeSurferAsciiMeshIO Self
void ReadCellsBuffer(TInput *input, TOutput *output)
unsigned long SizeValueType
SmartPointer< Self > Pointer
Superclass::SizeValueType SizeValueType
This class defines how to read and write freesurfer ASCII surface format. To use IO factory...
Control indentation during Print() invocation.
Abstract superclass defines mesh IO interface.
Define additional traits for native types such as int or float.