コード例 #1
0
def main():
    if (len(sys.argv) > 1):
        filename = sys.argv[1]
    else:
        # TODO Implement a file dialog here
        raise Exception("No file name specified")

    # Load the mesh
    mesh = cy.HalfEdgeMesh(cy.readMesh(filename))
    # 1. Build the matrix

    verts = list(mesh.verts)
    nv = len(verts)
    vd = {verts[i]: i for i in xrange(nv)}

    M_row = np.array([])
    M_col = np.array([])
    M_data = np.array([])

    for i in xrange(nv):
        v = verts[i]
        # for M[i,i]
        M_row = np.r_[M_row, [i]]
        M_col = np.r_[M_col, [i]]
        M_data = np.r_[M_data, [1]]
        # for neighbors M[i,j]
        for n in v.adjVerts():
            j = vd[n]
            M_row = np.r_[M_row, [i]]
            M_col = np.r_[M_col, [j]]
            M_data = np.r_[M_data, [1]]
    M = csr_matrix((M_data, (M_row, M_col)), shape=(nv, nv)).todense()
コード例 #2
0
ファイル: poisson.py プロジェクト: pavelkang/research
def main():
    if(len(sys.argv) > 1):
        filename = sys.argv[1]
    else:
        # TODO Implement a file dialog here
        raise Exception("No file name specified")

    # Load the mesh
    mesh = cy.HalfEdgeMesh(cy.readMesh(filename))
    # 1. Build the matrix

    verts = list(mesh.verts)
    nv = len(verts)
    vd = {verts[i]:i for i in xrange(nv)}

    M_row  = np.array([])
    M_col  = np.array([])
    M_data = np.array([])

    for i in xrange(nv):
        v = verts[i]
        # for M[i,i]
        M_row = np.r_[M_row, [i]]
        M_col = np.r_[M_col, [i]]
        M_data = np.r_[M_data, [1]]
        # for neighbors M[i,j]
        for n in v.adjVerts():
            j = vd[n]
            M_row = np.r_[M_row, [i]]
            M_col = np.r_[M_col, [j]]
            M_data = np.r_[M_data, [1]]
    M = csr_matrix((M_data, (M_row, M_col)), shape=(nv, nv)).todense()
コード例 #3
0
ファイル: main.py プロジェクト: pavelkang/cholesky
def main():
    # Get the path for the mesh to load, either from the program argument if
    # one was given, or a dialog otherwise
    filename = readFileName()
    # Load a mesh
    mesh = cy.HalfEdgeMesh(cy.readMesh(filename))
    # Try different strategies on this mesh
    vs = list(mesh.verts)
    strats = [RandomStrat(mesh, vs), SortByXStrat(mesh, vs),
              MinDegreeStrat(mesh, vs), MaxDegreeStrat(mesh, vs),
              CuthillStrat(mesh, vs)]
    # print sparsities
    for strat in strats:
        color_print("------ "+strat.getName()+" ------", PRIMARY)
        m = strat.applyReorder()
        cholesky_solve(m, printSparsity = True)
    return 0
コード例 #4
0
ファイル: meshviewGL.py プロジェクト: pavelkang/research
def main():

    # Get the path for the mesh to load, either from the program argument if
    # one was given, or a dialog otherwise
    if len(sys.argv) > 1:
        filename = sys.argv[1]
    else:
        # TODO Implement a file dialog here
        raise Exception("No file name specified")

    # Read in the mesh
    mesh = cy.readMesh(filename)
    print type(mesh)
    # Toss up a viewer window
    winName = "Cyamites meshview -- " + basename(filename)
    meshDisplay = cy.MeshDisplayGL(windowTitle=winName)
    meshDisplay.setMesh(mesh)
    meshDisplay.startMainLoop()
コード例 #5
0
def main():

    # Get the path for the mesh to load, either from the program argument if
    # one was given, or a dialog otherwise
    if(len(sys.argv) > 1):
        filename = sys.argv[1]
    else:
        # TODO Implement a file dialog here
        raise Exception("No file name specified")

    # Read in the mesh
    mesh = cy.HalfEdgeMesh(cy.readMesh(filename))

    # Uniform direction
    unifDir = cy.normalize(np.array([0.0,0.0,1.0]))

    # For each vertex, set a reference edge/direction and project the uniform
    # direction in to the normal plane
    print("Computing test directions...")

    startTime = time.time()
    mesh.assignReferenceDirections()
    for vert in mesh.verts:

        # Project
        uNorm = np.dot(vert.normal, unifDir)*vert.normal
        uInPlaneDir = cy.normalize(unifDir - uNorm)
        xVal = np.dot(vert.refDirR3, uInPlaneDir)
        yVal = np.dot(np.cross(vert.normal, vert.refDirR3), uInPlaneDir)
        vert.theta = atan2(yVal, xVal)

    elapsedTime = time.time() - startTime
    print("Computing directions took " + str(elapsedTime))

    # Toss up a viewer window
    winName = 'Cyamites meshview -- ' + basename(filename)
    meshDisplay = cy.MeshDisplayGL(windowTitle=winName)
    meshDisplay.setSurfaceDirections('theta', nSym=3)
    meshDisplay.setMesh(mesh)
    meshDisplay.startMainLoop()
コード例 #6
0
def main():

    # Get the path for the mesh to load, either from the program argument if
    # one was given, or a dialog otherwise
    if (len(sys.argv) > 1):
        filename = sys.argv[1]
    else:
        # TODO Implement a file dialog here
        raise Exception("No file name specified")

    # Read in the mesh
    mesh = cy.HalfEdgeMesh(cy.readMesh(filename))

    # Uniform direction
    unifDir = cy.normalize(np.array([0.0, 0.0, 1.0]))

    # For each vertex, set a reference edge/direction and project the uniform
    # direction in to the normal plane
    print("Computing test directions...")

    startTime = time.time()
    mesh.assignReferenceDirections()
    for vert in mesh.verts:

        # Project
        uNorm = np.dot(vert.normal, unifDir) * vert.normal
        uInPlaneDir = cy.normalize(unifDir - uNorm)
        xVal = np.dot(vert.refDirR3, uInPlaneDir)
        yVal = np.dot(np.cross(vert.normal, vert.refDirR3), uInPlaneDir)
        vert.theta = atan2(yVal, xVal)

    elapsedTime = time.time() - startTime
    print("Computing directions took " + str(elapsedTime))

    # Toss up a viewer window
    winName = 'Cyamites meshview -- ' + basename(filename)
    meshDisplay = cy.MeshDisplayGL(windowTitle=winName)
    meshDisplay.setSurfaceDirections('theta', nSym=3)
    meshDisplay.setMesh(mesh)
    meshDisplay.startMainLoop()