Browse Source

template Ele, ensuing templates

Former-commit-id: 5d11e3badc1565e5f15f7f923f5cda57dbd32bfd
Alec Jacobson 8 years ago
parent
commit
fa9913fffa

+ 68 - 47
include/igl/AABB.cpp

@@ -25,13 +25,13 @@
 #include <stack>
 #include <stack>
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
-  template <typename Derivedbb_mins, typename Derivedbb_maxs>
+template <typename DerivedEle, typename Derivedbb_mins, typename Derivedbb_maxs, typename Derivedelements>
 IGL_INLINE void igl::AABB<DerivedV,DIM>::init(
 IGL_INLINE void igl::AABB<DerivedV,DIM>::init(
     const Eigen::MatrixBase<DerivedV> & V,
     const Eigen::MatrixBase<DerivedV> & V,
-    const Eigen::MatrixXi & Ele, 
+    const Eigen::MatrixBase<DerivedEle> & Ele, 
     const Eigen::MatrixBase<Derivedbb_mins> & bb_mins,
     const Eigen::MatrixBase<Derivedbb_mins> & bb_mins,
     const Eigen::MatrixBase<Derivedbb_maxs> & bb_maxs,
     const Eigen::MatrixBase<Derivedbb_maxs> & bb_maxs,
-    const Eigen::VectorXi & elements,
+    const Eigen::MatrixBase<Derivedelements> & elements,
     const int i)
     const int i)
 {
 {
   using namespace std;
   using namespace std;
@@ -89,10 +89,11 @@ IGL_INLINE void igl::AABB<DerivedV,DIM>::init(
   }
   }
 }
 }
 
 
-  template <typename DerivedV, int DIM>
+template <typename DerivedV, int DIM>
+template <typename DerivedEle>
 void igl::AABB<DerivedV,DIM>::init(
 void igl::AABB<DerivedV,DIM>::init(
     const Eigen::MatrixBase<DerivedV> & V,
     const Eigen::MatrixBase<DerivedV> & V,
-    const Eigen::MatrixXi & Ele)
+    const Eigen::MatrixBase<DerivedEle> & Ele)
 {
 {
   using namespace Eigen;
   using namespace Eigen;
   // deinit will be immediately called...
   // deinit will be immediately called...
@@ -100,11 +101,15 @@ void igl::AABB<DerivedV,DIM>::init(
 }
 }
 
 
   template <typename DerivedV, int DIM>
   template <typename DerivedV, int DIM>
+template <
+  typename DerivedEle,
+  typename DerivedSI,
+  typename DerivedI>
 IGL_INLINE void igl::AABB<DerivedV,DIM>::init(
 IGL_INLINE void igl::AABB<DerivedV,DIM>::init(
     const Eigen::MatrixBase<DerivedV> & V,
     const Eigen::MatrixBase<DerivedV> & V,
-    const Eigen::MatrixXi & Ele, 
-    const Eigen::MatrixXi & SI,
-    const Eigen::VectorXi & I)
+    const Eigen::MatrixBase<DerivedEle> & Ele, 
+    const Eigen::MatrixBase<DerivedSI> & SI,
+    const Eigen::MatrixBase<DerivedI> & I)
 {
 {
   using namespace Eigen;
   using namespace Eigen;
   using namespace std;
   using namespace std;
@@ -197,10 +202,10 @@ IGL_INLINE bool igl::AABB<DerivedV,DIM>::is_leaf() const
 }
 }
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
-template <typename Derivedq>
+template <typename DerivedEle, typename Derivedq>
 IGL_INLINE std::vector<int> igl::AABB<DerivedV,DIM>::find(
 IGL_INLINE std::vector<int> igl::AABB<DerivedV,DIM>::find(
     const Eigen::MatrixBase<DerivedV> & V,
     const Eigen::MatrixBase<DerivedV> & V,
-    const Eigen::MatrixXi & Ele, 
+    const Eigen::MatrixBase<DerivedEle> & Ele, 
     const Eigen::MatrixBase<Derivedq> & q,
     const Eigen::MatrixBase<Derivedq> & q,
     const bool first) const
     const bool first) const
 {
 {
@@ -307,11 +312,11 @@ IGL_INLINE int igl::AABB<DerivedV,DIM>::subtree_size() const
 
 
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
-template <typename Derivedbb_mins, typename Derivedbb_maxs>
+template <typename Derivedbb_mins, typename Derivedbb_maxs, typename Derivedelements>
 IGL_INLINE void igl::AABB<DerivedV,DIM>::serialize(
 IGL_INLINE void igl::AABB<DerivedV,DIM>::serialize(
     Eigen::PlainObjectBase<Derivedbb_mins> & bb_mins,
     Eigen::PlainObjectBase<Derivedbb_mins> & bb_mins,
     Eigen::PlainObjectBase<Derivedbb_maxs> & bb_maxs,
     Eigen::PlainObjectBase<Derivedbb_maxs> & bb_maxs,
-    Eigen::VectorXi & elements,
+    Eigen::PlainObjectBase<Derivedelements> & elements,
     const int i) const
     const int i) const
 {
 {
   using namespace std;
   using namespace std;
@@ -340,27 +345,29 @@ IGL_INLINE void igl::AABB<DerivedV,DIM>::serialize(
 }
 }
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
+template <typename DerivedEle>
 IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar 
 IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar 
 igl::AABB<DerivedV,DIM>::squared_distance(
 igl::AABB<DerivedV,DIM>::squared_distance(
   const Eigen::MatrixBase<DerivedV> & V,
   const Eigen::MatrixBase<DerivedV> & V,
-  const Eigen::MatrixXi & Ele, 
+  const Eigen::MatrixBase<DerivedEle> & Ele, 
   const RowVectorDIMS & p,
   const RowVectorDIMS & p,
   int & i,
   int & i,
-  RowVectorDIMS & c) const
+  Eigen::PlainObjectBase<RowVectorDIMS> & c) const
 {
 {
   return squared_distance(V,Ele,p,std::numeric_limits<Scalar>::infinity(),i,c);
   return squared_distance(V,Ele,p,std::numeric_limits<Scalar>::infinity(),i,c);
 }
 }
 
 
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
+template <typename DerivedEle>
 IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar 
 IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar 
 igl::AABB<DerivedV,DIM>::squared_distance(
 igl::AABB<DerivedV,DIM>::squared_distance(
   const Eigen::MatrixBase<DerivedV> & V,
   const Eigen::MatrixBase<DerivedV> & V,
-  const Eigen::MatrixXi & Ele, 
+  const Eigen::MatrixBase<DerivedEle> & Ele, 
   const RowVectorDIMS & p,
   const RowVectorDIMS & p,
   Scalar min_sqr_d,
   Scalar min_sqr_d,
   int & i,
   int & i,
-  RowVectorDIMS & c) const
+  Eigen::PlainObjectBase<RowVectorDIMS> & c) const
 {
 {
   using namespace Eigen;
   using namespace Eigen;
   using namespace std;
   using namespace std;
@@ -388,7 +395,7 @@ igl::AABB<DerivedV,DIM>::squared_distance(
     const auto & look_right = [&]()
     const auto & look_right = [&]()
     {
     {
       int i_right;
       int i_right;
-      RowVectorDIMS c_right = c;
+      Eigen::PlainObjectBase<RowVectorDIMS> c_right = c;
       Scalar sqr_d_right = 
       Scalar sqr_d_right = 
         m_right->squared_distance(V,Ele,p,sqr_d,i_right,c_right);
         m_right->squared_distance(V,Ele,p,sqr_d,i_right,c_right);
       this->set_min(p,sqr_d_right,i_right,c_right,sqr_d,i,c);
       this->set_min(p,sqr_d_right,i_right,c_right,sqr_d,i,c);
@@ -436,13 +443,14 @@ igl::AABB<DerivedV,DIM>::squared_distance(
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
 template <
 template <
+  typename DerivedEle,
   typename DerivedP, 
   typename DerivedP, 
   typename DerivedsqrD, 
   typename DerivedsqrD, 
   typename DerivedI, 
   typename DerivedI, 
   typename DerivedC>
   typename DerivedC>
 IGL_INLINE void igl::AABB<DerivedV,DIM>::squared_distance(
 IGL_INLINE void igl::AABB<DerivedV,DIM>::squared_distance(
   const Eigen::MatrixBase<DerivedV> & V,
   const Eigen::MatrixBase<DerivedV> & V,
-  const Eigen::MatrixXi & Ele, 
+  const Eigen::MatrixBase<DerivedEle> & Ele, 
   const Eigen::MatrixBase<DerivedP> & P,
   const Eigen::MatrixBase<DerivedP> & P,
   Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
   Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
   Eigen::PlainObjectBase<DerivedI> & I,
   Eigen::PlainObjectBase<DerivedI> & I,
@@ -466,16 +474,18 @@ IGL_INLINE void igl::AABB<DerivedV,DIM>::squared_distance(
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
 template < 
 template < 
+  typename DerivedEle,
   typename Derivedother_V,
   typename Derivedother_V,
+  typename Derivedother_Ele,
   typename DerivedsqrD, 
   typename DerivedsqrD, 
   typename DerivedI, 
   typename DerivedI, 
   typename DerivedC>
   typename DerivedC>
 IGL_INLINE void igl::AABB<DerivedV,DIM>::squared_distance(
 IGL_INLINE void igl::AABB<DerivedV,DIM>::squared_distance(
   const Eigen::MatrixBase<DerivedV> & V,
   const Eigen::MatrixBase<DerivedV> & V,
-  const Eigen::MatrixXi & Ele, 
+  const Eigen::MatrixBase<DerivedEle> & Ele, 
   const AABB<Derivedother_V,DIM> & other,
   const AABB<Derivedother_V,DIM> & other,
   const Eigen::MatrixBase<Derivedother_V> & other_V,
   const Eigen::MatrixBase<Derivedother_V> & other_V,
-  const Eigen::MatrixXi & other_Ele, 
+  const Eigen::MatrixBase<Derivedother_Ele> & other_Ele, 
   Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
   Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
   Eigen::PlainObjectBase<DerivedI> & I,
   Eigen::PlainObjectBase<DerivedI> & I,
   Eigen::PlainObjectBase<DerivedC> & C) const
   Eigen::PlainObjectBase<DerivedC> & C) const
@@ -499,17 +509,19 @@ IGL_INLINE void igl::AABB<DerivedV,DIM>::squared_distance(
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
 template < 
 template < 
+  typename DerivedEle,
   typename Derivedother_V,
   typename Derivedother_V,
+  typename Derivedother_Ele,
   typename DerivedsqrD, 
   typename DerivedsqrD, 
   typename DerivedI, 
   typename DerivedI, 
   typename DerivedC>
   typename DerivedC>
 IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar 
 IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar 
   igl::AABB<DerivedV,DIM>::squared_distance_helper(
   igl::AABB<DerivedV,DIM>::squared_distance_helper(
   const Eigen::MatrixBase<DerivedV> & V,
   const Eigen::MatrixBase<DerivedV> & V,
-  const Eigen::MatrixXi & Ele, 
+  const Eigen::MatrixBase<DerivedEle> & Ele, 
   const AABB<Derivedother_V,DIM> * other,
   const AABB<Derivedother_V,DIM> * other,
   const Eigen::MatrixBase<Derivedother_V> & other_V,
   const Eigen::MatrixBase<Derivedother_V> & other_V,
-  const Eigen::MatrixXi & other_Ele, 
+  const Eigen::MatrixBase<Derivedother_Ele> & other_Ele, 
   const Scalar /*min_sqr_d*/,
   const Scalar /*min_sqr_d*/,
   Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
   Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
   Eigen::PlainObjectBase<DerivedI> & I,
   Eigen::PlainObjectBase<DerivedI> & I,
@@ -729,13 +741,14 @@ IGL_INLINE typename igl::AABB<DerivedV,DIM>::Scalar
 }
 }
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
+template <typename DerivedEle>
 IGL_INLINE void igl::AABB<DerivedV,DIM>::leaf_squared_distance(
 IGL_INLINE void igl::AABB<DerivedV,DIM>::leaf_squared_distance(
   const Eigen::MatrixBase<DerivedV> & V,
   const Eigen::MatrixBase<DerivedV> & V,
-  const Eigen::MatrixXi & Ele, 
+  const Eigen::MatrixBase<DerivedEle> & Ele, 
   const RowVectorDIMS & p,
   const RowVectorDIMS & p,
   Scalar & sqr_d,
   Scalar & sqr_d,
   int & i,
   int & i,
-  RowVectorDIMS & c) const
+  Eigen::PlainObjectBase<RowVectorDIMS> & c) const
 {
 {
   using namespace Eigen;
   using namespace Eigen;
   using namespace std;
   using namespace std;
@@ -759,7 +772,7 @@ IGL_INLINE void igl::AABB<DerivedV,DIM>::set_min(
   const RowVectorDIMS & c_candidate,
   const RowVectorDIMS & c_candidate,
   Scalar & sqr_d,
   Scalar & sqr_d,
   int & i,
   int & i,
-  RowVectorDIMS & c) const
+  Eigen::PlainObjectBase<RowVectorDIMS> & c) const
 {
 {
 #ifndef NDEBUG
 #ifndef NDEBUG
   //std::cout<<matlab_format(c_candidate,"c_candidate")<<std::endl;
   //std::cout<<matlab_format(c_candidate,"c_candidate")<<std::endl;
@@ -777,10 +790,11 @@ IGL_INLINE void igl::AABB<DerivedV,DIM>::set_min(
 
 
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
+template <typename DerivedEle>
 IGL_INLINE bool 
 IGL_INLINE bool 
 igl::AABB<DerivedV,DIM>::intersect_ray(
 igl::AABB<DerivedV,DIM>::intersect_ray(
   const Eigen::MatrixBase<DerivedV> & V,
   const Eigen::MatrixBase<DerivedV> & V,
-  const Eigen::MatrixXi & Ele, 
+  const Eigen::MatrixBase<DerivedEle> & Ele, 
   const RowVectorDIMS & origin,
   const RowVectorDIMS & origin,
   const RowVectorDIMS & dir,
   const RowVectorDIMS & dir,
   std::vector<igl::Hit> & hits) const
   std::vector<igl::Hit> & hits) const
@@ -819,10 +833,11 @@ igl::AABB<DerivedV,DIM>::intersect_ray(
 }
 }
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
+template <typename DerivedEle>
 IGL_INLINE bool 
 IGL_INLINE bool 
 igl::AABB<DerivedV,DIM>::intersect_ray(
 igl::AABB<DerivedV,DIM>::intersect_ray(
   const Eigen::MatrixBase<DerivedV> & V,
   const Eigen::MatrixBase<DerivedV> & V,
-  const Eigen::MatrixXi & Ele, 
+  const Eigen::MatrixBase<DerivedEle> & Ele, 
   const RowVectorDIMS & origin,
   const RowVectorDIMS & origin,
   const RowVectorDIMS & dir,
   const RowVectorDIMS & dir,
   igl::Hit & hit) const
   igl::Hit & hit) const
@@ -876,10 +891,11 @@ igl::AABB<DerivedV,DIM>::intersect_ray(
 }
 }
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
+template <typename DerivedEle>
 IGL_INLINE bool 
 IGL_INLINE bool 
 igl::AABB<DerivedV,DIM>::intersect_ray(
 igl::AABB<DerivedV,DIM>::intersect_ray(
   const Eigen::MatrixBase<DerivedV> & V,
   const Eigen::MatrixBase<DerivedV> & V,
-  const Eigen::MatrixXi & Ele, 
+  const Eigen::MatrixBase<DerivedEle> & Ele, 
   const RowVectorDIMS & origin,
   const RowVectorDIMS & origin,
   const RowVectorDIMS & dir,
   const RowVectorDIMS & dir,
   const Scalar _min_t,
   const Scalar _min_t,
@@ -945,23 +961,28 @@ igl::AABB<DerivedV,DIM>::intersect_ray(
 
 
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
 // Explicit template instantiation
-template std::vector<int, std::allocator<int> > igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::find<Eigen::Matrix<double, 1, -1, 1, 1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::MatrixBase<Eigen::Matrix<double, 1, -1, 1, 1, -1> > const&, bool) const;
-template std::vector<int, std::allocator<int> > igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::find<Eigen::Matrix<double, 1, -1, 1, 1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::MatrixBase<Eigen::Matrix<double, 1, -1, 1, 1, -1> > const&, bool) const;
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::init<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int);
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::serialize<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&,Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&, int) const;
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::init<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int);
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::serialize<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&, int) const;
-template void igl::AABB<Eigen::Matrix<float, -1, 3, 1, -1, 3>, 3>::init(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&);
-
-template float igl::AABB<Eigen::Matrix<float, -1, 3, 1, -1, 3>, 3>::squared_distance(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<float, 1, 3, 1, 1, 3> const&, int&, Eigen::Matrix<float, 1, 3, 1, 1, 3>&) const;
-template double igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, 1, 2, 1, 1, 2> const&, int&, Eigen::Matrix<double, 1, 2, 1, 1, 2>&) const;
-template double igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, int&, Eigen::Matrix<double, 1, 3, 1, 1, 3>&) const;
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&) const;
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::init(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&);
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::init(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&);
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
-template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&) const;
+// generated by autoexplicit.sh
+template float igl::AABB<Eigen::Matrix<float, -1, 3, 1, -1, 3>, 3>::squared_distance<Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::Matrix<float, 1, 3, 1, 1, 3> const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> >&) const;
+// generated by autoexplicit.sh
+template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<double, -1, -1, 0, -1, -1> >(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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
+// generated by autoexplicit.sh
+template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<long, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&) const;
+// generated by autoexplicit.sh
+template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<double, -1, -1, 0, -1, -1> >(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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
+// generated by autoexplicit.sh
+template double igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&) const;
+// generated by autoexplicit.sh
+template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<double, -1, -1, 0, -1, -1> >(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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
+// generated by autoexplicit.sh
+template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<long, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&) const;
+// generated by autoexplicit.sh
+template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<double, -1, -1, 0, -1, -1> >(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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
+// generated by autoexplicit.sh
+template double igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<double, 1, 2, 1, 1, 2> const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> >&) const;
+// generated by autoexplicit.sh
+template void igl::AABB<Eigen::Matrix<float, -1, 3, 1, -1, 3>, 3>::init<Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&);
+// generated by autoexplicit.sh
+template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::init<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
+// generated by autoexplicit.sh
+template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::init<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
 #endif
 #endif

+ 46 - 26
include/igl/AABB.h

@@ -105,18 +105,23 @@ public:
       //   bb_maxs  max_tree by dim list of bounding box max corner positions
       //   bb_maxs  max_tree by dim list of bounding box max corner positions
       //   elements  max_tree list of element or (not leaf id) indices into Ele
       //   elements  max_tree list of element or (not leaf id) indices into Ele
       //   i  recursive call index {0}
       //   i  recursive call index {0}
-      template <typename Derivedbb_mins, typename Derivedbb_maxs>
+      template <
+        typename DerivedEle, 
+        typename Derivedbb_mins, 
+        typename Derivedbb_maxs,
+        typename Derivedelements>
         IGL_INLINE void init(
         IGL_INLINE void init(
             const Eigen::MatrixBase<DerivedV> & V,
             const Eigen::MatrixBase<DerivedV> & V,
-            const Eigen::MatrixXi & Ele, 
+            const Eigen::MatrixBase<DerivedEle> & Ele, 
             const Eigen::MatrixBase<Derivedbb_mins> & bb_mins,
             const Eigen::MatrixBase<Derivedbb_mins> & bb_mins,
             const Eigen::MatrixBase<Derivedbb_maxs> & bb_maxs,
             const Eigen::MatrixBase<Derivedbb_maxs> & bb_maxs,
-            const Eigen::VectorXi & elements,
+            const Eigen::MatrixBase<Derivedelements> & elements,
             const int i = 0);
             const int i = 0);
       // Wrapper for root with empty serialization
       // Wrapper for root with empty serialization
+      template <typename DerivedEle>
       IGL_INLINE void init(
       IGL_INLINE void init(
           const Eigen::MatrixBase<DerivedV> & V,
           const Eigen::MatrixBase<DerivedV> & V,
-          const Eigen::MatrixXi & Ele);
+          const Eigen::MatrixBase<DerivedEle> & Ele);
       // Build an Axis-Aligned Bounding Box tree for a given mesh.
       // Build an Axis-Aligned Bounding Box tree for a given mesh.
       //
       //
       // Inputs:
       // Inputs:
@@ -129,11 +134,12 @@ public:
       //   I  #I list of indices into Ele of elements to include (for recursive
       //   I  #I list of indices into Ele of elements to include (for recursive
       //     calls)
       //     calls)
       // 
       // 
+      template <typename DerivedEle, typename DerivedSI, typename DerivedI>
       IGL_INLINE void init(
       IGL_INLINE void init(
           const Eigen::MatrixBase<DerivedV> & V,
           const Eigen::MatrixBase<DerivedV> & V,
-          const Eigen::MatrixXi & Ele, 
-          const Eigen::MatrixXi & SI,
-          const Eigen::VectorXi & I);
+          const Eigen::MatrixBase<DerivedEle> & Ele, 
+          const Eigen::MatrixBase<DerivedSI> & SI,
+          const Eigen::MatrixBase<DerivedI>& I);
       // Return whether at leaf node
       // Return whether at leaf node
       IGL_INLINE bool is_leaf() const;
       IGL_INLINE bool is_leaf() const;
       // Find the indices of elements containing given point: this makes sense
       // Find the indices of elements containing given point: this makes sense
@@ -148,10 +154,10 @@ public:
       //   first  whether to only return first element containing q
       //   first  whether to only return first element containing q
       // Returns:
       // Returns:
       //   list of indices of elements containing q
       //   list of indices of elements containing q
-      template <typename Derivedq>
+      template <typename DerivedEle, typename Derivedq>
       IGL_INLINE std::vector<int> find(
       IGL_INLINE std::vector<int> find(
           const Eigen::MatrixBase<DerivedV> & V,
           const Eigen::MatrixBase<DerivedV> & V,
-          const Eigen::MatrixXi & Ele, 
+          const Eigen::MatrixBase<DerivedEle> & Ele, 
           const Eigen::MatrixBase<Derivedq> & q,
           const Eigen::MatrixBase<Derivedq> & q,
           const bool first=false) const;
           const bool first=false) const;
 
 
@@ -166,11 +172,14 @@ public:
       //   bb_maxs  max_tree by dim list of bounding box max corner positions
       //   bb_maxs  max_tree by dim list of bounding box max corner positions
       //   elements  max_tree list of element or (not leaf id) indices into Ele
       //   elements  max_tree list of element or (not leaf id) indices into Ele
       //   i  recursive call index into these arrays {0}
       //   i  recursive call index into these arrays {0}
-      template <typename Derivedbb_mins, typename Derivedbb_maxs>
+      template <
+        typename Derivedbb_mins, 
+        typename Derivedbb_maxs,
+        typename Derivedelements>
         IGL_INLINE void serialize(
         IGL_INLINE void serialize(
             Eigen::PlainObjectBase<Derivedbb_mins> & bb_mins,
             Eigen::PlainObjectBase<Derivedbb_mins> & bb_mins,
             Eigen::PlainObjectBase<Derivedbb_maxs> & bb_maxs,
             Eigen::PlainObjectBase<Derivedbb_maxs> & bb_maxs,
-            Eigen::VectorXi & elements,
+            Eigen::PlainObjectBase<Derivedelements> & elements,
             const int i = 0) const;
             const int i = 0) const;
       // Compute squared distance to a query point
       // Compute squared distance to a query point
       //
       //
@@ -185,12 +194,13 @@ public:
       //
       //
       // Known bugs: currently assumes Elements are triangles regardless of
       // Known bugs: currently assumes Elements are triangles regardless of
       // dimension.
       // dimension.
+      template <typename DerivedEle>
       IGL_INLINE Scalar squared_distance(
       IGL_INLINE Scalar squared_distance(
         const Eigen::MatrixBase<DerivedV> & V,
         const Eigen::MatrixBase<DerivedV> & V,
-        const Eigen::MatrixXi & Ele, 
+        const Eigen::MatrixBase<DerivedEle> & Ele, 
         const RowVectorDIMS & p,
         const RowVectorDIMS & p,
         int & i,
         int & i,
-        RowVectorDIMS & c) const;
+        Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
 //private:
 //private:
       // Compute squared distance to a query point
       // Compute squared distance to a query point
       //
       //
@@ -208,31 +218,35 @@ public:
       //
       //
       // Known bugs: currently assumes Elements are triangles regardless of
       // Known bugs: currently assumes Elements are triangles regardless of
       // dimension.
       // dimension.
+      template <typename DerivedEle>
       IGL_INLINE Scalar squared_distance(
       IGL_INLINE Scalar squared_distance(
         const Eigen::MatrixBase<DerivedV> & V,
         const Eigen::MatrixBase<DerivedV> & V,
-        const Eigen::MatrixXi & Ele, 
+        const Eigen::MatrixBase<DerivedEle> & Ele, 
         const RowVectorDIMS & p,
         const RowVectorDIMS & p,
         const Scalar min_sqr_d,
         const Scalar min_sqr_d,
         int & i,
         int & i,
-        RowVectorDIMS & c) const;
+        Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
       // All hits
       // All hits
+      template <typename DerivedEle>
       IGL_INLINE bool intersect_ray(
       IGL_INLINE bool intersect_ray(
         const Eigen::MatrixBase<DerivedV> & V,
         const Eigen::MatrixBase<DerivedV> & V,
-        const Eigen::MatrixXi & Ele, 
+        const Eigen::MatrixBase<DerivedEle> & Ele, 
         const RowVectorDIMS & origin,
         const RowVectorDIMS & origin,
         const RowVectorDIMS & dir,
         const RowVectorDIMS & dir,
         std::vector<igl::Hit> & hits) const;
         std::vector<igl::Hit> & hits) const;
       // First hit
       // First hit
+      template <typename DerivedEle>
       IGL_INLINE bool intersect_ray(
       IGL_INLINE bool intersect_ray(
         const Eigen::MatrixBase<DerivedV> & V,
         const Eigen::MatrixBase<DerivedV> & V,
-        const Eigen::MatrixXi & Ele, 
+        const Eigen::MatrixBase<DerivedEle> & Ele, 
         const RowVectorDIMS & origin,
         const RowVectorDIMS & origin,
         const RowVectorDIMS & dir,
         const RowVectorDIMS & dir,
         igl::Hit & hit) const;
         igl::Hit & hit) const;
 //private:
 //private:
+      template <typename DerivedEle>
       IGL_INLINE bool intersect_ray(
       IGL_INLINE bool intersect_ray(
         const Eigen::MatrixBase<DerivedV> & V,
         const Eigen::MatrixBase<DerivedV> & V,
-        const Eigen::MatrixXi & Ele, 
+        const Eigen::MatrixBase<DerivedEle> & Ele, 
         const RowVectorDIMS & origin,
         const RowVectorDIMS & origin,
         const RowVectorDIMS & dir,
         const RowVectorDIMS & dir,
         const Scalar min_t,
         const Scalar min_t,
@@ -253,13 +267,14 @@ public:
       //   I  #P list of indices into Ele of closest primitives
       //   I  #P list of indices into Ele of closest primitives
       //   C  #P by dim list of closest points
       //   C  #P by dim list of closest points
       template <
       template <
+        typename DerivedEle,
         typename DerivedP, 
         typename DerivedP, 
         typename DerivedsqrD, 
         typename DerivedsqrD, 
         typename DerivedI, 
         typename DerivedI, 
         typename DerivedC>
         typename DerivedC>
       IGL_INLINE void squared_distance(
       IGL_INLINE void squared_distance(
         const Eigen::MatrixBase<DerivedV> & V,
         const Eigen::MatrixBase<DerivedV> & V,
-        const Eigen::MatrixXi & Ele, 
+        const Eigen::MatrixBase<DerivedEle> & Ele, 
         const Eigen::MatrixBase<DerivedP> & P,
         const Eigen::MatrixBase<DerivedP> & P,
         Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
         Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
         Eigen::PlainObjectBase<DerivedI> & I,
         Eigen::PlainObjectBase<DerivedI> & I,
@@ -281,31 +296,35 @@ public:
       //   I  #P list of indices into Ele of closest primitives
       //   I  #P list of indices into Ele of closest primitives
       //   C  #P by dim list of closest points
       //   C  #P by dim list of closest points
       template < 
       template < 
+        typename DerivedEle,
         typename Derivedother_V,
         typename Derivedother_V,
+        typename Derivedother_Ele,
         typename DerivedsqrD, 
         typename DerivedsqrD, 
         typename DerivedI, 
         typename DerivedI, 
         typename DerivedC>
         typename DerivedC>
       IGL_INLINE void squared_distance(
       IGL_INLINE void squared_distance(
         const Eigen::MatrixBase<DerivedV> & V,
         const Eigen::MatrixBase<DerivedV> & V,
-        const Eigen::MatrixXi & Ele, 
+        const Eigen::MatrixBase<DerivedEle> & Ele, 
         const AABB<Derivedother_V,DIM> & other,
         const AABB<Derivedother_V,DIM> & other,
         const Eigen::MatrixBase<Derivedother_V> & other_V,
         const Eigen::MatrixBase<Derivedother_V> & other_V,
-        const Eigen::MatrixXi & other_Ele, 
+        const Eigen::MatrixBase<Derivedother_Ele> & other_Ele, 
         Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
         Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
         Eigen::PlainObjectBase<DerivedI> & I,
         Eigen::PlainObjectBase<DerivedI> & I,
         Eigen::PlainObjectBase<DerivedC> & C) const;
         Eigen::PlainObjectBase<DerivedC> & C) const;
 private:
 private:
       template < 
       template < 
+        typename DerivedEle,
         typename Derivedother_V,
         typename Derivedother_V,
+        typename Derivedother_Ele,
         typename DerivedsqrD, 
         typename DerivedsqrD, 
         typename DerivedI, 
         typename DerivedI, 
         typename DerivedC>
         typename DerivedC>
       IGL_INLINE Scalar squared_distance_helper(
       IGL_INLINE Scalar squared_distance_helper(
         const Eigen::MatrixBase<DerivedV> & V,
         const Eigen::MatrixBase<DerivedV> & V,
-        const Eigen::MatrixXi & Ele, 
+        const Eigen::MatrixBase<DerivedEle> & Ele, 
         const AABB<Derivedother_V,DIM> * other,
         const AABB<Derivedother_V,DIM> * other,
         const Eigen::MatrixBase<Derivedother_V> & other_V,
         const Eigen::MatrixBase<Derivedother_V> & other_V,
-        const Eigen::MatrixXi & other_Ele, 
+        const Eigen::MatrixBase<Derivedother_Ele>& other_Ele, 
         const Scalar min_sqr_d,
         const Scalar min_sqr_d,
         Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
         Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
         Eigen::PlainObjectBase<DerivedI> & I,
         Eigen::PlainObjectBase<DerivedI> & I,
@@ -325,13 +344,14 @@ private:
       //     primitive
       //     primitive
       //   i  possibly updated index into Ele of closest point
       //   i  possibly updated index into Ele of closest point
       //   c  dim-long possibly updated closest point
       //   c  dim-long possibly updated closest point
+      template <typename DerivedEle>
       IGL_INLINE void leaf_squared_distance(
       IGL_INLINE void leaf_squared_distance(
         const Eigen::MatrixBase<DerivedV> & V,
         const Eigen::MatrixBase<DerivedV> & V,
-        const Eigen::MatrixXi & Ele, 
+        const Eigen::MatrixBase<DerivedEle> & Ele, 
         const RowVectorDIMS & p,
         const RowVectorDIMS & p,
         Scalar & sqr_d,
         Scalar & sqr_d,
         int & i,
         int & i,
-        RowVectorDIMS & c) const;
+        Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
       // If new distance (sqr_d_candidate) is less than current distance
       // If new distance (sqr_d_candidate) is less than current distance
       // (sqr_d), then update this distance and its associated values
       // (sqr_d), then update this distance and its associated values
       // _in-place_:
       // _in-place_:
@@ -356,7 +376,7 @@ private:
         const RowVectorDIMS & c_candidate,
         const RowVectorDIMS & c_candidate,
         Scalar & sqr_d,
         Scalar & sqr_d,
         int & i,
         int & i,
-        RowVectorDIMS & c) const;
+        Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
 public:
 public:
       EIGEN_MAKE_ALIGNED_OPERATOR_NEW
       EIGEN_MAKE_ALIGNED_OPERATOR_NEW
     };
     };

+ 2 - 0
include/igl/barycenter.cpp

@@ -34,6 +34,8 @@ IGL_INLINE void igl::barycenter(
 #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::barycenter<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<float, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&);
+// generated by autoexplicit.sh
 template void igl::barycenter<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&);
 template void igl::barycenter<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&);
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
 template void igl::barycenter<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> >&);
 template void igl::barycenter<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> >&);

+ 2 - 0
include/igl/point_simplex_squared_distance.cpp

@@ -157,6 +157,8 @@ IGL_INLINE void igl::point_simplex_squared_distance(
 #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::point_simplex_squared_distance<3, Eigen::Matrix<float, 1, 3, 1, 1, 3>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, float, Eigen::Matrix<float, 1, 3, 1, 1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::Matrix<int, -1, 3, 1, -1, 3>::Index, float&, Eigen::MatrixBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> >&);
+// generated by autoexplicit.sh
 template void igl::point_simplex_squared_distance<3, Eigen::Matrix<float, 1, 3, 1, 1, 3>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, float, Eigen::Matrix<float, 1, 3, 1, 1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, float&, Eigen::MatrixBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> >&);
 template void igl::point_simplex_squared_distance<3, Eigen::Matrix<float, 1, 3, 1, 1, 3>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, float, Eigen::Matrix<float, 1, 3, 1, 1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, float&, Eigen::MatrixBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> >&);
 template void igl::point_simplex_squared_distance<3, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double, Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, double&, Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&);
 template void igl::point_simplex_squared_distance<3, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double, Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, double&, Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&);
 template void igl::point_simplex_squared_distance<2, Eigen::Matrix<double, 1, 2, 1, 1, 2>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double, Eigen::Matrix<double, 1, 2, 1, 1, 2> >(Eigen::MatrixBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, double&, Eigen::MatrixBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> >&);
 template void igl::point_simplex_squared_distance<2, Eigen::Matrix<double, 1, 2, 1, 1, 2>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double, Eigen::Matrix<double, 1, 2, 1, 1, 2> >(Eigen::MatrixBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, double&, Eigen::MatrixBase<Eigen::Matrix<double, 1, 2, 1, 1, 2> >&);

+ 7 - 3
include/igl/signed_distance.cpp

@@ -232,7 +232,7 @@ IGL_INLINE void igl::signed_distance_pseudonormal(
   I.resize(np,1);
   I.resize(np,1);
   N.resize(np,3);
   N.resize(np,3);
   C.resize(np,3);
   C.resize(np,3);
-  typedef Eigen::Matrix<typename DerivedV::Scalar,1,3> RowVector3S;
+  typedef typename AABB<DerivedV,3>::RowVectorDIMS RowVector3S;
 # pragma omp parallel for if(np>1000)
 # pragma omp parallel for if(np>1000)
   for(size_t p = 0;p<np;p++)
   for(size_t p = 0;p<np;p++)
   {
   {
@@ -276,8 +276,12 @@ IGL_INLINE void igl::signed_distance_pseudonormal(
 {
 {
   using namespace Eigen;
   using namespace Eigen;
   using namespace std;
   using namespace std;
-  typedef Eigen::Matrix<typename DerivedV::Scalar,1,3> RowVector3S;
-  sqrd = tree.squared_distance(V,F,RowVector3S(q),i,(RowVector3S&)c);
+  //typedef Eigen::Matrix<typename DerivedV::Scalar,1,3> RowVector3S;
+  // Alec: Why was this constructor around q necessary?
+  //sqrd = tree.squared_distance(V,F,RowVector3S(q),i,(RowVector3S&)c);
+  // Alec: Why was this constructor around c necessary?
+  //sqrd = tree.squared_distance(V,F,q,i,(RowVector3S&)c);
+  sqrd = tree.squared_distance(V,F,q,i,c);
   pseudonormal_test(V,F,FN,VN,EN,EMAP,q,i,c,s,n);
   pseudonormal_test(V,F,FN,VN,EN,EMAP,q,i,c,s,n);
 }
 }