-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathTopologyDescImpl.h
109 lines (82 loc) · 3.41 KB
/
TopologyDescImpl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// TopologyDescImpl.h
//
// Topology implementation helpers
// Copyright (c) 2017 Kronosaur Productions, LLC. All Rights Reserved.
#pragma once
class CNetworkTopologyCreator
{
public:
CNetworkTopologyCreator (const CTopologyDesc &Desc);
ALERROR Create (STopologyCreateCtx &Ctx, CTopology &Topology, CTopologyNode **retpNode = NULL) const;
private:
const CTopologyDesc &m_Desc;
};
class CRandomTopologyCreator
{
public:
enum ENetworkTypes
{
netUnknown,
netWeb, // Full tessellation
netTree, // Greedy algorithm from starting node
netLine, // Minimal network for full connection
};
CRandomTopologyCreator (const CTopologyDesc &Desc);
ALERROR Create (STopologyCreateCtx &Ctx, CTopology &Topology, CTopologyNode **retpNode = NULL) const;
ALERROR FindExistingNode (STopologyCreateCtx &Ctx, CTopology &Topology, CTopologyNode *pExistingNode, CTopologyNode **retpNode) const;
private:
ALERROR AddRandomRegion (STopologyCreateCtx &Ctx, CTopology &Topology, CXMLElement *pRegionDef, CTopologyNode *&pExitNode, CIntGraph &Graph, TArray<CTopologyNode *> &Nodes) const;
ALERROR ApplyNodeTemplate (STopologyCreateCtx &Ctx, CTopology &Topology, const TArray<CTopologyNode *> &Nodes, CXMLElement *pNodeTemplate, bool bUnmarkedOnly) const;
ALERROR ApplyRandomNodeParams (STopologyCreateCtx &Ctx, CTopology &Topology, const TArray<CTopologyNode *> &Nodes) const;
static ENetworkTypes ParseNetworkType (const CString &sValue);
const CTopologyDesc &m_Desc;
};
class CTopologySystemDesc
{
public:
void Apply (CTopology &Topology, CTopologyNode *pNode) const;
ALERROR InitFromXML (SDesignLoadCtx &LoadCtx, CXMLElement *pDesc);
inline bool IsEmpty (void) const { return m_bEmpty; }
private:
bool m_bEmpty = true; // If TRUE, no settings here.
DWORD m_dwSystemUNID = 0; // System UNID (0 = not set)
CString m_sName; // System name
int m_iLevel = 0; // System level (0 = not set)
CString m_sAttributes; // System attributes
CString m_sVariantFromParent; // System variant (from parent)
CString m_sVariantFromSub; // System variant (from sub-element)
TUniquePtr<IElementGenerator> m_pGenerator;
CNameDesc m_Names;
bool m_bDeferCreate = false; // Do not create system until later
};
class CDelaunayStargateGenerator
{
public:
CDelaunayStargateGenerator (CIntGraph &Graph, const TArray<CTopologyNode *> &Nodes);
void Generate (TArray<CTopologyNode::SStargateRouteDesc> &Routes);
private:
CIntGraph &m_Graph;
const TArray<CTopologyNode *> &m_Nodes;
};
class CSimplePathStargateGenerator
{
public:
CSimplePathStargateGenerator (CIntGraph &Graph, const TArray<CTopologyNode *> &Nodes);
void Generate (DWORD dwFirstNode, TArray<CTopologyNode::SStargateRouteDesc> &Routes);
private:
bool FindConnection (const CLargeSet &Connected, const CLargeSet &Unconnected, DWORD *retdwFrom, DWORD *retdwTo) const;
Metric GetDistance (DWORD dwFrom, DWORD dwTo) const;
CIntGraph &m_Graph;
const TArray<CTopologyNode *> &m_Nodes;
mutable TSortMap<DWORD, TSortMap<DWORD, Metric>> m_Distance;
};
class CTreePathStargateGenerator
{
public:
CTreePathStargateGenerator (CIntGraph &Graph, const TArray<CTopologyNode *> &Nodes);
void Generate (DWORD dwFirstNode, TArray<CTopologyNode::SStargateRouteDesc> &Routes);
private:
DWORD FindConnection (DWORD dwFrom, const CLargeSet &Unconnected) const;
CIntGraph &m_Graph;
const TArray<CTopologyNode *> &m_Nodes;
};