Helios++
Helios software for LiDAR simulations
|
Dynamic object base implementation. More...
#include <DynObject.h>
Public Member Functions | |
DynObject () | |
Dynamic object default constructor. | |
DynObject (ScenePart const &sp, bool const shallowPrimitives=false) | |
Build the dynamic object from given scene part. More... | |
DynObject (string const id) | |
Dynamic object constructor with id as argument. More... | |
DynObject (vector< Primitive * > const &primitives) | |
Dynamic object constructor with primitives as argument. More... | |
DynObject (string const id, vector< Primitive * > const &primitives) | |
Dynamic object constructor with id and primitives as arguments. More... | |
virtual bool | doStep () |
Handle the computation of current simulation step according to configured step loop. This means that the DynObject::doSimStep method (which implements the logic of the DynObject) will be called by the DynObject::stepLoop when enough simulation steps have elapsed. More... | |
virtual bool | doSimStep ()=0 |
Any dynamic object concrete implementation must override this method providing dynamic behavior to the object. More... | |
void | operator() () |
Alias for DynObject::doStep method so it can be used as a functor. More... | |
size_t | countVertices () const |
Count how many vertices there are defining the dynamic object. More... | |
arma::mat | positionMatrixFromPrimitives () const |
Obtain the position matrix for primitives defining the dynamic object. More... | |
arma::mat | positionMatrixFromPrimitives (size_t const m) const |
Like DynObject::positionMatrixFromPrimitives but receiving the total number of vertices beforehand. More... | |
arma::mat | normalMatrixFromPrimitives () const |
Obtain the normal matrix for primitives defining the dynamic object. More... | |
arma::mat | normalMatrixFromPrimitives (size_t const m) const |
Like DynObject::normalMatrixFromPrimitives but receiving the total number of vertices beforehand. More... | |
void | updatePrimitivesPositionFromMatrix (arma::mat const &X) |
Update the position of each primitive with given matrix. More... | |
void | updatePrimitivesPositionFromMatrix (size_t const m, arma::mat const &X) |
Like updatePrimitivesPositionFromMatrix(arma::mat const &) but receiving the total number of vertices beforehand. More... | |
void | updatePrimitivesNormalFromMatrix (arma::mat const &X) |
Update the normal of each primitive with given matrix. More... | |
void | updatePrimitivesNormalFromMatrix (size_t const m, arma::mat const &X) |
Like updatePrimitivesNormalFromMatrix(arma::mat const &) but receiving the total number of vertices beforehand. More... | |
ObjectType | getType () const override |
int | getStepInterval () const |
Obtain the current step interval for the dynamic object. More... | |
void | setStepInterval (int const stepInterval) |
Set the step interval for the dynamic object. More... | |
![]() | |
ScenePart () | |
Default constructor for a scene part. More... | |
ScenePart (ScenePart const &sp, bool const shallowPrimitives=false) | |
ScenePart & | operator= (const ScenePart &rhs) |
Copy assigment operator. | |
void | addObj (WavefrontObj *obj) |
Add the primitives of a WavefrontObj to the ScenePart. More... | |
std::vector< Vertex * > | getAllVertices () const |
Obtain all vertices in the scene part. More... | |
void | smoothVertexNormals () |
Smooth normals for each vertex computing the mean for each triangle using it. | |
bool | splitSubparts () |
Split each subpart into a different scene part, with the first one corresponding to this scene part. More... | |
void | computeCentroid (bool const computeBound=false) |
Compute the default centroid for the scene part as the midrange point and its boundaries too. More... | |
std::vector< Primitive * > const & | getPrimitives () const |
Obtain the primitives of the scene part. More... | |
void | setPrimitives (std::vector< Primitive * > const &primitives) |
Set the primitives of the scene part. More... | |
arma::colvec | getCentroid () const |
Obtain the centroid of the scene part. More... | |
void | setCentroid (arma::colvec centroid) |
Set the centroid of the scene part. More... | |
std::string const & | getId () const |
Obtain the ID of the scene part. More... | |
void | setId (const std::string &id) |
Set the ID of the scene part. More... | |
virtual PrimitiveType | getPrimitiveType () const |
Protected Member Functions | |
arma::mat | matrixFromPrimitives (std::function< arma::colvec(Vertex const *)> get) const |
Build a matrix from the set of primitives defining the dynamic object. More... | |
arma::mat | matrixFromPrimitives (size_t const m, std::function< arma::colvec(Vertex const *)> get) const |
Like DynObject::matrixFromPrimitives but receiving the total number of vertices beforehand. More... | |
void | matrixToPrimitives (std::function< void(Vertex *, arma::colvec const &)> set, arma::mat const &X) |
Update primitives defining the dynamic object from given matrix. More... | |
void | matrixToPrimitives (size_t const m, std::function< void(Vertex *, arma::colvec const &)> set, arma::mat const &X) |
Like DynObject::matrixToPrimitives but receiving the total number of vertices beforehand. More... | |
Protected Attributes | |
NonVoidStepLoop< bool > | stepLoop |
The object to handle the execution of the dynamic object logic between specified simulation steps. More... | |
Private Member Functions | |
template<typename Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Serialize a dynamic object to a stream of bytes. More... | |
template<typename Archive > | |
void | save (Archive &ar, const unsigned int version) const |
Save a serialized dynamic object to a stream of bytes. More... | |
template<typename Archive > | |
void | load (Archive &ar, const unsigned int version) |
Load a serialized dynamic object from a stream of bytes. More... | |
Friends | |
class | boost::serialization::access |
Additional Inherited Members | |
![]() | |
enum | ObjectType { STATIC_OBJECT , DYN_OBJECT , DYN_MOVING_OBJECT } |
Specify the type of scene part / object. By default, the ScenePart is a static object. | |
enum | PrimitiveType { NONE , TRIANGLE , VOXEL } |
Specify the type of primitive used to build the scene part By default, the ScenePart is not build from primitives (None) More... | |
![]() | |
PrimitiveType | primitiveType |
The type of primitive used to build the scene part. More... | |
std::vector< Primitive * > | mPrimitives |
Vector of pointers to primitives used by this scene part. | |
arma::colvec | centroid |
The centroid of the scene part. | |
std::shared_ptr< AABB > | bound = nullptr |
The axis aligned bounding box defining scene part boundaries. | |
std::string | mId = "" |
Identifier for the scene part. | |
std::vector< size_t > | subpartLimit |
Vector specifying the limit of a subpart as the index of first element of next subpart. More... | |
std::string | onRayIntersectionMode = "" |
Specify the handling mode for ray intersections. | |
double | onRayIntersectionArgument = 0.0 |
Specify the extra value to be used for ray intersection handling computation, when needed (depends on mode). | |
bool | randomShift = false |
Specify if apply random shift to the scene part (true) or not (false, by default) | |
std::shared_ptr< LadLut > | ladlut = nullptr |
Look-up table for leaf angle distribution. | |
glm::dvec3 | mOrigin = glm::dvec3(0, 0, 0) |
Specify the origin for the scene part. | |
Rotation | mRotation = Rotation(glm::dvec3(1, 0, 0), 0) |
Specify the rotation for the scene part. | |
double | mScale = 1 |
Specify the scale for the scene part. | |
int | forceOnGround = 0 |
Force the scene part to be on ground if \(\neq 0\), do nothing if \(= 0\). More... | |
OGRSpatialReference * | mCrs = nullptr |
OGREnvelope * | mEnv = nullptr |
Dynamic object base implementation.
A dynamic object is a set of primitives which together define a single object. This object is expected to have a dynamic behavior which changes over time.
|
inline |
Build the dynamic object from given scene part.
sp | Scene part as basis for dynamic object |
|
inline |
Dynamic object constructor with id as argument.
id | The id for the dynamic object |
|
inline |
Dynamic object constructor with primitives as argument.
primitives | The primitives defining the dynamic object |
|
inline |
Dynamic object constructor with id and primitives as arguments.
id | The id for the dynamic object |
primitives | The primitives defining the dynamic object |
size_t DynObject::countVertices | ( | ) | const |
Count how many vertices there are defining the dynamic object.
It is the summation of the number of vertices for each primitive
|
pure virtual |
Any dynamic object concrete implementation must override this method providing dynamic behavior to the object.
This method must be invoked each time a dynamic object must be updated because the time step has changed. For the sake of understanding, let \(\mathcal{D}\) be the dynamic object so \(\mathcal{D}_0\) represents its status at start time. Now, the doStep method can be understood as a function \(f\) which receives a dynamic object on a given time step \(t\) and update it to correspond with next time step \(t+1\):
\[ \mathcal{D}_{t+1} = f\left(\mathcal{D}_{t}\right) \]
Implemented in DynSequentiableMovingObject, and DynMovingObject.
|
virtual |
Handle the computation of current simulation step according to configured step loop. This means that the DynObject::doSimStep method (which implements the logic of the DynObject) will be called by the DynObject::stepLoop when enough simulation steps have elapsed.
|
inline |
Obtain the current step interval for the dynamic object.
|
inlineoverridevirtual |
Reimplemented from ScenePart.
|
inlineprivate |
Load a serialized dynamic object from a stream of bytes.
|
protected |
Like DynObject::matrixFromPrimitives but receiving the total number of vertices beforehand.
It can increase efficiency when the number of primitives defining the dynamic object remains the same by caching the countVertices method output and passing it as \(m\). Otherwise, it will be computed for each call of matrixFromPrimitives method which implies iterating through vertices of each primitive.
m | Total number of vertices |
|
protected |
Build a matrix from the set of primitives defining the dynamic object.
Let \(X\) be the built matrix:
\[ X = \left[\begin{array}{lll} x_{11} &\ldots& x_{1n} \\ \vdots &\ddots& \vdots \\ x_{m1} &\ldots& x_{mn} \end{array}\right] \]
Now, let \(\vec{x}_{j}=\left(x_{1j}, \ldots, x_{mj}\right)\) be the \(j\)-th column vector of matrix \(X\), \(p_j\) be the \(j\)-th vertex defining the dynamic object and \(f\) be the get function. Thus, the usage of the get function can be defined as follows:
\[ \vec{x}_{j} = f\left(p_j\right) \]
get | Function to extract a column vector for a vertex which will be inserted in the matrix |
|
protected |
Like DynObject::matrixToPrimitives but receiving the total number of vertices beforehand.
It can increase efficiency when the number of primitives defining the dynamic object remains the same by caching the countVertices method output and passing it as \(m\). Otherwise, it will be computed for each call of matrixToPrimitives method which implies iterating through vertices of each primitive.
m | Total number of vertices |
|
protected |
Update primitives defining the dynamic object from given matrix.
Let \(X\) be the input matrix:
\[ X = \left[\begin{array}{lll} x_{11} &\ldots& x_{1n} \\ \vdots &\ddots& \vdots \\ x_{m1} &\ldots& x_{mn} \end{array}\right] \]
Now, let \(\vec{x}_{j}=\left(x_{1j}, \ldots, x_{mj}\right)\) be the \(j\)-th column vector of matrix \(X\), \(p_j\) be the \(j\)-th vertex defining the dynamic object and \(f\) be the set function. Thus, the usage of the set function can be defined as follows:
\[ p_j = f\left(\vec{x}_{j}\right) \]
set | Function to update a vertex from corresponding column vector in given matrix |
X | Matrix containing necessary data to update vertices. Each column contains the data for its corresponding vertex |
arma::mat DynObject::normalMatrixFromPrimitives | ( | ) | const |
Obtain the normal matrix for primitives defining the dynamic object.
\[ X_{m \times 3} = \left[\begin{array}{lll} \hat{n}_{x1} & \ldots & \hat{n}_{xm} \\ \hat{n}_{y1} & \ldots & \hat{n}_{ym} \\ \hat{n}_{z1} & \ldots & \hat{n}_{zm} \end{array}\right] \]
arma::mat DynObject::normalMatrixFromPrimitives | ( | size_t const | m | ) | const |
Like DynObject::normalMatrixFromPrimitives but receiving the total number of vertices beforehand.
It can increase efficiency when the number of primitives defining the dynamic object remains the same by caching the countVertices method output and passing it as \(m\). Otherwise, it will be computed for each call of normalMatrixFromPrimitives method which implies iterating through vertices of each primitive.
m | Total number of vertices |
|
inline |
Alias for DynObject::doStep method so it can be used as a functor.
arma::mat DynObject::positionMatrixFromPrimitives | ( | ) | const |
Obtain the position matrix for primitives defining the dynamic object.
\[ X_{m \times 3} = \left[\begin{array}{lll} x_1 & \ldots & x_m \\ y_1 & \ldots & y_m \\ z_1 & \ldots & z_m \end{array}\right] \]
arma::mat DynObject::positionMatrixFromPrimitives | ( | size_t const | m | ) | const |
Like DynObject::positionMatrixFromPrimitives but receiving the total number of vertices beforehand.
It can increase efficiency when the number of primitives defining the dynamic object remains the same by caching the countVertices method output and passing it as \(m\). Otherwise, it will be computed for each call of positionMatrixFromPrimitives method which implies iterating through vertices of each primitive.
m | Total number of vertices |
|
inlineprivate |
Save a serialized dynamic object to a stream of bytes.
|
inlineprivate |
Serialize a dynamic object to a stream of bytes.
Archive | Type of rendering |
ar | Specific rendering for the stream of bytes |
version | Version number for the dynamic object |
|
inline |
Set the step interval for the dynamic object.
stepInterval | The new step interval for the dynamic object |
void DynObject::updatePrimitivesNormalFromMatrix | ( | arma::mat const & | X | ) |
Update the normal of each primitive with given matrix.
The first column of matrix \(X\) contains the components for the new normal of the first primitive. The last column of matrix \(X\) contains the components for the new normal of the last primitive. The \(j\)-th column of matrix \(X\) contains the components for the new normal of the \(j\)-th primitive.
X | The normal matrix containing new components |
void DynObject::updatePrimitivesNormalFromMatrix | ( | size_t const | m, |
arma::mat const & | X | ||
) |
Like updatePrimitivesNormalFromMatrix(arma::mat const &) but receiving the total number of vertices beforehand.
It can increase efficiency when the number of primitives defining the dynamic object remains the same by caching the countVertices method output and passing as \(m\). Otherwise, it will be computed for each call of updatePrimitivesNormalFromMatrix method which implies iterating through vertices of each primitive.
m | Total number of vertices |
void DynObject::updatePrimitivesPositionFromMatrix | ( | arma::mat const & | X | ) |
Update the position of each primitive with given matrix.
The first column of matrix \(X\) contains the coordinates for the new position of the first primitive. The last column of matrix \(X\) contains the coordinates for the new position of the last primitive. The \(j\)-th column of matrix \(X\) contains the coordinates for the new position of the \(j\)-th primitive.
X | The position matrix containing new coordinates |
void DynObject::updatePrimitivesPositionFromMatrix | ( | size_t const | m, |
arma::mat const & | X | ||
) |
Like updatePrimitivesPositionFromMatrix(arma::mat const &) but receiving the total number of vertices beforehand.
It can increase efficiency when the number of primitives defining the dynamic object remains the same by caching the countVertices method output and passing as \(m\). Otherwise, it will be computed for each call of updatePrimitivesPositionFromMatrix method which implies iterating through vertices of each primitive.
m | Total number of vertices |
|
protected |
The object to handle the execution of the dynamic object logic between specified simulation steps.