core/vgl/io/vgl_io_homg_line_3d_2_points.txx
Go to the documentation of this file.
00001 // This is core/vgl/io/vgl_io_homg_line_3d_2_points.txx
00002 #ifndef vgl_io_homg_line_3d_2_points_txx_
00003 #define vgl_io_homg_line_3d_2_points_txx_
00004 //:
00005 // \file
00006 // \brief  See vgl_io_homg_line_3d_2_points.h for a description of this file.
00007 // \author John Kang (Manchester)
00008 
00009 #include "vgl_io_homg_line_3d_2_points.h"
00010 #include <vgl/io/vgl_io_homg_point_3d.h>
00011 
00012 #include <vsl/vsl_binary_io.h>
00013 
00014 //============================================================================
00015 //: Binary save self to stream.
00016 template<class T>
00017 void vsl_b_write(vsl_b_ostream &os, const vgl_homg_line_3d_2_points<T> & p)
00018 {
00019   const short io_version_no = 1;
00020   vsl_b_write(os, io_version_no);
00021   vsl_b_write(os, p.point_finite());
00022   vsl_b_write(os, p.point_infinite());
00023 }
00024 
00025 //============================================================================
00026 //: Binary load self from stream.
00027 template<class T>
00028 void vsl_b_read(vsl_b_istream &is, vgl_homg_line_3d_2_points<T> & p)
00029 {
00030   if (!is) return;
00031 
00032   short v;
00033   vsl_b_read(is, v);
00034   switch (v)
00035   {
00036    case 1: {
00037     vgl_homg_point_3d<T> p1, p2;
00038     vsl_b_read(is, p1);
00039     vsl_b_read(is, p2);
00040     p.set(p1,p2);
00041     break;
00042    }
00043 
00044    default:
00045     vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vgl_homg_line_3d_2_points<T>&)\n"
00046              << "           Unknown version number "<< v << '\n';
00047     is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on stream
00048     return;
00049   }
00050 }
00051 
00052 
00053 //============================================================================
00054 //: Output a human readable summary to the stream
00055 template<class T>
00056 void vsl_print_summary(vcl_ostream& os,const vgl_homg_line_3d_2_points<T> & p)
00057 {
00058   os << '('; vsl_print_summary(os,p.point_finite());
00059   os << ','; vsl_print_summary(os,p.point_infinite());
00060   os << ')';
00061 }
00062 
00063 #define VGL_IO_HOMG_LINE_3D_2_POINTS_INSTANTIATE(T) \
00064 template void vsl_print_summary(vcl_ostream &, \
00065                                 const vgl_homg_line_3d_2_points<T > &); \
00066 template void vsl_b_read(vsl_b_istream &, vgl_homg_line_3d_2_points<T > &); \
00067 template void vsl_b_write(vsl_b_ostream &, vgl_homg_line_3d_2_points<T >const&)
00068 
00069 #endif // vgl_io_homg_line_3d_2_points_txx_