summaryrefslogtreecommitdiff
path: root/src/TDF/TDF_ChildIterator.cxx
blob: 2bda8f0d4d1b7d69331fa83603d3b740da30d4ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// File:	TDF_ChildIterator.cxx
//      	----------------------
// Author:	DAUTRY Philippe
//		<fid@fox.paris1.matra-dtv.fr>
// Copyright:	Matra Datavision 1997

// Version:	0.0
// History:	Version	Date		Purpose
//		0.0	Feb  7 1997	Creation



#include <TDF_ChildIterator.ixx>

#include <TDF_Label.hxx>
#include <TDF_LabelNode.hxx>
#include <TDF_LabelNodePtr.hxx>

#define ChildIterator_UpToBrother \
{ \
    while (myNode && (myNode->Depth() > myFirstLevel) && !myNode->Brother()) \
      myNode = myNode->Father(); \
	if (myNode && (myNode->Depth() > myFirstLevel) && myNode->Father()) \
	  myNode = myNode->Brother(); \
	else \
	  myNode = NULL; \
}


//=======================================================================
//function : TDF_ChildIterator
//purpose  : 
//=======================================================================

TDF_ChildIterator::TDF_ChildIterator()
: myNode(NULL),
  myFirstLevel(0)
{}


//=======================================================================
//function : TDF_ChildIterator
//purpose  : 
//=======================================================================

TDF_ChildIterator::TDF_ChildIterator
(const TDF_Label& aLabel,
 const Standard_Boolean allLevels)
: myNode(aLabel.myLabelNode->FirstChild()),
  myFirstLevel(allLevels ? aLabel.Depth() : -1)
{}


//=======================================================================
//function : Initialize
//purpose  : 
//=======================================================================

void TDF_ChildIterator::Initialize
(const TDF_Label& aLabel,
 const Standard_Boolean allLevels)
{
  myNode = aLabel.myLabelNode->FirstChild();
  myFirstLevel = allLevels ? aLabel.Depth() : -1;
}


//=======================================================================
//function : Next
//purpose  : 
//=======================================================================

void TDF_ChildIterator::Next() 
{
  if (myFirstLevel == -1) {
    myNode = myNode->Brother();
  }
  else {
    if (myNode->FirstChild()) myNode = myNode->FirstChild();
    else ChildIterator_UpToBrother;
  }
}


//=======================================================================
//function : NextBrother
//purpose  : 
//=======================================================================

void TDF_ChildIterator::NextBrother() 
{
  if ((myFirstLevel  == -1) || myNode->Brother()) myNode = myNode->Brother();
  else ChildIterator_UpToBrother;
}