aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2010-09-30 17:55:17 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:00 +0100
commitb493440b312b1d08b3f70277fe9b78ce33a8e033 (patch)
tree7a4aa4f0ba8dd423c433cfdeafdeeca4061e1107 /src
parent8679d7a1977239c98b0f296e9d5b71eb08e4434b (diff)
pattern_sim: Get image size from detector geometry
Diffstat (limited to 'src')
-rw-r--r--src/detector.c22
-rw-r--r--src/detector.h2
-rw-r--r--src/pattern_sim.c18
3 files changed, 33 insertions, 9 deletions
diff --git a/src/detector.c b/src/detector.c
index c5665ab2..86d806e3 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -202,6 +202,7 @@ struct detector *get_detector_geometry(const char *filename)
char **bits;
int i;
int reject;
+ int x, y, max_x, max_y;
fh = fopen(filename, "r");
if ( fh == NULL ) return NULL;
@@ -339,7 +340,10 @@ struct detector *get_detector_geometry(const char *filename)
}
reject = 0;
+ max_x = 0;
+ max_y = 0;
for ( i=0; i<det->n_panels; i++ ) {
+
STATUS("Panel %i, min_x = %i\n", i, det->panels[i].min_x);
if ( det->panels[i].min_x == -1 ) {
ERROR("Please specify the minimum x coordinate for"
@@ -397,7 +401,25 @@ struct detector *get_detector_geometry(const char *filename)
}
/* It's not a problem if "no_index" is still zero */
+ if ( det->panels[i].max_x > max_x ) {
+ max_x = det->panels[i].max_x;
+ }
+ if ( det->panels[i].max_y > max_y ) {
+ max_y = det->panels[i].max_y;
+ }
+
+ }
+
+ for ( x=0; x<=max_x; x++ ) {
+ for ( y=0; y<=max_y; y++ ) {
+ if ( find_panel(det, x, y) == NULL ) {
+ ERROR("Detector geometry invalid: contains gaps.\n");
+ reject = 1;
+ }
+ }
}
+ det->max_x = max_x;
+ det->max_y = max_y;
if ( reject ) return NULL;
diff --git a/src/detector.h b/src/detector.h
index 854a765a..f6b26c8c 100644
--- a/src/detector.h
+++ b/src/detector.h
@@ -38,6 +38,8 @@ struct detector
{
struct panel *panels;
int n_panels;
+ int max_x;
+ int max_y; /* Size of overall array needed, minus 1 */
};
extern struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys,
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index d39dea7b..371a4ef5 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -338,9 +338,16 @@ int main(int argc, char *argv[])
delete_items(items);
}
+ image.det = get_detector_geometry(geometry);
+ if ( image.det == NULL ) {
+ ERROR("Failed to read detector geometry from '%s'\n", geometry);
+ return 1;
+ }
+ free(geometry);
+
/* Define image parameters */
- image.width = 1024;
- image.height = 1024;
+ image.width = image.det->max_x + 1;
+ image.height = image.det->max_y + 1;
image.lambda = ph_en_to_lambda(eV_to_J(PHOTON_ENERGY)); /* Wavelength */
cell = load_cell_from_pdb(filename);
if ( cell == NULL ) {
@@ -352,13 +359,6 @@ int main(int argc, char *argv[])
image.f0 = 1.0;
image.f0_available = 1;
- image.det = get_detector_geometry(geometry);
- if ( image.det == NULL ) {
- ERROR("Failed to read detector geometry from '%s'\n", geometry);
- return 1;
- }
- free(geometry);
-
powder = calloc(image.width*image.height, sizeof(*powder));
/* Splurge a few useful numbers */