diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-03-21 15:45:20 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-03-21 15:46:37 +0900 |
commit | 733b5d5ae2c5d625211e2985ac25728ac3f54883 (patch) | |
tree | a5b214744b256f07e1dc2bd7273035a7808c659f /boost/geometry/algorithms/detail/overlay/overlay.hpp | |
parent | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (diff) | |
download | boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.gz boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.bz2 boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.zip |
Imported Upstream version 1.58.0upstream/1.58.0
Change-Id: If0072143aa26874812e0db6872e1efb10a3e5e94
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/geometry/algorithms/detail/overlay/overlay.hpp')
-rw-r--r-- | boost/geometry/algorithms/detail/overlay/overlay.hpp | 118 |
1 files changed, 43 insertions, 75 deletions
diff --git a/boost/geometry/algorithms/detail/overlay/overlay.hpp b/boost/geometry/algorithms/detail/overlay/overlay.hpp index 44b5a0df3c..a2f52848d1 100644 --- a/boost/geometry/algorithms/detail/overlay/overlay.hpp +++ b/boost/geometry/algorithms/detail/overlay/overlay.hpp @@ -44,10 +44,6 @@ # include <boost/geometry/io/dsv/write.hpp> #endif -#ifdef BOOST_GEOMETRY_TIME_OVERLAY -# include <boost/timer.hpp> -#endif - namespace boost { namespace geometry { @@ -57,19 +53,10 @@ namespace boost { namespace geometry namespace detail { namespace overlay { -// Skip for assemble process -template <typename TurnInfo> -inline bool skip(TurnInfo const& turn_info) -{ - return (turn_info.discarded || turn_info.both(operation_union)) - && ! turn_info.any_blocked() - && ! turn_info.both(operation_intersection) - ; -} - -template <typename TurnPoints, typename Map> -inline void map_turns(Map& map, TurnPoints const& turn_points) +template <typename TurnPoints, typename TurnInfoMap> +inline void get_ring_turn_info(TurnInfoMap& turn_info_map, + TurnPoints const& turn_points) { typedef typename boost::range_value<TurnPoints>::type turn_point_type; typedef typename turn_point_type::container_type container_type; @@ -79,20 +66,32 @@ inline void map_turns(Map& map, TurnPoints const& turn_points) it != boost::end(turn_points); ++it) { - if (! skip(*it)) + typename boost::range_value<TurnPoints>::type const& turn_info = *it; + bool both_uu = turn_info.both(operation_union); + bool skip = (turn_info.discarded || both_uu) + && ! turn_info.any_blocked() + && ! turn_info.both(operation_intersection) + ; + + for (typename boost::range_iterator<container_type const>::type + op_it = boost::begin(turn_info.operations); + op_it != boost::end(turn_info.operations); + ++op_it) { - for (typename boost::range_iterator<container_type const>::type - op_it = boost::begin(it->operations); - op_it != boost::end(it->operations); - ++op_it) + ring_identifier ring_id + ( + op_it->seg_id.source_index, + op_it->seg_id.multi_index, + op_it->seg_id.ring_index + ); + + if (! skip) { - ring_identifier ring_id - ( - op_it->seg_id.source_index, - op_it->seg_id.multi_index, - op_it->seg_id.ring_index - ); - map[ring_id]++; + turn_info_map[ring_id].has_normal_turn = true; + } + else if (both_uu) + { + turn_info_map[ring_id].has_uu_turn = true; } } } @@ -137,10 +136,10 @@ inline OutputIterator return_if_one_input_is_empty(Geometry1 const& geometry1, #endif - std::map<ring_identifier, int> empty; + std::map<ring_identifier, ring_turn_info> empty; std::map<ring_identifier, properties> all_of_one_of_them; - select_rings<Direction>(geometry1, geometry2, empty, all_of_one_of_them, false); + select_rings<Direction>(geometry1, geometry2, empty, all_of_one_of_them); ring_container_type rings; assign_parents(geometry1, geometry2, rings, all_of_one_of_them); return add_rings<GeometryOut>(all_of_one_of_them, geometry1, geometry2, rings, out); @@ -193,10 +192,6 @@ struct overlay container_type turn_points; -#ifdef BOOST_GEOMETRY_TIME_OVERLAY - boost::timer timer; -#endif - #ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE std::cout << "get turns" << std::endl; #endif @@ -207,10 +202,6 @@ std::cout << "get turns" << std::endl; detail::overlay::assign_null_policy >(geometry1, geometry2, robust_policy, turn_points, policy); -#ifdef BOOST_GEOMETRY_TIME_OVERLAY - std::cout << "get_turns: " << timer.elapsed() << std::endl; -#endif - #ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE std::cout << "enrich" << std::endl; #endif @@ -223,11 +214,6 @@ std::cout << "enrich" << std::endl; robust_policy, side_strategy); -#ifdef BOOST_GEOMETRY_TIME_OVERLAY - std::cout << "enrich_intersection_points: " << timer.elapsed() << std::endl; -#endif - - #ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE std::cout << "traverse" << std::endl; #endif @@ -245,27 +231,18 @@ std::cout << "traverse" << std::endl; turn_points, rings ); -#ifdef BOOST_GEOMETRY_TIME_OVERLAY - std::cout << "traverse: " << timer.elapsed() << std::endl; -#endif - - - std::map<ring_identifier, int> map; - map_turns(map, turn_points); - -#ifdef BOOST_GEOMETRY_TIME_OVERLAY - std::cout << "map_turns: " << timer.elapsed() << std::endl; -#endif - - typedef ring_properties<typename geometry::point_type<GeometryOut>::type> properties; - - std::map<ring_identifier, properties> selected; - select_rings<Direction>(geometry1, geometry2, map, selected, ! turn_points.empty()); + std::map<ring_identifier, ring_turn_info> turn_info_per_ring; + get_ring_turn_info(turn_info_per_ring, turn_points); -#ifdef BOOST_GEOMETRY_TIME_OVERLAY - std::cout << "select_rings: " << timer.elapsed() << std::endl; -#endif + typedef ring_properties + < + typename geometry::point_type<GeometryOut>::type + > properties; + // Select all rings which are NOT touched by any intersection point + std::map<ring_identifier, properties> selected_ring_properties; + select_rings<Direction>(geometry1, geometry2, turn_info_per_ring, + selected_ring_properties); // Add rings created during traversal { @@ -275,24 +252,15 @@ std::cout << "traverse" << std::endl; it != boost::end(rings); ++it) { - selected[id] = properties(*it, true); - selected[id].reversed = ReverseOut; + selected_ring_properties[id] = properties(*it); + selected_ring_properties[id].reversed = ReverseOut; id.multi_index++; } } -#ifdef BOOST_GEOMETRY_TIME_OVERLAY - std::cout << "add traversal rings: " << timer.elapsed() << std::endl; -#endif - - - assign_parents(geometry1, geometry2, rings, selected); - -#ifdef BOOST_GEOMETRY_TIME_OVERLAY - std::cout << "assign_parents: " << timer.elapsed() << std::endl; -#endif + assign_parents(geometry1, geometry2, rings, selected_ring_properties); - return add_rings<GeometryOut>(selected, geometry1, geometry2, rings, out); + return add_rings<GeometryOut>(selected_ring_properties, geometry1, geometry2, rings, out); } }; |