From 9bf2b0c83209e2a8d9e412977d8ab512431dd3bd Mon Sep 17 00:00:00 2001 From: Hanif Koh Date: Fri, 28 Aug 2026 12:54:24 +0800 Subject: [PATCH] Add safeguard against extruder_pintable_heights and extruder_areas vector size mismatch --- src/libslic3r/BuildVolume.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/BuildVolume.cpp b/src/libslic3r/BuildVolume.cpp index 1ac200d9c8..2502fd2d73 100644 --- a/src/libslic3r/BuildVolume.cpp +++ b/src/libslic3r/BuildVolume.cpp @@ -13,7 +13,6 @@ BuildVolume::BuildVolume(const std::vector &printable_area, const double : m_bed_shape(printable_area), m_max_print_height(printable_height), m_extruder_shapes(extruder_areas), m_extruder_printable_height(extruder_printable_heights) { assert(printable_height >= 0); - //assert(extruder_printable_heights.size() == extruder_areas.size()); m_polygon = Polygon::new_scale(printable_area); assert(m_polygon.is_counter_clockwise()); @@ -100,7 +99,12 @@ BuildVolume::BuildVolume(const std::vector &printable_area, const double return; } - if ((extruder_shape == printable_area)&&(extruder_printable_heights[index] == printable_height)) { + if (index >= extruder_printable_heights.size()) + BOOST_LOG_TRIVIAL(warning) << boost::format("extruder_printable_height has only %1% entries but extruder_printable_area has %2%; using bed printable_height for extruder %3%") + % extruder_printable_heights.size() % m_extruder_shapes.size() % index; + const double extruder_height = index < extruder_printable_heights.size() ? extruder_printable_heights[index] : printable_height; + + if ((extruder_shape == printable_area)&&(extruder_height == printable_height)) { extruder_volume.same_with_bed = true; extruder_volume.type = m_type; extruder_volume.bbox = m_bbox; @@ -113,7 +117,7 @@ BuildVolume::BuildVolume(const std::vector &printable_area, const double double poly_area = poly.area(); extruder_volume.bbox = get_extents(poly); BoundingBoxf temp_bboxf = get_extents(extruder_shape); - extruder_volume.bboxf = BoundingBoxf3{ to_3d(temp_bboxf.min, 0.), to_3d(temp_bboxf.max, extruder_printable_heights[index]) }; + extruder_volume.bboxf = BoundingBoxf3{ to_3d(temp_bboxf.min, 0.), to_3d(temp_bboxf.max, extruder_height) }; if (extruder_shape.size() >= 4 && std::abs((poly_area - double(extruder_volume.bbox.size().x()) * double(extruder_volume.bbox.size().y()))) < sqr(SCALED_EPSILON)) {