mirror of https://github.com/CGAL/cgal
avoid using c style arrays
This commit is contained in:
parent
93f02ccd61
commit
724ef98978
|
|
@ -4,7 +4,7 @@
|
||||||
#include <CGAL/Random.h>
|
#include <CGAL/Random.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
typedef CGAL::Simple_cartesian<double> K;
|
typedef CGAL::Simple_cartesian<double> K;
|
||||||
typedef CGAL::Min_sphere_of_points_d_traits_2<K,double> Traits;
|
typedef CGAL::Min_sphere_of_points_d_traits_2<K,double> Traits;
|
||||||
typedef CGAL::Min_sphere_of_spheres_d<Traits> Min_circle;
|
typedef CGAL::Min_sphere_of_spheres_d<Traits> Min_circle;
|
||||||
|
|
@ -14,14 +14,14 @@ int
|
||||||
main( int, char**)
|
main( int, char**)
|
||||||
{
|
{
|
||||||
const int n = 100;
|
const int n = 100;
|
||||||
Point P[n];
|
std::vector<Point> P(n);
|
||||||
CGAL::Random r; // random number generator
|
CGAL::Random r; // random number generator
|
||||||
|
|
||||||
for ( int i = 0; i < n; ++i){
|
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();
|
Min_circle::Cartesian_const_iterator ccib = mc.center_cartesian_begin(), ccie = mc.center_cartesian_end();
|
||||||
std::cout << "center:";
|
std::cout << "center:";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include <CGAL/Simple_homogeneous.h>
|
#include <CGAL/Simple_homogeneous.h>
|
||||||
#include <CGAL/Min_circle_2.h>
|
#include <CGAL/Min_circle_2.h>
|
||||||
#include <CGAL/Min_circle_2_traits_2.h>
|
#include <CGAL/Min_circle_2_traits_2.h>
|
||||||
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// typedefs
|
// typedefs
|
||||||
|
|
@ -16,15 +16,15 @@ int
|
||||||
main( int, char**)
|
main( int, char**)
|
||||||
{
|
{
|
||||||
const int n = 100;
|
const int n = 100;
|
||||||
Point P[n];
|
std::vector<Point> P(n);
|
||||||
|
|
||||||
for ( int i = 0; i < n; ++i){
|
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), ...
|
// (0,0), (-1,0), (2,0), (-3,0), ...
|
||||||
}
|
}
|
||||||
|
|
||||||
Min_circle mc1( P, P+n, false); // very slow
|
Min_circle mc1( P.begin(), P.begin() + n, false); // very slow
|
||||||
Min_circle mc2( P, P+n, true); // fast
|
Min_circle mc2( P.begin(), P.begin() +n, true); // fast
|
||||||
|
|
||||||
CGAL::IO::set_pretty_mode( std::cout);
|
CGAL::IO::set_pretty_mode( std::cout);
|
||||||
std::cout << mc2;
|
std::cout << mc2;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue