1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014-2015, Oracle and/or its affiliates.
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_DEBUG_PRINT_BOUNDARY_POINTS_HPP
11 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_DEBUG_PRINT_BOUNDARY_POINTS_HPP
13 #ifdef BOOST_GEOMETRY_TEST_DEBUG
18 #include <boost/range.hpp>
20 #include <boost/geometry/core/point_type.hpp>
21 #include <boost/geometry/core/tag.hpp>
22 #include <boost/geometry/core/tags.hpp>
24 #include <boost/geometry/util/range.hpp>
26 #include <boost/geometry/io/dsv/write.hpp>
28 #include <boost/geometry/policies/compare.hpp>
30 #include <boost/geometry/algorithms/equals.hpp>
31 #include <boost/geometry/algorithms/not_implemented.hpp>
32 #endif // BOOST_GEOMETRY_TEST_DEBUG
35 namespace boost { namespace geometry
38 namespace detail { namespace is_simple
42 #ifdef BOOST_GEOMETRY_TEST_DEBUG
43 template <typename Linear, typename Tag = typename tag<Linear>::type>
44 struct debug_boundary_points_printer
45 : not_implemented<Linear>
48 template <typename Linestring>
49 struct debug_boundary_points_printer<Linestring, linestring_tag>
51 static inline void apply(Linestring const& linestring)
53 std::cout << "boundary points: ";
54 std::cout << " " << geometry::dsv(range::front(linestring));
55 std::cout << " " << geometry::dsv(range::back(linestring));
56 std::cout << std::endl << std::endl;
60 template <typename MultiLinestring>
61 struct debug_boundary_points_printer<MultiLinestring, multi_linestring_tag>
63 static inline void apply(MultiLinestring const& multilinestring)
65 typedef typename point_type<MultiLinestring>::type point_type;
66 typedef std::vector<point_type> point_vector;
68 point_vector boundary_points;
69 for (typename boost::range_iterator<MultiLinestring const>::type it
70 = boost::begin(multilinestring);
71 it != boost::end(multilinestring); ++it)
73 if ( boost::size(*it) > 1
74 && !geometry::equals(range::front(*it), range::back(*it)) )
76 boundary_points.push_back( range::front(*it) );
77 boundary_points.push_back( range::back(*it) );
81 std::sort(boundary_points.begin(), boundary_points.end(),
82 geometry::less<point_type>());
84 std::cout << "boundary points: ";
85 for (typename point_vector::const_iterator
86 pit = boundary_points.begin();
87 pit != boundary_points.end(); ++pit)
89 std::cout << " " << geometry::dsv(*pit);
91 std::cout << std::endl << std::endl;
96 template <typename Linear>
97 inline void debug_print_boundary_points(Linear const& linear)
99 debug_boundary_points_printer<Linear>::apply(linear);
102 template <typename Linear>
103 inline void debug_print_boundary_points(Linear const&)
106 #endif // BOOST_GEOMETRY_TEST_DEBUG
109 }} // namespace detail::is_simple
111 }} // namespace boost::geometry
113 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_DEBUG_PRINT_BOUNDARY_POINTS_HPP
In the beginning the Universe was created. This has made a lot of
people very angry and has been widely regarded as a bad move.
Douglas Adams