Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used std::vector instead of c-style arrays for point storage. #8709

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
8 changes: 4 additions & 4 deletions Bounding_volumes/examples/Min_circle_2/min_circle_2.cpp
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
#include <CGAL/Random.h>

#include <iostream>

#include <array>
typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Min_sphere_of_points_d_traits_2<K,double> Traits;
typedef CGAL::Min_sphere_of_spheres_d<Traits> Min_circle;
@@ -14,14 +14,14 @@ int
main( int, char**)
{
const int n = 100;
Point P[n];
std::array<Point, n> P;
CGAL::Random r; // random number generator

for ( int i = 0; i < n; ++i){
P[ i] = Point(r.get_double(), r.get_double());
P.at(i) = Point(r.get_double(), r.get_double());
}

Min_circle mc( P, P+n);
Min_circle mc( P.begin(), P.begin() + n);

Min_circle::Cartesian_const_iterator ccib = mc.center_cartesian_begin(), ccie = mc.center_cartesian_end();
std::cout << "center:";
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
#include <CGAL/Simple_homogeneous.h>
#include <CGAL/Min_circle_2.h>
#include <CGAL/Min_circle_2_traits_2.h>

#include <array>
#include <iostream>

// typedefs
@@ -16,15 +16,15 @@ int
main( int, char**)
{
const int n = 100;
Point P[n];
std::array<Point, n> P;

for ( int i = 0; i < n; ++i){
P[i] = Point( (i%2 == 0 ? i : -i), 0, 1);
P.at(i) = Point( (i%2 == 0 ? i : -i), 0, 1);
// (0,0), (-1,0), (2,0), (-3,0), ...
}

Min_circle mc1( P, P+n, false); // very slow
Min_circle mc2( P, P+n, true); // fast
Min_circle mc1( P.begin(), P.begin() + n, false); // very slow
Min_circle mc2( P.begin(), P.begin() +n, true); // fast

CGAL::IO::set_pretty_mode( std::cout);
std::cout << mc2;