Move yet another bunch of code to user classes...

This commit is contained in:
Sylvain Pion 2006-08-01 16:15:07 +00:00
parent 8972e33be9
commit 38956c9b10
9 changed files with 581 additions and 29 deletions

View File

@ -71,7 +71,6 @@ public:
Vector_3 to_vector() const;
Vector_3 vector() const { return to_vector(); }
const FT & delta(int i) const;
const FT & dx() const
{
return get(base).e0;
@ -129,15 +128,6 @@ DirectionC3<R>::to_vector() const
return Vector_3(dx(), dy(), dz());
}
template < class R >
const typename DirectionC3<R>::FT &
DirectionC3<R>::delta(int i) const
{
CGAL_kernel_precondition( i >= 0 && i <= 2 );
if (i==0) return dx();
if (i==1) return dy();
return dz();
}
#ifndef CGAL_NO_OSTREAM_INSERT_DIRECTIONC3
template < class R >

View File

@ -1015,6 +1015,30 @@ namespace CartesianKernelFunctors {
}
};
template <typename K>
class Compute_x_3 : Has_qrt
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Point_3& p) const
{
return p.rep().x();
}
const result_type &
operator()(const Vector_3& v) const
{
return v.rep().x();
}
};
template <typename K>
class Compute_y_2 : Has_qrt
@ -1041,6 +1065,55 @@ namespace CartesianKernelFunctors {
};
template <typename K>
class Compute_y_3 : Has_qrt
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Point_3& p) const
{
return p.rep().y();
}
const result_type &
operator()(const Vector_3& v) const
{
return v.rep().y();
}
};
template <typename K>
class Compute_z_3 : Has_qrt
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Point_3& p) const
{
return p.rep().z();
}
const result_type &
operator()(const Vector_3& v) const
{
return v.rep().z();
}
};
template <typename K>
class Compute_dx_2 : public Has_qrt
@ -1059,6 +1132,23 @@ namespace CartesianKernelFunctors {
}
};
template <typename K>
class Compute_dx_3 : public Has_qrt
{
typedef typename K::FT FT;
typedef typename K::Direction_3 Direction_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Direction_3& d) const
{
return d.rep().dx();
}
};
template <typename K>
class Compute_dy_2 : public Has_qrt
{
@ -1076,6 +1166,40 @@ namespace CartesianKernelFunctors {
}
};
template <typename K>
class Compute_dy_3 : public Has_qrt
{
typedef typename K::FT FT;
typedef typename K::Direction_3 Direction_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Direction_3& d) const
{
return d.rep().dy();
}
};
template <typename K>
class Compute_dz_3 : public Has_qrt
{
typedef typename K::FT FT;
typedef typename K::Direction_3 Direction_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Direction_3& d) const
{
return d.rep().dz();
}
};
template <typename K>
class Compute_hx_2 : public Has_qrt
{
@ -1100,6 +1224,30 @@ namespace CartesianKernelFunctors {
}
};
template <typename K>
class Compute_hx_3 : public Has_qrt
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Point_3& p) const
{
return p.rep().hx();
}
const result_type &
operator()(const Vector_3& v) const
{
return v.rep().hx();
}
};
template <typename K>
class Compute_hy_2 : public Has_qrt
{
@ -1124,6 +1272,54 @@ namespace CartesianKernelFunctors {
}
};
template <typename K>
class Compute_hy_3 : public Has_qrt
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Point_3& p) const
{
return p.rep().hy();
}
const result_type &
operator()(const Vector_3& v) const
{
return v.rep().hy();
}
};
template <typename K>
class Compute_hz_3 : public Has_qrt
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Point_3& p) const
{
return p.rep().hz();
}
const result_type &
operator()(const Vector_3& v) const
{
return v.rep().hz();
}
};
template <typename K>
class Compute_hw_2 : public Has_qrt
{
@ -1148,6 +1344,30 @@ namespace CartesianKernelFunctors {
}
};
template <typename K>
class Compute_hw_3
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
result_type
operator()(const Point_3& p) const
{
return p.rep().hw();
}
result_type
operator()(const Vector_3& v) const
{
return v.rep().hw();
}
};
template <typename K>
class Compute_xmin_2 : public Has_qrt

View File

@ -91,24 +91,8 @@ public:
const RT & hx() const { return get(base).e0; }
const RT & hy() const { return get(base).e1; }
const RT & hz() const { return get(base).e2; }
const RT & delta(int i) const;
};
template <class R >
CGAL_KERNEL_INLINE
const typename DirectionH3<R>::RT &
DirectionH3<R>::delta(int i) const
{
switch (i)
{
case 0: return x();
case 1: return y();
case 2: return z();
default: return delta( i%3 );
}
}
template <class R >
CGAL_KERNEL_INLINE
bool

View File

@ -1409,6 +1409,30 @@ namespace HomogeneousKernelFunctors {
}
};
template <typename K>
class Compute_x_3
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
FT
operator()(const Point_3& p) const
{
return p.rep().x();
}
FT
operator()(const Vector_3& v) const
{
return v.rep().x();
}
};
template <typename K>
class Compute_y_2
{
@ -1433,6 +1457,54 @@ namespace HomogeneousKernelFunctors {
}
};
template <typename K>
class Compute_y_3
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
FT
operator()(const Point_3& p) const
{
return p.rep().y();
}
FT
operator()(const Vector_3& v) const
{
return v.rep().y();
}
};
template <typename K>
class Compute_z_3
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 1 > Arity;
FT
operator()(const Point_3& p) const
{
return p.rep().z();
}
FT
operator()(const Vector_3& v) const
{
return v.rep().z();
}
};
template <typename K>
class Compute_dx_2 : public Has_qrt
{
@ -1450,6 +1522,23 @@ namespace HomogeneousKernelFunctors {
}
};
template <typename K>
class Compute_dx_3 : public Has_qrt
{
typedef typename K::RT RT;
typedef typename K::Direction_3 Direction_3;
public:
typedef RT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Direction_3& d) const
{
return d.rep().dx();
}
};
template <typename K>
class Compute_dy_2 : public Has_qrt
{
@ -1467,6 +1556,40 @@ namespace HomogeneousKernelFunctors {
}
};
template <typename K>
class Compute_dy_3 : public Has_qrt
{
typedef typename K::RT RT;
typedef typename K::Direction_3 Direction_3;
public:
typedef RT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Direction_3& d) const
{
return d.rep().dy();
}
};
template <typename K>
class Compute_dz_3 : public Has_qrt
{
typedef typename K::RT RT;
typedef typename K::Direction_3 Direction_3;
public:
typedef RT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Direction_3& d) const
{
return d.rep().dz();
}
};
template <typename K>
class Compute_hx_2 : public Has_qrt
{
@ -1492,6 +1615,31 @@ namespace HomogeneousKernelFunctors {
}
};
template <typename K>
class Compute_hx_3 : public Has_qrt
{
typedef typename K::FT FT;
typedef typename K::RT RT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef RT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Point_3& p) const
{
return p.rep().hx();
}
const result_type &
operator()(const Vector_3& v) const
{
return v.rep().hx();
}
};
template <typename K>
class Compute_hy_2 : public Has_qrt
{
@ -1517,6 +1665,56 @@ namespace HomogeneousKernelFunctors {
}
};
template <typename K>
class Compute_hy_3 : public Has_qrt
{
typedef typename K::FT FT;
typedef typename K::RT RT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef RT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Point_3& p) const
{
return p.rep().hy();
}
const result_type &
operator()(const Vector_3& v) const
{
return v.rep().hy();
}
};
template <typename K>
class Compute_hz_3 : public Has_qrt
{
typedef typename K::FT FT;
typedef typename K::RT RT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef RT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Point_3& p) const
{
return p.rep().hz();
}
const result_type &
operator()(const Vector_3& v) const
{
return v.rep().hz();
}
};
template <typename K>
class Compute_hw_2 : public Has_qrt
{
@ -1542,6 +1740,31 @@ namespace HomogeneousKernelFunctors {
}
};
template <typename K>
class Compute_hw_3 : public Has_qrt
{
typedef typename K::FT FT;
typedef typename K::RT RT;
typedef typename K::Point_3 Point_3;
typedef typename K::Vector_3 Vector_3;
public:
typedef RT result_type;
typedef Arity_tag< 1 > Arity;
const result_type &
operator()(const Point_3& p) const
{
return p.rep().hw();
}
const result_type &
operator()(const Vector_3& v) const
{
return v.rep().hw();
}
};
template <typename K>
class Construct_base_vector_3
{

View File

@ -91,6 +91,34 @@ public:
Vector_3 vector() const { return to_vector(); }
typename Qualified_result_of<typename R::Compute_dx_3, Direction_3>::type
dx() const
{
return R().compute_dx_3_object()(*this);
}
typename Qualified_result_of<typename R::Compute_dy_3, Direction_3>::type
dy() const
{
return R().compute_dy_3_object()(*this);
}
typename Qualified_result_of<typename R::Compute_dz_3, Direction_3>::type
dz() const
{
return R().compute_dz_3_object()(*this);
}
typename Qualified_result_of<typename R::Compute_dx_3, Direction_3>::type
delta(int i) const
{
CGAL_kernel_precondition( i >= 0 && i <= 2 );
if (i==0) return dx();
if (i==1) return dy();
return dz();
}
};
#ifndef CGAL_NO_OSTREAM_INSERT_DIRECTION_3

View File

@ -1578,13 +1578,13 @@ namespace CommonKernelFunctors {
Cartesian_const_iterator_3
operator()( const Point_3& p) const
{
return p.cartesian_begin();
return p.rep().cartesian_begin();
}
Cartesian_const_iterator_3
operator()( const Point_3& p, int) const
{
return p.cartesian_end();
return p.rep().cartesian_end();
}
};

View File

@ -137,18 +137,38 @@ CGAL_Kernel_cons(Compute_volume_3,
compute_volume_3_object)
CGAL_Kernel_cons(Compute_x_2,
compute_x_2_object)
CGAL_Kernel_cons(Compute_x_3,
compute_x_3_object)
CGAL_Kernel_cons(Compute_y_2,
compute_y_2_object)
CGAL_Kernel_cons(Compute_y_3,
compute_y_3_object)
CGAL_Kernel_cons(Compute_z_3,
compute_z_3_object)
CGAL_Kernel_cons(Compute_dx_2,
compute_dx_2_object)
CGAL_Kernel_cons(Compute_dx_3,
compute_dx_3_object)
CGAL_Kernel_cons(Compute_dy_2,
compute_dy_2_object)
CGAL_Kernel_cons(Compute_dy_3,
compute_dy_3_object)
CGAL_Kernel_cons(Compute_dz_3,
compute_dz_3_object)
CGAL_Kernel_cons(Compute_hx_2,
compute_hx_2_object)
CGAL_Kernel_cons(Compute_hx_3,
compute_hx_3_object)
CGAL_Kernel_cons(Compute_hy_2,
compute_hy_2_object)
CGAL_Kernel_cons(Compute_hy_3,
compute_hy_3_object)
CGAL_Kernel_cons(Compute_hz_3,
compute_hz_3_object)
CGAL_Kernel_cons(Compute_hw_2,
compute_hw_2_object)
CGAL_Kernel_cons(Compute_hw_3,
compute_hw_3_object)
CGAL_Kernel_cons(Compute_x_at_y_2,
compute_x_at_y_2_object)
CGAL_Kernel_cons(Compute_y_at_x_2,

View File

@ -42,7 +42,6 @@ public:
typedef RPoint_2 Rep;
typedef typename R_::Cartesian_const_iterator_2 Cartesian_const_iterator;
const Rep& rep() const
{
return *this;

View File

@ -37,6 +37,18 @@ class Point_3 : public R_::Kernel_base::Point_3
typedef typename R_::Kernel_base::Point_3 RPoint_3;
public:
typedef RPoint_3 Rep;
typedef typename R_::Cartesian_const_iterator_3 Cartesian_const_iterator;
const Rep& rep() const
{
return *this;
}
Rep& rep()
{
return *this;
}
typedef R_ R;
@ -56,6 +68,82 @@ public:
Point_3(const RT& hx, const RT& hy, const RT& hz, const RT& hw)
: RPoint_3(hx, hy, hz, hw) {}
typename Qualified_result_of<typename R::Compute_x_3, Point_3>::type
x() const
{
return typename R::Compute_x_3()(*this);
}
typename Qualified_result_of<typename R::Compute_y_3, Point_3>::type
y() const
{
return typename R::Compute_y_3()(*this);
}
typename Qualified_result_of<typename R::Compute_z_3, Point_3>::type
z() const
{
return typename R::Compute_z_3()(*this);
}
typename Qualified_result_of<typename R::Compute_hx_3, Point_3>::type
hx() const
{
return R().compute_hx_3_object()(*this);
}
typename Qualified_result_of<typename R::Compute_hy_3, Point_3>::type
hy() const
{
return R().compute_hy_3_object()(*this);
}
typename Qualified_result_of<typename R::Compute_hz_3, Point_3>::type
hz() const
{
return R().compute_hz_3_object()(*this);
}
typename Qualified_result_of<typename R::Compute_hw_3, Point_3>::type
hw() const
{
return R().compute_hw_3_object()(*this);
}
typename Qualified_result_of<typename R::Compute_x_3, Point_3>::type
cartesian(int i) const
{
CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) );
if (i==0) return x();
if (i==1) return y();
return z();
}
RT
homogeneous(int i) const
{
CGAL_kernel_precondition( (i >= 0) || (i <= 3) );
if (i==0) return hx();
if (i==1) return hy();
if (i==2) return hz();
return hw();
}
Cartesian_const_iterator cartesian_begin() const
{
return typename R::Construct_cartesian_const_iterator_3()(*this);
}
Cartesian_const_iterator cartesian_end() const
{
return typename R::Construct_cartesian_const_iterator_3()(*this,3);
}
int dimension() const
{
return 3;
}
Point_3 transform(const Aff_transformation_3 &t) const
{
return t.transform(*this);