From 0d04937c9112f3d4516d667c960adc57ffec8dd3 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 5 Mar 2021 16:27:57 +0100 Subject: [PATCH] Added tests for fill tool --- src/db/db/dbFillTool.cc | 12 ++--- src/db/unit_tests/dbFillToolTests.cc | 63 +++++++++++++++++++++++++++ testdata/algo/fill_tool1.gds | Bin 416 -> 416 bytes testdata/algo/fill_tool2.gds | Bin 0 -> 480 bytes testdata/algo/fill_tool3.gds | Bin 0 -> 480 bytes testdata/algo/fill_tool_au1.gds | Bin 0 -> 938 bytes testdata/algo/fill_tool_au2.gds | Bin 0 -> 1372 bytes testdata/algo/fill_tool_au3.gds | Bin 0 -> 1740 bytes 8 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 testdata/algo/fill_tool2.gds create mode 100644 testdata/algo/fill_tool3.gds create mode 100644 testdata/algo/fill_tool_au1.gds create mode 100644 testdata/algo/fill_tool_au2.gds create mode 100644 testdata/algo/fill_tool_au3.gds 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 540163aa2058e100a5edee876f1e7854de786ccb..0bcaec0c49f85e33a9681de30e6823deeb751179 100644 GIT binary patch delta 157 zcmZ3$yntDWfsKKQDS|U@~A};M@RH3Z_{E85mgDftZB>0C(jb AV*mgE delta 156 zcmZ3$yntDWfsKKQDS|HqLR8GreM@uOu@+j@amz`*#5fr0r7j0TAVF%MXtMUVk#H4w8f005}6Ao2hJ diff --git a/testdata/algo/fill_tool2.gds b/testdata/algo/fill_tool2.gds new file mode 100644 index 0000000000000000000000000000000000000000..c2e2214731697fb716fc546779dbb4b4b68ce747 GIT binary patch literal 480 zcmaKoKTiTd5XIl^?(H3kA|#d+d;k-Ojj=KD4|7pr9}o*jQRpQ`q?#w4k#kRDJ?W zDl226jXj|=F|2R7n}CHBZ+@GZeX}zQ3#BemiB$3hjTi@Lz-*t9D(gC@z@d&?C-=wQ zm#0PZ{JA!HxEi1m|L-eWd(m<3`mF67U{b*DD=-#Atd_L*{*f97GIK-S2_+v0Q{MR1 zAOD>7DK)3BLG^`_56t`tc21jGJLu6ab4K|)qml-aTkn5{fk0#c{VMc+rKmk2YfIL? zdG`Z|-#64pY(8c^r>X;mDUeb6uerUi%)$TS*L_l}jL92&�V|C)a-NYYct?m`88g literal 0 HcmV?d00001 diff --git a/testdata/algo/fill_tool_au1.gds b/testdata/algo/fill_tool_au1.gds new file mode 100644 index 0000000000000000000000000000000000000000..1cd62ae2c74a47c2939822f751326440877ea89c GIT binary patch literal 938 zcma))yGjE=6o&tuot@oyiB~Kng{>eMY{W+J3eiO^Qiz2%mX=l)DeQa$K?^(EU?Dz% zm87y11VIZcu@i#pKQkF-Q)FXt=3C~>x97|S3PS9o5{UR6AtH=m7E%5iiBM^66_^a8 z<&}%Y?Z?}%rS*sTo2!F5Dp7B*tkh;LO^?<#(iD&hpoRrFmi0I{8fIB`&1h(H=9qEr z=;k#c$Gk7P{1)>~MvLA8W6#meYg#`>VYi7=^7-$i`F^@o~3Ald7) rBX=zrLypXSGxx)_ue`4p&v1s_Hkj{FRDn{Hbq(GB4NV_>xl-Z}{_))N literal 0 HcmV?d00001 diff --git a/testdata/algo/fill_tool_au2.gds b/testdata/algo/fill_tool_au2.gds new file mode 100644 index 0000000000000000000000000000000000000000..a28cfd4c12ee7ea32988bffff6f6371b96579299 GIT binary patch literal 1372 zcmbW1ze^lJ7>3`Qot@p&z3*;_-=3&t84sI2)V#`n0w7ZVt`(X0N8y%b6@&n4HcsK&F6tD8SE} z{v4`Dd7gh^tZH&)k@3ONt!qL)^1k@bKj8j0=n+!LYi81qU#`L85x719v$&Omu3<<<1rDoNbm5;{swd$Xx5mX9ZhL+%F$w$2-zX0HRC>GhU{P#=gG1#&)>~od-mSPyF zZZmH|cm0ClGvn&uGsp91x9ZX``N|k-SBnmFFpnrh)g&+YD)F>=jQ6z|4$z9@tA}dW|%%NLX6u&p;n??K?_9uuLc-x3W4&Az<_y9didZcl0Vre&a5O@huc`lsapfxp|fuKZE(0 z>N6~FViF^knRyy_q@F&fnxZpF^6Qu)+I%XSb;v9X(e04E1@?aO?FVXkm!r1qPH);w5pDctZTGqb+~? z;y$30`&~W?Qg502+Inr#_UWHG3OeZZSv`+lTmiW=+E2af-mG2E_S@Al;&imOQhPR! z@P?g7IOY18ql}`fkNkt+3Dzs%DR3?GUjN~R@ zoMs)}q28xn@C7}X