Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortamasmeszaros <meszaros.q@gmail.com>2022-06-07 17:20:17 +0300
committertamasmeszaros <meszaros.q@gmail.com>2022-06-07 17:20:17 +0300
commitf11f216f919b383bd0d5ca800150bd138b97ae5b (patch)
treee27f6b756eca253e05027b246922ddc2f7fd8b35
parentdb8a120953bf695ffef2324adb0a58475d6b3c23 (diff)
parent86ebe946d9eb9e35326ab77cd20334b965b23822 (diff)
Merge branch 'tm_fix_astar_msvc'
-rw-r--r--src/libslic3r/AStar.hpp10
-rw-r--r--src/libslic3r/MutablePriorityQueue.hpp10
-rw-r--r--tests/libslic3r/test_mutable_priority_queue.cpp2
3 files changed, 17 insertions, 5 deletions
diff --git a/src/libslic3r/AStar.hpp b/src/libslic3r/AStar.hpp
index 61c82157b..b35b6a4af 100644
--- a/src/libslic3r/AStar.hpp
+++ b/src/libslic3r/AStar.hpp
@@ -53,7 +53,7 @@ template<class T> struct TracerTraits_
template<class T>
using TracerNodeT = typename TracerTraits_<remove_cvref_t<T>>::Node;
-constexpr size_t Unassigned = size_t(-1);
+constexpr auto Unassigned = std::numeric_limits<size_t>::max();
template<class Tracer>
struct QNode // Queue node. Keeps track of scores g, and h
@@ -69,7 +69,11 @@ struct QNode // Queue node. Keeps track of scores g, and h
size_t p = Unassigned,
float gval = std::numeric_limits<float>::infinity(),
float hval = 0.f)
- : node{std::move(n)}, parent{p}, queue_id{Unassigned}, g{gval}, h{hval}
+ : node{std::move(n)}
+ , parent{p}
+ , queue_id{InvalidQueueID}
+ , g{gval}
+ , h{hval}
{}
};
@@ -154,7 +158,7 @@ bool search_route(const Tracer &tracer,
// The cache needs to be updated either way
prev_nd = qsucc_nd;
- if (queue_id == decltype(qopen)::invalid_id())
+ if (queue_id == InvalidQueueID)
// was in closed or unqueued, rescheduling
qopen.push(succ_id);
else // was in open, updating
diff --git a/src/libslic3r/MutablePriorityQueue.hpp b/src/libslic3r/MutablePriorityQueue.hpp
index b45b8cfff..fd3e7ac2d 100644
--- a/src/libslic3r/MutablePriorityQueue.hpp
+++ b/src/libslic3r/MutablePriorityQueue.hpp
@@ -7,6 +7,10 @@
#include <limits>
#include <cstdlib> // adds size_t (without std::)
+namespace Slic3r {
+
+constexpr auto InvalidQueueID = std::numeric_limits<size_t>::max();
+
template<typename T, typename IndexSetter, typename LessPredicate, const bool ResetIndexWhenRemoved = false>
class MutablePriorityQueue
{
@@ -41,7 +45,7 @@ public:
bool empty() const { return m_heap.empty(); }
T& operator[](std::size_t idx) noexcept { return m_heap[idx]; }
const T& operator[](std::size_t idx) const noexcept { return m_heap[idx]; }
- static constexpr size_t invalid_id() { return std::numeric_limits<size_t>::max(); }
+ static constexpr size_t invalid_id() { return InvalidQueueID; }
using iterator = typename std::vector<T>::iterator;
using const_iterator = typename std::vector<T>::const_iterator;
@@ -291,7 +295,7 @@ public:
bool empty() const { return m_heap.empty(); }
T& operator[](std::size_t idx) noexcept { assert(! address::is_padding(idx)); return m_heap[idx]; }
const T& operator[](std::size_t idx) const noexcept { assert(! address::is_padding(idx)); return m_heap[idx]; }
- static constexpr size_t invalid_id() { return std::numeric_limits<size_t>::max(); }
+ static constexpr size_t invalid_id() { return InvalidQueueID; }
protected:
void update_heap_up(size_t top, size_t bottom);
@@ -450,4 +454,6 @@ inline void MutableSkipHeapPriorityQueue<T, LessPredicate, IndexSetter, blocking
}
}
+} // namespace Slic3r
+
#endif /* slic3r_MutablePriorityQueue_hpp_ */
diff --git a/tests/libslic3r/test_mutable_priority_queue.cpp b/tests/libslic3r/test_mutable_priority_queue.cpp
index 626b0388d..7e31b57c7 100644
--- a/tests/libslic3r/test_mutable_priority_queue.cpp
+++ b/tests/libslic3r/test_mutable_priority_queue.cpp
@@ -4,6 +4,8 @@
#include "libslic3r/MutablePriorityQueue.hpp"
+using namespace Slic3r;
+
// based on https://raw.githubusercontent.com/rollbear/prio_queue/master/self_test.cpp
// original source Copyright Björn Fahller 2015, Boost Software License, Version 1.0, http://www.boost.org/LICENSE_1_0.txt