Add a using directive "using std::array" in namespace CGAL to import either:

- C++0x's std:array from <array>
- TR1's std::tr1::array from <tr1/array>
- boost::array from <boost/array.hpp>
Motivation : GCC's std::array is faster than boost::array.

Move CGALi:make_array to namespace CGAL.

Document CGAL::array.
This commit is contained in:
Sylvain Pion 2008-08-26 13:08:16 +00:00
parent 39e7a3537e
commit 53f5c9679b
31 changed files with 171 additions and 110 deletions

View File

@ -42,7 +42,7 @@ class DirectionC2
typedef typename R_::Segment_2 Segment_2;
typedef typename R_::Direction_2 Direction_2;
typedef boost::array<FT, 2> Rep;
typedef CGAL::array<FT, 2> Rep;
typedef typename R_::template Handle<Rep>::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;

View File

@ -39,7 +39,7 @@ class DirectionC3
typedef typename R_::Segment_3 Segment_3;
typedef typename R_::Direction_3 Direction_3;
typedef boost::array<FT, 3> Rep;
typedef CGAL::array<FT, 3> Rep;
typedef typename R_::template Handle<Rep>::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;

View File

@ -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<Point_3, 2> Rep;
typedef CGAL::array<Point_3, 2> Rep;
typedef typename R_::template Handle<Rep>::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)));
}

View File

@ -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<Point_2, 2> Rep;
typedef CGAL::array<Point_2, 2> Rep;
typedef typename R_::template Handle<Rep>::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);

View File

@ -41,7 +41,7 @@ class LineC2
typedef typename R_::Segment_2 Segment_2;
typedef typename R_::Line_2 Line_2;
typedef boost::array<FT, 3> Rep;
typedef CGAL::array<FT, 3> Rep;
typedef typename R_::template Handle<Rep>::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;

View File

@ -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<FT, 4> Rep;
typedef CGAL::array<FT, 4> Rep;
typedef typename R_::template Handle<Rep>::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(),

View File

@ -35,7 +35,7 @@ class RayC2
typedef typename R_::Point_2 Point_2;
typedef typename R_::Ray_2 Ray_2;
typedef boost::array<Point_2, 2> Rep;
typedef CGAL::array<Point_2, 2> Rep;
typedef typename R_::template Handle<Rep>::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))
{}

View File

@ -39,7 +39,7 @@ class RayC3
typedef typename R_::Line_3 Line_3;
typedef typename R_::Ray_3 Ray_3;
typedef boost::array<Point_3, 2> Rep;
typedef CGAL::array<Point_3, 2> Rep;
typedef typename R_::template Handle<Rep>::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;

View File

@ -34,7 +34,7 @@ class SegmentC2
typedef typename R_::Point_2 Point_2;
typedef typename R_::Segment_2 Segment_2;
typedef boost::array<Point_2, 2> Rep;
typedef CGAL::array<Point_2, 2> Rep;
typedef typename R_::template Handle<Rep>::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 &

View File

@ -38,7 +38,7 @@ class SegmentC3
typedef typename R_::Line_3 Line_3;
typedef typename R_::Segment_3 Segment_3;
typedef boost::array<Point_3, 2> Rep;
typedef CGAL::array<Point_3, 2> Rep;
typedef typename R_::template Handle<Rep>::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;

View File

@ -39,7 +39,7 @@ class TetrahedronC3
typedef typename R_::Plane_3 Plane_3;
typedef typename R_::Tetrahedron_3 Tetrahedron_3;
typedef boost::array<Point_3, 4> Rep;
typedef CGAL::array<Point_3, 4> Rep;
typedef typename R_::template Handle<Rep>::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;

View File

@ -37,7 +37,7 @@ class TriangleC2
typedef typename R_::Vector_2 Vector_2;
typedef typename R_::Triangle_2 Triangle_2;
typedef boost::array<Point_2, 3> Rep;
typedef CGAL::array<Point_2, 3> Rep;
typedef typename R_::template Handle<Rep>::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 &

View File

@ -38,7 +38,7 @@ class TriangleC3
typedef typename R_::Plane_3 Plane_3;
typedef typename R_::Triangle_3 Triangle_3;
typedef boost::array<Point_3, 3> Rep;
typedef CGAL::array<Point_3, 3> Rep;
typedef typename R_::template Handle<Rep>::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;

View File

@ -42,7 +42,7 @@ class VectorC2
typedef typename R_::Line_2 Line_2;
typedef typename R_::Direction_2 Direction_2;
typedef boost::array<FT, 2> Rep;
typedef CGAL::array<FT, 2> Rep;
typedef typename R_::template Handle<Rep>::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
{

View File

@ -41,7 +41,7 @@ class VectorC3
typedef typename R_::Line_3 Line_3;
typedef typename R_::Direction_3 Direction_3;
typedef boost::array<FT, 3> Rep;
typedef CGAL::array<FT, 3> Rep;
typedef typename R_::template Handle<Rep>::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
{

View File

@ -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");

View File

@ -98,7 +98,7 @@ GraphicsViewCircleInput<K>::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;
}
}

View File

@ -40,7 +40,7 @@ class DirectionH2
typedef typename R_::Ray_2 Ray_2;
typedef typename R_::Segment_2 Segment_2;
typedef boost::array<RT, 3> Rep;
typedef CGAL::array<RT, 3> Rep;
typedef typename R_::template Handle<Rep>::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<RT, 3> -> array<RT, 2>
DirectionH2(const RT& x, const RT& y, const RT& w )
: base( w > RT(0) ? CGALi::make_array(x, y, w)
: CGALi::make_array<RT>(-x, -y, -w) ) {}
: base( w > RT(0) ? CGAL::make_array(x, y, w)
: CGAL::make_array<RT>(-x, -y, -w) ) {}
bool operator==( const DirectionH2<R>& d) const;
bool operator!=( const DirectionH2<R>& d) const;

View File

@ -39,7 +39,7 @@ class DirectionH3
typedef typename R_::Line_3 Line_3;
typedef typename R_::Ray_3 Ray_3;
typedef boost::array<RT, 4> Rep;
typedef CGAL::array<RT, 4> Rep;
typedef typename R_::template Handle<Rep>::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<RT>(-x, -y, -z, -w) ) {}
: base( w >= RT(0) ? CGAL::make_array(x, y, z, w)
: CGAL::make_array<RT>(-x, -y, -z, -w) ) {}
bool is_degenerate() const;

View File

@ -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<Point_3, 2> Rep;
typedef CGAL::array<Point_3, 2> Rep;
typedef typename R_::template Handle<Rep>::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<R>::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<R>::Point_3& left,
const typename Iso_cuboidH3<R>::Point_3& top,
const typename Iso_cuboidH3<R>::Point_3& far_,
const typename Iso_cuboidH3<R>::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<R>::
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<R>::
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)))
{}

View File

@ -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<Point_2, 2> Rep;
typedef CGAL::array<Point_2, 2> Rep;
typedef typename R_::template Handle<Rep>::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());

View File

@ -40,7 +40,7 @@ class LineH2
typedef typename R_::Ray_2 Ray_2;
typedef typename R_::Line_2 Line_2;
typedef boost::array<RT, 3> Rep;
typedef CGAL::array<RT, 3> Rep;
typedef typename R_::template Handle<Rep>::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<R>& l) const;
bool operator!=(const LineH2<R>& l) const;

View File

@ -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<RT, 4> Rep;
typedef CGAL::array<RT, 4> Rep;
typedef typename R_::template Handle<Rep>::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<RT, 4> ( a(), b(), c(), d() )
// CGAL::array<RT, 4> ( a(), b(), c(), d() )
template < class R >
inline
@ -142,7 +142,7 @@ PlaneH3<R>::new_rep(const typename PlaneH3<R>::Point_3 &p,
RT rhz = r.hz();
RT rhw = r.hw();
base = CGALi::make_array<RT>(
base = CGAL::make_array<RT>(
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<R>::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

View File

@ -44,7 +44,7 @@ class VectorH2
typedef typename R_::Direction_2 Direction_2;
typedef typename R_::Vector_2 Vector_2;
typedef boost::array<RT, 3> Rep;
typedef CGAL::array<RT, 3> Rep;
typedef typename R_::template Handle<Rep>::type Base;
typedef Rational_traits<FT> Rat_traits;
@ -65,10 +65,10 @@ public:
VectorH2(const Tx & x, const Ty & y,
typename boost::enable_if< boost::mpl::and_<boost::is_convertible<Tx, RT>,
boost::is_convertible<Ty, RT> > >::type* = 0)
: base(CGALi::make_array<RT>(x, y, RT(1))) {}
: base(CGAL::make_array<RT>(x, y, RT(1))) {}
VectorH2(const FT& x, const FT& y)
: base(CGALi::make_array<RT>(
: base(CGAL::make_array<RT>(
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<RT>(-x, -y, -w) ) {}
: base( w >= RT(0) ? CGAL::make_array( x, y, w)
: CGAL::make_array<RT>(-x, -y, -w) ) {}
const Self&
rep() const

View File

@ -42,7 +42,7 @@ class VectorH3
typedef typename R_::Line_3 Line_3;
typedef typename R_::Direction_3 Direction_3;
typedef boost::array<RT, 4> Rep;
typedef CGAL::array<RT, 4> Rep;
typedef typename R_::template Handle<Rep>::type Base;
typedef Rational_traits<FT> 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<Tx, RT>,
boost::is_convertible<Ty, RT> >,
boost::is_convertible<Tz, RT> > >::type* = 0)
: base(CGALi::make_array<RT>(x, y, z, RT(1))) {}
: base(CGAL::make_array<RT>(x, y, z, RT(1))) {}
VectorH3(const FT& x, const FT& y, const FT& z)
: base(CGALi::make_array<RT>(
: base(CGAL::make_array<RT>(
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<RT>(-x, -y, -z, -w) ) {}
: base( w >= RT(0) ? CGAL::make_array(x, y, z, w)
: CGAL::make_array<RT>(-x, -y, -z, -w) ) {}
const RT & hx() const { return get(base)[0]; }
const RT & hy() const { return get(base)[1]; }

View File

@ -36,7 +36,7 @@ struct Simple_cartesian;
class Bbox_2
{
typedef boost::array<double, 4> BBox_rep_2;
typedef CGAL::array<double, 4> 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;

View File

@ -35,7 +35,7 @@ struct Simple_cartesian;
class Bbox_3
{
boost::array<double, 6> rep;
CGAL::array<double, 6> 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;

View File

@ -0,0 +1,51 @@
%% =============================================================================
%% The CGAL Reference Manual
%% Chapter: STL Extensions - The Reference Part
%% -----------------------------------------------------------------------------
%% author: Sylvain Pion
%% -----------------------------------------------------------------------------
%% $Id$
%% $URL$
%% =============================================================================
%% +=========================================================================+
\begin{ccRefClass}{array<T, int>}
\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 <class T> array<T, 1> make_array(const T& a);}
{returns an array of dimension 1 whose first element is \ccc{a}.}
\ccFunction{template <class T> array<T, 2> 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

View File

@ -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

View File

@ -20,15 +20,27 @@
#ifndef CGAL_ARRAY_H
#define CGAL_ARRAY_H
#include <CGAL/basic.h>
#include <boost/array.hpp>
#include <CGAL/config.h>
#ifndef CGAL_CFG_NO_CPP0X_ARRAY
# include <array>
#elif !defined CGAL_CFG_NO_TR1_ARRAY
# include <tr1/array>
#else
# include <boost/array.hpp>
#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<T, 1>
array<T, 1>
make_array(const T& b1)
{
boost::array<T, 1> a = { { b1 } };
array<T, 1> a = { { b1 } };
return a;
}
template < typename T > inline
boost::array<T, 2>
array<T, 2>
make_array(const T& b1, const T& b2)
{
boost::array<T, 2> a = { { b1, b2 } };
array<T, 2> a = { { b1, b2 } };
return a;
}
template < typename T > inline
boost::array<T, 3>
array<T, 3>
make_array(const T& b1, const T& b2, const T& b3)
{
boost::array<T, 3> a = { { b1, b2, b3 } };
array<T, 3> a = { { b1, b2, b3 } };
return a;
}
template < typename T > inline
boost::array<T, 4>
array<T, 4>
make_array(const T& b1, const T& b2, const T& b3, const T& b4)
{
boost::array<T, 4> a = { { b1, b2, b3, b4 } };
array<T, 4> a = { { b1, b2, b3, b4 } };
return a;
}
template < typename T > inline
boost::array<T, 5>
array<T, 5>
make_array(const T& b1, const T& b2, const T& b3, const T& b4, const T& b5)
{
boost::array<T, 5> a = { { b1, b2, b3, b4, b5 } };
array<T, 5> a = { { b1, b2, b3, b4, b5 } };
return a;
}
template < typename T > inline
boost::array<T, 6>
array<T, 6>
make_array(const T& b1, const T& b2, const T& b3, const T& b4, const T& b5,
const T& b6)
{
boost::array<T, 6> a = { { b1, b2, b3, b4, b5, b6 } };
array<T, 6> 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

View File

@ -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);
}
}
}