40 #ifndef PCL_FILTERS_IMPL_EXTRACT_INDICES_HPP_
41 #define PCL_FILTERS_IMPL_EXTRACT_INDICES_HPP_
43 #include <pcl/filters/extract_indices.h>
47 template <
typename Po
intT>
void
51 bool temp = extract_removed_indices_;
52 extract_removed_indices_ =
true;
53 this->setInputCloud (cloud);
54 applyFilterIndices (indices);
55 extract_removed_indices_ = temp;
57 std::vector<pcl::PCLPointField> fields;
59 for (
const auto& rii : (*removed_indices_))
61 auto pt_index =
static_cast<uindex_t>(rii);
62 if (pt_index >= input_->size ())
64 PCL_ERROR (
"[pcl::%s::filterDirectly] The index exceeds the size of the input. Do nothing.\n",
65 getClassName ().c_str ());
69 auto* pt_data =
reinterpret_cast<std::uint8_t*
> (&(*cloud)[pt_index]);
70 for (
const auto &field : fields)
71 memcpy (pt_data + field.offset, &user_filter_value_, sizeof (
float));
73 if (!std::isfinite (user_filter_value_))
74 cloud->is_dense =
false;
78 template <
typename Po
intT>
void
84 bool temp = extract_removed_indices_;
85 extract_removed_indices_ =
true;
86 applyFilterIndices (indices);
87 extract_removed_indices_ = temp;
90 std::vector<pcl::PCLPointField> fields;
92 for (
const auto ri : *removed_indices_)
94 auto pt_index =
static_cast<std::size_t
>(ri);
95 if (pt_index >= input_->size ())
97 PCL_ERROR (
"[pcl::%s::applyFilter] The index exceeds the size of the input. Do nothing.\n",
98 getClassName ().c_str ());
102 auto* pt_data =
reinterpret_cast<std::uint8_t*
> (&output[pt_index]);
103 for (
const auto &field : fields)
104 memcpy (pt_data + field.offset, &user_filter_value_, sizeof (
float));
106 if (!std::isfinite (user_filter_value_))
111 applyFilterIndices (indices);
117 template <
typename Po
intT>
void
120 if (indices_->size () > input_->size ())
122 PCL_ERROR (
"[pcl::%s::applyFilter] The indices size exceeds the size of the input.\n", getClassName ().c_str ());
124 removed_indices_->clear ();
132 if (extract_removed_indices_)
135 Indices full_indices (input_->size ());
136 std::iota (full_indices.begin (), full_indices.end (),
static_cast<index_t> (0));
139 Indices sorted_input_indices = *indices_;
140 std::sort (sorted_input_indices.begin (), sorted_input_indices.end ());
143 removed_indices_->clear ();
144 set_difference (full_indices.begin (), full_indices.end (), sorted_input_indices.begin (), sorted_input_indices.end (), inserter (*removed_indices_, removed_indices_->begin ()));
150 Indices full_indices (input_->size ());
151 std::iota (full_indices.begin (), full_indices.end (),
static_cast<index_t> (0));
154 Indices sorted_input_indices = *indices_;
155 std::sort (sorted_input_indices.begin (), sorted_input_indices.end ());
159 set_difference (full_indices.begin (), full_indices.end (), sorted_input_indices.begin (), sorted_input_indices.end (), inserter (indices, indices.begin ()));
161 if (extract_removed_indices_)
162 removed_indices_ = indices_;
166 #define PCL_INSTANTIATE_ExtractIndices(T) template class PCL_EXPORTS pcl::ExtractIndices<T>;
typename PointCloud::Ptr PointCloudPtr
PointCloud represents the base class in PCL for storing collections of 3D points.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields).
void copyPointCloud(const pcl::PointCloud< PointInT > &cloud_in, pcl::PointCloud< PointOutT > &cloud_out)
Copy all the fields from a given point cloud into a new point cloud.
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
IndicesAllocator<> Indices
Type used for indices in PCL.