1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0031323: OCAF, TObj - TObj_OcafObjectIterator does not go recursively to children if type argument is used

Added theAllSubChildren flag to the TObj_OcafObjectIterator to iterate all sub-children.
By default it still iterates only the first level of children.
This commit is contained in:
mpv
2020-09-14 16:49:38 +03:00
committed by bugmaster
parent 0b55d29b6a
commit 689dc3b1c9
4 changed files with 73 additions and 31 deletions

View File

@@ -29,8 +29,10 @@ IMPLEMENT_STANDARD_RTTIEXT(TObj_OcafObjectIterator,TObj_LabelIterator)
TObj_OcafObjectIterator::TObj_OcafObjectIterator
(const TDF_Label& theLabel,
const Handle(Standard_Type)& theType,
const Standard_Boolean theRecursive)
: TObj_LabelIterator( theLabel, theRecursive ), myType( theType )
const Standard_Boolean theRecursive,
const Standard_Boolean theAllSubChildren)
: TObj_LabelIterator (theLabel, theRecursive),
myType (theType), myAllSubChildren (theAllSubChildren)
{
MakeStep();
}
@@ -46,14 +48,14 @@ void TObj_OcafObjectIterator::MakeStep()
{
TDF_Label L = myIterator.Value();
Handle(TObj_Object) anObject;
if(TObj_Object::GetObj(L,anObject))
if(TObj_Object::GetObj (L, anObject))
{
if (myType.IsNull() || anObject->IsKind( myType ))
if (myType.IsNull() || anObject->IsKind (myType))
{
myObject = anObject;
myNode = L;
}
myIterator.NextBrother();
myAllSubChildren ? myIterator.Next() : myIterator.NextBrother();
}
else
myIterator.Next();

View File

@@ -27,35 +27,28 @@
class TObj_OcafObjectIterator : public TObj_LabelIterator
{
public:
/**
* Constructor
*/
//! Creates the iterator on objects in the sub labels of theLabel
//! theType narrows a variety of iterated objects
public:
//! Creates the iterator on TObj objects on the sub-labels of theLabel.
//! @param theLabel start label for searching
//! @param theType type of the found objects, or all types if Null
//! @param theRecursive search children recursively, not only on sub-labels of theLabel
//! @param theAllSubChildren do not stop at the first level of children, but search for sub-children too
Standard_EXPORT TObj_OcafObjectIterator
(const TDF_Label& theLabel,
const Handle(Standard_Type)& theType = NULL,
const Standard_Boolean theRecursive = Standard_False);
protected:
/*
* Internal methods
*/
const Standard_Boolean theRecursive = Standard_False,
const Standard_Boolean theAllSubChildren = Standard_False);
protected:
//! Shift iterator to the next object
virtual Standard_EXPORT void MakeStep() Standard_OVERRIDE;
protected:
/**
* fields
*/
protected:
Handle(Standard_Type) myType; //!< type of objects to iterate on
Standard_Boolean myAllSubChildren; //!< to iterate all sub-children, do not stop on the first level
public:
//! CASCADE RTTI
public:
//! CASCADE RTTI
DEFINE_STANDARD_RTTIEXT(TObj_OcafObjectIterator,TObj_LabelIterator)
};