gwnavgeneration/generator/generator.h Source File

generator.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 // primary contact: GUAL - secondary contact: LASI
9 #ifndef GwNavGen_Generator_H
10 #define GwNavGen_Generator_H
11 
15 
31 
32 
33 namespace Kaim
34 {
35 
36 class IParallelForInterface;
37 class CollisionInterfaceFactory;
38 class NavMeshElementBlob;
39 class GeneratorSectorBuilder;
40 class GeneratorNavDataElement;
41 
42 
59 class Generator : public RefCountBaseNTS<Generator, MemStat_NavDataGen>
60 {
62 
63 friend class NavDataIndexBlobBuilder_FromGenerator;
64 
65 public:
75  Generator(Ptr<GeneratorInputProducer> producer,
76  Ptr<IParallelForInterface> parallelForInterface = KY_NULL,
77  Ptr<ITlsAlloc> tlsAlloc = KY_NULL,
78  Ptr<ICollisionInterface> visibilityInterface = KY_NULL);
79 
83  Generator(Ptr<GeneratorInputProducer> producer, Ptr<IGeneratorGlue> generatorGlue);
84 
85  ~Generator();
86 
87 public:
88  // ------------------------------ Configuration ------------------------------
89 
92  void SetFileOpener(FileOpenerBase* fileOpener);
93 
100  void SetOutputDirectory(const char* absoluteOutputBaseDir, const char* relativeOutputDir);
101 
103  const String& GetAbsoluteOutputDirectory() const { return m_sys.GetAbsoluteOutputDirectory(); }
104 
105  // ---------------------------------- Generation ----------------------------------
106 
111 
112  // ---------------------------------- Reporting ----------------------------------
113 
115  template <class OSTREAM> void LogConfiguration(OSTREAM& os);
116 
118  const GeneratorReport& GetGeneratorReport() const { return m_report; }
119 
121  const GeneratorProfiling& GetGeneratorProfiling() const { return m_generatorProfiling; }
122 
123  // ---------------------------------- Internal Access Only ----------------------------------
124 
125  GeneratorSystem& Sys() { return m_sys; }
126  const KyArray<Ptr<GeneratorSectorBuilder> >& GetSectorBuilders() const { return m_sectorBuilders; }
127 
128 private:
129  void ClearGeneratedData();
130  void ClearSectors();
131 
132  KyResult AddSector(Ptr<GeneratorSector> sector);
133 
134  void Init(Ptr<IParallelForInterface> parallelFor, Ptr<ITlsAlloc> tlsAlloc, Ptr<ICollisionInterface> visibilityInterface);
135 
136  KyResult GenerateInit(GeneratorInputOutput& generatorInputOutput);
137  bool CheckUserConfig(const GeneratorParameters& config) const;
138  bool CheckSysConfig() const;
139 
140  KyResult GenerateNavData();
141  KyResult ProduceSectorInputs();
142  void MakeGlobalGrid();
143  void MakeNavDataElements();
144  KyResult GenerateRawNavCells();
145  KyResult PerformSeedOrSurfaceFiltering();
146  KyResult PerformIntegrationOfTagvolumes();
147  KyResult MakeOutputBlobAggregates();
148  void ComputeStatistics();
149  KyResult BuildOutputDataIndex();
150  KyResult UpdateAndSaveGeneratorInputOutput();
151 
152  void AddInputCellInfosContributingToSingleGuid(
153  KyUInt32 mainIdx, const InputCellInfoArrayAtPos* inputCellInfoArrayAtPos, InputCellInfoArrayAtPos* contributingInputCellInfoArrayAtPos);
154 
155  bool IsGuidCompoundExclusive(const GeneratorGuidCompound& guidCompound) const;
156  void UpdateGeneratorInputOutput();
157  KyResult SaveGeneratorInputOutput();
158  KyResult SaveDatabaseDescriptorIndex();
159 
160  KyResult ProduceSectorInputs_FromChangedPatchs();
161  KyResult ProduceSectorInputs_FromSectorsOverlappingWithChangedPatches();
162  KyResult ProduceSectorInputs_FromChangedSectors();
163  KyResult ProduceSectorInputs_FromSectorsOverlappingWithChangedRegularSectors();
164 
165  void MakeNavDataElementsAtCellPos(const InputCellInfoArrayAtPos* cellsAtPos);
166  void RemoveInputTilesTempDir();
167 
168  KyResult MakeAbstractGraphs();
169 
170 public: //internal
171  void RemoveInputTilesPartTempDir();
172 
173 private:
174  Ptr<GeneratorInputProducer> m_producer;
175  Ptr<IGeneratorGlue> m_generatorGlue; // Ptr stored so that the passed glue is not deleted while being used
176  GeneratorSystem m_sys;
177  DefaultFileOpener m_defaultFileOpener;
178  KyArray<Ptr<GeneratorSectorBuilder> > m_sectorBuilders;
179  GeneratorSectorList m_sectorList;
180  InputCellInfoGrid m_inputCellGrid;
181  KyArray<GeneratorGuidCompound> m_exclusiveGuids;
182  GeneratorReport m_report;
183  GeneratorProfiling m_generatorProfiling;
184  KyArray<CellPos> m_patchedCellPositions;
185 };
186 
187 
188 template <class OSTREAM>
189 inline void Generator::LogConfiguration(OSTREAM& os)
190 {
191  os << KY_LOG_BIG_TITLE_BEGIN("", "Generator Configuration Info");
192 
193  os << m_sys;
194  os << m_sys.Config();
195  os << m_sys.RunOptions();
196 
197  for (KyUInt32 sectorIdx = 0; sectorIdx < m_sectorBuilders.GetCount(); ++sectorIdx)
198  {
199  os << KY_LOG_SMALL_TITLE_BEGIN("", "Sector " << sectorIdx <<" Info");
200  m_sectorBuilders[sectorIdx]->LogConfiguration(os);
201  os << KY_LOG_SMALL_TITLE_END("", "Sector " << sectorIdx <<" Info");
202  }
203 
204  os << KY_LOG_BIG_TITLE_END("", "Generator Configuration Info");
205 }
206 
207 
208 }
209 
210 
211 #endif
Base interface for a class that opens a file on disk.
Definition: fileopener.h:35
The GeneratorReport class encapsulates a detailed report of all activities carried out during a call ...
Definition: generatorreport.h:113
Provides an abstract base interface for an object that can treat computational jobs in parallel...
Definition: iparallelforinterface.h:43
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
const GeneratorReport & GetGeneratorReport() const
Retrieves a detailed record of the results of the last call to Generate().
Definition: generator.h:137
KyResult Generate(GeneratorInputOutput &config)
Launch the generation of the sectors stored in config, using the config parameters and runOptions als...
const String & GetAbsoluteOutputDirectory() const
returns absoluteOutputBaseDir/relativeOutputDir set by SetOutputDirectory()
Definition: generator.h:114
GeneratorSystem gathers everything that is global across a generation: configuration, options...
Definition: generatorsystem.h:46
The Generator is the principal class in the NavData generation system.
Definition: generator.h:61
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:118
#define KY_NULL
Null value.
Definition: types.h:247
An abstract interface for an object that can perform collision queries.
Definition: icollisioninterface.h:26
const GeneratorProfiling & GetGeneratorProfiling() const
Get some profiling information about the time taken by the various steps of the generation.
Definition: generator.h:140
Definition: gamekitcrowddispersion.h:20
The GeneratorInputOutput class is a central element of the generation.
Definition: generatorinputoutput.h:41
The GeneratorParameters class contains configuration parameters that control the characteristics of t...
Definition: generatorparameters.h:75
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
Simple default implementation of an object that opens a file on disk.
Definition: fileopener.h:59
The GeneratorInputProducer is an abstract base class for an object invoked by the NavData generation ...
Definition: generatorinputproducer.h:36
This class is a wrapper around an array of KyGuid objects.
Definition: generatorguidcompound.h:22
void SetFileOpener(FileOpenerBase *fileOpener)
Sets the Kaim::FileOpenerBase derived class that will be used to open any files.
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
void SetOutputDirectory(const char *absoluteOutputBaseDir, const char *relativeOutputDir)
Sets the directory used for the generation.
void LogConfiguration(OSTREAM &os)
Creates a detailed record of all configuration parameters and sector information, and writes the reco...
Definition: generator.h:217
Provides an abstract base interface for a class that the Generator can invoke in order to retrieve ob...
Definition: igeneratorglue.h:35