fold

FOLD Specification (version 1.2)

This specification is still considered a rough draft, with everything subject to change. But we will increment version numbers when breaking changes or major new features are added. See the history of past versions.

Design

The FOLD format seeks to balance generality and simplicity:

Examples

Check out some sample .fold files to get a quick sense of the format.

Overview

A .fold file is a JSON (JavaScript Object Notation) file where some fields should be interpreted with special meanings defined in this document. JSON is a simple way of encoding numbers, strings, arrays, and dictionaries with string keys into a text file. A benefit of adopting this format is that JSON parsers are already available in essentially all programming languages. For example, JavaScript has the built-in JSON module, and Python 2 and 3 have the built-in json library.

A .fold file represents one or more frames. A frame can represent a crease pattern (unfolding), a mountain-valley pattern, a folded state, a polyhedral complex, or even an abstract polyhedral metric, linkage configuration, or linkage. Each frame contains linked geometric information describing folded and (optionally) layered geometry in flat arrays, similar to information storage in the OBJ format. At the top level of every .fold file is a dictionary containing keys linking to either geometric data for a folded structure (frame properties), or metadata about the file itself (metadata properties).

Most properties (keys) have an A_B naming convention, where A represents some implicit object or objects and B represents some property of A. For example, if students represents an arbitrarily ordered list of students, then students_name might represent the name of each student, while students_age might represent each student’s age. The value of the students_name property would be a zero-indexed array of names, while the value of the students_age property would be an array of integers, where element i of students_name represents the name of student i, and element i of students_age represents the age of the same student i. (Laying out data in this flat “parallel arrays” representation decreases the depth of the object tree and makes it easy to add custom data onto existing objects.)

FOLD currently defines meaning for properties of the following form, which head the sections below. All properties are optional, but some are recommended.

File Metadata (file_...)

File-level (as opposed to frame-level) metadata properties can be included only in the top-level JSON dictionary. They include:

Frame Metadata (frame_...)

Frame-level (as opposed to file-level) metadata properties in the FOLD format include

Vertex information: vertices_...

The values of the following properties are zero-indexed arrays by vertex ID.

Edge information: edges_...

The values of the following properties are zero-indexed arrays by edge ID.

Face information: faces_...

Faces in a FOLD file should correspond to the “material” being folded. In particular, they do not typically include the exterior (unbounded) face of a planar graph such as a crease pattern.

The values of the following properties are zero-indexed arrays by face ID.

The counterclockwise ordering of each face defines the side/sign of its normal vector.

Layer information: faceOrders and edgeOrders

The layer ordering of a folded state is normally defined pointwise (λ(p, q) for two noncrease points p and q of paper that fold to the same point). FOLD does not directly represent such points, and instead works with entire faces (or edges for the case of linkages). Two faces have a consistent “above” or “below” relationship only if they overlap in a single connected region. For example, this property is guaranteed by convex faces. If your faces overlap in multiple regions, you should subdivide them (via "J" join edges) so that they do not. We recommend specifying either "convexFaces" or "nonConvexFaces" in frame_attributes.

Multiple Frames

Most properties described above (all but the file_... properties which are about the entire file) can appear in the top-level dictionary or within an individual frame. Properties in the top-level dictionary describes the key frame (frame 0). If your file consists of just one frame, that’s all you need to know.

If you want to store multiple frames in one file, use file_frames to store all frames beyond the key frame. The value of the file_frames property is an array of dictionaries, where file_frames[i] represents frame i+1 (because frame 0 is the key frame). Each frame dictionary can have any of the properties described above (again, except for file_... properties). In addition, frames (other than the key frame) can have the following properties:

Support for multiple frames is optional, so is not expected to be implemented by all software supporting the FOLD format. Software not implementing support for multiple frames should ignore all frames properties and use only the key frame.

Custom Properties

To add custom data to the FOLD format specific to your software, include a colon (:) in the property key, where the part before the colon identifies your software. For example, TreeMaker will use the tm: namespace, and a property mapping edges to TreeMaker structural types will use key "edges_tm:structuralType". (All property keys without colons are reserved for possible use in future versions of the FOLD specification. If you think your custom property would be broadly useful, feel free to send us your use cases for consideration.)

Similarly, custom classes and attributes can be specified by prefixing them with a namespace and a colon. For example, TreeMaker will use the frame class "tm:tree" to denote that the frame stores the metric tree of the uniaxial base. (Again, if you think your custom class or attribute would be broadly useful, feel free to send us your use cases for consideration.)