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