diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index fcb868f74..b709934bb 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -3552,8 +3552,6 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s // extrude along the path std::string gcode; for (ExtrusionPaths::iterator path = paths.begin(); path != paths.end(); ++path) { -// description += ExtrusionLoop::role_to_string(loop.loop_role()); -// description += ExtrusionEntity::role_to_string(path->role); path->simplify(SCALED_RESOLUTION); gcode += this->_extrude(*path, description, speed); } @@ -3649,8 +3647,6 @@ std::string GCode::extrude_multi_path(const ExtrusionMultiPath &multipath, const // extrude along the path std::string gcode; for (ExtrusionPath path : multipath.paths) { -// description += ExtrusionLoop::role_to_string(loop.loop_role()); -// description += ExtrusionEntity::role_to_string(path->role); path.simplify(SCALED_RESOLUTION); gcode += this->_extrude(path, description, speed); } @@ -3725,24 +3721,24 @@ void GCode::use(const ExtrusionEntityCollection &collection) { std::string extrusion_role_2_string(const ExtrusionRole &er) { switch (er) { - case erNone: return " none"; - case erPerimeter: return " perimeter"; - case erExternalPerimeter: return " perimeter external"; - case erOverhangPerimeter: return " perimeter overhang"; - case erInternalInfill: return " infill internal"; - case erSolidInfill: return " infill solid"; - case erTopSolidInfill: return " infill solid top"; - case erBridgeInfill: return " infill bridge"; - case erThinWall: return " thin_wall"; - case erGapFill: return " gap_fill"; - case erSkirt: return " skirt"; - case erSupportMaterial: return " support_material"; - case erSupportMaterialInterface: return " support_material_interface"; - case erWipeTower: return " wipe_tower"; - case erMilling: return " milling"; - case erCustom: return " custom"; - case erMixed: return " mixed"; - case erCount: return " count"; + case erNone: return "none"; + case erPerimeter: return "perimeter"; + case erExternalPerimeter: return "perimeter external"; + case erOverhangPerimeter: return "perimeter overhang"; + case erInternalInfill: return "infill internal"; + case erSolidInfill: return "infill solid"; + case erTopSolidInfill: return "infill solid top"; + case erBridgeInfill: return "infill bridge"; + case erThinWall: return "thin_wall"; + case erGapFill: return "gap_fill"; + case erSkirt: return "skirt"; + case erSupportMaterial: return "support_material"; + case erSupportMaterialInterface: return "support_material_interface"; + case erWipeTower: return "wipe_tower"; + case erMilling: return "milling"; + case erCustom: return "custom"; + case erMixed: return "mixed"; + case erCount: return "count"; } return " unkown"; } @@ -3902,7 +3898,7 @@ void GCode::_write(FILE* file, const char *what) //const char * gcode_pp = _post_process(what).c_str(); std::string str_preproc{ what }; - //_post_process(str_preproc); + _post_process(str_preproc); const std::string str_ana = m_analyzer.process_gcode(str_preproc); @@ -3980,7 +3976,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &descri double e_per_mm = path.mm3_per_mm * m_writer.tool()->e_per_mm3() * this->config().print_extrusion_multiplier.get_abs_value(1); - if (this->m_layer_index <= 0) e_per_mm *= this->config().first_layer_flow_ratio.get_abs_value(1); + if (std::abs(this->m_layer->height - this->m_layer->print_z) < EPSILON) e_per_mm *= this->config().first_layer_flow_ratio.get_abs_value(1); if (m_writer.extrusion_axis().empty()) e_per_mm = 0; if (path.polyline.lines().size() > 0) { //get last direction //TODO: save it @@ -4009,7 +4005,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &descri // the coeff is below 0.01 i the angle is higher than 125, so it's not useful if (idx_angle > 60) { //don't compensate if the angle is under 35, as it's already a 50% compensation, it's enough! - if (idx_angle > 144) angle = 144; + if (idx_angle > 144) idx_angle = 144; //surface extruded in path.width is path.width * path.width // define R = path.width/2 and a = angle/2 // then i have to print only 4RR + RR(2a-sin(2a))/2 - RR*sina*sina*tana if i want to remove the bits out of the external curve, if the internal overlap go to the exterior. @@ -4020,7 +4016,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string &descri //double removed = std::sin(A); removed = removed * removed * std::tan(A) / 4; //double coeff = 1. + added - removed; //we have to remove coeff percentage on path.width length - double coeff = cut_corner_cache[idx_angle]; + double coeff = cut_corner_cache[idx_angle-30]; //the length, do half of the work on width/4 and the other half on width/2 coordf_t length1 = (path.width) / 4; coordf_t line_length = unscaled(line.length()); diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index fbcdb4a41..a87635a2c 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -545,6 +545,8 @@ std::string GCodeWriter::_retract(double length, double restart_extra, const std } double dE = m_tool->retract(length, restart_extra); + assert(dE >= 0); + assert(dE < 10000000); if (dE != 0) { if (this->config.use_firmware_retraction) { if (FLAVOR_IS(gcfMachinekit)) @@ -573,6 +575,8 @@ std::string GCodeWriter::unretract() gcode << "M101 ; extruder on\n"; double dE = m_tool->unretract(); + assert(dE >= 0); + assert(dE < 10000000); if (dE != 0) { if (this->config.use_firmware_retraction) { if (FLAVOR_IS(gcfMachinekit)) diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 5bbbc5f3a..1d818b639 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -280,7 +280,6 @@ void PerimeterGenerator::process() if (!unsupported_filtered.empty()) { - //add this directly to the infill list. // this will avoid to throw wrong offsets into a good polygons this->fill_surfaces->append( @@ -308,9 +307,7 @@ void PerimeterGenerator::process() } else { surface->expolygon = last[0]; for (size_t idx = 1; idx < last.size(); idx++) { - Surface new_surf = *surface; - new_surf.expolygon = last[idx]; - all_surfaces.push_back(new_surf); + all_surfaces.emplace_back(*surface, last[idx]); } } } @@ -438,7 +435,7 @@ void PerimeterGenerator::process() // look for thin walls if (this->config->thin_walls) { // detect edge case where a curve can be split in multiple small chunks. - std::vector divs = {2.2f,1.75f,1.5f}; //don't go too far, it's not possible to print thinw wall after that + std::vector divs = { 2.1f, 1.9f, 2.2f, 1.75f, 1.5f}; //don't go too far, it's not possible to print thin wall after that size_t idx_div = 0; while (next_onion.size() > last.size() && idx_div < divs.size()) { float div = divs[idx_div]; @@ -447,7 +444,7 @@ void PerimeterGenerator::process() last, -(float)((ext_perimeter_width / 2) + (ext_min_spacing / div) - 1), +(float)((ext_min_spacing / div) - 1)); - if (next_onion.size() > next_onion_secondTry.size() * 1.2 || next_onion.size() - next_onion_secondTry.size() > 3) { + if (next_onion.size() > next_onion_secondTry.size() * 1.2 && next_onion.size() > next_onion_secondTry.size() + 2) { next_onion = next_onion_secondTry; } idx_div++; diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index c2692fbd9..e99753631 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1372,17 +1372,17 @@ std::pair Print::validate() const for (size_t i = 1; i < m_objects.size(); ++ i) { const PrintObject *object = m_objects[i]; const SlicingParameters &slicing_params = object->slicing_parameters(); - if (std::abs(slicing_params.first_print_layer_height - slicing_params0.first_print_layer_height) > EPSILON || - std::abs(slicing_params.layer_height - slicing_params0.layer_height ) > EPSILON) - return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they have equal layer heights") }; - if (slicing_params.raft_layers() != slicing_params0.raft_layers()) - return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are printed over an equal number of raft layers") }; - if (object->config().support_material_contact_distance_type != m_objects.front()->config().support_material_contact_distance_type - || object->config().support_material_contact_distance_top != m_objects.front()->config().support_material_contact_distance_top - || object->config().support_material_contact_distance_bottom != m_objects.front()->config().support_material_contact_distance_bottom) - return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are printed with the same support_material_contact_distance") }; - if (! equal_layering(slicing_params, slicing_params0)) - return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are sliced equally.") }; + if (std::abs(slicing_params.first_print_layer_height - slicing_params0.first_print_layer_height) > EPSILON || + std::abs(slicing_params.layer_height - slicing_params0.layer_height ) > EPSILON) + return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they have equal layer heights") }; + if (slicing_params.raft_layers() != slicing_params0.raft_layers()) + return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are printed over an equal number of raft layers") }; + if (object->config().support_material_contact_distance_type != m_objects.front()->config().support_material_contact_distance_type + || object->config().support_material_contact_distance_top != m_objects.front()->config().support_material_contact_distance_top + || object->config().support_material_contact_distance_bottom != m_objects.front()->config().support_material_contact_distance_bottom) + return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are printed with the same support_material_contact_distance") }; + if (! equal_layering(slicing_params, slicing_params0)) + return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are sliced equally.") }; if (has_custom_layering) { PrintObject::update_layer_height_profile(*object->model_object(), slicing_params, layer_height_profiles[i]); if (*(layer_height_profiles[i].end()-2) > *(layer_height_profiles[tallest_object_idx].end()-2)) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 91bf590ff..7cbf6f039 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1839,7 +1839,7 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back(L("Automatic, only for small areas")); def->enum_labels.push_back(L("Anchored")); def->mode = comAdvanced; - def->set_default_value(new ConfigOptionEnum(dfaAutomatic)); + def->set_default_value(new ConfigOptionEnum(dfaAutoNotFull)); def = this->add("infill_extruder", coInt); def->label = L("Infill extruder"); diff --git a/src/libslic3r/Slicing.hpp b/src/libslic3r/Slicing.hpp index 1dff6aed3..e393c679c 100644 --- a/src/libslic3r/Slicing.hpp +++ b/src/libslic3r/Slicing.hpp @@ -110,27 +110,27 @@ inline bool equal_layering(const SlicingParameters &sp1, const SlicingParameters { assert(sp1.valid); assert(sp2.valid); - return sp1.base_raft_layers == sp2.base_raft_layers && - sp1.interface_raft_layers == sp2.interface_raft_layers && - sp1.base_raft_layer_height == sp2.base_raft_layer_height && - sp1.interface_raft_layer_height == sp2.interface_raft_layer_height && - sp1.contact_raft_layer_height == sp2.contact_raft_layer_height && - sp1.contact_raft_layer_height_bridging == sp2.contact_raft_layer_height_bridging && - sp1.layer_height == sp2.layer_height && - sp1.min_layer_height == sp2.min_layer_height && - sp1.max_layer_height == sp2.max_layer_height && -// sp1.max_suport_layer_height == sp2.max_suport_layer_height && - sp1.first_print_layer_height == sp2.first_print_layer_height && - sp1.first_object_layer_height == sp2.first_object_layer_height && - sp1.first_object_layer_bridging == sp2.first_object_layer_bridging && - sp1.soluble_interface == sp2.soluble_interface && - sp1.gap_raft_object == sp2.gap_raft_object && - sp1.gap_object_support == sp2.gap_object_support && - sp1.gap_support_object == sp2.gap_support_object && - sp1.raft_base_top_z == sp2.raft_base_top_z && - sp1.raft_interface_top_z == sp2.raft_interface_top_z && - sp1.raft_contact_top_z == sp2.raft_contact_top_z && - sp1.object_print_z_min == sp2.object_print_z_min; + return sp1.base_raft_layers == sp2.base_raft_layers && + sp1.interface_raft_layers == sp2.interface_raft_layers && + std::abs(sp1.base_raft_layer_height - sp2.base_raft_layer_height) < EPSILON && + std::abs(sp1.interface_raft_layer_height - sp2.interface_raft_layer_height) < EPSILON && + std::abs(sp1.contact_raft_layer_height - sp2.contact_raft_layer_height) < EPSILON && + sp1.contact_raft_layer_height_bridging == sp2.contact_raft_layer_height_bridging && + std::abs(sp1.layer_height - sp2.layer_height) < EPSILON && + std::abs(sp1.min_layer_height - sp2.min_layer_height) < EPSILON && + std::abs(sp1.max_layer_height - sp2.max_layer_height) < EPSILON && + // sp1.max_suport_layer_height == sp2.max_suport_layer_height && + std::abs(sp1.first_print_layer_height - sp2.first_print_layer_height) < EPSILON && + std::abs(sp1.first_object_layer_height - sp2.first_object_layer_height) < EPSILON && + sp1.first_object_layer_bridging == sp2.first_object_layer_bridging && + sp1.soluble_interface == sp2.soluble_interface && + std::abs(sp1.gap_raft_object - sp2.gap_raft_object) < EPSILON && + std::abs(sp1.gap_object_support - sp2.gap_object_support) < EPSILON && + std::abs(sp1.gap_support_object - sp2.gap_support_object) < EPSILON && + std::abs(sp1.raft_base_top_z - sp2.raft_base_top_z) < EPSILON && + std::abs(sp1.raft_interface_top_z - sp2.raft_interface_top_z) < EPSILON && + std::abs(sp1.raft_contact_top_z - sp2.raft_contact_top_z) < EPSILON && + std::abs(sp1.object_print_z_min - sp2.object_print_z_min) < EPSILON; } typedef std::pair t_layer_height_range;