g-nmg — Perform Boolean evaluations to produce NMG objects


g-nmg [-v ] [-b ] [-xX lvl] [-t calc_dist_tol] [-a abs_tess_tol] [-n norm_tess_tol] [-P number_of_CPUs] [-r rel_tess_tol] [-o outfile.g] infile.g object(s)


g-nmg performs the Boolean operations in the specified object(s) and writes the resulting NMG primitives (or BOT primitives, if the -b option is specified) to outfile.g or to stdout if the -o option is not used.

The following options are available:

-a abs_tess_tol

Specify an absolute tessellation tolerance (in millimeters). This requires that the maximum absolute error from the tessellated surface to the actual surface must not be greater than abs_tess_tol.


Convert the results to a BOT primitive (triangle representation) instead of leaving it as an NMG.

-n norm_tess_tol

Specify a surface normal error tolerance (in degrees) for the tessellation.

-P #_of_CPUs

Specify the number of CPUs.

-o outfile.g

Specify the name of the file to be created. This should not be the same as the input file.

-r rel_tess_tol

Specify a relative error tolerance. This effectively sets an absolute tolerance for each primitive solid by multiplying the overall size of the solid by rel_tess_tol. This allows small objects to be tessellated with small tolerances, while large objects are tessellated with large tolerances. For example, specifying -r 0.1 when tessellating an object 2m in size will result in a tolerance of .2m (2.0 * 0.1). The same option will cause a 5cm object to be tessellated with a tolerance of 0.5cm.

-t calc_dist_tol

Specify a calculational distance tolerance (in millimeters). This tolerance is used to distinguish neighboring vertices. Any two vertices less than this tolerance distance apart will be considered the same vertex. The default value is 0.005mm. Prior to performing the Boolean operations for each region, the involved primitive solids are converted to a planar facetted approximation and stored as NMG solids. This tessellation can be controlled using the tessellation tolerances.


Produce copious progress information.


Set librt debug flags. The definitions of these flags may be found in raytrace.h.


Set NMG routines debug flags. The definitions of these flags may be found in h/nmg.h.


$ g-nmg -o  shell.g sample.g sample_object


Error messages are intended to be self-explanatory.


Boolean operations under finite precision arithmetic are not guaranteed to be solvable. As a result this command can fail. Scaling geometry adjusting tolerance values, and restructuring the boolean tree will often result in a successful tessellation.




This software is Copyright (c) 1998-2016 by the United States Government as represented by U.S. Army Research Laboratory.


Reports of bugs or problems should be submitted via electronic mail to <>.