1 // Copyright (c) 2005,2008 INRIA Sophia-Antipolis (France). 2 // All rights reserved. 3 // 4 // This file is part of CGAL (www.cgal.org) 5 // 6 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Kernel_23/include/CGAL/Kernel/Dimension_utils.h $ 7 // $Id: Dimension_utils.h 52164b1 2019-10-19T15:34:59+02:00 Sébastien Loriot 8 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial 9 // 10 // Author(s) : Sylvain Pion 11 12 #ifndef CGAL_KERNEL_DIMENSION_UTILS_H 13 #define CGAL_KERNEL_DIMENSION_UTILS_H 14 15 #include <CGAL/Kernel_traits.h> 16 #include <CGAL/Dimension.h> 17 18 namespace CGAL { 19 20 namespace Access { 21 22 // Some tools to find the type of a kernel object given its dimension. 23 // E.g. : Vector<K, 2>::type is K::Vector_2. 24 // 25 // Currently undocumented => for CGAL internal use only. 26 27 // TODO : 28 // - What about functors ? 29 // At least those with a dimensional-independent interface. 30 // - Another thing which would be nice would be to make d-dimensional 31 // algorithms use the 2d-3d kernel interface with a smaller wrapper. 32 // (again, this forces a full kernel, not a sub-set traits, but at least...) 33 // Then, based on Dimension<>, it's possible to automatically use it. 34 35 template < typename K, typename Dim_tag = typename K::Dimension> struct Point; 36 template < typename K, typename Dim_tag = typename K::Dimension> struct Vector; 37 template < typename K, typename Dim_tag = typename K::Dimension> struct Iso_box; 38 template < typename K, typename Dim_tag = typename K::Dimension> struct Direction; 39 template < typename K, typename Dim_tag = typename K::Dimension> struct Line; 40 template < typename K, typename Dim_tag = typename K::Dimension> struct Ray; 41 template < typename K, typename Dim_tag = typename K::Dimension> struct Segment; 42 template < typename K, typename Dim_tag = typename K::Dimension> struct Triangle; 43 template < typename K, typename Dim_tag = typename K::Dimension> struct Hypersphere; 44 template < typename K, typename Dim_tag = typename K::Dimension> struct Hyperplane; 45 template < typename K, typename Dim_tag = typename K::Dimension> struct Aff_transformation; 46 47 // Not-so generalizable stuff : Conic_2, Tetrahedron_3. 48 template < typename K, typename Dim_tag = typename K::Dimension> struct Tetrahedron; 49 50 51 template < typename K > 52 struct Point <K, Dimension_tag<2> > { typedef typename K::Point_2 type; }; 53 54 template < typename K > 55 struct Point <K, Dimension_tag<3> > { typedef typename K::Point_3 type; }; 56 57 template < typename K > 58 struct Point <K, Dynamic_dimension_tag> { typedef typename K::Point_d type; }; 59 60 61 template < typename K > 62 struct Vector <K, Dimension_tag<2> > { typedef typename K::Vector_2 type; }; 63 64 template < typename K > 65 struct Vector <K, Dimension_tag<3> > { typedef typename K::Vector_3 type; }; 66 67 template < typename K > 68 struct Vector <K, Dynamic_dimension_tag> { typedef typename K::Vector_d type; }; 69 70 71 template < typename K > 72 struct Iso_box <K, Dimension_tag<2> > { typedef typename K::Iso_rectangle_2 type; }; 73 74 template < typename K > 75 struct Iso_box <K, Dimension_tag<3> > { typedef typename K::Iso_cuboid_3 type; }; 76 77 template < typename K > 78 struct Iso_box <K, Dynamic_dimension_tag> { typedef typename K::Iso_box_d type; }; 79 80 81 template < typename K > 82 struct Direction <K, Dimension_tag<2> > { typedef typename K::Direction_2 type; }; 83 84 template < typename K > 85 struct Direction <K, Dimension_tag<3> > { typedef typename K::Direction_3 type; }; 86 87 template < typename K > 88 struct Direction <K, Dynamic_dimension_tag> { typedef typename K::Direction_d type; }; 89 90 91 template < typename K > 92 struct Line <K, Dimension_tag<2> > { typedef typename K::Line_2 type; }; 93 94 template < typename K > 95 struct Line <K, Dimension_tag<3> > { typedef typename K::Line_3 type; }; 96 97 template < typename K > 98 struct Line <K, Dynamic_dimension_tag> { typedef typename K::Line_d type; }; 99 100 101 template < typename K > 102 struct Ray <K, Dimension_tag<2> > { typedef typename K::Ray_2 type; }; 103 104 template < typename K > 105 struct Ray <K, Dimension_tag<3> > { typedef typename K::Ray_3 type; }; 106 107 template < typename K > 108 struct Ray <K, Dynamic_dimension_tag> { typedef typename K::Ray_d type; }; 109 110 111 template < typename K > 112 struct Segment <K, Dimension_tag<2> > { typedef typename K::Segment_2 type; }; 113 114 template < typename K > 115 struct Segment <K, Dimension_tag<3> > { typedef typename K::Segment_3 type; }; 116 117 template < typename K > 118 struct Segment <K, Dynamic_dimension_tag> { typedef typename K::Segment_d type; }; 119 120 121 template < typename K > 122 struct Triangle <K, Dimension_tag<2> > { typedef typename K::Triangle_2 type; }; 123 124 template < typename K > 125 struct Triangle <K, Dimension_tag<3> > { typedef typename K::Triangle_3 type; }; 126 127 template < typename K > 128 struct Triangle <K, Dynamic_dimension_tag> { typedef typename K::Triangle_d type; }; 129 130 131 template < typename K > 132 struct Tetrahedron <K, Dimension_tag<3> > { typedef typename K::Tetrahedron_3 type; }; 133 134 template < typename K > 135 struct Tetrahedron <K, Dynamic_dimension_tag> { typedef typename K::Tetrahedron_d type; }; 136 137 138 template < typename K > 139 struct Hypersphere <K, Dimension_tag<2> > { typedef typename K::Circle_2 type; }; 140 141 template < typename K > 142 struct Hypersphere <K, Dimension_tag<3> > { typedef typename K::Sphere_3 type; }; 143 144 template < typename K > 145 struct Hypersphere <K, Dynamic_dimension_tag> { typedef typename K::Sphere_d type; }; 146 147 148 template < typename K > 149 struct Hyperplane <K, Dimension_tag<2> > { typedef typename K::Line_2 type; }; 150 151 template < typename K > 152 struct Hyperplane <K, Dimension_tag<3> > { typedef typename K::Plane_3 type; }; 153 154 template < typename K > 155 struct Hyperplane <K, Dynamic_dimension_tag> { typedef typename K::Hyperplane_d type; }; 156 157 158 template < typename K > 159 struct Aff_transformation <K, Dimension_tag<2> > 160 { typedef typename K::Aff_transformation_2 type; }; 161 162 template < typename K > 163 struct Aff_transformation <K, Dimension_tag<3> > 164 { typedef typename K::Aff_transformation_3 type; }; 165 166 template < typename K > 167 struct Aff_transformation <K, Dynamic_dimension_tag> 168 { typedef typename K::Aff_transformation_d type; }; 169 170 } // namespace Access 171 172 } //namespace CGAL 173 174 #endif // CGAL_KERNEL_DIMENSION_UTILS_H 175