New experimental autospeed feature. #2810

This commit is contained in:
Alessandro Ranellucci 2015-05-31 22:04:32 +02:00
parent 6e280ab8cb
commit 7f70da97b4
12 changed files with 165 additions and 9 deletions

View file

@ -3,6 +3,7 @@
#include "ExPolygonCollection.hpp"
#include "ClipperUtils.hpp"
#include "Extruder.hpp"
#include <cmath>
#include <sstream>
namespace Slic3r {
@ -375,6 +376,20 @@ ExtrusionLoop::grow() const
return pp;
}
double
ExtrusionLoop::min_mm3_per_mm() const
{
double min_mm3_per_mm = 0;
for (ExtrusionPaths::const_iterator path = this->paths.begin(); path != this->paths.end(); ++path) {
if (min_mm3_per_mm == 0) {
min_mm3_per_mm = path->mm3_per_mm;
} else {
min_mm3_per_mm = fmin(min_mm3_per_mm, path->mm3_per_mm);
}
}
return min_mm3_per_mm;
}
#ifdef SLIC3RXS
REGISTER_CLASS(ExtrusionLoop, "ExtrusionLoop");
#endif

View file

@ -50,6 +50,7 @@ class ExtrusionEntity
virtual Point first_point() const = 0;
virtual Point last_point() const = 0;
virtual Polygons grow() const = 0;
virtual double min_mm3_per_mm() const = 0;
};
typedef std::vector<ExtrusionEntity*> ExtrusionEntitiesPtr;
@ -81,6 +82,9 @@ class ExtrusionPath : public ExtrusionEntity
double xofs, double yofs, std::string extrusion_axis,
std::string gcode_line_suffix) const;
Polygons grow() const;
double min_mm3_per_mm() const {
return this->mm3_per_mm;
};
private:
void _inflate_collection(const Polylines &polylines, ExtrusionEntityCollection* collection) const;
@ -117,6 +121,7 @@ class ExtrusionLoop : public ExtrusionEntity
bool is_infill() const;
bool is_solid_infill() const;
Polygons grow() const;
double min_mm3_per_mm() const;
};
}

View file

@ -1,5 +1,6 @@
#include "ExtrusionEntityCollection.hpp"
#include <algorithm>
#include <cmath>
#include <map>
namespace Slic3r {
@ -137,6 +138,37 @@ ExtrusionEntityCollection::items_count() const
return count;
}
/* Returns a single vector of pointers to all non-collection items contained in this one */
void
ExtrusionEntityCollection::flatten(ExtrusionEntityCollection* retval) const
{
for (ExtrusionEntitiesPtr::const_iterator it = this->entities.begin(); it != this->entities.end(); ++it) {
if ((*it)->is_collection()) {
ExtrusionEntityCollection* collection = dynamic_cast<ExtrusionEntityCollection*>(*it);
ExtrusionEntityCollection contents;
collection->flatten(&contents);
retval->entities.insert(retval->entities.end(), contents.entities.begin(), contents.entities.end());
} else {
retval->entities.push_back((*it)->clone());
}
}
}
double
ExtrusionEntityCollection::min_mm3_per_mm() const
{
double min_mm3_per_mm = 0;
for (ExtrusionEntitiesPtr::const_iterator it = this->entities.begin(); it != this->entities.end(); ++it) {
double mm3_per_mm = (*it)->min_mm3_per_mm();
if (min_mm3_per_mm == 0) {
min_mm3_per_mm = mm3_per_mm;
} else {
min_mm3_per_mm = fmin(min_mm3_per_mm, mm3_per_mm);
}
}
return min_mm3_per_mm;
}
#ifdef SLIC3RXS
// there is no ExtrusionLoop::Collection or ExtrusionEntity::Collection
REGISTER_CLASS(ExtrusionEntityCollection, "ExtrusionPath::Collection");

View file

