solve(viewer)
        return True
    elif key == ord(','):
        Beq[0, 0] = Beq[0, 0] / 2.0
        solve(viewer)
        return True
    elif key == ord(' '):
        solve(viewer)
        return True
    return False


V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()

igl.readOFF("../../tutorial/shared/cheburashka.off", V, F)

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

# One fixed point on belly
b = igl.eigen.MatrixXi([[2556]])
bc = igl.eigen.MatrixXd([[1]])

# Construct Laplacian and mass matrix
L = igl.eigen.SparseMatrixd()
M = igl.eigen.SparseMatrixd()
Minv = igl.eigen.SparseMatrixd()
         solve(viewer)
         return True
    elif key == ord(','):
         Beq[0,0] = Beq[0,0] / 2.0
         solve(viewer)
         return True
    elif key == ord(' '):
         solve(viewer)
         return True
    return False;


V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()

igl.readOFF("../../tutorial/shared/cheburashka.off",V,F)

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

# One fixed point on belly
b  = igl.eigen.MatrixXi([[2556]])
bc = igl.eigen.MatrixXd([[1]])

# Construct Laplacian and mass matrix
L = igl.eigen.SparseMatrixd()
M = igl.eigen.SparseMatrixd()
Minv = igl.eigen.SparseMatrixd()
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import igl

V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()

igl.readOFF("../../tutorial/shared/camelhead.off", V, F)

# Find boundary edges
E = igl.eigen.MatrixXi()
igl.boundary_facets(F, E)

# Find boundary vertices
b = igl.eigen.MatrixXi()
IA = igl.eigen.MatrixXi()
IC = igl.eigen.MatrixXi()

igl.unique(E, b, IA, IC)

# List of all vertex indices
vall = igl.eigen.MatrixXi()
vin = igl.eigen.MatrixXi()

igl.coloni(0, V.rows() - 1, vall)

# List of interior indices
igl.setdiff(vall, b, vin, IA)
# This function is called every time a keyboard button is pressed
def key_pressed(viewer, key, modifier):
    if key == ord('1'):
        viewer.data.set_normals(N_faces)
        return True
    elif key == ord('2'):
        viewer.data.set_normals(N_vertices)
        return True
    elif key == ord('3'):
        viewer.data.set_normals(N_corners)
        return True
    return False


# Load a mesh in OFF format
igl.readOFF("../../tutorial/shared/fandisk.off", V, F)

# Compute per-face normals
N_faces = igl.eigen.MatrixXd()
igl.per_face_normals(V, F, N_faces)

# Compute per-vertex normals
N_vertices = igl.eigen.MatrixXd()
igl.per_vertex_normals(V, F, igl.PER_VERTEX_NORMALS_WEIGHTING_TYPE_AREA,
                       N_vertices)

# Compute per-corner normals, |dihedral angle| > 20 degrees --> crease
N_corners = igl.eigen.MatrixXd()
igl.per_corner_normals(V, F, 20, N_corners)

# Plot the mesh
Example #5
0
import igl

# Load a mesh in OFF format
V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
igl.readOFF("../tutorial/shared/beetle.off", V, F)

# Plot the mesh
viewer = igl.viewer.Viewer();
viewer.data.set_mesh(V, F);
viewer.launch();
Example #6
0
    if key == ord('1'):
        # # Clear should be called before drawing the mesh
        viewer.data.clear();
        # # Draw_mesh creates or updates the vertices and faces of the displayed mesh.
        # # If a mesh is already displayed, draw_mesh returns an error if the given V and
        # # F have size different than the current ones
        viewer.data.set_mesh(V1, F1);
        viewer.core.align_camera_center(V1,F1);
    elif key == ord('2'):
        viewer.data.clear();
        viewer.data.set_mesh(V2, F2);
        viewer.core.align_camera_center(V2,F2);
    return False


#  Load two meshes
igl.readOFF("../tutorial/shared/bumpy.off", V1, F1);
igl.readOFF("../tutorial/shared/fertility.off", V2, F2);

print("1 Switch to bump mesh")
print("2 Switch to fertility mesh")

viewer = igl.viewer.Viewer()

# Register a keyboard callback that allows to switch between
# the two loaded meshes
viewer.callback_key_pressed = key_pressed
viewer.data.set_mesh(V1, F1)
viewer.launch()
Example #7
0
from __future__ import print_function
import igl

V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()

igl.readOFF("../tutorial/shared/decimated-knight.off",V,F)

# 100 random indicies into rows of F
I = igl.eigen.MatrixXi()
igl.floor((0.5*(igl.eigen.MatrixXd.Random(100,1)+1.)*F.rows()),I);

# 50 random indicies into rows of I
J = igl.eigen.MatrixXi()
igl.floor((0.5*(igl.eigen.MatrixXd.Random(50,1)+1.)*I.rows()),J)

# K = I(J);
K = igl.eigen.MatrixXi()
igl.slice(I,J,K)

