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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TNaming_Scope.ixx>
19 #include <TDF_Label.hxx>
20 #include <TDF_ChildIterator.hxx>
21 #include <TNaming_Tool.hxx>
23 //=======================================================================
24 //function : TNaming_Scope
26 //=======================================================================
28 TNaming_Scope::TNaming_Scope () : myWithValid(Standard_False)
32 //=======================================================================
33 //function : TNaming_Scope
35 //=======================================================================
37 TNaming_Scope::TNaming_Scope (TDF_LabelMap& map)
39 myWithValid = Standard_True;
43 //=======================================================================
44 //function : TNaming_Scope
46 //=======================================================================
48 TNaming_Scope::TNaming_Scope (const Standard_Boolean with) : myWithValid(with)
53 //=======================================================================
54 //function : WithValid
56 //=======================================================================
57 Standard_Boolean TNaming_Scope::WithValid() const
62 //=======================================================================
63 //function : WithValid
65 //=======================================================================
66 void TNaming_Scope::WithValid(const Standard_Boolean mode)
71 //=======================================================================
72 //function : ClearValid
74 //=======================================================================
75 void TNaming_Scope::ClearValid()
80 //=======================================================================
83 //=======================================================================
84 void TNaming_Scope::Valid(const TDF_Label& L)
89 //=======================================================================
90 //function : ValidChildren
92 //=======================================================================
94 void TNaming_Scope::ValidChildren(const TDF_Label& L,
95 const Standard_Boolean withroot)
98 TDF_ChildIterator itc (L,Standard_True);
99 for (;itc.More();itc.Next()) myValid.Add(itc.Value());
101 if (withroot) myValid.Add(L);
104 //=======================================================================
107 //=======================================================================
108 void TNaming_Scope::Unvalid(const TDF_Label& L)
113 //=======================================================================
114 //function : UnvalidChildren
116 //=======================================================================
118 void TNaming_Scope::UnvalidChildren(const TDF_Label& L,
119 const Standard_Boolean withroot)
122 TDF_ChildIterator itc (L,Standard_True);
123 for (;itc.More();itc.Next()) myValid.Remove(itc.Value());
125 if (withroot) myValid.Remove(L);
128 //=======================================================================
131 //=======================================================================
132 Standard_Boolean TNaming_Scope::IsValid(const TDF_Label& L) const
134 if (myWithValid) return myValid.Contains (L);
135 return Standard_True;
138 //=======================================================================
139 //function : GetValid
141 //=======================================================================
142 const TDF_LabelMap& TNaming_Scope::GetValid() const
147 //=======================================================================
148 //function : ChangeValid
150 //=======================================================================
151 TDF_LabelMap& TNaming_Scope::ChangeValid()
156 //=======================================================================
157 //function : CurrentShape
159 //=======================================================================
160 TopoDS_Shape TNaming_Scope::CurrentShape(const Handle(TNaming_NamedShape)& NS) const
162 if (myWithValid) return TNaming_Tool::CurrentShape(NS,myValid);
163 return TNaming_Tool::CurrentShape(NS);