Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69585 - in trunk/libs/geometry: doc/other doc/src/examples/algorithms test/algorithms test/algorithms/overlay/robustness
From: barend.gehrels_at_[hidden]
Date: 2011-03-05 17:28:27


Author: barendgehrels
Date: 2011-03-05 17:28:20 EST (Sat, 05 Mar 2011)
New Revision: 69585
URL: http://svn.boost.org/trac/boost/changeset/69585

Log:
Small addition/update in examples
Updated various intersection tests
Added:
   trunk/libs/geometry/doc/src/examples/algorithms/clear.cpp (contents, props changed)
Binary files modified:
   trunk/libs/geometry/doc/other/status.xls
Text files modified:
   trunk/libs/geometry/doc/src/examples/algorithms/Jamfile.v2 | 2 ++
   trunk/libs/geometry/doc/src/examples/algorithms/difference.cpp | 2 +-
   trunk/libs/geometry/test/algorithms/intersection.cpp | 4 ++--
   trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp | 4 ++--
   trunk/libs/geometry/test/algorithms/overlay/robustness/recursive_polygons.cpp | 23 ++++++++++++++++++++++-
   trunk/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp | 6 +++++-
   6 files changed, 34 insertions(+), 7 deletions(-)

Modified: trunk/libs/geometry/doc/other/status.xls
==============================================================================
Binary files. No diff available.

Modified: trunk/libs/geometry/doc/src/examples/algorithms/Jamfile.v2
==============================================================================
--- trunk/libs/geometry/doc/src/examples/algorithms/Jamfile.v2 (original)
+++ trunk/libs/geometry/doc/src/examples/algorithms/Jamfile.v2 2011-03-05 17:28:20 EST (Sat, 05 Mar 2011)
@@ -22,6 +22,8 @@
 exe assign_point_from_index : assign_point_from_index.cpp ;
 exe assign_point_to_index : assign_point_to_index.cpp ;
 
+exe clear : clear.cpp ;
+
 exe for_each_point : for_each_point.cpp ;
 exe for_each_point_const : for_each_point_const.cpp ;
 exe for_each_segment_const : for_each_segment_const.cpp ;

Added: trunk/libs/geometry/doc/src/examples/algorithms/clear.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/examples/algorithms/clear.cpp 2011-03-05 17:28:20 EST (Sat, 05 Mar 2011)
@@ -0,0 +1,62 @@
+// 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
+
+//[clear
+//` Shows how to clear a ring or 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;
+
+ typedef boost::tuple<float, float> point;
+ typedef boost::geometry::model::polygon<point> polygon;
+ typedef boost::geometry::model::ring<point> ring;
+
+ polygon poly;
+
+ // Fill the polygon (using its own methods + Boost.Assign)
+ poly.outer() = tuple_list_of(0, 0)(0, 10)(11, 11)(0, 0);
+ poly.inners().push_back(tuple_list_of(0, 0)(0, 10)(11, 11)(0, 0));
+
+ std::cout << boost::geometry::dsv(poly) << std::endl;
+ boost::geometry::clear(poly);
+ std::cout << boost::geometry::dsv(poly) << std::endl;
+
+ // Create a ring using Boost.Assign
+ ring r = tuple_list_of(0, 0)(0, 9)(8, 8)(0, 0);
+
+ std::cout << boost::geometry::dsv(r) << std::endl;
+ boost::geometry::clear(r);
+ std::cout << boost::geometry::dsv(r) << std::endl;
+
+ return 0;
+}
+
+//]
+
+
+//[clear_output
+/*`
+Output:
+[pre
+(((0, 0), (0, 10), (11, 11), (0, 0)), ((0, 0), (0, 10), (11, 11), (0, 0)))
+(())
+((0, 0), (0, 9), (8, 8), (0, 0))
+()
+]
+*/
+//]

Modified: trunk/libs/geometry/doc/src/examples/algorithms/difference.cpp
==============================================================================
--- trunk/libs/geometry/doc/src/examples/algorithms/difference.cpp (original)
+++ trunk/libs/geometry/doc/src/examples/algorithms/difference.cpp 2011-03-05 17:28:20 EST (Sat, 05 Mar 2011)
@@ -54,7 +54,7 @@
         std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
     }
 
- /*<-*/ create_svg("difference_a.svg", green, blue, output); /*->*/
+ /*<-*/ create_svg("difference_b.svg", green, blue, output); /*->*/
     return 0;
 }
 

