ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvGBLSensor.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "LineSet.h"
12 #include "ecvDepthBuffer.h"
13 #include "ecvOrientedBBox.h"
14 #include "ecvSensor.h"
15 
16 // CV_CORE_LIB
17 #include <GenericCloud.h>
18 
19 class ccPointCloud;
20 
22 
27 public:
29 
33  enum ROTATION_ORDER { YAW_THEN_PITCH = 0, PITCH_THEN_YAW = 1 };
34 
36 
38  explicit ccGBLSensor(ROTATION_ORDER rotOrder = YAW_THEN_PITCH);
39 
41 
44  ccGBLSensor(const ccGBLSensor& sensor);
45 
47  ~ccGBLSensor() override = default;
48 
49  // inherited from ccHObject
50  CV_CLASS_ENUM getClassID() const override { return CV_TYPES::GBL_SENSOR; }
51  bool isSerializable() const override { return true; }
52  ccBBox getOwnBB(bool withGLFeatures = false) override;
53  ccBBox getOwnFitBB(ccGLMatrix& trans) override;
54 
55  virtual void clearDrawings() override;
56  virtual void hideShowDrawings(CC_DRAW_CONTEXT& context) override;
57 
58  // inherited from ccSensor
59  bool applyViewport() override;
60 
63 
73  unsigned char checkVisibility(const CCVector3& P) const override;
74 
76 
79 
81 
84  static QString GetErrorString(int errorCode);
85 
86 public: // setters and getters
88 
92 
94  inline PointCoordinateType getMinPitch() const { return m_phiMin; }
95 
97  inline PointCoordinateType getMaxPitch() const { return m_phiMax; }
98 
100 
103 
105  inline PointCoordinateType getPitchStep() const { return m_deltaPhi; }
106 
109  bool pitchIsShifted() const { return m_pitchAnglesAreShifted; }
110 
112 
116  PointCoordinateType maxTheta);
117 
119  inline PointCoordinateType getMinYaw() const { return m_thetaMin; }
120 
122  inline PointCoordinateType getMaxYaw() const { return m_thetaMax; }
123 
125 
128 
130  inline PointCoordinateType getYawStep() const { return m_deltaTheta; }
131 
134  bool yawIsShifted() const { return m_yawAnglesAreShifted; }
135 
137  inline PointCoordinateType getSensorRange() const { return m_sensorRange; }
138 
140 
142  inline void setSensorRange(PointCoordinateType range) {
143  m_sensorRange = range;
144  }
145 
147  inline PointCoordinateType getUncertainty() const { return m_uncertainty; }
148 
150 
153  inline void setUncertainty(PointCoordinateType u) { m_uncertainty = u; }
154 
156  ROTATION_ORDER getRotationOrder() const { return m_rotationOrder; }
157 
159 
161  inline void setRotationOrder(ROTATION_ORDER rotOrder) {
162  m_rotationOrder = rotOrder;
163  }
164 
165 public: // projection tools
167 
174  void projectPoint(const CCVector3& sourcePoint,
175  CCVector2& destPoint,
176  PointCoordinateType& depth,
177  double posIndex = 0) const;
178 
180  using NormalGrid = std::vector<CCVector3>;
181 
183 
191  const NormalGrid& norms,
192  double posIndex = 0) const;
193 
195  using ColorGrid = std::vector<ecvColor::Rgb>;
196 
199 
206  const ColorGrid& rgbColors) const;
207 
208 public: // depth buffer management
211 
218  int& errorCode,
219  ccPointCloud* projectedCloud = nullptr);
220 
222 
225  inline const ccDepthBuffer& getDepthBuffer() const { return m_depthBuffer; }
226 
229 
231  return m_leg;
232  }
234  return m_axis;
235  }
236  const ecvOrientedBBox& getSensorHead() const { return m_obbHead; }
237 
238 protected:
239  // Inherited from ccHObject
240  bool toFile_MeOnly(QFile& out, short dataVersion) const override;
241  short minimumFileVersion_MeOnly() const override;
242  bool fromFile_MeOnly(QFile& in,
243  short dataVersion,
244  int flags,
245  LoadedIDMap& oldToNewIDMap) override;
247 
251  PointCoordinateType pitch,
252  unsigned& i,
253  unsigned& j) const;
254 
256 
259 
266 
268 
271 
278 
281 
286 
289 
293 };
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
#define CV_DB_LIB_API
Definition: CV_db.h:15
Bounding box structure.
Definition: ecvBBox.h:25
Sensor "depth map".
Ground-based Laser sensor.
Definition: ecvGBLSensor.h:26
void projectPoint(const CCVector3 &sourcePoint, CCVector2 &destPoint, PointCoordinateType &depth, double posIndex=0) const
Projects a point in the sensor world.
bool computeDepthBuffer(cloudViewer::GenericCloud *cloud, int &errorCode, ccPointCloud *projectedCloud=nullptr)
PointCoordinateType m_thetaMin
Minimal yaw limit (in radians)
Definition: ecvGBLSensor.h:269
void setRotationOrder(ROTATION_ORDER rotOrder)
Sets the sensor internal rotations order.
Definition: ecvGBLSensor.h:161
PointCoordinateType m_deltaTheta
Yaw step (in radians)
Definition: ecvGBLSensor.h:274
ColorGrid * projectColors(cloudViewer::GenericCloud *cloud, const ColorGrid &rgbColors) const
PointCoordinateType m_thetaMax
Maximal yaw limit (in radians)
Definition: ecvGBLSensor.h:272
ccBBox getOwnFitBB(ccGLMatrix &trans) override
Returns best-fit bounding-box (if available)
bool isSerializable() const override
Returns whether object is serializable of not.
Definition: ecvGBLSensor.h:51
virtual void clearDrawings() override
bool m_yawAnglesAreShifted
Definition: ecvGBLSensor.h:277
ROTATION_ORDER m_rotationOrder
Mirrors rotation order.
Definition: ecvGBLSensor.h:280
PointCoordinateType getMinPitch() const
Returns the minimal pitch limit (in radians)
Definition: ecvGBLSensor.h:94
virtual void hideShowDrawings(CC_DRAW_CONTEXT &context) override
ROTATION_ORDER
The order of inner-rotations of the sensor (body/mirrors)
Definition: ecvGBLSensor.h:33
PointCoordinateType m_phiMin
Minimal pitch limit (in radians)
Definition: ecvGBLSensor.h:257
PointCoordinateType m_deltaPhi
Pitch step (in radians)
Definition: ecvGBLSensor.h:262
PointCoordinateType getSensorRange() const
Returns the sensor max. range.
Definition: ecvGBLSensor.h:137
bool m_pitchAnglesAreShifted
Definition: ecvGBLSensor.h:265
PointCoordinateType getMinYaw() const
Returns the minimal yaw limit (in radians)
Definition: ecvGBLSensor.h:119
ccGBLSensor(const ccGBLSensor &sensor)
Copy constructor.
const ecvOrientedBBox & getSensorHead() const
Definition: ecvGBLSensor.h:236
CV_CLASS_ENUM getClassID() const override
Returns class ID.
Definition: ecvGBLSensor.h:50
void setYawRange(PointCoordinateType minTheta, PointCoordinateType maxTheta)
Sets the yaw scanning limits.
std::vector< CCVector3 > NormalGrid
2D grid of normals
Definition: ecvGBLSensor.h:180
bool convertToDepthMapCoords(PointCoordinateType yaw, PointCoordinateType pitch, unsigned &i, unsigned &j) const
const cloudViewer::geometry::LineSet & getSensorLegLines() const
Definition: ecvGBLSensor.h:230
void setUncertainty(PointCoordinateType u)
Sets the Z-buffer uncertainty on depth values.
Definition: ecvGBLSensor.h:153
ccGBLSensor(ROTATION_ORDER rotOrder=YAW_THEN_PITCH)
Default constructor.
PointCoordinateType getUncertainty() const
Returns the Z-buffer uncertainty on depth values.
Definition: ecvGBLSensor.h:147
~ccGBLSensor() override=default
Destructor.
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
void setPitchRange(PointCoordinateType minPhi, PointCoordinateType maxPhi)
Sets the pitch scanning limits.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
cloudViewer::geometry::LineSet m_leg
Definition: ecvGBLSensor.h:291
const cloudViewer::geometry::LineSet & getSensorAxis() const
Definition: ecvGBLSensor.h:233
bool computeAutoParameters(cloudViewer::GenericCloud *theCloud)
Computes angular parameters automatically (all but the angular steps!)
PointCoordinateType m_phiMax
Maximal pitch limit (in radians)
Definition: ecvGBLSensor.h:260
std::vector< ecvColor::Rgb > ColorGrid
2D grid of colors
Definition: ecvGBLSensor.h:195
void drawMeOnly(CC_DRAW_CONTEXT &context) override
Draws the entity only (not its children)
static QString GetErrorString(int errorCode)
Returns the error string corresponding to an error code.
bool yawIsShifted() const
Definition: ecvGBLSensor.h:134
const ccDepthBuffer & getDepthBuffer() const
Returns the associated depth buffer.
Definition: ecvGBLSensor.h:225
bool applyViewport() override
Apply sensor 'viewport' to a 3D view.
short minimumFileVersion_MeOnly() const override
ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
unsigned char checkVisibility(const CCVector3 &P) const override
NormalGrid * projectNormals(cloudViewer::GenericCloud *cloud, const NormalGrid &norms, double posIndex=0) const
Projects a set of point cloud normals in the sensor world.
void setSensorRange(PointCoordinateType range)
Sets the sensor max. range.
Definition: ecvGBLSensor.h:142
PointCoordinateType getPitchStep() const
Returns the lateral pitch step (in radians)
Definition: ecvGBLSensor.h:105
PointCoordinateType getMaxYaw() const
Returns the maximal yaw limit (in radians)
Definition: ecvGBLSensor.h:122
ccDepthBuffer m_depthBuffer
Associated Z-buffer.
Definition: ecvGBLSensor.h:288
void setYawStep(PointCoordinateType dTheta)
Sets the yaw step.
bool pitchIsShifted() const
Definition: ecvGBLSensor.h:109
ecvOrientedBBox m_obbHead
Definition: ecvGBLSensor.h:290
PointCoordinateType m_uncertainty
Z-buffer uncertainty.
Definition: ecvGBLSensor.h:285
PointCoordinateType m_sensorRange
Sensor max range.
Definition: ecvGBLSensor.h:283
ROTATION_ORDER getRotationOrder() const
Returns the sensor internal rotations order.
Definition: ecvGBLSensor.h:156
void clearDepthBuffer()
Removes the associated depth buffer.
cloudViewer::geometry::LineSet m_axis
Definition: ecvGBLSensor.h:292
PointCoordinateType getMaxPitch() const
Returns the maximal pitch limit (in radians)
Definition: ecvGBLSensor.h:97
PointCoordinateType getYawStep() const
Returns the yaw step (in radians)
Definition: ecvGBLSensor.h:130
void setPitchStep(PointCoordinateType dPhi)
Sets the pitch step.
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Generic sensor interface.
Definition: ecvSensor.h:27
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
LineSet define a sets of lines in 3D. A typical application is to display the point cloud corresponde...
Definition: LineSet.h:29
ImGuiContext * context
Definition: Window.cpp:76
@ GBL_SENSOR
Definition: CVTypes.h:117
Display context.