mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-18 04:08:02 -06:00
Introduction of a greedy Traveling Salesman Problem algorithm,
producing better shortest path estimate than the "closest next neighbor" heuristics. The new greedy algorithm utilizes KD tree for closest end point search, and builds a graph to detect loops. PerimeterGenerator newly uses the optimized TSP algorithm. ExtrusionEntity has been refactored / simplified.
This commit is contained in:
parent
110d5b9d56
commit
41495a932a
8 changed files with 797 additions and 61 deletions
|
@ -13,21 +13,28 @@ public:
|
|||
{}
|
||||
~MutablePriorityQueue() { clear(); }
|
||||
|
||||
inline void clear() { m_heap.clear(); }
|
||||
inline void reserve(size_t cnt) { m_heap.reserve(cnt); }
|
||||
inline void push(const T &item);
|
||||
inline void push(T &&item);
|
||||
inline void pop();
|
||||
inline T& top() { return m_heap.front(); }
|
||||
inline void remove(size_t idx);
|
||||
inline void update(size_t idx) { T item = m_heap[idx]; remove(idx); push(item); }
|
||||
void clear() { m_heap.clear(); }
|
||||
void reserve(size_t cnt) { m_heap.reserve(cnt); }
|
||||
void push(const T &item);
|
||||
void push(T &&item);
|
||||
void pop();
|
||||
T& top() { return m_heap.front(); }
|
||||
void remove(size_t idx);
|
||||
void update(size_t idx) { T item = m_heap[idx]; remove(idx); push(item); }
|
||||
|
||||
inline size_t size() const { return m_heap.size(); }
|
||||
inline bool empty() const { return m_heap.empty(); }
|
||||
size_t size() const { return m_heap.size(); }
|
||||
bool empty() const { return m_heap.empty(); }
|
||||
|
||||
using iterator = typename std::vector<T>::iterator;
|
||||
using const_iterator = typename std::vector<T>::const_iterator;
|
||||
iterator begin() { return m_heap.begin(); }
|
||||
iterator end() { return m_heap.end(); }
|
||||
const_iterator cbegin() const { return m_heap.cbegin(); }
|
||||
const_iterator cend() const { return m_heap.cend(); }
|
||||
|
||||
protected:
|
||||
inline void update_heap_up(size_t top, size_t bottom);
|
||||
inline void update_heap_down(size_t top, size_t bottom);
|
||||
void update_heap_up(size_t top, size_t bottom);
|
||||
void update_heap_down(size_t top, size_t bottom);
|
||||
|
||||
private:
|
||||
std::vector<T> m_heap;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue