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 //   04-04-2006 K. Kang: a few setters are added
00016 //   2004/10/07 Gamze D. Tunali  Created
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 
00025 class vsol_cylinder : public  vsol_spatial_object_3d
00026 {
00027   vgl_cylinder<double> cyl_;
00028 
00029  public:
00030   vsol_cylinder() {}
00031 
00032   vsol_cylinder(vgl_point_3d<double> centre, double radius, double length)
00033   : cyl_(centre, radius, length) {}
00034 
00035   vsol_cylinder(vgl_point_3d<double> centre, double radius, double length,
00036                 vgl_vector_3d<double> orient)
00037   : cyl_(centre, radius, length){ cyl_.set_orientation(orient); }
00038 
00039   // copy constructor
00040   vsol_cylinder(vsol_cylinder const& cyl)
00041     : vsol_spatial_object_3d(cyl), cyl_(cyl.cyl_) {}
00042 
00043   //: Return true iff the point p is inside (or on) this cylinder
00044   bool contains(vgl_point_3d<double> const& p);
00045 
00046   //: getters
00047   vgl_point_3d<double> center() { return cyl_.center(); }
00048   double radius() {return cyl_.radius(); }
00049   double length() {return cyl_.length(); }
00050   vgl_vector_3d<double> orientation() { return cyl_.orientation(); }
00051 
00052   //: setters
00053   void set_orientation(vgl_vector_3d<double> orient) {cyl_.set_orientation(orient);
00054   }
00055 
00056   void set_center(vgl_point_3d<double> const & c) {cyl_.set_center(c);}
00057 
00058   void set_length(double l) {cyl_.set_length(l);}
00059 
00060   void set_radius(double r) {cyl_.set_radius(r);}
00061   // ==== Binary IO methods ======
00062 
00063   //: Binary save self to stream.
00064   void b_write(vsl_b_ostream &os) const;
00065 
00066   //: Binary load self from stream.
00067   void b_read(vsl_b_istream &is);
00068 
00069   //: Return IO version number;
00070   short version() const;
00071 
00072   //: Print an ascii summary to the stream
00073   void print_summary(vcl_ostream &os) const;
00074 
00075   void describe(vcl_ostream &strm, int blanking) const;
00076 
00077   //: Return a platform independent string identifying the class
00078   vcl_string is_a() const { return vcl_string("vsol_cylinder"); }
00079 
00080   //: Return true if the argument matches the string identifying the class or any parent class
00081   bool is_class(const vcl_string& cls) const { return cls == is_a(); }
00082 
00083    // implementing virtual methods of vsol_spatial_object_3d
00084   vsol_spatial_object_3d_type spatial_type() const { return vsol_spatial_object_3d::VOLUME; }
00085 
00086   vsol_spatial_object_3d* clone() const { return new vsol_cylinder(*this); }
00087 
00088   virtual ~vsol_cylinder(void) {}
00089 };
00090 
00091 //: Binary save vsol_cylinder* to stream.
00092 void vsl_b_write(vsl_b_ostream &os, const vsol_cylinder* p);
00093 
00094 //: Binary load vsol_cylinder_sptr from stream.
00095 void vsl_b_write(vsl_b_istream &is, vsol_cylinder_sptr &p);
00096 
00097 //: Binary load vsol_cylinder* from stream.
00098 void vsl_b_read(vsl_b_istream &is, vsol_cylinder* &p);
00099 
00100 //: Binary load vsol_cylinder_sptr from stream.
00101 void vsl_b_read(vsl_b_istream &is, vsol_cylinder_sptr &p);
00102 
00103 #endif // vsol_cylinder_h_

Generated on Tue Dec 2 05:14:57 2008 for contrib/gel/vsol by  doxygen 1.5.1