Gui: export scene graph to file or buffer

This commit is contained in:
wmayer
2020-06-29 11:54:38 +02:00
parent b457adc0ae
commit 80ad2edfe4
3 changed files with 34 additions and 25 deletions

View File

@@ -301,7 +301,7 @@ SoNode* Gui::SoFCDB::replaceSwitches(SoNode* node)
return replaceSwitchesInSceneGraph(node);
}
bool Gui::SoFCDB::writeToVRML(SoNode* node, const char* filename, bool binary)
void Gui::SoFCDB::writeToVRML(SoNode* node, std::string& buffer)
{
SoNode* noSwitches = replaceSwitchesInSceneGraph(node);
noSwitches->ref();
@@ -313,13 +313,19 @@ bool Gui::SoFCDB::writeToVRML(SoNode* node, const char* filename, bool binary)
SoVRMLGroup* vrmlRoot = tovrml2.getVRML2SceneGraph();
vrmlRoot->setInstancePrefix(SbString("o"));
vrmlRoot->ref();
std::string buffer = SoFCDB::writeNodesToString(vrmlRoot);
buffer = SoFCDB::writeNodesToString(vrmlRoot);
vrmlRoot->unref(); // release the memory as soon as possible
// restore old settings
vrml2.setOverrideMode(false);
vrml2.apply(noSwitches);
noSwitches->unref();
}
bool Gui::SoFCDB::writeToVRML(SoNode* node, const char* filename, bool binary)
{
std::string buffer;
writeToVRML(node, buffer);
Base::FileInfo fi(filename);
if (binary) {