polygon_rectangle_formation_test.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Boost.Polygon library polygon_rectangle_formation_test.cpp file
  2. // Copyright Andrii Sydorchuk 2015.
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. // See http://www.boost.org for updates, documentation, and revision history.
  7. #include <boost/core/lightweight_test.hpp>
  8. #include <boost/polygon/polygon.hpp>
  9. using namespace boost::polygon;
  10. void rectangle_formation_test1()
  11. {
  12. typedef polygon_90_with_holes_data<int> polygon_type;
  13. typedef polygon_traits<polygon_type>::point_type point_type;
  14. polygon_type poly;
  15. point_type points[] = {
  16. boost::polygon::construct<point_type>(0, 0),
  17. boost::polygon::construct<point_type>(0, 10),
  18. boost::polygon::construct<point_type>(10, 10),
  19. boost::polygon::construct<point_type>(10, 0),
  20. };
  21. boost::polygon::set_points(poly, points, points + 4);
  22. std::vector< rectangle_data<int> > rects;
  23. boost::polygon::get_rectangles(rects, poly);
  24. BOOST_TEST_EQ(1, rects.size());
  25. const rectangle_data<int>& rect = rects[0];
  26. BOOST_TEST_EQ(0, rect.get(WEST));
  27. BOOST_TEST_EQ(10, rect.get(EAST));
  28. BOOST_TEST_EQ(10, rect.get(NORTH));
  29. BOOST_TEST_EQ(0, rect.get(SOUTH));
  30. }
  31. int main()
  32. {
  33. rectangle_formation_test1();
  34. return boost::report_errors();
  35. }