
D2R
A DXF (3DFACE) to RAW File Format Converter
by George Hunt
June 1997
Internet: 102723,1016@compuserve.com
Internet: GHunt10387@aol.com
Copyright 1997, Lightsword Productions

D2R - General

This is a simple DOS command line utility that converts a DXF file, Release 12 
specification, to one or more RAW files.  I have often needed to convert a DXF 
model to something I can use with MORAY/POVRAY.  I like using Thomas 
Baier's "3D to 3D Format Converter" to produce a model that I can manipulate in 
MORAY and render with POVRAY.  But the converter needs RAW (not DXF) 
source data.  Thus, the need for D2R.

See 3D to 3D on Thomas's homepage at:
http://ourworld.compuserve.com/homepages/thbaier

D2R converts only the 3DFACE type of entity from the DXF file.  This is because 
that is how two of the programs I use for creating the occasional object (Model 
Studio and Truespace) store data in DXF files.  A 3DFACE is defined as:

"Four points defining the corners of the face: (10, 20, 30), (11, 21, 
31), (12, 22, 32), and (13, 23, 33)... If only three points are entered 
(forming a triangular face), the third and fourth points will be the 
same."

Each instance of a 3DFACE entity is converted to either 1 or 2 triangles. If the 
third and fourth points in the 3DFACE are not the same, two triangles are 
defined, resulting in two triplets of data in the output RAW file.  Otherwise ( If the 
third and fourth points in the 3DFACE are the same ) only one triangle is 
defined, resulting in one triplet of data in the output RAW file.

Given that D2R can locate and open the specified input file, it will always 
generate a default output file.  This file bears the same name as the input file but 
has an extension of ".RAW".  This default output file contains a default name for 
the raw data ("RawObject") and all triangle data generated from "un-named" 
3DFACEs.  This file is created even if there are no "un-named" 3DFACES in 
which case it will contain only the default Raw Object name.

The triangle data generated for all instances of "named" 3DFACEs in the DXF 
file (indicated by a group value of "8"; usually immediately following the 
declaration of 3DFACE entity) is placed in a file containing only data for the 
"named" object. For instance, if a 3DFACE is encountered with a name of 
"LeftElbow", the triangle data generated will be grouped with all other triangle 
data generated from any other 3DFACE bearing that same name.  All of the data 
for "LeftElbow" will be placed in an output file dedicated to the "LeftElbow" 
object.  The name for the raw data (written as the first line in the output raw file) 
is this same name extracted from the DXF file.

The names assigned to output files other than the default output file are arrived 
at as follows.  First, the original input file name (not considering any extension 
that may have been entered) is truncated to 5 characters if it is greater than 5 
characters in length.  This creates a filename base that all of the output 
filenames will share.  Next a three digit sequence number is concatenated to the 
5 character filename base.  Each new 3DFACE name encounter causes this 
sequence number to be incremented.

In the end, D2R will generate n + 1 output files, where n is the number of unique 
3DFACE "names" encountered in the DXF file. The "1" more is the default output 
file.

If you convert the example DXF file included (chair1.dxf) by running the following 
command:

   D2R CHAIR1

you will see that the resulting files are:

  chair1.raw
  chair000.raw
  chair001.raw
  chair002.raw
  chair003.raw
  chair004.raw
  chair005.raw

The default file is empty except for the default raw object name.  If you care to 
use this exquisitely detailed model for one of your scenes, this (default) output 
file can be discarded. :-)  The remaining six files however contain data for the 
following objects respectively.

  leg1
  leg2
  leg4
  leg3
  seat
  back

Legal Stuff
D2R is Copyright 1996,1997 by George Hunt and Lightsword Productions. It is 
distributed as freeware but is not public domain. This software may be freely 
distributed as long as:
1. no charge is associated with such distribution
2. no changes are made to any part of the program, the accompanying 
documentation or sample data file.
3. the software program, documentation and example data file are distributed 
together as in the original (ZIP) archive.

This software is provided "as is".  There is no warranty, explicit or implied, as to 
the suitability of this software for any purpose.  The user of this software 
assumes the entire risk as to its quality or accuracy.

Although this software is quite simple in nature and has been tested reasonably 
well on different platforms and operating systems, the user assumes all 
responsibility for any and all damages to hardware or other software that may 
result from its use.

No part of this package may be included as part of a commercial package  
without explicit written permission.

Version History
v1.0 April 1996 - not released publicly
v1.1 April 1996


That's it.  Enjoy tracing and write to me questions or ideas.

		06/22/97

	1


