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
00040
00041 #include <algorithm>
00042 #include <pcl/apps/point_cloud_editor/selection.h>
00043 #include <pcl/apps/point_cloud_editor/cloud.h>
00044 #include <pcl/apps/point_cloud_editor/common.h>
00045
00046 Selection&
00047 Selection::operator= (const Selection& selection)
00048 {
00049 cloud_ptr_ = selection.cloud_ptr_;
00050 selected_indices_ = selection.selected_indices_;
00051 return (*this);
00052 }
00053
00054 void
00055 Selection::addIndex (unsigned int index)
00056 {
00057 selected_indices_.insert(index);
00058 }
00059
00060 void
00061 Selection::removeIndex (unsigned int index)
00062 {
00063 selected_indices_.erase(index);
00064 }
00065
00066 void
00067 Selection::addIndex (const IndexVector &indices)
00068 {
00069 selected_indices_.insert(indices.begin(), indices.end());
00070 }
00071
00072 void
00073 Selection::removeIndex (const IndexVector &indices)
00074 {
00075 IndexVector::const_iterator it;
00076 for(it = indices.begin(); it != indices.end(); ++it)
00077 removeIndex(*it);
00078 }
00079
00080 void
00081 Selection::addIndexRange (unsigned int start, unsigned int num)
00082 {
00083 for(unsigned int i = start; i < start + num; ++i)
00084 addIndex(i);
00085 }
00086
00087 void
00088 Selection::removeIndexRange (unsigned int start, unsigned int num)
00089 {
00090 for(unsigned int i = start; i < start + num; ++i)
00091 removeIndex(i);
00092 }
00093
00094 bool
00095 Selection::isSelected (unsigned int index) const
00096 {
00097 if (index >= cloud_ptr_->size())
00098 return (false);
00099 iterator it = selected_indices_.find(index);
00100 if (it != selected_indices_.end())
00101 return (true);
00102 return (false);
00103 }
00104
00105 void
00106 Selection::invertSelect ()
00107 {
00108 std::set<unsigned int> s, complement;
00109 IncIndex inc;
00110 for(unsigned int i = 0; i < cloud_ptr_->size(); ++i)
00111 s.insert(i);
00112 std::set_difference(s.begin(), s.end(),
00113 selected_indices_.begin(), selected_indices_.end(),
00114 std::inserter(complement, complement.end()));
00115 selected_indices_ = complement;
00116 }
00117
00118 std::string
00119 Selection::getStat () const
00120 {
00121 if (selected_indices_.size() == 0)
00122 return ("");
00123 std::string title = "Total number of selected points: ";
00124 std::string num_str;
00125 ::toString(selected_indices_.size(), num_str);
00126 return (title + num_str);
00127 }