Skip to content

Commit

Permalink
alternating perimeters (and new try for mac)
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Feb 29, 2024
2 parents fb26f35 + d7ee922 commit c3b79ef
Show file tree
Hide file tree
Showing 47 changed files with 709 additions and 257 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ccpp_mac_arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
build:

runs-on: macos-11
runs-on: macos-14

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ccpp_mac_arm_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build:

runs-on: macos-11
runs-on: macos-14

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ccpp_mac_arm_rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build:

runs-on: macos-11
runs-on: macos-14

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ if(WIN32)
endif()

if (APPLE)
add_compile_options(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
message("OS X SDK Path: ${CMAKE_OSX_SYSROOT}")
if (CMAKE_OSX_DEPLOYMENT_TARGET)
message("OS X Deployment Target: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
Expand Down
2 changes: 1 addition & 1 deletion resources/profiles
Submodule profiles updated 2 files
+0 −1 Basic.ini
+1 −1 Voron.ini
2 changes: 2 additions & 0 deletions resources/ui_layout/default/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ group:label_width$12:Overhangs
line:Extrusion direction
setting:sidetext_width$2:overhangs_reverse
setting:label_width$12:width$5:overhangs_reverse_threshold
setting:label$All perimeters:sidetext_width$2:perimeter_reverse
end_line
group:sidetext_width$5:Advanced
setting:width$25:no_perimeter_unsupported_algo
Expand Down Expand Up @@ -169,6 +170,7 @@ group:title_width$0:Infill
setting:tags$Advanced$Expert$Prusa:label_left:label_width$6:label$Sparse:width$8:sidetext_width$1:fill_density
setting:tags$Advanced$Expert$Prusa:label_width$0:label$_:fill_pattern
setting:label$_:width$18:infill_connection
setting:label$Aligned:fill_aligned_z
end_line
line:_
setting:label$Connection length:label_width$25:sidetext_width$7:width$12:infill_anchor_max
Expand Down
6 changes: 6 additions & 0 deletions resources/ui_layout/example/freq_fff.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ group:freq_settings_event:no_title:no_search:
setting:simple:script:bool:depends$brim_width:label$Brim:tooltip$Set the brim. Will be set to 5mm if nothing was previously set.:s_brim
freq_purging_volumes
end_line
line:
setting:simple:script:enum$hot$Hot$mild$Mild$cold$Cold:depends$bed_temperature$first_layer_bed_temperature:label$Bed temp:tooltip$Choose the bed you want.:full_width:s_bed_temp_fff
end_line
line:
setting:simple:script:enum$normal$Default$45$45°$custom$Custom:depends$init_z_rotate:label$Import angle:tooltip$The angle at which the parts are imported:full_width:s_orientation_fff
end_line
52 changes: 52 additions & 0 deletions resources/ui_layout/example/print.as
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,55 @@ void s_noperi_set(string &out set_val, int idx)
if (idx == 0) set_int("no_perimeter_unsupported_algo",0);
else set_string("no_perimeter_unsupported_algo", "filled");
}

// quick settings bed temp
int s_bed_temp_fff_get(string &out get_val)
{
int bed_temperature = get_int("bed_temperature");
int fl_bed_temperature = get_int("first_layer_bed_temperature");
if (bed_temperature >= 70 && fl_bed_temperature >= 70) {
return 0; //hot
}
if (bed_temperature >= 45 && fl_bed_temperature >= 45) {
return 1; //mild
}
return 2; // cold
}
void s_bed_temp_fff_set(string &in new_val, int idx)
{
if(idx == 0) { // hot
set_int("bed_temperature", 70);
set_int("first_layer_bed_temperature", 75);
} else if(idx == 1) { // mild
set_int("bed_temperature", 45);
set_int("first_layer_bed_temperature", 50);
} else if(idx == 2) { // cold
set_int("bed_temperature", 0);
set_int("first_layer_bed_temperature", 0);
}
}


// quick settings orientation
int s_orientation_fff_get(string &out get_val)
{
float orientation = get_float("init_z_rotate");
if (orientation == 0) {
return 0; // normal
}
if (orientation == 45) {
return 1; // 45°
}
return 3; // custom
}
void s_orientation_fff_set(string &in new_val, int idx)
{
if(idx == 0) { // normal
set_float("init_z_rotate", 0);
} else if(idx == 1) { // 45°
set_float("init_z_rotate", 45);
} else if(idx == 2) { // reset
back_initial_value("init_z_rotate");
}
}

3 changes: 3 additions & 0 deletions src/libslic3r/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ void AppConfig::set_defaults()
if (get("font_size").empty())
set("font_size", "0");

if (get("gcodeviewer_decimals").empty())
set("gcodeviewer_decimals", "2");

//get default color from the ini file

//try to load colors from ui file
Expand Down
7 changes: 7 additions & 0 deletions src/libslic3r/Arachne/utils/ExtrusionLine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ static inline Slic3r::ThickPolyline to_thick_polyline(const ClipperLib_Z::Path &
out.points_width.emplace_back(it->z());
}
}
// Don't create 1-element polyline.
if(out.points.size() <2)
return {};

assert(out.points.back().coincides_with_epsilon(Point{ path.back().x(), path.back().y() }));
out.points.back() = Point{ path.back().x(), path.back().y() };

assert(out.points.front().x() == path.front().x());
assert(out.points.front().y() == path.front().y());
assert(out.points.back().x() == path.back().x());
Expand Down
29 changes: 23 additions & 6 deletions src/libslic3r/ExtrusionEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,24 @@ class ExtrusionLoop : public ExtrusionEntity
ExtrusionPaths paths;

ExtrusionLoop(ExtrusionLoopRole role = elrDefault) : m_loop_role(role) , ExtrusionEntity(false) {}
ExtrusionLoop(const ExtrusionPaths &paths, ExtrusionLoopRole role = elrDefault) : paths(paths), m_loop_role(role), ExtrusionEntity(false) { assert(this->first_point().coincides_with_epsilon(this->paths.back().polyline.back())); }
ExtrusionLoop(ExtrusionPaths &&paths, ExtrusionLoopRole role = elrDefault) : paths(std::move(paths)), m_loop_role(role), ExtrusionEntity(false) { assert(this->first_point().coincides_with_epsilon(this->paths.back().polyline.back())); }
ExtrusionLoop(const ExtrusionPath &path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role), ExtrusionEntity(false)
{ this->paths.push_back(path); }
ExtrusionLoop(ExtrusionPath &&path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role), ExtrusionEntity(false)
{ this->paths.emplace_back(std::move(path)); }
ExtrusionLoop(const ExtrusionPaths &paths, ExtrusionLoopRole role = elrDefault) : paths(paths), m_loop_role(role), ExtrusionEntity(false) {
assert(!this->paths.empty());
assert(this->first_point().coincides_with_epsilon(this->paths.back().polyline.back()));
}
ExtrusionLoop(ExtrusionPaths &&paths, ExtrusionLoopRole role = elrDefault) : paths(std::move(paths)), m_loop_role(role), ExtrusionEntity(false) {
assert(!this->paths.empty());
assert(this->first_point().coincides_with_epsilon(this->paths.back().polyline.back()));
}
ExtrusionLoop(const ExtrusionPath &path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role), ExtrusionEntity(false) {
this->paths.push_back(path);
assert(!this->paths.empty());
assert(this->first_point().coincides_with_epsilon(this->paths.back().polyline.back()));
}
ExtrusionLoop(ExtrusionPath &&path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role), ExtrusionEntity(false) {
this->paths.emplace_back(std::move(path));
assert(!this->paths.empty());
assert(this->first_point().coincides_with_epsilon(this->paths.back().polyline.back()));
}
virtual bool is_loop() const override{ return true; }
virtual ExtrusionEntity* clone() const override{ return new ExtrusionLoop (*this); }
// Create a new object, initialize it with this object using the move semantics.
Expand Down Expand Up @@ -617,6 +629,11 @@ struct HasInfillVisitor : public HasRoleVisitor{
struct HasSolidInfillVisitor : public HasRoleVisitor{
void default_use(const ExtrusionEntity &entity) override { found = is_solid_infill(entity.role()); };
};
struct HasThisRoleVisitor : public HasRoleVisitor{
ExtrusionRole role_to_find;
HasThisRoleVisitor(ExtrusionRole role) : role_to_find(role) {}
void default_use(const ExtrusionEntity &entity) override { found = entity.role() == role_to_find; };
};


//call simplify for all paths.
Expand Down
25 changes: 20 additions & 5 deletions src/libslic3r/Fill/Fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ struct SurfaceFillParams : FillParams

RETURN_COMPARE_NON_EQUAL(anchor_length);
RETURN_COMPARE_NON_EQUAL(fill_exactly);
RETURN_COMPARE_NON_EQUAL(flow.width());
RETURN_COMPARE_NON_EQUAL(flow.height());
RETURN_COMPARE_NON_EQUAL(flow.nozzle_diameter());
RETURN_COMPARE_NON_EQUAL_TYPED(unsigned, flow.bridge());
Expand All @@ -80,7 +79,10 @@ struct SurfaceFillParams : FillParams
RETURN_COMPARE_NON_EQUAL(config->bridge_speed_internal);
RETURN_COMPARE_NON_EQUAL(config->gap_fill_speed);
RETURN_COMPARE_NON_EQUAL(config->print_extrusion_multiplier);
RETURN_COMPARE_NON_EQUAL(max_sparse_infill_spacing);
}
if (config == nullptr || rhs.config == nullptr || max_sparse_infill_spacing == 0)
RETURN_COMPARE_NON_EQUAL(flow.width());
assert(*this == rhs);
return false;
}
Expand Down Expand Up @@ -116,6 +118,7 @@ struct SurfaceFillParams : FillParams
this->fill_exactly == rhs.fill_exactly &&
this->flow == rhs.flow &&
this->role == rhs.role &&
this->max_sparse_infill_spacing == rhs.max_sparse_infill_spacing &&
this->priority == rhs.priority;
}
};
Expand Down Expand Up @@ -282,17 +285,18 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
//FIXME FLOW decide what to use
// Internal infill. Calculating infill line spacing independent of the current layer height and 1st layer status,
// so that internall infill will be aligned over all layers of the current region.
//params.spacing = layerm.region().flow(*layer.object(), frInfill, layer.object()->config().layer_height, false).spacing();
//params.spacing = layerm.region().flow(*layer.object(), frInfill, layer.heigh, false).spacing();
// it's internal infill, so we can calculate a generic flow spacing
// for all layers, for avoiding the ugly effect of
// misaligned infill on first layer because of different extrusion width and
// layer height
params.spacing = layerm.region().flow(
Flow infill_flow = layerm.region().flow(
*layer.object(),
frInfill,
layer.object()->config().layer_height.value, // TODO: handle infill_every_layers?
layer.height, // TODO: handle infill_every_layers?
layer.id()
).spacing();
);
params.spacing = infill_flow.spacing();

// Anchor a sparse infill to inner perimeters with the following anchor length:
params.anchor_length = float(region_config.infill_anchor);
Expand All @@ -302,6 +306,16 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
if (region_config.infill_anchor_max.percent)
params.anchor_length_max = float(params.anchor_length_max * 0.01 * params.spacing);
params.anchor_length = std::min(params.anchor_length, params.anchor_length_max);

//sparse infill, compute the max width if needed
if (region_config.fill_aligned_z) {
//don't use fill_aligned_z if the pattern can't use it.
if (params.pattern != ipHilbertCurve && params.pattern != ipArchimedeanChords &&
params.pattern != ipOctagramSpiral && params.pattern != ipScatteredRectilinear &&
params.pattern != ipLightning) {
params.max_sparse_infill_spacing = unscaled(layer.object()->get_sparse_max_spacing());
}
}
}

auto it_params = set_surface_params.find(params);
Expand Down Expand Up @@ -805,6 +819,7 @@ void Layer::make_ironing()
};

std::vector<IroningParams> by_extruder;
// not using layer.height?
double default_layer_height = this->object()->config().layer_height;

for (LayerRegion *layerm : m_regions)
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Fill/Fill3DHoneycomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void Fill3DHoneycomb::_fill_surface_single(
{
// no rotation is supported for this infill pattern
BoundingBox bb = expolygon.contour.bounding_box();
coord_t distance = coord_t(scale_(this->get_spacing()) / params.density);
coord_t distance = _line_spacing_for_density(params);

// align bounding box to a multiple of our honeycomb grid module
// (a module is 2*$distance since one $distance half-module is
Expand Down
8 changes: 5 additions & 3 deletions src/libslic3r/Fill/FillBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,11 @@ void Fill::fill_surface_extrusion(const Surface *surface, const FillParams &para



coord_t Fill::_line_spacing_for_density(float density) const
coord_t Fill::_line_spacing_for_density(const FillParams& params) const
{
return scale_t(this->get_spacing() / density);
if(params.max_sparse_infill_spacing > 0)
return scale_t(params.max_sparse_infill_spacing / params.density);
return scale_t(this->get_spacing() / params.density);
}

//FIXME: add recent improvmeent from perimetergenerator: avoid thick gapfill
Expand Down Expand Up @@ -3174,7 +3176,7 @@ void Fill::connect_base_support(Polylines &&infill_ordered, const std::vector<co
#endif // INFILL_DEBUG_OUTPUT

const double line_half_width = 0.5 * scale_(spacing);
const double line_spacing = scale_(spacing) / params.density;
const double line_spacing = ((params.max_sparse_infill_spacing > 0) ? params.max_sparse_infill_spacing : spacing) / params.density;
const double min_arch_length = 1.3 * line_spacing;
const double trim_length = line_half_width * 0.3;

Expand Down
16 changes: 10 additions & 6 deletions src/libslic3r/Fill/FillBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct FillParams
// Fill density, fraction in <0, 1>
float density { 0.f };

// bridge offset from the centerline.
// bridge offset from the centerline. (scaled)
coord_t bridge_offset = -1;

// Fill extruding flow multiplier, fraction in <0, 1>. Used by "over bridge compensation"
Expand Down Expand Up @@ -94,8 +94,12 @@ struct FillParams

// For Concentric infill, to switch between Classic and Arachne.
bool use_arachne { false };
// Layer height for Concentric infill with Arachne.
coordf_t layer_height { 0.f };

// Layer height for Concentric infill with Arachne. (unscaled)
float layer_height { 0.f };

// sparse infill width to use to create the pattern (0 if not used) (unscaled)
float max_sparse_infill_spacing { 0.f };
};
static_assert(IsTriviallyCopyable<FillParams>::value, "FillParams class is not POD (and it should be - see constructor).");

Expand Down Expand Up @@ -129,7 +133,7 @@ class Fill
#endif
protected:
// in unscaled coordinates, please use init (after settings all others settings) as some algos want to modify the value
coordf_t spacing_priv;
double spacing_priv;

public:
virtual ~Fill() {}
Expand All @@ -140,7 +144,7 @@ class Fill

void set_bounding_box(const Slic3r::BoundingBox &bbox) { bounding_box = bbox; }
virtual void init_spacing(coordf_t spacing, const FillParams &params) { this->spacing_priv = spacing; }
coordf_t get_spacing() const { return spacing_priv; }
double get_spacing() const { return spacing_priv; }

// Do not sort the fill lines to optimize the print head path?
virtual bool no_sort() const { return false; }
Expand Down Expand Up @@ -191,7 +195,7 @@ class Fill

virtual float _layer_angle(size_t idx) const { return can_angle_cross && (idx & 1) ? float(M_PI/2.) : 0; }

virtual coord_t _line_spacing_for_density(float density) const;
virtual coord_t _line_spacing_for_density(const FillParams& params) const;

virtual std::pair<float, Point> _infill_direction(const Surface *surface) const;

Expand Down
6 changes: 3 additions & 3 deletions src/libslic3r/Fill/FillConcentric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FillConcentric::init_spacing(coordf_t spacing, const FillParams &params)
{
Fill::init_spacing(spacing, params);
if (params.density > 0.9999f && !params.dont_adjust) {
this->spacing_priv = unscaled(this->_adjust_solid_spacing(bounding_box.size()(0), _line_spacing_for_density(params.density)));
this->spacing_priv = unscaled(this->_adjust_solid_spacing(bounding_box.size()(0), _line_spacing_for_density(params)));
}
}

Expand All @@ -30,7 +30,7 @@ FillConcentric::_fill_surface_single(
// no rotation is supported for this infill pattern
BoundingBox bounding_box = expolygon.contour.bounding_box();

coord_t distance = _line_spacing_for_density(params.density);
coord_t distance = _line_spacing_for_density(params);
if (params.density > 0.9999f && !params.dont_adjust) {
//it's == Slic3r::FillConcentric::_adjust_solid_spacing(bounding_box.size()(0), _line_spacing_for_density(params.density)) because of the init_spacing()
distance = scale_t(this->get_spacing());
Expand Down Expand Up @@ -115,7 +115,7 @@ FillConcentricWGapFill::fill_surface_extrusion(
// no rotation is supported for this infill pattern
BoundingBox bounding_box = expolygon.contour.bounding_box();

coord_t distance = _line_spacing_for_density(params.density);
coord_t distance = _line_spacing_for_density(params);
if (params.density > 0.9999f && !params.dont_adjust) {
distance = scale_t(this->get_spacing());
}
Expand Down
Loading

0 comments on commit c3b79ef

Please sign in to comment.