JMesh

Last updated
JMesh
OpenJData.png
Filename extension
.jmsh, .bmsh
Internet media type
application/json
Type code TEXT and BINARY
Developed by Qianqian Fang
Initial release16 September 2020;3 years ago (2020-09-16) [1]
Latest release
1.0 Draft 1
16 September 2020;3 years ago (2020-09-16) [2]
Type of formatData interchange
Extended from JSON, JData
Open format?Yes
Website openjdata.org

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.

Contents

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

Marching tetrahedrons.png

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.

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

{"_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.

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":{"_ArrayType_":"typename","_ArraySize_":[N1,N2,N3,...],"_ArrayData_":[v1,v2,v3,...]}

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":{"_DataInfo_":{...},"Data":[...],"Properties":[...]}

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": {"O":[x0,y0], "P": [x1,y1]}
"ShapeDisc2": {"O":[x0,y0], "R": r}
"ShapeEllipse": {"O":[x0,y0], "R": [r1,r2], "Angle":theta0}
"ShapeLine2": {"O":[x0,y0], "V": [v1,v2]}
"ShapeArrow2": {"O":[x0,y0], "V": [v1,v2], "Size": s}
"ShapeAnnulus": {"O":[x0,y0], "R": [r1,r2]}
"ShapeGrid2": {"O":[x0,y0], "P": [x1,y1], "Step":[Nx,Ny]}
"ShapeLine3": {"O":[x0,y0,z0], "V": [v1,v2,v3]}
"ShapePlane3": {"O":[x0,y0,z0], "N": [v1,v2,v3]}
"ShapeBox3": {"O":[x0,y0,z0], "P": [x1,y1,z1]}
"ShapeDisc3": {"O":[x0,y0,z0], "R": r, "N"=[v1,v2,v3]}
"ShapeGrid3": {"O":[x0,y0,z0], "P": [x1,y1,z1], "Step":[Nx,Ny,Nz]}
"ShapeSphere": {"O":[x0,y0,z0], "R": r}
"ShapeCylinder": {"O":[x0,y0,z0], "P":[x1,y1,z1], "R": r}
"ShapeEllipsoid": {"O":[x0,y0,z0], "R": [rx,ry,rz], "Angle":[theta0, phi0]}
"ShapeTorus": {"O":[x0,y0,z0], "R": r1, "Rtube": r2, "N":[v1,v2,v3]}
"ShapeCone": {"O":[x0,y0,z0], "P": [x1,y1,z1], "R": r}

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

Related Research Articles

In mathematics, specifically category theory, a functor is a mapping between categories. Functors were first considered in algebraic topology, where algebraic objects are associated to topological spaces, and maps between these algebraic objects are associated to continuous maps between spaces. Nowadays, functors are used throughout modern mathematics to relate various categories. Thus, functors are important in all areas within mathematics to which category theory is applied.

Bresenham's line algorithm is a line drawing algorithm that determines the points of an n-dimensional raster that should be selected in order to form a close approximation to a straight line between two points. It is commonly used to draw line primitives in a bitmap image, as it uses only integer addition, subtraction, and bit shifting, all of which are very cheap operations in historically common computer architectures. It is an incremental error algorithm, and one of the earliest algorithms developed in the field of computer graphics. An extension to the original algorithm called the midpoint circle algorithm may be used for drawing circles.

<span class="mw-page-title-main">Ray casting</span> Methodological basis for 3D CAD/CAM solid modeling and image rendering

Ray casting is the methodological basis for 3D CAD/CAM solid modeling and image rendering. It is essentially the same as ray tracing for computer graphics where virtual light rays are "cast" or "traced" on their path from the focal point of a camera through each pixel in the camera sensor to determine what is visible along the ray in the 3D scene. The term "Ray Casting" was introduced by Scott Roth while at the General Motors Research Labs from 1978–1980. His paper, "Ray Casting for Modeling Solids", describes modeled solid objects by combining primitive solids, such as blocks and cylinders, using the set operators union (+), intersection (&), and difference (-). The general idea of using these binary operators for solid modeling is largely due to Voelcker and Requicha's geometric modelling group at the University of Rochester. See solid modeling for a broad overview of solid modeling methods. This figure on the right shows a U-Joint modeled from cylinders and blocks in a binary tree using Roth's ray casting system in 1979.

<span class="mw-page-title-main">Perlin noise</span> Type of gradient noise in computer graphics

Perlin noise is a type of gradient noise developed by Ken Perlin in 1983. It has many uses, including but not limited to: procedurally generating terrain, applying pseudo-random changes to a variable, and assisting in the creation of image textures. It is most commonly implemented in two, three, or four dimensions, but can be defined for any number of dimensions.

In computer science, a topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge (u,v) from vertex u to vertex v, u comes before v in the ordering. For instance, the vertices of the graph may represent tasks to be performed, and the edges may represent constraints that one task must be performed before another; in this application, a topological ordering is just a valid sequence for the tasks. Precisely, a topological sort is a graph traversal in which each node v is visited only after all its dependencies are visited. A topological ordering is possible if and only if the graph has no directed cycles, that is, if it is a directed acyclic graph (DAG). Any DAG has at least one topological ordering, and algorithms are known for constructing a topological ordering of any DAG in linear time. Topological sorting has many applications, especially in ranking problems such as feedback arc set. Topological sorting is possible even when the DAG has disconnected components.

<span class="mw-page-title-main">Allen & Ginter</span> American tobacco company

Allen & Ginter was a Richmond, Virginia, tobacco manufacturing company formed by John F. Allen and Lewis Ginter around 1880. The firm created and marketed the first cigarette cards for collecting and trading in the United States. Some of the notable cards in the series include baseball players Charles Comiskey, Cap Anson, and Jack Glasscock, as well as non-athletes like Buffalo Bill Cody.

<span class="mw-page-title-main">Geometry processing</span>

Geometry processing is an area of research that uses concepts from applied mathematics, computer science and engineering to design efficient algorithms for the acquisition, reconstruction, analysis, manipulation, simulation and transmission of complex 3D models. As the name implies, many of the concepts, data structures, and algorithms are directly analogous to signal processing and image processing. For example, where image smoothing might convolve an intensity signal with a blur kernel formed using the Laplace operator, geometric smoothing might be achieved by convolving a surface geometry with a blur kernel formed using the Laplace-Beltrami operator.

<span class="mw-page-title-main">Noctilien</span> Bus service in Paris, France

Noctilien is the night bus service in Paris and its agglomeration. It is managed by the Île-de-France Mobilités, the Île-de-France regional public transit authority, and operated by RATP and Transilien SNCF.

<span class="mw-page-title-main">National primary road</span> Major road in Ireland

A national primary road is a road classification in Ireland. National primary roads form the major routes between the major urban centres. There are 2649 km of national primary roads. This category of road has the prefix "N" followed by one or two digits. Motorways are prefixed "M" followed by one or two digits.

In computer science, the prefix sum, cumulative sum, inclusive scan, or simply scan of a sequence of numbers x0, x1, x2, ... is a second sequence of numbers y0, y1, y2, ..., the sums of prefixes of the input sequence:

The N (Northern) postcode area, also known as the London N postcode area, is the part of the London post town covering part of North London, England. It is a group of 25 postcode districts which covers around 17,429 live postcodes.

In Euclidean geometry, the distance from a point to a line is the shortest distance from a given point to any point on an infinite straight line. It is the perpendicular distance of the point to the line, the length of the line segment which joins the point to nearest point on the line. The algebraic expression for calculating it can be derived and expressed in several ways.

<span class="mw-page-title-main">Vertex (computer graphics)</span>

A vertex in computer graphics is a data structure that describes certain attributes, like the position of a point in 2D or 3D space, or multiple points on a surface.

In computing, sequence containers refer to a group of container class templates in the standard library of the C++ programming language that implement storage of data elements. Being templates, they can be used to store arbitrary elements, such as integers or custom classes. One common property of all sequential containers is that the elements can be accessed sequentially. Like all other standard library components, they reside in namespace std.

<span class="mw-page-title-main">Rijksstraatweg</span>

Rijksstraatweg or simply Straatweg was the term for paved roads of interregional significance in the Netherlands in the 19th and early 20th centuries. These roads were built by the national government, and formed the country's first centrally planned highway network. They received route numbers, eventually resulting in a nationwide network of 82 highways. It formed the basis for today's system of nationally controlled roads, the Netherlands' main highway grid.

Universal Binary JSON (UBJSON) is a computer data interchange format. It is a binary form directly imitating JSON, but requiring fewer bytes of data. It aims to achieve the generality of JSON, combined with being much easier to process than JSON.

In the mathematical field of graph theory, Hall-type theorems for hypergraphs are several generalizations of Hall's marriage theorem from graphs to hypergraphs. Such theorems were proved by Ofra Kessler, Ron Aharoni, Penny Haxell, Roy Meshulam, and others.

<span class="mw-page-title-main">Parti Gagasan Rakyat Sabah</span> Malaysian multiracial political party

The Parti Gagasan Rakyat Sabah or also registered as Parti Gagasan Bersama Rakyat Sabah and better known as Gagasan Rakyat, is a political party based in Sabah, Malaysia mainly to serve as a Sabah-based community and regionalist party. The party was formed and registered on 28 August 2013 by Sabah local politician, Ationg Tituh as a multi-racial Sabah opposition party then with the vision to present the views and will of the original Sabahans to the government. It is only started to be active in 2016 and relatively little-known new party, initially registered as Parti Gagasan Bersama Rakyat Sabah, was among the latest new parties registration approved by the Registrar of Society (RoS) and just received permission to operate as a political party in 2013. This party is the main component of Gabungan Rakyat Sabah (GRS) since 9 December 2022.

JData is a light-weight data annotation and exchange open-standard designed to represent general-purpose and scientific data structures using human-readable (text-based) JSON and (binary) UBJSON formats. JData specification specifically aims at simplifying exchange of hierarchical and complex data between programming languages, such as MATLAB, Python, JavaScript etc. It defines a comprehensive list of JSON-compatible "name":value constructs to store a wide range of data structures, including scalars, N-dimensional arrays, sparse/complex-valued arrays, maps, tables, hashes, linked lists, trees and graphs, and support optional data grouping and metadata for each data element. The generated data files are compatible with JSON/UBJSON specifications and can be readily processed by most existing parsers. JData-defined annotation keywords also permit storage of strongly-typed binary data streams in JSON, data compression, linking and referencing.

References

  1. "JMesh Specification - Version 1 Draft 1". GitHub . 14 March 2022.
  2. "NeuroJSON/jmesh". GitHub . 14 March 2022.