40 #ifndef PCL_FILTERS_IMPL_PASSTHROUGH_HPP_
41 #define PCL_FILTERS_IMPL_PASSTHROUGH_HPP_
43 #include <pcl/filters/passthrough.h>
46 template <
typename Po
intT>
void
50 indices.resize (indices_->size ());
51 removed_indices_->resize (indices_->size ());
55 if (filter_field_name_.empty ())
58 for (
const auto ii : *indices_)
61 if (!std::isfinite ((*input_)[ii].x) ||
62 !std::isfinite ((*input_)[ii].y) ||
63 !std::isfinite ((*input_)[ii].z))
65 if (extract_removed_indices_)
66 (*removed_indices_)[rii++] = ii;
75 std::vector<pcl::PCLPointField> fields;
76 int distance_idx = pcl::getFieldIndex<PointT> (filter_field_name_, fields);
77 if (distance_idx == -1)
79 PCL_WARN (
"[pcl::%s::applyFilter] Unable to find field name in point type.\n", getClassName ().c_str ());
81 removed_indices_->clear ();
84 if (fields[distance_idx].datatype != pcl::PCLPointField::PointFieldTypes::FLOAT32)
86 PCL_ERROR (
"[pcl::%s::applyFilter] PassThrough currently only works with float32 fields. To filter fields of other types see ConditionalRemoval or FunctorFilter/FunctionFilter.\n", getClassName ().c_str ());
88 removed_indices_->clear ();
91 if (filter_field_name_ ==
"rgb")
92 PCL_WARN (
"[pcl::%s::applyFilter] You told PassThrough to operate on the 'rgb' field. This will likely not do what you expect. Consider using ConditionalRemoval or FunctorFilter/FunctionFilter.\n", getClassName ().c_str ());
93 const auto field_offset = fields[distance_idx].offset;
96 for (
const auto ii : *indices_)
99 if (!std::isfinite ((*input_)[ii].x) ||
100 !std::isfinite ((*input_)[ii].y) ||
101 !std::isfinite ((*input_)[ii].z))
103 if (extract_removed_indices_)
104 (*removed_indices_)[rii++] = ii;
109 const auto* pt_data =
reinterpret_cast<const std::uint8_t*
> (&(*input_)[ii]);
110 float field_value = 0;
111 memcpy (&field_value, pt_data + field_offset,
sizeof (
float));
114 if (!std::isfinite (field_value))
116 if (extract_removed_indices_)
117 (*removed_indices_)[rii++] = ii;
122 if (!negative_ && (field_value < filter_limit_min_ || field_value > filter_limit_max_))
124 if (extract_removed_indices_)
125 (*removed_indices_)[rii++] = ii;
130 if (negative_ && field_value >= filter_limit_min_ && field_value <= filter_limit_max_)
132 if (extract_removed_indices_)
133 (*removed_indices_)[rii++] = ii;
143 indices.resize (oii);
144 removed_indices_->resize (rii);
147 #define PCL_INSTANTIATE_PassThrough(T) template class PCL_EXPORTS pcl::PassThrough<T>;
void applyFilterIndices(Indices &indices)
Filtered results are indexed by an indices array.
IndicesAllocator<> Indices
Type used for indices in PCL.