1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2020 Digvijay Janartha, Hamirpur, India.
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)
9 #ifndef BOOST_GEOMETRY_GEOMETRIES_POINT_XYZ_HPP
10 #define BOOST_GEOMETRY_GEOMETRIES_POINT_XYZ_HPP
14 #include <boost/config.hpp>
15 #include <boost/mpl/int.hpp>
17 #include <boost/geometry/core/cs.hpp>
18 #include <boost/geometry/geometries/point.hpp>
20 namespace boost { namespace geometry
23 namespace model { namespace d3
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
31 \qbk{[include reference/geometries/point_xyz.qbk]}
34 [link geometry.reference.concepts.concept_point Point Concept]
37 \qbk{[include reference/geometries/point_assign_warning.qbk]}
40 template<typename CoordinateType, typename CoordinateSystem = cs::cartesian>
41 class point_xyz : public model::point<CoordinateType, 3, CoordinateSystem>
45 #ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
46 /// \constructor_default_no_init
47 point_xyz() = default;
49 /// \constructor_default_no_init
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)
60 inline CoordinateType const& x() const
61 { return this->template get<0>(); }
64 inline CoordinateType const& y() const
65 { return this->template get<1>(); }
68 inline CoordinateType const& z() const
69 { return this->template get<2>(); }
72 inline void x(CoordinateType const& v)
73 { this->template set<0>(v); }
76 inline void y(CoordinateType const& v)
77 { this->template set<1>(v); }
80 inline void z(CoordinateType const& v)
81 { this->template set<2>(v); }
85 }} // namespace model::d3
88 // Adapt the point_xyz to the concept
89 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
93 template <typename CoordinateType, typename CoordinateSystem>
94 struct tag<model::d3::point_xyz<CoordinateType, CoordinateSystem> >
96 typedef point_tag type;
99 template<typename CoordinateType, typename CoordinateSystem>
100 struct coordinate_type<model::d3::point_xyz<CoordinateType, CoordinateSystem> >
102 typedef CoordinateType type;
105 template<typename CoordinateType, typename CoordinateSystem>
106 struct coordinate_system<model::d3::point_xyz<CoordinateType, CoordinateSystem> >
108 typedef CoordinateSystem type;
111 template<typename CoordinateType, typename CoordinateSystem>
112 struct dimension<model::d3::point_xyz<CoordinateType, CoordinateSystem> >
113 : boost::mpl::int_<3>
116 template<typename CoordinateType, typename CoordinateSystem, std::size_t Dimension>
117 struct access<model::d3::point_xyz<CoordinateType, CoordinateSystem>, Dimension >
119 static inline CoordinateType get(
120 model::d3::point_xyz<CoordinateType, CoordinateSystem> const& p)
122 return p.template get<Dimension>();
125 static inline void set(model::d3::point_xyz<CoordinateType, CoordinateSystem>& p,
126 CoordinateType const& value)
128 p.template set<Dimension>(value);
132 } // namespace traits
133 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
135 }} // namespace boost::geometry
137 #endif // BOOST_GEOMETRY_GEOMETRIES_POINT_XYZ_HPP