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 00042 #ifndef SELECTION_H_ 00043 #define SELECTION_H_ 00044 00045 #include <set> 00046 #include <pcl/apps/point_cloud_editor/localTypes.h> 00047 #include <pcl/apps/point_cloud_editor/statistics.h> 00048 00052 class Selection : public Statistics 00053 { 00054 public: 00058 Selection (ConstCloudPtr cloud_ptr, bool register_stats=false) 00059 : cloud_ptr_(cloud_ptr) 00060 { 00061 if (register_stats) 00062 registerStats(); 00063 } 00064 00067 Selection (const Selection& copy) 00068 : cloud_ptr_(copy.cloud_ptr_), selected_indices_(copy.selected_indices_) 00069 { 00070 } 00071 00073 ~Selection () 00074 { 00075 } 00076 00080 Selection& 00081 operator= (const Selection& selection); 00082 00087 void 00088 addIndex (unsigned int index); 00089 00092 void 00093 removeIndex (unsigned int index); 00094 00099 void 00100 addIndex (const IndexVector &indices); 00101 00105 void 00106 removeIndex (const IndexVector &indices); 00107 00113 void 00114 addIndexRange (unsigned int start, unsigned int num); 00115 00119 void 00120 removeIndexRange (unsigned int start, unsigned int num); 00121 00123 void 00124 clear () 00125 { 00126 selected_indices_.clear(); 00127 } 00128 00129 typedef std::set<unsigned int>::iterator iterator; 00130 typedef std::set<unsigned int>::const_iterator const_iterator; 00131 00133 const_iterator 00134 begin () const 00135 { 00136 return (selected_indices_.begin()); 00137 } 00138 00140 const_iterator 00141 end () const 00142 { 00143 return (selected_indices_.end()); 00144 } 00145 00146 typedef std::set<unsigned int>::const_reverse_iterator 00147 const_reverse_iterator; 00148 00150 const_reverse_iterator 00151 rbegin () const 00152 { 00153 return (selected_indices_.rbegin()); 00154 } 00155 00157 const_reverse_iterator 00158 rend () const 00159 { 00160 return (selected_indices_.rend()); 00161 } 00162 00164 bool 00165 isSelected (unsigned int index) const; 00166 00168 inline 00169 bool 00170 empty () const 00171 { 00172 return (selected_indices_.empty()); 00173 } 00174 00176 inline 00177 unsigned int 00178 size () const 00179 { 00180 return (selected_indices_.size()); 00181 } 00182 00186 void 00187 invertSelect (); 00188 00190 std::string 00191 getStat () const; 00192 00193 private: 00195 Selection () 00196 { 00197 } 00198 00200 ConstCloudPtr cloud_ptr_; 00201 00203 std::set<unsigned int> selected_indices_; 00204 }; 00205 00206 #endif // SELECTION_H_