Helios++
Helios software for LiDAR simulations
SyncFileMeasurementWriterFactory.h
1 //
2 // Created by miguelyermo on 18/5/21.
3 //
4 
5 /*
6  * FILENAME : SyncFileMeasurementWriterFactory.h
7  * PROJECT : helios
8  * DESCRIPTION :
9  *
10  *
11  *
12  *
13  *
14  * AUTHOR : Miguel Yermo START DATE : 16:34 18/5/21
15  *
16  */
17 
18 #pragma once
19 
20 #include <filems/write/comps/SyncFileWriter.h>
21 #include <filems/write/comps/Las14SyncFileMeasurementWriter.h>
22 #include <filems/write/comps/LasSyncFileMeasurementWriter.h>
23 #include <filems/write/comps/ZipSyncFileMeasurementWriter.h>
24 #include <filems/write/comps/SimpleSyncFileMeasurementWriter.h>
25 #include <filems/write/comps/Las14VectorialSyncFileMeasurementWriter.h>
26 #include <filems/write/comps/Las14MultiVectorialSyncFileMeasurementWriter.h>
27 #include <filems/write/comps/LasVectorialSyncFileMeasurementWriter.h>
28 #include <filems/write/comps/LasMultiVectorialSyncFileMeasurementWriter.h>
29 #include <filems/write/comps/ZipVectorialSyncFileMeasurementWriter.h>
30 #include <filems/write/comps/ZipMultiVectorialSyncFileMeasurementWriter.h>
31 #include <filems/write/comps/SimpleVectorialSyncFileMeasurementWriter.h>
32 #include <filems/write/comps/SimpleMultiVectorialSyncFileMeasurementWriter.h>
33 #include <util/HeliosException.h>
34 
35 #include <string>
36 #include <sstream>
37 #include <memory>
38 
39 namespace helios { namespace filems{
40 
41 using std::string;
42 using std::stringstream;
43 using std::shared_ptr;
44 using std::make_shared;
45 
46 // ** Types of writers ** //
47 
51 enum WriterType
52 {
53  las10Type,
54  las14Type,
55  zipType,
56  simpleType
57 };
58 
59 
60 // ** SyncFileWriter factory ** //
61 
69 {
70 
71 public:
72  // *** STATIC MAKE METHODS *** //
73  // ***************************** //
85 static shared_ptr<SyncFileWriter<Measurement const&, glm::dvec3 const&>>
87  WriterType const type, const string &path, bool const compress = false,
88  double const scaleFactor = 0.0001,
89  glm::dvec3 const offset = glm::dvec3(0, 0, 0),
90  double const minIntensity = 0.0, double const deltaIntensity = 1000000.0
91 ){
92  switch (type) {
93  case las10Type:
94  return make_shared<LasSyncFileMeasurementWriter>(
95  path, // Output path
96  compress, // Zip flag
97  scaleFactor, // Scale factor
98  offset, // Offset
99  minIntensity, // Min intensity
100  deltaIntensity // Delta intensity
101  );
102  case las14Type:
103  return make_shared<Las14SyncFileMeasurementWriter>(
104  path, // Output path
105  compress, // Zip flag
106  scaleFactor, // Scale factor
107  offset, // Offset
108  minIntensity, // Min intensity
109  deltaIntensity // Delta intensity
110  );
111  case zipType:
112  return make_shared<ZipSyncFileMeasurementWriter>(path);
113  case simpleType:
114  return make_shared<SimpleSyncFileMeasurementWriter>(path);
115  }
116 
117  // Handle unexpected type
118  stringstream ss;
119  ss << "SyncFileMeasurementWriterFactory::makeWriter received an "
120  << "unexpected type: (" << type << ")";
121  throw HeliosException(ss.str());
122 }
123 
124 
136 static shared_ptr<
137  SyncFileWriter<vector<Measurement> const&, glm::dvec3 const&>
139  WriterType const type, const string &path, bool const compress = false,
140  double const scaleFactor = 0.0001,
141  glm::dvec3 const offset = glm::dvec3(0, 0, 0),
142  double const minIntensity = 0.0, double const deltaIntensity = 1000000.0
143 ){
144  switch (type) {
145  case las10Type:
146  return make_shared<LasVectorialSyncFileMeasurementWriter>(
147  path, // Output path
148  compress, // Zip flag
149  scaleFactor, // Scale factor
150  offset, // Offset
151  minIntensity, // Min intensity
152  deltaIntensity // Delta intensity
153  );
154  case las14Type:
155  return make_shared<Las14VectorialSyncFileMeasurementWriter>(
156  path, // Output path
157  compress, // Zip flag
158  scaleFactor, // Scale factor
159  offset, // Offset
160  minIntensity, // Min intensity
161  deltaIntensity // Delta intensity
162  );
163  case zipType:
164  return make_shared<ZipVectorialSyncFileMeasurementWriter>(path);
165  case simpleType:
166  return make_shared<SimpleVectorialSyncFileMeasurementWriter>(path);
167  }
168 
169  // Handle unexpected type
170  stringstream ss;
171  ss << "SyncFileMeasurementWriterFactory::makeVectorialWriter received an "
172  << "unexpected type: (" << type << ")";
173  throw HeliosException(ss.str());
174 }
175 
187 static shared_ptr<
188  SyncFileWriter<vector<Measurement> const&, glm::dvec3 const&>
190  WriterType const type,
191  vector<string> const &path,
192  bool const compress,
193  vector<double> const &scaleFactor,
194  vector<glm::dvec3> const &offset,
195  vector<double> const &minIntensity,
196  vector<double> const &deltaIntensity
197 ){
198  switch (type) {
199  case las10Type:
200  return make_shared<LasMultiVectorialSyncFileMeasurementWriter>(
201  path, // Output path
202  compress, // Zip flag
203  scaleFactor, // Scale factor
204  offset, // Offset
205  minIntensity, // Min intensity
206  deltaIntensity // Delta intensity
207  );
208  case las14Type:
209  return make_shared<Las14MultiVectorialSyncFileMeasurementWriter>(
210  path, // Output path
211  compress, // Zip flag
212  scaleFactor, // Scale factor
213  offset, // Offset
214  minIntensity, // Min intensity
215  deltaIntensity // Delta intensity
216  );
217  case zipType:
218  return make_shared<ZipMultiVectorialSyncFileMeasurementWriter>(
219  path
220  );
221  case simpleType:
222  return make_shared<SimpleMultiVectorialSyncFileMeasurementWriter>(
223  path
224  );
225  }
226 
227  // Handle unexpected type
228  stringstream ss;
229  ss << "SyncFileMeasurementWriterFactory::makeMultiVectorialWriter "
230  << "received an unexpected type: (" << type << ")";
231  throw HeliosException(ss.str());
232 }
233 
234 };
235 
236 }}
Base class for Helios exceptions.
Definition: HeliosException.h:12
SyncFileMeasurementWriter Factory class. Used to create the appropriate measurement writers based on ...
Definition: SyncFileMeasurementWriterFactory.h:69
static shared_ptr< SyncFileWriter< vector< Measurement > const &, glm::dvec3 const & >> makeMultiVectorialWriter(WriterType const type, vector< string > const &path, bool const compress, vector< double > const &scaleFactor, vector< glm::dvec3 > const &offset, vector< double > const &minIntensity, vector< double > const &deltaIntensity)
Synchronous multi-stream vectorial file writer factory.
Definition: SyncFileMeasurementWriterFactory.h:189
static shared_ptr< SyncFileWriter< vector< Measurement > const &, glm::dvec3 const & >> makeVectorialWriter(WriterType const type, const string &path, bool const compress=false, double const scaleFactor=0.0001, glm::dvec3 const offset=glm::dvec3(0, 0, 0), double const minIntensity=0.0, double const deltaIntensity=1000000.0)
Synchronous vectorial file writer factory.
Definition: SyncFileMeasurementWriterFactory.h:138
static shared_ptr< SyncFileWriter< Measurement const &, glm::dvec3 const & > > makeWriter(WriterType const type, const string &path, bool const compress=false, double const scaleFactor=0.0001, glm::dvec3 const offset=glm::dvec3(0, 0, 0), double const minIntensity=0.0, double const deltaIntensity=1000000.0)
Synchronous file writer factory.
Definition: SyncFileMeasurementWriterFactory.h:86
Abstract class defining common behavior for all synchronous file writers.
Definition: SyncFileWriter.h:18