ccTorus.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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_TORUS_PRIMITIVE_HEADER
  18. #define CC_TORUS_PRIMITIVE_HEADER
  19. //Local
  20. #include "ccGenericPrimitive.h"
  21. //! Torus (primitive)
  22. /** 3D torus primitive (with circular or rectangular section)
  23. **/
  24. class QCC_DB_LIB_API ccTorus : public ccGenericPrimitive
  25. {
  26. public:
  27. //! Default drawing precision
  28. /** \warning Never pass a 'constant initializer' by reference
  29. **/
  30. static const unsigned DEFAULT_DRAWING_PRECISION = 24;
  31. //! Default constructor
  32. /** Torus is defined in the XY plane by default
  33. \param insideRadius inside radius
  34. \param outsideRadius outside radius
  35. \param angle_rad subtended angle (in radians)
  36. \param rectangularSection whether section is rectangular or round
  37. \param rectSectionHeight section height (if rectangular torus)
  38. \param transMat optional 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)
  39. \param name name
  40. \param precision drawing precision (main loop angular step = 360/(4*precision), circular section angular step = 360/precision)
  41. \param uniqueID unique ID (handle with care)
  42. **/
  43. ccTorus(PointCoordinateType insideRadius,
  44. PointCoordinateType outsideRadius,
  45. double angle_rad = 2.0*M_PI,
  46. bool rectangularSection = false,
  47. PointCoordinateType rectSectionHeight = 0,
  48. const ccGLMatrix* transMat = nullptr,
  49. QString name = QString("Torus"),
  50. unsigned precision = DEFAULT_DRAWING_PRECISION,
  51. unsigned uniqueID = ccUniqueIDGenerator::InvalidUniqueID);
  52. //! Simplified constructor
  53. /** For ccHObject factory only!
  54. **/
  55. ccTorus(QString name = QString("Torus"));
  56. //! Returns class ID
  57. CC_CLASS_ENUM getClassID() const override { return CC_TYPES::TORUS; }
  58. //inherited from ccGenericPrimitive
  59. QString getTypeName() const override { return "Torus"; }
  60. bool hasDrawingPrecision() const override { return true; }
  61. ccGenericPrimitive* clone() const override;
  62. protected:
  63. //inherited from ccGenericPrimitive
  64. bool toFile_MeOnly(QFile& out, short dataVersion) const override;
  65. bool fromFile_MeOnly(QFile& in, short dataVersion, int flags, LoadedIDMap& oldToNewIDMap) override;
  66. short minimumFileVersion_MeOnly() const override;
  67. bool buildUp() override;
  68. //! Inside radius
  69. PointCoordinateType m_insideRadius;
  70. //! Outside radius
  71. PointCoordinateType m_outsideRadius;
  72. //! Whether torus has a rectangular (true) or circular (false) section
  73. bool m_rectSection;
  74. //! Rectangular section height (along Y-axis) if applicable
  75. PointCoordinateType m_rectSectionHeight;
  76. //! Subtended angle (in radians)
  77. double m_angle_rad;
  78. };
  79. #endif //CC_TORUS_PRIMITIVE_HEADER