Expand description
An indexed triangle mesh held for editing, with the topology queries edits need: which faces meet across each edge, the connected pieces, and the open rims.
§Half-edges
Side k of face f is half-edge 3 f + k, running from the face’s
corner k to corner k + 1. Two half-edges are twins when they run one
edge opposite ways and the faces are joined across it; a half-edge with
no twin lies on a rim.
§Points, and the vertices meeting at them
Every vertex is a copy of a point: the welded vertex of the source it came from. Faces meet across an edge when their corners name the same two points, and are joined across it by this rule, read only from the faces on that edge:
- two faces running it opposite ways are joined;
- two running it the same way are not, and the edge is open on both;
- three or more are taken in turn about the edge, and each one joined to the next where the space between them lies behind both, as the material of a closed body does. Two closed bodies sharing an edge each close on their own; a fin is joined to neither side.
The faces about a point, joined across the edges at it, make fans. A
point one fan meets is one vertex; a point several fans meet, as at the
centre of a bowtie or where two bodies touch, is split into one vertex
per fan, each a copy of the point at its position, so that every vertex
has one fan and every rim one way on. Editable::non_manifold reports
the copies, and the ends of the edges the rule could not join cleanly.
§What edits keep
Face and vertex numbers are stable: an edit never renumbers what it
leaves. A removed face keeps its number, unused; face f below the
source’s triangle count is source triangle f. After an edit, the fans
about a point it touched, taken in the order of their lowest-numbered
half-edge, each keep the lowest-numbered vertex their corners held that
no fan before took, and a fan left without one takes a new copy of the
point, numbered after every vertex there is. So a vertex split keeps its
number on one side, fans joined again share the lowest number among
them, and undoing an edit, flipping a face back, gives back the numbers
it had. A vertex an edit leaves with no face is gone.
Editable::to_triangulation is the compaction step: it numbers the
vertices left in order, then the faces left in order.
§Source vertices
Every vertex and every copy of it remembers the source vertices it came
from, through every edit: Editable::source_vertices. A vertex of
the source has one, the vertex it was welded onto. A collapse, by
Editable::simplify or by Editable::offset repairing a fold,
leaves the vertex it keeps with the source vertices of both. A vertex
an edit makes rather than carries, on an edge it cut or in a hole it
filled, has none, and adds none to a vertex it is merged with.
Editable::source_vertex names the source vertex where there is
exactly one.
A marking of the source’s vertices selects the vertices all of whose
source vertices it marks, and at least one:
Editable::region_from_sources turns it into the per-vertex region
that Editable::offset and Editable::smooth take. Provenance is
only ever carried; nothing is matched by position.
Re-exports§
pub use cut::Cap;pub use cut::CutReport;pub use cut::Side;pub use fill::Fairing;pub use fill::Fill;pub use fill::FillReport;pub use fill::OPTIMAL_UP_TO;pub use offset::OFFSET_EDGE_ANGLE;pub use offset::OFFSET_FARTHEST;pub use offset::OffsetReport;pub use simplify::SimplifyReport;pub use smooth::PASSES;pub use smooth::Smooth;pub use smooth::SmoothReport;
Modules§
- cut
- Cutting an editable mesh by a plane, and capping the cut flat.
- fill
- Filling a rim of an editable mesh with a patch of new faces.
- offset
- Offsetting an editable mesh: every face moved along its outward normal by one distance, the folds that leaves repaired.
- simplify
- Decimating an editable mesh in place, its source vertices carried.
- smooth
- Smoothing an editable mesh by projecting each vertex onto a local quadric, keeping creases sharp where asked.
Structs§
- Component
- A connected piece of the mesh: faces joined across edges.
- Editable
- An indexed triangle mesh held as half-edges, for editing.
- Rim
- A closed loop of open edges.
- RimId
- A rim’s name: its lowest-numbered half-edge, the first of its
Rim::edges. An edit that leaves the rim’s faces as they are leaves its name. One that adds faces on it, or removes or flips its faces, may give it another.