Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60001 - in sandbox/geometry/boost/geometry: algorithms algorithms/detail/overlay algorithms/overlay extensions/io/svg strategies/transform
From: barend.gehrels_at_[hidden]
Date: 2010-02-28 16:20:08


Author: barendgehrels
Date: 2010-02-28 16:20:07 EST (Sun, 28 Feb 2010)
New Revision: 60001
URL: http://svn.boost.org/trac/boost/changeset/60001

Log:
Added difference and sym_difference
Added reverse conform std::reverse

Added:
   sandbox/geometry/boost/geometry/algorithms/difference.hpp (contents, props changed)
   sandbox/geometry/boost/geometry/algorithms/reverse.hpp (contents, props changed)
   sandbox/geometry/boost/geometry/algorithms/sym_difference.hpp (contents, props changed)
Text files modified:
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp | 1
   sandbox/geometry/boost/geometry/algorithms/overlay/get_turns.hpp | 118 +++------------------------------------
   sandbox/geometry/boost/geometry/extensions/io/svg/svg_mapper.hpp | 2
   sandbox/geometry/boost/geometry/strategies/transform/matrix_transformers.hpp | 13 +---
   4 files changed, 17 insertions(+), 117 deletions(-)

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp 2010-02-28 16:20:07 EST (Sun, 28 Feb 2010)
@@ -9,6 +9,7 @@
 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_DEBUG_TURN_INFO_HPP
 
 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/visit_info.hpp>
 
 
 namespace boost { namespace geometry

Added: sandbox/geometry/boost/geometry/algorithms/difference.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/algorithms/difference.hpp 2010-02-28 16:20:07 EST (Sun, 28 Feb 2010)
@@ -0,0 +1,53 @@
+// 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_DIFFERENCE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DIFFERENCE_HPP
+
+#include <algorithm>
+
+
+#include <boost/geometry/algorithms/intersection.hpp>
+#include <boost/geometry/algorithms/reverse.hpp>
+
+
+/*!
+\defgroup difference difference: difference of two geometries
+*/
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+ \ingroup difference
+ \tparam Geometry geometry type
+ \param geometry the geometry to make difference
+*/
+template
+<
+ typename Geometry1,
+ typename Geometry2,
+ typename Collection
+>
+inline void difference(Geometry1 const& geometry1,
+ Geometry2 geometry2, Collection& output_collection)
+{
+ concept::check<Geometry1 const>();
+ concept::check<Geometry2>();
+
+ reverse(geometry2);
+
+ intersection(geometry1, geometry2, output_collection);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DIFFERENCE_HPP

Modified: sandbox/geometry/boost/geometry/algorithms/overlay/get_turns.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/overlay/get_turns.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/overlay/get_turns.hpp 2010-02-28 16:20:07 EST (Sun, 28 Feb 2010)
@@ -654,6 +654,8 @@
 namespace dispatch
 {
 
+// Because this is "detail" method, and most implementations will use "generic",
+// we take the freedom to derive it from "generic".
 template
 <
     typename GeometryTag1, typename GeometryTag2,
@@ -665,8 +667,15 @@
     typename InterruptPolicy
>
 struct get_turns
-{
-};
+ : detail::get_turns::get_turns_generic
+ <
+ Geometry1,
+ Geometry2,
+ Turns,
+ IntersectionStrategy,
+ AssignPolicy, InterruptPolicy
+ >
+{};
 
 
 template
@@ -778,111 +787,6 @@
 
 template
 <
- typename Ring1,
- typename Ring2,
- typename Turns,
- typename IntersectionStrategy,
- typename AssignPolicy,
- typename InterruptPolicy
->
-struct get_turns
- <
- ring_tag, ring_tag, false, false,
- Ring1, Ring2,
- Turns, IntersectionStrategy,
- AssignPolicy, InterruptPolicy
- >
- : detail::get_turns::get_turns_generic
- <
- Ring1,
- Ring2,
- Turns,
- IntersectionStrategy,
- AssignPolicy, InterruptPolicy
- >
-{};
-
-
-template
-<
- typename Polygon1,
- typename Polygon2,
- typename Turns,
- typename IntersectionStrategy,
- typename AssignPolicy,
- typename InterruptPolicy
->
-struct get_turns
- <
- polygon_tag, polygon_tag, false, false,
- Polygon1, Polygon2,
- Turns, IntersectionStrategy,
- AssignPolicy, InterruptPolicy
- >
- : detail::get_turns::get_turns_generic
- <
- Polygon1,
- Polygon2,
- Turns,
- IntersectionStrategy,
- AssignPolicy, InterruptPolicy
- >
-{};
-
-template
-<
- typename Polygon,
- typename Ring,
- typename Turns,
- typename IntersectionStrategy,
- typename AssignPolicy,
- typename InterruptPolicy
->
-struct get_turns
- <
- polygon_tag, ring_tag, false, false,
- Polygon, Ring,
- Turns, IntersectionStrategy,
- AssignPolicy, InterruptPolicy
- >
- : detail::get_turns::get_turns_generic
- <
- Polygon,
- Ring,
- Turns,
- IntersectionStrategy,
- AssignPolicy, InterruptPolicy
- >
-{};
-
-template
-<
- typename LineString1,
- typename LineString2,
- typename Turns,
- typename IntersectionStrategy,
- typename AssignPolicy,
- typename InterruptPolicy
->
-struct get_turns
- <
- linestring_tag, linestring_tag, false, false,
- LineString1, LineString2,
- Turns, IntersectionStrategy,
- AssignPolicy, InterruptPolicy
- >
- : detail::get_turns::get_turns_generic
- <
- LineString1,
- LineString2,
- Turns,
- IntersectionStrategy,
- AssignPolicy, InterruptPolicy
- >
-{};
-
-template
-<
     typename GeometryTag1, typename GeometryTag2,
     bool IsMulti1, bool IsMulti2,
     typename Geometry1, typename Geometry2,

Added: sandbox/geometry/boost/geometry/algorithms/reverse.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/algorithms/reverse.hpp 2010-02-28 16:20:07 EST (Sun, 28 Feb 2010)
@@ -0,0 +1,141 @@
+// 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_REVERSE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_REVERSE_HPP
+
+#include <algorithm>
+
+#include <boost/range.hpp>
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+/*!
+\defgroup reverse reverse: reverse a geometry
+ This is functionally equivalent to the std::reverse algorithm.
+ For a linestring or a linear ring, it is exactly the same as calling the std::reverse algorithm.
+ For a polygon or a multi-geometry, all its rings or elements are reversed.
+
+ No check on order is applied. So a clockwise polygon (having positive area)
+ will be made counterclockwise (having negative area).
+
+ The first and last points are reversed as well, even if they are closed and the same.
+*/
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace reverse
+{
+
+
+template <typename Range>
+struct range_reverse
+{
+ static inline void apply(Range& range)
+ {
+ std::reverse(boost::begin(range), boost::end(range));
+ }
+};
+
+
+template <typename Polygon>
+struct polygon_reverse
+{
+ static inline void apply(Polygon& polygon)
+ {
+ typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+ typedef range_reverse<ring_type> per_range;
+ per_range::apply(exterior_ring(polygon));
+
+ for (typename boost::range_iterator
+ <
+ typename interior_type<Polygon>::type
+ >::type it = boost::begin(interior_rings(polygon));
+ it != boost::end(interior_rings(polygon));
+ ++it)
+ {
+ per_range::apply(*it);
+ }
+ }
+};
+
+
+
+}} // namespace detail::reverse
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+ typename Tag,
+ typename Geometry
+>
+struct reverse
+{
+ static inline void apply(Geometry&)
+ {}
+};
+
+
+template <typename Ring>
+struct reverse<ring_tag, Ring>
+ : detail::reverse::range_reverse<Ring>
+{};
+
+
+template <typename LineString>
+struct reverse<linestring_tag, LineString>
+ : detail::reverse::range_reverse<LineString>
+{};
+
+
+template <typename Polygon>
+struct reverse<polygon_tag, Polygon>
+ : detail::reverse::polygon_reverse<Polygon>
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+ \ingroup reverse
+ \tparam Geometry geometry type
+ \param geometry the geometry to make reverse
+*/
+template <typename Geometry>
+inline void reverse(Geometry& geometry)
+{
+ concept::check<Geometry>();
+
+ dispatch::reverse
+ <
+ typename tag<Geometry>::type,
+ Geometry
+ >::apply(geometry);
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_REVERSE_HPP

Added: sandbox/geometry/boost/geometry/algorithms/sym_difference.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/algorithms/sym_difference.hpp 2010-02-28 16:20:07 EST (Sun, 28 Feb 2010)
@@ -0,0 +1,55 @@
+// 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_SYM_DIFFERENCE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_SYM_DIFFERENCE_HPP
+
+#include <algorithm>
+
+
+#include <boost/geometry/algorithms/intersection.hpp>
+#include <boost/geometry/algorithms/reverse.hpp>
+
+
+/*!
+\defgroup sym_difference sym_difference: sym_difference of two geometries
+*/
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+ \ingroup sym_difference
+ \tparam Geometry geometry type
+ \param geometry the geometry to make symmetric difference
+*/
+template
+<
+ typename Geometry1,
+ typename Geometry2,
+ typename Collection
+>
+inline void sym_difference(Geometry1 geometry1,
+ Geometry2 geometry2, Collection& output_collection)
+{
+ concept::check<Geometry1>();
+ concept::check<Geometry2>();
+
+ reverse(geometry2);
+ intersection(geometry1, geometry2, output_collection);
+ reverse(geometry2);
+ reverse(geometry1);
+ intersection(geometry1, geometry2, output_collection);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_SYM_DIFFERENCE_HPP

Modified: sandbox/geometry/boost/geometry/extensions/io/svg/svg_mapper.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/io/svg/svg_mapper.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/io/svg/svg_mapper.hpp 2010-02-28 16:20:07 EST (Sun, 28 Feb 2010)
@@ -12,6 +12,8 @@
 
 #include <vector>
 #include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
+
 
 //#include <boost/geometry/geometry.hpp>
 #include <boost/geometry/algorithms/envelope.hpp>

Modified: sandbox/geometry/boost/geometry/strategies/transform/matrix_transformers.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/transform/matrix_transformers.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/transform/matrix_transformers.hpp 2010-02-28 16:20:07 EST (Sun, 28 Feb 2010)
@@ -88,20 +88,13 @@
         coordinate_type const& c1 = get<0>(p1);
         coordinate_type const& c2 = get<1>(p1);
 
- typedef typename geometry::coordinate_type<P2>::type ct2;
-
- /*
- set<0>(p2, boost::numeric_cast<ct2>(
- c1 * m_matrix(0,0) + c2 * m_matrix(0,1) + m_matrix(0,2)));
- set<1>(p2, boost::numeric_cast<ct2>(
- c1 * m_matrix(1,0) + c2 * m_matrix(1,1) + m_matrix(1,2)));
- */
 
         coordinate_type p2x = c1 * m_matrix(0,0) + c2 * m_matrix(0,1) + m_matrix(0,2);
         coordinate_type p2y = c1 * m_matrix(1,0) + c2 * m_matrix(1,1) + m_matrix(1,2);
 
- set<0>(p2, p2x);
- set<1>(p2, p2y);
+ typedef typename geometry::coordinate_type<P2>::type ct2;
+ set<0>(p2, boost::numeric_cast<ct2>(p2x));
+ set<1>(p2, boost::numeric_cast<ct2>(p2y));
 
         return true;
     }


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