From 5a71e83bd5b84b7ab6bb96e3e2db79bc90ba8536 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 20 Jun 2014 13:41:00 +0300 Subject: [PATCH] [algorithms][is_valid] remove all explicit usages of debug macro; clean-up/polish debug-related code; --- .../algorithms/detail/is_valid/polygon.hpp | 61 ++++++------------- 1 file changed, 18 insertions(+), 43 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp b/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp index 545b23eac..87f4590d6 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp @@ -40,14 +40,12 @@ #include #include +#include +#include +#include #include -#ifdef GEOMETRY_TEST_DEBUG -#include -#include -#endif - namespace boost { namespace geometry { @@ -185,10 +183,11 @@ public: typedef typename point_type::type point_type; typedef typename ring_type::type ring_type; + typedef debug_validity_phase debug_phase; + // check validity of exterior ring -#ifdef GEOMETRY_TEST_DEBUG - std::cout << "checking exterior ring..." << std::endl; -#endif + debug_phase::apply(1); + if ( !detail::is_valid::is_valid_ring < ring_type, @@ -199,11 +198,9 @@ public: return false; } - // check validity of interior rings -#ifdef GEOMETRY_TEST_DEBUG - std::cout << "checking interior rings..." << std::endl; -#endif + debug_phase::apply(2); + if ( !are_valid_interior_rings(geometry::interior_rings(polygon)) ) { return false; @@ -211,9 +208,8 @@ public: // compute turns and check if all are acceptable -#ifdef GEOMETRY_TEST_DEBUG - std::cout << "computing and analyzing turns..." << std::endl; -#endif + debug_phase::apply(3); + typedef typename geometry::rescale_policy_type < point_type @@ -253,24 +249,7 @@ public: return false; } -#ifdef GEOMETRY_TEST_DEBUG - std::cout << "turns:"; - for (typename std::deque::const_iterator tit = turns.begin(); - tit != turns.end(); ++tit) - { - std::cout << " [" << geometry::method_char(tit->method); - std::cout << "," - << geometry::operation_char(tit->operations[0].operation); - std::cout << "/" - << geometry::operation_char(tit->operations[1].operation); - std::cout << " {" << tit->operations[0].seg_id.ring_index - << ", " << tit->operations[0].other_id.ring_index - << "}"; - std::cout << " " << geometry::dsv(tit->point); - std::cout << "] "; - } - std::cout << std::endl << std::endl; -#endif + debug_print_turns(turns.begin(), turns.end()); // put the ring id's that are associated with turns in a // container with fast lookup (std::set) @@ -284,10 +263,8 @@ public: // check if all interior rings are inside the exterior ring -#ifdef GEOMETRY_TEST_DEBUG - std::cout << "checking if holes are inside the exterior ring..." - << std::endl; -#endif + debug_phase::apply(4); + if ( !are_holes_inside(geometry::interior_rings(polygon), geometry::exterior_ring(polygon), rings_with_turns) ) @@ -297,9 +274,8 @@ public: // check whether the interior of the polygon is a connected set -#ifdef GEOMETRY_TEST_DEBUG - std::cout << "checking connectivity of interior..." << std::endl; -#endif + debug_phase::apply(5); + typedef graph_vertex graph_vertex; typedef complement_graph graph; @@ -317,9 +293,8 @@ public: g.add_edge(v2, vip); } -#ifdef GEOMETRY_TEST_DEBUG - g.print(); -#endif + debug_print_complement_graph(std::cout, g); + return !g.has_cycles(); } };