1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "DF_ChildIterator.hxx"
23 DF_ChildIterator::DF_ChildIterator(const DF_Label& theLabel, bool allLevels)
24 :_root(NULL), _current(NULL)
26 Init(theLabel, allLevels);
29 DF_ChildIterator::DF_ChildIterator()
30 :_root(NULL), _current(NULL)
34 DF_ChildIterator::~DF_ChildIterator()
40 //Initializes the iterator
41 void DF_ChildIterator::Init(const DF_Label& theLabel, bool allLevels)
43 _root = theLabel._node;
44 _allLevels = allLevels;
45 if(_root) _current = _root->_firstChild;
48 //Returns a current Label
49 DF_Label DF_ChildIterator::Value()
51 return DF_Label(_current);
54 //Returns true if there is a current Label
55 bool DF_ChildIterator::More()
60 //Moves to the next Label
61 void DF_ChildIterator::Next()
64 _current = _current->_next; //Move to the next brother
68 if(_current->_firstChild) { //Go down to the first child
69 _current = _current->_firstChild;
72 if(_current->_next) { //Next Brother
73 _current = _current->_next;
76 if(_current->_father && _current->_father != _root) {
77 DF_LabelNode *father = _current->_father;
78 _current = father->_next;
80 while(father && father != _root) {
81 father = father->_father;
82 if(father->_next) break;
84 if(father == _root) father = NULL;
85 if(father) _current = father->_next;
90 _current = NULL; //We iterate the whole sub tree