diff options
author | Thomas White <taw@physics.org> | 2010-03-17 11:35:04 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-03-17 11:35:04 +0100 |
commit | f38be837bd33dfc4d98d251b2e81d5fa555a4f5c (patch) | |
tree | 283e8886519dd42c87b25436a897c15bd045d926 /src/index.c | |
parent | 353a4224b3951be76bbc19bc043d24bfaf0590f6 (diff) |
Attempt to match multiple cells
Diffstat (limited to 'src/index.c')
-rw-r--r-- | src/index.c | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/index.c b/src/index.c index 713380e7..155e11e4 100644 --- a/src/index.c +++ b/src/index.c @@ -61,7 +61,6 @@ void index_pattern(struct image *image, IndexingMethod indm, int no_match, int verbose) { int i; - UnitCell *new_cell = NULL; int nc = 0; /* Map positions to 3D */ @@ -83,27 +82,52 @@ void index_pattern(struct image *image, IndexingMethod indm, int no_match, write_drx(image); + image->ncells = 0; + /* Index (or not) as appropriate */ if ( indm == INDEXING_NONE ) return; if ( indm == INDEXING_DIRAX ) run_dirax(image); - if ( image->indexed_cell == NULL ) { - STATUS("No cell found.\n"); + if ( image->ncells == 0 ) { + STATUS("No candidate cells found.\n"); + return; + } + + if ( no_match ) { + image->indexed_cell = image->candidate_cells[0]; + if ( verbose ) { + STATUS("--------------------\n"); + STATUS("The indexed cell (matching not performed):\n"); + cell_print(image->indexed_cell); + STATUS("--------------------\n"); + } return; - } else if ( verbose ) { - STATUS("--------------------\n"); - STATUS("The indexed cell (before matching):\n"); - cell_print(image->indexed_cell); - STATUS("--------------------\n"); } - if ( !no_match ) { - new_cell = match_cell(image->indexed_cell, + for ( i=0; i<image->ncells; i++ ) { + + UnitCell *new_cell = NULL; + + if ( verbose ) { + STATUS("--------------------\n"); + STATUS("Candidate cell %i (before matching):\n", i); + cell_print(image->candidate_cells[i]); + STATUS("--------------------\n"); + } + + new_cell = match_cell(image->candidate_cells[i], image->molecule->cell, verbose); - free(image->indexed_cell); image->indexed_cell = new_cell; if ( new_cell == NULL ) { - STATUS("Cell found, but not matched.\n"); + STATUS("Cell %i not matched.\n", i); + } else { + goto done; } + + } + +done: + for ( i=0; i<image->ncells; i++ ) { + free(image->candidate_cells[i]); } } |