00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Willow Garage, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * $Id: segment_differences.h 5026 2012-03-12 02:51:44Z rusu $ 00035 * 00036 */ 00037 00038 #ifndef PCL_SEGMENT_DIFFERENCES_H_ 00039 #define PCL_SEGMENT_DIFFERENCES_H_ 00040 00041 #include <pcl/pcl_base.h> 00042 #include <pcl/search/pcl_search.h> 00043 00044 namespace pcl 00045 { 00047 00056 template <typename PointT> 00057 void getPointCloudDifference ( 00058 const pcl::PointCloud<PointT> &src, const pcl::PointCloud<PointT> &tgt, 00059 double threshold, const boost::shared_ptr<pcl::search::Search<PointT> > &tree, 00060 pcl::PointCloud<PointT> &output); 00061 00065 00071 template <typename PointT> 00072 class SegmentDifferences: public PCLBase<PointT> 00073 { 00074 typedef PCLBase<PointT> BasePCLBase; 00075 00076 public: 00077 typedef pcl::PointCloud<PointT> PointCloud; 00078 typedef typename PointCloud::Ptr PointCloudPtr; 00079 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00080 00081 typedef typename pcl::search::Search<PointT> KdTree; 00082 typedef typename pcl::search::Search<PointT>::Ptr KdTreePtr; 00083 00084 typedef PointIndices::Ptr PointIndicesPtr; 00085 typedef PointIndices::ConstPtr PointIndicesConstPtr; 00086 00088 SegmentDifferences () : 00089 tree_ (), target_ (), distance_threshold_ (0) 00090 {}; 00091 00097 inline void 00098 setTargetCloud (const PointCloudConstPtr &cloud) { target_ = cloud; } 00099 00101 inline PointCloudConstPtr const 00102 getTargetCloud () { return (target_); } 00103 00107 inline void 00108 setSearchMethod (const KdTreePtr &tree) { tree_ = tree; } 00109 00111 inline KdTreePtr 00112 getSearchMethod () { return (tree_); } 00113 00119 inline void 00120 setDistanceThreshold (double sqr_threshold) { distance_threshold_ = sqr_threshold; } 00121 00125 inline double 00126 getDistanceThreshold () { return (distance_threshold_); } 00127 00131 void 00132 segment (PointCloud &output); 00133 00134 protected: 00135 // Members derived from the base class 00136 using BasePCLBase::input_; 00137 using BasePCLBase::indices_; 00138 using BasePCLBase::initCompute; 00139 using BasePCLBase::deinitCompute; 00140 00142 KdTreePtr tree_; 00143 00145 PointCloudConstPtr target_; 00146 00150 double distance_threshold_; 00151 00153 virtual std::string 00154 getClassName () const { return ("SegmentDifferences"); } 00155 }; 00156 } 00157 00158 #endif //#ifndef PCL_SEGMENT_DIFFERENCES_H_