diff --git a/src/db/db/dbLayoutToNetlist.cc b/src/db/db/dbLayoutToNetlist.cc index 4ac11e41c..b8491b9ac 100644 --- a/src/db/db/dbLayoutToNetlist.cc +++ b/src/db/db/dbLayoutToNetlist.cc @@ -209,10 +209,10 @@ const db::hier_clusters &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 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 &lc = m_netex.clusters ().clusters_per_cell (ci).cluster_by_id (net.cluster_id ()); for (db::local_cluster::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 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) diff --git a/src/db/db/dbLayoutToNetlist.h b/src/db/db/dbLayoutToNetlist.h index 8a9a8efbd..09834dcf1 100644 --- a/src/db/db/dbLayoutToNetlist.h +++ b/src/db/db/dbLayoutToNetlist.h @@ -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 diff --git a/src/db/db/gsiDeclDbLayoutToNetlist.cc b/src/db/db/gsiDeclDbLayoutToNetlist.cc index 900c906f5..6cee2d264 100644 --- a/src/db/db/gsiDeclDbLayoutToNetlist.cc +++ b/src/db/db/gsiDeclDbLayoutToNetlist.cc @@ -141,7 +141,7 @@ Class 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" diff --git a/src/db/unit_tests/dbLayoutToNetlistTests.cc b/src/db/unit_tests/dbLayoutToNetlistTests.cc index 2254c9b23..e70ab822c 100644 --- a/src/db/unit_tests/dbLayoutToNetlistTests.cc +++ b/src/db/unit_tests/dbLayoutToNetlistTests.cc @@ -114,8 +114,8 @@ static void dump_nets_to_layout (const db::LayoutToNetlist &l2n, db::Layout &ly, for (std::map::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 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_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 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); }