mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-10 04:01:46 +08:00
Follow-up to c3fec7b34934b44cef9334160d30cb02e36444f1
WIP: Invalidating shared support spots in Print::apply() The background slicing background was modified to call Print::cleanup() any time any data of any print step or print object step could become invalid. Cleaning up such invalid data will reduce memory footprint.
This commit is contained in:
parent
c3fec7b349
commit
31fbfa56de
@ -517,6 +517,7 @@ public:
|
||||
void set_task(const TaskParams ¶ms) override { PrintBaseWithState<PrintStep, psCount>::set_task_impl(params, m_objects); }
|
||||
void process() override;
|
||||
void finalize() override { PrintBaseWithState<PrintStep, psCount>::finalize_impl(m_objects); }
|
||||
void cleanup() override;
|
||||
|
||||
// Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
|
||||
// If preview_data is not null, the preview_data is filled in for the G-code visualization (not used by the command line Slic3r).
|
||||
|
@ -1451,7 +1451,18 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||
for (PrintObject *object : m_objects)
|
||||
object->update_slicing_parameters();
|
||||
|
||||
if (apply_status == APPLY_STATUS_INVALIDATED) {
|
||||
if (apply_status == APPLY_STATUS_CHANGED || apply_status == APPLY_STATUS_INVALIDATED)
|
||||
this->cleanup();
|
||||
|
||||
#ifdef _DEBUG
|
||||
check_model_ids_equal(m_model, model);
|
||||
#endif /* _DEBUG */
|
||||
|
||||
return static_cast<ApplyStatus>(apply_status);
|
||||
}
|
||||
|
||||
void Print::cleanup()
|
||||
{
|
||||
// Invalidate data of a single ModelObject shared by multiple PrintObjects.
|
||||
// Find spans of PrintObjects sharing the same PrintObjectRegions.
|
||||
std::vector<PrintObject*> all_objects(m_objects);
|
||||
@ -1464,13 +1475,6 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||
if (Print::is_shared_print_object_step_valid_unguarded(this_objects, posSupportSpotsSearch))
|
||||
shared_regions->generated_support_points.reset();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
check_model_ids_equal(m_model, model);
|
||||
#endif /* _DEBUG */
|
||||
|
||||
return static_cast<ApplyStatus>(apply_status);
|
||||
}
|
||||
|
||||
bool Print::is_shared_print_object_step_valid_unguarded(SpanOfConstPtrs<PrintObject> print_objects, PrintObjectStep print_object_step)
|
||||
|
@ -408,6 +408,10 @@ public:
|
||||
// Clean up after process() finished, either with success, error or if canceled.
|
||||
// The adjustments on the Print / PrintObject data due to set_task() are to be reverted here.
|
||||
virtual void finalize() = 0;
|
||||
// Clean up print step / print object step data after
|
||||
// 1) some print step / print object step was invalidated inside PrintBase::apply() while holding the milestone mutex locked.
|
||||
// 2) background thread finished being canceled.
|
||||
virtual void cleanup() = 0;
|
||||
|
||||
struct SlicingStatus {
|
||||
SlicingStatus(int percent, const std::string &text, unsigned int flags = 0) : percent(percent), text(text), flags(flags) {}
|
||||
|
@ -412,6 +412,7 @@ public:
|
||||
void set_task(const TaskParams ¶ms) override { PrintBaseWithState<SLAPrintStep, slapsCount>::set_task_impl(params, m_objects); }
|
||||
void process() override;
|
||||
void finalize() override { PrintBaseWithState<SLAPrintStep, slapsCount>::finalize_impl(m_objects); }
|
||||
void cleanup() override {}
|
||||
// Returns true if an object step is done on all objects and there's at least one object.
|
||||
bool is_step_done(SLAPrintObjectStep step) const;
|
||||
// Returns true if the last step was finished with success.
|
||||
|
@ -251,6 +251,9 @@ void BackgroundSlicingProcess::thread_proc()
|
||||
(m_state == STATE_CANCELED) ? SlicingProcessCompletedEvent::Cancelled :
|
||||
exception ? SlicingProcessCompletedEvent::Error : SlicingProcessCompletedEvent::Finished, exception);
|
||||
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone());
|
||||
// Cancelled by the user, not internally, thus cleanup() was not called yet.
|
||||
// Otherwise cleanup() is called from Print::apply()
|
||||
m_print->cleanup();
|
||||
}
|
||||
m_print->restart();
|
||||
lck.unlock();
|
||||
|
Loading…
x
Reference in New Issue
Block a user