Skip to content

Commit

Permalink
merge latest fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Apr 30, 2024
2 parents d59bfb9 + f5fc6eb commit 3a04445
Show file tree
Hide file tree
Showing 14 changed files with 331 additions and 113 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/ccpp_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,28 @@ jobs:
- name: change date in version
shell: powershell
run: (Get-Content version.inc) | Foreach-Object {$_ -replace "\+UNKNOWN", ("_" + [datetime]::Today.ToString("yyyy-MM-dd"))} | Set-Content version.inc
- name: mkdir in deps directory
run: mkdir deps/destdir
- run: mkdir deps/destdir
- name: download deps
uses: actions/download-artifact@v1
with:
name: deps_win
path: deps/destdir
- name: echo dir deps
run: dir deps
- name: echo dir deps destdir
run: dir deps/destdir
- name: mkdir
run: mkdir build
- run: dir deps
- run: dir deps/destdir
- run: mkdir msgfmt_bin
- name: copy gettext
working-directory: ./msgfmt_bin
shell: powershell
run: '(new-object System.Net.WebClient).DownloadFile("https://github.com/supermerill/SuperSlicer_deps/releases/download/gettext/gettext-tools-static-0.18.1.1.zip", "gettext.zip")'
- name: unzip
working-directory: ./msgfmt_bin
shell: cmd
run: '"C:/Program Files/7-Zip/7z.exe" x gettext.zip'
- name: add msgfmt to path
shell: powershell
working-directory: msgfmt_bin
run: echo "$pwd;" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- run: mkdir build
- name: cmake
working-directory: ./build
run: cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_PREFIX_PATH="d:\a\${{ github.event.repository.name }}\${{ github.event.repository.name }}\deps\destdir\usr\local"
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ class ConfigOptionVectorBase : public ConfigOption {
virtual bool empty() const = 0;
// Get if the size of this vector is/should be the same as nozzle_diameter
bool is_extruder_size() const { return (flags & FCO_EXTRUDER_ARRAY) != 0; }
ConfigOptionVectorBase* set_is_extruder_size(bool is_extruder_size) {
ConfigOptionVectorBase* set_is_extruder_size(bool is_extruder_size = true) {
if (is_extruder_size) this->flags |= FCO_EXTRUDER_ARRAY; else this->flags &= uint8_t(0xFF ^ FCO_EXTRUDER_ARRAY);
return this;
}
Expand Down
4 changes: 0 additions & 4 deletions src/libslic3r/Flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ double Flow::extrusion_width(const std::string& opt_key, const ConfigOptionFloat
}

if (opt->percent) {
auto opt_key_layer_height = first_layer ? "first_layer_height" : "layer_height";
auto opt_layer_height = config.option(opt_key_layer_height);
if (opt_layer_height == nullptr)
throw_on_missing_variable(opt_key, opt_key_layer_height);
// first_layer_height depends on first_printing_extruder
auto opt_nozzle_diameters = config.option<ConfigOptionFloats>("nozzle_diameter");
if (opt_nozzle_diameters == nullptr)
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ static std::vector<std::string> s_Preset_print_options {
"compatible_printers", "compatible_printers_condition", "inherits",
"infill_dense", "infill_dense_algo",
"no_perimeter_unsupported_algo",
"exact_last_layer_height",
// "exact_last_layer_height",
"perimeter_loop",
"perimeter_loop_seam",
"infill_connection", "infill_connection_solid", "infill_connection_top", "infill_connection_bottom", "infill_connection_bridge",
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ double Print::get_object_first_layer_height(const PrintObject& object) const {
object_first_layer_height = std::min(object_first_layer_height, object.config().first_layer_height.get_abs_value(nozzle_diameter));
}
}
assert(object_first_layer_height < 1000000000);
return object_first_layer_height;
}

Expand Down
18 changes: 10 additions & 8 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3275,6 +3275,7 @@ void PrintConfigDef::init_fff_params()
// and it contains a sum of "inherits" values over the print and filament profiles.
def = this->add("inherits_cummulative", coStrings);
def->set_default_value(new ConfigOptionStrings());
def->mode = comPrusa;
def->cli = ConfigOptionDef::nocli;

def = this->add("interface_shells", coBool);
Expand Down Expand Up @@ -3400,12 +3401,12 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert | comSuSi;
def->set_default_value(new ConfigOptionString(""));

def = this->add("exact_last_layer_height", coBool);
def->label = L("Exact last layer height");
def->category = OptionCategory::perimeter;
def->tooltip = L("This setting controls the height of last object layers to put the last layer at the exact highest height possible. Experimental.");
def->mode = comHidden;
def->set_default_value(new ConfigOptionBool(false));
// def = this->add("exact_last_layer_height", coBool);
// def->label = L("Exact last layer height");
// def->category = OptionCategory::perimeter;
// def->tooltip = L("This setting controls the height of last object layers to put the last layer at the exact highest height possible. Experimental.");
// def->mode = comHidden;
// def->set_default_value(new ConfigOptionBool(false));

def = this->add("remaining_times", coBool);
def->label = L("Supports remaining times");
Expand Down Expand Up @@ -7686,6 +7687,7 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
"seal_position", "vibration_limit", "bed_size",
"print_center", "g0", "threads", "pressure_advance", "wipe_tower_per_color_wipe",
"cooling", "serial_port", "serial_speed",
"exact_last_layer_height",
// Introduced in some PrusaSlicer 2.3.1 alpha, later renamed or removed.
"fuzzy_skin_perimeter_mode", "fuzzy_skin_shape",
// Introduced in PrusaSlicer 2.3.0-alpha2, later replaced by automatic calculation based on extrusion width.
Expand Down Expand Up @@ -8090,7 +8092,7 @@ std::unordered_set<std::string> prusa_export_to_remove_keys = {
"curve_smoothing_precision",
"default_speed",
"enforce_full_fill_volume",
"exact_last_layer_height",
// "exact_last_layer_height",
"external_infill_margin",
"external_perimeter_acceleration",
"external_perimeter_cut_corners",
Expand Down Expand Up @@ -8731,7 +8733,7 @@ void DynamicPrintConfig::normalize_fdm()
this->opt<ConfigOptionBool>("support_material", true)->value = false;
this->opt<ConfigOptionInt>("solid_over_perimeters")->value = 0;
this->opt<ConfigOptionInt>("support_material_enforce_layers")->value = 0;
this->opt<ConfigOptionBool>("exact_last_layer_height", true)->value = false;
// this->opt<ConfigOptionBool>("exact_last_layer_height", true)->value = false;
this->opt<ConfigOptionBool>("ensure_vertical_shell_thickness", true)->value = false;
this->opt<ConfigOptionBool>("infill_dense", true)->value = false;
this->opt<ConfigOptionBool>("extra_perimeters", true)->value = false;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, clip_multipart_objects))
((ConfigOptionBool, dont_support_bridges))
((ConfigOptionPercent, external_perimeter_cut_corners))
((ConfigOptionBool, exact_last_layer_height))
//((ConfigOptionBool, exact_last_layer_height))
((ConfigOptionFloatOrPercent, extrusion_width))
((ConfigOptionFloatOrPercent, extrusion_spacing))
((ConfigOptionFloatOrPercent, first_layer_acceleration_over_raft))
Expand Down
18 changes: 8 additions & 10 deletions src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,11 @@ namespace Slic3r {
{
m_max_sparse_spacing = 0;
std::atomic_int64_t max_sparse_spacing;
//tbb::parallel_for(
// tbb::blocked_range<size_t>(0, m_layers.size()),
// [this, &max_sparse_spacing](const tbb::blocked_range<size_t>& range) {
//for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++layer_idx) {
for (size_t layer_idx = 0; layer_idx < m_layers.size(); ++layer_idx) {
tbb::parallel_for(
tbb::blocked_range<size_t>(0, m_layers.size()),
[this, &max_sparse_spacing](const tbb::blocked_range<size_t>& range) {
for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++layer_idx) {
//for (size_t layer_idx = 0; layer_idx < m_layers.size(); ++layer_idx) {
m_print->throw_if_canceled();
const Layer *layer = m_layers[layer_idx];
for (const LayerRegion *layerm : layer->regions()) {
Expand All @@ -566,17 +566,14 @@ namespace Slic3r {
coord_t spacing = layerm->region().flow(*this, frInfill, layer->height, layer->id()).scaled_spacing();
// update atomic to max
int64_t prev_value = max_sparse_spacing.load();
std::cout<<"will update "<<max_sparse_spacing.load()<<"=="<<prev_value<<" to "<<spacing<<"\n";
while (prev_value < int64_t(spacing) &&
!max_sparse_spacing.compare_exchange_weak(prev_value, int64_t(spacing))) {
std::cout<<"can't update "<<max_sparse_spacing<<"\n";
}
std::cout<<"it ahs been updated to "<<max_sparse_spacing.load()<<" from "<<prev_value<<" -> "<<spacing<<"\n";
}
}
}
}
//});
});
m_max_sparse_spacing = max_sparse_spacing.load();
}

Expand Down Expand Up @@ -894,7 +891,7 @@ bool PrintObject::invalidate_state_by_config_options(
opt_key == "layer_height"
|| opt_key == "first_layer_height"
|| opt_key == "mmu_segmented_region_max_width"
|| opt_key == "exact_last_layer_height"
// || opt_key == "exact_last_layer_height"
|| opt_key == "raft_contact_distance"
|| opt_key == "raft_interface_layer_height"
|| opt_key == "raft_layers"
Expand Down Expand Up @@ -2695,6 +2692,7 @@ PrintRegionConfig region_config_from_model_volume(const PrintRegionConfig &defau
object_first_layer_height = std::fmin(object_first_layer_height, config().first_layer_height.get_abs_value(nozzle_diameter));
}
}
assert(object_first_layer_height < 1000000000);
return object_first_layer_height;
}

Expand Down
70 changes: 39 additions & 31 deletions src/libslic3r/Slicing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,29 @@ std::shared_ptr<SlicingParameters> SlicingParameters::create_from_config(
// if the first_layer_height setting depends of the nozzle width, use the first one. Apply the z_step

//get object first layer height
coordf_t first_layer_height = object_config.first_layer_height.value;
double first_layer_height = object_config.first_layer_height.value;
if (object_config.first_layer_height.percent) {
first_layer_height = 1000000000.;
for (uint16_t extruder_id : object_extruders) {
if (print_config.nozzle_diameter.size() <= extruder_id)
break;
coordf_t nozzle_diameter = print_config.nozzle_diameter.values[extruder_id];
double nozzle_diameter = print_config.nozzle_diameter.values[extruder_id];
first_layer_height = std::min(first_layer_height, object_config.first_layer_height.get_abs_value(nozzle_diameter));
}
if (first_layer_height == 1000000000.)
first_layer_height = 0;
}

if (first_layer_height == 0)

first_layer_height = check_z_step(first_layer_height, print_config.z_step);
assert(first_layer_height > 0);
for (uint16_t extruder_id : object_extruders)
assert(first_layer_height >=
print_config.min_layer_height.get_abs_value(extruder_id, print_config.nozzle_diameter.get_at(extruder_id)) - EPSILON);
if (first_layer_height <= EPSILON)
object_config.layer_height.value;
first_layer_height = check_z_step(first_layer_height, print_config.z_step);
assert(first_layer_height > 0);

// If object_config.support_material_extruder == 0 resp. object_config.support_material_interface_extruder == 0,
// print_config.nozzle_diameter.get_at(size_t(-1)) returns the 0th nozzle diameter,
// which is consistent with the requirement that if support_material_extruder == 0 resp. support_material_interface_extruder == 0,
Expand Down Expand Up @@ -138,7 +145,7 @@ std::shared_ptr<SlicingParameters> SlicingParameters::create_from_config(
params.max_layer_height = std::numeric_limits<double>::max();
params.max_suport_layer_height = 0;
params.min_suport_layer_height = 0;
params.exact_last_layer_height = object_config.exact_last_layer_height.value;
// params.exact_last_layer_height = object_config.exact_last_layer_height.value;
if (object_config.support_material.value || params.base_raft_layers > 0 || object_config.support_material_enforce_layers > 0) {
// Has some form of support. Add the support layers to the minimum / maximum layer height limits.
if (object_config.support_material_extruder > 0)
Expand Down Expand Up @@ -799,32 +806,33 @@ std::vector<coordf_t> generate_object_layers(
}

// Adjust the last layer to align with the top object layer exactly
if (out.size() > 0 && slicing_params.object_print_z_height() != out[out.size() - 1] && slicing_params.exact_last_layer_height) {
float neededPrintZ = slicing_params.object_print_z_height();
int idx_layer = out.size() / 2 - 1;
float diffZ = neededPrintZ - out[idx_layer * 2 + 1];
while (diffZ > EPSILON || diffZ < -EPSILON && idx_layer >= 0){
float newH = out[idx_layer * 2 + 1] - out[idx_layer * 2];
if (diffZ > 0){
newH = std::min((float)slicing_params.max_layer_height, newH + diffZ);
} else{
newH = std::max((float)slicing_params.min_layer_height, newH + diffZ);
}
out[idx_layer * 2 + 1] = neededPrintZ;
out[idx_layer * 2] = neededPrintZ - newH;

//next item
neededPrintZ = out[idx_layer * 2];
idx_layer--;
if (idx_layer >= 0){
diffZ = neededPrintZ - out[idx_layer * 2 + 1];
} else{
//unlikely to happen. note: can create a layer outside the min/max bounds.
diffZ = 0;
out[idx_layer * 2] = 0;
}
}
}
// FIXME
// if (out.size() > 0 && slicing_params.object_print_z_height() != out[out.size() - 1] && slicing_params.exact_last_layer_height) {
// float neededPrintZ = slicing_params.object_print_z_height();
// int idx_layer = out.size() / 2 - 1;
// float diffZ = neededPrintZ - out[idx_layer * 2 + 1];
// while (diffZ > EPSILON || diffZ < -EPSILON && idx_layer >= 0){
// float newH = out[idx_layer * 2 + 1] - out[idx_layer * 2];
// if (diffZ > 0){
// newH = std::min((float)slicing_params.max_layer_height, newH + diffZ);
// } else{
// newH = std::max((float)slicing_params.min_layer_height, newH + diffZ);
// }
// out[idx_layer * 2 + 1] = neededPrintZ;
// out[idx_layer * 2] = neededPrintZ - newH;

// //next item
// neededPrintZ = out[idx_layer * 2];
// idx_layer--;
// if (idx_layer >= 0){
// diffZ = neededPrintZ - out[idx_layer * 2 + 1];
// } else{
// //unlikely to happen. note: can create a layer outside the min/max bounds.
// diffZ = 0;
// out[idx_layer * 2] = 0;
// }
// }
// }

#ifdef _DEBUG
for (size_t i = 0; i < out.size(); i++)
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Slicing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct SlicingParameters
coordf_t max_layer_height { 0 };
coordf_t max_suport_layer_height { 0 };
coordf_t min_suport_layer_height { 0 };
bool exact_last_layer_height;
// bool exact_last_layer_height;
// min common divisor for all layer height
coordf_t z_step;

Expand Down
10 changes: 5 additions & 5 deletions src/slic3r/GUI/ConfigManipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
&& config->opt_bool("support_material") == false
&& config->opt_int("support_material_enforce_layers") == 0
&& config->opt_enum<PerimeterGeneratorType>("perimeter_generator") == PerimeterGeneratorType::Classic
&& config->opt_bool("exact_last_layer_height") == false
// && config->opt_bool("exact_last_layer_height") == false
&& config->opt_bool("ensure_vertical_shell_thickness") == true
&& config->opt_bool("infill_dense") == false
&& config->opt_bool("extra_perimeters") == false
Expand All @@ -97,7 +97,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
"- no support material\n"
"- Ensure vertical shell thickness enabled\n"
"- disabled 'no solid infill over perimeters'\n"
"- unchecked 'exact last layer height'\n"
// "- unchecked 'exact last layer height'\n"
"- unchecked 'dense infill'\n"
"- unchecked 'extra perimeters'"
"- unchecked 'gap fill after last perimeter'"
Expand All @@ -123,8 +123,8 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
new_conf.set_key_value("support_material", new ConfigOptionBool(false));
else if (this->local_config->get().optptr("support_material_enforce_layers"))
new_conf.set_key_value("support_material_enforce_layers", new ConfigOptionInt(0));
else if (this->local_config->get().optptr("exact_last_layer_height"))
new_conf.set_key_value("exact_last_layer_height", new ConfigOptionBool(false));
// else if (this->local_config->get().optptr("exact_last_layer_height"))
// new_conf.set_key_value("exact_last_layer_height", new ConfigOptionBool(false));
else if (this->local_config->get().optptr("ensure_vertical_shell_thickness"))
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(true));
else if (this->local_config->get().optptr("infill_dense"))
Expand Down Expand Up @@ -154,7 +154,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
new_conf.set_key_value("perimeter_generator", new ConfigOptionEnum<PerimeterGeneratorType>(PerimeterGeneratorType::Classic));
new_conf.set_key_value("support_material", new ConfigOptionBool(false));
new_conf.set_key_value("support_material_enforce_layers", new ConfigOptionInt(0));
new_conf.set_key_value("exact_last_layer_height", new ConfigOptionBool(false));
// new_conf.set_key_value("exact_last_layer_height", new ConfigOptionBool(false));
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(true));
new_conf.set_key_value("infill_dense", new ConfigOptionBool(false));
new_conf.set_key_value("extra_perimeters", new ConfigOptionBool(false));
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/GCodeViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4405,14 +4405,14 @@ void GCodeViewer::render_legend(float& legend_height)
imgui.text(min_label);
ImGui::SameLine();
ImGui::PushItemWidth(imgui.get_style_scaling() * size);
ImGui::InputFloat(m_extrusions.ranges.min_max_cstr_id[size_t(m_view_type)].second.c_str(), &mod_max, 0.0f,
ImGui::InputFloat(m_extrusions.ranges.min_max_cstr_id[size_t(m_view_type)].second.c_str(), &mod_min, 0.0f,
0.0f, format.c_str(), ImGuiInputTextFlags_CharsDecimal, 0.f);
// draw max
ImGui::SameLine();
imgui.text(max_label);
ImGui::SameLine();
ImGui::PushItemWidth(imgui.get_style_scaling() * size);
ImGui::InputFloat(m_extrusions.ranges.min_max_cstr_id[size_t(m_view_type)].first.c_str(), &mod_min, 0.0f,
ImGui::InputFloat(m_extrusions.ranges.min_max_cstr_id[size_t(m_view_type)].first.c_str(), &mod_max, 0.0f,
0.0f, format.c_str(), ImGuiInputTextFlags_CharsDecimal, 0.f);

} else {
Expand Down
3 changes: 3 additions & 0 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ void Tab::OnActivate()

void Tab::update_label_colours()
{
if (!this->completed())
return;

if (m_sys_label_clr == wxGetApp().get_label_clr_sys()
&& m_modified_label_clr == wxGetApp().get_label_clr_modified()
&& m_default_label_clr == wxGetApp().get_label_clr_default()
Expand Down
Loading

0 comments on commit 3a04445

Please sign in to comment.