diff --git a/src/db/db/dbFillTool.cc b/src/db/db/dbFillTool.cc index 5c38bbf40..ce9126e21 100644 --- a/src/db/db/dbFillTool.cc +++ b/src/db/db/dbFillTool.cc @@ -383,15 +383,15 @@ rasterize_extended (const db::Polygon &fp, const db::Box &fc_bbox, db::AreaMap & } static db::IMatrix2d -compute_shear_matrix (const db::Vector &row_step, const db::Vector &column_step) +compute_shear_matrix (const db::Vector &r, const db::Vector &c) { - db::IMatrix2d mr = db::IMatrix2d (1.0, 0.0, -double (row_step.y ()) / double (row_step.x ()), 1.0); + double det = r.x () * c.y () - r.y () * c.x (); - double csy = column_step.y () + mr.m21 () * column_step.x (); + double m11 = c.y () * r.x () / det; + double m12 = -c.x () * r.x () / det; + double m22 = c.y () * r.x () / det; - db::IMatrix2d mc = db::IMatrix2d (1.0, -double (column_step.x ()) / csy, 0.0, 1.0); - - return mc * mr; + return IMatrix2d (m11, m12, m12, m22); } DB_PUBLIC bool diff --git a/src/db/unit_tests/dbFillToolTests.cc b/src/db/unit_tests/dbFillToolTests.cc index fbc6940a3..de3fa628b 100644 --- a/src/db/unit_tests/dbFillToolTests.cc +++ b/src/db/unit_tests/dbFillToolTests.cc @@ -52,3 +52,66 @@ TEST(1) db::compare_layouts (_this, ly, tl::testsrc () + "/testdata/algo/fill_tool_au1.gds"); } +TEST(2) +{ + db::Layout ly; + { + std::string fn (tl::testsrc ()); + fn += "/testdata/algo/fill_tool2.gds"; + tl::InputStream stream (fn); + db::Reader reader (stream); + reader.read (ly); + } + + db::cell_index_type fill_cell = ly.cell_by_name ("FILL_CELL").second; + db::cell_index_type top_cell = ly.cell_by_name ("TOP").second; + unsigned int fill_layer = ly.get_layer (db::LayerProperties (1, 0)); + + db::Region fill_region (db::RecursiveShapeIterator (ly, ly.cell (top_cell), fill_layer)); + + db::Region remaining_parts, remaining_polygons; + + db::fill_region (&ly.cell (top_cell), fill_region, fill_cell, ly.cell (fill_cell).bbox (), db::Point (), true, &remaining_parts, db::Vector (50, 100), &remaining_polygons); + + unsigned int l100 = ly.insert_layer (db::LayerProperties (100, 0)); + unsigned int l101 = ly.insert_layer (db::LayerProperties (101, 0)); + remaining_parts.insert_into (&ly, top_cell, l100); + remaining_polygons.insert_into (&ly, top_cell, l101); + + CHECKPOINT(); + db::compare_layouts (_this, ly, tl::testsrc () + "/testdata/algo/fill_tool_au2.gds"); +} + +TEST(3) +{ + db::Layout ly; + { + std::string fn (tl::testsrc ()); + fn += "/testdata/algo/fill_tool3.gds"; + tl::InputStream stream (fn); + db::Reader reader (stream); + reader.read (ly); + } + + db::cell_index_type fill_cell = ly.cell_by_name ("FILL_CELL").second; + db::cell_index_type top_cell = ly.cell_by_name ("TOP").second; + unsigned int fill_layer = ly.get_layer (db::LayerProperties (1, 0)); + + db::Region fill_region (db::RecursiveShapeIterator (ly, ly.cell (top_cell), fill_layer)); + + db::Region remaining_parts, remaining_polygons; + + db::Vector ko (-100, -130); + db::Vector rs (230, 40); + db::Vector cs (40, 230); + db::fill_region (&ly.cell (top_cell), fill_region, fill_cell, ko, rs, cs, db::Point (), true, &remaining_parts, db::Vector (50, 100), &remaining_polygons); + + unsigned int l100 = ly.insert_layer (db::LayerProperties (100, 0)); + unsigned int l101 = ly.insert_layer (db::LayerProperties (101, 0)); + remaining_parts.insert_into (&ly, top_cell, l100); + remaining_polygons.insert_into (&ly, top_cell, l101); + + CHECKPOINT(); + db::compare_layouts (_this, ly, tl::testsrc () + "/testdata/algo/fill_tool_au3.gds"); +} + diff --git a/testdata/algo/fill_tool1.gds b/testdata/algo/fill_tool1.gds index 540163aa2..0bcaec0c4 100644 Binary files a/testdata/algo/fill_tool1.gds and b/testdata/algo/fill_tool1.gds differ diff --git a/testdata/algo/fill_tool2.gds b/testdata/algo/fill_tool2.gds new file mode 100644 index 000000000..c2e221473 Binary files /dev/null and b/testdata/algo/fill_tool2.gds differ diff --git a/testdata/algo/fill_tool3.gds b/testdata/algo/fill_tool3.gds new file mode 100644 index 000000000..d2470efa0 Binary files /dev/null and b/testdata/algo/fill_tool3.gds differ diff --git a/testdata/algo/fill_tool_au1.gds b/testdata/algo/fill_tool_au1.gds new file mode 100644 index 000000000..1cd62ae2c Binary files /dev/null and b/testdata/algo/fill_tool_au1.gds differ diff --git a/testdata/algo/fill_tool_au2.gds b/testdata/algo/fill_tool_au2.gds new file mode 100644 index 000000000..a28cfd4c1 Binary files /dev/null and b/testdata/algo/fill_tool_au2.gds differ diff --git a/testdata/algo/fill_tool_au3.gds b/testdata/algo/fill_tool_au3.gds new file mode 100644 index 000000000..3d351b309 Binary files /dev/null and b/testdata/algo/fill_tool_au3.gds differ