123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- #ifndef BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP
- #define BOOST_GEOMETRY_GEOMETRIES_POINTING_SEGMENT_HPP
- #include <cstddef>
- #include <type_traits>
- #include <boost/concept/assert.hpp>
- #include <boost/core/addressof.hpp>
- #include <boost/geometry/core/access.hpp>
- #include <boost/geometry/core/assert.hpp>
- #include <boost/geometry/core/coordinate_type.hpp>
- #include <boost/geometry/geometries/concepts/point_concept.hpp>
- namespace boost { namespace geometry
- {
- namespace model
- {
- template <typename ConstOrNonConstPoint>
- class pointing_segment
- {
- BOOST_CONCEPT_ASSERT( (
- typename std::conditional
- <
- std::is_const<ConstOrNonConstPoint>::value,
- concepts::Point<ConstOrNonConstPoint>,
- concepts::ConstPoint<ConstOrNonConstPoint>
- >
- ) );
- 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))
- {}
- };
- }
- #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
- namespace traits
- {
- template <typename Point>
- struct tag<model::pointing_segment<Point> >
- {
- typedef segment_tag type;
- };
- template <typename Point>
- struct point_type<model::pointing_segment<Point> >
- {
- typedef Point type;
- };
- template <typename Point, std::size_t Dimension>
- struct indexed_access<model::pointing_segment<Point>, 0, Dimension>
- {
- typedef model::pointing_segment<Point> 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<Dimension>(*s.first);
- }
- static inline void set(segment_type& s, coordinate_type const& value)
- {
- BOOST_GEOMETRY_ASSERT( s.first != NULL );
- geometry::set<Dimension>(*s.first, value);
- }
- };
- template <typename Point, std::size_t Dimension>
- struct indexed_access<model::pointing_segment<Point>, 1, Dimension>
- {
- typedef model::pointing_segment<Point> 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<Dimension>(*s.second);
- }
- static inline void set(segment_type& s, coordinate_type const& value)
- {
- BOOST_GEOMETRY_ASSERT( s.second != NULL );
- geometry::set<Dimension>(*s.second, value);
- }
- };
- }
- #endif
- }}
- #endif
|