ccSensor.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //##########################################################################
  2. //# #
  3. //# CLOUDCOMPARE #
  4. //# #
  5. //# This program is free software; you can redistribute it and/or modify #
  6. //# it under the terms of the GNU General Public License as published by #
  7. //# the Free Software Foundation; version 2 or later of the License. #
  8. //# #
  9. //# This program is distributed in the hope that it will be useful, #
  10. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  11. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  12. //# GNU General Public License for more details. #
  13. //# #
  14. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  15. //# #
  16. //##########################################################################
  17. #ifndef CC_SENSOR_HEADER
  18. #define CC_SENSOR_HEADER
  19. //Local
  20. #include "ccIndexedTransformationBuffer.h"
  21. //! Sensor types
  22. enum CC_SENSOR_TYPE { UNKNOWN_SENSOR,
  23. GROUND_BASED_LIDAR,
  24. };
  25. //! Generic sensor interface
  26. /** New sensor framework now relies on separate positions (stored
  27. in a buffer) as generated by a GPS/IMU. This way, sensor objects
  28. only contains intrinsic parameters. They are also associated
  29. to a 'rigid transformation' (e.g. a rigid mechanical link between
  30. the sensor 'optical' center and the GPS/IMU center position).
  31. **/
  32. class QCC_DB_LIB_API ccSensor : public ccHObject
  33. {
  34. public:
  35. //! Default constructor
  36. ccSensor(const QString& name);
  37. //! Copy constructor
  38. ccSensor(const ccSensor& sensor);
  39. //! Destructor
  40. ~ccSensor() override;
  41. //inherited from ccHObject
  42. CC_CLASS_ENUM getClassID() const override { return CC_TYPES::SENSOR; }
  43. bool isSerializable() const override { return true; }
  44. //! Returns the sensor type
  45. /** Should be re-implemented by sub-classes
  46. \return the sensor type
  47. **/
  48. virtual CC_SENSOR_TYPE getType() const { return UNKNOWN_SENSOR; }
  49. //! Returns the "visibility type" of a point
  50. /** Precise definition of point's visibility can be found in Daniel Girardeau-Montaut's
  51. PhD manuscript (Chapter 2, section 2-3-3). In fact it can be anything, assuming that
  52. a point that is not POINT_VISIBLE won't be compared during a point-to-cloud distance
  53. computation process.
  54. \deprecated This method is deprecated and should be ignored.
  55. \param P a 3D point
  56. \return the visibility of the point
  57. **/
  58. virtual inline unsigned char checkVisibility(const CCVector3& P) const { return CCCoreLib::POINT_VISIBLE; }
  59. //! Returns associated positions
  60. ccIndexedTransformationBuffer* getPositions() { return m_posBuffer; }
  61. //! Returns associated positions
  62. const ccIndexedTransformationBuffer* getPositions() const { return m_posBuffer; }
  63. //! Sets associated positions
  64. void setPositions(ccIndexedTransformationBuffer* positions) { m_posBuffer = positions; }
  65. //! Adds a new position (shortcut)
  66. /** \warning may be slow as this method may sort the positions
  67. after each call (if the new index is lower than the last one pushed)
  68. **/
  69. bool addPosition(ccGLMatrix& trans, double index);
  70. //! Returns the absolute transformation between the world and the "optical" center (shortcut)
  71. /** Absolute transformation corresponds to the rigid transformation
  72. multiplied by the associated transformation interpolated at the given index.
  73. **/
  74. bool getAbsoluteTransformation(ccIndexedTransformation& trans, double index) const;
  75. //! Gets currently active absolute transformation
  76. bool getActiveAbsoluteTransformation(ccIndexedTransformation& trans) const;
  77. //! Gets currently active absolute position
  78. bool getActiveAbsoluteCenter(CCVector3& vec) const;
  79. //! Gets currently active rotation matrix (without translation)
  80. bool getActiveAbsoluteRotation(ccGLMatrix& rotation) const;
  81. //! Sets the rigid transformation between this sensor and its associated positions
  82. /** Rigid transformation goes from the sensor position(s) to the sensor "optical" center.
  83. **/
  84. virtual void setRigidTransformation(const ccGLMatrix& mat) { m_rigidTransformation = mat; }
  85. //! Returns the rigid transformation between this sensor and its associated positions
  86. virtual ccGLMatrix& getRigidTransformation() { return m_rigidTransformation; }
  87. //! Returns the rigid transformation between this sensor and its associated positions (const version)
  88. virtual const ccGLMatrix& getRigidTransformation() const { return m_rigidTransformation; }
  89. //! Gets index boundaries (shortcut)
  90. void getIndexBounds(double& minIndex, double& maxIndex) const;
  91. //! Sets currently active index (displayed position, etc.)
  92. double getActiveIndex() const { return m_activeIndex; }
  93. //! Sets currently active index (displayed position, etc.)
  94. void setActiveIndex(double index) { m_activeIndex = index; }
  95. //! Sets the sensor graphic representation scale
  96. void setGraphicScale(PointCoordinateType scale) { m_scale = scale; }
  97. //! Returns the sensor graphic representation scale
  98. PointCoordinateType getGraphicScale() const { return m_scale; }
  99. //! Apply sensor 'viewport' to a 3D view
  100. /** \param win 3D view to which to apply the sensor viewport (or the associated 'display' if 0)
  101. \return success
  102. **/
  103. virtual bool applyViewport(ccGenericGLDisplay* win = nullptr) const;
  104. //inherited from ccHObject
  105. void applyGLTransformation(const ccGLMatrix& trans) override;
  106. protected:
  107. //inherited from ccHObject
  108. bool toFile_MeOnly(QFile& out, short dataVersion) const override;
  109. bool fromFile_MeOnly(QFile& in, short dataVersion, int flags, LoadedIDMap& oldToNewIDMap) override;
  110. short minimumFileVersion_MeOnly() const override;
  111. //! Positions buffer (optional)
  112. ccIndexedTransformationBuffer* m_posBuffer;
  113. //! Rigid transformation between this sensor and its associated positions
  114. /** The transformation goes from the sensor position(s) to the sensor "optical" center.
  115. **/
  116. ccGLMatrix m_rigidTransformation;
  117. //! Active index (for displayed position, etc.)
  118. double m_activeIndex;
  119. //! Color of the sensor
  120. /** Default color is green.
  121. **/
  122. ccColor::Rgb m_color;
  123. //! Sensor graphic representation scale
  124. PointCoordinateType m_scale;
  125. };
  126. #endif //CC_SENSOR_HEADER