Bladeren bron

fix example, openmp in selfintersect

Former-commit-id: aea2b4f82e60b2514af53d1474796fecf891edb7
Alec Jacobson 10 jaren geleden
bovenliggende
commit
18ecd80948

+ 1 - 1
build/Makefile_cgal

@@ -26,7 +26,7 @@ INC+=$(EIGEN3_INC)
 # CGAL dependency
 # CGAL dependency
 CGAL=$(DEFAULT_PREFIX)
 CGAL=$(DEFAULT_PREFIX)
 CGAL_INC=-I$(CGAL)/include
 CGAL_INC=-I$(CGAL)/include
-CGAL_FLAGS=-frounding-math -fsignaling-nans 
+CGAL_FLAGS=-frounding-math -fsignaling-nans ${OPENMP}
 CFLAGS+=$(CGAL_FLAGS)
 CFLAGS+=$(CGAL_FLAGS)
 INC+=$(CGAL_INC)
 INC+=$(CGAL_INC)
 
 

+ 1 - 0
examples/multi-viewport/example.cpp

@@ -49,6 +49,7 @@ int width,height;
 igl::Camera down_camera;
 igl::Camera down_camera;
 bool trackball_on = false;
 bool trackball_on = false;
 int down_mouse_x,down_mouse_y,move_x,move_y;
 int down_mouse_x,down_mouse_y,move_x,move_y;
+int down_vp;
 // Position of light
 // Position of light
 float light_pos[4] = {0.1,0.1,-0.9,0};
 float light_pos[4] = {0.1,0.1,-0.9,0};
 // Vertex positions, normals, colors and centroid
 // Vertex positions, normals, colors and centroid

+ 12 - 4
include/igl/cgal/SelfIntersectMesh.h

@@ -405,7 +405,9 @@ inline igl::SelfIntersectMesh<
   // Use map for *all* faces
   // Use map for *all* faces
   map<typename CDT_plus_2::Vertex_handle,Index> v2i;
   map<typename CDT_plus_2::Vertex_handle,Index> v2i;
   // Loop over offending triangles
   // Loop over offending triangles
-  for(Index o = 0;o<(Index)offending.size();o++)
+  const size_t noff = offending.size();
+# pragma omp parallel for if (noff>1000)
+  for(Index o = 0;o<(Index)noff;o++)
   {
   {
     // index in F
     // index in F
     const Index f = offending[o];
     const Index f = offending[o];
@@ -439,6 +441,7 @@ inline igl::SelfIntersectMesh<
           assert(T[f].vertex(i) == P[o].to_3d(vit->point()));
           assert(T[f].vertex(i) == P[o].to_3d(vit->point()));
 #endif
 #endif
           // For first three, use original index in F
           // For first three, use original index in F
+#   pragma omp critical
           v2i[vit] = F(f,i);
           v2i[vit] = F(f,i);
         }else
         }else
         {
         {
@@ -480,6 +483,7 @@ inline igl::SelfIntersectMesh<
                 if(vit_point_3 == P[no].to_3d(uit->point()))
                 if(vit_point_3 == P[no].to_3d(uit->point()))
                 {
                 {
                   assert(v2i.count(uit) == 1);
                   assert(v2i.count(uit) == 1);
+#   pragma omp critical
                   v2i[vit] = v2i[uit];
                   v2i[vit] = v2i[uit];
                   found = true;
                   found = true;
                 }
                 }
@@ -488,9 +492,12 @@ inline igl::SelfIntersectMesh<
           }
           }
           if(!found)
           if(!found)
           {
           {
-            v2i[vit] = V.rows()+NV_count;
-            NV.push_back(vit_point_3);
-            NV_count++;
+#   pragma omp critical
+            {
+              v2i[vit] = V.rows()+NV_count;
+              NV.push_back(vit_point_3);
+              NV_count++;
+            }
           }
           }
         }
         }
         i++;
         i++;
@@ -500,6 +507,7 @@ inline igl::SelfIntersectMesh<
       Index i = 0;
       Index i = 0;
       // Resize to fit new number of triangles
       // Resize to fit new number of triangles
       NF[o].resize(cdt[o].number_of_faces(),3);
       NF[o].resize(cdt[o].number_of_faces(),3);
+#   pragma omp atomic
       NF_count+=NF[o].rows();
       NF_count+=NF[o].rows();
       // Append new faces to NF
       // Append new faces to NF
       for(
       for(

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

@@ -32,8 +32,6 @@ IGL_INLINE void igl::intersect_other(
   typedef CGAL::Triangle_3<Kernel> Triangle_3; 
   typedef CGAL::Triangle_3<Kernel> Triangle_3; 
   typedef CGAL::Plane_3<Kernel>    Plane_3;
   typedef CGAL::Plane_3<Kernel>    Plane_3;
   typedef CGAL::Tetrahedron_3<Kernel> Tetrahedron_3; 
   typedef CGAL::Tetrahedron_3<Kernel> Tetrahedron_3; 
-  typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3; 
-  typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron_3; 
   // 2D Primitives
   // 2D Primitives
   typedef CGAL::Point_2<Kernel>    Point_2;
   typedef CGAL::Point_2<Kernel>    Point_2;
   typedef CGAL::Segment_2<Kernel>  Segment_2; 
   typedef CGAL::Segment_2<Kernel>  Segment_2;