// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2014 Daniele Panozzo // // 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 "lscm.h" #include "lscm_hessian.h" #include "massmatrix.h" #include "repdiag.h" #include "eigs.h" #include "min_quad_with_fixed.h" #include template < typename DerivedV, typename DerivedF, typename Derivedb, typename Derivedbc, typename DerivedV_uv, typename QScalar> IGL_INLINE bool igl::lscm( const Eigen::MatrixBase & V, const Eigen::MatrixBase & F, const Eigen::MatrixBase & b, const Eigen::MatrixBase & bc, Eigen::PlainObjectBase & V_uv, Eigen::SparseMatrix & Q) { using namespace Eigen; using namespace std; igl::lscm_hessian(V,F,Q); Eigen::Matrix b_flat(b.size()*bc.cols(),1); Eigen::Matrix bc_flat(bc.size(),1); for(int c = 0;c data; if(!igl::min_quad_with_fixed_precompute(Q,b_flat,SparseMatrix(),true,data)) { return false; } MatrixXd W_flat; if(!min_quad_with_fixed_solve(data,B_flat,bc_flat,VectorXd(),W_flat)) { return false; } assert(W_flat.rows() == V.rows()*2); V_uv.resize(V.rows(),2); for (unsigned i=0;i IGL_INLINE bool igl::lscm( const Eigen::MatrixBase & V, const Eigen::MatrixBase & F, const Eigen::MatrixBase & b, const Eigen::MatrixBase & bc, Eigen::PlainObjectBase & V_uv) { Eigen::SparseMatrix Q; return lscm(V, F, b, bc, V_uv, Q); } template < typename DerivedV, typename DerivedF, typename DerivedV_uv> IGL_INLINE bool igl::lscm( const Eigen::MatrixBase & V, const Eigen::MatrixBase & F, Eigen::PlainObjectBase & V_uv) { using Scalar = typename DerivedV_uv::Scalar; Eigen::SparseMatrix Q; igl::lscm_hessian(V,F,Q); Eigen::SparseMatrix M; igl::massmatrix(V,F,igl::MASSMATRIX_TYPE_DEFAULT,M); Eigen::SparseMatrix M2; igl::repdiag(M,2,M2); Eigen::Matrix U; Eigen::Matrix S; bool success = igl::eigs(Q,M2,3,igl::EIGS_TYPE_SM,U,S); if(!success) { return false; } V_uv.resize(V.rows(),2); V_uv<< U.col(0).head(V.rows()),U.col(0).tail(V.rows()); return true; } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh template bool igl::lscm, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); // generated by autoexplicit.sh template bool igl::lscm, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); #endif