Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:16

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2014-2020, Oracle and/or its affiliates.
0004 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0005 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0006 
0007 // Licensed under the Boost Software License version 1.0.
0008 // http://www.boost.org/users/license.html
0009 
0010 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_TURNS_PRINT_TURNS_HPP
0011 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_TURNS_PRINT_TURNS_HPP
0012 
0013 #include <algorithm>
0014 #include <iostream>
0015 
0016 #include <boost/range/begin.hpp>
0017 #include <boost/range/end.hpp>
0018 
0019 #include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
0020 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
0021 #include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
0022 #include <boost/geometry/io/wkt/write.hpp>
0023 #include <boost/geometry/io/dsv/write.hpp>
0024 
0025 namespace boost { namespace geometry
0026 {
0027 
0028 namespace detail { namespace turns
0029 {
0030 
0031 struct turn_printer
0032 {
0033     turn_printer(std::ostream & os)
0034         : index(0)
0035         , out(os)
0036     {}
0037 
0038     template <typename Turn>
0039     void operator()(Turn const& turn)
0040     {
0041         out << index
0042             << ": " << geometry::method_char(turn.method);
0043 
0044         if ( turn.discarded )
0045             out << " (discarded)\n";
0046         else if ( turn.blocked() )
0047             out << " (blocked)\n";
0048         else
0049             out << '\n';
0050 
0051         double fraction[2];
0052 
0053         fraction[0] = turn.operations[0].fraction.numerator()
0054             / turn.operations[0].fraction.denominator();
0055 
0056         out << geometry::operation_char(turn.operations[0].operation)
0057             <<": seg: " << turn.operations[0].seg_id.source_index
0058             << ", m: " << turn.operations[0].seg_id.multi_index
0059             << ", r: " << turn.operations[0].seg_id.ring_index
0060             << ", s: " << turn.operations[0].seg_id.segment_index;
0061         out << ", fr: " << fraction[0];
0062         out << ", col?: " << turn.operations[0].is_collinear;
0063         out << ' ' << geometry::dsv(turn.point) << ' ';
0064 
0065         out << '\n';
0066 
0067         fraction[1] = turn.operations[1].fraction.numerator()
0068             / turn.operations[1].fraction.denominator();
0069 
0070         out << geometry::operation_char(turn.operations[1].operation)
0071             << ": seg: " << turn.operations[1].seg_id.source_index
0072             << ", m: " << turn.operations[1].seg_id.multi_index
0073             << ", r: " << turn.operations[1].seg_id.ring_index
0074             << ", s: " << turn.operations[1].seg_id.segment_index;
0075         out << ", fr: " << fraction[1];
0076         out << ", col?: " << turn.operations[1].is_collinear;
0077         out << ' ' << geometry::dsv(turn.point) << ' ';
0078 
0079         ++index;
0080         out << std::endl;
0081     }
0082 
0083     int index;
0084     std::ostream & out;
0085 };
0086 
0087 template <typename Geometry1, typename Geometry2, typename Turns>
0088 static inline void print_turns(Geometry1 const& g1,
0089                                Geometry2 const& g2,
0090                                Turns const& turns)
0091 {
0092     std::cout << geometry::wkt(g1) << std::endl;
0093     std::cout << geometry::wkt(g2) << std::endl;
0094 
0095     std::for_each(boost::begin(turns), boost::end(turns), turn_printer(std::cout));
0096 }
0097 
0098 
0099 
0100 
0101 }} // namespace detail::turns
0102 
0103 }} // namespace boost::geometry
0104 
0105 
0106 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_TURNS_PRINT_TURNS_HPP