예제 #1
0
bool Sequence::initFromPattern( const std::string& pattern, const std::vector<FrameRange>& frameRanges, const EPattern accept )
{
	if( !retrieveInfosFromPattern( pattern, accept, _prefix, _suffix, _padding, _strictPadding ) )
		return false; // not regognize as a pattern, maybe a still file
	_ranges.clear();
	_ranges = frameRanges;
	return true;
}
예제 #2
0
bool Sequence::init( const std::string& pattern, const Time firstTime, const Time lastTime, const Time step, const EPattern accept )
{
	if( !retrieveInfosFromPattern( pattern, accept, _prefix, _suffix, _padding, _strictPadding ) )
		return false; // not regognize as a pattern, maybe a still file
	_firstTime = firstTime;
	_lastTime = lastTime;
	_step = step;
	_nbFiles = 0;
	//std::cout << "init => " <<  _firstTime << " > " << _lastTime << " : " << _nbFiles << std::endl;
	return true;
}
예제 #3
0
bool Sequence::initFromDetection( const std::string& pattern, const EPattern accept )
{
	clear();
	setDirectoryFromPath( pattern );

	if( !retrieveInfosFromPattern( boost::filesystem::path( pattern ).filename().string(), accept, _prefix, _suffix, _padding, _strictPadding ) )
		return false; // not recognized as a pattern, maybe a still file
	if( !boost::filesystem::exists( _directory ) )
		return true; // an empty sequence

	std::vector<std::string> allTimesStr;
	std::vector<Time> allTimes;
	bfs::directory_iterator itEnd;

	for( bfs::directory_iterator iter( _directory ); iter != itEnd; ++iter )
	{
		// we don't make this check, which can take long time on big sequences (>1000 files)
		// depending on your filesystem, we may need to do a stat() for each file
		//      if( bfs::is_directory( iter->status() ) )
		//          continue; // skip directories
		Time time;
		std::string timeStr;

		// if the file is inside the sequence
		if( isIn( iter->path().filename().string(), time, timeStr ) )
		{
			// create a big vector of all times in our sequence
			allTimesStr.push_back( timeStr );
			allTimes.push_back( time );
		}
	}
	if( allTimes.size() < 2 )
	{
		if( allTimes.size() == 1 )
		{
			_firstTime = _lastTime = allTimes.front();
		}
		//std::cout << "empty => " <<  _firstTime << " > " << _lastTime << " : " << _nbFiles << std::endl;
		return true; // an empty sequence
	}
	std::sort( allTimes.begin(), allTimes.end() );
	extractStep( allTimes );
	extractPadding( allTimesStr );
	extractIsStrictPadding( allTimesStr, _padding );
	_firstTime = allTimes.front();
	_lastTime = allTimes.back();
	_nbFiles = allTimes.size();
	//std::cout << _firstTime << " > " << _lastTime << " : " << _nbFiles << std::endl;
	return true; // a real file sequence
}