ENH: optimize speed of gcode export

Signed-off-by: salt.wei <salt.wei@bambulab.com>
Change-Id: Ic641352623f26c7241ae5720ad1baa202a1b00c7
This commit is contained in:
salt.wei 2023-03-02 20:30:47 +08:00 committed by Lane.Wei
parent 3448b7a053
commit 8669291aad
3 changed files with 30 additions and 1 deletions

View file

@ -33,6 +33,8 @@ public:
// collection of surfaces generated by slicing the original geometry
// divided by type top/bottom/internal
SurfaceCollection slices;
//BBS: simplifed final slices data to accelerate
SurfaceCollection slices_simplified;
// Backed up slices before they are split into top/bottom/internal.
// Only backed up for multi-region layers or layers with elephant foot compensation.
//FIXME Review whether not to simplify the code by keeping the raw_slices all the time.
@ -73,6 +75,8 @@ public:
void slices_to_fill_surfaces_clipped();
void prepare_fill_surfaces();
//BBS
inline void simplify_final_slices() { this->slices_simplified.set(this->slices); this->slices_simplified.simplify(scaled(SIMPLIFY_SLICES_RESOLUTION));}
//BBS
void make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces, ExPolygons* fill_no_overlap);
void process_external_surfaces(const Layer *lower_layer, const Polygons *lower_layer_covered);
double infill_area_threshold() const;
@ -166,6 +170,11 @@ public:
for (const LayerRegion *layerm : m_regions) if (layerm->slices.any_internal_contains(item)) return true;
return false;
}
//BBS: only be used in gcode export when reduce_infill_retraction is enabled
template <class T> bool any_internal_region_slmplify_slice_contains(const T& item) const {
for (const LayerRegion* layerm : m_regions) if (layerm->slices_simplified.any_internal_contains(item)) return true;
return false;
}
template <class T> bool any_bottom_region_slice_contains(const T &item) const {
for (const LayerRegion *layerm : m_regions) if (layerm->slices.any_bottom_contains(item)) return true;
return false;
@ -189,6 +198,8 @@ public:
void simplify_extrusion_path() { for (auto layerm : m_regions) layerm->simplify_extrusion_entity();}
//BBS: this function calculate the maximum void grid area of sparse infill of this layer. Just estimated value
coordf_t get_sparse_infill_max_void_area();
//BBS
inline void simplify_reagon_final_slices() { for (auto* region : this->m_regions) region->simplify_final_slices();}
protected:
friend class PrintObject;