Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polymesh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zain Selman
polymesh
Commits
908d2c3a
Commit
908d2c3a
authored
5 years ago
by
Zain Selman
Browse files
Options
Downloads
Patches
Plain Diff
adds two examples to the cookbook. they might too specific
parent
ea8a9384
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/cookbook.rst
+65
-0
65 additions, 0 deletions
docs/cookbook.rst
with
65 additions
and
0 deletions
docs/cookbook.rst
+
65
−
0
View file @
908d2c3a
...
...
@@ -17,3 +17,68 @@ 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().to_vector())
edges.emplace_back(tg::segment3(pos[e.vertexA()], pos[e.vertexB()]));
Add Triangle Faces to Mesh
--------------------------
::
pm::Mesh m;
auto pos = pm::vertex_attribute<tg::pos3>(m);
const auto n = 10;
std::vector<tg::triangle3> tris;
tris.reserve(n);
// some box to sample random positions
const auto box = tg::box3(tg::aabb3({-n, -n, -n}, {n, n, n}));
tg::rng rng;
// create random triangles
for (auto i = 0u; i < n; ++i)
tris.emplace_back(tg::triangle3(tg::uniform(rng, box), tg::uniform(rng, box), tg::uniform(rng, box)));
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();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment