#include "smooth_corner_adjacency.h" #include "vertex_triangle_adjacency.h" #include "matlab_format.h" #include "parallel_for.h" #include "unzip_corners.h" #include void igl::smooth_corner_adjacency( const Eigen::MatrixXd & V, const Eigen::MatrixXi & F, const double corner_threshold_radians, Eigen::VectorXi & CI, Eigen::VectorXi & CC) { typedef double Scalar; typedef Eigen::Index Index; Eigen::Matrix VF,NI; igl::vertex_triangle_adjacency(F,V.rows(),VF,NI); // unit normals Eigen::Matrix FN(F.rows(),3); igl::parallel_for(F.rows(),[&](const Index f) { const Eigen::Matrix v10 = V.row(F(f,1))-V.row(F(f,0)); const Eigen::Matrix v20 = V.row(F(f,2))-V.row(F(f,0)); const Eigen::Matrix n = v10.cross(v20); const Scalar a = n.norm(); FN.row(f) = n/a; },10000); // number of faces const Index m = F.rows(); // valence of faces const Index n = F.cols(); assert(n == 3); CI.resize(m*n*8); CI.setConstant(-1); Index ncc = 0; Index ci = -1; // assumes that ci is strictly increasing and we're appending to CI const auto append_CI = [&](Index nf) { // make room if(ncc >= CI.size()) { CI.conservativeResize(CI.size()*2+1); } CI(ncc++) = nf; CC(ci+1)++; }; CC.resize(m*3+1); CC.setConstant(-1); CC(0) = 0; const Scalar cos_thresh = cos(corner_threshold_radians); // parallelizing this probably requires map-reduce for(Index i = 0;i cos_thresh) { append_CI(nf); } } } } CI.conservativeResize(ncc); } void igl::smooth_corner_adjacency( const Eigen::MatrixXi & FV, const Eigen::MatrixXi & FN, Eigen::VectorXi & CI, Eigen::VectorXi & CC) { typedef double Scalar; typedef Eigen::Index Index; assert(FV.rows() == FN.rows()); assert(FV.cols() == 3); assert(FN.cols() == 3); Eigen::VectorXi J; Index nu = -1; { Eigen::MatrixXi U; Eigen::MatrixXi _; igl::unzip_corners({FV,FN},U,_,J); nu = U.rows(); assert(J.maxCoeff() == nu-1); } // could use linear arrays here if every becomes bottleneck std::vector> U2F(nu); const Index m = FV.rows(); for(Index j = 0;j<3;j++) { for(Index i = 0;i= CI.size()) { CI.conservativeResize(CI.size()*2+1); } CI(ncc++) = nf; CC(ci+1)++; }; for(Index i = 0;i