Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::Arachne::LimitedBeadingStrategy Class Reference

#include <src/libslic3r/Arachne/BeadingStrategy/LimitedBeadingStrategy.hpp>

+ Inheritance diagram for Slic3r::Arachne::LimitedBeadingStrategy:
+ Collaboration diagram for Slic3r::Arachne::LimitedBeadingStrategy:

Public Member Functions

 LimitedBeadingStrategy (coord_t max_bead_count, BeadingStrategyPtr parent)
 
 ~LimitedBeadingStrategy () override=default
 
Beading compute (coord_t thickness, coord_t bead_count) const override
 
coord_t getOptimalThickness (coord_t bead_count) const override
 
coord_t getTransitionThickness (coord_t lower_bead_count) const override
 
coord_t getOptimalBeadCount (coord_t thickness) const override
 
std::string toString () const override
 
coord_t getTransitioningLength (coord_t lower_bead_count) const override
 
float getTransitionAnchorPos (coord_t lower_bead_count) const override
 
virtual std::vector< coord_tgetNonlinearThicknesses (coord_t lower_bead_count) const
 
double getSplitMiddleThreshold () const
 
double getTransitioningAngle () const
 

Protected Attributes

const coord_t max_bead_count
 
const BeadingStrategyPtr parent
 
std::string name
 
coord_t optimal_width
 
double wall_split_middle_threshold
 Optimal bead width, nominal width off the walls in 'ideal' circumstances.
 
double wall_add_middle_threshold
 Threshold when a middle wall should be split into two, as a ratio of the optimal wall width.
 
coord_t default_transition_length
 Threshold when a new middle wall should be added between an even number of walls, as a ratio of the optimal wall width.
 
double transitioning_angle
 The length of the region to smoothly transfer between bead counts.
 

Detailed Description

This is a meta-strategy that can be applied on top of any other beading strategy, which limits the thickness of the walls to the thickness that the lines can reasonably print.

The width of the wall is limited to the maximum number of contours times the maximum width of each of these contours.

If the width of the wall gets limited, this strategy outputs one additional bead with 0 width. This bead is used to denote the limits of the walled area. Other structures can then use this border to align their structures to, such as to create correctly overlapping infill or skin, or to align the infill pattern to any extra infill walls.

Constructor & Destructor Documentation

◆ LimitedBeadingStrategy()

Slic3r::Arachne::LimitedBeadingStrategy::LimitedBeadingStrategy ( coord_t  max_bead_count,
BeadingStrategyPtr  parent 
)
31 , parent(std::move(parent))
32{
33 if (max_bead_count % 2 == 1)
34 {
35 BOOST_LOG_TRIVIAL(warning) << "LimitedBeadingStrategy with odd bead count is odd indeed!";
36 }
37}
BeadingStrategy(coord_t optimal_width, double wall_split_middle_threshold, double wall_add_middle_threshold, coord_t default_transition_length, float transitioning_angle=pi_div(3))
Definition BeadingStrategy.cpp:12
const BeadingStrategyPtr parent
Definition LimitedBeadingStrategy.hpp:45
const coord_t max_bead_count
Definition LimitedBeadingStrategy.hpp:44

References max_bead_count.

◆ ~LimitedBeadingStrategy()

Slic3r::Arachne::LimitedBeadingStrategy::~LimitedBeadingStrategy ( )
overridedefault

Member Function Documentation

◆ compute()

LimitedBeadingStrategy::Beading Slic3r::Arachne::LimitedBeadingStrategy::compute ( coord_t  thickness,
coord_t  bead_count 
) const
overridevirtual

Retrieve the bead widths with which to cover a given thickness.

Requirement: Given a constant bead_count the output of each bead width must change gradually along with the thickness.

Note
The bead_count might be different from the BeadingStrategy::optimal_bead_count

Implements Slic3r::Arachne::BeadingStrategy.

40{
41 if (bead_count <= max_bead_count)
42 {
43 Beading ret = parent->compute(thickness, bead_count);
44 bead_count = ret.toolpath_locations.size();
45
46 if (bead_count % 2 == 0 && bead_count == max_bead_count)
47 {
48 const coord_t innermost_toolpath_location = ret.toolpath_locations[max_bead_count / 2 - 1];
49 const coord_t innermost_toolpath_width = ret.bead_widths[max_bead_count / 2 - 1];
50 ret.toolpath_locations.insert(ret.toolpath_locations.begin() + max_bead_count / 2, innermost_toolpath_location + innermost_toolpath_width / 2);
51 ret.bead_widths.insert(ret.bead_widths.begin() + max_bead_count / 2, 0);
52 }
53 return ret;
54 }
55 assert(bead_count == max_bead_count + 1);
56 if(bead_count != max_bead_count + 1)
57 {
58 BOOST_LOG_TRIVIAL(warning) << "Too many beads! " << bead_count << " != " << max_bead_count + 1;
59 }
60
61 coord_t optimal_thickness = parent->getOptimalThickness(max_bead_count);
62 Beading ret = parent->compute(optimal_thickness, max_bead_count);
63 bead_count = ret.toolpath_locations.size();
64 ret.left_over += thickness - ret.total_thickness;
65 ret.total_thickness = thickness;
66
67 // Enforce symmetry
68 if (bead_count % 2 == 1) {
69 ret.toolpath_locations[bead_count / 2] = thickness / 2;
70 ret.bead_widths[bead_count / 2] = thickness - optimal_thickness;
71 }
72 for (coord_t bead_idx = 0; bead_idx < (bead_count + 1) / 2; bead_idx++)
73 ret.toolpath_locations[bead_count - 1 - bead_idx] = thickness - ret.toolpath_locations[bead_idx];
74
75 //Create a "fake" inner wall with 0 width to indicate the edge of the walled area.
76 //This wall can then be used by other structures to e.g. fill the infill area adjacent to the variable-width walls.
77 coord_t innermost_toolpath_location = ret.toolpath_locations[max_bead_count / 2 - 1];
78 coord_t innermost_toolpath_width = ret.bead_widths[max_bead_count / 2 - 1];
79 ret.toolpath_locations.insert(ret.toolpath_locations.begin() + max_bead_count / 2, innermost_toolpath_location + innermost_toolpath_width / 2);
80 ret.bead_widths.insert(ret.bead_widths.begin() + max_bead_count / 2, 0);
81
82 //Symmetry on both sides. Symmetry is guaranteed since this code is stopped early if the bead_count <= max_bead_count, and never reaches this point then.
83 const size_t opposite_bead = bead_count - (max_bead_count / 2 - 1);
84 innermost_toolpath_location = ret.toolpath_locations[opposite_bead];
85 innermost_toolpath_width = ret.bead_widths[opposite_bead];
86 ret.toolpath_locations.insert(ret.toolpath_locations.begin() + opposite_bead, innermost_toolpath_location - innermost_toolpath_width / 2);
87 ret.bead_widths.insert(ret.bead_widths.begin() + opposite_bead, 0);
88
89 return ret;
90}
int32_t coord_t
Definition libslic3r.h:39

References Slic3r::Arachne::BeadingStrategy::Beading::bead_widths, Slic3r::Arachne::BeadingStrategy::Beading::left_over, max_bead_count, parent, Slic3r::Arachne::BeadingStrategy::Beading::toolpath_locations, and Slic3r::Arachne::BeadingStrategy::Beading::total_thickness.

◆ getNonlinearThicknesses()

std::vector< coord_t > Slic3r::Arachne::BeadingStrategy::getNonlinearThicknesses ( coord_t  lower_bead_count) const
virtualinherited

Get the locations in a bead count region where BeadingStrategy::compute exhibits a bend in the widths. Ordered from lower thickness to higher.

This is used to insert extra support bones into the skeleton, so that the resulting beads in long trapezoids don't linearly change between the two ends.

Reimplemented in Slic3r::Arachne::WideningBeadingStrategy.

47{
48 return {};
49}

Referenced by Slic3r::Arachne::SkeletalTrapezoidation::generateExtraRibs().

+ Here is the caller graph for this function:

◆ getOptimalBeadCount()

coord_t Slic3r::Arachne::LimitedBeadingStrategy::getOptimalBeadCount ( coord_t  thickness) const
overridevirtual

The number of beads should we ideally usefor a given model thickness

Implements Slic3r::Arachne::BeadingStrategy.

113{
114 coord_t parent_bead_count = parent->getOptimalBeadCount(thickness);
115 if (parent_bead_count <= max_bead_count) {
116 return parent->getOptimalBeadCount(thickness);
117 } else if (parent_bead_count == max_bead_count + 1) {
118 if (thickness < parent->getOptimalThickness(max_bead_count + 1) - scaled<coord_t>(0.01))
119 return max_bead_count;
120 else
121 return max_bead_count + 1;
122 }
123 else return max_bead_count + 1;
124}
coord_t getOptimalThickness(coord_t bead_count) const override
Definition LimitedBeadingStrategy.cpp:92

References getOptimalThickness(), max_bead_count, and parent.

+ Here is the call graph for this function:

◆ getOptimalThickness()

coord_t Slic3r::Arachne::LimitedBeadingStrategy::getOptimalThickness ( coord_t  bead_count) const
overridevirtual

The ideal thickness for a given

Parameters
bead_count

Reimplemented from Slic3r::Arachne::BeadingStrategy.

