1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- // This file is part of libigl, a simple c++ geometry processing library.
- //
- // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
- //
- // This Source Code Form is subject to the terms of the Mozilla Public License
- // v. 2.0. If a copy of the MPL was not distributed with this file, You can
- // obtain one at http://mozilla.org/MPL/2.0/.
- #include "per_vertex_normals.h"
- #include "per_face_normals.h"
- template <typename DerivedV, typename DerivedF>
- IGL_INLINE void igl::per_vertex_normals(
- const Eigen::PlainObjectBase<DerivedV>& V,
- const Eigen::PlainObjectBase<DerivedF>& F,
- Eigen::PlainObjectBase<DerivedV> & N)
- {
- Eigen::PlainObjectBase<DerivedV> PFN;
- igl::per_face_normals(V,F,PFN);
- return igl::per_vertex_normals(V,F,PFN,N);
- }
- template <typename DerivedV, typename DerivedF>
- IGL_INLINE void igl::per_vertex_normals(
- const Eigen::PlainObjectBase<DerivedV>& V,
- const Eigen::PlainObjectBase<DerivedF>& F,
- const Eigen::PlainObjectBase<DerivedV>& FN,
- Eigen::PlainObjectBase<DerivedV> & N)
- {
- // Resize for output
- N.setZero(V.rows(),3);
- // loop over faces
- const int Frows = F.rows();
- //// Minimum number of iterms per openmp thread
- //#ifndef IGL_OMP_MIN_VALUE
- //# define IGL_OMP_MIN_VALUE 1000
- //#endif
- //#pragma omp parallel for if (Frows>IGL_OMP_MIN_VALUE)
- for(int i = 0; i < Frows;i++)
- {
- // throw normal at each corner
- for(int j = 0; j < 3;j++)
- {
- // Does this need to be critical?
- //#pragma omp critical
- N.row(F(i,j)) += FN.row(i);
- }
- }
- N.rowwise().normalize();
- }
- #ifndef IGL_HEADER_ONLY
- // Explicit template specialization
- // generated by autoexplicit.sh
- template void igl::per_vertex_normals<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
- template void igl::per_vertex_normals<Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&);
- template void igl::per_vertex_normals<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
- #endif
|