Browse Source

remove openmp from cgal selfintersect, drawmesh with C #C by 4

Former-commit-id: 72333aee03803b5d7debd1a095d0bb1ed2772e43
Alec Jacobson 10 years ago
parent
commit
a03cf9dfef
2 changed files with 8 additions and 6 deletions
  1. 7 5
      include/igl/cgal/SelfIntersectMesh.h
  2. 1 1
      include/igl/draw_mesh.cpp

+ 7 - 5
include/igl/cgal/SelfIntersectMesh.h

@@ -406,7 +406,9 @@ inline igl::SelfIntersectMesh<
   map<typename CDT_plus_2::Vertex_handle,Index> v2i;
   // Loop over offending triangles
   const size_t noff = offending.size();
-# pragma omp parallel for if (noff>1000)
+  // Unfortunately it looks like CGAL has trouble allocating memory when
+  // multiple openmp threads are running. Crashes durring CDT...
+//# pragma omp parallel for if (noff>1000)
   for(Index o = 0;o<(Index)noff;o++)
   {
     // index in F
@@ -441,7 +443,7 @@ inline igl::SelfIntersectMesh<
           assert(T[f].vertex(i) == P[o].to_3d(vit->point()));
 #endif
           // For first three, use original index in F
-#   pragma omp critical
+//#   pragma omp critical
           v2i[vit] = F(f,i);
         }else
         {
@@ -483,7 +485,7 @@ inline igl::SelfIntersectMesh<
                 if(vit_point_3 == P[no].to_3d(uit->point()))
                 {
                   assert(v2i.count(uit) == 1);
-#   pragma omp critical
+//#   pragma omp critical
                   v2i[vit] = v2i[uit];
                   found = true;
                 }
@@ -492,7 +494,7 @@ inline igl::SelfIntersectMesh<
           }
           if(!found)
           {
-#   pragma omp critical
+//#   pragma omp critical
             {
               v2i[vit] = V.rows()+NV_count;
               NV.push_back(vit_point_3);
@@ -507,7 +509,7 @@ inline igl::SelfIntersectMesh<
       Index i = 0;
       // Resize to fit new number of triangles
       NF[o].resize(cdt[o].number_of_faces(),3);
-#   pragma omp atomic
+//#   pragma omp atomic
       NF_count+=NF[o].rows();
       // Append new faces to NF
       for(

+ 1 - 1
include/igl/draw_mesh.cpp

@@ -91,7 +91,7 @@ IGL_INLINE void igl::draw_mesh(
     assert(F.maxCoeff() < V.rows());
     assert(V.cols() == 3);
     assert(rC == rV || rC == rF || rC == rF*3 || rC==1 || C.size() == 0);
-    assert(C.cols() == 3 || C.size() == 0);
+    assert(C.cols() >= 3 || C.size() == 0);
     assert(N.cols() == 3 || N.size() == 0);
     assert(TC.cols() == 2 || TC.size() == 0);
     assert(cF == 3 || cF == 4);