Go to the documentation of this file.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
00039
00040 #ifndef PCL_COMMON_RANDOM_HPP_
00041 #define PCL_COMMON_RANDOM_HPP_
00042
00043 #include <boost/version.hpp>
00044 #include <pcl/pcl_macros.h>
00045
00047 template <typename T>
00048 pcl::common::UniformGenerator<T>::UniformGenerator(T min, T max, pcl::uint32_t seed)
00049 : distribution_ (min, max)
00050 , generator_ (rng_, distribution_)
00051 {
00052 parameters_ = Parameters (min, max, seed);
00053 if(parameters_.seed != -1)
00054 rng_.seed (seed);
00055 }
00056
00057
00059 template <typename T>
00060 pcl::common::UniformGenerator<T>::UniformGenerator(const Parameters& parameters)
00061 : parameters_ (parameters)
00062 , distribution_ (parameters_.min, parameters_.max)
00063 , generator_ (rng_, distribution_)
00064 {
00065 if(parameters_.seed != -1)
00066 rng_.seed (parameters_.seed);
00067 }
00068
00070 template <typename T> void
00071 pcl::common::UniformGenerator<T>::setSeed (pcl::uint32_t seed)
00072 {
00073 if (seed != -1)
00074 {
00075 parameters_.seed = seed;
00076 rng_.seed(parameters_.seed);
00077 }
00078 }
00079
00081 template <typename T> void
00082 pcl::common::UniformGenerator<T>::setParameters (T min, T max, pcl::uint32_t seed)
00083 {
00084 parameters_.min = min;
00085 parameters_.max = max;
00086 parameters_.seed = seed;
00087 #if BOOST_VERSION >= 104700
00088 typename DistributionType::param_type params (parameters_.min, parameters_.max);
00089 distribution_.param (params);
00090 #else
00091 distribution_ = DistributionType (parameters_.min, parameters_.max);
00092 #endif
00093 distribution_.reset ();
00094 generator_.distribution () = distribution_;
00095 if (seed != -1)
00096 {
00097 parameters_.seed = seed;
00098 rng_.seed (parameters_.seed);
00099 }
00100 }
00101
00103 template <typename T> void
00104 pcl::common::UniformGenerator<T>::setParameters (const Parameters& parameters)
00105 {
00106 parameters_ = parameters;
00107 #if BOOST_VERSION >= 104700
00108 typename DistributionType::param_type params (parameters_.min, parameters_.max);
00109 distribution_.param (params);
00110 #else
00111 distribution_ = DistributionType (parameters_.min, parameters_.max);
00112 #endif
00113 distribution_.reset ();
00114 generator_.distribution () = distribution_;
00115 if (parameters_.seed != -1)
00116 rng_.seed (parameters_.seed);
00117 }
00118
00120 template <typename T>
00121 pcl::common::NormalGenerator<T>::NormalGenerator(T mean, T sigma, pcl::uint32_t seed)
00122 : distribution_ (mean, sigma)
00123 , generator_ (rng_, distribution_)
00124 {
00125 parameters_ = Parameters (mean, sigma, seed);
00126 if(parameters_.seed != -1)
00127 rng_.seed (seed);
00128 }
00129
00130
00132 template <typename T>
00133 pcl::common::NormalGenerator<T>::NormalGenerator(const Parameters& parameters)
00134 : parameters_ (parameters)
00135 , distribution_ (parameters_.mean, parameters_.sigma)
00136 , generator_ (rng_, distribution_)
00137 {
00138 if(parameters_.seed != -1)
00139 rng_.seed (parameters_.seed);
00140 }
00141
00143 template <typename T> void
00144 pcl::common::NormalGenerator<T>::setSeed (pcl::uint32_t seed)
00145 {
00146 if (seed != -1)
00147 {
00148 parameters_.seed = seed;
00149 rng_.seed(seed);
00150 }
00151 }
00152
00154 template <typename T> void
00155 pcl::common::NormalGenerator<T>::setParameters (T mean, T sigma, pcl::uint32_t seed)
00156 {
00157 parameters_.mean = mean;
00158 parameters_.sigma = sigma;
00159 parameters_.seed = seed;
00160 #if BOOST_VERSION >= 104700
00161 typename DistributionType::param_type params (parameters_.mean, parameters_.sigma);
00162 distribution_.param (params);
00163 #else
00164 distribution_ = DistributionType (parameters_.mean, parameters_.sigma);
00165 #endif
00166 distribution_.reset ();
00167 generator_.distribution () = distribution_;
00168 if (seed != -1)
00169 rng_.seed (parameters_.seed);
00170 }
00171
00173 template <typename T> void
00174 pcl::common::NormalGenerator<T>::setParameters (const Parameters& parameters)
00175 {
00176 parameters_ = parameters;
00177 #if BOOST_VERSION >= 104700
00178 typename DistributionType::param_type params (parameters_.mean, parameters_.sigma);
00179 distribution_.param (params);
00180 #else
00181 distribution_ = DistributionType (parameters_.mean, parameters_.sigma);
00182 #endif
00183 distribution_.reset ();
00184 generator_.distribution () = distribution_;
00185 if (parameters_.seed != -1)
00186 rng_.seed (parameters_.seed);
00187 }
00188
00189 #endif