Esempio n. 1
0
def larSignedBoundary3((V, FV, EV)):
    model = V, FV, EV
    faceCounter = zeros((len(FV), 2), dtype='b')
    CF, m = [], len(FV)
    efOp = larFaces2Edges(V, FV, EV)
    FE = [efOp([k]) for k in range(len(FV))]
    EF_angle, _, _, _ = boolean.faceSlopeOrdering(model, FE)
    nonWorkedFaces, coboundary_2, cellNumber = set(range(m)), [], 0
    boundaryOperator = larSignedBoundary2(V, FV, EV)
    FEbasis = signedBasis(boundaryOperator)
    row, col, data = [], [], []
    while True:
        startFace, orientation = chooseStartFace(FV, faceCounter)
        if startFace == -1: break
        nonWorkedFaces = nonWorkedFaces.difference({startFace})
        faceChainOrientation = {(startFace, orientation)}
        vect = csc_matrix((m, 1), dtype='b')
        for face, orientation in faceChainOrientation:
            vect[face] = orientation
        edgeCycleCoords = boundaryOperator * vect
        edgeCycle = coords2chain(edgeCycleCoords)
        while edgeCycle != []:
            look4face = adjFace(boundaryOperator, EV, EF_angle,
                                faceChainOrientation)
            for edge, orientation in edgeCycle:
                outPair = look4face(edge, orientation)
                if outPair != None:
                    adjacentFace, orientation = outPair
                    faceChainOrientation = faceChainOrientation.union([
                        (adjacentFace, orientation)
                    ])
                    nonWorkedFaces = nonWorkedFaces.difference([adjacentFace])
            vect = csc_matrix((m, 1), dtype='b')
            for face, orientation in faceChainOrientation:
                vect[face] = orientation
            edgeCycleCoords = boundaryOperator * vect
            edgeCycle = coords2chain(edgeCycleCoords)
            #if edgeCycle!=[]: VIEW(STRUCT(MKPOLS((V,[EV[e] for e in TRANS(edgeCycle)[0]]))))
        row += [face for face, _ in faceChainOrientation]
        col += [cellNumber for face, orientation in faceChainOrientation]
        data += [orientation for _, orientation in faceChainOrientation]
        cellNumber += 1

        for face, orientation in faceChainOrientation:
            if orientation == 1: faceCounter[face, 0] += 1
            elif orientation == -1: faceCounter[face, 1] += 1
        print "faceChainOrientation =", faceChainOrientation
        print "faceCounter =", faceCounter

        CF += [[face for face, _ in faceChainOrientation]]
        print "CF =", CF
        print "\nfaceCounter =", faceCounter
    outMatrix = coo_matrix((data, (row, col)),
                           shape=(m, cellNumber),
                           dtype='b')
    return csr_matrix(outMatrix), CF, faceCounter
Esempio n. 2
0
def larSignedBoundary3((V,FV,EV)):
    model = V,FV,EV
    faceCounter = zeros((len(FV),2),dtype='b')
    CF,m = [],len(FV)
    efOp = larFaces2Edges(V,FV,EV)
    FE = [efOp([k]) for k in range(len(FV))]
    EF_angle, _,_,_ = boolean.faceSlopeOrdering(model,FE)
    nonWorkedFaces,coboundary_2,cellNumber = set(range(m)),[],0
    boundaryOperator = larSignedBoundary2(V,FV,EV)
    FEbasis = signedBasis(boundaryOperator)
    row,col,data = [],[],[]
    while True:
        startFace,orientation = chooseStartFace(FV,faceCounter)
        if startFace == -1: break
        nonWorkedFaces = nonWorkedFaces.difference({startFace})
        faceChainOrientation = {(startFace,orientation)}
        vect = csc_matrix((m,1),dtype='b')
        for face,orientation in faceChainOrientation:  
            vect[face] = orientation
        edgeCycleCoords = boundaryOperator * vect
        edgeCycle = coords2chain(edgeCycleCoords)
        while edgeCycle != []:
            look4face = adjFace(boundaryOperator,EV,EF_angle,faceChainOrientation)
            for edge,orientation in edgeCycle:
                outPair = look4face(edge,orientation)
                if outPair != None:
                    adjacentFace,orientation = outPair
                    faceChainOrientation = faceChainOrientation.union(
                        [(adjacentFace,orientation)])
                    nonWorkedFaces = nonWorkedFaces.difference([adjacentFace])
            vect = csc_matrix((m,1),dtype='b')
            for face,orientation in faceChainOrientation:  
                vect[face] = orientation
            edgeCycleCoords = boundaryOperator * vect
            edgeCycle = coords2chain(edgeCycleCoords)
            #if edgeCycle!=[]: VIEW(STRUCT(MKPOLS((V,[EV[e] for e in TRANS(edgeCycle)[0]]))))
        row += [face for face,_ in faceChainOrientation]
        col += [cellNumber for face,orientation in faceChainOrientation]
        data += [orientation for _,orientation in faceChainOrientation]
        cellNumber += 1
        
        for face,orientation in faceChainOrientation:
          if orientation == 1: faceCounter[face,0]+=1
          elif orientation == -1: faceCounter[face,1]+=1
        print "faceChainOrientation =",faceChainOrientation   
        print "faceCounter =",faceCounter   
          
        CF += [[face for face,_ in faceChainOrientation]]
        print "CF =",CF
        print "\nfaceCounter =",faceCounter      
    outMatrix = coo_matrix((data, (row,col)), shape=(m,cellNumber),dtype='b')
    return csr_matrix(outMatrix),CF,faceCounter