Merge branch 'region-config'

Conflicts:
	lib/Slic3r/Format/AMF/Parser.pm
This commit is contained in:
Alessandro Ranellucci 2014-01-05 14:59:36 +01:00
commit 0bdea60b53
62 changed files with 2164 additions and 1432 deletions

View file

@ -35,6 +35,14 @@ ConfigBase::serialize(const t_config_option_key opt_key) {
void
ConfigBase::set_deserialize(const t_config_option_key opt_key, std::string str) {
if (this->def->count(opt_key) == 0) throw "Calling set_deserialize() on unknown option";
ConfigOptionDef* optdef = &(*this->def)[opt_key];
if (!optdef->shortcut.empty()) {
for (std::vector<t_config_option_key>::iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it)
this->set_deserialize(*it, str);
return;
}
ConfigOption* opt = this->option(opt_key, true);
assert(opt != NULL);
opt->deserialize(str);
@ -42,23 +50,29 @@ ConfigBase::set_deserialize(const t_config_option_key opt_key, std::string str)
double
ConfigBase::get_abs_value(const t_config_option_key opt_key) {
// get option definition
assert(this->def->count(opt_key) != 0);
ConfigOptionDef* def = &(*this->def)[opt_key];
assert(def->type == coFloatOrPercent);
ConfigOption* opt = this->option(opt_key, false);
if (ConfigOptionFloatOrPercent* optv = dynamic_cast<ConfigOptionFloatOrPercent*>(opt)) {
// get option definition
assert(this->def->count(opt_key) != 0);
ConfigOptionDef* def = &(*this->def)[opt_key];
// compute absolute value over the absolute value of the base option
return optv->get_abs_value(this->get_abs_value(def->ratio_over));
} else if (ConfigOptionFloat* optv = dynamic_cast<ConfigOptionFloat*>(opt)) {
return optv->value;
} else {
throw "Not a valid option type for get_abs_value()";
}
}
double
ConfigBase::get_abs_value(const t_config_option_key opt_key, double ratio_over) {
// get stored option value
ConfigOptionFloatOrPercent* opt = dynamic_cast<ConfigOptionFloatOrPercent*>(this->option(opt_key));
assert(opt != NULL);
// compute absolute value
if (opt->percent) {
ConfigOptionFloat* optbase = dynamic_cast<ConfigOptionFloat*>(this->option(def->ratio_over));
if (optbase == NULL) throw "ratio_over option not found";
return optbase->value * opt->value / 100;
} else {
return opt->value;
}
return opt->get_abs_value(ratio_over);
}
#ifdef SLIC3RXS
@ -108,9 +122,9 @@ ConfigBase::get(t_config_option_key opt_key) {
return optv->point.to_SV_pureperl();
} else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) {
AV* av = newAV();
av_fill(av, optv->points.size()-1);
for (Pointfs::iterator it = optv->points.begin(); it != optv->points.end(); ++it)
av_store(av, it - optv->points.begin(), it->to_SV_pureperl());
av_fill(av, optv->values.size()-1);
for (Pointfs::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), it->to_SV_pureperl());
return newRV_noinc((SV*)av);
} else if (ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt)) {
return newSViv(optv->value ? 1 : 0);
@ -126,11 +140,40 @@ ConfigBase::get(t_config_option_key opt_key) {
}
}
SV*
ConfigBase::get_at(t_config_option_key opt_key, size_t i) {
ConfigOption* opt = this->option(opt_key);
if (opt == NULL) return &PL_sv_undef;
if (ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt)) {
return newSVnv(optv->get_at(i));
} else if (ConfigOptionInts* optv = dynamic_cast<ConfigOptionInts*>(opt)) {
return newSViv(optv->get_at(i));
} else if (ConfigOptionStrings* optv = dynamic_cast<ConfigOptionStrings*>(opt)) {
// we don't serialize() because that would escape newlines
std::string val = optv->get_at(i);
return newSVpvn(val.c_str(), val.length());
} else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) {
return optv->get_at(i).to_SV_pureperl();
} else if (ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt)) {
return newSViv(optv->get_at(i) ? 1 : 0);
} else {
return &PL_sv_undef;
}
}
void
ConfigBase::set(t_config_option_key opt_key, SV* value) {
ConfigOption* opt = this->option(opt_key, true);
if (opt == NULL) CONFESS("Trying to set non-existing option");
ConfigOptionDef* optdef = &(*this->def)[opt_key];
if (!optdef->shortcut.empty()) {
for (std::vector<t_config_option_key>::iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it)
this->set(*it, value);
return;
}
if (ConfigOptionFloat* optv = dynamic_cast<ConfigOptionFloat*>(opt)) {
optv->value = SvNV(value);
} else if (ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt)) {
@ -164,14 +207,14 @@ ConfigBase::set(t_config_option_key opt_key, SV* value) {
} else if (ConfigOptionPoint* optv = dynamic_cast<ConfigOptionPoint*>(opt)) {
optv->point.from_SV(value);
} else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) {
optv->points.clear();
optv->values.clear();
AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1;
for (size_t i = 0; i < len; i++) {
SV** elem = av_fetch(av, i, 0);
Pointf point;
point.from_SV(*elem);
optv->points.push_back(point);
optv->values.push_back(point);
}
} else if (ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt)) {
optv->value = SvTRUE(value);

View file

@ -8,6 +8,7 @@
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
#include "Point.hpp"
@ -20,10 +21,26 @@ typedef std::vector<std::string> t_config_option_keys;
class ConfigOption {
public:
virtual ~ConfigOption() {};
virtual std::string serialize() = 0;
virtual std::string serialize() const = 0;
virtual void deserialize(std::string str) = 0;
};
template <class T>
class ConfigOptionVector
{
public:
virtual ~ConfigOptionVector() {};
std::vector<T> values;
T get_at(size_t i) {
try {
return this->values.at(i);
} catch (const std::out_of_range& oor) {
return this->values.front();
}
};
};
class ConfigOptionFloat : public ConfigOption
{
public:
@ -32,7 +49,7 @@ class ConfigOptionFloat : public ConfigOption
operator double() const { return this->value; };
std::string serialize() {
std::string serialize() const {
std::ostringstream ss;
ss << this->value;
return ss.str();
@ -43,12 +60,11 @@ class ConfigOptionFloat : public ConfigOption
};
};
class ConfigOptionFloats : public ConfigOption
class ConfigOptionFloats : public ConfigOption, public ConfigOptionVector<double>
{
public:
std::vector<double> values;
std::string serialize() {
std::string serialize() const {
std::ostringstream ss;
for (std::vector<double>::const_iterator it = this->values.begin(); it != this->values.end(); ++it) {
if (it - this->values.begin() != 0) ss << ",";
@ -75,7 +91,7 @@ class ConfigOptionInt : public ConfigOption
operator int() const { return this->value; };
std::string serialize() {
std::string serialize() const {
std::ostringstream ss;
ss << this->value;
return ss.str();
@ -86,12 +102,11 @@ class ConfigOptionInt : public ConfigOption
};
};
class ConfigOptionInts : public ConfigOption
class ConfigOptionInts : public ConfigOption, public ConfigOptionVector<int>
{
public:
std::vector<int> values;
std::string serialize() {
std::string serialize() const {
std::ostringstream ss;
for (std::vector<int>::const_iterator it = this->values.begin(); it != this->values.end(); ++it) {
if (it - this->values.begin() != 0) ss << ",";
@ -118,7 +133,7 @@ class ConfigOptionString : public ConfigOption
operator std::string() const { return this->value; };
std::string serialize() {
std::string serialize() const {
std::string str = this->value;
// s/\R/\\n/g
@ -144,12 +159,11 @@ class ConfigOptionString : public ConfigOption
};
// semicolon-separated strings
class ConfigOptionStrings : public ConfigOption
class ConfigOptionStrings : public ConfigOption, public ConfigOptionVector<std::string>
{
public:
std::vector<std::string> values;
std::string serialize() {
std::string serialize() const {
std::ostringstream ss;
for (std::vector<std::string>::const_iterator it = this->values.begin(); it != this->values.end(); ++it) {
if (it - this->values.begin() != 0) ss << ";";
@ -175,7 +189,15 @@ class ConfigOptionFloatOrPercent : public ConfigOption
bool percent;
ConfigOptionFloatOrPercent() : value(0), percent(false) {};
std::string serialize() {
double get_abs_value(double ratio_over) const {
if (this->percent) {
return ratio_over * this->value / 100;
} else {
return this->value;
}
};
std::string serialize() const {
std::ostringstream ss;
ss << this->value;
std::string s(ss.str());
@ -202,7 +224,7 @@ class ConfigOptionPoint : public ConfigOption
operator Pointf() const { return this->point; };
std::string serialize() {
std::string serialize() const {
std::ostringstream ss;
ss << this->point.x;
ss << ",";
@ -215,15 +237,14 @@ class ConfigOptionPoint : public ConfigOption
};
};
class ConfigOptionPoints : public ConfigOption
class ConfigOptionPoints : public ConfigOption, public ConfigOptionVector<Pointf>
{
public:
Pointfs points;
std::string serialize() {
std::string serialize() const {
std::ostringstream ss;
for (Pointfs::const_iterator it = this->points.begin(); it != this->points.end(); ++it) {
if (it - this->points.begin() != 0) ss << ",";
for (Pointfs::const_iterator it = this->values.begin(); it != this->values.end(); ++it) {
if (it - this->values.begin() != 0) ss << ",";
ss << it->x;
ss << "x";
ss << it->y;
@ -232,13 +253,13 @@ class ConfigOptionPoints : public ConfigOption
};
void deserialize(std::string str) {
this->points.clear();
this->values.clear();
std::istringstream is(str);
std::string point_str;
while (std::getline(is, point_str, ',')) {
Pointf point;
sscanf(point_str.c_str(), "%lfx%lf", &point.x, &point.y);
this->points.push_back(point);
this->values.push_back(point);
}
};
};
@ -251,7 +272,7 @@ class ConfigOptionBool : public ConfigOption
operator bool() const { return this->value; };
std::string serialize() {
std::string serialize() const {
return std::string(this->value ? "1" : "0");
};
@ -260,12 +281,11 @@ class ConfigOptionBool : public ConfigOption
};
};
class ConfigOptionBools : public ConfigOption
class ConfigOptionBools : public ConfigOption, public ConfigOptionVector<bool>
{
public:
std::vector<bool> values;
std::string serialize() {
std::string serialize() const {
std::ostringstream ss;
for (std::vector<bool>::const_iterator it = this->values.begin(); it != this->values.end(); ++it) {
if (it - this->values.begin() != 0) ss << ",";
@ -294,7 +314,7 @@ class ConfigOptionEnum : public ConfigOption
operator T() const { return this->value; };
std::string serialize() {
std::string serialize() const {
t_config_enum_values enum_keys_map = ConfigOptionEnum<T>::get_enum_values();
for (t_config_enum_values::iterator it = enum_keys_map.begin(); it != enum_keys_map.end(); ++it) {
if (it->second == static_cast<int>(this->value)) return it->first;
@ -321,7 +341,7 @@ class ConfigOptionEnumGeneric : public ConfigOption
operator int() const { return this->value; };
std::string serialize() {
std::string serialize() const {
for (t_config_enum_values::iterator it = this->keys_map->begin(); it != this->keys_map->end(); ++it) {
if (it->second == this->value) return it->first;
}
@ -354,6 +374,7 @@ class ConfigOptionDef
public:
ConfigOptionType type;
std::string label;
std::string full_label;
std::string category;
std::string tooltip;
std::string sidetext;
@ -361,7 +382,6 @@ class ConfigOptionDef
std::string scope;
t_config_option_key ratio_over;
bool multiline;
bool full_label;
bool full_width;
bool readonly;
int height;
@ -374,7 +394,7 @@ class ConfigOptionDef
std::vector<std::string> enum_labels;
t_config_enum_values enum_keys_map;
ConfigOptionDef() : multiline(false), full_label(false), full_width(false), readonly(false),
ConfigOptionDef() : multiline(false), full_width(false), readonly(false),
height(-1), width(-1), min(INT_MIN), max(INT_MAX) {};
};
@ -393,10 +413,12 @@ class ConfigBase
std::string serialize(const t_config_option_key opt_key);
void set_deserialize(const t_config_option_key opt_key, std::string str);
double get_abs_value(const t_config_option_key opt_key);
double get_abs_value(const t_config_option_key opt_key, double ratio_over);
#ifdef SLIC3RXS
SV* as_hash();
SV* get(t_config_option_key opt_key);
SV* get_at(t_config_option_key opt_key, size_t i);
void set(t_config_option_key opt_key, SV* value);
#endif
};

View file

@ -116,8 +116,7 @@ ExtrusionLoop::split_at_index(int index) const
ExtrusionPath* path = new ExtrusionPath();
path->polyline = *poly;
path->role = this->role;
path->height = this->height;
path->flow_spacing = this->flow_spacing;
path->mm3_per_mm = this->mm3_per_mm;
delete poly;
return path;

View file

@ -31,8 +31,7 @@ class ExtrusionEntity
virtual ExtrusionEntity* clone() const = 0;
virtual ~ExtrusionEntity() {};
ExtrusionRole role;
double height; // vertical thickness of the extrusion expressed in mm
double flow_spacing;
double mm3_per_mm; // mm^3 of plastic per mm of linear head motion
virtual void reverse() = 0;
virtual Point* first_point() const = 0;
virtual Point* last_point() const = 0;

109
xs/src/Flow.cpp Normal file
View file

@ -0,0 +1,109 @@
#include "Flow.hpp"
#include <cmath>
namespace Slic3r {
Flow
Flow::new_from_config_width(FlowRole role, const ConfigOptionFloatOrPercent &width, float nozzle_diameter, float height, float bridge_flow_ratio) {
float w;
if (!width.percent && width.value == 0) {
w = Flow::_width(role, nozzle_diameter, height, bridge_flow_ratio);
} else {
w = width.get_abs_value(height);
}
Flow flow(w, Flow::_spacing(w, nozzle_diameter, height, bridge_flow_ratio), nozzle_diameter);
if (bridge_flow_ratio > 0) flow.bridge = true;
return flow;
}
Flow
Flow::new_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge) {
float w = Flow::_width_from_spacing(spacing, nozzle_diameter, height, bridge);
Flow flow(w, spacing, nozzle_diameter);
flow.bridge = bridge;
return flow;
}
double
Flow::mm3_per_mm(float h) {
if (this->bridge) {
return (this->width * this->width) * PI/4.0;
} else if (this->width >= (this->nozzle_diameter + h)) {
// rectangle with semicircles at the ends
return this->width * h + (h*h) / 4.0 * (PI-4.0);
} else {
// rectangle with shrunk semicircles at the ends
return this->nozzle_diameter * h * (1 - PI/4.0) + h * this->width * PI/4.0;
}
}
float
Flow::_width(FlowRole role, float nozzle_diameter, float height, float bridge_flow_ratio) {
if (bridge_flow_ratio > 0) {
return sqrt(bridge_flow_ratio * (nozzle_diameter*nozzle_diameter));
}
// here we calculate a sane default by matching the flow speed (at the nozzle) and the feed rate
float volume = (nozzle_diameter*nozzle_diameter) * PI/4.0;
float shape_threshold = nozzle_diameter * height + (height*height) * PI/4.0;
float width;
if (volume >= shape_threshold) {
// rectangle with semicircles at the ends
width = ((nozzle_diameter*nozzle_diameter) * PI + (height*height) * (4.0 - PI)) / (4.0 * height);
} else {
// rectangle with squished semicircles at the ends
width = nozzle_diameter * (nozzle_diameter/height - 4.0/PI + 1);
}
float min = nozzle_diameter * 1.05;
float max = -1;
if (role == frPerimeter || role == frSupportMaterial) {
min = max = nozzle_diameter;
} else if (role != frInfill) {
// do not limit width for sparse infill so that we use full native flow for it
max = nozzle_diameter * 1.7;
}
if (max != -1 && width > max) width = max;
if (width < min) width = min;
return width;
}
float
Flow::_width_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge) {
if (bridge) {
return spacing - BRIDGE_EXTRA_SPACING;
}
float w_threshold = height + nozzle_diameter;
float s_threshold = w_threshold - OVERLAP_FACTOR * (w_threshold - (w_threshold - height * (1 - PI/4.0)));
if (spacing >= s_threshold) {
// rectangle with semicircles at the ends
return spacing + OVERLAP_FACTOR * height * (1 - PI/4.0);
} else {
// rectangle with shrunk semicircles at the ends
return (spacing + nozzle_diameter * OVERLAP_FACTOR * (PI/4.0 - 1)) / (1 + OVERLAP_FACTOR * (PI/4.0 - 1));
}
}
float
Flow::_spacing(float width, float nozzle_diameter, float height, float bridge_flow_ratio) {
if (bridge_flow_ratio > 0) {
return width + BRIDGE_EXTRA_SPACING;
}
float min_flow_spacing;
if (width >= (nozzle_diameter + height)) {
// rectangle with semicircles at the ends
min_flow_spacing = width - height * (1 - PI/4.0);
} else {
// rectangle with shrunk semicircles at the ends
min_flow_spacing = nozzle_diameter * (1 - PI/4.0) + width * PI/4.0;
}
return width - OVERLAP_FACTOR * (width - min_flow_spacing);
}
}

48
xs/src/Flow.hpp Normal file
View file

@ -0,0 +1,48 @@
#ifndef slic3r_Flow_hpp_
#define slic3r_Flow_hpp_
#include <myinit.h>
#include "Config.hpp"
#include "ExtrusionEntity.hpp"
namespace Slic3r {
#define BRIDGE_EXTRA_SPACING 0.05
#define OVERLAP_FACTOR 1.0
enum FlowRole {
frPerimeter,
frInfill,
frSolidInfill,
frTopSolidInfill,
frSupportMaterial,
frSupportMaterialInterface,
};
class Flow
{
public:
float width;
float spacing;
float nozzle_diameter;
bool bridge;
coord_t scaled_width;
coord_t scaled_spacing;
Flow(float _w, float _s, float _nd): width(_w), spacing(_s), nozzle_diameter(_nd), bridge(false) {
this->scaled_width = scale_(this->width);
this->scaled_spacing = scale_(this->spacing);
};
double mm3_per_mm(float h);
static Flow new_from_config_width(FlowRole role, const ConfigOptionFloatOrPercent &width, float nozzle_diameter, float height, float bridge_flow_ratio);
static Flow new_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge);
private:
static float _width(FlowRole role, float nozzle_diameter, float height, float bridge_flow_ratio);
static float _width_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge);
static float _spacing(float width, float nozzle_diameter, float height, float bridge_flow_ratio);
};
}
#endif

View file

@ -23,8 +23,8 @@ Point::rotate(double angle, Point* center)
{
double cur_x = (double)this->x;
double cur_y = (double)this->y;
this->x = (long)round( (double)center->x + cos(angle) * (cur_x - (double)center->x) - sin(angle) * (cur_y - (double)center->y) );
this->y = (long)round( (double)center->y + cos(angle) * (cur_y - (double)center->y) + sin(angle) * (cur_x - (double)center->x) );
this->x = (coord_t)round( (double)center->x + cos(angle) * (cur_x - (double)center->x) - sin(angle) * (cur_y - (double)center->y) );
this->y = (coord_t)round( (double)center->y + cos(angle) * (cur_y - (double)center->y) + sin(angle) * (cur_x - (double)center->x) );
}
bool

View file

@ -17,9 +17,9 @@ typedef std::vector<Pointf> Pointfs;
class Point
{
public:
long x;
long y;
explicit Point(long _x = 0, long _y = 0): x(_x), y(_y) {};
coord_t x;
coord_t y;
explicit Point(coord_t _x = 0, coord_t _y = 0): x(_x), y(_y) {};
void scale(double factor);
void translate(double x, double y);
void rotate(double angle, Point* center);

View file

@ -33,4 +33,11 @@ PrintState::invalidate(PrintStep step)
this->_done.erase(step);
}
void
PrintState::invalidate_all()
{
this->_started.clear();
this->_done.clear();
}
}

View file

@ -22,6 +22,7 @@ class PrintState
void set_started(PrintStep step);
void set_done(PrintStep step);
void invalidate(PrintStep step);
void invalidate_all();
};
}

View file

@ -2,6 +2,6 @@
namespace Slic3r {
t_optiondef_map PrintConfig::PrintConfigDef = PrintConfig::build_def();
t_optiondef_map PrintConfigDef::def = PrintConfigDef::build_def();
}

View file

@ -37,417 +37,10 @@ template<> inline t_config_enum_values ConfigOptionEnum<InfillPattern>::get_enum
return keys_map;
}
class PrintConfig : public StaticConfig
class PrintConfigDef
{
public:
static t_optiondef_map PrintConfigDef;
ConfigOptionBool avoid_crossing_perimeters;
ConfigOptionPoint bed_size;
ConfigOptionInt bed_temperature;
ConfigOptionInt bottom_solid_layers;
ConfigOptionFloat bridge_acceleration;
ConfigOptionInt bridge_fan_speed;
ConfigOptionFloat bridge_flow_ratio;
ConfigOptionFloat bridge_speed;
ConfigOptionFloat brim_width;
ConfigOptionBool complete_objects;
ConfigOptionBool cooling;
ConfigOptionFloat default_acceleration;
ConfigOptionInt disable_fan_first_layers;
ConfigOptionInt duplicate;
ConfigOptionFloat duplicate_distance;
ConfigOptionPoint duplicate_grid;
ConfigOptionString end_gcode;
ConfigOptionFloatOrPercent external_perimeter_speed;
ConfigOptionBool external_perimeters_first;
ConfigOptionBool extra_perimeters;
ConfigOptionFloat extruder_clearance_height;
ConfigOptionFloat extruder_clearance_radius;
ConfigOptionPoints extruder_offset;
ConfigOptionString extrusion_axis;
ConfigOptionFloats extrusion_multiplier;
ConfigOptionFloatOrPercent extrusion_width;
ConfigOptionBool fan_always_on;
ConfigOptionInt fan_below_layer_time;
ConfigOptionFloats filament_diameter;
ConfigOptionInt fill_angle;
ConfigOptionFloat fill_density;
ConfigOptionEnum<InfillPattern> fill_pattern;
ConfigOptionFloat first_layer_acceleration;
ConfigOptionInt first_layer_bed_temperature;
ConfigOptionFloatOrPercent first_layer_extrusion_width;
ConfigOptionFloatOrPercent first_layer_height;
ConfigOptionFloatOrPercent first_layer_speed;
ConfigOptionInts first_layer_temperature;
ConfigOptionBool g0;
ConfigOptionFloat gap_fill_speed;
ConfigOptionBool gcode_arcs;
ConfigOptionBool gcode_comments;
ConfigOptionEnum<GCodeFlavor> gcode_flavor;
ConfigOptionFloat infill_acceleration;
ConfigOptionInt infill_every_layers;
ConfigOptionInt infill_extruder;
ConfigOptionFloatOrPercent infill_extrusion_width;
ConfigOptionBool infill_first;
ConfigOptionBool infill_only_where_needed;
ConfigOptionFloat infill_speed;
ConfigOptionString layer_gcode;
ConfigOptionFloat layer_height;
ConfigOptionInt max_fan_speed;
ConfigOptionInt min_fan_speed;
ConfigOptionInt min_print_speed;
ConfigOptionFloat min_skirt_length;
ConfigOptionString notes;
ConfigOptionFloats nozzle_diameter;
ConfigOptionBool only_retract_when_crossing_perimeters;
ConfigOptionBool ooze_prevention;
ConfigOptionString output_filename_format;
ConfigOptionBool overhangs;
ConfigOptionFloat perimeter_acceleration;
ConfigOptionInt perimeter_extruder;
ConfigOptionFloatOrPercent perimeter_extrusion_width;
ConfigOptionFloat perimeter_speed;
ConfigOptionInt perimeters;
ConfigOptionStrings post_process;
ConfigOptionPoint print_center;
ConfigOptionInt raft_layers;
ConfigOptionBool randomize_start;
ConfigOptionFloat resolution;
ConfigOptionFloats retract_before_travel;
ConfigOptionBools retract_layer_change;
ConfigOptionFloats retract_length;
ConfigOptionFloats retract_length_toolchange;
ConfigOptionFloats retract_lift;
ConfigOptionFloats retract_restart_extra;
ConfigOptionFloats retract_restart_extra_toolchange;
ConfigOptionInts retract_speed;
ConfigOptionInt rotate;
ConfigOptionFloat scale;
ConfigOptionFloat skirt_distance;
ConfigOptionInt skirt_height;
ConfigOptionInt skirts;
ConfigOptionInt slowdown_below_layer_time;
ConfigOptionFloatOrPercent small_perimeter_speed;
ConfigOptionEnum<InfillPattern> solid_fill_pattern;
ConfigOptionFloat solid_infill_below_area;
ConfigOptionInt solid_infill_every_layers;
ConfigOptionFloatOrPercent solid_infill_extrusion_width;
ConfigOptionFloatOrPercent solid_infill_speed;
ConfigOptionInt solid_layers;
ConfigOptionBool spiral_vase;
ConfigOptionInt standby_temperature_delta;
ConfigOptionString start_gcode;
ConfigOptionBool start_perimeters_at_concave_points;
ConfigOptionBool start_perimeters_at_non_overhang;
ConfigOptionBool support_material;
ConfigOptionInt support_material_angle;
ConfigOptionInt support_material_enforce_layers;
ConfigOptionInt support_material_extruder;
ConfigOptionFloatOrPercent support_material_extrusion_width;
ConfigOptionInt support_material_interface_extruder;
ConfigOptionInt support_material_interface_layers;
ConfigOptionFloat support_material_interface_spacing;
ConfigOptionEnum<InfillPattern> support_material_pattern;
ConfigOptionFloat support_material_spacing;
ConfigOptionFloat support_material_speed;
ConfigOptionInt support_material_threshold;
ConfigOptionInts temperature;
ConfigOptionBool thin_walls;
ConfigOptionInt threads;
ConfigOptionString toolchange_gcode;
ConfigOptionFloatOrPercent top_infill_extrusion_width;
ConfigOptionFloatOrPercent top_solid_infill_speed;
ConfigOptionInt top_solid_layers;
ConfigOptionFloat travel_speed;
ConfigOptionBool use_firmware_retraction;
ConfigOptionBool use_relative_e_distances;
ConfigOptionFloat vibration_limit;
ConfigOptionBools wipe;
ConfigOptionFloat z_offset;
PrintConfig() {
this->def = &PrintConfig::PrintConfigDef;
this->avoid_crossing_perimeters.value = false;
this->bed_size.point = Pointf(200,200);
this->bed_temperature.value = 0;
this->bottom_solid_layers.value = 3;
this->bridge_acceleration.value = 0;
this->bridge_fan_speed.value = 100;
this->bridge_flow_ratio.value = 1;
this->bridge_speed.value = 60;
this->brim_width.value = 0;
this->complete_objects.value = false;
this->cooling.value = true;
this->default_acceleration.value = 0;
this->disable_fan_first_layers.value = 1;
this->duplicate.value = 1;
this->duplicate_distance.value = 6;
this->duplicate_grid.point = Pointf(1,1);
this->end_gcode.value = "M104 S0 ; turn off temperature\nG28 X0 ; home X axis\nM84 ; disable motors\n";
this->external_perimeter_speed.value = 70;
this->external_perimeter_speed.percent = true;
this->external_perimeters_first.value = false;
this->extra_perimeters.value = true;
this->extruder_clearance_height.value = 20;
this->extruder_clearance_radius.value = 20;
this->extruder_offset.points.resize(1);
this->extruder_offset.points[0] = Pointf(0,0);
this->extrusion_axis.value = "E";
this->extrusion_multiplier.values.resize(1);
this->extrusion_multiplier.values[0] = 1;
this->extrusion_width.value = 0;
this->extrusion_width.percent = false;
this->fan_always_on.value = false;
this->fan_below_layer_time.value = 60;
this->filament_diameter.values.resize(1);
this->filament_diameter.values[0] = 3;
this->fill_angle.value = 45;
this->fill_density.value = 0.4;
this->fill_pattern.value = ipHoneycomb;
this->first_layer_acceleration.value = 0;
this->first_layer_bed_temperature.value = 0;
this->first_layer_extrusion_width.value = 200;
this->first_layer_extrusion_width.percent = true;
this->first_layer_height.value = 0.35;
this->first_layer_height.percent = false;
this->first_layer_speed.value = 30;
this->first_layer_speed.percent = true;
this->first_layer_temperature.values.resize(1);
this->first_layer_temperature.values[0] = 200;
this->g0.value = false;
this->gap_fill_speed.value = 20;
this->gcode_arcs.value = false;
this->gcode_comments.value = false;
this->gcode_flavor.value = gcfRepRap;
this->infill_acceleration.value = 0;
this->infill_every_layers.value = 1;
this->infill_extruder.value = 1;
this->infill_extrusion_width.value = 0;
this->infill_extrusion_width.percent = false;
this->infill_first.value = false;
this->infill_only_where_needed.value = false;
this->infill_speed.value = 60;
this->layer_gcode.value = "";
this->layer_height.value = 0.4;
this->max_fan_speed.value = 100;
this->min_fan_speed.value = 35;
this->min_print_speed.value = 10;
this->min_skirt_length.value = 0;
this->notes.value = "";
this->nozzle_diameter.values.resize(1);
this->nozzle_diameter.values[0] = 0.5;
this->only_retract_when_crossing_perimeters.value = true;
this->ooze_prevention.value = false;
this->output_filename_format.value = "[input_filename_base].gcode";
this->overhangs.value = true;
this->perimeter_acceleration.value = 0;
this->perimeter_extruder.value = 1;
this->perimeter_extrusion_width.value = 0;
this->perimeter_extrusion_width.percent = false;
this->perimeter_speed.value = 30;
this->perimeters.value = 3;
this->print_center.point = Pointf(100,100);
this->raft_layers.value = 0;
this->randomize_start.value = false;
this->resolution.value = 0;
this->retract_before_travel.values.resize(1);
this->retract_before_travel.values[0] = 2;
this->retract_layer_change.values.resize(1);
this->retract_layer_change.values[0] = true;
this->retract_length.values.resize(1);
this->retract_length.values[0] = 1;
this->retract_length_toolchange.values.resize(1);
this->retract_length_toolchange.values[0] = 10;
this->retract_lift.values.resize(1);
this->retract_lift.values[0] = 0;
this->retract_restart_extra.values.resize(1);
this->retract_restart_extra.values[0] = 0;
this->retract_restart_extra_toolchange.values.resize(1);
this->retract_restart_extra_toolchange.values[0] = 0;
this->retract_speed.values.resize(1);
this->retract_speed.values[0] = 30;
this->rotate.value = 0;
this->scale.value = 1;
this->skirt_distance.value = 6;
this->skirt_height.value = 1;
this->skirts.value = 1;
this->slowdown_below_layer_time.value = 30;
this->small_perimeter_speed.value = 30;
this->small_perimeter_speed.percent = false;
this->solid_fill_pattern.value = ipRectilinear;
this->solid_infill_below_area.value = 70;
this->solid_infill_every_layers.value = 0;
this->solid_infill_extrusion_width.value = 0;
this->solid_infill_extrusion_width.percent = false;
this->solid_infill_speed.value = 60;
this->solid_infill_speed.percent = false;
this->spiral_vase.value = false;
this->standby_temperature_delta.value = -5;
this->start_gcode.value = "G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n";
this->start_perimeters_at_concave_points.value = false;
this->start_perimeters_at_non_overhang.value = false;
this->support_material.value = false;
this->support_material_angle.value = 0;
this->support_material_enforce_layers.value = 0;
this->support_material_extruder.value = 1;
this->support_material_extrusion_width.value = 0;
this->support_material_extrusion_width.percent = false;
this->support_material_interface_extruder.value = 1;
this->support_material_interface_layers.value = 3;
this->support_material_interface_spacing.value = 0;
this->support_material_pattern.value = ipHoneycomb;
this->support_material_spacing.value = 2.5;
this->support_material_speed.value = 60;
this->support_material_threshold.value = 0;
this->temperature.values.resize(1);
this->temperature.values[0] = 200;
this->thin_walls.value = true;
this->threads.value = 2;
this->toolchange_gcode.value = "";
this->top_infill_extrusion_width.value = 0;
this->top_infill_extrusion_width.percent = false;
this->top_solid_infill_speed.value = 50;
this->top_solid_infill_speed.percent = false;
this->top_solid_layers.value = 3;
this->travel_speed.value = 130;
this->use_firmware_retraction.value = false;
this->use_relative_e_distances.value = false;
this->vibration_limit.value = 0;
this->wipe.values.resize(1);
this->wipe.values[0] = false;
this->z_offset.value = 0;
};
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
if (opt_key == "avoid_crossing_perimeters") return &this->avoid_crossing_perimeters;
if (opt_key == "bed_size") return &this->bed_size;
if (opt_key == "bed_temperature") return &this->bed_temperature;
if (opt_key == "bottom_solid_layers") return &this->bottom_solid_layers;
if (opt_key == "bridge_acceleration") return &this->bridge_acceleration;
if (opt_key == "bridge_fan_speed") return &this->bridge_fan_speed;
if (opt_key == "bridge_flow_ratio") return &this->bridge_flow_ratio;
if (opt_key == "bridge_speed") return &this->bridge_speed;
if (opt_key == "brim_width") return &this->brim_width;
if (opt_key == "complete_objects") return &this->complete_objects;
if (opt_key == "cooling") return &this->cooling;
if (opt_key == "default_acceleration") return &this->default_acceleration;
if (opt_key == "disable_fan_first_layers") return &this->disable_fan_first_layers;
if (opt_key == "duplicate") return &this->duplicate;
if (opt_key == "duplicate_distance") return &this->duplicate_distance;
if (opt_key == "duplicate_grid") return &this->duplicate_grid;
if (opt_key == "end_gcode") return &this->end_gcode;
if (opt_key == "external_perimeter_speed") return &this->external_perimeter_speed;
if (opt_key == "external_perimeters_first") return &this->external_perimeters_first;
if (opt_key == "extra_perimeters") return &this->extra_perimeters;
if (opt_key == "extruder_clearance_height") return &this->extruder_clearance_height;
if (opt_key == "extruder_clearance_radius") return &this->extruder_clearance_radius;
if (opt_key == "extruder_offset") return &this->extruder_offset;
if (opt_key == "extrusion_axis") return &this->extrusion_axis;
if (opt_key == "extrusion_multiplier") return &this->extrusion_multiplier;
if (opt_key == "extrusion_width") return &this->extrusion_width;
if (opt_key == "fan_always_on") return &this->fan_always_on;
if (opt_key == "fan_below_layer_time") return &this->fan_below_layer_time;
if (opt_key == "filament_diameter") return &this->filament_diameter;
if (opt_key == "fill_angle") return &this->fill_angle;
if (opt_key == "fill_density") return &this->fill_density;
if (opt_key == "fill_pattern") return &this->fill_pattern;
if (opt_key == "first_layer_acceleration") return &this->first_layer_acceleration;
if (opt_key == "first_layer_bed_temperature") return &this->first_layer_bed_temperature;
if (opt_key == "first_layer_extrusion_width") return &this->first_layer_extrusion_width;
if (opt_key == "first_layer_height") return &this->first_layer_height;
if (opt_key == "first_layer_speed") return &this->first_layer_speed;
if (opt_key == "first_layer_temperature") return &this->first_layer_temperature;
if (opt_key == "g0") return &this->g0;
if (opt_key == "gap_fill_speed") return &this->gap_fill_speed;
if (opt_key == "gcode_arcs") return &this->gcode_arcs;
if (opt_key == "gcode_comments") return &this->gcode_comments;
if (opt_key == "gcode_flavor") return &this->gcode_flavor;
if (opt_key == "infill_acceleration") return &this->infill_acceleration;
if (opt_key == "infill_every_layers") return &this->infill_every_layers;
if (opt_key == "infill_extruder") return &this->infill_extruder;
if (opt_key == "infill_extrusion_width") return &this->infill_extrusion_width;
if (opt_key == "infill_first") return &this->infill_first;
if (opt_key == "infill_only_where_needed") return &this->infill_only_where_needed;
if (opt_key == "infill_speed") return &this->infill_speed;
if (opt_key == "layer_gcode") return &this->layer_gcode;
if (opt_key == "layer_height") return &this->layer_height;
if (opt_key == "max_fan_speed") return &this->max_fan_speed;
if (opt_key == "min_fan_speed") return &this->min_fan_speed;
if (opt_key == "min_print_speed") return &this->min_print_speed;
if (opt_key == "min_skirt_length") return &this->min_skirt_length;
if (opt_key == "notes") return &this->notes;
if (opt_key == "nozzle_diameter") return &this->nozzle_diameter;
if (opt_key == "only_retract_when_crossing_perimeters") return &this->only_retract_when_crossing_perimeters;
if (opt_key == "ooze_prevention") return &this->ooze_prevention;
if (opt_key == "output_filename_format") return &this->output_filename_format;
if (opt_key == "overhangs") return &this->overhangs;
if (opt_key == "perimeter_acceleration") return &this->perimeter_acceleration;
if (opt_key == "perimeter_extruder") return &this->perimeter_extruder;
if (opt_key == "perimeter_extrusion_width") return &this->perimeter_extrusion_width;
if (opt_key == "perimeter_speed") return &this->perimeter_speed;
if (opt_key == "perimeters") return &this->perimeters;
if (opt_key == "post_process") return &this->post_process;
if (opt_key == "print_center") return &this->print_center;
if (opt_key == "raft_layers") return &this->raft_layers;
if (opt_key == "randomize_start") return &this->randomize_start;
if (opt_key == "resolution") return &this->resolution;
if (opt_key == "retract_before_travel") return &this->retract_before_travel;
if (opt_key == "retract_layer_change") return &this->retract_layer_change;
if (opt_key == "retract_length") return &this->retract_length;
if (opt_key == "retract_length_toolchange") return &this->retract_length_toolchange;
if (opt_key == "retract_lift") return &this->retract_lift;
if (opt_key == "retract_restart_extra") return &this->retract_restart_extra;
if (opt_key == "retract_restart_extra_toolchange") return &this->retract_restart_extra_toolchange;
if (opt_key == "retract_speed") return &this->retract_speed;
if (opt_key == "rotate") return &this->rotate;
if (opt_key == "scale") return &this->scale;
if (opt_key == "skirt_distance") return &this->skirt_distance;
if (opt_key == "skirt_height") return &this->skirt_height;
if (opt_key == "skirts") return &this->skirts;
if (opt_key == "slowdown_below_layer_time") return &this->slowdown_below_layer_time;
if (opt_key == "small_perimeter_speed") return &this->small_perimeter_speed;
if (opt_key == "solid_fill_pattern") return &this->solid_fill_pattern;
if (opt_key == "solid_infill_below_area") return &this->solid_infill_below_area;
if (opt_key == "solid_infill_every_layers") return &this->solid_infill_every_layers;
if (opt_key == "solid_infill_extrusion_width") return &this->solid_infill_extrusion_width;
if (opt_key == "solid_infill_speed") return &this->solid_infill_speed;
if (opt_key == "solid_layers") return &this->solid_layers;
if (opt_key == "spiral_vase") return &this->spiral_vase;
if (opt_key == "standby_temperature_delta") return &this->standby_temperature_delta;
if (opt_key == "start_gcode") return &this->start_gcode;
if (opt_key == "start_perimeters_at_concave_points") return &this->start_perimeters_at_concave_points;
if (opt_key == "start_perimeters_at_non_overhang") return &this->start_perimeters_at_non_overhang;
if (opt_key == "support_material") return &this->support_material;
if (opt_key == "support_material_angle") return &this->support_material_angle;
if (opt_key == "support_material_enforce_layers") return &this->support_material_enforce_layers;
if (opt_key == "support_material_extruder") return &this->support_material_extruder;
if (opt_key == "support_material_extrusion_width") return &this->support_material_extrusion_width;
if (opt_key == "support_material_interface_extruder") return &this->support_material_interface_extruder;
if (opt_key == "support_material_interface_layers") return &this->support_material_interface_layers;
if (opt_key == "support_material_interface_spacing") return &this->support_material_interface_spacing;
if (opt_key == "support_material_pattern") return &this->support_material_pattern;
if (opt_key == "support_material_spacing") return &this->support_material_spacing;
if (opt_key == "support_material_speed") return &this->support_material_speed;
if (opt_key == "support_material_threshold") return &this->support_material_threshold;
if (opt_key == "temperature") return &this->temperature;
if (opt_key == "thin_walls") return &this->thin_walls;
if (opt_key == "threads") return &this->threads;
if (opt_key == "toolchange_gcode") return &this->toolchange_gcode;
if (opt_key == "top_infill_extrusion_width") return &this->top_infill_extrusion_width;
if (opt_key == "top_solid_infill_speed") return &this->top_solid_infill_speed;
if (opt_key == "top_solid_layers") return &this->top_solid_layers;
if (opt_key == "travel_speed") return &this->travel_speed;
if (opt_key == "use_firmware_retraction") return &this->use_firmware_retraction;
if (opt_key == "use_relative_e_distances") return &this->use_relative_e_distances;
if (opt_key == "vibration_limit") return &this->vibration_limit;
if (opt_key == "wipe") return &this->wipe;
if (opt_key == "z_offset") return &this->z_offset;
if (create) throw "Attempt to create non-existing option in StaticConfig object";
return NULL;
};
static t_optiondef_map def;
static t_optiondef_map build_def () {
t_optiondef_map Options;
@ -468,7 +61,7 @@ class PrintConfig : public StaticConfig
Options["bed_temperature"].tooltip = "Bed temperature for layers after the first one. Set this to zero to disable bed temperature control commands in the output.";
Options["bed_temperature"].sidetext = "°C";
Options["bed_temperature"].cli = "bed-temperature=i";
Options["bed_temperature"].full_label = true;
Options["bed_temperature"].full_label = "Bed temperature";
Options["bed_temperature"].max = 300;
Options["bottom_solid_layers"].type = coInt;
@ -477,7 +70,7 @@ class PrintConfig : public StaticConfig
Options["bottom_solid_layers"].tooltip = "Number of solid layers to generate on bottom surfaces.";
Options["bottom_solid_layers"].cli = "bottom-solid-layers=i";
Options["bottom_solid_layers"].scope = "object";
Options["bottom_solid_layers"].full_label = true;
Options["bottom_solid_layers"].full_label = "Bottom solid layers";
Options["bridge_acceleration"].type = coFloat;
Options["bridge_acceleration"].label = "Bridge";
@ -533,11 +126,6 @@ class PrintConfig : public StaticConfig
Options["disable_fan_first_layers"].cli = "disable-fan-first-layers=i";
Options["disable_fan_first_layers"].max = 1000;
Options["duplicate"].type = coInt;
Options["duplicate"].label = "Copies (autoarrange)";
Options["duplicate"].cli = "duplicate=i";
Options["duplicate"].min = 1;
Options["duplicate_distance"].type = coFloat;
Options["duplicate_distance"].label = "Distance between copies";
Options["duplicate_distance"].tooltip = "Distance used for the auto-arrange feature of the plater.";
@ -545,10 +133,6 @@ class PrintConfig : public StaticConfig
Options["duplicate_distance"].cli = "duplicate-distance=f";
Options["duplicate_distance"].aliases.push_back("multiply_distance");
Options["duplicate_grid"].type = coPoint;
Options["duplicate_grid"].label = "Copies (grid)";
Options["duplicate_grid"].cli = "duplicate-grid=s";
Options["end_gcode"].type = coString;
Options["end_gcode"].label = "End G-code";
Options["end_gcode"].tooltip = "This end procedure is inserted at the end of the output file. Note that you can use placeholder variables for all Slic3r settings.";
@ -576,6 +160,14 @@ class PrintConfig : public StaticConfig
Options["extra_perimeters"].cli = "extra-perimeters!";
Options["extra_perimeters"].scope = "object";
Options["extruder"].type = coInt;
Options["extruder"].label = "Extruder";
Options["extruder"].cli = "extruder=i";
Options["extruder"].shortcut.push_back("perimeter_extruder");
Options["extruder"].shortcut.push_back("infill_extruder");
Options["extruder"].shortcut.push_back("support_material_extruder");
Options["extruder"].shortcut.push_back("support_material_interface_extruder");
Options["extruder_clearance_height"].type = coFloat;
Options["extruder_clearance_height"].label = "Height";
Options["extruder_clearance_height"].tooltip = "Set this to the vertical distance between your nozzle tip and (usually) the X carriage rods. In other words, this is the height of the clearance cylinder around your extruder, and it represents the maximum depth the extruder can peek before colliding with other printed objects.";
@ -649,6 +241,7 @@ class PrintConfig : public StaticConfig
Options["fill_pattern"].tooltip = "Fill pattern for general low-density infill.";
Options["fill_pattern"].cli = "fill-pattern=s";
Options["fill_pattern"].scope = "object";
Options["fill_pattern"].enum_keys_map = ConfigOptionEnum<InfillPattern>::get_enum_values();
Options["fill_pattern"].enum_values.push_back("rectilinear");
Options["fill_pattern"].enum_values.push_back("line");
Options["fill_pattern"].enum_values.push_back("concentric");
@ -728,6 +321,7 @@ class PrintConfig : public StaticConfig
Options["gcode_flavor"].label = "G-code flavor";
Options["gcode_flavor"].tooltip = "Some G/M-code commands, including temperature control and others, are not universal. Set this option to your printer's firmware to get a compatible output. The \"No extrusion\" flavor prevents Slic3r from exporting any extrusion value at all.";
Options["gcode_flavor"].cli = "gcode-flavor=s";
Options["gcode_flavor"].enum_keys_map = ConfigOptionEnum<GCodeFlavor>::get_enum_values();
Options["gcode_flavor"].enum_values.push_back("reprap");
Options["gcode_flavor"].enum_values.push_back("teacup");
Options["gcode_flavor"].enum_values.push_back("makerware");
@ -754,7 +348,7 @@ class PrintConfig : public StaticConfig
Options["infill_every_layers"].sidetext = "layers";
Options["infill_every_layers"].cli = "infill-every-layers=i";
Options["infill_every_layers"].scope = "object";
Options["infill_every_layers"].full_label = true;
Options["infill_every_layers"].full_label = "Combine infill every n layers";
Options["infill_every_layers"].min = 1;
Options["infill_extruder"].type = coInt;
@ -983,16 +577,6 @@ class PrintConfig : public StaticConfig
Options["retract_speed"].cli = "retract-speed=f@";
Options["retract_speed"].max = 1000;
Options["rotate"].type = coInt;
Options["rotate"].label = "Rotate";
Options["rotate"].sidetext = "°";
Options["rotate"].cli = "rotate=i";
Options["rotate"].max = 359;
Options["scale"].type = coFloat;
Options["scale"].label = "Scale";
Options["scale"].cli = "scale=f";
Options["skirt_distance"].type = coFloat;
Options["skirt_distance"].label = "Distance from object";
Options["skirt_distance"].tooltip = "Distance between skirt and object(s). Set this to zero to attach the skirt to the object(s) and get a brim for better adhesion.";
@ -1031,6 +615,7 @@ class PrintConfig : public StaticConfig
Options["solid_fill_pattern"].tooltip = "Fill pattern for top/bottom infill.";
Options["solid_fill_pattern"].cli = "solid-fill-pattern=s";
Options["solid_fill_pattern"].scope = "object";
Options["solid_fill_pattern"].enum_keys_map = ConfigOptionEnum<InfillPattern>::get_enum_values();
Options["solid_fill_pattern"].enum_values.push_back("rectilinear");
Options["solid_fill_pattern"].enum_values.push_back("concentric");
Options["solid_fill_pattern"].enum_values.push_back("hilbertcurve");
@ -1133,7 +718,7 @@ class PrintConfig : public StaticConfig
Options["support_material_enforce_layers"].sidetext = "layers";
Options["support_material_enforce_layers"].cli = "support-material-enforce-layers=f";
Options["support_material_enforce_layers"].scope = "object";
Options["support_material_enforce_layers"].full_label = true;
Options["support_material_enforce_layers"].full_label = "Enforce support for the first n layers";
Options["support_material_extruder"].type = coInt;
Options["support_material_extruder"].label = "Support material extruder";
@ -1207,7 +792,7 @@ class PrintConfig : public StaticConfig
Options["temperature"].tooltip = "Extruder temperature for layers after the first one. Set this to zero to disable temperature control commands in the output.";
Options["temperature"].sidetext = "°C";
Options["temperature"].cli = "temperature=i@";
Options["temperature"].full_label = true;
Options["temperature"].full_label = "Temperature";
Options["temperature"].max = 400;
Options["thin_walls"].type = coBool;
@ -1253,7 +838,7 @@ class PrintConfig : public StaticConfig
Options["top_solid_layers"].tooltip = "Number of solid layers to generate on top surfaces.";
Options["top_solid_layers"].cli = "top-solid-layers=i";
Options["top_solid_layers"].scope = "object";
Options["top_solid_layers"].full_label = true;
Options["top_solid_layers"].full_label = "Top solid layers";
Options["travel_speed"].type = coFloat;
Options["travel_speed"].label = "Travel";
@ -1293,13 +878,459 @@ class PrintConfig : public StaticConfig
};
};
class PrintObjectConfig : public virtual StaticConfig
{
public:
ConfigOptionFloatOrPercent extrusion_width;
ConfigOptionFloatOrPercent first_layer_height;
ConfigOptionBool infill_only_where_needed;
ConfigOptionFloat layer_height;
ConfigOptionInt raft_layers;
ConfigOptionBool support_material;
ConfigOptionInt support_material_angle;
ConfigOptionInt support_material_enforce_layers;
ConfigOptionInt support_material_extruder;
ConfigOptionFloatOrPercent support_material_extrusion_width;
ConfigOptionInt support_material_interface_extruder;
ConfigOptionInt support_material_interface_layers;
ConfigOptionFloat support_material_interface_spacing;
ConfigOptionEnum<InfillPattern> support_material_pattern;
ConfigOptionFloat support_material_spacing;
ConfigOptionFloat support_material_speed;
ConfigOptionInt support_material_threshold;
PrintObjectConfig() {
this->def = &PrintConfigDef::def;
this->extrusion_width.value = 0;
this->extrusion_width.percent = false;
this->first_layer_height.value = 0.35;
this->first_layer_height.percent = false;
this->infill_only_where_needed.value = false;
this->layer_height.value = 0.4;
this->raft_layers.value = 0;
this->support_material.value = false;
this->support_material_angle.value = 0;
this->support_material_enforce_layers.value = 0;
this->support_material_extruder.value = 1;
this->support_material_extrusion_width.value = 0;
this->support_material_extrusion_width.percent = false;
this->support_material_interface_extruder.value = 1;
this->support_material_interface_layers.value = 3;
this->support_material_interface_spacing.value = 0;
this->support_material_pattern.value = ipHoneycomb;
this->support_material_spacing.value = 2.5;
this->support_material_speed.value = 60;
this->support_material_threshold.value = 0;
};
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
if (opt_key == "extrusion_width") return &this->extrusion_width;
if (opt_key == "first_layer_height") return &this->first_layer_height;
if (opt_key == "infill_only_where_needed") return &this->infill_only_where_needed;
if (opt_key == "layer_height") return &this->layer_height;
if (opt_key == "raft_layers") return &this->raft_layers;
if (opt_key == "support_material") return &this->support_material;
if (opt_key == "support_material_angle") return &this->support_material_angle;
if (opt_key == "support_material_enforce_layers") return &this->support_material_enforce_layers;
if (opt_key == "support_material_extruder") return &this->support_material_extruder;
if (opt_key == "support_material_extrusion_width") return &this->support_material_extrusion_width;
if (opt_key == "support_material_interface_extruder") return &this->support_material_interface_extruder;
if (opt_key == "support_material_interface_layers") return &this->support_material_interface_layers;
if (opt_key == "support_material_interface_spacing") return &this->support_material_interface_spacing;
if (opt_key == "support_material_pattern") return &this->support_material_pattern;
if (opt_key == "support_material_spacing") return &this->support_material_spacing;
if (opt_key == "support_material_speed") return &this->support_material_speed;
if (opt_key == "support_material_threshold") return &this->support_material_threshold;
return NULL;
};
};
class PrintRegionConfig : public virtual StaticConfig
{
public:
ConfigOptionInt bottom_solid_layers;
ConfigOptionBool extra_perimeters;
ConfigOptionInt fill_angle;
ConfigOptionFloat fill_density;
ConfigOptionEnum<InfillPattern> fill_pattern;
ConfigOptionInt infill_extruder;
ConfigOptionFloatOrPercent infill_extrusion_width;
ConfigOptionInt infill_every_layers;
ConfigOptionInt perimeter_extruder;
ConfigOptionFloatOrPercent perimeter_extrusion_width;
ConfigOptionInt perimeters;
ConfigOptionEnum<InfillPattern> solid_fill_pattern;
ConfigOptionFloat solid_infill_below_area;
ConfigOptionFloatOrPercent solid_infill_extrusion_width;
ConfigOptionInt solid_infill_every_layers;
ConfigOptionInt solid_layers;
ConfigOptionBool thin_walls;
ConfigOptionFloatOrPercent top_infill_extrusion_width;
ConfigOptionInt top_solid_layers;
PrintRegionConfig() {
this->def = &PrintConfigDef::def;
this->bottom_solid_layers.value = 3;
this->extra_perimeters.value = true;
this->fill_angle.value = 45;
this->fill_density.value = 0.4;
this->fill_pattern.value = ipHoneycomb;
this->infill_extruder.value = 1;
this->infill_extrusion_width.value = 0;
this->infill_extrusion_width.percent = false;
this->infill_every_layers.value = 1;
this->perimeter_extruder.value = 1;
this->perimeter_extrusion_width.value = 0;
this->perimeter_extrusion_width.percent = false;
this->perimeters.value = 3;
this->solid_fill_pattern.value = ipRectilinear;
this->solid_infill_below_area.value = 70;
this->solid_infill_extrusion_width.value = 0;
this->solid_infill_extrusion_width.percent = false;
this->solid_infill_every_layers.value = 0;
this->thin_walls.value = true;
this->top_infill_extrusion_width.value = 0;
this->top_infill_extrusion_width.percent = false;
this->top_solid_layers.value = 3;
};
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
if (opt_key == "bottom_solid_layers") return &this->bottom_solid_layers;
if (opt_key == "extra_perimeters") return &this->extra_perimeters;
if (opt_key == "fill_angle") return &this->fill_angle;
if (opt_key == "fill_density") return &this->fill_density;
if (opt_key == "fill_pattern") return &this->fill_pattern;
if (opt_key == "infill_extruder") return &this->infill_extruder;
if (opt_key == "infill_extrusion_width") return &this->infill_extrusion_width;
if (opt_key == "infill_every_layers") return &this->infill_every_layers;
if (opt_key == "perimeter_extruder") return &this->perimeter_extruder;
if (opt_key == "perimeter_extrusion_width") return &this->perimeter_extrusion_width;
if (opt_key == "perimeters") return &this->perimeters;
if (opt_key == "solid_fill_pattern") return &this->solid_fill_pattern;
if (opt_key == "solid_infill_below_area") return &this->solid_infill_below_area;
if (opt_key == "solid_infill_extrusion_width") return &this->solid_infill_extrusion_width;
if (opt_key == "solid_infill_every_layers") return &this->solid_infill_every_layers;
if (opt_key == "solid_layers") return &this->solid_layers;
if (opt_key == "thin_walls") return &this->thin_walls;
if (opt_key == "top_infill_extrusion_width") return &this->top_infill_extrusion_width;
if (opt_key == "top_solid_layers") return &this->top_solid_layers;
return NULL;
};
};
class PrintConfig : public virtual StaticConfig
{
public:
ConfigOptionBool avoid_crossing_perimeters;
ConfigOptionPoint bed_size;
ConfigOptionInt bed_temperature;
ConfigOptionFloat bridge_acceleration;
ConfigOptionInt bridge_fan_speed;
ConfigOptionFloat bridge_flow_ratio;
ConfigOptionFloat bridge_speed;
ConfigOptionFloat brim_width;
ConfigOptionBool complete_objects;
ConfigOptionBool cooling;
ConfigOptionFloat default_acceleration;
ConfigOptionInt disable_fan_first_layers;
ConfigOptionFloat duplicate_distance;
ConfigOptionString end_gcode;
ConfigOptionFloatOrPercent external_perimeter_speed;
ConfigOptionBool external_perimeters_first;
ConfigOptionFloat extruder_clearance_height;
ConfigOptionFloat extruder_clearance_radius;
ConfigOptionPoints extruder_offset;
ConfigOptionString extrusion_axis;
ConfigOptionFloats extrusion_multiplier;
ConfigOptionBool fan_always_on;
ConfigOptionInt fan_below_layer_time;
ConfigOptionFloats filament_diameter;
ConfigOptionFloat first_layer_acceleration;
ConfigOptionInt first_layer_bed_temperature;
ConfigOptionFloatOrPercent first_layer_extrusion_width;
ConfigOptionFloatOrPercent first_layer_speed;
ConfigOptionInts first_layer_temperature;
ConfigOptionBool g0;
ConfigOptionFloat gap_fill_speed;
ConfigOptionBool gcode_arcs;
ConfigOptionBool gcode_comments;
ConfigOptionEnum<GCodeFlavor> gcode_flavor;
ConfigOptionFloat infill_acceleration;
ConfigOptionBool infill_first;
ConfigOptionFloat infill_speed;
ConfigOptionString layer_gcode;
ConfigOptionInt max_fan_speed;
ConfigOptionInt min_fan_speed;
ConfigOptionInt min_print_speed;
ConfigOptionFloat min_skirt_length;
ConfigOptionString notes;
ConfigOptionFloats nozzle_diameter;
ConfigOptionBool only_retract_when_crossing_perimeters;
ConfigOptionBool ooze_prevention;
ConfigOptionString output_filename_format;
ConfigOptionBool overhangs;
ConfigOptionFloat perimeter_acceleration;
ConfigOptionFloat perimeter_speed;
ConfigOptionStrings post_process;
ConfigOptionPoint print_center;
ConfigOptionBool randomize_start;
ConfigOptionFloat resolution;
ConfigOptionFloats retract_before_travel;
ConfigOptionBools retract_layer_change;
ConfigOptionFloats retract_length;
ConfigOptionFloats retract_length_toolchange;
ConfigOptionFloats retract_lift;
ConfigOptionFloats retract_restart_extra;
ConfigOptionFloats retract_restart_extra_toolchange;
ConfigOptionInts retract_speed;
ConfigOptionFloat skirt_distance;
ConfigOptionInt skirt_height;
ConfigOptionInt skirts;
ConfigOptionInt slowdown_below_layer_time;
ConfigOptionFloatOrPercent small_perimeter_speed;
ConfigOptionFloatOrPercent solid_infill_speed;
ConfigOptionBool spiral_vase;
ConfigOptionInt standby_temperature_delta;
ConfigOptionString start_gcode;
ConfigOptionBool start_perimeters_at_concave_points;
ConfigOptionBool start_perimeters_at_non_overhang;
ConfigOptionInts temperature;
ConfigOptionInt threads;
ConfigOptionString toolchange_gcode;
ConfigOptionFloatOrPercent top_solid_infill_speed;
ConfigOptionFloat travel_speed;
ConfigOptionBool use_firmware_retraction;
ConfigOptionBool use_relative_e_distances;
ConfigOptionFloat vibration_limit;
ConfigOptionBools wipe;
ConfigOptionFloat z_offset;
PrintConfig() {
this->def = &PrintConfigDef::def;
this->avoid_crossing_perimeters.value = false;
this->bed_size.point = Pointf(200,200);
this->bed_temperature.value = 0;
this->bridge_acceleration.value = 0;
this->bridge_fan_speed.value = 100;
this->bridge_flow_ratio.value = 1;
this->bridge_speed.value = 60;
this->brim_width.value = 0;
this->complete_objects.value = false;
this->cooling.value = true;
this->default_acceleration.value = 0;
this->disable_fan_first_layers.value = 1;
this->duplicate_distance.value = 6;
this->end_gcode.value = "M104 S0 ; turn off temperature\nG28 X0 ; home X axis\nM84 ; disable motors\n";
this->external_perimeter_speed.value = 70;
this->external_perimeter_speed.percent = true;
this->external_perimeters_first.value = false;
this->extruder_clearance_height.value = 20;
this->extruder_clearance_radius.value = 20;
this->extruder_offset.values.resize(1);
this->extruder_offset.values[0] = Pointf(0,0);
this->extrusion_axis.value = "E";
this->extrusion_multiplier.values.resize(1);
this->extrusion_multiplier.values[0] = 1;
this->fan_always_on.value = false;
this->fan_below_layer_time.value = 60;
this->filament_diameter.values.resize(1);
this->filament_diameter.values[0] = 3;
this->first_layer_acceleration.value = 0;
this->first_layer_bed_temperature.value = 0;
this->first_layer_extrusion_width.value = 200;
this->first_layer_extrusion_width.percent = true;
this->first_layer_speed.value = 30;
this->first_layer_speed.percent = true;
this->first_layer_temperature.values.resize(1);
this->first_layer_temperature.values[0] = 200;
this->g0.value = false;
this->gap_fill_speed.value = 20;
this->gcode_arcs.value = false;
this->gcode_comments.value = false;
this->gcode_flavor.value = gcfRepRap;
this->infill_acceleration.value = 0;
this->infill_first.value = false;
this->infill_speed.value = 60;
this->layer_gcode.value = "";
this->max_fan_speed.value = 100;
this->min_fan_speed.value = 35;
this->min_print_speed.value = 10;
this->min_skirt_length.value = 0;
this->notes.value = "";
this->nozzle_diameter.values.resize(1);
this->nozzle_diameter.values[0] = 0.5;
this->only_retract_when_crossing_perimeters.value = true;
this->ooze_prevention.value = false;
this->output_filename_format.value = "[input_filename_base].gcode";
this->overhangs.value = true;
this->perimeter_acceleration.value = 0;
this->perimeter_speed.value = 30;
this->print_center.point = Pointf(100,100);
this->randomize_start.value = false;
this->resolution.value = 0;
this->retract_before_travel.values.resize(1);
this->retract_before_travel.values[0] = 2;
this->retract_layer_change.values.resize(1);
this->retract_layer_change.values[0] = true;
this->retract_length.values.resize(1);
this->retract_length.values[0] = 1;
this->retract_length_toolchange.values.resize(1);
this->retract_length_toolchange.values[0] = 10;
this->retract_lift.values.resize(1);
this->retract_lift.values[0] = 0;
this->retract_restart_extra.values.resize(1);
this->retract_restart_extra.values[0] = 0;
this->retract_restart_extra_toolchange.values.resize(1);
this->retract_restart_extra_toolchange.values[0] = 0;
this->retract_speed.values.resize(1);
this->retract_speed.values[0] = 30;
this->skirt_distance.value = 6;
this->skirt_height.value = 1;
this->skirts.value = 1;
this->slowdown_below_layer_time.value = 30;
this->small_perimeter_speed.value = 30;
this->small_perimeter_speed.percent = false;
this->solid_infill_speed.value = 60;
this->solid_infill_speed.percent = false;
this->spiral_vase.value = false;
this->standby_temperature_delta.value = -5;
this->start_gcode.value = "G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n";
this->start_perimeters_at_concave_points.value = false;
this->start_perimeters_at_non_overhang.value = false;
this->temperature.values.resize(1);
this->temperature.values[0] = 200;
this->threads.value = 2;
this->toolchange_gcode.value = "";
this->top_solid_infill_speed.value = 50;
this->top_solid_infill_speed.percent = false;
this->travel_speed.value = 130;
this->use_firmware_retraction.value = false;
this->use_relative_e_distances.value = false;
this->vibration_limit.value = 0;
this->wipe.values.resize(1);
this->wipe.values[0] = false;
this->z_offset.value = 0;
};
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
if (opt_key == "avoid_crossing_perimeters") return &this->avoid_crossing_perimeters;
if (opt_key == "bed_size") return &this->bed_size;
if (opt_key == "bed_temperature") return &this->bed_temperature;
if (opt_key == "bridge_acceleration") return &this->bridge_acceleration;
if (opt_key == "bridge_fan_speed") return &this->bridge_fan_speed;
if (opt_key == "bridge_flow_ratio") return &this->bridge_flow_ratio;
if (opt_key == "bridge_speed") return &this->bridge_speed;
if (opt_key == "brim_width") return &this->brim_width;
if (opt_key == "complete_objects") return &this->complete_objects;
if (opt_key == "cooling") return &this->cooling;
if (opt_key == "default_acceleration") return &this->default_acceleration;
if (opt_key == "disable_fan_first_layers") return &this->disable_fan_first_layers;
if (opt_key == "duplicate_distance") return &this->duplicate_distance;
if (opt_key == "end_gcode") return &this->end_gcode;
if (opt_key == "external_perimeter_speed") return &this->external_perimeter_speed;
if (opt_key == "external_perimeters_first") return &this->external_perimeters_first;
if (opt_key == "extruder_clearance_height") return &this->extruder_clearance_height;
if (opt_key == "extruder_clearance_radius") return &this->extruder_clearance_radius;
if (opt_key == "extruder_offset") return &this->extruder_offset;
if (opt_key == "extrusion_axis") return &this->extrusion_axis;
if (opt_key == "extrusion_multiplier") return &this->extrusion_multiplier;
if (opt_key == "fan_always_on") return &this->fan_always_on;
if (opt_key == "fan_below_layer_time") return &this->fan_below_layer_time;
if (opt_key == "filament_diameter") return &this->filament_diameter;
if (opt_key == "first_layer_acceleration") return &this->first_layer_acceleration;
if (opt_key == "first_layer_bed_temperature") return &this->first_layer_bed_temperature;
if (opt_key == "first_layer_extrusion_width") return &this->first_layer_extrusion_width;
if (opt_key == "first_layer_speed") return &this->first_layer_speed;
if (opt_key == "first_layer_temperature") return &this->first_layer_temperature;
if (opt_key == "g0") return &this->g0;
if (opt_key == "gap_fill_speed") return &this->gap_fill_speed;
if (opt_key == "gcode_arcs") return &this->gcode_arcs;
if (opt_key == "gcode_comments") return &this->gcode_comments;
if (opt_key == "gcode_flavor") return &this->gcode_flavor;
if (opt_key == "infill_acceleration") return &this->infill_acceleration;
if (opt_key == "infill_first") return &this->infill_first;
if (opt_key == "infill_speed") return &this->infill_speed;
if (opt_key == "layer_gcode") return &this->layer_gcode;
if (opt_key == "max_fan_speed") return &this->max_fan_speed;
if (opt_key == "min_fan_speed") return &this->min_fan_speed;
if (opt_key == "min_print_speed") return &this->min_print_speed;
if (opt_key == "min_skirt_length") return &this->min_skirt_length;
if (opt_key == "notes") return &this->notes;
if (opt_key == "nozzle_diameter") return &this->nozzle_diameter;
if (opt_key == "only_retract_when_crossing_perimeters") return &this->only_retract_when_crossing_perimeters;
if (opt_key == "ooze_prevention") return &this->ooze_prevention;
if (opt_key == "output_filename_format") return &this->output_filename_format;
if (opt_key == "overhangs") return &this->overhangs;
if (opt_key == "perimeter_acceleration") return &this->perimeter_acceleration;
if (opt_key == "perimeter_speed") return &this->perimeter_speed;
if (opt_key == "post_process") return &this->post_process;
if (opt_key == "print_center") return &this->print_center;
if (opt_key == "randomize_start") return &this->randomize_start;
if (opt_key == "resolution") return &this->resolution;
if (opt_key == "retract_before_travel") return &this->retract_before_travel;
if (opt_key == "retract_layer_change") return &this->retract_layer_change;
if (opt_key == "retract_length") return &this->retract_length;
if (opt_key == "retract_length_toolchange") return &this->retract_length_toolchange;
if (opt_key == "retract_lift") return &this->retract_lift;
if (opt_key == "retract_restart_extra") return &this->retract_restart_extra;
if (opt_key == "retract_restart_extra_toolchange") return &this->retract_restart_extra_toolchange;
if (opt_key == "retract_speed") return &this->retract_speed;
if (opt_key == "skirt_distance") return &this->skirt_distance;
if (opt_key == "skirt_height") return &this->skirt_height;
if (opt_key == "skirts") return &this->skirts;
if (opt_key == "slowdown_below_layer_time") return &this->slowdown_below_layer_time;
if (opt_key == "small_perimeter_speed") return &this->small_perimeter_speed;
if (opt_key == "solid_infill_speed") return &this->solid_infill_speed;
if (opt_key == "spiral_vase") return &this->spiral_vase;
if (opt_key == "standby_temperature_delta") return &this->standby_temperature_delta;
if (opt_key == "start_gcode") return &this->start_gcode;
if (opt_key == "start_perimeters_at_concave_points") return &this->start_perimeters_at_concave_points;
if (opt_key == "start_perimeters_at_non_overhang") return &this->start_perimeters_at_non_overhang;
if (opt_key == "temperature") return &this->temperature;
if (opt_key == "threads") return &this->threads;
if (opt_key == "toolchange_gcode") return &this->toolchange_gcode;
if (opt_key == "top_solid_infill_speed") return &this->top_solid_infill_speed;
if (opt_key == "travel_speed") return &this->travel_speed;
if (opt_key == "use_firmware_retraction") return &this->use_firmware_retraction;
if (opt_key == "use_relative_e_distances") return &this->use_relative_e_distances;
if (opt_key == "vibration_limit") return &this->vibration_limit;
if (opt_key == "wipe") return &this->wipe;
if (opt_key == "z_offset") return &this->z_offset;
return NULL;
};
std::string get_extrusion_axis() {
if (this->gcode_flavor == gcfMach3) {
return std::string("A");
} else if (this->gcode_flavor == gcfNoExtrusion) {
return std::string("");
}
return this->extrusion_axis;
}
};
class DynamicPrintConfig : public DynamicConfig
{
public:
DynamicPrintConfig() {
this->def = &PrintConfig::PrintConfigDef;
this->def = &PrintConfigDef::def;
};
};
class FullPrintConfig : public PrintObjectConfig, public PrintRegionConfig, public PrintConfig {
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
ConfigOption* opt;
if ((opt = PrintObjectConfig::option(opt_key, create)) != NULL) return opt;
if ((opt = PrintRegionConfig::option(opt_key, create)) != NULL) return opt;
if ((opt = PrintConfig::option(opt_key, create)) != NULL) return opt;
return NULL;
};
};
}

View file

@ -20,8 +20,10 @@ extern "C" {
#define EPSILON 1e-4
#define SCALING_FACTOR 0.000001
#define PI 3.141592653589793238
#define scale_(val) (val / SCALING_FACTOR)
#define unscale(val) (val * SCALING_FACTOR)
typedef long coord_t;
namespace Slic3r {}
using namespace Slic3r;