b311480e |
1 | // Created on: 1997-12-10 |
2 | // Created by: Denis PASCAL |
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 | |
17 | #include <TDataStd_Relation.ixx> |
18 | #include <TCollection_AsciiString.hxx> |
19 | #include <TDataStd_Variable.hxx> |
20 | #include <TDF_ListIteratorOfAttributeList.hxx> |
21 | |
22 | #define OCC387 |
23 | |
24 | //======================================================================= |
25 | //function : GetID |
26 | //purpose : |
27 | //======================================================================= |
28 | |
29 | const Standard_GUID& TDataStd_Relation::GetID() |
30 | { |
31 | static Standard_GUID TDataStd_RelationID("ce24146b-8e57-11d1-8953-080009dc4425"); |
32 | return TDataStd_RelationID; |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : Set |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | Handle(TDataStd_Relation) TDataStd_Relation::Set(const TDF_Label& L) |
41 | { |
42 | Handle(TDataStd_Relation) A; |
43 | if (!L.FindAttribute (TDataStd_Relation::GetID(), A)) { |
44 | A = new TDataStd_Relation (); |
45 | L.AddAttribute(A); |
46 | } |
47 | return A; |
48 | } |
49 | |
50 | //======================================================================= |
51 | //function : TDataStd_Relation |
52 | //purpose : |
53 | //======================================================================= |
54 | |
55 | TDataStd_Relation::TDataStd_Relation() |
56 | { |
57 | } |
58 | |
59 | |
60 | //======================================================================= |
61 | //function : Name |
62 | //purpose : |
63 | //======================================================================= |
64 | TCollection_ExtendedString TDataStd_Relation::Name () const |
65 | { |
66 | return myRelation; // ->String(); |
67 | } |
68 | |
69 | //======================================================================= |
70 | //function : SetRelation |
71 | //purpose : |
72 | //======================================================================= |
73 | |
74 | void TDataStd_Relation::SetRelation(const TCollection_ExtendedString& R) |
75 | { |
76 | // OCC2932 correction |
77 | if(myRelation == R) return; |
78 | |
79 | #ifdef OCC387 |
80 | Backup(); |
81 | #endif |
82 | myRelation = R; |
83 | } |
84 | |
85 | //======================================================================= |
86 | //function : GetRelation |
87 | //purpose : |
88 | //======================================================================= |
89 | |
90 | const TCollection_ExtendedString& TDataStd_Relation::GetRelation() const |
91 | { |
92 | return myRelation; |
93 | } |
94 | |
95 | //======================================================================= |
96 | //function : GetVariables |
97 | //purpose : |
98 | //======================================================================= |
99 | |
100 | TDF_AttributeList& TDataStd_Relation::GetVariables() |
101 | { |
102 | return myVariables; |
103 | } |
104 | |
105 | //======================================================================= |
106 | //function : ID |
107 | //purpose : |
108 | //======================================================================= |
109 | |
110 | const Standard_GUID& TDataStd_Relation::ID() const |
111 | { |
112 | return GetID(); |
113 | } |
114 | |
115 | //======================================================================= |
116 | //function : Restore |
117 | //purpose : |
118 | //======================================================================= |
119 | |
120 | void TDataStd_Relation::Restore(const Handle(TDF_Attribute)& With) |
121 | { |
122 | Handle(TDataStd_Relation) REL = Handle(TDataStd_Relation)::DownCast (With); |
123 | myRelation = REL->GetRelation(); |
124 | Handle(TDataStd_Variable) V; |
125 | myVariables.Clear(); |
126 | for (TDF_ListIteratorOfAttributeList it (REL->GetVariables()); it.More(); it.Next()) { |
127 | V = Handle(TDataStd_Variable)::DownCast(it.Value()); |
128 | myVariables.Append(V); |
129 | } |
130 | } |
131 | |
132 | //======================================================================= |
133 | //function : NewEmpty |
134 | //purpose : |
135 | //======================================================================= |
136 | |
137 | Handle(TDF_Attribute) TDataStd_Relation::NewEmpty() const |
138 | { |
139 | return new TDataStd_Relation(); |
140 | } |
141 | |
142 | //======================================================================= |
143 | //function : Paste |
144 | //purpose : |
145 | //======================================================================= |
146 | |
147 | void TDataStd_Relation::Paste(const Handle(TDF_Attribute)& Into, |
148 | const Handle(TDF_RelocationTable)& RT) const |
149 | { |
150 | Handle(TDataStd_Relation) REL = Handle(TDataStd_Relation)::DownCast (Into); |
151 | REL->SetRelation(myRelation); |
152 | Handle(TDataStd_Variable) V1,V2; |
153 | for (TDF_ListIteratorOfAttributeList it (myVariables); it.More(); it.Next()) { |
154 | V1 = Handle(TDataStd_Variable)::DownCast(it.Value()); |
155 | RT->HasRelocation (V1,V2); |
156 | REL->GetVariables().Append(V2); |
157 | } |
158 | } |
159 | |
160 | //======================================================================= |
161 | //function : Dump |
162 | //purpose : |
163 | //======================================================================= |
164 | |
165 | Standard_OStream& TDataStd_Relation::Dump(Standard_OStream& anOS) const |
166 | { |
167 | anOS << "Relation"; |
168 | return anOS; |
169 | } |
170 | |