home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / IRIT / POLY3DRS.ZIP / PARSER.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-05  |  4.5 KB  |  134 lines

  1. /*****************************************************************************
  2. * General definitions goes here:                                             *
  3. *****************************************************************************/
  4.  
  5. #ifndef PARSER_H
  6. #define PARSER_H
  7.  
  8. #ifndef LINE_LEN
  9. #define LINE_LEN    255
  10. #endif  LINE_LEN
  11.  
  12. #define NAME_LEN    6
  13.  
  14. #ifndef TRUE
  15. #define TRUE        -1
  16. #define FALSE        0
  17. #endif
  18.  
  19. #ifndef NULL
  20. #define NULL        0
  21. #endif
  22.  
  23. #define FILE_TYPE_DATA  1
  24. #define FILE_TYPE_VIEW  2
  25.  
  26. #define    UNGET_STACK_SIZE 5
  27.  
  28. /*****************************************************************************
  29. * Tokens definitions goes into here                                          *
  30. *****************************************************************************/
  31. #define TOKEN_OPEN_PAREN     1
  32. #define TOKEN_CLOSE_PAREN    2
  33.  
  34. #define TOKEN_NUMBER        10     /* Not used as number & names are decoded */
  35.                     /* according to their places in grammer. */
  36. #define TOKEN_VERTEX        20
  37. #define TOKEN_POLYGON       21
  38. #define TOKEN_POLYLINE      22
  39. #define TOKEN_OBJECT        23
  40. #define TOKEN_COLOR         24
  41. #define TOKEN_RGB           25
  42. #define TOKEN_INTERNAL      26
  43. #define TOKEN_PLANE         27
  44. #define TOKEN_NORMAL        28
  45.  
  46. #define TOKEN_OTHER         100            /* Probably names & numbers. */
  47. #define TOKEN_EOF           -1
  48.  
  49. #define VERTEX_ENTRY        0x0001          /* Entry type, up to 16 types. */
  50. #define POLYGON_ENTRY       0x0002
  51. #define POLYLINE_ENTRY      0x0004
  52. #define OBJECT_ENTRY        0x0008
  53. #define COLOR_ENTRY         0x0010
  54.  
  55. /*****************************************************************************
  56. * Parser error codes are following:                                          *
  57. *****************************************************************************/
  58. #define P_ERR_NumberExpected        1
  59. #define P_ERR_CloseParanExpected    2
  60. #define P_ERR_ListCompUndef        3
  61. #define P_ERR_UndefExprHeader        4
  62.  
  63. /*****************************************************************************
  64. * And some more definitions ...                                              *
  65. *****************************************************************************/
  66.  
  67. typedef unsigned char Byte;
  68.  
  69. typedef struct BinTree {       /* The entries are saved as binary trees. */
  70.     struct BinTree *right, *left;               /* Classic, isnt it!? */
  71.     union {
  72.     VoidPtr              PVoid;
  73.     struct VertexStruct  *PVertex;
  74.     struct PolygonStruct *PPolygon;
  75.     struct PolygonStruct *PPolyline;
  76.     struct ObjectStruct  *PObject;
  77.     } Data;
  78.     char Name[NAME_LEN];
  79.     Byte EntryType;                /* Kind of pointer in union. */
  80.     Byte Used;         /* TRUE if allready has been used (multi - referenced). */
  81. } BinTree;
  82.  
  83. typedef struct FileDescription {  /* Each data file loaded gets such struct. */
  84.     BinTree  *VertexPointer,             /* Pointers on the binary trees ... */
  85.          *PolygonPointer,
  86.          *PolylinePointer,
  87.          *ObjectPointer;
  88. } FileDescription;
  89.  
  90. typedef struct ScanConvertStruct {
  91.     int MaxEdgeY;              /* When this edge is no longer active. */
  92.     struct VertexStruct *VMinY, *VMaxY;/* Which vertices form this boundary. */
  93. } ScanConvertStruct;
  94.  
  95. /* Use the following structure if linear list operations are to be performed */
  96. /* on VertexStruct/PolygonStruct/ObjectStruct (Virtual functions...).         */
  97. typedef struct LinearListStruct {
  98.     struct LinearListStruct *Pnext;
  99. } LinearListStruct;
  100.  
  101. typedef struct VertexStruct {
  102.     struct VertexStruct *Pnext;
  103.     int Color;                      /* RGB of vertex as extracted. */
  104.     float Coord[3];                       /* The 3D coords. */
  105.     float Normal[3];                       /* The 3D normal. */
  106.     Byte Transform;
  107.     Byte HasNormal;
  108. } VertexStruct;
  109.  
  110. typedef struct PolygonStruct {
  111.     struct PolygonStruct *Pnext;
  112.     int Xmin, Xmax, Ymin, Ymax;             /* Bounding box of the polygon. */
  113.     struct ScanConvertStruct Bndry1, Bndry2;
  114.     VertexStruct *PVertex;                /* The polygon vertices. */
  115.     float Plane[4];                 /* Plane equation of polygon plane. */
  116.     Byte FlipPlaneDir;
  117.     Byte Polyline;
  118. } PolygonStruct;
  119.  
  120. typedef struct ObjectStruct {
  121.     struct ObjectStruct *Pnext;
  122.     PolygonStruct *PPolygon;
  123.     int Color;                    /* optionally if Color was def.. */
  124.     int RGBColor[3];                   /* Or full RGB was specified. */
  125. } ObjectStruct;
  126.  
  127. /* And function prototypes: */
  128.  
  129. FileDescription *GetDataFile(FILE *f);
  130. void GetViewFile(FILE *f, int FileExists);
  131. BinTree *GetBinTree(char *RecName, BinTree *Tree);
  132.  
  133. #endif PARSER_H
  134.