MeshLib C++ Docs
Loading...
Searching...
No Matches
MRAABBTreeNode.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRBox.h"
4#include "MRId.h"
5#include "MRVector2.h"
6#include "MRVector3.h"
7
8namespace MR
9{
10
13
14template<typename L, typename B>
16{
17 using LeafTag = L;
18 using LeafId = Id<L>;
19 using BoxT = B;
20};
21
22template<typename V>
26
28template<typename T>
30{
31 typename T::LeafId leafId;
32 typename T::BoxT box;
33
34 BoxedLeaf() noexcept = default;
35 explicit BoxedLeaf( NoInit ) noexcept : leafId( noInit ), box( noInit ) { }
36};
37
40{
42 [[nodiscard]] static bool isLeaf( NodeId child ) { return int( child ) < 0; }
44 [[nodiscard]] static size_t leafIndex( NodeId child ) { assert( isLeaf( child ) ); return size_t( ~int( child ) ); }
46 [[nodiscard]] static NodeId leafChild( size_t leafIndex ) { return NodeId( ~int( leafIndex ) ); }
47};
48
49template<typename T>
51{
52 using LeafId = typename T::LeafId;
53 using BoxT = typename T::BoxT;
54
56 NodeId l, r;
57
58 AABBTreeNode() noexcept = default;
59 explicit AABBTreeNode( NoInit ) noexcept : box( noInit ), l( noInit ), r( noInit ){}
60};
61
62template<typename T>
64
66{
67 NodeId aNode;
68 NodeId bNode;
69};
70
72
73}
#define MRMESH_CLASS
Definition MRMeshFwd.h:92
stores index of some element, it is made as template class to avoid mixing faces, edges and vertices
Definition MRId.h:20
Vector<T> is indexed by size_t.
Definition MRVector.h:24
Vector< AABBTreeNode< T >, NodeId > AABBTreeNodeVec
Definition MRAABBTreeNode.h:63
LineTreeTraits< Vector2f > LineTreeTraits2
Definition MRAABBTreeNode.h:24
AABBTreeTraits< UndirectedEdgeTag, Box< V > > LineTreeTraits
Definition MRAABBTreeNode.h:23
LineTreeTraits< Vector3f > LineTreeTraits3
Definition MRAABBTreeNode.h:25
constexpr NoInit noInit
Definition MRMeshFwd.h:103
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
the encoding of the children of AABB-tree nodes
Definition MRAABBTreeNode.h:40
static size_t leafIndex(NodeId child)
returns the index in the vector of leaves of the leaf encoded in given child of a node
Definition MRAABBTreeNode.h:44
static NodeId leafChild(size_t leafIndex)
encodes given index in the vector of leaves as a child of a node
Definition MRAABBTreeNode.h:46
static bool isLeaf(NodeId child)
returns true if given child of a node is a leaf rather than another node
Definition MRAABBTreeNode.h:42
typename Traits::LeafId LeafId
Definition MRAABBTreeNode.h:52
NodeId r
Definition MRAABBTreeNode.h:56
NodeId l
Definition MRAABBTreeNode.h:56
AABBTreeNode() noexcept=default
BoxT box
Definition MRAABBTreeNode.h:55
typename Traits::BoxT BoxT
Definition MRAABBTreeNode.h:53
Definition MRAABBTreeNode.h:16
L LeafTag
Definition MRAABBTreeNode.h:17
Id< L > LeafId
Definition MRAABBTreeNode.h:18
B BoxT
Definition MRAABBTreeNode.h:19
BoxedLeaf() noexcept=default
T::BoxT box
Definition MRAABBTreeNode.h:32
T::LeafId leafId
Definition MRAABBTreeNode.h:31
Definition MRMeshFwd.h:102
Definition MRAABBTreeNode.h:66
NodeId bNode
Definition MRAABBTreeNode.h:68
NodeId aNode
Definition MRAABBTreeNode.h:67