mirror of https://github.com/KLayout/klayout.git
WIP: more generalization
This commit is contained in:
parent
1b74607598
commit
453275e67e
|
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#define USE_LOCAL_PROCESSOR // @@@
|
||||
|
||||
namespace db
|
||||
{
|
||||
|
||||
|
|
@ -394,7 +396,7 @@ AsIfFlatRegion::selected_interacting_generic (const Edges &other, bool inverse,
|
|||
scanner.reserve2 (other.size ());
|
||||
|
||||
std::auto_ptr<FlatRegion> output (new FlatRegion (false));
|
||||
region_to_edge_interaction_filter<ResultCountingInserter, db::Polygon> filter (inserter, false, counting /*get all in counting mode*/);
|
||||
region_to_edge_interaction_filter<db::Polygon, db::Edge, ResultCountingInserter> filter (inserter, false, counting /*get all in counting mode*/);
|
||||
|
||||
AddressablePolygonDelivery p (begin_merged ());
|
||||
|
||||
|
|
@ -440,6 +442,27 @@ AsIfFlatRegion::selected_interacting_generic (const Texts &other, bool inverse,
|
|||
return clone ();
|
||||
}
|
||||
|
||||
#if defined(USE_LOCAL_PROCESSOR)
|
||||
|
||||
db::RegionIterator polygons (begin_merged ());
|
||||
|
||||
db::interacting_with_text_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
|
||||
bool counting = !(min_count == 1 && max_count == std::numeric_limits<size_t>::max ());
|
||||
|
||||
std::unordered_map<const db::Polygon *, size_t, std::ptr_hash_from_value<db::Polygon> > counted_results;
|
||||
|
|
@ -480,6 +503,7 @@ AsIfFlatRegion::selected_interacting_generic (const Texts &other, bool inverse,
|
|||
}
|
||||
|
||||
return output.release ();
|
||||
#endif
|
||||
}
|
||||
|
||||
RegionDelegate *
|
||||
|
|
@ -501,7 +525,7 @@ AsIfFlatRegion::selected_interacting_generic (const Region &other, int mode, boo
|
|||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
#if defined(USE_LOCAL_PROCESSOR)
|
||||
|
||||
bool counting = !(min_count == 1 && max_count == std::numeric_limits<size_t>::max ());
|
||||
|
||||
|
|
@ -624,7 +648,7 @@ AsIfFlatRegion::pull_generic (const Edges &other) const
|
|||
scanner.reserve2 (other.size ());
|
||||
|
||||
std::auto_ptr<FlatEdges> output (new FlatEdges (false));
|
||||
region_to_edge_interaction_filter<Shapes, db::Edge> filter (output->raw_edges (), false);
|
||||
region_to_edge_interaction_filter<db::Polygon, db::Edge, db::Shapes, db::Edge> filter (output->raw_edges (), false);
|
||||
|
||||
AddressablePolygonDelivery p (begin ());
|
||||
|
||||
|
|
@ -657,7 +681,7 @@ AsIfFlatRegion::pull_generic (const Texts &other) const
|
|||
scanner.reserve2 (other.size ());
|
||||
|
||||
std::auto_ptr<FlatTexts> output (new FlatTexts (false));
|
||||
region_to_text_interaction_filter<Shapes, db::Text, db::Text> filter (output->raw_texts (), false);
|
||||
region_to_text_interaction_filter<db::Polygon, db::Text, db::Shapes, db::Text> filter (output->raw_texts (), false);
|
||||
|
||||
AddressablePolygonDelivery p (begin ());
|
||||
|
||||
|
|
|
|||
|
|
@ -135,13 +135,13 @@ private:
|
|||
mutable std::unordered_map<shape_type, const shape_type *> m_cache_by_shape;
|
||||
};
|
||||
|
||||
template <>
|
||||
class shape_reference_translator<db::Edge>
|
||||
template <class Shape>
|
||||
class simple_shape_reference_translator
|
||||
{
|
||||
public:
|
||||
typedef db::Edge shape_type;
|
||||
typedef Shape shape_type;
|
||||
|
||||
shape_reference_translator (db::Layout * /*target_layout*/)
|
||||
simple_shape_reference_translator ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
|
@ -159,26 +159,27 @@ public:
|
|||
};
|
||||
|
||||
template <>
|
||||
class shape_reference_translator<db::Polygon>
|
||||
class shape_reference_translator<db::Edge>
|
||||
: public simple_shape_reference_translator<db::Edge>
|
||||
{
|
||||
public:
|
||||
typedef db::Polygon shape_type;
|
||||
shape_reference_translator (db::Layout * /*target_layout*/) { }
|
||||
};
|
||||
|
||||
shape_reference_translator (db::Layout * /*target_layout*/)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
template <>
|
||||
class shape_reference_translator<db::Polygon>
|
||||
: public simple_shape_reference_translator<db::Polygon>
|
||||
{
|
||||
public:
|
||||
shape_reference_translator (db::Layout * /*target_layout*/) { }
|
||||
};
|
||||
|
||||
const shape_type &operator() (const shape_type &s) const
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
template <class Trans>
|
||||
shape_type operator() (const shape_type &s, const Trans &tr) const
|
||||
{
|
||||
return s.transformed (tr);
|
||||
}
|
||||
template <>
|
||||
class shape_reference_translator<db::Text>
|
||||
: public simple_shape_reference_translator<db::Text>
|
||||
{
|
||||
public:
|
||||
shape_reference_translator (db::Layout * /*target_layout*/) { }
|
||||
};
|
||||
|
||||
template <class Ref, class Trans>
|
||||
|
|
@ -338,6 +339,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::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::Edge, db::PolygonRef>;
|
||||
template class DB_PUBLIC local_processor_cell_context<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
||||
|
|
@ -683,6 +685,7 @@ shape_interactions<TS, TI>::intruder_shape (unsigned int id) const
|
|||
}
|
||||
|
||||
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::PolygonRef, db::PolygonRef>;
|
||||
template class DB_PUBLIC shape_interactions<db::PolygonRef, db::Edge>;
|
||||
template class DB_PUBLIC shape_interactions<db::PolygonRef, db::TextRef>;
|
||||
|
|
@ -1038,6 +1041,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::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::Edge, db::PolygonRef>;
|
||||
template class DB_PUBLIC local_processor_context_computation_task<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
||||
|
|
@ -1086,6 +1090,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::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::Edge, db::PolygonRef>;
|
||||
template class DB_PUBLIC local_processor_result_computation_task<db::PolygonRef, db::PolygonRef, db::EdgePair>;
|
||||
|
|
@ -2030,6 +2035,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::Text, db::Polygon>;
|
||||
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::Edge>;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,19 @@ namespace
|
|||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static inline const db::Polygon *push_polygon_to_heap (db::Layout *, const db::Polygon &p, std::list<db::Polygon> &)
|
||||
{
|
||||
return &p;
|
||||
}
|
||||
|
||||
static inline const db::PolygonRef *push_polygon_to_heap (db::Layout *layout, const db::PolygonRef &p, std::list<db::PolygonRef> &heap)
|
||||
{
|
||||
db::PolygonRef ref = db::PolygonRef (p, layout->shape_repository ());
|
||||
heap.push_back (ref);
|
||||
return &heap.back ();
|
||||
}
|
||||
|
||||
|
||||
struct ResultInserter
|
||||
{
|
||||
typedef db::Polygon value_type;
|
||||
|
|
@ -54,29 +67,29 @@ private:
|
|||
std::unordered_set<db::PolygonRef> *mp_result;
|
||||
};
|
||||
|
||||
struct ResultCountingInserter
|
||||
template <class TR>
|
||||
struct result_counting_inserter
|
||||
{
|
||||
typedef db::Polygon value_type;
|
||||
typedef TR value_type;
|
||||
|
||||
ResultCountingInserter (db::Layout *layout, std::unordered_map<db::PolygonRef, size_t> &result)
|
||||
: mp_layout (layout), mp_result (&result)
|
||||
result_counting_inserter (std::unordered_map<TR, size_t> &result)
|
||||
: mp_result (&result)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void insert (const db::Polygon &p)
|
||||
void insert (const TR &p)
|
||||
{
|
||||
(*mp_result)[db::PolygonRef (p, mp_layout->shape_repository ())] += 1;
|
||||
(*mp_result)[p] += 1;
|
||||
}
|
||||
|
||||
void init (const db::Polygon &p)
|
||||
void init (const TR &p)
|
||||
{
|
||||
(*mp_result)[db::PolygonRef (p, mp_layout->shape_repository ())] = 0;
|
||||
(*mp_result)[p] = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
db::Layout *mp_layout;
|
||||
std::unordered_map<db::PolygonRef, size_t> *mp_result;
|
||||
std::unordered_map<TR, size_t> *mp_result;
|
||||
};
|
||||
|
||||
struct EdgeResultInserter
|
||||
|
|
@ -405,10 +418,10 @@ void InteractingWithEdgeLocalOperation::compute_local (db::Layout *layout, const
|
|||
std::unordered_map<db::PolygonRef, size_t> counted_results;
|
||||
bool counting = !(m_min_count == 1 && m_max_count == std::numeric_limits<size_t>::max ());
|
||||
|
||||
db::box_scanner2<db::Polygon, size_t, db::Edge, size_t> scanner;
|
||||
db::box_scanner2<db::PolygonRef, size_t, db::Edge, size_t> scanner;
|
||||
|
||||
ResultCountingInserter inserter (layout, counted_results);
|
||||
region_to_edge_interaction_filter<ResultCountingInserter> filter (inserter, false, counting /*get all in counting mode*/);
|
||||
result_counting_inserter<db::PolygonRef> 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*/);
|
||||
|
||||
std::set<unsigned int> intruder_ids;
|
||||
for (shape_interactions<db::PolygonRef, db::Edge>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||
|
|
@ -421,20 +434,21 @@ void InteractingWithEdgeLocalOperation::compute_local (db::Layout *layout, const
|
|||
scanner.insert2 (& interactions.intruder_shape (*j).second, 0);
|
||||
}
|
||||
|
||||
std::list<db::Polygon> heap;
|
||||
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);
|
||||
heap.push_back (subject.obj ().transformed (subject.trans ()));
|
||||
|
||||
scanner.insert1 (&heap.back (), 0);
|
||||
const db::PolygonRef *addressable = push_polygon_to_heap (layout, subject, heap);
|
||||
|
||||
scanner.insert1 (addressable, 0);
|
||||
if (m_inverse) {
|
||||
inserter.init (heap.back ());
|
||||
inserter.init (*addressable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
scanner.process (filter, 1, db::box_convert<db::Polygon> (), db::box_convert<db::Edge> ());
|
||||
scanner.process (filter, 1, db::box_convert<db::PolygonRef> (), db::box_convert<db::Edge> ());
|
||||
|
||||
// select hits based on their count
|
||||
|
||||
|
|
@ -476,15 +490,15 @@ db::Coord PullWithEdgeLocalOperation::dist () const
|
|||
return 1;
|
||||
}
|
||||
|
||||
void PullWithEdgeLocalOperation::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
|
||||
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
|
||||
{
|
||||
tl_assert (results.size () == 1);
|
||||
std::unordered_set<db::Edge> &result = results.front ();
|
||||
|
||||
db::box_scanner2<db::Polygon, size_t, db::Edge, size_t> scanner;
|
||||
db::box_scanner2<db::PolygonRef, size_t, db::Edge, size_t> scanner;
|
||||
|
||||
EdgeResultInserter inserter (result);
|
||||
region_to_edge_interaction_filter<EdgeResultInserter> filter (inserter, false);
|
||||
region_to_edge_interaction_filter<db::PolygonRef, db::Edge, EdgeResultInserter> filter (inserter, false);
|
||||
|
||||
for (shape_interactions<db::PolygonRef, db::Edge>::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) {
|
||||
|
|
@ -492,17 +506,13 @@ void PullWithEdgeLocalOperation::compute_local (db::Layout *, const shape_intera
|
|||
}
|
||||
}
|
||||
|
||||
std::list<db::Polygon> heap;
|
||||
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);
|
||||
heap.push_back (subject.obj ().transformed (subject.trans ()));
|
||||
|
||||
scanner.insert1 (&heap.back (), 0);
|
||||
|
||||
scanner.insert1 (push_polygon_to_heap (layout, subject, heap), 0);
|
||||
}
|
||||
|
||||
scanner.process (filter, 1, db::box_convert<db::Polygon> (), db::box_convert<db::Edge> ());
|
||||
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
|
||||
|
|
@ -536,7 +546,7 @@ void PullWithTextLocalOperation::compute_local (db::Layout *, const shape_intera
|
|||
db::box_scanner2<db::Polygon, size_t, db::TextRef, size_t> scanner;
|
||||
|
||||
TextResultInserter inserter (result);
|
||||
region_to_text_interaction_filter<TextResultInserter, db::TextRef> filter (inserter, false);
|
||||
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) {
|
||||
|
|
@ -580,31 +590,35 @@ std::string PullWithTextLocalOperation::description () const
|
|||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
InteractingWithTextLocalOperation::InteractingWithTextLocalOperation (bool inverse, size_t min_count, size_t max_count)
|
||||
template <class TS, class TI, class TR>
|
||||
interacting_with_text_local_operation<TS, TI, TR>::interacting_with_text_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)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
db::Coord InteractingWithTextLocalOperation::dist () const
|
||||
template <class TS, class TI, class TR>
|
||||
db::Coord interacting_with_text_local_operation<TS, TI, TR>::dist () const
|
||||
{
|
||||
// touching is sufficient
|
||||
return 1;
|
||||
}
|
||||
|
||||
void InteractingWithTextLocalOperation::compute_local (db::Layout *layout, const shape_interactions<db::PolygonRef, db::TextRef> &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_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
|
||||
{
|
||||
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 ());
|
||||
|
||||
db::box_scanner2<db::Polygon, size_t, db::TextRef, size_t> scanner;
|
||||
db::box_scanner2<TR, size_t, TI, size_t> scanner;
|
||||
|
||||
ResultCountingInserter inserter (layout, counted_results);
|
||||
region_to_text_interaction_filter<ResultCountingInserter, db::TextRef> filter (inserter, false, counting /*get all in counting mode*/);
|
||||
result_counting_inserter<TR> inserter (counted_results);
|
||||
region_to_text_interaction_filter<TS, TI, result_counting_inserter<TR> > filter (inserter, false, counting /*get all in counting mode*/);
|
||||
|
||||
std::set<unsigned int> intruder_ids;
|
||||
for (shape_interactions<db::PolygonRef, db::Edge>::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>::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);
|
||||
}
|
||||
}
|
||||
|
|
@ -613,27 +627,26 @@ void InteractingWithTextLocalOperation::compute_local (db::Layout *layout, const
|
|||
scanner.insert2 (& interactions.intruder_shape (*j).second, 0);
|
||||
}
|
||||
|
||||
std::list<db::Polygon> heap;
|
||||
for (shape_interactions<db::PolygonRef, db::PolygonRef>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||
std::list<TR> heap;
|
||||
for (typename shape_interactions<TS, TI>::iterator i = interactions.begin (); i != interactions.end (); ++i) {
|
||||
|
||||
const db::PolygonRef &subject = interactions.subject_shape (i->first);
|
||||
heap.push_back (subject.obj ().transformed (subject.trans ()));
|
||||
const TR *addressable = push_polygon_to_heap (layout, interactions.subject_shape (i->first), heap);
|
||||
|
||||
scanner.insert1 (&heap.back (), 0);
|
||||
scanner.insert1 (addressable, 0);
|
||||
if (m_inverse) {
|
||||
inserter.init (heap.back ());
|
||||
inserter.init (*addressable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
scanner.process (filter, 1, db::box_convert<db::Polygon> (), db::box_convert<db::TextRef> ());
|
||||
scanner.process (filter, 1, db::box_convert<TR> (), db::box_convert<TI> ());
|
||||
|
||||
// select hits based on their count
|
||||
|
||||
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;
|
||||
if (hit != m_inverse) {
|
||||
result.insert (r->first);
|
||||
|
|
@ -641,18 +654,24 @@ void InteractingWithTextLocalOperation::compute_local (db::Layout *layout, const
|
|||
}
|
||||
}
|
||||
|
||||
InteractingWithTextLocalOperation::on_empty_intruder_mode InteractingWithTextLocalOperation::on_empty_intruder_hint () const
|
||||
template <class TS, class TI, class TR>
|
||||
typename local_operation<TS, TI, TR>::on_empty_intruder_mode interacting_with_text_local_operation<TS, TI, TR>::on_empty_intruder_hint () const
|
||||
{
|
||||
if (!m_inverse) {
|
||||
return Drop;
|
||||
return local_operation<TS, TI, TR>::Drop;
|
||||
} else {
|
||||
return Copy;
|
||||
return local_operation<TS, TI, TR>::Copy;
|
||||
}
|
||||
}
|
||||
|
||||
std::string InteractingWithTextLocalOperation::description () const
|
||||
template <class TS, class TI, class TR>
|
||||
std::string interacting_with_text_local_operation<TS, TI, TR>::description () const
|
||||
{
|
||||
return tl::to_string (tr ("Select regions by their geometric relation to texts"));
|
||||
}
|
||||
|
||||
// explicit instantiations
|
||||
template class interacting_with_text_local_operation<db::PolygonRef, db::TextRef, db::PolygonRef>;
|
||||
template class interacting_with_text_local_operation<db::Polygon, db::Text, db::Polygon>;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,15 +127,16 @@ public:
|
|||
virtual std::string description () const;
|
||||
};
|
||||
|
||||
class InteractingWithTextLocalOperation
|
||||
: public local_operation<db::PolygonRef, db::TextRef, db::PolygonRef>
|
||||
template <class TS, class TI, class TR>
|
||||
class interacting_with_text_local_operation
|
||||
: public local_operation<TS, TI, TR>
|
||||
{
|
||||
public:
|
||||
InteractingWithTextLocalOperation (bool inverse, size_t min_count, size_t max_count);
|
||||
interacting_with_text_local_operation (bool inverse, size_t min_count, size_t max_count);
|
||||
|
||||
virtual db::Coord dist () const;
|
||||
virtual void compute_local (db::Layout *layout, const shape_interactions<db::PolygonRef, db::TextRef> &interactions, std::vector<std::unordered_set<db::PolygonRef> > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const;
|
||||
virtual on_empty_intruder_mode on_empty_intruder_hint () 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 typename local_operation<TS, TI, TR>::on_empty_intruder_mode on_empty_intruder_hint () const;
|
||||
virtual std::string description () const;
|
||||
|
||||
private:
|
||||
|
|
@ -143,6 +144,8 @@ private:
|
|||
size_t m_min_count, m_max_count;
|
||||
};
|
||||
|
||||
typedef interacting_with_text_local_operation<db::PolygonRef, db::TextRef, db::PolygonRef> InteractingWithTextLocalOperation;
|
||||
|
||||
} // namespace db
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -363,23 +363,23 @@ Poly2PolyCheckBase::enter (const db::Polygon &o1, size_t p1, const db::Polygon &
|
|||
// -------------------------------------------------------------------------------------
|
||||
// RegionToEdgeInteractionFilterBase implementation
|
||||
|
||||
template <class OutputType>
|
||||
region_to_edge_interaction_filter_base<OutputType>::region_to_edge_interaction_filter_base (bool inverse, bool get_all)
|
||||
template <class PolygonType, class EdgeType, class OutputType>
|
||||
region_to_edge_interaction_filter_base<PolygonType, EdgeType, OutputType>::region_to_edge_interaction_filter_base (bool inverse, bool get_all)
|
||||
: m_inverse (inverse), m_get_all (get_all)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
template <class OutputType>
|
||||
template <class PolygonType, class EdgeType, class OutputType>
|
||||
void
|
||||
region_to_edge_interaction_filter_base<OutputType>::preset (const OutputType *s)
|
||||
region_to_edge_interaction_filter_base<PolygonType, EdgeType, OutputType>::preset (const OutputType *s)
|
||||
{
|
||||
m_seen.insert (s);
|
||||
}
|
||||
|
||||
template <class OutputType>
|
||||
template <class PolygonType, class EdgeType, class OutputType>
|
||||
void
|
||||
region_to_edge_interaction_filter_base<OutputType>::add (const db::Polygon *p, size_t, const db::Edge *e, size_t)
|
||||
region_to_edge_interaction_filter_base<PolygonType, EdgeType, OutputType>::add (const PolygonType *p, size_t, const EdgeType *e, size_t)
|
||||
{
|
||||
const OutputType *o = 0;
|
||||
tl::select (o, p, e);
|
||||
|
|
@ -392,7 +392,7 @@ region_to_edge_interaction_filter_base<OutputType>::add (const db::Polygon *p, s
|
|||
if (p->box ().contains (e->p1 ()) && db::inside_poly (p->begin_edge (), e->p1 ()) >= 0) {
|
||||
interacts = true;
|
||||
} else {
|
||||
for (db::Polygon::polygon_edge_iterator pe = p->begin_edge (); ! pe.at_end () && ! interacts; ++pe) {
|
||||
for (typename PolygonType::polygon_edge_iterator pe = p->begin_edge (); ! pe.at_end () && ! interacts; ++pe) {
|
||||
if ((*pe).intersect (*e)) {
|
||||
interacts = true;
|
||||
}
|
||||
|
|
@ -413,9 +413,9 @@ region_to_edge_interaction_filter_base<OutputType>::add (const db::Polygon *p, s
|
|||
}
|
||||
}
|
||||
|
||||
template <class OutputType>
|
||||
template <class PolygonType, class EdgeType, class OutputType>
|
||||
void
|
||||
region_to_edge_interaction_filter_base<OutputType>::fill_output ()
|
||||
region_to_edge_interaction_filter_base<PolygonType, EdgeType, OutputType>::fill_output ()
|
||||
{
|
||||
for (typename std::set<const OutputType *>::const_iterator s = m_seen.begin (); s != m_seen.end (); ++s) {
|
||||
put (**s);
|
||||
|
|
@ -423,29 +423,31 @@ region_to_edge_interaction_filter_base<OutputType>::fill_output ()
|
|||
}
|
||||
|
||||
// explicit instantiations
|
||||
template class region_to_edge_interaction_filter_base<db::Polygon>;
|
||||
template class region_to_edge_interaction_filter_base<db::Edge>;
|
||||
template class region_to_edge_interaction_filter_base<db::Polygon, db::Edge, db::Polygon>;
|
||||
template class region_to_edge_interaction_filter_base<db::PolygonRef, db::Edge, db::PolygonRef>;
|
||||
template class region_to_edge_interaction_filter_base<db::Polygon, db::Edge, db::Edge>;
|
||||
template class region_to_edge_interaction_filter_base<db::PolygonRef, db::Edge, db::Edge>;
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// RegionToTextInteractionFilterBase implementation
|
||||
|
||||
template <class OutputType, class TextType>
|
||||
region_to_text_interaction_filter_base<OutputType, TextType>::region_to_text_interaction_filter_base (bool inverse, bool get_all)
|
||||
template <class PolygonType, class TextType, class OutputType>
|
||||
region_to_text_interaction_filter_base<PolygonType, TextType, OutputType>::region_to_text_interaction_filter_base (bool inverse, bool get_all)
|
||||
: m_inverse (inverse), m_get_all (get_all)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
template <class OutputType, class TextType>
|
||||
template <class PolygonType, class TextType, class OutputType>
|
||||
void
|
||||
region_to_text_interaction_filter_base<OutputType, TextType>::preset (const OutputType *s)
|
||||
region_to_text_interaction_filter_base<PolygonType, TextType, OutputType>::preset (const OutputType *s)
|
||||
{
|
||||
m_seen.insert (s);
|
||||
}
|
||||
|
||||
template <class OutputType, class TextType>
|
||||
template <class PolygonType, class TextType, class OutputType>
|
||||
void
|
||||
region_to_text_interaction_filter_base<OutputType, TextType>::add (const db::Polygon *p, size_t, const TextType *t, size_t)
|
||||
region_to_text_interaction_filter_base<PolygonType, TextType, OutputType>::add (const PolygonType *p, size_t, const TextType *t, size_t)
|
||||
{
|
||||
const OutputType *o = 0;
|
||||
tl::select (o, p, t);
|
||||
|
|
@ -469,9 +471,9 @@ region_to_text_interaction_filter_base<OutputType, TextType>::add (const db::Pol
|
|||
}
|
||||
}
|
||||
|
||||
template <class OutputType, class TextType>
|
||||
template <class PolygonType, class TextType, class OutputType>
|
||||
void
|
||||
region_to_text_interaction_filter_base<OutputType, TextType>::fill_output ()
|
||||
region_to_text_interaction_filter_base<PolygonType, TextType, OutputType>::fill_output ()
|
||||
{
|
||||
for (typename std::set<const OutputType *>::const_iterator s = m_seen.begin (); s != m_seen.end (); ++s) {
|
||||
put (**s);
|
||||
|
|
@ -479,10 +481,11 @@ region_to_text_interaction_filter_base<OutputType, TextType>::fill_output ()
|
|||
}
|
||||
|
||||
// explicit instantiations
|
||||
template class region_to_text_interaction_filter_base<db::Polygon, db::TextRef>;
|
||||
template class region_to_text_interaction_filter_base<db::Polygon, db::Text>;
|
||||
template class region_to_text_interaction_filter_base<db::Text, db::Text>;
|
||||
template class region_to_text_interaction_filter_base<db::TextRef, db::TextRef>;
|
||||
template class region_to_text_interaction_filter_base<db::PolygonRef, db::TextRef, db::PolygonRef>;
|
||||
template class region_to_text_interaction_filter_base<db::Polygon, db::Text, db::Polygon>;
|
||||
template class region_to_text_interaction_filter_base<db::Polygon, db::Text, db::Text>;
|
||||
template class region_to_text_interaction_filter_base<db::Polygon, db::TextRef, db::TextRef>;
|
||||
template class region_to_text_interaction_filter_base<db::PolygonRef, db::TextRef, db::TextRef>;
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Polygon snapping
|
||||
|
|
|
|||
|
|
@ -591,15 +591,15 @@ public:
|
|||
/**
|
||||
* @brief A helper class for the region to edge interaction functionality
|
||||
*/
|
||||
template <class OutputType>
|
||||
template <class PolygonType, class EdgeType, class OutputType>
|
||||
class DB_PUBLIC region_to_edge_interaction_filter_base
|
||||
: public db::box_scanner_receiver2<db::Polygon, size_t, db::Edge, size_t>
|
||||
: public db::box_scanner_receiver2<PolygonType, size_t, db::Edge, size_t>
|
||||
{
|
||||
public:
|
||||
region_to_edge_interaction_filter_base (bool inverse, bool get_all);
|
||||
|
||||
void preset (const OutputType *s);
|
||||
void add (const db::Polygon *p, size_t, const db::Edge *e, size_t);
|
||||
void add (const PolygonType *p, size_t, const EdgeType *e, size_t);
|
||||
void fill_output ();
|
||||
|
||||
protected:
|
||||
|
|
@ -613,21 +613,21 @@ private:
|
|||
/**
|
||||
* @brief A helper class for the region to edge interaction functionality
|
||||
*/
|
||||
template <class OutputContainer, class OutputType = typename OutputContainer::value_type>
|
||||
template <class PolygonType, class EdgeType, class OutputContainer, class OutputType = typename OutputContainer::value_type>
|
||||
class DB_PUBLIC_TEMPLATE region_to_edge_interaction_filter
|
||||
: public region_to_edge_interaction_filter_base<OutputType>
|
||||
: public region_to_edge_interaction_filter_base<PolygonType, EdgeType, OutputType>
|
||||
{
|
||||
public:
|
||||
region_to_edge_interaction_filter (OutputContainer &output, bool inverse, bool get_all = false)
|
||||
: region_to_edge_interaction_filter_base<OutputType> (inverse, get_all), mp_output (&output)
|
||||
: region_to_edge_interaction_filter_base<PolygonType, EdgeType, OutputType> (inverse, get_all), mp_output (&output)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void put (const OutputType &poly) const
|
||||
virtual void put (const OutputType &res) const
|
||||
{
|
||||
mp_output->insert (poly);
|
||||
mp_output->insert (res);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -637,15 +637,15 @@ private:
|
|||
/**
|
||||
* @brief A helper class for the region to text interaction functionality
|
||||
*/
|
||||
template <class OutputType, class TextType>
|
||||
template <class PolygonType, class TextType, class OutputType>
|
||||
class DB_PUBLIC region_to_text_interaction_filter_base
|
||||
: public db::box_scanner_receiver2<db::Polygon, size_t, TextType, size_t>
|
||||
: public db::box_scanner_receiver2<PolygonType, size_t, TextType, size_t>
|
||||
{
|
||||
public:
|
||||
region_to_text_interaction_filter_base (bool inverse, bool get_all);
|
||||
|
||||
void preset (const OutputType *s);
|
||||
void add (const db::Polygon *p, size_t, const TextType *e, size_t);
|
||||
void add (const PolygonType *p, size_t, const TextType *e, size_t);
|
||||
void fill_output ();
|
||||
|
||||
protected:
|
||||
|
|
@ -659,13 +659,13 @@ private:
|
|||
/**
|
||||
* @brief A helper class for the region to text interaction functionality
|
||||
*/
|
||||
template <class OutputContainer, class TextType, class OutputType = typename OutputContainer::value_type>
|
||||
template <class PolygonType, class TextType, class OutputContainer, class OutputType = typename OutputContainer::value_type>
|
||||
class DB_PUBLIC_TEMPLATE region_to_text_interaction_filter
|
||||
: public region_to_text_interaction_filter_base<OutputType, TextType>
|
||||
: public region_to_text_interaction_filter_base<PolygonType, TextType, OutputType>
|
||||
{
|
||||
public:
|
||||
region_to_text_interaction_filter (OutputContainer &output, bool inverse, bool get_all = false)
|
||||
: region_to_text_interaction_filter_base<OutputType, TextType> (inverse, get_all), mp_output (&output)
|
||||
: region_to_text_interaction_filter_base<PolygonType, TextType, OutputType> (inverse, get_all), mp_output (&output)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue