Helios++
Helios software for LiDAR simulations
|
Class for asset loading from XML file. More...
#include <XmlAssetsLoader.h>
Public Member Functions | |
XmlAssetsLoader (std::string &filePath, std::string &assetsDir) | |
Build a XmlAssetsLoader for given XML file and assets directory. More... | |
std::shared_ptr< Asset > | getAssetById (std::string type, std::string id, void *extraOutput=nullptr) |
Get asset by its identifier. More... | |
std::shared_ptr< Asset > | getAssetByLocation (std::string type, std::string location, void *extraOutput=nullptr) |
Get asset by location. More... | |
std::shared_ptr< Asset > | createAssetFromXml (std::string type, tinyxml2::XMLElement *assetNode, void *extraOutput=nullptr) |
Create an asset from given XML element (node) More... | |
std::shared_ptr< Asset > | createProceduralAssetFromXml (std::string const &type, std::string const &id, void *extraOutput=nullptr) |
Like XmlAssetsLoader::createAssetFromXml but creating the asset procedurally instead of simply loading it. More... | |
std::shared_ptr< Platform > | createPlatformFromXml (tinyxml2::XMLElement *platformNode) |
Create a platform from given XML element (node) More... | |
std::shared_ptr< PlatformSettings > | createPlatformSettingsFromXml (tinyxml2::XMLElement *node, std::unordered_set< std::string > *fields=nullptr) |
Create platform settings from given XML element (node) More... | |
std::shared_ptr< Platform > | procedurallyCreatePlatformFromXml (string const &type, string const &id) |
Procedurally create the platform from given XML specification. More... | |
std::shared_ptr< Platform > | createInterpolatedMovingPlatform () |
Procedurally create an InterpolatedMovingPlatform. More... | |
std::shared_ptr< Scanner > | createScannerFromXml (tinyxml2::XMLElement *scannerNode) |
Create scanner from given XML element (node) More... | |
std::shared_ptr< AbstractBeamDeflector > | createBeamDeflectorFromXml (tinyxml2::XMLElement *scannerNode) |
Create a beam deflector from given XML element (node) More... | |
std::shared_ptr< AbstractDetector > | createDetectorFromXml (tinyxml2::XMLElement *scannerNode, std::shared_ptr< Scanner > scanner) |
Create a pulse detector from given XML element (node) More... | |
std::shared_ptr< ScannerHead > | createScannerHeadFromXml (tinyxml2::XMLElement *scannerNode) |
Create a scanner head from given XML element (node) More... | |
std::shared_ptr< ScannerSettings > | createScannerSettingsFromXml (tinyxml2::XMLElement *node, std::unordered_set< std::string > *fields=nullptr) |
Create scanner settings from given XML element (node) More... | |
std::shared_ptr< FWFSettings > | createFWFSettingsFromXml (tinyxml2::XMLElement *node, std::shared_ptr< FWFSettings > settings=nullptr) |
Create FWF settings from given XML element (node) More... | |
std::shared_ptr< TrajectorySettings > | createTrajectorySettingsFromXml (tinyxml2::XMLElement *legNode, std::shared_ptr< TrajectorySettings > settings=nullptr) |
Create TrajectorySettings from given XML element (node) More... | |
void | fillScanningDevicesFromChannels (std::shared_ptr< Scanner > scanner, tinyxml2::XMLElement *scannerNode, tinyxml2::XMLElement *channels, std::shared_ptr< AbstractBeamDeflector > deflec, std::shared_ptr< AbstractDetector > detec, std::shared_ptr< ScannerHead > scanHead, std::shared_ptr< FWFSettings > fwfSettings) |
Fill vector of scanning devices with channel data. More... | |
Static Public Member Functions | |
static bool | isProceduralAsset (std::string const &type, std::string const &id) |
Check whether the given asset is a procedural asset or not. More... | |
Public Attributes | |
XmlSceneLoader | sceneLoader |
The scene loader. It is used to load scenes from XML files. | |
tinyxml2::XMLDocument | doc |
XML file through tinyxml2 library. | |
Protected Member Functions | |
virtual void | reinitLoader () |
Reinitialize the loader so maps with scanner fields and scanner templates and their fields are empty. | |
void | makeDefaultTemplates () |
void | trackNonDefaultScannerSettings (std::shared_ptr< ScannerSettings > base, std::shared_ptr< ScannerSettings > ref, std::string const defaultTemplateId, std::unordered_set< std::string > &fields) |
Track non default values at base. It is, those values which are in base distinct than the reference (ref) More... | |
void | trackNonDefaultPlatformSettings (std::shared_ptr< PlatformSettings > base, std::shared_ptr< PlatformSettings > ref, std::string const defaultTemplateId, std::unordered_set< std::string > &fields) |
Track non default values at base. It is, those values which are in base distinct than the reference (ref) More... | |
Protected Attributes | |
std::string | assetsDir |
Assets directory. | |
std::string | xmlDocFilename = "unknown.xml" |
Name of the XML file. | |
std::string | xmlDocFilePath = "" |
Path to the XML file. | |
std::shared_ptr< ScannerSettings > | defaultScannerTemplate |
The default scanner settings template. | |
std::shared_ptr< PlatformSettings > | defaultPlatformTemplate |
The default platform settings template. | |
std::unordered_map< std::string, std::shared_ptr< ScannerSettings > > | scannerTemplates |
Map containing all scanner templates that were loading while building from XML file. No repetitions, each template appears only one time. More... | |
std::unordered_map< std::string, std::shared_ptr< PlatformSettings > > | platformTemplates |
Map containing all platform templates that were loading while building from XML file. No repetitions, each template appears only one time. More... | |
std::unordered_map< std::string, std::unordered_set< std::string > > | scannerTemplatesFields |
Map containing the set of fields that have been overloaded by each scanner template. More... | |
std::unordered_map< std::string, std::unordered_set< std::string > > | platformTemplatesFields |
Map containing the set of fields that have been overloaded by each platform template. More... | |
Static Protected Attributes | |
static std::string const | defaultScannerSettingsMsg |
The message to be shown when default value is loaded for scanner settings. More... | |
static std::string const | defaultPlatformSettingsMsg |
The message to be shown when default value is loaded for platform settings. More... | |
Class for asset loading from XML file.
It is the main class for XML loading. It uses both XmlSceneLoader and XmlUtils
XmlAssetsLoader::XmlAssetsLoader | ( | std::string & | filePath, |
std::string & | assetsDir | ||
) |
Build a XmlAssetsLoader for given XML file and assets directory.
filePath | Path to XML File |
assetsDir | Path to assets directory |
std::shared_ptr< Asset > XmlAssetsLoader::createAssetFromXml | ( | std::string | type, |
tinyxml2::XMLElement * | assetNode, | ||
void * | extraOutput = nullptr |
||
) |
Create an asset from given XML element (node)
type | Asset type |
assetNode | XML element (node) containing asset data |
extraOutput[out] | Pointer to where extra output must be stored. If it is null, it means no extra output is required. Notice this only will be used when requested asset supports extra output |
std::shared_ptr< AbstractBeamDeflector > XmlAssetsLoader::createBeamDeflectorFromXml | ( | tinyxml2::XMLElement * | scannerNode | ) |
Create a beam deflector from given XML element (node)
scannerNode | XML element (node) containing deflector data |
std::shared_ptr< AbstractDetector > XmlAssetsLoader::createDetectorFromXml | ( | tinyxml2::XMLElement * | scannerNode, |
std::shared_ptr< Scanner > | scanner | ||
) |
Create a pulse detector from given XML element (node)
scannerNode | XML element (node) containing deflector data |
scanner | The shared pointer to the scanner associated to the detector |
std::shared_ptr< FWFSettings > XmlAssetsLoader::createFWFSettingsFromXml | ( | tinyxml2::XMLElement * | node, |
std::shared_ptr< FWFSettings > | settings = nullptr |
||
) |
Create FWF settings from given XML element (node)
node | XML element (node) containing FWF settings data |
settings | Specify the FWFSettings instance to use as output. If nullptr is specified, then a new instance of FWFSettings is used |
std::shared_ptr< Platform > XmlAssetsLoader::createInterpolatedMovingPlatform | ( | ) |
Procedurally create an InterpolatedMovingPlatform.
std::shared_ptr< Platform > XmlAssetsLoader::createPlatformFromXml | ( | tinyxml2::XMLElement * | platformNode | ) |
Create a platform from given XML element (node)
platformNode | XML element (node) containing platform data |
std::shared_ptr< PlatformSettings > XmlAssetsLoader::createPlatformSettingsFromXml | ( | tinyxml2::XMLElement * | node, |
std::unordered_set< std::string > * | fields = nullptr |
||
) |
Create platform settings from given XML element (node)
node | XML element (node) containing platform settings data |
std::shared_ptr< Asset > XmlAssetsLoader::createProceduralAssetFromXml | ( | std::string const & | type, |
std::string const & | id, | ||
void * | extraOutput = nullptr |
||
) |
Like XmlAssetsLoader::createAssetFromXml but creating the asset procedurally instead of simply loading it.
std::shared_ptr< Scanner > XmlAssetsLoader::createScannerFromXml | ( | tinyxml2::XMLElement * | scannerNode | ) |
Create scanner from given XML element (node)
scannerNode | XML element (node) containing scanner data |
std::shared_ptr< ScannerHead > XmlAssetsLoader::createScannerHeadFromXml | ( | tinyxml2::XMLElement * | scannerNode | ) |
Create a scanner head from given XML element (node)
scannerNode | XML element (node) containing scanner head data |
std::shared_ptr< ScannerSettings > XmlAssetsLoader::createScannerSettingsFromXml | ( | tinyxml2::XMLElement * | node, |
std::unordered_set< std::string > * | fields = nullptr |
||
) |
Create scanner settings from given XML element (node)
node | XML element (node) containing scanner settings data | |
[out] | fields | When it is not a nullptr, names of read values will be stored here |
std::shared_ptr< TrajectorySettings > XmlAssetsLoader::createTrajectorySettingsFromXml | ( | tinyxml2::XMLElement * | legNode, |
std::shared_ptr< TrajectorySettings > | settings = nullptr |
||
) |
Create TrajectorySettings from given XML element (node)
legNode | XML element (node) containing the Leg specification to build TrajectorySettings from |
settings | Specify the TrajectorySettings instance to use as output. If nullptr is specified, then a new instance of TrajectorySettings is used |
void XmlAssetsLoader::fillScanningDevicesFromChannels | ( | std::shared_ptr< Scanner > | scanner, |
tinyxml2::XMLElement * | scannerNode, | ||
tinyxml2::XMLElement * | channels, | ||
std::shared_ptr< AbstractBeamDeflector > | deflec, | ||
std::shared_ptr< AbstractDetector > | detec, | ||
std::shared_ptr< ScannerHead > | scanHead, | ||
std::shared_ptr< FWFSettings > | fwfSettings | ||
) |
Fill vector of scanning devices with channel data.
scanner | The multi-channel scanner to be filled |
scannerNode | The XML element representing the scanner |
channels | The channels to fill each scanning device |
deflec | The base deflector for each scanning device |
detec | The base detector for each scanning device |
scanHead | The base scanner head for each scanning device |
fwfSettings | The base fullwave settings for each scanning device |
std::shared_ptr< Asset > XmlAssetsLoader::getAssetById | ( | std::string | type, |
std::string | id, | ||
void * | extraOutput = nullptr |
||
) |
Get asset by its identifier.
type | Type of the asset |
id | Identifier of the asset |
extraOutput[out] | Pointer to where extra output must be stored. If it is null, it means no extra output is required. Notice this only will be used when requested asset supports extra output |
std::shared_ptr< Asset > XmlAssetsLoader::getAssetByLocation | ( | std::string | type, |
std::string | location, | ||
void * | extraOutput = nullptr |
||
) |
Get asset by location.
type | Type of the asset |
location | Location of the asset |
extraOutput[out] | Pointer to where extra output must be stored. If it is null, it means no extra output is required. Notice this only will be used when requested asset supports extra output |
|
static |
Check whether the given asset is a procedural asset or not.
A procedural asset is said to be an asset which is generated during execution. While it can be based in input data, it is not fully defined by that data. An example of procedural asset would be the InterpolatedMovingPlatform which is specified through the type "platform" and the id "interpolated"
type | Type of the asset |
id | Identifier of the asset |
|
protected |
std::shared_ptr< Platform > XmlAssetsLoader::procedurallyCreatePlatformFromXml | ( | string const & | type, |
string const & | id | ||
) |
Procedurally create the platform from given XML specification.
type | Asset type |
id | Identifier of the asset |
|
protected |
Track non default values at base. It is, those values which are in base distinct than the reference (ref)
base | Platform settings to be tracked |
ref | Reference platform settings defining default values |
defaultTemplateId | The identifier of reference/default template |
fields | Where tracked non default values must be stored |
|
protected |
Track non default values at base. It is, those values which are in base distinct than the reference (ref)
base | Scanner settings to be tracked |
ref | Reference scanner settings defining default values |
defaultTemplateId | The identifier of reference/default template |
fields | Where tracked non default values must be stored |
|
staticprotected |
The message to be shown when default value is loaded for platform settings.
|
staticprotected |
The message to be shown when default value is loaded for scanner settings.
|
protected |
Map containing all platform templates that were loading while building from XML file. No repetitions, each template appears only one time.
The id of the template is used as the key, while the template itself is the value (PlatformSettings object)
|
protected |
Map containing the set of fields that have been overloaded by each platform template.
The id of the template is used as the key, while the set of fields itself is the value
|
protected |
Map containing all scanner templates that were loading while building from XML file. No repetitions, each template appears only one time.
The id of the template is used as the key, while the template itself is the value (ScannerSettings object)
|
protected |
Map containing the set of fields that have been overloaded by each scanner template.
The id of the template is used as the key, while the set of fields itself is the value