Procházet zdrojové kódy

tutorial and unit tests compile and run with Eigen 3.3.1; Eigen's LinSpaced had yet another bug

Former-commit-id: ac0847f5ce6790ba6f55f4f720839579b6291352
Alec Jacobson před 8 roky
rodič
revize
2955adeb5e

+ 7 - 3
include/igl/LinSpaced.h

@@ -29,7 +29,8 @@
 namespace igl
 namespace igl
 {
 {
   template <typename Derived>
   template <typename Derived>
-  inline typename Eigen::DenseBase< Derived >::RandomAccessLinSpacedReturnType LinSpaced(
+  //inline typename Eigen::DenseBase< Derived >::RandomAccessLinSpacedReturnType 
+  inline Derived LinSpaced(
     typename Derived::Index size,
     typename Derived::Index size,
     const typename Derived::Scalar & low,
     const typename Derived::Scalar & low,
     const typename Derived::Scalar & high);
     const typename Derived::Scalar & high);
@@ -38,7 +39,8 @@ namespace igl
 // Implementation
 // Implementation
 
 
 template <typename Derived>
 template <typename Derived>
-inline typename Eigen::DenseBase< Derived >::RandomAccessLinSpacedReturnType 
+//inline typename Eigen::DenseBase< Derived >::RandomAccessLinSpacedReturnType 
+inline Derived
 igl::LinSpaced(
 igl::LinSpaced(
   typename Derived::Index size,
   typename Derived::Index size,
   const typename Derived::Scalar & low,
   const typename Derived::Scalar & low,
@@ -48,8 +50,10 @@ igl::LinSpaced(
   {
   {
     // Force empty vector with correct "RandomAccessLinSpacedReturnType" type.
     // Force empty vector with correct "RandomAccessLinSpacedReturnType" type.
     return Derived::LinSpaced(0,0,1);
     return Derived::LinSpaced(0,0,1);
-  }else
+  }else if(high < low)
   {
   {
+    return low-Derived::LinSpaced(size,low-low,low-high).array();
+  }else{
     return Derived::LinSpaced(size,low,high);
     return Derived::LinSpaced(size,low,high);
   }
   }
 }
 }

+ 2 - 2
include/igl/copyleft/cgal/CSGTree.h

@@ -150,9 +150,9 @@ namespace igl
           // Returns mesh vertices in the desired output type, casting when
           // Returns mesh vertices in the desired output type, casting when
           // appropriate to floating precision.
           // appropriate to floating precision.
           template <typename DerivedV>
           template <typename DerivedV>
-          Eigen::PlainObjectBase<DerivedV> cast_V() const
+          DerivedV cast_V() const
           {
           {
-            Eigen::PlainObjectBase<DerivedV> dV;
+            DerivedV dV;
             dV.resize(m_V.rows(),m_V.cols());
             dV.resize(m_V.rows(),m_V.cols());
             for(int i = 0;i<m_V.rows();i++)
             for(int i = 0;i<m_V.rows();i++)
             {
             {

+ 3 - 1
include/igl/copyleft/cgal/remesh_intersections.cpp

@@ -448,7 +448,9 @@ IGL_INLINE void igl::copyleft::cgal::remesh_intersections(
       std::transform(FF.data(), FF.data() + FF.rows()*FF.cols(),
       std::transform(FF.data(), FF.data() + FF.rows()*FF.cols(),
           FF.data(), [&vv_to_unique](const typename DerivedFF::Scalar& a)
           FF.data(), [&vv_to_unique](const typename DerivedFF::Scalar& a)
           { return vv_to_unique[a]; });
           { return vv_to_unique[a]; });
-      IM = igl::LinSpaced<
+      IM.resize(unique_vv.rows());
+      // Have to use << instead of = becasue Eigen's PlainObjectBase is annoying
+      IM << igl::LinSpaced<
         Eigen::Matrix<typename DerivedIM::Scalar, Eigen::Dynamic,1 >
         Eigen::Matrix<typename DerivedIM::Scalar, Eigen::Dynamic,1 >
         >(unique_vv.rows(), 0, unique_vv.rows()-1);
         >(unique_vv.rows(), 0, unique_vv.rows()-1);
     }else 
     }else 

+ 2 - 1
include/igl/setdiff.cpp

@@ -42,7 +42,8 @@ IGL_INLINE void igl::setdiff(
       }
       }
     }
     }
     assert(k == C.size());
     assert(k == C.size());
-    IA = igl::LinSpaced<Eigen::Matrix<typename DerivedIA::Scalar,Eigen::Dynamic,1> >(
+    // Have to use << instead of = becasue Eigen's PlainObjectBase is annoying
+    IA << igl::LinSpaced<Eigen::Matrix<typename DerivedIA::Scalar,Eigen::Dynamic,1> >(
       C.size(),0,C.size()-1);
       C.size(),0,C.size()-1);
   }
   }
 
 

+ 2 - 0
include/igl/slice.cpp

@@ -248,6 +248,8 @@ IGL_INLINE DerivedX igl::slice(
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
 // Explicit template instantiation
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
+template void igl::slice<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
+// generated by autoexplicit.sh
 template void igl::slice<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 1, -1, -1> >(Eigen::Matrix<double, -1, -1, 1, -1, -1> const&, Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, int, Eigen::Matrix<double, -1, -1, 1, -1, -1>&);
 template void igl::slice<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 1, -1, -1> >(Eigen::Matrix<double, -1, -1, 1, -1, -1> const&, Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, int, Eigen::Matrix<double, -1, -1, 1, -1, -1>&);
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
 template void igl::slice<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 1, -1, -1> >(Eigen::DenseBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> >&);
 template void igl::slice<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 1, -1, -1> >(Eigen::DenseBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> >&);

+ 2 - 1
include/igl/sort_angles.cpp

@@ -18,7 +18,8 @@ IGL_INLINE void igl::sort_angles(
     assert(num_cols >= 2);
     assert(num_cols >= 2);
 
 
     R.resize(num_rows);
     R.resize(num_rows);
-    R = igl::LinSpaced<
+    // Have to use << instead of = becasue Eigen's PlainObjectBase is annoying
+    R << igl::LinSpaced<
       Eigen::Matrix<typename DerivedR::Scalar, Eigen::Dynamic, 1> >
       Eigen::Matrix<typename DerivedR::Scalar, Eigen::Dynamic, 1> >
       (num_rows, 0, num_rows-1);
       (num_rows, 0, num_rows-1);