123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #include "per_corner_normals.h"
- #include "vertex_triangle_adjacency.h"
- #include "per_face_normals.h"
- #include "PI.h"
- template <typename DerivedV, typename DerivedF, typename DerivedCN>
- IGL_INLINE void igl::per_corner_normals(
- const Eigen::MatrixBase<DerivedV>& V,
- const Eigen::MatrixBase<DerivedF>& F,
- const double corner_threshold,
- Eigen::PlainObjectBase<DerivedCN> & CN)
- {
- using namespace Eigen;
- using namespace std;
- Eigen::Matrix<typename DerivedV::Scalar,Eigen::Dynamic,3> FN;
- per_face_normals(V,F,FN);
- vector<vector<int> > VF,VFi;
- vertex_triangle_adjacency(V.rows(),F,VF,VFi);
- return per_corner_normals(V,F,FN,VF,corner_threshold,CN);
- }
- template <
- typename DerivedV,
- typename DerivedF,
- typename DerivedFN,
- typename DerivedCN>
- IGL_INLINE void igl::per_corner_normals(
- const Eigen::MatrixBase<DerivedV>& V,
- const Eigen::MatrixBase<DerivedF>& F,
- const Eigen::MatrixBase<DerivedFN>& FN,
- const double corner_threshold,
- Eigen::PlainObjectBase<DerivedCN> & CN)
- {
- using namespace Eigen;
- using namespace std;
- vector<vector<int> > VF,VFi;
- vertex_triangle_adjacency(V.rows(),F,VF,VFi);
- return per_corner_normals(V,F,FN,VF,corner_threshold,CN);
- }
- template <
- typename DerivedV,
- typename DerivedF,
- typename DerivedFN,
- typename IndexType,
- typename DerivedCN>
- IGL_INLINE void igl::per_corner_normals(
- const Eigen::MatrixBase<DerivedV>& ,
- const Eigen::MatrixBase<DerivedF>& F,
- const Eigen::MatrixBase<DerivedFN>& FN,
- const std::vector<std::vector<IndexType> >& VF,
- const double corner_threshold,
- Eigen::PlainObjectBase<DerivedCN> & CN)
- {
- using namespace Eigen;
- using namespace std;
-
- const int m = F.rows();
-
- const int n = F.cols();
-
- CN.setZero(m*n,3);
-
- for(size_t i = 0;int(i)<m;i++)
- {
-
- Eigen::Matrix<typename DerivedV::Scalar,3,1> fn = FN.row(i);
-
- for(size_t j = 0;int(j)<n;j++)
- {
- const std::vector<IndexType> &incident_faces = VF[F(i,j)];
-
- for(int k = 0;k<(int)incident_faces.size();k++)
- {
- Eigen::Matrix<typename DerivedV::Scalar,3,1> ifn = FN.row(incident_faces[k]);
-
- double dp = fn.dot(ifn);
-
- if(dp > cos(corner_threshold*PI/180))
- {
-
- CN.row(i*n+j) += ifn;
-
- }else
- {
- }
- }
-
- CN.row(i*n+j).normalize();
- }
- }
- }
- #ifdef IGL_STATIC_LIBRARY
- template void igl::per_corner_normals<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
- template void igl::per_corner_normals<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
- template void igl::per_corner_normals<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
- template void igl::per_corner_normals<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
- template void igl::per_corner_normals<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, int, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
- #endif
|