Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <pcl/filters/impl/extract_indices.hpp>
00042
00044 void
00045 pcl::ExtractIndices<pcl::PCLPointCloud2>::applyFilter (PCLPointCloud2 &output)
00046 {
00047
00048 if (indices_->empty () || (input_->width * input_->height == 0))
00049 {
00050 output.width = output.height = 0;
00051 output.data.clear ();
00052
00053 if (negative_)
00054 output = *input_;
00055 return;
00056 }
00057 if (indices_->size () == (input_->width * input_->height))
00058 {
00059
00060 if (negative_)
00061 {
00062 output.width = output.height = 0;
00063 output.data.clear ();
00064 }
00065
00066 else
00067 output = *input_;
00068 return;
00069 }
00070
00071
00072 output.is_bigendian = input_->is_bigendian;
00073 output.point_step = input_->point_step;
00074 output.height = 1;
00075
00076 output.is_dense = false;
00077
00078 if (negative_)
00079 {
00080
00081 std::vector<int> all_indices (input_->width * input_->height);
00082 for (int i = 0; i < static_cast<int>(all_indices.size ()); ++i)
00083 all_indices[i] = i;
00084
00085 std::vector<int> indices = *indices_;
00086 std::sort (indices.begin (), indices.end ());
00087
00088
00089 std::vector<int> remaining_indices;
00090 set_difference (all_indices.begin (), all_indices.end (), indices.begin (), indices.end (),
00091 inserter (remaining_indices, remaining_indices.begin ()));
00092
00093
00094 output.width = static_cast<uint32_t> (remaining_indices.size ());
00095 output.data.resize (remaining_indices.size () * output.point_step);
00096 for (size_t i = 0; i < remaining_indices.size (); ++i)
00097 memcpy (&output.data[i * output.point_step], &input_->data[remaining_indices[i] * output.point_step], output.point_step);
00098 }
00099 else
00100 {
00101
00102 output.width = static_cast<uint32_t> (indices_->size ());
00103 output.data.resize (indices_->size () * output.point_step);
00104 for (size_t i = 0; i < indices_->size (); ++i)
00105 memcpy (&output.data[i * output.point_step], &input_->data[(*indices_)[i] * output.point_step], output.point_step);
00106 }
00107 output.row_step = output.point_step * output.width;
00108 }
00109
00111 void
00112 pcl::ExtractIndices<pcl::PCLPointCloud2>::applyFilter (std::vector<int> &indices)
00113 {
00114 if (negative_)
00115 {
00116
00117 if (indices_->size () == (input_->width * input_->height))
00118 {
00119
00120 indices.clear ();
00121 return;
00122 }
00123
00124
00125 std::vector<int> indices_fullset (input_->width * input_->height);
00126 for (int p_it = 0; p_it < static_cast<int> (indices_fullset.size ()); ++p_it)
00127 indices_fullset[p_it] = p_it;
00128
00129
00130 if (indices_->empty () || (input_->width * input_->height == 0))
00131 {
00132
00133 indices = indices_fullset;
00134 return;
00135 }
00136
00137
00138
00139 std::vector<int> indices_subset = *indices_;
00140 std::sort (indices_subset.begin (), indices_subset.end ());
00141
00142
00143 set_difference (indices_fullset.begin (), indices_fullset.end (), indices_subset.begin (), indices_subset.end (), inserter (indices, indices.begin ()));
00144 }
00145 else
00146 indices = *indices_;
00147 }
00148
00149 #ifndef PCL_NO_PRECOMPILE
00150 #include <pcl/impl/instantiate.hpp>
00151 #include <pcl/point_types.h>
00152
00153 #ifdef PCL_ONLY_CORE_POINT_TYPES
00154 PCL_INSTANTIATE(ExtractIndices, (pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::Normal)(pcl::PointXYZRGBNormal))
00155 #else
00156 PCL_INSTANTIATE(ExtractIndices, PCL_POINT_TYPES)
00157 #endif
00158
00159 #endif // PCL_NO_PRECOMPILE
00160