Jelajahi Sumber

intersect_other compute intersections between two meshes

Former-commit-id: 9b3644413e401c8488ad3a313c3b288e108425f2
Alec Jacobson 11 tahun lalu
induk
melakukan
d695449201

+ 2 - 1
include/igl/active_set.h

@@ -38,7 +38,8 @@ namespace igl
   //   lx  n by 1 list of lower bounds [] implies -Inf
   //   ux  n by 1 list of upper bounds [] implies Inf
   //   params  struct of additional parameters (see below)
-  //   Z, if not empty, is taken to be an n by 1 list of initial guess values
+  //   Z  if not empty, is taken to be an n by 1 list of initial guess values
+  //     (see output)
   // Outputs:
   //   Z  n by 1 list of solution values
   // Returns true on success, false on error

+ 9 - 17
include/igl/cgal/SelfIntersectMesh.h

@@ -9,6 +9,10 @@
 #include <map>
 #include <vector>
 
+#ifndef IGL_FIRST_HIT_EXCEPTION
+#define IGL_FIRST_HIT_EXCEPTION 10
+#endif
+
 // The easiest way to keep track of everything is to use a class
 
 namespace igl
@@ -49,17 +53,7 @@ namespace igl
       typedef 
         CGAL::Box_intersection_d::Box_with_handle_d<double,3,TrianglesIterator> 
         Box;
-      // Axis-aligned bounding box tree
-      typedef CGAL::AABB_triangle_primitive<Kernel,TrianglesIterator> Primitive;
-      typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
-      typedef CGAL::AABB_tree<Traits> Tree;
-      typedef typename Tree::Object_and_primitive_id Object_and_primitive_id;
-      typedef typename Tree::Primitive_id Primitive_id;
-      // 3D Delaunay Triangulation
-      typedef CGAL::Delaunay_triangulation_3<Kernel> Delaunay_triangulation_3;
-      typedef typename Delaunay_triangulation_3::Finite_cells_iterator 
-        Delaunay3CellIterator;
-  
+
       // Input mesh
       const Eigen::MatrixXd & V;
       const Eigen::MatrixXi & F;
@@ -157,7 +151,7 @@ namespace igl
           const Triangle_3 & B,
           const int fa,
           const int fb);
-  
+
     public:
       // Callback function called during box self intersections test. Means
       // boxes a and b intersect. This method then checks if the triangles in
@@ -242,8 +236,6 @@ inline void igl::SelfIntersectMesh<Kernel>::box_intersect(
   SIM->box_intersect(a,b);
 }
 
-#define FIRST_HIT_EXCEPTION 10
-
 template <typename Kernel>
 inline igl::SelfIntersectMesh<Kernel>::SelfIntersectMesh(
   const Eigen::MatrixXd & V,
@@ -287,8 +279,8 @@ inline igl::SelfIntersectMesh<Kernel>::SelfIntersectMesh(
     CGAL::box_self_intersection_d(boxes.begin(), boxes.end(),cb);
   }catch(int e)
   {
-    // Rethrow if not FIRST_HIT_EXCEPTION
-    if(e != FIRST_HIT_EXCEPTION)
+    // Rethrow if not IGL_FIRST_HIT_EXCEPTION
+    if(e != IGL_FIRST_HIT_EXCEPTION)
     {
       throw e;
     }
@@ -548,7 +540,7 @@ inline void igl::SelfIntersectMesh<Kernel>::count_intersection(
   // We found the first intersection
   if(params.first_only && this->count >= 1)
   {
-    throw FIRST_HIT_EXCEPTION;
+    throw IGL_FIRST_HIT_EXCEPTION;
   }
 }
 

+ 2 - 2
include/igl/cgal/intersect_other.cpp

@@ -1,4 +1,4 @@
-#include "intersect.h"
+#include "intersect_other.h"
 #include "CGAL_includes.hpp"
 #include "mesh_to_cgal_triangle_list.h"
 
@@ -6,7 +6,7 @@
 #define IGL_FIRST_HIT_EXCEPTION 10
 #endif
 
-IGL_INLINE void igl::intersect(
+IGL_INLINE void igl::intersect_other(
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
   const Eigen::MatrixXd & U,

+ 20 - 4
include/igl/cgal/intersect_other.h

@@ -1,5 +1,5 @@
-#ifndef IGL_INTERSECT_H
-#define IGL_INTERSECT_H
+#ifndef IGL_INTERSECT_OTHER_H
+#define IGL_INTERSECT_OTHER_H
 #include <igl/igl_inline.h>
 
 #include <Eigen/Dense>
@@ -13,7 +13,23 @@
 
 namespace igl
 {
-  IGL_INLINE void intersect(
+  // INTERSECT Given a triangle mesh (V,F) and another mesh (U,G) find all pairs
+  // of intersecting faces. Note that self-intersections are ignored.
+  // 
+  // [VV,FF,IF] = selfintersect(V,F,'ParameterName',ParameterValue, ...)
+  //
+  // Inputs:
+  //   V  #V by 3 list of vertex positions
+  //   F  #F by 3 list of triangle indices into V
+  //   U  #U by 3 list of vertex positions
+  //   G  #G by 3 list of triangle indices into U
+  //   first_only  whether to only detect the first intersection.
+  // Outputs:
+  //   IF  #intersecting face pairs by 2 list of intersecting face pairs,
+  //     indexing F and G
+  //
+  // See also: selfintersect
+  IGL_INLINE void intersect_other(
     const Eigen::MatrixXd & V,
     const Eigen::MatrixXi & F,
     const Eigen::MatrixXd & U,
@@ -23,7 +39,7 @@ namespace igl
 }
 
 #ifdef IGL_HEADER_ONLY
-#  include "intersect.cpp"
+#  include "intersect_other.cpp"
 #endif
   
 #endif

+ 2 - 2
include/igl/cgal/selfintersect.cpp

@@ -14,8 +14,8 @@ IGL_INLINE void igl::selfintersect(
   using namespace std;
   if(params.detect_only)
   {
-    // This is probably a terrible idea, but CGAL is throwing floating point
-    // exceptions.
+    //// This is probably a terrible idea, but CGAL is throwing floating point
+    //// exceptions.
 
 //#ifdef __APPLE__
 //#define IGL_THROW_FPE 11

+ 0 - 3
include/igl/cgal/selfintersect.h

@@ -4,10 +4,7 @@
 
 #include <Eigen/Dense>
 
-// IGL LIB includes
-// Use header only so that asserts get guarded.
 #ifdef MEX
-//#  define IGL_HEADER_ONLY
 #  include <mex.h>
 #  include <cassert>
 #  undef assert