MCPcopy Create free account
hub / github.com/OctoMap/octomap / subSampleRandom

Method subSampleRandom

octomap/src/Pointcloud.cpp:210–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208
209
210 void Pointcloud::subSampleRandom(unsigned int num_samples, Pointcloud& sample_cloud) {
211 point3d_collection samples;
212 // visual studio does not support random_sample_n and neither does libc++
213 #if defined(_MSC_VER) || defined(_LIBCPP_VERSION)
214 samples.reserve(this->size());
215 samples.insert(samples.end(), this->begin(), this->end());
216 #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) || __cplusplus >= 201103L)
217 std::random_device r;
218 std::mt19937 urbg(r());
219 std::shuffle(samples.begin(), samples.end(), urbg);
220 #else
221 std::random_shuffle(samples.begin(), samples.end());
222 #endif
223 samples.resize(num_samples);
224 #else
225 random_sample_n(begin(), end(), std::back_insert_iterator<point3d_collection>(samples), num_samples);
226 for (unsigned int i=0; i<samples.size(); i++) {
227 sample_cloud.push_back(samples[i]);
228 }
229 #endif
230 }
231
232
233 void Pointcloud::writeVrml(std::string filename){

Callers

nothing calls this directly

Calls 9

sizeMethod · 0.95
beginMethod · 0.95
endMethod · 0.95
reserveMethod · 0.80
insertMethod · 0.80
endMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected