0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / TNaming / TNaming_Scope.cxx
1 // Created on: 1999-11-03
2 // Created by: Denis PASCAL
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <TDF_ChildIterator.hxx>
19 #include <TDF_Label.hxx>
20 #include <TNaming_NamedShape.hxx>
21 #include <TNaming_Scope.hxx>
22 #include <TNaming_Tool.hxx>
23 #include <TopoDS_Shape.hxx>
24
25 //=======================================================================
26 //function : TNaming_Scope
27 //purpose  : 
28 //=======================================================================
29 TNaming_Scope::TNaming_Scope () : myWithValid(Standard_False)
30 {
31 }
32
33 //=======================================================================
34 //function : TNaming_Scope
35 //purpose  : 
36 //=======================================================================
37
38 TNaming_Scope::TNaming_Scope (TDF_LabelMap& map)
39
40   myWithValid = Standard_True;
41   myValid = map;
42 }
43
44 //=======================================================================
45 //function : TNaming_Scope
46 //purpose  : 
47 //=======================================================================
48
49 TNaming_Scope::TNaming_Scope (const Standard_Boolean with) : myWithValid(with)
50 {
51 }
52
53
54 //=======================================================================
55 //function : WithValid
56 //purpose  : 
57 //=======================================================================
58 Standard_Boolean TNaming_Scope::WithValid() const
59 {
60   return myWithValid;
61 }
62
63 //=======================================================================
64 //function : WithValid
65 //purpose  : 
66 //=======================================================================
67 void TNaming_Scope::WithValid(const Standard_Boolean mode) 
68 {
69   myWithValid = mode;
70 }
71
72 //=======================================================================
73 //function : ClearValid
74 //purpose  : 
75 //=======================================================================
76 void TNaming_Scope::ClearValid() 
77 {
78   myValid.Clear(); 
79 }
80
81 //=======================================================================
82 //function : Valid
83 //purpose  : 
84 //=======================================================================
85 void TNaming_Scope::Valid(const TDF_Label& L) 
86 {
87   myValid.Add(L);
88 }
89
90 //=======================================================================
91 //function : ValidChildren
92 //purpose  : 
93 //=======================================================================
94
95 void TNaming_Scope::ValidChildren(const TDF_Label& L,
96                                           const Standard_Boolean withroot) 
97 {  
98   if (L.HasChild()) {
99     TDF_ChildIterator itc (L,Standard_True);
100     for (;itc.More();itc.Next()) myValid.Add(itc.Value());
101   }
102   if (withroot) myValid.Add(L);
103 }
104
105 //=======================================================================
106 //function : Unvalid
107 //purpose  : 
108 //=======================================================================
109 void TNaming_Scope::Unvalid(const TDF_Label& L) 
110 {
111   myValid.Remove(L);
112 }
113
114 //=======================================================================
115 //function : UnvalidChildren
116 //purpose  : 
117 //=======================================================================
118
119 void TNaming_Scope::UnvalidChildren(const TDF_Label& L,
120                                           const Standard_Boolean withroot) 
121 {  
122   if (L.HasChild()) {
123     TDF_ChildIterator itc (L,Standard_True);
124     for (;itc.More();itc.Next()) myValid.Remove(itc.Value());
125   }
126   if (withroot) myValid.Remove(L);
127 }
128
129 //=======================================================================
130 //function : IsValid
131 //purpose  : 
132 //=======================================================================
133 Standard_Boolean TNaming_Scope::IsValid(const TDF_Label& L) const
134 {
135   if (myWithValid) return myValid.Contains (L);
136   return Standard_True;
137 }
138
139 //=======================================================================
140 //function : GetValid
141 //purpose  : 
142 //=======================================================================
143 const TDF_LabelMap& TNaming_Scope::GetValid() const
144 {
145   return myValid;
146 }
147
148 //=======================================================================
149 //function : ChangeValid
150 //purpose  : 
151 //=======================================================================
152 TDF_LabelMap& TNaming_Scope::ChangeValid()
153 {
154   return myValid;
155 }
156
157 //=======================================================================
158 //function : CurrentShape
159 //purpose  : 
160 //=======================================================================
161 TopoDS_Shape TNaming_Scope::CurrentShape(const Handle(TNaming_NamedShape)& NS) const     
162 {
163   if (myWithValid) return TNaming_Tool::CurrentShape(NS,myValid);
164   return TNaming_Tool::CurrentShape(NS);
165 }
166
167
168
169