1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | |
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. |
6 | |
7 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library |
8 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. |
9 | |
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) |
13 | |
14 | |
15 | #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP |
16 | #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP |
17 | |
18 | |
19 | #include <boost/concept_check.hpp> |
20 | #include <boost/range/concepts.hpp> |
21 | #include <boost/type_traits/remove_const.hpp> |
22 | |
23 | #include <boost/geometry/core/access.hpp> |
24 | #include <boost/geometry/core/mutable_range.hpp> |
25 | #include <boost/geometry/core/point_type.hpp> |
26 | |
27 | #include <boost/geometry/geometries/concepts/point_concept.hpp> |
28 | |
29 | |
30 | |
31 | namespace boost { namespace geometry { namespace concept |
32 | { |
33 | |
34 | |
35 | /*! |
36 | \brief Linestring concept |
37 | \ingroup concepts |
38 | \par Formal definition: |
39 | The linestring concept is defined as following: |
40 | - there must be a specialization of traits::tag defining linestring_tag as type |
41 | - it must behave like a Boost.Range |
42 | - it must implement a std::back_insert_iterator |
43 | - either by implementing push_back |
44 | - or by specializing std::back_insert_iterator |
45 | |
46 | \note to fulfill the concepts, no traits class has to be specialized to |
47 | define the point type. |
48 | |
49 | \par Example: |
50 | |
51 | A custom linestring, defining the necessary specializations to fulfill to the concept. |
52 | |
53 | Suppose that the following linestring is defined: |
54 | \dontinclude doxygen_5.cpp |
55 | \skip custom_linestring1 |
56 | \until }; |
57 | |
58 | It can then be adapted to the concept as following: |
59 | \dontinclude doxygen_5.cpp |
60 | \skip adapt custom_linestring1 |
61 | \until }} |
62 | |
63 | \note |
64 | - There is also the registration macro BOOST_GEOMETRY_REGISTER_LINESTRING |
65 | - For registration of std::vector<P> (and deque, and list) it is enough to |
66 | include the header-file geometries/adapted/std_as_linestring.hpp. That registers |
67 | a vector as a linestring (so it cannot be registered as a linear ring then, |
68 | in the same source code). |
69 | |
70 | |
71 | */ |
72 | |
73 | template <typename Geometry> |
74 | class Linestring |
75 | { |
76 | #ifndef DOXYGEN_NO_CONCEPT_MEMBERS |
77 | typedef typename point_type<Geometry>::type point_type; |
78 | |
79 | BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) ); |
80 | BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) ); |
81 | |
82 | public : |
83 | |
84 | BOOST_CONCEPT_USAGE(Linestring) |
85 | { |
86 | Geometry* ls = 0; |
87 | traits::clear<Geometry>::apply(*ls); |
88 | traits::resize<Geometry>::apply(*ls, 0); |
89 | point_type* point = 0; |
90 | traits::push_back<Geometry>::apply(*ls, *point); |
91 | } |
92 | #endif |
93 | }; |
94 | |
95 | |
96 | /*! |
97 | \brief Linestring concept (const version) |
98 | \ingroup const_concepts |
99 | \details The ConstLinestring concept check the same as the Linestring concept, |
100 | but does not check write access. |
101 | */ |
102 | template <typename Geometry> |
103 | class ConstLinestring |
104 | { |
105 | #ifndef DOXYGEN_NO_CONCEPT_MEMBERS |
106 | typedef typename point_type<Geometry>::type point_type; |
107 | |
108 | BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) ); |
109 | //BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) ); |
110 | // Relaxed the concept. |
111 | BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept<Geometry>) ); |
112 | |
113 | |
114 | public : |
115 | |
116 | BOOST_CONCEPT_USAGE(ConstLinestring) |
117 | { |
118 | } |
119 | #endif |
120 | }; |
121 | |
122 | }}} // namespace boost::geometry::concept |
123 | |
124 | |
125 | #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP |
126 | |