summaryrefslogtreecommitdiff
path: root/src/TNaming/TNaming_Scope.cxx
blob: 15ed4381fc5f294dc32c07883726b3803b9d805c (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// File:	TNaming_Scope.cxx
// Created:	Wed Nov  3 17:23:44 1999
// Author:	Denis PASCAL
//		<dp@dingox.paris1.matra-dtv.fr>


#include <TNaming_Scope.ixx>

#include <TDF_Label.hxx>
#include <TDF_ChildIterator.hxx>
#include <TNaming_Tool.hxx>

//=======================================================================
//function : TNaming_Scope
//purpose  : 
//=======================================================================

TNaming_Scope::TNaming_Scope () : myWithValid(Standard_False)
{
}

//=======================================================================
//function : TNaming_Scope
//purpose  : 
//=======================================================================

TNaming_Scope::TNaming_Scope (TDF_LabelMap& map)
{ 
  myWithValid = Standard_True;
  myValid = map;
}

//=======================================================================
//function : TNaming_Scope
//purpose  : 
//=======================================================================

TNaming_Scope::TNaming_Scope (const Standard_Boolean with) : myWithValid(with)
{
}


//=======================================================================
//function : WithValid
//purpose  : 
//=======================================================================
Standard_Boolean TNaming_Scope::WithValid() const
{
  return myWithValid;
}

//=======================================================================
//function : WithValid
//purpose  : 
//=======================================================================
void TNaming_Scope::WithValid(const Standard_Boolean mode) 
{
  myWithValid = mode;
}

//=======================================================================
//function : ClearValid
//purpose  : 
//=======================================================================
void TNaming_Scope::ClearValid() 
{
  myValid.Clear(); 
}

//=======================================================================
//function : Valid
//purpose  : 
//=======================================================================
void TNaming_Scope::Valid(const TDF_Label& L) 
{
  myValid.Add(L);
}

//=======================================================================
//function : ValidChildren
//purpose  : 
//=======================================================================

void TNaming_Scope::ValidChildren(const TDF_Label& L,
					  const Standard_Boolean withroot) 
{  
  if (L.HasChild()) {
    TDF_ChildIterator itc (L,Standard_True);
    for (;itc.More();itc.Next()) myValid.Add(itc.Value());
  }
  if (withroot) myValid.Add(L);
}

//=======================================================================
//function : Unvalid
//purpose  : 
//=======================================================================
void TNaming_Scope::Unvalid(const TDF_Label& L) 
{
  myValid.Remove(L);
}

//=======================================================================
//function : UnvalidChildren
//purpose  : 
//=======================================================================

void TNaming_Scope::UnvalidChildren(const TDF_Label& L,
					  const Standard_Boolean withroot) 
{  
  if (L.HasChild()) {
    TDF_ChildIterator itc (L,Standard_True);
    for (;itc.More();itc.Next()) myValid.Remove(itc.Value());
  }
  if (withroot) myValid.Remove(L);
}

//=======================================================================
//function : IsValid
//purpose  : 
//=======================================================================
Standard_Boolean TNaming_Scope::IsValid(const TDF_Label& L) const
{
  if (myWithValid) return myValid.Contains (L);
  return Standard_True;
}

//=======================================================================
//function : GetValid
//purpose  : 
//=======================================================================
const TDF_LabelMap& TNaming_Scope::GetValid() const
{
  return myValid;
}

//=======================================================================
//function : ChangeValid
//purpose  : 
//=======================================================================
TDF_LabelMap& TNaming_Scope::ChangeValid()
{
  return myValid;
}

//=======================================================================
//function : CurrentShape
//purpose  : 
//=======================================================================
TopoDS_Shape TNaming_Scope::CurrentShape(const Handle(TNaming_NamedShape)& NS) const     
{
  if (myWithValid) return TNaming_Tool::CurrentShape(NS,myValid);
  return TNaming_Tool::CurrentShape(NS);
}