//////////////////////////////////////////////////////
// DXF read/write/display code and utility objects
//
// John Biddiscombe Mar 1997. J.Biddiscombe@rl.ac.uk
//////////////////////////////////////////////////////

This is a much improved set of AutoCAD DXF read/write/display
routines. The earlier version (last year) didn't use objects for 
the basic entity types. This was done for performance reasons, but
it was messy and difficult to follow. This version is much better
in all respects, and the performance has not been affected much.

I have read the DXF files in an 'Ad Hoc' manner. There is a lot
of structure inside the DXF file that doesn't interest me, so I've
simply read the codes that I need. There is plenty of room for
expansion, and ideally, each DXF_Entity would have a read method
which would handle all of its own codes. However I simply didn't
need to bother. The entities we can handle with this code are

Points
Lines
Inserts (with Attribs)
Arcs
Circles
Polylines

You must install the Zoomer.pas unit to the component palette
if you wish to edit the form.

This code is a subset of a much larger set of routines that I have 
written...the reason being...

I work in research, doing Radio Propagation modelling.
(Rutherford Appleton Laboratory, UK)
I'm given DXF files of terrain, trees, building outlines and heights,
which I need to convert into 3D scenes to test my Raytracing code,
which predicts field strengths and area coverage. I needed to be
able to read DXF files, and manipulate the entities. I convert
polylines and lines representing roof features into buildings and
then simulate placing transmitters and receivers in various places
in the database.

Previously I didn't release all the DXF code, because I was not sure
how my employers would take to it. But I have been given permission to 
distribute this DXF code.

Please don't ask me for help. I do not have a copy of AutoCad, and
I've only ever played with it to see how things look. All the 
knowledge I've gained about DXF files has been from the Internet. 
I accept no responsibility for anything to do with this code. It may 
have bugs and errors, and it's up to you to find them.
If you need to know about DXF files, try a Web search for r13dxf.zip,
which contains the specs for the latest (?) DXF format.

Thanks to John F. Herbster for the original DXF class that got me started.

I hope this code helps someone. Please feel free to email me if you find
it useful, as my employers will look kindly upon me :) (and it'll make
me feel better too).

If you can add extra functionality, please let me have a copy of anything
nice.

John B

Notes
-----
The mouse tracking, does not follow the x,y coords of the mouse, but
instead looks for the nearest vertex in the display list(s). It then
shows this point. The extended info shows the full details of the entity
that the point belongs to. The code does this in two passes, it asks
each entity list for the nearest point (using squared distance to save
time), and then afterwards gets the info it needs. (ARCs and CIRCLEs
use the centre of the object geometrically speaking).

I don't know how AutoCAD handles layers, but for my purposes I need to
distinguish between points, lines, polylines etc. So I have opted for
a series of entity lists, where all the entities in a list are of the
same type. This may not be the most efficient method of storing data
but it simplifies my object filtering and building reconstruction from
corner vertices greatly.

When the user selects a bunch of entity lists, I use an object I've
loosely called a selection object. It's really just a list with a few
functions to make my life easier. Most of the functions I need to do
the 3D database creation are not included in this code, so it may give
the impression of being a little over engineered, you may want to strip
out some of the things I've put in.

The polylines has a closed flag to indicate closed polygons, In my code
I create a PolyClosed_ object to distinguish between them. It is not a true
AutoCAD entity, so it is not included here.

If you add your own entities, care should be taken when naming them - I've
used a virtual method - proper_name - to return the DXF entity name that should
be used when writing data to DXF files. At the moment it simply capitalizes
the class name and strips off the underscore.
(e.g. Polyline_ becomes POLYLINE which is the correct DXF name)

None of the code in these files does anything very complicated, so I'm
afraid there's very little in the way of comments or notes. Sorry.

Bugs that I do know about.
--------------------------
When tiny (or zoomed out) ARC's are plotted, The endpoints may be too
small and not seperated by more than one pixel. The Windows ARC routine
fails and draws an ARC that is nearly a complete cirle, rather than a tiny
segment. I don't care, because there are no ARC's in my datasets.

If a file with no $EXTMAX, $EXTMIN data is read, the entities are scanned
to find the limits in (x,y & z), but the values may be incorrect, I think this
is due to my calculation of ARC extents being dodgy. This is also true
when writing DXF files. I use my own format once I've modified the data, so
I've not tested it thoroughly.
