فهرست منبع

Revert "Make avg_edge_length() count interior edges only once."

Former-commit-id: e797ac9b60eccfebd4eb2b5e9a132d4f23e2a482
Alec Jacobson 6 سال پیش
والد
کامیت
7b6ebdc3ea
5فایلهای تغییر یافته به همراه32 افزوده شده و 35 حذف شده
  1. 5 6
      include/igl/adjacency_matrix.cpp
  2. 13 13
      include/igl/avg_edge_length.cpp
  3. 5 5
      include/igl/avg_edge_length.h
  4. 5 6
      include/igl/edges.cpp
  5. 4 5
      include/igl/median.cpp

+ 5 - 6
include/igl/adjacency_matrix.cpp

@@ -1,9 +1,9 @@
 // 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 "adjacency_matrix.h"
 
@@ -13,7 +13,7 @@
 
 template <typename DerivedF, typename T>
 IGL_INLINE void igl::adjacency_matrix(
-  const Eigen::MatrixBase<DerivedF> & F,
+  const Eigen::MatrixBase<DerivedF> & F, 
   Eigen::SparseMatrix<T>& A)
 {
   using namespace std;
@@ -71,5 +71,4 @@ IGL_INLINE void igl::adjacency_matrix(
 template void igl::adjacency_matrix<Eigen::Matrix<int, -1, -1, 0, -1, -1>, bool>(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<bool, 0, int>&);
 template void igl::adjacency_matrix<Eigen::Matrix<int, -1, -1, 0, -1, -1>, double>(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
 template void igl::adjacency_matrix<Eigen::Matrix<int, -1, -1, 0, -1, -1>, int>(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<int, 0, int>&);
-template void igl::adjacency_matrix<Eigen::Matrix<int, -1, 3, 0, -1, 3>, int>(Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::SparseMatrix<int, 0, int>&);
 #endif

+ 13 - 13
include/igl/avg_edge_length.cpp

@@ -1,12 +1,11 @@
 // 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 "avg_edge_length.h"
-#include "edges.h"
 
 #include <vector>
 
@@ -15,19 +14,20 @@ IGL_INLINE double igl::avg_edge_length(
   const Eigen::MatrixBase<DerivedV>& V,
   const Eigen::MatrixBase<DerivedF>& F)
 {
-  typedef typename DerivedF::Scalar Index;
-  Eigen::Matrix<Index, Eigen::Dynamic, 2> E;
-
-  igl::edges(F, E);
-
   double avg = 0;
+  long int count = 0;
 
-  for (unsigned i=0;i<E.rows();++i)
+  // Augh. Technically this is double counting interior edges...
+  for (unsigned i=0;i<F.rows();++i)
   {
-    avg += (V.row(E(i,0)) - V.row(E(i,1))).norm();
+    for (unsigned j=0;j<F.cols();++j)
+    {
+      ++count;
+      avg += (V.row(F(i,j)) - V.row(F(i,(j+1)%F.cols()))).norm();
+    }
   }
 
-  return avg / (double) E.rows();
+  return avg / (double) count;
 }
 
 #ifdef IGL_STATIC_LIBRARY

+ 5 - 5
include/igl/avg_edge_length.h

@@ -1,9 +1,9 @@
 // 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/.
 #ifndef IGL_AVERAGEEDGELENGTH_H
 #define IGL_AVERAGEEDGELENGTH_H
@@ -13,7 +13,7 @@
 #include <string>
 #include <vector>
 
-namespace igl
+namespace igl 
 {
   // Compute the average edge length for the given triangle mesh
   // Templates:

+ 5 - 6
include/igl/edges.cpp

@@ -1,9 +1,9 @@
 // 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 "edges.h"
 #include "adjacency_matrix.h"
@@ -11,7 +11,7 @@
 
 template <typename DerivedF, typename DerivedE>
 IGL_INLINE void igl::edges(
-  const Eigen::MatrixBase<DerivedF> & F,
+  const Eigen::MatrixBase<DerivedF> & F, 
   Eigen::PlainObjectBase<DerivedE> & E)
 {
   // build adjacency matrix
@@ -44,5 +44,4 @@ IGL_INLINE void igl::edges(
 // Explicit template instantiation
 template void igl::edges<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 2, 0, -1, 2> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> >&);
 template void igl::edges<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::edges<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> >&);
 #endif

+ 4 - 5
include/igl/median.cpp

@@ -1,9 +1,9 @@
 // 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 "median.h"
 #include "matrix_to_list.h"
@@ -42,5 +42,4 @@ IGL_INLINE bool igl::median(
 template bool igl::median<Eigen::Block<Eigen::Matrix<float, -1, -1, 0, -1, -1>, -1, 1, true>, float>(Eigen::MatrixBase<Eigen::Block<Eigen::Matrix<float, -1, -1, 0, -1, -1>, -1, 1, true> > const&, float&);
 // generated by autoexplicit.sh
 template bool igl::median<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, 1, true>, double>(Eigen::MatrixBase<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, 1, true> > const&, double&);
-template bool igl::median<Eigen::Matrix<double, -1, 1, 0, -1, 1>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, double&);
 #endif