20 #if !defined(__MITSUBA_RENDER_SCENEHANDLER_H_)
21 #define __MITSUBA_RENDER_SCENEHANDLER_H_
23 #include <xercesc/sax/HandlerBase.hpp>
24 #include <xercesc/sax/AttributeList.hpp>
28 #include <boost/unordered_map.hpp>
32 XERCES_CPP_NAMESPACE_BEGIN
35 XERCES_CPP_NAMESPACE_END
38 namespace xercesc = XERCES_CPP_NAMESPACE;
43 # pragma warning( push )
44 # pragma warning( disable : 4275 )
54 std::runtime_error(str), m_version(version) { }
62 inline const
Version &getVersion()
const {
return m_version; }
68 # pragma warning( pop )
86 typedef std::map<std::string, std::string, SimpleStringOrdering>
ParameterMap;
89 bool isIncludedFile =
false);
93 static ref<Scene> loadScene(
const fs::path &filename,
97 static ref<Scene> loadSceneFromString(
const std::string &
string,
101 static void staticInitialization();
104 static void staticShutdown();
109 virtual void startDocument();
110 virtual void endDocument();
111 virtual void startElement(
112 const XMLCh*
const name,
113 xercesc::AttributeList& attributes
115 virtual void endElement(
const XMLCh*
const name);
116 virtual void characters(
const XMLCh*
const chars,
const XMLSize_t length);
117 virtual void setDocumentLocator(
const xercesc::Locator*
const locator);
125 void warning(
const xercesc::SAXParseException& exc);
126 void error(
const xercesc::SAXParseException& exc);
127 void fatalError(
const xercesc::SAXParseException& exc);
129 std::string transcode(
const XMLCh * input)
const;
131 Float parseFloat(
const std::string &name,
const std::string &str,
132 Float defVal = -1)
const;
142 EScene, EShape, ESampler, EFilm,
143 EIntegrator, ETexture, ESensor,
144 EEmitter, ESubsurface, EMedium,
145 EVolume, EPhase, EBSDF, ERFilter,
146 ENull, EReference, EInteger, EFloat,
147 EBoolean, EString, ETranslate, ERotate,
148 ELookAt, EScale, EMatrix, EPoint,
149 EVector, ERGB, ESRGB, EBlackBody,
150 ESpectrum, ETransform, EAnimation,
151 EInclude, EAlias, EDefault
154 struct ParseContext {
155 inline ParseContext(ParseContext *_parent, ETag tag)
156 : parent(_parent), tag(tag) { }
158 ParseContext *parent;
160 Properties properties;
161 std::map<std::string, std::string> attributes;
162 std::vector<std::pair<std::string, ConfigurableObject *> > children;
166 typedef std::pair<ETag, const Class *> TagEntry;
167 typedef boost::unordered_map<std::string, TagEntry> TagMap;
169 const xercesc::Locator *m_locator;
170 xercesc::XMLTranscoder* m_transcoder;
172 ParameterMap m_params;
173 NamedObjectMap *m_namedObjects;
174 PluginManager *m_pluginManager;
175 std::stack<ParseContext> m_context;
177 Transform m_transform;
179 bool m_isIncludedFile;
std::map< std::string, ConfigurableObject * > NamedObjectMap
Definition: scenehandler.h:85
std::map< std::string, std::string, SimpleStringOrdering > ParameterMap
Definition: scenehandler.h:86
Principal scene data structure.
Definition: scene.h:49
const Scene * getScene() const
Definition: scenehandler.h:119
VersionException(const std::string &str, const Version &version)
Definition: scenehandler.h:53
Reference counting helper.
Definition: ref.h:40
Scene * getScene()
Definition: scenehandler.h:120
void pushSceneCleanupHandler(void(*cleanup)())
Push a cleanup handler to be executed after loading the scene is done.
XML parser for Mitsuba scene files. To be used with the SAX interface of Xerces-C++.
Definition: scenehandler.h:83
This exception is thrown when attempting to load an outdated file.
Definition: scenehandler.h:51
A simple data structure for representing and comparing Mitsuba version strings.
Definition: version.h:43