[vtkusers] Need help with cutting multiple vtkpolydata files with vtkcutter

nedc dnomdec.codes at gmail.com
Mon Jul 4 05:52:35 EDT 2011


Hi all,

I am trying to cut multiple vtkPolyData  with the same cut plane and display
it on a screen.

I tried the following (modified from
Examples_VisualizationAlgorithms_Python_ClipCow.py) but it didn't work.  The
plane only cut the first polydata, but not the second one.  Help is much
appreciated.  Thanks!!

cow = vtk.vtkBYUReader()
cow.SetGeometryFileName(VTK_DATA_ROOT + "/Data/Viewpoint/cow.g")
cowNormals = vtk.vtkPolyDataNormals()
cowNormals.SetInputConnection(cow.GetOutputPort())

plane = vtk.vtkPlane()
plane.SetOrigin(0.25, 0, 0)
plane.SetNormal(-1, -1, 0)

# transform the geometry to get the second polydata so the cut outline will
look different.
tf0 = vtk.vtkTransform()
tpdf0 = vtk.vtkTransformPolyDataFilter()
tpdf0.SetInputConnection(cow.GetOutputPort())
tpdf0.SetTransform(tf0)
tf0.Translate(0.1,0,0)
tf0.RotateX(90)
tpdf0.Update()a

cutEdges = vtk.vtkCutter()

cutEdges.INPUT_IS_REPEATABLE().Set(cutEdges.GetInputPortInformation(0),1)
cutEdges.SetInputConnection(cowNormals.GetOutputPort())
cutEdges.AddInputConnection(tpdf0.GetOutputPort())
cutEdges.SetCutFunction(plane)
cutEdges.GenerateCutScalarsOn()
cutEdges.SetValue(0, 0.5)

cutMapper = vtk.vtkPolyDataMapper()
cutMapper.SetInputConnection(cutEdges.GetOutputPort())
cutActor = vtk.vtkActor()
cutActor.SetMapper(cutMapper)
cutActor.GetProperty().SetColor(peacock)

# Create graphics stuff
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

# Add the actors to the renderer, set the background and size
ren.AddActor(cutActor)
ren.SetBackground(1, 1, 1)
ren.ResetCamera()
ren.GetActiveCamera().Azimuth(30)
ren.GetActiveCamera().Elevation(30)
ren.GetActiveCamera().Dolly(1.5)
ren.ResetCameraClippingRange()

renWin.SetSize(300, 300)
iren.Initialize()


--
View this message in context: http://vtk.1045678.n5.nabble.com/Need-help-with-cutting-multiple-vtkpolydata-files-with-vtkcutter-tp4549538p4549538.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list