/Src/Dependencies/Boost/libs/geometry/doc/src/examples/geometries/register/box_2d_4values.cpp

http://hadesmem.googlecode.com/ · C++ · 51 lines · 20 code · 12 blank · 19 comment · 0 complexity · 3314931294102cfd3a16785abfa01cc6 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. //[register_box_2d_4values
  8. //` Show the use of the macro BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES
  9. #include <iostream>
  10. #include <boost/geometry.hpp>
  11. #include <boost/geometry/geometries/register/point.hpp>
  12. #include <boost/geometry/geometries/register/box.hpp>
  13. struct my_point
  14. {
  15. int x, y;
  16. };
  17. struct my_box
  18. {
  19. int left, top, right, bottom;
  20. };
  21. BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, int, cs::cartesian, x, y)
  22. // Register the box type, also notifying that it is based on "my_point"
  23. // (even if it does not contain it)
  24. BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES(my_box, my_point, left, top, right, bottom)
  25. int main()
  26. {
  27. my_box b = boost::geometry::make<my_box>(0, 0, 2, 2);
  28. std::cout << "Area: " << boost::geometry::area(b) << std::endl;
  29. return 0;
  30. }
  31. //]
  32. //[register_box_2d_4values_output
  33. /*`
  34. Output:
  35. [pre
  36. Area: 4
  37. ]
  38. */
  39. //]