From 497736affe875d41b809fdfe28931a6932829b32 Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 15 Dec 2021 18:54:15 +0100 Subject: [PATCH 01/14] fix typo: 'layer height' instead of 'first layer height' supermerill/SuperSlicer#2060 --- src/libslic3r/Print.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 904ebe45c72..9043d0cde04 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1633,7 +1633,7 @@ std::pair Print::validate() const //check not-first layer if (object->region_volumes[region_id].front().first.second > layer_height) { if (layer_height + EPSILON < min_layer_height) - return { PrintBase::PrintValidationError::pveWrongSettings, (boost::format(L("First layer height can't be higher than %s")) % "min layer height").str() }; + return { PrintBase::PrintValidationError::pveWrongSettings, (boost::format(L("Layer height can't be higher than %s")) % "min layer height").str() }; for (auto tuple : std::vector>{ {nozzle_diameter, "nozzle diameter"}, {max_layer_height, "max layer height"}, From 269ade4859f606da4dde71a6cdfd7b65a897dc9f Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 15 Dec 2021 19:28:35 +0100 Subject: [PATCH 02/14] fix div/0 in libnest2D supermerill/SuperSlicer#2053 --- src/libnest2d/include/libnest2d/geometry_traits_nfp.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libnest2d/include/libnest2d/geometry_traits_nfp.hpp b/src/libnest2d/include/libnest2d/geometry_traits_nfp.hpp index 29a1ccd047c..07b34f47d59 100644 --- a/src/libnest2d/include/libnest2d/geometry_traits_nfp.hpp +++ b/src/libnest2d/include/libnest2d/geometry_traits_nfp.hpp @@ -281,9 +281,10 @@ inline NfpResult nfpConvexOnly(const RawShape& sh, // cos function. But with the quadrant info we can get the sign back int sign = q[0] == 1 || q[0] == 2 ? -1 : 1; + // supermerill: add safe-check for when two points are on the same position // If Ratio is an actual rational type, there is no precision loss - auto pcos1 = Ratio(lcos[0]) / lsq1 * sign * lcos[0]; - auto pcos2 = Ratio(lcos[1]) / lsq2 * sign * lcos[1]; + auto pcos1 = lsq1 != 0 ? Ratio(lcos[0]) / lsq1 * sign * lcos[0] : 1 * sign * lcos[0]; + auto pcos2 = lsq2 != 0 ? Ratio(lcos[1]) / lsq2 * sign * lcos[1] : 1 * sign * lcos[1]; return q[0] < 2 ? pcos1 < pcos2 : pcos1 > pcos2; } From b9e384519d12e1cb0e26f14b85cd7ef762b8e124 Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 15 Dec 2021 16:40:14 +0100 Subject: [PATCH 03/14] fix retract_lift_first_layer tooltip --- src/libslic3r/PrintConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 7d797445714..5f980ae337f 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3476,7 +3476,7 @@ void PrintConfigDef::init_fff_params() def->full_label = L("Enforce lift on first layer"); def->category = OptionCategory::extruders; def->tooltip = L("Select this option to enforce z-lift on the first layer." - "\nIf this is enabled and the lift value is 0 or deactivated, then every first move before each object will be lifted by the first layer height."); + "\nUseful to still use the lift on the first layer even if the 'Only lift Z below' (retract_lift_above) is higher than 0."); def->mode = comAdvanced; def->is_vector_extruder = true; def->set_default_value(new ConfigOptionBools{ false }); From 773e059c39b386e04bfcf96fc2c71046aa087eae Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 15 Dec 2021 19:02:39 +0100 Subject: [PATCH 04/14] perimeter_round_corners: keep clipper::mitter for first perimeter supermerill/superslicer#2046 --- src/libslic3r/PerimeterGenerator.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 6ba0c0815a3..3aeed59dae3 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -492,15 +492,15 @@ void PerimeterGenerator::process() next_onion = offset_ex( last, -(float)(ext_perimeter_width / 2), - (round_peri ? ClipperLib::JoinType::jtRound : ClipperLib::JoinType::jtMiter), - (round_peri ? min_round_spacing : 3)); + ClipperLib::JoinType::jtMiter, + 3); else next_onion = offset2_ex( last, -(float)(ext_perimeter_width / 2 + ext_min_spacing / 2 - 1), +(float)(ext_min_spacing / 2 - 1), - (round_peri ? ClipperLib::JoinType::jtRound : ClipperLib::JoinType::jtMiter), - (round_peri ? min_round_spacing : 3)); + ClipperLib::JoinType::jtMiter, + 3); // look for thin walls if (this->config->thin_walls) { @@ -569,20 +569,20 @@ void PerimeterGenerator::process() } } // use perimeters to extrude area that can't be printed by thin walls - // it's a bit like re-add thin area in to perimeter area. + // it's a bit like re-add thin area into perimeter area. // it can over-extrude a bit, but it's for a better good. { if (thin_perimeter) next_onion = union_ex(next_onion, offset_ex(diff_ex(last, thins, true), -(float)(ext_perimeter_width / 2), - (round_peri ? ClipperLib::JoinType::jtRound : ClipperLib::JoinType::jtMiter), - (round_peri ? min_round_spacing : 3))); + ClipperLib::JoinType::jtMiter, + 3)); else next_onion = union_ex(next_onion, offset2_ex(diff_ex(last, thins, true), -(float)((ext_perimeter_width / 2) + (ext_min_spacing / 4)), (float)(ext_min_spacing / 4), - (round_peri ? ClipperLib::JoinType::jtRound : ClipperLib::JoinType::jtMiter), - (round_peri ? min_round_spacing : 3))); + ClipperLib::JoinType::jtMiter, + 3)); next_onion = intersection_ex(next_onion, last); } From 59747ac40c82195d739f79c63ac11d04750176e3 Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 15 Dec 2021 19:03:46 +0100 Subject: [PATCH 05/14] fix commit 5a5ea5 --- src/libslic3r/MedialAxis.cpp | 46 +++++++++++++++++------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/libslic3r/MedialAxis.cpp b/src/libslic3r/MedialAxis.cpp index c44c1d97ad0..56a15ef54c1 100644 --- a/src/libslic3r/MedialAxis.cpp +++ b/src/libslic3r/MedialAxis.cpp @@ -499,7 +499,7 @@ MedialAxis::fusion_curve(ThickPolylines &pp) //check my length is small coord_t length = (coord_t)polyline.length(); - if (length > max_width) continue; + if (length > this->max_width) continue; size_t closest_point_idx = this->expolygon.contour.closest_point_index(polyline.points.back()); @@ -604,7 +604,7 @@ MedialAxis::remove_bits(ThickPolylines &pp) //check my length is small coordf_t length = polyline.length(); - if (length > coordf_t(max_width) * 1.5) { + if (length > coordf_t(this->max_width) * 1.5) { continue; } @@ -631,11 +631,11 @@ MedialAxis::remove_bits(ThickPolylines &pp) if (nb_better_than_me < 2) continue; //check if the length of the polyline is small vs width of the other lines - coord_t max_width = 0; + coord_t local_max_width = 0; for (int i = 0; i < crosspoint.size(); i++) { - max_width = std::max(max_width, pp[crosspoint[i]].width[0]); + local_max_width = std::max(local_max_width, pp[crosspoint[i]].width[0]); } - if (length > coordf_t(max_width + min_width)) + if (length > coordf_t(local_max_width + min_width)) continue; //delete the now unused polyline @@ -665,7 +665,7 @@ MedialAxis::fusion_corners(ThickPolylines &pp) //check my length is small coord_t length = (coord_t)polyline.length(); - if (length > max_width) continue; + if (length > this->max_width) continue; // look if other end is a cross point with multiple other branch std::vector crosspoint; @@ -764,7 +764,7 @@ MedialAxis::extends_line(ThickPolyline& polyline, const ExPolygons& anchors, con // prevent the line from touching on the other side, otherwise intersection() might return that solution if (polyline.points.size() == 2 && this->expolygon.contains(line.midpoint())) line.a = line.midpoint(); - line.extend_end((double)max_width); + line.extend_end((double)this->max_width); Point new_back; if (this->expolygon.contour.has_boundary_point(polyline.points.back())) { new_back = polyline.points.back(); @@ -842,14 +842,14 @@ MedialAxis::extends_line(ThickPolyline& polyline, const ExPolygons& anchors, con }*/ // find anchor Point best_anchor; - coordf_t shortest_dist = (coordf_t)max_width; + coordf_t shortest_dist = (coordf_t)this->max_width; for (const ExPolygon& a : anchors) { Point p_maybe_inside = a.contour.centroid(); coordf_t test_dist = new_bound.distance_to(p_maybe_inside) + new_back.distance_to(p_maybe_inside); //if (test_dist < max_width / 2 && (test_dist < shortest_dist || shortest_dist < 0)) { double angle_test = new_back.ccw_angle(p_maybe_inside, line.a); if (angle_test > PI) angle_test = 2 * PI - angle_test; - if (test_dist < max_width && test_dist PI / 2) { + if (test_dist < (coordf_t)this->max_width && test_dist PI / 2) { shortest_dist = test_dist; best_anchor = p_maybe_inside; } @@ -859,7 +859,7 @@ MedialAxis::extends_line(ThickPolyline& polyline, const ExPolygons& anchors, con p_obj.x() /= 2; p_obj.y() /= 2; Line l2 = Line(new_back, p_obj); - l2.extend_end((double)max_width); + l2.extend_end((coordf_t)this->max_width); (void)bounds->contour.first_intersection(l2, &new_bound); } if (new_bound.coincides_with_epsilon(new_back)) @@ -936,10 +936,10 @@ MedialAxis::main_fusion(ThickPolylines& pp) if ( ((polyline.points.back().distance_to(other.points.back()) + (polyline.width.back() + other.width.back()) / 4) - > max_width*1.05)) + > this->max_width *1.05)) continue; // test if the lines are not too different in length. - if (abs(polyline.length() - other.length()) > max_width) continue; + if (abs(polyline.length() - other.length()) > (coordf_t)this->max_width) continue; //test if we don't merge with something too different and without any relevance. @@ -955,7 +955,7 @@ MedialAxis::main_fusion(ThickPolylines& pp) // << (abs(polyline.length()*coeffSizePolyI - other.length()*coeffSizeOtherJ) > max_width / 2) // << (abs(polyline.length()*coeffSizePolyI - other.length()*coeffSizeOtherJ) > max_width) // << "\n"; - if (abs(polyline.length()*coeffSizePolyI - other.length()*coeffSizeOtherJ) > max_width / 2) continue; + if (abs(polyline.length()*coeffSizePolyI - other.length()*coeffSizeOtherJ) > (coordf_t)(this->max_width / 2)) continue; //compute angle to see if it's better than previous ones (straighter = better). @@ -1111,8 +1111,8 @@ MedialAxis::main_fusion(ThickPolylines& pp) //std::cout << "width:" << polyline.width[idx_point] << " = " << value_from_current_width << " + " << value_from_dist // << " (<" << max_width << " && " << (bounds.contour.closest_point(polyline.points[idx_point])->distance_to(polyline.points[idx_point]) * 2.1)<<")\n"; //failsafes - if (polyline.width[idx_point] > max_width) - polyline.width[idx_point] = max_width; + if (polyline.width[idx_point] > this->max_width) + polyline.width[idx_point] = this->max_width; //failsafe: try to not go out of the radius of the section, take the width of the merging point for that. (and with some offset) coord_t main_branch_width = pp[biggest_main_branch_id].width.front(); coordf_t main_branch_dist = pp[biggest_main_branch_id].points.front().distance_to(polyline.points[idx_point]); @@ -1249,7 +1249,7 @@ MedialAxis::remove_too_thin_extrusion(ThickPolylines& pp) changes = true; } //remove points and bits that comes from a "main line" - if (polyline.points.size() < 2 || (changes && polyline.length() < max_width && polyline.points.size() ==2)) { + if (polyline.points.size() < 2 || (changes && polyline.length() < this->max_width && polyline.points.size() ==2)) { //remove self if too small pp.erase(pp.begin() + i); --i; @@ -1468,17 +1468,15 @@ MedialAxis::remove_too_short_polylines(ThickPolylines& pp, const coord_t min_siz // know how long will the endpoints be extended since it depends on polygon thickness // which is variable - extension will be <= max_width/2 on each side) if ((polyline.endpoints.first || polyline.endpoints.second)) { - coordf_t max_width = max_width / 2; + coordf_t local_max_width = this->max_width / 2; for (coordf_t w : polyline.width) - max_width = std::max(max_width, w); - if(polyline.length() < max_width) { + local_max_width = std::max(local_max_width, w); + if(polyline.length() < local_max_width) { if (shortest_size > polyline.length()) { shortest_size = polyline.length(); shortest_idx = i; } - } - } } if (shortest_idx < pp.size()) { @@ -1490,14 +1488,14 @@ MedialAxis::remove_too_short_polylines(ThickPolylines& pp, const coord_t min_siz } void -MedialAxis::check_width(ThickPolylines& pp, coord_t max_width, std::string msg) +MedialAxis::check_width(ThickPolylines& pp, coord_t local_max_width, std::string msg) { //remove empty polyline int nb = 0; for (size_t i = 0; i < pp.size(); ++i) { for (size_t j = 0; j < pp[i].width.size(); ++j) { - if (pp[i].width[j] > coord_t(max_width * 1.01)) { - BOOST_LOG_TRIVIAL(error) << "Error " << msg << " width " << unscaled(pp[i].width[j]) << "(" << i << ":" << j << ") > " << unscaled(max_width) << "\n"; + if (pp[i].width[j] > coord_t(local_max_width * 1.01)) { + BOOST_LOG_TRIVIAL(error) << "Error " << msg << " width " << unscaled(pp[i].width[j]) << "(" << i << ":" << j << ") > " << unscaled(local_max_width) << "\n"; nb++; } } From 053ec48ff12711b4d5a6a75dd472b1e31ad25827 Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 15 Dec 2021 19:13:33 +0100 Subject: [PATCH 06/14] Fix Concentric (Filled) infill: honour gap_fill_min_area supermerill/SuperSlicer#2052 --- src/libslic3r/Fill/FillConcentric.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/Fill/FillConcentric.cpp b/src/libslic3r/Fill/FillConcentric.cpp index c8616f42fce..fd32706637a 100644 --- a/src/libslic3r/Fill/FillConcentric.cpp +++ b/src/libslic3r/Fill/FillConcentric.cpp @@ -78,6 +78,8 @@ FillConcentricWGapFill::fill_surface_extrusion( const FillParams ¶ms, ExtrusionEntitiesPtr &out) const { + double min_gapfill_area = double(params.flow.scaled_width()) * double(params.flow.scaled_width()); + if (params.config != nullptr) min_gapfill_area = scale_d(params.config->gap_fill_min_area.get_abs_value(params.flow.width)) * double(params.flow.scaled_width()); // Perform offset. Slic3r::ExPolygons expp = offset_ex(surface->expolygon, double(scale_(0 - 0.5 * this->get_spacing()))); // Create the infills for each of the regions. @@ -149,7 +151,7 @@ FillConcentricWGapFill::fill_surface_extrusion( for (const ExPolygon &ex : gaps_ex) { //remove too small gaps that are too hard to fill. //ie one that are smaller than an extrusion with width of min and a length of max. - if (ex.area() > min*max) { + if (ex.area() > min_gapfill_area) { MedialAxis{ ex, coord_t(max), coord_t(min), coord_t(params.flow.height) }.build(polylines); } } From 9e4b73f0814ffd8b439bacebd68df86989df8b03 Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 15 Dec 2021 19:19:39 +0100 Subject: [PATCH 07/14] missing includes for gentoo compilation supermerill/SuperSlicer#1931 --- src/libslic3r/AppConfig.cpp | 9 +++++---- src/libslic3r/Format/CWS.cpp | 4 ++++ src/libslic3r/GCode.cpp | 3 ++- src/libslic3r/GCode/AvoidCrossingPerimeters.cpp | 2 ++ src/libslic3r/GCodeWriter.cpp | 5 ++++- src/libslic3r/MedialAxis.cpp | 3 +++ src/libslic3r/PlaceholderParser.cpp | 3 +++ src/libslic3r/PrintBase.cpp | 2 ++ src/libslic3r/PrintObject.cpp | 2 +- src/slic3r/GUI/3DBed.cpp | 4 ++++ src/slic3r/GUI/CalibrationAbstractDialog.cpp | 4 ++++ src/slic3r/GUI/GUI_ObjectList.cpp | 2 ++ src/slic3r/GUI/PhysicalPrinterDialog.cpp | 1 + src/slic3r/GUI/Preferences.cpp | 4 ++++ src/slic3r/GUI/Search.cpp | 2 ++ src/slic3r/GUI/Tab.cpp | 7 +++++-- src/slic3r/Utils/PresetUpdater.cpp | 5 ++++- 17 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 9be3b5eaebf..df0209bb082 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -9,15 +9,16 @@ #include #include -#include +#include #include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include #ifdef WIN32 //FIXME replace the two following includes with after it becomes mainstream. diff --git a/src/libslic3r/Format/CWS.cpp b/src/libslic3r/Format/CWS.cpp index b28a47f5065..395be504402 100644 --- a/src/libslic3r/Format/CWS.cpp +++ b/src/libslic3r/Format/CWS.cpp @@ -2,6 +2,10 @@ #include "libslic3r/PrintConfig.hpp" #include "libslic3r/Time.hpp" +#include +#include +#include + namespace Slic3r { using ConfMap = std::map; diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index cd4a79af0e2..c48e11d79b4 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -16,9 +16,10 @@ #include #include +#include #include +#include #include -#include #include #include diff --git a/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp b/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp index 1d40a62bd3d..cad59bd32c4 100644 --- a/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp +++ b/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp @@ -9,6 +9,8 @@ #include "../SVG.hpp" #include "AvoidCrossingPerimeters.hpp" +#include + #include #include diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index ede145d8d43..09e45f1fe5e 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -1,10 +1,13 @@ #include "GCodeWriter.hpp" #include "CustomGCode.hpp" + +#include + #include +#include #include #include #include -#include #define FLAVOR_IS(val) this->config.gcode_flavor.value == val #define FLAVOR_IS_NOT(val) this->config.gcode_flavor.value != val diff --git a/src/libslic3r/MedialAxis.cpp b/src/libslic3r/MedialAxis.cpp index 56a15ef54c1..54c2beace98 100644 --- a/src/libslic3r/MedialAxis.cpp +++ b/src/libslic3r/MedialAxis.cpp @@ -8,6 +8,9 @@ #include "SVG.hpp" #include "polypartition.h" #include "poly2tri/poly2tri.h" + +#include + #include #include #include diff --git a/src/libslic3r/PlaceholderParser.cpp b/src/libslic3r/PlaceholderParser.cpp index c077d6cd70c..94aa32af3a0 100644 --- a/src/libslic3r/PlaceholderParser.cpp +++ b/src/libslic3r/PlaceholderParser.cpp @@ -1,11 +1,13 @@ #include "PlaceholderParser.hpp" #include "Exception.hpp" #include "Flow.hpp" + #include #include #include #include #include +#include #ifdef _MSC_VER #include // provides **_environ #else @@ -25,6 +27,7 @@ #endif #include +#include #include // Spirit v2.5 allows you to suppress automatic generation diff --git a/src/libslic3r/PrintBase.cpp b/src/libslic3r/PrintBase.cpp index e4a0b45cce4..5ca0198d54d 100644 --- a/src/libslic3r/PrintBase.cpp +++ b/src/libslic3r/PrintBase.cpp @@ -4,6 +4,8 @@ #include #include +#include + #include "I18N.hpp" //! macro used to mark string used at localization, diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 8e8a725dcd5..9aff46af962 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -14,12 +14,12 @@ #include "Fill/FillAdaptive.hpp" #include "Format/STL.hpp" +#include #include #include #include #include -#include #include diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index 54ddeac97af..b5e29302d53 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -16,7 +16,11 @@ #include #include +#include #include +#include +#include +#include static const float GROUND_Z = -0.02f; diff --git a/src/slic3r/GUI/CalibrationAbstractDialog.cpp b/src/slic3r/GUI/CalibrationAbstractDialog.cpp index 6fa3c1a6b45..385d5e0cfbb 100644 --- a/src/slic3r/GUI/CalibrationAbstractDialog.cpp +++ b/src/slic3r/GUI/CalibrationAbstractDialog.cpp @@ -5,10 +5,14 @@ #include "GUI.hpp" #include "GUI_ObjectList.hpp" #include "Tab.hpp" + #include #include #include +#include +#include + #if ENABLE_SCROLLABLE static wxSize get_screen_size(wxWindow* window) { diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index bcc1eef24c4..3d228052336 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -15,6 +15,8 @@ #include "Selection.hpp" #include +#include + #include "slic3r/Utils/FixModelByWin10.hpp" #ifdef __WXMSW__ diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.cpp b/src/slic3r/GUI/PhysicalPrinterDialog.cpp index 54701eedd94..387a3e8fba2 100644 --- a/src/slic3r/GUI/PhysicalPrinterDialog.cpp +++ b/src/slic3r/GUI/PhysicalPrinterDialog.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index a48961ee1ce..68987b44b2b 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -4,8 +4,12 @@ #include "Plater.hpp" #include "I18N.hpp" #include "libslic3r/AppConfig.hpp" + #include +#include +#include + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index 6c75eb1531c..b35efd92c5e 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -1,7 +1,9 @@ #include "Search.hpp" #include +#include #include + #include #include #include diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 7fe2c5c7bab..0f63501bcca 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -29,10 +30,12 @@ #include #include - -#include #include +#include +#include #include #include +#include + #include "wxExtensions.hpp" #include "PresetComboBoxes.hpp" #include diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index bf952bb8c22..37821d7c8ea 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -6,12 +6,15 @@ #include #include #include -#include + #include #include #include +#include #include #include +#include +#include #include #include From 45c8c3722fda56b58fd3d5ff2e7a125cb3c3479a Mon Sep 17 00:00:00 2001 From: Clayton O'Neill Date: Sat, 6 Nov 2021 09:47:50 -0400 Subject: [PATCH 08/14] Add support for building MacOS fat binaries * Fix cross compiling for GMP on Mac * Fix Apple silicon cross-compile for libcurl * Fix OpenEXR cross compile for apple silicon * Patch to cross compile libpng for Apple Silicon * Fix comment supermerill: * Test new BuildMacOS.sh script * limits macos-arm new command to macos. * add debug to BuildMacos script (like for linux) --- .github/workflows/ccpp_mac.yml | 2 +- .github/workflows/ccpp_mac_arm.yml | 28 +++++++ .github/workflows/ccpp_mac_arm_debug.yml | 31 ++++++++ .github/workflows/ccpp_mac_debug.yml | 98 ++---------------------- BuildMacOS.sh | 72 ++++++++++++++--- deps/CMakeLists.txt | 19 ++++- deps/GMP/GMP.cmake | 20 ++++- deps/MPFR/MPFR.cmake | 1 + deps/PNG/PNG.cmake | 40 +++++++--- deps/PNG/macos-arm64.patch | 65 ++++++++++++++++ deps/deps-macos.cmake | 32 ++++++-- deps/deps-unix-common.cmake | 27 ++++++- 12 files changed, 310 insertions(+), 125 deletions(-) create mode 100644 .github/workflows/ccpp_mac_arm.yml create mode 100644 .github/workflows/ccpp_mac_arm_debug.yml create mode 100644 deps/PNG/macos-arm64.patch diff --git a/.github/workflows/ccpp_mac.yml b/.github/workflows/ccpp_mac.yml index 9f64ec4fc3b..069f8122674 100644 --- a/.github/workflows/ccpp_mac.yml +++ b/.github/workflows/ccpp_mac.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: macos-latest + runs-on: macos-10.15 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/ccpp_mac_arm.yml b/.github/workflows/ccpp_mac_arm.yml new file mode 100644 index 00000000000..4c2ec279c49 --- /dev/null +++ b/.github/workflows/ccpp_mac_arm.yml @@ -0,0 +1,28 @@ +name: C/C++ debug arm macos + +on: + push: + branches: + - Nigthly + +jobs: + build: + + runs-on: macos-11 + + steps: + - uses: actions/checkout@v2 + with: + ref: 'debug_macos' + - name: build deps & slicer + run: ./BuildMacOS.sh -ia + - name: Upload artifact + uses: actions/upload-artifact@v1.0.0 + with: + name: nightly_macos_arm_debug.dmg + path: build/${{ github.event.repository.name }}.dmg + - name: Upload artifact + uses: actions/upload-artifact@v1.0.0 + with: + name: nightly_arm_macos.tar + path: build/${{ github.event.repository.name }}.tar diff --git a/.github/workflows/ccpp_mac_arm_debug.yml b/.github/workflows/ccpp_mac_arm_debug.yml new file mode 100644 index 00000000000..a1f7d7cd43a --- /dev/null +++ b/.github/workflows/ccpp_mac_arm_debug.yml @@ -0,0 +1,31 @@ +name: C/C++ debug arm macos + +on: + push: + branches: + - debug_macos + +jobs: + build: + + runs-on: macos-11 + + steps: + - uses: actions/checkout@v2 + with: + ref: 'debug_macos' + - name: build deps & slicer + run: ./BuildMacOS.sh -bia + - name: ls build + working-directory: ./build + run: ls + - name: Upload artifact + uses: actions/upload-artifact@v1.0.0 + with: + name: nightly_macos_arm_debug.dmg + path: build/${{ github.event.repository.name }}.dmg + - name: Upload artifact + uses: actions/upload-artifact@v1.0.0 + with: + name: nightly_arm_macos.tar + path: build/${{ github.event.repository.name }}.tar diff --git a/.github/workflows/ccpp_mac_debug.yml b/.github/workflows/ccpp_mac_debug.yml index e16b5cdf283..007dd5fdea0 100644 --- a/.github/workflows/ccpp_mac_debug.yml +++ b/.github/workflows/ccpp_mac_debug.yml @@ -10,104 +10,22 @@ jobs: runs-on: macos-latest - env: - EXEC_NAME: "${{ github.event.repository.name }}" - DBL_NAME: "${{ github.event.repository.name }}/${{ github.event.repository.name }}" steps: - uses: actions/checkout@v2 with: ref: 'debug_macos' - - name: update submodule profiles - working-directory: ./resources/profiles - run: git submodule update --init - - id: lowercase_repo - uses: ASzc/change-string-case-action@v1 - with: - string: ${{ github.event.repository.name }} - - name: set exec name - if: ${{ github.event.repository.name != 'Slic3r' }} - uses: allenevans/set-env@v2.0.0 - with: - EXEC_NAME: "${{ steps.lowercase_repo.outputs.lowercase }}" - - name: change date in version - run: | - sed "s/+UNKNOWN/_$(date '+%F')/" version.inc > version.date.inc - mv version.date.inc version.inc - - name: mkdir in deps - run: mkdir deps/build - - name: cmake deps - working-directory: ./deps/build - run: cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" - - name: make deps - working-directory: ./deps/build - run: make - - name: ls libs - working-directory: ./deps/build - run: ls ./destdir/usr/local/lib - - name: rename wxscintilla - working-directory: ./deps/build/destdir/usr/local/lib - run: cp libwxscintilla-3.1.a libwx_osx_cocoau_scintilla-3.1.a - - name: ls libs - working-directory: ./deps/build - run: ls ./destdir/usr/local/lib - - name: clean deps - working-directory: ./deps/build - run: rm -rf dep_* - - name: mkdir build - run: mkdir build - - name: cmake - working-directory: ./build - run: cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" -DSLIC3R_STATIC=1 - - name: make ${{ github.event.repository.name }} - working-directory: ./build - run: make Slic3r - - name: make .mo - working-directory: ./build - run: make gettext_po_to_mo - - name: update Info.plist - working-directory: ./build/src - run: sed "s/+UNKNOWN/_$(date '+%F')/" Info.plist >Info.date.plist - - name: create directory and copy into it - working-directory: ./build - run: | - mkdir pack - mkdir pack/${{ github.event.repository.name }} - mkdir pack/${{ env.DBL_NAME }}.app - mkdir pack/${{ env.DBL_NAME }}.app/Contents - mkdir pack/${{ env.DBL_NAME }}.app/Contents/_CodeSignature - mkdir pack/${{ env.DBL_NAME }}.app/Contents/Frameworks - mkdir pack/${{ env.DBL_NAME }}.app/Contents/MacOS - - name: copy Resources - working-directory: ./build - run: | - cp -Rf ../resources pack/${{ env.DBL_NAME }}.app/Contents/Resources - cp pack/${{ env.DBL_NAME }}.app/Contents/Resources/icons/${{ github.event.repository.name }}.icns pack/${{ github.event.repository.name }}/${{ github.event.repository.name }}.app/Contents/resources/${{ github.event.repository.name }}.icns - cp src/Info.date.plist pack/${{ github.event.repository.name }}/${{ github.event.repository.name }}.app/Contents/Info.plist - echo -n -e 'APPL????\x0a' > PkgInfo - cp PkgInfo pack/${{ env.DBL_NAME }}.app/Contents/PkgInfo -# echo -n -e '\xff\xfeAPPL\x3f\x00\x3f\x00\x3f\x00\x3f\x00\x0a\x00' > PkgInfo - - name: copy bin and do not let it lower case - working-directory: ./build - run: | - cp -f src/${{ env.EXEC_NAME }} pack/${{ env.DBL_NAME }}.app/Contents/MacOS/${{ github.event.repository.name }} - chmod u+x pack/${{ env.DBL_NAME }}.app/Contents/MacOS/${{ github.event.repository.name }} - tar -cvf ${{ github.event.repository.name }}.tar pack/${{ github.event.repository.name }} - - name: create dmg + - name: build deps & slicer + run: ./BuildMacOS.sh -bi + - name: tar the pack working-directory: ./build - run: | - hdiutil create -ov -fs HFS+ -volname "${{ github.event.repository.name }}" -srcfolder "pack/${{ github.event.repository.name }}" temp.dmg - hdiutil convert temp.dmg -format UDZO -o ${{ github.event.repository.name }}.dmg -# - name: signing Resources (creating CodeResources inside _CodeSignature) -# working-directory: . -# run: codesign -s Resources -# maybe i should just try to do that on a separate pc and copy the file here, more secure as a signing process. + run: ls - name: Upload artifact uses: actions/upload-artifact@v1.0.0 with: - name: nightly_macos.tar - path: build/${{ github.event.repository.name }}.tar + name: nightly_macos_debug.dmg + path: build/${{ github.event.repository.name }}.dmg - name: Upload artifact uses: actions/upload-artifact@v1.0.0 with: - name: nightly_macos_debug.dmg - path: build/${{ github.event.repository.name }}.dmg + name: nightly_macos.tar + path: build/${{ github.event.repository.name }}.tar diff --git a/BuildMacOS.sh b/BuildMacOS.sh index 7c7da1b723e..6442c0d617e 100755 --- a/BuildMacOS.sh +++ b/BuildMacOS.sh @@ -3,6 +3,7 @@ export ROOT=`pwd` export NCORES=`sysctl -n hw.ncpu` export CMAKE_INSTALLED=`which cmake` +#export ARCH=$(uname -m) # Check if CMake is installed if [[ -z "$CMAKE_INSTALLED" ]] @@ -11,18 +12,32 @@ then exit -1 fi -while getopts ":ih" opt; do +while getopts ":iaxbh" opt; do case ${opt} in i ) export BUILD_IMAGE="1" ;; + a ) + export BUILD_ARCH="arm64" + ;; + x ) + export BUILD_ARCH="x86_64" + ;; + b ) + export BUILD_DEBUG="1" + ;; h ) echo "Usage: ./BuildMacOS.sh [-i]" echo " -i: Generate DMG image (optional)" + echo " -a: Build for arm64 (Apple Silicon)" + echo " -x: Build for x86_64 (Intel)" + echo " -b: Build with debug symbols" exit 0 ;; esac done +echo "Build architecture: ${BUILD_ARCH}" + # mkdir build if [ ! -d "build" ] then @@ -35,7 +50,7 @@ echo -n "[1/9] Updating submodules..." pushd resources/profiles git submodule update --init popd -} > $ROOT/build/Build.log # Capture all command output +} #> $ROOT/build/Build.log # Capture all command output echo "done" echo -n "[2/9] Changing date in version..." @@ -43,7 +58,7 @@ echo -n "[2/9] Changing date in version..." # change date in version sed "s/+UNKNOWN/_$(date '+%F')/" version.inc > version.date.inc mv version.date.inc version.inc -} &> $ROOT/build/Build.log # Capture all command output +} #&> $ROOT/build/Build.log # Capture all command output echo "done" # mkdir in deps @@ -54,17 +69,31 @@ fi echo -n "[3/9] Configuring dependencies..." { + BUILD_ARGS="" + if [[ -n "$BUILD_ARCH" ]] + then + BUILD_ARGS="${BUILD_ARGS} -DCMAKE_OSX_ARCHITECTURES:STRING=${BUILD_ARCH}" + fi + if [[ -n "$BUILD_DEBUG" ]] + then + BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug" + fi # cmake deps + echo "Cmake command: cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=\"10.13\" ${BUILD_ARCH} " pushd deps/build - cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" -} &> $ROOT/build/Build.log # Capture all command output + cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" $BUILD_ARGS + echo "ls deps/build:" + ls -al + echo "ls deps/build/dep_GLEW-prefix" + ls -al dep_GLEW-prefix +} #&> $ROOT/build/Build.log # Capture all command output echo "done" echo -n "[4/9] Building dependencies..." { # make deps make -j$NCORES -} &> $ROOT/build/Build.log # Capture all command output +} #&> $ROOT/build/Build.log # Capture all command output echo "done" echo -n "[5/9] Renaming wxscintilla library..." @@ -72,8 +101,10 @@ echo -n "[5/9] Renaming wxscintilla library..." # rename wxscintilla pushd destdir/usr/local/lib cp libwxscintilla-3.1.a libwx_osx_cocoau_scintilla-3.1.a + echo "ls deps/build/destdir/usr/local/lib" + ls -al popd -} &> $ROOT/build/Build.log # Capture all command output +} #&> $ROOT/build/Build.log # Capture all command output echo "done" echo -n "[6/9] Cleaning dependencies..." @@ -81,15 +112,25 @@ echo -n "[6/9] Cleaning dependencies..." # clean deps rm -rf dep_* popd -} &> $ROOT/build/Build.log # Capture all command output +} #&> $ROOT/build/Build.log # Capture all command output echo "done" echo -n "[7/9] Configuring Slic3r..." { + BUILD_ARGS="" + if [[ -n "$BUILD_ARCH" ]] + then + BUILD_ARGS="${BUILD_ARGS} -DCMAKE_OSX_ARCHITECTURES=${BUILD_ARCH}" + fi + if [[ -n "$BUILD_DEBUG" ]] + then + BUILD_ARGS="-DCMAKE_BUILD_TYPE=Debug ${BUILD_ARGS}" + fi # cmake pushd build - cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" -DSLIC3R_STATIC=1 -} &> $ROOT/build/Build.log # Capture all command output + echo "Cmake command: cmake .. -DCMAKE_PREFIX_PATH=\"$PWD/../deps/build/destdir/usr/local\" -DCMAKE_OSX_DEPLOYMENT_TARGET=\"10.13\" -DSLIC3R_STATIC=1 ${BUILD_ARGS}" + cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" -DSLIC3R_STATIC=1 ${BUILD_ARGS} +} #&> $ROOT/build/Build.log # Capture all command output echo "done" echo -n "[8/9] Building Slic3r..." @@ -99,9 +140,14 @@ echo -n "[8/9] Building Slic3r..." # make .mo make gettext_po_to_mo -} &> $ROOT/build/Build.log # Capture all command output +} #&> $ROOT/build/Build.log # Capture all command output echo "done" - +echo "ls ROOT" +ls $ROOT +echo "ls ROOT/build" +ls $ROOT/build +echo "ls -al ROOT/build/src" +ls -al $ROOT/build/src # Give proper permissions to script chmod 755 $ROOT/build/src/BuildMacOSImage.sh @@ -111,3 +157,5 @@ then else $ROOT/build/src/BuildMacOSImage.sh fi +echo "ls -al ROOT/build" +ls -al $ROOT/build diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 4f7b08a48d7..603d3615fdf 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -39,6 +39,21 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") option(DEP_WX_GTK3 "Build wxWidgets against GTK3" OFF) endif() +set(IS_CROSS_COMPILE FALSE) + +if (APPLE) + set(CMAKE_FIND_FRAMEWORK LAST) + set(CMAKE_FIND_APPBUNDLE LAST) + list(FIND CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR} _arch_idx) + if (CMAKE_OSX_ARCHITECTURES AND _arch_idx LESS 0) + set(IS_CROSS_COMPILE TRUE) + string(REPLACE ";" "$" CMAKE_OSX_ARCHS "${CMAKE_OSX_ARCHITECTURES}") + set(_cmake_osx_arch -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHS}) + set(_cmake_args_osx_arch CMAKE_ARGS -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHS}) + message("Detect Cross-compilation. Will build for target ${CMAKE_OSX_ARCHS}" ) + endif () +endif () + # On developer machines, it can be enabled to speed up compilation and suppress warnings coming from IGL. # FIXME: # Enabling this option is not safe. IGL will compile itself with its own version of Eigen while @@ -61,7 +76,7 @@ function(prusaslicer_add_cmake_project projectname) set(_gen "") set(_build_j "-j${NPROC}") -if (MSVC) + if (MSVC) set(_gen CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}") set(_build_j "/m") endif () @@ -79,6 +94,7 @@ if (MSVC) -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} -DBUILD_SHARED_LIBS:BOOL=OFF + ${_cmake_osx_arch} "${_configs_line}" ${DEP_CMAKE_OPTS} ${P_ARGS_CMAKE_ARGS} @@ -181,6 +197,7 @@ if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") DEPENDS dep_boost CONFIGURE_COMMAND "" BUILD_COMMAND "" + ${_cmake_args_osx_arch} INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_BINARY_DIR}/dep_boost_polygon-prefix/src/dep_boost_polygon/include/boost/polygon" "${DESTDIR}/usr/local/include/boost/polygon" diff --git a/deps/GMP/GMP.cmake b/deps/GMP/GMP.cmake index a7fe19355f8..049e638161b 100644 --- a/deps/GMP/GMP.cmake +++ b/deps/GMP/GMP.cmake @@ -22,10 +22,24 @@ else () if (APPLE) if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") - set(_gmp_build_tgt aarch64) + set(_gmp_build_arch aarch64) + else () + set(_gmp_build_arch ${CMAKE_SYSTEM_PROCESSOR}) + endif() + if (IS_CROSS_COMPILE) + if (${CMAKE_OSX_ARCHITECTURES} MATCHES "arm") + set(_gmp_host_arch aarch64) + set(_gmp_host_arch_flags "-arch arm64") + elseif (${CMAKE_OSX_ARCHITECTURES} MATCHES "x86_64") + set(_gmp_host_arch x86_64) + set(_gmp_host_arch_flags "-arch x86_64") + endif() + set(_gmp_ccflags "${_gmp_ccflags} ${_gmp_host_arch_flags} -mmacosx-version-min=${DEP_OSX_TARGET}") + set(_gmp_build_tgt --build=${_gmp_build_arch}-apple-darwin --host=${_gmp_host_arch}-apple-darwin) + else () + set(_gmp_ccflags "${_gmp_ccflags} -mmacosx-version-min=${DEP_OSX_TARGET}") + set(_gmp_build_tgt "--build=${_gmp_build_arch}-apple-darwin") endif() - set(_gmp_ccflags "${_gmp_ccflags} -mmacosx-version-min=${DEP_OSX_TARGET}") - set(_gmp_build_tgt "--build=${_gmp_build_tgt}-apple-darwin") elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") set(_gmp_ccflags "${_gmp_ccflags} -march=armv7-a") # Works on RPi-4 diff --git a/deps/MPFR/MPFR.cmake b/deps/MPFR/MPFR.cmake index ddbb178d8d9..ea52dc402ca 100644 --- a/deps/MPFR/MPFR.cmake +++ b/deps/MPFR/MPFR.cmake @@ -24,6 +24,7 @@ else () CONFIGURE_COMMAND env "CFLAGS=${_gmp_ccflags}" "CXXFLAGS=${_gmp_ccflags}" ./configure --prefix=${DESTDIR}/usr/local --enable-shared=no --enable-static=yes --with-gmp=${DESTDIR}/usr/local ${_gmp_build_tgt} BUILD_COMMAND make -j INSTALL_COMMAND make install + ${_cmake_args_osx_arch} DEPENDS dep_GMP ) endif () diff --git a/deps/PNG/PNG.cmake b/deps/PNG/PNG.cmake index e07afec6de8..11357f9ef94 100644 --- a/deps/PNG/PNG.cmake +++ b/deps/PNG/PNG.cmake @@ -5,18 +5,36 @@ else () set(_disable_neon_extension "") endif () -prusaslicer_add_cmake_project(PNG - GIT_REPOSITORY https://github.com/glennrp/libpng.git - GIT_TAG v1.6.35 - DEPENDS ${ZLIB_PKG} - CMAKE_ARGS - -DPNG_SHARED=OFF - -DPNG_STATIC=ON - -DPNG_PREFIX=prusaslicer_ - -DPNG_TESTS=OFF - -DDISABLE_DEPENDENCY_TRACKING=OFF - ${_disable_neon_extension} +if(APPLE AND IS_CROSS_COMPILE) +# TODO: check if it doesn't create problem when compiling from arm to x86_64 + prusaslicer_add_cmake_project(PNG + GIT_REPOSITORY https://github.com/glennrp/libpng.git + GIT_TAG v1.6.35 + DEPENDS ${ZLIB_PKG} + PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df && + ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/macos-arm64.patch + CMAKE_ARGS + -DPNG_SHARED=OFF + -DPNG_STATIC=ON + -DPNG_PREFIX=prusaslicer_ + -DPNG_TESTS=OFF + -DDISABLE_DEPENDENCY_TRACKING=OFF + ${_disable_neon_extension} + ) +else () + prusaslicer_add_cmake_project(PNG + GIT_REPOSITORY https://github.com/glennrp/libpng.git + GIT_TAG v1.6.35 + DEPENDS ${ZLIB_PKG} + CMAKE_ARGS + -DPNG_SHARED=OFF + -DPNG_STATIC=ON + -DPNG_PREFIX=prusaslicer_ + -DPNG_TESTS=OFF + -DDISABLE_DEPENDENCY_TRACKING=OFF + ${_disable_neon_extension} ) +endif() if (MSVC) add_debug_dep(dep_PNG) diff --git a/deps/PNG/macos-arm64.patch b/deps/PNG/macos-arm64.patch new file mode 100644 index 00000000000..468d35685c6 --- /dev/null +++ b/deps/PNG/macos-arm64.patch @@ -0,0 +1,65 @@ +Based on https://github.com/vespakoen/libpng to work around until +https://github.com/glennrp/libpng/pull/354 is resolved. + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4db9bb87d..9099d1edf 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -82,10 +82,22 @@ option(PNG_HARDWARE_OPTIMIZATIONS "Enable Hardware Optimizations" ON) + set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names") + set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") + ++# CMake currently sets CMAKE_SYSTEM_PROCESSOR to one of x86_64 or arm64 on macOS, ++# based upon the OS architecture, not the target architecture. As such, we need ++# to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to ++# enable. Note that this will fail if you attempt to build a universal binary in ++# a single cmake invokation. ++if (APPLE AND CMAKE_OSX_ARCHITECTURES) ++ set(TARGET_ARCH ${CMAKE_OSX_ARCHITECTURES}) ++else() ++ set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}) ++endif() ++ ++ + if(PNG_HARDWARE_OPTIMIZATIONS) + # set definitions and sources for arm +-if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR +- CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") ++if(TARGET_ARCH MATCHES "^arm" OR ++ TARGET_ARCH MATCHES "^aarch64") + set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) + set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations: + check: (default) use internal checking code; +@@ -114,8 +126,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR + endif() + + # set definitions and sources for powerpc +-if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR +- CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*" ) ++if(TARGET_ARCH MATCHES "^powerpc*" OR ++ TARGET_ARCH MATCHES "^ppc64*" ) + set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) + set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations: + off: disable the optimizations.") +@@ -138,8 +150,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR + endif() + + # set definitions and sources for intel +-if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR +- CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*" ) ++if(TARGET_ARCH MATCHES "^i?86" OR ++ TARGET_ARCH MATCHES "^x86_64*" ) + set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) + set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations: + off: disable the optimizations") +@@ -162,8 +174,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR + endif() + + # set definitions and sources for MIPS +-if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR +- CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*" ) ++if(TARGET_ARCH MATCHES "mipsel*" OR ++ TARGET_ARCH MATCHES "mips64el*" ) + set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) + set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations: + off: disable the optimizations") diff --git a/deps/deps-macos.cmake b/deps/deps-macos.cmake index c3afdf90f00..ea170f608e9 100644 --- a/deps/deps-macos.cmake +++ b/deps/deps-macos.cmake @@ -15,6 +15,24 @@ set(DEP_CMAKE_OPTS include("deps-unix-common.cmake") +if (IS_CROSS_COMPILE) + if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") + set(_build_arch aarch64) + elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") + set(_build_arch x86_64) + endif() + + if (${CMAKE_OSX_ARCHITECTURES} MATCHES "arm") + set(_host_arch aarch64) + set(_arch_flags "-arch arm64") + elseif (${CMAKE_OSX_ARCHITECTURES} MATCHES "x86_64") + set(_host_arch x86_64) + set(_arch_flags "-arch x86_64") + endif() + set(_boost_linkflags "linkflags=${_arch_flags}") + set(_build_tgt --build=${_build_arch}-apple-darwin --host=${_host_arch}-apple-darwin) + set(_env_curl env "CFLAGS=${_arch_flags}") +endif () ExternalProject_Add(dep_boost EXCLUDE_FROM_ALL 1 @@ -33,10 +51,11 @@ ExternalProject_Add(dep_boost variant=release threading=multi boost.locale.icu=off - "cflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET}" - "cxxflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET}" - "mflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET}" - "mmflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET}" + "cflags=-fPIC ${_arch_flags} -mmacosx-version-min=${DEP_OSX_TARGET}" + "cxxflags=-fPIC ${_arch_flags} -mmacosx-version-min=${DEP_OSX_TARGET}" + "mflags=-fPIC ${_arch_flags} -mmacosx-version-min=${DEP_OSX_TARGET}" + "mmflags=-fPIC ${_arch_flags} -mmacosx-version-min=${DEP_OSX_TARGET}" + ${_boost_linkflags} install INSTALL_COMMAND "" # b2 does that already ) @@ -46,7 +65,8 @@ ExternalProject_Add(dep_libcurl URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz" URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115 BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND ./configure + CONFIGURE_COMMAND ${_env_curl} ./configure + ${_build_tgt} --enable-static --disable-shared "--with-ssl=${DESTDIR}/usr/local" @@ -87,4 +107,4 @@ ExternalProject_Add(dep_libcurl INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" ) -add_dependencies(dep_openvdb dep_boost) \ No newline at end of file +add_dependencies(dep_openvdb dep_boost) diff --git a/deps/deps-unix-common.cmake b/deps/deps-unix-common.cmake index 46c9f8864e0..e4c4a824ed6 100644 --- a/deps/deps-unix-common.cmake +++ b/deps/deps-unix-common.cmake @@ -27,6 +27,7 @@ ExternalProject_Add(dep_tbb -DTBB_BUILD_TESTS=OFF -DCMAKE_CXX_FLAGS=${TBB_MINGW_WORKAROUND} -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local + ${_cmake_osx_arch} ${DEP_CMAKE_OPTS} ) @@ -34,7 +35,10 @@ ExternalProject_Add(dep_gtest EXCLUDE_FROM_ALL 1 URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz" URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c - CMAKE_ARGS -DBUILD_GMOCK=OFF ${DEP_CMAKE_OPTS} -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local + CMAKE_ARGS + -DBUILD_GMOCK=OFF ${DEP_CMAKE_OPTS} + -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local + ${_cmake_osx_arch} ) ExternalProject_Add(dep_cereal @@ -44,6 +48,7 @@ ExternalProject_Add(dep_cereal CMAKE_ARGS -DJUST_INSTALL_CEREAL=on -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local + ${_cmake_osx_arch} ${DEP_CMAKE_OPTS} ) @@ -58,6 +63,7 @@ ExternalProject_Add(dep_nlopt -DNLOPT_MATLAB=OFF -DNLOPT_GUILE=OFF -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local + ${_cmake_osx_arch} ${DEP_CMAKE_OPTS} ) @@ -70,6 +76,7 @@ ExternalProject_Add(dep_qhull CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local + ${_cmake_osx_arch} ${DEP_CMAKE_OPTS} ) @@ -88,14 +95,30 @@ ExternalProject_Add(dep_blosc -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF -DPREFER_EXTERNAL_ZLIB=ON + ${_cmake_osx_arch} PATCH_COMMAND ${GIT_EXECUTABLE} reset --hard && git clean -df && ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/blosc-mods.patch ) +# Check if we're building for arm on x86_64 and just for OpenEXR, build fat +# binaries. We need this because it compiles some code to generate other +# source and we need to be able to run the executables. When we link the +# library, the x86_64 part will be ignored. +if (APPLE AND IS_CROSS_COMPILE) + if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" AND ${CMAKE_OSX_ARCHITECTURES} MATCHES "arm") + set(_openexr_arch arm64^^x86_64) + set(_openxr_list_sep LIST_SEPARATOR ^^) + set(_cmake_openexr_arch -DCMAKE_OSX_ARCHITECTURES:STRING=${_openexr_arch}) + else() + set(_openexr_arch ${CMAKE_OSX_ARCHITECTURES}) + set(_cmake_openexr_arch -DCMAKE_OSX_ARCHITECTURES:STRING=${_openexr_arch}) + endif() +endif() ExternalProject_Add(dep_openexr EXCLUDE_FROM_ALL 1 GIT_REPOSITORY https://github.com/openexr/openexr.git GIT_TAG eae0e337c9f5117e78114fd05f7a415819df413a #v2.4.0 + ${_openxr_list_sep} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local -DBUILD_SHARED_LIBS=OFF @@ -104,6 +127,7 @@ ExternalProject_Add(dep_openexr -DPYILMBASE_ENABLE:BOOL=OFF -DOPENEXR_VIEWERS_ENABLE:BOOL=OFF -DOPENEXR_BUILD_UTILS:BOOL=OFF + ${_cmake_openexr_arch} ) ExternalProject_Add(dep_openvdb @@ -124,6 +148,7 @@ ExternalProject_Add(dep_openvdb -DTBB_STATIC=ON -DOPENVDB_BUILD_VDB_PRINT=ON -DDISABLE_DEPENDENCY_VERSION_CHECKS=ON + ${_cmake_osx_arch} PATCH_COMMAND PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df && ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/openvdb-mods.patch ) From d1f475b476f72bce5ef19ee2fbb6eecead93c5a1 Mon Sep 17 00:00:00 2001 From: supermerill Date: Sun, 19 Dec 2021 23:17:49 +0100 Subject: [PATCH 09/14] fix regex import supermerill/SuperSlicer#2081 --- src/libslic3r/PlaceholderParser.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/PlaceholderParser.cpp b/src/libslic3r/PlaceholderParser.cpp index 94aa32af3a0..0a4948fab4e 100644 --- a/src/libslic3r/PlaceholderParser.cpp +++ b/src/libslic3r/PlaceholderParser.cpp @@ -7,7 +7,7 @@ #include #include #include -#include + #ifdef _MSC_VER #include // provides **_environ #else @@ -1502,11 +1502,11 @@ void PlaceholderParser::append_custom_variables(std::map 0; if (!is_array) nb_extruders = 1; - std::regex is_a_name("[a-zA-Z_]+"); + SLIC3R_REGEX_NAMESPACE::regex is_a_name("[a-zA-Z_]+"); for (const auto& entry : name2var_array) { if (entry.first.empty()) continue; - if (!std::regex_match(entry.first, is_a_name)) + if (!SLIC3R_REGEX_NAMESPACE::regex_match(entry.first, is_a_name)) continue; const std::vector& values = entry.second; //check if all values are empty @@ -1555,7 +1555,7 @@ void PlaceholderParser::append_custom_variables(std::map double_values; - //std::regex("\\s*[+-]?([0-9]+\\.[0-9]*([Ee][+-]?[0-9]+)?|\\.[0-9]+([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)"); + //SLIC3R_REGEX_NAMESPACE::regex("\\s*[+-]?([0-9]+\\.[0-9]*([Ee][+-]?[0-9]+)?|\\.[0-9]+([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)"); if (!is_not_numeric) { for (int extruder_id = 0; extruder_id < nb_extruders; ++extruder_id) { if (!values[extruder_id].empty()) { From 3d1c29c0e0f1c38ad788469229f9e928e03dd1ea Mon Sep 17 00:00:00 2001 From: supermerill Date: Mon, 20 Dec 2021 00:16:25 +0100 Subject: [PATCH 10/14] fix kickstart reverting when it shouldn't supermerill/SuperSlicer#2076 --- src/libslic3r/GCode/FanMover.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libslic3r/GCode/FanMover.cpp b/src/libslic3r/GCode/FanMover.cpp index ca6db9ecf2d..6e138d1d299 100644 --- a/src/libslic3r/GCode/FanMover.cpp +++ b/src/libslic3r/GCode/FanMover.cpp @@ -242,6 +242,8 @@ void FanMover::_process_gcode_line(GCodeReader& reader, const GCodeReader::GCode if (fan_speed >= 0) { const auto fan_baseline = (m_writer.config.fan_percentage.value ? 100.0 : 255.0); fan_speed = 100 * fan_speed / fan_baseline; + //speed change: stop kickstart reverting if any + m_current_kickstart.time = -1; if (!m_is_custom_gcode) { // if slow down => put in the queue. if not => if (m_back_buffer_fan_speed < fan_speed) { From 2f4b55ed3cd790d5f7df3d8f639da07b80f8e5b3 Mon Sep 17 00:00:00 2001 From: supermerill Date: Mon, 20 Dec 2021 03:51:45 +0100 Subject: [PATCH 11/14] 0 extrusion_spacing will always create 0-auto-extrusion_width. clean cout supermerill/SuperSlicer#2084 --- src/libslic3r/Fill/FillGyroid.cpp | 2 -- src/libslic3r/PrintConfig.cpp | 45 +++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/libslic3r/Fill/FillGyroid.cpp b/src/libslic3r/Fill/FillGyroid.cpp index 0ff0972c58e..461fc0e62f6 100644 --- a/src/libslic3r/Fill/FillGyroid.cpp +++ b/src/libslic3r/Fill/FillGyroid.cpp @@ -168,8 +168,6 @@ void FillGyroid::_fill_surface_single( const double tolerance_old = std::min(this->get_spacing() / 2, FillGyroid::PatternTolerance) / unscaled(scaleFactor); const double tolerance_old2 = std::min(this->get_spacing() / 2, FillGyroid::PatternTolerance) * density_adjusted / this->get_spacing(); const double tolerance = params.config->get_computed_value("resolution_internal") * density_adjusted / this->get_spacing(); - std::cout << "gyroid tolerance: " << tolerance_old << " == " << tolerance_old2 << " ? "<< tolerance << "\n"; - std::cout << "this->get_spacing(): " << this->get_spacing() << " , scaleFactor= " << unscaled(scaleFactor) << " , min(spa, 0.2)= " << std::min(this->get_spacing() / 2, FillGyroid::PatternTolerance) << "\n"; // generate pattern Polylines polylines = make_gyroid_waves( diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 5f980ae337f..123362949c6 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -6531,7 +6531,10 @@ std::set DynamicPrintConfig::value_changed(const t_co if (width_option) { width_option->set_phony(true); spacing_option->set_phony(false); - width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); + if (spacing_value == 0) + width_option->value = 0; + else + width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); width_option->percent = spacing_option->percent; something_changed = true; } @@ -6541,7 +6544,10 @@ std::set DynamicPrintConfig::value_changed(const t_co if (width_option) { width_option->set_phony(true); spacing_option->set_phony(false); - width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); + if (spacing_value == 0) + width_option->value = 0; + else + width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); width_option->percent = spacing_option->percent; something_changed = true; } @@ -6552,9 +6558,13 @@ std::set DynamicPrintConfig::value_changed(const t_co if (width_option && perimeter_overlap_option) { width_option->set_phony(true); spacing_option->set_phony(false); - flow.spacing_ratio = std::min(flow.spacing_ratio, float(perimeter_overlap_option->get_abs_value(1))); - flow.width = spacing_option->get_abs_value(max_nozzle_diameter) + layer_height_option->value * (1. - 0.25 * PI) * flow.spacing_ratio; - width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); + if(spacing_value == 0) + width_option->value = 0; + else { + flow.spacing_ratio = std::min(flow.spacing_ratio, float(perimeter_overlap_option->get_abs_value(1))); + flow.width = spacing_option->get_abs_value(max_nozzle_diameter) + layer_height_option->value * (1. - 0.25 * PI) * flow.spacing_ratio; + width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); + } width_option->percent = spacing_option->percent; something_changed = true; } @@ -6566,9 +6576,13 @@ std::set DynamicPrintConfig::value_changed(const t_co if (width_option && external_perimeter_overlap_option) { width_option->set_phony(true); spacing_option->set_phony(false); - flow.spacing_ratio = std::min(flow.spacing_ratio * 0.5f, float(external_perimeter_overlap_option->get_abs_value(0.25) + perimeter_overlap_option->get_abs_value(0.25))); - flow.width = spacing_option->get_abs_value(max_nozzle_diameter) + layer_height_option->value * (1. - 0.25 * PI) * flow.spacing_ratio; - width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); + if (spacing_value == 0) + width_option->value = 0; + else { + flow.spacing_ratio = std::min(flow.spacing_ratio * 0.5f, float(external_perimeter_overlap_option->get_abs_value(0.25) + perimeter_overlap_option->get_abs_value(0.25))); + flow.width = spacing_option->get_abs_value(max_nozzle_diameter) + layer_height_option->value * (1. - 0.25 * PI) * flow.spacing_ratio; + width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); + } width_option->percent = spacing_option->percent; something_changed = true; } @@ -6578,7 +6592,10 @@ std::set DynamicPrintConfig::value_changed(const t_co if (width_option) { width_option->set_phony(true); spacing_option->set_phony(false); - width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); + if (spacing_value == 0) + width_option->value = 0; + else + width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); width_option->percent = spacing_option->percent; something_changed = true; } @@ -6588,7 +6605,10 @@ std::set DynamicPrintConfig::value_changed(const t_co if (width_option) { width_option->set_phony(true); spacing_option->set_phony(false); - width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); + if (spacing_value == 0) + width_option->value = 0; + else + width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); width_option->percent = spacing_option->percent; something_changed = true; } @@ -6598,7 +6618,10 @@ std::set DynamicPrintConfig::value_changed(const t_co if (width_option) { width_option->set_phony(true); spacing_option->set_phony(false); - width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); + if (spacing_value == 0) + width_option->value = 0; + else + width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); width_option->percent = spacing_option->percent; something_changed = true; } From 91d3862ead68915cc6c64617f8cb5fa32183d5e3 Mon Sep 17 00:00:00 2001 From: supermerill Date: Mon, 20 Dec 2021 18:25:19 +0100 Subject: [PATCH 12/14] Fix 'merge thin walls with perimeter' (unneeded travels) also now use coincide_with_epsilon for most of medial_axis, as I have the proof the position can vary by 1 unit in an intersection. supermerill/SuperSlicer#2092 --- src/libslic3r/MedialAxis.cpp | 151 +++++++++++++++------------ src/libslic3r/PerimeterGenerator.cpp | 26 +++-- src/libslic3r/Point.hpp | 2 +- src/libslic3r/Polyline.cpp | 18 ++-- 4 files changed, 110 insertions(+), 87 deletions(-) diff --git a/src/libslic3r/MedialAxis.cpp b/src/libslic3r/MedialAxis.cpp index 54c2beace98..db05fbd173a 100644 --- a/src/libslic3r/MedialAxis.cpp +++ b/src/libslic3r/MedialAxis.cpp @@ -465,7 +465,7 @@ get_coeff_from_angle_countour(Point &point, const ExPolygon &contour, coord_t mi if (angle >= PI) angle = 2 * PI - angle; // smaller angle //compute the diff from 90° angle = abs(angle - PI / 2); - if (point_near.coincides_with(point_nearest) && std::max(nearest_dist, near_dist) + SCALED_EPSILON < point_nearest.distance_to(point_near)) { + if (point_near.coincides_with_epsilon(point_nearest) && std::max(nearest_dist, near_dist) + SCALED_EPSILON < point_nearest.distance_to(point_near)) { //not only nearest Point point_before = id_near == 0 ? contour.contour.points.back() : contour.contour.points[id_near - 1]; Point point_after = id_near == contour.contour.points.size() - 1 ? contour.contour.points.front() : contour.contour.points[id_near + 1]; @@ -532,13 +532,13 @@ MedialAxis::fusion_curve(ThickPolylines &pp) for (size_t j = 0; j < pp.size(); ++j) { if (j == i) continue; ThickPolyline& other = pp[j]; - if (polyline.first_point().coincides_with(other.last_point())) { + if (polyline.first_point().coincides_with_epsilon(other.last_point())) { other.reverse(); crosspoint.push_back(j); double dot_temp = dot(Line(polyline.points[0], polyline.points[1]), (Line(other.points[0], other.points[1]))); min_dot = std::min(min_dot, abs(dot_temp)); sum_dot += dot_temp; - } else if (polyline.first_point().coincides_with(other.first_point())) { + } else if (polyline.first_point().coincides_with_epsilon(other.first_point())) { crosspoint.push_back(j); double dot_temp = dot(Line(polyline.points[0], polyline.points[1]), (Line(other.points[0], other.points[1]))); min_dot = std::min(min_dot, abs(dot_temp)); @@ -616,10 +616,10 @@ MedialAxis::remove_bits(ThickPolylines &pp) for (size_t j = 0; j < pp.size(); ++j) { if (j == i) continue; ThickPolyline& other = pp[j]; - if (polyline.first_point().coincides_with(other.last_point())) { + if (polyline.first_point().coincides_with_epsilon(other.last_point())) { other.reverse(); crosspoint.push_back(j); - } else if (polyline.first_point().coincides_with(other.first_point())) { + } else if (polyline.first_point().coincides_with_epsilon(other.first_point())) { crosspoint.push_back(j); } } @@ -675,10 +675,10 @@ MedialAxis::fusion_corners(ThickPolylines &pp) for (size_t j = 0; j < pp.size(); ++j) { if (j == i) continue; ThickPolyline& other = pp[j]; - if (polyline.first_point().coincides_with(other.last_point())) { + if (polyline.first_point().coincides_with_epsilon(other.last_point())) { other.reverse(); crosspoint.push_back(j); - } else if (polyline.first_point().coincides_with(other.first_point())) { + } else if (polyline.first_point().coincides_with_epsilon(other.first_point())) { crosspoint.push_back(j); } } @@ -912,13 +912,13 @@ MedialAxis::main_fusion(ThickPolylines& pp) // find another polyline starting here for (size_t j = i + 1; j < pp.size(); ++j) { ThickPolyline& other = pp[j]; - if (polyline.last_point().coincides_with(other.last_point())) { + if (polyline.last_point().coincides_with_epsilon(other.last_point())) { polyline.reverse(); other.reverse(); - } else if (polyline.first_point().coincides_with(other.last_point())) { + } else if (polyline.first_point().coincides_with_epsilon(other.last_point())) { other.reverse(); - } else if (polyline.first_point().coincides_with(other.first_point())) { - } else if (polyline.last_point().coincides_with(other.first_point())) { + } else if (polyline.first_point().coincides_with_epsilon(other.first_point())) { + } else if (polyline.last_point().coincides_with_epsilon(other.first_point())) { polyline.reverse(); } else { continue; @@ -978,7 +978,7 @@ MedialAxis::main_fusion(ThickPolylines& pp) //std::cout << "try to find main : " << k << " ? " << i << " " << j << " "; if (k == i || k == j) continue; ThickPolyline& main = pp[k]; - if (polyline.first_point().coincides_with(main.last_point())) { + if (polyline.first_point().coincides_with_epsilon(main.last_point())) { main.reverse(); if (!main.endpoints.second) find_main_branch = true; @@ -986,7 +986,7 @@ MedialAxis::main_fusion(ThickPolylines& pp) biggest_main_branch_id = k; biggest_main_branch_length = (coord_t)main.length(); } - } else if (polyline.first_point().coincides_with(main.first_point())) { + } else if (polyline.first_point().coincides_with_epsilon(main.first_point())) { if (!main.endpoints.second) find_main_branch = true; else if (biggest_main_branch_length < main.length()) { @@ -1291,14 +1291,14 @@ MedialAxis::concatenate_polylines_with_crossing(ThickPolylines& pp) if (other.endpoints.first && other.endpoints.second) continue; bool me_reverse = false; bool other_reverse = false; - if (polyline.last_point().coincides_with(other.last_point())) { + if (polyline.last_point().coincides_with_epsilon(other.last_point())) { other_reverse = true; - } else if (polyline.first_point().coincides_with(other.last_point())) { + } else if (polyline.first_point().coincides_with_epsilon(other.last_point())) { me_reverse = true; other_reverse = true; - } else if (polyline.first_point().coincides_with(other.first_point())) { + } else if (polyline.first_point().coincides_with_epsilon(other.first_point())) { me_reverse = true; - } else if (!polyline.last_point().coincides_with(other.first_point())) { + } else if (!polyline.last_point().coincides_with_epsilon(other.first_point())) { continue; } @@ -1316,12 +1316,12 @@ MedialAxis::concatenate_polylines_with_crossing(ThickPolylines& pp) } } if (best_candidate != nullptr && best_candidate->points.size() > 1) { - if (polyline.last_point().coincides_with(best_candidate->last_point())) { + if (polyline.last_point().coincides_with_epsilon(best_candidate->last_point())) { best_candidate->reverse(); - } else if (polyline.first_point().coincides_with(best_candidate->last_point())) { + } else if (polyline.first_point().coincides_with_epsilon(best_candidate->last_point())) { polyline.reverse(); best_candidate->reverse(); - } else if (polyline.first_point().coincides_with(best_candidate->first_point())) { + } else if (polyline.first_point().coincides_with_epsilon(best_candidate->first_point())) { polyline.reverse(); } //intersections may create over-extrusion because the included circle can be a bit larger. We have to make it short again if needed. @@ -1415,18 +1415,18 @@ MedialAxis::remove_too_short_polylines(ThickPolylines& pp, const coord_t min_siz // if (endpoint_not_used[idx_endpoint]) { // int nb_endpoints; // Point pt = idx_endpoint % 2 == 0 ? polyline.first_point() : polyline.last_point(); - // if (idx_endpoint % 2 == 0 && pt.coincides_with(polyline.last_point())) { + // if (idx_endpoint % 2 == 0 && pt.coincides_with_epsilon(polyline.last_point())) { // nb_endpoints++; // endpoint_not_used[(idx_endpoint / 2) + 1] = false; // } // //good, now find other points // for (size_t idx_other_pp = (idx_endpoint / 2) + 1; idx_other_pp < pp.size(); idx_other_pp++) { // ThickPolyline& other = pp[idx_other_pp]; - // if (pt.coincides_with(other.first_point())) { + // if (pt.coincides_with_epsilon(other.first_point())) { // nb_endpoints++; // endpoint_not_used[idx_other_pp * 2] = false; // } - // if (pt.coincides_with(other.last_point())) { + // if (pt.coincides_with_epsilon(other.last_point())) { // nb_endpoints++; // endpoint_not_used[idx_other_pp * 2 + 1] = false; // } @@ -1438,7 +1438,7 @@ MedialAxis::remove_too_short_polylines(ThickPolylines& pp, const coord_t min_siz // std::cout << "reduce " << reduction << " points!\n"; // if (idx_endpoint % 2 == 0 ) { // polyline.width.front() *= reduction; - // if(pt.coincides_with(polyline.last_point())) + // if(pt.coincides_with_epsilon(polyline.last_point())) // polyline.width.back() *= reduction; // } else { // polyline.width.back() *= reduction; @@ -1446,10 +1446,10 @@ MedialAxis::remove_too_short_polylines(ThickPolylines& pp, const coord_t min_siz // //good, now find other points // for (size_t idx_other_pp = (idx_endpoint / 2) + 1; idx_other_pp < pp.size(); idx_other_pp++) { // ThickPolyline& other = pp[idx_other_pp]; - // if (pt.coincides_with(other.first_point())) { + // if (pt.coincides_with_epsilon(other.first_point())) { // other.width.front() *= reduction; // } - // if (pt.coincides_with(other.last_point())) { + // if (pt.coincides_with_epsilon(other.last_point())) { // other.width.back() *= reduction; // } // } @@ -1697,7 +1697,7 @@ MedialAxis::build(ThickPolylines &polylines_out) { //static int id = 0; //id++; - //std::cout << this->id << "\n"; + //std::cout << id << "\n"; //{ // std::stringstream stri; // stri << "medial_axis_0_enter_" << id << ".svg"; @@ -1710,8 +1710,8 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_0.5_simplified_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(bounds); - // svg.draw(this->expolygon); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); // svg.Close(); //} //safety check @@ -1778,9 +1778,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_0.9_voronoi_" << id << ".svg"; // SVG svg(stri.str()); - // //svg.draw(bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} @@ -1805,9 +1805,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_1_voronoi_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(*bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} @@ -1820,9 +1820,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_1_voronoi_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(*bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} @@ -1846,9 +1846,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_2_curve_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(*bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} @@ -1863,9 +1863,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_3_fusion_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} @@ -1875,6 +1875,15 @@ MedialAxis::build(ThickPolylines &polylines_out) // Loop through all returned polylines in order to extend their endpoints to the // expolygon boundaries (if done here, it may be cut later if not thick enough) if (stop_at_min_width) { + //{ + // std::stringstream stri; + // stri << "medial_axis_3_3_extends_" << id << ".svg"; + // SVG svg(stri.str()); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); + // svg.Close(); + //} extends_line_both_side(pp); } @@ -1886,14 +1895,24 @@ MedialAxis::build(ThickPolylines &polylines_out) std::cout << "\n"; }*/ //reduce extrusion when it's too thin to be printable + //{ + // std::stringstream stri; + // stri << "medial_axis_3_6_remove_thin_" << id << ".svg"; + // SVG svg(stri.str()); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); + // svg.Close(); + //} + remove_too_thin_extrusion(pp); //{ // std::stringstream stri; // stri << "medial_axis_4_thinok_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} @@ -1902,9 +1921,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_5.0_thuinner_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(*bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} @@ -1917,9 +1936,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_5_expand_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(*bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} //TODO: reduce the flow at the intersection ( + ) points on crossing? @@ -1928,9 +1947,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_6_concat_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} @@ -1939,9 +1958,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_8_tooshort_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} @@ -1950,9 +1969,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_9.1_end_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(*bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} if (nozzle_diameter != min_width) { @@ -1965,9 +1984,9 @@ MedialAxis::build(ThickPolylines &polylines_out) // std::stringstream stri; // stri << "medial_axis_9.9_endnwithtaper_" << id << ".svg"; // SVG svg(stri.str()); - // svg.draw(*bounds); - // svg.draw(this->expolygon); - // svg.draw(pp); + // svg.draw(*bounds, "grey"); + // svg.draw(this->expolygon, "green"); + // svg.draw(pp, "red"); // svg.Close(); //} @@ -2136,7 +2155,7 @@ thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow fl // Append paths to collection. if (!paths.empty()) { - if (paths.front().first_point().coincides_with(paths.back().last_point())) { + if (paths.front().first_point().coincides_with_epsilon(paths.back().last_point())) { coll.append(ExtrusionLoop(paths)); } else { if (role == erThinWall){ diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 3aeed59dae3..aba01cfd1c0 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -462,7 +462,7 @@ void PerimeterGenerator::process() // In case no perimeters are to be generated, loop_number will equal to -1. std::vector contours(loop_number + 1); // depth => loops std::vector holes(loop_number + 1); // depth => loops - ThickPolylines thin_walls; + ThickPolylines thin_walls_thickpolys; ExPolygons no_last_gapfill; // we loop one time more than needed in order to find gaps after the last perimeter was applied for (int i = 0;; ++i) { // outer loop is 0 @@ -562,7 +562,7 @@ void PerimeterGenerator::process() ma.use_bounds(bound) .use_min_real_width(scale_t(this->ext_perimeter_flow.nozzle_diameter)) .use_tapers(thin_walls_overlap) - .build(thin_walls); + .build(thin_walls_thickpolys); } break; } @@ -937,20 +937,23 @@ void PerimeterGenerator::process() } // append thin walls - if (!thin_walls.empty()) { - ExtrusionEntityCollection tw = thin_variable_width - (thin_walls, erThinWall, this->ext_perimeter_flow, std::max(ext_perimeter_width/4, scale_t(this->print_config->resolution))); - - entities.append(tw.entities); - thin_walls.clear(); + if (!thin_walls_thickpolys.empty()) { + if (this->object_config->thin_walls_merge) { + _merge_thin_walls(entities, thin_walls_thickpolys); + } else { + ExtrusionEntityCollection tw = thin_variable_width + (thin_walls_thickpolys, erThinWall, this->ext_perimeter_flow, std::max(ext_perimeter_width / 4, scale_t(this->print_config->resolution))); + entities.append(tw.entities); + } + thin_walls_thickpolys.clear(); } } else { if (this->object_config->thin_walls_merge) { ThickPolylines no_thin_walls; entities = this->_traverse_loops(contours.front(), no_thin_walls); - _merge_thin_walls(entities, thin_walls); + _merge_thin_walls(entities, thin_walls_thickpolys); } else { - entities = this->_traverse_loops(contours.front(), thin_walls); + entities = this->_traverse_loops(contours.front(), thin_walls_thickpolys); } } @@ -1697,11 +1700,12 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions } else { //first add the return path ExtrusionEntityCollection tws_second = tws; - tws_second.reverse(); change_flow.percent_extrusion = 0.1f; change_flow.use(tws_second); + //force reverse for (ExtrusionPath &path : change_flow.paths) path.reverse(); + std::reverse(change_flow.paths.begin(), change_flow.paths.end()); //std::reverse(change_flow.paths.begin(), change_flow.paths.end()); searcher.search_result.loop->paths.insert(searcher.search_result.loop->paths.begin() + 1 + searcher.search_result.idx_path, change_flow.paths.begin(), change_flow.paths.end()); diff --git a/src/libslic3r/Point.hpp b/src/libslic3r/Point.hpp index aaf1e7e48d4..b6a511b88a2 100644 --- a/src/libslic3r/Point.hpp +++ b/src/libslic3r/Point.hpp @@ -155,7 +155,7 @@ class Point : public Vec2crd double distance_to(const Line &line) const; bool coincides_with(const Point &point) const { return this->x() == point.x() && this->y() == point.y(); } bool coincides_with_epsilon(const Point &point) const { - return std::abs(this->x() - point.x()) < SCALED_EPSILON && std::abs(this->y() - point.y()) < SCALED_EPSILON; + return std::abs(this->x() - point.x()) < SCALED_EPSILON/2 && std::abs(this->y() - point.y()) < SCALED_EPSILON/2; } }; diff --git a/src/libslic3r/Polyline.cpp b/src/libslic3r/Polyline.cpp index 8f294f1628d..c7cf15c759c 100644 --- a/src/libslic3r/Polyline.cpp +++ b/src/libslic3r/Polyline.cpp @@ -273,7 +273,7 @@ void concatThickPolylines(ThickPolylines& pp) { //concat polyline if only 2 polyline at a point for (size_t i = 0; i < pp.size(); ++i) { ThickPolyline *polyline = &pp[i]; - if (polyline->first_point().coincides_with(polyline->last_point())) { + if (polyline->first_point().coincides_with_epsilon(polyline->last_point())) { polyline->endpoints.first = false; polyline->endpoints.second = false; continue; @@ -287,25 +287,25 @@ void concatThickPolylines(ThickPolylines& pp) { for (size_t j = 0; j < pp.size(); ++j) { if (j == i) continue; ThickPolyline *other = &pp[j]; - if (polyline->last_point().coincides_with(other->last_point())) { + if (polyline->last_point().coincides_with_epsilon(other->last_point())) { id_candidate_last_point = j; nbCandidate_last_point++; } - if (polyline->last_point().coincides_with(other->first_point())) { + if (polyline->last_point().coincides_with_epsilon(other->first_point())) { id_candidate_last_point = j; nbCandidate_last_point++; } - if (polyline->first_point().coincides_with(other->last_point())) { + if (polyline->first_point().coincides_with_epsilon(other->last_point())) { id_candidate_first_point = j; nbCandidate_first_point++; } - if (polyline->first_point().coincides_with(other->first_point())) { + if (polyline->first_point().coincides_with_epsilon(other->first_point())) { id_candidate_first_point = j; nbCandidate_first_point++; } } if (id_candidate_last_point == id_candidate_first_point && nbCandidate_first_point == 1 && nbCandidate_last_point == 1) { - if (polyline->first_point().coincides_with(pp[id_candidate_first_point].first_point())) pp[id_candidate_first_point].reverse(); + if (polyline->first_point().coincides_with_epsilon(pp[id_candidate_first_point].first_point())) pp[id_candidate_first_point].reverse(); // it's a trap! it's a loop! polyline->points.insert(polyline->points.end(), pp[id_candidate_first_point].points.begin() + 1, pp[id_candidate_first_point].points.end()); polyline->width.insert(polyline->width.end(), pp[id_candidate_first_point].width.begin() + 1, pp[id_candidate_first_point].width.end()); @@ -316,7 +316,7 @@ void concatThickPolylines(ThickPolylines& pp) { } else { if (nbCandidate_first_point == 1) { - if (polyline->first_point().coincides_with(pp[id_candidate_first_point].first_point())) pp[id_candidate_first_point].reverse(); + if (polyline->first_point().coincides_with_epsilon(pp[id_candidate_first_point].first_point())) pp[id_candidate_first_point].reverse(); //concat at front polyline->width[0] = std::max(polyline->width.front(), pp[id_candidate_first_point].width.back()); polyline->points.insert(polyline->points.begin(), pp[id_candidate_first_point].points.begin(), pp[id_candidate_first_point].points.end() - 1); @@ -336,7 +336,7 @@ void concatThickPolylines(ThickPolylines& pp) { polyline->endpoints.first = true; } if (nbCandidate_last_point == 1) { - if (polyline->last_point().coincides_with(pp[id_candidate_last_point].last_point())) pp[id_candidate_last_point].reverse(); + if (polyline->last_point().coincides_with_epsilon(pp[id_candidate_last_point].last_point())) pp[id_candidate_last_point].reverse(); //concat at back polyline->width[polyline->width.size() - 1] = std::max(polyline->width.back(), pp[id_candidate_last_point].width.front()); polyline->points.insert(polyline->points.end(), pp[id_candidate_last_point].points.begin() + 1, pp[id_candidate_last_point].points.end()); @@ -353,7 +353,7 @@ void concatThickPolylines(ThickPolylines& pp) { polyline->endpoints.second = true; } - if (polyline->last_point().coincides_with(polyline->first_point())) { + if (polyline->last_point().coincides_with_epsilon(polyline->first_point())) { //the concat has created a loop : update endpoints polyline->endpoints.first = false; polyline->endpoints.second = false; From 4e0d91fe94764bcb2a8d291e95d8c8152b1573f2 Mon Sep 17 00:00:00 2001 From: supermerill Date: Mon, 20 Dec 2021 19:26:04 +0100 Subject: [PATCH 13/14] Updated ConfigManipulation (disabled/enabled) for width & spacing. --- src/libslic3r/PrintConfig.cpp | 4 ++-- src/slic3r/GUI/ConfigManipulation.cpp | 28 ++++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 123362949c6..bf15e6c6a27 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1285,7 +1285,7 @@ void PrintConfigDef::init_fff_params() def->precision = 6; def->can_phony = true; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloatOrPercent(100, true, false)); + def->set_default_value(new ConfigOptionFloatOrPercent(0, false, false)); def = this->add("fan_always_on", coBools); def->label = L("Keep fan always on"); @@ -3659,7 +3659,7 @@ void PrintConfigDef::init_fff_params() def->max_literal = { 10, true }; def->precision = 6; def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); + def->set_default_value(new ConfigOptionFloatOrPercent(130, true)); def = this->add("skirts", coInt); def->label = L("Loops (minimum)"); diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index bfb9fe01480..0a1f2ae1a2c 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -319,7 +319,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) { bool have_perimeters = config->opt_int("perimeters") > 0; for (auto el : { "ensure_vertical_shell_thickness", "external_perimeter_speed", "extra_perimeters", "extra_perimeters_overhangs", "extra_perimeters_odd_layers", - "external_perimeters_first", "external_perimeters_vase", "external_perimeter_extrusion_width", + "external_perimeters_first", "external_perimeters_vase", "external_perimeter_extrusion_width", "external_perimeter_extrusion_spacing", "no_perimeter_unsupported_algo", "only_one_perimeter_top", "overhangs", "overhangs_reverse", "perimeter_loop", "perimeter_loop_seam","perimeter_speed", "seam_position", "small_perimeter_speed", "small_perimeter_min_length", " small_perimeter_max_length", "spiral_vase", @@ -375,12 +375,12 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) bool has_solid_infill = has_top_solid_infill || has_bottom_solid_infill || (have_infill && (config->opt_int("solid_infill_every_layers") > 0 || config->opt_float("solid_infill_below_area") > 0)); // solid_infill_extruder uses the same logic as in Print::extruders() for (auto el : { "top_fill_pattern", "bottom_fill_pattern", "solid_fill_pattern", "enforce_full_fill_volume", "external_infill_margin", "bridged_infill_margin", - "solid_infill_extruder", "solid_infill_extrusion_width", "solid_infill_speed" }) + "solid_infill_extruder", "solid_infill_extrusion_width", "solid_infill_extrusion_spacing", "solid_infill_speed" }) toggle_field(el, has_solid_infill); toggle_field("infill_first", (has_solid_infill || have_infill)); - for (auto el : { "fill_angle", "fill_angle_increment", "bridge_angle", "infill_extrusion_width", + for (auto el : { "fill_angle", "fill_angle_increment", "bridge_angle", "infill_extrusion_width", "infill_extrusion_spacing", "infill_speed" }) toggle_field(el, have_infill || has_solid_infill); @@ -396,7 +396,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) for (auto el : {"fill_smooth_width, fill_smooth_distribution" }) toggle_field(el, has_ironing_pattern); - for (auto el : { "ironing", "top_fill_pattern", "infill_connection_top", "top_infill_extrusion_width", "top_solid_infill_speed" }) + for (auto el : { "ironing", "top_fill_pattern", "infill_connection_top", "top_infill_extrusion_width", "top_infill_extrusion_spacing", "top_solid_infill_speed" }) toggle_field(el, has_top_solid_infill); for (auto el : { "bottom_fill_pattern", "infill_connection_bottom" }) @@ -450,13 +450,27 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) toggle_field(el, have_support_material && have_support_interface); toggle_field("support_material_synchronize_layers", have_support_soluble); - toggle_field("perimeter_extrusion_width", have_perimeters || have_skirt || have_brim); + toggle_field("perimeter_extrusion_width", have_perimeters || have_brim); + toggle_field("perimeter_extrusion_spacing", have_perimeters || have_brim); + toggle_field("skirt_extrusion_width", have_skirt); toggle_field("support_material_extruder", have_support_material || have_skirt); toggle_field("support_material_speed", have_support_material || have_brim || have_skirt); + //for default_extrusion_width/spacing, you need to ahve at least an extrusion_width with 0 + bool have_default_width = config->option("first_layer_extrusion_width")->getFloat() == 0 || + (config->option("perimeter_extrusion_width")->getFloat() == 0 && (have_perimeters || have_brim)) || + (config->option("external_perimeter_extrusion_width")->getFloat() == 0 && have_perimeters) || + (config->option("infill_extrusion_width")->getFloat() == 0 && (have_infill || has_solid_infill)) || + (config->option("solid_infill_extrusion_width")->getFloat() == 0 && has_solid_infill) || + (config->option("top_infill_extrusion_width")->getFloat() == 0 && has_top_solid_infill) || + (config->option("support_material_extrusion_width")->getFloat() == 0 && have_support_material) || + (config->option("skirt_extrusion_width")->getFloat() == 0 && have_skirt); + toggle_field("extrusion_width", have_default_width); + toggle_field("extrusion_spacing", have_default_width); + bool has_PP_ironing = has_top_solid_infill && config->opt_bool("ironing"); for (auto el : { "ironing_type", "ironing_flowrate", "ironing_spacing", "ironing_angle" }) - toggle_field(el, has_PP_ironing); + toggle_field(el, has_PP_ironing); bool has_ironing = has_PP_ironing || has_ironing_pattern; for (auto el : { "ironing_speed" }) @@ -465,7 +479,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) bool have_sequential_printing = config->opt_bool("complete_objects"); for (auto el : { /*"extruder_clearance_radius", "extruder_clearance_height",*/ "complete_objects_one_skirt", - "complete_objects_sort", "complete_objects_one_brim"}) + "complete_objects_sort", "complete_objects_one_brim"}) toggle_field(el, have_sequential_printing); bool have_ooze_prevention = config->opt_bool("ooze_prevention"); From 7b6b4b0871783657f6d4620b0a92c90e316ddda6 Mon Sep 17 00:00:00 2001 From: supermerill Date: Mon, 20 Dec 2021 20:18:31 +0100 Subject: [PATCH 14/14] typo: A platter is a tray (a plate). A plater is someone who plate metals. I won't fix mainline/prusa typo in the source code, only the text. --- src/libslic3r/PrintConfig.cpp | 8 ++++---- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/GUI/KBShortcutsDialog.cpp | 16 ++++++++-------- src/slic3r/GUI/MainFrame.cpp | 4 ++-- src/slic3r/GUI/Preferences.cpp | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index bf15e6c6a27..3d6649e3c9e 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -610,7 +610,7 @@ void PrintConfigDef::init_fff_params() def->label = L("Allow only one skirt loop"); def->category = OptionCategory::output; def->tooltip = L("When using 'Complete individual objects', the default behavior is to draw the skirt around each object." - " if you prefer to have only one skirt for the whole plater, use this option."); + " if you prefer to have only one skirt for the whole platter, use this option."); def->mode = comAdvanced; def->set_default_value(new ConfigOptionBool(false)); @@ -726,7 +726,7 @@ void PrintConfigDef::init_fff_params() def = this->add("duplicate_distance", coFloat); def->label = L("Default distance between objects"); def->category = OptionCategory::output; - def->tooltip = L("Default distance used for the auto-arrange feature of the plater.\nSet to 0 to use the last value instead."); + def->tooltip = L("Default distance used for the auto-arrange feature of the platter.\nSet to 0 to use the last value instead."); def->sidetext = L("mm"); def->aliases = { "multiply_distance" }; def->min = 0; @@ -1171,7 +1171,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Set this to the clearance radius around your extruder. " "If the extruder is not centered, choose the largest value for safety. " "This setting is used to check for collisions and to display the graphical preview " - "in the plater." + "in the platter." "\nSet zero to disable clearance checking."); def->sidetext = L("mm"); def->min = 0; @@ -4822,7 +4822,7 @@ void PrintConfigDef::init_fff_params() def = this->add("z_step", coFloat); def->label = L("Z full step"); def->tooltip = L("Set this to the height moved when your Z motor (or equivalent) turns one step." - "If your motor needs 200 steps to move your head/plater by 1mm, this field should be 1/200 = 0.005." + "If your motor needs 200 steps to move your head/platter by 1mm, this field should be 1/200 = 0.005." "\nNote that the gcode will write the z values with 6 digits after the dot if z_step is set (it's 3 digits if it's disabled)." "\nSet zero to disable."); def->cli = "z-step=f"; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index a6a72e3c99e..4bc3360e51e 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1908,7 +1908,7 @@ void GUI_App::add_config_menu(wxMenuBar *menu) title += " - " + _L("Language selection"); wxMessageDialog dialog(nullptr, _L("Switching the language will trigger application restart.\n" - "You will lose content of the plater.") + "\n\n" + + "You will lose content of the platter.") + "\n\n" + _L("Do you want to proceed?"), title, wxICON_QUESTION | wxOK | wxCANCEL); diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index 42a92b8f1c3..6603bb78248 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -66,13 +66,13 @@ void KBShortcutsDialog::fill_shortcuts() if (wxGetApp().is_editor()) { Shortcuts commands_shortcuts = { // File - { ctrl + "N", L("New project, clear plater") }, - { ctrl + "O", L("Open project STL/OBJ/AMF/3MF with config, clear plater") }, + { ctrl + "N", L("New project, clear platter") }, + { ctrl + "O", L("Open project STL/OBJ/AMF/3MF with config, clear platter") }, { ctrl + "S", L("Save project (3mf)") }, { ctrl + alt + "S", L("Save project as (3mf)") }, { ctrl + "R", L("(Re)slice") }, // File>Import - { ctrl + "I", L("Import STL/OBJ/AMF/3MF without config, keep plater") }, + { ctrl + "I", L("Import STL/OBJ/AMF/3MF without config, keep platter") }, { ctrl + "L", L("Import Config from ini/amf/3mf/gcode") }, { ctrl + alt + "L", L("Load Config from ini/amf/3mf/gcode and merge") }, // File>Export @@ -91,9 +91,9 @@ void KBShortcutsDialog::fill_shortcuts() { ctrl + "C", L("Copy to clipboard") }, { ctrl + "V", L("Paste from clipboard") }, #ifdef __APPLE__ - { ctrl + "Shift+" + "R", L("Reload plater from disk") }, + { ctrl + "Shift+" + "R", L("Reload platter from disk") }, #else - { "F5", L("Reload plater from disk") }, + { "F5", L("Reload platter from disk") }, #endif // __APPLE__ { ctrl + "F", L("Search") }, // Window @@ -169,7 +169,7 @@ void KBShortcutsDialog::fill_shortcuts() #endif // ENABLE_RENDER_PICKING_PASS }; - m_full_shortcuts.push_back({ { _L("Plater"), "" }, plater_shortcuts }); + m_full_shortcuts.push_back({ { _L("Platter"), "" }, plater_shortcuts }); Shortcuts gizmos_shortcuts = { { ctrl, L("All gizmos: Rotate - left mouse button; Pan - right mouse button") }, @@ -187,9 +187,9 @@ void KBShortcutsDialog::fill_shortcuts() Shortcuts commands_shortcuts = { { ctrl + "O", L("Open a G-code file") }, #ifdef __APPLE__ - { ctrl + "Shift+" + "R", L("Reload the plater from disk") }, + { ctrl + "Shift+" + "R", L("Reload the platter from disk") }, #else - { "F5", L("Reload plater from disk") }, + { "F5", L("Reload platter from disk") }, #endif // __APPLE__ }; diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 1804cb13d05..c3721a4b995 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -428,7 +428,7 @@ void MainFrame::update_layout() { //layout m_plater->Reparent(m_tabpanel); - m_tabpanel->InsertPage(0, m_plater, _L("Plater")); + m_tabpanel->InsertPage(0, m_plater, _L("Platter")); m_main_sizer->Add(m_tabpanel, 1, wxEXPAND); update_icon(); // show @@ -467,7 +467,7 @@ void MainFrame::update_layout() m_tabpanel->Hide(); m_main_sizer->Add(m_tabpanel, 1, wxEXPAND); m_plater_page = new wxPanel(m_tabpanel); - m_tabpanel->InsertPage(0, m_plater_page, _L("Plater")); // empty panel just for Plater tab */ + m_tabpanel->InsertPage(0, m_plater_page, _L("Platter")); // empty panel just for Plater tab */ update_icon(); m_plater->Show(); break; diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 68987b44b2b..dcbd277f71d 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -138,7 +138,7 @@ void PreferencesDialog::build() def_combobox_auto_switch_preview.gui_flags = "show_value"; def_combobox_auto_switch_preview.enum_values.push_back(_u8L("Don't switch")); def_combobox_auto_switch_preview.enum_values.push_back(_u8L("Switch when possible")); - def_combobox_auto_switch_preview.enum_values.push_back(_u8L("Only if on plater")); + def_combobox_auto_switch_preview.enum_values.push_back(_u8L("Only if on platter")); def_combobox_auto_switch_preview.enum_values.push_back(_u8L("Only when GCode is ready")); if (app_config->get("auto_switch_preview") == "0") def_combobox_auto_switch_preview.set_default_value(new ConfigOptionStrings{ def_combobox_auto_switch_preview.enum_values[0] }); @@ -803,7 +803,7 @@ void PreferencesDialog::create_settings_mode_widget(wxNotebook* tabs) #ifndef WIN32 + " " + unstable_warning #endif - + "\n* " + _L("Old layout: all windows are in the application, settings are on the top tab bar and the plater choice in on the bottom of the plater view.") + + "\n* " + _L("Old layout: all windows are in the application, settings are on the top tab bar and the platter choice in on the bottom of the platter view.") + "\n* " + _L("Settings button: all windows are in the application, no tabs: you have to clic on settings gears to switch to settings tabs.") + "\n* " + _L("Settings window: settings are displayed in their own window. You have to clic on settings gears to show the settings window.") );