From e214a0bbb650d036fc08130e6d6104008ecdcb48 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 22 Sep 2017 11:39:28 +0200 Subject: cell_new_from_cell(): Don't try to duplicate non-existent parameters --- libcrystfel/src/cell.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/libcrystfel/src/cell.c b/libcrystfel/src/cell.c index 3de61073..213d891c 100644 --- a/libcrystfel/src/cell.c +++ b/libcrystfel/src/cell.c @@ -246,18 +246,41 @@ UnitCell *cell_new_from_direct_axes(struct rvec a, struct rvec b, struct rvec c) UnitCell *cell_new_from_cell(UnitCell *orig) { - UnitCell *new; - double ax, ay, az, bx, by, bz, cx, cy, cz; + 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; - new = cell_new(); + 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); + + } - cell_get_cartesian(orig, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); - cell_set_cartesian(new, ax, ay, az, bx, by, bz, cx, cy, cz); - cell_set_lattice_type(new, orig->lattice_type); - cell_set_centering(new, orig->centering); - cell_set_unique_axis(new, orig->unique_axis); + 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 new; + return n; } -- cgit v1.2.3