mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-14 05:21:51 +08:00
#612 add soft threshold for big holes XY compensation
This commit is contained in:
parent
13586d6764
commit
151ea0a39f
@ -86,12 +86,15 @@ group:label_width$8:Modifying slices
|
|||||||
setting:width$6:curve_smoothing_angle_concave
|
setting:width$6:curve_smoothing_angle_concave
|
||||||
setting:width$6:curve_smoothing_cutoff_dist
|
setting:width$6:curve_smoothing_cutoff_dist
|
||||||
end_line
|
end_line
|
||||||
setting:hole_to_polyhole
|
|
||||||
line:XY compensation
|
line:XY compensation
|
||||||
setting:width$6:xy_size_compensation
|
setting:width$6:xy_size_compensation
|
||||||
setting:width$6:xy_inner_size_compensation
|
setting:width$6:xy_inner_size_compensation
|
||||||
setting:width$6:first_layer_size_compensation
|
setting:width$6:first_layer_size_compensation
|
||||||
|
end_line
|
||||||
|
line:Vertical Hole shrinking compensation
|
||||||
|
setting:hole_to_polyhole
|
||||||
setting:width$6:hole_size_compensation
|
setting:width$6:hole_size_compensation
|
||||||
|
setting:width$6:hole_size_threshold
|
||||||
end_line
|
end_line
|
||||||
group:Other
|
group:Other
|
||||||
setting:clip_multipart_objects
|
setting:clip_multipart_objects
|
||||||
|
@ -3725,7 +3725,8 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->category = OptionCategory::slicing;
|
def->category = OptionCategory::slicing;
|
||||||
def->tooltip = L("The object will be grown/shrunk in the XY plane by the configured value "
|
def->tooltip = L("The object will be grown/shrunk in the XY plane by the configured value "
|
||||||
"(negative = inwards, positive = outwards). This might be useful for fine-tuning sizes."
|
"(negative = inwards, positive = outwards). This might be useful for fine-tuning sizes."
|
||||||
"\nThis one only applies to the 'exterior' shell of the object");
|
"\nThis one only applies to the 'exterior' shell of the object."
|
||||||
|
"\n !!! it's recommended you put the same value into the 'Inner XY size compensation', unless you are sure you don't have horizontal holes. !!! ");
|
||||||
def->sidetext = L("mm");
|
def->sidetext = L("mm");
|
||||||
def->mode = comExpert;
|
def->mode = comExpert;
|
||||||
def->set_default_value(new ConfigOptionFloat(0));
|
def->set_default_value(new ConfigOptionFloat(0));
|
||||||
@ -3736,7 +3737,7 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->category = OptionCategory::slicing;
|
def->category = OptionCategory::slicing;
|
||||||
def->tooltip = L("The object will be grown/shrunk in the XY plane by the configured value "
|
def->tooltip = L("The object will be grown/shrunk in the XY plane by the configured value "
|
||||||
"(negative = inwards, positive = outwards). This might be useful for fine-tuning sizes."
|
"(negative = inwards, positive = outwards). This might be useful for fine-tuning sizes."
|
||||||
"\nThis one only applies to the 'inner' shell of the object");
|
"\nThis one only applies to the 'inner' shell of the object (!!! horizontal holes break the shell !!!)");
|
||||||
def->sidetext = L("mm");
|
def->sidetext = L("mm");
|
||||||
def->mode = comExpert;
|
def->mode = comExpert;
|
||||||
def->set_default_value(new ConfigOptionFloat(0));
|
def->set_default_value(new ConfigOptionFloat(0));
|
||||||
@ -3753,6 +3754,17 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->mode = comExpert;
|
def->mode = comExpert;
|
||||||
def->set_default_value(new ConfigOptionFloat(0));
|
def->set_default_value(new ConfigOptionFloat(0));
|
||||||
|
|
||||||
|
def = this->add("hole_size_threshold", coFloat);
|
||||||
|
def->label = L("Holes");
|
||||||
|
def->full_label = L("XY holes threshold");
|
||||||
|
def->category = OptionCategory::slicing;
|
||||||
|
def->tooltip = L("Maximum area for the hole where the hole_size_compensation will apply fully."
|
||||||
|
" After that, it will decraese down to 0 for four time this area."
|
||||||
|
" Set to 0 to let the hole_size_compensation apply fully for all detected holes");
|
||||||
|
def->sidetext = L("mm²");
|
||||||
|
def->mode = comExpert;
|
||||||
|
def->set_default_value(new ConfigOptionFloat(100));
|
||||||
|
|
||||||
def = this->add("hole_to_polyhole", coBool);
|
def = this->add("hole_to_polyhole", coBool);
|
||||||
def->label = L("Convert round holes to polyholes");
|
def->label = L("Convert round holes to polyholes");
|
||||||
def->full_label = L("Convert round holes to polyholes");
|
def->full_label = L("Convert round holes to polyholes");
|
||||||
|
@ -530,6 +530,7 @@ public:
|
|||||||
ConfigOptionFloatOrPercent first_layer_height;
|
ConfigOptionFloatOrPercent first_layer_height;
|
||||||
ConfigOptionFloat first_layer_size_compensation;
|
ConfigOptionFloat first_layer_size_compensation;
|
||||||
ConfigOptionFloat hole_size_compensation;
|
ConfigOptionFloat hole_size_compensation;
|
||||||
|
ConfigOptionFloat hole_size_threshold;
|
||||||
ConfigOptionBool infill_only_where_needed;
|
ConfigOptionBool infill_only_where_needed;
|
||||||
// Force the generation of solid shells between adjacent materials/volumes.
|
// Force the generation of solid shells between adjacent materials/volumes.
|
||||||
ConfigOptionBool interface_shells;
|
ConfigOptionBool interface_shells;
|
||||||
@ -592,6 +593,7 @@ protected:
|
|||||||
OPT_PTR(exact_last_layer_height);
|
OPT_PTR(exact_last_layer_height);
|
||||||
OPT_PTR(extrusion_width);
|
OPT_PTR(extrusion_width);
|
||||||
OPT_PTR(hole_size_compensation);
|
OPT_PTR(hole_size_compensation);
|
||||||
|
OPT_PTR(hole_size_threshold);
|
||||||
OPT_PTR(first_layer_height);
|
OPT_PTR(first_layer_height);
|
||||||
OPT_PTR(first_layer_size_compensation);
|
OPT_PTR(first_layer_size_compensation);
|
||||||
OPT_PTR(infill_only_where_needed);
|
OPT_PTR(infill_only_where_needed);
|
||||||
|
@ -646,6 +646,7 @@ bool PrintObject::invalidate_state_by_config_options(const std::vector<t_config_
|
|||||||
|| opt_key == "support_material_contact_distance_bottom"
|
|| opt_key == "support_material_contact_distance_bottom"
|
||||||
|| opt_key == "xy_size_compensation"
|
|| opt_key == "xy_size_compensation"
|
||||||
|| opt_key == "hole_size_compensation"
|
|| opt_key == "hole_size_compensation"
|
||||||
|
|| opt_key == "hole_size_threshold"
|
||||||
|| opt_key == "hole_to_polyhole"
|
|| opt_key == "hole_to_polyhole"
|
||||||
|| opt_key == "z_step") {
|
|| opt_key == "z_step") {
|
||||||
steps.emplace_back(posSlice);
|
steps.emplace_back(posSlice);
|
||||||
@ -2520,6 +2521,7 @@ end:
|
|||||||
|
|
||||||
ExPolygons PrintObject::_shrink_contour_holes(double contour_delta, double default_delta, double convex_delta, const ExPolygons& polys) const {
|
ExPolygons PrintObject::_shrink_contour_holes(double contour_delta, double default_delta, double convex_delta, const ExPolygons& polys) const {
|
||||||
ExPolygons new_ex_polys;
|
ExPolygons new_ex_polys;
|
||||||
|
double max_hole_area = scale_d(scale_d(m_config.hole_size_threshold.value));
|
||||||
for (const ExPolygon& ex_poly : polys) {
|
for (const ExPolygon& ex_poly : polys) {
|
||||||
Polygons contours;
|
Polygons contours;
|
||||||
Polygons holes;
|
Polygons holes;
|
||||||
@ -2541,7 +2543,17 @@ ExPolygons PrintObject::_shrink_contour_holes(double contour_delta, double defau
|
|||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
if (convex_delta != 0) {
|
if (convex_delta != 0) {
|
||||||
for (Polygon &newHole : offset(hole, -convex_delta)) {
|
//apply hole threshold cutoff
|
||||||
|
double convex_delta_adapted = convex_delta;
|
||||||
|
double area = -hole.area();
|
||||||
|
if (area > max_hole_area * 4) {
|
||||||
|
convex_delta_adapted = 0;
|
||||||
|
}else if (area > max_hole_area) {
|
||||||
|
// not a hard threshold, to avoid artefacts on slopped holes.
|
||||||
|
convex_delta_adapted = convex_delta * (max_hole_area * 4 - area) / (max_hole_area * 3);
|
||||||
|
}
|
||||||
|
if (convex_delta_adapted != 0) {
|
||||||
|
for (Polygon &newHole : offset(hole, -convex_delta_adapted)) {
|
||||||
newHole.make_counter_clockwise();
|
newHole.make_counter_clockwise();
|
||||||
holes.emplace_back(std::move(newHole));
|
holes.emplace_back(std::move(newHole));
|
||||||
}
|
}
|
||||||
@ -2549,6 +2561,10 @@ ExPolygons PrintObject::_shrink_contour_holes(double contour_delta, double defau
|
|||||||
holes.push_back(hole);
|
holes.push_back(hole);
|
||||||
holes.back().make_counter_clockwise();
|
holes.back().make_counter_clockwise();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
holes.push_back(hole);
|
||||||
|
holes.back().make_counter_clockwise();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (default_delta != 0) {
|
if (default_delta != 0) {
|
||||||
for (Polygon &newHole : offset(hole, -default_delta)) {
|
for (Polygon &newHole : offset(hole, -default_delta)) {
|
||||||
|
@ -100,6 +100,8 @@ inline T unscale(Q v) { return T(v) * T(SCALING_FACTOR); }
|
|||||||
inline double unscaled(double v) { return v * SCALING_FACTOR; }
|
inline double unscaled(double v) { return v * SCALING_FACTOR; }
|
||||||
inline coordf_t unscale_(coord_t v) { return v * SCALING_FACTOR; }
|
inline coordf_t unscale_(coord_t v) { return v * SCALING_FACTOR; }
|
||||||
inline coord_t scale_t(coordf_t v) { return (coord_t)(v / SCALING_FACTOR); }
|
inline coord_t scale_t(coordf_t v) { return (coord_t)(v / SCALING_FACTOR); }
|
||||||
|
inline double scale_d(coordf_t v) { return (v / SCALING_FACTOR); }
|
||||||
|
inline double scale_d(coord_t v) { return ((double)v / SCALING_FACTOR); }
|
||||||
|
|
||||||
enum Axis {
|
enum Axis {
|
||||||
X=0,
|
X=0,
|
||||||
|
@ -520,6 +520,7 @@ const std::vector<std::string>& Preset::print_options()
|
|||||||
"xy_size_compensation",
|
"xy_size_compensation",
|
||||||
"xy_inner_size_compensation",
|
"xy_inner_size_compensation",
|
||||||
"hole_size_compensation",
|
"hole_size_compensation",
|
||||||
|
"hole_size_threshold",
|
||||||
"hole_to_polyhole",
|
"hole_to_polyhole",
|
||||||
"threads", "resolution",
|
"threads", "resolution",
|
||||||
"wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging",
|
"wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user