Fixed issue #1373 (shapes with user properties are skipped from second input of flat region's '+' operator)

This commit is contained in:
Matthias Koefferlein 2023-05-14 22:48:31 +02:00
parent ae07629599
commit 3e60aabe7a
2 changed files with 20 additions and 0 deletions

View File

@ -313,6 +313,7 @@ RegionDelegate *FlatRegion::add (const Region &other) const
if (other_flat) {
new_region->raw_polygons ().insert (other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().begin (), other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().end ());
new_region->raw_polygons ().insert (other_flat->raw_polygons ().get_layer<db::PolygonWithProperties, db::unstable_layer_tag> ().begin (), other_flat->raw_polygons ().get_layer<db::PolygonWithProperties, db::unstable_layer_tag> ().end ());
} else {
@ -343,6 +344,7 @@ RegionDelegate *FlatRegion::add_in_place (const Region &other)
if (other_flat) {
polygons.insert (other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().begin (), other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().end ());
polygons.insert (other_flat->raw_polygons ().get_layer<db::PolygonWithProperties, db::unstable_layer_tag> ().begin (), other_flat->raw_polygons ().get_layer<db::PolygonWithProperties, db::unstable_layer_tag> ().end ());
} else {

View File

@ -2081,6 +2081,24 @@ TEST(50_PropertiesFlat)
EXPECT_EQ (s.at_end (), true);
}
// "+" operator with properties (issue #1373)
TEST(50b_PropertiesFlat)
{
db::Region r, rr;
r.insert (db::Box (0, 0, 10, 20));
rr.insert (db::Box (0, 0, 100, 200));
rr.insert (db::BoxWithProperties (db::Box (1, 2, 101, 202), 1));
EXPECT_EQ ((db::Region () + rr).to_string (), "(0,0;0,200;100,200;100,0);(1,2;1,202;101,202;101,2)");
EXPECT_EQ ((rr + db::Region ()).to_string (), "(0,0;0,200;100,200;100,0);(1,2;1,202;101,202;101,2)");
EXPECT_EQ ((r + rr).to_string (), "(0,0;0,20;10,20;10,0);(0,0;0,200;100,200;100,0);(1,2;1,202;101,202;101,2)");
r += rr;
EXPECT_EQ (r.to_string (), "(0,0;0,20;10,20;10,0);(0,0;0,200;100,200;100,0);(1,2;1,202;101,202;101,2)");
}
TEST(51_PropertiesFlatFromLayout)
{
db::Layout ly;