contrib/gel/vsol/vsol_cylinder.h
Go to the documentation of this file.
00001 #ifndef vsol_cylinder_h_
00002 #define vsol_cylinder_h_
00003 //*****************************************************************************
00004 //:
00005 // \file
00006 // \brief a class to hold cylinder data in 3D
00007 //
00008 // This class inherits from vsol_spatial_object_3d.
00009 //
00010 // \author Gamze D. Tunali
00011 // \date   2005-11-07
00012 //
00013 // \verbatim
00014 //  Modifications
00015 //   2004-10-07 Gamze D. Tunali  Created
00016 //   2006-04-04 K. Kang: a few setters are added
00017 // \endverbatim
00018 //*****************************************************************************
00019 
00020 #include <vgl/vgl_cylinder.h>
00021 #include <vsol/vsol_spatial_object_3d.h>
00022 #include <vsol/vsol_cylinder_sptr.h>
00023 #include <vsl/vsl_binary_io.h>
00024 #include <vcl_string.h>
00025 #include <vcl_iosfwd.h>
00026 
00027 class vsol_cylinder : public  vsol_spatial_object_3d
00028 {
00029   vgl_cylinder<double> cyl_;
00030 
00031  public:
00032   vsol_cylinder() {}
00033 
00034   vsol_cylinder(vgl_point_3d<double> centre, double radius, double length)
00035   : cyl_(centre, radius, length) {}
00036 
00037   vsol_cylinder(vgl_point_3d<double> centre, double radius, double length,
00038                 vgl_vector_3d<double> orient)
00039   : cyl_(centre, radius, length){ cyl_.set_orientation(orient); }
00040 
00041   // copy constructor
00042   vsol_cylinder(vsol_cylinder const& cyl)
00043     : vsol_spatial_object_3d(cyl), cyl_(cyl.cyl_) {}
00044 
00045   //: Return true iff the point p is inside (or on) this cylinder
00046   bool contains(vgl_point_3d<double> const& p);
00047 
00048   //: getters
00049   vgl_point_3d<double> center() { return cyl_.center(); }
00050   double radius() {return cyl_.radius(); }
00051   double length() {return cyl_.length(); }
00052   vgl_vector_3d<double> orientation() { return cyl_.orientation(); }
00053 
00054   //: setters
00055   void set_orientation(vgl_vector_3d<double> orient) {cyl_.set_orientation(orient);
00056   }
00057 
00058   void set_center(vgl_point_3d<double> const & c) {cyl_.set_center(c);}
00059 
00060   void set_length(double l) {cyl_.set_length(l);}
00061 
00062   void set_radius(double r) {cyl_.set_radius(r);}
00063   // ==== Binary IO methods ======
00064 
00065   //: Binary save self to stream.
00066   void b_write(vsl_b_ostream &os) const;
00067 
00068   //: Binary load self from stream.
00069   void b_read(vsl_b_istream &is);
00070 
00071   //: Return IO version number;
00072   short version() const;
00073 
00074   //: Print an ascii summary to the stream
00075   void print_summary(vcl_ostream &os) const;
00076 
00077   void describe(vcl_ostream &strm, int blanking) const;
00078 
00079   //: Return a platform independent string identifying the class
00080   vcl_string is_a() const { return vcl_string("vsol_cylinder"); }
00081 
00082   //: Return true if the argument matches the string identifying the class or any parent class
00083   bool is_class(const vcl_string& cls) const { return cls == is_a(); }
00084 
00085    // implementing virtual methods of vsol_spatial_object_3d
00086   vsol_spatial_object_3d_type spatial_type() const { return vsol_spatial_object_3d::VOLUME; }
00087 
00088   vsol_spatial_object_3d* clone() const { return new vsol_cylinder(*this); }
00089 
00090   virtual ~vsol_cylinder(void) {}
00091 };
00092 
00093 //: Binary save vsol_cylinder* to stream.
00094 void vsl_b_write(vsl_b_ostream &os, const vsol_cylinder* p);
00095 
00096 //: Binary load vsol_cylinder_sptr from stream.
00097 void vsl_b_write(vsl_b_istream &is, vsol_cylinder_sptr &p);
00098 
00099 //: Binary load vsol_cylinder* from stream.
00100 void vsl_b_read(vsl_b_istream &is, vsol_cylinder* &p);
00101 
00102 //: Binary load vsol_cylinder_sptr from stream.
00103 void vsl_b_read(vsl_b_istream &is, vsol_cylinder_sptr &p);
00104 
00105 #endif // vsol_cylinder_h_