From a336b225b92367cc4f6a608db71e17659205bb34 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 22 Nov 2023 17:42:02 +0100 Subject: [PATCH] Fixed some numeric conversion warnings --- include/TreeSupportSettings.h | 6 +++--- include/timeEstimate.h | 20 ++++++++++---------- include/utils/ExtrusionLine.h | 4 ++-- include/utils/string.h | 6 +++--- src/FffPolygonGenerator.cpp | 2 +- src/MeshGroup.cpp | 2 +- src/gcodeExport.cpp | 4 ++-- src/skin.cpp | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/TreeSupportSettings.h b/include/TreeSupportSettings.h index a550bb530b..78be092694 100644 --- a/include/TreeSupportSettings.h +++ b/include/TreeSupportSettings.h @@ -32,8 +32,8 @@ struct TreeSupportSettings , min_radius(mesh_group_settings.get("support_tree_tip_diameter") / 2) , // The actual radius is 50 microns larger as the resulting branches will be increased by 50 microns to avoid rounding errors effectively increasing the xydistance max_radius(mesh_group_settings.get("support_tree_max_diameter") / 2) - , maximum_move_distance((angle < TAU / 4) ? (coord_t)(tan(angle) * layer_height) : std::numeric_limits::max()) - , maximum_move_distance_slow((angle_slow < TAU / 4) ? (coord_t)(tan(angle_slow) * layer_height) : std::numeric_limits::max()) + , maximum_move_distance((angle < TAU / 4) ? std::llround(tan(angle) * layer_height) : std::numeric_limits::max()) + , maximum_move_distance_slow((angle_slow < TAU / 4) ? std::llround(tan(angle_slow) * layer_height) : std::numeric_limits::max()) , support_bottom_layers(mesh_group_settings.get("support_bottom_enable") ? round_divide(mesh_group_settings.get("support_bottom_height"), layer_height) : 0) , tip_layers(std::max((branch_radius - min_radius) / (support_line_width / 3), branch_radius / layer_height)) , // Ensure lines always stack nicely even if layer height is large @@ -50,7 +50,7 @@ struct TreeSupportSettings : RestPreference::BUILDPLATE) , xy_distance(mesh_group_settings.get("support_xy_distance")) , bp_radius(mesh_group_settings.get("support_tree_bp_diameter") / 2) - , diameter_scale_bp_radius(std::min(sin(0.7) * layer_height / branch_radius, 1.0 / (branch_radius / (support_line_width / 2.0)))) + , diameter_scale_bp_radius(std::min(sin(0.7) * static_cast(layer_height / branch_radius), 1.0 / (branch_radius / (support_line_width / 2.0)))) , // Either 40° or as much as possible so that 2 lines will overlap by at least 50%, whichever is smaller. support_overrides(mesh_group_settings.get("support_xy_overrides_z")) , xy_min_distance(support_overrides == SupportDistPriority::Z_OVERRIDES_XY ? mesh_group_settings.get("support_xy_distance_overhang") : xy_distance) diff --git a/include/timeEstimate.h b/include/timeEstimate.h index 4ce741a6ba..b78b136aea 100644 --- a/include/timeEstimate.h +++ b/include/timeEstimate.h @@ -4,15 +4,15 @@ #ifndef TIME_ESTIMATE_H #define TIME_ESTIMATE_H +#include +#include +#include + #include "PrintFeature.h" #include "settings/types/Duration.h" //Print time estimates. #include "settings/types/Ratio.h" #include "settings/types/Velocity.h" //Speeds and accelerations at which we print. -#include -#include -#include - namespace cura { @@ -26,11 +26,11 @@ class Settings; class TimeEstimateCalculator { public: - constexpr static unsigned int NUM_AXIS = 4; - constexpr static unsigned int X_AXIS = 0; - constexpr static unsigned int Y_AXIS = 1; - constexpr static unsigned int Z_AXIS = 2; - constexpr static unsigned int E_AXIS = 3; + constexpr static size_t NUM_AXIS = 4; + constexpr static size_t X_AXIS = 0; + constexpr static size_t Y_AXIS = 1; + constexpr static size_t Z_AXIS = 2; + constexpr static size_t E_AXIS = 3; class Position @@ -50,7 +50,7 @@ class TimeEstimateCalculator } double axis[NUM_AXIS]; - double& operator[](const int n) + double& operator[](const size_t n) { return axis[n]; } diff --git a/include/utils/ExtrusionLine.h b/include/utils/ExtrusionLine.h index 7c09ca4eb5..e1f2437666 100644 --- a/include/utils/ExtrusionLine.h +++ b/include/utils/ExtrusionLine.h @@ -129,12 +129,12 @@ struct ExtrusionLine return junctions_.back(); } - const ExtrusionJunction& operator[](unsigned int index) const + const ExtrusionJunction& operator[](size_t index) const { return junctions_[index]; } - ExtrusionJunction& operator[](unsigned int index) + ExtrusionJunction& operator[](size_t index) { return junctions_[index]; } diff --git a/include/utils/string.h b/include/utils/string.h index 7ca857c191..90ddc318fd 100644 --- a/include/utils/string.h +++ b/include/utils/string.h @@ -121,10 +121,10 @@ struct MMtoStream * \param coord double to output * \param ss The output stream to write the string to */ -static inline void writeDoubleToStream(const unsigned int precision, const double coord, std::ostream& ss) +static inline void writeDoubleToStream(const uint8_t precision, const double coord, std::ostream& ss) { char format[5] = "%.xF"; // write a float with [x] digits after the dot - format[2] = '0' + precision; // set [x] + format[2] = '0' + static_cast(precision); // set [x] constexpr size_t buffer_size = 400; char buffer[buffer_size]; int char_count = sprintf(buffer, format, coord); @@ -166,7 +166,7 @@ static inline void writeDoubleToStream(const unsigned int precision, const doubl */ struct PrecisionedDouble { - unsigned int precision; //!< Number of digits after the decimal mark with which to convert to string + uint8_t precision; //!< Number of digits after the decimal mark with which to convert to string double value; //!< The double value friend inline std::ostream& operator<<(std::ostream& out, const PrecisionedDouble precision_and_input) diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp index 16503d2839..384093794c 100644 --- a/src/FffPolygonGenerator.cpp +++ b/src/FffPolygonGenerator.cpp @@ -827,7 +827,7 @@ void FffPolygonGenerator::processSkinsAndInfill(SliceMeshStorage& mesh, const La SkinInfillAreaComputation skin_infill_area_computation(layer_nr, mesh, process_infill); skin_infill_area_computation.generateSkinsAndInfill(); - if (mesh.settings.get("ironing_enabled") && (! mesh.settings.get("ironing_only_highest_layer") || mesh.layer_nr_max_filled_layer == layer_nr) + if (((mesh.settings.get("ironing_enabled") && (! mesh.settings.get("ironing_only_highest_layer"))) || mesh.layer_nr_max_filled_layer == layer_nr) || ! mesh.settings.get("small_skin_on_surface")) { // Generate the top surface to iron over. diff --git a/src/MeshGroup.cpp b/src/MeshGroup.cpp index c31623cee6..f71b2f7bd5 100644 --- a/src/MeshGroup.cpp +++ b/src/MeshGroup.cpp @@ -210,7 +210,7 @@ bool loadMeshSTL_binary(Mesh* mesh, const char* filename, const Matrix4x3D& matr fclose(f); return false; } - float* v = ((float*)buffer) + 3; + float* v = reinterpret_cast(buffer) + 3; Point3LL v0 = matrix.apply(Point3F(v[0], v[1], v[2]).toPoint3d()); Point3LL v1 = matrix.apply(Point3F(v[3], v[4], v[5]).toPoint3d()); diff --git a/src/gcodeExport.cpp b/src/gcodeExport.cpp index 9726c9b39c..8372ba1656 100644 --- a/src/gcodeExport.cpp +++ b/src/gcodeExport.cpp @@ -31,7 +31,7 @@ std::string transliterate(const std::string& text) std::ostringstream stream; for (const char& c : text) { - stream << static_cast((c >= 0) ? c : '?'); + stream << ((c >= 0) ? c : '?'); } return stream.str(); } @@ -1165,7 +1165,7 @@ void GCodeExport::writeRetraction(const RetractionConfig& config, bool force, bo } } - if (extruder_attr_[current_extruder_].machine_firmware_retract_) + if (extr_attr.machine_firmware_retract_) { if (extruder_switch && extr_attr.retraction_e_amount_current_) { diff --git a/src/skin.cpp b/src/skin.cpp index e02ba1b2d1..1f36864698 100644 --- a/src/skin.cpp +++ b/src/skin.cpp @@ -535,7 +535,7 @@ void SkinInfillAreaComputation::generateGradualInfill(SliceMeshStorage& mesh) void SkinInfillAreaComputation::combineInfillLayers(SliceMeshStorage& mesh) { - if (mesh.layers.empty() || mesh.layers.size() - 1 < static_cast(mesh.settings.get("top_layers")) + if (mesh.layers.empty() || mesh.layers.size() - 1 < mesh.settings.get("top_layers") || mesh.settings.get("infill_line_distance") == 0) // No infill is even generated. { return;