Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86580 - in trunk/boost/geometry: algorithms multi/algorithms multi/algorithms/detail
From: barend.gehrels_at_[hidden]
Date: 2013-11-06 18:27:02


Author: barendgehrels
Date: 2013-11-06 18:27:02 EST (Wed, 06 Nov 2013)
New Revision: 86580
URL: http://svn.boost.org/trac/boost/changeset/86580

Log:
[geometry] added extreme_points for multi-polygon to fix compilation in disjoint for multi polygon. Also fixed bug in multi by using within, we have to use rings_containing, that one is restored. It is now duplicated (temporary) in touches because that one has to use point_on_border still (somehow), to be found out

Added:
   trunk/boost/geometry/multi/algorithms/detail/extreme_points.hpp (contents, props changed)
Text files modified:
   trunk/boost/geometry/algorithms/disjoint.hpp | 48 +++++++++++++++++++++------
   trunk/boost/geometry/multi/algorithms/detail/extreme_points.hpp | 68 ++++++++++++++++++++++++++++++++++++++++
   trunk/boost/geometry/multi/algorithms/disjoint.hpp | 1
   3 files changed, 106 insertions(+), 11 deletions(-)

Modified: trunk/boost/geometry/algorithms/disjoint.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/disjoint.hpp Wed Nov 6 17:42:02 2013 (r86579)
+++ trunk/boost/geometry/algorithms/disjoint.hpp 2013-11-06 18:27:02 EST (Wed, 06 Nov 2013) (r86580)
@@ -32,8 +32,10 @@
 
 #include <boost/geometry/algorithms/detail/disjoint.hpp>
 #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+#include <boost/geometry/algorithms/detail/point_on_border.hpp>
 #include <boost/geometry/algorithms/point_on_surface.hpp>
 #include <boost/geometry/algorithms/within.hpp>
+#include <boost/geometry/algorithms/detail/for_each_range.hpp>
 
 #include <boost/geometry/geometries/concepts/check.hpp>
 
@@ -48,6 +50,38 @@
 namespace detail { namespace disjoint
 {
 
+template<typename Geometry>
+struct check_each_ring_for_within
+{
+ bool has_within;
+ Geometry const& m_geometry;
+
+ inline check_each_ring_for_within(Geometry const& g)
+ : has_within(false)
+ , m_geometry(g)
+ {}
+
+ template <typename Range>
+ inline void apply(Range const& range)
+ {
+ if (geometry::within(geometry::return_point_on_surface(range), m_geometry))
+ {
+ has_within = true;
+ }
+ }
+};
+
+template <typename FirstGeometry, typename SecondGeometry>
+inline bool rings_containing(FirstGeometry const& geometry1,
+ SecondGeometry const& geometry2)
+{
+ check_each_ring_for_within<FirstGeometry> checker(geometry1);
+ geometry::detail::for_each_range(geometry2, checker);
+ return checker.has_within;
+}
+
+
+
 struct assign_disjoint_policy
 {
     // We want to include all points:
@@ -139,17 +173,8 @@
         typedef typename geometry::point_type<Geometry1>::type point_type1;
         typedef typename geometry::point_type<Geometry2>::type point_type2;
 
- if (geometry::within
- (
- geometry::return_point_on_surface(geometry1),
- geometry2
- )
- || geometry::within
- (
- geometry::return_point_on_surface(geometry2),
- geometry1
- )
- )
+ if (rings_containing(geometry1, geometry2)
+ || rings_containing(geometry2, geometry1))
         {
             return false;
         }
@@ -204,6 +229,7 @@
     }
 };
 
+
 }} // namespace detail::disjoint
 #endif // DOXYGEN_NO_DETAIL
 

Added: trunk/boost/geometry/multi/algorithms/detail/extreme_points.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/geometry/multi/algorithms/detail/extreme_points.hpp 2013-11-06 18:27:02 EST (Wed, 06 Nov 2013) (r86580)
@@ -0,0 +1,68 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2013 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2013 Mateusz Loskot, London, UK.
+// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_EXTREME_POINTS_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_EXTREME_POINTS_HPP
+
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/geometries/concepts/check.hpp>
+
+#include <boost/geometry/algorithms/detail/extreme_points.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+
+template<typename MultiPolygon, std::size_t Dimension>
+struct extreme_points<MultiPolygon, Dimension, multi_polygon_tag>
+{
+ template <typename Extremes, typename Intruders>
+ static inline bool apply(MultiPolygon const& multi, Extremes& extremes, Intruders& intruders)
+ {
+ // Get one for the very first polygon, that is (for the moment) enough.
+ // It is not guaranteed the "extreme" then, but for the current purpose
+ // (point_on_surface) it can just be this point.
+ if (boost::size(multi) >= 1)
+ {
+ return extreme_points
+ <
+ typename boost::range_value<MultiPolygon const>::type,
+ Dimension,
+ polygon_tag
+ >::apply(*boost::begin(multi), extremes, intruders);
+ }
+
+ return false;
+ }
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_EXTREME_POINTS_HPP

Modified: trunk/boost/geometry/multi/algorithms/disjoint.hpp
==============================================================================
--- trunk/boost/geometry/multi/algorithms/disjoint.hpp Wed Nov 6 17:42:02 2013 (r86579)
+++ trunk/boost/geometry/multi/algorithms/disjoint.hpp 2013-11-06 18:27:02 EST (Wed, 06 Nov 2013) (r86580)
@@ -14,6 +14,7 @@
 
 #include <boost/geometry/algorithms/disjoint.hpp>
 #include <boost/geometry/multi/algorithms/covered_by.hpp>
+#include <boost/geometry/multi/algorithms/detail/extreme_points.hpp>
 
 #include <boost/geometry/multi/core/tags.hpp>
 #include <boost/geometry/multi/geometries/concepts/check.hpp>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk