Commit 57f51681 authored by Sujin Philip's avatar Sujin Philip
Browse files

Support reading Global and Pedigree ids

parent a01e4335
Pipeline #229052 passed with stage
in 0 seconds
version https://git-lfs.github.com/spec/v1
oid sha256:a12c7f1989c34e670fdc3d1756f5f40a906fe065e6e0b356427f0601b5c90e77
size 1584
version https://git-lfs.github.com/spec/v1
oid sha256:a9b2f98c364d25f6e5c10b85ffac733961e66d224e2a4842ad1f209af7c4501a
size 2418
......@@ -403,6 +403,10 @@ void VTKDataSetReaderBase::ReadAttributes()
{
this->ReadFields(association, size);
}
else if (tag == "GLOBAL_IDS" || tag == "PEDIGREE_IDS")
{
this->ReadGlobalOrPedigreeIds(association, size);
}
else
{
break;
......@@ -655,6 +659,22 @@ void VTKDataSetReaderBase::ReadGlobalFields(std::vector<vtkm::Float32>* visitBou
}
}
void VTKDataSetReaderBase::ReadGlobalOrPedigreeIds(vtkm::cont::Field::Association association,
std::size_t numElements)
{
std::string dataName;
std::string dataType;
this->DataFile->Stream >> dataName >> dataType >> std::ws;
internal::parseAssert(dataType == "vtkIdType");
std::vector<vtkm::Int32> buffer(numElements); // vtk writes vtkIdType as int
this->ReadArray(buffer);
vtkm::cont::UnknownArrayHandle data(vtkm::cont::make_ArrayHandleMove(std::move(buffer)));
this->AddField(dataName, association, data);
this->SkipArrayMetaData(1);
}
class VTKDataSetReaderBase::SkipArrayVariant
{
public:
......
......@@ -168,6 +168,8 @@ private:
VTKM_CONT void ReadTensors(vtkm::cont::Field::Association association, std::size_t numElements);
VTKM_CONT void ReadFields(vtkm::cont::Field::Association association,
std::size_t expectedNumElements);
VTKM_CONT void ReadGlobalOrPedigreeIds(vtkm::cont::Field::Association association,
std::size_t numElements);
protected:
VTKM_CONT void ReadGlobalFields(std::vector<vtkm::Float32>* visitBounds = nullptr);
......
......@@ -125,6 +125,23 @@ void TestReadingUnstructuredGrid(Format format)
"Incorrect cellset type");
}
void TestReadingV5Format(Format format)
{
std::string testFileName = (format == FORMAT_ASCII)
? vtkm::cont::testing::Testing::DataPath("unstructured/simple_unstructured_ascii_v5.vtk")
: vtkm::cont::testing::Testing::DataPath("unstructured/simple_unstructured_bin_v5.vtk");
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 6, "Incorrect number of fields");
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 26, "Incorrect number of points");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
"Incorrect number of points (from cell set)");
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == 15, "Incorrect number of cells");
VTKM_TEST_ASSERT(ds.GetCellSet().IsType<vtkm::cont::CellSetExplicit<>>(),
"Incorrect cellset type");
}
void TestReadingUnstructuredGridEmpty()
{
vtkm::cont::DataSet data =
......@@ -531,6 +548,11 @@ void TestReadingVTKDataSet()
TestSkppingStringFields(FORMAT_ASCII);
std::cout << "Test skipping string fields in BINARY files" << std::endl;
TestSkppingStringFields(FORMAT_BINARY);
std::cout << "Test reading v5 file format in ASCII" << std::endl;
TestReadingV5Format(FORMAT_ASCII);
std::cout << "Test reading v5 file format in BINARY" << std::endl;
TestReadingV5Format(FORMAT_BINARY);
}
int UnitTestVTKDataSetReader(int argc, char* argv[])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment