Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
iMSTK
iMSTK
Commits
6e20e88b
Commit
6e20e88b
authored
May 17, 2021
by
Andrew Wilson
🐘
Browse files
ENH: Can now read LineMesh's from VTK files
parent
6fb6e835
Changes
2
Hide whitespace changes
Inline
Side-by-side
Source/Geometry/imstkGeometryUtilities.cpp
View file @
6e20e88b
...
...
@@ -360,6 +360,12 @@ GeometryUtils::copyToLineMesh(vtkSmartPointer<vtkPolyData> vtkMesh)
std
::
shared_ptr
<
VecDataArray
<
double
,
3
>>
vertices
=
copyToVecDataArray
(
vtkMesh
->
GetPoints
());
std
::
shared_ptr
<
VecDataArray
<
int
,
2
>>
cells
=
copyToVecDataArray
<
2
>
(
vtkMesh
->
GetPolys
());
// If polys is empty use lines instead
if
(
cells
->
size
()
==
0
)
{
cells
=
copyToVecDataArray
<
2
>
(
vtkMesh
->
GetLines
());
}
auto
mesh
=
std
::
make_unique
<
LineMesh
>
();
mesh
->
initialize
(
vertices
,
cells
);
...
...
Source/MeshIO/imstkVTKMeshIO.cpp
View file @
6e20e88b
...
...
@@ -250,7 +250,18 @@ VTKMeshIO::readVtkGenericFormatData(const std::string& filePath)
if
(
vtkSmartPointer
<
vtkPolyData
>
vtkMesh
=
reader
->
GetPolyDataOutput
())
{
return
GeometryUtils
::
copyToSurfaceMesh
(
vtkMesh
);
// Try to convert to surface mesh, if no elements exist try reading as a line mesh
std
::
shared_ptr
<
SurfaceMesh
>
surfMesh
=
GeometryUtils
::
copyToSurfaceMesh
(
vtkMesh
);
if
(
surfMesh
->
getNumTriangles
()
>
0
)
{
return
surfMesh
;
}
std
::
shared_ptr
<
LineMesh
>
lineMesh
=
GeometryUtils
::
copyToLineMesh
(
vtkMesh
);
if
(
lineMesh
->
getNumLines
()
>
0
)
{
return
lineMesh
;
}
return
GeometryUtils
::
copyToPointSet
(
vtkMesh
);
}
if
(
vtkUnstructuredGrid
*
vtkMesh
=
reader
->
GetUnstructuredGridOutput
())
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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