Introduce a context variable to control and abort
GoogleCodeExporter opened this issue · comments
As discussed via email, it would be great to have some kind of a context
variable that allows mainly for two things:
* Be able to cancel the execution of long running V-HACD functions. There has to be a reasonable tradeoff between response time and performance. Execution does not need to interrupt immediately but with an approximate grace period of, say between 10 and 30 seconds. I need to set this from an outside thread (in a callback?) and the function will stop at the next given opportunity. Preferably including cleanup of temp data.
* The same mechanism should be able to give me an approximation of progress. Ideally in percent of total time. Again, this doesn't need to be precise. Just a rough indication for the user to know how long this will take.
I suggest a context object interface that is implemented by the user and can be
passed in. It could look like this:
namespace VHACD {
struct IControlFlow {
// called by vhacd to tell the total progress.
// (optional, could resort to always 100 percent)
// it would be ideal if this would be called only
// once and not change afterwards but I guess that
// would be hard to achieve
void set_total_progress(std::size_t p) throw () = 0;
// called by vhacd to indicate how much progress
// has been made. Must be between 0 and set_total_progress()
void set_progress(std::size_t p) throw () = 0;
// called by vhacd regularily
// if it returns false, the algo is aked to stop at
// the next given occasion
bool continue() throw () = 0;
}
}
The user will implement this object and pass it to ApproximateDecomposition().
Would be awesome.
Thanks,
Stephan
Original issue reported on code.google.com by stephan....@gmail.com
on 2 Dec 2014 at 9:00
Hi Stephan,
I have added the following interfaces to make integration easier:
- IVHACD to access the convex decomposition
- IUserCallback to track progress
- IUserLogger to log execution information
Check main.cpp for a simple example on how to use these interfcaes.
To cancel the execution of the algorithm, you need to call IVHACD::Cancel(). I
haven't tested with multi-threading yet. Please, give it a try and let me know
if you face any issues.
Thanks,
--Khaled
Original comment by kma...@gmail.com
on 5 Dec 2014 at 8:53
- Added labels: Maintainability, Priority-High, Type-Enhancement
[deleted comment]
[deleted comment]
Fixed - Feature added
Original comment by kma...@gmail.com
on 5 Dec 2014 at 8:58
- Changed state: Fixed
Awesome job!
Original comment by stephan....@gmail.com
on 5 Dec 2014 at 8:45