|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66580 - in sandbox/geometry/libs/geometry/test: algorithms/overlay algorithms/overlay/robustness multi/algorithms/overlay
From: barend.gehrels_at_[hidden]
Date: 2010-11-14 16:06:58
Author: barendgehrels
Date: 2010-11-14 16:06:57 EST (Sun, 14 Nov 2010)
New Revision: 66580
URL: http://svn.boost.org/trac/boost/changeset/66580
Log:
Added multi-polygon self-tangent pie-test
Added test-cases for these
Text files modified:
sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp | 66 +++++++++++++++++++++++++++++++--------
sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp | 21 +++++++----
sandbox/geometry/libs/geometry/test/algorithms/overlay/traverse.cpp | 3 +
sandbox/geometry/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp | 32 ++++++++++++++++---
sandbox/geometry/libs/geometry/test/multi/algorithms/overlay/multi_traverse.cpp | 37 +++++++++++++++++++++-
5 files changed, 130 insertions(+), 29 deletions(-)
Modified: sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp 2010-11-14 16:06:57 EST (Sun, 14 Nov 2010)
@@ -17,6 +17,7 @@
#include <test_overlay_p_q.hpp>
#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/multi/multi.hpp>
template <typename Polygon>
@@ -61,11 +62,12 @@
template <typename T>
-void test_pie(int total_segment_count, T factor_p, T factor_q)
+void test_pie(int total_segment_count, T factor_p, T factor_q, bool svg)
{
boost::timer t;
typedef boost::geometry::point_xy<T> point_type;
typedef boost::geometry::polygon<point_type> polygon;
+ typedef boost::geometry::multi_polygon<polygon> multi_polygon;
int good_count = 0;
int bad_count = 0;
@@ -78,21 +80,55 @@
{
for (int offset = 1; offset < total_segment_count; offset++)
{
- for (int y = 0; y <= 2500; y += 500)
+ //for (int y = 0; y <= 2500; y += 500)
+ int y = 0;
{
polygon q;
make_pie(q, b, offset, y, factor_q, total_segment_count);
- std::ostringstream out;
- out << "pie_" << a << "_" << b << "_" << offset << "_" << y;
-
- if (test_overlay_p_q<polygon, T>(out.str(), p, q, false, 0.01))
- {
- good_count++;
- }
- else
+ // multi-polygon:
+ //for (int c = o
+ int left = total_segment_count - b - 2;
+ //std::cout << a << " " << b << " " << left << std::endl;
+ for (int c = 2; c < left; c++)
{
- bad_count++;
+ polygon q2;
+ make_pie(q2, c, offset + b + 1, y, factor_q, total_segment_count);
+
+ std::ostringstream out;
+ out << "pie_" << a << "_" << b << "_" << offset << "_" << y
+ << "_" << c
+ ;
+
+ bool good = false;
+ bool one_with_self_tangency = false;
+
+ // Represent as either multi-polygon, or as single-self-touching-polygon
+ if (one_with_self_tangency)
+ {
+ polygon q1 = q;
+ for (unsigned int i = 1; i < q2.outer().size(); i++)
+ {
+ q1.outer().push_back(q2.outer()[i]);
+ }
+ good = test_overlay_p_q<polygon, T>(out.str(), p, q1, svg, 0.01);
+ }
+ else
+ {
+ multi_polygon mq;
+ mq.push_back(q);
+ mq.push_back(q2);
+ good = test_overlay_p_q<polygon, T>(out.str(), p, mq, svg, 0.01);
+ }
+
+ if (good)
+ {
+ good_count++;
+ }
+ else
+ {
+ bad_count++;
+ }
}
}
}
@@ -106,17 +142,19 @@
template <typename T>
-void test_all()
+void test_all(bool svg)
{
- test_pie<T>(24, 0.55, 0.45);
+ test_pie<T>(24, 0.55, 0.45, svg);
}
int main(int argc, char** argv)
{
try
{
+ bool svg = argc > 1 && std::string(argv[1]) == std::string("svg");
+
//test_all<float>();
- test_all<double>();
+ test_all<double>(svg);
//test_all<long double>();
#if defined(HAVE_CLN)
Modified: sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp 2010-11-14 16:06:57 EST (Sun, 14 Nov 2010)
@@ -19,6 +19,9 @@
#include <boost/geometry/geometry.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
+
#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
#include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
@@ -26,7 +29,9 @@
template <typename OutputType, typename CalculationType, typename G1, typename G2>
-static bool test_overlay_p_q(std::string const& caseid, G1 const& p, G2 const& q, bool svg, double tolerance)
+static bool test_overlay_p_q(std::string const& caseid,
+ G1 const& p, G2 const& q,
+ bool svg, double tolerance, bool force_output = false)
{
bool result = true;
@@ -67,12 +72,14 @@
}
double diff = (area_p + area_q) - area_u - area_i;
- if (std::abs(diff) > tolerance
- // for creating SVG-selection: || area_i > 2.0e+006
- )
+ bool wrong = std::abs(diff) > tolerance;
+ if (wrong || force_output)
{
- result = false;
- svg = true;
+ if (wrong)
+ {
+ result = false;
+ svg = true;
+ }
std::cout
<< "type: " << string_from_type<CalculationType>::name()
@@ -115,14 +122,12 @@
for (typename std::vector<OutputType>::const_iterator it = out_i.begin();
it != out_i.end(); ++it)
{
- //mapper.map(*it, "opacity:0.6;fill:none;stroke:rgb(255,0,0);stroke-width:3");
mapper.map(*it, "fill-opacity:0.1;stroke-opacity:0.4;fill:rgb(255,0,0);"
"stroke:rgb(255,0,0);stroke-width:4");
}
for (typename std::vector<OutputType>::const_iterator it = out_u.begin();
it != out_u.end(); ++it)
{
- //mapper.map(*it, "opacity:0.6;fill:none;stroke:rgb(255,0,255);stroke-width:3");
mapper.map(*it, "fill-opacity:0.1;stroke-opacity:0.4;fill:rgb(255,0,0);"
"stroke:rgb(255,0,255);stroke-width:4");
Modified: sandbox/geometry/libs/geometry/test/algorithms/overlay/traverse.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/overlay/traverse.cpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/overlay/traverse.cpp 2010-11-14 16:06:57 EST (Sun, 14 Nov 2010)
@@ -41,6 +41,9 @@
#include <boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp>
#include <boost/geometry/algorithms/detail/overlay/traverse.hpp>
+#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
+
+
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/algorithms/correct.hpp>
Modified: sandbox/geometry/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp (original)
+++ sandbox/geometry/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp 2010-11-14 16:06:57 EST (Sun, 14 Nov 2010)
@@ -362,13 +362,35 @@
"MULTIPOLYGON(((0 7,0 8,1 8,1 7,0 7)),((5 3,4 3,4 4,6 4,6 3,7 3,6 2,5 2,5 3)),((8 2,8 3,9 2,8 2)),((1 1,2 2,2 1,1 1)),((2 1,3 1,2 0,1 0,2 1)),((2 3,3 4,3 3,2 3)),((1 9,2 8,1 8,1 9)),((2 10,2 9,1 9,1 10,2 10)),((9 7,9 8,10 8,10 7,9 7)),((6 0,6 1,7 1,7 0,6 0)),((8 0,9 1,9 0,8 0)),((1 6,1 5,0 5,1 6)),((0 2,1 1,0 1,0 2)),((1 3,2 3,2 2,1 2,1 3)),((5 1,5 0,4 0,4 1,3 1,4 2,5 2,6 1,5 1)),((1 3,0 3,0 4,1 4,1 3)),((3 6,4 5,2 5,3 6)),((9 2,10 2,10 1,9 1,9 2)),((7 5,6 4,6 5,7 6,8 6,8 5,7 5)),((7 4,8 5,8.5 4.5,9 5,9 4,8 4,8.5 3.5,9 4,10 3,7 3,7 4)),((1 6,1 7,3 7,3 8,4 7,5 7,6 8,6 10,7 9,8 10,9 10,9 9,8 9,8 8,7 8,6 7,6 6,1 6)))"
};
-static std::string case_recursive_boxes_4[2] =
+static std::string pie_21_7_21_0_3[2] =
{
- // SQL Server
- "MULTIPOLYGON(((3 4,3 5,4 5,3 4)),((2 5,3 6,3 5,2 4,2 5)),((1 1,0 1,0 10,2 10,3 9,3 10,9 10,9 9,8 9,8 7,7 7,7 6,5 6,6 5,9 8,8 8,10 10,10 7,9 7,9 6,10 7,10 5,9 4,10 4,10 0,5 0,5 1,4 0,3 0,3 1,2 1,2 0,0 0,1 1),(4 3,4 6,1 6,2 5,1 5,1 4,3 4,4 3),(3.5 7.5,4 7,5 7,5 8,4 8,3.5 7.5),(1 8,2 8,2 9,1 8,1 9,0.5 8.5,1 8),(6 1,7 1,7 2,6 1),(7 3,7 4,6 3,7 3),(3 2,3.5 1.5,4 2,3 2),(2 2,2 3,1.5 2.5,2 2),(7 8,7 9,6.5 8.5,7 8)))",
- "MULTIPOLYGON(((1 0,0 0,1 1,0 1,1 2,1 3,0 3,0 5,0.5 4.5,2 6,1 6,1 5,0 5,0 7,1 7,1 8,3 8,3 9,0 9,0 10,1 10,1.5 9.5,2 10,4 10,3.5 9.5,4 9,5 10,6 10,6.5 9.5,7 10,9 10,10 9,9 9,9.5 8.5,10 9,10 8,9 8,10 7,10 5,8 5,7.5 4.5,8 4,9 5,10 4,10 3,9 3,9 2,10 2,10 1,8 1,8 0,6 0,6 1,5 1,5 0,2 0,3 1,2 1,2 0,1 0),(5 7,5 8,6 8,6 9,5 8,5 9,4.5 8.5,5 8,4.5 7.5,5 7),(7 8,8 8,8 9,7 9,7 8),(2.5 6.5,3 7,4 7,4 8,3 7,2 7,2.5 6.5),(4 1,4 2,4.5 1.5,5 2,4 2,3.5 1.5,4 1),(2 4,3 5,2 5,2 4),(4 4,3 4,3 3,4 4),(4 5,4 6,3 6,4 5),(6 2,7 3,6 3,6 2),(7.5 1.5,8 2,7 2,7.5 1.5)),((0.5 8.5,1 9,1 8,0 8,0 9,0.5 8.5)))"
+ "MULTIPOLYGON(((2500 2500,2500 3875,2855 3828,3187 3690,3472 3472,3690 3187,3828 2855,3875 2500,3828 2144,3690 1812,3472 1527,3187 1309,2855 1171,2499 1125,2144 1171,1812 1309,1527 1527,1309 1812,1171 2144,1125 2499,1171 2855,1309 3187,2500 2500)))",
+ "MULTIPOLYGON(((2500 2500,1704 3295,1937 3474,2208 3586,2499 3625,2791 3586,3062 3474,3295 3295,2500 2500)),((2500 2500,3586 2791,3625 2500,3586 2208,2500 2500)))"
+};
+
+static std::string pie_23_19_5_0_2[2] =
+{
+ "MULTIPOLYGON(((2500 2500,2500 3875,2855 3828,3187 3690,3472 3472,3690 3187,3828 2855,3875 2500,3828 2144,3690 1812,3472 1527,3187 1309,2855 1171,2499 1125,2144 1171,1812 1309,1527 1527,1309 1812,1171 2144,1125 2499,1171 2855,1309 3187,1527 3472,1812 3690,2500 2500)))",
+ "MULTIPOLYGON(((2500 2500,3586 2791,3625 2500,3586 2208,3474 1937,3295 1704,3062 1525,2791 1413,2499 1375,2208 1413,1937 1525,1704 1704,1525 1937,1413 2208,1375 2500,1413 2791,1525 3062,1704 3295,1937 3474,2208 3586,2500 2500)),((2500 2500,2791 3586,3062 3474,2500 2500)))"
+};
+
+static std::string pie_7_14_5_0_7[2] =
+{
+ "MULTIPOLYGON(((2500 2500,2500 3875,2855 3828,3187 3690,3472 3472,3690 3187,3828 2855,3875 2500,2500 2500)))",
+ "MULTIPOLYGON(((2500 2500,3586 2791,3625 2500,3586 2208,3474 1937,3295 1704,3062 1525,2791 1413,2499 1375,2208 1413,1937 1525,1704 1704,1525 1937,1413 2208,1375 2500,2500 2500)),((2500 2500,1525 3062,1704 3295,1937 3474,2208 3586,2499 3625,2791 3586,3062 3474,2500 2500)))"
+};
+
+static std::string pie_16_16_9_0_2[2] =
+{
+ "MULTIPOLYGON(((2500 2500,2500 3875,2855 3828,3187 3690,3472 3472,3690 3187,3828 2855,3875 2500,3828 2144,3690 1812,3472 1527,3187 1309,2855 1171,2499 1125,2144 1171,1812 1309,1527 1527,2500 2500)))",
+ "MULTIPOLYGON(((2500 2500,3295 1704,3062 1525,2791 1413,2499 1375,2208 1413,1937 1525,1704 1704,1525 1937,1413 2208,1375 2500,1413 2791,1525 3062,1704 3295,1937 3474,2208 3586,2499 3625,2500 2500)),((2500 2500,3062 3474,3295 3295,2500 2500)))"
+};
+
+static std::string pie_7_2_1_0_15[2] =
+{
+ "MULTIPOLYGON(((2500 2500,2500 3875,2855 3828,3187 3690,3472 3472,3690 3187,3828 2855,3875 2500,2500 2500)))",
+ "MULTIPOLYGON(((2500 2500,2791 3586,3062 3474,2500 2500)),((2500 2500,3474 3062,3586 2791,3625 2500,3586 2208,3474 1937,3295 1704,3062 1525,2791 1413,2499 1375,2208 1413,1937 1525,1704 1704,1525 1937,1413 2208,1375 2500,2500 2500)))"
};
-
#endif // BOOST_GEOMETRY_TEST_MULTI_OVERLAY_CASES_HPP
Modified: sandbox/geometry/libs/geometry/test/multi/algorithms/overlay/multi_traverse.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/multi/algorithms/overlay/multi_traverse.cpp (original)
+++ sandbox/geometry/libs/geometry/test/multi/algorithms/overlay/multi_traverse.cpp 2010-11-14 16:06:57 EST (Sun, 14 Nov 2010)
@@ -103,14 +103,12 @@
// #72, note that it intersects into 2 shapes,
// the third one is done by assemble (see intersection #72)
-//wrong:
test_overlay<multi_polygon, multi_polygon,
test_traverse<ov::operation_intersection>, Tuple>
(
"case_72_multi", boost::make_tuple(2, 1.35),
case_72_multi[0], case_72_multi[1]
);
-//return;
test_overlay<multi_polygon, multi_polygon,
test_traverse<ov::operation_intersection>, Tuple>
@@ -443,6 +441,41 @@
"case_recursive_boxes_3", boost::make_tuple(8, 49.5),
case_recursive_boxes_3[0], case_recursive_boxes_3[1]
);
+
+ test_overlay<multi_polygon, multi_polygon,
+ test_traverse<ov::operation_intersection>, Tuple>
+ (
+ "pie_21_7_21_0_3", boost::make_tuple(2, 818824.56678),
+ pie_21_7_21_0_3[0], pie_21_7_21_0_3[1]
+ );
+
+ test_overlay<multi_polygon, multi_polygon,
+ test_traverse<ov::operation_intersection>, Tuple>
+ (
+ "pie_23_19_5_0_2", boost::make_tuple(2, 2948602.3911823),
+ pie_23_19_5_0_2[0], pie_23_19_5_0_2[1]
+ );
+ test_overlay<multi_polygon, multi_polygon,
+ test_traverse<ov::operation_intersection>, Tuple>
+ (
+ "pie_7_14_5_0_7", boost::make_tuple(2, 490804.56678),
+ pie_7_14_5_0_7[0], pie_7_14_5_0_7[1]
+ );
+ test_overlay<multi_polygon, multi_polygon,
+ test_traverse<ov::operation_intersection>, Tuple>
+ (
+ "pie_16_16_9_0_2", boost::make_tuple(2, 1146795),
+ pie_16_16_9_0_2[0], pie_16_16_9_0_2[1]
+ );
+return;
+wrong:
+ test_overlay<multi_polygon, multi_polygon,
+ test_traverse<ov::operation_intersection>, Tuple>
+ (
+ "pie_7_2_1_0_15", boost::make_tuple(2, 1146795),
+ pie_7_2_1_0_15[0], pie_7_2_1_0_15[1]
+ );
+
}
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