ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/warp3d.c
(Generate patch)

Comparing ray/src/px/warp3d.c (file contents):
Revision 3.6 by greg, Wed Apr 23 00:52:34 2003 UTC vs.
Revision 3.7 by schorsch, Sun Mar 28 20:33:14 2004 UTC

# Line 8 | Line 8 | static const char      RCSid[] = "$Id$";
8   #include <stdio.h>
9   #include <stdlib.h>
10   #include <math.h>
11 +
12 + #include "rterror.h"
13 + #include "rtio.h"
14   #include "fvect.h"
15   #include "warp3d.h"
16  
# Line 24 | Line 27 | typedef struct {
27   #define AHUNK   24              /* number of points to allocate at a time */
28  
29  
30 + double wpdist2(W3VEC p1, W3VEC p2);
31 + static int gridpoint(GNDX ndx, W3VEC rem, W3VEC ipt, struct grid3d *gp);
32 + static int get3dgpt(W3VEC ov, GNDX ndx, WARP3D *wp);
33 + static int get3dgin(W3VEC ov, GNDX ndx, W3VEC rem, WARP3D *wp);
34 + static void l3interp(W3VEC vo, W3VEC *cl, W3VEC dv, int n);
35 + static int warp3dex(W3VEC ov, W3VEC pi, WARP3D *wp);
36 + //static unsigned long gridhash(void *gp);
37 + static lut_hashf_t gridhash;
38 + static int new3dgrid(WARP3D *wp);
39 + static void done3dgrid(struct grid3d *gp);
40 +
41 +
42   double
43 < wpdist2(p1, p2)                 /* compute square of distance between points */
44 < register W3VEC  p1, p2;
43 > wpdist2(                        /* compute square of distance between points */
44 >        register W3VEC  p1,
45 >        register W3VEC  p2
46 > )
47   {
48          double  d, d2;
49  
# Line 38 | Line 55 | register W3VEC p1, p2;
55  
56  
57   int
58 < warp3d(po, pi, wp)              /* warp 3D point according to the given map */
59 < W3VEC   po, pi;
60 < register WARP3D *wp;
58 > warp3d(         /* warp 3D point according to the given map */
59 >        W3VEC   po,
60 >        W3VEC   pi,
61 >        register WARP3D *wp
62 > )
63   {
64          int     rval = W3OK;
65          GNDX    gi;
# Line 62 | Line 81 | register WARP3D        *wp;
81   }
82  
83  
84 < int
85 < gridpoint(ndx, rem, ipt, gp)    /* compute grid position for ipt */
86 < GNDX    ndx;
87 < W3VEC   rem, ipt;
88 < register struct grid3d  *gp;
84 > static int
85 > gridpoint(      /* compute grid position for ipt */
86 >        GNDX    ndx,
87 >        W3VEC   rem,
88 >        W3VEC   ipt,
89 >        register struct grid3d  *gp
90 > )
91   {
92          int     rval = W3OK;
93          register int    i;
# Line 87 | Line 108 | register struct grid3d *gp;
108   }
109  
110  
111 < int
112 < get3dgpt(ov, ndx, wp)           /* get value for voxel */
113 < W3VEC   ov;
114 < GNDX    ndx;
115 < register WARP3D *wp;
111 > static int
112 > get3dgpt(               /* get value for voxel */
113 >        W3VEC   ov,
114 >        GNDX    ndx,
115 >        register WARP3D *wp
116 > )
117   {
118          W3VEC   gpt;
119          register LUENT  *le;
# Line 122 | Line 144 | register WARP3D        *wp;
144   }
145  
146  
147 < int
148 < get3dgin(ov, ndx, rem, wp)      /* interpolate from warp grid */
149 < W3VEC   ov, rem;
150 < GNDX    ndx;
151 < WARP3D  *wp;
147 > static int
148 > get3dgin(       /* interpolate from warp grid */
149 >        W3VEC   ov,
150 >        GNDX    ndx,
151 >        W3VEC   rem,
152 >        WARP3D  *wp
153 > )
154   {
155          W3VEC   cv[8];
156          GNDX    gi;
# Line 146 | Line 170 | WARP3D *wp;
170   }
171  
172  
173 < l3interp(vo, cl, dv, n)         /* trilinear interpolation (recursive) */
174 < W3VEC   vo, *cl, dv;
175 < int     n;
173 > static void
174 > l3interp(               /* trilinear interpolation (recursive) */
175 >        W3VEC   vo,
176 >        W3VEC   *cl,
177 >        W3VEC   dv,
178 >        int     n
179 > )
180   {
181          W3VEC   v0, v1;
182          register int    i;
# Line 165 | Line 193 | int    n;
193   }
194  
195  
196 < int
197 < warp3dex(ov, pi, wp)            /* compute warp using 1/r^2 weighted avg. */
198 < W3VEC   ov, pi;
199 < register WARP3D *wp;
196 > static int
197 > warp3dex(               /* compute warp using 1/r^2 weighted avg. */
198 >        W3VEC   ov,
199 >        W3VEC   pi,
200 >        register WARP3D *wp
201 > )
202   {
203          double  d2, w, wsum;
204          W3VEC   vt;
# Line 195 | Line 225 | register WARP3D        *wp;
225  
226  
227   WARP3D *
228 < new3dw(flgs)                    /* allocate and initialize WARP3D struct */
229 < int     flgs;
228 > new3dw(                 /* allocate and initialize WARP3D struct */
229 >        int     flgs
230 > )
231   {
232          register WARP3D  *wp;
233  
# Line 217 | Line 248 | int    flgs;
248  
249  
250   WARP3D *
251 < load3dw(fn, wp)                 /* load 3D warp from file */
252 < char    *fn;
253 < WARP3D  *wp;
251 > load3dw(                        /* load 3D warp from file */
252 >        char    *fn,
253 >        WARP3D  *wp
254 > )
255   {
256          FILE    *fp;
257          W3VEC   inp, outp;
# Line 247 | Line 279 | cleanup:
279   }
280  
281  
282 < int
283 < set3dwfl(wp, flgs)              /* reset warp flags */
284 < register WARP3D *wp;
285 < int     flgs;
282 > extern int
283 > set3dwfl(               /* reset warp flags */
284 >        register WARP3D *wp,
285 >        int     flgs
286 > )
287   {
288          if (flgs == wp->grid.flags)
289                  return(0);
# Line 265 | Line 298 | int    flgs;
298  
299  
300   int
301 < add3dpt(wp, pti, pto)           /* add 3D point pair to warp structure */
302 < register WARP3D *wp;
303 < W3VEC   pti, pto;
301 > add3dpt(                /* add 3D point pair to warp structure */
302 >        register WARP3D *wp,
303 >        W3VEC   pti,
304 >        W3VEC   pto
305 > )
306   {
307          double  d2;
308          register W3VEC  *na;
# Line 317 | Line 352 | W3VEC  pti, pto;
352   }
353  
354  
355 < free3dw(wp)                     /* free WARP3D data */
356 < register WARP3D *wp;
355 > extern void
356 > free3dw(                        /* free WARP3D data */
357 >        register WARP3D *wp
358 > )
359   {
360          done3dgrid(&wp->grid);
361          free((void *)wp->ip);
# Line 327 | Line 364 | register WARP3D        *wp;
364   }
365  
366  
367 < unsigned long
368 < gridhash(gp)                    /* hash a grid point index */
369 < GNDX    gp;
367 > static unsigned long
368 > gridhash(                       /* hash a grid point index */
369 >        //GNDX  gp
370 >        void    *gp
371 > )
372   {
373 <        return(((unsigned long)gp[0]<<GNBITS | gp[1])<<GNBITS | gp[2]);
373 >        //return(((unsigned long)gp[0]<<GNBITS | gp[1])<<GNBITS | gp[2]);
374 >        return(((unsigned long)((unsigned char*)gp)[0]<<GNBITS | ((unsigned char*)gp)[1])<<GNBITS | ((unsigned char*)gp)[2]);
375   }
376  
377  
378 < int
379 < new3dgrid(wp)                   /* initialize interpolating grid for warp */
380 < register WARP3D *wp;
378 > static int
379 > new3dgrid(                      /* initialize interpolating grid for warp */
380 >        register WARP3D *wp
381 > )
382   {
383          W3VEC   gmax;
384          double  gridstep, d;
# Line 383 | Line 424 | register WARP3D        *wp;
424   }
425  
426  
427 < done3dgrid(gp)                  /* free interpolating grid for warp */
428 < register struct grid3d  *gp;
427 > static void
428 > done3dgrid(                     /* free interpolating grid for warp */
429 >        register struct grid3d  *gp
430 > )
431   {
432          if (gp->gn[0] == 0)
433                  return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines