Skip to main content

Module triangulate

Module triangulate 

Source
Expand description

Triangulating a face.

The second half of tessellation. A face is a trimmed region of a surface, so the triangulation is built in the surface’s (u, v) parameter space (where the region is an ordinary polygon with holes) and then lifted back into space by evaluating the surface at each vertex.

§Why parameter space

Triangulating in 3D would mean deciding which side of a curved boundary a point falls on, in space, which is the point-in-solid problem. In parameter space the boundary is a closed 2D polygon and the question is a winding count. The surface does the rest.

The cost is that parameter space is distorted: equal steps in (u, v) cover very different distances near a sphere’s pole than near its equator. So the interior points are chosen by measuring deflection in space and the triangulation is done in parameter space: measuring where the answer matters, connecting where it is easy.

§Watertightness

A face’s boundary points come from discretizing the edge’s 3D curve and evaluating the pcurve at those same parameters. Two faces sharing an edge therefore place their boundary vertices at identical spatial positions, and the join has no gap. Discretizing each face’s pcurve independently would give each face its own idea of where the edge runs, and the seams would show.

Structs§

FaceMeshCache
Face meshes kept by what each face is, for a caller that meshes a run of models in which most faces recur unchanged, as a construction retried after a few of its faces changed does.

Functions§

edge_chords_for
The chords the faces below shape agree to draw their shared edges to.
face_boundary
A face’s trimming boundary, in its surface’s parameter space.
face_boundary_in_chart
face_boundary, each ring keeping within the chord of its edges in the chart too, read in space through the surface’s tangent scales: a point on an edge then lies within the chord of its ring however much more the edge bends in the chart than in space.
face_boundary_in_chart_met
face_boundary_in_chart where every edge’s polyline honours the deflection, and None where one reached Deflection::max_segments first: rings that keep within the chord are what a point can be placed against at that chord.
face_meshes_for
Every face below shape in exploration order, each with what triangulate_face_with answers for it with the chords the faces agree on (what edge_chords_for answers), and those chords: the agreement and the meshes drawn in one pass. A face kept has drawn before to the same chords is taken from it.
inside_boundary
Whether a point in parameter space lies inside the region rings bound.
inside_boundary_with
As inside_boundary, with the predicate implementation named.
open_chart_ring
One wire’s trimming ring on a face whose chart neither repeats nor closes on itself, as face_boundary_in_chart draws it among the face’s other rings; None where the wire leaves no ring there.
polyline_of_edge
Discretize an edge into a polyline in space, for display or coarse queries.
triangle_normal
The unit normal of a triangle, or None if it is degenerate.
triangulate
Triangulate every face below a shape, welded into one mesh.
triangulate_face
Triangulate one face.
triangulate_face_kept
As triangulate_face, taking the face from kept where it drew this face at this deflection before, and keeping what it draws there.
triangulate_face_with
As triangulate_face, with the edge chords the shape agreed on (the answer of edge_chords_for), so the face’s boundary matches its neighbours’ point for point along every edge the map names.
triangulate_with_chords
As triangulate, with the edge chords the faces agreed on: what edge_chords_for answers for the same shape and deflection, without drawing every face a second time to find it.
triangulate_with_face_meshes
As triangulate_with_chords, with every face’s own mesh beside the welded whole: each face below shape in exploration order, and what triangulate_face_with answers for it with the returned chords. The whole is welded from those same meshes, so they are drawn once. A face kept has drawn before to the same chords is taken from it.

Type Aliases§

EdgeChords
The chord each edge is to be drawn to, by edge node index, where a face wants its edges finer than the caller’s chord: what every face sharing an edge has to agree on, or their meshes disagree along it.
FaceMesh
A face and its mesh, or why it would not draw.