Helios++
Helios software for LiDAR simulations
ScenePart Class Reference

Class representing a scene part. More...

#include <ScenePart.h>

Inheritance diagram for ScenePart:
Collaboration diagram for ScenePart:

Public Types

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 Member Functions

 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 ObjectType getType () const
 Obtain the object type of the scene part. More...
 
virtual PrimitiveType getPrimitiveType () const
 

Public Attributes

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
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 Serialize a ScenePart to a stream of bytes. More...
 

Friends

class boost::serialization::access
 

Detailed Description

Class representing a scene part.

Member Enumeration Documentation

◆ PrimitiveType

Specify the type of primitive used to build the scene part By default, the ScenePart is not build from primitives (None)

See also
ScenePart::primitiveType

Constructor & Destructor Documentation

◆ ScenePart()

ScenePart::ScenePart ( )
inline

Default constructor for a scene part.

Parameters
shallowPrimitivesIf true, primitives pointers will be the same for the copy and for the source. If false, then primitives for the copy will be cloned so they are at different memory regions. Notice that a shallow copy of the primitives implies that the primitives in the copy will have the source as their reference scene part. Use this mode (true) with caution.

Member Function Documentation

◆ addObj()

void ScenePart::addObj ( WavefrontObj obj)

Add the primitives of a WavefrontObj to the ScenePart.

Parameters
objPointer to a loaded OBJ

◆ computeCentroid()

void ScenePart::computeCentroid ( bool const  computeBound = false)

Compute the default centroid for the scene part as the midrange point and its boundaries too.

Let \(P = \left\{p_1, \ldots, p_m\right\}\) be the set of points/vertices defining the scene part, where \(\forall p_i \in P,\, p_i=\left(p_{ix}, p_{iy}, p_{iz}\right)\). So \(\vec{p}_{x}\) is the vector containing the \(m\) \(x\)-coordinates, \(\vec{p}_{y}\) is the vector containing the \(m\) \(y\)-coordinates and \(\vec{p}_{z}\) is the vector containing the \(m\) \(z\)-cordinates. Now, let \(o\) be the centroid of the scene part, so it can be defined as

\[ \begin{array}{lll} o &=& \frac{1}{2} \left( \min\left(\vec{p}_x\right)+\max\left(\vec{p}_{x}\right), \min\left(\vec{p}_y\right)+\max\left(\vec{p}_{y}\right), \min\left(\vec{p}_z\right)+\max\left(\vec{p}_{z}\right) \right) \\ &=& \frac{1}{2} \left(\frac{a+b}{2}\right) \end{array} \]

The boundaries of the scene part are defined as the set of the min and max vertices respectively \(\{a, b\}\) where:

\[ \begin{array}{lll} a &=& \left( \min\left(\vec{p}_x\right), \min\left(\vec{p}_y\right), \min\left(\vec{p}_z\right) \right) \\ b &=& \left( \max\left(\vec{p}_x\right), \max\left(\vec{p}_y\right), \max\left(\vec{p}_z\right) \right) \end{array} \]

Parameters
computeBoundTrue to specify boundaries must be computed, false to avoid it. They are already necessary to compute the centroid, so if they are needed, calling this function with computeBound=true will store them with no extra computations but the ones required to build the AABB object itself
See also
ScenePart::centroid
AABB

◆ getAllVertices()

std::vector< Vertex * > ScenePart::getAllVertices ( ) const

Obtain all vertices in the scene part.

Returns
All vertices in the scene part

◆ getCentroid()

arma::colvec ScenePart::getCentroid ( ) const
inline

Obtain the centroid of the scene part.

Returns
Scene part centroid
See also
ScenePart::centroid

◆ getId()

std::string const& ScenePart::getId ( ) const
inline

Obtain the ID of the scene part.

Returns
Scene part ID
See also
ScenePart::mId

◆ getPrimitives()

std::vector<Primitive *> const& ScenePart::getPrimitives ( ) const
inline

Obtain the primitives of the scene part.

Returns
Scene part primitives
See also
ScenePart::mPrimitives

◆ getType()

virtual ObjectType ScenePart::getType ( ) const
inlinevirtual

Obtain the object type of the scene part.

Returns
Object type of the scene part
See also
ScenePart::ObjectType

Reimplemented in DynObject, and DynMovingObject.

◆ serialize()

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

Serialize a ScenePart to a stream of bytes.

Template Parameters
ArchiveType of rendering
Parameters
arSpecific rendering for the stream of bytes
versionVersion number for the ScenePart

◆ setCentroid()

void ScenePart::setCentroid ( arma::colvec  centroid)
inline

Set the centroid of the scene part.

Parameters
centroidNew centroid for the scene part
See also
ScenePart::centroid

◆ setId()

void ScenePart::setId ( const std::string &  id)
inline

Set the ID of the scene part.

Parameters
idScene part ID
See also
ScenePart::id

◆ setPrimitives()

void ScenePart::setPrimitives ( std::vector< Primitive * > const &  primitives)
inline

Set the primitives of the scene part.

Parameters
primitivesScene part primitives
See also
ScenePart::mPrimitives

◆ splitSubparts()

bool ScenePart::splitSubparts ( )

Split each subpart into a different scene part, with the first one corresponding to this scene part.

See also
subpartLimit
Returns
True when split was successfully performed, false otherwise

Member Data Documentation

◆ forceOnGround

int ScenePart::forceOnGround = 0

Force the scene part to be on ground if \(\neq 0\), do nothing if \(= 0\).

The force on ground process assumes the ground can be reduced to a plane and uses a search process:
-1 : Force on ground with optimum vertex, it is the one which is closest to the ground plane. Optimum solution with respect to ground plane is guaranteed but it is the most computationally expensive mode
0 : Dont force on ground at all
1 : Uses the minimum \(z\) vertex to calculate to ground translation. It is the least computationally expensive mode
>1 : Uses a search process considering as many search steps as given. It allows to approximate the optimum vertex while maintaining computational cost inside desired boundaries

NOTICE forceOnGround will not force the object to be on ground if it is a dynamic object which moves around the scene. It only assures the object will be INITIALLY placed at ground level

◆ primitiveType

PrimitiveType ScenePart::primitiveType

The type of primitive used to build the scene part.

See also
ScenePart::PrimitiveType

◆ subpartLimit

std::vector<size_t> ScenePart::subpartLimit

Vector specifying the limit of a subpart as the index of first element of next subpart.

This vector makes sense when a scene part is built from multiple objects, so each one must be placed on its own scene part.

The ith subpart is defined inside interval \([u[i-1], u[i])\), where \(u\) is the subpartLimit vector. For the first case, the interval is defined as \([0, u[i])\) Having \(|u| = 1\) means there is only one scene part


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