Save some memory on net shape retrieval.

This commit is contained in:
Matthias Koefferlein 2019-01-02 23:23:04 +01:00
parent ec3198c466
commit 76330bea3a
4 changed files with 17 additions and 13 deletions

View File

@ -209,10 +209,10 @@ const db::hier_clusters<db::PolygonRef> &LayoutToNetlist::net_clusters () const
return m_netex.clusters ();
}
db::Region LayoutToNetlist::shapes_of_net (const db::Net &net, const db::Region &of_layer, bool recursive) const
db::Region *LayoutToNetlist::shapes_of_net (const db::Net &net, const db::Region &of_layer, bool recursive) const
{
unsigned int lid = layer_of (of_layer);
db::Region res;
std::auto_ptr<db::Region> res (new db::Region ());
if (! recursive) {
@ -224,7 +224,7 @@ db::Region LayoutToNetlist::shapes_of_net (const db::Net &net, const db::Region
const db::local_cluster<db::PolygonRef> &lc = m_netex.clusters ().clusters_per_cell (ci).cluster_by_id (net.cluster_id ());
for (db::local_cluster<db::PolygonRef>::shape_iterator s = lc.begin (lid); !s.at_end (); ++s) {
res.insert (s->obj ().transformed (s->trans ()));
res->insert (s->obj ().transformed (s->trans ()));
}
} else {
@ -235,12 +235,12 @@ db::Region LayoutToNetlist::shapes_of_net (const db::Net &net, const db::Region
db::cell_index_type ci = circuit->cell_index ();
for (db::recursive_cluster_shape_iterator<db::PolygonRef> rci (m_netex.clusters (), lid, ci, net.cluster_id ()); !rci.at_end (); ++rci) {
res.insert (rci->obj ().transformed (rci.trans () * db::ICplxTrans (rci->trans ())));
res->insert (rci->obj ().transformed (rci.trans () * db::ICplxTrans (rci->trans ())));
}
}
return res;
return res.release ();
}
db::Net *LayoutToNetlist::probe_net (const db::Region &of_region, const db::DPoint &point)

View File

@ -215,10 +215,14 @@ public:
/**
* @brief Returns all shapes of a specific net and layer.
*
* If "recursive" is true, the returned region will contain the shapes of
* all subcircuits too.
*
* This methods returns a new'd Region. It's the responsibility of the caller
* to delete this object.
*/
db::Region shapes_of_net (const db::Net &net, const db::Region &of_layer, bool recursive) const;
db::Region *shapes_of_net (const db::Net &net, const db::Region &of_layer, bool recursive) const;
/**
* @brief Finds the net by probing a specific location on the given layer

View File

@ -141,7 +141,7 @@ Class<db::LayoutToNetlist> decl_dbLayoutToNetlist ("db", "LayoutToNetlist",
gsi::method ("netlist", &db::LayoutToNetlist::netlist,
"@brief gets the netlist extracted (0 if no extraction happened yet)\n"
) +
gsi::method ("shapes_of_net", &db::LayoutToNetlist::shapes_of_net, gsi::arg ("net"), gsi::arg ("of_layer"), gsi::arg ("recursive"),
gsi::factory ("shapes_of_net", &db::LayoutToNetlist::shapes_of_net, gsi::arg ("net"), gsi::arg ("of_layer"), gsi::arg ("recursive"),
"@brief Returns all shapes of a specific net and layer.\n"
"If 'recursive'' is true, the returned region will contain the shapes of\n"
"all subcircuits too.\n"

View File

@ -114,8 +114,8 @@ static void dump_nets_to_layout (const db::LayoutToNetlist &l2n, db::Layout &ly,
for (std::map<const db::Region *, unsigned int>::const_iterator m = lmap.begin (); m != lmap.end (); ++m) {
db::Region shapes = l2n.shapes_of_net (*n, *m->first, false);
if (shapes.empty ()) {
std::auto_ptr<db::Region> shapes (l2n.shapes_of_net (*n, *m->first, false));
if (shapes->empty ()) {
continue;
}
@ -125,7 +125,7 @@ static void dump_nets_to_layout (const db::LayoutToNetlist &l2n, db::Layout &ly,
cell.insert (db::CellInstArray (db::CellInst (nci), db::Trans ()));
}
shapes.insert_into (&ly, nci, m->second);
shapes->insert_into (&ly, nci, m->second);
}
@ -152,8 +152,8 @@ static void dump_recursive_nets_to_layout (const db::LayoutToNetlist &l2n, db::L
for (std::map<const db::Region *, unsigned int>::const_iterator m = lmap.begin (); m != lmap.end (); ++m) {
db::Region shapes = l2n.shapes_of_net (*n, *m->first, true);
if (shapes.empty ()) {
std::auto_ptr<db::Region> shapes (l2n.shapes_of_net (*n, *m->first, true));
if (shapes->empty ()) {
continue;
}
@ -163,7 +163,7 @@ static void dump_recursive_nets_to_layout (const db::LayoutToNetlist &l2n, db::L
cell.insert (db::CellInstArray (db::CellInst (nci), db::Trans ()));
}
shapes.insert_into (&ly, nci, m->second);
shapes->insert_into (&ly, nci, m->second);
}