1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. 4 5 // Use, modification and distribution is subject to the Boost Software License, 6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_RING_PROPERTIES_HPP 10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_RING_PROPERTIES_HPP 11 12 13 #include <boost/geometry/algorithms/area.hpp> 14 #include <boost/geometry/algorithms/within.hpp> 15 #include <boost/geometry/algorithms/detail/point_on_border.hpp> 16 17 18 namespace boost { namespace geometry 19 { 20 21 22 #ifndef DOXYGEN_NO_DETAIL 23 namespace detail { namespace overlay 24 { 25 26 template <typename Point> 27 struct ring_properties 28 { 29 typedef Point point_type; 30 typedef typename default_area_result<Point>::type area_type; 31 32 bool valid; 33 34 // Filled by "select_rings" 35 Point point; 36 area_type area; 37 38 // Filled by "update_ring_selection" 39 bool reversed; 40 41 // Filled/used by "assign_rings" 42 bool discarded; 43 ring_identifier parent; 44 area_type parent_area; 45 std::vector<ring_identifier> children; 46 ring_propertiesboost::geometry::detail::overlay::ring_properties47 inline ring_properties() 48 : valid(false) 49 , area(area_type()) 50 , reversed(false) 51 , discarded(false) 52 , parent_area(-1) 53 {} 54 55 template <typename RingOrBox> ring_propertiesboost::geometry::detail::overlay::ring_properties56 inline ring_properties(RingOrBox const& ring_or_box) 57 : reversed(false) 58 , discarded(false) 59 , parent_area(-1) 60 { 61 this->area = geometry::area(ring_or_box); 62 // We should take a point somewhere in the middle of the ring, 63 // to avoid taking a point on a (self)tangency, 64 // in cases where multiple points come together 65 valid = geometry::point_on_border(this->point, ring_or_box, true); 66 } 67 get_areaboost::geometry::detail::overlay::ring_properties68 inline area_type get_area() const 69 { 70 return reversed ? -area : area; 71 } 72 }; 73 74 }} // namespace detail::overlay 75 #endif // DOXYGEN_NO_DETAIL 76 77 78 }} // namespace boost::geometry 79 80 81 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_RING_PROPERTIES_HPP 82