shape_doc 0.1
/Users/mourrain/Devel/mmx/shape/include/shape/axel_glue.hpp
Go to the documentation of this file.
00001 #ifndef shape_axel_glue_hpp
00002 #define shape_axel_glue_hpp
00003 //====================================================================
00004 # include <basix/glue.hpp>
00005 # include <numerix/rational.hpp>
00006 # include <numerix/floating.hpp>
00007 # include <shape/viewer_axel.hpp>
00008 # include <shape/MGXK.hpp>
00009 
00010 # define TMPL template<class K>
00011 # define SELF shape::viewer<shape::axel,K>
00012 # define shape_axel shape::viewer<shape::axel,shape::MGXK>
00013 //====================================================================
00014 
00015 namespace mmx {
00016   namespace shape{  
00017     
00018     TMPL inline bool operator ==(const SELF& v1, const SELF& v2) {return true;}
00019     TMPL inline bool operator !=(const SELF& v1, const SELF& v2) {return !(v1==v2);}
00020     
00021     TMPL inline bool exact_eq (const SELF& v1, const SELF& v2) {return v1==v2;}
00022     TMPL inline bool exact_neq(const SELF& v1, const SELF& v2) {return v1!=v2;}
00023     
00024     TMPL inline unsigned hash (const SELF& v) {
00025       register unsigned i, h= 214365, n=1;
00026       for (i=0; i<n; i++) h= (h<<1) ^ (h<<5) ^ (h>>27) ;//^ hash(v[i]);
00027       return h;
00028     }
00029     
00030     TMPL inline unsigned exact_hash (const SELF& m) {return hash(m);}
00031     TMPL inline unsigned soft_hash (const SELF& m) {return hash(m);}
00032   
00033 
00034     inline syntactic flatten(const shape_axel& axl)
00035     {
00036       return apply(syntactic("Axel"), syntactic(axl.file));
00037     } 
00038    
00039   }
00040   //--------------------------------------------------------------------
00041 
00042   inline shape_axel
00043   shape_axel_string (const mmx::string& s) { 
00044     return shape_axel(as_charp(s));
00045   } 
00046   
00047   TMPL inline void 
00048   shape_axel_view (const SELF& os) {
00049     os.view();
00050   } 
00051   
00052   TMPL inline SELF& operator<<(SELF& os, const mmx::rational& x) {
00053     os << as_double(x);  return os;
00054   }
00055   
00056   
00057   TMPL inline SELF& operator<<(SELF& os, const mmx::floating<> & x) {
00058     os << as_double(x);  return os;
00059     }
00060   
00061   template<class K, class C>
00062   SELF& operator<<(SELF& os, const vector<C>& p) {
00063     os<<"<point> ";
00064     for(unsigned i=0;i<N(p);i++) {
00065       os<<p[i]<<" ";
00066     }
00067     for(unsigned i=N(p); i<3;i++) os<<"0 ";
00068     os<<"</point>\n";
00069     return os;
00070   }
00071 //====================================================================
00072 } //namespace mmx
00073 //====================================================================
00074 # undef TMPL
00075 # undef SELF
00076 # undef BoundingBox
00077 # endif //shape_axel_glue_hpp