Bug fixes, tests.

This commit is contained in:
Matthias Koefferlein 2022-08-30 00:23:22 +02:00
parent f92d86a1e1
commit e591d205c7
3 changed files with 229 additions and 23 deletions

View File

@ -1320,10 +1320,10 @@ public:
virtual OnEmptyIntruderHint on_empty_intruder_hint () const
{
if (m_output_mode != Normal) {
return Copy;
if (m_mode == EdgesOutside) {
return m_output_mode == Both ? Copy : (m_output_mode == Inverse ? Drop : Copy);
} else {
return Drop;
return m_output_mode == Both ? CopyToSecond : (m_output_mode == Inverse ? Copy : Drop);
}
}
@ -1472,16 +1472,41 @@ public:
virtual OnEmptyIntruderHint on_empty_intruder_hint () const
{
if (m_output_mode != Normal) {
return Copy;
if (m_mode == EdgesOutside) {
return m_output_mode == Both ? Copy : (m_output_mode == Inverse ? Drop : Copy);
} else {
return Drop;
return m_output_mode == Both ? CopyToSecond : (m_output_mode == Inverse ? Copy : Drop);
}
}
virtual std::string description () const
{
return tl::to_string (tr ("Select interacting edges"));
if (m_mode == EdgesInteract) {
if (m_output_mode == Inverse) {
return tl::to_string (tr ("Select non-interacting edges"));
} else if (m_output_mode == Normal) {
return tl::to_string (tr ("Select interacting edges"));
} else {
return tl::to_string (tr ("Select interacting and non-interacting edges"));
}
} else if (m_mode == EdgesInside) {
if (m_output_mode == Inverse) {
return tl::to_string (tr ("Select non-inside edges"));
} else if (m_output_mode == Normal) {
return tl::to_string (tr ("Select inside edges"));
} else {
return tl::to_string (tr ("Select inside and non-inside edges"));
}
} else if (m_mode == EdgesOutside) {
if (m_output_mode == Inverse) {
return tl::to_string (tr ("Select non-outside edges"));
} else if (m_output_mode == Normal) {
return tl::to_string (tr ("Select outside edges"));
} else {
return tl::to_string (tr ("Select outside and non-outside edges"));
}
}
return std::string ();
}
private:

View File

@ -430,7 +430,7 @@ EdgeToPolygonLocalOperation::EdgeToPolygonLocalOperation (EdgePolygonOp::mode_t
OnEmptyIntruderHint
EdgeToPolygonLocalOperation::on_empty_intruder_hint () const
{
return (m_op != EdgePolygonOp::Inside) ? Copy : Drop;
return m_op == EdgePolygonOp::Inside ? Drop : (m_op == EdgePolygonOp::Outside ? Copy : CopyToSecond);
}
std::string

View File

@ -590,18 +590,8 @@ TEST(10_PullInteracting)
db::compare_layouts (_this, target, tl::testdata () + "/algo/deep_edges_au10.gds");
}
TEST(11_SelectedInside)
TEST(11_SelectedInsideWithRegion)
{
db::DeepShapeStore dss;
db::Layout ly (0.001);
ly.add_cell ("TOP");
unsigned int l1 = ly.insert_layer ();
unsigned int l2 = ly.insert_layer ();
db::cell_index_type top_cell_index = *ly.begin_top_down ();
db::Cell &top_cell = ly.cell (top_cell_index);
db::Edges e;
e.insert (db::Edge (0, 0, 0, 1000));
e.insert (db::Edge (100, 0, 100, 3000));
@ -616,16 +606,28 @@ TEST(11_SelectedInside)
e.insert (db::Edge (1800, 2500, 1800, 3500));
e.insert (db::Edge (-1500, 0, -1500, 1000));
// make deep
e.insert_into (&ly, top_cell.cell_index (), l1);
e = db::Edges (db::RecursiveShapeIterator (ly, top_cell, l1), dss);
db::Region r;
r.insert (db::Box (0, -1000, 2000, 0));
r.insert (db::Box (1000, 1000, 2000, 2000));
// make deep
db::DeepShapeStore dss;
db::Layout ly (0.001);
ly.add_cell ("TOP");
unsigned int l1 = ly.insert_layer ();
unsigned int l2 = ly.insert_layer ();
db::cell_index_type top_cell_index = *ly.begin_top_down ();
db::Cell &top_cell = ly.cell (top_cell_index);
e.insert_into (&ly, top_cell.cell_index (), l1);
db::Edges eflat = e;
e = db::Edges (db::RecursiveShapeIterator (ly, top_cell, l1), dss);
r.insert_into (&ly, top_cell.cell_index (), l2);
db::Region rflat = r;
r = db::Region (db::RecursiveShapeIterator (ly, top_cell, l2), dss);
EXPECT_EQ (db::compare (e.selected_inside (db::Region ()), ""), true);
@ -637,9 +639,188 @@ TEST(11_SelectedInside)
EXPECT_EQ (db::compare (db::Edges ().selected_inside_differential (r).first, ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_inside_differential (r).second, ""), true);
EXPECT_EQ (db::compare (e.selected_inside (r), "(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1600,-800;1600,-200)"), true);
EXPECT_EQ (db::compare (e.selected_inside (rflat), "(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1600,-800;1600,-200)"), true);
EXPECT_EQ (db::compare (eflat.selected_inside (r), "(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1600,-800;1600,-200)"), true);
EXPECT_EQ (db::compare (e.selected_not_inside (r), "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1500,1000;1500,2100);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_not_inside (rflat), "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1500,1000;1500,2100);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (eflat.selected_not_inside (r), "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1500,1000;1500,2100);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_inside_differential (r).first, "(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1600,-800;1600,-200)"), true);
EXPECT_EQ (db::compare (e.selected_inside_differential (rflat).first, "(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1600,-800;1600,-200)"), true);
EXPECT_EQ (db::compare (eflat.selected_inside_differential (r).first, "(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1600,-800;1600,-200)"), true);
EXPECT_EQ (db::compare (e.selected_inside_differential (r).second, "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1500,1000;1500,2100);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_inside_differential (rflat).second, "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1500,1000;1500,2100);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (eflat.selected_inside_differential (r).second, "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1500,1000;1500,2100);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
}
TEST(11_SelectedInsideWithEdges)
{
db::Edges e;
e.insert (db::Edge (0, 0, 0, 1000));
e.insert (db::Edge (100, 0, 100, 3000));
e.insert (db::Edge (1100, -1000, 1100, 2000));
e.insert (db::Edge (1200, -1000, 1200, 0));
e.insert (db::Edge (1300, -800, 1300, -200));
e.insert (db::Edge (1400, 1000, 1400, 1100));
e.insert (db::Edge (1500, 1000, 1500, 2100));
e.insert (db::Edge (1600, -800, 1600, -400));
e.insert (db::Edge (1600, -400, 1600, -200));
e.insert (db::Edge (1700, 1500, 1600, 2500));
e.insert (db::Edge (1800, 2500, 1800, 3500));
e.insert (db::Edge (-1500, 0, -1500, 1000));
db::Edges ee;
for (int i = 0; i <= 2000; i += 100) {
ee.insert (db::Edge (i, -1000, i, 0));
}
for (int i = 1000; i <= 2000; i += 100) {
ee.insert (db::Edge (i, 1000, i, 2000));
}
// make deep
db::DeepShapeStore dss;
db::Layout ly (0.001);
ly.add_cell ("TOP");
unsigned int l1 = ly.insert_layer ();
unsigned int l2 = ly.insert_layer ();
db::cell_index_type top_cell_index = *ly.begin_top_down ();
db::Cell &top_cell = ly.cell (top_cell_index);
e.insert_into (&ly, top_cell.cell_index (), l1);
db::Edges eflat = e;
e = db::Edges (db::RecursiveShapeIterator (ly, top_cell, l1), dss);
ee.insert_into (&ly, top_cell.cell_index (), l2);
db::Edges eeflat = ee;
ee = db::Edges (db::RecursiveShapeIterator (ly, top_cell, l2), dss);
EXPECT_EQ (db::compare (e.selected_inside (db::Edges ()), ""), true);
EXPECT_EQ (db::compare (e.selected_not_inside (db::Edges ()), "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1500,1000;1500,2100);(1600,-800;1600,-200);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_inside_differential (db::Edges ()).first, ""), true);
EXPECT_EQ (db::compare (e.selected_inside_differential (db::Edges ()).second, "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1500,1000;1500,2100);(1600,-800;1600,-200);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (db::Edges ().selected_inside (ee), ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_not_inside (ee), ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_inside_differential (ee).first, ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_inside_differential (ee).second, ""), true);
EXPECT_EQ (db::compare (e.selected_inside (ee), "(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1600,-800;1600,-200)"), true);
EXPECT_EQ (db::compare (e.selected_inside (eeflat), "(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1600,-800;1600,-200)"), true);
EXPECT_EQ (db::compare (eflat.selected_inside (ee), "(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1600,-800;1600,-200)"), true);
EXPECT_EQ (db::compare (e.selected_not_inside (ee), "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1500,1000;1500,2100);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_inside_differential (ee).first, "(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1600,-800;1600,-200)"), true);
EXPECT_EQ (db::compare (e.selected_inside_differential (ee).second, "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1500,1000;1500,2100);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
}
TEST(12_SelectedOutsideWithRegion)
{
db::Edges e;
e.insert (db::Edge (0, 0, 0, 1000));
e.insert (db::Edge (100, 0, 100, 3000));
e.insert (db::Edge (1100, -1000, 1100, 2000));
e.insert (db::Edge (1200, -1000, 1200, 0));
e.insert (db::Edge (1300, -800, 1300, -200));
e.insert (db::Edge (1400, 1000, 1400, 1100));
e.insert (db::Edge (1500, 1000, 1500, 2100));
e.insert (db::Edge (1600, -800, 1600, -400));
e.insert (db::Edge (1600, -400, 1600, -200));
e.insert (db::Edge (1700, 1500, 1600, 2500));
e.insert (db::Edge (1800, 2500, 1800, 3500));
e.insert (db::Edge (-1500, 0, -1500, 1000));
db::Region r;
r.insert (db::Box (0, -1000, 2000, 0));
r.insert (db::Box (1000, 1000, 2000, 2000));
// make deep
db::DeepShapeStore dss;
db::Layout ly (0.001);
ly.add_cell ("TOP");
unsigned int l1 = ly.insert_layer ();
unsigned int l2 = ly.insert_layer ();
db::cell_index_type top_cell_index = *ly.begin_top_down ();
db::Cell &top_cell = ly.cell (top_cell_index);
e.insert_into (&ly, top_cell.cell_index (), l1);
db::Edges eflat = e;
e = db::Edges (db::RecursiveShapeIterator (ly, top_cell, l1), dss);
r.insert_into (&ly, top_cell.cell_index (), l2);
db::Region rflat = r;
r = db::Region (db::RecursiveShapeIterator (ly, top_cell, l2), dss);
EXPECT_EQ (db::compare (e.selected_outside (db::Region ()), "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1500,1000;1500,2100);(1600,-800;1600,-200);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_not_outside (db::Region ()), ""), true);
EXPECT_EQ (db::compare (e.selected_outside_differential (db::Region ()).first, "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1500,1000;1500,2100);(1600,-800;1600,-200);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_outside_differential (db::Region ()).second, ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_outside (r), ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_not_outside (r), ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_outside_differential (r).first, ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_outside_differential (r).second, ""), true);
EXPECT_EQ (db::compare (e.selected_outside (r), "(0,0;0,1000);(100,0;100,3000);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_not_outside (r), "(1100,-1000;1100,2000);(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1500,1000;1500,2100);(1600,-800;1600,-200);(1700,1500;1600,2500)"), true);
EXPECT_EQ (db::compare (e.selected_outside_differential (r).first, "(0,0;0,1000);(100,0;100,3000);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_outside_differential (r).second, "(1100,-1000;1100,2000);(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1500,1000;1500,2100);(1600,-800;1600,-200);(1700,1500;1600,2500)"), true);
}
TEST(13_SelectedOutsideWithEdges)
{
db::Edges e;
e.insert (db::Edge (0, 0, 0, 1000));
e.insert (db::Edge (100, 0, 100, 3000));
e.insert (db::Edge (1100, -1000, 1100, 2000));
e.insert (db::Edge (1200, -1000, 1200, 0));
e.insert (db::Edge (1300, -800, 1300, -200));
e.insert (db::Edge (1400, 1000, 1400, 1100));
e.insert (db::Edge (1500, 1000, 1500, 2100));
e.insert (db::Edge (1600, -800, 1600, -400));
e.insert (db::Edge (1600, -400, 1600, -200));
e.insert (db::Edge (1700, 1500, 1600, 2500));
e.insert (db::Edge (1800, 2500, 1800, 3500));
e.insert (db::Edge (-1500, 0, -1500, 1000));
db::Edges ee;
for (int i = 0; i <= 2000; i += 100) {
ee.insert (db::Edge (i, -1000, i, 0));
}
for (int i = 1000; i <= 2000; i += 100) {
ee.insert (db::Edge (i, 1000, i, 2000));
}
// make deep
db::DeepShapeStore dss;
db::Layout ly (0.001);
ly.add_cell ("TOP");
unsigned int l1 = ly.insert_layer ();
unsigned int l2 = ly.insert_layer ();
db::cell_index_type top_cell_index = *ly.begin_top_down ();
db::Cell &top_cell = ly.cell (top_cell_index);
e.insert_into (&ly, top_cell.cell_index (), l1);
db::Edges eflat = e;
e = db::Edges (db::RecursiveShapeIterator (ly, top_cell, l1), dss);
ee.insert_into (&ly, top_cell.cell_index (), l2);
db::Edges eeflat = ee;
ee = db::Edges (db::RecursiveShapeIterator (ly, top_cell, l2), dss);
EXPECT_EQ (db::compare (e.selected_outside (db::Edges ()), "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1500,1000;1500,2100);(1600,-800;1600,-200);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_not_outside (db::Edges ()), ""), true);
EXPECT_EQ (db::compare (e.selected_outside_differential (db::Edges ()).first, "(0,0;0,1000);(100,0;100,3000);(1100,-1000;1100,2000);(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1500,1000;1500,2100);(1600,-800;1600,-200);(1700,1500;1600,2500);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_outside_differential (db::Edges ()).second, ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_outside (ee), ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_not_outside (ee), ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_outside_differential (ee).first, ""), true);
EXPECT_EQ (db::compare (db::Edges ().selected_outside_differential (ee).second, ""), true);
EXPECT_EQ (db::compare (e.selected_outside (ee), "(0,0;0,1000);(100,0;100,3000);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_not_outside (ee), "(1100,-1000;1100,2000);(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1500,1000;1500,2100);(1600,-800;1600,-200);(1700,1500;1600,2500)"), true);
EXPECT_EQ (db::compare (e.selected_outside_differential (ee).first, "(0,0;0,1000);(100,0;100,3000);(1800,2500;1800,3500);(-1500,0;-1500,1000)"), true);
EXPECT_EQ (db::compare (e.selected_outside_differential (ee).second, "(1100,-1000;1100,2000);(1200,-1000;1200,0);(1300,-800;1300,-200);(1400,1000;1400,1100);(1500,1000;1500,2100);(1600,-800;1600,-200);(1700,1500;1600,2500)"), true);
}