Restored performance of some checks

This commit is contained in:
Matthias Koefferlein 2021-11-09 21:55:55 +01:00
parent ac1167278e
commit 379a22c86a
3 changed files with 80 additions and 5 deletions

View File

@ -468,6 +468,34 @@ poly2poly_check<PolygonType>::enter (const PolygonType &o, size_t p)
}
}
// TODO: move to generic header
static bool interact (const db::Box &box, const db::Edge &e)
{
if (! e.bbox ().touches (box)) {
return false;
} else if (e.is_ortho ()) {
return true;
} else {
return e.clipped (box).first;
}
}
template <class PolygonType>
void
poly2poly_check<PolygonType>::enter (const PolygonType &o, size_t p, const poly2poly_check<PolygonType>::box_type &box)
{
if (box.empty ()) {
return;
}
for (typename PolygonType::polygon_edge_iterator e = o.begin_edge (); ! e.at_end (); ++e) {
if (interact (box, *e)) {
m_edge_heap.push_back (*e);
m_scanner.insert (& m_edge_heap.back (), p);
}
}
}
template <class PolygonType>
void
poly2poly_check<PolygonType>::process ()

View File

@ -309,6 +309,8 @@ template <class PolygonType>
class DB_PUBLIC poly2poly_check
{
public:
typedef typename PolygonType::box_type box_type;
poly2poly_check (Edge2EdgeCheckBase &output);
poly2poly_check ();
@ -318,6 +320,7 @@ public:
void connect (Edge2EdgeCheckBase &output);
void enter (const PolygonType &o, size_t p);
void enter (const PolygonType &o, size_t p, const box_type &search_box);
void process ();
private:

View File

@ -218,12 +218,40 @@ check_local_operation<TS, TI>::do_compute_local (db::Layout *layout, const shape
}
}
bool take_all = edge_check.has_negative_edge_output () || interactions.num_intruders () == 0;
db::Box common_box;
if (! take_all) {
db::Vector e (edge_check.distance (), edge_check.distance ());
db::Box subject_box;
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
subject_box += db::box_convert<TS> () (interactions.subject_shape (i->first));
}
if (edge_check.requires_different_layers ()) {
db::Box intruder_box;
for (std::set<unsigned int>::const_iterator id = ids.begin (); id != ids.end (); ++id) {
intruder_box += db::box_convert<TI> () (interactions.intruder_shape (*id).second);
}
common_box = subject_box.enlarged (e) & intruder_box.enlarged (e);
} else {
common_box = subject_box.enlarged (e);
}
}
if (m_has_other) {
size_t n = 0;
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
const TS &subject = interactions.subject_shape (i->first);
m_poly_check.enter (subject, n);
if (! take_all) {
m_poly_check.enter (subject, n, common_box);
} else {
m_poly_check.enter (subject, n);
}
n += 2;
}
@ -261,7 +289,11 @@ check_local_operation<TS, TI>::do_compute_local (db::Layout *layout, const shape
n = 1;
for (typename std::unordered_set<TI>::const_iterator o = polygons.begin (); o != polygons.end (); ++o) {
m_poly_check.enter (*o, n);
if (! take_all) {
m_poly_check.enter (*o, n, common_box);
} else {
m_poly_check.enter (*o, n);
}
n += 2;
}
@ -269,7 +301,11 @@ check_local_operation<TS, TI>::do_compute_local (db::Layout *layout, const shape
n = 1;
for (std::set<unsigned int>::const_iterator id = ids.begin (); id != ids.end (); ++id) {
m_poly_check.enter (interactions.intruder_shape (*id).second, n);
if (! take_all) {
m_poly_check.enter (interactions.intruder_shape (*id).second, n, common_box);
} else {
m_poly_check.enter (interactions.intruder_shape (*id).second, n);
}
n += 2;
}
@ -285,7 +321,11 @@ check_local_operation<TS, TI>::do_compute_local (db::Layout *layout, const shape
// we can't directly insert because TS may be != TI
const TS &ts = interactions.subject_shape (i->first);
insert_into_hash (polygons, ts);
m_poly_check.enter (ts, n);
if (! take_all) {
m_poly_check.enter (ts, n, common_box);
} else {
m_poly_check.enter (ts, n);
}
n += 2;
}
@ -294,7 +334,11 @@ check_local_operation<TS, TI>::do_compute_local (db::Layout *layout, const shape
for (std::set<unsigned int>::const_iterator id = ids.begin (); id != ids.end (); ++id) {
const TI &ti = interactions.intruder_shape (*id).second;
if (polygons.find (ti) == polygons.end ()) {
m_poly_check.enter (ti, n);
if (! take_all) {
m_poly_check.enter (ti, n, common_box);
} else {
m_poly_check.enter (ti, n);
}
n += 2;
}
}