vgl_cylinder.hxx
Go to the documentation of this file.
1 #ifndef vgl_cylinder_hxx_
2 #define vgl_cylinder_hxx_
3 //:
4 // \file
5 
6 #include <iostream>
7 #include "vgl_cylinder.h"
8 #ifdef _MSC_VER
9 # include <vcl_msvc_warnings.h>
10 #endif
11 
12 template <class T>
14 {
15  return (this==&cyl) ||
16  ( cyl.center_ == this->center_ &&
17  cyl.radius_ == this->radius_ &&
18  cyl.length_ == this->length_ &&
19  cyl.orient_ == this->orient_);
20 }
21 
22 template <class T>
23 std::ostream& vgl_cylinder<T>::print(std::ostream& s) const
24 {
25  return s << "<vgl_cylinder center=" << center_ << ','
26  << " radius=" << radius_ << ", length =" << length_
27  << ", direction=" << orient_ << '>';
28 }
29 
30 template <class T>
31 std::ostream& operator<<(std::ostream& os, const vgl_cylinder<T>& cyl)
32 {
33  return cyl.print(os);
34 }
35 
36 template <class T>
37 std::istream& operator>>(std::istream& s, vgl_cylinder<T>& cyl)
38 {
39  T center_x, center_y, center_z, radius, length, orient_x, orient_y, orient_z;
40  s >> center_x >> center_y >> center_z >> radius >> length >> orient_x >> orient_y >> orient_z;
41  cyl.set_center(vgl_point_3d<T>(center_x,center_y,center_z));
42  cyl.set_radius(radius);
43  cyl.set_length(length);
44  cyl.set_orientation(vgl_vector_3d<T>(orient_x,orient_y,orient_z));
45  return s;
46 }
47 
48 #undef VGL_CYLINDER_INSTANTIATE
49 #define VGL_CYLINDER_INSTANTIATE(T) \
50 template class vgl_cylinder<T >; \
51 template std::ostream& operator<<(std::ostream&, vgl_cylinder<T >const&); \
52 template std::istream& operator>>(std::istream&, vgl_cylinder<T >&)
53 
54 #endif // vgl_cylinder_hxx_
vgl_point_3d< Type > center_
Definition: vgl_cylinder.h:24
bool operator==(vgl_cylinder< Type > const &cyl) const
operations.
defines a cylinder in 3D by a center point, radius, length and orientation
vgl_vector_3d< Type > orient_
Definition: vgl_cylinder.h:27
std::ostream & print(std::ostream &s) const
Writes "<vgl_cylinder center=(x0,y0,z0), radius=r, length=l, direction=(x1,y1,z1)>" to stream.