[vtkusers] vtkClipPolyData with vtkBox as implicit function: doesn't work
Theodore Sternberg
tdsternberg at lbl.gov
Wed Jan 26 19:12:57 EST 2005
I'm trying to use vtkClipPolyData with vtkBox to define the implicit
function, and nothing gets clipped. If, instead of vtkBox, I use
vtkPlane, clipping occurs as expected. Here's a short example:
=============================================================
from vtkpython import *
import Tkinter
import vtkRenderWidget
# PolyData
points = vtkPoints()
points.InsertPoint(0,[0,0,0])
points.InsertPoint(1,[1,0,0])
points.InsertPoint(2,[1,1,0])
points.InsertPoint(3,[0,1,0])
rect = vtkCellArray()
rect.InsertNextCell(4)
for p in range(0,4):
rect.InsertCellPoint(p)
poly_data = vtkPolyData()
poly_data.SetPolys(rect)
poly_data.SetPoints(points)
# Implicit function to clip against (doesn't work)
implicit_box = vtkBox()
implicit_box.SetBounds( 0.4,0.6, 0.1,0.9, 0,0 )
# Plane to clip against (works)
clip_plane = vtkPlane()
clip_plane.SetOrigin( 0.4,0.9,0 )
clip_plane.SetNormal( 0,1,0 )
# Clipper
clipper = vtkClipPolyData()
clipper.SetClipFunction( implicit_box ) # doesn't work
#clipper.SetClipFunction( clip_plane ) # works!
clipper.GenerateClipScalarsOn()
clipper.SetInput( poly_data )
clipper.SetValue( 0.0 )
# 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()
=============================================================
More information about the vtkusers
mailing list