From 9baa853415d8cf9a46d4ac9106b6860d4e8eb8c2 Mon Sep 17 00:00:00 2001 From: abv Date: Tue, 16 Feb 2016 14:53:16 +0300 Subject: [PATCH] Revert "0026314: Method SetShape working not correctly." This reverts commit e2df45413ea1d506d911c6f29dacf42c80ca8a35. --- src/XCAFDoc/XCAFDoc_ShapeTool.cxx | 79 +++++++------------------------ src/XCAFDoc/XCAFDoc_ShapeTool.hxx | 8 ---- src/XDEDRAW/XDEDRAW_Shapes.cxx | 3 +- tests/bugs/xde/bug22962 | 2 +- tests/bugs/xde/bug25441 | 22 --------- tests/bugs/xde/bug26314 | 23 --------- 6 files changed, 19 insertions(+), 118 deletions(-) delete mode 100644 tests/bugs/xde/bug25441 delete mode 100644 tests/bugs/xde/bug26314 diff --git a/src/XCAFDoc/XCAFDoc_ShapeTool.cxx b/src/XCAFDoc/XCAFDoc_ShapeTool.cxx index 7949f6580c..75f010b75d 100644 --- a/src/XCAFDoc/XCAFDoc_ShapeTool.cxx +++ b/src/XCAFDoc/XCAFDoc_ShapeTool.cxx @@ -402,32 +402,26 @@ TDF_Label XCAFDoc_ShapeTool::NewShape() const //======================================================================= void XCAFDoc_ShapeTool::SetShape (const TDF_Label& L, const TopoDS_Shape& S) -{ - if(IsReference(L) || !IsTopLevel(L) || /*IsAssembly(L) ||*/ !S.Location().IsIdentity()) - return; - - TDF_LabelSequence aSubShapes; - GetSubShapes(L, aSubShapes); - +{ TNaming_Builder tnBuild(L); tnBuild.Generated(S); Handle(XCAFDoc_ShapeMapTool) A = XCAFDoc_ShapeMapTool::Set(L); +// if ( ! L.FindAttribute(XCAFDoc_ShapeMapTool::GetID(), A) ) { +// A = XCAFDoc_ShapeMapTool::Set(L); +// L.AddAttribute(A); +// } A->SetShape(S); - for(Standard_Integer i = 1; i<=aSubShapes.Length(); i++) - { - TDF_Label aSubLabel = aSubShapes(i); - if (!IsSubShape(L, GetShape(aSubLabel))) - { - aSubLabel.ForgetAllAttributes(); - } - } - if(!myShapeLabels.IsBound(S)) { myShapeLabels.Bind(S,L); } - - UpdateAssociatedAssembly(L); + + //:abv 31.10.01: update assemblies that refer a shape + TDF_LabelSequence Labels; + if ( GetUsers ( L, Labels, Standard_True ) ) { + for ( Standard_Integer i=Labels.Length(); i >=1; i-- ) + UpdateAssembly ( Labels(i) ); + } } //======================================================================= @@ -998,26 +992,6 @@ void XCAFDoc_ShapeTool::RemoveComponent (const TDF_Label& comp) const } } -//======================================================================= -//function : UpdateAssociatedAssembly -//purpose : -//======================================================================= - -void XCAFDoc_ShapeTool::UpdateAssociatedAssembly (const TDF_Label& L) const -{ - TDF_LabelSequence Labels; - if ( GetUsers ( L, Labels ) ) { - for ( Standard_Integer i=Labels.Length(); i >=1; i-- ) - { - TDF_Label anAssemblyLabel = Labels(i).Father(); - if(!anAssemblyLabel.IsNull()) - { - UpdateAssembly(anAssemblyLabel); - } - } - } -} - //======================================================================= //function : UpdateAssembly //purpose : @@ -1027,38 +1001,19 @@ void XCAFDoc_ShapeTool::UpdateAssembly (const TDF_Label& L) const { if ( ! IsAssembly(L) ) return; + TopoDS_Compound newassembly; BRep_Builder b; - TopoDS_Shape aShape = GetShape(L); - Standard_Boolean isFree = aShape.Free(); - if (!isFree) - aShape.Free(Standard_True); - - TopTools_SequenceOfShape aSubShapeSeq; - TopoDS_Iterator Iterator(aShape); - for (; Iterator.More(); Iterator.Next()) - aSubShapeSeq.Append(Iterator.Value()); - - for (Standard_Integer i = 1; i <= aSubShapeSeq.Length(); i++) - b.Remove(aShape, aSubShapeSeq.Value(i)); + b.MakeCompound(newassembly); TDF_ChildIterator chldLabIt(L); for (; chldLabIt.More(); chldLabIt.Next() ) { TDF_Label subLabel = chldLabIt.Value(); if ( IsComponent ( subLabel ) ) { - b.Add(aShape, GetShape(subLabel)); + b.Add(newassembly, GetShape(subLabel)); } } - - if (!isFree) - aShape.Free(Standard_False); - TNaming_Builder tnBuild(L); - tnBuild.Generated(aShape); - - Handle(XCAFDoc_ShapeMapTool) A = XCAFDoc_ShapeMapTool::Set(L); - A->SetShape(aShape); - - UpdateAssociatedAssembly(L); + tnBuild.Generated(newassembly); } //======================================================================= @@ -1951,4 +1906,4 @@ void XCAFDoc_ShapeTool::makeSubShape (const TDF_Label& Part, const TopoDS_Shape& } makeSubShape(Part, aChildShape); } -} \ No newline at end of file +} diff --git a/src/XCAFDoc/XCAFDoc_ShapeTool.hxx b/src/XCAFDoc/XCAFDoc_ShapeTool.hxx index c1f7c9dc6b..bc7ddd8c1e 100644 --- a/src/XCAFDoc/XCAFDoc_ShapeTool.hxx +++ b/src/XCAFDoc/XCAFDoc_ShapeTool.hxx @@ -203,11 +203,6 @@ public: Standard_EXPORT TDF_Label NewShape() const; //! Sets representation (TopoDS_Shape) for top-level shape. - //! If S has location(location.IsIdentity() is false), - //! command will be skipped. Sub-shapes of S which is - //! subshape of old shape, will be stored ( all atributes will be stored). - //! If a sub-label of L is not a sub-shape of the new shape, - //! it will be removed. Standard_EXPORT void SetShape (const TDF_Label& L, const TopoDS_Shape& S); //! Adds a new top-level (creates and returns a new label) @@ -291,9 +286,6 @@ public: //! Removes a component from its assembly Standard_EXPORT void RemoveComponent (const TDF_Label& comp) const; - //! Update labels associated with Label - Standard_EXPORT void UpdateAssociatedAssembly (const TDF_Label& L) const; - //! Update an assembly at label Standard_EXPORT void UpdateAssembly (const TDF_Label& L) const; diff --git a/src/XDEDRAW/XDEDRAW_Shapes.cxx b/src/XDEDRAW/XDEDRAW_Shapes.cxx index 954be5fccc..20bfb0ca9e 100644 --- a/src/XDEDRAW/XDEDRAW_Shapes.cxx +++ b/src/XDEDRAW/XDEDRAW_Shapes.cxx @@ -102,8 +102,7 @@ static Standard_Integer setShape (Draw_Interpretor& di, Standard_Integer argc, c // XCAFDoc_ShapeTool myAssembly; // myAssembly.Init(Doc); Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); - if( !myAssembly->IsAssembly(aLabel)) - myAssembly->SetShape(aLabel, aShape); + myAssembly->SetShape(aLabel, aShape); return 0; } diff --git a/tests/bugs/xde/bug22962 b/tests/bugs/xde/bug22962 index 53b527dc9e..4155ca96b1 100755 --- a/tests/bugs/xde/bug22962 +++ b/tests/bugs/xde/bug22962 @@ -7,7 +7,7 @@ puts "" ####################################################################### set BugNumber OCC22962 -set check_value 96 +set check_value 94 pload DCAF ReadStep D1 [locate_data_file OCC22962-dm1-oc-214.stp] diff --git a/tests/bugs/xde/bug25441 b/tests/bugs/xde/bug25441 deleted file mode 100644 index 60aad3fe52..0000000000 --- a/tests/bugs/xde/bug25441 +++ /dev/null @@ -1,22 +0,0 @@ -puts "========" -puts "OCC25441" -puts "========" -puts "" -########################################################################### -# XCAFDoc_ShapeTool::UpdateAssembly() does not update the back-references -########################################################################### - -pload OCAFKERNEL - -box b 0 0 0 1 1 1 -psphere b1 10 -NewDocument d -compound b c -compound c c1 -XAddShape d c1 1 -XShow d -XSetShape d 0:1:1:3 b1 -XShow d -vfit - -checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/xde/bug26314 b/tests/bugs/xde/bug26314 deleted file mode 100644 index 23d9bd49e0..0000000000 --- a/tests/bugs/xde/bug26314 +++ /dev/null @@ -1,23 +0,0 @@ -puts "========" -puts "OCC26314" -puts "========" -puts "" -############################################################ -# Method XCAFDoc_ShapeTool::SetShape() works not correctly -############################################################ - -pload OCAFKERNEL - -box b 0 0 0 1 1 1 -box b1 -10 -10 -10 10 10 10 -box b2 1 1 1 10 10 10 -NewDocument d -compound b1 c1 -XAddShape d b 1 -XAddShape d c1 1 -XShow d -XSetShape d 0:1:1:3 b2 -XShow d -vfit - -checkview -screenshot -3d -path ${imagedir}/${test_image}.png