Example #1
0
def writeOutTriangulation(tri, filebase="mesh", nbase=0, verbose=0):
    """
    collect necessary steps to write out files for triangle data structures

    """
    failed = False
    if tri == None:
        failed = True
        return failed
    if not nbase in [0, 1]:
        print 'must have vertex base numbering = 0 or 1, got nbase= ', nbase
        failed = True
        return failed
    #end

    nodes = triangulate.getPoints(tri)
    patts = triangulate.getPointAttributes(tri)
    pmarks = triangulate.getPointMarkers(tri)
    if verbose > 0:
        print 'writing node file'
    printNodeFile(nodes, filebase, patts, pmarks, nbase=nbase)

    elems = triangulate.getTriangles(tri)
    eatts = triangulate.getTriangleAttributes(tri)
    if verbose > 0:
        print 'writing elements file'
    printElemFile(elems, filebase, eatts, nbase=nbase)

    segms = triangulate.getSegments(tri)
    segmmks = triangulate.getSegmentMarkers(tri)
    holes = triangulate.getHoles(tri)
    regions = triangulate.getRegions(tri)
    if verbose > 0:
        print 'writing poly file'
    printPolyFile(nodes,
                  segms,
                  filebase,
                  patts,
                  pmarks,
                  segmmks,
                  holes,
                  regions,
                  nbase=nbase)

    edges = triangulate.getEdges(tri)
    edgemks = triangulate.getEdgeMarkers(tri)
    if verbose > 0:
        print 'writing edges file'
    printEdgeFile(edges, filebase, edgemks, nbase=nbase)

    neigs = triangulate.getNeighbors(tri)
    if verbose > 0:
        print 'writing neighbors file'
    printNeighborFile(neigs, filebase, nbase=nbase)

    return failed
Example #2
0
def writeOutTriangulation(tri,filebase="mesh",nbase=0,verbose=0):
    """
    collect necessary steps to write out files for triangle data structures

    """
    failed = False
    if tri == None:
        failed = True
        return failed
    if not nbase in [0,1]:
        print 'must have vertex base numbering = 0 or 1, got nbase= ',nbase
        failed = True
        return failed
    #end

    nodes = triangulate.getPoints(tri)
    patts = triangulate.getPointAttributes(tri)
    pmarks= triangulate.getPointMarkers(tri)
    if verbose > 0:
        print 'writing node file'
    printNodeFile(nodes,filebase,patts,pmarks,nbase=nbase)

    elems = triangulate.getTriangles(tri)
    eatts = triangulate.getTriangleAttributes(tri)
    if verbose > 0:
        print 'writing elements file'
    printElemFile(elems,filebase,eatts,nbase=nbase)

    segms  = triangulate.getSegments(tri)
    segmmks= triangulate.getSegmentMarkers(tri)
    holes  = triangulate.getHoles(tri)
    regions= triangulate.getRegions(tri)
    if verbose > 0:
        print 'writing poly file'
    printPolyFile(nodes,segms,filebase,patts,pmarks,
                  segmmks,holes,regions,nbase=nbase)

    edges  = triangulate.getEdges(tri)
    edgemks= triangulate.getEdgeMarkers(tri)
    if verbose > 0:
        print 'writing edges file'
    printEdgeFile(edges,filebase,edgemks,nbase=nbase)

    neigs  = triangulate.getNeighbors(tri)
    if verbose > 0:
        print 'writing neighbors file'
    printNeighborFile(neigs,filebase,nbase=nbase)

    return failed
Example #3
0
print 'pointsin= ',pointsin
print 'pointsout= ',pointsout
print 'pointsoutCopy= ',pointsout2
print 'pointmarksin= ',marksin
print 'pointmarksout= ',marksout

#create some point attributes,
npts  = pointsout.shape[0]
natts = 1
patts = Numeric.zeros((npts,natts),Numeric.Float)
for i in range(npts):
    patts[i,:] = pointsout[i,0]**2 + pointsout[i,1]**2
#end i
triangulate.setPointAttributes(trin,patts)

pattsout = triangulate.getPointAttributes(trin)
pattsoutCopy = triangulate.getPointAttributesCopy(trin)
print 'pattsin=\n',patts
print 'pattsout=\n',pattsout
print 'pattsoutCopy=\n',pattsoutCopy

#manually construct triangles
ntri = 2;
ncorn= 3;
elems0  = Numeric.zeros((ntri,ncorn),Numeric.Int)
elems0[0,:] = [0,1,2]
elems0[1,:] = [0,2,3]

triangulate.setTriangles(trin,elems0)

#shallow copy
Example #4
0
print 'pointsin= ', pointsin
print 'pointsout= ', pointsout
print 'pointsoutCopy= ', pointsout2
print 'pointmarksin= ', marksin
print 'pointmarksout= ', marksout

#create some point attributes,
npts = pointsout.shape[0]
natts = 1
patts = Numeric.zeros((npts, natts), Numeric.Float)
for i in range(npts):
    patts[i, :] = pointsout[i, 0]**2 + pointsout[i, 1]**2
#end i
triangulate.setPointAttributes(trin, patts)

pattsout = triangulate.getPointAttributes(trin)
pattsoutCopy = triangulate.getPointAttributesCopy(trin)
print 'pattsin=\n', patts
print 'pattsout=\n', pattsout
print 'pattsoutCopy=\n', pattsoutCopy

#manually construct triangles
ntri = 2
ncorn = 3
elems0 = Numeric.zeros((ntri, ncorn), Numeric.Int)
elems0[0, :] = [0, 1, 2]
elems0[1, :] = [0, 2, 3]

triangulate.setTriangles(trin, elems0)

#shallow copy