Algorithm Search⌘K

Techniqueadvanced

Boundary recovery in 3D meshing

Also called constraint recovery, George-Hecht-Saltel boundary recovery.

Restores the boundary edges and faces missing from a Delaunay tetrahedralization by flips and Steiner points, so the mesh conforms to the domain.

Boundary recovery is the step of a Delaunay tetrahedral mesher that makes the mesh contain the boundary. A mesher first builds the Delaunay tetrahedralization of the boundary vertices, for example with the Bowyer-Watson algorithm. Some boundary edges and triangles are then missing, because the Delaunay tetrahedralization does not know about them. In the plane they can always be put back by edge flips, with no new vertices. In space they cannot: Schönhardt's polyhedron has no tetrahedralization at all, and deciding whether a polyhedron has one is NP-complete. So every 3D method adds Steiner points somewhere. George, Hecht and Saltel's 1991 method, the classic one, swaps edges and faces and adds points when swaps get stuck; it works well and has no guarantee. Shewchuk's edge protection (2002) is a proved bound: it adds points only on the input segments, every new piece is at least a quarter of the local feature size long, and then the facets come back with no further points by the existence theorem for the constrained Delaunay tetrahedralization. TetGen uses the CDT approach of Si and Gärtner.

In plain words

Imagine the boundary of a part as a set of corner points, edges and flat faces. Put all the corner points into a Delaunay mesh. Most boundary edges show up as mesh edges by themselves, but an edge that passes too close to another edge or a corner usually does not.

The fix is to break such an edge into shorter pieces. A short piece has a small sphere around it, and once the sphere is free of other points, the piece is guaranteed to be in the Delaunay mesh. Where two edges meet at a sharp angle, first cut both near the corner with a small sphere, so that halving never chases the corner forever. When every boundary edge piece is in the mesh in this strong sense, a theorem says the faces can be filled in with no more new points, using the constrained Delaunay tetrahedralization.

When it applies

  • The input is a piecewise linear complex (PLC) in 3D: vertices, segments and planar facets, for example a triangulated surface from CAD.
  • The mesher is Delaunay based, so the volume is filled starting from the Delaunay tetrahedralization of the boundary vertices, as in tetrahedral Delaunay refinement.
  • The input may be in any position. Segments may pass close to each other and meet at small angles. Edge protection handles both, at the cost of more points.
  • Steiner points on the boundary are acceptable, or they will be moved off it later. If the input surface must stay unchanged, see the TetGen -Y option under Variations.

The template

The template below is the segment recovery step of Shewchuk's method, edge protection, as in the implementation. A subsegment is strongly Delaunay if some sphere through its two endpoints has every other vertex strictly outside; a strongly Delaunay segment is an edge of every Delaunay tetrahedralization. The local feature size lfs(u)\mathrm{lfs}(u) of a point uu is the radius of the smallest ball around uu that meets two input vertices or segments that do not touch each other. For an input vertex vv it is the distance from vv to the nearest other vertex or segment not containing vv. Facets are ignored.

  1. EDGE-PROTECT(vertices, segments)
  2. 1for each vertex v where two segments meet at less than 90 degrees: mark both segments clipped at v
  3. 2for each such v: r_v ← min(lfs(v), ℓ_v/3, 2 d_v/3)
  4. 3for each segment e clipped at v: insert the point where the sphere S(v, r_v) cuts e
  5. 4test every subsegment for being strongly Delaunay
  6. 5while some subsegment s is not strongly Delaunay
  7. 6insert the midpoint of s and retest the subsegments whose empty sphere contains it
  8. 7return the vertices and the subsegments

Here ℓv\ell_v is the length of the shortest segment clipped at vv, and dvd_v is the length of the shortest segment at vv whose other end is clipped (dv=∞d_v = \infty if there is none). The pieces from vv to the points of line L3 are the ends. After EDGE-PROTECT, the second step builds the CDT of the augmented PLC, by gift wrapping, by a sweep, or by inserting the facets one at a time.

Claim 1 (proved here: the ends). Every end at vv has length at least lfs(v)/3\mathrm{lfs}(v)/3, so ∣e∣≥lfs(u)/4|e| \ge \mathrm{lfs}(u)/4 for every point uu of it. Every end is strongly Delaunay after line L3 and stays so until line L7, so line L6 never splits an end. The middle piece of a segment tt clipped at both ends has length at least ∣t∣/3≥lfs(u)/3|t|/3 \ge \mathrm{lfs}(u)/3 for every uu in it.

Proof. Each candidate in line L2 is at least lfs(v)/3\mathrm{lfs}(v)/3: segment lengths at vv are at least lfs(v)\mathrm{lfs}(v), because the far endpoint is another vertex. So the end has length rv≥lfs(v)/3r_v \ge \mathrm{lfs}(v)/3. The function lfs\mathrm{lfs} is 1-Lipschitz, so for uu in the end, lfs(u)≤lfs(v)+∣e∣≤4∣e∣\mathrm{lfs}(u) \le \mathrm{lfs}(v) + |e| \le 4|e|.

Let the end run from vv to xx, with ∣vx∣=rv|vx| = r_v. Every point of its closed diametral ball other than xx is at distance less than rvr_v from vv. Input vertices and points on segments not containing vv are at distance at least lfs(v)≥rv\mathrm{lfs}(v) \ge r_v from vv, so they are not in the ball. A segment gg at vv at an angle of 90 degrees or more stays outside it: for yy on gg and the center mm of the ball, ∣y−m∣2=∣y−v∣2+∣m−v∣2−2(y−v)⋅(m−v)>∣m−v∣2|y - m|^2 = |y - v|^2 + |m - v|^2 - 2 (y - v) \cdot (m - v) > |m - v|^2. A segment gg at vv at a smaller angle is clipped at vv, its own end lies on S(v,rv)S(v, r_v) or beyond, and its point at the far end is at distance ∣g∣−rw≥∣g∣−∣g∣/3≥rv|g| - r_w \ge |g| - |g|/3 \ge r_v from vv, since rw≤ℓw/3≤∣g∣/3r_w \le \ell_w/3 \le |g|/3 and rv≤2dv/3≤2∣g∣/3r_v \le 2 d_v/3 \le 2|g|/3. The only points of other segments that come closer than rvr_v to vv are on the ends at vv, and line L6 inserts points only on pieces that are not ends. So no vertex but vv and xx is ever inside or on the diametral sphere, and the end stays strongly Delaunay.

For the middle piece, line L2 gives r≤ℓ/3≤∣t∣/3r \le \ell/3 \le |t|/3 at each end, so it keeps at least ∣t∣/3|t|/3. A ball of radius ∣t∣|t| around any uu on tt contains both endpoints of tt, two distinct vertices, so lfs(u)≤∣t∣\mathrm{lfs}(u) \le |t|. □\square

Claim 2 (cited: Shewchuk's Theorem 2, a proved bound). EDGE-PROTECT "creates no segment shorter than one-quarter the local feature size of any point in that segment." For the pieces of line L6 Shewchuk shows ∣s∣≥lfs(u)/2|s| \ge \mathrm{lfs}(u)/2: a piece ss is created only when the piece of length 2∣s∣2|s| has a vertex off its own segment on or inside its diametral sphere. His Theorem 3 extends the bound to every edge of the final CDT: ∣e∣≥lfs(u)sin⁡(φ/2)/2|e| \ge \mathrm{lfs}(u) \sin(\varphi/2)/2 when the ends of ee lie on two segments that meet at an angle φ<60\varphi < 60 degrees, and ∣e∣≥lfs(u)/4|e| \ge \mathrm{lfs}(u)/4 otherwise.

Claim 3 (proved here, given Claim 2: termination and correctness). EDGE-PROTECT stops, and its output is edge-protected, so the augmented PLC, with each facet carrying the new points on its boundary, has a CDT that contains every facet with no further Steiner points.

Proof. By Claim 2 every piece is at least 14min⁡lfs\frac14 \min \mathrm{lfs} long, and min⁡lfs>0\min \mathrm{lfs} > 0 over a finite PLC. The segments have finite length, so only finitely many midpoints fit. When the loop of line L5 ends, every subsegment is strongly Delaunay, which is the definition of edge-protected. Shewchuk's CDT Theorem, an existence theorem, gives the CDT. □\square

The proved bound is a lower bound on edge lengths, not a bound on the number of points. No bound polynomial in the input size is known; Shewchuk writes that the problem "is unsolved". Point counts depend on how close the segments come. In the tests, a segment passing between two others at gaps of 8, 4, 2 and 1 gets 2, 3, 4 and 5 midpoints, one more each time the gap halves.

No guarantee without Steiner points. No method can recover every boundary without new points, because some polyhedra have no tetrahedralization, and Ruppert and Seidel proved that deciding whether one exists is NP-complete. When new points are allowed, they may still be many: Chazelle's polyhedra with nn vertices need a quadratic number of convex pieces, hence Ω(n2)\Omega(n^2) tetrahedra, and Si and Gärtner note that O(n2)O(n^2) tetrahedra suffice for any simple polyhedron.

What is proved, and of which kind.

  • George, Hecht and Saltel (1991), and Weatherill and Hassan (1994): methods with no guarantee. Missing edges and faces are recovered by swaps, and points are added where swaps fail. Si and Gärtner write that such methods "rely on ad hoc techniques" and that "their complexities are hard to analyze".
  • George, Borouchaki and Saltel (2003): a method designed to always succeed, by adding points; they also show that a Steiner point on a boundary edge or face can be moved off it into the interior. Not all can be deleted, as Schönhardt's polyhedron shows.
  • Shewchuk (2002): edge protection with the proved bounds of Claim 2, and the CDT Theorem, an existence theorem, for the facets.
  • Si and Gärtner (2011): Steiner points "on segments only", chosen by rules that avoid needlessly short pieces, so that "it is theoretically guaranteed that the facets can be recovered without using Steiner points". Their Theorem 5: if all segments are Delaunay edges of vertices in general position, the PLC has a unique CDT. Theorems 8 and 9: their facet recovery terminates and returns that CDT. Theorem 10: one missing facet is recovered in expected time O(v2+vlog⁡v)O(v^2 + v \log v) for vv vertices; they give an Ω(fv2)\Omega(f v^2) example, and the worst case is open.

What TetGen does. TetGen 1.6 follows Si and Gärtner ("TetGen's CDT algorithm is from Si and Gärtner"). Its verbose log names the steps: Delaunizing vertices, Creating surface mesh, Recovering boundaries, Removing exterior tetrahedra, Suppressing Steiner points, Recovering Delaunayness, Optimizing mesh. Its manual says that by default "TetGen generates a constrained tetrahedralization of the PLC", that "It only adds Steiner points when flips and advanced local mesh modifications cannot recover an edge or a facet", and that then "Steiner points might be added directly on the input edges or facets". With the -Y switch the input boundary is kept and Steiner points "appear only in the interior space of the PLC".

Proved constants and measured ones. The proved constant 14\frac14 is much worse than what happens. In the tests, the smallest ratio of piece length to lfs\mathrm{lfs} was between 0.315 and 0.413 on each of 10 random segment sets, 0.42 on Schönhardt's polyhedron and 0.663 on the worked example below. On six models with 460 to 57270 input vertices, Si and Gärtner report that "the number of Steiner points is in the order of the input size. This is a typical case." Their total running times were 0.26 to 7.85 seconds. Most of those points were later removed: on the Heart model, 3605 of 3622 Steiner points were deleted and the other 17 moved off the boundary.

Classic examples

A segment between two others. Take O=(0,0,0)O = (0,0,0), A=(20,0,0)A = (20,0,0), B=(16,12,0)B = (16,12,0) with segments OAOA and OBOB, and two short segments CDCD from (10,−3,1)(10,-3,1) to (10,3,1)(10,3,1) and EFEF from (10,−3,−1)(10,-3,-1) to (10,3,−1)(10,3,-1). OAOA passes between them at distance 1 from each. OBOB, CDCD and EFEF are strongly Delaunay and OAOA is not.

Step What happens New points
L1 OAOA and OBOB meet at OO at 36.936.9 degrees, so both are clipped at OO
L2 lfs(O)=101≈10.05\mathrm{lfs}(O) = \sqrt{101} \approx 10.05, the distance to CDCD; ℓO/3=20/3\ell_O / 3 = 20/3; dO=∞d_O = \infty; so rO=20/3r_O = 20/3
L3 the sphere S(O,20/3)S(O, 20/3) cuts OAOA and OBOB (203,0,0)(\frac{20}{3}, 0, 0), (163,4,0)(\frac{16}{3}, 4, 0)
L4, L5 the piece from 203\frac{20}{3} to 2020 on OAOA is not strongly Delaunay
L6 split it at 403\frac{40}{3}; the piece from 203\frac{20}{3} to 403\frac{40}{3} still is not; split it at 1010 (403,0,0)(\frac{40}{3}, 0, 0), (10,0,0)(10, 0, 0)

The result has 4 Steiner points, and every piece is strongly Delaunay. The shortest piece compared with the local feature size is the end at OO, with ratio 20/3101=0.663\frac{20/3}{\sqrt{101}} = 0.663, against the proved 0.250.25. The tests check every number in this table in exact arithmetic.

Schönhardt's polyhedron. Take the twisted prism of the implementation, with its 12 edges as segments. Every vertex has segments meeting at less than 90 degrees, so line L3 clips all 12 segments at both ends: 24 points, with radii of about 37.5. Line L6 then splits the middle piece of each of the three reflex edges once: 3 more points. Now every segment is strongly Delaunay, and by the CDT Theorem the polyhedron with its 8 subdivided facets has a CDT. Without new points it has no tetrahedralization at all.

Flips first. Most meshers try flips before adding points. A missing edge often crosses only a few triangles, and 2-3 and 3-2 flips remove the crossings. Liu and Baida (2000) studied how far flips alone can go. Flips are what TetGen tries first, and Schönhardt's polyhedron is the standard example where they fail.

Variations

  • Si and Gärtner's split points. Instead of midpoints, the split point on a missing segment is chosen with a reference point that encroaches on it and a parameter cc, and acute vertices (angles below 60 degrees) get special rules. On their comparison example this adds 8 Steiner points where Shewchuk's algorithm adds 24.
  • Weak edge protection. Only grazeable segments need to be strongly Delaunay for a CDT to exist, so they alone need splitting. The incremental facet insertion algorithm needs full edge protection.
  • Moving Steiner points off the boundary. TetGen's -Y switch keeps boundary Steiner points off the input boundary. George, Borouchaki and Saltel showed that such points can be moved into the interior. On Si and Gärtner's four test models, "The majority of the Steiner points can be completely deleted from the mesh, only few of them have been relocated to the interior of the domain."
  • Robust CDT. Diazzi, Panozzo, Vaxman and Attene (2023) build the CDT with exact indirect predicates, close a gap in the theory behind TetGen's facet recovery, and report success on all 4408 Thingi10k models they tried.
  • Conforming Delaunay. A conforming Delaunay triangulation adds points until an ordinary Delaunay tetrahedralization contains the facets too. It needs more points, many on the facets.

Pitfalls

  • Recovery does not make good tetrahedra. The CDT may contain flat ones, and the refinement that usually follows bounds only the radius-edge ratio, which does not remove slivers, the flat sliver tetrahedra with all four vertices near a circle. TetGen's manual says the same and adds the minimum dihedral angle as a second measure.
  • The strongly Delaunay test is degenerate when five vertices are cospherical. Shewchuk recommends symbolic perturbation; the implementation decides the strict sphere condition exactly over rationals.
  • The point where a sphere cuts a segment has a square root. The implementation rounds the distance down to a multiple of 2−502^{-50} of the segment length, which keeps the point exact and the radius at most rvr_v, and loosens the lower bound of Claim 1 by a factor of 1−2−501 - 2^{-50} at most.
  • Steiner points on the boundary change the input. Downstream codes that match boundary faces to CAD faces must expect split triangles, or remove the points afterwards.
  • Point counts grow when segments come close. In the tests, every halving of the gap between two segments adds one midpoint, and two long parallel segments close together would need very many tetrahedra for good shape in any case.
  • Swap-based recovery can cycle or get stuck without a fallback. A robust code needs a rule for adding points that always works.

Code

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

boundary_recovery.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/boundary-recovery/. The authors are listed in prov/NKFBHW.jsonl.

"""Segment recovery by edge protection (Shewchuk 2002), with exact predicates.

The input is the 1-skeleton of a piecewise linear complex in R^3: vertices with
rational coordinates and straight segments that meet only at shared endpoints.
EDGE_PROTECT inserts Steiner points on the segments until every subsegment is
strongly Delaunay: some sphere passes through its two endpoints and has every
other vertex strictly outside. By Shewchuk's CDT theorem the augmented complex
then has a constrained Delaunay tetrahedralization, so its facets can be
recovered with no further Steiner points.

  step 1  at every vertex where two segments meet at less than 90 degrees, cut
          those segments with a sphere of radius r = min(lfs, l/3, 2d/3);
  step 2  split at its midpoint any subsegment that is not strongly Delaunay,
          until none is left.

STRONGLY_DELAUNAY decides the sphere condition exactly. The centre c of a sphere
through a and b lies in their bisector plane, and a vertex p is strictly outside
exactly when |p|^2 - |a|^2 - 2 c.(p - a) > 0, which is linear in c. So the test is
the feasibility of a system of strict linear inequalities in two unknowns, done
by Fourier-Motzkin elimination over Fraction. It returns a witness centre.

The module also builds a Schonhardt polyhedron and tests points against it
exactly, to show the case where no recovery without Steiner points exists.
"""

import math
from fractions import Fraction
from itertools import combinations
from typing import Dict, List, Optional, Sequence, Tuple

Point = Sequence


def sub(a: Point, b: Point) -> tuple:
    return tuple(x - y for x, y in zip(a, b))


def add(a: Point, b: Point) -> tuple:
    return tuple(x + y for x, y in zip(a, b))


def scale(k, a: Point) -> tuple:
    return tuple(k * x for x in a)


def dot(a: Point, b: Point):
    return sum(x * y for x, y in zip(a, b))


def cross(a: Point, b: Point) -> tuple:
    return (a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0])


def dist2(a: Point, b: Point):
    d = sub(a, b)
    return dot(d, d)


def orient(a: Point, b: Point, c: Point, d: Point):
    """Six times the signed volume of abcd: positive if d is above the plane abc,
    seen with a, b, c counterclockwise."""
    return dot(cross(sub(b, a), sub(c, a)), sub(d, a))


def point_seg_dist2(p: Point, a: Point, b: Point) -> Fraction:
    d = sub(b, a)
    t = Fraction(dot(sub(p, a), d), dot(d, d))
    t = min(Fraction(1), max(Fraction(0), t))
    return dist2(p, add(a, scale(t, d)))


def seg_seg_dist2(a: Point, b: Point, c: Point, d: Point) -> Fraction:
    """Exact squared distance between segments ab and cd."""
    u, v, w = sub(b, a), sub(d, c), sub(a, c)
    A, B, C, D, E = dot(u, u), dot(u, v), dot(v, v), dot(u, w), dot(v, w)
    den = A * C - B * B
    best = min(point_seg_dist2(a, c, d), point_seg_dist2(b, c, d),
               point_seg_dist2(c, a, b), point_seg_dist2(d, a, b))
    if den != 0:
        s = Fraction(B * E - C * D, den)
        t = Fraction(A * E - B * D, den)
        if 0 <= s <= 1 and 0 <= t <= 1:
            best = min(best, dist2(add(a, scale(s, u)), add(c, scale(t, v))))
    return best


def check_complex(points: Sequence[Point], segments: Sequence[Tuple[int, int]]) -> None:
    """Raise ValueError unless the segments form a valid 1-complex."""
    pts = [tuple(Fraction(x) for x in p) for p in points]
    if any(len(p) != 3 for p in pts) or len(set(pts)) != len(pts):
        raise ValueError("points must be distinct and three-dimensional")
    seen = set()
    for u, v in segments:
        if not (0 <= u < len(pts) and 0 <= v < len(pts)) or u == v:
            raise ValueError("bad segment")
        key = (min(u, v), max(u, v))
        if key in seen:
            raise ValueError("repeated segment")
        seen.add(key)
        for k, p in enumerate(pts):
            if k not in (u, v) and point_seg_dist2(p, pts[u], pts[v]) == 0:
                raise ValueError("a vertex lies inside a segment")
    segs = list(seen)
    for (u, v), (x, y) in combinations(segs, 2):
        shared = {u, v} & {x, y}
        if not shared:
            if seg_seg_dist2(pts[u], pts[v], pts[x], pts[y]) == 0:
                raise ValueError("segments cross")
        else:
            o = shared.pop()
            p = v if u == o else u
            q = y if x == o else x
            d1, d2 = sub(pts[p], pts[o]), sub(pts[q], pts[o])
            if cross(d1, d2) == (0, 0, 0) and dot(d1, d2) > 0:
                raise ValueError("segments overlap")


def strongly_delaunay(a: Point, b: Point, pts: Sequence[Point]) -> Optional[tuple]:
    """Return the centre of a sphere through a and b that has every point of pts
    other than a and b strictly outside, or None if there is no such sphere."""
    a = tuple(Fraction(x) for x in a)
    b = tuple(Fraction(x) for x in b)
    d = sub(b, a)
    k = min(range(3), key=lambda i: abs(d[i]))
    axis = tuple(1 if i == k else 0 for i in range(3))
    e1 = cross(d, axis)
    e2 = cross(d, e1)
    m = scale(Fraction(1, 2), add(a, b))
    aa = dot(a, a)
    # constraint alpha + beta*s + gamma*t > 0 for the centre m + s*e1 + t*e2
    cons = []
    for p in pts:
        p = tuple(Fraction(x) for x in p)
        if p == a or p == b:
            continue
        pa = sub(p, a)
        cons.append((dot(p, p) - aa - 2 * dot(m, pa), -2 * dot(e1, pa), -2 * dot(e2, pa)))
    lower = [c for c in cons if c[2] > 0]
    upper = [c for c in cons if c[2] < 0]
    flat = [(c[0], c[1]) for c in cons if c[2] == 0]
    for al, bl, gl in lower:  # eliminate t: each lower bound below each upper bound
        for au, bu, gu in upper:
            flat.append((au * gl - al * gu, bu * gl - bl * gu))
    lo, hi = None, None  # open interval for s
    for A, B in flat:
        if B == 0:
            if A <= 0:
                return None
        elif B > 0:
            x = Fraction(-A, 1) / B
            lo = x if lo is None or x > lo else lo
        else:
            x = Fraction(-A, 1) / B
            hi = x if hi is None or x < hi else hi
    if lo is not None and hi is not None and lo >= hi:
        return None
    if lo is None and hi is None:
        s = Fraction(0)
    elif lo is None:
        s = hi - 1
    elif hi is None:
        s = lo + 1
    else:
        s = (lo + hi) / 2
    tl = max((-(al + bl * s) / gl for al, bl, gl in lower), default=None)
    tu = min((-(au + bu * s) / gu for au, bu, gu in upper), default=None)
    if tl is None and tu is None:
        t = Fraction(0)
    elif tl is None:
        t = tu - 1
    elif tu is None:
        t = tl + 1
    else:
        t = (tl + tu) / 2
    c = add(m, add(scale(s, e1), scale(t, e2)))
    r2 = dist2(c, a)
    assert all(dist2(c, p) > r2 for p in pts if tuple(Fraction(x) for x in p) not in (a, b))
    return c


def strongly_delaunay_brute(a: Point, b: Point, pts: Sequence[Point]) -> bool:
    """Reference test by Helly's theorem and Motzkin's transposition theorem.

    The open half-planes {alpha + beta*s + gamma*t > 0} have a common point
    exactly when every three of them do (Helly in the plane), and three fail
    exactly when a nonnegative, nonzero combination of them has zero beta and
    gamma parts and a nonpositive alpha part."""
    a = tuple(Fraction(x) for x in a)
    b = tuple(Fraction(x) for x in b)
    d = sub(b, a)
    k = min(range(3), key=lambda i: abs(d[i]))
    e1 = cross(d, tuple(1 if i == k else 0 for i in range(3)))
    e2 = cross(d, e1)
    m = scale(Fraction(1, 2), add(a, b))
    cons = []
    for p in pts:
        p = tuple(Fraction(x) for x in p)
        if p in (a, b):
            continue
        pa = sub(p, a)
        cons.append((dot(p, p) - dot(a, a) - 2 * dot(m, pa), -2 * dot(e1, pa), -2 * dot(e2, pa)))

    def dead(sub_cons) -> bool:
        n = len(sub_cons)
        # search the nonnegative combinations that cancel beta and gamma
        for size in range(1, n + 1):
            for idx in combinations(range(n), size):
                rows = [sub_cons[i] for i in idx]
                for lam in _kernel_rays(rows):
                    if all(x >= 0 for x in lam) and any(x > 0 for x in lam):
                        if sum(l * r[0] for l, r in zip(lam, rows)) <= 0:
                            return True
        return False

    for triple in combinations(range(len(cons)), min(3, len(cons))):
        if dead([cons[i] for i in triple]):
            return False
    return True


def _kernel_rays(rows):
    """Vectors lam (up to sign) with sum lam_i*(beta_i, gamma_i) = 0, one per
    one-dimensional kernel, for one, two or three rows."""
    n = len(rows)
    B = [r[1] for r in rows]
    G = [r[2] for r in rows]
    out = []
    if n == 1:
        if B[0] == 0 and G[0] == 0:
            out.append((1,))
    elif n == 2:
        if B[0] * G[1] - B[1] * G[0] == 0:
            lam = (B[1], -B[0]) if (B[0], B[1]) != (0, 0) else (G[1], -G[0])
            if lam != (0, 0):
                out.append(lam)
    else:
        lam = cross(tuple(B), tuple(G))
        if lam != (0, 0, 0):
            out.append(lam)
    return out + [tuple(-x for x in lam) for lam in out]


def lfs2(p: Point, points: Sequence[Point], segments: Sequence[Tuple[int, int]]) -> Fraction:
    """Squared local feature size at p: the smallest r^2 such that the ball of
    radius r around p meets two disjoint vertices or segments of the input."""
    feats = [("v", i) for i in range(len(points))] + [("s", s) for s in segments]

    def d2(f):
        if f[0] == "v":
            return dist2(p, points[f[1]])
        u, v = f[1]
        return point_seg_dist2(p, points[u], points[v])

    def verts(f):
        return {f[1]} if f[0] == "v" else set(f[1])

    vals = [d2(f) for f in feats]
    best = None
    for i, j in combinations(range(len(feats)), 2):
        if verts(feats[i]) & verts(feats[j]):
            continue
        x = max(vals[i], vals[j])
        best = x if best is None or x < best else best
    return best


class Protection:
    def __init__(self, points, chains, ends, radii, stats):
        self.points = points  # all vertices, input first, as Fraction tuples
        self.chains = chains  # per input segment, vertex indices from u to v
        self.ends = ends  # set of (i, j) subsegments cut off in step 1
        self.radii2 = radii  # vertex -> squared protecting sphere radius (exact)
        self.radii = {v: math.sqrt(r2) for v, r2 in radii.items()}
        self.stats = stats  # counts of Steiner points by step

    def subsegments(self) -> List[Tuple[int, int]]:
        return [(c[k], c[k + 1]) for c in self.chains for k in range(len(c) - 1)]


def _sqrt_floor(q: Fraction, bits: int = 50) -> Fraction:
    """sqrt(q) exactly when it is rational, else the largest k/2^bits below it."""
    q = Fraction(q)
    rn, rd = math.isqrt(q.numerator), math.isqrt(q.denominator)
    if rn * rn == q.numerator and rd * rd == q.denominator:
        return Fraction(rn, rd)
    return Fraction(math.isqrt(q.numerator * 4 ** bits // q.denominator), 2 ** bits)


def edge_protect(points: Sequence[Point], segments: Sequence[Tuple[int, int]],
                 max_points: int = 2000, check: bool = True) -> Protection:
    if check:
        check_complex(points, segments)
    pts = [tuple(Fraction(x) for x in p) for p in points]
    segs = [(u, v) for u, v in segments]
    inc: Dict[int, List[int]] = {}
    for e, (u, v) in enumerate(segs):
        inc.setdefault(u, []).append(e)
        inc.setdefault(v, []).append(e)

    def other(e, v):
        u, w = segs[e]
        return w if u == v else u

    clipped = set()  # (segment, vertex): the segment is cut by the sphere at vertex
    for v, es in inc.items():
        for e, f in combinations(es, 2):
            if dot(sub(pts[other(e, v)], pts[v]), sub(pts[other(f, v)], pts[v])) > 0:  # @line L1
                clipped.add((e, v))
                clipped.add((f, v))
    len2 = [dist2(pts[u], pts[v]) for u, v in segs]
    radii2: Dict[int, Fraction] = {}  # squared radii, exact
    for v in sorted({v for _, v in clipped}):
        near = [dist2(pts[v], pts[u]) for u in range(len(pts)) if u != v]
        near += [point_seg_dist2(pts[v], pts[a], pts[b]) for a, b in segs if v not in (a, b)]
        ell2 = min(len2[e] for e in inc[v] if (e, v) in clipped)
        cands = near + [Fraction(ell2, 9)]
        cands += [Fraction(4 * len2[e], 9) for e in inc[v] if (e, other(e, v)) in clipped]
        radii2[v] = min(cands)  # @line L2
    chains = []
    ends = set()
    for e, (u, v) in enumerate(segs):
        chain = [u]
        for x, y in ((u, v), (v, u)):
            if (e, x) in clipped:
                lam = _sqrt_floor(Fraction(radii2[x]) / len2[e])
                pts.append(add(pts[x], scale(lam, sub(pts[y], pts[x]))))  # @line L3
                if x == u:
                    chain.append(len(pts) - 1)
                    ends.add((u, len(pts) - 1))
                else:
                    tail = len(pts) - 1
                    ends.add((tail, v))
        if (e, v) in clipped:
            chain.append(tail)
        chain.append(v)
        chains.append(chain)
    step1 = len(pts) - len(points)
    # witness[(i, j)] = (centre, r^2) of an empty sphere through i and j, or None
    witness: Dict[Tuple[int, int], Optional[tuple]] = {}

    def test(i, j):
        c = strongly_delaunay(pts[i], pts[j], pts)
        witness[(i, j)] = None if c is None else (c, dist2(c, pts[i]))

    for c in chains:
        for k in range(len(c) - 1):
            test(c[k], c[k + 1])  # @line L4
    while True:
        bad = next((s for c in chains for s in zip(c, c[1:]) if witness[s] is None), None)  # @line L5
        if bad is None:
            break
        if len(pts) >= max_points:
            raise RuntimeError("too many Steiner points")
        i, j = bad
        pts.append(scale(Fraction(1, 2), add(pts[i], pts[j])))  # @line L6
        m = len(pts) - 1
        for c in chains:
            for k in range(len(c) - 1):
                if (c[k], c[k + 1]) == bad:
                    c.insert(k + 1, m)
                    break
        del witness[bad]
        test(i, m)
        test(m, j)
        for s, w in list(witness.items()):
            if w is not None and dist2(w[0], pts[m]) <= w[1]:
                test(*s)
    stats = {"step1": step1, "step2": len(pts) - len(points) - step1}
    return Protection(pts, chains, ends, radii2, stats)  # @line L7


def schonhardt(R: int = 100, h: int = 100, twist: int = 30):
    """A Schonhardt polyhedron with integer coordinates: a triangular prism whose
    top is turned by `twist` degrees, each side split along its reflex diagonal.

    Returns (points, faces, reflex, outside): faces are outward triangles,
    reflex the three reflex edges, outside the three vertex pairs whose
    segment leaves the polyhedron."""
    pts = []
    for k in range(3):
        t = math.radians(90 + 120 * k)
        pts.append((round(R * math.cos(t)), round(R * math.sin(t)), 0))
    for k in range(3):
        t = math.radians(90 + 120 * k + twist)
        pts.append((round(R * math.cos(t)), round(R * math.sin(t)), h))
    centroid = tuple(Fraction(sum(p[i] for p in pts), 6) for i in range(3))
    faces, reflex, outside = [], [], []
    for k in range(3):
        a0, a1, b0, b1 = k, (k + 1) % 3, 3 + k, 3 + (k + 1) % 3
        # the diagonal a0-b1 is reflex when b0 lies outside the plane of a0 a1 b1
        if orient(pts[a0], pts[a1], pts[b1], pts[b0]) * orient(pts[a0], pts[a1], pts[b1], centroid) < 0:
            diag, other_pair, tris = (a0, b1), (a1, b0), [(a0, a1, b1), (a0, b1, b0)]
        else:
            diag, other_pair, tris = (a1, b0), (a0, b1), [(a0, a1, b0), (a1, b1, b0)]
        reflex.append(diag)
        outside.append(other_pair)
        faces.extend(tris)
    faces.append((0, 2, 1))
    faces.append((3, 4, 5))
    # orient every face outward, using the centroid, which sees every face
    out = []
    for f in faces:
        if orient(pts[f[0]], pts[f[1]], pts[f[2]], centroid) > 0:
            f = (f[0], f[2], f[1])
        out.append(f)
    return pts, out, reflex, outside


def edges_of(faces) -> set:
    return {tuple(sorted((f[i], f[(i + 1) % 3]))) for f in faces for i in range(3)}


def inside_polyhedron(q: Point, pts: Sequence[Point], faces) -> bool:
    """Exact ray-parity test for a point not on the boundary."""
    q = tuple(Fraction(x) for x in q)
    for r in ((1, Fraction(3, 7), Fraction(5, 11)), (Fraction(2, 13), 1, Fraction(7, 17)),
              (Fraction(5, 19), Fraction(3, 23), 1)):
        hits, degenerate = 0, False
        for f in faces:
            p0, p1, p2 = (pts[i] for i in f)
            n = cross(sub(p1, p0), sub(p2, p0))
            den = dot(n, r)
            if den == 0:
                continue
            t = Fraction(dot(n, sub(p0, q))) / den
            if t <= 0:
                if t == 0:
                    degenerate = True
                continue
            x = add(q, scale(t, r))
            s = [dot(n, cross(sub(pts[f[(i + 1) % 3]], pts[f[i]]), sub(x, pts[f[i]]))) for i in range(3)]
            if any(v == 0 for v in s):
                degenerate = True
                break
            if all(v > 0 for v in s):
                hits += 1
        if not degenerate:
            return hits % 2 == 1
    raise ValueError("point on the boundary or degenerate rays")
test_boundary_recovery.py 236 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/boundary-recovery/. The authors are listed in prov/NKFBHW.jsonl.

import math
import random
from fractions import Fraction as F
from itertools import combinations

import pytest

from boundary_recovery import (
    add,
    check_complex,
    dist2,
    dot,
    edge_protect,
    edges_of,
    inside_polyhedron,
    lfs2,
    orient,
    scale,
    schonhardt,
    strongly_delaunay,
    strongly_delaunay_brute,
    sub,
)

EXAMPLE_P = [(0, 0, 0), (20, 0, 0), (16, 12, 0), (10, -3, 1), (10, 3, 1), (10, -3, -1), (10, 3, -1)]
EXAMPLE_S = [(0, 1), (0, 2), (3, 4), (5, 6)]


def random_complex(rng, nv=6, ne=7, span=20):
    while True:
        P = [tuple(rng.randint(-span, span) for _ in range(3)) for _ in range(nv)]
        S = set()
        while len(S) < ne:
            i, j = rng.sample(range(nv), 2)
            S.add((min(i, j), max(i, j)))
        S = sorted(S)
        try:
            check_complex(P, S)
        except ValueError:
            continue
        return P, S


def test_strongly_delaunay_matches_brute_force():
    rng = random.Random(1)
    seen = {True: 0, False: 0}
    for _ in range(400):
        k = rng.randint(2, 7)
        P = [tuple(rng.randint(-3, 3) for _ in range(3)) for _ in range(k)]
        if P[0] == P[1]:
            continue
        got = strongly_delaunay(P[0], P[1], P)
        assert (got is not None) == strongly_delaunay_brute(P[0], P[1], P)
        seen[got is not None] += 1
        if got is not None:  # the witness is a certificate
            r2 = dist2(got, P[0])
            assert dist2(got, P[1]) == r2
            assert all(dist2(got, p) > r2 for p in P if p not in (P[0], P[1]))
    assert seen[True] > 50 and seen[False] > 5


def test_cube_edges_and_diagonals():
    cube = [(x, y, z) for x in (0, 1) for y in (0, 1) for z in (0, 1)]
    # an edge: its diametral sphere already has the other six vertices outside
    assert strongly_delaunay((0, 0, 0), (1, 0, 0), cube) is not None
    # a face diagonal is Delaunay (the circumsphere of the cube) but not strongly
    assert strongly_delaunay((0, 0, 0), (1, 1, 0), cube) is None
    assert strongly_delaunay_brute((0, 0, 0), (1, 1, 0), cube) is False
    # a long diagonal is not even Delaunay
    assert strongly_delaunay((0, 0, 0), (1, 1, 1), cube) is None


def test_collinear_points():
    a, b = (0, 0, 0), (4, 0, 0)
    assert strongly_delaunay(a, b, [a, b, (2, 0, 0)]) is None  # a point inside ab
    assert strongly_delaunay(a, b, [a, b, (5, 0, 0), (-1, 0, 0)]) is not None


def test_worked_example():
    P, S = EXAMPLE_P, EXAMPLE_S
    assert strongly_delaunay(P[0], P[1], P) is None
    for i, j in S[1:]:
        assert strongly_delaunay(P[i], P[j], P) is not None
    pr = edge_protect(P, S)
    assert pr.radii2 == {0: F(400, 9)}  # r = min(lfs, l/3, 2d/3) = 20/3
    xs = [pr.points[i] for i in pr.chains[0]]
    assert xs == [(0, 0, 0), (F(20, 3), 0, 0), (10, 0, 0), (F(40, 3), 0, 0), (20, 0, 0)]
    assert [pr.points[i] for i in pr.chains[1]] == [(0, 0, 0), (F(16, 3), 4, 0), (16, 12, 0)]
    assert pr.chains[2] == [3, 4] and pr.chains[3] == [5, 6]
    assert pr.stats == {"step1": 2, "step2": 2}
    assert lfs2(P[0], P, S) == 101


def _check_protection(P, S, pr):
    sub_segs = pr.subsegments()
    # every subsegment is strongly Delaunay with respect to all the vertices
    for i, j in sub_segs:
        assert strongly_delaunay(pr.points[i], pr.points[j], pr.points) is not None
    # the cut-off ends are never split, and their diametral balls are empty
    present = set(sub_segs)
    for i, j in pr.ends:
        assert (i, j) in present
        m = scale(F(1, 2), add(pr.points[i], pr.points[j]))
        r2 = dist2(m, pr.points[i])
        assert all(dist2(m, p) > r2 for k, p in enumerate(pr.points) if k not in (i, j))
    # Steiner points lie in order on their segments
    for (u, v), chain in zip(S, pr.chains):
        a, b = pr.points[u], pr.points[v]
        ts = []
        for k in chain:
            d = sub(pr.points[k], a)
            t = F(dot(d, sub(b, a))) / dist2(a, b)
            assert add(a, scale(t, sub(b, a))) == pr.points[k]
            ts.append(t)
        assert ts == sorted(ts) and ts[0] == 0 and ts[-1] == 1 and len(set(ts)) == len(ts)


def _worst_ratio(P, S, pr, samples=4):
    """min over subsegments s and sample points u of |s|^2 / lfs(u)^2."""
    worst = None
    for i, j in pr.subsegments():
        a, b = pr.points[i], pr.points[j]
        s2 = dist2(a, b)
        for k in range(samples + 1):
            u = add(a, scale(F(k, samples), sub(b, a)))
            r = s2 / lfs2(u, P, S)
            worst = r if worst is None or r < worst else worst
    return worst


def test_theorem_2_bound_on_example():
    pr = edge_protect(EXAMPLE_P, EXAMPLE_S)
    _check_protection(EXAMPLE_P, EXAMPLE_S, pr)
    # proved: |s| >= lfs(u)/4; here the worst ratio |s|/lfs(u) is (20/3)/sqrt(101),
    # at the corner O of the end cut off there
    w = _worst_ratio(EXAMPLE_P, EXAMPLE_S, pr, samples=8)
    assert w == F(400, 909)


def test_random_complexes():
    rng = random.Random(7)
    worst = 1.0
    for _ in range(10):
        P, S = random_complex(rng)
        pr = edge_protect(P, S)
        _check_protection(P, S, pr)
        w = _worst_ratio(P, S, pr)
        assert w >= F(1, 16) * (1 - F(1, 10 ** 9))
        worst = min(worst, math.sqrt(w))
    assert worst > 0.25


def test_parallel_segments_need_nothing():
    # two parallel segments 1 apart: a large sphere bulging away clears each one
    P = [(0, 0, 0), (40, 0, 0), (0, 1, 0), (40, 1, 0)]
    pr = edge_protect(P, [(0, 1), (2, 3)])
    assert pr.stats == {"step1": 0, "step2": 0}


def test_closer_crossings_need_more_points():
    counts = []
    for k, h in ((3, 8), (3, 4), (3, 2), (1, 1)):
        P = [(0, 0, 0), (64, 0, 0), (21, -k, h), (21, k, h), (21, -k, -h), (21, k, -h)]
        S = [(0, 1), (2, 3), (4, 5)]
        pr = edge_protect(P, S)
        _check_protection(P, S, pr)
        assert _worst_ratio(P, S, pr) >= F(1, 16)
        counts.append(pr.stats["step2"])
    assert counts == [2, 3, 4, 5]


def _schonhardt_volume(pts, faces):
    o = (0, 0, 0)
    return sum(orient(pts[a], pts[b], pts[c], o) for a, b, c in faces)


def test_schonhardt_has_no_tetrahedralization():
    for twist in (10, 30, 50):
        pts, faces, reflex, outside = schonhardt(twist=twist)
        E = edges_of(faces)
        assert len(faces) == 8 and len(E) == 12
        assert set(map(tuple, map(sorted, reflex))) <= E
        # the three remaining pairs leave the polyhedron
        for p, q in outside:
            assert tuple(sorted((p, q))) not in E
            m = scale(F(1, 2), add(pts[p], pts[q]))
            assert not inside_polyhedron(m, pts, faces)
        # so every one of the 15 tetrahedra has an edge outside the polyhedron
        bad = {tuple(sorted(o)) for o in outside}
        for quad in combinations(range(6), 4):
            assert any(tuple(sorted(e)) in bad for e in combinations(quad, 2))
        # one Steiner point at the centroid sees all eight faces
        c = tuple(F(sum(p[i] for p in pts), 6) for i in range(3))
        assert inside_polyhedron(c, pts, faces)
        vols = [-orient(pts[a], pts[b], pts[cc], c) for a, b, cc in faces]
        assert all(v > 0 for v in vols)
        assert sum(vols) == -_schonhardt_volume(pts, faces)


def test_schonhardt_reflex_edges_never_all_strongly_delaunay():
    rng = random.Random(3)
    counts = set()
    for _ in range(40):
        pts, faces, reflex, _ = schonhardt(twist=rng.randint(8, 50), h=rng.randint(40, 200))
        pts = [tuple(x + rng.randint(-3, 3) for x in p) for p in pts]
        k = sum(strongly_delaunay(pts[a], pts[b], pts) is not None for a, b in reflex)
        counts.add(k)
        assert k <= 2
    assert 2 in counts  # Shewchuk: any two may be strongly Delaunay


def test_schonhardt_edge_protection():
    pts, faces, reflex, _ = schonhardt()
    S = sorted(edges_of(faces))
    pr = edge_protect(pts, S)
    _check_protection(pts, S, pr)
    assert pr.stats["step1"] == 24


def test_bad_input():
    with pytest.raises(ValueError):
        check_complex([(0, 0, 0), (1, 0, 0), (2, 0, 0)], [(0, 2)])  # vertex inside
    with pytest.raises(ValueError):
        check_complex([(0, 0, 0), (2, 0, 0), (1, -1, 0), (1, 1, 0)], [(0, 1), (2, 3)])  # crossing
    with pytest.raises(ValueError):
        check_complex([(0, 0, 0), (1, 0, 0), (2, 0, 0)], [(0, 1), (0, 2)])  # overlap
    with pytest.raises(ValueError):
        check_complex([(0, 0, 0), (0, 0, 0)], [(0, 1)])
    with pytest.raises(ValueError):
        check_complex([(0, 0, 0), (1, 0, 0)], [(0, 1), (1, 0)])
    with pytest.raises(RuntimeError):
        edge_protect([(0, 0, 0), (64, 0, 0), (21, -1, 1), (21, 1, 1), (21, -1, -1), (21, 1, -1)],
                     [(0, 1), (2, 3), (4, 5)], max_points=8)

Exercises

  1. Show that a strongly Delaunay segment is an edge of every Delaunay tetrahedralization of the vertices.
  2. In the worked example, move CDCD and EFEF to z=±2z = \pm 2. How many midpoints does line L6 insert now?
  3. Show that a point yy on a segment at vv lies inside the diametral ball of a piece [v,x][v, x] of another segment exactly when ∣vy∣<∣vx∣cos⁡θ|vy| < |vx| \cos \theta, where θ\theta is the angle at vv. Why does line L1 clip only below 90 degrees?
  4. Prove that the three reflex edges of Schönhardt's polyhedron cannot all be strongly Delaunay, using the CDT Theorem.
  5. Run EDGE-PROTECT on a cube with its 12 edges and 6 face diagonals as segments. Which segments get Steiner points?

References

  1. Jonathan Richard Shewchuk, Constrained Delaunay tetrahedralizations and provably good boundary recovery, Proceedings of the 11th International Meshing Roundtable, 2002, 193 to 204, Section 3 (edge protection and Theorem 1), Section 4 (testing edge protection), Section 5 (the two-step edge protection algorithm, the radius min of lfs, l/3 and 2d/3, Figure 11, Theorems 2 and 3, the remark that a polynomial bound on the number of vertices is unsolved), Section 6 (gift wrapping and sweep), Section 9 (symbolic perturbation)
  2. Hang Si and Klaus Gärtner, 3D boundary recovery by constrained Delaunay tetrahedralization, International Journal for Numerical Methods in Engineering 85(11), 2011, 1341 to 1364, read as WIAS preprint 1530; the abstract, Section 1 (swap-based methods and their analysis), Theorem 5 (unique CDT once all segments are Delaunay edges), the segment recovery rules, Theorems 8 to 10 (facet recovery terminates, gives the CDT, expected time per facet), Section 7 (removing and relocating Steiner points), Tables I and II
  3. Hang Si, TetGen, a quality tetrahedral mesh generator and a 3D Delaunay triangulator, User's Manual, version 1.6, WIAS Berlin, 2020, the description of the -p switch (constrained tetrahedralization by default, Steiner points only when flips and local operations fail), the -Y switch (no Steiner points on the boundary), the steps reported by -V, the reference of its CDT algorithm to Si and Gärtner, and the section on quality meshes (the radius-edge ratio does not remove slivers)
  4. Paul-Louis George, Frédéric Hecht and Eric Saltel, Automatic mesh generator with specified boundary, Computer Methods in Applied Mechanics and Engineering 92(3), 1991, 269 to 288, boundary recovery in a Delaunay tetrahedralization by edge and face swaps with Steiner points where swaps fail (general locator, described through Si and Gärtner)
  5. Nigel P. Weatherill and Oubay Hassan, Efficient three-dimensional Delaunay triangulation with automatic point creation and imposed boundary constraints, International Journal for Numerical Methods in Engineering 37(12), 1994, 2005 to 2039, boundary recovery by swaps and added points (general locator)
  6. Paul-Louis George, Houman Borouchaki and Eric Saltel, Ultimate robustness in meshing an arbitrary polyhedron, International Journal for Numerical Methods in Engineering 58(7), 2003, 1061 to 1089, recovery that always succeeds with Steiner points, and moving Steiner points off the boundary (general locator, described through Si and Gärtner)
  7. Jim Ruppert and Raimund Seidel, On the difficulty of triangulating three-dimensional nonconvex polyhedra, Discrete and Computational Geometry 7(3), 1992, 227 to 253, the NP-completeness of deciding whether a polyhedron can be tetrahedralized without new vertices (general locator)
  8. Bernard Chazelle, Convex partitions of polyhedra, a lower bound and worst-case optimal algorithm, SIAM Journal on Computing 13(3), 1984, 488 to 507, polyhedra with n vertices that need a quadratic number of convex pieces, and the quadratic upper bound (general locator)
  9. Lorenzo Diazzi, Daniele Panozzo, Amir Vaxman and Marco Attene, Constrained Delaunay tetrahedrization, a robust and practical approach, ACM Transactions on Graphics 42(6), 2023, the robust CDT construction with indirect predicates and its test on the Thingi10k models (general locator)
  10. Hang Si, TetGen, a Delaunay-based quality tetrahedral mesh generator, ACM Transactions on Mathematical Software 41(2), 2015, the design of TetGen, including boundary recovery by constrained Delaunay tetrahedralization (general locator)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • three classic examples