aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-07-14 17:58:55 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:53 +0100
commit6a5422356c15962726df2261aa53354b0ff12662 (patch)
treeb6c5ae80b837bda38957cef07816b511515ffdcb /src/utils.c
parent6a476e010468f27e02df6bb90a1ea197bd9d039d (diff)
Reduce the scope of "count"
Lists of counts had pervaded every corner of CrystFEL, being used as markers for the presence of reflections. Now we have a better way of doing this, the ReflItemList, and few parts of the suite apart from process_hkl have any business knowing how many observations were made of a particular reflection.
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/utils.c b/src/utils.c
index 21ba882f..0f20435e 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -387,24 +387,23 @@ int num_items(const ReflItemList *items)
}
-unsigned int *items_to_counts(ReflItemList *items)
+void union_op_items(ReflItemList *items, ReflItemList *newi)
{
- unsigned int *c;
- int i;
+ int n, i;
- c = new_list_count();
+ n = num_items(newi);
+ for ( i=0; i<n; i++ ) {
- for ( i=0; i<num_items(items); i++ ) {
- struct refl_item *r;
- r = get_item(items, i);
- set_count(c, r->h, r->k, r->l, 1);
- }
+ struct refl_item *r = get_item(newi, i);
+ if ( find_op(items, r->op) ) continue;
+
+ add_item_with_op(items, r->h, r->k, r->l, r->op);
- return c;
+ }
}
-void union_op_items(ReflItemList *items, ReflItemList *newi)
+void union_items(ReflItemList *items, ReflItemList *newi)
{
int n, i;
@@ -412,9 +411,28 @@ void union_op_items(ReflItemList *items, ReflItemList *newi)
for ( i=0; i<n; i++ ) {
struct refl_item *r = get_item(newi, i);
- if ( find_op(items, r->op) ) continue;
+ if ( find_item(items, r->h, r->k, r->l) ) continue;
add_item_with_op(items, r->h, r->k, r->l, r->op);
}
}
+
+
+ReflItemList *intersection_items(ReflItemList *i1, ReflItemList *i2)
+{
+ int n, i;
+ ReflItemList *res = new_items();
+
+ n = num_items(i1);
+ for ( i=0; i<n; i++ ) {
+
+ struct refl_item *r = get_item(i1, i);
+ if ( find_item(i2, r->h, r->k, r->l) ) {
+ add_item_with_op(res, r->h, r->k, r->l, r->op);
+ }
+
+ }
+
+ return res;
+}