Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Track.cxx

Go to the documentation of this file.
00001 // $Heading: Track.cxx $
00002 //   Author: T. Burnett
00003 //
00004 
00005 #include "geometry/Track.h"
00006 #include "geometry/Ray.h"
00007 
00008 
00009 Ray* Track::currentRay;
00010 double Track::currentArcLength;
00011 
00012 
00013 float Track::maxKink = 0.2f;//0.05;
00014 
00015 Track::Track( Ray* first, bool charged)
00016 : m_charged(charged)
00017 {
00018    rayList.push_back( first);
00019    arclength = first->getArcLength();
00020    currentRay = first;
00021 }
00022 
00023 Track::~Track()
00024 {
00025     Raylist::iterator rayptr = rayList.begin();
00026     while( rayptr < rayList.end() )
00027         delete *rayptr++;
00028 }
00029 
00030 GeomObject&
00031 Track::transform(const CoordTransform& T)
00032 {
00033   for(unsigned i=0; i< rayList.size(); i++)
00034     rayList[i]->transform(T);
00035   return *this;
00036 }
00037 void Track::findSegment( double s )
00038 {  unsigned i=0;
00039    currentRay = rayList[0];
00040    currentArcLength = 0.;
00041    double ds = currentRay->getArcLength();
00042    while ( i<rayList.size() && s > currentArcLength+ds) {
00043         currentArcLength += ds;
00044         currentRay =rayList[++i];
00045         ds = currentRay->getArcLength();
00046    }
00047 }
00048 
00049 void Track::addSegment( Ray* next )
00050 {
00051   float ds = next->getArcLength();
00052   arclength += ds;
00053 /*
00054 //  This section of code fails when multiple scattering is present
00055    if( currentRay->curvature()==0
00056             && next->curvature()==0 )
00057    {
00058       // this is a continuation of a straight ray. Eventually want
00059       // to generalize it to helices
00060        currentRay->addArcLength( ds );
00061        delete next;
00062    }
00063    else
00064    {   append( (GmsListLink*)next );
00065        currentRay = next;
00066    }
00067 */
00068 //   Till I(WBA) have time to fix this
00069    rayList.push_back( next );
00070    currentRay = next;
00071 
00072 }
00073 
00074 void Track::printOn(std::ostream& os) const
00075 {
00076     os << "Track:  total arclength = "<< arclength << '\n';
00077     for( unsigned i=0; i<rayList.size(); i++ )
00078         rayList[i]->printOn(os);
00079 }
00080 
00081 Point
00082 Track::position( double s ) const
00083 {
00084    Track* self = (Track*)this; // have to cast to non-const
00085    self->findSegment(s);
00086    return currentRay->position(s-currentArcLength);
00087 }
00088 
00089 Vector Track::direction( double s ) const
00090 {
00091    Track* self = const_cast<Track*>(this); // have to cast to non-const
00092    self->findSegment(s);
00093    return currentRay->direction(s-currentArcLength);
00094 }
00095 
00096 
00097 

Generated at Mon Nov 26 18:18:21 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000