diff options
author | Thomas White <taw@physics.org> | 2011-06-30 16:58:37 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:31 +0100 |
commit | 98c2349ffc47d4d7945e33b3a2279df2895a7b4d (patch) | |
tree | dffa7ebc8a834487f167878f37ebcd034559dec0 /src/render_hkl.c | |
parent | 3c0bb00394fa7a63e4a6df9fff947698bbb9b1a1 (diff) |
render_hkl: Go loads faster
Diffstat (limited to 'src/render_hkl.c')
-rw-r--r-- | src/render_hkl.c | 143 |
1 files changed, 75 insertions, 68 deletions
diff --git a/src/render_hkl.c b/src/render_hkl.c index cb47e680..58784e2f 100644 --- a/src/render_hkl.c +++ b/src/render_hkl.c @@ -94,96 +94,103 @@ static void draw_circles(signed int xh, signed int xk, signed int xl, double *max_val, double *max_u, double *max_v, double *max_res) { - signed int xi, yi; + Reflection *refl; + RefListIterator *iter; if ( dctx == NULL ) { *max_u = 0.0; *max_v = 0.0; *max_val = 0.0; *max_res = 0.0; *max_ux = 0; *max_uy = 0; } - /* Iterate over possible reflections in this zone */ - for ( xi=-INDMAX; xi<INDMAX; xi++ ) { - for ( yi=-INDMAX; yi<INDMAX; yi++ ) { + /* Iterate over all reflections */ + for ( refl = first_refl(list, &iter); + refl != NULL; + refl = next_refl(refl, iter) ) { double u, v, val, res; - signed int h, k, l; - signed int he, ke, le; - Reflection *refl; - int r; - - h = xi*xh + yi*yh; - k = xi*xk + yi*yk; - l = xi*xl + yi*yl; - - /* Got this reflection? */ - r = find_equiv_in_list(list, h, k, l, sym, &he, &ke, &le); - if ( !r ) continue; - refl = find_refl(list, he, ke, le); - - switch ( wght ) { - case WGHT_I : - val = get_intensity(refl); - break; - case WGHT_SQRTI : - val = get_intensity(refl); - val = (val>0.0) ? sqrt(val) : 0.0; - break; - case WGHT_COUNTS : - val = get_redundancy(refl); - val /= (float)num_equivs(h, k, l, sym); - break; - case WGHT_RAWCOUNTS : - val = get_redundancy(refl); - break; - default : - ERROR("Invalid weighting.\n"); - abort(); - } + signed int ha, ka, la; + int xi, yi; + int i; + + get_indices(refl, &ha, &ka, &la); + + for ( i=0; i<num_equivs(ha, ka, la, sym); i++ ) { + + signed int h, k, l; + + get_equiv(ha, ka, la, &h, &k, &l, sym, i); + + /* Is the reflection in the zone? */ + if ( h*zh + k*zk + l*zl != 0 ) continue; + + xi = h*xh + k*xk + l*xl; + yi = h*yh + k*yk + l*yl; + + switch ( wght) { + case WGHT_I : + val = get_intensity(refl); + break; + case WGHT_SQRTI : + val = get_intensity(refl); + val = (val>0.0) ? sqrt(val) : 0.0; + break; + case WGHT_COUNTS : + val = get_redundancy(refl); + val /= (float)num_equivs(h, k, l, sym); + break; + case WGHT_RAWCOUNTS : + val = get_redundancy(refl); + break; + default : + ERROR("Invalid weighting.\n"); + abort(); + } - /* Absolute location in image based on 2D basis */ - u = (double)xi*as*sin(theta); - v = (double)xi*as*cos(theta) + (double)yi*bs; + /* Absolute location in image based on 2D basis */ + u = (double)xi*as*sin(theta); + v = (double)xi*as*cos(theta) + (double)yi*bs; - if ( dctx != NULL ) { + if ( dctx != NULL ) { - double r, g, b; + double r, g, b; - cairo_arc(dctx, ((double)cx)+u*scale, - ((double)cy)+v*scale, - radius, 0, 2*M_PI); + cairo_arc(dctx, ((double)cx)+u*scale, + ((double)cy)+v*scale, + radius, 0, 2*M_PI); - render_scale(val, *max_val/boost, colscale, - &r, &g, &b); - cairo_set_source_rgb(dctx, r, g, b); - cairo_fill(dctx); + render_scale(val, *max_val/boost, colscale, + &r, &g, &b); + cairo_set_source_rgb(dctx, r, g, b); + cairo_fill(dctx); - } else { + } else { - /* Find max vectors in plane for scaling */ - if ( fabs(u) > fabs(*max_u) ) *max_u = fabs(u); - if ( fabs(v) > fabs(*max_v) ) *max_v = fabs(v); + /* Find max vectors in plane for scaling */ + if ( fabs(u) > fabs(*max_u) ) *max_u = fabs(u); + if ( fabs(v) > fabs(*max_v) ) *max_v = fabs(v); - /* Find max value for colour scale */ - if ( !isnan(val) && !isinf(val) - && (fabs(val) > fabs(*max_val)) ) - { - *max_val = fabs(val); - } + /* Find max value for colour scale */ + if ( !isnan(val) && !isinf(val) + && (fabs(val) > fabs(*max_val)) ) + { + *max_val = fabs(val); + } - /* Find max indices */ - if ( (yi==0) && (fabs(xi) > *max_ux) ) - *max_ux = fabs(xi); - if ( (xi==0) && (fabs(yi) > *max_uy) ) - *max_uy = fabs(yi); + /* Find max indices */ + if ( (yi==0) && (fabs(xi) > *max_ux) ) + *max_ux = fabs(xi); + if ( (xi==0) && (fabs(yi) > *max_uy) ) + *max_uy = fabs(yi); - /* Find max resolution */ - res = resolution(cell, h, k, l); - if ( res > *max_res ) *max_res = res; + /* Find max resolution */ + res = resolution(cell, h, k, l); + if ( res > *max_res ) *max_res = res; + + } } } - } } |