5 #include <Inventor/VRMLnodes/SoVRMLGroup.h>
6 #include <Inventor/actions/SoToVRML2Action.h>
7 #include <Inventor/actions/SoWriteAction.h>
8 #include <Inventor/nodes/SoFile.h>
9 #include <Inventor/nodes/SoSeparator.h>
15 convertSoFileChildren(SoGroup* orig)
24 if (orig->getTypeId() == SoSeparator::getClassTypeId())
26 storeResult =
new SoSeparator;
30 storeResult =
new SoGroup;
35 if (orig->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
38 for (
int i = 0; i < orig->getNumChildren(); i++)
40 SoNode* n1 = orig->getChild(i);
42 if (n1->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
45 SoGroup* n2 = (SoGroup*)n1;
46 SoGroup* gr1 = convertSoFileChildren(n2);
47 storeResult->addChild(gr1);
49 else if (n1->getTypeId() == SoFile::getClassTypeId())
52 SoFile* fn = (SoFile*)n1;
53 SoGroup* fileChildren;
54 fileChildren = fn->copyChildren();
55 storeResult->addChild(fileChildren);
60 storeResult->addChild(n1);
65 storeResult->unrefNoDelete();
72 SoOutput*
so =
new SoOutput();
73 if (!
so->openFile(exportFilePath.c_str()))
75 ARMARX_ERROR <<
"Could not open file " << exportFilePath <<
" for writing.";
79 so->setHeaderString(
"#VRML V2.0 utf8");
81 SoGroup*
n =
new SoGroup;
84 SoGroup* newVisu = convertSoFileChildren(
n);
87 SoToVRML2Action tovrml2;
88 tovrml2.apply(newVisu);
89 SoVRMLGroup* newroot = tovrml2.getVRML2SceneGraph();
91 SoWriteAction wra(
so);