aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-02-03 15:52:24 +0100
committerThomas White <taw@physics.org>2018-02-27 10:53:26 +0100
commit76718028a6c6419a799c5cc89e0bd7ce0a3c70b1 (patch)
treec0d82bf36509ad2a87220917e3c4ecb9c34b9b9d
parented135cad77c52f65e0a3d7ecdeebbca492b7becd (diff)
const-cleanliness
-rw-r--r--libcrystfel/src/cell.c49
-rw-r--r--libcrystfel/src/cell.h10
-rw-r--r--libcrystfel/src/crystal.c8
-rw-r--r--libcrystfel/src/crystal.h3
4 files changed, 23 insertions, 47 deletions
diff --git a/libcrystfel/src/cell.c b/libcrystfel/src/cell.c
index 213d891c..2a4e45be 100644
--- a/libcrystfel/src/cell.c
+++ b/libcrystfel/src/cell.c
@@ -3,15 +3,15 @@
*
* A class representing a unit cell
*
- * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
* Copyright © 2012 Richard Kirian
* Copyright © 2012 Lorenzo Galli
*
* Authors:
- * 2009-2012,2014 Thomas White <taw@physics.org>
- * 2010 Richard Kirian
- * 2012 Lorenzo Galli
+ * 2009-2012,2014,2017 Thomas White <taw@physics.org>
+ * 2010 Richard Kirian
+ * 2012 Lorenzo Galli
*
* This file is part of CrystFEL.
*
@@ -244,43 +244,12 @@ UnitCell *cell_new_from_direct_axes(struct rvec a, struct rvec b, struct rvec c)
}
-UnitCell *cell_new_from_cell(UnitCell *orig)
+UnitCell *cell_new_from_cell(const UnitCell *orig)
{
- UnitCell *n;
-
- n = cell_new();
-
- switch ( orig->rep ) {
-
- case CELL_REP_CRYST :
- n->a = orig->a; n->b = orig->b; n->c = orig->c;
- n->alpha = orig->alpha; n->beta = orig->beta; n->gamma = orig->gamma;
- break;
-
- case CELL_REP_CART :
- n->ax = orig->ax; n->bx = orig->bx; n->cx = orig->cx;
- n->ay = orig->ay; n->by = orig->by; n->cy = orig->cy;
- n->az = orig->az; n->bz = orig->bz; n->cz = orig->cz;
- break;
-
- case CELL_REP_RECIP :
- n->axs = orig->axs; n->bxs = orig->bxs; n->cxs = orig->cxs;
- n->ays = orig->ays; n->bys = orig->bys; n->cys = orig->cys;
- n->azs = orig->azs; n->bzs = orig->bzs; n->czs = orig->czs;
- break;
-
- default :
- ERROR("Bad cell representation %i\n", orig->rep);
-
- }
-
- n->lattice_type = orig->lattice_type;
- n->centering = orig->centering;
- n->unique_axis = orig->unique_axis;
- n->rep = orig->rep;
- n->have_parameters = orig->have_parameters;
-
- return n;
+ UnitCell *new;
+ new = cell_new();
+ *new = *orig;
+ return new;
}
diff --git a/libcrystfel/src/cell.h b/libcrystfel/src/cell.h
index 46927134..39e6a1ed 100644
--- a/libcrystfel/src/cell.h
+++ b/libcrystfel/src/cell.h
@@ -3,15 +3,15 @@
*
* A class representing a unit cell
*
- * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
* Copyright © 2012 Richard Kirian
* Copyright © 2012 Lorenzo Galli
*
* Authors:
- * 2009-2012,2014 Thomas White <taw@physics.org>
- * 2010,2012 Richard Kirian
- * 2012 Lorenzo Galli
+ * 2009-2012,2014,2017 Thomas White <taw@physics.org>
+ * 2010,2012 Richard Kirian
+ * 2012 Lorenzo Galli
*
* This file is part of CrystFEL.
*
@@ -104,7 +104,7 @@ extern "C" {
#endif
extern UnitCell *cell_new(void);
-extern UnitCell *cell_new_from_cell(UnitCell *orig);
+extern UnitCell *cell_new_from_cell(const UnitCell *orig);
extern void cell_free(UnitCell *cell);
/* Lengths in m, angles in radians */
diff --git a/libcrystfel/src/crystal.c b/libcrystfel/src/crystal.c
index 1cfaf621..3ea148bd 100644
--- a/libcrystfel/src/crystal.c
+++ b/libcrystfel/src/crystal.c
@@ -123,7 +123,7 @@ Crystal *crystal_new()
* Returns: a (shallow) copy of @cryst, or NULL on failure.
*
*/
-Crystal *crystal_copy(Crystal *cryst)
+Crystal *crystal_copy(const Crystal *cryst)
{
Crystal *c;
@@ -160,6 +160,12 @@ UnitCell *crystal_get_cell(Crystal *cryst)
}
+const UnitCell *crystal_get_cell_const(const Crystal *cryst)
+{
+ return cryst->cell;
+}
+
+
double crystal_get_profile_radius(Crystal *cryst)
{
return cryst->profile_radius;
diff --git a/libcrystfel/src/crystal.h b/libcrystfel/src/crystal.h
index 7552a257..b4726cce 100644
--- a/libcrystfel/src/crystal.h
+++ b/libcrystfel/src/crystal.h
@@ -52,10 +52,11 @@ extern "C" {
#endif
extern Crystal *crystal_new(void);
-extern Crystal *crystal_copy(Crystal *cryst);
+extern Crystal *crystal_copy(const Crystal *cryst);
extern void crystal_free(Crystal *cryst);
extern UnitCell *crystal_get_cell(Crystal *cryst);
+extern const UnitCell *crystal_get_cell_const(const Crystal *cryst);
extern double crystal_get_profile_radius(Crystal *cryst);
extern RefList *crystal_get_reflections(Crystal *cryst);
extern double crystal_get_resolution_limit(Crystal *cryst);