00001 // This is gel/vsol/vsol_orient_box_3d.h 00002 #ifndef vsol_orient_box_3d_h_ 00003 #define vsol_orient_box_3d_h_ 00004 //: 00005 // \file 00006 // \brief A bounding oriented box 00007 // 00008 // This class mimics the properties of an oriented 00009 // box by keeping a regular axis aligned box and a 00010 // rotation direction. It keeps a bounding box of 00011 // the rotated box which is an axis aligned box. 00012 // 00013 00014 #include <vsol/vsol_point_3d_sptr.h> 00015 #include <vsol/vsol_volume_3d.h> 00016 #include <vsl/vsl_binary_io.h> 00017 #include <vbl/vbl_bounding_box.h> 00018 #include <vgl/algo/vgl_orient_box_3d.h> 00019 00020 //: An oriented bounding box for 3d spatial objects 00021 00022 class vsol_orient_box_3d : public vsol_volume_3d 00023 { 00024 protected: 00025 vbl_bounding_box<double,3> box_; 00026 vgl_orient_box_3d<double> orient_box_; 00027 00028 public: 00029 //: create an empty box 00030 vsol_orient_box_3d() {} 00031 00032 //: creates a bounding box from an oriented box 00033 vsol_orient_box_3d(vgl_orient_box_3d<double> const& orient_box); 00034 00035 vsol_orient_box_3d(vsol_orient_box_3d const& b) 00036 : vsol_volume_3d(b), box_(b.box_), orient_box_(b.orient_box_) {} 00037 00038 ~vsol_orient_box_3d() {} 00039 00040 virtual vsol_spatial_object_3d* clone(void) const {return new vsol_orient_box_3d(*this); } 00041 00042 // accessors 00043 // these min and max points belong to the bounding box 00044 double get_min_x() const; 00045 double get_max_x() const; 00046 00047 double get_min_y() const; 00048 double get_max_y() const; 00049 00050 double get_min_z() const; 00051 double get_max_z() const; 00052 00053 double width() const { return orient_box_.width(); } 00054 double height() const { return orient_box_.height(); } 00055 double depth() const { return orient_box_.depth(); } 00056 double volume() const { return width() * height() * depth(); } 00057 00058 //--------------------------------------------------------------------------- 00059 //: Is the point `p' inside `this' volume ? 00060 //--------------------------------------------------------------------------- 00061 bool in(vsol_point_3d_sptr const& p) const; 00062 00063 //: enlarge the bounding box by adding the point (x,y,z) & taking convex hull 00064 void add_point(double x, double y, double z); 00065 00066 //: Return a platform independent string identifying the class 00067 virtual vcl_string is_a() const { return vcl_string("vsol_orient_box_3d"); } 00068 00069 //: Return true if the argument matches the string identifying the class or any parent class 00070 virtual bool is_class(const vcl_string& cls) const { return cls==is_a(); } 00071 }; 00072 00073 00074 #endif // vsol_orient_box_3d_h_