00001
00002
00003
00004 #ifndef GISMO_RCParticle_H
00005 #define GISMO_RCParticle_H
00006
00007 #include "gismo/GParticle.h"
00008 #include "geometry/Ray.h"
00009 #include <vector>
00010
00011 class Medium;
00012
00014
00015
00016
00017
00018
00019
00020 class RCParticle : public GParticle
00021 {
00022
00023 public:
00025 RCParticle(Point x0, Vector t0, float dist);
00026
00028 ~RCParticle();
00029
00031 enum Status {ALIVE, LEFT, LOST, STUCK, DONE};
00032
00034 RCParticle::Status status() const;
00036 void setStatus(RCParticle::Status);
00037
00039 void setMaxArcLength(float dist);
00040
00042 float increaseMaxArcLenBy(float dist);
00043
00045 virtual void propagate();
00046
00048 bool propagate(const char * title);
00049
00050 void printOn( std::ostream& ) const;
00051
00052
00054 int stepCount() const ;
00055 float stepLength() const;
00056 float arclength() const;
00057 float radlength() const;
00058 float currentTime() const;
00059 Point position(float s) const;
00060 Point position() const;
00061 Point getHit(int) const;
00062 Vector direction(float s) const;
00063 Vector direction() const;
00064 float mScat_Angle(float momentum, float s) const;
00065 float mScat_Angle(float momentum, int step_no) const;
00066 float mScat_Dist(float momentum, float s) const;
00067 float mScat_Dist(float momentum, int step_no) const;
00068
00070 const Medium *medium() const;
00071
00073 int findMedium(const char * name) const;
00074
00076 const Medium* getCurrentMedium () { return m_currentMedium; }
00077
00079 const Medium* getMedium (int) const;
00080
00081
00082
00083
00084
00085 class Step
00086 {
00087 public:
00088 Step(const Medium * med, Point x, Vector t, float s, float x0);
00089 ~Step() {};
00090
00091 Point position() const {return m_pos;}
00092 Vector direction() const {return m_dir;}
00093 float length() const {return m_step_length;}
00094 float rad_len() const {return m_rad_length;}
00095 const Medium * place() const {return m_region;}
00096 void printOn( std::ostream& ) const;
00097
00098 private:
00099 Point m_pos;
00100 Vector m_dir;
00101 float m_step_length;
00102 float m_rad_length;
00103 const Medium * m_region;
00104 };
00105
00106
00107 typedef std::vector<Step> StepList;
00108 typedef std::vector<Step>::const_iterator const_iterator;
00109
00110 const StepList& steps() const {return m_stepList;}
00111 const_iterator begin() const {return m_stepList.begin();}
00112 const_iterator end() const {return m_stepList.end();}
00113
00114
00115 static const Medium* s_world;
00116
00117 protected:
00118
00119 Status m_status;
00120 const Medium *m_lastMedium;
00121 void stepBy(float, Ray&);
00122 void ini();
00123
00124 StepList m_stepList;
00125
00126 double m_startingEnergy;
00127 float m_arcLength;
00128 float m_radLength;
00129 float m_properTime;
00130 float m_step;
00131 float m_maxStep;
00132 float m_maxArcLen;
00133 int m_stepcount;
00134 const Medium* m_currentMedium;
00135
00136 };
00137
00138 inline RCParticle::Status RCParticle::status()const{return m_status;}
00139 inline void RCParticle::setStatus(RCParticle::Status s){m_status = s;}
00140 inline int RCParticle::stepCount() const {return m_stepcount;}
00141
00142 inline void RCParticle::setMaxArcLength(float dist) {m_maxArcLen = dist; return;}
00143 inline float RCParticle::increaseMaxArcLenBy(float dist)
00144 {
00145 m_maxArcLen += dist; return m_maxArcLen;
00146 }
00147 inline float RCParticle::stepLength() const {return m_step;}
00148 inline float RCParticle::arclength() const {return m_arcLength;}
00149 inline float RCParticle::radlength() const {return m_radLength;}
00150 inline float RCParticle::currentTime()const {return m_properTime;}
00151 inline Point RCParticle::position() const
00152 {
00153 return GParticle::position();
00154 }
00155 inline Vector RCParticle::direction() const
00156 {
00157 return GParticle::direction();
00158 }
00159 inline Point RCParticle::position(float s) const
00160 {
00161 return position() + s*direction();
00162 }
00163 inline Vector RCParticle::direction(float s) const
00164 {
00165 return GParticle::direction();
00166 }
00167
00168 inline const Medium * RCParticle::medium()const {return m_lastMedium;}
00169 inline const Medium * RCParticle::getMedium(int ith) const
00170 {
00171 return m_stepList[ith].place();
00172 }
00173 inline Point RCParticle::getHit(int ith) const
00174 {
00175 return m_stepList[ith].position();
00176 }
00177 #endif
00178