Ejemplo n.º 1
0
def main():
    # Load a mesh in OFF format
    igl.readOFF("../../tutorial/shared/bunny.off", V1, F1)

    # Init the viewer
    viewer = igl.viewer.Viewer()

    # Extend viewer menu
    viewer.callback_init = viewer_init

    # Plot the mesh
    viewer.data.set_mesh(V1, F1)
    viewer.launch()
Ejemplo n.º 2
0
def main():
    # Load a mesh in OFF format
    igl.readOFF(TUTORIAL_SHARED_PATH + "bumpy.off", V, F)

    # Create a Vector Field
    temp_field = igl.eigen.MatrixXd()
    b = igl.eigen.MatrixXi([[0]])
    bc = igl.eigen.MatrixXd([[1, 1, 1]])
    S = igl.eigen.MatrixXd()  # unused

    degree = 3
    igl.comiso.nrosy(V, F, b, bc, igl.eigen.MatrixXi(), igl.eigen.MatrixXd(), igl.eigen.MatrixXd(), 1, 0.5, temp_field, S)
    temp_field2 = igl.eigen.MatrixXd()
    representative_to_nrosy(V, F, temp_field, degree, temp_field2)

    # Initialize tracer
    igl.streamlines_init(V, F, temp_field2, treat_as_symmetric, data, state)

    # Setup viewer
    viewer = igl.viewer.Viewer()
    viewer.data.set_mesh(V, F)
    viewer.callback_pre_draw = pre_draw
    viewer.callback_key_down = key_down

    viewer.core.show_lines = False

    viewer.core.is_animating = False
    viewer.core.animation_max_fps = 30.0

    # Paint mesh grayish
    C = igl.eigen.MatrixXd()
    C.setConstant(viewer.data.V.rows(), 3, .9)
    viewer.data.set_colors(C)

    # Draw vector field on sample points
    state0 = state.copy()

    igl.streamlines_next(V, F, data, state0)
    v = state0.end_point - state0.start_point
    v = v.rowwiseNormalized()

    viewer.data.add_edges(state0.start_point,
                          state0.start_point + 0.059 * v,
                          igl.eigen.MatrixXd([[1.0, 1.0, 1.0]]))

    print("Press [space] to toggle animation")
    viewer.launch()
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
import sys, os

# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl

from shared import TUTORIAL_SHARED_PATH, check_dependencies

dependencies = ["glfw"]
check_dependencies(dependencies)


# Load mesh
V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
igl.readOFF(TUTORIAL_SHARED_PATH + "bumpy.off", V, F)

# Compute Gaussian curvature
K = igl.eigen.MatrixXd()
igl.gaussian_curvature(V, F, K)

# Compute pseudocolor
C = igl.eigen.MatrixXd()
igl.jet(K, True, C)

# Plot the mesh with pseudocolors
viewer = igl.glfw.Viewer()
viewer.data().set_mesh(V, F)
viewer.data().set_colors(C)
viewer.launch()
import sys, os

# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl

from shared import TUTORIAL_SHARED_PATH, check_dependencies

dependencies = ["viewer"]
check_dependencies(dependencies)

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

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

# Read scalar function values from a file, U: #V by 1
U = igl.eigen.MatrixXd()
igl.readDMAT(TUTORIAL_SHARED_PATH + "cheburashka-scalar.dmat", U)
U = U.col(0)

# Compute gradient operator: #F*3 by #V
G = igl.eigen.SparseMatrixd()
igl.grad(V, F, G)

# Compute gradient of U
GU = (G * U).MapMatrix(F.rows(), 3)

# Compute gradient magnitude
GU_mag = GU.rowwiseNorm()
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import pyigl as igl

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

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);
Ejemplo n.º 8
0
    elif key == ord('q'):
        V_uv = initial_guess

    if show_uv:
        viewer.data().set_mesh(V_uv, F)
        viewer.core.align_camera_center(V_uv, F)
    else:
        viewer.data().set_mesh(V, F)
        viewer.core.align_camera_center(V, F)

    viewer.data().compute_normals()
    return False


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

# Compute the initial solution for ARAP (harmonic parametrization)
bnd = igl.eigen.MatrixXi()
igl.boundary_loop(F, bnd)
bnd_uv = igl.eigen.MatrixXd()
igl.map_vertices_to_circle(V, bnd, bnd_uv)

igl.harmonic(V, F, bnd, bnd_uv, 1, initial_guess)

# Add dynamic regularization to avoid to specify boundary conditions
arap_data = igl.ARAPData()
arap_data.with_dynamics = True
b = igl.eigen.MatrixXi.Zero(0, 0)
bc = igl.eigen.MatrixXd.Zero(0, 0)
Ejemplo n.º 9
0
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import pyigl as 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)
Ejemplo n.º 10
0
        viewer.data().set_colors(C)
    elif key == ord('.'):
        viewer.core.lighting_factor += 0.1
    elif key == ord(','):
        viewer.core.lighting_factor -= 0.1
    else:
        return False

    viewer.core.lighting_factor = min(max(viewer.core.lighting_factor, 0.0), 1.0)
    return True


print("Press 1 to turn off Ambient Occlusion\nPress 2 to turn on Ambient Occlusion\nPress . to turn up lighting\nPress , to turn down lighting")

# Load a surface mesh
igl.readOFF(TUTORIAL_SHARED_PATH + "fertility.off", V, F)

# Calculate vertex normals
igl.per_vertex_normals(V, F, N)

# Compute ambient occlusion factor using embree
igl.embree.ambient_occlusion(V, F, V, N, 500, AO)
AO = 1.0 - AO

# Plot the generated mesh
viewer.data().set_mesh(V, F)
key_down(viewer, ord('2'), 0)
viewer.callback_key_down = key_down
viewer.data().show_lines = False
viewer.core.lighting_factor = 0.0
viewer.launch()
Ejemplo n.º 11
0
# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl

from shared import TUTORIAL_SHARED_PATH, check_dependencies

dependencies = ["viewer"]
check_dependencies(dependencies)


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

# Load a mesh in OFF format
igl.readOFF(TUTORIAL_SHARED_PATH + "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
Ejemplo n.º 12
0
import sys, os

# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl

from shared import TUTORIAL_SHARED_PATH, check_dependencies

dependencies = ["viewer"]
check_dependencies(dependencies)


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

igl.readOFF(TUTORIAL_SHARED_PATH + "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)
Ejemplo n.º 13
0
# 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()
Ejemplo n.º 14
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_PATH + "bumpy.off", V1, F1)
igl.readOFF(TUTORIAL_SHARED_PATH + "fertility.off", V2, F2)

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

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

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

import pyigl as 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]]
]
)
Ejemplo n.º 17
0
if __name__ == "__main__":

    VA = igl.eigen.MatrixXd()
    FA = igl.eigen.MatrixXi()
    VB = igl.eigen.MatrixXd()
    FB = igl.eigen.MatrixXi()
    VC = igl.eigen.MatrixXd()
    FC = igl.eigen.MatrixXi()
    J = igl.eigen.MatrixXi()

    Red = igl.eigen.MatrixXd([[1, 0, 0]])
    Green = igl.eigen.MatrixXd([[0, 1, 0]])

    # Load meshes in OFF format
    igl.readOFF(TUTORIAL_SHARED_PATH + "cheburashka.off", VA, FA)
    igl.readOFF(TUTORIAL_SHARED_PATH + "decimated-knight.off", VB, FB)

    boolean_type = igl.MESH_BOOLEAN_TYPE_UNION

    viewer = igl.viewer.Viewer()
    update(viewer)

    print(
        "Usage: Press '.' to switch to next boolean operation type. \nPress ',' to switch to previous boolean operation type. \nPress ']' to push near cutting plane away from camera. \nPress '[' to pull near cutting plane closer to camera. \nHint: investigate _inside_ the model to see orientation changes. \n")

    viewer.core.show_lines = True
    viewer.callback_key_down = key_down
    viewer.core.camera_dnear = 3.9
    viewer.launch()
Ejemplo n.º 18
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)
Ejemplo n.º 19
0
from shared import TUTORIAL_SHARED_PATH, check_dependencies

dependencies = ["viewer"]
check_dependencies(dependencies)


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_PATH + "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)
Ejemplo n.º 20
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 pyigl as 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()
Ejemplo n.º 21
0
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import pyigl as igl

# Load mesh
V = igl.eigen.MatrixXd()
F = igl.eigen.MatrixXi()
igl.readOFF("../../tutorial/shared/bumpy.off",V,F);

# Compute Gaussian curvature
K = igl.eigen.MatrixXd();
igl.gaussian_curvature(V,F,K);

# Compute pseudocolor
C = igl.eigen.MatrixXd();
igl.jet(K,True,C);

# Plot the mesh with pseudocolors
viewer = igl.viewer.Viewer()
viewer.data.set_mesh(V, F)
viewer.data.set_colors(C)
viewer.launch()
Ejemplo n.º 22
0
# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl

from shared import TUTORIAL_SHARED_PATH, check_dependencies

dependencies = ["glfw"]
check_dependencies(dependencies)


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

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

# Read scalar function values from a file, U: #V by 1
U = igl.eigen.MatrixXd()
igl.readDMAT(TUTORIAL_SHARED_PATH + "cheburashka-scalar.dmat", U)
U = U.col(0)

# Compute gradient operator: #F*3 by #V
G = igl.eigen.SparseMatrixd()
igl.grad(V, F, G)

# Compute gradient of U
GU = (G * U).MapMatrix(F.rows(), 3)

# Compute gradient magnitude
GU_mag = GU.rowwiseNorm()
Ejemplo n.º 23
0
        viewer.data.set_colors(C)

        # Plot a line for each edge of the quad mesh
        viewer.data.add_edges(PQC0plan, PQC1plan, igl.eigen.MatrixXd([[0, 0, 0]]))
        viewer.data.add_edges(PQC1plan, PQC2plan, igl.eigen.MatrixXd([[0, 0, 0]]))
        viewer.data.add_edges(PQC2plan, PQC3plan, igl.eigen.MatrixXd([[0, 0, 0]]))
        viewer.data.add_edges(PQC3plan, PQC0plan, igl.eigen.MatrixXd([[0, 0, 0]]))

    else:
        return False

    return True


# Load a quad mesh generated by a conjugate field
igl.readOFF(TUTORIAL_SHARED_PATH + "inspired_mesh_quads_Conjugate.off", VQC, FQC)

# Convert it to a triangle mesh
FQCtri.resize(2 * FQC.rows(), 3)

FQCtriUpper = igl.eigen.MatrixXi(FQC.rows(), 3)
FQCtriLower = igl.eigen.MatrixXi(FQC.rows(), 3)

FQCtriUpper.setCol(0, FQC.col(0))
FQCtriUpper.setCol(1, FQC.col(1))
FQCtriUpper.setCol(2, FQC.col(2))
FQCtriLower.setCol(0, FQC.col(2))
FQCtriLower.setCol(1, FQC.col(3))
FQCtriLower.setCol(2, FQC.col(0))

FQCtri.setTopRows(FQCtriUpper.rows(), FQCtriUpper)
Ejemplo n.º 24
0
# This file is part of libigl, a simple c++ geometry processing library.
#
# Copyright (C) 2017 Sebastian Koch <*****@*****.**> and Daniele Panozzo <*****@*****.**>
#
# This Source Code Form is subject to the terms of the Mozilla Public License
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
import sys, os

# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl

from shared import TUTORIAL_SHARED_PATH, check_dependencies

dependencies = ["viewer"]
check_dependencies(dependencies)


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

# Plot the mesh
viewer = igl.viewer.Viewer()
viewer.data.set_mesh(V, F)
viewer.launch()
Ejemplo n.º 25
0
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import pyigl as 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()
Ejemplo n.º 26
0
        # Global parametrization in 3D with seams
        viewer.data().set_mesh(V, F)
        viewer.data().set_uv(UV_seams, FUV_seams)
        viewer.data().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_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)
Ejemplo n.º 27
0
# Add the igl library to the modules search path
import sys, os
sys.path.insert(0, os.getcwd() + "/../")

import pyigl as 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()
Ejemplo n.º 28
0
# 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_PATH + "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()
Ejemplo n.º 29
0
# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl

from shared import TUTORIAL_SHARED_PATH, check_dependencies

dependencies = ["glfw"]
check_dependencies(dependencies)


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

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

# Plot the mesh
viewer = igl.glfw.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