Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79669 - trunk/boost/geometry/algorithms/detail/overlay
From: barend.gehrels_at_[hidden]
Date: 2012-07-22 09:05:30


Author: barendgehrels
Date: 2012-07-22 09:05:29 EDT (Sun, 22 Jul 2012)
New Revision: 79669
URL: http://svn.boost.org/trac/boost/changeset/79669

Log:
[geometry] Small tweak, avoid inner rings with e.g. two points only. Plus comment update / tab removal
Text files modified:
   trunk/boost/geometry/algorithms/detail/overlay/add_rings.hpp | 33 ++++++++++++++++-----------------
   trunk/boost/geometry/algorithms/detail/overlay/convert_ring.hpp | 21 ++++++++++++++++-----
   2 files changed, 32 insertions(+), 22 deletions(-)

Modified: trunk/boost/geometry/algorithms/detail/overlay/add_rings.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/detail/overlay/add_rings.hpp (original)
+++ trunk/boost/geometry/algorithms/detail/overlay/add_rings.hpp 2012-07-22 09:05:29 EDT (Sun, 22 Jul 2012)
@@ -75,15 +75,15 @@
             OutputIterator out)
 {
     typedef typename SelectionMap::const_iterator iterator;
- typedef typename SelectionMap::mapped_type property_type;
- typedef typename property_type::area_type area_type;
+ typedef typename SelectionMap::mapped_type property_type;
+ typedef typename property_type::area_type area_type;
 
- area_type const zero = 0;
- std::size_t const min_num_points = core_detail::closure::minimum_ring_size
- <
- geometry::closure
- <
- typename boost::range_value
+ area_type const zero = 0;
+ std::size_t const min_num_points = core_detail::closure::minimum_ring_size
+ <
+ geometry::closure
+ <
+ typename boost::range_value
                         <
                             RingCollection const
>::type
@@ -117,15 +117,14 @@
                 }
             }
 
- // Only add rings if they satisfy minimal requirements.
- // This cannot be done earlier (during traversal), not
- // everything is figured out yet (sum of positive/negative rings)
- // TODO: individual rings can still contain less than 3 points.
- if (geometry::num_points(result) >= min_num_points
- && math::larger(geometry::area(result), zero))
- {
- *out++ = result;
- }
+ // Only add rings if they satisfy minimal requirements.
+ // This cannot be done earlier (during traversal), not
+ // everything is figured out yet (sum of positive/negative rings)
+ if (geometry::num_points(result) >= min_num_points
+ && math::larger(geometry::area(result), zero))
+ {
+ *out++ = result;
+ }
         }
     }
     return out;

Modified: trunk/boost/geometry/algorithms/detail/overlay/convert_ring.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/detail/overlay/convert_ring.hpp (original)
+++ trunk/boost/geometry/algorithms/detail/overlay/convert_ring.hpp 2012-07-22 09:05:29 EDT (Sun, 22 Jul 2012)
@@ -77,12 +77,23 @@
         }
         else
         {
- interior_rings(destination).resize(
- interior_rings(destination).size() + 1);
- geometry::convert(source, interior_rings(destination).back());
- if (reverse)
+ // Avoid adding interior rings which are invalid because of number of points:
+ if (geometry::num_points(source) >=
+ core_detail::closure::minimum_ring_size
+ <
+ geometry::closure
+ <
+ Destination
+ >::value
+ >::value)
             {
- boost::reverse(interior_rings(destination).back());
+ interior_rings(destination).resize(
+ interior_rings(destination).size() + 1);
+ geometry::convert(source, interior_rings(destination).back());
+ if (reverse)
+ {
+ boost::reverse(interior_rings(destination).back());
+ }
             }
         }
     }


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