[cad-linux-dev] Re: format as a mini-language

  • From: "Jeffrey McGrew" <JMcGrew@xxxxxxxxxxxxxx>
  • To: <cad-linux-dev@xxxxxxxxxxxxx>
  • Date: Mon, 8 Dec 2003 09:30:43 -0800

> See the chapter in the Raymond book about mini-languages.  He's got =
some
> good thoughts and examples in there.

One way that this exact topic is handled with Radiance, which already
uses a *very* robust plaintext format for geometry storage (albeit for
renderings only), is to have added additional command line tools that
spit out object definitions dependant on the perimeters fed to them.

For example, Radiance has a command called GENBOX. If I type this
on the command line with some arguments;

# genbox blue_plastic box  .5  .5  .5 > box.rad

I get a six sided box, 0.5 units on a side, that's got the
'blue-plastic' as it's material saved as the plaintext file
'box.rad'.

These generator programs are very robust, this is a simple
example, and they have many more switches available.

The way this ties into the parametric/CAD thing is that
you can call upon these generator programs from within
your 'scene' files, and also translate their position
at the same time, as so:

!genbox blue_plastic box  .5  .5  .5  | xform -rz  15  -t  .5  .75  0

This would generate that box, and move it to the location
specified by xform, without having to actually have the
plaintext definition of the six sides of that box within
any file.

The two big advantages of this approach is that one these
geometry generators are simple command-line tools, allowing
you to script them in very complex ways, and two is that
you can use them in such a way so that they don't generate
the geometry until you want to 'view' them, saving overhead
and simplifying plaintext geometry definition (it's easier
to type out !genbox than to define each of the six faces
by hand).

I mean, if I wanted to have a animation where I
had a large group of boxes moving and changing
dependant upon some math function, it would just
take a script that calls the genbox command with
the changing arguments for every frame of my animation.
Additionally, there are already people that do
exactly this with Radiance for fluid analysis
and more.

For example, all of the images on this page
were generated via these command-line tools:
http://mark.technolope.org/pages/ray_4.html

And here's an example of what the genbox command
can do when fed by a script:
http://mark.technolope.org/radmisc/bench2.jpg

So if you generated a few simple command line tools
that generated geometry, and had a way to call them
from within your plaintext format, you could forgo
having to put code into your actual format and instead
have the command line tools do the work. This way
the plaintext format is rather 'dead' if you will.

Sorry to keep bringing up Radiance, but several
of the problems we're discussing here right now
on how to make a plaintext-based CAD system have
be solved in Radiance, and could at least provide
some inspiration as to how to solve some of the
design issues we're talking about now. If Radiance
had some way to 'draw'; some CAD-like front end,
and had provisions for material properties beyond
what their surface renders like, and had some way
to view & interact with the dataset without having
to compile everything into a single static binary
then it would be 90% of the way to being the CAD
system we're all talking about...

Jeffrey

Other related posts: