gwnavgeneration/generator/generatorsystem.h Source File

generatorsystem.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
9 
10 
28 
29 
30 namespace Kaim
31 {
32 
33 class GeneratorInputOutput;
34 class BlobCategory;
35 class BlobAggregate;
36 class GeneratorProfiling;
37 class BaseVisualDebugServer;
38 class BaseVisualDebugManager;
39 class VisualDebugServer;
40 class FileOpenerBase;
41 class GeneratorReport;
42 class DisplayListManager;
43 
46 {
47  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavDataGen)
48 
49 public:
51  ~GeneratorSystem();
52 
53  void Init(GeneratorInputOutput* genIO);
54 
55  const GeneratorParameters& Config() const { return m_genIO->m_params; }
56  GeneratorParameters& Config() { return m_genIO->m_params; }
57 
58  const GeneratorAdvancedParameters& AdvancedParams() const { return m_genIO->m_params.m_advancedParameters; }
59  GeneratorAdvancedParameters& AdvancedParams() { return m_genIO->m_params.m_advancedParameters; }
60 
61  const GeneratorAbstractGraphParameters& AbstractGraphParams() const { return m_genIO->m_abstractGraphParams; }
62  GeneratorAbstractGraphParameters& AbstractGraphParams() { return m_genIO->m_abstractGraphParams; }
63 
64  const GeneratorRunOptions& RunOptions() const { return m_genIO->m_runOptions; }
65  GeneratorRunOptions& RunOptions() { return m_genIO->m_runOptions; }
66 
67  const GeneratorFileSystem& GetFileSystem() const { return m_fileSystem; }
68  GeneratorFileSystem& GetFileSystem() { return m_fileSystem; }
69 
70  const String& GetAbsoluteOutputDirectory() const { return GetFileSystem().GetAbsoluteOutputDirectory(); }
71  String GetAbsoluteFileName(const String& relativeFileName) const { return GetFileSystem().GetAbsoluteFileName(relativeFileName); }
72 
73  IParallelForInterface* GetParallelForIfUseMulticore();
74 
75  const PixelAndCellGrid& GetPixelAndCellGrid() const { return m_pixelAndCellGrid; }
76  PixelAndCellGrid& GetPixelAndCellGrid() { return m_pixelAndCellGrid; }
77 
78  KyFloat32 GetNormalizedRasterPrecision() const { return m_genIO->m_params.m_normalizedParameters.m_normalizedRasterPrecision; }
79  KyFloat32 GetNormalizedCellSize() const { return m_genIO->m_params.m_normalizedParameters.m_normalizedCellSize; }
80 
81  const IntermediateFilesConfig& GetIntermediates() const { return m_genIO->m_runOptions.m_intermediateFiles; }
82 
83  // Load Blob from fileName
84  void* LoadBlobBase(const char* fileName, BaseBlobHandler& blobHandler);
85 
86  template<class T>
87  T* LoadBlob(const char* fileName, BlobHandler<T>& blobHandler) { return (T*)LoadBlobBase(fileName, blobHandler); }
88 
89  // Save Blob to fileName
90  KyResult SaveBlob(const char* fileName, const BaseBlobHandler& blobHandler, Endianness::Type endianness = Endianness::LittleEndian);
91 
92  // Load BlobAggregate from fileName
93  KyResult LoadAggregate(const char* fileName, BlobAggregate& aggregate);
94 
95  // Save Blob to fileName
96  KyResult SaveAggregate(const char* fileName, BlobAggregate& aggregate, Endianness::Type endianness = Endianness::LittleEndian);
97 
99  bool IsInputTilingEnabled() const { return RunOptions().m_doEnableLimitedMemoryMode; }
100  KyUInt32 GetInputTileSizeInNbCells() const { return RunOptions().m_limitedMemoryModeTileSizeInNbCells; }
101 
102  // Create m_visualDebugServer and m_displayListManager
103  void InitVisualDebug();
104 
105 private:
106  void InitFromParams(GeneratorParameters& params);
107  KyResult ComputeGenerationMode();
108 
109  void DestroyVisualDebug();
110  bool IsVisualDebugConnected();
111  VisualDebugServer* GetVisualDebugServerIfConnected();
112 
113 public:
114  GeneratorInputOutput* m_genIO;
115  DatabaseGenMetrics m_genMetrics;
116  PixelAndCellGrid m_pixelAndCellGrid;
117  GeneratorIntegerCoords m_integerCoords;
118  KyUInt32 m_timeStamp;
119  String m_generatorInputOuputSaveFileName;
120  GeneratorFileSystem m_fileSystem;
121  DenseGrid<KyUInt8> m_isMultipleInputAtCellPosGrid;
122  GeneratorNavDataElementMap m_navDataElementGlobalMap;
123  BlobCategory* m_blobRegistry;
124  Ptr<IParallelForInterface> m_parallelForInterface;
125  Ptr<ITlsAlloc> m_tlsAlloc;
126  Ptr<ICollisionInterface> m_collisionInterface;
127  GeneratorProfiling* m_generatorProfiling;
128  FileOpenerBase* m_fileOpener;
129  VisualDebugServer* m_visualDebugServer;
130  DisplayListManager* m_displayListManager;
131  String m_inputTilesTempDir; // local to Generator::GetAbsoluteOutputDirectory()
132  String m_inputTilePartsTempDir; // local to Generator::GetAbsoluteOutputDirectory()
133  GenFlags::GenerationMode m_generationMode;
134  GeneratorReport* m_generatorReport;
135 };
136 
137 
138 template <class OSTREAM>
139 inline OSTREAM& operator<<(OSTREAM& os, GeneratorSystem& sys)
140 {
141  os << KY_LOG_SMALL_TITLE_BEGIN("", "GeneratorSystem Info");
142  os << "ParallelForInterface status: " << (sys.m_parallelForInterface ? "SET" : "UNSET") << Endl;
143  os << "VisualDebugServer status: " << (sys.m_visualDebugServer ? "CONNECTED" : "DECONNECTED") << Endl;
144  os << KY_LOG_SMALL_TITLE_END("", "GeneratorSystem Info");
145  return os;
146 }
147 
148 }
149 
150 
151 
Provides an abstract base interface for an object that can treat computational jobs in parallel...
Definition: iparallelforinterface.h:36
GeneratorAdvancedParameters m_advancedParameters
Contains more advanced configuration parameters.
Definition: generatorparameters.h:157
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
KyUInt32 m_limitedMemoryModeTileSizeInNbCells
Size of the internally used tiles for large scale generations and/or running generation with low memo...
Definition: generatorrunoptions.h:120
GeneratorSystem gathers everything that is global across a generation: configuration, options...
Definition: generatorsystem.h:45
The BlobHandler class is a top-level mechanism for serializing blobs between objects in memory and fi...
Definition: blobhandler.h:40
IntermediateFilesConfig m_intermediateFiles
Contains configuration parameters that relate to the generation of intermediate data files...
Definition: generatorrunoptions.h:162
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
bool IsInputTilingEnabled() const
Tiling enabled i.e. IsLowMemoryModeEnabled() or possibly a future fast-local-input-produce-mode.
Definition: generatorsystem.h:99
Little-endian format (used, for example, for Windows, Linux).
Definition: endianness.h:22
The GeneratorAdvancedParameters class is used by the GeneratorParameters class to maintain a set of c...
Definition: generatoradvancedparameters.h:30
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
The GeneratorInputOutput class is a central element of the generation.
Definition: generatorinputoutput.h:35
The GeneratorParameters class contains configuration parameters that control the characteristics of t...
Definition: generatorparameters.h:67
bool m_doEnableLimitedMemoryMode
Determines whether or not the input geometry consumption is buffered to avoid exceeding the memory li...
Definition: generatorrunoptions.h:115
The GeneratorRunOptions class contains configuration parameters that control the way in which the Gen...
Definition: generatorrunoptions.h:43
Type
Enumerates possible endianness types.
Definition: endianness.h:20
The IntermediateFilesConfig class is used by GeneratorRunOptions to store configuration parameters th...
Definition: intermediatefilesconfig.h:18
float KyFloat32
float
Definition: types.h:32