From 1fbbaaae9bf2cdbd56ada1a0def59d1f691c1c2d Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 7 Mar 2023 12:30:23 +0100 Subject: [PATCH] Fixed several warnings --- src/libslic3r/Config.hpp | 12 +++---- src/libslic3r/GCode/WipeTower.cpp | 6 ++-- src/libslic3r/Geometry/MedialAxis.cpp | 4 ++- src/libslic3r/LayerRegion.cpp | 2 +- src/libslic3r/Model.cpp | 1 - src/libslic3r/PrintObject.cpp | 2 +- src/libslic3r/SLAPrint.cpp | 2 +- src/libslic3r/SLAPrintSteps.cpp | 2 +- src/libslic3r/TriangleMesh.cpp | 2 +- src/libslic3r/TriangleMeshSlicer.cpp | 6 +++- src/slic3r/GUI/Field.cpp | 16 ++++----- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 50 --------------------------- src/slic3r/GUI/PrintHostDialogs.cpp | 2 +- src/slic3r/Utils/Bonjour.cpp | 2 +- src/slic3r/Utils/TCPConsole.cpp | 8 ++--- 15 files changed, 36 insertions(+), 81 deletions(-) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index a1013f1fc..538580d50 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -1736,7 +1736,7 @@ private: void set_values(const std::initializer_list il) { m_values.clear(); m_values.reserve(il.size()); - for (const std::string_view p : il) + for (const std::string_view& p : il) m_values.emplace_back(p); assert(m_labels.empty() || m_labels.size() == m_values.size()); } @@ -1745,7 +1745,7 @@ private: m_values.reserve(il.size()); m_labels.clear(); m_labels.reserve(il.size()); - for (const std::pair p : il) { + for (const std::pair& p : il) { m_values.emplace_back(p.first); m_labels.emplace_back(p.second); } @@ -1753,7 +1753,7 @@ private: void set_labels(const std::initializer_list il) { m_labels.clear(); m_labels.reserve(il.size()); - for (const std::string_view p : il) + for (const std::string_view& p : il) m_labels.emplace_back(p); assert(m_values.empty() || m_labels.size() == m_values.size()); } @@ -1762,9 +1762,9 @@ private: // Check whether def.enum_values contains all the values of def.enum_keys_map and // that they are sorted by their ordinary values. m_values_ordinary = true; - for (const std::pair& key : *m_enum_keys_map) { - assert(key.second >= 0); - if (key.second >= this->values().size() || this->value(key.second) != key.first) { + for (const auto& [enum_name, enum_int] : *m_enum_keys_map) { + assert(enum_int >= 0); + if (enum_int >= int(this->values().size()) || this->value(enum_int) != enum_name) { m_values_ordinary = false; break; } diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 237ec3604..4f4871366 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -929,7 +929,7 @@ void WipeTower::toolchange_Unload( writer.retract(-m_cooling_tube_length/2.f+m_parking_pos_retraction-m_cooling_tube_retraction, 2000); } - // this is to align ramming and future wiping extrusions, so the future y-steps can be uniform from the start: + // this is to align ramming and future wiping extrusions, so the future y-steps can be uniform from the start: // the perimeter_width will later be subtracted, it is there to not load while moving over just extruded material Vec2f pos = Vec2f(end_of_ramming.x(), end_of_ramming.y() + (y_step/m_extra_spacing-m_perimeter_width) / 2.f + m_perimeter_width); if (m_semm) @@ -937,8 +937,8 @@ void WipeTower::toolchange_Unload( else writer.set_position(pos); - writer.resume_preview() - .flush_planner_queue(); + writer.resume_preview() + .flush_planner_queue(); } // Change the tool, set a speed override for soluble and flex materials. diff --git a/src/libslic3r/Geometry/MedialAxis.cpp b/src/libslic3r/Geometry/MedialAxis.cpp index 39677c928..0f9d81da6 100644 --- a/src/libslic3r/Geometry/MedialAxis.cpp +++ b/src/libslic3r/Geometry/MedialAxis.cpp @@ -444,7 +444,9 @@ private: MedialAxis::MedialAxis(double min_width, double max_width, const ExPolygon &expolygon) : m_expolygon(expolygon), m_lines(expolygon.lines()), m_min_width(min_width), m_max_width(max_width) -{} +{ + (void)m_expolygon; // supress unused variable warning +} void MedialAxis::build(ThickPolylines* polylines) { diff --git a/src/libslic3r/LayerRegion.cpp b/src/libslic3r/LayerRegion.cpp index 0adc8f4cf..6017f393e 100644 --- a/src/libslic3r/LayerRegion.cpp +++ b/src/libslic3r/LayerRegion.cpp @@ -356,7 +356,7 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly shell_width += perimeter_flow.scaled_spacing() * (num_perimeters - 1); } else { // TODO: Maybe there is better solution when printing with zero perimeters, but this works reasonably well, given the situation - shell_width = SCALED_EPSILON; + shell_width = float(SCALED_EPSILON); } // Scaled expansions of the respective external surfaces. diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 6024cd775..c21f6bd2b 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -889,7 +889,6 @@ const BoundingBoxf3& ModelObject::bounding_box_exact() const if (! m_bounding_box_exact_valid) { m_bounding_box_exact_valid = true; m_min_max_z_valid = true; - BoundingBoxf3 raw_bbox = this->raw_mesh_bounding_box(); m_bounding_box_exact.reset(); for (size_t i = 0; i < this->instances.size(); ++ i) m_bounding_box_exact.merge(this->instance_bounding_box(i)); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 005309e7c..b9552a2ef 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1774,7 +1774,7 @@ void PrintObject::bridge_over_infill() Polygons infill_region = to_polygons(r->fill_expolygons()); Polygons deep_infill_area = closing(infill_region, scale_(0.01), scale_(0.01) + 4.0 * flow.scaled_spacing()); Polygons solid_supported_area = expand(not_sparse_infill, 4.0 * flow.scaled_spacing()); - infill_and_deep_infill_polygons_per_region[r] = {closing(infill_region, scale_(0.1)), + infill_and_deep_infill_polygons_per_region[r] = {closing(infill_region, float(scale_(0.1))), intersection(lower_layers_sparse_infill, diff(deep_infill_area, solid_supported_area))}; } diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index abf8b5216..202da5e00 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -1077,7 +1077,7 @@ SLAPrintObject::get_parts_to_slice(SLAPrintObjectStep untilstep) const std::vector ret; - for (int step = 0; step < s; ++step) { + for (unsigned int step = 0; step < s; ++step) { auto r = m_mesh_to_slice.equal_range(SLAPrintObjectStep(step)); csg::copy_csgrange_shallow(Range{r.first, r.second}, std::back_inserter(ret)); } diff --git a/src/libslic3r/SLAPrintSteps.cpp b/src/libslic3r/SLAPrintSteps.cpp index 92260deec..338130454 100644 --- a/src/libslic3r/SLAPrintSteps.cpp +++ b/src/libslic3r/SLAPrintSteps.cpp @@ -180,7 +180,7 @@ indexed_triangle_set SLAPrint::Steps::generate_preview_vdb( auto r = range(po.m_mesh_to_slice); auto grid = csg::voxelize_csgmesh(r, voxparams); auto m = grid ? grid_to_mesh(*grid, 0., 0.01) : indexed_triangle_set{}; - float loss_less_max_error = 1e-6; + float loss_less_max_error = float(1e-6); its_quadric_edge_collapse(m, 0U, &loss_less_max_error); return m; diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index 4d9dff345..d35251d20 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -1114,7 +1114,7 @@ indexed_triangle_set its_make_sphere(double radius, double fa) std::vector> divided_triangles(indices.size()); std::vector new_neighbors(4*indices.size()); - size_t orig_indices_size = indices.size(); + int orig_indices_size = int(indices.size()); for (int i=0; i(window, m_opt.type) ) - // on_kill_focus() cause a call of OptionsGroup::reload_config(), - // Thus, do it only when it's really needed (when undefined value was input) + if (!is_defined_input_value(window, m_opt.type) ) + // on_kill_focus() cause a call of OptionsGroup::reload_config(), + // Thus, do it only when it's really needed (when undefined value was input) on_kill_focus(); - else if (value_was_changed()) + else if (value_was_changed()) on_change_field(); } @@ -931,8 +931,8 @@ boost::any& SpinCtrl::get_value() if (spin->GetTextValue() == na_value(true)) return m_value; - int value = spin->GetValue(); - return m_value = value; + int value = spin->GetValue(); + return m_value = value; } void SpinCtrl::propagate_value() @@ -946,7 +946,7 @@ void SpinCtrl::propagate_value() if (tmp_value == UNDEF_VALUE) { on_kill_focus(); - } else { + } else { #ifdef __WXOSX__ // check input value for minimum if (m_opt.min > 0 && tmp_value < m_opt.min) { @@ -1152,7 +1152,7 @@ void Choice::set_value(const std::string& value, bool change_event) //! Redunda field->SetSelection(*opt); else field->SetValue(value); - m_disable_change_event = false; + m_disable_change_event = false; } void Choice::set_value(const boost::any& value, bool change_event) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 820e35a37..3ba67e60e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -64,26 +64,6 @@ static GLModel::Geometry its_make_line(Vec3f beg_pos, Vec3f end_pos) return init_data; } -// Generates mesh for a square plane -static GLModel::Geometry its_make_square_plane(float radius) -{ - GLModel::Geometry init_data; - init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3 }; - init_data.reserve_vertices(4); - init_data.reserve_indices(6); - - // vertices - init_data.add_vertex(Vec3f(-radius, -radius, 0.0)); - init_data.add_vertex(Vec3f(radius , -radius, 0.0)); - init_data.add_vertex(Vec3f(radius , radius , 0.0)); - init_data.add_vertex(Vec3f(-radius, radius , 0.0)); - - // indices - init_data.add_triangle(0, 1, 2); - init_data.add_triangle(2, 3, 0); - return init_data; -} - //! -- #ysFIXME those functions bodies are ported from GizmoRotation // Generates mesh for a circle static void init_from_circle(GLModel& model, double radius) @@ -627,36 +607,6 @@ bool GLGizmoCut3D::render_reset_button(const std::string& label_id, const std::s return revert; } -static Vec2d ndc_to_ss(const Vec3d& ndc, const std::array& viewport) { - const double half_w = 0.5 * double(viewport[2]); - const double half_h = 0.5 * double(viewport[3]); - return { half_w * ndc.x() + double(viewport[0]) + half_w, half_h * ndc.y() + double(viewport[1]) + half_h }; -}; -static Vec3d clip_to_ndc(const Vec4d& clip) { - return Vec3d(clip.x(), clip.y(), clip.z()) / clip.w(); -} -static Vec4d world_to_clip(const Vec3d& world, const Matrix4d& projection_view_matrix) { - return projection_view_matrix * Vec4d(world.x(), world.y(), world.z(), 1.0); -} -static Vec2d world_to_ss(const Vec3d& world, const Matrix4d& projection_view_matrix, const std::array& viewport) { - return ndc_to_ss(clip_to_ndc(world_to_clip(world, projection_view_matrix)), viewport); -} - -static wxString get_label(Vec3d vec) -{ - wxString str = "x=" + double_to_string(vec.x(), 2) + - ", y=" + double_to_string(vec.y(), 2) + - ", z=" + double_to_string(vec.z(), 2); - return str; -} - -static wxString get_label(Vec2d vec) -{ - wxString str = "x=" + double_to_string(vec.x(), 2) + - ", y=" + double_to_string(vec.y(), 2); - return str; -} - void GLGizmoCut3D::render_cut_plane() { if (cut_line_processing()) diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index 982fe99a7..f986a1552 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -197,7 +197,7 @@ std::string PrintHostSendDialog::storage() const { if (!combo_storage) return GUI::format("%1%", m_preselected_storage); - if (combo_storage->GetSelection() < 0 || combo_storage->GetSelection() >= m_paths.size()) + if (combo_storage->GetSelection() < 0 || combo_storage->GetSelection() >= int(m_paths.size())) return {}; return boost::nowide::narrow(m_paths[combo_storage->GetSelection()]); } diff --git a/src/slic3r/Utils/Bonjour.cpp b/src/slic3r/Utils/Bonjour.cpp index e35708381..0701695ef 100644 --- a/src/slic3r/Utils/Bonjour.cpp +++ b/src/slic3r/Utils/Bonjour.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include using boost::optional; using boost::system::error_code; diff --git a/src/slic3r/Utils/TCPConsole.cpp b/src/slic3r/Utils/TCPConsole.cpp index 3c943cc63..277e3c0d5 100644 --- a/src/slic3r/Utils/TCPConsole.cpp +++ b/src/slic3r/Utils/TCPConsole.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ void TCPConsole::transmit_next_command() boost::asio::async_write( m_socket, boost::asio::buffer(m_send_buffer), - boost::bind(&TCPConsole::handle_write, this, _1, _2) + boost::bind(&TCPConsole::handle_write, this, boost::placeholders::_1, boost::placeholders::_2) ); } @@ -52,7 +52,7 @@ void TCPConsole::wait_next_line() m_socket, m_recv_buffer, m_newline, - boost::bind(&TCPConsole::handle_read, this, _1, _2) + boost::bind(&TCPConsole::handle_read, this, boost::placeholders::_1, boost::placeholders::_2) ); } @@ -157,7 +157,7 @@ bool TCPConsole::run_queue() auto endpoints = m_resolver.resolve(m_host_name, m_port_name); m_socket.async_connect(endpoints->endpoint(), - boost::bind(&TCPConsole::handle_connect, this, _1) + boost::bind(&TCPConsole::handle_connect, this, boost::placeholders::_1) ); // Loop until we get any reasonable result. Negative result is also result.