Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70581 - trunk/libs/geometry/test/algorithms/overlay
From: barend.gehrels_at_[hidden]
Date: 2011-03-26 14:39:03


Author: barendgehrels
Date: 2011-03-26 14:39:02 EDT (Sat, 26 Mar 2011)
New Revision: 70581
URL: http://svn.boost.org/trac/boost/changeset/70581

Log:
Refactored to not use overlay (for intel compilers / Boost.Trunk regression report)
Text files modified:
   trunk/libs/geometry/test/algorithms/overlay/get_turns.cpp | 233 +++++++++++++++++++++++++--------------
   1 files changed, 146 insertions(+), 87 deletions(-)

Modified: trunk/libs/geometry/test/algorithms/overlay/get_turns.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/get_turns.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/get_turns.cpp 2011-03-26 14:39:02 EDT (Sat, 26 Mar 2011)
@@ -16,12 +16,20 @@
 
 #include <boost/geometry/strategies/strategies.hpp>
 
+#include <boost/geometry/algorithms/correct.hpp>
 #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
 
 #include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
 
+#include <boost/geometry/geometries/geometries.hpp>
+
+#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
+#include <boost/geometry/domains/gis/io/wkt/write_wkt.hpp>
+
+#if defined(TEST_WITH_SVG)
+# include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
+#endif
 
-#include <algorithms/overlay/overlay_common.hpp>
 #include <algorithms/overlay/overlay_cases.hpp>
 
 
@@ -33,12 +41,14 @@
 {
 };
 
+namespace detail
+{
 
 struct test_get_turns
 {
- template <typename G1, typename G2>
+ template<typename G1, typename G2>
     static void apply(std::string const& id,
- boost::tuple<int> const& expected_count_and_center,
+ int expected_count,
             G1 const& g1, G2 const& g2, double precision)
     {
             typedef bg::detail::overlay::turn_info
@@ -51,9 +61,9 @@
         bg::get_turns<false, false, bg::detail::overlay::assign_null_policy>(g1, g2, turns, policy);
 
         BOOST_CHECK_MESSAGE(
- expected_count_and_center.get<0>() == boost::size(turns),
+ expected_count == boost::size(turns),
                 "get_turns: " << id
- << " #turns expected: " << expected_count_and_center.get<0>()
+ << " #turns expected: " << expected_count
                 << " detected: " << boost::size(turns)
                 << " type: " << string_from_type
                     <typename bg::coordinate_type<G1>::type>::name()
@@ -112,6 +122,53 @@
     }
 };
 
+}
+
+template<typename G1, typename G2>
+struct test_get_turns
+{
+ inline static void apply(std::string const& id, int expected_count,
+ std::string const& wkt1, std::string const& wkt2,
+ double precision = 0.001)
+ {
+ if (wkt1.empty() || wkt2.empty())
+ {
+ return;
+ }
+
+ G1 g1;
+ bg::read_wkt(wkt1, g1);
+
+ G2 g2;
+ bg::read_wkt(wkt2, g2);
+
+ bg::correct(g1);
+ bg::correct(g2);
+
+ // Try the overlay-function in both ways
+ std::string caseid = id;
+ //goto case_reversed;
+
+#ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
+ std::cout << std::endl << std::endl << "# " << caseid << std::endl;
+#endif
+ detail::test_get_turns::apply(caseid, expected_count, g1, g2, precision);
+
+#ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
+ return;
+#endif
+
+ //case_reversed:
+#if ! defined(BOOST_GEOMETRY_TEST_OVERLAY_NOT_EXCHANGED)
+ caseid = id + "_rev";
+#ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
+ std::cout << std::endl << std::endl << "# " << caseid << std::endl;
+#endif
+
+ detail::test_get_turns::apply(caseid, expected_count, g2, g1, precision);
+#endif
+ }
+};
 
 #if ! defined(GEOMETRY_TEST_MULTI)
 template <typename T>
@@ -125,13 +182,15 @@
     // Expected count, average x, average y
     typedef boost::tuple<int> Tuple;
 
+#ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
     std::cout << string_from_type<T>::name() << std::endl;
+#endif
 
 
     // snl
     /*
- test_overlay<polygon, polygon, test_get_turns, Tuple>("snl_2",
- boost::make_tuple(5),
+ test_get_turns<polygon, polygon>::apply("snl_2",
+ 5,
         //snl-1
         //"POLYGON((182467 605842,182480 605954,182557 605958,182571 605958,182585 605958,182579 605843,182559 605838,182467 605842))",
         //"POLYGON((182499 605955,182511 605960,182536 605974,182536 605981,182536 606006,182563 606006,182610 605985,182613 605976,182620 605948,182628 605937,182631 605924,182639 605889,182634 605885,182603 605848,182579 605843,182585 605958,182571 605958,182557 605958,182499 605955))");
@@ -148,113 +207,113 @@
     */
 
     // 1-6
- test_overlay<polygon, polygon, test_get_turns, Tuple>("1", boost::make_tuple(6), case_1[0], case_1[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("2", boost::make_tuple(8),case_2[0], case_2[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("3", boost::make_tuple(4),case_3[0], case_3[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("4", boost::make_tuple(12),case_4[0], case_4[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("5", boost::make_tuple(17), case_5[0], case_5[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("6", boost::make_tuple(3),case_6[0], case_6[1]);
+ test_get_turns<polygon, polygon>::apply("1", 6, case_1[0], case_1[1]);
+ test_get_turns<polygon, polygon>::apply("2", 8, case_2[0], case_2[1]);
+ test_get_turns<polygon, polygon>::apply("3", 4, case_3[0], case_3[1]);
+ test_get_turns<polygon, polygon>::apply("4", 12, case_4[0], case_4[1]);
+ test_get_turns<polygon, polygon>::apply("5", 17, case_5[0], case_5[1]);
+ test_get_turns<polygon, polygon>::apply("6", 3, case_6[0], case_6[1]);
 
     // 7-12
- test_overlay<polygon, polygon, test_get_turns, Tuple>("7", boost::make_tuple(2),case_7[0], case_7[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("8", boost::make_tuple(2),case_8[0], case_8[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("9", boost::make_tuple(1),case_9[0], case_9[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("10", boost::make_tuple(3),case_10[0], case_10[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("11", boost::make_tuple(1),case_11[0], case_11[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("12", boost::make_tuple(8), case_12[0], case_12[1]);
+ test_get_turns<polygon, polygon>::apply("7", 2, case_7[0], case_7[1]);
+ test_get_turns<polygon, polygon>::apply("8", 2, case_8[0], case_8[1]);
+ test_get_turns<polygon, polygon>::apply("9", 1, case_9[0], case_9[1]);
+ test_get_turns<polygon, polygon>::apply("10", 3, case_10[0], case_10[1]);
+ test_get_turns<polygon, polygon>::apply("11", 1, case_11[0], case_11[1]);
+ test_get_turns<polygon, polygon>::apply("12", 8, case_12[0], case_12[1]);
 
     // 13-18
- test_overlay<polygon, polygon, test_get_turns, Tuple>("13", boost::make_tuple(2), case_13[0], case_13[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("14", boost::make_tuple(2),case_14[0], case_14[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("15", boost::make_tuple(2),case_15[0], case_15[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("16", boost::make_tuple(4),case_16[0], case_16[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("17", boost::make_tuple(2),case_17[0], case_17[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("18", boost::make_tuple(4),case_18[0], case_18[1]);
+ test_get_turns<polygon, polygon>::apply("13", 2, case_13[0], case_13[1]);
+ test_get_turns<polygon, polygon>::apply("14", 2, case_14[0], case_14[1]);
+ test_get_turns<polygon, polygon>::apply("15", 2, case_15[0], case_15[1]);
+ test_get_turns<polygon, polygon>::apply("16", 4, case_16[0], case_16[1]);
+ test_get_turns<polygon, polygon>::apply("17", 2, case_17[0], case_17[1]);
+ test_get_turns<polygon, polygon>::apply("18", 4, case_18[0], case_18[1]);
 
     // 19-24
- test_overlay<polygon, polygon, test_get_turns, Tuple>("19", boost::make_tuple(2),case_19[0], case_19[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("20", boost::make_tuple(3),case_20[0], case_20[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("21", boost::make_tuple(3),case_21[0], case_21[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("22", boost::make_tuple(1), case_22[0], case_22[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("23", boost::make_tuple(2), case_23[0], case_23[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("24", boost::make_tuple(1), case_24[0], case_24[1]);
+ test_get_turns<polygon, polygon>::apply("19", 2, case_19[0], case_19[1]);
+ test_get_turns<polygon, polygon>::apply("20", 3, case_20[0], case_20[1]);
+ test_get_turns<polygon, polygon>::apply("21", 3, case_21[0], case_21[1]);
+ test_get_turns<polygon, polygon>::apply("22", 1, case_22[0], case_22[1]);
+ test_get_turns<polygon, polygon>::apply("23", 2, case_23[0], case_23[1]);
+ test_get_turns<polygon, polygon>::apply("24", 1, case_24[0], case_24[1]);
 
     // 25-30
- test_overlay<polygon, polygon, test_get_turns, Tuple>("25", boost::make_tuple(1),case_25[0], case_25[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("26", boost::make_tuple(1),case_26[0], case_26[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("27", boost::make_tuple(2), case_27[0], case_27[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("28", boost::make_tuple(2), case_28[0], case_28[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("29", boost::make_tuple(2), case_29[0], case_29[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("30", boost::make_tuple(2), case_30[0], case_30[1]);
+ test_get_turns<polygon, polygon>::apply("25", 1, case_25[0], case_25[1]);
+ test_get_turns<polygon, polygon>::apply("26", 1, case_26[0], case_26[1]);
+ test_get_turns<polygon, polygon>::apply("27", 2, case_27[0], case_27[1]);
+ test_get_turns<polygon, polygon>::apply("28", 2, case_28[0], case_28[1]);
+ test_get_turns<polygon, polygon>::apply("29", 2, case_29[0], case_29[1]);
+ test_get_turns<polygon, polygon>::apply("30", 2, case_30[0], case_30[1]);
 
     // 31-36
- test_overlay<polygon, polygon, test_get_turns, Tuple>("31", boost::make_tuple(1),case_31[0], case_31[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("32", boost::make_tuple(1),case_32[0], case_32[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("33", boost::make_tuple(1),case_33[0], case_33[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("34", boost::make_tuple(2), case_34[0], case_34[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("35", boost::make_tuple(1), case_35[0], case_35[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("36", boost::make_tuple(3), case_36[0], case_36[1]);
+ test_get_turns<polygon, polygon>::apply("31", 1, case_31[0], case_31[1]);
+ test_get_turns<polygon, polygon>::apply("32", 1, case_32[0], case_32[1]);
+ test_get_turns<polygon, polygon>::apply("33", 1, case_33[0], case_33[1]);
+ test_get_turns<polygon, polygon>::apply("34", 2, case_34[0], case_34[1]);
+ test_get_turns<polygon, polygon>::apply("35", 1, case_35[0], case_35[1]);
+ test_get_turns<polygon, polygon>::apply("36", 3, case_36[0], case_36[1]);
 
     // 37-42
- test_overlay<polygon, polygon, test_get_turns, Tuple>("37", boost::make_tuple(3), case_37[0], case_37[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("38", boost::make_tuple(3), case_38[0], case_38[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("39", boost::make_tuple(4),case_39[0], case_39[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("40", boost::make_tuple(3),case_40[0], case_40[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("41", boost::make_tuple(5),case_41[0], case_41[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("42", boost::make_tuple(5),case_42[0], case_42[1]);
+ test_get_turns<polygon, polygon>::apply("37", 3, case_37[0], case_37[1]);
+ test_get_turns<polygon, polygon>::apply("38", 3, case_38[0], case_38[1]);
+ test_get_turns<polygon, polygon>::apply("39", 4, case_39[0], case_39[1]);
+ test_get_turns<polygon, polygon>::apply("40", 3, case_40[0], case_40[1]);
+ test_get_turns<polygon, polygon>::apply("41", 5, case_41[0], case_41[1]);
+ test_get_turns<polygon, polygon>::apply("42", 5, case_42[0], case_42[1]);
 
     // 43-48
- test_overlay<polygon, polygon, test_get_turns, Tuple>("43", boost::make_tuple(4), case_43[0], case_43[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("44", boost::make_tuple(4),case_44[0], case_44[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("45", boost::make_tuple(4),case_45[0], case_45[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("46", boost::make_tuple(4), case_46[0], case_46[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("47", boost::make_tuple(5), case_47[0], case_47[1]);
+ test_get_turns<polygon, polygon>::apply("43", 4, case_43[0], case_43[1]);
+ test_get_turns<polygon, polygon>::apply("44", 4, case_44[0], case_44[1]);
+ test_get_turns<polygon, polygon>::apply("45", 4, case_45[0], case_45[1]);
+ test_get_turns<polygon, polygon>::apply("46", 4, case_46[0], case_46[1]);
+ test_get_turns<polygon, polygon>::apply("47", 5, case_47[0], case_47[1]);
 
     // 49-54
- test_overlay<polygon, polygon, test_get_turns, Tuple>("50", boost::make_tuple(4), case_50[0], case_50[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("51", boost::make_tuple(3), case_51[0], case_51[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("52", boost::make_tuple(8), case_52[0], case_52[1]);
+ test_get_turns<polygon, polygon>::apply("50", 4, case_50[0], case_50[1]);
+ test_get_turns<polygon, polygon>::apply("51", 3, case_51[0], case_51[1]);
+ test_get_turns<polygon, polygon>::apply("52", 8, case_52[0], case_52[1]);
     // A touching point interior/ring exterior/ring can be represented in two ways:
- test_overlay<polygon, polygon, test_get_turns, Tuple>("53a", boost::make_tuple(4), case_53[0], case_53[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("53b", boost::make_tuple(4), case_53[0], case_53[2]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("54aa", boost::make_tuple(13), case_54[0], case_54[2]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("54ab", boost::make_tuple(13), case_54[0], case_54[3]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("54ba", boost::make_tuple(13), case_54[1], case_54[2]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("54bb", boost::make_tuple(13), case_54[1], case_54[3]);
+ test_get_turns<polygon, polygon>::apply("53a", 4, case_53[0], case_53[1]);
+ test_get_turns<polygon, polygon>::apply("53b", 4, case_53[0], case_53[2]);
+ test_get_turns<polygon, polygon>::apply("54aa", 13, case_54[0], case_54[2]);
+ test_get_turns<polygon, polygon>::apply("54ab", 13, case_54[0], case_54[3]);
+ test_get_turns<polygon, polygon>::apply("54ba", 13, case_54[1], case_54[2]);
+ test_get_turns<polygon, polygon>::apply("54bb", 13, case_54[1], case_54[3]);
 
- test_overlay<polygon, polygon, test_get_turns, Tuple>("55", boost::make_tuple(12), case_55[0], case_55[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("56", boost::make_tuple(9), case_56[0], case_56[1]);
+ test_get_turns<polygon, polygon>::apply("55", 12, case_55[0], case_55[1]);
+ test_get_turns<polygon, polygon>::apply("56", 9, case_56[0], case_56[1]);
 
 
     // other
- test_overlay<polygon, polygon, test_get_turns, Tuple>("many_situations", boost::make_tuple(31), case_many_situations[0], case_many_situations[1]);
+ test_get_turns<polygon, polygon>::apply("many_situations", 31, case_many_situations[0], case_many_situations[1]);
 
 
     // ticket#17
- test_overlay<polygon, box, test_get_turns, Tuple>("ticket_17", boost::make_tuple(6), ticket_17[0], ticket_17[1]);
+ test_get_turns<polygon, box>::apply("ticket_17", 6, ticket_17[0], ticket_17[1]);
 
     // GGL-mailing list
- test_overlay<polygon, polygon, test_get_turns, Tuple>("ggl_list_20110306_javier",
- boost::make_tuple(4),
+ test_get_turns<polygon, polygon>::apply("ggl_list_20110306_javier",
+ 4,
             ggl_list_20110306_javier[0], ggl_list_20110306_javier[1]);
 
 
     // pies
- test_overlay<polygon, polygon, test_get_turns, Tuple>("pie_23_16_16", boost::make_tuple(3), pie_23_16_16[0], pie_23_16_16[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("pie_16_4_12", boost::make_tuple(2), pie_16_4_12[0], pie_16_4_12[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("pie_4_13_15", boost::make_tuple(3), pie_4_13_15[0], pie_4_13_15[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("pie_16_2_15_0", boost::make_tuple(2), pie_16_2_15_0[0], pie_16_2_15_0[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("pie_20_20_7_100", boost::make_tuple(3), pie_20_20_7_100[0], pie_20_20_7_100[1]);
- test_overlay<polygon, polygon, test_get_turns, Tuple>("pie_23_23_3_2000", boost::make_tuple(5), pie_23_23_3_2000[0], pie_23_23_3_2000[1]);
+ test_get_turns<polygon, polygon>::apply("pie_23_16_16", 3, pie_23_16_16[0], pie_23_16_16[1]);
+ test_get_turns<polygon, polygon>::apply("pie_16_4_12", 2, pie_16_4_12[0], pie_16_4_12[1]);
+ test_get_turns<polygon, polygon>::apply("pie_4_13_15", 3, pie_4_13_15[0], pie_4_13_15[1]);
+ test_get_turns<polygon, polygon>::apply("pie_16_2_15_0", 2, pie_16_2_15_0[0], pie_16_2_15_0[1]);
+ test_get_turns<polygon, polygon>::apply("pie_20_20_7_100", 3, pie_20_20_7_100[0], pie_20_20_7_100[1]);
+ test_get_turns<polygon, polygon>::apply("pie_23_23_3_2000", 5, pie_23_23_3_2000[0], pie_23_23_3_2000[1]);
 
 
     // line-line
- test_overlay<linestring, linestring, test_get_turns, Tuple>("lineline1", boost::make_tuple(3), line_line1[0], line_line1[1]);
+ test_get_turns<linestring, linestring>::apply("lineline1", 3, line_line1[0], line_line1[1]);
 
     // line-polygon
- test_overlay<linestring, polygon, test_get_turns, Tuple>("line_poly1", boost::make_tuple(4), line_line1[0], case_1[1]);
- test_overlay<linestring, polygon, test_get_turns, Tuple>("line_poly2", boost::make_tuple(4), line_line1[1], case_1[0]);
- test_overlay<polygon, linestring, test_get_turns, Tuple>("poly_line", boost::make_tuple(4), case_1[1], line_line1[0]);
+ test_get_turns<linestring, polygon>::apply("line_poly1", 4, line_line1[0], case_1[1]);
+ test_get_turns<linestring, polygon>::apply("line_poly2", 4, line_line1[1], case_1[0]);
+ test_get_turns<polygon, linestring>::apply("poly_line", 4, case_1[1], line_line1[0]);
 }
 
 
@@ -266,12 +325,12 @@
     typedef boost::tuple<int> Tuple;
 
 
- test_overlay<polygon, polygon, test_get_turns, Tuple>("ccw_1",
- boost::make_tuple(6),
+ test_get_turns<polygon, polygon>::apply("ccw_1",
+ 6,
                 ccw_case_1[0], ccw_case_1[1]);
 
- test_overlay<polygon, polygon, test_get_turns, Tuple>("ccw_9",
- boost::make_tuple(1),
+ test_get_turns<polygon, polygon>::apply("ccw_9",
+ 1,
                 case_9[0], case_9[1]);
 
 }
@@ -283,12 +342,12 @@
     typedef bg::model::polygon<P, true, false> polygon;
     typedef boost::tuple<int> Tuple;
 
- test_overlay<polygon, polygon, test_get_turns, Tuple>("open_1",
- boost::make_tuple(6),
+ test_get_turns<polygon, polygon>::apply("open_1",
+ 6,
                 open_case_1[0], open_case_1[1]);
 
- test_overlay<polygon, polygon, test_get_turns, Tuple>("open_9",
- boost::make_tuple(1),
+ test_get_turns<polygon, polygon>::apply("open_9",
+ 1,
                 open_case_9[0], open_case_9[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