OpenSceneGraph 3.6.5
Output
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGDB_OUTPUT
15#define OSGDB_OUTPUT 1
16
17#include <osg/Object>
18
19#include <osgDB/ReaderWriter>
20#include <osgDB/fstream>
21
22#include <string>
23#include <map>
24
25namespace osgDB {
26
29{
30 public:
31
33 Output(const char* name);
34
35 virtual ~Output();
36
37
38 void setOptions(const Options* options);
39 const Options* getOptions() const { return _options.get(); }
40
43
44 void open(const char *name);
45
46 // comment out temporarily to avoid compilation problems, RO Jan 2002.
47 // void open(const char *name,int mode);
48
50
52 std::string wrapString(const char* str);
53
55 std::string wrapString(const std::string& str);
56
57 inline void setIndentStep(int step) { _indentStep = step; }
58 inline int getIndentStep() const { return _indentStep; }
59
60 inline void setIndent(int indent) { _indent = indent; }
61 inline int getIndent() const { return _indent; }
62
63 inline void setNumIndicesPerLine(int num) { _numIndicesPerLine = num; }
64 inline int getNumIndicesPerLine() const { return _numIndicesPerLine; }
65
66 void moveIn();
67 void moveOut();
68
69 virtual bool writeObject(const osg::Object& obj);
70 virtual void writeBeginObject(const std::string& name);
71 virtual void writeEndObject();
72 virtual void writeUseID(const std::string& id);
73 virtual void writeUniqueID(const std::string& id);
74
75 bool getUniqueIDForObject(const osg::Object* obj,std::string& uniqueID);
76 bool createUniqueIDForObject(const osg::Object* obj,std::string& uniqueID);
77 bool registerUniqueIDForObject(const osg::Object* obj,std::string& uniqueID);
78
86
87 inline void setPathNameHint(const PathNameHint pnh) { _pathNameHint = pnh; }
88 inline PathNameHint getPathNameHint() const { return _pathNameHint; }
89
90 virtual std::string getFileNameForOutput(const std::string& filename) const;
91 const std::string& getFileName() const { return _filename; }
92
93 // Set and get if export texture files during write
94 void setOutputTextureFiles(bool flag) { _outputTextureFiles = flag; }
96
97 // support code for OutputTextureFiles
98 virtual std::string getTextureFileNameForOutput();
99
100 void setOutputShaderFiles(bool flag) { _outputShaderFiles = flag; }
102
103 virtual std::string getShaderFileNameForOutput();
104
105 void setExternalFileWritten(const std::string& filename, bool hasBeenWritten=true);
106 bool getExternalFileWritten(const std::string& filename) const;
107
108 protected:
109
110
111 virtual void init();
112
114
117
119
120 typedef std::map<const osg::Object*,std::string> UniqueIDToLabelMapping;
122
123 std::string _filename;
124
126
129
132
134
135 typedef std::map<std::string, bool> ExternalFileWrittenMap;
137};
138
139}
140
141#endif // __SG_OUTPUT_H
The osgDB library provides support for reading and writing scene graphs, providing a plugin framework...
Definition Archive:24
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Definition fstream:47
Options base class used for passing options into plugins to control their operation.
Definition Options:30
virtual std::string getShaderFileNameForOutput()
bool createUniqueIDForObject(const osg::Object *obj, std::string &uniqueID)
int _indent
Definition Output:115
bool registerUniqueIDForObject(const osg::Object *obj, std::string &uniqueID)
unsigned int _shaderFileNameNumber
Definition Output:131
std::string _filename
Definition Output:123
int _indentStep
Definition Output:116
virtual void writeBeginObject(const std::string &name)
unsigned int _textureFileNameNumber
Definition Output:128
std::map< const osg::Object *, std::string > UniqueIDToLabelMapping
Definition Output:120
int getIndentStep() const
Definition Output:58
virtual std::string getFileNameForOutput(const std::string &filename) const
virtual void writeEndObject()
int getIndent() const
Definition Output:61
Output(const char *name)
bool getUniqueIDForObject(const osg::Object *obj, std::string &uniqueID)
void setNumIndicesPerLine(int num)
Definition Output:63
void setOutputTextureFiles(bool flag)
Definition Output:94
void setWriteOutDefaultValues(bool flag)
Definition Output:41
std::string wrapString(const char *str)
wrap a string with "" quotes and use " for any internal quotes.
void setExternalFileWritten(const std::string &filename, bool hasBeenWritten=true)
std::string wrapString(const std::string &str)
wrap a string with "" quotes and use " for any internal quotes.
int _numIndicesPerLine
Definition Output:118
Output & indent()
bool _writeOutDefaultValues
Definition Output:133
bool _outputTextureFiles
Definition Output:127
virtual void writeUseID(const std::string &id)
void setPathNameHint(const PathNameHint pnh)
Definition Output:87
bool getOutputShaderFiles() const
Definition Output:101
PathNameHint _pathNameHint
Definition Output:125
virtual void init()
ExternalFileWrittenMap _externalFileWritten
Definition Output:136
bool _outputShaderFiles
Definition Output:130
bool getOutputTextureFiles() const
Definition Output:95
bool getWriteOutDefaultValues() const
Definition Output:42
void setOutputShaderFiles(bool flag)
Definition Output:100
virtual void writeUniqueID(const std::string &id)
virtual std::string getTextureFileNameForOutput()
const Options * getOptions() const
Definition Output:39
bool getExternalFileWritten(const std::string &filename) const
osg::ref_ptr< const Options > _options
Definition Output:113
virtual ~Output()
virtual bool writeObject(const osg::Object &obj)
UniqueIDToLabelMapping _objectToUniqueIDMap
Definition Output:121
PathNameHint
Definition Output:80
@ RELATIVE_PATH
Definition Output:83
@ FILENAME_ONLY
Definition Output:84
@ AS_IS
Definition Output:81
@ FULL_PATH
Definition Output:82
std::map< std::string, bool > ExternalFileWrittenMap
Definition Output:135
PathNameHint getPathNameHint() const
Definition Output:88
const std::string & getFileName() const
Definition Output:91
int getNumIndicesPerLine() const
Definition Output:64
void setIndentStep(int step)
Definition Output:57
void open(const char *name)
void setOptions(const Options *options)
void setIndent(int indent)
Definition Output:60
#define OSGDB_EXPORT
Definition Export:39

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.