From 4a589b6c4ba6efe7a669c2cfd39e7962f3121f44 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sat, 21 Jan 2023 14:35:42 +0800 Subject: [PATCH] fix: link error in layer data convert --- src/graph/graph.cc | 28 +++++++++++++++++----------- src/graph/graph.h | 2 +- src/graph/svg/svg.cc | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/graph/graph.cc b/src/graph/graph.cc index 52cd3a5..de3fc36 100644 --- a/src/graph/graph.cc +++ b/src/graph/graph.cc @@ -32,6 +32,8 @@ void Graph::svg_demo(Analyse::track_data_t track_data) { auto skin = CaseSkin(); + // TODO: remove layer_index + // TODO: try remove layer_num struct graph_t { uint64_t code; uint32_t layer_num; @@ -64,24 +66,28 @@ void Graph::svg_demo(Analyse::track_data_t track_data) { // std::cout << std::endl; // std::cout << "layer " << i << " -> " << graph_layer[i].size() << std::endl; - for (const auto *c : graph_layer[i]) { + for (const auto *curr : graph_layer[i]) { // std::cout << "code = " << c->code << std::endl; - for (const auto src : track_data[i][c->code].last) { + for (const auto *src : track_data[i][curr->code].last) { // std::cout << " src -> " << src->code << std::endl; - auto ret = graph_data.emplace(src->code, graph_t { - .code = src->code, - .layer_num = i - 1, - .layer_index = static_cast(graph_layer[i - 1].size()), - .next = std::list{static_cast(graph_layer[i - 1].size())}, - }); + auto find_ret = graph_data.find(src->code); + + if (find_ret != graph_data.end()) { // already exist + + find_ret->second.next.emplace_back(curr->layer_index); - if (ret.second) { // insert success - graph_layer[i - 1].emplace_back(&ret.first->second); } else { - graph_data[src->code].next.emplace_back(graph_data[c->code].layer_index); + graph_layer[i - 1].emplace_back(&graph_data.emplace(src->code, graph_t { + .code = src->code, + .layer_num = i - 1, + .layer_index = static_cast(graph_layer[i - 1].size()), + .next = std::list{curr->layer_index}, + }).first->second); + } + } } } diff --git a/src/graph/graph.h b/src/graph/graph.h index e3d8892..ddec392 100644 --- a/src/graph/graph.h +++ b/src/graph/graph.h @@ -49,7 +49,7 @@ public: uint64_t CASE_WIDTH = BLOCK_LENGTH * 4 + BLOCK_GAP * 5; uint64_t CASE_HEIGHT = BLOCK_LENGTH * 5 + BLOCK_GAP * 6; - uint64_t LINE_OFFSET = 3; + uint64_t LINE_OFFSET = 2; void svg_demo(Analyse::track_data_t track_data); diff --git a/src/graph/svg/svg.cc b/src/graph/svg/svg.cc index 06d3816..22b11e5 100644 --- a/src/graph/svg/svg.cc +++ b/src/graph/svg/svg.cc @@ -20,7 +20,7 @@ std::string SvgLine::dump() const { xml += "x2=\"" + std::to_string(end.x) + "\" "; xml += "y2=\"" + std::to_string(end.y) + "\" "; - std::string style = "stroke:blue;stroke-width:1;"; + std::string style = "stroke:#636379;stroke-width:1;"; //