home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / IRIT / POLY3DHS.ZIP / PARSER.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-05  |  4.2 KB  |  128 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_INTERNAL      25
  42. #define TOKEN_PLANE         26
  43.  
  44. #define TOKEN_OTHER         100            /* Probably names & numbers. */
  45. #define TOKEN_EOF           -1
  46.  
  47. #define VERTEX_ENTRY        0x0001          /* Entry type, up to 16 types. */
  48. #define POLYGON_ENTRY       0x0002
  49. #define POLYLINE_ENTRY      0x0004
  50. #define OBJECT_ENTRY        0x0008
  51. #define COLOR_ENTRY         0x0010
  52.  
  53. /*****************************************************************************
  54. * Parser error codes are following:                                          *
  55. *****************************************************************************/
  56. #define P_ERR_NumberExpected        1
  57. #define P_ERR_CloseParanExpected    2
  58. #define P_ERR_ListCompUndef        3
  59. #define P_ERR_UndefExprHeader        4
  60.  
  61. /*****************************************************************************
  62. * And some more definitions ...                                              *
  63. *****************************************************************************/
  64.  
  65. typedef unsigned char Byte;
  66.  
  67. typedef struct BinTree {       /* The entries are saved as binary trees. */
  68.     struct BinTree *right, *left;              /* Classic, isnt it !? */
  69.     union {
  70.     VoidPtr              PVoid;
  71.     struct VertexStruct  *PVertex;
  72.     struct PolygonStruct *PPolygon;
  73.     struct PolygonStruct *PPolyline;
  74.     struct ObjectStruct  *PObject;
  75.     } Data;
  76.     char Name[NAME_LEN];
  77.     Byte EntryType;                /* Kind of pointer in union. */
  78.     Byte Used;         /* TRUE if allready has been used (multi - referenced). */
  79. } BinTree;
  80.  
  81. typedef struct FileDescription {  /* Each data file loaded gets such struct. */
  82.     BinTree *VertexPointer,             /* Pointers on the binary trees ... */
  83.         *PolygonPointer,
  84.         *PolylinePointer,
  85.         *ObjectPointer;
  86. } FileDescription;
  87.  
  88. /* Use the following structure if linear list operations are to be performed */
  89. /* on VertexStruct/PolygonStruct/ObjectStruct (Virtual functions...).         */
  90. typedef struct LinearListStruct {
  91.     struct LinearListStruct *Pnext;
  92. } LinearListStruct;
  93.  
  94. typedef struct VertexStruct {
  95.     struct VertexStruct *Pnext;
  96.     float Coord[3];                       /* The 3D coords. */
  97.     Byte Transform;
  98.     Byte Internal;               /* If edge is Internal (IRIT output). */
  99. } VertexStruct;
  100.  
  101. typedef struct EdgeStruct {
  102.     struct VertexStruct *Vertex[2];           /* The two edge vertices. */
  103.     struct EdgeStruct *Pnext;
  104.     Byte Internal;               /* If edge is Internal (IRIT output). */
  105. } EdgeStruct;
  106.  
  107. typedef struct PolygonStruct {
  108.     struct PolygonStruct *Pnext;
  109.     VertexStruct *PVertex;                /* The polygon vertices. */
  110.     float Xmin, Xmax, Ymin, Ymax;         /* Bounding box of the polygon. */
  111.     float Plane[4];                 /* Plane equation of polygon plane. */
  112.     Byte Polyline;
  113. } PolygonStruct;
  114.  
  115. typedef struct ObjectStruct {
  116.     struct ObjectStruct *Pnext;
  117.     int Color;                    /* optionally if Color was def.. */
  118.     PolygonStruct *PPolygon;                /* The objects polygons. */
  119. } ObjectStruct;
  120.  
  121. /* And function prototypes: */
  122.  
  123. FileDescription *GetDataFile(FILE *f);
  124. void GetViewFile(FILE *f, int FileExists);
  125. BinTree *GetBinTree(char *RecName, BinTree *Tree);
  126.  
  127. #endif PARSER_H
  128.