Helios++
Helios software for LiDAR simulations
DirectFullWaveformWriteStrategy.h
1 #pragma once
2 
3 #include <filems/write/strategies/WriteStrategy.h>
4 #include <scanner/detector/FullWaveform.h>
5 
6 #include <vector>
7 #include <fstream>
8 #include <sstream>
9 
10 namespace helios { namespace filems {
11 
21  public WriteStrategy<FullWaveform const &>
22 {
23 protected:
24  // *** ATTRIBUTES *** //
25  // ******************** //
29  std::ofstream &ofs;
30 
31 public:
32  // *** CONSTRUCTION / DESTRUCTION *** //
33  // ************************************ //
39  virtual ~DirectFullWaveformWriteStrategy() = default;
40 
41  // *** WRITE STRATEGY INTERFACE *** //
42  // ********************************** //
48  void write(FullWaveform const &fullWaveform) override {
49  ofs << fullWaveformToString(fullWaveform);
50  }
51 
52 protected:
53  // *** UTILS *** //
54  // *************** //
60  virtual std::string fullWaveformToString(FullWaveform const &fw){
61  std::stringstream ss;
62  ss << std::setprecision(4) << std::fixed
63  << fw.fullwaveIndex << " "
64  << fw.beamOrigin.x << " "
65  << fw.beamOrigin.y << " "
66  << fw.beamOrigin.z << " "
67  << fw.beamDir.x << " "
68  << fw.beamDir.y << " "
69  << fw.beamDir.z << " "
70  << fw.minTime << " "
71  << fw.maxTime << " "
72  << std::setprecision(9) << std::fixed
73  << fw.gpsTime/1000000000.0 << " ";
74 
75  std::copy(
76  fw.fullwave.begin(),
77  fw.fullwave.end()-1,
78  std::ostream_iterator<double>(ss, " ")
79  );
80  ss << fw.fullwave.back();
81  ss << "\n";
82  return ss.str();
83  }
84 };
85 
86 }}
Class representing a full waveform.
Definition: FullWaveform.h:12
std::vector< double > fullwave
The full wave vector containing the values of the full waveform itself.
Definition: FullWaveform.h:20
glm::dvec3 beamDir
The director vector of the beam.
Definition: FullWaveform.h:40
double maxTime
Maximum hit time (nanoseconds)
Definition: FullWaveform.h:32
double gpsTime
The GPS time associated to the full wave (nanoseconds)
Definition: FullWaveform.h:44
int fullwaveIndex
The index for the full wave.
Definition: FullWaveform.h:24
double minTime
Minimum hit time (nanoseconds)
Definition: FullWaveform.h:28
glm::dvec3 beamOrigin
The coordinates of the beam origin.
Definition: FullWaveform.h:36
Concrete class specializing WriteStrategy to directly write full waveform data to a file.
Definition: DirectFullWaveformWriteStrategy.h:22
virtual std::string fullWaveformToString(FullWaveform const &fw)
Build a string from fullwave data.
Definition: DirectFullWaveformWriteStrategy.h:60
std::ofstream & ofs
The output file stream to do the writing.
Definition: DirectFullWaveformWriteStrategy.h:29
void write(FullWaveform const &fullWaveform) override
Write full waveform data to file.
Definition: DirectFullWaveformWriteStrategy.h:48
DirectFullWaveformWriteStrategy(std::ofstream &ofs)
Default constructor for direct full waveform write strategy.
Definition: DirectFullWaveformWriteStrategy.h:38
Interface that must be implemented by any class which supports write implementations for file writers...
Definition: WriteStrategy.h:14