octree_pointcloud_density.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010-2011, Willow Garage, Inc.
00006  *
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of Willow Garage, Inc. nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  * $Id: octree_pointcloud_density.h 6119 2012-07-03 18:50:04Z aichim $
00037  */
00038 
00039 #ifndef OCTREE_DENSITY_H
00040 #define OCTREE_DENSITY_H
00041 
00042 #include "octree_pointcloud.h"
00043 
00044 #include "octree_base.h"
00045 #include "octree2buf_base.h"
00046 
00047 namespace pcl
00048 {
00049   namespace octree
00050   {
00055     template<typename DataT>
00056     class OctreePointCloudDensityContainer
00057     {
00058       public:
00060         OctreePointCloudDensityContainer () : pointCounter_ (0)
00061         {
00062         }
00063 
00065         virtual ~OctreePointCloudDensityContainer ()
00066         {
00067         }
00068 
00070         virtual OctreePointCloudDensityContainer *
00071         deepCopy () const
00072         {
00073           return (new OctreePointCloudDensityContainer (*this));
00074         }
00075 
00079         size_t
00080         getSize () const
00081         {
00082           return 0;
00083         }
00084 
00087         void
00088         setData (const DataT&)
00089         {
00090           pointCounter_++;
00091         }
00092 
00096         void
00097         getData (const DataT*& data_arg) const
00098         {
00099           data_arg = 0;
00100         }
00101 
00104         void
00105         getData (std::vector<DataT>&) const
00106         {
00107         }
00108 
00112         unsigned int
00113         getPointCounter ()
00114         {
00115           return (pointCounter_);
00116         }
00117 
00119         void
00120         reset ()
00121         {
00122           pointCounter_ = 0;
00123         }
00124 
00125       private:
00126         unsigned int pointCounter_;
00127 
00128     };
00129 
00138     template<typename PointT, typename LeafT = OctreePointCloudDensityContainer<int> , typename BranchT = OctreeContainerEmpty<int> >
00139     class OctreePointCloudDensity : public OctreePointCloud<PointT, LeafT, BranchT>
00140     {
00141       public:
00142 
00146         OctreePointCloudDensity (const double resolution_arg) :
00147         OctreePointCloud<PointT, LeafT, BranchT> (resolution_arg)
00148         {
00149         }
00150 
00152         virtual
00153         ~OctreePointCloudDensity ()
00154         {
00155         }
00156 
00161         unsigned int
00162         getVoxelDensityAtPoint (const PointT& point_arg) const
00163         {
00164           unsigned int pointCount = 0;
00165 
00166           OctreePointCloudDensityContainer<int>* leaf = this->findLeafAtPoint (point_arg);
00167 
00168           if (leaf)
00169             pointCount = leaf->getPointCounter ();
00170 
00171           return (pointCount);
00172         }
00173     };
00174   }
00175 }
00176 
00177 #define PCL_INSTANTIATE_OctreePointCloudDensity(T) template class PCL_EXPORTS pcl::octree::OctreePointCloudDensity<T>;
00178 
00179 #endif
00180 


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:15:57