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