| 5 |
|
* 3D warping routines. |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
– |
#include <stdio.h> |
| 8 |
|
#include <stdlib.h> |
| 9 |
|
#include <math.h> |
| 10 |
|
|
| 39 |
|
|
| 40 |
|
double |
| 41 |
|
wpdist2( /* compute square of distance between points */ |
| 42 |
< |
register W3VEC p1, |
| 43 |
< |
register W3VEC p2 |
| 42 |
> |
W3VEC p1, |
| 43 |
> |
W3VEC p2 |
| 44 |
|
) |
| 45 |
|
{ |
| 46 |
|
double d, d2; |
| 56 |
|
warp3d( /* warp 3D point according to the given map */ |
| 57 |
|
W3VEC po, |
| 58 |
|
W3VEC pi, |
| 59 |
< |
register WARP3D *wp |
| 59 |
> |
WARP3D *wp |
| 60 |
|
) |
| 61 |
|
{ |
| 62 |
|
int rval = W3OK; |
| 84 |
|
GNDX ndx, |
| 85 |
|
W3VEC rem, |
| 86 |
|
W3VEC ipt, |
| 87 |
< |
register struct grid3d *gp |
| 87 |
> |
struct grid3d *gp |
| 88 |
|
) |
| 89 |
|
{ |
| 90 |
|
int rval = W3OK; |
| 91 |
< |
register int i; |
| 91 |
> |
int i; |
| 92 |
|
|
| 93 |
|
for (i = 0; i < 3; i++) { |
| 94 |
|
rem[i] = (ipt[i] - gp->gmin[i])/gp->gstep[i]; |
| 110 |
|
get3dgpt( /* get value for voxel */ |
| 111 |
|
W3VEC ov, |
| 112 |
|
GNDX ndx, |
| 113 |
< |
register WARP3D *wp |
| 113 |
> |
WARP3D *wp |
| 114 |
|
) |
| 115 |
|
{ |
| 116 |
|
W3VEC gpt; |
| 117 |
< |
register LUENT *le; |
| 117 |
> |
LUENT *le; |
| 118 |
|
KEYDP *kd; |
| 119 |
|
int rval = W3OK; |
| 120 |
< |
register int i; |
| 120 |
> |
int i; |
| 121 |
|
|
| 122 |
|
le = lu_find(&wp->grid.gtab, ndx); |
| 123 |
|
if (le == NULL) |
| 153 |
|
W3VEC cv[8]; |
| 154 |
|
GNDX gi; |
| 155 |
|
int rval = W3OK; |
| 156 |
< |
register int i; |
| 156 |
> |
int i; |
| 157 |
|
/* get corner values */ |
| 158 |
|
for (i = 0; i < 8; i++) { |
| 159 |
|
gi[0] = ndx[0] + (i & 1); |
| 177 |
|
) |
| 178 |
|
{ |
| 179 |
|
W3VEC v0, v1; |
| 180 |
< |
register int i; |
| 180 |
> |
int i; |
| 181 |
|
|
| 182 |
|
if (--n) { |
| 183 |
|
l3interp(v0, cl, dv, n); |
| 195 |
|
warp3dex( /* compute warp using 1/r^2 weighted avg. */ |
| 196 |
|
W3VEC ov, |
| 197 |
|
W3VEC pi, |
| 198 |
< |
register WARP3D *wp |
| 198 |
> |
WARP3D *wp |
| 199 |
|
) |
| 200 |
|
{ |
| 201 |
|
double d2, w, wsum; |
| 202 |
|
W3VEC vt; |
| 203 |
< |
register int i; |
| 203 |
> |
int i; |
| 204 |
|
|
| 205 |
|
vt[0] = vt[1] = vt[2] = 0.; |
| 206 |
|
wsum = 0.; |
| 227 |
|
int flgs |
| 228 |
|
) |
| 229 |
|
{ |
| 230 |
< |
register WARP3D *wp; |
| 230 |
> |
WARP3D *wp; |
| 231 |
|
|
| 232 |
|
if ((flgs & (W3EXACT|W3FAST)) == (W3EXACT|W3FAST)) { |
| 233 |
|
eputs("new3dw: only one of W3EXACT or W3FAST\n"); |
| 279 |
|
|
| 280 |
|
extern int |
| 281 |
|
set3dwfl( /* reset warp flags */ |
| 282 |
< |
register WARP3D *wp, |
| 282 |
> |
WARP3D *wp, |
| 283 |
|
int flgs |
| 284 |
|
) |
| 285 |
|
{ |
| 297 |
|
|
| 298 |
|
int |
| 299 |
|
add3dpt( /* add 3D point pair to warp structure */ |
| 300 |
< |
register WARP3D *wp, |
| 300 |
> |
WARP3D *wp, |
| 301 |
|
W3VEC pti, |
| 302 |
|
W3VEC pto |
| 303 |
|
) |
| 304 |
|
{ |
| 305 |
|
double d2; |
| 306 |
< |
register W3VEC *na; |
| 307 |
< |
register int i; |
| 306 |
> |
W3VEC *na; |
| 307 |
> |
int i; |
| 308 |
|
|
| 309 |
|
if (wp->npts == 0) { /* initialize */ |
| 310 |
|
wp->ip = (W3VEC *)malloc(AHUNK*sizeof(W3VEC)); |
| 352 |
|
|
| 353 |
|
extern void |
| 354 |
|
free3dw( /* free WARP3D data */ |
| 355 |
< |
register WARP3D *wp |
| 355 |
> |
WARP3D *wp |
| 356 |
|
) |
| 357 |
|
{ |
| 358 |
|
done3dgrid(&wp->grid); |
| 359 |
< |
free((void *)wp->ip); |
| 360 |
< |
free((void *)wp->ov); |
| 361 |
< |
free((void *)wp); |
| 359 |
> |
free(wp->ip); |
| 360 |
> |
free(wp->ov); |
| 361 |
> |
free(wp); |
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
|
| 373 |
|
|
| 374 |
|
static int |
| 375 |
|
new3dgrid( /* initialize interpolating grid for warp */ |
| 376 |
< |
register WARP3D *wp |
| 376 |
> |
WARP3D *wp |
| 377 |
|
) |
| 378 |
|
{ |
| 379 |
|
W3VEC gmax; |
| 380 |
|
double gridstep, d; |
| 381 |
|
int n; |
| 382 |
< |
register int i; |
| 382 |
> |
int i; |
| 383 |
|
/* free old grid (if any) */ |
| 384 |
|
done3dgrid(&wp->grid); |
| 385 |
|
/* check parameters */ |
| 422 |
|
|
| 423 |
|
static void |
| 424 |
|
done3dgrid( /* free interpolating grid for warp */ |
| 425 |
< |
register struct grid3d *gp |
| 425 |
> |
struct grid3d *gp |
| 426 |
|
) |
| 427 |
|
{ |
| 428 |
|
if (gp->gn[0] == 0) |