| 8 | #include <iostream> |
| 9 | |
| 10 | int main() |
| 11 | { |
| 12 | // Load mesh |
| 13 | auto loadRes = MR::MeshLoad::fromAnySupportedFormat( "mesh.stl" ); |
| 14 | if ( !loadRes.has_value() ) |
| 15 | { |
| 16 | std::cerr << loadRes.error() << std::endl; |
| 17 | return 1; |
| 18 | } |
| 19 | MR::Mesh& mesh = *loadRes; |
| 20 | |
| 21 | // Add noise to the mesh |
| 22 | std::ignore = MR::addNoise( mesh.points, mesh.topology.getValidVerts(), { |
| 23 | .sigma = mesh.computeBoundingBox().diagonal() * 0.0001f, |
| 24 | } ); |
| 25 | |
| 26 | // Invalidate the mesh because of the external vertex changes |
| 27 | mesh.invalidateCaches(); |
| 28 | |
| 29 | // Save the noised mesh |
| 30 | if ( auto saveRes = MR::MeshSave::toAnySupportedFormat( mesh, "noised_mesh.stl" ); !saveRes ) |
| 31 | { |
| 32 | std::cerr << saveRes.error() << std::endl; |
| 33 | return 1; |
| 34 | } |
| 35 | |
| 36 | // Denoise the mesh with sharpening for sharp edges |
| 37 | // see the article "Mesh Denoising via a Novel Mumford-Shah Framework" |
| 38 | std::ignore = MR::meshDenoiseViaNormals( mesh ); |
| 39 | |
| 40 | // Save the denoised mesh |
| 41 | if ( auto saveRes = MR::MeshSave::toAnySupportedFormat( mesh, "denoised_mesh.stl" ); !saveRes ) |
| 42 | { |
| 43 | std::cerr << saveRes.error() << std::endl; |
| 44 | return 1; |
| 45 | } |
| 46 | } |
nothing calls this directly
no test coverage detected