00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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 C = double, class B= default_env> struct use;
00031
00032 struct ref_def {};
00033
00034 template<> struct use<ref_def> { typedef default_env Ref; };
00035
00036
00037 # define REF_OF(N0) typename use<ref_def,double,N0>::Ref
00038 # define DECLARE_REF_OF(V0,R1) struct use<ref_def,double,V0 > {typedef R1 Ref; };
00039
00040
00041
00042
00043 struct graphic_def {};
00044 struct scalar_def {};
00045
00046 template<> struct use<scalar_def> { typedef double Scalar; };
00047
00048
00049 TMPL class geometric;
00050
00051
00052 struct shape_def {};
00053
00054 template<class C> struct use<shape_def,C> {
00055 typedef geometric<default_env> Shape;
00056 };
00057
00058 # define SHAPE_OF(V) use<shape_def,double,V>::Shape
00059
00060
00061 TMPL class geometric {
00062 public:
00063 geometric(void) {
00064 m_x = m_y = m_z = 0.0 ;
00065 m_q0 = m_q1 = m_q2 = m_q3 = 0.0 ;
00066 }
00067
00068 virtual ~geometric(void) {} ;
00069
00070 bool position(double * x, double * y, double * z) ;
00071 bool orientation(double * q0, double * q1, double * q2, double * q3) ;
00072
00073 protected:
00074 double m_x, m_y, m_z ;
00075 double m_q0, m_q1, m_q2, m_q3 ;
00076 } ;
00077
00078 TMPL bool
00079 SELF::position(double * x, double * y, double * z) {
00080 *x = this->m_x ;
00081 *y = this->m_y ;
00082 *z = this->m_z ;
00083 return true ;
00084 }
00085
00086 TMPL bool
00087 SELF::orientation(double * q0, double * q1, double * q2, double * q3) {
00088 *q0 = this->m_q0 ;
00089 *q1 = this->m_q1 ;
00090 *q2 = this->m_q2 ;
00091 *q3 = this->m_q3 ;
00092 return true ;
00093 }
00094
00095
00096 TMPL struct process {};
00097
00098 # define PROCESS_OF(V) process<V>
00099
00100
00101 } ;
00102 } ;
00103
00104 # undef TMPL
00105 # undef SELF
00106 # endif // shape_shape_hpp