/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield * * This application is open source and may be redistributed and/or modified * freely and without restriction, both in commericial and non commericial applications, * as long as this copyright notice is maintained. * * This application is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include #include #include #include #include #include #include #include class proxy_streambuf : public std::streambuf { public: proxy_streambuf(std::streambuf* streambuf, unsigned int numChars): _streambuf(streambuf), _numChars(numChars) {} /// Destructor deallocates no buffer space. virtual ~proxy_streambuf() {} std::streambuf* _streambuf; unsigned int _numChars; protected: virtual int_type uflow () { if (_numChars==0) return -1; --_numChars; return _streambuf->sbumpc(); } }; int main( int argc, char **argv ) { /* std::ifstream fin("GNUmakefile"); std::istream& ins = fin; proxy_streambuf mystreambuf(ins.rdbuf(),10000); ins.rdbuf(&mystreambuf); while (!fin.eof()) { std::cout.put(fin.get()); } std::cout<<"Exiting normally "<setApplicationName(arguments.getApplicationName()); arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); // if user request help write it out to cout. if (arguments.read("-h") || arguments.read("--help")) { arguments.getApplicationUsage()->write(std::cout); return 1; } std::string archiveFilename; while (arguments.read("-a",archiveFilename) || arguments.read("--archive",archiveFilename)) { } bool insert = false; while (arguments.read("-i") || arguments.read("--insert")) { insert = true; } bool extract = false; while (arguments.read("-e") || arguments.read("--extract")) { extract = true; } bool list = false; while (arguments.read("-l") || arguments.read("--list")) { list = true; } typedef std::vector FileNameList; FileNameList files; for(int pos=1;pos obj = osgDB::readObjectFile(*itr); if (obj.valid()) { archive.writeObject(*obj, *itr); } } } else { archive.open(archiveFilename,osgDB::Archive::READ); if (extract) { for (FileNameList::iterator itr=files.begin(); itr!=files.end(); ++itr) { osg::Timer_t start = osg::Timer::instance()->tick(); osgDB::ReaderWriter::ReadResult result = archive.readObject(*itr); osg::ref_ptr obj = result.getObject(); std::cout<<"readObejct time = "<delta_m(start,osg::Timer::instance()->tick())<first<<"\t"<second.first<<"\t"<second.second<