From 488cffa559a08683ae7ac546ea4b0fecf6ca053f Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Thu, 12 May 2022 13:29:13 +0200 Subject: [PATCH] Fix crash when optimizing rotation probably helps to solve #8319 --- src/slic3r/GUI/Jobs/RotoptimizeJob.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp b/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp index 95821a674d..340be5d11f 100644 --- a/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp +++ b/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp @@ -92,16 +92,18 @@ void RotoptimizeJob::finalize() auto trmatrix = oi->get_transformation().get_matrix(); Polygon trchull = o->convex_hull_2d(trmatrix); - - MinAreaBoundigBox rotbb(trchull, MinAreaBoundigBox::pcConvex); - double phi = rotbb.angle_to_X(); - - // The box should be landscape - if(rotbb.width() < rotbb.height()) phi += PI / 2; - - Vec3d rt = oi->get_rotation(); rt(Z) += phi; - - oi->set_rotation(rt); + + if (!trchull.empty()) { + MinAreaBoundigBox rotbb(trchull, MinAreaBoundigBox::pcConvex); + double phi = rotbb.angle_to_X(); + + // The box should be landscape + if(rotbb.width() < rotbb.height()) phi += PI / 2; + + Vec3d rt = oi->get_rotation(); rt(Z) += phi; + + oi->set_rotation(rt); + } } // Correct the z offset of the object which was corrupted be