Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VTK
VTK-m
Commits
52cecefb
Commit
52cecefb
authored
Sep 01, 2020
by
Kenneth Moreland
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash when loading poly data with no cells
parent
3e398bbb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
0 deletions
+41
-0
data/data/unstructured/empty_poly.vtk
data/data/unstructured/empty_poly.vtk
+3
-0
data/data/unstructured/empty_unstructured.vtk
data/data/unstructured/empty_unstructured.vtk
+3
-0
vtkm/io/internal/VTKDataSetCells.h
vtkm/io/internal/VTKDataSetCells.h
+9
-0
vtkm/io/testing/UnitTestVTKDataSetReader.cxx
vtkm/io/testing/UnitTestVTKDataSetReader.cxx
+26
-0
No files found.
data/data/unstructured/empty_poly.vtk
0 → 100644
LFS
View file @
52cecefb
File added
data/data/unstructured/empty_unstructured.vtk
0 → 100644
LFS
View file @
52cecefb
File added
vtkm/io/internal/VTKDataSetCells.h
View file @
52cecefb
...
...
@@ -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
)
...
...
vtkm/io/testing/UnitTestVTKDataSetReader.cxx
View file @
52cecefb
...
...
@@ -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
);
...
...
Kenneth Moreland
@kmorel
mentioned in commit
278ab6c5
·
Sep 02, 2020
mentioned in commit
278ab6c5
mentioned in commit 278ab6c5042e3a2832f583761da1f99666820caf
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment