00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef PCL_NORMAL_3D_TBB_H_
00039 #define PCL_NORMAL_3D_TBB_H_
00040
00041
00042
00043
00044 #include <pcl/features/normal_3d.h>
00045
00046
00047 #include <tbb/parallel_for.h>
00048 #include <tbb/blocked_range.h>
00049 #include <tbb/task_scheduler_init.h>
00050
00051 namespace pcl
00052 {
00053 template <typename PointInT, typename PointOutT> class TBB_NormalEstimationTBB;
00054
00059 template <typename PointInT, typename PointOutT>
00060 class NormalEstimationTBB: public NormalEstimation<PointInT, PointOutT>
00061 {
00062 public:
00063 using Feature<PointInT, PointOutT>::feature_name_;
00064 using Feature<PointInT, PointOutT>::getClassName;
00065 using Feature<PointInT, PointOutT>::indices_;
00066
00067 typedef typename NormalEstimation<PointInT, PointOutT>::PointCloudOut PointCloudOut;
00068 typedef boost::shared_ptr <Feature<PointInT, PointOutT> > FeaturePtr;
00069
00071 NormalEstimationTBB ()
00072 {
00073 scheduler_.initialize (tbb::task_scheduler_init::automatic);
00074 feature_name_ = "NormalEstimationTBB";
00075 }
00076
00080 NormalEstimationTBB (int nr_threads)
00081 {
00082 setNumberOfThreads (nr_threads);
00083 feature_name_ = "NormalEstimationTBB";
00084 }
00085
00089 inline void setNumberOfThreads (int nr_threads) { scheduler_.initialize (nr_threads); }
00090
00092 virtual ~NormalEstimationTBB ()
00093 {
00094 scheduler_.terminate ();
00095 }
00096
00097 private:
00098
00103 inline void
00104 computeFeature (PointCloudOut &output)
00105 {
00106 tbb::parallel_for (tbb::blocked_range <size_t> (0, indices_->size ()),
00107 TBB_NormalEstimationTBB<PointInT, PointOutT> (this, output));
00108 }
00109
00110 private:
00112 tbb::task_scheduler_init scheduler_;
00113 };
00114
00115 template <typename PointInT, typename PointOutT>
00116 class TBB_NormalEstimationTBB
00117 {
00118 typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
00119
00120 NormalEstimationTBB<PointInT, PointOutT> *feature_;
00121 PointCloudOut &output_;
00122
00123 public:
00125 void operator () (const tbb::blocked_range <size_t> &r) const;
00126
00128 TBB_NormalEstimationTBB (NormalEstimationTBB<PointInT, PointOutT> *feature, PointCloudOut &output): feature_ (feature), output_ (output) {}
00129 };
00130 }
00131
00132
00133
00134 #endif //#ifndef PCL_NORMAL_3D_TBB_H_
00135
00136