FIX: tree support may miss contact points along overhang contours

We use EdgeCache to sample contact points along overhang contours.
However, the EdgeCache misses the last edge if the polygon is not closed.

jira: STUDIO-9179
Change-Id: Id06b565b12f513e753a66135c74eab60979ea612
This commit is contained in:
Arthur 2024-12-13 17:25:47 +08:00 committed by Lane.Wei
parent 92a6014795
commit b1844cc2a2
1 changed files with 10 additions and 0 deletions

View File

@ -183,6 +183,11 @@ template<class RawShape> class EdgeCache {
contour_.full_distance += length(contour_.emap.back());
contour_.distances.emplace_back(contour_.full_distance);
}
if (*sl::cbegin(sh)!=*sl::rcbegin(sh)) {
contour_.emap.emplace_back(*std::prev(endit), *sl::cbegin(sh));
contour_.full_distance += length(contour_.emap.back());
contour_.distances.emplace_back(contour_.full_distance);
}
}
for(auto& h : shapelike::holes(sh)) { // For the holes
@ -198,6 +203,11 @@ template<class RawShape> class EdgeCache {
hc.full_distance += length(hc.emap.back());
hc.distances.emplace_back(hc.full_distance);
}
if (*sl::cbegin(h) != *sl::rcbegin(h)) {
hc.emap.emplace_back(*std::prev(endit), *sl::cbegin(h));
hc.full_distance += length(hc.emap.back());
hc.distances.emplace_back(hc.full_distance);
}
holes_.emplace_back(std::move(hc));
}