buffer_ring.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2017-2019 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 "test_buffer.hpp"
  8. // Short test verifying behavior of explicit ring_type (polygon without holes)
  9. // The test buffer_polygon.cpp contains all other tests, also for rings.
  10. static std::string const concave_simplex = "POLYGON ((0 0,3 5,3 3,5 3,0 0))";
  11. template <bool Clockwise, typename P>
  12. void test_all()
  13. {
  14. typedef bg::model::ring<P, Clockwise, true> ring_type;
  15. typedef bg::model::polygon<P, Clockwise, true> polygon_type;
  16. bg::strategy::buffer::join_miter join_miter(10.0);
  17. bg::strategy::buffer::join_round join_round(100);
  18. bg::strategy::buffer::end_flat end_flat;
  19. test_one<ring_type, polygon_type>("concave_simplex", concave_simplex, join_round, end_flat, 14.5616, 0.5);
  20. test_one<ring_type, polygon_type>("concave_simplex", concave_simplex, join_miter, end_flat, 16.3861, 0.5);
  21. test_one<ring_type, polygon_type>("concave_simplex", concave_simplex, join_round, end_flat, 0.777987, -0.5);
  22. test_one<ring_type, polygon_type>("concave_simplex", concave_simplex, join_miter, end_flat, 0.724208, -0.5);
  23. }
  24. int test_main(int, char* [])
  25. {
  26. BoostGeometryWriteTestConfiguration();
  27. test_all<true, bg::model::point<default_test_type, 2, bg::cs::cartesian> >();
  28. #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_ORDER)
  29. test_all<false, bg::model::point<default_test_type, 2, bg::cs::cartesian> >();
  30. #endif
  31. #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
  32. test_all<true, bg::model::point<float, 2, bg::cs::cartesian> >();
  33. test_all<false, bg::model::point<float, 2, bg::cs::cartesian> >();
  34. #endif
  35. return 0;
  36. }