From 2a795e8605e20f0fa3e20fed094f0c906b147628 Mon Sep 17 00:00:00 2001 From: Kenneth Beyerlein Date: Wed, 25 Jun 2014 14:57:15 +0200 Subject: Add get_symop --- libcrystfel/src/symmetry.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ libcrystfel/src/symmetry.h | 1 + 2 files changed, 51 insertions(+) (limited to 'libcrystfel') diff --git a/libcrystfel/src/symmetry.c b/libcrystfel/src/symmetry.c index 67298ec1..14b108b7 100644 --- a/libcrystfel/src/symmetry.c +++ b/libcrystfel/src/symmetry.c @@ -205,6 +205,56 @@ static void add_symop_v(SymOpList *ops, } +/** + * get_symop: + * @ops: A %SymOpList + * @m: A %SymOpMask + * @idx: Index of the operation to get + * + * Returns a pointer to an integer matrix specifying a symmetry operation + * contained in the symmetry operator list, and identified by the specified + * index. + **/ +IntegerMatrix* get_symop(const SymOpList *ops, const SymOpMask *m, int idx) +{ + const int n = num_ops(ops); + + if ( m != NULL ) { + + int i, c; + + c = 0; + for ( i=0; imask[i] ) { + return ops->ops[i]; + } + + if ( m->mask[i] ) { + c++; + } + + } + + ERROR("Index %i out of range for point group '%s'\n", + idx, symmetry_name(ops)); + + return NULL; + + } + + if ( idx >= n ) { + + ERROR("Index %i out of range for point group '%s'\n", idx, + symmetry_name(ops)); + + return NULL; + + } + + return ops->ops[idx]; +} + static signed int *v(signed int h, signed int k, signed int i, signed int l) { signed int *vec = malloc(3*sizeof(signed int)); diff --git a/libcrystfel/src/symmetry.h b/libcrystfel/src/symmetry.h index 145b5473..42cbd9b3 100644 --- a/libcrystfel/src/symmetry.h +++ b/libcrystfel/src/symmetry.h @@ -61,6 +61,7 @@ extern "C" { extern void free_symoplist(SymOpList *ops); extern SymOpList *get_pointgroup(const char *sym); +extern IntegerMatrix* get_symop(const SymOpList *ops, const SymOpMask *m, int idx); extern SymOpMask *new_symopmask(const SymOpList *list); extern void free_symopmask(SymOpMask *m); -- cgit v1.2.3