MeshLib C++ Docs
Loading...
Searching...
No Matches
MRAABBTreeBase.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRAABBTreeNode.h"
4#include "MRVector.h"
5
6namespace MR
7{
10
11
13template <typename T>
14class MRMESH_CLASS AABBTreeBase
15{
16public:
17 using Traits = T;
20 using LeafTag = typename T::LeafTag;
21 using LeafId = typename T::LeafId;
22 using LeafBitSet = TaggedBitSet<LeafTag>;
24 using BoxT = typename T::BoxT;
25
26public:
28 [[nodiscard]] const NodeVec & nodes() const { return nodes_; }
29
31 [[nodiscard]] const Node & operator[]( NodeId nid ) const { return nodes_[nid]; }
32
34 [[nodiscard]] static NodeId rootNodeId() { return NodeId{ 0 }; }
35
37 [[nodiscard]] BoxT getBoundingBox() const { return nodes_.empty() ? BoxT{} : nodes_[rootNodeId()].box; }
38
40 [[nodiscard]] size_t heapBytes() const { return nodes_.heapBytes(); }
41
43 [[nodiscard]] size_t numLeaves() const { return nodes_.empty() ? 0 : ( nodes_.size() + 1 ) / 2; }
44
46 [[nodiscard]] MRMESH_API std::vector<NodeId> getSubtrees( int minNum ) const;
47
49 [[nodiscard]] MRMESH_API LeafBitSet getSubtreeLeaves( NodeId subtreeRoot ) const;
50
52 [[nodiscard]] MRMESH_API NodeBitSet getNodesFromLeaves( const LeafBitSet & leaves ) const;
53
56 MRMESH_API void getLeafOrder( LeafBMap & leafMap ) const;
57
60 MRMESH_API void getLeafOrderAndReset( LeafBMap & leafMap );
61
62protected:
64};
65
66}
base class for most AABB-trees (except for AABBTreePoints)
Definition MRAABBTreeBase.h:15
NodeVec nodes_
Definition MRAABBTreeBase.h:63
typename T::BoxT BoxT
Definition MRAABBTreeBase.h:24
size_t numLeaves() const
returns the number of leaves in whole tree
Definition MRAABBTreeBase.h:43
const NodeVec & nodes() const
const-access to all nodes
Definition MRAABBTreeBase.h:28
T Traits
Definition MRAABBTreeBase.h:17
MRMESH_API void getLeafOrderAndReset(LeafBMap &leafMap)
typename T::LeafTag LeafTag
Definition MRAABBTreeBase.h:20
MRMESH_API void getLeafOrder(LeafBMap &leafMap) const
TaggedBitSet< LeafTag > LeafBitSet
Definition MRAABBTreeBase.h:22
MRMESH_API std::vector< NodeId > getSubtrees(int minNum) const
returns at least given number of top-level not-intersecting subtrees, union of which contain all tree...
BoxT getBoundingBox() const
returns the root node bounding box
Definition MRAABBTreeBase.h:37
static NodeId rootNodeId()
returns root node id
Definition MRAABBTreeBase.h:34
MRMESH_API LeafBitSet getSubtreeLeaves(NodeId subtreeRoot) const
returns all leaves in the subtree with given root
const Node & operator[](NodeId nid) const
const-access to any node
Definition MRAABBTreeBase.h:31
MRMESH_API NodeBitSet getNodesFromLeaves(const LeafBitSet &leaves) const
returns set of nodes containing among direct or indirect children given leaves
size_t heapBytes() const
returns the amount of memory this object occupies on heap
Definition MRAABBTreeBase.h:40
typename T::LeafId LeafId
Definition MRAABBTreeBase.h:21
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRAABBTreeNode.h:31
flat map: I -> T
Definition MRBuffer.h:147