From e9143b6ca8299c63888c13b31d1b81f90cf33578 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Mon, 18 Jan 2021 05:51:56 +0100 Subject: [PATCH] Removed Edge class. Wasn't needed. Nodes and Corners are anough. --- include/corner.h | 11 +++++++---- include/edge.h | 6 ------ include/node.h | 5 +++-- include/prototypes.h | 2 -- src/corner.cpp | 2 +- src/main.cpp | 2 -- src/node.cpp | 5 +---- 7 files changed, 12 insertions(+), 21 deletions(-) delete mode 100644 include/edge.h diff --git a/include/corner.h b/include/corner.h index 96ce281..7f7b756 100644 --- a/include/corner.h +++ b/include/corner.h @@ -1,14 +1,17 @@ #pragma once + +class Corner; + #include "my_fastled.h" #include #include -#include "edge.h" +#include "node.h" class Corner { public: - Edge* e1; - Edge* e2; - Corner(Edge* e1, Edge* e2); + Node* node; + uint8_t number; + Corner(Node* node, uint8_t number); std::list _leds; std::vector _long_neighbours {}; std::vector _short_neighbours {}; diff --git a/include/edge.h b/include/edge.h deleted file mode 100644 index f757295..0000000 --- a/include/edge.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -class Edge { - public: - Edge* neighbour = nullptr; -}; \ No newline at end of file diff --git a/include/node.h b/include/node.h index 6981393..bc0e1fd 100644 --- a/include/node.h +++ b/include/node.h @@ -1,7 +1,9 @@ #pragma once + +class Node; + #include #include "config.h" -#include "edge.h" #include "corner.h" #include "prototypes.h" @@ -20,7 +22,6 @@ class Node { Coords coords; uint8_t direction; Node* neighbours[CORNERS_PER_PART]; - Edge* edges[CORNERS_PER_PART]; Corner* _corners[CORNERS_PER_PART]; Node(uint16_t number, Coords c, uint8_t direction); Node* create_neighbour(uint8_t edge); diff --git a/include/prototypes.h b/include/prototypes.h index de7d6f1..9453793 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -4,13 +4,11 @@ #include #include "config.h" #include "node.h" -#include "edge.h" #include "corner.h" class Node; extern std::vector nodes; -extern std::list edges; extern std::vector corners; extern CRGB leds[LED_COUNT]; diff --git a/src/corner.cpp b/src/corner.cpp index b1f19d3..ec3913e 100644 --- a/src/corner.cpp +++ b/src/corner.cpp @@ -2,7 +2,7 @@ #include "prototypes.h" #include "tools.h" -Corner::Corner(Edge* new_e1, Edge* new_e2): e1(new_e1), e2(new_e2) { +Corner::Corner(Node* no, uint8_t nu): node(no), number(nu) { } diff --git a/src/main.cpp b/src/main.cpp index f066f9d..5dcc8e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,6 @@ #include "config.h" #include "tools.h" #include "node.h" -#include "edge.h" #include "corner.h" #include "prototypes.h" #include "mqtt.h" @@ -13,7 +12,6 @@ #include "syslog.h" std::vector nodes; -std::list edges; std::vector corners; CRGB leds[LED_COUNT]; diff --git a/src/node.cpp b/src/node.cpp index 0011b29..2fd4494 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -9,7 +9,7 @@ Node::Node(uint16_t number, Coords c, uint8_t _dir) { LOGln("Created Node #%d at coordinates %d,%d with direction %d.", _number, coords.x, coords.y, direction); for(int i=0; ineighbours[0] = this; neighbours[edge] = node; - node->edges[0]->neighbour = this->edges[edge]; - this->edges[edge]->neighbour = node->edges[0]; - return node; }