Эх сурвалжийг харах

added 502

Former-commit-id: b386614cb66676cc34f0c5b58fd7a8fbd6f62483
Daniele Panozzo 9 жил өмнө
parent
commit
4cfbb151a4

+ 50 - 0
python/502_LSCMParam.py

@@ -0,0 +1,50 @@
+import igl
+
+V = igl.eigen.MatrixXd()
+F = igl.eigen.MatrixXi()
+V_uv = igl.eigen.MatrixXd()
+
+def key_down(viewer, key, modifier):
+    if key == ord('1'):
+        # Plot the 3D mesh
+        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/camelhead.off", V, F);
+
+# Fix two points on the boundary
+bnd = igl.eigen.MatrixXi()
+b   = igl.eigen.MatrixXi(2,1)
+
+igl.boundary_loop(F,bnd)
+b[0] = bnd[0]
+b[1] = bnd[int(bnd.size()/2)]
+bc = igl.eigen.MatrixXd([[0,0],[1,0]])
+
+# LSCM parametrization
+igl.lscm(V,F,b,bc,V_uv)
+
+# Scale the uv
+V_uv *= 5
+
+# Plot the mesh
+viewer = igl.viewer.Viewer()
+viewer.data.set_mesh(V, F)
+viewer.data.set_uv(V_uv)
+viewer.callback_key_down = key_down
+
+# Disable wireframe
+viewer.core.show_lines = False
+
+# Draw checkerboard texture
+viewer.core.show_texture = True
+
+# Launch the viewer
+viewer.launch()

+ 2 - 1
python/py_igl.cpp

@@ -38,6 +38,7 @@
 #include <igl/ARAPEnergyType.h>
 #include <igl/boundary_loop.h>
 #include <igl/map_vertices_to_circle.h>
+#include <igl/lscm.h>
 
 void python_export_igl(py::module &m)
 {
@@ -77,5 +78,5 @@ void python_export_igl(py::module &m)
 #include "py_igl/py_arap.cpp"
 #include "py_igl/py_boundary_loop.cpp"
 #include "py_igl/py_map_vertices_to_circle.cpp"
-
+#include "py_igl/py_lscm.cpp"
 }

+ 13 - 0
python/py_igl/py_lscm.cpp

@@ -0,0 +1,13 @@
+m.def("lscm", []
+(
+  const Eigen::MatrixXd& V,
+  const Eigen::MatrixXi& F,
+  const Eigen::MatrixXi& b,
+  const Eigen::MatrixXd& bc,
+  Eigen::MatrixXd& V_uv
+)
+{
+  assert_is_VectorX("b",b);
+  return igl::lscm(V,F,b,bc,V_uv);
+}, __doc_igl_lscm,
+py::arg("V"), py::arg("F"), py::arg("b"), py::arg("bc"), py::arg("V_uv"));