{
unsigned path = 1<<i;
endpoints[i].paths |= path;
- set<Track *> visited;
- find_paths(*endpoints[i].track, endpoints[i].track_ep, path, visited);
+ find_paths(TrackIter(endpoints[i].track, endpoints[i].track_ep), path);
}
layout.add_block(*this);
return false;
}
-void Block::find_paths(Track &track, unsigned track_ep, unsigned path, set<Track *> &visited)
+void Block::find_paths(TrackIter track, unsigned path)
{
- visited.insert(&track);
-
- const vector<TrackType::Endpoint> &eps = track.get_type().get_endpoints();
- for(unsigned i=0; i<eps.size(); ++i)
- {
- if(i==track_ep) continue;
- Track *link = track.get_link(i);
- if(!link) continue;
- if(visited.count(link)) continue;
- if(!(eps[i].paths&eps[track_ep].paths)) continue;
-
- if(tracks.count(link))
- find_paths(*link, link->get_endpoint_by_link(track), path, visited);
- else
+ unsigned mask = track->get_type().get_endpoints()[track.entry()].paths;
+ for(unsigned i=0; mask>>i; ++i)
+ if(mask&(1<<i))
{
- for(vector<Endpoint>::iterator j=endpoints.begin(); j!=endpoints.end(); ++j)
- if(j->track==&track && j->track_ep==i)
- j->paths |= path;
+ TrackIter next = track.next(i);
+ if(!next)
+ continue;
+ else if(has_track(*next))
+ find_paths(track.next(i), path);
+ else
+ {
+ next = next.flip();
+ for(vector<Endpoint>::iterator j=endpoints.begin(); j!=endpoints.end(); ++j)
+ if(j->track==next.track() && j->track_ep==next.entry())
+ j->paths |= path;
+ }
}
- }
}
void Block::determine_id()