diff --git a/tests/algorithms/edge_split.cc b/tests/algorithms/edge_split.cc new file mode 100644 index 0000000000000000000000000000000000000000..d7d268ff3961fe279f81885f74471dc42809e1da --- /dev/null +++ b/tests/algorithms/edge_split.cc @@ -0,0 +1,38 @@ +#include <doctest.hh> + +#include <polymesh/Mesh.hh> +#include <polymesh/algorithms/edge_split.hh> +#include <polymesh/algorithms/remeshing/triangulate.hh> +#include <polymesh/objects/quad.hh> + +#include <typed-geometry/tg.hh> + +#include <glow-extras/viewer/view.hh> + +TEST_CASE("edge split") +{ + pm::Mesh m; + auto pos = m.vertices().make_attribute<tg::pos3>(); + + tg::rng rng; + auto s = 8; + pm::objects::add_quad(m, [&](auto v, float x, float y) { pos[v] = {x * s + uniform(rng, -.2f, .2f), 0, y * s + uniform(rng, -.2f, .2f)}; }, s, s); + + pm::triangulate_naive(m); + m.compactify(); + + pm::split_edges_trimesh(m, + [&](pm::edge_handle e) -> tg::optional<float> { + auto l = distance(pos[e.vertexA()], pos[e.vertexB()]); + if (l < 0.2f) + return {}; + return l; + }, + [&](pm::vertex_handle v, pm::halfedge_handle, pm::vertex_handle v_from, pm::vertex_handle v_to) { + pos[v] = mix(pos[v_from], pos[v_to], 0.5f); + // is OK! m.assert_consistency(); + }); + + auto v = view(pos); + view(lines(pos).line_width_world(0.003f)); +} diff --git a/tests/main.cc b/tests/main.cc index eb644ee9b63568a44664db037241036b3b72b771..b8ce090e3545fa0e3b25bd04f0365eeeae645348 100644 --- a/tests/main.cc +++ b/tests/main.cc @@ -2,9 +2,9 @@ #include <glow-extras/glfw/GlfwContext.hh> -int main(int argc, char **argv) +int main(int argc, char** argv) { - glow::glfw::GlfwContext ctx; + glow::glfw::GlfwContext glfw; doctest::Context context; context.applyCommandLine(argc, argv); diff --git a/tests/ranges/range-test.cc b/tests/ranges/range-test.cc index f5ce060b5da9e132a123d33c9634227d29490de3..8f59ddaa220b34b58de3e746cef82c2c19853885 100644 --- a/tests/ranges/range-test.cc +++ b/tests/ranges/range-test.cc @@ -34,4 +34,24 @@ TEST_CASE("Ranges.Basics") v.centroid = f.vertices().avg(pos); return v; }); + + // TODO !!!!!!!!! + // m.vertices().map(&tg::pos3::y); + // + // struct foo { + // float bar(); + // float baz(int); + // float baz2(pm::vertex_attribute<int> const&); + // }; + // auto f = m.vertices().make_attribute<foo>(); + // auto ia = m.vertices().make_attribute<int>(); + // f.map(&foo::bar); + // f.map(&foo::baz, 7); + // f.map(&foo::baz, ia); + // f.map(&foo::baz2, ia); + // f.map_to(ia, ...); + // auto el = m.edges().map(pm::edge_length, pos); + // m.edges().map([&](auto e) { return edge_length(e, pos); }); + + pos = m.vertices().map([&](pm::vertex_handle v) { return v.adjacent_vertices().avg(pos); }); }