Better reporting of the analyzed layout at startup.
This commit is contained in:
parent
5676b5d63c
commit
d9708d9159
49
src/main.cpp
49
src/main.cpp
@ -42,24 +42,12 @@ void setup_layout() {
|
||||
nodes.push_back(current_node);
|
||||
}
|
||||
|
||||
for(Node* node: nodes) {
|
||||
for(Edge* edge: node->edges) {
|
||||
auto e = std::find(edges.begin(), edges.end(), edge);
|
||||
if (e == edges.end()) {
|
||||
edges.push_back(edge);
|
||||
}
|
||||
}
|
||||
LOGln("Node %p:", node);
|
||||
for(Node* n : node->neighbours) {
|
||||
LOGln(" %p", n);
|
||||
}
|
||||
}
|
||||
|
||||
bool verbose = false;
|
||||
for (Node* n1 : nodes) {
|
||||
LOGln("Looking for neighbours of node #%d @ %d,%d", n1->_number, n1->coords.x, n1->coords.y);
|
||||
if (verbose) LOGln("Looking for neighbours of node #%d @ %d,%d", n1->_number, n1->coords.x, n1->coords.y);
|
||||
for(int edge=0; edge<CORNERS_PER_PART; edge++) {
|
||||
Coords c = n1->coords_at_direction(edge);
|
||||
LOGln(" Chcking edge %d @ %d,%d...", edge, c.x, c.y);
|
||||
if (verbose) LOGln(" Chcking edge %d @ %d,%d...", edge, c.x, c.y);
|
||||
|
||||
Node* found = nullptr;
|
||||
for(Node* n2 : nodes) {
|
||||
@ -72,7 +60,7 @@ void setup_layout() {
|
||||
}
|
||||
}
|
||||
if (found != nullptr) {
|
||||
LOGln(" Found node #%d", found->_number);
|
||||
if (verbose) LOGln(" Found node #%d", found->_number);
|
||||
uint8_t inverse_dir = (n1->direction + 2*edge + 3) % 6;
|
||||
int8_t e = (inverse_dir - found->direction) % 6;
|
||||
if (e < 0) e+=6;
|
||||
@ -83,30 +71,39 @@ void setup_layout() {
|
||||
int8_t e2 = (e - 1) % CORNERS_PER_PART;
|
||||
if (e2<0) e2+=CORNERS_PER_PART;
|
||||
|
||||
LOGln(" Mapping Corner #%d,%d with #%d,%d", n1->_number, edge, found->_number, e2);
|
||||
if (verbose) LOGln(" Mapping Corner #%d,%d with #%d,%d", n1->_number, edge, found->_number, e2);
|
||||
n1->_corners[edge]->_short_neighbours.push_back(found->_corners[e2]);
|
||||
|
||||
LOGln(" Mapping Corner #%d,%d with #%d,%d", n1->_number, e1, found->_number, e);
|
||||
if (verbose) LOGln(" Mapping Corner #%d,%d with #%d,%d", n1->_number, e1, found->_number, e);
|
||||
n1->_corners[e1]->_short_neighbours.push_back(found->_corners[e]);
|
||||
} else {
|
||||
LOGln(" No match.");
|
||||
if (verbose) LOGln(" No match.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Corner* corner: corners) {
|
||||
LOGln("Corner %p:", corner);
|
||||
for(auto c: corner->_long_neighbours) {
|
||||
LOGln(" Long: %p", c);
|
||||
for (Node* node : nodes) {
|
||||
LOGln("Node #%d:", node->_number);
|
||||
for(Corner* corner : node->_corners) {
|
||||
LOGln(" Corner #%d,%d:", node->_number, corner->number);
|
||||
for (auto c: corner->_long_neighbours) {
|
||||
LOGln(" Long neighbour: #%d,%d", c->node->_number, c->number);
|
||||
}
|
||||
for (auto c: corner->_short_neighbours) {
|
||||
LOGln(" Short neighbour: #%d,%d", c->node->_number, c->number);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<CORNERS_PER_PART; i++) {
|
||||
if (node->neighbours[i]==nullptr) {
|
||||
LOGln(" Neighbour %d: NULL", i);
|
||||
} else {
|
||||
LOGln(" Neighbour %d: #%d", i, node->neighbours[i]->_number);
|
||||
}
|
||||
for(auto c: corner->_short_neighbours) {
|
||||
LOGln(" Short: %p", c);
|
||||
}
|
||||
}
|
||||
|
||||
LOGln("Counts:");
|
||||
LOGln("Nodes: %3d", nodes.size());
|
||||
LOGln("Edges: %3d", edges.size());
|
||||
LOGln("Corners: %3d", corners.size());
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ Node::Node(uint16_t number, Coords c, uint8_t _dir) {
|
||||
|
||||
Corner* last_corner = nullptr;
|
||||
for(int i=0; i<CORNERS_PER_PART; i++) {
|
||||
Corner* c = new Corner(edges[i], edges[(i+1) % CORNERS_PER_PART]);
|
||||
Corner* c = new Corner(this, i);
|
||||
for(int j=0; j<LEDS_PER_CORNER; j++) {
|
||||
c->add_led(number * CORNERS_PER_PART * LEDS_PER_CORNER + i * LEDS_PER_CORNER + j);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user