Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seam: use scarf joint to minimize seam visiblity #3839

Merged
merged 54 commits into from Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f4e8ff2
Remember z of previous layer
Noisyfox Jan 25, 2024
071274e
Support travel to middle of the layer z
Noisyfox Jan 25, 2024
85586d8
Support sloped extrusion
Noisyfox Jan 25, 2024
a69d796
Implement sloped seam
Noisyfox Jan 26, 2024
ed1ba2d
Reduce extra movements
Noisyfox Jan 26, 2024
b1393a1
Don't clip loop if sloped seam is enabled
Noisyfox Jan 26, 2024
467c68f
Fix wipe
Noisyfox Jan 26, 2024
51d11de
Ensure `slope_max_segment_length`
Noisyfox Jan 26, 2024
e3793c6
Add options
Noisyfox Jan 26, 2024
20365d5
Merge branch 'main' into dev/no-seam
Noisyfox Jan 27, 2024
4dba03e
Limit slope length to perimeter length
Noisyfox Jan 27, 2024
c502f0c
Fix slope segmentation
Noisyfox Jan 27, 2024
f3f0c82
Rename the option to scarf joint seam
Noisyfox Jan 27, 2024
ebbdc80
Merge branch 'main' into dev/no-seam
Noisyfox Jan 27, 2024
1d6b10d
Don't modify the slope option when turning on spiral vase
Noisyfox Jan 27, 2024
fa3383a
Add a few suggestions when turnning on scarf joint
Noisyfox Jan 27, 2024
5cd06dd
Add option to add scarf joint to inner walls
Noisyfox Jan 28, 2024
fbaf137
Apply seam gap at the end of the slope
Noisyfox Jan 28, 2024
65eae47
Merge branch 'main' into dev/no-seam
Noisyfox Jan 28, 2024
685b358
Merge branch 'main' into dev/no-seam
Noisyfox Jan 29, 2024
4280402
Add option to explicitly use the entire loop as scarf length
Noisyfox Jan 30, 2024
e1f76d9
Merge branch 'main' into dev/no-seam
Noisyfox Jan 30, 2024
1d422a1
Merge branch 'main' into dev/no-seam
Noisyfox Jan 30, 2024
fa6ee5c
Fix layer number
Noisyfox Jan 31, 2024
17bb717
Increase default scarf length to 20mm
Noisyfox Jan 31, 2024
8006927
Merge branch 'main' into dev/no-seam
Noisyfox Jan 31, 2024
ef90d48
Better way of storing the global scarf state
Noisyfox Feb 1, 2024
86c60e9
Better vase mode layer height recognition
Noisyfox Feb 2, 2024
590f733
Move id should exclude seams
Noisyfox Feb 2, 2024
b7c5b5f
Fix slope height with independent support layer height
Noisyfox Feb 2, 2024
a8e22b8
Fix linux build
Noisyfox Feb 3, 2024
b35c051
Merge branch 'main' into dev/no-seam
Noisyfox Feb 6, 2024
5a624a6
Merge branch 'main' into dev/no-seam
Noisyfox Feb 11, 2024
ebb5f9b
Merge branch 'main' into dev/no-seam
Noisyfox Feb 11, 2024
7466947
Allow controlling the scarf with modifier
Noisyfox Feb 11, 2024
ad8cfa2
Merge branch 'main' into dev/no-seam
Noisyfox Feb 19, 2024
5124fbd
Merge branch 'main' into dev/no-seam
SoftFever Feb 20, 2024
11e2893
Scarf start height default to 0
Noisyfox Feb 22, 2024
dcab21f
Allow enable scarf seam on contour only
Noisyfox Feb 22, 2024
7b71c5a
Merge branch 'main' into dev/no-seam
Noisyfox Feb 24, 2024
9a2b4c9
Merge branch 'main' into dev/no-seam
SoftFever Feb 25, 2024
5a95329
Merge branch 'main' into dev/no-seam
SoftFever Feb 25, 2024
3a0cf90
Fix type error
Noisyfox Feb 27, 2024
89e61a0
Move the creation of sloped loop into ExtrusionEntity.cpp
Noisyfox Feb 27, 2024
6e5f2d1
Fix error "vector too long"
Noisyfox Feb 27, 2024
163e8e8
Detect seams properly
Noisyfox Feb 27, 2024
cb5f994
Merge branch 'main' into dev/no-seam
Noisyfox Feb 27, 2024
05961f7
The correct way of calculating the rate limit
Noisyfox Feb 29, 2024
3b37595
The correct way of calculating the rate limit
Noisyfox Feb 29, 2024
9e2b14c
Merge branch 'main' into dev/no-seam
Noisyfox Feb 29, 2024
773cba7
Add pressure equalizer in print by object mode
Noisyfox Feb 29, 2024
dce7dd1
Merge branch 'bugfox/correct-pressure-equalizer' into dev/no-seam
Noisyfox Feb 29, 2024
2eebee8
Remove the settings recommendation as it varies a lot depends on prin…
Noisyfox Mar 2, 2024
c5c6683
Add a beta suffix
Noisyfox Mar 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
109 changes: 109 additions & 0 deletions src/libslic3r/ExtrusionEntity.cpp
Expand Up @@ -340,6 +340,115 @@ double ExtrusionLoop::min_mm3_per_mm() const
return min_mm3_per_mm;
}

