瀏覽代碼

fixed marching tets

Teseo Schneider 6 年之前
父節點
當前提交
3840f803f3
共有 2 個文件被更改,包括 22 次插入22 次删除
  1. 7 7
      include/igl/marching_tets.cpp
  2. 15 15
      include/igl/marching_tets.h

+ 7 - 7
include/igl/marching_tets.cpp

@@ -22,9 +22,9 @@ template <typename DerivedTV,
           typename DerivedJ,
           typename BCType>
 void igl::marching_tets(
-    const Eigen::PlainObjectBase<DerivedTV>& TV,
-    const Eigen::PlainObjectBase<DerivedTT>& TT,
-    const Eigen::PlainObjectBase<DerivedS>& isovals,
+    const Eigen::MatrixBase<DerivedTV>& TV,
+    const Eigen::MatrixBase<DerivedTT>& TT,
+    const Eigen::MatrixBase<DerivedS>& isovals,
     double isovalue,
     Eigen::PlainObjectBase<DerivedSV>& outV,
     Eigen::PlainObjectBase<DerivedSF>& outF,
@@ -94,7 +94,7 @@ void igl::marching_tets(
     for (int v = 0; v < 4; v++)
     {
       const int vid = TT(i, v);
-      const uint8_t flag = isovals[vid] > isovalue;
+      const uint8_t flag = isovals(vid, 0) > isovalue;
       key |= flag << v;
     }
 
@@ -160,8 +160,8 @@ void igl::marching_tets(
         typedef Eigen::Matrix<typename DerivedTV::Scalar, 1, 3, Eigen::RowMajor, 1, 3> RowVector;
         const RowVector v1 = TV.row(edge.first);
         const RowVector v2 = TV.row(edge.second);
-        const double a = fabs(isovals[edge.first] - isovalue);
-        const double b = fabs(isovals[edge.second] - isovalue);
+        const double a = fabs(isovals(edge.first, 0) - isovalue);
+        const double b = fabs(isovals(edge.second, 0) - isovalue);
         const double w = a / (a+b);
 
         // Create a casted copy in case BCType is a float and we need to downcast
@@ -190,5 +190,5 @@ void igl::marching_tets(
 
 
 #ifdef IGL_STATIC_LIBRARY
-template void igl::marching_tets<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, double>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::SparseMatrix<double, 0, int>&);
+template void igl::marching_tets<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::SparseMatrix<double, 0, int>&);
 #endif // IGL_STATIC_LIBRARY

+ 15 - 15
include/igl/marching_tets.h

@@ -40,9 +40,9 @@ namespace igl {
             typename DerivedJ,
             typename BCType>
   IGL_INLINE void marching_tets(
-      const Eigen::PlainObjectBase<DerivedTV>& TV,
-      const Eigen::PlainObjectBase<DerivedTT>& TT,
-      const Eigen::PlainObjectBase<DerivedS>& S,
+      const Eigen::MatrixBase<DerivedTV>& TV,
+      const Eigen::MatrixBase<DerivedTT>& TT,
+      const Eigen::MatrixBase<DerivedS>& S,
       double isovalue,
       Eigen::PlainObjectBase<DerivedSV>& SV,
       Eigen::PlainObjectBase<DerivedSF>& SF,
@@ -74,9 +74,9 @@ namespace igl {
             typename DerivedJ,
             typename BCType>
   IGL_INLINE void marching_tets(
-      const Eigen::PlainObjectBase<DerivedTV>& TV,
-      const Eigen::PlainObjectBase<DerivedTT>& TT,
-      const Eigen::PlainObjectBase<DerivedS>& S,
+      const Eigen::MatrixBase<DerivedTV>& TV,
+      const Eigen::MatrixBase<DerivedTT>& TT,
+      const Eigen::MatrixBase<DerivedS>& S,
       Eigen::PlainObjectBase<DerivedSV>& SV,
       Eigen::PlainObjectBase<DerivedSF>& SF,
       Eigen::PlainObjectBase<DerivedJ>& J,
@@ -108,9 +108,9 @@ namespace igl {
             typename DerivedSF,
             typename DerivedJ>
   IGL_INLINE void marching_tets(
-      const Eigen::PlainObjectBase<DerivedTV>& TV,
-      const Eigen::PlainObjectBase<DerivedTT>& TT,
-      const Eigen::PlainObjectBase<DerivedS>& S,
+      const Eigen::MatrixBase<DerivedTV>& TV,
+      const Eigen::MatrixBase<DerivedTT>& TT,
+      const Eigen::MatrixBase<DerivedS>& S,
       double isovalue,
       Eigen::PlainObjectBase<DerivedSV>& SV,
       Eigen::PlainObjectBase<DerivedSF>& SF,
@@ -143,9 +143,9 @@ namespace igl {
             typename DerivedSF,
             typename BCType>
   IGL_INLINE void marching_tets(
-      const Eigen::PlainObjectBase<DerivedTV>& TV,
-      const Eigen::PlainObjectBase<DerivedTT>& TT,
-      const Eigen::PlainObjectBase<DerivedS>& S,
+      const Eigen::MatrixBase<DerivedTV>& TV,
+      const Eigen::MatrixBase<DerivedTT>& TT,
+      const Eigen::MatrixBase<DerivedS>& S,
       double isovalue,
       Eigen::PlainObjectBase<DerivedSV>& SV,
       Eigen::PlainObjectBase<DerivedSF>& SF,
@@ -176,9 +176,9 @@ namespace igl {
             typename DerivedSV,
             typename DerivedSF>
   IGL_INLINE void marching_tets(
-      const Eigen::PlainObjectBase<DerivedTV>& TV,
-      const Eigen::PlainObjectBase<DerivedTT>& TT,
-      const Eigen::PlainObjectBase<DerivedS>& S,
+      const Eigen::MatrixBase<DerivedTV>& TV,
+      const Eigen::MatrixBase<DerivedTT>& TT,
+      const Eigen::MatrixBase<DerivedS>& S,
       double isovalue,
       Eigen::PlainObjectBase<DerivedSV>& SV,
       Eigen::PlainObjectBase<DerivedSF>& SF) {