aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/detector.c
diff options
context:
space:
mode:
authorValerio Mariani <valerio.mariani@desy.de>2014-12-11 18:17:08 +0100
committerThomas White <taw@physics.org>2014-12-12 18:32:47 +0100
commit7774a292a498a21f3da311a12fc3302b52c9cd20 (patch)
tree492af40ddf0df6d352c4e71a91593e5192aec0c2 /libcrystfel/src/detector.c
parentde4fd34a0e9454ca7ebe73aa5c32a418f1f3bd12 (diff)
Deep copy of dim_structure when needed
Diffstat (limited to 'libcrystfel/src/detector.c')
-rw-r--r--libcrystfel/src/detector.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index e148cb59..1e160f7d 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -530,6 +530,22 @@ static struct panel *new_panel(struct detector *det, const char *name)
new->data = strdup(new->data);
}
+ /* Create a new copy of the dim_structure if needed */
+ if ( new->dim_structure != NULL ) {
+
+ struct dim_structure *dim_copy;
+ int di;
+
+ dim_copy = initialize_dim_structure();
+ dim_copy->num_dims = new->dim_structure->num_dims;
+ dim_copy->dims = malloc(dim_copy->num_dims*sizeof(int));
+ for ( di=0; di<dim_copy->num_dims; di++ ) {
+ dim_copy->dims[di] = new->dim_structure->dims[di];
+ }
+
+ new->dim_structure = dim_copy;
+ }
+
/* Create a new copy of the bad pixel mask location */
if ( new->mask != NULL ) {
new->mask = strdup(new->mask);
@@ -1407,6 +1423,24 @@ struct detector *copy_geom(const struct detector *in)
p->clen_from = strdup(p->clen_from);
}
+ if ( p->dim_structure != NULL ) {
+ /* Make a copy of the dim_structure fields unique to this
+ * copy of the structure. */
+
+ struct dim_structure *dim_new;
+ int di;
+
+ dim_new = initialize_dim_structure();
+ dim_new->num_dims = p->dim_structure->num_dims;
+ dim_new->dims = malloc(dim_new->num_dims*sizeof(int));
+ for ( di=0; di<dim_new->num_dims; di++ ) {
+ dim_new->dims[di] = p->dim_structure->dims[di];
+ }
+
+ p->dim_structure = dim_new;
+
+ }
+
if ( p->clen_from != NULL ) {
/* Make a copy of the mask fields unique to this
* copy of the structure. */