-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrid.h
64 lines (56 loc) · 1.37 KB
/
Grid.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include<vector>
#include<queue>
class Component;
class Gate;
class SWITCH;
class LED;
class Connection;
class Pin;
class InputPin;
class Grid
{
public:
Grid(int r_X, int r_Y);
void Reset();
std::vector< std::pair<int,int> > FindPath(std::pair<int,int> Point1, std::pair<int,int> Point2);
bool IsValidCenter(std::pair<int,int> Center) const;
void AddGate(Gate* pGate);
void AddSWITCH(SWITCH* pSWITCH);
void AddLED(LED* pLED);
void AddConnection(Connection* pConnection);
void RemoveGate(Gate* pGate);
void RemoveSWITCH(SWITCH* pSWITCH);
void RemoveLED(LED* pLED);
void RemoveConnection(Connection* pConnection);
Component* GetComponentAt(std::pair<int, int> Point);
Pin* GetPinAt(std::pair<int, int> Point);
private:
int SizeX, SizeY;
struct Node
{
int ParentX ,ParentY;
enum {NOCONNECTION, CONNECTIONFULL, VERTICAL, HORIZONTAL, CORNER, GATE, PINPOINT, NOTHING} State;
bool Visited, BelongToGate;
Component* pComp;
Pin* pPin;
};
std::vector< std::vector<Node> > Nodes;
std::vector< std::pair<int, int> > CreateThePath(std::pair<int, int> Point1, std::pair<int, int> Point2);
void ClearParent();
};
/*
-------------
-CCCCCCCCCCC-
-CCCCCCCCCCC-
-CCCCCCCCCCC-
-CCGGGGGGGCC-
-C*GGGGGGGCC-
-C*GGGGGGG*C-
-C*GGGGGGGCC-
-CCGGGGGGGCC-
-CCCCCCCCCCC-
-CCCCCCCCCCC-
-CCCCCCCCCCC-
-------------
*/