[vtkusers] Cutting a polygon

igorznt igorznt at gmail.com
Mon Dec 27 14:40:26 EST 2010


I have a polydata, and I want to cut it with a plane and see the inside part
filled with ist color. Im sending 2 images and the vtp file im using. the
first one is without cut, and second is with cut.  You can see the cylinder
and the implant in the first, but in the second, you can see the cylinder
cutted and a i line that i putted to show where the implant should be. I
have already tryed this
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/CapClip . I tested it with
simple polygons and it works for cutting, but with others, like the vtp i
sent, it dindt work. Nothing is displayed. For coloring, if  i cut a tube,
and 2 parts of it is cutted, it join both and create a new area. Does anyone
knows how to help.

Here's my code.

#implant.vtp file was sent with mail. It looks perfectly when i don't cut it
#When i cut, i would like to show the part cutted filled with its color
path = os.path.join(constant.RESOURCES_DIR, "implant.vtp")
reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName(path)
reader.Update()

mapper = vtk.vtkPolyDataMapper()
mapper.SetResolveCoincidentTopologyToPolygonOffset()

#Using cut and dont using extract, i could see a cylinder border, but
#the implant, i couldnt see anyway. I dont know if it is because of the
# implant polydata, and if im cutting the right way
cutter = vtk.vtkCutter()
cutter.SetCutFunction(planeCutter) #Plane cutter is a vtk plane
cutter.GenerateCutScalarsOn()
cutter.SetInputConnection(reader.GetOutputPort())
cutter.Update()

extract = vtk.vtkExtractPolyDataGeometry()
extract.SetInputConnection(cutter.GetOutputPort())
extract.ExtractBoundaryCellsOn()
extract.SetImplicitFunction(planeCutter)

mapper.SetInputConnection(extract.GetOutputPort())
mapper.GlobalImmediateModeRenderingOn()   

actor = vtk.vtkActor()
actor.PickableOn()
actor.SetMapper(mapper)

actor.GetProperty().SetColor(self.implantColor)
renderer.AddActor(actor)
-- 
View this message in context: http://vtk.1045678.n5.nabble.com/Cutting-a-polygon-tp3319653p3319653.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list