Helios++
Helios software for LiDAR simulations
DynMovingObject Class Reference

Implementation of a dynamic object which supports dynamic motions (extended rigid motions) More...

#include <DynMovingObject.h>

Inheritance diagram for DynMovingObject:
Collaboration diagram for DynMovingObject:

Public Member Functions

 DynMovingObject ()
 
 DynMovingObject (ScenePart const &sp, bool const shallowPrimitives=false)
 
 DynMovingObject (string const id)
 
 DynMovingObject (vector< Primitive * > const &primitives)
 
 DynMovingObject (string const id, vector< Primitive * > const &primitives)
 
virtual bool doSimStep ()
 Dynamic motion behavior implementation. More...
 
virtual void doObserverUpdate ()
 Handle update notifications to the subscribed observer. It is, notify the observer that it has been updated by the dynamic moving object. More...
 
void pushPositionMotion (shared_ptr< DynMotion > const dm)
 Push given dynamic motion to the position motion queue. More...
 
shared_ptr< DynMotionnextPositionMotion ()
 Retrieve the first dynamic motion in the position motion queue. More...
 
void clearPositionMotionQueue ()
 Remove all dynamic motions from the position motion queue.
 
bool positionMotionQueueHasNext () const
 Check if position motion queue has a next dynamic motion or not. More...
 
void pushNormalMotion (shared_ptr< DynMotion > const dm)
 Push given dynamic motion to the normal motion queue. More...
 
shared_ptr< DynMotionnextNormalMotion ()
 Retrieve the first dynamic motion in the normal motion queue. More...
 
void clearNormalMotionQueue ()
 Remove all dynamic motions from the normal motion queue.
 
bool normalMotionQueueHasNext () const
 Check if normal motion queue has a next dynamic motion or not. More...
 
void registerObserverGrove (shared_ptr< KDGrove > kdGroveObserver) override
 Register given grove as a observer for the dynamic moving object. More...
 
void unregisterObserverGrove () override
 Unregister current grove observer. More...
 
void setGroveSubjectId (std::size_t const id) override
 
std::size_t getGroveSubjectId () override
 
ObjectType getType () const override
 
void setObserverStepInterval (int const stepInterval)
 Set the step interval between consecutive observer update notifications. More...
 
int getObserverStepInterval () const
 Get the step interval between consecutive observer update notifications. More...
 
- Public Member Functions inherited from DynObject
 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...
 
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...
 
- Public Member Functions inherited from ScenePart
 ScenePart ()
 Default constructor for a scene part. More...
 
 ScenePart (ScenePart const &sp, bool const shallowPrimitives=false)
 
ScenePartoperator= (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
 
- Public Member Functions inherited from KDGroveSubject
void registerObserverGrove (std::shared_ptr< BasicDynGrove< GroveKDTreeRaycaster, DynMovingObject >> observer) override
 Workaround to redirect calls from BasicDynGroveObjectSubject::registerObserverGrove to KDGroveSubject::registerObserverGrove(std::shared_ptr<KDGroveSubject>) method. More...
 
virtual void registerObserverGrove (std::shared_ptr< KDGrove > observer)=0
 Register given KDGrove as a observer with respect to the subject. More...
 

Protected Member Functions

bool applyDynMotionQueue (std::function< arma::mat()> matrixFromPrimitives, std::function< void(arma::mat const &X)> matrixToPrimitives, std::function< bool()> queueHasNext, std::function< shared_ptr< DynMotion >()> queueNext)
 Method to assist dynamic motions computation. More...
 
shared_ptr< DynMotion_next (deque< shared_ptr< DynMotion >> &deck)
 Assist next operation over given queue. More...
 
- Protected Member Functions inherited from DynObject
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

deque< shared_ptr< DynMotion > > positionMotionQueue
 Queue of motions to be applied to the position of each primitive. More...
 
deque< shared_ptr< DynMotion > > normalMotionQueue
 Queue of motions to be applied to the normal vector of each primitive. More...
 
DynMotionEngine dme
 The dynamic motion engine to apply dynamic motions. More...
 
std::shared_ptr< KDGrovekdGroveObserver
 The observer grove to which the dynamic moving object is registered. More...
 
size_t groveSubjectId
 The identifier of the dynamic moving object as subject of a KDGrove. More...
 
VoidStepLoop observerStepLoop
 Handle how many consecutive updates must elapse so the observer is notified. More...
 
- Protected Attributes inherited from DynObject
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 moving object to a stream of bytes. More...
 
template<typename Archive >
void save (Archive &ar, const unsigned int version) const
 Save a serialized dynamic moving object to a stream of bytes. More...
 
template<typename Archive >
void load (Archive &ar, const unsigned int version)
 Load a serialized dynamic moving object from a stream of bytes. More...
 

Friends

class boost::serialization::access
 

Additional Inherited Members

- Public Types inherited from ScenePart
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...
 
- Public Attributes inherited from ScenePart
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< AABBbound = 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< LadLutladlut = 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
 

Detailed Description

Implementation of a dynamic object which supports dynamic motions (extended rigid motions)

Author
Alberto M. Esmoris Pena
Version
1.0

This dynamic object handles any rigid motion in \(\mathbb{R}^2\) and \(\mathbb{R}^{3}\) and also extended functionalities coming from dynamic motion extra features, if any

See also
DynObject
rigidmotion::RigidMotion
DynMotion
rigidmotion::RigidMotionEngine
rigidmotion::RigidMotionR2Factory
rigidmotion::RigidMotionR3Factory

Constructor & Destructor Documentation

◆ DynMovingObject() [1/5]

DynMovingObject::DynMovingObject ( )
inline

◆ DynMovingObject() [2/5]

DynMovingObject::DynMovingObject ( ScenePart const &  sp,
bool const  shallowPrimitives = false 
)
inline

◆ DynMovingObject() [3/5]

DynMovingObject::DynMovingObject ( string const  id)
inline

◆ DynMovingObject() [4/5]

DynMovingObject::DynMovingObject ( vector< Primitive * > const &  primitives)
inline

◆ DynMovingObject() [5/5]

DynMovingObject::DynMovingObject ( string const  id,
vector< Primitive * > const &  primitives 
)
inline

Member Function Documentation

◆ _next()

shared_ptr< DynMotion > DynMovingObject::_next ( deque< shared_ptr< DynMotion >> &  deck)
protected

Assist next operation over given queue.

Notice next operation implies removing the retrieved element from the queue

Parameters
deckQueue to retrieve next from
Returns
First dynamic motion in the given queue

◆ applyDynMotionQueue()

bool DynMovingObject::applyDynMotionQueue ( std::function< arma::mat()>  matrixFromPrimitives,
std::function< void(arma::mat const &X)>  matrixToPrimitives,
std::function< bool()>  queueHasNext,
std::function< shared_ptr< DynMotion >()>  queueNext 
)
protected

Method to assist dynamic motions computation.

It provides the abstract logic to compute dynamic motions in an efficient way. Functions to extract dynamic motion queue elements and to read and update primitives must be given as input arguments.

Parameters
matrixFromPrimitivesFunction to get a matrix from primitives composing the dynamic object
matrixToPrimitivesFunction to update primitives from a given matrix
queueHasNextFunction to check whether the queue has dynamic motions left (true) or not (false)
queueNextFunction to obtain the next dynamic motion from a queue
Returns
True if modifications occurred, false otherwise

◆ doObserverUpdate()

void DynMovingObject::doObserverUpdate ( )
virtual

Handle update notifications to the subscribed observer. It is, notify the observer that it has been updated by the dynamic moving object.

See also
DynMovingObject::observerStepLoop
DynMovingObject::kdGroveObserver
DynMovingObject::getObserverStepInterval
DynMovingObject::setObserverStepInterval

◆ doSimStep()

bool DynMovingObject::doSimStep ( )
virtual

Dynamic motion behavior implementation.

Let a moving dynamic object \(\mathcal{D}\) be defined by matrices \(P_{n \times m}\) defining the position and \(U_{n \times m}\) defining the normals. So the dynamic object is composed by \(m\) vertices and normals in a \(n\)-dimensional space and its update function would be as follows:

\[ \mathcal{D}_{t+1} = f\left(\mathcal{D}_{t}\right) = \left\{\begin{array}{lll} P_{t+1} &=& C + AP_{t} \\ U_{t+1} &=& C' + A'P_{t} \end{array}\right. \]

Where \(C_{n \times 1}\) is the transposition column vector and \(A_{n \times n}\) is the fixed origin transformation matrix defining the rigid motion at the core of the dynamic motion. Then, \(C'\) and \(A'\) are analogous to \(C\) and \(A\) but coming from the normal motion queue instead of the position motion queue.

Returns
True if the dynamic object was modified, false otherwise
See also
DynObject::doStep
rigidmotion::RigidMotion
DynMotion
DynMovingObject::positionMotionQueue
DynMovingObject::normalMotionQueue

Implements DynObject.

Reimplemented in DynSequentiableMovingObject.

◆ getGroveSubjectId()

std::size_t DynMovingObject::getGroveSubjectId ( )
overridevirtual

◆ getObserverStepInterval()

int DynMovingObject::getObserverStepInterval ( ) const
inline

Get the step interval between consecutive observer update notifications.

Returns
The step interval between consecutive observer update notifications
See also
DynMovingObject::observerStepLoop
DynMovingObject::kdGroveObserver
DynMovingObject::doObserverUpdate
DynMovingObject::setObserverStepInterval

◆ getType()

ObjectType DynMovingObject::getType ( ) const
inlineoverridevirtual
See also
ScenePart::getType

Reimplemented from ScenePart.

◆ load()

template<typename Archive >
void DynMovingObject::load ( Archive &  ar,
const unsigned int  version 
)
inlineprivate

Load a serialized dynamic moving object from a stream of bytes.

See also
DynMovingObject::serialize(Archive &, const unsigned int)
DynMovingObject::save(Archive &, const unsigned int)

◆ nextNormalMotion()

shared_ptr<DynMotion> DynMovingObject::nextNormalMotion ( )
inline

Retrieve the first dynamic motion in the normal motion queue.

Notice this implies removing it from the queue.

Returns
First dynamic motion in the normal motion queue

◆ nextPositionMotion()

shared_ptr<DynMotion> DynMovingObject::nextPositionMotion ( )
inline

Retrieve the first dynamic motion in the position motion queue.

Notice this implies removing it from the queue.

Returns
First dynamic motion in the position motion queue

◆ normalMotionQueueHasNext()

bool DynMovingObject::normalMotionQueueHasNext ( ) const
inline

Check if normal motion queue has a next dynamic motion or not.

Returns
True if normal motion queue has a next dynamic motion, false otherwise

◆ positionMotionQueueHasNext()

bool DynMovingObject::positionMotionQueueHasNext ( ) const
inline

Check if position motion queue has a next dynamic motion or not.

Returns
True if position motion queue has a next dynamic motion, false otherwise

◆ pushNormalMotion()

void DynMovingObject::pushNormalMotion ( shared_ptr< DynMotion > const  dm)
inline

Push given dynamic motion to the normal motion queue.

Parameters
dmDynamic motion to be pushed to the normal motion queue

◆ pushPositionMotion()

void DynMovingObject::pushPositionMotion ( shared_ptr< DynMotion > const  dm)
inline

Push given dynamic motion to the position motion queue.

Parameters
dmDynamic motion to be pushed to the position motion queue

◆ registerObserverGrove()

void DynMovingObject::registerObserverGrove ( shared_ptr< KDGrove kdGroveObserver)
override

Register given grove as a observer for the dynamic moving object.

Parameters
kdGroveObserverGrove to be registered as a observer
See also
KDGroveSubject::registerObserverGrove

◆ save()

template<typename Archive >
void DynMovingObject::save ( Archive &  ar,
const unsigned int  version 
) const
inlineprivate

Save a serialized dynamic moving object to a stream of bytes.

See also
DynMovingObject::serialize(Archive &, const unsigned int)
DynMovingObject::load(Archive &, const unsigned int)

◆ serialize()

template<typename Archive >
void DynMovingObject::serialize ( Archive &  ar,
const unsigned int  version 
)
inlineprivate

Serialize a dynamic moving object to a stream of bytes.

Template Parameters
ArchiveType of rendering
Parameters
arSpecific rendering for the stream of bytes
versionVersion number for the dynamic moving object

◆ setGroveSubjectId()

void DynMovingObject::setGroveSubjectId ( std::size_t const  id)
overridevirtual

◆ setObserverStepInterval()

void DynMovingObject::setObserverStepInterval ( int const  stepInterval)
inline

Set the step interval between consecutive observer update notifications.

Parameters
stepIntervalThe new step interval between consecutive observer update notifications
See also
DynMovingObject::observerStepLoop
DynMovingObject::kdGroveObserver
DynMovingObject::doObserverUpdate
DynMovingObject::getObserverStepInterval

◆ unregisterObserverGrove()

void DynMovingObject::unregisterObserverGrove ( )
overridevirtual

Member Data Documentation

◆ dme

DynMotionEngine DynMovingObject::dme
protected

The dynamic motion engine to apply dynamic motions.

See also
rigidmotion::RigidMotionEngine
DynMotionEngine

◆ groveSubjectId

size_t DynMovingObject::groveSubjectId
protected

The identifier of the dynamic moving object as subject of a KDGrove.

See also
DynMovingObject::kdGroveObserver

◆ kdGroveObserver

std::shared_ptr<KDGrove> DynMovingObject::kdGroveObserver
protected

The observer grove to which the dynamic moving object is registered.

See also
BasicDynGrove
KDGrove

◆ normalMotionQueue

deque<shared_ptr<DynMotion> > DynMovingObject::normalMotionQueue
protected

Queue of motions to be applied to the normal vector of each primitive.

The first motion in the queue is the first motion to be applied. The last motion in the queue is the last motion to be applied.

See also
DynMovingObject::positionMotionQueue

◆ observerStepLoop

VoidStepLoop DynMovingObject::observerStepLoop
protected

◆ positionMotionQueue

deque<shared_ptr<DynMotion> > DynMovingObject::positionMotionQueue
protected

Queue of motions to be applied to the position of each primitive.

The first motion in the queue is the first motion to be applied. The last motion in the queue is the last motion to be applied.

See also
DynMovingObject::normalMotionQueue

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