changeset 1001:82e597e0ee28

*** empty log message ***
author david <david>
date Tue, 07 May 1996 13:22:38 +0000
parents d47128626f36
children fe50f0e1be81
files volume_io/Volumes/evaluate.c volume_io/Volumes/output_mnc.c
diffstat 2 files changed, 87 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/volume_io/Volumes/evaluate.c
+++ b/volume_io/Volumes/evaluate.c
@@ -15,7 +15,7 @@
 #include  <internal_volume_io.h>
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/evaluate.c,v 1.29 1996-04-11 19:01:29 david Exp $";
+static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/evaluate.c,v 1.30 1996-05-07 13:22:38 david Exp $";
 #endif
 
 /* ----------------------------- MNI Header -----------------------------------
@@ -96,7 +96,7 @@
 {
     Real   voxel;
 
-    GET_VOXEL( voxel, volume, v0, v1, v2, v3, v4 );
+    GET_VOXEL_TYPED( voxel, (Real), volume, v0, v1, v2, v3, v4 );
 
     return( voxel );
 }
@@ -205,7 +205,7 @@
     if( data_type != FLOAT &&
         data_type != DOUBLE )
     {
-        voxel = ROUND( voxel );
+        voxel = (Real) ROUND( voxel );
     }
 
     set_volume_voxel_value( volume, v0, v1, v2, v3, v4, voxel );
@@ -259,14 +259,14 @@
         j = (int) y;
         k = (int) z;
 
-        GET_VOXEL_3D( c000, volume, i  , j  , k );
-        GET_VOXEL_3D( c001, volume, i  , j  , k+1 );
-        GET_VOXEL_3D( c010, volume, i  , j+1, k );
-        GET_VOXEL_3D( c011, volume, i  , j+1, k+1 );
-        GET_VOXEL_3D( c100, volume, i+1, j  , k );
-        GET_VOXEL_3D( c101, volume, i+1, j  , k+1 );
-        GET_VOXEL_3D( c110, volume, i+1, j+1, k );
-        GET_VOXEL_3D( c111, volume, i+1, j+1, k+1 );
+        GET_VOXEL_3D_TYPED( c000, (Real), volume, i  , j  , k );
+        GET_VOXEL_3D_TYPED( c001, (Real), volume, i  , j  , k+1 );
+        GET_VOXEL_3D_TYPED( c010, (Real), volume, i  , j+1, k );
+        GET_VOXEL_3D_TYPED( c011, (Real), volume, i  , j+1, k+1 );
+        GET_VOXEL_3D_TYPED( c100, (Real), volume, i+1, j  , k );
+        GET_VOXEL_3D_TYPED( c101, (Real), volume, i+1, j  , k+1 );
+        GET_VOXEL_3D_TYPED( c110, (Real), volume, i+1, j+1, k );
+        GET_VOXEL_3D_TYPED( c111, (Real), volume, i+1, j+1, k+1 );
     }
     else
     {
@@ -284,7 +284,8 @@
                 j + dy >= 0 && j + dy < sizes[1] &&
                 k + dz >= 0 && k + dz < sizes[2] )
             {
-                GET_VOXEL_3D( coefs[dx][dy][dz], volume, i+dx, j+dy, k+dz );
+                GET_VOXEL_3D_TYPED( coefs[dx][dy][dz], (Real),
+                                    volume, i+dx, j+dy, k+dz );
             }
             else
                 coefs[dx][dy][dz] = outside_value;
@@ -571,7 +572,7 @@
     case 1:
         for_less( v0, start0, end0 )
         {
-            GET_VALUE_1D( coefs[ind], volume, v0 );
+            GET_VALUE_1D_TYPED( coefs[ind], (Real), volume, v0 );
             ind += inc0;
         }
         break;
@@ -581,7 +582,7 @@
         {
             for_less( v1, start1, end1 )
             {
-                GET_VALUE_2D( coefs[ind], volume, v0, v1 );
+                GET_VALUE_2D_TYPED( coefs[ind], (Real), volume, v0, v1 );
                 ind += inc1;
             }
             ind += inc0;
@@ -595,7 +596,7 @@
             {
                 for_less( v2, start2, end2 )
                 {
-                    GET_VALUE_3D( coefs[ind], volume, v0, v1, v2 );
+                    GET_VALUE_3D_TYPED( coefs[ind], (Real), volume, v0, v1, v2);
                     ind += inc2;
                 }
                 ind += inc1;
@@ -613,7 +614,8 @@
                 {
                     for_less( v3, start3, end3 )
                     {
-                        GET_VALUE_4D( coefs[ind], volume, v0, v1, v2, v3 );
+                        GET_VALUE_4D_TYPED( coefs[ind], (Real),
+                                            volume, v0, v1, v2, v3 );
                         ind += inc3;
                     }
                     ind += inc2;
@@ -635,8 +637,8 @@
                     {
                         for_less( v4, start4, end4 )
                         {
-                            GET_VALUE_5D( coefs[ind], volume,
-                                          v0, v1, v2, v3, v4 );
+                            GET_VALUE_5D_TYPED( coefs[ind], (Real), volume,
+                                                v0, v1, v2, v3, v4 );
                             ind += inc4;
                         }
                         ind += inc3;
@@ -836,7 +838,7 @@
             interp_dims[n_interp_dims] = d;
             pos = voxel[d] - bound;
             start[d] =       FLOOR( pos );
-            fraction[n_interp_dims] = pos - start[d];
+            fraction[n_interp_dims] = pos - (Real) start[d];
 
             if( voxel[d] == (Real) sizes[d] - 1.0 - bound )
             {
--- a/volume_io/Volumes/output_mnc.c
+++ b/volume_io/Volumes/output_mnc.c
@@ -16,7 +16,7 @@
 #include  <minc.h>
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/output_mnc.c,v 1.44 1996-02-28 16:03:58 david Exp $";
+static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/output_mnc.c,v 1.45 1996-05-07 13:24:50 david Exp $";
 #endif
 
 #define  INVALID_AXIS   -1
@@ -125,7 +125,7 @@
 
     for_less( i, 0, 3 )
     {
-        if( Vector_coord(axes[i],i) < 0.0 )
+        if( Vector_coord(axes[i],i) < 0.0f )
         {
             SCALE_VECTOR( axes[i], axes[i], -1.0 );
             separation[i] *= -1.0;
@@ -135,7 +135,7 @@
     for_less( i, 0, 3 )
     {
         for_less( j, 0, 3 )
-            dir_cosines[i][j] = Vector_coord(axes[i],j);
+            dir_cosines[i][j] = (Real) Vector_coord(axes[i],j);
     }
 
     make_identity_transform( &t );
@@ -360,10 +360,11 @@
 
     for_less( d, 0, n_dimensions )
     {
-        file->sizes_in_file[d] = sizes[d];
+        file->sizes_in_file[d] = (long) sizes[d];
         file->indices[d] = 0;
         file->dim_names[d] = create_string( dim_names[d] );
-        dim_vars[d] = ncdimdef( file->cdfid, file->dim_names[d], sizes[d] );
+        dim_vars[d] = ncdimdef( file->cdfid, file->dim_names[d],
+                                (long) sizes[d] );
     }
 
     if( output_world_transform( file, voxel_to_world_transform )
@@ -498,7 +499,7 @@
     int         src_cdfid,
     STRING      history_string )
 {
-    int     src_img_var, varid, n_excluded, excluded_vars[10];
+    int     src_img_var, varid, n_excluded, excluded_vars[10], ret;
     int     i, src_min_id, src_max_id, src_root_id;
     Status  status;
     STRING  excluded_list[] = {
@@ -579,11 +580,24 @@
     if( history_string != NULL )
         status = add_minc_history( file, history_string );
 
-    (void) ncendef( file->cdfid );
-    file->end_def_done = TRUE;
+    if( status == OK )
+    {
+        ret = ncendef( file->cdfid );
 
-    (void) micopy_all_var_values( src_cdfid, file->cdfid,
-                                  n_excluded, excluded_vars );
+        if( ret == MI_ERROR )
+        {
+            print_error( "Error outputting volume: possibly disk full?\n" );
+            status = ERROR;
+        }
+    }
+
+    if( status == OK )
+    {
+        file->end_def_done = TRUE;
+
+        (void) micopy_all_var_values( src_cdfid, file->cdfid,
+                                      n_excluded, excluded_vars );
+    }
 
     ncopts = NC_VERBOSE | NC_FATAL;
 
@@ -728,10 +742,10 @@
 @MODIFIED   : 
 ---------------------------------------------------------------------------- */
 
-private  void  check_minc_output_variables(
+private  Status  check_minc_output_variables(
     Minc_file   file )
 {
-    int               d, axis;
+    int               d, axis, ret;
     long              start_index, mindex[MAX_VAR_DIMS];
     Real              voxel_min, voxel_max, real_min, real_max;
     double            dim_value;
@@ -741,8 +755,16 @@
     {
         /* --- Get into data mode */
 
-        (void) ncendef( file->cdfid );
+        ncopts = NC_VERBOSE;
+        ret = ncendef( file->cdfid );
+        ncopts = NC_VERBOSE | NC_FATAL;
         file->end_def_done = TRUE;
+
+        if( ret == MI_ERROR )
+        {
+            print_error( "Error outputting volume: possibly disk full?\n" );
+            return( ERROR );
+        }
     }
 
     if( !file->variables_written )
@@ -767,7 +789,8 @@
 
         file->minc_icv = miicv_create();
 
-        (void) miicv_setint( file->minc_icv, MI_ICV_TYPE, volume->nc_data_type);
+        (void) miicv_setint( file->minc_icv, MI_ICV_TYPE,
+                             (int) volume->nc_data_type);
         (void) miicv_setstr( file->minc_icv, MI_ICV_SIGN,
                              volume->signed_flag ? MI_SIGNED : MI_UNSIGNED );
         (void) miicv_setint( file->minc_icv, MI_ICV_DO_NORM, TRUE );
@@ -809,6 +832,8 @@
         }
         ncopts = NC_VERBOSE | NC_FATAL;
     }
+
+    return( OK );
 }
 
 /* ----------------------------- MNI Header -----------------------------------
@@ -825,12 +850,16 @@
 @MODIFIED   : 
 ---------------------------------------------------------------------------- */
 
-public  void  set_minc_output_random_order(
+public  Status  set_minc_output_random_order(
     Minc_file   file )
 {
-    check_minc_output_variables( file );
+    Status  status;
+
+    status = check_minc_output_variables( file );
 
     file->outputting_in_order = FALSE;
+
+    return( status );
 }
 
 /* ----------------------------- MNI Header -----------------------------------
@@ -876,7 +905,10 @@
     Status           status;
     multidim_array   buffer_array;
 
-    check_minc_output_variables( file );
+    status = check_minc_output_variables( file );
+
+    if( status != OK )
+        return( status );
 
     n_file_dims = file->n_file_dimensions;
     expected_ind = n_array_dims-1;
@@ -904,7 +936,7 @@
             array_counts[ind] = file_count[file_ind];
 
             if( !non_full_size_found &&
-                file_count[file_ind] < file->sizes_in_file[file_ind] )
+                (long) file_count[file_ind] < file->sizes_in_file[file_ind] )
                 non_full_size_found = TRUE;
             else if( non_full_size_found && file_count[file_ind] > 1 )
                 direct_from_array = FALSE;
@@ -1137,7 +1169,7 @@
     long        file_start[] )
 {
     Status            status;
-    int               i, d, n_volume_dims, sizes[MAX_DIMENSIONS];
+    int               d, n_volume_dims, sizes[MAX_DIMENSIONS];
     int               slab_size, n_slab, this_count;
     int               vol_index, step, n_steps, n_range_dims;
     int               to_volume_index[MAX_VAR_DIMS];
@@ -1149,7 +1181,10 @@
     BOOLEAN           increment;
     progress_struct   progress;
 
-    check_minc_output_variables( file );
+    status = check_minc_output_variables( file );
+
+    if( status != OK )
+        return( status );
 
     /* --- check if dimension name correspondence between volume and file */
 
@@ -1202,7 +1237,7 @@
             this_count = 1;
         }
 
-        if( file_start[d] < 0 || file_start[d] + this_count >
+        if( file_start[d] < 0 || file_start[d] + (long) this_count >
             file->sizes_in_file[d] )
         {
             print_error( "output_the_volume:  invalid minc file position.\n" );
@@ -1218,6 +1253,7 @@
     if( file->image_range[0] >= file->image_range[1] )
     {
         long     n_ranges, range_start[MAX_VAR_DIMS], range_count[MAX_VAR_DIMS];
+        long     r;
         double   *image_range;
 
         n_range_dims = file->n_file_dimensions - 2;
@@ -1236,8 +1272,8 @@
             }
             else
             {
-                n_ranges *= volume_count[vol_index];
-                range_count[d] = volume_count[vol_index];
+                n_ranges *= (long) volume_count[vol_index];
+                range_count[d] = (long) volume_count[vol_index];
                 range_start[d] = 0;
             }
         }
@@ -1246,15 +1282,15 @@
 
         ALLOC( image_range, n_ranges );
 
-        for_less( i, 0, n_ranges )
-            image_range[i] = real_min;
+        for_less( r, 0, n_ranges )
+            image_range[r] = real_min;
 
         (void) mivarput( file->minc_icv, file->min_id,
                          range_start, range_count,
                          NC_DOUBLE, MI_UNSIGNED, (void *) image_range );
 
-        for_less( i, 0, n_ranges )
-            image_range[i] = real_max;
+        for_less( r, 0, n_ranges )
+            image_range[r] = real_max;
 
         (void) mivarput( file->minc_icv, file->max_id,
                          range_start, range_count,
@@ -1315,7 +1351,7 @@
             if( vol_index == INVALID_AXIS || n_slab >= file->n_slab_dims )
                 count[d] = 1;
             else
-                count[d] = volume_count[vol_index];
+                count[d] = (long) volume_count[vol_index];
 
             if( vol_index != INVALID_AXIS )
                 ++n_slab;
@@ -1337,7 +1373,8 @@
             if( vol_index != INVALID_AXIS && n_slab >= file->n_slab_dims )
             {
                 ++file_indices[d];
-                if( file_indices[d] < file_start[d] + volume_count[vol_index] )
+                if( file_indices[d] <
+                    file_start[d] + (long) volume_count[vol_index] )
                     increment = FALSE;
                 else
                     file_indices[d] = file_start[d];