/Src/Dependencies/Boost/libs/geometry/test/geometries/adapted.cpp

http://hadesmem.googlecode.com/ · C++ · 109 lines · 52 code · 32 blank · 25 comment · 0 complexity · ee919dd2b689e2834ede41c6c7f7ecb4 MD5 · raw file

  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <deque>
  8. #include <vector>
  9. #include <geometry_test_common.hpp>
  10. #include <boost/geometry/geometries/geometries.hpp>
  11. #include <boost/geometry/multi/multi.hpp>
  12. #include <boost/geometry/geometries/adapted/c_array.hpp>
  13. #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
  14. #include <test_common/test_point.hpp>
  15. #define BOOST_GEOMETRY_TEST_RING
  16. #if defined(BOOST_GEOMETRY_TEST_RING)
  17. #include <boost/geometry/geometries/register/ring.hpp>
  18. #include <boost/geometry/geometries/concepts/ring_concept.hpp>
  19. BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::vector)
  20. BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque)
  21. #elif defined(BOOST_GEOMETRY_TEST_MULTI_POINT)
  22. #include <boost/geometry/multi/geometries/register/multi_point.hpp>
  23. #include <boost/geometry/multi/geometries/concepts/multi_point_concept.hpp>
  24. BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::vector)
  25. BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::deque)
  26. #else
  27. #include <boost/geometry/geometries/register/linestring.hpp>
  28. #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
  29. BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
  30. BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
  31. #endif
  32. BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
  33. BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
  34. // ----------------------------------------------------------------------------
  35. template <typename G>
  36. void test_geometry(G const& geometry, int expected_size = 0)
  37. {
  38. #if defined(BOOST_GEOMETRY_TEST_RING)
  39. BOOST_CONCEPT_ASSERT( (bg::concept::ConstRing<G>) );
  40. #elif defined(BOOST_GEOMETRY_TEST_MULTI_POINT)
  41. BOOST_CONCEPT_ASSERT( (bg::concept::ConstMultiPoint<G>) );
  42. #else
  43. BOOST_CONCEPT_ASSERT( (bg::concept::ConstLinestring<G>) );
  44. #endif
  45. typedef typename bg::point_type<G>::type P;
  46. typedef typename bg::coordinate_type<P>::type C;
  47. // Check range-like behaviour
  48. BOOST_CHECK_EQUAL(boost::size(geometry), expected_size);
  49. }
  50. template <typename P>
  51. void test_all()
  52. {
  53. test_geometry(std::vector<P>());
  54. test_geometry(std::deque<P>());
  55. //test_geometry(std::list<P>());
  56. /***
  57. double vertices[][3] = {
  58. {-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1},
  59. {-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}
  60. };
  61. test_geometry(vertices, 8);
  62. ***/
  63. }
  64. int test_main(int, char* [])
  65. {
  66. /* test_all<test::test_point>();
  67. test_all<boost::tuple<float, float> >();
  68. test_all<bg::model::point<int, 2, bg::cs::cartesian> >();
  69. test_all<bg::model::point<float, 2, bg::cs::cartesian> >();
  70. test_all<bg::model::point<double, 2, bg::cs::cartesian> >();
  71. test_all<bg::model::point<long double, 2, bg::cs::cartesian> >();
  72. */
  73. test_all<bg::model::point<double, 3, bg::cs::cartesian> >();
  74. //test_all<bg::model::point<long double, 3, bg::cs::cartesian> >();
  75. return 0;
  76. }