0030409: Data Exchange - exception during VRML file export
authorkgv <kgv@opencascade.com>
Thu, 13 Dec 2018 07:45:14 +0000 (10:45 +0300)
committerapn <apn@opencascade.com>
Fri, 14 Dec 2018 09:07:56 +0000 (12:07 +0300)
VrmlData_ShapeConvert::addShape() - handle case when parent node is NULL.

src/VrmlData/VrmlData_ShapeConvert.cxx
tests/bugs/xde/bug30409 [new file with mode: 0644]

index eb717f0..2b7373c 100644 (file)
@@ -683,7 +683,7 @@ void VrmlData_ShapeConvert::addShape (const Handle(VrmlData_Group)& theParent,
         aShapeNode->SetAppearance(makeMaterialFromColor(aColorL, aColorTool));
       }
 
-      myScene.AddNode(aShapeNode, Standard_False);
+      myScene.AddNode(aShapeNode, theParent.IsNull() && aGroup.IsNull());
       aShapeNode->SetGeometry(aTShapeNode);
       if (aLoc.IsIdentity())
       {
@@ -692,7 +692,7 @@ void VrmlData_ShapeConvert::addShape (const Handle(VrmlData_Group)& theParent,
         {
           aGroup->AddNode(aShapeNode);
         }
-        else
+        else if (!theParent.IsNull())
         {
           theParent->AddNode(aShapeNode);
         }
@@ -709,12 +709,12 @@ void VrmlData_ShapeConvert::addShape (const Handle(VrmlData_Group)& theParent,
             aTrsf.SetTranslationPart(aTransl);
         }
         aTrans->SetTransform(aTrsf);
-        myScene.AddNode(aTrans, Standard_False);
+        myScene.AddNode(aTrans, theParent.IsNull() && aGroup.IsNull());
         if (!aGroup.IsNull())
         {
           aGroup->AddNode(aTrans);
         }
-        else
+        else if (!theParent.IsNull())
         {
           theParent->AddNode(aTrans);
         }
diff --git a/tests/bugs/xde/bug30409 b/tests/bugs/xde/bug30409
new file mode 100644 (file)
index 0000000..b37120f
--- /dev/null
@@ -0,0 +1,14 @@
+puts "================"
+puts "0030409: Data Exchange - e x c e p t i o n during VRML file export"
+puts "================"
+puts ""
+
+pload XDE MODELING VISUALIZATION
+box b 1 2 3
+incmesh b 1
+explode b F
+XNewDoc D
+XAddShape D b_1 0
+WriteVrml D $imagedir/${casename}.wrl
+loadvrml  w $imagedir/${casename}.wrl
+checktrinfo w -tri 2 -nod 4