Browse Source

rm boost dependency extra, absorb functions into main library

Former-commit-id: f8f633cd7bea5c541855bdbb0991175f936be5c4
Alec Jacobson 10 years ago
parent
commit
98540fdb74

+ 15 - 4
RELEASE_HISTORY.txt

@@ -17,13 +17,24 @@ Version | Short description
 ## Version 1.2 Changes ##
 This change introduces better organization of dependencies and removes some
 deprecated/repeated functions. The 3x3 svd code and dependent functions
-(including ARAP) were absorbed into the main library.
+(including ARAP) were absorbed into the main library. Similarly, the boost
+dependency extra was absorbed.
 
 ### Deprecated/repeated functions ###
 
-Old                              | New
--------------------------------- | -------------------------------------
-`igl::angles`                    | `igl::internal_angles`
+Old                                     | New
+--------------------------------------- | -----------------------------------
+`igl::angles`                           | `igl::internal_angles`
+`#include <igl/boost/components.h>`     | `#include <igl/components.h>`
+`#include <igl/boost/bfs_orient.h>`     | `#include <igl/bfs_orient.h>`
+`#include <igl/boost/orientable_patches.h>` | `#include <igl/orientable_patches.h>`
+`#include <igl/svd3x3/arap.h>`          | `#include <igl/arap.h>`
+`#include <igl/svd3x3/arap_dof.h>`      | `#include <igl/arap_dof.h>`
+`#include <igl/svd3x3/fit_rotations.h>` | `#include <igl/fit_rotations.h>`
+`#include <igl/svd3x3/polar_svd3x3.h>`  | `#include <igl/polar_svd3x3.h>`
+`#include <igl/svd3x3/svd3x3.h>`        | `#include <igl/svd3x3.h>`
+`#include <igl/svd3x3/svd3x3_avx.h>`    | `#include <igl/svd3x3_avx.h>`
+`#include <igl/svd3x3/svd3x3_sse.h>`    | `#include <igl/svd3x3_sse.h>`
 
 
 ## Version 1.0 Changes ##

+ 0 - 0
include/igl/boost/bfs_orient.cpp → include/igl/bfs_orient.cpp


+ 0 - 0
include/igl/boost/bfs_orient.h → include/igl/bfs_orient.h


+ 0 - 56
include/igl/boost/components.cpp

@@ -1,56 +0,0 @@
-// 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 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#include "components.h"
-#include <igl/adjacency_matrix.h>
-
-//#include <boost/graph/adjacency_matrix.hpp>
-#include <boost/graph/adjacency_list.hpp>
-#include <boost/graph/connected_components.hpp>
-#include <iostream>
-#include <vector>
-#include <cassert>
-
-template <typename AScalar, typename DerivedC>
-IGL_INLINE void igl::components(
-  const Eigen::SparseMatrix<AScalar> & A,
-  Eigen::PlainObjectBase<DerivedC> & C)
-{
-  assert(A.rows() == A.cols());
-  using namespace Eigen;
-  // THIS IS DENSE:
-  //boost::adjacency_matrix<boost::undirectedS> bA(A.rows());
-  boost::adjacency_list<boost::vecS,boost::vecS,boost::undirectedS> bA(A.rows());
-  for(int j=0; j<A.outerSize();j++)
-  {
-    // Iterate over inside
-    for(typename SparseMatrix<AScalar>::InnerIterator it (A,j); it; ++it)
-    {
-      if(0 != it.value())
-      {
-        boost::add_edge(it.row(),it.col(),bA);
-      }
-    }
-  }
-  C.resize(A.rows(),1);
-  boost::connected_components(bA,C.data());
-}
-
-template <typename DerivedF, typename DerivedC>
-IGL_INLINE void igl::components(
-  const Eigen::PlainObjectBase<DerivedF> & F,
-  Eigen::PlainObjectBase<DerivedC> & C)
-{
-  Eigen::SparseMatrix<typename DerivedC::Scalar> A;
-  igl::adjacency_matrix(F,A);
-  return components(A,C);
-}
-
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template specialization
-template void igl::components<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> >&);
-#endif

+ 91 - 0
include/igl/components.cpp

@@ -0,0 +1,91 @@
+// 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 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#include "components.h"
+#include "adjacency_matrix.h"
+#include <queue>
+#include <vector>
+
+template <typename AScalar, typename DerivedC, typename Derivedcounts>
+IGL_INLINE void igl::components(
+  const Eigen::SparseMatrix<AScalar> & A,
+  Eigen::PlainObjectBase<DerivedC> & C,
+  Eigen::PlainObjectBase<Derivedcounts> & counts)
+{
+  using namespace Eigen;
+  using namespace std;
+  assert(A.rows() == A.cols() && "A should be square.");
+  const size_t n = A.rows();
+  Array<bool,Dynamic,1> seen = Array<bool,Dynamic,1>::Zero(n,1);
+  C.resize(n,1);
+  typename DerivedC::Scalar id = 0;
+  vector<typename Derivedcounts::Scalar> vcounts;
+  for(int k=0; k<A.outerSize(); ++k)
+  {
+    if(seen(k))
+    {
+      continue;
+    }
+    queue<int> Q;
+    Q.push(k);
+    vcounts.push_back(0);
+    while(!Q.empty())
+    {
+      const int f = Q.front();
+      Q.pop();
+      if(seen(f))
+      {
+        continue;
+      }
+      seen(f) = true;
+      C(f,0) = id;
+      vcounts[id]++;
+      // Iterate over inside
+      for(typename SparseMatrix<AScalar>::InnerIterator it (A,f); it; ++it)
+      {
+        const int g = it.index();
+        if(!seen(g))
+        {
+          Q.push(g);
+        }
+      }
+    }
+    id++;
+  }
+  assert((size_t) id == vcounts.size());
+  const size_t ncc = vcounts.size();
+  assert((size_t)C.maxCoeff()+1 == ncc);
+  counts.resize(ncc,1);
+  for(size_t i = 0;i<ncc;i++)
+  {
+    counts(i) = vcounts[i];
+  }
+}
+
+template <typename AScalar, typename DerivedC>
+IGL_INLINE void igl::components(
+  const Eigen::SparseMatrix<AScalar> & A,
+  Eigen::PlainObjectBase<DerivedC> & C)
+{
+  Eigen::VectorXi counts;
+  return components(A,C,counts);
+}
+
+template <typename DerivedF, typename DerivedC>
+IGL_INLINE void igl::components(
+  const Eigen::PlainObjectBase<DerivedF> & F,
+  Eigen::PlainObjectBase<DerivedC> & C)
+{
+  Eigen::SparseMatrix<typename DerivedC::Scalar> A;
+  adjacency_matrix(F,A);
+  return components(A,C);
+}
+
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template specialization
+template void igl::components<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> >&);
+#endif

+ 12 - 4
include/igl/boost/components.h → include/igl/components.h

@@ -1,24 +1,31 @@
 // This file is part of libigl, a simple c++ geometry processing library.
 // 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
+// Copyright (C) 2015 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 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_COMPONENTS_H
 #define IGL_COMPONENTS_H
-#include <igl/igl_inline.h>
+#include "igl_inline.h"
 #include <Eigen/Core>
 #include <Eigen/Sparse>
 namespace igl
 {
-  // Compute connected components of a graph represented by an adjacency matrix
+  // Compute connected components of a graph represented by an adjacency
+  // matrix. This version is faster than the previous version using boost.
   //
   // Inputs:
   //   A  n by n adjacency matrix
   // Outputs:
-  //   C  n list of component ids
+  //   C  n list of component ids (starting with 0)
+  //   counts  #components list of counts for each component
   //
+  template <typename AScalar, typename DerivedC, typename Derivedcounts>
+  IGL_INLINE void components(
+    const Eigen::SparseMatrix<AScalar> & A,
+    Eigen::PlainObjectBase<DerivedC> & C,
+    Eigen::PlainObjectBase<Derivedcounts> & counts);
   template <typename AScalar, typename DerivedC>
   IGL_INLINE void components(
     const Eigen::SparseMatrix<AScalar> & A,
@@ -42,3 +49,4 @@ namespace igl
 #endif
 
 #endif
+

+ 1 - 1
include/igl/embree/reorient_facets_raycast.cpp

@@ -9,7 +9,7 @@
 #include "../per_face_normals.h"
 #include "../doublearea.h"
 #include "../random_dir.h"
-#include "../boost/bfs_orient.h"
+#include "../bfs_orient.h"
 #include "EmbreeIntersector.h"
 #include <iostream>
 #include <random>

+ 2 - 3
include/igl/boost/orientable_patches.cpp → include/igl/orientable_patches.cpp

@@ -7,9 +7,8 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "orientable_patches.h"
 #include "components.h"
-#include <igl/sort.h>
-#include <igl/unique.h>
-#include <igl/matlab_format.h>
+#include "sort.h"
+#include "unique.h"
 #include <vector>
 #include <iostream>
 

+ 0 - 0
include/igl/boost/orientable_patches.h → include/igl/orientable_patches.h