Skip to documentation
DocumentationAll documentsEnglish

G-VOXEL(1)

NAME

g-voxel - voxelize BRL-CAD geometry into a list of occupied voxels

On this page

SYNOPSIS

g-voxel [-s "_dx dy dz_"] [-d _n_] [-t _f_] _model.g_ _object_...

DESCRIPTION

g-voxel raytraces the named object(s) in a BRL-CAD database model.g and samples the geometry onto a regular three-dimensional grid of voxels. Each voxel is sampled by firing a grid of rays through it; the resulting fill fraction (the portion of the voxel occupied by geometry, 0.0 to 1.0) is compared against a threshold. Every voxel whose fill fraction meets or exceeds the threshold is written, one per line, to the file voxels1.txt in the current directory. Output is appended, so an existing voxels1.txt is added to rather than replaced.

Each output line contains the voxel center coordinates (in millimeters, relative to the model bounding box), the name of the region occupying the voxel, and the fill fraction:

(x, y, z)	region_name	fill

OPTIONS

-s "dx dy dz"

Set the voxel dimensions along the X, Y, and Z axes, in millimeters. The three values must be given as a single quoted argument. Default is 1.0 1.0 1.0.

-d n

Set the level of detail, i.e. the number of rays fired per voxel edge (so n x n rays sample each voxel face). Higher values yield more accurate fill fractions at greater cost. Default is 4.

-t f

Set the fill threshold in the range 0.0 to 1.0. A voxel is written only when its fill fraction is greater than or equal to f. Default is 0.5.

EXAMPLES

Example 1. Voxelize at a coarse resolution and inspect the result
rm -f voxels1.txt
g-voxel -s "5 5 5" -d 8 -t 0.5 havoc.g havoc
wc -l voxels1.txt

Removes any stale output, then voxelizes the havoc object using 5mm cubic voxels and 8x8 rays per voxel, keeping voxels that are at least half full. Counting the lines of voxels1.txt reports how many voxels were occupied. The rm is important because g-voxel appends to the output file.

Example 2. Capture only nearly solid voxels at fine resolution
rm -f voxels1.txt
g-voxel -s "1 1 1" -d 16 -t 0.95 engine.g block

Uses 1mm voxels with dense 16x16 sampling and a high threshold so that only voxels almost entirely filled with material are recorded, producing a tight solid-core approximation of the block region.

SEE ALSO

brlcad(1), rt(1), g-raw(1), rtcheck(1)

AUTHOR

BRL-CAD Team

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

BUG REPORTS

Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org