mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 07:19:05 +08:00
Move IndexRange.hpp to LayerRegion.hpp and fix warnings
This commit is contained in:
parent
555424ffbb
commit
78cd2f9e68
@ -221,7 +221,6 @@ set(SLIC3R_SOURCES
|
|||||||
JumpPointSearch.cpp
|
JumpPointSearch.cpp
|
||||||
JumpPointSearch.hpp
|
JumpPointSearch.hpp
|
||||||
KDTreeIndirect.hpp
|
KDTreeIndirect.hpp
|
||||||
IndexRange.hpp
|
|
||||||
Layer.cpp
|
Layer.cpp
|
||||||
Layer.hpp
|
Layer.hpp
|
||||||
LayerRegion.hpp
|
LayerRegion.hpp
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
#ifndef slic3r_IndexRange_hpp_
|
|
||||||
#define slic3r_IndexRange_hpp_
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace Slic3r {
|
|
||||||
// Range of indices, providing support for range based loops.
|
|
||||||
template<typename T>
|
|
||||||
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<T>;
|
|
||||||
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<uint32_t>;
|
|
||||||
} // Slic3r
|
|
||||||
|
|
||||||
#endif // slic3r_IndexRange_hpp_
|
|
@ -17,7 +17,6 @@
|
|||||||
#include "Flow.hpp"
|
#include "Flow.hpp"
|
||||||
#include "SurfaceCollection.hpp"
|
#include "SurfaceCollection.hpp"
|
||||||
#include "ExtrusionEntityCollection.hpp"
|
#include "ExtrusionEntityCollection.hpp"
|
||||||
#include "IndexRange.hpp"
|
|
||||||
#include "LayerRegion.hpp"
|
#include "LayerRegion.hpp"
|
||||||
|
|
||||||
#include <boost/container/small_vector.hpp>
|
#include <boost/container/small_vector.hpp>
|
||||||
|
@ -279,7 +279,7 @@ void detect_bridge_directions(
|
|||||||
unsigned end_index{};
|
unsigned end_index{};
|
||||||
for (const ExpansionZone& expansion_zone: expansion_zones) {
|
for (const ExpansionZone& expansion_zone: expansion_zones) {
|
||||||
end_index += expansion_zone.expolygons.size();
|
end_index += expansion_zone.expolygons.size();
|
||||||
if (last_anchor_id < end_index) {
|
if (last_anchor_id < static_cast<int64_t>(end_index)) {
|
||||||
append(anchor_areas, to_polygons(expansion_zone.expolygons[last_anchor_id - start_index]));
|
append(anchor_areas, to_polygons(expansion_zone.expolygons[last_anchor_id - start_index]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "BoundingBox.hpp"
|
#include "BoundingBox.hpp"
|
||||||
#include "ExtrusionEntityCollection.hpp"
|
#include "ExtrusionEntityCollection.hpp"
|
||||||
#include "SurfaceCollection.hpp"
|
#include "SurfaceCollection.hpp"
|
||||||
#include "IndexRange.hpp"
|
|
||||||
#include "libslic3r/Algorithm/RegionExpansion.hpp"
|
#include "libslic3r/Algorithm/RegionExpansion.hpp"
|
||||||
|
|
||||||
|
|
||||||
@ -14,6 +13,41 @@ class Layer;
|
|||||||
using LayerPtrs = std::vector<Layer*>;
|
using LayerPtrs = std::vector<Layer*>;
|
||||||
class PrintRegion;
|
class PrintRegion;
|
||||||
|
|
||||||
|
// Range of indices, providing support for range based loops.
|
||||||
|
template<typename T>
|
||||||
|
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<T>;
|
||||||
|
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<uint32_t>;
|
||||||
|
|
||||||
using ExtrusionRange = IndexRange<uint32_t>;
|
using ExtrusionRange = IndexRange<uint32_t>;
|
||||||
using ExPolygonRange = IndexRange<uint32_t>;
|
using ExPolygonRange = IndexRange<uint32_t>;
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@ struct LayerRegionFixture {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST_CASE_METHOD(LayerRegionFixture, "test the surface expansion", "[LayerRegion]") {
|
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,
|
surfaces, stBottomBridge,
|
||||||
expansion_zones,
|
expansion_zones,
|
||||||
closing_radius,
|
closing_radius,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user