18 #ifndef itkVTKPolyDataMeshIO_h
19 #define itkVTKPolyDataMeshIO_h
20 #include "ITKIOMeshVTKExport.h"
73 bool CanReadFile(
const char *FileNameToRead)
override;
76 void ReadMeshInformation()
override;
79 void ReadPoints(
void *buffer)
override;
81 void ReadCells(
void *buffer)
override;
83 void ReadPointData(
void *buffer)
override;
85 void ReadCellData(
void *buffer)
override;
93 bool CanWriteFile(
const char *FileNameToWrite)
override;
96 void WriteMeshInformation()
override;
100 void WritePoints(
void *buffer)
override;
102 void WriteCells(
void *buffer)
override;
104 void WritePointData(
void *buffer)
override;
106 void WriteCellData(
void *buffer)
override;
108 void Write()
override;
114 void PrintSelf(std::ostream & os,
Indent indent)
const override;
117 int GetNextLine(std::ifstream& ifs, std::string& line,
bool lowerCase =
true,
SizeValueType count= 0);
119 template<
typename T >
122 unsigned int numberOfVertices = 0;
123 unsigned int numberOfVertexIndices = 0;
124 unsigned int numberOfLines = 0;
126 unsigned int numberOfPolygons = 0;
127 unsigned int numberOfPolygonIndices = 0;
131 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
134 auto nn =
static_cast< unsigned int >( buffer[index++] );
139 numberOfVertexIndices += nn + 1;
143 numberOfLineIndices += nn + 1;
147 numberOfPolygonIndices += nn + 1;
151 numberOfPolygonIndices += nn + 1;
153 case QUADRILATERAL_CELL:
155 numberOfPolygonIndices += nn + 1;
158 itkExceptionMacro(<<
"Currently we dont support this cell type");
165 EncapsulateMetaData< unsigned int >(metaDic,
"numberOfVertices", numberOfVertices);
166 EncapsulateMetaData< unsigned int >(metaDic,
"numberOfVertexIndices", numberOfVertexIndices);
167 EncapsulateMetaData< unsigned int >(metaDic,
"numberOfLines", numberOfLines);
168 EncapsulateMetaData< unsigned int >(metaDic,
"numberOfLineIndices", numberOfLineIndices);
169 EncapsulateMetaData< unsigned int >(metaDic,
"numberOfPolygons", numberOfPolygons);
170 EncapsulateMetaData< unsigned int >(metaDic,
"numberOfPolygonIndices", numberOfPolygonIndices);
174 template<
typename T >
179 while ( !inputFile.eof() )
181 std::getline(inputFile, line,
'\n');
183 if ( line.find(
"POINTS") != std::string::npos )
186 SizeValueType numberOfComponents = this->m_NumberOfPoints * this->m_PointDimension;
189 inputFile >> buffer[ii];
195 template<
typename T >
200 while ( !inputFile.eof() )
202 std::getline(inputFile, line,
'\n');
204 if ( line.find(
"POINTS") != std::string::npos )
207 SizeValueType numberOfComponents = this->m_NumberOfPoints * this->m_PointDimension;
208 inputFile.read( reinterpret_cast< char * >( buffer ), numberOfComponents *
sizeof( T ) );
218 void ReadCellsBufferAsASCII(std::ifstream & inputFile,
void *buffer);
220 void ReadCellsBufferAsBINARY(std::ifstream & inputFile,
void *buffer);
222 template<
typename T >
227 while ( !inputFile.eof() )
229 std::getline(inputFile, line,
'\n');
230 if ( line.find(
"POINT_DATA") != std::string::npos )
232 if ( !inputFile.eof() )
234 std::getline(inputFile, line,
'\n');
238 itkExceptionMacro(
"UnExpected end of line while trying to read POINT_DATA");
242 if ( line.find(
"SCALARS") != std::string::npos && line.find(
"COLOR_SCALARS") == std::string::npos )
244 if ( !inputFile.eof() )
246 std::getline(inputFile, line,
'\n');
247 if ( line.find(
"LOOKUP_TABLE") == std::string::npos )
249 itkExceptionMacro(
"UnExpected end of line while trying to read LOOKUP_TABLE");
254 itkExceptionMacro(
"UnExpected end of line while trying to read LOOKUP_TABLE");
260 SizeValueType numberOfComponents = this->m_NumberOfPointPixels * this->m_NumberOfPointPixelComponents;
263 inputFile >> buffer[ii];
269 template<
typename T >
274 while ( !inputFile.eof() )
276 std::getline(inputFile, line,
'\n');
277 if ( line.find(
"POINT_DATA") != std::string::npos )
279 if ( !inputFile.eof() )
281 std::getline(inputFile, line,
'\n');
285 itkExceptionMacro(
"UnExpected end of line while trying to read POINT_DATA");
289 if ( line.find(
"SCALARS") != std::string::npos && line.find(
"COLOR_SCALARS") == std::string::npos )
291 if ( !inputFile.eof() )
293 std::getline(inputFile, line,
'\n');
294 if ( line.find(
"LOOKUP_TABLE") == std::string::npos )
296 itkExceptionMacro(
"UnExpected end of line while trying to read LOOKUP_TABLE");
301 itkExceptionMacro(
"UnExpected end of line while trying to read LOOKUP_TABLE");
307 SizeValueType numberOfComponents = this->m_NumberOfPointPixels * this->m_NumberOfPointPixelComponents;
308 inputFile.read( reinterpret_cast< char * >( buffer ), numberOfComponents *
sizeof( T ) );
318 template<
typename T >
323 while ( !inputFile.eof() )
325 std::getline(inputFile, line,
'\n');
326 if ( line.find(
"CELL_DATA") != std::string::npos )
328 if ( !inputFile.eof() )
330 std::getline(inputFile, line,
'\n');
334 itkExceptionMacro(
"UnExpected end of line while trying to read CELL_DATA");
338 if ( line.find(
"SCALARS") != std::string::npos && line.find(
"COLOR_SCALARS") == std::string::npos )
340 if ( !inputFile.eof() )
342 std::getline(inputFile, line,
'\n');
343 if ( line.find(
"LOOKUP_TABLE") == std::string::npos )
345 itkExceptionMacro(
"UnExpected end of line while trying to read LOOKUP_TABLE");
350 itkExceptionMacro(
"UnExpected end of line while trying to read LOOKUP_TABLE");
356 SizeValueType numberOfComponents = this->m_NumberOfCellPixels * this->m_NumberOfCellPixelComponents;
359 inputFile >> buffer[ii];
365 template<
typename T >
370 while ( !inputFile.eof() )
372 std::getline(inputFile, line,
'\n');
373 if ( line.find(
"POINT_DATA") != std::string::npos )
375 if ( !inputFile.eof() )
377 std::getline(inputFile, line,
'\n');
381 itkExceptionMacro(
"UnExpected end of line while trying to read POINT_DATA");
385 if ( line.find(
"SCALARS") != std::string::npos && line.find(
"COLOR_SCALARS") == std::string::npos )
387 if ( !inputFile.eof() )
389 std::getline(inputFile, line,
'\n');
390 if ( line.find(
"LOOKUP_TABLE") == std::string::npos )
392 itkExceptionMacro(
"UnExpected end of line while trying to read LOOKUP_TABLE");
397 itkExceptionMacro(
"UnExpected end of line while trying to read LOOKUP_TABLE");
402 SizeValueType numberOfComponents = this->m_NumberOfCellPixels * this->m_NumberOfCellPixelComponents;
403 inputFile.read( reinterpret_cast< char * >( buffer ), numberOfComponents *
sizeof( T ) );
413 template<
typename T >
418 outputFile <<
"POINTS " << this->m_NumberOfPoints;
420 outputFile << pointComponentType <<
'\n';
421 for (
SizeValueType ii = 0; ii < this->m_NumberOfPoints; ii++ )
423 for (
unsigned int jj = 0; jj < this->m_PointDimension - 1; jj++ )
425 outputFile << convert(buffer[ii * this->m_PointDimension + jj]) <<
" ";
428 outputFile << convert(buffer[ii * this->m_PointDimension + this->m_PointDimension - 1]) <<
'\n';
434 template<
typename T >
438 outputFile <<
"POINTS " << this->m_NumberOfPoints;
439 outputFile << pointComponentType <<
"\n";
446 template<
typename T >
450 unsigned int numberOfVertices = 0;
451 unsigned int numberOfVertexIndices = 0;
452 unsigned int numberOfLines = 0;
453 unsigned int numberOfLineIndices = 0;
454 unsigned int numberOfPolygons = 0;
455 unsigned int numberOfPolygonIndices = 0;
460 ExposeMetaData< unsigned int >(metaDic,
"numberOfVertices", numberOfVertices);
461 if ( numberOfVertices )
463 ExposeMetaData< unsigned int >(metaDic,
"numberOfVertexIndices", numberOfVertexIndices);
464 outputFile <<
"VERTICES " << numberOfVertices <<
" " << numberOfVertexIndices <<
'\n';
465 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
468 auto nn =
static_cast< unsigned int >( buffer[index++] );
469 if ( cellType == VERTEX_CELL )
472 for (
unsigned int jj = 0; jj < nn; jj++ )
474 outputFile <<
" " << buffer[index++];
487 ExposeMetaData< unsigned int >(metaDic,
"numberOfLines", numberOfLines);
490 numberOfLineIndices = 0;
494 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
497 auto nn =
static_cast< unsigned int >( buffer[index++] );
498 if ( cellType == LINE_CELL )
500 if ( pointIds.size() >= nn )
503 if (
id == static_cast< SizeValueType >( buffer[index] ) )
505 pointIds.push_back( static_cast< SizeValueType >( buffer[index + 1] ) );
507 else if (
id == static_cast< SizeValueType >( buffer[index + 1] ) )
509 pointIds.push_back( static_cast< SizeValueType >( buffer[index] ) );
513 polylines->InsertElement(numberOfPolylines++, pointIds);
514 numberOfLineIndices += pointIds.size();
518 for (
unsigned int jj = 0; jj < nn; jj++ )
520 pointIds.push_back( static_cast< SizeValueType >( buffer[index + jj] ) );
526 for (
unsigned int jj = 0; jj < nn; jj++ )
528 pointIds.push_back( static_cast< SizeValueType >( buffer[index + jj] ) );
535 polylines->InsertElement(numberOfPolylines++, pointIds);
536 numberOfLineIndices += pointIds.size();
539 numberOfLines = polylines->Size();
540 numberOfLineIndices += numberOfLines;
541 EncapsulateMetaData< unsigned int >(metaDic,
"numberOfLines", numberOfLines);
542 EncapsulateMetaData< unsigned int >(metaDic,
"numberOfLineIndices", numberOfLineIndices);
543 outputFile <<
"LINES " << numberOfLines <<
" " << numberOfLineIndices <<
'\n';
546 auto nn =
static_cast<unsigned int>( polylines->ElementAt(ii).size() );
548 for (
unsigned int jj = 0; jj < nn; ++jj )
550 outputFile <<
" " << polylines->ElementAt(ii)[jj];
558 ExposeMetaData< unsigned int >(metaDic,
"numberOfPolygons", numberOfPolygons);
559 if ( numberOfPolygons )
561 ExposeMetaData< unsigned int >(metaDic,
"numberOfPolygonIndices", numberOfPolygonIndices);
562 outputFile <<
"POLYGONS " << numberOfPolygons <<
" " << numberOfPolygonIndices <<
'\n';
563 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
566 auto nn =
static_cast< unsigned int >( buffer[index++] );
567 if ( cellType == POLYGON_CELL ||
568 cellType == TRIANGLE_CELL ||
569 cellType == QUADRILATERAL_CELL )
572 for (
unsigned int jj = 0; jj < nn; jj++ )
574 outputFile <<
" " << buffer[index++];
587 template<
typename T >
591 unsigned int numberOfVertices = 0;
592 unsigned int numberOfVertexIndices = 0;
593 unsigned int numberOfLines = 0;
594 unsigned int numberOfLineIndices = 0;
595 unsigned int numberOfPolygons = 0;
596 unsigned int numberOfPolygonIndices = 0;
601 ExposeMetaData< unsigned int >(metaDic,
"numberOfVertices", numberOfVertices);
602 if ( numberOfVertices )
604 ExposeMetaData< unsigned int >(metaDic,
"numberOfVertexIndices", numberOfVertexIndices);
605 outputFile <<
"VERTICES " << numberOfVertices <<
" " << numberOfVertexIndices <<
'\n';
606 auto * data =
new unsigned int[numberOfVertexIndices];
607 ReadCellsBuffer(buffer, data);
615 ExposeMetaData< unsigned int >(metaDic,
"numberOfLines", numberOfLines);
618 numberOfLineIndices = 0;
622 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
625 auto nn =
static_cast< unsigned int >( buffer[index++] );
626 if ( cellType == LINE_CELL )
628 if ( pointIds.size() >= nn )
631 if (
id == static_cast< SizeValueType >( buffer[index] ) )
633 pointIds.push_back( static_cast< SizeValueType >( buffer[index + 1] ) );
635 else if (
id == static_cast< SizeValueType >( buffer[index + 1] ) )
637 pointIds.push_back( static_cast< SizeValueType >( buffer[index] ) );
641 polylines->InsertElement(numberOfPolylines++, pointIds);
642 numberOfLineIndices += pointIds.size();
646 for (
unsigned int jj = 0; jj < nn; jj++ )
648 pointIds.push_back( static_cast< SizeValueType >( buffer[index + jj] ) );
654 for (
unsigned int jj = 0; jj < nn; jj++ )
656 pointIds.push_back( static_cast< SizeValueType >( buffer[index + jj] ) );
663 polylines->InsertElement(numberOfPolylines++, pointIds);
664 numberOfLineIndices += pointIds.size();
667 numberOfLines = polylines->Size();
668 numberOfLineIndices += numberOfLines;
669 EncapsulateMetaData< unsigned int >(metaDic,
"numberOfLines", numberOfLines);
670 EncapsulateMetaData< unsigned int >(metaDic,
"numberOfLineIndices", numberOfLineIndices);
672 outputFile <<
"LINES " << numberOfLines <<
" " << numberOfLineIndices <<
'\n';
673 auto * data =
new unsigned int[numberOfLineIndices];
674 unsigned long outputIndex = 0;
677 auto nn =
static_cast<unsigned int>( polylines->ElementAt(ii).size() );
678 data[outputIndex++] = nn;
679 for (
unsigned int jj = 0; jj < nn; ++jj )
681 data[outputIndex++] = polylines->ElementAt(ii)[jj];
692 ExposeMetaData< unsigned int >(metaDic,
"numberOfPolygons", numberOfPolygons);
693 if ( numberOfPolygons )
695 ExposeMetaData< unsigned int >(metaDic,
"numberOfPolygonIndices", numberOfPolygonIndices);
696 outputFile <<
"POLYGONS " << numberOfPolygons <<
" " << numberOfPolygonIndices <<
'\n';
697 auto * data =
new unsigned int[numberOfPolygonIndices];
698 ReadCellsBuffer(buffer, data);
706 template<
typename T >
713 outputFile <<
"POINT_DATA " << this->m_NumberOfPointPixels <<
'\n';
714 switch ( this->m_PointPixelType )
718 outputFile <<
"SCALARS ";
719 ExposeMetaData< StringType >(metaDic,
"pointScalarDataName", dataName);
720 outputFile << dataName <<
" ";
725 case COVARIANTVECTOR:
728 outputFile <<
"VECTORS ";
729 ExposeMetaData< StringType >(metaDic,
"pointVectorDataName", dataName);
730 outputFile << dataName <<
" ";
733 case SYMMETRICSECONDRANKTENSOR:
734 case DIFFUSIONTENSOR3D:
736 outputFile <<
"TENSORS ";
737 ExposeMetaData< StringType >(metaDic,
"pointTensorDataName", dataName);
738 outputFile << dataName <<
" ";
742 case VARIABLELENGTHVECTOR:
744 outputFile <<
"COLOR_SCALARS ";
745 ExposeMetaData< StringType >(metaDic,
"pointColorScalarDataName", dataName);
746 outputFile << dataName <<
" ";
747 WriteColorScalarBufferAsASCII(outputFile, buffer, this->m_NumberOfPointPixelComponents, this->m_NumberOfPointPixels);
752 itkExceptionMacro(<<
"Unknown point pixel type");
756 outputFile << pointPixelComponentName <<
'\n';
758 if ( this->m_PointPixelType == SCALAR )
760 outputFile <<
"LOOKUP_TABLE default" <<
'\n';
764 if ( this->m_PointPixelType == SYMMETRICSECONDRANKTENSOR )
768 const SizeValueType num = this->m_NumberOfPointPixelComponents * this->m_NumberOfPointPixels;
771 if( this->m_NumberOfPointPixelComponents == 3 )
773 T zero( itk::NumericTraits<T>::ZeroValue() );
778 outputFile << convert(*ptr++) << indent;
780 outputFile << convert(e12) << indent;
781 outputFile << convert(zero) <<
'\n';
783 outputFile << convert(e12) << indent;
784 outputFile << convert(*ptr++) << indent;
785 outputFile << convert(zero) <<
'\n';
787 outputFile << convert(zero) << indent << convert(zero) << indent << convert(zero) <<
"\n\n";
791 else if( this->m_NumberOfPointPixelComponents == 6 )
799 outputFile << convert(*ptr++) << indent;
801 outputFile << convert(e12) << indent;
803 outputFile << convert(e13) <<
'\n';
805 outputFile << convert(e12) << indent;
806 outputFile << convert(*ptr++) << indent;
808 outputFile << convert(e23) <<
'\n';
810 outputFile << convert(e13) << indent;
811 outputFile << convert(e23) << indent;
812 outputFile << convert(*ptr++) <<
"\n\n";
819 "itk::ERROR: VTKImageIO2: Unsupported number of components in tensor.",
827 for (
SizeValueType ii = 0; ii < this->m_NumberOfPointPixels; ii++ )
829 for ( jj = 0; jj < this->m_NumberOfPointPixelComponents - 1; jj++ )
831 outputFile << convert(buffer[ii * this->m_NumberOfPointPixelComponents + jj]) << indent;
833 outputFile << convert(buffer[ii * this->m_NumberOfPointPixelComponents + jj]);
841 template<
typename T >
847 outputFile <<
"POINT_DATA " << this->m_NumberOfPointPixels <<
"\n";
848 switch ( this->m_PointPixelType )
852 outputFile <<
"SCALARS ";
853 ExposeMetaData< StringType >(metaDic,
"pointScalarDataName", dataName);
854 outputFile << dataName <<
" ";
859 case COVARIANTVECTOR:
862 outputFile <<
"VECTORS ";
863 ExposeMetaData< StringType >(metaDic,
"pointVectorDataName", dataName);
864 outputFile << dataName <<
" ";
867 case SYMMETRICSECONDRANKTENSOR:
868 case DIFFUSIONTENSOR3D:
870 outputFile <<
"TENSORS ";
871 ExposeMetaData< StringType >(metaDic,
"pointTensorDataName", dataName);
872 outputFile << dataName <<
" ";
876 case VARIABLELENGTHVECTOR:
878 outputFile <<
"COLOR_SCALARS ";
879 ExposeMetaData< StringType >(metaDic,
"pointColorScalarDataName", dataName);
880 outputFile << dataName <<
" ";
881 WriteColorScalarBufferAsBINARY(outputFile, buffer, this->m_NumberOfPointPixelComponents, this->m_NumberOfPointPixels);
886 itkExceptionMacro(<<
"Unknown point pixel type");
890 outputFile << pointPixelComponentName <<
"\n";
891 if ( this->m_PointPixelType == SCALAR )
893 outputFile <<
"LOOKUP_TABLE default\n";
897 this->m_NumberOfPointPixels * this->m_NumberOfPointPixelComponents,
903 template<
typename T >
909 outputFile <<
"CELL_DATA " << this->m_NumberOfCellPixels <<
'\n';
910 switch ( this->m_CellPixelType )
914 outputFile <<
"SCALARS ";
915 ExposeMetaData< StringType >(metaDic,
"cellScalarDataName", dataName);
916 outputFile << dataName <<
" ";
921 case COVARIANTVECTOR:
924 outputFile <<
"VECTORS ";
925 ExposeMetaData< StringType >(metaDic,
"cellVectorDataName", dataName);
926 outputFile << dataName <<
" ";
929 case SYMMETRICSECONDRANKTENSOR:
930 case DIFFUSIONTENSOR3D:
932 outputFile <<
"TENSORS ";
933 ExposeMetaData< StringType >(metaDic,
"cellTensorDataName", dataName);
934 outputFile << dataName <<
" ";
938 case VARIABLELENGTHVECTOR:
940 outputFile <<
"COLOR_SCALARS ";
941 ExposeMetaData< StringType >(metaDic,
"cellColorScalarDataName", dataName);
942 outputFile << dataName <<
" ";
943 WriteColorScalarBufferAsASCII(outputFile, buffer, this->m_NumberOfCellPixelComponents, this->m_NumberOfCellPixels);
948 itkExceptionMacro(<<
"Unknown cell pixel type");
952 outputFile << cellPixelComponentName <<
'\n';
953 if ( this->m_CellPixelType == SCALAR )
955 outputFile <<
"LOOKUP_TABLE default" <<
'\n';
959 if ( this->m_CellPixelType == SYMMETRICSECONDRANKTENSOR )
963 const SizeValueType num = this->m_NumberOfCellPixelComponents * this->m_NumberOfCellPixels;
964 if( this->m_NumberOfCellPixelComponents == 2 )
966 T zero( itk::NumericTraits<T>::ZeroValue() );
971 outputFile << *ptr++ << indent;
973 outputFile << e12 << indent;
974 outputFile << zero <<
'\n';
976 outputFile << e12 << indent;
977 outputFile << *ptr++ << indent;
978 outputFile << zero <<
'\n';
980 outputFile << zero << indent << zero << indent << zero <<
"\n\n";
984 else if( this->m_NumberOfCellPixelComponents == 3 )
992 outputFile << *ptr++ << indent;
994 outputFile << e12 << indent;
996 outputFile << e13 <<
'\n';
998 outputFile << e12 << indent;
999 outputFile << *ptr++ << indent;
1001 outputFile << e23 <<
'\n';
1003 outputFile << e13 << indent;
1004 outputFile << e23 << indent;
1005 outputFile << *ptr++ <<
"\n\n";
1012 "itk::ERROR: VTKPolyDataMeshIO: Unsupported number of components in tensor.",
1020 for (
SizeValueType ii = 0; ii < this->m_NumberOfCellPixels; ii++ )
1022 for ( jj = 0; jj < this->m_NumberOfCellPixelComponents - 1; jj++ )
1024 outputFile << buffer[ii * this->m_NumberOfCellPixelComponents + jj] << indent;
1026 outputFile << buffer[ii * this->m_NumberOfCellPixelComponents + jj];
1034 template<
typename T >
1040 outputFile <<
"CELL_DATA " << this->m_NumberOfCellPixels <<
"\n";
1041 switch ( this->m_CellPixelType )
1045 outputFile <<
"SCALARS ";
1046 ExposeMetaData< StringType >(metaDic,
"cellScalarDataName", dataName);
1047 outputFile << dataName <<
" ";
1052 case COVARIANTVECTOR:
1055 outputFile <<
"VECTORS ";
1056 ExposeMetaData< StringType >(metaDic,
"cellVectorDataName", dataName);
1057 outputFile << dataName <<
" ";
1060 case SYMMETRICSECONDRANKTENSOR:
1061 case DIFFUSIONTENSOR3D:
1063 outputFile <<
"TENSORS ";
1064 ExposeMetaData< StringType >(metaDic,
"cellTensorDataName", dataName);
1065 outputFile << dataName <<
" ";
1069 case VARIABLELENGTHVECTOR:
1071 outputFile <<
"COLOR_SCALARS ";
1072 ExposeMetaData< StringType >(metaDic,
"cellColorScalarDataName", dataName);
1073 outputFile << dataName <<
" ";
1074 WriteColorScalarBufferAsBINARY(outputFile, buffer, this->m_NumberOfCellPixelComponents, this->m_NumberOfCellPixels);
1079 itkExceptionMacro(<<
"Unknown cell pixel type");
1083 outputFile << cellPixelComponentName <<
"\n";
1084 if ( this->m_CellPixelType == SCALAR )
1086 outputFile <<
"LOOKUP_TABLE default\n";
1090 this->m_NumberOfCells * this->m_NumberOfCellPixelComponents,
1096 template<
typename T >
1099 unsigned int numberOfPixelComponents,
1103 outputFile << numberOfPixelComponents <<
"\n";
1107 for (
unsigned int jj = 0; jj < numberOfPixelComponents; ++jj )
1109 outputFile << convert(static_cast< float >( buffer[ii * numberOfPixelComponents + jj])) << indent;
1118 template<
typename T >
1121 unsigned int numberOfPixelComponents,
1124 outputFile << numberOfPixelComponents <<
"\n";
1125 SizeValueType numberOfElements = numberOfPixelComponents * numberOfPixels;
1126 auto * data =
new unsigned char[numberOfElements];
1129 data[ii] =
static_cast< unsigned char >( buffer[ii] );
1132 outputFile.write(reinterpret_cast< char * >( data ), numberOfElements);
1141 template<
typename TInput,
typename TOutput >
1147 if ( input && output )
1149 for (
SizeValueType ii = 0; ii < this->m_NumberOfCells; ii++ )
1152 auto nn =
static_cast< unsigned int >( input[inputIndex++] );
1153 output[outputIndex++] = nn;
1154 for (
unsigned int jj = 0; jj < nn; jj++ )
1156 output[outputIndex++] =
static_cast< TOutput
>( input[inputIndex++] );
1163 IOComponentType GetComponentTypeFromString(
const std::string & pixelType);
1167 #endif // itkVTKPolyDataMeshIO_h
Light weight base class for most itk classes.
IdentifierType SizeValueType
unsigned long SizeValueType
void WritePointsBufferAsASCII(std::ofstream &outputFile, T *buffer, const StringType &pointComponentType)
This class defines how to read and write vtk legacy file format.
void ReadPointsBufferAsASCII(std::ifstream &inputFile, T *buffer)
void ReadCellDataBufferAsASCII(std::ifstream &inputFile, T *buffer)
std::vector< SizeValueType > PointIdVector
std::stringstream StringStreamType
void WritePointsBufferAsBINARY(std::ofstream &outputFile, T *buffer, const StringType &pointComponentType)
void WriteColorScalarBufferAsBINARY(std::ofstream &outputFile, T *buffer, unsigned int numberOfPixelComponents, SizeValueType numberOfPixels)
void ReadCellsBuffer(TInput *input, TOutput *output)
static void SwapRangeFromSystemToBigEndian(T *p, BufferSizeType num)
void WriteCellsBufferAsBINARY(std::ofstream &outputFile, T *buffer)
Convert floating and fixed point numbers to strings.
void ReadCellDataBufferAsBINARY(std::ifstream &inputFile, T *buffer)
Standard exception handling object.
void WriteCellDataBufferAsASCII(std::ofstream &outputFile, T *buffer, const StringType &cellPixelComponentName)
void WriteCellDataBufferAsBINARY(std::ofstream &outputFile, T *buffer, const StringType &cellPixelComponentName)
void ReadPointsBufferAsBINARY(std::ifstream &inputFile, T *buffer)
void WritePointDataBufferAsBINARY(std::ofstream &outputFile, T *buffer, const StringType &pointPixelComponentName)
void ReadPointDataBufferAsBINARY(std::ifstream &inputFile, T *buffer)
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
std::vector< StringType > StringVectorType
void WriteCellsBufferAsASCII(std::ofstream &outputFile, T *buffer)
Control indentation during Print() invocation.
static void SwapWriteRangeFromSystemToBigEndian(T *p, int num, OStreamType *fp)
Abstract superclass defines mesh IO interface.
void WritePointDataBufferAsASCII(std::ofstream &outputFile, T *buffer, const StringType &pointPixelComponentName)
void WriteColorScalarBufferAsASCII(std::ofstream &outputFile, T *buffer, unsigned int numberOfPixelComponents, SizeValueType numberOfPixels)
Base class for most ITK classes.
Perform machine dependent byte swapping.
void ReadPointDataBufferAsASCII(std::ifstream &inputFile, T *buffer)
void UpdateCellInformation(T *buffer)