40#ifndef PCL_FILTERS_IMPL_PASSTHROUGH_HPP_
41#define PCL_FILTERS_IMPL_PASSTHROUGH_HPP_
43#include <pcl/filters/passthrough.h>
46template <
typename Po
intT>
void
55 if (filter_field_name_.empty ())
61 if (!std::isfinite ((*
input_)[ii].x) ||
62 !std::isfinite ((*
input_)[ii].y) ||
63 !std::isfinite ((*
input_)[ii].z))
66 (*removed_indices_)[rii++] = ii;
75 std::vector<pcl::PCLPointField>
fields;
77 if (distance_idx == -1)
79 PCL_WARN (
"[pcl::%s::applyFilter] Unable to find field name in point type.\n",
getClassName ().c_str ());
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 ());
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;
99 if (!std::isfinite ((*
input_)[ii].x) ||
100 !std::isfinite ((*
input_)[ii].y) ||
101 !std::isfinite ((*
input_)[ii].z))
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))
117 (*removed_indices_)[rii++] = ii;
122 if (!
negative_ && (field_value < filter_limit_min_ || field_value > filter_limit_max_))
125 (*removed_indices_)[rii++] = ii;
130 if (
negative_ && field_value >= filter_limit_min_ && field_value <= filter_limit_max_)
133 (*removed_indices_)[rii++] = ii;
143 indices.resize (oii);
147#define PCL_INSTANTIATE_PassThrough(T) template class PCL_EXPORTS pcl::PassThrough<T>;
bool extract_removed_indices_
Set to true if we want to return the indices of the removed points.
const std::string & getClassName() const
Get a string representation of the name of this class.
IndicesPtr removed_indices_
Indices of the points that are removed.
bool negative_
False = normal filter behavior (default), true = inverted behavior.
PointCloudConstPtr input_
The input point cloud dataset.
IndicesPtr indices_
A pointer to the vector of point indices to use.
void applyFilterIndices(Indices &indices)
Filtered results are indexed by an indices array.
int getFieldIndex(const pcl::PointCloud< PointT > &, const std::string &field_name, std::vector< pcl::PCLPointField > &fields)
IndicesAllocator<> Indices
Type used for indices in PCL.