b311480e |
1 | // Created on: 1997-08-04 |
2 | // Created by: VAUTHIER Jean-Claude |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
bc73b006 |
17 | #include <TDF_TagSource.hxx> |
7fd59977 |
18 | |
bc73b006 |
19 | #include <Standard_Dump.hxx> |
42cf5bc1 |
20 | #include <Standard_GUID.hxx> |
21 | #include <Standard_Type.hxx> |
22 | #include <TDF_Attribute.hxx> |
23 | #include <TDF_Label.hxx> |
24 | #include <TDF_RelocationTable.hxx> |
7fd59977 |
25 | |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(TDF_TagSource,TDF_Attribute) |
27 | |
7fd59977 |
28 | //======================================================================= |
29 | //function : GetID |
30 | //purpose : |
31 | //======================================================================= |
7fd59977 |
32 | const Standard_GUID& TDF_TagSource::GetID () { |
33 | |
34 | static Standard_GUID TDF_TagSourceID("2a96b611-ec8b-11d0-bee7-080009dc3333"); |
35 | return TDF_TagSourceID; |
36 | } |
37 | |
38 | |
39 | |
40 | //======================================================================= |
41 | //function : Set |
42 | //purpose : |
43 | //======================================================================= |
44 | |
45 | Handle(TDF_TagSource) TDF_TagSource::Set (const TDF_Label& L) { |
46 | |
47 | Handle(TDF_TagSource) T; |
48 | if (!L.FindAttribute (TDF_TagSource::GetID (), T)) { |
49 | T = new TDF_TagSource (); |
50 | L.AddAttribute (T); |
51 | } |
52 | return T; |
53 | } |
54 | |
55 | //======================================================================= |
56 | //function : NewChild |
57 | //purpose : |
58 | //======================================================================= |
59 | |
60 | TDF_Label TDF_TagSource::NewChild (const TDF_Label& L) |
61 | { |
62 | Handle(TDF_TagSource) T; |
63 | if (!L.FindAttribute(GetID(),T)) { |
64 | T = new TDF_TagSource(); |
65 | L.AddAttribute(T); |
66 | } |
67 | return T->NewChild(); |
68 | } |
69 | |
70 | |
71 | |
72 | //======================================================================= |
73 | //function : TDF_TagSource |
74 | //purpose : |
75 | //======================================================================= |
76 | |
77 | TDF_TagSource::TDF_TagSource () : myTag(0) { } |
78 | |
79 | |
80 | |
81 | //======================================================================= |
82 | //function : NewTag |
83 | //purpose : |
84 | //======================================================================= |
85 | |
86 | Standard_Integer TDF_TagSource::NewTag () { |
87 | |
88 | Backup(); // FID 02/07/98 |
89 | return ++myTag; |
90 | } |
91 | |
92 | |
93 | //======================================================================= |
94 | //function : NewChild |
95 | //purpose : |
96 | //======================================================================= |
97 | |
98 | TDF_Label TDF_TagSource::NewChild () { |
99 | return Label().FindChild(NewTag(),Standard_True); |
100 | } |
101 | |
102 | |
103 | //======================================================================= |
104 | //function : Get |
105 | //purpose : |
106 | //======================================================================= |
107 | |
108 | Standard_Integer TDF_TagSource::Get() const |
109 | { |
110 | return myTag; |
111 | } |
112 | |
113 | //======================================================================= |
114 | //function : Set |
115 | //purpose : |
116 | //======================================================================= |
117 | |
118 | void TDF_TagSource::Set (const Standard_Integer T) { |
119 | // OCC2932 correction |
120 | if(myTag == T) return; |
121 | |
122 | Backup (); // FID 02/07/98 |
123 | myTag = T; |
124 | } |
125 | |
126 | |
127 | //======================================================================= |
128 | //function : ID |
129 | //purpose : |
130 | //======================================================================= |
131 | |
132 | const Standard_GUID& TDF_TagSource::ID() const { return GetID (); } |
133 | |
134 | |
135 | |
136 | |
137 | //======================================================================= |
138 | //function : NewEmpty |
139 | //purpose : |
140 | //======================================================================= |
141 | |
142 | Handle(TDF_Attribute) TDF_TagSource::NewEmpty () const |
143 | { |
144 | return new TDF_TagSource (); |
145 | } |
146 | |
147 | |
148 | //======================================================================= |
149 | //function : Restore |
150 | //purpose : |
151 | //======================================================================= |
152 | |
153 | void TDF_TagSource::Restore(const Handle(TDF_Attribute)& With) |
154 | { |
155 | myTag = Handle(TDF_TagSource)::DownCast (With)->Get (); |
156 | } |
157 | |
158 | |
159 | |
160 | //======================================================================= |
161 | //function : Paste |
162 | //purpose : |
163 | //======================================================================= |
164 | |
35e08fe8 |
165 | void TDF_TagSource::Paste (const Handle(TDF_Attribute)& Into, |
166 | const Handle(TDF_RelocationTable)&) const |
7fd59977 |
167 | { |
168 | Handle(TDF_TagSource)::DownCast(Into)->Set (myTag); |
169 | } |
bc73b006 |
170 | |
171 | //======================================================================= |
172 | //function : DumpJson |
173 | //purpose : |
174 | //======================================================================= |
175 | void TDF_TagSource::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const |
176 | { |
177 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) |
178 | |
179 | OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute) |
180 | |
181 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTag) |
182 | } |