Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:28

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2020.
0008 // Modifications copyright (c) 2020, Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 
0011 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0012 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0013 
0014 // Use, modification and distribution is subject to the Boost Software License,
0015 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 #ifndef BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP
0019 #define BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP
0020 
0021 #include <cstddef>
0022 #include <type_traits>
0023 
0024 #include <boost/geometry/core/cs.hpp>
0025 #include <boost/geometry/geometries/point.hpp>
0026 
0027 namespace boost { namespace geometry
0028 {
0029 
0030 namespace model { namespace d2
0031 {
0032 
0033 /*!
0034 \brief 2D point in Cartesian coordinate system
0035 \tparam CoordinateType numeric type, for example, double, float, int
0036 \tparam CoordinateSystem coordinate system, defaults to cs::cartesian
0037 
0038 \qbk{[include reference/geometries/point_xy.qbk]}
0039 \qbk{before.synopsis,
0040 [heading Model of]
0041 [link geometry.reference.concepts.concept_point Point Concept]
0042 }
0043 
0044 \qbk{[include reference/geometries/point_assign_warning.qbk]}
0045 
0046 */
0047 template<typename CoordinateType, typename CoordinateSystem = cs::cartesian>
0048 class point_xy : public model::point<CoordinateType, 2, CoordinateSystem>
0049 {
0050 public:
0051     /// \constructor_default_no_init
0052     constexpr point_xy() = default;
0053 
0054     /// Constructor with x/y values
0055     constexpr point_xy(CoordinateType const& x, CoordinateType const& y)
0056         : model::point<CoordinateType, 2, CoordinateSystem>(x, y)
0057     {}
0058 
0059     /// Get x-value
0060     constexpr CoordinateType const& x() const
0061     { return this->template get<0>(); }
0062 
0063     /// Get y-value
0064     constexpr CoordinateType const& y() const
0065     { return this->template get<1>(); }
0066 
0067     /// Set x-value
0068     void x(CoordinateType const& v)
0069     { this->template set<0>(v); }
0070 
0071     /// Set y-value
0072     void y(CoordinateType const& v)
0073     { this->template set<1>(v); }
0074 };
0075 
0076 
0077 }} // namespace model::d2
0078 
0079 
0080 // Adapt the point_xy to the concept
0081 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0082 namespace traits
0083 {
0084 
0085 template <typename CoordinateType, typename CoordinateSystem>
0086 struct tag<model::d2::point_xy<CoordinateType, CoordinateSystem> >
0087 {
0088     typedef point_tag type;
0089 };
0090 
0091 template<typename CoordinateType, typename CoordinateSystem>
0092 struct coordinate_type<model::d2::point_xy<CoordinateType, CoordinateSystem> >
0093 {
0094     typedef CoordinateType type;
0095 };
0096 
0097 template<typename CoordinateType, typename CoordinateSystem>
0098 struct coordinate_system<model::d2::point_xy<CoordinateType, CoordinateSystem> >
0099 {
0100     typedef CoordinateSystem type;
0101 };
0102 
0103 template<typename CoordinateType, typename CoordinateSystem>
0104 struct dimension<model::d2::point_xy<CoordinateType, CoordinateSystem> >
0105     : std::integral_constant<std::size_t, 2>
0106 {};
0107 
0108 template<typename CoordinateType, typename CoordinateSystem, std::size_t Dimension>
0109 struct access<model::d2::point_xy<CoordinateType, CoordinateSystem>, Dimension >
0110 {
0111     static constexpr CoordinateType get(
0112         model::d2::point_xy<CoordinateType, CoordinateSystem> const& p)
0113     {
0114         return p.template get<Dimension>();
0115     }
0116 
0117     static void set(model::d2::point_xy<CoordinateType, CoordinateSystem>& p,
0118         CoordinateType const& value)
0119     {
0120         p.template set<Dimension>(value);
0121     }
0122 };
0123 
0124 template<typename CoordinateType, typename CoordinateSystem>
0125 struct make<model::d2::point_xy<CoordinateType, CoordinateSystem> >
0126 {
0127     typedef model::d2::point_xy<CoordinateType, CoordinateSystem> point_type;
0128 
0129     static const bool is_specialized = true;
0130 
0131     static constexpr point_type apply(CoordinateType const& x,
0132                                       CoordinateType const& y)
0133     {
0134         return point_type(x, y);
0135     }
0136 };
0137 
0138 
0139 } // namespace traits
0140 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0141 
0142 }} // namespace boost::geometry
0143 
0144 #endif // BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP