ccHObjectCaster.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 "qCC_db.h"
  20. //System
  21. #include <vector>
  22. class cc2DLabel;
  23. class cc2DViewportLabel;
  24. class cc2DViewportObject;
  25. class ccCameraSensor;
  26. class ccCone;
  27. class ccCylinder;
  28. class ccDish;
  29. class ccExtru;
  30. class ccFacet;
  31. class ccGBLSensor;
  32. class ccGenericMesh;
  33. class ccGenericPointCloud;
  34. class ccGenericPrimitive;
  35. class ccHObject;
  36. class ccImage;
  37. class ccIndexedTransformationBuffer;
  38. class ccKdTree;
  39. class ccMesh;
  40. class ccOctree;
  41. class ccOctreeProxy;
  42. class ccPlanarEntityInterface;
  43. class ccPlane;
  44. class ccPointCloud;
  45. class ccPolyline;
  46. class ccSensor;
  47. class ccShiftedObject;
  48. class ccSphere;
  49. class ccSubMesh;
  50. class ccTorus;
  51. class ccCoordinateSystem;
  52. //! Useful class to (try to) statically cast a basic ccHObject to a given type
  53. class QCC_DB_LIB_API ccHObjectCaster
  54. {
  55. public:
  56. //! Converts current object to 'equivalent' ccPointCloud
  57. /** Warning: if a mesh is passed, this method returns its vertices.
  58. \param obj ccHObject to dynamically cast to a ccPointCloud object
  59. \param isLockedVertices the caller can be warned if the returned cloud corresponds to locked vertices
  60. **/
  61. static ccPointCloud* ToPointCloud(ccHObject* obj, bool* isLockedVertices = nullptr);
  62. //! Converts current object to 'equivalent' ccGenericPointCloud
  63. /** Warning: if a mesh is passed, this method returns its vertices.
  64. **/
  65. static ccGenericPointCloud* ToGenericPointCloud(ccHObject* obj, bool* isLockedVertices = nullptr);
  66. //! Converts current object to 'equivalent' ccShiftedObject
  67. /** Warning: if a mesh is passed, this method returns its vertices.
  68. **/
  69. static ccShiftedObject* ToShifted(ccHObject* obj, bool* isLockedVertices = nullptr);
  70. //! Converts current object to ccGenericMesh (if possible)
  71. static ccGenericMesh* ToGenericMesh(ccHObject* obj);
  72. //! Converts current object to ccMesh (if possible)
  73. static ccMesh* ToMesh(ccHObject* obj);
  74. //! Converts current object to ccSubMesh (if possible)
  75. static ccSubMesh* ToSubMesh(ccHObject* obj);
  76. //! Converts current object to ccPolyline (if possible)
  77. static ccPolyline* ToPolyline(ccHObject* obj);
  78. //! Converts current object to ccFacet (if possible)
  79. static ccFacet* ToFacet(ccHObject* obj);
  80. //! Converts current object to ccPlanarEntityInterface (if possible)
  81. static ccPlanarEntityInterface* ToPlanarEntity(ccHObject* obj);
  82. //! Converts current object to ccGenericPrimitive (if possible)
  83. static ccGenericPrimitive* ToPrimitive(ccHObject* obj);
  84. //! Converts current object to ccSphere (if possible)
  85. static ccSphere* ToSphere(ccHObject* obj);
  86. //! Converts current object to ccCylinder (if possible)
  87. static ccCylinder* ToCylinder(ccHObject* obj);
  88. //! Converts current object to ccCone (if possible)
  89. static ccCone* ToCone(ccHObject* obj);
  90. //! Converts current object to ccPlane (if possible)
  91. static ccPlane* ToPlane(ccHObject* obj);
  92. //! Converts current object to ccDish (if possible)
  93. static ccDish* ToDish(ccHObject* obj);
  94. //! Converts current object to ccExtru (if possible)
  95. static ccExtru* ToExtru(ccHObject* obj);
  96. //! Converts current object to ccTorus (if possible)
  97. static ccTorus* ToTorus(ccHObject* obj);
  98. //! Converts current object to ccOctreeProxy (if possible)
  99. static ccOctreeProxy* ToOctreeProxy(ccHObject* obj);
  100. //! Converts current object to ccOctree (if possible)
  101. static ccOctree* ToOctree(ccHObject* obj);
  102. //! Converts current object to ccKdTree (if possible)
  103. static ccKdTree* ToKdTree(ccHObject* obj);
  104. //! Converts current object to ccSensor (if possible)
  105. static ccSensor* ToSensor(ccHObject* obj);
  106. //! Converts current object to ccGBLSensor (if possible)
  107. static ccGBLSensor* ToGBLSensor(ccHObject* obj);
  108. //! Converts current object to ccCameraSensor (if possible)
  109. static ccCameraSensor* ToCameraSensor(ccHObject* obj);
  110. //! Converts current object to ccImage (if possible)
  111. static ccImage* ToImage(ccHObject* obj);
  112. //! Converts current object to cc2DLabel (if possible)
  113. static cc2DLabel* To2DLabel(ccHObject* obj);
  114. //! Converts current object to cc2DViewportLabel (if possible)
  115. static cc2DViewportLabel* To2DViewportLabel(ccHObject* obj);
  116. //! Converts current object to cc2DViewportObject (if possible)
  117. static cc2DViewportObject* To2DViewportObject(ccHObject* obj);
  118. //! Converts current object to ccIndexedTransformationBuffer (if possible)
  119. static ccIndexedTransformationBuffer* ToTransBuffer(ccHObject* obj);
  120. //! Converts current object to ccCoordinateSystem (if possible)
  121. static ccCoordinateSystem* ToCoordinateSystem(ccHObject* obj);
  122. //! Helper: clones the children of sourceEntity and set the resulting entities as children of destEntity
  123. /** \warning: Not all children can be cloned this way. Only simple ones for now (labels, sensors, images, etc.).
  124. \param sourceEntity source entity
  125. \param destEntity destination entity (can be the same as the source entity)
  126. \param newPointOrTriangleIndex optional: provides a mapping of the entity elements (points or triangles)
  127. between the source and the destination (-1 means no correspondance)
  128. \param sourceEntityProxy for internal use
  129. \param destEntityProxy for internal use
  130. \return success
  131. **/
  132. static bool CloneChildren( const ccHObject* sourceEntity,
  133. ccHObject* destEntity,
  134. std::vector<int>* newPointOrTriangleIndex = nullptr,
  135. const ccHObject* sourceEntityProxy = nullptr,
  136. ccHObject* destEntityProxy = nullptr );
  137. };