// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2018 Alec Jacobson // // 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 "cotmatrix_intrinsic.h" #include "cotmatrix_entries.h" #include template IGL_INLINE void igl::cotmatrix_intrinsic( const Eigen::MatrixBase & l, const Eigen::MatrixBase & F, Eigen::SparseMatrix& L) { using namespace Eigen; using namespace std; // Cribbed from cotmatrix const int nverts = F.maxCoeff()+1; L.resize(nverts,nverts); Matrix edges; int simplex_size = F.cols(); // 3 for triangles, 4 for tets assert(simplex_size == 3); // This is important! it could decrease the comptuation time by a factor of 2 // Laplacian for a closed 2d manifold mesh will have on average 7 entries per // row L.reserve(10*nverts); edges.resize(3,2); edges << 1,2, 2,0, 0,1; // Gather cotangents Matrix C; cotmatrix_entries(l,C); vector > IJV; IJV.reserve(F.rows()*edges.rows()*4); // Loop over triangles for(int i = 0; i < F.rows(); i++) { // loop over edges of element for(int e = 0;e(source,dest,C(i,e))); IJV.push_back(Triplet(dest,source,C(i,e))); IJV.push_back(Triplet(source,source,-C(i,e))); IJV.push_back(Triplet(dest,dest,-C(i,e))); } } L.setFromTriplets(IJV.begin(),IJV.end()); } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation template void igl::cotmatrix_intrinsic, Eigen::Matrix, double>(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::SparseMatrix&); template void igl::cotmatrix_intrinsic, Eigen::Matrix, double>(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::SparseMatrix&); template void igl::cotmatrix_intrinsic, Eigen::Matrix, double>(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::SparseMatrix&); template void igl::cotmatrix_intrinsic, Eigen::Matrix, double>(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::SparseMatrix&); template void igl::cotmatrix_intrinsic, Eigen::Matrix, double>(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::SparseMatrix&); #endif