22 lines
529 B
C++
22 lines
529 B
C++
|
#include "node.h"
|
||
|
|
||
|
Node::Node() {
|
||
|
for(int i=0; i<CORNERS_PER_PART; i++) {
|
||
|
edges[i] = new Edge();
|
||
|
corners[i] = new Corner();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Node* Node::create_neighbour(uint8_t edge) {
|
||
|
Node* node = new Node();
|
||
|
node->neighbours[0] = this;
|
||
|
neighbours[edge] = node;
|
||
|
|
||
|
delete node->edges[0];
|
||
|
node->edges[0] = this->edges[edge];
|
||
|
delete node->corners[0];
|
||
|
node->corners[0] = this->corners[(edge-1) % CORNERS_PER_PART];
|
||
|
delete node->corners[CORNERS_PER_PART-1];
|
||
|
node->corners[CORNERS_PER_PART-1] = this->corners[edge];
|
||
|
return node;
|
||
|
}
|