All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TiledGraphNode.h
1 #pragma once
2 
3 #include "Graphs.h"
4 #include "VectorMath.h"
5 #include "MortonKey.h"
6 
7 #include <functional>
8 #include <vector>
9 #include <sstream>
10 
11 namespace Eegeo
12 {
13  namespace Graphs
14  {
16  {
18  : CellKey(Eegeo::Streaming::MortonKey(0))
19  , LocalNodeId(-1)
20  {}
21 
23  const Eegeo::Streaming::MortonKey& cellKey,
24  int localNodeId
25  )
26  : CellKey(cellKey)
27  , LocalNodeId(localNodeId)
28  {}
29 
31  : CellKey(other.CellKey)
32  , LocalNodeId(other.LocalNodeId)
33  {}
34 
35 
37  int LocalNodeId;
38  };
39 
40  inline bool operator == (const TiledGraphNodeId& lhs, const TiledGraphNodeId& rhs)
41  {
42  return (lhs.LocalNodeId == rhs.LocalNodeId) &&
43  (lhs.CellKey == rhs.CellKey);
44  }
45 
46  inline std::string TiledGraphNodeIdToString(const TiledGraphNodeId& nodeId)
47  {
48  std::stringstream ss;
49  ss << nodeId.CellKey.ToString() << ":" << nodeId.LocalNodeId;
50  return ss.str();
51  }
52 
53  inline TiledGraphNodeId MakeExternalTiledGraphNodeId()
54  {
55  return TiledGraphNodeId(Streaming::MortonKey(0), -1);
56  }
57 
59  {
60  std::size_t operator()(const TiledGraphNodeId& nodeId) const
61  {
62  std::size_t h1 = Eegeo::Streaming::MortonKeyHash{}(nodeId.CellKey);
63  std::size_t h2 = std::hash<int>{}(nodeId.LocalNodeId);
64  return h1 ^ (h2 << 1);
65  }
66  };
67 
69  {
71  : LocalPoint(v3::Zero())
72  , IncidentEdgesOffset(0)
73  , IncidentEdgesCount(0)
74  {}
75 
77  const v3& localPoint,
78  int incidentEdgesOffset,
79  int incidentEdgesCount
80  )
81  : LocalPoint(localPoint)
82  , IncidentEdgesOffset(incidentEdgesOffset)
83  , IncidentEdgesCount(incidentEdgesCount)
84  {}
85 
86  v3 LocalPoint;
87  int IncidentEdgesOffset;
88  int IncidentEdgesCount;
89  };
90 
91  inline bool operator == (const TiledGraphNode& lhs, const TiledGraphNode& rhs)
92  {
93  return (lhs.LocalPoint == rhs.LocalPoint) &&
94  (lhs.IncidentEdgesOffset == rhs.IncidentEdgesOffset) &&
95  (lhs.IncidentEdgesCount == rhs.IncidentEdgesCount);
96  }
97  }
98 }