File indexing completed on 2025-09-17 08:30:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP
0012 #define BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP
0013
0014 #include <cstddef>
0015 #include <type_traits>
0016
0017 #include <boost/concept/assert.hpp>
0018 #include <boost/core/addressof.hpp>
0019
0020 #include <boost/geometry/core/access.hpp>
0021 #include <boost/geometry/core/assert.hpp>
0022 #include <boost/geometry/core/coordinate_type.hpp>
0023
0024 #include <boost/geometry/geometries/concepts/point_concept.hpp>
0025
0026 namespace boost { namespace geometry
0027 {
0028
0029 namespace model
0030 {
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 template <typename ConstOrNonConstPoint>
0041 class pointing_segment
0042 {
0043 BOOST_CONCEPT_ASSERT( (
0044 typename std::conditional
0045 <
0046 std::is_const<ConstOrNonConstPoint>::value,
0047 concepts::Point<ConstOrNonConstPoint>,
0048 concepts::ConstPoint<ConstOrNonConstPoint>
0049 >
0050 ) );
0051
0052 typedef ConstOrNonConstPoint point_type;
0053
0054 public:
0055 point_type* first;
0056 point_type* second;
0057
0058 inline pointing_segment()
0059 : first(NULL)
0060 , second(NULL)
0061 {}
0062
0063 inline pointing_segment(point_type const& p1, point_type const& p2)
0064 : first(boost::addressof(p1))
0065 , second(boost::addressof(p2))
0066 {}
0067 };
0068
0069
0070 }
0071
0072
0073
0074 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0075 namespace traits
0076 {
0077
0078 template <typename Point>
0079 struct tag<model::pointing_segment<Point> >
0080 {
0081 using type = segment_tag;
0082 };
0083
0084 template <typename Point>
0085 struct point_type<model::pointing_segment<Point> >
0086 {
0087 using type = Point;
0088 };
0089
0090 template <typename Point, std::size_t Dimension>
0091 struct indexed_access<model::pointing_segment<Point>, 0, Dimension>
0092 {
0093 using segment_type = model::pointing_segment<Point>;
0094 using coordinate_type = geometry::coordinate_type_t<segment_type>;
0095
0096 static inline coordinate_type get(segment_type const& s)
0097 {
0098 BOOST_GEOMETRY_ASSERT( s.first != NULL );
0099 return geometry::get<Dimension>(*s.first);
0100 }
0101
0102 static inline void set(segment_type& s, coordinate_type const& value)
0103 {
0104 BOOST_GEOMETRY_ASSERT( s.first != NULL );
0105 geometry::set<Dimension>(*s.first, value);
0106 }
0107 };
0108
0109
0110 template <typename Point, std::size_t Dimension>
0111 struct indexed_access<model::pointing_segment<Point>, 1, Dimension>
0112 {
0113 using segment_type = model::pointing_segment<Point>;
0114 using coordinate_type = geometry::coordinate_type_t<segment_type>;
0115
0116 static inline coordinate_type get(segment_type const& s)
0117 {
0118 BOOST_GEOMETRY_ASSERT( s.second != NULL );
0119 return geometry::get<Dimension>(*s.second);
0120 }
0121
0122 static inline void set(segment_type& s, coordinate_type const& value)
0123 {
0124 BOOST_GEOMETRY_ASSERT( s.second != NULL );
0125 geometry::set<Dimension>(*s.second, value);
0126 }
0127 };
0128
0129
0130
0131 }
0132 #endif
0133
0134 }}
0135
0136 #endif