[vtkusers] vtkBooleanOperationPolyDataFilter including disconnected faces

Fahlgren, Eric efahlgren at lifemodeler.com
Mon Jan 23 12:59:42 EST 2012


Here's another shot of a similar configuration (I think I've moved the spheres from the previous example).  This one clearly shows the odd shading on the stitching, which look to me to be normals pointed off to Mars or possibly Alpha Centauri.  Could they just be pointed 180 off, an inside/outside detection problem when generating those new faces that glue the surfaces together?

http://www.lifemodeler.com/eric/badNormals.png

Eric

> 
> 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