5 #include <Inventor/actions/SoWriteAction.h>
6 #include <Inventor/actions/SoToVRML2Action.h>
7 #include <Inventor/nodes/SoFile.h>
8 #include <Inventor/nodes/SoSeparator.h>
9 #include <Inventor/VRMLnodes/SoVRMLGroup.h>
14 static SoGroup* convertSoFileChildren(SoGroup* orig)
23 if (orig->getTypeId() == SoSeparator::getClassTypeId())
25 storeResult =
new SoSeparator;
29 storeResult =
new SoGroup;
34 if (orig->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
37 for (
int i = 0; i < orig->getNumChildren(); i++)
39 SoNode* n1 = orig->getChild(i);
41 if (n1->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
44 SoGroup* n2 = (SoGroup*)n1;
45 SoGroup* gr1 = convertSoFileChildren(n2);
46 storeResult->addChild(gr1);
48 else if (n1->getTypeId() == SoFile::getClassTypeId())
51 SoFile* fn = (SoFile*)n1;
52 SoGroup* fileChildren;
53 fileChildren = fn->copyChildren();
54 storeResult->addChild(fileChildren);
59 storeResult->addChild(n1);
64 storeResult->unrefNoDelete();
70 SoOutput*
so =
new SoOutput();
71 if (!
so->openFile(exportFilePath.c_str()))
73 ARMARX_ERROR <<
"Could not open file " << exportFilePath <<
" for writing.";
77 so->setHeaderString(
"#VRML V2.0 utf8");
79 SoGroup* n =
new SoGroup;
82 SoGroup* newVisu = convertSoFileChildren(n);
85 SoToVRML2Action tovrml2;
86 tovrml2.apply(newVisu);
87 SoVRMLGroup* newroot = tovrml2.getVRML2SceneGraph();
89 SoWriteAction wra(
so);