Browse Source

fix: link error in layer data convert

master
Dnomd343 2 years ago
parent
commit
4a589b6c4b
  1. 28
      src/graph/graph.cc
  2. 2
      src/graph/graph.h
  3. 2
      src/graph/svg/svg.cc

28
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<uint32_t>(graph_layer[i - 1].size()),
.next = std::list<uint32_t>{static_cast<uint32_t>(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<uint32_t>(graph_layer[i - 1].size()),
.next = std::list<uint32_t>{curr->layer_index},
}).first->second);
}
}
}
}

2
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);

2
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;";
// <line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2"/>

Loading…
Cancel
Save