Browse Source

clean up all around

Former-commit-id: 58beb88a84af651ee1cada12dd25c17ed1d68960
jalec 13 years ago
parent
commit
c66820d5e3
57 changed files with 574 additions and 432 deletions
  1. 2 2
      EPS.h
  2. 2 2
      ONE.h
  3. 3 0
      ReAntTweakBar.h
  4. 2 2
      Timer.h
  5. 2 2
      ZERO.h
  6. 15 17
      adjacency_list.h
  7. 2 2
      all_pairs_distances.h
  8. 8 8
      cat.h
  9. 6 1
      cocoa_key_to_anttweakbar_key.h
  10. 2 2
      cotangent.h
  11. 78 65
      edgetopology.h
  12. 2 2
      faces_first.h
  13. 2 2
      file_contents_as_string.h
  14. 2 1
      get_seconds.h
  15. 12 11
      get_seconds_hires.h
  16. 4 3
      gl_type_size.h
  17. 10 8
      grad.h
  18. 25 21
      is_border_vertex.h
  19. 15 5
      is_manifold.h
  20. 2 2
      limit_faces.h
  21. 2 2
      list_to_matrix.h
  22. 2 1
      load_shader.h
  23. 2 0
      mat_max.h
  24. 1 0
      mat_min.h
  25. 3 0
      material_colors.h
  26. 4 4
      matlabinterface.h
  27. 1 1
      max_size.h
  28. 83 76
      min_quad_dense.h
  29. 1 1
      min_size.h
  30. 2 2
      mode.h
  31. 4 2
      moveFV.h
  32. 3 3
      mvc.h
  33. 2 0
      normalize_rows.h
  34. 3 3
      orth.h
  35. 40 30
      plot_vector.h
  36. 2 4
      pos.h
  37. 4 3
      print_gl_get.h
  38. 2 2
      print_program_info_log.h
  39. 2 2
      print_shader_info_log.h
  40. 3 0
      quat_to_mat.h
  41. 25 2
      readme.txt
  42. 4 4
      removeDuplicates.h
  43. 2 2
      removeUnreferenced.h
  44. 8 1
      report_gl_error.h
  45. 4 4
      rows_to_matrix.h
  46. 11 10
      sort.h
  47. 2 0
      speye.h
  48. 1 1
      stdin_to_temp.h
  49. 2 0
      sum.h
  50. 2 2
      texture_from_tga.h
  51. 3 0
      tga.h
  52. 5 0
      todos.txt
  53. 3 0
      trackball.h
  54. 80 66
      tt.h
  55. 4 4
      upsample.h
  56. 29 18
      write.h
  57. 27 24
      writeOFF.h

+ 2 - 2
EPS.h

@@ -1,5 +1,5 @@
-#ifndef EPS_H
-#define EPS_H
+#ifndef IGL_EPS_H
+#define IGL_EPS_H
 // Define a standard value for double epsilon
 // Define a standard value for double epsilon
 namespace igl
 namespace igl
 {
 {

+ 2 - 2
ONE.h

@@ -1,5 +1,5 @@
-#ifndef ONE_H
-#define ONE_H
+#ifndef IGL_ONE_H
+#define IGL_ONE_H
 // Often one needs a reference to a dummy variable containing zero as its
 // Often one needs a reference to a dummy variable containing zero as its
 // value, for example when using AntTweakBar's
 // value, for example when using AntTweakBar's
 // TwSetParam( "3D View", "opened", TW_PARAM_INT32, 1, &INT_ONE);
 // TwSetParam( "3D View", "opened", TW_PARAM_INT32, 1, &INT_ONE);

+ 3 - 0
ReAntTweakBar.h

@@ -1,3 +1,5 @@
+#ifndef IGL_REANTTWEAKBAR_H
+#define IGL_REANTTWEAKBAR_H
 // ReAntTweakBar is a minimal wrapper for the AntTweakBar library that allows
 // ReAntTweakBar is a minimal wrapper for the AntTweakBar library that allows
 // "bars" to be saved and load from disk. Changing your existing app that users
 // "bars" to be saved and load from disk. Changing your existing app that users
 // AntTweakBar to use ReAntTweakBar is trivial.
 // AntTweakBar to use ReAntTweakBar is trivial.
@@ -865,3 +867,4 @@ bool igl::ReTwBar::set_value_from_string(
   }
   }
   return true;
   return true;
 }
 }
+#endif

+ 2 - 2
Timer.h

@@ -12,8 +12,8 @@
 // Copyright (c) 2003 Song Ho Ahn
 // Copyright (c) 2003 Song Ho Ahn
 //////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////
 
 
-#ifndef TIMER_H_DEF
-#define TIMER_H_DEF
+#ifndef IGL_TIMER_H
+#define IGL_TIMER_H
 
 
 #ifdef WIN32   // Windows system specific
 #ifdef WIN32   // Windows system specific
 #include <windows.h>
 #include <windows.h>

+ 2 - 2
ZERO.h

@@ -1,5 +1,5 @@
-#ifndef ZERO_H
-#define ZERO_H
+#ifndef IGL_ZERO_H
+#define IGL_ZERO_H
 // Often one needs a reference to a dummy variable containing zero as its
 // Often one needs a reference to a dummy variable containing zero as its
 // value, for example when using AntTweakBar's
 // value, for example when using AntTweakBar's
 // TwSetParam( "3D View", "opened", TW_PARAM_INT32, 1, &INT_ZERO);
 // TwSetParam( "3D View", "opened", TW_PARAM_INT32, 1, &INT_ZERO);

+ 15 - 17
adjacency_list.h

@@ -24,10 +24,9 @@ namespace igl
   // See also: edges, cotmatrix, diag
   // See also: edges, cotmatrix, diag
   template <typename T, typename M>
   template <typename T, typename M>
   inline void adjacency_list(
   inline void adjacency_list(
-                             const M & F, 
-                             std::vector<std::vector<T> >& A,
-                             bool sorted = false
-                             );
+    const M & F, 
+    std::vector<std::vector<T> >& A,
+    bool sorted = false);
 }
 }
 
 
 // Implementation
 // Implementation
@@ -35,10 +34,9 @@ namespace igl
 
 
 template <typename T, typename M>
 template <typename T, typename M>
 inline void igl::adjacency_list(
 inline void igl::adjacency_list(
-                                const M & F, 
-                                std::vector<std::vector<T> >& A,
-                                bool sorted 
-                                )
+    const M & F, 
+    std::vector<std::vector<T> >& A,
+    bool sorted)
 {
 {
   A.clear(); 
   A.clear(); 
   A.resize(F.maxCoeff()+1);
   A.resize(F.maxCoeff()+1);
@@ -67,14 +65,14 @@ inline void igl::adjacency_list(
   // If needed, sort every VV
   // If needed, sort every VV
   if (sorted)
   if (sorted)
   {
   {
-	  // Loop over faces
-	  
-	  // for every vertex v store a set of ordered edges not incident to v that belongs to triangle incident on v.
+    // Loop over faces
+    
+    // for every vertex v store a set of ordered edges not incident to v that belongs to triangle incident on v.
     std::vector<std::vector<std::vector<int> > > SR; 
     std::vector<std::vector<std::vector<int> > > SR; 
-	  SR.resize(A.size());
-	  
-	  for(int i = 0;i<F.rows();i++)
-	  {
+    SR.resize(A.size());
+    
+    for(int i = 0;i<F.rows();i++)
+    {
       // Loop over this face
       // Loop over this face
       for(int j = 0;j<F.cols();j++)
       for(int j = 0;j<F.cols();j++)
       {
       {
@@ -89,8 +87,8 @@ inline void igl::adjacency_list(
         e[1] = v;
         e[1] = v;
         SR[s].push_back(e);
         SR[s].push_back(e);
       }
       }
-	  }
-	  
+    }
+    
     for(int v=0; v<(int)SR.size();++v)
     for(int v=0; v<(int)SR.size();++v)
     {
     {
       std::vector<int>& vv = A.at(v);
       std::vector<int>& vv = A.at(v);

+ 2 - 2
all_pairs_distances.h

@@ -19,7 +19,7 @@ namespace igl
   //     squareed distance between V(i,:) and U(j,:)
   //     squareed distance between V(i,:) and U(j,:)
   // 
   // 
   template <typename Mat>
   template <typename Mat>
-  void all_pairs_distances(
+  inline void all_pairs_distances(
     const Mat & V,
     const Mat & V,
     const Mat & U,
     const Mat & U,
     const bool squared, 
     const bool squared, 
@@ -29,7 +29,7 @@ namespace igl
 // Implementation
 // Implementation
 
 
 template <typename Mat>
 template <typename Mat>
-void igl::all_pairs_distances(
+inline void igl::all_pairs_distances(
   const Mat & V,
   const Mat & V,
   const Mat & U,
   const Mat & U,
   const bool squared,
   const bool squared,

+ 8 - 8
cat.h

@@ -27,20 +27,20 @@ namespace igl
   //   C  output matrix
   //   C  output matrix
   //   
   //   
   template <typename Scalar>
   template <typename Scalar>
-  void cat(
+  inline void cat(
       const int dim, 
       const int dim, 
       const Eigen::SparseMatrix<Scalar> & A, 
       const Eigen::SparseMatrix<Scalar> & A, 
       const Eigen::SparseMatrix<Scalar> & B, 
       const Eigen::SparseMatrix<Scalar> & B, 
       Eigen::SparseMatrix<Scalar> & C);
       Eigen::SparseMatrix<Scalar> & C);
   template <typename Derived, class MatC>
   template <typename Derived, class MatC>
-  void cat(
+  inline void cat(
     const int dim,
     const int dim,
     const Eigen::MatrixBase<Derived> & A, 
     const Eigen::MatrixBase<Derived> & A, 
     const Eigen::MatrixBase<Derived> & B,
     const Eigen::MatrixBase<Derived> & B,
     MatC & C);
     MatC & C);
   // Wrapper that returns C
   // Wrapper that returns C
   template <class Mat>
   template <class Mat>
-  Mat cat(const int dim, const Mat & A, const Mat & B);
+  inline Mat cat(const int dim, const Mat & A, const Mat & B);
 
 
   // Note: Maybe we can autogenerate a bunch of overloads D = cat(int,A,B,C),
   // Note: Maybe we can autogenerate a bunch of overloads D = cat(int,A,B,C),
   // E = cat(int,A,B,C,D), etc. 
   // E = cat(int,A,B,C,D), etc. 
@@ -53,7 +53,7 @@ namespace igl
   // Output:
   // Output:
   //   C
   //   C
   template <class Mat>
   template <class Mat>
-    void cat(const std::vector<std::vector< Mat > > & A, Mat & C);
+  inline void cat(const std::vector<std::vector< Mat > > & A, Mat & C);
 }
 }
 
 
 // Implementation
 // Implementation
@@ -62,7 +62,7 @@ namespace igl
 // Template:
 // Template:
 //   Scalar  sparse matrix scalar type, e.g. double
 //   Scalar  sparse matrix scalar type, e.g. double
 template <typename Scalar>
 template <typename Scalar>
-void igl::cat(
+inline void igl::cat(
     const int dim, 
     const int dim, 
     const Eigen::SparseMatrix<Scalar> & A, 
     const Eigen::SparseMatrix<Scalar> & A, 
     const Eigen::SparseMatrix<Scalar> & B, 
     const Eigen::SparseMatrix<Scalar> & B, 
@@ -124,7 +124,7 @@ void igl::cat(
 }
 }
 
 
 template <typename Derived, class MatC>
 template <typename Derived, class MatC>
-void igl::cat(
+inline void igl::cat(
   const int dim,
   const int dim,
   const Eigen::MatrixBase<Derived> & A, 
   const Eigen::MatrixBase<Derived> & A, 
   const Eigen::MatrixBase<Derived> & B,
   const Eigen::MatrixBase<Derived> & B,
@@ -160,7 +160,7 @@ void igl::cat(
 }
 }
 
 
 template <class Mat>
 template <class Mat>
-Mat igl::cat(const int dim, const Mat & A, const Mat & B)
+inline Mat igl::cat(const int dim, const Mat & A, const Mat & B)
 {
 {
   assert(dim == 1 || dim == 2);
   assert(dim == 1 || dim == 2);
   Mat C;
   Mat C;
@@ -169,7 +169,7 @@ Mat igl::cat(const int dim, const Mat & A, const Mat & B)
 }
 }
 
 
 template <class Mat>
 template <class Mat>
-void cat(const std::vector<std::vector< Mat > > & A, Mat & C)
+inline void cat(const std::vector<std::vector< Mat > > & A, Mat & C)
 {
 {
   using namespace igl;
   using namespace igl;
   using namespace std;
   using namespace std;

+ 6 - 1
cocoa_key_to_anttweakbar_key.h

@@ -1,4 +1,6 @@
-#include <AntTweakBar.h>
+#ifndef IGL_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H
+#define IGL_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H
+
 
 
 namespace igl
 namespace igl
 {
 {
@@ -12,6 +14,8 @@ namespace igl
 }
 }
 
 
 // Implementation
 // Implementation
+#include <AntTweakBar.h>
+
 inline int igl::cocoa_key_to_anttweakbar_key(int key)
 inline int igl::cocoa_key_to_anttweakbar_key(int key)
 {
 {
   // I've left commented the AntTweakBar key codes that correspond to keys I
   // I've left commented the AntTweakBar key codes that correspond to keys I
@@ -80,3 +84,4 @@ inline int igl::cocoa_key_to_anttweakbar_key(int key)
   }
   }
   return key;
   return key;
 }
 }
+#endif

+ 2 - 2
cotangent.h

@@ -16,7 +16,7 @@ namespace igl
   //     for triangles, columns correspond to edges 23,31,12
   //     for triangles, columns correspond to edges 23,31,12
   //     for tets, columns correspond to edges 23,31,12,41,42,43
   //     for tets, columns correspond to edges 23,31,12,41,42,43
   template <class MatV, class MatF, class MatC>
   template <class MatV, class MatF, class MatC>
-  void cotangent(const MatV & V, const MatF & F, MatC & C);
+  inline void cotangent(const MatV & V, const MatF & F, MatC & C);
 }
 }
 
 
 // Implementation
 // Implementation
@@ -24,7 +24,7 @@ namespace igl
 #include <Eigen/Dense>
 #include <Eigen/Dense>
 
 
 template <class MatV, class MatF, class MatC>
 template <class MatV, class MatF, class MatC>
-void igl::cotangent(const MatV & V, const MatF & F, MatC & C)
+inline void igl::cotangent(const MatV & V, const MatF & F, MatC & C)
 {
 {
   using namespace igl;
   using namespace igl;
   using namespace std;
   using namespace std;

+ 78 - 65
edgetopology.h

@@ -3,82 +3,95 @@
 //
 //
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 
 
-#ifndef EDGETOPOLOGY_H
-#define EDGETOPOLOGY_H
+#ifndef IGL_EDGETOPOLOGY_H
+#define IGL_EDGETOPOLOGY_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <string>
 #include <string>
-#include <ismanifold.h>
 
 
 #include <vector>
 #include <vector>
 
 
 namespace igl 
 namespace igl 
 {
 {
-    // Initialize Edges and their topological relations
-    
-    // Output:
-    // EV  : #Ex2, Stores the edge description as pair of indices to vertices
-    // FE : #Fx3, Stores the Triangle-Edge relation
-    // EF : #Ex2: Stores the Edge-Triangle relation (unsorted)
+  // Initialize Edges and their topological relations
+  
+  // Output:
+  // EV  : #Ex2, Stores the edge description as pair of indices to vertices
+  // FE : #Fx3, Stores the Triangle-Edge relation
+  // EF : #Ex2: Stores the Edge-Triangle relation (unsorted)
+  inline void edgetopology(
+    const Eigen::MatrixXd& V, 
+    const Eigen::MatrixXi& F, 
+    const Eigen::MatrixXi& EV, 
+    const Eigen::MatrixXi& FE, 
+    const Eigen::MatrixXi& EF);
+}
+
+// Implementation
+#include <algorithm>
+#include "is_manifold.h"
 
 
-    inline void edgetopology(Eigen::MatrixXd& V, Eigen::MatrixXi& F, 
-                      Eigen::MatrixXi& EV, Eigen::MatrixXi& FE, Eigen::MatrixXi& EF)
+inline void edgetopology(
+  const Eigen::MatrixXd& V, 
+  const Eigen::MatrixXi& F, 
+  const Eigen::MatrixXi& EV, 
+  const Eigen::MatrixXi& FE, 
+  const Eigen::MatrixXi& EF)
+{
+  assert(igl::is_manifold(V,F));
+  std::vector<std::vector<int> > ETT;
+  for(int f=0;f<F.rows();++f)
+    for (int i=0;i<3;++i)
+    {
+      // v1 v2 f vi 
+      int v1 = F(f,i);
+      int v2 = F(f,(i+1)%3);
+      if (v1 > v2) std::swap(v1,v2);
+      std::vector<int> r(4);
+      r[0] = v1; r[1] = v2;
+      r[2] = f;  r[3] = i;
+      ETT.push_back(r);
+    }
+  std::sort(ETT.begin(),ETT.end());
+  
+  // count the number of edges (assume manifoldness)
+  int En = 1; // the last is always counted
+  for(int i=0;i<ETT.size()-1;++i)
+    if (!((ETT[i][0] == ETT[i+1][0]) && (ETT[i][1] == ETT[i+1][1])))
+      ++En;
+  
+  EV  = Eigen::MatrixXi::Constant((int)(En),2,-1);
+  FE = Eigen::MatrixXi::Constant((int)(F.rows()),3,-1);
+  EF = Eigen::MatrixXi::Constant((int)(En),2,-1);
+  En = 0;
+  
+  for(int i=0;i<ETT.size();++i)
+  {
+    if (i == ETT.size()-1 ||
+      !((ETT[i][0] == ETT[i+1][0]) && (ETT[i][1] == ETT[i+1][1]))
+      )
+    {
+      // Border edge
+      std::vector<int>& r1 = ETT[i];
+      EV(En,0)     = r1[0];
+      EV(En,1)     = r1[1];
+      EF(En,0)    = r1[2];
+      FE(r1[2],r1[3]) = En;
+    } 
+    else
     {
     {
-        assert(igl::isManifold(V,F));
-        std::vector<std::vector<int> > ETT;
-        for(int f=0;f<F.rows();++f)
-            for (int i=0;i<3;++i)
-            {
-                // v1 v2 f vi 
-                int v1 = F(f,i);
-                int v2 = F(f,(i+1)%3);
-                if (v1 > v2) std::swap(v1,v2);
-                std::vector<int> r(4);
-                r[0] = v1; r[1] = v2;
-                r[2] = f;  r[3] = i;
-                ETT.push_back(r);
-            }
-        std::sort(ETT.begin(),ETT.end());
-        
-        // count the number of edges (assume manifoldness)
-        int En = 1; // the last is always counted
-        for(int i=0;i<ETT.size()-1;++i)
-            if (!((ETT[i][0] == ETT[i+1][0]) && (ETT[i][1] == ETT[i+1][1])))
-                ++En;
-        
-        EV  = Eigen::MatrixXi::Constant((int)(En),2,-1);
-        FE = Eigen::MatrixXi::Constant((int)(F.rows()),3,-1);
-        EF = Eigen::MatrixXi::Constant((int)(En),2,-1);
-        En = 0;
-        
-        for(int i=0;i<ETT.size();++i)
-        {
-            if (i == ETT.size()-1 ||
-                !((ETT[i][0] == ETT[i+1][0]) && (ETT[i][1] == ETT[i+1][1]))
-                )
-            {
-                // Border edge
-                std::vector<int>& r1 = ETT[i];
-                EV(En,0)         = r1[0];
-                EV(En,1)         = r1[1];
-                EF(En,0)        = r1[2];
-                FE(r1[2],r1[3]) = En;
-            } 
-            else
-            {
-                std::vector<int>& r1 = ETT[i];
-                std::vector<int>& r2 = ETT[i+1];
-                EV(En,0)         = r1[0];
-                EV(En,1)         = r1[1];
-                EF(En,0)        = r1[2];
-                EF(En,1)        = r2[2];
-                FE(r1[2],r1[3]) = En;
-                FE(r2[2],r2[3]) = En;
-                ++i; // skip the next one
-            }
-            ++En;
-        }        
+      std::vector<int>& r1 = ETT[i];
+      std::vector<int>& r2 = ETT[i+1];
+      EV(En,0)     = r1[0];
+      EV(En,1)     = r1[1];
+      EF(En,0)    = r1[2];
+      EF(En,1)    = r2[2];
+      FE(r1[2],r1[3]) = En;
+      FE(r2[2],r2[3]) = En;
+      ++i; // skip the next one
     }
     }
+    ++En;
+  }    
 }
 }
 
 
 #endif
 #endif

+ 2 - 2
faces_first.h

@@ -24,7 +24,7 @@ namespace igl
   //    and RV(IM,:) = V
   //    and RV(IM,:) = V
   //
   //
   template <typename MatV, typename MatF, typename VecI>
   template <typename MatV, typename MatF, typename VecI>
-  void faces_first(
+  inline void faces_first(
     const MatV & V, 
     const MatV & V, 
     const MatF & F, 
     const MatF & F, 
     MatV & RV, 
     MatV & RV, 
@@ -37,7 +37,7 @@ namespace igl
 #include <Eigen/Dense>
 #include <Eigen/Dense>
 
 
 template <typename MatV, typename MatF, typename VecI>
 template <typename MatV, typename MatF, typename VecI>
-void igl::faces_first(
+inline void igl::faces_first(
   const MatV & V, 
   const MatV & V, 
   const MatF & F, 
   const MatF & F, 
   MatV & RV, 
   MatV & RV, 

+ 2 - 2
file_contents_as_string.h

@@ -1,5 +1,5 @@
-#ifndef FILE_CONTENTS_AS_STRING_H
-#define FILE_CONTENTS_AS_STRING_H
+#ifndef IGL_FILE_CONTENTS_AS_STRING_H
+#define IGL_FILE_CONTENTS_AS_STRING_H
 
 
 #include <string>
 #include <string>
 namespace igl
 namespace igl

+ 2 - 1
get_seconds.h

@@ -8,7 +8,8 @@ namespace igl
 
 
 }
 }
 
 
-//Implementation
+// Implementation
+
 #if _WIN32
 #if _WIN32
 #  include <ctime>
 #  include <ctime>
 inline double igl::get_seconds()
 inline double igl::get_seconds()

+ 12 - 11
get_seconds_hires.h

@@ -3,28 +3,29 @@
 
 
 namespace igl
 namespace igl
 {
 {
-	// Return the current time in seconds using performance counters
-	inline double get_seconds_hires();
+  // Return the current time in seconds using performance counters
+  inline double get_seconds_hires();
 }
 }
 
 
-//Implementation
+// Implementation
+
 #if _WIN32
 #if _WIN32
 #  include <windows.h>
 #  include <windows.h>
 inline double igl::get_seconds_hires()
 inline double igl::get_seconds_hires()
 {
 {
-	LARGE_INTEGER li_freq, li_current;
-	const bool ret = QueryPerformanceFrequency(&li_freq);
-	const bool ret2 = QueryPerformanceCounter(&li_current);
-	assert(ret && ret2);
-	assert(li_freq.QuadPart > 0);
-	return double(li_current.QuadPart) / double(li_freq.QuadPart);
+  LARGE_INTEGER li_freq, li_current;
+  const bool ret = QueryPerformanceFrequency(&li_freq);
+  const bool ret2 = QueryPerformanceCounter(&li_current);
+  assert(ret && ret2);
+  assert(li_freq.QuadPart > 0);
+  return double(li_current.QuadPart) / double(li_freq.QuadPart);
 }
 }
 #else
 #else
 #  include "get_seconds.h"
 #  include "get_seconds.h"
 inline double igl::get_seconds_hires()
 inline double igl::get_seconds_hires()
 {
 {
-	// Sorry I've no idea how performance counters work on Mac...
-	return igl::get_seconds();
+  // Sorry I've no idea how performance counters work on Mac...
+  return igl::get_seconds();
 }
 }
 #endif
 #endif
 #endif
 #endif

+ 4 - 3
gl_type_size.h

@@ -18,11 +18,12 @@ namespace igl
   // Inputs:
   // Inputs:
   //   type  enum value of opengl type
   //   type  enum value of opengl type
   // Returns size in bytes of type
   // Returns size in bytes of type
-  inline int gl_type_size(GLenum type);
+  inline int gl_type_size(const GLenum type);
 }
 }
 
 
-//Implementation
-inline int igl::gl_type_size(GLenum type)
+// Implementation
+
+inline int igl::gl_type_size(const GLenum type)
 {
 {
   switch(type)
   switch(type)
   {
   {

+ 10 - 8
grad.h

@@ -6,8 +6,8 @@
 //  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
 //  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
 //
 //
 
 
-#ifndef Preview3D_grad_h
-#define Preview3D_grad_h
+#ifndef IGL_GRAD_H
+#define IGL_GRAD_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 
 
@@ -34,16 +34,18 @@ namespace igl {
   //
   //
   template <typename T>
   template <typename T>
   inline void grad(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
   inline void grad(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
-                   const Eigen::MatrixXi &F,
-                   const Eigen::Matrix<T, Eigen::Dynamic, 1>&X,
-                   Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &G );
+    const Eigen::MatrixXi &F,
+    const Eigen::Matrix<T, Eigen::Dynamic, 1>&X,
+    Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &G );
 }
 }
 
 
+// Implementation
+
 template <typename T>
 template <typename T>
 inline void igl::grad(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
 inline void igl::grad(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
-                 const Eigen::MatrixXi &F,
-                 const Eigen::Matrix<T, Eigen::Dynamic, 1>&X,
-                 Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &G )
+  const Eigen::MatrixXi &F,
+  const Eigen::Matrix<T, Eigen::Dynamic, 1>&X,
+  Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &G )
 {
 {
   G = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>::Zero(F.rows(),3);
   G = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>::Zero(F.rows(),3);
   for (int i = 0; i<F.rows(); ++i)
   for (int i = 0; i<F.rows(); ++i)

+ 25 - 21
is_border_vertex.h

@@ -3,35 +3,39 @@
 //
 //
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 
 
-#ifndef ISBORDERVERTEX_H
-#define ISBORDERVERTEX_H
+#ifndef IGL_IS_BORDER_VERTEX_H
+#define IGL_IS_BORDER_VERTEX_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
-#include <string>
-
 #include <vector>
 #include <vector>
-#include "tt.h"
 
 
 namespace igl 
 namespace igl 
 {
 {
   template<typename T>
   template<typename T>
   inline std::vector<bool> is_border_vertex(const T& V, const Eigen::MatrixXi& F)
   inline std::vector<bool> is_border_vertex(const T& V, const Eigen::MatrixXi& F)
-  {
-    Eigen::MatrixXi FF;
-    igl::tt(V,F,FF);
-    vector<bool> ret(V.rows());
-    for(int i=0; i<ret.size();++i)
-      ret[i] = false;
-    
-    for(int i=0; i<F.rows();++i)
-      for(int j=0;j<F.cols();++j)
-        if(FF(i,j) == -1)
-        {
-          ret[F(i,j)]       = true;
-          ret[F(i,(j+1)%3)] = true;
-        }
-    return ret;
-  }
 }
 }
 
 
+// Implementation
+#include "tt.h"
+
+template<typename T>
+inline std::vector<bool> igl::is_border_vertex(const T& V, const Eigen::MatrixXi& F)
+{
+  Eigen::MatrixXi FF;
+  igl::tt(V,F,FF);
+  vector<bool> ret(V.rows());
+  for(int i=0; i<ret.size();++i)
+    ret[i] = false;
+  
+  for(int i=0; i<F.rows();++i)
+    for(int j=0;j<F.cols();++j)
+      if(FF(i,j) == -1)
+      {
+        ret[F(i,j)]       = true;
+        ret[F(i,(j+1)%3)] = true;
+      }
+  return ret;
+}
+
+
 #endif
 #endif

+ 15 - 5
ismanifold.h → is_manifold.h

@@ -3,19 +3,29 @@
 //
 //
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 
 
-#ifndef ISMANIFOLD_H
-#define ISMANIFOLD_H
+#ifndef IGL_IS_MANIFOLD_H
+#define IGL_IS_MANIFOLD_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
-#include <string>
-
 #include <vector>
 #include <vector>
 
 
 namespace igl 
 namespace igl 
 {
 {
   // check if the mesh is edge-manifold
   // check if the mesh is edge-manifold
+  //
+  // Not clear whether this returns true or false if the mesh is disc topology
+  //
+  // Known Bugs:
+  //  Does not check for non-manifold vertices
   template<typename T>
   template<typename T>
-  inline bool isManifold(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F)
+  inline bool is_manifold(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F);
+}
+
+// Implementation
+#include <algorithm>
+
+template<typename T>
+inline bool igl::is_manifold(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F);
   {
   {
     std::vector<std::vector<int> > TTT;
     std::vector<std::vector<int> > TTT;
     for(int f=0;f<F.rows();++f)
     for(int f=0;f<F.rows();++f)

+ 2 - 2
limit_faces.h

@@ -21,7 +21,7 @@ namespace igl
   //   in  #F list of whether given face was included
   //   in  #F list of whether given face was included
   //
   //
   template <typename MatF, typename VecL>
   template <typename MatF, typename VecL>
-  void limit_faces(
+  inline void limit_faces(
     const MatF & F, 
     const MatF & F, 
     const VecL & L, 
     const VecL & L, 
     const bool exclusive,
     const bool exclusive,
@@ -32,7 +32,7 @@ namespace igl
 #include <vector>
 #include <vector>
 
 
 template <typename MatF, typename VecL>
 template <typename MatF, typename VecL>
-void igl::limit_faces(
+inline void igl::limit_faces(
   const MatF & F, 
   const MatF & F, 
   const VecL & L, 
   const VecL & L, 
   const bool exclusive,
   const bool exclusive,

+ 2 - 2
list_to_matrix.h

@@ -15,7 +15,7 @@ namespace igl
   //   M  an m by n matrix
   //   M  an m by n matrix
   // Returns true on success, false on errors
   // Returns true on success, false on errors
   template <typename T, class Mat>
   template <typename T, class Mat>
-  bool list_to_matrix(const std::vector<std::vector<T > > & V,Mat & M);
+  inline bool list_to_matrix(const std::vector<std::vector<T > > & V,Mat & M);
 }
 }
 
 
 // Implementation
 // Implementation
@@ -28,7 +28,7 @@ namespace igl
 #include "verbose.h"
 #include "verbose.h"
 
 
 template <typename T, class Mat>
 template <typename T, class Mat>
-bool igl::list_to_matrix(const std::vector<std::vector<T > > & V,Mat & M)
+inline bool igl::list_to_matrix(const std::vector<std::vector<T > > & V,Mat & M)
 {
 {
   // number of columns
   // number of columns
   int m = V.size();
   int m = V.size();

+ 2 - 1
load_shader.h

@@ -25,7 +25,8 @@ namespace igl
   inline GLuint load_shader(const char *src,const GLenum type);
   inline GLuint load_shader(const char *src,const GLenum type);
 }
 }
 
 
-// Implmentation
+// Implementation
+
 // Copyright Denis Kovacs 4/10/08
 // Copyright Denis Kovacs 4/10/08
 #include "print_shader_info_log.h"
 #include "print_shader_info_log.h"
 #include <cstdio>
 #include <cstdio>

+ 2 - 0
mat_max.h

@@ -29,6 +29,8 @@ namespace igl
     Eigen::Matrix<int,Eigen::Dynamic,1> & I);
     Eigen::Matrix<int,Eigen::Dynamic,1> & I);
 }
 }
 
 
+// Implementation
+
 template <typename T>
 template <typename T>
 inline void igl::mat_max(
 inline void igl::mat_max(
   const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
   const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,

+ 1 - 0
mat_min.h

@@ -31,6 +31,7 @@ namespace igl
     Eigen::Matrix<int,Eigen::Dynamic,1> & I);
     Eigen::Matrix<int,Eigen::Dynamic,1> & I);
 }
 }
 
 
+// Implementation
 #include "verbose.h"
 #include "verbose.h"
 
 
 template <typename T>
 template <typename T>

+ 3 - 0
material_colors.h

@@ -1,3 +1,5 @@
+#ifndef IGL_MATERIAL_COLORS_H
+#define IGL_MATERIAL_COLORS_H
 // Define som constant material colors for use with opengl glMaterialfv
 // Define som constant material colors for use with opengl glMaterialfv
 namespace igl
 namespace igl
 {
 {
@@ -13,3 +15,4 @@ namespace igl
   const float CYAN_SPECULAR[4] =   { 163.0/255.0,221.0/255.0,255.0/255.0,1.0f };
   const float CYAN_SPECULAR[4] =   { 163.0/255.0,221.0/255.0,255.0/255.0,1.0f };
   const float DENIS_PURPLE_DIFFUSE[4] =   { 80.0/255.0,64.0/255.0,255.0/255.0,1.0f };
   const float DENIS_PURPLE_DIFFUSE[4] =   { 80.0/255.0,64.0/255.0,255.0/255.0,1.0f };
 }
 }
+#endif

+ 4 - 4
matlabinterface.h

@@ -15,8 +15,8 @@
 // DYLD_LIBRARY_PATH = /Applications/MATLAB_R2011a.app/bin/maci64
 // DYLD_LIBRARY_PATH = /Applications/MATLAB_R2011a.app/bin/maci64
 // PATH = /opt/local/bin:/opt/local/sbin:/Applications/MATLAB_R2011a.app/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin
 // PATH = /opt/local/bin:/opt/local/sbin:/Applications/MATLAB_R2011a.app/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin
 
 
-#ifndef MATLAB_INTERFACE_H
-#define MATLAB_INTERFACE_H
+#ifndef IGL_MATLAB_INTERFACE_H
+#define IGL_MATLAB_INTERFACE_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <string>
 #include <string>
@@ -67,7 +67,7 @@ namespace igl
   
   
 }
 }
 
 
-//Implementation
+// Implementation
 
 
 // Init the MATLAB engine 
 // Init the MATLAB engine 
 // (no need to call it directly since it is automatically invoked by any other command)
 // (no need to call it directly since it is automatically invoked by any other command)
@@ -302,4 +302,4 @@ inline std::string igl::mleval(Engine** mlengine, std::string code)
 }
 }
 
 
 
 
-#endif
+#endif

+ 1 - 1
max_size.h

@@ -14,7 +14,7 @@ namespace igl
   inline int max_size(const std::vector<T> & V);
   inline int max_size(const std::vector<T> & V);
 }
 }
 
 
-// implementation 
+// Implementation 
 
 
 template <typename T>
 template <typename T>
 inline int igl::max_size(const std::vector<T> & V)
 inline int igl::max_size(const std::vector<T> & V)

+ 83 - 76
min_quad_dense.h

@@ -13,93 +13,100 @@
 
 
 namespace igl
 namespace igl
 {
 {
-	// MIN_QUAD_WITH_FIXED Minimize quadratic energy Z'*A*Z + Z'*B + C
-	// subject to linear constraints Aeq*Z = Beq
-	//
-	// Templates:
-	//   T  should be a eigen matrix primitive type like float or double
-	// Inputs:
-	//   A  n by n matrix of quadratic coefficients
-	//   B  n by 1 column of linear coefficients
-	//   Aeq  m by n list of linear equality constraint coefficients
-	//   Beq  m by 1 list of linear equality constraint constant values
-	// Outputs:
-	//   S  n by (n + m) "solve" matrix, such that S*[B', Beq'] is a solution
-	// Returns true on success, false on error
-	template <typename T>
-	void min_quad_dense_precompute(
-		const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& A,
-		const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& Aeq,		
-		Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& S)
-	{
-		typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> Mat;
-                // This threshold seems to matter a lot but I'm not sure how to
-                // set it
-		const T treshold = igl::FLOAT_EPS;
-		//const T treshold = igl::DOUBLE_EPS;
+  // MIN_QUAD_WITH_FIXED Minimize quadratic energy Z'*A*Z + Z'*B + C
+  // subject to linear constraints Aeq*Z = Beq
+  //
+  // Templates:
+  //   T  should be a eigen matrix primitive type like float or double
+  // Inputs:
+  //   A  n by n matrix of quadratic coefficients
+  //   B  n by 1 column of linear coefficients
+  //   Aeq  m by n list of linear equality constraint coefficients
+  //   Beq  m by 1 list of linear equality constraint constant values
+  // Outputs:
+  //   S  n by (n + m) "solve" matrix, such that S*[B', Beq'] is a solution
+  // Returns true on success, false on error
+  template <typename T>
+  inline void min_quad_dense_precompute(
+    const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& A,
+    const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& Aeq,    
+    Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& S);
+}
+
+// Implementation
+template <typename T>
+inline void igl::min_quad_dense_precompute(
+  const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& A,
+  const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& Aeq,    
+  Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& S)
+{
+  typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> Mat;
+        // This threshold seems to matter a lot but I'm not sure how to
+        // set it
+  const T treshold = igl::FLOAT_EPS;
+  //const T treshold = igl::DOUBLE_EPS;
 
 
-		const int n = A.rows();
-		assert(A.cols() == n);
-		const int m = Aeq.rows();
-		assert(Aeq.cols() == n);
+  const int n = A.rows();
+  assert(A.cols() == n);
+  const int m = Aeq.rows();
+  assert(Aeq.cols() == n);
 
 
-		// Lagrange multipliers method:
-		Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> LM(n + m, n + m);
-		LM.block(0, 0, n, n) = A;
-		LM.block(0, n, n, m) = Aeq.transpose();
-		LM.block(n, 0, m, n) = Aeq;
-		LM.block(n, n, m, m).setZero();
+  // Lagrange multipliers method:
+  Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> LM(n + m, n + m);
+  LM.block(0, 0, n, n) = A;
+  LM.block(0, n, n, m) = Aeq.transpose();
+  LM.block(n, 0, m, n) = Aeq;
+  LM.block(n, n, m, m).setZero();
 
 
 //#define USE_LU_DECOMPOSITION
 //#define USE_LU_DECOMPOSITION
-#ifdef USE_LU_DECOMPOSITION		
-		// if LM is close to singular, use at your own risk :)
-		Mat LMpinv = LM.inverse();
+#ifdef USE_LU_DECOMPOSITION    
+  // if LM is close to singular, use at your own risk :)
+  Mat LMpinv = LM.inverse();
 #else // use SVD
 #else // use SVD
-		typedef Eigen::Matrix<T, Eigen::Dynamic, 1> Vec; 
-		Vec singValues;
-		Eigen::JacobiSVD<Mat> svd;
-		svd.compute(LM, Eigen::ComputeFullU | Eigen::ComputeFullV );
-		const Mat& u = svd.matrixU();
-		const Mat& v = svd.matrixV();
-		const Vec& singVals = svd.singularValues();
+  typedef Eigen::Matrix<T, Eigen::Dynamic, 1> Vec; 
+  Vec singValues;
+  Eigen::JacobiSVD<Mat> svd;
+  svd.compute(LM, Eigen::ComputeFullU | Eigen::ComputeFullV );
+  const Mat& u = svd.matrixU();
+  const Mat& v = svd.matrixV();
+  const Vec& singVals = svd.singularValues();
 
 
-		Vec pi_singVals(n + m);
-		int zeroed = 0;
-		for (int i=0; i<n + m; i++)
-		{
-			T sv = singVals(i, 0);
-			assert(sv >= 0);			
-                       // printf("sv: %lg ? %lg\n",(double) sv,(double)treshold);
-			if (sv > treshold) pi_singVals(i, 0) = T(1) / sv;
-			else 
-			{
-				pi_singVals(i, 0) = T(0);
-				zeroed++;
-			}
-		}
+  Vec pi_singVals(n + m);
+  int zeroed = 0;
+  for (int i=0; i<n + m; i++)
+  {
+    T sv = singVals(i, 0);
+    assert(sv >= 0);      
+               // printf("sv: %lg ? %lg\n",(double) sv,(double)treshold);
+    if (sv > treshold) pi_singVals(i, 0) = T(1) / sv;
+    else 
+    {
+      pi_singVals(i, 0) = T(0);
+      zeroed++;
+    }
+  }
 
 
-		printf("min_quad_dense_precompute: %i singular values zeroed (threshold = %e)\n", zeroed, treshold);
-		Eigen::DiagonalMatrix<T, Eigen::Dynamic> pi_diag(pi_singVals);
+  printf("min_quad_dense_precompute: %i singular values zeroed (threshold = %e)\n", zeroed, treshold);
+  Eigen::DiagonalMatrix<T, Eigen::Dynamic> pi_diag(pi_singVals);
 
 
-		Mat LMpinv = v * pi_diag * u.transpose();
+  Mat LMpinv = v * pi_diag * u.transpose();
 #endif
 #endif
-		S = LMpinv.block(0, 0, n, n + m);
+  S = LMpinv.block(0, 0, n, n + m);
 
 
-		//// debug:
-		//mlinit(&g_pEngine);
-		//
-		//mlsetmatrix(&g_pEngine, "A", A);
-		//mlsetmatrix(&g_pEngine, "Aeq", Aeq);
-		//mlsetmatrix(&g_pEngine, "LM", LM);
-		//mlsetmatrix(&g_pEngine, "u", u);
-		//mlsetmatrix(&g_pEngine, "v", v);
-		//MatrixXd svMat = singVals;
-		//mlsetmatrix(&g_pEngine, "singVals", svMat);
-		//mlsetmatrix(&g_pEngine, "LMpinv", LMpinv);
-		//mlsetmatrix(&g_pEngine, "S", S);
+  //// debug:
+  //mlinit(&g_pEngine);
+  //
+  //mlsetmatrix(&g_pEngine, "A", A);
+  //mlsetmatrix(&g_pEngine, "Aeq", Aeq);
+  //mlsetmatrix(&g_pEngine, "LM", LM);
+  //mlsetmatrix(&g_pEngine, "u", u);
+  //mlsetmatrix(&g_pEngine, "v", v);
+  //MatrixXd svMat = singVals;
+  //mlsetmatrix(&g_pEngine, "singVals", svMat);
+  //mlsetmatrix(&g_pEngine, "LMpinv", LMpinv);
+  //mlsetmatrix(&g_pEngine, "S", S);
 
 
-		//int hu = 1;
-	}
+  //int hu = 1;
 }
 }
 
 
 #endif
 #endif

+ 1 - 1
min_size.h

@@ -14,7 +14,7 @@ namespace igl
   inline int min_size(const std::vector<T> & V);
   inline int min_size(const std::vector<T> & V);
 }
 }
 
 
-// implementation 
+// Implementation 
 
 
 template <typename T>
 template <typename T>
 inline int igl::min_size(const std::vector<T> & V)
 inline int igl::min_size(const std::vector<T> & V)

+ 2 - 2
mode.h

@@ -14,7 +14,7 @@ namespace igl
   //   M  vector containing mode along dension d, if d==1 then this will be a
   //   M  vector containing mode along dension d, if d==1 then this will be a
   //     n-long vector if d==2 then this will be a m-long vector
   //     n-long vector if d==2 then this will be a m-long vector
   template <typename T>
   template <typename T>
-  void mode(
+  inline void mode(
     const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
     const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
     const int d, 
     const int d, 
     Eigen::Matrix<T,Eigen::Dynamic,1> & M);
     Eigen::Matrix<T,Eigen::Dynamic,1> & M);
@@ -24,7 +24,7 @@ namespace igl
 #include <vector>
 #include <vector>
 
 
 template <typename T>
 template <typename T>
-void igl::mode(
+inline void igl::mode(
   const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
   const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
   const int d, 
   const int d, 
   Eigen::Matrix<T,Eigen::Dynamic,1> & M)
   Eigen::Matrix<T,Eigen::Dynamic,1> & M)

+ 4 - 2
moveFV.h

@@ -6,8 +6,8 @@
 //  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
 //  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
 //
 //
 
 
-#ifndef Preview3D_moveFV_h
-#define Preview3D_moveFV_h
+#ifndef IGL_MOVEFV_h
+#define IGL_MOVEFV_h
 
 
 namespace igl 
 namespace igl 
 {
 {
@@ -27,6 +27,8 @@ namespace igl
               Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &SV);
               Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &SV);
 }
 }
 
 
+// Implementation
+
 template <typename T>
 template <typename T>
 inline void igl::moveFV(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
 inline void igl::moveFV(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
             const Eigen::MatrixXi &F,
             const Eigen::MatrixXi &F,

+ 3 - 3
mvc.h

@@ -5,8 +5,8 @@
 //  Copyright (c) 2011 ETH Zurich. All rights reserved.
 //  Copyright (c) 2011 ETH Zurich. All rights reserved.
 //
 //
 
 
-#ifndef mvc_h
-#define mvc_h
+#ifndef IGL_MVC_H
+#define IGL_MVC_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 
 
@@ -24,7 +24,7 @@ namespace igl
 //    W  weights, #V by #C matrix of weights
 //    W  weights, #V by #C matrix of weights
 //  
 //  
     
     
-  void mvc(const Eigen::MatrixXd &V, const Eigen::MatrixXd &C, Eigen::MatrixXd &W);
+  inline void mvc(const Eigen::MatrixXd &V, const Eigen::MatrixXd &C, Eigen::MatrixXd &W);
   
   
 }
 }
 
 

+ 2 - 0
normalize_rows.h

@@ -13,6 +13,8 @@ namespace igl
   inline void normalize_rows(const Eigen::MatrixXd & A, Eigen::MatrixXd & B);
   inline void normalize_rows(const Eigen::MatrixXd & A, Eigen::MatrixXd & B);
 }
 }
 
 
+// Implementation
+
 inline void igl::normalize_rows(const Eigen::MatrixXd & A, Eigen::MatrixXd & B)
 inline void igl::normalize_rows(const Eigen::MatrixXd & A, Eigen::MatrixXd & B)
 {
 {
   // Resize output
   // Resize output

+ 3 - 3
orth.h

@@ -5,8 +5,8 @@
 //  Copyright (c) 2011 ETH Zurich. All rights reserved.
 //  Copyright (c) 2011 ETH Zurich. All rights reserved.
 //
 //
 
 
-#ifndef orth_h
-#define orth_h
+#ifndef IGL_ORTH_H
+#define IGL_ORTH_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 
 
@@ -24,7 +24,7 @@ namespace igl
 //   provides more reliable and consistent rank determination.
 //   provides more reliable and consistent rank determination.
 //   Closely follows MATLAB implementation in orth.m
 //   Closely follows MATLAB implementation in orth.m
 //  
 //  
-  void orth(const Eigen::MatrixXd &A, Eigen::MatrixXd &Q);
+  inline void orth(const Eigen::MatrixXd &A, Eigen::MatrixXd &Q);
 }
 }
 
 
 // Implementation
 // Implementation

+ 40 - 30
plot_vector.h

@@ -4,47 +4,57 @@
 #include <iostream>
 #include <iostream>
 namespace igl 
 namespace igl 
 {
 {
+  // Not clear what these are supposed to be doing. Currently they print
+  // vectors to standard error...
   template <typename T>
   template <typename T>
-  inline void plot_vector( std::vector<T>& v)
+  inline void plot_vector( std::vector<T>& v);
+  template <typename T>
+  inline void plot_vector( std::vector< std::vector<T> >& v);
+  template <typename T>
+  inline void plot_vector( std::vector< std::vector< std::vector<T> > >& v);
+}
+
+// Implementation
+
+template <typename T>
+inline void igl::plot_vector( std::vector<T>& v)
+{
+  for (int i=0; i<v.size(); ++i)
+    std::cerr << v[i] << " ";
+  std::cerr << std::endl;
+}
+
+template <typename T>
+inline void igl::plot_vector( std::vector< std::vector<T> >& v)
+{
+  for (int i=0; i<v.size(); ++i)
   {
   {
-    for (int i=0; i<v.size(); ++i)
-      std::cerr << v[i] << " ";
+    std::cerr << i << ": ";
+    for (int j=0; j<v[i].size(); ++j)
+      std::cerr << v[i][j] << " ";
     std::cerr << std::endl;
     std::cerr << std::endl;
   }
   }
-  
-  template <typename T>
-  inline void plot_vector( std::vector< std::vector<T> >& v)
+}
+
+
+template <typename T>
+inline void igl::plot_vector( std::vector< std::vector< std::vector<T> > >& v)
+{
+  for (int m=0; m<v.size(); ++m)
   {
   {
-    for (int i=0; i<v.size(); ++i)
+    std::cerr << "Matrix " << m << std::endl;
+
+    for (int i=0; i<v[m].size(); ++i)
     {
     {
       std::cerr << i << ": ";
       std::cerr << i << ": ";
-      for (int j=0; j<v[i].size(); ++j)
-        std::cerr << v[i][j] << " ";
+      for (int j=0; j<v[m][i].size(); ++j)
+        std::cerr << v[m][i][j] << " ";
       std::cerr << std::endl;
       std::cerr << std::endl;
     }
     }
-  }
-  
-  
-  template <typename T>
-  inline void plot_vector( std::vector< std::vector< std::vector<T> > >& v)
-  {
-    for (int m=0; m<v.size(); ++m)
-    {
-      std::cerr << "Matrix " << m << std::endl;
-
-      for (int i=0; i<v[m].size(); ++i)
-      {
-        std::cerr << i << ": ";
-        for (int j=0; j<v[m][i].size(); ++j)
-          std::cerr << v[m][i][j] << " ";
-        std::cerr << std::endl;
-      }
-      
-      std::cerr << "---- end " << m << std::endl;
+    
+    std::cerr << "---- end " << m << std::endl;
 
 
-    }
   }
   }
-  
 }
 }
 
 
 #endif
 #endif

+ 2 - 4
pos.h

@@ -3,12 +3,10 @@
 //
 //
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 
 
-#ifndef POS_H
-#define POS_H
+#ifndef IGL_POS_H
+#define IGL_POS_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
-#include <string>
-#include "ismanifold.h"
 
 
 #include <vector>
 #include <vector>
 
 

+ 4 - 3
print_gl_get.h

@@ -1,5 +1,5 @@
-#ifndef PRINT_gl_get_H
-#define PRINT_gl_get_H
+#ifndef IGL_PRINT_GL_GET_H
+#define IGL_PRINT_GL_GET_H
 
 
 #if __APPLE__
 #if __APPLE__
 #  include <OpenGL/gl.h>
 #  include <OpenGL/gl.h>
@@ -21,7 +21,8 @@ namespace igl
 }
 }
 
 
 
 
-// implementation
+// Implementation
+
 #include <cstdio>
 #include <cstdio>
 inline void igl::print_gl_get(GLenum pname)
 inline void igl::print_gl_get(GLenum pname)
 {
 {

+ 2 - 2
print_program_info_log.h

@@ -1,4 +1,4 @@
-#ifndef  IGL_PRINT_PROGRAM_INFO_LOG_H
+#ifndef IGL_PRINT_PROGRAM_INFO_LOG_H
 #define IGL_PRINT_PROGRAM_INFO_LOG_H
 #define IGL_PRINT_PROGRAM_INFO_LOG_H
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
@@ -18,7 +18,7 @@ namespace igl
   inline void print_program_info_log(const GLuint obj);
   inline void print_program_info_log(const GLuint obj);
 }
 }
 
 
-// Implmentation
+// Implementation
 #include <cstdio>
 #include <cstdio>
 // Copyright Denis Kovacs 4/10/08
 // Copyright Denis Kovacs 4/10/08
 inline void igl::print_program_info_log(const GLuint obj)
 inline void igl::print_program_info_log(const GLuint obj)

+ 2 - 2
print_shader_info_log.h

@@ -1,4 +1,4 @@
-#ifndef  IGL_PRINT_SHADER_INFO_LOG_H
+#ifndef IGL_PRINT_SHADER_INFO_LOG_H
 #define IGL_PRINT_SHADER_INFO_LOG_H
 #define IGL_PRINT_SHADER_INFO_LOG_H
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
@@ -19,7 +19,7 @@ namespace igl
   inline void print_shader_info_log(const GLuint obj);
   inline void print_shader_info_log(const GLuint obj);
 }
 }
 
 
-// Implmentation
+// Implementation
 #include <cstdio>
 #include <cstdio>
 // Copyright Denis Kovacs 4/10/08
 // Copyright Denis Kovacs 4/10/08
 inline void igl::print_shader_info_log(const GLuint obj)
 inline void igl::print_shader_info_log(const GLuint obj)

+ 3 - 0
quat_to_mat.h

@@ -1,3 +1,5 @@
+#ifndef IGL_QUAT2MAT_H
+#define IGL_QUAT2MAT_H
 // Name history:
 // Name history:
 //   quat2mat  until 16 Sept 2011
 //   quat2mat  until 16 Sept 2011
 namespace igl
 namespace igl
@@ -42,3 +44,4 @@ inline void igl::quat_to_mat(const Q_type * quat, Q_type * mat)
   mat[3*4+0] = mat[3*4+1] = mat[3*4+2] = 0;
   mat[3*4+0] = mat[3*4+1] = mat[3*4+2] = 0;
   mat[3*4+3] = 1;
   mat[3*4+3] = 1;
 }
 }
+#endif

+ 25 - 2
readme.txt

@@ -1,4 +1,4 @@
-igl Library - A simple c++ mesh library
+e gl Library - A simple c++ mesh library
 Copyright 2011 - Daniele Panozzo, Alec Jacobson, Olga Diamanti
 Copyright 2011 - Daniele Panozzo, Alec Jacobson, Olga Diamanti
 Interactive Geometry Lab - ETH Zurich
 Interactive Geometry Lab - ETH Zurich
 
 
@@ -52,7 +52,7 @@ description of each template, input and output in each prototype.
   - Do not use the using namespace directive anywhere. This means never
   - Do not use the using namespace directive anywhere. This means never
     write:
     write:
     "using namespace std;"
     "using namespace std;"
-    or 
+     or 
     "using namespace igl;"
     "using namespace igl;"
     etc.
     etc.
 
 
@@ -83,3 +83,26 @@ description of each template, input and output in each prototype.
   templates, you must document the template just as you document inputs
   templates, you must document the template just as you document inputs
   and outputs.
   and outputs.
 
 
+  = Useful checks =
+  
+  Find files that aren't using "inline"
+
+    grep -L inline *
+
+  Find files that aren't using igl namespace
+
+    grep -L "namespace igl" *
+
+  Find files using [TAB] character
+
+    grep -P '\t' *
+
+  Find files that don't contain // Implementation
+
+    grep -L "^\/\/ Implementation" *
+
+  Find files that don't contain #ifndef IGL_
+
+    grep -L "^#ifndef IGL_" *
+
+

+ 4 - 4
removeDuplicates.h

@@ -6,8 +6,8 @@
 //  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
 //  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
 //
 //
 
 
-#ifndef RemoveDuplicates_h
-#define RemoveDuplicates_h
+#ifndef IGL_REMOVEDUPLICATES_H
+#define IGL_REMOVEDUPLICATES_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 namespace igl 
 namespace igl 
@@ -63,7 +63,7 @@ inline void igl::removeDuplicates(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::
     }
     }
   }
   }
   
   
-  NV.conservativeResize	(	count , Eigen::NoChange );
+  NV.conservativeResize  (  count , Eigen::NoChange );
 
 
   count = 0;
   count = 0;
   std::vector<int> face;
   std::vector<int> face;
@@ -81,7 +81,7 @@ inline void igl::removeDuplicates(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::
       count ++;
       count ++;
     }
     }
   }
   }
-  NF.conservativeResize	(	count , Eigen::NoChange );
+  NF.conservativeResize  (  count , Eigen::NoChange );
   
   
   delete [] VISITED;
   delete [] VISITED;
 }
 }

+ 2 - 2
removeUnreferenced.h

@@ -4,8 +4,8 @@
 //
 //
 //  Created by Daniele Panozzo on 17/11/11.
 //  Created by Daniele Panozzo on 17/11/11.
 
 
-#ifndef RemoveUnreferenced_h
-#define RemoveUnreferenced_h
+#ifndef IGL_REMOVEUNREFERENCED_H
+#define IGL_REMOVEUNREFERENCED_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 namespace igl 
 namespace igl 

+ 8 - 1
report_gl_error.h

@@ -23,7 +23,9 @@ namespace igl
   // Inputs:
   // Inputs:
   //   id   string to appear before any error msgs
   //   id   string to appear before any error msgs
   // Returns result of glGetError() 
   // Returns result of glGetError() 
-  inline GLenum report_gl_error(const std::string id = std::string(""));
+  inline GLenum report_gl_error(const std::string id);
+  // No prefix
+  inline GLenum report_gl_error();
 }
 }
 
 
 // Implementation
 // Implementation
@@ -40,4 +42,9 @@ inline GLenum igl::report_gl_error(const std::string id)
   return err;
   return err;
 }
 }
 
 
+inline GLenum igl::report_gl_error()
+{
+  return igl::report_gl_error(std::string(""));
+}
+
 #endif
 #endif

+ 4 - 4
rows_to_matrix.h

@@ -16,7 +16,7 @@ namespace igl
   //   M  an m by n matrix
   //   M  an m by n matrix
   // Returns true on success, false on errors
   // Returns true on success, false on errors
   template <class Row, class Mat>
   template <class Row, class Mat>
-  bool rows_to_matrix(const std::vector<Row> & V,Mat & M);
+  inline bool rows_to_matrix(const std::vector<Row> & V,Mat & M);
 }
 }
 
 
 // Implementation
 // Implementation
@@ -27,20 +27,20 @@ namespace igl
 #include "min_size.h"
 #include "min_size.h"
 
 
 template <class Row, class Mat>
 template <class Row, class Mat>
-bool igl::rows_to_matrix(const std::vector<Row> & V,Mat & M)
+inline bool igl::rows_to_matrix(const std::vector<Row> & V,Mat & M)
 {
 {
   // number of columns
   // number of columns
   int m = V.size();
   int m = V.size();
   if(m == 0)
   if(m == 0)
   {
   {
-    fprintf(stderr,"Error: list_to_matrix() list is empty()\n");
+    fprintf(stderr,"Error: rows_to_matrix() list is empty()\n");
     return false;
     return false;
   }
   }
   // number of rows
   // number of rows
   int n = igl::min_size(V);
   int n = igl::min_size(V);
   if(n != igl::max_size(V))
   if(n != igl::max_size(V))
   {
   {
-    fprintf(stderr,"Error: list_to_matrix()"
+    fprintf(stderr,"Error: rows_to_matrix()"
       " list elements are not all the same size\n");
       " list elements are not all the same size\n");
     return false;
     return false;
   }
   }

+ 11 - 10
sort.h

@@ -44,7 +44,6 @@ namespace igl
       const bool ascending,
       const bool ascending,
       std::vector<T> &sorted,
       std::vector<T> &sorted,
       std::vector<size_t> &index_map);
       std::vector<size_t> &index_map);
-
 }
 }
 
 
 // Implementation
 // Implementation
@@ -109,15 +108,17 @@ inline void igl::sort(
 
 
 // Comparison struct used by sort
 // Comparison struct used by sort
 // http://bytes.com/topic/c/answers/132045-sort-get-index
 // http://bytes.com/topic/c/answers/132045-sort-get-index
-template<class T> struct index_cmp
-{
-  index_cmp(const T arr) : arr(arr) {}
-  bool operator()(const size_t a, const size_t b) const
+namespace igl{
+  template<class T> struct index_cmp
   {
   {
-    return arr[a] < arr[b];
-  }
-  const T arr;
-};
+    index_cmp(const T arr) : arr(arr) {}
+    bool operator()(const size_t a, const size_t b) const
+    {
+      return arr[a] < arr[b];
+    }
+    const T arr;
+  };
+}
 
 
 template <class T>
 template <class T>
 inline void igl::sort(
 inline void igl::sort(
@@ -136,7 +137,7 @@ inline void igl::sort(
   sort(
   sort(
     index_map.begin(),
     index_map.begin(),
     index_map.end(),
     index_map.end(),
-    index_cmp<const std::vector<T>& >(unsorted));
+    igl::index_cmp<const std::vector<T>& >(unsorted));
 
 
   // if not ascending then reverse
   // if not ascending then reverse
   if(!ascending)
   if(!ascending)

+ 2 - 0
speye.h

@@ -27,6 +27,8 @@ namespace igl
   inline void speye(const int n, Eigen::SparseMatrix<T> & I);
   inline void speye(const int n, Eigen::SparseMatrix<T> & I);
 }
 }
 
 
+// Implementation
+
 template <typename T>
 template <typename T>
 inline void igl::speye(const int m, const int n, Eigen::SparseMatrix<T> & I)
 inline void igl::speye(const int m, const int n, Eigen::SparseMatrix<T> & I)
 {
 {

+ 1 - 1
stdin_to_temp.h

@@ -21,7 +21,7 @@ namespace igl
   inline bool stdin_to_temp(FILE ** temp_file);
   inline bool stdin_to_temp(FILE ** temp_file);
 }
 }
 
 
-// IMPLEMENTATION
+// Implementation
 #include <iostream>
 #include <iostream>
 
 
 inline bool igl::stdin_to_temp(FILE ** temp_file)
 inline bool igl::stdin_to_temp(FILE ** temp_file)

+ 2 - 0
sum.h

@@ -26,6 +26,8 @@ namespace igl
     Eigen::SparseVector<T>& S);
     Eigen::SparseVector<T>& S);
 }
 }
 
 
+// Implementation
+
 template <typename T>
 template <typename T>
 inline void igl::sum(
 inline void igl::sum(
   const Eigen::SparseMatrix<T>& X, 
   const Eigen::SparseMatrix<T>& X, 

+ 2 - 2
texture_from_tga.h

@@ -21,14 +21,14 @@ namespace igl
   // Output:
   // Output:
   //  id  of generated openGL texture
   //  id  of generated openGL texture
   // Returns true on success, false on failure
   // Returns true on success, false on failure
-  bool texture_from_tga(const std::string tga_file, GLuint & id);
+  inline bool texture_from_tga(const std::string tga_file, GLuint & id);
 }
 }
 
 
 
 
 // Implementation
 // Implementation
 #include "tga.h"
 #include "tga.h"
 
 
-bool igl::texture_from_tga(const std::string tga_file, GLuint & id)
+inline bool igl::texture_from_tga(const std::string tga_file, GLuint & id)
 {
 {
   using namespace std;
   using namespace std;
   using namespace igl;
   using namespace igl;

+ 3 - 0
tga.h

@@ -1,3 +1,5 @@
+#ifndef IGL_TGA_H
+#define IGL_TGA_H
 #pragma once
 #pragma once
 
 
 // interface for TrueVision (TGA) image file loader
 // interface for TrueVision (TGA) image file loader
@@ -646,3 +648,4 @@ static void writeTGA( gliGenericImage* image, FILE *fp) {
 }
 }
 
 
 } // end of namespace
 } // end of namespace
+#endif

+ 5 - 0
todos.txt

@@ -0,0 +1,5 @@
+- standardize use of string/char *, add to style conventions
+- standardize Eigen Templates, add to style conventions
+- standardize headers-only vs. static library
+- clean up tga.h
+- standardize igl includes #include "cotangent.h" or #include <cotangent.h>

+ 3 - 0
trackball.h

@@ -1,3 +1,5 @@
+#ifndef IGL_TRACKBALL_H
+#define IGL_TRACKBALL_H
 
 
 namespace igl
 namespace igl
 {
 {
@@ -126,3 +128,4 @@ inline void igl::trackball(
     }
     }
   }
   }
 }
 }
+#endif

+ 80 - 66
tt.h

@@ -3,94 +3,108 @@
 //
 //
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 
 
-#ifndef TT_H
-#define TT_H
+#ifndef IGL_TT_H
+#define IGL_TT_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
-#include <string>
-#include "ismanifold.h"
 
 
 #include <vector>
 #include <vector>
 
 
 namespace igl 
 namespace igl 
 {
 {
-
   // Preprocessing
   // Preprocessing
   template<typename T> 
   template<typename T> 
-  inline void tt_preprocess(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F, std::vector<std::vector<int> >& TTT)
-  {
-    for(int f=0;f<F.rows();++f)
-      for (int i=0;i<3;++i)
-      {
-        // v1 v2 f ei 
-        int v1 = F(f,i);
-        int v2 = F(f,(i+1)%3);
-        if (v1 > v2) std::swap(v1,v2);
-        std::vector<int> r(4);
-        r[0] = v1; r[1] = v2;
-        r[2] = f;  r[3] = i;
-        TTT.push_back(r);
-      }
-    std::sort(TTT.begin(),TTT.end());
-  }
-  
+  inline void tt_preprocess(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F, std::vector<std::vector<int> >& TTT);
   // Extract the face adjacencies
   // Extract the face adjacencies
-  inline void tt_extractTT(const Eigen::MatrixXi& F, std::vector<std::vector<int> >& TTT, Eigen::MatrixXi& TT)
-  {
-    TT = Eigen::MatrixXi::Constant((int)(F.rows()),3,-1);
-    
-    for(int i=1;i<(int)TTT.size();++i)
+  inline void tt_extractTT(const Eigen::MatrixXi& F, std::vector<std::vector<int> >& TTT, Eigen::MatrixXi& TT);
+  // Extract the face adjacencies indices (needed for fast traversal)
+  inline void tt_extractTTi(const Eigen::MatrixXi& F, std::vector<std::vector<int> >& TTT, Eigen::MatrixXi& TTi);
+  // Compute triangle-triangle adjacency
+  template<typename T> 
+  inline void tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F, Eigen::MatrixXi& TT);
+  // Compute triangle-triangle adjacency with indices
+  template<typename T> 
+  inline void tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F, Eigen::MatrixXi& TT, Eigen::MatrixXi& TTi);
+}
+
+// Implementation
+#include "is_manifold.h"
+#include <algorithm>
+
+template<typename T> 
+inline void igl::tt_preprocess(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F, std::vector<std::vector<int> >& TTT)
+{
+  for(int f=0;f<F.rows();++f)
+    for (int i=0;i<3;++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];
-      }
+      // v1 v2 f ei 
+      int v1 = F(f,i);
+      int v2 = F(f,(i+1)%3);
+      if (v1 > v2) std::swap(v1,v2);
+      std::vector<int> r(4);
+      r[0] = v1; r[1] = v2;
+      r[2] = f;  r[3] = i;
+      TTT.push_back(r);
     }
     }
-  }
+  std::sort(TTT.begin(),TTT.end());
+}
+
+// Extract the face adjacencies
+inline void igl::tt_extractTT(const Eigen::MatrixXi& F, std::vector<std::vector<int> >& TTT, Eigen::MatrixXi& TT)
+{
+  TT = Eigen::MatrixXi::Constant((int)(F.rows()),3,-1);
   
   
-  // Extract the face adjacencies indices (needed for fast traversal)
-  inline void tt_extractTTi(const Eigen::MatrixXi& F, std::vector<std::vector<int> >& TTT, Eigen::MatrixXi& TTi)
+  for(int i=1;i<(int)TTT.size();++i)
   {
   {
-    TTi = Eigen::MatrixXi::Constant((int)(F.rows()),3,-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]))
     {
     {
-      std::vector<int>& r1 = TTT[i-1];
-      std::vector<int>& r2 = TTT[i];
-      if ((r1[0] == r2[0]) && (r1[1] == r2[1]))
-      {
-        TTi(r1[2],r1[3]) = r2[3];
-        TTi(r2[2],r2[3]) = r1[3];
-      }
+      TT(r1[2],r1[3]) = r2[2];
+      TT(r2[2],r2[3]) = r1[2];
     }
     }
   }
   }
+}
 
 
-  // Compute triangle-triangle adjacency
-  template<typename T> 
-  inline void tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F, Eigen::MatrixXi& TT)
+// Extract the face adjacencies indices (needed for fast traversal)
+inline void igl::tt_extractTTi(const Eigen::MatrixXi& F, std::vector<std::vector<int> >& TTT, Eigen::MatrixXi& TTi)
+{
+  TTi = Eigen::MatrixXi::Constant((int)(F.rows()),3,-1);
+  
+  for(int i=1;i<(int)TTT.size();++i)
   {
   {
-    assert(igl::isManifold(V,F));
-    std::vector<std::vector<int> > TTT;
-    
-    tt_preprocess<T>(V,F,TTT);
-    tt_extractTT(F,TTT,TT);
+    std::vector<int>& r1 = TTT[i-1];
+    std::vector<int>& r2 = TTT[i];
+    if ((r1[0] == r2[0]) && (r1[1] == r2[1]))
+    {
+      TTi(r1[2],r1[3]) = r2[3];
+      TTi(r2[2],r2[3]) = r1[3];
+    }
   }
   }
+}
 
 
-  // Compute triangle-triangle adjacency with indices
-  template<typename T> 
-  inline void tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F, Eigen::MatrixXi& TT, Eigen::MatrixXi& TTi)
-  {
-    assert(igl::isManifold(V,F));
-    std::vector<std::vector<int> > TTT;
-    
-    tt_preprocess<T>(V,F,TTT);
-    tt_extractTT(F,TTT,TT);
-    tt_extractTTi(F,TTT,TTi);
-  }
+// Compute triangle-triangle adjacency
+template<typename T> 
+inline void igl::tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F, Eigen::MatrixXi& TT)
+{
+  assert(igl::is_manifold(V,F));
+  std::vector<std::vector<int> > TTT;
+  
+  tt_preprocess<T>(V,F,TTT);
+  tt_extractTT(F,TTT,TT);
+}
 
 
+// Compute triangle-triangle adjacency with indices
+template<typename T> 
+inline void igl::tt(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& V, const Eigen::MatrixXi& F, Eigen::MatrixXi& TT, Eigen::MatrixXi& TTi)
+{
+  assert(igl::is_manifold(V,F));
+  std::vector<std::vector<int> > TTT;
+  
+  tt_preprocess<T>(V,F,TTT);
+  tt_extractTT(F,TTT,TT);
+  tt_extractTTi(F,TTT,TTi);
 }
 }
 
 
+
 #endif
 #endif

+ 4 - 4
upsample.h

@@ -18,10 +18,10 @@ namespace igl
   // NOTE: V should not be the same as NV,
   // NOTE: V should not be the same as NV,
   // NOTE: F should not be the same as NF, use other proto
   // NOTE: F should not be the same as NF, use other proto
   template <typename MatV, typename MatF>
   template <typename MatV, typename MatF>
-  void upsample( const MatV & V, const MatF & F, MatV & NV, MatF & NF);
+  inline void upsample( const MatV & V, const MatF & F, MatV & NV, MatF & NF);
   // Virtually in place wrapper
   // Virtually in place wrapper
   template <typename MatV, typename MatF>
   template <typename MatV, typename MatF>
-  void upsample( MatV & V,MatF & F);
+  inline void upsample( MatV & V,MatF & F);
 }
 }
 
 
 // Implementation
 // Implementation
@@ -30,7 +30,7 @@ namespace igl
 #include <Eigen/Dense>
 #include <Eigen/Dense>
 
 
 template <typename MatV, typename MatF>
 template <typename MatV, typename MatF>
-void igl::upsample( const MatV & V, const MatF & F, MatV & NV, MatF & NF)
+inline void igl::upsample( const MatV & V, const MatF & F, MatV & NV, MatF & NF)
 {
 {
   // Use "in place" wrapper instead
   // Use "in place" wrapper instead
   assert(&V != &NV);
   assert(&V != &NV);
@@ -105,7 +105,7 @@ void igl::upsample( const MatV & V, const MatF & F, MatV & NV, MatF & NF)
 }
 }
 
 
 template <typename MatV, typename MatF>
 template <typename MatV, typename MatF>
-void igl::upsample( MatV & V,MatF & F)
+inline void igl::upsample( MatV & V,MatF & F)
 {
 {
   const MatV V_copy = V;
   const MatV V_copy = V;
   const MatF F_copy = F;
   const MatF F_copy = F;

+ 29 - 18
write.h

@@ -3,32 +3,43 @@
 //
 //
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 
 
-#ifndef WRITE_H
-#define WRITE_H
+#ifndef IGL_WRITE_H
+#define IGL_WRITE_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <string>
 #include <string>
 
 
+namespace igl 
+{
+  // write mesh to an ascii file with automatic detection of file format. supported: obj, off)
+  // Known Bugs:
+  //  Does not correctly find file extensions: myfile.foo.off 
+  inline bool write(
+    const std::string str, 
+    const Eigen::MatrixXd& V, 
+    const Eigen::MatrixXi& F);
+}
+
+// Implementation
 #include <writeOBJ.h>
 #include <writeOBJ.h>
 #include <writeOFF.h>
 #include <writeOFF.h>
 
 
-namespace igl 
+inline bool igl::write(
+  const std::string str, 
+  const Eigen::MatrixXd& V, 
+  const Eigen::MatrixXi& F)
 {
 {
-    // write mesh to an ascii file with automatic detection of file format. supported: obj, off)
-    inline bool write(std::string str, Eigen::MatrixXd& V, Eigen::MatrixXi& F)
-    {
-        const char* p;
-        for (p = str.c_str(); *p != '\0'; p++)
-            ;
-        while (*p != '.')
-            p--;
-        
-        if (!strcmp(p, ".obj") || !strcmp(p, ".OBJ"))
-            return igl::writeOBJ(str,V,F);
-        
-        if (!strcmp(p, ".off") || !strcmp(p, ".OFF"))
-            return igl::writeOFF(str,V,F);
-    }
+  const char* p;
+  for (p = str.c_str(); *p != '\0'; p++)
+    ;
+  while (*p != '.')
+    p--;
+  
+  if (!strcmp(p, ".obj") || !strcmp(p, ".OBJ"))
+    return igl::writeOBJ(str,V,F);
+  
+  if (!strcmp(p, ".off") || !strcmp(p, ".OFF"))
+    return igl::writeOFF(str,V,F);
 }
 }
 
 
 #endif
 #endif

+ 27 - 24
writeOFF.h

@@ -3,37 +3,40 @@
 //
 //
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 //  Copyright 2011, Daniele Panozzo. All rights reserved.
 
 
-#ifndef WRITEOFF_H
-#define WRITEOFF_H
+#ifndef IGL_WRITEOFF_H
+#define IGL_WRITEOFF_H
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <string>
 #include <string>
 
 
 namespace igl 
 namespace igl 
 {
 {
-    // write mesh to an ascii off file
-    inline bool writeOFF (std::string fname, Eigen::MatrixXd& V, Eigen::MatrixXi& F)
+    inline bool writeOFF(const std::string fname, const Eigen::MatrixXd& V, const Eigen::MatrixXi& F);
+}
+
+// Implementation
+
+// write mesh to an ascii off file
+inline bool igl::writeOFF(const std::string fname, const Eigen::MatrixXd& V, const Eigen::MatrixXi& F)
+{
+    FILE *fp = fopen (fname.c_str(), "w");
+  
+    
+    if (!fp)
     {
     {
-        FILE *fp = fopen (fname.c_str(), "w");
-      
-        
-        if (!fp)
-        {
-            fprintf (stderr, "writeOFF(): could not open file %s", fname.c_str());
-          return false;
-        }
-        
-        fprintf (fp, "OFF\n%d %d 0\n",  (int) V.rows(), (int) F.rows());
-        
-        for (unsigned i = 0; i < V.rows(); i++)
-            fprintf (fp, "%f %f %f\n", V(i,0), V(i,1), V(i,2));
-        
-        for (unsigned i = 0; i < F.rows(); i++)
-            fprintf (fp, "3 %d %d %d\n", F(i,0), F(i,1), F(i,2));
-        
-        fclose (fp);
-        return true;
+        fprintf (stderr, "writeOFF(): could not open file %s", fname.c_str());
+      return false;
     }
     }
+    
+    fprintf (fp, "OFF\n%d %d 0\n",  (int) V.rows(), (int) F.rows());
+    
+    for (unsigned i = 0; i < V.rows(); i++)
+        fprintf (fp, "%f %f %f\n", V(i,0), V(i,1), V(i,2));
+    
+    for (unsigned i = 0; i < F.rows(); i++)
+        fprintf (fp, "3 %d %d %d\n", F(i,0), F(i,1), F(i,2));
+    
+    fclose (fp);
+    return true;
 }
 }
-
 #endif
 #endif