Helios++
Helios software for LiDAR simulations
PySceneWrapper.h
1 #pragma once
2 
3 #ifdef PYTHON_BINDING
4 
5 #include <string>
6 #include <Triangle.h>
7 #include <DetailedVoxel.h>
8 #include <AABB.h>
9 #include <Scene.h>
10 #include <DynScene.h>
11 #include <PyPrimitiveWrapper.h>
12 #include <PyTriangleWrapper.h>
13 #include <PyDetailedVoxelWrapper.h>
14 #include <PyAABBWrapper.h>
15 #include <PyRaySceneIntersectionWrapper.h>
16 
17 namespace pyhelios{
18 
27 public:
28  // *** ATTRIBUTES *** //
29  // ******************** //
30  Scene &scene;
31 
32  // *** CONSTRUCTOR / DESTRUCTOR *** //
33  // ********************************** //
34  PySceneWrapper(Scene &scene) : scene(scene) {}
35  virtual ~PySceneWrapper() {}
36 
37  // *** GETTERS and SETTERS *** //
38  // ***************************** //
39  PyTriangleWrapper * newTriangle(){
40  Vertex v;
41  v.pos[0] = 0.0; v.pos[1] = 0.0; v.pos[2] = 0.0;
42  Triangle * tri = new Triangle(v, v, v);
43  scene.primitives.push_back(tri);
44  return new PyTriangleWrapper(tri);
45  }
46  PyDetailedVoxelWrapper * newDetailedVoxel(){
47  std::vector<int> vi({0, 0});
48  std::vector<double> vd({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
49  DetailedVoxel *dv = new DetailedVoxel(0.0, 0.0, 0.0, 0.5, vi, vd);
50  scene.primitives.push_back(dv);
51  return new PyDetailedVoxelWrapper(dv);
52  }
53  PyPrimitiveWrapper * getPrimitive(size_t index)
54  {return new PyPrimitiveWrapper(scene.primitives[index]);}
55  PyAABBWrapper * getAABB()
56  {return new PyAABBWrapper(scene.getAABB().get());}
57  PythonDVec3 * getGroundPointAt(double x, double y, double z){
58  glm::dvec3 gp = glm::dvec3(x, y, z);
59  return new PythonDVec3(gp);
60  }
61  PyRaySceneIntersectionWrapper * getIntersection(
62  double ox, double oy, double oz, // Origin
63  double dx, double dy, double dz, // Direction
64  bool groundOnly
65  ){
66  glm::dvec3 origin(ox, oy, oz);
67  glm::dvec3 direction(dx, dy, dz);
69  *scene.getIntersection(origin, direction, groundOnly)
70  );
71  }
72  PythonDVec3 * getShift(){return new PythonDVec3(scene.getShift());}
73  size_t getNumSceneParts(){return scene.parts.size();}
74  PyScenePartWrapper * getScenePart(size_t const i)
75  {return new PyScenePartWrapper(*scene.parts[i]);}
76  size_t getDynSceneStep(){return _asDynScene().getStepInterval();}
77  void setDynSceneStep(size_t const stepInterval)
78  {_asDynScene().setStepInterval(stepInterval);}
79 
80 
81  // *** M E T H O D S *** //
82  // *********************** //
83  bool finalizeLoading() {return scene.finalizeLoading();}
84  void writeObject(std::string path) {scene.writeObject(path);}
85 
86  // *** INTERNAL USE *** //
87  // ********************** //
93 };
94 
95 }
96 
97 #endif
Class which extends Voxel to support AMAPVox format with extra features.
Definition: DetailedVoxel.h:15
Dynamic scene base implementation.
Definition: DynScene.h:29
void setStepInterval(int const stepInterval)
Set the step interval for the dynamic scene.
Definition: DynScene.h:235
int getStepInterval() const
Obtain the current step interval for the dynamic scene.
Definition: DynScene.h:228
Class representing a scene asset.
Definition: Scene.h:28
glm::dvec3 getShift()
Obtain the minimum boundaries of the original axis aligned bounding box containing the scene,...
Definition: Scene.cpp:210
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.
Definition: Scene.cpp:168
std::vector< std::shared_ptr< ScenePart > > parts
Parts composing the scene with no repeats.
Definition: Scene.h:141
std::vector< Primitive * > primitives
Vector of primitives composing the scene.
Definition: Scene.h:132
virtual void writeObject(std::string path)
Serialize the scene and write it to given output file.
Definition: Scene.cpp:385
std::shared_ptr< AABB > getAABB()
Obtain the axis aligned bounding box defining scene boundaries.
Definition: Scene.cpp:142
bool finalizeLoading(bool const safe=false)
Handle scene loading finish process.
Definition: Scene.cpp:69
Class representing triangle primitive.
Definition: Triangle.h:13
Class representing a vertex.
Definition: Vertex.h:14
glm::dvec3 pos
Vertex 3D position.
Definition: Vertex.h:39
Wrapper for AABB class.
Definition: PyAABBWrapper.h:16
Wrapper for DetailedVoxel class.
Definition: PyDetailedVoxelWrapper.h:16
Wrapper for Primitive class.
Definition: PyPrimitiveWrapper.h:20
Wrapper for RaySceneIntersection.
Definition: PyRaySceneIntersectionWrapper.h:16
Wrapper for ScenePart class.
Definition: PyScenePartWrapper.h:18
Wrapper for Scene.
Definition: PySceneWrapper.h:26
DynScene & _asDynScene()
Obtain the scene as a dynamic scene if possible. Use with caution because an exception can be thrown ...
Definition: PySceneWrapper.cpp:9
Wrapper for Triangle class.
Definition: PyTriangleWrapper.h:17
Wrapper to communicate glm::dvec3 with python.
Definition: PythonDVec3.h:16