Mercurial > hg > minc-tools
changeset 54:22d0cb5dac63
*** empty log message ***
author | david <david> |
---|---|
date | Thu, 07 Jan 1993 15:02:33 +0000 |
parents | 4bef3da8d9ec |
children | a23deb019f17 |
files | volume_io/Volumes/input_volume.c |
diffstat | 1 files changed, 54 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/volume_io/Volumes/input_volume.c +++ b/volume_io/Volumes/input_volume.c @@ -8,11 +8,15 @@ volume_struct *volume ) { Status status; - int x, y, z; - Volume_type *x_strip; + char name[MAX_NC_NAME]; + int x, y, z, volume_axis; + double slice_separation[N_DIMENSIONS]; + double start_position[N_DIMENSIONS]; + double direction_cosines[N_DIMENSIONS][N_DIMENSIONS]; + Volume_type *image; int axis; long length; - int icv, cdfid, img; + int icv, cdfid, img, dimvar; int ndims, dim[MAX_VAR_DIMS]; long start[3], count[3]; @@ -41,42 +45,73 @@ for_less( axis, 0, ndims ) { - (void) ncdiminq( cdfid, dim[axis], (char *) 0, &length ); - volume->sizes[2-axis] = length; + volume_axis = 2 - axis; + + (void) ncdiminq( cdfid, dim[axis], name, &length ); + volume->sizes[volume_axis] = length; + + ncopts = 0; + dimvar = ncvarid( cdfid, name ); + if( dimvar != MI_ERROR ) + { + if( miattget1( cdfid, dimvar, MIstep, NC_DOUBLE, + (void *) &slice_separation[volume_axis] ) == MI_ERROR ) + { + slice_separation[volume_axis] = 1.0; + } + + if( miattget1( cdfid, dimvar, MIstart, NC_DOUBLE, + (void *) &start_position[volume_axis] ) == MI_ERROR ) + { + start_position[volume_axis] = 0.0; + } + + if( miattget( cdfid, dimvar, MIstart, NC_DOUBLE, N_DIMENSIONS, + (void *) direction_cosines[volume_axis], (int *) 0 ) + == MI_ERROR ) + { + direction_cosines[volume_axis][0] = 0.0; + direction_cosines[volume_axis][1] = 0.0; + direction_cosines[volume_axis][2] = 0.0; + direction_cosines[volume_axis][volume_axis] = 1.0; + } + } + ncopts = NC_VERBOSE | NC_FATAL; } ALLOC3D( status, volume->data, volume->sizes[X], volume->sizes[Y], volume->sizes[Z] ); - ALLOC( status, x_strip, volume->sizes[X] ); + ALLOC( status, image, volume->sizes[X] * volume->sizes[Y] ); for_less( z, 0, volume->sizes[Z] ) { + start[0] = z; + start[1] = 0; + start[2] = 0; + count[0] = 1; + count[1] = volume->sizes[Y]; + count[2] = volume->sizes[X]; + + (void) miicv_get( icv, start, count, (void *) image ); + for_less( y, 0, volume->sizes[Y] ) { - start[0] = z; - start[1] = y; - start[2] = 0; - count[0] = 1; - count[1] = 1; - count[2] = volume->sizes[X]; - (void) miicv_get( icv, start, count, (void *) x_strip ); - for_less( x, 0, volume->sizes[X] ) { - volume->data[x][y][z] = x_strip[x]; + volume->data[x][y][z] = image[IJ(y,x,volume->sizes[X])]; } } } - FREE( status, x_strip ); + FREE( status, image ); (void) ncclose( cdfid ); (void) miicv_free( icv ); - volume->thickness[X] = 1.0; - volume->thickness[Y] = 1.0; - volume->thickness[Z] = 1.0; + volume->thickness[X] = (Real) slice_separation[X]; + volume->thickness[Y] = (Real) slice_separation[Y]; + volume->thickness[Z] = (Real) slice_separation[Z]; volume->value_scale = 1.0; volume->value_translation = 0.0;