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.
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>
25 //=======================================================================
26 //function : TNaming_Scope
28 //=======================================================================
29 TNaming_Scope::TNaming_Scope () : myWithValid(Standard_False)
33 //=======================================================================
34 //function : TNaming_Scope
36 //=======================================================================
38 TNaming_Scope::TNaming_Scope (TDF_LabelMap& map)
40 myWithValid = Standard_True;
44 //=======================================================================
45 //function : TNaming_Scope
47 //=======================================================================
49 TNaming_Scope::TNaming_Scope (const Standard_Boolean with) : myWithValid(with)
54 //=======================================================================
55 //function : WithValid
57 //=======================================================================
58 Standard_Boolean TNaming_Scope::WithValid() const
63 //=======================================================================
64 //function : WithValid
66 //=======================================================================
67 void TNaming_Scope::WithValid(const Standard_Boolean mode)
72 //=======================================================================
73 //function : ClearValid
75 //=======================================================================
76 void TNaming_Scope::ClearValid()
81 //=======================================================================
84 //=======================================================================
85 void TNaming_Scope::Valid(const TDF_Label& L)
90 //=======================================================================
91 //function : ValidChildren
93 //=======================================================================
95 void TNaming_Scope::ValidChildren(const TDF_Label& L,
96 const Standard_Boolean withroot)
99 TDF_ChildIterator itc (L,Standard_True);
100 for (;itc.More();itc.Next()) myValid.Add(itc.Value());
102 if (withroot) myValid.Add(L);
105 //=======================================================================
108 //=======================================================================
109 void TNaming_Scope::Unvalid(const TDF_Label& L)
114 //=======================================================================
115 //function : UnvalidChildren
117 //=======================================================================
119 void TNaming_Scope::UnvalidChildren(const TDF_Label& L,
120 const Standard_Boolean withroot)
123 TDF_ChildIterator itc (L,Standard_True);
124 for (;itc.More();itc.Next()) myValid.Remove(itc.Value());
126 if (withroot) myValid.Remove(L);
129 //=======================================================================
132 //=======================================================================
133 Standard_Boolean TNaming_Scope::IsValid(const TDF_Label& L) const
135 if (myWithValid) return myValid.Contains (L);
136 return Standard_True;
139 //=======================================================================
140 //function : GetValid
142 //=======================================================================
143 const TDF_LabelMap& TNaming_Scope::GetValid() const
148 //=======================================================================
149 //function : ChangeValid
151 //=======================================================================
152 TDF_LabelMap& TNaming_Scope::ChangeValid()
157 //=======================================================================
158 //function : CurrentShape
160 //=======================================================================
161 TopoDS_Shape TNaming_Scope::CurrentShape(const Handle(TNaming_NamedShape)& NS) const
163 if (myWithValid) return TNaming_Tool::CurrentShape(NS,myValid);
164 return TNaming_Tool::CurrentShape(NS);