/Src/Dependencies/Boost/libs/geometry/doc/src/examples/geometries/adapted/boost_range/sliced.cpp

http://hadesmem.googlecode.com/ · C++ · 50 lines · 20 code · 13 blank · 17 comment · 0 complexity · 61470ccd6e818031636a65c31f7dffb5 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. //[boost_range_sliced
  8. //` Shows how to use a Boost.Geometry linestring, sliced by Boost.Range adaptor
  9. #include <iostream>
  10. #include <boost/assign.hpp>
  11. #include <boost/geometry.hpp>
  12. #include <boost/geometry/geometries/linestring.hpp>
  13. #include <boost/geometry/geometries/point_xy.hpp>
  14. #include <boost/geometry/geometries/adapted/boost_range/sliced.hpp>
  15. int main()
  16. {
  17. using namespace boost::assign;
  18. typedef boost::geometry::model::d2::point_xy<int> xy;
  19. boost::geometry::model::linestring<xy> line;
  20. line += xy(0, 0);
  21. line += xy(1, 1);
  22. line += xy(2, 2);
  23. line += xy(3, 3);
  24. line += xy(4, 4);
  25. std::cout
  26. << boost::geometry::dsv(line | boost::adaptors::sliced(1, 3)) << std::endl;
  27. return 0;
  28. }
  29. //]
  30. //[boost_range_sliced_output
  31. /*`
  32. Output:
  33. [pre
  34. ((1, 1), (2, 2))
  35. ]
  36. */
  37. //]