vgl_io_homg_line_2d.hxx
Go to the documentation of this file.
1 // This is core/vgl/io/vgl_io_homg_line_2d.hxx
2 #ifndef vgl_io_homg_line_2d_hxx_
3 #define vgl_io_homg_line_2d_hxx_
4 //:
5 // \file
6 
7 #include <iostream>
8 #include "vgl_io_homg_line_2d.h"
9 #include <vsl/vsl_binary_io.h>
10 
11 //======================================================================
12 //: Binary save vgl_homg_line_2d to stream.
13 template<class T>
14 void vsl_b_write(vsl_b_ostream &os, const vgl_homg_line_2d<T>& v)
15 {
16  constexpr short io_version_no = 1;
17  vsl_b_write(os, io_version_no);
18  vsl_b_write(os, v.a());
19  vsl_b_write(os, v.b());
20  vsl_b_write(os, v.c());
21 }
22 
23 //======================================================================
24 //: Binary load vgl_homg_line_2d from stream.
25 template<class T>
26 void vsl_b_read(vsl_b_istream &is, vgl_homg_line_2d<T>& v)
27 {
28  if (!is) return;
29 
30  T a,b,c;
31  short w;
32  vsl_b_read(is, w);
33  switch (w)
34  {
35  case 1:
36  vsl_b_read(is, a);
37  vsl_b_read(is, b);
38  vsl_b_read(is, c);
39  v.set(a,b,c);
40  break;
41 
42  default:
43  std::cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vgl_homg_line_2d<T>&)\n"
44  << " Unknown version number "<< v << '\n';
45  is.is().clear(std::ios::badbit); // Set an unrecoverable IO error on stream
46  return;
47  }
48 }
49 
50 
51 //======================================================================
52 //: Output a human readable summary of a vgl_homg_line_2d object to the stream
53 template<class T>
54 void vsl_print_summary(std::ostream &os, const vgl_homg_line_2d<T>& v)
55 {
56  os<<"Homg_line: ( "<<v.a()<<"x + "<<v.b()<<"y + "<<v.c()<<"z = 0 )";
57 }
58 
59 #define VGL_IO_HOMG_LINE_2D_INSTANTIATE(T) \
60 template void vsl_print_summary(std::ostream &, const vgl_homg_line_2d<T >&); \
61 template void vsl_b_read(vsl_b_istream &, vgl_homg_line_2d<T >&); \
62 template void vsl_b_write(vsl_b_ostream &, const vgl_homg_line_2d<T >&)
63 
64 #endif // vgl_io_homg_line_2d_hxx_
Represents a homogeneous 2D line.
Definition: vgl_fwd.h:14
contains functions vsl_b_write, vsl_b_read and vsl_print_summary
#define v
Definition: vgl_vector_2d.h:74
void vsl_b_read(vsl_b_istream &is, vgl_homg_line_2d< T > &v)
Binary load vgl_homg_line_2d from stream.
void vsl_print_summary(std::ostream &os, const vgl_homg_line_2d< T > &v)
Output a human readable summary of a vgl_homg_line_2d object to the stream.
void vsl_b_write(vsl_b_ostream &os, const vgl_homg_line_2d< T > &v)
Binary save vgl_homg_line_2d to stream.