41 #ifndef PCL_FILTERS_IMPL_NORMAL_REFINEMENT_H_
42 #define PCL_FILTERS_IMPL_NORMAL_REFINEMENT_H_
44 #include <pcl/filters/normal_refinement.h>
47 template <
typename NormalT>
void
53 PCL_ERROR (
"[pcl::%s::applyFilter] No source was input!\n",
54 getClassName ().c_str ());
61 if (k_indices_.empty () || k_sqr_distances_.empty ())
63 PCL_ERROR (
"[pcl::%s::applyFilter] No point correspondences given! Returning original input.\n",
64 getClassName ().c_str ());
69 const unsigned int size = k_indices_.size ();
70 if (k_sqr_distances_.size () != size || input_->size () != size)
72 PCL_ERROR (
"[pcl::%s::applyFilter] Inconsistency between size of correspondence indices/distances or input! Returning original input.\n",
73 getClassName ().c_str ());
78 for (
unsigned int i = 0; i < max_iterations_; ++i)
81 PointCloud tmp = output;
88 for(
unsigned int j = 0; j < size; ++j)
94 if (
refineNormal (output, j, k_indices_[j], k_sqr_distances_[j], tmpj))
97 const NormalT& outputj = output[j];
98 ddot += tmpj.normal_x * outputj.normal_x + tmpj.normal_y * outputj.normal_y + tmpj.normal_z * outputj.normal_z;
104 ddot /=
static_cast<float> (num_valids);
113 if (ddot < convergence_threshold_)
115 PCL_DEBUG(
"[pcl::%s::applyFilter] Converged after %i iterations with mean error of %f.\n",
116 getClassName ().c_str (), i+1, ddot);