cad_boundp [-i _input_] [-o _output_] [-t _tolerance_] [-v]
CAD_BOUNDP(1)
NAME
cad_boundp - find bounding polygon of a two-dimensional view
On this page
SYNOPSIS
DESCRIPTION
cad_boundp reads a set of 2D line segments, one per input line as four whitespace-separated numbers (x1 y1 x2 y2), and computes the bounding polygon of the region they outline. The segments typically describe a two-dimensional view of the edges of a 3D object. Intersecting segments are split so that every polygon vertex falls on a segment endpoint, and the perimeter is then traced counter-clockwise starting from the vertex with the smallest y coordinate.
By default each polygon vertex is written as an x y pair. Input lines that do not begin with a number (such as comments or color records) are silently skipped, so segment data may be interleaved with other annotations.
OPTIONS
- -i input
-
Read segment data from input instead of standard input. A value of - also selects standard input.
- -o output
-
Write results to output instead of standard output. A value of - also selects standard output.
- -t tolerance
-
Treat two points as identical when the distance between them does not exceed tolerance (default 0, requiring an exact match). A tolerance that is too tight, or incomplete input, may yield a degenerate or smaller-than-expected polygon; specifying double the expected tolerance is often prudent.
- -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.
- -h, -?
-
Print a usage message and exit.
RESTRICTIONS
Holes within the view cannot be recognized. 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.
EXAMPLES
$ 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. Re-running with -v would instead print the closed loop of edge segments, suitable for piping into another cad_boundp or plotting tool.
DIAGNOSTICS
Any error condition causes cad_boundp to terminate with non-zero exit status after printing a message on standard error. 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".
SEE ALSO
brlcad(1), cad_parea(1)
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