mirror of
https://git.mirrors.martin98.com/https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-03 13:15:08 +08:00
Fix rare crash when calculating bridge expansion (#9287)
* Fix #12469 - crash caused by bridge expansion. Handle a very rare case in which the algorithm picks a wrong polygon for expansion seed. (cherry picked from commit 5f843cc93470c96483abcbd47cf8ee5fe38dffe2) * SPE-2698: Fix crash during regions expansion. (cherry picked from commit a3f75133c8baead6f8d7bb01722a6bfcdc2e9038) --------- Co-authored-by: Martin Šach <martin.sachin@gmail.com> Co-authored-by: Lukáš Hejl <hejl.lukas@gmail.com>
This commit is contained in:
parent
7a40ebda66
commit
8e38ac234f
@ -258,14 +258,33 @@ std::vector<WaveSeed> wave_seeds(
|
|||||||
int iseed = 0;
|
int iseed = 0;
|
||||||
for (const ClipperLib_Z::Path &path : segments) {
|
for (const ClipperLib_Z::Path &path : segments) {
|
||||||
assert(path.size() >= 2);
|
assert(path.size() >= 2);
|
||||||
const ClipperLib_Z::IntPoint &front = path.front();
|
ClipperLib_Z::IntPoint front = path.front();
|
||||||
const ClipperLib_Z::IntPoint &back = path.back();
|
ClipperLib_Z::IntPoint back = path.back();
|
||||||
// Both ends of a seed segment are supposed to be inside a single boundary expolygon.
|
// Both ends of a seed segment are supposed to be inside a single boundary expolygon.
|
||||||
// Thus as long as the seed contour is not closed, it should be open at a boundary point.
|
// Thus as long as the seed contour is not closed, it should be open at a boundary point.
|
||||||
assert((front == back && front.z() >= idx_boundary_end && front.z() < idx_src_end) ||
|
assert((front == back && front.z() >= idx_boundary_end && front.z() < idx_src_end) ||
|
||||||
//(front.z() < 0 && back.z() < 0));
|
//(front.z() < 0 && back.z() < 0));
|
||||||
// Hope that at least one end of an open polyline is clipped by the boundary, thus an intersection point is created.
|
// Hope that at least one end of an open polyline is clipped by the boundary, thus an intersection point is created.
|
||||||
(front.z() < 0 || back.z() < 0));
|
(front.z() < 0 || back.z() < 0));
|
||||||
|
|
||||||
|
if (front != back && front.z() >= 0 && back.z() >= 0) {
|
||||||
|
// Very rare case when both endpoints intersect boundary ExPolygons in existing points.
|
||||||
|
// So the ZFillFunction callback hasn't been called.
|
||||||
|
continue;
|
||||||
|
} else
|
||||||
|
if (front == back && (front.z() < idx_boundary_end)) {
|
||||||
|
// This should be a very rare exception.
|
||||||
|
// See https://github.com/prusa3d/PrusaSlicer/issues/12469.
|
||||||
|
// Segement is open, yet its first point seems to be part of boundary polygon.
|
||||||
|
// Take the first point with src polygon index.
|
||||||
|
for (const ClipperLib_Z::IntPoint &point : path) {
|
||||||
|
if (point.z() >= idx_boundary_end) {
|
||||||
|
front = point;
|
||||||
|
back = point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Intersection *intersection = nullptr;
|
const Intersection *intersection = nullptr;
|
||||||
auto intersection_point_valid = [idx_boundary_end, idx_src_end](const Intersection &is) {
|
auto intersection_point_valid = [idx_boundary_end, idx_src_end](const Intersection &is) {
|
||||||
return is.first >= 1 && is.first < idx_boundary_end &&
|
return is.first >= 1 && is.first < idx_boundary_end &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user