[vtkusers] vtkStripper question (maybe vtkPolyDataAlgorithm question)

Bill Lorensen bill.lorensen at gmail.com
Sat Jan 28 16:28:05 EST 2012


I prefer "clever" to "kludgy"

Bill

On Fri, Jan 27, 2012 at 6:00 PM, David Gobbi <david.gobbi at gmail.com> wrote:
> Hi Eric,
>
> The issue here is that the output of vtkCutter is no a polygon, it is
> a set of lines that form a contour.  So the goal here should be to
> triangulate the output of the cutter, and then write the result to a
> file with the vtkSTLWriter.
>
> The ClipCow example demonstrates a kludgy way of doing the
> triangulation: the contour is converted into a continuous polyline
> with vtkStripper, and then VTK is fooled into interpreting that
> polyline as a polygon.
>
> To answer your question about the stripper, though, the stripper is
> doing exactly what it should: it takes all of the line segments that
> are produced by the cutter and joins them end-to-end to create a
> single polyline.  This is how stripper behaves when given lines as
> input.  (When given triangles as input, it produces triangle strips...
> but that isn't the case here because the output of your vtkCutter is
> lines, not triangles).
>
>  - David
>
>
> On Fri, Jan 27, 2012 at 3:07 PM, Fahlgren, Eric
> <efahlgren at lifemodeler.com> wrote:
>> 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()
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers



-- 
Unpaid intern in BillsBasement at noware dot com



More information about the vtkusers mailing list