Skip to content

Union of crossing box beams (a lattice mast): --strict rejects a valid-looking solid at 40 beams, and 148 beams end non-manifold after 110 s #116

Done

Description

@ramsaicharan

Version: forma-3d 0.4.4 (npm, WASM), Node 24.22.3, macOS. Not tested on main.

What I did

A plain square lattice mast, all 0.6 m box beams: four posts on a 10 m square, and per 8 m tier and per face two diagonal braces (an X) and one ring beam. The beams are joined one at a time with add.

lattice-mast-gen.py <tiers> box writes the script; mast-box-3.forma (41 lines) is the smallest failing case.

forma-3d eval --strict --out mast.glb mast-box-3.forma

What happens

Tiers Beams --strict --no-strict
1 16 OK, WT=ok, vol 58.741
2 28 OK, WT=ok, vol 116.396
3 40 ERR: invariant violation on 'mast': self-intersecting surface (faces of one shell pass through each other) WT=ok NM=0 B=0 g=45 vol=174.052
6 76 the same error WT=ok NM=0 B=0 g=93 vol=347.020
12 148 ERR: ... non-manifold result (WT=false, CW=false, NM=232, B=74, NaN=0) after 110 s not run

Two things look wrong:

  1. 3 and 6 tiers. Without strict the solid is watertight, its volume grows by the same 57.656 per tier and its genus by 16 per tier, as the 1 and 2 tier masts do. So the union looks right and the self-intersection check may be a false positive.
  2. 12 tiers. The union itself fails (232 non-manifold edges, 74 boundary edges) and takes 110 s, where 76 beams take 0.4 s.

The same mast with tube() braces instead of rotated boxes passes --strict up to 76 beams (0.9 s). At 148 beams it had not finished after 3 minutes and I stopped it.

Expected

The union succeeds, or fails fast with the failing pair named.

Possibly related

#104 and PR #105 (seams at slivers and near-parallel faces): the two braces of one face share their front and back planes, and every ring beam shares planes with the posts, so there are many coplanar overlaps.

Why it matters

Lattice structures (masts, pylons, trusses, scaffolds, towers) are crossing thin beams by nature. Our way round it was to write the mesh directly, each beam its own closed box.

Files

lattice-mast-gen.py
# A plain square lattice mast: 4 posts, and per tier and face one X of two braces and a ring beam.
import math, sys
tiers = int(sys.argv[1]); kind = sys.argv[2]; t = 0.6; a = 5.0; h = 8.0
f = lambda v: f"{v:.4f}".rstrip("0").rstrip(".")
parts = []
for sx, sy in ((1, 1), (1, -1), (-1, -1), (-1, 1)):
    parts.append(f"box({f(t)}, {f(t)}, {f(tiers * h)}, at=({f(sx * a)}, {f(sy * a)}, 0), z0=0)")
L = math.hypot(2 * a, h); ang = math.degrees(math.atan2(h, 2 * a))
for k in range(tiers):
    zc = k * h + h / 2
    for face in range(4):
        turn = 90 * face
        for s in (1, -1):
            if kind == "box":
                parts.append(f"box({f(L)}, {f(t)}, {f(t)}, at=(0, 0, 0), rot=(0, {f(s * ang)}, 0)) | move(0, {f(a)}, {f(zc)}) | rot(0, 0, {turn})")
            else:
                parts.append(f"tube([({f(-a)}, {f(a)}, {f(zc - s * h / 2)}), ({f(a)}, {f(a)}, {f(zc + s * h / 2)})], r={f(t / 2)}) | rot(0, 0, {turn})")
        parts.append(f"box({f(2 * a)}, {f(t)}, {f(t)}, at=(0, {f(a)}, {f((k + 1) * h)})) | rot(0, 0, {turn})")
out = []
for i, p in enumerate(parts):
    out.append(f"_b{i} = {p}")
out.append("mast = _b0" + "".join(f" | add(_b{i})" for i in range(1, len(parts))))
open(f"mast-{kind}-{tiers}.forma", "w").write("\n".join(out) + "\n")
print(len(parts), "beams")
mast-box-3.forma (40 beams, the smallest failing case)
_b0 = box(0.6, 0.6, 24, at=(5, 5, 0), z0=0)
_b1 = box(0.6, 0.6, 24, at=(5, -5, 0), z0=0)
_b2 = box(0.6, 0.6, 24, at=(-5, -5, 0), z0=0)
_b3 = box(0.6, 0.6, 24, at=(-5, 5, 0), z0=0)
_b4 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 4) | rot(0, 0, 0)
_b5 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 4) | rot(0, 0, 0)
_b6 = box(10, 0.6, 0.6, at=(0, 5, 8)) | rot(0, 0, 0)
_b7 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 4) | rot(0, 0, 90)
_b8 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 4) | rot(0, 0, 90)
_b9 = box(10, 0.6, 0.6, at=(0, 5, 8)) | rot(0, 0, 90)
_b10 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 4) | rot(0, 0, 180)
_b11 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 4) | rot(0, 0, 180)
_b12 = box(10, 0.6, 0.6, at=(0, 5, 8)) | rot(0, 0, 180)
_b13 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 4) | rot(0, 0, 270)
_b14 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 4) | rot(0, 0, 270)
_b15 = box(10, 0.6, 0.6, at=(0, 5, 8)) | rot(0, 0, 270)
_b16 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 12) | rot(0, 0, 0)
_b17 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 12) | rot(0, 0, 0)
_b18 = box(10, 0.6, 0.6, at=(0, 5, 16)) | rot(0, 0, 0)
_b19 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 12) | rot(0, 0, 90)
_b20 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 12) | rot(0, 0, 90)
_b21 = box(10, 0.6, 0.6, at=(0, 5, 16)) | rot(0, 0, 90)
_b22 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 12) | rot(0, 0, 180)
_b23 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 12) | rot(0, 0, 180)
_b24 = box(10, 0.6, 0.6, at=(0, 5, 16)) | rot(0, 0, 180)
_b25 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 12) | rot(0, 0, 270)
_b26 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 12) | rot(0, 0, 270)
_b27 = box(10, 0.6, 0.6, at=(0, 5, 16)) | rot(0, 0, 270)
_b28 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 20) | rot(0, 0, 0)
_b29 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 20) | rot(0, 0, 0)
_b30 = box(10, 0.6, 0.6, at=(0, 5, 24)) | rot(0, 0, 0)
_b31 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 20) | rot(0, 0, 90)
_b32 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 20) | rot(0, 0, 90)
_b33 = box(10, 0.6, 0.6, at=(0, 5, 24)) | rot(0, 0, 90)
_b34 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 20) | rot(0, 0, 180)
_b35 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 20) | rot(0, 0, 180)
_b36 = box(10, 0.6, 0.6, at=(0, 5, 24)) | rot(0, 0, 180)
_b37 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, 38.6598, 0)) | move(0, 5, 20) | rot(0, 0, 270)
_b38 = box(12.8062, 0.6, 0.6, at=(0, 0, 0), rot=(0, -38.6598, 0)) | move(0, 5, 20) | rot(0, 0, 270)
_b39 = box(10, 0.6, 0.6, at=(0, 5, 24)) | rot(0, 0, 270)
mast = _b0 | add(_b1) | add(_b2) | add(_b3) | add(_b4) | add(_b5) | add(_b6) | add(_b7) | add(_b8) | add(_b9) | add(_b10) | add(_b11) | add(_b12) | add(_b13) | add(_b14) | add(_b15) | add(_b16) | add(_b17) | add(_b18) | add(_b19) | add(_b20) | add(_b21) | add(_b22) | add(_b23) | add(_b24) | add(_b25) | add(_b26) | add(_b27) | add(_b28) | add(_b29) | add(_b30) | add(_b31) | add(_b32) | add(_b33) | add(_b34) | add(_b35) | add(_b36) | add(_b37) | add(_b38) | add(_b39)

Activity

  1. wrong-nebula commented on Dec 4, 2026

    @wrong-nebula
    Owner

    Thanks for the crisp generator and repro! Both the strict-mode rejection at 40/76 beams and the 110 s / non-manifold failure at 148 beams are now resolved on main (via the boolean seam-repair, BVH/overlap frame hardening, and kernel speedups merged since 0.4.4), and we added a permanent regression suite in PR #123 covering box and tube masts up to 12 tiers (148 beams) under --strict.

    Verified on main (--strict, WT=ok NM=0 B=0, zero self-intersections):

    • box 3 tiers (40 beams): 32 ms native / 104 ms WASM (g=45, vol=174.052)
    • box 12 tiers (148 beams): 299 ms native / 877 ms WASM (g=189, vol=692.953) — down from 110 s
    • box 25 tiers (304 beams): 1.19 s native
    • tube 12 tiers (148 beams): 880 ms native / 2.44 s WASM (g=189, vol=597.563)

    These fixes will be included in the next forma-3d npm release after 0.4.4.

  2. added 2 commits that reference this issue on Dec 4, 2026
    9a64c3e
    0236b16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions