mirror of https://github.com/KLayout/klayout.git
Refactoring: unified handling of splitting parameters.
This commit is contained in:
parent
6da9bc5e85
commit
12aaa2db20
|
|
@ -346,10 +346,12 @@ DeepRegion::and_or_not_with (const DeepRegion *other, bool and_op) const
|
|||
{
|
||||
DeepLayer dl_out (m_deep_layer.derived ());
|
||||
|
||||
db::BoolAndOrNotLocalOperation op (and_op, m_deep_layer.store ()->max_area_ratio (), m_deep_layer.store ()->max_vertex_count ());
|
||||
db::BoolAndOrNotLocalOperation op (and_op);
|
||||
|
||||
db::LocalProcessor proc (const_cast<db::Layout *> (&m_deep_layer.layout ()), const_cast<db::Cell *> (&m_deep_layer.initial_cell ()), &other->deep_layer ().layout (), &other->deep_layer ().initial_cell ());
|
||||
proc.set_threads (m_deep_layer.store ()->threads ());
|
||||
proc.set_area_ratio(m_deep_layer.store ()->max_area_ratio ());
|
||||
proc.set_max_vertex_count (m_deep_layer.store ()->max_vertex_count ());
|
||||
|
||||
proc.run (&op, m_deep_layer.layer (), other->deep_layer ().layer (), dl_out.layer ());
|
||||
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ LocalProcessorCellContexts::create (const key_type &intruders)
|
|||
}
|
||||
|
||||
static void
|
||||
subtract (std::unordered_set<db::PolygonRef> &res, const std::unordered_set<db::PolygonRef> &other, db::Layout *layout)
|
||||
subtract (std::unordered_set<db::PolygonRef> &res, const std::unordered_set<db::PolygonRef> &other, db::Layout *layout, size_t max_vertex_count, double area_ratio)
|
||||
{
|
||||
if (other.empty ()) {
|
||||
return;
|
||||
|
|
@ -281,12 +281,10 @@ subtract (std::unordered_set<db::PolygonRef> &res, const std::unordered_set<db::
|
|||
p2 += 2;
|
||||
}
|
||||
|
||||
double m_max_area_ratio = 3.0; // @@@
|
||||
size_t m_max_vertex_count = 16; // @@@
|
||||
res.clear ();
|
||||
db::BooleanOp op (db::BooleanOp::ANotB);
|
||||
db::PolygonRefGenerator pr (layout, res);
|
||||
db::PolygonSplitter splitter (pr, m_max_area_ratio, m_max_vertex_count);
|
||||
db::PolygonSplitter splitter (pr, area_ratio, max_vertex_count);
|
||||
db::PolygonGenerator pg (splitter, true, true);
|
||||
ep.process (pg, op);
|
||||
}
|
||||
|
|
@ -351,10 +349,10 @@ LocalProcessorCellContexts::compute_results (const LocalProcessorContexts &conte
|
|||
|
||||
if (! lost.empty ()) {
|
||||
|
||||
subtract (lost, res, cell->layout ());
|
||||
subtract (lost, res, cell->layout (), proc->max_vertex_count (), proc->area_ratio ());
|
||||
|
||||
if (! lost.empty ()) {
|
||||
subtract (common, lost, cell->layout ());
|
||||
subtract (common, lost, cell->layout (), proc->max_vertex_count (), proc->area_ratio ());
|
||||
for (std::unordered_map<key_type, db::LocalProcessorCellContext>::iterator cc = m_contexts.begin (); cc != c; ++cc) {
|
||||
cc->second.propagate (lost);
|
||||
}
|
||||
|
|
@ -371,7 +369,7 @@ LocalProcessorCellContexts::compute_results (const LocalProcessorContexts &conte
|
|||
|
||||
if (! gained.empty ()) {
|
||||
|
||||
subtract (gained, common, cell->layout ());
|
||||
subtract (gained, common, cell->layout (), proc->max_vertex_count (), proc->area_ratio ());
|
||||
|
||||
if (! gained.empty ()) {
|
||||
c->second.propagate (gained);
|
||||
|
|
@ -782,13 +780,13 @@ LocalProcessorResultComputationTask::perform ()
|
|||
// LocalProcessor implementation
|
||||
|
||||
LocalProcessor::LocalProcessor (db::Layout *layout, db::Cell *top)
|
||||
: mp_subject_layout (layout), mp_intruder_layout (layout), mp_subject_top (top), mp_intruder_top (top), m_nthreads (0)
|
||||
: mp_subject_layout (layout), mp_intruder_layout (layout), mp_subject_top (top), mp_intruder_top (top), m_nthreads (0), m_max_vertex_count (0), m_area_ratio (0.0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
LocalProcessor::LocalProcessor (db::Layout *subject_layout, db::Cell *subject_top, const db::Layout *intruder_layout, const db::Cell *intruder_top)
|
||||
: mp_subject_layout (subject_layout), mp_intruder_layout (intruder_layout), mp_subject_top (subject_top), mp_intruder_top (intruder_top), m_nthreads (0)
|
||||
: mp_subject_layout (subject_layout), mp_intruder_layout (intruder_layout), mp_subject_top (subject_top), mp_intruder_top (intruder_top), m_nthreads (0), m_max_vertex_count (0), m_area_ratio (0.0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
|
@ -1260,7 +1258,7 @@ LocalProcessor::compute_local_cell (const LocalProcessorContexts &contexts, db::
|
|||
|
||||
}
|
||||
|
||||
op->compute_local (mp_subject_layout, interactions, result);
|
||||
op->compute_local (mp_subject_layout, interactions, result, m_max_vertex_count, m_area_ratio);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,6 +329,31 @@ public:
|
|||
m_nthreads = nthreads;
|
||||
}
|
||||
|
||||
unsigned int threads () const
|
||||
{
|
||||
return m_nthreads;
|
||||
}
|
||||
|
||||
void set_max_vertex_count (size_t max_vertex_count)
|
||||
{
|
||||
m_max_vertex_count = max_vertex_count;
|
||||
}
|
||||
|
||||
size_t max_vertex_count () const
|
||||
{
|
||||
return m_max_vertex_count;
|
||||
}
|
||||
|
||||
void set_area_ratio (double area_ratio)
|
||||
{
|
||||
m_area_ratio = area_ratio;
|
||||
}
|
||||
|
||||
double area_ratio () const
|
||||
{
|
||||
return m_area_ratio;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class LocalProcessorCellContexts;
|
||||
friend class LocalProcessorContextComputationTask;
|
||||
|
|
@ -339,6 +364,8 @@ private:
|
|||
const db::Cell *mp_intruder_top;
|
||||
std::string m_description;
|
||||
unsigned int m_nthreads;
|
||||
size_t m_max_vertex_count;
|
||||
double m_area_ratio;
|
||||
mutable std::auto_ptr<tl::Job<LocalProcessorContextComputationWorker> > mp_cc_job;
|
||||
|
||||
std::string description (const LocalOperation *op) const;
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ namespace db
|
|||
// ---------------------------------------------------------------------------------------------
|
||||
// BoolAndOrNotLocalOperation implementation
|
||||
|
||||
BoolAndOrNotLocalOperation::BoolAndOrNotLocalOperation (bool is_and, double max_area_ratio, size_t max_vertex_count)
|
||||
: m_is_and (is_and), m_max_area_ratio (max_area_ratio), m_max_vertex_count (max_vertex_count)
|
||||
BoolAndOrNotLocalOperation::BoolAndOrNotLocalOperation (bool is_and)
|
||||
: m_is_and (is_and)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ BoolAndOrNotLocalOperation::description () const
|
|||
}
|
||||
|
||||
void
|
||||
BoolAndOrNotLocalOperation::compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result) const
|
||||
BoolAndOrNotLocalOperation::compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result, size_t max_vertex_count, double area_ratio) const
|
||||
{
|
||||
db::EdgeProcessor ep;
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ BoolAndOrNotLocalOperation::compute_local (db::Layout *layout, const ShapeIntera
|
|||
|
||||
db::BooleanOp op (m_is_and ? db::BooleanOp::And : db::BooleanOp::ANotB);
|
||||
db::PolygonRefGenerator pr (layout, result);
|
||||
db::PolygonSplitter splitter (pr, m_max_area_ratio, m_max_vertex_count);
|
||||
db::PolygonSplitter splitter (pr, area_ratio, max_vertex_count);
|
||||
db::PolygonGenerator pg (splitter, true, true);
|
||||
ep.process (pg, op);
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ SelfOverlapMergeLocalOperation::SelfOverlapMergeLocalOperation (unsigned int wra
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void SelfOverlapMergeLocalOperation::compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result) const
|
||||
void SelfOverlapMergeLocalOperation::compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result, size_t /*max_vertex_count*/, double /*area_ratio*/) const
|
||||
{
|
||||
if (m_wrap_count == 0) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public:
|
|||
* @param interactions The interaction set
|
||||
* @param result The container to which the results are written
|
||||
*/
|
||||
virtual void compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result) const = 0;
|
||||
virtual void compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result, size_t max_vertex_count, double area_ratio) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Indicates the desired behaviour when a shape does not have an intruder
|
||||
|
|
@ -114,16 +114,14 @@ class DB_PUBLIC BoolAndOrNotLocalOperation
|
|||
: public LocalOperation
|
||||
{
|
||||
public:
|
||||
BoolAndOrNotLocalOperation (bool is_and, double max_area_ratio = 0.0, size_t max_vertex_count = 0);
|
||||
BoolAndOrNotLocalOperation (bool is_and);
|
||||
|
||||
virtual void compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result) const;
|
||||
virtual void compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result, size_t max_vertex_count, double area_ratio) const;
|
||||
virtual on_empty_intruder_mode on_empty_intruder_hint () const;
|
||||
virtual std::string description () const;
|
||||
|
||||
private:
|
||||
bool m_is_and;
|
||||
double m_max_area_ratio;
|
||||
size_t m_max_vertex_count;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -137,7 +135,7 @@ class DB_PUBLIC SelfOverlapMergeLocalOperation
|
|||
public:
|
||||
SelfOverlapMergeLocalOperation (unsigned int wrap_count);
|
||||
|
||||
virtual void compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result) const;
|
||||
virtual void compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result, size_t max_vertex_count, double area_ratio) const;
|
||||
virtual on_empty_intruder_mode on_empty_intruder_hint () const;
|
||||
virtual std::string description () const;
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public:
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
virtual void compute_local (db::Layout *layout, const db::ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result) const
|
||||
virtual void compute_local (db::Layout *layout, const db::ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result, size_t max_vertex_count, double area_ratio) const
|
||||
{
|
||||
db::ShapeInteractions sized_interactions = interactions;
|
||||
for (db::ShapeInteractions::iterator i = sized_interactions.begin (); i != sized_interactions.end (); ++i) {
|
||||
|
|
@ -66,7 +66,7 @@ public:
|
|||
sized_interactions.add_shape (*j, db::PolygonRef (poly, layout->shape_repository ()));
|
||||
}
|
||||
}
|
||||
BoolAndOrNotLocalOperation::compute_local (layout, sized_interactions, result);
|
||||
BoolAndOrNotLocalOperation::compute_local (layout, sized_interactions, result, max_vertex_count, area_ratio);
|
||||
}
|
||||
|
||||
db::Coord dist () const
|
||||
|
|
@ -91,7 +91,7 @@ public:
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
virtual void compute_local (db::Layout *layout, const db::ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result) const
|
||||
virtual void compute_local (db::Layout *layout, const db::ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result, size_t max_vertex_count, double area_ratio) const
|
||||
{
|
||||
db::ShapeInteractions sized_interactions = interactions;
|
||||
for (db::ShapeInteractions::iterator i = sized_interactions.begin (); i != sized_interactions.end (); ++i) {
|
||||
|
|
@ -110,7 +110,7 @@ public:
|
|||
|
||||
}
|
||||
|
||||
SelfOverlapMergeLocalOperation::compute_local (layout, sized_interactions, result);
|
||||
SelfOverlapMergeLocalOperation::compute_local (layout, sized_interactions, result, max_vertex_count, area_ratio);
|
||||
}
|
||||
|
||||
db::Coord dist () const
|
||||
|
|
|
|||
Loading…
Reference in New Issue