1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014, Oracle and/or its affiliates.
5 // Licensed under the Boost Software License version 1.0.
6 // http://www.boost.org/users/license.html
8 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
10 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_TURNS_PRINT_TURNS_HPP
11 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_TURNS_PRINT_TURNS_HPP
16 #include <boost/range.hpp>
18 #include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
19 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
20 #include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
21 #include <boost/geometry/io/wkt/write.hpp>
22 #include <boost/geometry/io/dsv/write.hpp>
24 namespace boost { namespace geometry
27 namespace detail { namespace turns
32 turn_printer(std::ostream & os)
37 template <typename Turn>
38 void operator()(Turn const& turn)
41 << ": " << geometry::method_char(turn.method);
44 out << " (discarded)\n";
45 else if ( turn.blocked() )
46 out << " (blocked)\n";
52 fraction[0] = turn.operations[0].fraction.numerator()
53 / turn.operations[0].fraction.denominator();
55 out << geometry::operation_char(turn.operations[0].operation)
56 <<": seg: " << turn.operations[0].seg_id.source_index
57 << ", m: " << turn.operations[0].seg_id.multi_index
58 << ", r: " << turn.operations[0].seg_id.ring_index
59 << ", s: " << turn.operations[0].seg_id.segment_index;
60 out << ", fr: " << fraction[0];
61 out << ", col?: " << turn.operations[0].is_collinear;
62 out << ' ' << geometry::dsv(turn.point) << ' ';
66 fraction[1] = turn.operations[1].fraction.numerator()
67 / turn.operations[1].fraction.denominator();
69 out << geometry::operation_char(turn.operations[1].operation)
70 << ": seg: " << turn.operations[1].seg_id.source_index
71 << ", m: " << turn.operations[1].seg_id.multi_index
72 << ", r: " << turn.operations[1].seg_id.ring_index
73 << ", s: " << turn.operations[1].seg_id.segment_index;
74 out << ", fr: " << fraction[1];
75 out << ", col?: " << turn.operations[1].is_collinear;
76 out << ' ' << geometry::dsv(turn.point) << ' ';
86 template <typename Geometry1, typename Geometry2, typename Turns>
87 static inline void print_turns(Geometry1 const& g1,
91 std::cout << geometry::wkt(g1) << std::endl;
92 std::cout << geometry::wkt(g2) << std::endl;
94 std::for_each(boost::begin(turns), boost::end(turns), turn_printer(std::cout));
100 }} // namespace detail::turns
102 }} // namespace boost::geometry
105 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_TURNS_PRINT_TURNS_HPP