mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-13 20:45:56 +08:00
Avoid placement of seams on bridging perimeters, if random seam is enabled. #3526
https://github.com/alexrj/Slic3r/issues/3526#issuecomment-263125049 Conflicts: xs/src/libslic3r/GCode.cpp
This commit is contained in:
parent
ccf0a45752
commit
4d521ca839
@ -145,15 +145,20 @@ ExtrusionLoop::split_at_vertex(const Point &point)
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
ExtrusionLoop::split_at(const Point &point)
|
||||
// Splitting an extrusion loop, possibly made of multiple segments, some of the segments may be bridging.
|
||||
void ExtrusionLoop::split_at(const Point &point, bool prefer_non_overhang)
|
||||
{
|
||||
if (this->paths.empty()) return;
|
||||
if (this->paths.empty())
|
||||
return;
|
||||
|
||||
// find the closest path and closest point belonging to that path
|
||||
// Find the closest path and closest point belonging to that path. Avoid overhangs, if asked for.
|
||||
size_t path_idx = 0;
|
||||
Point p = this->paths.front().first_point();
|
||||
double min = point.distance_to(p);
|
||||
Point p;
|
||||
{
|
||||
double min = std::numeric_limits<double>::max();
|
||||
Point p_non_overhang;
|
||||
size_t path_idx_non_overhang = 0;
|
||||
double min_non_overhang = std::numeric_limits<double>::max();
|
||||
for (ExtrusionPaths::const_iterator path = this->paths.begin(); path != this->paths.end(); ++path) {
|
||||
Point p_tmp = point.projection_onto(path->polyline);
|
||||
double dist = point.distance_to(p_tmp);
|
||||
@ -162,6 +167,17 @@ ExtrusionLoop::split_at(const Point &point)
|
||||
min = dist;
|
||||
path_idx = path - this->paths.begin();
|
||||
}
|
||||
if (prefer_non_overhang && ! path->is_bridge() && dist < min_non_overhang) {
|
||||
p_non_overhang = p_tmp;
|
||||
min_non_overhang = dist;
|
||||
path_idx_non_overhang = path - this->paths.begin();
|
||||
}
|
||||
}
|
||||
if (prefer_non_overhang && min_non_overhang != std::numeric_limits<double>::max()) {
|
||||
// Only apply the non-overhang point if there is one.
|
||||
path_idx = path_idx_non_overhang;
|
||||
p = p_non_overhang;
|
||||
}
|
||||
}
|
||||
|
||||
// now split path_idx in two parts
|
||||
|
@ -139,7 +139,7 @@ class ExtrusionLoop : public ExtrusionEntity
|
||||
Polygon polygon() const;
|
||||
virtual double length() const;
|
||||
bool split_at_vertex(const Point &point);
|
||||
void split_at(const Point &point);
|
||||
void split_at(const Point &point, bool prefer_non_overhang = false);
|
||||
void clip_end(double distance, ExtrusionPaths* paths) const;
|
||||
// Test, whether the point is extruded by a bridging flow.
|
||||
// This used to be used to avoid placing seams on overhangs, but now the EdgeGrid is used instead.
|
||||
|
@ -392,7 +392,7 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed)
|
||||
last_pos = Point(polygon.bounding_box().max.x, centroid.y);
|
||||
last_pos.rotate(fmod((float)rand()/16.0, 2.0*PI), centroid);
|
||||
}
|
||||
loop.split_at(last_pos);
|
||||
loop.split_at(last_pos, true);
|
||||
}
|
||||
|
||||
// clip the path to avoid the extruder to get exactly on the first point of the loop;
|
||||
|
@ -21,8 +21,8 @@
|
||||
double length();
|
||||
bool split_at_vertex(Point* point)
|
||||
%code{% RETVAL = THIS->split_at_vertex(*point); %};
|
||||
void split_at(Point* point)
|
||||
%code{% THIS->split_at(*point); %};
|
||||
void split_at(Point* point, int prefer_non_overhang = 0)
|
||||
%code{% THIS->split_at(*point, prefer_non_overhang != 0); %};
|
||||
ExtrusionPaths clip_end(double distance)
|
||||
%code{% THIS->clip_end(distance, &RETVAL); %};
|
||||
bool has_overhang_point(Point* point)
|
||||
|
Loading…
x
Reference in New Issue
Block a user