浏览代码

remove legacy interface, templating

Former-commit-id: 5bae702d752cab01c361e6bb3081eb98b43f8761
Alec Jacobson 9 年之前
父节点
当前提交
ceb3f7c459
共有 2 个文件被更改,包括 32 次插入95 次删除
  1. 23 65
      include/igl/triangle_triangle_adjacency.cpp
  2. 9 30
      include/igl/triangle_triangle_adjacency.h

+ 23 - 65
include/igl/triangle_triangle_adjacency.cpp

@@ -13,19 +13,31 @@
 #include <algorithm>
 #include <iostream>
 
-template <typename Scalar, typename Index>
-IGL_INLINE void igl::triangle_triangle_adjacency_preprocess(
-    const Eigen::PlainObjectBase<Scalar>& /*V*/,
-    const Eigen::PlainObjectBase<Index>& F,
-    std::vector<std::vector<int> >& TTT)
+// Extract the face adjacencies
+template <typename DerivedF, typename TTT_type, typename DerivedTT>
+IGL_INLINE void igl::triangle_triangle_adjacency_extractTT(
+  const Eigen::PlainObjectBase<DerivedF>& F,
+  std::vector<std::vector<TTT_type> >& TTT,
+  Eigen::PlainObjectBase<DerivedTT>& TT)
 {
-  return triangle_triangle_adjacency_preprocess(F,TTT);
+  TT.setConstant((int)(F.rows()),F.cols(),-1);
+
+  for(int i=1;i<(int)TTT.size();++i)
+  {
+    std::vector<int>& r1 = TTT[i-1];
+    std::vector<int>& r2 = TTT[i];
+    if ((r1[0] == r2[0]) && (r1[1] == r2[1]))
+    {
+      TT(r1[2],r1[3]) = r2[2];
+      TT(r2[2],r2[3]) = r1[2];
+    }
+  }
 }
 
-template <typename Index>
+template <typename DerivedF, typename TTT_type>
 IGL_INLINE void igl::triangle_triangle_adjacency_preprocess(
-    const Eigen::PlainObjectBase<Index>& F,
-    std::vector<std::vector<int> >& TTT)
+  const Eigen::PlainObjectBase<DerivedF>& F,
+  std::vector<std::vector<TTT_type> >& TTT)
 {
   for(int f=0;f<F.rows();++f)
     for (int i=0;i<F.cols();++i)
@@ -42,32 +54,11 @@ IGL_INLINE void igl::triangle_triangle_adjacency_preprocess(
   std::sort(TTT.begin(),TTT.end());
 }
 
-// Extract the face adjacencies
-template <typename DerivedF, typename DerivedTT>
-IGL_INLINE void igl::triangle_triangle_adjacency_extractTT(
-  const Eigen::PlainObjectBase<DerivedF>& F,
-  std::vector<std::vector<int> >& TTT,
-  Eigen::PlainObjectBase<DerivedTT>& TT)
-{
-  TT.setConstant((int)(F.rows()),F.cols(),-1);
-
-  for(int i=1;i<(int)TTT.size();++i)
-  {
-    std::vector<int>& r1 = TTT[i-1];
-    std::vector<int>& r2 = TTT[i];
-    if ((r1[0] == r2[0]) && (r1[1] == r2[1]))
-    {
-      TT(r1[2],r1[3]) = r2[2];
-      TT(r2[2],r2[3]) = r1[2];
-    }
-  }
-}
-
 // Extract the face adjacencies indices (needed for fast traversal)
-template <typename DerivedF, typename DerivedTTi>
+template <typename DerivedF, typename TTT_type, typename DerivedTTi>
 IGL_INLINE void igl::triangle_triangle_adjacency_extractTTi(
   const Eigen::PlainObjectBase<DerivedF>& F,
-  std::vector<std::vector<int> >& TTT,
+  std::vector<std::vector<TTT_type> >& TTT,
   Eigen::PlainObjectBase<DerivedTTi>& TTi)
 {
   TTi.setConstant((int)(F.rows()),F.cols(),-1);
@@ -84,34 +75,6 @@ IGL_INLINE void igl::triangle_triangle_adjacency_extractTTi(
   }
 }
 
-// Compute triangle-triangle adjacency
-template <typename Scalar, typename Index>
-IGL_INLINE void igl::triangle_triangle_adjacency(const Eigen::PlainObjectBase<Scalar>& V,
-                        const Eigen::PlainObjectBase<Index>& F,
-                        Eigen::PlainObjectBase<Index>& TT)
-{
-  //assert(igl::is_edge_manifold(V,F));
-  std::vector<std::vector<int> > TTT;
-
-  triangle_triangle_adjacency_preprocess(V,F,TTT);
-  triangle_triangle_adjacency_extractTT(F,TTT,TT);
-}
-
-// Compute triangle-triangle adjacency with indices
-template <typename Scalar, typename Index>
-IGL_INLINE void igl::triangle_triangle_adjacency(
-  const Eigen::PlainObjectBase<Scalar>& /*V*/,
-  const Eigen::PlainObjectBase<Index>& F,
-  Eigen::PlainObjectBase<Index>& TT,
-  Eigen::PlainObjectBase<Index>& TTi)
-{
-  //assert(igl::is_edge_manifold(V,F));
-  std::vector<std::vector<int> > TTT;
-  triangle_triangle_adjacency_preprocess(F,TTT);
-  triangle_triangle_adjacency_extractTT(F,TTT,TT);
-  triangle_triangle_adjacency_extractTTi(F,TTT,TTi);
-}
-
 // Compute triangle-triangle adjacency with indices
 template <typename DerivedF, typename DerivedTT, typename DerivedTTi>
 IGL_INLINE void igl::triangle_triangle_adjacency(
@@ -119,7 +82,6 @@ IGL_INLINE void igl::triangle_triangle_adjacency(
   Eigen::PlainObjectBase<DerivedTT>& TT,
   Eigen::PlainObjectBase<DerivedTTi>& TTi)
 {
-  //assert(igl::is_edge_manifold(V,F));
   std::vector<std::vector<int> > TTT;
   triangle_triangle_adjacency_preprocess(F,TTT);
   triangle_triangle_adjacency_extractTT(F,TTT,TT);
@@ -235,10 +197,6 @@ template <
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::triangle_triangle_adjacency<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
-template void igl::triangle_triangle_adjacency<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> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::triangle_triangle_adjacency<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> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::triangle_triangle_adjacency<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
 template void igl::triangle_triangle_adjacency<Eigen::Matrix<int, -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<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 template void igl::triangle_triangle_adjacency<Eigen::Matrix<int, -1, 2, 0, -1, 2>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, long, long, long>(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, bool, std::vector<std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >, std::allocator<std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > > >&, std::vector<std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >, std::allocator<std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > > >&);
 template void igl::triangle_triangle_adjacency<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, unsigned long, int, int>(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, std::vector<std::vector<unsigned long, std::allocator<unsigned long> >, std::allocator<std::vector<unsigned long, std::allocator<unsigned long> > > > const&, bool, std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >&, std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >&);

+ 9 - 30
include/igl/triangle_triangle_adjacency.h

@@ -22,7 +22,6 @@ namespace igl
   //   Index  derived type of eigen matrix for F (e.g. derived from
   //     MatrixXi)
   // Inputs:
-  //   V  #V by dim list of mesh vertex positions
   //   F  #F by simplex_size list of mesh faces (must be triangles)
   // Outputs:
   //   TT   #F by #3 adjacent matrix, the element i,j is the id of the triangle adjacent to the j edge of triangle i
@@ -30,56 +29,36 @@ namespace igl
   // NOTE: the first edge of a triangle is [0,1] the second [1,2] and the third [2,3].
   //       this convention is DIFFERENT from cotmatrix_entries.h
   // Known bug: this should not need to take V as input.
-
-  template <typename Scalar, typename Index>
-  IGL_INLINE void triangle_triangle_adjacency(
-    const Eigen::PlainObjectBase<Scalar>& V,
-    const Eigen::PlainObjectBase<Index>& F,
-    Eigen::PlainObjectBase<Index>& TT);
-  // Compute triangle-triangle adjacency with indices
-  template <typename Scalar, typename Index>
-  IGL_INLINE void triangle_triangle_adjacency(
-    const Eigen::PlainObjectBase<Scalar>& V,
-    const Eigen::PlainObjectBase<Index>& F,
-    Eigen::PlainObjectBase<Index>& TT,
-    Eigen::PlainObjectBase<Index>& TTi);
-
   template <typename DerivedF, typename DerivedTT, typename DerivedTTi>
   IGL_INLINE void triangle_triangle_adjacency(
     const Eigen::PlainObjectBase<DerivedF>& F,
     Eigen::PlainObjectBase<DerivedTT>& TT,
     Eigen::PlainObjectBase<DerivedTTi>& TTi);
-
-
   // Preprocessing
-  template <typename Scalar, typename Index>
-  IGL_INLINE void triangle_triangle_adjacency_preprocess(
-    const Eigen::PlainObjectBase<Scalar>& V,
-    const Eigen::PlainObjectBase<Index>& F,
-    std::vector<std::vector<int> >& TTT);
-  template <typename DerivedF>
+  template <typename DerivedF, typename TTT_type>
   IGL_INLINE void triangle_triangle_adjacency_preprocess(
     const Eigen::PlainObjectBase<DerivedF>& F,
-    std::vector<std::vector<int> >& TTT);
+    std::vector<std::vector<TTT_type> >& TTT);
   // Extract the face adjacencies
-  template <typename DerivedF, typename DerivedTT>
+  template <typename DerivedF, typename TTT_type, typename DerivedTT>
   IGL_INLINE void triangle_triangle_adjacency_extractTT(
     const Eigen::PlainObjectBase<DerivedF>& F,
-    std::vector<std::vector<int> >& TTT,
+    std::vector<std::vector<TTT_type> >& TTT,
     Eigen::PlainObjectBase<DerivedTT>& TT);
   // Extract the face adjacencies indices (needed for fast traversal)
-  template <typename DerivedF, typename DerivedTTi>
+  template <typename DerivedF, typename TTT_type, typename DerivedTTi>
   IGL_INLINE void triangle_triangle_adjacency_extractTTi(
     const Eigen::PlainObjectBase<DerivedF>& F,
-    std::vector<std::vector<int> >& TTT,
+    std::vector<std::vector<TTT_type> >& TTT,
     Eigen::PlainObjectBase<DerivedTTi>& TTi);
   // Adjacency list version, which works with non-manifold meshes
   //
   // Inputs:
   //   F  #F by 3 list of triangle indices
   // Outputs:
-  //   TT  #F by 3 list of lists so that TT[i][c] --> {j,k,...} means that faces j and
-  //     k etc. are edge-neighbors of face i on face i's edge opposite corner c
+  //   TT  #F by 3 list of lists so that TT[i][c] --> {j,k,...} means that
+  //     faces j and k etc. are edge-neighbors of face i on face i's edge
+  //     opposite corner c
   //   TTj  #F list of lists so that TTj[i][c] --> {j,k,...} means that face
   //     TT[i][c][0] is an edge-neighbor of face i incident on the edge of face
   //     TT[i][c][0] opposite corner j, and TT[i][c][1] " corner k, etc.