Merge topic 'vtk-files-no-cells'
66a4a23eb Fix issue of getting pointer from std::vector of size 0 3f8da6e7e Fix some debugging code that should not have been there 52cecefba Fix crash when loading poly data with no cells Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2254
This commit is contained in:
commit
278ab6c504
3
data/data/unstructured/empty_poly.vtk
Normal file
3
data/data/unstructured/empty_poly.vtk
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3d0ddc7c712a6d544db85660cd9d325884892b18d6f0ed451361aaeae2a96413
|
||||
size 204
|
3
data/data/unstructured/empty_unstructured.vtk
Normal file
3
data/data/unstructured/empty_unstructured.vtk
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:75b5601eb23b1724d5309e69a51839615bce625f6e7641b52dc3d06e10b0c5ee
|
||||
size 745
|
@ -140,12 +140,14 @@ public:
|
||||
|
||||
void TestContourWedges() const
|
||||
{
|
||||
std::cout << "Testing Contour filter on wedge cells" << std::endl;
|
||||
|
||||
auto pathname = vtkm::cont::testing::Testing::DataPath("unstructured/wedge_cells.vtk");
|
||||
vtkm::io::VTKDataSetReader reader(pathname);
|
||||
|
||||
vtkm::cont::DataSet dataSet = reader.ReadDataSet();
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
vtkm::cont::CellSetSingleType<> cellSet;
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> fieldArray;
|
||||
|
@ -267,7 +267,7 @@ void VTKDataSetReaderBase::ReadCells(vtkm::cont::ArrayHandle<vtkm::Id>& connecti
|
||||
std::vector<vtkm::Int32> buffer(static_cast<std::size_t>(numInts));
|
||||
this->ReadArray(buffer);
|
||||
|
||||
vtkm::Int32* buffp = &buffer[0];
|
||||
vtkm::Int32* buffp = buffer.data();
|
||||
auto connectivityPortal = connectivity.WritePortal();
|
||||
auto numIndicesPortal = numIndices.WritePortal();
|
||||
for (vtkm::Id i = 0, connInd = 0; i < numCells; ++i)
|
||||
@ -292,7 +292,7 @@ void VTKDataSetReaderBase::ReadShapes(vtkm::cont::ArrayHandle<vtkm::UInt8>& shap
|
||||
std::vector<vtkm::Int32> buffer(static_cast<std::size_t>(numCells));
|
||||
this->ReadArray(buffer);
|
||||
|
||||
vtkm::Int32* buffp = &buffer[0];
|
||||
vtkm::Int32* buffp = buffer.data();
|
||||
auto shapesPortal = shapes.WritePortal();
|
||||
for (vtkm::Id i = 0; i < numCells; ++i)
|
||||
{
|
||||
|
@ -65,8 +65,7 @@ void VTKUnstructuredGridReader::Read()
|
||||
vtkm::io::internal::FixupCellSet(connectivity, numIndices, shapes, permutation);
|
||||
this->SetCellsPermutation(permutation);
|
||||
|
||||
//DRP
|
||||
if (false) //vtkm::io::internal::IsSingleShape(shapes))
|
||||
if (vtkm::io::internal::IsSingleShape(shapes))
|
||||
{
|
||||
vtkm::cont::CellSetSingleType<> cellSet;
|
||||
cellSet.Fill(
|
||||
|
@ -210,6 +210,15 @@ inline void FixupCellSet(vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
|
||||
inline bool IsSingleShape(const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes)
|
||||
{
|
||||
if (shapes.GetNumberOfValues() < 1)
|
||||
{
|
||||
// If the data has no cells, is it single shape? That would make sense, but having
|
||||
// a single shape cell set requires you to slect a shape, and there are no cells to
|
||||
// make that selection from. We could get around that, but it's easier just to treat
|
||||
// it as a general explicit grid.
|
||||
return false;
|
||||
}
|
||||
|
||||
auto shapesPortal = shapes.ReadPortal();
|
||||
vtkm::UInt8 shape0 = shapesPortal.Get(0);
|
||||
for (vtkm::Id i = 1; i < shapes.GetNumberOfValues(); ++i)
|
||||
|
@ -62,6 +62,17 @@ void TestReadingPolyData(Format format)
|
||||
"Incorrect cellset type");
|
||||
}
|
||||
|
||||
void TestReadingPolyDataEmpty()
|
||||
{
|
||||
vtkm::cont::DataSet data =
|
||||
readVTKDataSet(vtkm::cont::testing::Testing::DataPath("unstructured/empty_poly.vtk"));
|
||||
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfPoints() == 8);
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfCells() == 0);
|
||||
VTKM_TEST_ASSERT(data.GetCellSet().GetNumberOfPoints() == 8);
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfFields() == 1);
|
||||
}
|
||||
|
||||
void TestReadingStructuredPoints(Format format)
|
||||
{
|
||||
std::string testFileName = (format == FORMAT_ASCII)
|
||||
@ -114,6 +125,17 @@ void TestReadingUnstructuredGrid(Format format)
|
||||
"Incorrect cellset type");
|
||||
}
|
||||
|
||||
void TestReadingUnstructuredGridEmpty()
|
||||
{
|
||||
vtkm::cont::DataSet data =
|
||||
readVTKDataSet(vtkm::cont::testing::Testing::DataPath("unstructured/empty_unstructured.vtk"));
|
||||
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfPoints() == 26);
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfCells() == 0);
|
||||
VTKM_TEST_ASSERT(data.GetCellSet().GetNumberOfPoints() == 26);
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfFields() == 2);
|
||||
}
|
||||
|
||||
void TestReadingUnstructuredGridVisIt(Format format)
|
||||
{
|
||||
VTKM_TEST_ASSERT(format == FORMAT_ASCII);
|
||||
@ -452,6 +474,8 @@ void TestReadingVTKDataSet()
|
||||
TestReadingPolyData(FORMAT_ASCII);
|
||||
std::cout << "Test reading VTK Polydata file in BINARY" << std::endl;
|
||||
TestReadingPolyData(FORMAT_BINARY);
|
||||
std::cout << "Test reading VTK Polydata with no cells" << std::endl;
|
||||
TestReadingPolyDataEmpty();
|
||||
std::cout << "Test reading VTK StructuredPoints file in ASCII" << std::endl;
|
||||
TestReadingStructuredPoints(FORMAT_ASCII);
|
||||
|
||||
@ -461,6 +485,8 @@ void TestReadingVTKDataSet()
|
||||
TestReadingUnstructuredGrid(FORMAT_ASCII);
|
||||
std::cout << "Test reading VTK UnstructuredGrid file in BINARY" << std::endl;
|
||||
TestReadingUnstructuredGrid(FORMAT_BINARY);
|
||||
std::cout << "Test reading VTK UnstructuredGrid with no cells" << std::endl;
|
||||
TestReadingUnstructuredGridEmpty();
|
||||
|
||||
std::cout << "Test reading VTK RectilinearGrid file in ASCII" << std::endl;
|
||||
TestReadingRectilinearGrid1(FORMAT_ASCII);
|
||||
|
Loading…
Reference in New Issue
Block a user