Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: Chris@16: // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@16: // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. Chris@16: // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. Chris@16: Chris@16: // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library Chris@16: // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP Chris@16: #define BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace geometry Chris@16: { Chris@16: Chris@16: namespace model { namespace d2 Chris@16: { Chris@16: Chris@16: /*! Chris@16: \brief 2D point in Cartesian coordinate system Chris@16: \tparam CoordinateType numeric type, for example, double, float, int Chris@16: \tparam CoordinateSystem coordinate system, defaults to cs::cartesian Chris@16: Chris@16: \qbk{before.synopsis, Chris@16: [heading Model of] Chris@16: [link geometry.reference.concepts.concept_point Point Concept] Chris@16: } Chris@16: Chris@16: \qbk{[include reference/geometries/point_assign_warning.qbk]} Chris@16: Chris@16: */ Chris@16: template Chris@16: class point_xy : public model::point Chris@16: { Chris@16: public: Chris@16: Chris@16: /// Default constructor, does not initialize anything Chris@16: inline point_xy() Chris@16: : model::point() Chris@16: {} Chris@16: Chris@16: /// Constructor with x/y values Chris@16: inline point_xy(CoordinateType const& x, CoordinateType const& y) Chris@16: : model::point(x, y) Chris@16: {} Chris@16: Chris@16: /// Get x-value Chris@16: inline CoordinateType const& x() const Chris@16: { return this->template get<0>(); } Chris@16: Chris@16: /// Get y-value Chris@16: inline CoordinateType const& y() const Chris@16: { return this->template get<1>(); } Chris@16: Chris@16: /// Set x-value Chris@16: inline void x(CoordinateType const& v) Chris@16: { this->template set<0>(v); } Chris@16: Chris@16: /// Set y-value Chris@16: inline void y(CoordinateType const& v) Chris@16: { this->template set<1>(v); } Chris@16: }; Chris@16: Chris@16: Chris@16: }} // namespace model::d2 Chris@16: Chris@16: Chris@16: // Adapt the point_xy to the concept Chris@16: #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@16: namespace traits Chris@16: { Chris@16: Chris@16: template Chris@16: struct tag > Chris@16: { Chris@16: typedef point_tag type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct coordinate_type > Chris@16: { Chris@16: typedef CoordinateType type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct coordinate_system > Chris@16: { Chris@16: typedef CoordinateSystem type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct dimension > Chris@16: : boost::mpl::int_<2> Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct access, Dimension > Chris@16: { Chris@16: static inline CoordinateType get( Chris@16: model::d2::point_xy const& p) Chris@16: { Chris@16: return p.template get(); Chris@16: } Chris@16: Chris@16: static inline void set(model::d2::point_xy& p, Chris@16: CoordinateType const& value) Chris@16: { Chris@16: p.template set(value); Chris@16: } Chris@16: }; Chris@16: Chris@16: } // namespace traits Chris@16: #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@16: Chris@16: }} // namespace boost::geometry Chris@16: Chris@16: #endif // BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP