JMesh explained

JMesh
Mime:application/json
Type Code:TEXT and BINARY
Extension:.jmsh, .bmsh
Developer:Qianqian Fang
Released:[1]
Latest Release Version:1.0 Draft 1
Latest Release Date:[2]
Genre:Data interchange
Extended From:JSON, JData
Open:Yes

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, 3D 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

The above mesh can be stored in the JMesh/JSON format asThe optional "_DataInfo_" record can contain additional metadata according to JData specification.

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.

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

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 aswhere 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.

Array form

For simple data, one can use the "array form" to store the data under a JMesh keyword. In such case, the format of the data must follow the "N-Dimensional Array Storage Keyword" rules defined in the JData specification. For example, one can store a 1-D or 2-D array using the direct storage format as "jmesh_container_1d": [v1,v2,...,vn], "jmesh_container_2d": [[v11,v12,...,v1n], [v21,v22,...,v2n], ... [vm1,vm2,...,vmn] ]or using the "annotated storage" format as "jmesh_container_nd":

Structure form

One can also use a JData structure to store the primary data as well as to support additional metadata associated with the container. For example, a structure-based container may have the below subfields: "jmesh_container_struct": Only the "Data" subfield is required, and it must have the same data stored in the "array form" (either in direct or annotated format) as shown above.

The optional "Properties" subfield allows one to store additional data with this shape/mesh element. The "Properties" subfield can be an array or structure with additional subfields.

The optional "_DataInfo_" is the JData construct for storing metadata associated with this structure. It can be used to store simple metadata, such as data acquisition date, operator name, or version number. The strategies how to split the metadata between _DataInfo_ and Properties is user-dependent.

Summary of JMesh keywords

Most of the data container keywords associated with discretized geometries have a prefix of "Mesh"; keywords associated with parametric shape constructs have a prefix of "Shape"; keywords associated with constructive solid geometries have a prefix "CSG". Many of the keywords ends with a numerical value which typically represents the column number of the data when stored in the array format.

Vertices

"MeshVertex1": [x1,x2,x3,...]

"MeshVertex2": [[x1,y1], [x2,y2], [x3,y3], ...]

"MeshVertex3": [[x1,y1,z1], [x2,y2,z2], [x3,y3,z3], ...]

Line segments and curves

"MeshPolyLine": [N1, N2, N3, ... ]

"MeshEdge": [[N11,N12], [N21,N22], [N31,N32], ...]

Surfaces

"MeshTri3": [[N11, N12, N13], [N21, N22, N23], [N31, N32, N33], ...]

"MeshQuad4": [[N11, N12, N13, N14], [N21, N22, N23, N24], [N31, N32, N33, N24], ...]

"MeshPLC": [[N11, N12, N13, ...], [N21, N22, N23, N24, ...], [N31, N32, N33, N34, ..., ...], ...]

Solid Elements

"MeshTet4": [[N11, N12, N13, N14], [N21, N22, N23, N24], [N31, N32, N33, N34], ...]

"MeshHex8": [[N11, N12, N13, ..., N18], [N21, N22, N23, ..., N28], [N31, N32, N33, ..., N28], ...]

"MeshPyramid5": [[N11, N12, N13, ..., N15], [N21, N22, N23, ..., N25], [N31, N32, N33, ..., N25], ...]

"MeshTet10": [[N11, N12, N13, ..., N1_10], [N21, N22, N23, ..., N2_10], [N31, N32, N33, ..., N2_10], ...]The first 4 columns of the array specifies the indices of the 4 vertices of the tetrahedron, identical to "MeshTet4", and the last 6 columns of the array specifies the mid-edge node indices, sorted in the below order: [N1, N2, N3, N4, N12, N13, N14, N22, N23, N34]

Flexible mesh data containers

Flexible mesh data containers allow one to encode a wide range of mesh data using a simple 2-D array.

"MeshNode": [[x11, y11, z11, ..., w1D, ..., v11, v12, ..., v1P], [x21, y21, z21, ..., w2D, ..., v21, v22, ..., v2P], [x31, y31, z31, ..., w3D, ..., v31, v32, ..., v3P], ...]

"MeshSurf": [[N11, N11, ..., N1K, ..., v11, v12, ..., v1P], [N21, N21, ..., N2K, ..., v21, v22, ..., v2P], [N31, N31, ..., N3K, ..., v31, v32, ..., v3P], ...]

"MeshPoly": [[N11, N12, N13, ..., {properties}], [N21, N22, N23, N24, ...], [N31, N32, N33, N34, ..., ..., [properties] ], ...]

"MeshElem": [[N11, N11, ..., N1K, ..., v11, v12, ..., v1P], [N21, N21, ..., N2K, ..., v21, v22, ..., v2P], [N31, N31, ..., N3K, ..., v31, v32, ..., v3P], ...]

Shape primitives

"ShapeBox2":

"ShapeDisc2":

"ShapeEllipse":

"ShapeLine2":

"ShapeArrow2":

"ShapeAnnulus":

"ShapeGrid2":

"ShapeLine3":

"ShapePlane3":

"ShapeBox3":

"ShapeDisc3":

"ShapeGrid3":

"ShapeSphere":

"ShapeCylinder":

"ShapeEllipsoid":

"ShapeTorus":

"ShapeCone":

Software library

Because JMesh specification is defined base on the JData specification, it shares the same underlying data serialization formats, i.e. JSON for text-based JMesh files (.jmsh) and BJData/UBJSON for binary-based JMesh files (.bmsh). Most existing JSON parsers can readily parse the text-based JMesh files, and similarly, existing UBJSON parsers can be used to parse .bmsh files without modification.

In MATLAB/GNU Octave, saving mesh data to the JMesh format is supported in Iso2Mesh - a 3-D mesh generation toolbox - via the savejmesh function.

See also

External links

Notes and References

  1. Web site: JMesh Specification - Version 1 Draft 1. GitHub. 14 March 2022.
  2. Web site: NeuroJSON/jmesh. GitHub. 14 March 2022.