Observe and control a long-running Manifold evaluation. More...
#include <common.h>
Public Member Functions | |
| ExecutionContext (const ExecutionContext &) | |
| ExecutionContext (ExecutionContext &&) noexcept | |
| ExecutionContext & | operator= (const ExecutionContext &) |
| ExecutionContext & | operator= (ExecutionContext &&) noexcept |
| void | Cancel () |
| Request cancellation. Can be called from any thread. Idempotent. | |
| bool | Cancelled () const |
| Has cancellation been requested? | |
| double | Progress () const |
| Manifold | FromMeshGL (const MeshGL &mesh) |
| Manifold | FromMeshGL (const MeshGL64 &mesh) |
| Manifold | Smooth (const MeshGL &mesh, const std::vector< Smoothness > &sharpenedEdges={}) |
| Manifold | Smooth (const MeshGL64 &mesh, const std::vector< Smoothness > &sharpenedEdges={}) |
| Manifold | LevelSet (std::function< double(vec3)> sdf, Box bounds, double edgeLength, double level=0, double tolerance=-1, bool canParallel=true) |
Public Attributes | |
| std::shared_ptr< Impl > | impl_ |
Observe and control a long-running Manifold evaluation.
Attach to a Manifold via Manifold::WithContext(ctx); the next eager op invoked on the result (Status, Refine / RefineToLength / RefineToTolerance, Hull, MinkowskiSum / MinkowskiDifference) snapshots the ctx and reports progress and observes cancellation through it. Safe to read/write from any thread.
Copyable and movable: copies share the same underlying state via a shared_ptr, so one thread can evaluate while another holds a copy and observes Progress() or calls Cancel(). Use a separate context per evaluation; passing the same context (or a copy of it) to two concurrent eager ops produces meaningless progress values because both calls reset and mutate the same counters.
Cancellation is permanent for a Manifold: once requested and detected, the Manifold's status becomes Error::Cancelled and stays Cancelled. To retry, construct a new Manifold. A context, however, is reusable: each evaluation through it resets the progress counters, but it does NOT clear the cancel flag – once Cancel() has been called on a context, every subsequent evaluation with that context (or any copy of it) will short-circuit to Error::Cancelled. Construct a fresh context to make a new evaluation cancellable independently.
Cancellation granularity varies by op: Boolean trees check per sub-boolean (so a single very large boolean may run to completion before the next check); Hull checks at the boundaries of its main phases (post-buildMesh and post-SortGeometry); Minkowski checks per face of the first input and per internal BatchBoolean batch.
Example: cancel a long-running BatchBoolean from an observer thread.
Example: cancel a Minkowski sum mid-evaluation.
| double Progress | ( | ) | const |
Normalized progress in [0, 1]. Monotonically increases during evaluation. Returns 1.0 when no work has been scheduled (interpreted as trivially complete – e.g. a single-leaf manifold has nothing to evaluate, and Progress() called before any Status(ctx) reflects the same "no pending work" state).
| Manifold FromMeshGL | ( | const MeshGL & | mesh | ) |
Eager ctx-aware Manifold(MeshGL). The heavy ingest steps check cancel and credit Progress() between phases. Precedence: a Cancel() before this call wins over empty/malformed input; validation errors win over a Cancel() that races in after that. Concurrent calls on the same ctx produce undefined progress values; the returned Manifolds remain valid.
| Manifold Smooth | ( | const MeshGL & | mesh, |
| const std::vector< Smoothness > & | sharpenedEdges = {} ) |
Eager ctx-aware Manifold::Smooth(MeshGL[64]). The ingest phases plus the tangent-creation phases check cancel and credit Progress() between phases. Same cancel-vs-validation precedence as FromMeshGL.
| Manifold LevelSet | ( | std::function< double(vec3)> | sdf, |
| Box | bounds, | ||
| double | edgeLength, | ||
| double | level = 0, | ||
| double | tolerance = -1, | ||
| bool | canParallel = true ) |
Eager ctx-aware Manifold::LevelSet. The voxel-sampling and mesh-extraction phases check cancel and credit Progress() between phases. A Cancel() before or during the call yields a Cancelled result.