All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
NavigationGraphRoad.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "VectorMathDecl.h"
7 #include "Navigation.h"
8 #include "Geometry.h"
9 #include <vector>
10 
11 // TODO: Move the road direction enum elsewhere
12 #include "ParsedNavGraph.h"
13 
14 namespace Eegeo
15 {
16  namespace Resources
17  {
18  namespace Roads
19  {
20  namespace Navigation
21  {
23  {
24  public:
26  const std::vector<Eegeo::v3>::const_iterator verticesBegin,
27  const std::vector<Eegeo::v3>::const_iterator verticesEnd,
28  const std::vector<u16>::const_iterator connectionsToIndicesBegin,
29  const std::vector<u16>::const_iterator connectionsToIndicesEnd,
30  const std::vector<u16>::const_iterator connectionsFromIndicesBegin,
31  const std::vector<u16>::const_iterator connectionsFromIndicesEnd,
32  float halfWidth,
33  u8 averageSpeedInKph,
34  RoadDirection direction,
35  u8 roughSpeedLimitInKph,
36  FunctionalRoadClass::Type roadClass = FunctionalRoadClass::NotApplicable
37  );
38 
39  const std::vector<Eegeo::v3>& GetVertices() const { return m_vertices; }
40  const std::vector<int>& GetConnectionsToIndices() const { return m_connectionsToIndices; }
41  const std::vector<int>& GetConnectionsFromIndices() const { return m_connectionsFromIndices; }
42  float GetHalfWidth() const { return m_halfWidth; }
43  u8 GetAverageSpeedInKph() const { return m_averageSpeedInKph; }
44  RoadDirection GetRoadDirection() const { return m_direction; }
45  u8 GetRoughSpeedLimitInKph() const { return m_roughSpeedLimitInKph; }
46  int GetVertexCount() const { return static_cast<int>(m_vertices.size()); }
47  const FunctionalRoadClass::Type GetFunctionalRoadClass() const { return m_functionalRoadClass; }
48 
49  bool IsConnectedAtStart(const NavigationGraphRoad& road, const NavigationGraph& navGraph) const;
50  bool IsConnectedAtEnd(const NavigationGraphRoad& road, const NavigationGraph& navGraph) const;
51 
52  bool IsConnectedAtStart(const NavigationGraphRoad& road, const std::vector<NavigationGraphRoad*>& roads) const;
53  bool IsConnectedAtEnd(const NavigationGraphRoad& road, const std::vector<NavigationGraphRoad*>& roads) const;
54 
55  bool AreConnectionsValid(const NavigationGraph& navGraph) const;
56 
57 
58  void LinkAtStart(NavigationGraphLink* navGraphLink);
59  void LinkAtEnd(NavigationGraphLink* navGraphLink);
60  void Unlink(NavigationGraphLink* navGraphLink);
61 
62  const bool HasConnectionToCell() const { return m_connectionToCell != NULL; }
63  const bool HasConnectionFromCell() const { return m_connectionFromCell != NULL; }
64  NavigationGraphLink* GetConnectionToCell() const { return m_connectionToCell; }
65  NavigationGraphLink* GetConnectionFromCell() const { return m_connectionFromCell; }
66  const bool HasConnectionTo() { return HasConnectionToCell() || !GetConnectionsToIndices().empty(); }
67  const bool HasConnectionFrom() { return HasConnectionFromCell() || !GetConnectionsFromIndices().empty(); }
68  const bool IsActualDeadEnd(bool forwardsDirection) {
69  return (!HasConnectionTo() && forwardsDirection) ||
70  (!HasConnectionFrom() && !forwardsDirection);
71  }
72 
73  bool IsBoundaryVertexOrDeadEnd(int vertexIndex) const;
74 
75  void DisableRoad();
76  void EnableRoad();
77  void DisableVertex(int index);
78  void EnableVertex(int index);
79  bool IsVertexEnabled(int index) const;
80  bool HasDisabledVertices() const;
81 
82  private:
83  bool AreConnectionsValid(const NavigationGraph& navGraph, const std::vector<int>& connectionIndices) const;
84 
85  const std::vector<Eegeo::v3> m_vertices;
86  const std::vector<int> m_connectionsToIndices;
87  const std::vector<int> m_connectionsFromIndices;
88  const float m_halfWidth;
89  const u8 m_averageSpeedInKph;
90  const RoadDirection m_direction;
91  const u8 m_roughSpeedLimitInKph;
92  const Resources::Roads::FunctionalRoadClass::Type m_functionalRoadClass;
93 
94  std::vector<int> m_disabledVertexIndices;
95  NavigationGraphLink* m_connectionToCell;
96  NavigationGraphLink* m_connectionFromCell;
97  };
98  }
99  }
100  }
101 }