Helios++
Helios software for LiDAR simulations
|
Class representing a scene asset. More...
#include <Scene.h>
Public Member Functions | |
Scene () | |
Scene default constructor. | |
Scene (Scene &s) | |
bool | finalizeLoading (bool const safe=false) |
Handle scene loading finish process. More... | |
void | registerParts () |
Register all scene parts composing the scene in the parts vector with no repetitions. More... | |
std::shared_ptr< AABB > | getAABB () |
Obtain the axis aligned bounding box defining scene boundaries. More... | |
glm::dvec3 | getGroundPointAt (glm::dvec3 point) |
Obtain the ground point at specified XY coordinates. More... | |
std::shared_ptr< RaySceneIntersection > | getIntersection (glm::dvec3 const &rayOrigin, glm::dvec3 const &rayDir, bool const groundOnly) const |
Obtain the intersection between the ray and the scene, if any. More... | |
std::shared_ptr< RaySceneIntersection > | getIntersection (vector< double > const &tMinMax, glm::dvec3 const &rayOrigin, glm::dvec3 const &rayDir, bool const groundOnly) const |
Like Scene::getIntersection(dvec3 const, dvec3 const, bool const) but receiving precomputed minimum and maximum intersection times with respect to the axis aligned bounding box that bounds the scene. More... | |
std::map< double, Primitive * > | getIntersections (glm::dvec3 &rayOrigin, glm::dvec3 &rayDir, bool const groundOnly) |
Obtain all intersections between the ray and the scene, if any. More... | |
glm::dvec3 | getShift () |
Obtain the minimum boundaries of the original axis aligned bounding box containing the scene, before it was centered so (0, 0, 0) became its new minimum boundaries. More... | |
glm::dvec3 const & | getShiftRef () const |
Like Scene::getShift but returning a const reference instead of a copy. More... | |
std::vector< Vertex * > | getAllVertices () |
Obtain all vertices (without repetitions) composing the scene. More... | |
void | doForceOnGround () |
For each scene part which is flagged as forceOnGround, it will be vertically translated to closest ground scene part. More... | |
glm::dvec3 | findForceOnGroundQ (int const searchDepth, glm::dvec3 const minzv, vector< Vertex * > &vertices, vector< double > const &o, vector< double > const &v) |
Assist doForceOnGround function to find an adequate \(q\) for step 4. More... | |
void | buildKDGrove (bool const safe=false) |
Build the KDGrove for the scene, overwriting previous one if any. More... | |
void | buildKDGroveWithLog (bool const safe=false) |
Call buildKDGrove exporting building information through logging system. More... | |
virtual std::shared_ptr< KDGroveRaycaster > const & | getRaycaster () const |
virtual std::shared_ptr< KDGroveFactory > | getKDGroveFactory () const |
Obtain the KDGrove factory used by the scene. More... | |
virtual void | setKDGroveFactory (std::shared_ptr< KDGroveFactory > const kdgf) |
Set the KDGrove factory to be used by the scene. More... | |
virtual std::shared_ptr< KDGrove > | getKDGrove () const |
Obtain the KDGrove used by the scene. More... | |
virtual void | setKDGrove (std::shared_ptr< KDGrove > const kdgrove) |
Set the KDGrove to be used by the scene. More... | |
virtual std::shared_ptr< AABB > | getBBox () const |
Obtain the scene's bounding box. More... | |
virtual void | setBBox (std::shared_ptr< AABB > const bbox) |
Set the scene's bounding box. More... | |
virtual std::shared_ptr< AABB > | getBBoxCRS () const |
Obtain the scene's coordinate reference system bounding box. More... | |
virtual void | setBBoxCRS (std::shared_ptr< AABB > const bbox) |
Set the scene's coordinate reference system bounding box. More... | |
virtual bool | hasMovingObjects () const |
Checke whether the scene contains at least one moving object (true) or not (false) More... | |
virtual void | writeObject (std::string path) |
Serialize the scene and write it to given output file. More... | |
virtual bool | doSimStep () |
Support simulation step handling from scene side. More... | |
![]() | |
std::string | getLocationString () |
Obtain asset location string. More... | |
virtual bool | isEgg () const |
Check whether the asset is an EggAsset or not. More... | |
Static Public Member Functions | |
static Scene * | readObject (std::string path) |
Read serialized scene from given file. More... | |
Public Attributes | |
std::vector< Primitive * > | primitives |
Vector of primitives composing the scene. | |
std::vector< std::shared_ptr< ScenePart > > | parts |
Parts composing the scene with no repeats. More... | |
![]() | |
std::string | id = "" |
Asset identifier. | |
std::string | name = "Unnamed Asset" |
Asset name. | |
std::string | sourceFilePath = "" |
Path to asset file. | |
Protected Attributes | |
std::shared_ptr< KDGroveFactory > | kdgf |
The KDGrove factory used to build the scene KDGrove. More... | |
std::shared_ptr< KDGrove > | kdgrove |
KDGrove containing a KDTree for each scene part to speed-up ray-primitive intersection check computations. | |
std::shared_ptr< AABB > | bbox |
Axis aligned bounding box defining scene boundaries. | |
std::shared_ptr< AABB > | bbox_crs |
Original axis aligned bounding box defining scene boundaries before centering it. | |
std::shared_ptr< KDGroveRaycaster > | raycaster |
The raycaster based on KDGrove. More... | |
Private Member Functions | |
template<class Archive > | |
void | save (Archive &ar, unsigned int const version) const |
Handle scene save operation. More... | |
template<class Archive > | |
void | load (Archive &ar, unsigned int const fileVersion) |
Handle scene load operation. More... | |
BOOST_SERIALIZATION_SPLIT_MEMBER () | |
Friends | |
class | boost::serialization::access |
Class representing a scene asset.
void Scene::buildKDGrove | ( | bool const | safe = false | ) |
Build the KDGrove for the scene, overwriting previous one if any.
safe | The same safe as the one received by finalizeSceneLoading |
void Scene::buildKDGroveWithLog | ( | bool const | safe = false | ) |
Call buildKDGrove exporting building information through logging system.
void Scene::doForceOnGround | ( | ) |
For each scene part which is flagged as forceOnGround, it will be vertically translated to closest ground scene part.
This function requires that there is at least one scene part flagged as ground, otherwise it is not possible to apply it. The algorithm can be described in 5 steps:
Let the scene part to be placed on ground be defined by its \(m\) vertices, such that \(Q = \left\{q_1, \ldots, q_m\right\}\). Also, let it be represented by its minimum \(z\) vertex \(q_* = (q_{*x}, q_{*y}, q_{*z}) \). Thus, the first found ground scene part such that \(q_*\) is inside its \(\mathbb{R}^{2}\) boundaries is considered as the ground reference. More formally, it must be satisfied that:
\[ q_{*x} \in [a_{ix}, b_{ix}] \land q_{*y} \in [a_{iy}, b_{iy}] \]
Find the best fitting plane \(\pi\) with respect to vertices of ground reference, which orthonormal vector is noted as \(\hat{v}\)
\[ \pi = \left\{ p=(x, y, z) : \left\langle{\overrightarrow{op}, \hat{v}}\right\rangle = 0 \right\} \]
Compute the vertical projection of \(q\) on best fitting ground plane \(\pi\) as follows:
\[ \begin{array}{lll} \mathcal{P}^{z}_{\pi}(q) &=& \left( q_{x}, q_{y}, \frac{ \hat{v}_x o_x + \hat{v}_y o_y + \hat{v}_z o_z - \hat{v}_x q_{x} - \hat{v}_y q_{y} } {\hat{v}_z} \right) \\ &=& \left( q_{x}, q_{y}, \frac{ \left\langle{\hat{v}, \vec{o}}\right\rangle - \hat{v}_x q_{x} - \hat{v}_y q_{y} }{\hat{v}_z} \right) \\ &=& (p_x, p_y, p_z) \\ &=& p \end{array} \]
Where \(q\) varies depending on search depth, as explained in parameter documentation at the Scene::findForceOnGroundQ function.
Let \(\Delta_z = q_{*z} - p_z\) be the magnitude of vertical translation for the entire scene part. Now, each vertex defining the scene part must be translated so:
\[ \forall q_i \in Q,\, q'_i = (q_{ix}, q_{iy}, q_{iz} - \Delta_z) \]
|
inlinevirtual |
Support simulation step handling from scene side.
For basic scenes and static scenes, there is nothing to do. However, dynamic scenes are expected to override this method to provide simulation level dynamism.
Reimplemented in DynScene.
bool Scene::finalizeLoading | ( | bool const | safe = false | ) |
Handle scene loading finish process.
Computations such as primitives update and centering the scene (all its vertices) so the axis aligned bounding box defining its boundaries start at (0, 0, 0) and also KDTree building are performed here
safe | Enable safe mode (true) or disable it (false). Safe mode is mainly useful for debugging purposes because it prevents certain changes such as modification of primitives ordering. Whenever safe mode is not necessary, it is recommended to set it to false as enabling it might lead to a slowdown |
glm::dvec3 Scene::findForceOnGroundQ | ( | int const | searchDepth, |
glm::dvec3 const | minzv, | ||
vector< Vertex * > & | vertices, | ||
vector< double > const & | o, | ||
vector< double > const & | v | ||
) |
Assist doForceOnGround function to find an adequate \(q\) for step 4.
searchDepth | The search strategy specification. This function should never be called with searchDepth 0, that case must be skipped at Scene::doForceOnGround directly. Search depth corresponds with the scene part's forceOnGround attribute |
If it is 0 the force on ground process will be skipped. If it is 1, a specific algorithm based on \(q=q_*\) as min \(z\) point will be used. If it is \(>1\), then it specifies the number of search steps to be performed to find \(q\) on a discrete linear search with searchDepth steps. If it is -1, then \( q = \mathrm{argmin}_{q \in Q} \;\;\; q_z - \frac{\left\langle{\hat{v}, \vec{o}}\right\rangle - \left( \hat{v}_x q_x + \hat{v}_y q_y \right)}{\hat{v}_z} \)
minzv | The \(q_*\) that is used as \(q\) if searchDepth is 1 |
vertices | All vertices defining the scene part to be placed on ground |
o | A point contained in the best fitting ground plane |
v | The normal vector of the best fitting ground plane |
shared_ptr< AABB > Scene::getAABB | ( | ) |
Obtain the axis aligned bounding box defining scene boundaries.
vector< Vertex * > Scene::getAllVertices | ( | ) |
Obtain all vertices (without repetitions) composing the scene.
|
inlinevirtual |
|
inlinevirtual |
Obtain the scene's coordinate reference system bounding box.
glm::dvec3 Scene::getGroundPointAt | ( | glm::dvec3 | point | ) |
Obtain the ground point at specified XY coordinates.
point | Point definint the XY coordinates for which the ground point shall be obtained |
shared_ptr< RaySceneIntersection > Scene::getIntersection | ( | glm::dvec3 const & | rayOrigin, |
glm::dvec3 const & | rayDir, | ||
bool const | groundOnly | ||
) | const |
Obtain the intersection between the ray and the scene, if any.
rayOrigin | Ray origin 3D coordinates |
rayDir | Ray 3D director vector |
groundOnly | Flag to specify if only ground points must be considered (true) or not (false) |
std::shared_ptr< RaySceneIntersection > Scene::getIntersection | ( | vector< double > const & | tMinMax, |
glm::dvec3 const & | rayOrigin, | ||
glm::dvec3 const & | rayDir, | ||
bool const | groundOnly | ||
) | const |
Like Scene::getIntersection(dvec3 const, dvec3 const, bool const) but receiving precomputed minimum and maximum intersection times with respect to the axis aligned bounding box that bounds the scene.
tMinMax | The minimum and maximum intersection times |
map< double, Primitive * > Scene::getIntersections | ( | glm::dvec3 & | rayOrigin, |
glm::dvec3 & | rayDir, | ||
bool const | groundOnly | ||
) |
Obtain all intersections between the ray and the scene, if any.
rayOrigin | Ray origin 3D coordinates |
rayDir | Ray 3D director vector |
groundOnly | Flag to specify if only ground points must be considered (true) or not (false) |
|
inlinevirtual |
|
inlinevirtual |
Obtain the KDGrove factory used by the scene.
glm::dvec3 Scene::getShift | ( | ) |
Obtain the minimum boundaries of the original axis aligned bounding box containing the scene, before it was centered so (0, 0, 0) became its new minimum boundaries.
|
inline |
Like Scene::getShift but returning a const reference instead of a copy.
|
inlinevirtual |
Checke whether the scene contains at least one moving object (true) or not (false)
|
inlineprivate |
|
static |
Read serialized scene from given file.
path | Path to file where a serialized scene is stored |
void Scene::registerParts | ( | ) |
Register all scene parts composing the scene in the parts vector with no repetitions.
|
inlineprivate |
|
inlinevirtual |
|
inlinevirtual |
Set the scene's coordinate reference system bounding box.
bbox | New coordinate reference system bounding box for the scene |
|
inlinevirtual |
|
inlinevirtual |
Set the KDGrove factory to be used by the scene.
kdgf | New KDGrove factory to be used by the scene |
|
virtual |
Serialize the scene and write it to given output file.
path | Path to output file where serialized scene shall be stored |
Reimplemented in StaticScene, and DynScene.
|
protected |
The KDGrove factory used to build the scene KDGrove.
std::vector<std::shared_ptr<ScenePart> > Scene::parts |
Parts composing the scene with no repeats.
Please avoid manually computing this vector. If it is necessary to initialize or update it, call registerParts instead.
|
protected |
The raycaster based on KDGrove.