Skip to content

Commit

Permalink
Squash merge of pull request Raft enhancements #6003
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit a16674f
Merge: a5972e6 28e5e41
Author: Vojtech Bubnik <bubnikv@gmail.com>
Date:   Wed Feb 10 08:56:21 2021 +0100

    Merge branch 'rafting_extras_2' of https://github.com/nemart69/PrusaSlicer into nemart69-rafting_extras_2

commit 28e5e41
Author: nemart69 <78763471+nemart69@users.noreply.github.com>
Date:   Wed Feb 10 00:58:50 2021 +0100

    Fix after merge with master

    Fixed missing curly brace after improperly solved merge conflict.

commit 02b71f7
Merge: 08131f0 8fbafbe
Author: nemart69 <78763471+nemart69@users.noreply.github.com>
Date:   Tue Feb 9 22:12:26 2021 +0100

    Merge branch 'master' into rafting_extras_2

commit 08131f0
Author: nemart69 <78763471+nemart69@users.noreply.github.com>
Date:   Tue Feb 9 21:17:19 2021 +0100

    Raft changes, GUI part

commit 69aae4a
Author: nemart69 <78763471+nemart69@users.noreply.github.com>
Date:   Tue Feb 9 21:15:33 2021 +0100

    Raft changes, libslic3r part
  • Loading branch information
bubnikv committed Feb 10, 2021
1 parent a5972e6 commit 8e9526e
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 147 deletions.
5 changes: 4 additions & 1 deletion src/libslic3r/PerimeterGenerator.cpp
Expand Up @@ -154,7 +154,10 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime

// detect overhanging/bridging perimeters
ExtrusionPaths paths;
if (perimeter_generator.config->overhangs && perimeter_generator.layer_id > 0
if ( ( (perimeter_generator.config->overhangs && perimeter_generator.layer_id > perimeter_generator.object_config->raft_layers)
|| (perimeter_generator.object_config->raft_overhangs
&& perimeter_generator.object_config->raft_layers > 0
&& perimeter_generator.layer_id == perimeter_generator.object_config->raft_layers)) // RaftingEdition
&& !(perimeter_generator.object_config->support_material && perimeter_generator.object_config->support_material_contact_distance.value == 0)) {
// get non-overhang paths by intersecting this loop with the grown lower slices
extrusion_paths_append(
Expand Down
53 changes: 27 additions & 26 deletions src/libslic3r/Preset.cpp
Expand Up @@ -15,7 +15,7 @@
// !!! If you needed to translate some string,
// !!! please use _L(string)
// !!! _() - is a standard wxWidgets macro to translate
// !!! L() is used only for marking localizable string
// !!! L() is used only for marking localizable string
// !!! It will be used in "xgettext" to create a Locating Message Catalog.
#define L(s) s
#endif /* L */
Expand Down Expand Up @@ -386,7 +386,7 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config)
} else if (type == TYPE_FILAMENT || type == TYPE_SLA_MATERIAL) {
const std::string &section_name = (type == TYPE_FILAMENT) ? AppConfig::SECTION_FILAMENTS : AppConfig::SECTION_MATERIALS;
if (app_config.has_section(section_name)) {
// Check whether this profile is marked as "installed" in PrusaSlicer.ini,
// Check whether this profile is marked as "installed" in PrusaSlicer.ini,
// or whether a profile is marked as "installed", which this profile may have been renamed from.
const std::map<std::string, std::string> &installed = app_config.get_section(section_name);
auto has = [&installed](const std::string &name) {
Expand All @@ -403,12 +403,12 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config)
const std::vector<std::string>& Preset::print_options()
{
static std::vector<std::string> s_opts {
"layer_height", "first_layer_height", "perimeters", "spiral_vase", "slice_closing_radius",
"layer_height", "first_layer_height", "perimeters", "spiral_vase", "slice_closing_radius",
"top_solid_layers", "top_solid_min_thickness", "bottom_solid_layers", "bottom_solid_min_thickness",
"extra_perimeters", "ensure_vertical_shell_thickness", "avoid_crossing_perimeters", "thin_walls", "overhangs",
"seam_position", "external_perimeters_first", "fill_density", "fill_pattern", "top_fill_pattern", "bottom_fill_pattern",
"infill_every_layers", "infill_only_where_needed", "solid_infill_every_layers", "fill_angle", "bridge_angle",
"solid_infill_below_area", "only_retract_when_crossing_perimeters", "infill_first",
"solid_infill_below_area", "only_retract_when_crossing_perimeters", "infill_first",
"ironing", "ironing_type", "ironing_flowrate", "ironing_speed", "ironing_spacing",
"max_print_speed", "max_volumetric_speed", "avoid_crossing_perimeters_max_detour",
"fuzzy_skin_perimeter_mode", /* "fuzzy_skin_shape", */ "fuzzy_skin_thickness", "fuzzy_skin_point_dist",
Expand All @@ -420,6 +420,7 @@ const std::vector<std::string>& Preset::print_options()
"bridge_speed", "gap_fill_speed", "travel_speed", "first_layer_speed", "perimeter_acceleration", "infill_acceleration",
"bridge_acceleration", "first_layer_acceleration", "default_acceleration", "skirts", "skirt_distance", "skirt_height", "draft_shield",
"min_skirt_length", "brim_width", "brim_offset", "brim_type", "support_material", "support_material_auto", "support_material_threshold", "support_material_enforce_layers",
"raft_overhangs", "raft_contact_distance", "raft_xy_size_compensation", "raft_size_adjust",
"raft_layers", "support_material_pattern", "support_material_with_sheath", "support_material_spacing",
"support_material_synchronize_layers", "support_material_angle", "support_material_interface_layers",
"support_material_interface_spacing", "support_material_interface_contact_loops", "support_material_contact_distance",
Expand Down Expand Up @@ -485,7 +486,7 @@ const std::vector<std::string>& Preset::printer_options()
"between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "cooling_tube_retraction",
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "max_print_height",
"default_print_profile", "inherits",
"remaining_times", "silent_mode",
"remaining_times", "silent_mode",
"machine_limits_usage", "thumbnails"
};
s_opts.insert(s_opts.end(), Preset::machine_limits_options().begin(), Preset::machine_limits_options().end());
Expand Down Expand Up @@ -646,7 +647,7 @@ void PresetCollection::add_default_preset(const std::vector<std::string> &keys,
// Throws an exception on error.
void PresetCollection::load_presets(const std::string &dir_path, const std::string &subdir)
{
// Don't use boost::filesystem::canonical() on Windows, it is broken in regard to reparse points,
// Don't use boost::filesystem::canonical() on Windows, it is broken in regard to reparse points,
// see https://github.com/prusa3d/PrusaSlicer/issues/732
boost::filesystem::path dir = boost::filesystem::absolute(boost::filesystem::path(dir_path) / subdir).make_preferred();
m_dir_path = dir.string();
Expand Down Expand Up @@ -970,7 +971,7 @@ const Preset* PresetCollection::get_selected_preset_parent() const
// Resolve the "renamed_from" field.
assert(! inherits.empty());
auto it = this->find_preset_renamed(inherits);
if (it != m_presets.end())
if (it != m_presets.end())
preset = &(*it);
}
return (preset == nullptr/* || preset->is_default*/ || preset->is_external) ? nullptr : preset;
Expand All @@ -985,17 +986,17 @@ const Preset* PresetCollection::get_preset_parent(const Preset& child) const
const Preset* preset = this->find_preset(inherits, false);
if (preset == nullptr) {
auto it = this->find_preset_renamed(inherits);
if (it != m_presets.end())
if (it != m_presets.end())
preset = &(*it);
}
return
return
// not found
(preset == nullptr/* || preset->is_default */||
(preset == nullptr/* || preset->is_default */||
// this should not happen, user profile should not derive from an external profile
preset->is_external ||
// this should not happen, however people are creative, see GH #4996
preset == &child) ?
nullptr :
preset == &child) ?
nullptr :
preset;
}

Expand All @@ -1022,7 +1023,7 @@ const std::string& PresetCollection::get_preset_name_by_alias(const std::string&
// Continue over all profile names with the same alias.
it != m_map_alias_to_profile_name.end() && it->first == alias; ++ it)
if (auto it_preset = this->find_preset_internal(it->second);
it_preset != m_presets.end() && it_preset->name == it->second &&
it_preset != m_presets.end() && it_preset->name == it->second &&
it_preset->is_visible && (it_preset->is_compatible || size_t(it_preset - m_presets.begin()) == m_idx_selected))
return it_preset->name;
return alias;
Expand Down Expand Up @@ -1092,7 +1093,7 @@ size_t PresetCollection::update_compatible_internal(const PresetWithVendorProfil
some_compatible |= preset_edited.is_compatible;
if (active_print != nullptr)
preset_edited.is_compatible &= is_compatible_with_print(this_preset_with_vendor_profile, *active_print, active_printer);
if (! preset_edited.is_compatible && selected &&
if (! preset_edited.is_compatible && selected &&
(unselect_if_incompatible == PresetSelectCompatibleType::Always || (unselect_if_incompatible == PresetSelectCompatibleType::OnlyIfWasCompatible && was_compatible)))
m_idx_selected = size_t(-1);
if (selected)
Expand Down Expand Up @@ -1433,13 +1434,13 @@ const std::set<std::string>& PhysicalPrinter::get_preset_names() const
return preset_names;
}

bool PhysicalPrinter::has_empty_config() const
bool PhysicalPrinter::has_empty_config() const
{
return config.opt_string("print_host" ).empty() &&
config.opt_string("printhost_apikey" ).empty() &&
config.opt_string("printhost_cafile" ).empty() &&
return config.opt_string("print_host" ).empty() &&
config.opt_string("printhost_apikey" ).empty() &&
config.opt_string("printhost_cafile" ).empty() &&
config.opt_string("printhost_port" ).empty() &&
config.opt_string("printhost_user" ).empty() &&
config.opt_string("printhost_user" ).empty() &&
config.opt_string("printhost_password").empty();
}

Expand All @@ -1451,7 +1452,7 @@ void PhysicalPrinter::update_preset_names_in_config()
name += el + ";";
name.pop_back();
config.set_key_value("preset_name", new ConfigOptionString(name));
}
}
}

void PhysicalPrinter::save(const std::string& file_name_from, const std::string& file_name_to)
Expand Down Expand Up @@ -1500,7 +1501,7 @@ bool PhysicalPrinter::delete_preset(const std::string& preset_name)
return preset_names.erase(preset_name) > 0;
}

PhysicalPrinter::PhysicalPrinter(const std::string& name, const DynamicPrintConfig& default_config) :
PhysicalPrinter::PhysicalPrinter(const std::string& name, const DynamicPrintConfig& default_config) :
name(name), config(default_config)
{
update_from_config(config);
Expand Down Expand Up @@ -1557,7 +1558,7 @@ PhysicalPrinterCollection::PhysicalPrinterCollection( const std::vector<std::str
// Throws an exception on error.
void PhysicalPrinterCollection::load_printers(const std::string& dir_path, const std::string& subdir)
{
// Don't use boost::filesystem::canonical() on Windows, it is broken in regard to reparse points,
// Don't use boost::filesystem::canonical() on Windows, it is broken in regard to reparse points,
// see https://github.com/prusa3d/PrusaSlicer/issues/732
boost::filesystem::path dir = boost::filesystem::absolute(boost::filesystem::path(dir_path) / subdir).make_preferred();
m_dir_path = dir.string();
Expand Down Expand Up @@ -1709,7 +1710,7 @@ PhysicalPrinter* PhysicalPrinterCollection::find_printer_with_same_config(const
for (const char *opt : legacy_print_host_options)
if (is_equal && printer.config.opt_string(opt) != config.opt_string(opt))
is_equal = false;

if (is_equal)
return find_printer(printer.name);
}
Expand All @@ -1725,7 +1726,7 @@ std::string PhysicalPrinterCollection::path_from_name(const std::string& new_nam

void PhysicalPrinterCollection::save_printer(PhysicalPrinter& edited_printer, const std::string& renamed_from/* = ""*/)
{
// controll and update preset_names in edited_printer config
// controll and update preset_names in edited_printer config
edited_printer.update_preset_names_in_config();

std::string name = renamed_from.empty() ? edited_printer.name : renamed_from;
Expand Down Expand Up @@ -1817,7 +1818,7 @@ std::vector<std::string> PhysicalPrinterCollection::get_printers_with_preset(con

for (auto printer : m_printers) {
if (printer.preset_names.size() == 1)
continue;
continue;
if (printer.preset_names.find(preset_name) != printer.preset_names.end())
printers.emplace_back(printer.name);
}
Expand Down Expand Up @@ -1887,7 +1888,7 @@ void PhysicalPrinterCollection::unselect_printer()

bool PhysicalPrinterCollection::is_selected(PhysicalPrinterCollection::ConstIterator it, const std::string& preset_name) const
{
return m_idx_selected == size_t(it - m_printers.begin()) &&
return m_idx_selected == size_t(it - m_printers.begin()) &&
m_selected_preset == preset_name;
}

Expand Down
42 changes: 42 additions & 0 deletions src/libslic3r/PrintConfig.cpp
Expand Up @@ -1809,6 +1809,48 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionInt(0));

// RaftingEdition
def = this->add("raft_overhangs", coBool);
def->label = L("Bridge flow above raft");
def->category = L("Support material");
def->tooltip = L("Use bridge flow and speed for the bottom layer. Quality of the layer improves significantly when this setting is off, however it could be difficult to remove the object from raft. Ignored for soluble interface.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));

def = this->add("raft_contact_distance", coFloat);
def->label = L("Raft contact Z distance");
def->category = L("Support material");
def->tooltip = L("The vertical distance between object and raft. Ignored for soluble interface.");
def->sidetext = L("mm");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0.1));

def = this->add("raft_xy_size_compensation", coFloat);
def->label = L("Bottom layer expansion");
def->category = L("Support material");
def->tooltip = L("XY plane expansion of the bottom layer. This is useful to compensate shrinking, especially for higher contact Z distances and / or specific materials.");
def->sidetext = L("mm");
def->min = 0;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0.0));

def = this->add("raft_size_adjust", coEnum);
def->label = L("Raft size");
def->category = L("Support material");
def->tooltip = L("Raft size adjustment. Can be used to improve adhesion or reduce material consumption / save some printing area.");
def->enum_keys_map = &ConfigOptionEnum<RaftSizeAdjust>::get_enum_values();
def->enum_values.push_back("small");
def->enum_values.push_back("normal");
def->enum_values.push_back("large");
def->enum_values.push_back("extralarge");
def->enum_labels.push_back("Small");
def->enum_labels.push_back("Normal");
def->enum_labels.push_back("Large");
def->enum_labels.push_back("Extra large");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<RaftSizeAdjust>(rsaNormal));

def = this->add("resolution", coFloat);
def->label = L("Resolution");
def->tooltip = L("Minimum detail resolution, used to simplify the input file for speeding up "
Expand Down
51 changes: 39 additions & 12 deletions src/libslic3r/PrintConfig.hpp
Expand Up @@ -110,6 +110,13 @@ enum BrimType {
btOuterAndInner,
};

enum RaftSizeAdjust {
rsaSmall,
rsaNormal,
rsaLarge,
rsaExtraLarge
};

template<> inline const t_config_enum_values& ConfigOptionEnum<PrinterTechnology>::get_enum_values() {
static t_config_enum_values keys_map;
if (keys_map.empty()) {
Expand Down Expand Up @@ -282,6 +289,18 @@ template<> inline const t_config_enum_values& ConfigOptionEnum<BrimType>::get_en
return keys_map;
}

template<> inline const t_config_enum_values& ConfigOptionEnum<RaftSizeAdjust>::get_enum_values() {
static const t_config_enum_values keys_map = {
{ "small", rsaSmall },
{ "normal", rsaNormal },
{ "large", rsaLarge },
{ "extralarge", rsaExtraLarge }
};

return keys_map;
}


// Defines each and every confiuration option of Slic3r, including the properties of the GUI dialogs.
// Does not store the actual values, but defines default values.
class PrintConfigDef : public ConfigDef
Expand Down Expand Up @@ -512,6 +531,10 @@ class PrintObjectConfig : public StaticPrintConfig
ConfigOptionBool interface_shells;
ConfigOptionFloat layer_height;
ConfigOptionInt raft_layers;
ConfigOptionBool raft_overhangs;
ConfigOptionFloat raft_contact_distance;
ConfigOptionFloat raft_xy_size_compensation;
ConfigOptionEnum<RaftSizeAdjust> raft_size_adjust;
ConfigOptionEnum<SeamPosition> seam_position;
// ConfigOptionFloat seam_preferred_direction;
// ConfigOptionFloat seam_preferred_direction_jitter;
Expand Down Expand Up @@ -563,6 +586,10 @@ class PrintObjectConfig : public StaticPrintConfig
OPT_PTR(interface_shells);
OPT_PTR(layer_height);
OPT_PTR(raft_layers);
OPT_PTR(raft_overhangs);
OPT_PTR(raft_contact_distance);
OPT_PTR(raft_xy_size_compensation);
OPT_PTR(raft_size_adjust);
OPT_PTR(seam_position);
OPT_PTR(slice_closing_radius);
// OPT_PTR(seam_preferred_direction);
Expand Down Expand Up @@ -1120,7 +1147,7 @@ class SLAPrintObjectConfig : public StaticPrintConfig
// The percentage of smaller pillars compared to the normal pillar diameter
// which are used in problematic areas where a normal pilla cannot fit.
ConfigOptionPercent support_small_pillar_diameter_percent;

// How much bridge (supporting another pinhead) can be placed on a pillar.
ConfigOptionInt support_max_bridges_on_pillar;

Expand Down Expand Up @@ -1172,7 +1199,7 @@ class SLAPrintObjectConfig : public StaticPrintConfig

// The height of the pad from the bottom to the top not considering the pit
ConfigOptionFloat pad_wall_height /*= 5*/;

// How far should the pad extend around the contained geometry
ConfigOptionFloat pad_brim_size;

Expand All @@ -1196,7 +1223,7 @@ class SLAPrintObjectConfig : public StaticPrintConfig

// Disable the elevation (ignore its value) and use the zero elevation mode
ConfigOptionBool pad_around_object;

ConfigOptionBool pad_around_object_everywhere;

// This is the gap between the object bottom and the generated pad
Expand All @@ -1210,7 +1237,7 @@ class SLAPrintObjectConfig : public StaticPrintConfig

// How much should the tiny connectors penetrate into the model body
ConfigOptionFloat pad_object_connector_penetration;

// /////////////////////////////////////////////////////////////////////////
// Model hollowing parameters:
// - Models can be hollowed out as part of the SLA print process
Expand All @@ -1219,17 +1246,17 @@ class SLAPrintObjectConfig : public StaticPrintConfig
// - Additional holes will be drilled into the hollow model to allow for
// - resin removal.
// /////////////////////////////////////////////////////////////////////////

ConfigOptionBool hollowing_enable;
// The minimum thickness of the model walls to maintain. Note that the

// The minimum thickness of the model walls to maintain. Note that the
// resulting walls may be thicker due to smoothing out fine cavities where
// resin could stuck.
ConfigOptionFloat hollowing_min_thickness;

// Indirectly controls the voxel size (resolution) used by openvdb
ConfigOptionFloat hollowing_quality;

// Indirectly controls the minimum size of created cavities.
ConfigOptionFloat hollowing_closing_distance;

Expand Down Expand Up @@ -1451,13 +1478,13 @@ Points get_bed_shape(const SLAPrinterConfig &cfg);
// ModelConfig is a wrapper around DynamicPrintConfig with an addition of a timestamp.
// Each change of ModelConfig is tracked by assigning a new timestamp from a global counter.
// The counter is used for faster synchronization of the background slicing thread
// with the front end by skipping synchronization of equal config dictionaries.
// The global counter is also used for avoiding unnecessary serialization of config
// with the front end by skipping synchronization of equal config dictionaries.
// The global counter is also used for avoiding unnecessary serialization of config
// dictionaries when taking an Undo snapshot.
//
// The global counter is NOT thread safe, therefore it is recommended to use ModelConfig from
// the main thread only.
//
//
// As there is a global counter and it is being increased with each change to any ModelConfig,
// if two ModelConfig dictionaries differ, they should differ with their timestamp as well.
// Therefore copying the ModelConfig including its timestamp is safe as there is no harm
Expand Down

0 comments on commit 8e9526e

Please sign in to comment.