ENH: boost is_support_necessary's performance

1. Parallelize the majority of overhang detection, leaving only a small
part of sharp tail detection as sequential. This strategy makes
is_support_necessary 10 times faster.
2. Use the overlaps function to detect overlapping, instead of using
intersection().empty()
3. Control the max recursion depth to prevent crashing due to too deep
recursion.

Jira: STUDIO-2445, STUDIO-2458
Change-Id: I35283da3e4a22d7afe251b804ce30b90a9d754df
(cherry picked from commit 1a6fedd1a0c82906f1807234ea1b816247ca6fd7)
This commit is contained in:
arthur.tang 2023-03-14 17:04:42 +08:00 committed by Lane.Wei
parent 6f298ac6f1
commit 6c489808a7
5 changed files with 280 additions and 325 deletions

View file

@ -174,6 +174,17 @@ bool ExPolygon::overlaps(const ExPolygon &other) const
other.contains(this->contour.points.front());
}
bool overlaps(const ExPolygons& expolys1, const ExPolygons& expolys2)
{
for (const ExPolygon& expoly1 : expolys1) {
for (const ExPolygon& expoly2 : expolys2) {
if (expoly1.overlaps(expoly2))
return true;
}
}
return false;
}
void ExPolygon::simplify_p(double tolerance, Polygons* polygons) const
{
Polygons pp = this->simplify_p(tolerance);