Created a total_lengt() free function for Polygons and Polylines.

Modified the "extra perimeters when needed" function to use the new free functions,
extended the tooltip of the "extra perimeters when needed" feature.
This commit is contained in:
bubnikv 2017-02-02 16:03:32 +01:00
parent c25ae35737
commit 4256af22ff
4 changed files with 18 additions and 11 deletions

View File

@ -59,6 +59,13 @@ extern BoundingBox get_extents_rotated(const Polygon &poly, double angle);
extern BoundingBox get_extents_rotated(const Polygons &polygons, double angle);
extern std::vector<BoundingBox> get_extents_vector(const Polygons &polygons);
inline double total_length(const Polygons &polylines) {
double total = 0;
for (Polygons::const_iterator it = polylines.begin(); it != polylines.end(); ++it)
total += it->length();
return total;
}
// Remove sticks (tentacles with zero area) from the polygon.
extern bool remove_sticks(Polygon &poly);
extern bool remove_sticks(Polygons &polys);

View File

@ -69,6 +69,13 @@ public:
extern BoundingBox get_extents(const Polyline &polyline);
extern BoundingBox get_extents(const Polylines &polylines);
inline double total_length(const Polylines &polylines) {
double total = 0;
for (Polylines::const_iterator it = polylines.begin(); it != polylines.end(); ++it)
total += it->length();
return total;
}
inline Lines to_lines(const Polyline &poly)
{
Lines lines;

View File

@ -204,7 +204,7 @@ PrintConfigDef::PrintConfigDef()
def = this->add("extra_perimeters", coBool);
def->label = "Extra perimeters if needed";
def->category = "Layers and Perimeters";
def->tooltip = "Add more perimeters when needed for avoiding gaps in sloping walls.";
def->tooltip = "Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r keeps adding perimeters, until more than 70% of the loop immediately above is supported.";
def->cli = "extra-perimeters!";
def->default_value = new ConfigOptionBool(true);

View File

@ -1168,10 +1168,7 @@ PrintObject::_make_perimeters()
// Filter upper layer polygons in intersection_ppl by their bounding boxes?
// my $upper_layerm_poly_bboxes= [ map $_->bounding_box, @{$upper_layerm_polygons} ];
double total_loop_length = 0;
for (Polygons::const_iterator it = upper_layerm_polygons.begin(); it != upper_layerm_polygons.end(); ++it)
total_loop_length += it->length();
const double total_loop_length = total_length(upper_layerm_polygons);
const coord_t perimeter_spacing = layerm.flow(frPerimeter).scaled_spacing();
const Flow ext_perimeter_flow = layerm.flow(frExternalPerimeter);
const coord_t ext_perimeter_width = ext_perimeter_flow.scaled_width();
@ -1199,12 +1196,8 @@ PrintObject::_make_perimeters()
);
// only add an additional loop if at least 30% of the slice loop would benefit from it
{
double total_intersection_length = 0;
for (Polylines::const_iterator it = intersection.begin(); it != intersection.end(); ++it)
total_intersection_length += it->length();
if (total_intersection_length <= total_loop_length*0.3) break;
}
if (total_length(intersection) <= total_loop_length*0.3)
break;
/*
if (0) {