]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/geometries/point_xyz.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / boost / geometry / geometries / point_xyz.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2020 Digvijay Janartha, Hamirpur, India.
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_POINT_XYZ_HPP
10 #define BOOST_GEOMETRY_GEOMETRIES_POINT_XYZ_HPP
11
12 #include <cstddef>
13
14 #include <boost/config.hpp>
15 #include <boost/mpl/int.hpp>
16
17 #include <boost/geometry/core/cs.hpp>
18 #include <boost/geometry/geometries/point.hpp>
19
20 namespace boost { namespace geometry
21 {
22
23 namespace model { namespace d3
24 {
25
26 /*!
27 \brief 3D point in Cartesian coordinate system
28 \tparam CoordinateType numeric type, for example, double, float, int
29 \tparam CoordinateSystem coordinate system, defaults to cs::cartesian
30
31 \qbk{[include reference/geometries/point_xyz.qbk]}
32 \qbk{before.synopsis,
33 [heading Model of]
34 [link geometry.reference.concepts.concept_point Point Concept]
35 }
36
37 \qbk{[include reference/geometries/point_assign_warning.qbk]}
38
39 */
40 template<typename CoordinateType, typename CoordinateSystem = cs::cartesian>
41 class point_xyz : public model::point<CoordinateType, 3, CoordinateSystem>
42 {
43 public:
44
45 #ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
46 /// \constructor_default_no_init
47 point_xyz() = default;
48 #else
49 /// \constructor_default_no_init
50 inline point_xyz()
51 {}
52 #endif
53
54 /// Constructor with x/y/z values
55 inline point_xyz(CoordinateType const& x, CoordinateType const& y, CoordinateType const& z)
56 : model::point<CoordinateType, 3, CoordinateSystem>(x, y, z)
57 {}
58
59 /// Get x-value
60 inline CoordinateType const& x() const
61 { return this->template get<0>(); }
62
63 /// Get y-value
64 inline CoordinateType const& y() const
65 { return this->template get<1>(); }
66
67 /// Get z-value
68 inline CoordinateType const& z() const
69 { return this->template get<2>(); }
70
71 /// Set x-value
72 inline void x(CoordinateType const& v)
73 { this->template set<0>(v); }
74
75 /// Set y-value
76 inline void y(CoordinateType const& v)
77 { this->template set<1>(v); }
78
79 /// Set z-value
80 inline void z(CoordinateType const& v)
81 { this->template set<2>(v); }
82 };
83
84
85 }} // namespace model::d3
86
87
88 // Adapt the point_xyz to the concept
89 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
90 namespace traits
91 {
92
93 template <typename CoordinateType, typename CoordinateSystem>
94 struct tag<model::d3::point_xyz<CoordinateType, CoordinateSystem> >
95 {
96 typedef point_tag type;
97 };
98
99 template<typename CoordinateType, typename CoordinateSystem>
100 struct coordinate_type<model::d3::point_xyz<CoordinateType, CoordinateSystem> >
101 {
102 typedef CoordinateType type;
103 };
104
105 template<typename CoordinateType, typename CoordinateSystem>
106 struct coordinate_system<model::d3::point_xyz<CoordinateType, CoordinateSystem> >
107 {
108 typedef CoordinateSystem type;
109 };
110
111 template<typename CoordinateType, typename CoordinateSystem>
112 struct dimension<model::d3::point_xyz<CoordinateType, CoordinateSystem> >
113 : boost::mpl::int_<3>
114 {};
115
116 template<typename CoordinateType, typename CoordinateSystem, std::size_t Dimension>
117 struct access<model::d3::point_xyz<CoordinateType, CoordinateSystem>, Dimension >
118 {
119 static inline CoordinateType get(
120 model::d3::point_xyz<CoordinateType, CoordinateSystem> const& p)
121 {
122 return p.template get<Dimension>();
123 }
124
125 static inline void set(model::d3::point_xyz<CoordinateType, CoordinateSystem>& p,
126 CoordinateType const& value)
127 {
128 p.template set<Dimension>(value);
129 }
130 };
131
132 } // namespace traits
133 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
134
135 }} // namespace boost::geometry
136
137 #endif // BOOST_GEOMETRY_GEOMETRIES_POINT_XYZ_HPP