mirror of https://github.com/KLayout/klayout.git
Refinement of solution for DRC hull generator, still not perfect.
This commit is contained in:
parent
03d77bbff6
commit
eb1ac4903e
|
|
@ -435,17 +435,18 @@ static void create_edge_segment (std::vector<db::Point> &points, db::metrics_typ
|
|||
void
|
||||
DRCHullProcessor::process (const db::Polygon &poly, std::vector<db::Polygon> &result) const
|
||||
{
|
||||
result.push_back (db::Polygon ());
|
||||
db::EdgeProcessor ep;
|
||||
std::vector<db::Point> 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<db::Point> 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<db::Polygon> &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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<db::DPoint>::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")));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue