File indexing completed on 2025-01-18 09:36:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_VIEWS_DETAIL_TWO_DIMENSIONAL_VIEW_HPP
0012 #define BOOST_GEOMETRY_VIEWS_DETAIL_TWO_DIMENSIONAL_VIEW_HPP
0013
0014 #include <cstddef>
0015
0016 #include <boost/geometry/core/access.hpp>
0017 #include <boost/geometry/core/coordinate_type.hpp>
0018 #include <boost/geometry/core/coordinate_system.hpp>
0019 #include <boost/geometry/core/coordinate_dimension.hpp>
0020 #include <boost/geometry/core/point_type.hpp>
0021 #include <boost/geometry/core/static_assert.hpp>
0022 #include <boost/geometry/core/tag.hpp>
0023 #include <boost/geometry/core/tags.hpp>
0024
0025 #include <boost/geometry/algorithms/not_implemented.hpp>
0026
0027
0028 namespace boost { namespace geometry
0029 {
0030
0031 #ifndef DOXYGEN_NO_DETAIL
0032 namespace detail
0033 {
0034
0035 template
0036 <
0037 typename Geometry,
0038 std::size_t Dimension1 = 0,
0039 std::size_t Dimension2 = 1,
0040 typename Tag = typename tag<Geometry>::type
0041 >
0042 struct two_dimensional_view
0043 : not_implemented<Tag>
0044 {};
0045
0046
0047
0048
0049 template <typename Point, std::size_t Dimension1, std::size_t Dimension2>
0050 struct two_dimensional_view<Point, Dimension1, Dimension2, point_tag>
0051 {
0052 BOOST_GEOMETRY_STATIC_ASSERT(
0053 (Dimension1 < dimension<Point>::value),
0054 "Coordinate Dimension1 is larger than Point's dimension.",
0055 std::integral_constant<std::size_t, Dimension1>);
0056
0057 BOOST_GEOMETRY_STATIC_ASSERT(
0058 (Dimension2 < dimension<Point>::value),
0059 "Coordinate Dimension2 is larger than Point's dimension.",
0060 std::integral_constant<std::size_t, Dimension2>);
0061
0062 two_dimensional_view(Point& point)
0063 : m_point(point)
0064 {}
0065
0066 Point& m_point;
0067 };
0068
0069
0070 }
0071 #endif
0072
0073
0074 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0075 namespace traits
0076 {
0077
0078
0079 template <typename Point, std::size_t Dimension1, std::size_t Dimension2>
0080 struct tag
0081 <
0082 geometry::detail::two_dimensional_view
0083 <
0084 Point, Dimension1, Dimension2, point_tag
0085 >
0086 >
0087 {
0088 typedef point_tag type;
0089 };
0090
0091 template <typename Point, std::size_t Dimension1, std::size_t Dimension2>
0092 struct coordinate_system
0093 <
0094 geometry::detail::two_dimensional_view
0095 <
0096 Point, Dimension1, Dimension2, point_tag
0097 >
0098 > : coordinate_system<typename geometry::point_type<Point>::type>
0099 {};
0100
0101 template <typename Point, std::size_t Dimension1, std::size_t Dimension2>
0102 struct coordinate_type
0103 <
0104 geometry::detail::two_dimensional_view
0105 <
0106 Point, Dimension1, Dimension2, point_tag
0107 >
0108 > : coordinate_type<typename geometry::point_type<Point>::type>
0109 {};
0110
0111 template <typename Point, std::size_t Dimension1, std::size_t Dimension2>
0112 struct dimension
0113 <
0114 geometry::detail::two_dimensional_view
0115 <
0116 Point, Dimension1, Dimension2, point_tag
0117 >
0118 > : std::integral_constant<std::size_t, 2>
0119 {};
0120
0121 template <typename Point, std::size_t Dimension1, std::size_t Dimension2>
0122 struct point_type
0123 <
0124 geometry::detail::two_dimensional_view
0125 <
0126 Point, Dimension1, Dimension2, point_tag
0127 >
0128 >
0129 {
0130 typedef typename geometry::point_type<Point>::type type;
0131 };
0132
0133
0134 template <typename Point, std::size_t Dimension1, std::size_t Dimension2>
0135 struct access
0136 <
0137 geometry::detail::two_dimensional_view
0138 <
0139 Point, Dimension1, Dimension2, point_tag
0140 >,
0141 0
0142 >
0143 {
0144 typedef typename geometry::coordinate_type<Point>::type coordinate_type;
0145 typedef geometry::detail::two_dimensional_view
0146 <
0147 Point, Dimension1, Dimension2, point_tag
0148 > view_type;
0149
0150 static inline coordinate_type get(view_type const& view)
0151 {
0152 return geometry::get<Dimension1>(view.m_point);
0153 }
0154
0155 static inline void set(view_type& view, coordinate_type const& value)
0156 {
0157 geometry::set<Dimension1>(view.m_point, value);
0158 }
0159 };
0160
0161 template <typename Point, std::size_t Dimension1, std::size_t Dimension2>
0162 struct access
0163 <
0164 geometry::detail::two_dimensional_view
0165 <
0166 Point, Dimension1, Dimension2, point_tag
0167 >,
0168 1
0169 >
0170 {
0171 typedef typename geometry::coordinate_type<Point>::type coordinate_type;
0172 typedef geometry::detail::two_dimensional_view
0173 <
0174 Point, Dimension1, Dimension2, point_tag
0175 > view_type;
0176
0177 static inline coordinate_type get(view_type const& view)
0178 {
0179 return geometry::get<Dimension2>(view.m_point);
0180 }
0181
0182 static inline void set(view_type& view, coordinate_type const& value)
0183 {
0184 geometry::set<Dimension2>(view.m_point, value);
0185 }
0186 };
0187
0188
0189 }
0190 #endif
0191
0192 }}
0193
0194
0195 #endif