Commit e372aab3 authored by Philip Trettner's avatar Philip Trettner
Browse files

Merge branch 'develop' into 'develop'

Added Cookbook examples

See merge request !18
parents 6dac0122 23c4e2a5
......@@ -17,3 +17,59 @@ Laplacian Smoothing with Feature Edges
Extracting Edges as Segments
// given:
// pm::Mesh m;
// pm::vertex_attribute<tg::pos3> pos;
// functional style
auto edges0 = m.edges().map([&](pm::edge_handle e) {
return tg::segment3(pos[e.vertexA()], pos[e.vertexB()]);
// or
// classical style
std::vector<tg::segment3> edges;
for (auto const& e : m.edges())
edges.emplace_back(pos[e.vertexA()], pos[e.vertexB()]);
Add Triangle Faces to Mesh
// given:
// std::vector<tg::triangle3> tris;
pm::Mesh m;
auto pos = pm::vertex_attribute<tg::pos3>(m);
for (auto const& tri : tris)
/// add vertices to topology
const auto vh0 = m.vertices().add();
const auto vh1 = m.vertices().add();
const auto vh2 = m.vertices().add();
/// add vertex positions
pos[vh0] = tri.pos0;
pos[vh1] = tri.pos1;
pos[vh2] = tri.pos2;
/// add face to topology
m.faces().add(vh0, vh1, vh2);
// note that this will generate a triangle soup only. to obtain a sound mesh, deduplicate it
// triangles that share a certain position will then be properly connected
pm::deduplicate(m, 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