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

Comparing ray/src/cv/pabopto2xml.c (file contents):
Revision 2.17 by greg, Tue Oct 16 22:00:51 2012 UTC vs.
Revision 2.18 by greg, Wed Oct 17 19:01:47 2012 UTC

# Line 27 | Line 27 | static const char RCSid[] = "$Id$";
27   #define GRIDRES         200             /* grid resolution per side */
28   #endif
29  
30 + #define MAXSAMPORD      7               /* don't sample finer than this */
31 +
32   #define RSCA            2.7             /* radius scaling factor (empirical) */
33  
34                                          /* convert to/from coded radians */
# Line 95 | Line 97 | static MIGRATION       *mig_grid[GRIDRES][GRIDRES];
97  
98   char                    *progname;
99  
100 < #ifdef DEBUG                    /* percentage to cull (<0 to turn off) */
99 < int                     pctcull = -1;
100 < #else
100 >                                /* percentage to cull (<0 to turn off) */
101   int                     pctcull = 90;
102 #endif
102                                  /* number of processes to run */
103   int                     nprocs = 1;
104 +
105                                  /* number of children (-1 in child) */
106   int                     nchild = 0;
107  
# Line 269 | Line 269 | make_rbfrep(void)
269          insert_dsf(newnode);
270                                  /* adjust sampling resolution */
271          samp_order = log(2./R2ANG(minrad))/M_LN2 + .5;
272 +        if (samp_order > MAXSAMPORD)
273 +                samp_order = MAXSAMPORD;
274  
275          return(newnode);
276   }
# Line 576 | Line 578 | min_cost(double amt2move, const double *avail, const f
578   static double
579   migration_step(MIGRATION *mig, double *src_rem, double *dst_rem, const float *pmtx)
580   {
581 +        const double    maxamt = .1;
582          static double   *src_cost = NULL;
583          static int      n_alloc = 0;
581        const double    maxamt = .1; /* 2./(mtx_nrows(mig)*mtx_ncols(mig)); */
582        double          amt = 0;
584          struct {
585                  int     s, d;   /* source and destination */
586                  double  price;  /* price estimate per amount moved */
# Line 621 | Line 622 | migration_step(MIGRATION *mig, double *src_rem, double
622                                  src_rem[cur.s] : dst_rem[cur.d];
623              if (cur.amt > maxamt) cur.amt = maxamt;
624              dst_rem[cur.d] -= cur.amt;          /* add up differential costs */
625 <            for (i = mtx_nrows(mig); i--; ) {
626 <                if (i == cur.s) continue;
627 <                cost_others += min_cost(src_rem[i], dst_rem, price, mtx_ncols(mig))
625 >            for (i = mtx_nrows(mig); i--; )
626 >                if (i != cur.s)
627 >                        cost_others += min_cost(src_rem[i], dst_rem,
628 >                                                price, mtx_ncols(mig))
629                                          - src_cost[i];
628            }
630              dst_rem[cur.d] += cur.amt;          /* undo trial move */
631              cur.price += cost_others/cur.amt;   /* adjust effective price */
632              if (cur.price < best.price)         /* are we better than best? */
# Line 803 | Line 804 | create_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
804   #ifdef DEBUG
805          if (!nchild) fputs("\ndone.\n", stderr);
806   #endif
806
807        free(pmtx);                             /* free working arrays */
808        free(src_rem);
809        free(dst_rem);
807          for (i = from_rbf->nrbf; i--; ) {       /* normalize final matrix */
808              float       nf = rbf_volume(&from_rbf->rbfa[i]);
809              int         j;
# Line 816 | Line 813 | create_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
813                  newmig->mtx[mtx_ndx(newmig,i,j)] *= nf;
814          }
815          end_subprocess();                       /* exit here if subprocess */
816 +        free(pmtx);                             /* free working arrays */
817 +        free(src_rem);
818 +        free(dst_rem);
819          return(newmig);
820   }
821  
# Line 1102 | Line 1102 | build_mesh()
1102                  mesh_from_edge(create_migration(shrt_edj[0], shrt_edj[1]));
1103          else
1104                  mesh_from_edge(create_migration(shrt_edj[1], shrt_edj[0]));
1105                                                /* complete migrations */
1106        await_children(nchild);
1105                                                  /* draw edge list into grid */
1106          draw_edges();
1107 +                                                /* complete migrations */
1108 +        await_children(nchild);
1109   }
1110  
1111   /* Identify enclosing triangle for this position (flood fill raster check) */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines