A find Command for BRL-CAD geometry

Image:Design_icon.png This page contains the design document for an enhancement or feature. The design should be considered a work in progress and may not represent the final design. As this is a collaborative design, contributions and participation from other developers and users is encouraged. Use the discussion page for providing comments and suggestions.

Contents

[edit] A find Command for BRL-CAD

In most Unix-style command line environments there exists a find command used to list files according to user specified criteria and then carry out operations on the returned lists. This document is intended to lay out the features a find command targeted for use inside BRL-CAD should have - what features of find are appropriate, what features make no sense in the context of a BRL-CAD database, and what features should be added to better interact with model geometry.

The basic syntax of find:

find path... [operating options...]

I would like to propose that a default path assumption of "/" be made if no pathname is supplied - e.g. find -name object1.s would be the same as find / -name object1.s. If a pathname starts with the "-" character it can be "escaped" with the "/" character - e.g. : find /-assembly -name object1.s instead of find -assembly -name object1.s

[edit] Basic Functionality

Features found in operating system find commands of interest to BRL-CAD:

  1. -name : Basic regular expression based name matching. Probably the most basic option for any find command.
  2. -exec : Executing a command on the list returned by a search. Some thought may need to be given on sanity checking and how to handle various commands (e.g. what would --exec sed {}; do with a mixed list of solids and combinations?)
  3. -depth: Limit how far down a tree find will proceed relative to the given path.

[edit] BRL-CAD Specific Functionality

Features added or altered from standard find commands specifically for BRL-CAD:

  1. -type : Rather than accepting file system types, this argument should accept object types - primitive types (arb8/ell1/eto...), all solids (solids/sol/s), all combinations (combinations/comb/c), all regions (regions/r), and possibly all assemblies (combinations above the region level).
  2. -attr [!]attrname[=attrval] : An attribute option that returns objects that do/don't have a given attribute, or if a specific value of the attribute is specified both the name and value must match. Also support one or more special options - obvious one is "nonstd" to list any object with a "nonstandard" attribute - e.g. one not found in the basic BRL-CAD attributes normally used by regions et. al.
  3. -vol x1 y1 z1 x2 y2 z2 : Specify a 3D volume and return all displayed objects whose bounding boxes are within that volume - this option would provide a "spacial find". On a related note, support specifying an object from which to pull coordinates : -bbox select_box.s

[edit] Possibly Useful Existing Code

It is possible that existing find code could be adapted to work with BRL-CAD, but this is not yet known. Any suggestions need to remember the licensing constraints: LGPL or Modified BSD.

  1. OpenBSD's implementation of find: [1]
  2. NetBSD's copy is here, maybe same as OpenBSD: [2]

[edit] References

  1. Posix find: [3]
  2. Heirloom man page for find: [4]
  3. GNU fileutils: [5]