shape_doc 0.1
/Users/mourrain/Devel/mmx/shape/include/shape/shape.hpp
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * M a t h e m a g i x
00003  *****************************************************************************
00004  * shape
00005  * 2008-03-21
00006  * Julien Wintz && Bernard Mourrain
00007  *****************************************************************************
00008  *               Copyright (C) 2006 INRIA Sophia-Antipolis
00009  *****************************************************************************
00010  * Comments :
00011  ****************************************************************************/
00012 # ifndef shape_shape_hpp
00013 # define shape_shape_hpp
00014 # define TMPL template<class K>
00015 # define SELF geometric<K>
00016 //====================================================================
00017 namespace mmx {
00018 
00019 
00020 # define TMPL_TYPE(NAME, X) typename NAME<X>::T
00021 # define TYPE(NAME, X) NAME<X>::T
00022 
00023 # define WITH(N0, K1, N2) typedef typename use<N0##_def,K1>::N2 N2
00024 
00025 //====================================================================
00026 namespace shape {
00027 //====================================================================
00028   struct default_env {};
00029 
00030   template<class A, class B= default_env> struct use;
00031 
00032   struct ref_def {};
00033 
00034   template<> struct use<ref_def>        { typedef default_env Ref; };
00035   template<> struct use<ref_def,double> { typedef default_env Ref; };
00036 
00037 # define REF_OF(N0) typename use<ref_def,N0>::Ref
00038 # define DECLARE_REF_OF(V0,R1) struct use<ref_def,V0 > {typedef R1 Ref; };
00039 
00040 //--------------------------------------------------------------------
00041   
00042   template<class A, class B> struct join2 {};
00043 
00044 //--------------------------------------------------------------------
00045   struct scalar_def {};
00046 
00047   template<> struct use<scalar_def>        { typedef double Scalar; };
00048 //--------------------------------------------------------------------
00049 
00050 TMPL struct geometric;
00051 
00052 struct shape_def {};
00053 template<> struct use<shape_def> { 
00054   typedef geometric<default_env> Shape; 
00055 };
00056 
00057 # define SHAPE_OF(V) use<shape_def,V>::Shape
00058 
00059 //geometric<REF_OF(V)>
00060 
00061 //--------------------------------------------------------------------
00062 TMPL class geometric {
00063 public:
00064   geometric(void) {
00065     m_x = m_y = m_z = 0.0 ;
00066     m_q0 = m_q1 = m_q2 = m_q3 = 0.0 ;
00067   }
00068   
00069   virtual ~geometric(void) {} ;
00070 
00071   bool position(double * x, double * y, double * z) ;
00072   bool orientation(double * q0, double * q1, double * q2, double * q3) ; 
00073 
00074 protected:
00075     double m_x, m_y, m_z ;
00076     double m_q0, m_q1, m_q2, m_q3 ;
00077 } ;
00078 
00079 TMPL bool 
00080 SELF::position(double * x, double * y, double * z) {
00081   *x = this->m_x ;
00082   *y = this->m_y ;
00083   *z = this->m_z ;
00084   return true ;
00085 }
00086 
00087 TMPL bool 
00088 SELF::orientation(double * q0, double * q1, double * q2, double * q3) {
00089   *q0 = this->m_q0 ;
00090   *q1 = this->m_q1 ;
00091   *q2 = this->m_q2 ;
00092   *q3 = this->m_q3 ;
00093   return true ;
00094 }
00095 
00096 //--------------------------------------------------------------------
00097 TMPL struct process {};
00098 
00099 # define PROCESS_OF(V) process<V>
00100 
00101 //====================================================================
00102 } ; // namespace shape
00103 } ; // namespace mmx
00104 //====================================================================
00105 # undef TMPL
00106 # undef SELF
00107 # endif // shape_shape_hpp