Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor code clarity #6057

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 27 additions & 29 deletions src/drt/src/io/GuideProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1580,9 +1580,9 @@ void GuidePathFinder::clipGuides(std::vector<frRect>& rects)
continue;
}
if (box.ll() == pt) {
rect.setBBox(Rect(box.xMax(), box.yMax(), box.xMax(), box.yMax()));
rect.setBBox(Rect(box.ur(), box.ur()));
} else {
rect.setBBox(Rect(box.xMin(), box.yMin(), box.xMin(), box.yMin()));
rect.setBBox(Rect(box.ll(), box.ll()));
}
node_map_[pt].erase(node_map_[pt].find(idx));
}
Expand All @@ -1598,32 +1598,30 @@ void GuidePathFinder::mergeGuides(std::vector<frRect>& rects)
std::back_inserter(visited_indices),
[this](int idx) { return visited_[idx]; });
const uint num_indices = visited_indices.size();
if (num_indices == 2) {
const auto first_idx = *(visited_indices.begin());
const auto second_idx = *std::prev(visited_indices.end());
if (!isGuideIdx(first_idx) || !isGuideIdx(second_idx)) {
continue;
}
auto& rect1 = rects[first_idx];
auto& rect2 = rects[second_idx];
Rect box1 = rect1.getBBox();
Rect box2 = rect2.getBBox();
if (box1.getDir() == box2.getDir()) {
// merge both and remove rect1/box1/first_idx
box2.merge(box1);
rect2.setBBox(box2);
node_map_[pt].clear();
Point3D to_be_updated_pos;
if (box1.ll() == pt) {
to_be_updated_pos = Point3D(box1.ur(), pt.z());
} else {
to_be_updated_pos = Point3D(box1.ll(), pt.z());
}
auto it = node_map_[to_be_updated_pos].find(first_idx);
node_map_[to_be_updated_pos].erase(it);
node_map_[to_be_updated_pos].insert(second_idx);
visited_[first_idx] = false;
}
if (num_indices != 2) {
continue;
}
const auto first_idx = *(visited_indices.begin());
const auto second_idx = *std::prev(visited_indices.end());
if (!isGuideIdx(first_idx) || !isGuideIdx(second_idx)) {
continue;
}
auto& rect1 = rects[first_idx];
auto& rect2 = rects[second_idx];
Rect box1 = rect1.getBBox();
Rect box2 = rect2.getBBox();
if (box1.getDir() == box2.getDir()) {
continue;
}
// merge both and remove rect1/box1/first_idx
box2.merge(box1);
rect2.setBBox(box2);
node_map_[pt].clear();
Point3D to_be_updated_pos((box1.ll() == pt) ? box1.ur() : box1.ll(), pt.z());
auto it = node_map_[to_be_updated_pos].find(first_idx);
node_map_[to_be_updated_pos].erase(it);
node_map_[to_be_updated_pos].insert(second_idx);
visited_[first_idx] = false;
}
}
}
Expand Down Expand Up @@ -1997,4 +1995,4 @@ void GuideProcessor::processGuides()
}
}

} // namespace drt::io
} // namespace drt::io
Loading