diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 959e9d9bd7..a8268e226d 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -221,7 +221,6 @@ set(SLIC3R_SOURCES JumpPointSearch.cpp JumpPointSearch.hpp KDTreeIndirect.hpp - IndexRange.hpp Layer.cpp Layer.hpp LayerRegion.hpp diff --git a/src/libslic3r/IndexRange.hpp b/src/libslic3r/IndexRange.hpp deleted file mode 100644 index 1c8b69ec87..0000000000 --- a/src/libslic3r/IndexRange.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef slic3r_IndexRange_hpp_ -#define slic3r_IndexRange_hpp_ - -#include -#include - -namespace Slic3r { -// Range of indices, providing support for range based loops. -template -class IndexRange -{ -public: - IndexRange(T ibegin, T iend) : m_begin(ibegin), m_end(iend) {} - IndexRange() = default; - - // Just a bare minimum functionality iterator required by range-for loop. - class Iterator { - public: - T operator*() const { return m_idx; } - bool operator!=(const Iterator &rhs) const { return m_idx != rhs.m_idx; } - void operator++() { ++ m_idx; } - private: - friend class IndexRange; - Iterator(T idx) : m_idx(idx) {} - T m_idx; - }; - - Iterator begin() const { assert(m_begin <= m_end); return Iterator(m_begin); }; - Iterator end() const { assert(m_begin <= m_end); return Iterator(m_end); }; - - bool empty() const { assert(m_begin <= m_end); return m_begin >= m_end; } - T size() const { assert(m_begin <= m_end); return m_end - m_begin; } - -private: - // Index of the first extrusion in LayerRegion. - T m_begin { 0 }; - // Index of the last extrusion in LayerRegion. - T m_end { 0 }; -}; - -template class IndexRange; -} // Slic3r - -#endif // slic3r_IndexRange_hpp_ diff --git a/src/libslic3r/Layer.hpp b/src/libslic3r/Layer.hpp index d926edb3e9..6b45c38925 100644 --- a/src/libslic3r/Layer.hpp +++ b/src/libslic3r/Layer.hpp @@ -17,7 +17,6 @@ #include "Flow.hpp" #include "SurfaceCollection.hpp" #include "ExtrusionEntityCollection.hpp" -#include "IndexRange.hpp" #include "LayerRegion.hpp" #include diff --git a/src/libslic3r/LayerRegion.cpp b/src/libslic3r/LayerRegion.cpp index d939bd4c97..fc547bba63 100644 --- a/src/libslic3r/LayerRegion.cpp +++ b/src/libslic3r/LayerRegion.cpp @@ -279,7 +279,7 @@ void detect_bridge_directions( unsigned end_index{}; for (const ExpansionZone& expansion_zone: expansion_zones) { end_index += expansion_zone.expolygons.size(); - if (last_anchor_id < end_index) { + if (last_anchor_id < static_cast(end_index)) { append(anchor_areas, to_polygons(expansion_zone.expolygons[last_anchor_id - start_index])); break; } diff --git a/src/libslic3r/LayerRegion.hpp b/src/libslic3r/LayerRegion.hpp index 6b6b89e565..fa8bb8d988 100644 --- a/src/libslic3r/LayerRegion.hpp +++ b/src/libslic3r/LayerRegion.hpp @@ -4,7 +4,6 @@ #include "BoundingBox.hpp" #include "ExtrusionEntityCollection.hpp" #include "SurfaceCollection.hpp" -#include "IndexRange.hpp" #include "libslic3r/Algorithm/RegionExpansion.hpp" @@ -14,6 +13,41 @@ class Layer; using LayerPtrs = std::vector; class PrintRegion; +// Range of indices, providing support for range based loops. +template +class IndexRange +{ +public: + IndexRange(T ibegin, T iend) : m_begin(ibegin), m_end(iend) {} + IndexRange() = default; + + // Just a bare minimum functionality iterator required by range-for loop. + class Iterator { + public: + T operator*() const { return m_idx; } + bool operator!=(const Iterator &rhs) const { return m_idx != rhs.m_idx; } + void operator++() { ++ m_idx; } + private: + friend class IndexRange; + Iterator(T idx) : m_idx(idx) {} + T m_idx; + }; + + Iterator begin() const { assert(m_begin <= m_end); return Iterator(m_begin); }; + Iterator end() const { assert(m_begin <= m_end); return Iterator(m_end); }; + + bool empty() const { assert(m_begin <= m_end); return m_begin >= m_end; } + T size() const { assert(m_begin <= m_end); return m_end - m_begin; } + +private: + // Index of the first extrusion in LayerRegion. + T m_begin { 0 }; + // Index of the last extrusion in LayerRegion. + T m_end { 0 }; +}; + +template class IndexRange; + using ExtrusionRange = IndexRange; using ExPolygonRange = IndexRange; diff --git a/tests/libslic3r/test_layer_region.cpp b/tests/libslic3r/test_layer_region.cpp index c35d18e776..0f6dfb7cba 100644 --- a/tests/libslic3r/test_layer_region.cpp +++ b/tests/libslic3r/test_layer_region.cpp @@ -73,9 +73,9 @@ struct LayerRegionFixture { }; TEST_CASE_METHOD(LayerRegionFixture, "test the surface expansion", "[LayerRegion]") { - float custom_angle = 1.234; + const double custom_angle{1.234f}; - Surfaces result{expand_merge_surfaces( + const Surfaces result{expand_merge_surfaces( surfaces, stBottomBridge, expansion_zones, closing_radius,