aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/stream.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-01-18 09:46:26 +0100
committerThomas White <taw@physics.org>2024-02-06 16:59:34 +0100
commit604c081d5f8dffc7a78cb07c245dae531342db04 (patch)
tree71d1d900e23c6c2c0a3761a9e485dd040d07d659 /libcrystfel/src/stream.c
parent513827a44d1ddd395f677a74617b42934ca9bc64 (diff)
Crystals shouldn't own RefLists (part 2)
This commit replaces image.crystals with an array of small structs, each consisting of a Crystal-RefList pair. index.c and stream.c are updated, more to follow.
Diffstat (limited to 'libcrystfel/src/stream.c')
-rw-r--r--libcrystfel/src/stream.c48
1 files changed, 13 insertions, 35 deletions
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index edbeb7af..ffe68162 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -338,11 +338,9 @@ static int num_integrated_reflections(RefList *list)
}
-static int write_crystal(Stream *st, Crystal *cr,
- int include_reflections)
+static int write_crystal(Stream *st, Crystal *cr, RefList *reflist)
{
UnitCell *cell;
- RefList *reflist;
double asx, asy, asz;
double bsx, bsy, bsz;
double csx, csy, csz;
@@ -389,7 +387,6 @@ static int write_crystal(Stream *st, Crystal *cr,
fprintf(st->fh, "predict_refine/det_shift x = %.3f y = %.3f mm\n",
det_shift_x*1e3, det_shift_y*1e3);
- reflist = crystal_get_reflections(cr);
if ( reflist != NULL ) {
fprintf(st->fh, "diffraction_resolution_limit"
@@ -406,20 +403,17 @@ static int write_crystal(Stream *st, Crystal *cr,
}
- if ( include_reflections ) {
-
- if ( reflist != NULL ) {
+ if ( reflist != NULL ) {
- fprintf(st->fh, STREAM_REFLECTION_START_MARKER"\n");
- ret = write_stream_reflections(st->fh, reflist,
- st->dtempl_write);
- fprintf(st->fh, STREAM_REFLECTION_END_MARKER"\n");
+ fprintf(st->fh, STREAM_REFLECTION_START_MARKER"\n");
+ ret = write_stream_reflections(st->fh, reflist,
+ st->dtempl_write);
+ fprintf(st->fh, STREAM_REFLECTION_END_MARKER"\n");
- } else {
+ } else {
- fprintf(st->fh, "No integrated reflections.\n");
+ fprintf(st->fh, "No integrated reflections.\n");
- }
}
fprintf(st->fh, STREAM_CRYSTAL_END_MARKER"\n");
@@ -512,11 +506,11 @@ int stream_write_chunk(Stream *st, const struct image *i,
}
for ( j=0; j<i->n_crystals; j++ ) {
- if ( crystal_get_user_flag(i->crystals[j]) ) {
+ if ( crystal_get_user_flag(i->crystals[j].cr) ) {
continue;
}
- ret = write_crystal(st, i->crystals[j],
- srf & STREAM_REFLECTIONS);
+ ret = write_crystal(st, i->crystals[j].cr,
+ srf & STREAM_REFLECTIONS ? i->crystals[j].refls : NULL);
}
fprintf(st->fh, STREAM_CHUNK_END_MARKER"\n");
@@ -564,8 +558,7 @@ static void read_crystal(Stream *st, struct image *image,
char unique_axis = '*';
LatticeType lattice_type = L_TRICLINIC;
Crystal *cr;
- int n;
- Crystal **crystals_new;
+ RefList *reflist = NULL;
double shift_x, shift_y;
as.u = 0.0; as.v = 0.0; as.w = 0.0;
@@ -664,8 +657,6 @@ static void read_crystal(Stream *st, struct image *image,
if ( (strcmp(line, STREAM_REFLECTION_START_MARKER) == 0)
&& (srf & STREAM_REFLECTIONS) )
{
-
- RefList *reflist;
reflist = read_stream_reflections_2_3(st);
if ( reflist == NULL ) {
ERROR("Failed while reading reflections\n");
@@ -673,9 +664,6 @@ static void read_crystal(Stream *st, struct image *image,
ERROR("Event = %s\n", image->ev);
break;
}
-
- crystal_set_reflections(cr, reflist);
-
}
if ( strcmp(line, STREAM_CRYSTAL_END_MARKER) == 0 ) break;
@@ -713,17 +701,7 @@ static void read_crystal(Stream *st, struct image *image,
/* Unused at the moment */
crystal_set_mosaicity(cr, 0.0);
- /* Add crystal to the list for this image */
- n = image->n_crystals+1;
- crystals_new = cfrealloc(image->crystals, n*sizeof(Crystal *));
-
- if ( crystals_new == NULL ) {
- ERROR("Failed to expand crystal list!\n");
- } else {
- image->crystals = crystals_new;
- image->crystals[image->n_crystals++] = cr;
- }
-
+ image_add_crystal_refls(image, cr, reflist);
}