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 // Use, modification and distribution is subject to the Boost Software License, 7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 8 // http://www.boost.org/LICENSE_1_0.txt) 9 10 11 #ifndef GEOMETRY_TEST_TEST_COMMON_TEST_POINT_HPP 12 #define GEOMETRY_TEST_TEST_COMMON_TEST_POINT_HPP 13 14 #include <boost/geometry/core/access.hpp> 15 #include <boost/geometry/core/coordinate_type.hpp> 16 #include <boost/geometry/core/coordinate_system.hpp> 17 #include <boost/geometry/core/coordinate_dimension.hpp> 18 #include <boost/geometry/core/cs.hpp> 19 #include <boost/geometry/core/tag.hpp> 20 #include <boost/geometry/geometries/register/point.hpp> 21 22 // NOTE: since Boost 1.51 the Point type may always be a pointer. 23 // Therefore the traits class don't need to add a pointer. 24 // This obsoletes this whole test-point-type 25 26 namespace test 27 { 28 29 // Test point class 30 31 struct test_point 32 { 33 float c1, c2, c3; 34 }; 35 36 struct test_const_point 37 { test_const_pointtest::test_const_point38 test_const_point() 39 : c1(0.0), c2(0.0), c3(0.0) { } 40 test_const_pointtest::test_const_point41 test_const_point(float c1, float c2, float c3) 42 : c1(c1), c2(c2), c3(c3) { } 43 44 const float c1, c2, c3; 45 }; 46 47 } // namespace test 48 49 50 51 namespace boost { namespace geometry { namespace traits { 52 53 template<> 54 struct tag<test::test_point> { typedef point_tag type; }; 55 56 template<> 57 struct coordinate_type<test::test_point> { typedef float type; }; 58 59 template<> 60 struct coordinate_system<test::test_point> { typedef cs::cartesian type; }; 61 62 template<> 63 struct dimension<test::test_point>: boost::mpl::int_<3> {}; 64 65 template<> struct access<test::test_point, 0> 66 { getboost::geometry::traits::access67 static inline const float& get(const test::test_point& p) 68 { 69 return p.c1; 70 } 71 setboost::geometry::traits::access72 static inline void set(test::test_point& p, const float& value) 73 { 74 p.c1 = value; 75 } 76 }; 77 78 template<> struct access<test::test_point, 1> 79 { getboost::geometry::traits::access80 static inline const float& get(const test::test_point& p) 81 { 82 return p.c2; 83 } 84 setboost::geometry::traits::access85 static inline void set(test::test_point& p, const float& value) 86 { 87 p.c2 = value; 88 } 89 }; 90 91 template<> struct access<test::test_point, 2> 92 { getboost::geometry::traits::access93 static inline const float& get(const test::test_point& p) 94 { 95 return p.c3; 96 } 97 setboost::geometry::traits::access98 static inline void set(test::test_point& p, const float& value) 99 { 100 p.c3 = value; 101 } 102 }; 103 104 }}} // namespace bg::traits 105 106 BOOST_GEOMETRY_REGISTER_POINT_3D_CONST(test::test_const_point, 107 float, 108 boost::geometry::cs::cartesian, 109 c1, c2, c3) 110 111 #endif // GEOMETRY_TEST_TEST_COMMON_TEST_POINT_HPP 112