瀏覽代碼

Merge remote-tracking branch 'upstream/master'

Former-commit-id: c7dd95940392c87e185aac88a3bf0da9793d455a
Qingnan Zhou 10 年之前
父節點
當前提交
117efb776a
共有 2 個文件被更改,包括 21 次插入12 次删除
  1. 15 10
      include/igl/boolean/mesh_boolean.cpp
  2. 6 2
      include/igl/cgal/mesh_to_cgal_triangle_list.cpp

+ 15 - 10
include/igl/boolean/mesh_boolean.cpp

@@ -177,12 +177,14 @@ IGL_INLINE void igl::boolean::mesh_boolean(
   {
     libigl_resolve(V,F,EV,CF,CJ);
     CV.resize(EV.rows(), EV.cols());
-    std::transform(EV.data(), EV.data() + EV.rows()*EV.cols(),
-            CV.data(), [&](ExactScalar val) {
-            Scalar c;
-            assign_scalar(val,c);
-            return c;
-            });
+    // Just use f'ing for loops. What if EV and CV don't use the same ordering?
+    for(int i=0;i<EV.rows();i++)
+    {
+      for(int j=0;j<EV.cols();j++)
+      {
+        assign_scalar(EV(i,j),CV(i,j));
+      }
+    }
   }
 
   if(type == MESH_BOOLEAN_TYPE_RESOLVE)
@@ -201,8 +203,11 @@ IGL_INLINE void igl::boolean::mesh_boolean(
   VectorXi I;
   Matrix<bool,Dynamic,1> flip;
   peel_outer_hull_layers(EV,CF,I,flip);
-  // 0 is "first" iteration, so it's odd
-  Array<bool,Dynamic,1> odd = igl::mod(I,2).array()==0;
+  //Array<bool,Dynamic,1> even = igl::mod(I,2).array()==0;
+  const auto even = [&](const Index & f)->bool
+  {
+    return (I(f)%2)==0;
+  };
 
 #ifdef IGL_MESH_BOOLEAN_DEBUG
   cout<<"categorize..."<<endl;
@@ -219,7 +224,7 @@ IGL_INLINE void igl::boolean::mesh_boolean(
     {
       case MESH_BOOLEAN_TYPE_XOR:
       case MESH_BOOLEAN_TYPE_UNION:
-        if((odd(f)&&!flip(f))||(!odd(f)&&flip(f)))
+        if((even(f)&&!flip(f))||(!even(f)&&flip(f)))
         {
           vG.push_back(f);
           Gflip.push_back(false);
@@ -230,7 +235,7 @@ IGL_INLINE void igl::boolean::mesh_boolean(
         }
         break;
       case MESH_BOOLEAN_TYPE_INTERSECT:
-        if((!odd(f) && !flip(f)) || (odd(f) && flip(f)))
+        if((!even(f) && !flip(f)) || (even(f) && flip(f)))
         {
           vG.push_back(f);
           Gflip.push_back(type == MESH_BOOLEAN_TYPE_MINUS);

+ 6 - 2
include/igl/cgal/mesh_to_cgal_triangle_list.cpp

@@ -30,9 +30,13 @@ IGL_INLINE void igl::cgal::mesh_to_cgal_triangle_list(
     DerivedV::RowsAtCompileTime,
     DerivedV::ColsAtCompileTime> 
     KV(V.rows(),V.cols());
-  for(int i = 0;i<V.size();i++)
+  // Just use f'ing for loops. What if V and KV don't use same ordering?
+  for(int i = 0;i<V.rows();i++)
   {
-    assign_scalar(*(V.data()+i),*(KV.data()+i));
+    for(int j = 0;j<V.cols();j++)
+    {
+      assign_scalar(V(i,j),KV(i,j));
+    }
   }
   // Must be triangles
   assert(F.cols() == 3);