93{
94 if (bead_count <= max_bead_count)
95 return parent->getOptimalThickness(bead_count);
96 assert(false);
97 return scaled<coord_t>(1000.); // 1 meter (Cura was returning 10 meter)
98}

References max_bead_count, and parent.

Referenced by getOptimalBeadCount().

+ Here is the caller graph for this function:

◆ getSplitMiddleThreshold()

double Slic3r::Arachne::BeadingStrategy::getSplitMiddleThreshold ( ) const
inherited
57{
59}
double wall_split_middle_threshold
Optimal bead width, nominal width off the walls in 'ideal' circumstances.
Definition BeadingStrategy.hpp:101

References Slic3r::Arachne::BeadingStrategy::wall_split_middle_threshold.

◆ getTransitionAnchorPos()

float Slic3r::Arachne::LimitedBeadingStrategy::getTransitionAnchorPos ( coord_t  lower_bead_count) const
overridevirtual

The fraction of the transition length to put between the lower end of the transition and the point where the unsmoothed bead count jumps.

Transitions are used to smooth out the jumps in integer bead count; the jumps turn into ramps which could be positioned relative to the jump location.

Reimplemented from Slic3r::Arachne::BeadingStrategy.

24{
25 return parent->getTransitionAnchorPos(lower_bead_count);
26}

References parent.

◆ getTransitioningAngle()

double Slic3r::Arachne::BeadingStrategy::getTransitioningAngle ( ) const
inherited
62{
64}
double transitioning_angle
The length of the region to smoothly transfer between bead counts.
Definition BeadingStrategy.hpp:111

References Slic3r::Arachne::BeadingStrategy::transitioning_angle.

Referenced by Slic3r::Arachne::SkeletalTrapezoidation::updateIsCentral().

+ Here is the caller graph for this function:

◆ getTransitioningLength()

coord_t Slic3r::Arachne::LimitedBeadingStrategy::getTransitioningLength ( coord_t  lower_bead_count) const
overridevirtual

The length of the transitioning region along the marked / significant regions of the skeleton.

Transitions are used to smooth out the jumps in integer bead count; the jumps turn into ramps with some incline defined by their length.

Reimplemented from Slic3r::Arachne::BeadingStrategy.

19{
20 return parent->getTransitioningLength(lower_bead_count);
21}

References parent.

◆ getTransitionThickness()

coord_t Slic3r::Arachne::LimitedBeadingStrategy::getTransitionThickness ( coord_t  lower_bead_count) const
overridevirtual

The model thickness at which BeadingStrategy::optimal_bead_count transitions from lower_bead_count to lower_bead_count + 1

Reimplemented from Slic3r::Arachne::BeadingStrategy.

101{
102 if (lower_bead_count < max_bead_count)
103 return parent->getTransitionThickness(lower_bead_count);
104
105 if (lower_bead_count == max_bead_count)
106 return parent->getOptimalThickness(lower_bead_count + 1) - scaled<coord_t>(0.01);
107
108 assert(false);
109 return scaled<coord_t>(900.); // 0.9 meter;
110}

References max_bead_count, and parent.

◆ toString()

std::string Slic3r::Arachne::LimitedBeadingStrategy::toString ( ) const
overridevirtual

Reimplemented from Slic3r::Arachne::BeadingStrategy.

14{
15 return std::string("LimitedBeadingStrategy+") + parent->toString();
16}

References parent.

Member Data Documentation

◆ default_transition_length

coord_t Slic3r::Arachne::BeadingStrategy::default_transition_length
protectedinherited

Threshold when a new middle wall should be added between an even number of walls, as a ratio of the optimal wall width.

Referenced by Slic3r::Arachne::BeadingStrategy::getTransitioningLength().

◆ max_bead_count

const coord_t Slic3r::Arachne::LimitedBeadingStrategy::max_bead_count
protected

◆ name

◆ optimal_width

◆ parent

◆ transitioning_angle

double Slic3r::Arachne::BeadingStrategy::transitioning_angle
protectedinherited

The length of the region to smoothly transfer between bead counts.

The maximum angle between outline segments smaller than which we are going to add transitions Equals 180 - the "limit bisector angle" from the paper

Referenced by Slic3r::Arachne::BeadingStrategy::getTransitioningAngle().

◆ wall_add_middle_threshold

double Slic3r::Arachne::BeadingStrategy::wall_add_middle_threshold
protectedinherited

Threshold when a middle wall should be split into two, as a ratio of the optimal wall width.

Referenced by Slic3r::Arachne::DistributedBeadingStrategy::getOptimalBeadCount(), and Slic3r::Arachne::BeadingStrategy::getTransitionThickness().

◆ wall_split_middle_threshold

double Slic3r::Arachne::BeadingStrategy::wall_split_middle_threshold
protectedinherited

The documentation for this class was generated from the following files: