mirror of https://github.com/KLayout/klayout.git
Fixed #805 - introducing layer.count and layout.hier_count for DRC
This commit is contained in:
parent
5e04ea6156
commit
2e63628ddd
|
|
@ -276,16 +276,37 @@ module DRC
|
|||
end
|
||||
|
||||
# %DRC%
|
||||
# @name size
|
||||
# @name count
|
||||
# @brief Returns the number of objects on the layer
|
||||
# @synopsis layer.size
|
||||
# @synopsis layer.count
|
||||
#
|
||||
# The number of objects is the number of raw objects, not merged
|
||||
# regions or edges. It is more efficent to call this method on output layers than
|
||||
# on input layers.
|
||||
# The count is the number of raw objects, not merged
|
||||
# regions or edges. This is the flat count - the number of polygons,
|
||||
# edges or edge pairs seen from the top cell.
|
||||
# "count" can be computationally expensive for original layers with
|
||||
# clip regions or cell tree filters.
|
||||
#
|
||||
# See \hier_count for a hierarchical (each cell counts once) count.
|
||||
|
||||
def size
|
||||
self.data.size
|
||||
def count
|
||||
self.data.count
|
||||
end
|
||||
|
||||
# %DRC%
|
||||
# @name hier_count
|
||||
# @brief Returns the hierarchical number of objects on the layer
|
||||
# @synopsis layer.hier_count
|
||||
#
|
||||
# The hier_count is the number of raw objects, not merged
|
||||
# regions or edges, with each cell counting once.
|
||||
# A high \count to hier_count (flat to hierarchical) ratio is an indication
|
||||
# of a good hierarchical compression.
|
||||
# "hier_count" applies only to original layers without clip regions or
|
||||
# cell filters and to layers in \deep mode. Otherwise, hier_count gives
|
||||
# the same value than \count.
|
||||
|
||||
def hier_count
|
||||
self.data.hier_count
|
||||
end
|
||||
|
||||
# %DRC%
|
||||
|
|
|
|||
|
|
@ -275,6 +275,21 @@ The following images show the effect of this method:
|
|||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
<a name="count"/><h2>"count" - Returns the number of objects on the layer</h2>
|
||||
<keyword name="count"/>
|
||||
<p>Usage:</p>
|
||||
<ul>
|
||||
<li><tt>layer.count</tt></li>
|
||||
</ul>
|
||||
<p>
|
||||
The count is the number of raw objects, not merged
|
||||
regions or edges. This is the flat count - the number of polygons,
|
||||
edges or edge pairs seen from the top cell.
|
||||
"count" can be computationally expensive for original layers with
|
||||
clip regions or cell tree filters.
|
||||
</p><p>
|
||||
See <a href="#hier_count">hier_count</a> for a hierarchical (each cell counts once) count.
|
||||
</p>
|
||||
<a name="covering"/><h2>"covering" - Selects shapes or regions of self which completely cover (enclose) one or more shapes from the other region</h2>
|
||||
<keyword name="covering"/>
|
||||
<p>Usage:</p>
|
||||
|
|
@ -1187,6 +1202,21 @@ l = nil
|
|||
</p><p>
|
||||
By setting the layer to nil, it is ensured that it can no longer be accessed.
|
||||
</p>
|
||||
<a name="hier_count"/><h2>"hier_count" - Returns the hierarchical number of objects on the layer</h2>
|
||||
<keyword name="hier_count"/>
|
||||
<p>Usage:</p>
|
||||
<ul>
|
||||
<li><tt>layer.hier_count</tt></li>
|
||||
</ul>
|
||||
<p>
|
||||
The hier_count is the number of raw objects, not merged
|
||||
regions or edges, with each cell counting once.
|
||||
A high <a href="#count">count</a> to hier_count (flat to hierarchical) ratio is an indication
|
||||
of a good hierarchical compression.
|
||||
"hier_count" applies only to original layers without clip regions or
|
||||
cell filters and to layers in <a href="#deep">deep</a> mode. Otherwise, hier_count gives
|
||||
the same value than <a href="#count">count</a>.
|
||||
</p>
|
||||
<a name="holes"/><h2>"holes" - Selects all polygon holes from the input</h2>
|
||||
<keyword name="holes"/>
|
||||
<p>Usage:</p>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,17 @@ dbu 0.001
|
|||
|
||||
target($drc_test_target, "TOP")
|
||||
|
||||
def self.expect_count(layer, c, hc, where)
|
||||
if layer.count != c
|
||||
raise(where + ": Layer count #{layer.count} does not equal #{c}")
|
||||
end
|
||||
if layer.hier_count != hc
|
||||
raise(where + ": Layer hier count #{layer.hier_count} does not equal #{c}")
|
||||
end
|
||||
end
|
||||
|
||||
x = polygon_layer
|
||||
expect_count(x, 0, 0, "empty layer")
|
||||
x.is_empty? == true || raise("unexpected value")
|
||||
x.is_box? == false || raise("unexpected value")
|
||||
x.insert(box(4.0, 0, 4.7, 0.7))
|
||||
|
|
@ -12,6 +22,7 @@ x.is_box? == true || raise("unexpected value")
|
|||
x.insert(polygon([ p(0, 0), p(2.0, 0), p(1.0, 1.0) ]))
|
||||
x.insert(polygon([ p(0, -5.0), p(2.0, -5.0), p(1.0, -6.0) ]))
|
||||
x.insert(path([ p(0, -2), p(2.0, -2) ], 0.2))
|
||||
expect_count(x, 4, 4, "after 3x insert")
|
||||
x.is_box? == false || raise("unexpected value")
|
||||
x.output(10, 0)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,15 @@
|
|||
target($drc_test_target, "TOP")
|
||||
source($drc_test_source, "TOP")
|
||||
|
||||
def self.expect_count(layer, c, hc, where)
|
||||
if layer.count != c
|
||||
raise(where + ": Layer count #{layer.count} does not equal #{c}")
|
||||
end
|
||||
if layer.hier_count != hc
|
||||
raise(where + ": Layer hier count #{layer.hier_count} does not equal #{c}")
|
||||
end
|
||||
end
|
||||
|
||||
a1 = input(1)
|
||||
b1 = input(2)
|
||||
c1 = input(3)
|
||||
|
|
@ -89,3 +98,6 @@ a1.edges.collect_to_region { |p| p.length < 0.8 && p.bbox.transformed(RBA::VCplx
|
|||
a1.width(1.5).collect { |p| p.transformed(RBA::VCplxTrans::new(1000.0)) }.output(1120, 0)
|
||||
a1.width(1.5).collect_to_edge_pairs { |p| p.transformed(RBA::VCplxTrans::new(1000.0)) }.output(1121, 0)
|
||||
|
||||
expect_count(a1.edges, 9, 9, "a1.edges")
|
||||
expect_count(a1.width(1.5), 5, 5, "a1.width(1.5)")
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,15 @@
|
|||
source($drc_test_source, "TOPTOP_SMALL")
|
||||
target($drc_test_target)
|
||||
|
||||
def self.expect_count(layer, c, hc, where)
|
||||
if layer.count != c
|
||||
raise(where + ": Layer count #{layer.count} does not equal #{c}")
|
||||
end
|
||||
if layer.hier_count != hc
|
||||
raise(where + ": Layer hier count #{layer.hier_count} does not equal #{c}")
|
||||
end
|
||||
end
|
||||
|
||||
cell("TOPTOP_SMALL")
|
||||
|
||||
l1_flat = input(1)
|
||||
|
|
@ -66,12 +75,16 @@ r.output(1023, 0)
|
|||
r.extents.output(1123, 0)
|
||||
|
||||
r = l1.space(0.5)
|
||||
expect_count(r, 3, 1, "r on l1")
|
||||
r.output(1010, 0)
|
||||
r.extents.output(1110, 0)
|
||||
|
||||
expect_count(l1, 15, 5, "l1 before flatten")
|
||||
l1.flatten
|
||||
expect_count(l1, 15, 15, "l1 after flatten")
|
||||
r = l1.space(0.5)
|
||||
r.output(1011, 0)
|
||||
r.extents.output(1111, 0)
|
||||
expect_count(r, 3, 1, "r on l1.flatten")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue