aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
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
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')
-rw-r--r--libcrystfel/src/datatemplate.c16
-rw-r--r--libcrystfel/src/detgeom.c4
-rw-r--r--libcrystfel/src/detgeom.h9
3 files changed, 23 insertions, 6 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;
}
diff --git a/libcrystfel/src/detgeom.c b/libcrystfel/src/detgeom.c
index 7f458343..988d3f28 100644
--- a/libcrystfel/src/detgeom.c
+++ b/libcrystfel/src/detgeom.c
@@ -199,7 +199,9 @@ static void detgeom_show_group(const struct detgeom_panel_group *group, int leve
return;
}
- STATUS("%s\n", group->name);
+ STATUS("%s (level %i, index %i)\n", group->name,
+ group->hierarchy_level,
+ group->member_index);
for ( i=0; i<group->n_children; i++ ) {
detgeom_show_group(group->children[i], level+1);
diff --git a/libcrystfel/src/detgeom.h b/libcrystfel/src/detgeom.h
index 0b37e9f1..917b6bd3 100644
--- a/libcrystfel/src/detgeom.h
+++ b/libcrystfel/src/detgeom.h
@@ -83,6 +83,9 @@ struct detgeom_panel
int w;
int h;
/*@}*/
+
+ /** \name Leaf group containing this panel (only) */
+ const struct detgeom_panel_group *group;
};
@@ -91,8 +94,12 @@ struct detgeom_panel_group
char *name;
int n_children;
+ struct detgeom_panel_group *parent;
+ int hierarchy_level;
+ int member_index;
+
/* If n_children > 0, here are the child groups */
- const struct detgeom_panel_group **children;
+ struct detgeom_panel_group **children;
/* If n_children == 0, this is a leaf node, so: */
struct detgeom_panel *panel;