1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
kgv
2a6b327cbb 0030739: Data Exchange - XCAFDoc_ShapeTool::IsComponent() is too slow 2019-05-23 23:54:44 +03:00
kgv
2eec394698 0030738: Data Exchange - XCAFDoc_ShapeTool::updateComponent() is too long
Cache subshapes list into map instead of re-iterating it multiple times within the loop.
Avoid iteration at all if modified state has been already detected.

XCAFDoc now returns GUIDs by const reference instead of a copy.
2019-05-23 22:48:48 +03:00
6 changed files with 148 additions and 166 deletions

View File

@@ -57,20 +57,16 @@ public:
Standard_EXPORT void Initialize
(const TDF_Label& aLabel,
const Standard_Boolean withoutForgotten = Standard_True) ;
inline Standard_Boolean More() const;
Standard_EXPORT void Next() ;
inline Handle(TDF_Attribute) Value() const;
Standard_Boolean More() const { return myValue != NULL; }
protected:
Standard_EXPORT void Next();
// Methods PROTECTED
//
// Fields PROTECTED
//
//! Return current value as handle.
Handle(TDF_Attribute) ValueHandle() const { return myValue; }
//! Return current value as pointer.
TDF_Attribute* Value() const { return myValue; }
private:
@@ -85,14 +81,4 @@ private:
Standard_Boolean myWithoutForgotten;
};
// other inline functions and methods (like "C++: function call" methods)
//
inline Standard_Boolean TDF_AttributeIterator::More() const
{ return (myValue != 0L); }
inline Handle(TDF_Attribute) TDF_AttributeIterator::Value() const
{ return myValue; }
#endif

View File

