// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include #include #include #include BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) template void test_get_set() { typedef typename bg::coordinate_type::type coordinate_type; G g; bg::set<0>(g, coordinate_type(1)); bg::set<1>(g, coordinate_type(2)); coordinate_type x = bg::get<0>(g); coordinate_type y = bg::get<1>(g); BOOST_CHECK_CLOSE(double(x), 1.0, 0.0001); BOOST_CHECK_CLOSE(double(y), 2.0, 0.0001); } template void test_indexed_get_set(G& g) { bg::set<0, 0>(g, 1); bg::set<0, 1>(g, 2); bg::set<1, 0>(g, 3); bg::set<1, 1>(g, 4); typedef typename bg::coordinate_type::type coordinate_type; coordinate_type x1 = bg::get<0, 0>(g); coordinate_type y1 = bg::get<0, 1>(g); coordinate_type x2 = bg::get<1, 0>(g); coordinate_type y2 = bg::get<1, 1>(g); BOOST_CHECK_CLOSE(double(x1), 1.0, 0.0001); BOOST_CHECK_CLOSE(double(y1), 2.0, 0.0001); BOOST_CHECK_CLOSE(double(x2), 3.0, 0.0001); BOOST_CHECK_CLOSE(double(y2), 4.0, 0.0001); } template void test_indexed_get(G const& g, T a, T b, T c, T d) { T x1 = bg::get<0, 0>(g); T y1 = bg::get<0, 1>(g); T x2 = bg::get<1, 0>(g); T y2 = bg::get<1, 1>(g); BOOST_CHECK_CLOSE(double(x1), double(a), 0.0001); BOOST_CHECK_CLOSE(double(y1), double(b), 0.0001); BOOST_CHECK_CLOSE(double(x2), double(c), 0.0001); BOOST_CHECK_CLOSE(double(y2), double(d), 0.0001); } template void test_all() { typedef typename bg::coordinate_type

::type coordinate_type; // POINT, setting coordinate test_get_set

(); // BOX, setting left/right/top/bottom bg::model::box

b; test_indexed_get_set(b); // SEGMENT (in GGL not having default constructor; however that is not a requirement) P p1 = bg::make_zero

(); P p2 = bg::make_zero

(); bg::model::referring_segment

s(p1, p2); test_indexed_get_set(s); // CONST SEGMENT bg::set<0>(p1, 1); // we don't use assign because dim in {2,3} bg::set<1>(p1, 2); bg::set<0>(p2, 3); bg::set<1>(p2, 4); bg::model::referring_segment

cs(p1, p2); test_indexed_get(cs, coordinate_type(1), coordinate_type(2), coordinate_type(3), coordinate_type(4)); } int test_main(int, char* []) { test_get_set(); test_get_set(); test_get_set(); test_get_set(); test_get_set >(); test_all >(); test_all >(); test_all >(); return 0; }