# default green for all faces
#C = p2e(np.array([[0.4,0.8,0.3]])).replicate(F.rows(),1)
C = igl.eigen.MatrixXd([[0.4,0.8,0.3]]).replicate(F.rows(),1)

# Red for each in K
R = igl.eigen.MatrixXd([[1.0,0.3,0.3]]).replicate(K.rows(),1)
# C(K,:) = R
igl.slice_into(R,K,1,C)

# Plot the mesh with pseudocolors
viewer = igl.viewer.Viewer()
    if key == ord('8'):
        # Global parametrization in 3D with seams
        viewer.data.set_mesh(V, F)
        viewer.data.set_uv(UV_seams,FUV_seams)
        viewer.core.show_texture = True

    viewer.data.set_colors(igl.eigen.MatrixXd([[1,1,1]]))

    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/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)
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import igl

V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()

igl.readOFF("../../tutorial/shared/camelhead.off",V,F)

# Find boundary edges
E = igl.eigen.MatrixXi()
igl.boundary_facets(F,E);

# Find boundary vertices
b  = igl.eigen.MatrixXi()
IA = igl.eigen.MatrixXi()
IC = igl.eigen.MatrixXi()

igl.unique(E,b,IA,IC);

# List of all vertex indices
vall  = igl.eigen.MatrixXi()
vin   = igl.eigen.MatrixXi()

igl.coloni(0,V.rows()-1,vall)

# List of interior indices
igl.setdiff(vall,b,vin,IA)
# Add the igl library to the modules search path
import sys, os

sys.path.insert(0, os.getcwd() + "/../")

import igl

V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
C = igl.eigen.MatrixXd()

# Load a mesh in OFF format
igl.readOFF("../../tutorial/shared/screwdriver.off", V, F)

# Plot the mesh
viewer = igl.viewer.Viewer()
viewer.data.set_mesh(V, F)

# Use the z coordinate as a scalar field over the surface
Z = V.col(2)

# Compute per-vertex colors
igl.jet(Z, True, C)

# Add per-vertex colors
viewer.data.set_colors(C)

# Launch the viewer
viewer.launch()
Example #11
0
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import igl

# Load a mesh in OFF format
V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
igl.readOFF("../../tutorial/shared/beetle.off", V, F)

# Plot the mesh
viewer = igl.viewer.Viewer();
viewer.data.set_mesh(V, F);
viewer.launch();
Example #12
0
import math

global V
global U
global F
global L

V = igl.eigen.MatrixXd()
U = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()

L = igl.eigen.SparseMatrixd()
viewer = igl.viewer.Viewer()

# Load a mesh in OFF format
igl.readOFF("../tutorial/shared/cow.off", V, F)

# Compute Laplace-Beltrami operator: #V by #V
igl.cotmatrix(V,F,L)

# Alternative construction of same Laplacian
G = igl.eigen.SparseMatrixd()
K = igl.eigen.SparseMatrixd()

# Gradient/Divergence
igl.grad(V,F,G);

# Diagonal per-triangle "mass matrix"
dblA = igl.eigen.MatrixXd()
igl.doublearea(V,F,dblA)
Example #13
0
from __future__ import print_function
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import igl

# Load a mesh in OFF format
V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
igl.readOFF("../../tutorial/shared/cube.off", V, F)

# Print the vertices and faces matrices
print("Vertices: \n", V, sep='')
print("Faces: \n", F, sep='')

# Save the mesh in OBJ format
igl.writeOBJ("cube.obj", V, F)
Example #14
0
## This is a test application for the TCPViewer

# Add the igl library to the modules search path
import sys, os

sys.path.insert(0, os.getcwd() + "/../")

import os
import time

# Launch the tcp viewer
os.system("python ../tcpviewer.py&")

# Wait for it to set up the socket
time.sleep(1)

import igl
import tcpviewer

# Read a mesh
V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
igl.readOFF('../../tutorial/shared/beetle.off', V, F)

# Send it to the viewer
viewer = tcpviewer.TCPViewer()
viewer.data.set_mesh(V, F)
viewer.launch()
        # Global parametrization in 3D with seams
        viewer.data.set_mesh(V, F)
        viewer.data.set_uv(UV_seams, FUV_seams)
        viewer.core.show_texture = True

    viewer.data.set_colors(igl.eigen.MatrixXd([[1, 1, 1]]))

    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/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(),
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import igl

V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()

# Load a mesh in OFF format
igl.readOFF("../../tutorial/shared/bunny.off", V, F)

# Find the bounding box
m = V.colwiseMinCoeff()
M = V.colwiseMaxCoeff()


# Corners of the bounding box
V_box = igl.eigen.MatrixXd(
[
[m[0,0], m[0,1], m[0,2]],
[M[0,0], m[0,1], m[0,2]],
[M[0,0], M[0,1], m[0,2]],
[m[0,0], M[0,1], m[0,2]],
[m[0,0], m[0,1], M[0,2]],
[M[0,0], m[0,1], M[0,2]],
[M[0,0], M[0,1], M[0,2]],
[m[0,0], M[0,1], M[0,2]]
]
)
    if key == ord('1'):
        # # Clear should be called before drawing the mesh
        viewer.data.clear()
        # # Draw_mesh creates or updates the vertices and faces of the displayed mesh.
        # # If a mesh is already displayed, draw_mesh returns an error if the given V and
        # # F have size different than the current ones
        viewer.data.set_mesh(V1, F1)
        viewer.core.align_camera_center(V1, F1)
    elif key == ord('2'):
        viewer.data.clear()
        viewer.data.set_mesh(V2, F2)
        viewer.core.align_camera_center(V2, F2)
    return False


#  Load two meshes
igl.readOFF("../../tutorial/shared/bumpy.off", V1, F1)
igl.readOFF("../../tutorial/shared/fertility.off", V2, F2)

print("1 Switch to bump mesh")
print("2 Switch to fertility mesh")

viewer = igl.viewer.Viewer()

# Register a keyboard callback that allows to switch between
# the two loaded meshes
viewer.callback_key_pressed = key_pressed
viewer.data.set_mesh(V1, F1)
viewer.launch()
# This function is called every time a keyboard button is pressed
def key_pressed(viewer, key, modifier):
    if key == ord('1'):
      viewer.data.set_normals(N_faces)
      return True
    elif key == ord('2'):
      viewer.data.set_normals(N_vertices)
      return True
    elif key == ord('3'):
      viewer.data.set_normals(N_corners)
      return True
    return False

# Load a mesh in OFF format
igl.readOFF("../../tutorial/shared/fandisk.off", V, F);

# Compute per-face normals
N_faces = igl.eigen.MatrixXd()
igl.per_face_normals(V,F,N_faces)

# Compute per-vertex normals
N_vertices = igl.eigen.MatrixXd()
igl.per_vertex_normals(V,F,igl.PER_VERTEX_NORMALS_WEIGHTING_TYPE_AREA,N_vertices)

# Compute per-corner normals, |dihedral angle| > 20 degrees --> crease
N_corners = igl.eigen.MatrixXd()
igl.per_corner_normals(V,F,20,N_corners)

# Plot the mesh
viewer = igl.viewer.Viewer()
# It allows to change the degree of the field when a number is pressed
def key_down(viewer, key, modifier):
    global N
    if key >= ord('1') and key <= ord('9'):
        N = key - ord('0')

    R = igl.eigen.MatrixXd()
    S = igl.eigen.MatrixXd()

    igl.comiso.nrosy(V,F,b,bc,igl.eigen.MatrixXi(),igl.eigen.MatrixXd(),igl.eigen.MatrixXd(),N,0.5,R,S)
    plot_mesh_nrosy(viewer,V,F,N,R,S,b)

    return False

# Load a mesh in OFF format
igl.readOFF("../../tutorial/shared/bumpy.off", V, F);

# Threshold faces with high anisotropy
b  = igl.eigen.MatrixXi([[0]])
bc = igl.eigen.MatrixXd([[1,1,1]])

viewer = igl.viewer.Viewer()

# Interpolate the field and plot
key_down(viewer, ord('4'), 0)

# Plot the mesh
viewer.data.set_mesh(V, F)
viewer.callback_key_down = key_down

# Disable wireframe
Example #20
0
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import igl

V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()

igl.readOFF("../../tutorial/shared/decimated-knight.off", V, F)

# Sort barycenters lexicographically
BC = igl.eigen.MatrixXd()
sorted_BC = igl.eigen.MatrixXd()

igl.barycenter(V, F, BC)

I = igl.eigen.MatrixXi()
J = igl.eigen.MatrixXi()

# sorted_BC = BC(I,:)
igl.sortrows(BC, True, sorted_BC, I)

# Get sorted "place" from sorted indices
J.resize(I.rows(), 1)
# J(I) = 1:numel(I)

igl.slice_into(igl.coloni(0, I.size() - 1), I, J)

# Pseudo-color based on sorted place
C = igl.eigen.MatrixXd()
from __future__ import print_function
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import igl

# Load a mesh in OFF format
V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
igl.readOFF("../../tutorial/shared/cube.off", V, F)

# Print the vertices and faces matrices
print("Vertices: \n", V, sep='')
print("Faces: \n", F, sep='')

# Save the mesh in OBJ format
igl.writeOBJ("cube.obj",V,F)
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import igl

V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
C = igl.eigen.MatrixXd()

# Load a mesh in OFF format
igl.readOFF("../../tutorial/shared/screwdriver.off", V, F)

# Plot the mesh
viewer = igl.viewer.Viewer()
viewer.data.set_mesh(V, F)

# Use the z coordinate as a scalar field over the surface
Z = V.col(2);

# Compute per-vertex colors
igl.jet(Z,True,C)

# Add per-vertex colors
viewer.data.set_colors(C)

# Launch the viewer
viewer.launch()