1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
4 // Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2009-2011 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)
14 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP
15 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP
18 #include <boost/concept_check.hpp>
20 #include <boost/geometry/geometries/concepts/point_concept.hpp>
22 #include <boost/geometry/core/access.hpp>
23 #include <boost/geometry/core/point_type.hpp>
26 namespace boost { namespace geometry { namespace concept
31 \brief Segment concept.
33 \details Formal definition:
34 The segment concept is defined as following:
35 - there must be a specialization of traits::tag defining segment_tag as type
36 - there must be a specialization of traits::point_type to define the
37 underlying point type (even if it does not consist of points, it should define
38 this type, to indicate the points it can work with)
39 - there must be a specialization of traits::indexed_access, per index
40 and per dimension, with two functions:
41 - get to get a coordinate value
42 - set to set a coordinate value (this one is not checked for ConstSegment)
44 \note The segment concept is similar to the box concept, defining another tag.
45 However, the box concept assumes the index as min_corner, max_corner, while
46 for the segment concept there is no assumption.
48 template <typename Geometry>
51 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
52 typedef typename point_type<Geometry>::type point_type;
54 BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
57 template <size_t Index, size_t Dimension, size_t DimensionCount>
58 struct dimension_checker
63 geometry::set<Index, Dimension>(*s, geometry::get<Index, Dimension>(*s));
64 dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
68 template <size_t Index, size_t DimensionCount>
69 struct dimension_checker<Index, DimensionCount, DimensionCount>
71 static void apply() {}
76 BOOST_CONCEPT_USAGE(Segment)
78 static const size_t n = dimension<point_type>::type::value;
79 dimension_checker<0, 0, n>::apply();
80 dimension_checker<1, 0, n>::apply();
87 \brief Segment concept (const version).
88 \ingroup const_concepts
89 \details The ConstSegment concept verifies the same as the Segment concept,
90 but does not verify write access.
92 template <typename Geometry>
95 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
96 typedef typename point_type<Geometry>::type point_type;
97 typedef typename coordinate_type<Geometry>::type coordinate_type;
99 BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
102 template <size_t Index, size_t Dimension, size_t DimensionCount>
103 struct dimension_checker
107 const Geometry* s = 0;
108 coordinate_type coord(geometry::get<Index, Dimension>(*s));
109 boost::ignore_unused_variable_warning(coord);
110 dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
114 template <size_t Index, size_t DimensionCount>
115 struct dimension_checker<Index, DimensionCount, DimensionCount>
117 static void apply() {}
122 BOOST_CONCEPT_USAGE(ConstSegment)
124 static const size_t n = dimension<point_type>::type::value;
125 dimension_checker<0, 0, n>::apply();
126 dimension_checker<1, 0, n>::apply();
132 }}} // namespace boost::geometry::concept
135 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP