mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Integrating new step, removing old and unused steps.
This commit is contained in:
		
							parent
							
								
									34094bf1b8
								
							
						
					
					
						commit
						bc74761513
					
				
					 4 changed files with 50 additions and 58 deletions
				
			
		| 
						 | 
				
			
			@ -43,8 +43,7 @@ const std::array<unsigned, slaposCount>     OBJ_STEP_LEVELS =
 | 
			
		|||
    30,     // slaposSupportPoints,
 | 
			
		||||
    25,     // slaposSupportTree,
 | 
			
		||||
    25,     // slaposBasePool,
 | 
			
		||||
    5,      // slaposSliceSupports,
 | 
			
		||||
    5       // slaposIndexSlices
 | 
			
		||||
    10,      // slaposSliceSupports,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
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 pad"),                // slaposBasePool,
 | 
			
		||||
    L("Slicing supports"),              // slaposSliceSupports,
 | 
			
		||||
    L("Slicing supports")               // slaposIndexSlices,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Should also add up to 100 (%)
 | 
			
		||||
const std::array<unsigned, slapsCount> PRINT_STEP_LEVELS =
 | 
			
		||||
{
 | 
			
		||||
    5,      // slapsStats
 | 
			
		||||
    94,     // slapsRasterize
 | 
			
		||||
    1,      // slapsValidate
 | 
			
		||||
    95,     // slapsRasterize
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
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("Validating"),                 // slapsValidate
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -206,7 +202,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, const DynamicPrintConf
 | 
			
		|||
                model_object_status.emplace(model_object->id(), ModelObjectStatus::Old);
 | 
			
		||||
        } else if (model_object_list_extended(m_model, model)) {
 | 
			
		||||
            // 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)
 | 
			
		||||
                model_object_status.emplace(model_object->id(), ModelObjectStatus::Old);
 | 
			
		||||
            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.
 | 
			
		||||
            // First stop background processing before shuffling or deleting the PrintObjects in the object list.
 | 
			
		||||
            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.
 | 
			
		||||
            std::vector<ModelObject*> model_objects_old(std::move(m_model.objects));
 | 
			
		||||
            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()) {
 | 
			
		||||
					// Instances changed.
 | 
			
		||||
					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);
 | 
			
		||||
				const_cast<PrintObjectStatus&>(*it_print_object_status).status = PrintObjectStatus::Reused;
 | 
			
		||||
| 
						 | 
				
			
			@ -613,6 +609,18 @@ std::string SLAPrint::validate() const
 | 
			
		|||
    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>
 | 
			
		||||
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 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
 | 
			
		||||
    // 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.
 | 
			
		||||
    // If the pad had been added previously (see step "base_pool" than it will
 | 
			
		||||
    // be part of the slices)
 | 
			
		||||
    auto slice_supports = [](SLAPrintObject& po) {
 | 
			
		||||
    auto slice_supports = [this](SLAPrintObject& po) {
 | 
			
		||||
        auto& sd = po.m_supportdata;
 | 
			
		||||
 | 
			
		||||
        if(sd) sd->support_slices.clear();
 | 
			
		||||
| 
						 | 
				
			
			@ -906,16 +914,14 @@ void SLAPrint::process()
 | 
			
		|||
        {
 | 
			
		||||
            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.
 | 
			
		||||
        report_status(*this, -2, "", SlicingStatus::RELOAD_SLA_PREVIEW);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    auto fillstats = [this]() {
 | 
			
		||||
    // 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]() {
 | 
			
		||||
 | 
			
		||||
        m_print_statistics.clear();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1079,15 +1085,13 @@ void SLAPrint::process()
 | 
			
		|||
        support_points,
 | 
			
		||||
        support_tree,
 | 
			
		||||
        base_pool,
 | 
			
		||||
        slice_supports,
 | 
			
		||||
        index_slices
 | 
			
		||||
        slice_supports
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    std::array<slapsFn, slapsCount> print_program =
 | 
			
		||||
    {
 | 
			
		||||
        fillstats,
 | 
			
		||||
        rasterize,
 | 
			
		||||
        [](){}  // validate
 | 
			
		||||
        merge_slices_and_eval_stats,
 | 
			
		||||
        rasterize
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    unsigned st = min_objstatus;
 | 
			
		||||
| 
						 | 
				
			
			@ -1127,7 +1131,7 @@ void SLAPrint::process()
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    std::array<SLAPrintStep, slapsCount> printsteps = {
 | 
			
		||||
        slapsStats, slapsRasterize, slapsValidate
 | 
			
		||||
        slapsMergeSlicesAndEval, slapsRasterize
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // this would disable the rasterization step
 | 
			
		||||
| 
						 | 
				
			
			@ -1193,11 +1197,11 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_opt
 | 
			
		|||
        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,
 | 
			
		||||
            // so there is nothing to invalidate.
 | 
			
		||||
            steps.emplace_back(slapsRasterize);
 | 
			
		||||
            steps.emplace_back(slapsMergeSlicesAndEval);
 | 
			
		||||
        } else if (steps_ignore.find(opt_key) != steps_ignore.end()) {
 | 
			
		||||
            // These steps have no influence on the output. Just ignore them.
 | 
			
		||||
        } else if (opt_key == "initial_layer_height") {
 | 
			
		||||
            steps.emplace_back(slapsRasterize);
 | 
			
		||||
            steps.emplace_back(slapsMergeSlicesAndEval);
 | 
			
		||||
            osteps.emplace_back(slaposObjectSlice);
 | 
			
		||||
        } else {
 | 
			
		||||
            // All values should be covered.
 | 
			
		||||
| 
						 | 
				
			
			@ -1459,19 +1463,16 @@ bool SLAPrintObject::invalidate_step(SLAPrintObjectStep step)
 | 
			
		|||
    if (step == slaposObjectSlice) {
 | 
			
		||||
        invalidated |= this->invalidate_all_steps();
 | 
			
		||||
    } else if (step == slaposSupportPoints) {
 | 
			
		||||
        invalidated |= this->invalidate_steps({ slaposSupportTree, slaposBasePool, slaposSliceSupports, slaposIndexSlices });
 | 
			
		||||
        invalidated |= m_print->invalidate_step(slapsRasterize);
 | 
			
		||||
        invalidated |= this->invalidate_steps({ slaposSupportTree, slaposBasePool, slaposSliceSupports });
 | 
			
		||||
        invalidated |= m_print->invalidate_step(slapsMergeSlicesAndEval);
 | 
			
		||||
    } else if (step == slaposSupportTree) {
 | 
			
		||||
        invalidated |= this->invalidate_steps({ slaposBasePool, slaposSliceSupports, slaposIndexSlices });
 | 
			
		||||
        invalidated |= m_print->invalidate_step(slapsRasterize);
 | 
			
		||||
        invalidated |= this->invalidate_steps({ slaposBasePool, slaposSliceSupports });
 | 
			
		||||
        invalidated |= m_print->invalidate_step(slapsMergeSlicesAndEval);
 | 
			
		||||
    } else if (step == slaposBasePool) {
 | 
			
		||||
        invalidated |= this->invalidate_steps({slaposSliceSupports, slaposIndexSlices});
 | 
			
		||||
        invalidated |= m_print->invalidate_step(slapsRasterize);
 | 
			
		||||
        invalidated |= this->invalidate_steps({slaposSliceSupports});
 | 
			
		||||
        invalidated |= m_print->invalidate_step(slapsMergeSlicesAndEval);
 | 
			
		||||
    } else if (step == slaposSliceSupports) {
 | 
			
		||||
        invalidated |= this->invalidate_step(slaposIndexSlices);
 | 
			
		||||
        invalidated |= m_print->invalidate_step(slapsRasterize);
 | 
			
		||||
    } else if(step == slaposIndexSlices) {
 | 
			
		||||
        invalidated |= m_print->invalidate_step(slapsRasterize);
 | 
			
		||||
        invalidated |= m_print->invalidate_step(slapsMergeSlicesAndEval);
 | 
			
		||||
    }
 | 
			
		||||
    return invalidated;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1547,18 +1548,6 @@ const ExPolygons &SliceRecord::get_slice(SliceOrigin o) const
 | 
			
		|||
    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
 | 
			
		||||
{
 | 
			
		||||
    switch (step) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,9 +11,8 @@
 | 
			
		|||
namespace Slic3r {
 | 
			
		||||
 | 
			
		||||
enum SLAPrintStep : unsigned int {
 | 
			
		||||
    slapsStats,
 | 
			
		||||
	slapsRasterize,
 | 
			
		||||
	slapsValidate,
 | 
			
		||||
    slapsMergeSlicesAndEval,
 | 
			
		||||
    slapsRasterize,
 | 
			
		||||
	slapsCount
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -22,8 +21,7 @@ enum SLAPrintObjectStep : unsigned int {
 | 
			
		|||
	slaposSupportPoints,
 | 
			
		||||
	slaposSupportTree,
 | 
			
		||||
	slaposBasePool,
 | 
			
		||||
	slaposSliceSupports,
 | 
			
		||||
    slaposIndexSlices,
 | 
			
		||||
    slaposSliceSupports,
 | 
			
		||||
	slaposCount
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +188,7 @@ private:
 | 
			
		|||
        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;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
| 
						 | 
				
			
			@ -205,7 +203,9 @@ public:
 | 
			
		|||
    // /////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
    // 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.
 | 
			
		||||
    // max_epsilon gives the allowable deviation of the returned slice record's
 | 
			
		||||
| 
						 | 
				
			
			@ -370,7 +370,7 @@ public:
 | 
			
		|||
    // 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.
 | 
			
		||||
	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) {
 | 
			
		||||
        if(m_printer) m_printer->save<Fmt>(fname);
 | 
			
		||||
| 
						 | 
				
			
			@ -396,6 +396,9 @@ private:
 | 
			
		|||
    using SLAPrinter = FilePrinter<FilePrinterFormat::SLA_PNGZIP>;
 | 
			
		||||
    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.
 | 
			
		||||
    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()) &&
 | 
			
		||||
            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 initial_layer_height = print->material_config().initial_layer_height.value;
 | 
			
		||||
| 
						 | 
				
			
			@ -6212,7 +6212,7 @@ void GLCanvas3D::_load_shells_sla()
 | 
			
		|||
    int obj_idx = 0;
 | 
			
		||||
    for (const SLAPrintObject* obj : print->objects())
 | 
			
		||||
    {
 | 
			
		||||
        if (!obj->is_step_done(slaposIndexSlices))
 | 
			
		||||
        if (!obj->is_step_done(slaposSliceSupports))
 | 
			
		||||
            continue;
 | 
			
		||||
 | 
			
		||||
        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;
 | 
			
		||||
    double initial_layer_height = print->material_config().initial_layer_height.value;
 | 
			
		||||
    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();
 | 
			
		||||
            for (auto& rec : obj->get_slice_index())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue