CAD_BOUNDP(1)

πŸ“¦
version 7.44.0 Β· 2 versions
, in nixpkgs unstable

πŸ’… 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 πŸ’œ

  • -i input β€” 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 ✨)
  • -o output β€” write results to output instead of standard output. a value of - also selects standard output. same energy πŸŽ€
  • -t tolerance β€” treat two points as identical when the distance between them does not exceed tolerance (default 0, 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 y2 pairs of consecutive vertices, including the closing edge) rather than as vertex points. this form can be fed back into another invocation of cad_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 🌈

brlcad(1), cad_parea(1)

go read those too, iykyk 🧚


πŸ“ 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

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