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