Add progress callback support for all remeshing modules#324
Open
kmarchais wants to merge 2 commits intoMmgTools:developfrom
Open
Add progress callback support for all remeshing modules#324kmarchais wants to merge 2 commits intoMmgTools:developfrom
kmarchais wants to merge 2 commits intoMmgTools:developfrom
Conversation
Add an optional progress callback mechanism that reports iteration-level progress during mesh adaptation and optimization phases. The callback enables: - Two-level progress reporting: phase-level (adaptation vs optimization) and iteration-level within each phase - Per-iteration operation counts: splits, collapses, swaps, and moves - Cooperative cancellation: return 0 from callback to gracefully abort API additions: - MMG5_progressCallback typedef in libmmgtypes.h - MMG5_progressPhase enum (GEOMETRIC_MESH, COMPUTATIONAL_MESH, ADAPTATION, OPTIMIZATION) - MMG3D_Set_progressCallback(), MMG2D_Set_progressCallback(), MMGS_Set_progressCallback() setter functions Design principles: - Zero overhead when no callback is set (single NULL pointer check) - No changes to existing data structures layout or control flow - Callback is invoked after each iteration, alongside existing fprintf progress output - Non-invasive: all changes are additive, no existing code is modified Instrumented loops: - mmg3d: MMG5_adpdel (Delone adaptation), MMG5_adptet (pattern adaptation), MMG5_optet/MMG5_optbad/MMG5_optetLES (optimization) - mmg2d: MMG2D_adptri (adaptation) - mmgs: adptri (adaptation + optimization) Includes example programs for all three modules demonstrating progress display and cancellation.
…urn, cleanup - Add progress callback invocations in anatet/anatri loops for geometric mesh (typchk=1) and computational mesh (typchk=2) phases across mmg3d, mmg2d, and mmgs - Check MMG5_optbad return value in MMG5_adpdel to propagate cancellation immediately - Remove undeclared BUILD_EXAMPLES from CMakeLists.txt - Remove dead total_max_iterations field from progress_3d example - Fix MMG3D_Set_progressCallback doc comment
bd75c98 to
282c297
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an optional progress callback that allows callers to monitor iteration-level progress during remeshing and to request cooperative cancellation. When no callback is set (the default), there is zero overhead.
API
MMG5_progressPhaseenum:GEOMETRIC_MESH,COMPUTATIONAL_MESH,ADAPTATION,OPTIMIZATIONMMG5_progressCallbacktypedef: receives phase, iteration index, max iterations, operation counts (splits, collapses, swaps, moves), and user data. Returns1to continue,0to cancel.MMG3D_Set_progressCallback,MMG2D_Set_progressCallback,MMGS_Set_progressCallbackThe callback is instrumented across all three modules (mmg3d, mmg2d, mmgs). Geometric mesh and computational mesh phases use the existing
anatet/anatriiterative loops. Adaptation and optimization use their respective loops. All four phases fire in mmg3d and mmgs; mmg2d has no separate optimization phase so only the first three apply.Note: the
MMG5_optbadreturn value inMMG5_adpdelwas previously discarded (pre-existing indevelop). Since this PR adds a cancellation path insideMMG5_optbad, the return value is now checked to ensure cancellation propagates immediately.