viewer.data().set_mesh(V, F) viewer.core().align_camera_center(V, F) elif key == ord('2'): # Plot the mesh in 2D using the UV coordinates as vertex coordinates viewer.data().set_mesh(V_uv, F) viewer.core().align_camera_center(V_uv, F) viewer.data().compute_normals() return False # Load a mesh in OFF format igl.readOFF(TUTORIAL_SHARED_PATH + "camelhead.off", V, F) # Find the open boundary bnd = igl.eigen.MatrixXi() igl.boundary_loop(F, bnd) # Map the boundary to a circle, preserving edge proportions bnd_uv = igl.eigen.MatrixXd() igl.map_vertices_to_circle(V, bnd, bnd_uv) # Harmonic parametrization for the internal vertices igl.harmonic(V, F, bnd, bnd_uv, 1, V_uv) # Scale UV to make the texture more clear V_uv *= 5 # Plot the mesh viewer = igl.glfw.Viewer() viewer.data().set_mesh(V, F) viewer.data().set_uv(V_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) # Initialize ARAP arap_data.max_iter = 100 # 2 means that we're going to *solve* in 2d