Dimension detecting stuff rewrite.

There is now Ambiant_dimension and Feature_dimension.
The handling of the dynamic dimension case is now done by having
the di,ension tag as the first thing provided, with the integral
constant value available only when it makes sense (INT_MAX no longer needed).
This commit is contained in:
Sylvain Pion 2008-04-13 12:38:48 +00:00
parent 3df06fa8da
commit 2389cdcc1e
54 changed files with 433 additions and 181 deletions

View File

@ -102,8 +102,13 @@ struct Cartesian_base
Angle;
template <typename T>
struct Dimension {
static const int value = T::static_dimension;
struct Ambiant_dimension {
typedef typename T::Ambiant_dimension type;
};
template <typename T>
struct Feature_dimension {
typedef typename T::Feature_dimension type;
};
typedef PointC2<Kernel> Point_2;

View File

@ -26,6 +26,7 @@
#define CGAL_CONIC_2_H
#include <CGAL/Conic_misc.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -39,7 +40,8 @@ class Conic_2 : public R_::Kernel_base::Conic_2 {
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<1> Feature_dimension;
// types
typedef R_ R;

View File

@ -68,8 +68,13 @@ struct Filtered_kernel_base
};
template < typename T >
struct Dimension {
static const int value = T::static_dimension; // maybe not the right way...
struct Ambiant_dimension {
typedef typename T::Ambiant_dimension type; // maybe not the right way...
};
template < typename T >
struct Feature_dimension {
typedef typename T::Feature_dimension type; // maybe not the right way...
};
// We change the predicates.

View File

@ -60,8 +60,13 @@ public:
struct Base { typedef Lazy_kernel_generic_base<Exact_kernel, Approximate_kernel, E2A, Kernel2> Type; };
template < typename T >
struct Dimension {
static const int value = T::static_dimension;
struct Ambiant_dimension {
typedef typename T::Ambiant_dimension type;
};
template < typename T >
struct Feature_dimension {
typedef typename T::Feature_dimension type;
};
// What to do with the tag ?

View File

@ -109,8 +109,13 @@ struct Homogeneous_base
Angle;
template <typename T>
struct Dimension {
static const int value = T::static_dimension;
struct Ambiant_dimension {
typedef typename T::Ambiant_dimension type;
};
template <typename T>
struct Feature_dimension {
typedef typename T::Feature_dimension type;
};
typedef PointH2<Kernel> Point_2;

View File

@ -0,0 +1,39 @@
\begin{ccRefClass} {Ambiant_dimension<T, K = Kernel_traits<T>::Kernel>}
\ccDefinition
The class \ccRefName\ allows to retrieve the dimension of the ambiant space of
a type.
\ccInclude{CGAL/Dimension.h}
\ccConstants
\ccVariable{static const int value;}{The dimension value as a compile-time
integral constant. It is implemented as \ccc{K::Dimension<T>::type::value}.
It exists only when the dimension is a compile-time constant.}
\ccTypes
\ccTypedef{type;}{Either \ccc{Dimension_tag<dim>} if the dimension is a
compile-time constant of value \ccc{dim}, or \ccc{Dynamic_dimension_tag}
otherwise. It is implemented as \ccc{K::Ambiant_dimension<T>::type}. }
\ccCreation
\ccCreationVariable{d}
\ccExample
The following retrieves the dimension of a point type.
\begin{cprog}
typedef K::Point_2 Point;
int dimension = Ambiant_dimension<Point, K>::value;
assert(dimension == 2);
\end{cprog}
\ccSeeAlso
\ccRefConceptPage{Dimension_tag}
\ccRefConceptPage{Dynamic_dimension_tag}
\ccRefConceptPage{Feature_dimension}
\end{ccRefClass}

View File

@ -1,31 +0,0 @@
\begin{ccRefClass} {Dimension<T, K = Kernel_traits<T>::Kernel>}
\ccDefinition
The class \ccRefName\ allows to retrieve the dimension of the ambiant space of
a type. The dimension can also be the special constant
\ccc{Dynamic_dimension}, which value is \ccc{INT_MAX}, to indicate the case
where the dimension is only known at run time.
\ccInclude{CGAL/Dimension.h}
\ccConstants
\ccVariable{static const int value;}{ The dimension. It is implemented as \ccc{K::Dimension<T>::value}. }
\ccCreation
\ccCreationVariable{d}
\ccExample
The following retrieves the dimension of a point type.
\begin{cprog}
typedef Point_2<K> Point;
int dimension = Dimension<Point, K>::value;
assert(dimension == 2);
\end{cprog}
\ccSeeAlso
\ccRefConceptPage{Dimension_tag}
\end{ccRefClass}

View File

@ -6,7 +6,7 @@ for dispatching functions based on the dimension of an object, as provided
by the \ccc{dim} parameter. It is useful in cases where it is not more
practical to pass the dimension as a template parameter directly.
\ccInclude{CGAL/Dimension_tag.h}
\ccInclude{CGAL/Dimension.h}
\ccConstants
@ -17,7 +17,8 @@ practical to pass the dimension as a template parameter directly.
\ccExample
The following declaration creates two points at the origin, either in 2D or in 3D.
The following code declares two functions constructing two points at the origin,
either in 2D or in 3D.
\begin{cprog}
Point_2<K> get_origin(Dimension_tag<2>) { return Point_2<K>(ORIGIN); }
@ -27,6 +28,8 @@ The following declaration creates two points at the origin, either in 2D or in 3
\end{cprog}
\ccSeeAlso
\ccRefConceptPage{Dimension}
\ccRefConceptPage{Ambiant_dimension}
\ccRefConceptPage{Feature_dimension}
\ccRefConceptPage{Dynamic_dimension_tag}
\end{ccRefClass}

View File

@ -0,0 +1,32 @@
\begin{ccRefClass} {Dynamic_dimension_tag}
\ccDefinition
An object of the class \ccRefName\ is an empty object which can be used
for dispatching functions based on the dimension of an object.
\ccRefName\ indicates that the dimension is not known at compile-time.
\ccc{Dimension_tag} is the tag class dealing with compile-time dimensions.
\ccInclude{CGAL/Dimension.h}
\ccCreation
\ccCreationVariable{d}
\ccExample
The following code declares two functions constructing two points at the origin,
either in 2D or in 3D.
\begin{cprog}
Point_2<K> get_origin(Dimension_tag<2>) { return Point_2<K>(ORIGIN); }
Point_3<K> get_origin(Dimension_tag<3>) { return Point_3<K>(ORIGIN); }
Point_d<K> get_origin(Dynamic_dmension_tag) { return Point_d<K>(ORIGIN); }
std::cout << get_origin(Dynamic_dimension_tag())) << std::endl;
\end{cprog}
\ccSeeAlso
\ccRefConceptPage{Dimension_tag}
\ccRefConceptPage{Ambiant_dimension}
\ccRefConceptPage{Feature_dimension}
\end{ccRefClass}

View File

@ -0,0 +1,38 @@
\begin{ccRefClass} {Feature_dimension<T, K = Kernel_traits<T>::Kernel>}
\ccDefinition
The class \ccRefName\ allows to retrieve the geometric dimension of a type.
\ccInclude{CGAL/Dimension.h}
\ccConstants
\ccVariable{static const int value;}{The dimension value as a compile-time
integral constant. It is implemented as \ccc{K::Feature_dimension<T>::type::value}.
It exists only when the dimension is a compile-time constant.}
\ccTypes
\ccTypedef{type;}{Either \ccc{Dimension_tag<dim>} if the dimension is a
compile-time constant of value \ccc{dim}, or \ccc{Dynamic_dimension_tag}
otherwise. It is implemented as \ccc{K::Feature_dimension<T>::type}. }
\ccCreation
\ccCreationVariable{d}
\ccExample
The following retrieves the dimension of a point type.
\begin{cprog}
typedef K::Point_2 Point;
int dimension = Feature_dimension<Point, K>::value;
assert(dimension == 0);
\end{cprog}
\ccSeeAlso
\ccRefConceptPage{Dimension_tag}
\ccRefConceptPage{Dynamic_dimension_tag}
\ccRefConceptPage{Ambiant_dimension}
\end{ccRefClass}

View File

@ -464,6 +464,8 @@ in the kernel.
\section{Dimension handling tools}
\gdef\ccRefPageBreak{\ccFalse}
\input{Kernel_23_ref/Dimension.tex}
\input{Kernel_23_ref/Ambiant_dimension.tex}
\input{Kernel_23_ref/Feature_dimension.tex}
\gdef\ccRefPageBreak{\ccTrue}
\input{Kernel_23_ref/Dimension_tag.tex}
\input{Kernel_23_ref/Dynamic_dimension_tag.tex}

View File

@ -18,14 +18,13 @@
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri
// Stefan Schirra
// Author(s) : Andreas Fabri, Stefan Schirra
#ifndef CGAL_AFF_TRANSFORMATION_2_H
#define CGAL_AFF_TRANSFORMATION_2_H
#include <CGAL/basic.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -39,9 +38,10 @@ class Aff_transformation_2 : public R_::Kernel_base::Aff_transformation_2
typedef typename R_::Vector_2 Vector_2;
typedef typename R_::Kernel_base::Aff_transformation_2 RAff_transformation_2;
public:
typedef R_ R;
static const int static_dimension = 2;
typedef CGAL::Dimension_tag<2> Ambiant_dimension;
typedef R_ R;
Aff_transformation_2() {}

View File

@ -18,12 +18,13 @@
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri, Stefan Schirra
#ifndef CGAL_AFF_TRANSFORMATION_3_H
#define CGAL_AFF_TRANSFORMATION_3_H
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
template <class R_>
@ -34,7 +35,7 @@ class Aff_transformation_3 : public R_::Kernel_base::Aff_transformation_3
typedef typename R_::Kernel_base::Aff_transformation_3 RAff_transformation_3;
public:
static const int static_dimension = 3;
typedef CGAL::Dimension_tag<3> Ambiant_dimension;
typedef R_ R;

View File

@ -18,7 +18,6 @@
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri
#ifndef CGAL_BBOX_2_H
@ -28,9 +27,13 @@
#include <CGAL/kernel_assertions.h>
#include <CGAL/IO/io.h>
#include <CGAL/Fourtuple.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
template < typename T >
struct Simple_cartesian;
class Bbox_2
{
typedef Fourtuple<double> BBox_rep_2;
@ -39,7 +42,10 @@ class Bbox_2
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<2> Feature_dimension;
typedef Simple_cartesian<double> R;
Bbox_2() {}

View File

@ -18,7 +18,6 @@
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri
#ifndef CGAL_BBOX_3_H
@ -27,16 +26,23 @@
#include <CGAL/basic.h>
#include <CGAL/IO/io.h>
#include <CGAL/Sixtuple.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
template < typename T >
struct Simple_cartesian;
class Bbox_3
{
Sixtuple<double> rep;
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<3> Feature_dimension;
typedef Simple_cartesian<double> R;
Bbox_3() {}

View File

@ -29,6 +29,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -45,7 +46,8 @@ class Circle_2 : public R_::Kernel_base::Circle_2
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<1> Feature_dimension;
typedef RCircle_2 Rep;

View File

@ -1,8 +1,5 @@
// Copyright (c) 2005 Utrecht University (The Netherlands),
// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
// and Tel-Aviv University (Israel). All rights reserved.
// Copyright (c) 2008 INRIA Sophia-Antipolis (France).
// Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
@ -18,7 +15,6 @@
// $URL$
// $Id$
//
//
// Author(s) : Sylvain Pion
#ifndef CGAL_DIMENSION_H
@ -30,16 +26,48 @@
CGAL_BEGIN_NAMESPACE
// This is a tool to obtain the static dimension of a kernel object.
// That is, the dimension of the ambiant space.
// These tag classes help dispatching functions based on a geometric dimension.
template < typename T, typename K = typename Kernel_traits<T>::Kernel >
struct Dimension
template < int dim >
struct Dimension_tag
{
static const int value = K::template Dimension<T>::value;
static const int value = dim;
};
static const int Dynamic_dimension = INT_MAX;
struct Dynamic_dimension_tag {};
namespace CGALi {
template < typename D >
struct Dim_value {
static const int value = D::value;
};
template <>
struct Dim_value <Dynamic_dimension_tag> {};
} // namespace CGALi
// Ambiant_dimension gives access to the dimension of the ambiant space of an object.
template < typename T, typename K = typename Kernel_traits<T>::Kernel >
struct Ambiant_dimension
: public CGALi::Dim_value< typename K::template Ambiant_dimension<T>::type >
{
typedef typename K::template Ambiant_dimension<T>::type type;
};
// Feature_dimension gives access to the dimension of an object.
template < typename T, typename K = typename Kernel_traits<T>::Kernel >
struct Feature_dimension
: public CGALi::Dim_value< typename K::template Feature_dimension<T>::type >
{
typedef typename K::template Feature_dimension<T>::type type;
};
CGAL_END_NAMESPACE

View File

@ -1,37 +0,0 @@
// Copyright (c) 2008 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; version 2.1 of the License.
// See the file LICENSE.LGPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
// Author(s) : Sylvain Pion
#ifndef CGAL_DIMENSION_TAG_H
#define CGAL_DIMENSION_TAG_H
#include <CGAL/basic.h>
CGAL_BEGIN_NAMESPACE
// This class helps dispatching functions based on the geometric dimension.
template < int dim >
struct Dimension_tag
{
static const int value = dim;
};
CGAL_END_NAMESPACE
#endif // CGAL_DIMENSION_TAG_H

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -47,7 +48,8 @@ class Direction_2 : public R_::Kernel_base::Direction_2
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<0> Feature_dimension;
typedef RDirection_2 Rep;

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -46,7 +47,8 @@ class Direction_3 : public R_::Kernel_base::Direction_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<0> Feature_dimension;
typedef typename R_::Kernel_base::Direction_3 Rep;

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -43,7 +44,8 @@ class Iso_cuboid_3 : public R_::Kernel_base::Iso_cuboid_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<3> Feature_dimension;
typedef typename R_::Kernel_base::Iso_cuboid_3 Rep;

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -44,7 +45,8 @@ class Iso_rectangle_2 : public R_::Kernel_base::Iso_rectangle_2
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<2> Feature_dimension;
typedef typename R_::Kernel_base::Iso_rectangle_2 Rep;

View File

@ -27,6 +27,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -48,7 +49,8 @@ class Line_2 : public R_::Kernel_base::Line_2
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<1> Feature_dimension;
typedef RLine_2 Rep;

View File

@ -28,6 +28,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -48,7 +49,8 @@ class Line_3 : public R_::Kernel_base::Line_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<1> Feature_dimension;
typedef typename R_::Kernel_base::Line_3 Rep;

View File

@ -27,6 +27,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -48,7 +49,8 @@ class Plane_3 : public R_::Kernel_base::Plane_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<2> Feature_dimension;
typedef typename R_::Kernel_base::Plane_3 Rep;

View File

@ -30,6 +30,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -47,7 +48,8 @@ class Point_2 : public R_::Kernel_base::Point_2
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<0> Feature_dimension;
typedef RPoint_2 Rep;
typedef typename R_::Cartesian_const_iterator_2 Cartesian_const_iterator;

View File

@ -31,6 +31,7 @@
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -47,7 +48,8 @@ class Point_3 : public R_::Kernel_base::Point_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<0> Feature_dimension;
typedef typename R_::Kernel_base::Point_3 Rep;
typedef typename R_::Cartesian_const_iterator_3 Cartesian_const_iterator;

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -49,7 +50,8 @@ class Ray_2 : public R_::Kernel_base::Ray_2
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<1> Feature_dimension;
typedef RRay_2 Rep;

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -46,7 +47,8 @@ class Ray_3 : public R_::Kernel_base::Ray_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<1> Feature_dimension;
typedef typename R_::Kernel_base::Ray_3 Rep;

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -48,7 +49,8 @@ class Segment_2 : public R_::Kernel_base::Segment_2
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<1> Feature_dimension;
typedef RSegment_2 Rep;

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -47,7 +48,8 @@ class Segment_3 : public R_::Kernel_base::Segment_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<1> Feature_dimension;
typedef typename R_::Kernel_base::Segment_3 Rep;

View File

@ -29,6 +29,7 @@
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -44,7 +45,8 @@ class Sphere_3 : public R_::Kernel_base::Sphere_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<2> Feature_dimension;
typedef typename R_::Kernel_base::Sphere_3 Rep;

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -42,7 +43,8 @@ class Tetrahedron_3 : public R_::Kernel_base::Tetrahedron_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<3> Feature_dimension;
typedef typename R_::Kernel_base::Tetrahedron_3 Rep;

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -43,7 +44,8 @@ class Triangle_2 : public R_::Kernel_base::Triangle_2
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<2> Feature_dimension;
typedef RTriangle_2 Rep;

View File

@ -28,6 +28,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -45,7 +46,8 @@ class Triangle_3 : public R_::Kernel_base::Triangle_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<2> Feature_dimension;
typedef typename R_::Kernel_base::Triangle_3 Rep;

View File

@ -30,6 +30,7 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -51,7 +52,8 @@ class Vector_2 : public R_::Kernel_base::Vector_2
public:
static const int static_dimension = 2;
typedef Dimension_tag<2> Ambiant_dimension;
typedef Dimension_tag<0> Feature_dimension;
typedef RVector_2 Rep;
typedef typename R_::Cartesian_const_iterator_2 Cartesian_const_iterator;

View File

@ -30,6 +30,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -50,7 +51,8 @@ class Vector_3 : public R_::Kernel_base::Vector_3
public:
static const int static_dimension = 3;
typedef Dimension_tag<3> Ambiant_dimension;
typedef Dimension_tag<0> Feature_dimension;
typedef typename R_::Cartesian_const_iterator_3 Cartesian_const_iterator;
typedef typename R_::Kernel_base::Vector_3 Rep;

View File

@ -1,5 +1,5 @@
// Test program for Dimension<>.
// Sylvain Pion, 2005.
// Test program for Ambiant_dimension<> and Feature_dimension<>.
// Sylvain Pion, 2005, 2008.
#include <cassert>
#include <CGAL/Cartesian.h>
@ -10,65 +10,107 @@
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Dimension.h>
#include <CGAL/Dimension_tag.h>
#include <CGAL/Dimension.h>
template < typename K >
void test(CGAL::Dimension_tag<2>)
{
assert( 2 == CGAL::Dimension<typename K::Point_2>::value );
assert( 2 == CGAL::Dimension<typename K::Vector_2>::value );
assert( 2 == CGAL::Dimension<typename K::Direction_2>::value );
assert( 2 == CGAL::Dimension<typename K::Line_2>::value );
assert( 2 == CGAL::Dimension<typename K::Ray_2>::value );
assert( 2 == CGAL::Dimension<typename K::Segment_2>::value );
assert( 2 == CGAL::Dimension<typename K::Triangle_2>::value );
assert( 2 == CGAL::Dimension<typename K::Iso_rectangle_2>::value );
assert( 2 == CGAL::Dimension<typename K::Circle_2>::value );
assert( 2 == CGAL::Dimension<typename K::Conic_2>::value );
assert( 2 == CGAL::Dimension<typename K::Aff_transformation_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Point_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Vector_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Direction_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Line_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Ray_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Segment_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Triangle_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Iso_rectangle_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Circle_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Conic_2>::value );
assert( 2 == CGAL::Ambiant_dimension<typename K::Aff_transformation_2>::value );
assert( 2 == CGAL::Ambiant_dimension<CGAL::Bbox_2>::value );
assert( 0 == CGAL::Feature_dimension<typename K::Point_2>::value );
assert( 0 == CGAL::Feature_dimension<typename K::Vector_2>::value );
assert( 0 == CGAL::Feature_dimension<typename K::Direction_2>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Line_2>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Ray_2>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Segment_2>::value );
assert( 2 == CGAL::Feature_dimension<typename K::Triangle_2>::value );
assert( 2 == CGAL::Feature_dimension<typename K::Iso_rectangle_2>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Circle_2>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Conic_2>::value );
// assert( ? == CGAL::Feature_dimension<typename K::Aff_transformation_2>::value );
assert( 2 == CGAL::Feature_dimension<CGAL::Bbox_2>::value );
}
template < typename K >
void test(CGAL::Dimension_tag<3>)
{
assert( 3 == CGAL::Dimension<typename K::Point_3>::value );
assert( 3 == CGAL::Dimension<typename K::Plane_3>::value );
assert( 3 == CGAL::Dimension<typename K::Vector_3>::value );
assert( 3 == CGAL::Dimension<typename K::Direction_3>::value );
assert( 3 == CGAL::Dimension<typename K::Line_3>::value );
assert( 3 == CGAL::Dimension<typename K::Ray_3>::value );
assert( 3 == CGAL::Dimension<typename K::Segment_3>::value );
assert( 3 == CGAL::Dimension<typename K::Triangle_3>::value );
assert( 3 == CGAL::Dimension<typename K::Tetrahedron_3>::value );
assert( 3 == CGAL::Dimension<typename K::Iso_cuboid_3>::value );
assert( 3 == CGAL::Dimension<typename K::Sphere_3>::value );
assert( 3 == CGAL::Dimension<typename K::Aff_transformation_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Point_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Plane_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Vector_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Direction_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Line_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Ray_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Segment_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Triangle_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Tetrahedron_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Iso_cuboid_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Sphere_3>::value );
assert( 3 == CGAL::Ambiant_dimension<typename K::Aff_transformation_3>::value );
assert( 3 == CGAL::Ambiant_dimension<CGAL::Bbox_3>::value );
assert( 0 == CGAL::Feature_dimension<typename K::Point_3>::value );
assert( 2 == CGAL::Feature_dimension<typename K::Plane_3>::value );
assert( 0 == CGAL::Feature_dimension<typename K::Vector_3>::value );
assert( 0 == CGAL::Feature_dimension<typename K::Direction_3>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Line_3>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Ray_3>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Segment_3>::value );
assert( 2 == CGAL::Feature_dimension<typename K::Triangle_3>::value );
assert( 3 == CGAL::Feature_dimension<typename K::Tetrahedron_3>::value );
assert( 3 == CGAL::Feature_dimension<typename K::Iso_cuboid_3>::value );
assert( 2 == CGAL::Feature_dimension<typename K::Sphere_3>::value );
// assert( ? == CGAL::Feature_dimension<typename K::Aff_transformation_3>::value );
assert( 3 == CGAL::Feature_dimension<CGAL::Bbox_3>::value );
}
void check_dyn_dim(CGAL::Dynamic_dimension_tag) {}
template < typename K >
void test(CGAL::Dimension_tag<CGAL::Dynamic_dimension>)
void test(CGAL::Dynamic_dimension_tag)
{
assert( CGAL::Dynamic_dimension == CGAL::Dimension<typename K::Point_d>::value );
assert( CGAL::Dynamic_dimension == CGAL::Dimension<typename K::Hyperplane_d>::value );
assert( CGAL::Dynamic_dimension == CGAL::Dimension<typename K::Vector_d>::value );
assert( CGAL::Dynamic_dimension == CGAL::Dimension<typename K::Direction_d>::value );
assert( CGAL::Dynamic_dimension == CGAL::Dimension<typename K::Line_d>::value );
assert( CGAL::Dynamic_dimension == CGAL::Dimension<typename K::Ray_d>::value );
assert( CGAL::Dynamic_dimension == CGAL::Dimension<typename K::Segment_d>::value );
assert( CGAL::Dynamic_dimension == CGAL::Dimension<typename K::Iso_box_d>::value );
assert( CGAL::Dynamic_dimension == CGAL::Dimension<typename K::Sphere_d>::value );
assert( CGAL::Dynamic_dimension == CGAL::Dimension<typename K::Aff_transformation_d>::value );
check_dyn_dim(typename CGAL::Ambiant_dimension<typename K::Point_d>::type() );
check_dyn_dim(typename CGAL::Ambiant_dimension<typename K::Hyperplane_d>::type() );
check_dyn_dim(typename CGAL::Ambiant_dimension<typename K::Vector_d>::type() );
check_dyn_dim(typename CGAL::Ambiant_dimension<typename K::Direction_d>::type() );
check_dyn_dim(typename CGAL::Ambiant_dimension<typename K::Line_d>::type() );
check_dyn_dim(typename CGAL::Ambiant_dimension<typename K::Ray_d>::type() );
check_dyn_dim(typename CGAL::Ambiant_dimension<typename K::Segment_d>::type() );
check_dyn_dim(typename CGAL::Ambiant_dimension<typename K::Iso_box_d>::type() );
check_dyn_dim(typename CGAL::Ambiant_dimension<typename K::Sphere_d>::type() );
check_dyn_dim(typename CGAL::Ambiant_dimension<typename K::Aff_transformation_d>::type() );
assert( 0 == CGAL::Feature_dimension<typename K::Point_d>::value );
assert( 0 == CGAL::Feature_dimension<typename K::Vector_d>::value );
assert( 0 == CGAL::Feature_dimension<typename K::Direction_d>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Line_d>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Ray_d>::value );
assert( 1 == CGAL::Feature_dimension<typename K::Segment_d>::value );
check_dyn_dim(typename CGAL::Feature_dimension<typename K::Hyperplane_d>::type() );
check_dyn_dim(typename CGAL::Feature_dimension<typename K::Iso_box_d>::type() );
check_dyn_dim(typename CGAL::Feature_dimension<typename K::Sphere_d>::type() );
// check_dyn_dim(typename CGAL::Feature_dimension<typename K::Aff_transformation_d>::type() );
}
int main()
{
test<CGAL::Cartesian<int> >(CGAL::Dimension_tag<2>());
test<CGAL::Cartesian<int> >(CGAL::Dimension_tag<3>());
test<CGAL::Cartesian_d<int> >(CGAL::Dimension_tag<CGAL::Dynamic_dimension>());
test<CGAL::Cartesian_d<int> >(CGAL::Dynamic_dimension_tag());
test<CGAL::Homogeneous<int> >(CGAL::Dimension_tag<2>());
test<CGAL::Homogeneous<int> >(CGAL::Dimension_tag<3>());
test<CGAL::Homogeneous_d<int> >(CGAL::Dimension_tag<CGAL::Dynamic_dimension>());
test<CGAL::Homogeneous_d<int> >(CGAL::Dynamic_dimension_tag());
test<CGAL::Exact_predicates_inexact_constructions_kernel>(CGAL::Dimension_tag<2>());
test<CGAL::Exact_predicates_inexact_constructions_kernel>(CGAL::Dimension_tag<3>());

View File

@ -46,8 +46,6 @@
#include <CGAL/Kernel_d/Interface_classes.h>
#include <CGAL/Kernel_d/simple_objects.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
template <class pFT, class pLA = Linear_algebraCd<pFT> >
@ -76,9 +74,14 @@ public:
typedef typename Point_d_base::Cartesian_const_iterator Cartesian_const_iterator_d;
template <typename>
struct Dimension {
static const int value = Dynamic_dimension;
template <typename T>
struct Ambiant_dimension {
typedef typename T::Ambiant_dimension type;
};
template <typename T>
struct Feature_dimension {
typedef typename T::Feature_dimension type;
};
template <typename K>

View File

@ -47,8 +47,6 @@
#include <CGAL/Kernel_d/Interface_classes.h>
#include <CGAL/Kernel_d/simple_objects.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
template <class pRT, class pLA = Linear_algebraHd<pRT> >
@ -76,9 +74,14 @@ public:
typedef typename Point_d_base::Cartesian_const_iterator Cartesian_const_iterator_d;
template <typename>
struct Dimension {
static const int value = Dynamic_dimension;
template <typename T>
struct Ambiant_dimension {
typedef typename T::Ambiant_dimension type;
};
template <typename T>
struct Feature_dimension {
typedef typename T::Feature_dimension type;
};
template <typename K>

View File

@ -18,17 +18,21 @@
// $URL$
// $Id$
//
//
// Author(s) : Michael Seel <seel@mpi-sb.mpg.de>
#ifndef CGAL_AFF_TRANSFORMATION_D_H
#define CGAL_AFF_TRANSFORMATION_D_H
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
template <class pR>
class Aff_transformation_d : public pR::Aff_transformation_d_base
{ public:
typedef CGAL::Dynamic_dimension_tag Ambiant_dimension;
typedef typename pR::Aff_transformation_d_base Base;
typedef Aff_transformation_d<pR> Self;
typedef pR R;

View File

@ -20,14 +20,21 @@
//
//
// Author(s) : Michael Seel
#ifndef CGAL_DIRECTION_D_H
#define CGAL_DIRECTION_D_H
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
template <class pR>
class Direction_d : public pR::Direction_d_base
{ public:
typedef CGAL::Dynamic_dimension_tag Ambiant_dimension;
typedef CGAL::Dimension_tag<0> Feature_dimension;
typedef typename pR::Direction_d_base Base;
typedef Direction_d<pR> Self;
typedef pR R;

View File

@ -24,12 +24,18 @@
#ifndef CGAL_HYPERPLANE_D_H
#define CGAL_HYPERPLANE_D_H
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
template <class pR>
class Hyperplane_d : public pR::Hyperplane_d_base
{
public:
typedef CGAL::Dynamic_dimension_tag Ambiant_dimension;
typedef CGAL::Dynamic_dimension_tag Feature_dimension;
typedef typename pR::Hyperplane_d_base Base;
typedef Hyperplane_d<pR> Self;
typedef pR R;

View File

@ -27,6 +27,7 @@
#include <CGAL/basic.h>
#include <CGAL/Handle_for.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
#include <functional>
#include <algorithm>
#include <numeric>
@ -311,6 +312,9 @@ namespace CGAL {
public:
typedef CGAL::Dynamic_dimension_tag Ambiant_dimension;
typedef CGAL::Dynamic_dimension_tag Feature_dimension;
Iso_box_d() {}
Iso_box_d(const Point_d& p, const Point_d& q)

View File

@ -27,6 +27,7 @@
#include <CGAL/Kernel_d/Pair_d.h>
#include <CGAL/Kernel_d/Segment_d.h>
#include <CGAL/Kernel_d/Ray_d.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -50,6 +51,10 @@ An instance of data type |Line_d| is an oriented line in
$d$-dimensional Euclidian space.}*/
public:
typedef CGAL::Dynamic_dimension_tag Ambiant_dimension;
typedef CGAL::Dimension_tag<1> Feature_dimension;
/*{\Mtypes 5}*/
typedef p_R R;
/*{\Mtypemember the representation type.}*/

View File

@ -20,9 +20,12 @@
//
//
// Author(s) : Michael Seel
#ifndef CGAL_POINT_D_H
#define CGAL_POINT_D_H
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
template <class pR>
@ -37,6 +40,9 @@ private:
typedef typename R::LA LA;
public:
typedef CGAL::Dynamic_dimension_tag Ambiant_dimension;
typedef CGAL::Dimension_tag<0> Feature_dimension;
Point_d(int d=0) : Base(d) {}
Point_d(int d, const Origin &o) : Base(d,o) {}

View File

@ -20,12 +20,14 @@
//
//
// Author(s) : Michael Seel
#ifndef CGAL_RAY_D_H
#define CGAL_RAY_D_H
#include <CGAL/Kernel_d/Pair_d.h>
#include <CGAL/Kernel_d/Segment_d.h>
#include <CGAL/Kernel_d/Line_d.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -51,6 +53,10 @@ Euclidian space. It starts in a point called the source of |\Mvar| and
it goes to infinity.}*/
public:
typedef CGAL::Dynamic_dimension_tag Ambiant_dimension;
typedef CGAL::Dimension_tag<1> Feature_dimension;
/*{\Mtypes 4}*/
typedef p_R R;
/*{\Mtypemember the representation type.}*/

View File

@ -20,12 +20,14 @@
//
//
// Author(s) : Michael Seel
#ifndef CGAL_SEGMENT_D_H
#define CGAL_SEGMENT_D_H
#include <CGAL/Kernel_d/Pair_d.h>
#include <CGAL/Kernel_d/Line_d.h>
#include <CGAL/Kernel_d/Ray_d.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -53,6 +55,10 @@ $p$ and $q$. $p$ is called the source point and $q$ is called
the target point of $s$, both points are called endpoints of $s$. A
segment whose endpoints are equal is called \emph{degenerate}.}*/
public:
typedef CGAL::Dynamic_dimension_tag Ambiant_dimension;
typedef CGAL::Dimension_tag<1> Feature_dimension;
/*{\Mtypes 5}*/
typedef p_R R;
/*{\Mtypemember the representation type.}*/

View File

@ -20,11 +20,13 @@
//
//
// Author(s) : Michael Seel
#ifndef CGAL_SPHERE_D_H
#define CGAL_SPHERE_D_H
#include <CGAL/basic.h>
#include <vector>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
@ -77,6 +79,9 @@ set of defining points to be legal. The orientation of $S$ is equal
to the orientation of the defining points, i.e., |orientation(A)|. }*/
public:
typedef CGAL::Dynamic_dimension_tag Ambiant_dimension;
typedef CGAL::Dynamic_dimension_tag Feature_dimension;
/*{\Mtypes 4}*/
typedef Sphere_d_rep<R_> Rep;

View File

@ -18,16 +18,22 @@
// $URL$
// $Id$
//
//
// Author(s) : Michael Seel
#ifndef CGAL_VECTOR_D_H
#define CGAL_VECTOR_D_H
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE
template <class pR>
class Vector_d : public pR::Vector_d_base
{ public:
typedef CGAL::Dynamic_dimension_tag Ambiant_dimension;
typedef CGAL::Dimension_tag<0> Feature_dimension;
typedef typename pR::Vector_d_base Base;
typedef Vector_d<pR> Self;
typedef pR R;

View File

@ -22,7 +22,7 @@
#include <CGAL/basic.h>
#include <CGAL/Object.h>
#include <CGAL/Linear_algebraCd.h>
#include <CGAL/Dimension_tag.h>
#include <CGAL/Dimension.h>
CGAL_BEGIN_NAMESPACE

View File

@ -25,7 +25,7 @@
#include <iterator>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Kernel/Dimension_utils.h>
#include <CGAL/Dimension_tag.h>
#include <CGAL/Dimension.h>
#include <list>
// Functions to compute the centroid of N points.

View File

@ -28,7 +28,7 @@
#include <CGAL/linear_least_squares_fitting_triangles_2.h>
#include <CGAL/linear_least_squares_fitting_circles_2.h>
#include <CGAL/linear_least_squares_fitting_rectangles_2.h>
#include <CGAL/Dimension_tag.h>
#include <CGAL/Dimension.h>
#include <iterator>

View File

@ -31,7 +31,7 @@
#include <CGAL/linear_least_squares_fitting_tetrahedra_3.h>
#include <CGAL/linear_least_squares_fitting_spheres_3.h>
#include <CGAL/Dimension_tag.h>
#include <CGAL/Dimension.h>
#include <iterator>
#include <list>