ExtrusionLoopSloped::ExtrusionLoopSloped(ExtrusionPaths& original_paths,
double seam_gap,
double slope_min_length,
double slope_max_segment_length,
double start_slope_ratio,
ExtrusionLoopRole role)
: ExtrusionLoop(role)
{
// create slopes
const auto add_slop = [this, slope_max_segment_length, seam_gap](const ExtrusionPath& path, const Polyline& poly,
double ratio_begin, double ratio_end) {
if (poly.empty()) {
return;
}

// Ensure `slope_max_segment_length`
Polyline detailed_poly;
{
detailed_poly.append(poly.first_point());

// Recursively split the line into half until no longer than `slope_max_segment_length`
const std::function<void(const Line&)> handle_line = [slope_max_segment_length, &detailed_poly, &handle_line](const Line& line) {
if (line.length() <= slope_max_segment_length) {
detailed_poly.append(line.b);
} else {
// Then process left half
handle_line({line.a, line.midpoint()});
// Then process right half
handle_line({line.midpoint(), line.b});
}
};

for (const auto& l : poly.lines()) {
handle_line(l);
}
}

starts.emplace_back(detailed_poly, path, ExtrusionPathSloped::Slope{ratio_begin, ratio_begin},
ExtrusionPathSloped::Slope{ratio_end, ratio_end});

if (is_approx(ratio_end, 1.) && seam_gap > 0) {
// Remove the segments that has no extrusion
const auto seg_length = detailed_poly.length();
if (seg_length > seam_gap) {
// Split the segment and remove the last `seam_gap` bit
const Polyline orig = detailed_poly;
Polyline tmp;
orig.split_at_length(seg_length - seam_gap, &detailed_poly, &tmp);

ratio_end = lerp(ratio_begin, ratio_end, (seg_length - seam_gap) / seg_length);
assert(1. - ratio_end > EPSILON);
} else {
// Remove the entire segment
detailed_poly.clear();
}
}
if (!detailed_poly.empty()) {
ends.emplace_back(detailed_poly, path, ExtrusionPathSloped::Slope{1., 1. - ratio_begin},
ExtrusionPathSloped::Slope{1., 1. - ratio_end});
}
};

double remaining_length = slope_min_length;

ExtrusionPaths::iterator path = original_paths.begin();
double start_ratio = start_slope_ratio;
for (; path != original_paths.end() && remaining_length > 0; ++path) {
const double path_len = unscale_(path->length());
if (path_len > remaining_length) {
// Split current path into slope and non-slope part
Polyline slope_path;
Polyline flat_path;
path->polyline.split_at_length(scale_(remaining_length), &slope_path, &flat_path);

add_slop(*path, slope_path, start_ratio, 1);
start_ratio = 1;

paths.emplace_back(std::move(flat_path), *path);
remaining_length = 0;
} else {
remaining_length -= path_len;
const double end_ratio = lerp(1.0, start_slope_ratio, remaining_length / slope_min_length);
add_slop(*path, path->polyline, start_ratio, end_ratio);
start_ratio = end_ratio;
}
}
assert(remaining_length <= 0);
assert(start_ratio == 1.);

// Put remaining flat paths
paths.insert(paths.end(), path, original_paths.end());
}

std::vector<const ExtrusionPath*> ExtrusionLoopSloped::get_all_paths() const {
std::vector<const ExtrusionPath*> r;
r.reserve(starts.size() + paths.size() + ends.size());
for (const auto& p : starts) {
r.push_back(&p);
}
for (const auto& p : paths) {
r.push_back(&p);
}
for (const auto& p : ends) {
r.push_back(&p);
}

return r;
}


std::string ExtrusionEntity::role_to_string(ExtrusionRole role)
{
Expand Down
52 changes: 52 additions & 0 deletions src/libslic3r/ExtrusionEntity.hpp
Expand Up @@ -301,6 +301,42 @@ class ExtrusionPath : public ExtrusionEntity
bool m_no_extrusion = false;
};

class ExtrusionPathSloped : public ExtrusionPath
SoftFever marked this conversation as resolved.
Show resolved Hide resolved
{
public:
struct Slope
{
double z_ratio{1.};
double e_ratio{1.};
};

Slope slope_begin;
Slope slope_end;

ExtrusionPathSloped(const ExtrusionPath& rhs, const Slope& begin, const Slope& end)
: ExtrusionPath(rhs), slope_begin(begin), slope_end(end)
{}
ExtrusionPathSloped(ExtrusionPath&& rhs, const Slope& begin, const Slope& end)
: ExtrusionPath(std::move(rhs)), slope_begin(begin), slope_end(end)
{}
ExtrusionPathSloped(const Polyline& polyline, const ExtrusionPath& rhs, const Slope& begin, const Slope& end)
: ExtrusionPath(polyline, rhs), slope_begin(begin), slope_end(end)
{}
ExtrusionPathSloped(Polyline&& polyline, const ExtrusionPath& rhs, const Slope& begin, const Slope& end)
: ExtrusionPath(std::move(polyline), rhs), slope_begin(begin), slope_end(end)
{}

Slope interpolate(const double ratio) const
{
return {
lerp(slope_begin.z_ratio, slope_end.z_ratio, ratio),
lerp(slope_begin.e_ratio, slope_end.e_ratio, ratio),
};
}

bool is_flat() const { return is_approx(slope_begin.z_ratio, slope_end.z_ratio); }
};

class ExtrusionPathOriented : public ExtrusionPath
{
public:
Expand Down Expand Up @@ -459,6 +495,22 @@ class ExtrusionLoop : public ExtrusionEntity
ExtrusionLoopRole m_loop_role;
};

class ExtrusionLoopSloped : public ExtrusionLoop
{
public:
std::vector<ExtrusionPathSloped> starts;
std::vector<ExtrusionPathSloped> ends;

ExtrusionLoopSloped(ExtrusionPaths& original_paths,
double seam_gap,
double slope_min_length,
double slope_max_segment_length,
double start_slope_ratio,
ExtrusionLoopRole role = elrDefault);

[[nodiscard]] std::vector<const ExtrusionPath*> get_all_paths() const;
};

inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &polylines, ExtrusionRole role, double mm3_per_mm, float width, float height)
{
dst.reserve(dst.size() + polylines.size());
Expand Down