Removed Edge class. Wasn't needed. Nodes and Corners are anough.

This commit is contained in:
Fabian Schlenz 2021-01-18 05:51:56 +01:00
parent db76255a2c
commit e9143b6ca8
7 changed files with 12 additions and 21 deletions

View File

@ -1,14 +1,17 @@
#pragma once
class Corner;
#include "my_fastled.h"
#include <vector>
#include <list>
#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<uint16_t> _leds;
std::vector<Corner*> _long_neighbours {};
std::vector<Corner*> _short_neighbours {};

View File

@ -1,6 +0,0 @@
#pragma once
class Edge {
public:
Edge* neighbour = nullptr;
};

View File

@ -1,7 +1,9 @@
#pragma once
class Node;
#include <Arduino.h>
#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);

View File

@ -4,13 +4,11 @@
#include <vector>
#include "config.h"
#include "node.h"
#include "edge.h"
#include "corner.h"
class Node;
extern std::vector<Node*> nodes;
extern std::list<Edge*> edges;
extern std::vector<Corner*> corners;
extern CRGB leds[LED_COUNT];

View File

@ -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) {
}

View File

@ -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<Node*> nodes;
std::list<Edge*> edges;
std::vector<Corner*> corners;
CRGB leds[LED_COUNT];

View File

@ -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; i<CORNERS_PER_PART; i++) {
edges[i] = new Edge();
neighbours[i] = nullptr;
}
Corner* last_corner = nullptr;
@ -42,9 +42,6 @@ Node* Node::create_neighbour(uint8_t edge) {
node->neighbours[0] = this;
neighbours[edge] = node;
node->edges[0]->neighbour = this->edges[edge];
this->edges[edge]->neighbour = node->edges[0];
return node;
}