Commit | Line | Data |
---|---|---|
973c2be1 | 1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 2 | // |
973c2be1 | 3 | // This file is part of Open CASCADE Technology software library. |
b311480e | 4 | // |
d5f74e42 | 5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
9 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 10 | // |
973c2be1 | 11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. | |
b311480e | 13 | |
42cf5bc1 | 14 | |
7fd59977 | 15 | #include <Interface_Check.hxx> |
42cf5bc1 | 16 | #include <Interface_EntityIterator.hxx> |
17 | #include <Interface_Graph.hxx> | |
18 | #include <Interface_HGraph.hxx> | |
19 | #include <Interface_InterfaceModel.hxx> | |
7fd59977 | 20 | #include <Interface_MSG.hxx> |
42cf5bc1 | 21 | #include <Message_Messenger.hxx> |
22 | #include <Standard_Transient.hxx> | |
23 | #include <Standard_Type.hxx> | |
7fd59977 | 24 | #include <TColStd_HSequenceOfTransient.hxx> |
42cf5bc1 | 25 | #include <Transfer_Binder.hxx> |
26 | #include <Transfer_TransientProcess.hxx> | |
7fd59977 | 27 | |
92efcf78 | 28 | IMPLEMENT_STANDARD_RTTIEXT(Transfer_TransientProcess,Transfer_ProcessForTransient) |
29 | ||
7fd59977 | 30 | //======================================================================= |
31 | //function : Transfer_TransientProcess | |
32 | //purpose : | |
33 | //======================================================================= | |
7fd59977 | 34 | Transfer_TransientProcess::Transfer_TransientProcess |
35 | (const Standard_Integer nb) : Transfer_ProcessForTransient (nb) | |
36 | { | |
37 | thetrroots = new TColStd_HSequenceOfTransient; | |
38 | } | |
39 | ||
40 | ||
41 | //======================================================================= | |
42 | //function : SetModel | |
43 | //purpose : | |
44 | //======================================================================= | |
45 | ||
46 | void Transfer_TransientProcess::SetModel | |
47 | (const Handle(Interface_InterfaceModel)& model) | |
48 | { | |
49 | themodel = model; | |
50 | } | |
51 | ||
52 | ||
53 | //======================================================================= | |
54 | //function : Model | |
55 | //purpose : | |
56 | //======================================================================= | |
57 | ||
58 | Handle(Interface_InterfaceModel) Transfer_TransientProcess::Model () const | |
59 | { | |
60 | return themodel; | |
61 | } | |
62 | ||
63 | ||
64 | void Transfer_TransientProcess::SetGraph(const Handle(Interface_HGraph)& HG) | |
65 | { | |
66 | thegraph = HG; | |
67 | if (!thegraph.IsNull()) | |
68 | SetModel(thegraph->Graph().Model()); | |
bc650d41 G |
69 | else |
70 | themodel.Nullify(); | |
7fd59977 | 71 | } |
72 | ||
73 | ||
74 | //======================================================================= | |
75 | //function : HasGraph | |
76 | //purpose : | |
77 | //======================================================================= | |
78 | ||
79 | Standard_Boolean Transfer_TransientProcess::HasGraph () const | |
80 | { | |
81 | return !thegraph.IsNull(); | |
82 | } | |
83 | ||
84 | ||
85 | //======================================================================= | |
86 | //function : HGraph | |
87 | //purpose : | |
88 | //======================================================================= | |
89 | ||
90 | Handle(Interface_HGraph) Transfer_TransientProcess::HGraph () const | |
91 | { | |
92 | return thegraph; | |
93 | } | |
94 | ||
95 | ||
96 | //======================================================================= | |
97 | //function : Graph | |
98 | //purpose : | |
99 | //======================================================================= | |
100 | ||
101 | const Interface_Graph& Transfer_TransientProcess::Graph () const | |
102 | { | |
103 | return thegraph->Graph(); | |
104 | } | |
105 | ||
106 | ||
107 | //======================================================================= | |
108 | //function : SetContext | |
109 | //purpose : | |
110 | //======================================================================= | |
111 | ||
112 | void Transfer_TransientProcess::SetContext(const Standard_CString name, | |
113 | const Handle(Standard_Transient)& ctx) | |
114 | { | |
997e128f | 115 | thectx.Bind(name,ctx); |
7fd59977 | 116 | } |
117 | ||
118 | ||
119 | //======================================================================= | |
120 | //function : GetContext | |
121 | //purpose : | |
122 | //======================================================================= | |
123 | ||
124 | Standard_Boolean Transfer_TransientProcess::GetContext | |
125 | (const Standard_CString name, const Handle(Standard_Type)& type, | |
126 | Handle(Standard_Transient)& ctx) const | |
127 | { | |
997e128f | 128 | if (thectx.IsEmpty()) return Standard_False; |
129 | if (!thectx.Find(name, ctx)) | |
130 | ctx.Nullify(); | |
131 | ||
7fd59977 | 132 | if (ctx.IsNull()) return Standard_False; |
133 | if (type.IsNull()) return Standard_True; | |
134 | if (!ctx->IsKind(type)) ctx.Nullify(); | |
135 | return !ctx.IsNull(); | |
136 | } | |
137 | ||
138 | ||
139 | //======================================================================= | |
140 | //function : Context | |
141 | //purpose : | |
142 | //======================================================================= | |
143 | ||
997e128f | 144 | NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& Transfer_TransientProcess::Context () |
7fd59977 | 145 | { |
146 | return thectx; | |
147 | } | |
148 | ||
149 | ||
150 | //======================================================================= | |
151 | //function : PrintTrace | |
152 | //purpose : | |
153 | //======================================================================= | |
154 | ||
155 | void Transfer_TransientProcess::PrintTrace | |
156 | (const Handle(Standard_Transient)& start, const Handle(Message_Messenger)& S) const | |
157 | { | |
158 | if (!start.IsNull()) { | |
159 | S << "Entity "; | |
160 | if (!themodel.IsNull()) { | |
161 | themodel->Print (start,S,1); | |
162 | // S<<"id "; themodel->Print (start,S); | |
163 | // S<<" Type:"<<themodel->TypeName (start); | |
164 | } | |
165 | else S<<" Type:"<< Interface_InterfaceModel::ClassName(start->DynamicType()->Name()); | |
166 | // << start (handle) ?? | |
167 | } | |
168 | } | |
169 | ||
170 | ||
171 | //======================================================================= | |
172 | //function : CheckNum | |
173 | //purpose : | |
174 | //======================================================================= | |
175 | ||
176 | Standard_Integer Transfer_TransientProcess::CheckNum | |
177 | (const Handle(Standard_Transient)& start) const | |
178 | { | |
179 | return (themodel.IsNull() ? 0 : themodel->Number(start)); | |
180 | } | |
181 | ||
182 | ||
183 | //======================================================================= | |
184 | //function : TypedSharings | |
185 | //purpose : | |
186 | //======================================================================= | |
187 | ||
188 | Interface_EntityIterator Transfer_TransientProcess::TypedSharings | |
189 | (const Handle(Standard_Transient)& start, | |
190 | const Handle(Standard_Type)& type) const | |
191 | { | |
192 | Interface_EntityIterator iter; | |
193 | if (thegraph.IsNull()) return iter; | |
194 | return thegraph->Graph().TypedSharings (start,type); | |
195 | } | |
196 | ||
197 | ||
198 | //======================================================================= | |
199 | //function : IsDataLoaded | |
200 | //purpose : | |
201 | //======================================================================= | |
202 | ||
203 | Standard_Boolean Transfer_TransientProcess::IsDataLoaded | |
204 | (const Handle(Standard_Transient)& start) const | |
205 | { | |
206 | if (themodel.IsNull()) return Standard_True; | |
207 | Standard_Integer num = themodel->Number(start); | |
208 | if (num == 0) return Standard_True; | |
209 | if (themodel->IsUnknownEntity(num)) return Standard_False; | |
210 | return !themodel->IsRedefinedContent(num); | |
211 | } | |
212 | ||
213 | ||
214 | //======================================================================= | |
215 | //function : IsDataFail | |
216 | //purpose : | |
217 | //======================================================================= | |
218 | ||
219 | Standard_Boolean Transfer_TransientProcess::IsDataFail | |
220 | (const Handle(Standard_Transient)& start) const | |
221 | { | |
222 | if (themodel.IsNull()) return Standard_False; | |
223 | Standard_Integer num = themodel->Number(start); | |
224 | if (num == 0) return Standard_False; | |
225 | if (themodel->IsErrorEntity(num)) return Standard_True; | |
226 | const Handle(Interface_Check) ach = themodel->Check(num,Standard_False); // semantic | |
227 | return ach->HasFailed(); | |
228 | } | |
229 | ||
230 | ||
231 | //======================================================================= | |
232 | //function : PrintStats | |
233 | //purpose : | |
234 | //======================================================================= | |
235 | ||
236 | void Transfer_TransientProcess::PrintStats(const Standard_Integer /*mode*/, | |
237 | const Handle(Message_Messenger)& S) const | |
238 | { | |
239 | S<<"\n*******************************************************************\n"; | |
240 | // if (mode == 1) { // Statistiques de base | |
241 | S << "******** Basic Statistics ********"<<endl; | |
242 | ||
243 | Handle(Interface_InterfaceModel) model = Model(); | |
244 | if (model.IsNull()) S<<"**** Model unknown"<<endl; | |
245 | else | |
246 | S<<"**** Nb Entities : "<<model->NbEntities()<<endl; | |
247 | ||
248 | Standard_Integer nbr = 0, nbe = 0, nbw = 0; | |
249 | Standard_Integer i, max = NbMapped(), nbroots = NbRoots(); | |
250 | S << "**** Nb Final Results : "<<nbroots<<endl; | |
251 | ||
252 | for (i = 1; i <= max; i ++) { | |
253 | const Handle(Transfer_Binder)& binder = MapItem(i); | |
254 | if (binder.IsNull()) continue; | |
255 | const Handle(Interface_Check) ach = binder->Check(); | |
256 | Transfer_StatusExec stat = binder->StatusExec(); | |
257 | if (stat != Transfer_StatusInitial && stat != Transfer_StatusDone) | |
258 | nbe ++; | |
259 | else { | |
260 | if (ach->NbWarnings() > 0) nbw ++; | |
261 | if (binder->HasResult()) nbr ++; | |
262 | } | |
263 | } | |
264 | if (nbr > nbroots) | |
265 | S<<"**** ( Itermediate Results : "<<nbr-nbroots<<" )\n"; | |
266 | if (nbe > 0) | |
267 | S<<"**** Errors on : "<<Interface_MSG::Blanks(nbe,4)<<nbe<<" Entities\n"; | |
268 | if (nbw > 0) | |
269 | S<<"**** Warnings on : "<<Interface_MSG::Blanks(nbw,4)<<nbw<<" Entities\n"; | |
270 | S<<"*******************************************************************"; | |
271 | // } | |
272 | S<<endl; | |
273 | } | |
274 | ||
275 | ||
276 | //======================================================================= | |
277 | //function : RootsForTransfer | |
278 | //purpose : | |
279 | //======================================================================= | |
280 | ||
281 | Handle(TColStd_HSequenceOfTransient) Transfer_TransientProcess::RootsForTransfer() | |
282 | { | |
283 | return thetrroots; | |
284 | } |