<html><body>
<p><tt>&quot;Tilo Junge&quot; &lt;pult34@gmx.de&gt; wrote on 27/07/2007 20:32:48:<br>
<br>
&gt; Hello.<br>
&gt; <br>
&gt; I tried to cut a cylinder out of a cube, but it does not work right.<br>
&gt; I use python and my code looks like this:<br>
&gt; <br>
&gt; import vtkpython<br>
&gt; <br>
&gt; cylinder = vtkpython.vtkCylinder()<br>
&gt; cylinder.SetRadius(0.25)<br>
&gt; cylinder.SetCenter(0.0, 0.0, 0.0)<br>
&gt; vertPlane = vtkpython.vtkPlane()<br>
&gt; vertPlane.SetOrigin(0, -2, 0)<br>
&gt; vertPlane.SetNormal(0, -1, 0)<br>
&gt; basePlane = vtkpython.vtkPlane()<br>
&gt; basePlane.SetOrigin(0, 2, 0)<br>
&gt; basePlane.SetNormal(0, 1, 0)<br>
&gt; <br>
&gt; cube = vtkpython.vtkCubeSource()<br>
&gt; cube.SetXLength(2.0)<br>
&gt; cube.SetYLength(2.0)<br>
&gt; cube.SetZLength(2.0)<br>
&gt; cube.SetCenter(0.0, 0.0, 0.0)<br>
&gt; <br>
&gt; theCylinder = vtkpython.vtkImplicitBoolean()<br>
&gt; theCylinder.SetOperationTypeToIntersection()<br>
&gt; theCylinder.AddFunction(cylinder)<br>
&gt; theCylinder.AddFunction(vertPlane)<br>
&gt; theCylinder.AddFunction(basePlane)<br>
&gt; <br>
&gt; clipper = vtkpython.vtkClipPolyData()<br>
&gt; clipper.SetInput(cube.GetOutput())<br>
&gt; clipper.SetClipFunction(theCylinder)<br>
&gt; clipper.InsideOutOff()<br>
&gt; <br>
&gt; mapper = vtkpython.vtkPolyDataMapper()<br>
&gt; mapper.SetInput(clipper.GetOutput())<br>
&gt; <br>
&gt; actor = vtkpython.vtkActor()<br>
&gt; actor.SetMapper(mapper)<br>
&gt; actor.GetProperty().SetColor(0, 1, 0)<br>
&gt; <br>
&gt; ren1= vtkpython.vtkRenderer()<br>
&gt; ren1.AddActor(actor)<br>
&gt; ren1.SetBackground(1, 1, 1)<br>
&gt; <br>
&gt; renWin = vtkpython.vtkRenderWindow()<br>
&gt; renWin.AddRenderer( ren1 )<br>
&gt; renWin.SetSize( 500, 500 )<br>
&gt; iren = vtkpython.vtkRenderWindowInteractor()<br>
&gt; iren.SetRenderWindow(renWin)<br>
&gt; <br>
&gt; iren.Initialize()<br>
&gt; renWin.Render()<br>
&gt; iren.Start()<br>
&gt; <br>
&gt; I also tried to use vtkCutter, but the result isnt what I wanted either.<br>
&gt; Maybe someone can help me?</tt><br>
<br>
<tt>vtkCubeSource probably generates just 6 polygons (I've never actually used it), which is exactly what it should do. But using this as the input to clipping will not give what you expect. Clipping removes any cells completely inside the implicit surface and it clips any cells that have some points inside the surface and some points outside the surface. The points defining your cube are ALL outside the implicit surface so nothing is clipped! </tt><br>
<br>
<tt>What you need are cube surfaces that are made of many cells, some inside, some outside and some crossing the implicit surface, then you will see clipping. With say just 4 cells per cube surface you will get a very ugly square hole. As the number of cells (and points) increases you will get a better approximation to the circular hole you are expecting.</tt><br>
<br>
<tt>To get more cells/points on the cube surfaces you could use: </tt><br>
<tt>vtkPlaneSource (one per cube surface, thats 6 of them) and use SetResolution to increase the number of cells.</tt><br>
<tt>vtkLinearSubdivisionFilter to subdivide the cells in your vtkCubeSource, try 2 or 3 iterations for a start.</tt><br>
<br>
<tt>&nbsp; &nbsp;how do I know this.... yep I have been exactly where you are</tt><br>
<br>
<tt>good luck, Dave P</tt><br>
<tt><br>
&gt; <br>
&gt; Thanks<br>
&gt; -- <br>
&gt; Psssst! Schon vom neuen GMX MultiMessenger gehört?<br>
&gt; Der kanns mit allen: <a href="http://www.gmx.net/de/go/multimessenger">http://www.gmx.net/de/go/multimessenger</a><br>
&gt; _______________________________________________<br>
&gt; This is the private VTK discussion list. <br>
&gt; Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk">http://www.vtk</a>.<br>
&gt; org/Wiki/VTK_FAQ<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</tt></body></html>