Merge branch 'lm_improvements'

This commit is contained in:
Lukas Matena 2022-03-31 16:45:54 +02:00
commit ad610ffe2b
20 changed files with 36 additions and 37 deletions

View File

@ -552,7 +552,7 @@ static CircleBed to_circle(const Point &center, const Points& points) {
std::vector<double> vertex_distances; std::vector<double> vertex_distances;
double avg_dist = 0; double avg_dist = 0;
for (auto pt : points) for (const Point& pt : points)
{ {
double distance = distance_to(center, pt); double distance = distance_to(center, pt);
vertex_distances.push_back(distance); vertex_distances.push_back(distance);

View File

@ -306,7 +306,7 @@ ConfigOptionDef* ConfigDef::add_nullable(const t_config_option_key &opt_key, Con
std::ostream& ConfigDef::print_cli_help(std::ostream& out, bool show_defaults, std::function<bool(const ConfigOptionDef &)> filter) const std::ostream& ConfigDef::print_cli_help(std::ostream& out, bool show_defaults, std::function<bool(const ConfigOptionDef &)> filter) const
{ {
// prepare a function for wrapping text // prepare a function for wrapping text
auto wrap = [](std::string text, size_t line_length) -> std::string { auto wrap = [](const std::string& text, size_t line_length) -> std::string {
std::istringstream words(text); std::istringstream words(text);
std::ostringstream wrapped; std::ostringstream wrapped;
std::string word; std::string word;
@ -335,7 +335,7 @@ std::ostream& ConfigDef::print_cli_help(std::ostream& out, bool show_defaults, s
categories.insert(def.category); categories.insert(def.category);
} }
for (auto category : categories) { for (const std::string& category : categories) {
if (category != "") { if (category != "") {
out << category << ":" << std::endl; out << category << ":" << std::endl;
} else if (categories.size() > 1) { } else if (categories.size() > 1) {

View File

@ -41,7 +41,7 @@ extern void check_mode_for_custom_gcode_per_print_z(Info& info)
return; return;
bool is_single_extruder = true; bool is_single_extruder = true;
for (auto item : info.gcodes) for (const Item& item : info.gcodes)
{ {
if (item.type == ToolChange) { if (item.type == ToolChange) {
info.mode = MultiAsSingle; info.mode = MultiAsSingle;

View File

@ -169,10 +169,10 @@ inline Polylines to_polylines(ExPolygon &&src)
Polyline &pl = polylines[idx ++]; Polyline &pl = polylines[idx ++];
pl.points = std::move(src.contour.points); pl.points = std::move(src.contour.points);
pl.points.push_back(pl.points.front()); pl.points.push_back(pl.points.front());
for (Polygons::const_iterator ith = src.holes.begin(); ith != src.holes.end(); ++ith) { for (auto ith = src.holes.begin(); ith != src.holes.end(); ++ith) {
Polyline &pl = polylines[idx ++]; Polyline &pl = polylines[idx ++];
pl.points = std::move(ith->points); pl.points = std::move(ith->points);
pl.points.push_back(ith->points.front()); pl.points.push_back(p1.points.front());
} }
assert(idx == polylines.size()); assert(idx == polylines.size());
return polylines; return polylines;
@ -183,14 +183,14 @@ inline Polylines to_polylines(ExPolygons &&src)
Polylines polylines; Polylines polylines;
polylines.assign(number_polygons(src), Polyline()); polylines.assign(number_polygons(src), Polyline());
size_t idx = 0; size_t idx = 0;
for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++it) { for (auto it = src.begin(); it != src.end(); ++it) {
Polyline &pl = polylines[idx ++]; Polyline &pl = polylines[idx ++];
pl.points = std::move(it->contour.points); pl.points = std::move(it->contour.points);
pl.points.push_back(pl.points.front()); pl.points.push_back(pl.points.front());
for (Polygons::const_iterator ith = it->holes.begin(); ith != it->holes.end(); ++ith) { for (auto ith = it->holes.begin(); ith != it->holes.end(); ++ith) {
Polyline &pl = polylines[idx ++]; Polyline &pl = polylines[idx ++];
pl.points = std::move(ith->points); pl.points = std::move(ith->points);
pl.points.push_back(ith->points.front()); pl.points.push_back(pl.points.front());
} }
} }
assert(idx == polylines.size()); assert(idx == polylines.size());

View File

@ -242,7 +242,7 @@ public:
ExtrusionLoop(ExtrusionPaths &&paths, ExtrusionLoopRole role = elrDefault) : paths(std::move(paths)), m_loop_role(role) {} ExtrusionLoop(ExtrusionPaths &&paths, ExtrusionLoopRole role = elrDefault) : paths(std::move(paths)), m_loop_role(role) {}
ExtrusionLoop(const ExtrusionPath &path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role) ExtrusionLoop(const ExtrusionPath &path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role)
{ this->paths.push_back(path); } { this->paths.push_back(path); }
ExtrusionLoop(const ExtrusionPath &&path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role) ExtrusionLoop(ExtrusionPath &&path, ExtrusionLoopRole role = elrDefault) : m_loop_role(role)
{ this->paths.emplace_back(std::move(path)); } { this->paths.emplace_back(std::move(path)); }
bool is_loop() const override{ return true; } bool is_loop() const override{ return true; }
bool can_reverse() const override { return false; } bool can_reverse() const override { return false; }

View File

@ -125,7 +125,7 @@ protected:
unsigned int /* thickness_layers */, unsigned int /* thickness_layers */,
const std::pair<float, Point> & /* direction */, const std::pair<float, Point> & /* direction */,
ExPolygon /* expolygon */, ExPolygon /* expolygon */,
Polylines & /* polylines_out */) {}; Polylines & /* polylines_out */) {}
virtual float _layer_angle(size_t idx) const { return (idx & 1) ? float(M_PI/2.) : 0; } virtual float _layer_angle(size_t idx) const { return (idx & 1) ? float(M_PI/2.) : 0; }

View File

@ -18,7 +18,7 @@ class PrintObject;
namespace FillAdaptive { namespace FillAdaptive {
struct Octree; struct Octree;
}; }
namespace FillLightning { namespace FillLightning {
class Generator; class Generator;

View File

@ -903,7 +903,7 @@ indexed_triangle_set ModelObject::raw_indexed_triangle_set() const
size_t j = out.indices.size(); size_t j = out.indices.size();
append(out.vertices, v->mesh().its.vertices); append(out.vertices, v->mesh().its.vertices);
append(out.indices, v->mesh().its.indices); append(out.indices, v->mesh().its.indices);
auto m = v->get_matrix(); const Transform3d& m = v->get_matrix();
for (; i < out.vertices.size(); ++ i) for (; i < out.vertices.size(); ++ i)
out.vertices[i] = (m * out.vertices[i].cast<double>()).cast<float>().eval(); out.vertices[i] = (m * out.vertices[i].cast<double>()).cast<float>().eval();
if (v->is_left_handed()) { if (v->is_left_handed()) {

View File

@ -817,7 +817,7 @@ private:
this->set_material_id(other.material_id()); this->set_material_id(other.material_id());
} }
// Providing a new mesh, therefore this volume will get a new unique ID assigned. // Providing a new mesh, therefore this volume will get a new unique ID assigned.
ModelVolume(ModelObject *object, const ModelVolume &other, const TriangleMesh &&mesh) : ModelVolume(ModelObject *object, const ModelVolume &other, TriangleMesh &&mesh) :
name(other.name), source(other.source), m_mesh(new TriangleMesh(std::move(mesh))), config(other.config), m_type(other.m_type), object(object), m_transformation(other.m_transformation) name(other.name), source(other.source), m_mesh(new TriangleMesh(std::move(mesh))), config(other.config), m_type(other.m_type), object(object), m_transformation(other.m_transformation)
{ {
assert(this->id().valid()); assert(this->id().valid());

View File

@ -220,10 +220,10 @@ inline Polylines to_polylines(Polygons &&polys)
Polylines polylines; Polylines polylines;
polylines.assign(polys.size(), Polyline()); polylines.assign(polys.size(), Polyline());
size_t idx = 0; size_t idx = 0;
for (Polygons::const_iterator it = polys.begin(); it != polys.end(); ++ it) { for (auto it = polys.begin(); it != polys.end(); ++ it) {
Polyline &pl = polylines[idx ++]; Polyline &pl = polylines[idx ++];
pl.points = std::move(it->points); pl.points = std::move(it->points);
pl.points.push_back(it->points.front()); pl.points.push_back(pl.points.front());
} }
assert(idx == polylines.size()); assert(idx == polylines.size());
return polylines; return polylines;
@ -242,7 +242,7 @@ inline Polygons to_polygons(std::vector<Points> &&paths)
{ {
Polygons out; Polygons out;
out.reserve(paths.size()); out.reserve(paths.size());
for (const Points &path : paths) for (Points &path : paths)
out.emplace_back(std::move(path)); out.emplace_back(std::move(path));
return out; return out;
} }

View File

@ -139,7 +139,7 @@ inline Polylines to_polylines(std::vector<Points> &&paths)
{ {
Polylines out; Polylines out;
out.reserve(paths.size()); out.reserve(paths.size());
for (const Points &path : paths) for (Points &path : paths)
out.emplace_back(std::move(path)); out.emplace_back(std::move(path));
return out; return out;
} }

View File

@ -1498,7 +1498,7 @@ void PhysicalPrinter::update_preset_names_in_config()
if (!preset_names.empty()) { if (!preset_names.empty()) {
std::vector<std::string>& values = config.option<ConfigOptionStrings>("preset_names")->values; std::vector<std::string>& values = config.option<ConfigOptionStrings>("preset_names")->values;
values.clear(); values.clear();
for (auto preset : preset_names) for (const std::string& preset : preset_names)
values.push_back(preset); values.push_back(preset);
// temporary workaround for compatibility with older Slicer // temporary workaround for compatibility with older Slicer
@ -1571,7 +1571,7 @@ void PhysicalPrinter::set_name(const std::string& name)
this->name = name; this->name = name;
} }
std::string PhysicalPrinter::get_full_name(std::string preset_name) const std::string PhysicalPrinter::get_full_name(const std::string& preset_name) const
{ {
return name + separator() + preset_name; return name + separator() + preset_name;
} }
@ -1888,7 +1888,7 @@ std::vector<std::string> PhysicalPrinterCollection::get_printers_with_only_prese
{ {
std::vector<std::string> printers; std::vector<std::string> printers;
for (auto printer : m_printers) for (const PhysicalPrinter& printer : m_printers)
if (printer.preset_names.size() == 1 && *printer.preset_names.begin() == preset_name) if (printer.preset_names.size() == 1 && *printer.preset_names.begin() == preset_name)
printers.emplace_back(printer.name); printers.emplace_back(printer.name);

View File

@ -675,7 +675,7 @@ public:
bool operator<(const PhysicalPrinter& other) const { return this->name < other.name; } bool operator<(const PhysicalPrinter& other) const { return this->name < other.name; }
// get full printer name included a name of the preset // get full printer name included a name of the preset
std::string get_full_name(std::string preset_name) const; std::string get_full_name(const std::string &preset_name) const;
// get printer name from the full name uncluded preset name // get printer name from the full name uncluded preset name
static std::string get_short_name(std::string full_name); static std::string get_short_name(std::string full_name);

View File

@ -267,7 +267,7 @@ PresetsConfigSubstitutions PresetBundle::load_presets(AppConfig &config, Forward
std::string errors_cummulative; std::string errors_cummulative;
std::tie(substitutions, errors_cummulative) = this->load_system_presets(substitution_rule); std::tie(substitutions, errors_cummulative) = this->load_system_presets(substitution_rule);
const std::string dir_user_presets = data_dir() const std::string& dir_user_presets = data_dir()
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR #ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
// Store the print/filament/printer presets into a "presets" directory. // Store the print/filament/printer presets into a "presets" directory.
+ "/presets" + "/presets"

View File

@ -885,9 +885,9 @@ std::string Print::export_gcode(const std::string& path_template, GCodeProcessor
message = L("Generating G-code"); message = L("Generating G-code");
this->set_status(90, message); this->set_status(90, message);
// The following line may die for multiple reasons. // Create GCode on heap, it has quite a lot of data.
GCode gcode; std::unique_ptr<GCode> gcode(new GCode);
gcode.do_export(this, path.c_str(), result, thumbnail_cb); gcode->do_export(this, path.c_str(), result, thumbnail_cb);
return path.c_str(); return path.c_str();
} }

View File

@ -58,11 +58,11 @@ public:
thickness(rhs.thickness), thickness_layers(rhs.thickness_layers), thickness(rhs.thickness), thickness_layers(rhs.thickness_layers),
bridge_angle(rhs.bridge_angle), extra_perimeters(rhs.extra_perimeters) bridge_angle(rhs.bridge_angle), extra_perimeters(rhs.extra_perimeters)
{}; {};
Surface(SurfaceType _surface_type, const ExPolygon &&_expolygon) Surface(SurfaceType _surface_type, ExPolygon &&_expolygon)
: surface_type(_surface_type), expolygon(std::move(_expolygon)), : surface_type(_surface_type), expolygon(std::move(_expolygon)),
thickness(-1), thickness_layers(1), bridge_angle(-1), extra_perimeters(0) thickness(-1), thickness_layers(1), bridge_angle(-1), extra_perimeters(0)
{}; {};
Surface(const Surface &other, const ExPolygon &&_expolygon) Surface(const Surface &other, ExPolygon &&_expolygon)
: surface_type(other.surface_type), expolygon(std::move(_expolygon)), : surface_type(other.surface_type), expolygon(std::move(_expolygon)),
thickness(other.thickness), thickness_layers(other.thickness_layers), thickness(other.thickness), thickness_layers(other.thickness_layers),
bridge_angle(other.bridge_angle), extra_perimeters(other.extra_perimeters) bridge_angle(other.bridge_angle), extra_perimeters(other.extra_perimeters)
@ -159,7 +159,7 @@ inline ExPolygons to_expolygons(Surfaces &&src)
{ {
ExPolygons expolygons; ExPolygons expolygons;
expolygons.reserve(src.size()); expolygons.reserve(src.size());
for (Surfaces::const_iterator it = src.begin(); it != src.end(); ++it) for (auto it = src.begin(); it != src.end(); ++it)
expolygons.emplace_back(ExPolygon(std::move(it->expolygon))); expolygons.emplace_back(ExPolygon(std::move(it->expolygon)));
src.clear(); src.clear();
return expolygons; return expolygons;
@ -260,8 +260,8 @@ inline void surfaces_append(Surfaces &dst, ExPolygons &&src, SurfaceType surface
inline void surfaces_append(Surfaces &dst, ExPolygons &&src, const Surface &surfaceTempl) inline void surfaces_append(Surfaces &dst, ExPolygons &&src, const Surface &surfaceTempl)
{ {
dst.reserve(dst.size() + number_polygons(src)); dst.reserve(dst.size() + number_polygons(src));
for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it) for (ExPolygon& explg : src)
dst.emplace_back(Surface(surfaceTempl, std::move(*it))); dst.emplace_back(Surface(surfaceTempl, std::move(explg)));
src.clear(); src.clear();
} }

View File

@ -962,8 +962,10 @@ std::string string_printf(const char *format, ...)
::vsnprintf(buffer.data(), buffer.size(), format, args2); ::vsnprintf(buffer.data(), buffer.size(), format, args2);
} }
buffer.resize(bufflen); va_end(args1);
va_end(args2);
buffer.resize(bufflen);
return buffer; return buffer;
} }

View File

@ -1084,7 +1084,7 @@ void Control::Ruler::update(const std::vector<double>& values, double scroll_ste
{ {
if (!m_parent || values.empty() || if (!m_parent || values.empty() ||
// check if need to update ruler in respect to input values // check if need to update ruler in respect to input values
values.front() == m_min_val && values.back() == m_max_val && m_scroll_step == scroll_step && max_values.size() == m_max_values_cnt) (values.front() == m_min_val && values.back() == m_max_val && m_scroll_step == scroll_step && max_values.size() == m_max_values_cnt))
return; return;
m_min_val = values.front(); m_min_val = values.front();

View File

@ -530,9 +530,6 @@ wxExecuteEnv get_appimage_exec_env()
} // namespace } // namespace
void desktop_execute(const char* argv[]) void desktop_execute(const char* argv[])
{ {
if (sizeof(argv) == 0)
return;
// Check if we're running in an AppImage container, if so, we need to remove AppImage's env vars, // Check if we're running in an AppImage container, if so, we need to remove AppImage's env vars,
// because they may mess up the environment expected by the file manager. // because they may mess up the environment expected by the file manager.
// Mostly this is about LD_LIBRARY_PATH, but we remove a few more too for good measure. // Mostly this is about LD_LIBRARY_PATH, but we remove a few more too for good measure.

View File

@ -207,7 +207,7 @@ bool AppUpdateDownloadDialog::run_after_download() const
boost::filesystem::path AppUpdateDownloadDialog::get_download_path() const boost::filesystem::path AppUpdateDownloadDialog::get_download_path() const
{ {
return std::move(boost::filesystem::path(txtctrl_path->GetValue().ToUTF8().data())); return boost::filesystem::path(txtctrl_path->GetValue().ToUTF8().data());
} }
// MsgUpdateConfig // MsgUpdateConfig