diff --git a/test/algorithms/difference.cpp b/test/algorithms/difference.cpp index 3cf8d4349..7aa8f0d8a 100644 --- a/test/algorithms/difference.cpp +++ b/test/algorithms/difference.cpp @@ -38,7 +38,7 @@ void test_all() typedef bg::model::polygon

polygon; typedef bg::model::ring

ring; - bool const is_float = + bool const is_float = boost::is_same::type, float>::value; test_one("simplex_normal", @@ -211,17 +211,17 @@ void test_all() 5, 22, 1.1901714, 5, 27, 1.6701714); test_one( - "ring_star_ring", example_ring, example_star, + "ring_star_ring", example_ring, example_star, 5, 22, 1.6701714, 5, 27, 1.1901714); static std::string const clip = "POLYGON((2.5 0.5,5.5 2.5))"; - test_one("star_box", + test_one("star_box", clip, example_star, 4, 11, 2.833333, 4, 11, 0.833333); - test_one("box_star", - example_star, clip, + test_one("box_star", + example_star, clip, 4, 11, 0.833333, 4, 11, 2.833333); } @@ -247,16 +247,16 @@ void test_all() static std::string const clip = "POLYGON((2 2,4 4))"; - test_one("simplex_multi_box_mp", + test_one("simplex_multi_box_mp", clip, case_multi_simplex[0], 3, 11, 4.53333, 3, 11, 8.53333); - test_one("simplex_multi_mp_box", - case_multi_simplex[0], clip, + test_one("simplex_multi_mp_box", + case_multi_simplex[0], clip, 3, 11, 8.53333, 3, 11, 4.53333); } /*** - Experimental (cut), does not work: + Experimental (cut), does not work: test_one( "polygon_pseudo_line", "POLYGON((0 0,0 4,4 4,4 0,0 0))", @@ -362,12 +362,15 @@ int test_main(int, char* []) //test_difference_parcel_precision(); //test_difference_parcel_precision(); - test_all >(); test_all >(); +#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) + test_all >(); + #ifdef HAVE_TTMATH test_all >(); //test_difference_parcel_precision(); +#endif #endif return 0; diff --git a/test/algorithms/intersection.cpp b/test/algorithms/intersection.cpp index cb822fc8f..71344b7ee 100644 --- a/test/algorithms/intersection.cpp +++ b/test/algorithms/intersection.cpp @@ -40,7 +40,7 @@ void test_areal() simplex_normal[0], polygon_empty, 0, 0, 0.0); test_one("simplex_with_empty_2", - polygon_empty, simplex_normal[0], + polygon_empty, simplex_normal[0], 0, 0, 0.0); test_one("simplex_normal", @@ -204,7 +204,7 @@ void test_areal_clip() 2, 13, 1.0744456); test_one("clip_poly7", "Box(0 0, 3 3)", - "POLYGON((2 2, 1 4, 2 4, 3 3, 2 2))", + "POLYGON((2 2, 1 4, 2 4, 3 3, 2 2))", 1, 4, 0.75); } @@ -253,7 +253,7 @@ void test_all() #if defined(TEST_FAIL_DIFFERENT_ORIENTATIONS) // Should NOT compile - // NOTE: this can probably be relaxed later on. + // NOTE: this can probably be relaxed later on. test_one("simplex_normal", simplex_normal[0], simplex_normal[1], 1, 7, 5.47363293); @@ -287,7 +287,7 @@ void test_all() // Outputting two lines (because of 3-4-5 constructions (0.3,0.4,0.5) // which occur 4 times, the length is expected to be 2.0) test_one("llb_2", "LINESTRING(1.7 1.6,2.3 2.4,2.9 1.6,3.5 2.4,4.1 1.6)", clip, 2, 6, 4 * 0.5); - + // linear test_one("llp1", "LINESTRING(0 0,1 1)", "LINESTRING(0 1,1 0)", 1, 1, 0); test_one("ssp1", "LINESTRING(0 0,1 1)", "LINESTRING(0 1,1 0)", 1, 1, 0); @@ -348,14 +348,18 @@ void test_pointer_version() int test_main(int, char* []) { - test_all >(); test_all >(); +#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) + test_all >(); + #if defined(HAVE_TTMATH) test_all >(); #endif //test_pointer_version(); +#endif + return 0; } diff --git a/test/algorithms/overlay/Jamfile.v2 b/test/algorithms/overlay/Jamfile.v2 index 5d5628a2f..bd31c9168 100644 --- a/test/algorithms/overlay/Jamfile.v2 +++ b/test/algorithms/overlay/Jamfile.v2 @@ -10,11 +10,10 @@ test-suite boost-geometry-algorithms-overlay : [ run assemble.cpp ] # [ run ccw_traverse.cpp ] -# [ run dissolver.cpp ] [ run get_turn_info.cpp ] [ run get_turns.cpp ] # [ run relative_order.cpp ] + [ run select_rings.cpp ] # [ run self_intersection_points.cpp ] -# [ run split_rings.cpp ] [ run traverse.cpp ] ; diff --git a/test/algorithms/overlay/overlay.sln b/test/algorithms/overlay/overlay.sln index 9c8b6f7e7..9bbaff6f2 100644 --- a/test/algorithms/overlay/overlay.sln +++ b/test/algorithms/overlay/overlay.sln @@ -12,10 +12,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "relative_order", "relative_ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assemble", "assemble.vcproj", "{306E829F-ACEC-42D5-B1D4-2531B2F56EA3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dissolver", "dissolver.vcproj", "{6CCB145C-C682-4B9F-8672-6D04DB5C76DD}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ccw_traverse", "ccw_traverse.vcproj", "{BA789719-B2FC-405A-9258-E9E4ABCE1791}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "select_rings", "select_rings.vcproj", "{029117F7-1D6A-4A05-9FB7-93E09751C909}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -46,14 +46,14 @@ Global {306E829F-ACEC-42D5-B1D4-2531B2F56EA3}.Debug|Win32.Build.0 = Debug|Win32 {306E829F-ACEC-42D5-B1D4-2531B2F56EA3}.Release|Win32.ActiveCfg = Release|Win32 {306E829F-ACEC-42D5-B1D4-2531B2F56EA3}.Release|Win32.Build.0 = Release|Win32 - {6CCB145C-C682-4B9F-8672-6D04DB5C76DD}.Debug|Win32.ActiveCfg = Debug|Win32 - {6CCB145C-C682-4B9F-8672-6D04DB5C76DD}.Debug|Win32.Build.0 = Debug|Win32 - {6CCB145C-C682-4B9F-8672-6D04DB5C76DD}.Release|Win32.ActiveCfg = Release|Win32 - {6CCB145C-C682-4B9F-8672-6D04DB5C76DD}.Release|Win32.Build.0 = Release|Win32 {BA789719-B2FC-405A-9258-E9E4ABCE1791}.Debug|Win32.ActiveCfg = Debug|Win32 {BA789719-B2FC-405A-9258-E9E4ABCE1791}.Debug|Win32.Build.0 = Debug|Win32 {BA789719-B2FC-405A-9258-E9E4ABCE1791}.Release|Win32.ActiveCfg = Release|Win32 {BA789719-B2FC-405A-9258-E9E4ABCE1791}.Release|Win32.Build.0 = Release|Win32 + {029117F7-1D6A-4A05-9FB7-93E09751C909}.Debug|Win32.ActiveCfg = Debug|Win32 + {029117F7-1D6A-4A05-9FB7-93E09751C909}.Debug|Win32.Build.0 = Debug|Win32 + {029117F7-1D6A-4A05-9FB7-93E09751C909}.Release|Win32.ActiveCfg = Release|Win32 + {029117F7-1D6A-4A05-9FB7-93E09751C909}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/algorithms/overlay/robustness/interior_triangles.cpp b/test/algorithms/overlay/robustness/interior_triangles.cpp index ac1fbb323..eff646dd2 100644 --- a/test/algorithms/overlay/robustness/interior_triangles.cpp +++ b/test/algorithms/overlay/robustness/interior_triangles.cpp @@ -33,13 +33,13 @@ template -inline void make_polygon(Polygon& polygon, int count_x, int count_y, int index) +inline void make_polygon(Polygon& polygon, int count_x, int count_y, int index, int offset) { typedef typename bg::point_type::type point_type; bg::exterior_ring(polygon).push_back(point_type(0, 0)); bg::exterior_ring(polygon).push_back(point_type(0, count_y * 10)); - bg::exterior_ring(polygon).push_back(point_type(count_x * 10, count_y * 10)); - bg::exterior_ring(polygon).push_back(point_type(count_x * 10, 0)); + bg::exterior_ring(polygon).push_back(point_type(count_x * 10 + 10, count_y * 10)); + bg::exterior_ring(polygon).push_back(point_type(count_x * 10 + 10, 0)); bg::exterior_ring(polygon).push_back(point_type(0, 0)); for(int j = 0; j < count_x; ++j) @@ -47,10 +47,10 @@ inline void make_polygon(Polygon& polygon, int count_x, int count_y, int index) for(int k = 0; k < count_y; ++k) { polygon.inners().push_back(Polygon::inner_container_type::value_type()); - polygon.inners().back().push_back(point_type(j * 10 + 1, k * 10 + 1)); - polygon.inners().back().push_back(point_type(j * 10 + 7, k * 10 + 5 + index)); - polygon.inners().back().push_back(point_type(j * 10 + 5 + index, k * 10 + 7)); - polygon.inners().back().push_back(point_type(j * 10 + 1, k * 10 + 1)); + polygon.inners().back().push_back(point_type(offset + j * 10 + 1, k * 10 + 1)); + polygon.inners().back().push_back(point_type(offset + j * 10 + 7, k * 10 + 5 + index)); + polygon.inners().back().push_back(point_type(offset + j * 10 + 5 + index, k * 10 + 7)); + polygon.inners().back().push_back(point_type(offset + j * 10 + 1, k * 10 + 1)); } } bg::correct(polygon); @@ -59,12 +59,12 @@ inline void make_polygon(Polygon& polygon, int count_x, int count_y, int index) template -void test_star_comb(int count_x, int count_y, p_q_settings const& settings) +void test_star_comb(int count_x, int count_y, int offset, p_q_settings const& settings) { Polygon p, q; - make_polygon(p, count_x, count_y, 0); - make_polygon(q, count_x, count_y, 1); + make_polygon(p, count_x, count_y, 0, 0); + make_polygon(q, count_x, count_y, 1, offset); std::ostringstream out; out << "interior_triangles"; @@ -77,7 +77,7 @@ void test_star_comb(int count_x, int count_y, p_q_settings const& settings) template -void test_all(int count, int count_x, int count_y, p_q_settings const& settings) +void test_all(int count, int count_x, int count_y, int offset, p_q_settings const& settings) { boost::timer t; @@ -90,7 +90,7 @@ void test_all(int count, int count_x, int count_y, p_q_settings const& settings) int index = 0; for(int i = 0; i < count; i++) { - test_star_comb(count_x, count_y, settings); + test_star_comb(count_x, count_y, offset, settings); } std::cout << " type: " << string_from_type::name() @@ -104,6 +104,7 @@ int main(int argc, char** argv) namespace po = boost::program_options; po::options_description description("=== interior_triangles ===\nAllowed options"); + int offset = 0; int count = 1; int count_x = 10; int count_y = 10; @@ -116,6 +117,7 @@ int main(int argc, char** argv) ("count", po::value(&count)->default_value(1), "Number of tests") ("count_x", po::value(&count_x)->default_value(10), "Triangle count in x-direction") ("count_y", po::value(&count_y)->default_value(10), "Triangle count in y-direction") + ("offset", po::value(&offset)->default_value(0), "Offset of second triangle in x-direction") ("diff", po::value(&settings.also_difference)->default_value(false), "Include testing on difference") ("ccw", po::value(&ccw)->default_value(false), "Counter clockwise polygons") ("open", po::value(&open)->default_value(false), "Open polygons") @@ -135,19 +137,19 @@ int main(int argc, char** argv) if (ccw && open) { - test_all(count, count_x, count_y, settings); + test_all(count, count_x, count_y, offset, settings); } else if (ccw) { - test_all(count, count_x, count_y, settings); + test_all(count, count_x, count_y, offset, settings); } else if (open) { - test_all(count, count_x, count_y, settings); + test_all(count, count_x, count_y, offset, settings); } else { - test_all(count, count_x, count_y, settings); + test_all(count, count_x, count_y, offset, settings); } #if defined(HAVE_TTMATH) diff --git a/test/algorithms/overlay/select_rings.cpp b/test/algorithms/overlay/select_rings.cpp new file mode 100644 index 000000000..330f4717b --- /dev/null +++ b/test/algorithms/overlay/select_rings.cpp @@ -0,0 +1,82 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels, Geodan B.V. 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) + +#include + +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + + + +template +void test_geometry(std::string const& wkt1, std::string const& wkt2, Vector const& expected) +{ + typedef bg::detail::overlay::ring_properties::type> properties; + + Geometry1 geometry1; + Geometry2 geometry2; + + bg::read_wkt(wkt1, geometry1); + bg::read_wkt(wkt2, geometry2); + + typedef std::map map_type; + map_type selected; + std::map empty; + + bg::detail::overlay::select_rings(geometry1, geometry2, empty, selected); + + BOOST_CHECK_EQUAL(selected.size(), expected.size()); + + if (selected.size() <= expected.size()) + { + BOOST_AUTO(eit, expected.begin()); + for(typename map_type::const_iterator it = selected.begin(); it != selected.end(); ++it, ++eit) + { + bg::ring_identifier const ring_id = it->first; + BOOST_CHECK_EQUAL(ring_id.source_index, eit->template get<0>()); + BOOST_CHECK_EQUAL(ring_id.multi_index, eit->template get<1>()); + BOOST_CHECK_EQUAL(ring_id.ring_index, eit->template get<2>()); + BOOST_CHECK_EQUAL(it->second.within_code, eit->template get<3>()); + } + } +} + + + + +template +void test_all() +{ + // Point in correct clockwise ring -> should return true + test_geometry, bg::model::polygon

, bg::overlay_union>( + winded[0], winded[1], + boost::assign::tuple_list_of(0,-1,-1,-1)(0,-1,0,-1)(0,-1,1,-1)(0,-1,3,-1)(1,-1,1,-1)(1,-1,2,-1)); + test_geometry, bg::model::polygon

, bg::overlay_intersection>( + winded[0], winded[1], + boost::assign::tuple_list_of(0,-1,2,1)(1,-1,-1,1)(1,-1,0,1)(1,-1,3,1)); +} + + + + +int test_main( int , char* [] ) +{ + test_all >(); + + return 0; +} diff --git a/test/algorithms/overlay/select_rings.vcproj b/test/algorithms/overlay/select_rings.vcproj new file mode 100644 index 000000000..ff025e1a5 --- /dev/null +++ b/test/algorithms/overlay/select_rings.vcproj @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/algorithms/overlay/traverse.cpp b/test/algorithms/overlay/traverse.cpp index 29a2f8b9f..ffffd71ba 100644 --- a/test/algorithms/overlay/traverse.cpp +++ b/test/algorithms/overlay/traverse.cpp @@ -77,7 +77,7 @@ template > struct test_traverse { - + static void apply(std::string const& id, int expected_count, double expected_area, G1 const& g1, G2 const& g2, @@ -897,7 +897,7 @@ void test_open() typedef bg::model::polygon < - bg::model::point, + bg::model::point, true, false > polygon; @@ -915,7 +915,7 @@ void test_ccw() typedef bg::model::polygon < - bg::model::point, + bg::model::point, false, true > polygon; @@ -929,6 +929,9 @@ void test_ccw() int test_main(int, char* []) { +#if defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) + test_all(); +#else test_all(); test_all(); test_open(); @@ -940,6 +943,7 @@ int test_main(int, char* []) #ifdef HAVE_TTMATH test_all(); +#endif #endif return 0; diff --git a/test/algorithms/union.cpp b/test/algorithms/union.cpp index 0e6fb9b37..c8e4f94ff 100644 --- a/test/algorithms/union.cpp +++ b/test/algorithms/union.cpp @@ -47,7 +47,7 @@ void test_areal() simplex_normal[0], polygon_empty, 1, 0, 4, 8.0); test_one("simplex_with_empty_2", - polygon_empty, simplex_normal[0], + polygon_empty, simplex_normal[0], 1, 0, 4, 8.0); test_one("star_ring", example_star, example_ring, @@ -239,8 +239,8 @@ void test_areal() isovist1[0], isovist1[1], 1, 0, - tn == std::string("f") ? 71 - : tn == std::string("d") ? 72 + tn == std::string("f") ? 71 + : tn == std::string("d") ? 72 : 73, 313.36036462); } @@ -305,12 +305,15 @@ void test_all() int test_main(int, char* []) { - test_all >(); test_all >(); + +#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) + test_all >(); //test_all >(); #if defined(HAVE_TTMATH) test_all >(); +#endif #endif return 0; diff --git a/test/geometry_test_common.hpp b/test/geometry_test_common.hpp index 79b5e2975..ba75946b9 100644 --- a/test/geometry_test_common.hpp +++ b/test/geometry_test_common.hpp @@ -19,6 +19,15 @@ //#pragma warning( disable : 4305 ) #endif // defined(_MSC_VER) +#include + + +#if defined(BOOST_INTEL_CXX_VERSION) +#define BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE +#endif + + + #include diff --git a/test/multi/algorithms/multi_intersection.cpp b/test/multi/algorithms/multi_intersection.cpp index 7fa887449..34d9efef7 100644 --- a/test/multi/algorithms/multi_intersection.cpp +++ b/test/multi/algorithms/multi_intersection.cpp @@ -145,6 +145,8 @@ void test_all() typedef bg::model::multi_polygon multi_polygon; test_areal(); +#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) + typedef bg::model::ring ring_ccw; typedef bg::model::polygon polygon_ccw; typedef bg::model::multi_polygon multi_polygon_ccw; @@ -167,7 +169,7 @@ void test_all() typedef bg::model::multi_linestring multi_linestring; test_linear(); - +#endif // linear