diff --git a/src/db/db/dbDeepEdges.cc b/src/db/db/dbDeepEdges.cc index 081ac4c99..61a88d447 100644 --- a/src/db/db/dbDeepEdges.cc +++ b/src/db/db/dbDeepEdges.cc @@ -108,6 +108,15 @@ DeepEdges::DeepEdges (const RecursiveShapeIterator &si, DeepShapeStore &dss, con set_merged_semantics (merged_semantics); } +DeepEdges::DeepEdges (const db::Edges &other, DeepShapeStore &dss) + : AsIfFlatEdges (), m_merged_edges () +{ + m_deep_layer = dss.create_from_flat (other); + + init (); + set_merged_semantics (other.merged_semantics ()); +} + DeepEdges::DeepEdges () : AsIfFlatEdges () { diff --git a/src/db/db/dbDeepEdges.h b/src/db/db/dbDeepEdges.h index a114d7e66..dd70bd590 100644 --- a/src/db/db/dbDeepEdges.h +++ b/src/db/db/dbDeepEdges.h @@ -43,6 +43,7 @@ class DB_PUBLIC DeepEdges { public: DeepEdges (); + DeepEdges (const db::Edges &other, DeepShapeStore &dss); DeepEdges (const RecursiveShapeIterator &si, DeepShapeStore &dss, bool as_edges = true); DeepEdges (const RecursiveShapeIterator &si, DeepShapeStore &dss, const db::ICplxTrans &trans, bool as_edges = true, bool merged_semantics = true); diff --git a/src/db/db/dbDeepRegion.cc b/src/db/db/dbDeepRegion.cc index d40612b17..2eb962283 100644 --- a/src/db/db/dbDeepRegion.cc +++ b/src/db/db/dbDeepRegion.cc @@ -1855,10 +1855,12 @@ DeepRegion::selected_interacting_generic (const Region &other, int mode, bool to // with these flag set to true, the resulting polygons are broken again. bool split_after = false; + std::auto_ptr dr_holder; const db::DeepRegion *other_deep = dynamic_cast (other.delegate ()); if (! other_deep) { - // @@@ turn into deep - return db::AsIfFlatRegion::selected_interacting_generic (other, mode, touching, inverse); + // if the other region isn't deep, turn into a top-level only deep region to facilitate re-hierarchisation + dr_holder.reset (new db::DeepRegion (other, const_cast (*deep_layer ().store ()))); + other_deep = dr_holder.get (); } ensure_merged_polygons_valid (); @@ -1890,10 +1892,12 @@ DeepRegion::selected_interacting_generic (const Edges &other, bool inverse) cons // with these flag set to true, the resulting polygons are broken again. bool split_after = false; + std::auto_ptr dr_holder; const db::DeepEdges *other_deep = dynamic_cast (other.delegate ()); if (! other_deep) { - // @@@ turn into deep - return db::AsIfFlatRegion::selected_interacting_generic (other, inverse); + // if the other region isn't deep, turn into a top-level only deep region to facilitate re-hierarchisation + dr_holder.reset (new db::DeepEdges (other, const_cast (*deep_layer ().store ()))); + other_deep = dr_holder.get (); } ensure_merged_polygons_valid (); @@ -1959,10 +1963,12 @@ DeepRegion::pull_generic (const Region &other, int mode, bool touching) const EdgesDelegate * DeepRegion::pull_generic (const Edges &other) const { + std::auto_ptr dr_holder; const db::DeepEdges *other_deep = dynamic_cast (other.delegate ()); if (! other_deep) { - // @@@ see above - return db::AsIfFlatRegion::pull_generic (other); + // if the other region isn't deep, turn into a top-level only deep region to facilitate re-hierarchisation + dr_holder.reset (new db::DeepEdges (other, const_cast (*deep_layer ().store ()))); + other_deep = dr_holder.get (); } ensure_merged_polygons_valid (); diff --git a/src/db/db/dbDeepShapeStore.cc b/src/db/db/dbDeepShapeStore.cc index 7fa787440..db8ce5d01 100644 --- a/src/db/db/dbDeepShapeStore.cc +++ b/src/db/db/dbDeepShapeStore.cc @@ -326,6 +326,36 @@ DeepLayer DeepShapeStore::create_from_flat (const db::Region ®ion, bool for_n return dl; } +DeepLayer DeepShapeStore::create_from_flat (const db::Edges &edges, const db::ICplxTrans &trans) +{ + // reuse existing layer + std::pair lff = layer_for_flat (tl::id_of (edges.delegate ())); + if (lff.first) { + return lff.second; + } + + require_singular (); + + unsigned int layer = layout ().insert_layer (); + + db::Shapes *shapes = &initial_cell ().shapes (layer); + db::Box world = db::Box::world (); + + db::EdgeBuildingHierarchyBuilderShapeReceiver eb (false); + + std::pair ii = edges.begin_iter (); + db::ICplxTrans ttop = trans * ii.second; + while (! ii.first.at_end ()) { + eb.push (*ii.first, ttop * ii.first.trans (), world, 0, shapes); + ++ii.first; + } + + DeepLayer dl (this, 0 /*singular layout index*/, layer); + m_layers_for_flat [tl::id_of (edges.delegate ())] = std::make_pair (dl.layout_index (), dl.layer ()); + m_flat_region_id [std::make_pair (dl.layout_index (), dl.layer ())] = tl::id_of (edges.delegate ()); + return dl; +} + std::pair DeepShapeStore::layer_for_flat (const db::Region ®ion) const { return layer_for_flat (tl::id_of (region.delegate ())); diff --git a/src/db/db/dbDeepShapeStore.h b/src/db/db/dbDeepShapeStore.h index 79c5c7495..0a5404f35 100644 --- a/src/db/db/dbDeepShapeStore.h +++ b/src/db/db/dbDeepShapeStore.h @@ -41,6 +41,7 @@ namespace db { class DeepShapeStore; class Region; +class Edges; /** * @brief Represents a shape collection from the deep shape store @@ -274,6 +275,17 @@ public: */ DeepLayer create_from_flat (const db::Region ®ion, bool for_netlist, double max_area_ratio = 0.0, size_t max_vertex_count = 0, const db::ICplxTrans &trans = db::ICplxTrans ()); + /** + * @brief Creates a new layer from a flat edge collection (or the edge collection is made flat) + * + * This method is intended for use with singular-created DSS objects (see + * singular constructor). + * + * After a flat layer has been created for a region, it can be retrieved + * from the region later with layer_for_flat (region). + */ + DeepLayer create_from_flat (const db::Edges ®ion, const db::ICplxTrans &trans = db::ICplxTrans ()); + /** * @brief Gets the layer for a given flat region. *