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

Addressed alecjacobson's comments

Former-commit-id: 93919a411726cd5ce8726a06549cc7004e4fc343
Oded Stein 7 жил өмнө
parent
commit
b541b0f316

+ 12 - 12
include/igl/fem_hessian.cpp → include/igl/hessian.cpp

@@ -1,12 +1,12 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2017 Alec Jacobson <alecjacobson@gmail.com> and Oded Stein <oded.stein@columbia.edu>
-// 
-// 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 "fem_hessian.h"
+#include "hessian.h"
 #include <vector>
 
 #include <igl/grad.h>
@@ -16,22 +16,22 @@
 
 
 template <typename DerivedV, typename DerivedF, typename Scalar>
-IGL_INLINE void igl::fem_hessian(
-                            const Eigen::PlainObjectBase<DerivedV> & V,
-                            const Eigen::PlainObjectBase<DerivedF> & F,
-                            Eigen::SparseMatrix<Scalar>& H)
+IGL_INLINE void igl::hessian(
+                             const Eigen::MatrixBase<DerivedV> & V,
+                             const Eigen::MatrixBase<DerivedF> & F,
+                             Eigen::SparseMatrix<Scalar>& H)
 {
     typedef typename DerivedV::Scalar denseScalar;
     typedef typename Eigen::Matrix<denseScalar, Eigen::Dynamic, 1> VecXd;
     typedef typename Eigen::SparseMatrix<Scalar> SparseMat;
     typedef typename Eigen::DiagonalMatrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> DiagMat;
-
+    
     int dim = V.cols();
     assert((dim==2 || dim==3) && "The dimension of the vertices should be 2 or 3");
     
     //Construct the combined gradient matric
     SparseMat G;
-    igl::grad(V, F, G, false);
+    igl::grad(Eigen::PlainObjectBase<DerivedV>(V), Eigen::PlainObjectBase<DerivedF>(F), G, false);
     SparseMat GG(F.rows(), dim*V.rows());
     GG.reserve(G.nonZeros());
     for(int i=0; i<dim; ++i)
@@ -51,5 +51,5 @@ IGL_INLINE void igl::fem_hessian(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
-template void igl::fem_hessian<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
+template void igl::hessian<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
 #endif

+ 8 - 6
include/igl/fem_hessian.h → include/igl/hessian.h

@@ -17,7 +17,9 @@
 namespace igl
 {
     // Constructs the finite element Hessian matrix
-    // as described in https://arxiv.org/abs/1707.04348
+    // as described in https://arxiv.org/abs/1707.04348,
+    // Natural Boundary Conditions for Smoothing in Geometry Processing
+    // (Oded Stein, Eitan Grinspun, Max Wardetzky, Alec Jacobson)
     // The interior vertices are NOT set to zero yet.
     //
     // Inputs:
@@ -29,15 +31,15 @@ namespace igl
     //
     //
     template <typename DerivedV, typename DerivedF, typename Scalar>
-    IGL_INLINE void fem_hessian(
-                                const Eigen::PlainObjectBase<DerivedV> & V,
-                                const Eigen::PlainObjectBase<DerivedF> & F,
-                                Eigen::SparseMatrix<Scalar>& H);
+    IGL_INLINE void hessian(
+                            const Eigen::MatrixBase<DerivedV> & V,
+                            const Eigen::MatrixBase<DerivedF> & F,
+                            Eigen::SparseMatrix<Scalar>& H);
     
 }
 
 #ifndef IGL_STATIC_LIBRARY
-#  include "fem_hessian.cpp"
+#  include "hessian.cpp"
 #endif
 
 #endif

+ 12 - 12
include/igl/hessian_energy.cpp

@@ -1,23 +1,23 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2017 Alec Jacobson <alecjacobson@gmail.com> and Oded Stein <oded.stein@columbia.edu>
-// 
-// 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 "hessian_energy.h"
 #include <vector>
 
-#include <igl/fem_hessian.h>
+#include <igl/hessian.h>
 #include <igl/massmatrix.h>
 #include <igl/boundary_loop.h>
 
 
 template <typename DerivedV, typename DerivedF, typename Scalar>
 IGL_INLINE void igl::hessian_energy(
-                               const Eigen::PlainObjectBase<DerivedV> & V,
-                               const Eigen::PlainObjectBase<DerivedF> & F,
-                               Eigen::SparseMatrix<Scalar>& Q)
+                                    const Eigen::MatrixBase<DerivedV> & V,
+                                    const Eigen::MatrixBase<DerivedF> & F,
+                                    Eigen::SparseMatrix<Scalar>& Q)
 {
     typedef typename DerivedV::Scalar denseScalar;
     typedef typename Eigen::Matrix<denseScalar, Eigen::Dynamic, 1> VecXd;
@@ -26,14 +26,14 @@ IGL_INLINE void igl::hessian_energy(
     
     int dim = V.cols();
     assert((dim==2 || dim==3) && "The dimension of the vertices should be 2 or 3");
-
+    
     SparseMat M;
     igl::massmatrix(V,F,igl::MASSMATRIX_TYPE_VORONOI,M);
     
     //Kill non-interior DOFs
     VecXd Mint = M.diagonal();
     std::vector<std::vector<int> > bdryLoop;
-    igl::boundary_loop(F,bdryLoop);
+    igl::boundary_loop(Eigen::PlainObjectBase<DerivedF>(F),bdryLoop);
     for(const std::vector<int>& loop : bdryLoop)
         for(const int& bdryVert : loop)
             Mint(bdryVert) = 0.;
@@ -48,7 +48,7 @@ IGL_INLINE void igl::hessian_energy(
     
     //Compute squared Hessian
     SparseMat H;
-    igl::fem_hessian(V,F,H);
+    igl::hessian(V,F,H);
     Q = H.transpose()*stackedMinv*H;
     
 }
@@ -57,5 +57,5 @@ IGL_INLINE void igl::hessian_energy(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
-template void igl::hessian_energy<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
+template void igl::hessian_energy<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
 #endif

+ 4 - 2
include/igl/hessian_energy.h

@@ -17,6 +17,8 @@ namespace igl
 {
     // Constructs the Hessian energy matrix using mixed FEM
     // as described in https://arxiv.org/abs/1707.04348
+    // Natural Boundary Conditions for Smoothing in Geometry Processing
+    // (Oded Stein, Eitan Grinspun, Max Wardetzky, Alec Jacobson)
     //
     // Inputs:
     //   V  #V by dim list of mesh vertex positions
@@ -28,8 +30,8 @@ namespace igl
     //
     template <typename DerivedV, typename DerivedF, typename Scalar>
     IGL_INLINE void hessian_energy(
-                                   const Eigen::PlainObjectBase<DerivedV> & V,
-                                   const Eigen::PlainObjectBase<DerivedF> & F,
+                                   const Eigen::MatrixBase<DerivedV> & V,
+                                   const Eigen::MatrixBase<DerivedF> & F,
                                    Eigen::SparseMatrix<Scalar>& Q);
     
 }