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)
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);
void applyFilter(PointCloud &output) override
Filter a Point Cloud.
PointCloud represents the base class in PCL for storing collections of 3D points.
bool refineNormal(const PointCloud< NormalT > &cloud, int index, const Indices &k_indices, const std::vector< float > &k_sqr_distances, NormalT &point)
Refine an indexed point based on its neighbors, this function only writes to the normal_* fields.
A point structure representing normal coordinates and the surface curvature estimate.