Browse Source

missing documentation rename

Former-commit-id: 43c12bec0d3e018010da267f04c1dd78e4e88324
Alec Jacobson 9 years ago
parent
commit
979a2421f7
2 changed files with 180 additions and 143 deletions
  1. 101 100
      include/igl/copyleft/boolean/mesh_boolean.cpp
  2. 79 43
      include/igl/copyleft/boolean/mesh_boolean.h

+ 101 - 100
include/igl/copyleft/boolean/mesh_boolean.cpp

@@ -179,110 +179,111 @@ typename ResolveFunc,
 typename DerivedVC,
 typename DerivedFC,
 typename DerivedJ>
-IGL_INLINE void igl::copyleft::boolean::per_face_winding_number_binary_operation(
-        const Eigen::PlainObjectBase<DerivedVA> & VA,
-        const Eigen::PlainObjectBase<DerivedFA> & FA,
-        const Eigen::PlainObjectBase<DerivedVB> & VB,
-        const Eigen::PlainObjectBase<DerivedFB> & FB,
-        const WindingNumberOp& wind_num_op,
-        const KeepFunc& keep,
-        const ResolveFunc& resolve_fun,
-        Eigen::PlainObjectBase<DerivedVC > & VC,
-        Eigen::PlainObjectBase<DerivedFC > & FC,
-        Eigen::PlainObjectBase<DerivedJ > & J) {
-    using namespace igl::copyleft::boolean::mesh_boolean_helper;
+IGL_INLINE void igl::copyleft::boolean::mesh_boolean(
+  const Eigen::PlainObjectBase<DerivedVA> & VA,
+  const Eigen::PlainObjectBase<DerivedFA> & FA,
+  const Eigen::PlainObjectBase<DerivedVB> & VB,
+  const Eigen::PlainObjectBase<DerivedFB> & FB,
+  const WindingNumberOp& wind_num_op,
+  const KeepFunc& keep,
+  const ResolveFunc& resolve_fun,
+  Eigen::PlainObjectBase<DerivedVC > & VC,
+  Eigen::PlainObjectBase<DerivedFC > & FC,
+  Eigen::PlainObjectBase<DerivedJ > & J)
+{
+  using namespace igl::copyleft::boolean::mesh_boolean_helper;
 
-    typedef typename DerivedVC::Scalar Scalar;
-    typedef typename DerivedFC::Scalar Index;
-    typedef Eigen::Matrix<Scalar,Eigen::Dynamic,3> MatrixX3S;
-    typedef Eigen::Matrix<Index,Eigen::Dynamic,Eigen::Dynamic> MatrixXI;
-    typedef Eigen::Matrix<typename DerivedJ::Scalar,Eigen::Dynamic,1> VectorXJ;
+  typedef typename DerivedVC::Scalar Scalar;
+  typedef typename DerivedFC::Scalar Index;
+  typedef Eigen::Matrix<Scalar,Eigen::Dynamic,3> MatrixX3S;
+  typedef Eigen::Matrix<Index,Eigen::Dynamic,Eigen::Dynamic> MatrixXI;
+  typedef Eigen::Matrix<typename DerivedJ::Scalar,Eigen::Dynamic,1> VectorXJ;
 
-    // Generate combined mesh.
-    typedef Eigen::Matrix<
-        ExactScalar,
-        Eigen::Dynamic,
-        Eigen::Dynamic,
-        DerivedVC::IsRowMajor> MatrixXES;
-    MatrixXES V;
-    DerivedFC F;
-    VectorXJ  CJ;
-    resolve_intersections(VA, FA, VB, FB, resolve_fun, V, F, CJ);
+  // Generate combined mesh.
+  typedef Eigen::Matrix<
+      ExactScalar,
+      Eigen::Dynamic,
+      Eigen::Dynamic,
+      DerivedVC::IsRowMajor> MatrixXES;
+  MatrixXES V;
+  DerivedFC F;
+  VectorXJ  CJ;
+  resolve_intersections(VA, FA, VB, FB, resolve_fun, V, F, CJ);
 
-    // Compute winding numbers on each side of each facet.
-    const size_t num_faces = F.rows();
-    Eigen::MatrixXi W;
-    Eigen::VectorXi labels(num_faces);
-    std::transform(CJ.data(), CJ.data()+CJ.size(), labels.data(),
-            [&](int i) { return i<FA.rows() ? 0:1; });
-    igl::copyleft::cgal::propagate_winding_numbers(V, F, labels, W);
-    assert(W.rows() == num_faces);
-    if (W.cols() == 2) {
-        assert(FB.rows() == 0);
-        Eigen::MatrixXi W_tmp(num_faces, 4);
-        W_tmp << W, Eigen::MatrixXi::Zero(num_faces, 2);
-        W = W_tmp;
-    } else {
-        assert(W.cols() == 4);
-    }
+  // Compute winding numbers on each side of each facet.
+  const size_t num_faces = F.rows();
+  Eigen::MatrixXi W;
+  Eigen::VectorXi labels(num_faces);
+  std::transform(CJ.data(), CJ.data()+CJ.size(), labels.data(),
+          [&](int i) { return i<FA.rows() ? 0:1; });
+  igl::copyleft::cgal::propagate_winding_numbers(V, F, labels, W);
+  assert(W.rows() == num_faces);
+  if (W.cols() == 2) {
+      assert(FB.rows() == 0);
+      Eigen::MatrixXi W_tmp(num_faces, 4);
+      W_tmp << W, Eigen::MatrixXi::Zero(num_faces, 2);
+      W = W_tmp;
+  } else {
+      assert(W.cols() == 4);
+  }
 
-    // Compute resulting winding number.
-    Eigen::MatrixXi Wr(num_faces, 2);
-    for (size_t i=0; i<num_faces; i++) {
-        Eigen::MatrixXi w_out(1,2), w_in(1,2);
-        w_out << W(i,0), W(i,2);
-        w_in  << W(i,1), W(i,3);
-        Wr(i,0) = wind_num_op(w_out);
-        Wr(i,1) = wind_num_op(w_in);
-    }
+  // Compute resulting winding number.
+  Eigen::MatrixXi Wr(num_faces, 2);
+  for (size_t i=0; i<num_faces; i++) {
+      Eigen::MatrixXi w_out(1,2), w_in(1,2);
+      w_out << W(i,0), W(i,2);
+      w_in  << W(i,1), W(i,3);
+      Wr(i,0) = wind_num_op(w_out);
+      Wr(i,1) = wind_num_op(w_in);
+  }
 
-    // Extract boundary separating inside from outside.
-    auto index_to_signed_index = [&](size_t i, bool ori) -> int{
-        return (i+1)*(ori?1:-1);
-    };
-    auto signed_index_to_index = [&](int i) -> size_t {
-        return abs(i) - 1;
-    };
-    std::vector<int> selected;
-    for(size_t i=0; i<num_faces; i++) {
-        auto should_keep = keep(Wr(i,0), Wr(i,1));
-        if (should_keep > 0) {
-            selected.push_back(index_to_signed_index(i, true));
-        } else if (should_keep < 0) {
-            selected.push_back(index_to_signed_index(i, false));
-        }
-    }
+  // Extract boundary separating inside from outside.
+  auto index_to_signed_index = [&](size_t i, bool ori) -> int{
+      return (i+1)*(ori?1:-1);
+  };
+  auto signed_index_to_index = [&](int i) -> size_t {
+      return abs(i) - 1;
+  };
+  std::vector<int> selected;
+  for(size_t i=0; i<num_faces; i++) {
+      auto should_keep = keep(Wr(i,0), Wr(i,1));
+      if (should_keep > 0) {
+          selected.push_back(index_to_signed_index(i, true));
+      } else if (should_keep < 0) {
+          selected.push_back(index_to_signed_index(i, false));
+      }
+  }
 
-    const size_t num_selected = selected.size();
-    DerivedFC kept_faces(num_selected, 3);
-    DerivedJ  kept_face_indices;
-    kept_face_indices.resize(num_selected, 1);
-    for (size_t i=0; i<num_selected; i++) {
-        size_t idx = abs(selected[i]) - 1;
-        if (selected[i] > 0) {
-            kept_faces.row(i) = F.row(idx);
-        } else {
-            kept_faces.row(i) = F.row(idx).reverse();
-        }
-        kept_face_indices(i, 0) = CJ[idx];
-    }
+  const size_t num_selected = selected.size();
+  DerivedFC kept_faces(num_selected, 3);
+  DerivedJ  kept_face_indices;
+  kept_face_indices.resize(num_selected, 1);
+  for (size_t i=0; i<num_selected; i++) {
+      size_t idx = abs(selected[i]) - 1;
+      if (selected[i] > 0) {
+          kept_faces.row(i) = F.row(idx);
+      } else {
+          kept_faces.row(i) = F.row(idx).reverse();
+      }
+      kept_face_indices(i, 0) = CJ[idx];
+  }
 
 
-    // Finally, remove duplicated faces and unreferenced vertices.
-    {
-        DerivedFC G;
-        DerivedJ J;
-        resolve_duplicated_faces(kept_faces, kept_face_indices, G, J);
+  // Finally, remove duplicated faces and unreferenced vertices.
+  {
+      DerivedFC G;
+      DerivedJ J;
+      resolve_duplicated_faces(kept_faces, kept_face_indices, G, J);
 
-        MatrixX3S Vs(V.rows(), V.cols());
-        for (size_t i=0; i<V.rows(); i++) {
-            for (size_t j=0; j<V.cols(); j++) {
-                igl::copyleft::cgal::assign_scalar(V(i,j), Vs(i,j));
-            }
-        }
-        Eigen::VectorXi newIM;
-        igl::remove_unreferenced(Vs,G,VC,FC,newIM);
-    }
+      MatrixX3S Vs(V.rows(), V.cols());
+      for (size_t i=0; i<V.rows(); i++) {
+          for (size_t j=0; j<V.cols(); j++) {
+              igl::copyleft::cgal::assign_scalar(V(i,j), Vs(i,j));
+          }
+      }
+      Eigen::VectorXi newIM;
+      igl::remove_unreferenced(Vs,G,VC,FC,newIM);
+  }
 }
 
 template <
@@ -309,28 +310,28 @@ IGL_INLINE void igl::copyleft::boolean::mesh_boolean(
 
     switch (type) {
         case MESH_BOOLEAN_TYPE_UNION:
-            igl::copyleft::boolean::per_face_winding_number_binary_operation(
+            igl::copyleft::boolean::mesh_boolean(
                     VA, FA, VB, FB, igl::copyleft::boolean::BinaryUnion(),
                     igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
             break;
         case MESH_BOOLEAN_TYPE_INTERSECT:
-            igl::copyleft::boolean::per_face_winding_number_binary_operation(
+            igl::copyleft::boolean::mesh_boolean(
                     VA, FA, VB, FB, igl::copyleft::boolean::BinaryIntersect(),
                     igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
             break;
         case MESH_BOOLEAN_TYPE_MINUS:
-            igl::copyleft::boolean::per_face_winding_number_binary_operation(
+            igl::copyleft::boolean::mesh_boolean(
                     VA, FA, VB, FB, igl::copyleft::boolean::BinaryMinus(),
                     igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
             break;
         case MESH_BOOLEAN_TYPE_XOR:
-            igl::copyleft::boolean::per_face_winding_number_binary_operation(
+            igl::copyleft::boolean::mesh_boolean(
                     VA, FA, VB, FB, igl::copyleft::boolean::BinaryXor(),
                     igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
             break;
         case MESH_BOOLEAN_TYPE_RESOLVE:
             //op = binary_resolve();
-            igl::copyleft::boolean::per_face_winding_number_binary_operation(
+            igl::copyleft::boolean::mesh_boolean(
                     VA, FA, VB, FB, igl::copyleft::boolean::BinaryResolve(),
                     igl::copyleft::boolean::KeepAll(), resolve_func, VC, FC, J);
             break;

+ 79 - 43
include/igl/copyleft/boolean/mesh_boolean.h

@@ -21,30 +21,7 @@ namespace igl
   {
     namespace boolean
     {
-      template <
-          typename DerivedVA,
-          typename DerivedFA,
-          typename DerivedVB,
-          typename DerivedFB,
-          typename WindingNumberOp,
-          typename IsInsideFunc,
-          typename ResolveFunc,
-          typename DerivedVC,
-          typename DerivedFC,
-          typename DerivedJ>
-      IGL_INLINE void per_face_winding_number_binary_operation(
-              const Eigen::PlainObjectBase<DerivedVA> & VA,
-              const Eigen::PlainObjectBase<DerivedFA> & FA,
-              const Eigen::PlainObjectBase<DerivedVB> & VB,
-              const Eigen::PlainObjectBase<DerivedFB> & FB,
-              const WindingNumberOp& wind_num_op,
-              const IsInsideFunc& is_inside,
-              const ResolveFunc& resolve_fun,
-              Eigen::PlainObjectBase<DerivedVC > & VC,
-              Eigen::PlainObjectBase<DerivedFC > & FC,
-              Eigen::PlainObjectBase<DerivedJ > & J);
-      //  MESH_BOOLEAN Compute boolean csg operations on "solid",
-      //  consistently
+      //  MESH_BOOLEAN Compute boolean csg operations on "solid", consistently
       //  oriented meshes.
       // 
       //  Inputs:
@@ -52,7 +29,10 @@ namespace igl
       //    FA  #FA by 3 list of triangle indices into VA
       //    VB  #VB by 3 list of vertex positions of second mesh
       //    FB  #FB by 3 list of triangle indices into VB
-      //    type  type of boolean operation
+      //    wind_num_op  function handle for filtering winding numbers from
+      //      tuples of integer values to [0,1] outside/inside values
+      //    keep  function handle for determining if a patch should be "kept"
+      //      in the output based on the winding number on either side
       //    resolve_fun  function handle for computing resolve of a
       //      self-intersections of a mesh and outputting the new mesh.
       //  Outputs:
@@ -63,7 +43,43 @@ namespace igl
       //  See also: mesh_boolean_cork, intersect_other,
       //  remesh_self_intersections
       //     
-
+      template <
+        typename DerivedVA,
+        typename DerivedFA,
+        typename DerivedVB,
+        typename DerivedFB,
+        typename WindingNumberOp,
+        typename KeepFunc,
+        typename ResolveFunc,
+        typename DerivedVC,
+        typename DerivedFC,
+        typename DerivedJ>
+      IGL_INLINE void mesh_boolean(
+        const Eigen::PlainObjectBase<DerivedVA> & VA,
+        const Eigen::PlainObjectBase<DerivedFA> & FA,
+        const Eigen::PlainObjectBase<DerivedVB> & VB,
+        const Eigen::PlainObjectBase<DerivedFB> & FB,
+        const WindingNumberOp& wind_num_op,
+        const KeepFunc& keep,
+        const ResolveFunc& resolve_fun,
+        Eigen::PlainObjectBase<DerivedVC > & VC,
+        Eigen::PlainObjectBase<DerivedFC > & FC,
+        Eigen::PlainObjectBase<DerivedJ > & J);
+      //  Inputs:
+      //    VA  #VA by 3 list of vertex positions of first mesh
+      //    FA  #FA by 3 list of triangle indices into VA
+      //    VB  #VB by 3 list of vertex positions of second mesh
+      //    FB  #FB by 3 list of triangle indices into VB
+      //    type  type of boolean operation
+      //    resolve_fun  function handle for computing resolve of a
+      //      self-intersections of a mesh and outputting the new mesh.
+      //  Outputs:
+      //    VC  #VC by 3 list of vertex positions of boolean result mesh
+      //    FC  #FC by 3 list of triangle indices into VC
+      //    J  #FC list of indices into [FA;FB] revealing "birth" facet
+      //
+      //  See also: mesh_boolean_cork, intersect_other,
+      //  remesh_self_intersections
       template <
         typename DerivedVA,
         typename DerivedFA,
@@ -83,7 +99,19 @@ namespace igl
         Eigen::PlainObjectBase<DerivedVC > & VC,
         Eigen::PlainObjectBase<DerivedFC > & FC,
         Eigen::PlainObjectBase<DerivedJ > & J);
-
+      //  Inputs:
+      //    VA  #VA by 3 list of vertex positions of first mesh
+      //    FA  #FA by 3 list of triangle indices into VA
+      //    VB  #VB by 3 list of vertex positions of second mesh
+      //    FB  #FB by 3 list of triangle indices into VB
+      //    type  type of boolean operation
+      //  Outputs:
+      //    VC  #VC by 3 list of vertex positions of boolean result mesh
+      //    FC  #FC by 3 list of triangle indices into VC
+      //    J  #FC list of indices into [FA;FB] revealing "birth" facet
+      //
+      //  See also: mesh_boolean_cork, intersect_other,
+      //  remesh_self_intersections
       template <
         typename DerivedVA,
         typename DerivedFA,
@@ -101,22 +129,30 @@ namespace igl
         Eigen::PlainObjectBase<DerivedVC > & VC,
         Eigen::PlainObjectBase<DerivedFC > & FC,
         Eigen::PlainObjectBase<DerivedJ > & J);
-
-    template <
-      typename DerivedVA,
-      typename DerivedFA,
-      typename DerivedVB,
-      typename DerivedFB,
-      typename DerivedVC,
-      typename DerivedFC>
-    IGL_INLINE void mesh_boolean(
-      const Eigen::PlainObjectBase<DerivedVA > & VA,
-      const Eigen::PlainObjectBase<DerivedFA > & FA,
-      const Eigen::PlainObjectBase<DerivedVB > & VB,
-      const Eigen::PlainObjectBase<DerivedFB > & FB,
-      const MeshBooleanType & type,
-      Eigen::PlainObjectBase<DerivedVC > & VC,
-      Eigen::PlainObjectBase<DerivedFC > & FC);
+      //  Inputs:
+      //    VA  #VA by 3 list of vertex positions of first mesh
+      //    FA  #FA by 3 list of triangle indices into VA
+      //    VB  #VB by 3 list of vertex positions of second mesh
+      //    FB  #FB by 3 list of triangle indices into VB
+      //    type  type of boolean operation
+      //  Outputs:
+      //    VC  #VC by 3 list of vertex positions of boolean result mesh
+      //    FC  #FC by 3 list of triangle indices into VC
+      template <
+        typename DerivedVA,
+        typename DerivedFA,
+        typename DerivedVB,
+        typename DerivedFB,
+        typename DerivedVC,
+        typename DerivedFC>
+      IGL_INLINE void mesh_boolean(
+        const Eigen::PlainObjectBase<DerivedVA > & VA,
+        const Eigen::PlainObjectBase<DerivedFA > & FA,
+        const Eigen::PlainObjectBase<DerivedVB > & VB,
+        const Eigen::PlainObjectBase<DerivedFB > & FB,
+        const MeshBooleanType & type,
+        Eigen::PlainObjectBase<DerivedVC > & VC,
+        Eigen::PlainObjectBase<DerivedFC > & FC);
     }
   }
 }