diff --git a/src/rdb/rdb/rdbUtils.cc b/src/rdb/rdb/rdbUtils.cc index 059de3d5f..bd905d100 100644 --- a/src/rdb/rdb/rdbUtils.cc +++ b/src/rdb/rdb/rdbUtils.cc @@ -103,10 +103,17 @@ public: virtual void begin (const db::RecursiveShapeIterator *iter) { - m_cell_stack.clear (); - db::cell_index_type ci = iter->top_cell ()->cell_index (); const rdb::Cell *rdb_cell = cell_for_id (iter->layout (), ci); + + if (! m_cell_stack.empty () && rdb_cell != m_cell_stack.front () && (rdb_cell->references ().begin () == rdb_cell->references ().end ())) { + // If the actual top cell is not the one specified, add a dummy reference so we find the real top cell under + // the given one. + // TODO: get rid of the const_cast + (const_cast (rdb_cell))->references ().insert (rdb::Reference (db::DCplxTrans (), m_cell_stack.front ()->id ())); + } + + m_cell_stack.clear (); m_cell_stack.push_back (rdb_cell); m_id_to_cell.insert (std::make_pair (ci, rdb_cell)); } diff --git a/testdata/ruby/rdbTest.rb b/testdata/ruby/rdbTest.rb index 4ecc4de36..3f436162e 100644 --- a/testdata/ruby/rdbTest.rb +++ b/testdata/ruby/rdbTest.rb @@ -789,6 +789,30 @@ class RDB_TestClass < TestBase rdb.each_cell { |c| cn << c.to_s_items } assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001),polygon: (0.01,0.021;0.01,0.051;0.031,0.051;0.031,0.021),polygon: (0.021,0.042;0.021,0.073;0.043,0.073;0.043,0.042)]") + rdb = RBA::ReportDatabase.new("neu") + cat = rdb.create_category("l1") + r = RBA::Region::new(c1.begin_shapes_rec(l1)) + cat.scan_region(rdb.create_cell("TOP"), RBA::CplxTrans::new(0.001), r) # hierarchical scan + assert_equal(cat.num_items, 3) + cn = [] + rdb.each_cell { |c| cn << c.to_s_test } + assert_equal(cn.join(";"), "TOP[];c1[TOP->r0 *1 0,0];c2[c1->r0 *1 0.01,0.02];c3[c1->r0 *1 0.021,0.041]") + cn = [] + rdb.each_cell { |c| cn << c.to_s_items } + assert_equal(cn.join(";"), "TOP[];c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)];c3[polygon: (0,0.001;0,0.032;0.022,0.032;0.022,0.001)]") + + rdb = RBA::ReportDatabase.new("neu") + cat = rdb.create_category("l1") + r = RBA::Region::new(c1.begin_shapes_rec(l1)) + cat.scan_region(rdb.create_cell("TOP"), RBA::CplxTrans::new(0.001), r, true) # flat scan + assert_equal(cat.num_items, 3) + cn = [] + rdb.each_cell { |c| cn << c.to_s_test } + assert_equal(cn.join(";"), "TOP[]") + cn = [] + rdb.each_cell { |c| cn << c.to_s_items } + assert_equal(cn.join(";"), "TOP[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001),polygon: (0.01,0.021;0.01,0.051;0.031,0.051;0.031,0.021),polygon: (0.021,0.042;0.021,0.073;0.043,0.073;0.043,0.042)]") + end # shape insertion from shape, shapes, recursive iterator