mirror of https://github.com/KLayout/klayout.git
WIP: more generalization
This commit is contained in:
parent
453275e67e
commit
bb5d30e0c0
|
|
@ -388,6 +388,27 @@ AsIfFlatRegion::selected_interacting_generic (const Edges &other, bool inverse,
|
||||||
|
|
||||||
bool counting = !(min_count == 1 && max_count == std::numeric_limits<size_t>::max ());
|
bool counting = !(min_count == 1 && max_count == std::numeric_limits<size_t>::max ());
|
||||||
|
|
||||||
|
#if defined(USE_LOCAL_PROCESSOR)
|
||||||
|
|
||||||
|
db::RegionIterator polygons (begin_merged ());
|
||||||
|
|
||||||
|
db::interacting_with_edge_local_operation<db::Polygon, db::Edge, db::Polygon> op (inverse, min_count, max_count);
|
||||||
|
|
||||||
|
db::local_processor<db::Polygon, db::Edge, db::Polygon> proc;
|
||||||
|
proc.set_base_verbosity (base_verbosity ());
|
||||||
|
|
||||||
|
std::vector<generic_shape_iterator<db::Edge> > others;
|
||||||
|
others.push_back (counting ? other.begin_merged () : other.begin ());
|
||||||
|
|
||||||
|
std::auto_ptr<FlatRegion> output (new FlatRegion (merged_semantics ()));
|
||||||
|
std::vector<db::Shapes *> results;
|
||||||
|
results.push_back (&output->raw_polygons ());
|
||||||
|
|
||||||
|
proc.run_flat (polygons, others, &op, results);
|
||||||
|
|
||||||
|
return output.release ();
|
||||||
|
|
||||||
|
#else
|
||||||
std::unordered_map<const db::Polygon *, size_t, std::ptr_hash_from_value<db::Polygon> > counted_results;
|
std::unordered_map<const db::Polygon *, size_t, std::ptr_hash_from_value<db::Polygon> > counted_results;
|
||||||
ResultCountingInserter inserter (counted_results);
|
ResultCountingInserter inserter (counted_results);
|
||||||
|
|
||||||
|
|
@ -425,6 +446,7 @@ AsIfFlatRegion::selected_interacting_generic (const Edges &other, bool inverse,
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.release ();
|
return output.release ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionDelegate *
|
RegionDelegate *
|
||||||
|
|
@ -643,6 +665,28 @@ AsIfFlatRegion::pull_generic (const Edges &other) const
|
||||||
return new EmptyEdges ();
|
return new EmptyEdges ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // @@@ defined(USE_LOCAL_PROCESSOR)
|
||||||
|
|
||||||
|
db::RegionIterator polygons (begin_merged ());
|
||||||
|
|
||||||
|
db::pull_local_operation (<db::Polygon, db::Text, db::Polygon> op (inverse, min_count, max_count);
|
||||||
|
|
||||||
|
db::local_processor<db::Polygon, db::Text, db::Polygon> proc;
|
||||||
|
proc.set_base_verbosity (base_verbosity ());
|
||||||
|
|
||||||
|
std::vector<generic_shape_iterator<db::Text> > others;
|
||||||
|
others.push_back (other.begin ());
|
||||||
|
|
||||||
|
std::auto_ptr<FlatRegion> output (new FlatRegion (merged_semantics ()));
|
||||||
|
std::vector<db::Shapes *> results;
|
||||||
|
results.push_back (&output->raw_polygons ());
|
||||||
|
|
||||||
|
proc.run_flat (polygons, others, &op, results);
|
||||||
|
|
||||||
|
return output.release ();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
db::box_scanner2<db::Polygon, size_t, db::Edge, size_t> scanner (report_progress (), progress_desc ());
|
db::box_scanner2<db::Polygon, size_t, db::Edge, size_t> scanner (report_progress (), progress_desc ());
|
||||||
scanner.reserve1 (size ());
|
scanner.reserve1 (size ());
|
||||||
scanner.reserve2 (other.size ());
|
scanner.reserve2 (other.size ());
|
||||||
|
|
@ -665,6 +709,7 @@ AsIfFlatRegion::pull_generic (const Edges &other) const
|
||||||
scanner.process (filter, 1, db::box_convert<db::Polygon> (), db::box_convert<db::Edge> ());
|
scanner.process (filter, 1, db::box_convert<db::Polygon> (), db::box_convert<db::Edge> ());
|
||||||
|
|
||||||
return output.release ();
|
return output.release ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TextsDelegate *
|
TextsDelegate *
|
||||||
|
|
@ -703,6 +748,27 @@ AsIfFlatRegion::pull_generic (const Texts &other) const
|
||||||
RegionDelegate *
|
RegionDelegate *
|
||||||
AsIfFlatRegion::pull_generic (const Region &other, int mode, bool touching) const
|
AsIfFlatRegion::pull_generic (const Region &other, int mode, bool touching) const
|
||||||
{
|
{
|
||||||
|
#if defined(USE_LOCAL_PROCESSOR)
|
||||||
|
|
||||||
|
db::RegionIterator polygons (begin ());
|
||||||
|
|
||||||
|
db::pull_local_operation <db::Polygon, db::Polygon, db::Polygon> op (mode, touching);
|
||||||
|
|
||||||
|
db::local_processor<db::Polygon, db::Polygon, db::Polygon> proc;
|
||||||
|
proc.set_base_verbosity (base_verbosity ());
|
||||||
|
|
||||||
|
std::vector<generic_shape_iterator<db::Polygon> > others;
|
||||||
|
others.push_back (other.begin_merged ());
|
||||||
|
|
||||||
|
std::auto_ptr<FlatRegion> output (new FlatRegion (merged_semantics ()));
|
||||||
|
std::vector<db::Shapes *> results;
|
||||||
|
results.push_back (&output->raw_polygons ());
|
||||||
|
|
||||||
|
proc.run_flat (polygons, others, &op, results);
|
||||||
|
|
||||||
|
return output.release ();
|
||||||
|
|
||||||
|
#else
|
||||||
db::EdgeProcessor ep (report_progress (), progress_desc ());
|
db::EdgeProcessor ep (report_progress (), progress_desc ());
|
||||||
ep.set_base_verbosity (base_verbosity ());
|
ep.set_base_verbosity (base_verbosity ());
|
||||||
|
|
||||||
|
|
@ -751,6 +817,7 @@ AsIfFlatRegion::pull_generic (const Region &other, int mode, bool touching) cons
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.release ();
|
return output.release ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Trans>
|
template <class Trans>
|
||||||
|
|
|
||||||
|
|
@ -341,6 +341,7 @@ 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::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::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,6 +588,7 @@ 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::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::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>;
|
||||||
|
|
@ -688,6 +690,7 @@ template class DB_PUBLIC shape_interactions<db::Polygon, db::Polygon>;
|
||||||
template class DB_PUBLIC shape_interactions<db::Polygon, db::Text>;
|
template class DB_PUBLIC shape_interactions<db::Polygon, db::Text>;
|
||||||
template class DB_PUBLIC shape_interactions<db::PolygonRef, db::PolygonRef>;
|
template class DB_PUBLIC shape_interactions<db::PolygonRef, db::PolygonRef>;
|
||||||
template class DB_PUBLIC shape_interactions<db::PolygonRef, db::Edge>;
|
template class DB_PUBLIC shape_interactions<db::PolygonRef, db::Edge>;
|
||||||
|
template class DB_PUBLIC shape_interactions<db::Polygon, db::Edge>;
|
||||||
template class DB_PUBLIC shape_interactions<db::PolygonRef, db::TextRef>;
|
template class DB_PUBLIC shape_interactions<db::PolygonRef, db::TextRef>;
|
||||||
template class DB_PUBLIC shape_interactions<db::Edge, db::Edge>;
|
template class DB_PUBLIC shape_interactions<db::Edge, db::Edge>;
|
||||||
template class DB_PUBLIC shape_interactions<db::Edge, db::PolygonRef>;
|
template class DB_PUBLIC shape_interactions<db::Edge, db::PolygonRef>;
|
||||||
|
|
@ -1043,6 +1046,7 @@ 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::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
||||||
|
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::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>;
|
||||||
|
|
@ -1092,6 +1096,7 @@ 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::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
||||||
|
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::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>;
|
||||||
|
|
@ -2036,6 +2041,7 @@ 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::Edge, db::Polygon>;
|
||||||
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>;
|
||||||
|
|
|
||||||
|
|
@ -331,41 +331,44 @@ template class interacting_local_operation<db::Polygon, db::Polygon, db::Polygon
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
PullLocalOperation::PullLocalOperation (int mode, bool touching)
|
template <class TS, class TI, class TR>
|
||||||
|
pull_local_operation<TS, TI, TR>::pull_local_operation (int mode, bool touching)
|
||||||
: m_mode (mode), m_touching (touching)
|
: m_mode (mode), m_touching (touching)
|
||||||
{
|
{
|
||||||
// .. nothing yet ..
|
// .. nothing yet ..
|
||||||
}
|
}
|
||||||
|
|
||||||
db::Coord PullLocalOperation::dist () const
|
template <class TS, class TI, class TR>
|
||||||
|
db::Coord pull_local_operation<TS, TI, TR>::dist () const
|
||||||
{
|
{
|
||||||
return m_touching ? 1 : 0;
|
return m_touching ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PullLocalOperation::compute_local (db::Layout * /*layout*/, const shape_interactions<db::PolygonRef, db::PolygonRef> &interactions, std::vector<std::unordered_set<db::PolygonRef> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const
|
template <class TS, class TI, class TR>
|
||||||
|
void pull_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::PolygonRef> &result = results.front ();
|
std::unordered_set<TR> &result = results.front ();
|
||||||
|
|
||||||
db::EdgeProcessor ep;
|
db::EdgeProcessor ep;
|
||||||
|
|
||||||
std::set<db::PolygonRef> others;
|
std::set<TI> others;
|
||||||
for (shape_interactions<db::PolygonRef, db::PolygonRef>::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::PolygonRef>::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) {
|
||||||
others.insert (interactions.intruder_shape (*j).second);
|
others.insert (interactions.intruder_shape (*j).second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (shape_interactions<db::PolygonRef, db::PolygonRef>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||||
const db::PolygonRef &subject = interactions.subject_shape (i->first);
|
const TS &subject = interactions.subject_shape (i->first);
|
||||||
for (db::PolygonRef::polygon_edge_iterator e = subject.begin_edge (); ! e.at_end(); ++e) {
|
for (typename TS::polygon_edge_iterator e = subject.begin_edge (); ! e.at_end(); ++e) {
|
||||||
ep.insert (*e, 0);
|
ep.insert (*e, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t n = 1;
|
size_t n = 1;
|
||||||
for (std::set<db::PolygonRef>::const_iterator o = others.begin (); o != others.end (); ++o, ++n) {
|
for (typename std::set<TI>::const_iterator o = others.begin (); o != others.end (); ++o, ++n) {
|
||||||
for (db::PolygonRef::polygon_edge_iterator e = o->begin_edge (); ! e.at_end(); ++e) {
|
for (typename TI::polygon_edge_iterator e = o->begin_edge (); ! e.at_end(); ++e) {
|
||||||
ep.insert (*e, n);
|
ep.insert (*e, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -382,50 +385,58 @@ void PullLocalOperation::compute_local (db::Layout * /*layout*/, const shape_int
|
||||||
}
|
}
|
||||||
|
|
||||||
n = 1;
|
n = 1;
|
||||||
for (std::set<db::PolygonRef>::const_iterator o = others.begin (); o != others.end (); ++o, ++n) {
|
for (typename std::set<TI>::const_iterator o = others.begin (); o != others.end (); ++o, ++n) {
|
||||||
if (selected.find (n) != selected.end ()) {
|
if (selected.find (n) != selected.end ()) {
|
||||||
result.insert (*o);
|
result.insert (*o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PullLocalOperation::on_empty_intruder_mode PullLocalOperation::on_empty_intruder_hint () const
|
template <class TS, class TI, class TR>
|
||||||
|
typename local_operation<TS, TI, TR>::on_empty_intruder_mode pull_local_operation<TS, TI, TR>::on_empty_intruder_hint () const
|
||||||
{
|
{
|
||||||
return Drop;
|
return local_operation<TS, TI, TR>::Drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PullLocalOperation::description () const
|
template <class TS, class TI, class TR>
|
||||||
|
std::string pull_local_operation<TS, TI, TR>::description () const
|
||||||
{
|
{
|
||||||
return tl::to_string (tr ("Pull regions by their geometrical relation to first"));
|
return tl::to_string (tr ("Pull regions by their geometrical relation to first"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template class pull_local_operation<db::PolygonRef, db::PolygonRef, db::PolygonRef>;
|
||||||
|
template class pull_local_operation<db::Polygon, db::Polygon, db::Polygon>;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
InteractingWithEdgeLocalOperation::InteractingWithEdgeLocalOperation (bool inverse, size_t min_count, size_t max_count)
|
template <class TS, class TI, class TR>
|
||||||
|
interacting_with_edge_local_operation<TS, TI, TR>::interacting_with_edge_local_operation (bool inverse, size_t min_count, size_t max_count)
|
||||||
: m_inverse (inverse), m_min_count (std::max (size_t (1), min_count)), m_max_count (max_count)
|
: m_inverse (inverse), m_min_count (std::max (size_t (1), min_count)), m_max_count (max_count)
|
||||||
{
|
{
|
||||||
// .. nothing yet ..
|
// .. nothing yet ..
|
||||||
}
|
}
|
||||||
|
|
||||||
db::Coord InteractingWithEdgeLocalOperation::dist () const
|
template <class TS, class TI, class TR>
|
||||||
|
db::Coord interacting_with_edge_local_operation<TS, TI, TR>::dist () const
|
||||||
{
|
{
|
||||||
// touching is sufficient
|
// touching is sufficient
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InteractingWithEdgeLocalOperation::compute_local (db::Layout *layout, const shape_interactions<db::PolygonRef, db::Edge> &interactions, std::vector<std::unordered_set<db::PolygonRef> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const
|
template <class TS, class TI, class TR>
|
||||||
|
void interacting_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
|
||||||
{
|
{
|
||||||
std::unordered_map<db::PolygonRef, size_t> counted_results;
|
std::unordered_map<TR, size_t> counted_results;
|
||||||
bool counting = !(m_min_count == 1 && m_max_count == std::numeric_limits<size_t>::max ());
|
bool counting = !(m_min_count == 1 && m_max_count == std::numeric_limits<size_t>::max ());
|
||||||
|
|
||||||
db::box_scanner2<db::PolygonRef, size_t, db::Edge, size_t> scanner;
|
db::box_scanner2<TS, size_t, TI, size_t> scanner;
|
||||||
|
|
||||||
result_counting_inserter<db::PolygonRef> inserter (counted_results);
|
result_counting_inserter<TR> inserter (counted_results);
|
||||||
region_to_edge_interaction_filter<db::PolygonRef, db::Edge, result_counting_inserter<db::PolygonRef> > filter (inserter, false, counting /*get all in counting mode*/);
|
region_to_edge_interaction_filter<TS, TI, result_counting_inserter<TR> > filter (inserter, false, counting /*get all in counting mode*/);
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -434,12 +445,12 @@ void InteractingWithEdgeLocalOperation::compute_local (db::Layout *layout, const
|
||||||
scanner.insert2 (& interactions.intruder_shape (*j).second, 0);
|
scanner.insert2 (& interactions.intruder_shape (*j).second, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<db::PolygonRef> heap;
|
std::list<TR> heap;
|
||||||
for (shape_interactions<db::PolygonRef, db::PolygonRef>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||||
|
|
||||||
const db::PolygonRef &subject = interactions.subject_shape (i->first);
|
const TS &subject = interactions.subject_shape (i->first);
|
||||||
|
|
||||||
const db::PolygonRef *addressable = push_polygon_to_heap (layout, subject, heap);
|
const TR *addressable = push_polygon_to_heap (layout, subject, heap);
|
||||||
|
|
||||||
scanner.insert1 (addressable, 0);
|
scanner.insert1 (addressable, 0);
|
||||||
if (m_inverse) {
|
if (m_inverse) {
|
||||||
|
|
@ -448,14 +459,14 @@ void InteractingWithEdgeLocalOperation::compute_local (db::Layout *layout, const
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner.process (filter, 1, db::box_convert<db::PolygonRef> (), db::box_convert<db::Edge> ());
|
scanner.process (filter, 1, db::box_convert<TS> (), db::box_convert<TI> ());
|
||||||
|
|
||||||
// select hits based on their count
|
// select hits based on their count
|
||||||
|
|
||||||
tl_assert (results.size () == 1);
|
tl_assert (results.size () == 1);
|
||||||
std::unordered_set<db::PolygonRef> &result = results.front ();
|
std::unordered_set<TR> &result = results.front ();
|
||||||
|
|
||||||
for (std::unordered_map<db::PolygonRef, size_t>::const_iterator r = counted_results.begin (); r != counted_results.end (); ++r) {
|
for (typename std::unordered_map<TR, size_t>::const_iterator r = counted_results.begin (); r != counted_results.end (); ++r) {
|
||||||
bool hit = r->second >= m_min_count && r->second <= m_max_count;
|
bool hit = r->second >= m_min_count && r->second <= m_max_count;
|
||||||
if (hit != m_inverse) {
|
if (hit != m_inverse) {
|
||||||
result.insert (r->first);
|
result.insert (r->first);
|
||||||
|
|
@ -463,20 +474,25 @@ void InteractingWithEdgeLocalOperation::compute_local (db::Layout *layout, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InteractingWithEdgeLocalOperation::on_empty_intruder_mode InteractingWithEdgeLocalOperation::on_empty_intruder_hint () const
|
template <class TS, class TI, class TR>
|
||||||
|
typename local_operation<TS, TI, TR>::on_empty_intruder_mode interacting_with_edge_local_operation<TS, TI, TR>::on_empty_intruder_hint () const
|
||||||
{
|
{
|
||||||
if (!m_inverse) {
|
if (!m_inverse) {
|
||||||
return Drop;
|
return local_operation<TS, TI, TR>::Drop;
|
||||||
} else {
|
} else {
|
||||||
return Copy;
|
return local_operation<TS, TI, TR>::Copy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string InteractingWithEdgeLocalOperation::description () const
|
template <class TS, class TI, class TR>
|
||||||
|
std::string interacting_with_edge_local_operation<TS, TI, TR>::description () const
|
||||||
{
|
{
|
||||||
return tl::to_string (tr ("Select regions by their geometric relation to edges"));
|
return tl::to_string (tr ("Select regions by their geometric relation to edges"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template class interacting_with_edge_local_operation<db::PolygonRef, db::Edge, db::PolygonRef>;
|
||||||
|
template class interacting_with_edge_local_operation<db::Polygon, db::Edge, db::Polygon>;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
PullWithEdgeLocalOperation::PullWithEdgeLocalOperation ()
|
PullWithEdgeLocalOperation::PullWithEdgeLocalOperation ()
|
||||||
|
|
|
||||||
|
|
@ -71,15 +71,16 @@ private:
|
||||||
|
|
||||||
typedef interacting_local_operation<db::PolygonRef, db::PolygonRef, db::PolygonRef> InteractingLocalOperation;
|
typedef interacting_local_operation<db::PolygonRef, db::PolygonRef, db::PolygonRef> InteractingLocalOperation;
|
||||||
|
|
||||||
class PullLocalOperation
|
template <class TS, class TI, class TR>
|
||||||
: public local_operation<db::PolygonRef, db::PolygonRef, db::PolygonRef>
|
class pull_local_operation
|
||||||
|
: public local_operation<TS, TI, TR>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PullLocalOperation (int mode, bool touching);
|
pull_local_operation (int mode, bool touching);
|
||||||
|
|
||||||
virtual db::Coord dist () const;
|
virtual db::Coord dist () const;
|
||||||
virtual void compute_local (db::Layout * /*layout*/, const shape_interactions<db::PolygonRef, db::PolygonRef> &interactions, std::vector<std::unordered_set<db::PolygonRef> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const;
|
virtual void 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;
|
||||||
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;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -87,15 +88,18 @@ private:
|
||||||
bool m_touching;
|
bool m_touching;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InteractingWithEdgeLocalOperation
|
typedef pull_local_operation<db::PolygonRef, db::PolygonRef, db::PolygonRef> PullLocalOperation;
|
||||||
: public local_operation<db::PolygonRef, db::Edge, db::PolygonRef>
|
|
||||||
|
template <class TS, class TI, class TR>
|
||||||
|
class interacting_with_edge_local_operation
|
||||||
|
: public local_operation<TS, TI, TR>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InteractingWithEdgeLocalOperation (bool inverse, size_t min_count, size_t max_count);
|
interacting_with_edge_local_operation (bool inverse, size_t min_count, size_t max_count);
|
||||||
|
|
||||||
virtual db::Coord dist () const;
|
virtual db::Coord dist () const;
|
||||||
virtual void compute_local (db::Layout *layout, const shape_interactions<db::PolygonRef, db::Edge> &interactions, std::vector<std::unordered_set<db::PolygonRef> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const;
|
virtual void 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;
|
||||||
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;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -103,6 +107,8 @@ private:
|
||||||
size_t m_min_count, m_max_count;
|
size_t m_min_count, m_max_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef interacting_with_edge_local_operation<db::PolygonRef, db::Edge, db::PolygonRef> InteractingWithEdgeLocalOperation;
|
||||||
|
|
||||||
class PullWithEdgeLocalOperation
|
class PullWithEdgeLocalOperation
|
||||||
: public local_operation<db::PolygonRef, db::Edge, db::Edge>
|
: public local_operation<db::PolygonRef, db::Edge, db::Edge>
|
||||||
{
|
{
|
||||||
|
|
@ -115,18 +121,6 @@ public:
|
||||||
virtual std::string description () const;
|
virtual std::string description () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PullWithTextLocalOperation
|
|
||||||
: public local_operation<db::PolygonRef, db::TextRef, db::TextRef>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PullWithTextLocalOperation ();
|
|
||||||
|
|
||||||
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 on_empty_intruder_mode on_empty_intruder_hint () const;
|
|
||||||
virtual std::string description () const;
|
|
||||||
};
|
|
||||||
|
|
||||||
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>
|
||||||
|
|
@ -146,6 +140,18 @@ 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
|
||||||
|
: public local_operation<db::PolygonRef, db::TextRef, db::TextRef>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PullWithTextLocalOperation ();
|
||||||
|
|
||||||
|
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 on_empty_intruder_mode on_empty_intruder_hint () const;
|
||||||
|
virtual std::string description () const;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace db
|
} // namespace db
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue