File indexing completed on 2025-01-18 09:35:06
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 = typename tag<Linear>::type>
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 typedef typename point_type<MultiLinestring>::type point_type;
0069 typedef std::vector<point_type> point_vector;
0070
0071 point_vector boundary_points;
0072 for (auto it = boost::begin(multilinestring); it != boost::end(multilinestring); ++it)
0073 {
0074 if ( boost::size(*it) > 1
0075 && !geometry::equals(range::front(*it), range::back(*it)) )
0076 {
0077 boundary_points.push_back( range::front(*it) );
0078 boundary_points.push_back( range::back(*it) );
0079 }
0080 }
0081
0082 std::sort(boundary_points.begin(), boundary_points.end(),
0083 geometry::less<point_type>());
0084
0085 std::cout << "boundary points: ";
0086 for (auto const& p : boundary_points)
0087 {
0088 std::cout << " " << geometry::dsv(p);
0089 }
0090 std::cout << std::endl << std::endl;
0091 }
0092 };
0093
0094
0095 template <typename Linear>
0096 inline void debug_print_boundary_points(Linear const& linear)
0097 {
0098 debug_boundary_points_printer<Linear>::apply(linear);
0099 }
0100 #else
0101 template <typename Linear>
0102 inline void debug_print_boundary_points(Linear const&)
0103 {
0104 }
0105 #endif
0106
0107
0108 }}
0109
0110 }}
0111
0112 #endif