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);
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.