Added support for tracking the directory of the output file whilst still maintaining
local file references within this directory.
This commit is contained in:
parent
601ac461a2
commit
d2487e73e5
@ -264,8 +264,7 @@ int main( int argc, char **argv )
|
|||||||
std::string archiveName;
|
std::string archiveName;
|
||||||
while (arguments.read("-a",archiveName)) { dataset->setArchiveName(archiveName); }
|
while (arguments.read("-a",archiveName)) { dataset->setArchiveName(archiveName); }
|
||||||
|
|
||||||
dataset->setDestinationTileBaseName("output");
|
dataset->setDestinationName("output.ive");
|
||||||
dataset->setDestinationTileExtension(".ive");
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int numLevels = 10;
|
unsigned int numLevels = 10;
|
||||||
@ -573,14 +572,7 @@ int main( int argc, char **argv )
|
|||||||
else if (arguments.read(pos, "-o",filename))
|
else if (arguments.read(pos, "-o",filename))
|
||||||
{
|
{
|
||||||
std::cout<<"-o "<<filename<<std::endl;
|
std::cout<<"-o "<<filename<<std::endl;
|
||||||
|
dataset->setDestinationName(filename);
|
||||||
std::string path = osgDB::getFilePath(filename);
|
|
||||||
std::string base = path.empty()?osgDB::getStrippedName(filename):
|
|
||||||
path +'/'+ osgDB::getStrippedName(filename);
|
|
||||||
std::string extension = '.'+osgDB::getLowerCaseFileExtension(filename);
|
|
||||||
|
|
||||||
dataset->setDestinationTileBaseName(base);
|
|
||||||
dataset->setDestinationTileExtension(extension);
|
|
||||||
|
|
||||||
if (!currentCS.empty()) dataset->setDestinationCoordinateSystem(currentCS);
|
if (!currentCS.empty()) dataset->setDestinationCoordinateSystem(currentCS);
|
||||||
|
|
||||||
|
@ -974,9 +974,12 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
|
|||||||
/** Get the Archive if one is to being used.*/
|
/** Get the Archive if one is to being used.*/
|
||||||
osgDB::Archive* getArchive() { return _archive.get(); }
|
osgDB::Archive* getArchive() { return _archive.get(); }
|
||||||
|
|
||||||
/** Set the DestinationTileBaseName and DestinationTileExtension from the passed in filename.*/
|
/** Set the Directory, DestinationTileBaseName and DestinationTileExtension from the passed in filename.*/
|
||||||
void setDestinationName(const std::string& filename);
|
void setDestinationName(const std::string& filename);
|
||||||
|
|
||||||
|
void setDirectory(const std::string& directory);
|
||||||
|
const std::string& getDirectory() const { return _directory; }
|
||||||
|
|
||||||
void setDestinationTileBaseName(const std::string& basename) { _tileBasename = basename; }
|
void setDestinationTileBaseName(const std::string& basename) { _tileBasename = basename; }
|
||||||
const std::string& getDestinationTileBaseName() const { return _tileBasename; }
|
const std::string& getDestinationTileBaseName() const { return _tileBasename; }
|
||||||
|
|
||||||
@ -1126,6 +1129,7 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
|
|||||||
osg::BoundingBox _extents;
|
osg::BoundingBox _extents;
|
||||||
std::string _archiveName;
|
std::string _archiveName;
|
||||||
osg::ref_ptr<osgDB::Archive> _archive;
|
osg::ref_ptr<osgDB::Archive> _archive;
|
||||||
|
std::string _directory;
|
||||||
std::string _tileBasename;
|
std::string _tileBasename;
|
||||||
std::string _tileExtension;
|
std::string _tileExtension;
|
||||||
std::string _imageExtension;
|
std::string _imageExtension;
|
||||||
|
@ -3742,14 +3742,41 @@ void DataSet::init()
|
|||||||
void DataSet::setDestinationName(const std::string& filename)
|
void DataSet::setDestinationName(const std::string& filename)
|
||||||
{
|
{
|
||||||
std::string path = osgDB::getFilePath(filename);
|
std::string path = osgDB::getFilePath(filename);
|
||||||
std::string base = path.empty()?osgDB::getStrippedName(filename):
|
std::string base = osgDB::getStrippedName(filename);
|
||||||
path +'/'+ osgDB::getStrippedName(filename);
|
|
||||||
std::string extension = '.'+osgDB::getLowerCaseFileExtension(filename);
|
std::string extension = '.'+osgDB::getLowerCaseFileExtension(filename);
|
||||||
|
|
||||||
|
osg::notify(osg::NOTICE)<<"setDestinationName("<<filename<<")"<<std::endl;
|
||||||
|
osg::notify(osg::NOTICE)<<" path "<<path<<std::endl;
|
||||||
|
osg::notify(osg::NOTICE)<<" base "<<base<<std::endl;
|
||||||
|
osg::notify(osg::NOTICE)<<" extension "<<extension<<std::endl;
|
||||||
|
|
||||||
|
setDirectory(path);
|
||||||
setDestinationTileBaseName(base);
|
setDestinationTileBaseName(base);
|
||||||
setDestinationTileExtension(extension);
|
setDestinationTileExtension(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataSet::setDirectory(const std::string& directory)
|
||||||
|
{
|
||||||
|
_directory = directory;
|
||||||
|
|
||||||
|
if (_directory.empty()) return;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
// convert trailing forward slash if any to back slash.
|
||||||
|
if (_directory[_directory.size()-1]=='/') _directory[_directory.size()-1] = '\\';
|
||||||
|
|
||||||
|
// if no trailing back slash exists add one.
|
||||||
|
if (_directory[_directory.size()-1]!='\\') _directory.push_back('\\');
|
||||||
|
#else
|
||||||
|
// convert trailing back slash if any to forward slash.
|
||||||
|
if (_directory[_directory.size()-1]=='\\') _directory[_directory.size()-1] = '/';
|
||||||
|
|
||||||
|
// if no trailing forward slash exists add one.
|
||||||
|
if (_directory[_directory.size()-1]!='/') _directory.push_back('/');
|
||||||
|
#endif
|
||||||
|
osg::notify(osg::NOTICE)<<"directory name set "<<_directory<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
void DataSet::addSource(Source* source)
|
void DataSet::addSource(Source* source)
|
||||||
{
|
{
|
||||||
if (!source) return;
|
if (!source) return;
|
||||||
@ -4414,7 +4441,7 @@ public:
|
|||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
_dataSet->_writeImageFile(*image,image->getFileName().c_str());
|
_dataSet->_writeImageFile(*image,(_dataSet->getDirectory()+image->getFileName()).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4435,7 +4462,7 @@ void DataSet::_writeRow(Row& row)
|
|||||||
if (!parent->getSubTilesGenerated() && parent->areSubTilesComplete())
|
if (!parent->getSubTilesGenerated() && parent->areSubTilesComplete())
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Node> node = parent->createSubTileScene();
|
osg::ref_ptr<osg::Node> node = parent->createSubTileScene();
|
||||||
std::string filename = parent->getSubTileName();
|
std::string filename = _directory+parent->getSubTileName();
|
||||||
if (node.valid())
|
if (node.valid())
|
||||||
{
|
{
|
||||||
my_notify(osg::NOTICE)<<" writeSubTile filename="<<filename<<std::endl;
|
my_notify(osg::NOTICE)<<" writeSubTile filename="<<filename<<std::endl;
|
||||||
@ -4475,8 +4502,7 @@ void DataSet::_writeRow(Row& row)
|
|||||||
node->addDescription(_comment);
|
node->addDescription(_comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
//std::string filename = cd->_name + _tileExtension;
|
std::string filename = _directory+_tileBasename+_tileExtension;
|
||||||
std::string filename = _tileBasename+_tileExtension;
|
|
||||||
|
|
||||||
if (node.valid())
|
if (node.valid())
|
||||||
{
|
{
|
||||||
@ -4566,7 +4592,7 @@ void DataSet::_buildDestination(bool writeToDisk)
|
|||||||
|
|
||||||
if (_destinationGraph.valid())
|
if (_destinationGraph.valid())
|
||||||
{
|
{
|
||||||
std::string filename = _tileBasename+_tileExtension;
|
std::string filename = _directory+_tileBasename+_tileExtension;
|
||||||
|
|
||||||
if (_archive.valid())
|
if (_archive.valid())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user