00001 // This is core/vnl/io/vnl_io_real_polynomial.cxx 00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00003 #pragma implementation 00004 #endif 00005 //: 00006 // \file 00007 00008 #include "vnl_io_real_polynomial.h" 00009 #include <vsl/vsl_binary_io.h> 00010 #include <vnl/io/vnl_io_vector.h> 00011 #include <vnl/io/vnl_io_matrix.h> 00012 00013 00014 //============================================================================== 00015 //: Binary save self to stream. 00016 void vsl_b_write(vsl_b_ostream & os, const vnl_real_polynomial & p) 00017 { 00018 const short io_version_no = 1; 00019 vsl_b_write(os, io_version_no); 00020 00021 vsl_b_write(os, p.coefficients()); 00022 } 00023 00024 //============================================================================== 00025 //: Binary load self from stream. 00026 void vsl_b_read(vsl_b_istream &is, vnl_real_polynomial & p) 00027 { 00028 if (!is) return; 00029 00030 short ver; 00031 vnl_vector<double> coeffs; 00032 vsl_b_read(is, ver); 00033 switch (ver) 00034 { 00035 case 1: 00036 vsl_b_read(is, coeffs); 00037 p.set_coefficients(coeffs); 00038 break; 00039 00040 default: 00041 vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vnl_real_polynomial&)\n" 00042 << " Unknown version number "<< ver << '\n'; 00043 is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on stream 00044 return; 00045 } 00046 } 00047 00048 //============================================================================== 00049 //: Output a human readable summary to the stream 00050 void vsl_print_summary(vcl_ostream & os,const vnl_real_polynomial & p) 00051 { 00052 p.print(os); 00053 }