[vtkusers] Problem with vtkClipPolyData

Leonhard Kahn graviija at hotmail.com
Mon Oct 4 13:48:21 EDT 2010


Hello, 
 I am trying to intersect two vtkPolyData together but I can't seem to find out how. The two polydatas are complex shapes and not just some vtkSphere or vtkCube. They are models of cars, animals and humans. 
I have tried using vtkClipPolyData to intersect them. I used one of them as the vtkImplicitDataSet and set it as the implicit function. Unfortunately, this does not seem to work. It always return the original polydata. The only thing vtkImplicitDataSet seem to require is for the data set to contain scalars. In my case, they both do. 
Did anyone ever clip two complex polydatas together (not vtkSphere, plane, cube, etc)? 
Is there something else that I am missing?
Is what I am trying to do even possible with vtkClipPolyData?  If not, what else can I try?
Thanks
Leonhard
Here is an example of what I am doing.
#get the first polydatareader1 = vtk.vtkPolyDataReader()reader1.SetFileName("auto")reader1.Update()autoPolyData = reader1.GetOutput()
#get the second polydatareader2 = vtk.vtkPolyDataReader()reader2.SetFileName("baum")reader2.Update()baumPolyData = reader2.GetOutput()
#clipimplicitDataSet = vtk.vtkImplicitDataSet()implicitDataSet.SetDataSet(baumPolyData)clipper = vtk.vtkClipPolyData()clipper.SetInput(autoPolyData)clipper.SetClipFunction(implicitDataSet)clipper.GenerateClippedOutputOn()clipper.GenerateClipScalarsOff()clipper.SetInsideOut(1)
#normalsnormalsFilter = vtk.vtkPolyDataNormals()normalsFilter.SetInputConnection(clipper.GetOutputPort())normalsFilter.SetFeatureAngle(50)
#strip		stripper = vtk.vtkStripper()stripper.SetInputConnection(normalsFilter.GetOutputPort())stripper.Update()polydata3 = stripper.GetOutput()
#actormapper = vtk.vtkPolyDataMapper()mapper.SetInput(clipper.GetOutput())actor = vtk.vtkActor()actor.SetMapper(mapper3)actor.SetPosition(0, -200, 0)

#renderrenderer.AddActor(actor)renderer.SetBackground(0.8, 0.8, 0.8)renWin = vtk.vtkRenderWindow()renWin.AddRenderer(renderer)renWin.SetSize(500, 500)iren = vtk.vtkRenderWindowInteractor()iren.SetRenderWindow(renWin)style = vtk.vtkInteractorStyleTrackballCamera()iren.SetInteractorStyle(style)iren.Initialize()renWin.Render()iren.Start() 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101004/b353bbad/attachment.htm>


More information about the vtkusers mailing list