mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0030739: Data Exchange - XCAFDoc_ShapeTool::IsComponent() is too slow
This commit is contained in:
@@ -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
|
||||
|
@@ -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)) {
|
||||
|
@@ -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
|
||||
|
@@ -757,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();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
Reference in New Issue
Block a user