• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List

jdxfunction.h

00001 /***************************************************************************
00002                           jdxfunction.h  -  description
00003                              -------------------
00004     begin                : Mon Jun 24 2002
00005     copyright            : (C) 2002 by Thies H. Jochimsen
00006     email                : jochimse@cns.mpg.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 #ifndef JDXFUNCTION_H
00018 #define JDXFUNCTION_H
00019 
00020 #include <odinpara/jdxblock.h>
00021 
00027 enum funcType {shapeFunc=0, trajFunc, filterFunc};
00028 
00039 enum funcMode {zeroDeeMode=0,oneDeeMode,twoDeeMode,n_dimModes};
00040 
00042 
00043 class OdinPulse; // forward declaration
00044 
00046 
00052 struct kspace_coord {
00053 
00054   kspace_coord() : index(-1), traj_s(0.0), kx(0), ky(0), kz(0), Gx(0), Gy(0), Gz(0), denscomp(1.0) {}
00055 
00059   mutable int index;
00060 
00064   float traj_s;
00065 
00069   float kx;
00070 
00074   float ky;
00075 
00079   float kz;
00080 
00084   float Gx;
00085 
00089   float Gy;
00090 
00094   float Gz;
00095 
00099   float denscomp;
00100 };
00101 
00102 
00104 
00105 struct shape_info {
00106 
00107   shape_info() : ref_x_pos(0), ref_y_pos(0), ref_z_pos(0), adiabatic(false), fixed_size(-1), spatial_extent(0.0) {}
00108 
00109   float ref_x_pos; // Reference position to adjust flip angle
00110   float ref_y_pos;
00111   float ref_z_pos;
00112   bool adiabatic; // Whether pulse is adiabatic
00113   int fixed_size; // Pulse has fixed size (for imported pulses)
00114   float spatial_extent;
00115 };
00116 
00118 
00119 struct traj_info {
00120 
00121   traj_info() : rel_center(0), max_kspace_step(0) {}
00122 
00123   float rel_center;
00124   float max_kspace_step;
00125 
00126 };
00127 
00129 
00130 class JDXfunctionPlugIn : public JcampDxBlock {
00131 
00132  public:
00133   JDXfunctionPlugIn(const STD_string& funclabel) : JcampDxBlock(funclabel) {}
00134 
00135   JDXfunctionPlugIn(const JDXfunctionPlugIn& jfp) : JcampDxBlock(jfp) {}
00136 
00137   virtual ~JDXfunctionPlugIn() {}
00138 
00139   JDXfunctionPlugIn& operator = (const JDXfunctionPlugIn& jfp) {JcampDxBlock::operator = (jfp); return *this;}
00140 
00141   JDXfunctionPlugIn& register_function(funcType type, funcMode mode);
00142 
00143   // virtual functions for pulse shapes
00144   virtual void init_shape() {}
00145   virtual STD_complex calculate_shape(const kspace_coord& coord ) const {return STD_complex(0.0);}
00146   virtual STD_complex calculate_shape(float s, float Tp) const {return STD_complex(0.0);}
00147   virtual const shape_info& get_shape_properties() const {return shape_info_retval;}
00148 
00149 
00150   // virtual functions for pulse trajectories
00151   virtual void init_trajectory(OdinPulse* pls) {}
00152   virtual const kspace_coord& calculate_traj(float s) const {return coord_retval;}
00153   virtual const traj_info& get_traj_properties() const {return traj_info_retval;}
00154 
00155   // virtual functions for filters
00156   virtual float calculate_filter(float rel_kradius) const {return 0;}
00157 
00158 
00159 
00160   // virtual constructor
00161   virtual JDXfunctionPlugIn* clone() const = 0;
00162 
00163   // local statics do not work on IDEA
00164   static kspace_coord coord_retval;
00165 //  static shape_vals   shape_retval;
00166   static shape_info   shape_info_retval;
00167   static traj_info    traj_info_retval;
00168 
00169 };
00170 
00171 
00173 
00174 // Wrapper to bundle JDXfunctionPlugIn and funcType/funcMode together so it can be inserted into lists
00175 // multiple times with different funcTypes and funcModes
00176 struct JDXfunctionEntry {
00177 
00178   JDXfunctionEntry(JDXfunctionPlugIn* func_plugin, funcType func_type, funcMode func_mode)
00179     : plugin(func_plugin), type(func_type),  mode(func_mode) {}
00180 
00181   JDXfunctionPlugIn* plugin;
00182 
00183   const funcType type;
00184   const funcMode mode;
00185 
00186   bool operator == (const JDXfunctionEntry& jfe) const;
00187   bool operator <  (const JDXfunctionEntry& jfe) const;
00188 
00189 };
00190 
00192 
00193 
00194 class JDXfunction : public JcampDxClass, public StaticHandler<JDXfunction> {
00195 
00196  public:
00197 
00198   ~JDXfunction() {new_plugin(0);}
00199 
00200   JDXfunction& set_function_mode(funcMode newmode);
00201   funcMode get_function_mode() const {return mode;}
00202 
00203   const STD_string& get_function_label(unsigned int index) const;
00204   JDXfunction& set_function(const STD_string& funclabel);
00205   JDXfunction& set_function(unsigned int index);
00206   unsigned int get_function_index() const;
00207 
00208   JcampDxBlock* get_funcpars_block();
00209 
00210   JDXfunction& set_funcpars(const svector& funcpars);
00211   JDXfunction& set_funcpars(const STD_string& funcpars) {STD_string tt(funcpars); parsevalstring(tt); return *this;}
00212   svector get_funcpars() const;
00213 
00214   bool set_parameter(const STD_string& parameter_label, const STD_string& value);
00215   STD_string get_parameter(const STD_string& parameter_label) const;
00216 
00217   STD_string get_function_name() const;
00218 
00219   const STD_string& get_funcdescription() const;
00220 
00221 
00222   // overwriting virtual functions from JcampDxClass
00223   JDXfunction* cast(JDXfunction*) {return this;}
00224   bool parsevalstring (const STD_string& parstring);
00225   STD_string printvalstring() const;
00226   svector get_alternatives() const;
00227   const char* get_typeInfo() const {return "function";}
00228   JcampDxClass* create_copy() const {return new JDXfunction(*this);}
00229 
00230 
00231   // stuff for StaticHandler
00232   static void init_static();
00233   static void destroy_static();
00234 
00235 
00236  protected:
00237 
00238   // Make it impossible to create/use instance of JDXfunction directly
00239   JDXfunction(funcType function_type, const STD_string& jdxlabel);
00240   JDXfunction(const JDXfunction& jf);
00241   JDXfunction& operator = (const JDXfunction& jf);
00242 
00243   funcMode mode;
00244   JDXfunctionPlugIn* allocated_function;
00245 
00246  private:
00247   friend class JDXfunctionPlugIn;
00248 
00249 
00250 
00251 
00252   void new_plugin(JDXfunctionPlugIn* pi);
00253 
00254   const funcType type;
00255 
00256 
00257   static STD_list<JDXfunctionEntry>* registered_functions;
00258 
00259 };
00260 
00261 
00265 #endif
00266 
00267 

Generated on Tue Dec 18 2012 15:11:14 by  doxygen 1.7.1