Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

col_code_io.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- 00002 @COPYRIGHT : 00003 Copyright 1993,1994,1995 David MacDonald, 00004 McConnell Brain Imaging Centre, 00005 Montreal Neurological Institute, McGill University. 00006 Permission to use, copy, modify, and distribute this 00007 software and its documentation for any purpose and without 00008 fee is hereby granted, provided that the above copyright 00009 notice appear in all copies. The author and McGill University 00010 make no representations about the suitability of this 00011 software for any purpose. It is provided "as is" without 00012 express or implied warranty. 00013 ---------------------------------------------------------------------------- */ 00014 00015 #include <volume_io/internal_volume_io.h> 00016 #include <bicpl/vols.h> 00017 00018 #ifndef lint 00019 static char rcsid[] = "$Header: /software/source//libraries/bicpl/Volumes/col_code_io.c,v 1.5 2000/12/15 19:55:06 stever Exp $"; 00020 #endif 00021 00022 #define DEFAULT_USER_DEFINED_COLOUR_CODE_SUFFIX "ccd" 00023 00024 public STRING get_default_user_def_colour_code_suffix( void ) 00025 { 00026 return( DEFAULT_USER_DEFINED_COLOUR_CODE_SUFFIX ); 00027 } 00028 00029 public Status input_user_defined_colour_coding( 00030 colour_coding_struct *colour_coding, 00031 STRING filename ) 00032 { 00033 Status status; 00034 FILE *file; 00035 Real pos, *positions; 00036 Colour col, *colours; 00037 STRING line; 00038 int n_colours; 00039 00040 if( open_file_with_default_suffix( filename, 00041 get_default_user_def_colour_code_suffix(), 00042 READ_FILE, ASCII_FORMAT, &file ) != OK ) 00043 return( ERROR ); 00044 00045 n_colours = 0; 00046 colours = NULL; 00047 positions = NULL; 00048 00049 status = OK; 00050 while( input_real( file, &pos ) == OK ) 00051 { 00052 if( input_line( file, &line ) != OK ) 00053 { 00054 print_error( "Error loading user defined colour coding.\n" ); 00055 status = ERROR; 00056 break; 00057 } 00058 00059 col = convert_string_to_colour( line ); 00060 00061 delete_string( line ); 00062 00063 ADD_ELEMENT_TO_ARRAY( colours, n_colours, col, DEFAULT_CHUNK_SIZE ); 00064 /* n_colours is the number of elements currently in the array. 00065 A side-effect of the macro ADD_ELEMENT_TO_ARRAY is that n_colours is 00066 incremented, so we have to decrement it before using it as the index 00067 for the second array. */ 00068 --n_colours; 00069 ADD_ELEMENT_TO_ARRAY( positions, n_colours, pos, DEFAULT_CHUNK_SIZE ); 00070 } 00071 00072 (void) close_file( file ); 00073 00074 if( status == OK && 00075 !define_colour_coding_user_defined( colour_coding, 00076 n_colours, colours, positions, RGB_SPACE ) ) 00077 { 00078 status = ERROR; 00079 } 00080 00081 if( n_colours > 0 ) 00082 { 00083 FREE( colours ); 00084 FREE( positions ); 00085 } 00086 00087 return( status ); 00088 }

Generated on Wed Jul 28 09:10:56 2004 for BICPL by doxygen 1.3.7