Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,50 @@ VTKPolyDataMeshIO::ReadMeshInformation()
this->m_NumberOfPointPixelComponents = this->m_PointDimension * (this->m_PointDimension + 1) / 2;
this->m_UpdatePointData = true;
}
if (line.find("FIELD") != std::string::npos)
{
StringStreamType sss;
sss << line;

sss >> item; // should be "FIELD"
if (item == "FIELD")
{
sss >> item; // field data name (e.g. "FieldData")
sss >> item; // number of field data arrays
const int numArrays = std::stoi(item);
if (numArrays >= 1)
{
// Read the first field data array header.
// Additional arrays are silently skipped.
std::getline(inputFile, line, '\n');

StringStreamType fieldStream;
fieldStream << line;
fieldStream >> item; // array name

fieldStream >> item; // numComponents
const unsigned int numComponents = std::stoi(item);

fieldStream >> item; // numTuples
const unsigned int numTuples = std::stoi(item);

fieldStream >> item; // data type
const IOComponentEnum componentType = this->GetComponentTypeFromString(item);

if (this->m_NumberOfPoints == numTuples)
{
this->m_NumberOfPointPixelComponents = numComponents;
this->m_PointPixelType = IOPixelEnum::VARIABLELENGTHVECTOR;
this->m_PointPixelComponentType = componentType;
if (this->m_PointPixelComponentType == IOComponentEnum::UNKNOWNCOMPONENTTYPE)
{
itkExceptionMacro("Unknown point pixel component type");
}
this->m_UpdatePointData = true;
}
}
}
}
}
else if (line.find("CELL_DATA") != std::string::npos)
{
Expand Down Expand Up @@ -788,6 +832,50 @@ VTKPolyDataMeshIO::ReadMeshInformation()
this->m_NumberOfCellPixelComponents = this->m_PointDimension * (this->m_PointDimension + 1) / 2;
this->m_UpdateCellData = true;
}
if (line.find("FIELD") != std::string::npos)
{
StringStreamType sss;
sss << line;

sss >> item; // should be "FIELD"
if (item == "FIELD")
{
sss >> item; // field data name (e.g. "FieldData")
sss >> item; // number of field data arrays
const int numArrays = std::stoi(item);
if (numArrays >= 1)
{
// Read the first field data array header.
// Additional arrays are silently skipped.
std::getline(inputFile, line, '\n');

StringStreamType fieldStream;
fieldStream << line;
fieldStream >> item; // array name

fieldStream >> item; // numComponents
const unsigned int numComponents = std::stoi(item);

fieldStream >> item; // numTuples
const unsigned int numTuples = std::stoi(item);

fieldStream >> item; // data type
const IOComponentEnum componentType = this->GetComponentTypeFromString(item);

if (this->m_NumberOfCells == numTuples)
{
this->m_NumberOfCellPixelComponents = numComponents;
this->m_CellPixelType = IOPixelEnum::VARIABLELENGTHVECTOR;
this->m_CellPixelComponentType = componentType;
if (this->m_CellPixelComponentType == IOComponentEnum::UNKNOWNCOMPONENTTYPE)
{
itkExceptionMacro("Unknown cell pixel component type");
}
this->m_UpdateCellData = true;
}
}
}
}
}
else if (line.find("OFFSETS") != std::string::npos)
{
Expand Down
8 changes: 8 additions & 0 deletions Modules/IO/MeshVTK/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ itk_add_test(
2
1
1)
itk_add_test(
NAME
itkMeshFileReadWriteTestField
COMMAND
ITKIOMeshVTKTestDriver
itkMeshFileReadWriteTest
DATA{Input/gourd.vtk}
${ITK_TEST_OUTPUT_DIR}/gourd.vtk)

set(ITKIOMeshVTKGTests itkVTKPolyDataMeshIOGTest.cxx)

Expand Down
1 change: 1 addition & 0 deletions Modules/IO/MeshVTK/test/Input/gourd.vtk.cid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bafkreidv66i2s5mleluikmvcpq32yziqt7qo3tvc5imncrx4auoimwtdua
Loading