mirror of https://github.com/CGAL/cgal
used std::array for point storage in the following examples of Bounding_volumes (1)min_annulus_d_fast_exact.cpp (2)min_annulus_d.cpp (3)min_ellipse_2.cpp (4)min_sphere_3.cpp (5)min_sphere_homogenous_3.cpp
This commit is contained in:
parent
27c788d1d3
commit
057caa3d19
|
|
@ -6,6 +6,7 @@
|
|||
#include <CGAL/Homogeneous.h>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <array>
|
||||
|
||||
#ifdef CGAL_USE_GMP
|
||||
#include <CGAL/Gmpzf.h>
|
||||
|
|
@ -25,10 +26,10 @@ typedef CGAL::Min_annulus_d<Traits> Min_annulus;
|
|||
int main()
|
||||
{
|
||||
// points on the squares [-1,1]^2 and [-2,2]^2
|
||||
Point P[8] = { Point(-1,-1), Point(-1,1), Point(1,-1), Point(1,1),
|
||||
std::array<Point, 8> P = { Point(-1,-1), Point(-1,1), Point(1,-1), Point(1,1),
|
||||
Point(-2,-2), Point(-2,2), Point(2,-2), Point(2,2)};
|
||||
|
||||
Min_annulus ma(P, P+8);
|
||||
Min_annulus ma(P.begin(), P.end());
|
||||
assert (ma.is_valid());
|
||||
|
||||
// get center of annulus
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ typedef CGAL::Exact_integer ET;
|
|||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#include <array>
|
||||
// use an inexact kernel...
|
||||
typedef CGAL::Homogeneous<double> K;
|
||||
typedef K::Point_2 Point;
|
||||
|
|
@ -24,10 +24,10 @@ typedef CGAL::Min_annulus_d<Traits> Min_annulus;
|
|||
int main()
|
||||
{
|
||||
// points on the squares [-1,1]^2 and [-2,2]^2
|
||||
Point P[8] = { Point(-1,-1), Point(-1,1), Point(1,-1), Point(1,1),
|
||||
std::array<Point, 8> P = { Point(-1,-1), Point(-1,1), Point(1,-1), Point(1,1),
|
||||
Point(-2,-2), Point(-2,2), Point(2,-2), Point(2,2)};
|
||||
|
||||
Min_annulus ma(P, P+8);
|
||||
Min_annulus ma(P.begin(), P.end());
|
||||
assert (ma.is_valid());
|
||||
|
||||
// get center of annulus
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <CGAL/Exact_rational.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <array>
|
||||
typedef CGAL::Exact_rational NT;
|
||||
typedef CGAL::Cartesian<NT> K;
|
||||
typedef CGAL::Point_2<K> Point;
|
||||
|
|
@ -16,20 +16,20 @@ int
|
|||
main( int, char**)
|
||||
{
|
||||
const int n = 200;
|
||||
Point P[n];
|
||||
std::array<Point, n> P;
|
||||
|
||||
for ( int i = 0; i < n; ++i)
|
||||
P[ i] = Point( i % 2 ? i : -i , 0);
|
||||
P.at(i) = Point( i % 2 ? i : -i , 0);
|
||||
// (0,0), (-1,0), (2,0), (-3,0)
|
||||
|
||||
std::cout << "Computing ellipse (without randomization)...";
|
||||
std::cout.flush();
|
||||
Min_ellipse me1( P, P+n, false); // very slow
|
||||
Min_ellipse me1( P.begin(), P.end(), false); // very slow
|
||||
std::cout << "done." << std::endl;
|
||||
|
||||
std::cout << "Computing ellipse (with randomization)...";
|
||||
std::cout.flush();
|
||||
Min_ellipse me2( P, P+n, true); // fast
|
||||
Min_ellipse me2( P.begin(), P.end(), true); // fast
|
||||
std::cout << "done." << std::endl;
|
||||
|
||||
// because all input points are collinear, the ellipse is
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <array>
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
typedef CGAL::Min_sphere_of_points_d_traits_3<K,double> Traits;
|
||||
typedef CGAL::Min_sphere_of_spheres_d<Traits> Min_sphere;
|
||||
|
|
@ -16,16 +16,16 @@ const int d = 3; // dimension of points
|
|||
|
||||
int main ()
|
||||
{
|
||||
Point P[n]; // n points
|
||||
std::array<Point, n> P; // n points
|
||||
CGAL::Random r; // random number generator
|
||||
|
||||
for (int i=0; i<n; ++i) {
|
||||
for (int j = 0; j < d; ++j) {
|
||||
P[i] = Point(r.get_double(), r.get_double(), r.get_double()); // random point
|
||||
P.at(i) = Point(r.get_double(), r.get_double(), r.get_double()); // random point
|
||||
}
|
||||
}
|
||||
|
||||
Min_sphere ms(P, P+n); // smallest enclosing sphere
|
||||
Min_sphere ms(P.begin(), P.end()); // smallest enclosing sphere
|
||||
|
||||
Min_sphere::Cartesian_const_iterator ccib = ms.center_cartesian_begin(), ccie = ms.center_cartesian_end();
|
||||
std::cout << "center:";
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ int
|
|||
main ()
|
||||
{
|
||||
const int n = 10; // number of points
|
||||
Point P[n]; // n points
|
||||
std::array<Point, n> P; // n points
|
||||
CGAL::Random r; // random number generator
|
||||
|
||||
for (int i=0; i<n; ++i) {
|
||||
P[i] = Point(r.get_int(0, 1000),r.get_int(0, 1000), r.get_int(0, 1000), 1 );
|
||||
P.at(i) = Point(r.get_int(0, 1000),r.get_int(0, 1000), r.get_int(0, 1000), 1 );
|
||||
}
|
||||
|
||||
Min_sphere ms (P, P+n); // smallest enclosing sphere
|
||||
Min_sphere ms (P.begin(), P.end()); // smallest enclosing sphere
|
||||
|
||||
CGAL::IO::set_pretty_mode (std::cout);
|
||||
std::cout << ms; // output the sphere
|
||||
|
|
|
|||
Loading…
Reference in New Issue