From 02e543a2944e33cfd02ad7277f057e512fb5548f Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Fri, 11 Apr 2008 21:03:22 +0000 Subject: [PATCH] Add Dimension whose nested "value" is the dimension of the ambiant space. A special constant CGAL::Dynamic_dimension (equal to INT_MAX) indicates the case where the dimension is only known at run time. --- .../include/CGAL/Cartesian/Cartesian_base.h | 5 + Conic_2/include/CGAL/Conic_2.h | 7 +- .../include/CGAL/Filtered_kernel.h | 5 + Filtered_kernel/include/CGAL/Lazy_kernel.h | 5 + .../CGAL/Homogeneous/Homogeneous_base.h | 5 + Kernel_23/doc_tex/Kernel_23_ref/Dimension.tex | 31 +++ .../doc_tex/Kernel_23_ref/Dimension_tag.tex | 6 +- Kernel_23/doc_tex/Kernel_23_ref/main.tex | 5 +- Kernel_23/include/CGAL/Aff_transformation_2.h | 2 + Kernel_23/include/CGAL/Aff_transformation_3.h | 3 + Kernel_23/include/CGAL/Bbox_2.h | 3 + Kernel_23/include/CGAL/Bbox_3.h | 3 + Kernel_23/include/CGAL/Circle_2.h | 2 + Kernel_23/include/CGAL/Dimension.h | 46 +++++ Kernel_23/include/CGAL/Direction_2.h | 2 + Kernel_23/include/CGAL/Direction_3.h | 2 + Kernel_23/include/CGAL/Iso_cuboid_3.h | 2 + Kernel_23/include/CGAL/Iso_rectangle_2.h | 2 + Kernel_23/include/CGAL/Kernel/Dimension.h | 187 ------------------ .../include/CGAL/Kernel/Dimension_utils.h | 28 +-- Kernel_23/include/CGAL/Line_2.h | 2 + Kernel_23/include/CGAL/Line_3.h | 2 + Kernel_23/include/CGAL/Plane_3.h | 2 + Kernel_23/include/CGAL/Point_2.h | 3 + Kernel_23/include/CGAL/Point_3.h | 2 + Kernel_23/include/CGAL/Ray_2.h | 2 + Kernel_23/include/CGAL/Ray_3.h | 2 + Kernel_23/include/CGAL/Segment_2.h | 2 + Kernel_23/include/CGAL/Segment_3.h | 2 + Kernel_23/include/CGAL/Sphere_3.h | 2 + Kernel_23/include/CGAL/Tetrahedron_3.h | 2 + Kernel_23/include/CGAL/Triangle_2.h | 2 + Kernel_23/include/CGAL/Triangle_3.h | 2 + Kernel_23/include/CGAL/Vector_2.h | 2 + Kernel_23/include/CGAL/Vector_3.h | 2 + Kernel_23/test/Kernel_23/Dimension.cpp | 42 ++-- Kernel_d/include/CGAL/Cartesian_d.h | 7 + Kernel_d/include/CGAL/Homogeneous_d.h | 7 + .../include/CGAL/bounding_box.h | 4 +- 39 files changed, 213 insertions(+), 229 deletions(-) create mode 100644 Kernel_23/doc_tex/Kernel_23_ref/Dimension.tex create mode 100644 Kernel_23/include/CGAL/Dimension.h delete mode 100644 Kernel_23/include/CGAL/Kernel/Dimension.h diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Cartesian_base.h b/Cartesian_kernel/include/CGAL/Cartesian/Cartesian_base.h index bdee60c11b6..61973aee365 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Cartesian_base.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Cartesian_base.h @@ -101,6 +101,11 @@ struct Cartesian_base typedef typename Same_uncertainty_nt::type Angle; + template + struct Dimension { + static const int value = T::static_dimension; + }; + typedef PointC2 Point_2; typedef VectorC2 Vector_2; typedef DirectionC2 Direction_2; diff --git a/Conic_2/include/CGAL/Conic_2.h b/Conic_2/include/CGAL/Conic_2.h index c9646ad4bf6..3b679a5fdad 100644 --- a/Conic_2/include/CGAL/Conic_2.h +++ b/Conic_2/include/CGAL/Conic_2.h @@ -32,11 +32,6 @@ CGAL_BEGIN_NAMESPACE template < class R_ > class Optimisation_ellipse_2; -CGAL_END_NAMESPACE - - -CGAL_BEGIN_NAMESPACE - template < class R_> class Conic_2 : public R_::Kernel_base::Conic_2 { @@ -44,6 +39,8 @@ class Conic_2 : public R_::Kernel_base::Conic_2 { public: + static const int static_dimension = 2; + // types typedef R_ R; typedef typename R_::RT RT; diff --git a/Filtered_kernel/include/CGAL/Filtered_kernel.h b/Filtered_kernel/include/CGAL/Filtered_kernel.h index 0fca80851e1..7e67db78680 100644 --- a/Filtered_kernel/include/CGAL/Filtered_kernel.h +++ b/Filtered_kernel/include/CGAL/Filtered_kernel.h @@ -67,6 +67,11 @@ struct Filtered_kernel_base typedef Filtered_kernel_base Type; }; + template < typename T > + struct Dimension { + static const int value = T::static_dimension; // maybe not the right way... + }; + // We change the predicates. #define CGAL_Kernel_pred(P, Pf) \ typedef Filtered_predicate P; \ diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index c0b525f98f5..ef67489490f 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -59,6 +59,11 @@ public: template < typename Kernel2 > struct Base { typedef Lazy_kernel_generic_base Type; }; + template < typename T > + struct Dimension { + static const int value = T::static_dimension; + }; + // What to do with the tag ? // Probably this should not exist, should it ? // struct filter_tag{}; diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h index 2bf7f8d652f..b59b17e8255 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h @@ -108,6 +108,11 @@ struct Homogeneous_base typedef typename Same_uncertainty_nt::type Angle; + template + struct Dimension { + static const int value = T::static_dimension; + }; + typedef PointH2 Point_2; typedef VectorH2 Vector_2; typedef DirectionH2 Direction_2; diff --git a/Kernel_23/doc_tex/Kernel_23_ref/Dimension.tex b/Kernel_23/doc_tex/Kernel_23_ref/Dimension.tex new file mode 100644 index 00000000000..bdd1def1bdd --- /dev/null +++ b/Kernel_23/doc_tex/Kernel_23_ref/Dimension.tex @@ -0,0 +1,31 @@ +\begin{ccRefClass} {Dimension::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::value}. } + +\ccCreation +\ccCreationVariable{d} + +\ccExample + +The following retrieves the dimension of a point type. + +\begin{cprog} + typedef Point_2 Point; + int dimension = Dimension::value; + assert(dimension == 2); +\end{cprog} + +\ccSeeAlso +\ccRefConceptPage{Dimension_tag} + +\end{ccRefClass} diff --git a/Kernel_23/doc_tex/Kernel_23_ref/Dimension_tag.tex b/Kernel_23/doc_tex/Kernel_23_ref/Dimension_tag.tex index 9861c0d1916..28f2c651ef2 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/Dimension_tag.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/Dimension_tag.tex @@ -26,9 +26,7 @@ The following declaration creates two points at the origin, either in 2D or in 3 std::cout << get_origin(Dimension_tag<2>())) << std::endl; \end{cprog} -% \ccSeeAlso -% \ccRefConceptPage{Kernel::Point_2} -% \ccRefIdfierPage{CGAL::Tag_true} \\ -% \ccRefIdfierPage{CGAL::Tag_false} +\ccSeeAlso +\ccRefConceptPage{Dimension} \end{ccRefClass} diff --git a/Kernel_23/doc_tex/Kernel_23_ref/main.tex b/Kernel_23/doc_tex/Kernel_23_ref/main.tex index b3de3d3eb22..1558b5e92cb 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/main.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/main.tex @@ -464,7 +464,6 @@ in the kernel. \section{Dimension handling tools} \gdef\ccRefPageBreak{\ccFalse} +\input{Kernel_23_ref/Dimension.tex} +\gdef\ccRefPageBreak{\ccTrue} \input{Kernel_23_ref/Dimension_tag.tex} -%\gdef\ccRefPageBreak{\ccTrue} -%\input{Kernel_23_ref/Exact_predicates_exact_constructions_kernel_with_sqrt.tex} -%\input{Kernel_23_ref/Exact_predicates_inexact_constructions_kernel.tex} diff --git a/Kernel_23/include/CGAL/Aff_transformation_2.h b/Kernel_23/include/CGAL/Aff_transformation_2.h index ca76f02136e..124cf274373 100644 --- a/Kernel_23/include/CGAL/Aff_transformation_2.h +++ b/Kernel_23/include/CGAL/Aff_transformation_2.h @@ -41,6 +41,8 @@ class Aff_transformation_2 : public R_::Kernel_base::Aff_transformation_2 public: typedef R_ R; + static const int static_dimension = 2; + Aff_transformation_2() {} Aff_transformation_2(const RAff_transformation_2& t) diff --git a/Kernel_23/include/CGAL/Aff_transformation_3.h b/Kernel_23/include/CGAL/Aff_transformation_3.h index 4b98377665b..4d2cbe3ba24 100644 --- a/Kernel_23/include/CGAL/Aff_transformation_3.h +++ b/Kernel_23/include/CGAL/Aff_transformation_3.h @@ -33,6 +33,9 @@ class Aff_transformation_3 : public R_::Kernel_base::Aff_transformation_3 typedef typename R_::Vector_3 Vector_3; typedef typename R_::Kernel_base::Aff_transformation_3 RAff_transformation_3; public: + + static const int static_dimension = 3; + typedef R_ R; Aff_transformation_3() {} diff --git a/Kernel_23/include/CGAL/Bbox_2.h b/Kernel_23/include/CGAL/Bbox_2.h index 6785f823746..6242d6367b0 100644 --- a/Kernel_23/include/CGAL/Bbox_2.h +++ b/Kernel_23/include/CGAL/Bbox_2.h @@ -38,6 +38,9 @@ class Bbox_2 BBox_rep_2 rep; public: + + static const int static_dimension = 2; + Bbox_2() {} Bbox_2(double x_min, double y_min, diff --git a/Kernel_23/include/CGAL/Bbox_3.h b/Kernel_23/include/CGAL/Bbox_3.h index d81a6abaf5e..2267d23df76 100644 --- a/Kernel_23/include/CGAL/Bbox_3.h +++ b/Kernel_23/include/CGAL/Bbox_3.h @@ -35,6 +35,9 @@ class Bbox_3 Sixtuple rep; public: + + static const int static_dimension = 3; + Bbox_3() {} Bbox_3(double x_min, double y_min, double z_min, diff --git a/Kernel_23/include/CGAL/Circle_2.h b/Kernel_23/include/CGAL/Circle_2.h index 118412419e8..bd9426285fd 100644 --- a/Kernel_23/include/CGAL/Circle_2.h +++ b/Kernel_23/include/CGAL/Circle_2.h @@ -45,6 +45,8 @@ class Circle_2 : public R_::Kernel_base::Circle_2 public: + static const int static_dimension = 2; + typedef RCircle_2 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Dimension.h b/Kernel_23/include/CGAL/Dimension.h new file mode 100644 index 00000000000..3a42e631884 --- /dev/null +++ b/Kernel_23/include/CGAL/Dimension.h @@ -0,0 +1,46 @@ +// 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. +// +// 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_H +#define CGAL_DIMENSION_H + +#include +#include +#include + +CGAL_BEGIN_NAMESPACE + +// This is a tool to obtain the static dimension of a kernel object. +// That is, the dimension of the ambiant space. + +template < typename T, typename K = typename Kernel_traits::Kernel > +struct Dimension +{ + static const int value = K::template Dimension::value; +}; + +static const int Dynamic_dimension = INT_MAX; + +CGAL_END_NAMESPACE + +#endif // CGAL_DIMENSION_H diff --git a/Kernel_23/include/CGAL/Direction_2.h b/Kernel_23/include/CGAL/Direction_2.h index f878763fa40..c70b5df99cf 100644 --- a/Kernel_23/include/CGAL/Direction_2.h +++ b/Kernel_23/include/CGAL/Direction_2.h @@ -47,6 +47,8 @@ class Direction_2 : public R_::Kernel_base::Direction_2 public: + static const int static_dimension = 2; + typedef RDirection_2 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Direction_3.h b/Kernel_23/include/CGAL/Direction_3.h index 56420db9a52..7eefaf7ac5d 100644 --- a/Kernel_23/include/CGAL/Direction_3.h +++ b/Kernel_23/include/CGAL/Direction_3.h @@ -46,6 +46,8 @@ class Direction_3 : public R_::Kernel_base::Direction_3 public: + static const int static_dimension = 3; + typedef typename R_::Kernel_base::Direction_3 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Iso_cuboid_3.h b/Kernel_23/include/CGAL/Iso_cuboid_3.h index 8791eee6327..5d7e2b96689 100644 --- a/Kernel_23/include/CGAL/Iso_cuboid_3.h +++ b/Kernel_23/include/CGAL/Iso_cuboid_3.h @@ -43,6 +43,8 @@ class Iso_cuboid_3 : public R_::Kernel_base::Iso_cuboid_3 public: + static const int static_dimension = 3; + typedef typename R_::Kernel_base::Iso_cuboid_3 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Iso_rectangle_2.h b/Kernel_23/include/CGAL/Iso_rectangle_2.h index c7767b04532..400f20a075c 100644 --- a/Kernel_23/include/CGAL/Iso_rectangle_2.h +++ b/Kernel_23/include/CGAL/Iso_rectangle_2.h @@ -44,6 +44,8 @@ class Iso_rectangle_2 : public R_::Kernel_base::Iso_rectangle_2 public: + static const int static_dimension = 2; + typedef typename R_::Kernel_base::Iso_rectangle_2 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Kernel/Dimension.h b/Kernel_23/include/CGAL/Kernel/Dimension.h deleted file mode 100644 index 091074f4475..00000000000 --- a/Kernel_23/include/CGAL/Kernel/Dimension.h +++ /dev/null @@ -1,187 +0,0 @@ -// 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. -// -// 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_KERNEL_DIMENSION_H -#define CGAL_KERNEL_DIMENSION_H - -#include -#include - -CGAL_BEGIN_NAMESPACE - -// This is a tool to obtain the static dimension of a kernel object. -// Currently undocumented => for CGAL internal use only. - -// TODO : -// - Should the default be that kernel objects export this value themselves ? -// This way, user defined objects will work as well ? -// But an object could have a dimension depending on the traits... -// => Well, let's make it work first. -// - Should it be named Dimension_traits<> ? - -template < typename T, typename K = typename Kernel_traits::Kernel > -struct Dimension; - -// 2D objects - -template < typename K > -struct Dimension < typename K::Point_2, K > -{ static const int value = 2; }; - -template < typename K > -struct Dimension < typename K::Vector_2, K > -{ static const int value = 2; }; - -template < typename K > -struct Dimension < typename K::Direction_2, K > -{ static const int value = 2; }; - -template < typename K > -struct Dimension < typename K::Line_2, K > -{ static const int value = 2; }; - -template < typename K > -struct Dimension < typename K::Ray_2, K > -{ static const int value = 2; }; - -template < typename K > -struct Dimension < typename K::Segment_2, K > -{ static const int value = 2; }; - -template < typename K > -struct Dimension < typename K::Triangle_2, K > -{ static const int value = 2; }; - -template < typename K > -struct Dimension < typename K::Iso_rectangle_2, K > -{ static const int value = 2; }; - -template < typename K > -struct Dimension < typename K::Circle_2, K > -{ static const int value = 2; }; - -template < typename K > -struct Dimension < typename K::Conic_2, K > -{ static const int value = 2; }; - -template < typename K > -struct Dimension < typename K::Aff_transformation_2, K > -{ static const int value = 2; }; - - -// 3D objects - -template < typename K > -struct Dimension < typename K::Point_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Plane_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Vector_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Direction_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Line_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Ray_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Segment_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Triangle_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Tetrahedron_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Iso_cuboid_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Sphere_3, K > -{ static const int value = 3; }; - -template < typename K > -struct Dimension < typename K::Aff_transformation_3, K > -{ static const int value = 3; }; - - -// dD objects - -template < typename K > -struct Dimension < typename K::Point_d, K > -{ static const int value = 0; }; - -template < typename K > -struct Dimension < typename K::Vector_d, K > -{ static const int value = 0; }; - -template < typename K > -struct Dimension < typename K::Direction_d, K > -{ static const int value = 0; }; - -template < typename K > -struct Dimension < typename K::Hyperplane_d, K > -{ static const int value = 0; }; - -template < typename K > -struct Dimension < typename K::Aff_transformation_d, K > -{ static const int value = 0; }; - -template < typename K > -struct Dimension < typename K::Sphere_d, K > -{ static const int value = 0; }; - -template < typename K > -struct Dimension < typename K::Iso_box_d, K > -{ static const int value = 0; }; - -template < typename K > -struct Dimension < typename K::Segment_d, K > -{ static const int value = 0; }; - -template < typename K > -struct Dimension < typename K::Ray_d, K > -{ static const int value = 0; }; - -template < typename K > -struct Dimension < typename K::Line_d, K > -{ static const int value = 0; }; - -CGAL_END_NAMESPACE - -#endif // CGAL_KERNEL_DIMENSION_H diff --git a/Kernel_23/include/CGAL/Kernel/Dimension_utils.h b/Kernel_23/include/CGAL/Kernel/Dimension_utils.h index 59f4cc27e48..1b16dec9e57 100644 --- a/Kernel_23/include/CGAL/Kernel/Dimension_utils.h +++ b/Kernel_23/include/CGAL/Kernel/Dimension_utils.h @@ -25,7 +25,7 @@ #define CGAL_KERNEL_DIMENSION_UTILS_H #include -#include +#include CGAL_BEGIN_NAMESPACE @@ -66,7 +66,7 @@ template < typename K > struct Point <3, K> { typedef typename K::Point_3 type; }; template < typename K > -struct Point <0, K> { typedef typename K::Point_d type; }; +struct Point { typedef typename K::Point_d type; }; template < typename K > @@ -76,7 +76,7 @@ template < typename K > struct Vector <3, K> { typedef typename K::Vector_3 type; }; template < typename K > -struct Vector <0, K> { typedef typename K::Vector_d type; }; +struct Vector { typedef typename K::Vector_d type; }; template < typename K > @@ -86,7 +86,7 @@ template < typename K > struct Iso_box <3, K> { typedef typename K::Iso_cuboid_3 type; }; template < typename K > -struct Iso_box <0, K> { typedef typename K::Iso_box_d type; }; +struct Iso_box { typedef typename K::Iso_box_d type; }; template < typename K > @@ -96,7 +96,7 @@ template < typename K > struct Direction <3, K> { typedef typename K::Direction_3 type; }; template < typename K > -struct Direction <0, K> { typedef typename K::Direction_d type; }; +struct Direction { typedef typename K::Direction_d type; }; template < typename K > @@ -106,7 +106,7 @@ template < typename K > struct Line <3, K> { typedef typename K::Line_3 type; }; template < typename K > -struct Line <0, K> { typedef typename K::Line_d type; }; +struct Line { typedef typename K::Line_d type; }; template < typename K > @@ -116,7 +116,7 @@ template < typename K > struct Ray <3, K> { typedef typename K::Ray_3 type; }; template < typename K > -struct Ray <0, K> { typedef typename K::Ray_d type; }; +struct Ray { typedef typename K::Ray_d type; }; template < typename K > @@ -126,7 +126,7 @@ template < typename K > struct Segment <3, K> { typedef typename K::Segment_3 type; }; template < typename K > -struct Segment <0, K> { typedef typename K::Segment_d type; }; +struct Segment { typedef typename K::Segment_d type; }; template < typename K > @@ -136,14 +136,14 @@ template < typename K > struct Triangle <3, K> { typedef typename K::Triangle_3 type; }; template < typename K > -struct Triangle <0, K> { typedef typename K::Triangle_d type; }; +struct Triangle { typedef typename K::Triangle_d type; }; template < typename K > struct Tetrahedron <3, K> { typedef typename K::Tetrahedron_3 type; }; template < typename K > -struct Tetrahedron <0, K> { typedef typename K::Tetrahedron_d type; }; +struct Tetrahedron { typedef typename K::Tetrahedron_d type; }; template < typename K > @@ -153,7 +153,7 @@ template < typename K > struct Hypersphere <3, K> { typedef typename K::Sphere_3 type; }; template < typename K > -struct Hypersphere <0, K> { typedef typename K::Sphere_d type; }; +struct Hypersphere { typedef typename K::Sphere_d type; }; template < typename K > @@ -163,7 +163,7 @@ template < typename K > struct Hyperplane <3, K> { typedef typename K::Plane_3 type; }; template < typename K > -struct Hyperplane <0, K> { typedef typename K::Hyperplane_d type; }; +struct Hyperplane { typedef typename K::Hyperplane_d type; }; template < typename K > @@ -175,7 +175,7 @@ struct Aff_transformation <3, K> { typedef typename K::Aff_transformation_3 type; }; template < typename K > -struct Aff_transformation <0, K> +struct Aff_transformation { typedef typename K::Aff_transformation_d type; }; @@ -224,7 +224,7 @@ struct Dimension_mapper }; template < typename T, typename K > -struct Dimension_mapper +struct Dimension_mapper : public K { Dimension_mapper() {} diff --git a/Kernel_23/include/CGAL/Line_2.h b/Kernel_23/include/CGAL/Line_2.h index dd5eb678108..20f388d8d0d 100644 --- a/Kernel_23/include/CGAL/Line_2.h +++ b/Kernel_23/include/CGAL/Line_2.h @@ -48,6 +48,8 @@ class Line_2 : public R_::Kernel_base::Line_2 public: + static const int static_dimension = 2; + typedef RLine_2 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Line_3.h b/Kernel_23/include/CGAL/Line_3.h index f11c520059e..5adba15ccba 100644 --- a/Kernel_23/include/CGAL/Line_3.h +++ b/Kernel_23/include/CGAL/Line_3.h @@ -48,6 +48,8 @@ class Line_3 : public R_::Kernel_base::Line_3 public: + static const int static_dimension = 3; + typedef typename R_::Kernel_base::Line_3 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Plane_3.h b/Kernel_23/include/CGAL/Plane_3.h index 74c98de957d..ec095fa0e3e 100644 --- a/Kernel_23/include/CGAL/Plane_3.h +++ b/Kernel_23/include/CGAL/Plane_3.h @@ -48,6 +48,8 @@ class Plane_3 : public R_::Kernel_base::Plane_3 public: + static const int static_dimension = 3; + typedef typename R_::Kernel_base::Plane_3 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Point_2.h b/Kernel_23/include/CGAL/Point_2.h index 0c4c5eca811..46ad95e3945 100644 --- a/Kernel_23/include/CGAL/Point_2.h +++ b/Kernel_23/include/CGAL/Point_2.h @@ -46,6 +46,9 @@ class Point_2 : public R_::Kernel_base::Point_2 BOOST_STATIC_ASSERT((boost::is_same::value)); public: + + static const int static_dimension = 2; + typedef RPoint_2 Rep; typedef typename R_::Cartesian_const_iterator_2 Cartesian_const_iterator; diff --git a/Kernel_23/include/CGAL/Point_3.h b/Kernel_23/include/CGAL/Point_3.h index 52997b58b98..71aa0e927da 100644 --- a/Kernel_23/include/CGAL/Point_3.h +++ b/Kernel_23/include/CGAL/Point_3.h @@ -47,6 +47,8 @@ class Point_3 : public R_::Kernel_base::Point_3 public: + static const int static_dimension = 3; + typedef typename R_::Kernel_base::Point_3 Rep; typedef typename R_::Cartesian_const_iterator_3 Cartesian_const_iterator; diff --git a/Kernel_23/include/CGAL/Ray_2.h b/Kernel_23/include/CGAL/Ray_2.h index 0967307e11e..5b5eaa7f53e 100644 --- a/Kernel_23/include/CGAL/Ray_2.h +++ b/Kernel_23/include/CGAL/Ray_2.h @@ -49,6 +49,8 @@ class Ray_2 : public R_::Kernel_base::Ray_2 public: + static const int static_dimension = 2; + typedef RRay_2 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Ray_3.h b/Kernel_23/include/CGAL/Ray_3.h index b687740ed7d..beb41b3cf42 100644 --- a/Kernel_23/include/CGAL/Ray_3.h +++ b/Kernel_23/include/CGAL/Ray_3.h @@ -46,6 +46,8 @@ class Ray_3 : public R_::Kernel_base::Ray_3 public: + static const int static_dimension = 3; + typedef typename R_::Kernel_base::Ray_3 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Segment_2.h b/Kernel_23/include/CGAL/Segment_2.h index 9a66d78f8d4..d023e36cb23 100644 --- a/Kernel_23/include/CGAL/Segment_2.h +++ b/Kernel_23/include/CGAL/Segment_2.h @@ -48,6 +48,8 @@ class Segment_2 : public R_::Kernel_base::Segment_2 public: + static const int static_dimension = 2; + typedef RSegment_2 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Segment_3.h b/Kernel_23/include/CGAL/Segment_3.h index 6ef87d02091..fd23a6708cf 100644 --- a/Kernel_23/include/CGAL/Segment_3.h +++ b/Kernel_23/include/CGAL/Segment_3.h @@ -47,6 +47,8 @@ class Segment_3 : public R_::Kernel_base::Segment_3 public: + static const int static_dimension = 3; + typedef typename R_::Kernel_base::Segment_3 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Sphere_3.h b/Kernel_23/include/CGAL/Sphere_3.h index 501d5274db3..e730c6bb66a 100644 --- a/Kernel_23/include/CGAL/Sphere_3.h +++ b/Kernel_23/include/CGAL/Sphere_3.h @@ -44,6 +44,8 @@ class Sphere_3 : public R_::Kernel_base::Sphere_3 public: + static const int static_dimension = 3; + typedef typename R_::Kernel_base::Sphere_3 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Tetrahedron_3.h b/Kernel_23/include/CGAL/Tetrahedron_3.h index b0c1681b962..a31a3a57976 100644 --- a/Kernel_23/include/CGAL/Tetrahedron_3.h +++ b/Kernel_23/include/CGAL/Tetrahedron_3.h @@ -42,6 +42,8 @@ class Tetrahedron_3 : public R_::Kernel_base::Tetrahedron_3 public: + static const int static_dimension = 3; + typedef typename R_::Kernel_base::Tetrahedron_3 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Triangle_2.h b/Kernel_23/include/CGAL/Triangle_2.h index 93b175025ef..c22c4770fd5 100644 --- a/Kernel_23/include/CGAL/Triangle_2.h +++ b/Kernel_23/include/CGAL/Triangle_2.h @@ -43,6 +43,8 @@ class Triangle_2 : public R_::Kernel_base::Triangle_2 public: + static const int static_dimension = 2; + typedef RTriangle_2 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Triangle_3.h b/Kernel_23/include/CGAL/Triangle_3.h index 42de947c3f3..665e7f8e12c 100644 --- a/Kernel_23/include/CGAL/Triangle_3.h +++ b/Kernel_23/include/CGAL/Triangle_3.h @@ -45,6 +45,8 @@ class Triangle_3 : public R_::Kernel_base::Triangle_3 public: + static const int static_dimension = 3; + typedef typename R_::Kernel_base::Triangle_3 Rep; const Rep& rep() const diff --git a/Kernel_23/include/CGAL/Vector_2.h b/Kernel_23/include/CGAL/Vector_2.h index a2b3728b8c7..36839d88da6 100644 --- a/Kernel_23/include/CGAL/Vector_2.h +++ b/Kernel_23/include/CGAL/Vector_2.h @@ -51,6 +51,8 @@ class Vector_2 : public R_::Kernel_base::Vector_2 public: + static const int static_dimension = 2; + typedef RVector_2 Rep; typedef typename R_::Cartesian_const_iterator_2 Cartesian_const_iterator; diff --git a/Kernel_23/include/CGAL/Vector_3.h b/Kernel_23/include/CGAL/Vector_3.h index 8ce54737b91..bb77390c23d 100644 --- a/Kernel_23/include/CGAL/Vector_3.h +++ b/Kernel_23/include/CGAL/Vector_3.h @@ -50,6 +50,8 @@ class Vector_3 : public R_::Kernel_base::Vector_3 public: + static const int static_dimension = 3; + typedef typename R_::Cartesian_const_iterator_3 Cartesian_const_iterator; typedef typename R_::Kernel_base::Vector_3 Rep; diff --git a/Kernel_23/test/Kernel_23/Dimension.cpp b/Kernel_23/test/Kernel_23/Dimension.cpp index aff26957c59..1e450a38341 100644 --- a/Kernel_23/test/Kernel_23/Dimension.cpp +++ b/Kernel_23/test/Kernel_23/Dimension.cpp @@ -1,11 +1,15 @@ // Test program for Dimension<>. // Sylvain Pion, 2005. -#include #include +#include #include +#include +#include +#include +#include -#include +#include #include template < typename K > @@ -42,25 +46,35 @@ void test(CGAL::Dimension_tag<3>) } template < typename K > -void test(CGAL::Dimension_tag<0>) +void test(CGAL::Dimension_tag) { - assert( 0 == CGAL::Dimension::value ); - assert( 0 == CGAL::Dimension::value ); - assert( 0 == CGAL::Dimension::value ); - assert( 0 == CGAL::Dimension::value ); - assert( 0 == CGAL::Dimension::value ); - assert( 0 == CGAL::Dimension::value ); - assert( 0 == CGAL::Dimension::value ); - assert( 0 == CGAL::Dimension::value ); - assert( 0 == CGAL::Dimension::value ); - assert( 0 == CGAL::Dimension::value ); + assert( CGAL::Dynamic_dimension == CGAL::Dimension::value ); + assert( CGAL::Dynamic_dimension == CGAL::Dimension::value ); + assert( CGAL::Dynamic_dimension == CGAL::Dimension::value ); + assert( CGAL::Dynamic_dimension == CGAL::Dimension::value ); + assert( CGAL::Dynamic_dimension == CGAL::Dimension::value ); + assert( CGAL::Dynamic_dimension == CGAL::Dimension::value ); + assert( CGAL::Dynamic_dimension == CGAL::Dimension::value ); + assert( CGAL::Dynamic_dimension == CGAL::Dimension::value ); + assert( CGAL::Dynamic_dimension == CGAL::Dimension::value ); + assert( CGAL::Dynamic_dimension == CGAL::Dimension::value ); } int main() { test >(CGAL::Dimension_tag<2>()); test >(CGAL::Dimension_tag<3>()); - test >(CGAL::Dimension_tag<0>()); + test >(CGAL::Dimension_tag()); + + test >(CGAL::Dimension_tag<2>()); + test >(CGAL::Dimension_tag<3>()); + test >(CGAL::Dimension_tag()); + test(CGAL::Dimension_tag<2>()); + test(CGAL::Dimension_tag<3>()); + + test(CGAL::Dimension_tag<2>()); + test(CGAL::Dimension_tag<3>()); + return 0; } diff --git a/Kernel_d/include/CGAL/Cartesian_d.h b/Kernel_d/include/CGAL/Cartesian_d.h index d0d8aa216f1..3edcc15c457 100644 --- a/Kernel_d/include/CGAL/Cartesian_d.h +++ b/Kernel_d/include/CGAL/Cartesian_d.h @@ -46,6 +46,8 @@ #include #include +#include + CGAL_BEGIN_NAMESPACE template > @@ -74,6 +76,11 @@ public: typedef typename Point_d_base::Cartesian_const_iterator Cartesian_const_iterator_d; + template + struct Dimension { + static const int value = Dynamic_dimension; + }; + template class Construct_cartesian_const_iterator { diff --git a/Kernel_d/include/CGAL/Homogeneous_d.h b/Kernel_d/include/CGAL/Homogeneous_d.h index a875e103bdb..0a8c51da83b 100644 --- a/Kernel_d/include/CGAL/Homogeneous_d.h +++ b/Kernel_d/include/CGAL/Homogeneous_d.h @@ -47,6 +47,8 @@ #include #include +#include + CGAL_BEGIN_NAMESPACE template > @@ -74,6 +76,11 @@ public: typedef typename Point_d_base::Cartesian_const_iterator Cartesian_const_iterator_d; + template + struct Dimension { + static const int value = Dynamic_dimension; + }; + template class Construct_cartesian_const_iterator { diff --git a/Principal_component_analysis/include/CGAL/bounding_box.h b/Principal_component_analysis/include/CGAL/bounding_box.h index 33ad7087cae..b8c4a10b813 100644 --- a/Principal_component_analysis/include/CGAL/bounding_box.h +++ b/Principal_component_analysis/include/CGAL/bounding_box.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include CGAL_BEGIN_NAMESPACE @@ -148,7 +148,7 @@ struct bbox<3> }; template <> -struct bbox<0> +struct bbox { template < class ForwardIterator, class Traits > typename Traits::Iso_box_d