ccIndexedTransformation.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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_INDEXED_TRANSFORMATION_HEADER
  18. #define CC_INDEXED_TRANSFORMATION_HEADER
  19. //Local
  20. #include "ccGLMatrix.h"
  21. //! A 4x4 'transformation' matrix (column major order) associated to an index (typically a timestamp)
  22. class QCC_DB_LIB_API ccIndexedTransformation : public ccGLMatrix
  23. {
  24. public:
  25. //! Default constructor
  26. /** Matrix is set to identity (see ccGLMatrix::toIdentity) by default.
  27. Index is set to zero by default.
  28. **/
  29. ccIndexedTransformation();
  30. //! Constructor from a transformation matrix
  31. /** Index is set to zero by default.
  32. \param matrix transformation matrix
  33. **/
  34. ccIndexedTransformation(const ccGLMatrix& matrix);
  35. //! Constructor from a transformation matrix and an index
  36. /** \param matrix transformation matrix
  37. \param index associated index (e.g. timestamp)
  38. **/
  39. ccIndexedTransformation(const ccGLMatrix& matrix, double index);
  40. //! Copy constructor
  41. ccIndexedTransformation(const ccIndexedTransformation& trans) = default;
  42. //! Returns associated index (e.g. timestamp)
  43. inline double getIndex() const { return m_index; }
  44. //! Sets associated index (e.g. timestamp)
  45. inline void setIndex(double index) { m_index = index; }
  46. //! Interpolates two transformations at an absolute position (index)
  47. /** Warning: interpolation index must lie between the two input matrices indexes!
  48. \param interpIndex interpolation position (should be between trans1 and trans2 indexes).
  49. \param trans1 first transformation
  50. \param trans2 second transformation
  51. **/
  52. static ccIndexedTransformation Interpolate(double interpIndex, const ccIndexedTransformation& trans1, const ccIndexedTransformation& trans2);
  53. //! Multiplication by a ccGLMatrix operator
  54. ccIndexedTransformation operator * (const ccGLMatrix& mat) const;
  55. //! (in place) Multiplication by a ccGLMatrix operator
  56. /** Warning: index is not modified by this operation.
  57. **/
  58. ccIndexedTransformation& operator *= (const ccGLMatrix& mat);
  59. //! Multiplication operator
  60. //ccIndexedTransformation operator * (const ccIndexedTransformation& mat) const;
  61. //! (in place) Multiplication operator
  62. /** Warning: index is not modified by this operation.
  63. **/
  64. //ccIndexedTransformation& operator *= (const ccIndexedTransformation& trans)
  65. //! (in place) Translation operator
  66. /** Warning: index is not modified by this operation.
  67. **/
  68. ccIndexedTransformation& operator += (const CCVector3& T);
  69. //! (in place) Translation operator
  70. /** Warning: index is not modified by this operation.
  71. **/
  72. ccIndexedTransformation& operator -= (const CCVector3& T);
  73. //! Returns transposed transformation
  74. /** Warning: index is not modified by this operation.
  75. **/
  76. ccIndexedTransformation transposed() const;
  77. //! Returns inverse transformation
  78. /** Warning: index is not modified by this operation.
  79. **/
  80. ccIndexedTransformation inverse() const;
  81. //inherited from ccGLMatrix
  82. bool toAsciiFile(QString filename, int precision = 12) const override;
  83. bool fromAsciiFile(QString filename) override;
  84. //inherited from ccSerializableObject
  85. bool isSerializable() const override { return true; }
  86. bool toFile(QFile& out, short dataVersion) const override;
  87. bool fromFile(QFile& in, short dataVersion, int flags, LoadedIDMap& oldToNewIDMap) override;
  88. short minimumFileVersion() const override;
  89. protected:
  90. //! Associated index (e.g. timestamp)
  91. double m_index;
  92. };
  93. #endif //CC_INDEXED_TRANSFORMATION_HEADER