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

Method to_inst_element

src/laybasic/laybasic/layDisplayState.cc:68–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68std::pair<bool, db::InstElement>
69SpecificInst::to_inst_element (const db::Layout &layout, const db::Cell &parent_cell) const
70{
71 // first, we must find the cell by name
72 std::pair<bool, db::cell_index_type> ci = layout.cell_by_name (cell_name.c_str ());
73 if (! ci.first) {
74 return std::make_pair(false, db::InstElement ());
75 }
76
77 db::cell_index_type cell_index = ci.second;
78
79 for (db::Cell::const_iterator inst = parent_cell.begin (); ! inst.at_end (); ++inst) {
80
81 // use fuzzy comparison to find the base instance
82 if (inst->cell_index () == cell_index && inst->complex_trans ().equal (trans)) {
83
84 // if a matching instance is found, look for the matching array instance.
85 // HINT: this can be optimized somewhat by inverting the transformation to a array instance
86 // directly rather than iterating.
87 for (db::CellInstArray::iterator ainst = inst->begin (); ! ainst.at_end (); ++ainst) {
88 if (*ainst == array_trans) {
89
90 // a matching instance/array instance is found: deliver this
91 db::InstElement el;
92 el.inst_ptr = *inst;
93 el.array_inst = ainst;
94 return std::make_pair (true, el);
95
96 }
97 }
98
99 }
100
101 }
102
103 // nothing found.
104 return std::make_pair(false, db::InstElement ());
105}
106
107std::string
108SpecificInst::trans_str () const

Callers 1

cellviewMethod · 0.80

Calls 8

InstElementFunction · 0.85
cell_by_nameMethod · 0.45
c_strMethod · 0.45
beginMethod · 0.45
at_endMethod · 0.45
cell_indexMethod · 0.45
equalMethod · 0.45
complex_transMethod · 0.45

Tested by

no test coverage detected