home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / gprim / bbox / bboxcreate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-25  |  2.1 KB  |  76 lines

  1. /* Copyright (c) 1992 The Geometry Center; University of Minnesota
  2.    1300 South Second Street;  Minneapolis, MN  55454, USA;
  3.    
  4. This file is part of geomview/OOGL. geomview/OOGL is free software;
  5. you can redistribute it and/or modify it only under the terms given in
  6. the file COPYING, which you should have received along with this file.
  7. This and other related software may be obtained via anonymous ftp from
  8. geom.umn.edu; email: software@geom.umn.edu. */
  9. static char *copyright = "Copyright (C) 1992 The Geometry Center";
  10.  
  11. /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips */
  12.  
  13. #include "bboxP.h"
  14. #include "appearance.h"
  15.  
  16. /*--------------------------------------------------------------------------
  17.  * Function:    BBoxCreate
  18.  * Description: creates or edits a bounding box
  19.  * Args:    BBox *exist: existing bbox to be edited, if using editing.
  20.  *                NULL otherwise.
  21.  *        GeomClass *classp: 
  22.  *        a_list: List of option type - option pairs.  Option types
  23.  *            are specified by integers, with 0 signifying end of
  24.  *            list.
  25.  * Returns:    Pointer to BBox created or edited.
  26.  */
  27.  
  28. BBox *
  29. BBoxCreate (exist, classp, a_list)
  30. BBox *exist;
  31. GeomClass *classp;
  32. va_list a_list;
  33. {
  34.     register BBox *bbox;
  35.     int attr, copy = 1, fourd = 0;
  36.  
  37.     if (exist == NULL) {
  38.     bbox = OOGLNewE(BBox, "BBoxCreate BBox");
  39.     bbox->flag = BBOX_P;
  40.         GGeomInit (bbox, classp, BBOXMAGIC, NULL);
  41.     } else {
  42.     /* Check that exist is in fact a BBox. */
  43.     bbox = exist;
  44.     }
  45.  
  46.     while (attr = va_arg (a_list, int)) switch (attr) {
  47.     case CR_FLAG:
  48.         bbox->flag = va_arg (a_list, int );
  49.         break;
  50.     case CR_MIN:
  51.         Pt3ToPt4(va_arg(a_list, Point3 *), &bbox->min, 1);
  52.         break;
  53.     case CR_MAX:
  54.         Pt3ToPt4(va_arg(a_list, Point3 *), &bbox->max, 1);
  55.         break;
  56.     case CR_4MIN:
  57.         bbox->min = *va_arg(a_list, HPoint3 *);
  58.         bbox->geomflags |= VERT_4D;
  59.         break;
  60.     case CR_4MAX:
  61.         bbox->max = *va_arg(a_list, HPoint3 *);
  62.         bbox->geomflags |= VERT_4D;
  63.         break;
  64.     default:
  65.         if (GeomDecorate (bbox, ©, attr, &a_list)) {
  66.         OOGLError (0, "BBoxCreate: Undefined attribute: %d", attr);
  67.         OOGLFree (bbox);
  68.         return NULL;
  69.         }
  70.     }
  71.  
  72.     if (exist != NULL) return exist;
  73.     
  74.     return (bbox);
  75. }
  76.