MCPcopy Create free account
hub / github.com/KLayout/klayout / erase

Method erase

src/laybasic/laybasic/layAnnotationShapes.cc:38–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void
39AnnotationLayerOp::erase (AnnotationShapes *shapes)
40{
41 if (size_t (std::distance (shapes->begin (), shapes->end ())) <= m_shapes.size ()) {
42 // If all shapes are to be removed, just clear the list
43 shapes->clear ();
44 } else {
45
46 // look up the shapes to delete and collect them in a sorted list. Then pass this to
47 // the erase_positions method of the shapes object
48 std::vector<bool> done;
49 done.resize (m_shapes.size (), false);
50
51 std::sort (m_shapes.begin (), m_shapes.end ());
52
53 std::vector<shape_type>::const_iterator s_begin = m_shapes.begin ();
54 std::vector<shape_type>::const_iterator s_end = m_shapes.end ();
55
56 std::vector<AnnotationShapes::layer_type::iterator> to_erase;
57 to_erase.reserve (m_shapes.size ());
58
59 // This is not quite effective but seems to be the simplest way
60 // of implementing this: search for each element and erase these.
61 for (AnnotationShapes::layer_type::iterator lsh = shapes->begin (); lsh != shapes->end (); ++lsh) {
62 std::vector<shape_type>::const_iterator s = std::lower_bound (s_begin, s_end, *lsh);
63 while (s != s_end && *s == *lsh && done [std::distance(s_begin, s)]) {
64 ++s;
65 }
66 if (s != s_end && *s == *lsh) {
67 done [std::distance(s_begin, s)] = true;
68 to_erase.push_back (lsh);
69 }
70 }
71
72 shapes->erase_positions (to_erase.begin (), to_erase.end ());
73
74 }
75}
76
77// ---------------------------------------------------------------------------------------
78// Shapes implementation

Callers

nothing calls this directly

Calls 12

sortFunction · 0.85
managerFunction · 0.70
distanceFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
resizeMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45
erase_positionsMethod · 0.45
queueMethod · 0.45

Tested by

no test coverage detected