47 #ifndef _OPENGR_UTILS_GEOMETRY_H_ 48 #define _OPENGR_UTILS_GEOMETRY_H_ 50 #include "gr/utils/disablewarnings.h" 57 template <
typename PointContainer,
typename VecContainer>
59 VecContainer &normals){
60 using Point =
typename PointContainer::value_type;
61 using Vector =
typename VecContainer::value_type;
62 if (v.size() == normals.size()){
63 typename PointContainer::iterator itV = v.begin();
64 typename VecContainer::iterator itN = normals.begin();
67 for( ; itV != v.end(); itV++, itN++){
69 if ((*itV).normal().squaredNorm() < 0.01){
70 (*itN) = {0., 0., 0.};
71 (*itV).set_normal({0., 0., 0.});
80 std::cout <<
"Found " << nb <<
" vertices with invalid normals" << std::endl;
85 template <
typename PointContainer>
87 Eigen::Ref<
const Eigen::Matrix<
typename PointContainer::value_type::Scalar, 4, 4>> tr){
88 using Scalar =
typename PointContainer::value_type::Scalar;
89 auto tr3x3 = tr.
template block<3,3>(0,0);
90 for (
auto& vertex : v){
91 vertex.pos() = (tr * vertex.pos().homogeneous()).
template head<3>();
92 vertex.set_normal(tr3x3 * vertex.normal());
static void CleanInvalidNormals(PointContainer &v, VecContainer &normals)
Definition: geometry.h:58
static void TransformPointCloud(PointContainer &v, Eigen::Ref< const Eigen::Matrix< typename PointContainer::value_type::Scalar, 4, 4 >> tr)
Definition: geometry.h:86