#include "voronoi_mass.h" #include "circumradius.h" #include "centroid.h" #include "unique_simplices.h" template < typename DerivedV, typename DerivedT, typename DerivedM> void igl::voronoi_mass( const Eigen::MatrixBase & V, const Eigen::MatrixBase & T, Eigen::PlainObjectBase & M) { // DerivedM::Scalar must be same as DerivedV::Scalar static_assert(std::is_same::value, "DerivedM::Scalar must be same as DerivedV::Scalar"); // DerivedM must be a vector (rows or cols at compile time = 1) static_assert(DerivedM::RowsAtCompileTime == 1 || DerivedM::ColsAtCompileTime == 1, "DerivedM must be a vector (rows or cols at compile time = 1)"); // DerivedT must have Dynamic or 4 cols static_assert(DerivedT::ColsAtCompileTime == Eigen::Dynamic || DerivedT::ColsAtCompileTime == 4, "DerivedT must have Dynamic or 4 cols"); assert(T.cols() == 4 && "Tetrahedra should have 4 vertices"); // DerivedV must have Dynamic or 3 cols static_assert(DerivedV::ColsAtCompileTime == Eigen::Dynamic || DerivedV::ColsAtCompileTime == 3, "DerivedV must have Dynamic or 3 cols"); assert(V.cols() == 3 && "V should have 3 columns"); using Scalar = typename DerivedV::Scalar; using VectorXS = Eigen::Matrix; using MatrixX3S = Eigen::Matrix; using MatrixX4S = Eigen::Matrix; using MatrixX3I = Eigen::Matrix; using MatrixX4I = Eigen::Matrix; MatrixX3I F; MatrixX4I I; { MatrixX3I allF(T.rows()*T.cols(),3); for(int i = 0;i U(8,V.cols()); U.row(0) = V.row(T(i,j)); // edge circumcenters for(int k = 1;k<4;k++) { U.row(k) = 0.5*(U.row(0) + V.row(T(i,(j+k)%4))); } // face circumcenters { U.block(4,0,3,V.cols()) << CF.row(I(i,(j+1)%4)), CF.row(I(i,(j+2)%4)), CF.row(I(i,(j+3)%4)); } // Tet circumcenter { U.row(7) = CT.row(i); } Eigen::Matrix Fij(12,3); Fij<< 4,2,0, 5,3,0, 6,1,0, 7,2,4, 7,3,5, 7,1,6, 4,0,3, 5,0,1, 6,0,2, 7,4,3, 7,5,1, 7,6,2; if(j%2) { Fij = Fij.rowwise().reverse().eval(); } Scalar vol; { Eigen::Matrix cen; igl::centroid(U,Fij,cen,vol); } M(T(i,j)) += vol; } } } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation template void igl::voronoi_mass, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); template void igl::voronoi_mass, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); template void igl::voronoi_mass, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); template void igl::voronoi_mass, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); #endif