@@ -53,31 +53,28 @@ void TDF_Label::Imported(const Standard_Boolean aStatus) const
//purpose : Finds an attributes according to an ID.
//=======================================================================
Standard_Boolean TDF_Label::FindAttribute
(const Standard_GUID& anID,
Handle(TDF_Attribute)& anAttribute) const
TDF_Attribute* TDF_Label::FindAttribute (const Standard_GUID& theID) const
{
if (IsNull()) throw Standard_NullObject("A null Label has no attribute.");
TDF_AttributeIterator itr (myLabelNode); // Without removed attributes.
for ( ; itr.More(); itr.Next()) {
if (itr.Value()->ID() == anID) {
anAttribute = itr.Value();
return Standard_True;
// Without removed attributes.
for (TDF_AttributeIterator itr (myLabelNode); itr.More(); itr.Next())
{
if (itr.Value()->ID() == theID)
{
return itr.Value();
}
}
return Standard_False;
return NULL;
}
//=======================================================================
//function : FindAttribute
//purpose : Finds an attributes according to an ID and a Transaction.
//=======================================================================
Standard_Boolean TDF_Label::FindAttribute
(const Standard_GUID& anID,
const Standard_Integer aTransaction,
Handle(TDF_Attribute)& anAttribute) const
Standard_Boolean TDF_Label::FindAttribute (const Standard_GUID& anID,
const Standard_Integer aTransaction,
Handle(TDF_Attribute)& anAttribute) const
{
Handle(TDF_Attribute) locAtt;
if (FindAttribute(anID, locAtt)) {

View File

@@ -141,23 +141,42 @@ public:
//! attribute is not in the structure.
Standard_EXPORT void ResumeAttribute (const Handle(TDF_Attribute)& anAttribute) const;
//! Finds an attribute of the current label, according
//! to <anID>.
//! If anAttribute is not a valid one, false is returned.
//!
//! Finds an attribute of the current label, according to given ID.
//! The method returns True if found, False otherwise.
//!
//! A removed attribute cannot be found.
Standard_EXPORT Standard_Boolean FindAttribute (const Standard_GUID& anID, Handle(TDF_Attribute)& anAttribute) const;
Standard_Boolean FindAttribute (const Standard_GUID& theID,
Handle(TDF_Attribute)& theAttribute) const
{
if (TDF_Attribute* anAttrib = FindAttribute (theID))
{
theAttribute = anAttrib;
return Standard_True;
}
return Standard_False;
}
//! Finds an attribute of the current label, according to given ID.
//! The method returns NULL if ID is not found.
//! A removed attribute cannot be found.
Standard_EXPORT TDF_Attribute* FindAttribute (const Standard_GUID& anID) const;
//! Safe variant of FindAttribute() for arbitrary type of argument
template <class T>
Standard_Boolean FindAttribute (const Standard_GUID& theID, Handle(T)& theAttr) const
{
Handle(TDF_Attribute) anAttr = theAttr;
Handle(TDF_Attribute) anAttr;
return FindAttribute (theID, anAttr) && ! (theAttr = Handle(T)::DownCast(anAttr)).IsNull();
}
//! Safe variant of FindAttribute() for arbitrary type of argument (pointer)
template <class T>
Standard_Boolean FindAttribute (const Standard_GUID& theID, T*& theAttr) const
{
TDF_Attribute* anAttr = FindAttribute (theID);
theAttr = dynamic_cast<T*> (anAttr);
return theAttr != NULL;
}
//! Finds an attribute of the current label, according
//! to <anID> and <aTransaction>. This attribute
//! has/had to be a valid one for the given

View File

@@ -25,9 +25,9 @@
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ShapeRefGUID ()
const Standard_GUID& XCAFDoc::ShapeRefGUID ()
{
static Standard_GUID ID ("5b896afe-3adf-11d4-b9b7-0060b0ee281b");
static const Standard_GUID ID ("5b896afe-3adf-11d4-b9b7-0060b0ee281b");
return ID;
}
@@ -37,9 +37,9 @@ Standard_GUID XCAFDoc::ShapeRefGUID ()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::AssemblyGUID ()
const Standard_GUID& XCAFDoc::AssemblyGUID ()
{
static Standard_GUID ID ("5b896b00-3adf-11d4-b9b7-0060b0ee281b");
static const Standard_GUID ID ("5b896b00-3adf-11d4-b9b7-0060b0ee281b");
return ID;
}
@@ -49,9 +49,9 @@ Standard_GUID XCAFDoc::AssemblyGUID ()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ExternRefGUID ()
const Standard_GUID& XCAFDoc::ExternRefGUID ()
{
static Standard_GUID ID ("6b896b01-3adf-11d4-b9b7-0060b0ee281b");
static const Standard_GUID ID ("6b896b01-3adf-11d4-b9b7-0060b0ee281b");
return ID;
}
@@ -61,11 +61,11 @@ Standard_GUID XCAFDoc::ExternRefGUID ()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ColorRefGUID (const XCAFDoc_ColorType type)
const Standard_GUID& XCAFDoc::ColorRefGUID (const XCAFDoc_ColorType type)
{
static Standard_GUID IDcol ("efd212e4-6dfd-11d4-b9c8-0060b0ee281b");
static Standard_GUID IDcolSurf ("efd212e5-6dfd-11d4-b9c8-0060b0ee281b");
static Standard_GUID IDcolCurv ("efd212e6-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID IDcol ("efd212e4-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID IDcolSurf ("efd212e5-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID IDcolCurv ("efd212e6-6dfd-11d4-b9c8-0060b0ee281b");
switch ( type ) {
default:
@@ -81,10 +81,10 @@ Standard_GUID XCAFDoc::ColorRefGUID (const XCAFDoc_ColorType type)
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::DimTolRefGUID()
const Standard_GUID& XCAFDoc::DimTolRefGUID()
{
//static Standard_GUID IDDimTol("58ed092d-44de-11d8-8776-001083004c77");
static Standard_GUID ID("efd212e9-6dfd-11d4-b9c8-0060b0ee281b");
//static const Standard_GUID IDDimTol("58ed092d-44de-11d8-8776-001083004c77");
static const Standard_GUID ID("efd212e9-6dfd-11d4-b9c8-0060b0ee281b");
//return IDDimTol;
return ID;
}
@@ -94,9 +94,9 @@ Standard_GUID XCAFDoc::DimTolRefGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::DimensionRefFirstGUID()
const Standard_GUID& XCAFDoc::DimensionRefFirstGUID()
{
static Standard_GUID ID("efd212e3-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID("efd212e3-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -105,9 +105,9 @@ Standard_GUID XCAFDoc::DimensionRefFirstGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::DimensionRefSecondGUID()
const Standard_GUID& XCAFDoc::DimensionRefSecondGUID()
{
static Standard_GUID ID("efd212e0-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID("efd212e0-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -116,9 +116,9 @@ Standard_GUID XCAFDoc::DimensionRefSecondGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::GeomToleranceRefGUID()
const Standard_GUID& XCAFDoc::GeomToleranceRefGUID()
{
static Standard_GUID ID("efd213e3-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID("efd213e3-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -127,9 +127,9 @@ Standard_GUID XCAFDoc::GeomToleranceRefGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::DatumRefGUID()
const Standard_GUID& XCAFDoc::DatumRefGUID()
{
static Standard_GUID ID("efd212e2-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID("efd212e2-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -139,10 +139,10 @@ Standard_GUID XCAFDoc::DatumRefGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::DatumTolRefGUID()
const Standard_GUID& XCAFDoc::DatumTolRefGUID()
{
//static Standard_GUID IDDimTol("58ed092d-44de-11d8-8776-001083004c77");
static Standard_GUID ID("efd212e7-6dfd-11d4-b9c8-0060b0ee281b");
//static const Standard_GUID IDDimTol("58ed092d-44de-11d8-8776-001083004c77");
static const Standard_GUID ID("efd212e7-6dfd-11d4-b9c8-0060b0ee281b");
//return IDDimTol;
return ID;
}
@@ -153,9 +153,9 @@ Standard_GUID XCAFDoc::DatumTolRefGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::LayerRefGUID ()
const Standard_GUID& XCAFDoc::LayerRefGUID ()
{
static Standard_GUID ID ("efd212e8-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID ("efd212e8-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -165,9 +165,9 @@ Standard_GUID XCAFDoc::LayerRefGUID ()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::MaterialRefGUID ()
const Standard_GUID& XCAFDoc::MaterialRefGUID ()
{
static Standard_GUID ID ("efd212f7-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID ("efd212f7-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -177,9 +177,9 @@ Standard_GUID XCAFDoc::MaterialRefGUID ()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::NoteRefGUID()
const Standard_GUID& XCAFDoc::NoteRefGUID()
{
static Standard_GUID ID ("F3599E50-F84A-493e-8D1B-1284E79322F1");
static const Standard_GUID ID ("F3599E50-F84A-493e-8D1B-1284E79322F1");
return ID;
}
@@ -188,9 +188,9 @@ Standard_GUID XCAFDoc::NoteRefGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::InvisibleGUID ()
const Standard_GUID& XCAFDoc::InvisibleGUID ()
{
static Standard_GUID ID ("5b896aff-3adf-11d4-b9b7-0060b0ee281b");
static const Standard_GUID ID ("5b896aff-3adf-11d4-b9b7-0060b0ee281b");
return ID;
}
@@ -200,9 +200,9 @@ Standard_GUID XCAFDoc::InvisibleGUID ()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ColorByLayerGUID ()
const Standard_GUID& XCAFDoc::ColorByLayerGUID ()
{
static Standard_GUID ID ("279e8c1e-70af-4130-b626-9cc52a537db8");
static const Standard_GUID ID ("279e8c1e-70af-4130-b626-9cc52a537db8");
return ID;
}
@@ -212,9 +212,9 @@ Standard_GUID XCAFDoc::ColorByLayerGUID ()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::SHUORefGUID ()
const Standard_GUID& XCAFDoc::SHUORefGUID ()
{
static Standard_GUID ID ("efd212ea-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID ("efd212ea-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -223,9 +223,9 @@ Standard_GUID XCAFDoc::SHUORefGUID ()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ViewRefGUID()
const Standard_GUID& XCAFDoc::ViewRefGUID()
{
static Standard_GUID ID("efd213e5-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID("efd213e5-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -234,9 +234,9 @@ Standard_GUID XCAFDoc::ViewRefGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ViewRefShapeGUID()
const Standard_GUID& XCAFDoc::ViewRefShapeGUID()
{
static Standard_GUID ID("efd213e6-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID("efd213e6-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -245,9 +245,9 @@ Standard_GUID XCAFDoc::ViewRefShapeGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ViewRefGDTGUID()
const Standard_GUID& XCAFDoc::ViewRefGDTGUID()
{
static Standard_GUID ID("efd213e7-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID("efd213e7-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -256,9 +256,9 @@ Standard_GUID XCAFDoc::ViewRefGDTGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ViewRefPlaneGUID()
const Standard_GUID& XCAFDoc::ViewRefPlaneGUID()
{
static Standard_GUID ID("efd213e9-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID("efd213e9-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -267,9 +267,9 @@ Standard_GUID XCAFDoc::ViewRefPlaneGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ViewRefNoteGUID()
const Standard_GUID& XCAFDoc::ViewRefNoteGUID()
{
static Standard_GUID ID("C814ACC6-43AC-4812-9B2A-4E9A2A549354");
static const Standard_GUID ID("C814ACC6-43AC-4812-9B2A-4E9A2A549354");
return ID;
}
@@ -278,9 +278,9 @@ Standard_GUID XCAFDoc::ViewRefNoteGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ViewRefAnnotationGUID()
const Standard_GUID& XCAFDoc::ViewRefAnnotationGUID()
{
static Standard_GUID ID("A2B5BA42-DD00-43f5-8882-4B5F8E76B9D2");
static const Standard_GUID ID("A2B5BA42-DD00-43f5-8882-4B5F8E76B9D2");
return ID;
}
@@ -289,8 +289,8 @@ Standard_GUID XCAFDoc::ViewRefAnnotationGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::LockGUID()
const Standard_GUID& XCAFDoc::LockGUID()
{
static Standard_GUID ID("efd213eb-6dfd-11d4-b9c8-0060b0ee281b");
static const Standard_GUID ID("efd213eb-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}

View File

@@ -68,105 +68,68 @@ public:
//! class for containing GraphNodes.
//! Returns GUID for UAttribute identifying assembly
Standard_EXPORT static Standard_GUID AssemblyGUID();
Standard_EXPORT static const Standard_GUID& AssemblyGUID();
//! Returns GUID for TreeNode representing assembly link
Standard_EXPORT static Standard_GUID ShapeRefGUID();
Standard_EXPORT static const Standard_GUID& ShapeRefGUID();
//! Return GUIDs for TreeNode representing specified types of colors
Standard_EXPORT static Standard_GUID ColorRefGUID (const XCAFDoc_ColorType type);
Standard_EXPORT static const Standard_GUID& ColorRefGUID (const XCAFDoc_ColorType type);
//! Return GUIDs for TreeNode representing specified types of DGT
Standard_EXPORT static Standard_GUID DimTolRefGUID();
Standard_EXPORT static const Standard_GUID& DimTolRefGUID();
//! Return GUIDs for TreeNode representing specified types of Dimension
Standard_EXPORT static Standard_GUID DimensionRefFirstGUID() ;
Standard_EXPORT static const Standard_GUID& DimensionRefFirstGUID() ;
//! Return GUIDs for TreeNode representing specified types of Dimension
Standard_EXPORT static Standard_GUID DimensionRefSecondGUID() ;
Standard_EXPORT static const Standard_GUID& DimensionRefSecondGUID() ;
//! Return GUIDs for TreeNode representing specified types of GeomTolerance
Standard_EXPORT static Standard_GUID GeomToleranceRefGUID() ;
Standard_EXPORT static const Standard_GUID& GeomToleranceRefGUID() ;
//! Return GUIDs for TreeNode representing specified types of datum
Standard_EXPORT static Standard_GUID DatumRefGUID();
Standard_EXPORT static const Standard_GUID& DatumRefGUID();
//! Return GUIDs for TreeNode representing connections Datum-Toler
Standard_EXPORT static Standard_GUID DatumTolRefGUID();
Standard_EXPORT static const Standard_GUID& DatumTolRefGUID();
Standard_EXPORT static Standard_GUID LayerRefGUID();
Standard_EXPORT static const Standard_GUID& LayerRefGUID();
Standard_EXPORT static Standard_GUID MaterialRefGUID();
Standard_EXPORT static const Standard_GUID& MaterialRefGUID();
//! Return GUIDs for representing notes
Standard_EXPORT static Standard_GUID NoteRefGUID();
Standard_EXPORT static const Standard_GUID& NoteRefGUID();
Standard_EXPORT static Standard_GUID InvisibleGUID();
Standard_EXPORT static const Standard_GUID& InvisibleGUID();
Standard_EXPORT static Standard_GUID ColorByLayerGUID();
Standard_EXPORT static const Standard_GUID& ColorByLayerGUID();
//! Returns GUID for UAttribute identifying external reference on no-step file
Standard_EXPORT static Standard_GUID ExternRefGUID();
Standard_EXPORT static const Standard_GUID& ExternRefGUID();
//! Returns GUID for UAttribute identifying specified higher usage occurrence
Standard_EXPORT static Standard_GUID SHUORefGUID();
Standard_EXPORT static const Standard_GUID& SHUORefGUID();
//! Return GUIDs for TreeNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefGUID();
Standard_EXPORT static const Standard_GUID& ViewRefGUID();
//! Return GUIDs for TreeNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefShapeGUID();
Standard_EXPORT static const Standard_GUID& ViewRefShapeGUID();
//! Return GUIDs for TreeNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefGDTGUID();
Standard_EXPORT static const Standard_GUID& ViewRefGDTGUID();
//! Return GUIDs for TreeNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefPlaneGUID();
Standard_EXPORT static const Standard_GUID& ViewRefPlaneGUID();
//! Return GUIDs for GraphNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefNoteGUID();
Standard_EXPORT static Standard_GUID ViewRefAnnotationGUID();
Standard_EXPORT static const Standard_GUID& ViewRefNoteGUID();
Standard_EXPORT static const Standard_GUID& ViewRefAnnotationGUID();
//! Returns GUID for UAttribute identifying lock flag
Standard_EXPORT static Standard_GUID LockGUID();
protected:
private:
friend class XCAFDoc_DocumentTool;
friend class XCAFDoc_Location;
friend class XCAFDoc_Color;
friend class XCAFDoc_DimTol;
friend class XCAFDoc_Datum;
friend class XCAFDoc_Material;
friend class XCAFDoc_Volume;
friend class XCAFDoc_Area;
friend class XCAFDoc_Centroid;
friend class XCAFDoc_ClippingPlaneTool;
friend class XCAFDoc_ShapeTool;
friend class XCAFDoc_ShapeMapTool;
friend class XCAFDoc_ColorTool;
friend class XCAFDoc_DimTolTool;
friend class XCAFDoc_LayerTool;
friend class XCAFDoc_MaterialTool;
friend class XCAFDoc_GraphNode;
friend class XCAFDoc_Editor;
friend class XCAFDoc_ViewTool;
Standard_EXPORT static const Standard_GUID& LockGUID();
};
#endif // _XCAFDoc_HeaderFile

View File

@@ -46,6 +46,7 @@
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfOrientedShape.hxx>
#include <XCAFDoc.hxx>
#include <XCAFDoc_GraphNode.hxx>
#include <XCAFDoc_Location.hxx>
@@ -756,8 +757,21 @@ Standard_Boolean XCAFDoc_ShapeTool::IsSimpleShape (const TDF_Label& L)
Standard_Boolean XCAFDoc_ShapeTool::IsReference (const TDF_Label& L)
{
Handle(TDataStd_TreeNode) Node;
return L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node) && Node->HasFather();
static const Standard_GUID& aShapeGuid = XCAFDoc::ShapeRefGUID();
static const Handle(Standard_Type) aDynType = STANDARD_TYPE(TDataStd_TreeNode);
if (TDF_Attribute* anAttrib = L.FindAttribute (aShapeGuid))
{
if (anAttrib->IsKind (aDynType))
{
TDataStd_TreeNode* aNode = (TDataStd_TreeNode* )anAttrib;
return aNode->HasFather();
}
}
return Standard_False;
//return L.FindAttribute (aShapeGuid, aNode)
// && aNode->HasFather();
//Handle(TDataStd_TreeNode) Node;
//return L.FindAttribute(XCAFDoc::ShapeRefGUID(), Node) && Node->HasFather();
}
//=======================================================================
@@ -1964,6 +1978,7 @@ Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabe
// Get the currently stored compound for the assembly
TopoDS_Shape aCurrentRootShape;
GetShape(theItemLabel, aCurrentRootShape);
TopTools_MapOfOrientedShape aCurrentRootShapeMap (aCurrentRootShape.NbChildren());
// Get components of the assembly
TDF_LabelSequence aComponentLabs;
@@ -1975,7 +1990,7 @@ Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabe
// Compare the number of components in XDE structure with the number of
// components in topological structure. A component may happen to be removed,
// so we have to update the assembly compound
Standard_Integer aNumTopoComponents = aCurrentRootShape.NbChildren();
const Standard_Integer aNumTopoComponents = aCurrentRootShape.NbChildren();
//
if ( aNumTopoComponents != aComponentLabs.Length() )
isModified = Standard_True;
@@ -2014,21 +2029,23 @@ Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabe
else
{
// Search for a part in the actual compound of the ultimate assembly.
// If the part is there, then the compound is up-to-date, so it does
// not require rebuilding
Standard_Boolean isPartFound = Standard_False;
for ( TopoDS_Iterator aTopoIt(aCurrentRootShape); aTopoIt.More(); aTopoIt.Next() )
// If the part is there, then the compound is up-to-date, so it does not require rebuilding
if (!isModified)
{
if ( aTopoIt.Value() == aComponentShape )
if (aCurrentRootShapeMap.IsEmpty())
{
isPartFound = Standard_True;
break;
// optimize search for next labels in aComponentLabs
for (TopoDS_Iterator aTopoIt(aCurrentRootShape); aTopoIt.More(); aTopoIt.Next())
{
aCurrentRootShapeMap.Add (aTopoIt.Value());
}
}
if (!aCurrentRootShapeMap.Contains (aComponentShape))
{
// Part has been modified somewhere, so the compound has to be rebuilt
isModified = Standard_True;
}
}
if ( !isPartFound && !isModified )
isModified = Standard_True; // Part has been modified somewhere, so the compound
// has to be rebuilt
}
// Fill the list of shapes composing a new compound for the assembly