-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#include "SUIT_DataObjectIterator.h"
/*!
*/
SUIT_DataObjectIterator::SUIT_DataObjectIterator( SUIT_DataObject* root, const int det, const bool fromTrueRoot )
: myRoot( root ),
-myDetourType( det ),
-myCurrentLevel( 0 )
+myDetourType( det )
{
if ( myRoot && fromTrueRoot )
myRoot = myRoot->root();
if ( myCurrent->myChildren.count() > 0 )
{
myCurrent = extreme( myCurrent->myChildren, myDetourType == DepthLeft );
- myCurrentLevel++;
+ myChildrenIndexes.append(myDetourType == DepthLeft ? 0 : myCurrent->myChildren.size() - 1);
}
else do
{
}
else
{
- aParent->myChildren.find( myCurrent );
- if ( myDetourType == DepthLeft )
- myCurrent = aParent->myChildren.next();
- else
- myCurrent = aParent->myChildren.prev();
- if ( !myCurrent )
+ int idx = myChildrenIndexes.last();
+ if (myDetourType == DepthLeft && idx < aParent->myChildren.count() - 1)
{
- myCurrent = aParent;
- myCurrentLevel--;
+ myChildrenIndexes.last()++;
+ myCurrent = aParent->myChildren[idx + 1];
+ exit = true;
}
- else
+ else if (myDetourType == DepthRight && idx > 0)
+ {
+ myChildrenIndexes.last()--;
+ myCurrent = aParent->myChildren[idx - 1];
exit = true;
+ } else {
+ myCurrent = aParent;
+ myChildrenIndexes.removeLast();
+ }
}
}
while ( !exit );
{
myExtremeChild = extreme( cur->myChildren, myDetourType == BreadthLeft );
myCurrent = myExtremeChild;
- myCurrentLevel++;
+ myChildrenIndexes.append(myDetourType == BreadthLeft ? 0 : myCurrent->myChildren.size() - 1);
}
}
}
*/
int SUIT_DataObjectIterator::depth() const
{
- return myCurrentLevel;
+ return myChildrenIndexes.size();
}
/*!
if ( obj && ( par = parent( obj ) ) )
{
- par->myChildren.find( obj );
- if ( par->myChildren.next() )
- return par->myChildren.current();
+ int idx = par->myChildren.indexOf( obj );
+ if ( idx < par->myChildren.count() - 1 )
+ return par->myChildren[idx + 1];
else
{
for ( ; par; par = globalSibling( par, next ) )
SUIT_DataObject* SUIT_DataObjectIterator::extreme( DataObjectList& aList, bool FromLeft ) const
{
if ( FromLeft )
- return aList.getFirst();
+ return aList.first();
else
- return aList.getLast();
+ return aList.last();
}
/*!