[vtkusers] Hole filling

Amitesh Agarwal amiteshagarwal at gmail.com
Tue Apr 11 14:54:47 EDT 2006


Hi All,

I was attempting hole filling using this code while customizing it for an
unstructured grid as input. I am getting segmentation fault error. Please
note that this code was sent by *Alexandre[dot]Gouaillar[at]sun[dot]com *in
this same forum in c++. I just rewrote it in python and it is crashing  due
to some update bug about which I have no idea. I would be really thankful if
you (or anyone else ) could point me towards the error in the code or a
possible get around to this problem.

Thanks for your valuable time

With Best Regards
Amitesh
---------------------------------------------------------------------------------------

#!/usr/bin/vtkpython
import vtk
reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName("/home/amitesh/testcase.vtk")


meshin = vtk.vtkDataSetSurfaceFilter()
meshin.SetInput(reader.GetOutput())

#Detect holes
boundaryEdges = vtk.vtkFeatureEdges()
boundaryEdges.SetInput(meshin.GetOutput())
boundaryEdges.SetBoundaryEdges(1)
boundaryEdges.SetFeatureEdges(0)
boundaryEdges.SetNonManifoldEdges(0)
boundaryEdges.SetManifoldEdges(0)
boundaryEdges.Update()

#Number of Boundary Edges
#nombreoutput = boundaryEdges.GetOutput()
nombre = (boundaryEdges.GetOutput().GetNumberOfLines())

#number of Edge nodes
pointsNumber = nombre

#Cleanup the mesh
poly = vtk.vtkCleanPolyData()
poly.SetInput(meshin.GetOutput())
poly.Update()

region = vtk.vtkPolyDataConnectivityFilter()
meshAppend = vtk.vtkAppendPolyData()
bouchon = vtk.vtkStripper()
bouchonPoly = vtk.vtkPolyData()
bouchontri = vtk.vtkTriangleFilter()

meshAppend.AddInput(poly.GetOutput())
meshAppend.AddInput(bouchontri.GetOutput())

region.SetInputConnection(boundaryEdges.GetOutputPort())
region.SetExtractionMode(6)

bouchon.SetInput(region.GetOutput())
bouchontri.SetInput(bouchonPoly)

poly.SetInput(meshAppend.GetOutput())
poly.SetTolerance(0.0)
poly.SetConvertLinesToPoints(0)
poly.SetConvertPolysToLines(0)
poly.SetConvertStripsToPolys(0)

boundaryEdges.SetInput(poly.GetOutput())
while nombre != 0:
        region.Update()
        bouchonPoly.Initialize()
        bouchonPoly.SetPoints(bouchon.GetOutput().GetPoints())
        bouchonPoly.SetLines(bouchon.GetOutput().GetLines())
        bouchonPoly.Update()

        #triangulate the polygonal patch
        bouchontri.Update()

        #patch (add the patch to the mesh)
        meshAppend.Update()

        #remove duplicated edges and points
        poly.Update()

        #update the number of border edges
        boundaryEdges.Update()

        nombre = boundaryEdges.GetOutput().GetNumberOfLines()

meshout = vtk.vtkPolyData()
meshout.DeepCopy(poly.GetOutput())
meshout.Update()

Writer = vtk.vtkPolyDataWriter()
Writer.SetFileName("/home/amitesh/testcasepatched.vtk")
Writer.SetInput(meshout)
Writer.Write()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060411/6e571dff/attachment.htm>


More information about the vtkusers mailing list