Helios++
Helios software for LiDAR simulations
XmlSurveyLoader Class Reference

Survey loader from XML. More...

#include <XmlSurveyLoader.h>

Inheritance diagram for XmlSurveyLoader:
Collaboration diagram for XmlSurveyLoader:

Public Member Functions

 XmlSurveyLoader (std::string &filePath, std::string &assetsDir)
 XML survey loader constructor. More...
 
std::shared_ptr< LegcreateLegFromXML (tinyxml2::XMLElement *legNode, std::unordered_set< std::string > *scannerFields, std::unordered_set< std::string > *platformFields)
 Create a leg from a XML element/node. More...
 
std::shared_ptr< SurveycreateSurveyFromXml (tinyxml2::XMLElement *surveyNode, bool legNoiseDisabled=false, bool rebuildScene=false)
 Create a survey form a XML element/node. More...
 
std::shared_ptr< Surveyload (bool legNoiseDisabled=false, bool rebuildScene=false)
 Load a full survey from XML. More...
 
- Public Member Functions inherited from XmlAssetsLoader
 XmlAssetsLoader (std::string &filePath, std::string &assetsDir)
 Build a XmlAssetsLoader for given XML file and assets directory. More...
 
std::shared_ptr< AssetgetAssetById (std::string type, std::string id, void *extraOutput=nullptr)
 Get asset by its identifier. More...
 
std::shared_ptr< AssetgetAssetByLocation (std::string type, std::string location, void *extraOutput=nullptr)
 Get asset by location. More...
 
std::shared_ptr< AssetcreateAssetFromXml (std::string type, tinyxml2::XMLElement *assetNode, void *extraOutput=nullptr)
 Create an asset from given XML element (node) More...
 
std::shared_ptr< AssetcreateProceduralAssetFromXml (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< PlatformcreatePlatformFromXml (tinyxml2::XMLElement *platformNode)
 Create a platform from given XML element (node) More...
 
std::shared_ptr< PlatformSettingscreatePlatformSettingsFromXml (tinyxml2::XMLElement *node, std::unordered_set< std::string > *fields=nullptr)
 Create platform settings from given XML element (node) More...
 
std::shared_ptr< PlatformprocedurallyCreatePlatformFromXml (string const &type, string const &id)
 Procedurally create the platform from given XML specification. More...
 
std::shared_ptr< PlatformcreateInterpolatedMovingPlatform ()
 Procedurally create an InterpolatedMovingPlatform. More...
 
std::shared_ptr< ScannercreateScannerFromXml (tinyxml2::XMLElement *scannerNode)
 Create scanner from given XML element (node) More...
 
std::shared_ptr< AbstractBeamDeflectorcreateBeamDeflectorFromXml (tinyxml2::XMLElement *scannerNode)
 Create a beam deflector from given XML element (node) More...
 
std::shared_ptr< AbstractDetectorcreateDetectorFromXml (tinyxml2::XMLElement *scannerNode, std::shared_ptr< Scanner > scanner)
 Create a pulse detector from given XML element (node) More...
 
std::shared_ptr< ScannerHeadcreateScannerHeadFromXml (tinyxml2::XMLElement *scannerNode)
 Create a scanner head from given XML element (node) More...
 
std::shared_ptr< ScannerSettingscreateScannerSettingsFromXml (tinyxml2::XMLElement *node, std::unordered_set< std::string > *fields=nullptr)
 Create scanner settings from given XML element (node) More...
 
std::shared_ptr< FWFSettingscreateFWFSettingsFromXml (tinyxml2::XMLElement *node, std::shared_ptr< FWFSettings > settings=nullptr)
 Create FWF settings from given XML element (node) More...
 
std::shared_ptr< TrajectorySettingscreateTrajectorySettingsFromXml (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...
 

Protected Member Functions

void reinitLoader () override
 Call the reinitLoader from XmlAssetsLoader and then also assure that the map of scanning strips is empty. The last serial leg identifier is also setted to -1. More...
 
std::shared_ptr< SceneloadScene (std::string sceneString, bool rebuildScene=false)
 Load scene from XML. More...
 
void loadSurveyCore (tinyxml2::XMLElement *surveyNode, std::shared_ptr< Survey > survey)
 Load the core components of the survey. It is, its name, the source file path, the scanner and the platform. More...
 
void handleCoreOverloading (tinyxml2::XMLElement *surveyNode, std::shared_ptr< Survey > survey)
 Handle overloading of survey's core components. More...
 
void loadLegs (tinyxml2::XMLElement *legNodes, std::shared_ptr< ScannerSettings > scannerSettings, std::shared_ptr< Platform > platform, std::vector< std::shared_ptr< Leg >> &legs)
 Load all legs defining the survey. More...
 
void applySceneShift (tinyxml2::XMLElement *surveyNode, bool const legNoiseDisabled, std::shared_ptr< Survey > survey)
 Apply scene geometry shift to platform waypoints. More...
 
void loadPlatformNoise (tinyxml2::XMLElement *surveyNode, std::shared_ptr< Platform > platform)
 Load plataform noise, overriding what is specified in platform.xml if necessary. More...
 
- Protected Member Functions inherited from XmlAssetsLoader
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...
 

Static Protected Member Functions

static void configureDefaultRandomnessGenerator (tinyxml2::XMLElement *surveyNode)
 Configure the default randomness generador. If a seed was specified through XML survey node, then it will replace the previous one. More...
 
static void integrateSurveyAndLegs (std::shared_ptr< Survey > survey)
 Integrating survey and legs means fitting survey attributes from legs and leg attributes from survey whenever it is necessary. More...
 
static void validateSurvey (std::shared_ptr< Survey > survey)
 Validate given survey is free from inconsistencies. Otherwise, proper logging and forced exit (if needed) will be applied. More...
 

Protected Attributes

std::unordered_map< std::string, std::shared_ptr< ScanningStrip > > strips
 Map of scanning strips. More...
 
int lastLegSerialId = -1
 Serial identifier for last created leg. It is initialized as -1, so the first leg has 0 as serial id.
 
- Protected Attributes inherited from XmlAssetsLoader
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< ScannerSettingsdefaultScannerTemplate
 The default scanner settings template.
 
std::shared_ptr< PlatformSettingsdefaultPlatformTemplate
 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...
 

Additional Inherited Members

- Static Public Member Functions inherited from XmlAssetsLoader
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 inherited from XmlAssetsLoader
XmlSceneLoader sceneLoader
 The scene loader. It is used to load scenes from XML files.
 
tinyxml2::XMLDocument doc
 XML file through tinyxml2 library.
 
- Static Protected Attributes inherited from XmlAssetsLoader
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...
 

Detailed Description

Survey loader from XML.

This class strongly depends on its parent class XmlAssetsLoader

See also
XmlAssetsLoader

Constructor & Destructor Documentation

◆ XmlSurveyLoader()

XmlSurveyLoader::XmlSurveyLoader ( std::string &  filePath,
std::string &  assetsDir 
)
inline

XML survey loader constructor.

Parameters
filePathPath to the XML File
assetsDirPath to the assets directory

Member Function Documentation

◆ applySceneShift()

void XmlSurveyLoader::applySceneShift ( tinyxml2::XMLElement *  surveyNode,
bool const  legNoiseDisabled,
std::shared_ptr< Survey survey 
)
protected

Apply scene geometry shift to platform waypoints.

Parameters
surveyNodeXML element/node containing survey data
legNoiseDisabledFlag to disable leg noise @sparam survey The survey containing all legs and scene data

◆ configureDefaultRandomnessGenerator()

void XmlSurveyLoader::configureDefaultRandomnessGenerator ( tinyxml2::XMLElement *  surveyNode)
staticprotected

Configure the default randomness generador. If a seed was specified through XML survey node, then it will replace the previous one.

Parameters
surveyNodeXML elemetn/node containing survey data

◆ createLegFromXML()

shared_ptr< Leg > XmlSurveyLoader::createLegFromXML ( tinyxml2::XMLElement *  legNode,
std::unordered_set< std::string > *  scannerFields,
std::unordered_set< std::string > *  platformFields 
)

Create a leg from a XML element/node.

Parameters
legNodeXML element/node containing leg data
[in]scannerFieldsUnordered set to track which scanner settings have been overloaded
[in]platformFieldsUnordered set to track which platform settings have been overloaded
Returns
Created leg
See also
Leg

◆ createSurveyFromXml()

shared_ptr< Survey > XmlSurveyLoader::createSurveyFromXml ( tinyxml2::XMLElement *  surveyNode,
bool  legNoiseDisabled = false,
bool  rebuildScene = false 
)

Create a survey form a XML element/node.

Notice that calling this method will reinitialize the loader by calling XmlSurveyLoader::reinitLoader

Parameters
surveyNodeXML element/node containing survey data
legNoiseDisabledFlag to disable leg noise
rebuildSceneFlag to specify scene must be rebuild even when a previously built one is found (true) or not (false)
Returns
Created survey
See also
Survey
XmlSurveyLoader::reinitLoader

◆ handleCoreOverloading()

void XmlSurveyLoader::handleCoreOverloading ( tinyxml2::XMLElement *  surveyNode,
std::shared_ptr< Survey survey 
)
protected

Handle overloading of survey's core components.

Parameters
surveyNodeXML element/node containing survey data
surveyThe survey to be loaded
See also
XmlSurveyLoader::loadSurveyCore

◆ integrateSurveyAndLegs()

void XmlSurveyLoader::integrateSurveyAndLegs ( std::shared_ptr< Survey survey)
staticprotected

Integrating survey and legs means fitting survey attributes from legs and leg attributes from survey whenever it is necessary.

For example, it is used to scale the vertical resolution when the deflector has an effective max scan angle.

Parameters
surveyThe survey that must be integrated with respect to the legs composing it

◆ load()

shared_ptr< Survey > XmlSurveyLoader::load ( bool  legNoiseDisabled = false,
bool  rebuildScene = false 
)

Load a full survey from XML.

Parameters
legNoiseDisabledFlag to disable leg noise
rebuildSceneFlag to specify scene must be rebuild even when a previously built one is found (true) or not (false)
Returns
Fully loaded survey
See also
Survey

◆ loadLegs()

void XmlSurveyLoader::loadLegs ( tinyxml2::XMLElement *  legNodes,
std::shared_ptr< ScannerSettings scannerSettings,
std::shared_ptr< Platform platform,
std::vector< std::shared_ptr< Leg >> &  legs 
)
protected

Load all legs defining the survey.

Parameters
legNodesFirst leg node
scannerSettingsThe scanner settings of the survey scanner itself
platformThe platform of the survey itself
legsVector where loaded legs must be inserted

◆ loadPlatformNoise()

void XmlSurveyLoader::loadPlatformNoise ( tinyxml2::XMLElement *  surveyNode,
std::shared_ptr< Platform platform 
)
protected

Load plataform noise, overriding what is specified in platform.xml if necessary.

Parameters
surveyNodeXML element/node containing survey data
platformThe platform which noise must be loaded

◆ loadScene()

shared_ptr< Scene > XmlSurveyLoader::loadScene ( std::string  sceneString,
bool  rebuildScene = false 
)
protected

Load scene from XML.

Parameters
sceneStringString from XML scene attribute at survey element/node
rebuildSceneFlag to specify scene must be rebuild even when a previously built one is found (true) or not (false)
Returns
Loaded scene
See also
Scene

◆ loadSurveyCore()

void XmlSurveyLoader::loadSurveyCore ( tinyxml2::XMLElement *  surveyNode,
std::shared_ptr< Survey survey 
)
protected

Load the core components of the survey. It is, its name, the source file path, the scanner and the platform.

Parameters
surveyNodeXML element/node containing survey data
surveyThe survey to be loaded
See also
XmlSurveyLoader::handleCoreOverloading

◆ reinitLoader()

void XmlSurveyLoader::reinitLoader ( )
overrideprotectedvirtual

Call the reinitLoader from XmlAssetsLoader and then also assure that the map of scanning strips is empty. The last serial leg identifier is also setted to -1.

See also
XmlAssetsLoader::reinitLoader

Reimplemented from XmlAssetsLoader.

◆ validateSurvey()

void XmlSurveyLoader::validateSurvey ( std::shared_ptr< Survey survey)
staticprotected

Validate given survey is free from inconsistencies. Otherwise, proper logging and forced exit (if needed) will be applied.

Parameters
surveyThe survey to be validated

Member Data Documentation

◆ strips

std::unordered_map<std::string, std::shared_ptr<ScanningStrip> > XmlSurveyLoader::strips
protected

Map of scanning strips.

See also
ScanningStrip

The documentation for this class was generated from the following files: