From 7510728a712cfa2b847f37bf3f73c38953ff8ce3 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Aug 2024 23:18:57 +0200 Subject: [PATCH] First API steps --- src/db/db/dbAsIfFlatEdgePairs.cc | 84 +++++++++++++ src/db/db/dbAsIfFlatEdgePairs.h | 16 +++ src/db/db/dbDeepEdgePairs.cc | 84 +++++++++++++ src/db/db/dbDeepEdgePairs.h | 16 +++ src/db/db/dbEdgePairs.cc | 10 ++ src/db/db/dbEdgePairs.h | 208 +++++++++++++++++++++++++++++++ src/db/db/dbEdgePairsDelegate.h | 16 +++ src/db/db/dbEmptyEdgePairs.cc | 12 ++ src/db/db/dbEmptyEdgePairs.h | 16 +++ 9 files changed, 462 insertions(+) diff --git a/src/db/db/dbAsIfFlatEdgePairs.cc b/src/db/db/dbAsIfFlatEdgePairs.cc index d0f098e27..789322e69 100644 --- a/src/db/db/dbAsIfFlatEdgePairs.cc +++ b/src/db/db/dbAsIfFlatEdgePairs.cc @@ -241,6 +241,90 @@ AsIfFlatEdgePairs::filtered (const EdgePairFilterBase &filter) const return new_edge_pairs.release (); } +RegionDelegate * +AsIfFlatEdgePairs::pull_interacting (const Region &) const +{ + // @@@ +} + +EdgesDelegate * +AsIfFlatEdgePairs::pull_interacting (const Edges &) const +{ + // @@@ +} + +EdgePairsDelegate * +AsIfFlatEdgePairs::selected_interacting (const Region &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +EdgePairsDelegate * +AsIfFlatEdgePairs::selected_not_interacting (const Region &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +EdgePairsDelegate * +AsIfFlatEdgePairs::selected_interacting (const Edges &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +EdgePairsDelegate * +AsIfFlatEdgePairs::selected_not_interacting (const Edges &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +std::pair +AsIfFlatEdgePairs::selected_interacting_pair (const Region &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +std::pair +AsIfFlatEdgePairs::selected_interacting_pair (const Edges &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +EdgePairsDelegate * +AsIfFlatEdgePairs::selected_outside (const Region &other) const +{ + // @@@ +} + +EdgePairsDelegate * +AsIfFlatEdgePairs::selected_not_outside (const Region &other) const +{ + // @@@ +} + +std::pair +AsIfFlatEdgePairs::selected_outside_pair (const Region &other) const +{ + // @@@ +} + +EdgePairsDelegate * +AsIfFlatEdgePairs::selected_inside (const Region &other) const +{ + // @@@ +} + +EdgePairsDelegate * +AsIfFlatEdgePairs::selected_not_inside (const Region &other) const +{ + // @@@ +} + +std::pair +AsIfFlatEdgePairs::selected_inside_pair (const Region &other) const +{ + // @@@ +} + RegionDelegate * AsIfFlatEdgePairs::polygons (db::Coord e) const { diff --git a/src/db/db/dbAsIfFlatEdgePairs.h b/src/db/db/dbAsIfFlatEdgePairs.h index 2a69bb035..9387aa03c 100644 --- a/src/db/db/dbAsIfFlatEdgePairs.h +++ b/src/db/db/dbAsIfFlatEdgePairs.h @@ -62,6 +62,22 @@ public: virtual RegionDelegate *processed_to_polygons (const EdgePairToPolygonProcessorBase &proc) const; virtual EdgesDelegate *processed_to_edges (const EdgePairToEdgeProcessorBase &proc) const; + virtual RegionDelegate *pull_interacting (const Region &) const; + virtual EdgesDelegate *pull_interacting (const Edges &) const; + virtual EdgePairsDelegate *selected_interacting (const Region &other, size_t min_count, size_t max_count) const; + virtual EdgePairsDelegate *selected_not_interacting (const Region &other, size_t min_count, size_t max_count) const; + virtual EdgePairsDelegate *selected_interacting (const Edges &other, size_t min_count, size_t max_count) const; + virtual EdgePairsDelegate *selected_not_interacting (const Edges &other, size_t min_count, size_t max_count) const; + virtual std::pair selected_interacting_pair (const Region &other, size_t min_count, size_t max_count) const; + virtual std::pair selected_interacting_pair (const Edges &other, size_t min_count, size_t max_count) const; + + virtual EdgePairsDelegate *selected_outside (const Region &other) const; + virtual EdgePairsDelegate *selected_not_outside (const Region &other) const; + virtual std::pair selected_outside_pair (const Region &other) const; + virtual EdgePairsDelegate *selected_inside (const Region &other) const; + virtual EdgePairsDelegate *selected_not_inside (const Region &other) const; + virtual std::pair selected_inside_pair (const Region &other) const; + virtual EdgePairsDelegate *add_in_place (const EdgePairs &other) { return add (other); diff --git a/src/db/db/dbDeepEdgePairs.cc b/src/db/db/dbDeepEdgePairs.cc index 090644265..4900d5e0e 100644 --- a/src/db/db/dbDeepEdgePairs.cc +++ b/src/db/db/dbDeepEdgePairs.cc @@ -497,6 +497,90 @@ RegionDelegate *DeepEdgePairs::polygons (db::Coord e) const return new db::DeepRegion (new_layer); } +RegionDelegate * +DeepEdgePairs::pull_interacting (const Region &) const +{ + // @@@ +} + +EdgesDelegate * +DeepEdgePairs::pull_interacting (const Edges &) const +{ + // @@@ +} + +EdgePairsDelegate * +DeepEdgePairs::selected_interacting (const Region &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +EdgePairsDelegate * +DeepEdgePairs::selected_not_interacting (const Region &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +EdgePairsDelegate * +DeepEdgePairs::selected_interacting (const Edges &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +EdgePairsDelegate * +DeepEdgePairs::selected_not_interacting (const Edges &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +std::pair +DeepEdgePairs::selected_interacting_pair (const Region &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +std::pair +DeepEdgePairs::selected_interacting_pair (const Edges &other, size_t min_count, size_t max_count) const +{ + // @@@ +} + +EdgePairsDelegate * +DeepEdgePairs::selected_outside (const Region &other) const +{ + // @@@ +} + +EdgePairsDelegate * +DeepEdgePairs::selected_not_outside (const Region &other) const +{ + // @@@ +} + +std::pair +DeepEdgePairs::selected_outside_pair (const Region &other) const +{ + // @@@ +} + +EdgePairsDelegate * +DeepEdgePairs::selected_inside (const Region &other) const +{ + // @@@ +} + +EdgePairsDelegate * +DeepEdgePairs::selected_not_inside (const Region &other) const +{ + // @@@ +} + +std::pair +DeepEdgePairs::selected_inside_pair (const Region &other) const +{ + // @@@ +} + EdgesDelegate *DeepEdgePairs::generic_edges (bool first, bool second) const { db::DeepLayer new_layer = deep_layer ().derived (); diff --git a/src/db/db/dbDeepEdgePairs.h b/src/db/db/dbDeepEdgePairs.h index 8ec686da0..ae0e7a5e5 100644 --- a/src/db/db/dbDeepEdgePairs.h +++ b/src/db/db/dbDeepEdgePairs.h @@ -83,6 +83,22 @@ public: virtual RegionDelegate *processed_to_polygons (const EdgePairToPolygonProcessorBase &filter) const; virtual EdgesDelegate *processed_to_edges (const EdgePairToEdgeProcessorBase &filter) const; + virtual RegionDelegate *pull_interacting (const Region &) const; + virtual EdgesDelegate *pull_interacting (const Edges &) const; + virtual EdgePairsDelegate *selected_interacting (const Region &other, size_t min_count, size_t max_count) const; + virtual EdgePairsDelegate *selected_not_interacting (const Region &other, size_t min_count, size_t max_count) const; + virtual EdgePairsDelegate *selected_interacting (const Edges &other, size_t min_count, size_t max_count) const; + virtual EdgePairsDelegate *selected_not_interacting (const Edges &other, size_t min_count, size_t max_count) const; + virtual std::pair selected_interacting_pair (const Region &other, size_t min_count, size_t max_count) const; + virtual std::pair selected_interacting_pair (const Edges &other, size_t min_count, size_t max_count) const; + + virtual EdgePairsDelegate *selected_outside (const Region &other) const; + virtual EdgePairsDelegate *selected_not_outside (const Region &other) const; + virtual std::pair selected_outside_pair (const Region &other) const; + virtual EdgePairsDelegate *selected_inside (const Region &other) const; + virtual EdgePairsDelegate *selected_not_inside (const Region &other) const; + virtual std::pair selected_inside_pair (const Region &other) const; + virtual EdgePairsDelegate *add_in_place (const EdgePairs &other); virtual EdgePairsDelegate *add (const EdgePairs &other) const; diff --git a/src/db/db/dbEdgePairs.cc b/src/db/db/dbEdgePairs.cc index 6e0d9059e..600d5c709 100644 --- a/src/db/db/dbEdgePairs.cc +++ b/src/db/db/dbEdgePairs.cc @@ -224,6 +224,16 @@ void EdgePairs::second_edges (Edges &output) const output.set_delegate (mp_delegate->second_edges ()); } +void EdgePairs::pull_interacting (Region &output, const Region &other) const +{ + // @@@ +} + +void EdgePairs::pull_interacting (Edges &output, const Edges &other) const +{ + // @@@ +} + void EdgePairs::set_delegate (EdgePairsDelegate *delegate) { if (delegate != mp_delegate) { diff --git a/src/db/db/dbEdgePairs.h b/src/db/db/dbEdgePairs.h index 53a499689..dd5211a1c 100644 --- a/src/db/db/dbEdgePairs.h +++ b/src/db/db/dbEdgePairs.h @@ -370,6 +370,214 @@ public: */ void processed (Edges &output, const EdgePairToEdgeProcessorBase &proc) const; + /** + * @brief Selects all polygons of the region set which overlap or touch edges from this edge pair set + * + * Merged semantics applies for the other region. Merged polygons will be selected from the other region + * if merged semantics is enabled. + */ + void pull_interacting (Region &output, const Region &other) const; + + /** + * @brief Selects all edges of the other edge set which overlap or touch edges from this edge pair set + * + * Merged semantics applies. If merged semantics is chosen, the connected edge parts will be + * selected as a whole from other. + */ + void pull_interacting (Edges &output, const Edges &other) const; + + /** + * @brief Selects all edge pairs of this set which overlap or touch with polygons from the region + */ + EdgePairs &select_interacting (const Region &other, size_t min_count = 1, size_t max_count = std::numeric_limits::max ()) + { + set_delegate (mp_delegate->selected_interacting (other, min_count, max_count)); + return *this; + } + + /** + * @brief Returns all edge pairs of this set which overlap or touch with polygons from the region + * + * This method is an out-of-place version of select_interacting. + */ + EdgePairs selected_interacting (const Region &other, size_t min_count = 1, size_t max_count = std::numeric_limits::max ()) const + { + return EdgePairs (mp_delegate->selected_interacting (other, min_count, max_count)); + } + + /** + * @brief Selects all edge pairs of this set which do not overlap or touch with polygons from the region + */ + EdgePairs &select_not_interacting (const Region &other, size_t min_count = 1, size_t max_count = std::numeric_limits::max ()) + { + set_delegate (mp_delegate->selected_not_interacting (other, min_count, max_count)); + return *this; + } + + /** + * @brief Returns all edge pairs of this set which do not overlap or touch with polygons from the region + * + * This method is an out-of-place version of select_not_interacting. + */ + EdgePairs selected_not_interacting (const Region &other, size_t min_count = 1, size_t max_count = std::numeric_limits::max ()) const + { + return EdgePairs (mp_delegate->selected_not_interacting (other, min_count, max_count)); + } + + /** + * @brief Returns all edge pairs of this set which do not overlap or touch with polygons from the region together with the ones that do not + */ + std::pair selected_interacting_differential (const Region &other, size_t min_count = 1, size_t max_count = std::numeric_limits::max ()) const + { + std::pair p = mp_delegate->selected_interacting_pair (other, min_count, max_count); + return std::pair (EdgePairs (p.first), EdgePairs (p.second)); + } + + /** + * @brief Selects all edge pairs of this collection which are completely outside polygons from the region + */ + EdgePairs &select_outside (const Region &other) + { + set_delegate (mp_delegate->selected_outside (other)); + return *this; + } + + /** + * @brief Selects all edge pairs of this collection which are not completely outside polygons from the region + */ + EdgePairs &select_not_outside (const Region &other) + { + set_delegate (mp_delegate->selected_not_outside (other)); + return *this; + } + + /** + * @brief Returns all edge pairs of this collection which are completely outside polygons from the region + * + * This method is an out-of-place version of select_outside. + */ + EdgePairs selected_outside (const Region &other) const + { + return EdgePairs (mp_delegate->selected_outside (other)); + } + + /** + * @brief Returns all edge pairs of this collection which are not completely outside polygons from the region + * + * This method is an out-of-place version of select_not_outside. + */ + EdgePairs selected_not_outside (const Region &other) const + { + return EdgePairs (mp_delegate->selected_not_outside (other)); + } + + /** + * @brief Returns all edge pairs of this which are completely outside polygons from the region and the opposite ones at the same time + * + * This method is equivalent to calling selected_outside and selected_not_outside, but faster. + */ + std::pair selected_outside_differential (const Region &other) const + { + std::pair p = mp_delegate->selected_outside_pair (other); + return std::pair (EdgePairs (p.first), EdgePairs (p.second)); + } + + /** + * @brief Selects all edge pairs of this collection which are completely inside polygons from the region + */ + EdgePairs &select_inside (const Region &other) + { + set_delegate (mp_delegate->selected_inside (other)); + return *this; + } + + /** + * @brief Selects all edge pairs of this collection which are not completely inside polygons from the region + */ + EdgePairs &select_not_inside (const Region &other) + { + set_delegate (mp_delegate->selected_not_inside (other)); + return *this; + } + + /** + * @brief Returns all edge pairs of this which are completely inside polygons from the region + * + * This method is an out-of-place version of select_inside. + */ + EdgePairs selected_inside (const Region &other) const + { + return EdgePairs (mp_delegate->selected_inside (other)); + } + + /** + * @brief Returns all edge pairs of this which are not completely inside polygons from the region + * + * This method is an out-of-place version of select_not_inside. + */ + EdgePairs selected_not_inside (const Region &other) const + { + return EdgePairs (mp_delegate->selected_not_inside (other)); + } + + /** + * @brief Returns all edge pairs of this which are completely inside polygons from the region and the opposite ones at the same time + * + * This method is equivalent to calling selected_inside and selected_not_inside, but faster. + */ + std::pair selected_inside_differential (const Region &other) const + { + std::pair p = mp_delegate->selected_inside_pair (other); + return std::pair (EdgePairs (p.first), EdgePairs (p.second)); + } + + /** + * @brief Selects all edge pairs of this edge pairs set which overlap or touch with edges from the edge set + */ + EdgePairs &select_interacting (const Edges &other, size_t min_count = 1, size_t max_count = std::numeric_limits::max ()) + { + set_delegate (mp_delegate->selected_interacting (other, min_count, max_count)); + return *this; + } + + /** + * @brief Returns all edge pairs of this edge pairs set which overlap or touch with edges from the edge set + * + * This method is an out-of-place version of select_interacting. + */ + EdgePairs selected_interacting (const Edges &other, size_t min_count = 1, size_t max_count = std::numeric_limits::max ()) const + { + return EdgePairs (mp_delegate->selected_interacting (other, min_count, max_count)); + } + + /** + * @brief Returns all edge pairs of this edge set which do not overlap or touch with edges from the other edge set together with the ones that do not + */ + std::pair selected_interacting_differential (const Edges &other, size_t min_count = 1, size_t max_count = std::numeric_limits::max ()) const + { + std::pair p = mp_delegate->selected_interacting_pair (other, min_count, max_count); + return std::pair (EdgePairs (p.first), EdgePairs (p.second)); + } + + /** + * @brief Selects all edge pairs of this edge pairs set which do not overlap or touch with edges from the edge set + */ + EdgePairs &select_not_interacting (const Edges &other, size_t min_count = 1, size_t max_count = std::numeric_limits::max ()) + { + set_delegate (mp_delegate->selected_not_interacting (other, min_count, max_count)); + return *this; + } + + /** + * @brief Returns all edge pairs of this edge pairs set which do not overlap or touch with edges from the edge set + * + * This method is an out-of-place version of select_not_interacting. + */ + EdgePairs selected_not_interacting (const Edges &other, size_t min_count = 1, size_t max_count = std::numeric_limits::max ()) const + { + return EdgePairs (mp_delegate->selected_not_interacting (other, min_count, max_count)); + } + /** * @brief Transforms the edge pair set */ diff --git a/src/db/db/dbEdgePairsDelegate.h b/src/db/db/dbEdgePairsDelegate.h index 189ff293e..c786838fa 100644 --- a/src/db/db/dbEdgePairsDelegate.h +++ b/src/db/db/dbEdgePairsDelegate.h @@ -200,6 +200,22 @@ public: virtual RegionDelegate *processed_to_polygons (const EdgePairToPolygonProcessorBase &proc) const = 0; virtual EdgesDelegate *processed_to_edges (const EdgePairToEdgeProcessorBase &proc) const = 0; + virtual RegionDelegate *pull_interacting (const Region &) const = 0; + virtual EdgesDelegate *pull_interacting (const Edges &) const = 0; + virtual EdgePairsDelegate *selected_interacting (const Region &other, size_t min_count, size_t max_count) const = 0; + virtual EdgePairsDelegate *selected_not_interacting (const Region &other, size_t min_count, size_t max_count) const = 0; + virtual EdgePairsDelegate *selected_interacting (const Edges &other, size_t min_count, size_t max_count) const = 0; + virtual EdgePairsDelegate *selected_not_interacting (const Edges &other, size_t min_count, size_t max_count) const = 0; + virtual std::pair selected_interacting_pair (const Region &other, size_t min_count, size_t max_count) const = 0; + virtual std::pair selected_interacting_pair (const Edges &other, size_t min_count, size_t max_count) const = 0; + + virtual EdgePairsDelegate *selected_outside (const Region &other) const = 0; + virtual EdgePairsDelegate *selected_not_outside (const Region &other) const = 0; + virtual std::pair selected_outside_pair (const Region &other) const = 0; + virtual EdgePairsDelegate *selected_inside (const Region &other) const = 0; + virtual EdgePairsDelegate *selected_not_inside (const Region &other) const = 0; + virtual std::pair selected_inside_pair (const Region &other) const = 0; + virtual RegionDelegate *polygons (db::Coord e) const = 0; virtual EdgesDelegate *edges () const = 0; virtual EdgesDelegate *first_edges () const = 0; diff --git a/src/db/db/dbEmptyEdgePairs.cc b/src/db/db/dbEmptyEdgePairs.cc index d9468ef93..e9f2aa2a1 100644 --- a/src/db/db/dbEmptyEdgePairs.cc +++ b/src/db/db/dbEmptyEdgePairs.cc @@ -65,6 +65,18 @@ EmptyEdgePairs::processed_to_edges (const EdgePairToEdgeProcessorBase &) const return new EmptyEdges (); } +RegionDelegate * +EmptyEdgePairs::pull_interacting (const Region &) const +{ + return new EmptyRegion (); +} + +EdgesDelegate * +EmptyEdgePairs::pull_interacting (const Edges &) const +{ + return new EmptyEdges (); +} + EdgesDelegate * EmptyEdgePairs::edges () const { diff --git a/src/db/db/dbEmptyEdgePairs.h b/src/db/db/dbEmptyEdgePairs.h index 16be5fa99..d74697533 100644 --- a/src/db/db/dbEmptyEdgePairs.h +++ b/src/db/db/dbEmptyEdgePairs.h @@ -61,6 +61,22 @@ public: virtual RegionDelegate *processed_to_polygons (const EdgePairToPolygonProcessorBase &filter) const; virtual EdgesDelegate *processed_to_edges (const EdgePairToEdgeProcessorBase &filter) const; + virtual RegionDelegate *pull_interacting (const Region &) const; + virtual EdgesDelegate *pull_interacting (const Edges &) const; + virtual EdgePairsDelegate *selected_interacting (const Region &, size_t, size_t) const { return new EmptyEdgePairs (); } + virtual EdgePairsDelegate *selected_not_interacting (const Region &, size_t, size_t) const { return new EmptyEdgePairs (); } + virtual EdgePairsDelegate *selected_interacting (const Edges &, size_t, size_t) const { return new EmptyEdgePairs (); } + virtual EdgePairsDelegate *selected_not_interacting (const Edges &, size_t, size_t) const { return new EmptyEdgePairs (); } + virtual std::pair selected_interacting_pair (const Region &, size_t, size_t) const { return std::make_pair (new EmptyEdgePairs (), new EmptyEdgePairs ()); } + virtual std::pair selected_interacting_pair (const Edges &, size_t, size_t) const { return std::make_pair (new EmptyEdgePairs (), new EmptyEdgePairs ()); } + + virtual EdgePairsDelegate *selected_outside (const Region &) const { return new EmptyEdgePairs (); } + virtual EdgePairsDelegate *selected_not_outside (const Region &) const { return new EmptyEdgePairs (); } + virtual std::pair selected_outside_pair (const Region &) const { return std::make_pair (new EmptyEdgePairs (), new EmptyEdgePairs ()); } + virtual EdgePairsDelegate *selected_inside (const Region &) const { return new EmptyEdgePairs (); } + virtual EdgePairsDelegate *selected_not_inside (const Region &) const { return new EmptyEdgePairs (); } + virtual std::pair selected_inside_pair (const Region &) const { return std::make_pair (new EmptyEdgePairs (), new EmptyEdgePairs ()); } + virtual RegionDelegate *polygons (db::Coord e) const; virtual EdgesDelegate *edges () const; virtual EdgesDelegate *first_edges () const;