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/trans.h>
00017
00018
#ifndef lint
00019
static char rcsid[] =
"$Header: /software/source//libraries/bicpl/Transforms/transform_io.c,v 1.8 2000/02/06 15:30:51 stever Exp $";
00020
#endif
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 public Status
write_transform_file(
00038 STRING filename,
00039 STRING comments,
00040 Transform *transform )
00041 {
00042 Status status;
00043 FILE *file;
00044 General_transform gen_transform;
00045
00046 create_linear_transform( &gen_transform, transform );
00047
00048 status = open_file_with_default_suffix( filename,
"xfm",
00049 WRITE_FILE, ASCII_FORMAT, &file );
00050
00051
if( status == OK )
00052 {
00053 status = output_transform( file, filename, NULL, comments,
00054 &gen_transform );
00055
00056 (
void) close_file( file );
00057 }
00058
00059 delete_general_transform( &gen_transform );
00060
00061
return( status );
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 public Status
read_transform_file(
00078 STRING filename,
00079 Transform *transform )
00080 {
00081 Status status;
00082 FILE *file;
00083 Transform *lin_trans;
00084 General_transform gen_transform;
00085
00086 status = open_file_with_default_suffix( filename,
"xfm",
00087 READ_FILE, ASCII_FORMAT, &file );
00088
00089
if( status == OK )
00090 {
00091
if( input_transform( file, filename, &gen_transform ) != OK )
00092 status = ERROR;
00093
00094 (
void) close_file( file );
00095 }
00096
00097
if( status == OK && get_transform_type(&gen_transform) != LINEAR )
00098 {
00099 print(
"File %s does not contain a linear transform.\n", filename );
00100 status = ERROR;
00101 }
00102
00103
if( status == OK )
00104 {
00105 lin_trans = get_linear_transform_ptr( &gen_transform );
00106 *transform = *lin_trans;
00107 }
00108
00109 delete_general_transform( &gen_transform );
00110
00111
return( status );
00112 }