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() igl.readOFF(TUTORIAL_SHARED_PATH + "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
# Compute barycenters of all tets igl.barycenter(V, T, BC) # Compute generalized winding number at all barycenters print("Computing winding number over all %i tets..." % T.rows()) igl.winding_number(V, F, BC, W) # Extract interior tets Wt = sum(W > 0.5) CT = igl.eigen.MatrixXi(Wt, 4) k = 0 for t in range(T.rows()): if W[t] > 0.5: CT.setRow(k, T.row(t)) k += 1 # find bounary facets of interior tets igl.boundary_facets(CT, G) # boundary_facets seem to be reversed... G = G.rowwiseReverse() # normalize W = (W - W.minCoeff()) / (W.maxCoeff() - W.minCoeff()) # Plot the generated mesh viewer = igl.viewer.Viewer() update(viewer) viewer.callback_key_down = key_down viewer.launch()
# 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)
# Compute barycenters of all tets igl.barycenter(V, T, BC) # Compute generalized winding number at all barycenters print("Computing winding number over all %i tets..." % T.rows()) igl.winding_number(V, F, BC, W) # Extract interior tets Wt = sum(W > 0.5) CT = igl.eigen.MatrixXi(Wt, 4) k = 0 for t in range(T.rows()): if W[t] > 0.5: CT.setRow(k, T.row(t)) k += 1 # find bounary facets of interior tets igl.boundary_facets(CT, G) # boundary_facets seem to be reversed... G = G.rowwiseReverse() # normalize W = (W - W.minCoeff()) / (W.maxCoeff() - W.minCoeff()) # Plot the generated mesh viewer = igl.glfw.Viewer() update(viewer) viewer.callback_key_down = key_down viewer.launch()