Commit 86aacb62 authored by Philip Trettner's avatar Philip Trettner
Browse files

more docs

parent 1364013e
......@@ -60,6 +60,145 @@ A small helper that merges vertices based on a user criterion.
.. doxygenfunction:: polymesh::deduplicate
Delaunay
--------
An incomplete collection of algorithms for Delaunay triangulations.
::
#include <polymesh/algorithms/delaunay.hh>
pm::Mesh m;
auto pos = m.vertices().make_attribute<tg::pos3>();
load(...);
// makes mesh surface delaunay via flipping
pm::make_delaunay(m, pos);
.. doxygenfunction:: polymesh::make_delaunay
There is also a 2D version that starts with a vertex-only mesh and creates faces via 2D Delaunay:
.. doxygenfunction:: polymesh::create_delaunay_triangulation
Edge Split
----------
A generic edge splitting routine.
::
#include <polymesh/algorithms/edge_split.hh>
pm::Mesh m;
auto pos = m.vertices().make_attribute<tg::pos3>();
load(...);
auto const target_edge_length = 0.1f;
// split all edges longer than 0.1 in descending length order
pm::split_edges_trimesh(m,
// function to provide a priority value and signal if the edge should not be split
[&](pm::edge_handle e) -> tg::optional<float> {
auto const l = pm::edge_length(e, pos);
if (l < target_edge_length)
return {};
return l;
},
// a function performing the split
[&](pm::vertex_handle v, pm::halfedge_handle, pm::vertex_handle v_from, pm::vertex_handle v_to) {
pos[v] = mix(pos[v_to], pos[v_from], 0.5f);
// .. and propagate other attributes if desire
});
For polygonal meshes, splitting edges can either be very simple (only insert a vertex) or complex (re-triangulate polygons, ensure user constraints).
The following function provides a generic interface:
.. doxygenfunction:: polymesh::split_edges
If the mesh is known to be triangular (and should stay triangular), then the split is well defined and the split function only has to fill in missing attributes:
.. doxygenfunction:: polymesh::split_edges_trimesh
These functions guarantee that meshes stay *compact* (see :ref:`memory-model`) and are, in general, quite fast.
Normal Estimation
-----------------
A simple estimation algorithm for computing smoothed vertex normals.
Edges that should not be smoothed over can be declared in a generic interface.
::
#include <polymesh/algorithms/normal_estimation.hh>
pm::Mesh m;
auto pos = m.vertices().make_attribute<tg::pos3>();
load(...);
auto fnormals = pm::face_normals(pos);
// compute smooth vertex normals without smoothing over more than 60° edges
auto vnormals = pm::normal_estimation(fnormals, [&](pm::edge_handle e) {
return dot(fnormals[e.faceA()], fnormals[e.faceB()]) < 0.5;
});
// .. or just smooth over everything
auto vnormals2 = pm::normal_estimation(pos, [](auto) { return false; });
This function has two versions, one based on face normals, the other on vertex positions (which internally computes face normals):
.. doxygenfunction:: polymesh::normal_estimation(face_attribute<Vec3> const&, IsHardEdgeF&&)
.. doxygenfunction:: polymesh::normal_estimation(vertex_attribute<Pos3> const&, IsHardEdgeF&&)
Normalization
-------------
An incomplete collection of helpers for ensuring different normalization constraints.
::
#include <polymesh/algorithms/normalize.hh>
pm::Mesh m;
auto pos = m.vertices().make_attribute<tg::pos3>();
load(...);
// translates and uniformly rescales the mesh
// so it fits in the [-1, 1] cube and is centered at the origin
pm::normalize(pos);
.. doxygenfunction:: polymesh::normalize
Cache Optimization
------------------
An incomplete collection of algorithms that reorder the internal memory layout to improve cache coherence in different scenarios.
::
#include <polymesh/algorithms/cache-optimization.hh>
pm::Mesh m;
load(...);
// reorder memory layout for improved performance when performing vertex-traversal algorithms
pm::optimize_for_vertex_traversal(m);
.. doxygenfunction:: polymesh::optimize_for_face_traversal
.. doxygenfunction:: polymesh::optimize_for_vertex_traversal
TODO: preserve line breaks in doxygen
TODO: decimate, dedup, delaunay, edge_split, subdivision, interpolation, iteration, normal-estimation, normalize, operations, optimizations, sampling, smoothing, stats, topology, tracing, triangulate
TODO: decimate, subdivision, interpolation, iteration, sampling, smoothing, stats, topology, tracing, triangulate
......@@ -43,6 +43,7 @@ Functions returning a mesh with new ownership should use ``std::unique_ptr<pm::M
:func:`polymesh::Mesh::create` is a static helper function to create a ``unique_ptr<Mesh>`` though the typical way to just use ``pm::Mesh`` as a member or as a local variable.
.. _memory-model:
Memory Model
------------
......
......@@ -215,6 +215,40 @@ Algorithms
.. doxygenfunction:: polymesh::deduplicate
.. doxygenfunction:: polymesh::make_delaunay
.. doxygenfunction:: polymesh::create_delaunay_triangulation
.. doxygenfunction:: polymesh::split_edges
.. doxygenfunction:: polymesh::split_edges_trimesh
.. doxygenfunction:: polymesh::normal_estimation(face_attribute<Vec3> const&, IsHardEdgeF&&)
.. doxygenfunction:: polymesh::normal_estimation(vertex_attribute<Pos3> const&, IsHardEdgeF&&)
.. doxygenfunction:: polymesh::normalize
.. doxygenfunction:: polymesh::remove_faces
.. doxygenfunction:: polymesh::remove_edges_and_faces
.. doxygenfunction:: polymesh::optimize_for_face_traversal
.. doxygenfunction:: polymesh::optimize_for_vertex_traversal
.. doxygenfunction:: polymesh::optimize_edges_for_faces
.. doxygenfunction:: polymesh::optimize_vertices_for_faces
.. doxygenfunction:: polymesh::optimize_edges_for_vertices
.. doxygenfunction:: polymesh::optimize_faces_for_vertices
.. doxygenfunction:: polymesh::cache_coherent_face_layout
.. doxygenfunction:: polymesh::cache_coherent_vertex_layout
Low-Level API
-------------
......
......@@ -15,6 +15,7 @@
// - intersections
// - statistics
#include "algorithms/cache-optimization.hh"
#include "algorithms/components.hh"
#include "algorithms/decimate.hh"
#include "algorithms/deduplicate.hh"
......@@ -24,7 +25,6 @@
#include "algorithms/iteration.hh"
#include "algorithms/normalize.hh"
#include "algorithms/operations.hh"
#include "algorithms/optimization.hh"
#include "algorithms/sampling.hh"
#include "algorithms/smoothing.hh"
#include "algorithms/stats.hh"
......
#include "optimization.hh"
#include "cache-optimization.hh"
#include <polymesh/detail/permutation.hh>
#include <polymesh/detail/random.hh>
......
......@@ -5,7 +5,7 @@
namespace polymesh
{
// Applies a translation and a uniform rescaling such that the mesh is centerd at (0,0,0) and withing the [-1 .. 1] cube
/// Applies a translation and a uniform rescaling such that the mesh is centerd at (0,0,0) and within the [-1 .. 1] cube
template <class Pos3>
void normalize(vertex_attribute<Pos3>& pos)
{
......
Supports Markdown
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