Esempio n. 1
0
def plot_mesh_nrosy(viewer, V, F, N, PD1, S, b):
    # Clear the mesh
    viewer.data.clear()
    viewer.data.set_mesh(V, F)

    # Expand the representative vectors in the full vector set and plot them as lines
    avg = igl.avg_edge_length(V, F)
    Y = igl.eigen.MatrixXd()
    representative_to_nrosy(V, F, PD1, N, Y)

    B = igl.eigen.MatrixXd()
    igl.barycenter(V, F, B)

    Be = igl.eigen.MatrixXd(B.rows() * N, 3)
    for i in range(0, B.rows()):
        for j in range(0, N):
            Be.setRow(i * N + j, B.row(i))

    viewer.data.add_edges(Be, Be + Y * (avg / 2), igl.eigen.MatrixXd([[0, 0, 1]]))

    # Plot the singularities as colored dots (red for negative, blue for positive)
    for i in range(0, S.size()):
        if S[i] < -0.001:
            viewer.data.add_points(V.row(i), igl.eigen.MatrixXd([[1, 0, 0]]))
        elif S[i] > 0.001:
            viewer.data.add_points(V.row(i), igl.eigen.MatrixXd([[0, 1, 0]]));

    # Highlight in red the constrained faces
    C = igl.eigen.MatrixXd.Constant(F.rows(), 3, 1)
    for i in range(0, b.size()):
        C.setRow(b[i], igl.eigen.MatrixXd([[1, 0, 0]]))
    viewer.data.set_colors(C)
Esempio n. 2
0
    viewer.data().set_texture(texture_R, texture_B, texture_G)

    viewer.core.align_camera_center(viewer.data().V, viewer.data().F)

    return False


# Load a mesh in OFF format
igl.readOFF(TUTORIAL_SHARED_PATH + "3holes.off", V, F)

# Compute face barycenters
igl.barycenter(V, F, B)

# Compute scale for visualizing fields
global_scale = .5 * igl.avg_edge_length(V, F)

# Contrain one face
b = igl.eigen.MatrixXd([[0]]).castint()
bc = igl.eigen.MatrixXd([[1, 0, 0]])

# Create a smooth 4-RoSy field
S = igl.eigen.MatrixXd()

igl.comiso.nrosy(V, F, b, bc, igl.eigen.MatrixXi(), igl.eigen.MatrixXd(), igl.eigen.MatrixXd(), 4, 0.5, X1, S)

# Find the orthogonal vector
B1 = igl.eigen.MatrixXd()
B2 = igl.eigen.MatrixXd()
B3 = igl.eigen.MatrixXd()
    viewer.data.set_texture(texture_R, texture_B, texture_G)

    viewer.core.align_camera_center(viewer.data.V, viewer.data.F)

    return False


# Load a mesh in OFF format
igl.readOFF(TUTORIAL_SHARED_PATH + "3holes.off", V, F)

# Compute face barycenters
igl.barycenter(V, F, B)

# Compute scale for visualizing fields
global_scale = .5 * igl.avg_edge_length(V, F)

# Contrain one face
b = igl.eigen.MatrixXi([[0]])
bc = igl.eigen.MatrixXd([[1, 0, 0]])

# Create a smooth 4-RoSy field
S = igl.eigen.MatrixXd()

igl.comiso.nrosy(V, F, b, bc, igl.eigen.MatrixXi(), igl.eigen.MatrixXd(), igl.eigen.MatrixXd(), 4, 0.5, X1, S)

# Find the the orthogonal vector
B1 = igl.eigen.MatrixXd()
B2 = igl.eigen.MatrixXd()
B3 = igl.eigen.MatrixXd()
Esempio n. 4
0
# Compute gradient magnitude
GU_mag = GU.rowwiseNorm()

viewer = igl.glfw.Viewer()
viewer.data().set_mesh(V, F)

# Compute pseudocolor for original function
C = igl.eigen.MatrixXd()

igl.jet(U, True, C)

# Or for gradient magnitude
# igl.jet(GU_mag,True,C)

viewer.data().set_colors(C)

# Average edge length divided by average gradient (for scaling)
max_size = igl.avg_edge_length(V, F) / GU_mag.mean()

# Draw a black segment in direction of gradient at face barycenters
BC = igl.eigen.MatrixXd()
igl.barycenter(V, F, BC)

black = igl.eigen.MatrixXd([[0.0, 0.0, 0.0]])
viewer.data().add_edges(BC, BC + max_size * GU, black)

# Hide wireframe
viewer.data().show_lines = False

viewer.launch()
Esempio n. 5
0
igl.principal_curvature(V, F, PD1, PD2, PV1, PV2)

# Mean curvature
H = 0.5 * (PV1 + PV2)

viewer = igl.glfw.Viewer()
viewer.data().set_mesh(V, F)

# Compute pseudocolor
C = igl.eigen.MatrixXd()
igl.parula(H, True, C)

viewer.data().set_colors(C)

# Average edge length for sizing
avg = igl.avg_edge_length(V, F)

# Draw a blue segment parallel to the minimal curvature direction
red = igl.eigen.MatrixXd([[0.8, 0.2, 0.2]])
blue = igl.eigen.MatrixXd([[0.2, 0.2, 0.8]])

viewer.data().add_edges(V + PD1 * avg, V - PD1 * avg, blue)

# Draw a red segment parallel to the maximal curvature direction
viewer.data().add_edges(V + PD2 * avg, V - PD2 * avg, red)

# Hide wireframe
viewer.data().show_lines = False

viewer.launch()
Esempio n. 6
0
# Compute gradient magnitude
GU_mag = GU.rowwiseNorm()

viewer = igl.glfw.Viewer()
viewer.data().set_mesh(V, F)

# Compute pseudocolor for original function
C = igl.eigen.MatrixXd()

igl.jet(U, True, C)

# Or for gradient magnitude
# igl.jet(GU_mag,True,C)

viewer.data().set_colors(C)

# Average edge length divided by average gradient (for scaling)
max_size = igl.avg_edge_length(V, F) / GU_mag.mean()

# Draw a black segment in direction of gradient at face barycenters
BC = igl.eigen.MatrixXd()
igl.barycenter(V, F, BC)

black = igl.eigen.MatrixXd([[0.0, 0.0, 0.0]])
viewer.data().add_edges(BC, BC + max_size * GU, black)

# Hide wireframe
viewer.data().show_lines = False

viewer.launch()
Esempio n. 7
0
        igl.jet(c, 1, 1 + rand_factor, C2)
        viewer.data.add_edges(B - global_scale * VF, B + global_scale * VF, C2)

    return False


# Load a mesh in OBJ format
igl.readOBJ("../../tutorial/shared/lilium.obj", V, F)
samples = readSamples("../../tutorial/shared/lilium.samples.0.2")

# Compute local basis for faces
igl.local_basis(V, F, B1, B2, B3)

# Compute face barycenters
igl.barycenter(V, F, B)

# Compute scale for visualizing fields
global_scale = 0.2 * igl.avg_edge_length(V, F)

# Make the example deterministic
random.seed(0)

viewer = igl.viewer.Viewer()
viewer.data.set_mesh(V, F)
viewer.callback_key_down = key_down
viewer.core.show_lines = False

key_down(viewer, ord('2'), 0)

viewer.launch()
Esempio n. 8
0
igl.principal_curvature(V, F, PD1, PD2, PV1, PV2)

# Mean curvature
H = 0.5 * (PV1 + PV2)

viewer = igl.glfw.Viewer()
viewer.data().set_mesh(V, F)

# Compute pseudocolor
C = igl.eigen.MatrixXd()
igl.parula(H, True, C)

viewer.data().set_colors(C)

# Average edge length for sizing
avg = igl.avg_edge_length(V, F)

# Draw a blue segment parallel to the minimal curvature direction
red = igl.eigen.MatrixXd([[0.8, 0.2, 0.2]])
blue = igl.eigen.MatrixXd([[0.2, 0.2, 0.8]])

viewer.data().add_edges(V + PD1 * avg, V - PD1 * avg, blue)

# Draw a red segment parallel to the maximal curvature direction
viewer.data().add_edges(V + PD2 * avg, V - PD2 * avg, red)

# Hide wireframe
viewer.data().show_lines = False

viewer.launch()
Esempio n. 9
0
        igl.jet(c,1,1+rand_factor,C2)
        viewer.data.add_edges(B - global_scale*VF, B + global_scale*VF , C2)

    return False


# Load a mesh in OBJ format
igl.readOBJ("../../tutorial/shared/lilium.obj", V, F)
samples = readSamples("../../tutorial/shared/lilium.samples.0.2")

# Compute local basis for faces
igl.local_basis(V,F,B1,B2,B3)

# Compute face barycenters
igl.barycenter(V, F, B)

# Compute scale for visualizing fields
global_scale = 0.2*igl.avg_edge_length(V, F)

# Make the example deterministic
random.seed(0)

viewer = igl.viewer.Viewer()
viewer.data.set_mesh(V, F)
viewer.callback_key_down = key_down
viewer.core.show_lines = False

key_down(viewer,ord('2'),0)

viewer.launch()