CAD_BOUNDP(1)
π cad_boundp(1) β the BRL-CAD girlie's guide
okay so bestie, this is cad_boundp, straight out of the BRL-CAD manual set, and it's genuinely one of the most satisfying little tools ever. it finds the bounding polygon of a two-dimensional view. that's the vibe. let's get into it π
β¨ SYNOPSIS β¨
cad_boundp [-i _input_] [-o _output_] [-t _tolerance_] [-v]
that's it. that's the whole incantation. short, sweet, iconic π
πΈ DESCRIPTION πΈ
So here's what's happening, bestie. cad_boundp reads a set of 2D line segments β one per input line, formatted as four whitespace-separated numbers:
x1 y1 x2 y2
and it computes the bounding polygon of the region they outline. no cap. the segments typically describe a two-dimensional view of the edges of a 3D object, which is lowkey the main character situation here.
Then it does the smart stuff: intersecting segments are split so that every polygon vertex falls on a segment endpoint. after that, the perimeter is traced counter-clockwise starting from the vertex with the smallest y coordinate. periods. that's the algorithm and it ate π«Ά
By default, each polygon vertex is written out as an x y pair. And here's a cute detail β input lines that do not begin with a number (so like, comments, or color records) are silently skipped. so you can interleave your segment data with other annotations and it simply does not care. not me being unbothered π
π OPTIONS π
-iinput β read segment data from input instead of standard input. a value of-also selects standard input. (yes, both paths lead to stdin, she's flexible like that β¨)-ooutput β write results to output instead of standard output. a value of-also selects standard output. same energy π-ttolerance β treat two points as identical when the distance between them does not exceed tolerance (default0, requiring an exact match). > careful bestie: a tolerance that's too tight, or incomplete input, may yield a degenerate or smaller-than-expected polygon. specifying double the expected tolerance is often prudent. like, genuinely, take the advice π-vβ emit the result as line segments (x1 y1 x2 y2pairs of consecutive vertices, including the closing edge) rather than as vertex points. this form can be fed back into another invocation ofcad_boundp. recursion slay π₯-h,-?β print a usage message and exit. the classic escape hatch π
π¦ RESTRICTIONS π¦
okay, reality check time, and these ones matter:
- Holes within the view cannot be recognized. nope. not a thing it does. π
- The silhouette thickness must everywhere exceed tolerance (no narrow necking-down) or part of the silhouette will be lost. in particular, the view should not consist of disjoint parts. like at all. fr fr.
so if your shape has a skinny little waist, she's gonna lose it. respect the boundaries β
β EXAMPLES β
Example 1. Tracing the outline of a unit square
$ cat square.txt
# bottom, right, top, and left edges
0.0 0.0 1.0 0.0
1.0 0.0 1.0 1.0
1.0 1.0 0.0 1.0
0.0 1.0 0.0 0.0
$ cad_boundp -t 0.01 -i square.txt
0 0
1 0
1 1
0 1
The four edges are reduced to the bounding polygon's vertices, listed counter-clockwise from the lowest point. and re-running with -v would instead print the closed loop of edge segments, suitable for piping into another cad_boundp or a plotting tool. pipeline queen π
π DIAGNOSTICS π
Any error condition causes cad_boundp to terminate with non-zero exit status after printing a message on standard error. the specific ones:
- Improperly formatted input produces a
"bad input"message. - A perimeter vertex with only one segment attached yields
"degenerate input". - Exhausting available memory yields
"out of memory".
she tells you what went wrong, she's honest, we stan a transparent icon π
π SEE ALSO π
go read those too, iykyk π§
π AUTHOR π
BRL-CAD Team
π COPYRIGHT π
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
don't be shy, they literally want to hear from you π«Ά
and that's the whole page, bestie β straight from the BRL-CAD manual set, version tag CAD_BOUNDP(1), copyright running 1989-2026. go trace some polygons, you got this πβ¨
π¦ where this page comes from
- nixpkgs unstable: brlcad 7.44.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms