Эх сурвалжийг харах

changed templates for tt to enable different types for F and TT,TTi (F might be unsigned but TT has to contain -1's)

Former-commit-id: 65fc6bcf36cd19a6cad24ba173077803da3e4385
dolga 13 жил өмнө
parent
commit
1f7f30930c

+ 2 - 0
include/igl/cotangent.cpp

@@ -116,7 +116,9 @@ IGL_INLINE void igl::cotangent(const MatV & V, const MatF & F, MatC & C)
     }
     if(diag_all_pos)
     {
+#ifdef VERBOSE 
       verbose("cotangent.h: Flipping sign of cotangent, so that cots are positive\n");
+#endif
       C *= -1.0;
     }
   }else

+ 4 - 4
include/igl/is_manifold.cpp

@@ -2,9 +2,9 @@
 
 #include <algorithm>
 
-template<typename T, typename S>
-IGL_INLINE bool igl::is_manifold(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V,
-                                 const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic>& F)
+template <typename DerivedV, typename DerivedF>
+IGL_INLINE bool igl::is_manifold(const Eigen::PlainObjectBase<DerivedV>& V,
+                                 const Eigen::PlainObjectBase<DerivedF>& F)
   {
     std::vector<std::vector<int> > TTT;
     for(int f=0;f<F.rows();++f)
@@ -39,5 +39,5 @@ IGL_INLINE bool igl::is_manifold(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::D
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
 // generated by autoexplicit.sh
-template bool igl::is_manifold<double>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&);
+//template bool igl::is_manifold<double>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&);
 #endif

+ 3 - 3
include/igl/is_manifold.h

@@ -18,9 +18,9 @@ namespace igl
   //
   // Known Bugs:
   //  Does not check for non-manifold vertices
-  template<typename T, typename S>
-  IGL_INLINE bool is_manifold(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V,
-                              const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic>& F);
+  template <typename DerivedV, typename DerivedF>
+  IGL_INLINE bool is_manifold(const Eigen::PlainObjectBase<DerivedV>& V,
+                              const Eigen::PlainObjectBase<DerivedF>& F);
 }
 
 #ifdef IGL_HEADER_ONLY

+ 26 - 16
include/igl/tt.cpp

@@ -3,8 +3,10 @@
 #include "is_manifold.h"
 #include <algorithm>
 
-template<typename T, typename S> 
-IGL_INLINE void igl::tt_preprocess(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& , const Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& F, std::vector<std::vector<int> >& TTT)
+template <typename DerivedV, typename DerivedF>
+IGL_INLINE void igl::tt_preprocess(const Eigen::PlainObjectBase<DerivedV>& V,
+                                   const Eigen::PlainObjectBase<DerivedF>& F,
+                                   std::vector<std::vector<int> >& TTT)
 {
   for(int f=0;f<F.rows();++f)
     for (int i=0;i<3;++i)
@@ -22,10 +24,12 @@ IGL_INLINE void igl::tt_preprocess(const Eigen::Matrix<T, Eigen::Dynamic, Eigen:
 }
 
 // Extract the face adjacencies
-template<typename S> 
-IGL_INLINE void igl::tt_extractTT(const Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& F, std::vector<std::vector<int> >& TTT, Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& TT)
+template <typename DerivedF, typename DerivedTT>
+IGL_INLINE void igl::tt_extractTT(const Eigen::PlainObjectBase<DerivedF>& F,
+                                  std::vector<std::vector<int> >& TTT,
+                                  Eigen::PlainObjectBase<DerivedTT>& TT)
 {
-  TT = Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>::Constant((int)(F.rows()),3,-1);
+  TT = Eigen::PlainObjectBase<DerivedTT>::Constant((int)(F.rows()),3,-1);
   
   for(int i=1;i<(int)TTT.size();++i)
   {
@@ -40,10 +44,12 @@ IGL_INLINE void igl::tt_extractTT(const Eigen::Matrix<S,Eigen::Dynamic, Eigen::D
 }
 
 // Extract the face adjacencies indices (needed for fast traversal)
-template<typename S> 
-IGL_INLINE void igl::tt_extractTTi(const Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& F, std::vector<std::vector<int> >& TTT, Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& TTi)
+template <typename DerivedF, typename DerivedTT>
+IGL_INLINE void igl::tt_extractTTi(const Eigen::PlainObjectBase<DerivedF>& F,
+                                   std::vector<std::vector<int> >& TTT,
+                                   Eigen::PlainObjectBase<DerivedTT>& TTi)
 {
-  TTi = Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>::Constant((int)(F.rows()),3,-1);
+  TTi = Eigen::PlainObjectBase<DerivedTT>::Constant((int)(F.rows()),3,-1);
   
   for(int i=1;i<(int)TTT.size();++i)
   {
@@ -58,24 +64,29 @@ IGL_INLINE void igl::tt_extractTTi(const Eigen::Matrix<S,Eigen::Dynamic, Eigen::
 }
 
 // Compute triangle-triangle adjacency
-template<typename T, typename S> 
-IGL_INLINE void igl::tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& F, Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& TT)
+template <typename DerivedV, typename DerivedF, typename DerivedTT>
+IGL_INLINE void igl::tt(const Eigen::PlainObjectBase<DerivedV>& V,
+                        const Eigen::PlainObjectBase<DerivedF>& F,
+                        Eigen::PlainObjectBase<DerivedTT>& TT)
 {
   assert(igl::is_manifold(V,F));
   std::vector<std::vector<int> > TTT;
   
-  tt_preprocess<T>(V,F,TTT);
+  tt_preprocess(V,F,TTT);
   tt_extractTT(F,TTT,TT);
 }
 
 // Compute triangle-triangle adjacency with indices
-template<typename T, typename S> 
-IGL_INLINE void igl::tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& F, Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& TT, Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& TTi)
+template <typename DerivedV, typename DerivedF, typename DerivedTT>
+IGL_INLINE void igl::tt(const Eigen::PlainObjectBase<DerivedV>& V,
+                        const Eigen::PlainObjectBase<DerivedF>& F,
+                        Eigen::PlainObjectBase<DerivedTT>& TT,
+                        Eigen::PlainObjectBase<DerivedTT>& TTi)
 {
   assert(igl::is_manifold(V,F));
   std::vector<std::vector<int> > TTT;
   
-  tt_preprocess<T>(V,F,TTT);
+  tt_preprocess(V,F,TTT);
   tt_extractTT(F,TTT,TT);
   tt_extractTTi(F,TTT,TTi);
 }
@@ -83,6 +94,5 @@ IGL_INLINE void igl::tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>&
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
 // generated by autoexplicit.sh
-template void igl::tt<double>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1>&);
-template void igl::tt<double, int>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1>&, Eigen::Matrix<int, -1, -1, 0, -1, -1>&);
+template void igl::tt<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(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<int, -1, -1, 0, -1, -1> >&);
 #endif

+ 21 - 10
include/igl/tt.h

@@ -14,20 +14,31 @@
 namespace igl 
 {
   // Preprocessing
-  template<typename T, typename S> 
-  IGL_INLINE void tt_preprocess(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& F, std::vector<std::vector<int> >& TTT);
+  template <typename DerivedV, typename DerivedF>
+  IGL_INLINE void tt_preprocess(const Eigen::PlainObjectBase<DerivedV>& V,
+                                const Eigen::PlainObjectBase<DerivedF>& F,
+                                std::vector<std::vector<int> >& TTT);
   // Extract the face adjacencies
-  template<typename S> 
-  IGL_INLINE void tt_extractTT(const Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& F, std::vector<std::vector<int> >& TTT, Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& TT);
+  template <typename DerivedF, typename DerivedTT>
+  IGL_INLINE void tt_extractTT(const Eigen::PlainObjectBase<DerivedF>& F,
+                               std::vector<std::vector<int> >& TTT,
+                               Eigen::PlainObjectBase<DerivedTT>& TT);
   // Extract the face adjacencies indices (needed for fast traversal)
-  template<typename S> 
-  IGL_INLINE void tt_extractTTi(const Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& F, std::vector<std::vector<int> >& TTT, Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& TTi);
+  template <typename DerivedF, typename DerivedTT>
+  IGL_INLINE void tt_extractTTi(const Eigen::PlainObjectBase<DerivedF>& F,
+                                std::vector<std::vector<int> >& TTT,
+                                Eigen::PlainObjectBase<DerivedTT>& TTi);
   // Compute triangle-triangle adjacency
-  template<typename T, typename S> 
-  IGL_INLINE void tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& F, Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& TT);
+  template <typename DerivedV, typename DerivedF, typename DerivedTT>
+  IGL_INLINE void tt(const Eigen::PlainObjectBase<DerivedV>& V,
+                     const Eigen::PlainObjectBase<DerivedF>& F,
+                     Eigen::PlainObjectBase<DerivedTT>& TT);
   // Compute triangle-triangle adjacency with indices
-  template<typename T, typename S> 
-  IGL_INLINE void tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& F, Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& TT, Eigen::Matrix<S,Eigen::Dynamic, Eigen::Dynamic>& TTi);
+  template <typename DerivedV, typename DerivedF, typename DerivedTT>
+  IGL_INLINE void tt(const Eigen::PlainObjectBase<DerivedV>& V,
+                     const Eigen::PlainObjectBase<DerivedF>& F,
+                     Eigen::PlainObjectBase<DerivedTT>& TT,
+                     Eigen::PlainObjectBase<DerivedTT>& TTi);
 }
 
 #ifdef IGL_HEADER_ONLY

+ 1 - 1
include/igl/upsample.cpp

@@ -89,5 +89,5 @@ IGL_INLINE void igl::upsample( MatV & V,MatF & F)
 
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
-template void igl::upsample<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<int, -1, -1, 0, -1, -1>&);
+//template void igl::upsample<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<int, -1, -1, 0, -1, -1>&);
 #endif