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

graphics_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/objects.h> 00017 00018 #ifndef lint 00019 static char rcsid[] = "$Header: /software/source//libraries/bicpl/Objects/graphics_io.c,v 1.8 2000/02/06 15:30:42 stever Exp $"; 00020 #endif 00021 00022 /* ----------------------------- MNI Header ----------------------------------- 00023 @NAME : input_graphics_file 00024 @INPUT : filename 00025 @OUTPUT : format 00026 n_objects 00027 object_list 00028 @RETURNS : OK or ERROR 00029 @DESCRIPTION: Inputs a file of graphics objects. 00030 @METHOD : 00031 @GLOBALS : 00032 @CALLS : 00033 @CREATED : 1993 David MacDonald 00034 @MODIFIED : 00035 ---------------------------------------------------------------------------- */ 00036 00037 public Status input_graphics_file( 00038 STRING filename, 00039 File_formats *format, 00040 int *n_objects, 00041 object_struct ***object_list ) 00042 { 00043 Status status; 00044 FILE *file; 00045 BOOLEAN eof; 00046 object_struct *object; 00047 STRING current_directory; 00048 00049 status = open_file_with_default_suffix( filename, "obj", READ_FILE, 00050 BINARY_FORMAT, &file ); 00051 00052 *n_objects = 0; 00053 00054 if( status == OK ) 00055 { 00056 current_directory = extract_directory( filename ); 00057 00058 do 00059 { 00060 status = input_object( current_directory, file, format, 00061 &object, &eof ); 00062 00063 if( status == OK && !eof ) 00064 add_object_to_list( n_objects, object_list, object ); 00065 00066 } while( status == OK && !eof ); 00067 00068 delete_string( current_directory ); 00069 } 00070 00071 if( status == OK ) 00072 status = close_file( file ); 00073 00074 return( status ); 00075 } 00076 00077 /* ----------------------------- MNI Header ----------------------------------- 00078 @NAME : output_graphics_file 00079 @INPUT : filename 00080 format 00081 n_objects 00082 object_list 00083 @OUTPUT : 00084 @RETURNS : OK or ERROR 00085 @DESCRIPTION: Writes a file of graphics objects. 00086 @METHOD : 00087 @GLOBALS : 00088 @CALLS : 00089 @CREATED : 1993 David MacDonald 00090 @MODIFIED : 00091 ---------------------------------------------------------------------------- */ 00092 00093 public Status output_graphics_file( 00094 STRING filename, 00095 File_formats format, 00096 int n_objects, 00097 object_struct *object_list[] ) 00098 { 00099 Status status; 00100 int i; 00101 FILE *file; 00102 00103 status = open_file_with_default_suffix( filename, "obj", WRITE_FILE, 00104 BINARY_FORMAT, &file ); 00105 00106 if( status == OK ) 00107 { 00108 for_less( i, 0, n_objects ) 00109 { 00110 if( status == OK ) 00111 status = output_object( file, format, object_list[i] ); 00112 } 00113 } 00114 00115 if( status == OK ) 00116 status = close_file( file ); 00117 00118 return( status ); 00119 } 00120 00121 /* ----------------------------- MNI Header ----------------------------------- 00122 @NAME : input_objects_any_format 00123 @INPUT : volume 00124 filename 00125 marker_colour \ 00126 marker_size these three used to set tag information 00127 marker_type / 00128 @OUTPUT : n_objects 00129 object_list 00130 @RETURNS : OK or ERROR 00131 @DESCRIPTION: Inputs a landmark file, a tag point file, or a graphics file, 00132 creating graphics objects. 00133 @METHOD : 00134 @GLOBALS : 00135 @CALLS : 00136 @CREATED : 1993 David MacDonald 00137 @MODIFIED : 00138 ---------------------------------------------------------------------------- */ 00139 00140 public Status input_objects_any_format( 00141 Volume volume, 00142 STRING filename, 00143 Colour marker_colour, 00144 Real marker_size, 00145 Marker_types marker_type, 00146 int *n_objects, 00147 object_struct **object_list[] ) 00148 { 00149 Status status; 00150 File_formats format; 00151 00152 if( filename_extension_matches(filename,get_default_landmark_file_suffix())) 00153 { 00154 status = input_landmark_file( volume, filename, 00155 marker_colour, marker_size, marker_type, 00156 n_objects, object_list ); 00157 } 00158 else if( filename_extension_matches(filename,get_default_tag_file_suffix())) 00159 { 00160 status = input_tag_objects_file( filename, 00161 marker_colour, marker_size, marker_type, 00162 n_objects, object_list ); 00163 } 00164 else 00165 { 00166 status = input_graphics_file( filename, &format, 00167 n_objects, object_list ); 00168 } 00169 00170 return( status ); 00171 }

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