mirror of https://github.com/KLayout/klayout.git
Trying to reduce memory overhead of tiling processor - using box objects when possible
This commit is contained in:
parent
bcaefefded
commit
ffbcfc5490
|
|
@ -78,6 +78,15 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator() (const db::Box &box)
|
||||||
|
{
|
||||||
|
if (m_healing && ! box.inside (mp_tile->enlarged (db::Vector (-1, -1)))) {
|
||||||
|
mp_receiver->keep_for_healing (db::Polygon (box));
|
||||||
|
} else {
|
||||||
|
m_count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size_t count () const
|
size_t count () const
|
||||||
{
|
{
|
||||||
return m_count;
|
return m_count;
|
||||||
|
|
@ -167,6 +176,15 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator() (const db::Box &box)
|
||||||
|
{
|
||||||
|
if (m_healing && ! box.inside (mp_tile->enlarged (db::Vector (-1, -1)))) {
|
||||||
|
mp_receiver->keep_for_healing (*mp_trans * db::Polygon (box));
|
||||||
|
} else {
|
||||||
|
mp_receiver->output (*mp_trans * db::Polygon (box));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const db::Box *mp_tile;
|
const db::Box *mp_tile;
|
||||||
bool m_healing;
|
bool m_healing;
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,27 @@ private:
|
||||||
TilingProcessor *mp_proc;
|
TilingProcessor *mp_proc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delivery of tiling processor output
|
||||||
|
* This utility is put between the container and the receiver.
|
||||||
|
* The inserter is an object having an operator() that takes the object.
|
||||||
|
* This function is responsible for preparing (i.e. clipping) and delivering the output.
|
||||||
|
*/
|
||||||
|
template <class X>
|
||||||
|
void insert (X &inserter, const db::Box &o, const db::Box &tile, bool clip)
|
||||||
|
{
|
||||||
|
if (clip) {
|
||||||
|
// clipping
|
||||||
|
db::Box oc = o & tile;
|
||||||
|
if (! oc.empty () && oc.width () > 0 && oc.height () > 0) {
|
||||||
|
inserter (oc);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// no clipping
|
||||||
|
inserter (o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delivery of tiling processor output
|
* @brief Delivery of tiling processor output
|
||||||
* This utility is put between the container and the receiver.
|
* This utility is put between the container and the receiver.
|
||||||
|
|
@ -144,7 +165,10 @@ private:
|
||||||
template <class X>
|
template <class X>
|
||||||
void insert (X &inserter, const db::Polygon &o, const db::Box &tile, bool clip)
|
void insert (X &inserter, const db::Polygon &o, const db::Box &tile, bool clip)
|
||||||
{
|
{
|
||||||
if (clip && ! o.box ().inside (tile)) {
|
if (o.is_box ()) {
|
||||||
|
// simple case: box
|
||||||
|
insert (inserter, o.box (), tile, clip);
|
||||||
|
} else if (clip && ! o.box ().inside (tile)) {
|
||||||
// apply clipping
|
// apply clipping
|
||||||
if (o.box ().touches (tile)) {
|
if (o.box ().touches (tile)) {
|
||||||
std::vector <db::Polygon> clipped_poly;
|
std::vector <db::Polygon> clipped_poly;
|
||||||
|
|
@ -168,7 +192,10 @@ void insert (X &inserter, const db::Polygon &o, const db::Box &tile, bool clip)
|
||||||
template <class X>
|
template <class X>
|
||||||
void insert (X &inserter, const db::SimplePolygon &o, const db::Box &tile, bool clip)
|
void insert (X &inserter, const db::SimplePolygon &o, const db::Box &tile, bool clip)
|
||||||
{
|
{
|
||||||
if (clip && ! o.box ().inside (tile)) {
|
if (o.is_box ()) {
|
||||||
|
// simple case: box
|
||||||
|
insert (inserter, o.box (), tile, clip);
|
||||||
|
} else if (clip && ! o.box ().inside (tile)) {
|
||||||
// apply clipping
|
// apply clipping
|
||||||
if (o.box ().touches (tile)) {
|
if (o.box ().touches (tile)) {
|
||||||
std::vector <db::SimplePolygon> clipped_poly;
|
std::vector <db::SimplePolygon> clipped_poly;
|
||||||
|
|
@ -242,27 +269,6 @@ void insert (X &inserter, const db::Text &o, const db::Box &tile, bool clip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Delivery of tiling processor output
|
|
||||||
* This utility is put between the container and the receiver.
|
|
||||||
* The inserter is an object having an operator() that takes the object.
|
|
||||||
* This function is responsible for preparing (i.e. clipping) and delivering the output.
|
|
||||||
*/
|
|
||||||
template <class X>
|
|
||||||
void insert (X &inserter, const db::Box &o, const db::Box &tile, bool clip)
|
|
||||||
{
|
|
||||||
if (clip) {
|
|
||||||
// clipping
|
|
||||||
db::Box oc = o & tile;
|
|
||||||
if (! oc.empty ()) {
|
|
||||||
inserter (oc);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// no clipping
|
|
||||||
inserter (o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delivery of tiling processor output
|
* @brief Delivery of tiling processor output
|
||||||
* This utility is put between the container and the receiver.
|
* This utility is put between the container and the receiver.
|
||||||
|
|
|
||||||
|
|
@ -150,8 +150,8 @@ TEST(2)
|
||||||
tp.queue ("_tile && _output(o3, _tile, false)");
|
tp.queue ("_tile && _output(o3, _tile, false)");
|
||||||
tp.execute ("test");
|
tp.execute ("test");
|
||||||
|
|
||||||
EXPECT_EQ (to_s (ly, top, o1), "polygon (60,10;60,20;70,20;70,10);polygon (10,10;10,30;30,30;30,10)");
|
EXPECT_EQ (to_s (ly, top, o1), "box (60,10;70,20);box (10,10;30,30)");
|
||||||
EXPECT_EQ (to_s (ly, top, o2), "polygon (50,40;50,70;80,70;80,40)");
|
EXPECT_EQ (to_s (ly, top, o2), "box (50,40;80,70)");
|
||||||
EXPECT_EQ (to_s (ly, top, o3), "");
|
EXPECT_EQ (to_s (ly, top, o3), "");
|
||||||
|
|
||||||
ly.clear_layer (o1);
|
ly.clear_layer (o1);
|
||||||
|
|
@ -164,9 +164,9 @@ TEST(2)
|
||||||
|
|
||||||
tp.execute ("test");
|
tp.execute ("test");
|
||||||
|
|
||||||
EXPECT_EQ (to_s (ly, top, o1), "polygon (10,10;10,23;20,23;20,10);polygon (10,23;10,30;20,30;20,23);polygon (20,10;20,23;30,23;30,10);polygon (20,23;20,30;30,30;30,23);polygon (60,10;60,20;70,20;70,10)");
|
EXPECT_EQ (to_s (ly, top, o1), "box (10,10;20,23);box (10,23;20,30);box (20,10;30,23);box (20,23;30,30);box (60,10;70,20)");
|
||||||
EXPECT_EQ (to_s (ly, top, o2), "");
|
EXPECT_EQ (to_s (ly, top, o2), "");
|
||||||
EXPECT_EQ (to_s (ly, top, o3), "polygon (-5,-2;-5,23;20,23;20,-2);polygon (-5,23;-5,48;20,48;20,23);polygon (-5,48;-5,73;20,73;20,48);polygon (20,-2;20,23;45,23;45,-2);polygon (20,23;20,48;45,48;45,23);polygon (20,48;20,73;45,73;45,48);polygon (45,-2;45,23;70,23;70,-2);polygon (45,23;45,48;70,48;70,23);polygon (45,48;45,73;70,73;70,48);polygon (70,-2;70,23;95,23;95,-2);polygon (70,23;70,48;95,48;95,23);polygon (70,48;70,73;95,73;95,48);polygon (95,-2;95,23;120,23;120,-2);polygon (95,23;95,48;120,48;120,23);polygon (95,48;95,73;120,73;120,48);polygon (120,-2;120,23;145,23;145,-2);polygon (120,23;120,48;145,48;145,23);polygon (120,48;120,73;145,73;145,48)");
|
EXPECT_EQ (to_s (ly, top, o3), "box (-5,-2;20,23);box (-5,23;20,48);box (-5,48;20,73);box (20,-2;45,23);box (20,23;45,48);box (20,48;45,73);box (45,-2;70,23);box (45,23;70,48);box (45,48;70,73);box (70,-2;95,23);box (70,23;95,48);box (70,48;95,73);box (95,-2;120,23);box (95,23;120,48);box (95,48;120,73);box (120,-2;145,23);box (120,23;145,48);box (120,48;145,73)");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -185,8 +185,8 @@ TEST(2)
|
||||||
tp.queue ("_output(o3, _tile)");
|
tp.queue ("_output(o3, _tile)");
|
||||||
tp.execute ("test");
|
tp.execute ("test");
|
||||||
|
|
||||||
EXPECT_EQ (to_s (ly, top, o1), "polygon (60,10;60,20;70,20;70,10);polygon (10,10;10,30;30,30;30,10)");
|
EXPECT_EQ (to_s (ly, top, o1), "box (60,10;70,20);box (10,10;30,30)");
|
||||||
EXPECT_EQ (to_s (ly, top, o2), "polygon (50,40;50,70;80,70;80,40)");
|
EXPECT_EQ (to_s (ly, top, o2), "box (50,40;80,70)");
|
||||||
EXPECT_EQ (to_s (ly, top, o3), "");
|
EXPECT_EQ (to_s (ly, top, o3), "");
|
||||||
|
|
||||||
ly.clear_layer (o1);
|
ly.clear_layer (o1);
|
||||||
|
|
@ -199,9 +199,9 @@ TEST(2)
|
||||||
|
|
||||||
tp.execute ("test");
|
tp.execute ("test");
|
||||||
|
|
||||||
EXPECT_EQ (to_s (ly, top, o1), "polygon (10,10;10,23;20,23;20,10);polygon (10,23;10,30;20,30;20,23);polygon (20,10;20,23;30,23;30,10);polygon (20,23;20,30;30,30;30,23);polygon (60,10;60,20;70,20;70,10)");
|
EXPECT_EQ (to_s (ly, top, o1), "box (10,10;20,23);box (10,23;20,30);box (20,10;30,23);box (20,23;30,30);box (60,10;70,20)");
|
||||||
EXPECT_EQ (to_s (ly, top, o2), "");
|
EXPECT_EQ (to_s (ly, top, o2), "");
|
||||||
EXPECT_EQ (to_s (ly, top, o3), "polygon (-5,-2;-5,23;20,23;20,-2);polygon (-5,23;-5,48;20,48;20,23);polygon (-5,48;-5,73;20,73;20,48);polygon (20,-2;20,23;45,23;45,-2);polygon (20,23;20,48;45,48;45,23);polygon (20,48;20,73;45,73;45,48);polygon (45,-2;45,23;70,23;70,-2);polygon (45,23;45,48;70,48;70,23);polygon (45,48;45,73;70,73;70,48);polygon (70,-2;70,23;95,23;95,-2);polygon (70,23;70,48;95,48;95,23);polygon (70,48;70,73;95,73;95,48);polygon (95,-2;95,23;120,23;120,-2);polygon (95,23;95,48;120,48;120,23);polygon (95,48;95,73;120,73;120,48);polygon (120,-2;120,23;145,23;145,-2);polygon (120,23;120,48;145,48;145,23);polygon (120,48;120,73;145,73;145,48)");
|
EXPECT_EQ (to_s (ly, top, o3), "box (-5,-2;20,23);box (-5,23;20,48);box (-5,48;20,73);box (20,-2;45,23);box (20,23;45,48);box (20,48;45,73);box (45,-2;70,23);box (45,23;70,48);box (45,48;70,73);box (70,-2;95,23);box (70,23;95,48);box (70,48;95,73);box (95,-2;120,23);box (95,23;120,48);box (95,48;120,73);box (120,-2;145,23);box (120,23;145,48);box (120,48;145,73)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -348,8 +348,8 @@ TEST(4)
|
||||||
tp.execute ("test");
|
tp.execute ("test");
|
||||||
|
|
||||||
EXPECT_EQ (to_s (o, topo, l1o), "");
|
EXPECT_EQ (to_s (o, topo, l1o), "");
|
||||||
EXPECT_EQ (to_s (o, topo, l2o), "polygon (1000,2000;1000,4000;3000,4000;3000,2000)");
|
EXPECT_EQ (to_s (o, topo, l2o), "box (1000,2000;3000,4000)");
|
||||||
EXPECT_EQ (to_s (o, topo, l3o), "polygon (1000,2000;1000,4000;3000,4000;3000,2000)");
|
EXPECT_EQ (to_s (o, topo, l3o), "box (1000,2000;3000,4000)");
|
||||||
|
|
||||||
o.clear_layer (l1o);
|
o.clear_layer (l1o);
|
||||||
o.clear_layer (l2o);
|
o.clear_layer (l2o);
|
||||||
|
|
@ -359,8 +359,8 @@ TEST(4)
|
||||||
tp.execute ("test");
|
tp.execute ("test");
|
||||||
|
|
||||||
EXPECT_EQ (to_s (o, topo, l1o), "polygon (3000,2000;3000,4000;1000,4000;1000,4010;3010,4010;3010,2000)");
|
EXPECT_EQ (to_s (o, topo, l1o), "polygon (3000,2000;3000,4000;1000,4000;1000,4010;3010,4010;3010,2000)");
|
||||||
EXPECT_EQ (to_s (o, topo, l2o), "polygon (1000,2000;1000,4000;3000,4000;3000,2000)");
|
EXPECT_EQ (to_s (o, topo, l2o), "box (1000,2000;3000,4000)");
|
||||||
EXPECT_EQ (to_s (o, topo, l3o), "polygon (1000,2000;1000,4010;3010,4010;3010,2000)");
|
EXPECT_EQ (to_s (o, topo, l3o), "box (1000,2000;3010,4010)");
|
||||||
|
|
||||||
o.clear_layer (l1o);
|
o.clear_layer (l1o);
|
||||||
o.clear_layer (l2o);
|
o.clear_layer (l2o);
|
||||||
|
|
@ -370,7 +370,7 @@ TEST(4)
|
||||||
|
|
||||||
tp.execute ("test");
|
tp.execute ("test");
|
||||||
|
|
||||||
EXPECT_EQ (to_s (o, topo, l1o), "polygon (1000,4000;1000,4010;1510,4010;1510,4000);polygon (1510,4000;1510,4010;2510,4010;2510,4000);polygon (3000,2000;3000,2510;3010,2510;3010,2000);polygon (3000,2510;3000,3510;3010,3510;3010,2510);polygon (3000,3510;3000,4000;2510,4000;2510,4010;3010,4010;3010,3510)");
|
EXPECT_EQ (to_s (o, topo, l1o), "polygon (3000,3510;3000,4000;2510,4000;2510,4010;3010,4010;3010,3510);box (1000,4000;1510,4010);box (1510,4000;2510,4010);box (3000,2000;3010,2510);box (3000,2510;3010,3510)");
|
||||||
|
|
||||||
o.clear_layer (l1o);
|
o.clear_layer (l1o);
|
||||||
o.clear_layer (l2o);
|
o.clear_layer (l2o);
|
||||||
|
|
@ -380,9 +380,9 @@ TEST(4)
|
||||||
tp.set_scale_to_dbu (false);
|
tp.set_scale_to_dbu (false);
|
||||||
tp.execute ("test");
|
tp.execute ("test");
|
||||||
|
|
||||||
EXPECT_EQ (to_s (o, topo, l1o), "polygon (100,200;100,400;300,400;300,200);polygon (1000,2000;1000,4010;3010,4010;3010,2000)");
|
EXPECT_EQ (to_s (o, topo, l1o), "box (100,200;300,400);box (1000,2000;3010,4010)");
|
||||||
EXPECT_EQ (to_s (o, topo, l2o), "polygon (100,200;100,400;300,400;300,200)");
|
EXPECT_EQ (to_s (o, topo, l2o), "box (100,200;300,400)");
|
||||||
EXPECT_EQ (to_s (o, topo, l3o), "polygon (1000,2000;1000,4010;3010,4010;3010,2000)");
|
EXPECT_EQ (to_s (o, topo, l3o), "box (1000,2000;3010,4010)");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue