浏览代码

option to return non solid mesh for rendering

Former-commit-id: f8fce70692059eeaadf30523e99d688fc9152005
Alec Jacobson 7 年之前
父节点
当前提交
3c5e4cf634
共有 2 个文件被更改,包括 66 次插入22 次删除
  1. 31 6
      include/igl/copyleft/cgal/wire_mesh.cpp
  2. 35 16
      include/igl/copyleft/cgal/wire_mesh.h

+ 31 - 6
include/igl/copyleft/cgal/wire_mesh.cpp

@@ -18,6 +18,7 @@ IGL_INLINE void igl::copyleft::cgal::wire_mesh(
   const Eigen::MatrixBase<DerivedWE> & WE,
   const Eigen::MatrixBase<DerivedWE> & WE,
   const double th,
   const double th,
   const int poly_size,
   const int poly_size,
+  const bool solid,
   Eigen::PlainObjectBase<DerivedV> & V,
   Eigen::PlainObjectBase<DerivedV> & V,
   Eigen::PlainObjectBase<DerivedF> & F,
   Eigen::PlainObjectBase<DerivedF> & F,
   Eigen::PlainObjectBase<DerivedJ> & J)
   Eigen::PlainObjectBase<DerivedJ> & J)
@@ -166,12 +167,36 @@ IGL_INLINE void igl::copyleft::cgal::wire_mesh(
   }
   }
 
 
   list_to_matrix(vF,F);
   list_to_matrix(vF,F);
-  // Self-union to clean up 
-  igl::copyleft::cgal::mesh_boolean(
-    Eigen::MatrixXd(V),Eigen::MatrixXi(F),Eigen::MatrixXd(),Eigen::MatrixXi(),
-    "union",
-    V,F,J);
-  for(int j=0;j<J.size();j++) J(j) = vJ[J(j)];
+  if(solid)
+  {
+    // Self-union to clean up 
+    igl::copyleft::cgal::mesh_boolean(
+      Eigen::MatrixXd(V),Eigen::MatrixXi(F),Eigen::MatrixXd(),Eigen::MatrixXi(),
+      "union",
+      V,F,J);
+    for(int j=0;j<J.size();j++) J(j) = vJ[J(j)];
+  }else
+  {
+    list_to_matrix(vJ,J);
+  }
+}
+
+template <
+  typename DerivedWV,
+  typename DerivedWE,
+  typename DerivedV,
+  typename DerivedF,
+  typename DerivedJ>
+IGL_INLINE void igl::copyleft::cgal::wire_mesh(
+  const Eigen::MatrixBase<DerivedWV> & WV,
+  const Eigen::MatrixBase<DerivedWE> & WE,
+  const double th,
+  const int poly_size,
+  Eigen::PlainObjectBase<DerivedV> & V,
+  Eigen::PlainObjectBase<DerivedF> & F,
+  Eigen::PlainObjectBase<DerivedJ> & J)
+{
+  return wire_mesh(WV,WE,th,poly_size,true,V,F,J);
 }
 }
 
 
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY

+ 35 - 16
include/igl/copyleft/cgal/wire_mesh.h

@@ -6,24 +6,26 @@ namespace igl
 {
 {
   namespace copyleft
   namespace copyleft
   {
   {
-    // Construct a "wire" or "wireframe" or "strut" surface mesh, given a
-    // one-dimensional network of straight edges.
-    //
-    // Inputs:
-    //   WV  #WV by 3 list of vertex positions
-    //   WE  #WE by 2 list of edge indices into WV
-    //   th  diameter thickness of wire 
-    //   poly_size  number of sides on each wire (e.g., 4 would produce wires by
-    //     connecting rectangular prisms).
-    // Outputs:
-    //   V  #V by 3 list of output vertices
-    //   F  #F by 3 list of output triangle indices into V
-    //   J  #F list of indices into [0,#WV+#WE) revealing "birth simplex" of
-    //     output faces J(j) < #WV means the face corresponds to the J(j)th
-    //     vertex in WV. J(j) >= #WV means the face corresponds to the
-    //     (J(j)-#WV)th edge in WE.
     namespace cgal
     namespace cgal
     {
     {
+      // Construct a "wire" or "wireframe" or "strut" surface mesh, given a
+      // one-dimensional network of straight edges.
+      //
+      // Inputs:
+      //   WV  #WV by 3 list of vertex positions
+      //   WE  #WE by 2 list of edge indices into WV
+      //   th  diameter thickness of wire 
+      //   poly_size  number of sides on each wire (e.g., 4 would produce wires by
+      //     connecting rectangular prisms).
+      //   solid  whether to resolve self-intersections to
+      //     create a "solid" output mesh (cf., [Zhou et al. 2016]
+      // Outputs:
+      //   V  #V by 3 list of output vertices
+      //   F  #F by 3 list of output triangle indices into V
+      //   J  #F list of indices into [0,#WV+#WE) revealing "birth simplex" of
+      //     output faces J(j) < #WV means the face corresponds to the J(j)th
+      //     vertex in WV. J(j) >= #WV means the face corresponds to the
+      //     (J(j)-#WV)th edge in WE.
       template <
       template <
         typename DerivedWV,
         typename DerivedWV,
         typename DerivedWE,
         typename DerivedWE,
@@ -35,9 +37,26 @@ namespace igl
         const Eigen::MatrixBase<DerivedWE> & WE,
         const Eigen::MatrixBase<DerivedWE> & WE,
         const double th,
         const double th,
         const int poly_size,
         const int poly_size,
+        const bool solid,
         Eigen::PlainObjectBase<DerivedV> & V,
         Eigen::PlainObjectBase<DerivedV> & V,
         Eigen::PlainObjectBase<DerivedF> & F,
         Eigen::PlainObjectBase<DerivedF> & F,
         Eigen::PlainObjectBase<DerivedJ> & J);
         Eigen::PlainObjectBase<DerivedJ> & J);
+      // Default with solid=true
+      template <
+        typename DerivedWV,
+        typename DerivedWE,
+        typename DerivedV,
+        typename DerivedF,
+        typename DerivedJ>
+      IGL_INLINE void wire_mesh(
+        const Eigen::MatrixBase<DerivedWV> & WV,
+        const Eigen::MatrixBase<DerivedWE> & WE,
+        const double th,
+        const int poly_size,
+        Eigen::PlainObjectBase<DerivedV> & V,
+        Eigen::PlainObjectBase<DerivedF> & F,
+        Eigen::PlainObjectBase<DerivedJ> & J);
+
     }
     }
   }
   }
 }
 }