浏览代码

resolve overlaps optional

Former-commit-id: 0dd452239d07d871f83acb8f8c3a9c58ac398ad4
Alec Jacobson 9 年之前
父节点
当前提交
78e9ca1226
共有 2 个文件被更改,包括 43 次插入0 次删除
  1. 22 0
      include/igl/copyleft/boolean/minkowski_sum.cpp
  2. 21 0
      include/igl/copyleft/boolean/minkowski_sum.h

+ 22 - 0
include/igl/copyleft/boolean/minkowski_sum.cpp

@@ -18,6 +18,7 @@ IGL_INLINE void igl::copyleft::boolean::minkowski_sum(
   const Eigen::PlainObjectBase<DerivedF> & F,
   const Eigen::PlainObjectBase<Deriveds> & s,
   const Eigen::PlainObjectBase<Derivedd> & d,
+  const bool resolve_overlaps, 
   Eigen::PlainObjectBase<DerivedW> & W,
   Eigen::PlainObjectBase<DerivedG> & G,
   Eigen::PlainObjectBase<DerivedJ> & J)
@@ -196,6 +197,7 @@ IGL_INLINE void igl::copyleft::boolean::minkowski_sum(
     GQ.col(0), GQ.col(2), GQ.col(3);
   J.resize(JT.rows()+2*GQ.rows(),1);
   J<<JT,DerivedJ::Constant(2*GQ.rows(),1,2*m+1);
+  if(resolve_overlaps)
   {
     DerivedJ SJ;
     mesh_boolean(
@@ -206,3 +208,23 @@ IGL_INLINE void igl::copyleft::boolean::minkowski_sum(
     J = slice(DerivedJ(J),SJ,1);
   }
 }
+
+template <
+  typename DerivedV,
+  typename DerivedF,
+  typename Deriveds,
+  typename Derivedd,
+  typename DerivedW,
+  typename DerivedG,
+  typename DerivedJ>
+IGL_INLINE void igl::copyleft::boolean::minkowski_sum(
+  const Eigen::PlainObjectBase<DerivedV> & V,
+  const Eigen::PlainObjectBase<DerivedF> & F,
+  const Eigen::PlainObjectBase<Deriveds> & s,
+  const Eigen::PlainObjectBase<Derivedd> & d,
+  Eigen::PlainObjectBase<DerivedW> & W,
+  Eigen::PlainObjectBase<DerivedG> & G,
+  Eigen::PlainObjectBase<DerivedJ> & J)
+{
+  return minkowski_sum(V,F,s,d,true,W,G,J);
+}

+ 21 - 0
include/igl/copyleft/boolean/minkowski_sum.h

@@ -18,6 +18,9 @@ namespace igl
       //   F  #F by 3 list of triangle indices into V
       //   s  segment source endpoint in 3D
       //   d  segment source endpoint in 3D
+      //   resolve_overlaps  whether or not to resolve self-union. If false
+      //     then result may contain self-intersections if input mesh is
+      //     non-convex.
       // Outputs:
       //   W  #W by 3 list of mesh vertices in 3D
       //   G  #G by 3 list of triangle indices into W
@@ -36,9 +39,27 @@ namespace igl
         const Eigen::PlainObjectBase<DerivedF> & F,
         const Eigen::PlainObjectBase<Deriveds> & s,
         const Eigen::PlainObjectBase<Derivedd> & d,
+        const bool resolve_overlaps,
         Eigen::PlainObjectBase<DerivedW> & W,
         Eigen::PlainObjectBase<DerivedG> & G,
         Eigen::PlainObjectBase<DerivedJ> & J);
+      template <
+        typename DerivedV,
+        typename DerivedF,
+        typename Deriveds,
+        typename Derivedd,
+        typename DerivedW,
+        typename DerivedG,
+        typename DerivedJ>
+      IGL_INLINE void minkowski_sum(
+        const Eigen::PlainObjectBase<DerivedV> & V,
+        const Eigen::PlainObjectBase<DerivedF> & F,
+        const Eigen::PlainObjectBase<Deriveds> & s,
+        const Eigen::PlainObjectBase<Derivedd> & d,
+        Eigen::PlainObjectBase<DerivedW> & W,
+        Eigen::PlainObjectBase<DerivedG> & G,
+        Eigen::PlainObjectBase<DerivedJ> & J);
+
     }
   }
 }