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 <pcl/apps/point_cloud_editor/cutCommand.h> 00042 #include <pcl/apps/point_cloud_editor/copyBuffer.h> 00043 #include <pcl/apps/point_cloud_editor/selection.h> 00044 00045 CutCommand::CutCommand (CopyBufferPtr copy_buffer_ptr, 00046 SelectionPtr selection_ptr, 00047 CloudPtr cloud_ptr) 00048 : selection_ptr_(selection_ptr), cloud_ptr_(cloud_ptr), 00049 copy_buffer_ptr_(copy_buffer_ptr), cut_selection_(cloud_ptr) 00050 { 00051 } 00052 00053 CutCommand::~CutCommand () 00054 { 00055 } 00056 00057 void 00058 CutCommand::execute () 00059 { 00060 if (!cloud_ptr_) 00061 return; 00062 if (selection_ptr_->empty()) 00063 return; 00064 00065 // do the copy 00066 copy_buffer_ptr_ -> set(cloud_ptr_, *selection_ptr_); 00067 00068 // back up copied points for undo 00069 cut_cloud_buffer_ = *copy_buffer_ptr_; 00070 cut_selection_ = *selection_ptr_; 00071 00072 // remove the copied points from the cloud. 00073 cloud_ptr_ -> remove(cut_selection_); 00074 00075 // The selection points to the incorrect points or may have indices out of 00076 // bounds, so we must clear it. 00077 selection_ptr_ -> clear(); 00078 00079 // notify the cloud that the selection has changed 00080 cloud_ptr_ -> setSelection(selection_ptr_); 00081 } 00082 00083 void 00084 CutCommand::undo() 00085 { 00086 if (!cloud_ptr_) 00087 return; 00088 cloud_ptr_ -> restore(cut_cloud_buffer_, cut_selection_); 00089 }