Helios++
Helios software for LiDAR simulations
PyHeliosSimulation.h
1 #pragma once
2 #ifdef PYTHON_BINDING
3 
4 #include <string>
5 #include <Leg.h>
6 #include <SurveyPlayback.h>
7 #include <memory>
8 #include <noise/RandomnessGenerator.h>
9 #include <PyPlatformWrapper.h>
10 #include <PySceneWrapper.h>
11 #include <PyHeliosOutputWrapper.h>
12 #include <PyHeliosException.h>
13 #include <XmlSurveyLoader.h>
14 
22 private:
23  // *** ATTRIBUTES *** //
24  // ******************** //
25  std::shared_ptr<XmlSurveyLoader> xmlreader = nullptr;
26  bool started = false;
27  bool paused = false;
28  bool stopped = false;
29  bool finished = false;
30  size_t numThreads = 0;
31  size_t simFrequency = 0;
32  std::string surveyPath = "NULL";
33  std::string assetsPath = "NULL";
34  std::string outputPath = "NULL";
35  std::shared_ptr<Survey> survey = nullptr;
36  std::shared_ptr<SurveyPlayback> playback = nullptr;
37  boost::thread * thread = nullptr;
38  std::shared_ptr<PySimulationCycleCallback> callback = nullptr;
39  bool lasOutput = false;
40  bool zipOutput = false;
41 public:
42  bool finalOutput = true;
43  bool exportToFile = true;
44 
45  // *** CONSTRUCTION / DESTRUCTION *** //
46  // ************************************ //
47  PyHeliosSimulation() = default;
58  std::string surveyPath,
59  std::string assetsPath = "assets/",
60  std::string outputPath = "output/",
61  size_t numThreads = 0,
62  bool lasOutput = false,
63  bool zipOutput = false
64  );
65  virtual ~PyHeliosSimulation();
66 
67  // *** GETTERS and SETTERS *** //
68  // ***************************** //
74  bool isStarted() {return started;}
80  bool isPaused() {return paused;}
86  bool isStopped() {return stopped;}
92  bool isFinished();
98  bool isRunning();
104  std::string getSurveyPath() {return surveyPath;}
110  std::string getAssetsPath() {return assetsPath;}
111 
117  Survey & getSurvey() {return *survey;}
123  Scanner & getScanner() {return *survey->scanner;}
130  {return new PyPlatformWrapper(*survey->scanner->platform);}
131  PySceneWrapper * getScene()
132  {return new PySceneWrapper(*survey->scanner->platform->scene);}
138  int getNumLegs() {return survey->legs.size();}
144  Leg & getLeg(int index) {return *(survey->legs[index]);}
150  void removeLeg(int index)
151  {survey->legs.erase(survey->legs.begin() + index);}
157  Leg & newLeg(int index);
163  size_t getSimFrequency() {return simFrequency;}
169  size_t getNumThreads() {return this->numThreads;}
173  void setNumThreads(size_t numThreads) {this->numThreads = numThreads;}
177  void setSimFrequency(size_t simFrequency)
178  {this->simFrequency = simFrequency;}
182  void setCallback(PyObject * pyCallback);
187  playback->callback = nullptr;
188  survey->scanner->cycleMeasurements = nullptr;
189  survey->scanner->cycleMeasurementsMutex = nullptr;
190  }
191  void setLasOutput(double lasOutput){
192  if(started) throw PyHeliosException(
193  "Cannot modify LAS output flag for already started simulations."
194  );
195  this->lasOutput = lasOutput;
196  }
197  double getLasOutput(){return lasOutput;}
198  double getZipOutput(){return zipOutput;}
199  void setZipOutput(bool zipOutput){
200  if(started) throw PyHeliosException(
201  "Cannot modify ZIP output flag for already started simulations."
202  );
203  this->zipOutput = zipOutput;
204  }
205 
206  // *** CONTROL FUNCTIONS *** //
207  // *************************** //
212  void start();
217  void pause();
222  void stop();
227  void resume();
232 
233  // *** SIMULATION CONFIGURATION FUNCTIONS *** //
234  // ******************************************** //
244  void loadSurvey(
245  bool legNoiseDisabled = false,
246  bool rebuildScene = false,
247  bool writeWaveform = false,
248  bool calcEchowidth = false,
249  bool fullWaveNoise = false,
250  bool platformNoiseDisabled = true
251  );
252  void addRotateFilter(
253  double q0,
254  double q1,
255  double q2,
256  double q3,
257  std::string partId
258  );
259  void addScaleFilter(double scaleFactor, std::string partId);
260  void addTranslateFilter(double x, double y, double z, std::string partId);
261 
262  // *** SIMULATION COPY *** //
263  // ************************* //
264  PyHeliosSimulation * copy();
265 };
266 
267 #endif
void start()
Start the simulation if possible. Otherwise, PyHeliosException will be thrown.
Definition: PyHeliosSimulation.cpp:49
std::string getSurveyPath()
Obtain the survey path used by the simulation.
Definition: PyHeliosSimulation.h:104
bool isRunning()
Check if the simulation is running or not.
Definition: PyHeliosSimulation.cpp:140
Leg & getLeg(int index)
Obtain leg at given index.
Definition: PyHeliosSimulation.h:144
bool isFinished()
Check if the simulation has finished or not.
Definition: PyHeliosSimulation.cpp:136
Definition: PyHeliosException.h:12
PyPlatformWrapper * getPlatform()
Obtain the platform used by the simulation.
Definition: PyHeliosSimulation.h:129
Leg & newLeg(int index)
Create a new empty leg.
Definition: PyHeliosSimulation.cpp:35
bool isPaused()
Check if the simulation has been paused or not.
Definition: PyHeliosSimulation.h:80
PyHeliosOutputWrapper * join()
Cause caller thread to wait until simulation has finished.
Definition: PyHeliosSimulation.cpp:145
Definition: PyHeliosSimulation.h:21
void setSimFrequency(size_t simFrequency)
Set the simulation frequency.
Definition: PyHeliosSimulation.h:177
size_t getNumThreads()
Obtain the number of threads.
Definition: PyHeliosSimulation.h:169
bool isStopped()
Check if the simulation has been stopped or not.
Definition: PyHeliosSimulation.h:86
Scanner & getScanner()
Obtain the scanner used by the simulation.
Definition: PyHeliosSimulation.h:123
void loadSurvey(bool legNoiseDisabled=false, bool rebuildScene=false, bool writeWaveform=false, bool calcEchowidth=false, bool fullWaveNoise=false, bool platformNoiseDisabled=true)
Load a survey XML file.
Definition: PyHeliosSimulation.cpp:187
std::string getAssetsPath()
Obtain the path to assets directory used by the simulation.
Definition: PyHeliosSimulation.h:110
size_t getSimFrequency()
Obtain simulation frequency.
Definition: PyHeliosSimulation.h:163
void setCallback(PyObject *pyCallback)
Set the simulation callback to specified python object functor.
Definition: PyHeliosSimulation.cpp:257
Class representing a scanner asset.
Definition: Scanner.h:31
Class representing a Helios++ survey.
Definition: Survey.h:11
bool isStarted()
Check if the simulation has been started or not.
Definition: PyHeliosSimulation.h:74
void pause()
Pause the simulation if possible. Otherwise, PyHeliosException will be thrown.
Definition: PyHeliosSimulation.cpp:86
void clearCallback()
Clear simulation callback so it will no longer be invoked.
Definition: PyHeliosSimulation.h:186
Class representing a survey leg.
Definition: Leg.h:11
void setNumThreads(size_t numThreads)
Set the number of threads.
Definition: PyHeliosSimulation.h:173
void stop()
Stop the simulation if possible. Otherwise, PyHeliosException will be thrown.
Definition: PyHeliosSimulation.cpp:101
void removeLeg(int index)
Remove leg at given index.
Definition: PyHeliosSimulation.h:150
Python wrapper for helios output.
Definition: PyHeliosOutputWrapper.h:16
int getNumLegs()
Obtain the number of legs.
Definition: PyHeliosSimulation.h:138
void resume()
Resume the simulation if possible. Otherwise, PyHeliosException will be thrown.
Definition: PyHeliosSimulation.cpp:116
Survey & getSurvey()
Obtain the survey used by the simulation.
Definition: PyHeliosSimulation.h:117
Wrapper for Platform class.
Definition: PyPlatformWrapper.h:12
Wrapper for Scene.
Definition: PySceneWrapper.h:22