本文整理汇总了C++中Files::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Files::begin方法的具体用法?C++ Files::begin怎么用?C++ Files::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Files
的用法示例。
在下文中一共展示了Files::begin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: forEachFile
void DirView::forEachFile(FileEnumCallback f, void *user, bool /*ignored*/)
{
Files flist; // TODO: optimize allocation
for(ViewList::reverse_iterator it = _view.rbegin(); it != _view.rend(); ++it)
(*it)->forEachFile(_addFileCallback, &flist);
for(Files::iterator it = flist.begin(); it != flist.end(); ++it)
f(it->second, user);
}
示例2: run
int App::run()
{
_options.parse();
#ifdef DEBUG
_options.dump(cerr);
cerr << "\n";
#endif
Files f = _options.files();
for (Files::iterator it = f.begin(); it != f.end(); it++)
{
char cmd[255] = {0};
sprintf(cmd, "deltree /y %s", it->c_str());
system(cmd); // temporary solution
}
return 0;
}
示例3: open
bool open(osg::Group* group)
{
Files files;
readMasterFile(files);
for(Files::iterator itr = files.begin();
itr != files.end();
++itr)
{
osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFile(*itr);
if (model)
{
osg::notify(osg::NOTICE)<<"open: Loaded file "<<*itr<<std::endl;
group->addChild(model);
_existingFilenameNodeMap[*itr] = model;
}
}
return true;
}
示例4: DumpFiles
void DumpFiles( const Files& files, BOOL bOnlyFileName )
{
if(files.empty())
{
_tprintf(_T("Empty Files\r\n"));
}
else
{
int i=0;
for(Files::const_iterator it=files.begin(); it!=files.end(); ++it)
{
++i;
LPCTSTR szFile = *it;
if(bOnlyFileName)
{
LPCTSTR szName = _tcsrchr(szFile, _T('\\'));
if(szName)
szFile = ++szName;
}
_tprintf(_T("%d/%d %s\r\n"), i, files.size(), szFile);
}
}
}
示例5: readImage
virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
notice()<<"Reading DICOM file "<<file<<" using DCMTK"<<std::endl;
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = file;
if (ext=="dicom")
{
fileName = osgDB::getNameLessExtension(file);
}
fileName = osgDB::findDataFile( fileName, options );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
Files files;
osgDB::FileType fileType = osgDB::fileType(fileName);
if (fileType==osgDB::DIRECTORY)
{
getDicomFilesInDirectory(fileName, files);
}
else
{
#if 1
files.push_back(fileName);
#else
if (!getDicomFilesInDirectory(osgDB::getFilePath(fileName), files))
{
files.push_back(fileName);
}
#endif
}
if (files.empty())
{
return ReadResult::FILE_NOT_FOUND;
}
osg::ref_ptr<osg::RefMatrix> matrix = new osg::RefMatrix;
osg::ref_ptr<osg::Image> image;
unsigned int imageNum = 0;
EP_Representation pixelRep = EPR_Uint8;
int numPlanes = 0;
GLenum pixelFormat = 0;
GLenum dataType = 0;
unsigned int pixelSize = 0;
typedef std::list<FileInfo> FileInfoList;
FileInfoList fileInfoList;
typedef std::map<double, FileInfo> DistanceFileInfoMap;
typedef std::map<osg::Vec3d, DistanceFileInfoMap> OrientationFileInfoMap;
OrientationFileInfoMap orientationFileInfoMap;
unsigned int totalNumSlices = 0;
for(Files::iterator itr = files.begin();
itr != files.end();
++itr)
{
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile((*itr).c_str());
if(!status.good()) return ReadResult::ERROR_IN_READING_FILE;
FileInfo fileInfo;
fileInfo.filename = *itr;
double pixelSize_y = 1.0;
double pixelSize_x = 1.0;
double sliceThickness = 1.0;
double imagePositionPatient[3] = {0, 0, 0};
double imageOrientationPatient[6] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0 };
Uint16 numOfSlices = 1;
double value = 0.0;
if (fileformat.getDataset()->findAndGetFloat64(DCM_PixelSpacing, value,0).good())
{
pixelSize_y = value;
fileInfo.matrix(1,1) = pixelSize_y;
}
if (fileformat.getDataset()->findAndGetFloat64(DCM_PixelSpacing, value,1).good())
{
pixelSize_x = value;
fileInfo.matrix(0,0) = pixelSize_x;
}
// Get slice thickness
if (fileformat.getDataset()->findAndGetFloat64(DCM_SliceThickness, value).good())
{
sliceThickness = value;
notice()<<"sliceThickness = "<<sliceThickness<<std::endl;
fileInfo.sliceThickness = sliceThickness;
}
notice()<<"tagExistsWithValue(DCM_NumberOfFrames)="<<fileformat.getDataset()->tagExistsWithValue(DCM_NumberOfFrames)<<std::endl;
notice()<<"tagExistsWithValue(DCM_NumberOfSlices)="<<fileformat.getDataset()->tagExistsWithValue(DCM_NumberOfSlices)<<std::endl;
//.........这里部分代码省略.........
示例6: main
int main(int argc, char** argv)
{
if(argc < 3){
cout << "Prague metadata tool" << endl;
cout << "Usage: " << argv[0] <<" [-s] [-c] [-o <output file>] <metadata filename1>...<metadata filenameN>" << endl;
cout << "\t-s\t\t" << "change byteorder of metadata from little-endian to big-endian" << endl;
cout << "\t-c\t\t" << "save in metacache format" << endl;
cout << "\t-m\t\t" << "save in multimeta format" << endl;
cout << "\t-o <filename>\t" << "name of output file [default is out.meta]" << endl;
return -1;
}
bool swap = false;
bool cache = false;
bool multi = false;
Files files;
int i = 1;
string outfile("out.meta");
while(i < argc){
if(argv[i][0] == '-'){
switch(argv[i++][1]){
case 's': swap = true; break;
case 'c': cache = true; break;
case 'm': multi = true; break;
case 'o':
if(i < argc)
outfile = argv[i++];
else
cerr << "an output file is not specified" << endl;
break;
default: cerr << "unknown option '" << argv[i][1] << "'" << endl;
}
}
else
files.push_back(argv[i++]);
}
PragueMetadata metadata;
MetaLoader<GetLEValue> loader;
for(Files::const_iterator i = files.begin(); i != files.end(); ++i)
if(!loader.load(i->c_str(), metadata)){
cerr << "Can't load metadata from " << *i << endl;
continue;
}
bool result = false;
if(swap){
MetaSaver<SaveBEValue> saver;
if(!saver.open(outfile.c_str())){
cerr << "can't open " << outfile << endl;
return -1;
}
if(cache)
result = saver.saveCache(metadata);
else if(multi || (metadata.count() > 1))
result = saver.saveMulti(metadata);
else
result = saver.saveOne(metadata);
}
else{
MetaSaver<SaveValue> saver;
if(!saver.open(outfile.c_str())){
cerr << "can't open " << outfile << endl;
return -1;
}
if(cache)
result = saver.saveCache(metadata);
else if(multi || (metadata.count() > 1))
result = saver.saveMulti(metadata);
else
result = saver.saveOne(metadata);
}
if(!result){
cerr << "Can't save metadata to " << outfile << endl;
return -1;
}
return 0;
}
示例7: _iterFiles
static void _iterFiles(Files &m, FileEnumCallback f, void *user)
{
for(Files::iterator it = m.begin(); it != m.end(); ++it)
f(it->second.content(), user);
}
示例8: load
void load()
{
//osg::notify(osg::NOTICE)<<"void load(Object)"<<std::endl;
Files filesA;
Files filesB;
readMasterFile(filesB);
// osg::notify(osg::NOTICE)<<"First read "<<filesA.size()<<std::endl;
// itererate until the master file is stable
do
{
OpenThreads::Thread::microSleep(100000);
filesB.swap(filesA);
filesB.clear();
readMasterFile(filesB);
// osg::notify(osg::NOTICE)<<"second read "<<filesB.size()<<std::endl;
} while (filesA!=filesB);
Files files;
files.swap(filesB);
// osg::notify(osg::NOTICE)<<"Now equal "<<files.size()<<std::endl;
Files newFiles;
Files removedFiles;
// find out which files are new, and which ones have been removed.
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
for(Files::iterator fitr = files.begin();
fitr != files.end();
++fitr)
{
if (_existingFilenameNodeMap.count(*fitr)==0) newFiles.insert(*fitr);
}
for(FilenameNodeMap::iterator litr = _existingFilenameNodeMap.begin();
litr != _existingFilenameNodeMap.end();
++litr)
{
if (files.count(litr->first)==0)
{
removedFiles.insert(litr->first);
}
}
}
#if 0
if (!newFiles.empty() || !removedFiles.empty())
{
osg::notify(osg::NOTICE)<<std::endl<<std::endl<<"void operator () files.size()="<<files.size()<<std::endl;
}
#endif
// first load the new files.
FilenameNodeMap nodesToAdd;
if (!newFiles.empty())
{
typedef std::vector< osg::ref_ptr<osg::GraphicsThread> > GraphicsThreads;
GraphicsThreads threads;
for(unsigned int i=0; i<= osg::GraphicsContext::getMaxContextID(); ++i)
{
osg::GraphicsContext* gc = osg::GraphicsContext::getCompileContext(i);
osg::GraphicsThread* gt = gc ? gc->getGraphicsThread() : 0;
if (gt) threads.push_back(gt);
}
if (_operationQueue.valid())
{
// osg::notify(osg::NOTICE)<<"Using OperationQueue"<<std::endl;
_endOfLoadBlock = new osg::RefBlockCount(newFiles.size());
_endOfLoadBlock->reset();
typedef std::list< osg::ref_ptr<LoadAndCompileOperation> > LoadAndCompileList;
LoadAndCompileList loadAndCompileList;
for(Files::iterator nitr = newFiles.begin();
nitr != newFiles.end();
++nitr)
{
// osg::notify(osg::NOTICE)<<"Adding LoadAndCompileOperation "<<*nitr<<std::endl;
osg::ref_ptr<LoadAndCompileOperation> loadAndCompile = new LoadAndCompileOperation( *nitr, _incrementalCompileOperation.get(), _endOfLoadBlock.get() );
loadAndCompileList.push_back(loadAndCompile);
_operationQueue->add( loadAndCompile.get() );
}
#if 1
osg::ref_ptr<osg::Operation> operation;
while ((operation=_operationQueue->getNextOperation()).valid())
//.........这里部分代码省略.........
示例9: RemoveFiles
// Remove the files in the given list of files
void RemoveFiles(const Files &files)
{
std::for_each(files.begin(), files.end(), [](const std::string &file) { remove(file.c_str()); });
}