aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-06-30 15:39:15 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:51 +0100
commitb4664d394beac2fe7f2810f0687625a4bbc3af50 (patch)
tree72d513760ebcb50dc455bdf2de36c33e5287378d
parenta1e1f14f09e0c0a9a00175c821650588cc2fbaea (diff)
Change macro to static function in symmetry
-rw-r--r--src/symmetry.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/symmetry.c b/src/symmetry.c
index 06148de7..a3c3ac48 100644
--- a/src/symmetry.c
+++ b/src/symmetry.c
@@ -28,29 +28,32 @@
#endif /* DEBUG */
-/* Conditions for a reflection to be in the asymmetric unit cell */
-#define COND_1(h, k, l) (1)
-#define COND_6(h, k, l) ( (h>=0) && (k>=0) )
-#define COND_6M(h, k, l) ( (h>=0) && (k>=0) && (l>=0) )
-#define COND_6MMM(h, k, l) ( (h>=0) && (k>=0) && (l>=0) \
- && (h>=k) )
-/* TODO: Add more groups here */
+/* Check if a reflection is in the asymmetric unit cell */
+static int check_cond(signed int h, signed int k, signed int l, const char *sym)
+{
+ if ( strcmp(sym, "1") == 0 )
+ return ( 1 );
+ if ( strcmp(sym, "6") == 0 )
+ return ( (h>=0) && (k>=0) );
+ if ( strcmp(sym, "6/m") == 0 )
+ return ( (h>=0) && (k>=0) && (l>=0) );
+ if ( strcmp(sym, "6/mmm") == 0 )
+ return ( (h>=0) && (k>=0) && (l>=0) && (h>=k) );
+
+ /* TODO: Add more groups here */
+
+ return 1;
+}
/* Macros for checking the above conditions and returning if satisfied */
-#define CHECK_COND(h, k, l, cond) \
- if ( COND_##cond((h), (k), (l)) ) { \
+#define CHECK_COND(h, k, l, sym) \
+ if ( check_cond((h), (k), (l), (sym)) ) { \
*hp = (h); *kp = (k); *lp = (l); \
return; \
}
-/* Abort macro if no match found */
-#define SYM_ABORT \
- ERROR("No match in %s for %i %i %i\n", sym, h, k, l); \
- abort();
-
-
/* FIXME: Should take into account special indices
* e.g. l==0 has fewer equivalent reflections */
int num_equivs(signed int h, signed int k, signed int l, const char *sym)
@@ -132,6 +135,8 @@ void get_equiv(signed int h, signed int k, signed int l,
}
}
+ /* TODO: Add more groups here */
+
/* Fallback for unrecognised groups */
*he = h; *ke = k; *le = l;
}
@@ -149,14 +154,9 @@ void get_asymm(signed int h, signed int k, signed int l,
signed int he, ke, le;
get_equiv(h, k, l, &he, &ke, &le, sym, p);
SYM_DEBUG("%i : %i %i %i\n", p, he, ke, le);
- if ( strcmp(sym, "1") == 0 ) CHECK_COND(he, ke, le, 1);
- if ( strcmp(sym, "6") == 0 ) CHECK_COND(he, ke, le, 6);
- if ( strcmp(sym, "6/m") == 0 ) CHECK_COND(he, ke, le, 6M);
- if ( strcmp(sym, "6/mmm") == 0 ) CHECK_COND(he, ke, le, 6MMM);
+ CHECK_COND(he, ke, le, sym);
}
- SYM_ABORT; /* Should never reach here */
-
- ERROR("Unknown point group '%s'\n", sym);
- abort();
+ /* Should never reach here */
+ ERROR("No match found in %s for %i %i %i\n", sym, h, k, l);
}