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/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
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
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
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
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 }