From f3147001b5f89ea4499e1cb92e9b5afb8942487d Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Tue, 11 Feb 2014 23:08:32 +0100 Subject: [PATCH] [geometry] Splitted file rescale.hpp into different files: segment_ratio_type robust_point_type no_rescale_policy --- .../detail/has_self_intersections.hpp | 3 +- .../detail/overlay/clean_dups_and_spikes.hpp | 2 +- .../overlay/get_intersection_points.hpp | 3 +- .../detail/overlay/get_turn_info.hpp | 2 ++ .../detail/overlay/intersection_insert.hpp | 3 +- .../algorithms/detail/overlay/overlay.hpp | 3 +- .../detail/sections/sectionalize.hpp | 4 ++- .../boost/geometry/algorithms/difference.hpp | 1 + .../boost/geometry/algorithms/disjoint.hpp | 5 +-- .../boost/geometry/algorithms/intersects.hpp | 2 +- .../geometry/algorithms/sym_difference.hpp | 18 ++++------ include/boost/geometry/algorithms/touches.hpp | 1 + include/boost/geometry/algorithms/within.hpp | 2 ++ .../{rescale.hpp => no_rescale_policy.hpp} | 35 +++++++------------ .../policies/robustness/robust_point_type.hpp | 28 +++++++++++++++ .../robustness/segment_ratio_type.hpp | 28 +++++++++++++++ .../policies/robustness/zoom_to_robust.hpp | 4 ++- .../strategies/cartesian/cart_intersect.hpp | 5 ++- .../geometry/strategies/intersection.hpp | 1 + .../strategies/intersection_result.hpp | 1 - test/policies/rescale_policy.cpp | 13 +++---- 21 files changed, 107 insertions(+), 57 deletions(-) rename include/boost/geometry/policies/robustness/{rescale.hpp => no_rescale_policy.hpp} (64%) create mode 100644 include/boost/geometry/policies/robustness/robust_point_type.hpp create mode 100644 include/boost/geometry/policies/robustness/segment_ratio_type.hpp diff --git a/include/boost/geometry/algorithms/detail/has_self_intersections.hpp b/include/boost/geometry/algorithms/detail/has_self_intersections.hpp index bca4c870f..5dbde9e36 100644 --- a/include/boost/geometry/algorithms/detail/has_self_intersections.hpp +++ b/include/boost/geometry/algorithms/detail/has_self_intersections.hpp @@ -17,7 +17,8 @@ #include #include -#include +#include +#include #include diff --git a/include/boost/geometry/algorithms/detail/overlay/clean_dups_and_spikes.hpp b/include/boost/geometry/algorithms/detail/overlay/clean_dups_and_spikes.hpp index c3935c5c4..618f93675 100644 --- a/include/boost/geometry/algorithms/detail/overlay/clean_dups_and_spikes.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/clean_dups_and_spikes.hpp @@ -13,7 +13,7 @@ #include #include - +#include namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp b/include/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp index 47801f245..1552f8662 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp @@ -15,10 +15,9 @@ #include #include -#include - #include +#include namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp index 37fdb86a4..92d41c5a2 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp @@ -20,6 +20,8 @@ #include +#include + // Silence warning C4127: conditional expression is constant #if defined(_MSC_VER) diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp index 5b2d277d8..9b1498feb 100644 --- a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp @@ -29,7 +29,8 @@ #include #include -#include +#include +#include #include diff --git a/include/boost/geometry/algorithms/detail/overlay/overlay.hpp b/include/boost/geometry/algorithms/detail/overlay/overlay.hpp index f5c5beaa1..9e1cc7c87 100644 --- a/include/boost/geometry/algorithms/detail/overlay/overlay.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/overlay.hpp @@ -38,7 +38,8 @@ #include #include -#include +#include + #ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE # include diff --git a/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp b/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp index 7d5446771..024d6a6f2 100644 --- a/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp +++ b/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp @@ -32,15 +32,17 @@ #include #include -#include #include #include +#include +#include #include #include #include + namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/difference.hpp b/include/boost/geometry/algorithms/difference.hpp index d5b1831bf..a093c5ddd 100644 --- a/include/boost/geometry/algorithms/difference.hpp +++ b/include/boost/geometry/algorithms/difference.hpp @@ -12,6 +12,7 @@ #include #include +#include namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/disjoint.hpp b/include/boost/geometry/algorithms/disjoint.hpp index 51bf5640d..601b9f426 100644 --- a/include/boost/geometry/algorithms/disjoint.hpp +++ b/include/boost/geometry/algorithms/disjoint.hpp @@ -40,8 +40,6 @@ #include #include -#include - #include #include @@ -50,6 +48,9 @@ #include #include +#include +#include + namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/intersects.hpp b/include/boost/geometry/algorithms/intersects.hpp index 7436b83ea..dd89c7529 100644 --- a/include/boost/geometry/algorithms/intersects.hpp +++ b/include/boost/geometry/algorithms/intersects.hpp @@ -21,7 +21,7 @@ #include #include -#include +#include namespace boost { namespace geometry diff --git a/include/boost/geometry/algorithms/sym_difference.hpp b/include/boost/geometry/algorithms/sym_difference.hpp index 21bf51fb6..d922f7609 100644 --- a/include/boost/geometry/algorithms/sym_difference.hpp +++ b/include/boost/geometry/algorithms/sym_difference.hpp @@ -156,19 +156,13 @@ inline void sym_difference(Geometry1 const& geometry1, typedef typename boost::range_value::type geometry_out; concept::check(); -#if defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) - typedef typename geometry::rescale_policy_type - < - typename geometry::point_type::type // TODO from both - >::type - rescale_policy_type; - - rescale_policy_type rescale_policy - = get_rescale_policy(geometry1, geometry2); -#else - detail::no_rescale_policy rescale_policy; -#endif + typedef typename geometry::rescale_policy_type + < + typename geometry::point_type::type // TODO from both + >::type rescale_policy_type; + rescale_policy_type rescale_policy + = get_rescale_policy(geometry1, geometry2); detail::sym_difference::sym_difference_insert( geometry1, geometry2, rescale_policy, diff --git a/include/boost/geometry/algorithms/touches.hpp b/include/boost/geometry/algorithms/touches.hpp index 9992f6073..d1ba2bfb0 100644 --- a/include/boost/geometry/algorithms/touches.hpp +++ b/include/boost/geometry/algorithms/touches.hpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/geometry/algorithms/within.hpp b/include/boost/geometry/algorithms/within.hpp index fbb40b5e3..9756bf544 100644 --- a/include/boost/geometry/algorithms/within.hpp +++ b/include/boost/geometry/algorithms/within.hpp @@ -41,6 +41,8 @@ #include #include +#include +#include #include #include #include diff --git a/include/boost/geometry/policies/robustness/rescale.hpp b/include/boost/geometry/policies/robustness/no_rescale_policy.hpp similarity index 64% rename from include/boost/geometry/policies/robustness/rescale.hpp rename to include/boost/geometry/policies/robustness/no_rescale_policy.hpp index 67f826a68..14b08c103 100644 --- a/include/boost/geometry/policies/robustness/rescale.hpp +++ b/include/boost/geometry/policies/robustness/no_rescale_policy.hpp @@ -9,24 +9,26 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_HPP -#define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_HPP +#ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_NO_RESCALE_POLICY_HPP +#define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_NO_RESCALE_POLICY_HPP +#include + +#include #include +#include namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL - -// To be removed later, when we will initialize a real policy namespace detail { +// Probably this will be moved out of namespace detail struct no_rescale_policy { - - // We don't rescale but return the reference. zero cost. + // We don't rescale but return the reference of the input template inline Value const& apply(Value const& value) const { @@ -35,37 +37,26 @@ struct no_rescale_policy }; } // namespace detail +#endif -// Meta-function to define a robust point type -template -struct robust_point_type {}; - -// Meta-function to access segment-ratio -template -struct segment_ratio_type {}; - - -// For no-rescaling +// Implement meta-functions for this policy template struct robust_point_type { + // The point itself typedef Point type; }; -// Implementation for no-rescaling (using coordinate itself) template struct segment_ratio_type { + // The coordinate itself typedef typename geometry::coordinate_type::type coordinate_type; typedef segment_ratio type; -// typedef segment_ratio type; }; -#endif - }} // namespace boost::geometry - -#endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_HPP +#endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_NO_RESCALE_POLICY_HPP diff --git a/include/boost/geometry/policies/robustness/robust_point_type.hpp b/include/boost/geometry/policies/robustness/robust_point_type.hpp new file mode 100644 index 000000000..35f719865 --- /dev/null +++ b/include/boost/geometry/policies/robustness/robust_point_type.hpp @@ -0,0 +1,28 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013 Bruno Lalande, Paris, France. +// Copyright (c) 2013 Mateusz Loskot, London, UK. +// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. + +// 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) + +#ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_ROBUST_POINT_TYPE_HPP +#define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_ROBUST_POINT_TYPE_HPP + +#include + +namespace boost { namespace geometry +{ + +// Meta-function to typedef a robust point type for a policy +template +struct robust_point_type {}; //: not_implemented<> {}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_ROBUST_POINT_TYPE_HPP diff --git a/include/boost/geometry/policies/robustness/segment_ratio_type.hpp b/include/boost/geometry/policies/robustness/segment_ratio_type.hpp new file mode 100644 index 000000000..19e935bbb --- /dev/null +++ b/include/boost/geometry/policies/robustness/segment_ratio_type.hpp @@ -0,0 +1,28 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013 Bruno Lalande, Paris, France. +// Copyright (c) 2013 Mateusz Loskot, London, UK. +// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. + +// 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) + +#ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_SEGMENT_RATIO_TYPE_HPP +#define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_SEGMENT_RATIO_TYPE_HPP + +#include + +namespace boost { namespace geometry +{ + +// Meta-function to access segment-ratio for a policy +template +struct segment_ratio_type {}; // : not_implemented<> {}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_SEGMENT_RATIO_TYPE_HPP diff --git a/include/boost/geometry/policies/robustness/zoom_to_robust.hpp b/include/boost/geometry/policies/robustness/zoom_to_robust.hpp index 85f81e66a..eeff056c8 100644 --- a/include/boost/geometry/policies/robustness/zoom_to_robust.hpp +++ b/include/boost/geometry/policies/robustness/zoom_to_robust.hpp @@ -24,7 +24,9 @@ #include #include -#include +#include +#include +#include namespace boost { namespace geometry { diff --git a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp index 89d7b019a..f37344680 100644 --- a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp +++ b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp @@ -33,9 +33,8 @@ #include #include -// TODO move to policies folder -#include - +#include +#include #if defined(BOOST_GEOMETRY_DEBUG_ROBUSTNESS) diff --git a/include/boost/geometry/strategies/intersection.hpp b/include/boost/geometry/strategies/intersection.hpp index 233796a25..80c51b240 100644 --- a/include/boost/geometry/strategies/intersection.hpp +++ b/include/boost/geometry/strategies/intersection.hpp @@ -20,6 +20,7 @@ #include #include +#include namespace boost { namespace geometry diff --git a/include/boost/geometry/strategies/intersection_result.hpp b/include/boost/geometry/strategies/intersection_result.hpp index 6cc28ac99..e060dda77 100644 --- a/include/boost/geometry/strategies/intersection_result.hpp +++ b/include/boost/geometry/strategies/intersection_result.hpp @@ -15,7 +15,6 @@ #include -#include namespace boost { namespace geometry diff --git a/test/policies/rescale_policy.cpp b/test/policies/rescale_policy.cpp index 1f89af375..d2b399614 100644 --- a/test/policies/rescale_policy.cpp +++ b/test/policies/rescale_policy.cpp @@ -15,9 +15,6 @@ #include #include -#include -#include - #include #include @@ -25,10 +22,10 @@ #include #include #include - #include - +#include #include +#include #include @@ -217,7 +214,7 @@ typename bg::default_area_result::type test_one(std::string const& ca std::string const& wkt1, std::string const& wkt2, std::size_t expected_count = 0, int expected_point_count = 0, double expected_length_or_area = 0, - double percentage = 0.01, + double percentage = 0.02, bool debug = false) { Geometry1 geometry1; @@ -284,10 +281,10 @@ int test_main(int, char* []) { // test_all >(); test_all >(); -// test_all >(); + test_all >(); // test_all >(); // test_all >(); -// test_all >(); + test_all >(); return 0; }