48
48
#include < boost/random/uniform_int.hpp> // for uniform_int
49
49
#include < boost/random/variate_generator.hpp> // for variate_generator
50
50
#include < random>
51
+ #include < numeric> // for iota
51
52
52
53
#include < pcl/memory.h>
53
54
#include < pcl/console/print.h>
@@ -101,41 +102,14 @@ namespace pcl
101
102
}
102
103
103
104
public:
104
- /* * \brief Constructor for base SampleConsensusModel.
105
- * \param[in] cloud the input point cloud dataset
106
- * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
107
- */
108
- SampleConsensusModel (const PointCloudConstPtr &cloud, bool random = false )
109
- : input_ ()
110
- , radius_min_ (-std::numeric_limits<double >::max ())
111
- , radius_max_ (std::numeric_limits<double >::max ())
112
- , samples_radius_ (0 .)
113
- , samples_radius_search_ ()
114
- , rng_dist_ (new boost::uniform_int<> (0 , std::numeric_limits<int >::max ()))
115
- , custom_model_constraints_ ([](auto ){return true ;})
116
- {
117
- if (random)
118
- rng_alg_.seed (std::random_device ()());
119
- else
120
- rng_alg_.seed (12345u );
121
-
122
- // Sets the input cloud and creates a vector of "fake" indices
123
- setInputCloud (cloud);
124
-
125
- // Create a random number generator object
126
- rng_gen_.reset (new boost::variate_generator<boost::mt19937&, boost::uniform_int<> > (rng_alg_, *rng_dist_));
127
- }
128
-
129
105
/* * \brief Constructor for base SampleConsensusModel.
130
106
* \param[in] cloud the input point cloud dataset
131
107
* \param[in] indices a vector of point indices to be used from \a cloud
132
108
* \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
133
109
*/
134
- SampleConsensusModel (const PointCloudConstPtr &cloud,
135
- const Indices &indices,
136
- bool random = false )
110
+ SampleConsensusModel (const PointCloudConstPtr &cloud, const Indices &indices, const bool random = false )
137
111
: input_ (cloud)
138
- , indices_ (new Indices (indices))
112
+ , indices_(new Indices(indices))
139
113
, radius_min_ (-std::numeric_limits<double >::max ())
140
114
, radius_max_ (std::numeric_limits<double >::max ())
141
115
, samples_radius_ (0 .)
@@ -148,6 +122,13 @@ namespace pcl
148
122
else
149
123
rng_alg_.seed (12345u );
150
124
125
+ // If no indices are provided, use all points
126
+ if (indices_->empty ())
127
+ {
128
+ indices_->resize (cloud->size ());
129
+ std::iota (indices_->begin (), indices_->end (), 0 );
130
+ }
131
+
151
132
if (indices_->size () > input_->size ())
152
133
{
153
134
PCL_ERROR (" [pcl::SampleConsensusModel] Invalid index vector given with size "
@@ -160,7 +141,14 @@ namespace pcl
160
141
161
142
// Create a random number generator object
162
143
rng_gen_.reset (new boost::variate_generator<boost::mt19937&, boost::uniform_int<> > (rng_alg_, *rng_dist_));
163
- };
144
+ }
145
+
146
+ /* * \brief Constructor for base SampleConsensusModel.
147
+ * \param[in] cloud the input point cloud dataset
148
+ * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
149
+ */
150
+ SampleConsensusModel (const PointCloudConstPtr &cloud, const bool random = false )
151
+ : SampleConsensusModel(cloud, Indices(), random) {};
164
152
165
153
/* * \brief Destructor for base SampleConsensusModel. */
166
154
virtual ~SampleConsensusModel () = default ;
0 commit comments