Skip to content

Commit

Permalink
Fixed some numeric conversion warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Nov 22, 2023
1 parent 332b2f3 commit a336b22
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions include/TreeSupportSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ struct TreeSupportSettings
, min_radius(mesh_group_settings.get<coord_t>("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<coord_t>("support_tree_max_diameter") / 2)
, maximum_move_distance((angle < TAU / 4) ? (coord_t)(tan(angle) * layer_height) : std::numeric_limits<coord_t>::max())
, maximum_move_distance_slow((angle_slow < TAU / 4) ? (coord_t)(tan(angle_slow) * layer_height) : std::numeric_limits<coord_t>::max())
, maximum_move_distance((angle < TAU / 4) ? std::llround(tan(angle) * layer_height) : std::numeric_limits<coord_t>::max())
, maximum_move_distance_slow((angle_slow < TAU / 4) ? std::llround(tan(angle_slow) * layer_height) : std::numeric_limits<coord_t>::max())
, support_bottom_layers(mesh_group_settings.get<bool>("support_bottom_enable") ? round_divide(mesh_group_settings.get<coord_t>("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
Expand All @@ -50,7 +50,7 @@ struct TreeSupportSettings
: RestPreference::BUILDPLATE)
, xy_distance(mesh_group_settings.get<coord_t>("support_xy_distance"))
, bp_radius(mesh_group_settings.get<coord_t>("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<double>(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<SupportDistPriority>("support_xy_overrides_z"))
, xy_min_distance(support_overrides == SupportDistPriority::Z_OVERRIDES_XY ? mesh_group_settings.get<coord_t>("support_xy_distance_overhang") : xy_distance)
Expand Down
20 changes: 10 additions & 10 deletions include/timeEstimate.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
#ifndef TIME_ESTIMATE_H
#define TIME_ESTIMATE_H

#include <stdint.h>
#include <unordered_map>
#include <vector>

#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 <stdint.h>
#include <unordered_map>
#include <vector>

namespace cura
{

Expand All @@ -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
Expand All @@ -50,7 +50,7 @@ class TimeEstimateCalculator
}
double axis[NUM_AXIS];

double& operator[](const int n)
double& operator[](const size_t n)
{
return axis[n];
}
Expand Down
4 changes: 2 additions & 2 deletions include/utils/ExtrusionLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
6 changes: 3 additions & 3 deletions include/utils/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>(precision); // set [x]
constexpr size_t buffer_size = 400;
char buffer[buffer_size];
int char_count = sprintf(buffer, format, coord);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/FffPolygonGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>("ironing_enabled") && (! mesh.settings.get<bool>("ironing_only_highest_layer") || mesh.layer_nr_max_filled_layer == layer_nr)
if (((mesh.settings.get<bool>("ironing_enabled") && (! mesh.settings.get<bool>("ironing_only_highest_layer"))) || mesh.layer_nr_max_filled_layer == layer_nr)
|| ! mesh.settings.get<bool>("small_skin_on_surface"))
{
// Generate the top surface to iron over.
Expand Down
2 changes: 1 addition & 1 deletion src/MeshGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float*>(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());
Expand Down
4 changes: 2 additions & 2 deletions src/gcodeExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ std::string transliterate(const std::string& text)
std::ostringstream stream;
for (const char& c : text)
{
stream << static_cast<char>((c >= 0) ? c : '?');
stream << ((c >= 0) ? c : '?');
}
return stream.str();
}
Expand Down Expand Up @@ -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_)
{
Expand Down
2 changes: 1 addition & 1 deletion src/skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void SkinInfillAreaComputation::generateGradualInfill(SliceMeshStorage& mesh)

void SkinInfillAreaComputation::combineInfillLayers(SliceMeshStorage& mesh)
{
if (mesh.layers.empty() || mesh.layers.size() - 1 < static_cast<size_t>(mesh.settings.get<size_t>("top_layers"))
if (mesh.layers.empty() || mesh.layers.size() - 1 < mesh.settings.get<size_t>("top_layers")
|| mesh.settings.get<coord_t>("infill_line_distance") == 0) // No infill is even generated.
{
return;
Expand Down

0 comments on commit a336b22

Please sign in to comment.