| 8 | #include <iostream> |
| 9 | |
| 10 | int main() |
| 11 | { |
| 12 | // Generate point cloud |
| 13 | MR::PointCloud pc; |
| 14 | pc.points.reserve( 10000 ); |
| 15 | for ( auto i = 0; i < 100; ++i ) |
| 16 | { |
| 17 | const auto u = MR::PI2_F * float( i ) / ( 100.f - 1.f ); |
| 18 | for ( auto j = 0; j < 100; ++j ) |
| 19 | { |
| 20 | const auto v = MR::PI_F * float( j ) / ( 100.f - 1.f ); |
| 21 | |
| 22 | pc.points.emplace_back( |
| 23 | std::cos( u ) * std::sin( v ), |
| 24 | std::sin( u ) * std::sin( v ), |
| 25 | std::cos( v ) |
| 26 | ); |
| 27 | } |
| 28 | } |
| 29 | // Remove duplicate points |
| 30 | auto vs = MR::pointUniformSampling( pc, { |
| 31 | .distance = 1e-3f, |
| 32 | } ); |
| 33 | assert( vs ); |
| 34 | pc.validPoints = std::move( *vs ); |
| 35 | pc.invalidateCaches(); |
| 36 | |
| 37 | // Triangulate it |
| 38 | auto triangulated = MR::triangulatePointCloud( pc ); |
| 39 | assert( triangulated ); |
| 40 | |
| 41 | // Fix possible issues |
| 42 | auto mesh = MR::offsetMesh( *triangulated, 0.f, { { |
| 43 | .voxelSize = MR::suggestVoxelSize( *triangulated, 5e+6f ), |
| 44 | } } ); |
| 45 | assert( mesh ); |
| 46 | |
| 47 | // Save result |
| 48 | if ( auto saveRes = MR::MeshSave::toAnySupportedFormat( *mesh, "result.stl" ); !saveRes ) |
| 49 | { |
| 50 | std::cerr << saveRes.error() << std::endl; |
| 51 | return 1; |
| 52 | } |
| 53 | |
| 54 | return 0; |
| 55 | } |
nothing calls this directly
no test coverage detected