Skip to content

Commit

Permalink
Merge pull request #13 from bostongfx/11-set-active-arrays
Browse files Browse the repository at this point in the history
Set active arrays in vtk polydata
  • Loading branch information
haehn authored Feb 26, 2021
2 parents b0b83c1 + f922784 commit 81ea3b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion trako/gltfi2vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def convert(input, output=None, verbose=True):
points = vtk.vtkPoints()
points.SetData(numpy_support.numpy_to_vtk(draco_points_reshaped))
polydata.SetPoints(points)
pointdata = polydata.GetPointData()

#
# scalars
Expand All @@ -101,11 +102,16 @@ def convert(input, output=None, verbose=True):
scalarname = k[1:]
vtkArr = numpy_support.numpy_to_vtk(draco_points_reshaped)
vtkArr.SetName(scalarname)
polydata.GetPointData().AddArray(vtkArr)
pointdata.AddArray(vtkArr)

if verbose:
print('Restored scalar', scalarname)

if draco_points_reshaped.shape[1] == 1 and pointdata.GetScalars() is None:
pointdata.SetScalars(vtkArr)

if draco_points_reshaped.shape[1] == 9 and pointdata.GetTensors() is None:
pointdata.SetTensors(vtkArr)
#
#
# now the indices / cell data
Expand Down
2 changes: 1 addition & 1 deletion trako/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
import matplotlib.pyplot as plt
#import matplotlib.pyplot as plt
import vtk
from vtk.util import numpy_support

Expand Down

0 comments on commit 81ea3b5

Please sign in to comment.