Get rid of problem with updating of parents shared one assembly.
GetFreeShapes(aRootLabels);
// Iterate over the free shapes
GetFreeShapes(aRootLabels);
// Iterate over the free shapes
+ TDF_LabelMap anUpdated;
for ( TDF_LabelSequence::Iterator anIt(aRootLabels); anIt.More(); anIt.Next() )
{
TDF_Label aRefLabel = anIt.Value();
for ( TDF_LabelSequence::Iterator anIt(aRootLabels); anIt.More(); anIt.Next() )
{
TDF_Label aRefLabel = anIt.Value();
}
const TDF_Label& aRootLab = aRefLabel;
TopoDS_Shape anAssemblyShape;
}
const TDF_Label& aRootLab = aRefLabel;
TopoDS_Shape anAssemblyShape;
- updateComponent(aRootLab, anAssemblyShape);
+ updateComponent(aRootLab, anAssemblyShape, anUpdated);
//=======================================================================
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) )
return Standard_False; // Do nothing for non-assemblies
{
if ( !IsAssembly(theItemLabel) )
return Standard_False; // Do nothing for non-assemblies
// Get the currently stored compound for the assembly
TopoDS_Shape aCurrentRootShape;
GetShape(theItemLabel, aCurrentRootShape);
// Get the currently stored compound for the assembly
TopoDS_Shape 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());
// Get components of the assembly
TopTools_MapOfOrientedShape aCurrentRootShapeMap (aCurrentRootShape.NbChildren());
// Get components of the assembly
if ( IsAssembly(aComponentRefLab) )
{
// Recursive call
if ( IsAssembly(aComponentRefLab) )
{
// 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
}
}
NB.Generated(theUpdatedShape);
}
NB.Generated(theUpdatedShape);
}
+ if (isModified)
+ theUpdated.Add(theItemLabel);
+
#include <Standard_Boolean.hxx>
#include <TDataStd_NamedData.hxx>
#include <TDF_Attribute.hxx>
#include <Standard_Boolean.hxx>
#include <TDataStd_NamedData.hxx>
#include <TDF_Attribute.hxx>
+#include <TDF_LabelMap.hxx>
#include <TDF_LabelSequence.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OStream.hxx>
#include <TDF_LabelSequence.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OStream.hxx>
//! associated compound is updated. Returns true if the assembly item is
//! modified, false -- otherwise.
Standard_EXPORT Standard_Boolean updateComponent(const TDF_Label& theAssmLabel,
//! associated compound is updated. Returns true if the assembly item is
//! modified, false -- otherwise.
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)
//! For internal use. Used by public method AddShape.
//! Adds a new top-level (creates and returns a new label)
//! For internal use. Used by public method AddShape.
--- /dev/null
+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
+