00001
00002
00003
00004 #include "geomrep/TrackRep.h"
00005 #include "geometry/Ray.h"
00006
00007 bool TrackRep::useColor=true;
00008 unsigned TrackRep::charged_color_index=1;
00009 unsigned TrackRep::neutral_color_index=0;
00010
00011 float TrackRep::delta = 0.005f;
00012
00013 float TrackRep::minStepSize = 0.5f;
00014
00015
00016 void TrackRep::update()
00017 {
00018 if( useColor )
00019 set_col_index( m_track.charged()? charged_color_index : neutral_color_index );
00020 else
00021 set_line_style( m_track.charged()? SOLID_LINE : DOTTED_LINE );
00022
00023 noDetailCheck();
00024 move_to(m_track.position(0));
00025
00026 for( Track::const_iterator it= m_track.begin(); it !=m_track.end(); ++it) {
00027 const Ray* r = *it;
00028 float stot = r->getArcLength();
00029 float kappa;
00030 if( (kappa=r->curvature())!=0 ){
00031
00032 float step = sqrt(8*delta/fabs(kappa));
00033 if( step< minStepSize) step=minStepSize;
00034 if(stot > 100000) continue;
00035 int nstep = (int) ( stot / step );
00036 if(nstep>1) {
00037 step = stot/nstep;
00038 float s=0;
00039 for( int j=0; j<nstep ; j++ )
00040 line_to(r->position(s+=step));
00041 }
00042 }
00043 line_to(r->position(stot));
00044 }
00045 flush();
00046 }
00047
00048