diff --git a/src/db/db/dbDeepRegion.cc b/src/db/db/dbDeepRegion.cc index 9fa57117b..976c29b84 100644 --- a/src/db/db/dbDeepRegion.cc +++ b/src/db/db/dbDeepRegion.cc @@ -532,16 +532,53 @@ public: void erase (size_t cid, db::cell_index_type ci) { m_merged_cluster.erase (std::make_pair (cid, ci)); + m_property_id_per_cluster.erase (std::make_pair (cid, ci)); } private: std::map, db::Shapes> m_merged_cluster; + std::map, db::properties_id_type> m_property_id_per_cluster; unsigned int m_layer; db::Layout *mp_layout; const db::hier_clusters *mp_hc; bool m_min_coherence; db::EdgeProcessor m_ep; + db::properties_id_type property_id (size_t cid, db::cell_index_type ci, bool initial) + { + std::map, db::properties_id_type>::iterator s = m_property_id_per_cluster.find (std::make_pair (cid, ci)); + + // some sanity checks: initial clusters are single-use, are never generated twice and cannot be retrieved again + if (initial) { + tl_assert (s == m_property_id_per_cluster.end ()); + } + + if (s != m_property_id_per_cluster.end ()) { + return s->second; + } + + s = m_property_id_per_cluster.insert (std::make_pair (std::make_pair (cid, ci), db::properties_id_type (0))).first; + + const db::connected_clusters &cc = mp_hc->clusters_per_cell (ci); + const db::local_cluster &c = cc.cluster_by_id (cid); + + if (c.begin_attr () != c.end_attr ()) { + + s->second = *c.begin_attr (); + + } else { + + const db::connected_clusters::connections_type &conn = cc.connections_for_cluster (cid); + for (db::connected_clusters::connections_type::const_iterator i = conn.begin (); i != conn.end () && s->second == db::properties_id_type (0); ++i) { + s->second = property_id (i->id (), i->inst_cell_index (), false); + } + + } + + return s->second; + + } + db::Shapes &compute_merged (size_t cid, db::cell_index_type ci, bool initial, unsigned int min_wc) { std::map, db::Shapes>::iterator s = m_merged_cluster.find (std::make_pair (cid, ci)); @@ -557,6 +594,8 @@ private: s = m_merged_cluster.insert (std::make_pair (std::make_pair (cid, ci), db::Shapes (false))).first; + db::properties_id_type prop_id = property_id (cid, ci, initial); + const db::connected_clusters &cc = mp_hc->clusters_per_cell (ci); const db::local_cluster &c = cc.cluster_by_id (cid); @@ -608,7 +647,7 @@ private: // and run the merge step db::MergeOp op (min_wc); - db::PolygonRefToShapesGenerator pr (mp_layout, &s->second, c.begin_attr () == c.end_attr () ? db::properties_id_type (0) : *c.begin_attr ()); + db::PolygonRefToShapesGenerator pr (mp_layout, &s->second, prop_id); db::PolygonGenerator pg (pr, false /*don't resolve holes*/, m_min_coherence); m_ep.process (pg, op); diff --git a/testdata/algo/deep_region_au40.gds b/testdata/algo/deep_region_au40.gds index ad019dc23..2999bb979 100644 Binary files a/testdata/algo/deep_region_au40.gds and b/testdata/algo/deep_region_au40.gds differ