Helios++
Helios software for LiDAR simulations
BaseMeasurementWriter.h
1 #ifndef _HELIOS_FILEMS_BASE_MEASUREMENT_WRITER_H_
2 #define _HELIOS_FILEMS_BASE_MEASUREMENT_WRITER_H_
3 
4 #include <filems/write/core/HeliosWriter.h>
5 #include <filems/factory/SyncFileMeasurementWriterFactory.h>
6 #include <scanner/Scanner.h>
7 
8 #include <string>
9 #include <memory>
10 #include <unordered_map>
11 
12 
13 namespace helios { namespace filems {
14 
15 
16 using std::string;
17 using std::shared_ptr;
18 using std::unordered_map;
19 
20 
30 template <typename ... WriteArgs>
31 class BaseMeasurementWriter : public HeliosWriter<WriteArgs ...>{
32 protected:
33  // *** USING *** //
34  // *************** //
35  using HeliosWriter<WriteArgs ...>::sfw;
36 public:
37  using HeliosWriter<WriteArgs ...>::isZipOutput;
38  using HeliosWriter<WriteArgs ...>::isLasOutput;
39  using HeliosWriter<WriteArgs ...>::isLas10;
40  using HeliosWriter<WriteArgs ...>::getLasScale;
41  using HeliosWriter<WriteArgs ...>::getOutputPath;
42 protected:
43  // *** ATTRIBUTES *** //
44  // ******************** //
49  shared_ptr<Scanner> scanner = nullptr;
54  glm::dvec3 shift;
55 
60  unordered_map<string, shared_ptr<SyncFileWriter<WriteArgs ...>>> writers{};
61 
62 public:
63  // *** CONSTRUCTION / DESTRUCTION *** //
64  // ************************************ //
68  BaseMeasurementWriter() = default;
69  virtual ~BaseMeasurementWriter() = default;
70 
71  // *** M E T H O D S *** //
72  // ************************* //
80  virtual void configure(
81  string const &parent,
82  string const &prefix,
83  bool const lastLegInStrip
84  );
89  virtual WriterType chooseWriterType() const;
93  virtual void clearPointcloudFile();
103  virtual shared_ptr<SyncFileWriter<WriteArgs ...>> makeWriter(
104  WriterType const &type,
105  string const &path,
106  bool const zipOutput,
107  double const lasScale,
108  glm::dvec3 shift,
109  double const minIntensity,
110  double const deltaIntensity
111  ) const = 0;
112 
113  // *** HELIOS WRITER METHODS *** //
114  // ******************************* //
120  void finish() override;
121 
122  // *** GETTERs and SETTERs *** //
123  // ***************************** //
128  virtual void setOutputFilePath(
129  string const &path, bool const lastLegInStrip
130  );
135  inline shared_ptr<Scanner> getScanner() const {return scanner;}
143  inline void setScanner(shared_ptr<Scanner> scanner){
144  this->scanner = scanner;
145  if(scanner != nullptr){
146  this->shift = this->scanner->platform->scene->getShift();
147  }
148  }
153  inline glm::dvec3 const& getShift(){return shift;}
154 };
155 
156 #include <filems/write/core/BaseMeasurementWriter.tpp>
157 
158 }}
159 
160 
161 #endif
Class to handle writing of measurements to generate HELIOS++ output virtual point clouds....
Definition: BaseMeasurementWriter.h:31
BaseMeasurementWriter()=default
Default constructor for base measurement writer.
virtual void configure(string const &parent, string const &prefix, bool const lastLegInStrip)
Configure the output path for the base measurement writer.
virtual WriterType chooseWriterType() const
Choose a type of file writer based on input flags.
glm::dvec3 shift
The pointer to the shift vector to be applied to measurements.
Definition: BaseMeasurementWriter.h:54
shared_ptr< Scanner > scanner
The scanner that generates the measurements to be written.
Definition: BaseMeasurementWriter.h:49
void setScanner(shared_ptr< Scanner > scanner)
Associate a new scanner with the base measurement writer, which implies updating the shift vector to ...
Definition: BaseMeasurementWriter.h:143
shared_ptr< Scanner > getScanner() const
Obtain the scanner associated with the base measurement writer.
Definition: BaseMeasurementWriter.h:135
glm::dvec3 const & getShift()
Obtain the shift applied by the base measurement writer.
Definition: BaseMeasurementWriter.h:153
virtual void clearPointcloudFile()
Clear point cloud file for current leg.
void finish() override
Finishes all writers.
unordered_map< string, shared_ptr< SyncFileWriter< WriteArgs ... > > > writers
Map of writers. This map allows to reuse writers for legs grouped in the same strip.
Definition: BaseMeasurementWriter.h:60
virtual void setOutputFilePath(string const &path, bool const lastLegInStrip)
Set path to output file.
virtual shared_ptr< SyncFileWriter< WriteArgs ... > > makeWriter(WriterType const &type, string const &path, bool const zipOutput, double const lasScale, glm::dvec3 shift, double const minIntensity, double const deltaIntensity) const =0
Make a SyncFileWriter that is suitable to be used by the base measurement writer.
Alberto M. Esmoris Pena.
Definition: HeliosWriter.h:25
bool isZipOutput() const
Get the zip output flag.
Definition: HeliosWriter.h:120
virtual string getOutputPath() const
Definition: HeliosWriter.h:93
shared_ptr< SyncFileWriter< WriteArgs ... > > sfw
Synchronous file writer.
Definition: HeliosWriter.h:33
bool isLasOutput() const
Get the LAS output flag.
Definition: HeliosWriter.h:99
double lasScale
Scale factor specification to be used when LAS output format specified.
Definition: HeliosWriter.h:56
bool zipOutput
Flag specifying if detector output must be zipped (true) or not (false)
Definition: HeliosWriter.h:50
double getLasScale() const
Obtain the LAS scale of the measurement writer.
Definition: HeliosWriter.h:131
bool isLas10() const
Get the LAS 10 specification flag.
Definition: HeliosWriter.h:110
Abstract class defining common behavior for all synchronous file writers.
Definition: SyncFileWriter.h:18