FIX: crash when change infill pattern
1. Fix crash when change infill pattern. Now change infill pattern will influence prepare infill 2. Remove with loop param, no longer use now jira:NEW Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: Ibee8808e462bd418d83b7e5781dd2bc5cc772eb1
This commit is contained in:
parent
6b47046fc8
commit
385e7ffe3e
|
@ -47,8 +47,6 @@ struct SurfaceFillParams
|
||||||
float anchor_length = 1000.f;
|
float anchor_length = 1000.f;
|
||||||
float anchor_length_max = 1000.f;
|
float anchor_length_max = 1000.f;
|
||||||
//BBS
|
//BBS
|
||||||
bool with_loop = false;
|
|
||||||
|
|
||||||
// width, height of extrusion, nozzle diameter, is bridge
|
// width, height of extrusion, nozzle diameter, is bridge
|
||||||
// For the output, for fill generator.
|
// For the output, for fill generator.
|
||||||
Flow flow;
|
Flow flow;
|
||||||
|
@ -82,7 +80,6 @@ struct SurfaceFillParams
|
||||||
// RETURN_COMPARE_NON_EQUAL_TYPED(unsigned, dont_adjust);
|
// RETURN_COMPARE_NON_EQUAL_TYPED(unsigned, dont_adjust);
|
||||||
RETURN_COMPARE_NON_EQUAL(anchor_length);
|
RETURN_COMPARE_NON_EQUAL(anchor_length);
|
||||||
RETURN_COMPARE_NON_EQUAL(anchor_length_max);
|
RETURN_COMPARE_NON_EQUAL(anchor_length_max);
|
||||||
RETURN_COMPARE_NON_EQUAL(with_loop);
|
|
||||||
RETURN_COMPARE_NON_EQUAL(flow.width());
|
RETURN_COMPARE_NON_EQUAL(flow.width());
|
||||||
RETURN_COMPARE_NON_EQUAL(flow.height());
|
RETURN_COMPARE_NON_EQUAL(flow.height());
|
||||||
RETURN_COMPARE_NON_EQUAL(flow.nozzle_diameter());
|
RETURN_COMPARE_NON_EQUAL(flow.nozzle_diameter());
|
||||||
|
@ -107,7 +104,6 @@ struct SurfaceFillParams
|
||||||
// this->dont_adjust == rhs.dont_adjust &&
|
// this->dont_adjust == rhs.dont_adjust &&
|
||||||
this->anchor_length == rhs.anchor_length &&
|
this->anchor_length == rhs.anchor_length &&
|
||||||
this->anchor_length_max == rhs.anchor_length_max &&
|
this->anchor_length_max == rhs.anchor_length_max &&
|
||||||
this->with_loop == rhs.with_loop &&
|
|
||||||
this->flow == rhs.flow &&
|
this->flow == rhs.flow &&
|
||||||
this->extrusion_role == rhs.extrusion_role &&
|
this->extrusion_role == rhs.extrusion_role &&
|
||||||
this->sparse_infill_speed == rhs.sparse_infill_speed &&
|
this->sparse_infill_speed == rhs.sparse_infill_speed &&
|
||||||
|
@ -161,8 +157,6 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||||
params.extruder = layerm.region().extruder(extrusion_role);
|
params.extruder = layerm.region().extruder(extrusion_role);
|
||||||
params.pattern = region_config.sparse_infill_pattern.value;
|
params.pattern = region_config.sparse_infill_pattern.value;
|
||||||
params.density = float(region_config.sparse_infill_density);
|
params.density = float(region_config.sparse_infill_density);
|
||||||
//BBS
|
|
||||||
params.with_loop = surface.surface_type == stInternalWithLoop;
|
|
||||||
|
|
||||||
if (surface.is_solid()) {
|
if (surface.is_solid()) {
|
||||||
params.density = 100.f;
|
params.density = 100.f;
|
||||||
|
@ -193,7 +187,7 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||||
layerm.bridging_flow(extrusion_role, (surface.is_bridge() && !surface.is_external()) || object_config.thick_bridges) :
|
layerm.bridging_flow(extrusion_role, (surface.is_bridge() && !surface.is_external()) || object_config.thick_bridges) :
|
||||||
layerm.flow(extrusion_role, (surface.thickness == -1) ? layer.height : surface.thickness);
|
layerm.flow(extrusion_role, (surface.thickness == -1) ? layer.height : surface.thickness);
|
||||||
//BBS: record speed params
|
//BBS: record speed params
|
||||||
if (!params.with_loop && !params.bridge) {
|
if (!params.bridge) {
|
||||||
if (params.extrusion_role == erInternalInfill)
|
if (params.extrusion_role == erInternalInfill)
|
||||||
params.sparse_infill_speed = region_config.sparse_infill_speed;
|
params.sparse_infill_speed = region_config.sparse_infill_speed;
|
||||||
else if (params.extrusion_role == erTopSolidInfill)
|
else if (params.extrusion_role == erTopSolidInfill)
|
||||||
|
@ -497,7 +491,6 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
|
||||||
params.extrusion_role = surface_fill.params.extrusion_role;
|
params.extrusion_role = surface_fill.params.extrusion_role;
|
||||||
params.using_internal_flow = using_internal_flow;
|
params.using_internal_flow = using_internal_flow;
|
||||||
params.no_extrusion_overlap = surface_fill.params.overlap;
|
params.no_extrusion_overlap = surface_fill.params.overlap;
|
||||||
params.with_loop = surface_fill.params.with_loop;
|
|
||||||
if (surface_fill.params.pattern == ipGrid)
|
if (surface_fill.params.pattern == ipGrid)
|
||||||
params.can_reverse = false;
|
params.can_reverse = false;
|
||||||
LayerRegion* layerm = this->m_regions[surface_fill.region_id];
|
LayerRegion* layerm = this->m_regions[surface_fill.region_id];
|
||||||
|
@ -774,7 +767,7 @@ void Layer::make_ironing()
|
||||||
// Check whether there is any non-solid hole in the regions.
|
// Check whether there is any non-solid hole in the regions.
|
||||||
bool internal_infill_solid = region_config.sparse_infill_density.value > 95.;
|
bool internal_infill_solid = region_config.sparse_infill_density.value > 95.;
|
||||||
for (const Surface &surface : ironing_params.layerm->fill_surfaces.surfaces)
|
for (const Surface &surface : ironing_params.layerm->fill_surfaces.surfaces)
|
||||||
if ((!internal_infill_solid && surface.surface_type == stInternal) || surface.surface_type == stInternalBridge || surface.surface_type == stInternalVoid || surface.surface_type==stInternalWithLoop) {
|
if ((!internal_infill_solid && surface.surface_type == stInternal) || surface.surface_type == stInternalBridge || surface.surface_type == stInternalVoid) {
|
||||||
// Some fill region is not quite solid. Don't iron over the whole surface.
|
// Some fill region is not quite solid. Don't iron over the whole surface.
|
||||||
iron_completely = false;
|
iron_completely = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -115,57 +115,14 @@ void Fill::fill_surface_extrusion(const Surface* surface, const FillParams& para
|
||||||
{
|
{
|
||||||
Polylines polylines;
|
Polylines polylines;
|
||||||
ThickPolylines thick_polylines;
|
ThickPolylines thick_polylines;
|
||||||
if (!params.with_loop) {
|
|
||||||
try {
|
|
||||||
if (params.use_arachne)
|
|
||||||
thick_polylines = this->fill_surface_arachne(surface, params);
|
|
||||||
else
|
|
||||||
polylines = this->fill_surface(surface, params);
|
|
||||||
}
|
|
||||||
catch (InfillFailedException&) {}
|
|
||||||
}
|
|
||||||
//BBS: add handling for infill pattern with loop
|
|
||||||
else {
|
|
||||||
Slic3r::ExPolygons expp = offset_ex(surface->expolygon, float(scale_(this->overlap - 0.5 * this->spacing)));
|
|
||||||
Polylines loop_polylines = to_polylines(expp);
|
|
||||||
{
|
|
||||||
//BBS: clip the loop
|
|
||||||
size_t j = 0;
|
|
||||||
for (size_t i = 0; i < loop_polylines.size(); ++i) {
|
|
||||||
loop_polylines[i].clip_end(this->loop_clipping);
|
|
||||||
if (loop_polylines[i].is_valid()) {
|
|
||||||
if (j < i)
|
|
||||||
loop_polylines[j] = std::move(loop_polylines[i]);
|
|
||||||
++j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (j < loop_polylines.size())
|
|
||||||
loop_polylines.erase(loop_polylines.begin() + int(j), loop_polylines.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!loop_polylines.empty()) {
|
try {
|
||||||
if (params.use_arachne)
|
if (params.use_arachne)
|
||||||
append(thick_polylines, to_thick_polylines(std::move(loop_polylines), scaled<coord_t>(this->spacing)));
|
thick_polylines = this->fill_surface_arachne(surface, params);
|
||||||
else
|
else
|
||||||
append(polylines, std::move(loop_polylines));
|
polylines = this->fill_surface(surface, params);
|
||||||
expp = offset_ex(expp, float(scale_(0 - 0.5 * this->spacing)));
|
|
||||||
} else {
|
|
||||||
//BBS: the area is too narrow to place a loop, return to original expolygon
|
|
||||||
expp = { surface->expolygon };
|
|
||||||
}
|
|
||||||
|
|
||||||
Surface temp_surface = *surface;
|
|
||||||
for (ExPolygon& ex : expp) {
|
|
||||||
temp_surface.expolygon = ex;
|
|
||||||
try {
|
|
||||||
if (params.use_arachne)
|
|
||||||
append(thick_polylines, std::move(this->fill_surface_arachne(&temp_surface, params)));
|
|
||||||
else
|
|
||||||
append(polylines, std::move(this->fill_surface(&temp_surface, params)));
|
|
||||||
}
|
|
||||||
catch (InfillFailedException&) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (InfillFailedException&) {}
|
||||||
|
|
||||||
if (!polylines.empty() || !thick_polylines.empty()) {
|
if (!polylines.empty() || !thick_polylines.empty()) {
|
||||||
// calculate actual flow from spacing (which might have been adjusted by the infill
|
// calculate actual flow from spacing (which might have been adjusted by the infill
|
||||||
|
|
|
@ -67,8 +67,6 @@ struct FillParams
|
||||||
bool use_arachne{ false };
|
bool use_arachne{ false };
|
||||||
// Layer height for Concentric infill with Arachne.
|
// Layer height for Concentric infill with Arachne.
|
||||||
coordf_t layer_height { 0.f };
|
coordf_t layer_height { 0.f };
|
||||||
//BBS
|
|
||||||
bool with_loop { false };
|
|
||||||
|
|
||||||
// BBS
|
// BBS
|
||||||
Flow flow;
|
Flow flow;
|
||||||
|
|
|
@ -848,14 +848,7 @@ bool PrintObject::invalidate_state_by_config_options(
|
||||||
|| opt_key == "initial_layer_line_width") {
|
|| opt_key == "initial_layer_line_width") {
|
||||||
steps.emplace_back(posInfill);
|
steps.emplace_back(posInfill);
|
||||||
} else if (opt_key == "sparse_infill_pattern") {
|
} else if (opt_key == "sparse_infill_pattern") {
|
||||||
steps.emplace_back(posInfill);
|
steps.emplace_back(posPrepareInfill);
|
||||||
const auto *old_fill_pattern = old_config.option<ConfigOptionEnum<InfillPattern>>(opt_key);
|
|
||||||
const auto *new_fill_pattern = new_config.option<ConfigOptionEnum<InfillPattern>>(opt_key);
|
|
||||||
assert(old_fill_pattern && new_fill_pattern);
|
|
||||||
// We need to recalculate infill surfaces when infill_only_where_needed is enabled, and we are switching from
|
|
||||||
// the Lightning infill to another infill or vice versa.
|
|
||||||
if (PrintObject::infill_only_where_needed && (new_fill_pattern->value == ipLightning || old_fill_pattern->value == ipLightning))
|
|
||||||
steps.emplace_back(posPrepareInfill);
|
|
||||||
} else if (opt_key == "sparse_infill_density") {
|
} else if (opt_key == "sparse_infill_density") {
|
||||||
// One likely wants to reslice only when switching between zero infill to simulate boolean difference (subtracting volumes),
|
// One likely wants to reslice only when switching between zero infill to simulate boolean difference (subtracting volumes),
|
||||||
// normal infill and 100% (solid) infill.
|
// normal infill and 100% (solid) infill.
|
||||||
|
|
|
@ -15,8 +15,6 @@ enum SurfaceType {
|
||||||
stBottomBridge,
|
stBottomBridge,
|
||||||
// Normal sparse infill.
|
// Normal sparse infill.
|
||||||
stInternal,
|
stInternal,
|
||||||
// Normal sparse infill.
|
|
||||||
stInternalWithLoop,
|
|
||||||
// Full infill, supporting the top surfaces and/or defining the verticall wall thickness.
|
// Full infill, supporting the top surfaces and/or defining the verticall wall thickness.
|
||||||
stInternalSolid,
|
stInternalSolid,
|
||||||
// 1st layer of dense infill over sparse infill, printed with a bridging extrusion flow.
|
// 1st layer of dense infill over sparse infill, printed with a bridging extrusion flow.
|
||||||
|
|
|
@ -45,9 +45,9 @@ void SurfaceCollection::group(std::vector<SurfacesPtr> *retval)
|
||||||
SurfacesPtr SurfaceCollection::filter_by_type(const SurfaceType type)
|
SurfacesPtr SurfaceCollection::filter_by_type(const SurfaceType type)
|
||||||
{
|
{
|
||||||
SurfacesPtr ss;
|
SurfacesPtr ss;
|
||||||
for (Surfaces::iterator surface = this->surfaces.begin(); surface != this->surfaces.end(); ++surface) {
|
for (Surface &surface : this->surfaces)
|
||||||
if (surface->surface_type == type) ss.push_back(&*surface);
|
if (surface.surface_type == type)
|
||||||
}
|
ss.push_back(&surface);
|
||||||
return ss;
|
return ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue