Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
dorie
dorie
Commits
4335909f
Commit
4335909f
authored
Feb 22, 2019
by
Lukas Riedel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only load required components of VTK Python lib
Also fix a bug where cell data arrays would be ignored.
parent
2b3ae9a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
python/dorie/dorie/utilities/vtktools/vtkreader.py
python/dorie/dorie/utilities/vtktools/vtkreader.py
+14
-9
No files found.
python/dorie/dorie/utilities/vtktools/vtkreader.py
View file @
4335909f
import
vtk
from
vtk
import
vtkXMLGenericDataObjectReader
,
\
vtkCellTreeLocator
,
\
vtkDataSet
,
\
vtkGenericCell
,
\
reference
import
numpy
as
np
class
VTKReader
:
...
...
@@ -8,13 +12,13 @@ class VTKReader:
self
.
_data_array
=
None
# set up the reader
self
.
_reader
=
vtk
.
vtkXMLGenericDataObjectReader
()
self
.
_reader
=
vtkXMLGenericDataObjectReader
()
self
.
_reader
.
SetFileName
(
file_name
)
self
.
_reader
.
Update
()
self
.
_dataset
=
vtk
.
vtkDataSet
.
SafeDownCast
(
self
.
_reader
.
GetOutput
())
self
.
_dataset
=
vtkDataSet
.
SafeDownCast
(
self
.
_reader
.
GetOutput
())
# build the locator
self
.
_locator
=
vtk
.
vtkCellTreeLocator
()
self
.
_locator
=
vtkCellTreeLocator
()
self
.
_locator
.
SetDataSet
(
self
.
_dataset
)
self
.
_locator
.
BuildLocator
()
...
...
@@ -22,7 +26,7 @@ class VTKReader:
self
.
set_data_array
(
array_name
,
data_type
)
# cache for cell and ID
self
.
_cell
=
vtk
.
vtkGenericCell
()
self
.
_cell
=
vtkGenericCell
()
self
.
_cell_id
=
-
1
def
set_data_array
(
self
,
array_name
,
data_type
=
None
):
...
...
@@ -39,13 +43,14 @@ class VTKReader:
if
data_type
==
"cell"
or
data_type
is
None
:
# retrieve cell data array...
self
.
_data_array
=
retrieve_array
(
self
.
_dataset
.
GetCellData
(),
array_name
)
array_name
)
self
.
_eval
=
self
.
__eval_cell
if
data_type
==
"vertex"
or
data_type
is
None
:
if
self
.
_data_array
is
None
\
and
(
data_type
==
"vertex"
or
data_type
is
None
):
# ...or vertex data array
self
.
_data_array
=
retrieve_array
(
self
.
_dataset
.
GetPointData
(),
array_name
)
array_name
)
self
.
_eval
=
self
.
__eval_vertex
if
self
.
_data_array
is
None
:
...
...
@@ -71,7 +76,7 @@ class VTKReader:
# unused stubs
zeros
=
[
0
,
0
,
0
]
zero_ref
=
vtk
.
reference
(
0
)
zero_ref
=
reference
(
0
)
# interpolation weights
weights
=
np
.
zeros
(
10
)
...
...
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