Explorar o código

make is_border_vertex() + tt() work for general face matrix types

Former-commit-id: 10205ae8cb84cbe992d66d3aff7e743e0c846c1d
kenshi %!s(int64=12) %!d(string=hai) anos
pai
achega
f7d4aaeaf3
Modificáronse 3 ficheiros con 11 adicións e 11 borrados
  1. 4 4
      include/igl/is_border_vertex.cpp
  2. 3 3
      include/igl/is_border_vertex.h
  3. 4 4
      include/igl/tt.cpp

+ 4 - 4
include/igl/is_border_vertex.cpp

@@ -3,10 +3,10 @@
 
 #include "tt.h"
 
-template<typename T, typename S>
-IGL_INLINE std::vector<bool> igl::is_border_vertex(const T& V, const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic>& F)
+template <typename DerivedV, typename DerivedF>
+IGL_INLINE std::vector<bool> igl::is_border_vertex(const Eigen::PlainObjectBase<DerivedV> &V, const Eigen::PlainObjectBase<DerivedF> &F)
 {
-  Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic> FF;
+  Eigen::PlainObjectBase<DerivedF> FF;
   igl::tt(V,F,FF);
   std::vector<bool> ret(V.rows());
   for(unsigned i=0; i<ret.size();++i)
@@ -17,7 +17,7 @@ IGL_INLINE std::vector<bool> igl::is_border_vertex(const T& V, const Eigen::Matr
       if(FF(i,j) == -1)
       {
         ret[F(i,j)]       = true;
-        ret[F(i,(j+1)%3)] = true;
+        ret[F(i,(j+1)%F.cols())] = true;
       }
   return ret;
 }

+ 3 - 3
include/igl/is_border_vertex.h

@@ -12,9 +12,9 @@
 
 namespace igl 
 {
-  template<typename T, typename S>
-  IGL_INLINE std::vector<bool> is_border_vertex(const T& V,
-                                                const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic>& F);
+  template <typename DerivedV, typename DerivedF>
+  IGL_INLINE std::vector<bool> is_border_vertex(const Eigen::PlainObjectBase<DerivedV> &V,
+                                                const Eigen::PlainObjectBase<DerivedF> &F);
 }
 
 #ifdef IGL_HEADER_ONLY

+ 4 - 4
include/igl/tt.cpp

@@ -9,11 +9,11 @@ IGL_INLINE void igl::tt_preprocess(const Eigen::PlainObjectBase<DerivedV>& /*V*/
                                    std::vector<std::vector<int> >& TTT)
 {
   for(int f=0;f<F.rows();++f)
-    for (int i=0;i<3;++i)
+    for (int i=0;i<F.cols();++i)
     {
       // v1 v2 f ei 
       int v1 = F(f,i);
-      int v2 = F(f,(i+1)%3);
+      int v2 = F(f,(i+1)%F.cols());
       if (v1 > v2) std::swap(v1,v2);
       std::vector<int> r(4);
       r[0] = v1; r[1] = v2;
@@ -29,7 +29,7 @@ IGL_INLINE void igl::tt_extractTT(const Eigen::PlainObjectBase<DerivedF>& F,
                                   std::vector<std::vector<int> >& TTT,
                                   Eigen::PlainObjectBase<DerivedTT>& TT)
 {
-  TT = Eigen::PlainObjectBase<DerivedTT>::Constant((int)(F.rows()),3,-1);
+  TT = Eigen::PlainObjectBase<DerivedTT>::Constant((int)(F.rows()),F.cols(),-1);
   
   for(int i=1;i<(int)TTT.size();++i)
   {
@@ -49,7 +49,7 @@ IGL_INLINE void igl::tt_extractTTi(const Eigen::PlainObjectBase<DerivedF>& F,
                                    std::vector<std::vector<int> >& TTT,
                                    Eigen::PlainObjectBase<DerivedTT>& TTi)
 {
-  TTi = Eigen::PlainObjectBase<DerivedTT>::Constant((int)(F.rows()),3,-1);
+  TTi = Eigen::PlainObjectBase<DerivedTT>::Constant((int)(F.rows()),F.cols(),-1);
   
   for(int i=1;i<(int)TTT.size();++i)
   {