// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2014, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP #define BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { namespace model { // const or non-const segment type that is meant to be // * default constructible // * copy constructible // * assignable // referring_segment does not fit these requirements, hence the // pointing_segment class // // this class is used by the segment_iterator as its value type template class pointing_segment { BOOST_CONCEPT_ASSERT( ( typename boost::mpl::if_ < boost::is_const, concept::Point, concept::ConstPoint > ) ); typedef ConstOrNonConstPoint point_type; public: point_type* first; point_type* second; inline pointing_segment() : first(NULL) , second(NULL) {} inline pointing_segment(point_type const& p1, point_type const& p2) : first(boost::addressof(p1)) , second(boost::addressof(p2)) {} }; } // namespace model // Traits specializations for segment above #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS namespace traits { template struct tag > { typedef segment_tag type; }; template struct point_type > { typedef Point type; }; template struct indexed_access, 0, Dimension> { typedef model::pointing_segment segment_type; typedef typename geometry::coordinate_type < segment_type >::type coordinate_type; static inline coordinate_type get(segment_type const& s) { BOOST_GEOMETRY_ASSERT( s.first != NULL ); return geometry::get(*s.first); } static inline void set(segment_type& s, coordinate_type const& value) { BOOST_GEOMETRY_ASSERT( s.first != NULL ); geometry::set(*s.first, value); } }; template struct indexed_access, 1, Dimension> { typedef model::pointing_segment segment_type; typedef typename geometry::coordinate_type < segment_type >::type coordinate_type; static inline coordinate_type get(segment_type const& s) { BOOST_GEOMETRY_ASSERT( s.second != NULL ); return geometry::get(*s.second); } static inline void set(segment_type& s, coordinate_type const& value) { BOOST_GEOMETRY_ASSERT( s.second != NULL ); geometry::set(*s.second, value); } }; } // namespace traits #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS }} // namespace boost::geometry #endif // BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP