<html><head><base href="x-msg://45/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello Leonhard,<div><br></div><div>This question comes up a lot on the mailing list. Take a look at one solution in this VTK Journal submission:</div><div><br></div><div><a href="http://www.insight-journal.org/browse/publication/726">http://www.insight-journal.org/browse/publication/726</a></div><div><br></div><div>-Eric</div><div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div>------------------------------------------------------</div><div>Eric E Monson</div><div>Duke Visualization Technology Group</div><div><span class="Apple-style-span" style="font-size: medium;"><br></span></div></span>
</div>
<br><div><div>On Oct 4, 2010, at 1:48 PM, Leonhard Kahn wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: 12pt; ">Hello, </span><div style="font-family: Helvetica; font-size: 12pt; "><br><div> 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. </div><div><br></div><div>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. </div><div><br></div><div>Did anyone ever clip two complex polydatas together (not vtkSphere, plane, cube, etc)? </div><div><br></div><div>Is there something else that I am missing?</div><div><br></div><div>Is what I am trying to do even possible with vtkClipPolyData? If not, what else can I try?</div><div><br></div><div>Thanks</div><div><br></div><div>Leonhard</div><div><br></div><div></div><div>Here is an example of what I am doing.</div><div><br></div><div>#get the first polydata</div><div><div>reader1 = vtk.vtkPolyDataReader()</div><div>reader1.SetFileName("auto")</div><div>reader1.Update()</div><div>autoPolyData = reader1.GetOutput()</div></div><div><br></div><div>#get the second polydata</div><div><div>reader2 = vtk.vtkPolyDataReader()</div><div>reader2.SetFileName("baum")</div><div>reader2.Update()</div><div>baumPolyData = reader2.GetOutput()</div></div><div><br></div><div><div>#clip</div><div>implicitDataSet = vtk.vtkImplicitDataSet()</div><div>implicitDataSet.SetDataSet(baumPolyData)</div><div>clipper = vtk.vtkClipPolyData()</div><div>clipper.SetInput(autoPolyData)</div><div>clipper.SetClipFunction(implicitDataSet)</div><div>clipper.GenerateClippedOutputOn()</div><div>clipper.GenerateClipScalarsOff()</div><div>clipper.SetInsideOut(1)</div></div><div><br></div><div>#normals</div><div><div>normalsFilter = vtk.vtkPolyDataNormals()</div><div>normalsFilter.SetInputConnection(clipper.GetOutputPort())</div><div>normalsFilter.SetFeatureAngle(50)</div><div><span class="Apple-tab-span" style="white-space: pre; "><br></span></div><div>#strip<span class="Apple-tab-span" style="white-space: pre; ">                </span></div><div>stripper = vtk.vtkStripper()</div><div>stripper.SetInputConnection(normalsFilter.GetOutputPort())</div><div>stripper.Update()</div><div>polydata3 = stripper.GetOutput()</div><div><br></div><div>#actor</div><div>mapper = vtk.vtkPolyDataMapper()</div><div>mapper.SetInput(clipper.GetOutput())</div><div>actor = vtk.vtkActor()</div><div>actor.SetMapper(mapper3)</div><div>actor.SetPosition(0, -200, 0)</div><div><br></div><div><br></div><div>#render</div><div>renderer.AddActor(actor)</div><div>renderer.SetBackground(0.8, 0.8, 0.8)</div><div>renWin = vtk.vtkRenderWindow()</div><div>renWin.AddRenderer(renderer)</div><div>renWin.SetSize(500, 500)</div><div>iren = vtk.vtkRenderWindowInteractor()</div><div>iren.SetRenderWindow(renWin)</div><div>style = vtk.vtkInteractorStyleTrackballCamera()</div><div>iren.SetInteractorStyle(style)</div><div>iren.Initialize()</div><div>renWin.Render()</div><div>iren.Start()</div></div></div>_______________________________________________<br>Powered by<span class="Apple-converted-space"> </span><a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the VTK FAQ at:<a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></div></blockquote></div><br></div></body></html>