Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:28

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2014-2020, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Licensed under the Boost Software License version 1.0.
0009 // http://www.boost.org/users/license.html
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 // const or non-const segment type that is meant to be
0033 // * default constructible
0034 // * copy constructible
0035 // * assignable
0036 // referring_segment does not fit these requirements, hence the
0037 // pointing_segment class
0038 //
0039 // this class is used by the segment_iterator as its value type
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 } // namespace model
0071 
0072 
0073 // Traits specializations for segment above
0074 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0075 namespace traits
0076 {
0077 
0078 template <typename Point>
0079 struct tag<model::pointing_segment<Point> >
0080 {
0081     typedef segment_tag type;
0082 };
0083 
0084 template <typename Point>
0085 struct point_type<model::pointing_segment<Point> >
0086 {
0087     typedef Point type;
0088 };
0089 
0090 template <typename Point, std::size_t Dimension>
0091 struct indexed_access<model::pointing_segment<Point>, 0, Dimension>
0092 {
0093     typedef model::pointing_segment<Point> segment_type;
0094     typedef typename geometry::coordinate_type
0095         <
0096             segment_type
0097         >::type coordinate_type;
0098 
0099     static inline coordinate_type get(segment_type const& s)
0100     {
0101         BOOST_GEOMETRY_ASSERT( s.first != NULL );
0102         return geometry::get<Dimension>(*s.first);
0103     }
0104 
0105     static inline void set(segment_type& s, coordinate_type const& value)
0106     {
0107         BOOST_GEOMETRY_ASSERT( s.first != NULL );
0108         geometry::set<Dimension>(*s.first, value);
0109     }
0110 };
0111 
0112 
0113 template <typename Point, std::size_t Dimension>
0114 struct indexed_access<model::pointing_segment<Point>, 1, Dimension>
0115 {
0116     typedef model::pointing_segment<Point> segment_type;
0117     typedef typename geometry::coordinate_type
0118         <
0119             segment_type
0120         >::type coordinate_type;
0121 
0122     static inline coordinate_type get(segment_type const& s)
0123     {
0124         BOOST_GEOMETRY_ASSERT( s.second != NULL );
0125         return geometry::get<Dimension>(*s.second);
0126     }
0127 
0128     static inline void set(segment_type& s, coordinate_type const& value)
0129     {
0130         BOOST_GEOMETRY_ASSERT( s.second != NULL );
0131         geometry::set<Dimension>(*s.second, value);
0132     }
0133 };
0134 
0135 
0136 
0137 } // namespace traits
0138 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0139 
0140 }} // namespace boost::geometry
0141 
0142 #endif // BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP