File indexing completed on 2025-09-17 08:30:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_DEBUG_PRINT_BOUNDARY_POINTS_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_DEBUG_PRINT_BOUNDARY_POINTS_HPP
0013
0014 #ifdef BOOST_GEOMETRY_TEST_DEBUG
0015 #include <algorithm>
0016 #include <iostream>
0017 #include <vector>
0018
0019 #include <boost/range/begin.hpp>
0020 #include <boost/range/end.hpp>
0021 #include <boost/range/size.hpp>
0022
0023 #include <boost/geometry/core/point_type.hpp>
0024 #include <boost/geometry/core/tag.hpp>
0025 #include <boost/geometry/core/tags.hpp>
0026
0027 #include <boost/geometry/util/range.hpp>
0028
0029 #include <boost/geometry/io/dsv/write.hpp>
0030
0031 #include <boost/geometry/policies/compare.hpp>
0032
0033 #include <boost/geometry/algorithms/equals.hpp>
0034 #include <boost/geometry/algorithms/not_implemented.hpp>
0035 #endif
0036
0037
0038 namespace boost { namespace geometry
0039 {
0040
0041 namespace detail { namespace is_simple
0042 {
0043
0044
0045 #ifdef BOOST_GEOMETRY_TEST_DEBUG
0046 template <typename Linear, typename Tag = tag_t<Linear>>
0047 struct debug_boundary_points_printer
0048 : not_implemented<Linear>
0049 {};
0050
0051 template <typename Linestring>
0052 struct debug_boundary_points_printer<Linestring, linestring_tag>
0053 {
0054 static inline void apply(Linestring const& linestring)
0055 {
0056 std::cout << "boundary points: ";
0057 std::cout << " " << geometry::dsv(range::front(linestring));
0058 std::cout << " " << geometry::dsv(range::back(linestring));
0059 std::cout << std::endl << std::endl;
0060 }
0061 };
0062
0063 template <typename MultiLinestring>
0064 struct debug_boundary_points_printer<MultiLinestring, multi_linestring_tag>
0065 {
0066 static inline void apply(MultiLinestring const& multilinestring)
0067 {
0068 std::vector<point_type_t<MultiLinestring>> boundary_points;
0069 for (auto it = boost::begin(multilinestring); it != boost::end(multilinestring); ++it)
0070 {
0071 if ( boost::size(*it) > 1
0072 && !geometry::equals(range::front(*it), range::back(*it)) )
0073 {
0074 boundary_points.push_back( range::front(*it) );
0075 boundary_points.push_back( range::back(*it) );
0076 }
0077 }
0078
0079 std::sort(boundary_points.begin(), boundary_points.end(),
0080 geometry::less<point_type>());
0081
0082 std::cout << "boundary points: ";
0083 for (auto const& p : boundary_points)
0084 {
0085 std::cout << " " << geometry::dsv(p);
0086 }
0087 std::cout << std::endl << std::endl;
0088 }
0089 };
0090
0091
0092 template <typename Linear>
0093 inline void debug_print_boundary_points(Linear const& linear)
0094 {
0095 debug_boundary_points_printer<Linear>::apply(linear);
0096 }
0097 #else
0098 template <typename Linear>
0099 inline void debug_print_boundary_points(Linear const&)
0100 {
0101 }
0102 #endif
0103
0104
0105 }}
0106
0107 }}
0108
0109 #endif