File indexing completed on 2026-08-21 08:45:50
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_DEBUG_GRAPH_HPP
0010 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_DEBUG_GRAPH_HPP
0011
0012 #include <boost/geometry/core/access.hpp>
0013
0014 #include <ostream>
0015 #include <iostream>
0016
0017 #include <boost/graph/graph_traits.hpp>
0018 #include <boost/graph/adjacency_list.hpp>
0019
0020 namespace boost { namespace geometry
0021 {
0022
0023 #ifndef DOXYGEN_NO_DETAIL
0024 namespace detail { namespace overlay
0025 {
0026
0027
0028 template <typename Turns, typename Clusters, typename Graph, typename Components, typename VertexMap>
0029 void write_graph_viz(std::ostream& out, Turns const& turns, Clusters const& clusters,
0030 Graph const& g, Components const& component, VertexMap const& vertex_map,
0031 bool use_absolute_position = true)
0032 {
0033 out << "graph A {\n node[shape=\"circle\"]\n";
0034
0035 auto add_pos = [&](auto const& point)
0036 {
0037 out << ", pos=\"" << geometry::get<0>(point) << "," << geometry::get<1>(point) << "!\"";
0038 };
0039
0040
0041 for (auto const& vertex_pair : vertex_map)
0042 {
0043 auto const& vertex = vertex_pair.second;
0044
0045 out << vertex.node_id << "[label=\"" << vertex.node_id << "\"";
0046 if (use_absolute_position)
0047 {
0048 if (vertex.node_id < 0)
0049 {
0050
0051 auto it = clusters.find(vertex.node_id);
0052 if (it != clusters.end())
0053 {
0054 auto const& cluster = it->second;
0055 if (! cluster.turn_indices.empty())
0056 {
0057 add_pos(turns[*cluster.turn_indices.begin()].point);
0058 }
0059 }
0060 }
0061 else if (vertex.node_id < static_cast<int>(turns.size()))
0062 {
0063 add_pos(turns[vertex.node_id].point);
0064 }
0065 else if (vertex.original_node_id >= 0 && vertex.original_node_id < turns.size())
0066 {
0067
0068
0069
0070 auto point = turns[vertex.original_node_id].point;
0071 geometry::set<0>(point, geometry::get<0>(point) - 1.0);
0072 geometry::set<1>(point, geometry::get<1>(point) - 1.0);
0073 add_pos(point);
0074 }
0075 }
0076 out << "]\n";
0077 }
0078
0079 typename graph_traits<Graph>::edge_iterator ei, ei_end;
0080 for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
0081 {
0082 auto const source_vertex = source(*ei, g);
0083 auto const target_vertex = target(*ei, g);
0084 auto it_source = vertex_map.find(source_vertex);
0085 auto it_target = vertex_map.find(target_vertex);
0086 if (it_source == vertex_map.end() || it_target == vertex_map.end())
0087 {
0088 std::cerr << "Edge not found FOR GRAPH_VIZ "
0089 << source_vertex << " -- " << target_vertex
0090 << std::endl;
0091 continue;
0092 }
0093 auto const source_node_id = it_source->second.node_id;
0094 auto const target_node_id = it_target->second.node_id;
0095
0096 out << source_node_id << " -- " << target_node_id
0097 << "[label=\""
0098
0099 << component[*ei]
0100
0101 << "\"]"
0102 << '\n';
0103 }
0104 out << "}\n";
0105 }
0106
0107 }}
0108 #endif
0109
0110 }}
0111
0112 #endif