Output
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library 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. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGDB_OUTPUT
#define OSGDB_OUTPUT 1
#include <osg/Object>
#include <osgDB/ReaderWriter>
#include <osgDB/fstream>
#include <string>
#include <map>
namespace osgDB {
class OSGDB_EXPORT Output : public osgDB::ofstream
{
public:
Output();
Output(const char* name);
virtual ~Output();
void setOptions(const Options* options);
const Options* getOptions() const { return _options.get(); }
void setWriteOutDefaultValues(bool flag) { _writeOutDefaultValues = flag; }
bool getWriteOutDefaultValues() const { return _writeOutDefaultValues; }
void open(const char *name);
// comment out temporarily to avoid compilation problems, RO Jan 2002.
// void open(const char *name,int mode);
Output& indent();
std::string wrapString(const char* str);
std::string wrapString(const std::string& str);
inline void setIndentStep(int step) { _indentStep = step; }
inline int getIndentStep() const { return _indentStep; }
inline void setIndent(int indent) { _indent = indent; }
inline int getIndent() const { return _indent; }
inline void setNumIndicesPerLine(int num) { _numIndicesPerLine = num; }
inline int getNumIndicesPerLine() const { return _numIndicesPerLine; }
void moveIn();
void moveOut();
virtual bool writeObject(const osg::Object& obj);
virtual void writeBeginObject(const std::string& name);
virtual void writeEndObject();
virtual void writeUseID(const std::string& id);
virtual void writeUniqueID(const std::string& id);
bool getUniqueIDForObject(const osg::Object* obj,std::string& uniqueID);
bool createUniqueIDForObject(const osg::Object* obj,std::string& uniqueID);
bool registerUniqueIDForObject(const osg::Object* obj,std::string& uniqueID);
enum PathNameHint
{
AS_IS,
FULL_PATH,
RELATIVE_PATH,
FILENAME_ONLY
};
inline void setPathNameHint(const PathNameHint pnh) { _pathNameHint = pnh; }
inline PathNameHint getPathNameHint() const { return _pathNameHint; }
virtual std::string getFileNameForOutput(const std::string& filename) const;
const std::string& getFileName() const { return _filename; }
// Set and get if export texture files during write
void setOutputTextureFiles(bool flag) { _outputTextureFiles = flag; }
bool getOutputTextureFiles() const { return _outputTextureFiles; }
// support code for OutputTextureFiles
virtual std::string getTextureFileNameForOutput();
void setOutputShaderFiles(bool flag) { _outputShaderFiles = flag; }
bool getOutputShaderFiles() const { return _outputShaderFiles; }
virtual std::string getShaderFileNameForOutput();
void setExternalFileWritten(const std::string& filename, bool hasBeenWritten=true);
bool getExternalFileWritten(const std::string& filename) const;
protected:
virtual void init();
osg::ref_ptr<const Options> _options;
int _indent;
int _indentStep;
int _numIndicesPerLine;
typedef std::map<const osg::Object*,std::string> UniqueIDToLabelMapping;
UniqueIDToLabelMapping _objectToUniqueIDMap;
std::string _filename;
PathNameHint _pathNameHint;
bool _outputTextureFiles;
unsigned int _textureFileNameNumber;
bool _outputShaderFiles;
unsigned int _shaderFileNameNumber;
bool _writeOutDefaultValues;
typedef std::map<std::string, bool> ExternalFileWrittenMap;
ExternalFileWrittenMap _externalFileWritten;
};
}
#endif // __SG_OUTPUT_H
Object
ReaderWriter
osgDB::Options
Definition Options:30
osgDB::Output::getShaderFileNameForOutput
virtual std::string getShaderFileNameForOutput()
osgDB::Output::createUniqueIDForObject
bool createUniqueIDForObject(const osg::Object *obj, std::string &uniqueID)
osgDB::Output::_indent
int _indent
Definition Output:115
osgDB::Output::registerUniqueIDForObject
bool registerUniqueIDForObject(const osg::Object *obj, std::string &uniqueID)
osgDB::Output::_shaderFileNameNumber
unsigned int _shaderFileNameNumber
Definition Output:131
osgDB::Output::_filename
std::string _filename
Definition Output:123
osgDB::Output::_indentStep
int _indentStep
Definition Output:116
osgDB::Output::writeBeginObject
virtual void writeBeginObject(const std::string &name)
osgDB::Output::moveOut
void moveOut()
osgDB::Output::_textureFileNameNumber
unsigned int _textureFileNameNumber
Definition Output:128
osgDB::Output::UniqueIDToLabelMapping
std::map< const osg::Object *, std::string > UniqueIDToLabelMapping
Definition Output:120
osgDB::Output::getIndentStep
int getIndentStep() const
Definition Output:58
osgDB::Output::getFileNameForOutput
virtual std::string getFileNameForOutput(const std::string &filename) const
osgDB::Output::writeEndObject
virtual void writeEndObject()
osgDB::Output::getIndent
int getIndent() const
Definition Output:61
osgDB::Output::Output
Output(const char *name)
osgDB::Output::getUniqueIDForObject
bool getUniqueIDForObject(const osg::Object *obj, std::string &uniqueID)
osgDB::Output::setNumIndicesPerLine
void setNumIndicesPerLine(int num)
Definition Output:63
osgDB::Output::setOutputTextureFiles
void setOutputTextureFiles(bool flag)
Definition Output:94
osgDB::Output::setWriteOutDefaultValues
void setWriteOutDefaultValues(bool flag)
Definition Output:41
osgDB::Output::wrapString
std::string wrapString(const char *str)
osgDB::Output::setExternalFileWritten
void setExternalFileWritten(const std::string &filename, bool hasBeenWritten=true)
osgDB::Output::wrapString
std::string wrapString(const std::string &str)
osgDB::Output::_numIndicesPerLine
int _numIndicesPerLine
Definition Output:118
osgDB::Output::indent
Output & indent()
osgDB::Output::_writeOutDefaultValues
bool _writeOutDefaultValues
Definition Output:133
osgDB::Output::_outputTextureFiles
bool _outputTextureFiles
Definition Output:127
osgDB::Output::writeUseID
virtual void writeUseID(const std::string &id)
osgDB::Output::setPathNameHint
void setPathNameHint(const PathNameHint pnh)
Definition Output:87
osgDB::Output::getOutputShaderFiles
bool getOutputShaderFiles() const
Definition Output:101
osgDB::Output::_pathNameHint
PathNameHint _pathNameHint
Definition Output:125
osgDB::Output::init
virtual void init()
osgDB::Output::_externalFileWritten
ExternalFileWrittenMap _externalFileWritten
Definition Output:136
osgDB::Output::_outputShaderFiles
bool _outputShaderFiles
Definition Output:130
osgDB::Output::getOutputTextureFiles
bool getOutputTextureFiles() const
Definition Output:95
osgDB::Output::getWriteOutDefaultValues
bool getWriteOutDefaultValues() const
Definition Output:42
osgDB::Output::Output
Output()
osgDB::Output::setOutputShaderFiles
void setOutputShaderFiles(bool flag)
Definition Output:100
osgDB::Output::writeUniqueID
virtual void writeUniqueID(const std::string &id)
osgDB::Output::getTextureFileNameForOutput
virtual std::string getTextureFileNameForOutput()
osgDB::Output::getOptions
const Options * getOptions() const
Definition Output:39
osgDB::Output::getExternalFileWritten
bool getExternalFileWritten(const std::string &filename) const
osgDB::Output::_options
osg::ref_ptr< const Options > _options
Definition Output:113
osgDB::Output::~Output
virtual ~Output()
osgDB::Output::writeObject
virtual bool writeObject(const osg::Object &obj)
osgDB::Output::_objectToUniqueIDMap
UniqueIDToLabelMapping _objectToUniqueIDMap
Definition Output:121
osgDB::Output::PathNameHint
PathNameHint
Definition Output:80
osgDB::Output::RELATIVE_PATH
@ RELATIVE_PATH
Definition Output:83
osgDB::Output::FILENAME_ONLY
@ FILENAME_ONLY
Definition Output:84
osgDB::Output::AS_IS
@ AS_IS
Definition Output:81
osgDB::Output::FULL_PATH
@ FULL_PATH
Definition Output:82
osgDB::Output::ExternalFileWrittenMap
std::map< std::string, bool > ExternalFileWrittenMap
Definition Output:135
osgDB::Output::getPathNameHint
PathNameHint getPathNameHint() const
Definition Output:88
osgDB::Output::getFileName
const std::string & getFileName() const
Definition Output:91
osgDB::Output::getNumIndicesPerLine
int getNumIndicesPerLine() const
Definition Output:64
osgDB::Output::setIndentStep
void setIndentStep(int step)
Definition Output:57
osgDB::Output::moveIn
void moveIn()
osgDB::Output::open
void open(const char *name)
osgDB::Output::setOptions
void setOptions(const Options *options)
osgDB::Output::setIndent
void setIndent(int indent)
Definition Output:60
osgDB::ofstream
Definition fstream:47
osg::Object
Definition Object:61
osg::ref_ptr
Definition ref_ptr:32
fstream
osgDB
Definition Archive:24
OSGDB_EXPORT
#define OSGDB_EXPORT
Definition osgDB/Export:39