MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / pointsGridSampling

Method pointsGridSampling

source/MRMesh/MRMeshOrPoints.cpp:50–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50std::optional<VertBitSet> MeshOrPoints::pointsGridSampling( float voxelSize, size_t maxVoxels, const ProgressCallback & cb ) const
51{
52 assert( voxelSize >= 0 );
53 if ( voxelSize == 0 )
54 return validPoints();
55 assert( maxVoxels > 0 );
56 auto box = computeBoundingBox();
57 if ( !box.valid() )
58 return VertBitSet();
59
60 auto bboxDiag = box.size() / voxelSize;
61 auto nSamples = bboxDiag[0] * bboxDiag[1] * bboxDiag[2];
62 if ( nSamples > maxVoxels )
63 voxelSize *= std::cbrt( float(nSamples) / float(maxVoxels) );
64 return std::visit( overloaded{
65 [voxelSize, cb]( const MeshPart & mp ) { return verticesGridSampling( mp, voxelSize, cb ); },
66 [voxelSize, cb]( const PointCloudPart & pcp ) { return pointGridSampling( pcp, voxelSize, cb ); }
67 }, var_ );
68}
69
70const VertCoords & MeshOrPoints::points() const
71{

Callers 3

sampleFltPointsMethod · 0.80
sampleRefPointsMethod · 0.80
resamplePointsMethod · 0.80

Calls 5

verticesGridSamplingFunction · 0.85
pointGridSamplingFunction · 0.85
computeBoundingBoxFunction · 0.70
validMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected