static BOOLEAN test_skiplist_integrity( skiplist_struct *skiplist ) { int i; update_struct update; BOOLEAN okay; for_less( i, 0, skiplist->level ) update.update[i] = skiplist->header->forward[i]; while( update.update[0] != NULL ) { i = 1; while( i < skiplist->level && update.update[0] == update.update[i] ) { update.update[i] = update.update[i]->forward[i]; ++i; } update.update[0] = update.update[0]->forward[0]; } okay = TRUE; for_less( i, 0, skiplist->level ) if( update.update[i] != NULL ) okay = FALSE; if( !okay ) handle_internal_error( "Skiplist integrity" ); return( okay ); }
BICAPI void initialize_skiplist( skiplist_struct *skiplist ) { int i; skiplist->level = 1; ALLOC_SKIP_STRUCT( skiplist->header, MAX_SKIP_LEVELS ); for_less( i, 0, MAX_SKIP_LEVELS ) skiplist->header->forward[i] = NULL; }
private Real evaluate_along_line( int n_parameters, Real parameters[], Real line_direction[], Real t, Real test_parameters[], Real (*function) ( Real [], void * ), void *function_data ) { int parm; for_less( parm, 0, n_parameters ) test_parameters[parm] = parameters[parm] + t * line_direction[parm]; return( (*function) ( test_parameters, function_data ) ); }
static void initialize_alloc_list( alloc_struct *alloc_list ) { int i; alloc_list->next_memory_threshold = MEMORY_DIFFERENCE; alloc_list->total_memory_allocated = 0; ALLOC_SKIP_STRUCT( alloc_list->header, MAX_SKIP_LEVELS ); skip_alloc_size += sizeof(skip_entry)+(MAX_SKIP_LEVELS-1) * sizeof(skip_entry *); alloc_list->level = 1; for_less( i, 0, MAX_SKIP_LEVELS ) alloc_list->header->forward[i] = (skip_entry *) 0; }
VIOAPI VIO_Status start_volume_input( VIO_STR filename, int n_dimensions, VIO_STR dim_names[], nc_type volume_nc_data_type, VIO_BOOL volume_signed_flag, VIO_Real volume_voxel_min, VIO_Real volume_voxel_max, VIO_BOOL create_volume_flag, VIO_Volume *volume, minc_input_options *options, volume_input_struct *input_info ) { VIO_Status status; int d; VIO_STR expanded_filename; minc_input_options default_options; status = VIO_OK; if( options == (minc_input_options *) NULL ) { set_default_minc_input_options( &default_options ); options = &default_options; } if( create_volume_flag || *volume == (VIO_Volume) NULL ) { if( n_dimensions < 1 || n_dimensions > VIO_MAX_DIMENSIONS ) { n_dimensions = VIO_MAX_DIMENSIONS; } if( dim_names == (VIO_STR *) NULL ) dim_names = get_default_dim_names( n_dimensions ); *volume = create_volume( n_dimensions, dim_names, volume_nc_data_type, volume_signed_flag, volume_voxel_min, volume_voxel_max ); } else if( n_dimensions != get_volume_n_dimensions( *volume ) && volume_is_alloced( *volume ) ) { free_volume_data( *volume ); } expanded_filename = expand_filename( filename ); if (filename_extension_matches( expanded_filename, FREE_ENDING ) ) { input_info->file_format = FREE_FORMAT; } #ifdef LIBMINC_NIFTI_SUPPORT else if (filename_extension_matches( expanded_filename, "mgh" ) || filename_extension_matches( expanded_filename, "mgz" ) ) { input_info->file_format = MGH_FORMAT; /* FreeSurfer */ } else if (filename_extension_matches( expanded_filename, "nii" ) || filename_extension_matches( expanded_filename, "hdr" )) { input_info->file_format = NII_FORMAT; /* NIfTI-1 */ } else if (filename_extension_matches( expanded_filename, "nhdr" ) || filename_extension_matches( expanded_filename, "nrrd" )) { input_info->file_format = NRRD_FORMAT; /* NRRD */ } #endif /*LIBMINC_NIFTI_SUPPORT*/ else { #if defined(HAVE_MINC1) && defined(HAVE_MINC2) if(options->prefer_minc2_api) { #endif #if defined(HAVE_MINC2) input_info->file_format = MNC2_FORMAT; #endif #if defined(HAVE_MINC1) && defined(HAVE_MINC2) } else { #endif #ifdef HAVE_MINC1 input_info->file_format = MNC_FORMAT; #endif #if defined(HAVE_MINC1) && defined(HAVE_MINC2) } #endif } switch( input_info->file_format ) { #ifdef HAVE_MINC1 case MNC_FORMAT: if( !file_exists( expanded_filename ) ) { file_exists_as_compressed( expanded_filename, &expanded_filename ); } input_info->minc_file = initialize_minc_input( expanded_filename, *volume, options ); if( input_info->minc_file == (Minc_file) NULL ) status = VIO_ERROR; else { for_less( d, 0, VIO_MAX_DIMENSIONS ) input_info->axis_index_from_file[d] = d; } break; #endif /*HAVE_MINC1*/ #ifdef HAVE_MINC2 case MNC2_FORMAT: input_info->minc_file = initialize_minc2_input( expanded_filename, *volume, options ); if( input_info->minc_file == (Minc_file) NULL ) status = VIO_ERROR; else { for_less( d, 0, VIO_MAX_DIMENSIONS ) input_info->axis_index_from_file[d] = d; } break; #endif /*HAVE_MINC2*/ case FREE_FORMAT: status = initialize_free_format_input( expanded_filename, *volume, input_info ); break; #ifdef LIBMINC_NIFTI_SUPPORT case MGH_FORMAT: status = initialize_mgh_format_input( expanded_filename, *volume, input_info ); break; case NII_FORMAT: status = initialize_nifti_format_input( expanded_filename, *volume, input_info ); break; case NRRD_FORMAT: status = initialize_nrrd_format_input( expanded_filename, *volume, input_info ); break; #endif /*LIBMINC_NIFTI_SUPPORT*/ default: /*Unsupported file format*/ status = VIO_ERROR; break; } if( status != VIO_OK && create_volume_flag ) delete_volume( *volume ); delete_string( expanded_filename ); return( status ); }