فهرست منبع

split Hessians into two files

Former-commit-id: b40d1f0e9f30829382c737ee5dd166bac072c1a4
Oded Stein 7 سال پیش
والد
کامیت
51053408d2
4فایلهای تغییر یافته به همراه100 افزوده شده و 56 حذف شده
  1. 55 0
      include/igl/fem_hessian.cpp
  2. 43 0
      include/igl/fem_hessian.h
  3. 2 37
      include/igl/hessian_energy.cpp
  4. 0 19
      include/igl/hessian_energy.h

+ 55 - 0
include/igl/fem_hessian.cpp

@@ -0,0 +1,55 @@
+// 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 
+// obtain one at http://mozilla.org/MPL/2.0/.
+
+#include "fem_hessian.h"
+#include <vector>
+
+#include <igl/grad.h>
+#include <igl/doublearea.h>
+#include <igl/repdiag.h>
+
+
+
+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)
+{
+    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);
+    SparseMat GG(F.rows(), dim*V.rows());
+    GG.reserve(G.nonZeros());
+    for(int i=0; i<dim; ++i)
+        GG.middleCols(i*G.cols(), G.cols()) = G.middleRows(i*F.rows(), F.rows());
+    SparseMat D;
+    igl::repdiag(GG,dim,D);
+    
+    //Compute area matrix
+    VecXd areas;
+    igl::doublearea(V, F, areas);
+    DiagMat A = (0.5*areas).replicate(dim,1).asDiagonal();
+    
+    //Compute FEM Hessian
+    H = D.transpose()*A*G;
+}
+
+
+#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>&);
+#endif

+ 43 - 0
include/igl/fem_hessian.h

@@ -0,0 +1,43 @@
+// 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
+// obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef IGL_FEM_HESSIAN_H
+#define IGL_FEM_HESSIAN_H
+#include "igl_inline.h"
+
+#include <Eigen/Dense>
+#include <Eigen/Sparse>
+
+
+namespace igl
+{
+    // Constructs the finite element Hessian matrix
+    // as described in https://arxiv.org/abs/1707.04348
+    // The interior vertices are NOT set to zero yet.
+    //
+    // Inputs:
+    //   V  #V by dim list of mesh vertex positions
+    //   F  #F by 3 list of mesh faces (must be triangles)
+    // Outputs:
+    //   H  #V by #V Hessian energy matrix, each column i corresponding to V(i,:)
+    //
+    //
+    //
+    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);
+    
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "fem_hessian.cpp"
+#endif
+
+#endif

+ 2 - 37
include/igl/hessian_energy.cpp

@@ -8,11 +8,10 @@
 #include "hessian_energy.h"
 #include <vector>
 
-#include <igl/grad.h>
-#include <igl/doublearea.h>
+#include <igl/fem_hessian.h>
 #include <igl/massmatrix.h>
 #include <igl/boundary_loop.h>
-#include <igl/repdiag.h>
+
 
 template <typename DerivedV, typename DerivedF, typename Scalar>
 IGL_INLINE void igl::hessian_energy(
@@ -55,42 +54,8 @@ IGL_INLINE void igl::hessian_energy(
 }
 
 
-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)
-{
-    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);
-    SparseMat GG(F.rows(), dim*V.rows());
-    GG.reserve(G.nonZeros());
-    for(int i=0; i<dim; ++i)
-        GG.middleCols(i*G.cols(), G.cols()) = G.middleRows(i*F.rows(), F.rows());
-    SparseMat D;
-    igl::repdiag(GG,dim,D);
-    
-    //Compute area matrix
-    VecXd areas;
-    igl::doublearea(V, F, areas);
-    DiagMat A = (0.5*areas).replicate(dim,1).asDiagonal();
-    
-    //Compute FEM Hessian
-    H = D.transpose()*A*G;
-}
-
 
 #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::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>&);
 #endif

+ 0 - 19
include/igl/hessian_energy.h

@@ -32,25 +32,6 @@ namespace igl
                                    const Eigen::PlainObjectBase<DerivedF> & F,
                                    Eigen::SparseMatrix<Scalar>& Q);
     
-    
-    // Constructs the finite element Hessian matrix
-    // as described in https://arxiv.org/abs/1707.04348
-    // The interior vertices are NOT set to zero yet.
-    //
-    // Inputs:
-    //   V  #V by dim list of mesh vertex positions
-    //   F  #F by 3 list of mesh faces (must be triangles)
-    // Outputs:
-    //   H  #V by #V Hessian energy matrix, each column i corresponding to V(i,:)
-    //
-    //
-    //
-    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);
-    
 }
 
 #ifndef IGL_STATIC_LIBRARY