SPE-2698: Fix crash during regions expansion.

This commit is contained in:
Lukáš Hejl 2025-02-24 01:48:23 +01:00 committed by Lukas Matena
parent ed27d06be3
commit a3f75133c8
2 changed files with 33 additions and 0 deletions

View File

@ -283,6 +283,11 @@ std::vector<WaveSeed> wave_seeds(
// 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));
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.

View File

@ -284,3 +284,31 @@ SCENARIO("Region expansion basics", "[RegionExpansion]") {
}
}
}
TEST_CASE("WaveSeed - ZFillFunction - SPE-2698", "[WaveSeedZFillFunctionSPE2698]")
{
const ExPolygons boundary = {{
Point(-5900000, -20000000),
Point(-6518889, -22009467),
Point(-5779768, -22315621),
Point(-5662934, -22033558),
Point(-5615689, -21919501),
Point(-5779767, -22315622),
Point(-5040682, -22621761),
Point(-4000000, -20000000),
}};
const ExPolygons src = {{
Point(-5615689, -21919501),
Point(-5662934, -22033558),
Point(-5779768, -22315621),
Point(-5779767, -22315622),
}};
std::vector<Slic3r::Algorithm::WaveSeed> wave_seeds = Slic3r::Algorithm::wave_seeds(src, boundary, 83561.8046, true);
for (const Slic3r::Algorithm::WaveSeed &wave_seed : wave_seeds) {
REQUIRE(wave_seed.src < src.size());
REQUIRE(wave_seed.boundary < boundary.size());
}
}