From 5e9a8ea70053e89690bb9a7b304bc7d5f8a2ce38 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Tue, 9 Feb 2021 19:23:58 +0100 Subject: [PATCH] Fixed some clang warnings --- src/libslic3r/Brim.cpp | 2 +- src/libslic3r/Config.hpp | 1 + src/libslic3r/ElephantFootCompensation.cpp | 2 ++ src/libslic3r/Fill/FillBase.cpp | 2 ++ src/libslic3r/Fill/FillRectilinear.cpp | 16 ++++++++-------- src/libslic3r/Format/3mf.cpp | 2 +- src/libslic3r/GCode.cpp | 2 ++ src/libslic3r/ShortestPath.cpp | 9 +++++++-- src/libslic3r/SlicingAdaptive.cpp | 2 +- src/libslic3r/SupportMaterial.cpp | 2 +- src/libslic3r/TriangleMesh.cpp | 3 ++- src/slic3r/GUI/GCodeViewer.cpp | 2 +- src/slic3r/GUI/GLCanvas3D.cpp | 20 ++++++++++---------- src/slic3r/GUI/GLCanvas3D.hpp | 3 +-- src/slic3r/GUI/RemovableDriveManager.cpp | 2 ++ src/slic3r/Utils/RetinaHelper.hpp | 2 ++ src/slic3r/Utils/RetinaHelperImpl.mm | 3 +-- 17 files changed, 45 insertions(+), 30 deletions(-) diff --git a/src/libslic3r/Brim.cpp b/src/libslic3r/Brim.cpp index 78a6bad70..e3ffda122 100644 --- a/src/libslic3r/Brim.cpp +++ b/src/libslic3r/Brim.cpp @@ -301,7 +301,7 @@ static Polylines connect_brim_lines(Polylines &&polylines, const Polygons &brim_ polylines.erase(polylines.begin() + end, polylines.end()); } - return polylines; + return std::move(polylines); } static void make_inner_brim(const Print &print, const ConstPrintObjectPtrs &top_level_objects_with_brim, ExtrusionEntityCollection &brim) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index 5e4b2ed6a..1420ee39e 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -1695,6 +1695,7 @@ public: // Static configuration definition. Any value stored into this ConfigBase shall have its definition here. virtual const ConfigDef* def() const = 0; // Find ando/or create a ConfigOption instance for a given name. + using ConfigOptionResolver::optptr; virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) = 0; // Collect names of all configuration values maintained by this configuration store. virtual t_config_option_keys keys() const = 0; diff --git a/src/libslic3r/ElephantFootCompensation.cpp b/src/libslic3r/ElephantFootCompensation.cpp index 9610582f7..f28d88f7e 100644 --- a/src/libslic3r/ElephantFootCompensation.cpp +++ b/src/libslic3r/ElephantFootCompensation.cpp @@ -445,6 +445,7 @@ Points resample_polygon(const Points &contour, double dist, std::vector &compensation, float strength, size_t num_iterations) { std::vector out(compensation); @@ -459,6 +460,7 @@ static inline void smooth_compensation(std::vector &compensation, float s out.swap(compensation); } } +#endif static inline void smooth_compensation_banded(const Points &contour, float band, std::vector &compensation, float strength, size_t num_iterations) { diff --git a/src/libslic3r/Fill/FillBase.cpp b/src/libslic3r/Fill/FillBase.cpp index 6ebc6023c..a6501accc 100644 --- a/src/libslic3r/Fill/FillBase.cpp +++ b/src/libslic3r/Fill/FillBase.cpp @@ -690,6 +690,7 @@ static inline bool interval_inside_interval(double outer_low, double outer_high, return inside_interval(outer_low, outer_high, inner_low) && inside_interval(outer_low, outer_high, inner_high); } +#if 0 static inline bool cyclic_interval_inside_interval(double outer_low, double outer_high, double inner_low, double inner_high, double length) { if (outer_low > outer_high) @@ -702,6 +703,7 @@ static inline bool cyclic_interval_inside_interval(double outer_low, double oute } return interval_inside_interval(outer_low, outer_high, inner_low, inner_high, double(SCALED_EPSILON)); } +#endif // #define INFILL_DEBUG_OUTPUT diff --git a/src/libslic3r/Fill/FillRectilinear.cpp b/src/libslic3r/Fill/FillRectilinear.cpp index d6e400837..668d9a6eb 100644 --- a/src/libslic3r/Fill/FillRectilinear.cpp +++ b/src/libslic3r/Fill/FillRectilinear.cpp @@ -2245,22 +2245,22 @@ static std::vector chain_monotonic_regions( #endif /* NDEBUG */ // How many times to repeat the ant simulation (number of ant generations). - constexpr int num_rounds = 25; + constexpr int const const num_rounds = 25; // After how many rounds without an improvement to exit? - constexpr int num_rounds_no_change_exit = 8; + constexpr int const num_rounds_no_change_exit = 8; // With how many ants each of the run will be performed? - const int num_ants = std::min(int(regions.size()), 10); + const int const num_ants = std::min(int(regions.size()), 10); // Base (initial) pheromone level. This value will be adjusted based on the length of the first greedy path found. float pheromone_initial_deposit = 0.5f; // Evaporation rate of pheromones. - constexpr float pheromone_evaporation = 0.1f; + constexpr float const pheromone_evaporation = 0.1f; // Evaporation rate to diversify paths taken by individual ants. - constexpr float pheromone_diversification = 0.1f; + constexpr float const pheromone_diversification = 0.1f; // Probability at which to take the next best path. Otherwise take the the path based on the cost distribution. - constexpr float probability_take_best = 0.9f; + constexpr float const probability_take_best = 0.9f; // Exponents of the cost function. - constexpr float pheromone_alpha = 1.f; // pheromone exponent - constexpr float pheromone_beta = 2.f; // attractiveness weighted towards edge length + constexpr float const pheromone_alpha = 1.f; // pheromone exponent + constexpr float const pheromone_beta = 2.f; // attractiveness weighted towards edge length AntPathMatrix path_matrix(regions, poly_with_offset, segs, pheromone_initial_deposit); diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index c9f110864..531869239 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -2432,7 +2432,7 @@ namespace Slic3r { if (!volume->mesh().has_shared_vertices()) throw Slic3r::FileIOError("store_3mf() requires shared vertices"); - volumes_offsets.insert({ volume, Offsets(vertices_count) }).first; + volumes_offsets.insert({ volume, Offsets(vertices_count) }); const indexed_triangle_set &its = volume->mesh().its; if (its.vertices.empty()) { diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index f076a74ca..40392466d 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -891,6 +891,7 @@ namespace DoExport { } } +#if 0 // Sort the PrintObjects by their increasing Z, likely useful for avoiding colisions on Deltas during sequential prints. static inline std::vector sort_object_instances_by_max_z(const Print &print) { @@ -903,6 +904,7 @@ static inline std::vector sort_object_instances_by_max_z(c instances.emplace_back(&object->instances()[i]); return instances; } +#endif // Produce a vector of PrintObjects in the order of their respective ModelObjects in print.model(). std::vector sort_object_instances_by_model_order(const Print& print) diff --git a/src/libslic3r/ShortestPath.cpp b/src/libslic3r/ShortestPath.cpp index 60f8feaa6..df09df956 100644 --- a/src/libslic3r/ShortestPath.cpp +++ b/src/libslic3r/ShortestPath.cpp @@ -1083,6 +1083,7 @@ void svg_draw_polyline_chain(const char *name, size_t idx, const Polylines &poly } #endif /* DEBUG_SVG_OUTPUT */ +#if 0 // Flip the sequences of polylines to lower the total length of connecting lines. static inline void improve_ordering_by_segment_flipping(Polylines &polylines, bool fixed_start) { @@ -1253,6 +1254,7 @@ static inline void improve_ordering_by_segment_flipping(Polylines &polylines, bo assert(cost_final <= cost_initial); #endif /* NDEBUG */ } +#endif struct FlipEdge { FlipEdge(const Vec2d &p1, const Vec2d &p2, size_t source_index) : p1(p1), p2(p2), source_index(source_index) {} @@ -1337,6 +1339,7 @@ static inline std::pair minimum_crossover_cost( return std::make_pair(cost_min, flip_min); } +#if 0 static inline std::pair minimum_crossover_cost( const std::vector &edges, const std::pair &span1, const ConnectionCost &cost1, @@ -1412,6 +1415,7 @@ static inline std::pair minimum_crossover_cost( } return std::make_pair(cost_min, flip_min); } +#endif static inline void do_crossover(const std::vector &edges_in, std::vector &edges_out, const std::pair &span1, const std::pair &span2, const std::pair &span3, @@ -1454,7 +1458,7 @@ static inline void do_crossover(const std::vector &edges_in, std::vect assert(edges_in.size() == edges_out.size()); } - +#if 0 static inline void do_crossover(const std::vector &edges_in, std::vector &edges_out, const std::pair &span1, const std::pair &span2, const std::pair &span3, const std::pair &span4, size_t i) @@ -1526,6 +1530,7 @@ static inline void do_crossover(const std::vector &edges_in, std::vect } assert(edges_in.size() == edges_out.size()); } +#endif // Worst time complexity: O(min(n, 100) * (n * log n + n^2) // Expected time complexity: O(min(n, 100) * (n * log n + k * n) @@ -1702,6 +1707,7 @@ private: const ConnectionCost* costs[4]; }; +#if 0 static inline std::pair minimum_crossover_cost( const FourOptCosts &segment_costs, const Matrixd &segment_end_point_distance_matrix, @@ -1760,7 +1766,6 @@ static inline std::pair minimum_crossover_cost( return std::make_pair(cost_min, flip_min); } -#if 0 // Currently not used, too slow. static inline void reorder_by_three_exchanges_with_segment_flipping2(std::vector &edges) { diff --git a/src/libslic3r/SlicingAdaptive.cpp b/src/libslic3r/SlicingAdaptive.cpp index 7ab0c47b2..778e3e184 100644 --- a/src/libslic3r/SlicingAdaptive.cpp +++ b/src/libslic3r/SlicingAdaptive.cpp @@ -52,7 +52,7 @@ static inline std::pair face_z_span(const stl_facet &f) // https://tams.informatik.uni-hamburg.de/publications/2017/Adaptive%20Slicing%20for%20the%20FDM%20Process%20Revisited.pdf // (page 51, formula (8)) // Currenty @platch's error metric formula is not used. -static constexpr double SURFACE_CONST = 0.18403; +static constexpr const double SURFACE_CONST = 0.18403; // for a given facet, compute maximum height within the allowed surface roughness / stairstepping deviation static inline float layer_height_from_slope(const SlicingAdaptive::FaceZ &face, float max_surface_deviation) diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index a2d25b51c..8f653b99d 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -3304,7 +3304,7 @@ void PrintObjectSupportMaterial::generate_toolpaths( // Now modulate the support layer height in parallel. tbb::parallel_for(tbb::blocked_range(n_raft_layers, support_layers.size()), - [this, &support_layers, &layer_caches] + [&support_layers, &layer_caches] (const tbb::blocked_range& range) { for (size_t support_layer_id = range.begin(); support_layer_id < range.end(); ++ support_layer_id) { SupportLayer &support_layer = *support_layers[support_layer_id]; diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index b99a21f11..adb9be64d 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -1146,6 +1146,7 @@ TriangleMeshSlicer::FacetSliceType TriangleMeshSlicer::slice_facet( return NoSlice; } +#if 0 //FIXME Should this go away? For valid meshes the function slice_facet() returns Slicing // and sets edges of vertical triangles to produce only a single edge per pair of neighbor faces. // So the following code makes only sense now to handle degenerate meshes with more than two faces @@ -1209,7 +1210,7 @@ static inline void remove_tangent_edges(std::vector &lines) } } } - +#endif struct OpenPolyline { OpenPolyline() {}; diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 48428b4ee..fb6067931 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -3553,7 +3553,7 @@ void GCodeViewer::render_toolpaths() const } #if ENABLE_REDUCED_TOOLPATHS_SEGMENT_CAPS - auto render_sequential_range_cap = [this, set_uniform_color](const SequentialRangeCap& cap) { + auto render_sequential_range_cap = [set_uniform_color](const SequentialRangeCap& cap) { GLShaderProgram* shader = wxGetApp().get_shader(cap.buffer->shader.c_str()); if (shader != nullptr) { shader->start_using(); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 98c02a6b5..bbdcdf5d2 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -67,20 +67,20 @@ #include -static const float TRACKBALLSIZE = 0.8f; +static constexpr const float TRACKBALLSIZE = 0.8f; -static const float DEFAULT_BG_DARK_COLOR[3] = { 0.478f, 0.478f, 0.478f }; -static const float DEFAULT_BG_LIGHT_COLOR[3] = { 0.753f, 0.753f, 0.753f }; -static const float ERROR_BG_DARK_COLOR[3] = { 0.478f, 0.192f, 0.039f }; -static const float ERROR_BG_LIGHT_COLOR[3] = { 0.753f, 0.192f, 0.039f }; -//static const float AXES_COLOR[3][3] = { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f } }; +static constexpr const float DEFAULT_BG_DARK_COLOR[3] = { 0.478f, 0.478f, 0.478f }; +static constexpr const float DEFAULT_BG_LIGHT_COLOR[3] = { 0.753f, 0.753f, 0.753f }; +static constexpr const float ERROR_BG_DARK_COLOR[3] = { 0.478f, 0.192f, 0.039f }; +static constexpr const float ERROR_BG_LIGHT_COLOR[3] = { 0.753f, 0.192f, 0.039f }; +//static constexpr const float AXES_COLOR[3][3] = { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f } }; // Number of floats -static const size_t MAX_VERTEX_BUFFER_SIZE = 131072 * 6; // 3.15MB +static constexpr const size_t MAX_VERTEX_BUFFER_SIZE = 131072 * 6; // 3.15MB // Reserve size in number of floats. -static const size_t VERTEX_BUFFER_RESERVE_SIZE = 131072 * 2; // 1.05MB +static constexpr const size_t VERTEX_BUFFER_RESERVE_SIZE = 131072 * 2; // 1.05MB // Reserve size in number of floats, maximum sum of all preallocated buffers. -static const size_t VERTEX_BUFFER_RESERVE_SIZE_SUM_MAX = 1024 * 1024 * 128 / 4; // 128MB +static constexpr const size_t VERTEX_BUFFER_RESERVE_SIZE_SUM_MAX = 1024 * 1024 * 128 / 4; // 128MB namespace Slic3r { namespace GUI { @@ -1180,7 +1180,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas) #endif // ENABLE_RENDER_PICKING_PASS , m_render_sla_auxiliaries(true) , m_labels(*this) - , m_slope(*this, m_volumes) + , m_slope(m_volumes) { if (m_canvas != nullptr) { m_timer.SetOwner(m_canvas); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index d3b4e1748..6a6145a80 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -394,11 +394,10 @@ class GLCanvas3D class Slope { bool m_enabled{ false }; - GLCanvas3D& m_canvas; GLVolumeCollection& m_volumes; static float s_window_width; public: - Slope(GLCanvas3D& canvas, GLVolumeCollection& volumes) : m_canvas(canvas), m_volumes(volumes) {} + Slope(GLVolumeCollection& volumes) : m_volumes(volumes) {} void enable(bool enable) { m_enabled = enable; } bool is_enabled() const { return m_enabled; } diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index b11cc8dd5..74dc76415 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -203,6 +203,7 @@ namespace search_for_drives_internal } } +#if 0 static void search_path(const std::string &path, const std::string &parent_path, std::vector &out) { glob_t globbuf; @@ -217,6 +218,7 @@ namespace search_for_drives_internal } globfree(&globbuf); } +#endif } std::vector RemovableDriveManager::search_for_removable_drives() const diff --git a/src/slic3r/Utils/RetinaHelper.hpp b/src/slic3r/Utils/RetinaHelper.hpp index 659bc7f56..336fc17c4 100644 --- a/src/slic3r/Utils/RetinaHelper.hpp +++ b/src/slic3r/Utils/RetinaHelper.hpp @@ -18,7 +18,9 @@ public: float get_scale_factor(); private: +#ifdef __WXGTK3__ wxWindow* m_window; +#endif // __WXGTK3__ void* m_self; }; diff --git a/src/slic3r/Utils/RetinaHelperImpl.mm b/src/slic3r/Utils/RetinaHelperImpl.mm index de0402d34..ee4e4d589 100644 --- a/src/slic3r/Utils/RetinaHelperImpl.mm +++ b/src/slic3r/Utils/RetinaHelperImpl.mm @@ -11,8 +11,7 @@ namespace Slic3r { namespace GUI { -RetinaHelper::RetinaHelper(wxWindow* window) : - m_window(window) +RetinaHelper::RetinaHelper(wxWindow*) { m_self = nullptr; m_self = [[RetinaHelperImpl alloc] initWithView:window->GetHandle() handler:window->GetEventHandler()];