diff options
-rw-r--r-- | src/basis.c | 30 | ||||
-rw-r--r-- | src/cache.c | 18 | ||||
-rw-r--r-- | src/cache.h | 4 | ||||
-rw-r--r-- | src/control.h | 4 | ||||
-rw-r--r-- | src/displaywindow.c | 14 | ||||
-rw-r--r-- | src/ipr.c | 8 | ||||
-rw-r--r-- | src/main.c | 10 | ||||
-rw-r--r-- | src/mapping.c | 14 | ||||
-rw-r--r-- | src/mapping.h | 2 | ||||
-rw-r--r-- | src/qdrp.c | 2 | ||||
-rw-r--r-- | src/reflections.c | 100 | ||||
-rw-r--r-- | src/reflections.h | 24 | ||||
-rw-r--r-- | src/reproject.c | 18 | ||||
-rw-r--r-- | src/reproject.h | 2 |
14 files changed, 125 insertions, 125 deletions
diff --git a/src/basis.c b/src/basis.c index a7ff978..939dc93 100644 --- a/src/basis.c +++ b/src/basis.c @@ -21,12 +21,12 @@ #include "reflections.h" #include "basis.h" -static double basis_efom(ReflectionContext *rctx, Basis *basis) { +static double basis_efom(ReflectionList *reflectionlist, Basis *basis) { int n_indexed, n_counted; Reflection *cur; - cur = rctx->reflections; + cur = reflectionlist->reflections; n_indexed = 0; n_counted = 0; while ( cur ) { @@ -80,14 +80,14 @@ static int basis_lfom(ControlContext *ctx, double vx, double vy, double vz) { lfom = 0; tol = modulus(vx, vy, vz)/10.0; - tcentre = ctx->reflectionctx->reflections; + tcentre = ctx->reflectionlist->reflections; do { for ( j=-20; j<=20; j++ ) { Reflection *check; - check = reflection_find_nearest(ctx->reflectionctx, tcentre->x+vx*j, tcentre->y+vy*j, tcentre->z+vz*j); + check = reflection_find_nearest(ctx->reflectionlist, tcentre->x+vx*j, tcentre->y+vy*j, tcentre->z+vz*j); if ( check && (distance3d(check->x, check->y, check->z, tcentre->x+vx*j, tcentre->y+vy*j, tcentre->z+vz*j) < tol) ) { lfom++; } @@ -102,7 +102,7 @@ static int basis_lfom(ControlContext *ctx, double vx, double vy, double vz) { } -static ReflectionContext *basis_find_seeds(ControlContext *ctx) { +static ReflectionList *basis_find_seeds(ControlContext *ctx) { double tilt_min; double tilt_max; @@ -113,7 +113,7 @@ static ReflectionContext *basis_find_seeds(ControlContext *ctx) { double x, y, z; Reflection *centre; int i; - ReflectionContext *seeds; + ReflectionList *seeds; seeds = reflection_init(); @@ -134,17 +134,17 @@ static ReflectionContext *basis_find_seeds(ControlContext *ctx) { z = z_temp; /* Find the point in the middle of the "wedge" */ - scale = reflection_largest_g(ctx->reflectionctx)/4; + scale = reflection_largest_g(ctx->reflectionlist)/4; x *= scale; y *= scale; z *= scale; - reflection_add(ctx->reflectionctx, x, y, z, 1.0, REFLECTION_VECTOR_MARKER_2); + reflection_add(ctx->reflectionlist, x, y, z, 1.0, REFLECTION_VECTOR_MARKER_2); /* Find an "origin" reflection */ - centre = reflection_find_nearest(ctx->reflectionctx, x, y, z); + centre = reflection_find_nearest(ctx->reflectionlist, x, y, z); if ( !centre ) return NULL; centre->found = 1; - reflection_add(ctx->reflectionctx, centre->x, centre->y, centre->z, 1.0, REFLECTION_GENERATED); + reflection_add(ctx->reflectionlist, centre->x, centre->y, centre->z, 1.0, REFLECTION_GENERATED); for ( i=1; i<=10; i++ ) { @@ -160,7 +160,7 @@ static ReflectionContext *basis_find_seeds(ControlContext *ctx) { accept = 1; /* Find a "candidate vector" reflection */ - vector = reflection_find_nearest_longer(ctx->reflectionctx, centre->x, centre->y, centre->z, 1e9); /* 0.5 A^-1 */ + vector = reflection_find_nearest_longer(ctx->reflectionlist, centre->x, centre->y, centre->z, 1e9); /* 0.5 A^-1 */ if ( !vector ) { printf("BS: Couldn't find enough seeds\n"); return NULL; @@ -173,7 +173,7 @@ static ReflectionContext *basis_find_seeds(ControlContext *ctx) { vz = vector->z - centre->z; /* Proximity test */ - check = reflection_find_nearest_type(ctx->reflectionctx, vx, vy, vz, REFLECTION_NORMAL); + check = reflection_find_nearest_type(ctx->reflectionlist, vx, vy, vz, REFLECTION_NORMAL); if ( check ) { if ( distance3d(vx, vy, vz, check->x, check->y, check->z) < 1e9 ) { /* Too close to another seed */ @@ -193,7 +193,7 @@ static ReflectionContext *basis_find_seeds(ControlContext *ctx) { } while ( !accept ); reflection_add(seeds, vx, vy, vz, 1.0, REFLECTION_NORMAL); - reflection_add(ctx->reflectionctx, vx, vy, vz, 1.0, REFLECTION_MARKER); + reflection_add(ctx->reflectionlist, vx, vy, vz, 1.0, REFLECTION_MARKER); } @@ -204,7 +204,7 @@ static ReflectionContext *basis_find_seeds(ControlContext *ctx) { Basis *basis_find(ControlContext *ctx) { Basis *basis; - ReflectionContext *seeds; + ReflectionList *seeds; Reflection *ref; int i; @@ -244,7 +244,7 @@ Basis *basis_find(ControlContext *ctx) { } - printf("BS: eFOM = %7.3f %%\n", basis_efom(ctx->reflectionctx, basis)*100); + printf("BS: eFOM = %7.3f %%\n", basis_efom(ctx->reflectionlist, basis)*100); return basis; diff --git a/src/cache.c b/src/cache.c index f3b85af..eb164aa 100644 --- a/src/cache.c +++ b/src/cache.c @@ -28,17 +28,17 @@ typedef struct struct_cacheheader { double scale; } CacheHeader; -ReflectionContext *cache_load(const char *filename) { +ReflectionList *cache_load(const char *filename) { FILE *f; CacheHeader ch; - ReflectionContext *rctx; + ReflectionList *reflectionlist; size_t cachedreflection_size; int i; cachedreflection_size = sizeof(Reflection) - sizeof(Reflection *); - rctx = reflection_init(); + reflectionlist = reflection_init(); f = fopen(filename, "rb"); if ( !f ) { fprintf(stderr, "Couldn't read reflections from cache\n"); @@ -58,22 +58,22 @@ ReflectionContext *cache_load(const char *filename) { fprintf(stderr, "Couldn't read reflections from cache\n"); fclose(f); free(cr); - reflection_clear(rctx); + reflection_clear(reflectionlist); return NULL; } cr->next = NULL; /* Guarantee swift failure in the event of a screw-up */ //printf("reading (%f,%f,%f) i=%f (%d,%d,%d) %d\n",cr->x,cr->y,cr->z,cr->intensity,cr->h,cr->k,cr->l,cr->type); - reflection_add_from_reflection(rctx, cr); + reflection_add_from_reflection(reflectionlist, cr); } fclose(f); - return rctx; + return reflectionlist; } -int cache_save(const char *input_filename, ReflectionContext *rctx) { +int cache_save(const char *input_filename, ReflectionList *reflectionlist) { FILE *f; CacheHeader ch; @@ -91,7 +91,7 @@ int cache_save(const char *input_filename, ReflectionContext *rctx) { cachedreflection_size = sizeof(Reflection) - sizeof(Reflection *); count = 0; - r = rctx->reflections; + r = reflectionlist->reflections; while ( r != NULL ) { count++; r = r->next; @@ -108,7 +108,7 @@ int cache_save(const char *input_filename, ReflectionContext *rctx) { ch.scale = 0.; //temp, currently doesn't do anything fwrite(&ch, sizeof(CacheHeader), 1, f); - r = rctx->reflections; + r = reflectionlist->reflections; while ( r != NULL ) { fwrite(r, cachedreflection_size, 1, f); /* Write the reflection block, stopping just short of the "next" pointer */ diff --git a/src/cache.h b/src/cache.h index 716f0ee..a52edfe 100644 --- a/src/cache.h +++ b/src/cache.h @@ -17,8 +17,8 @@ #include <config.h> #endif -extern ReflectionContext *cache_load(const char *filename); -extern int cache_save(const char *filename, ReflectionContext *rctx); +extern ReflectionList *cache_load(const char *filename); +extern int cache_save(const char *filename, ReflectionList *reflectionlist); extern unsigned int cache_is_cachefile(const char *filename); #endif /*CACHE_H_*/ diff --git a/src/control.h b/src/control.h index 50c7230..5b0d187 100644 --- a/src/control.h +++ b/src/control.h @@ -111,7 +111,7 @@ typedef struct cctx_struct { ImageRecord images[MAX_IMAGES]; /* Output */ - struct rctx_struct *reflectionctx; + struct reflectionlist_struct *reflectionlist; struct dw_struct *dw; /* GTK bits */ @@ -123,7 +123,7 @@ typedef struct cctx_struct { /* IPR stuff */ int ipr_cur_image; struct imagedisplay_struct *ipr_id; - struct rctx_struct *ipr_lat; + struct reflectionlist_struct *ipr_lat; struct basis_struct *ipr_basis; } ControlContext; diff --git a/src/displaywindow.c b/src/displaywindow.c index 867b2cb..b38007d 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -358,7 +358,7 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { if ( dw->gl_use_buffers ) { glGenBuffersARB(1, &dw->gl_ref_vertex_buffer); } - reflection = ctx->reflectionctx->reflections; + reflection = ctx->reflectionlist->reflections; i = 0; do { if ( reflection->type == REFLECTION_NORMAL ) i++; @@ -366,7 +366,7 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { } while ( reflection != NULL ); dw->gl_ref_num_vertices = i; i = 0; - reflection = ctx->reflectionctx->reflections; + reflection = ctx->reflectionlist->reflections; vertices = malloc(3*dw->gl_ref_num_vertices*sizeof(GLfloat)); do { if ( reflection->type == REFLECTION_NORMAL ) { @@ -390,7 +390,7 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { glGenBuffersARB(1, &dw->gl_marker_vertex_buffer); glGenBuffersARB(1, &dw->gl_marker_normal_buffer); } - reflection = ctx->reflectionctx->reflections; + reflection = ctx->reflectionlist->reflections; i = 0; do { if ( reflection->type == REFLECTION_MARKER ) i++; @@ -398,7 +398,7 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { } while ( reflection != NULL ); dw->gl_marker_num_vertices = i*VERTICES_IN_A_BLOB; i = 0; - reflection = ctx->reflectionctx->reflections; + reflection = ctx->reflectionlist->reflections; vertices = malloc(3*dw->gl_marker_num_vertices*sizeof(GLfloat)); normals = malloc(3*dw->gl_marker_num_vertices*sizeof(GLfloat)); do { @@ -424,7 +424,7 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { glGenBuffersARB(1, &dw->gl_gen_vertex_buffer); glGenBuffersARB(1, &dw->gl_gen_normal_buffer); } - reflection = ctx->reflectionctx->reflections; + reflection = ctx->reflectionlist->reflections; i = 0; do { if ( reflection->type == REFLECTION_GENERATED ) i++; @@ -432,7 +432,7 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { } while ( reflection != NULL ); dw->gl_gen_num_vertices = i*VERTICES_IN_A_BLOB; i = 0; - reflection = ctx->reflectionctx->reflections; + reflection = ctx->reflectionlist->reflections; vertices = malloc(3*dw->gl_gen_num_vertices*sizeof(GLfloat)); normals = malloc(3*dw->gl_gen_num_vertices*sizeof(GLfloat)); do { @@ -517,7 +517,7 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { glPopMatrix(); /* Plot the other reflections */ - reflection = ctx->reflectionctx->reflections; + reflection = ctx->reflectionlist->reflections; quadric = gluNewQuadric(); do { @@ -29,9 +29,9 @@ #include "basis.h" /* Generate list of reflections to analyse */ -static ReflectionContext *ipr_generate(ControlContext *ctx, Basis *basis) { +static ReflectionList *ipr_generate(ControlContext *ctx, Basis *basis) { - ReflectionContext *ordered; + ReflectionList *ordered; double max_res; signed int h, k, l; int max_order_a, max_order_b, max_order_c; @@ -73,7 +73,7 @@ static ReflectionContext *ipr_generate(ControlContext *ctx, Basis *basis) { ref->h = h; ref->k = k; ref->l = l; } if ( (h!=0) || (k!=0) || (l!=0) ) { - // reflection_add(ctx->reflectionctx, x, y, z, 1, REFLECTION_GENERATED); + // reflection_add(ctx->reflectionlist, x, y, z, 1, REFLECTION_GENERATED); reflection_add(ordered, x, y, z, 1, REFLECTION_GENERATED); } } @@ -95,7 +95,7 @@ static gint ipr_clicked(GtkWidget *widget, GdkEventButton *event, ControlContext if ( ctx->ipr_cur_image == ctx->n_images ) ctx->ipr_cur_image = 0; imagedisplay_clear_circles(ctx->ipr_id); - reflection_clear_markers(ctx->reflectionctx); + reflection_clear_markers(ctx->reflectionlist); refl = reproject_get_reflections(ctx->images[ctx->ipr_cur_image], &n, ctx->ipr_lat, ctx); for ( j=0; j<n; j++ ) { @@ -43,15 +43,15 @@ void main_do_reconstruction(ControlContext *ctx) { mapping_create(ctx); } - if ( (ctx->inputfiletype != INPUT_CACHE) && !val && ctx->reflectionctx && ctx->savecache ) { - cache_save(ctx->filename, ctx->reflectionctx); + if ( (ctx->inputfiletype != INPUT_CACHE) && !val && ctx->reflectionlist && ctx->savecache ) { + cache_save(ctx->filename, ctx->reflectionlist); } - if ( (ctx->rmode == RECONSTRUCTION_PREDICTION) && (ctx->reflectionctx) ) { + if ( (ctx->rmode == RECONSTRUCTION_PREDICTION) && (ctx->reflectionlist) ) { val = ipr_refine(ctx); } - if ( !val && (ctx->reflectionctx) ) { + if ( !val && (ctx->reflectionlist) ) { ctx->dw = displaywindow_open(ctx); } else { fprintf(stderr, "Reconstruction failed.\n"); @@ -102,7 +102,7 @@ static gint main_method_window_response(GtkWidget *method_window, gint response, } else if ( ctx->inputfiletype == INPUT_MRC ) { val = mrc_read(ctx); } else if ( ctx->inputfiletype == INPUT_CACHE ) { - ctx->reflectionctx = cache_load(ctx->filename); + ctx->reflectionlist = cache_load(ctx->filename); val=0; } diff --git a/src/mapping.c b/src/mapping.c index fdce9ea..8570966 100644 --- a/src/mapping.c +++ b/src/mapping.c @@ -17,24 +17,24 @@ #include "control.h" #include "itrans.h" -ReflectionContext *mapping_create(ControlContext *ctx) { +ReflectionList *mapping_create(ControlContext *ctx) { - ReflectionContext *rctx; + ReflectionList *reflectionlist; int i; /* Create reflection context */ - rctx = reflection_init(); + reflectionlist = reflection_init(); /* Pass all images through itrans - * (let itrans add the reflections to rctx for now) */ + * (let itrans add the reflections to reflectionlist for now) */ printf("MP: Processing images..."); fflush(stdout); - ctx->reflectionctx = rctx; + ctx->reflectionlist = reflectionlist; for ( i=0; i<ctx->n_images; i++ ) { itrans_process_image(&ctx->images[i], ctx); } - printf("done: %i 'measured' reflections\n", ctx->reflectionctx->n_reflections); + printf("done: %i 'measured' reflections\n", ctx->reflectionlist->n_reflections); - return rctx; + return reflectionlist; } diff --git a/src/mapping.h b/src/mapping.h index f40d8f1..601ad46 100644 --- a/src/mapping.h +++ b/src/mapping.h @@ -19,7 +19,7 @@ #include "reflections.h" #include "control.h" -extern ReflectionContext *mapping_create(ControlContext *ctx); +extern ReflectionList *mapping_create(ControlContext *ctx); #endif /* MAPPING_H */ @@ -107,7 +107,7 @@ static int qdrp_parseline(ControlContext *ctx, const char *line) { } ctx->started = 1; - ctx->reflectionctx = reflection_init(); + ctx->reflectionlist = reflection_init(); } diff --git a/src/reflections.c b/src/reflections.c index 3fa1b6d..a0ff76d 100644 --- a/src/reflections.c +++ b/src/reflections.c @@ -22,34 +22,34 @@ #include "reflections.h" #include "utils.h" -static void reflection_addfirst(ReflectionContext *reflectionctx) { +static void reflection_addfirst(ReflectionList *reflectionlist) { /* Create first items on lists - saves faffing later. Corresponds to a central marker. Reflections are only stored if they have non-zero value. */ - reflectionctx->reflections = malloc(sizeof(Reflection)); - reflectionctx->reflections->next = NULL; - reflectionctx->reflections->x = 0; - reflectionctx->reflections->y = 0; - reflectionctx->reflections->z = 0; - reflectionctx->reflections->type = REFLECTION_CENTRAL; - reflectionctx->last_reflection = reflectionctx->reflections; - reflectionctx->n_reflections = 1; - reflectionctx->list_capped = 0; + reflectionlist->reflections = malloc(sizeof(Reflection)); + reflectionlist->reflections->next = NULL; + reflectionlist->reflections->x = 0; + reflectionlist->reflections->y = 0; + reflectionlist->reflections->z = 0; + reflectionlist->reflections->type = REFLECTION_CENTRAL; + reflectionlist->last_reflection = reflectionlist->reflections; + reflectionlist->n_reflections = 1; + reflectionlist->list_capped = 0; } -ReflectionContext *reflection_init() { +ReflectionList *reflection_init() { - ReflectionContext *reflectionctx = malloc(sizeof(ReflectionContext)); - reflectionctx->n_reflections = 0; - reflection_addfirst(reflectionctx); - reflectionctx->list_capped = 0; + ReflectionList *reflectionlist = malloc(sizeof(ReflectionList)); + reflectionlist->n_reflections = 0; + reflection_addfirst(reflectionlist); + reflectionlist->list_capped = 0; - return reflectionctx; + return reflectionlist; } -void reflection_clear_markers(ReflectionContext *reflectionctx) { +void reflection_clear_markers(ReflectionList *reflectionlist) { - Reflection *reflection = reflectionctx->reflections; + Reflection *reflection = reflectionlist->reflections; Reflection *prev = NULL; int del = 0; @@ -64,7 +64,7 @@ void reflection_clear_markers(ReflectionContext *reflectionctx) { if ( prev ) { prev->next = next; } else { - reflectionctx->reflections = next; + reflectionlist->reflections = next; } } else { prev = reflection; @@ -74,48 +74,48 @@ void reflection_clear_markers(ReflectionContext *reflectionctx) { } while ( reflection ); - reflectionctx->n_reflections -= del; - reflectionctx->last_reflection = prev; + reflectionlist->n_reflections -= del; + reflectionlist->last_reflection = prev; } -void reflection_clear(ReflectionContext *reflectionctx) { +void reflection_clear(ReflectionList *reflectionlist) { - Reflection *reflection = reflectionctx->reflections; + Reflection *reflection = reflectionlist->reflections; do { Reflection *next = reflection->next; free(reflection); reflection = next; } while ( reflection ); - reflectionctx->n_reflections = 0; - reflectionctx->list_capped = 0; - reflection_addfirst(reflectionctx); + reflectionlist->n_reflections = 0; + reflectionlist->list_capped = 0; + reflection_addfirst(reflectionlist); } -void reflection_free(ReflectionContext *reflectionctx) { - reflection_clear(reflectionctx); - free(reflectionctx->reflections); - free(reflectionctx); +void reflection_free(ReflectionList *reflectionlist) { + reflection_clear(reflectionlist); + free(reflectionlist->reflections); + free(reflectionlist); } -Reflection *reflection_add(ReflectionContext *reflectionctx, double x, double y, double z, double intensity, ReflectionType type) { +Reflection *reflection_add(ReflectionList *reflectionlist, double x, double y, double z, double intensity, ReflectionType type) { Reflection *new_reflection; Reflection *nearest; - if ( reflectionctx->list_capped ) return NULL; + if ( reflectionlist->list_capped ) return NULL; - if ( reflectionctx->n_reflections > 1e7 ) { + if ( reflectionlist->n_reflections > 1e7 ) { fprintf(stderr, "More than 10 million reflections on list. I think this is silly.\n"); fprintf(stderr, "No further reflections will be stored. Go and fix the peak detection.\n"); - reflectionctx->list_capped = 1; + reflectionlist->list_capped = 1; } - nearest = reflection_find_nearest_type(reflectionctx, x, y, z, type); + nearest = reflection_find_nearest_type(reflectionlist, x, y, z, type); if ( nearest && distance3d(x, y, z, nearest->x, nearest->y, nearest->z) < 0.1e9 ) return NULL; - reflectionctx->n_reflections++; + reflectionlist->n_reflections++; new_reflection = malloc(sizeof(Reflection)); new_reflection->next = NULL; @@ -126,8 +126,8 @@ Reflection *reflection_add(ReflectionContext *reflectionctx, double x, double y, new_reflection->type = type; new_reflection->found = 0; - reflectionctx->last_reflection->next = new_reflection; - reflectionctx->last_reflection = new_reflection; + reflectionlist->last_reflection->next = new_reflection; + reflectionlist->last_reflection = new_reflection; return new_reflection; @@ -216,23 +216,23 @@ void reflection_add_from_dp(ControlContext *ctx, double x, double y, ImageRecord refl.intensity = intensity; if ( !reflection_map_to_space(&refl, &nx, &ny, &nz, &twotheta) ) { - reflection_add(ctx->reflectionctx, nx, ny, nz, intensity, REFLECTION_NORMAL); + reflection_add(ctx->reflectionlist, nx, ny, nz, intensity, REFLECTION_NORMAL); } } -void reflection_add_from_reflection(ReflectionContext *rctx, Reflection *r) { +void reflection_add_from_reflection(ReflectionList *reflectionlist, Reflection *r) { r->next = NULL; - rctx->last_reflection->next = r; - rctx->last_reflection = r; + reflectionlist->last_reflection->next = r; + reflectionlist->last_reflection = r; } -double reflection_largest_g(ReflectionContext *reflectionctx) { +double reflection_largest_g(ReflectionList *reflectionlist) { double max = 0.0; Reflection *reflection; - reflection = reflectionctx->reflections; + reflection = reflectionlist->reflections; while ( reflection ) { if ( reflection->type == REFLECTION_NORMAL ) { double mod; @@ -246,13 +246,13 @@ double reflection_largest_g(ReflectionContext *reflectionctx) { } -Reflection *reflection_find_nearest(ReflectionContext *reflectionctx, double x, double y, double z) { +Reflection *reflection_find_nearest(ReflectionList *reflectionlist, double x, double y, double z) { double max = +INFINITY; Reflection *reflection; Reflection *best = NULL; - reflection = reflectionctx->reflections; + reflection = reflectionlist->reflections; while ( reflection ) { if ( reflection->type == REFLECTION_NORMAL ) { double mod; @@ -269,13 +269,13 @@ Reflection *reflection_find_nearest(ReflectionContext *reflectionctx, double x, } -Reflection *reflection_find_nearest_longer(ReflectionContext *reflectionctx, double x, double y, double z, double min_distance) { +Reflection *reflection_find_nearest_longer(ReflectionList *reflectionlist, double x, double y, double z, double min_distance) { double max = +INFINITY; Reflection *reflection; Reflection *best = NULL; - reflection = reflectionctx->reflections; + reflection = reflectionlist->reflections; while ( reflection ) { if ( (reflection->type == REFLECTION_NORMAL) && (!reflection->found) ) { double mod; @@ -292,13 +292,13 @@ Reflection *reflection_find_nearest_longer(ReflectionContext *reflectionctx, dou } -Reflection *reflection_find_nearest_type(ReflectionContext *reflectionctx, double x, double y, double z, ReflectionType type) { +Reflection *reflection_find_nearest_type(ReflectionList *reflectionlist, double x, double y, double z, ReflectionType type) { double max = +INFINITY; Reflection *reflection; Reflection *best = NULL; - reflection = reflectionctx->reflections; + reflection = reflectionlist->reflections; while ( reflection ) { if ( reflection->type == type ) { double mod; diff --git a/src/reflections.h b/src/reflections.h index 9dd281a..9ac0cec 100644 --- a/src/reflections.h +++ b/src/reflections.h @@ -45,7 +45,7 @@ typedef struct reflection_struct { } Reflection; -typedef struct rctx_struct { +typedef struct reflectionlist_struct { Reflection *reflections; Reflection *last_reflection; @@ -53,24 +53,24 @@ typedef struct rctx_struct { unsigned int n_reflections; unsigned int list_capped; -} ReflectionContext; +} ReflectionList; -extern ReflectionContext *reflection_init(void); -extern void reflection_clear(ReflectionContext *reflectionctx); -extern void reflection_clear_markers(ReflectionContext *reflectionctx); -extern void reflection_free(ReflectionContext *reflectionctx); +extern ReflectionList *reflection_init(void); +extern void reflection_clear(ReflectionList *reflectionlist); +extern void reflection_clear_markers(ReflectionList *reflectionlist); +extern void reflection_free(ReflectionList *reflectionlist); -extern Reflection *reflection_add(ReflectionContext *reflectionctx, double x, double y, double z, double intensity, ReflectionType type); +extern Reflection *reflection_add(ReflectionList *reflectionlist, double x, double y, double z, double intensity, ReflectionType type); #include "control.h" extern void reflection_add_from_dp(ControlContext *ctx, double x, double y, ImageRecord *imagerecord, double intensity); -extern void reflection_add_from_reflection(ReflectionContext *rctx, Reflection *r); -extern double reflection_largest_g(ReflectionContext *reflectionctx); +extern void reflection_add_from_reflection(ReflectionList *reflectionlist, Reflection *r); +extern double reflection_largest_g(ReflectionList *reflectionlist); extern int reflection_map_to_space(ImageReflection *refl, double *ddx, double *ddy, double *ddz, double *twotheta); -extern Reflection *reflection_find_nearest(ReflectionContext *reflectionctx, double x, double y, double z); -extern Reflection *reflection_find_nearest_longer(ReflectionContext *reflectionctx, double x, double y, double z, double min_distance); -extern Reflection *reflection_find_nearest_type(ReflectionContext *reflectionctx, double x, double y, double z, ReflectionType type); +extern Reflection *reflection_find_nearest(ReflectionList *reflectionlist, double x, double y, double z); +extern Reflection *reflection_find_nearest_longer(ReflectionList *reflectionlist, double x, double y, double z, double min_distance); +extern Reflection *reflection_find_nearest_type(ReflectionList *reflectionlist, double x, double y, double z, ReflectionType type); #endif /* REFLECTION_H */ diff --git a/src/reproject.c b/src/reproject.c index ed359fc..38f15ff 100644 --- a/src/reproject.c +++ b/src/reproject.c @@ -18,7 +18,7 @@ #define MAX_IMAGE_REFLECTIONS 8*1024 -ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, ReflectionContext *rctx, ControlContext *ctx) { +ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, ReflectionList *reflectionlist, ControlContext *ctx) { ImageReflection *refl; Reflection *reflection; @@ -42,7 +42,7 @@ ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, Reflect kx = nx / image.lambda; ky = ny / image.lambda; kz = nz / image.lambda; /* This is the centre of the Ewald sphere */ - //reflection_add(ctx->reflectionctx, kx, ky, kz, 1, REFLECTION_VECTOR_MARKER_1); + //reflection_add(ctx->reflectionlist, kx, ky, kz, 1, REFLECTION_VECTOR_MARKER_1); /* Determine where "up" is * See above. */ @@ -50,10 +50,10 @@ ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, Reflect ux = uxt; uy = cos(tilt)*uyt + sin(tilt)*uzt; uz = -sin(tilt)*uyt + cos(tilt)*uzt; uxt = ux; uyt = uy; uzt = uz; ux = uxt*cos(-omega) + uyt*-sin(omega); uy = -uxt*sin(omega) + uyt*cos(omega); uz = uzt; - //reflection_add(ctx->reflectionctx, ux*50e9, uy*50e9, uz*50e9, 1, REFLECTION_VECTOR_MARKER_2); + //reflection_add(ctx->reflectionlist, ux*50e9, uy*50e9, uz*50e9, 1, REFLECTION_VECTOR_MARKER_2); refl = malloc(MAX_IMAGE_REFLECTIONS*sizeof(ImageReflection)); - reflection = rctx->reflections; + reflection = reflectionlist->reflections; i = 0; do { @@ -99,8 +99,8 @@ ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, Reflect double psi, disc; - //reflection_add(ctx->reflectionctx, xl, yl, zl, 1, REFLECTION_GENERATED); - //reflection_add(ctx->reflectionctx, xi, yi, zi, 1, REFLECTION_MARKER); + //reflection_add(ctx->reflectionlist, xl, yl, zl, 1, REFLECTION_GENERATED); + //reflection_add(ctx->reflectionlist, xi, yi, zi, 1, REFLECTION_MARKER); /* Calculate azimuth of point in image (clockwise from "up", will be changed later) */ cx = yi*nz-zi*ny; cy = nx*zi-nz*xi; cz = ny*xi-nx*yi; /* c = i x n */ @@ -110,9 +110,9 @@ ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, Reflect rx = cy*nz-cz*ny; ry = nx*cz-nz*cx; rz = ny*cx-nx*cy; /* r = [i x n] x n */ disc = angle_between(rx, ry, rz, ux, uy, uz); // if ( (i==20) && !done_debug ) { - // reflection_add(ctx->reflectionctx, xi, yi, zi, 1, REFLECTION_VECTOR_MARKER_3); - // reflection_add(ctx->reflectionctx, cx, cy, cz, 1, REFLECTION_VECTOR_MARKER_4); - // reflection_add(ctx->reflectionctx, rx, ry, rz, 1, REFLECTION_VECTOR_MARKER_4); + // reflection_add(ctx->reflectionlist, xi, yi, zi, 1, REFLECTION_VECTOR_MARKER_3); + // reflection_add(ctx->reflectionlist, cx, cy, cz, 1, REFLECTION_VECTOR_MARKER_4); + // reflection_add(ctx->reflectionlist, rx, ry, rz, 1, REFLECTION_VECTOR_MARKER_4); // printf("psi=%f deg, disc=%f deg\n", rad2deg(psi), rad2deg(disc)); // } if ( (psi >= M_PI_2) && (disc >= M_PI_2) ) { diff --git a/src/reproject.h b/src/reproject.h index 790f43d..95a2b77 100644 --- a/src/reproject.h +++ b/src/reproject.h @@ -19,7 +19,7 @@ #include "control.h" #include "reflections.h" -extern ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, ReflectionContext *rctx, ControlContext *ctx); +extern ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, ReflectionList *reflectionlist, ControlContext *ctx); #endif /* REPROJECT_H */ |