123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include "vector_area_matrix.h"
- #include <vector>
- #include <iostream>
- #include <unsupported/Eigen/SparseExtra>
- #include <igl/boundary_facets.h>
- template <typename DerivedF, typename Scalar>
- IGL_INLINE void igl::vector_area_matrix(
- const Eigen::PlainObjectBase<DerivedF> & F,
- Eigen::SparseMatrix<Scalar>& A)
- {
- using namespace Eigen;
- using namespace std;
-
- const int n = F.maxCoeff()+1;
- MatrixXi E;
- boundary_facets(F,E);
-
- vector<Triplet<Scalar> > tripletList;
- tripletList.reserve(4*E.rows());
- for(int k = 0; k < E.rows(); k++)
- {
- int i = E(k,0);
- int j = E(k,1);
- tripletList.push_back(Triplet<Scalar>(i+n, j, -0.25));
- tripletList.push_back(Triplet<Scalar>(j, i+n, -0.25));
- tripletList.push_back(Triplet<Scalar>(i, j+n, 0.25));
- tripletList.push_back(Triplet<Scalar>(j+n, i, 0.25));
- }
-
- A.resize(n * 2, n * 2);
- A.setFromTriplets(tripletList.begin(), tripletList.end());
- }
- #ifdef IGL_STATIC_LIBRARY
- template void igl::vector_area_matrix<Eigen::Matrix<int, -1, -1, 0, -1, -1>, double>(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
- #endif
|