-
Notifications
You must be signed in to change notification settings - Fork 0
/
BSP.h
33 lines (29 loc) · 774 Bytes
/
BSP.h
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
#pragma once
#include "Polygon.h"
#include <vector>
#include <unordered_set>
class TreeNode{
public:
TreeNode(){};
TreeNode* left;
TreeNode* right;
Edge edge;
std::vector<Edge> coincident;
};
class BSP{
public:
BSP(Polygon& polygon);
BSP(BSP& bsp)=delete;
~BSP();
BSP& operator=(BSP& bsp)=delete;
TreeNode* travalToLeaf(int x, int y);
bool isInterior(int x, int y);
int getPointLocation(TreeNode* root, int x, int y);
inline TreeNode* getRoot(){return root;}
private:
TreeNode* root;
Polygon* polygonPtr;
int height;
TreeNode* constructBSP(std::vector<Edge> edges, int& height, bool convex);
void freeBSP(TreeNode* root);
};