vgl_io_homg_line_3d_2_points.hxx
Go to the documentation of this file.
1 // This is core/vgl/io/vgl_io_homg_line_3d_2_points.hxx
2 #ifndef vgl_io_homg_line_3d_2_points_hxx_
3 #define vgl_io_homg_line_3d_2_points_hxx_
4 //:
5 // \file
6 // \brief See vgl_io_homg_line_3d_2_points.h for a description of this file.
7 // \author John Kang (Manchester)
8 
9 #include <iostream>
12 
13 #include <vsl/vsl_binary_io.h>
14 
15 //============================================================================
16 //: Binary save self to stream.
17 template<class T>
18 void vsl_b_write(vsl_b_ostream &os, const vgl_homg_line_3d_2_points<T> & p)
19 {
20  constexpr short io_version_no = 1;
21  vsl_b_write(os, io_version_no);
22  vsl_b_write(os, p.point_finite());
23  vsl_b_write(os, p.point_infinite());
24 }
25 
26 //============================================================================
27 //: Binary load self from stream.
28 template<class T>
29 void vsl_b_read(vsl_b_istream &is, vgl_homg_line_3d_2_points<T> & p)
30 {
31  if (!is) return;
32 
33  short v;
34  vsl_b_read(is, v);
35  switch (v)
36  {
37  case 1: {
38  vgl_homg_point_3d<T> p1, p2;
39  vsl_b_read(is, p1);
40  vsl_b_read(is, p2);
41  p.set(p1,p2);
42  break;
43  }
44 
45  default:
46  std::cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&, vgl_homg_line_3d_2_points<T>&)\n"
47  << " Unknown version number "<< v << '\n';
48  is.is().clear(std::ios::badbit); // Set an unrecoverable IO error on stream
49  return;
50  }
51 }
52 
53 
54 //============================================================================
55 //: Output a human readable summary to the stream
56 template<class T>
57 void vsl_print_summary(std::ostream& os,const vgl_homg_line_3d_2_points<T> & p)
58 {
59  os << '('; vsl_print_summary(os,p.point_finite());
60  os << ','; vsl_print_summary(os,p.point_infinite());
61  os << ')';
62 }
63 
64 #define VGL_IO_HOMG_LINE_3D_2_POINTS_INSTANTIATE(T) \
65 template void vsl_print_summary(std::ostream &, \
66  const vgl_homg_line_3d_2_points<T > &); \
67 template void vsl_b_read(vsl_b_istream &, vgl_homg_line_3d_2_points<T > &); \
68 template void vsl_b_write(vsl_b_ostream &, vgl_homg_line_3d_2_points<T >const&)
69 
70 #endif // vgl_io_homg_line_3d_2_points_hxx_
void vsl_print_summary(std::ostream &os, const vgl_homg_line_3d_2_points< T > &p)
Output a human readable summary to the stream.
Represents a homogeneous 3D point.
Definition: vgl_fwd.h:9
#define v
Definition: vgl_vector_2d.h:74
void vsl_b_write(vsl_b_ostream &os, const vgl_homg_line_3d_2_points< T > &p)
Binary save self to stream.
void vsl_b_read(vsl_b_istream &is, vgl_homg_line_3d_2_points< T > &p)
Binary load self from stream.
vgl_homg_point_3d< Type > point_finite() const
Finite point (Could be an ideal point, if the whole line is at infinity.).
void set(vgl_homg_point_3d< Type > const &p1, vgl_homg_point_3d< Type > const &p2)
Assignment.
vgl_homg_point_3d< Type > point_infinite() const
Infinite point: the intersection of the line with the plane at infinity.
Represents a homogeneous 3D line using two points.
Definition: vgl_fwd.h:15