mirror of https://github.com/KLayout/klayout.git
WIP: templatized local hierarchical processor.
This commit is contained in:
parent
d35e86e189
commit
dd4fcd9e36
|
|
@ -463,7 +463,7 @@ DeepRegion::and_or_not_with (const DeepRegion *other, bool and_op) const
|
|||
|
||||
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 ());
|
||||
db::local_processor<db::PolygonRef> 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_base_verbosity (base_verbosity ());
|
||||
proc.set_threads (m_deep_layer.store ()->threads ());
|
||||
proc.set_area_ratio (m_deep_layer.store ()->max_area_ratio ());
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -42,19 +42,20 @@
|
|||
namespace db
|
||||
{
|
||||
|
||||
class LocalProcessor;
|
||||
class LocalProcessorCellContext;
|
||||
class LocalProcessorContexts;
|
||||
template <class T> class local_processor;
|
||||
template <class T> class local_processor_cell_context;
|
||||
template <class T> class local_processor_contexts;
|
||||
|
||||
// TODO: move this somewhere else?
|
||||
class DB_PUBLIC ShapeInteractions
|
||||
template <class T>
|
||||
class DB_PUBLIC shape_interactions
|
||||
{
|
||||
public:
|
||||
typedef std::unordered_map<unsigned int, std::vector<unsigned int> > container;
|
||||
typedef container::const_iterator iterator;
|
||||
typedef container::value_type::second_type::const_iterator iterator2;
|
||||
|
||||
ShapeInteractions ();
|
||||
shape_interactions ();
|
||||
|
||||
iterator begin () const
|
||||
{
|
||||
|
|
@ -67,11 +68,11 @@ public:
|
|||
}
|
||||
|
||||
bool has_shape_id (unsigned int id) const;
|
||||
void add_shape (unsigned int id, const db::PolygonRef &shape);
|
||||
void add_subject (unsigned int id, const db::PolygonRef &shape);
|
||||
void add_shape (unsigned int id, const T &shape);
|
||||
void add_subject (unsigned int id, const T &shape);
|
||||
void add_interaction (unsigned int subject_id, unsigned int intruder_id);
|
||||
const std::vector<unsigned int> &intruders_for (unsigned int subject_id) const;
|
||||
const db::PolygonRef &shape (unsigned int id) const;
|
||||
const T &shape (unsigned int id) const;
|
||||
|
||||
unsigned int next_id ()
|
||||
{
|
||||
|
|
@ -80,43 +81,45 @@ public:
|
|||
|
||||
private:
|
||||
std::unordered_map<unsigned int, std::vector<unsigned int> > m_interactions;
|
||||
std::unordered_map<unsigned int, db::PolygonRef> m_shapes;
|
||||
std::unordered_map<unsigned int, T> m_shapes;
|
||||
unsigned int m_id;
|
||||
};
|
||||
|
||||
// TODO: should be hidden (private data?)
|
||||
struct DB_PUBLIC LocalProcessorCellDrop
|
||||
template <class T>
|
||||
struct DB_PUBLIC local_processor_cell_drop
|
||||
{
|
||||
LocalProcessorCellDrop (db::LocalProcessorCellContext *_parent_context, db::Cell *_parent, const db::ICplxTrans &_cell_inst)
|
||||
local_processor_cell_drop (db::local_processor_cell_context<T> *_parent_context, db::Cell *_parent, const db::ICplxTrans &_cell_inst)
|
||||
: parent_context (_parent_context), parent (_parent), cell_inst (_cell_inst)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::LocalProcessorCellContext *parent_context;
|
||||
db::local_processor_cell_context<T> *parent_context;
|
||||
db::Cell *parent;
|
||||
db::ICplxTrans cell_inst;
|
||||
};
|
||||
|
||||
// TODO: should be hidden (private data?)
|
||||
class DB_PUBLIC LocalProcessorCellContext
|
||||
template <class T>
|
||||
class DB_PUBLIC local_processor_cell_context
|
||||
{
|
||||
public:
|
||||
typedef std::pair<const db::Cell *, db::ICplxTrans> parent_inst_type;
|
||||
typedef std::vector<LocalProcessorCellDrop>::const_iterator drop_iterator;
|
||||
typedef typename std::vector<local_processor_cell_drop<T> >::const_iterator drop_iterator;
|
||||
|
||||
LocalProcessorCellContext ();
|
||||
LocalProcessorCellContext (const LocalProcessorCellContext &other);
|
||||
local_processor_cell_context ();
|
||||
local_processor_cell_context (const local_processor_cell_context &other);
|
||||
|
||||
void add (db::LocalProcessorCellContext *parent_context, db::Cell *parent, const db::ICplxTrans &cell_inst);
|
||||
void propagate (const std::unordered_set<db::PolygonRef> &res);
|
||||
void add (db::local_processor_cell_context<T> *parent_context, db::Cell *parent, const db::ICplxTrans &cell_inst);
|
||||
void propagate (const std::unordered_set<T> &res);
|
||||
|
||||
std::unordered_set<db::PolygonRef> &propagated ()
|
||||
std::unordered_set<T> &propagated ()
|
||||
{
|
||||
return m_propagated;
|
||||
}
|
||||
|
||||
const std::unordered_set<db::PolygonRef> &propagated () const
|
||||
const std::unordered_set<T> &propagated () const
|
||||
{
|
||||
return m_propagated;
|
||||
}
|
||||
|
|
@ -144,24 +147,25 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
std::unordered_set<db::PolygonRef> m_propagated;
|
||||
std::vector<LocalProcessorCellDrop> m_drops;
|
||||
std::unordered_set<T> m_propagated;
|
||||
std::vector<local_processor_cell_drop<T> > m_drops;
|
||||
tl::Mutex m_lock;
|
||||
};
|
||||
|
||||
class DB_PUBLIC LocalProcessorCellContexts
|
||||
template <class T>
|
||||
class DB_PUBLIC local_processor_cell_contexts
|
||||
{
|
||||
public:
|
||||
typedef std::pair<std::set<CellInstArray>, std::set<db::PolygonRef> > context_key_type;
|
||||
typedef std::unordered_map<context_key_type, db::LocalProcessorCellContext> context_map_type;
|
||||
typedef context_map_type::const_iterator iterator;
|
||||
typedef std::pair<std::set<CellInstArray>, std::set<T> > context_key_type;
|
||||
typedef std::unordered_map<context_key_type, db::local_processor_cell_context<T> > context_map_type;
|
||||
typedef typename context_map_type::const_iterator iterator;
|
||||
|
||||
LocalProcessorCellContexts ();
|
||||
LocalProcessorCellContexts (const db::Cell *intruder_cell);
|
||||
local_processor_cell_contexts ();
|
||||
local_processor_cell_contexts (const db::Cell *intruder_cell);
|
||||
|
||||
db::LocalProcessorCellContext *find_context (const context_key_type &intruders);
|
||||
db::LocalProcessorCellContext *create (const context_key_type &intruders);
|
||||
void compute_results (const LocalProcessorContexts &contexts, db::Cell *cell, const LocalOperation *op, unsigned int output_layer, const LocalProcessor *proc);
|
||||
db::local_processor_cell_context<T> *find_context (const context_key_type &intruders);
|
||||
db::local_processor_cell_context<T> *create (const context_key_type &intruders);
|
||||
void compute_results (const local_processor_contexts<T> &contexts, db::Cell *cell, const local_operation<T> *op, unsigned int output_layer, const local_processor<T> *proc);
|
||||
|
||||
iterator begin () const
|
||||
{
|
||||
|
|
@ -175,22 +179,23 @@ public:
|
|||
|
||||
private:
|
||||
const db::Cell *mp_intruder_cell;
|
||||
std::unordered_map<context_key_type, db::LocalProcessorCellContext> m_contexts;
|
||||
std::unordered_map<context_key_type, db::local_processor_cell_context<T> > m_contexts;
|
||||
};
|
||||
|
||||
class DB_PUBLIC LocalProcessorContexts
|
||||
template <class T>
|
||||
class DB_PUBLIC local_processor_contexts
|
||||
{
|
||||
public:
|
||||
typedef std::unordered_map<db::Cell *, LocalProcessorCellContexts> contexts_per_cell_type;
|
||||
typedef contexts_per_cell_type::iterator iterator;
|
||||
typedef std::unordered_map<db::Cell *, local_processor_cell_contexts<T> > contexts_per_cell_type;
|
||||
typedef typename contexts_per_cell_type::iterator iterator;
|
||||
|
||||
LocalProcessorContexts ()
|
||||
local_processor_contexts ()
|
||||
: m_subject_layer (0), m_intruder_layer (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
LocalProcessorContexts (const LocalProcessorContexts &other)
|
||||
local_processor_contexts (const local_processor_contexts &other)
|
||||
: m_contexts_per_cell (other.m_contexts_per_cell), m_subject_layer (other.m_subject_layer), m_intruder_layer (other.m_intruder_layer)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
|
|
@ -201,11 +206,11 @@ public:
|
|||
m_contexts_per_cell.clear ();
|
||||
}
|
||||
|
||||
LocalProcessorCellContexts &contexts_per_cell (db::Cell *subject_cell, const db::Cell *intruder_cell)
|
||||
local_processor_cell_contexts<T> &contexts_per_cell (db::Cell *subject_cell, const db::Cell *intruder_cell)
|
||||
{
|
||||
contexts_per_cell_type::iterator ctx = m_contexts_per_cell.find (subject_cell);
|
||||
typename contexts_per_cell_type::iterator ctx = m_contexts_per_cell.find (subject_cell);
|
||||
if (ctx == m_contexts_per_cell.end ()) {
|
||||
ctx = m_contexts_per_cell.insert (std::make_pair (subject_cell, LocalProcessorCellContexts (intruder_cell))).first;
|
||||
ctx = m_contexts_per_cell.insert (std::make_pair (subject_cell, local_processor_cell_contexts<T> (intruder_cell))).first;
|
||||
}
|
||||
return ctx->second;
|
||||
}
|
||||
|
|
@ -256,30 +261,32 @@ private:
|
|||
mutable tl::Mutex m_lock;
|
||||
};
|
||||
|
||||
class DB_PUBLIC LocalProcessorContextComputationTask
|
||||
template <class T>
|
||||
class DB_PUBLIC local_processor_context_computation_task
|
||||
: public tl::Task
|
||||
{
|
||||
public:
|
||||
LocalProcessorContextComputationTask (const LocalProcessor *proc, LocalProcessorContexts &contexts, db::LocalProcessorCellContext *parent_context, db::Cell *subject_parent, db::Cell *subject_cell, const db::ICplxTrans &subject_cell_inst, const db::Cell *intruder_cell, LocalProcessorCellContexts::context_key_type &intruders, db::Coord dist);
|
||||
local_processor_context_computation_task (const local_processor<T> *proc, local_processor_contexts<T> &contexts, db::local_processor_cell_context<T> *parent_context, db::Cell *subject_parent, db::Cell *subject_cell, const db::ICplxTrans &subject_cell_inst, const db::Cell *intruder_cell, typename local_processor_cell_contexts<T>::context_key_type &intruders, db::Coord dist);
|
||||
void perform ();
|
||||
|
||||
private:
|
||||
const LocalProcessor *mp_proc;
|
||||
LocalProcessorContexts *mp_contexts;
|
||||
db::LocalProcessorCellContext *mp_parent_context;
|
||||
const local_processor<T> *mp_proc;
|
||||
local_processor_contexts<T> *mp_contexts;
|
||||
db::local_processor_cell_context<T> *mp_parent_context;
|
||||
db::Cell *mp_subject_parent;
|
||||
db::Cell *mp_subject_cell;
|
||||
db::ICplxTrans m_subject_cell_inst;
|
||||
const db::Cell *mp_intruder_cell;
|
||||
LocalProcessorCellContexts::context_key_type m_intruders;
|
||||
typename local_processor_cell_contexts<T>::context_key_type m_intruders;
|
||||
db::Coord m_dist;
|
||||
};
|
||||
|
||||
class DB_PUBLIC LocalProcessorContextComputationWorker
|
||||
template <class T>
|
||||
class DB_PUBLIC local_processor_context_computation_worker
|
||||
: public tl::Worker
|
||||
{
|
||||
public:
|
||||
LocalProcessorContextComputationWorker ()
|
||||
local_processor_context_computation_worker ()
|
||||
: tl::Worker ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
|
|
@ -287,31 +294,33 @@ public:
|
|||
|
||||
void perform_task (tl::Task *task)
|
||||
{
|
||||
static_cast<LocalProcessorContextComputationTask *> (task)->perform ();
|
||||
static_cast<local_processor_context_computation_task<T> *> (task)->perform ();
|
||||
}
|
||||
};
|
||||
|
||||
class DB_PUBLIC LocalProcessorResultComputationTask
|
||||
template <class T>
|
||||
class DB_PUBLIC local_processor_result_computation_task
|
||||
: public tl::Task
|
||||
{
|
||||
public:
|
||||
LocalProcessorResultComputationTask (const LocalProcessor *proc, LocalProcessorContexts &contexts, db::Cell *cell, LocalProcessorCellContexts *cell_contexts, const LocalOperation *op, unsigned int output_layer);
|
||||
local_processor_result_computation_task (const local_processor<T> *proc, local_processor_contexts<T> &contexts, db::Cell *cell, local_processor_cell_contexts<T> *cell_contexts, const local_operation<T> *op, unsigned int output_layer);
|
||||
void perform ();
|
||||
|
||||
private:
|
||||
const LocalProcessor *mp_proc;
|
||||
LocalProcessorContexts *mp_contexts;
|
||||
const local_processor<T> *mp_proc;
|
||||
local_processor_contexts<T> *mp_contexts;
|
||||
db::Cell *mp_cell;
|
||||
LocalProcessorCellContexts *mp_cell_contexts;
|
||||
const LocalOperation *mp_op;
|
||||
local_processor_cell_contexts<T> *mp_cell_contexts;
|
||||
const local_operation<T> *mp_op;
|
||||
unsigned int m_output_layer;
|
||||
};
|
||||
|
||||
class DB_PUBLIC LocalProcessorResultComputationWorker
|
||||
template <class T>
|
||||
class DB_PUBLIC local_processor_result_computation_worker
|
||||
: public tl::Worker
|
||||
{
|
||||
public:
|
||||
LocalProcessorResultComputationWorker ()
|
||||
local_processor_result_computation_worker ()
|
||||
: tl::Worker ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
|
|
@ -319,18 +328,19 @@ public:
|
|||
|
||||
void perform_task (tl::Task *task)
|
||||
{
|
||||
static_cast<LocalProcessorResultComputationTask *> (task)->perform ();
|
||||
static_cast<local_processor_result_computation_task<T> *> (task)->perform ();
|
||||
}
|
||||
};
|
||||
|
||||
class DB_PUBLIC LocalProcessor
|
||||
template <class T>
|
||||
class DB_PUBLIC local_processor
|
||||
{
|
||||
public:
|
||||
LocalProcessor (db::Layout *layout, db::Cell *top);
|
||||
LocalProcessor (db::Layout *subject_layout, db::Cell *subject_top, const db::Layout *intruder_layout, const db::Cell *intruder_cell);
|
||||
void run (LocalOperation *op, unsigned int subject_layer, unsigned int intruder_layer, unsigned int output_layer);
|
||||
void compute_contexts (LocalProcessorContexts &contexts, const LocalOperation *op, unsigned int subject_layer, unsigned int intruder_layer) const;
|
||||
void compute_results (LocalProcessorContexts &contexts, const LocalOperation *op, unsigned int output_layer) const;
|
||||
local_processor (db::Layout *layout, db::Cell *top);
|
||||
local_processor (db::Layout *subject_layout, db::Cell *subject_top, const db::Layout *intruder_layout, const db::Cell *intruder_cell);
|
||||
void run (local_operation<T> *op, unsigned int subject_layer, unsigned int intruder_layer, unsigned int output_layer);
|
||||
void compute_contexts (local_processor_contexts<T> &contexts, const local_operation<T> *op, unsigned int subject_layer, unsigned int intruder_layer) const;
|
||||
void compute_results (local_processor_contexts<T> &contexts, const local_operation<T> *op, unsigned int output_layer) const;
|
||||
|
||||
void set_description (const std::string &d)
|
||||
{
|
||||
|
|
@ -378,8 +388,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
friend class LocalProcessorCellContexts;
|
||||
friend class LocalProcessorContextComputationTask;
|
||||
template<typename> friend class local_processor_cell_contexts;
|
||||
template<typename> friend class local_processor_context_computation_task;
|
||||
|
||||
db::Layout *mp_subject_layout;
|
||||
const db::Layout *mp_intruder_layout;
|
||||
|
|
@ -390,14 +400,14 @@ private:
|
|||
size_t m_max_vertex_count;
|
||||
double m_area_ratio;
|
||||
int m_base_verbosity;
|
||||
mutable std::auto_ptr<tl::Job<LocalProcessorContextComputationWorker> > mp_cc_job;
|
||||
mutable std::auto_ptr<tl::Job<local_processor_context_computation_worker<T> > > mp_cc_job;
|
||||
|
||||
std::string description (const LocalOperation *op) const;
|
||||
void compute_contexts (db::LocalProcessorContexts &contexts, db::LocalProcessorCellContext *parent_context, db::Cell *subject_parent, db::Cell *subject_cell, const db::ICplxTrans &subject_cell_inst, const db::Cell *intruder_cell, const LocalProcessorCellContexts::context_key_type &intruders, db::Coord dist) const;
|
||||
void do_compute_contexts (db::LocalProcessorCellContext *cell_context, const db::LocalProcessorContexts &contexts, db::LocalProcessorCellContext *parent_context, db::Cell *subject_parent, db::Cell *subject_cell, const db::ICplxTrans &subject_cell_inst, const db::Cell *intruder_cell, const LocalProcessorCellContexts::context_key_type &intruders, db::Coord dist) const;
|
||||
void issue_compute_contexts (db::LocalProcessorContexts &contexts, db::LocalProcessorCellContext *parent_context, db::Cell *subject_parent, db::Cell *subject_cell, const db::ICplxTrans &subject_cell_inst, const db::Cell *intruder_cell, LocalProcessorCellContexts::context_key_type &intruders, db::Coord dist) const;
|
||||
void push_results (db::Cell *cell, unsigned int output_layer, const std::unordered_set<db::PolygonRef> &result) const;
|
||||
void compute_local_cell (const db::LocalProcessorContexts &contexts, db::Cell *subject_cell, const db::Cell *intruder_cell, const LocalOperation *op, const LocalProcessorCellContexts::context_key_type &intruders, std::unordered_set<db::PolygonRef> &result) const;
|
||||
std::string description (const local_operation<T> *op) const;
|
||||
void compute_contexts (db::local_processor_contexts<T> &contexts, db::local_processor_cell_context<T> *parent_context, db::Cell *subject_parent, db::Cell *subject_cell, const db::ICplxTrans &subject_cell_inst, const db::Cell *intruder_cell, const typename local_processor_cell_contexts<T>::context_key_type &intruders, db::Coord dist) const;
|
||||
void do_compute_contexts (db::local_processor_cell_context<T> *cell_context, const db::local_processor_contexts<T> &contexts, db::local_processor_cell_context<T> *parent_context, db::Cell *subject_parent, db::Cell *subject_cell, const db::ICplxTrans &subject_cell_inst, const db::Cell *intruder_cell, const typename local_processor_cell_contexts<T>::context_key_type &intruders, db::Coord dist) const;
|
||||
void issue_compute_contexts (db::local_processor_contexts<T> &contexts, db::local_processor_cell_context<T> *parent_context, db::Cell *subject_parent, db::Cell *subject_cell, const db::ICplxTrans &subject_cell_inst, const db::Cell *intruder_cell, typename local_processor_cell_contexts<T>::context_key_type &intruders, db::Coord dist) const;
|
||||
void push_results (db::Cell *cell, unsigned int output_layer, const std::unordered_set<T> &result) const;
|
||||
void compute_local_cell (const db::local_processor_contexts<T> &contexts, db::Cell *subject_cell, const db::Cell *intruder_cell, const local_operation<T> *op, const typename local_processor_cell_contexts<T>::context_key_type &intruders, std::unordered_set<T> &result) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -405,8 +415,8 @@ private:
|
|||
namespace tl
|
||||
{
|
||||
|
||||
template <>
|
||||
struct type_traits<db::LocalProcessor> : public tl::type_traits<void>
|
||||
template <class T>
|
||||
struct type_traits<db::local_processor<T> > : public tl::type_traits<void>
|
||||
{
|
||||
// mark "LocalProcessor" as not having a default ctor and no copy ctor
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ BoolAndOrNotLocalOperation::BoolAndOrNotLocalOperation (bool is_and)
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
LocalOperation::on_empty_intruder_mode
|
||||
local_operation<db::PolygonRef>::on_empty_intruder_mode
|
||||
BoolAndOrNotLocalOperation::on_empty_intruder_hint () const
|
||||
{
|
||||
return m_is_and ? LocalOperation::Drop : LocalOperation::Copy;
|
||||
return m_is_and ? local_operation::Drop : local_operation::Copy;
|
||||
}
|
||||
|
||||
std::string
|
||||
|
|
@ -58,20 +58,20 @@ BoolAndOrNotLocalOperation::description () const
|
|||
}
|
||||
|
||||
void
|
||||
BoolAndOrNotLocalOperation::compute_local (db::Layout *layout, const ShapeInteractions &interactions, std::unordered_set<db::PolygonRef> &result, size_t max_vertex_count, double area_ratio) const
|
||||
BoolAndOrNotLocalOperation::compute_local (db::Layout *layout, const shape_interactions<db::PolygonRef> &interactions, std::unordered_set<db::PolygonRef> &result, size_t max_vertex_count, double area_ratio) const
|
||||
{
|
||||
db::EdgeProcessor ep;
|
||||
|
||||
size_t p1 = 0, p2 = 1;
|
||||
|
||||
std::set<db::PolygonRef> others;
|
||||
for (ShapeInteractions::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||
for (ShapeInteractions::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
||||
for (shape_interactions<db::PolygonRef>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||
for (shape_interactions<db::PolygonRef>::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
||||
others.insert (interactions.shape (*j));
|
||||
}
|
||||
}
|
||||
|
||||
for (ShapeInteractions::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||
for (shape_interactions<db::PolygonRef>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||
|
||||
const db::PolygonRef &subject = interactions.shape (i->first);
|
||||
if (others.find (subject) != others.end ()) {
|
||||
|
|
@ -119,7 +119,7 @@ SelfOverlapMergeLocalOperation::SelfOverlapMergeLocalOperation (unsigned int wra
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
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
|
||||
void SelfOverlapMergeLocalOperation::compute_local (db::Layout *layout, const shape_interactions<db::PolygonRef> &interactions, std::unordered_set<db::PolygonRef> &result, size_t /*max_vertex_count*/, double /*area_ratio*/) const
|
||||
{
|
||||
if (m_wrap_count == 0) {
|
||||
return;
|
||||
|
|
@ -130,7 +130,7 @@ void SelfOverlapMergeLocalOperation::compute_local (db::Layout *layout, const Sh
|
|||
size_t p1 = 0, p2 = 1;
|
||||
std::set<unsigned int> seen;
|
||||
|
||||
for (ShapeInteractions::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||
for (shape_interactions<db::PolygonRef>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||
|
||||
if (seen.find (i->first) == seen.end ()) {
|
||||
seen.insert (i->first);
|
||||
|
|
@ -141,7 +141,7 @@ void SelfOverlapMergeLocalOperation::compute_local (db::Layout *layout, const Sh
|
|||
p1 += 2;
|
||||
}
|
||||
|
||||
for (db::ShapeInteractions::iterator2 o = i->second.begin (); o != i->second.end (); ++o) {
|
||||
for (db::shape_interactions<db::PolygonRef>::iterator2 o = i->second.begin (); o != i->second.end (); ++o) {
|
||||
// don't take the same (really the same, not an identical one) shape twice - the interaction
|
||||
// set does not take care to list just one copy of the same item on the intruder side.
|
||||
if (seen.find (*o) == seen.end ()) {
|
||||
|
|
@ -165,7 +165,7 @@ void SelfOverlapMergeLocalOperation::compute_local (db::Layout *layout, const Sh
|
|||
|
||||
SelfOverlapMergeLocalOperation::on_empty_intruder_mode SelfOverlapMergeLocalOperation::on_empty_intruder_hint () const
|
||||
{
|
||||
return m_wrap_count > 1 ? LocalOperation::Drop : LocalOperation::Copy;
|
||||
return m_wrap_count > 1 ? local_operation::Drop : local_operation::Copy;
|
||||
}
|
||||
|
||||
std::string SelfOverlapMergeLocalOperation::description () const
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
namespace db
|
||||
{
|
||||
|
||||
class ShapeInteractions;
|
||||
template <class T> class shape_interactions;
|
||||
|
||||
/**
|
||||
* @brief A base class for "local operations"
|
||||
|
|
@ -49,7 +49,8 @@ class ShapeInteractions;
|
|||
* This class implements the actual operation. It receives a
|
||||
* cluster of subject shapes vs. corresponding intruder shapes.
|
||||
*/
|
||||
class DB_PUBLIC LocalOperation
|
||||
template <class T>
|
||||
class DB_PUBLIC local_operation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -75,12 +76,12 @@ public:
|
|||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
LocalOperation () { }
|
||||
local_operation () { }
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
virtual ~LocalOperation () { }
|
||||
virtual ~local_operation () { }
|
||||
|
||||
/**
|
||||
* @brief Computes the results from a given set of interacting shapes
|
||||
|
|
@ -88,7 +89,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, size_t max_vertex_count, double area_ratio) const = 0;
|
||||
virtual void compute_local (db::Layout *layout, const shape_interactions<T> &interactions, std::unordered_set<T> &result, size_t max_vertex_count, double area_ratio) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Indicates the desired behaviour when a shape does not have an intruder
|
||||
|
|
@ -111,12 +112,12 @@ public:
|
|||
* @brief Implements a boolean AND or NOT operation
|
||||
*/
|
||||
class DB_PUBLIC BoolAndOrNotLocalOperation
|
||||
: public LocalOperation
|
||||
: public local_operation<db::PolygonRef>
|
||||
{
|
||||
public:
|
||||
BoolAndOrNotLocalOperation (bool is_and);
|
||||
|
||||
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 void compute_local (db::Layout *layout, const shape_interactions<db::PolygonRef> &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;
|
||||
|
||||
|
|
@ -130,12 +131,12 @@ private:
|
|||
* the original shapes overlap at least "wrap_count" times.
|
||||
*/
|
||||
class DB_PUBLIC SelfOverlapMergeLocalOperation
|
||||
: public LocalOperation
|
||||
: public local_operation<db::PolygonRef>
|
||||
{
|
||||
public:
|
||||
SelfOverlapMergeLocalOperation (unsigned int wrap_count);
|
||||
|
||||
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 void compute_local (db::Layout *layout, const shape_interactions<db::PolygonRef> &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,11 +55,11 @@ public:
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
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
|
||||
virtual void compute_local (db::Layout *layout, const db::shape_interactions<db::PolygonRef> &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) {
|
||||
for (db::ShapeInteractions::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
||||
db::shape_interactions<db::PolygonRef> sized_interactions = interactions;
|
||||
for (db::shape_interactions<db::PolygonRef>::iterator i = sized_interactions.begin (); i != sized_interactions.end (); ++i) {
|
||||
for (db::shape_interactions<db::PolygonRef>::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
||||
const db::PolygonRef &ref = interactions.shape (*j);
|
||||
db::Polygon poly = ref.obj ().transformed (ref.trans ());
|
||||
poly.size (m_dist, m_dist);
|
||||
|
|
@ -91,17 +91,17 @@ public:
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
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
|
||||
virtual void compute_local (db::Layout *layout, const db::shape_interactions<db::PolygonRef> &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) {
|
||||
db::shape_interactions<db::PolygonRef> sized_interactions = interactions;
|
||||
for (db::shape_interactions<db::PolygonRef>::iterator i = sized_interactions.begin (); i != sized_interactions.end (); ++i) {
|
||||
|
||||
const db::PolygonRef &ref = interactions.shape (i->first);
|
||||
db::Polygon poly = ref.obj ().transformed (ref.trans ());
|
||||
poly.size (m_dist / 2, m_dist / 2);
|
||||
sized_interactions.add_shape (i->first, db::PolygonRef (poly, layout->shape_repository ()));
|
||||
|
||||
for (db::ShapeInteractions::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
||||
for (db::shape_interactions<db::PolygonRef>::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
||||
const db::PolygonRef &ref = interactions.shape (*j);
|
||||
db::Polygon poly = ref.obj ().transformed (ref.trans ());
|
||||
poly.size (m_dist / 2, m_dist / 2);
|
||||
|
|
@ -140,15 +140,15 @@ static void normalize_layer (db::Layout &layout, unsigned int layer)
|
|||
}
|
||||
|
||||
|
||||
static std::string contexts_to_s (db::Layout *layout, db::LocalProcessorContexts &contexts)
|
||||
static std::string contexts_to_s (db::Layout *layout, db::local_processor_contexts<db::PolygonRef> &contexts)
|
||||
{
|
||||
std::string res;
|
||||
|
||||
for (db::Layout::top_down_const_iterator i = layout->begin_top_down (); i != layout->end_top_down(); ++i) {
|
||||
db::LocalProcessorContexts::iterator cc = contexts.context_map ().find (&layout->cell (*i));
|
||||
db::local_processor_contexts<db::PolygonRef>::iterator cc = contexts.context_map ().find (&layout->cell (*i));
|
||||
if (cc != contexts.context_map ().end ()) {
|
||||
int index = 1;
|
||||
for (db::LocalProcessorCellContexts::iterator j = cc->second.begin (); j != cc->second.end (); ++j) {
|
||||
for (db::local_processor_cell_contexts<db::PolygonRef>::iterator j = cc->second.begin (); j != cc->second.end (); ++j) {
|
||||
res += tl::sprintf ("%s[%d] %d insts, %d shapes (%d times)\n", layout->cell_name (*i), index, int (j->first.first.size ()), int (j->first.second.size ()), int (j->second.size ()));
|
||||
index += 1;
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ static void run_test_bool_gen (tl::TestBase *_this, const char *file, TestMode m
|
|||
normalize_layer (layout_org, l2);
|
||||
}
|
||||
|
||||
db::LocalOperation *lop = 0;
|
||||
db::local_operation<db::PolygonRef> *lop = 0;
|
||||
db::BoolAndOrNotLocalOperation bool_op (mode == TMAnd || mode == TMAndSwapped);
|
||||
db::SelfOverlapMergeLocalOperation self_intersect_op (2);
|
||||
BoolAndOrNotWithSizedLocalOperation sized_bool_op (mode == TMAnd || mode == TMAndSwapped, dist);
|
||||
|
|
@ -224,7 +224,7 @@ static void run_test_bool_gen (tl::TestBase *_this, const char *file, TestMode m
|
|||
|
||||
if (single) {
|
||||
|
||||
db::LocalProcessor proc (&layout_org, &layout_org.cell (*layout_org.begin_top_down ()));
|
||||
db::local_processor<db::PolygonRef> proc (&layout_org, &layout_org.cell (*layout_org.begin_top_down ()));
|
||||
proc.set_threads (nthreads);
|
||||
proc.set_area_ratio (3.0);
|
||||
proc.set_max_vertex_count (16);
|
||||
|
|
@ -232,7 +232,7 @@ static void run_test_bool_gen (tl::TestBase *_this, const char *file, TestMode m
|
|||
if (! context_doc) {
|
||||
proc.run (lop, l1, l2, lout);
|
||||
} else {
|
||||
db::LocalProcessorContexts contexts;
|
||||
db::local_processor_contexts<db::PolygonRef> contexts;
|
||||
proc.compute_contexts (contexts, lop, l1, l2);
|
||||
*context_doc = contexts_to_s (&layout_org, contexts);
|
||||
proc.compute_results (contexts, lop, lout);
|
||||
|
|
@ -242,7 +242,7 @@ static void run_test_bool_gen (tl::TestBase *_this, const char *file, TestMode m
|
|||
|
||||
db::Layout layout_org2 = layout_org;
|
||||
|
||||
db::LocalProcessor proc (&layout_org, &layout_org.cell (*layout_org.begin_top_down ()), &layout_org2, &layout_org2.cell (*layout_org2.begin_top_down ()));
|
||||
db::local_processor<db::PolygonRef> proc (&layout_org, &layout_org.cell (*layout_org.begin_top_down ()), &layout_org2, &layout_org2.cell (*layout_org2.begin_top_down ()));
|
||||
proc.set_threads (nthreads);
|
||||
proc.set_area_ratio (3.0);
|
||||
proc.set_max_vertex_count (16);
|
||||
|
|
@ -250,7 +250,7 @@ static void run_test_bool_gen (tl::TestBase *_this, const char *file, TestMode m
|
|||
if (! context_doc) {
|
||||
proc.run (lop, l1, l2, lout);
|
||||
} else {
|
||||
db::LocalProcessorContexts contexts;
|
||||
db::local_processor_contexts<db::PolygonRef> contexts;
|
||||
proc.compute_contexts (contexts, lop, l1, l2);
|
||||
*context_doc = contexts_to_s (&layout_org, contexts);
|
||||
proc.compute_results (contexts, lop, lout);
|
||||
|
|
|
|||
Loading…
Reference in New Issue