Implemented volumetric flow rate hints,

removed some C++11 conditioned compilation. Slic3r now requires C++11.
This commit is contained in:
bubnikv 2017-11-09 15:10:20 +01:00
parent 9a0100d6de
commit b23b9ea1d2
10 changed files with 151 additions and 236 deletions

View file

@ -1010,7 +1010,7 @@ public:
{
ConfigOption *opt = this->optptr(opt_key, create);
assert(opt == nullptr || opt->type() == typename TYPE::static_type());
return (opt == nullptr || opt->type() == typename TYPE::static_type()) ? nullptr : static_cast<TYPE*>(opt);
return (opt == nullptr || opt->type() != typename TYPE::static_type()) ? nullptr : static_cast<TYPE*>(opt);
}
template<typename TYPE>
const TYPE* option(const t_config_option_key &opt_key) const
@ -1101,23 +1101,23 @@ public:
// Overrides ConfigBase::keys(). Collect names of all configuration values maintained by this configuration store.
t_config_option_keys keys() const override;
std::string& opt_string(const t_config_option_key &opt_key, bool create = false) { return dynamic_cast<ConfigOptionString*>(this->option(opt_key, create))->value; }
std::string& opt_string(const t_config_option_key &opt_key, bool create = false) { return this->option<ConfigOptionString>(opt_key, create)->value; }
const std::string& opt_string(const t_config_option_key &opt_key) const { return const_cast<DynamicConfig*>(this)->opt_string(opt_key); }
std::string& opt_string(const t_config_option_key &opt_key, unsigned int idx) { return dynamic_cast<ConfigOptionStrings*>(this->option(opt_key))->get_at(idx); }
std::string& opt_string(const t_config_option_key &opt_key, unsigned int idx) { return this->option<ConfigOptionStrings>(opt_key)->get_at(idx); }
const std::string& opt_string(const t_config_option_key &opt_key, unsigned int idx) const { return const_cast<DynamicConfig*>(this)->opt_string(opt_key, idx); }
double& opt_float(const t_config_option_key &opt_key) { return dynamic_cast<ConfigOptionFloat*>(this->option(opt_key))->value; }
double& opt_float(const t_config_option_key &opt_key) { return this->option<ConfigOptionFloat>(opt_key)->value; }
const double opt_float(const t_config_option_key &opt_key) const { return dynamic_cast<const ConfigOptionFloat*>(this->option(opt_key))->value; }
double& opt_float(const t_config_option_key &opt_key, unsigned int idx) { return dynamic_cast<ConfigOptionFloats*>(this->option(opt_key))->get_at(idx); }
double& opt_float(const t_config_option_key &opt_key, unsigned int idx) { return this->option<ConfigOptionFloats>(opt_key)->get_at(idx); }
const double opt_float(const t_config_option_key &opt_key, unsigned int idx) const { return dynamic_cast<const ConfigOptionFloats*>(this->option(opt_key))->get_at(idx); }
int& opt_int(const t_config_option_key &opt_key) { return dynamic_cast<ConfigOptionInt*>(this->option(opt_key))->value; }
int& opt_int(const t_config_option_key &opt_key) { return this->option<ConfigOptionInt>(opt_key)->value; }
const int opt_int(const t_config_option_key &opt_key) const { return dynamic_cast<const ConfigOptionInt*>(this->option(opt_key))->value; }
int& opt_int(const t_config_option_key &opt_key, unsigned int idx) { return dynamic_cast<ConfigOptionInts*>(this->option(opt_key))->get_at(idx); }
int& opt_int(const t_config_option_key &opt_key, unsigned int idx) { return this->option<ConfigOptionInts>(opt_key)->get_at(idx); }
const int opt_int(const t_config_option_key &opt_key, unsigned int idx) const { return dynamic_cast<const ConfigOptionInts*>(this->option(opt_key))->get_at(idx); }
bool opt_bool(const t_config_option_key &opt_key) const { return dynamic_cast<const ConfigOptionBool*>(this->option(opt_key))->value != 0; }
bool opt_bool(const t_config_option_key &opt_key, unsigned int idx) const { return dynamic_cast<const ConfigOptionBools*>(this->option(opt_key))->get_at(idx) != 0; }
bool opt_bool(const t_config_option_key &opt_key) const { return this->option<ConfigOptionBool>(opt_key)->value != 0; }
bool opt_bool(const t_config_option_key &opt_key, unsigned int idx) const { return this->option<ConfigOptionBools>(opt_key)->get_at(idx) != 0; }
protected:
DynamicConfig() {}

View file

@ -149,7 +149,6 @@ inline Polylines to_polylines(const ExPolygons &src)
return polylines;
}
#if SLIC3R_CPPVER >= 11
inline Polylines to_polylines(ExPolygon &&src)
{
Polylines polylines;
@ -166,6 +165,7 @@ inline Polylines to_polylines(ExPolygon &&src)
assert(idx == polylines.size());
return polylines;
}
inline Polylines to_polylines(ExPolygons &&src)
{
Polylines polylines;
@ -184,7 +184,6 @@ inline Polylines to_polylines(ExPolygons &&src)
assert(idx == polylines.size());
return polylines;
}
#endif
inline Polygons to_polygons(const ExPolygon &src)
{

View file

@ -176,11 +176,7 @@ void Fill3DHoneycomb::_fill_surface_single(
}
}
Polylines chained = PolylineCollection::chained_path_from(
#if SLIC3R_CPPVER >= 11
std::move(polylines),
#else
polylines,
#endif
PolylineCollection::leftmost_point(polylines), false); // reverse allowed
bool first = true;
for (Polylines::iterator it_polyline = chained.begin(); it_polyline != chained.end(); ++ it_polyline) {
@ -199,12 +195,7 @@ void Fill3DHoneycomb::_fill_surface_single(
}
}
// The lines cannot be connected.
#if SLIC3R_CPPVER >= 11
polylines_out.push_back(std::move(*it_polyline));
#else
polylines_out.push_back(Polyline());
std::swap(polylines_out.back(), *it_polyline);
#endif
polylines_out.emplace_back(std::move(*it_polyline));
first = false;
}
}

View file

@ -17,12 +17,7 @@ void FillHoneycomb::_fill_surface_single(
CacheID cache_id(params.density, this->spacing);
Cache::iterator it_m = this->cache.find(cache_id);
if (it_m == this->cache.end()) {
#if 0
// #if SLIC3R_CPPVER > 11
it_m = this->cache.emplace_hint(it_m);
#else
it_m = this->cache.insert(it_m, std::pair<CacheID, CacheData>(cache_id, CacheData()));
#endif
CacheData &m = it_m->second;
coord_t min_spacing = scale_(this->spacing);
m.distance = min_spacing / params.density;
@ -99,11 +94,7 @@ void FillHoneycomb::_fill_surface_single(
// connect paths
if (! paths.empty()) { // prevent calling leftmost_point() on empty collections
Polylines chained = PolylineCollection::chained_path_from(
#if SLIC3R_CPPVER >= 11
std::move(paths),
#else
paths,
#endif
PolylineCollection::leftmost_point(paths), false);
assert(paths.empty());
paths.clear();

View file

@ -93,11 +93,7 @@ void FillRectilinear::_fill_surface_single(
}
}
Polylines chained = PolylineCollection::chained_path_from(
#if SLIC3R_CPPVER >= 11
std::move(polylines),
#else
polylines,
#endif
PolylineCollection::leftmost_point(polylines), false); // reverse allowed
bool first = true;
for (Polylines::iterator it_polyline = chained.begin(); it_polyline != chained.end(); ++ it_polyline) {
@ -118,12 +114,7 @@ void FillRectilinear::_fill_surface_single(
}
}
// The lines cannot be connected.
#if SLIC3R_CPPVER >= 11
polylines_out.push_back(std::move(*it_polyline));
#else
polylines_out.push_back(Polyline());
std::swap(polylines_out.back(), *it_polyline);
#endif
polylines_out.emplace_back(std::move(*it_polyline));
first = false;
}
}

View file

@ -8,39 +8,6 @@ namespace Slic3r {
// This static method returns a sane extrusion width default.
static inline float auto_extrusion_width(FlowRole role, float nozzle_diameter, float height)
{
#if 0
// Here we calculate a sane default by matching the flow speed (at the nozzle) and the feed rate.
// shape: rectangle with semicircles at the ends
// This "sane" extrusion width gives the following results for a 0.4mm dmr nozzle:
// Layer Calculated Calculated width
// heigh extrusion over nozzle
// width diameter
// 0.40 0.40 1.00
// 0.35 0.43 1.09
// 0.30 0.48 1.21
// 0.25 0.56 1.39
// 0.20 0.67 1.68
// 0.15 0.87 2.17
// 0.10 1.28 3.20
// 0.05 2.52 6.31
//
float width = float(0.25 * (nozzle_diameter * nozzle_diameter) * PI / height + height * (1.0 - 0.25 * PI));
switch (role) {
case frExternalPerimeter:
case frSupportMaterial:
case frSupportMaterialInterface:
return nozzle_diameter;
case frPerimeter:
case frSolidInfill:
case frTopSolidInfill:
// do not limit width for sparse infill so that we use full native flow for it
return std::min(std::max(width, nozzle_diameter * 1.05f), nozzle_diameter * 1.7f);
case frInfill:
default:
return std::max(width, nozzle_diameter * 1.05f);
}
#else
switch (role) {
case frSupportMaterial:
case frSupportMaterialInterface:
@ -53,7 +20,6 @@ static inline float auto_extrusion_width(FlowRole role, float nozzle_diameter, f
case frInfill:
return 1.125f * nozzle_diameter;
}
#endif
}
// This constructor builds a Flow object from an extrusion width config setting

View file

@ -154,7 +154,6 @@ inline Polylines to_polylines(const Polygons &polys)
return polylines;
}
#if SLIC3R_CPPVER >= 11
inline Polylines to_polylines(Polygons &&polys)
{
Polylines polylines;
@ -168,7 +167,6 @@ inline Polylines to_polylines(Polygons &&polys)
assert(idx == polylines.size());
return polylines;
}
#endif
} // Slic3r