mirror of https://github.com/KLayout/klayout.git
Region[] now returns a PolygonWithProperties object or nil
This commit is contained in:
parent
227203cdd1
commit
a24d5388d7
|
|
@ -1379,6 +1379,16 @@ rasterize1 (const db::Region *region, const db::Point &origin, const db::Vector
|
||||||
return rasterize2 (region, origin, pixel_size, pixel_size, nx, ny);
|
return rasterize2 (region, origin, pixel_size, pixel_size, nx, ny);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static tl::Variant nth (const db::Region *region, size_t n)
|
||||||
|
{
|
||||||
|
const db::Polygon *poly = region->nth (n);
|
||||||
|
if (! poly) {
|
||||||
|
return tl::Variant ();
|
||||||
|
} else {
|
||||||
|
return tl::Variant (db::PolygonWithProperties (*poly, region->nth_prop_id (n)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static db::generic_shape_iterator<db::PolygonWithProperties> begin_region (const db::Region *region)
|
static db::generic_shape_iterator<db::PolygonWithProperties> begin_region (const db::Region *region)
|
||||||
{
|
{
|
||||||
return db::generic_shape_iterator<db::PolygonWithProperties> (db::make_wp_iter (region->delegate ()->begin ()));
|
return db::generic_shape_iterator<db::PolygonWithProperties> (db::make_wp_iter (region->delegate ()->begin ()));
|
||||||
|
|
@ -4103,14 +4113,16 @@ Class<db::Region> decl_Region (decl_dbShapeCollection, "db", "Region",
|
||||||
"This returns the raw polygons if merged semantics is disabled or the merged ones if merged semantics is enabled.\n"
|
"This returns the raw polygons if merged semantics is disabled or the merged ones if merged semantics is enabled.\n"
|
||||||
"Starting with version 0.30, the iterator delivers a RegionWithProperties object."
|
"Starting with version 0.30, the iterator delivers a RegionWithProperties object."
|
||||||
) +
|
) +
|
||||||
method ("[]", &db::Region::nth, gsi::arg ("n"),
|
method_ext ("[]", &nth, gsi::arg ("n"),
|
||||||
"@brief Returns the nth polygon of the region\n"
|
"@brief Returns the nth polygon of the region\n"
|
||||||
"\n"
|
"\n"
|
||||||
"This method returns nil if the index is out of range. It is available for flat regions only - i.e. "
|
"This method returns nil if the index is out of range. It is available for flat regions only - i.e. "
|
||||||
"those for which \\has_valid_polygons? is true. Use \\flatten to explicitly flatten a region.\n"
|
"those for which \\has_valid_polygons? is true. Use \\flatten to explicitly flatten a region.\n"
|
||||||
"This method returns the raw polygon (not merged polygons, even if merged semantics is enabled).\n"
|
"This method returns the raw polygon (not merged polygons, even if merged semantics is enabled).\n"
|
||||||
"\n"
|
"\n"
|
||||||
"The \\each iterator is the more general approach to access the polygons."
|
"The \\each iterator is the more general approach to access the polygons.\n"
|
||||||
|
"\n"
|
||||||
|
"Since version 0.30.1, this method returns a \\PolygonWithProperties object."
|
||||||
) +
|
) +
|
||||||
method ("flatten", &db::Region::flatten,
|
method ("flatten", &db::Region::flatten,
|
||||||
"@brief Explicitly flattens a region\n"
|
"@brief Explicitly flattens a region\n"
|
||||||
|
|
|
||||||
|
|
@ -898,4 +898,3 @@ TEST(17)
|
||||||
"it.add_value(17.5)").execute ();
|
"it.add_value(17.5)").execute ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -226,11 +226,15 @@ class DBRegion_TestClass < TestBase
|
||||||
|
|
||||||
r.flatten
|
r.flatten
|
||||||
assert_equal(r.has_valid_polygons?, true)
|
assert_equal(r.has_valid_polygons?, true)
|
||||||
assert_equal(r[1].to_s, "(-10,80;-10,120;10,120;10,80)")
|
assert_equal(r[1].to_s, "(-10,80;-10,120;10,120;10,80) props={}")
|
||||||
assert_equal(r[4].to_s, "")
|
assert_equal(r[4].to_s, "")
|
||||||
assert_equal(r.bbox.to_s, "(-10,-20;210,120)")
|
assert_equal(r.bbox.to_s, "(-10,-20;210,120)")
|
||||||
assert_equal(r.is_merged?, false)
|
assert_equal(r.is_merged?, false)
|
||||||
|
|
||||||
|
r = RBA::Region::new
|
||||||
|
r.insert(RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 10, 20), { 1 => 'value' }))
|
||||||
|
assert_equal(r[0].to_s, "(0,0;0,20;10,20;10,0) props={1=>value}")
|
||||||
|
|
||||||
r = RBA::Region::new(ly.begin_shapes(c1.cell_index, l2), "*")
|
r = RBA::Region::new(ly.begin_shapes(c1.cell_index, l2), "*")
|
||||||
assert_equal(csort(r.to_s), csort("(-11,-21;-11,-19;-9,-19;-9,-21);(9,19;9,21;11,21;11,19);(-11,79;-11,81;-9,81;-9,79);(9,119;9,121;11,121;11,119);(189,79;189,81;191,81;191,79);(209,119;209,121;211,121;211,119)"))
|
assert_equal(csort(r.to_s), csort("(-11,-21;-11,-19;-9,-19;-9,-21);(9,19;9,21;11,21;11,19);(-11,79;-11,81;-9,81;-9,79);(9,119;9,121;11,121;11,119);(189,79;189,81;191,81;191,79);(209,119;209,121;211,121;211,119)"))
|
||||||
r = RBA::Region::new(ly.begin_shapes(c1.cell_index, l2), "A*")
|
r = RBA::Region::new(ly.begin_shapes(c1.cell_index, l2), "A*")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue