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 34546 2010-12-06 11:27:12Z rusu $ 00035 * 00036 */ 00037 00038 #ifndef PCL_SEGMENT_DIFFERENCES_H_ 00039 #define PCL_SEGMENT_DIFFERENCES_H_ 00040 00041 #include <pcl/pcl_base.h> 00042 00043 #include "pcl/kdtree/kdtree.h" 00044 #include "pcl/kdtree/tree_types.h" 00045 00046 namespace pcl 00047 { 00049 00057 template <typename PointT> 00058 void getPointCloudDifference ( 00059 const pcl::PointCloud<PointT> &src, const pcl::PointCloud<PointT> &tgt, 00060 double threshold, const boost::shared_ptr<pcl::KdTree<PointT> > &tree, 00061 pcl::PointCloud<PointT> &output); 00062 00066 00070 template <typename PointT> 00071 class SegmentDifferences: public PCLBase<PointT> 00072 { 00073 typedef PCLBase<PointT> BasePCLBase; 00074 00075 public: 00076 typedef pcl::PointCloud<PointT> PointCloud; 00077 typedef typename PointCloud::Ptr PointCloudPtr; 00078 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00079 00080 typedef typename pcl::KdTree<PointT> KdTree; 00081 typedef typename pcl::KdTree<PointT>::Ptr KdTreePtr; 00082 00083 typedef PointIndices::Ptr PointIndicesPtr; 00084 typedef PointIndices::ConstPtr PointIndicesConstPtr; 00085 00087 00088 SegmentDifferences () : tree_ (), target_ (), spatial_locator_ (0), distance_threshold_ (0) 00089 {}; 00090 00092 00095 inline void setTargetCloud (const PointCloudConstPtr &cloud) { target_ = cloud; } 00096 00098 00099 inline PointCloudConstPtr const getTargetCloud () { return (target_); } 00100 00102 00105 inline void setSearchMethod (const KdTreePtr &tree) { tree_ = tree; } 00106 00108 00109 inline KdTreePtr getSearchMethod () { return (tree_); } 00110 00112 00115 inline void setDistanceThreshold (double threshold) { distance_threshold_ = threshold; } 00116 00118 00119 inline double getDistanceThreshold () { return (distance_threshold_); } 00120 00122 00125 void segment (PointCloud &output); 00126 00127 protected: 00128 // Members derived from the base class 00129 using BasePCLBase::input_; 00130 using BasePCLBase::indices_; 00131 using BasePCLBase::initCompute; 00132 using BasePCLBase::deinitCompute; 00133 00135 KdTreePtr tree_; 00136 00138 PointCloudConstPtr target_; 00139 00145 int spatial_locator_; 00146 00148 double distance_threshold_; 00149 00151 00152 virtual std::string getClassName () const { return ("SegmentDifferences"); } 00153 }; 00154 } 00155 00156 #endif //#ifndef PCL_SEGMENT_DIFFERENCES_H_