From 8cbf1f8d41f51660c8f87c5367ba26aa734f6cb9 Mon Sep 17 00:00:00 2001 From: ika Date: Thu, 21 Jun 2018 17:21:02 +0300 Subject: [PATCH] 0029888: [Regression] Data Exchange - XCAFDoc_Editor::Expand() removes names XCAFDoc_Editor::Expand function avoids expanding references to assemblies. --- src/XCAFDoc/XCAFDoc_Editor.cxx | 12 ++++++++---- tests/bugs/xde/bug29888_1 | 22 ++++++++++++++++++++++ tests/bugs/xde/bug29888_2 | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 tests/bugs/xde/bug29888_1 create mode 100644 tests/bugs/xde/bug29888_2 diff --git a/src/XCAFDoc/XCAFDoc_Editor.cxx b/src/XCAFDoc/XCAFDoc_Editor.cxx index f11d6d6a80..37f07e0f27 100644 --- a/src/XCAFDoc/XCAFDoc_Editor.cxx +++ b/src/XCAFDoc/XCAFDoc_Editor.cxx @@ -49,11 +49,15 @@ Standard_Boolean XCAFDoc_Editor::Expand (const TDF_Label& Doc, const TDF_Label& Standard_Boolean isAutoNaming = aShapeTool->AutoNaming(); aShapeTool->SetAutoNaming(Standard_False); - TopoDS_Shape aS = aShapeTool->GetShape(Shape); - if (aShapeTool->Expand(Shape)) + TDF_Label aCompoundPartL = Shape; + if (aShapeTool->IsReference(Shape)) + aShapeTool->GetReferredShape(aCompoundPartL, aCompoundPartL); + + TopoDS_Shape aS = aShapeTool->GetShape(aCompoundPartL); + if (aShapeTool->Expand(aCompoundPartL)) { //move attributes - TDF_ChildIterator anIter(Shape, Standard_True); + TDF_ChildIterator anIter(aCompoundPartL, Standard_True); for(; anIter.More(); anIter.Next()) { TDF_Label aChild = anIter.Value(); @@ -104,7 +108,7 @@ Standard_Boolean XCAFDoc_Editor::Expand (const TDF_Label& Doc, const TDF_Label& //if assembly contains compound, expand it recursively(if flag recursively is true) if(recursively) { - anIter.Initialize(Shape); + anIter.Initialize(aCompoundPartL); for(; anIter.More(); anIter.Next()) { TDF_Label aChild = anIter.Value(); diff --git a/tests/bugs/xde/bug29888_1 b/tests/bugs/xde/bug29888_1 new file mode 100644 index 0000000000..2dcaaa0de9 --- /dev/null +++ b/tests/bugs/xde/bug29888_1 @@ -0,0 +1,22 @@ +puts "==========" +puts "OCC29888" +puts "==========" +puts "" +######################################### +# XCAFDoc_Editor::Expand() removes names +######################################### +pload ALL + +XOpen [locate_data_file bug29888.xbf] D + +set isBAD 1 + +if {[catch {XExpand D 0} result]} { + set isBAD 0 +} + +if {$isBAD} { + puts "Error: expand unexpandable shape type" +} + +Close D diff --git a/tests/bugs/xde/bug29888_2 b/tests/bugs/xde/bug29888_2 new file mode 100644 index 0000000000..cc2fa4cb86 --- /dev/null +++ b/tests/bugs/xde/bug29888_2 @@ -0,0 +1,32 @@ +puts "==========" +puts "OCC29888" +puts "==========" +puts "" +######################################### +# XCAFDoc_Editor::Expand() removes names +######################################### +pload ALL + +XOpen [locate_data_file bug29888_part.xbf] D + +XExpand D 0 + +set name_ref [GetName D 0:1:1:2:4] +set name_part [GetName D 0:1:1:6] +if {$name_ref != $name_part || $name_ref != "LanternPole_Body"} { + puts "Error: name has been lost" +} + +set name_ref [GetName D 0:1:1:2:5] +set name_part [GetName D 0:1:1:7] +if {$name_ref != $name_part || $name_ref != "LanternPole_Chain"} { + puts "Error: name has been lost" +} + +set name_ref [GetName D 0:1:1:2:6] +set name_part [GetName D 0:1:1:8] +if {$name_ref != $name_part || $name_ref != "LanternPole_Lantern"} { + puts "Error: name has been lost" +} + +Close D