MeshLib
 
Loading...
Searching...
No Matches
MRAABBTreePoints.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRBox.h"
4#include "MRId.h"
5#include "MRVector.h"
6#include "MRVector3.h"
7
8namespace MR
9{
10
13
16{
17public:
18 struct Node
19 {
23 bool leaf() const { return !leftOrFirst.valid(); }
25 std::pair<int, int> getLeafPointRange() const { assert( leaf() ); return {-( leftOrFirst + 1 ),-( rightOrLast + 1 )}; }
27 void setLeafPointRange( int first, int last ) { leftOrFirst = NodeId( -( first + 1 ) ); rightOrLast = NodeId( -( last + 1 ) ); }
28 };
31 [[nodiscard]] const NodeVec& nodes() const { return nodes_; }
32 [[nodiscard]] const Node& operator[]( NodeId nid ) const { return nodes_[nid]; }
33 [[nodiscard]] static NodeId rootNodeId() { return NodeId{0}; }
35 [[nodiscard]] Box3f getBoundingBox() const { return nodes_.empty() ? Box3f{} : nodes_[rootNodeId()].box; }
36
37 struct Point
38 {
41 };
42 [[nodiscard]] const std::vector<Point>& orderedPoints() const { return orderedPoints_; }
43
45 MRMESH_API AABBTreePoints( const PointCloud& pointCloud );
49 MRMESH_API AABBTreePoints( const VertCoords & points, const VertBitSet * validPoints = nullptr );
51 AABBTreePoints( const VertCoords & points, const VertBitSet & validPoints ) : AABBTreePoints( points, &validPoints ) {}
52
54 constexpr static int MaxNumPointsInLeaf = 16;
55
56 AABBTreePoints( AABBTreePoints && ) noexcept = default;
57 AABBTreePoints & operator =( AABBTreePoints && ) noexcept = default;
58
61 MRMESH_API void getLeafOrder( VertBMap & vertMap ) const;
65 MRMESH_API void getLeafOrderAndReset( VertBMap & vertMap );
66
68 [[nodiscard]] MRMESH_API size_t heapBytes() const;
69
74 MRMESH_API void refit( const VertCoords & newCoords, const VertBitSet & changedVerts );
75
76private:
77 std::vector<Point> orderedPoints_;
78 NodeVec nodes_;
79
80 AABBTreePoints( const AABBTreePoints & ) = default;
81 AABBTreePoints & operator =( const AABBTreePoints & ) = default;
83};
84
86
87} // namespace MR
List< Vector3f^> VertCoords
Definition MRDotNet/MRMeshFwd.h:95
int VertId
Definition MRDotNet/MRMeshFwd.h:51
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRDotNet/MRBitSet.h:39
bounding volume hierarchy for point cloud structure
Definition MRAABBTreePoints.h:16
MRMESH_API void getLeafOrderAndReset(VertBMap &vertMap)
const Node & operator[](NodeId nid) const
Definition MRAABBTreePoints.h:32
MRMESH_API size_t heapBytes() const
returns the amount of memory this object occupies on heap
const std::vector< Point > & orderedPoints() const
Definition MRAABBTreePoints.h:42
AABBTreePoints(AABBTreePoints &&) noexcept=default
const NodeVec & nodes() const
Definition MRAABBTreePoints.h:31
static constexpr int MaxNumPointsInLeaf
maximum number of points in leaf node of tree (all of leafs should have this number of points except ...
Definition MRAABBTreePoints.h:54
Box3f getBoundingBox() const
returns the root node bounding box
Definition MRAABBTreePoints.h:35
MRMESH_API AABBTreePoints(const VertCoords &points, const VertBitSet *validPoints=nullptr)
creates tree from given valid points
MRMESH_API AABBTreePoints(const Mesh &mesh)
creates tree for vertices of given mesh
MRMESH_API void refit(const VertCoords &newCoords, const VertBitSet &changedVerts)
static NodeId rootNodeId()
Definition MRAABBTreePoints.h:33
MRMESH_API void getLeafOrder(VertBMap &vertMap) const
MRMESH_API AABBTreePoints(const PointCloud &pointCloud)
creates tree for given point cloud
AABBTreePoints(const VertCoords &points, const VertBitSet &validPoints)
creates tree from given valid points
Definition MRAABBTreePoints.h:51
container of bits representing specific indices (faces, verts or edges)
Definition MRMesh/MRBitSet.h:115
Definition MRUniqueThreadSafeOwner.h:20
bool empty() const
Definition MRMesh/MRVector.h:38
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
Definition MRCameraOrientationPlugin.h:7
Definition MRAABBTreePoints.h:19
void setLeafPointRange(int first, int last)
sets [first,last) to this node (leaf)
Definition MRAABBTreePoints.h:27
Box3f box
bounding box of whole subtree
Definition MRAABBTreePoints.h:20
NodeId rightOrLast
Definition MRAABBTreePoints.h:21
std::pair< int, int > getLeafPointRange() const
returns [first,last) indices of leaf points
Definition MRAABBTreePoints.h:25
bool leaf() const
returns true if node represent real points, false if it has child nodes
Definition MRAABBTreePoints.h:23
NodeId leftOrFirst
Definition MRAABBTreePoints.h:21
Definition MRAABBTreePoints.h:38
Vector3f coord
Definition MRAABBTreePoints.h:39
VertId id
Definition MRAABBTreePoints.h:40
Definition MRMesh/MRMesh.h:23
Definition MRMesh/MRPointCloud.h:16