UosIO.hpp
Go to the documentation of this file.
1 
35 #ifndef UOSIO_H_
36 #define UOSIO_H_
37 
38 #define _USE_MATH_DEFINES
39 
40 #include <string>
41 #include <iomanip>
42 #include <iostream>
43 #include <math.h>
44 #include <fstream>
45 #include <sstream>
46 #include <vector>
47 
48 #include "lvr2/io/BaseIO.hpp"
49 #include "lvr2/io/AsciiIO.hpp"
50 
53 
54 using std::string;
55 using std::fstream;
56 using std::stringstream;
57 
58 namespace lvr2
59 {
60 
61 using Vec = BaseVector<float>;
62 
74 class UosIO : public BaseIO
75 {
76 
77 public:
78 
82  UosIO() :
83  m_firstScan(-1),
84  m_lastScan(-1),
85  m_saveToDisk(false),
87  m_numScans(0),
88  m_saveRemission(false),
89  m_saveRemissionColor(false){}
90 
98  ModelPtr read(string dir);
99 
100 
105  void setFirstScan(int n) { m_firstScan = n;}
106 
107 
112  void setLastScan(int n) {m_lastScan = n;}
113 
114 
123  void reduce(string dir, string target, int reduction = 1);
124 
125 
130  void save(string filename) {}
131 
132 
133 
138 
139 
143  void saveRemission(bool yes) { m_saveRemission= yes;}
144 
145 
153  Matrix4<Vec> parseFrameFile(ifstream& frameFile);
154 
155 private:
156 
164  void readNewFormat(ModelPtr &m, string dir, int first, int last, size_t &n);
165 
166 
174  void readOldFormat(ModelPtr &m, string dir, int first, int last, size_t &n);
175 
176 
177  inline std::string to_string(const int& t, int width)
178  {
179  stringstream ss;
180  ss << std::setfill('0') << std::setw(width) << t;
181  return ss.str();
182  }
183 
184 
185  inline std::string to_string(const int& t)
186  {
187  stringstream ss;
188  ss << t;
189  return ss.str();
190  }
191 
192 
202  inline float rad(const float deg)
203  {
204  return (float)((2 * M_PI * deg) / 360);
205  }
206 
207 
214  inline float deg(const float rad)
215  {
216  return (float)((rad * 360) / (2 * M_PI));
217  }
218 
219 
222 
225 
228 
230  ofstream m_outputFile;
231 
234 
237 
240 
243 
244 };
245 
246 } // namespace lvr2
247 
248 #endif /* UOSIO_H_ */
void saveRemissionAsColor(bool convert)
Convert remission value to pseudo RGB values while saving.
Definition: UosIO.hpp:137
int m_numScans
Number of loaded scans.
Definition: UosIO.hpp:233
void first(int id)
Definition: example.cpp:7
std::string to_string(const int &t, int width)
Definition: UosIO.hpp:177
bool m_saveRemissionColor
If true, remission values will be converted to color.
Definition: UosIO.hpp:239
A 4x4 matrix class implementation for use with the provided vertex types.
Definition: Matrix4.hpp:64
void readOldFormat(ModelPtr &m, string dir, int first, int last, size_t &n)
Reads scans from first} to last} in old UOS format.
Definition: UosIO.cpp:517
bool m_saveRemission
If true, the original remission information will be saved.
Definition: UosIO.hpp:242
void setLastScan(int n)
Defines the last scan to read.
Definition: UosIO.hpp:112
void convert(COORD_SYSTEM from, COORD_SYSTEM to, float *point)
void reduce(string dir, string target, int reduction=1)
Definition: UosIO.cpp:180
Matrix4< Vec > parseFrameFile(ifstream &frameFile)
Creates a transformation matrix from given frame file.
Definition: UosIO.cpp:708
UosIO()
Contructor.
Definition: UosIO.hpp:82
float deg(const float rad)
Definition: UosIO.hpp:214
#define M_PI
Definition: Matrix4.hpp:52
ModelPtr read(string dir)
Reads all scans or an specified range of scans from the given directory.
Definition: UosIO.cpp:59
Read and write pointclouds from .pts and .3d files.
Interface specification for low-level io. All read elements are stored in linear arrays.
Definition: BaseIO.hpp:57
void readNewFormat(ModelPtr &m, string dir, int first, int last, size_t &n)
Reads scans from first} to last} in new UOS format.
Definition: UosIO.cpp:201
int m_reductionTarget
Number of targeted points for reduction.
Definition: UosIO.hpp:236
int m_lastScan
The last scan to read (or -1 if all scans should be processed)
Definition: UosIO.hpp:224
std::string to_string(const int &t)
Definition: UosIO.hpp:185
Base interface for all I/O related classes.
void saveRemission(bool yes)
Save remission (if present)
Definition: UosIO.hpp:143
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
An input class for laser scans in UOS 3d format.
Definition: UosIO.hpp:74
int m_firstScan
The first scan to read (or -1 if all scans should be processed)
Definition: UosIO.hpp:221
float rad(const float deg)
Definition: UosIO.hpp:202
BaseVector< float > Vec
bool m_saveToDisk
If true, the read point will not be stored in local memory.
Definition: UosIO.hpp:227
ofstream m_outputFile
Filestream to save reduced data.
Definition: UosIO.hpp:230
void save(string filename)
Definition: UosIO.hpp:130
void setFirstScan(int n)
Defines the first scan to read.
Definition: UosIO.hpp:105


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:09