core/vgl/io/vgl_io_line_2d.txx
Go to the documentation of this file.
00001 // This is core/vgl/io/vgl_io_line_2d.txx
00002 #ifndef vgl_io_line_2d_txx_
00003 #define vgl_io_line_2d_txx_
00004 //:
00005 // \file
00006 
00007 #include "vgl_io_line_2d.h"
00008 
00009 //======================================================================
00010 //: Binary save vgl_line_2d to stream.
00011 template<class T>
00012 void vsl_b_write(vsl_b_ostream &os, const vgl_line_2d<T>& v)
00013 {
00014   const short io_version_no = 1;
00015   vsl_b_write(os, io_version_no);
00016   vsl_b_write(os, v.a());
00017   vsl_b_write(os, v.b());
00018   vsl_b_write(os, v.c());
00019 }
00020 
00021 //======================================================================
00022 //: Binary load vgl_line_2d from stream.
00023 template<class T>
00024 void vsl_b_read(vsl_b_istream &is, vgl_line_2d<T>& v)
00025 {
00026   if (!is) return;
00027 
00028   T a,b,c;
00029   short w;
00030   vsl_b_read(is, w);
00031   switch (w)
00032   {
00033    case 1:
00034     vsl_b_read(is, a);
00035     vsl_b_read(is, b);
00036     vsl_b_read(is, c);
00037     v.set(a,b,c);
00038     break;
00039 
00040    default:
00041     vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vgl_line_2d<T>&)\n"
00042              << "           Unknown version number "<< v << '\n';
00043     is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on stream
00044     return;
00045   }
00046 }
00047 
00048 
00049 //======================================================================
00050 //: Output a human readable summary of a vgl_line_2d object to the stream
00051 template<class T>
00052 void vsl_print_summary(vcl_ostream &os, const vgl_line_2d<T>& v)
00053 {
00054     os<<"Line: ( "<<v.a()<<"x + "<<v.b()<<"y + "<<v.c()<<"=0 )";
00055 }
00056 
00057 #define VGL_IO_LINE_2D_INSTANTIATE(T) \
00058 template void vsl_print_summary(vcl_ostream &, const vgl_line_2d<T >&); \
00059 template void vsl_b_read(vsl_b_istream &, vgl_line_2d<T >&); \
00060 template void vsl_b_write(vsl_b_ostream &, const vgl_line_2d<T >&)
00061 
00062 #endif // vgl_io_line_2d_txx_