core/vgl/io/vgl_io_infinite_line_3d.txx
Go to the documentation of this file.
00001 // This is core/vgl/io/vgl_io_infinite_line_3d.txx
00002 #ifndef vgl_io_infinite_line_3d_txx_
00003 #define vgl_io_infinite_line_3d_txx_
00004 //:
00005 // \file
00006 
00007 #include "vgl_io_infinite_line_3d.h"
00008 #include "vgl_io_vector_2d.h"
00009 #include "vgl_io_vector_3d.h"
00010 
00011 //======================================================================
00012 //: Binary save vgl_infinite_line_3d to stream.
00013 template<class T>
00014 void vsl_b_write(vsl_b_ostream &os, const vgl_infinite_line_3d<T>& v)
00015 {
00016   const short io_version_no = 1;
00017   vsl_b_write(os, io_version_no);
00018   vsl_b_write(os, v.x0());
00019   vsl_b_write(os, v.direction());
00020 }
00021 
00022 //======================================================================
00023 //: Binary load vgl_infinite_line_3d from stream.
00024 template<class T>
00025 void vsl_b_read(vsl_b_istream &is, vgl_infinite_line_3d<T>& v)
00026 {
00027   if (!is) return;
00028 
00029   vgl_vector_2d<T> x0;
00030   vgl_vector_3d<T> dir;
00031   short w;
00032   vsl_b_read(is, w);
00033   switch (w)
00034   {
00035    case 1:
00036     vsl_b_read(is, x0);
00037     vsl_b_read(is, dir);
00038     v.set(x0,dir);
00039     break;
00040 
00041    default:
00042     vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vgl_infinite_line_3d<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_infinite_line_3d object to the stream
00052 template<class T>
00053 void vsl_print_summary(vcl_ostream &os, const vgl_infinite_line_3d<T>& v)
00054 {
00055     os << "infinite_line: (position vector=" << v.x0()<< " direction=" << v.direction() <<")";
00056 }
00057 
00058 #define VGL_IO_INFINITE_LINE_3D_INSTANTIATE(T) \
00059 template void vsl_print_summary(vcl_ostream &, const vgl_infinite_line_3d<T >&); \
00060 template void vsl_b_read(vsl_b_istream &, vgl_infinite_line_3d<T >&); \
00061 template void vsl_b_write(vsl_b_ostream &, const vgl_infinite_line_3d<T >&)
00062 
00063 #endif // vgl_io_infinite_line_3d_txx_