Scan.hpp
Go to the documentation of this file.
1 //
2 // Scan.hpp
3 //
4 // A simple data structure for scan data.
5 //
6 
7 #ifndef SCAN_HPP
8 #define SCAN_HPP
9 
10 #include <vector>
11 #include "ScannerInfo.hpp"
12 #include "ScanPoint.hpp"
13 #include "../BasicDatatypes.hpp"
14 
15 namespace datatypes
16 {
17 
18 //
19 // Sehr einfacher Container fuer Scandaten.
20 //
21 // Ein Objekt dieser Klasse repraesentiert einen Einzelscan eines
22 // Laserscanners.
23 //
24 class Scan : public BasicData
25 {
26 public:
27  // Type of the scan point list
28  typedef std::vector<ScanPoint> PointList;
29 
30  // Type of the scan point list
31  typedef std::vector<ScannerInfo> ScannerInfoVector;
32 
33  // Type of a reference to an element
34  typedef ScanPoint& reference;
35 
37  typedef const ScanPoint& const_reference;
38 
39  // Type of container size
40  typedef PointList::size_type size_type;
41 
42  // Type of constant iterator
43  typedef PointList::const_iterator const_iterator;
44 
45  // Type of iterator
46  typedef PointList::iterator iterator;
47 
48  // Property flags
49  enum ScanFlags
50  {
51  FlagVehicleCoordinates = 0x00000800
52  };
53 
54  // Estimate the memory usage of this object
55  virtual const UINT32 getUsedMemory() const;
56 
57 protected:
58  // Properties of this scan.
59  // See ScanFlags for a list of available property flags.
61 
62  // Consecutive scan number
64 
65  // The list of scan points
66  //
67  // At Scan creation, enough points are reserved in this vector in
68  // order to avoid memory re-allocations during runtime. This is
69  // now all handled by std::vector<> directly.
70  PointList m_points;
71 
73  ScannerInfoVector m_scannerInfos;
74 
75  // WATCH OUT: If you add more member variables here, you MUST also
76  // adapt the method Scan::copy(), addScan() and add the variables there.
77 
78  // ////////////////////////////////////////////////////////////
79 
80 public:
81 
82  // Constructor
83  Scan (size_type maxPoints = 5280); // 5280 = Maxpoints with 1/8deg resolution, for 50- -60deg
84 
87  Scan (const Scan&);
88 
89  // Copy the given right hand side object into this object. An
90  // alias for copy().
91  Scan& operator= (const Scan&);
92 
93  // Copy the given right hand side object into this object.
94  Scan& copy(const Scan&);
95 
97  ~Scan();
98 
100  void clear ();
101 
102 
103  // Equality predicate
104 // bool operator==(const Scan& other) const;
105 
106  // Returns the number of points in this scan. The same number can be retrieved by size().
107  UINT16 getNumPoints() const { return size(); }
108 
109  // Returns the number of points in the scan. An alias for getNumPoints().
110  size_type size() const { return m_points.size(); }
111 
112  // Returns true if this scan contains no points.
113  bool empty() const { return m_points.empty(); }
114 
130  void resize(size_type new_size, const ScanPoint& default_point = ScanPoint());
131 
132  // Returns the size of the memory (in number of points) allocated.
133  //
134  // Note: This is probably not the number of currently available
135  // scan points! See size() or getNumPoints() for this.
136  //
137  size_type capacity() const { return m_points.capacity(); }
138 
147  void reserve(size_type new_capacity);
148 
149 
150 
151  // Returns the consecutive number of this scan.
152  // Intended to detect missing scans.
154 
155  // Set the consecutive number of this scan.
156  void setScanNumber (UINT16 val) { m_scanNumber = val; }
157 
158 
159  // Returns the total size of the current scan object, in [bytes]. This value is the actual memory
160  // usage, including all sub-structures. Intended usage: Find out how much memory will be used when
161  // storing this object in a buffer.
162  //
163  // Note that the returned value is an estimation that may not match up to the last byte...
165 
166  // Returns all property flags of this scan in one number
167  // isGroundLabeled(), isDirtLabeled(), isRainLabeled() etc.
168  UINT32 getFlags() const { return m_flags; }
169 
170  // Returns true if the ground detection ran on this scan.
171 // bool isGroundLabeled() const { return ((m_flags & FlagGroundLabeled) != 0); }
172 
173  // Returns true if the dirt detection ran on this scan.
174 // bool isDirtLabeled() const { return ((m_flags & FlagDirtLabeled) != 0); }
175 
176  // Returns true if the background detection ran on this scan.
177 // bool isBackgroundLabeled() const { return ((m_flags & FlagBackgroundLabeled) != 0); }
178 
179  // Returns true if the scan points are given in vehicle coordinates, or false if the scan points are given in the Laserscanner coordinate system.
180 // bool isVehicleCoordinates() const { return ((m_flags & FlagVehicleCoordinates) != 0); }
181 
182  // Set all flags in one number
183  void setFlags (UINT32 val) { m_flags = val; }
184 
185  // Clears the given processing flag in the scan.
186  //
187  // Note: This only changes the flags of the Scan object, not the
188  // flags in the individual scan points! The flags in the
189  // individual points are unchanged and must be modified in a
190  // manual iteration loop.
191  void clearLabelFlag(Scan::ScanFlags scanFlag);
192 
193 // void setGroundLabeled(bool isGroundLabeled = true); ///< Set the Scan has ground labeled.
194 // void setDirtLabeled(bool isDirtLabeled = true); ///< Set the Scan has dirt labeled.
195 // void setRainLabeled(bool isRainLabeled = true); ///< Set the Scan has rain labeled.
196 // void setCoverageLabeled(bool isCoverageLabeled = true); ///< Set the Scan has coverage labeled.
197 // void setBackgroundLabeled(bool isBackgroundLabeled = true); ///< Set the Scan has background labeled.
198 // void setReflectorLabeled(bool isReflectorLabeled = true); ///< Set the Scan has reflector labeled.
199 
201  void setVehicleCoordinates(bool inVehicleCoordinates);
202 
203 
204  // Returns the list of scan points (read only)
205  const PointList& getPointList() const { return m_points; }
206  // Returns the list of scan points (read/write)
207  PointList& getPointList() { return m_points; }
208 
209  // Returns the iterator of the first scan point (read only)
210  PointList::const_iterator getPointListBegin() const { return m_points.begin(); }
211  // Returns the iterator of the first scan point (read/write)
212  PointList::iterator getPointListBegin() { return m_points.begin(); }
213 
214  // Returns the iterator of one behind the last scan point (read only)
215  PointList::const_iterator getPointListEnd() const { return m_points.end(); }
216 
217  // Returns the iterator of one behind the last scan point (read/write)
218  PointList::iterator getPointListEnd() { return m_points.end(); }
219 
220  // Returns the iterator of the first scan point (read only)
221  const_iterator begin() const { return m_points.begin(); }
222 
223  // Returns the iterator of the first scan point (read/write)
224  iterator begin() { return m_points.begin(); }
225 
226  // Returns the iterator of one behind the last scan point (read only)
227  const_iterator end() const { return m_points.end(); }
228 
229  // Returns the iterator of one behind the last scan point (read/write)
230  iterator end() { return m_points.end(); }
231 
232  // Returns the n-th scan point (read/write). No range checking to avoid runtime costs.
233  reference operator[](size_type n) { return m_points[n]; }
234 
235  // Returns the n-th scan point (read only). No range checking to avoid runtime costs.
236  const_reference operator[](size_type n) const { return m_points[n]; }
237 
238  // Returns the n-th scan point (read/write) with range checking.
239  reference at(size_type n) { return m_points.at(n); }
240 
242  const_reference at(size_type n) const { return m_points.at(n); }
243 
244  // Returns the n-th scan point (read only). No range checking to avoid runtime costs.
245  const ScanPoint& getPoint (UINT16 n) const { return m_points[n]; }
246  // Returns the n-th scan point (read/write). No range checking to avoid runtime costs.
247  ScanPoint& getPoint (UINT16 n) { return m_points[n]; }
248 
249  // Adds a new point to the list of scan points
251 
252 
253  // Returns the ScannerInfo collection.
254  //
255  // If this Scan contains points on 8 Layers (because of the
256  // interlaced fusion of an 8-Layer scanner), the returned list
257  // contains two ScannerInfo objects with the same deviceID. In all
258  // other cases there will be only one ScannerInfo object for each
259  // deviceID.
260  //
261  const ScannerInfoVector& getScannerInfos() const { return m_scannerInfos; }
262  ScannerInfoVector& getScannerInfos();
263  const ScannerInfo* getScannerInfoByDeviceId(UINT8 id) const;
264 
265  // Sets the ScannerInfo collection.
266  void setScannerInfos(const ScannerInfoVector& v);
267 
268 
269  //
270  // Sorts the scan points of this scan by angle in descending
271  // order. (Angles from high to low.)
272  //
273  // The first scan point will be the one with the largest
274  // (leftmost) angle. The last scan point will be the one with
275  // smallest (rightmost) angle, most probably a negative value.
276  //
277  // (Is used for the scan fusion.)
278  //
279  void sort();
280 
281 
282  //
283  // Coordinate system transformations
284  //
285 
286  void addCartesianOffset(double offsetX, double offsetY, double offsetZ);
287  void addPolarOffset(double distOffset, double hAngleOffset, double vAngleOffset);
288 
289 
291 
304 
306 
317 
318 
319 private:
320 
322 };
323 
324 } // namespace datatypes
325 
326 
327 #endif // SCAN_HPP
void clear()
Resets all members of this object.
Definition: Scan.cpp:133
iterator begin()
Definition: Scan.hpp:224
UINT32 getFlags() const
Definition: Scan.hpp:168
const_iterator end() const
Definition: Scan.hpp:227
ScannerInfoVector m_scannerInfos
The ScannerInfo collection.
Definition: Scan.hpp:73
virtual const UINT32 getUsedMemory() const
Definition: Scan.cpp:44
bool m_beVerbose
Definition: Scan.hpp:321
void setVehicleCoordinates(bool inVehicleCoordinates)
Set whether the scanpoints are given in vehicle coordinates.
Definition: Scan.cpp:179
reference at(size_type n)
Definition: Scan.hpp:239
const ScanPoint & const_reference
Type of a const reference to an element.
Definition: Scan.hpp:37
size_type size() const
Definition: Scan.hpp:110
PointList::size_type size_type
Definition: Scan.hpp:40
uint16_t UINT16
bool empty() const
Definition: Scan.hpp:113
PointList::const_iterator getPointListEnd() const
Definition: Scan.hpp:215
Scan(size_type maxPoints=5280)
Definition: Scan.cpp:26
const ScanPoint & getPoint(UINT16 n) const
Definition: Scan.hpp:245
bool transformToVehicleCoordinates()
Transforms this scan (i.e. the scan points) to the vehicle coordinates.
Definition: Scan.cpp:343
size_type capacity() const
Definition: Scan.hpp:137
uint32_t UINT32
void setScannerInfos(const ScannerInfoVector &v)
Definition: Scan.cpp:212
const_reference operator[](size_type n) const
Definition: Scan.hpp:236
void reserve(size_type new_capacity)
Allocates memory for a total of new_capacity points.
Definition: Scan.cpp:159
PointList & getPointList()
Definition: Scan.hpp:207
UINT32 m_flags
Definition: Scan.hpp:60
UINT16 getNumPoints() const
Definition: Scan.hpp:107
UINT16 getScanNumber() const
Definition: Scan.hpp:153
UINT16 m_scanNumber
Definition: Scan.hpp:63
ScanPoint & addNewPoint()
Definition: Scan.cpp:173
PointList::iterator getPointListBegin()
Definition: Scan.hpp:212
const ScannerInfoVector & getScannerInfos() const
Definition: Scan.hpp:261
std::vector< ScanPoint > PointList
Definition: Scan.hpp:28
PointList::const_iterator getPointListBegin() const
Definition: Scan.hpp:210
void addPolarOffset(double distOffset, double hAngleOffset, double vAngleOffset)
Definition: Scan.cpp:206
iterator end()
Definition: Scan.hpp:230
void setScanNumber(UINT16 val)
Definition: Scan.hpp:156
PointList::iterator iterator
Definition: Scan.hpp:46
const ScannerInfo * getScannerInfoByDeviceId(UINT8 id) const
Definition: Scan.cpp:360
const_iterator begin() const
Definition: Scan.hpp:221
Scan & copy(const Scan &)
Definition: Scan.cpp:52
void resize(size_type new_size, const ScanPoint &default_point=ScanPoint())
Resizes the scan to the specified number of points.
Definition: Scan.cpp:149
std::vector< ScannerInfo > ScannerInfoVector
Definition: Scan.hpp:31
PointList::const_iterator const_iterator
Definition: Scan.hpp:43
void addCartesianOffset(double offsetX, double offsetY, double offsetZ)
Definition: Scan.cpp:200
void clearLabelFlag(Scan::ScanFlags scanFlag)
Definition: Scan.cpp:373
ScanPoint & getPoint(UINT16 n)
Definition: Scan.hpp:247
const_reference at(size_type n) const
Returns the n-th scan point (read only) with range checking.
Definition: Scan.hpp:242
UINT32 getTotalObjectSize()
Definition: Scan.cpp:86
PointList m_points
Definition: Scan.hpp:70
reference operator[](size_type n)
Definition: Scan.hpp:233
~Scan()
Default destructor.
Definition: Scan.cpp:145
void setFlags(UINT32 val)
Definition: Scan.hpp:183
ScanPoint & reference
Definition: Scan.hpp:34
Bit 11: Scanpoint coordinate system; 0 = scanner coordinates, 1 = vehicle / reference coordinates...
Definition: Scan.hpp:51
void sort()
Definition: Scan.cpp:195
Scan & operator=(const Scan &)
Definition: Scan.cpp:97
PointList::iterator getPointListEnd()
Definition: Scan.hpp:218
bool transformToVehicleCoordinatesUnsorted()
Transforms this scan (i.e. the scan points) to the vehicle coordinates.
Definition: Scan.cpp:299
uint8_t UINT8
const PointList & getPointList() const
Definition: Scan.hpp:205


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Mon Oct 26 2020 03:27:30