JMesh is a JSON-based portable and extensible file format for the storage and interchange of unstructured geometric data, including discretized geometries such as triangular and tetrahedral meshes, parametric geometries such as NURBS curves and surfaces, and constructive geometries such as constructive solid geometry (CGS) of shape primitives and meshes. Built upon the JData specification, a JMesh file utilizes the JSON and Universal Binary JSON (UBJSON) constructs to serialize and encode geometric data structures, therefore, it can be directly processed by most existing JSON and UBJSON parsers. The JMesh specification defines a list of JSON-compatible constructs to encode geometric data, including N-dimensional (ND) vertices, curves, surfaces, solid elements, shape primitives, their interactions (such as CGS) and spatial relations, together with their associated properties, such as numerical values, colors, normals, materials, textures and other properties related to graphics data manipulation, 3-D fabrication, computer graphics rendering and animations.

JMesh File Example

The following mesh (a tetrahedral mesh of a unit cube) contains 8 3-D vertices, 12 triangular faces and 6 tetrahedral elements

JMesh

The above mesh can be stored in the JMesh/JSON format as

{

"_DataInfo_":{

"JMeshVersion":0.5, "CreationTime":"19-Dec-2021 11:53:43", "Comment":"Created by iso2mesh 1.9.5-Rev(http:\/\/iso2mesh.sf.net)" }, "MeshVertex3":[ [0,0,0], [1,0,0], [0,1,0], [1,1,0], [0,0,1], [1,0,1], [0,1,1], [1,1,1] ], "MeshTri3":[ [1,2,4], [1,2,6], [1,3,4], [1,3,7], [1,5,6], [1,5,7], [2,8,4], [2,8,6], [3,8,4], [3,8,7], [5,8,6], [5,8,7] ], "MeshTet4":[ [1,2,4,8], [1,3,4,8], [1,2,6,8], [1,5,6,8], [1,3,7,8], [1,5,7,8] ] } The optional "_DataInfo_" record can contain additional metadata according to JData specification.

JMesh

Instead of using dimension-specific mesh data constructs, i.e. MeshVertex3, MeshTri3, and MeshTet4, one can also replace those with the corresponding flexible mesh data containers, MeshNode, MeshSurf, and MeshElem, respectively. It is recommended to add "Dimension": 3 in the "_DataInfo_" metadata header to help parsers correctly process the numerical data in each entry.

JMesh

Alternatively, according to JMesh and JData specifications, the above JSON-styled 2-D arrays can be stored as a structure using JData annotated N-D array format to add additional binary data type support, as below { "_DataInfo_":{ "JMeshVersion":0.5, "Dimension":3 }, "MeshNode":{ "_ArrayType_":"double", "_ArraySize_":[8,3], "_ArrayData_":[0,0,0,1,0,0,0,1,0,1,1,0,0,0,1,1,0,1,0,1,1,1,1,1] }, "MeshSurf":{ "_ArrayType_":"uint8", "_ArraySize_":[12,3], "_ArrayData_":[1,2,4,1,2,6,1,3,4,1,3,7,1,5,6,1,5,7,2,8,4,2,8,6,3,8,4,3,8,7,5,8,6,5,8,7] }, "MeshElem":{ "_ArrayType_":"uint8", "_ArraySize_":[6,4], "_ArrayData_":[1,2,4,8,1,3,4,8,1,2,6,8,1,5,6,8,1,3,7,8,1,5,7,8] } }

For large mesh data files, record-level compression is supported via the JData specification. Just for illustration purposes, the above JMesh data can also be written as { "_DataInfo_":{ "JMeshVersion":0.5, "Dimension":3 }, "MeshNode":{ "_ArrayType_":"double", "_ArraySize_":[8,3], "_ArrayZipSize_":[1,24], "_ArrayZipType_":"zlib", "_ArrayZipData_":"eJxjYMAHPtjjlcaQh/GJ1YdLPy51mDQAp2EONQ==" }, "MeshSurf":{ "_ArrayType_":"uint8", "_ArraySize_":[12,3], "_ArrayZipSize_":[1,36], "_ArrayZipType_":"zlib", "_ArrayZipData_":"eJwFwYcNAAAIArAAMv6/2BY8MNBBhQOXOy7aafXi9QEJtwCj" }, "MeshElem":{ "_ArrayType_":"uint8", "_ArraySize_":[6,4], "_ArrayZipSize_":[1,24], "_ArrayZipType_":"zlib", "_ArrayZipData_":"eJxjZGLhYGQGYiY2DkZWIGZmB9LsHAAExABt" } } where the strings in "_ArrayZipData_" store the row-major serialized, Zlib-compressed and Base64 encoded binary stream of the raw binary array data in the precision specified in _ArrayType_. Record-level data compression may offer significant size reduction in storing large mesh files.

Format Overview

JMesh syntax

All JMesh files are JData specification compliant. Same as JData, it has both a text-format based on JSON serialization scheme and a binary format based on the UBJSON serialization scheme.

Nearly all supported mesh data containers (i.e. named JData nodes) can be defined using one of the two forms: an N-D array or a structure.