40 #ifndef PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
41 #define PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
43 #include <pcl/filters/radius_outlier_removal.h>
44 #include <pcl/common/io.h>
47 template <
typename Po
intT>
void
50 std::vector<int> indices;
53 bool temp = extract_removed_indices_;
54 extract_removed_indices_ =
true;
55 applyFilterIndices (indices);
56 extract_removed_indices_ = temp;
59 for (
const auto ri : *removed_indices_)
61 if (!std::isfinite (user_filter_value_))
66 applyFilterIndices (indices);
72 template <
typename Po
intT>
void
75 if (search_radius_ == 0.0)
77 PCL_ERROR (
"[pcl::%s::applyFilter] No radius defined!\n", getClassName ().c_str ());
79 removed_indices_->clear ();
86 if (input_->isOrganized ())
91 searcher_->setInputCloud (input_);
94 std::vector<int> nn_indices (indices_->size ());
95 std::vector<float> nn_dists (indices_->size ());
96 indices.resize (indices_->size ());
97 removed_indices_->resize (indices_->size ());
101 if (input_->is_dense)
104 int mean_k = min_pts_radius_ + 1;
105 double nn_dists_max = search_radius_ * search_radius_;
107 for (std::vector<int>::const_iterator it = indices_->begin (); it != indices_->end (); ++it)
110 int k = searcher_->nearestKSearch (*it, mean_k, nn_indices, nn_dists);
114 bool chk_neighbors =
true;
119 chk_neighbors =
false;
120 if (nn_dists_max < nn_dists[k-1])
122 chk_neighbors =
true;
127 chk_neighbors =
true;
128 if (nn_dists_max < nn_dists[k-1])
130 chk_neighbors =
false;
137 chk_neighbors =
true;
139 chk_neighbors =
false;
146 if (extract_removed_indices_)
147 (*removed_indices_)[rii++] = *it;
152 indices[oii++] = *it;
158 for (std::vector<int>::const_iterator it = indices_->begin (); it != indices_->end (); ++it)
162 int k = searcher_->radiusSearch (*it, search_radius_, nn_indices, nn_dists);
166 if ((!negative_ && k <= min_pts_radius_) || (negative_ && k > min_pts_radius_))
168 if (extract_removed_indices_)
169 (*removed_indices_)[rii++] = *it;
174 indices[oii++] = *it;
179 indices.resize (oii);
180 removed_indices_->resize (rii);
183 #define PCL_INSTANTIATE_RadiusOutlierRemoval(T) template class PCL_EXPORTS pcl::RadiusOutlierRemoval<T>;
185 #endif // PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_