centroid.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, Willow Garage, Inc.
00006  *  Copyright (c) 2012-, Open Perception, Inc.
00007  *
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of the copyright holder(s) nor the names of its
00021  *     contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  */
00038 
00039 #ifndef PCL18_BACKPORTS_CENTROID_H
00040 #define PCL18_BACKPORTS_CENTROID_H
00041 
00042 #include <pcl/common/centroid.h>
00043 
00044 #ifdef BACKPORT_PCL_CENTROID
00045 
00046 // System has old PCL; backport CentroidPoint class from pcl-1.8
00047 
00048 #include <vector>
00049 
00050 #include <pcl/point_cloud.h>
00051 #include <pcl/point_traits.h>
00052 #include <pcl/PointIndices.h>
00053 #include <pcl/cloud_iterator.h>
00054 
00055 #include <pcl18_backports/accumulators.h>
00056 
00057 namespace pcl
00058 {
00120 template <typename PointT>
00121 class CentroidPoint
00122 {
00123 public:
00124   CentroidPoint() = default;
00125 
00130   void add(const PointT& point)
00131   {
00132     // Invoke add point on each accumulator
00133     boost::fusion::for_each(accumulators_, detail::AddPoint<PointT>(point));
00134     ++num_points_;
00135   }
00136 
00146   template <typename PointOutT>
00147   void get(PointOutT& point) const
00148   {
00149     if (num_points_ != 0)
00150     {
00151       // Filter accumulators so that only those that are compatible with
00152       // both PointT and requested point type remain
00153       auto ca = boost::fusion::filter_if<detail::IsAccumulatorCompatible<PointT, PointOutT>>(accumulators_);
00154       // Invoke get point on each accumulator in filtered list
00155       boost::fusion::for_each(ca, detail::GetPoint<PointOutT>(point, num_points_));
00156     }
00157   }
00158 
00160   size_t getSize() const
00161   {
00162     return (num_points_);
00163   }
00164 
00165   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00166 
00167 private:
00168   size_t num_points_ = 0;
00169   typename pcl::detail::Accumulators<PointT>::type accumulators_;
00170 };
00171 
00172 }  // namespace pcl
00173 
00174 #endif  // BACKPORT_PCL_CENTROID
00175 #endif  // PCL18_BACKPORTS_CENTROID_H


mcl_3dl
Author(s): Atsushi Watanabe
autogenerated on Thu Jun 20 2019 20:04:43