Merging new steps integration
This commit is contained in:
commit
8fdff97eb7
4 changed files with 50 additions and 58 deletions
|
@ -43,8 +43,7 @@ const std::array<unsigned, slaposCount> OBJ_STEP_LEVELS =
|
||||||
30, // slaposSupportPoints,
|
30, // slaposSupportPoints,
|
||||||
25, // slaposSupportTree,
|
25, // slaposSupportTree,
|
||||||
25, // slaposBasePool,
|
25, // slaposBasePool,
|
||||||
5, // slaposSliceSupports,
|
10, // slaposSliceSupports,
|
||||||
5 // slaposIndexSlices
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::array<std::string, slaposCount> OBJ_STEP_LABELS =
|
const std::array<std::string, slaposCount> OBJ_STEP_LABELS =
|
||||||
|
@ -54,22 +53,19 @@ const std::array<std::string, slaposCount> OBJ_STEP_LABELS =
|
||||||
L("Generating support tree"), // slaposSupportTree,
|
L("Generating support tree"), // slaposSupportTree,
|
||||||
L("Generating pad"), // slaposBasePool,
|
L("Generating pad"), // slaposBasePool,
|
||||||
L("Slicing supports"), // slaposSliceSupports,
|
L("Slicing supports"), // slaposSliceSupports,
|
||||||
L("Slicing supports") // slaposIndexSlices,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Should also add up to 100 (%)
|
// Should also add up to 100 (%)
|
||||||
const std::array<unsigned, slapsCount> PRINT_STEP_LEVELS =
|
const std::array<unsigned, slapsCount> PRINT_STEP_LEVELS =
|
||||||
{
|
{
|
||||||
5, // slapsStats
|
5, // slapsStats
|
||||||
94, // slapsRasterize
|
95, // slapsRasterize
|
||||||
1, // slapsValidate
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::array<std::string, slapsCount> PRINT_STEP_LABELS =
|
const std::array<std::string, slapsCount> PRINT_STEP_LABELS =
|
||||||
{
|
{
|
||||||
L("Calculating statistics"), // slapsStats
|
L("Merging slices and calculating statistics"), // slapsStats
|
||||||
L("Rasterizing layers"), // slapsRasterize
|
L("Rasterizing layers"), // slapsRasterize
|
||||||
L("Validating"), // slapsValidate
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -206,7 +202,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, const DynamicPrintConf
|
||||||
model_object_status.emplace(model_object->id(), ModelObjectStatus::Old);
|
model_object_status.emplace(model_object->id(), ModelObjectStatus::Old);
|
||||||
} else if (model_object_list_extended(m_model, model)) {
|
} else if (model_object_list_extended(m_model, model)) {
|
||||||
// Add new objects. Their volumes and configs will be synchronized later.
|
// Add new objects. Their volumes and configs will be synchronized later.
|
||||||
update_apply_status(this->invalidate_step(slapsRasterize));
|
update_apply_status(this->invalidate_step(slapsMergeSlicesAndEval));
|
||||||
for (const ModelObject *model_object : m_model.objects)
|
for (const ModelObject *model_object : m_model.objects)
|
||||||
model_object_status.emplace(model_object->id(), ModelObjectStatus::Old);
|
model_object_status.emplace(model_object->id(), ModelObjectStatus::Old);
|
||||||
for (size_t i = m_model.objects.size(); i < model.objects.size(); ++ i) {
|
for (size_t i = m_model.objects.size(); i < model.objects.size(); ++ i) {
|
||||||
|
@ -218,7 +214,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, const DynamicPrintConf
|
||||||
// Reorder the objects, add new objects.
|
// Reorder the objects, add new objects.
|
||||||
// First stop background processing before shuffling or deleting the PrintObjects in the object list.
|
// First stop background processing before shuffling or deleting the PrintObjects in the object list.
|
||||||
this->call_cancel_callback();
|
this->call_cancel_callback();
|
||||||
update_apply_status(this->invalidate_step(slapsRasterize));
|
update_apply_status(this->invalidate_step(slapsMergeSlicesAndEval));
|
||||||
// Second create a new list of objects.
|
// Second create a new list of objects.
|
||||||
std::vector<ModelObject*> model_objects_old(std::move(m_model.objects));
|
std::vector<ModelObject*> model_objects_old(std::move(m_model.objects));
|
||||||
m_model.objects.clear();
|
m_model.objects.clear();
|
||||||
|
@ -390,7 +386,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, const DynamicPrintConf
|
||||||
if (new_instances != it_print_object_status->print_object->instances()) {
|
if (new_instances != it_print_object_status->print_object->instances()) {
|
||||||
// Instances changed.
|
// Instances changed.
|
||||||
it_print_object_status->print_object->set_instances(new_instances);
|
it_print_object_status->print_object->set_instances(new_instances);
|
||||||
update_apply_status(this->invalidate_step(slapsRasterize));
|
update_apply_status(this->invalidate_step(slapsMergeSlicesAndEval));
|
||||||
}
|
}
|
||||||
print_objects_new.emplace_back(it_print_object_status->print_object);
|
print_objects_new.emplace_back(it_print_object_status->print_object);
|
||||||
const_cast<PrintObjectStatus&>(*it_print_object_status).status = PrintObjectStatus::Reused;
|
const_cast<PrintObjectStatus&>(*it_print_object_status).status = PrintObjectStatus::Reused;
|
||||||
|
@ -613,6 +609,18 @@ std::string SLAPrint::validate() const
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SLAPrint::invalidate_step(SLAPrintStep step)
|
||||||
|
{
|
||||||
|
bool invalidated = Inherited::invalidate_step(step);
|
||||||
|
|
||||||
|
// propagate to dependent steps
|
||||||
|
if (step == slapsMergeSlicesAndEval) {
|
||||||
|
invalidated |= this->invalidate_all_steps();
|
||||||
|
}
|
||||||
|
|
||||||
|
return invalidated;
|
||||||
|
}
|
||||||
|
|
||||||
template<class...Args>
|
template<class...Args>
|
||||||
void report_status(SLAPrint& p, int st, const std::string& msg, Args&&...args)
|
void report_status(SLAPrint& p, int st, const std::string& msg, Args&&...args)
|
||||||
{
|
{
|
||||||
|
@ -639,7 +647,7 @@ void SLAPrint::process()
|
||||||
const size_t objcount = m_objects.size();
|
const size_t objcount = m_objects.size();
|
||||||
|
|
||||||
const unsigned min_objstatus = 0; // where the per object operations start
|
const unsigned min_objstatus = 0; // where the per object operations start
|
||||||
const unsigned max_objstatus = PRINT_STEP_LEVELS[slapsRasterize]; // where the per object operations end
|
const unsigned max_objstatus = PRINT_STEP_LEVELS[slapsMergeSlicesAndEval]; // where the per object operations end
|
||||||
|
|
||||||
// the coefficient that multiplies the per object status values which
|
// the coefficient that multiplies the per object status values which
|
||||||
// are set up for <0, 100>. They need to be scaled into the whole process
|
// are set up for <0, 100>. They need to be scaled into the whole process
|
||||||
|
@ -883,7 +891,7 @@ void SLAPrint::process()
|
||||||
// Slicing the support geometries similarly to the model slicing procedure.
|
// Slicing the support geometries similarly to the model slicing procedure.
|
||||||
// If the pad had been added previously (see step "base_pool" than it will
|
// If the pad had been added previously (see step "base_pool" than it will
|
||||||
// be part of the slices)
|
// be part of the slices)
|
||||||
auto slice_supports = [](SLAPrintObject& po) {
|
auto slice_supports = [this](SLAPrintObject& po) {
|
||||||
auto& sd = po.m_supportdata;
|
auto& sd = po.m_supportdata;
|
||||||
|
|
||||||
if(sd) sd->support_slices.clear();
|
if(sd) sd->support_slices.clear();
|
||||||
|
@ -906,16 +914,14 @@ void SLAPrint::process()
|
||||||
{
|
{
|
||||||
po.m_slice_index[i].set_support_slice_idx(po, i);
|
po.m_slice_index[i].set_support_slice_idx(po, i);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// We have the layer polygon collection but we need to unite them into
|
|
||||||
// an index where the key is the height level in discrete levels (clipper)
|
|
||||||
auto index_slices = [this/*, ilhd*/](SLAPrintObject& /*po*/) {
|
|
||||||
// Using RELOAD_SLA_PREVIEW to tell the Plater to pass the update status to the 3D preview to load the SLA slices.
|
// Using RELOAD_SLA_PREVIEW to tell the Plater to pass the update status to the 3D preview to load the SLA slices.
|
||||||
report_status(*this, -2, "", SlicingStatus::RELOAD_SLA_PREVIEW);
|
report_status(*this, -2, "", SlicingStatus::RELOAD_SLA_PREVIEW);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto fillstats = [this, ilhs]() {
|
// Merging the slices from all the print objects into one slice grid and
|
||||||
|
// calculating print statistics from the merge result.
|
||||||
|
auto merge_slices_and_eval_stats = [this, ilhs]() {
|
||||||
|
|
||||||
// clear the rasterizer input
|
// clear the rasterizer input
|
||||||
m_printer_input.clear();
|
m_printer_input.clear();
|
||||||
|
@ -1081,15 +1087,13 @@ void SLAPrint::process()
|
||||||
support_points,
|
support_points,
|
||||||
support_tree,
|
support_tree,
|
||||||
base_pool,
|
base_pool,
|
||||||
slice_supports,
|
slice_supports
|
||||||
index_slices
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::array<slapsFn, slapsCount> print_program =
|
std::array<slapsFn, slapsCount> print_program =
|
||||||
{
|
{
|
||||||
fillstats,
|
merge_slices_and_eval_stats,
|
||||||
rasterize,
|
rasterize
|
||||||
[](){} // validate
|
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned st = min_objstatus;
|
unsigned st = min_objstatus;
|
||||||
|
@ -1129,7 +1133,7 @@ void SLAPrint::process()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<SLAPrintStep, slapsCount> printsteps = {
|
std::array<SLAPrintStep, slapsCount> printsteps = {
|
||||||
slapsStats, slapsRasterize, slapsValidate
|
slapsMergeSlicesAndEval, slapsRasterize
|
||||||
};
|
};
|
||||||
|
|
||||||
// this would disable the rasterization step
|
// this would disable the rasterization step
|
||||||
|
@ -1195,11 +1199,11 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_opt
|
||||||
if (steps_rasterize.find(opt_key) != steps_rasterize.end()) {
|
if (steps_rasterize.find(opt_key) != steps_rasterize.end()) {
|
||||||
// These options only affect the final rasterization, or they are just notes without influence on the output,
|
// These options only affect the final rasterization, or they are just notes without influence on the output,
|
||||||
// so there is nothing to invalidate.
|
// so there is nothing to invalidate.
|
||||||
steps.emplace_back(slapsRasterize);
|
steps.emplace_back(slapsMergeSlicesAndEval);
|
||||||
} else if (steps_ignore.find(opt_key) != steps_ignore.end()) {
|
} else if (steps_ignore.find(opt_key) != steps_ignore.end()) {
|
||||||
// These steps have no influence on the output. Just ignore them.
|
// These steps have no influence on the output. Just ignore them.
|
||||||
} else if (opt_key == "initial_layer_height") {
|
} else if (opt_key == "initial_layer_height") {
|
||||||
steps.emplace_back(slapsRasterize);
|
steps.emplace_back(slapsMergeSlicesAndEval);
|
||||||
osteps.emplace_back(slaposObjectSlice);
|
osteps.emplace_back(slaposObjectSlice);
|
||||||
} else {
|
} else {
|
||||||
// All values should be covered.
|
// All values should be covered.
|
||||||
|
@ -1445,19 +1449,16 @@ bool SLAPrintObject::invalidate_step(SLAPrintObjectStep step)
|
||||||
if (step == slaposObjectSlice) {
|
if (step == slaposObjectSlice) {
|
||||||
invalidated |= this->invalidate_all_steps();
|
invalidated |= this->invalidate_all_steps();
|
||||||
} else if (step == slaposSupportPoints) {
|
} else if (step == slaposSupportPoints) {
|
||||||
invalidated |= this->invalidate_steps({ slaposSupportTree, slaposBasePool, slaposSliceSupports, slaposIndexSlices });
|
invalidated |= this->invalidate_steps({ slaposSupportTree, slaposBasePool, slaposSliceSupports });
|
||||||
invalidated |= m_print->invalidate_step(slapsRasterize);
|
invalidated |= m_print->invalidate_step(slapsMergeSlicesAndEval);
|
||||||
} else if (step == slaposSupportTree) {
|
} else if (step == slaposSupportTree) {
|
||||||
invalidated |= this->invalidate_steps({ slaposBasePool, slaposSliceSupports, slaposIndexSlices });
|
invalidated |= this->invalidate_steps({ slaposBasePool, slaposSliceSupports });
|
||||||
invalidated |= m_print->invalidate_step(slapsRasterize);
|
invalidated |= m_print->invalidate_step(slapsMergeSlicesAndEval);
|
||||||
} else if (step == slaposBasePool) {
|
} else if (step == slaposBasePool) {
|
||||||
invalidated |= this->invalidate_steps({slaposSliceSupports, slaposIndexSlices});
|
invalidated |= this->invalidate_steps({slaposSliceSupports});
|
||||||
invalidated |= m_print->invalidate_step(slapsRasterize);
|
invalidated |= m_print->invalidate_step(slapsMergeSlicesAndEval);
|
||||||
} else if (step == slaposSliceSupports) {
|
} else if (step == slaposSliceSupports) {
|
||||||
invalidated |= this->invalidate_step(slaposIndexSlices);
|
invalidated |= m_print->invalidate_step(slapsMergeSlicesAndEval);
|
||||||
invalidated |= m_print->invalidate_step(slapsRasterize);
|
|
||||||
} else if(step == slaposIndexSlices) {
|
|
||||||
invalidated |= m_print->invalidate_step(slapsRasterize);
|
|
||||||
}
|
}
|
||||||
return invalidated;
|
return invalidated;
|
||||||
}
|
}
|
||||||
|
@ -1533,18 +1534,6 @@ const ExPolygons &SliceRecord::get_slice(SliceOrigin o) const
|
||||||
return idx >= v.size() ? EMPTY_SLICE : v[idx];
|
return idx >= v.size() ? EMPTY_SLICE : v[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<SliceRecord> & SLAPrintObject::get_slice_index() const
|
|
||||||
{
|
|
||||||
// assert(is_step_done(slaposIndexSlices));
|
|
||||||
return m_slice_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<ExPolygons> &SLAPrintObject::get_model_slices() const
|
|
||||||
{
|
|
||||||
// assert(is_step_done(slaposObjectSlice));
|
|
||||||
return m_model_slices;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SLAPrintObject::has_mesh(SLAPrintObjectStep step) const
|
bool SLAPrintObject::has_mesh(SLAPrintObjectStep step) const
|
||||||
{
|
{
|
||||||
switch (step) {
|
switch (step) {
|
||||||
|
|
|
@ -11,9 +11,8 @@
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
enum SLAPrintStep : unsigned int {
|
enum SLAPrintStep : unsigned int {
|
||||||
slapsStats,
|
slapsMergeSlicesAndEval,
|
||||||
slapsRasterize,
|
slapsRasterize,
|
||||||
slapsValidate,
|
|
||||||
slapsCount
|
slapsCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@ enum SLAPrintObjectStep : unsigned int {
|
||||||
slaposSupportTree,
|
slaposSupportTree,
|
||||||
slaposBasePool,
|
slaposBasePool,
|
||||||
slaposSliceSupports,
|
slaposSliceSupports,
|
||||||
slaposIndexSlices,
|
|
||||||
slaposCount
|
slaposCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,7 +188,7 @@ private:
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<ExPolygons>& get_model_slices() const;
|
const std::vector<ExPolygons>& get_model_slices() const { return m_model_slices; }
|
||||||
const std::vector<ExPolygons>& get_support_slices() const;
|
const std::vector<ExPolygons>& get_support_slices() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -205,7 +203,9 @@ public:
|
||||||
// /////////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Retrieve the slice index.
|
// Retrieve the slice index.
|
||||||
const std::vector<SliceRecord>& get_slice_index() const;
|
const std::vector<SliceRecord>& get_slice_index() const {
|
||||||
|
return m_slice_index;
|
||||||
|
}
|
||||||
|
|
||||||
// Search slice index for the closest slice to given print_level.
|
// Search slice index for the closest slice to given print_level.
|
||||||
// max_epsilon gives the allowable deviation of the returned slice record's
|
// max_epsilon gives the allowable deviation of the returned slice record's
|
||||||
|
@ -383,7 +383,7 @@ public:
|
||||||
// Returns true if an object step is done on all objects and there's at least one object.
|
// 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;
|
bool is_step_done(SLAPrintObjectStep step) const;
|
||||||
// Returns true if the last step was finished with success.
|
// Returns true if the last step was finished with success.
|
||||||
bool finished() const override { return this->is_step_done(slaposIndexSlices) && this->Inherited::is_step_done(slapsRasterize); }
|
bool finished() const override { return this->is_step_done(slaposSliceSupports) && this->Inherited::is_step_done(slapsRasterize); }
|
||||||
|
|
||||||
template<class Fmt> void export_raster(const std::string& fname) {
|
template<class Fmt> void export_raster(const std::string& fname) {
|
||||||
if(m_printer) m_printer->save<Fmt>(fname);
|
if(m_printer) m_printer->save<Fmt>(fname);
|
||||||
|
@ -409,6 +409,9 @@ private:
|
||||||
using SLAPrinter = FilePrinter<FilePrinterFormat::SLA_PNGZIP>;
|
using SLAPrinter = FilePrinter<FilePrinterFormat::SLA_PNGZIP>;
|
||||||
using SLAPrinterPtr = std::unique_ptr<SLAPrinter>;
|
using SLAPrinterPtr = std::unique_ptr<SLAPrinter>;
|
||||||
|
|
||||||
|
// Implement same logic as in SLAPrintObject
|
||||||
|
bool invalidate_step(SLAPrintStep st);
|
||||||
|
|
||||||
// Invalidate steps based on a set of parameters changed.
|
// Invalidate steps based on a set of parameters changed.
|
||||||
bool invalidate_state_by_config_options(const std::vector<t_config_option_key> &opt_keys);
|
bool invalidate_state_by_config_options(const std::vector<t_config_option_key> &opt_keys);
|
||||||
|
|
||||||
|
|
|
@ -5010,7 +5010,7 @@ void GLCanvas3D::_render_sla_slices() const
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bottom_obj_triangles.empty() || bottom_sup_triangles.empty() || top_obj_triangles.empty() || top_sup_triangles.empty()) &&
|
if ((bottom_obj_triangles.empty() || bottom_sup_triangles.empty() || top_obj_triangles.empty() || top_sup_triangles.empty()) &&
|
||||||
obj->is_step_done(slaposIndexSlices) && !obj->get_slice_index().empty())
|
obj->is_step_done(slaposSliceSupports) && !obj->get_slice_index().empty())
|
||||||
{
|
{
|
||||||
double layer_height = print->default_object_config().layer_height.value;
|
double layer_height = print->default_object_config().layer_height.value;
|
||||||
double initial_layer_height = print->material_config().initial_layer_height.value;
|
double initial_layer_height = print->material_config().initial_layer_height.value;
|
||||||
|
@ -6212,7 +6212,7 @@ void GLCanvas3D::_load_shells_sla()
|
||||||
int obj_idx = 0;
|
int obj_idx = 0;
|
||||||
for (const SLAPrintObject* obj : print->objects())
|
for (const SLAPrintObject* obj : print->objects())
|
||||||
{
|
{
|
||||||
if (!obj->is_step_done(slaposIndexSlices))
|
if (!obj->is_step_done(slaposSliceSupports))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
unsigned int initial_volumes_count = (unsigned int)m_volumes.volumes.size();
|
unsigned int initial_volumes_count = (unsigned int)m_volumes.volumes.size();
|
||||||
|
|
|
@ -772,7 +772,7 @@ void Preview::load_print_as_sla()
|
||||||
std::vector<double> zs;
|
std::vector<double> zs;
|
||||||
double initial_layer_height = print->material_config().initial_layer_height.value;
|
double initial_layer_height = print->material_config().initial_layer_height.value;
|
||||||
for (const SLAPrintObject* obj : print->objects())
|
for (const SLAPrintObject* obj : print->objects())
|
||||||
if (obj->is_step_done(slaposIndexSlices) && !obj->get_slice_index().empty())
|
if (obj->is_step_done(slaposSliceSupports) && !obj->get_slice_index().empty())
|
||||||
{
|
{
|
||||||
auto low_coord = obj->get_slice_index().front().print_level();
|
auto low_coord = obj->get_slice_index().front().print_level();
|
||||||
for (auto& rec : obj->get_slice_index())
|
for (auto& rec : obj->get_slice_index())
|
||||||
|
|
Loading…
Reference in a new issue