Skip to content

gui: fix bbox descriptor#10575

Draft
LucasYuki wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:gui-bbox-descriptors
Draft

gui: fix bbox descriptor#10575
LucasYuki wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:gui-bbox-descriptors

Conversation

@LucasYuki
Copy link
Copy Markdown
Contributor

Summary

This PR fixes 2 bugs in the gui:

  • The descriptor shows a bounding box in objects that don't have one.
  • Wrong bounding box calculation in some nets.

Changes:

  • Check if bbox is inverted in the getBBox method of the descriptors.
  • Doesn't apply transformation in the bounding box of a bterm if it doesn't have any MPins.

Type of Change

  • Bug fix

Impact

[How does this change the tool's behavior?]
Now objects that don't have a bounding box don't show an invalid bounding box.

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Related Issues

[Link issues here]

LucasYuki and others added 2 commits May 21, 2026 19:40
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: LucasYuki <46359888+LucasYuki@users.noreply.github.com>
@LucasYuki LucasYuki self-assigned this Jun 1, 2026
@github-actions github-actions Bot added the size/S label Jun 1, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors several bounding box retrieval methods in dbDescriptors.cpp to return whether the bounding box is valid using !bbox.isInverted() instead of unconditionally returning true or tracking a boolean flag. It also adds a check in dbITerm.cpp to handle empty master pins. The reviewer feedback highlights two critical issues where applying coordinate transforms to inverted bounding boxes can cause integer overflow/underflow, corrupting the coordinates and bypassing the inversion checks. The reviewer suggests checking for inverted bounding boxes before applying transforms in both dbITerm::getBBox and DbBoxDescriptor::getBBox.

Comment on lines +747 to 752
if (term->getMPins().empty()) {
Rect bbox;
bbox.mergeInit();
return bbox;
}
Rect bbox = term->getBBox();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of checking if getMPins().empty() and manually constructing an inverted bounding box, it is more robust and direct to check if the retrieved term->getBBox() is inverted. This handles both the empty pins case and any other scenario where the master terminal's bounding box is invalid, while also preventing the instance transform from being applied to an inverted bounding box (which would corrupt its coordinates due to overflow/underflow during translation/rotation).

  Rect bbox = term->getBBox();
  if (bbox.isInverted()) {
    return bbox;
  }

Comment on lines 5533 to +5536
bbox = getObject(object)->getBox();
const auto xform = getTransform(object);
xform.apply(bbox);
return true;
return !bbox.isInverted();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If bbox is inverted, applying the transform via xform.apply(bbox) will corrupt the coordinates (due to integer overflow/underflow during translation/rotation of INT_MAX/INT_MIN), which can make the box appear non-inverted and cause !bbox.isInverted() to incorrectly return true. It is safer to check if bbox is inverted and return false before applying the transform.

  bbox = getObject(object)->getBox();
  if (bbox.isInverted()) {
    return false;
  }
  const auto xform = getTransform(object);
  xform.apply(bbox);
  return true;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant