DHART
Loading...
Searching...
No Matches
Edge.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <node.h>
10#include <vector>
11
12namespace HF {
13 namespace SpatialStructures {
15 enum STEP {
17 NONE = 1,
18 UP = 2,
19 DOWN = 3,
20 OVER = 4
21 };
22
24
29 struct Edge {
32 float score;
33
40
50 Edge(const Node& Child, float Score = 0, STEP Step_Type = NONE);
51
53 Edge() {};
54 };
55
56
58 struct IntEdge {
59 int child;
60 float weight;
61
62
63 inline bool operator==(const IntEdge& IE2) const {
64 return ( (this->child == IE2.child && abs(this->weight - IE2.weight) < 0.0001 ) // \todo resolve this constant for edge tolerance?
65 );
66 }
67
68 inline bool operator!=(const IntEdge& IE2) const { return !(this->operator==(IE2)); }
69 };
70
72
77 struct EdgeSet {
78 int parent;
79 std::vector<IntEdge> children;
80
82 EdgeSet() { parent = -1; };
83
84
86 inline EdgeSet(int parent, const std::vector<IntEdge>& edges) {
87 this->AddEdges(edges);
88 this->parent = parent;
89 }
90
92 inline int size() const { return children.size(); }
93
95 inline void AddEdges(const std::vector<IntEdge> & edges) {
96 // If we have no edges, just overwrite our existing array
97 if (children.size() == 0)
98 children = edges;
99 // Otherwise resize and copy in
100 else {
101 children.resize(children.size() + edges.size());
102 std::copy(edges.begin(), edges.end(), children.begin() + children.size());
103 }
104 }
105
107 inline bool operator==(const EdgeSet & ES2) const {
108 if (this->parent != ES2.parent) return false;
109 if (this->children.size() != ES2.children.size()) return false;
110
111 for (int i = 0; i < this->children.size(); i++)
112 if (this->children[i] != ES2.children[i])
113 return false;
114 return true;
115 }
116 };
117 }
118}
Contains definitions for the Node structure.
Perform human scale analysis on 3D environments.
STEP
Describes the type of step an edge connects to.
Definition: Edge.h:15
@ DOWN
A step down is required to get from parent to child.
Definition: Edge.h:19
@ NONE
Parent and child are on the same plane and no step is required.
Definition: Edge.h:17
@ UP
A step up is required to get from parent to child.
Definition: Edge.h:18
@ NOT_CONNECTED
No connection between parent and child.
Definition: Edge.h:16
@ OVER
A step over something is required to get from parent to child.
Definition: Edge.h:20
A connection to a child node.
Definition: Edge.h:29
Edge()
Default Constructor.
Definition: Edge.h:53
Node child
The child node for this edge.
Definition: Edge.h:30
STEP step_type
Step required to traverse this edge.
Definition: Edge.h:31
float score
The cost required to traverse this edge.
Definition: Edge.h:32
A lighter version of Edge that contains an ID instead of a full node object..
Definition: Edge.h:58
float weight
Cost to traverse to child.
Definition: Edge.h:60
bool operator!=(const IntEdge &IE2) const
Definition: Edge.h:68
int child
Identifier of child node.
Definition: Edge.h:59
bool operator==(const IntEdge &IE2) const
Definition: Edge.h:63
A collection of edges and a parent.
Definition: Edge.h:77
int parent
Identifier of parent node.
Definition: Edge.h:78
bool operator==(const EdgeSet &ES2) const
Check the equality of two edge sets.
Definition: Edge.h:107
EdgeSet(int parent, const std::vector< IntEdge > &edges)
Construct an edge set with a list of int edges and a parent.
Definition: Edge.h:86
void AddEdges(const std::vector< IntEdge > &edges)
Add a set of edges to the array of children.
Definition: Edge.h:95
std::vector< IntEdge > children
vector of IntEdge (children)
Definition: Edge.h:79
int size() const
Get the number of children in this edgeset.
Definition: Edge.h:92
EdgeSet()
Empty Constructor.
Definition: Edge.h:82
A point in space with an ID.
Definition: node.h:38