[vtkusers] vtkBooleanOperationPolyDataFilter including disconnected faces
Fahlgren, Eric
efahlgren at lifemodeler.com
Fri Jan 20 14:57:34 EST 2012
http://www.lifemodeler.com/eric/badBoolean.png
Two problems, possibly related:
1) When I perform two successive Boolean operations, extraneous faces from the second solid of the final operation are left in the polydata.
2) Note the faces in the red box of the linked image. The normals appear to be incorrect, there are occasional dark regions in odd places on the resulting polydata.
Is there a filter I can add after the Boolean operations to eliminate the extra faces? How about straightening up the normals?
Thanks,
Eric
#!/usr/bin/env python
import vtk
LHS = vtk.vtkCubeSource()
LHS.SetCenter((0.0, 0.0, 0.8))
if 1:
triangle = vtk.vtkTriangleFilter()
triangle.SetInputConnection(LHS.GetOutputPort())
LHS = triangle
if 1:
RHS = vtk.vtkSphereSource()
RHS.SetCenter((0.5, 0.0, 0.2))
RHS.SetRadius(1.0); RHS.SetPhiResolution(40); RHS.SetThetaResolution(40)
boolOp = vtk.vtkBooleanOperationPolyDataFilter()
boolOp.SetOperation(vtk.VTK_DIFFERENCE)
boolOp.SetInputConnection(0, LHS.GetOutputPort())
boolOp.SetInputConnection(1, RHS.GetOutputPort())
LHS = boolOp
if 1:
RHS = vtk.vtkSphereSource()
RHS.SetCenter((-0.5, 0.0, 0.3))
RHS.SetRadius(1.0); RHS.SetPhiResolution(40); RHS.SetThetaResolution(40)
boolOp = vtk.vtkBooleanOperationPolyDataFilter()
boolOp.SetOperation(vtk.VTK_DIFFERENCE)
boolOp.SetInputConnection(0, LHS.GetOutputPort())
boolOp.SetInputConnection(1, RHS.GetOutputPort())
LHS = boolOp
if 0:
fill = vtk.vtkFillHolesFilter()
#fill.SetHoleSize(1.0)
fill.SetInputConnection(LHS.GetOutputPort())
LHS = fill
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(LHS.GetOutputPort(0))
mapper.ScalarVisibilityOff()
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindow.SetSize(1024, 1024)
renderer.AddActor(actor)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renderWindow)
interactor.Initialize()
renderWindow.Render()
interactor.Start()
More information about the vtkusers
mailing list