ccCone.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #pragma once
  2. //##########################################################################
  3. //# #
  4. //# CLOUDCOMPARE #
  5. //# #
  6. //# This program is free software; you can redistribute it and/or modify #
  7. //# it under the terms of the GNU General Public License as published by #
  8. //# the Free Software Foundation; version 2 or later of the License. #
  9. //# #
  10. //# This program is distributed in the hope that it will be useful, #
  11. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  12. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  13. //# GNU General Public License for more details. #
  14. //# #
  15. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  16. //# #
  17. //##########################################################################
  18. //Local
  19. #include "ccGenericPrimitive.h"
  20. //! Cone (primitive)
  21. /** 3D cone primitive
  22. **/
  23. class QCC_DB_LIB_API ccCone : public ccGenericPrimitive
  24. {
  25. public:
  26. //! Default drawing precision
  27. /** \warning Never pass a 'constant initializer' by reference
  28. **/
  29. static const unsigned DEFAULT_DRAWING_PRECISION = 24;
  30. //! Default constructor
  31. /** Cone axis corresponds to the 'Z' dimension by default
  32. \param bottomRadius cone bottom radius
  33. \param topRadius cone top radius
  34. \param height cone height (transformation should point to the axis center)
  35. \param xOff displacement of axes along X-axis (Snout mode)
  36. \param yOff displacement of axes along Y-axis (Snout mode)
  37. \param transMat optional 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)
  38. \param name name
  39. \param precision drawing precision (angular step = 360/precision)
  40. \param uniqueID unique ID (handle with care)
  41. **/
  42. ccCone( PointCoordinateType bottomRadius,
  43. PointCoordinateType topRadius,
  44. PointCoordinateType height,
  45. PointCoordinateType xOff = 0,
  46. PointCoordinateType yOff = 0,
  47. const ccGLMatrix* transMat = nullptr,
  48. QString name = QString("Cone"),
  49. unsigned precision = DEFAULT_DRAWING_PRECISION,
  50. unsigned uniqueID = ccUniqueIDGenerator::InvalidUniqueID);
  51. //! Simplified constructor
  52. /** For ccHObject factory only!
  53. **/
  54. ccCone(QString name = QString("Cone"));
  55. //! Returns class ID
  56. virtual CC_CLASS_ENUM getClassID() const override { return CC_TYPES::CONE; }
  57. //! Returns height
  58. inline PointCoordinateType getHeight() const { return m_height; }
  59. //! Sets height
  60. /** \warning changes primitive content (calls ccGenericPrimitive::updateRepresentation)
  61. **/
  62. void setHeight(PointCoordinateType height);
  63. //! Returns bottom radius
  64. inline PointCoordinateType getBottomRadius() const { return m_bottomRadius; }
  65. //! Sets bottom radius
  66. /** \warning changes primitive content (calls ccGenericPrimitive::updateRepresentation)
  67. **/
  68. virtual void setBottomRadius(PointCoordinateType radius);
  69. //! Returns top radius
  70. inline PointCoordinateType getTopRadius() const { return m_topRadius; }
  71. //! Sets top radius
  72. /** \warning changes primitive content (calls ccGenericPrimitive::updateRepresentation)
  73. **/
  74. virtual void setTopRadius(PointCoordinateType radius);
  75. //! Returns cone axis bottom end point after applying transformation
  76. virtual CCVector3 getBottomCenter() const;
  77. //! Returns cone axis top end point after applying transformation
  78. virtual CCVector3 getTopCenter() const;
  79. //! Returns cone axis end point associated with whichever radii is smaller
  80. virtual CCVector3 getSmallCenter() const;
  81. //! Returns cone axis end point associated with whichever radii is larger
  82. virtual CCVector3 getLargeCenter() const;
  83. //! Returns whichever cone radii is smaller
  84. virtual PointCoordinateType getSmallRadius() const;
  85. //! Returns whichever cone radii is larger
  86. virtual PointCoordinateType getLargeRadius() const;
  87. //! Returns true if the Cone was created in snout mode
  88. virtual bool isSnoutMode() const { return (m_xOff != 0 || m_yOff != 0); }
  89. //inherited from ccGenericPrimitive
  90. virtual QString getTypeName() const override { return "Cone"; }
  91. virtual bool hasDrawingPrecision() const override { return true; }
  92. virtual ccGenericPrimitive* clone() const override;
  93. //! Computes the cone apex position
  94. CCVector3 computeApex() const;
  95. //! Computes the cone half angle (in degrees)
  96. double computeHalfAngle_deg() const;
  97. protected:
  98. //inherited from ccGenericPrimitive
  99. bool toFile_MeOnly(QFile& out, short dataVersion) const override;
  100. bool fromFile_MeOnly(QFile& in, short dataVersion, int flags, LoadedIDMap& oldToNewIDMap) override;
  101. short minimumFileVersion_MeOnly() const override;
  102. bool buildUp() override;
  103. //! Bottom radius
  104. PointCoordinateType m_bottomRadius;
  105. //! Top radius
  106. PointCoordinateType m_topRadius;
  107. //! Displacement of axes along X-axis (Snout mode)
  108. PointCoordinateType m_xOff;
  109. //! Displacement of axes along Y-axis (Snout mode)
  110. PointCoordinateType m_yOff;
  111. //! Height
  112. PointCoordinateType m_height;
  113. };