mirror of https://github.com/KLayout/klayout.git
Enabled 'break_polygons' for editable Shapes containers
This commit is contained in:
parent
1ed69e9b46
commit
4d80fb37c3
|
|
@ -715,21 +715,35 @@ static bool split_polygon (bool first, db::Polygon &poly, size_t max_vertex_coun
|
||||||
void
|
void
|
||||||
break_polygons (db::Shapes &shapes, size_t max_vertex_count, double max_area_ratio)
|
break_polygons (db::Shapes &shapes, size_t max_vertex_count, double max_area_ratio)
|
||||||
{
|
{
|
||||||
std::vector<db::Polygon> new_polygons;
|
if (shapes.is_editable ()) {
|
||||||
std::vector<db::Shape> to_delete;
|
|
||||||
|
|
||||||
for (auto s = shapes.begin (db::ShapeIterator::Polygons | db::ShapeIterator::Paths); ! s.at_end (); ++s) {
|
std::vector<db::Polygon> new_polygons;
|
||||||
db::Polygon poly;
|
std::vector<db::Shape> to_delete;
|
||||||
s->instantiate (poly);
|
|
||||||
if (split_polygon (true, poly, max_vertex_count, max_area_ratio, new_polygons)) {
|
for (auto s = shapes.begin (db::ShapeIterator::Polygons | db::ShapeIterator::Paths); ! s.at_end (); ++s) {
|
||||||
to_delete.push_back (*s);
|
db::Polygon poly;
|
||||||
|
s->instantiate (poly);
|
||||||
|
if (split_polygon (true, poly, max_vertex_count, max_area_ratio, new_polygons)) {
|
||||||
|
to_delete.push_back (*s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
shapes.erase_shapes (to_delete);
|
shapes.erase_shapes (to_delete);
|
||||||
|
|
||||||
|
for (auto p = new_polygons.begin (); p != new_polygons.end (); ++p) {
|
||||||
|
shapes.insert (*p);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// In non-editable mode we cannot do "erase", so we use a temporary, editable Shapes container
|
||||||
|
db::Shapes tmp (true);
|
||||||
|
tmp.insert (shapes);
|
||||||
|
|
||||||
|
shapes.clear ();
|
||||||
|
break_polygons (tmp, max_vertex_count, max_area_ratio);
|
||||||
|
shapes.insert (tmp);
|
||||||
|
|
||||||
for (auto p = new_polygons.begin (); p != new_polygons.end (); ++p) {
|
|
||||||
shapes.insert (*p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue