Skip to content

Commit

Permalink
Merge pull request #6049 from smunaut/iterm-geom
Browse files Browse the repository at this point in the history
odb: In dbITerm::getGeometries, return layer + rect
  • Loading branch information
maliberty authored Nov 23, 2024
2 parents 62c4360 + dcb9668 commit 35d3dd3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -3636,7 +3636,8 @@ class dbITerm : public dbObject
///
/// Returns all geometries of all dbMPin associated with
/// the dbMTerm.
std::vector<Rect> getGeometries() const;
///
std::vector<std::pair<dbTechLayer*, Rect>> getGeometries() const;

void setAccessPoint(dbMPin* pin, dbAccessPoint* ap);

Expand Down
6 changes: 3 additions & 3 deletions src/odb/src/db/dbITerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,16 +801,16 @@ std::vector<dbAccessPoint*> dbITerm::getPrefAccessPoints() const
return aps;
}

std::vector<Rect> dbITerm::getGeometries() const
std::vector<std::pair<dbTechLayer*, Rect>> dbITerm::getGeometries() const
{
const dbTransform transform = getInst()->getTransform();

std::vector<Rect> geometries;
std::vector<std::pair<dbTechLayer*, Rect>> geometries;
for (dbMPin* mpin : getMTerm()->getMPins()) {
for (dbBox* box : mpin->getGeometry()) {
Rect rect = box->getBox();
transform.apply(rect);
geometries.push_back(rect);
geometries.emplace_back(box->getTechLayer(), rect);
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/odb/src/swig/python/dbtypes.i
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@
$result = list;
}

%typemap(out) std::vector< std::pair< T*, odb::Rect > > {
PyObject *list = PyList_New($1.size());
for (unsigned int i = 0; i < $1.size(); i++) {
PyObject *sub_list = PyList_New(2);
std::pair< T*, odb::Rect > p = $1.at(i);
T* ptr1 = p.first;
odb::Rect* ptr2 = new odb::Rect(p.second);
PyObject *obj1 = SWIG_NewInstanceObj(ptr1, $descriptor(T *), 0);
PyObject *obj2 = SWIG_NewInstanceObj(ptr2, $descriptor(odb::Rect *), 0);
PyList_SetItem(sub_list, 0, obj1);
PyList_SetItem(sub_list, 1, obj2);
PyList_SetItem(list, i, sub_list);
}
$result = list;
}

%typemap(in) std::vector< T* >* (std::vector< T* > *v, std::vector< T* > w),
std::vector< T* >& (std::vector< T* > *v, std::vector< T* > w) {

Expand Down
16 changes: 16 additions & 0 deletions src/odb/src/swig/tcl/dbtypes.i
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@
Tcl_SetObjResult(interp, list);
}

%typemap(out) std::vector< std::pair< T*, odb::Rect > > {
Tcl_Obj *list = Tcl_NewListObj(0, nullptr);
for (unsigned int i = 0; i < $1.size(); i++) {
Tcl_Obj *sub_list = Tcl_NewListObj(0, nullptr);
std::pair< T*, odb::Rect > p = $1.at(i);
T* ptr1 = p.first;
odb::Rect* ptr2 = new odb::Rect(p.second);
Tcl_Obj *obj1 = SWIG_NewInstanceObj(ptr1, $descriptor(T *), 0);
Tcl_Obj *obj2 = SWIG_NewInstanceObj(ptr2, $descriptor(odb::Rect *), 0);
Tcl_ListObjAppendElement(interp, sub_list, obj1);
Tcl_ListObjAppendElement(interp, sub_list, obj2);
Tcl_ListObjAppendElement(interp, list, sub_list);
}
Tcl_SetObjResult(interp, list);
}

%typemap(in) std::vector< T* >* (std::vector< T* > *v, std::vector< T* > w),
std::vector< T* >& (std::vector< T* > *v, std::vector< T* > w) {
Tcl_Obj **listobjv;
Expand Down

0 comments on commit 35d3dd3

Please sign in to comment.