本文整理汇总了Python中pyigl.readOFF函数的典型用法代码示例。如果您正苦于以下问题:Python readOFF函数的具体用法?Python readOFF怎么用?Python readOFF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readOFF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
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()
示例2: main
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()
示例3:
# 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]]
]
)
示例4: check_dependencies
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()
示例5: ord
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)
示例6:
# 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);
示例7: ord
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()
示例8:
# 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)
示例9: check_dependencies
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)
示例10: ord
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)
示例11: check_dependencies
# 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
示例12: key_pressed
# 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()
示例13: ord
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()
示例14:
# 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();
示例15: check_dependencies
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)