annotate DEPENDENCIES/generic/include/boost/geometry/geometries/pointing_segment.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@102 2
Chris@102 3 // Copyright (c) 2014, Oracle and/or its affiliates.
Chris@102 4
Chris@102 5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
Chris@102 6
Chris@102 7 // Licensed under the Boost Software License version 1.0.
Chris@102 8 // http://www.boost.org/users/license.html
Chris@102 9
Chris@102 10 #ifndef BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP
Chris@102 11 #define BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP
Chris@102 12
Chris@102 13 #include <cstddef>
Chris@102 14
Chris@102 15 #include <boost/assert.hpp>
Chris@102 16 #include <boost/concept/assert.hpp>
Chris@102 17 #include <boost/core/addressof.hpp>
Chris@102 18 #include <boost/mpl/if.hpp>
Chris@102 19 #include <boost/type_traits/is_const.hpp>
Chris@102 20
Chris@102 21 #include <boost/geometry/geometries/concepts/point_concept.hpp>
Chris@102 22
Chris@102 23 #include <boost/geometry/core/access.hpp>
Chris@102 24 #include <boost/geometry/core/coordinate_type.hpp>
Chris@102 25
Chris@102 26
Chris@102 27 namespace boost { namespace geometry
Chris@102 28 {
Chris@102 29
Chris@102 30 namespace model
Chris@102 31 {
Chris@102 32
Chris@102 33 // const or non-const segment type that is meant to be
Chris@102 34 // * default constructible
Chris@102 35 // * copy constructible
Chris@102 36 // * assignable
Chris@102 37 // referring_segment does not fit these requirements, hence the
Chris@102 38 // pointing_segment class
Chris@102 39 //
Chris@102 40 // this class is used by the segment_iterator as its value type
Chris@102 41 template <typename ConstOrNonConstPoint>
Chris@102 42 class pointing_segment
Chris@102 43 {
Chris@102 44 BOOST_CONCEPT_ASSERT( (
Chris@102 45 typename boost::mpl::if_
Chris@102 46 <
Chris@102 47 boost::is_const<ConstOrNonConstPoint>,
Chris@102 48 concept::Point<ConstOrNonConstPoint>,
Chris@102 49 concept::ConstPoint<ConstOrNonConstPoint>
Chris@102 50 >
Chris@102 51 ) );
Chris@102 52
Chris@102 53 typedef ConstOrNonConstPoint point_type;
Chris@102 54
Chris@102 55 public:
Chris@102 56 point_type* first;
Chris@102 57 point_type* second;
Chris@102 58
Chris@102 59 inline pointing_segment()
Chris@102 60 : first(NULL)
Chris@102 61 , second(NULL)
Chris@102 62 {}
Chris@102 63
Chris@102 64 inline pointing_segment(point_type const& p1, point_type const& p2)
Chris@102 65 : first(boost::addressof(p1))
Chris@102 66 , second(boost::addressof(p2))
Chris@102 67 {}
Chris@102 68 };
Chris@102 69
Chris@102 70
Chris@102 71 } // namespace model
Chris@102 72
Chris@102 73
Chris@102 74 // Traits specializations for segment above
Chris@102 75 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@102 76 namespace traits
Chris@102 77 {
Chris@102 78
Chris@102 79 template <typename Point>
Chris@102 80 struct tag<model::pointing_segment<Point> >
Chris@102 81 {
Chris@102 82 typedef segment_tag type;
Chris@102 83 };
Chris@102 84
Chris@102 85 template <typename Point>
Chris@102 86 struct point_type<model::pointing_segment<Point> >
Chris@102 87 {
Chris@102 88 typedef Point type;
Chris@102 89 };
Chris@102 90
Chris@102 91 template <typename Point, std::size_t Dimension>
Chris@102 92 struct indexed_access<model::pointing_segment<Point>, 0, Dimension>
Chris@102 93 {
Chris@102 94 typedef model::pointing_segment<Point> segment_type;
Chris@102 95 typedef typename geometry::coordinate_type
Chris@102 96 <
Chris@102 97 segment_type
Chris@102 98 >::type coordinate_type;
Chris@102 99
Chris@102 100 static inline coordinate_type get(segment_type const& s)
Chris@102 101 {
Chris@102 102 BOOST_ASSERT( s.first != NULL );
Chris@102 103 return geometry::get<Dimension>(*s.first);
Chris@102 104 }
Chris@102 105
Chris@102 106 static inline void set(segment_type& s, coordinate_type const& value)
Chris@102 107 {
Chris@102 108 BOOST_ASSERT( s.first != NULL );
Chris@102 109 geometry::set<Dimension>(*s.first, value);
Chris@102 110 }
Chris@102 111 };
Chris@102 112
Chris@102 113
Chris@102 114 template <typename Point, std::size_t Dimension>
Chris@102 115 struct indexed_access<model::pointing_segment<Point>, 1, Dimension>
Chris@102 116 {
Chris@102 117 typedef model::pointing_segment<Point> segment_type;
Chris@102 118 typedef typename geometry::coordinate_type
Chris@102 119 <
Chris@102 120 segment_type
Chris@102 121 >::type coordinate_type;
Chris@102 122
Chris@102 123 static inline coordinate_type get(segment_type const& s)
Chris@102 124 {
Chris@102 125 BOOST_ASSERT( s.second != NULL );
Chris@102 126 return geometry::get<Dimension>(*s.second);
Chris@102 127 }
Chris@102 128
Chris@102 129 static inline void set(segment_type& s, coordinate_type const& value)
Chris@102 130 {
Chris@102 131 BOOST_ASSERT( s.second != NULL );
Chris@102 132 geometry::set<Dimension>(*s.second, value);
Chris@102 133 }
Chris@102 134 };
Chris@102 135
Chris@102 136
Chris@102 137
Chris@102 138 } // namespace traits
Chris@102 139 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@102 140
Chris@102 141 }} // namespace boost::geometry
Chris@102 142
Chris@102 143 #endif // BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP