-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnode.h
More file actions
33 lines (26 loc) · 911 Bytes
/
node.h
File metadata and controls
33 lines (26 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef NODE_H
#define NODE_H
#include <memory>
#include <vector>
#include "polygon.h"
using namespace std;
class Node : public std::enable_shared_from_this<Node>
{
public:
Node(vector<shared_ptr<Polygon>> const &polygons = {});
bool isConvex(vector<shared_ptr<Polygon>> const &polygons);
void build(vector<shared_ptr<Polygon>> const &polygons);
vector<shared_ptr<Polygon>> allPolygons() const;
shared_ptr<Node> clone() const;
shared_ptr<Node> invert();
vector<shared_ptr<Polygon>> clipPolygons(vector<shared_ptr<Polygon>> const &polygons) const;
void clipTo(shared_ptr<Node> const &node);
private:
/** Depth-first aggregate without intermediate vectors (same order as recursive merge). */
void collectPolygons(vector<shared_ptr<Polygon>> &out) const;
vector<shared_ptr<Polygon>> polygons;
shared_ptr<Node> front;
shared_ptr<Node> back;
shared_ptr<Polygon> divider;
};
#endif