MeshLib
 
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{
8
10template <typename T>
12{
13public:
14 using Traits = T;
17 using LeafTag = typename T::LeafTag;
18 using LeafId = typename T::LeafId;
21 using BoxT = typename T::BoxT;
22
23public:
25 [[nodiscard]] const NodeVec & nodes() const { return nodes_; }
26
28 [[nodiscard]] const Node & operator[]( NodeId nid ) const { return nodes_[nid]; }
29
31 [[nodiscard]] static NodeId rootNodeId() { return NodeId{ 0 }; }
32
34 [[nodiscard]] BoxT getBoundingBox() const { return nodes_.empty() ? BoxT{} : nodes_[rootNodeId()].box; }
35
37 [[nodiscard]] MRMESH_API size_t heapBytes() const { return nodes_.heapBytes(); }
38
40 [[nodiscard]] size_t numLeaves() const { return nodes_.empty() ? 0 : ( nodes_.size() + 1 ) / 2; }
41
43 [[nodiscard]] MRMESH_API std::vector<NodeId> getSubtrees( int minNum ) const;
44
46 [[nodiscard]] MRMESH_API LeafBitSet getSubtreeLeaves( NodeId subtreeRoot ) const;
47
49 [[nodiscard]] MRMESH_API NodeBitSet getNodesFromLeaves( const LeafBitSet & leaves ) const;
50
53 MRMESH_API void getLeafOrder( LeafBMap & leafMap ) const;
54
58
59protected:
61};
62
63} //namespace MR
64
65#if defined(MR_PARSING_FOR_PB11_BINDINGS) || defined(MR_COMPILING_PB11_BINDINGS)
66#include "MRAABBTreeBase.hpp"
67#endif
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
base class for most AABB-trees (except for AABBTreePoints)
Definition MRAABBTreeBase.h:12
NodeVec nodes_
Definition MRAABBTreeBase.h:60
MRMESH_API size_t heapBytes() const
returns the amount of memory this object occupies on heap
Definition MRAABBTreeBase.h:37
typename T::BoxT BoxT
Definition MRAABBTreeBase.h:21
size_t numLeaves() const
returns the number of leaves in whole tree
Definition MRAABBTreeBase.h:40
const NodeVec & nodes() const
const-access to all nodes
Definition MRAABBTreeBase.h:25
T Traits
Definition MRAABBTreeBase.h:14
MRMESH_API void getLeafOrderAndReset(LeafBMap &leafMap)
typename T::LeafTag LeafTag
Definition MRAABBTreeBase.h:17
MRMESH_API void getLeafOrder(LeafBMap &leafMap) const
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:34
static NodeId rootNodeId()
returns root node id
Definition MRAABBTreeBase.h:31
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:28
MRMESH_API NodeBitSet getNodesFromLeaves(const LeafBitSet &leaves) const
returns set of nodes containing among direct or indirect children given leaves
typename T::LeafId LeafId
Definition MRAABBTreeBase.h:18
container of bits representing specific indices (faces, verts or edges)
Definition MRMesh/MRBitSet.h:115
std::size_t size() const
Definition MRMesh/MRVector.h:40
size_t heapBytes() const
returns the amount of memory this object occupies on heap
Definition MRMesh/MRVector.h:133
bool empty() const
Definition MRMesh/MRVector.h:38
Definition MRCameraOrientationPlugin.h:7
Definition MRAABBTreeNode.h:31
flat map: I -> T
Definition MRBuffer.h:143