mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Fix reading global ids of permuted cells
The legacy VTK reader sometimes has to permute cell data because some VTK cells are not directly supported in VTK-m. (For example, triangle strips are not supported. They have to be converted to triangles.) The global and petigree identifiers were not properly getting permuted. This is now fixed.
This commit is contained in:
parent
ef3c4c65c9
commit
d81cbc6e37
8
docs/changelog/read-permuted-global-cell-ids.md
Normal file
8
docs/changelog/read-permuted-global-cell-ids.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Fix reading global ids of permuted cells
|
||||
|
||||
The legacy VTK reader sometimes has to permute cell data because some VTK
|
||||
cells are not directly supported in VTK-m. (For example, triangle strips
|
||||
are not supported. They have to be converted to triangles.)
|
||||
|
||||
The global and petigree identifiers were not properly getting permuted.
|
||||
This is now fixed.
|
@ -664,10 +664,10 @@ void VTKDataSetReaderBase::ReadGlobalOrPedigreeIds(vtkm::cont::Field::Associatio
|
||||
std::string dataType;
|
||||
this->DataFile->Stream >> dataName >> dataType >> std::ws;
|
||||
internal::parseAssert(dataType == "vtkIdType");
|
||||
// vtk writes vtkIdType as int
|
||||
|
||||
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)));
|
||||
vtkm::cont::UnknownArrayHandle data =
|
||||
this->DoReadArrayVariant(association, "int", numElements, 1);
|
||||
this->AddField(dataName, association, data);
|
||||
|
||||
this->SkipArrayMetaData(1);
|
||||
|
@ -140,6 +140,29 @@ void TestReadingV5Format(Format format)
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == 15, "Incorrect number of cells");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().IsType<vtkm::cont::CellSetExplicit<>>(),
|
||||
"Incorrect cellset type");
|
||||
|
||||
for (vtkm::IdComponent fieldIdx = 0; fieldIdx < ds.GetNumberOfFields(); ++fieldIdx)
|
||||
{
|
||||
vtkm::cont::Field field = ds.GetField(fieldIdx);
|
||||
switch (field.GetAssociation())
|
||||
{
|
||||
case vtkm::cont::Field::Association::Points:
|
||||
VTKM_TEST_ASSERT(field.GetData().GetNumberOfValues() == ds.GetNumberOfPoints(),
|
||||
"Field ",
|
||||
field.GetName(),
|
||||
" is the wrong size");
|
||||
break;
|
||||
case vtkm::cont::Field::Association::Cells:
|
||||
VTKM_TEST_ASSERT(field.GetData().GetNumberOfValues() == ds.GetNumberOfCells(),
|
||||
"Field ",
|
||||
field.GetName(),
|
||||
" is the wrong size");
|
||||
break;
|
||||
default:
|
||||
// Could be any size.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TestReadingUnstructuredGridEmpty()
|
||||
|
Loading…
Reference in New Issue
Block a user