[cad-linux-dev] CAD::Drawing Perl module data structure

  • From: Eric Wilhelm <ewilhelm@xxxxxxxxxxxxx>
  • To: cad-linux-dev@xxxxxxxxxxxxx
  • Date: Sun, 5 Oct 2003 12:08:30 -0500

I'm deep in the redesign of this package right now, with the intention of 
getting it on CPAN fairly soon.

The new data structure is like this:

$self->{geom}{$layer}{$type}{$index} = \%objecthash;

(where %objecthash depends on the entity type, but will usually contain at 
least "pt" or "pts" keys (i.e. plines have "pts" while circles have "pt" and 
"rad".))

Note that the $index can be a string.  Previously, this was an index in an 
array and the data structure was:
$self->{$layer}{$type}[$index] = \%objecthash;

This was a bad design because it prevented the use of a delete() function 
(since the main program would be (indirectly) holding a handful of indices 
which would then need to shift according to which side of the deleted item 
they happened to fall. (ack!))

Also note that I've also dropped the layer down a level to allow storage of 
drawing constants and other properties besides geometry at the toplevel.  
With this, I'm trying to move away from the limitations of AutoCAD 
conventions and open the door to some new ways of looking at things.

A benefit of the new string-based indexing is also that it can now support the 
directory-based file format.  The index simply becomes the filename, and if a 
call to save() points back to the original directory, each entity would go 
back from whence it came!  The entire module has already supported selective 
reads, and with atomic formats like the directory-based database (and 
sql-table based formats,)  it could now have selective writes which would 
simply replace the original data on a per-entity basis.

While xSpace and Draft have been centered around immediate modification of the 
geometry file, I have based this module more around a data structure.  I'm 
currently trying to work out how to have the methods affect the original data 
in real time.  Possibly this could be done through inheritance, but my 
central idea has been to make the programming interface independent of the 
file format.  Maybe an update function could be defined by the load() 
function?

--Eric
-- 
"Cleanliness is next to impossible."
                                        --Unknown


Other related posts:

  • » [cad-linux-dev] CAD::Drawing Perl module data structure