1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
//##########################################################################
//# #
//# CLOUDCOMPARE #
//# #
//# This program is free software; you can redistribute it and/or modify #
//# it under the terms of the GNU General Public License as published by #
//# the Free Software Foundation; version 2 or later of the License. #
//# #
//# This program is distributed in the hope that it will be useful, #
//# but WITHOUT ANY WARRANTY; without even the implied warranty of #
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
//# GNU General Public License for more details. #
//# #
//# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
//# #
//##########################################################################
#ifndef CC_KD_TREE_HEADER
#define CC_KD_TREE_HEADER
//CCLib
#include <TrueKdTree.h>
//Local
#include "ccHObject.h"
//System
#include <unordered_set>
class ccGenericPointCloud;
//! KD-tree structure
/** Extends the CCLib::TrueKdTree class.
**/
class QCC_DB_LIB_API ccKdTree : public CCLib::TrueKdTree, public ccHObject
{
public:
//! Default constructor
/** \param aCloud a point cloud
**/
explicit ccKdTree(ccGenericPointCloud* aCloud);
//! Multiplies the bounding-box of the tree
/** If the cloud coordinates are simply multiplied by the same factor,
there is no use to recompute the tree structure. It's sufficient
to update its bounding-box.
\param multFactor multiplication factor
**/
void multiplyBoundingBox(const PointCoordinateType multFactor);
//! Translates the bounding-box of the tree
/** If the cloud has simply been translated, there is no use to recompute
the tree structure. It's sufficient to update its bounding-box.
\param T translation vector
**/
void translateBoundingBox(const CCVector3& T);
//! Returns class ID
virtual CC_CLASS_ENUM getClassID() const override { return CC_TYPES::POINT_KDTREE; }
//Inherited from ccHObject
virtual ccBBox getOwnBB(bool withGLFeatures = false) override;
//! Flag points with cell index (as a scalar field)
bool convertCellIndexToSF();
//! Flag points with a random color per leaf
bool convertCellIndexToRandomColor();
//! Returns the bounding-box of a given cell
ccBBox getCellBBox(BaseNode* node) const;
//! A set of leaves
typedef std::unordered_set<Leaf*> LeafSet;
//! Returns the neighbor leaves around a given cell
bool getNeighborLeaves(BaseNode* cell, ccKdTree::LeafSet& neighbors, const int* userDataFilter = 0);
//! Returns associated (generic) point cloud
inline ccGenericPointCloud* associatedGenericCloud() const { return m_associatedGenericCloud; }
protected:
//Inherited from ccHObject
virtual void drawMeOnly(CC_DRAW_CONTEXT& context) override;
//! Associated cloud
ccGenericPointCloud* m_associatedGenericCloud;
};
#endif //CC_KD_TREE_HEADER
|