1 |
– |
/* Copyright (c) 1997 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* 3D warping routines. |
6 |
|
*/ |
7 |
|
|
8 |
|
#include <stdio.h> |
9 |
+ |
#include <stdlib.h> |
10 |
|
#include <math.h> |
11 |
|
#include "fvect.h" |
12 |
|
#include "warp3d.h" |
23 |
|
|
24 |
|
#define AHUNK 24 /* number of points to allocate at a time */ |
25 |
|
|
28 |
– |
#ifndef malloc |
29 |
– |
extern char *malloc(), *realloc(); |
30 |
– |
#endif |
31 |
– |
extern void free(); |
26 |
|
|
33 |
– |
|
27 |
|
double |
28 |
|
wpdist2(p1, p2) /* compute square of distance between points */ |
29 |
|
register W3VEC p1, p2; |
130 |
|
{ |
131 |
|
W3VEC cv[8]; |
132 |
|
GNDX gi; |
133 |
< |
int rval = 0; |
133 |
> |
int rval = W3OK; |
134 |
|
register int i; |
135 |
|
/* get corner values */ |
136 |
|
for (i = 0; i < 8; i++) { |
284 |
|
W3VCPY(wp->ulim, pti); |
285 |
|
} else { |
286 |
|
if (wp->npts % AHUNK == 0) { /* allocate another hunk */ |
287 |
< |
na = (W3VEC *)realloc((char *)wp->ip, |
287 |
> |
na = (W3VEC *)realloc((void *)wp->ip, |
288 |
|
(wp->npts+AHUNK)*sizeof(W3VEC)); |
289 |
|
if (na == NULL) return(0); |
290 |
|
wp->ip = na; |
291 |
< |
na = (W3VEC *)realloc((char *)wp->ov, |
291 |
> |
na = (W3VEC *)realloc((void *)wp->ov, |
292 |
|
(wp->npts+AHUNK)*sizeof(W3VEC)); |
293 |
|
if (na == NULL) return(0); |
294 |
|
wp->ov = na; |
321 |
|
register WARP3D *wp; |
322 |
|
{ |
323 |
|
done3dgrid(&wp->grid); |
324 |
< |
free((char *)wp->ip); |
325 |
< |
free((char *)wp->ov); |
326 |
< |
free((char *)wp); |
324 |
> |
free((void *)wp->ip); |
325 |
> |
free((void *)wp->ov); |
326 |
> |
free((void *)wp); |
327 |
|
} |
328 |
|
|
329 |
|
|
330 |
< |
long |
330 |
> |
unsigned long |
331 |
|
gridhash(gp) /* hash a grid point index */ |
332 |
|
GNDX gp; |
333 |
|
{ |
360 |
|
} |
361 |
|
if (wp->grid.flags & W3EXACT) { |
362 |
|
wp->grid.gn[0] = wp->grid.gn[1] = wp->grid.gn[2] = 1; |
363 |
+ |
wp->grid.gstep[0] = gmax[0] - wp->grid.gmin[0]; |
364 |
+ |
wp->grid.gstep[1] = gmax[1] - wp->grid.gmin[1]; |
365 |
+ |
wp->grid.gstep[2] = gmax[2] - wp->grid.gmin[2]; |
366 |
|
return(W3OK); /* no interpolation, so no grid */ |
367 |
|
} |
368 |
|
/* create grid */ |