#include "per_face_normals.h" #include #define SQRT_ONE_OVER_THREE 0.57735026918962573 template IGL_INLINE void igl::per_face_normals( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase & Z, Eigen::PlainObjectBase & N) { N.resize(F.rows(),3); // loop over faces int Frows = F.rows(); #pragma omp parallel for for(int i = 0; i < Frows;i++) { Eigen::Matrix v1 = V.row(F(i,1)) - V.row(F(i,0)); Eigen::Matrix v2 = V.row(F(i,2)) - V.row(F(i,0)); N.row(i) = v1.cross(v2);//.normalized(); typename DerivedV::Scalar r = N.row(i).norm(); if(r == 0) { N.row(i) = Z; }else { N.row(i) /= r; } } } template IGL_INLINE void igl::per_face_normals( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, Eigen::PlainObjectBase & N) { using namespace Eigen; Matrix Z(0,0,0); return per_face_normals(V,F,Z,N); } #ifndef IGL_HEADER_ONLY // Explicit template specialization template void igl::per_face_normals, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); template void igl::per_face_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); #endif