Ejemplo n.º 1
0
def key_pressed(viewer, key, modifier):
    global V
    global U
    global F
    global L

    if key == ord('r') or key == ord('R'):
        U = V;
    elif key == ord(' '):

        # Recompute just mass matrix on each step
        M = igl.eigen.SparseMatrixd()

        igl.massmatrix(U,F,igl.MASSMATRIX_TYPE_BARYCENTRIC,M);

        # Solve (M-delta*L) U = M*U
        S = (M - 0.001*L)

        solver = igl.eigen.SimplicialLLTsparse(S)

        U = solver.solve(M*U)

        # Compute centroid and subtract (also important for numerics)
        dblA = igl.eigen.MatrixXd()
        igl.doublearea(U,F,dblA)

        print(dblA.sum())

        area = 0.5*dblA.sum()
        BC = igl.eigen.MatrixXd()
        igl.barycenter(U,F,BC)
        centroid = igl.eigen.MatrixXd([[0.0,0.0,0.0]])

        for i in range(0,BC.rows()):
            centroid += 0.5*dblA[i,0]/area*BC.row(i)

        U -= centroid.replicate(U.rows(),1)

        # Normalize to unit surface area (important for numerics)
        U = U / math.sqrt(area)
    else:
        return False

    # Send new positions, update normals, recenter
    viewer.data.set_vertices(U)
    viewer.data.compute_normals()
    viewer.core.align_camera_center(U,F)
    return True
igl.readOFF("../../tutorial/shared/cheburashka.off",V,F)

# Two fixed points
# Left hand, left foot
b = igl.eigen.MatrixXi([[4331],[5957]])
bc = igl.eigen.MatrixXd([[1],[-1]])

# Construct Laplacian and mass matrix
L = igl.eigen.SparseMatrixd()
M = igl.eigen.SparseMatrixd()
Minv = igl.eigen.SparseMatrixd()
Q = igl.eigen.SparseMatrixd()

igl.cotmatrix(V,F,L)
igl.massmatrix(V,F,igl.MASSMATRIX_TYPE_VORONOI,M)
igl.invert_diag(M,Minv)

# Bi-Laplacian
Q = L * (Minv * L);

# Zero linear term
B = igl.eigen.MatrixXd.Zero(V.rows(),1);

Z       = igl.eigen.MatrixXd()
Z_const = igl.eigen.MatrixXd()

# Alternative, short hand
mqwf = igl.min_quad_with_fixed_data()

# Empty constraints
Ejemplo n.º 3
0
c = 0
bbd = 1.0
twod = False

if not igl.read_triangle_mesh(TUTORIAL_SHARED_PATH + "beetle.off", V, F):
    print("failed to load mesh")

twod = V.col(2).minCoeff() == V.col(2).maxCoeff()
bbd = (V.colwiseMaxCoeff() - V.colwiseMinCoeff()).norm()

L = igl.eigen.SparseMatrixd()
M = igl.eigen.SparseMatrixd()

igl.cotmatrix(V, F, L)
L = -L
igl.massmatrix(V, F, igl.MASSMATRIX_TYPE_DEFAULT, M)
k = 5

D = igl.eigen.MatrixXd()
if not igl.eigs(L, M, k + 1, igl.EIGS_TYPE_SM, U, D):
    print("Eigs failed.")

U = (U - U.minCoeff()) / (U.maxCoeff() - U.minCoeff())

viewer = igl.viewer.Viewer()


def key_down(viewer, key, mod):
    global U, c

    if key == ord(' '):
Ejemplo n.º 4
0
c = 0
bbd = 1.0
twod = False

if not igl.read_triangle_mesh("../../tutorial/shared/beetle.off",V,F):
    print("failed to load mesh")

twod = V.col(2).minCoeff() == V.col(2).maxCoeff()
bbd = (V.colwiseMaxCoeff() - V.colwiseMinCoeff()).norm()

L = igl.eigen.SparseMatrixd()
M = igl.eigen.SparseMatrixd()

igl.cotmatrix(V,F,L)
L = -L
igl.massmatrix(V,F,igl.MASSMATRIX_TYPE_DEFAULT,M)
k = 5

D = igl.eigen.MatrixXd()
if not igl.eigs(L,M,k+1,igl.EIGS_TYPE_SM,U,D):
    print("Eigs failed.")

U = (U-U.minCoeff())/(U.maxCoeff()-U.minCoeff());

viewer = igl.viewer.Viewer()

def key_down(viewer,key,mod):
    global U, c

    if key == ord(' '):
        U = U.rightCols(k)
Ejemplo n.º 5
0
igl.readOFF(TUTORIAL_SHARED_PATH + "cheburashka.off", V, F)

# Two fixed points
# Left hand, left foot
b = igl.eigen.MatrixXd([[4331], [5957]]).castint()
bc = igl.eigen.MatrixXd([[1], [-1]])

# Construct Laplacian and mass matrix
L = igl.eigen.SparseMatrixd()
M = igl.eigen.SparseMatrixd()
Minv = igl.eigen.SparseMatrixd()
Q = igl.eigen.SparseMatrixd()

igl.cotmatrix(V, F, L)
igl.massmatrix(V, F, igl.MASSMATRIX_TYPE_VORONOI, M)
igl.invert_diag(M, Minv)

# Bi-Laplacian
Q = L * (Minv * L)

# Zero linear term
B = igl.eigen.MatrixXd.Zero(V.rows(), 1)

Z = igl.eigen.MatrixXd()
Z_const = igl.eigen.MatrixXd()

# Alternative, short hand
mqwf = igl.min_quad_with_fixed_data()

# Empty constraints