コード例 #1
0
RAT::DS::MCTrack JoinMCTracks(std::vector<RAT::DS::MCTrack> theTrackList)
{
	//Typedef the time ordered set of tracks.
	typedef std::set<RAT::DS::MCTrack,TrackTimeOrdering> TOTrackSet;
	//Build a time ordered set of tracks.
	TOTrackSet TOTracks( theTrackList.begin(), theTrackList.end() );
	
	//Now create a new track that we will fill with all of the old steps.  We
	//can use a copy of the first track to get started.
	RAT::DS::MCTrack theJoinedTrack = *TOTracks.begin();
	
	//Now just iterate over all members of the set and fill the new track with
	//the old steps.
	typedef TOTrackSet::iterator setIt; 
	//Get an iterator to the beginning of the TOTracks and move it forward one
	//step past the very first.
	setIt TOTracksIterator = TOTracks.begin();
	TOTracksIterator++;
	
	while ( TOTracksIterator != TOTracks.end() )
	{
		for ( int i = 0; i < TOTracksIterator->GetMCTrackStepCount(); i++ )
		{
			*theJoinedTrack.AddNewMCTrackStep() = *TOTracksIterator->GetMCTrackStep(i); 
		}
		TOTracksIterator++;
	}
	
	return theJoinedTrack;
}