mirror of https://github.com/KLayout/klayout.git
Fixed #152 (shape count wrong)
This commit is contained in:
parent
1a7bcfc31c
commit
bcd6c466fb
|
|
@ -50,6 +50,21 @@ static void dump_mem_statistics (const db::Shapes *shapes, bool detailed)
|
|||
ms.print ();
|
||||
}
|
||||
|
||||
static size_t shapes_size (const db::Shapes *shapes)
|
||||
{
|
||||
// we may have shape arrays - expand their count to match the shape count with the shapes delivered
|
||||
size_t n = 0;
|
||||
for (db::Shapes::shape_iterator i = shapes->begin (db::ShapeIterator::All); ! i.at_end (); ++i) {
|
||||
if (i.in_array ()) {
|
||||
n += i.array ().array_size ();
|
||||
i.finish_array ();
|
||||
} else {
|
||||
++n;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
template<class Sh>
|
||||
static db::Shape insert (db::Shapes *s, const Sh &p)
|
||||
{
|
||||
|
|
@ -1088,7 +1103,7 @@ Class<db::Shapes> decl_Shapes ("Shapes",
|
|||
"@brief Clears the shape container\n"
|
||||
"This method has been introduced in version 0.16. It can only be used in editable mode."
|
||||
) +
|
||||
gsi::method ("size", (size_t (db::Shapes::*)() const) &db::Shapes::size,
|
||||
gsi::method_ext ("size", &shapes_size,
|
||||
"@brief Gets the number of shapes in this container\n"
|
||||
"This method was introduced in version 0.16\n"
|
||||
"@return The number of shapes in this container\n"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1377,6 +1377,23 @@ class DBShapes_TestClass < TestBase
|
|||
|
||||
end
|
||||
|
||||
# issue 152 (number of shapes count wrong in viewer mode)
|
||||
def test_10
|
||||
|
||||
ly = RBA::Layout::new(true)
|
||||
ly.read(File.join($ut_testsrc, "testdata", "oasis", "issue_152.oas"))
|
||||
assert_equal(ly.top_cell.shapes(ly.layer(1, 0)).size, 200)
|
||||
ly.top_cell.shapes(ly.layer(1, 0)).insert(RBA::Polygon::new(RBA::Box::new(0, 0, 100, 100)))
|
||||
assert_equal(ly.top_cell.shapes(ly.layer(1, 0)).size, 201)
|
||||
|
||||
ly = RBA::Layout::new(false)
|
||||
ly.read(File.join($ut_testsrc, "testdata", "oasis", "issue_152.oas"))
|
||||
assert_equal(ly.top_cell.shapes(ly.layer(1, 0)).size, 200)
|
||||
ly.top_cell.shapes(ly.layer(1, 0)).insert(RBA::Polygon::new(RBA::Box::new(0, 0, 100, 100)))
|
||||
assert_equal(ly.top_cell.shapes(ly.layer(1, 0)).size, 201)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
load("test_epilogue.rb")
|
||||
|
|
|
|||
Loading…
Reference in New Issue