Helios++
Helios software for LiDAR simulations
PySceneWrapper.h
1 #pragma once
2 
3 #ifdef PYTHON_BINDING
4 
5 #include <Triangle.h>
6 #include <DetailedVoxel.h>
7 #include <AABB.h>
8 #include <Scene.h>
9 #include <PyPrimitiveWrapper.h>
10 #include <PyTriangleWrapper.h>
11 #include <PyDetailedVoxelWrapper.h>
12 #include <PyAABBWrapper.h>
13 #include <PyRaySceneIntersectionWrapper.h>
14 
23 public:
24  // *** ATTRIBUTES *** //
25  // ******************** //
26  Scene &scene;
27 
28  // *** CONSTRUCTOR / DESTRUCTOR *** //
29  // ********************************** //
30  PySceneWrapper(Scene &scene) : scene(scene) {}
31  virtual ~PySceneWrapper() {}
32 
33  // *** GETTERS and SETTERS *** //
34  // ***************************** //
35  PyTriangleWrapper * newTriangle(){
36  Vertex v;
37  v.pos[0] = 0.0; v.pos[1] = 0.0; v.pos[2] = 0.0;
38  Triangle * tri = new Triangle(v, v, v);
39  scene.primitives.push_back(tri);
40  return new PyTriangleWrapper(tri);
41  }
42  PyDetailedVoxelWrapper * newDetailedVoxel(){
43  std::vector<int> vi({0, 0});
44  std::vector<double> vd({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
45  DetailedVoxel *dv = new DetailedVoxel(0.0, 0.0, 0.0, 0.5, vi, vd);
46  scene.primitives.push_back(dv);
47  return new PyDetailedVoxelWrapper(dv);
48  }
49  PyPrimitiveWrapper * getPrimitive(size_t index)
50  {return new PyPrimitiveWrapper(scene.primitives[index]);}
51  PyAABBWrapper * getAABB()
52  {return new PyAABBWrapper(scene.getAABB().get());}
53  PythonDVec3 * getGroundPointAt(double x, double y, double z){
54  glm::dvec3 gp = glm::dvec3(x, y, z);
55  return new PythonDVec3(gp);
56  }
57  PyRaySceneIntersectionWrapper * getIntersection(
58  double ox, double oy, double oz, // Origin
59  double dx, double dy, double dz, // Direction
60  bool groundOnly
61  ){
62  glm::dvec3 origin(ox, oy, oz);
63  glm::dvec3 direction(dx, dy, dz);
65  *scene.getIntersection(origin, direction, groundOnly)
66  );
67  }
68  PythonDVec3 * getShift(){return new PythonDVec3(scene.getShift());}
69 
70 
71  // *** M E T H O D S *** //
72  // *********************** //
73  bool finalizeLoading() {return scene.finalizeLoading();}
74  void writeObject(std::string path) {scene.writeObject(path);}
75 };
76 
77 #endif
Wrapper for Triangle class.
Definition: PyTriangleWrapper.h:15
Wrapper for AABB class.
Definition: PyAABBWrapper.h:14
void writeObject(std::string path)
Serialize the scene and write it to given output file.
Definition: Scene.cpp:231
std::shared_ptr< AABB > getAABB()
Obtain the axis aligned bounding box defining scene boundaries.
Definition: Scene.cpp:144
std::vector< Primitive * > primitives
Vector of primitives composing the scene.
Definition: Scene.h:66
Class which extends Voxel to support AMAPVox format with extra features.
Definition: DetailedVoxel.h:12
bool finalizeLoading()
Handle scene loading finish process.
Definition: Scene.cpp:59
Class representing triangle primitive.
Definition: Triangle.h:13
Wrapper for RaySceneIntersection.
Definition: PyRaySceneIntersectionWrapper.h:14
glm::dvec3 pos
Vertex 3D position.
Definition: Vertex.h:32
Wrapper for DetailedVoxel class.
Definition: PyDetailedVoxelWrapper.h:14
glm::dvec3 getShift()
Obtain the minimum boundaries of the original axis aligned bounding box containing the scene...
Definition: Scene.cpp:227
Class representing a scene asset.
Definition: Scene.h:25
Wrapper for Primitive class.
Definition: PyPrimitiveWrapper.h:18
std::shared_ptr< RaySceneIntersection > getIntersection(glm::dvec3 &rayOrigin, glm::dvec3 &rayDir, bool groundOnly)
Obtain the intersection between the ray and the scene, if any.
Definition: Scene.cpp:174
Wrapper to communicate glm::dvec3 with python.
Definition: PythonDVec3.h:14
Class representing a vertex.
Definition: Vertex.h:14
Wrapper for Scene.
Definition: PySceneWrapper.h:22