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