figbuild a 2d->3d converter for xfig

 description:

figbuild reads xfig files (Version 3.x , tested with 3.1 , 3.2) plus its own config file for heights and generates 3d input files for Radiance, Rayshade or, by extending the underlaying GGW library, other formats.

figbuild is useful for fast shading analysis in daylight calculations, to hack lower Manhatten into RADIANCE or to model your favorite ASIC as 3d structure. You may find it faster and cheaper than a full blown CAD program for simple geometries.
Note Jan 2005: On the other hand, figbuild was started half a dozen year ago, and CAD programs are now available in the public domain. Frankly I don't see much use in pushing this further, - consider it historic unless you are explicitly in need for a xfig -> 3D converter.

Example input: (click to download this xfig file and height file)

xfig image

Example output:
radiance image

 download

This code of figbuild is copyrighted by Peter Apian-Bennewitz. You may use the program for any work, but you may not sell it. By downloading you agree to this and the disclaimer below.

The binary should run on a veriety of Linux distibutions. To compile an ANSI-C compiler and (optionally) yacc/lex are needed. Download the ggw library, unpack it and run make. Download the figbuild.tgz file, unpack it, edit the makefile and compile. Have fun. Let me know about problems or if you have a nice application using figbuild and a picture to share.

Note: My qqw library is currently not made public, mostly since that needs some docu and cross-checking. Contact me if you're interested.

Linux 2.4.17/ Slackware 8 figbuild.Linux_2.4.tgz
source figbuild.tgz

 syntax of height file

  1. The vertical wall structure (consisting of segments) is defined in figbuild's height file:
    { figseg-Red-Dashed
    2.0 radmat1
    1.3 radmat2
    0.2 radmat3
    }
    Defines the vertical structure for red-dashed lines : Consist of 3 materials, where radmat3 extends from zero height to 0.2 units, radmat2 extends from 0.2 units to 1.3 units and radmat1 from 1.3 to 2 units. Heights should be specified in increasing order as shown. A material name void suppresses polygon generation for this segment and generates a hole.

    A lower edge maybe given as:
    { figseg-Red-Solid
    4.0 radmat1
    2.0 ground
    }
    Specifying a radmat1 material starting at a height of 2 and extending up to a height of 4. The difference to using 2.0 void here is that the floorpolygon is generated at 2 height-units as well.

    Extrusions:
    {figseg-Yellow-Dashed # "pipeline"
    extrude cyl pipes 0.05
    3.9 ground
    }
    Defines that yellow-dashed lines are transformed into pipes of 0.05 radius at a height of 3.9 units.

    Comments:
    # one-line comments
    /*
    multiline comments
    */
    Lines starting with # and anything between /*....*/ is treated as comment and ignored. Since this input file is read with lex/yacc, any carriage-returns, tabs, blanks etc. may be added or left out at your will.

    Any lines (including comments) in the height file between
    quote on
    this text is directly copied
    quote off
    are copied straight to stdout, which is useful to include material definitions inside the height file.

  2. Ceiling- and floor-materials are specified with
    ceilmat radmat
    floormat radmat
    either inside a defseg-endseg pair (floor/ceiling material for this segment) or outside (default for all following segments). A ceiling is generated for filled xfig structures, which are associated with a wall segment which has a ceilmat specfied. (floor-polygons dito).

  3. Coordinates of the floorplan are read from xfig file and the xfig line parameters are transformed into names for wall segments. Currently the color and line type are assembled into a segment name as: figseg-color-linestyle . Example: A blue, dashed line in the fig drawing has a segment-name attached: figseg-Blue-Dashed . The naming scheme follows the names displayed in xfig's popup menues (and not those given in the FORMAT3.2 doc of xfig). More complex geometry (e.g. windows, ceiling with overhangs etc.) may be generated by combining polylines and polygons in xfig. As mentioned, floors and ceilings are generated for filled or tiled polygons.

    figbuild reads and converts these fig primitives: polyline, polygon, box, compound, circle, text.
    Currently not supported are: splines, ellipse, arc , since they require tesselation into polygons, which might be added later.
    All standard (31) colors may be used, whereas user defined colors are ignored.
    Text with the 'special' flag set is converted to instances. The text consists of instance name and optional Radiance-style transformation parameters. To convert all text ('special' flag set or cleared) use the '-t' option.

    Xfig's displayed coordinates (inch or metric) are used to export to RADIANCE: A box extending from 10 to 20 [cm] in xfig will extend from 10 to 20 RADIANCE units. The same holds true for [inch] units in xfig. The Y-axis in xfig extends along the negative y-axis in RADIANCE, as xfig's origin is fixed to the upper left corner of the 2d drawing. This is compatible with 'North' being 'up' on most drawings and the coordinate system used by gensky/gendaylit

    Notes:

  4. run figbuild:
    figbuild [-f radiance|rayshade] [-i] [-n] -h demo.height -g demo.fig
    writes RADIANCE geometry to stdout. Optional errors and logging infos are sent to stderr.
    command line options
    -f format Radiance | Rayshade
    -igenerate geometry with normals facing inward
    -ndon't re-orient polygons, take orientation as defined in xfig
    -Vdisplay version and exit
    -dturn on debugging


History

figbuild was written by Peter Apian-Bennewitz in 2000+, as a complete rewrite of previous work ('genroom') by the same author at Fraunhofer ISE. It is backward compatible with enhanced features.

Have fun, happy rendering.
contact: (info@pab-opto.de)

DISCLAIMER

PETER APIAN-BENNEWITZ DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.