From eb1ac4903eee2e043e27e46776db8947c0642ff2 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 30 Mar 2024 22:34:26 +0100 Subject: [PATCH] Refinement of solution for DRC hull generator, still not perfect. --- src/db/db/dbRegionProcessors.cc | 26 +++++++++++++++++++------- src/edt/edt/edtServiceImpl.cc | 10 +++++----- src/edt/edt/edtServiceImpl.h | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/db/db/dbRegionProcessors.cc b/src/db/db/dbRegionProcessors.cc index 655af7c7c..bf9b1ccf2 100644 --- a/src/db/db/dbRegionProcessors.cc +++ b/src/db/db/dbRegionProcessors.cc @@ -435,17 +435,18 @@ static void create_edge_segment (std::vector &points, db::metrics_typ void DRCHullProcessor::process (const db::Polygon &poly, std::vector &result) const { - result.push_back (db::Polygon ()); + db::EdgeProcessor ep; + std::vector points; for (unsigned int i = 0; i < poly.holes () + 1; ++i) { + points.clear (); + auto c = poly.contour (i); if (c.size () < 2) { continue; } - std::vector points; - for (auto p = c.begin (); p != c.end (); ++p) { auto pp = p; @@ -458,13 +459,24 @@ DRCHullProcessor::process (const db::Polygon &poly, std::vector &re } - if (i == 0) { - result.back ().assign_hull (points.begin (), points.end ()); - } else { - result.back ().insert_hole (points.begin (), points.end ()); + for (auto p = points.begin (); p != points.end (); ++p) { + + auto pp = p; + ++pp; + if (pp == points.end ()) { + pp = points.begin (); + } + + ep.insert (db::Edge (*p, *pp)); + } } + + db::SimpleMerge op; + db::PolygonContainer psink (result); + db::PolygonGenerator pg (psink, false); + ep.process (pg, op); } } diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index ee6ed623f..dc3d2228c 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -552,11 +552,11 @@ PolygonService::do_finish_edit () } db::Polygon -PolygonService::get_polygon (bool all_points) const +PolygonService::get_polygon (bool editing) const { db::Polygon poly; - if (m_points.size () + (m_closure_set ? 1 : 0) < (all_points ? 3 : 4)) { + if (! editing && m_points.size () + (m_closure_set ? 1 : 0) < 4) { throw tl::Exception (tl::to_string (tr ("A polygon must have at least 3 points"))); } @@ -567,16 +567,16 @@ PolygonService::get_polygon (bool all_points) const for (std::vector::const_iterator p = m_points.begin (); p + 1 != m_points.end (); ++p) { points_dbu.push_back (trans () * *p); } - if (all_points) { + if (editing) { points_dbu.push_back (trans () * m_points.back ()); } if (m_closure_set) { points_dbu.push_back (trans () * m_closure); } - poly.assign_hull (points_dbu.begin (), points_dbu.end (), true, true /*remove reflected*/); + poly.assign_hull (points_dbu.begin (), points_dbu.end (), !editing /*compress*/, !editing /*remove reflected*/); - if (poly.hull ().size () < 3) { + if (! editing && poly.hull ().size () < 3) { throw tl::Exception (tl::to_string (tr ("A polygon must have at least 3 effective points"))); } diff --git a/src/edt/edt/edtServiceImpl.h b/src/edt/edt/edtServiceImpl.h index 80e4bc515..e2c31ae5d 100644 --- a/src/edt/edt/edtServiceImpl.h +++ b/src/edt/edt/edtServiceImpl.h @@ -121,7 +121,7 @@ private: db::DPoint m_last; void update_marker (); - db::Polygon get_polygon (bool all_points) const; + db::Polygon get_polygon (bool editing) const; void add_closure (); void set_last_point (const db::DPoint &p); };