core/vgl/io/vgl_io_line_3d_2_points.txx
Go to the documentation of this file.
00001 // This is core/vgl/io/vgl_io_line_3d_2_points.txx
00002 #ifndef vgl_io_line_3d_2_points_txx_
00003 #define vgl_io_line_3d_2_points_txx_
00004 //:
00005 // \file
00006 // \author Peter Vanroose
00007 // \date 24 Oct 2002
00008 
00009 #include "vgl_io_line_3d_2_points.h"
00010 #include <vgl/io/vgl_io_point_3d.h>
00011 
00012 //============================================================================
00013 //: Binary save self to stream.
00014 template<class T>
00015 void vsl_b_write(vsl_b_ostream& os, vgl_line_3d_2_points<T> const& p)
00016 {
00017   const short io_version_no = 1;
00018   vsl_b_write(os, io_version_no);
00019   vsl_b_write(os, p.point1());
00020   vsl_b_write(os, p.point2());
00021 }
00022 
00023 //============================================================================
00024 //: Binary load self from stream.
00025 template<class T>
00026 void vsl_b_read(vsl_b_istream &is, vgl_line_3d_2_points<T> & p)
00027 {
00028   if (!is) return;
00029 
00030   short v;
00031   vsl_b_read(is, v);
00032   switch (v)
00033   {
00034    case 1:
00035    {
00036     vgl_point_3d<T> p1,p2; vsl_b_read(is,p1); vsl_b_read(is,p2); p.set(p1,p2);
00037     return;
00038    }
00039 
00040    default:
00041     vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vgl_line_3d_2_points<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 to the stream
00051 template<class T>
00052 void vsl_print_summary(vcl_ostream& os, vgl_line_3d_2_points<T> const& p)
00053 {
00054   os<<'('; vsl_print_summary(os,p.point1());
00055   os<<','; vsl_print_summary(os,p.point2());
00056   os<<')';
00057 }
00058 
00059 #define VGL_IO_LINE_3D_2_POINTS_INSTANTIATE(T) \
00060 template void vsl_print_summary(vcl_ostream&, vgl_line_3d_2_points<T > const&);\
00061 template void vsl_b_read(vsl_b_istream&, vgl_line_3d_2_points<T > &); \
00062 template void vsl_b_write(vsl_b_ostream&, vgl_line_3d_2_points<T > const&)
00063 
00064 #endif // vgl_io_line_3d_2_points_txx_