1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014-2020, Oracle and/or its affiliates.
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
11 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_DEBUG_PRINT_BOUNDARY_POINTS_HPP
12 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_DEBUG_PRINT_BOUNDARY_POINTS_HPP
14 #ifdef BOOST_GEOMETRY_TEST_DEBUG
19 #include <boost/range/begin.hpp>
20 #include <boost/range/end.hpp>
21 #include <boost/range/size.hpp>
23 #include <boost/geometry/core/point_type.hpp>
24 #include <boost/geometry/core/tag.hpp>
25 #include <boost/geometry/core/tags.hpp>
27 #include <boost/geometry/util/range.hpp>
29 #include <boost/geometry/io/dsv/write.hpp>
31 #include <boost/geometry/policies/compare.hpp>
33 #include <boost/geometry/algorithms/equals.hpp>
34 #include <boost/geometry/algorithms/not_implemented.hpp>
35 #endif // BOOST_GEOMETRY_TEST_DEBUG
38 namespace boost { namespace geometry
41 namespace detail { namespace is_simple
45 #ifdef BOOST_GEOMETRY_TEST_DEBUG
46 template <typename Linear, typename Tag = typename tag<Linear>::type>
47 struct debug_boundary_points_printer
48 : not_implemented<Linear>
51 template <typename Linestring>
52 struct debug_boundary_points_printer<Linestring, linestring_tag>
54 static inline void apply(Linestring const& linestring)
56 std::cout << "boundary points: ";
57 std::cout << " " << geometry::dsv(range::front(linestring));
58 std::cout << " " << geometry::dsv(range::back(linestring));
59 std::cout << std::endl << std::endl;
63 template <typename MultiLinestring>
64 struct debug_boundary_points_printer<MultiLinestring, multi_linestring_tag>
66 static inline void apply(MultiLinestring const& multilinestring)
68 typedef typename point_type<MultiLinestring>::type point_type;
69 typedef std::vector<point_type> point_vector;
71 point_vector boundary_points;
72 for (typename boost::range_iterator<MultiLinestring const>::type it
73 = boost::begin(multilinestring);
74 it != boost::end(multilinestring); ++it)
76 if ( boost::size(*it) > 1
77 && !geometry::equals(range::front(*it), range::back(*it)) )
79 boundary_points.push_back( range::front(*it) );
80 boundary_points.push_back( range::back(*it) );
84 std::sort(boundary_points.begin(), boundary_points.end(),
85 geometry::less<point_type>());
87 std::cout << "boundary points: ";
88 for (typename point_vector::const_iterator
89 pit = boundary_points.begin();
90 pit != boundary_points.end(); ++pit)
92 std::cout << " " << geometry::dsv(*pit);
94 std::cout << std::endl << std::endl;
99 template <typename Linear>
100 inline void debug_print_boundary_points(Linear const& linear)
102 debug_boundary_points_printer<Linear>::apply(linear);
105 template <typename Linear>
106 inline void debug_print_boundary_points(Linear const&)
109 #endif // BOOST_GEOMETRY_TEST_DEBUG
112 }} // namespace detail::is_simple
114 }} // namespace boost::geometry
116 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_DEBUG_PRINT_BOUNDARY_POINTS_HPP