diff --git a/src/slic3r/GUI/LibVGCode/include/Viewer.hpp b/src/slic3r/GUI/LibVGCode/include/Viewer.hpp index 067eee04cf..b869b812f1 100644 --- a/src/slic3r/GUI/LibVGCode/include/Viewer.hpp +++ b/src/slic3r/GUI/LibVGCode/include/Viewer.hpp @@ -105,7 +105,7 @@ public: // // Return the count of detected extrusion roles // - uint32_t get_extrusion_roles_count() const; + size_t get_extrusion_roles_count() const; // // Return the list of detected extrusion roles diff --git a/src/slic3r/GUI/LibVGCode/src/Bitset.hpp b/src/slic3r/GUI/LibVGCode/src/Bitset.hpp index da14686d6a..83805cab92 100644 --- a/src/slic3r/GUI/LibVGCode/src/Bitset.hpp +++ b/src/slic3r/GUI/LibVGCode/src/Bitset.hpp @@ -20,7 +20,7 @@ template struct BitSet { BitSet() = default; - BitSet(unsigned int size) : size(size), blocks(1 + (size / (sizeof(T) * 8))) { clear(); } + BitSet(size_t size) : size(size), blocks(1 + (size / (sizeof(T) * 8))) { clear(); } void clear() { for (size_t i = 0; i < blocks.size(); ++i) { @@ -35,24 +35,24 @@ struct BitSet } //return true if bit changed - bool set(unsigned int index) { + bool set(size_t index) { const auto [block_idx, bit_idx] = get_coords(index); - T mask = (T(1) << bit_idx); + const T mask = (T(1) << bit_idx); bool flip = mask xor blocks[block_idx]; blocks[block_idx] |= mask; return flip; } //return true if bit changed - bool reset(unsigned int index) { + bool reset(size_t index) { const auto [block_idx, bit_idx] = get_coords(index); - T mask = (T(1) << bit_idx); - bool flip = mask xor blocks[block_idx]; + const T mask = (T(1) << bit_idx); + const bool flip = mask xor blocks[block_idx]; blocks[block_idx] &= (~mask); return flip; } - bool operator [] (unsigned int index) const { + bool operator [] (size_t index) const { const auto [block_idx, bit_idx] = get_coords(index); return ((blocks[block_idx] >> bit_idx) & 1) != 0; } @@ -68,30 +68,30 @@ struct BitSet // Atomic set operation (enabled only for atomic types), return true if bit changed template - inline typename std::enable_if, bool>::type set_atomic(unsigned int index) { + inline typename std::enable_if, bool>::type set_atomic(size_t index) { const auto [block_idx, bit_idx] = get_coords(index); - T mask = static_cast(1) << bit_idx; - T oldval = blocks[block_idx].fetch_or(mask, std::memory_order_relaxed); + const T mask = static_cast(1) << bit_idx; + const T oldval = blocks[block_idx].fetch_or(mask, std::memory_order_relaxed); return oldval xor (oldval or mask); } // Atomic reset operation (enabled only for atomic types), return true if bit changed template - inline typename std::enable_if, bool>::type reset_atomic(unsigned int index) { + inline typename std::enable_if, bool>::type reset_atomic(size_t index) { const auto [block_idx, bit_idx] = get_coords(index); - T mask = ~(static_cast(1) << bit_idx); - T oldval = blocks[block_idx].fetch_and(mask, std::memory_order_relaxed); + const T mask = ~(static_cast(1) << bit_idx); + const T oldval = blocks[block_idx].fetch_and(mask, std::memory_order_relaxed); return oldval xor (oldval and mask); } - std::pair get_coords(unsigned int index) const + std::pair get_coords(size_t index) const { - unsigned int block_idx = index / (sizeof(T) * 8); - unsigned int bit_idx = index % (sizeof(T) * 8); - return std::make_pair(block_idx, bit_idx); + const size_t block_idx = index / (sizeof(T) * 8); + const size_t bit_idx = index % (sizeof(T) * 8); + return { block_idx, bit_idx }; } - unsigned int size{ 0 }; + size_t size{ 0 }; std::vector blocks{ 0 }; }; diff --git a/src/slic3r/GUI/LibVGCode/src/ColorRange.cpp b/src/slic3r/GUI/LibVGCode/src/ColorRange.cpp index d36bad7248..530a2e5e2b 100644 --- a/src/slic3r/GUI/LibVGCode/src/ColorRange.cpp +++ b/src/slic3r/GUI/LibVGCode/src/ColorRange.cpp @@ -6,6 +6,7 @@ #include #include +#include namespace libvgcode { @@ -45,7 +46,7 @@ Color ColorRange::get_color_at(float value) const if (step > 0.0f) { if (m_type == EColorRangeType::Logarithmic) { if (m_range[0] != 0.0f) - global_t = log(value / m_range[0]) / step; + global_t = std::log(value / m_range[0]) / step; } else global_t = (value - m_range[0]) / step; @@ -54,7 +55,7 @@ Color ColorRange::get_color_at(float value) const const size_t color_max_idx = Ranges_Colors.size() - 1; // Compute the two colors just below (low) and above (high) the input value - const size_t color_low_idx = std::clamp(global_t, 0, color_max_idx); + const size_t color_low_idx = std::clamp(static_cast(global_t), 0, color_max_idx); const size_t color_high_idx = std::clamp(color_low_idx + 1, 0, color_max_idx); // Interpolate between the low and high colors to find exactly which color the input value should get diff --git a/src/slic3r/GUI/LibVGCode/src/OpenGLUtils.hpp b/src/slic3r/GUI/LibVGCode/src/OpenGLUtils.hpp index 7ba80ed252..8417093c96 100644 --- a/src/slic3r/GUI/LibVGCode/src/OpenGLUtils.hpp +++ b/src/slic3r/GUI/LibVGCode/src/OpenGLUtils.hpp @@ -18,7 +18,7 @@ extern void glAssertRecentCallImpl(const char* file_name, unsigned int line, con inline void glAssertRecentCall() { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } #define glsafe(cmd) do { cmd; glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false) #define glcheck() do { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false) -#else // HAS_GLSAFE +#else inline void glAssertRecentCall() { } #define glsafe(cmd) cmd #define glcheck() diff --git a/src/slic3r/GUI/LibVGCode/src/OptionTemplate.cpp b/src/slic3r/GUI/LibVGCode/src/OptionTemplate.cpp index d7f4c22231..3c9b54373e 100644 --- a/src/slic3r/GUI/LibVGCode/src/OptionTemplate.cpp +++ b/src/slic3r/GUI/LibVGCode/src/OptionTemplate.cpp @@ -8,6 +8,7 @@ #include #include +#include namespace libvgcode { @@ -43,7 +44,7 @@ void OptionTemplate::init(uint8_t resolution) add_vertex({ 0.0f, 0.0f, 0.5f }, { 0.0f, 0.0f, 1.0f }, top_vertices); for (uint8_t i = 0; i <= m_resolution; ++i) { const float ii = float(i) * step; - const Vec3 pos = { 0.5f * ::cos(ii), 0.5f * ::sin(ii), 0.0f }; + const Vec3 pos = { 0.5f * std::cos(ii), 0.5f * std::sin(ii), 0.0f }; const Vec3 norm = normalize(pos); add_vertex(pos, norm, top_vertices); } @@ -56,7 +57,7 @@ void OptionTemplate::init(uint8_t resolution) add_vertex({ 0.0f, 0.0f, -0.5f }, { 0.0f, 0.0f, -1.0f }, bottom_vertices); for (uint8_t i = 0; i <= m_resolution; ++i) { const float ii = -float(i) * step; - const Vec3 pos = { 0.5f * ::cos(ii), 0.5f * ::sin(ii), 0.0f }; + const Vec3 pos = { 0.5f * std::cos(ii), 0.5f * std::sin(ii), 0.0f }; const Vec3 norm = normalize(pos); add_vertex(pos, norm, bottom_vertices); } @@ -103,10 +104,9 @@ void OptionTemplate::render(size_t count) glsafe(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &curr_vertex_array)); glsafe(glBindVertexArray(m_top_vao_id)); - glsafe(glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, m_vertices_count, count)); + glsafe(glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, static_cast(m_vertices_count), static_cast(count))); glsafe(glBindVertexArray(m_bottom_vao_id)); - glsafe(glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, m_vertices_count, count)); - + glsafe(glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, static_cast(m_vertices_count), static_cast(count))); glsafe(glBindVertexArray(curr_vertex_array)); } diff --git a/src/slic3r/GUI/LibVGCode/src/SegmentTemplate.cpp b/src/slic3r/GUI/LibVGCode/src/SegmentTemplate.cpp index b01b3e1f05..34a9f54d07 100644 --- a/src/slic3r/GUI/LibVGCode/src/SegmentTemplate.cpp +++ b/src/slic3r/GUI/LibVGCode/src/SegmentTemplate.cpp @@ -67,8 +67,7 @@ void SegmentTemplate::render(size_t count) glsafe(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &curr_vertex_array)); glsafe(glBindVertexArray(m_vao_id)); - glsafe(glDrawArraysInstanced(GL_TRIANGLES, 0, VERTEX_DATA.size(), count)); - + glsafe(glDrawArraysInstanced(GL_TRIANGLES, 0, static_cast(VERTEX_DATA.size()), static_cast(count))); glsafe(glBindVertexArray(curr_vertex_array)); } diff --git a/src/slic3r/GUI/LibVGCode/src/ToolMarker.cpp b/src/slic3r/GUI/LibVGCode/src/ToolMarker.cpp index 995e87ad20..e9845533f7 100644 --- a/src/slic3r/GUI/LibVGCode/src/ToolMarker.cpp +++ b/src/slic3r/GUI/LibVGCode/src/ToolMarker.cpp @@ -6,7 +6,7 @@ #include "OpenGLUtils.hpp" #include "Utils.hpp" -#include +#include #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS @@ -49,8 +49,8 @@ void ToolMarker::init(uint16_t resolution, float tip_radius, float tip_height, f for (uint16_t i = 0; i < resolution; ++i) { const float angle = angle_step * float(i); - cosines[i] = ::cos(angle); - sines[i] = -::sin(angle); + cosines[i] = std::cos(angle); + sines[i] = -std::sin(angle); } const float total_height = tip_height + stem_height; diff --git a/src/slic3r/GUI/LibVGCode/src/ToolMarker.hpp b/src/slic3r/GUI/LibVGCode/src/ToolMarker.hpp index e0ca11cc2e..cacdf25538 100644 --- a/src/slic3r/GUI/LibVGCode/src/ToolMarker.hpp +++ b/src/slic3r/GUI/LibVGCode/src/ToolMarker.hpp @@ -8,6 +8,7 @@ #include "../include/Types.hpp" #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS +#include namespace libvgcode { diff --git a/src/slic3r/GUI/LibVGCode/src/Utils.cpp b/src/slic3r/GUI/LibVGCode/src/Utils.cpp index ce9edf9439..aee2cd4875 100644 --- a/src/slic3r/GUI/LibVGCode/src/Utils.cpp +++ b/src/slic3r/GUI/LibVGCode/src/Utils.cpp @@ -4,6 +4,7 @@ ///|/ #include "Utils.hpp" +#include #include namespace libvgcode { diff --git a/src/slic3r/GUI/LibVGCode/src/Viewer.cpp b/src/slic3r/GUI/LibVGCode/src/Viewer.cpp index 46a9461bbe..bf7c7bfff1 100644 --- a/src/slic3r/GUI/LibVGCode/src/Viewer.cpp +++ b/src/slic3r/GUI/LibVGCode/src/Viewer.cpp @@ -202,7 +202,7 @@ const Interval& Viewer::get_enabled_options_range() const return m_impl->get_enabled_options_range(); } -uint32_t Viewer::get_extrusion_roles_count() const +size_t Viewer::get_extrusion_roles_count() const { return m_impl->get_extrusion_roles_count(); } diff --git a/src/slic3r/GUI/LibVGCode/src/ViewerImpl.cpp b/src/slic3r/GUI/LibVGCode/src/ViewerImpl.cpp index d596f3e223..8b1fc3d6c3 100644 --- a/src/slic3r/GUI/LibVGCode/src/ViewerImpl.cpp +++ b/src/slic3r/GUI/LibVGCode/src/ViewerImpl.cpp @@ -10,10 +10,11 @@ #include #include -#include +#include #include #include #include +#include namespace libvgcode { @@ -180,7 +181,7 @@ static Mat4x4 inverse(const Mat4x4& m) float det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12]; assert(det != 0.0f); - det = 1.0 / det; + det = 1.0f / det; std::array ret = {}; for (int i = 0; i < 16; ++i) { @@ -534,10 +535,10 @@ void ViewerImpl::load(GCodeInputData&& gcode_data) Vec3 position = v.position; if (move_type == EMoveType::Extrude) // push down extrusion vertices by half height to render them at the right z - position[2] -= 0.5 * v.height; + position[2] -= 0.5f * v.height; positions.emplace_back(position); - const float angle = atan2(prev_line[0] * this_line[1] - prev_line[1] * this_line[0], dot(prev_line, this_line)); + const float angle = std::atan2(prev_line[0] * this_line[1] - prev_line[1] * this_line[0], dot(prev_line, this_line)); heights_widths_angles.push_back({ v.height, v.width, angle }); } @@ -612,7 +613,7 @@ void ViewerImpl::update_enabled_entities() --range[0]; } - for (uint32_t i = range[0]; i < range[1]; ++i) { + for (size_t i = range[0]; i < range[1]; ++i) { const PathVertex& v = m_vertices[i]; if (!m_valid_lines_bitset[i] && !v.is_option()) @@ -637,9 +638,9 @@ void ViewerImpl::update_enabled_entities() continue; if (v.is_option()) - enabled_options.push_back(i); + enabled_options.push_back(static_cast(i)); else - enabled_segments.push_back(i); + enabled_segments.push_back(static_cast(i)); } m_enabled_segments_count = enabled_segments.size();