[vtkusers] Cutting a cylinder out of a cube

Tilo Junge pult34 at gmx.de
Fri Jul 27 04:32:48 EDT 2007


Hello.

I tried to cut a cylinder out of a cube, but it does not work right.
I use python and my code looks like this:

import vtkpython

cylinder = vtkpython.vtkCylinder()
cylinder.SetRadius(0.25)
cylinder.SetCenter(0.0, 0.0, 0.0)
vertPlane = vtkpython.vtkPlane()
vertPlane.SetOrigin(0, -2, 0)
vertPlane.SetNormal(0, -1, 0)
basePlane = vtkpython.vtkPlane()
basePlane.SetOrigin(0, 2, 0)
basePlane.SetNormal(0, 1, 0)

cube = vtkpython.vtkCubeSource()
cube.SetXLength(2.0)
cube.SetYLength(2.0)
cube.SetZLength(2.0)
cube.SetCenter(0.0, 0.0, 0.0)

theCylinder = vtkpython.vtkImplicitBoolean()
theCylinder.SetOperationTypeToIntersection()
theCylinder.AddFunction(cylinder)
theCylinder.AddFunction(vertPlane)
theCylinder.AddFunction(basePlane)

clipper = vtkpython.vtkClipPolyData()
clipper.SetInput(cube.GetOutput())
clipper.SetClipFunction(theCylinder)
clipper.InsideOutOff()

mapper = vtkpython.vtkPolyDataMapper()
mapper.SetInput(clipper.GetOutput())

actor = vtkpython.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(0, 1, 0)

ren1= vtkpython.vtkRenderer()
ren1.AddActor(actor)
ren1.SetBackground(1, 1, 1)

renWin = vtkpython.vtkRenderWindow()
renWin.AddRenderer( ren1 )
renWin.SetSize( 500, 500 )
iren = vtkpython.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

iren.Initialize()
renWin.Render()
iren.Start()

I also tried to use vtkCutter, but the result isnt what I wanted either.
Maybe someone can help me?

Thanks
-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger



More information about the vtkusers mailing list