[vtkusers] vtkPolyDataSilhouette to vtkPolyData (in Python)

Shawnoah Pollock shawnoah.pollock at gmail.com
Wed Nov 9 11:32:34 EST 2016


Hello,

I am working with VTK 6.3.0 in Python.  I am importing an stl model and
creating a vtkActor.  Then I am taking that actor and creating a silhouette
with vtkPolyDataSilhouette. Once I have the silhouette created, I am able
to make it map it's output to an actor and render it in the scene.  This
works just great.  My problem is that I also want to create another copy of
this silhouette and project it from a specified viewpoint onto a plane.  If
I could somehow get a vtkPolyData as an output from vtkPolyDataSilhouette,
I could do a deepcopy to a new vtkPolyData, do the projection and map that
to a new vtkActor.  For some reason, everytime I try to get a vtkPolyData
from the vtkPolyDataSilhouette it is empty (no cells, no points, no lines,
no anything).  I am sure I am just missing something simple, but I have
been looking for 2 days and am stumped.  Doesn't help that I am new to VTK.

Here is a code snippet:

                silhouette = vtk.vtkPolyDataSilhouette()
                silhouette.ReleaseDataFlagOff()

silhouette.SetInputData(actor.GetMapper().GetInputAsDataSet())
                silhouette.SetCamera(camera)
                silhouette.SetEnableFeatureAngle(0)
                silhouette_mapper = vtk.vtkPolyDataMapper()

silhouette_mapper.SetInputConnection(silhouette.GetOutputPort())
                silhouette_actor = vtk.vtkActor()
                silhouette_actor.SetMapper(silhouette_mapper)
                self.renderer.AddActor(silhouette_actor)
                self.viewer.Render()

To get the vtkPolyData, I have tried  polydata = silhouette.GetOutput() as
well as silhouette_actor.GetMapper().GetInputAsDataSet().  I've tried to
connect the output of the vtkSilhouette to another algorithm and grab the
output...  nothing seems to return anything but an empty polydata... yet,
the silhouette_actor renders as expected.  Please help...

SHAWN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161109/63331b83/attachment.html>


More information about the vtkusers mailing list