diff --git a/src/db/db/db.pro b/src/db/db/db.pro index 295976015..f4cb732bc 100644 --- a/src/db/db/db.pro +++ b/src/db/db/db.pro @@ -58,6 +58,7 @@ SOURCES = \ dbLog.cc \ dbManager.cc \ dbMatrix.cc \ + dbMeasure.cc \ dbMemStatistics.cc \ dbMutableEdgePairs.cc \ dbMutableEdges.cc \ @@ -295,6 +296,7 @@ HEADERS = \ dbLog.h \ dbManager.h \ dbMatrix.h \ + dbMeasure.h \ dbMemStatistics.h \ dbMetaInfo.h \ dbMutableEdgePairs.h \ diff --git a/src/db/db/dbAsIfFlatEdgePairs.cc b/src/db/db/dbAsIfFlatEdgePairs.cc index 29dc42390..1eb18c432 100644 --- a/src/db/db/dbAsIfFlatEdgePairs.cc +++ b/src/db/db/dbAsIfFlatEdgePairs.cc @@ -160,13 +160,17 @@ AsIfFlatEdgePairs::processed (const EdgePairProcessorBase &filter) const { std::unique_ptr edge_pairs (new FlatEdgePairs ()); - std::vector res_edge_pairs; + std::vector res_edge_pairs; for (EdgePairsIterator e = begin (); ! e.at_end (); ++e) { res_edge_pairs.clear (); - filter.process (*e, res_edge_pairs); - for (std::vector::const_iterator er = res_edge_pairs.begin (); er != res_edge_pairs.end (); ++er) { - edge_pairs->insert (*er); + filter.process (e.wp (), res_edge_pairs); + for (auto er = res_edge_pairs.begin (); er != res_edge_pairs.end (); ++er) { + if (er->properties_id () != 0) { + edge_pairs->insert (*er); + } else { + edge_pairs->insert (er->base ()); + } } } @@ -182,17 +186,16 @@ AsIfFlatEdgePairs::processed_to_polygons (const EdgePairToPolygonProcessorBase & region->set_merged_semantics (false); } - std::vector res_polygons; + std::vector res_polygons; for (EdgePairsIterator e (begin ()); ! e.at_end (); ++e) { res_polygons.clear (); - filter.process (*e, res_polygons); - for (std::vector::const_iterator pr = res_polygons.begin (); pr != res_polygons.end (); ++pr) { - db::properties_id_type prop_id = e.prop_id (); - if (prop_id != 0) { - region->insert (db::PolygonWithProperties (*pr, prop_id)); - } else { + filter.process (e.wp (), res_polygons); + for (auto pr = res_polygons.begin (); pr != res_polygons.end (); ++pr) { + if (pr->properties_id () != 0) { region->insert (*pr); + } else { + region->insert (pr->base ()); } } } @@ -209,17 +212,16 @@ AsIfFlatEdgePairs::processed_to_edges (const EdgePairToEdgeProcessorBase &filter edges->set_merged_semantics (false); } - std::vector res_edges; + std::vector res_edges; for (EdgePairsIterator e (begin ()); ! e.at_end (); ++e) { res_edges.clear (); - filter.process (*e, res_edges); - for (std::vector::const_iterator pr = res_edges.begin (); pr != res_edges.end (); ++pr) { - db::properties_id_type prop_id = e.prop_id (); - if (prop_id != 0) { - edges->insert (db::EdgeWithProperties (*pr, prop_id)); - } else { + filter.process (e.wp (), res_edges); + for (auto pr = res_edges.begin (); pr != res_edges.end (); ++pr) { + if (pr->properties_id () != 0) { edges->insert (*pr); + } else { + edges->insert (pr->base ()); } } } diff --git a/src/db/db/dbAsIfFlatEdges.cc b/src/db/db/dbAsIfFlatEdges.cc index 6ab1eac43..f370532e0 100644 --- a/src/db/db/dbAsIfFlatEdges.cc +++ b/src/db/db/dbAsIfFlatEdges.cc @@ -648,13 +648,17 @@ AsIfFlatEdges::processed (const EdgeProcessorBase &filter) const edges->set_merged_semantics (false); } - std::vector res_edges; + std::vector res_edges; for (EdgesIterator e (filter.requires_raw_input () ? begin () : begin_merged ()); ! e.at_end (); ++e) { res_edges.clear (); - filter.process (*e, res_edges); - for (std::vector::const_iterator er = res_edges.begin (); er != res_edges.end (); ++er) { - edges->insert (*er); + filter.process (e.wp (), res_edges); + for (auto er = res_edges.begin (); er != res_edges.end (); ++er) { + if (er->properties_id () != 0) { + edges->insert (*er); + } else { + edges->insert (er->base ()); + } } } @@ -670,13 +674,17 @@ AsIfFlatEdges::processed_to_edge_pairs (const EdgeToEdgePairProcessorBase &filte edge_pairs->set_merged_semantics (false); } - std::vector res_edge_pairs; + std::vector res_edge_pairs; for (EdgesIterator e (filter.requires_raw_input () ? begin () : begin_merged ()); ! e.at_end (); ++e) { res_edge_pairs.clear (); - filter.process (*e, res_edge_pairs); - for (std::vector::const_iterator epr = res_edge_pairs.begin (); epr != res_edge_pairs.end (); ++epr) { - edge_pairs->insert (*epr); + filter.process (e.wp (), res_edge_pairs); + for (auto epr = res_edge_pairs.begin (); epr != res_edge_pairs.end (); ++epr) { + if (epr->properties_id () != 0) { + edge_pairs->insert (*epr); + } else { + edge_pairs->insert (epr->base ()); + } } } @@ -692,13 +700,17 @@ AsIfFlatEdges::processed_to_polygons (const EdgeToPolygonProcessorBase &filter) region->set_merged_semantics (false); } - std::vector res_polygons; + std::vector res_polygons; for (EdgesIterator e (filter.requires_raw_input () ? begin () : begin_merged ()); ! e.at_end (); ++e) { res_polygons.clear (); - filter.process (*e, res_polygons); - for (std::vector::const_iterator pr = res_polygons.begin (); pr != res_polygons.end (); ++pr) { - region->insert (*pr); + filter.process (e.wp (), res_polygons); + for (auto pr = res_polygons.begin (); pr != res_polygons.end (); ++pr) { + if (pr->properties_id () != 0) { + region->insert (*pr); + } else { + region->insert (pr->base ()); + } } } diff --git a/src/db/db/dbAsIfFlatRegion.cc b/src/db/db/dbAsIfFlatRegion.cc index 1ea27bb98..c460963cf 100644 --- a/src/db/db/dbAsIfFlatRegion.cc +++ b/src/db/db/dbAsIfFlatRegion.cc @@ -155,29 +155,29 @@ AsIfFlatRegion::edges (const EdgeFilterBase *filter, const PolygonToEdgeProcesso } result->reserve (n); - std::vector heap; + std::vector heap; for (RegionIterator p (begin_merged ()); ! p.at_end (); ++p) { - db::properties_id_type prop_id = p.prop_id (); - if (proc) { heap.clear (); - proc->process (*p, heap); + proc->process (p.wp (), heap); for (auto e = heap.begin (); e != heap.end (); ++e) { - if (! filter || filter->selected (*e, prop_id)) { - if (prop_id != 0) { - result->insert (db::EdgeWithProperties (*e, prop_id)); - } else { + if (! filter || filter->selected (*e, e->properties_id ())) { + if (e->properties_id () != 0) { result->insert (*e); + } else { + result->insert (e->base ()); } } } } else { + auto prop_id = p.prop_id (); + for (db::Polygon::polygon_edge_iterator e = p->begin_edge (); ! e.at_end (); ++e) { if (! filter || filter->selected (*e, prop_id)) { if (prop_id != 0) { @@ -460,17 +460,17 @@ AsIfFlatRegion::processed (const PolygonProcessorBase &filter) const new_region->set_merged_semantics (false); } - std::vector poly_res; + std::vector poly_res; for (RegionIterator p (filter.requires_raw_input () ? begin () : begin_merged ()); ! p.at_end (); ++p) { poly_res.clear (); - filter.process (*p, poly_res); - for (std::vector::const_iterator pr = poly_res.begin (); pr != poly_res.end (); ++pr) { - if (p.prop_id () != 0) { - new_region->insert (db::PolygonWithProperties (*pr, p.prop_id ())); - } else { + filter.process (p.wp (), poly_res); + for (auto pr = poly_res.begin (); pr != poly_res.end (); ++pr) { + if (pr->properties_id () != 0) { new_region->insert (*pr); + } else { + new_region->insert (pr->base ()); } } @@ -487,17 +487,17 @@ AsIfFlatRegion::processed_to_edges (const PolygonToEdgeProcessorBase &filter) co new_edges->set_merged_semantics (false); } - std::vector edge_res; + std::vector edge_res; for (RegionIterator p (filter.requires_raw_input () ? begin () : begin_merged ()); ! p.at_end (); ++p) { edge_res.clear (); - filter.process (*p, edge_res); - for (std::vector::const_iterator er = edge_res.begin (); er != edge_res.end (); ++er) { - if (p.prop_id () != 0) { - new_edges->insert (db::EdgeWithProperties (*er, p.prop_id ())); - } else { + filter.process (p.wp (), edge_res); + for (auto er = edge_res.begin (); er != edge_res.end (); ++er) { + if (er->properties_id () != 0) { new_edges->insert (*er); + } else { + new_edges->insert (er->base ()); } } @@ -514,17 +514,17 @@ AsIfFlatRegion::processed_to_edge_pairs (const PolygonToEdgePairProcessorBase &f new_edge_pairs->set_merged_semantics (false); } - std::vector edge_pair_res; + std::vector edge_pair_res; for (RegionIterator p (filter.requires_raw_input () ? begin () : begin_merged ()); ! p.at_end (); ++p) { edge_pair_res.clear (); - filter.process (*p, edge_pair_res); - for (std::vector::const_iterator epr = edge_pair_res.begin (); epr != edge_pair_res.end (); ++epr) { - if (p.prop_id () != 0) { - new_edge_pairs->insert (db::EdgePairWithProperties (*epr, p.prop_id ())); - } else { + filter.process (p.wp (), edge_pair_res); + for (auto epr = edge_pair_res.begin (); epr != edge_pair_res.end (); ++epr) { + if (epr->properties_id () != 0) { new_edge_pairs->insert (*epr); + } else { + new_edge_pairs->insert (epr->base ()); } } diff --git a/src/db/db/dbAsIfFlatTexts.cc b/src/db/db/dbAsIfFlatTexts.cc index a9e8c0e91..d4fe8cad8 100644 --- a/src/db/db/dbAsIfFlatTexts.cc +++ b/src/db/db/dbAsIfFlatTexts.cc @@ -193,13 +193,17 @@ AsIfFlatTexts::processed (const TextProcessorBase &filter) const { std::unique_ptr texts (new FlatTexts ()); - std::vector res_texts; + std::vector res_texts; for (TextsIterator e = begin (); ! e.at_end (); ++e) { res_texts.clear (); - filter.process (*e, res_texts); - for (std::vector::const_iterator er = res_texts.begin (); er != res_texts.end (); ++er) { - texts->insert (*er); + filter.process (e.wp (), res_texts); + for (auto er = res_texts.begin (); er != res_texts.end (); ++er) { + if (er->properties_id () != 0) { + texts->insert (*er); + } else { + texts->insert (er->base ()); + } } } @@ -215,16 +219,16 @@ AsIfFlatTexts::processed_to_polygons (const TextToPolygonProcessorBase &filter) region->set_merged_semantics (false); } - std::vector res_polygons; + std::vector res_polygons; for (TextsIterator e (begin ()); ! e.at_end (); ++e) { res_polygons.clear (); - filter.process (*e, res_polygons); - for (std::vector::const_iterator pr = res_polygons.begin (); pr != res_polygons.end (); ++pr) { - if (e.prop_id () != 0) { - region->insert (db::PolygonWithProperties (*pr, e.prop_id ())); - } else { + filter.process (e.wp (), res_polygons); + for (auto pr = res_polygons.begin (); pr != res_polygons.end (); ++pr) { + if (pr->properties_id () != 0) { region->insert (*pr); + } else { + region->insert (pr->base ()); } } } diff --git a/src/db/db/dbDeepRegion.cc b/src/db/db/dbDeepRegion.cc index aaa6e5fb3..6df881cd6 100644 --- a/src/db/db/dbDeepRegion.cc +++ b/src/db/db/dbDeepRegion.cc @@ -1505,12 +1505,13 @@ DeepRegion::edges (const EdgeFilterBase *filter, const PolygonToEdgeProcessorBas const db::Shapes &s = c->shapes (polygons.layer ()); db::Shapes &st = c->shapes (res->deep_layer ().layer ()); - std::vector heap; + std::vector heap; for (db::Shapes::shape_iterator si = s.begin (db::ShapeIterator::All); ! si.at_end (); ++si) { - db::Polygon poly; + db::PolygonWithProperties poly; si->polygon (poly); + poly.properties_id (si->prop_id ()); if (proc) { @@ -1518,16 +1519,16 @@ DeepRegion::edges (const EdgeFilterBase *filter, const PolygonToEdgeProcessorBas proc->process (poly, heap); for (auto e = heap.begin (); e != heap.end (); ++e) { - if (! filter || filter->selected ((*e).transformed (tr), si->prop_id ())) { - st.insert (db::EdgeWithProperties (*e, si->prop_id ())); + if (! filter || filter->selected ((*e).transformed (tr), e->properties_id ())) { + st.insert (*e); } } } else { for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); ! e.at_end (); ++e) { - if (! filter || filter->selected ((*e).transformed (tr), si->prop_id ())) { - st.insert (db::EdgeWithProperties (*e, si->prop_id ())); + if (! filter || filter->selected ((*e).transformed (tr), poly.properties_id ())) { + st.insert (db::EdgeWithProperties (*e, poly.properties_id ())); } } diff --git a/src/db/db/dbEdgePairsDelegate.h b/src/db/db/dbEdgePairsDelegate.h index d4a1efd97..d000911c3 100644 --- a/src/db/db/dbEdgePairsDelegate.h +++ b/src/db/db/dbEdgePairsDelegate.h @@ -52,14 +52,6 @@ public: : m_e (e) { } - void process(const EdgePair &ep, std::vector &res) const - { - db::Polygon poly = ep.normalized ().to_polygon (m_e); - if (poly.vertices () >= 3) { - res.push_back (poly); - } - } - void process(const EdgePairWithProperties &ep, std::vector &res) const { db::Polygon poly = ep.normalized ().to_polygon (m_e); @@ -80,12 +72,6 @@ public: EdgePairToEdgesProcessor () { } - void process(const EdgePair &ep, std::vector &res) const - { - res.push_back (ep.first ()); - res.push_back (ep.second ()); - } - void process(const EdgePairWithProperties &ep, std::vector &res) const { res.push_back (db::EdgeWithProperties (ep.first (), ep.properties_id ())); @@ -101,14 +87,6 @@ public: EdgePairToFirstEdgesProcessor () { } - void process(const EdgePair &ep, std::vector &res) const - { - res.push_back (ep.first ()); - if (ep.is_symmetric ()) { - res.push_back (ep.second ()); - } - } - void process(const EdgePairWithProperties &ep, std::vector &res) const { res.push_back (db::EdgeWithProperties (ep.first (), ep.properties_id ())); @@ -126,13 +104,6 @@ public: EdgePairToSecondEdgesProcessor () { } - void process(const EdgePair &ep, std::vector &res) const - { - if (! ep.is_symmetric ()) { - res.push_back (ep.second ()); - } - } - void process(const EdgePairWithProperties &ep, std::vector &res) const { if (! ep.is_symmetric ()) { @@ -149,11 +120,6 @@ public: EdgePairToLesserEdgesProcessor () { } - void process(const EdgePair &ep, std::vector &res) const - { - res.push_back (ep.lesser ()); - } - void process(const EdgePairWithProperties &ep, std::vector &res) const { res.push_back (db::EdgeWithProperties (ep.lesser (), ep.properties_id ())); @@ -168,11 +134,6 @@ public: EdgePairToGreaterEdgesProcessor () { } - void process(const EdgePair &ep, std::vector &res) const - { - res.push_back (ep.greater ()); - } - void process(const EdgePairWithProperties &ep, std::vector &res) const { res.push_back (db::EdgeWithProperties (ep.greater (), ep.properties_id ())); diff --git a/src/db/db/dbEdgesUtils.cc b/src/db/db/dbEdgesUtils.cc index 68db12206..2a3118d39 100644 --- a/src/db/db/dbEdgesUtils.cc +++ b/src/db/db/dbEdgesUtils.cc @@ -184,34 +184,6 @@ EdgeSegmentSelector::EdgeSegmentSelector (int mode, Edge::distance_type length, EdgeSegmentSelector::~EdgeSegmentSelector () { } -void -EdgeSegmentSelector::process (const db::Edge &edge, std::vector &res) const -{ - double l = std::max (edge.double_length () * m_fraction, double (m_length)); - - db::DVector ds; - if (! edge.is_degenerate ()) { - ds = db::DVector (edge.d ()) * (l / edge.double_length ()); - } - - if (m_mode < 0) { - - res.push_back (db::Edge (edge.p1 (), db::Point (db::DPoint (edge.p1 ()) + ds))); - - } else if (m_mode > 0) { - - res.push_back (db::Edge (db::Point (db::DPoint (edge.p2 ()) - ds), edge.p2 ())); - - } else { - - db::DVector dl = ds * 0.5; - db::DPoint center = db::DPoint (edge.p1 ()) + db::DVector (edge.p2 () - edge.p1 ()) * 0.5; - - res.push_back (db::Edge (db::Point (center - dl), db::Point (center + dl))); - - } -} - void EdgeSegmentSelector::process (const db::EdgeWithProperties &edge, std::vector &res) const { diff --git a/src/db/db/dbEdgesUtils.h b/src/db/db/dbEdgesUtils.h index 769687b01..563f897f2 100644 --- a/src/db/db/dbEdgesUtils.h +++ b/src/db/db/dbEdgesUtils.h @@ -644,11 +644,6 @@ public: : m_ext_b (ext_b), m_ext_e (ext_e), m_ext_o (ext_o), m_ext_i (ext_i) { } - virtual void process (const Edge &edge, std::vector &res) const - { - res.push_back (extended_edge (edge, m_ext_b, m_ext_e, m_ext_o, m_ext_i)); - } - virtual void process (const EdgeWithProperties &edge, std::vector &res) const { res.push_back (db::PolygonWithProperties (extended_edge (edge, m_ext_b, m_ext_e, m_ext_o, m_ext_i), edge.properties_id ())); @@ -668,7 +663,6 @@ public: EdgeSegmentSelector (int mode, Edge::distance_type length, double fraction); ~EdgeSegmentSelector (); - virtual void process (const db::Edge &edge, std::vector &res) const; virtual void process (const db::EdgeWithProperties &edge, std::vector &res) const; virtual const TransformationReducer *vars () const { return &m_vars; } diff --git a/src/db/db/dbFlatEdges.cc b/src/db/db/dbFlatEdges.cc index 27e323cae..825ff7fae 100644 --- a/src/db/db/dbFlatEdges.cc +++ b/src/db/db/dbFlatEdges.cc @@ -226,7 +226,7 @@ Box FlatEdges::compute_bbox () const EdgesDelegate * FlatEdges::processed_in_place (const EdgeProcessorBase &filter) { - std::vector edge_res; + std::vector edge_res; db::Shapes &e = *mp_edges; @@ -236,22 +236,22 @@ FlatEdges::processed_in_place (const EdgeProcessorBase &filter) for (EdgesIterator p (filter.requires_raw_input () ? begin () : begin_merged ()); ! p.at_end (); ++p) { edge_res.clear (); - filter.process (*p, edge_res); + filter.process (p.wp (), edge_res); - for (std::vector::const_iterator pr = edge_res.begin (); pr != edge_res.end (); ++pr) { - if (p.prop_id () != 0) { + for (auto pr = edge_res.begin (); pr != edge_res.end (); ++pr) { + if (pr->properties_id () != 0) { if (pw_wp == e.get_layer ().end ()) { - e.get_layer ().insert (db::EdgeWithProperties (*pr, p.prop_id ())); + e.get_layer ().insert (*pr); pw_wp = e.get_layer ().end (); } else { - e.get_layer ().replace (pw_wp++, db::EdgeWithProperties (*pr, p.prop_id ())); + e.get_layer ().replace (pw_wp++, *pr); } } else { if (pw == e.get_layer ().end ()) { - e.get_layer ().insert (*pr); + e.get_layer ().insert (pr->base ()); pw = e.get_layer ().end (); } else { - e.get_layer ().replace (pw++, *pr); + e.get_layer ().replace (pw++, pr->base ()); } } } diff --git a/src/db/db/dbFlatRegion.cc b/src/db/db/dbFlatRegion.cc index f6abd1696..1255331dd 100644 --- a/src/db/db/dbFlatRegion.cc +++ b/src/db/db/dbFlatRegion.cc @@ -220,16 +220,16 @@ RegionDelegate *FlatRegion::process_in_place (const PolygonProcessorBase &filter db::layer &poly_layer_wp = mp_polygons->get_layer (); db::layer out_wp; - std::vector poly_res; + std::vector poly_res; for (RegionIterator p (filter.requires_raw_input () ? begin () : begin_merged ()); ! p.at_end (); ++p) { poly_res.clear (); - filter.process (*p, poly_res); - if (p.prop_id () != 0) { - for (auto r = poly_res.begin (); r != poly_res.end (); ++r) { - out_wp.insert (db::PolygonWithProperties (*r, p.prop_id ())); + filter.process (p.wp (), poly_res); + for (auto r = poly_res.begin (); r != poly_res.end (); ++r) { + if (r->properties_id () != 0) { + out_wp.insert (*r); + } else { + out_wp.insert (r->base ()); } - } else { - out.insert (poly_res.begin (), poly_res.end ()); } } diff --git a/src/db/db/dbGenericShapeIterator.h b/src/db/db/dbGenericShapeIterator.h index 4e44681b6..7125cddc0 100644 --- a/src/db/db/dbGenericShapeIterator.h +++ b/src/db/db/dbGenericShapeIterator.h @@ -284,6 +284,7 @@ class DB_PUBLIC generic_shape_iterator public: typedef T value_type; typedef const value_type &reference; + typedef const db::object_with_properties with_properties_type; typedef const value_type *pointer; typedef std::forward_iterator_tag iterator_category; typedef void difference_type; @@ -373,6 +374,11 @@ public: return mp_delegate->get (); } + with_properties_type wp () const + { + return with_properties_type (*mp_delegate->get (), mp_delegate->prop_id ()); + } + generic_shape_iterator &operator++ () { mp_delegate->increment (); diff --git a/src/db/db/dbMeasure.cc b/src/db/db/dbMeasure.cc new file mode 100644 index 000000000..9f8174616 --- /dev/null +++ b/src/db/db/dbMeasure.cc @@ -0,0 +1,45 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2025 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include "dbMeasure.h" +#include "dbRegion.h" +#include "dbEdges.h" +#include "dbEdgePairs.h" +#include "dbTexts.h" +#include "tlExpression.h" + +namespace db +{ + + + +template +void compute_as_properties (Container *container, const std::map &expressions, bool clear_properties) +{ + // - collect property names + // - define functions for + +} + + + +} diff --git a/src/db/db/dbMeasure.h b/src/db/db/dbMeasure.h new file mode 100644 index 000000000..e69de29bb diff --git a/src/db/db/dbObjectWithProperties.h b/src/db/db/dbObjectWithProperties.h index 9ab320b23..2875784ea 100644 --- a/src/db/db/dbObjectWithProperties.h +++ b/src/db/db/dbObjectWithProperties.h @@ -186,6 +186,22 @@ public: return db::properties_id_less (m_id, d.m_id); } + /** + * @brief Downcase to base object (non-const) + */ + Obj &base () + { + return *this; + } + + /** + * @brief Downcase to base object (const) + */ + const Obj &base () const + { + return *this; + } + /** * @brief Properties Id read accessor */ diff --git a/src/db/db/dbRegionProcessors.cc b/src/db/db/dbRegionProcessors.cc index 730f6ea7a..874b2da16 100644 --- a/src/db/db/dbRegionProcessors.cc +++ b/src/db/db/dbRegionProcessors.cc @@ -97,14 +97,6 @@ void CornerDetectorCore::detect_corners (const db::PolygonWithProperties &poly, // ----------------------------------------------------------------------------------- // Extents implementation -void Extents::process (const db::Polygon &poly, std::vector &result) const -{ - db::Box b = poly.box (); - if (! b.empty ()) { - result.push_back (db::Polygon (b)); - } -} - void Extents::process (const db::PolygonWithProperties &poly, std::vector &result) const { db::Box b = poly.box (); @@ -116,19 +108,6 @@ void Extents::process (const db::PolygonWithProperties &poly, std::vector &result) const -{ - db::Box b = poly.box (); - db::Point p1 (b.left () + db::coord_traits::rounded (m_fx1 * b.width ()), - b.bottom () + db::coord_traits::rounded (m_fy1 * b.height ())); - db::Point p2 (b.left () + db::coord_traits::rounded (m_fx2 * b.width ()), - b.bottom () + db::coord_traits::rounded (m_fy2 * b.height ())); - db::Box box = db::Box (p1, p2).enlarged (db::Vector (m_dx, m_dy)); - if (! box.empty ()) { - result.push_back (db::Polygon (box)); - } -} - void RelativeExtents::process (const db::PolygonWithProperties &poly, std::vector &result) const { db::Box b = poly.box (); @@ -156,16 +135,6 @@ const TransformationReducer *RelativeExtents::vars () const // ----------------------------------------------------------------------------------- // RelativeExtentsAsEdges implementation -void RelativeExtentsAsEdges::process (const db::Polygon &poly, std::vector &result) const -{ - db::Box b = poly.box (); - db::Point p1 (b.left () + db::coord_traits::rounded (m_fx1 * b.width ()), - b.bottom () + db::coord_traits::rounded (m_fy1 * b.height ())); - db::Point p2 (b.left () + db::coord_traits::rounded (m_fx2 * b.width ()), - b.bottom () + db::coord_traits::rounded (m_fy2 * b.height ())); - result.push_back (db::Edge (p1, p2)); -} - void RelativeExtentsAsEdges::process (const db::PolygonWithProperties &poly, std::vector &result) const { db::Box b = poly.box (); @@ -280,23 +249,6 @@ contour_to_edges (const db::Polygon::contour_type &contour, PolygonToEdgeProcess } } -void PolygonToEdgeProcessor::process (const db::Polygon &poly, std::vector &result) const -{ - if (m_mode == All) { - - for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); ! e.at_end (); ++e) { - result.push_back (*e); - } - - } else { - - for (unsigned int i = 0; i < poly.holes () + 1; ++i) { - contour_to_edges (poly.contour (i), m_mode, result); - } - - } -} - void PolygonToEdgeProcessor::process (const db::PolygonWithProperties &poly, std::vector &result) const { if (m_mode == All) { @@ -322,15 +274,6 @@ void PolygonToEdgeProcessor::process (const db::PolygonWithProperties &poly, std // ----------------------------------------------------------------------------------- // ConvexDecomposition implementation -void ConvexDecomposition::process (const db::Polygon &poly, std::vector &result) const -{ - db::SimplePolygonContainer sp; - db::decompose_convex (poly, m_mode, sp); - for (std::vector ::const_iterator i = sp.polygons ().begin (); i != sp.polygons ().end (); ++i) { - result.push_back (db::simple_polygon_to_polygon (*i)); - } -} - void ConvexDecomposition::process (const db::PolygonWithProperties &poly, std::vector &result) const { db::SimplePolygonContainer sp; @@ -343,15 +286,6 @@ void ConvexDecomposition::process (const db::PolygonWithProperties &poly, std::v // ----------------------------------------------------------------------------------- // TrapezoidDecomposition implementation -void TrapezoidDecomposition::process (const db::Polygon &poly, std::vector &result) const -{ - db::SimplePolygonContainer sp; - db::decompose_trapezoids (poly, m_mode, sp); - for (std::vector ::const_iterator i = sp.polygons ().begin (); i != sp.polygons ().end (); ++i) { - result.push_back (db::simple_polygon_to_polygon (*i)); - } -} - void TrapezoidDecomposition::process (const db::PolygonWithProperties &poly, std::vector &result) const { db::SimplePolygonContainer sp; @@ -364,21 +298,6 @@ void TrapezoidDecomposition::process (const db::PolygonWithProperties &poly, std // ----------------------------------------------------------------------------------- // PolygonBreaker implementation -void PolygonBreaker::process (const db::Polygon &poly, std::vector &result) const -{ - if (db::suggest_split_polygon (poly, m_max_vertex_count, m_max_area_ratio)) { - - std::vector split_polygons; - db::split_polygon (poly, split_polygons); - for (std::vector::const_iterator p = split_polygons.begin (); p != split_polygons.end (); ++p) { - process (*p, result); - } - - } else { - result.push_back (poly); - } -} - void PolygonBreaker::process (const db::PolygonWithProperties &poly, std::vector &result) const { if (db::suggest_split_polygon (poly, m_max_vertex_count, m_max_area_ratio)) { @@ -412,14 +331,6 @@ PolygonSizer::~PolygonSizer () delete m_vars; } -void PolygonSizer::process (const db::Polygon &poly, std::vector &result) const -{ - db::PolygonContainer pr (result); - db::PolygonGenerator pg2 (pr, false /*don't resolve holes*/, true /*min. coherence*/); - db::SizingPolygonFilter siz (pg2, m_dx, m_dy, m_mode); - siz.put (poly); -} - void PolygonSizer::process (const db::PolygonWithProperties &poly, std::vector &result) const { db::PolygonContainerWithProperties pr (result, poly.properties_id ()); @@ -447,27 +358,6 @@ TriangulationProcessor::TriangulationProcessor (double max_area, double min_b) m_param.min_b = min_b; } -void -TriangulationProcessor::process (const db::Polygon &poly, std::vector &result) const -{ - // NOTE: we center the polygon for better numerical stability - db::CplxTrans trans = db::CplxTrans (triangulation_dbu) * db::ICplxTrans (db::Trans (db::Point () - poly.box ().center ())); - - db::plc::Graph tri; - db::plc::Triangulation (&tri).triangulate (poly, m_param, trans); - - db::Point pts [3]; - auto trans_inv = trans.inverted (); - - for (auto t = tri.begin (); t != tri.end (); ++t) { - for (int i = 0; i < 3; ++i) { - pts [i] = trans_inv * *t->vertex (i); - } - result.push_back (db::Polygon ()); - result.back ().assign_hull (pts + 0, pts + 3); - } -} - void TriangulationProcessor::process (const db::PolygonWithProperties &poly, std::vector &result) const { @@ -600,13 +490,6 @@ DRCHullProcessor::process (const db::PolygonWithProperties &poly, std::vector &result) const -{ - db::PolygonContainer psink (result); - do_process (poly, psink); -} - void DRCHullProcessor::do_process (const db::Polygon &poly, db::PolygonSink &psink) const { diff --git a/src/db/db/dbRegionProcessors.h b/src/db/db/dbRegionProcessors.h index ea593f1d3..54cdb546b 100644 --- a/src/db/db/dbRegionProcessors.h +++ b/src/db/db/dbRegionProcessors.h @@ -180,11 +180,6 @@ public: // .. nothing yet .. } - void process (const db::Polygon &poly, std::vector &result) const - { - detect_corners (poly, CornerRectDelivery (m_dim, result)); - } - void process (const db::PolygonWithProperties &poly, std::vector &result) const { detect_corners (poly, CornerRectDelivery (m_dim, result)); @@ -214,11 +209,6 @@ public: // .. nothing yet .. } - void process (const db::Polygon &poly, std::vector &result) const - { - detect_corners (poly, CornerDotDelivery (result)); - } - void process (const db::PolygonWithProperties &poly, std::vector &result) const { detect_corners (poly, CornerDotDelivery (result)); @@ -244,11 +234,6 @@ public: // .. nothing yet .. } - void process (const db::Polygon &poly, std::vector &result) const - { - detect_corners (poly, CornerEdgePairDelivery (result)); - } - void process (const db::PolygonWithProperties &poly, std::vector &result) const { detect_corners (poly, CornerEdgePairDelivery (result)); @@ -276,7 +261,6 @@ public: // .. nothing yet .. } - void process (const db::Polygon &poly, std::vector &result) const; void process (const db::PolygonWithProperties &poly, std::vector &result) const; virtual const TransformationReducer *vars () const { return 0; } @@ -301,7 +285,6 @@ public: // .. nothing yet .. } - void process (const db::Polygon &poly, std::vector &result) const; void process (const db::PolygonWithProperties &poly, std::vector &result) const; virtual const TransformationReducer *vars () const; @@ -334,7 +317,6 @@ public: // .. nothing yet .. } - void process (const db::Polygon &poly, std::vector &result) const; void process (const db::PolygonWithProperties &poly, std::vector &result) const; virtual const TransformationReducer *vars () const; @@ -361,7 +343,6 @@ public: PolygonToEdgeProcessor (EdgeMode mode = All); - void process (const db::Polygon &poly, std::vector &result) const; void process (const db::PolygonWithProperties &poly, std::vector &result) const; private: @@ -381,7 +362,6 @@ public: // .. nothing yet .. } - void process (const db::Polygon &poly, std::vector &result) const; void process (const db::PolygonWithProperties &poly, std::vector &result) const; virtual const TransformationReducer *vars () const { return &m_vars; } @@ -408,7 +388,6 @@ public: // .. nothing yet .. } - void process (const db::Polygon &poly, std::vector &result) const; void process (const db::PolygonWithProperties &poly, std::vector &result) const; virtual const TransformationReducer *vars () const { return &m_vars; } @@ -438,7 +417,6 @@ public: // .. nothing yet .. } - void process (const db::Polygon &poly, std::vector &result) const; void process (const db::PolygonWithProperties &poly, std::vector &result) const; virtual const TransformationReducer *vars () const { return 0; } @@ -464,7 +442,6 @@ public: virtual const TransformationReducer *vars () const { return m_vars; } - void process (const db::Polygon &poly, std::vector &result) const; void process (const db::PolygonWithProperties &poly, std::vector &result) const; virtual bool result_is_merged () const; @@ -487,7 +464,6 @@ class DB_PUBLIC TriangulationProcessor public: TriangulationProcessor (double max_area = 0.0, double min_b = 1.0); - void process (const db::Polygon &poly, std::vector &result) const; void process (const db::PolygonWithProperties &poly, std::vector &result) const; virtual const TransformationReducer *vars () const { return &m_vars; } @@ -516,11 +492,6 @@ public: // .. nothing yet .. } - void process (const db::Polygon &poly, std::vector &result) const - { - result.push_back (db::minkowski_sum (poly, m_q, false)); - } - void process (const db::PolygonWithProperties &poly, std::vector &result) const { result.push_back (db::PolygonWithProperties (db::minkowski_sum (poly, m_q, false), poly.properties_id ())); @@ -547,7 +518,6 @@ class DB_PUBLIC_TEMPLATE DRCHullProcessor public: DRCHullProcessor (db::Coord d, db::metrics_type metrics, size_t n_circle = 64); - void process (const db::Polygon &poly, std::vector &result) const; void process (const db::PolygonWithProperties &poly, std::vector &result) const; private: diff --git a/src/db/db/dbRegionUtils.cc b/src/db/db/dbRegionUtils.cc index 925bd314f..28dda0d62 100644 --- a/src/db/db/dbRegionUtils.cc +++ b/src/db/db/dbRegionUtils.cc @@ -354,23 +354,6 @@ SinglePolygonCheck::SinglePolygonCheck (db::edge_relation_type rel, db::Coord d, : m_relation (rel), m_d (d), m_options (options) { } -void -SinglePolygonCheck::process (const db::Polygon &polygon, std::vector &res) const -{ - std::unordered_set result; - - EdgeRelationFilter check (m_relation, m_d, m_options); - - edge2edge_check_negative_or_positive > edge_check (check, result, m_options.negative, false /*=same polygons*/, false /*=same layers*/, m_options.shielded, true /*=symmetric*/); - poly2poly_check poly_check (edge_check); - - do { - poly_check.single (polygon, 0); - } while (edge_check.prepare_next_pass ()); - - res.insert (res.end (), result.begin (), result.end ()); -} - void SinglePolygonCheck::process (const db::PolygonWithProperties &polygon, std::vector &res) const { @@ -412,19 +395,6 @@ StrangePolygonCheckProcessor::StrangePolygonCheckProcessor () { } StrangePolygonCheckProcessor::~StrangePolygonCheckProcessor () { } -void -StrangePolygonCheckProcessor::process (const db::Polygon &poly, std::vector &res) const -{ - EdgeProcessor ep; - ep.insert (poly); - - StrangePolygonInsideFunc inside; - db::GenericMerge op (inside); - db::PolygonContainer pc (res, false); - db::PolygonGenerator pg (pc, false, false); - ep.process (pg, op); -} - void StrangePolygonCheckProcessor::process (const db::PolygonWithProperties &poly, std::vector &res) const { @@ -445,12 +415,6 @@ SmoothingProcessor::SmoothingProcessor (db::Coord d, bool keep_hv) : m_d (d), m_ SmoothingProcessor::~SmoothingProcessor () { } -void -SmoothingProcessor::process (const db::Polygon &poly, std::vector &res) const -{ - res.push_back (db::smooth (poly, m_d, m_keep_hv)); -} - void SmoothingProcessor::process (const db::PolygonWithProperties &poly, std::vector &res) const { @@ -467,12 +431,6 @@ RoundedCornersProcessor::RoundedCornersProcessor (double rinner, double router, RoundedCornersProcessor::~RoundedCornersProcessor () { } -void -RoundedCornersProcessor::process (const db::Polygon &poly, std::vector &res) const -{ - res.push_back (db::compute_rounded (poly, m_rinner, m_router, m_n)); -} - void RoundedCornersProcessor::process (const db::PolygonWithProperties &poly, std::vector &res) const { @@ -490,15 +448,6 @@ HolesExtractionProcessor::~HolesExtractionProcessor () { } -void -HolesExtractionProcessor::process (const db::Polygon &poly, std::vector &res) const -{ - for (size_t i = 0; i < poly.holes (); ++i) { - res.push_back (db::Polygon ()); - res.back ().assign_hull (poly.begin_hole ((unsigned int) i), poly.end_hole ((unsigned int) i)); - } -} - void HolesExtractionProcessor::process (const db::PolygonWithProperties &poly, std::vector &res) const { @@ -520,13 +469,6 @@ HullExtractionProcessor::~HullExtractionProcessor () { } -void -HullExtractionProcessor::process (const db::Polygon &poly, std::vector &res) const -{ - res.push_back (db::Polygon ()); - res.back ().assign_hull (poly.begin_hull (), poly.end_hull ()); -} - void HullExtractionProcessor::process (const db::PolygonWithProperties &poly, std::vector &res) const { diff --git a/src/db/db/dbRegionUtils.h b/src/db/db/dbRegionUtils.h index 49a0ac003..d1d36ec0a 100644 --- a/src/db/db/dbRegionUtils.h +++ b/src/db/db/dbRegionUtils.h @@ -488,7 +488,6 @@ public: StrangePolygonCheckProcessor (); ~StrangePolygonCheckProcessor (); - virtual void process (const db::Polygon &poly, std::vector &res) const; virtual void process (const db::PolygonWithProperties &poly, std::vector &res) const; virtual const TransformationReducer *vars () const { return 0; } @@ -508,7 +507,6 @@ public: SmoothingProcessor (db::Coord d, bool keep_hv); ~SmoothingProcessor (); - virtual void process (const db::Polygon &poly, std::vector &res) const; virtual void process (const db::PolygonWithProperties &poly, std::vector &res) const; virtual const TransformationReducer *vars () const { return &m_vars; } @@ -533,7 +531,6 @@ public: RoundedCornersProcessor (double rinner, double router, unsigned int n); ~RoundedCornersProcessor (); - virtual void process (const db::Polygon &poly, std::vector &res) const; virtual void process (const db::PolygonWithProperties &poly, std::vector &res) const; virtual const TransformationReducer *vars () const { return &m_vars; } @@ -558,7 +555,6 @@ public: HolesExtractionProcessor (); ~HolesExtractionProcessor (); - virtual void process (const db::Polygon &poly, std::vector &res) const; virtual void process (const db::PolygonWithProperties &poly, std::vector &res) const; virtual const TransformationReducer *vars () const { return 0; } @@ -578,7 +574,6 @@ public: HullExtractionProcessor (); ~HullExtractionProcessor (); - virtual void process (const db::Polygon &poly, std::vector &res) const; virtual void process (const db::PolygonWithProperties &poly, std::vector &res) const; virtual const TransformationReducer *vars () const { return 0; } @@ -597,7 +592,6 @@ class DB_PUBLIC SinglePolygonCheck public: SinglePolygonCheck (db::edge_relation_type rel, db::Coord d, const RegionCheckOptions &options); - virtual void process (const db::Polygon &polygon, std::vector &res) const; virtual void process (const db::PolygonWithProperties &polygon, std::vector &res) const; virtual const TransformationReducer *vars () const { return &m_vars; } virtual bool wants_variants () const { return true; } diff --git a/src/db/db/dbShapeCollectionUtils.h b/src/db/db/dbShapeCollectionUtils.h index 0705a9061..e0f9ba45d 100644 --- a/src/db/db/dbShapeCollectionUtils.h +++ b/src/db/db/dbShapeCollectionUtils.h @@ -61,17 +61,10 @@ public: */ virtual ~shape_collection_processor () { } - /** - * @brief Performs the actual processing - * This method will take the input edge from "edge" and puts the results into "res". - * "res" can be empty - in this case, the edge will be skipped. - */ - virtual void process (const Shape &shape, std::vector &res) const = 0; - /** * @brief Performs the actual processing with properties - * This method will take the input edge from "edge" and puts the results into "res". - * "res" can be empty - in this case, the edge will be skipped. + * This method will take the input edge from "shape" and puts the results into "res". + * "res" can be empty - in this case, the shape will be skipped. */ virtual void process (const db::object_with_properties &shape, std::vector > &res) const = 0; @@ -194,7 +187,7 @@ shape_collection_processed_impl (const db::DeepLayer &input, const shape_collect } - std::vector heap; + std::vector > heap; std::map > to_commit; std::unique_ptr res (new OutputContainer (input.derived ())); @@ -225,16 +218,17 @@ shape_collection_processed_impl (const db::DeepLayer &input, const shape_collect db::ICplxTrans trinv = tr.inverted (); for (db::Shapes::shape_iterator si = s.begin (db::ShapeIterator::All); ! si.at_end (); ++si) { - Shape s; + db::object_with_properties s; si->instantiate (s); + s.properties_id (si->prop_id ()); s.transform (tr); heap.clear (); filter.process (s, heap); - for (typename std::vector::const_iterator i = heap.begin (); i != heap.end (); ++i) { - if (si->prop_id ()) { - delivery_wp.put (db::object_with_properties (i->transformed (trinv), si->prop_id ())); + for (auto i = heap.begin (); i != heap.end (); ++i) { + if (i->properties_id ()) { + delivery_wp.put (db::object_with_properties (i->transformed (trinv), i->properties_id ())); } else { - delivery.put (i->transformed (trinv)); + delivery.put (i->base ().transformed (trinv)); } } } @@ -248,15 +242,16 @@ shape_collection_processed_impl (const db::DeepLayer &input, const shape_collect shape_collection_processor_delivery > delivery_wp (&layout, &st); for (db::Shapes::shape_iterator si = s.begin (db::ShapeIterator::All); ! si.at_end (); ++si) { - Shape s; + db::object_with_properties s; si->instantiate (s); + s.properties_id (si->prop_id ()); heap.clear (); filter.process (s, heap); - for (typename std::vector::const_iterator i = heap.begin (); i != heap.end (); ++i) { + for (auto i = heap.begin (); i != heap.end (); ++i) { if (si->prop_id ()) { - delivery_wp.put (db::object_with_properties (*i, si->prop_id ())); + delivery_wp.put (*i); } else { - delivery.put (*i); + delivery.put (i->base ()); } } } @@ -287,15 +282,6 @@ public: : m_dx (dx), m_dy (dy) { } - virtual void process (const Shape &s, std::vector &res) const - { - db::box_convert bc; - db::Box box = bc (s).enlarged (db::Vector (m_dx, m_dy)); - if (! box.empty ()) { - res.push_back (db::Polygon (box)); - } - } - virtual void process (const db::object_with_properties &s, std::vector &res) const { db::box_convert > bc; diff --git a/src/db/unit_tests/dbRegionProcessorTests.cc b/src/db/unit_tests/dbRegionProcessorTests.cc index 07f04ab07..97140a21a 100644 --- a/src/db/unit_tests/dbRegionProcessorTests.cc +++ b/src/db/unit_tests/dbRegionProcessorTests.cc @@ -48,11 +48,11 @@ TEST(1_RegionToEdgesProcessor) db::Point (100, 900) }; - db::Polygon poly; + db::PolygonWithProperties poly; poly.assign_hull (hull + 0, hull + sizeof (hull) / sizeof (hull[0])); poly.insert_hole (hole + 0, hole + sizeof (hole) / sizeof (hole[0])); - std::vector result; + std::vector result; result.clear (); db::PolygonToEdgeProcessor ().process (poly, result);