1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0031517: Data Exchange - wrong result of ShapeTool::UpdateAssemblies()

Get rid of problem with updating of parents shared one assembly.
This commit is contained in:
ika 2020-04-23 17:58:59 +03:00 committed by bugmaster
parent 7ff18fb9cc
commit 331bcfc0d0
3 changed files with 55 additions and 7 deletions

View File

@ -1012,6 +1012,7 @@ void XCAFDoc_ShapeTool::UpdateAssemblies()
GetFreeShapes(aRootLabels); GetFreeShapes(aRootLabels);
// Iterate over the free shapes // Iterate over the free shapes
TDF_LabelMap anUpdated;
for ( TDF_LabelSequence::Iterator anIt(aRootLabels); anIt.More(); anIt.Next() ) for ( TDF_LabelSequence::Iterator anIt(aRootLabels); anIt.More(); anIt.Next() )
{ {
TDF_Label aRefLabel = anIt.Value(); TDF_Label aRefLabel = anIt.Value();
@ -1021,7 +1022,7 @@ void XCAFDoc_ShapeTool::UpdateAssemblies()
} }
const TDF_Label& aRootLab = aRefLabel; const TDF_Label& aRootLab = aRefLabel;
TopoDS_Shape anAssemblyShape; TopoDS_Shape anAssemblyShape;
updateComponent(aRootLab, anAssemblyShape); updateComponent(aRootLab, anAssemblyShape, anUpdated);
} }
} }
@ -2003,7 +2004,8 @@ void XCAFDoc_ShapeTool::makeSubShape (const TDF_Label& theMainShapeL,
//======================================================================= //=======================================================================
Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabel, Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabel,
TopoDS_Shape& theUpdatedShape) const TopoDS_Shape& theUpdatedShape,
TDF_LabelMap& theUpdated) const
{ {
if ( !IsAssembly(theItemLabel) ) if ( !IsAssembly(theItemLabel) )
return Standard_False; // Do nothing for non-assemblies return Standard_False; // Do nothing for non-assemblies
@ -2011,6 +2013,13 @@ Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabe
// Get the currently stored compound for the assembly // Get the currently stored compound for the assembly
TopoDS_Shape aCurrentRootShape; TopoDS_Shape aCurrentRootShape;
GetShape(theItemLabel, aCurrentRootShape); GetShape(theItemLabel, aCurrentRootShape);
// Check if the given assembly is already updated
if (theUpdated.Contains(theItemLabel)) {
theUpdatedShape = aCurrentRootShape;
return Standard_True;
}
TopTools_MapOfOrientedShape aCurrentRootShapeMap (aCurrentRootShape.NbChildren()); TopTools_MapOfOrientedShape aCurrentRootShapeMap (aCurrentRootShape.NbChildren());
// Get components of the assembly // Get components of the assembly
@ -2051,11 +2060,9 @@ Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabe
if ( IsAssembly(aComponentRefLab) ) if ( IsAssembly(aComponentRefLab) )
{ {
// Recursive call // Recursive call
if ( updateComponent(aComponentRefLab, aComponentShape) ) if ( updateComponent(aComponentRefLab, aComponentShape, theUpdated) )
{ {
if ( !isModified ) isModified = Standard_True;
isModified = Standard_True;
aComponentShape.Location(aComponentLoc); // Apply placement aComponentShape.Location(aComponentLoc); // Apply placement
} }
} }
@ -2106,6 +2113,9 @@ Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabe
NB.Generated(theUpdatedShape); NB.Generated(theUpdatedShape);
} }
if (isModified)
theUpdated.Add(theItemLabel);
return isModified; return isModified;
} }

View File

@ -23,6 +23,7 @@
#include <Standard_Boolean.hxx> #include <Standard_Boolean.hxx>
#include <TDataStd_NamedData.hxx> #include <TDataStd_NamedData.hxx>
#include <TDF_Attribute.hxx> #include <TDF_Attribute.hxx>
#include <TDF_LabelMap.hxx>
#include <TDF_LabelSequence.hxx> #include <TDF_LabelSequence.hxx>
#include <Standard_Integer.hxx> #include <Standard_Integer.hxx>
#include <Standard_OStream.hxx> #include <Standard_OStream.hxx>
@ -441,7 +442,8 @@ private:
//! associated compound is updated. Returns true if the assembly item is //! associated compound is updated. Returns true if the assembly item is
//! modified, false -- otherwise. //! modified, false -- otherwise.
Standard_EXPORT Standard_Boolean updateComponent(const TDF_Label& theAssmLabel, Standard_EXPORT Standard_Boolean updateComponent(const TDF_Label& theAssmLabel,
TopoDS_Shape& theUpdatedShape) const; TopoDS_Shape& theUpdatedShape,
TDF_LabelMap& theUpdated) const;
//! Adds a new top-level (creates and returns a new label) //! Adds a new top-level (creates and returns a new label)
//! For internal use. Used by public method AddShape. //! For internal use. Used by public method AddShape.

36
tests/bugs/xde/bug31517 Normal file
View File

@ -0,0 +1,36 @@
puts "======================================================================"
puts "0031517: Data Exchange - wrong result of ShapeTool::UpdateAssemblies()"
puts "======================================================================"
puts ""
pload DCAF
# make structure with two assemblies linked to one original assembly (2 * 3 boxes)
box b1 1 1 1
box b2 2 0 0 1 1 1
box b3 -2 0 0 1 1 1
compound b1 b2 b3 bs
copy bs bs1
ttranslate bs1 0 2 0
copy bs bs2
ttranslate bs2 0 -2 0
compound bs1 r1
compound bs2 r2
compound r1 r2 root
XNewDoc D
XAddShape D root
# delete one of boxes in common assembly (should be 2 * 2 boxes)
XRemoveComponent D 0:1:1:3:1
XRemoveShape D 0:1:1:4
XUpdateAssemblies D
XGetOneShape upd D
# check number of boxes
set boxes [explode upd so]
if {$boxes != "upd_1 upd_2 upd_3 upd_4"} {
puts "Error: wrong result of UpdateAssemblies."
}
Close D