Skip to documentation
DocumentationAll documentsEnglish

RTWEIGHT(1)

NAME

rtweight - calculate mass, volume, and centroid of geometry via ray tracing

On this page

SYNOPSIS

rtweight [options] model.g [objects...]

DESCRIPTION

rtweight fires a grid of rays at the listed objects in the BRL-CAD database model.g and uses the line-of-sight (LOS) thickness of each region, combined with per-material density, to compute the volume, mass, and overall geometric centroid of the geometry. Boolean operations are honored, so overlapping or subtracted solids are accounted for correctly.

If no objects are listed, rtweight uses the same automatic default-object selection described in rt(1). If no single usable default can be resolved, it aborts before computing mass properties.

Density information is obtained, in order of preference, from a density file named with -d, from a DENSITIES table embedded in _model.g, from material objects in the database, or finally from a .density file in the current directory. A density file contains one entry per line with the integer material id, the density in grams per cubic centimeter, and the material name, separated by whitespace. Regions whose material id has no density entry have their mass reported as undefined while their volume is still computed. See gqa(1) for more on defining and managing density information.

By default rtweight reports the mass of every region individually (by region path name and by region id) in addition to the totals; use -R to print only the summary. Results are written in metric or English units chosen from the database’s editing units.

rtweight accepts the same view, grid, and threading options as rt(1); the most useful ones are listed below. The -C (background color) and -W (white background) options of rt(1) are disabled here.

OPTIONS

-d file

Read density definitions from file instead of from the database.

-o file

Write the report to file rather than to standard output.

-r

Report the mass of each region verbosely (this is the default).

-R

Suppress the per-region report and print only the totals.

-s #

Fire a square grid of by rays (default 512). Conflicts with -g.

-g #

Set the grid cell width in millimeters. Conflicts with -s.

-G #

Set the grid cell height in millimeters.

-a deg

Set the view azimuth in degrees. Use with -e; conflicts with -M.

-e deg

Set the view elevation in degrees. Use with -a; conflicts with -M.

-M

Read the model2view matrix from standard input. Conflicts with -a and -e.

-P #

Use at most # processor cores. The default is all available cores; a negative value means use all but that many.

-U #

Set whether air-coded regions are retained (0 = discard, the default; 1 = keep).

-h, -?

Print a help summary and exit.

Most other rt(1) options (non-square views, perspective, tolerances, debugging flags, and so on) are also accepted.

EXAMPLES

Example 1. Total mass and centroid with a custom density file
rtweight -d steel.density -R -s 1024 engine.g block crankshaft > engine.wt

Fires a 1024x1024 grid at the block and crankshaft regions of engine.g, using the material densities defined in steel.density, and writes only the volume, mass, and centroid totals to engine.wt.

Example 2. Per-region breakdown using densities stored in the database
rtweight -a 35 -e 25 model.g hull

Ray traces the hull assembly from azimuth 35, elevation 25 degrees, pulling density values from the DENSITIES table (or material objects) inside _model.g, and prints the mass of each contained region followed by the overall totals.

SEE ALSO

brlcad(1), rt(1), gqa(1), mged(1), librt(3)

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