aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/datatemplate.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-06-15 12:07:14 +0200
committerThomas White <taw@physics.org>2023-07-28 13:22:05 +0200
commitaada11e09edca22f816f4471c73fff6d6a383256 (patch)
tree798a9c90c85fd27dee780a95ecab1526299b0db8 /libcrystfel/src/datatemplate.c
parentc6115928bb875b0ed408655ff12b9ca00dae017c (diff)
detgeom: Add references from children to parents
This allows us to start from the panel and work upwards to the top-level group, which makes hierarchical gradient calculation much easier.
Diffstat (limited to 'libcrystfel/src/datatemplate.c')
-rw-r--r--libcrystfel/src/datatemplate.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index 28567b6f..2126f313 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -1807,8 +1807,10 @@ static int detector_flat(const DataTemplate *dtempl)
static struct detgeom_panel_group *walk_group(const DataTemplate *dtempl,
- const struct panel_group_template *gt,
- struct detgeom *detgeom)
+ struct panel_group_template *gt,
+ struct detgeom *detgeom,
+ int hierarchy_level,
+ int member_index)
{
struct detgeom_panel_group *gr;
@@ -1829,6 +1831,7 @@ static struct detgeom_panel_group *walk_group(const DataTemplate *dtempl,
ERROR("Couldn't find panel %s for leaf group\n", gr->name);
return NULL;
}
+ gr->panel->group = gr;
} else {
@@ -1842,12 +1845,16 @@ static struct detgeom_panel_group *walk_group(const DataTemplate *dtempl,
}
for ( i=0; i<gt->n_children; i++ ) {
- gr->children[i] = walk_group(dtempl, gt->children[i], detgeom);
+ gr->children[i] = walk_group(dtempl, gt->children[i],
+ detgeom, hierarchy_level+1, i);
if ( gr->children[i] == NULL ) return NULL;
+ gr->children[i]->parent = gr;
}
}
+ gr->member_index = member_index;
+ gr->hierarchy_level = hierarchy_level;
return gr;
}
@@ -1976,7 +1983,8 @@ struct detgeom *create_detgeom(struct image *image,
}
- detgeom->top_group = walk_group(dtempl, find_group(dtempl, "all"), detgeom);
+ detgeom->top_group = walk_group(dtempl, find_group(dtempl, "all"), detgeom, 0, 0);
+ detgeom->top_group->parent = NULL;
return detgeom;
}