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 // This file was modified by Oracle on 2021.
8 // Modifications copyright (c) 2021 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
12 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
14 // Use, modification and distribution is subject to the Boost Software License,
15 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
16 // http://www.boost.org/LICENSE_1_0.txt)
18 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP
19 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP
22 #include <boost/concept_check.hpp>
23 #include <boost/core/ignore_unused.hpp>
25 #include <boost/geometry/core/access.hpp>
26 #include <boost/geometry/core/point_type.hpp>
28 #include <boost/geometry/geometries/concepts/concept_type.hpp>
29 #include <boost/geometry/geometries/concepts/point_concept.hpp>
32 namespace boost { namespace geometry { namespace concepts
37 \brief Segment concept.
39 \details Formal definition:
40 The segment concept is defined as following:
41 - there must be a specialization of traits::tag defining segment_tag as type
42 - there must be a specialization of traits::point_type to define the
43 underlying point type (even if it does not consist of points, it should define
44 this type, to indicate the points it can work with)
45 - there must be a specialization of traits::indexed_access, per index
46 and per dimension, with two functions:
47 - get to get a coordinate value
48 - set to set a coordinate value (this one is not checked for ConstSegment)
50 \note The segment concept is similar to the box concept, defining another tag.
51 However, the box concept assumes the index as min_corner, max_corner, while
52 for the segment concept there is no assumption.
54 template <typename Geometry>
57 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
58 typedef typename point_type<Geometry>::type point_type;
60 BOOST_CONCEPT_ASSERT( (concepts::Point<point_type>) );
63 template <size_t Index, size_t Dimension, size_t DimensionCount>
64 struct dimension_checker
69 geometry::set<Index, Dimension>(*s, geometry::get<Index, Dimension>(*s));
70 dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
74 template <size_t Index, size_t DimensionCount>
75 struct dimension_checker<Index, DimensionCount, DimensionCount>
77 static void apply() {}
82 BOOST_CONCEPT_USAGE(Segment)
84 static const size_t n = dimension<point_type>::type::value;
85 dimension_checker<0, 0, n>::apply();
86 dimension_checker<1, 0, n>::apply();
93 \brief Segment concept (const version).
94 \ingroup const_concepts
95 \details The ConstSegment concept verifies the same as the Segment concept,
96 but does not verify write access.
98 template <typename Geometry>
101 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
102 typedef typename point_type<Geometry>::type point_type;
103 typedef typename coordinate_type<Geometry>::type coordinate_type;
105 BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point_type>) );
108 template <size_t Index, size_t Dimension, size_t DimensionCount>
109 struct dimension_checker
113 const Geometry* s = 0;
114 coordinate_type coord(geometry::get<Index, Dimension>(*s));
115 boost::ignore_unused(coord);
116 dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
120 template <size_t Index, size_t DimensionCount>
121 struct dimension_checker<Index, DimensionCount, DimensionCount>
123 static void apply() {}
128 BOOST_CONCEPT_USAGE(ConstSegment)
130 static const size_t n = dimension<point_type>::type::value;
131 dimension_checker<0, 0, n>::apply();
132 dimension_checker<1, 0, n>::apply();
138 template <typename Geometry>
139 struct concept_type<Geometry, segment_tag>
141 using type = Segment<Geometry>;
144 template <typename Geometry>
145 struct concept_type<Geometry const, segment_tag>
147 using type = ConstSegment<Geometry>;
151 }}} // namespace boost::geometry::concepts
154 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP