Output — the FOLD contract
7. Output: the FOLD contract (since v0.0; dual-frame since v0.7-dev)
Section titled “7. Output: the FOLD contract (since v0.0; dual-frame since v0.7-dev)”beloch fold FILE.bel emits a FOLD file
[foldformat] with two frames built from the folded state’s
faces: the flat crease pattern (frame 0, the top-level dictionary) and the
folded form (file_frames[0]). A program with no @ folds still emits both;
the folded form then coincides with the flat sheet.
The planar graph is the face set: vertices are deduplicated by paper coordinate
(vertices shared across faces along a crease coincide), each face is one polygon,
edges are the deduplicated polygon edges. Square-boundary edges are "B"; an
internal edge is a crease.
Frame 0 — creasePattern:
file_spec,file_creator: "beloch 0.3.0-dev",frame_classes: ["creasePattern"]vertices_coords—[x, y]per vertex, in paper coordinates. Exact values are rendered to JSON decimal at serialization (non-terminating reals rounded in the output only; internal values stay exact).edges_vertices—[v0, v1]index pairs.edges_assignment([foldformat] §“Edge information”) —"B"for paper-boundary edges, derived"M"/"V"for folded creases (§4.6), and"U"for an unfolded precrease (a crease line with no fold yet). One physical fold through several layers can yield different M/V per layer (the accordion), since each crease edge carries its own derived assignment.faces_vertices— each face’s vertex indices, counter-clockwise. A program with no creases yields the single square face[[0, 1, 2, 3]].beloch:edges— custom property ([foldformat] §“Custom Properties”) carrying, per crease edge, its originating operation ("axiom1","axiom2","axiom3","axiom5"), the source point/crease names, the source span, and the bound"name"(e.g."d1"for--d1: …, elsenull). Additive: stock FOLD consumers ignore it;tools/fold2svg.mjsuses it to colour/label creases.
file_frames[0] — foldedForm (frame_parent: 0, frame_inherit: true, so
it inherits the topology and overrides only the coordinates):
vertices_coords— the same vertices in table (folded) coordinates: each face’s paper polygon through its isometry. Flat folds stay in the plane, so these are 2D; stacking is conveyed byfaceOrders, not a z-offset.edges_foldAngle—+180for valley,−180for mountain,0otherwise; the sign matchesedges_assignment.faceOrders—[f, g, s]layer-ordering triples for face pairs whose table footprints overlap;s = +1iffis aboveg(towardg’s normal),−1below ([foldformat] §“Layer information”). Emitted only for overlapping pairs (empty when nothing overlaps, e.g. a flat program).
The renderer/animation client is a separate consumer; tools/fold2svg.mjs draws
frame 0 by default and the folded form with --folded.