Skip to content

Commit

Permalink
2.4 fixes. also brim speed/accel
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Mar 31, 2022
2 parents 5d375c9 + 76e78c2 commit 6fcfe8f
Show file tree
Hide file tree
Showing 22 changed files with 288 additions and 2,468 deletions.
2 changes: 2 additions & 0 deletions resources/ui_layout/default/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ group:label_width$8:sidetext_width$7:Speed for print moves
line:Support speed
setting:width$4:support_material_speed
setting:width$4:support_material_interface_speed
setting:width$4:brim_speed
line:Bridge speed
setting:width$4:bridge_speed
setting:width$4:bridge_speed_internal
Expand Down Expand Up @@ -315,6 +316,7 @@ group:label_width$9:sidetext_width$8:Acceleration control (advanced)
line:Support acceleration
setting:width$4:support_material_acceleration
setting:width$4:support_material_interface_acceleration
setting:width$4:brim_acceleration
line:Bridge acceleration
setting:width$4:bridge_acceleration
setting:width$4:bridge_internal_acceleration
Expand Down
2 changes: 1 addition & 1 deletion resources/ui_layout/default/version.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = Standard
version = 2.4.58.1
version = 2.4.58.2
description = Default layout for superslicer.

2 changes: 2 additions & 0 deletions resources/ui_layout/example/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ group:label_width$8:sidetext_width$7:Speed for print moves
line:Support speed
setting:width$4:support_material_speed
setting:width$4:support_material_interface_speed
setting:width$4:brim_speed
line:Bridge speed
setting:width$4:bridge_speed
setting:width$4:bridge_speed_internal
Expand Down Expand Up @@ -315,6 +316,7 @@ group:label_width$9:sidetext_width$8:Acceleration control (advanced)
line:Support acceleration
setting:width$4:support_material_acceleration
setting:width$4:support_material_interface_acceleration
setting:width$4:brim_acceleration
line:Bridge acceleration
setting:width$4:bridge_acceleration
setting:width$4:bridge_internal_acceleration
Expand Down
2 changes: 1 addition & 1 deletion resources/ui_layout/example/version.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = Example of another layout
version = 2.4.58.1
version = 2.4.58.2
description = More tags for ps/susi only settings, example of new quick settings.

31 changes: 30 additions & 1 deletion src/libslic3r/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,37 @@ void AppConfig::set_defaults()
if (get("drop_project_action").empty())
set("drop_project_action", "1");

if (get("freecad_path").empty())
if (get("freecad_path").empty() || get("freecad_path") == ".") {
set("freecad_path", ".");
//try to find it
#ifdef _WIN32
//windows
boost::filesystem::path prg_files = "C:/Program Files";
boost::filesystem::path freecad_path;
if (boost::filesystem::exists(prg_files)) {
for (boost::filesystem::directory_entry& prg_dir : boost::filesystem::directory_iterator(prg_files)) {
if (prg_dir.status().type() == boost::filesystem::file_type::directory_file
&& boost::starts_with(prg_dir.path().filename().string(), "FreeCAD")
&& (freecad_path.empty() || freecad_path.filename().string() < prg_dir.path().filename().string())) {
freecad_path = prg_dir.path();
}
}
}
if (!freecad_path.empty())
set("freecad_path", freecad_path.string());
#else
#ifdef __APPLE__
//apple
if (boost::filesystem::exists("/Applications/FreeCAD.app/Contents/Frameworks/FreeCAD"))
set("freecad_path", "/Applications/FreeCAD.app/Contents/Frameworks/FreeCAD");

#else
// linux
if (boost::filesystem::exists("/usr/local/bin/FreeCAD"))
set("freecad_path", "/usr/local/bin/FreeCAD");
#endif
#endif
}

if (get("show_overwrite_dialog").empty())
set("show_overwrite_dialog", "1");
Expand Down
8 changes: 8 additions & 0 deletions src/libslic3r/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,14 @@ size_t ConfigBase::load_from_gcode_string_legacy(ConfigBase& config, const char*
}
catch (UnknownOptionException & /* e */) {
// ignore
} catch (BadOptionValueException & e) {
if (substitutions.rule == ForwardCompatibilitySubstitutionRule::Disable)
throw e;
// log the error
const ConfigDef* def = config.def();
if (def == nullptr) throw e;
const ConfigOptionDef* optdef = def->get(std::string(key, key_end));
substitutions.substitutions.emplace_back(optdef, std::string(value, end), ConfigOptionUniquePtr(optdef->default_value->clone()));
}
end = start;
}
Expand Down
38 changes: 26 additions & 12 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,10 +943,8 @@ namespace DoExport {
excluded.insert(erMixed);
excluded.insert(erNone);
excluded.insert(erWipeTower);
if (config->option("perimeter_speed") != nullptr && config->get_computed_value("perimeter_speed") != 0) {
if (config->option("perimeter_speed") != nullptr && config->get_computed_value("perimeter_speed") != 0)
excluded.insert(erPerimeter);
excluded.insert(erSkirt);
}
if (config->option("external_perimeter_speed") != nullptr && config->get_computed_value("external_perimeter_speed") != 0)
excluded.insert(erExternalPerimeter);
if (config->option("overhangs_speed") != nullptr && config->get_computed_value("overhangs_speed") != 0)
Expand All @@ -969,6 +967,8 @@ namespace DoExport {
excluded.insert(erSupportMaterial);
if (config->option("support_material_interface_speed") != nullptr && config->get_computed_value("support_material_interface_speed") != 0)
excluded.insert(erSupportMaterialInterface);
if (config->option("brim_speed") != nullptr && config->get_computed_value("brim_speed") != 0)
excluded.insert(erSkirt);
}
virtual void use(const ExtrusionPath& path) override {
if (excluded.find(path.role()) == excluded.end())
Expand Down Expand Up @@ -2982,8 +2982,7 @@ GCode::LayerResult GCode::process_layer(
path.height = layer_skirt_flow.height();
path.mm3_per_mm = mm3_per_mm;
}
//FIXME using the support_material_speed of the 1st object printed.
gcode += this->extrude_loop(loop, "", m_config.support_material_speed.value);
gcode += this->extrude_loop(loop, "");
}
m_avoid_crossing_perimeters.use_external_mp(false);
// Allow a straight travel move to the first object point if this is the first layer (but don't in next layers).
Expand All @@ -3000,7 +2999,7 @@ GCode::LayerResult GCode::process_layer(
for (const ExtrusionEntity* brim_entity : print.brim().entities()) {
//if first layer, ask for a bigger lift for travel to each brim, to be on the safe side
set_extra_lift(m_last_layer_z, layer.id(), print.config(), m_writer, extruder_id);
gcode += this->extrude_entity(*brim_entity, "Brim", m_config.support_material_speed.value);
gcode += this->extrude_entity(*brim_entity, "Brim");
}
m_brim_done = true;
m_avoid_crossing_perimeters.use_external_mp(false);
Expand All @@ -3019,10 +3018,10 @@ GCode::LayerResult GCode::process_layer(
if (this->m_layer != nullptr && (this->m_layer->id() < m_config.skirt_height || print.has_infinite_skirt() )) {
if(first_layer && print.skirt_first_layer())
for (const ExtrusionEntity* ee : print_object->skirt_first_layer()->entities())
gcode += this->extrude_entity(*ee, "", m_config.support_material_speed.value);
gcode += this->extrude_entity(*ee, "");
else
for (const ExtrusionEntity *ee : print_object->skirt().entities())
gcode += this->extrude_entity(*ee, "", m_config.support_material_speed.value);
gcode += this->extrude_entity(*ee, "");
}
}
//extrude object-only brim
Expand All @@ -3034,7 +3033,7 @@ GCode::LayerResult GCode::process_layer(
if (this->m_layer != nullptr && this->m_layer->id() == 0) {
m_avoid_crossing_perimeters.use_external_mp(true);
for (const ExtrusionEntity *ee : print_object->brim().entities())
gcode += this->extrude_entity(*ee, "brim", m_config.support_material_speed.value);
gcode += this->extrude_entity(*ee, "brim");
m_avoid_crossing_perimeters.use_external_mp(false);
m_avoid_crossing_perimeters.disable_once();
}
Expand Down Expand Up @@ -4197,8 +4196,8 @@ std::string GCode::extrude_support(const ExtrusionEntityCollection &support_fill

std::string gcode;
if (! support_fills.entities().empty()) {
const double support_speed = m_config.support_material_speed.value;
const double support_interface_speed = m_config.support_material_interface_speed.get_abs_value(support_speed);
const double support_speed = m_config.get_computed_value("support_material_speed");
const double support_interface_speed = m_config.get_computed_value("support_material_interface_speed");
for (const ExtrusionEntity *ee : support_fills.entities()) {
ExtrusionRole role = ee->role();
assert(role == erSupportMaterial || role == erSupportMaterialInterface || role == erMixed);
Expand Down Expand Up @@ -4466,6 +4465,12 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee
speed = m_config.get_computed_value("travel_speed");
} else if (path.role() == erMilling) {
speed = m_config.get_computed_value("milling_speed");
} else if (path.role() == erSupportMaterial) {
speed = m_config.get_computed_value("support_material_speed");
} else if (path.role() == erSupportMaterialInterface) {
speed = m_config.get_computed_value("support_material_interface_speed");
} else if (path.role() == erSkirt) {
speed = m_config.get_computed_value("brim_speed");
} else {
throw Slic3r::InvalidArgument("Invalid speed");
}
Expand Down Expand Up @@ -4622,7 +4627,6 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string
}
goto topSolidInfill;
case erSupportMaterial:
case erSkirt:
case erWipeTower:
supportMaterial:
if (m_config.support_material_acceleration.value > 0) {
Expand All @@ -4640,6 +4644,16 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string
}
}
goto supportMaterial;
case erSkirt:
//skirtBrim:
if (m_config.brim_acceleration.value > 0) {
double brim_acceleration = m_config.get_computed_value("brim_acceleration");
if (brim_acceleration > 0) {
acceleration = brim_acceleration;
break;
}
}
goto supportMaterial;
case erBridgeInfill:
bridgeInfill:
if (m_config.bridge_acceleration.value > 0) {
Expand Down
19 changes: 13 additions & 6 deletions src/libslic3r/GCode/SeamPlacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,35 +551,42 @@ Point SeamPlacer::calculate_seam(const Layer& layer, SeamPosition seam_position,
// Look for all lambda-seam-modifiers below current z, choose the highest one
ModelVolume* v_lambda_seam = nullptr;
Vec3d lambda_pos;
double lambda_z;
double lambda_dist;
double lambda_radius;
//get model_instance (like from po->model_object()->instances, but we don't have the index for that array)
const ModelInstance* model_instance = po->instances()[print_object_instance_idx].model_instance;
for (ModelVolume* v : po->model_object()->volumes) {
if (v->is_seam_position()) {
//xy in object coordinates, z in plater coordinates
Vec3d test_lambda_pos = model_instance->transform_vector(v->get_offset(), true);
// created/moved shpere have offset in their transformation, and loaded ones have their loaded transformation in the source transformation.
Vec3d test_lambda_pos = model_instance->transform_vector((v->get_transformation() * v->source.transform).get_offset(), false);
// remove shift, as we used the transform_vector(.., FALSE). that way, we have a correct z vs the layer height, and same for the x and y vs polygon.
test_lambda_pos.x() -= unscaled(po->instances()[print_object_instance_idx].shift.x());
test_lambda_pos.y() -= unscaled(po->instances()[print_object_instance_idx].shift.y());

double test_lambda_z = std::abs(layer.print_z - test_lambda_pos.z());
Point xy_lambda(scale_(test_lambda_pos.x()), scale_(test_lambda_pos.y()));
Point nearest = polygon.point_projection(xy_lambda);
Vec3d polygon_3dpoint{ unscaled(nearest.x()), unscaled(nearest.y()), (double)layer.print_z };
double test_lambda_dist = (polygon_3dpoint - test_lambda_pos).norm();
double sphere_radius = po->model_object()->instance_bounding_box(0, true).size().x() / 2;
//if (test_lambda_dist > sphere_radius)
// continue;

//use this one if the first or nearer (in z)
if (v_lambda_seam == nullptr || lambda_dist > test_lambda_dist) {

//use this one if the first or nearer (in z, or in xy if same z)
if (v_lambda_seam == nullptr
|| ( lambda_z > test_lambda_z )
|| ( lambda_z == test_lambda_z && lambda_dist > test_lambda_dist ) ){
v_lambda_seam = v;
lambda_pos = test_lambda_pos;
lambda_radius = sphere_radius;
lambda_dist = test_lambda_dist;
lambda_z = test_lambda_z;
}
}
}

if (v_lambda_seam != nullptr) {
lambda_pos = model_instance->transform_vector(v_lambda_seam->get_offset(), true);
// Found, get the center point and apply rotation and scaling of Model instance. Continues to spAligned if not found or Weight set to Zero.
last_pos = Point::new_scale(lambda_pos.x(), lambda_pos.y());
// Weight is set by user and stored in the radius of the sphere
Expand Down
Loading

0 comments on commit 6fcfe8f

Please sign in to comment.