1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
16 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
21 #include <boost/concept_check.hpp>
24 #include <boost/geometry/core/access.hpp>
25 #include <boost/geometry/core/coordinate_dimension.hpp>
26 #include <boost/geometry/core/point_type.hpp>
29 namespace boost { namespace geometry { namespace concepts
36 \par Formal definition:
37 The box concept is defined as following:
38 - there must be a specialization of traits::tag defining box_tag as type
39 - there must be a specialization of traits::point_type to define the
40 underlying point type (even if it does not consist of points, it should define
41 this type, to indicate the points it can work with)
42 - there must be a specialization of traits::indexed_access, per index
43 (min_corner, max_corner) and per dimension, with two functions:
44 - get to get a coordinate value
45 - set to set a coordinate value (this one is not checked for ConstBox)
47 template <typename Geometry>
50 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
51 typedef typename point_type<Geometry>::type point_type;
57 std::size_t Dimension,
58 std::size_t DimensionCount
60 struct dimension_checker
65 geometry::set<Index, Dimension>(*b, geometry::get<Index, Dimension>(*b));
66 dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
70 template <std::size_t Index, std::size_t DimensionCount>
71 struct dimension_checker<Index, DimensionCount, DimensionCount>
73 static void apply() {}
77 BOOST_CONCEPT_USAGE(Box)
79 static const std::size_t n = dimension<Geometry>::type::value;
80 dimension_checker<min_corner, 0, n>::apply();
81 dimension_checker<max_corner, 0, n>::apply();
88 \brief Box concept (const version)
89 \ingroup const_concepts
90 \details The ConstBox concept apply the same as the Box concept,
91 but does not apply write access.
93 template <typename Geometry>
96 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
97 typedef typename point_type<Geometry>::type point_type;
98 typedef typename coordinate_type<Geometry>::type coordinate_type;
103 std::size_t Dimension,
104 std::size_t DimensionCount
106 struct dimension_checker
110 const Geometry* b = 0;
111 coordinate_type coord(geometry::get<Index, Dimension>(*b));
112 boost::ignore_unused_variable_warning(coord);
113 dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
117 template <std::size_t Index, std::size_t DimensionCount>
118 struct dimension_checker<Index, DimensionCount, DimensionCount>
120 static void apply() {}
124 BOOST_CONCEPT_USAGE(ConstBox)
126 static const std::size_t n = dimension<Geometry>::type::value;
127 dimension_checker<min_corner, 0, n>::apply();
128 dimension_checker<max_corner, 0, n>::apply();
133 }}} // namespace boost::geometry::concepts
136 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP