Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69253 - in trunk/libs/geometry/doc: . html/img html/img/algorithms ref/algorithms ref/core reference src/examples/algorithms
From: barend.gehrels_at_[hidden]
Date: 2011-02-24 17:31:42


Author: barendgehrels
Date: 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
New Revision: 69253
URL: http://svn.boost.org/trac/boost/changeset/69253

Log:
Doc update, added images,
Added union/difference docs
Added samples
Added:
   trunk/libs/geometry/doc/html/img/
   trunk/libs/geometry/doc/html/img/algorithms/
   trunk/libs/geometry/doc/html/img/algorithms/difference_a.png (contents, props changed)
   trunk/libs/geometry/doc/html/img/algorithms/difference_b.png (contents, props changed)
   trunk/libs/geometry/doc/html/img/algorithms/intersection.png (contents, props changed)
   trunk/libs/geometry/doc/html/img/algorithms/sym_difference.png (contents, props changed)
   trunk/libs/geometry/doc/html/img/algorithms/union.png (contents, props changed)
   trunk/libs/geometry/doc/ref/algorithms/append.qbk (contents, props changed)
   trunk/libs/geometry/doc/ref/algorithms/sym_difference.qbk (contents, props changed)
   trunk/libs/geometry/doc/ref/algorithms/union.qbk (contents, props changed)
   trunk/libs/geometry/doc/src/examples/algorithms/append.cpp (contents, props changed)
   trunk/libs/geometry/doc/src/examples/algorithms/create_svg.hpp (contents, props changed)
   trunk/libs/geometry/doc/src/examples/algorithms/difference.cpp (contents, props changed)
   trunk/libs/geometry/doc/src/examples/algorithms/intersection_poly_poly.cpp (contents, props changed)
   trunk/libs/geometry/doc/src/examples/algorithms/sym_difference.cpp (contents, props changed)
   trunk/libs/geometry/doc/src/examples/algorithms/union.cpp (contents, props changed)
Text files modified:
   trunk/libs/geometry/doc/geometry.qbk | 7 +++++++
   trunk/libs/geometry/doc/ref/algorithms/intersection.qbk | 8 ++++++++
   trunk/libs/geometry/doc/ref/core/set_point.qbk | 1 +
   trunk/libs/geometry/doc/reference/append.qbk | 16 +++++++++-------
   trunk/libs/geometry/doc/reference/assign.qbk | 3 +++
   trunk/libs/geometry/doc/reference/difference.qbk | 4 +++-
   trunk/libs/geometry/doc/reference/sym_difference.qbk | 4 +++-
   trunk/libs/geometry/doc/reference/union.qbk | 2 ++
   8 files changed, 36 insertions(+), 9 deletions(-)

Modified: trunk/libs/geometry/doc/geometry.qbk
==============================================================================
--- trunk/libs/geometry/doc/geometry.qbk (original)
+++ trunk/libs/geometry/doc/geometry.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -29,6 +29,7 @@
 [def __0dim__ pointlike (e.g. point)]
 [def __1dim__ linear (e.g. linestring)]
 [def __2dim__ areal (e.g. polygon)]
+[def DIM2 areal (e.g. polygon)]
 [def __single__ single (e.g. point, polygon)]
 [def __multi__ multiple (e.g. multi_point, multi_polygon)]
 [def __cart__ Cartesian]
@@ -41,6 +42,7 @@
 [def __point__ Point]
 [def __linestring__ Linestring]
 [def __polygon__ Polygon]
+[def __ring__ Ring]
 [def __multi_point__ Multi point]
 [def __multi_polygon__ Multi Polygon]
 [def __range__ Rangelike (linestring, ring)]
@@ -71,6 +73,7 @@
 [import src/examples/quick_start.cpp]
 [import src/examples/algorithms/area.cpp]
 [import src/examples/algorithms/area_with_strategy.cpp]
+[import src/examples/algorithms/append.cpp]
 [import src/examples/algorithms/assign_2d_point.cpp]
 [import src/examples/algorithms/assign_3d_point.cpp]
 [import src/examples/algorithms/assign_box_corners.cpp]
@@ -78,6 +81,7 @@
 [import src/examples/algorithms/assign_with_range.cpp]
 [import src/examples/algorithms/assign_point_to_index.cpp]
 [import src/examples/algorithms/assign_point_from_index.cpp]
+[import src/examples/algorithms/difference.cpp]
 [import src/examples/algorithms/for_each_point.cpp]
 [import src/examples/algorithms/for_each_point_const.cpp]
 [import src/examples/algorithms/for_each_segment_const.cpp]
@@ -89,12 +93,15 @@
 [import src/examples/algorithms/make_with_range.cpp]
 [import src/examples/algorithms/intersection_ls_ls_point.cpp]
 [import src/examples/algorithms/intersection_segment.cpp]
+[import src/examples/algorithms/intersection_poly_poly.cpp]
 [import src/examples/algorithms/intersects_linestring.cpp]
 [import src/examples/algorithms/num_geometries.cpp]
 [import src/examples/algorithms/num_interior_rings.cpp]
 [import src/examples/algorithms/num_points.cpp]
 [import src/examples/algorithms/simplify.cpp]
 [import src/examples/algorithms/simplify_inserter.cpp]
+[import src/examples/algorithms/sym_difference.cpp]
+[import src/examples/algorithms/union.cpp]
 [import src/examples/core/get_point.cpp]
 [import src/examples/core/get_box.cpp]
 [import src/examples/core/set_point.cpp]

Added: trunk/libs/geometry/doc/html/img/algorithms/difference_a.png
==============================================================================
Binary file. No diff available.

Added: trunk/libs/geometry/doc/html/img/algorithms/difference_b.png
==============================================================================
Binary file. No diff available.

Added: trunk/libs/geometry/doc/html/img/algorithms/intersection.png
==============================================================================
Binary file. No diff available.

Added: trunk/libs/geometry/doc/html/img/algorithms/sym_difference.png
==============================================================================
Binary file. No diff available.

Added: trunk/libs/geometry/doc/html/img/algorithms/union.png
==============================================================================
Binary file. No diff available.

Added: trunk/libs/geometry/doc/ref/algorithms/append.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/ref/algorithms/append.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -0,0 +1,33 @@
+[/============================================================================
+ Boost.Geometry (aka GGL, Generic Geometry Library)
+
+ Copyright (c) 2009-2011 Barend Gehrels, Geodan, Amsterdam, the Netherlands.
+ Copyright (c) 2009-2011 Mateusz Loskot (mateusz_at_[hidden])
+ Copyright (c) 2009-2011 Bruno Lalande, Paris, France.
+
+ 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)
+=============================================================================/]
+
+[heading Behavior]
+[table
+[[Case] [Behavior] ]
+[[__point__, __box__, __segment__][Compiles, but no action]]
+[[__linestring__][Appends point or range to the end of the linestring]]
+[[__ring__][Appends point or range to the end of the ring (without explicitly closing it)]]
+[[__polygon__][Appends point or range to the end of the polygon (without explicitly closing it),
+ either the exterior ring (the default) or specify a zero-based index for one of the interior rings.
+ In the last case, the interior rings are not resized automatically,
+ so ensure that the zero-based index is smaller than the number of interior rings]]
+]
+
+[heading Complexity]
+Linear
+
+[heading Example]
+[append]
+[append_output]
+
+[heading See also]
+* [link geometry.reference.algorithms.assign.assign_2_with_a_range assign]

Modified: trunk/libs/geometry/doc/ref/algorithms/intersection.qbk
==============================================================================
--- trunk/libs/geometry/doc/ref/algorithms/intersection.qbk (original)
+++ trunk/libs/geometry/doc/ref/algorithms/intersection.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -18,3 +18,11 @@
 [[[qbk_out __polygon__]][Calculates intersection polygons input (multi)polygons and/or boxes]]
 ]
 
+[heading Example]
+[intersection]
+[intersection_output]
+
+[heading See also]
+* [link geometry.reference.algorithms.union.union_ union]
+* [link geometry.reference.algorithms.difference.difference difference]
+* [link geometry.reference.algorithms.sym_difference.sym_difference sym_difference (symmetric difference)]

Added: trunk/libs/geometry/doc/ref/algorithms/sym_difference.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/ref/algorithms/sym_difference.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -0,0 +1,29 @@
+[/============================================================================
+ Boost.Geometry (aka GGL, Generic Geometry Library)
+
+ Copyright (c) 2009-2011 Barend Gehrels, Geodan, Amsterdam, the Netherlands.
+ Copyright (c) 2009-2011 Mateusz Loskot (mateusz_at_[hidden])
+ Copyright (c) 2009-2011 Bruno Lalande, Paris, France.
+
+ 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)
+=============================================================================/]
+
+[heading Behavior]
+[table
+[[Case] [Behavior] ]
+[[__2dim__][All combinations of: box, ring, polygon, multi_polygon]]
+[[__other__][Not supported]]
+
+]
+
+[heading Example]
+[sym_difference]
+[sym_difference_output]
+
+[heading See also]
+* [link geometry.reference.algorithms.difference.difference difference]
+* [link geometry.reference.algorithms.intersection.intersection intersection]
+* [link geometry.reference.algorithms.union.union_ union]
+

Added: trunk/libs/geometry/doc/ref/algorithms/union.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/ref/algorithms/union.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -0,0 +1,25 @@
+[/============================================================================
+ Boost.Geometry (aka GGL, Generic Geometry Library)
+
+ Copyright (c) 2009-2011 Barend Gehrels, Geodan, Amsterdam, the Netherlands.
+ Copyright (c) 2009-2011 Mateusz Loskot (mateusz_at_[hidden])
+ Copyright (c) 2009-2011 Bruno Lalande, Paris, France.
+
+ 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)
+=============================================================================/]
+
+[heading Behavior]
+[table
+[[Case] [Behavior] ]
+]
+
+[heading Example]
+[union]
+[union_output]
+
+[heading See also]
+* [link geometry.reference.algorithms.intersection.intersection intersection]
+* [link geometry.reference.algorithms.difference.difference difference]
+* [link geometry.reference.algorithms.sym_difference.sym_difference sym_difference (symmetric difference)]

Modified: trunk/libs/geometry/doc/ref/core/set_point.qbk
==============================================================================
--- trunk/libs/geometry/doc/ref/core/set_point.qbk (original)
+++ trunk/libs/geometry/doc/ref/core/set_point.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -8,6 +8,7 @@
   http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================/]
 
+[note If you host both the std:: library namespace and boost::geometry:: namespace set might become ambiguous, std::set is a collection. So don't do that or refer to geometry::set then explicitly.]
 
 [heading Behavior]
 [table

Modified: trunk/libs/geometry/doc/reference/append.qbk
==============================================================================
--- trunk/libs/geometry/doc/reference/append.qbk (original)
+++ trunk/libs/geometry/doc/reference/append.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -15,20 +15,20 @@
 [/ Generated from doxy/doxygen_output/xml/group__append.xml]
 [section:append append]
 
-Appends one or more points to a linestring, ring, polygon, multi.
+Appends one or more points to a linestring, ring, polygon, multi-geometry.
 
 [heading Synopsis]
-``template<typename Geometry, typename RoP>
-void append(Geometry & geometry, RoP const & range_or_point, int ring_index = -1, int multi_index = 0)``
+``template<typename Geometry, typename RangeOrPoint>
+void append(Geometry & geometry, RangeOrPoint const & range_or_point, int ring_index = -1, int multi_index = 0)``
 
 [heading Parameters]
 
 [table
 [[Type] [Concept] [Name] [Description] ]
-[[Geometry &] [] [geometry] [a geometry ]]
-[[RoP const &] [] [range_or_point] [the point or range to add ]]
-[[int] [] [ring_index] [the index of the ring in case of a polygon: exterior ring (-1, the default) or interior ring index ]]
-[[int] [] [multi_index] [reserved for multi polygons ]]
+[[Geometry &] [Any type fulfilling a Geometry Concept ] [geometry] [A model of the specified concept ]]
+[[RangeOrPoint const &] [Either a range or a point, fullfilling Boost.Range concept or Boost.Geometry Point Concept ] [range_or_point] [The point or range to add ]]
+[[int] [] [ring_index] [The index of the ring in case of a polygon: exterior ring (-1, the default) or interior ring index ]]
+[[int] [] [multi_index] [Reserved for multi polygons or multi linestrings]]
 ]
 
 
@@ -41,6 +41,8 @@
 
 `#include <boost/geometry/algorithms/append.hpp>`
 
+[include ref/algorithms/append.qbk]
+
 
 [endsect]
 

Modified: trunk/libs/geometry/doc/reference/assign.qbk
==============================================================================
--- trunk/libs/geometry/doc/reference/assign.qbk (original)
+++ trunk/libs/geometry/doc/reference/assign.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -39,11 +39,14 @@
 
 `#include <boost/geometry/algorithms/assign.hpp>`
 
+[heading Notes]
+[note Assign automatically clears the geometry before assigning (use append if you don't want that)]
 [heading Example]
 [assign_with_range] [assign_with_range_output]
 
 [heading See also]
 * [link geometry.reference.algorithms.make.make_1_with_a_range make]
+* [link geometry.reference.algorithms.append.append append]
 
 
 [endsect]

Modified: trunk/libs/geometry/doc/reference/difference.qbk
==============================================================================
--- trunk/libs/geometry/doc/reference/difference.qbk (original)
+++ trunk/libs/geometry/doc/reference/difference.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -30,7 +30,7 @@
 [[Type] [Concept] [Name] [Description] ]
 [[Geometry1 const &] [Any type fulfilling a Geometry Concept ] [geometry1] [A model of the specified concept ]]
 [[Geometry2 const &] [Any type fulfilling a Geometry Concept ] [geometry2] [A model of the specified concept ]]
-[[Collection &] [output collection, either a multi-geometry, or a std::vector<Geometry> / std::deque<Geometry> etc ] [output_collection] [the output collection ]]
+[[Collection &] [output collection, either a multi-geometry, or a std::vector<Geometry> / std::deque<Geometry> etc ] [output_collection] [the output collection]]
 ]
 
 
@@ -43,6 +43,8 @@
 
 `#include <boost/geometry/algorithms/difference.hpp>`
 
+[include ref/algorithms/difference.qbk]
+
 
 [endsect]
 

Modified: trunk/libs/geometry/doc/reference/sym_difference.qbk
==============================================================================
--- trunk/libs/geometry/doc/reference/sym_difference.qbk (original)
+++ trunk/libs/geometry/doc/reference/sym_difference.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -27,7 +27,7 @@
 [[Type] [Concept] [Name] [Description] ]
 [[Geometry1 const &] [Any type fulfilling a Geometry Concept ] [geometry1] [A model of the specified concept ]]
 [[Geometry2 const &] [Any type fulfilling a Geometry Concept ] [geometry2] [A model of the specified concept ]]
-[[Collection &] [output collection, either a multi-geometry, or a std::vector<Geometry> / std::deque<Geometry> etc ] [output_collection] [the output collection ]]
+[[Collection &] [output collection, either a multi-geometry, or a std::vector<Geometry> / std::deque<Geometry> etc ] [output_collection] [the output collection]]
 ]
 
 
@@ -40,6 +40,8 @@
 
 `#include <boost/geometry/algorithms/sym_difference.hpp>`
 
+[include ref/algorithms/sym_difference.qbk]
+
 
 [endsect]
 

Modified: trunk/libs/geometry/doc/reference/union.qbk
==============================================================================
--- trunk/libs/geometry/doc/reference/union.qbk (original)
+++ trunk/libs/geometry/doc/reference/union.qbk 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -40,6 +40,8 @@
 
 `#include <boost/geometry/algorithms/union.hpp>`
 
+[include ref/algorithms/union.qbk]
+
 
 [endsect]
 

Added: trunk/libs/geometry/doc/src/examples/algorithms/append.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/examples/algorithms/append.cpp 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -0,0 +1,59 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2011, 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)
+//
+// Quickbook Example
+
+//[append
+//` Shows usage of Boost.Geometry's append to append a point or a range to a polygon
+
+#include <iostream>
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/geometries/adapted/tuple_cartesian.hpp>
+
+#include <boost/assign.hpp>
+
+int main()
+{
+ using boost::assign::tuple_list_of;
+ using boost::make_tuple;
+ using boost::geometry::append;
+
+ typedef boost::geometry::model::polygon<boost::tuple<int, int> > polygon;
+
+ polygon poly;
+
+ // Append a range
+ append(poly, tuple_list_of(0, 0)(0, 10)(11, 11)(10, 0)); /*< tuple_list_of delivers a range and can therefore be used in boost::geometry::append >*/
+ // Append a point (in this case the closing point
+ append(poly, make_tuple(0, 0));
+
+ // Create an interior ring (append does not do this automatically)
+ boost::geometry::interior_rings(poly).resize(1);
+
+ // Append a range to the interior ring
+ append(poly, tuple_list_of(2, 2)(2, 5)(6, 6)(5, 2), 0);
+ // Append a point to the first interior ring
+ append(poly, make_tuple(2, 2), 0);
+
+ std::cout << boost::geometry::dsv(poly) << std::endl;
+
+ return 0;
+}
+
+//]
+
+
+//[append_output
+/*`
+Output:
+[pre
+(((0, 0), (0, 10), (11, 11), (10, 0), (0, 0)), ((2, 2), (2, 5), (6, 6), (5, 2), (2, 2)))
+]
+*/
+//]

Added: trunk/libs/geometry/doc/src/examples/algorithms/create_svg.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/examples/algorithms/create_svg.hpp 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -0,0 +1,46 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2011, 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)
+//
+// Code to create SVG for examples
+#ifndef CREATE_SVG_HPP
+#define CREATE_SVG_HPP
+
+#include <fstream>
+#include <boost/algorithm/string.hpp>
+#include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
+
+template <typename Geometry, typename Range>
+void create_svg(std::string const& filename, Geometry const& a, Geometry const& b, Range const& range)
+{
+ std::cout << std::endl << "[$img/algorithms/" << boost::replace_all_copy(filename, ".svg", ".png") << "]" << std::endl << std::endl;
+
+ typedef typename boost::geometry::point_type<Geometry>::type point_type;
+ std::ofstream svg(filename.c_str());
+
+ boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400);
+ mapper.add(a);
+ mapper.add(b);
+
+ mapper.map(a, "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:2");
+ mapper.map(b, "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:2");
+ int i = 0;
+ BOOST_FOREACH(Geometry const& g, range)
+ {
+ mapper.map(g, "opacity:0.8;fill:none;stroke:rgb(255,128,0);stroke-width:4;stroke-dasharray:1,7;stroke-linecap:round");
+ std::ostringstream out;
+ out << i++;
+ mapper.text(boost::geometry::make_centroid<point_type>(g), out.str(),
+ "fill:rgb(0,0,0);font-family:Arial;font-size:10px");
+ }
+}
+
+// NOTE: convert manually from svg to png using Inkscape ctrl-shift-E
+// and copy png to html/img/algorithms/
+
+
+#endif // CREATE_SVG_HPP
+

