Add progress callback support for all remeshing modules#324
Conversation
bd75c98 to
282c297
Compare
282c297 to
c58ae35
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #324 +/- ##
===========================================
- Coverage 50.31% 50.24% -0.07%
===========================================
Files 177 177
Lines 47831 47913 +82
Branches 10352 10372 +20
===========================================
+ Hits 24065 24073 +8
- Misses 16037 16099 +62
- Partials 7729 7741 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
corentin-prigent
left a comment
There was a problem hiding this comment.
Hello,
Thank you for your submission. As you suggested, it would be interesting to had an example to illustrate how this option is used, and specifically, how to set the function that goes into mesh.info.progressCb.
Additionnally, this option is currently only available for library usage. Is there a way to extend this option for command line execution ?
Thank you very much in advance for your answers.
|
The latest commit adds the To get progress information from the API, create a callback function: static int progress_cb(void *mesh, int phase, int it, int maxit,
int64_t nsplit, int64_t ncollapse,
int64_t nswap, int64_t nmove, void *user_data) {
int pct = maxit > 0 ? 100 * (it + 1) / maxit : 100;
if ( pct > 100 ) pct = 100;
printf("\rprogress %3d%%", pct);
fflush(stdout);
return 1; /* return 0 to cancel */
}
/* before MMG3D_mmg3dlib */
MMG3D_Set_progressCallback(mmgMesh, progress_cb, NULL);This progress information can then be used by external tools such as GUIs, Python wrappers, or custom progress bars. To test the CLI progress bar from the repository root: |
Adds an optional progress callback to mmg3d / mmg2d / mmgs that reports iteration progress and supports cooperative cancellation (return 0 to abort). When unset (the default), the only runtime cost is a NULL check on the existing iterative loops.
Incidental change worth flagging:
MMG5_adpdelpreviously discarded the return value ofMMG5_optbad. With this PR a cancellation can originate insideoptbad, so the return value is now checked and propagated.Happy to add a
libexamples/<module>/progress_callback/style example as a follow-up if useful.