瀏覽代碼

handle RowMajor V

Former-commit-id: b00cd0fa67d41a635e7c64871372fd1004c59945
Alec Jacobson 10 年之前
父節點
當前提交
67cd5fd5ca
共有 1 個文件被更改,包括 24 次插入3 次删除
  1. 24 3
      include/igl/outer_hull.cpp

+ 24 - 3
include/igl/outer_hull.cpp

@@ -174,6 +174,9 @@ IGL_INLINE void igl::outer_hull(
   cout<<"outer facet..."<<endl;
 #endif
     outer_facet(V,F,N,IM,f,f_flip);
+#ifdef IGL_OUTER_HULL_DEBUG
+  cout<<"outer facet: "<<f<<endl;
+#endif
     int FHcount = 0;
     // Q contains list of face edges to continue traversing upong
     queue<int> Q;
@@ -387,8 +390,23 @@ IGL_INLINE void igl::outer_hull(
     MatrixXV q = BC.row(AJ(0));
     // In a perfect world, it's enough to test a single point.
     double w;
+
+    // winding_number_3 expects colmajor
+    const typename DerivedV::Scalar * Vdata;
+    Vdata = V.data();
+    Matrix<
+      typename DerivedV::Scalar,
+      DerivedV::RowsAtCompileTime,
+      DerivedV::ColsAtCompileTime,
+      ColMajor> Vcol;
+    if(DerivedV::IsRowMajor)
+    {
+      // copy to convert to colmajor
+      Vcol = V;
+      Vdata = Vcol.data();
+    }
     winding_number_3(
-      V.data(),V.rows(),
+      Vdata,V.rows(),
       B.data(),B.rows(),
       q.data(),1,&w);
     return fabs(w)>0.5;
@@ -406,8 +424,11 @@ IGL_INLINE void igl::outer_hull(
       {
         continue;
       }
-      keep[id] = keep[id] && 
-        !is_component_inside_other(V,BC,vG[id],vJ[id],vG[oid]);
+      const bool inside = is_component_inside_other(V,BC,vG[id],vJ[id],vG[oid]);
+#ifdef IGL_OUTER_HULL_DEBUG
+      cout<<id<<" is inside "<<oid<<" ? "<<inside<<endl;
+#endif
+      keep[id] = keep[id] && !inside;
     }
     if(keep[id])
     {