core/vgl/vgl_cylinder.h
Go to the documentation of this file.
00001 // This is core/vgl/vgl_cylinder.h
00002 #ifndef vgl_cylinder_h_
00003 #define vgl_cylinder_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief  defines a cylinder in 3D by a center point, radius, length and orientation
00010 // \author Gamze D. Tunali (gamze@lems.brown.edu)
00011 // \date   Nov 07, 2005
00012 //
00013 // \verbatim
00014 //  Modifications
00015 //   Nov 2005 created
00016 // \endverbatim
00017 #include <vgl/vgl_point_3d.h>
00018 #include <vgl/vgl_vector_3d.h>
00019 #include <vcl_iosfwd.h>
00020 
00021 template <class Type>
00022 class vgl_cylinder
00023 {
00024   vgl_point_3d<Type> center_;
00025   Type radius_;
00026   Type length_;
00027   vgl_vector_3d<Type> orient_;
00028 
00029  public:
00030   //: Default constructor
00031   vgl_cylinder(void): center_(0.0, 0.0, 0.0), radius_(0.0), length_(0.0) {}
00032 
00033   vgl_cylinder(const Type v[8])
00034     :center_(v[0], v[1], v[2]), radius_(v[3]), length_(v[5]), orient_(vgl_vector_3d<Type> (v[6], v[7], v[8])) {}
00035 
00036   vgl_cylinder(Type cx, Type cy, Type cz, Type rad, Type len)
00037     :center_(cx, cy, cz), radius_(rad), length_(len), orient_(vgl_vector_3d<Type> (0,0,1)) {}
00038 
00039   vgl_cylinder(vgl_point_3d<Type> cntr, Type rad, Type len)
00040     :center_(cntr), radius_(rad), length_(len), orient_(vgl_vector_3d<Type> (0,0,1)) {}
00041 
00042   vgl_cylinder(vgl_point_3d<Type> cntr, Type rad, Type len, vgl_vector_3d<Type> orient)
00043     :center_(cntr), radius_(rad), length_(len), orient_(orient) {}
00044 
00045   ~vgl_cylinder(void) {}
00046 
00047   //: getters
00048   vgl_point_3d<Type> center() const { return center_; }
00049   Type radius() const { return radius_; }
00050   Type length() const { return length_; }
00051   vgl_vector_3d<Type> orientation() const { return orient_; }
00052 
00053   //: setters
00054   void set_center(vgl_point_3d<Type> cntr) { center_ = cntr; }
00055   void set_radius(Type rad) { radius_ = rad; }
00056   void set_length(Type len) { length_ = len; }
00057   void set_orientation (vgl_vector_3d<Type> orient) { orient_ = orient; }
00058 
00059   //: operations
00060   bool operator==(vgl_cylinder<Type> const& cyl) const;
00061 
00062   //: Writes "<vgl_cylinder center=(x0,y0,z0), radius=r, length=l, direction=(x1,y1,z1)>" to stream
00063   vcl_ostream& print(vcl_ostream& s) const;
00064 };
00065 
00066 template <class T>
00067 vcl_ostream& operator<<(vcl_ostream& os, const vgl_cylinder<T>& cyl);
00068 
00069 template <class T>
00070 vcl_istream& operator>>(vcl_istream& s, vgl_cylinder<T>& cyl);
00071 
00072 #define VGL_CYLINDER_INSTANTIATE(T) extern "please include vgl/vgl_cylinder.txx first"
00073 
00074 #endif // vgl_cylinder_h_