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:
authorFilip Sykala <filip.sykala@prusa3d.cz>2021-07-19 10:17:50 +0300
committerFilip Sykala <filip.sykala@prusa3d.cz>2021-07-19 10:17:50 +0300
commitaf526c54f4b421fb7dda636b86d2202b635ba80a (patch)
tree664d86b1db15b37164e943e71d18e0e33f2e4821 /tests/libslic3r
parent756d2694eb2035ce4bbbb86aa81f8e277ef09692 (diff)
Add simplification GUI
Diffstat (limited to 'tests/libslic3r')
-rw-r--r--tests/libslic3r/test_indexed_triangle_set.cpp3
-rw-r--r--tests/libslic3r/test_mutable_priority_queue.cpp101
2 files changed, 103 insertions, 1 deletions
diff --git a/tests/libslic3r/test_indexed_triangle_set.cpp b/tests/libslic3r/test_indexed_triangle_set.cpp
index e079cb302..06ca3635e 100644
--- a/tests/libslic3r/test_indexed_triangle_set.cpp
+++ b/tests/libslic3r/test_indexed_triangle_set.cpp
@@ -231,9 +231,10 @@ TEST_CASE("Reduce one edge by Quadric Edge Collapse", "[its]")
}
#include "test_utils.hpp"
-TEST_CASE("Symplify mesh by Quadric edge collapse to 5%", "[its]")
+TEST_CASE("Simplify mesh by Quadric edge collapse to 5%", "[its]")
{
TriangleMesh mesh = load_model("frog_legs.obj");
+ //TriangleMesh mesh; load_obj("C:/Users/filip/Documents/models/scarecrow_torso.obj", &mesh);
double original_volume = its_volume(mesh.its);
uint32_t wanted_count = mesh.its.indices.size() * 0.05;
REQUIRE_FALSE(mesh.empty());
diff --git a/tests/libslic3r/test_mutable_priority_queue.cpp b/tests/libslic3r/test_mutable_priority_queue.cpp
index 37b244432..ece655365 100644
--- a/tests/libslic3r/test_mutable_priority_queue.cpp
+++ b/tests/libslic3r/test_mutable_priority_queue.cpp
@@ -339,3 +339,104 @@ TEST_CASE("Mutable priority queue - reshedule first", "[MutableSkipHeapPriorityQ
}
}
}
+
+TEST_CASE("Mutable priority queue - first pop", "[MutableSkipHeapPriorityQueue]")
+{
+ struct MyValue{
+ int id;
+ float val;
+ };
+ size_t count = 50000;
+ std::vector<size_t> idxs(count, {0});
+ std::vector<bool> dels(count, false);
+ auto q = make_miniheap_mutable_priority_queue<MyValue, 16, true>(
+ [&](MyValue &v, size_t idx) {
+ idxs[v.id] = idx;
+ },
+ [](MyValue &l, MyValue &r) { return l.val < r.val; });
+ q.reserve(count);
+ for (size_t id = 0; id < count; id++) {
+ MyValue mv;
+ mv.id = id;
+ mv.val = rand();
+ q.push(mv);
+ }
+ MyValue it = q.top(); // copy
+ q.pop();
+ bool valid = (it.id != 0) && (idxs[0] < 3 * count);
+ CHECK(valid);
+}
+
+TEST_CASE("Mutable priority queue complex", "[MutableSkipHeapPriorityQueue]")
+{
+ struct MyValue {
+ int id;
+ float val;
+ };
+ size_t count = 5000;
+ std::vector<size_t> idxs(count, {0});
+ std::vector<bool> dels(count, false);
+ auto q = make_miniheap_mutable_priority_queue<MyValue, 16, true>(
+ [&](MyValue &v, size_t idx) { idxs[v.id] = idx; },
+ [](MyValue &l, MyValue &r) { return l.val < r.val; });
+ q.reserve(count);
+
+ auto rand_val = [&]()->float { return (rand() % 53) / 10.f; };
+ int ord = 0;
+ for (size_t id = 0; id < count; id++) {
+ MyValue mv;
+ mv.id = ord++;
+ mv.val = rand_val();
+ q.push(mv);
+ }
+ auto check = [&]()->bool{
+ for (size_t i = 0; i < idxs.size(); ++i) {
+ if (dels[i]) continue;
+ size_t qid = idxs[i];
+ if (qid > 3*count) {
+ return false;
+ }
+ MyValue &mv = q[qid];
+ if (mv.id != i) {
+ return false; // ERROR
+ }
+ }
+ return true;
+ };
+
+ CHECK(check()); // initial check
+
+ auto get_valid_id = [&]()->int {
+ int id = 0;
+ do {
+ id = rand() % count;
+ } while (dels[id]);
+ return id;
+ };
+ for (size_t i = 0; i < 100; i++) {
+ MyValue it = q.top(); // copy
+ q.pop();
+ dels[it.id] = true;
+ CHECK(check());
+ if (i % 20 == 0) {
+ it.val = rand_val();
+ q.push(it);
+ dels[it.id] = false;
+ CHECK(check());
+ continue;
+ }
+
+ int id = get_valid_id();
+ q.remove(idxs[id]);
+ dels[id] = true;
+ CHECK(check());
+ for (size_t j = 0; j < 5; j++) {
+ int id = get_valid_id();
+ size_t qid = idxs[id];
+ MyValue &mv = q[qid];
+ mv.val = rand_val();
+ q.update(qid);
+ CHECK(check());
+ }
+ }
+}