1 /// 2 /// Copyright (c) 2012, Texas A&M University 3 /// All rights reserved. 4 /// 5 /// Redistribution and use in source and binary forms, with or without 6 /// modification, are permitted provided that the following conditions 7 /// are met: 8 /// 9 /// * Redistributions of source code must retain the above copyright 10 /// notice, this list of conditions and the following disclaimer. 11 /// * Redistributions in binary form must reproduce the above 12 /// copyright notice, this list of conditions and the following 13 /// disclaimer in the documentation and/or other materials provided 14 /// with the distribution. 15 /// * Neither the name of Texas A&M University nor the names of its 16 /// contributors may be used to endorse or promote products derived 17 /// from this software without specific prior written permission. 18 /// 19 /// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 /// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 /// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 /// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 /// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 /// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 /// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 /// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 /// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 /// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 29 /// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 /// POSSIBILITY OF SUCH DAMAGE. 31 /// 32 /// The following software was written as part of a collaboration with the 33 /// University of South Carolina, Interdisciplinary Mathematics Institute. 34 /// 35 36 /// @file copyBuffer.h 37 /// @details A CopyBuffer object provides a buffer to store the points 38 /// copied from the cloud. 39 /// @author Yue Li and Matthew Hielsberg 40 41 #pragma once 42 43 #include <pcl/apps/point_cloud_editor/localTypes.h> 44 #include <pcl/apps/point_cloud_editor/cloud.h> 45 46 /// @brief a buffer holding the points being copied and a set of operations for 47 /// manipulating the buffer. 48 class CopyBuffer : public Statistics 49 { 50 public: 51 /// @brief Default Constructor 52 /// @details This creates an empty buffer 53 CopyBuffer (bool register_stats=false) 54 { 55 if (register_stats) 56 registerStats(); 57 } 58 59 /// @brief Sets the points in the copy buffer. 60 /// @details The passed selection pointer is used to get specified points 61 /// from the stored cloud pointer and copy them into the internal buffer. 62 /// Any points that currently exist in this buffer are removed and replaced 63 /// with those passed. Note that this buffer is cleared prior to any 64 /// checking of the state of the passed parameters. 65 /// @param cloud_ptr a pointer to a cloud object whose points are to be 66 /// copied 67 /// @param selection a const reference to the selected points object 68 void 69 set (const ConstCloudPtr& cloud_ptr, const Selection& selection); 70 71 /// @brief Returns the points stored in the internal buffer as a const Cloud 72 const Cloud& 73 get() const; 74 75 /// @brief Returns the points stored in the internal buffer as a Cloud 76 Cloud& 77 get(); 78 79 /// @brief Removes all the points from the copy buffer. 80 void 81 clean (); 82 83 /// @brief Get the statistics of the copied points in string. 84 std::string 85 getStat () const override; 86 87 /// @brief Returns true if the buffer is empty, false otherwise 88 bool empty()89 empty() const 90 { 91 return (buffer_.size() == 0); 92 } 93 94 private: 95 /// a cloud object holding all the copied points. 96 Cloud buffer_; 97 }; 98