CAD Programs on Slackware – 4 – BRL-CAD
BRL-CAD is an open-source solid modeling program originally created by the US Army Ballistic Research Laboratory, that later became the Army Research Laboratory. One of the original creators was Mike Muuss, who also invented the program that has probably been installed on more computers than anything else: the ‘ping’ utility. (Do check the source code for ping.c and you’ll find his name there as the author in December, 1983…)
BRL-CAD is described on its homepage like this:
BRL-CAD is a powerful cross-platform Open Source combinatorial Constructive Solid Geometry (CSG) solid modeling system that includes interactive 3D solid geometry editing, high-performance ray-tracing support for rendering and geometric analysis, network-distributed framebuffer support, image and signal-processing tools, path-tracing and photon mapping support for realistic image synthesis, a system performance analysis benchmark suite, an embedded scripting interface, and libraries for robust high-performance geometric representation and analysis.
As the description says, it includes a ray-tracing module to create good-looking images of your designs.
Building on Slackware
I found a SlackBuild script for BRL-CAD for Slackware 12.2 on SlackBuilds.org but I had to change a few things to get it working.
First of all, the base directory (’<prefix>’) had to be changed to /opt/brlcad, as /usr caused some conflicts with existing libraries and man-pages. This was simple enough.
I also needed to write two patches: one to build it on 13.0, as it stumbled on a bug in gcc 4.3.3, and another to get it working on -current, because of the new libpng library that introduces some incompatibilities. This is the fun part of writing SlackBuilds
In the end, I included a .desktop file to include BRL-CAD in the menu, and two small scripts in /etc/profile.d/ to include the directory with the BRL-CAD binaries in the PATH variable.
The resulting SlackBuild script has been submitted and is currently awaiting approval.
BRL-CAD includes a “Geometry Editor” called ‘mged’ that is command-line based, and a GUI interface called ‘archer’. The latter is still under heavy development and did not work for me, neither on the stable Salckware 13.0, nor on -current. The svn repository has a modified version, but I wanted to stick to a stable release for now. Maybe the next version will work better.
But all documentation and tutorials are based on mged, so I was fine with this for now.
mged opens two windows: the “Command Window” and the “Graphics Window”.
The first tutorial shows how to create a simple mug in a few commands:
opendb mug.g title MGED Tutorial Geometry units in in outside.s rcc 0 0 0 0 0 3.5 1.75 in inside.s rcc 0 0 0.25 0 0 3.5 1.5 in ring.s eto 0 2.5 1.75 1 0 0 1.45 .6 0 0 0.2 comb cup.c u outside.s - inside.s comb handle.c u ring.s - outside.s r mug.r u cup.c u handle.c ae 35 25
Basically, what we do here is:
- Create a new geometry database file called “mug.g”
- Set the title
- Set the units to inches
- Create an “outside” and “inside” cylinder section
- Create a elliptical torus (”eto”) section called ring.s
- Create the combination called cup.c subtracting the inside cylinder from the outside
- Create the combination called handle.c subtracting the outside section from the ring section
- Create the region called mug.r as a union of the cup and the handle
- Show the result from an angle of 35 / 25 degrees
Now let’s do our first ray-tracing, with a few extra commands:
mater mug.r plastic 32 128 32 0 Z draw mug.r rt
- Set the material of our mug to “plastic”, colored green (RGB 32 / 128 / 32)
- Zero the graphics window
- Redraw the mug
- Ray-Trace it
These examples really only touch the surface of the possibilities that BRL-CAD has to offer. This CAD & modeling program has been in continuous development for over twenty years, and has a lot to offer – and completely for free.
- A very solid and stable program, after more than 20 years of development
- Includes ray-tracing module
- Very complete documentation (reference cards, man-pages, tutorials, HTML), with several parts translated into Spanish
- “Different”, command-line based interface, might not be for everyone