MeshLib
 
Loading...
Searching...
No Matches
MRMesh/MRPointCloud.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVector.h"
4#include "MRBitSet.h"
5#include "MRMeshFwd.h"
8
9namespace MR
10{
11
13
16{
19
22
25
27 [[nodiscard]] size_t calcNumValidPoints() const { return validPoints.count(); }
28
30 [[nodiscard]] bool hasNormals() const { return normals.size() >= points.size(); }
31
33 [[nodiscard]] const VertBitSet & getVertIds( const VertBitSet * region ) const
34 {
35 assert( !region || ( *region - validPoints ).none() ); // if region is given, then region must be a subset of them
36 return region ? *region : validPoints;
37 }
38
41
43 [[nodiscard]] const AABBTreePoints * getAABBTreeNotCreate() const { return AABBTreeOwner_.get(); }
44
46 [[nodiscard]] MRMESH_API Box3f getBoundingBox() const;
47
50 [[nodiscard]] MRMESH_API Box3f computeBoundingBox( const AffineXf3f * toWorld = nullptr ) const;
51
54
56 [[nodiscard]] MRMESH_API Vector3f findCenterFromBBox() const;
57
59 [[nodiscard]] MRMESH_API std::vector<VertId> getLexicographicalOrder() const;
60
64 MRMESH_API void addPartByMask( const PointCloud& from, const VertBitSet& fromVerts, const CloudPartMapping& outMap = {},
65 const VertNormals * extNormals = nullptr );
66
69
72
74 MRMESH_API void mirror( const Plane3f& plane );
75
77 MRMESH_API void flipOrientation( const VertBitSet * region = nullptr );
78
82 MRMESH_API bool pack( VertMap * outNew2Old = nullptr );
83
86 MRMESH_API VertBMap pack( Reorder reoder );
87
89 void invalidateCaches() { AABBTreeOwner_.reset(); }
90
92 [[nodiscard]] MRMESH_API size_t heapBytes() const;
93
94private:
95 mutable UniqueThreadSafeOwner<AABBTreePoints> AABBTreeOwner_;
96};
97
98} // namespace MR
List< Vector3f^> VertNormals
Definition MRDotNet/MRMeshFwd.h:98
List< Vector3f^> VertCoords
Definition MRDotNet/MRMeshFwd.h:95
int VertId
Definition MRDotNet/MRMeshFwd.h:51
List< VertId > VertMap
Definition MRDotNet/MRMeshFwd.h:84
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRDotNet/MRBitSet.h:39
bounding volume hierarchy for point cloud structure
Definition MRAABBTreePoints.h:16
Definition MRUniqueThreadSafeOwner.h:20
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
Definition MRCameraOrientationPlugin.h:7
Reorder
determines how points to be ordered
Definition MRMesh/MRMeshFwd.h:606
Definition MRCloudPartMapping.h:10
Definition MRMesh/MRPointCloud.h:16
VertCoords points
coordinates of points
Definition MRMesh/MRPointCloud.h:18
MRMESH_API size_t heapBytes() const
returns the amount of memory this object occupies on heap
VertNormals normals
unit normal directions of points (can be empty if no normals are known)
Definition MRMesh/MRPointCloud.h:21
MRMESH_API Box3f getBoundingBox() const
returns the minimal bounding box containing all valid vertices (implemented via getAABBTree())
MRMESH_API void flipOrientation(const VertBitSet *region=nullptr)
flip orientation (normals) of given points (or all valid points is nullptr)
MRMESH_API void addPartByMask(const PointCloud &from, const VertBitSet &fromVerts, const CloudPartMapping &outMap={}, const VertNormals *extNormals=nullptr)
bool hasNormals() const
returns true if there is a normal for each point
Definition MRMesh/MRPointCloud.h:30
size_t calcNumValidPoints() const
computes the total number of valid points in the cloud
Definition MRMesh/MRPointCloud.h:27
const VertBitSet & getVertIds(const VertBitSet *region) const
if region pointer is not null then converts it in reference, otherwise returns all valid points in th...
Definition MRMesh/MRPointCloud.h:33
MRMESH_API const AABBTreePoints & getAABBTree() const
returns cached aabb-tree for this point cloud, creating it if it did not exist in a thread-safe manne...
MRMESH_API void mirror(const Plane3f &plane)
reflects the points from a given plane
MRMESH_API VertId addPoint(const Vector3f &point)
appends a point and returns its VertId
MRMESH_API std::vector< VertId > getLexicographicalOrder() const
returns all valid point ids sorted lexicographically by their coordinates (optimal for uniform sampli...
VertBitSet validPoints
only points and normals corresponding to set bits here are valid
Definition MRMesh/MRPointCloud.h:24
MRMESH_API VertBMap pack(Reorder reoder)
void invalidateCaches()
Invalidates caches (e.g. aabb-tree) after a change in point cloud.
Definition MRMesh/MRPointCloud.h:89
MRMESH_API bool pack(VertMap *outNew2Old=nullptr)
MRMESH_API Box3f computeBoundingBox(const AffineXf3f *toWorld=nullptr) const
const AABBTreePoints * getAABBTreeNotCreate() const
returns cached aabb-tree for this point cloud, but does not create it if it did not exist
Definition MRMesh/MRPointCloud.h:43
MRMESH_API VertId addPoint(const Vector3f &point, const Vector3f &normal)
appends a point with normal and returns its VertId
MRMESH_API Vector3f findCenterFromPoints() const
computes average position of all valid points
MRMESH_API Vector3f findCenterFromBBox() const
computes bounding box and returns its center