61 WithFallback(std::shared_ptr<IContourExtractor> primary, std::shared_ptr<IContourExtractor> fallback)
62 : primary(
std::move(primary)), fallback(
std::move(fallback)) {}
77 bool primary_returned =
false;
80 res = primary->extract(field, cr);
81 primary_returned =
true;
82 }
catch (
const std::exception& e) {
83 LOG_WARN(
"Primary contour extraction threw, falling back: ", e.what());
85 LOG_WARN(
"Primary contour extraction threw unknown exception, falling back.");
88 if (!primary_returned || !res.
success) {
89 LOG_WARN(
"Primary contour extraction method failed or returned no contour, falling back.");
90 res = fallback->extract(field, cr);
97 std::shared_ptr<IContourExtractor> primary;
98 std::shared_ptr<IContourExtractor> fallback;
#define LOG_WARN(...)
Macro for logging warning messages.
Tries a primary contour extractor and falls back to another extractor on failure.
Contour extract(const ScalarField2D &field, const ContourRequest &cr) override
Extracts a contour using the primary extractor, then fallback if needed.
WithFallback(std::shared_ptr< IContourExtractor > primary, std::shared_ptr< IContourExtractor > fallback)
Constructs a fallback contour extractor wrapper.
std::function< double(double, double)> ScalarField2D
Hash specialization for SymbolId<Tag>.
Input configuration for a two-dimensional contour extraction.
Output of a contour extraction algorithm.
bool success
Whether extraction produced a valid contour.