/* * DXF2FIG : Converter for Autocad DXF format to FIG format. * Aug 1990 : Atari ST and VAX/VMS version by KL * Nov 2003 : Modified for Linux and Xfig by KL * Copyright (c) 1990-2003 by Kees Lemmens * * This software is distributed under the Gnu Public License and as such * may be copied, redistributed and modified freely as long as the original * Copyright above is retained and as long as any software derived from * this is distributed under the Gnu Public License as well. Use of this * software in any patented or closed source software is strictly * prohibited. * * For more information see the GPL : http://www.gnu.org/licenses/gpl.txt * */ /* Note that this DEBUG is coupled with the -v commandline option : for DEBUG = 2 or higher the -v will be automatically set to 2, but for lower values of DEBUG you have to specify -v on the commandline to get debug info. DEBUG = 0 : disables all debug info completely, even if -v is used DEBUG = 1 : default, only verbose output if -v is used on the commandline DEBUG = 2 : always gives (a lot off) output, but still functional DEBUG =>3 : doesn't do anything useful anymore : just for debugging */ #define DEBUG 1 #define TMPDIR "/tmp" #define DEG2RAD 0.0174532925 /* PI*2/360 */ #define PI2 6.2831853072 #define RATIO 1.0 /* aspect ratio between X & Y coords */ /* The line macro's are only here to avoid a dependency on my "hrgraphlib" if * only compiling dxf2fig. For that reason the linestyle macros below have * the same values as the ones in that library */ #define DXFSOLID 'a' #define DXFDOTTED 'b' #define DXFDOTDASHED 'c' #define DXFDASHED 'd' #define DXFLONGDASHED 'e' #define STRSIZE 512 /* Standard size of all string buffers */ typedef struct _parser { int code; char regel[STRSIZE]; char label[STRSIZE]; char text1[STRSIZE]; char text2[STRSIZE]; char blnm[STRSIZE]; char layer[STRSIZE]; int ltype; int dim; double x[4]; double y[4]; double z[4]; double width; double radius; double scale; double angle1; double angle2; int color; int polattr; int txtattr1; int txtattr2; int txtattr3; int txtattr4; int nrvrt; } Parser; typedef struct _plotdata { int width; double angle1; double angle2; long rgbcolor; int ltype; double scale; char *text; /* currently simply pointer to parser txt */ int txthjst; /* text horizontal justification */ int txtvjst; /* text vertical justification */ int xi[4]; /* converted screen coordinates */ int yi[4]; int *xvrt; /* polyline vertices array */ int *yvrt; int nrvrt; /* number of vertices for polylines */ int rx; /* converted screen radius */ int ry; int theight; /* converted screen textheight */ int depth; /* layer number (only for DXF) */ } Plotdata; typedef struct _extends { double xrange; double yrange; double xmin; double ymin; double xmax; double ymax; } Extends; typedef struct _layer { char name[STRSIZE]; int ltype; int color; int depth; } Layer; typedef struct _block { FILE *source; char sname[STRSIZE]; int vp; /* viewpoint or projection for 3D plots */ int mode; /* level of nesting for blocks (toplevel = 1) */ int blkcnt; /* nr of blocks in this dxffile */ Layer *layers; /* dynamic array with layer information */ int layercnt; /* nr of layers in this dxf file */ int arrsize; /* current size of the (dynamic) layer array */ double bbx; /* block base insertion point if not at toplevel */ double bby; /* idem for y coordinate */ double angle; /* rotation angle of this block */ int width; /* These contains the default values for all entities */ int color; /* without a local attribute for this property */ int ltype; /* id. */ double txthgt; /* id. */ double scale; Extends e; } Block; typedef struct _paper { char *name; double wdtcm; double hgtcm; double wdtin; double hgtin; } Paper; /* Global variables */ extern char verbose; /* External function declarations : */ extern double sin(),cos(); /* Stuff from dxfread : */ void debug(char *format, ...); void warning(char *format, ...); int compare(char *str1, char *str2,int len); void errorexit(char *format, ...); void entities(Parser *p, Block *b, char *einde); void startparser(char *dxfname, int viewplane, char *filters); void closeparser(); int lookupdxfltype(char *name); int lookuplayer(char *name, Block *b); /* Stuff from frontend : */ long lookupcolor(int color); int lookupltype(int ltype); int lookuphorjust(int txthjst); int getxres(void); int getyres(void); /* Stuff from dxfplot and dxf2fig : */ void dopoint(Plotdata *d); void doline(Plotdata *d); void dopline(Plotdata *d); void dosolid(Plotdata *d); void do3dface(Plotdata *d); void docircle(Plotdata *d); void doarc(Plotdata *d); void dotext(Plotdata *d); void openblock(Plotdata *d); void closeblock(void); /* Stuff from dxffilter : */ char *filterhelp(); int filter(Plotdata *d); void initfilters(char *filters);