19 #ifndef itkFreeSurferAsciiMeshIO_h
20 #define itkFreeSurferAsciiMeshIO_h
21 #include "ITKIOMeshFreeSurferExport.h"
64 CanReadFile(
const char * fileName)
override;
68 ReadMeshInformation()
override;
72 ReadPoints(
void * buffer)
override;
75 ReadCells(
void * buffer)
override;
78 ReadPointData(
void * buffer)
override;
81 ReadCellData(
void * buffer)
override;
91 CanWriteFile(
const char * fileName)
override;
95 WriteMeshInformation()
override;
100 WritePoints(
void * buffer)
override;
103 WriteCells(
void * buffer)
override;
106 WritePointData(
void * buffer)
override;
109 WriteCellData(
void * buffer)
override;
116 template <
typename T>
118 WritePoints(T * buffer, std::ofstream & outputFile, T label = T{})
120 outputFile.precision(6);
122 for (
SizeValueType ii = 0; ii < this->m_NumberOfPoints; ++ii)
124 for (
unsigned int jj = 0; jj < this->m_PointDimension; ++jj)
126 outputFile << std::fixed << buffer[index++] <<
" ";
128 outputFile << label <<
'\n';
133 template <
typename T>
135 WriteCells(T * buffer, std::ofstream & outputFile, T label = T{})
137 constexpr
unsigned int numberOfCellPoints = 3;
140 const auto data = make_unique_for_overwrite<T[]>(this->m_NumberOfCells * numberOfCellPoints);
142 ReadCellsBuffer(buffer, data.get());
146 for (
unsigned int jj = 0; jj < numberOfCellPoints; ++jj)
148 outputFile << data[index++] <<
" ";
150 outputFile << label <<
'\n';
155 template <
typename TInput,
typename TOutput>
163 for (
unsigned int jj = 0; jj < 3; ++jj)
168 output[ii * 3 + jj] = static_cast<TOutput>(input[5 * ii + jj + 2]);
178 PrintSelf(std::ostream & os,
Indent indent)
const override;
187 std::ifstream m_InputFile{};