diff --git a/src/libslic3r/MutablePriorityQueue.hpp b/src/libslic3r/MutablePriorityQueue.hpp index 68cd01859..cc1cae68c 100644 --- a/src/libslic3r/MutablePriorityQueue.hpp +++ b/src/libslic3r/MutablePriorityQueue.hpp @@ -354,7 +354,7 @@ inline void MutableSkipHeapPriorityQueue::max()); + m_index_setter(m_heap[1], std::numeric_limits::max()); } // Zero'th element is padding, thus non-empty queue must have at least two elements. if (m_heap.size() > 2) { diff --git a/src/libslic3r/QuadricEdgeCollapse.cpp b/src/libslic3r/QuadricEdgeCollapse.cpp index 94375ec9d..c5de1b0a7 100644 --- a/src/libslic3r/QuadricEdgeCollapse.cpp +++ b/src/libslic3r/QuadricEdgeCollapse.cpp @@ -151,10 +151,11 @@ void Slic3r::its_quadric_edge_collapse( statusfn(status_init_size); // convert from triangle index to mutable priority queue index - std::vector ti_2_mpqi(its.indices.size(), {0}); + std::vector ti_2_mpqi(its.indices.size(), {0}); auto setter = [&ti_2_mpqi](const Error &e, size_t index) { ti_2_mpqi[e.triangle_index] = index; }; auto less = [](const Error &e1, const Error &e2) -> bool { return e1.value < e2.value; }; - MutablePriorityQueue mpq(std::move(setter), std::move(less)); + auto mpq = make_miniheap_mutable_priority_queue(std::move(setter), std::move(less)); + //MutablePriorityQueue mpq(std::move(setter), std::move(less)); mpq.reserve(its.indices.size()); for (Error &error :errors) mpq.push(error); @@ -257,16 +258,14 @@ void Slic3r::its_quadric_edge_collapse( vi_top0, t1, ceis, e_infos_swap); // Change vertex - // Has to be set after subtract quadric its.vertices[vi0] = new_vertex0; // fix errors - must be after set neighbors - v_infos mpq.remove(ti_2_mpqi[ti1]); for (uint32_t ti : changed_triangle_indices) { size_t priority_queue_index = ti_2_mpqi[ti]; - auto iterator = mpq.begin() + priority_queue_index; TriangleInfo& t_info = t_infos[ti]; - *iterator = calculate_error(ti, its.indices[ti], its.vertices, v_infos, t_info.min_index); + mpq[priority_queue_index] = calculate_error(ti, its.indices[ti], its.vertices, v_infos, t_info.min_index); mpq.update(priority_queue_index); }