00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __mmx_shape_bounding_box_glue_hpp
00012 #define __mmx_shape_bounding_box_glue_hpp
00013 #include <basix/glue.hpp>
00014 #include <basix/tuple.hpp>
00015 #include <shape/MGXK.hpp>
00016 #include <shape/bounding_box.hpp>
00017
00018 #define shape_bounding_box shape::bounding_box<double, shape::MGXK>
00019 #define BoundingBox shape::bounding_box<double,shape::MGXK>
00020
00021 namespace mmx {
00022 namespace shape {
00023
00024 inline bool operator ==(const BoundingBox& v1, const BoundingBox& v2) {return true;}
00025 inline bool operator !=(const BoundingBox& v1, const BoundingBox& v2) {return !(v1==v2);}
00026 inline bool exact_eq (const BoundingBox& v1, const BoundingBox& v2) {return v1==v2;}
00027 inline bool exact_neq(const BoundingBox& v1, const BoundingBox& v2) {return v1!=v2;}
00028
00029 inline unsigned hash (const BoundingBox& v)
00030 {
00031 register unsigned i, h= 214365, n=1;
00032 for (i=0; i<n; i++) h= (h<<1) ^ (h<<5) ^ (h>>27) ;
00033 return h;
00034 }
00035 inline unsigned exact_hash(const BoundingBox& m) {return hash(m);}
00036 inline unsigned soft_hash (const BoundingBox& m) {return hash(m);}
00037
00038 inline syntactic flatten (const BoundingBox& s)
00039 {
00040 vector<syntactic> box;
00041 box<<mmx::flatten(s.xmin());
00042 box<<mmx::flatten(s.xmax());
00043 box<<mmx::flatten(s.ymin());
00044 box<<mmx::flatten(s.ymax());
00045 box<<mmx::flatten(s.zmin());
00046 box<<mmx::flatten(s.zmax());
00047
00048 return mmx::flatten(box);
00049 }
00050 }
00051
00052 template<class C>
00053 inline BoundingBox shape_bounding_box_from_vector(const vector<C>& v)
00054 {
00055 unsigned n= N(v);
00056 double a=0,b=1,c=0,d=1,e=0,f=1;
00057 if (n>1) a =as_double(v[0]); b=as_double(v[1]);
00058 if (n>3) c =as_double(v[2]); d=as_double(v[3]);
00059 if (n<5) return BoundingBox(a,b,c,d);
00060 if (n>5) e =as_double(v[4]); f=as_double(v[5]);
00061 return BoundingBox(a,b,c,d,e,f);
00062 }
00063
00064
00065
00066 }
00067 #undef BoundingBox
00068 #endif // __mmx_bounding_box_glue_hpp