1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "DF_ChildIterator.hxx"
28 DF_ChildIterator::DF_ChildIterator(const DF_Label& theLabel, bool allLevels)
29 :_root(NULL), _current(NULL)
31 Init(theLabel, allLevels);
34 DF_ChildIterator::DF_ChildIterator()
35 :_root(NULL), _current(NULL)
39 DF_ChildIterator::~DF_ChildIterator()
45 //Initializes the iterator
46 void DF_ChildIterator::Init(const DF_Label& theLabel, bool allLevels)
48 _root = theLabel._node;
49 _allLevels = allLevels;
50 if(_root) _current = _root->_firstChild;
53 //Returns a current Label
54 DF_Label DF_ChildIterator::Value()
56 return DF_Label(_current);
59 //Returns true if there is a current Label
60 bool DF_ChildIterator::More()
62 return bool(_current);
65 //Moves to the next Label
66 void DF_ChildIterator::Next()
69 _current = _current->_next; //Move to the next brother
73 if(_current->_firstChild) { //Go down to the first child
74 _current = _current->_firstChild;
77 if(_current->_next) { //Next Brother
78 _current = _current->_next;
81 if(_current->_father && _current->_father != _root) {
82 DF_LabelNode *father = _current->_father;
83 _current = father->_next;
85 while(father && father != _root) {
86 father = father->_father;
87 if(father->_next) break;
89 if(father == _root) father = NULL;
90 if(father) _current = father->_next;
95 _current = NULL; //We iterate the whole sub tree