[vtkusers] Problem with vtkClipPolyData

Eric E. Monson emonson at cs.duke.edu
Mon Oct 4 14:01:52 EDT 2010


Hello Leonhard,

This question comes up a lot on the mailing list. Take a look at one solution in this VTK Journal submission:

http://www.insight-journal.org/browse/publication/726

-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Oct 4, 2010, at 1:48 PM, Leonhard Kahn wrote:

> 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 polydata
> reader1 = vtk.vtkPolyDataReader()
> reader1.SetFileName("auto")
> reader1.Update()
> autoPolyData = reader1.GetOutput()
> 
> #get the second polydata
> reader2 = vtk.vtkPolyDataReader()
> reader2.SetFileName("baum")
> reader2.Update()
> baumPolyData = reader2.GetOutput()
> 
> #clip
> implicitDataSet = vtk.vtkImplicitDataSet()
> implicitDataSet.SetDataSet(baumPolyData)
> clipper = vtk.vtkClipPolyData()
> clipper.SetInput(autoPolyData)
> clipper.SetClipFunction(implicitDataSet)
> clipper.GenerateClippedOutputOn()
> clipper.GenerateClipScalarsOff()
> clipper.SetInsideOut(1)
> 
> #normals
> normalsFilter = vtk.vtkPolyDataNormals()
> normalsFilter.SetInputConnection(clipper.GetOutputPort())
> normalsFilter.SetFeatureAngle(50)
> 
> #strip		
> stripper = vtk.vtkStripper()
> stripper.SetInputConnection(normalsFilter.GetOutputPort())
> stripper.Update()
> polydata3 = stripper.GetOutput()
> 
> #actor
> mapper = vtk.vtkPolyDataMapper()
> mapper.SetInput(clipper.GetOutput())
> actor = vtk.vtkActor()
> actor.SetMapper(mapper3)
> actor.SetPosition(0, -200, 0)
> 
> 
> #render
> renderer.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()
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects athttp://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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101004/6872d35a/attachment.htm>


More information about the vtkusers mailing list