00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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
00065
00066
00067
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 }