Helios++
Helios software for LiDAR simulations
ScenePart.h
1 #pragma once
2 
3 
4 class Primitive;
5 class AABB;
6 class WavefrontObj;
7 
8 #include <Vertex.h>
9 #include <maths/Rotation.h>
10 #include <LadLut.h>
11 
12 #include <armadillo>
13 #include <ogr_geometry.h>
14 #include <iostream>
15 #include <vector>
16 
20 class ScenePart {
21  // *** SERIALIZATION *** //
22  // *********************** //
23  friend class boost::serialization::access;
30  template<class Archive>
31  void serialize(Archive &ar, const unsigned int version){
32  ar & mPrimitives;
33  ar & centroid;
34  ar & bound;
35  ar & mId;
36  ar & subpartLimit;
39  ar & randomShift;
40  ar & ladlut;
41  ar & mOrigin;
42  ar & mRotation;
43  ar & mScale;
44  ar & forceOnGround;
45  }
46 public:
47  // *** TYPE ENUM *** //
48  // ******************** //
53  enum ObjectType{
54  STATIC_OBJECT,
55  DYN_OBJECT,
56  DYN_MOVING_OBJECT
57  };
64  NONE,
65  TRIANGLE,
66  VOXEL
67  };
68  // *** ATTRIBUTES *** //
69  // ******************** //
78  std::vector<Primitive*> mPrimitives;
82  arma::colvec centroid;
86  std::shared_ptr<AABB> bound = nullptr;
87 
91  std::string mId = "";
104  std::vector<size_t> subpartLimit;
108  std::string onRayIntersectionMode = "";
118  bool randomShift = false;
119 
123  std::shared_ptr<LadLut> ladlut = nullptr;
124 
128  glm::dvec3 mOrigin = glm::dvec3(0, 0, 0);
132  Rotation mRotation = Rotation(glm::dvec3(1, 0, 0), 0);
136  double mScale = 1;
158  int forceOnGround = 0;
159 
160 
161  OGRSpatialReference *mCrs = nullptr;
162  OGREnvelope *mEnv = nullptr;
163 
164  // *** CONSTRUCTION / DESTRUCTION *** //
165  // ************************************ //
177  {}
178  ScenePart(ScenePart const &sp, bool const shallowPrimitives=false);
179  virtual ~ScenePart() {}
180 
181  // *** COPY / MOVE OPERATORS *** //
182  // ******************************* //
186  ScenePart & operator=(const ScenePart & rhs);
187 
188  // *** M E T H O D S *** //
189  // ************************* //
194  void addObj(WavefrontObj * obj);
199  std::vector<Vertex*> getAllVertices() const;
200 
205  void smoothVertexNormals();
206 
213  bool splitSubparts();
214 
266  void computeCentroid(bool const computeBound=false);
267 
268  // *** GETTERS and SETTERS *** //
269  // ***************************** //
275  inline std::vector<Primitive *> const & getPrimitives() const
276  {return mPrimitives;}
282  inline void setPrimitives(std::vector<Primitive *> const &primitives)
283  {this->mPrimitives = primitives;}
289  inline arma::colvec getCentroid() const {return centroid;}
295  inline void setCentroid(arma::colvec centroid) {this->centroid = centroid;}
296 
302  inline std::string const &getId() const {return mId;}
308  inline void setId(const std::string &id) {this->mId = id;}
314  virtual ObjectType getType() const {return ObjectType::STATIC_OBJECT;}
315  virtual PrimitiveType getPrimitiveType() const {return primitiveType;}
316 
317 
318 };
Class representing an Axis Aligned Bounding Box (AABB)
Definition: AABB.h:10
Abstract class defining the common behavior for all primitives.
Definition: Primitive.h:24
Definition: Rotation.h:80
Class representing a scene part.
Definition: ScenePart.h:20
void setId(const std::string &id)
Set the ID of the scene part.
Definition: ScenePart.h:308
ScenePart & operator=(const ScenePart &rhs)
Copy assigment operator.
Definition: ScenePart.cpp:49
std::vector< Primitive * > mPrimitives
Vector of pointers to primitives used by this scene part.
Definition: ScenePart.h:78
void smoothVertexNormals()
Smooth normals for each vertex computing the mean for each triangle using it.
Definition: ScenePart.cpp:106
bool randomShift
Specify if apply random shift to the scene part (true) or not (false, by default)
Definition: ScenePart.h:118
void setPrimitives(std::vector< Primitive * > const &primitives)
Set the primitives of the scene part.
Definition: ScenePart.h:282
void setCentroid(arma::colvec centroid)
Set the centroid of the scene part.
Definition: ScenePart.h:295
virtual ObjectType getType() const
Obtain the object type of the scene part.
Definition: ScenePart.h:314
PrimitiveType
Specify the type of primitive used to build the scene part By default, the ScenePart is not build fro...
Definition: ScenePart.h:63
arma::colvec centroid
The centroid of the scene part.
Definition: ScenePart.h:82
std::vector< size_t > subpartLimit
Vector specifying the limit of a subpart as the index of first element of next subpart.
Definition: ScenePart.h:104
glm::dvec3 mOrigin
Specify the origin for the scene part.
Definition: ScenePart.h:128
double onRayIntersectionArgument
Specify the extra value to be used for ray intersection handling computation, when needed (depends on...
Definition: ScenePart.h:113
bool splitSubparts()
Split each subpart into a different scene part, with the first one corresponding to this scene part.
Definition: ScenePart.cpp:141
Rotation mRotation
Specify the rotation for the scene part.
Definition: ScenePart.h:132
void computeCentroid(bool const computeBound=false)
Compute the default centroid for the scene part as the midrange point and its boundaries too.
Definition: ScenePart.cpp:199
std::string onRayIntersectionMode
Specify the handling mode for ray intersections.
Definition: ScenePart.h:108
std::string const & getId() const
Obtain the ID of the scene part.
Definition: ScenePart.h:302
std::shared_ptr< LadLut > ladlut
Look-up table for leaf angle distribution.
Definition: ScenePart.h:123
ObjectType
Specify the type of scene part / object. By default, the ScenePart is a static object.
Definition: ScenePart.h:53
std::vector< Vertex * > getAllVertices() const
Obtain all vertices in the scene part.
Definition: ScenePart.cpp:96
arma::colvec getCentroid() const
Obtain the centroid of the scene part.
Definition: ScenePart.h:289
double mScale
Specify the scale for the scene part.
Definition: ScenePart.h:136
void serialize(Archive &ar, const unsigned int version)
Serialize a ScenePart to a stream of bytes.
Definition: ScenePart.h:31
PrimitiveType primitiveType
The type of primitive used to build the scene part.
Definition: ScenePart.h:74
void addObj(WavefrontObj *obj)
Add the primitives of a WavefrontObj to the ScenePart.
Definition: ScenePart.cpp:79
ScenePart()
Default constructor for a scene part.
Definition: ScenePart.h:175
int forceOnGround
Force the scene part to be on ground if , do nothing if .
Definition: ScenePart.h:158
std::shared_ptr< AABB > bound
The axis aligned bounding box defining scene part boundaries.
Definition: ScenePart.h:86
std::vector< Primitive * > const & getPrimitives() const
Obtain the primitives of the scene part.
Definition: ScenePart.h:275
std::string mId
Identifier for the scene part.
Definition: ScenePart.h:91
Class representing a .obj loaded file.
Definition: WavefrontObj.h:15