Remove the reference-counting inside Point_2 and Point_3, as they now store

only a Vector_2 and Vector_3 which is responsible for the reference-counting.
This commit is contained in:
Sylvain Pion 2008-04-10 14:41:35 +00:00
parent 451039a260
commit 7ace759d8e
5 changed files with 68 additions and 83 deletions

View File

@ -25,8 +25,6 @@
#define CGAL_CARTESIAN_POINT_2_H
#include <CGAL/Origin.h>
#include <CGAL/Handle_for.h>
#include <CGAL/constant.h>
CGAL_BEGIN_NAMESPACE
@ -38,16 +36,12 @@ class PointC2
typedef typename R_::Vector_2 Vector_2;
typedef typename R_::Point_2 Point_2;
// TODO : we now have 2 layers of reference counting.
// => maybe simply suppress the one at this level?
typedef Vector_2 Rep;
typedef typename R_::template Handle<Rep>::type Base;
Base base;
// We do not use reference counting here as it is done at the Vector_2 level.
Vector_2 base;
public:
typedef typename Rep::Cartesian_const_iterator Cartesian_const_iterator;
typedef typename Vector_2::Cartesian_const_iterator Cartesian_const_iterator;
typedef R_ R;
@ -64,40 +58,40 @@ public:
const FT& x() const
{
return get(base).x();
return base.x();
}
const FT& y() const
{
return get(base).y();
return base.y();
}
const FT& hx() const
{
return x();
return base.hx();
}
const FT& hy() const
{
return y();
return base.hy();
}
const FT& hw() const
{
return constant<FT, 1>();
return base.hw();
}
Cartesian_const_iterator cartesian_begin() const
{
return get(base).cartesian_begin();
return base.cartesian_begin();
}
Cartesian_const_iterator cartesian_end() const
{
return get(base).cartesian_end();
return base.cartesian_end();
}
bool operator==(const PointC2 &p) const
{
return get(base) == get(p.base);
return base == p.base;
}
bool operator!=(const PointC2 &p) const
{

View File

@ -24,9 +24,7 @@
#ifndef CGAL_CARTESIAN_POINT_3_H
#define CGAL_CARTESIAN_POINT_3_H
#include <CGAL/Handle_for.h>
#include <CGAL/Origin.h>
#include <CGAL/constant.h>
CGAL_BEGIN_NAMESPACE
@ -38,14 +36,11 @@ class PointC3
typedef typename R_::Point_3 Point_3;
typedef typename R_::Aff_transformation_3 Aff_transformation_3;
// TODO : we have 2 levels of ref-counting here.
typedef Vector_3 Rep;
typedef typename R_::template Handle<Rep>::type Base;
Base base;
// We do not use reference counting here as it is done at the Vector_3 level.
Vector_3 base;
public:
typedef typename Rep::Cartesian_const_iterator Cartesian_const_iterator;
typedef typename Vector_3::Cartesian_const_iterator Cartesian_const_iterator;
typedef R_ R;
PointC3() {}
@ -61,32 +56,32 @@ public:
const FT & x() const
{
return get(base).x();
return base.x();
}
const FT & y() const
{
return get(base).y();
return base.y();
}
const FT & z() const
{
return get(base).z();
return base.z();
}
const FT & hx() const
{
return x();
return base.hx();
}
const FT & hy() const
{
return y();
return base.hy();
}
const FT & hz() const
{
return z();
return base.hz();
}
const FT & hw() const
{
return constant<FT, 1>();
return base.hw();
}
const FT & cartesian(int i) const;
@ -95,17 +90,17 @@ public:
Cartesian_const_iterator cartesian_begin() const
{
return get(base).cartesian_begin();
return base.cartesian_begin();
}
Cartesian_const_iterator cartesian_end() const
{
return get(base).cartesian_end();
return base.cartesian_end();
}
int dimension() const
{
return get(base).dimension();
return base.dimension();
}
Point_3 transform(const Aff_transformation_3 &t) const
@ -119,7 +114,7 @@ inline
const typename PointC3<R>::FT &
PointC3<R>::cartesian(int i) const
{
return get(base).cartesian(i);
return base.cartesian(i);
}
template < class R >
@ -127,7 +122,7 @@ inline
const typename PointC3<R>::FT &
PointC3<R>::operator[](int i) const
{
return get(base)[i];
return base[i];
}
template < class R >
@ -135,7 +130,7 @@ inline
const typename PointC3<R>::FT &
PointC3<R>::homogeneous(int i) const
{
return get(base).homogeneous(i);
return base.homogeneous(i);
}
CGAL_END_NAMESPACE

View File

@ -26,6 +26,7 @@
#include <CGAL/Origin.h>
#include <CGAL/array.h>
#include <CGAL/constant.h>
CGAL_BEGIN_NAMESPACE

View File

@ -42,19 +42,16 @@ class PointH2
typedef typename R_::Point_2 Point_2;
typedef typename R_::Direction_2 Direction_2;
// TODO : we have 2 levels of ref-counting here.
typedef Vector_2 Rep;
typedef typename R_::template Handle<Rep>::type Base;
typedef Rational_traits<FT> Rat_traits;
Base base;
// Reference-counting is handled in Vector_2.
Vector_2 base;
public:
typedef FT Cartesian_coordinate_type;
typedef const RT& Homogeneous_coordinate_type;
typedef typename Rep::Cartesian_const_iterator Cartesian_const_iterator;
typedef typename Vector_2::Cartesian_const_iterator Cartesian_const_iterator;
typedef R_ R;
PointH2() {}
@ -77,9 +74,9 @@ public:
bool operator==( const PointH2<R>& p) const;
bool operator!=( const PointH2<R>& p) const;
const RT & hx() const { return get(base).hx(); }
const RT & hy() const { return get(base).hy(); }
const RT & hw() const { return get(base).hw(); }
const RT & hx() const { return base.hx(); }
const RT & hy() const { return base.hy(); }
const RT & hw() const { return base.hw(); }
FT x() const { return FT(hx()) / FT(hw()); }
FT y() const { return FT(hy()) / FT(hw()); }
@ -90,12 +87,12 @@ public:
Cartesian_const_iterator cartesian_begin() const
{
return get(base).cartesian_begin();
return base.cartesian_begin();
}
Cartesian_const_iterator cartesian_end() const
{
return get(base).cartesian_end();
return base.cartesian_end();
}
int dimension() const;
@ -104,11 +101,11 @@ public:
};
template < class R >
CGAL_KERNEL_INLINE
inline
bool
PointH2<R>::operator==( const PointH2<R>& p) const
{
return get(base) == get(p.base);
return base == p.base;
}
template < class R >
@ -118,36 +115,36 @@ PointH2<R>::operator!=( const PointH2<R>& p) const
{ return !(*this == p); }
template < class R >
CGAL_KERNEL_INLINE
inline
typename PointH2<R>::FT
PointH2<R>::cartesian(int i) const
{
return get(base).cartesian(i);
return base.cartesian(i);
}
template < class R >
CGAL_KERNEL_INLINE
inline
const typename PointH2<R>::RT &
PointH2<R>::homogeneous(int i) const
{
return get(base).homogeneous(i);
return base.homogeneous(i);
}
template < class R >
inline
typename PointH2<R>::FT
PointH2<R>::operator[](int i) const
{ return get(base)[i]; }
{ return base[i]; }
template < class R >
inline
int
PointH2<R>::dimension() const
{ return get(base).dimension(); }
{ return base.dimension(); }
template < class R >
CGAL_KERNEL_INLINE
inline
typename PointH2<R>::Direction_2
PointH2<R>::direction() const
{ return typename PointH2<R>::Direction_2(*this); }

View File

@ -42,16 +42,14 @@ class PointH3
typedef typename R_::Direction_3 Direction_3;
typedef typename R_::Aff_transformation_3 Aff_transformation_3;
typedef Vector_3 Rep;
typedef typename R_::template Handle<Rep>::type Base;
typedef Rational_traits<FT> Rat_traits;
Base base;
// Reference-counting is handled in Vector_3.
Vector_3 base;
public:
typedef typename Rep::Cartesian_const_iterator Cartesian_const_iterator;
typedef typename Vector_3::Cartesian_const_iterator Cartesian_const_iterator;
typedef R_ R;
PointH3() {}
@ -86,12 +84,12 @@ public:
Cartesian_const_iterator cartesian_begin() const
{
return get(base).cartesian_begin();
return base.cartesian_begin();
}
Cartesian_const_iterator cartesian_end() const
{
return get(base).cartesian_end();
return base.cartesian_end();
}
int dimension() const;
@ -108,64 +106,64 @@ template < class R >
inline
const typename PointH3<R>::RT &
PointH3<R>::hx() const
{ return get(base).hx(); }
{ return base.hx(); }
template < class R >
inline
const typename PointH3<R>::RT &
PointH3<R>::hy() const
{ return get(base).hy(); }
{ return base.hy(); }
template < class R >
inline
const typename PointH3<R>::RT &
PointH3<R>::hz() const
{ return get(base).hz(); }
{ return base.hz(); }
template < class R >
inline
const typename PointH3<R>::RT &
PointH3<R>::hw() const
{ return get(base).hw(); }
{ return base.hw(); }
template < class R >
CGAL_KERNEL_INLINE
inline
typename PointH3<R>::FT
PointH3<R>::x() const
{ return FT(hx()) / FT(hw()); }
{ return base.x(); }
template < class R >
CGAL_KERNEL_INLINE
inline
typename PointH3<R>::FT
PointH3<R>::y() const
{ return FT(hy()) / FT(hw()); }
{ return base.y(); }
template < class R >
CGAL_KERNEL_INLINE
inline
typename PointH3<R>::FT
PointH3<R>::z() const
{ return FT(hz()) / FT(hw()); }
{ return base.z(); }
template < class R >
inline
int
PointH3<R>::dimension() const
{ return get(base).dimension(); }
{ return base.dimension(); }
template < class R >
CGAL_KERNEL_INLINE
inline
typename PointH3<R>::FT
PointH3<R>::cartesian(int i) const
{
return get(base).cartesian(i);
return base.cartesian(i);
}
template < class R >
CGAL_KERNEL_INLINE
inline
const typename PointH3<R>::RT &
PointH3<R>::homogeneous(int i) const
{
return get(base).homogeneous(i);
return base.homogeneous(i);
}
template < class R >
@ -173,7 +171,7 @@ inline
typename PointH3<R>::FT
PointH3<R>::operator[](int i) const
{
return get(base)[i];
return base[i];
}
template < class R >
@ -183,11 +181,11 @@ PointH3<R>::direction() const
{ return Direction_3(*this); }
template < class R >
CGAL_KERNEL_INLINE
inline
bool
PointH3<R>::operator==( const PointH3<R> & p) const
{
return get(base) == get(p.base);
return base == p.base;
}
template < class R >