diff --git a/src/db/db/dbLayoutUtils.cc b/src/db/db/dbLayoutUtils.cc index 2a71a0c1a..5809458de 100644 --- a/src/db/db/dbLayoutUtils.cc +++ b/src/db/db/dbLayoutUtils.cc @@ -218,6 +218,7 @@ copy_or_propagate_shapes (db::Layout &target, db::Cell &target_cell = target.cell (cm->second); transformer->insert_transformed (target_cell.shapes (target_layer), source_cell.shapes (source_layer), trans * propagate_trans); + } } diff --git a/src/db/db/dbPolygon.h b/src/db/db/dbPolygon.h index 5835c0976..8ecadc16e 100644 --- a/src/db/db/dbPolygon.h +++ b/src/db/db/dbPolygon.h @@ -1581,7 +1581,7 @@ public: void translate (const polygon &d, const T &t, db::generic_repository &, db::ArrayRepository &) { *this = d; - transform (t); + transform (t, false); } /** diff --git a/src/db/unit_tests/dbLayoutTests.cc b/src/db/unit_tests/dbLayoutTests.cc index d7a503335..9b6178ca8 100644 --- a/src/db/unit_tests/dbLayoutTests.cc +++ b/src/db/unit_tests/dbLayoutTests.cc @@ -1009,3 +1009,34 @@ TEST(100_UndoOfDeleteLayer) EXPECT_EQ (l.get_properties (li).to_string (), "1/0"); EXPECT_EQ (l.get_properties (li2).to_string (), "2/0"); } + +// issue #2343 +TEST(101_CopyTreeDoesNotModifyPolygons) +{ + db::Manager m; + db::Layout l (&m); + db::Cell &top = l.cell (l.add_cell ("TOP")); + l.insert_layer (db::LayerProperties (1, 0)); + + std::unique_ptr t (new db::Layout ()); + db::Cell &ttop = t->cell (t->add_cell ("TOP")); + unsigned int tl1 = t->insert_layer (db::LayerProperties (1, 0)); + + std::vector pts = { + { 0, 0 }, { 0, 1000 }, { 500, 1000 }, { 1500, 1000 }, { 1000, 1000 }, { 1000, 0 } + }; + + db::Polygon poly; + poly.assign_hull (pts.begin (), pts.end (), false /*don't compress*/, false /*don't remove reflected*/); + ttop.shapes (tl1).insert (poly); + + EXPECT_EQ (l2s (*t), "begin_lib 0.001\nbegin_cell {TOP}\nboundary 1 0 {0 0} {0 1000} {500 1000} {1500 1000} {1000 1000} {1000 0} {0 0}\nend_cell\nend_lib\n"); + + db::CellMapping cm; + cm.create_single_mapping (l, top.cell_index (), *t, ttop.cell_index ()); + l.copy_tree_shapes (*t, cm); + + // polygon is still not normalized + EXPECT_EQ (l2s (l), "begin_lib 0.001\nbegin_cell {TOP}\nboundary 1 0 {0 0} {0 1000} {500 1000} {1500 1000} {1000 1000} {1000 0} {0 0}\nend_cell\nend_lib\n"); +} +