[vtkusers] Re: vtkClipPolyData with vtkBox as implicit function:	doesn't work
    Theodore Sternberg 
    tdsternberg at lbl.gov
       
    Thu Jan 27 15:50:03 EST 2005
    
    
  
OK, now it works better but still not quite as required.  The clipped 
region has rounded corners.  The degree of rounding seems to depend on the 
resolution of the polydata, which is understandable, but it seems that if 
that's the way it works, there should be some "quanta" where the clipping 
would be exact.
-----------------------------------------------------------------------------------
from vtkpython import *
# PolyData to clip:
plane = vtkPlaneSource()
plane.SetOrigin(0,0,0)
plane.SetPoint1(1,0,0)
plane.SetPoint2(0,1,0)
plane.SetResolution(9,9)
# Implicit function to clip against
implicit_box = vtkBox()
implicit_box.SetBounds( 1.0/9,8.0/9, 1.0/9,8.0/9,  -3,3 ) # rounded corners!?
# Clipper
clipper = vtkClipPolyData()
clipper.SetClipFunction( implicit_box )
clipper.SetInput( plane.GetOutput() )
# Boilerplate rendering pipeline stuff
mapper = vtkPolyDataMapper()
mapper.SetInput( clipper.GetOutput() )
actor = vtkActor()
actor.SetMapper( mapper )
renWin = vtkRenderWindow()
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow( renWin )
ren = vtkRenderer()
renWin.AddRenderer( ren )
ren.AddActor( actor )
iren.Initialize()
iren.Start()
-----------------------------------------------------------------------------------
Ted Sternberg
Lawrence Berkeley National Laboratory
    
    
More information about the vtkusers
mailing list