/Src/Dependencies/Boost/libs/geometry/doc/src/examples/algorithms/equals.cpp

http://hadesmem.googlecode.com/ · C++ · 61 lines · 25 code · 18 blank · 18 comment · 0 complexity · a0a57beae94c7798262927ad4a0ccaf2 MD5 · raw file

  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // QuickBook Example
  3. // Copyright (c) 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. //[equals
  8. //` Shows the predicate equals, which returns true if two geometries are spatially equal
  9. #include <iostream>
  10. #include <boost/geometry.hpp>
  11. #include <boost/geometry/geometries/polygon.hpp>
  12. #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
  13. BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
  14. #include <boost/assign.hpp>
  15. int main()
  16. {
  17. using boost::assign::tuple_list_of;
  18. typedef boost::tuple<int, int> point;
  19. boost::geometry::model::polygon<point> poly1, poly2;
  20. boost::geometry::exterior_ring(poly1) = tuple_list_of(0, 0)(0, 5)(5, 5)(5, 0)(0, 0);
  21. boost::geometry::exterior_ring(poly2) = tuple_list_of(5, 0)(0, 0)(0, 5)(5, 5)(5, 0);
  22. std::cout
  23. << "polygons are spatially "
  24. << (boost::geometry::equals(poly1, poly2) ? "equal" : "not equal")
  25. << std::endl;
  26. boost::geometry::model::box<point> box;
  27. boost::geometry::assign_values(box, 0, 0, 5, 5);
  28. std::cout
  29. << "polygon and box are spatially "
  30. << (boost::geometry::equals(box, poly2) ? "equal" : "not equal")
  31. << std::endl;
  32. return 0;
  33. }
  34. //]
  35. //[equals_output
  36. /*`
  37. Output:
  38. [pre
  39. polygons are spatially equal
  40. polygon and box are spatially equal
  41. ]
  42. */
  43. //]