All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
NavigationGraph.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "BuiltResourceWithKey.h"
6 #include "Types.h"
7 #include "Navigation.h"
8 #include "Space.h"
9 #include "VectorMath.h"
10 #include "CubeMapCellInfo.h"
11 #include "DoublePlane.h"
12 #include "Graphs.h"
13 #include "Point3Spline.h"
14 
15 #include <vector>
16 #include <algorithm>
17 
18 
19 
20 namespace Eegeo
21 {
22  namespace Resources
23  {
24  namespace Roads
25  {
26  namespace Navigation
27  {
29  {
30  public:
31  typedef std::vector<NavigationGraphRoad*> TRoadsVector;
32 
35  const std::vector<Geometry::DoublePlane>& cellBoundaryPlanes,
36  TRoadsVector roads,
37  const std::vector<u16>::const_iterator roadIndicesJoiningCellBegin,
38  const std::vector<u16>::const_iterator roadIndicesJoiningCellEnd,
39  const std::vector<u16>::const_iterator roadIndicesLeavingCellBegin,
40  const std::vector<u16>::const_iterator roadIndicesLeavingCellEnd,
41  NavigationGraphRepository* const navigationGraphRepository,
42  size_t totalVerticesInNavigationGraph,
43  const std::vector<Geometry::Point3Spline>& roadSplines,
44  Graphs::TiledGraphCell* pTiledGraphCell
45  );
46 
49  const std::vector<Geometry::DoublePlane>& cellBoundaryPlanes,
50  NavigationGraphRepository* const navigationGraphRepository,
51  const std::vector<Geometry::Point3Spline>& roadSplines,
52  Graphs::TiledGraphCell* pTiledGraphCell
53  );
54 
55  virtual ~NavigationGraph();
56 
57  const Eegeo::Space::CubeMap::CubeMapCellInfo& GetCellInfo() const { return m_cellInfo; }
58  const std::vector<Geometry::DoublePlane>& GetCellBoundaryPlanes() const { return m_cellBoundaryPlanes; }
59  size_t GetTotalVerticesInNavigationGraph() const { return m_totalVerticesInNavigationGraph; }
60 
61  const Eegeo::v3& GetUpECEF() const { return m_upECEF; }
62  const TRoadsVector& GetRoads() const { return m_roads; }
63  const std::vector<u16> GetRoadIndicesJoiningCell() const { return m_roadIndicesJoiningCell; }
64  const std::vector<u16> GetRoadIndicesLeavingCell() const { return m_roadIndicesLeavingCell; }
65  const TRoadsVector& GetRoadsWithCellConnections() const { return m_roadsWithCellConnections; }
66  void ClearRoadsWithCellConnections() { m_roadsWithCellConnections.clear(); }
67 
68  void Unload();
69  void AddedToSceneGraph();
70  void RemovedFromSceneGraph();
71 
72  void RegisterRoadWithCellConnection(NavigationGraphRoad* road);
73  bool OwnsRoad(NavigationGraphRoad* road) const { return std::find(m_roads.begin(), m_roads.end(), road) != m_roads.end(); }
74 
75  const std::vector<Geometry::Point3Spline>& GetRoadSplines() const { return m_roadSplines; }
76  Graphs::TiledGraphCell& GetTiledGraphCell() const { return *m_pTiledGraphCell; }
77 
78  private:
79  bool IsValid() const;
80  bool AreConnectionsValid() const;
81 
82  TRoadsVector m_roads;
83  TRoadsVector m_roadsWithCellConnections;
84  std::vector<u16> m_roadIndicesLeavingCell;
85  std::vector<u16> m_roadIndicesJoiningCell;
87  std::vector<Geometry::DoublePlane> m_cellBoundaryPlanes;
88  Eegeo::v3 m_upECEF;
89  NavigationGraphRepository* m_navigationGraphRepository;
90  size_t m_totalVerticesInNavigationGraph;
91 
92  std::vector<Geometry::Point3Spline> m_roadSplines;
93  Graphs::TiledGraphCell* const m_pTiledGraphCell;
94  };
95  }
96  }
97  }
98 }