mirror of https://github.com/KLayout/klayout.git
Restored performance of some checks
This commit is contained in:
parent
ac1167278e
commit
379a22c86a
|
|
@ -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>
|
template <class PolygonType>
|
||||||
void
|
void
|
||||||
poly2poly_check<PolygonType>::process ()
|
poly2poly_check<PolygonType>::process ()
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,8 @@ template <class PolygonType>
|
||||||
class DB_PUBLIC poly2poly_check
|
class DB_PUBLIC poly2poly_check
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef typename PolygonType::box_type box_type;
|
||||||
|
|
||||||
poly2poly_check (Edge2EdgeCheckBase &output);
|
poly2poly_check (Edge2EdgeCheckBase &output);
|
||||||
poly2poly_check ();
|
poly2poly_check ();
|
||||||
|
|
||||||
|
|
@ -318,6 +320,7 @@ public:
|
||||||
|
|
||||||
void connect (Edge2EdgeCheckBase &output);
|
void connect (Edge2EdgeCheckBase &output);
|
||||||
void enter (const PolygonType &o, size_t p);
|
void enter (const PolygonType &o, size_t p);
|
||||||
|
void enter (const PolygonType &o, size_t p, const box_type &search_box);
|
||||||
void process ();
|
void process ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
if (m_has_other) {
|
||||||
|
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||||
const TS &subject = interactions.subject_shape (i->first);
|
const TS &subject = interactions.subject_shape (i->first);
|
||||||
|
if (! take_all) {
|
||||||
|
m_poly_check.enter (subject, n, common_box);
|
||||||
|
} else {
|
||||||
m_poly_check.enter (subject, n);
|
m_poly_check.enter (subject, n);
|
||||||
|
}
|
||||||
n += 2;
|
n += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -261,7 +289,11 @@ check_local_operation<TS, TI>::do_compute_local (db::Layout *layout, const shape
|
||||||
|
|
||||||
n = 1;
|
n = 1;
|
||||||
for (typename std::unordered_set<TI>::const_iterator o = polygons.begin (); o != polygons.end (); ++o) {
|
for (typename std::unordered_set<TI>::const_iterator o = polygons.begin (); o != polygons.end (); ++o) {
|
||||||
|
if (! take_all) {
|
||||||
|
m_poly_check.enter (*o, n, common_box);
|
||||||
|
} else {
|
||||||
m_poly_check.enter (*o, n);
|
m_poly_check.enter (*o, n);
|
||||||
|
}
|
||||||
n += 2;
|
n += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,7 +301,11 @@ check_local_operation<TS, TI>::do_compute_local (db::Layout *layout, const shape
|
||||||
|
|
||||||
n = 1;
|
n = 1;
|
||||||
for (std::set<unsigned int>::const_iterator id = ids.begin (); id != ids.end (); ++id) {
|
for (std::set<unsigned int>::const_iterator id = ids.begin (); id != ids.end (); ++id) {
|
||||||
|
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);
|
m_poly_check.enter (interactions.intruder_shape (*id).second, n);
|
||||||
|
}
|
||||||
n += 2;
|
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
|
// we can't directly insert because TS may be != TI
|
||||||
const TS &ts = interactions.subject_shape (i->first);
|
const TS &ts = interactions.subject_shape (i->first);
|
||||||
insert_into_hash (polygons, ts);
|
insert_into_hash (polygons, ts);
|
||||||
|
if (! take_all) {
|
||||||
|
m_poly_check.enter (ts, n, common_box);
|
||||||
|
} else {
|
||||||
m_poly_check.enter (ts, n);
|
m_poly_check.enter (ts, n);
|
||||||
|
}
|
||||||
n += 2;
|
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) {
|
for (std::set<unsigned int>::const_iterator id = ids.begin (); id != ids.end (); ++id) {
|
||||||
const TI &ti = interactions.intruder_shape (*id).second;
|
const TI &ti = interactions.intruder_shape (*id).second;
|
||||||
if (polygons.find (ti) == polygons.end ()) {
|
if (polygons.find (ti) == polygons.end ()) {
|
||||||
|
if (! take_all) {
|
||||||
|
m_poly_check.enter (ti, n, common_box);
|
||||||
|
} else {
|
||||||
m_poly_check.enter (ti, n);
|
m_poly_check.enter (ti, n);
|
||||||
|
}
|
||||||
n += 2;
|
n += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue