aboutsummaryrefslogtreecommitdiff
path: root/src/index.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-02-02 18:12:29 +0100
committerThomas White <taw@physics.org>2010-02-02 18:12:29 +0100
commit7df59f9bc7acedb5f8aa01ad12f2f22d271a0f58 (patch)
tree9bc98ff31e5f37068169cf82cd645877ce22ea5f /src/index.c
parent9fed7cd780eb4912602f76323a0430a48cfd0834 (diff)
Tidy up options
This also simplifies quite a lot of code
Diffstat (limited to 'src/index.c')
-rw-r--r--src/index.c52
1 files changed, 41 insertions, 11 deletions
diff --git a/src/index.c b/src/index.c
index a20ad3a5..6d896820 100644
--- a/src/index.c
+++ b/src/index.c
@@ -72,10 +72,41 @@ int map_position(struct image *image, double x, double y,
}
-void index_pattern(struct image *image, int no_index, int use_dirax)
+static void write_drx(struct image *image)
{
+ FILE *fh;
int i;
+ STATUS("Writing xfel.drx file. Remember that it uses units of "
+ "reciprocal Angstroms!\n");
+
+ fh = fopen("xfel.drx", "w");
+ if ( !fh ) {
+ ERROR("Couldn't open temporary file xfel.drx\n");
+ return;
+ }
+ fprintf(fh, "%f\n", 0.5); /* Lie about the wavelength. */
+
+ for ( i=0; i<image_feature_count(image->features); i++ ) {
+
+ struct imagefeature *f;
+
+ f = image_get_feature(image->features, i);
+ if ( f == NULL ) continue;
+
+ fprintf(fh, "%10f %10f %10f %8f\n",
+ f->rx/1e10, f->ry/1e10, f->rz/1e10, 1.0);
+
+ }
+ fclose(fh);
+}
+
+
+void index_pattern(struct image *image, IndexingMethod indm)
+{
+ int i;
+ UnitCell *new_cell = NULL;
+
/* Map positions to 3D */
for ( i=0; i<image_feature_count(image->features); i++ ) {
@@ -95,17 +126,16 @@ void index_pattern(struct image *image, int no_index, int use_dirax)
}
}
- if ( use_dirax ) {
-
- UnitCell *new_cell;
-
- run_dirax(image, no_index);
+ write_drx(image);
- new_cell = match_cell(image->indexed_cell,
- image->molecule->cell);
+ /* Index (or not) as appropriate */
+ if ( indm == INDEXING_NONE ) return;
+ if ( indm == INDEXING_DIRAX ) run_dirax(image);
- if ( new_cell != NULL ) image->indexed_cell = new_cell;
-
- return;
+ new_cell = match_cell(image->indexed_cell,
+ image->molecule->cell);
+ if ( new_cell != NULL ) {
+ free(image->indexed_cell);
+ image->indexed_cell = new_cell;
}
}