Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip Trettner
polymesh
Commits
e372aab3
Commit
e372aab3
authored
Mar 04, 2020
by
Philip Trettner
Browse files
Merge branch 'develop' into 'develop'
Added Cookbook examples See merge request
!18
parents
6dac0122
23c4e2a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
docs/cookbook.rst
View file @
e372aab3
...
...
@@ -17,3 +17,59 @@ Laplacian Smoothing with Feature Edges
--------------------------------------
TODO
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()]);
}).to_vector();
// or
// classical style
std::vector<tg::segment3> edges;
edges.reserve(m.edges().size());
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);
m.compactify();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment