forked from Conedy/Conedy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspatialNetwork.cpp
76 lines (46 loc) · 1.65 KB
/
spatialNetwork.cpp
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
65
66
67
68
69
70
71
72
73
74
75
76
#include "spatialNetwork.h"
namespace conedy
{
//nodeDescriptor spatialNetwork::addNode()
//{
// return network::addNode();
//}
void spatialNetwork::connectCloseNodes(node *source, node * target, baseType dist, edgeBlueprint *l)
{
networkElementType sourceNodeType = source->getNodeInfo().theNodeType;
networkElementType targetNodeType = target->getNodeInfo().theNodeType;
nodeList sources, targets;
nodeIterator si, ti;
verticesMatching(sources, sourceNodeType);
verticesMatching(targets, targetNodeType);
double distance = dist * dist;
for (si = sources.begin(); si != sources.end(); si++)
for (ti = targets.begin(); ti != targets.end(); ti++)
if ((euclidianDistance(*si, *ti) < distance) && (*si != *ti))
addEdge(*si, *ti, l);
}
void spatialNetwork::connectCloseNodesTorus(node *source, node * target, baseType dist, edgeBlueprint *l)
{
networkElementType sourceNodeType = source->getNodeInfo().theNodeType;
networkElementType targetNodeType = target->getNodeInfo().theNodeType;
nodeList sources, targets;
nodeIterator si, ti;
verticesMatching(sources, sourceNodeType);
verticesMatching(targets, targetNodeType);
double distance = dist * dist;
for (si = sources.begin(); si != sources.end(); si++)
for (ti = targets.begin(); ti != targets.end(); ti++)
if ((euclidianDistanceTorus(*si, *ti) < distance) && (*si != *ti))
addEdge(*si, *ti, l);
}
nodeDescriptor spatialNetwork::addNode( nodeBlueprint *n)
{
if (((n->getNodeInfo().theNodeKind & _dynNode_) != 0) && nodePositioner != NULL)
{
nodePos.push_back(nodePositioner->getNodePosition());
return network::addNode(n);
}
else
return network::addNode(n);
}
};