Fixed couple of warnings

Turned several includes into forward declarations
Removed several sprintf calls in favor of std::to_string
This commit is contained in:
Lukas Matena 2019-08-29 13:17:10 +02:00
parent 0dfeee6caf
commit 942f959e87
8 changed files with 53 additions and 66 deletions

View file

@ -247,7 +247,7 @@ extern void its_transform(indexed_triangle_set &its, T *trafo3x4)
template<typename T>
inline void its_transform(indexed_triangle_set &its, const Eigen::Transform<T, 3, Eigen::Affine, Eigen::DontAlign>& t)
{
const Eigen::Matrix<double, 3, 3, Eigen::DontAlign> r = t.matrix().template block<3, 3>(0, 0);
//const Eigen::Matrix<double, 3, 3, Eigen::DontAlign> r = t.matrix().template block<3, 3>(0, 0);
for (stl_vertex &v : its.vertices)
v = (t * v.template cast<T>()).template cast<float>().eval();
}

View file

@ -151,7 +151,7 @@ public:
float dx = x - m_current_pos.x();
float dy = y - m_current_pos.y();
double len = sqrt(dx*dx+dy*dy);
float len = std::sqrt(dx*dx+dy*dy);
if (record_length)
m_used_filament_length += e;
@ -159,11 +159,11 @@ public:
Vec2f rotated_current_pos(rotate(m_current_pos + Vec2f(0.f,m_y_shift), m_wipe_tower_width, m_wipe_tower_depth, m_internal_angle)); // this is where we are
Vec2f rot(rotate(Vec2f(x,y+m_y_shift), m_wipe_tower_width, m_wipe_tower_depth, m_internal_angle)); // this is where we want to go
if (! m_preview_suppressed && e > 0.f && len > 0.) {
if (! m_preview_suppressed && e > 0.f && len > 0.f) {
change_analyzer_mm3_per_mm(len, e);
// Width of a squished extrusion, corrected for the roundings of the squished extrusions.
// This is left zero if it is a travel move.
float width = float(double(e) * m_filpar[0].filament_area / (len * m_layer_height));
float width = e * m_filpar[0].filament_area / (len * m_layer_height);
// Correct for the roundings of a squished extrusion.
width += m_layer_height * float(1. - M_PI / 4.);
if (m_extrusions.empty() || m_extrusions.back().pos != rotated_current_pos)
@ -172,10 +172,10 @@ public:
}
m_gcode += "G1";
if (std::abs(rot.x() - rotated_current_pos.x()) > EPSILON)
if (std::abs(rot.x() - rotated_current_pos.x()) > (float)EPSILON)
m_gcode += set_format_X(rot.x());
if (std::abs(rot.y() - rotated_current_pos.y()) > EPSILON)
if (std::abs(rot.y() - rotated_current_pos.y()) > (float)EPSILON)
m_gcode += set_format_Y(rot.y());
@ -214,7 +214,7 @@ public:
{
float dx = x - m_current_pos.x();
float dy = y - m_current_pos.y();
return extrude_explicit(x, y, sqrt(dx*dx+dy*dy) * m_extrusion_flow, f, true);
return extrude_explicit(x, y, std::sqrt(dx*dx+dy*dy) * m_extrusion_flow, f, true);
}
WipeTowerWriter& extrude(const Vec2f &dest, const float f = 0.f)
@ -311,7 +311,7 @@ public:
return *this;
}
WipeTowerWriter& set_tool(int tool)
WipeTowerWriter& set_tool(unsigned tool)
{
m_current_tool = tool;
return *this;
@ -320,57 +320,52 @@ public:
// Set extruder temperature, don't wait by default.
WipeTowerWriter& set_extruder_temp(int temperature, bool wait = false)
{
char buf[128];
sprintf(buf, "M%d S%d\n", wait ? 109 : 104, temperature);
m_gcode += buf;
m_gcode += "M" + std::to_string(wait ? 109 : 104) + " S" + std::to_string(temperature) + "\n";
return *this;
};
}
// Wait for a period of time (seconds).
WipeTowerWriter& wait(float time)
{
if (time==0)
if (time==0.f)
return *this;
char buf[128];
sprintf(buf, "G4 S%.3f\n", time);
m_gcode += buf;
return *this;
};
}
// Set speed factor override percentage.
WipeTowerWriter& speed_override(int speed)
{
char buf[128];
sprintf(buf, "M220 S%d\n", speed);
m_gcode += buf;
m_gcode += "M220 S" + std::to_string(speed) + "\n";
return *this;
};
}
// Let the firmware back up the active speed override value.
WipeTowerWriter& speed_override_backup()
{
m_gcode += "M220 B\n";
return *this;
};
}
// Let the firmware restore the active speed override value.
WipeTowerWriter& speed_override_restore()
{
m_gcode += "M220 R\n";
return *this;
};
}
// Set digital trimpot motor
WipeTowerWriter& set_extruder_trimpot(int current)
{
char buf[128];
if (m_gcode_flavor == gcfRepRap)
sprintf(buf, "M906 E%d\n", current);
m_gcode += "M906 E";
else
sprintf(buf, "M907 E%d\n", current);
m_gcode += buf;
m_gcode += "M907 E";
m_gcode += std::to_string(current) + "\n";
return *this;
};
}
WipeTowerWriter& flush_planner_queue()
{
@ -386,28 +381,20 @@ public:
}
WipeTowerWriter& comment_with_value(const char *comment, int value)
{
char strvalue[64];
sprintf(strvalue, "%d", value);
m_gcode += std::string(";") + comment + strvalue + "\n";
{
m_gcode += std::string(";") + comment + std::to_string(value) + "\n";
return *this;
};
}
WipeTowerWriter& set_fan(unsigned int speed)
{
if (speed == m_last_fan_speed)
return *this;
if (speed == 0)
m_gcode += "M107\n";
else
{
m_gcode += "M106 S";
char buf[128];
sprintf(buf,"%u\n",(unsigned int)(255.0 * speed / 100.0));
m_gcode += buf;
}
else
m_gcode += "M106 S" + std::to_string((size_t)(255.0 * speed / 100.0)) + "\n";
m_last_fan_speed = speed;
return *this;
}
@ -995,8 +982,8 @@ void WipeTower::toolchange_Unload(
// Change the tool, set a speed override for soluble and flex materials.
void WipeTower::toolchange_Change(
WipeTowerWriter &writer,
const unsigned int new_tool,
const std::string& new_material)
const size_t new_tool,
const std::string& new_material)
{
// Ask the writer about how much of the old filament we consumed:
if (m_current_tool < m_used_filament_length.size())

View file

@ -7,21 +7,21 @@
#include <utility>
#include <algorithm>
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Point.hpp"
namespace Slic3r
{
class WipeTowerWriter;
class PrintConfig;
enum GCodeFlavor : unsigned char;
class WipeTower
{
public:
struct Extrusion
{
{
Extrusion(const Vec2f &pos, float width, unsigned int tool) : pos(pos), width(width), tool(tool) {}
// End position of this extrusion.
Vec2f pos;
@ -79,7 +79,6 @@ public:
// width -- width of wipe tower in mm ( default 60 mm - leave as it is )
// wipe_area -- space available for one toolchange in mm
WipeTower(const PrintConfig& config, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool);
virtual ~WipeTower() {}
// Set the extruder properties.
@ -244,7 +243,7 @@ private:
bool m_print_brim = true;
// A fill-in direction (positive Y, negative Y) alternates with each layer.
wipe_shape m_current_shape = SHAPE_NORMAL;
unsigned int m_current_tool = 0;
size_t m_current_tool = 0;
const std::vector<std::vector<float>> wipe_volumes;
float m_depth_traversed = 0.f; // Current y position at the wipe tower.
@ -309,13 +308,13 @@ private:
// to store information about tool changes for a given layer
struct WipeTowerInfo{
struct ToolChange {
unsigned int old_tool;
unsigned int new_tool;
size_t old_tool;
size_t new_tool;
float required_depth;
float ramming_depth;
float first_wipe_line;
float wipe_volume;
ToolChange(unsigned int old, unsigned int newtool, float depth=0.f, float ramming_depth=0.f, float fwl=0.f, float wv=0.f)
ToolChange(size_t old, size_t newtool, float depth=0.f, float ramming_depth=0.f, float fwl=0.f, float wv=0.f)
: old_tool{old}, new_tool{newtool}, required_depth{depth}, ramming_depth{ramming_depth}, first_wipe_line{fwl}, wipe_volume{wv} {}
};
float z; // z position of the layer
@ -350,7 +349,7 @@ private:
void toolchange_Change(
WipeTowerWriter &writer,
const unsigned int new_tool,
const size_t new_tool,
const std::string& new_material);
void toolchange_Load(

View file

@ -24,7 +24,7 @@
namespace Slic3r {
enum GCodeFlavor {
enum GCodeFlavor : unsigned char {
gcfRepRap, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfSailfish, gcfMach3, gcfMachinekit,
gcfSmoothie, gcfNoExtrusion,
};

View file

@ -1870,12 +1870,13 @@ std::vector<ExPolygons> PrintObject::slice_modifiers(size_t region_id, const std
merge.assign(out.size(), false);
} else {
for (size_t i = 0; i < out.size(); ++ i)
if (! this_slices[i].empty())
if (! this_slices[i].empty()) {
if (! out[i].empty()) {
append(out[i], this_slices[i]);
merge[i] = true;
} else
out[i] = std::move(this_slices[i]);
}
}
i = j;
} else

View file

@ -5,11 +5,11 @@
#include <vector>
#include <wx/panel.h>
#include "wxExtensions.hpp"
#include "libslic3r/PrintConfig.hpp"
class wxBoxSizer;
namespace Slic3r {
class DynamicPrintConfig;
namespace GUI {
class ConfigOptionsGroup;

View file

@ -13,6 +13,7 @@
#include "slic3r/GUI/GUI_ObjectSettings.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include "slic3r/GUI/PresetBundle.hpp"
#include "libslic3r/SLAPrint.hpp"
#include "libslic3r/Tesselate.hpp"

View file

@ -11,7 +11,6 @@
#include "slic3r/GUI/I18N.hpp" // ...and redefine again when we are done with the igl code
#include "libslic3r/SLA/SLACommon.hpp"
#include "libslic3r/SLAPrint.hpp"
#include <wx/dialog.h>
#include <cereal/types/vector.hpp>
@ -78,7 +77,7 @@ private:
public:
GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
virtual ~GLGizmoSlaSupports();
~GLGizmoSlaSupports() override;
void set_sla_support_data(ModelObject* model_object, const Selection& selection);
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
void delete_selected_points(bool force = false);
@ -90,10 +89,10 @@ public:
void reslice_SLA_supports(bool postpone_error_messages = false) const;
private:
bool on_init();
void on_update(const UpdateData& data);
virtual void on_render() const;
virtual void on_render_for_picking() const;
bool on_init() override;
void on_update(const UpdateData& data) override;
void on_render() const override;
void on_render_for_picking() const override;
//void render_selection_rectangle() const;
void render_points(const Selection& selection, bool picking = false) const;
@ -157,20 +156,20 @@ private:
protected:
void on_set_state() override;
virtual void on_set_hover_id()
void on_set_hover_id() override
{
if (! m_editing_mode || (int)m_editing_cache.size() <= m_hover_id)
m_hover_id = -1;
}
void on_start_dragging() override;
void on_stop_dragging() override;
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
void on_render_input_window(float x, float y, float bottom_limit) override;
virtual std::string on_get_name() const;
virtual bool on_is_activable() const;
virtual bool on_is_selectable() const;
virtual void on_load(cereal::BinaryInputArchive& ar) override;
virtual void on_save(cereal::BinaryOutputArchive& ar) const override;
std::string on_get_name() const override;
bool on_is_activable() const override;
bool on_is_selectable() const override;
void on_load(cereal::BinaryInputArchive& ar) override;
void on_save(cereal::BinaryOutputArchive& ar) const override;
};