Added support of archiving into osgTerrain::DataSet and osgdem.

This commit is contained in:
Robert Osfield
2004-11-09 14:18:29 +00:00
parent ec319e663f
commit 564869487a
6 changed files with 199 additions and 56 deletions

View File

@@ -62,6 +62,34 @@ class OSGDB_EXPORT Archive : public ReaderWriter
virtual WriteResult writeHeightField(const osg::HeightField& heightField,const std::string& fileName,const Options* options=NULL);
virtual WriteResult writeNode(const osg::Node& node,const std::string& fileName,const Options* options=NULL);
/** Functor used in internal implementations.*/
struct ReadFunctor
{
ReadFunctor(const std::string& filename, const ReaderWriter::Options* options):
_filename(filename),
_options(options) {}
virtual ~ReadFunctor() {}
virtual ReaderWriter::ReadResult doRead(ReaderWriter& rw, std::istream& input) const = 0;
std::string _filename;
const ReaderWriter::Options* _options;
};
/** Functor used in internal implementations.*/
struct WriteFunctor
{
WriteFunctor(const std::string& filename, const ReaderWriter::Options* options):
_filename(filename),
_options(options) {}
virtual ~WriteFunctor() {}
virtual ReaderWriter::WriteResult doWrite(ReaderWriter& rw, std::ostream& output) const = 0;
std::string _filename;
const ReaderWriter::Options* _options;
};
protected:
@@ -114,7 +142,8 @@ class OSGDB_EXPORT Archive : public ReaderWriter
char* _data;
};
ReaderWriter::ReadResult read(const ReadFunctor& readFunctor);
ReaderWriter::WriteResult write(const WriteFunctor& writeFunctor);
typedef std::list< osg::ref_ptr<IndexBlock> > IndexBlockList;

View File

@@ -32,6 +32,8 @@
#include <osg/Shape>
#include <osg/CoordinateSystemNode>
#include <osgDB/Archive>
#include <set>
#include <osgTerrain/Export>
@@ -927,6 +929,18 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
void setDestinationGeoTransform(const osg::Matrixd& geoTransform) { _geoTransform = geoTransform; }
/** Set the Archive name if one is to be used.*/
void setArchiveName(const std::string& filename) { _archiveName = filename; }
/** Get the Archive name.*/
const std::string& getArchiveName() const { return _archiveName; }
/** Set the Archive.*/
void setArchive(osgDB::Archive* archive) { _archive = archive; }
/** Get the Archive if one is to being used.*/
osgDB::Archive* getArchive() { return _archive.get(); }
/** Set the DestinationTileBaseName and DestinationTileExtension from the passed in filename.*/
void setDestinationName(const std::string& filename);
@@ -1020,12 +1034,16 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
osg::Node* getDestinationRootNode() { return _rootNode.get(); }
// helper functions for handling optional archive
void _writeNodeFile(const osg::Node& node,const std::string& filename);
void _writeImageFile(const osg::Image& image,const std::string& filename);
protected:
virtual ~DataSet() {}
void _readRow(Row& row);
void _equalizeRow(Row& row);
void _writeRow(Row& row);
@@ -1059,6 +1077,8 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
osg::Matrixd _geoTransform;
osg::BoundingBox _extents;
std::string _archiveName;
osg::ref_ptr<osgDB::Archive> _archive;
std::string _tileBasename;
std::string _tileExtension;
osg::Vec4 _defaultColor;