mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-08 02:49:11 +08:00
Logging during sla processing.
This commit is contained in:
parent
2be23c8b14
commit
dae01af2ac
@ -420,6 +420,12 @@ void swapXY(ExPolygon& expoly) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class...Args>
|
||||||
|
void report_status(SLAPrint& p, int st, const std::string& msg, Args&&...args) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << st << "% " << msg;
|
||||||
|
p.set_status(st, msg, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
void SLAPrint::process()
|
void SLAPrint::process()
|
||||||
{
|
{
|
||||||
using namespace sla;
|
using namespace sla;
|
||||||
@ -524,9 +530,11 @@ void SLAPrint::process()
|
|||||||
// scaling for the sub operations
|
// scaling for the sub operations
|
||||||
double d = *stthis / (objcount * 100.0);
|
double d = *stthis / (objcount * 100.0);
|
||||||
|
|
||||||
ctl.statuscb = [this, init, d](unsigned st, const std::string& msg){
|
ctl.statuscb = [this, init, d](unsigned st, const std::string& msg)
|
||||||
set_status(int(init + st*d), msg);
|
{
|
||||||
|
report_status(*this, int(init + st*d), msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
ctl.stopcondition = [this](){ return canceled(); };
|
ctl.stopcondition = [this](){ return canceled(); };
|
||||||
ctl.cancelfn = [this]() { throw_if_canceled(); };
|
ctl.cancelfn = [this]() { throw_if_canceled(); };
|
||||||
|
|
||||||
@ -536,9 +544,9 @@ void SLAPrint::process()
|
|||||||
|
|
||||||
// Create the unified mesh
|
// Create the unified mesh
|
||||||
auto rc = SlicingStatus::RELOAD_SCENE;
|
auto rc = SlicingStatus::RELOAD_SCENE;
|
||||||
set_status(-1, L("Visualizing supports"));
|
report_status(*this, -1, L("Visualizing supports"));
|
||||||
po.m_supportdata->support_tree_ptr->merged_mesh();
|
po.m_supportdata->support_tree_ptr->merged_mesh();
|
||||||
set_status(-1, L("Visualizing supports"), rc);
|
report_status(*this, -1, L("Visualizing supports"), rc);
|
||||||
} catch(sla::SLASupportsStoppedException&) {
|
} catch(sla::SLASupportsStoppedException&) {
|
||||||
// no need to rethrow
|
// no need to rethrow
|
||||||
// throw_if_canceled();
|
// throw_if_canceled();
|
||||||
@ -581,7 +589,7 @@ void SLAPrint::process()
|
|||||||
|
|
||||||
po.throw_if_canceled();
|
po.throw_if_canceled();
|
||||||
auto rc = SlicingStatus::RELOAD_SCENE;
|
auto rc = SlicingStatus::RELOAD_SCENE;
|
||||||
set_status(-1, L("Visualizing supports"), rc);
|
report_status(*this, -1, L("Visualizing supports"), rc);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Slicing the support geometries similarly to the model slicing procedure.
|
// Slicing the support geometries similarly to the model slicing procedure.
|
||||||
@ -740,8 +748,12 @@ void SLAPrint::process()
|
|||||||
auto lvlcnt = unsigned(m_printer_input.size());
|
auto lvlcnt = unsigned(m_printer_input.size());
|
||||||
printer.layers(lvlcnt);
|
printer.layers(lvlcnt);
|
||||||
|
|
||||||
|
// slot is the portion of 100% that is realted to rasterization
|
||||||
unsigned slot = PRINT_STEP_LEVELS[slapsRasterize];
|
unsigned slot = PRINT_STEP_LEVELS[slapsRasterize];
|
||||||
|
// ist: initial state; pst: previous state
|
||||||
unsigned ist = max_objstatus, pst = ist;
|
unsigned ist = max_objstatus, pst = ist;
|
||||||
|
// coefficient to map the rasterization state (0-99) to the allocated
|
||||||
|
// portion (slot) of the process state
|
||||||
double sd = (100 - ist) / 100.0;
|
double sd = (100 - ist) / 100.0;
|
||||||
SpinMutex slck;
|
SpinMutex slck;
|
||||||
|
|
||||||
@ -778,11 +790,11 @@ void SLAPrint::process()
|
|||||||
// Finish the layer for later saving it.
|
// Finish the layer for later saving it.
|
||||||
printer.finish_layer(level_id);
|
printer.finish_layer(level_id);
|
||||||
|
|
||||||
// Status indication
|
// Status indication guarded with the spinlock
|
||||||
auto st = ist + unsigned(sd*level_id*slot/m_printer_input.size());
|
auto st = ist + unsigned(sd*level_id*slot/m_printer_input.size());
|
||||||
{ std::lock_guard<SpinMutex> lck(slck);
|
{ std::lock_guard<SpinMutex> lck(slck);
|
||||||
if( st > pst) {
|
if( st > pst) {
|
||||||
set_status(int(st), PRINT_STEP_LABELS[slapsRasterize]);
|
report_status(*this, int(st), PRINT_STEP_LABELS[slapsRasterize]);
|
||||||
pst = st;
|
pst = st;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -832,9 +844,14 @@ void SLAPrint::process()
|
|||||||
unsigned st = min_objstatus;
|
unsigned st = min_objstatus;
|
||||||
unsigned incr = 0;
|
unsigned incr = 0;
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Start slicing process.";
|
||||||
|
|
||||||
// TODO: this loop could run in parallel but should not exhaust all the CPU
|
// TODO: this loop could run in parallel but should not exhaust all the CPU
|
||||||
// power available
|
// power available
|
||||||
for(SLAPrintObject * po : m_objects) {
|
for(SLAPrintObject * po : m_objects) {
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Slicing object " << po->model_object()->name;
|
||||||
|
|
||||||
for(size_t s = 0; s < objectsteps.size(); ++s) {
|
for(size_t s = 0; s < objectsteps.size(); ++s) {
|
||||||
auto currentstep = objectsteps[s];
|
auto currentstep = objectsteps[s];
|
||||||
|
|
||||||
@ -846,8 +863,7 @@ void SLAPrint::process()
|
|||||||
st += unsigned(incr * ostepd);
|
st += unsigned(incr * ostepd);
|
||||||
|
|
||||||
if(po->m_stepmask[currentstep] && po->set_started(currentstep)) {
|
if(po->m_stepmask[currentstep] && po->set_started(currentstep)) {
|
||||||
|
report_status(*this, int(st), OBJ_STEP_LABELS[currentstep]);
|
||||||
set_status(int(st), OBJ_STEP_LABELS[currentstep]);
|
|
||||||
pobj_program[currentstep](*po);
|
pobj_program[currentstep](*po);
|
||||||
po->set_done(currentstep);
|
po->set_done(currentstep);
|
||||||
}
|
}
|
||||||
@ -872,7 +888,7 @@ void SLAPrint::process()
|
|||||||
|
|
||||||
if(m_stepmask[currentstep] && set_started(currentstep))
|
if(m_stepmask[currentstep] && set_started(currentstep))
|
||||||
{
|
{
|
||||||
set_status(int(st), PRINT_STEP_LABELS[currentstep]);
|
report_status(*this, int(st), PRINT_STEP_LABELS[currentstep]);
|
||||||
print_program[currentstep]();
|
print_program[currentstep]();
|
||||||
set_done(currentstep);
|
set_done(currentstep);
|
||||||
}
|
}
|
||||||
@ -881,7 +897,7 @@ void SLAPrint::process()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If everything vent well
|
// If everything vent well
|
||||||
set_status(100, L("Slicing done"));
|
report_status(*this, 100, L("Slicing done"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_option_key> &opt_keys)
|
bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_option_key> &opt_keys)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user