boost_array_as_point.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2010 Alfredo Correa
  4. // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
  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)
  8. #include <boost/config.hpp>
  9. #include <geometry_test_common.hpp>
  10. #include<boost/geometry/geometry.hpp>
  11. #include<boost/geometry/geometries/adapted/boost_array.hpp>
  12. #include<boost/geometry/geometries/adapted/c_array.hpp>
  13. #include<boost/geometry/geometries/adapted/boost_tuple.hpp>
  14. #include<iostream>
  15. BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
  16. BOOST_GEOMETRY_REGISTER_BOOST_ARRAY_CS(cs::cartesian)
  17. BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
  18. #ifndef BOOST_NO_CXX11_HDR_ARRAY
  19. #include<boost/geometry/geometries/adapted/std_array.hpp>
  20. BOOST_GEOMETRY_REGISTER_STD_ARRAY_CS(cs::cartesian)
  21. #endif //BOOST_NO_CXX11_HDR_ARRAY
  22. int test_main(int, char* [])
  23. {
  24. bg::model::point<double, 3, bg::cs::cartesian> p1(1,2,3);
  25. double p2[3] = {4,5,6};
  26. boost::tuple<double, double, double> p3(7,8,9);
  27. boost::array<double, 3> p4 = {{10,11,12}};
  28. std::clog << bg::distance(p1, p2) << std::endl;
  29. std::clog << bg::distance(p2, p3) << std::endl;
  30. std::clog << bg::distance(p3, p4) << std::endl;
  31. #ifndef BOOST_NO_CXX11_HDR_ARRAY
  32. #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  33. std::array<double, 3> p5 = {13,14,15};
  34. #else
  35. std::array<double, 3> p5; p5[0] = 13; p5[1] = 14; p5[2] = 15;
  36. #endif // BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  37. std::clog << bg::distance(p4, p5) << std::endl;
  38. #endif //BOOST_NO_CXX11_HDR_ARRAY
  39. return 0;
  40. }