| 1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
| 2 | // Unit Test |
| 3 | |
| 4 | // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. |
| 5 | // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. |
| 6 | |
| 7 | // This file was modified by Oracle on 2021. |
| 8 | // Modifications copyright (c) 2021 Oracle and/or its affiliates. |
| 9 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle |
| 10 | |
| 11 | // Use, modification and distribution is subject to the Boost Software License, |
| 12 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 13 | // http://www.boost.org/LICENSE_1_0.txt) |
| 14 | |
| 15 | |
| 16 | #ifndef GEOMETRY_TEST_TEST_COMMON_TEST_POINT_HPP |
| 17 | #define GEOMETRY_TEST_TEST_COMMON_TEST_POINT_HPP |
| 18 | |
| 19 | #include <boost/geometry/core/access.hpp> |
| 20 | #include <boost/geometry/core/coordinate_type.hpp> |
| 21 | #include <boost/geometry/core/coordinate_system.hpp> |
| 22 | #include <boost/geometry/core/coordinate_dimension.hpp> |
| 23 | #include <boost/geometry/core/cs.hpp> |
| 24 | #include <boost/geometry/core/tag.hpp> |
| 25 | #include <boost/geometry/geometries/register/point.hpp> |
| 26 | |
| 27 | // NOTE: since Boost 1.51 the Point type may always be a pointer. |
| 28 | // Therefore the traits class don't need to add a pointer. |
| 29 | // This obsoletes this whole test-point-type |
| 30 | |
| 31 | namespace test |
| 32 | { |
| 33 | |
| 34 | // Test point class |
| 35 | |
| 36 | struct test_point |
| 37 | { |
| 38 | float c1, c2, c3; |
| 39 | }; |
| 40 | |
| 41 | struct test_const_point |
| 42 | { |
| 43 | test_const_point() |
| 44 | : c1(0.0), c2(0.0), c3(0.0) { } |
| 45 | |
| 46 | test_const_point(float c1, float c2, float c3) |
| 47 | : c1(c1), c2(c2), c3(c3) { } |
| 48 | |
| 49 | const float c1, c2, c3; |
| 50 | }; |
| 51 | |
| 52 | } // namespace test |
| 53 | |
| 54 | |
| 55 | |
| 56 | namespace boost { namespace geometry { namespace traits { |
| 57 | |
| 58 | template<> |
| 59 | struct tag<test::test_point> { typedef point_tag type; }; |
| 60 | |
| 61 | template<> |
| 62 | struct coordinate_type<test::test_point> { typedef float type; }; |
| 63 | |
| 64 | template<> |
| 65 | struct coordinate_system<test::test_point> { typedef cs::cartesian type; }; |
| 66 | |
| 67 | template<> |
| 68 | struct dimension<test::test_point> : std::integral_constant<int, 3> {}; |
| 69 | |
| 70 | template<> struct access<test::test_point, 0> |
| 71 | { |
| 72 | static inline const float& get(const test::test_point& p) |
| 73 | { |
| 74 | return p.c1; |
| 75 | } |
| 76 | |
| 77 | static inline void set(test::test_point& p, float const& value) |
| 78 | { |
| 79 | p.c1 = value; |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | template<> struct access<test::test_point, 1> |
| 84 | { |
| 85 | static inline const float& get(const test::test_point& p) |
| 86 | { |
| 87 | return p.c2; |
| 88 | } |
| 89 | |
| 90 | static inline void set(test::test_point& p, float const& value) |
| 91 | { |
| 92 | p.c2 = value; |
| 93 | } |
| 94 | }; |
| 95 | |
| 96 | template<> struct access<test::test_point, 2> |
| 97 | { |
| 98 | static inline const float& get(const test::test_point& p) |
| 99 | { |
| 100 | return p.c3; |
| 101 | } |
| 102 | |
| 103 | static inline void set(test::test_point& p, float const& value) |
| 104 | { |
| 105 | p.c3 = value; |
| 106 | } |
| 107 | }; |
| 108 | |
| 109 | }}} // namespace bg::traits |
| 110 | |
| 111 | BOOST_GEOMETRY_REGISTER_POINT_3D_CONST(test::test_const_point, |
| 112 | float, |
| 113 | boost::geometry::cs::cartesian, |
| 114 | c1, c2, c3) |
| 115 | |
| 116 | #endif // GEOMETRY_TEST_TEST_COMMON_TEST_POINT_HPP |
| 117 | |