mirror of https://github.com/KLayout/klayout.git
WIP: more generalization
This commit is contained in:
parent
bb5d30e0c0
commit
145c298d58
|
|
@ -665,21 +665,21 @@ AsIfFlatRegion::pull_generic (const Edges &other) const
|
||||||
return new EmptyEdges ();
|
return new EmptyEdges ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // @@@ defined(USE_LOCAL_PROCESSOR)
|
#if defined(USE_LOCAL_PROCESSOR)
|
||||||
|
|
||||||
db::RegionIterator polygons (begin_merged ());
|
db::RegionIterator polygons (begin ());
|
||||||
|
|
||||||
db::pull_local_operation (<db::Polygon, db::Text, db::Polygon> op (inverse, min_count, max_count);
|
db::pull_with_edge_local_operation <db::Polygon, db::Edge, db::Edge> op;
|
||||||
|
|
||||||
db::local_processor<db::Polygon, db::Text, db::Polygon> proc;
|
db::local_processor<db::Polygon, db::Edge, db::Edge> proc;
|
||||||
proc.set_base_verbosity (base_verbosity ());
|
proc.set_base_verbosity (base_verbosity ());
|
||||||
|
|
||||||
std::vector<generic_shape_iterator<db::Text> > others;
|
std::vector<generic_shape_iterator<db::Edge> > others;
|
||||||
others.push_back (other.begin ());
|
others.push_back (other.begin_merged ());
|
||||||
|
|
||||||
std::auto_ptr<FlatRegion> output (new FlatRegion (merged_semantics ()));
|
std::auto_ptr<FlatEdges> output (new FlatEdges (merged_semantics ()));
|
||||||
std::vector<db::Shapes *> results;
|
std::vector<db::Shapes *> results;
|
||||||
results.push_back (&output->raw_polygons ());
|
results.push_back (&output->raw_edges ());
|
||||||
|
|
||||||
proc.run_flat (polygons, others, &op, results);
|
proc.run_flat (polygons, others, &op, results);
|
||||||
|
|
||||||
|
|
@ -715,6 +715,27 @@ AsIfFlatRegion::pull_generic (const Edges &other) const
|
||||||
TextsDelegate *
|
TextsDelegate *
|
||||||
AsIfFlatRegion::pull_generic (const Texts &other) const
|
AsIfFlatRegion::pull_generic (const Texts &other) const
|
||||||
{
|
{
|
||||||
|
#if defined(USE_LOCAL_PROCESSOR)
|
||||||
|
|
||||||
|
db::RegionIterator polygons (begin ());
|
||||||
|
|
||||||
|
db::pull_with_text_local_operation <db::Polygon, db::Text, db::Text> op;
|
||||||
|
|
||||||
|
db::local_processor<db::Polygon, db::Text, db::Text> proc;
|
||||||
|
proc.set_base_verbosity (base_verbosity ());
|
||||||
|
|
||||||
|
std::vector<generic_shape_iterator<db::Text> > others;
|
||||||
|
others.push_back (other.begin ());
|
||||||
|
|
||||||
|
std::auto_ptr<FlatTexts> output (new FlatTexts (merged_semantics ()));
|
||||||
|
std::vector<db::Shapes *> results;
|
||||||
|
results.push_back (&output->raw_texts ());
|
||||||
|
|
||||||
|
proc.run_flat (polygons, others, &op, results);
|
||||||
|
|
||||||
|
return output.release ();
|
||||||
|
|
||||||
|
#else
|
||||||
if (other.empty ()) {
|
if (other.empty ()) {
|
||||||
return other.delegate ()->clone ();
|
return other.delegate ()->clone ();
|
||||||
} else if (empty ()) {
|
} else if (empty ()) {
|
||||||
|
|
@ -743,6 +764,7 @@ AsIfFlatRegion::pull_generic (const Texts &other) const
|
||||||
scanner.process (filter, 1, db::box_convert<db::Polygon> (), db::box_convert<db::Text> ());
|
scanner.process (filter, 1, db::box_convert<db::Polygon> (), db::box_convert<db::Text> ());
|
||||||
|
|
||||||
return output.release ();
|
return output.release ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionDelegate *
|
RegionDelegate *
|
||||||
|
|
|
||||||
|
|
@ -340,8 +340,10 @@ local_processor_cell_context<TS, TI, TR>::propagate (unsigned int output_layer,
|
||||||
|
|
||||||
template class DB_PUBLIC local_processor_cell_context<db::Polygon, db::Polygon, db::Polygon>;
|
template class DB_PUBLIC local_processor_cell_context<db::Polygon, db::Polygon, db::Polygon>;
|
||||||
template class DB_PUBLIC local_processor_cell_context<db::Polygon, db::Text, db::Polygon>;
|
template class DB_PUBLIC local_processor_cell_context<db::Polygon, db::Text, db::Polygon>;
|
||||||
template class DB_PUBLIC local_processor_cell_context<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
|
||||||
template class DB_PUBLIC local_processor_cell_context<db::Polygon, db::Edge, db::Polygon>;
|
template class DB_PUBLIC local_processor_cell_context<db::Polygon, db::Edge, db::Polygon>;
|
||||||
|
template class DB_PUBLIC local_processor_cell_context<db::Polygon, db::Text, db::Text>;
|
||||||
|
template class DB_PUBLIC local_processor_cell_context<db::Polygon, db::Edge, db::Edge>;
|
||||||
|
template class DB_PUBLIC local_processor_cell_context<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
||||||
template class DB_PUBLIC local_processor_cell_context<db::PolygonRef, db::Edge, db::PolygonRef>;
|
template class DB_PUBLIC local_processor_cell_context<db::PolygonRef, db::Edge, db::PolygonRef>;
|
||||||
template class DB_PUBLIC local_processor_cell_context<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
template class DB_PUBLIC local_processor_cell_context<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
||||||
template class DB_PUBLIC local_processor_cell_context<db::Edge, db::Edge, db::Edge>;
|
template class DB_PUBLIC local_processor_cell_context<db::Edge, db::Edge, db::Edge>;
|
||||||
|
|
@ -587,8 +589,11 @@ local_processor_cell_contexts<TS, TI, TR>::compute_results (const local_processo
|
||||||
}
|
}
|
||||||
|
|
||||||
template class DB_PUBLIC local_processor_cell_contexts<db::Polygon, db::Polygon, db::Polygon>;
|
template class DB_PUBLIC local_processor_cell_contexts<db::Polygon, db::Polygon, db::Polygon>;
|
||||||
template class DB_PUBLIC local_processor_cell_contexts<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
|
||||||
template class DB_PUBLIC local_processor_cell_contexts<db::Polygon, db::Edge, db::Polygon>;
|
template class DB_PUBLIC local_processor_cell_contexts<db::Polygon, db::Edge, db::Polygon>;
|
||||||
|
template class DB_PUBLIC local_processor_cell_contexts<db::Polygon, db::Edge, db::Edge>;
|
||||||
|
template class DB_PUBLIC local_processor_cell_contexts<db::Polygon, db::Text, db::Polygon>;
|
||||||
|
template class DB_PUBLIC local_processor_cell_contexts<db::Polygon, db::Text, db::Text>;
|
||||||
|
template class DB_PUBLIC local_processor_cell_contexts<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
||||||
template class DB_PUBLIC local_processor_cell_contexts<db::PolygonRef, db::Edge, db::PolygonRef>;
|
template class DB_PUBLIC local_processor_cell_contexts<db::PolygonRef, db::Edge, db::PolygonRef>;
|
||||||
template class DB_PUBLIC local_processor_cell_contexts<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
template class DB_PUBLIC local_processor_cell_contexts<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
||||||
template class DB_PUBLIC local_processor_cell_contexts<db::Edge, db::PolygonRef, db::Edge>;
|
template class DB_PUBLIC local_processor_cell_contexts<db::Edge, db::PolygonRef, db::Edge>;
|
||||||
|
|
@ -1045,8 +1050,10 @@ local_processor_context_computation_task<TS, TI, TR>::perform ()
|
||||||
|
|
||||||
template class DB_PUBLIC local_processor_context_computation_task<db::Polygon, db::Polygon, db::Polygon>;
|
template class DB_PUBLIC local_processor_context_computation_task<db::Polygon, db::Polygon, db::Polygon>;
|
||||||
template class DB_PUBLIC local_processor_context_computation_task<db::Polygon, db::Text, db::Polygon>;
|
template class DB_PUBLIC local_processor_context_computation_task<db::Polygon, db::Text, db::Polygon>;
|
||||||
template class DB_PUBLIC local_processor_context_computation_task<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
template class DB_PUBLIC local_processor_context_computation_task<db::Polygon, db::Text, db::Text>;
|
||||||
template class DB_PUBLIC local_processor_context_computation_task<db::Polygon, db::Edge, db::Polygon>;
|
template class DB_PUBLIC local_processor_context_computation_task<db::Polygon, db::Edge, db::Polygon>;
|
||||||
|
template class DB_PUBLIC local_processor_context_computation_task<db::Polygon, db::Edge, db::Edge>;
|
||||||
|
template class DB_PUBLIC local_processor_context_computation_task<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
||||||
template class DB_PUBLIC local_processor_context_computation_task<db::PolygonRef, db::Edge, db::PolygonRef>;
|
template class DB_PUBLIC local_processor_context_computation_task<db::PolygonRef, db::Edge, db::PolygonRef>;
|
||||||
template class DB_PUBLIC local_processor_context_computation_task<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
template class DB_PUBLIC local_processor_context_computation_task<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
||||||
template class DB_PUBLIC local_processor_context_computation_task<db::Edge, db::Edge, db::Edge>;
|
template class DB_PUBLIC local_processor_context_computation_task<db::Edge, db::Edge, db::Edge>;
|
||||||
|
|
@ -1095,8 +1102,10 @@ local_processor_result_computation_task<TS, TI, TR>::perform ()
|
||||||
|
|
||||||
template class DB_PUBLIC local_processor_result_computation_task<db::Polygon, db::Polygon, db::Polygon>;
|
template class DB_PUBLIC local_processor_result_computation_task<db::Polygon, db::Polygon, db::Polygon>;
|
||||||
template class DB_PUBLIC local_processor_result_computation_task<db::Polygon, db::Text, db::Polygon>;
|
template class DB_PUBLIC local_processor_result_computation_task<db::Polygon, db::Text, db::Polygon>;
|
||||||
template class DB_PUBLIC local_processor_result_computation_task<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
template class DB_PUBLIC local_processor_result_computation_task<db::Polygon, db::Text, db::Text>;
|
||||||
template class DB_PUBLIC local_processor_result_computation_task<db::Polygon, db::Edge, db::Polygon>;
|
template class DB_PUBLIC local_processor_result_computation_task<db::Polygon, db::Edge, db::Polygon>;
|
||||||
|
template class DB_PUBLIC local_processor_result_computation_task<db::Polygon, db::Edge, db::Edge>;
|
||||||
|
template class DB_PUBLIC local_processor_result_computation_task<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
||||||
template class DB_PUBLIC local_processor_result_computation_task<db::PolygonRef, db::Edge, db::PolygonRef>;
|
template class DB_PUBLIC local_processor_result_computation_task<db::PolygonRef, db::Edge, db::PolygonRef>;
|
||||||
template class DB_PUBLIC local_processor_result_computation_task<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
template class DB_PUBLIC local_processor_result_computation_task<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
||||||
template class DB_PUBLIC local_processor_result_computation_task<db::Edge, db::Edge, db::Edge>;
|
template class DB_PUBLIC local_processor_result_computation_task<db::Edge, db::Edge, db::Edge>;
|
||||||
|
|
@ -2041,7 +2050,9 @@ local_processor<TS, TI, TR>::run_flat (const generic_shape_iterator<TS> &subject
|
||||||
|
|
||||||
template class DB_PUBLIC local_processor<db::Polygon, db::Polygon, db::Polygon>;
|
template class DB_PUBLIC local_processor<db::Polygon, db::Polygon, db::Polygon>;
|
||||||
template class DB_PUBLIC local_processor<db::Polygon, db::Text, db::Polygon>;
|
template class DB_PUBLIC local_processor<db::Polygon, db::Text, db::Polygon>;
|
||||||
|
template class DB_PUBLIC local_processor<db::Polygon, db::Text, db::Text>;
|
||||||
template class DB_PUBLIC local_processor<db::Polygon, db::Edge, db::Polygon>;
|
template class DB_PUBLIC local_processor<db::Polygon, db::Edge, db::Polygon>;
|
||||||
|
template class DB_PUBLIC local_processor<db::Polygon, db::Edge, db::Edge>;
|
||||||
template class DB_PUBLIC local_processor<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
template class DB_PUBLIC local_processor<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
||||||
template class DB_PUBLIC local_processor<db::PolygonRef, db::Edge, db::PolygonRef>;
|
template class DB_PUBLIC local_processor<db::PolygonRef, db::Edge, db::PolygonRef>;
|
||||||
template class DB_PUBLIC local_processor<db::PolygonRef, db::Edge, db::Edge>;
|
template class DB_PUBLIC local_processor<db::PolygonRef, db::Edge, db::Edge>;
|
||||||
|
|
|
||||||
|
|
@ -92,42 +92,24 @@ private:
|
||||||
std::unordered_map<TR, size_t> *mp_result;
|
std::unordered_map<TR, size_t> *mp_result;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EdgeResultInserter
|
template <class TR>
|
||||||
|
struct simple_result_inserter
|
||||||
{
|
{
|
||||||
typedef db::Edge value_type;
|
typedef TR value_type;
|
||||||
|
|
||||||
EdgeResultInserter (std::unordered_set<db::Edge> &result)
|
simple_result_inserter<TR> (std::unordered_set<TR> &result)
|
||||||
: mp_result (&result)
|
: mp_result (&result)
|
||||||
{
|
{
|
||||||
// .. nothing yet ..
|
// .. nothing yet ..
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert (const db::Edge &e)
|
void insert (const TR &e)
|
||||||
{
|
{
|
||||||
(*mp_result).insert (e);
|
(*mp_result).insert (e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_set<db::Edge> *mp_result;
|
std::unordered_set<TR> *mp_result;
|
||||||
};
|
|
||||||
|
|
||||||
struct TextResultInserter
|
|
||||||
{
|
|
||||||
typedef db::TextRef value_type;
|
|
||||||
|
|
||||||
TextResultInserter (std::unordered_set<db::TextRef> &result)
|
|
||||||
: mp_result (&result)
|
|
||||||
{
|
|
||||||
// .. nothing yet ..
|
|
||||||
}
|
|
||||||
|
|
||||||
void insert (const db::TextRef &e)
|
|
||||||
{
|
|
||||||
(*mp_result).insert (e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unordered_set<db::TextRef> *mp_result;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -495,84 +477,39 @@ template class interacting_with_edge_local_operation<db::Polygon, db::Edge, db::
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
PullWithEdgeLocalOperation::PullWithEdgeLocalOperation ()
|
template <class TS, class TI, class TR>
|
||||||
|
pull_with_edge_local_operation<TS, TI, TR>::pull_with_edge_local_operation ()
|
||||||
{
|
{
|
||||||
// .. nothing yet ..
|
// .. nothing yet ..
|
||||||
}
|
}
|
||||||
|
|
||||||
db::Coord PullWithEdgeLocalOperation::dist () const
|
template <class TS, class TI, class TR>
|
||||||
|
db::Coord pull_with_edge_local_operation<TS, TI, TR>::dist () const
|
||||||
{
|
{
|
||||||
// touching is sufficient
|
// touching is sufficient
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PullWithEdgeLocalOperation::compute_local (db::Layout *layout, const shape_interactions<db::PolygonRef, db::Edge> &interactions, std::vector<std::unordered_set<db::Edge> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const
|
template <class TS, class TI, class TR>
|
||||||
|
void pull_with_edge_local_operation<TS, TI, TR>::compute_local (db::Layout *layout, const shape_interactions<TS, TI> &interactions, std::vector<std::unordered_set<TR> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const
|
||||||
{
|
{
|
||||||
tl_assert (results.size () == 1);
|
tl_assert (results.size () == 1);
|
||||||
std::unordered_set<db::Edge> &result = results.front ();
|
std::unordered_set<TR> &result = results.front ();
|
||||||
|
|
||||||
db::box_scanner2<db::PolygonRef, size_t, db::Edge, size_t> scanner;
|
db::box_scanner2<TS, size_t, TI, size_t> scanner;
|
||||||
|
|
||||||
EdgeResultInserter inserter (result);
|
simple_result_inserter<TR> inserter (result);
|
||||||
region_to_edge_interaction_filter<db::PolygonRef, db::Edge, EdgeResultInserter> filter (inserter, false);
|
region_to_edge_interaction_filter<TS, TI, simple_result_inserter<TR> > filter (inserter, false);
|
||||||
|
|
||||||
for (shape_interactions<db::PolygonRef, db::Edge>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
std::list<TS> heap;
|
||||||
for (shape_interactions<db::PolygonRef, db::Edge>::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||||
scanner.insert2 (& interactions.intruder_shape (*j).second, 0);
|
const TS &subject = interactions.subject_shape (i->first);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<db::PolygonRef> heap;
|
|
||||||
for (shape_interactions<db::PolygonRef, db::PolygonRef>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
|
||||||
const db::PolygonRef &subject = interactions.subject_shape (i->first);
|
|
||||||
scanner.insert1 (push_polygon_to_heap (layout, subject, heap), 0);
|
scanner.insert1 (push_polygon_to_heap (layout, subject, heap), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner.process (filter, 1, db::box_convert<db::PolygonRef> (), db::box_convert<db::Edge> ());
|
|
||||||
}
|
|
||||||
|
|
||||||
PullWithEdgeLocalOperation::on_empty_intruder_mode PullWithEdgeLocalOperation::on_empty_intruder_hint () const
|
|
||||||
{
|
|
||||||
return Drop;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string PullWithEdgeLocalOperation::description () const
|
|
||||||
{
|
|
||||||
return tl::to_string (tr ("Pull edges from second by their geometric relation to first"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
PullWithTextLocalOperation::PullWithTextLocalOperation ()
|
|
||||||
{
|
|
||||||
// .. nothing yet ..
|
|
||||||
}
|
|
||||||
|
|
||||||
db::Coord PullWithTextLocalOperation::dist () const
|
|
||||||
{
|
|
||||||
// touching is sufficient
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PullWithTextLocalOperation::compute_local (db::Layout *, const shape_interactions<db::PolygonRef, db::TextRef> &interactions, std::vector<std::unordered_set<db::TextRef> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const
|
|
||||||
{
|
|
||||||
tl_assert (results.size () == 1);
|
|
||||||
std::unordered_set<db::TextRef> &result = results.front ();
|
|
||||||
|
|
||||||
db::box_scanner2<db::Polygon, size_t, db::TextRef, size_t> scanner;
|
|
||||||
|
|
||||||
TextResultInserter inserter (result);
|
|
||||||
region_to_text_interaction_filter<db::Polygon, db::TextRef, TextResultInserter> filter (inserter, false);
|
|
||||||
|
|
||||||
for (shape_interactions<db::PolygonRef, db::TextRef>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
|
||||||
for (shape_interactions<db::PolygonRef, db::TextRef>::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
|
||||||
scanner.insert2 (& interactions.intruder_shape (*j).second, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<unsigned int> intruder_ids;
|
std::set<unsigned int> intruder_ids;
|
||||||
for (shape_interactions<db::PolygonRef, db::Edge>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||||
for (shape_interactions<db::PolygonRef, db::Edge>::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
for (typename shape_interactions<TS, TI>::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
||||||
intruder_ids.insert (*j);
|
intruder_ids.insert (*j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -581,29 +518,91 @@ void PullWithTextLocalOperation::compute_local (db::Layout *, const shape_intera
|
||||||
scanner.insert2 (& interactions.intruder_shape (*j).second, 0);
|
scanner.insert2 (& interactions.intruder_shape (*j).second, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<db::Polygon> heap;
|
scanner.process (filter, 1, db::box_convert<TS> (), db::box_convert<TI> ());
|
||||||
for (shape_interactions<db::PolygonRef, db::PolygonRef>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
}
|
||||||
|
|
||||||
const db::PolygonRef &subject = interactions.subject_shape (i->first);
|
template <class TS, class TI, class TR>
|
||||||
heap.push_back (subject.obj ().transformed (subject.trans ()));
|
typename local_operation<TS, TI, TR>::on_empty_intruder_mode pull_with_edge_local_operation<TS, TI, TR>::on_empty_intruder_hint () const
|
||||||
|
{
|
||||||
|
return local_operation<TS, TI, TR>::Drop;
|
||||||
|
}
|
||||||
|
|
||||||
scanner.insert1 (&heap.back (), 0);
|
template <class TS, class TI, class TR>
|
||||||
|
std::string pull_with_edge_local_operation<TS, TI, TR>::description () const
|
||||||
|
{
|
||||||
|
return tl::to_string (tr ("Pull edges from second by their geometric relation to first"));
|
||||||
|
}
|
||||||
|
|
||||||
|
template class pull_with_edge_local_operation<db::PolygonRef, db::Edge, db::Edge>;
|
||||||
|
template class pull_with_edge_local_operation<db::Polygon, db::Edge, db::Edge>;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template <class TS, class TI, class TR>
|
||||||
|
pull_with_text_local_operation<TS, TI, TR>::pull_with_text_local_operation ()
|
||||||
|
{
|
||||||
|
// .. nothing yet ..
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class TS, class TI, class TR>
|
||||||
|
db::Coord pull_with_text_local_operation<TS, TI, TR>::dist () const
|
||||||
|
{
|
||||||
|
// touching is sufficient
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class TS, class TI, class TR>
|
||||||
|
void pull_with_text_local_operation<TS, TI, TR>::compute_local (db::Layout *layout, const shape_interactions<TS, TI> &interactions, std::vector<std::unordered_set<TR> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const
|
||||||
|
{
|
||||||
|
tl_assert (results.size () == 1);
|
||||||
|
std::unordered_set<TR> &result = results.front ();
|
||||||
|
|
||||||
|
db::box_scanner2<TS, size_t, TI, size_t> scanner;
|
||||||
|
|
||||||
|
simple_result_inserter<TR> inserter (result);
|
||||||
|
region_to_text_interaction_filter<TS, TI, simple_result_inserter<TR> > filter (inserter, false);
|
||||||
|
|
||||||
|
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||||
|
for (typename shape_interactions<TS, TI>::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
||||||
|
scanner.insert2 (& interactions.intruder_shape (*j).second, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner.process (filter, 1, db::box_convert<db::Polygon> (), db::box_convert<db::TextRef> ());
|
std::set<unsigned int> intruder_ids;
|
||||||
|
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||||
|
for (typename shape_interactions<TS, TI>::iterator2 j = i->second.begin (); j != i->second.end (); ++j) {
|
||||||
|
intruder_ids.insert (*j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::set<unsigned int>::const_iterator j = intruder_ids.begin (); j != intruder_ids.end (); ++j) {
|
||||||
|
scanner.insert2 (& interactions.intruder_shape (*j).second, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<TS> heap;
|
||||||
|
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||||
|
const TS *subject = push_polygon_to_heap (layout, interactions.subject_shape (i->first), heap);
|
||||||
|
scanner.insert1 (subject, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
scanner.process (filter, 1, db::box_convert<TS> (), db::box_convert<TI> ());
|
||||||
}
|
}
|
||||||
|
|
||||||
PullWithTextLocalOperation::on_empty_intruder_mode PullWithTextLocalOperation::on_empty_intruder_hint () const
|
template <class TS, class TI, class TR>
|
||||||
|
typename local_operation<TS, TI, TR>::on_empty_intruder_mode pull_with_text_local_operation<TS, TI, TR>::on_empty_intruder_hint () const
|
||||||
{
|
{
|
||||||
return Drop;
|
return local_operation<TS, TI, TR>::Drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PullWithTextLocalOperation::description () const
|
template <class TS, class TI, class TR>
|
||||||
|
std::string pull_with_text_local_operation<TS, TI, TR>::description () const
|
||||||
{
|
{
|
||||||
return tl::to_string (tr ("Pull texts from second by their geometric relation to first"));
|
return tl::to_string (tr ("Pull texts from second by their geometric relation to first"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template class pull_with_text_local_operation<db::PolygonRef, db::TextRef, db::TextRef>;
|
||||||
|
template class pull_with_text_local_operation<db::Polygon, db::Text, db::Text>;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
template <class TS, class TI, class TR>
|
template <class TS, class TI, class TR>
|
||||||
|
|
|
||||||
|
|
@ -109,18 +109,21 @@ private:
|
||||||
|
|
||||||
typedef interacting_with_edge_local_operation<db::PolygonRef, db::Edge, db::PolygonRef> InteractingWithEdgeLocalOperation;
|
typedef interacting_with_edge_local_operation<db::PolygonRef, db::Edge, db::PolygonRef> InteractingWithEdgeLocalOperation;
|
||||||
|
|
||||||
class PullWithEdgeLocalOperation
|
template <class TS, class TI, class TR>
|
||||||
: public local_operation<db::PolygonRef, db::Edge, db::Edge>
|
class pull_with_edge_local_operation
|
||||||
|
: public local_operation<TS, TI, TR>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PullWithEdgeLocalOperation ();
|
pull_with_edge_local_operation ();
|
||||||
|
|
||||||
virtual db::Coord dist () const;
|
virtual db::Coord dist () const;
|
||||||
virtual void compute_local (db::Layout *, const shape_interactions<db::PolygonRef, db::Edge> &interactions, std::vector<std::unordered_set<db::Edge> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const;
|
virtual void compute_local (db::Layout *, const shape_interactions<TS, TI> &interactions, std::vector<std::unordered_set<TR> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const;
|
||||||
virtual on_empty_intruder_mode on_empty_intruder_hint () const;
|
virtual typename local_operation<TS, TI, TR>::on_empty_intruder_mode on_empty_intruder_hint () const;
|
||||||
virtual std::string description () const;
|
virtual std::string description () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef pull_with_edge_local_operation<db::PolygonRef, db::Edge, db::Edge> PullWithEdgeLocalOperation;
|
||||||
|
|
||||||
template <class TS, class TI, class TR>
|
template <class TS, class TI, class TR>
|
||||||
class interacting_with_text_local_operation
|
class interacting_with_text_local_operation
|
||||||
: public local_operation<TS, TI, TR>
|
: public local_operation<TS, TI, TR>
|
||||||
|
|
@ -140,18 +143,21 @@ private:
|
||||||
|
|
||||||
typedef interacting_with_text_local_operation<db::PolygonRef, db::TextRef, db::PolygonRef> InteractingWithTextLocalOperation;
|
typedef interacting_with_text_local_operation<db::PolygonRef, db::TextRef, db::PolygonRef> InteractingWithTextLocalOperation;
|
||||||
|
|
||||||
class PullWithTextLocalOperation
|
template <class TS, class TI, class TR>
|
||||||
: public local_operation<db::PolygonRef, db::TextRef, db::TextRef>
|
class pull_with_text_local_operation
|
||||||
|
: public local_operation<TS, TI, TR>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PullWithTextLocalOperation ();
|
pull_with_text_local_operation ();
|
||||||
|
|
||||||
virtual db::Coord dist () const;
|
virtual db::Coord dist () const;
|
||||||
virtual void compute_local (db::Layout *, const shape_interactions<db::PolygonRef, db::TextRef> &interactions, std::vector<std::unordered_set<db::TextRef> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const;
|
virtual void compute_local (db::Layout *, const shape_interactions<TS, TI> &interactions, std::vector<std::unordered_set<TR> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const;
|
||||||
virtual on_empty_intruder_mode on_empty_intruder_hint () const;
|
virtual typename local_operation<TS, TI, TR>::on_empty_intruder_mode on_empty_intruder_hint () const;
|
||||||
virtual std::string description () const;
|
virtual std::string description () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef pull_with_text_local_operation<db::PolygonRef, db::TextRef, db::TextRef> PullWithTextLocalOperation;
|
||||||
|
|
||||||
} // namespace db
|
} // namespace db
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue