-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cpp
More file actions
59 lines (45 loc) · 943 Bytes
/
node.cpp
File metadata and controls
59 lines (45 loc) · 943 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "node.h"
Node::Node()
:fSolid(false), fGoal(false), fStart(false) {}
Node::Node(int id, bool isSolid, bool isGoal, bool isStart)
: fSolid(isGoal || isStart ? false:isSolid), fGoal(isGoal), fStart(isStart), fIdentity(id) {}
void Node::SetIsSolid(bool value)
{
fSolid = value;
if (fSolid)
{
fGoal = false;
fStart = false;
}
}
void Node::SetIsGoal(bool value)
{
fGoal = value;
if (fGoal)
{
fSolid = false;
fStart = false;
}
}
void Node::SetIsStart(bool value)
{
fStart = value;
if (fStart)
{
fSolid = false;
fGoal = false;
}
}
std::vector<int> Node::GetNeighbourIDs()
{
std::vector<int> IDs;
std::vector<Node*> n = GetNeighbours();
for (int i = 0; i < n.size(); i++)
IDs.push_back(n[i]->Identify());
return IDs;
}
void Node::Change(const Node& n)
{
fSolid = n.fSolid;
fGoal = n.fGoal;
}