40 #ifndef PCL_FILTERS_IMPL_EXTRACT_INDICES_HPP_ 41 #define PCL_FILTERS_IMPL_EXTRACT_INDICES_HPP_ 43 #include <pcl/filters/extract_indices.h> 44 #include <pcl/common/io.h> 47 template <
typename Po
intT>
void 50 std::vector<int> indices;
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 (
int rii = 0; rii < static_cast<int> (removed_indices_->size ()); ++rii)
61 uint8_t* pt_data =
reinterpret_cast<uint8_t*
> (&cloud->points[(*removed_indices_)[rii]]);
62 for (
int fi = 0; fi < static_cast<int> (fields.size ()); ++fi)
63 memcpy (pt_data + fields[fi].offset, &user_filter_value_,
sizeof (
float));
65 if (!pcl_isfinite (user_filter_value_))
66 cloud->is_dense =
false;
70 template <
typename Po
intT>
void 73 std::vector<int> indices;
76 bool temp = extract_removed_indices_;
77 extract_removed_indices_ =
true;
78 applyFilterIndices (indices);
79 extract_removed_indices_ = temp;
82 std::vector<pcl::PCLPointField> fields;
84 for (
int rii = 0; rii < static_cast<int> (removed_indices_->size ()); ++rii)
86 uint8_t* pt_data =
reinterpret_cast<uint8_t*
> (&output.
points[(*removed_indices_)[rii]]);
87 for (
int fi = 0; fi < static_cast<int> (fields.size ()); ++fi)
88 memcpy (pt_data + fields[fi].offset, &user_filter_value_,
sizeof (
float));
90 if (!pcl_isfinite (user_filter_value_))
95 applyFilterIndices (indices);
101 template <
typename Po
intT>
void 104 if (indices_->size () > input_->points.size ())
106 PCL_ERROR (
"[pcl::%s::applyFilter] The indices size exceeds the size of the input.\n", getClassName ().c_str ());
108 removed_indices_->clear ();
116 if (extract_removed_indices_)
119 std::vector<int> full_indices (input_->points.size ());
120 for (
int fii = 0; fii < static_cast<int> (full_indices.size ()); ++fii)
121 full_indices[fii] = fii;
124 std::vector<int> sorted_input_indices = *indices_;
125 std::sort (sorted_input_indices.begin (), sorted_input_indices.end ());
128 removed_indices_->clear ();
129 set_difference (full_indices.begin (), full_indices.end (), sorted_input_indices.begin (), sorted_input_indices.end (), inserter (*removed_indices_, removed_indices_->begin ()));
135 std::vector<int> full_indices (input_->points.size ());
136 for (
int fii = 0; fii < static_cast<int> (full_indices.size ()); ++fii)
137 full_indices[fii] = fii;
140 std::vector<int> sorted_input_indices = *indices_;
141 std::sort (sorted_input_indices.begin (), sorted_input_indices.end ());
145 set_difference (full_indices.begin (), full_indices.end (), sorted_input_indices.begin (), sorted_input_indices.end (), inserter (indices, indices.begin ()));
147 if (extract_removed_indices_)
148 removed_indices_ = indices_;
152 #define PCL_INSTANTIATE_ExtractIndices(T) template class PCL_EXPORTS pcl::ExtractIndices<T>; 154 #endif // PCL_FILTERS_IMPL_EXTRACT_INDICES_HPP_ std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
PCL_EXPORTS void copyPointCloud(const pcl::PCLPointCloud2 &cloud_in, const std::vector< int > &indices, pcl::PCLPointCloud2 &cloud_out)
Extract the indices of a given point cloud as a new point cloud.
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).