Skip to content

Commit 53240e4

Browse files
committed
Introduce setting "Inner Wall Inset"
CURA-13281
1 parent b226085 commit 53240e4

9 files changed

Lines changed: 136 additions & 5 deletions

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ set(engine_SRCS # Except main.cpp.
102102
src/BeadingStrategy/RedistributeBeadingStrategy.cpp
103103
src/BeadingStrategy/WideningBeadingStrategy.cpp
104104
src/BeadingStrategy/OuterWallInsetBeadingStrategy.cpp
105+
src/BeadingStrategy/InnerWallInsetBeadingStrategy.cpp
105106

106107
src/bridge/bridge.cpp
107108
src/bridge/ExpansionRange.cpp

include/BeadingStrategy/BeadingStrategyFactory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class BeadingStrategyFactory
2727
const Ratio wall_add_middle_threshold = 0.5_r,
2828
const coord_t max_bead_count = 0,
2929
const coord_t outer_wall_offset = 0,
30+
const coord_t inner_wall_offset = 0,
3031
const int inward_distributed_center_wall_count = 2,
3132
const Ratio minimum_variable_line_ratio = 0.5);
3233
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) 2020 Ultimaker B.V.
2+
// CuraEngine is released under the terms of the AGPLv3 or higher.
3+
4+
#ifndef INNER_WALL_INSET_BEADING_STRATEGY_H
5+
#define INNER_WALL_INSET_BEADING_STRATEGY_H
6+
7+
#include "BeadingStrategy.h"
8+
9+
namespace cura
10+
{
11+
/*
12+
* This is a meta strategy that allows for the outer wall to be inset towards the inside of the model.
13+
*/
14+
class InnerWallInsetBeadingStrategy : public BeadingStrategy
15+
{
16+
public:
17+
InnerWallInsetBeadingStrategy(coord_t inner_wall_offset, BeadingStrategyPtr parent);
18+
19+
virtual ~InnerWallInsetBeadingStrategy() = default;
20+
21+
Beading compute(coord_t thickness, coord_t bead_count) const override;
22+
23+
coord_t getOptimalThickness(coord_t bead_count) const override;
24+
coord_t getTransitionThickness(coord_t lower_bead_count) const override;
25+
coord_t getOptimalBeadCount(coord_t thickness) const override;
26+
coord_t getTransitioningLength(coord_t lower_bead_count) const override;
27+
28+
std::string toString() const override;
29+
30+
private:
31+
BeadingStrategyPtr parent_;
32+
coord_t inner_wall_offset_;
33+
};
34+
} // namespace cura
35+
#endif // INNER_WALL_INSET_BEADING_STRATEGY_H

include/WallToolPaths.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ class WallToolPaths
2020
* \param nominal_bead_width The nominal bead width used in the generation of the toolpaths
2121
* \param inset_count The maximum number of parallel extrusion lines that make up the wall
2222
* \param wall_0_inset How far to inset the outer wall, to make it adhere better to other walls.
23+
* \param wall_x_inset How far to inset the inner walls, to make it adhere better to other walls.
2324
* \param settings The settings as provided by the user
2425
*/
2526
WallToolPaths(
2627
const Shape& outline,
2728
const coord_t nominal_bead_width,
2829
const size_t inset_count,
2930
const coord_t wall_0_inset,
31+
const coord_t wall_x_inset,
3032
const Settings& settings,
3133
const int layer_idx,
3234
SectionType section_type);
@@ -38,6 +40,7 @@ class WallToolPaths
3840
* \param bead_width_x The bead width of the inner walls used in the generation of the toolpaths
3941
* \param inset_count The maximum number of parallel extrusion lines that make up the wall
4042
* \param wall_0_inset How far to inset the outer wall, to make it adhere better to other walls.
43+
* \param wall_x_inset How far to inset the inner walls, to make it adhere better to other walls.
4144
* \param settings The settings as provided by the user
4245
*/
4346
WallToolPaths(
@@ -46,6 +49,7 @@ class WallToolPaths
4649
const coord_t bead_width_x,
4750
const size_t inset_count,
4851
const coord_t wall_0_inset,
52+
const coord_t wall_x_inset,
4953
const Settings& settings,
5054
const int layer_idx,
5155
SectionType section_type);
@@ -125,6 +129,7 @@ class WallToolPaths
125129
// this is the same as bead_width_0
126130
size_t inset_count_; //<! The maximum number of walls to generate
127131
coord_t wall_0_inset_; //<! How far to inset the outer wall. Should only be applied when printing the actual walls, not extra infill/skin/support walls.
132+
coord_t wall_x_inset_; //<! How far to inset the inner walls
128133
bool print_thin_walls_; //<! Whether to enable the widening beading meta-strategy for thin features
129134
coord_t min_feature_size_; //<! The minimum size of the features that can be widened by the widening beading meta-strategy. Features thinner than that will not be printed
130135
coord_t min_bead_width_; //<! The minimum bead size to use when widening thin model features with the widening beading meta-strategy

src/BeadingStrategy/BeadingStrategyFactory.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "BeadingStrategy/DistributedBeadingStrategy.h"
1111
#include "BeadingStrategy/LimitedBeadingStrategy.h"
1212
#include "BeadingStrategy/OuterWallInsetBeadingStrategy.h"
13+
#include "BeadingStrategy/InnerWallInsetBeadingStrategy.h"
1314
#include "BeadingStrategy/RedistributeBeadingStrategy.h"
1415
#include "BeadingStrategy/WideningBeadingStrategy.h"
1516

@@ -28,6 +29,7 @@ BeadingStrategyPtr BeadingStrategyFactory::makeStrategy(
2829
const Ratio wall_add_middle_threshold,
2930
const coord_t max_bead_count,
3031
const coord_t outer_wall_offset,
32+
const coord_t inner_wall_offset,
3133
const int inward_distributed_center_wall_count,
3234
const Ratio minimum_variable_line_ratio)
3335
{
@@ -53,6 +55,11 @@ BeadingStrategyPtr BeadingStrategyFactory::makeStrategy(
5355
spdlog::debug("Applying the OuterWallOffset meta-strategy with offset = {}", outer_wall_offset);
5456
ret = make_unique<OuterWallInsetBeadingStrategy>(outer_wall_offset, std::move(ret));
5557
}
58+
if (inner_wall_offset != 0)
59+
{
60+
spdlog::debug("Applying the InnerWallOffset meta-strategy with offset = {}", inner_wall_offset);
61+
ret = make_unique<InnerWallInsetBeadingStrategy>(inner_wall_offset, std::move(ret));
62+
}
5663

5764
// Apply the LimitedBeadingStrategy last, since that adds a 0-width marker wall which other beading strategies shouldn't touch.
5865
spdlog::debug("Applying the Limited Beading meta-strategy with maximum bead count = {}", max_bead_count);
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright (c) 2026 UltiMaker
2+
// CuraEngine is released under the terms of the AGPLv3 or higher.
3+
4+
#include "BeadingStrategy/InnerWallInsetBeadingStrategy.h"
5+
6+
#include <range/v3/view/drop.hpp>
7+
8+
#include <algorithm>
9+
10+
namespace cura
11+
{
12+
InnerWallInsetBeadingStrategy::InnerWallInsetBeadingStrategy(coord_t outer_wall_offset, BeadingStrategyPtr parent)
13+
: BeadingStrategy(*parent)
14+
, parent_(std::move(parent))
15+
, inner_wall_offset_(outer_wall_offset)
16+
{
17+
name_ = "InnerWallInsetBeadingStrategy";
18+
}
19+
20+
21+
coord_t InnerWallInsetBeadingStrategy::getOptimalThickness(coord_t bead_count) const
22+
{
23+
return parent_->getOptimalThickness(bead_count);
24+
}
25+
26+
coord_t InnerWallInsetBeadingStrategy::getTransitionThickness(coord_t lower_bead_count) const
27+
{
28+
return parent_->getTransitionThickness(lower_bead_count);
29+
}
30+
31+
coord_t InnerWallInsetBeadingStrategy::getOptimalBeadCount(coord_t thickness) const
32+
{
33+
return parent_->getOptimalBeadCount(thickness);
34+
}
35+
36+
coord_t InnerWallInsetBeadingStrategy::getTransitioningLength(coord_t lower_bead_count) const
37+
{
38+
return parent_->getTransitioningLength(lower_bead_count);
39+
}
40+
41+
std::string InnerWallInsetBeadingStrategy::toString() const
42+
{
43+
return std::string("InnerWallInsetBeadingStrategy+") + parent_->toString();
44+
}
45+
46+
BeadingStrategy::Beading InnerWallInsetBeadingStrategy::compute(coord_t thickness, coord_t bead_count) const
47+
{
48+
Beading ret = parent_->compute(thickness, bead_count);
49+
50+
// Actual count and thickness as represented by extant walls. Don't count any potential zero-width 'signaling' walls.
51+
bead_count = std::count_if(
52+
ret.bead_widths.begin(),
53+
ret.bead_widths.end(),
54+
[](const coord_t width)
55+
{
56+
return width > 0;
57+
});
58+
59+
// No need to apply any inset if there is just a single wall.
60+
if (bead_count < 2)
61+
{
62+
return ret;
63+
}
64+
65+
for (auto& location : ret.toolpath_locations | ranges::views::drop(1))
66+
{
67+
location += inner_wall_offset_;
68+
}
69+
70+
return ret;
71+
}
72+
73+
} // namespace cura

src/WallToolPaths.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ WallToolPaths::WallToolPaths(
2727
const coord_t nominal_bead_width,
2828
const size_t inset_count,
2929
const coord_t wall_0_inset,
30+
const coord_t wall_x_inset,
3031
const Settings& settings,
3132
const int layer_idx,
3233
SectionType section_type)
@@ -35,6 +36,7 @@ WallToolPaths::WallToolPaths(
3536
, bead_width_x_(nominal_bead_width)
3637
, inset_count_(inset_count)
3738
, wall_0_inset_(wall_0_inset)
39+
, wall_x_inset_(wall_x_inset)
3840
, print_thin_walls_(settings.get<bool>("fill_outline_gaps"))
3941
, min_feature_size_(nominal_bead_width / 4)
4042
, min_bead_width_(std::min(min_even_wall_line_width_, min_odd_wall_line_width_))
@@ -61,6 +63,7 @@ WallToolPaths::WallToolPaths(
6163
const coord_t bead_width_x,
6264
const size_t inset_count,
6365
const coord_t wall_0_inset,
66+
const coord_t wall_x_inset,
6467
const Settings& settings,
6568
const int layer_idx,
6669
SectionType section_type)
@@ -69,6 +72,7 @@ WallToolPaths::WallToolPaths(
6972
, bead_width_x_(bead_width_x)
7073
, inset_count_(inset_count)
7174
, wall_0_inset_(wall_0_inset)
75+
, wall_x_inset_(wall_x_inset)
7276
, print_thin_walls_(settings.get<bool>("fill_outline_gaps"))
7377
, min_feature_size_(settings.get<coord_t>("min_feature_size"))
7478
, min_bead_width_(settings.get<coord_t>("min_bead_width"))
@@ -120,6 +124,7 @@ const std::vector<VariableWidthLines>& WallToolPaths::generate()
120124
wall_add_middle_threshold,
121125
max_bead_count,
122126
wall_0_inset_,
127+
wall_x_inset_,
123128
wall_distribution_count_);
124129
SkeletalTrapezoidation wall_maker(
125130
prepared_outline,

src/WallsComputation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void WallsComputation::generateWalls(SliceLayerPart* part, SectionType section_t
6161
const Ratio line_width_0_factor = first_layer ? settings_.get<ExtruderTrain&>("wall_0_extruder_nr").settings_.get<Ratio>("initial_layer_line_width_factor") : 1.0_r;
6262
const coord_t line_width_0 = settings_.get<coord_t>("wall_line_width_0") * line_width_0_factor;
6363
const coord_t wall_0_inset = settings_.get<coord_t>("wall_0_inset");
64+
const coord_t wall_x_inset = settings_.get<coord_t>("wall_x_inset");
6465

6566
const Ratio line_width_x_factor = first_layer ? settings_.get<ExtruderTrain&>("wall_x_extruder_nr").settings_.get<Ratio>("initial_layer_line_width_factor") : 1.0_r;
6667
const coord_t line_width_x = settings_.get<coord_t>("wall_line_width_x") * line_width_x_factor;
@@ -81,7 +82,7 @@ void WallsComputation::generateWalls(SliceLayerPart* part, SectionType section_t
8182
}
8283
else
8384
{
84-
WallToolPaths wall_tool_paths(part->outline, line_width_0, line_width_x, wall_count, wall_0_inset, settings_, layer_nr_, section_type);
85+
WallToolPaths wall_tool_paths(part->outline, line_width_0, line_width_x, wall_count, wall_0_inset, wall_x_inset, settings_, layer_nr_, section_type);
8586
part->wall_toolpaths = wall_tool_paths.getToolPaths();
8687
part->inner_area = wall_tool_paths.getInnerContour();
8788
}

src/infill.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ Shape Infill::generateWallToolPaths(
7171
if (wall_line_count > 0)
7272
{
7373
constexpr coord_t wall_0_inset = 0; // Don't apply any outer wall inset for these. That's just for the outer wall.
74-
WallToolPaths wall_toolpaths(outer_contour, line_width, wall_line_count, wall_0_inset, settings, layer_idx, section_type);
74+
constexpr coord_t wall_x_inset = 0; // Don't apply any inner wall inset for these. That's just for the outer wall.
75+
WallToolPaths wall_toolpaths(outer_contour, line_width, wall_line_count, wall_0_inset, wall_x_inset, settings, layer_idx, section_type);
7576
wall_toolpaths.pushToolPaths(toolpaths);
7677
inner_contour = wall_toolpaths.getInnerContour();
7778
}
@@ -142,7 +143,8 @@ void Infill::generate(
142143

143144
// Fill narrow area with walls.
144145
const size_t narrow_wall_count = small_area_width_ / infill_line_width_ + 1;
145-
WallToolPaths wall_toolpaths(small_infill, infill_line_width_, narrow_wall_count, 0, settings, layer_idx, section_type);
146+
const coord_t inset = 0; // outer/inner wall inset is set to 0
147+
WallToolPaths wall_toolpaths(small_infill, infill_line_width_, narrow_wall_count, inset, inset, settings, layer_idx, section_type);
146148
std::vector<VariableWidthLines> small_infill_paths = wall_toolpaths.getToolPaths();
147149
scripta::log(
148150
"infill_small_infill_paths_0",
@@ -505,8 +507,9 @@ void Infill::generateConcentricInfill(const Shape& outline, std::vector<Variable
505507
}
506508

507509
constexpr size_t inset_wall_count = 1; // 1 wall at a time.
508-
constexpr coord_t wall_0_inset = 0; // Don't apply any outer wall inset for these. That's just for the outer wall.
509-
WallToolPaths wall_toolpaths(current_inset, infill_line_width_, inset_wall_count, wall_0_inset, settings, layer_idx, SectionType::CONCENTRIC_INFILL);
510+
constexpr coord_t wall_0_inset = 0; // Don't apply any inner/outer wall inset for these. That's just for the outer wall.
511+
constexpr coord_t wall_x_inset = 0; // Don't apply any outer wall inset for these. That's just for the outer wall.
512+
WallToolPaths wall_toolpaths(current_inset, infill_line_width_, inset_wall_count, wall_0_inset, wall_x_inset, settings, layer_idx, SectionType::CONCENTRIC_INFILL);
510513
const std::vector<VariableWidthLines> inset_paths = wall_toolpaths.getToolPaths();
511514
toolpaths.insert(toolpaths.end(), inset_paths.begin(), inset_paths.end());
512515

0 commit comments

Comments
 (0)