mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
FIX: avoid arrange to nonprefered region
Previously we assume the NFP of exclude regions are rectangle, which was not always right. Now we calculate the NFP and find a best new position to shift. Change-Id: I02c075603cf71dd3c9146d7ac7a6706c0f850669 (cherry picked from commit 713ebd666c90d5dcfaf89914c37d211e9a470e99)
This commit is contained in:
@@ -183,6 +183,25 @@ bool overlaps(const ExPolygons& expolys1, const ExPolygons& expolys2)
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Point projection_onto(const ExPolygons& polygons, const Point& from)
|
||||
{
|
||||
Point projected_pt;
|
||||
double min_dist = std::numeric_limits<double>::max();
|
||||
|
||||
for (const auto& poly : polygons) {
|
||||
for (int i = 0; i < poly.num_contours(); i++) {
|
||||
Point p = from.projection_onto(poly.contour_or_hole(i));
|
||||
double dist = (from - p).cast<double>().squaredNorm();
|
||||
if (dist < min_dist) {
|
||||
projected_pt = p;
|
||||
min_dist = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return projected_pt;
|
||||
}
|
||||
|
||||
void ExPolygon::simplify_p(double tolerance, Polygons* polygons) const
|
||||
|
||||
Reference in New Issue
Block a user