ccKdTree.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_KD_TREE_HEADER
  18. #define CC_KD_TREE_HEADER
  19. //CCCoreLib
  20. #include <TrueKdTree.h>
  21. //Local
  22. #include "ccHObject.h"
  23. //System
  24. #include <unordered_set>
  25. class ccGenericPointCloud;
  26. //! KD-tree structure
  27. /** Extends the CCCoreLib::TrueKdTree class.
  28. **/
  29. class QCC_DB_LIB_API ccKdTree : public CCCoreLib::TrueKdTree, public ccHObject
  30. {
  31. public:
  32. //! Default constructor
  33. /** \param aCloud a point cloud
  34. **/
  35. explicit ccKdTree(ccGenericPointCloud* aCloud);
  36. //! Multiplies the bounding-box of the tree
  37. /** If the cloud coordinates are simply multiplied by the same factor,
  38. there is no use to recompute the tree structure. It's sufficient
  39. to update its bounding-box.
  40. \param multFactor multiplication factor
  41. **/
  42. void multiplyBoundingBox(const PointCoordinateType multFactor);
  43. //! Translates the bounding-box of the tree
  44. /** If the cloud has simply been translated, there is no use to recompute
  45. the tree structure. It's sufficient to update its bounding-box.
  46. \param T translation vector
  47. **/
  48. void translateBoundingBox(const CCVector3& T);
  49. //! Returns class ID
  50. virtual CC_CLASS_ENUM getClassID() const override { return CC_TYPES::POINT_KDTREE; }
  51. //Inherited from ccHObject
  52. virtual ccBBox getOwnBB(bool withGLFeatures = false) override;
  53. //! Flag points with cell index (as a scalar field)
  54. bool convertCellIndexToSF();
  55. //! Flag points with a random color per leaf
  56. bool convertCellIndexToRandomColor();
  57. //! Returns the bounding-box of a given cell
  58. ccBBox getCellBBox(BaseNode* node) const;
  59. //! A set of leaves
  60. typedef std::unordered_set<Leaf*> LeafSet;
  61. //! Returns the neighbor leaves around a given cell
  62. bool getNeighborLeaves(BaseNode* cell, ccKdTree::LeafSet& neighbors, const int* userDataFilter = nullptr);
  63. //! Returns associated (generic) point cloud
  64. inline ccGenericPointCloud* associatedGenericCloud() const { return m_associatedGenericCloud; }
  65. protected:
  66. //Inherited from ccHObject
  67. virtual void drawMeOnly(CC_DRAW_CONTEXT& context) override;
  68. //! Associated cloud
  69. ccGenericPointCloud* m_associatedGenericCloud;
  70. };
  71. #endif //CC_KD_TREE_HEADER