From e28ae8c7f34c3d38a7d161f6e56f420824801abe Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 13 May 2008 17:27:29 +0000 Subject: [PATCH] Added support for -e level minX minY maxX maxY extents controls --- applications/osgfilecache/osgfilecache.cpp | 198 ++++++++++++++++----- 1 file changed, 155 insertions(+), 43 deletions(-) diff --git a/applications/osgfilecache/osgfilecache.cpp b/applications/osgfilecache/osgfilecache.cpp index 5f174571e..d4bc0db17 100644 --- a/applications/osgfilecache/osgfilecache.cpp +++ b/applications/osgfilecache/osgfilecache.cpp @@ -30,20 +30,123 @@ static bool s_ExitApplication = false; +struct Extents +{ + + Extents(): + _maxLevel(0), + _min(DBL_MAX,DBL_MAX), + _max(-DBL_MAX,-DBL_MAX) {} + + Extents(unsigned int maxLevel, double minX, double minY, double maxX, double maxY): + _maxLevel(maxLevel), + _min(minX, minY), + _max(maxX, maxY) {} + + Extents(const Extents& extents): + _maxLevel(extents._maxLevel), + _min(extents._min), + _max(extents._max) {} + + Extents& operator = (const Extents& rhs) + { + if (&rhs == this) return *this; + + _maxLevel = rhs._maxLevel; + _min = rhs._min; + _max = rhs._max; + + return *this; + } + + bool intersects(unsigned level, osg::Vec2d& in_min, osg::Vec2d& in_max) + { + osg::notify(osg::INFO)<<"intersects("<getLocator() : 0; if (locator) { - std::cout<<" Found terrain locator "<getEllipsoidModel(), w01); } - osg::notify(osg::NOTICE)<<" w00 = "<_maxLevels) return; - if (s_ExitApplication) return; ++_currentLevel; - initBound(); @@ -132,36 +221,36 @@ public: { if (plod.getFileName(i).empty()) { - std::cout<<" search local subgraph"< node = osgDB::readNodeFile(filename); + + if (!s_ExitApplication && node.valid()) node->accept(*this); } - else - { - filename = plod.getFileName(i); - } - - std::cout<<" reading "< node = osgDB::readNodeFile(filename); - - if (!s_ExitApplication && node.valid()) node->accept(*this); } } - + --_currentLevel; } @@ -227,16 +316,25 @@ protected: } } - bool isCulled() + bool intersects() { - std::cout<<"isCulled() _min = "<<_min<<" _max = "<<_max<setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); + arguments.getApplicationUsage()->addCommandLineOption("-l level","Read down to level across the whole database."); + arguments.getApplicationUsage()->addCommandLineOption("-e level minX minY maxX maxY","Read down to across the extents minX, minY to maxY, maxY. Note, for geocentric datase X and Y are longitude and latitude respectively."); + arguments.getApplicationUsage()->addCommandLineOption("-c directory","Shorthand for --file-cache directory."); + arguments.getApplicationUsage()->addCommandLineOption("--file-cache directory","Set directory as to place cache download files."); // if user request help write it out to cout. if (arguments.read("-h") || arguments.read("--help")) @@ -280,9 +382,20 @@ int main( int argc, char **argv ) return 1; } + LoadDataVisitor ldv; + unsigned int maxLevels = 0; - while(arguments.read("-l",maxLevels)) {} + while(arguments.read("-l",maxLevels)) + { + ldv.addExtents(maxLevels); + } + double minX, maxX, minY, maxY; + while(arguments.read("-e",maxLevels, minX, minY, maxX, maxY)) + { + ldv.addExtents(maxLevels, minX, minY, maxX, maxY); + } + std::string fileCache; while(arguments.read("--file-cache",fileCache) || arguments.read("-c",fileCache)) {} @@ -301,7 +414,6 @@ int main( int argc, char **argv ) return 1; } - LoadDataVisitor ldv(maxLevels); loadedModel->accept(ldv);