From 8bb2c7e3f5f4cfe9793256c009f62b0289607332 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 24 Sep 2010 18:25:49 +0200 Subject: Move stream handling functions to a separate module --- src/cubeit.c | 70 +----------------------------------------------------------- 1 file changed, 1 insertion(+), 69 deletions(-) (limited to 'src/cubeit.c') diff --git a/src/cubeit.c b/src/cubeit.c index f6ff2c67..4bc466a6 100644 --- a/src/cubeit.c +++ b/src/cubeit.c @@ -31,6 +31,7 @@ #include "diffraction.h" #include "render.h" #include "symmetry.h" +#include "stream.h" #define MAX_THREADS (256) @@ -383,75 +384,6 @@ static void write_slice(const char *filename, double *vals, int z, } -static UnitCell *read_orientation_matrix(FILE *fh) -{ - float u, v, w; - struct rvec as, bs, cs; - UnitCell *cell; - char line[1024]; - - if ( fgets(line, 1023, fh) == NULL ) return NULL; - if ( sscanf(line, "astar = %f %f %f", &u, &v, &w) != 3 ) { - ERROR("Couldn't read a-star\n"); - return NULL; - } - as.u = u*1e9; as.v = v*1e9; as.w = w*1e9; - if ( fgets(line, 1023, fh) == NULL ) return NULL; - if ( sscanf(line, "bstar = %f %f %f", &u, &v, &w) != 3 ) { - ERROR("Couldn't read b-star\n"); - return NULL; - } - bs.u = u*1e9; bs.v = v*1e9; bs.w = w*1e9; - if ( fgets(line, 1023, fh) == NULL ) return NULL; - if ( sscanf(line, "cstar = %f %f %f", &u, &v, &w) != 3 ) { - ERROR("Couldn't read c-star\n"); - return NULL; - } - cs.u = u*1e9; cs.v = v*1e9; cs.w = w*1e9; - cell = cell_new_from_axes(as, bs, cs); - - return cell; -} - - -static int find_chunk(FILE *fh, UnitCell **cell, char **filename) -{ - char line[1024]; - char *rval = NULL; - - do { - - rval = fgets(line, 1023, fh); - if ( rval == NULL ) continue; - - chomp(line); - - if ( strncmp(line, "Reflections from indexing", 25) != 0 ) { - continue; - } - - *filename = strdup(line+29); - - /* Skip two lines (while checking for errors) */ - rval = fgets(line, 1023, fh); - if ( rval == NULL ) continue; - rval = fgets(line, 1023, fh); - if ( rval == NULL ) continue; - - *cell = read_orientation_matrix(fh); - if ( *cell == NULL ) { - STATUS("Got filename but no cell for %s\n", *filename); - continue; - } - - return 0; - - } while ( rval != NULL ); - - return 1; -} - - static void add_to_mean(UnitCell *cell, double *ast, double *bst, double *cst, double *alst, double *best, double *gast) { -- cgit v1.2.3