rf-geom / ridgeforge Public

Overview/Examples/3. Building a level-of-detail chain

worked example 3 of 6

Building a level-of-detail chain

One decimator, three targets: call run three times with falling triangle budgets and write each result. Nothing survives between runs, so reuse is free.

Example 3 of six - the program sits on the examples page, and this page takes it from the running end: the console it produces, the Status values that end it early, and the options worth changing.

What it prints

in     620400 tris
lod1   160000 tris  err 0.0021
lod2    40000 tris  err 0.0137
lod3    10000 tris  err 0.0719

max_applied_error climbs as the budget falls; on the turbine blade it stays small until the last step, where the thin trailing edges start to cost.

When it goes wrong

No target was set
With all three of target_triangles, target_ratio and max_error left at zero, run returns Status::InvalidOption and the mesh is untouched.
The target is below what locks allow
target_reached comes back false with status Ok: the mesh is valid, just larger than asked, because sharp edges were pinned.
Ridges round off
Set preserve_ridges=true and a ridge_angle_deg that matches the part, or the collapse metric will trade a sharp arris for error it is allowed to spend.

Variations

By ratio, not count
Set target_ratio=0.1f to keep a tenth of whatever came in, independent of the input size.
Hard error ceiling
Set max_error and leave the count targets zero to decimate only as far as a deviation budget permits.

Symbols used here