[vtkusers] Broken surfaces for vtkBooleanOperationPolyDataFilter() - Bug?

normanius juch at zhaw.ch
Tue Dec 8 14:34:03 EST 2015


Hi, 

For two polydata objects I create boolean operations, and /often/ this does
not cause any problems. However, /sometimes/ I get results as seen in the
image below. The second image shows that there are indeed non-manifold edges
resulting from the operations.

I verified that the input objects are manifold.

I came across  this
<http://vtk.1045678.n5.nabble.com/Non-manifold-triangles-after-running-vtkBooleanOperationPolydataFilter-td5713964.html>  
post where Cory Quammen states it might be related to a bug in the
algorithm.

(I've cross-posted the problem also on  Stackoverflow
<http://stackoverflow.com/questions/34100211>  , but I found that I reach
the vtk cracks much more efficiently through this mailing list.)

I'm calling the following code:

def doApplyCutAdvanced(source, cutCylinder, domeCutCenter):
    '''
    Cut a cylinder B from source A according to the following recipe:
    A = A \ B
    A = connectivityFilter(A, domeCenter)
    A = A v (A ^ B)
    '''
    
    # Extract triangles.
    sourceTriangles = vtk.vtkTriangleFilter()
    sourceTriangles.SetInputConnection(source.GetOutputPort())
    sourceTriangles.Update()
    
    cylinderTriangles = vtk.vtkTriangleFilter()
    cylinderTriangles.SetInputConnection(cutCylinder.GetOutputPort())
    cylinderTriangles.Update()
    
    # First operation: A \ B
    operation1 = vtk.vtkBooleanOperationPolyDataFilter()
    operation1.SetOperationToDifference()
    operation1.SetInputConnection(0, sourceTriangles.GetOutputPort())
    operation1.SetInputConnection(1, cylinderTriangles.GetOutputPort())
    operation1.Update()
    
    # Second operation: A ^ B
    operation2 = vtk.vtkBooleanOperationPolyDataFilter()
    operation2.SetOperationToIntersection()
    operation2.SetInputConnection(0, source.GetOutputPort())
    operation2.SetInputConnection(1, cylinderTriangles.GetOutputPort())
    operation2.Update()
    
    # Apply the cut.
    cutSurfaceConnected = vtk.vtkPolyDataConnectivityFilter()
    cutSurfaceConnected.SetInputConnection(operation1.GetOutputPort())
    cutSurfaceConnected.SetExtractionModeToClosestPointRegion()
    cutSurfaceConnected.SetClosestPoint(domeCutCenter)
    cutSurfaceConnected.Update()
    
    # Fix up the source object (if it was cut partially by the cylinder)
    appendFilter = vtk.vtkAppendPolyData()
    if vtk.vtkVersion.GetVTKMajorVersion() == 5:
        appendFilter.AddInput(cutSurfaceConnected.GetOutput())
        appendFilter.AddInput(operation2.GetOutput())
    else:
        appendFilter.AddInputData(cutSurfaceConnected.GetOutput())
        appendFilter.AddInputData(operation2.GetOutput())
    appendFilter.Update()
        
    cutSurfaceRepaired = vtk.vtkCleanPolyData()
    cutSurfaceRepaired.SetInputConnection(appendFilter.GetOutputPort())
    cutSurfaceRepaired.Update()
    
    cutSurfaceRepairedTriangles = vtk.vtkTriangleFilter()
   
cutSurfaceRepairedTriangles.SetInputConnection(cutSurfaceRepaired.GetOutputPort())
    cutSurfaceRepairedTriangles.Update()
    
    return cutSurfaceRepairedTriangles

<http://vtk.1045678.n5.nabble.com/file/n5735413/example_broken_surface.png> 
<http://vtk.1045678.n5.nabble.com/file/n5735413/example_broken_surface_nonmanifold_edges.png> 




--
View this message in context: http://vtk.1045678.n5.nabble.com/Broken-surfaces-for-vtkBooleanOperationPolyDataFilter-Bug-tp5735413.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list