Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59763 - in sandbox/geometry/boost/geometry: algorithms algorithms/overlay core multi multi/algorithms multi/algorithms/overlay multi/core
From: barend.gehrels_at_[hidden]
Date: 2010-02-20 06:00:52


Author: barendgehrels
Date: 2010-02-20 06:00:51 EST (Sat, 20 Feb 2010)
New Revision: 59763
URL: http://svn.boost.org/trac/boost/changeset/59763

Log:
Added num_geometries, dissolve
Fixed self turn points, new template parameter
Added:
   sandbox/geometry/boost/geometry/algorithms/dissolve.hpp (contents, props changed)
   sandbox/geometry/boost/geometry/core/num_geometries.hpp (contents, props changed)
   sandbox/geometry/boost/geometry/multi/algorithms/dissolve.hpp (contents, props changed)
   sandbox/geometry/boost/geometry/multi/core/num_geometries.hpp (contents, props changed)
Text files modified:
   sandbox/geometry/boost/geometry/algorithms/overlay/self_turn_points.hpp | 8 ++++----
   sandbox/geometry/boost/geometry/multi/algorithms/overlay/self_turn_points.hpp | 8 +++++---
   sandbox/geometry/boost/geometry/multi/multi.hpp | 1 +
   3 files changed, 10 insertions(+), 7 deletions(-)

Added: sandbox/geometry/boost/geometry/algorithms/dissolve.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/algorithms/dissolve.hpp 2010-02-20 06:00:51 EST (Sat, 20 Feb 2010)
@@ -0,0 +1,173 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands.
+// 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_ALGORITHMS_DISSOLVE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DISSOLVE_HPP
+
+
+#include <boost/geometry/algorithms/overlay/get_turns.hpp>
+#include <boost/geometry/algorithms/overlay/self_turn_points.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/enrichment_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp>
+
+#include <boost/geometry/algorithms/detail/point_on_border.hpp>
+
+#include <boost/geometry/algorithms/overlay/enrich_intersection_points.hpp>
+#include <boost/geometry/algorithms/overlay/traverse.hpp>
+#include <boost/geometry/algorithms/overlay/assemble.hpp>
+
+#include <boost/geometry/strategies/area_result.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace dissolve
+{
+
+
+template <typename Geometry, typename OutputIterator>
+struct dissolve_region
+{
+ static inline OutputIterator apply(Geometry const& geometry,
+ OutputIterator out)
+ {
+ // Get the self-intersection points, including turns
+ typedef detail::overlay::traversal_turn_info
+ <
+ typename point_type<Geometry>::type
+ > turn_info;
+
+ std::vector<turn_info> turns;
+ detail::get_turns::no_interrupt_policy policy;
+ geometry::get_turns
+ <
+ detail::overlay::calculate_distance_policy
+ >(geometry, turns, policy);
+
+
+ typedef typename ring_type<Geometry>::type ring_type;
+ typedef std::vector<ring_type> out_vector;
+ out_vector rings;
+
+ // Enrich the turns
+ typedef typename strategy_side
+ <
+ typename cs_tag<Geometry>::type
+ >::type side_strategy_type;
+
+ enrich_intersection_points(turns, geometry, geometry,
+ side_strategy_type());
+
+
+ // Traverse the polygons twice in two different directions
+ traverse(geometry, geometry, detail::overlay::operation_union,
+ turns, rings);
+
+ clear_visit_info(turns);
+
+ traverse(geometry, geometry, detail::overlay::operation_intersection,
+ turns, rings);
+
+ return detail::overlay::assemble<Geometry>(rings, turns,
+ geometry, geometry, 1, true, out);
+ }
+};
+
+
+
+}} // namespace detail::dissolve
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+ typename GeometryTag,
+ typename Geometry,
+ typename OutputIterator
+>
+struct dissolve
+{};
+
+
+template
+<
+ typename Polygon,
+ typename OutputIterator
+>
+struct dissolve
+ <
+ polygon_tag,
+ Polygon,
+ OutputIterator
+ >
+ : detail::dissolve::dissolve_region<Polygon, OutputIterator>
+{};
+
+
+template
+<
+ typename Ring,
+ typename OutputIterator
+>
+struct dissolve
+ <
+ ring_tag,
+ Ring,
+ OutputIterator
+ >
+ : detail::dissolve::dissolve_region<Ring, OutputIterator>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+/*!
+ \brief Removes self intersections from a geometry
+ \ingroup overlay
+ \tparam Geometry geometry type
+ \tparam OutputIterator type of intersection container
+ (e.g. vector of "intersection/turn point"'s)
+ \param geometry first geometry
+ \param output container which will contain intersection points
+ */
+template
+<
+ typename Geometry,
+ typename OutputIterator
+>
+inline OutputIterator dissolve(Geometry const& geometry, OutputIterator output)
+{
+ concept::check<Geometry const>();
+
+
+ return dispatch::dissolve
+ <
+ typename tag<Geometry>::type,
+ Geometry,
+ OutputIterator
+ >::apply(geometry, output);
+}
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DISSOLVE_HPP

Modified: sandbox/geometry/boost/geometry/algorithms/overlay/self_turn_points.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/overlay/self_turn_points.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/overlay/self_turn_points.hpp 2010-02-20 06:00:51 EST (Sat, 20 Feb 2010)
@@ -177,17 +177,17 @@
     \param geometry geometry
     \param turns container which will contain intersection points
  */
-template
+template
 <
- typename AssignPolicy,
- typename Geometry,
+ typename AssignPolicy,
+ typename Geometry,
     typename Turns,
     typename InterruptPolicy
>
 inline void get_turns(Geometry const& geometry,
             Turns& turns, InterruptPolicy& interrupt_policy)
 {
- concept::check<Geometry>();
+ concept::check<Geometry const>();
 
     typedef typename strategy_intersection
         <

Added: sandbox/geometry/boost/geometry/core/num_geometries.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/core/num_geometries.hpp 2010-02-20 06:00:51 EST (Sat, 20 Feb 2010)
@@ -0,0 +1,70 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands.
+// 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_NUM_GEOMETRIES_HPP
+#define BOOST_GEOMETRY_NUM_GEOMETRIES_HPP
+
+#include <cstddef>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/core/is_multi.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+
+template <typename Tag, bool IsMulti, typename Geometry>
+struct num_geometries
+{
+ static inline std::size_t apply(Geometry const&)
+ {
+ return 1;
+ }
+};
+
+
+
+} // namespace core_dispatch
+#endif
+
+
+/*!
+ \brief Function to get the number of geometries of a composite geometry.
+ For a single geometry it is always 0 (also for a polygon with holes)
+ \ingroup access
+ \tparam Geometry geometry type
+ \param geometry the polygon or other geometry
+ \return the number of interior rings of the geometry
+*/
+template <typename Geometry>
+inline std::size_t num_geometries(Geometry const& geometry)
+{
+ concept::check<Geometry const>();
+
+ return core_dispatch::num_geometries
+ <
+ typename tag<Geometry>::type,
+ is_multi<Geometry>::type::value,
+ Geometry
+ >::apply(geometry);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_NUM_GEOMETRIES_HPP

Added: sandbox/geometry/boost/geometry/multi/algorithms/dissolve.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/multi/algorithms/dissolve.hpp 2010-02-20 06:00:51 EST (Sat, 20 Feb 2010)
@@ -0,0 +1,48 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands.
+// 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_DISSOLVE_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DISSOLVE_HPP
+
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/algorithms/dissolve.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+ typename Multi,
+ typename OutputIterator
+>
+struct dissolve
+ <
+ multi_polygon_tag,
+ Multi,
+ OutputIterator
+ >
+ : detail::dissolve::dissolve_region<Multi, OutputIterator>
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DISSOLVE_HPP

Modified: sandbox/geometry/boost/geometry/multi/algorithms/overlay/self_turn_points.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/multi/algorithms/overlay/self_turn_points.hpp (original)
+++ sandbox/geometry/boost/geometry/multi/algorithms/overlay/self_turn_points.hpp 2010-02-20 06:00:51 EST (Sat, 20 Feb 2010)
@@ -29,20 +29,22 @@
     typename MultiPolygon,
     typename IntersectionPoints,
     typename IntersectionStrategy,
- typename AssignPolicy
+ typename AssignPolicy,
+ typename InterruptPolicy
>
 struct self_get_turn_points
     <
         multi_polygon_tag, true, MultiPolygon,
         IntersectionPoints, IntersectionStrategy,
- AssignPolicy
+ AssignPolicy, InterruptPolicy
>
     : detail::self_get_turn_points::get_turns
         <
             MultiPolygon,
             IntersectionPoints,
             IntersectionStrategy,
- AssignPolicy
+ AssignPolicy,
+ InterruptPolicy
>
 {};
 

Added: sandbox/geometry/boost/geometry/multi/core/num_geometries.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/multi/core/num_geometries.hpp 2010-02-20 06:00:51 EST (Sat, 20 Feb 2010)
@@ -0,0 +1,45 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands.
+// 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_CORE_NUM_GEOMETRIES_HPP
+#define BOOST_GEOMETRY_MULTI_CORE_NUM_GEOMETRIES_HPP
+
+
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Tag, typename MultiGeometry>
+struct num_geometries<Tag, true, MultiGeometry>
+{
+ static inline std::size_t apply(MultiGeometry const& multi_geometry)
+ {
+ return boost::size(multi_geometry);
+ }
+};
+
+
+} // namespace core_dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_CORE_NUM_GEOMETRIES_HPP

Modified: sandbox/geometry/boost/geometry/multi/multi.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/multi/multi.hpp (original)
+++ sandbox/geometry/boost/geometry/multi/multi.hpp 2010-02-20 06:00:51 EST (Sat, 20 Feb 2010)
@@ -14,6 +14,7 @@
 #include <boost/geometry/multi/core/geometry_id.hpp>
 #include <boost/geometry/multi/core/is_multi.hpp>
 #include <boost/geometry/multi/core/interior_rings.hpp>
+#include <boost/geometry/multi/core/num_geometries.hpp>
 #include <boost/geometry/multi/core/point_type.hpp>
 #include <boost/geometry/multi/core/ring_type.hpp>
 #include <boost/geometry/multi/core/tags.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