Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs/src
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-02-02 18:03:32 +0300
committerbubnikv <bubnikv@gmail.com>2017-02-02 18:03:32 +0300
commit4256af22ff628156c85349c217ff46c1e41321a2 (patch)
treea5095c860f86d1ab7d11c55feab87fe5edd1c884 /xs/src
parentc25ae357377f8738da5e29b82b085a75960f27c5 (diff)
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.
Diffstat (limited to 'xs/src')
-rw-r--r--xs/src/libslic3r/Polygon.hpp7
-rw-r--r--xs/src/libslic3r/Polyline.hpp7
-rw-r--r--xs/src/libslic3r/PrintConfig.cpp2
-rw-r--r--xs/src/libslic3r/PrintObject.cpp13
4 files changed, 18 insertions, 11 deletions
diff --git a/xs/src/libslic3r/Polygon.hpp b/xs/src/libslic3r/Polygon.hpp
index 74039bacc..2a595d36a 100644
--- a/xs/src/libslic3r/Polygon.hpp
+++ b/xs/src/libslic3r/Polygon.hpp
@@ -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);
diff --git a/xs/src/libslic3r/Polyline.hpp b/xs/src/libslic3r/Polyline.hpp
index d304ba19a..ac59c6378 100644
--- a/xs/src/libslic3r/Polyline.hpp
+++ b/xs/src/libslic3r/Polyline.hpp
@@ -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;
diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp
index 1f58d308d..9b4a0e7e4 100644
--- a/xs/src/libslic3r/PrintConfig.cpp
+++ b/xs/src/libslic3r/PrintConfig.cpp
@@ -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);
diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp
index 1c1d0113e..94001cb38 100644
--- a/xs/src/libslic3r/PrintObject.cpp
+++ b/xs/src/libslic3r/PrintObject.cpp
@@ -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) {