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

  1. /* $XConsortium: bld_view.c,v 5.2 91/07/12 18:05:36 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. /*--------------------------------------------------------------------*\
  27. |  Copyright (C) 1989,1990, 1991, National Computer Graphics Association
  28. |
  29. |  Permission is granted to any individual or institution to use, copy, or
  30. |  redistribute this software so long as it is not sold for profit, provided
  31. |  this copyright notice is retained.
  32. |
  33. |                         Developed for the
  34. |                National Computer Graphics Association
  35. |                         2722 Merrilee Drive
  36. |                         Fairfax, VA  22031
  37. |                           (703) 698-9600
  38. |
  39. |                                by
  40. |                 SimGraphics Engineering Corporation
  41. |                    1137 Huntington Drive  Unit A
  42. |                      South Pasadena, CA  91030
  43. |                           (213) 255-0900
  44. |---------------------------------------------------------------------
  45. |
  46. | Author        :    John M. Zulauf
  47. |
  48. | File          :    bld_view.c
  49. | Date          :    Thu Jun 29 20:28:01 PDT 1989
  50. | Project       :    PLB
  51. | Description   :    The build, store/execute functions for "view"
  52. |                    entities
  53. | Status        :    Version 1.0
  54. |
  55. | Revisions     :
  56. |
  57. |    6/89        Staff SimGEC: Extracted from bifbuild.c
  58. |            (PLBDEMO), ANSI/ISO PHIGs Viewing Calls
  59. |
  60. |       2/90            MFC Tektronix, Inc.: PEX-SI API implementation.
  61. |
  62. |       5/90            MFC Tektronix, Inc.: PEX-SI API Binding change.
  63. |
  64. |      12/90            MFC Tektronix, Inc.: PEX-SI PEX5R1 Release.
  65. |
  66. \*--------------------------------------------------------------------*/
  67.  
  68. /*--------------------------------------------------------------------*\
  69. |    Table of Contents
  70. |
  71. |    int bif_vieworient3(BIF_INT, BIF_REAL, BIF_REAL, BIF_REAL)
  72. |        :    Receive a VIEW_ORIENTATION3 entity from the parser
  73. |    int bif_viewmap3(BIF_INT)
  74. |        :    Begin / End receiving a VIEW_MAPPING3 entity from
  75. |    int bif_viewmapbasic(    BIF_INT, BIF_REAL, BIF_REAL, BIF_REAL,
  76. |                BIF_REAL, BIF_INT, *BIF_REAL, BIF_REAL,
  77. |                BIF_REAL)
  78. |        :    Receive basic data for a VIEW_MAPPING3 entity
  79. |    int bif_viewmapmatch(    BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL,
  80. |                BIF_INT )
  81. |        :    Receive aspect ratio match data for VIEW_MAPPING3 
  82. |    int bif_viewspec(BIF_INT, BIF_INT, BIF_INT, BIF_INT, BIF_INT,
  83. |                BIF_INT, BIF_REAL, BIF_REAL, BIF_REAL,
  84. |                BIF_REAL)
  85. |        :    Receive a SET_VIEW_SPECIFICATION entity from the parser
  86. |    int bif_defviewspec(BIF_INT, BIF_REAL, BIF_INT )
  87. |        :    Receive a DEFAULT_VIEW_SPECIFICATION entity from
  88. |    int bif_activeview(BIF_INT)
  89. |        :    Receive an ACTIVE_VIEW entity from the parser
  90. |
  91. \*--------------------------------------------------------------------*/
  92.  
  93. /*---------------------------------------------------------------------*\
  94. |    Include files 
  95. \*--------------------------------------------------------------------- */
  96. #include <stdio.h>
  97. #include "biftypes.h"
  98. #include "bifbuild.h"
  99. #include "new_ents.h"
  100. #include "bifparse.h"
  101. #include "db_tools.h"
  102. #include "doentity.h"
  103. #include "bifmacro.h"
  104. #include "globals.h"
  105. #include "ph_map.h"
  106. #include "macfunct.h"
  107.  
  108.  
  109. /*--------------------------------------------------------------------*\
  110. |Local #define
  111. \*--------------------------------------------------------------------*/
  112.  
  113. /*--------------------------------------------------------------------*\
  114. | External Symbols
  115. \*--------------------------------------------------------------------*/
  116. int noop_function();
  117.  
  118. /*--------------------------------------------------------------------*\
  119. | Local global variables
  120. \*--------------------------------------------------------------------*/
  121. /* Useful statics */
  122. /* Temporary entity storage */
  123. static BIF_All temp_ent;
  124. static BIF_All temp_ent2;
  125.  
  126. /*----------------------------------------------------------------------*\
  127. | Procedure    :    int bif_vieworient3(BIF_INT, BIF_REAL, BIF_REAL,
  128. |                        BIF_REAL)
  129. |------------------------------------------------------------------------|
  130. | Description    :    Receive a VIEW_ORIENTATION3 entity from the parser
  131. |
  132. |    matrix_id    ID of matrix table entry hold result
  133. |    vrp        View reference point
  134. |    vpn        View plane normal
  135. |    vup        View up vector
  136. |------------------------------------------------------------------------|
  137. | Return    :    Error Code
  138. \*----------------------------------------------------------------------*/
  139. int bif_vieworient3(matrix_id, vrp, vpn, vup)
  140. BIF_INT matrix_id;
  141. BIF_REAL  vrp[3], vpn[3], vup[3];
  142.  
  143. {
  144.     static int ent_size = sizeof(BIF_Matrix3);
  145.     BIF_All *ent;
  146.     float f_vrp[3], f_vpn[3], f_vup[3];
  147.  
  148. #ifdef TEST_PRINT
  149.     printf("VIEW_ORIENTATION3: id %d\n", matrix_id);
  150.     printf("view_ref  %f %f %f\n", vrp[0], vrp[1], vrp[2]);
  151.     printf("view_norm %f %f %f\n", vpn[0], vpn[1], vpn[2]);
  152.     printf("view_up   %f %f %f\n", vup[0], vup[1], vup[2]);
  153. #endif /* TEST_PRINT */
  154. #ifndef PRINT_ONLY
  155.     /* Check the matrix_id */
  156.     ERROR_MATRIX_ID(matrix_id,VIEW_ORIENTATION3);
  157.  
  158.     /* Fill the buffer */
  159.     temp_ent.matrix3.matrix_id   = matrix_id;
  160.     temp_ent.matrix3.concat_type = BIF_REPLACE;
  161.  
  162.     /* Compute the View orientation matrix */
  163.     Cpvec3f(vrp, f_vrp);
  164.     Cpvec3f(vpn, f_vpn);
  165.     Cpvec3f(vup, f_vup);
  166.     compute_vieworient_matrix(f_vrp, f_vpn, f_vup,
  167.         temp_ent.matrix3.matrix);
  168.  
  169. /* Allocate the entity */
  170.     ent = new_generic(&temp_ent, ent_size, MATRIX3, do_matrix3);
  171.  
  172. /* Error check for ent == NULL ( FATAL ) */
  173.     ENT_ERROR(ent);
  174.  
  175. /* Build or Execute */
  176.     Traverse(traverser_state, ent);
  177.  
  178. #ifdef USING_PHIGS
  179. /* Matrix Table Function Only */
  180. /* No PHIGS call here */
  181. #endif /* USING_PHIGS */
  182.  
  183. /* Release Non-Retained Entities */
  184.     Free_NRE(traverser_state, ent);
  185.  
  186. #endif /* PRINT_ONLY */
  187. } /* End procedure bif_vieworient3 */
  188.  
  189. /*----------------------------------------------------------------------*\
  190. | Procedure    :    int bif_viewmap3(BIF_INT)
  191. |------------------------------------------------------------------------|
  192. | Description    :    Begin / End receiving a VIEW_MAPPING3 entity from
  193. |            the parser.  Store the received data in the
  194. |            entity structure.
  195. |
  196. |    BIF_P_BEGIN     begin entity
  197. |    BIF_P_END    end entity
  198. |------------------------------------------------------------------------|
  199. | Return    :    Error Code
  200. \*----------------------------------------------------------------------*/
  201. int bif_viewmap3(begin_or_end)
  202. BIF_INT begin_or_end;
  203. {
  204.   static int ent_size = sizeof(BIF_Matrix3);
  205.   static float npcMinMax[6] = 
  206.     {
  207.       0., 1.,
  208.       0., 1.,
  209.       0., 1.
  210.       };
  211.  
  212.   BIF_All *ent;
  213.   int ierrind;
  214.   Pview_map3 mapping;
  215.     
  216. #ifdef TEST_PRINT
  217.   BEGEND(viewmap3);
  218. #endif /* TEST_PRINT */
  219. #ifndef PRINT_ONLY
  220.   switch ( begin_or_end )
  221.     {
  222.     case BIF_P_BEGIN :
  223.       /* Initialize entity */
  224.       temp_ent.viewmapping3.match_type = GROW;
  225.       temp_ent.viewmapping3.match_aspect = wk_info.aspect_ratio;
  226.       break;
  227.       
  228.     case BIF_P_END :
  229.       /* Adjust the UV window of for correct images */
  230.       adjust_window(temp_ent.viewmapping3.uvMinMax,
  231.             temp_ent.viewmapping3.match_type,
  232.             temp_ent.viewmapping3.match_aspect);
  233.       
  234.       /* Computed & store the result using the Matrix3 entity */
  235.       temp_ent2.matrix3.matrix_id =
  236.     temp_ent.viewmapping3.matrix_id;
  237.       temp_ent2.matrix3.concat_type = BIF_REPLACE;
  238. #ifdef USING_PHIGS
  239.         /*----------------------------------------------------*\
  240.         |    Call the evaluate view mapping matrix utility
  241.         |    The view mapping matrices are generated with an
  242.         |    assumed a unit cube npc mapping.
  243.         |    This matrix will be altered to map to the
  244.         |    correct area of the workstation window when 
  245.         |    the view specification call is made.
  246.         \*----------------------------------------------------*/
  247.       mapping.win.x_min = temp_ent.viewmapping3.uvMinMax[0];
  248.       mapping.win.x_max = temp_ent.viewmapping3.uvMinMax[1];
  249.       mapping.win.y_min = temp_ent.viewmapping3.uvMinMax[2];
  250.       mapping.win.y_max = temp_ent.viewmapping3.uvMinMax[3];
  251.       mapping.proj_vp.x_min = npcMinMax[0];
  252.       mapping.proj_vp.x_max = npcMinMax[1];
  253.       mapping.proj_vp.y_min = npcMinMax[2];
  254.       mapping.proj_vp.y_max = npcMinMax[3];
  255.       mapping.proj_vp.z_min = npcMinMax[4];
  256.       mapping.proj_vp.z_max = npcMinMax[5];
  257.       mapping.proj_type = (Pproj_type)temp_ent.viewmapping3.proj_type;
  258.       mapping.proj_ref_point.x = temp_ent.viewmapping3.proj_reference[0];
  259.       mapping.proj_ref_point.y = temp_ent.viewmapping3.proj_reference[1];
  260.       mapping.proj_ref_point.z = temp_ent.viewmapping3.proj_reference[2];
  261.       mapping.view_plane = 0.0;
  262.       mapping.back_plane = temp_ent.viewmapping3.back_plane;
  263.       mapping.front_plane = temp_ent.viewmapping3.front_plane;
  264.       peval_view_map_matrix3(&mapping,&ierrind,temp_ent2.matrix3.matrix);
  265. #else /* USING_PHIGS */
  266.         /*----------------------------------------------------*\
  267.         |    Native Graphics Routine to generate viewmapping
  268.         |    matrix here.
  269.         \*----------------------------------------------------*/
  270.       /* So it has a defined value for testing */
  271.       mx_identity( temp_ent2.matrix3.matrix );
  272. #endif /* USING_PHIGS */
  273.  
  274.       /* Allocate the entity */
  275.       ent = new_generic(&temp_ent2, ent_size, MATRIX3, do_matrix3);
  276.  
  277.       /* Error check for ent == NULL ( FATAL ) */
  278.       ENT_ERROR(ent);
  279.  
  280.       /* Build or Execute */
  281.       Traverse(traverser_state, ent);
  282.  
  283.       /* Release Non-Retained Entities */
  284.       Free_NRE(traverser_state, ent);
  285.  
  286.       break;
  287.     }
  288.  
  289. #endif /* PRINT_ONLY */
  290. } /* End procedure bif_viewmap3 */
  291.  
  292. /*----------------------------------------------------------------------*\
  293. | Procedure    :    int bif_viewmapbasic(BIF_INT, BIF_REAL, BIF_REAL,
  294. |                        BIF_REAL, BIF_REAL,
  295. |                        BIF_INT, *BIF_REAL,
  296. |                        BIF_REAL, BIF_REAL)
  297. |------------------------------------------------------------------------|
  298. | Description    :    Receive basic data for a VIEW_MAPPING3 entity
  299. |            from the parser.
  300. |
  301. |    matrix_id    ID of matrix table entry hold result
  302. |    x_min, x_max,
  303. |    y_min, y_max    UV window
  304. |    proj_type    Projection type: PERSPECTIVE | PARALLEL
  305. |    prp        Projection reference point
  306. |    front_plane    Front Clipping Location ( VRC )
  307. |    back_plane    Back Clipping Location ( VRC )
  308. |------------------------------------------------------------------------|
  309. | Return    :    Error Code
  310. \*----------------------------------------------------------------------*/
  311. int bif_viewmapbasic(matrix_id, x_min, x_max, y_min, y_max, proj_type, prp, 
  312.             front_plane, back_plane)
  313. BIF_INT matrix_id;
  314. BIF_REAL  x_min, x_max, y_min, y_max;
  315. BIF_INT proj_type;
  316. BIF_REAL  prp[3];
  317. BIF_REAL front_plane, back_plane;
  318. {
  319. #ifdef TEST_PRINT
  320.     printf("viewmapbasic: id %d\n", matrix_id);
  321.     printf("x_window  %f %f\n", x_min, x_max);
  322.     printf("y_window  %f %f\n", y_min, y_max);
  323.     printf("proj type %d\n", proj_type);
  324.     printf("proj ref  %f %f %f\n", prp[0], prp[1], prp[2]);
  325.     printf("clipping  %f %f\n", front_plane, back_plane);
  326. #endif /* TEST_PRINT */
  327. #ifndef PRINT_ONLY
  328. /* Check the matrix_id */
  329.     ERROR_MATRIX_ID(matrix_id,VIEW_MAPPING3);
  330.  
  331.     temp_ent.viewmapping3.matrix_id = matrix_id;
  332.     temp_ent.viewmapping3.uvMinMax[0] = x_min;
  333.     temp_ent.viewmapping3.uvMinMax[1] = x_max;
  334.     temp_ent.viewmapping3.uvMinMax[2] = y_min;
  335.     temp_ent.viewmapping3.uvMinMax[3] = y_max;
  336.     temp_ent.viewmapping3.proj_type = REMAP_PROJ(proj_type);
  337.     Cpvec3f(prp, temp_ent.viewmapping3.proj_reference);
  338.     temp_ent.viewmapping3.front_plane     = front_plane;
  339.     temp_ent.viewmapping3.back_plane      = back_plane;
  340. #endif /* PRINT_ONLY */
  341. } /* End procedure bif_viewmapbasic */
  342.  
  343. /*----------------------------------------------------------------------*\
  344. | Procedure    :    int bif_viewmapmatch(BIF_REAL, BIF_REAL,
  345. |                        BIF_REAL, BIF_REAL,
  346. |                        BIF_INT )
  347. |------------------------------------------------------------------------|
  348. | Description    :    Receive aspect ratio match data for VIEW_MAPPING3 
  349. |            entity from the parser.
  350. |
  351. |    vw_area_xmin, vw_area_xmax, vw_area_ymin, vw_area_ymax
  352. |            Dimensions of view-area to match
  353. |    match_type    ADJUST_X | ADJUST_Y | GROW | SHRINK
  354. |------------------------------------------------------------------------|
  355. | Return    :    Error Code
  356. \*----------------------------------------------------------------------*/
  357. int bif_viewmapmatch(vw_area_xmin, vw_area_xmax, vw_area_ymin,
  358.                 vw_area_ymax, match_type)
  359. BIF_REAL vw_area_xmin, vw_area_xmax;
  360. BIF_REAL vw_area_ymin, vw_area_ymax;
  361. BIF_INT match_type;
  362. {
  363.     float u_size, v_size;
  364. #ifdef TEST_PRINT
  365.     printf("viewmapmatch:");
  366.     printf("x_view_area  %f %f\n", vw_area_xmin, vw_area_xmax);
  367.     printf("y_view_area  %f %f\n", vw_area_ymin, vw_area_ymax);
  368.     printf("match type  %d\n", match_type);
  369. #endif /* TEST_PRINT */
  370. #ifndef PRINT_ONLY
  371.     temp_ent.viewmapping3.match_type    = match_type;
  372.     /* Aspect Ratio To Match */
  373.     u_size =  vw_area_xmax - vw_area_xmin;
  374.     v_size =  vw_area_ymax - vw_area_ymin;
  375.     v_size = (v_size != 0.) ? v_size : 1.0 ;
  376.     temp_ent.viewmapping3.match_aspect = (u_size / v_size) *
  377.         wk_info.aspect_ratio;
  378.  
  379. #endif /* PRINT_ONLY */
  380. } /* End procedure bif_viewmapmatch */
  381.  
  382. /*----------------------------------------------------------------------*\
  383. | Procedure    :    int bif_viewspec(BIF_INT, BIF_INT, BIF_INT, 
  384. |                 BIF_INT, BIF_INT,BIF_INT,
  385. |                BIF_REAL, BIF_REAL, BIF_REAL, BIF_REAL)
  386. |------------------------------------------------------------------------|
  387. | Description    :    Receive a SET_VIEW_SPECIFICATION entity from the parser
  388. |
  389. |    id_view_spec        View Table entry ID
  390. |    id_view_orientation    ID ofstored view orientation matrix
  391. |    id_view_mapping        ID of stored dview mapping  matrix
  392. |    xy_clip_flag        Enable/Disable XY Clipping
  393. |    front_clip_flag        Enable / Disable Front Clipping
  394. |    back_clip_flag        Enable / Disable Back Clipping
  395. |    vw_area_xmin vw_area_xmax    X extrema of view area
  396. |    vw_area_ymin vw_area_ymax    Y extrema of view area
  397. |------------------------------------------------------------------------|
  398. | Return    :    Error Code
  399. \*----------------------------------------------------------------------*/
  400. int bif_viewspec(id_view_spec, id_view_orientation, id_view_mapping, 
  401.          xy_clip_flag, front_clip_flag, back_clip_flag,
  402.         vw_area_xmin, vw_area_xmax, vw_area_ymin, vw_area_ymax)
  403. BIF_INT id_view_spec, id_view_orientation, id_view_mapping; 
  404. BIF_INT xy_clip_flag, front_clip_flag, back_clip_flag;
  405. BIF_REAL vw_area_xmin, vw_area_xmax, vw_area_ymin, vw_area_ymax;
  406.  
  407. {
  408.     static int ent_size = sizeof(BIF_Defineviewspecification);
  409.     BIF_Defineviewspecification *vent;
  410.     BIF_All *ent;
  411.     int ierr;
  412.         
  413. #ifdef TEST_PRINT
  414.     printf("SET_VIEW_SPECIFICATION : view id %d\n", id_view_spec);
  415.     printf("view and mapping matrix id %d %d\n",
  416.             id_view_orientation, id_view_mapping);
  417.     printf("clip flags  %d %d %d\n",
  418.             xy_clip_flag, front_clip_flag, back_clip_flag);
  419.     printf("x_view_area  %f %f\n", vw_area_xmin, vw_area_xmax);
  420.     printf("y_view_area  %f %f\n", vw_area_ymin, vw_area_ymax);
  421. #endif /* TEST_PRINT */
  422. #ifndef PRINT_ONLY
  423.     /* Check the matrix ID's */
  424.     ERROR_MATRIX_ID(id_view_orientation,DEFINE_VIEW_SPECIFICATION);
  425.     ERROR_MATRIX_ID(id_view_mapping,DEFINE_VIEW_SPECIFICATION);
  426.  
  427.     /* ************************************** */
  428.     /* Fill the View Specification Parameters */
  429.     /* ************************************** */
  430.     vent = &temp_ent.defineviewspecification;
  431.     vent->id_view_spec = id_view_spec;
  432.     vent->id_view_orientation = id_view_orientation;
  433.     vent->id_view_mapping     = id_view_mapping;
  434.  
  435.     /* Clipping Flags:    Check the Remaps against the ENUMs */
  436.     vent->xy_clip_flag        = REMAP_CLIP(xy_clip_flag);
  437.     vent->front_clip_flag     = REMAP_CLIP(front_clip_flag);
  438.     vent->back_clip_flag      = REMAP_CLIP(back_clip_flag);
  439.  
  440.     /* View area : Normalized BIF Display Coord. */
  441.     if ( wk_info.aspect_ratio != 1.0) {
  442.         if ( wk_info.aspect_ratio < 1.0) { /* Shrink X */
  443.         vent->ndcMinMax[0] = vw_area_xmin * wk_info.aspect_ratio;
  444.         vent->ndcMinMax[1] = vw_area_xmax * wk_info.aspect_ratio;
  445.         vent->ndcMinMax[2] = vw_area_ymin;
  446.         vent->ndcMinMax[3] = vw_area_ymax;
  447.         }
  448.         else { /* Shrink Y */
  449.         vent->ndcMinMax[0] = vw_area_xmin;
  450.         vent->ndcMinMax[1] = vw_area_xmax;
  451.         vent->ndcMinMax[2] = vw_area_ymin / wk_info.aspect_ratio;
  452.         vent->ndcMinMax[3] = vw_area_ymax / wk_info.aspect_ratio;
  453.         }
  454.     }
  455.     else {
  456.         vent->ndcMinMax[0] = vw_area_xmin;
  457.         vent->ndcMinMax[1] = vw_area_xmax;
  458.         vent->ndcMinMax[2] = vw_area_ymin;
  459.         vent->ndcMinMax[3] = vw_area_ymax;
  460.     }
  461.     vent->ndcMinMax[4] = 0.;
  462.     vent->ndcMinMax[5] = 1.;
  463.  
  464.     /* Can Use but NOT set view index 0 */
  465.     ierr = indexRange(DEFINE_VIEW_SPECIFICATION,
  466.               (BIF_INT)vent->id_view_spec ,
  467.               1, VIEW_TABLE_SIZE );
  468.  
  469.     if ( ierr ) /* Substitue default value */
  470.         vent->id_view_spec = 1;
  471.  
  472.     /* Allocate the entity */
  473.     ent = new_generic( &temp_ent, ent_size,
  474.               DEFINE_VIEW_SPECIFICATION,
  475.               do_defineviewspecification );
  476.  
  477.     /* Error check for ent == NULL ( FATAL ) */
  478.     ENT_ERROR(ent);
  479.  
  480.     /* Build or Execute */
  481.     Traverse(traverser_state, ent);
  482.  
  483. #ifdef USING_PHIGS
  484.     /* Called by the BIF execute traverser */
  485.     /* No PHIGS call here */
  486. #endif /* USING_PHIGS */
  487.  
  488.     /* Release Non-Retained Entities */
  489.     Free_NRE(traverser_state, ent);
  490.  
  491. #endif /* PRINT_ONLY */
  492. } /* End procedure bif_viewspec */
  493.  
  494. /*----------------------------------------------------------------------*\
  495. | Procedure    :    int bif_defviewspec(BIF_INT, BIF_REAL, BIF_INT )
  496. |------------------------------------------------------------------------|
  497. | Description    :    Receive a DEFAULT_VIEW_SPECIFICATION entity from
  498. |            the parser.
  499. |
  500. |    id_view_spec    View Table entry ID
  501. |    radius_of_view    Radius of visible sphere
  502. |    proj_type    Projection type: BIF_PERSPECTIVE | BIF_PARALLEL
  503. |------------------------------------------------------------------------|
  504. | Return    :    Error Code
  505. \*----------------------------------------------------------------------*/
  506. int bif_defviewspec(id_view_spec, radius_of_view, proj_type )
  507. BIF_INT id_view_spec;
  508. BIF_REAL radius_of_view;
  509. BIF_INT proj_type; 
  510.  
  511. {
  512.     static int ent_size = sizeof(BIF_Defaultviewspecification);
  513.     BIF_All *ent;
  514.     BIF_Defaultviewspecification *vent;
  515.     int ierr;
  516.  
  517.     ent_size += sizeof(Pview_rep3);
  518. #ifdef TEST_PRINT
  519.     printf("DEFAULT_VIEW_SPECIFICATION: viewid %d radius %f proj_type %d\n",
  520.             id_view_spec, radius_of_view, proj_type );
  521. #endif /* TEST_PRINT */
  522. #ifndef PRINT_ONLY
  523.     /* Allocate the entity */
  524.     /* Store the supplied data */
  525.     vent = &temp_ent.defaultviewspecification;
  526.     vent->id_view_spec = id_view_spec;
  527.     vent->radius_of_view= radius_of_view;
  528.     vent->proj_type= REMAP_PROJ(proj_type);
  529.  
  530. /* Compute the rest of the data */
  531.     compute_default_view((BIF_Defaultviewspecification *)&temp_ent,
  532.                  wk_info.aspect_ratio);
  533.  
  534.     /* Can Use but NOT set view index 0 */
  535.     ierr = indexRange(DEFAULT_VIEW_SPECIFICATION,
  536.               (BIF_INT)vent->id_view_spec ,
  537.               1, VIEW_TABLE_SIZE );
  538.  
  539.     if ( ierr ) /* Substitute default value */
  540.         vent->id_view_spec = 1;
  541.  
  542.     ent = new_generic( &temp_ent, ent_size,
  543.               DEFAULT_VIEW_SPECIFICATION,
  544.               do_defaultviewspecification );
  545.  
  546.     /* Error check for ent == NULL ( FATAL ) */
  547.     ENT_ERROR(ent);
  548.  
  549.     /* Build or Execute */
  550.     Traverse(traverser_state, ent);
  551.  
  552. #ifdef USING_PHIGS
  553.     /* Called by the BIF execute traverser */
  554.     /* No PHIGS call here */
  555. #endif /* USING_PHIGS */
  556.  
  557.     /* Release Non-Retained Entities */
  558.     Free_NRE(traverser_state, ent);
  559.  
  560. #endif /* PRINT_ONLY */
  561. } /* End procedure bif_defviewspec */
  562.  
  563. /*----------------------------------------------------------------------*\
  564. | Procedure    :    int bif_activeview(BIF_INT)
  565. |------------------------------------------------------------------------|
  566. | Description    :    Receive an ACTIVE_VIEW entity from the parser
  567. |
  568. |    id_view_spec    View Table entry ID to select
  569. |------------------------------------------------------------------------|
  570. | Return    :    Error Code
  571. \*----------------------------------------------------------------------*/
  572. int bif_activeview(id_view_spec)
  573. BIF_INT id_view_spec;
  574.  
  575. {
  576.     int ierr;
  577.     /* Build, Store/Execute the entity */
  578.     /* Check the view ie against the range of valid values */
  579.     /* Can Use but NOT set view index 0 */
  580.     ierr = indexRange(ACTIVE_VIEW,
  581.               (BIF_INT)id_view_spec , 0, VIEW_TABLE_SIZE );
  582.  
  583.     if ( ierr ) /* Substitute default value */
  584.         id_view_spec = 1;
  585.  
  586.     bif_index((int)id_view_spec, sizeof(BIF_Index),
  587.           ACTIVE_VIEW, do_activeview, pset_view_ind );
  588.  
  589. } /* End procedure bif_activeview */
  590.  
  591.  
  592.