#include "bone_visible.h" #include "EmbreeIntersector.h" #include #include #include template < typename DerivedV, typename DerivedF, typename DerivedSD, typename Derivedflag> void bone_visible( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, const Eigen::PlainObjectBase & s, const Eigen::PlainObjectBase & d, Eigen::PlainObjectBase & flag) { using namespace igl; using namespace std; using namespace Eigen; flag.resize(V.rows()); // "double sided lighting" Eigen::PlainObjectBase FF; FF.resize(F.rows()*2,F.cols()); FF << F, F.rowwise().reverse(); // Initialize intersector const EmbreeIntersector ei = EmbreeIntersector(V,FF); const double sd_norm = (s-d).norm(); // loop over mesh vertices // TODO: openmp? for(int v = 0;v1) { t = 1; sqrd = (Vv-d).array().pow(2).sum(); projv = d; } } embree::Hit hit; // perhaps 1.0 should be 1.0-epsilon, or actually since we checking the // incident face, perhaps 1.0 should be 1.0+eps const Vector3d dir = (Vv-projv)*1.0; if(ei.intersectSegment(projv,dir, hit)) { // mod for double sided lighting const int fi = hit.id0 % F.rows(); //if(v == 1228-1) //{ // Vector3d bc,P; // bc << 1 - hit.u - hit.v, hit.u, hit.v; // barycentric // P = V.row(F(fi,0))*bc(0) + // V.row(F(fi,1))*bc(1) + // V.row(F(fi,2))*bc(2); // cout<<(fi+1)<sqrd) { flag(v) = true; } }else { // no hit so vectex v is visible flag(v) = true; } } } #ifndef IGL_HEADER_ONLY // Explicit template instanciation template void bone_visible, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); template void bone_visible, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); #endif