From 63ad38e9d90e35a60b93886014cc0340b6a174e3 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Dec 2022 20:59:36 +0100 Subject: [PATCH] Region#inside/not_inside/covering/not_covering is faster as it skips the merge step now. Fixed deep mode implementation (counting mode detection) with performance effect on outside/interacting too --- src/db/db/dbAsIfFlatRegion.cc | 3 ++- src/db/db/dbDeepRegion.cc | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/db/db/dbAsIfFlatRegion.cc b/src/db/db/dbAsIfFlatRegion.cc index 842e55eba..be42a4843 100644 --- a/src/db/db/dbAsIfFlatRegion.cc +++ b/src/db/db/dbAsIfFlatRegion.cc @@ -581,7 +581,8 @@ AsIfFlatRegion::selected_interacting_generic (const Region &other, int mode, boo proc.set_report_progress (report_progress ()); std::vector > others; - others.push_back ((mode < 0 || counting) ? other.begin_merged () : other.begin ()); + // NOTE: with counting the other region needs to be merged + others.push_back (counting ? other.begin_merged () : other.begin ()); proc.run_flat (polygons, others, std::vector (), &op, oph.results ()); diff --git a/src/db/db/dbDeepRegion.cc b/src/db/db/dbDeepRegion.cc index 0f7ea7fd7..350e10fe2 100644 --- a/src/db/db/dbDeepRegion.cc +++ b/src/db/db/dbDeepRegion.cc @@ -1952,6 +1952,7 @@ DeepRegion::selected_interacting_generic (const Region &other, int mode, bool to } } + min_count = std::max (size_t (1), min_count); bool counting = !(min_count == 1 && max_count == std::numeric_limits::max ()); // with these flag set to true, the resulting polygons are broken again. @@ -1966,9 +1967,8 @@ DeepRegion::selected_interacting_generic (const Region &other, int mode, bool to } const db::DeepLayer &polygons = merged_deep_layer (); - // NOTE: on "inside" or with counting, the other polygons must be merged - bool other_needs_merged = (mode < 0 || counting); - const db::DeepLayer &other_polygons = other_needs_merged ? other_deep->merged_deep_layer () : other_deep->deep_layer (); + // NOTE: with counting, the other polygons must be merged + const db::DeepLayer &other_polygons = counting ? other_deep->merged_deep_layer () : other_deep->deep_layer (); db::InteractingLocalOperation op (mode, touching, output_mode, min_count, max_count, true); @@ -2011,6 +2011,7 @@ DeepRegion::selected_interacting_generic (const Edges &other, InteractingOutputM } } + min_count = std::max (size_t (1), min_count); bool counting = !(min_count == 1 && max_count == std::numeric_limits::max ()); // with these flag set to true, the resulting polygons are broken again. @@ -2181,6 +2182,8 @@ DeepRegion::selected_interacting_generic (const Texts &other, InteractingOutputM } } + min_count = std::max (size_t (1), min_count); + // with these flag set to true, the resulting polygons are broken again. bool split_after = false;