Quellcode durchsuchen

Merge pull request #368 from pelayogmp/master

Python bindings for line_mesh_intersection() and barycentric_to_global()

Former-commit-id: 93343b858a5b293fcc46ea5988cf15c971ed69fe
Daniele Panozzo vor 8 Jahren
Ursprung
Commit
773734834e

+ 2 - 0
python/modules/py_igl_embree.cpp

@@ -7,6 +7,7 @@
 
 
 #include <igl/embree/ambient_occlusion.h>
 #include <igl/embree/ambient_occlusion.h>
 #include <igl/embree/reorient_facets_raycast.h>
 #include <igl/embree/reorient_facets_raycast.h>
+#include <igl/embree/line_mesh_intersection.h>
 
 
 
 
 void python_export_igl_embree(py::module &me) {
 void python_export_igl_embree(py::module &me) {
@@ -16,5 +17,6 @@ void python_export_igl_embree(py::module &me) {
 
 
   #include "../py_igl/embree/py_ambient_occlusion.cpp"
   #include "../py_igl/embree/py_ambient_occlusion.cpp"
   #include "../py_igl/embree/py_reorient_facets_raycast.cpp"
   #include "../py_igl/embree/py_reorient_facets_raycast.cpp"
+  #include "../py_igl/embree/py_line_mesh_intersection.cpp"
 
 
 }
 }

+ 31 - 0
python/py_doc.cpp

@@ -76,6 +76,20 @@ const char *__doc_igl_barycentric_coordinates = R"igl_Qu8mg5v7(// Compute baryce
   // Outputs:
   // Outputs:
   //   L  #P by 4 list of barycentric coordinates
   //   L  #P by 4 list of barycentric coordinates
   //   )igl_Qu8mg5v7";
   //   )igl_Qu8mg5v7";
+const char *__doc_igl_barycentric_to_global = R"igl_Qu8mg5v7(// Converts barycentric coordinates in the embree form to 3D coordinates
+  // Embree stores barycentric coordinates as triples: fid, bc1, bc2
+  // fid is the id of a face, bc1 is the displacement of the point wrt the 
+  // first vertex v0 and the edge v1-v0. Similarly, bc2 is the displacement
+  // wrt v2-v0.
+  // 
+  // Input:
+  // V:  #Vx3 Vertices of the mesh
+  // F:  #Fxe Faces of the mesh
+  // bc: #Xx3 Barycentric coordinates, one row per point
+  //
+  // Output:
+  // #X: #Xx3 3D coordinates of all points in bc
+  //   )igl_Qu8mg5v7";
 const char *__doc_igl_bbw_bbw = R"igl_Qu8mg5v7(// Compute Bounded Biharmonic Weights on a given domain (V,Ele) with a given
 const char *__doc_igl_bbw_bbw = R"igl_Qu8mg5v7(// Compute Bounded Biharmonic Weights on a given domain (V,Ele) with a given
     // set of boundary conditions
     // set of boundary conditions
     //
     //
@@ -536,6 +550,23 @@ const char *__doc_igl_embree_reorient_facets_raycast = R"igl_Qu8mg5v7(// Orient
     // Outputs:
     // Outputs:
     //   I  #F list of whether face has been flipped
     //   I  #F list of whether face has been flipped
     //   C  #F list of patch ID (output of bfs_orient > manifold patches))igl_Qu8mg5v7";
     //   C  #F list of patch ID (output of bfs_orient > manifold patches))igl_Qu8mg5v7";
+const char *__doc_igl_embree_line_mesh_intersection = R"igl_Qu8mg5v7(// Project the point cloud V_source onto the triangle mesh
+    // V_target,F_target. 
+    // A ray is casted for every vertex in the direction specified by 
+    // N_source and its opposite.
+    //
+    // Input:
+    // V_source: #Vx3 Vertices of the source mesh
+    // N_source: #Vx3 Normals of the point cloud
+    // V_target: #V2x3 Vertices of the target mesh
+    // F_target: #F2x3 Faces of the target mesh
+    //
+    // Output:
+    // #Vx3 matrix of baricentric coordinate. Each row corresponds to 
+    // a vertex of the projected mesh and it has the following format:
+    // id b1 b2. id is the id of a face of the source mesh. b1 and b2 are 
+    // the barycentric coordinates wrt the first two edges of the triangle
+    // To convert to standard global coordinates, see barycentric_to_global.h)igl_Qu8mg5v7";
 const char *__doc_igl_find_cross_field_singularities = R"igl_Qu8mg5v7(// Inputs:
 const char *__doc_igl_find_cross_field_singularities = R"igl_Qu8mg5v7(// Inputs:
   //   V                #V by 3 eigen Matrix of mesh vertex 3D positions
   //   V                #V by 3 eigen Matrix of mesh vertex 3D positions
   //   F                #F by 3 eigen Matrix of face (quad) indices
   //   F                #F by 3 eigen Matrix of face (quad) indices

+ 2 - 0
python/py_doc.h

@@ -4,6 +4,7 @@ extern const char *__doc_igl_arap_solve;
 extern const char *__doc_igl_avg_edge_length;
 extern const char *__doc_igl_avg_edge_length;
 extern const char *__doc_igl_barycenter;
 extern const char *__doc_igl_barycenter;
 extern const char *__doc_igl_barycentric_coordinates;
 extern const char *__doc_igl_barycentric_coordinates;
+extern const char *__doc_igl_barycentric_to_global;
 extern const char *__doc_igl_bbw_bbw;
 extern const char *__doc_igl_bbw_bbw;
 extern const char *__doc_igl_boundary_conditions;
 extern const char *__doc_igl_boundary_conditions;
 extern const char *__doc_igl_boundary_facets;
 extern const char *__doc_igl_boundary_facets;
@@ -38,6 +39,7 @@ extern const char *__doc_igl_edge_topology;
 extern const char *__doc_igl_eigs;
 extern const char *__doc_igl_eigs;
 extern const char *__doc_igl_embree_ambient_occlusion;
 extern const char *__doc_igl_embree_ambient_occlusion;
 extern const char *__doc_igl_embree_reorient_facets_raycast;
 extern const char *__doc_igl_embree_reorient_facets_raycast;
+extern const char *__doc_igl_embree_line_mesh_intersection;
 extern const char *__doc_igl_find_cross_field_singularities;
 extern const char *__doc_igl_find_cross_field_singularities;
 extern const char *__doc_igl_fit_rotations;
 extern const char *__doc_igl_fit_rotations;
 extern const char *__doc_igl_fit_rotations_planar;
 extern const char *__doc_igl_fit_rotations_planar;

+ 2 - 0
python/py_igl.cpp

@@ -12,6 +12,7 @@
 #include <igl/avg_edge_length.h>
 #include <igl/avg_edge_length.h>
 #include <igl/barycenter.h>
 #include <igl/barycenter.h>
 #include <igl/barycentric_coordinates.h>
 #include <igl/barycentric_coordinates.h>
+#include <igl/barycentric_to_global.h>
 #include <igl/boundary_conditions.h>
 #include <igl/boundary_conditions.h>
 #include <igl/boundary_facets.h>
 #include <igl/boundary_facets.h>
 #include <igl/boundary_loop.h>
 #include <igl/boundary_loop.h>
@@ -105,6 +106,7 @@ void python_export_igl(py::module &m)
 #include "py_igl/py_avg_edge_length.cpp"
 #include "py_igl/py_avg_edge_length.cpp"
 #include "py_igl/py_barycenter.cpp"
 #include "py_igl/py_barycenter.cpp"
 #include "py_igl/py_barycentric_coordinates.cpp"
 #include "py_igl/py_barycentric_coordinates.cpp"
+#include "py_igl/py_barycentric_to_global.cpp"
 #include "py_igl/py_boundary_conditions.cpp"
 #include "py_igl/py_boundary_conditions.cpp"
 #include "py_igl/py_boundary_facets.cpp"
 #include "py_igl/py_boundary_facets.cpp"
 #include "py_igl/py_boundary_loop.cpp"
 #include "py_igl/py_boundary_loop.cpp"

+ 13 - 0
python/py_igl/embree/py_line_mesh_intersection.cpp

@@ -0,0 +1,13 @@
+
+
+m.def("line_mesh_intersection", []
+(
+  const Eigen::MatrixXd& V_source,
+  const Eigen::MatrixXd& N_source,
+  const Eigen::MatrixXd& V_target,
+  const Eigen::MatrixXi& F_target
+)
+{
+  return igl::embree::line_mesh_intersection(V_source, N_source, V_target, F_target);
+}, __doc_igl_embree_line_mesh_intersection,
+py::arg("V_source"), py::arg("N_source"), py::arg("V_target"), py::arg("F_target"));

+ 12 - 0
python/py_igl/py_barycentric_to_global.cpp

@@ -0,0 +1,12 @@
+
+
+m.def("barycentric_to_global", []
+(
+  const Eigen::MatrixXd& V,
+  const Eigen::MatrixXi& F,
+  const Eigen::MatrixXd& bc
+)
+{
+  return igl::barycentric_to_global(V, F, bc);
+}, __doc_igl_barycentric_to_global,
+py::arg("V"), py::arg("F"), py::arg("bc"));

+ 1 - 0
python/python_shared.cpp

@@ -61,6 +61,7 @@ PYBIND11_PLUGIN(pyigl) {
            avg_edge_length
            avg_edge_length
            barycenter
            barycenter
            barycentric_coordinates
            barycentric_coordinates
+           barycentric_to_global
            bbw_bbw
            bbw_bbw
            boundary_conditions
            boundary_conditions
            boundary_facets
            boundary_facets