All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RouteSampler.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Routes.h"
7 #include "Terrain.h"
8 #include "VectorMathDecl.h"
9 #include "Streaming.h"
10 
11 namespace Eegeo
12 {
13  namespace Routes
14  {
15  namespace Simulation
16  {
18  {
19  public:
20  RouteSampler(const Route& route,
21  const Fitting::FittedRouteRepository& fittedRouteRepository,
22  const Resources::Terrain::Heights::TerrainHeightProvider& terrainHeightProvider)
23  : m_route(route)
24  , m_fittedRouteRepository(fittedRouteRepository)
25  , m_terrainHeightProvider(terrainHeightProvider)
26  , m_fittedRouteSection(NULL)
27  {
28 
29  }
30 
31  void Invalidate()
32  {
33  m_fittedRouteSection = NULL;
34  }
35 
36  void InvalidateFittedRouteSectionForKey(const double routeParam, const Eegeo::Streaming::MortonKey& key);
37 
38  void UpdateFittedRouteSection(const double routeParam);
39 
40  RouteSample RouteSimVertexAtRouteParam(const double routeParam) const;
41 
42  private:
43  const Fitting::FittedRouteSection* FindFittedRouteSection(const double routeParam) const;
44 
45  bool TryGetLocalRouteVertex(const double routeParam, LocalRouteVertex& out_localRouteVertex, dv3& out_cellOrigin, v3& out_direction) const;
46 
47  bool TryGetInterpolatedLocalRouteVertex(const double routeParam, const Fitting::FittedRouteSection& fittedRouteSection, LocalRouteVertex& out_interpolatedVertex, v3& out_direction) const;
48 
49  dv3 ProjectOntoTerrain(const dv3& pointEcef) const;
50 
51 
52  const Route& m_route;
53  const Fitting::FittedRouteRepository& m_fittedRouteRepository;
54  const Resources::Terrain::Heights::TerrainHeightProvider& m_terrainHeightProvider;
55  const Fitting::FittedRouteSection* m_fittedRouteSection;
56  };
57 
58 
59  }
60  }
61 }