19 #ifndef itkFreeSurferAsciiMeshIO_h
20 #define itkFreeSurferAsciiMeshIO_h
21 #include "ITKIOMeshFreeSurferExport.h"
63 bool CanReadFile(
const char *FileNameToRead)
override;
66 void ReadMeshInformation()
override;
69 void ReadPoints(
void *buffer)
override;
71 void ReadCells(
void *buffer)
override;
73 void ReadPointData(
void *buffer)
override;
75 void ReadCellData(
void *buffer)
override;
84 bool CanWriteFile(
const char *FileNameToWrite)
override;
87 void WriteMeshInformation()
override;
91 void WritePoints(
void *buffer)
override;
93 void WriteCells(
void *buffer)
override;
95 void WritePointData(
void *buffer)
override;
97 void WriteCellData(
void *buffer)
override;
99 void Write()
override;
103 template<
typename T >
104 void WritePoints(T *buffer, std::ofstream & outputFile, T label = itk::NumericTraits< T >::ZeroValue())
106 outputFile.precision(6);
108 for (
SizeValueType ii = 0; ii < this->m_NumberOfPoints; ii++ )
110 for (
unsigned int jj = 0; jj < this->m_PointDimension; jj++ )
112 outputFile << std::fixed << buffer[index++] <<
" ";
114 outputFile << label <<
'\n';
119 template<
typename T >
120 void WriteCells(T *buffer, std::ofstream & outputFile, T label = itk::NumericTraits< T >::ZeroValue())
122 constexpr
unsigned int numberOfCellPoints = 3;
125 auto * data =
new T[this->m_NumberOfCells * numberOfCellPoints];
127 ReadCellsBuffer(buffer, data);
129 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
131 for (
unsigned int jj = 0; jj < numberOfCellPoints; jj++ )
133 outputFile << data[index++] <<
" ";
135 outputFile << label <<
'\n';
141 template<
typename TInput,
typename TOutput >
144 if ( input && output )
146 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
148 for (
unsigned int jj = 0; jj < 3; jj++ )
152 output[ii * 3 + jj] =
static_cast< TOutput
>( input[5 * ii + jj + 2] );
161 void PrintSelf(std::ostream & os,
Indent indent)
const override;
Light weight base class for most itk classes.
void WriteCells(T *buffer, std::ofstream &outputFile, T label=itk::NumericTraits< T >::ZeroValue())
IdentifierType SizeValueType
unsigned long SizeValueType
void ReadCellsBuffer(TInput *input, TOutput *output)
void WritePoints(T *buffer, std::ofstream &outputFile, T label=itk::NumericTraits< T >::ZeroValue())
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.
std::ifstream m_InputFile
Base class for most ITK classes.