Skip to content

Commit 8c070dd

Browse files
committed
🐛 Fix architecture for patches outside of zones
1 parent 570a224 commit 8c070dd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/na/Architecture.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,14 @@ auto Architecture::getPositionOffsetBy(const Point& p, const Number& rows,
545545
if (!nextSiteOpt.has_value()) {
546546
break;
547547
}
548-
anchorSitePos = getPositionOfSite(nextSiteOpt.value());
548+
const auto& newAnchorSitePos = getPositionOfSite(nextSiteOpt.value());
549+
// The following check is used to decide whether the patch is located outside of the zone
550+
// Patches that overlap the border of the zone are not possible with this appraoch yet
551+
if (std::abs(newAnchorSitePos.y - anchorSitePos.y) < std::abs(dy)) {
552+
break;
553+
} else {
554+
anchorSitePos = newAnchorSitePos;
555+
}
549556
}
550557

551558
for (; c > 0; --c) {
@@ -555,7 +562,12 @@ auto Architecture::getPositionOffsetBy(const Point& p, const Number& rows,
555562
if (!nextSiteOpt.has_value()) {
556563
break;
557564
}
558-
anchorSitePos = getPositionOfSite(nextSiteOpt.value());
565+
const auto& newAnchorSitePos = getPositionOfSite(nextSiteOpt.value());
566+
if (std::abs(newAnchorSitePos.x - anchorSitePos.x) < std::abs(dx)) {
567+
break;
568+
} else {
569+
anchorSitePos = newAnchorSitePos;
570+
}
559571
}
560572
anchorSitePos.x =
561573
cols >= 0 ? anchorSitePos.x + c * d : anchorSitePos.x - c * d;

0 commit comments

Comments
 (0)