mirror of https://github.com/KLayout/klayout.git
WIP: optimization of sized_inside - distance can be reduced to 0 if 'inside' is merged
This commit is contained in:
parent
d2479c7159
commit
e63a7b5940
|
|
@ -1386,15 +1386,21 @@ AsIfFlatRegion::sized_inside (const Region &inside, coord_type d, int steps, uns
|
|||
RegionDelegate *
|
||||
AsIfFlatRegion::sized_inside (const Region &inside, coord_type dx, coord_type dy, int steps, unsigned int mode, const Region *stop_at) const
|
||||
{
|
||||
if (steps <= 0) {
|
||||
if (steps <= 0 || empty ()) {
|
||||
// Nothing to do - NOTE: don't return EmptyRegion because we want to
|
||||
// maintain "deepness"
|
||||
return clone ();
|
||||
}
|
||||
|
||||
if (dx < 0 || dy < 0) {
|
||||
throw tl::Exception (tl::to_string (tr ("'sized_inside' operation does not make sense with negative sizing")));
|
||||
}
|
||||
|
||||
std::unique_ptr<FlatRegion> output (new FlatRegion ());
|
||||
std::vector<db::Shapes *> results;
|
||||
results.push_back (&output->raw_polygons ());
|
||||
|
||||
db::sized_inside_local_operation<db::Polygon, db::Polygon, db::Polygon> op (dx, dy, steps, mode);
|
||||
db::sized_inside_local_operation<db::Polygon, db::Polygon, db::Polygon> op (dx, dy, steps, mode, true /*inside layer is merged*/);
|
||||
|
||||
db::local_processor<db::Polygon, db::Polygon, db::Polygon> proc;
|
||||
proc.set_base_verbosity (base_verbosity ());
|
||||
|
|
@ -1402,7 +1408,7 @@ AsIfFlatRegion::sized_inside (const Region &inside, coord_type dx, coord_type dy
|
|||
proc.set_report_progress (report_progress ());
|
||||
|
||||
std::vector<db::generic_shape_iterator<db::Polygon> > others;
|
||||
others.push_back (inside.begin ());
|
||||
others.push_back (inside.begin_merged ());
|
||||
if (stop_at) {
|
||||
others.push_back (stop_at->begin ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1796,6 +1796,10 @@ DeepRegion::sized_inside (const Region &inside, coord_type dx, coord_type dy, in
|
|||
return clone ();
|
||||
}
|
||||
|
||||
if (dx < 0 || dy < 0) {
|
||||
throw tl::Exception (tl::to_string (tr ("'sized_inside' operation does not make sense with negative sizing")));
|
||||
}
|
||||
|
||||
const db::DeepRegion *inside_deep = dynamic_cast<const db::DeepRegion *> (inside.delegate ());
|
||||
if (! inside_deep) {
|
||||
return db::AsIfFlatRegion::sized_inside (inside, dx, dy, steps, mode, stop_at);
|
||||
|
|
@ -1818,9 +1822,9 @@ DeepRegion::sized_inside (const Region &inside, coord_type dx, coord_type dy, in
|
|||
}
|
||||
|
||||
const db::DeepLayer &polygons = merged_deep_layer ();
|
||||
const db::DeepLayer &inside_polygons = inside_deep->deep_layer ();
|
||||
const db::DeepLayer &inside_polygons = inside_deep->merged_deep_layer ();
|
||||
|
||||
db::sized_inside_local_operation<db::PolygonRef, db::PolygonRef, db::PolygonRef> op (dx, dy, steps, mode);
|
||||
db::sized_inside_local_operation<db::PolygonRef, db::PolygonRef, db::PolygonRef> op (dx, dy, steps, mode, true /*inside layer is merged*/);
|
||||
|
||||
db::local_processor<db::PolygonRef, db::PolygonRef, db::PolygonRef> proc (const_cast<db::Layout *> (&polygons.layout ()), const_cast<db::Cell *> (&polygons.initial_cell ()), &inside_polygons.layout (), &inside_polygons.initial_cell (), polygons.breakout_cells (), inside_polygons.breakout_cells ());
|
||||
configure_proc (proc);
|
||||
|
|
|
|||
|
|
@ -1948,17 +1948,20 @@ template class DB_PUBLIC two_bool_and_not_local_operation_with_properties<db::Po
|
|||
// sized_inside_local_operation implementation
|
||||
|
||||
template <class TS, class TI, class TR>
|
||||
sized_inside_local_operation<TS, TI, TR>::sized_inside_local_operation (db::Coord dx, db::Coord dy, int steps, unsigned int mode)
|
||||
: m_dx (dx), m_dy (dy), m_steps (steps), m_mode (mode)
|
||||
sized_inside_local_operation<TS, TI, TR>::sized_inside_local_operation (db::Coord dx, db::Coord dy, int steps, unsigned int mode, bool inside_is_merged)
|
||||
: m_dx (dx), m_dy (dy), m_steps (steps), m_mode (mode), m_dist (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
m_dist = 0;
|
||||
if (! inside_is_merged) {
|
||||
m_dist = std::max (0, std::max (m_dx, m_dy));
|
||||
}
|
||||
}
|
||||
|
||||
template <class TS, class TI, class TR>
|
||||
db::Coord
|
||||
sized_inside_local_operation<TS, TI, TR>::dist () const
|
||||
{
|
||||
return std::max (0, std::max (m_dx, m_dy));
|
||||
return m_dist;
|
||||
}
|
||||
|
||||
template <class TS, class TI, class TR>
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@ class DB_PUBLIC sized_inside_local_operation
|
|||
: public local_operation<TS, TI, TR>
|
||||
{
|
||||
public:
|
||||
sized_inside_local_operation (db::Coord dx, db::Coord dy, int steps, unsigned int mode);
|
||||
sized_inside_local_operation (db::Coord dx, db::Coord dy, int steps, unsigned int mode, bool inside_is_merged);
|
||||
|
||||
virtual db::Coord dist () const;
|
||||
virtual OnEmptyIntruderHint on_empty_intruder_hint () const;
|
||||
|
|
@ -486,6 +486,7 @@ public:
|
|||
|
||||
private:
|
||||
db::Coord m_dx, m_dy;
|
||||
db::Coord m_dist;
|
||||
int m_steps;
|
||||
unsigned int m_mode;
|
||||
db::MagnificationAndOrientationReducer m_vars_anisotropic;
|
||||
|
|
|
|||
Loading…
Reference in New Issue