Class DXF_Reader (unit DXF_read)

Inherits from

TObject

Constructors


Constructor Create (const aName: shortstring);

Constructors and destructors

///////////////////////////////////////////////////////////////////////////// DXFReader implementation /////////////////////////////////////////////////////////////////////////////



Functions

function block_list : Entity_List;

we need to know where the blocks are stored for lookup purposes

Destructor Destroy;


function get_max_extent : Point3D;


function get_min_extent : Point3D;


function layer_num(layername:string) : integer;

removed Aspectratio stuff since it never seems to make any difference and sometimes buggers everything up if (Group=DXF_floatvals1) then Aspect := ValDbl;

function move_to_blocks_section : boolean;

Blocks section

--------------------------------------------------------------------------- } { Blocks section { ---------------------------------------------------------------------------


function move_to_entity_section : boolean;

Entities section

--------------------------------------------------------------------------- } { Entities section { ---------------------------------------------------------------------------


function move_to_header_section : boolean;

Header section

--------------------------------------------------------------------------- } { Header section { ---------------------------------------------------------------------------


function move_to_tables_section : boolean;

Tables section

--------------------------------------------------------------------------- } { Tables (Layers - VPort) section { ---------------------------------------------------------------------------


function read_block : boolean;

I've shifted all block so that the block base lies on the origin, and translated all the points within the block by the corresponding amount This makes the drawing routines less complicated

function read_blocks : boolean;


function read_entities : boolean;


function read_file : boolean;

These are the main routines to use

///////////////////////////////////////////////////////////////////////////// Main routines to use /////////////////////////////////////////////////////////////////////////////


function read_header : boolean;


function read_layer_information : boolean;


function read_tables : boolean;


function read_vport_information : boolean;

This no longer does anything !

function release_control_of_layers : TList;

Hand over ownership of the layers, the owner of the entity lists is now responsible for their destruction

function remove_empty_layers : boolean;

just a delay to let the message be visible

procedure set_skipped_list(s:TStrings);

Since we're not reading all groupcodes, we offer the chance to dump the main titles into a list so we can see what we've missed

function code_and_double(var group:integer; var d:double) : boolean;

useful in debugging if (group=0) then begin astr := IntToStr(group)+' '+s; alb.

function code_and_string(var group:integer; var s:string) : boolean;


function general_purpose_read(obj_type:TClass; var entity:DXF_Entity; var layer:integer) : boolean;

we can read most entities with this one

These ones are straightforward, so we'll use a crafty TClass parameter


procedure goto_marked_position;


procedure go_back_to_last(code:integer; str:shortstring);


procedure go_back_to_start;

--------------------------------------------------------------------------- } { Routines for fetching codes and values { ---------------------------------------------------------------------------

procedure mark_position;


function NextGroupCode: integer;


function read_2Dpoint(var p1:Point3D) : boolean;

This routine is just for the $EXT(max/min) and should be used with care.

function read_entity(s,endstr:string; var entity:DXF_Entity; var layer:integer) : boolean;

this calls the others above

next bit only when vertices overflow


function read_entity_data(ent:abstract_entity) : boolean;

lowest level read function

--------------------------------------------------------------------------- } { Entity reading code { ---------------------------------------------------------------------------


function read_generic(var layer:integer) : abstract_entity;

for safety

function read_insert(var entity:DXF_Entity; var layer:integer) : boolean;

inserts/polylines need a little more complexity

INSERTs may have ATTRIBs + BLOCKs which makes it a little more complicated


function read_polyline(var entity:DXF_Entity; var layer:integer) : boolean;

POLYLINEs have variable number of points.

function skip_upto_section(name:string) : boolean;

y next

function ValDbl: double;


function ValInt: integer;


function ValStr: shortstring;

NextGroupCode

Properties

Events

Variables

colour_BYLAYER : boolean;


DXF_Layers : TList;

We will read the Entities in the layers into this list

max_extents : Point3D;


min_extents : Point3D;

Extents in (x,y) of the dataset

skipped : TStrings;


backflag : boolean;


EC : integer;


fCode : integer;


file_pos : integer;

useful bits to make parsing easier.

fLine : shortstring;


ii : integer;


IO_chan : file;

used when reading data from the file

Line_num : longint;


marked_pos : integer;


num_in_buf : integer;


pBuf : ^tCharArray;


progress : TProgressBar;


SizeOfBuf : integer;



Constructors


Constructor Create (const aName: shortstring);

Constructors and destructors

///////////////////////////////////////////////////////////////////////////// DXFReader implementation /////////////////////////////////////////////////////////////////////////////


Functions


function block_list : Entity_List;

we need to know where the blocks are stored for lookup purposes


Destructor Destroy;


function get_max_extent : Point3D;


function get_min_extent : Point3D;


function layer_num(layername:string) : integer;

removed Aspectratio stuff since it never seems to make any difference and sometimes buggers everything up if (Group=DXF_floatvals1) then Aspect := ValDbl;


function move_to_blocks_section : boolean;

Blocks section

--------------------------------------------------------------------------- } { Blocks section { ---------------------------------------------------------------------------


function move_to_entity_section : boolean;

Entities section

--------------------------------------------------------------------------- } { Entities section { ---------------------------------------------------------------------------


function move_to_header_section : boolean;

Header section

--------------------------------------------------------------------------- } { Header section { ---------------------------------------------------------------------------


function move_to_tables_section : boolean;

Tables section

--------------------------------------------------------------------------- } { Tables (Layers - VPort) section { ---------------------------------------------------------------------------


function read_block : boolean;

I've shifted all block so that the block base lies on the origin, and translated all the points within the block by the corresponding amount This makes the drawing routines less complicated


function read_blocks : boolean;


function read_entities : boolean;


function read_file : boolean;

These are the main routines to use

///////////////////////////////////////////////////////////////////////////// Main routines to use /////////////////////////////////////////////////////////////////////////////


function read_header : boolean;


function read_layer_information : boolean;


function read_tables : boolean;


function read_vport_information : boolean;

This no longer does anything !


function release_control_of_layers : TList;

Hand over ownership of the layers, the owner of the entity lists is now responsible for their destruction


function remove_empty_layers : boolean;

just a delay to let the message be visible


procedure set_skipped_list(s:TStrings);

Since we're not reading all groupcodes, we offer the chance to dump the main titles into a list so we can see what we've missed


function code_and_double(var group:integer; var d:double) : boolean;

useful in debugging if (group=0) then begin astr := IntToStr(group)+' '+s; alb.Items.Add(astr); end;


function code_and_string(var group:integer; var s:string) : boolean;


function general_purpose_read(obj_type:TClass; var entity:DXF_Entity; var layer:integer) : boolean;

we can read most entities with this one

These ones are straightforward, so we'll use a crafty TClass parameter


procedure goto_marked_position;


procedure go_back_to_last(code:integer; str:shortstring);


procedure go_back_to_start;

--------------------------------------------------------------------------- } { Routines for fetching codes and values { ---------------------------------------------------------------------------


procedure mark_position;


function NextGroupCode: integer;


function read_2Dpoint(var p1:Point3D) : boolean;

This routine is just for the $EXT(max/min) and should be used with care....


function read_entity(s,endstr:string; var entity:DXF_Entity; var layer:integer) : boolean;

this calls the others above

next bit only when vertices overflow


function read_entity_data(ent:abstract_entity) : boolean;

lowest level read function

--------------------------------------------------------------------------- } { Entity reading code { ---------------------------------------------------------------------------


function read_generic(var layer:integer) : abstract_entity;

for safety


function read_insert(var entity:DXF_Entity; var layer:integer) : boolean;

inserts/polylines need a little more complexity

INSERTs may have ATTRIBs + BLOCKs which makes it a little more complicated


function read_polyline(var entity:DXF_Entity; var layer:integer) : boolean;

POLYLINEs have variable number of points... Modified to accept polyface mesh variety of polyline ... I've ignored the invisible flag for edges Modified to accept polygon MxN grid mesh ... It's a bit messy - you could simplify it a bit - but hey - what do you expect from free code.


function skip_upto_section(name:string) : boolean;

y next


function ValDbl: double;


function ValInt: integer;


function ValStr: shortstring;

NextGroupCode


Properties


Events


Variables


colour_BYLAYER : boolean;


DXF_Layers : TList;

We will read the Entities in the layers into this list


max_extents : Point3D;


min_extents : Point3D;

Extents in (x,y) of the dataset


skipped : TStrings;


backflag : boolean;


EC : integer;


fCode : integer;


file_pos : integer;

useful bits to make parsing easier...


fLine : shortstring;


ii : integer;


IO_chan : file;

used when reading data from the file


Line_num : longint;


marked_pos : integer;


num_in_buf : integer;


pBuf : ^tCharArray;


progress : TProgressBar;


SizeOfBuf : integer;