home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / demos / gpc / bifbuild.c < prev    next >
Encoding:
Text File  |  1991-08-23  |  95.4 KB  |  2,744 lines

  1. /* $XConsortium: bifbuild.c,v 5.4 91/08/23 16:45:28 rws Exp $ */
  2. /***********************************************************
  3. Copyright (c) 1989,1990, 1991 by Sun Microsystems, Inc. and the X Consortium at M.I.T.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its
  8. documentation for any purpose and without fee is hereby granted,
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in
  11. supporting documentation, and that the names of Sun Microsystems,
  12. the X Consortium, and MIT not be used in advertising or publicity
  13. pertaining to distribution of the software without specific, written
  14. prior permission.
  15.  
  16. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  17. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  18. SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  19. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22. SOFTWARE.
  23.  
  24. ******************************************************************/
  25.  
  26. /*--------------------------------------------------------------------*\
  27. |
  28. |  Copyright (C) 1989,1990, 1991, National Computer Graphics Association
  29. |
  30. |  Permission is granted to any individual or institution to use, copy, or
  31. |  redistribute this software so long as it is not sold for profit, provided
  32. |  this copyright notice is retained.
  33. |
  34. |                         Developed for the
  35. |                National Computer Graphics Association
  36. |                         2722 Merrilee Drive
  37. |                         Fairfax, VA  22031
  38. |                           (703) 698-9600
  39. |
  40. |                                by
  41. |                 SimGraphics Engineering Corporation
  42. |                    1137 Huntington Drive  Unit A
  43. |                      South Pasadena, CA  91030
  44. |                           (213) 255-0900
  45. |---------------------------------------------------------------------
  46. |
  47. | Author        :    SimGraphics Engineering Corportation
  48. |
  49. | File          :    bifbuild.c
  50. | Date          :    Fri Feb  9 10:46:55 PST 1990
  51. | Project       :    PLB
  52. | Description   :    Contain the BUILD/EXECUTE functions for turning
  53. |            parser date into BIF entities and dealing
  54. |            with them appropriately.
  55. |                                                                    
  56. | Status        :    Version 1.0
  57. |
  58. | Revisions     :    
  59. |
  60. |    4/4/89        JMZ SimGEC: Fixes to bif_matrix3,
  61. |            bif_gtransform3, bif_ltransform3,
  62. |            bif_clear, bif_rotate3
  63. |
  64. |    2/90        Staff SimGEC: Background color/colorindex
  65. |
  66. |       2/90            MFC Tektronix, Inc.: PEX-SI API implementation.
  67. |                       
  68. |       5/90            MFC Tektronix, Inc.: PEX-SI API Binding change.
  69. |
  70. |      12/90            MFC Tektronix, Inc.: PEX-SI PEX5R1 Release.
  71. |
  72. \*--------------------------------------------------------------------- */
  73.     
  74. /*--------------------------------------------------------------------*\
  75. |    Table of Contents
  76. |
  77. |    int bif_mktype(BIF_INT)
  78. |        :    Receive a MARKER_TYPE entity from the parser
  79. |    int bif_linetype(BIF_INT)
  80. |        :    Receive a LINE_TYPE entity from the parser
  81. |    int bif_lineshading(BIF_INT)
  82. |        :    Receive a LINE_TYPE entity from the parser
  83. |    int bif_linewidth(BIF_REAL)
  84. |        :    Receive a LINE_WIDTH entity from the parser
  85. |    int bif_intstyle(BIF_INT)
  86. |        :    Receive an INTERIOR_STYLE entity from the parser
  87. |    int bif_intpatternindex(BIF_INT)
  88. |        :    Receive an INTERIOR_PATTERN_INDEX entity from the
  89. |    int bif_intshade(BIF_INT)
  90. |        :    Receive an INTERIOR_SHADING entity from the parser
  91. |    int bif_intlight(BIF_INT)
  92. |        :    Receive an INTERIOR_LIGHTING entity from the parser
  93. |    int bif_curve_approx_criteria (BIF_INT, BIF_REAL)
  94. |        :    Receive an INTERIOR_LIGHTING entity from the parser
  95. |    int bif_curve_approx_criteria (BIF_INT,BIF_REAL)
  96. |        :    Receive an INTERIOR_LIGHTING entity from the parser
  97. |    int bif_curve_approx_criteria (BIF_INT,BIF_REAL)
  98. |        :    Receive an INTERIOR_LIGHTING entity from the parser
  99. |    int bif_surfprop(BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL,
  100. |                BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL)
  101. |        :    Receive a SURFACE_PROPERTIES entity from the parser
  102. |    int bif_bkfprop(BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL,
  103. |                BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL)
  104. |        :    Receive a BACKFACE_PROPERTIES entity from the parser
  105. |    int bif_bkfprocessing(BIF_INT,BIF_INT)
  106. |        :    Receive a BACK_FACE_PROCESSING entity from
  107. |    int bif_edgeflag(BIF_INT)
  108. |        :    Receive an EDGE_FLAG entity from the parser
  109. |    int bif_edgetype(BIF_INT)
  110. |        :    Receive an EDGE_TYPE entity from the parser
  111. |    int bif_edgewidth(BIF_REAL)
  112. |        :    Receive an EDGE_WIDTH entity from the parser
  113. |    int bif_textfont(BIF_INT)
  114. |        :    Receive a TEXT_FONT entity from the parser
  115. |    int bif_textprec(BIF_INT)
  116. |        :    Receive a TEXT_PREC entity from the parser
  117. |    int bif_textpath(BIF_INT)
  118. |        :    Receive a TEXT_PATH entity from the parser
  119. |    int bif_textalign(BIF_INT, BIF_INT)
  120. |        :    Receive a TEXT_ALIGN entity from the parser
  121. |    int bif_charheight(BIF_REAL)
  122. |        :    Receive a CHAR_HEIGHT entity from the parser
  123. |    int bif_charexp(BIF_REAL)
  124. |        :    Receive a CHAR_EXP entity from the parser
  125. |    int bif_charspace(BIF_REAL)
  126. |        :    Receive a CHAR_SPACE entity from the parser
  127. |    int bif_charupvector(BIF_REAL, BIF_REAL)
  128. |        :    Receive a CHAR_UP_VECTOR entity from the parser
  129. |    int bif_annotextcharheight(BIF_REAL)
  130. |        :    Receive a ANNO_TEXT_CHAR_HEIGHT entity from the parser
  131. |    int bif_annotextcharupvector(BIF_REAL, BIF_REAL)
  132. |        :    Receive a ANNO_TEXT_CHAR_UP_VECTOR entity from
  133. |    int bif_annotextstyle(BIF_INT)
  134. |        :    Receive a ANNO_TEXT_STYLE entity from the parser
  135. |    int bif_definelight(BIF_INT)
  136. |        :    Begin / End receiving a DEFINE_LIGHT entity from
  137. |    int bif_lightbasic(BIF_INT, BIF_REAL, BIF_REAL, BIF_REAL)
  138. |        :    Receive basic data for DEFINE_LIGHT entity from
  139. |    int bif_ldtranform(BIF_INT)
  140. |        :    Receive the matrix id of the Light Definition
  141. |    int bif_lightoption(BIF_INT, BIF_REAL, BIF_REAL, BIF_REAL,
  142. |                BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL,
  143. |                BIF_REAL, BIF_REAL, BIF_REAL)
  144. |        :    Receive data for DEFINE_LIGHT entity from the
  145. |    int bif_lightstate(BIF_INT)
  146. |        :    Begin / End receiving a LIGHT_STATE entity from
  147. |    int bif_definedepthcue(BIF_INT, BIF_INT, BIF_REAL, BIF_REAL,
  148. |                BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL,
  149. |                BIF_REAL)
  150. |        :    Receive the results of a DEFINE_DEPTHCUE
  151. |    int bif_depthcueindex(BIF_INT)
  152. |        :    Receive a DEPTHCUE_INDEX entity from the parser
  153. |    int bif_hlhsremoval(BIF_INT)
  154. |        :    Receive a HLHS_REMOVAL entity from the parser
  155. |    int bif_definecolor(BIF_INT, BIF_REAL, BIF_REAL, BIF_REAL)
  156. |        :    Receive a DEFINE_COLOR entity from the parser
  157. |    bif_backgroundcolor(BIF_REAL,BIF_REAL,BIF_REAL)
  158. |        :    Define the background true color components
  159. |    bif_backgroundcolorindex(BIF_INT)
  160. |        :    Define the background color index
  161. |    int bif_identity3(BIF_INT)
  162. |        :    Receive an IDENTITY3 entity from the parser
  163. |    int bif_concatmatrix3(BIF_INT, BIF_INT, BIF_INT)
  164. |        :    Receive a CONCAT_MATRIX3 entity from the parser
  165. |    int bif_invertmatrix3(BIF_INT)
  166. |        :    Receive an INVERT_MATRIX3 entity from the parser
  167. |    int bif_rotate3( BIF_INT, BIF_REAL, BIF_INT, BIF_INT )
  168. |        :    Receive a ROTATE3 entity from the parser
  169. |    BIF_INT bif_rotatexyz3(BIF_INT,BIF_REAL,BIF_REAL, BIF_REAL,BIF_INT)
  170. |        :    Receive a ROTATE_XYZ3 entity from the parser
  171. |    int bif_translate3(BIF_INT , BIF_REAL, BIF_REAL, BIF_REAL, BIF_INT)
  172. |        :    Receive a TRANSLATE3 entity from the parser
  173. |    int bif_scale3(BIF_INT , BIF_REAL, BIF_REAL, BIF_REAL, BIF_INT)
  174. |        :    Receive a SCALE3 entity from the parser
  175. |    int bif_matrix3(BIF_INT, *BIF_REAL, BIF_INT)
  176. |        :    Receive a MATRIX3 entity from the parser
  177. |    int bif_getmatrix3(BIF_INT, BIF_INT, BIF_INT)
  178. |        :    Receive a GET_MATRIX3 entity from the parser
  179. |    int bif_pushmatrix3()
  180. |        :    Receive a PUSH_MATRIX3 entity from the parser
  181. |    int bif_popmatrix3()
  182. |        :    Receive a POP_MATRIX3 entity from the parser
  183. |    int bif_gtransform3(*BIF_REAL)
  184. |        :    Receive a GLOBAL_TRANSFORMATION3 entity from the
  185. |    int bif_ltransform3(*BIF_REAL, BIF_INT)
  186. |        :    Receive a LOCAL_TRANSFORMATION3 entity from the
  187. |    int bif_applytoglobal3(BIF_INT)
  188. |        :    Receive an APPLY_TO_GLOBAL3 entity from the parser
  189. |    int bif_applytolocal3(BIF_INT, BIF_INT)
  190. |        :    Receive an APPLY_TO_LOCAL3 entity from the parser
  191. |    int bif_cleargeom()
  192. |        :    Receive a CLEAR_GEOMETRY entity from the parser.
  193. |    int bif_reportfile(*char)
  194. |        :    Receive a REPORT_FILE entity from the parser.
  195. |    int bif_begintest(BIF_INT)
  196. |        :    Receive a BEGIN_TEST entity from the parser
  197. |    int bif_endtest()
  198. |        :    Receive an END_TEST entity from the parser
  199. |    int bif_pause()
  200. |        :    Receive a PAUSE entity from the parser
  201. |    int bif_sleep(BIF_INT)
  202. |        :    Receive a SLEEP entity from the parser
  203. |    int indexRange(int, int, int, int)
  204. |        :    Check the supplied index against the range
  205. |
  206. \*--------------------------------------------------------------------*/
  207.     
  208. /*--------------------------------------------------------------------*\
  209. |    Include files 
  210. \*--------------------------------------------------------------------*/
  211. #include <stdio.h>
  212. #include "biftypes.h"
  213. #include "bifbuild.h"
  214. #include "new_ents.h"
  215. #include "bifparse.h"
  216. #include "db_tools.h"
  217. #include "doentity.h"
  218. #include "bifmacro.h"
  219. #include "globals.h"
  220. #include "ph_map.h"
  221. #include "macfunct.h"
  222. #include "brftypes.h"
  223. #include "brfexption.h"
  224. #include <X11/Xfuncs.h>
  225.     
  226.     
  227. /*--------------------------------------------------------------------*\
  228. |Local #define
  229. \*--------------------------------------------------------------------*/
  230.     
  231. /*--------------------------------------------------------------------*\
  232. | Local MACROS    
  233. \*--------------------------------------------------------------------*/
  234.     
  235. /*--------------------------------------------------------------------*\
  236. | External Symbols
  237. \*--------------------------------------------------------------------*/
  238.     void noop_function();
  239.     
  240. /*--------------------------------------------------------------------*\
  241. | Local global variables
  242. \*--------------------------------------------------------------------*/
  243.     /* Useful statics */
  244.     /* Temporary entity storage */
  245.     static BIF_All temp_ent;
  246.     static BIF_Begintest current_test;
  247.     static BIF_Traverser_state temp_state;
  248.     static BIF_Traverser_state *temp_state_ptr = &temp_state;
  249.     static BRF_state brf_state;
  250.     static int background_color_index = -1;
  251.     
  252.     /* The identity matrix */
  253.     static float ident_matrix[4][4] =
  254. {
  255.     1., 0., 0., 0.,
  256.     0., 1., 0., 0.,
  257.     0., 0., 1., 0.,
  258.     0., 0., 0., 1.,
  259. };
  260.  
  261.  
  262. /*--------------------------------------------------------------------*\
  263. | BEGIN PROCEDURE CODE
  264. \*--------------------------------------------------------------------*/
  265.  
  266. /* ****************************************
  267.  * Primitives Attributes
  268.  * ************************************** */
  269.  
  270. /* ***************** */
  271. /* Marker Attributes */
  272. /* ***************** */
  273. /*----------------------------------------------------------------------*\
  274. | Procedure    :    int bif_mktype(BIF_INT)
  275. |------------------------------------------------------------------------|
  276. | Description    :    Receive a MARKER_TYPE entity from the parser
  277. |            pass it on to a generic build, store/execute
  278. |            function.
  279. |------------------------------------------------------------------------|
  280. | Return    :    Error Code
  281. \*----------------------------------------------------------------------*/
  282. int bif_mktype(marker_type)
  283.     BIF_INT marker_type;
  284. {
  285.     static entSize = sizeof(BIF_Index);
  286.     /* Build, Store/Execute the entity */
  287.     /* NOTE: + 1 to map BIF markertypes to PHIGs markertypes */
  288.     bif_index((int)(marker_type+1),entSize,MARKER_TYPE,do_markertype,
  289.           pset_marker_type);
  290. } /* End procedure bif_mktype */
  291.  
  292. /* MACRO-GENERATED FUNCTIONS */
  293. /* APPROX: MARKER_SIZE integer multiples only */
  294.     MF_BIF_SIZE(bif_mkscale,MARKER_SIZE,do_markersize,pset_marker_size)
  295.     
  296.     MF_TRUE_COLOR(bif_mkcolor,MARKER_COLOR,do_markercolor,pset_marker_colr)
  297.     
  298.     MF_MAP_INDEX(bif_mkcolorindex,MARKER_COLOR_INDEX,
  299.          do_markercolorindex,pset_marker_colr)
  300.     
  301. /* *************** */
  302. /* Line Attributes */
  303. /* *************** */
  304. /*----------------------------------------------------------------------*\
  305. | Procedure    :    int bif_linetype(BIF_INT)
  306. |------------------------------------------------------------------------|
  307. | Description    :    Receive a LINE_TYPE entity from the parser
  308. |            pass it on to a generic build, store/execute
  309. |            function.
  310. |------------------------------------------------------------------------|
  311. | Return    :    Error Code
  312. \*----------------------------------------------------------------------*/
  313.     int bif_linetype(line_type)
  314.     BIF_INT line_type;
  315. {
  316.     static int entSize = sizeof(BIF_Index);
  317.     /* Build, Store/Execute the entity */
  318.     /* NOTE: + 1 to map BIF linetypes to PHIGs linetypes */
  319.     bif_index((int)(line_type+1),entSize,LINE_TYPE,do_linetype,
  320.           pset_linetype);
  321.     
  322. } /* End procedure bif_linetype */
  323.  
  324. /*----------------------------------------------------------------------*\
  325. | Procedure    :    int bif_lineshading(BIF_INT)
  326. |------------------------------------------------------------------------|
  327. | Description    :    Receive a LINE_TYPE entity from the parser
  328. |            pass it on to a generic build, store/execute
  329. |            function.
  330. |------------------------------------------------------------------------|
  331. | Return    :    Error Code
  332. \*----------------------------------------------------------------------*/
  333. int bif_lineshading(line_shade)
  334.     BIF_INT line_shade;
  335. {
  336.     /* Build, Store/Execute the entity */
  337.     /* NOTE: + 1 to map BIF lineshading to PHIGs lineshading  */
  338.     bif_index((int)(line_shade+1),sizeof(BIF_Index),
  339.           LINE_SHADING,do_lineshading, pset_line_shad_meth);
  340.     
  341. } /* End procedure bif_lineshading */
  342.  
  343. /*----------------------------------------------------------------------*\
  344. | Procedure    :    int bif_linewidth(BIF_REAL)
  345. |------------------------------------------------------------------------|
  346. | Description    :    Receive a LINE_WIDTH entity from the parser
  347. |            pass it on to a generic build, store/execute
  348. |            function.
  349. |------------------------------------------------------------------------|
  350. | Return    :    Error Code
  351. \*----------------------------------------------------------------------*/
  352. int bif_linewidth(line_width)
  353.     BIF_REAL line_width;
  354. {
  355.     /* Build, Store/Execute the entity */
  356.     bif_size((float)line_width,sizeof(BIF_Size),
  357.          LINE_WIDTH,do_linewidth,pset_linewidth);
  358.     
  359. #ifdef EXTERNALNOTE
  360.     /* Alliant has a hardware problem with line widths > 1.
  361.        The resultant line is deviod of any defined line type,
  362.        and will no longer Z buffer. Since this is a temporary concern,
  363.        merely issuing a warning to inform the user that what he sees 
  364.        on the graphics device may not be a problem with his PLB file. This
  365.        is a good example of 'catch all' exception handling! */
  366. #endif
  367.     
  368. } /* End procedure bif_linewidth */
  369.  
  370. /* MACRO-GENERATED FUNCTIONS */
  371.     MF_TRUE_COLOR(bif_linecolor,LINE_COLOR,do_linecolor,pset_line_colr)
  372.     
  373.     MF_MAP_INDEX(bif_linecolorindex,LINE_COLOR_INDEX,do_linecolorindex,
  374.          pset_line_colr)
  375.     
  376. /* ****************** */
  377. /* Polygon Attributes */
  378. /* ****************** */
  379. /*----------------------------------------------------------------------*\
  380. | Procedure    :    int bif_intstyle(BIF_INT)
  381. |------------------------------------------------------------------------|
  382. | Description    :    Receive an INTERIOR_STYLE entity from the parser
  383. |            pass it on to a generic build, store/execute
  384. |            function.
  385. |------------------------------------------------------------------------|
  386. | Return    :    Error Code
  387. \*----------------------------------------------------------------------*/
  388.     int bif_intstyle(style_index)
  389.     BIF_INT style_index;
  390. {
  391.     int sty_index;
  392.     /* Build, Store/Execute the entity */
  393.     sty_index = REMAP_INTSTYLE(style_index);
  394.     /* NONSUP: interior style PATTERN */
  395.     /* Must also do backface interior style */
  396.     bif_2_index(sty_index, sizeof(BIF_Index),
  397.         INTERIOR_STYLE, do_interiorstyle,
  398.         pset_int_style,
  399.         pset_back_int_style);
  400. } /* End procedure bif_intstyle */
  401.  
  402. /*----------------------------------------------------------------------*\
  403. | Procedure    :    int bif_intpatternindex(BIF_INT)
  404. |------------------------------------------------------------------------|
  405. | Description    :    Receive an INTERIOR_PATTERN_INDEX entity from the
  406. |            parser pass it on to a generic build,
  407. |            store/execute function.
  408. |------------------------------------------------------------------------|
  409. | Return    :    Error Code
  410. \*----------------------------------------------------------------------*/
  411. int bif_intpatternindex(pattern_index)
  412.     BIF_INT pattern_index;
  413. {
  414.     /* Build, Store/Execute the entity */
  415.     /* Must also do back interior style index */
  416.     bif_2_index((int)pattern_index, sizeof(BIF_Index),
  417.         INTERIOR_PATTERN_INDEX, do_interiorpatternindex, 
  418.         pset_int_style_ind,
  419.         pset_back_int_style_ind);
  420.     
  421. } /* End procedure bif_intpatternindex */
  422.  
  423. /*----------------------------------------------------------------------*\
  424. | Procedure    :    int bif_intshade(BIF_INT)
  425. |------------------------------------------------------------------------|
  426. | Description    :    Receive an INTERIOR_SHADING entity from the parser
  427. |            pass it on to a generic build, store/execute
  428. |            function.
  429. |------------------------------------------------------------------------|
  430. | Return    :    Error Code
  431. \*----------------------------------------------------------------------*/
  432. int bif_intshade(shade_type)
  433.     BIF_INT shade_type;
  434. {
  435.     /* Build, Store/Execute the entity */
  436.     /* BIF shade types match the values for the GX4000 */
  437.     /* Must also do backface interior shading */
  438.     bif_2_index((int)shade_type, sizeof(BIF_Index),
  439.         INTERIOR_SHADING, do_interiorshading,
  440.         pset_int_shad_meth,
  441.         pset_back_int_shad_meth);
  442.  
  443. } /* End procedure bif_intshade */
  444.  
  445. /*----------------------------------------------------------------------*\
  446. | Procedure    :    int bif_intlight(BIF_INT)
  447. |------------------------------------------------------------------------|
  448. | Description    :    Receive an INTERIOR_LIGHTING entity from the parser
  449. |            pass it on to a generic build, store/execute
  450. |            function.
  451. |------------------------------------------------------------------------|
  452. | Return    :    Error Code
  453. \*----------------------------------------------------------------------*/
  454. int bif_intlight(light_type)
  455.     BIF_INT light_type;
  456. {
  457.     /* Build, Store/Execute the entity */
  458.     /* BIF shade types match the values for the GX4000 */
  459.     /* Must also do back interior reflectance eq */
  460.     bif_2_index((int)light_type, sizeof(BIF_Index),
  461.         INTERIOR_LIGHTING, do_interiorlighting,
  462.         pset_refl_eqn,
  463.         pset_back_refl_eqn);
  464.  
  465. } /* End procedure bif_intlight */
  466.  
  467. /*----------------------------------------------------------------------*\
  468. | Procedure    :    int bif_curve_approx_criteria (BIF_INT, BIF_REAL)
  469. |------------------------------------------------------------------------|
  470. | Description    :    Receive an INTERIOR_LIGHTING entity from the parser
  471. |            pass it on to a generic build, store/execute
  472. |            function.
  473. |------------------------------------------------------------------------|
  474. | Return    :    Error Code
  475. \*----------------------------------------------------------------------*/
  476. bif_curve_approx_criteria ( icriteria, approx_value ) /* ver 1.0 */
  477.     BIF_INT icriteria;
  478.     BIF_REAL approx_value;
  479. {
  480. #ifdef TEST_PRINT
  481.     printf(" bif_curve_approx_criteria: icriteria %ld, approx_value %f\n",
  482.        icriteria, approx_value);
  483. #endif /* ifdef TEST_PRINT */
  484. }
  485.  
  486. /*----------------------------------------------------------------------*\
  487. | Procedure    :    int bif_curve_approx_criteria (BIF_INT,BIF_REAL)
  488. |------------------------------------------------------------------------|
  489. | Description    :    Receive an INTERIOR_LIGHTING entity from the parser
  490. |            pass it on to a generic build, store/execute
  491. |            function.
  492. |------------------------------------------------------------------------|
  493. | Return    :    Error Code
  494. \*----------------------------------------------------------------------*/
  495. bif_surface_approx_criteria ( icriteria, u_approx_value, v_approx_value )
  496.     BIF_INT icriteria;                        /* ver 1.0 */
  497.     BIF_REAL u_approx_value;
  498.     BIF_REAL v_approx_value;
  499. {
  500. #ifdef TEST_PRINT
  501.     printf(" bif_trimcurve_approx_criteria : icriteria %ld, u_approx_value %f\n",
  502.        icriteria, u_approx_value);
  503.     printf(" v_approx_value %f\n", v_approx_value);
  504. #endif /* ifdef TEST_PRINT */
  505. }
  506.  
  507. /*----------------------------------------------------------------------*\
  508. | Procedure    :    int bif_curve_approx_criteria (BIF_INT,BIF_REAL)
  509. |------------------------------------------------------------------------|
  510. | Description    :    Receive an INTERIOR_LIGHTING entity from the parser
  511. |            pass it on to a generic build, store/execute
  512. |            function.
  513. |------------------------------------------------------------------------|
  514. | Return    :    Error Code
  515. \*----------------------------------------------------------------------*/
  516. bif_trimcurve_approx_criteria ( icriteria, approx_value )  /* ver 1.0 */
  517.     BIF_INT icriteria;
  518.     BIF_REAL approx_value;
  519. {
  520. #ifdef TEST_PRINT
  521.     printf(" bif_trimcurve_approx_criteria : icriteria %ld, approx_value %f\n",
  522.        icriteria, approx_value);
  523. #endif /* ifdef TEST_PRINT */
  524. }
  525.  
  526.  
  527.  
  528.  
  529. /* MACRO-GENERATED FUNCTIONS */
  530.     MF_TRUE_COLOR(bif_intcolor,INTERIOR_COLOR,do_interiorcolor,pset_int_colr)
  531.     
  532.     MF_MAP_INDEX(bif_intcolorindex,INTERIOR_COLOR_INDEX,
  533.          do_interiorcolorindex, pset_int_colr)
  534.     
  535.     MF_MAP_INDEX(bif_bkfintcolorindex,BACKFACE_INTERIOR_COLOR_INDEX,
  536.          do_backfaceinteriorcolorindex, pset_back_int_colr)
  537.     
  538.     MF_TRUE_COLOR(bif_bkfintcolor, BACKFACE_INTERIOR_COLOR,
  539.           do_backfaceinteriorcolor, pset_back_int_colr)
  540.     
  541. /*----------------------------------------------------------------------*\
  542. | Procedure    :    int bif_surfprop(BIF_REAL, BIF_REAL, BIF_REAL,
  543. |                    BIF_REAL, BIF_REAL, BIF_REAL,
  544. |                    BIF_REAL, BIF_REAL)
  545. |------------------------------------------------------------------------|
  546. | Description    :    Receive a SURFACE_PROPERTIES entity from the parser
  547. |            pass it on to a generic build, store/execute
  548. |            function.
  549. |
  550. |    ambient, diffuse, specular    Reflectance coefficents
  551. |    c1, c2, c3            Specular color
  552. |    highlight            Specular exponent
  553. |    transparency            Transparency coefficient
  554. |------------------------------------------------------------------------|
  555. | Return    :    Error Code
  556. \*----------------------------------------------------------------------*/
  557. int bif_surfprop(ambient, diffuse, specular, c1, c2, c3,
  558.          highlight, transparency)
  559.     BIF_REAL ambient, diffuse, specular, c1, c2, c3, highlight, transparency;
  560. {
  561.     static int ent_size = sizeof(BIF_Surfaceproperties);
  562.     BIF_All *ent;
  563.     
  564. #ifdef TEST_PRINT
  565.     printf("SURFACE_PROPERTIES :\n");
  566.     printf("ambient, diffuse, specular %f %f %f\n",
  567.        ambient, diffuse, specular);
  568.     printf("c1, c2, c3 %f %f %f\n",c1, c2, c3);
  569.     printf("highlight, transparency %f %f\n",
  570.        highlight, transparency);
  571. #endif /* TEST_PRINT */
  572. #ifndef PRINT_ONLY
  573.     /* Fill the temp_ent then allocate the entity */
  574.     temp_ent.surfaceproperties.props.ambient_coef = ambient;
  575.     temp_ent.surfaceproperties.props.diffuse_coef = diffuse;
  576.     temp_ent.surfaceproperties.props.specular_coef = specular;
  577.     
  578.     temp_ent.surfaceproperties.props.specular_colr.type =
  579.     wk_info.color_model;
  580.     temp_ent.surfaceproperties.props.specular_colr.val.general.x = c1;
  581.     temp_ent.surfaceproperties.props.specular_colr.val.general.y = c2;
  582.     temp_ent.surfaceproperties.props.specular_colr.val.general.z = c3;
  583.     temp_ent.surfaceproperties.props.specular_exp = highlight;
  584.     
  585.     ent = new_generic(&temp_ent,ent_size,SURFACE_PROPERTIES,
  586.               do_surfaceproperties);
  587.     
  588.     /* Error check for ent == NULL ( FATAL ) */
  589.     ENT_ERROR(ent);
  590.     
  591.     /* Build or Execute */
  592.     Traverse(traverser_state, ent);
  593.     
  594. #ifdef TEST_PRINT
  595.     fprintf(stderr,"bifbuild pset_refl_props ambient = %f\n",
  596.         temp_ent.surfaceproperties.props.ambient_coef);
  597.     fprintf(stderr,"bifbuild pset_refl_props diffuse = %f\n",
  598.         temp_ent.surfaceproperties.props.diffuse_coef);
  599.     fprintf(stderr,"bifbuild pset_refl_props specular = %f\n",
  600.         temp_ent.surfaceproperties.props.specular_coef);
  601.     fprintf(stderr,"bifbuild pset_refl_props color model = %d\n",
  602.         temp_ent.surfaceproperties.props.specular_colr.type);
  603.     fprintf(stderr,"bifbuild pset_refl_props specularcolor[0] = %f\n",
  604.         temp_ent.surfaceproperties.props.specular_colr.val.general.x);
  605.     fprintf(stderr,"bifbuild pset_refl_props specularcolor[1] = %f\n",
  606.         temp_ent.surfaceproperties.props.specular_colr.val.general.y);
  607.     fprintf(stderr,"bifbuild pset_refl_props specularcolor[2] = %f\n",
  608.         temp_ent.surfaceproperties.props.specular_colr.val.general.z);
  609.     fprintf(stderr,"bifbuild pset_refl_props highlight = %f\n",
  610.         temp_ent.surfaceproperties.props.specular_exp);
  611. #endif /* TEST_PRINT */
  612.     
  613.     
  614.     
  615.     
  616. #ifdef USING_PHIGS
  617.     /* Call the entity in PHIGS */
  618.     pset_refl_props(&ent->surfaceproperties.props);
  619. #endif /* USING_PHIGS */
  620.     
  621.     /* Release Non-Retained Entities */
  622.     Free_NRE(traverser_state, ent);
  623.     
  624. #endif /* PRINT_ONLY */
  625. } /* End procedure bif_surfprop */
  626.  
  627. /*----------------------------------------------------------------------*\
  628. | Procedure    :    int bif_bkfprop(BIF_REAL, BIF_REAL, BIF_REAL,
  629. |                    BIF_REAL, BIF_REAL, BIF_REAL,
  630. |                    BIF_REAL, BIF_REAL)
  631. |------------------------------------------------------------------------|
  632. | Description    :    Receive a BACKFACE_PROPERTIES entity from the parser
  633. |            pass it on to a generic build, store/execute
  634. |            function.
  635. |
  636. |    ambient, diffuse, specular    Reflectance coefficents
  637. |    c1, c2, c3            Specular color
  638. |    highlight            Specular exponent
  639. |    transparency            Transparency coefficient
  640. |------------------------------------------------------------------------|
  641. | Return    :    Error Code
  642. \*----------------------------------------------------------------------*/
  643. int bif_bkfprop(ambient, diffuse, specular, c1, c2, c3,
  644.         highlight, transparency)
  645.     BIF_REAL ambient, diffuse, specular, c1, c2, c3, highlight, transparency;
  646. {
  647.     static int ent_size = sizeof(BIF_Surfaceproperties);
  648.     BIF_All *ent;
  649.     
  650. #ifdef TEST_PRINT
  651.     printf("BACKFACE_PROPERTIES :\n");
  652.     printf("ambient, diffuse, specular %f %f %f\n",
  653.        ambient, diffuse, specular);
  654.     printf("c1, c2, c3 %f %f %f\n",c1, c2, c3);
  655.     printf("highlight, transparency %f %f %f\n",
  656.        highlight, transparency);
  657. #endif /* TEST_PRINT */
  658. #ifndef PRINT_ONLY
  659.     /* Fill the temp_ent then allocate the entity */
  660.     temp_ent.surfaceproperties.props.ambient_coef = ambient;
  661.     temp_ent.surfaceproperties.props.diffuse_coef = diffuse;
  662.     temp_ent.surfaceproperties.props.specular_coef = specular;
  663.     
  664.     temp_ent.surfaceproperties.props.specular_colr.type = 
  665.     wk_info.color_model;
  666.     temp_ent.surfaceproperties.props.specular_colr.val.general.x = c1;
  667.     temp_ent.surfaceproperties.props.specular_colr.val.general.y = c2;
  668.     temp_ent.surfaceproperties.props.specular_colr.val.general.z = c3;
  669.     temp_ent.surfaceproperties.props.specular_exp = highlight;
  670.     
  671.     ent = new_generic(&temp_ent,ent_size,BACKFACE_PROPERTIES,
  672.               do_backfaceproperties);
  673.     
  674.     /* Error check for ent == NULL ( FATAL ) */
  675.     ENT_ERROR(ent);
  676.     
  677.     /* Build or Execute */
  678.     Traverse(traverser_state, ent);
  679.     
  680. #ifdef USING_PHIGS
  681.     /* Call the entity in PHIGS */
  682.     pset_back_refl_props(&ent->surfaceproperties.props);
  683. #endif /* USING_PHIGS */
  684.     
  685.     /* Release Non-Retained Entities */
  686.     Free_NRE(traverser_state, ent);
  687.     
  688. #endif /* PRINT_ONLY */
  689. } /* End procedure bif_surfprop */
  690.  
  691. /*--------------------------------------------------------------------*\
  692. | Procedure     :    int bif_bkfprocessing(BIF_INT,BIF_INT)
  693. |---------------------------------------------------------------------
  694. | Description    :    Receive a BACK_FACE_PROCESSING entity from
  695. |            the parser pass it on to a generic build,
  696. |            store/execute function.
  697. |---------------------------------------------------------------------
  698. | Return        :    
  699. \*--------------------------------------------------------------------*/
  700. int bif_bkfprocessing(ident,cull)
  701.     BIF_INT ident, cull;
  702.     
  703. {
  704.     static int ent_size = sizeof(BIF_Backfaceprocessing);
  705.     BIF_All *ent;
  706. #ifdef TEST_PRINT
  707.     printf("BACKFACE_PROCESSING :\n");
  708.     printf("identify, cull %d %d\n", ident, cull);
  709. #endif /* TEST_PRINT */
  710. #ifndef PRINT_ONLY
  711.     /* Fill the temp_ent then allocate the entity */
  712.     temp_ent.backfaceprocessing.g_mode = (Pdisting_mode)ident;
  713.     temp_ent.backfaceprocessing.cull_mode = (Pcull_mode)cull;
  714.     
  715.     ent = new_generic(&temp_ent,ent_size,BACKFACE_PROCESSING,
  716.               do_backfaceprocessing);
  717.     
  718.     /* Error check for ent == NULL ( FATAL ) */
  719.     ENT_ERROR(ent);
  720.     
  721.     /* Build or Execute */
  722.     Traverse(traverser_state, ent);
  723.     
  724. #ifdef USING_PHIGS
  725.     /* Call the entity in PHIGS */
  726.     pset_face_disting_mode(ent->backfaceprocessing.g_mode);
  727.     pset_face_cull_mode(ent->backfaceprocessing.cull_mode);
  728. #endif /* USING_PHIGS */
  729.     
  730.     /* Release Non-Retained Entities */
  731.     Free_NRE(traverser_state, ent);
  732.     
  733. #endif /* PRINT_ONLY */
  734. } /* End bif_bkfprocessing() */
  735.  
  736. /*----------------------------------------------------------------------*\
  737. | Procedure    :    int bif_edgeflag(BIF_INT)
  738. |------------------------------------------------------------------------|
  739. | Description    :    Receive an EDGE_FLAG entity from the parser
  740. |            pass it on to a generic build,
  741. |            store/execute function
  742. |
  743. |    ENABLE        Enable edge display
  744. |    DISABLE        Disable edge display
  745. |------------------------------------------------------------------------|
  746. | Return    :    Error Code
  747. \*----------------------------------------------------------------------*/
  748. int bif_edgeflag(edge_flag)
  749.     BIF_INT edge_flag;
  750. {
  751.     int edg_flag;
  752.     /* Build, Store/Execute the entity */
  753.     edg_flag = REMAP_EDGEFLAG(edge_flag);
  754.     bif_index(edg_flag, sizeof(BIF_Index),
  755.           EDGE_FLAG,do_edgeflag,pset_edge_flag);
  756.     
  757. } /* End procedure bif_edgeflag */
  758.  
  759. /*----------------------------------------------------------------------*\
  760. | Procedure    :    int bif_edgetype(BIF_INT)
  761. |------------------------------------------------------------------------|
  762. | Description    :    Receive an EDGE_TYPE entity from the parser
  763. |            Set the line style for edges.  Pass it on to a
  764. |            generic build, store/execute function.
  765. |------------------------------------------------------------------------|
  766. | Return    :    Error Code
  767. \*----------------------------------------------------------------------*/
  768. int bif_edgetype(edge_type)
  769.     BIF_INT edge_type;
  770. {
  771.     /* Build, Store/Execute the entity */
  772.     /* NONSUP: Any value other than solid (BIF value = 0) */
  773.     /* NOTE: + 1 to map BIF edgetypes to PHIGs edgetypes */
  774.     bif_index((int)(edge_type+1), sizeof(BIF_Index),
  775.           EDGE_TYPE,do_edgetype,pset_edgetype);
  776.     
  777. } /* End procedure bif_edgetype */
  778.  
  779. /*----------------------------------------------------------------------*\
  780. | Procedure    :    int bif_edgewidth(BIF_REAL)
  781. |------------------------------------------------------------------------|
  782. | Description    :    Receive an EDGE_WIDTH entity from the parser
  783. |            Pass it on to a generic build, store/execute
  784. |            function.
  785. |------------------------------------------------------------------------|
  786. | Return    :    Error Code
  787. \*----------------------------------------------------------------------*/
  788. int bif_edgewidth(scale_factor)
  789.     BIF_REAL scale_factor;
  790. {
  791.     /* Build, Store/Execute the entity */
  792.     bif_size((float)scale_factor,sizeof(BIF_Size),
  793.          EDGE_WIDTH,do_edgewidth,pset_edgewidth);
  794.     
  795. } /* End procedure bif_edgewidth */
  796.  
  797. /* MACRO-GENERATED FUNCTIONS */
  798.     MF_TRUE_COLOR(bif_edgecolor, EDGE_COLOR, do_edgecolor, pset_edge_colr)
  799.     
  800.     MF_MAP_INDEX(bif_edgecolorindex,EDGE_COLOR_INDEX,
  801.          do_edgecolorindex, pset_edge_colr)
  802.     
  803.     
  804. /* *************** */
  805. /* Text Attributes */
  806. /* *************** */
  807. /*----------------------------------------------------------------------*\
  808. | Procedure    :    int bif_textfont(BIF_INT)
  809. |------------------------------------------------------------------------|
  810. | Description    :    Receive a TEXT_FONT entity from the parser
  811. |            pass it on to a generic build, store/execute
  812. |            function.
  813. |------------------------------------------------------------------------|
  814. | Return    :    Error Code
  815. \*----------------------------------------------------------------------*/
  816.     int bif_textfont(font_id)
  817.     BIF_INT font_id;
  818. {
  819.     int fnt_id;
  820.     /* Build, Store/Execute the entity */
  821.     /* NONSUP: Only one font is supported (BIF font -2) */
  822.     fnt_id = REMAP_TEXTFONT(font_id);
  823.     bif_index(fnt_id, sizeof(BIF_Index),
  824.           TEXT_FONT,do_textfont,pset_text_font);
  825.     
  826. } /* End procedure bif_textfont */
  827.  
  828. /*----------------------------------------------------------------------*\
  829. | Procedure    :    int bif_textprec(BIF_INT)
  830. |------------------------------------------------------------------------|
  831. | Description    :    Receive a TEXT_PREC entity from the parser
  832. |            pass it on to a generic build, store/execute
  833. |            function.
  834. |
  835. |    STRING    "String" Precision    Good
  836. |    CHAR    "Character" Precision    Better
  837. |    STROKE    "Stroke" Precision    Best
  838. |------------------------------------------------------------------------|
  839. | Return    :    Error Code
  840. \*----------------------------------------------------------------------*/
  841. int bif_textprec(precision)
  842.     BIF_INT precision;
  843. {
  844.     /* Build, Store/Execute the entity */
  845.     REMAP_TEXTPREC(precision);
  846.     /* NONSUP: ONLY BIF_STROKE (BIF token STROKE) supported */
  847.     bif_index((int)precision, sizeof(BIF_Index),
  848.           TEXT_PREC,do_textprec,pset_text_prec);
  849.     
  850. } /* End procedure bif_textprec */
  851.  
  852. /* MACRO-GENERATED FUNCTIONS */
  853.     MF_TRUE_COLOR(bif_textcolor, TEXT_COLOR, do_textcolor, pset_text_colr)
  854.     
  855.     MF_MAP_INDEX(bif_textcolorindex,TEXT_COLOR_INDEX,
  856.          do_textcolorindex, pset_text_colr)
  857.     
  858. /*----------------------------------------------------------------------*\
  859. | Procedure    :    int bif_textpath(BIF_INT)
  860. |------------------------------------------------------------------------|
  861. | Description    :    Receive a TEXT_PATH entity from the parser
  862. |            pass it on to a generic build, store/execute
  863. |            function.
  864. |------------------------------------------------------------------------|
  865. | Return    :    Error Code
  866. \*----------------------------------------------------------------------*/
  867. int bif_textpath(path_index)
  868.     BIF_INT path_index;
  869. {
  870.     extern void fxsattxp();
  871.     /* Build, Store/Execute the entity */
  872.     /* NOTE: - 1 from the BIF values match the PHIGs enumerated values */
  873.     bif_index((int)(path_index-1), sizeof(BIF_Index),
  874.           TEXT_PATH,do_textpath,fxsattxp);
  875.     
  876. } /* End procedure bif_textpath */
  877.  
  878. /*----------------------------------------------------------------------*\
  879. | Procedure    :    int bif_textalign(BIF_INT, BIF_INT)
  880. |------------------------------------------------------------------------|
  881. | Description    :    Receive a TEXT_ALIGN entity from the parser
  882. |            store/execute as appropriate.
  883. |
  884. |    horizontal_alignment    Horizontal just. see Table 3.3-10
  885. |    vertical_alignment    Vertical   just. see Table 3.3-11
  886. |------------------------------------------------------------------------|
  887. | Return    :    Error Code
  888. \*----------------------------------------------------------------------*/
  889. int bif_textalign(horizontal_alignment, vertical_alignment)
  890.     BIF_INT horizontal_alignment, vertical_alignment;
  891. {
  892.     static int ent_size = sizeof(BIF_Textalign);
  893.     BIF_All *ent;
  894.     
  895. #ifdef TEST_PRINT
  896.     printf("TEXT_ALIGN: Set to %d %d\n",horizontal_alignment,
  897.        vertical_alignment);
  898. #endif /* TEST_PRINT */
  899. #ifndef PRINT_ONLY
  900.     /* Fill the temp_ent then allocate and copy the entity */
  901.     /* BIF values match the PHIGs enumerated values */
  902.     temp_ent.textalign.text_align.hor = (Phor_text_align)horizontal_alignment;
  903.     temp_ent.textalign.text_align.vert = (Pvert_text_align)vertical_alignment;
  904.     ent = new_generic(&temp_ent,ent_size,TEXT_ALIGN, do_textalign);
  905.     
  906.     /* Error check for ent == NULL ( FATAL ) */
  907.     ENT_ERROR(ent);
  908.     
  909.     /* Build or Execute */
  910.     Traverse(traverser_state, ent);
  911.     
  912. #ifdef USING_PHIGS
  913.     /* Call the entity in PHIGS */
  914.     /* MERGE: BIF merges the text3 and anno text3 attributes here */
  915.     fxsattxal(&ent->textalign.text_align);
  916. #endif /* USING_PHIGS */
  917.     
  918.     /* Release Non-Retained Entities */
  919.     Free_NRE(traverser_state, ent);
  920.     
  921. #endif /* PRINT_ONLY */
  922. } /* End procedure bif_textalign */
  923.  
  924. /*----------------------------------------------------------------------*\
  925. | Procedure    :    int bif_charheight(BIF_REAL)
  926. |------------------------------------------------------------------------|
  927. | Description    :    Receive a CHAR_HEIGHT entity from the parser
  928. |            pass it on to a generic build, store/execute
  929. |            function.
  930. |------------------------------------------------------------------------|
  931. | Return    :    Error Code
  932. \*----------------------------------------------------------------------*/
  933. int bif_charheight(height)
  934.     BIF_REAL height;
  935. {
  936.     /* Build, Store/Execute the entity */
  937.     bif_size((float)height,sizeof(BIF_Size),
  938.          CHAR_HEIGHT,do_charheight,pset_char_ht);
  939.     
  940. } /* End procedure bif_charheight */
  941.  
  942. /*----------------------------------------------------------------------*\
  943. | Procedure    :    int bif_charexp(BIF_REAL)
  944. |------------------------------------------------------------------------|
  945. | Description    :    Receive a CHAR_EXP entity from the parser
  946. |            pass it on to a generic build, store/execute
  947. |            function.
  948. |------------------------------------------------------------------------|
  949. | Return    :    Error Code
  950. \*----------------------------------------------------------------------*/
  951. int bif_charexp(exp)
  952.     BIF_REAL exp;
  953. {
  954.     /* Build, Store/Execute the entity */
  955.     bif_size((float)exp,sizeof(BIF_Size),
  956.          CHAR_EXP,do_charexp,pset_char_expan);
  957.     
  958. } /* End procedure bif_charexp */
  959.  
  960. /*----------------------------------------------------------------------*\
  961. | Procedure    :    int bif_charspace(BIF_REAL)
  962. |------------------------------------------------------------------------|
  963. | Description    :    Receive a CHAR_SPACE entity from the parser
  964. |            pass it on to a generic build, store/execute
  965. |            function.
  966. |------------------------------------------------------------------------|
  967. | Return    :    Error Code
  968. \*----------------------------------------------------------------------*/
  969. int bif_charspace(space)
  970.     BIF_REAL space;
  971. {
  972.     /* Build, Store/Execute the entity */
  973.     bif_size((float)space,sizeof(BIF_Size),
  974.          CHAR_SPACE,do_charspace,pset_char_space);
  975.     
  976. } /* End procedure bif_charspace */
  977.  
  978. /*----------------------------------------------------------------------*\
  979. | Procedure    :    int bif_charupvector(BIF_REAL, BIF_REAL)
  980. |------------------------------------------------------------------------|
  981. | Description    :    Receive a CHAR_UP_VECTOR entity from the parser
  982. |
  983. |    x y    Character up vector components
  984. |------------------------------------------------------------------------|
  985. | Return    :    Error Code
  986. \*----------------------------------------------------------------------*/
  987. int bif_charupvector(x, y)
  988.     BIF_REAL x, y;
  989. {
  990.     static int ent_size = sizeof(BIF_Charupvector);
  991.     BIF_All *ent;
  992.     
  993. #ifdef TEST_PRINT
  994.     printf("CHAR_UP_VECTOR : Set to %f %f\n",x, y);
  995. #endif /* TEST_PRINT */
  996. #ifndef PRINT_ONLY
  997.     /* Allocate the entity */
  998.     temp_ent.charupvector.up_vect.delta_x = x;
  999.     temp_ent.charupvector.up_vect.delta_y = y;
  1000.     ent = new_generic(&temp_ent,ent_size,CHAR_UP_VECTOR,
  1001.               do_charupvector);
  1002.     
  1003.     /* Error check for ent == NULL ( FATAL ) */
  1004.     ENT_ERROR(ent);
  1005.     
  1006.     /* Build or Execute */
  1007.     Traverse(traverser_state, ent);
  1008.     
  1009. #ifdef USING_PHIGS
  1010.     /* Call the entity in PHIGS */
  1011.     pset_char_up_vec(&ent->charupvector.up_vect);
  1012. #endif /* USING_PHIGS */
  1013.     
  1014.     /* Release Non-Retained Entities */
  1015.     Free_NRE(traverser_state, ent);
  1016.     
  1017. #endif /* PRINT_ONLY */
  1018. } /* End procedure bif_charupvector */
  1019.  
  1020. /*----------------------------------------------------------------------*\
  1021. | Procedure    :    int bif_annotextcharheight(BIF_REAL)
  1022. |------------------------------------------------------------------------|
  1023. | Description    :    Receive a ANNO_TEXT_CHAR_HEIGHT entity from the parser
  1024. |            pass it on to a generic build, store/execute
  1025. |            function.
  1026. |------------------------------------------------------------------------|
  1027. | Return    :    Error Code
  1028. \*----------------------------------------------------------------------*/
  1029. int bif_annotextcharheight(height)
  1030.     BIF_REAL height;
  1031. {
  1032.     /* Build, Store/Execute the entity */
  1033.     bif_size((float)height,sizeof(BIF_Size),
  1034.          ANNO_TEXT_CHAR_HEIGHT,
  1035.          do_annotextcharheight,pset_anno_char_ht);
  1036.     
  1037. } /* End procedure bif_annotextcharheight */
  1038.  
  1039. /*----------------------------------------------------------------------*\
  1040. | Procedure    :    int bif_annotextcharupvector(BIF_REAL, BIF_REAL)
  1041. |------------------------------------------------------------------------|
  1042. | Description    :    Receive a ANNO_TEXT_CHAR_UP_VECTOR entity from
  1043. |            the parser.
  1044. |
  1045. |        x y    Character up vector components
  1046. |------------------------------------------------------------------------|
  1047. | Return    :    Error Code
  1048. \*----------------------------------------------------------------------*/
  1049. int bif_annotextcharupvector(x, y)
  1050.     BIF_REAL x, y;
  1051. {
  1052.     static int ent_size = sizeof(BIF_Charupvector);
  1053.     BIF_All *ent;
  1054.     
  1055. #ifdef TEST_PRINT
  1056.     printf("ANNO_TEXT_CHAR_UP_VECTOR : Set to %f %f\n",x, y);
  1057. #endif /* TEST_PRINT */
  1058. #ifndef PRINT_ONLY
  1059.     /* Allocate the entity */
  1060.     temp_ent.charupvector.up_vect.delta_x = x;
  1061.     temp_ent.charupvector.up_vect.delta_y = y;
  1062.     ent = new_generic(&temp_ent,ent_size,ANNO_TEXT_CHAR_UP_VECTOR,
  1063.               do_annotextcharupvector);
  1064.     
  1065.     /* Error check for ent == NULL ( FATAL ) */
  1066.     ENT_ERROR(ent);
  1067.     
  1068.     /* Build or Execute */
  1069.     Traverse(traverser_state, ent);
  1070.     
  1071. #ifdef USING_PHIGS
  1072.     /* Call the entity in PHIGS */
  1073.     pset_anno_char_up_vec(&ent->charupvector.up_vect);
  1074. #endif /* USING_PHIGS */
  1075.     
  1076.     /* Release Non-Retained Entities */
  1077.     Free_NRE(traverser_state, ent);
  1078.     
  1079. #endif /* PRINT_ONLY */
  1080. } /* End procedure bif_annotextcharupvector */
  1081.  
  1082. /*----------------------------------------------------------------------*\
  1083. | Procedure    :    int bif_annotextstyle(BIF_INT)
  1084. |------------------------------------------------------------------------|
  1085. | Description    :    Receive a ANNO_TEXT_STYLE entity from the parser
  1086. |            pass it on to a generic build, store/execute
  1087. |            function.
  1088. |------------------------------------------------------------------------|
  1089. | Return    :    Error Code
  1090. \*----------------------------------------------------------------------*/
  1091. int bif_annotextstyle(style)
  1092.     BIF_INT style;
  1093. {
  1094.     /* Build, Store/Execute the entity */
  1095.     /* BIF anno types match the values for the GX4000 */
  1096.     bif_index((int)style, sizeof(BIF_Index),
  1097.           ANNO_TEXT_STYLE,do_annotextstyle,pset_anno_style);
  1098.     
  1099. } /* End procedure bif_annotextstyle */
  1100.  
  1101. /* ******************** */
  1102. /* Rendering Attributes */
  1103. /* ******************** */
  1104.  
  1105. /* ****************************** */
  1106. /* Lights and lighting Attributes */
  1107. /* ****************************** */
  1108.  
  1109. /*----------------------------------------------------------------------*\
  1110. | Procedure    :    int bif_definelight(BIF_INT)
  1111. |------------------------------------------------------------------------|
  1112. | Description    :    Begin / End receiving a DEFINE_LIGHT entity from
  1113. |            the parser
  1114. |    BIF_P_BEGIN     begin entity
  1115. |    BIF_P_END    end entity
  1116. |------------------------------------------------------------------------|
  1117. | Return    :    Error Code
  1118. \*----------------------------------------------------------------------*/
  1119. int bif_definelight(begin_or_end)
  1120.     BIF_INT begin_or_end;
  1121. {
  1122.     static int ent_size = sizeof(BIF_Definelight);
  1123.     BIF_All *ent;
  1124.     int ierr;
  1125. #ifdef TEST_PRINT
  1126.     BEGEND(definelight);
  1127.     fflush(stdout);
  1128. #endif /* TEST_PRINT */
  1129. #ifndef PRINT_ONLY
  1130.     switch ( begin_or_end )
  1131.     {
  1132.       case BIF_P_BEGIN :
  1133.       /* Initialize entity */
  1134.       temp_ent.definelight.ld_trans_id = -1; /* No transform */
  1135.       /* default light type is ambient */
  1136.       temp_ent.definelight.light_type = BIF_AMBIENT;
  1137.       break;
  1138.       
  1139.     case BIF_P_END :
  1140.         /* Check / Limit / Warn / Index Range Exception */
  1141.         ierr = indexRange(DEFINE_LIGHT,
  1142.                   (BIF_INT)temp_ent.definelight.light_number,
  1143.                   1, BIF_MAX_LIGHTS);
  1144.       
  1145.         if ( ierr ) /* Substitute default value for error condition */
  1146.         temp_ent.definelight.light_number = 1;
  1147.  
  1148.         /* Allocate the entity */
  1149.         ent = new_generic(&temp_ent, ent_size,
  1150.                   DEFINE_LIGHT, do_definelight);
  1151.  
  1152.         /* Error check for ent == NULL ( FATAL ) */
  1153.         ENT_ERROR(ent);
  1154.           
  1155.         /* Build or Execute */
  1156.         Traverse(traverser_state, ent);
  1157.           
  1158. #ifdef USING_PHIGS
  1159.         /* Called by the BIF execute traverser */
  1160.         /* No PHIGS call here */
  1161. #endif /* USING_PHIGS */
  1162.           
  1163.         /* Release Non-Retained Entities */
  1164.         Free_NRE(traverser_state, ent);
  1165.       }
  1166.     
  1167.     
  1168. #endif /* PRINT_ONLY */
  1169. } /* End procedure bif_definelight */
  1170.  
  1171. /*----------------------------------------------------------------------*\
  1172. | Procedure    :    int bif_lightbasic(BIF_INT,
  1173. |                    BIF_REAL, BIF_REAL, BIF_REAL)
  1174. |------------------------------------------------------------------------|
  1175. | Description    :    Receive basic data for DEFINE_LIGHT entity from
  1176. |            the parser.
  1177. |    light_number    Light table entry to define
  1178. |    c1, c2, c3    Light color
  1179. |------------------------------------------------------------------------|
  1180. | Return    :    Error Code
  1181. \*----------------------------------------------------------------------*/
  1182. int bif_lightbasic(light_number, c1, c2, c3)
  1183.     BIF_INT light_number;
  1184.     BIF_REAL c1, c2, c3;
  1185. {
  1186.     
  1187. #ifdef TEST_PRINT
  1188.     printf("Lightbasic: for %d color %f %f %f \n",light_number, c1, c2, c3);
  1189. #endif /* TEST_PRINT */
  1190. #ifndef PRINT_ONLY
  1191.     temp_ent.definelight.light_number   = (int)light_number;
  1192.     temp_ent.definelight.color_model    = wk_info.color_model;
  1193.     temp_ent.definelight.light_color[0] = (float)c1;
  1194.     temp_ent.definelight.light_color[1] = (float)c2;
  1195.     temp_ent.definelight.light_color[2] = (float)c3;
  1196. #endif /* PRINT_ONLY */
  1197.     
  1198. } /* End bif_lightbasic */
  1199.  
  1200. /*----------------------------------------------------------------------*\
  1201. | Procedure    :    int bif_ldtranform(BIF_INT)
  1202. |------------------------------------------------------------------------|
  1203. | Description    :    Receive the matrix id of the Light Definition
  1204. |            transformation.
  1205. |
  1206. |    mat_id        Matrix table entry to define the defining coord.
  1207. |            space for the current light;
  1208. |------------------------------------------------------------------------|
  1209. | Return    :    Error Code
  1210. \*----------------------------------------------------------------------*/
  1211. int bif_ldtransform(mat_id)
  1212.     BIF_INT mat_id;
  1213. {
  1214.     
  1215. #ifdef TEST_PRINT
  1216.     printf("Ldtransform: Matrix id %d\n",mat_id);
  1217. #endif /* TEST_PRINT */
  1218.     
  1219. #ifndef PRINT_ONLY
  1220.     ERROR_MATRIX_ID(mat_id,DEFINE_LIGHT);
  1221.     temp_ent.definelight.ld_trans_id = mat_id;
  1222. #endif /* PRINT_ONLY */
  1223.     
  1224. } /* End new_ldtransform */
  1225.  
  1226. /*----------------------------------------------------------------------*\
  1227. | Procedure    :    int bif_lightoption(BIF_INT,
  1228. |                    BIF_REAL, BIF_REAL, BIF_REAL,
  1229. |                    BIF_REAL, BIF_REAL, BIF_REAL,
  1230. |                    BIF_REAL, BIF_REAL,
  1231. |                    BIF_REAL, BIF_REAL)
  1232. |------------------------------------------------------------------------|
  1233. | Description    :    Receive data for DEFINE_LIGHT entity from the
  1234. |            parser that defines non-ambient lights
  1235. |
  1236. |    light_type    Type of light defined
  1237. |    x, y, z        Light position
  1238. |    u, v, w        Light direction
  1239. |    e        Concentration exponent            
  1240. |    s        Spread angle
  1241. |    a, b        Attenuation coefficients
  1242. |------------------------------------------------------------------------|
  1243. | Return    :    Error Code
  1244. \*----------------------------------------------------------------------*/
  1245. int bif_lightoption(light_type, x , y , z , u , v , w , e , s , a , b)
  1246.     BIF_INT light_type;
  1247.     BIF_REAL x, y, z;
  1248.     BIF_REAL u, v, w;
  1249.     BIF_REAL e;
  1250.     BIF_REAL s;
  1251.     BIF_REAL a, b;
  1252. {
  1253. #ifdef TEST_PRINT
  1254.     printf("Lightoption : Light type %d\n",(int)light_type);
  1255.     printf("Position  %f %f %f \n",x, y, z);
  1256.     printf("Direction %f %f %f \n",u, v, w);
  1257.     printf("Expon Spread %f %f \n",e, s);
  1258.     printf("Attenuation  %f %f \n",a, b);
  1259. #endif /* TEST_PRINT */
  1260. #ifndef PRINT_ONLY
  1261.     /* NONSUP: Attenuation Factors (BIF tokens POSITIONAL, SPOT) */
  1262.     temp_ent.definelight.light_type   = REMAP_LIGHTTYPE(light_type);
  1263.     temp_ent.definelight.direction[0] = u;
  1264.     temp_ent.definelight.direction[1] = v;
  1265.     temp_ent.definelight.direction[2] = w;
  1266.     temp_ent.definelight.position[0]  = x;
  1267.     temp_ent.definelight.position[1]  = y;
  1268.     temp_ent.definelight.position[2]  = z;
  1269.     temp_ent.definelight.attenuation[0] = a;
  1270.     temp_ent.definelight.attenuation[1] = b;
  1271.     temp_ent.definelight.exponent = e;
  1272.     temp_ent.definelight.spread = s;
  1273.     
  1274. #endif /* PRINT_ONLY */
  1275. } /* End procedure bif_lightoption */
  1276.  
  1277.  
  1278. /*----------------------------------------------------------------------*\
  1279. | Procedure    :    int bif_lightstate(BIF_INT)
  1280. |------------------------------------------------------------------------|
  1281. | Description    :    Begin / End receiving a LIGHT_STATE entity from
  1282. |            the parser.
  1283. |
  1284. |    BIF_P_BEGIN     begin entity
  1285. |            Initialize group handler for data groups ACTIVATE_LIST
  1286. |            and DEACTIVATE_LIST
  1287. |
  1288. |    BIF_P_END    end entity
  1289. |            Store accumulated lists in entity structure.
  1290. |------------------------------------------------------------------------|
  1291. | Return    :    Error Code
  1292. \*----------------------------------------------------------------------*/
  1293. int bif_lightstate(begin_or_end)
  1294.     BIF_INT begin_or_end;
  1295. {
  1296.     BIF_Lightstate *ent;
  1297.     Group_description *group_list;
  1298.     int num_groups;
  1299.     
  1300. #ifdef TEST_PRINT
  1301.     BEGEND(lightstate );
  1302. #endif /* TEST_PRINT */
  1303. #ifndef PRINT_ONLY
  1304.     switch (begin_or_end) {
  1305.       case BIF_P_BEGIN:
  1306.     /* Start of a lightstate */
  1307.     init_groups();
  1308.     break;
  1309.     
  1310.       case BIF_P_END:
  1311.     num_groups = end_groups(&group_list);
  1312.     ent = new_lightstate(num_groups, group_list);
  1313.     ENT_ERROR(ent);
  1314.     
  1315.     /* Store or execute */        
  1316.     Traverse(traverser_state, ent);
  1317.     
  1318.     /* Send to PHIGs */
  1319. #ifdef USING_PHIGS
  1320. #ifdef TEST_PRINT
  1321.     {
  1322.         int i;
  1323.         for ( i = 0 ;  i < ent->activation.num_ints ; i++ )
  1324.         printf("Switching on  Light # %d\n", ent->activation.ints[i]);
  1325.         for ( i = 0 ;  i < ent->deactivation.num_ints ; i++ )
  1326.         printf("Switching off Light # %d\n", ent->deactivation.ints[i]);
  1327.     }
  1328. #endif /* TEST_PRINT */
  1329.     pset_light_src_state(&ent->activation,&ent->deactivation);
  1330. #endif /* USING_PHIGS */
  1331.     Free_NRE(traverser_state, ent);
  1332.     }
  1333. #endif /* PRINT_ONLY */
  1334. } /* End procedure bif_lightstate */
  1335.  
  1336. /* ********************** */
  1337. /* Depth Cueing           */
  1338. /* ********************** */
  1339. /*--------------------------------------------------------------------*\
  1340. | Procedure     :    int bif_definedepthcue(BIF_INT, BIF_INT,
  1341. |                BIF_REAL, BIF_REAL,
  1342. |                BIF_REAL, BIF_REAL,
  1343. |                BIF_REAL, BIF_REAL, BIF_REAL)
  1344. |---------------------------------------------------------------------
  1345. | Description   :    Receive the results of a DEFINE_DEPTHCUE
  1346. |            from the parser.
  1347. |---------------------------------------------------------------------
  1348. | Return        :    Error Code (Not Implemented)
  1349. \*--------------------------------------------------------------------*/
  1350. int bif_definedepthcue(entry_id, flag, near, far, nScale, fScale, 
  1351.                c1, c2,c3)
  1352.     
  1353.     BIF_INT entry_id;
  1354.     BIF_INT flag;
  1355.     BIF_REAL near, far;
  1356.     BIF_REAL nScale, fScale;
  1357.     BIF_REAL c1, c2,c3;
  1358.     
  1359. {
  1360.     static int ent_size = sizeof(BIF_DefineDepthCue);
  1361.     BIF_All *ent;
  1362.     BIF_DefineDepthCue *dent;
  1363.     int ierr;
  1364. #ifdef TEST_PRINT
  1365.     char *key_w, *find_keyword_token(); 
  1366.     
  1367.     key_w = find_keyword_token(flag);
  1368.     printf("DEFINE_DEPTHCUE: Entry %d (%s)\n", entry_id, key_w);
  1369. #endif /* TEST_PRINT */
  1370. #ifndef PRINT_ONLY
  1371.     dent = &temp_ent.definedepthcue;
  1372.     dent->ind               = (int)entry_id;
  1373.     dent->rep.mode          = (Pdcue_mode)REMAP_DCMODE(flag);
  1374.     dent->rep.ref_planes[0] = (Pfloat)far;     /* back plane in npc  */
  1375.     dent->rep.ref_planes[1] = (Pfloat)near;    /* front plane in npc */
  1376.     dent->rep.scaling[0]   = (Pfloat)fScale;  /* back scale factor  */
  1377.     dent->rep.scaling[1]   = (Pfloat)nScale;  /* front scale factor */
  1378.     dent->rep.colr.type   = wk_info.color_model;
  1379.     dent->rep.colr.val.general.x = c1;
  1380.     dent->rep.colr.val.general.y = c2;
  1381.     dent->rep.colr.val.general.z = c3;
  1382.     
  1383.     /* Check / Limit / Warn / Index Range Exception */
  1384.     ierr = indexRange(DEFINE_DEPTHCUE, (BIF_INT)dent->ind,
  1385.               1, BIF_MAX_DCRS);
  1386.     
  1387.     if ( ierr ) /* Substitute default value */
  1388.     dent->ind = 0;
  1389.  
  1390.     /* Allocate the entity */
  1391.     ent = new_generic(&temp_ent, ent_size,
  1392.               DEFINE_DEPTHCUE, do_definedepthcue);
  1393.     
  1394.     /* Error check for ent == NULL ( FATAL ) */
  1395.     ENT_ERROR(ent);
  1396.  
  1397.     /* Build or Execute */
  1398.     Traverse(traverser_state, ent);
  1399.     
  1400. #ifdef USING_PHIGS
  1401.     /* Called by the BIF execute traverser */
  1402.     /* No PHIGS call here */
  1403. #endif /* USING_PHIGS */
  1404.     
  1405.     /* Release Non-Retained Entities */
  1406.     Free_NRE(traverser_state, ent);
  1407. #endif /* PRINT_ONLY */
  1408. } /* End of procedure bif_definedepthcue */
  1409.  
  1410. /*----------------------------------------------------------------------*\
  1411. | Procedure    :    int bif_depthcueindex(BIF_INT)
  1412. |------------------------------------------------------------------------|
  1413. | Description    :    Receive a DEPTHCUE_INDEX entity from the parser
  1414. |
  1415. |    dc_index    the index of the depthcue entry
  1416. |            to make the current entry.
  1417. |------------------------------------------------------------------------|
  1418. | Return    :    Error Code
  1419. \*----------------------------------------------------------------------*/
  1420. int bif_depthcueindex(dc_index)
  1421.     BIF_INT dc_index;
  1422. {
  1423.     int ierr;
  1424.     /* Check / Limit / Warn / Index Range Exception */
  1425.     ierr = indexRange(DEFINE_DEPTHCUE, dc_index,
  1426.               1, BIF_MAX_DCRS);
  1427.     
  1428.     if ( ierr ) /* Substitute default value */
  1429.     dc_index = 0;
  1430.  
  1431.     /* Build, Store/Execute the entity */
  1432.     bif_index((int)dc_index, sizeof(BIF_Index),
  1433.           DEPTHCUE_INDEX, do_depthcueindex, pset_dcue_ind);
  1434.     
  1435. } /* End procedure bif_depthcueindex */
  1436.  
  1437. /* ********************** */
  1438. /* Hidden Surface Removal */
  1439. /* ********************** */
  1440. /*----------------------------------------------------------------------*\
  1441.   | Procedure    :    int bif_hlhsremoval(BIF_INT)
  1442.   |------------------------------------------------------------------------|
  1443.   | Description    :    Receive a HLHS_REMOVAL entity from the parser
  1444.   |            pass it on to a generic build, store/execute
  1445.   |            function.
  1446.   |
  1447.   |    hlhs_flag    HL/HS switch; see Table 3.4-1
  1448.   |            BIF_DISABLE        Disable HL/HS removal
  1449.   |            BIF_ENABLE        Enable HL/HS removal
  1450.   |------------------------------------------------------------------------|
  1451.   | Return    :    Error Code
  1452.   \*----------------------------------------------------------------------*/
  1453. int bif_hlhsremoval(hlhs_flag)
  1454.     BIF_INT hlhs_flag;
  1455. {
  1456.     int hl_flag;
  1457.     /* Build, Store/Execute the entity */
  1458.     hl_flag = REMAP_HLHS(hlhs_flag);
  1459.     bif_index(hl_flag, sizeof(BIF_Index),
  1460.           HLHS_REMOVAL, do_hlhsremoval, pset_hlhsr_id);
  1461.     
  1462. } /* End procedure bif_hlhsremoval */
  1463.  
  1464. /* ********************** */
  1465. /* Color Model Attributes */
  1466. /* ********************** */
  1467.  
  1468. /*----------------------------------------------------------------------*\
  1469. | Procedure    :    int bif_definecolor(BIF_INT,
  1470. |                    BIF_REAL, BIF_REAL, BIF_REAL)
  1471. |------------------------------------------------------------------------|
  1472. | Description    :    Receive a DEFINE_COLOR entity from the parser
  1473. |
  1474. |    map_index    Color map table entry to define
  1475. |    c1, c2, c3    True-color components for entry
  1476. |------------------------------------------------------------------------|
  1477. | Return    :    Error Code
  1478. \*----------------------------------------------------------------------*/
  1479. int bif_definecolor(map_index, c1, c2, c3)
  1480.     BIF_INT map_index;
  1481.     BIF_REAL c1, c2, c3;
  1482. {
  1483.     static int ent_size = sizeof(BIF_Definecolor);
  1484.     BIF_All *ent;
  1485.     int ierr;
  1486.     
  1487. #ifdef TEST_PRINT
  1488.     printf("DEFINE_COLOR: Color %d set to %f %f %f\n",
  1489.        map_index, c1, c2, c3);
  1490. #endif /* TEST_PRINT */
  1491. #ifndef PRINT_ONLY
  1492.     /* Allocate the entity */
  1493.     /* indexRange reporting for definecolor */
  1494.     ierr = indexRange(DEFINE_COLOR, map_index,
  1495.               0, (BIF_INT)wk_info.cmap_size);
  1496.     if ( ierr ) /* Substitute default value */
  1497.     map_index = 1;
  1498.  
  1499.     temp_ent.definecolor.ind = map_index;
  1500.     temp_ent.definecolor.color_model = wk_info.color_model;
  1501.     temp_ent.definecolor.rep.rgb.red      = c1;
  1502.     temp_ent.definecolor.rep.rgb.green      = c2;
  1503.     temp_ent.definecolor.rep.rgb.blue      = c3;
  1504.     ent = new_generic(&temp_ent,ent_size,
  1505.               DEFINE_COLOR,do_definecolor);
  1506.     
  1507.     /* Error check for ent == NULL ( FATAL ) */
  1508.     ENT_ERROR(ent);
  1509.     
  1510.     /* Build or Execute */
  1511.     Traverse(traverser_state, ent);
  1512.     
  1513. #ifdef USING_PHIGS
  1514.     /*----------------------------------------------------*\
  1515.     | If we are redefining the entry that defines
  1516.     | the background we must ALSO redfine the
  1517.     | background.
  1518.     \*----------------------------------------------------*/
  1519.     if ( map_index == background_color_index )
  1520.     bif_backgroundcolorindex(map_index);
  1521.     
  1522.     /* Cannot be contained within PHIGS structures */
  1523.     /* Called by the BIF execute traverser */
  1524.     /* No PHIGS call here */
  1525. #endif /* USING_PHIGS */
  1526.     
  1527.     /* Release Non-Retained Entities */
  1528.     Free_NRE(traverser_state, ent);
  1529.     
  1530. #endif /* PRINT_ONLY */
  1531. } /* End procedure bif_definecolor */
  1532.  
  1533. /*--------------------------------------------------------------------*\
  1534. | Procedure     :    bif_backgroundcolor(BIF_REAL,BIF_REAL,BIF_REAL)
  1535. |---------------------------------------------------------------------
  1536. | Description   :    Define the background true color components
  1537. |---------------------------------------------------------------------
  1538. | Return        :    
  1539. \*--------------------------------------------------------------------*/
  1540. bif_backgroundcolor(c1, c2, c3)
  1541.     BIF_REAL c1, c2, c3;
  1542.     
  1543. {/* bif_backgroundcolor */
  1544.     float comp1, comp2, comp3;
  1545.     comp1 = (float)c1;
  1546.     comp2 = (float)c2;
  1547.     comp3 = (float)c3;
  1548.     
  1549.     /*------------------------------------------------------------*\
  1550.     | Disconnect background from the color map
  1551.     \*------------------------------------------------------------*/
  1552.     background_color_index = -1;
  1553. #ifdef USING_PHIGS
  1554.     /*------------------------------------------------------------*\
  1555.     | We set the background color by redefining map entry 0
  1556.     \*------------------------------------------------------------*/
  1557.     {
  1558.     Pcolr_rep rep;
  1559.     
  1560.     if (user_background) {
  1561.         PLB_EXCEPTION(BIF_EX_BACKCOLOR);
  1562.     }
  1563.     else {
  1564.         rep.rgb.red = comp1;
  1565.         rep.rgb.green = comp2;
  1566.         rep.rgb.blue = comp3;
  1567.         pset_colr_rep((Pint)bench_setup.workid, 0, &rep);
  1568.     }
  1569.     }
  1570. #endif /* USING_PHIGS */
  1571. }/* bif_backgroundcolor */
  1572.  
  1573.  
  1574. /*--------------------------------------------------------------------*\
  1575. | Procedure     :    bif_backgroundcolorindex(BIF_INT)
  1576. |---------------------------------------------------------------------
  1577. | Description   :    Define the background color index
  1578. |---------------------------------------------------------------------
  1579. | Return        :    
  1580. \*--------------------------------------------------------------------*/
  1581. bif_backgroundcolorindex(lindex)
  1582.     BIF_INT lindex;
  1583.     
  1584. {/* bif_backgroundcolorindex */
  1585.     int indx;
  1586.     int type;
  1587.     int errind;
  1588.     float comp1, comp2, comp3;
  1589.     indx = (int)lindex;
  1590.     
  1591.     if ( indexRange(BACKGROUND_COLOR_INDEX, indx,
  1592.             0, wk_info.cmap_size ) ) /* Substitute default value */
  1593.     indx = 1;
  1594.  
  1595.     background_color_index = indx;
  1596. #ifdef USING_PHIGS
  1597.     {
  1598.     Pcolr_rep rep;
  1599.     Pint errind;
  1600.         
  1601.     if (user_background) {
  1602.         PLB_EXCEPTION(BIF_EX_BACKCOLOR);
  1603.     }
  1604.     else {
  1605.         /*----------------------------------------------------*\
  1606.         | Offset the map index "as usual" with PHIGS/BIF
  1607.         \*----------------------------------------------------*/
  1608.         indx++;
  1609.         /*----------------------------------------------------*\
  1610.         |    Get the color we are "into"
  1611.         \*----------------------------------------------------*/
  1612.         
  1613.         pinq_colr_rep((Pint)bench_setup.workid, (Pint)indx,
  1614.               PINQ_SET, &errind, &rep);
  1615.         
  1616.         /*----------------------------------------------------*\
  1617.         |    We set the background color using map entry 0
  1618.         \*----------------------------------------------------*/
  1619.         
  1620.         pset_colr_rep((Pint)bench_setup.workid, (Pint)0, &rep);
  1621.     }
  1622.     }
  1623. #endif /* USING_PHIGS */
  1624. }/* bif_backgroundcolorindex */
  1625.  
  1626.  
  1627. /* ****************************************
  1628.  * Coordinate Transformation Entities
  1629.  * ************************************** */
  1630.  
  1631. /*----------------------------------------------------------------------*\
  1632. | Procedure    :    int bif_identity3(BIF_INT)
  1633. |------------------------------------------------------------------------|
  1634. | Description    :    Receive an IDENTITY3 entity from the parser
  1635. |            Implemented as a MATRIX3 / REPLACE
  1636. |
  1637. |    matrix_id    ID of matrix table entry
  1638. |------------------------------------------------------------------------|
  1639. | Return    :    Error Code
  1640. \*----------------------------------------------------------------------*/
  1641. int bif_identity3(matrix_id)
  1642.     BIF_INT matrix_id;
  1643. {
  1644.     static int ent_size = sizeof(BIF_Matrix3);
  1645.     BIF_All *ent;
  1646.     
  1647. #ifdef TEST_PRINT
  1648.     printf("IDENTITY3 : Set matrix %d to the identity matrix\n",matrix_id);
  1649. #endif /* TEST_PRINT */
  1650. #ifndef PRINT_ONLY
  1651.     /* Check the matrix_id */
  1652.     ERROR_MATRIX_ID(matrix_id,IDENTITY3);
  1653.     
  1654.     /* Allocate the entity */
  1655.     temp_ent.matrix3.matrix_id = matrix_id;
  1656.     temp_ent.matrix3.concat_type = BIF_REPLACE;
  1657.     copy44f(ident_matrix,temp_ent.matrix3.matrix);
  1658.     ent = new_generic(&temp_ent,ent_size,MATRIX3,do_matrix3);
  1659.     
  1660.     /* Error check for ent == NULL ( FATAL ) */
  1661.     ENT_ERROR(ent);
  1662.     
  1663.     /* Build or Execute */
  1664.     Traverse(traverser_state, ent);
  1665.     
  1666. #ifdef USING_PHIGS
  1667.     /* Cannot be contained within PHIGS structures */
  1668.     /* Called by the BIF execute traverser */
  1669.     /* No PHIGS call here */
  1670. #endif /* USING_PHIGS */
  1671.     
  1672.     /* Release Non-Retained Entities */
  1673.     Free_NRE(traverser_state, ent);
  1674.     
  1675. #endif /* PRINT_ONLY */
  1676. } /* End procedure bif_identity3 */
  1677.  
  1678. /*----------------------------------------------------------------------*\
  1679. | Procedure    :    int bif_concatmatrix3(BIF_INT, BIF_INT, BIF_INT)
  1680. |------------------------------------------------------------------------|
  1681. | Description    :    Receive a CONCAT_MATRIX3 entity from the parser
  1682. |
  1683. |    matrix_from    ID of "from" matrix table entry
  1684. |    matrix_to    ID of "to" matrix table entry
  1685. |    concat        PRECONCAT | POSTCONCAT | REPLACE
  1686. |------------------------------------------------------------------------|
  1687. | Return    :    Error Code
  1688. \*----------------------------------------------------------------------*/
  1689. int bif_concatmatrix3(matrix_from, matrix_to, concat)
  1690.     BIF_INT matrix_from, matrix_to, concat;
  1691. {
  1692.     static int ent_size = sizeof(BIF_Concatmatrix3);
  1693.     BIF_All *ent;
  1694. #ifdef TEST_PRINT
  1695.     printf("CONCAT_MATRIX3 : Concat %d and %d. Operation %d\n",
  1696.        matrix_from, matrix_to, concat);
  1697.     fflush(stdout);
  1698. #endif /* TEST_PRINT */
  1699. #ifndef PRINT_ONLY
  1700.     /* Check the matrix_id's */
  1701.     ERROR_MATRIX_ID(matrix_from,CONCAT_MATRIX3);
  1702.     ERROR_MATRIX_ID(matrix_to,CONCAT_MATRIX3);
  1703.     
  1704.     /* Allocate the entity */
  1705.     temp_ent.concatmatrix3.matrix_id_from = matrix_from;
  1706.     temp_ent.concatmatrix3.matrix_id_to   = matrix_to;
  1707.     temp_ent.concatmatrix3.concat_type    = REMAP_CONCAT(concat);
  1708.     ent = new_generic(&temp_ent,ent_size,CONCAT_MATRIX3,
  1709.               do_concatmatrix3);
  1710.     
  1711.     /* Error check for ent == NULL ( FATAL ) */
  1712.     ENT_ERROR(ent);
  1713.     
  1714.     /* Build or Execute */
  1715.     Traverse(traverser_state, ent);
  1716.     
  1717. #ifdef USING_PHIGS
  1718.     /* Cannot be contained within PHIGS structures */
  1719.     /* Called by the BIF execute traverser */
  1720.     /* No PHIGS call here */
  1721. #endif /* USING_PHIGS */
  1722.     
  1723.     /* Release Non-Retained Entities */
  1724.     Free_NRE(traverser_state, ent);
  1725.     
  1726. #endif /* PRINT_ONLY */
  1727. } /* End procedure bif_concatmatrix3 */
  1728.  
  1729. /*----------------------------------------------------------------------*\
  1730. | Procedure    :    int bif_invertmatrix3(BIF_INT)
  1731. |------------------------------------------------------------------------|
  1732. | Description    :    Receive an INVERT_MATRIX3 entity from the parser
  1733. |
  1734. |    matrix_id    ID of matrix table entry to invert
  1735. |------------------------------------------------------------------------|
  1736. | Return    :    Error Code
  1737. \*----------------------------------------------------------------------*/
  1738. int bif_invertmatrix3(matrix_id)
  1739.     BIF_INT matrix_id;
  1740. {
  1741.     static int ent_size = sizeof(BIF_Invertmatrix3);
  1742.     BIF_All *ent;
  1743. #ifdef TEST_PRINT
  1744.     printf("INVERT_MATRIX3 : Invert matrix %d\n",matrix_id);
  1745. #endif /* TEST_PRINT */
  1746. #ifndef PRINT_ONLY
  1747.     /* Check the matrix_id */
  1748.     ERROR_MATRIX_ID(matrix_id,INVERT_MATRIX3);
  1749.     
  1750.     /* Allocate the entity */
  1751.     temp_ent.invertmatrix3.matrix_id = matrix_id;
  1752.     ent = new_generic(&temp_ent,ent_size,INVERT_MATRIX3,
  1753.               do_invertmatrix3);
  1754.     
  1755.     /* Error check for ent == NULL ( FATAL ) */
  1756.     ENT_ERROR(ent);
  1757.     
  1758.     /* Build or Execute */
  1759.     Traverse(traverser_state, ent);
  1760.     
  1761. #ifdef USING_PHIGS
  1762.     /* Cannot be contained within PHIGS structures */
  1763.     /* Called by the BIF execute traverser */
  1764.     /* No PHIGS call here */
  1765. #endif /* USING_PHIGS */
  1766.     
  1767.     /* Release Non-Retained Entities */
  1768.     Free_NRE(traverser_state, ent);
  1769.     
  1770. #endif /* PRINT_ONLY */
  1771. } /* End procedure bif_invertmatrix3 */
  1772.  
  1773. /*----------------------------------------------------------------------*\
  1774. | Procedure    :    int bif_rotate3( BIF_INT, BIF_REAL,
  1775. |                        BIF_INT, BIF_INT )
  1776. |------------------------------------------------------------------------|
  1777. | Description    :    Receive a ROTATE3 entity from the parser
  1778. |            Implemented as a MATRIX3 / concat
  1779. |
  1780. |    matrix_id    ID of matrix table entry to alter
  1781. |    angle        Angle of rotation
  1782. |    axis        X_AXIS | Y_AXIS | Z_AXIS
  1783. |    concat        PRECONCAT | POSTCONCAT | REPLACE
  1784. |
  1785. |------------------------------------------------------------------------|
  1786. | Return    :    Error Code
  1787. \*----------------------------------------------------------------------*/
  1788. int bif_rotate3( matrix_id, angle, axis, concat )
  1789.     BIF_INT matrix_id;
  1790.     BIF_REAL angle;
  1791.     BIF_INT axis, concat;
  1792. {
  1793.     static int ent_size = sizeof(BIF_Matrix3);
  1794.     BIF_All *ent;
  1795.     matrix4 amx;
  1796. #ifdef TEST_PRINT
  1797.     printf("ROTATE3 : id %d by %f on %d. Op=%d\n",
  1798.        matrix_id, angle, axis, concat);
  1799. #endif /* TEST_PRINT */
  1800. #ifndef PRINT_ONLY
  1801.     /* Check the matrix_id */
  1802.     ERROR_MATRIX_ID(matrix_id,ROTATE3);
  1803.     
  1804.     /* Fill the temp entity */
  1805.     switch( axis )
  1806.     {
  1807.       case X_AXIS :
  1808.       mx_rot_x( (float)angle, amx );
  1809.       break;
  1810.     case Y_AXIS :
  1811.         mx_rot_y( (float)angle, amx );
  1812.       break;
  1813.     case Z_AXIS :
  1814.         mx_rot_z( (float)angle, amx );
  1815.       break;
  1816.       }
  1817.     temp_ent.matrix3.matrix_id   = matrix_id;
  1818.     temp_ent.matrix3.concat_type = REMAP_CONCAT(concat);
  1819.     copy44f( amx, temp_ent.matrix3.matrix );
  1820.     ent = new_generic( &temp_ent, ent_size, MATRIX3, do_matrix3 );
  1821.     
  1822.     /* Error check for ent == NULL ( FATAL ) */
  1823.     ENT_ERROR(ent);
  1824.     
  1825.     /* Build or Execute */
  1826.     Traverse(traverser_state, ent);
  1827.     
  1828. #ifdef USING_PHIGS
  1829.     /* Cannot be contained within PHIGS structures */
  1830.     /* Called by the BIF execute traverser */
  1831.     /* No PHIGS call here */
  1832. #endif /* USING_PHIGS */
  1833.     
  1834.     /* Release Non-Retained Entities */
  1835.     Free_NRE(traverser_state, ent);
  1836.     
  1837. #endif /* PRINT_ONLY */
  1838. } /* End procedure bif_rotate3 */
  1839.  
  1840. /*----------------------------------------------------------------------*\
  1841. | Procedure    :    BIF_INT bif_rotatexyz3(BIF_INT,BIF_REAL,BIF_REAL,
  1842. |                        BIF_REAL,BIF_INT)
  1843. |------------------------------------------------------------------------|
  1844. | Description    :    Receive a ROTATE_XYZ3 entity from the parser
  1845. |        Implemented as a MATRIX3 / concat
  1846. |
  1847. |    matrix_id    ID of matrix table entry to alter
  1848. |    angle_x, angle_y, angle_z
  1849. |            Angles of rotations
  1850. |    concat        PRECONCAT | POSTCONCAT | REPLACE
  1851. |------------------------------------------------------------------------|
  1852. | Return    :    Error Code
  1853. \*----------------------------------------------------------------------*/
  1854. int bif_rotatexyz3(matrix_id, angle_x, angle_y, angle_z, concat)
  1855.     BIF_INT matrix_id;
  1856.     BIF_REAL angle_x,angle_y,angle_z;
  1857.     BIF_INT concat;
  1858. {
  1859.     static int ent_size = sizeof(BIF_Matrix3);
  1860.     BIF_All *ent;
  1861.     matrix4 amx;
  1862. #ifdef TEST_PRINT
  1863.     printf("ROTATEXYZ3 : id %d by %f %f %f. Op=%d\n",
  1864.        matrix_id, angle_x, angle_y, angle_z, concat);
  1865. #endif /* TEST_PRINT */
  1866. #ifndef PRINT_ONLY
  1867.     /* Check the matrix_id */
  1868.     ERROR_MATRIX_ID(matrix_id,ROTATE_XYZ3);
  1869.     
  1870.     /* Fill the temp entity */
  1871.     mx_euler_matrix( (float)angle_x, (float)angle_y,
  1872.             (float)angle_z, amx );
  1873.     temp_ent.matrix3.matrix_id   = matrix_id;
  1874.     temp_ent.matrix3.concat_type = REMAP_CONCAT(concat);
  1875.     copy44f( amx, temp_ent.matrix3.matrix );
  1876.     ent = new_generic( &temp_ent, ent_size, MATRIX3, do_matrix3 );
  1877.     
  1878.     /* Error check for ent == NULL ( FATAL ) */
  1879.     ENT_ERROR(ent);
  1880.     
  1881.     /* Build or Execute */
  1882.     Traverse(traverser_state, ent);
  1883.     
  1884. #ifdef USING_PHIGS
  1885.     /* Cannot be contained within PHIGS structures */
  1886.     /* Called by the BIF execute traverser */
  1887.     /* No PHIGS call here */
  1888. #endif /* USING_PHIGS */
  1889.     
  1890.     /* Release Non-Retained Entities */
  1891.     Free_NRE(traverser_state, ent);
  1892.     
  1893. #endif /* PRINT_ONLY */
  1894. } /* End procedure bif_rotatexyz3 */
  1895.  
  1896. /*----------------------------------------------------------------------*\
  1897. | Procedure    :    int bif_translate3(BIF_INT ,
  1898. |                    BIF_REAL, BIF_REAL, BIF_REAL,
  1899. |                    BIF_INT)
  1900. |------------------------------------------------------------------------|
  1901. | Description    :    Receive a TRANSLATE3 entity from the parser
  1902. |        Implemented as a MATRIX3 / concat
  1903. |
  1904. |    matrix_id    ID of matrix table entry to alter
  1905. |    tx, ty, tz    Translation vector 
  1906. |    concat        PRECONCAT | POSTCONCAT | REPLACE
  1907. |------------------------------------------------------------------------|
  1908. | Return    :    Error Code
  1909. \*----------------------------------------------------------------------*/
  1910. int bif_translate3(matrix_id, tx, ty, tz, concat)
  1911.     BIF_INT matrix_id;
  1912.     BIF_REAL tx, ty, tz;
  1913.     BIF_INT concat;
  1914. {
  1915.     static int ent_size = sizeof(BIF_Matrix3);
  1916.     BIF_All *ent;
  1917.     float amx[4][4];
  1918. #ifdef TEST_PRINT
  1919.     printf("TRANSLATE3 : id %d by %f %f %f. Op=%d\n",
  1920.        matrix_id, tx, ty, tz, concat);
  1921. #endif /* TEST_PRINT */
  1922. #ifndef PRINT_ONLY
  1923.     /* Check the matrix_id */
  1924.     ERROR_MATRIX_ID(matrix_id,TRANSLATE3);
  1925.     
  1926.     /* Fill the temp entity */
  1927.     mx_translate( (float)tx, (float)ty, (float)tz, amx );
  1928.     temp_ent.matrix3.matrix_id   = matrix_id;
  1929.     temp_ent.matrix3.concat_type = REMAP_CONCAT(concat);
  1930.     copy44f( amx, temp_ent.matrix3.matrix );
  1931.     ent = new_generic( &temp_ent, ent_size, MATRIX3, do_matrix3 );
  1932.     
  1933.     /* Error check for ent == NULL ( FATAL ) */
  1934.     ENT_ERROR(ent);
  1935.     
  1936.     /* Build or Execute */
  1937.     Traverse(traverser_state, ent);
  1938.     
  1939. #ifdef USING_PHIGS
  1940.     /* Cannot be contained within PHIGS structures */
  1941.     /* Called by the BIF execute traverser */
  1942.     /* No PHIGS call here */
  1943. #endif /* USING_PHIGS */
  1944.     
  1945.     /* Release Non-Retained Entities */
  1946.     Free_NRE(traverser_state, ent);
  1947.     
  1948. #endif /* PRINT_ONLY */
  1949. } /* End procedure bif_globaltransformation3 */
  1950.  
  1951.  
  1952. /*----------------------------------------------------------------------*\
  1953. | Procedure    :    int bif_scale3(BIF_INT , BIF_REAL, BIF_REAL,
  1954. |                    BIF_REAL, BIF_INT)
  1955. |------------------------------------------------------------------------|
  1956. | Description    :    Receive a SCALE3 entity from the parser
  1957. |            Implemented as a MATRIX3 / concat
  1958. |
  1959. |    matrix_id    ID of matrix table entry to alter
  1960. |    sx, sy, sz    Scaling vector 
  1961. |    concat        PRECONCAT | POSTCONCAT | REPLACE
  1962. |------------------------------------------------------------------------|
  1963. | Return    :    Error Code
  1964. \*----------------------------------------------------------------------*/
  1965. int bif_scale3(matrix_id, sx, sy, sz, concat)
  1966.     BIF_INT matrix_id;
  1967.     BIF_REAL sx, sy, sz;
  1968.     BIF_INT concat;
  1969. {
  1970.     static int ent_size = sizeof(BIF_Matrix3);
  1971.     BIF_All *ent;
  1972.     float amx[4][4];
  1973. #ifdef TEST_PRINT
  1974.     printf("SCALE3 : id %d by %f %f %f. Op=%d\n",
  1975.        matrix_id, sx, sy, sz, concat);
  1976. #endif /* TEST_PRINT */
  1977. #ifndef PRINT_ONLY
  1978.     /* Check the matrix_id */
  1979.     ERROR_MATRIX_ID(matrix_id,SCALE3);
  1980.     
  1981.     /* Fill the temp entity */
  1982.     mx_scale( (float)sx, (float)sy, (float)sz, amx );
  1983.     temp_ent.matrix3.matrix_id   = matrix_id;
  1984.     temp_ent.matrix3.concat_type = REMAP_CONCAT(concat);
  1985.     copy44f( amx, temp_ent.matrix3.matrix );
  1986.     ent = new_generic( &temp_ent, ent_size, MATRIX3, do_matrix3 );
  1987.     
  1988.     /* Error check for ent == NULL ( FATAL ) */
  1989.     ENT_ERROR(ent);
  1990.     
  1991.     /* Build or Execute */
  1992.     Traverse(traverser_state, ent);
  1993.     
  1994. #ifdef USING_PHIGS
  1995.     /* Cannot be contained within PHIGS structures */
  1996.     /* Called by the BIF execute traverser */
  1997.     /* No PHIGS call here */
  1998. #endif /* USING_PHIGS */
  1999.     
  2000.     /* Release Non-Retained Entities */
  2001.     Free_NRE(traverser_state, ent);
  2002.     
  2003. #endif /* PRINT_ONLY */
  2004. } /* End procedure bif_scale3 */
  2005.  
  2006. /*----------------------------------------------------------------------*\
  2007. | Procedure    :    int bif_matrix3(BIF_INT, *BIF_REAL, BIF_INT)
  2008. |------------------------------------------------------------------------|
  2009. | Description    :    Receive a MATRIX3 entity from the parser
  2010. |
  2011. |    matrix_id    ID of matrix table entry to alter
  2012. |    amatrix        Matrix to use 
  2013. |    concat        PRECONCAT | POSTCONCAT | REPLACE
  2014. |------------------------------------------------------------------------|
  2015. | Return    :    Error Code
  2016. \*----------------------------------------------------------------------*/
  2017. int bif_matrix3(matrix_id, amatrix, concat)
  2018.     BIF_INT matrix_id;
  2019.     BIF_REAL  amatrix[4][4];
  2020.     BIF_INT concat;
  2021. {
  2022.     static int ent_size = sizeof(BIF_Matrix3);
  2023.     BIF_All *ent;
  2024. #ifdef TEST_PRINT
  2025.     printf("MATRIX3 : id %d  Op=%d Matrix:\n", matrix_id, concat);
  2026.     PRINT_MATRIX44(amatrix);
  2027. #endif /* TEST_PRINT */
  2028. #ifndef PRINT_ONLY
  2029.     /* Check the matrix_id */
  2030.     ERROR_MATRIX_ID(matrix_id,MATRIX3);
  2031.     
  2032.     /* Fill the temp entity */
  2033.     temp_ent.matrix3.matrix_id   = matrix_id;
  2034.     temp_ent.matrix3.concat_type = REMAP_CONCAT(concat);
  2035.     Transpose44( amatrix, temp_ent.matrix3.matrix );
  2036.     ent = new_generic(&temp_ent, ent_size, MATRIX3, do_matrix3);
  2037.     
  2038.     /* Error check for ent == NULL ( FATAL ) */
  2039.     ENT_ERROR(ent);
  2040.     
  2041.     /* Build or Execute */
  2042.     Traverse(traverser_state, ent);
  2043.     
  2044. #ifdef USING_PHIGS
  2045.     /* Cannot be contained within PHIGS structures */
  2046.     /* Called by the BIF execute traverser */
  2047.     /* No PHIGS call here */
  2048. #endif /* USING_PHIGS */
  2049.     
  2050.     /* Release Non-Retained Entities */
  2051.     Free_NRE(traverser_state, ent);
  2052.     
  2053. #endif /* PRINT_ONLY */
  2054. } /* End procedure bif_matrix3 */
  2055.  
  2056. /*----------------------------------------------------------------------*\
  2057. | Procedure    :    int bif_getmatrix3(BIF_INT, BIF_INT, BIF_INT)
  2058. |------------------------------------------------------------------------|
  2059. | Description    :    Receive a GET_MATRIX3 entity from the parser
  2060. |
  2061. |    matrix_id    ID of matrix table entry to alter
  2062. |    get_this    System Matrix to use 
  2063. |    concat        PRECONCAT | POSTCONCAT | REPLACE
  2064. |------------------------------------------------------------------------|
  2065. | Return    :    Error Code
  2066. \*----------------------------------------------------------------------*/
  2067. int bif_getmatrix3(matrix_id, get_this, concat)
  2068.     BIF_INT matrix_id;
  2069.     BIF_INT get_this;
  2070.     BIF_INT concat;
  2071. {
  2072.     static int ent_size = sizeof(BIF_Getmatrix3);
  2073.     BIF_All *ent;
  2074.     char *from_mat, *mat_op;
  2075.     char *find_keyword_token();
  2076.     from_mat = find_keyword_token(get_this);
  2077.     mat_op   = find_keyword_token(concat);
  2078. #ifdef TEST_PRINT
  2079.     printf("GET_MATRIX3 : Matrix id %d from %s Op= %s \n",
  2080.        matrix_id, from_mat, mat_op);
  2081. #endif /* TEST_PRINT */
  2082. #ifndef PRINT_ONLY
  2083.     /* Check the matrix_id */
  2084.     ERROR_MATRIX_ID(matrix_id,GET_MATRIX3);
  2085.     
  2086.     /* Fill the temp_ent then allocate and copy the entity */
  2087.     temp_ent.getmatrix3.matrix_id   = matrix_id;
  2088.     temp_ent.getmatrix3.get_matrix  = REMAP_GETMAT(get_this);
  2089.     temp_ent.getmatrix3.concat_type = REMAP_CONCAT(concat);
  2090.     ent = new_generic(&temp_ent, ent_size, GET_MATRIX3,
  2091.               do_getmatrix3);
  2092.     
  2093.     /* Error check for ent == NULL ( FATAL ) */
  2094.     ENT_ERROR(ent);
  2095.     
  2096.     /* Build or Execute */
  2097.     Traverse(traverser_state, ent);
  2098.     
  2099. #ifdef USING_PHIGS
  2100.     /* Cannot be contained within PHIGS structures */
  2101.     /* Called by the BIF execute traverser */
  2102.     /* No PHIGS call here */
  2103. #endif /* USING_PHIGS */
  2104.     
  2105.     /* Release Non-Retained Entities */
  2106.     Free_NRE(traverser_state, ent);
  2107.     
  2108. #endif /* PRINT_ONLY */
  2109. } /* End procedure bif_getmatrix3 */
  2110.  
  2111.  
  2112. /*--------------------------------------------------------------------*\
  2113. | Procedure     :    int bif_pushmatrix3()
  2114. |---------------------------------------------------------------------
  2115. | Description   :    Receive a PUSH_MATRIX3 entity from the parser
  2116. |            Build, then store or execute the appropriate
  2117. |            entity.  The bif_entity only manipulates the 
  2118. |            matrix stack ( on matrix entry 0 )
  2119. |---------------------------------------------------------------------
  2120. | Return        :    Error Code (Not Implemented)
  2121. \*--------------------------------------------------------------------*/
  2122. int bif_pushmatrix3()
  2123.     
  2124. {
  2125.     static int ent_size = sizeof(BIF_No_data);
  2126.     BIF_All *ent;
  2127.     
  2128. #ifdef TEST_PRINT
  2129.     printf("PUSH_MATRIX3:\n");
  2130. #endif /* TEST_PRINT */
  2131. #ifndef PRINT_ONLY
  2132.     /* Allocate and fill the entity */
  2133.     ent = new_generic(&temp_ent, ent_size, PUSH_MATRIX3,
  2134.               do_pushmatrix3);
  2135.     
  2136.     /* Error check for ent == NULL ( FATAL ) */
  2137.     ENT_ERROR(ent);
  2138.     
  2139.     /* Build or Execute */
  2140.     Traverse(traverser_state, ent);
  2141.     
  2142. #ifdef USING_PHIGS
  2143.     /* Cannot be contained within PHIGS structures */
  2144.     /* Called by the BIF execute traverser */
  2145.     /* No PHIGS call here */
  2146. #endif /* USING_PHIGS */
  2147.     
  2148.     /* Release Non-Retained Entities */
  2149.     Free_NRE(traverser_state, ent);
  2150.     
  2151. #endif /* PRINT_ONLY */
  2152. } /* End bif_pushmatrix3() */
  2153.  
  2154. /*--------------------------------------------------------------------*\
  2155. | Procedure     :    int bif_popmatrix3()
  2156. |---------------------------------------------------------------------
  2157. | Description   :    Receive a POP_MATRIX3 entity from the parser
  2158. |            Build, then store or execute the appropriate
  2159. |            entity.  The bif_entity only manipulates the 
  2160. |            matrix stack ( on matrix entry 0 )
  2161. |---------------------------------------------------------------------
  2162. | Return        :    Error Code (Not Implemented)
  2163. \*--------------------------------------------------------------------*/
  2164. int bif_popmatrix3()
  2165.     
  2166. {
  2167.     static int ent_size = sizeof(BIF_No_data);
  2168.     BIF_All *ent;
  2169.     
  2170. #ifdef TEST_PRINT
  2171.     printf("POP_MATRIX3:\n");
  2172. #endif /* TEST_PRINT */
  2173. #ifndef PRINT_ONLY
  2174.     /* Allocate and fill the entity */
  2175.     ent = new_generic(&temp_ent, ent_size, POP_MATRIX3,
  2176.               do_popmatrix3);
  2177.     
  2178.     /* Error check for ent == NULL ( FATAL ) */
  2179.     ENT_ERROR(ent);
  2180.     
  2181.     /* Build or Execute */
  2182.     Traverse(traverser_state, ent);
  2183.     
  2184. #ifdef USING_PHIGS
  2185.     /* Cannot be contained within PHIGS structures */
  2186.     /* Called by the BIF execute traverser */
  2187.     /* No PHIGS call here */
  2188. #endif /* USING_PHIGS */
  2189.     
  2190.     /* Release Non-Retained Entities */
  2191.     Free_NRE(traverser_state, ent);
  2192.     
  2193. #endif /* PRINT_ONLY */
  2194. } /* End bif_popmatrix3() */
  2195.  
  2196.  
  2197. /*----------------------------------------------------------------------*\
  2198. | Procedure    :    int bif_gtransform3(*BIF_REAL)
  2199. |------------------------------------------------------------------------|
  2200. | Description    :    Receive a GLOBAL_TRANSFORMATION3 entity from the
  2201. |            parser amatrix    Matrix to use 
  2202. |------------------------------------------------------------------------|
  2203. | Return    :    Error Code
  2204. \*----------------------------------------------------------------------*/
  2205. int bif_gtransform3(amatrix)
  2206.     BIF_REAL  amatrix[4][4];
  2207. {
  2208. #ifdef USING_PHIGS
  2209.     Pmatrix3 tmp_xform;
  2210. #endif
  2211.     static int ent_size = sizeof(BIF_Globaltransformation3);
  2212.     BIF_All *ent;
  2213. #ifdef TEST_PRINT
  2214.     printf("GLOBAL_TRANSFORMATION3 : Matrix:\n");
  2215.     PRINT_MATRIX44(amatrix);
  2216. #endif /* TEST_PRINT */
  2217. #ifndef PRINT_ONLY
  2218.     /* Fill the temp entity */
  2219.     Transpose44( amatrix, temp_ent.globaltransformation3.xform);
  2220.     ent = new_generic(&temp_ent, ent_size, GLOBAL_TRANSFORMATION3,
  2221.               do_globaltransformation3);
  2222.     
  2223.     /* Error check for ent == NULL ( FATAL ) */
  2224.     ENT_ERROR(ent);
  2225.     
  2226.     /* Build or Execute */
  2227.     Traverse(traverser_state, ent);
  2228.     
  2229. #ifdef USING_PHIGS
  2230.     Cpmatrix44(amatrix, tmp_xform); /* Convert from BIF_REAL to Pmatrix3 */
  2231.     pset_global_tran3(tmp_xform);
  2232. #endif /* USING_PHIGS */
  2233.     
  2234.     /* Release Non-Retained Entities */
  2235.     Free_NRE(traverser_state, ent);
  2236.     
  2237. #endif /* PRINT_ONLY */
  2238. } /* End procedure bif_gtransform3 */
  2239.  
  2240. /*----------------------------------------------------------------------*\
  2241. | Procedure    :    int bif_ltransform3(*BIF_REAL, BIF_INT)
  2242. |------------------------------------------------------------------------|
  2243. | Description    :    Receive a LOCAL_TRANSFORMATION3 entity from the
  2244. |            parser amatrix    Matrix to use 
  2245. |
  2246. |    concat        PRECONCAT | POSTCONCAT | REPLACE
  2247. |------------------------------------------------------------------------|
  2248. | Return    :    Error Code
  2249. \*----------------------------------------------------------------------*/
  2250. int bif_ltransform3(amatrix, concat)
  2251.     BIF_REAL  amatrix[4][4];
  2252.     BIF_INT concat;
  2253. {
  2254. #ifdef USING_PHIGS
  2255.     Pmatrix3 tmp_xform;
  2256. #endif
  2257.     static int ent_size = sizeof(BIF_Localtransformation3);
  2258.     BIF_All *ent;
  2259. #ifdef TEST_PRINT
  2260.     printf("LOCAL_TRANSFORMATION3 : Op=%d Matrix:\n", concat);
  2261.     PRINT_MATRIX44(amatrix);
  2262. #endif /* TEST_PRINT */
  2263. #ifndef PRINT_ONLY
  2264.     /* Fill the temp entity */
  2265.     Transpose44( amatrix, temp_ent.localtransformation3.xform );
  2266.     temp_ent.localtransformation3.compose_type =
  2267.     (Pcompose_type)REMAP_CONCAT(concat);
  2268.     ent = new_generic(&temp_ent, ent_size, 
  2269.               LOCAL_TRANSFORMATION3, do_localtransformation3);
  2270.     
  2271.     /* Error check for ent == NULL ( FATAL ) */
  2272.     ENT_ERROR(ent);
  2273.     
  2274.     /* Build or Execute */
  2275.     Traverse(traverser_state, ent);
  2276.     
  2277. #ifdef USING_PHIGS
  2278.     Cpmatrix44(amatrix, tmp_xform); /* Convert from BIF_REAL to Pmatrix3 */
  2279.     pset_local_tran3(tmp_xform, ent->localtransformation3.compose_type );
  2280. #endif /* USING_PHIGS */
  2281.     
  2282.     /* Release Non-Retained Entities */
  2283.     Free_NRE(traverser_state, ent);
  2284.     
  2285. #endif /* PRINT_ONLY */
  2286. } /* End procedure bif_ltransform3 */
  2287.  
  2288. /*----------------------------------------------------------------------*\
  2289. | Procedure    :    int bif_applytoglobal3(BIF_INT)
  2290. |------------------------------------------------------------------------|
  2291. | Description    :    Receive an APPLY_TO_GLOBAL3 entity from the parser
  2292. |
  2293. |    matrix_id    ID of matrix table entry to apply to global
  2294. |------------------------------------------------------------------------|
  2295. | Return    :    Error Code
  2296. \*----------------------------------------------------------------------*/
  2297. int bif_applytoglobal3(matrix_id)
  2298.     BIF_INT matrix_id;
  2299. {
  2300.     static int ent_size = sizeof(BIF_Applytoglobal3);
  2301.     BIF_All *ent;
  2302.     BIF_Applytoglobal3 *app;
  2303.     BIF_Beginstructure *str_ptr;
  2304. #ifdef TEST_PRINT
  2305.     printf("APPLY_TO_GLOBAL3 : id %d  \n", matrix_id);
  2306. #endif /* TEST_PRINT */
  2307. #ifndef PRINT_ONLY
  2308.     /* Check the matrix_id */
  2309.     ERROR_MATRIX_ID(matrix_id,APPLY_TO_GLOBAL3);
  2310.     
  2311.     /* Fill the temp entity */
  2312.     app = &temp_ent.applytoglobal3;
  2313.     app->matrix_id    = matrix_id;
  2314.     if ( (str_ptr = traverser_state->open_structure) != NULL )
  2315.     app->structure_id = str_ptr->structure_id;
  2316.     else
  2317.     app->structure_id = bench_setup.nrs_stid;
  2318.     app->matrix_label = getNextLabel();
  2319.     
  2320.     /* Allocate the entity */
  2321.     ent = new_generic(&temp_ent, ent_size,
  2322.               APPLY_TO_GLOBAL3,do_applytoglobal3);
  2323. #ifdef TEST_PRINT
  2324.     printf("push_level %d  \n", traverser_state->push_level);
  2325. #endif /* TEST_PRINT */
  2326.     
  2327.     /* Error check for ent == NULL ( FATAL ) */
  2328.     ENT_ERROR(ent);
  2329.     
  2330. #ifdef USING_PHIGS
  2331.     /* Insert Label must be before the BIF traversal */
  2332.     plabel(app->matrix_label);
  2333.     {
  2334.     Pmatrix3 mx;
  2335.     mx_identity(mx);
  2336.     pset_global_tran3(mx);
  2337.     }
  2338. #endif /* USING_PHIGS */
  2339.     /* Store or Execute */
  2340.     Traverse(traverser_state, ent);
  2341.     
  2342. #endif /* PRINT_ONLY */
  2343. } /* End procedure bif_applytoglobal3 */
  2344.  
  2345. /*----------------------------------------------------------------------*\
  2346. | Procedure    :    int bif_applytolocal3(BIF_INT, BIF_INT)
  2347. |------------------------------------------------------------------------|
  2348. | Description    :    Receive an APPLY_TO_LOCAL3 entity from the parser
  2349. |
  2350. |    matrix_id    ID of matrix table entry to apply to local
  2351. |    concat    PRECONCAT | POSTCONCAT | REPLACE
  2352. |------------------------------------------------------------------------|
  2353. | Return    :    Error Code
  2354. \*----------------------------------------------------------------------*/
  2355. int bif_applytolocal3(matrix_id, concat)
  2356.     BIF_INT matrix_id;
  2357.     BIF_INT concat;
  2358. {
  2359.     static int ent_size = sizeof(BIF_Applytolocal3);
  2360.     BIF_All *ent;
  2361.     BIF_Applytolocal3 *app;
  2362.     BIF_Beginstructure *str_ptr;
  2363. #ifdef TEST_PRINT
  2364.     printf("APPLY_TO_LOCAL3 : id %d  Op=%d\n", matrix_id, concat);
  2365. #endif /* TEST_PRINT */
  2366. #ifndef PRINT_ONLY
  2367.     /* Check the matrix_id */
  2368.     ERROR_MATRIX_ID(matrix_id,APPLY_TO_LOCAL3);
  2369.     
  2370.     /* Fill the temp entity */
  2371.     app = &temp_ent.applytolocal3;
  2372.     app->matrix_id    = matrix_id;
  2373.     app->concat_type  = REMAP_CONCAT(concat);
  2374.     if ( (str_ptr = traverser_state->open_structure) != NULL )
  2375.     app->structure_id = str_ptr->structure_id;
  2376.     else
  2377.     app->structure_id = bench_setup.nrs_stid;
  2378.     app->matrix_label = getNextLabel();
  2379.     
  2380.     /* Allocate the entity */
  2381.     ent = new_generic(&temp_ent, ent_size,
  2382.               APPLY_TO_LOCAL3,do_applytolocal3);
  2383.     
  2384.     /* Error check for ent == NULL ( FATAL ) */
  2385.     ENT_ERROR(ent);
  2386.     
  2387. #ifdef USING_PHIGS
  2388.     /* Insert Label must be before the BIF traversal */
  2389.     plabel(app->matrix_label);
  2390.     {
  2391.     Pmatrix3 mx;
  2392.     Pcompose_type contype;
  2393.     mx_identity(mx);
  2394.     contype = (Pcompose_type)BIF_PRECONCAT;
  2395.     pset_local_tran3(mx,contype);
  2396.     }
  2397. #endif /* USING_PHIGS */
  2398.     /* Store or Execute */
  2399.     Traverse(traverser_state, ent);
  2400.     
  2401. #endif /* PRINT_ONLY */
  2402. } /* End procedure bif_applytolocal3 */
  2403.  
  2404. /*--------------------------------------------------------------------*\
  2405. |    * ***************************************** *
  2406. |        BIF Verb File
  2407. |    * ***************************************** *
  2408. \*--------------------------------------------------------------------*/
  2409.  
  2410. /*--------------------------------------------------------------------*\
  2411. |    * ***************************************** *
  2412. |        Input / Output
  2413. |    * ***************************************** *
  2414. \*--------------------------------------------------------------------*/
  2415.  
  2416.  
  2417. /*--------------------------------------------------------------------*\
  2418. |    Read Geom is a function of the parser
  2419. \*--------------------------------------------------------------------*/
  2420.  
  2421. /*----------------------------------------------------------------------*\
  2422. | Procedure    :    int bif_cleargeom()
  2423. |------------------------------------------------------------------------|
  2424. | Description    :    Receive a CLEAR_GEOMETRY entity from the parser.
  2425. |            Delete all structures from memory.
  2426. |------------------------------------------------------------------------|
  2427. | Return    :    Error Code
  2428. \*----------------------------------------------------------------------*/
  2429. int bif_cleargeom()
  2430. {
  2431. #ifdef TEST_PRINT
  2432.     printf("CLEAR_GEOMETRY :\n");
  2433. #endif /* TEST_PRINT */
  2434. #ifndef PRINT_ONLY
  2435.     db_clear_all();
  2436.     
  2437. #ifdef USING_PHIGS
  2438.     /* Nothing Here.... db_clear_all also does PEMST as well as free the 
  2439.        BIF structures         */
  2440. #endif /* USING_PHIGS */
  2441.     
  2442. #endif /* PRINT_ONLY */
  2443. } /* End procedure bif_cleargeom */
  2444.  
  2445. /*----------------------------------------------------------------------*\
  2446. | Procedure    :    int bif_reportfile(*char)
  2447. |------------------------------------------------------------------------|
  2448. | Description    :    Receive a REPORT_FILE entity from the parser.
  2449. |            Specifies new report file.
  2450. |------------------------------------------------------------------------|
  2451. | Return    :    Error Code
  2452. \*----------------------------------------------------------------------*/
  2453. int bif_reportfile(file_name)
  2454.     char *file_name;
  2455. {
  2456. #ifdef TEST_PRINT
  2457.     printf("REPORT_FILE : %s\n",file_name);
  2458. #endif /* TEST_PRINT */
  2459. #ifndef PRINT_ONLY
  2460.     
  2461.     
  2462.     close_reportfile();
  2463.     open_reportfile(file_name);
  2464.     
  2465.     
  2466. #endif /* PRINT_ONLY */
  2467. } /* End procedure bif_reportfile */
  2468.  
  2469. /*--------------------------------------------------------------------*\
  2470. |    * ***************************************** *
  2471. |        Test Control
  2472. |    * ***************************************** *
  2473. \*--------------------------------------------------------------------*/
  2474.  
  2475. /*----------------------------------------------------------------------*\
  2476. | Procedure    :    int bif_begintest(BIF_INT)
  2477. |------------------------------------------------------------------------|
  2478. | Description    :    Receive a BEGIN_TEST entity from the parser
  2479. |
  2480. |    n_repetitions    Number of frames
  2481. |------------------------------------------------------------------------|
  2482. | Return    :    Error Code
  2483. \*----------------------------------------------------------------------*/
  2484. int bif_begintest(n_repetitions)
  2485.     BIF_INT n_repetitions;
  2486. {
  2487.     int structure_id;
  2488.     BIF_Beginstructure *ent;
  2489. #ifdef TEST_PRINT
  2490.     printf("BEGIN_TEST : repeats %d \n",n_repetitions);
  2491. #endif /* TEST_PRINT */
  2492. #ifndef PRINT_ONLY
  2493.     /* Get the pointer to the structure ( allocated if new ) */
  2494.     structure_id = bench_setup.test_stid;
  2495.     ent = db_get_str((BIF_INT)structure_id);
  2496.     
  2497.     /*  Check if we ran out of memory */
  2498.     ENT_ERROR(ent);
  2499.     
  2500.     /* Store the Current test state */
  2501.     current_test.n_repetitions = n_repetitions;
  2502.     current_test.structure_id   = structure_id;
  2503.     current_test.structure_ptr  = ent;
  2504.     current_test.structure_ptr->expanded = 0;
  2505.     
  2506.     /* Clear the Structure of its last contents */
  2507.     free_all_list(ent->top_of_list);
  2508.     ent->top_of_list = NULL;
  2509.     
  2510.     /* Open the Structure in the BIF Database / set the traverser */
  2511.     /* to the build mode */
  2512.     do_beginstructure(traverser_state, ent);
  2513.     
  2514.     /* ************************************************************* */
  2515.     /* Non-Phigs: Insert Border BIF Structure                        */
  2516.     /*      Traverse(traverser_state, border_structure.top_of_list ) */
  2517.     /* ************************************************************* */
  2518.     
  2519. #ifdef USING_PHIGS
  2520.     /* Close the Non-Retained Structure */
  2521.     fxclns();
  2522.     traverser_state->nrs_state = 0;
  2523.     
  2524.     /* ************************************************************ */
  2525.     /* Do the PHIGS calls that initialize the test_structure        */
  2526.     /* ************************************************************ */
  2527.     /* Empty the Test Structure */
  2528.     pempty_struct((Pint)structure_id);
  2529.     
  2530.     /* Open the Test Structure */
  2531.     popen_struct((Pint)structure_id);
  2532.     /* Insert the "Basestate" the Test Structure */
  2533.     pcopy_all_elems_struct((Pint)bench_setup.base_state_stid);
  2534. #endif /* USING_PHIGS */
  2535. #endif /* PRINT_ONLY */
  2536. } /* End procedure bif_begintest */
  2537.  
  2538. /*----------------------------------------------------------------------*\
  2539. | Procedure: int bif_endtest()
  2540. |------------------------------------------------------------------------|
  2541. | Description: Receive an END_TEST entity from the parser
  2542. |------------------------------------------------------------------------|
  2543. | Return: Error Code
  2544. \*----------------------------------------------------------------------*/
  2545. int bif_endtest()
  2546. {
  2547.     BIF_All *bif_list;
  2548.     int indx;
  2549.     slList tol; /* Top of list for CALL expansion */
  2550. #ifdef TEST_PRINT
  2551.     printf("END_TEST :\n");
  2552.     fflush(stdout);
  2553. #endif /* TEST_PRINT */
  2554. #ifndef PRINT_ONLY
  2555.     /* End the insertion of entities into the BIF test structure */
  2556.     /* Put the traverser into EXECUTE mode */
  2557.     do_endstructure(traverser_state,NULL);
  2558.     
  2559. #ifdef USING_PHIGS
  2560.     /* Close and the test structure */
  2561.     pclose_struct();
  2562.     
  2563. #ifdef TEST_PRINT
  2564.     printf("ppost(%d, %d, 1.0)\n",bench_setup.workid,current_test.structure_id);
  2565.     fflush(stdout);
  2566. #endif /* TEST_PRINT */
  2567.     
  2568. #ifdef EXTERNALNOTE
  2569.     /* it was discovered that the border around the test window
  2570.        was adding a substantial overhead on earlier versions
  2571.        of PLB. Because this overhead is mostly text, it tends to
  2572.        bias the PLB towards machines with faster text operations.
  2573.        The answer is to unpost the border structure just prior to the
  2574.        test loop itself, then post the test structure. After the test is run,
  2575.        the border is re-posted and the workstation updated. This presents
  2576.        the final frame with border to the user. At this point, the test
  2577.        structure is un-posted, and vanishes on the next operation.*/
  2578. #endif
  2579.     
  2580.     /* UN-post the border structure if there is one */
  2581.     if (bench_setup.border_stid)
  2582.     punpost_struct((Pint)bench_setup.workid,(Pint)bench_setup.border_stid);
  2583.  
  2584. #endif /* USING_PHIGS */
  2585.     
  2586.     /* Push the traverser state */
  2587.     traverser_state->currentFrame = 1;
  2588. #ifdef SYSV
  2589.     memcpy((char *)temp_state_ptr,(char *)traverser_state,
  2590.        sizeof(BIF_Traverser_state));
  2591. #else
  2592.     bcopy((char *)traverser_state, (char *)temp_state_ptr,
  2593.       sizeof(BIF_Traverser_state));
  2594. #endif
  2595.     /* Disable Basestate edits */
  2596.     temp_state_ptr->push_level = 1;
  2597.     bif_list = current_test.structure_ptr->top_of_list;
  2598.     
  2599. #ifndef REFER_STRUCTURE_EXISTS
  2600.     /* Expand the CALL's */
  2601.     expandStructure(current_test.structure_ptr);
  2602.     
  2603.     /* Allow instance tracing editing */
  2604.     temp_state_ptr->tol = &tol;
  2605.     temp_state_ptr->eol = &tol;
  2606.     tol.next = NULL;
  2607.     tol.data = current_test.structure_id;
  2608.     
  2609. #endif /* REFER_STRUCTURE_EXISTS */
  2610.     
  2611. #ifdef USING_PHIGS
  2612.     ppost_struct((Pint)bench_setup.workid,
  2613.          (Pint)current_test.structure_id,(Pfloat)1.);
  2614. #endif /* USING_PHIGS */
  2615.     /* **************************** */
  2616.     /* Do the statistical traverser */
  2617.     /* **************************** */
  2618.     brf_state.brf_start_frame = 1;
  2619.     brf_state.brf_end_frame = current_test.n_repetitions;
  2620.     brf_state.brf_num_frames = current_test.n_repetitions;
  2621.     brf_init ( );
  2622.     brf_traverser( traverser_state, bif_list, &brf_state);
  2623.     brf_report(&brf_state ); /* generates the body of report */
  2624.     /* **************** */
  2625.     /* Start stop watch */
  2626.     /* **************** */
  2627.     brf_start_stopwatch();
  2628.     /* **************** */
  2629.     /* Do the test loop */
  2630.     /* **************** */
  2631.     for ( indx = 0 ; indx < current_test.n_repetitions ; indx++ )
  2632.     {
  2633.     Traverse(temp_state_ptr,bif_list);
  2634.     
  2635. #ifdef USING_PHIGS
  2636.     pupd_ws((Pint)bench_setup.workid,(Pregen_flag)PFLAG_PERFORM);
  2637. #endif /* USING_PHIGS */
  2638.     
  2639.     temp_state_ptr->currentFrame++;
  2640.     
  2641.     }
  2642.     /* **************************************** */
  2643.     /* Stop stop watch and print timing results */
  2644.     /* **************************************** */
  2645.     brf_stop_stopwatch(&brf_state);
  2646.     /* **************************************** */
  2647.     
  2648. #ifdef USING_PHIGS
  2649.     /* RE-post the border structure if it exists */
  2650.     if (bench_setup.border_stid) {
  2651.     ppost_struct((Pint)bench_setup.workid,(Pint)bench_setup.border_stid,
  2652.              (Pfloat)1.);
  2653.     pupd_ws((Pint)bench_setup.workid,(Pregen_flag)PFLAG_PERFORM);
  2654.     }
  2655.     /* Open the Non-Reatained Structure */
  2656.     fxopns();
  2657.     traverser_state->nrs_state = 1;
  2658. #endif /* USING_PHIGS */
  2659.     
  2660. #endif /* PRINT_ONLY */
  2661. } /* End procedure bif_endtest */
  2662.  
  2663. /*----------------------------------------------------------------------*\
  2664. | Procedure: int bif_pause()
  2665. |------------------------------------------------------------------------|
  2666. | Description: Receive a PAUSE entity from the parser
  2667. |------------------------------------------------------------------------|
  2668. | Return: Error Code
  2669. \*----------------------------------------------------------------------*/
  2670. int bif_pause()
  2671. {
  2672. #ifdef TEST_PRINT
  2673.     printf("PAUSE :\n");
  2674. #endif /* TEST_PRINT */
  2675. #ifndef PRINT_ONLY
  2676. #ifdef USING_PHIGS
  2677.     fxpaus(&bench_setup.workid);
  2678. #else
  2679.     /* Insert a mouse or keyboard wait */
  2680.     fxpaus(&bench_setup.workid);
  2681. #endif /* USING_PHIGS */
  2682. #endif /* PRINT_ONLY */
  2683. } /* End procedure bif_pause */
  2684. /*----------------------------------------------------------------------*\
  2685. | Procedure    :    int bif_sleep(BIF_INT)
  2686. |------------------------------------------------------------------------|
  2687. | Description    :    Receive a SLEEP entity from the parser
  2688. |
  2689. |    sleep    Sleep period in seconds
  2690. |------------------------------------------------------------------------|
  2691. | Return    :    Error Code
  2692. \*----------------------------------------------------------------------*/
  2693. int bif_sleep(sleep_time)
  2694.     BIF_INT sleep_time;
  2695. {
  2696. #ifdef TEST_PRINT
  2697.     printf("SLEEP : zzzzzzz for %d sec.\n",sleep_time);
  2698. #endif /* TEST_PRINT */
  2699. #ifndef PRINT_ONLY
  2700.     sleep((unsigned)sleep_time);
  2701. #endif /* PRINT_ONLY */
  2702. } /* End procedure bif_sleep */
  2703.  
  2704. /*--------------------------------------------------------------------*\
  2705. | Procedure     :    int indexRange(int, int, int, int)
  2706. |---------------------------------------------------------------------
  2707. | Description   :    Check the supplied index against the range
  2708. |            Generate warning message at file load time.
  2709. |---------------------------------------------------------------------
  2710. | Return        :    -1 --> Value  < min
  2711. |             0 --> min <= Value  <= max
  2712. |            +1 --> Value  > max
  2713. \*--------------------------------------------------------------------*/
  2714. int indexRange(token, indx, min, max)
  2715.     BIF_INT token, indx, min, max;
  2716.     
  2717. {
  2718.     int retCode;
  2719.     char *key_w, *find_keyword_token(); 
  2720.     char buffy[255];
  2721.     if ( indx > max )
  2722.     {
  2723.     retCode =  1;
  2724.     key_w = find_keyword_token(token); 
  2725.     sprintf(buffy,"%s: Index value %d > Max. (%d)",
  2726.         key_w,indx,max);
  2727.     yyerror(buffy);
  2728.     }
  2729.     else if ( indx < min )
  2730.     {
  2731.     retCode = -1;
  2732.     key_w = find_keyword_token(token); 
  2733.     sprintf(buffy,"%s: Index value %d < Min. (%d)",
  2734.         key_w,indx,min);
  2735.     yyerror(buffy);
  2736.     }
  2737.     else
  2738.     {
  2739.     retCode = 0;
  2740.     }
  2741.     
  2742.     return(retCode);
  2743. } /* End indexRange() */
  2744.