aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-07-24 16:47:21 +0200
committerThomas White <taw@physics.org>2013-07-24 16:47:21 +0200
commit0bb8df9b6a54db5da84d9fc9c26efcf5974fc89b (patch)
tree937cfe2c1e95324e52e474edbc219b0330a4cc78 /libcrystfel
parent863b0ddea31ff8dc0d789f2806c6a311d826a152 (diff)
Iteration over reflection list should include other reflections with same asymmetric indices
This fixes a >2 year old bug in the reflection list, and a bug in tests/list_check.c which allowed it to go undetected for so long. The main situation where it would have caused problems is when asymmetric_indices() was called on a reflection list containing symmetrically equivalent reflections. The only core CrystFEL program which does this is partialator. compare_hkl uses asymmetric_indices(), but the reflections are already guaranteed to be asymmetric by that point (because check_list_symmetry() has been called).
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/reflist.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/libcrystfel/src/reflist.c b/libcrystfel/src/reflist.c
index b3b9f85b..a450d8fa 100644
--- a/libcrystfel/src/reflist.c
+++ b/libcrystfel/src/reflist.c
@@ -992,12 +992,20 @@ Reflection *first_refl(RefList *list, RefListIterator **piter)
**/
Reflection *next_refl(Reflection *refl, RefListIterator *iter)
{
- int returned = 1;
+ /* Are there more reflections with the same indices? */
+ if ( refl->next != NULL ) {
+ return refl->next;
+ } else {
- do {
+ /* No, so rewind back to the head of the list */
+ while ( refl->prev != NULL ) {
+ refl = refl->prev;
+ }
+
+ }
- if ( returned ) refl = refl->child[1];
- returned = 0;
+ refl = refl->child[1];
+ do {
if ( refl != NULL ) {
@@ -1041,13 +1049,21 @@ static int recursive_depth(Reflection *refl)
static int recursive_count(Reflection *refl)
{
int count_left, count_right;
+ Reflection *probe;
+ int n_this = 1;
if ( refl == NULL ) return 0;
+ probe = refl;
+ while ( probe->next != NULL ) {
+ probe = probe->next;
+ n_this++;
+ }
+
count_left = recursive_count(refl->child[0]);
count_right = recursive_count(refl->child[1]);
- return 1 + count_left + count_right;
+ return n_this + count_left + count_right;
}