Browse Source

auto dense infill : add no_sort to draw the perimeter first

supermerill 6 years ago
parent
commit
2437579de6

+ 46 - 6
xs/src/libslic3r/Fill/FillRectilinear2.cpp

@@ -7,6 +7,7 @@
 
 
 #include <boost/static_assert.hpp>
 #include <boost/static_assert.hpp>
 
 
+#include "../ExtrusionEntityCollection.hpp"
 #include "../ClipperUtils.hpp"
 #include "../ClipperUtils.hpp"
 #include "../ExPolygon.hpp"
 #include "../ExPolygon.hpp"
 #include "../Geometry.hpp"
 #include "../Geometry.hpp"
@@ -1473,29 +1474,68 @@ Polylines FillCubic::fill_surface(const Surface *surface, const FillParams &para
 }
 }
 
 
 
 
-Polylines FillRectilinear2Peri::fill_surface(const Surface *surface, const FillParams &params) {
-    Polylines polylines_out;
+//Polylines FillRectilinear2Peri::fill_surface(const Surface *surface, const FillParams &params) {
+
+void FillRectilinear2Peri::fill_surface_extrusion(const Surface *surface, const FillParams &params, const Flow &flow, ExtrusionEntityCollection &out) {
+    ExtrusionEntityCollection *eecroot = new ExtrusionEntityCollection();
+    //you don't want to sort the extrusions: big infill first, small second
+    eecroot->no_sort = true;
+
+    Polylines polylines_1;
     //generate perimeter:
     //generate perimeter:
     //TODO: better optimize start/end point?
     //TODO: better optimize start/end point?
     ExPolygons path_perimeter = offset_ex(surface->expolygon, scale_(-this->spacing/2));
     ExPolygons path_perimeter = offset_ex(surface->expolygon, scale_(-this->spacing/2));
     for (ExPolygon &expolygon : path_perimeter) {
     for (ExPolygon &expolygon : path_perimeter) {
         expolygon.contour.make_counter_clockwise();
         expolygon.contour.make_counter_clockwise();
-        polylines_out.push_back(expolygon.contour.split_at_index(0));
+        polylines_1.push_back(expolygon.contour.split_at_index(0));
         for (Polygon hole : expolygon.holes) {
         for (Polygon hole : expolygon.holes) {
             hole.make_clockwise();
             hole.make_clockwise();
-            polylines_out.push_back(hole.split_at_index(0));
+            polylines_1.push_back(hole.split_at_index(0));
         }
         }
     }
     }
 
 
+    // Save into layer.
+    auto *eec = new ExtrusionEntityCollection();
+    /// pass the no_sort attribute to the extrusion path
+    eec->no_sort = this->no_sort();
+    /// add it into the collection
+    eecroot->entities.push_back(eec);
+    /// push the path
+    extrusion_entities_append_paths(
+        eec->entities, STDMOVE(polylines_1),
+        flow.bridge ?
+    erBridgeInfill :
+                   (surface->is_solid() ?
+                   ((surface->is_top()) ? erTopSolidInfill : erSolidInfill) :
+                   erInternalInfill),
+                   flow.mm3_per_mm() * params.flow_mult, flow.width * params.flow_mult, flow.height);
+
+    Polylines polylines_2;
     //50% overlap with the new perimeter
     //50% overlap with the new perimeter
     ExPolygons path_inner = offset2_ex(surface->expolygon, scale_(-this->spacing * 1.5), scale_(this->spacing));
     ExPolygons path_inner = offset2_ex(surface->expolygon, scale_(-this->spacing * 1.5), scale_(this->spacing));
     for (ExPolygon &expolygon : path_inner) {
     for (ExPolygon &expolygon : path_inner) {
         Surface surfInner(*surface, expolygon);
         Surface surfInner(*surface, expolygon);
-        if (!fill_surface_by_lines(&surfInner, params, 0.f, 0.f, polylines_out)) {
+        if (!fill_surface_by_lines(&surfInner, params, 0.f, 0.f, polylines_2)) {
             printf("FillRectilinear2::fill_surface() failed to fill a region.\n");
             printf("FillRectilinear2::fill_surface() failed to fill a region.\n");
         }
         }
     }
     }
-    return polylines_out;
+    // Save into layer.
+    eec = new ExtrusionEntityCollection();
+    /// pass the no_sort attribute to the extrusion path
+    eec->no_sort = this->no_sort();
+    /// add it into the collection
+    eecroot->entities.push_back(eec);
+    /// push the path
+    extrusion_entities_append_paths(
+        eec->entities, STDMOVE(polylines_2),
+        flow.bridge ?
+    erBridgeInfill :
+                   (surface->is_solid() ?
+                   ((surface->is_top()) ? erTopSolidInfill : erSolidInfill) :
+                   erInternalInfill),
+                   flow.mm3_per_mm() * params.flow_mult, flow.width * params.flow_mult, flow.height);
+
+    out.entities.push_back(eecroot);
 }
 }
 
 
 } // namespace Slic3r
 } // namespace Slic3r

+ 2 - 1
xs/src/libslic3r/Fill/FillRectilinear2.hpp

@@ -75,7 +75,8 @@ public:
 
 
     virtual Fill* clone() const { return new FillRectilinear2Peri(*this); };
     virtual Fill* clone() const { return new FillRectilinear2Peri(*this); };
     virtual ~FillRectilinear2Peri() {}
     virtual ~FillRectilinear2Peri() {}
-    virtual Polylines fill_surface(const Surface *surface, const FillParams &params);
+    //virtual Polylines fill_surface(const Surface *surface, const FillParams &params);
+    virtual void fill_surface_extrusion(const Surface *surface, const FillParams &params, const Flow &flow, ExtrusionEntityCollection &out);
 
 
 };
 };
 
 

+ 0 - 3
xs/src/libslic3r/Fill/FillSmooth.cpp

@@ -95,9 +95,6 @@ namespace Slic3r {
                 if (extrudedVolume == 0) extrudedVolume = 1;
                 if (extrudedVolume == 0) extrudedVolume = 1;
 
 
                 // Save into layer smoothing path.
                 // Save into layer smoothing path.
-                eec = new ExtrusionEntityCollection();
-                eecroot->entities.push_back(eec);
-                eec->no_sort = false;
                 // print thin
                 // print thin
 
 
                 eec = new ExtrusionEntityCollection();
                 eec = new ExtrusionEntityCollection();

+ 1 - 1
xs/src/libslic3r/PrintObject.cpp

@@ -499,7 +499,7 @@ ExPolygons fit_to_size(ExPolygon polygon_to_cover, ExPolygon polygon_to_check, c
 void PrintObject::count_distance_solid() {
 void PrintObject::count_distance_solid() {
     //if dense area * COEFF_SPLIT > sparse area then fill all with dense
     //if dense area * COEFF_SPLIT > sparse area then fill all with dense
     // sparse area = layer's fill area - dense area
     // sparse area = layer's fill area - dense area
-    const float COEFF_SPLIT = .1;
+    const float COEFF_SPLIT = 1;
     const int NB_DENSE_LAYERS = 1;
     const int NB_DENSE_LAYERS = 1;
     for (int idx_region = 0; idx_region < this->_print->regions.size(); ++idx_region) {
     for (int idx_region = 0; idx_region < this->_print->regions.size(); ++idx_region) {
         //count how many surface there are on each one
         //count how many surface there are on each one