Added: trunk/libs/geometry/doc/src/examples/algorithms/difference.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/examples/algorithms/difference.cpp 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -0,0 +1,89 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2011, 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)
+//
+// Quickbook Example
+
+//[difference
+//` Shows how to subtract one polygon from another polygon
+
+#include <iostream>
+#include <list>
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
+
+#include <boost/foreach.hpp>
+/*<-*/ #include "create_svg.hpp" /*->*/
+
+int main()
+{
+ typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon;
+
+ polygon green, blue;
+
+ boost::geometry::read_wkt(
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
+ "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", green);
+
+ boost::geometry::read_wkt(
+ "POLYGON((4.0 -0.5 , 3.5 1.0 , 2.0 1.5 , 3.5 2.0 , 4.0 3.5 , 4.5 2.0 , 6.0 1.5 , 4.5 1.0 , 4.0 -0.5))", blue);
+
+ std::list<polygon> output;
+ boost::geometry::difference(green, blue, output);
+
+ int i = 0;
+ std::cout << "green - blue:" << std::endl;
+ BOOST_FOREACH(polygon const& p, output)
+ {
+ std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
+ }
+
+ /*<-*/ create_svg("difference_a.svg", green, blue, output); /*->*/
+ output.clear();
+ boost::geometry::difference(blue, green, output);
+
+ i = 0;
+ std::cout << "blue - green:" << std::endl;
+ BOOST_FOREACH(polygon const& p, output)
+ {
+ std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
+ }
+
+ /*<-*/ create_svg("difference_a.svg", green, blue, output); /*->*/
+ return 0;
+}
+
+//]
+
+
+//[difference_output
+/*`
+Output:
+[pre
+green - blue:
+0: 0.02375
+1: 0.542951
+2: 0.0149697
+3: 0.226855
+4: 0.839424
+
+[$img/algorithms/difference_a.png]
+
+blue - green:
+0: 0.525154
+1: 0.015
+2: 0.181136
+3: 0.128798
+4: 0.340083
+5: 0.307778
+
+[$img/algorithms/difference_b.png]
+]
+*/
+//]
+

Added: trunk/libs/geometry/doc/src/examples/algorithms/intersection_poly_poly.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/examples/algorithms/intersection_poly_poly.cpp 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -0,0 +1,65 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2011, 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)
+//
+// Quickbook Example
+
+//[intersection
+//` Shows the intersection of two polygons
+
+#include <iostream>
+#include <deque>
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
+
+#include <boost/foreach.hpp>
+/*<-*/ #include "create_svg.hpp" /*->*/
+
+int main()
+{
+ typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon;
+
+ polygon green, blue;
+
+ boost::geometry::read_wkt(
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
+ "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", green);
+
+ boost::geometry::read_wkt(
+ "POLYGON((4.0 -0.5 , 3.5 1.0 , 2.0 1.5 , 3.5 2.0 , 4.0 3.5 , 4.5 2.0 , 6.0 1.5 , 4.5 1.0 , 4.0 -0.5))", blue);
+
+ std::deque<polygon> output;
+ boost::geometry::intersection(green, blue, output);
+
+ int i = 0;
+ std::cout << "green && blue:" << std::endl;
+ BOOST_FOREACH(polygon const& p, output)
+ {
+ std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
+ }
+
+ /*<-*/ create_svg("intersection.svg", green, blue, output); /*->*/
+ return 0;
+}
+
+//]
+
+
+//[intersection_output
+/*`
+Output:
+[pre
+green && blue:
+0: 2.50205
+
+[$img/algorithms/intersection.png]
+
+]
+*/
+//]
+

Added: trunk/libs/geometry/doc/src/examples/algorithms/sym_difference.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/examples/algorithms/sym_difference.cpp 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -0,0 +1,75 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2011, 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)
+//
+// Quickbook Example
+
+//[sym_difference
+//` Shows how to calculate the symmetric difference (XOR) geometry of two polygons
+
+#include <iostream>
+#include <vector>
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
+
+#include <boost/foreach.hpp>
+/*<-*/ #include "create_svg.hpp" /*->*/
+
+int main()
+{
+ typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon;
+
+ polygon green, blue;
+
+ boost::geometry::read_wkt(
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
+ "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", green);
+
+ boost::geometry::read_wkt(
+ "POLYGON((4.0 -0.5 , 3.5 1.0 , 2.0 1.5 , 3.5 2.0 , 4.0 3.5 , 4.5 2.0 , 6.0 1.5 , 4.5 1.0 , 4.0 -0.5))", blue);
+
+ std::vector<polygon> output;
+ boost::geometry::sym_difference(green, blue, output);
+
+ int i = 0;
+ std::cout << "green XOR blue:" << std::endl;
+ BOOST_FOREACH(polygon const& p, output)
+ {
+ std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
+ }
+
+ /*<-*/ create_svg("sym_difference.svg", green, blue, output); /*->*/
+ return 0;
+}
+
+//]
+
+
+//[sym_difference_output
+/*`
+Output:
+[pre
+green XOR blue:
+0: 0.02375
+1: 0.542951
+2: 0.0149697
+3: 0.226855
+4: 0.839424
+5: 0.525154
+6: 0.015
+7: 0.181136
+8: 0.128798
+9: 0.340083
+10: 0.307778
+
+[$img/algorithms/sym_difference.png]
+
+]
+*/
+//]
+

Added: trunk/libs/geometry/doc/src/examples/algorithms/union.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/examples/algorithms/union.cpp 2011-02-24 17:31:37 EST (Thu, 24 Feb 2011)
@@ -0,0 +1,65 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2011, 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)
+//
+// Quickbook Example
+
+//[union
+//` Shows how to get a united geometry of two polygons
+
+#include <iostream>
+#include <vector>
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
+
+#include <boost/foreach.hpp>
+/*<-*/ #include "create_svg.hpp" /*->*/
+
+int main()
+{
+ typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon;
+
+ polygon green, blue;
+
+ boost::geometry::read_wkt(
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
+ "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", green);
+
+ boost::geometry::read_wkt(
+ "POLYGON((4.0 -0.5 , 3.5 1.0 , 2.0 1.5 , 3.5 2.0 , 4.0 3.5 , 4.5 2.0 , 6.0 1.5 , 4.5 1.0 , 4.0 -0.5))", blue);
+
+ std::vector<polygon> output;
+ boost::geometry::union_(green, blue, output);
+
+ int i = 0;
+ std::cout << "green || blue:" << std::endl;
+ BOOST_FOREACH(polygon const& p, output)
+ {
+ std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
+ }
+
+ /*<-*/ create_svg("union.svg", green, blue, output); /*->*/
+ return 0;
+}
+
+//]
+
+
+//[union_output
+/*`
+Output:
+[pre
+green || blue:
+0: 5.64795
+
+[$img/algorithms/union.png]
+
+]
+*/
+//]
+


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