Modified: trunk/libs/geometry/test/algorithms/intersection.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/intersection.cpp (original)
+++ trunk/libs/geometry/test/algorithms/intersection.cpp 2011-03-05 17:28:20 EST (Sat, 05 Mar 2011)
@@ -32,9 +32,9 @@
 template <typename Polygon>
 void test_areal()
 {
- /*test_one<Polygon, Polygon, Polygon>("pie_2_3_23_0",
+ test_one<Polygon, Polygon, Polygon>("pie_2_3_23_0",
         pie_2_3_23_0[0], pie_2_3_23_0[1],
- 1, 4, 163292.677335535, 0.01);*/
+ 1, 4, 163292.679042133, 0.1);
 
     test_one<Polygon, Polygon, Polygon>("simplex_with_empty_1",
         simplex_normal[0], polygon_empty,

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp 2011-03-05 17:28:20 EST (Sat, 05 Mar 2011)
@@ -255,10 +255,10 @@
 
         description.add_options()
             ("help", "Help message")
- ("svg", po::value<bool>(&svg)->default_value(false), "Create an SVG filename for all tests")
             ("multi", po::value<bool>(&multi)->default_value(false), "Multiple tangencies at one point")
             ("ccw", po::value<bool>(&ccw)->default_value(false), "Counter clockwise polygons")
- ("open", po::value<bool>(&open)->default_value(false), "Open polytons")
+ ("open", po::value<bool>(&open)->default_value(false), "Open polygons")
+ ("svg", po::value<bool>(&svg)->default_value(false), "Create an SVG filename for all tests")
         ;
 
         po::variables_map varmap;

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/recursive_polygons.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/recursive_polygons.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/recursive_polygons.cpp 2011-03-05 17:28:20 EST (Sat, 05 Mar 2011)
@@ -160,6 +160,8 @@
         int seed = static_cast<unsigned int>(std::time(0));
         int level = 3;
         int field_size = 10;
+ bool ccw = false;
+ bool open = false;
         bool svg = false;
         std::string form = "box";
 
@@ -170,6 +172,8 @@
             ("level", po::value<int>(&level)->default_value(3), "Level to reach (higher->slower)")
             ("size", po::value<int>(&field_size)->default_value(10), "Size of the field")
             ("form", po::value<std::string>(&form)->default_value("box"), "Form of the polygons (box, triangle)")
+ ("ccw", po::value<bool>(&ccw)->default_value(false), "Counter clockwise polygons")
+ ("open", po::value<bool>(&open)->default_value(false), "Open polygons")
             ("svg", po::value<bool>(&svg)->default_value(false), "Create an SVG filename for all tests")
         ;
 
@@ -183,8 +187,25 @@
             return 1;
         }
 
+ bool triangular = form != "box";
 
- test_all<double, true, true>(seed, count, field_size, svg, level, form != "box");
+
+ if (ccw && open)
+ {
+ test_all<double, false, false>(seed, count, field_size, svg, level, triangular);
+ }
+ else if (ccw)
+ {
+ test_all<double, false, true>(seed, count, field_size, svg, level, triangular);
+ }
+ else if (open)
+ {
+ test_all<double, true, false>(seed, count, field_size, svg, level, triangular);
+ }
+ else
+ {
+ test_all<double, true, true>(seed, count, field_size, svg, level, triangular);
+ }
 
 #if defined(HAVE_TTMATH)
         // test_all<ttmath_big, true, true>(seed, count, max, svg, level);

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp 2011-03-05 17:28:20 EST (Sat, 05 Mar 2011)
@@ -48,7 +48,7 @@
     CalculationType area_q = bg::area(q);
 
     bg::intersection(p, q, out_i);
- CalculationType area_i = abs(bg::area(out_i)); // TEMP abs call, TODO solve this
+ CalculationType area_i = bg::area(out_i);
 
     bg::union_(p, q, out_u);
     CalculationType area_u = bg::area(out_u);
@@ -77,6 +77,8 @@
             result = false;
             svg = true;
         }
+ bg::unique(out_i);
+ bg::unique(out_u);
 
         std::cout
             << "type: " << string_from_type<CalculationType>::name()
@@ -94,6 +96,8 @@
             << std::setprecision(20)
             << " p: " << bg::wkt(p) << std::endl
             << " q: " << bg::wkt(q) << std::endl
+ << " i: " << bg::wkt(out_i) << std::endl
+ << " u: " << bg::wkt(out_u) << std::endl
             ;
 
     }


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