Helios++
Helios software for LiDAR simulations
XmlSceneLoader Class Reference

Class for scene loading from XML file. More...

#include <XmlSceneLoader.h>

Collaboration diagram for XmlSceneLoader:

Public Member Functions

 XmlSceneLoader ()
 Default constructor for XML scene loader.
 
std::shared_ptr< ScenecreateSceneFromXml (tinyxml2::XMLElement *sceneNode, std::string path, SerialSceneWrapper::SceneType *sceneType=nullptr)
 Create scene from given XML element (node) More...
 
shared_ptr< ScenePartloadFilters (tinyxml2::XMLElement *scenePartNode, bool &holistic)
 Load filters defining the scene part. More...
 
bool loadScenePartId (tinyxml2::XMLElement *scenePartNode, int partIndex, shared_ptr< ScenePart > scenePart)
 Load the scene part identifier. More...
 
bool validateScenePart (shared_ptr< ScenePart > scenePart, tinyxml2::XMLElement *scenePartNode)
 Validate the given loaded scene part. More...
 
void digestScenePart (shared_ptr< ScenePart > &scenePart, std::shared_ptr< StaticScene > &scene, bool holistic, bool splitPart, bool dynObject, int &partIndex)
 Apply final processings to the built scene part so it is fully integrated in the scene and totally configured. More...
 
shared_ptr< KDTreeFactorymakeKDTreeFactory ()
 Build the KDTree factory from loader's kdtFactoryType and kdtSAHLossNodes attributes. More...
 
shared_ptr< KDGroveFactorymakeKDGroveFactory ()
 Build the KDGrove factory from loader's KDTree factory specification. More...
 
shared_ptr< DynSequentiableMovingObjectloadDynMotions (tinyxml2::XMLElement *scenePartNode, shared_ptr< ScenePart > scenePart)
 Build a dynamic sequentiable moving object which is composed of dynamic motions. More...
 
shared_ptr< StaticScenemakeSceneDynamic (shared_ptr< StaticScene > scene)
 Build a dynamic scene based on given static scene. More...
 
void handleDynamicSceneAttributes (tinyxml2::XMLElement *sceneNode, shared_ptr< DynScene > scene)
 Handle the loading of dynamic scene attributes. More...
 

Public Attributes

SceneLoadingSpecification sceneSpec
 Scene loading specification. More...
 
int kdtFactoryType = 1
 Type of KDTree factory to be used to build scene. More...
 
size_t kdtNumJobs = 1
 How many threads must be used to build KDTree. More...
 
size_t kdtGeomJobs = 1
 How many threads must be used to build upper nodes of KDTree. More...
 
size_t kdtSAHLossNodes = 21
 How many loss nodes for the Surface Area Heuristic if using a SAH like KDTree factory to build the scene.
 

Detailed Description

Class for scene loading from XML file.

Whenever possible, it is preferred to load XML defined components by XmlAssetsLoader or XmlSurveyLoader classes which are the main classes for this purpose.

See also
XmlAssetsLoader

Member Function Documentation

◆ createSceneFromXml()

std::shared_ptr< Scene > XmlSceneLoader::createSceneFromXml ( tinyxml2::XMLElement *  sceneNode,
std::string  path,
SerialSceneWrapper::SceneType sceneType = nullptr 
)

Create scene from given XML element (node)

Parameters
sceneNodeXML element (node) containing scene data
pathPath to scene file
sceneType[out]When it is not null, it will be used to store the type of created scene
Returns
Shared pointer to created scene
See also
Scene

◆ digestScenePart()

void XmlSceneLoader::digestScenePart ( shared_ptr< ScenePart > &  scenePart,
std::shared_ptr< StaticScene > &  scene,
bool  holistic,
bool  splitPart,
bool  dynObject,
int &  partIndex 
)

Apply final processings to the built scene part so it is fully integrated in the scene and totally configured.

Parameters
scenePartThe scene part object to be digested
sceneThe scene where the scene part belongs
holisticFlag used to specify if all vertices defining each primitive must be considered as a whole (true) or not (false)
splitPartFlag to specify if scene part must be splitted into subparts (true) or not (false)
dynObjectFlag to specify if the scene part corresponds to a dynamic object (true) or to a static one (false)
[out]partIndexIf the subpart is splitted, then partIndex will be opportunely updated
See also
ScenePart::splitSubparts

◆ handleDynamicSceneAttributes()

void XmlSceneLoader::handleDynamicSceneAttributes ( tinyxml2::XMLElement *  sceneNode,
shared_ptr< DynScene scene 
)

Handle the loading of dynamic scene attributes.

Parameters
sceneNodeThe XML node defining the dynamic scene
sceneDynamic scene which attributes must be configured

◆ loadDynMotions()

shared_ptr< DynSequentiableMovingObject > XmlSceneLoader::loadDynMotions ( tinyxml2::XMLElement *  scenePartNode,
shared_ptr< ScenePart scenePart 
)

Build a dynamic sequentiable moving object which is composed of dynamic motions.

It is mandatory that dmotion elements contained in the part element also contain an id attribute specifying the unique identifier for the sequence in its context. The loop attribute is also mandatory, where \(0\) means infinity loop and \(n > 0\) specifies how many times the sequence will be repeated until proceeding to next sequence. Next sequence can be specified through the next attribute, which may contain the identifier of the next sequence. If no next attribute is given, then it is assumed that there is no next sequence.

Parameters
scenePartNodeXML part node defining the scene part
scenePartThe scene part object where the dynamic sequentiable moving object belongs to
Returns
Built dynamic sequentiable moving object composed of dynamic motions specified in the XML
See also
DynSequencer
DynSequence
rigidmotion::RigidMotion
DynMotion
XmlUtils::createDynMotionsVector

◆ loadFilters()

shared_ptr< ScenePart > XmlSceneLoader::loadFilters ( tinyxml2::XMLElement *  scenePartNode,
bool &  holistic 
)

Load filters defining the scene part.

NOTICE a scene part requires at least one primitives loading filter to be instantiated, otherwise it will be nullptr

Parameters
scenePartNodeXML part node defining the scene part
[out]holisticUsed to specify if all vertices defining each primitive must be considered as a whole (true) or not
Returns
Built scene part if any, nullptr otherwise

◆ loadScenePartId()

bool XmlSceneLoader::loadScenePartId ( tinyxml2::XMLElement *  scenePartNode,
int  partIndex,
shared_ptr< ScenePart scenePart 
)

Load the scene part identifier.

Parameters
scenePartNodeXML part node where the identifier might be explicitly specified
partIndexIndex of scene part according to current loop iteration. It will be used if no specific identifier is provided through XML
scenePartThe scene part object to which identifier must be assigned
Returns
True if scene part must be splitted, false otherwise. A scene part can only be splitted when a part identifier is explicitly provided

◆ makeKDGroveFactory()

shared_ptr< KDGroveFactory > XmlSceneLoader::makeKDGroveFactory ( )

Build the KDGrove factory from loader's KDTree factory specification.

Returns
Build KDGrove factory
See also
XmlSceneLoader::makeKDTreeFactory
KDGroveFactory

◆ makeKDTreeFactory()

shared_ptr< KDTreeFactory > XmlSceneLoader::makeKDTreeFactory ( )

Build the KDTree factory from loader's kdtFactoryType and kdtSAHLossNodes attributes.

Returns
Built KDTree factory
See also
XmlSceneLoader::kdtFactoryType
XmlSceneLoader::kdtSAHLossNodes
KDTreeFactory

◆ makeSceneDynamic()

shared_ptr< StaticScene > XmlSceneLoader::makeSceneDynamic ( shared_ptr< StaticScene scene)

Build a dynamic scene based on given static scene.

NOTICE for this method to work properly given scene MUST be of StaticScene type or unexpected behaviors might occur. Use with caution.

Parameters
sceneStatic scene to be used to build a dynamic scene
Returns
Built dynamic scene based on given static scene
See also
StaticScene
DynScene

◆ validateScenePart()

bool XmlSceneLoader::validateScenePart ( shared_ptr< ScenePart scenePart,
tinyxml2::XMLElement *  scenePartNode 
)

Validate the given loaded scene part.

Parameters
scenePartNodeXML part node corresponding to the scene part being validated
scenePartThe scene part to be validated
Returns
True if the given ScenePart is valid, false otherwise

Member Data Documentation

◆ kdtFactoryType

int XmlSceneLoader::kdtFactoryType = 1

Type of KDTree factory to be used to build scene.

See also
KDTreeFactory

◆ kdtGeomJobs

size_t XmlSceneLoader::kdtGeomJobs = 1

How many threads must be used to build upper nodes of KDTree.

See also
KDTreeFactory
SimpleKDTreeFactory
MultiThreadKDTreeFactory
SAHKDTreeFactory
MultiThreadSAHKDTreeFactory

◆ kdtNumJobs

size_t XmlSceneLoader::kdtNumJobs = 1

◆ sceneSpec

SceneLoadingSpecification XmlSceneLoader::sceneSpec

Scene loading specification.

See also
SceneLoadingSpecification

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