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

Comparing ray/src/util/evalglare.c (file contents):
Revision 2.4 by greg, Thu Jul 28 16:46:10 2016 UTC vs.
Revision 2.7 by greg, Sat Aug 12 15:11:09 2017 UTC

# Line 1 | Line 1
1   #ifndef lint
2   static const char RCSid[] = "$Id$";
3   #endif
4 < /* EVALGLARE V1.29
4 > /* EVALGLARE V2.00
5   * Evalglare Software License, Version 2.0
6   *
7   * Copyright (c) 1995 - 2016 Fraunhofer ISE, EPFL.
# Line 310 | Line 310 | changed masking threshold to 0.05 cd/m2
310     */
311   /* evalglare.c, v1.30 2016/07/28 change zonal output: If just one zone is specified, only one zone shows up in the output (bug removal).
312     */
313 + /* evalglare.c, v1.31 2016/08/02  bug removal: default output did not calculate the amout of glare sources before and therefore no_glaresources was set to zero causing dgi,ugr being set to zero as well. Now renumbering of the glare sources and calculation of the amount of glare sources is done for all output versions.
314 +   */
315 + /* evalglare.c, v2.00 2016/11/15  add of a second fast calculation mode for annual calculations, activted by -2. Output: dgp,ugr
316 +   */
317 + /* evalglare.c, v2.01 2016/11/16  change of -2 option (now -2 dir_illum). External provision of the direct illuminance necessary, since the sun interpolation of daysim is causing problems in calculation of the background luminance.
318 +   */
319 + /* evalglare.c, v2.02 2017/02/28  change of warning message, when invalid exposure setting is found. Reason: tab removal is not in all cases the right measure - it depends which tool caused the invalid exposure entry   */
320 +
321 + /* evalglare.c, v2.03 2017/08/12  ad of -O option - disk replacement by providing luminance, not documented
322 + remove some minor memory leakages, clean up initialization by C. Reetz
323 +  */
324 +
325 +
326 +
327 + #ifndef EVALGLARE  
328   #define EVALGLARE
329 + #endif
330   #define PROGNAME "evalglare"
331 < #define VERSION "1.30 release 29.07.2016 by EPFL, J.Wienold"
331 > #define VERSION "2.03 release 12.08.2017 by EPFL, J.Wienold"
332   #define RELEASENAME PROGNAME " " VERSION
333  
334  
# Line 1199 | Line 1215 | float get_ugr(pict * p, double lum_backg, int igs, int
1215                  }
1216          }
1217          ugr = 8 * log10(0.25 / lum_backg * sum_glare);
1218 <
1218 >        if (sum_glare==0) {
1219 >        ugr=0.0;
1220 >        }
1221 >        if (lum_backg<=0) {
1222 >        ugr=-99.0;
1223 >        }
1224 >        
1225          return ugr;
1226  
1227   }
# Line 1374 | Line 1396 | int main(int argc, char **argv)
1396                  i_split, posindex_2, task_lum, checkfile, rval, i, i_max, x, y,x2,y2,x_zone,y_zone, i_z1, i_z2,
1397                  igs, actual_igs, lastpixelwas_gs, icol, xt, yt, change,checkpixels, before_igs, sgs, splithigh,uniform_gs,x_max, y_max,y_mid,
1398                  detail_out, posindex_picture, non_cos_lb, rx, ry, rmx,rmy,apply_disability,band_calc,band_color,masking,i_mask,no_glaresources,force;
1399 <        double  lum_total_max,age_corr_factor,age,dgp_ext,dgp,low_light_corr,omega_cos_contr, setvalue, lum_ideal, E_v_contr, sigma,om,delta_E,
1399 >        double  LUM_replace,lum_total_max,age_corr_factor,age,dgp_ext,dgp,low_light_corr,omega_cos_contr, setvalue, lum_ideal, E_v_contr, sigma,om,delta_E,
1400                  E_vl_ext, lum_max, new_lum_max, r_center, ugp, ugr_exp, dgi_mod,lum_a, pgsv,E_v_mask,pgsv_sat,angle_disk,dist,n_corner_px,zero_corner_px,
1401 <                search_pix, a1, a2, a3, a4, a5, c3, c1, c2, r_split, max_angle,r_actual,lum_actual,
1401 >                search_pix, a1, a2, a3, a4, a5, c3, c1, c2, r_split, max_angle,r_actual,lum_actual,dir_ill,
1402                  omegat, sang, E_v, E_v2, E_v_dir, avlum, act_lum, ang, angle_z1, angle_z2,per_95_band,per_75_band,pos,
1403                  l_max, lum_backg, lum_backg_cos, omega_sources, lum_sources,per_75_mask,per_95_mask,per_75_z1,per_95_z1,per_75_z2,per_95_z2,
1404                  lum, lum_source,teta,Lveil_cie,Lveil_cie_sum,disability_thresh,u_r,u_g,u_b,band_angle,band_avlum,
# Line 1388 | Line 1410 | int main(int argc, char **argv)
1410          float lum_task, lum_thres, dgi,  vcp, cgi, ugr, limit, dgr,
1411                  abs_max, Lveil;
1412          char maskfile[500],file_out[500], file_out2[500], version[500];
1413 <        char *cline;
1413 >        char *cline = NULL;
1414          VIEW userview = STDVIEW;
1415          int gotuserview = 0;
1416 <        struct muc_rvar* s_mask;
1416 >        struct muc_rvar* s_mask = NULL;
1417 >        struct muc_rvar* s_band = NULL;
1418 >        struct muc_rvar* s_z1 = NULL;
1419 >        struct muc_rvar* s_z2 = NULL;
1420 >        struct muc_rvar* s_noposweight = NULL;
1421 >        struct muc_rvar* s_posweight = NULL;
1422 >        struct muc_rvar* s_posweight2 = NULL;
1423 >
1424 >        // initializing variables ....
1425 >        Lveil = lum_backg_cos = 0;
1426 >        dgi = ugr = ugp = ugr_exp = dgi_mod = cgi = dgr = vcp = 0.0;
1427 >        lum_task = lum_thres = limit = 0;
1428          s_mask = muc_rvar_create();
1429 <        muc_rvar_set_dim(s_mask, 1);
1429 >        muc_rvar_set_dim(s_mask, 1);
1430          muc_rvar_clear(s_mask);
1398        struct muc_rvar* s_band;
1431          s_band = muc_rvar_create();
1432 <        muc_rvar_set_dim(s_band, 1);
1432 >        muc_rvar_set_dim(s_band, 1);
1433          muc_rvar_clear(s_band);
1402        struct muc_rvar* s_z1;
1434          s_z1 = muc_rvar_create();
1435 <        muc_rvar_set_dim(s_z1, 1);
1435 >        muc_rvar_set_dim(s_z1, 1);
1436          muc_rvar_clear(s_z1);
1437  
1407        struct muc_rvar* s_z2;
1438          s_z2 = muc_rvar_create();
1439 <        muc_rvar_set_dim(s_z2, 1);
1439 >        muc_rvar_set_dim(s_z2, 1);
1440          muc_rvar_clear(s_z2);
1441  
1412        struct muc_rvar* s_noposweight;
1442          s_noposweight = muc_rvar_create();
1443 <        muc_rvar_set_dim(s_noposweight, 1);
1443 >        muc_rvar_set_dim(s_noposweight, 1);
1444          muc_rvar_clear(s_noposweight);
1445  
1417        struct muc_rvar* s_posweight;
1446          s_posweight = muc_rvar_create();
1447 <        muc_rvar_set_dim(s_posweight, 1);
1447 >        muc_rvar_set_dim(s_posweight, 1);
1448          muc_rvar_clear(s_posweight);
1449  
1422        struct muc_rvar* s_posweight2;
1450          s_posweight2 = muc_rvar_create();
1451 <        muc_rvar_set_dim(s_posweight2, 1);
1451 >        muc_rvar_set_dim(s_posweight2, 1);
1452          muc_rvar_clear(s_posweight2);
1453  
1454          /*set required user view parameters to invalid values*/
1455 +        dir_ill=0.0;
1456          delta_E=0.0;
1457          no_glaresources=0;
1458          n_corner_px=0;
# Line 1527 | Line 1555 | int main(int argc, char **argv)
1555          omega_mask=0.0;
1556          i_mask=0;
1557          actual_igs=0;
1558 +        LUM_replace=0;
1559   /* command line for output picture*/
1560  
1561          cline = (char *) malloc(CLINEMAX+1);
# Line 1665 | Line 1694 | int main(int argc, char **argv)
1694                          strcpy(file_out2, argv[++i]);
1695   /*                      printf("max lum set to %f\n",new_lum_max);*/
1696                          break;
1697 +                case 'O':
1698 +                        img_corr = 1;
1699 +                        set_lum_max2 = 3;
1700 +                        x_disk = atoi(argv[++i]);
1701 +                        y_disk = atoi(argv[++i]);
1702 +                        angle_disk = atof(argv[++i]);
1703 +                        LUM_replace = atof(argv[++i]);
1704 +                        strcpy(file_out2, argv[++i]);
1705 + /*                      printf("max lum set to %f\n",new_lum_max);*/
1706 +                        break;
1707  
1708 +
1709                  case 'n':
1710                          non_cos_lb = 0;
1711                          break;
# Line 1737 | Line 1777 | int main(int argc, char **argv)
1777                  case '1':
1778                          output = 1;
1779                          break;
1780 +                case '2':
1781 +                        output = 2;
1782 +                        dir_ill = atof(argv[++i]);
1783 +                        break;
1784  
1785                  case 'v':
1786                          if (argv[i][2] == '\0') {
# Line 1768 | Line 1812 | int main(int argc, char **argv)
1812  
1813   /*fast calculation, if gendgp_profile is used: No Vertical illuminance calculation, only dgp is calculated*/
1814  
1815 < if (output == 1 && ext_vill == 1) {
1815 > if (output == 1 && ext_vill == 1 ) {
1816                         calcfast=1;
1817                         }
1818 +                      
1819 + if (output == 2 && ext_vill == 1 ) {
1820 +                       calcfast=2;
1821 +                       }
1822 +                      
1823   /*masking and zoning cannot be applied at the same time*/
1824  
1825   if (masking ==1 && zones >0) {
# Line 2059 | Line 2108 | if (cut_view==2) {
2108          lum_pos_mean= lum_pos_mean/sang;
2109          lum_pos2_mean= lum_pos2_mean/sang;
2110  
2111 <        if (set_lum_max2 >= 1 && E_v_contr > 0 && (E_vl_ext - E_v) > 0) {
2111 >        // XXX: sure this works? I'd suggest parenthesis.
2112 >        if ((set_lum_max2 >= 1 && E_v_contr > 0 && (E_vl_ext - E_v) > 0) || set_lum_max2==3) {
2113  
2114 +                if (set_lum_max2<3){
2115                  lum_ideal = (E_vl_ext - E_v + E_v_contr) / omega_cos_contr;
2116                  if (set_lum_max2 == 2 && lum_ideal >= 2e9) {
2117                  printf("warning! luminance of replacement pixels would be larger than 2e9 cd/m2. Value set to 2e9cd/m2!\n") ;
# Line 2071 | Line 2122 | if (cut_view==2) {
2122                  }
2123                  printf("change luminance values!! lum_ideal,setvalue,E_vl_ext,E_v,E_v_contr %f  %f %f %f %f\n",
2124                           lum_ideal, setvalue, E_vl_ext, E_v, E_v_contr);
2125 +                          }else{setvalue=LUM_replace;
2126 +                         }
2127  
2128              
2129                  for (x = 0; x < pict_get_xsize(p); x++)
# Line 2090 | Line 2143 | if (cut_view==2) {
2143                                                          pict_get_color(p, x, y)[BLU] =
2144                                                                  setvalue / 179.0;
2145  
2146 <                                                }else{ if(set_lum_max2 ==2 ) {
2146 >                                                }else{ if(set_lum_max2 >1 ) {
2147                                                          r_actual =acos(DOT(pict_get_cached_dir(p, x_disk, y_disk), pict_get_cached_dir(p, x, y))) * 2;
2148                                                          if (x_disk == x && y_disk==y ) r_actual=0.0;
2149  
# Line 2103 | Line 2156 | if (cut_view==2) {
2156                                                          pict_get_color(p, x, y)[BLU] =
2157                                                                  setvalue / 179.0;
2158                                                        
2159 <                                                       }
2107 <                                                                
2108 <                                                
2159 >                                                       }                                                
2160                                                  }
2161                                                  }
2162                                          }
# Line 2221 | Line 2272 | if (cut_view==1) {
2272   /*      pict_write(p,"firstscan.pic");   */
2273  
2274  
2275 < if (calcfast == 1 || search_pix <= 1.0) {
2275 >
2276 >
2277 > if (calcfast ==1 || search_pix <= 1.0 || calcfast == 2 ) {
2278     skip_second_scan=1;
2279     }
2280 +  
2281  
2282   /* second glare source scan: combine glare sources facing each other */
2283          change = 1;
# Line 2398 | Line 2452 | if (calcfast == 1 || search_pix <= 1.0) {
2452  
2453   /* calculation of direct vertical illuminance for CGI and for disability glare, coloring glare sources*/
2454  
2455 <        if (calcfast == 0) {
2455 >        if (calcfast == 0 || calcfast == 2) {
2456          for (x = 0; x < pict_get_xsize(p); x++)
2457                  for (y = 0; y < pict_get_ysize(p); y++) {
2458                          if (pict_get_hangle(p, x, y, p->view.vdir, p->view.vup, &ang)) {
# Line 2495 | Line 2549 | if (calcfast == 1 || search_pix <= 1.0) {
2549   /* print detailed output */
2550          
2551          
2498        if (detail_out == 1) {
2552  
2553   /* masking */
2554  
# Line 2540 | Line 2593 | if (calcfast == 1 || search_pix <= 1.0) {
2593   /* PSGV only why masking of window is applied! */
2594                   pgsv = get_pgsv(E_v, E_v_mask, omega_mask, lum_mask_av);
2595                   pgsv_sat =get_pgsv_sat(E_v);
2596 +
2597 +        if (detail_out == 1) {
2598 +
2599                  printf ("masking:no_pixels,omega,av_lum,median_lum,std_lum,perc_75,perc_95,lum_min,lum_max,pgsv,pgsv_sat: %i %f %f %f %f %f %f %f %f %f %f\n",i_mask,omega_mask,lum_mask_av,lum_mask_median[0],sqrt(lum_mask_std[0]),per_75_mask,per_95_mask,bbox[0],bbox[1],pgsv,pgsv_sat );
2600  
2601 +        }      
2602                  
2546                
2603          }
2604  
2605   /* zones */
# Line 2633 | Line 2689 | if (calcfast == 1 || search_pix <= 1.0) {
2689                  per_95_z1=lum_z1_median[0];
2690                  muc_rvar_get_median(s_z1,lum_z1_median);
2691                  muc_rvar_get_bounding_box(s_z1,bbox_z1);
2692 <
2692 >        if (detail_out == 1) {
2693 >
2694                  printf ("zoning:z1_omega,z1_av_lum,z1_median_lum,z1_std_lum,z1_perc_75,z1_perc_95,z1_lum_min,z1_lum_max: %f %f %f %f %f %f %f %f\n",omega_z1,lum_z1_av,lum_z1_median[0],sqrt(lum_z1_std[0]),per_75_z1,per_95_z1,bbox_z1[0],bbox_z1[1] );
2695  
2696                 if (zones == 2 ) {
2697  
2698                  printf ("zoning:z2_omega,z2_av_lum,z2_median_lum,z2_std_lum,z2_perc_75,z2_perc_95,z2_lum_min,z2_lum_max:  %f %f %f %f %f %f %f %f\n",omega_z2,lum_z2_av,lum_z2_median[0],sqrt(lum_z2_std[0]),per_75_z2,per_95_z2,bbox_z2[0],bbox_z2[1] );
2699 < }            
2699 > } }            
2700                  
2701          }
2702  
# Line 2653 | Line 2710 | if (calcfast == 1 || search_pix <= 1.0) {
2710                  no_glaresources=i;
2711  
2712   /* glare sources */
2713 +        if (detail_out == 1) {
2714 +
2715                  printf
2716                          ("%i No pixels x-pos y-pos L_s Omega_s Posindx L_b L_t E_vert Edir Max_Lum Sigma xdir ydir zdir Eglare_cie Lveil_cie teta glare_zone\n",
2717                           i);
# Line 2817 | Line 2876 | if (calcfast == 0) {
2876                                  if (E_vl_ext < 1000) {
2877                                  low_light_corr=1.0*exp(0.024*E_vl_ext-4)/(1+exp(0.024*E_vl_ext-4)); } else {low_light_corr=1.0 ;}
2878                                  dgp =low_light_corr*dgp;
2879 <                                dgp =age_corr_factor*dgp;
2880 <                printf("%f\n", dgp);
2879 >
2880 >                     if (calcfast == 2) {
2881 >                    
2882 >                         lum_backg_cos=(E_vl_ext-dir_ill)/3.1415927;
2883 >                         ugr = get_ugr(p, lum_backg_cos, igs, posindex_2);
2884 >                         printf("%f %f \n", dgp,ugr);
2885 >                     }else{      
2886 >                         printf("%f\n", dgp);
2887 >                }
2888          }
2889  
2890  
# Line 2855 | Line 2921 | has to be re-written from scratch....
2921          }
2922  
2923  
2924 <
2924 >        pict_free(p);
2925 >        pict_free(pm);
2926 >        muc_rvar_free(s_mask);
2927 >        muc_rvar_free(s_band);
2928 >        muc_rvar_free(s_z1);
2929 >        muc_rvar_free(s_z2);
2930 >        muc_rvar_free(s_noposweight);
2931 >        muc_rvar_free(s_posweight);
2932 >        muc_rvar_free(s_posweight2);
2933 >        free(cline);
2934          return EXIT_SUCCESS;
2860        exit(0);
2935  
2936    userr:
2937          fprintf(stderr,
2938                          "Usage: %s [-s][-d][-c picture][-t xpos ypos angle] [-T xpos ypos angle] [-b fact] [-r angle] [-y] [-Y lum] [-i Ev] [-I Ev ymax ymin] [-v] picfile\n",
2939                          progname);
2940 <        exit(1);
2940 >        pict_free(p);
2941 >        pict_free(pm);
2942 >        muc_rvar_free(s_mask);
2943 >        muc_rvar_free(s_band);
2944 >        muc_rvar_free(s_z1);
2945 >        muc_rvar_free(s_z2);
2946 >        muc_rvar_free(s_noposweight);
2947 >        muc_rvar_free(s_posweight);
2948 >        muc_rvar_free(s_posweight2);
2949 >        free(cline);
2950 >        return 1;
2951   }
2952  
2953  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines