mirror of https://github.com/CGAL/cgal
quick code review (some comments for Sven)
This commit is contained in:
parent
7adb8b5a1a
commit
a076bc5630
|
|
@ -7,8 +7,8 @@
|
||||||
#include <CGAL/Point_with_normal_3.h>
|
#include <CGAL/Point_with_normal_3.h>
|
||||||
#include <CGAL/property_map.h>
|
#include <CGAL/property_map.h>
|
||||||
|
|
||||||
const int rounds = 50;
|
const int rounds = 50; // TODO: capitalize constant: NB_ROUNDS
|
||||||
const int ptsCount = 1000;
|
const int ptsCount = 1000; // TODO: capitalize constant NB_POINTS
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
bool test_cylinder_parameters() {
|
bool test_cylinder_parameters() {
|
||||||
|
|
@ -27,21 +27,24 @@ bool test_cylinder_parameters() {
|
||||||
|
|
||||||
std::size_t success = 0;
|
std::size_t success = 0;
|
||||||
|
|
||||||
for (std::size_t i = 0;i<rounds;i++) {
|
for (std::size_t i = 0;i<rounds;i++)
|
||||||
|
{
|
||||||
Pwn_vector points;
|
Pwn_vector points;
|
||||||
|
|
||||||
K::FT radius = 0;
|
// generate random points on random cylinder
|
||||||
|
K::FT radius = (FT)0; // radius will be randomly generated by sampleRandomCylinderInBox
|
||||||
Vector axis;
|
Vector axis;
|
||||||
Point center;
|
Point center;
|
||||||
CGAL::Bbox_3 bbox(-10, -10, -10, 10, 10, 10);
|
CGAL::Bbox_3 bbox(-10, -10, -10, 10, 10, 10);
|
||||||
|
|
||||||
sampleRandomCylinderInBox(ptsCount, bbox, center, axis,
|
sampleRandomCylinderInBox(ptsCount, bbox, center, axis, // fix case, sample_random...
|
||||||
radius, std::back_inserter(points));
|
radius, std::back_inserter(points));
|
||||||
|
|
||||||
|
// add outliers in second half of rounds
|
||||||
if (i >= rounds / 2)
|
if (i >= rounds / 2)
|
||||||
for (std::size_t j = 0;j<ptsCount/2;j++) {
|
for (std::size_t j = 0; j < ptsCount / 2; j++)
|
||||||
points.push_back(random_pwn_in<K>(bbox));
|
points.push_back(random_pwn_in<K>(bbox));
|
||||||
}
|
|
||||||
|
|
||||||
Efficient_ransac ransac;
|
Efficient_ransac ransac;
|
||||||
|
|
||||||
|
|
@ -65,11 +68,13 @@ bool test_cylinder_parameters() {
|
||||||
|
|
||||||
Efficient_ransac::Shape_range shapes = ransac.shapes();
|
Efficient_ransac::Shape_range shapes = ransac.shapes();
|
||||||
|
|
||||||
|
// check: unique shape detected
|
||||||
if (shapes.size() != 1)
|
if (shapes.size() != 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
boost::shared_ptr<Cylinder> cyl = boost::dynamic_pointer_cast<Cylinder>((*shapes.first));
|
boost::shared_ptr<Cylinder> cyl = boost::dynamic_pointer_cast<Cylinder>((*shapes.first));
|
||||||
|
|
||||||
|
// check: shape detected is a cylinder
|
||||||
if (!cyl)
|
if (!cyl)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue