ring_properties.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // This file was modified by Oracle on 2017.
  4. // Modifications copyright (c) 2017 Oracle and/or its affiliates.
  5. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  6. // Use, modification and distribution is subject to the Boost Software License,
  7. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_RING_PROPERTIES_HPP
  10. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_RING_PROPERTIES_HPP
  11. #include <boost/geometry/algorithms/area.hpp>
  12. #include <boost/geometry/algorithms/within.hpp>
  13. #include <boost/geometry/algorithms/detail/point_on_border.hpp>
  14. namespace boost { namespace geometry
  15. {
  16. #ifndef DOXYGEN_NO_DETAIL
  17. namespace detail { namespace overlay
  18. {
  19. template <typename Point, typename AreaType>
  20. struct ring_properties
  21. {
  22. typedef Point point_type;
  23. typedef AreaType area_type;
  24. bool valid;
  25. // Filled by "select_rings"
  26. Point point;
  27. area_type area;
  28. // Filled by "update_ring_selection"
  29. bool reversed;
  30. // Filled/used by "assign_rings"
  31. bool discarded;
  32. ring_identifier parent;
  33. area_type parent_area;
  34. std::vector<ring_identifier> children;
  35. inline ring_properties()
  36. : valid(false)
  37. , area(area_type())
  38. , reversed(false)
  39. , discarded(false)
  40. , parent_area(-1)
  41. {}
  42. template <typename RingOrBox, typename AreaStrategy>
  43. inline ring_properties(RingOrBox const& ring_or_box, AreaStrategy const& strategy)
  44. : reversed(false)
  45. , discarded(false)
  46. , parent_area(-1)
  47. {
  48. this->area = geometry::area(ring_or_box, strategy);
  49. valid = geometry::point_on_border(this->point, ring_or_box);
  50. }
  51. inline area_type get_area() const
  52. {
  53. return reversed ? -area : area;
  54. }
  55. };
  56. }} // namespace detail::overlay
  57. #endif // DOXYGEN_NO_DETAIL
  58. }} // namespace boost::geometry
  59. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_RING_PROPERTIES_HPP