1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2012 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)
15 #ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP
16 #define BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP
19 #ifndef DOXYGEN_NO_SPECIALIZATIONS
22 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS(Segment, Point, Index0, Index1) \
24 struct indexed_access<Segment, min_corner, D> \
26 typedef typename coordinate_type<Point>::type ct; \
27 static inline ct get(Segment const& b) \
28 { return geometry::get<D>(b. Index0); } \
29 static inline void set(Segment& b, ct const& value) \
30 { geometry::set<D>(b. Index0, value); } \
33 struct indexed_access<Segment, max_corner, D> \
35 typedef typename coordinate_type<Point>::type ct; \
36 static inline ct get(Segment const& b) \
37 { return geometry::get<D>(b. Index1); } \
38 static inline void set(Segment& b, ct const& value) \
39 { geometry::set<D>(b. Index1, value); } \
43 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_TEMPLATIZED(Segment, Index0, Index1) \
44 template <typename P, size_t D> \
45 struct indexed_access<Segment<P>, min_corner, D> \
47 typedef typename coordinate_type<P>::type ct; \
48 static inline ct get(Segment<P> const& b) \
49 { return geometry::get<D>(b. Index0); } \
50 static inline void set(Segment<P>& b, ct const& value) \
51 { geometry::set<D>(b. Index0, value); } \
53 template <typename P, size_t D> \
54 struct indexed_access<Segment<P>, max_corner, D> \
56 typedef typename coordinate_type<P>::type ct; \
57 static inline ct get(Segment<P> const& b) \
58 { return geometry::get<D>(b. Index1); } \
59 static inline void set(Segment<P>& b, ct const& value) \
60 { geometry::set<D>(b. Index1, value); } \
64 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_4VALUES(Segment, Point, Left, Bottom, Right, Top) \
65 template <> struct indexed_access<Segment, min_corner, 0> \
67 typedef coordinate_type<Point>::type ct; \
68 static inline ct get(Segment const& b) { return b. Left; } \
69 static inline void set(Segment& b, ct const& value) { b. Left = value; } \
71 template <> struct indexed_access<Segment, min_corner, 1> \
73 typedef coordinate_type<Point>::type ct; \
74 static inline ct get(Segment const& b) { return b. Bottom; } \
75 static inline void set(Segment& b, ct const& value) { b. Bottom = value; } \
77 template <> struct indexed_access<Segment, max_corner, 0> \
79 typedef coordinate_type<Point>::type ct; \
80 static inline ct get(Segment const& b) { return b. Right; } \
81 static inline void set(Segment& b, ct const& value) { b. Right = value; } \
83 template <> struct indexed_access<Segment, max_corner, 1> \
85 typedef coordinate_type<Point>::type ct; \
86 static inline ct get(Segment const& b) { return b. Top; } \
87 static inline void set(Segment& b, ct const& value) { b. Top = value; } \
93 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \
94 template<> struct tag<Segment > { typedef segment_tag type; }; \
95 template<> struct point_type<Segment > { typedef PointType type; };
97 #define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS_TEMPLATIZED(Segment) \
98 template<typename P> struct tag<Segment<P> > { typedef segment_tag type; }; \
99 template<typename P> struct point_type<Segment<P> > { typedef P type; };
101 #endif // DOXYGEN_NO_SPECIALIZATIONS
105 #define BOOST_GEOMETRY_REGISTER_SEGMENT(Segment, PointType, Index0, Index1) \
106 namespace boost { namespace geometry { namespace traits { \
107 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \
108 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS(Segment, PointType, Index0, Index1) \
112 #define BOOST_GEOMETRY_REGISTER_SEGMENT_TEMPLATIZED(Segment, Index0, Index1) \
113 namespace boost { namespace geometry { namespace traits { \
114 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS_TEMPLATIZED(Segment) \
115 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_TEMPLATIZED(Segment, Index0, Index1) \
118 #define BOOST_GEOMETRY_REGISTER_SEGMENT_2D_4VALUES(Segment, PointType, Left, Bottom, Right, Top) \
119 namespace boost { namespace geometry { namespace traits { \
120 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \
121 BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_4VALUES(Segment, PointType, Left, Bottom, Right, Top) \
126 // CONST versions are for segments probably not that common. Postponed.
129 #endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP