00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __mmx_shape_point_glue_hpp
00012 #define __mmx_shape_point_glue_hpp
00013 #include <basix/glue.hpp>
00014 #include <shape/axel_glue.hpp>
00015 #include <shape/point.hpp>
00016
00017 #define TMPL template<class C>
00018 #define Point shape::point<C>
00019 #define Scalar C
00020 #define Vector vector<Scalar>
00021
00022
00023 namespace mmx {
00024 namespace shape {
00025
00026 TMPL inline bool operator ==(const Point& v1, const Point& v2) {return true;}
00027 TMPL inline bool operator !=(const Point& v1, const Point& v2) {return !(v1==v2);}
00028 TMPL inline bool exact_eq(const Point& v1, const Point& v2) {return v1==v2;}
00029 TMPL inline bool exact_neq(const Point& v1, const Point& v2) {return v1!=v2;}
00030
00031 TMPL inline unsigned hash (const Point& v)
00032 {
00033 register unsigned i, h= 214365, n=1;
00034 for (i=0; i<n; i++) h= (h<<1) ^ (h<<5) ^ (h>>27) ;
00035 return h;
00036 }
00037 TMPL inline unsigned exact_hash (const Point& m) {return hash(m);}
00038 TMPL inline unsigned soft_hash (const Point& m) {return hash(m);}
00039
00040 TMPL inline syntactic flatten (const Point& p) {
00041 vector<syntactic> v;
00042 v<<mmx::flatten(p[0]);
00043 v<<mmx::flatten(p[1]);
00044 v<<mmx::flatten(p[2]);
00045
00046 return mmx::flatten(v);
00047 }
00048 }
00049
00050
00051 TMPL Point shape_point_tuple(const vector<C>& v) {
00052 Point p;
00053 for(unsigned i=0;i<N(v) && i<3; i++)
00054 p[i]=v[i];
00055 return p;
00056 }
00057
00058 TMPL vector<C> operator-(const Point& p1, const Point& p2){
00059 Vector res((C)0,3);
00060 for(unsigned i=0;i<3; i++) res[i]=p1[i]-p2[i];
00061 return res;
00062 }
00063
00064 TMPL Point operator+(const Point& p, const vector<C>& v) {
00065 Point res;
00066 for(unsigned i=0;i<3; i++) res[i]=p[i]+v[i];
00067 return res;
00068 }
00069 #undef TMPL
00070 #undef Point
00071
00072 }
00073 #endif // __mmx_point_glue_hpp