mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-16 00:25:54 +08:00
Medial axis: taper the end of thin walls
This commit is contained in:
parent
b053a23e1e
commit
2ce0d3a946
@ -1283,7 +1283,6 @@ MedialAxis::ensure_not_overextrude(ThickPolylines& pp)
|
||||
for (ThickPolyline& polyline : pp) {
|
||||
for (coordf_t &width : polyline.width) {
|
||||
width *= reduce_by;
|
||||
width *= reduce_by;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1333,8 +1332,7 @@ MedialAxis::simplify_polygon_frontier()
|
||||
}
|
||||
|
||||
void
|
||||
MedialAxis::build(ThickPolylines* polylines_out)
|
||||
{
|
||||
MedialAxis::build(ThickPolylines* polylines_out) {
|
||||
this->id++;
|
||||
//std::cout << layerid << "\n";
|
||||
//{
|
||||
@ -1361,7 +1359,7 @@ MedialAxis::build(ThickPolylines* polylines_out)
|
||||
// compute the Voronoi diagram and extract medial axis polylines
|
||||
ThickPolylines pp;
|
||||
this->polyline_from_voronoi(this->expolygon.lines(), &pp);
|
||||
|
||||
|
||||
concatThickPolylines(pp);
|
||||
|
||||
//std::cout << "concatThickPolylines\n";
|
||||
@ -1374,8 +1372,8 @@ MedialAxis::build(ThickPolylines* polylines_out)
|
||||
// svg.draw(pp);
|
||||
// svg.Close();
|
||||
//}
|
||||
|
||||
/* Find the maximum width returned; we're going to use this for validating and
|
||||
|
||||
/* Find the maximum width returned; we're going to use this for validating and
|
||||
filtering the output segments. */
|
||||
double max_w = 0;
|
||||
for (ThickPolylines::const_iterator it = pp.begin(); it != pp.end(); ++it)
|
||||
@ -1488,8 +1486,10 @@ MedialAxis::build(ThickPolylines* polylines_out)
|
||||
// svg.draw(pp);
|
||||
// svg.Close();
|
||||
//}
|
||||
if (nozzle_diameter != min_width)
|
||||
if (nozzle_diameter != min_width) {
|
||||
grow_to_nozzle_diameter(pp, diff_ex(this->bounds, this->expolygon));
|
||||
taper_ends(pp);
|
||||
}
|
||||
|
||||
polylines_out->insert(polylines_out->end(), pp.begin(), pp.end());
|
||||
|
||||
@ -1513,6 +1513,33 @@ MedialAxis::grow_to_nozzle_diameter(ThickPolylines& pp, const ExPolygons& anchor
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MedialAxis::taper_ends(ThickPolylines& pp) {
|
||||
//ensure the width is not lower than 0.4.
|
||||
for (ThickPolyline& polyline : pp) {
|
||||
if (polyline.length() < nozzle_diameter * 2) continue;
|
||||
if (polyline.endpoints.first) {
|
||||
polyline.width[0] = min_width;
|
||||
coord_t current_dist = min_width;
|
||||
for (size_t i = 1; i<polyline.width.size(); ++i) {
|
||||
current_dist += polyline.points[i - 1].distance_to(polyline.points[i]);
|
||||
if (current_dist > polyline.width[i]) break;
|
||||
polyline.width[i] = current_dist;
|
||||
}
|
||||
}
|
||||
if (polyline.endpoints.second) {
|
||||
size_t last_idx = polyline.width.size() - 1;
|
||||
polyline.width[last_idx] = min_width;
|
||||
coord_t current_dist = min_width;
|
||||
for (size_t i = 1; i<polyline.width.size(); ++i) {
|
||||
current_dist += polyline.points[last_idx - i + 1].distance_to(polyline.points[last_idx - i]);
|
||||
if (current_dist > polyline.width[last_idx - i]) break;
|
||||
polyline.width[last_idx - i] = current_dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExtrusionEntityCollection thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow) {
|
||||
// this value determines granularity of adaptive width, as G-code does not allow
|
||||
// variable extrusion within a single move; this value shall only affect the amount
|
||||
|
@ -63,6 +63,7 @@ namespace Slic3r {
|
||||
void remove_too_short_polylines(ThickPolylines& pp, const coord_t min_size);
|
||||
void ensure_not_overextrude(ThickPolylines& pp);
|
||||
void grow_to_nozzle_diameter(ThickPolylines& pp, const ExPolygons& anchors);
|
||||
void taper_ends(ThickPolylines& pp);
|
||||
};
|
||||
|
||||
ExtrusionEntityCollection thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow);
|
||||
|
Loading…
x
Reference in New Issue
Block a user