]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/detail/is_simple/debug_print_boundary_points.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / algorithms / detail / is_simple / debug_print_boundary_points.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2014-2015, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9
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
12
13 #ifdef BOOST_GEOMETRY_TEST_DEBUG
14 #include <algorithm>
15 #include <iostream>
16 #include <vector>
17
18 #include <boost/range.hpp>
19
20 #include <boost/geometry/core/point_type.hpp>
21 #include <boost/geometry/core/tag.hpp>
22 #include <boost/geometry/core/tags.hpp>
23
24 #include <boost/geometry/util/range.hpp>
25
26 #include <boost/geometry/io/dsv/write.hpp>
27
28 #include <boost/geometry/policies/compare.hpp>
29
30 #include <boost/geometry/algorithms/equals.hpp>
31 #include <boost/geometry/algorithms/not_implemented.hpp>
32 #endif // BOOST_GEOMETRY_TEST_DEBUG
33
34
35 namespace boost { namespace geometry
36 {
37
38 namespace detail { namespace is_simple
39 {
40
41
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>
46 {};
47
48 template <typename Linestring>
49 struct debug_boundary_points_printer<Linestring, linestring_tag>
50 {
51 static inline void apply(Linestring const& linestring)
52 {
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;
57 }
58 };
59
60 template <typename MultiLinestring>
61 struct debug_boundary_points_printer<MultiLinestring, multi_linestring_tag>
62 {
63 static inline void apply(MultiLinestring const& multilinestring)
64 {
65 typedef typename point_type<MultiLinestring>::type point_type;
66 typedef std::vector<point_type> point_vector;
67
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)
72 {
73 if ( boost::size(*it) > 1
74 && !geometry::equals(range::front(*it), range::back(*it)) )
75 {
76 boundary_points.push_back( range::front(*it) );
77 boundary_points.push_back( range::back(*it) );
78 }
79 }
80
81 std::sort(boundary_points.begin(), boundary_points.end(),
82 geometry::less<point_type>());
83
84 std::cout << "boundary points: ";
85 for (typename point_vector::const_iterator
86 pit = boundary_points.begin();
87 pit != boundary_points.end(); ++pit)
88 {
89 std::cout << " " << geometry::dsv(*pit);
90 }
91 std::cout << std::endl << std::endl;
92 }
93 };
94
95
96 template <typename Linear>
97 inline void debug_print_boundary_points(Linear const& linear)
98 {
99 debug_boundary_points_printer<Linear>::apply(linear);
100 }
101 #else
102 template <typename Linear>
103 inline void debug_print_boundary_points(Linear const&)
104 {
105 }
106 #endif // BOOST_GEOMETRY_TEST_DEBUG
107
108
109 }} // namespace detail::is_simple
110
111 }} // namespace boost::geometry
112
113 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_DEBUG_PRINT_BOUNDARY_POINTS_HPP