// Generic Geometry Library - Star Comb Overlay Comparisons // // Copyright Barend Gehrels, 2009, Geodan Holding 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 namespace gtl = boost::polygon; using namespace boost::polygon::operators; #include #include namespace boost { namespace polygon { typedef int Unit; typedef point_data Point; typedef interval_data Interval; typedef rectangle_data Rectangle; typedef polygon_90_data Polygon; typedef polygon_90_with_holes_data PolygonWithHoles; typedef polygon_45_data Polygon45; typedef polygon_45_with_holes_data Polygon45WithHoles; typedef polygon_90_set_data PolygonSet; typedef polygon_45_set_data Polygon45Set; typedef polygon_data PolygonRandom; typedef polygon_with_holes_data PolygonRandomWithHoles; typedef polygon_set_data PolygonRandomSet; typedef axis_transformation AxisTransform; typedef transformation Transform; } } using namespace std; #include "../common/starcomb.hpp" template void add(Polygon& polygon, double x, double y, int) { typedef typename ggl::point_type::type p; ggl::exterior_ring(polygon).push_back(ggl::make

(x, y)); } int main(int argc, char** argv) { try { bool do_union; int testcount, starcount, combcount; double factor1, factor2; parse(argc, argv, testcount, starcount, combcount, factor1, factor2, do_union); typedef ggl::point_xy point_type; typedef ggl::polygon polygon_type; const int K = 2; polygon_type gglpolys[K]; for(int i = 0; i < K; ++i) { ggl::exterior_ring(gglpolys[i]).push_back(ggl::make (0, 0)); ggl::exterior_ring(gglpolys[i]).push_back(ggl::make (0, combcount * 20)); ggl::exterior_ring(gglpolys[i]).push_back(ggl::make (starcount * 20, combcount * 20)); ggl::exterior_ring(gglpolys[i]).push_back(ggl::make (starcount * 20, 0)); ggl::exterior_ring(gglpolys[i]).push_back(ggl::make (0, 0)); for(int j = 0; j < starcount; ++j) { for(int k = 0; k < combcount; ++k) { gglpolys[i].inners().push_back(polygon_type::inner_container_type::value_type()); gglpolys[i].inners().back().push_back(ggl::make (j * 10 + 1, k * 10 + 1)); gglpolys[i].inners().back().push_back(ggl::make (j * 10 + 7, k * 10 + 5+i)); gglpolys[i].inners().back().push_back(ggl::make (j * 10 + 5+i, k * 10 + 7)); gglpolys[i].inners().back().push_back(ggl::make (j * 10 + 1, k * 10 + 1)); } } std::cout << ggl::area(gglpolys[i]) << std::endl; } double area = 0; boost::timer t; for (int i = 0; i < testcount; i++) { std::vector v; if (do_union) { ggl::union_inserter(gglpolys[0], gglpolys[1], std::back_inserter(v)); } else { ggl::intersection_inserter(gglpolys[0], gglpolys[1], std::back_inserter(v)); } double a = 0.0; for (std::vector::const_iterator pit = v.begin(); pit != v.end(); ++pit) { a += ggl::area(*pit); #ifdef _DEBUG std::cout << ggl::wkt(*pit) << std::endl; #endif } area += a; } report("GGL", area, t); } catch(std::exception const& e) { std::cout << "GGL: " << e.what() << std::endl; } catch(...) { std::cout << "GGL exception..." << std::endl; } return 0; }