From 9e89a1e10ee9dda75b5a949339f4bc6ecd10b45f Mon Sep 17 00:00:00 2001 From: "yifan.wu" Date: Mon, 24 Oct 2022 17:21:23 +0800 Subject: [PATCH] ENH: optimize the performance of slicing Signed-off-by: yifan.wu Change-Id: Ic769fabf641eb07eaf5cb55bf308a49831998470 --- src/libslic3r/Print.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 0e273e793a..ef5761ecbc 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1404,15 +1404,21 @@ void Print::process() obj->set_done(posIroning); } } - for (PrintObject *obj : m_objects) { - if (need_slicing_objects.count(obj) != 0) { - obj->generate_support_material(); - } - else { - if (obj->set_started(posSupportMaterial)) - obj->set_done(posSupportMaterial); + + tbb::parallel_for(tbb::blocked_range(0, int(m_objects.size())), + [this, need_slicing_objects](const tbb::blocked_range& range) { + for (int i = range.begin(); i < range.end(); i++) { + PrintObject* obj = m_objects[i]; + if (need_slicing_objects.count(obj) != 0) { + obj->generate_support_material(); + } + else { + if (obj->set_started(posSupportMaterial)) + obj->set_done(posSupportMaterial); + } + } } - } + ); for (PrintObject *obj : m_objects) {