19 #include <pcl/filters/filter_indices.h>
20 #include <pcl/point_traits.h>
25 namespace experimental {
32 template <
typename Po
intT,
typename Function>
34 std::is_invocable_r_v<bool, Function, const PointCloud<PointT>&,
index_t>;
44 template <
typename Po
intT,
typename FunctionObject>
52 static_assert(is_function_object_for_filter_v<PointT, FunctionObjectT>,
53 "Function object signature must be similar to `bool(const "
54 "PointCloud<PointT>&, index_t)`");
57 using Base::extract_removed_indices_;
58 using Base::filter_name_;
59 using Base::negative_;
60 using Base::removed_indices_;
61 using PCL_Base::indices_;
62 using PCL_Base::input_;
80 filter_name_ =
"functor_filter";
103 indices.reserve(indices_->size());
104 if (extract_removed_indices_) {
105 removed_indices_->clear();
106 removed_indices_->reserve(indices_->size());
109 for (
const auto index : *indices_) {
112 indices.push_back(index);
114 else if (extract_removed_indices_) {
115 removed_indices_->push_back(index);
125 if (!extract_removed_indices_)
127 PCL_WARN (
"[pcl::FilterIndices<PointT>::applyFilter] extract_removed_indices_ was set to 'true' to keep the point cloud organized.\n");
128 extract_removed_indices_ =
true;
139 for (
const auto ri : *removed_indices_)
140 copyPoint(ufv, output[ri]);
142 output.is_dense =
false;
146 output.is_dense =
true;
148 pcl::copyPointCloud (*input_, indices, output);
162 filter_name_ =
"functor_filter";
178 template <
class Po
intT>
181 template <
class Po
intT>
Filter point clouds and indices based on a function object passed in the ctor.
void applyFilter(Indices &indices) override
Filtered results are indexed by an indices array.
FunctorFilter(FunctionObjectT function_object, bool extract_removed_indices=false)
Constructor.
FunctionObjectT & getFunctionObject() noexcept
PCLBase< PointT > PCL_Base
void applyFilter(PointCloud< PointT > &output) override
FunctorFilter(bool extract_removed_indices=false)
ctor to be used by derived classes with member function as FilterFunction
const FunctionObjectT & getFunctionObject() const noexcept
void setFunctionObject(FunctionObjectT function_object) const noexcept
utility function for derived class
FunctionObject FunctionObjectT
FunctionObjectT functionObject_
std::function< bool(const PointCloud< PointT > &, index_t)> FilterFunction
static constexpr bool is_function_object_for_filter_v
Checks if the function object meets the usage in FunctorFilter class.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.