Browse Source

fix ordering bug using assign_scalar on matrix

Former-commit-id: e07e56dad899e9de43f0aa03714ce06b34c0cdd0
Alec Jacobson 9 years ago
parent
commit
cdad9924db

+ 8 - 6
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)

+ 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);