1 /* Copyright (C) 1992-1998 The Geometry Center
2 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3 *
4 * This file is part of Geomview.
5 *
6 * Geomview is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * Geomview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Geomview; see the file COPYING. If not, write
18 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19 * USA, or visit http://www.gnu.org.
20 */
21
22 #if HAVE_CONFIG_H
23 # include "config.h"
24 #endif
25
26 #if 0
27 static char copyright[] = "Copyright (C) 1992-1998 The Geometry Center\n\
28 Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips";
29 #endif
30
31 /* This file is for managing the output stack of group elements */
32
33 #include "discgrpP.h"
34
35 static int BlockSize, array_size;
36 static DiscGrpEl *mystack = NULL, *stackptr = NULL;
37 static int count = 0, debug = 0;
38
39 int
init_out_stack()40 init_out_stack()
41 {
42 array_size = 1;
43 BlockSize = 1024;
44 count = 0;
45 if ((mystack = OOGLNewN (DiscGrpEl, BlockSize )) == (DiscGrpEl *) NULL) return(0);
46 stackptr = mystack;
47 return(1);
48 }
49
50 int
enumpush(pp)51 enumpush(pp)
52 DiscGrpEl *pp;
53 {
54 if (stackptr >= &mystack[BlockSize*array_size]) {
55 if (debug)
56 fprintf(stderr,"allocating again: size is now %d\n",array_size*BlockSize);
57 array_size = array_size*2;
58 if ((mystack = OOGLRenewN(DiscGrpEl,mystack, array_size*BlockSize)) == (DiscGrpEl *) NULL) return (0);
59 stackptr = &mystack[count];
60 }
61 *stackptr = *pp;
62 TmCopy(pp->tform, stackptr->tform);
63 stackptr++;
64 count++;
65 return(1);
66 }
67
68 int
enumgetsize()69 enumgetsize()
70 {
71 return(count);
72 }
73
74 DiscGrpEl *
enumgetstack()75 enumgetstack()
76 {
77 DiscGrpEl *thisptr;
78 thisptr = OOGLNewN (DiscGrpEl, count );
79 if (thisptr == NULL) return ( (DiscGrpEl *) NULL);
80 memcpy(thisptr, mystack, sizeof(DiscGrpEl) * count);
81 OOGLFree(mystack);
82 return(thisptr);
83 }
84