ccIndexedTransformationBuffer.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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_BUFFER_HEADER
  18. #define CC_INDEXED_TRANSFORMATION_BUFFER_HEADER
  19. //Local
  20. #include "ccHObject.h"
  21. #include "ccIndexedTransformation.h"
  22. //system
  23. #include <cfloat>
  24. //! Indexed Transformation buffer
  25. class QCC_DB_LIB_API ccIndexedTransformationBuffer : public ccHObject, public std::vector< ccIndexedTransformation >
  26. {
  27. public:
  28. //! Default constructor
  29. ccIndexedTransformationBuffer(const QString& name = QString("Trans. buffer"));
  30. //! Copy constructor
  31. ccIndexedTransformationBuffer(const ccIndexedTransformationBuffer& buffer);
  32. //inherited from ccHObject
  33. CC_CLASS_ENUM getClassID() const override { return CC_TYPES::TRANS_BUFFER; }
  34. bool isSerializable() const override { return true; }
  35. //! Sorts transformations based on their index
  36. /** Ascending sort.
  37. **/
  38. void sort();
  39. //! Returns the nearest indexed transformation(s) to a given index
  40. /** This method returns the preceding and following transformations.
  41. \warning Binary search: buffer must be sorted! (see ccIndexedTransformationBuffer::sort)
  42. \param index query index (e.g. timestamp)
  43. \param trans1 directly preceding transformation (if any - null otherwise)
  44. \param trans2 directly following transformation (if any - null otherwise)
  45. \param trans1IndexInBuffer (optional) index of trans1 in buffer
  46. \param trans2IndexInBuffer (optional) index of trans2 in buffer
  47. \return success
  48. **/
  49. bool findNearest(double index,
  50. const ccIndexedTransformation* &trans1,
  51. const ccIndexedTransformation* &trans2,
  52. size_t* trans1IndexInBuffer = nullptr,
  53. size_t* trans2IndexInBuffer = nullptr) const;
  54. //! Returns the indexed transformation at a given index (interpolates it if necessary)
  55. /** \warning Binary search: buffer must be sorted! (see ccIndexedTransformationBuffer::sort)
  56. \param index query index (e.g. timestamp)
  57. \param trans output transformation (if successful)
  58. \param maxIndexDistForInterpolation max 'distance' between query index and existing indexes to actually interpolate/output a transformation
  59. \return success
  60. **/
  61. bool getInterpolatedTransformation( double index,
  62. ccIndexedTransformation& trans,
  63. double maxIndexDistForInterpolation = DBL_MAX) const;
  64. //! [Display option] Returns whether trihedrons should be displayed or not (otherwise only points or a polyline)
  65. bool trihedronsShown() const { return m_showTrihedrons; }
  66. //! [Display option] Sets whether trihedrons should be displayed or not (otherwise only points or a polyline)
  67. void showTrihedrons(bool state) { m_showTrihedrons = state; }
  68. //! [Display option] Returns trihedron display size
  69. float trihedronsDisplayScale() const { return m_trihedronsScale; }
  70. //! [Display option] Sets trihedron display size
  71. void setTrihedronsDisplayScale(float scale) { m_trihedronsScale = scale; }
  72. //! [Display option] Returns whether the path should be displayed as a polyline or not (otherwise only points)
  73. bool isPathShownAsPolyline() const { return m_showAsPolyline; }
  74. //! [Display option] Sets whether the path should be displayed as a polyline or not (otherwise only points)
  75. void showPathAsPolyline(bool state) { m_showAsPolyline = state; }
  76. //! Invalidates the bounding box
  77. /** Should be called whenever the content of this structure changes!
  78. **/
  79. void invalidateBoundingBox();
  80. //Inherited from ccHObject
  81. ccBBox getOwnBB(bool withGLFeatures = false) override;
  82. protected:
  83. //inherited from ccHObject
  84. bool toFile_MeOnly(QFile& out, short dataVersion) const override;
  85. bool fromFile_MeOnly(QFile& in, short dataVersion, int flags, LoadedIDMap& oldToNewIDMap) override;
  86. short minimumFileVersion_MeOnly() const override;
  87. void drawMeOnly(CC_DRAW_CONTEXT& context) override;
  88. //! Bounding box
  89. ccBBox m_bBox;
  90. //! Bounding box last 'validity' size
  91. size_t m_bBoxValidSize;
  92. //! Whether the path should be displayed as a polyline or not
  93. bool m_showAsPolyline;
  94. //! Whether trihedrons should be displayed or not
  95. bool m_showTrihedrons;
  96. //! Trihedrons display scale
  97. float m_trihedronsScale;
  98. };
  99. #endif