add ironing_pattern "Concentric"

This commit is contained in:
Wang YB
2024-05-03 15:14:02 +08:00
parent a2ddbe8eb4
commit e768b990a8
6 changed files with 61 additions and 12 deletions

View File

@@ -991,6 +991,8 @@ void Layer::make_ironing()
// First classify regions based on the extruder used.
struct IroningParams {
//w33
InfillPattern pattern;
int extruder = -1;
bool just_infill = false;
// Spacing of the ironing lines, also to calculate the extrusion flow from.
@@ -1031,7 +1033,9 @@ void Layer::make_ironing()
bool operator==(const IroningParams &rhs) const {
return this->extruder == rhs.extruder && this->just_infill == rhs.just_infill &&
this->line_spacing == rhs.line_spacing && this->height == rhs.height && this->speed == rhs.speed &&
this->angle == rhs.angle;
this->angle == rhs.angle
//w33
&& this->pattern == rhs.pattern;
}
LayerRegion *layerm;
@@ -1081,27 +1085,46 @@ void Layer::make_ironing()
ironing_params.angle = config.fill_angle * M_PI / 180.;
ironing_params.layerm = layerm;
ironing_params.region_id = region_id;
//w33
ironing_params.pattern = config.ironing_pattern;
by_extruder.emplace_back(ironing_params);
}
}
std::sort(by_extruder.begin(), by_extruder.end());
FillRectilinear fill;
//w33
//FillRectilinear fill;
FillParams fill_params;
fill.set_bounding_box(this->object()->bounding_box());
//fill.set_bounding_box(this->object()->bounding_box());
// Layer ID is used for orienting the infill in alternating directions.
// Layer::id() returns layer ID including raft layers, subtract them to make the infill direction independent
// from raft.
//FIXME ironing does not take fill angle into account. Shall it? Does it matter?
fill.layer_id = this->id() - this->object()->get_layer(0)->id();
fill.z = this->print_z;
fill.overlap = 0;
//fill.layer_id = this->id() - this->object()->get_layer(0)->id();
//fill.z = this->print_z;
//fill.overlap = 0;
fill_params.density = 1.;
fill_params.monotonic = true;
InfillPattern f_pattern = ipRectilinear;
std::unique_ptr<Fill> f = std::unique_ptr<Fill>(Fill::new_from_type(f_pattern));
f->set_bounding_box(this->object()->bounding_box());
f->layer_id = this->id();
f->z = this->print_z;
f->overlap = 0;
for (size_t i = 0; i < by_extruder.size();) {
// Find span of regions equivalent to the ironing operation.
IroningParams &ironing_params = by_extruder[i];
//w33
if (f_pattern != ironing_params.pattern) {
f_pattern = ironing_params.pattern;
f = std::unique_ptr<Fill>(Fill::new_from_type(f_pattern));
f->set_bounding_box(this->object()->bounding_box());
f->layer_id = this->id();
f->z = this->print_z;
f->overlap = 0;
}
size_t j = i;
for (++ j; j < by_extruder.size() && ironing_params == by_extruder[j]; ++ j) ;
@@ -1163,10 +1186,15 @@ void Layer::make_ironing()
}
// Create the filler object.
fill.spacing = ironing_params.line_spacing;
fill.angle = float(ironing_params.angle + 0.25 * M_PI);
fill.link_max_length = (coord_t)scale_(3. * fill.spacing);
double extrusion_height = ironing_params.height * fill.spacing / nozzle_dmr;
//w33
//fill.spacing = ironing_params.line_spacing;
//fill.angle = float(ironing_params.angle + 0.25 * M_PI);
//fill.link_max_length = (coord_t)scale_(3. * fill.spacing);
//double extrusion_height = ironing_params.height * fill.spacing / nozzle_dmr;
f->spacing = ironing_params.line_spacing;
f->angle = float(ironing_params.angle + 0.25 * M_PI);
f->link_max_length = (coord_t) scale_(3. * f->spacing);
double extrusion_height = ironing_params.height * f->spacing / nozzle_dmr;
float extrusion_width = Flow::rounded_rectangle_extrusion_width_from_spacing(float(nozzle_dmr), float(extrusion_height));
double flow_mm3_per_mm = nozzle_dmr * extrusion_height;
Surface surface_fill(stTop, ExPolygon());
@@ -1175,7 +1203,9 @@ void Layer::make_ironing()
Polylines polylines;
try {
assert(!fill_params.use_arachne);
polylines = fill.fill_surface(&surface_fill, fill_params);
//w33
//polylines = fill.fill_surface(&surface_fill, fill_params);
polylines = f->fill_surface(&surface_fill, fill_params);
} catch (InfillFailedException &) {
}
if (! polylines.empty()) {

View File

@@ -495,6 +495,8 @@ static std::vector<std::string> s_Preset_print_options {
,"top_solid_infill_flow_ratio", "bottom_solid_infill_flow_ratio"
//w31
,"make_overhang_printable", "make_overhang_printable_angle", "make_overhang_printable_hole_size"
//w33
,"ironing_pattern"
};
static std::vector<std::string> s_Preset_filament_options {

View File

@@ -1898,6 +1898,18 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<IroningType>(IroningType::TopSurfaces));
//w33
def = this->add("ironing_pattern", coEnum);
def->label = L("Ironing Pattern");
def->category = L("Ironing");
def->tooltip = L("Ironing Type");
def->set_enum<InfillPattern>({
{ "concentric", L("Concentric") },
{ "zig-za", L("Rectilinear") }
});
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<InfillPattern>(ipRectilinear));
def = this->add("ironing_flowrate", coPercent);
def->label = L("Flow rate");
def->category = L("Ironing");

View File

@@ -650,6 +650,8 @@ PRINT_CONFIG_CLASS_DEFINE(
// Ironing options
((ConfigOptionBool, ironing))
((ConfigOptionEnum<IroningType>, ironing_type))
//w33
((ConfigOptionEnum<InfillPattern>, ironing_pattern))
((ConfigOptionPercent, ironing_flowrate))
((ConfigOptionFloat, ironing_spacing))
((ConfigOptionFloat, ironing_speed))

View File

@@ -342,7 +342,8 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
toggle_field(el, have_raft);
bool has_ironing = config->opt_bool("ironing");
for (auto el : { "ironing_type", "ironing_flowrate", "ironing_spacing", "ironing_speed" })
//w33
for (auto el : {"ironing_type", "ironing_flowrate", "ironing_spacing", "ironing_speed", "ironing_pattern"})
toggle_field(el, has_ironing);
bool have_sequential_printing = config->opt_bool("complete_objects");

View File

@@ -1498,7 +1498,9 @@ void TabPrint::build()
optgroup = page->new_optgroup(L("Ironing"));
category_path = "ironing_177488#";
optgroup->append_single_option_line("ironing", category_path);
//w33
optgroup->append_single_option_line("ironing_type", category_path + "ironing-type");
optgroup->append_single_option_line("ironing_pattern", category_path + "ironing_pattern");
optgroup->append_single_option_line("ironing_flowrate", category_path + "flow-rate");
optgroup->append_single_option_line("ironing_spacing", category_path + "spacing-between-ironing-passes");