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/property_map.h>
|
||||
|
||||
const int rounds = 50;
|
||||
const int ptsCount = 1000;
|
||||
const int rounds = 50; // TODO: capitalize constant: NB_ROUNDS
|
||||
const int ptsCount = 1000; // TODO: capitalize constant NB_POINTS
|
||||
|
||||
template <class K>
|
||||
bool test_cylinder_parameters() {
|
||||
|
|
@ -27,22 +27,25 @@ bool test_cylinder_parameters() {
|
|||
|
||||
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;
|
||||
|
||||
K::FT radius = 0;
|
||||
// generate random points on random cylinder
|
||||
K::FT radius = (FT)0; // radius will be randomly generated by sampleRandomCylinderInBox
|
||||
Vector axis;
|
||||
Point center;
|
||||
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));
|
||||
|
||||
// add outliers in second half of rounds
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
Efficient_ransac ransac;
|
||||
|
||||
ransac.add_shape_factory<Cylinder>();
|
||||
|
|
@ -65,15 +68,17 @@ bool test_cylinder_parameters() {
|
|||
|
||||
Efficient_ransac::Shape_range shapes = ransac.shapes();
|
||||
|
||||
// check: unique shape detected
|
||||
if (shapes.size() != 1)
|
||||
continue;
|
||||
|
||||
boost::shared_ptr<Cylinder> cyl = boost::dynamic_pointer_cast<Cylinder>((*shapes.first));
|
||||
|
||||
if (!cyl)
|
||||
// check: shape detected is a cylinder
|
||||
if (!cyl)
|
||||
continue;
|
||||
|
||||
Vector dir = cyl->axis().to_vector();
|
||||
Vector dir = cyl->axis().to_vector();
|
||||
Point pos = cyl->axis().point(0);
|
||||
|
||||
// Check radius and alignment with axis.
|
||||
|
|
|
|||
Loading…
Reference in New Issue