diff --git a/src/db/db/dbAsIfFlatRegion.cc b/src/db/db/dbAsIfFlatRegion.cc index e6faa10c0..0f6c89940 100644 --- a/src/db/db/dbAsIfFlatRegion.cc +++ b/src/db/db/dbAsIfFlatRegion.cc @@ -665,21 +665,21 @@ AsIfFlatRegion::pull_generic (const Edges &other) const 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 ( op (inverse, min_count, max_count); + db::pull_with_edge_local_operation op; - db::local_processor proc; + db::local_processor proc; proc.set_base_verbosity (base_verbosity ()); - std::vector > others; - others.push_back (other.begin ()); + std::vector > others; + others.push_back (other.begin_merged ()); - std::auto_ptr output (new FlatRegion (merged_semantics ())); + std::auto_ptr output (new FlatEdges (merged_semantics ())); std::vector results; - results.push_back (&output->raw_polygons ()); + results.push_back (&output->raw_edges ()); proc.run_flat (polygons, others, &op, results); @@ -715,6 +715,27 @@ AsIfFlatRegion::pull_generic (const Edges &other) const TextsDelegate * AsIfFlatRegion::pull_generic (const Texts &other) const { +#if defined(USE_LOCAL_PROCESSOR) + + db::RegionIterator polygons (begin ()); + + db::pull_with_text_local_operation op; + + db::local_processor proc; + proc.set_base_verbosity (base_verbosity ()); + + std::vector > others; + others.push_back (other.begin ()); + + std::auto_ptr output (new FlatTexts (merged_semantics ())); + std::vector results; + results.push_back (&output->raw_texts ()); + + proc.run_flat (polygons, others, &op, results); + + return output.release (); + +#else if (other.empty ()) { return other.delegate ()->clone (); } else if (empty ()) { @@ -743,6 +764,7 @@ AsIfFlatRegion::pull_generic (const Texts &other) const scanner.process (filter, 1, db::box_convert (), db::box_convert ()); return output.release (); +#endif } RegionDelegate * diff --git a/src/db/db/dbHierProcessor.cc b/src/db/db/dbHierProcessor.cc index e07eb2f9f..d759e0837 100644 --- a/src/db/db/dbHierProcessor.cc +++ b/src/db/db/dbHierProcessor.cc @@ -340,8 +340,10 @@ local_processor_cell_context::propagate (unsigned int output_layer, template class DB_PUBLIC local_processor_cell_context; template class DB_PUBLIC local_processor_cell_context; -template class DB_PUBLIC local_processor_cell_context; template class DB_PUBLIC local_processor_cell_context; +template class DB_PUBLIC local_processor_cell_context; +template class DB_PUBLIC local_processor_cell_context; +template class DB_PUBLIC local_processor_cell_context; template class DB_PUBLIC local_processor_cell_context; template class DB_PUBLIC local_processor_cell_context; template class DB_PUBLIC local_processor_cell_context; @@ -587,8 +589,11 @@ local_processor_cell_contexts::compute_results (const local_processo } template class DB_PUBLIC local_processor_cell_contexts; -template class DB_PUBLIC local_processor_cell_contexts; template class DB_PUBLIC local_processor_cell_contexts; +template class DB_PUBLIC local_processor_cell_contexts; +template class DB_PUBLIC local_processor_cell_contexts; +template class DB_PUBLIC local_processor_cell_contexts; +template class DB_PUBLIC local_processor_cell_contexts; template class DB_PUBLIC local_processor_cell_contexts; template class DB_PUBLIC local_processor_cell_contexts; template class DB_PUBLIC local_processor_cell_contexts; @@ -1045,8 +1050,10 @@ local_processor_context_computation_task::perform () template class DB_PUBLIC local_processor_context_computation_task; template class DB_PUBLIC local_processor_context_computation_task; -template class DB_PUBLIC local_processor_context_computation_task; +template class DB_PUBLIC local_processor_context_computation_task; template class DB_PUBLIC local_processor_context_computation_task; +template class DB_PUBLIC local_processor_context_computation_task; +template class DB_PUBLIC local_processor_context_computation_task; template class DB_PUBLIC local_processor_context_computation_task; template class DB_PUBLIC local_processor_context_computation_task; template class DB_PUBLIC local_processor_context_computation_task; @@ -1095,8 +1102,10 @@ local_processor_result_computation_task::perform () template class DB_PUBLIC local_processor_result_computation_task; template class DB_PUBLIC local_processor_result_computation_task; -template class DB_PUBLIC local_processor_result_computation_task; +template class DB_PUBLIC local_processor_result_computation_task; template class DB_PUBLIC local_processor_result_computation_task; +template class DB_PUBLIC local_processor_result_computation_task; +template class DB_PUBLIC local_processor_result_computation_task; template class DB_PUBLIC local_processor_result_computation_task; template class DB_PUBLIC local_processor_result_computation_task; template class DB_PUBLIC local_processor_result_computation_task; @@ -2041,7 +2050,9 @@ local_processor::run_flat (const generic_shape_iterator &subject template class DB_PUBLIC local_processor; template class DB_PUBLIC local_processor; +template class DB_PUBLIC local_processor; template class DB_PUBLIC local_processor; +template class DB_PUBLIC local_processor; template class DB_PUBLIC local_processor; template class DB_PUBLIC local_processor; template class DB_PUBLIC local_processor; diff --git a/src/db/db/dbRegionLocalOperations.cc b/src/db/db/dbRegionLocalOperations.cc index 8c84273c9..004c63bfb 100644 --- a/src/db/db/dbRegionLocalOperations.cc +++ b/src/db/db/dbRegionLocalOperations.cc @@ -92,42 +92,24 @@ private: std::unordered_map *mp_result; }; -struct EdgeResultInserter +template +struct simple_result_inserter { - typedef db::Edge value_type; + typedef TR value_type; - EdgeResultInserter (std::unordered_set &result) + simple_result_inserter (std::unordered_set &result) : mp_result (&result) { // .. nothing yet .. } - void insert (const db::Edge &e) + void insert (const TR &e) { (*mp_result).insert (e); } private: - std::unordered_set *mp_result; -}; - -struct TextResultInserter -{ - typedef db::TextRef value_type; - - TextResultInserter (std::unordered_set &result) - : mp_result (&result) - { - // .. nothing yet .. - } - - void insert (const db::TextRef &e) - { - (*mp_result).insert (e); - } - -private: - std::unordered_set *mp_result; + std::unordered_set *mp_result; }; } @@ -495,84 +477,39 @@ template class interacting_with_edge_local_operation +pull_with_edge_local_operation::pull_with_edge_local_operation () { // .. nothing yet .. } -db::Coord PullWithEdgeLocalOperation::dist () const +template +db::Coord pull_with_edge_local_operation::dist () const { // touching is sufficient return 1; } -void PullWithEdgeLocalOperation::compute_local (db::Layout *layout, const shape_interactions &interactions, std::vector > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const +template +void pull_with_edge_local_operation::compute_local (db::Layout *layout, const shape_interactions &interactions, std::vector > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const { tl_assert (results.size () == 1); - std::unordered_set &result = results.front (); + std::unordered_set &result = results.front (); - db::box_scanner2 scanner; + db::box_scanner2 scanner; - EdgeResultInserter inserter (result); - region_to_edge_interaction_filter filter (inserter, false); + simple_result_inserter inserter (result); + region_to_edge_interaction_filter > filter (inserter, false); - for (shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { - for (shape_interactions::iterator2 j = i->second.begin (); j != i->second.end (); ++j) { - scanner.insert2 (& interactions.intruder_shape (*j).second, 0); - } - } - - std::list heap; - for (shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { - const db::PolygonRef &subject = interactions.subject_shape (i->first); + std::list heap; + for (typename shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { + const TS &subject = interactions.subject_shape (i->first); scanner.insert1 (push_polygon_to_heap (layout, subject, heap), 0); } - scanner.process (filter, 1, db::box_convert (), db::box_convert ()); -} - -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 &interactions, std::vector > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const -{ - tl_assert (results.size () == 1); - std::unordered_set &result = results.front (); - - db::box_scanner2 scanner; - - TextResultInserter inserter (result); - region_to_text_interaction_filter filter (inserter, false); - - for (shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { - for (shape_interactions::iterator2 j = i->second.begin (); j != i->second.end (); ++j) { - scanner.insert2 (& interactions.intruder_shape (*j).second, 0); - } - } - std::set intruder_ids; - for (shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { - for (shape_interactions::iterator2 j = i->second.begin (); j != i->second.end (); ++j) { + for (typename shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { + for (typename shape_interactions::iterator2 j = i->second.begin (); j != i->second.end (); ++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); } - std::list heap; - for (shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { + scanner.process (filter, 1, db::box_convert (), db::box_convert ()); +} - const db::PolygonRef &subject = interactions.subject_shape (i->first); - heap.push_back (subject.obj ().transformed (subject.trans ())); +template +typename local_operation::on_empty_intruder_mode pull_with_edge_local_operation::on_empty_intruder_hint () const +{ + return local_operation::Drop; +} - scanner.insert1 (&heap.back (), 0); +template +std::string pull_with_edge_local_operation::description () const +{ + return tl::to_string (tr ("Pull edges from second by their geometric relation to first")); +} +template class pull_with_edge_local_operation; +template class pull_with_edge_local_operation; + +// --------------------------------------------------------------------------------------------------------------- + +template +pull_with_text_local_operation::pull_with_text_local_operation () +{ + // .. nothing yet .. +} + +template +db::Coord pull_with_text_local_operation::dist () const +{ + // touching is sufficient + return 1; +} + +template +void pull_with_text_local_operation::compute_local (db::Layout *layout, const shape_interactions &interactions, std::vector > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const +{ + tl_assert (results.size () == 1); + std::unordered_set &result = results.front (); + + db::box_scanner2 scanner; + + simple_result_inserter inserter (result); + region_to_text_interaction_filter > filter (inserter, false); + + for (typename shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { + for (typename shape_interactions::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::box_convert ()); + std::set intruder_ids; + for (typename shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { + for (typename shape_interactions::iterator2 j = i->second.begin (); j != i->second.end (); ++j) { + intruder_ids.insert (*j); + } + } + + for (std::set::const_iterator j = intruder_ids.begin (); j != intruder_ids.end (); ++j) { + scanner.insert2 (& interactions.intruder_shape (*j).second, 0); + } + + std::list heap; + for (typename shape_interactions::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 (), db::box_convert ()); } -PullWithTextLocalOperation::on_empty_intruder_mode PullWithTextLocalOperation::on_empty_intruder_hint () const +template +typename local_operation::on_empty_intruder_mode pull_with_text_local_operation::on_empty_intruder_hint () const { - return Drop; + return local_operation::Drop; } -std::string PullWithTextLocalOperation::description () const +template +std::string pull_with_text_local_operation::description () const { return tl::to_string (tr ("Pull texts from second by their geometric relation to first")); } +template class pull_with_text_local_operation; +template class pull_with_text_local_operation; + // --------------------------------------------------------------------------------------------------------------- template diff --git a/src/db/db/dbRegionLocalOperations.h b/src/db/db/dbRegionLocalOperations.h index d653d4a45..0fa0aa865 100644 --- a/src/db/db/dbRegionLocalOperations.h +++ b/src/db/db/dbRegionLocalOperations.h @@ -109,18 +109,21 @@ private: typedef interacting_with_edge_local_operation InteractingWithEdgeLocalOperation; -class PullWithEdgeLocalOperation - : public local_operation +template +class pull_with_edge_local_operation + : public local_operation { public: - PullWithEdgeLocalOperation (); + pull_with_edge_local_operation (); virtual db::Coord dist () const; - virtual void compute_local (db::Layout *, const shape_interactions &interactions, std::vector > &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 *, const shape_interactions &interactions, std::vector > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const; + virtual typename local_operation::on_empty_intruder_mode on_empty_intruder_hint () const; virtual std::string description () const; }; +typedef pull_with_edge_local_operation PullWithEdgeLocalOperation; + template class interacting_with_text_local_operation : public local_operation @@ -140,18 +143,21 @@ private: typedef interacting_with_text_local_operation InteractingWithTextLocalOperation; -class PullWithTextLocalOperation - : public local_operation +template +class pull_with_text_local_operation + : public local_operation { public: - PullWithTextLocalOperation (); + pull_with_text_local_operation (); virtual db::Coord dist () const; - virtual void compute_local (db::Layout *, const shape_interactions &interactions, std::vector > &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 *, const shape_interactions &interactions, std::vector > &results, size_t /*max_vertex_count*/, double /*area_ratio*/) const; + virtual typename local_operation::on_empty_intruder_mode on_empty_intruder_hint () const; virtual std::string description () const; }; +typedef pull_with_text_local_operation PullWithTextLocalOperation; + } // namespace db #endif