@ -30,6 +30,8 @@ class ExtrusionEntityCollection : public ExtrusionEntity
Point last_point() const;
Polygons grow() const;
size_t items_count() const;
void flatten(ExtrusionEntityCollection* retval) const;
double min_mm3_per_mm() const;
};
}

View file

@ -61,7 +61,7 @@ class PrintRegion
private:
Print* _print;
PrintRegion(Print* print);
~PrintRegion();
};

View file

@ -501,6 +501,22 @@ PrintConfigDef::build_def() {
Options["min_print_speed"].min = 0;
Options["min_print_speed"].max = 1000;
Options["max_print_speed"].type = coFloat;
Options["max_print_speed"].label = "Max print speed";
Options["max_print_speed"].tooltip = "When setting other speed settings to 0 Slic3r will autocalculate the optimal speed in order to keep constant extruder pressure. This experimental setting is used to set the highest print speed you want to allow.";
Options["max_print_speed"].sidetext = "mm/s";
Options["max_print_speed"].cli = "max-print-speed=f";
Options["max_print_speed"].min = 1;
Options["max_print_speed"].max = 1000;
Options["max_volumetric_speed"].type = coFloat;
Options["max_volumetric_speed"].label = "Max volumetric speed";
Options["max_volumetric_speed"].tooltip = "When setting other speed settings to 0 Slic3r will autocalculate the optimal speed in order to keep constant extruder pressure. This experimental setting is used to set the maximum volumetric speed your extruder supports.";
Options["max_volumetric_speed"].sidetext = "mm³/s";
Options["max_volumetric_speed"].cli = "max-volumetric-speed=f";
Options["max_volumetric_speed"].min = 0;
Options["max_volumetric_speed"].max = 1000;
Options["min_skirt_length"].type = coFloat;
Options["min_skirt_length"].label = "Minimum extrusion length";
Options["min_skirt_length"].tooltip = "Generate no less than the number of skirt loops required to consume the specified amount of filament on the bottom layer. For multi-extruder machines, this minimum applies to each extruder.";

View file

@ -306,6 +306,8 @@ class GCodeConfig : public virtual StaticPrintConfig
ConfigOptionBool gcode_comments;
ConfigOptionEnum<GCodeFlavor> gcode_flavor;
ConfigOptionString layer_gcode;
ConfigOptionFloat max_print_speed;
ConfigOptionFloat max_volumetric_speed;
ConfigOptionFloat pressure_advance;
ConfigOptionFloats retract_length;
ConfigOptionFloats retract_length_toolchange;
@ -331,6 +333,8 @@ class GCodeConfig : public virtual StaticPrintConfig
this->gcode_comments.value = false;
this->gcode_flavor.value = gcfRepRap;
this->layer_gcode.value = "";
this->max_print_speed.value = 80;
this->max_volumetric_speed.value = 0;
this->pressure_advance.value = 0;
this->retract_length.values.resize(1);
this->retract_length.values[0] = 2;
@ -361,6 +365,8 @@ class GCodeConfig : public virtual StaticPrintConfig
if (opt_key == "gcode_comments") return &this->gcode_comments;
if (opt_key == "gcode_flavor") return &this->gcode_flavor;
if (opt_key == "layer_gcode") return &this->layer_gcode;
if (opt_key == "max_print_speed") return &this->max_print_speed;
if (opt_key == "max_volumetric_speed") return &this->max_volumetric_speed;
if (opt_key == "pressure_advance") return &this->pressure_advance;
if (opt_key == "retract_length") return &this->retract_length;
if (opt_key == "retract_length_toolchange") return &this->retract_length_toolchange;

View file

@ -28,6 +28,12 @@
%code{% RETVAL = THIS->entities.size(); %};
int items_count()
%code{% RETVAL = THIS->items_count(); %};
ExtrusionEntityCollection* flatten()
%code{%
RETVAL = new ExtrusionEntityCollection();
THIS->flatten(RETVAL);
%};
double min_mm3_per_mm();
bool empty()
%code{% RETVAL = THIS->entities.empty(); %};
std::vector<size_t> orig_indices()