Ejemplo n.º 1
0
def tricall0():
    import triIfaceUtils
    import triIfaceFileUtils
    #define some flags for how the script will run
    verbose = 2   #level of output
    tinfo = """triangulation:
number of points        = %d
attributes per point    = %d
number of triangles     = %d
nodes per triangle      = %d
attributes per triangle = %d
number of segments      = %d
number of holes         = %d
number of regions       = %d
number of edges         = %d
"""

    trin = triangulate.new()
    pointsin = Numeric.array([[0.0, 0.0],
                              [1.0,0.0],
                              [1.0,10.0],
                              [0.0,10.0]])
    npoints = pointsin.shape[0]
    pattsin = Numeric.array([0.0, 1.0, 11.0, 10.0])
    pmarkin = Numeric.zeros((npoints,),Numeric.Int)
    pmarkin[1] = 2
    pregion =  Numeric.array([[0.5,5.0,7.0,0.1]])
    if verbose > 3:
        print 'pregion shape=',pregion.shape
    #end verbose
    triangulate.setPointsAndMarkers(trin,pointsin,pmarkin)
    triangulate.setPointAttributes(trin,pattsin)
    triangulate.setRegions(trin,pregion)
    
    tiInfo = triangulate.getInfo(trin)

    print 'trin info says'
    print tinfo % tiInfo

    #create a simple flag list
    flags = "pczAevn"
    
    trimid = triangulate.new()
    vorout = triangulate.new()
    
    triangulate.applyTriangulate(flags,trin,trimid,vorout)

    tmInfo = triangulate.getInfo(trimid)

    print 'trimid info says'
    print tinfo % tmInfo

    if verbose > 1:
        points0 = triangulate.getPoints(trin)
        print 'in points=\n',points0
        elems0 = triangulate.getTriangles(trin)
        print 'in elems=\n',elems0
        elems1 = triangulate.getTriangles(trimid)
        print 'out elems=\n',elems1
    #end verbose
    if verbose > 1:
        print 'calling printReport for input'
        triangulate.printReport(trin)
        print 'calling printReport for output'
        triangulate.printReport(trimid)
    #end verbose
    triIfaceUtils.writeOutTriangulation(trimid,"trimesh")

    #now refine intermediate triangle
    nelmsmid = tmInfo[2]
    midArea = Numeric.zeros((nelmsmid,),Numeric.Float)
    midArea[0] = 3.0
    midArea[1] = 1.0

    triangulate.setTriangleAreas(trimid,midArea)
    
    triout = triangulate.new()
    flags  = "prazBP"
    triangulate.applyTriangulateNoVoronoi(flags,trimid,triout)
    
    triIfaceUtils.writeOutTriangulation(triout,"trimesh.1")


    #now view with showme
    showme = "../bin/showme"
    showmecmd = showme+" trimesh"

    failure = 0
    failure = triIfaceFileUtils.checkFileExists(showme)
    failure = os.system(showmecmd)
    
    #manually delete things for debugging
    print 'deleting trin'
    del trin
    print 'deleting trimid'
    del trimid
    print 'deleting vor'
    del vorout
    print 'deleting triout'
    del triout

    return failure
Ejemplo n.º 2
0
print 'segmentsOut=\n', segsout
print 'segmarksout=\n', segmarksout

ntatts = 2
nelem = elems1.shape[0]
tatts = Numeric.zeros((nelem, ntatts), Numeric.Float)
for i in range(nelem):
    tatts[i, :] = Numeric.ones(ntatts, ) * float(i)
#end i
print 'try to set triangle attributes \n', tatts
triangulate.setTriangleAttributes(trin, tatts)

carea = Numeric.ones((nelem, ), Numeric.Float)
print 'try to set triangle area constraints \n', carea
triangulate.setTriangleAreas(trin, carea)

#this should be empty before calling triangulate
neigs0 = triangulate.getNeighbors(trin)
print 'neigs= ', neigs0
#this should be empty before calling triangulate
neigs1 = triangulate.getNeighborsCopy(trin)
print 'neigsCopy= ', neigs1

vornorms = triangulate.getVoronoiNormals(trin)
print 'vornorms= ', vornorms

#get basic info about triangulation
info = triangulate.getInfo(trin)
sinfo = """triangulation:
number of points        = %d
Ejemplo n.º 3
0
print 'segmentsOut=\n',segsout
print 'segmarksout=\n',segmarksout


ntatts = 2
nelem  = elems1.shape[0]
tatts = Numeric.zeros((nelem,ntatts),Numeric.Float)
for i in range(nelem):
    tatts[i,:] = Numeric.ones(ntatts,)*float(i)
#end i
print 'try to set triangle attributes \n',tatts
triangulate.setTriangleAttributes(trin,tatts)

carea = Numeric.ones((nelem,),Numeric.Float)
print 'try to set triangle area constraints \n',carea
triangulate.setTriangleAreas(trin,carea)

#this should be empty before calling triangulate
neigs0 = triangulate.getNeighbors(trin)
print 'neigs= ',neigs0
#this should be empty before calling triangulate
neigs1 = triangulate.getNeighborsCopy(trin)
print 'neigsCopy= ',neigs1

vornorms= triangulate.getVoronoiNormals(trin)
print 'vornorms= ',vornorms

#get basic info about triangulation
info =triangulate.getInfo(trin)
sinfo = """triangulation:
number of points        = %d
Ejemplo n.º 4
0
def tricall0():
    import triIfaceUtils
    import triIfaceFileUtils
    #define some flags for how the script will run
    verbose = 2  #level of output
    tinfo = """triangulation:
number of points        = %d
attributes per point    = %d
number of triangles     = %d
nodes per triangle      = %d
attributes per triangle = %d
number of segments      = %d
number of holes         = %d
number of regions       = %d
number of edges         = %d
"""

    trin = triangulate.new()
    pointsin = Numeric.array([[0.0, 0.0], [1.0, 0.0], [1.0, 10.0], [0.0,
                                                                    10.0]])
    npoints = pointsin.shape[0]
    pattsin = Numeric.array([0.0, 1.0, 11.0, 10.0])
    pmarkin = Numeric.zeros((npoints, ), Numeric.Int)
    pmarkin[1] = 2
    pregion = Numeric.array([[0.5, 5.0, 7.0, 0.1]])
    if verbose > 3:
        print 'pregion shape=', pregion.shape
    #end verbose
    triangulate.setPointsAndMarkers(trin, pointsin, pmarkin)
    triangulate.setPointAttributes(trin, pattsin)
    triangulate.setRegions(trin, pregion)

    tiInfo = triangulate.getInfo(trin)

    print 'trin info says'
    print tinfo % tiInfo

    #create a simple flag list
    flags = "pczAevn"

    trimid = triangulate.new()
    vorout = triangulate.new()

    triangulate.applyTriangulate(flags, trin, trimid, vorout)

    tmInfo = triangulate.getInfo(trimid)

    print 'trimid info says'
    print tinfo % tmInfo

    if verbose > 1:
        points0 = triangulate.getPoints(trin)
        print 'in points=\n', points0
        elems0 = triangulate.getTriangles(trin)
        print 'in elems=\n', elems0
        elems1 = triangulate.getTriangles(trimid)
        print 'out elems=\n', elems1
    #end verbose
    if verbose > 1:
        print 'calling printReport for input'
        triangulate.printReport(trin)
        print 'calling printReport for output'
        triangulate.printReport(trimid)
    #end verbose
    triIfaceUtils.writeOutTriangulation(trimid, "trimesh")

    #now refine intermediate triangle
    nelmsmid = tmInfo[2]
    midArea = Numeric.zeros((nelmsmid, ), Numeric.Float)
    midArea[0] = 3.0
    midArea[1] = 1.0

    triangulate.setTriangleAreas(trimid, midArea)

    triout = triangulate.new()
    flags = "prazBP"
    triangulate.applyTriangulateNoVoronoi(flags, trimid, triout)

    triIfaceUtils.writeOutTriangulation(triout, "trimesh.1")

    #now view with showme
    showme = "../bin/showme"
    showmecmd = showme + " trimesh"

    failure = 0
    failure = triIfaceFileUtils.checkFileExists(showme)
    failure = os.system(showmecmd)

    #manually delete things for debugging
    print 'deleting trin'
    del trin
    print 'deleting trimid'
    del trimid
    print 'deleting vor'
    del vorout
    print 'deleting triout'
    del triout

    return failure