Commit ae5c815a authored by Philip Trettner's avatar Philip Trettner

merge, added edge split test

parent 9674de5c
#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));
}
......@@ -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);
......
......@@ -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); });
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment