[vtkusers] vtkStripper question (maybe vtkPolyDataAlgorithm question)
Fahlgren, Eric
efahlgren at lifemodeler.com
Fri Jan 27 17:07:14 EST 2012
I'm missing something fundamental here. I have a script culled from the Python/ClipCow example, boiled down to its basic pieces. Why can't I force the stripper's output object, a vtkPolyData, to feed the STL writer (or indeed use it as input to filters or whatever)? Why is the intermediate vtkPolyData object needed? When I use a different object derived from vtkPolyDataAlgorithm (say a vtkCubeSource), I get the values I expect, it's just the vtkStripper that is behaving in a way I don't expect.
Thanks,
Eric
With line 20 True, the stl contains:
solid ascii
endsolid
With line 20 set to False, we get:
solid ascii
facet normal 0.70014 0.70014 0.140028
outer loop
vertex -0.5 0.44 0.3
vertex -0.5 0.24 1.3
vertex 0.24 -0.5 1.3
endloop
endfacet
endsolid
1 #!/usr/bin/env python
2 # vim: set expandtab softtabstop=3 shiftwidth=3:
3
4 import vtk
5
6 block = vtk.vtkCubeSource()
7 block.SetCenter((0.0, 0.0, 0.8))
8
9 plane = vtk.vtkPlane()
10 plane.SetNormal(1.0,1.0,0.2)
11
12 cutter = vtk.vtkCutter()
13 cutter.SetCutFunction(plane)
14 cutter.SetInputConnection(block.GetOutputPort())
15
16 stripper = vtk.vtkStripper()
17 stripper.SetInputConnection(cutter.GetOutputPort())
18 stripper.Update()
19
20 if True:
21 poly = stripper.GetOutput() # Why doesn't this work?
22 else:
23 poly = vtk.vtkPolyData()
24 poly.SetPoints(stripper.GetOutput().GetPoints())
25 poly.SetPolys (stripper.GetOutput().GetLines())
26
27 writer = vtk.vtkSTLWriter()
28 writer.SetInput(poly)
29 writer.SetFileName("outline.stl")
30 writer.Update()
More information about the vtkusers
mailing list