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

tt -> triangle_triangle_adjacency

Former-commit-id: 0f62ba127b5f598c2647f8a491ee3390d25717c9
Daniele Panozzo 11 жил өмнө
parent
commit
8f57abacbc

+ 2 - 2
include/igl/boundary_vertices_sorted.cpp

@@ -7,7 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "boundary_vertices_sorted.h"
 
-#include "tt.h"
+#include "triangle_triangle_adjacency.h"
 #include "vf.h"
 
 IGL_INLINE void igl::boundary_vertices_sorted(
@@ -25,7 +25,7 @@ IGL_INLINE void igl::boundary_vertices_sorted(
   assert(is_manifold(V,F) && "Mesh must be manifold");
   Eigen::MatrixXi TT,TTi;
   std::vector<std::vector<int> > VF, VFi;
-  igl::tt(V,F,TT,TTi);
+  igl::triangle_triangle_adjacency(V,F,TT,TTi);
   igl::vf(V,F,VF,VFi);
 
   // Extract one boundary edge

+ 26 - 26
include/igl/comb_cross_field.cpp

@@ -14,34 +14,34 @@
 #include "is_border_vertex.h"
 #include "rotation_matrix_from_directions.h"
 
-#include "tt.h"
+#include "triangle_triangle_adjacency.h"
 
 namespace igl {
   template <typename DerivedV, typename DerivedF>
   class Comb
   {
   public:
-    
+
     const Eigen::PlainObjectBase<DerivedV> &V;
     const Eigen::PlainObjectBase<DerivedF> &F;
     const Eigen::PlainObjectBase<DerivedV> &PD1;
     const Eigen::PlainObjectBase<DerivedV> &PD2;
     Eigen::PlainObjectBase<DerivedV> N;
-    
+
   private:
     // internal
     Eigen::PlainObjectBase<DerivedF> TT;
     Eigen::PlainObjectBase<DerivedF> TTi;
-    
-    
+
+
   private:
-    
-    
+
+
     static inline double Sign(double a){return (double)((a>0)?+1:-1);}
-    
-    
+
+
   private:
-    
+
     // returns the 90 deg rotation of a (around n) most similar to target b
     /// a and b should be in the same plane orthogonal to N
     static inline Eigen::Matrix<typename DerivedV::Scalar, 3, 1> K_PI_new(const Eigen::Matrix<typename DerivedV::Scalar, 3, 1>& a,
@@ -56,9 +56,9 @@ namespace igl {
       else
         return c*Sign(scorec);
     }
-    
- 
-    
+
+
+
   public:
     inline Comb(const Eigen::PlainObjectBase<DerivedV> &_V,
          const Eigen::PlainObjectBase<DerivedF> &_F,
@@ -71,7 +71,7 @@ namespace igl {
     PD2(_PD2)
     {
       igl::per_face_normals(V,F,N);
-      igl::tt(V,F,TT,TTi);
+      igl::triangle_triangle_adjacency(V,F,TT,TTi);
     }
     inline void comb(Eigen::PlainObjectBase<DerivedV> &PD1out,
               Eigen::PlainObjectBase<DerivedV> &PD2out)
@@ -80,14 +80,14 @@ namespace igl {
 //      PD2out = PD2;
       PD1out.setZero(F.rows(),3);PD1out<<PD1;
       PD2out.setZero(F.rows(),3);PD2out<<PD2;
-      
+
       Eigen::VectorXi mark = Eigen::VectorXi::Constant(F.rows(),false);
-      
+
       std::deque<int> d;
-      
+
       d.push_back(0);
       mark(0) = true;
-      
+
       while (!d.empty())
       {
         int f0 = d.at(0);
@@ -97,35 +97,35 @@ namespace igl {
           int f1 = TT(f0,k);
           if (f1==-1) continue;
           if (mark(f1)) continue;
-          
+
           Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0    = PD1out.row(f0);
           Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1    = PD1out.row(f1);
           Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n0    = N.row(f0);
           Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n1    = N.row(f1);
 
-          
+
           Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0Rot = igl::rotation_matrix_from_directions(n0, n1)*dir0;
           dir0Rot.normalize();
           Eigen::Matrix<typename DerivedV::Scalar, 3, 1> targD   = K_PI_new(dir1,dir0Rot,n1);
-          
+
           PD1out.row(f1)  = targD;
           PD2out.row(f1)  = n1.cross(targD).normalized();
-          
+
           mark(f1) = true;
           d.push_back(f1);
 
         }
       }
-      
+
       // everything should be marked
       for (int i=0; i<F.rows(); i++)
       {
         assert(mark(i));
       }
     }
-    
-    
-    
+
+
+
   };
 }
 template <typename DerivedV, typename DerivedF>

+ 22 - 23
include/igl/cross_field_missmatch.cpp

@@ -14,7 +14,7 @@
 #include "per_face_normals.h"
 #include "is_border_vertex.h"
 #include "vf.h"
-#include "tt.h"
+#include "triangle_triangle_adjacency.h"
 #include "rotation_matrix_from_directions.h"
 
 namespace igl {
@@ -22,13 +22,13 @@ namespace igl {
   class MissMatchCalculator
   {
   public:
-    
+
     const Eigen::PlainObjectBase<DerivedV> &V;
     const Eigen::PlainObjectBase<DerivedF> &F;
     const Eigen::PlainObjectBase<DerivedV> &PD1;
     const Eigen::PlainObjectBase<DerivedV> &PD2;
     Eigen::PlainObjectBase<DerivedV> N;
-    
+
   private:
     // internal
     std::vector<bool> V_border; // bool
@@ -36,10 +36,10 @@ namespace igl {
     std::vector<std::vector<int> > VFi;
     Eigen::PlainObjectBase<DerivedF> TT;
     Eigen::PlainObjectBase<DerivedF> TTi;
-    
-    
+
+
   private:
-    
+
     // Alec: Not compiling... Handle_MMatch not declared.
     /////return true if a vertex is singluar by looking at initialized missmatches
     //// possible bugs, verify deleted flag vs IsD()
@@ -50,7 +50,7 @@ namespace igl {
     //  ///check that is on border..
     //  if (V_border[vid])
     //    return 0;
-    //  
+    //
     //  int missmatch=0;
     //  for (unsigned int i=0;i<VF[vid].size();i++)
     //  {
@@ -60,15 +60,15 @@ namespace igl {
     //      if (F(VF[vid][i],z) == vid)
     //        j=z;
     //    assert(j!=-1);
-    //    
+    //
     //    missmatch+=Handle_MMatch(VF[vid][i],j);
     //  }
-    //  
+    //
     //  missmatch=missmatch%4;
     //  return missmatch;
     //}
-    
-    
+
+
     ///compute the mismatch between 2 faces
     inline int MissMatchByCross(const int f0,
                          const int f1)
@@ -77,21 +77,21 @@ namespace igl {
       Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1 = PD1.row(f1);
       Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n0 = N.row(f0);
       Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n1 = N.row(f1);
-      
+
       Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1Rot = igl::rotation_matrix_from_directions(n1,n0)*dir1;
       dir1Rot.normalize();
-      
+
       // TODO: this should be equivalent to the other code below, to check!
       // Compute the angle between the two vectors
       //    double a0 = atan2(dir0.dot(B2.row(f0)),dir0.dot(B1.row(f0)));
       //    double a1 = atan2(dir1Rot.dot(B2.row(f0)),dir1Rot.dot(B1.row(f0)));
       //
       //    double angle_diff = a1-a0;   //VectToAngle(f0,dir1Rot);
-      
+
       double angle_diff = atan2(dir1Rot.dot(PD2.row(f0)),dir1Rot.dot(PD1.row(f0)));
-      
+
       //    std::cerr << "Dani: " << dir0(0) << " " << dir0(1) << " " << dir0(2) << " " << dir1Rot(0) << " " << dir1Rot(1) << " " << dir1Rot(2) << " " << angle_diff << std::endl;
-      
+
       double step=M_PI/2.0;
       int i=(int)floor((angle_diff/step)+0.5);
       int k=0;
@@ -101,8 +101,8 @@ namespace igl {
         k=(-(3*i))%4;
       return k;
     }
-    
-    
+
+
 public:
   inline MissMatchCalculator(const Eigen::PlainObjectBase<DerivedV> &_V,
                       const Eigen::PlainObjectBase<DerivedF> &_F,
@@ -117,9 +117,9 @@ public:
     igl::per_face_normals(V,F,N);
     V_border = igl::is_border_vertex(V,F);
     igl::vf(V,F,VF,VFi);
-    igl::tt(V,F,TT,TTi);
+    igl::triangle_triangle_adjacency(V,F,TT,TTi);
   }
-  
+
   inline void calculateMissmatch(Eigen::PlainObjectBase<DerivedO> &Handle_MMatch)
   {
     Handle_MMatch.setConstant(F.rows(),3,-1);
@@ -134,7 +134,7 @@ public:
       }
     }
   }
-  
+
 };
 }
 template <typename DerivedV, typename DerivedF, typename DerivedO>
@@ -147,7 +147,7 @@ IGL_INLINE void igl::cross_field_missmatch(const Eigen::PlainObjectBase<DerivedV
 {
   Eigen::PlainObjectBase<DerivedV> PD1_combed;
   Eigen::PlainObjectBase<DerivedV> PD2_combed;
-  
+
   if (!isCombed)
     igl::comb_cross_field(V,F,PD1,PD2,PD1_combed,PD2_combed);
   else
@@ -162,4 +162,3 @@ IGL_INLINE void igl::cross_field_missmatch(const Eigen::PlainObjectBase<DerivedV
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
 #endif
-

+ 0 - 1
include/igl/frame_field_deformer.cpp

@@ -14,7 +14,6 @@
 #include <igl/cotangent.h>
 #include <igl/cotmatrix.h>
 #include <igl/vf.h>
-#include <igl/tt.h>
 
 namespace igl
 {

+ 7 - 7
include/igl/is_border_vertex.cpp

@@ -1,24 +1,24 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "is_border_vertex.h"
 #include <vector>
 
-#include "tt.h"
+#include "triangle_triangle_adjacency.h"
 
 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::PlainObjectBase<DerivedF> FF;
-  igl::tt(V,F,FF);
+  igl::triangle_triangle_adjacency(V,F,FF);
   std::vector<bool> ret(V.rows());
   for(unsigned i=0; i<ret.size();++i)
     ret[i] = false;
-  
+
   for(unsigned i=0; i<F.rows();++i)
     for(unsigned j=0;j<F.cols();++j)
       if(FF(i,j) == -1)

+ 25 - 25
include/igl/tt.cpp → include/igl/triangle_triangle_adjacency.cpp

@@ -1,24 +1,24 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
-#include "tt.h"
+#include "triangle_triangle_adjacency.h"
 
-#include "is_manifold.h"
+#include <igl/is_manifold.h>
 #include <algorithm>
 
 template <typename Scalar, typename Index>
-IGL_INLINE void igl::tt_preprocess(const Eigen::PlainObjectBase<Scalar>& /*V*/,
+IGL_INLINE void igl::triangle_triangle_adjacency_preprocess(const Eigen::PlainObjectBase<Scalar>& /*V*/,
                                    const Eigen::PlainObjectBase<Index>& F,
                                    std::vector<std::vector<int> >& TTT)
 {
   for(int f=0;f<F.rows();++f)
     for (int i=0;i<F.cols();++i)
     {
-      // v1 v2 f ei 
+      // v1 v2 f ei
       int v1 = F(f,i);
       int v2 = F(f,(i+1)%F.cols());
       if (v1 > v2) std::swap(v1,v2);
@@ -32,12 +32,12 @@ IGL_INLINE void igl::tt_preprocess(const Eigen::PlainObjectBase<Scalar>& /*V*/,
 
 // Extract the face adjacencies
 template <typename Index>
-IGL_INLINE void igl::tt_extractTT(const Eigen::PlainObjectBase<Index>& F,
+IGL_INLINE void igl::triangle_triangle_adjacency_extractTT(const Eigen::PlainObjectBase<Index>& F,
                                   std::vector<std::vector<int> >& TTT,
                                   Eigen::PlainObjectBase<Index>& TT)
 {
   TT = Eigen::PlainObjectBase<Index>::Constant((int)(F.rows()),F.cols(),-1);
-  
+
   for(int i=1;i<(int)TTT.size();++i)
   {
     std::vector<int>& r1 = TTT[i-1];
@@ -52,12 +52,12 @@ IGL_INLINE void igl::tt_extractTT(const Eigen::PlainObjectBase<Index>& F,
 
 // Extract the face adjacencies indices (needed for fast traversal)
 template <typename Index>
-IGL_INLINE void igl::tt_extractTTi(const Eigen::PlainObjectBase<Index>& F,
+IGL_INLINE void igl::triangle_triangle_adjacency_extractTTi(const Eigen::PlainObjectBase<Index>& F,
                                    std::vector<std::vector<int> >& TTT,
                                    Eigen::PlainObjectBase<Index>& TTi)
 {
   TTi = Eigen::PlainObjectBase<Index>::Constant((int)(F.rows()),F.cols(),-1);
-  
+
   for(int i=1;i<(int)TTT.size();++i)
   {
     std::vector<int>& r1 = TTT[i-1];
@@ -72,36 +72,36 @@ IGL_INLINE void igl::tt_extractTTi(const Eigen::PlainObjectBase<Index>& F,
 
 // Compute triangle-triangle adjacency
 template <typename Scalar, typename Index>
-IGL_INLINE void igl::tt(const Eigen::PlainObjectBase<Scalar>& V,
+IGL_INLINE void igl::triangle_triangle_adjacency(const Eigen::PlainObjectBase<Scalar>& V,
                         const Eigen::PlainObjectBase<Index>& F,
                         Eigen::PlainObjectBase<Index>& TT)
 {
   //assert(igl::is_manifold(V,F));
   std::vector<std::vector<int> > TTT;
-  
-  tt_preprocess(V,F,TTT);
-  tt_extractTT(F,TTT,TT);
+
+  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::tt(const Eigen::PlainObjectBase<Scalar>& V,
+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_manifold(V,F));
   std::vector<std::vector<int> > TTT;
-  
-  tt_preprocess(V,F,TTT);
-  tt_extractTT(F,TTT,TT);
-  tt_extractTTi(F,TTT,TTi);
+
+  triangle_triangle_adjacency_preprocess(V,F,TTT);
+  triangle_triangle_adjacency_extractTT(F,TTT,TT);
+  triangle_triangle_adjacency_extractTTi(F,TTT,TTi);
 }
 
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
-template void igl::tt<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> >&);
 // generated by autoexplicit.sh
-template void igl::tt<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::tt<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> >&);
+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> >&);
 #endif

+ 18 - 20
include/igl/tt.h → include/igl/triangle_triangle_adjacency.h

@@ -1,21 +1,19 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_TT_H
-#define IGL_TT_H
-#include "igl_inline.h"
-
+#ifndef IGL_TRIANGLE_TRIANGLE_ADJACENCY_H
+#define IGL_TRIANGLE_TRIANGLE_ADJACENCY_H
+#include <igl/igl_inline.h>
 #include <Eigen/Core>
-
 #include <vector>
 
-namespace igl 
+namespace igl
 {
-  // Constructs the triangle adjacency matrix for a given
+  // Constructs the triangle-triangle adjacency matrix for a given
   // mesh (V,F).
   //
   // Templates:
@@ -30,39 +28,39 @@ namespace igl
   //   TT   #F by #3 adjacent matrix, the element i,j is the id of the triangle adjacent to the j edge of triangle i
   //   TTi  #F by #3 adjacent matrix, the element i,j is the id of edge of the triangle TT(i,j) that is adjacent with triangle i
   // NOTE: the first edge of a triangle is [0,1] the second [1,2] and the third [2,3].
-  //       this convention is DIFFERENT from cotangent.h
+  //       this convention is DIFFERENT from cotmatrix_entries.h
 
   template <typename Scalar, typename Index>
-  IGL_INLINE void tt(const Eigen::PlainObjectBase<Scalar>& V,
+  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 tt(const Eigen::PlainObjectBase<Scalar>& V,
+  IGL_INLINE void triangle_triangle_adjacency(const Eigen::PlainObjectBase<Scalar>& V,
                      const Eigen::PlainObjectBase<Index>& F,
                      Eigen::PlainObjectBase<Index>& TT,
                      Eigen::PlainObjectBase<Index>& TTi);
 
-  
+
   // Preprocessing
   template <typename Scalar, typename Index>
-  IGL_INLINE void tt_preprocess(const Eigen::PlainObjectBase<Scalar>& V,
+  IGL_INLINE void 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 Index>
-  IGL_INLINE void tt_extractTT(const Eigen::PlainObjectBase<Index>& F,
+  IGL_INLINE void triangle_triangle_adjacency_extractTT(const Eigen::PlainObjectBase<Index>& F,
                                std::vector<std::vector<int> >& TTT,
                                Eigen::PlainObjectBase<Index>& TT);
   // Extract the face adjacencies indices (needed for fast traversal)
   template <typename Index>
-  IGL_INLINE void tt_extractTTi(const Eigen::PlainObjectBase<Index>& F,
+  IGL_INLINE void triangle_triangle_adjacency_extractTTi(const Eigen::PlainObjectBase<Index>& F,
                                 std::vector<std::vector<int> >& TTT,
                                 Eigen::PlainObjectBase<Index>& TTi);
 }
 
 #ifdef IGL_HEADER_ONLY
-#  include "tt.cpp"
+#  include "triangle_triangle_adjacency.cpp"
 #endif
 
 #endif

+ 15 - 24
include/igl/upsample.cpp

@@ -1,23 +1,18 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "upsample.h"
 
-#include "tt.h"
-
-//// Bug in unsupported/Eigen/SparseExtra needs iostream first
-//#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
-//#include <iostream>
-//#include <unsupported/Eigen/SparseExtra>
+#include "triangle_triangle_adjacency.h"
 
 #include <Eigen/Dense>
 
 template <
-  typename DerivedV, 
+  typename DerivedV,
   typename DerivedF,
   typename DerivedNV,
   typename DerivedNF>
@@ -34,19 +29,15 @@ IGL_INLINE void igl::upsample(
   using namespace std;
   using namespace Eigen;
 
-  ////typedef Eigen::PlainObjectBase<DerivedF> MatF;
-  ////typedef Eigen::PlainObjectBase<DerivedNF> MatNF;
-  ////typedef Eigen::PlainObjectBase<DerivedNV> MatNV;
-  ////MatF FF, FFi;
   Eigen::MatrixXi FF,FFi;
-  tt(V,F,FF,FFi);
+  triangle_triangle_adjacency(V,F,FF,FFi);
 
   // TODO: Cache optimization missing from here, it is a mess
-  
+
   // Compute the number and positions of the vertices to insert (on edges)
   Eigen::MatrixXi NI = Eigen::MatrixXi::Constant(FF.rows(),FF.cols(),-1);
   int counter = 0;
-  
+
   for(int i=0;i<FF.rows();++i)
   {
     for(int j=0;j<3;++j)
@@ -67,11 +58,11 @@ IGL_INLINE void igl::upsample(
   // Not sure what this is
   //Eigen::DynamicSparseMatrix<double> SUBD(V.rows()+n_even,V.rows());
   //SUBD.reserve(15 * (V.rows()+n_even));
-  
+
   // Preallocate NV and NF
   NV.resize(V.rows()+n_even,V.cols());
   NF.resize(F.rows()*4,3);
-  
+
   // Fill the odd vertices position
   NV.block(0,0,V.rows(),V.cols()) = V;
 
@@ -89,23 +80,23 @@ IGL_INLINE void igl::upsample(
   {
     VectorXi VI(6);
     VI << F(i,0), F(i,1), F(i,2), NI(i,0) + n_odd, NI(i,1) + n_odd, NI(i,2) + n_odd;
-    
+
     VectorXi f0(3), f1(3), f2(3), f3(3);
     f0 << VI(0), VI(3), VI(5);
     f1 << VI(1), VI(4), VI(3);
     f2 << VI(3), VI(4), VI(5);
     f3 << VI(4), VI(2), VI(5);
-    
+
     NF.row((i*4)+0) = f0;
     NF.row((i*4)+1) = f1;
     NF.row((i*4)+2) = f2;
     NF.row((i*4)+3) = f3;
   }
-  
+
 }
 
 template <
-  typename MatV, 
+  typename MatV,
   typename MatF>
 IGL_INLINE void igl::upsample(
   MatV& V,