From 53f5c9679b566303d529b4954d96b2b8d3c5c03a Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Tue, 26 Aug 2008 13:08:16 +0000 Subject: [PATCH] Add a using directive "using std::array" in namespace CGAL to import either: - C++0x's std:array from - TR1's std::tr1::array from - boost::array from Motivation : GCC's std::array is faster than boost::array. Move CGALi:make_array to namespace CGAL. Document CGAL::array. --- .../include/CGAL/Cartesian/Direction_2.h | 4 +- .../include/CGAL/Cartesian/Direction_3.h | 6 +-- .../include/CGAL/Cartesian/Iso_cuboid_3.h | 14 ++--- .../include/CGAL/Cartesian/Iso_rectangle_2.h | 4 +- .../include/CGAL/Cartesian/Line_2.h | 4 +- .../include/CGAL/Cartesian/Plane_3.h | 4 +- .../include/CGAL/Cartesian/Ray_2.h | 4 +- .../include/CGAL/Cartesian/Ray_3.h | 10 ++-- .../include/CGAL/Cartesian/Segment_2.h | 4 +- .../include/CGAL/Cartesian/Segment_3.h | 4 +- .../include/CGAL/Cartesian/Tetrahedron_3.h | 4 +- .../include/CGAL/Cartesian/Triangle_2.h | 4 +- .../include/CGAL/Cartesian/Triangle_3.h | 4 +- .../include/CGAL/Cartesian/Vector_2.h | 8 +-- .../include/CGAL/Cartesian/Vector_3.h | 8 +-- .../include/CGAL/IO/Dxf_reader_doubles.h | 4 +- .../include/CGAL/Qt/GraphicsViewCircleInput.h | 2 +- .../include/CGAL/Homogeneous/DirectionH2.h | 8 +-- .../include/CGAL/Homogeneous/DirectionH3.h | 6 +-- .../include/CGAL/Homogeneous/Iso_cuboidH3.h | 12 ++--- .../CGAL/Homogeneous/Iso_rectangleH2.h | 4 +- .../include/CGAL/Homogeneous/LineH2.h | 4 +- .../include/CGAL/Homogeneous/PlaneH3.h | 8 +-- .../include/CGAL/Homogeneous/VectorH2.h | 10 ++-- .../include/CGAL/Homogeneous/VectorH3.h | 12 ++--- Kernel_23/include/CGAL/Bbox_2.h | 4 +- Kernel_23/include/CGAL/Bbox_3.h | 4 +- .../doc_tex/STL_Extension_ref/array.tex | 51 ++++++++++++++++++ .../doc_tex/STL_Extension_ref/main.tex | 1 + STL_Extension/include/CGAL/array.h | 53 +++++++++++-------- .../Triangulation_incremental_builder_3.h | 12 ++--- 31 files changed, 171 insertions(+), 110 deletions(-) create mode 100644 STL_Extension/doc_tex/STL_Extension_ref/array.tex diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h index 3cab529b3aa..a89a9e33a6b 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h @@ -42,7 +42,7 @@ class DirectionC2 typedef typename R_::Segment_2 Segment_2; typedef typename R_::Direction_2 Direction_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -54,7 +54,7 @@ public: DirectionC2() {} DirectionC2(const FT &x, const FT &y) - : base(CGALi::make_array(x, y)) {} + : base(CGAL::make_array(x, y)) {} bool operator==(const DirectionC2 &d) const; bool operator!=(const DirectionC2 &d) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h index a4c5c2ca4a4..44b6047e42c 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h @@ -39,7 +39,7 @@ class DirectionC3 typedef typename R_::Segment_3 Segment_3; typedef typename R_::Direction_3 Direction_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -51,7 +51,7 @@ public: DirectionC3() {} DirectionC3(const Vector_3 &v) - : base(CGALi::make_array(v.x(), v.y(), v.z())) {} + : base(CGAL::make_array(v.x(), v.y(), v.z())) {} // { *this = v.direction(); } DirectionC3(const Line_3 &l) @@ -64,7 +64,7 @@ public: { *this = s.direction(); } DirectionC3(const FT &x, const FT &y, const FT &z) - : base(CGALi::make_array(x, y, z)) {} + : base(CGAL::make_array(x, y, z)) {} typename R::Bool_type operator==(const DirectionC3 &d) const; typename R::Bool_type operator!=(const DirectionC3 &d) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h index a804ffe1205..898159fbb1c 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h @@ -39,7 +39,7 @@ class Iso_cuboidC3 typedef typename R_::Aff_transformation_3 Aff_transformation_3; typedef typename R_::Construct_point_3 Construct_point_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -50,7 +50,7 @@ public: Iso_cuboidC3() {} Iso_cuboidC3(const Point_3 &p, const Point_3 &q, int) - : base(CGALi::make_array(p, q)) + : base(CGAL::make_array(p, q)) { // I have to remove the assertions, because of Cartesian_converter. // CGAL_kernel_assertion(p.x()<=q.x()); @@ -68,14 +68,14 @@ public: else { miny = q.y(); maxy = p.y(); } if (p.z() < q.z()) { minz = p.z(); maxz = q.z(); } else { minz = q.z(); maxz = p.z(); } - base = Rep(CGALi::make_array(construct_point_3(minx, miny, minz), + base = Rep(CGAL::make_array(construct_point_3(minx, miny, minz), construct_point_3(maxx, maxy, maxz))); } Iso_cuboidC3(const Point_3 &left, const Point_3 &right, const Point_3 &bottom, const Point_3 &top, const Point_3 &far_, const Point_3 &close) - : base(CGALi::make_array(Construct_point_3()(left.x(), bottom.y(), far_.z()), + : base(CGAL::make_array(Construct_point_3()(left.x(), bottom.y(), far_.z()), Construct_point_3()(right.x(), top.y(), close.z()))) { CGAL_kernel_precondition(!less_x(right, left)); @@ -85,7 +85,7 @@ public: Iso_cuboidC3(const FT& min_x, const FT& min_y, const FT& min_z, const FT& max_x, const FT& max_y, const FT& max_z) - : base(CGALi::make_array(Construct_point_3()(min_x, min_y, min_z), + : base(CGAL::make_array(Construct_point_3()(min_x, min_y, min_z), Construct_point_3()(max_x, max_y, max_z))) { CGAL_kernel_precondition(min_x <= max_x); @@ -98,10 +98,10 @@ public: const FT& hw) { if (hw == FT(1)) - base = Rep(CGALi::make_array(Construct_point_3()(min_hx, min_hy, min_hz), + base = Rep(CGAL::make_array(Construct_point_3()(min_hx, min_hy, min_hz), Construct_point_3()(max_hx, max_hy, max_hz))); else - base = Rep(CGALi::make_array(Construct_point_3()(min_hx/hw, min_hy/hw, min_hz/hw), + base = Rep(CGAL::make_array(Construct_point_3()(min_hx/hw, min_hy/hw, min_hz/hw), Construct_point_3()(max_hx/hw, max_hy/hw, max_hz/hw))); } diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h index bab5f547e87..c4c20299e50 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h @@ -36,7 +36,7 @@ class Iso_rectangleC2 typedef typename R_::Iso_rectangle_2 Iso_rectangle_2; typedef typename R_::Construct_point_2 Construct_point_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -50,7 +50,7 @@ public: // : base(p, q) {} Iso_rectangleC2(const Point_2 &p, const Point_2 &q, int) - : base(CGALi::make_array(p, q)) + : base(CGAL::make_array(p, q)) { // I have to remove the assertions, because of Cartesian_converter. // CGAL_kernel_assertion(p<=q); diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h index 9afa5aba9ac..03737e04818 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h @@ -41,7 +41,7 @@ class LineC2 typedef typename R_::Segment_2 Segment_2; typedef typename R_::Line_2 Line_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -53,7 +53,7 @@ public: LineC2() {} LineC2(const FT &a, const FT &b, const FT &c) - : base(CGALi::make_array(a, b, c)) {} + : base(CGAL::make_array(a, b, c)) {} typename R_::Bool_type operator==(const LineC2 &l) const; typename R_::Bool_type operator!=(const LineC2 &l) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h index 292b049ac85..3daf7aa30eb 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h @@ -45,7 +45,7 @@ class PlaneC3 typedef typename R_::Construct_point_3 Construct_point_3; typedef typename R_::Construct_point_2 Construct_point_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -66,7 +66,7 @@ public: { *this = plane_from_point_direction(p, v.direction()); } PlaneC3(const FT &a, const FT &b, const FT &c, const FT &d) - : base(CGALi::make_array(a, b, c, d)) {} + : base(CGAL::make_array(a, b, c, d)) {} PlaneC3(const Line_3 &l, const Point_3 &p) { *this = plane_from_points(l.point(), diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h index 9cc5071500c..511189c0813 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h @@ -35,7 +35,7 @@ class RayC2 typedef typename R_::Point_2 Point_2; typedef typename R_::Ray_2 Ray_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -47,7 +47,7 @@ public: {} RayC2(const Point_2 &sp, const Point_2 &secondp) - : base(CGALi::make_array(sp, secondp)) + : base(CGAL::make_array(sp, secondp)) {} diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h index 25d592c608b..47c73e06ab0 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h @@ -39,7 +39,7 @@ class RayC3 typedef typename R_::Line_3 Line_3; typedef typename R_::Ray_3 Ray_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -50,16 +50,16 @@ public: RayC3() {} RayC3(const Point_3 &sp, const Point_3 &secondp) - : base(CGALi::make_array(sp, secondp)) {} + : base(CGAL::make_array(sp, secondp)) {} RayC3(const Point_3 &sp, const Vector_3 &v) - : base(CGALi::make_array(sp, sp + v)) {} + : base(CGAL::make_array(sp, sp + v)) {} RayC3(const Point_3 &sp, const Direction_3 &d) - : base(CGALi::make_array(sp, sp + d.to_vector())) {} + : base(CGAL::make_array(sp, sp + d.to_vector())) {} RayC3(const Point_3 &sp, const Line_3 &l) - : base(CGALi::make_array(sp, sp + l.to_vector())) {} + : base(CGAL::make_array(sp, sp + l.to_vector())) {} typename R::Bool_type operator==(const RayC3 &r) const; typename R::Bool_type operator!=(const RayC3 &r) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h index d8d39100bfe..d68202508b1 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h @@ -34,7 +34,7 @@ class SegmentC2 typedef typename R_::Point_2 Point_2; typedef typename R_::Segment_2 Segment_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -46,7 +46,7 @@ public: {} SegmentC2(const Point_2 &sp, const Point_2 &ep) - : base(CGALi::make_array(sp, ep)) + : base(CGAL::make_array(sp, ep)) {} const Point_2 & diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h index 3f12644e5a6..e786f92d075 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h @@ -38,7 +38,7 @@ class SegmentC3 typedef typename R_::Line_3 Line_3; typedef typename R_::Segment_3 Segment_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -49,7 +49,7 @@ public: SegmentC3() {} SegmentC3(const Point_3 &sp, const Point_3 &ep) - : base(CGALi::make_array(sp, ep)) {} + : base(CGAL::make_array(sp, ep)) {} bool has_on(const Point_3 &p) const; bool collinear_has_on(const Point_3 &p) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h index 34ffcea31a6..c51310bcd81 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h @@ -39,7 +39,7 @@ class TetrahedronC3 typedef typename R_::Plane_3 Plane_3; typedef typename R_::Tetrahedron_3 Tetrahedron_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -51,7 +51,7 @@ public: TetrahedronC3(const Point_3 &p, const Point_3 &q, const Point_3 &r, const Point_3 &s) - : base(CGALi::make_array(p, q, r, s)) {} + : base(CGAL::make_array(p, q, r, s)) {} const Point_3 & vertex(int i) const; const Point_3 & operator[](int i) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h index 38969cb109a..d160bb2b2d3 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h @@ -37,7 +37,7 @@ class TriangleC2 typedef typename R_::Vector_2 Vector_2; typedef typename R_::Triangle_2 Triangle_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -48,7 +48,7 @@ public: TriangleC2() {} TriangleC2(const Point_2 &p, const Point_2 &q, const Point_2 &r) - : base(CGALi::make_array(p, q, r)) {} + : base(CGAL::make_array(p, q, r)) {} const Point_2 & diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h index 33b5667fbaf..6ceb51d296c 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h @@ -38,7 +38,7 @@ class TriangleC3 typedef typename R_::Plane_3 Plane_3; typedef typename R_::Triangle_3 Triangle_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -49,7 +49,7 @@ public: TriangleC3() {} TriangleC3(const Point_3 &p, const Point_3 &q, const Point_3 &r) - : base(CGALi::make_array(p, q, r)) {} + : base(CGAL::make_array(p, q, r)) {} bool operator==(const TriangleC3 &t) const; bool operator!=(const TriangleC3 &t) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h index 31fa7177de9..0ab9959893b 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h @@ -42,7 +42,7 @@ class VectorC2 typedef typename R_::Line_2 Line_2; typedef typename R_::Direction_2 Direction_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -56,11 +56,11 @@ public: VectorC2() {} VectorC2(const FT &x, const FT &y) - : base(CGALi::make_array(x, y)) {} + : base(CGAL::make_array(x, y)) {} VectorC2(const FT &hx, const FT &hy, const FT &hw) - : base( hw != FT(1) ? CGALi::make_array(hx/hw, hy/hw) - : CGALi::make_array(hx, hy) ) {} + : base( hw != FT(1) ? CGAL::make_array(hx/hw, hy/hw) + : CGAL::make_array(hx, hy) ) {} const FT & x() const { diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index ebd7657b531..af6c7f951e7 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -41,7 +41,7 @@ class VectorC3 typedef typename R_::Line_3 Line_3; typedef typename R_::Direction_3 Direction_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -70,11 +70,11 @@ public: { *this = R().construct_vector_3_object()(l); } VectorC3(const FT &x, const FT &y, const FT &z) - : base(CGALi::make_array(x, y, z)) {} + : base(CGAL::make_array(x, y, z)) {} VectorC3(const FT &x, const FT &y, const FT &z, const FT &w) - : base( w != FT(1) ? CGALi::make_array(x/w, y/w, z/w) - : CGALi::make_array(x, y, z) ) {} + : base( w != FT(1) ? CGAL::make_array(x/w, y/w, z/w) + : CGAL::make_array(x, y, z) ) {} const FT & x() const { diff --git a/Circular_kernel_2/include/CGAL/IO/Dxf_reader_doubles.h b/Circular_kernel_2/include/CGAL/IO/Dxf_reader_doubles.h index 235d7f4f274..ebd3c787e63 100644 --- a/Circular_kernel_2/include/CGAL/IO/Dxf_reader_doubles.h +++ b/Circular_kernel_2/include/CGAL/IO/Dxf_reader_doubles.h @@ -137,7 +137,7 @@ private: is >> r; FT rft(r); - circ = CGALi::make_array(cx,cy,rft); + circ = CGAL::make_array(cx,cy,rft); } @@ -176,7 +176,7 @@ read_polygon(std::istream& is, Polygon& poly) } else { CGAL_assertion(n == 0); } - poly.push_back(CGALi::make_array(x,y, len)); + poly.push_back(CGAL::make_array(x,y, len)); } } while (str != "SEQEND"); diff --git a/GraphicsView/include/CGAL/Qt/GraphicsViewCircleInput.h b/GraphicsView/include/CGAL/Qt/GraphicsViewCircleInput.h index 0e92233d2f7..6f38485a06f 100644 --- a/GraphicsView/include/CGAL/Qt/GraphicsViewCircleInput.h +++ b/GraphicsView/include/CGAL/Qt/GraphicsViewCircleInput.h @@ -98,7 +98,7 @@ GraphicsViewCircleInput::mousePressEvent(QGraphicsSceneMouseEvent *event) r = convert(qr); typename K::Collinear_2 collinear; if(! collinear(p,q,r)){ - emit generate(CGAL::make_object(CGALi::make_array(p,q,r))); + emit generate(CGAL::make_object(CGAL::make_array(p,q,r))); count = 0; } } diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH2.h index ce492d42c46..88c7f091f8f 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH2.h @@ -40,7 +40,7 @@ class DirectionH2 typedef typename R_::Ray_2 Ray_2; typedef typename R_::Segment_2 Segment_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -60,13 +60,13 @@ public: DirectionH2() {} DirectionH2(const RT& x, const RT& y) - : base(CGALi::make_array(x, y, RT(1))) {} + : base(CGAL::make_array(x, y, RT(1))) {} // TODO Not documented : should not exist, not used. // we should also change array -> array DirectionH2(const RT& x, const RT& y, const RT& w ) - : base( w > RT(0) ? CGALi::make_array(x, y, w) - : CGALi::make_array(-x, -y, -w) ) {} + : base( w > RT(0) ? CGAL::make_array(x, y, w) + : CGAL::make_array(-x, -y, -w) ) {} bool operator==( const DirectionH2& d) const; bool operator!=( const DirectionH2& d) const; diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH3.h index 5f7f8ed0c48..24f00d21469 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH3.h @@ -39,7 +39,7 @@ class DirectionH3 typedef typename R_::Line_3 Line_3; typedef typename R_::Ray_3 Ray_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -68,8 +68,8 @@ public: // the fourth argument is not documented. Should go away ? DirectionH3(const RT& x, const RT& y, const RT& z, const RT& w = RT(1) ) - : base( w >= RT(0) ? CGALi::make_array(x, y, z, w) - : CGALi::make_array(-x, -y, -z, -w) ) {} + : base( w >= RT(0) ? CGAL::make_array(x, y, z, w) + : CGAL::make_array(-x, -y, -z, -w) ) {} bool is_degenerate() const; diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_cuboidH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_cuboidH3.h index 70946dcdd98..4443c44c6e2 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_cuboidH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_cuboidH3.h @@ -36,7 +36,7 @@ class Iso_cuboidH3 typedef typename R_::Point_3 Point_3; typedef typename R_::Aff_transformation_3 Aff_transformation_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -47,7 +47,7 @@ public: Iso_cuboidH3() {} Iso_cuboidH3(const Point_3& p, const Point_3& q, int) - : base(CGALi::make_array(p, q)) + : base(CGAL::make_array(p, q)) { CGAL_kernel_assertion(p.x()<=q.x()); CGAL_kernel_assertion(p.y()<=q.y()); @@ -145,7 +145,7 @@ Iso_cuboidH3(const typename Iso_cuboidH3::Point_3& p, minz = q.hz()*p.hw(); maxz = p.hz()*q.hw(); } - base = Rep(CGALi::make_array(Point_3(minx, miny, minz, minw), + base = Rep(CGAL::make_array(Point_3(minx, miny, minz, minw), Point_3(maxx, maxy, maxz, maxw))); } @@ -158,7 +158,7 @@ Iso_cuboidH3(const typename Iso_cuboidH3::Point_3& left, const typename Iso_cuboidH3::Point_3& top, const typename Iso_cuboidH3::Point_3& far_, const typename Iso_cuboidH3::Point_3& close) - : base(CGALi::make_array(Point_3(left.hx() * bottom.hw() * far_.hw(), + : base(CGAL::make_array(Point_3(left.hx() * bottom.hw() * far_.hw(), bottom.hy() * left.hw() * far_.hw(), far_.hz() * left.hw() * bottom.hw(), left.hw() * bottom.hw() * far_.hw()), @@ -177,7 +177,7 @@ CGAL_KERNEL_LARGE_INLINE Iso_cuboidH3:: Iso_cuboidH3(const RT& min_hx, const RT& min_hy, const RT& min_hz, const RT& max_hx, const RT& max_hy, const RT& max_hz) - : base(CGALi::make_array(Point_3(min_hx, min_hy, min_hz, RT(1)), + : base(CGAL::make_array(Point_3(min_hx, min_hy, min_hz, RT(1)), Point_3(max_hx, max_hy, max_hz, RT(1)))) {} @@ -187,7 +187,7 @@ Iso_cuboidH3:: Iso_cuboidH3(const RT& min_hx, const RT& min_hy, const RT& min_hz, const RT& max_hx, const RT& max_hy, const RT& max_hz, const RT& hw) - : base(CGALi::make_array(Point_3(min_hx, min_hy, min_hz, hw), + : base(CGAL::make_array(Point_3(min_hx, min_hy, min_hz, hw), Point_3(max_hx, max_hy, max_hz, hw))) {} diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_rectangleH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_rectangleH2.h index a56b6784503..48e73b3e8db 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_rectangleH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_rectangleH2.h @@ -36,7 +36,7 @@ class Iso_rectangleH2 typedef typename R_::Point_2 Point_2; typedef typename R_::Iso_rectangle_2 Iso_rectangle_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -49,7 +49,7 @@ public: Iso_rectangleH2() {} Iso_rectangleH2(const Point_2& p, const Point_2& q, int) - : base(CGALi::make_array(p, q)) + : base(CGAL::make_array(p, q)) { // I have to remove the assertions, because of Homogeneous_converter. // CGAL_kernel_assertion(p.x()<=q.x()); diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/LineH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/LineH2.h index edc9e3385d3..0012b8591b6 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/LineH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/LineH2.h @@ -40,7 +40,7 @@ class LineH2 typedef typename R_::Ray_2 Ray_2; typedef typename R_::Line_2 Line_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -51,7 +51,7 @@ public: LineH2() {} LineH2(const RT& a, const RT& b, const RT& c) - : base(CGALi::make_array(a, b, c)) {} + : base(CGAL::make_array(a, b, c)) {} bool operator==(const LineH2& l) const; bool operator!=(const LineH2& l) const; diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/PlaneH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/PlaneH3.h index 3d0df1f9087..46f17c5fde0 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/PlaneH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/PlaneH3.h @@ -43,7 +43,7 @@ class PlaneH3 typedef typename R_::Plane_3 Plane_3; typedef typename R_::Aff_transformation_3 Aff_transformation_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; Base base; @@ -118,7 +118,7 @@ protected: // | q.hx() q.hy() q.hz() q.hw() | // | r.hx() r.hy() r.hz() r.hw() | // -// boost::array ( a(), b(), c(), d() ) +// CGAL::array ( a(), b(), c(), d() ) template < class R > inline @@ -142,7 +142,7 @@ PlaneH3::new_rep(const typename PlaneH3::Point_3 &p, RT rhz = r.hz(); RT rhw = r.hw(); - base = CGALi::make_array( + base = CGAL::make_array( phy*( qhz*rhw - qhw*rhz ) - qhy*( phz*rhw - phw*rhz ) // * X + rhy*( phz*qhw - phw*qhz ), @@ -164,7 +164,7 @@ template < class R > inline void PlaneH3::new_rep(const RT &a, const RT &b, const RT &c, const RT &d) -{ base = CGALi::make_array(a, b, c, d); } +{ base = CGAL::make_array(a, b, c, d); } template < class R > inline diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH2.h index f56caecc5ce..a7f84eecac1 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH2.h @@ -44,7 +44,7 @@ class VectorH2 typedef typename R_::Direction_2 Direction_2; typedef typename R_::Vector_2 Vector_2; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; typedef Rational_traits Rat_traits; @@ -65,10 +65,10 @@ public: VectorH2(const Tx & x, const Ty & y, typename boost::enable_if< boost::mpl::and_, boost::is_convertible > >::type* = 0) - : base(CGALi::make_array(x, y, RT(1))) {} + : base(CGAL::make_array(x, y, RT(1))) {} VectorH2(const FT& x, const FT& y) - : base(CGALi::make_array( + : base(CGAL::make_array( Rat_traits().numerator(x) * Rat_traits().denominator(y), Rat_traits().numerator(y) * Rat_traits().denominator(x), Rat_traits().denominator(x) * Rat_traits().denominator(y))) @@ -77,8 +77,8 @@ public: } VectorH2(const RT& x, const RT& y, const RT& w ) - : base( w >= RT(0) ? CGALi::make_array( x, y, w) - : CGALi::make_array(-x, -y, -w) ) {} + : base( w >= RT(0) ? CGAL::make_array( x, y, w) + : CGAL::make_array(-x, -y, -w) ) {} const Self& rep() const diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH3.h index 1b4a46060d9..56c9929cc82 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH3.h @@ -42,7 +42,7 @@ class VectorH3 typedef typename R_::Line_3 Line_3; typedef typename R_::Direction_3 Direction_3; - typedef boost::array Rep; + typedef CGAL::array Rep; typedef typename R_::template Handle::type Base; typedef Rational_traits Rat_traits; @@ -70,17 +70,17 @@ public: { *this = R().construct_vector_3_object()(l); } VectorH3(const Null_vector&) - : base(CGALi::make_array(RT(0), RT(0), RT(0), RT(1))) {} + : base(CGAL::make_array(RT(0), RT(0), RT(0), RT(1))) {} template < typename Tx, typename Ty, typename Tz > VectorH3(const Tx & x, const Ty & y, const Tz & z, typename boost::enable_if< boost::mpl::and_< boost::mpl::and_< boost::is_convertible, boost::is_convertible >, boost::is_convertible > >::type* = 0) - : base(CGALi::make_array(x, y, z, RT(1))) {} + : base(CGAL::make_array(x, y, z, RT(1))) {} VectorH3(const FT& x, const FT& y, const FT& z) - : base(CGALi::make_array( + : base(CGAL::make_array( Rat_traits().numerator(x) * Rat_traits().denominator(y) * Rat_traits().denominator(z), Rat_traits().numerator(y) * Rat_traits().denominator(x) @@ -94,8 +94,8 @@ public: } VectorH3(const RT& x, const RT& y, const RT& z, const RT& w) - : base( w >= RT(0) ? CGALi::make_array(x, y, z, w) - : CGALi::make_array(-x, -y, -z, -w) ) {} + : base( w >= RT(0) ? CGAL::make_array(x, y, z, w) + : CGAL::make_array(-x, -y, -z, -w) ) {} const RT & hx() const { return get(base)[0]; } const RT & hy() const { return get(base)[1]; } diff --git a/Kernel_23/include/CGAL/Bbox_2.h b/Kernel_23/include/CGAL/Bbox_2.h index c1f0482d0e4..35e68be4c11 100644 --- a/Kernel_23/include/CGAL/Bbox_2.h +++ b/Kernel_23/include/CGAL/Bbox_2.h @@ -36,7 +36,7 @@ struct Simple_cartesian; class Bbox_2 { - typedef boost::array BBox_rep_2; + typedef CGAL::array BBox_rep_2; BBox_rep_2 rep; @@ -51,7 +51,7 @@ public: Bbox_2(double x_min, double y_min, double x_max, double y_max) - : rep(CGALi::make_array(x_min, y_min, x_max, y_max)) {} + : rep(CGAL::make_array(x_min, y_min, x_max, y_max)) {} inline bool operator==(const Bbox_2 &b) const; inline bool operator!=(const Bbox_2 &b) const; diff --git a/Kernel_23/include/CGAL/Bbox_3.h b/Kernel_23/include/CGAL/Bbox_3.h index 86fb31e8f39..2fb9d8c90a3 100644 --- a/Kernel_23/include/CGAL/Bbox_3.h +++ b/Kernel_23/include/CGAL/Bbox_3.h @@ -35,7 +35,7 @@ struct Simple_cartesian; class Bbox_3 { - boost::array rep; + CGAL::array rep; public: @@ -48,7 +48,7 @@ public: Bbox_3(double x_min, double y_min, double z_min, double x_max, double y_max, double z_max) - : rep(CGALi::make_array(x_min, y_min, z_min, x_max, y_max, z_max)) {} + : rep(CGAL::make_array(x_min, y_min, z_min, x_max, y_max, z_max)) {} inline bool operator==(const Bbox_3 &b) const; inline bool operator!=(const Bbox_3 &b) const; diff --git a/STL_Extension/doc_tex/STL_Extension_ref/array.tex b/STL_Extension/doc_tex/STL_Extension_ref/array.tex new file mode 100644 index 00000000000..395717fddca --- /dev/null +++ b/STL_Extension/doc_tex/STL_Extension_ref/array.tex @@ -0,0 +1,51 @@ +%% ============================================================================= +%% The CGAL Reference Manual +%% Chapter: STL Extensions - The Reference Part +%% ----------------------------------------------------------------------------- +%% author: Sylvain Pion +%% ----------------------------------------------------------------------------- +%% $Id$ +%% $URL$ +%% ============================================================================= + +%% +=========================================================================+ + +\begin{ccRefClass}{array} + +\ccDefinition + +An object of the class \ccClassTemplateName\ represents an array of elements +of type \ccc{T}, the number of which is specified by the second template argument. + +There is actually no class in \cgal\ with this name, but a using declaration which +imports a class from another namespace. By order of priority: the one in namespace +\ccc{std} is used (provided by C++0x), if not found, then the one in namespace +\ccc{std::tr1} is used (provided by TR1), and finally, the fallback solution +is taken from Boost. + + \ccInclude{CGAL/array.h} + + %% +-----------------------------------+ + \ccParameters + + The parameter \ccStyle{T} is the value type. The second parameter is the + dimension of the array. + + %% +-----------------------------------+ + \ccHeading{Construction functions} + + The array class does not provide a constructor which can be used to initialize + data members. \cgal\ therefore provides a \ccc{make_array} function for + this purpose, up to a certain number of arguments. + + \def\ccTagRmEigenClassName{\ccFalse} + \ccFunction{template array make_array(const T& a);} + {returns an array of dimension 1 whose first element is \ccc{a}.} + + \ccFunction{template array make_array(const T& a1, const T& a2);} + {returns an array of dimension 2 whose first element is \ccc{a1} + and second element is \ccc{a2}.} + +\end{ccRefClass} + +\ccParDims diff --git a/STL_Extension/doc_tex/STL_Extension_ref/main.tex b/STL_Extension/doc_tex/STL_Extension_ref/main.tex index e8d4a123c64..a0deaab5527 100644 --- a/STL_Extension/doc_tex/STL_Extension_ref/main.tex +++ b/STL_Extension/doc_tex/STL_Extension_ref/main.tex @@ -33,6 +33,7 @@ \input{STL_Extension_ref/Object.tex} \input{STL_Extension_ref/stl_extension.tex} \input{STL_Extension_ref/Uncertain.tex} +\input{STL_Extension_ref/array.tex} %%\cgalColumnLayout diff --git a/STL_Extension/include/CGAL/array.h b/STL_Extension/include/CGAL/array.h index 498e8849d30..43ce4fa18fb 100644 --- a/STL_Extension/include/CGAL/array.h +++ b/STL_Extension/include/CGAL/array.h @@ -20,15 +20,27 @@ #ifndef CGAL_ARRAY_H #define CGAL_ARRAY_H -#include -#include +#include +#ifndef CGAL_CFG_NO_CPP0X_ARRAY +# include +#elif !defined CGAL_CFG_NO_TR1_ARRAY +# include +#else +# include +#endif CGAL_BEGIN_NAMESPACE -namespace CGALi { +#ifndef CGAL_CFG_NO_CPP0X_ARRAY +using std::array; +#elif !defined CGAL_CFG_NO_TR1_ARRAY +using std::tr1::array; +#else +using boost::array; +#endif -// The make_array() function simply constructs a boost::array. -// It is needed for cases where a boost::array is used as a class data +// The make_array() function simply constructs an std::array. +// It is needed for cases where a std::array is used as a class data // member and you want to initialize it in the member initializers list. // It is also optimized: no spurious copies of the objects are made, // provided the compiler does the NRVO. So this is better than @@ -45,69 +57,66 @@ namespace CGALi { template< typename T, typename... Args > inline -boost::array< T, 1 + sizeof...(Args) > +array< T, 1 + sizeof...(Args) > make_array(const T & t, const Args & ... args) { - boost::array< T, 1 + sizeof...(Args) > a = { { t, args... } }; + array< T, 1 + sizeof...(Args) > a = { { t, args... } }; return a; } #else // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES template < typename T > inline -boost::array +array make_array(const T& b1) { - boost::array a = { { b1 } }; + array a = { { b1 } }; return a; } template < typename T > inline -boost::array +array make_array(const T& b1, const T& b2) { - boost::array a = { { b1, b2 } }; + array a = { { b1, b2 } }; return a; } template < typename T > inline -boost::array +array make_array(const T& b1, const T& b2, const T& b3) { - boost::array a = { { b1, b2, b3 } }; + array a = { { b1, b2, b3 } }; return a; } template < typename T > inline -boost::array +array make_array(const T& b1, const T& b2, const T& b3, const T& b4) { - boost::array a = { { b1, b2, b3, b4 } }; + array a = { { b1, b2, b3, b4 } }; return a; } template < typename T > inline -boost::array +array make_array(const T& b1, const T& b2, const T& b3, const T& b4, const T& b5) { - boost::array a = { { b1, b2, b3, b4, b5 } }; + array a = { { b1, b2, b3, b4, b5 } }; return a; } template < typename T > inline -boost::array +array make_array(const T& b1, const T& b2, const T& b3, const T& b4, const T& b5, const T& b6) { - boost::array a = { { b1, b2, b3, b4, b5, b6 } }; + array a = { { b1, b2, b3, b4, b5, b6 } }; return a; } - #endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES -} // namespace CGALi - CGAL_END_NAMESPACE #endif // CGAL_ARRAY_H diff --git a/Skin_surface_3/include/CGAL/Triangulation_incremental_builder_3.h b/Skin_surface_3/include/CGAL/Triangulation_incremental_builder_3.h index b079a7ceae9..a4bd81a1056 100644 --- a/Skin_surface_3/include/CGAL/Triangulation_incremental_builder_3.h +++ b/Skin_surface_3/include/CGAL/Triangulation_incremental_builder_3.h @@ -77,22 +77,22 @@ private: Vtriple facet(Vertex_handle vh1, Vertex_handle vh2, Vertex_handle vh3) { if (vh1 < vh2) { if (vh2 < vh3) { - return CGALi::make_array(vh1,vh2,vh3); + return CGAL::make_array(vh1,vh2,vh3); } else { if (vh1 < vh3) { - return CGALi::make_array(vh1,vh3,vh2); + return CGAL::make_array(vh1,vh3,vh2); } else { - return CGALi::make_array(vh3,vh1,vh2); + return CGAL::make_array(vh3,vh1,vh2); } } } if (vh1 < vh3) { - return CGALi::make_array(vh2,vh1,vh3); + return CGAL::make_array(vh2,vh1,vh3); } else { if (vh2 < vh3) { - return CGALi::make_array(vh2,vh3,vh1); + return CGAL::make_array(vh2,vh3,vh1); } else { - return CGALi::make_array(vh3,vh2,vh1); + return CGAL::make_array(vh3,vh2,vh1); } } }