home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / demos / gpc / bld_prim.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-12  |  47.8 KB  |  1,567 lines

  1. /* $XConsortium: bld_prim.c,v 5.3 91/07/12 18:05:26 hersh 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. /*#define TEST_PRINT*/
  27. /*#define TEST_PRINT2*/
  28. #define PPRECCHECK 1
  29. /*#define PRINT_ONLY*/
  30. /*--------------------------------------------------------------------*\
  31. |  Copyright (C) 1989,1990, 1991, National Computer Graphics Association
  32. |
  33. |  Permission is granted to any individual or institution to use, copy, or
  34. |  redistribute this software so long as it is not sold for profit, provided
  35. |  this copyright notice is retained.
  36. |
  37. |                         Developed for the
  38. |                National Computer Graphics Association
  39. |                         2722 Merrilee Drive
  40. |                         Fairfax, VA  22031
  41. |                           (703) 698-9600
  42. |
  43. |                                by
  44. |                 SimGraphics Engineering Corporation
  45. |                    1137 Huntington Drive  Unit A
  46. |                      South Pasadena, CA  91030
  47. |                           (213) 255-0900
  48. |---------------------------------------------------------------------
  49. |
  50. | Author        :    John M. Zulauf
  51. |
  52. | File          :    bld_prim.c
  53. | Date          :    Tue Jun 20 11:27:08 PDT 1989
  54. | Project       :    PLB
  55. | Description   :    entity build/exectute functions for the graphics
  56. |            primtive entities
  57. | Status        :    Version 1.0
  58. |
  59. | Revisions     :
  60. |    1/21/89     Paul Chek DEC:
  61. |            - insert an additional argument in call to
  62. |            pfad3 to specify the facet color. It works for
  63. |            DEC PHIGS+, but not with Alliant GX4000 PHIGS+.
  64. |
  65. |    1/89        Staff SimGEC: Various bug fixes.
  66. |
  67. |    2/89        MFR/JMZ SimGEC: Rewrite of bif_pixelmap3 
  68. |            "guts" of pixmap output moved to fakefigs.c
  69. |
  70. |    2/89        MJF SimGEC: Added NUB support 
  71. |            
  72. |
  73. |       2/90            MFC Tektronix, Inc.: PEX-SI API implementation.
  74. |
  75. |       5/90            MFC Tektronix, Inc.: PEX-SI API Binding change.
  76. |
  77. |      12/90            MFC Tektronix, Inc.: PEX-SI PEX5R1 Release.
  78. |
  79. \*--------------------------------------------------------------------*/
  80.  
  81. /*--------------------------------------------------------------------*\
  82. |    Table of Contents
  83. |
  84. |    int bif_marker(BIF_INT)
  85. |        :    Begin / End receiving a MARKER entity
  86. |    int bif_marker3(BIF_INT)
  87. |        :    Begin / End receiving a MARKER3 entity
  88. |    int bif_line(BIF_INT)
  89. |        :    Begin / End receiving a LINE entity from the parser
  90. |    int bif_line3(BIF_INT)
  91. |        :    Begin / End receiving a LINE3 entity from the parser
  92. |    int bif_polygon(BIF_INT)
  93. |        :    Begin / End receiving a POLYGON entity from the parser
  94. |    int bif_polygon3(BIF_INT)
  95. |        :    Begin / End receiving a POLYDATA3 entity from the parser
  96. |    int bif_faset(BIF_INT)
  97. |        :    Begin / End receiving a FILLAREASET entity from the
  98. |    int bif_faset3(BIF_INT)
  99. |        :    Receive a FILLAREASET3 entity from the parser.
  100. |    int bif_triangle3(BIF_INT)
  101. |        :    Begin / End receiving a TRIANGLE3 entity from the parser
  102. |    int bif_quad_mesh3(BIF_INT)
  103. |        :    Begin / End receiving a QUADMESH3 entity from the parser
  104. |    int bif_quadmeshorder(BIF_INT, BIF_INT)
  105. |        :    Receive the size of the current quadmesh from
  106. |    int bif_indexpolygons3(BIF_INT)
  107. |        :    Receive a INDEX_POLYGONS3 entity from the parser. 
  108. |    int bif_text(BIF_REAL, BIF_REAL, * char)
  109. |        :    Receive a TEXT entity from the parser
  110. |    int bif_text3(BIF_REAL, BIF_REAL, BIF_REAL, *char, int, BIF_REAL, 
  111. |        BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL)
  112. |        :    Receive a TEXT3 entity from the parser
  113. |    int bif_annotationtext(BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL, 
  114. |        BIF_REAL, BIF_REAL, *char)
  115. |        :    Receive a ANNOTATION_TEXT3 entity from the parser
  116. |    int bif_sphere3(BIF_INT)
  117. |        :    Begin / End receiving a SPHERE3 entity
  118. |    int bif_gencircle(BIF_INT)
  119. |        :    Begin / End receiving a CIRCLE entity
  120. |    int bif_gencircle3(BIF_INT)
  121. |        :    Begin / End receiving a CIRCLE entity
  122. |    int bif_sphereorder(BIF_INT, BIF_INT)
  123. |        :    Receive the size of the current sphere from
  124. |    int bif_circleedges(BIF_INT)
  125. |        :    Receive the size of the current circle(3) from
  126. |    int bif_exact(BIF_INT)
  127. |        :    Set the GEN_* exact parameter.
  128. |    int bif_center(BIF_REAL, BIF_REAL, BIF_REAL)
  129. |        :    Set the GEN_* center parameter.
  130. |    int bif_radius(BIF_REAL);
  131. |        :    Set the GEN_* radius parameter.
  132. |    int bif_scalefactors(BIF_REAL, BIF_REAL, BIF_REAL)
  133. |        :    Set the GEN_* scale parameter.
  134. |    int bif_normal(BIF_REAL, BIF_REAL, BIF_REAL)
  135. |        :    Set the GEN_* normal parameter.
  136. |    int bif_pixelmap3(BIF_INT)
  137. |        :    Begin / End receiving a PIXEL_MAP3 entity from
  138. |    int bif_nubc (BIF_INT)
  139. |         :    Begin / End receiving a NON_UNIFORM_BSPLINE_CURVE 
  140. |    int bif_nubs (BIF_INT) 
  141. |         :    Begin / End receiving a NON_UNIFORM_BSPLINE_surfaces 
  142. |    int bif_nubcholder (BIF_INT,BIF_INT) 
  143. |         :    Receive the rational/non_rationsl flag for 
  144. |    int bif_nubsholder(BIF_INT,BIF_INT,BIF_INT,BIF_INT,BIF_INT ) 
  145. |         :    Receive the rational/non_rationsl flag for 
  146. |
  147. \*--------------------------------------------------------------------*/
  148.  
  149. /*--------------------------------------------------------------------*\
  150. |    Include files 
  151. \*--------------------------------------------------------------------*/
  152. #include <stdio.h>
  153. #include <X11/Xosdefs.h>
  154. #ifndef X_NOT_STDC_ENV
  155. #include <stdlib.h>
  156. #else
  157. char *malloc();
  158. #endif
  159. #if defined(macII) && !defined(__STDC__)  /* stdlib.h fails to define these */
  160. char *malloc();
  161. #endif /* macII */
  162. #include "biftypes.h"
  163. #include "bifbuild.h"
  164. #include "new_ents.h"
  165. #include "bifparse.h"
  166. #include "db_tools.h"
  167. #include "doentity.h"
  168. #include "bifmacro.h"
  169. #include "globals.h"
  170. #include "ph_map.h"
  171.  
  172. /*--------------------------------------------------------------------*\
  173. |Local #define
  174. \*--------------------------------------------------------------------*/
  175. #ifndef FALSE
  176. #define FALSE 0
  177. #endif
  178. #ifndef TRUE
  179. #define TRUE (!FALSE)
  180. #endif
  181.  
  182. /*--------------------------------------------------------------------*\
  183. |    Local Macros
  184. \*--------------------------------------------------------------------*/
  185.  
  186. /*--------------------------------------------------------------------*\
  187. |    Local Globals
  188. \*--------------------------------------------------------------------*/
  189. static BIF_All temp_ent;
  190. static int numRows, numColumns;
  191. static int static_iorder;
  192. static int static_rational_non;
  193. static int static_iuorder;
  194. static int static_ivorder;
  195. static int static_m;
  196. static int static_n;
  197.  
  198. /*--------------------------------------------------------------------*\
  199. | Procedure     :    int bif_marker(BIF_INT)
  200. |---------------------------------------------------------------------
  201. | Description   :    Begin / End receiving a MARKER entity
  202. |    BIF_P_BEGIN     Initialize a triple list for marker locations
  203. |    BIF_P_END    Store the point list in the entity structure
  204. |---------------------------------------------------------------------
  205. | Return        :    Error Code (Not Implemented)
  206. \*--------------------------------------------------------------------*/
  207.  
  208. int bif_marker(begin_or_end)
  209. BIF_INT begin_or_end;
  210. {
  211.     int size;
  212.     BIF_Marker *ent;
  213.     Real_int_union *trip_list;
  214. #ifdef TEST_PRINT
  215.     BEGEND(marker);
  216. #endif /* TEST_PRINT */
  217. #ifndef PRINT_ONLY
  218.     switch (begin_or_end)
  219.     {
  220.     case BIF_P_BEGIN:
  221.     /* Start of a MARKER */
  222.         init_triplets();
  223.         break;
  224.  
  225.     case  BIF_P_END:
  226.         size = end_triplets(&trip_list);
  227.         ent = new_marker(size,trip_list);
  228.         ENT_ERROR(ent);
  229.  
  230.     /* Store or execute */        
  231.         Traverse(traverser_state, ent);
  232.  
  233.     /* Send to PHIGs */
  234. #ifdef USING_PHIGS
  235.         {
  236.             Ppoint_list points;
  237.  
  238.             points.num_points = ent->number;
  239.             points.points = ent->points;
  240.             ppolymarker(&points);
  241.         }
  242. #endif /* USING_PHIGS */
  243.         Free_NRE(traverser_state, ent);
  244.         break;
  245.     }
  246. #endif /* PRINT_ONLY */
  247. } /* End procedure bif_marker */
  248.  
  249. /*--------------------------------------------------------------------*\
  250. | Procedure     :    int bif_marker3(BIF_INT)
  251. |---------------------------------------------------------------------
  252. | Description   :    Begin / End receiving a MARKER3 entity
  253. |    BIF_P_BEGIN     Initialize a triple list for marker locations
  254. |    BIF_P_END    Store the point list in the entity structure
  255. |---------------------------------------------------------------------
  256. | Return        :    Error Code (Not Implemented)
  257. \*--------------------------------------------------------------------*/
  258.  
  259. int bif_marker3(begin_or_end)
  260. BIF_INT begin_or_end;
  261. {
  262.     int size;
  263.     BIF_Marker3 *ent;
  264.     Real_int_union *trip_list;
  265. #ifdef TEST_PRINT
  266.     BEGEND(marker3);
  267. #endif /* TEST_PRINT */
  268. #ifndef PRINT_ONLY
  269.     switch (begin_or_end)
  270.     {
  271.     case BIF_P_BEGIN:
  272.     /* Start of a MARKER3 */
  273.         init_triplets();
  274.         break;
  275.  
  276.     case BIF_P_END:
  277.         size = end_triplets(&trip_list);
  278.         ent = new_marker3(size,trip_list);
  279.         ENT_ERROR(ent);
  280.  
  281.     /* Store or execute */        
  282.         Traverse(traverser_state, ent);
  283.  
  284.     /* Send to PHIGs */
  285. #ifdef USING_PHIGS
  286.         {
  287.             Ppoint_list3 points;
  288.  
  289.             points.num_points = ent->number;
  290.             points.points = ent->points;
  291.             ppolymarker3(&points);
  292.         }
  293. #endif /* USING_PHIGS */
  294.         Free_NRE(traverser_state, ent);
  295.         break;
  296.     }
  297. #endif /* PRINT_ONLY */
  298. } /* End procedure bif_marker3 */
  299.  
  300. /*--------------------------------------------------------------------*\
  301. | Procedure    :    int bif_line(BIF_INT)
  302. |---------------------------------------------------------------------
  303. | Description    :    Begin / End receiving a LINE entity from the parser
  304. |        BIF_P_BEGIN     Init a triple list for line vertices
  305. |        BIF_P_END     Store the vertices in the entity
  306. |---------------------------------------------------------------------
  307. | Return    :    Error Code (Not Implemented)
  308. \*--------------------------------------------------------------------*/
  309. int bif_line(begin_or_end)
  310. BIF_INT begin_or_end;
  311.  
  312. {
  313.     int size;
  314.     BIF_Line *ent;
  315.     Real_int_union *trip_list;
  316. #ifdef TEST_PRINT
  317.     BEGEND(line);
  318. #endif /* TEST_PRINT */
  319. #ifndef PRINT_ONLY
  320.     switch (begin_or_end)
  321.     {
  322.     case BIF_P_BEGIN:
  323.     /* Start of a LINE */
  324.         init_triplets();
  325.         break;
  326.  
  327.     case BIF_P_END:
  328.         size = end_triplets(&trip_list);
  329.         ent = new_line(size,trip_list);
  330.         ENT_ERROR(ent);
  331.  
  332.     /* Store or execute */        
  333.         Traverse(traverser_state, ent);
  334.  
  335. #ifdef USING_PHIGS
  336.         { 
  337.             Ppoint_list points;
  338.  
  339.             points.num_points = ent->number;
  340.             points.points = ent->points;
  341.             ppolyline(&points);
  342.         }
  343. #endif /* USING_PHIGS */
  344.         Free_NRE(traverser_state, ent);
  345.  
  346.     }
  347. #endif /* PRINT_ONLY */
  348. } /* End procedure bif_line */
  349.  
  350. /*--------------------------------------------------------------------*\
  351. | Procedure    :     int bif_line3(BIF_INT)
  352. |---------------------------------------------------------------------
  353. | Description    :    Begin / End receiving a LINE3 entity from the parser
  354. |        BIF_P_BEGIN     Init the group list for LINE3 data
  355. |        BIF_P_END     Store the LINE3 data in the entity
  356. |
  357. |        LINE3 may contain per vertex color data.
  358. |---------------------------------------------------------------------
  359. | Return    :    Error Code (Not Implemented)
  360. \*--------------------------------------------------------------------*/
  361. int bif_line3(begin_or_end)
  362. BIF_INT begin_or_end;
  363.  
  364. {
  365.  
  366.     BIF_Line3 *ent;
  367.  
  368.     int num_groups;
  369.     Group_description *group_list;
  370.  
  371. #ifdef TEST_PRINT
  372.     BEGEND(line3);
  373. #endif /* TEST_PRINT */
  374. #ifndef PRINT_ONLY
  375.     switch (begin_or_end)
  376.     {
  377.     case BIF_P_BEGIN:
  378.     /* Start of a LINE3 */
  379.         init_groups();
  380.         break;
  381.  
  382.     case BIF_P_END:
  383.         num_groups = end_groups(&group_list);
  384.         ent = new_line3(num_groups, group_list);
  385. #ifdef TEST_PRINT
  386. printf("line3: %d groups\n", num_groups);
  387. #endif /* TEST_PRINT */
  388.         ENT_ERROR(ent);
  389.  
  390.     /* Store or execute */        
  391.         Traverse(traverser_state, ent);
  392.  
  393. #ifdef USING_PHIGS
  394.         /* Send to PHIGs */
  395.  
  396.         if (ent->vertex_data_flag)
  397.             ppolyline_set3_data(ent->vertex_data_flag,
  398.                     ent->colour_model,1,&ent->vdata);
  399.         else {
  400.             Ppoint_list3 points;
  401.  
  402.             points.num_points = ent->vdata.num_vertices;
  403.             points.points = ent->vdata.vertex_data.points;
  404.  
  405.             ppolyline3(&points);
  406.         }
  407.  
  408. #endif /* USING_PHIGS */
  409.         Free_NRE(traverser_state, ent);
  410.     }
  411. #endif /* PRINT_ONLY */
  412. } /* End procedure bif_line3 */
  413.  
  414. /*----------------------------------------------------------------------*\
  415. | Procedure    :    int bif_polygon(BIF_INT)
  416. |------------------------------------------------------------------------|
  417. | Description    :    Begin / End receiving a POLYGON entity from the parser
  418. |    BIF_P_BEGIN     begin entity
  419. |        Initialize a triple list for incoming polygon contour
  420. |    BIF_P_END    end entity
  421. |        Store the received point list in the entity structure
  422. |------------------------------------------------------------------------|
  423. | Return    :    Error Code
  424. \*----------------------------------------------------------------------*/
  425. int bif_polygon(begin_or_end)
  426. BIF_INT begin_or_end;
  427. {
  428.     int size;
  429.     BIF_Polygon *ent;
  430.     Real_int_union *trip_list;
  431. #ifdef TEST_PRINT
  432.     BEGEND(polygon);
  433. #endif /* TEST_PRINT */
  434. #ifndef PRINT_ONLY
  435.     switch (begin_or_end)
  436.     {
  437.     case BIF_P_BEGIN:
  438.     /* Start of a POLYGON */
  439.         init_triplets();
  440.         break;
  441.     case BIF_P_END:
  442.         size = end_triplets(&trip_list);
  443.         ent = new_polygon(size,trip_list);
  444.         ENT_ERROR(ent);
  445.  
  446.     /* Store or execute */        
  447.         Traverse(traverser_state, ent);
  448.  
  449.     /* Send to PHIGs */
  450. #ifdef USING_PHIGS
  451.         {
  452.             Ppoint_list_list poly_list_list;
  453.             Ppoint_list poly_list;
  454.             poly_list_list.num_point_lists = (Pint)1;
  455.             poly_list.num_points = ent->number;
  456.             poly_list.points = ent->points;
  457.             poly_list_list.point_lists = &poly_list;
  458.             pfill_area_set(&poly_list_list);
  459.         }
  460. #endif /* USING_PHIGS */
  461.         Free_NRE(traverser_state, ent);
  462.     }
  463. #endif /* PRINT_ONLY */
  464. } /* End procedure bif_polygon */
  465.  
  466. /*----------------------------------------------------------------------*\
  467. | Procedure    :    int bif_polygon3(BIF_INT)
  468. |------------------------------------------------------------------------|
  469. | Description    :    Begin / End receiving a POLYDATA3 entity from the parser
  470. |    BIF_P_BEGIN     begin entity
  471. |        Initialize group handler for incoming polydata contour
  472. |        and optional data groups:
  473. |        VERTEX_COLORS, VERTEX_NORMALS, FACET_COLORS, 
  474. |        FACET_NORMALS 
  475. |    BIF_P_END        end entity
  476. |        Store the received point list and optional data in the
  477. |        entity structure.
  478. |------------------------------------------------------------------------|
  479. | Return    :    Error Code
  480. \*----------------------------------------------------------------------*/
  481. int bif_polygon3(begin_or_end)
  482. BIF_INT begin_or_end;
  483. {
  484.     BIF_Polygon3 *ent;
  485.     Group_description *group_list;
  486.     int num_groups;
  487.  
  488. #ifdef TEST_PRINT
  489.     BEGEND(polygon3);
  490. #endif /* TEST_PRINT */
  491. #ifndef PRINT_ONLY
  492.     switch (begin_or_end)
  493.     {
  494.     case BIF_P_BEGIN:
  495.     /* Start of a polygon3 */
  496.         init_groups();
  497.         break;
  498.  
  499.     case BIF_P_END:
  500.         num_groups = end_groups(&group_list);
  501. #ifdef TEST_PRINT2
  502. fflush(stderr);
  503. printf("polygon3: %d groups\n", num_groups);
  504. fflush(stdout);
  505. #endif /* TEST_PRINT2 */
  506.         ent = new_polygon3(num_groups, group_list);
  507.         ENT_ERROR(ent);
  508.  
  509.     /* Store or execute */        
  510.         Traverse(traverser_state, ent);
  511.  
  512.     /* Send to PHIGs */
  513. #ifdef USING_PHIGS
  514. #ifdef TEST_PRINT2
  515. printf("flags %d %d %d\n",
  516.     ent->facet_data_flag, ent->vertex_data_flag, ent->colour_model );
  517. printf("numFacets %d\n", ent->numFacets);
  518. #endif /* TEST_PRINT */
  519.         {
  520.             Pfacet_vdata_list3 vdata;
  521.  
  522.             vdata.num_vertices = ent->numCoords;
  523.             vdata.vertex_data = ent->vdata;
  524.             pfill_area_set3_data(ent->facet_data_flag,0,
  525.                      ent->vertex_data_flag,
  526.                      ent->colour_model,&ent->fdata,1,
  527.                      (Pedge_data_list *)NULL,&vdata);
  528.         }
  529. #endif /* USING_PHIGS */
  530.         Free_NRE(traverser_state, ent);
  531.     }
  532. #endif /* PRINT_ONLY */
  533. } /* End procedure bif_polygon3 */
  534.  
  535. /*--------------------------------------------------------------------*\
  536. | Procedure    :    int bif_faset(BIF_INT)
  537. |---------------------------------------------------------------------
  538. | Description    :    Begin / End receiving a FILLAREASET entity from the
  539. |            parser
  540. |    BIF_P_BEGIN     Initialize the triple list for the 
  541. |            fillareaset contours.  Initialize the
  542. |            contour handler.
  543. |
  544. |    BIF_P_END    Store the contour list in the entity.
  545. |---------------------------------------------------------------------
  546. | Return    :    Error Code
  547. \*--------------------------------------------------------------------*/
  548. int bif_faset(begin_or_end)
  549. BIF_INT begin_or_end;
  550. {
  551.     BIF_Fillareaset *ent;
  552.     int num_contours;
  553.     Real_int_union *cont_list;
  554.  
  555. #ifdef TEST_PRINT
  556.     BEGEND(fillareaset );
  557. #endif /* TEST_PRINT */
  558. #ifndef PRINT_ONLY
  559.     switch (begin_or_end)
  560.     {
  561.     case BIF_P_BEGIN:
  562.     /* Start of a fillareaset */
  563.         init_contours(begin_or_end);
  564.         break;
  565.     case BIF_P_END:
  566.         num_contours = end_contours(&cont_list);
  567.         ent = new_fillareaset(num_contours, cont_list);
  568.         ENT_ERROR(ent);
  569.  
  570.     /* Store or execute */        
  571.         Traverse(traverser_state, ent);
  572.  
  573.     /* Send to PHIGs */
  574. #ifdef USING_PHIGS
  575.     {
  576.         Ppoint_list_list poly_list_list;
  577.         poly_list_list.num_point_lists = ent->numContours;
  578.         poly_list_list.point_lists = ent->sets;
  579.         pfill_area_set(&poly_list_list);
  580.     }
  581. #endif /* USING_PHIGS */
  582.         Free_NRE(traverser_state, ent);
  583.     }
  584. #endif /* PRINT_ONLY */
  585. } /* End procedure bif_faset */
  586.  
  587. /*--------------------------------------------------------------------*\
  588. | Procedure    :    int bif_faset3(BIF_INT)
  589. |---------------------------------------------------------------------
  590. | Description    :    Receive a FILLAREASET3 entity from the parser.
  591. |
  592. |    BIF_P_BEGIN    Initialize group handler for the
  593. |            incoming fill area set contours and
  594. |            optional data groups.
  595. |
  596. |    BIF_P_END    Store the received contours and
  597. |            optional data in the entity structure.
  598. |---------------------------------------------------------------------
  599. | Return    :    Error Code
  600. \*--------------------------------------------------------------------*/
  601. int bif_faset3(begin_or_end)
  602. BIF_INT begin_or_end;
  603. {
  604.     BIF_Fillareaset3 *ent;
  605.     Group_description *group_list;
  606.     int num_groups;
  607. #ifdef TEST_PRINT
  608.     BEGEND(fillareaset3);
  609. #endif /* TEST_PRINT */
  610. #ifndef PRINT_ONLY
  611.     switch (begin_or_end)
  612.     {
  613.     case BIF_P_BEGIN:
  614.         /* Start of a fillarea3 */
  615.         init_groups();
  616.         break;
  617.  
  618.     case BIF_P_END:
  619.         num_groups = end_groups(&group_list);
  620.         ent = new_fillareaset3(num_groups, group_list);
  621.         ENT_ERROR(ent);
  622.  
  623.         /* Store or execute */        
  624.         Traverse(traverser_state, ent);
  625.  
  626. #ifdef USING_PHIGS
  627.         pfill_area_set3_data(ent->facet_data_flag,ent->edge_data_flag,
  628.                      ent->vertex_data_flag,
  629.                      ent->colour_model,&ent->fdata,
  630.                      ent->numContours,ent->edata,
  631.                      ent->vdata);
  632. #ifdef TEST_PRINT2
  633.     printf("v pfill_area_set3_data\n");
  634.     fflush(stdout);
  635. #endif /* TEST_PRINT2 */
  636.  
  637. #endif /* USING_PHIGS */
  638.  
  639.         Free_NRE(traverser_state, ent);
  640.     }
  641.  
  642. #endif /* PRINT_ONLY */
  643. } /* End procedure bif_faset3 */
  644.  
  645. /*--------------------------------------------------------------------*\
  646. | Procedure    :    int bif_triangle3(BIF_INT)
  647. |---------------------------------------------------------------------
  648. | Description    :    Begin / End receiving a TRIANGLE3 entity from the parser
  649. |    BIF_P_BEGIN     Initialize group handler for incoming triangle3
  650. |            points and optional data groups
  651. |
  652. |    BIF_P_END    Store the points and optional data in the
  653. |            entity.
  654. |---------------------------------------------------------------------
  655. | Return    :    Error Code
  656. \*--------------------------------------------------------------------*/
  657. int bif_triangle3(begin_or_end)
  658. BIF_INT begin_or_end;
  659. {
  660.     BIF_Triangle3 *ent;
  661.     Group_description *group_list;
  662.     int num_groups;
  663.  
  664. #ifdef TEST_PRINT
  665.     BEGEND(triangle3);
  666. #endif /* TEST_PRINT */
  667. #ifndef PRINT_ONLY
  668.     switch (begin_or_end)
  669.     {
  670.     case BIF_P_BEGIN:
  671.     /* Start of a triangle3 */
  672.         init_groups();
  673.         break;
  674.  
  675.     case BIF_P_END:
  676.         num_groups = end_groups(&group_list);
  677.         ent = new_triangle3(num_groups, group_list);
  678.         ENT_ERROR(ent);
  679.  
  680.     /* Store or execute */        
  681.         Traverse(traverser_state, ent);
  682.  
  683.     /* Send to PHIGs (fakefigs.c on the GX4000) */
  684. #ifdef USING_PHIGS
  685.         ptri_strip3_data(ent->facet_data_flag,ent->vertex_data_flag,
  686.               ent->colour_model,ent->numCoords,
  687.               &ent->fdata,&ent->vdata);
  688. #endif /* USING_PHIGS */
  689.         Free_NRE(traverser_state, ent);
  690.     }
  691. #endif /* PRINT_ONLY */
  692. } /* End procedure bif_triangle3 */
  693.  
  694. /*--------------------------------------------------------------------*\
  695. | Procedure    :    int bif_quad_mesh3(BIF_INT)
  696. |---------------------------------------------------------------------
  697. | Description    :    Begin / End receiving a QUADMESH3 entity from the parser
  698. |    BIF_P_BEGIN     Initialize group handler for incoming quadmesh3
  699. |            points and optional data groups
  700. |
  701. |    BIF_P_END    Store the points and optional data in the
  702. |            entity.
  703. |---------------------------------------------------------------------
  704. | Return    :    Error Code
  705. \*--------------------------------------------------------------------*/
  706. int bif_quad_mesh3(begin_or_end)
  707. BIF_INT begin_or_end;
  708. {
  709.     BIF_Quadmesh3 *ent;
  710.     Group_description *group_list;
  711.     int num_groups;
  712.  
  713. #ifdef TEST_PRINT
  714.     BEGEND(quadmesh3);
  715. #endif /* TEST_PRINT */
  716. #ifndef PRINT_ONLY
  717.     switch (begin_or_end)
  718.     {
  719.     case BIF_P_BEGIN:
  720.     /* Start of a quadmesh3 */
  721.         init_groups();
  722.         break;
  723.  
  724.     case BIF_P_END:
  725.         num_groups = end_groups(&group_list);
  726.         ent = new_quadmesh3(numRows, numColumns,
  727.             num_groups, group_list);
  728.  
  729.         ENT_ERROR(ent);
  730.  
  731.     /* Store or execute */        
  732.         Traverse(traverser_state, ent);
  733.  
  734.     /* Send to PHIGs */
  735. #ifdef TEST_PRINT
  736. printf("bif_qm: fxqmd3\n");
  737. printf("qmd flags %d %d %d\n",
  738.     ent->facet_data_flag, ent->vertex_data_flag, ent->colour_model );
  739. #endif /* TEST_PRINT */
  740. #ifdef USING_PHIGS
  741.         pquad_mesh3_data(ent->facet_data_flag,
  742.                ent->vertex_data_flag,
  743.                ent->colour_model,&ent->dim,
  744.                &ent->fdata,&ent->vdata);
  745. #endif /* USING_PHIGS */
  746.         Free_NRE(traverser_state, ent);
  747.     }
  748. #endif /* PRINT_ONLY */
  749. } /* End procedure bif_quadmesh3 */
  750.  
  751. /*--------------------------------------------------------------------*\
  752. | Procedure     :    int bif_quadmeshorder(BIF_INT, BIF_INT)
  753. |---------------------------------------------------------------------
  754. | Description   :    Receive the size of the current quadmesh from
  755. |            the parser. Save them in static variables
  756. |            numRows and numColumns.
  757. |---------------------------------------------------------------------
  758. | Return        :    Error Code (Not Implemented.)
  759. \*--------------------------------------------------------------------*/
  760. int bif_quadmeshorder(nRows, nCols)
  761. BIF_INT nRows, nCols;
  762.  
  763. {
  764. #ifdef TEST_PRINT
  765.     printf("quadmeshorder: %d %d\n", nRows, nCols);
  766. #endif /* TEST_PRINT */
  767.     numRows    = nRows;
  768.     numColumns = nCols;
  769. } /* End bif_quadmeshorder() */
  770.  
  771.  
  772. /*--------------------------------------------------------------------*\
  773. | Procedure    :    int bif_indexpolygons3(BIF_INT)
  774. |---------------------------------------------------------------------
  775. | Description    :    Receive a INDEX_POLYGONS3 entity from the parser. 
  776. |
  777. |    BIF_P_BEGIN    Initialize group handler for the
  778. |            incoming indexpolygons3 and
  779. |            optional data groups.
  780. |
  781. |    BIF_P_END    Store the received contours and
  782. |            optional data in the entity structure.
  783. |---------------------------------------------------------------------
  784. | Return    :    Error Code
  785. \*--------------------------------------------------------------------*/
  786. int bif_indexpoly3(begin_or_end)
  787. BIF_INT begin_or_end;
  788. {
  789.     BIF_Indexpolygons3 *ent;
  790.     Group_description *group_list;
  791.     int num_groups;
  792. #ifdef TEST_PRINT
  793.     BEGEND(indexpolygons3);
  794. #endif /* TEST_PRINT */
  795. #ifndef PRINT_ONLY
  796.     switch (begin_or_end)
  797.     {
  798.     case BIF_P_BEGIN:
  799.         /* Start of a indexpolygons3 */
  800.         init_groups();
  801.         break;
  802.  
  803.     case BIF_P_END:
  804.         num_groups = end_groups(&group_list);
  805.         ent = new_indexpolygons3(num_groups, group_list);
  806.         ENT_ERROR(ent);
  807.  
  808.         /* Store or execute */        
  809.         Traverse(traverser_state, ent);
  810.  
  811.         /* Send to PHIGs */
  812. #ifdef USING_PHIGS
  813. #ifdef TEST_PRINT
  814.         printf("pphd3 flags %d %d %d\n",
  815.                ent->facet_data_flag, ent->vertex_data_flag,
  816.                ent->colour_model );
  817.         fflush(stdout);
  818. #endif /* TEST_PRINT */
  819.         pset_of_fill_area_set3_data(ent->facet_data_flag,
  820.                         ent->edge_data_flag,
  821.                         ent->vertex_data_flag,
  822.                         ent->colour_model,ent->numFacets,
  823.                         &ent->fdata,ent->edata,
  824.                         ent->vlist,&ent->vdata);
  825. #endif /* USING_PHIGS */
  826.         Free_NRE(traverser_state, ent);
  827.     }
  828. #endif /* PRINT_ONLY */
  829. } /* End procedure bif_indexpoly3 */
  830.  
  831. /*----------------------------------------------------------------------*\
  832. | Procedure    :    int bif_text(BIF_REAL, BIF_REAL, * char)
  833. |------------------------------------------------------------------------|
  834. | Description    :    Receive a TEXT entity from the parser
  835. |        x, y        Location of the text (MC)
  836. |        qtext_string    Contents of text.
  837. |------------------------------------------------------------------------|
  838. | Return    :    Error Code
  839. \*----------------------------------------------------------------------*/
  840. int bif_text(x, y, qtext_string)
  841. BIF_REAL x, y;
  842. char *qtext_string;
  843. {
  844.  
  845.     BIF_Text *ent;
  846. #ifdef TEST_PRINT
  847.     printf("Text: at %f %f display %s\n",x, y, qtext_string);
  848. #endif /* TEST_PRINT */
  849. #ifndef PRINT_ONLY
  850.     ent = new_text((float)x, (float)y, qtext_string);
  851.     ENT_ERROR(ent);
  852.     Traverse(traverser_state, ent);
  853.  
  854. #ifdef USING_PHIGS
  855.     ptext(&ent->text_pt,ent->text_string);
  856. #endif /* USING_PHIGS */
  857. #endif /* PRINT_ONLY */
  858. } /* End procedure bif_text */
  859.  
  860. /*--------------------------------------------------------------------*\
  861. | Procedure    :    int bif_text3(BIF_REAL, BIF_REAL, BIF_REAL, 
  862. |                    *char, int,
  863. |                    BIF_REAL, BIF_REAL, BIF_REAL,
  864. |                    BIF_REAL, BIF_REAL, BIF_REAL)
  865. |---------------------------------------------------------------------
  866. | Description    :    Receive a TEXT3 entity from the parser
  867. |        x, y, z        Location of the text (MC)
  868. |        qtext_string    Contents of text.
  869. |---------------------------------------------------------------------
  870. | Return    :    Error Code
  871. \*--------------------------------------------------------------------*/
  872. int bif_text3(x, y, z, qtext_string,
  873.     flag, tbx, tby, tbz, tux, tuy, tuz)
  874. BIF_REAL x, y, z;
  875. char *qtext_string;
  876. int flag;
  877. BIF_REAL tbx, tby, tbz;
  878. BIF_REAL tux, tuy, tuz;
  879.  
  880. {
  881.  
  882.     BIF_Text3 *ent;
  883. #ifdef TEST_PRINT
  884.     printf("Text3: at %f %f %f display %s\n",x,y,z,qtext_string);
  885.     if ( flag )
  886.         printf("Text directions: base %f %f %f up %f %f %f\n",
  887.             tbx, tby, tbz, tux, tuy, tuz);
  888. #endif /* TEST_PRINT */
  889. #ifndef PRINT_ONLY
  890.     if ( flag == FALSE )
  891.     {
  892.         tbx = 1.; tby = 0.; tbz = 0.;
  893.         tux = 0.; tuy = 1.; tuz = 0.;
  894.     }
  895.  
  896.     ent = new_text3((float)x, (float)y, (float)z, qtext_string,
  897.         (float)tbx, (float)tby, (float)tbz,
  898.         (float)tux, (float)tuy, (float)tuz);
  899.     ENT_ERROR(ent);
  900.     Traverse(traverser_state, ent);
  901. #ifdef TEST_PRINT
  902.     printf("Text3: after new_text3 display %s\n",ent->text_string);
  903. #endif /* TEST_PRINT */
  904. #ifdef EXTERNALNOTE
  905.     Changed the order of arguments in the following ptx3 call.
  906. #endif
  907. #ifdef USING_PHIGS
  908.  
  909.     ptext3(&ent->text_pt,ent->dir,ent->text_string);
  910.  
  911. #endif /* USING_PHIGS */
  912. #endif /* PRINT_ONLY */
  913. } /* End procedure bif_text3 */
  914.  
  915. /*--------------------------------------------------------------------*\
  916. | Procedure    :    int bif_annotationtext(BIF_REAL, BIF_REAL,
  917. |                    BIF_REAL, BIF_REAL, BIF_REAL,
  918. |                    BIF_REAL, *char)
  919. |---------------------------------------------------------------------
  920. | Description    :    Receive a ANNOTATION_TEXT3 entity from the parser
  921. |         x,  y,  z    Location of the text (MC)
  922. |        ox, oy, oz    Offset of the text (NPC)
  923. |        qtext_string    Contents of text.
  924. |---------------------------------------------------------------------
  925. | Return    :    Error Code
  926. \*--------------------------------------------------------------------*/
  927. int bif_annotationtext(x, y, z, ox, oy, oz, qtext_string)
  928. BIF_REAL  x,  y,  z;
  929. BIF_REAL ox, oy, oz;
  930. char *qtext_string;
  931.  
  932. {
  933.  
  934.     BIF_Anno_text3 *ent;
  935. #ifdef TEST_PRINT
  936.     printf("Anno_text3: at %f %f %f display %s\n",x,y,z,qtext_string);
  937.     printf("Offset %f %f %f\n", ox, oy, oz);
  938. #endif /* TEST_PRINT */
  939. #ifndef PRINT_ONLY
  940.  
  941.     ent = new_annotext3((float)x, (float)y, (float)z,
  942.         (float)ox, (float)oy, (float)oz, qtext_string);
  943.  
  944.     ENT_ERROR(ent);
  945.     Traverse(traverser_state, ent);
  946.  
  947. #ifdef USING_PHIGS
  948.     panno_text_rel3(&ent->ref_pt,&ent->anno_offset,
  949.                  ent->text_string);
  950. #endif /* USING_PHIGS */
  951. #endif /* PRINT_ONLY */
  952. } /* End procedure bif_annotationtext */
  953. /*--------------------------------------------------------------------*\
  954. | Procedure     :    int bif_sphere3(BIF_INT)
  955. |---------------------------------------------------------------------
  956. | Description   :    Begin / End receiving a SPHERE3 entity
  957. |    BIF_P_BEGIN     Initialize the sphere optional data
  958. |    BIF_P_END    Generate a quadmesh to do the display
  959. |---------------------------------------------------------------------
  960. | Return        :    Error Code (Not Implemented)
  961. \*--------------------------------------------------------------------*/
  962.  
  963. int bif_sphere3(begin_or_end)
  964. BIF_INT begin_or_end;
  965. {
  966. #ifdef TEST_PRINT
  967.     BEGEND(sphere3);
  968. #endif /* TEST_PRINT */
  969. #ifndef PRINT_ONLY
  970.     switch (begin_or_end)
  971.     {
  972.     case BIF_P_BEGIN:
  973.         /* Start of a GEN_SPHERE3 */
  974.         /* Initialize the default values */
  975.         bif_exact(FALSE);
  976.         bif_center(0.,0.,0.);
  977.         bif_radius(1.0);
  978.         bif_scalefactors(1.0,1.0,1.0);
  979.         break;
  980.  
  981.     case  BIF_P_END:
  982.         /*----------------------------------------------------*\
  983.         |    The generated sphere3 is stored as a quadmesh.
  984.         |    (For the reference port only no "non-EXACT"
  985.         |    method is supported)
  986.         |    genSphere3Mesh generate points to the buffers     
  987.     |    (using bif_triplet) just like the parser would.
  988.         |    bif_quadmesh3(BIF_P_END) stores/executes the
  989.         |    generated data as appropriate.
  990.         \*----------------------------------------------------*/
  991.         genSphere3Mesh(&temp_ent.sphere3);
  992.  
  993.         break;
  994.     }
  995. #endif /* PRINT_ONLY */
  996. } /* End procedure bif_sphere3 */
  997.  
  998. /*--------------------------------------------------------------------*\
  999. | Procedure     :    int bif_gencircle(BIF_INT)
  1000. |---------------------------------------------------------------------
  1001. | Description   :    Begin / End receiving a CIRCLE entity
  1002. |    BIF_P_BEGIN     Initialize the circle optional data
  1003. |    BIF_P_END    Generate a polygon with enough sides.
  1004. |---------------------------------------------------------------------
  1005. | Return        :    Error Code (Not Implemented)
  1006. \*--------------------------------------------------------------------*/
  1007.  
  1008. int bif_gencircle(begin_or_end)
  1009. BIF_INT begin_or_end;
  1010. {
  1011. #ifdef TEST_PRINT
  1012.     BEGEND(circle);
  1013. #endif /* TEST_PRINT */
  1014. #ifndef PRINT_ONLY
  1015.     switch (begin_or_end)
  1016.     {
  1017.     case BIF_P_BEGIN:
  1018.         /* Start of a GEN_CIRCLE */
  1019.         /* Initialize the default values */
  1020.         bif_exact(FALSE);
  1021.         bif_center(0.,0.,0.);
  1022.         bif_radius(1.0);
  1023.         bif_scalefactors(1.0,1.0,1.0);
  1024.         break;
  1025.  
  1026.     case  BIF_P_END:
  1027.         /*----------------------------------------------------*\
  1028.         |    The generated circle is stored as a polygon.
  1029.         |    genCirclePoly generate points to the buffers 
  1030.         |    (using bif_pair) just like the parser would.
  1031.         |    bif_polygon(BIF_P_END) stores/executes the
  1032.         |    generated data as appropriate.
  1033.         \*----------------------------------------------------*/
  1034.         genCirclePoly(&temp_ent.circle);
  1035.     break;
  1036.     }
  1037. #endif /* PRINT_ONLY */
  1038. } /* End procedure bif_gencircle */
  1039.  
  1040. /*--------------------------------------------------------------------*\
  1041. | Procedure     :    int bif_gencircle3(BIF_INT)
  1042. |---------------------------------------------------------------------
  1043. | Description   :    Begin / End receiving a CIRCLE entity
  1044. |    BIF_P_BEGIN     Initialize the circle3 optional data
  1045. |    BIF_P_END    Generate a polygon with enough sides.
  1046. |---------------------------------------------------------------------
  1047. | Return        :    Error Code (Not Implemented)
  1048. \*--------------------------------------------------------------------*/
  1049.  
  1050. int bif_gencircle3(begin_or_end)
  1051. BIF_INT begin_or_end;
  1052. {
  1053. #ifdef TEST_PRINT
  1054.     BEGEND(circle3);
  1055. #endif /* TEST_PRINT */
  1056. #ifndef PRINT_ONLY
  1057.     switch (begin_or_end)
  1058.     {
  1059.     case BIF_P_BEGIN:
  1060.         /* Start of a GEN_CIRCLE3 */
  1061.         /* Initialize the default values */
  1062.         bif_exact(FALSE);
  1063.         bif_center(0.,0.,0.);
  1064.         bif_normal(0.,0.,1.);
  1065.         bif_radius(1.0);
  1066.         bif_scalefactors(1.0,1.0,1.0);
  1067.         break;
  1068.  
  1069.     case  BIF_P_END:
  1070.         /*----------------------------------------------------*\
  1071.         |    The generated circle3 is stored as a polygon3.
  1072.         |    genCircle3Poly generate points to the buffers 
  1073.         |    (using bif_triplets) just like the parser would .
  1074.         |    bif_polygon3(BIF_P_END) stores/executes the
  1075.         |    generated data as appropriate.
  1076.         \*----------------------------------------------------*/
  1077.         genCircle3Poly(&temp_ent.circle3);
  1078.  
  1079.         break;
  1080.     }
  1081. #endif /* PRINT_ONLY */
  1082. } /* End procedure bif_gencircle3 */
  1083.  
  1084. /*--------------------------------------------------------------------*\
  1085. | Procedure     :    int bif_sphereorder(BIF_INT, BIF_INT)
  1086. |---------------------------------------------------------------------
  1087. | Description   :    Receive the size of the current sphere from
  1088. |            the parser. Save them in static temp_ent<dot>
  1089. |            numLong and numLat.
  1090. |---------------------------------------------------------------------
  1091. | Return        :    Error Code (Not Implemented.)
  1092. \*--------------------------------------------------------------------*/
  1093. int bif_sphereorder(nLong, nLat)
  1094. BIF_INT nLong, nLat;
  1095.  
  1096. {
  1097.     temp_ent.sphere3.numLong = nLong;
  1098.     temp_ent.sphere3.numLat  = nLat;
  1099. } /* End bif_sphereorder() */
  1100.  
  1101. /*--------------------------------------------------------------------*\
  1102. | Procedure     :    int bif_circleedges(BIF_INT)
  1103. |---------------------------------------------------------------------
  1104. | Description   :    Receive the size of the current circle(3) from
  1105. |            the parser. Save it in static:
  1106. |            temp_ent.sphere3.numLong
  1107. |                (numLat is ignored for circles.)
  1108. |---------------------------------------------------------------------
  1109. | Return        :    Error Code (Not Implemented.)
  1110. \*--------------------------------------------------------------------*/
  1111. int bif_circleedges(nLong)
  1112. BIF_INT nLong;
  1113.  
  1114. {
  1115.     temp_ent.sphere3.numLong = nLong;
  1116.     temp_ent.sphere3.numLat  = 1; 
  1117. } /* End bif_circleedges() */
  1118.  
  1119. /*--------------------------------------------------------------------*\
  1120. | Procedure     :    int bif_exact(BIF_INT)
  1121. |---------------------------------------------------------------------
  1122. | Description   :    Set the GEN_* exact parameter.
  1123. |            Save it in static:
  1124. |                temp_ent.sphere3.exact
  1125. |---------------------------------------------------------------------
  1126. | Return        :    Error Code (Not Implemented.)
  1127. \*--------------------------------------------------------------------*/
  1128. int bif_exact(exact)
  1129. BIF_INT exact;
  1130.  
  1131. {
  1132.     temp_ent.sphere3.exact    = exact;
  1133. } /* End bif_exact() */
  1134.  
  1135. /*--------------------------------------------------------------------*\
  1136. | Procedure     :    int bif_center(BIF_REAL, BIF_REAL, BIF_REAL)
  1137. |---------------------------------------------------------------------
  1138. | Description   :    Set the GEN_* center parameter.
  1139. |            Save it in static:
  1140. |                temp_ent.sphere3.center
  1141. |---------------------------------------------------------------------
  1142. | Return        :    Error Code (Not Implemented.)
  1143. \*--------------------------------------------------------------------*/
  1144. int bif_center(x_center, y_center, z_center)
  1145. BIF_REAL x_center, y_center, z_center;
  1146.  
  1147. {
  1148.     temp_ent.sphere3.center[0]    = (float)x_center;
  1149.     temp_ent.sphere3.center[1]    = (float)y_center;
  1150.     temp_ent.sphere3.center[2]    = (float)z_center;
  1151. } /* End bif_center() */
  1152.  
  1153. /*--------------------------------------------------------------------*\
  1154. | Procedure     :    int bif_radius(BIF_REAL);
  1155. |---------------------------------------------------------------------
  1156. | Description   :    Set the GEN_* radius parameter.
  1157. |            Save it in static:
  1158. |                temp_ent.sphere3.radius
  1159. |---------------------------------------------------------------------
  1160. | Return        :    Error Code (Not Implemented.)
  1161. \*--------------------------------------------------------------------*/
  1162. int bif_radius(radius)
  1163. BIF_REAL radius;
  1164.  
  1165. {
  1166.     temp_ent.sphere3.radius    = (float)radius;
  1167. } /* End bif_radius() */
  1168.  
  1169. /*--------------------------------------------------------------------*\
  1170. | Procedure     :    int bif_scalefactors(BIF_REAL, BIF_REAL, BIF_REAL)
  1171. |---------------------------------------------------------------------
  1172. | Description   :    Set the GEN_* scale parameter.
  1173. |            Save it in static:
  1174. |                temp_ent.sphere3.scale
  1175. |---------------------------------------------------------------------
  1176. | Return        :    Error Code (Not Implemented.)
  1177. \*--------------------------------------------------------------------*/
  1178. int bif_scalefactors(x_scale, y_scale, z_scale)
  1179. BIF_REAL x_scale, y_scale, z_scale;
  1180.  
  1181. {
  1182.     temp_ent.sphere3.scale[0]    = (float)x_scale;
  1183.     temp_ent.sphere3.scale[1]    = (float)y_scale;
  1184.     temp_ent.sphere3.scale[2]    = (float)z_scale;
  1185. } /* End bif_scalefactors() */
  1186.  
  1187. /*--------------------------------------------------------------------*\
  1188. | Procedure     :    int bif_normal(BIF_REAL, BIF_REAL, BIF_REAL)
  1189. |---------------------------------------------------------------------
  1190. | Description   :    Set the GEN_* normal parameter.
  1191. |            Save it in static:
  1192. |                temp_ent.sphere3.norm
  1193. |---------------------------------------------------------------------
  1194. | Return        :    Error Code (Not Implemented.)
  1195. \*--------------------------------------------------------------------*/
  1196. int bif_normal(x_normal, y_normal, z_normal)
  1197. BIF_REAL x_normal, y_normal, z_normal;
  1198.  
  1199. {
  1200.     temp_ent.sphere3.norm[0]    = (float)x_normal;
  1201.     temp_ent.sphere3.norm[1]    = (float)y_normal;
  1202.     temp_ent.sphere3.norm[2]    = (float)z_normal;
  1203. } /* End bif_normal() */
  1204.  
  1205. /*----------------------------------------------------------------------*\
  1206. | Procedure    :    int bif_pixelmap3(BIF_INT)
  1207. |------------------------------------------------------------------------|
  1208. | Description    :    Begin / End receiving a PIXEL_MAP3 entity from
  1209. |            the parser.
  1210. |    BIF_P_BEGIN     begin entity
  1211. |        Initialize group handler for incoming pixelmap
  1212. |        and optional data groups: PSEUDO_COLOR
  1213. |        Make the BIF entity... and post the channels to the 
  1214. |        pixel catching routine.
  1215. |    BIF_P_END        end entity
  1216. |        Store the received point list and optional data in the
  1217. |        entity structure.
  1218. |------------------------------------------------------------------------|
  1219. | Return    :    Error Code
  1220. \*----------------------------------------------------------------------*/
  1221. int bif_pixelmap3(begin_or_end, x, y, z, ixsize, iysize, repFun, mapType)
  1222. BIF_INT begin_or_end;
  1223. BIF_REAL x, y, z;
  1224. BIF_INT ixsize, iysize;
  1225. BIF_INT repFun;
  1226. BIF_INT mapType;
  1227.  
  1228. {
  1229.     BIF_Pixelmap3 *ent;
  1230.     static BIF_Pixelmap3 *saved_ent = NULL;
  1231.     Group_description *group_list;
  1232.     int num_groups;
  1233.     int i; /* generic counter */
  1234.  
  1235. #define NUM_PIX_DGS    1
  1236.     static int pixScan[NUM_PIX_DGS] = 
  1237.     {
  1238.         PSEUDO_COLOR
  1239.     };
  1240.     
  1241.     static int listSize[NUM_PIX_DGS];
  1242.     static Real_int_union *pixList[NUM_PIX_DGS];
  1243.  
  1244.     int numPix, packSize, numPack, ierr;
  1245.     char *packed;
  1246.     int status = 0;    /* general return value */
  1247.  
  1248. #ifdef TEST_PRINT
  1249.     BEGEND(pixelmap3);
  1250.     fprintf(stderr,"into pixel_map3.\n");
  1251.     fflush(stderr);
  1252. #endif /* TEST_PRINT */
  1253. #ifndef PRINT_ONLY
  1254.     switch (begin_or_end)
  1255.     {
  1256.     case BIF_P_BEGIN:
  1257.     /* Start of a pixelmap3 */
  1258.  
  1259.         /* Fill the tempory entity with the necessary info */
  1260.         temp_ent.pixelmap3.upperLeft[0]        = (float)x;
  1261.         temp_ent.pixelmap3.upperLeft[1]        = (float)y;
  1262.         temp_ent.pixelmap3.upperLeft[2]        = (float)z;
  1263.         temp_ent.pixelmap3.numColumns          = (int)ixsize;
  1264.         temp_ent.pixelmap3.numRows             = (int)iysize;
  1265.         temp_ent.pixelmap3.pixelUpdateFunction =
  1266.                 REMAP_PIXFUNC((int)repFun);
  1267.         temp_ent.pixelmap3.bifMapType          = (int)mapType;
  1268.  
  1269.         init_groups();
  1270.  
  1271.         ent = new_pixelmap3( &temp_ent.pixelmap3);
  1272.         ENT_ERROR(ent);
  1273.  
  1274.         bif_initpixelbuffer(ent->numRows, ent->numColumns,
  1275.                 ent->bifMapType, ent->red,
  1276.                 ent->green, ent->blue);
  1277.         saved_ent = ent;
  1278.  
  1279.         break;
  1280.  
  1281.     case BIF_P_END:
  1282.         /*----------------------------------------------------*\
  1283.         |    Pick up where we left off... the buffer should
  1284.         |    now be full.
  1285.         \*----------------------------------------------------*/
  1286.         ent = saved_ent;
  1287.         ENT_ERROR(ent);
  1288.  
  1289.         /*----------------------------------------------------*\
  1290.         |    Find the DG's and compute the sizes
  1291.         \*----------------------------------------------------*/
  1292.         num_groups = end_groups(&group_list);
  1293.         scanForGroups(num_groups, group_list, NUM_PIX_DGS,
  1294.                 pixScan, listSize, pixList);
  1295.  
  1296.         /*----------------------------------------------------*\
  1297.         |    Finish up the pixel buffer
  1298.         \*----------------------------------------------------*/
  1299.         bif_endpixelbuffer(listSize[0]/3, pixList[0]);
  1300.  
  1301.     /* Store or execute */        
  1302.         Traverse(traverser_state, ent);
  1303.  
  1304.     /* Send to PHIGs */
  1305. #ifdef USING_PHIGS
  1306.         /*----------------------------------------------------*\
  1307.         |    Set the pixel update function
  1308.         \*----------------------------------------------------*/
  1309.         fxpixelup(ent->pixelUpdateFunction);
  1310.  
  1311.         /*----------------------------------------------------*\
  1312.         |    PIXEL_MAP3: prepare for the phigs Calls
  1313.         |    Malloc "Enough Space" for one channel of
  1314.         |    data (packed), share the workspace for the 
  1315.         |    three channels, if true color.
  1316.         |    256 is safety margin
  1317.         \*----------------------------------------------------*/
  1318.         numPix = ent->numRows * ent->numColumns;
  1319.         packSize = sizeof(char) * ( numPix +256 );
  1320.         numPack = packSize / 80;
  1321.         packed = malloc ( packSize );
  1322.         ENT_ERROR(packed);
  1323.         
  1324.         if ( wk_info.color_mode == BIF_TRUE_COLOR )
  1325.         {/* True color pixmaps */
  1326.             /*--------------------------------------------*\
  1327.             |    Output R, G, and B
  1328.             \*--------------------------------------------*/
  1329.             fxpixmap3(ent->upperLeft,
  1330.                 ent->numColumns, ent->numRows,
  1331.                 1, ent->red, numPack, packed);
  1332.  
  1333.             fxpixmap3(ent->upperLeft,
  1334.                 ent->numColumns, ent->numRows,
  1335.                 2, ent->green, numPack, packed);
  1336.  
  1337.             fxpixmap3(ent->upperLeft,
  1338.                 ent->numColumns, ent->numRows,
  1339.                 3, ent->blue, numPack, packed);
  1340.         }/* True color pixmaps */
  1341.         else
  1342.         {/* pseudo color pixmaps */
  1343.             /*--------------------------------------------*\
  1344.             |    Output R to all channels
  1345.             \*--------------------------------------------*/
  1346.             fxpixmap3(ent->upperLeft,
  1347.                 ent->numColumns, ent->numRows,
  1348.                 0, ent->red, numPack, packed);
  1349.         }/* pseudo color pixmaps */
  1350.  
  1351.         /*----------------------------------------------------*\
  1352.         |    Free the workspace.
  1353.         \*----------------------------------------------------*/
  1354.         free(packed);
  1355.  
  1356.         /*----------------------------------------------------*\
  1357.         |    Reset the pixel update function
  1358.         \*----------------------------------------------------*/
  1359.         fxpixelup(BIF_PF_REPLACE);
  1360. #endif /* USING_PHIGS */
  1361.  
  1362.         Free_NRE(traverser_state, ent);
  1363.         saved_ent = NULL;
  1364.     }
  1365. #endif /* PRINT_ONLY */
  1366. } /* End procedure bif_pixelmap3 */
  1367.  
  1368. /*--------------------------------------------------------------------*\
  1369. | Procedure    : int bif_nubc (BIF_INT)
  1370. |---------------------------------------------------------------------
  1371. | Description    : Begin / End receiving a NON_UNIFORM_BSPLINE_CURVE 
  1372. |          entity from the parser
  1373. |        BIF_P_BEGIN     Init the group list for 
  1374. |                NON_UNIFORM_BSPLINE_CURVE data
  1375. |        BIF_P_END     Store the NON_UNIFORM_BSPLINE_CURVE  
  1376. |                data in the entity
  1377. |
  1378. |---------------------------------------------------------------------
  1379. | Return    : Error Code (Not Implemented)
  1380. \*--------------------------------------------------------------------*/
  1381. int bif_nubc (begin_or_end) /* ver 1.0 */
  1382. BIF_INT begin_or_end;
  1383. {
  1384.  
  1385.     BIF_Nubc *ent;    /* WORKING: new type */
  1386.  
  1387.     int num_groups;
  1388.     Group_description *group_list;
  1389.  
  1390. #ifdef    TEST_PRINT
  1391.     BEGEND(non_uniform_bspline_curve (nubc));
  1392.     /*------------*/
  1393. #endif /* TEST_PRINT */
  1394.       /*------------*/
  1395.  
  1396.  
  1397. #ifndef PRINT_ONLY
  1398.     switch (begin_or_end)
  1399.     {
  1400.     case BIF_P_BEGIN:
  1401.     /* Start of a LINE3 */
  1402.         init_groups();
  1403.         break;
  1404.  
  1405.     case BIF_P_END:
  1406.         num_groups = end_groups(&group_list);
  1407.         ent = new_nubc(num_groups, group_list);/* WORKING: new type */
  1408. #    ifdef    TEST_PRINT
  1409.         printf("non_uniform_bspline_curve : %d groups\n", num_groups);
  1410.            /*------------*/
  1411. #    endif /* TEST_PRINT */
  1412.          /*------------*/
  1413.             /* can not make this call till memory is being allocated
  1414.         ENT_ERROR(ent);
  1415.         */
  1416.  
  1417.     /*------------------------------------------------------------*\
  1418.     |  Store or execute                           | 
  1419.     \*------------------------------------------------------------*/
  1420.             /* can not make this call till memory is being allocated
  1421.         Traverse(traverser_state, ent);
  1422.         */
  1423.  
  1424. #    ifdef    USING_PHIGS
  1425.         /*----------------------------------------------------*\
  1426.         |  Send to PHIGs:                       |
  1427.         |  Put Phigs call for non_uniform_bspline_curve here   |
  1428.         \*----------------------------------------------------*/
  1429.  
  1430.            /*-------------*/
  1431. #    endif /* USING_PHIGS */
  1432.          /*-------------*/
  1433.  
  1434.             /* can not make this call till memory is being allocated
  1435.         Free_NRE(traverser_state, ent);
  1436.         */
  1437.     }
  1438.     /*-------------*/
  1439. #endif /* PRINT_ONLY  */
  1440.       /*-------------*/
  1441. } /* End procedure bif_nubc */
  1442.  
  1443. /*--------------------------------------------------------------------*\
  1444. | Procedure    : int bif_nubs (BIF_INT)
  1445. |---------------------------------------------------------------------
  1446. | Description    : Begin / End receiving a NON_UNIFORM_BSPLINE_surfaces 
  1447. |          entity from the parser
  1448. |        BIF_P_BEGIN     Init the group list for 
  1449. |                NON_UNIFORM_BSPLINE_surfaces data
  1450. |        BIF_P_END     Store the NON_UNIFORM_BSPLINE_surfaces  
  1451. |                data in the entity
  1452. |
  1453. |---------------------------------------------------------------------
  1454. | Return    : Error Code (Not Implemented)
  1455. \*--------------------------------------------------------------------*/
  1456. int bif_nubs (begin_or_end) /* ver 1.0 */
  1457. BIF_INT begin_or_end;
  1458. {
  1459.     BIF_Nubs *ent;    /* WORKING: new type */
  1460.  
  1461.     int num_groups;
  1462.     Group_description *group_list;
  1463.  
  1464. #ifdef    TEST_PRINT
  1465.     BEGEND(non_uniform_bspline_surfaces (nubs));
  1466.     /*------------*/
  1467. #endif /* TEST_PRINT */
  1468.       /*------------*/
  1469.  
  1470.  
  1471. #ifndef PRINT_ONLY
  1472.     switch (begin_or_end)
  1473.     {
  1474.     case BIF_P_BEGIN:
  1475.     /* Start of a LINE3 */
  1476.         init_groups();
  1477.         break;
  1478.  
  1479.     case BIF_P_END:
  1480.         num_groups = end_groups(&group_list);
  1481.         ent = new_nubs(num_groups, group_list);/* WORKING: new type */
  1482. #    ifdef    TEST_PRINT
  1483.         printf("non_uniform_bspline_surfaces : %d groups\n",num_groups);
  1484.            /*------------*/
  1485. #    endif /* TEST_PRINT */
  1486.          /*------------*/
  1487.             /* can not make this call till memory is being allocated
  1488.         ENT_ERROR(ent);
  1489.         */
  1490.  
  1491.     /*------------------------------------------------------------*\
  1492.     |  Store or execute                           | 
  1493.     \*------------------------------------------------------------*/
  1494.             /* can not make this call till memory is being allocated
  1495.         Traverse(traverser_state, ent);
  1496.         */
  1497.  
  1498. #    ifdef    USING_PHIGS
  1499.         /*----------------------------------------------------*\
  1500.         |  Send to PHIGs:                       |
  1501.         |  Put Phigs call for non_uniform_bspline_surfaces here|
  1502.         \*----------------------------------------------------*/
  1503.  
  1504.            /*-------------*/
  1505. #    endif /* USING_PHIGS */
  1506.          /*-------------*/
  1507.  
  1508.             /* can not make this call till memory is being allocated
  1509.         Free_NRE(traverser_state, ent);
  1510.         */
  1511.     }
  1512.     /*-------------*/
  1513. #endif /* PRINT_ONLY  */
  1514.       /*-------------*/
  1515. } /* End procedure bif_nubs */
  1516.  
  1517. /*--------------------------------------------------------------------*\
  1518. | Procedure     :    int bif_nubcholder(BIF_INT, BIF_INT)
  1519. |---------------------------------------------------------------------
  1520. | Description   :    Receive the rational/non_rationsl flag for 
  1521. |            and the order for NON_UNIFORM_BSPLINE_CURVE
  1522. |---------------------------------------------------------------------
  1523. | Return        :    Error Code (Not Implemented.)
  1524. \*--------------------------------------------------------------------*/
  1525. int bif_nubcholder (rational_non,iorder) /* ver 1.0 */
  1526. BIF_INT rational_non,iorder;
  1527. {
  1528. #ifdef TEST_PRINT
  1529.     printf("nubcholder: ");
  1530.     if (rational_non == RATIONAL)
  1531.         printf("RATIONAL order is %d\n",iorder);
  1532.     else
  1533.         printf("NON_RATIONAL order is %d\n",iorder);
  1534. #endif /* TEST_PRINT */
  1535.     static_rational_non = rational_non;
  1536.     static_iorder = iorder;
  1537. } /* End bif_nubcholder() */
  1538.  
  1539.  
  1540. /*--------------------------------------------------------------------*\
  1541. | Procedure     :    int bif_nubsholder(BIF_INT, BIF_INT, BIF_INT,
  1542. |                       BIF_INT, BIF_INT, BIF_INT)
  1543. |---------------------------------------------------------------------
  1544. | Description   :    Receive the rational/non_rationsl flag for 
  1545. |            and the order for NON_UNIFORM_BSPLINE_CURVE
  1546. |---------------------------------------------------------------------
  1547. | Return        :    Error Code (Not Implemented.)
  1548. \*--------------------------------------------------------------------*/
  1549. int bif_nubsholder ( rational_non,iuorder,ivorder,m,n ) /* ver 1.0 */
  1550. BIF_INT rational_non,iuorder,ivorder,m,n;
  1551. {
  1552. #ifdef TEST_PRINT
  1553.     printf("nubsholder: ");
  1554.     if (rational_non == RATIONAL)
  1555.         printf("RATIONAL iuorder=%d ivorder=%d m=%d n=%d\n",
  1556.         iuorder,ivorder,m,n);
  1557.     else
  1558.         printf("NON_RATIONAL iuorder=%d ivorder=%d m=%d n=%d\n", 
  1559.         iuorder,ivorder,m,n);
  1560. #endif /* TEST_PRINT */
  1561.     static_rational_non = rational_non;
  1562.     static_iuorder = iuorder;
  1563.     static_ivorder = ivorder;
  1564.     static_m = m;
  1565.     static_n = n;
  1566. } /* End bif_nubsholder() */
  1567.