1 |
< |
/* Copyright (c) 1994 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
25 |
|
char **xf_argend; /* end of transform argument list */ |
26 |
|
static char **xf_argbeg; /* beginning of transform argument list */ |
27 |
|
|
28 |
– |
static XF_SPEC *new_xf(); |
29 |
– |
static long comp_xfid(); |
30 |
– |
static int put_oname(); |
28 |
|
|
32 |
– |
|
29 |
|
int |
30 |
|
xf_handler(ac, av) /* handle xf entity */ |
31 |
|
int ac; |
42 |
|
if (spec->xarr != NULL) { /* check for iteration */ |
43 |
|
register struct xf_array *ap = spec->xarr; |
44 |
|
|
45 |
< |
(void)put_oname((struct xf_array *)NULL); |
45 |
> |
(void)xf_aname((struct xf_array *)NULL); |
46 |
|
n = ap->ndim; |
47 |
|
while (n--) { |
48 |
|
if (++ap->aarg[n].i < ap->aarg[n].n) |
54 |
|
if ((rv = mg_fgoto(&ap->spos)) != MG_OK) |
55 |
|
return(rv); |
56 |
|
sprintf(ap->aarg[n].arg, "%d", ap->aarg[n].i); |
57 |
< |
(void)put_oname(ap); |
58 |
< |
} else |
63 |
< |
free((MEM_PTR)ap); |
57 |
> |
(void)xf_aname(ap); |
58 |
> |
} |
59 |
|
} |
60 |
|
if (n < 0) { /* pop transform */ |
61 |
|
xf_context = spec->prev; |
62 |
< |
free((MEM_PTR)spec); |
62 |
> |
free_xf(spec); |
63 |
|
return(MG_OK); |
64 |
|
} |
65 |
|
} else { /* else allocate transform */ |
66 |
|
if ((spec = new_xf(ac-1, av+1)) == NULL) |
67 |
|
return(MG_EMEM); |
68 |
+ |
if (spec->xarr != NULL) |
69 |
+ |
(void)xf_aname(spec->xarr); |
70 |
|
spec->prev = xf_context; /* push onto stack */ |
71 |
|
xf_context = spec; |
72 |
|
} |
73 |
|
/* translate new specification */ |
74 |
|
n = xf_ac(spec); |
75 |
< |
if (spec->prev != NULL) /* incremental comp. is more eff. */ |
79 |
< |
n -= xf_ac(spec->prev); |
75 |
> |
n -= xf_ac(spec->prev); /* incremental comp. is more eff. */ |
76 |
|
if (xf(&spec->xf, n, xf_av(spec)) != n) |
77 |
|
return(MG_ETYPE); |
78 |
|
/* check for vertex reversal */ |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
< |
static XF_SPEC * |
92 |
> |
XF_SPEC * |
93 |
|
new_xf(ac, av) /* allocate new transform structure */ |
94 |
|
int ac; |
95 |
|
char **av; |
147 |
|
xf_av(spec)[i] = strcpy(cp, av[i]); |
148 |
|
cp += strlen(av[i]) + 1; |
149 |
|
} |
154 |
– |
if (spec->xarr != NULL) |
155 |
– |
(void)put_oname(spec->xarr); |
150 |
|
return(spec); |
151 |
|
} |
152 |
|
|
153 |
|
|
154 |
< |
static int |
155 |
< |
put_oname(ap) /* put out name for this instance */ |
154 |
> |
void |
155 |
> |
free_xf(spec) /* free a transform */ |
156 |
> |
register XF_SPEC *spec; |
157 |
> |
{ |
158 |
> |
if (spec->xarr != NULL) |
159 |
> |
free((MEM_PTR)spec->xarr); |
160 |
> |
free((MEM_PTR)spec); |
161 |
> |
} |
162 |
> |
|
163 |
> |
|
164 |
> |
int |
165 |
> |
xf_aname(ap) /* put out name for this instance */ |
166 |
|
register struct xf_array *ap; |
167 |
|
{ |
168 |
|
static char oname[10*XF_MAXDIM]; |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
< |
static long |
187 |
> |
long |
188 |
|
comp_xfid(xfm) /* compute unique ID from matrix */ |
189 |
|
register MAT4 xfm; |
190 |
|
{ |
216 |
|
} |
217 |
|
while ((spec = xf_context) != NULL) { |
218 |
|
xf_context = spec->prev; |
219 |
< |
if (spec->xarr != NULL) |
216 |
< |
free((MEM_PTR)spec->xarr); |
217 |
< |
free((MEM_PTR)spec); |
219 |
> |
free_xf(spec); |
220 |
|
} |
221 |
|
} |
222 |
|
|