OpenChain.hpp
Go to the documentation of this file.
1 #ifndef _OPEN_CHAIN_HPP_
2 #define _OPEN_CHAIN_HPP_
3 
4 // Copyright (c) 2015 Andrew Hundt, Baltimore, MD
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
6 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
7 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
8 
9 
10 #include <boost/concept_check.hpp>
11 #include <boost/range/concepts.hpp>
12 #include <boost/type_traits/remove_const.hpp>
13 
14 #include <boost/geometry/core/access.hpp>
15 #include <boost/geometry/core/mutable_range.hpp>
16 #include <boost/geometry/core/point_type.hpp>
17 
18 #include <boost/geometry/geometries/concepts/point_concept.hpp>
19 
20 namespace grl { namespace concept {
21 /*!
22 \brief OpenChain concept
23 \ingroup concepts
24 \par Formal definition:
25 The OpenChain concept is defined as following:
26 - there must be a specialization of traits::tag defining linestring_tag as type
27 - it must behave like a Boost.Range
28 - it must implement a std::back_insert_iterator
29  - either by implementing push_back
30  - or by specializing std::back_insert_iterator
31 \note to fulfill the concepts, no traits class has to be specialized to
32 define the joint type.
33 \par Example:
34 A custom linestring, defining the necessary specializations to fulfill to the concept.
35 Suppose that the following linestring is defined:
36 \dontinclude doxygen_5.cpp
37 \skip custom_linestring1
38 \until };
39 It can then be adapted to the concept as following:
40 \dontinclude doxygen_5.cpp
41 \skip adapt custom_linestring1
42 \until }}
43 \note
44 - Open chain refers to a single linear series of states.
45 The best example of this is an open kinematic chain,
46 such as a robot arm consisting of a series of revolute
47 and prismatic joints.
48 - There is also the registration macro BOOST_GEOMETRY_REGISTER_LINESTRING
49 - For registration of std::vector<P> (and deque, and list) it is enough to
50 include the header-file geometries/adapted/std_as_linestring.hpp. That registers
51 a vector as a linestring (so it cannot be registered as a linear ring then,
52 in the same source code).
53 
54 \see Based on Boost.Geometry Linestring concept http://www.boost.org/doc/libs/release/libs/geometry/doc/html/geometry/reference/concepts/concept_linestring.html
55 
56 */
57 class OpenChain {
58 
59 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
60  typedef typename boost::geometry::concept::point_type<Geometry>::type point_type;
61 
62  BOOST_CONCEPT_ASSERT( (boost::geometry::concept::Point<point_type>) );
63  BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
64 
65 public :
66 
67  BOOST_CONCEPT_USAGE(Linestring)
68  {
69  Geometry* ls = 0;
70  traits::clear<Geometry>::apply(*ls);
71  traits::resize<Geometry>::apply(*ls, 0);
72  point_type* point = 0;
73  traits::push_back<Geometry>::apply(*ls, *point);
74  }
75 #endif
76 };
77 
79 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
80  typedef typename boost::geometry::concept::point_type<Geometry>::type point_type;
81 
82  BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
83  //BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
84  // Relaxed the concept.
85  BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept<Geometry>) );
86 
87 
88 public :
89 
90  BOOST_CONCEPT_USAGE(ConstLinestring)
91  {
92  }
93 #endif
94 };
95 
96 }
97 }}
98 #endif
99 
BOOST_CONCEPT_USAGE(Linestring)
Definition: OpenChain.hpp:67
OpenChain concept.
Definition: OpenChain.hpp:57
BOOST_CONCEPT_USAGE(ConstLinestring)
Definition: OpenChain.hpp:90