MCPcopy Create free account
hub / github.com/RenderKit/embree / XMLLoader

Method XMLLoader

tutorials/common/scenegraph/xml_loader.cpp:1969–2009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1967 }
1968
1969 XMLLoader::XMLLoader(const FileName& fileName, const AffineSpace3fa& space, SharedState& state)
1970 : binFile(nullptr), binFileSize(0), state(state), currentNodeID(0)
1971 {
1972 path = fileName.path();
1973 binFileName = fileName.setExt(".bin");
1974 binFile = fopen(binFileName.c_str(),"rb");
1975 if (!binFile) {
1976 binFileName = fileName.addExt(".bin");
1977 binFile = fopen(binFileName.c_str(),"rb");
1978 }
1979 if (binFile) {
1980 fseek(binFile, 0L, SEEK_END);
1981 binFileSize = ftell(binFile);
1982 fseek(binFile, 0L, SEEK_SET);
1983 }
1984
1985
1986 Ref<XML> xml = parseXML(fileName);
1987 if (xml->name == "scene")
1988 {
1989 Ref<SceneGraph::GroupNode> group = new SceneGraph::GroupNode;
1990 for (size_t i=0; i<xml->size(); i++) {
1991 group->add(loadNode(xml->children[i]));
1992 }
1993 root = group.cast<SceneGraph::Node>();
1994 }
1995 else if (xml->name == "BGFscene")
1996 {
1997 Ref<SceneGraph::Node> last = nullptr;
1998 for (size_t i=0; i<xml->size(); i++) {
1999 root = loadBGFNode(xml->children[i]);
2000 }
2001 }
2002 else
2003 THROW_RUNTIME_ERROR(xml->loc.str()+": invalid scene tag");
2004
2005 if (space == AffineSpace3fa(one))
2006 return;
2007
2008 root = new SceneGraph::TransformNode(space,root);
2009 }
2010
2011 XMLLoader::~XMLLoader() {
2012 if (binFile) fclose(binFile);

Callers

nothing calls this directly

Calls 8

parseXMLFunction · 0.85
pathMethod · 0.80
setExtMethod · 0.80
addExtMethod · 0.80
c_strMethod · 0.45
sizeMethod · 0.45
addMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected