1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. 4 5 // Use, modification and distribution is subject to the Boost Software License, 6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 9 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP 10 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP 11 12 // Adapts Geometries from Boost.Polygon for usage in Boost.Geometry 13 // boost::polygon::point_data -> boost::geometry::point 14 15 16 #include <boost/polygon/polygon.hpp> 17 18 #include <boost/geometry/core/access.hpp> 19 #include <boost/geometry/core/cs.hpp> 20 #include <boost/geometry/core/coordinate_dimension.hpp> 21 #include <boost/geometry/core/coordinate_type.hpp> 22 #include <boost/geometry/core/tags.hpp> 23 24 25 namespace boost { namespace geometry 26 { 27 28 29 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS 30 namespace traits 31 { 32 33 34 template <typename CoordinateType> 35 struct tag<boost::polygon::point_data<CoordinateType> > 36 { 37 typedef point_tag type; 38 }; 39 40 41 template <typename CoordinateType> 42 struct coordinate_type<boost::polygon::point_data<CoordinateType> > 43 { 44 typedef CoordinateType type; 45 }; 46 47 48 template <typename CoordinateType> 49 struct coordinate_system<boost::polygon::point_data<CoordinateType> > 50 { 51 typedef cs::cartesian type; 52 }; 53 54 55 template <typename CoordinateType> 56 struct dimension<boost::polygon::point_data<CoordinateType> > 57 : boost::mpl::int_<2> 58 {}; 59 60 61 template <typename CoordinateType> 62 struct access<boost::polygon::point_data<CoordinateType>, 0> 63 { 64 typedef boost::polygon::point_data<CoordinateType> point_type; 65 getboost::geometry::traits::access66 static inline CoordinateType get(point_type const& p) 67 { 68 return p.x(); 69 } 70 setboost::geometry::traits::access71 static inline void set(point_type& p, CoordinateType const& value) 72 { 73 p.x(value); 74 } 75 }; 76 77 78 template <typename CoordinateType> 79 struct access<boost::polygon::point_data<CoordinateType>, 1> 80 { 81 typedef boost::polygon::point_data<CoordinateType> point_type; 82 getboost::geometry::traits::access83 static inline CoordinateType get(point_type const& p) 84 { 85 return p.y(); 86 } 87 setboost::geometry::traits::access88 static inline void set(point_type& p, CoordinateType const& value) 89 { 90 p.y(value); 91 } 92 }; 93 94 95 } // namespace traits 96 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS 97 98 99 }} // namespace boost::geometry 100 101 102 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP 103