Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4508 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Jun 4, 2005, 2:29:11 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: implemented a better backloop-check in the track-system
also implemented a new function in tList: inList() that returns tru, if a certain element is already in the List and false otherwise

Location:
orxonox/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/util/list.h

    r4500 r4508  
    110110  int getSize();
    111111  //T* enumerate();
     112  bool inList(T* entity);
    112113  tIterator<T>* getIterator();
    113114  T* nextElement(T* toEntity);
     
    258259}
    259260
     261/**
     262   \brief checks if an entity is in the List
     263   \param entity The entity to check for in the entire List.
     264   \returns true if it is, false otherwise
     265*/
     266template<class T>
     267inline bool tList<T>::inList(T* entity)
     268
     269  // pre checks
     270  if(this->size == 0) return false;
     271  if( entity == NULL) return false;
     272
     273  // search in the List
     274  this->currentEl = this->first;
     275  while(this->currentEl->curr != entity && this->currentEl != NULL)
     276    this->currentEl = this->currentEl->next;
     277
     278  // post checks
     279  if(this->currentEl == NULL)
     280    return false;
     281  else
     282    return true;
     283}
    260284
    261285/**
  • orxonox/trunk/src/story_entities/world.cc

    r4504 r4508  
    570570  trackManager->addPointV(Vector(970, 24, 40));
    571571  trackManager->addPointV(Vector(1000, 40, -7));
     572
    572573  trackManager->setDuration(4);
    573574     
  • orxonox/trunk/src/util/track/track_manager.cc

    r4502 r4508  
    149149
    150150/**
    151    \brief checks if there are any BackLoops in the Track (Backloops only
    152    \param trackElem the trackElement to check about
    153    \param depth the depth to search in
     151   \brief checks if there are any BackLoops in the Track
    154152   \returns true if NO loop was found, false Otherwise
    155153   You actually have to act on false!!
    156    it simply does this by looking if the current trackElem is found again somewhere else in the Track
    157 
    158    \todo this has to be reimplemented
    159 */
    160 bool TrackElement::backLoopCheck(const TrackElement* trackElem, unsigned int depth) const
    161 {
    162   if(depth == 0 || this != trackElem)
    163     {
    164       if (this->children)
    165         {
    166           tIterator<TrackElement>* iterator = this->children->getIterator();
    167           TrackElement* enumElem = iterator->nextElement();
    168           while (enumElem)
    169             {
    170               if(!enumElem->backLoopCheck(trackElem, depth + 1))
    171                 return false;
    172               enumElem = iterator->nextElement();
    173             }
    174           delete iterator;
    175         }
    176     }
    177   else
    178     return false;
    179 
     154*/
     155bool TrackElement::backLoopCheck(void) const
     156{
     157  tList<const TrackElement>* trackList = new tList<const TrackElement>;
     158 
     159  this->backLoopCheckAtomic(trackList);
     160 
     161  delete trackList;
    180162  // only returns if everything worked out
    181163  return true;
    182164}
     165
     166/**
     167   \brief checks if there are any BackLoops in the Track.
     168   \param trackList A list of stored tracks, to search in.
     169   \returns true if NO loop was found, false Otherwise
     170   You actually have to act on false!!
     171*/
     172bool TrackElement::backLoopCheckAtomic(tList<const TrackElement>* trackList) const
     173{
     174  if (trackList->inList(this))
     175    return false;
     176
     177  trackList->add(this);
     178
     179  if (this->children)
     180    {
     181      tIterator<TrackElement>* iterator = this->children->getIterator();
     182      TrackElement* enumElem = iterator->nextElement();
     183      while (enumElem)
     184        {
     185          if (!enumElem->backLoopCheckAtomic(trackList))
     186            return false;
     187        }
     188      delete iterator;
     189    }
     190  return true;
     191}
     192
    183193
    184194/**
     
    264274    PRINT(0)("   is Joined at the End\n");
    265275 
    266   if(!this->backLoopCheck(this)) /* this should not happen */
     276  if(!this->backLoopCheck()) /* this should not happen */
    267277    PRINT(2)(" THERE IS A BACKLOOP TO THIS ELEMENT\n");
    268278}
     
    916926  // checking if there is a back-loop-connection and ERROR if it is.
    917927  tmpTrackElem = this->firstTrackElem->findByID(trackIDs[0]);
    918   if (!tmpTrackElem->backLoopCheck(tmpTrackElem))
     928  if (!tmpTrackElem->backLoopCheck())
    919929    {
    920930      PRINTF(2)("Backloop connection detected at joining trackElements\n -> TRACK WILL NOT BE JOINED\n");
  • orxonox/trunk/src/util/track/track_manager.h

    r4502 r4508  
    4848  TrackElement* findByID(unsigned int trackID);
    4949  TrackElement* findByName(const char* trackName);
    50   bool backLoopCheck(const TrackElement* trackElem, unsigned int depth = 0) const;
     50  bool backLoopCheck(void) const;
    5151
    5252  TrackElement* getChild(int childNumber) const;
     
    5555  inline const char* getName(void) const { return this->name; };
    5656
    57 
     57 private:
     58  bool backLoopCheckAtomic(tList<const TrackElement>* trackList) const;
     59
     60 public:
    5861  // atributes
    5962  bool                  isFresh;              //!< If no Points where added until now
Note: See TracChangeset for help on using the changeset viewer.