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

http://hadesmem.googlecode.com/ · C++ · 41 lines · 13 code · 11 blank · 17 comment · 0 complexity · 25b4683e1933030e89f5bc0aac62b746 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. //[unique
  8. //` Shows how to make a so-called minimal set of a polygon by removing duplicate points
  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. int main()
  15. {
  16. boost::geometry::model::polygon<boost::tuple<double, double> > poly;
  17. boost::geometry::read_wkt("POLYGON((0 0,0 0,0 5,5 5,5 5,5 5,5 0,5 0,0 0,0 0,0 0,0 0))", poly);
  18. boost::geometry::unique(poly);
  19. std::cout << boost::geometry::wkt(poly) << std::endl;
  20. return 0;
  21. }
  22. //]
  23. //[unique_output
  24. /*`
  25. Output:
  26. [pre
  27. POLYGON((0 0,0 5,5 5,5 0,0 0))
  28. ]
  29. */
  30. //]