Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@16
|
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
Chris@16
|
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
Chris@16
|
6
|
Chris@16
|
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@16
|
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@16
|
9
|
Chris@16
|
10 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
12 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
13
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP
|
Chris@16
|
16 #define BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP
|
Chris@16
|
17
|
Chris@16
|
18
|
Chris@16
|
19 #ifndef DOXYGEN_NO_SPECIALIZATIONS
|
Chris@16
|
20
|
Chris@16
|
21
|
Chris@16
|
22 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS(Segment, Point, Index0, Index1) \
|
Chris@16
|
23 template <size_t D> \
|
Chris@16
|
24 struct indexed_access<Segment, min_corner, D> \
|
Chris@16
|
25 { \
|
Chris@16
|
26 typedef typename coordinate_type<Point>::type ct; \
|
Chris@16
|
27 static inline ct get(Segment const& b) \
|
Chris@16
|
28 { return geometry::get<D>(b. Index0); } \
|
Chris@16
|
29 static inline void set(Segment& b, ct const& value) \
|
Chris@16
|
30 { geometry::set<D>(b. Index0, value); } \
|
Chris@16
|
31 }; \
|
Chris@16
|
32 template <size_t D> \
|
Chris@16
|
33 struct indexed_access<Segment, max_corner, D> \
|
Chris@16
|
34 { \
|
Chris@16
|
35 typedef typename coordinate_type<Point>::type ct; \
|
Chris@16
|
36 static inline ct get(Segment const& b) \
|
Chris@16
|
37 { return geometry::get<D>(b. Index1); } \
|
Chris@16
|
38 static inline void set(Segment& b, ct const& value) \
|
Chris@16
|
39 { geometry::set<D>(b. Index1, value); } \
|
Chris@16
|
40 };
|
Chris@16
|
41
|
Chris@16
|
42
|
Chris@16
|
43 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_TEMPLATIZED(Segment, Index0, Index1) \
|
Chris@16
|
44 template <typename P, size_t D> \
|
Chris@16
|
45 struct indexed_access<Segment<P>, min_corner, D> \
|
Chris@16
|
46 { \
|
Chris@16
|
47 typedef typename coordinate_type<P>::type ct; \
|
Chris@16
|
48 static inline ct get(Segment<P> const& b) \
|
Chris@16
|
49 { return geometry::get<D>(b. Index0); } \
|
Chris@16
|
50 static inline void set(Segment<P>& b, ct const& value) \
|
Chris@16
|
51 { geometry::set<D>(b. Index0, value); } \
|
Chris@16
|
52 }; \
|
Chris@16
|
53 template <typename P, size_t D> \
|
Chris@16
|
54 struct indexed_access<Segment<P>, max_corner, D> \
|
Chris@16
|
55 { \
|
Chris@16
|
56 typedef typename coordinate_type<P>::type ct; \
|
Chris@16
|
57 static inline ct get(Segment<P> const& b) \
|
Chris@16
|
58 { return geometry::get<D>(b. Index1); } \
|
Chris@16
|
59 static inline void set(Segment<P>& b, ct const& value) \
|
Chris@16
|
60 { geometry::set<D>(b. Index1, value); } \
|
Chris@16
|
61 };
|
Chris@16
|
62
|
Chris@16
|
63
|
Chris@16
|
64 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_4VALUES(Segment, Point, Left, Bottom, Right, Top) \
|
Chris@16
|
65 template <> struct indexed_access<Segment, min_corner, 0> \
|
Chris@16
|
66 { \
|
Chris@16
|
67 typedef coordinate_type<Point>::type ct; \
|
Chris@16
|
68 static inline ct get(Segment const& b) { return b. Left; } \
|
Chris@16
|
69 static inline void set(Segment& b, ct const& value) { b. Left = value; } \
|
Chris@16
|
70 }; \
|
Chris@16
|
71 template <> struct indexed_access<Segment, min_corner, 1> \
|
Chris@16
|
72 { \
|
Chris@16
|
73 typedef coordinate_type<Point>::type ct; \
|
Chris@16
|
74 static inline ct get(Segment const& b) { return b. Bottom; } \
|
Chris@16
|
75 static inline void set(Segment& b, ct const& value) { b. Bottom = value; } \
|
Chris@16
|
76 }; \
|
Chris@16
|
77 template <> struct indexed_access<Segment, max_corner, 0> \
|
Chris@16
|
78 { \
|
Chris@16
|
79 typedef coordinate_type<Point>::type ct; \
|
Chris@16
|
80 static inline ct get(Segment const& b) { return b. Right; } \
|
Chris@16
|
81 static inline void set(Segment& b, ct const& value) { b. Right = value; } \
|
Chris@16
|
82 }; \
|
Chris@16
|
83 template <> struct indexed_access<Segment, max_corner, 1> \
|
Chris@16
|
84 { \
|
Chris@16
|
85 typedef coordinate_type<Point>::type ct; \
|
Chris@16
|
86 static inline ct get(Segment const& b) { return b. Top; } \
|
Chris@16
|
87 static inline void set(Segment& b, ct const& value) { b. Top = value; } \
|
Chris@16
|
88 };
|
Chris@16
|
89
|
Chris@16
|
90
|
Chris@16
|
91
|
Chris@16
|
92
|
Chris@16
|
93 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \
|
Chris@16
|
94 template<> struct tag<Segment > { typedef segment_tag type; }; \
|
Chris@16
|
95 template<> struct point_type<Segment > { typedef PointType type; };
|
Chris@16
|
96
|
Chris@16
|
97 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS_TEMPLATIZED(Segment) \
|
Chris@16
|
98 template<typename P> struct tag<Segment<P> > { typedef segment_tag type; }; \
|
Chris@16
|
99 template<typename P> struct point_type<Segment<P> > { typedef P type; };
|
Chris@16
|
100
|
Chris@16
|
101 #endif // DOXYGEN_NO_SPECIALIZATIONS
|
Chris@16
|
102
|
Chris@16
|
103
|
Chris@16
|
104
|
Chris@16
|
105 #define BOOST_GEOMETRY_REGISTER_SEGMENT(Segment, PointType, Index0, Index1) \
|
Chris@16
|
106 namespace boost { namespace geometry { namespace traits { \
|
Chris@16
|
107 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \
|
Chris@16
|
108 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS(Segment, PointType, Index0, Index1) \
|
Chris@16
|
109 }}}
|
Chris@16
|
110
|
Chris@16
|
111
|
Chris@16
|
112 #define BOOST_GEOMETRY_REGISTER_SEGMENT_TEMPLATIZED(Segment, Index0, Index1) \
|
Chris@16
|
113 namespace boost { namespace geometry { namespace traits { \
|
Chris@16
|
114 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS_TEMPLATIZED(Segment) \
|
Chris@16
|
115 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_TEMPLATIZED(Segment, Index0, Index1) \
|
Chris@16
|
116 }}}
|
Chris@16
|
117
|
Chris@16
|
118 #define BOOST_GEOMETRY_REGISTER_SEGMENT_2D_4VALUES(Segment, PointType, Left, Bottom, Right, Top) \
|
Chris@16
|
119 namespace boost { namespace geometry { namespace traits { \
|
Chris@16
|
120 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \
|
Chris@16
|
121 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_4VALUES(Segment, PointType, Left, Bottom, Right, Top) \
|
Chris@16
|
122 }}}
|
Chris@16
|
123
|
Chris@16
|
124
|
Chris@16
|
125
|
Chris@16
|
126 // CONST versions are for segments probably not that common. Postponed.
|
Chris@16
|
127
|
Chris@16
|
128
|
Chris@16
|
129 #endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP
|