| 48 | } |
| 49 | |
| 50 | std::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 | |
| 70 | const VertCoords & MeshOrPoints::points() const |
| 71 | { |
no test coverage detected