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 | |
7fd59977 | 14 | //#1 svv 10.01.00 : porting on DEC |
15 | //smh#14 17.03.2000 : FRA62479 Clearing of gtool | |
7fd59977 | 16 | |
42cf5bc1 | 17 | #include <Dico_DictionaryOfTransient.hxx> |
7fd59977 | 18 | #include <Dico_IteratorOfDictionaryOfInteger.hxx> |
42cf5bc1 | 19 | #include <Dico_IteratorOfDictionaryOfTransient.hxx> |
20 | #include <IFGraph_SubPartsIterator.hxx> | |
21 | #include <IFSelect_CheckCounter.hxx> | |
22 | #include <IFSelect_Dispatch.hxx> | |
23 | #include <IFSelect_DispGlobal.hxx> | |
24 | #include <IFSelect_DispPerCount.hxx> | |
25 | #include <IFSelect_DispPerOne.hxx> | |
26 | #include <IFSelect_EditForm.hxx> | |
27 | #include <IFSelect_Editor.hxx> | |
28 | #include <IFSelect_GeneralModifier.hxx> | |
29 | #include <IFSelect_IntParam.hxx> | |
30 | #include <IFSelect_ModelCopier.hxx> | |
31 | #include <IFSelect_Modifier.hxx> | |
32 | #include <IFSelect_PacketList.hxx> | |
33 | #include <IFSelect_ParamEditor.hxx> | |
34 | #include <IFSelect_SelectCombine.hxx> | |
35 | #include <IFSelect_SelectControl.hxx> | |
7fd59977 | 36 | #include <IFSelect_SelectDeduct.hxx> |
42cf5bc1 | 37 | #include <IFSelect_SelectDiff.hxx> |
38 | #include <IFSelect_SelectEntityNumber.hxx> | |
7fd59977 | 39 | #include <IFSelect_SelectExtract.hxx> |
42cf5bc1 | 40 | #include <IFSelect_SelectIntersection.hxx> |
41 | #include <IFSelect_Selection.hxx> | |
42 | #include <IFSelect_SelectionIterator.hxx> | |
7fd59977 | 43 | #include <IFSelect_SelectModelEntities.hxx> |
42cf5bc1 | 44 | #include <IFSelect_SelectModelRoots.hxx> |
7fd59977 | 45 | #include <IFSelect_SelectPointed.hxx> |
7fd59977 | 46 | #include <IFSelect_SelectSignature.hxx> |
42cf5bc1 | 47 | #include <IFSelect_SelectUnion.hxx> |
48 | #include <IFSelect_ShareOut.hxx> | |
49 | #include <IFSelect_ShareOutResult.hxx> | |
50 | #include <IFSelect_Signature.hxx> | |
51 | #include <IFSelect_SignatureList.hxx> | |
52 | #include <IFSelect_SignCounter.hxx> | |
53 | #include <IFSelect_SignValidity.hxx> | |
54 | #include <IFSelect_Transformer.hxx> | |
7fd59977 | 55 | #include <IFSelect_TransformStandard.hxx> |
42cf5bc1 | 56 | #include <IFSelect_WorkLibrary.hxx> |
57 | #include <IFSelect_WorkSession.hxx> | |
58 | #include <Interface_Category.hxx> | |
59 | #include <Interface_Check.hxx> | |
60 | #include <Interface_CheckIterator.hxx> | |
61 | #include <Interface_CheckTool.hxx> | |
62 | #include <Interface_CopyControl.hxx> | |
63 | #include <Interface_CopyTool.hxx> | |
64 | #include <Interface_EntityIterator.hxx> | |
65 | #include <Interface_GeneralLib.hxx> | |
66 | #include <Interface_GeneralModule.hxx> | |
67 | #include <Interface_Graph.hxx> | |
68 | #include <Interface_GTool.hxx> | |
69 | #include <Interface_HGraph.hxx> | |
70 | #include <Interface_InterfaceModel.hxx> | |
7fd59977 | 71 | #include <Interface_Macros.hxx> |
72 | #include <Interface_MSG.hxx> | |
42cf5bc1 | 73 | #include <Interface_Protocol.hxx> |
74 | #include <Interface_ReportEntity.hxx> | |
75 | #include <Interface_ShareFlags.hxx> | |
76 | #include <Interface_ShareTool.hxx> | |
77 | #include <Interface_Static.hxx> | |
7fd59977 | 78 | #include <Message.hxx> |
42cf5bc1 | 79 | #include <Message_Messenger.hxx> |
80 | #include <OSD_Path.hxx> | |
81 | #include <Standard_DomainError.hxx> | |
82 | #include <Standard_ErrorHandler.hxx> | |
7fd59977 | 83 | #include <Standard_Failure.hxx> |
42cf5bc1 | 84 | #include <Standard_Transient.hxx> |
85 | #include <Standard_Type.hxx> | |
86 | #include <TCollection_AsciiString.hxx> | |
ec357c5c | 87 | #include <TCollection_HAsciiString.hxx> |
42cf5bc1 | 88 | #include <TColStd_MapOfInteger.hxx> |
7fd59977 | 89 | |
92efcf78 | 90 | IMPLEMENT_STANDARD_RTTIEXT(IFSelect_WorkSession,MMgt_TShared) |
91 | ||
7fd59977 | 92 | #define Flag_Incorrect 2 |
93 | // (Bit Map n0 2) | |
94 | ||
95 | ||
96 | static Standard_Boolean errhand; // pb : un seul a la fois, mais ca va si vite | |
97 | static TCollection_AsciiString bufstr; | |
98 | ||
99 | ||
100 | // ################################################################# | |
101 | ||
102 | ||
103 | //======================================================================= | |
104 | //function : | |
105 | //purpose : | |
106 | //======================================================================= | |
107 | ||
108 | IFSelect_WorkSession::IFSelect_WorkSession () | |
109 | { | |
110 | theshareout = new IFSelect_ShareOut; | |
111 | theerrhand = errhand = Standard_True; | |
112 | thenames = new Dico_DictionaryOfTransient; | |
113 | thecopier = new IFSelect_ModelCopier; | |
114 | thecopier->SetShareOut (theshareout); | |
115 | thecheckdone = Standard_False; | |
116 | thegtool = new Interface_GTool; | |
bc650d41 | 117 | themodelstat = Standard_False; |
7fd59977 | 118 | } |
119 | ||
7fd59977 | 120 | //======================================================================= |
121 | //function : | |
122 | //purpose : | |
123 | //======================================================================= | |
124 | ||
7f56eba8 | 125 | void IFSelect_WorkSession::SetErrorHandle (const Standard_Boolean toHandle) |
7fd59977 | 126 | { |
7f56eba8 | 127 | theerrhand = errhand = toHandle; |
7fd59977 | 128 | } |
7f56eba8 | 129 | |
7fd59977 | 130 | |
131 | //======================================================================= | |
132 | //function : | |
133 | //purpose : | |
134 | //======================================================================= | |
135 | ||
136 | void IFSelect_WorkSession::SetProtocol | |
137 | (const Handle(Interface_Protocol)& protocol) | |
138 | { | |
139 | theprotocol = protocol; | |
140 | Interface_Protocol::SetActive(protocol); | |
141 | thegtool->SetProtocol (protocol); | |
142 | } | |
143 | ||
144 | ||
145 | //======================================================================= | |
146 | //function : | |
147 | //purpose : | |
148 | //======================================================================= | |
149 | ||
7f56eba8 | 150 | void IFSelect_WorkSession::SetSignType (const Handle(IFSelect_Signature)& signtype) |
7fd59977 | 151 | { |
152 | thegtool->SetSignType (signtype); | |
153 | if (signtype.IsNull()) thenames->RemoveItem ("xst-sign-type"); | |
154 | else thenames->SetItem ("xst-sign-type",signtype); | |
155 | } | |
156 | ||
157 | ||
158 | //======================================================================= | |
159 | //function : | |
160 | //purpose : | |
161 | //======================================================================= | |
162 | ||
163 | Handle(IFSelect_Signature) IFSelect_WorkSession::SignType () const | |
164 | { | |
165 | return Handle(IFSelect_Signature)::DownCast (thegtool->SignType()); | |
166 | } | |
167 | ||
168 | ||
169 | //======================================================================= | |
170 | //function : | |
171 | //purpose : | |
172 | //======================================================================= | |
173 | ||
174 | void IFSelect_WorkSession::SetShareOut | |
175 | (const Handle(IFSelect_ShareOut)& shareout) | |
176 | { | |
177 | theshareout = shareout; | |
178 | thecopier->SetShareOut (theshareout); | |
179 | // ... faudrait ajouter les Params, Dispatches, etc... | |
180 | } | |
181 | ||
182 | ||
7fd59977 | 183 | //======================================================================= |
184 | //function : | |
185 | //purpose : | |
186 | //======================================================================= | |
187 | ||
188 | void IFSelect_WorkSession::SetModel | |
189 | (const Handle(Interface_InterfaceModel)& model, | |
190 | const Standard_Boolean clearpointed) | |
191 | { | |
7f56eba8 | 192 | if (myModel != model) |
7fd59977 | 193 | theloaded.Clear(); |
7f56eba8 | 194 | myModel = model; |
7fd59977 | 195 | if (!thegtool.IsNull()) thegtool->ClearEntities(); //smh#14 FRA62479 |
7f56eba8 | 196 | myModel->SetGTool (thegtool); |
bc650d41 | 197 | |
7fd59977 | 198 | thegraph.Nullify(); |
199 | ComputeGraph(); // fait qqchose si Protocol present. Sinon, ne fait rien | |
200 | ClearData(3); // RAZ CheckList, a refaire | |
201 | thecheckrun.Clear(); | |
202 | ||
203 | // MISE A JOUR des SelectPointed C-A-D on efface leur contenu | |
204 | if (clearpointed) ClearData(4); | |
205 | ClearData(0); | |
206 | } | |
207 | ||
208 | ||
7fd59977 | 209 | //======================================================================= |
210 | //function : | |
211 | //purpose : | |
212 | //======================================================================= | |
213 | ||
214 | IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile | |
215 | (const Standard_CString filename) | |
216 | { | |
217 | if (thelibrary.IsNull()) return IFSelect_RetVoid; | |
218 | if (theprotocol.IsNull()) return IFSelect_RetVoid; | |
219 | Handle(Interface_InterfaceModel) model; | |
220 | IFSelect_ReturnStatus status = IFSelect_RetVoid; | |
221 | try { | |
222 | OCC_CATCH_SIGNALS | |
223 | Standard_Integer stat = thelibrary->ReadFile (filename,model,theprotocol); | |
224 | if (stat == 0) status = IFSelect_RetDone; | |
225 | else if (stat < 0) status = IFSelect_RetError; | |
226 | else status = IFSelect_RetFail; | |
227 | } | |
228 | catch(Standard_Failure) { | |
229 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
230 | sout<<" **** Interruption ReadFile par Exception : ****\n"; | |
231 | sout << Standard_Failure::Caught()->GetMessageString(); | |
232 | sout<<"\n Abandon"<<endl; | |
233 | status = IFSelect_RetFail; | |
234 | } | |
235 | if (status != IFSelect_RetDone) return status; | |
236 | if (model.IsNull()) return IFSelect_RetVoid; | |
237 | SetModel (model); | |
238 | SetLoadedFile (filename); | |
239 | return status; | |
240 | } | |
241 | ||
242 | ||
243 | //======================================================================= | |
244 | //function : | |
245 | //purpose : | |
246 | //======================================================================= | |
247 | ||
248 | Standard_Integer IFSelect_WorkSession::NbStartingEntities () const | |
249 | { | |
7f56eba8 | 250 | return (myModel.IsNull()? 0 : myModel->NbEntities()); |
7fd59977 | 251 | } |
252 | ||
253 | ||
254 | //======================================================================= | |
255 | //function : | |
256 | //purpose : | |
257 | //======================================================================= | |
258 | ||
7f56eba8 | 259 | Handle(Standard_Transient) IFSelect_WorkSession::StartingEntity (const Standard_Integer num) const |
7fd59977 | 260 | { |
261 | Handle(Standard_Transient) res; // Null par defaut | |
7f56eba8 | 262 | if (myModel.IsNull()) return res; |
263 | if (num < 1 || num > myModel->NbEntities()) return res; | |
264 | return myModel->Value(num); | |
7fd59977 | 265 | } |
266 | ||
267 | ||
268 | //======================================================================= | |
269 | //function : | |
270 | //purpose : | |
271 | //======================================================================= | |
272 | ||
7f56eba8 | 273 | Standard_Integer IFSelect_WorkSession::StartingNumber (const Handle(Standard_Transient)& ent) const |
7fd59977 | 274 | { |
7f56eba8 | 275 | return (myModel.IsNull()? 0 : myModel->Number(ent)); |
7fd59977 | 276 | } |
277 | ||
278 | ||
279 | //======================================================================= | |
280 | //function : | |
281 | //purpose : | |
282 | //======================================================================= | |
283 | ||
284 | Standard_Integer IFSelect_WorkSession::NumberFromLabel | |
285 | (const Standard_CString val, const Standard_Integer afternum) const | |
286 | { | |
287 | Standard_Integer i, cnt = 0, num = atoi(val); | |
7f56eba8 | 288 | if (num > 0 || myModel.IsNull()) return num; // un n0 direct : gagne ! |
7fd59977 | 289 | // Sinon, on considere que c est un label; a traiter en CaseNonSensitive ... |
7f56eba8 | 290 | if (num > myModel->NbEntities()) { num = 0; return num; } |
7fd59977 | 291 | Standard_Boolean exact = Standard_False; |
292 | Standard_Integer after = (afternum >= 0 ? afternum : -afternum); | |
7f56eba8 | 293 | for (i = myModel->NextNumberForLabel (val, after, exact) ; i != 0; |
294 | i = myModel->NextNumberForLabel (val, i, exact)) { | |
7fd59977 | 295 | cnt ++; |
296 | if (num <= 0) num = i; | |
297 | } | |
298 | if (cnt == 1) return num; | |
299 | num = -num; | |
bc650d41 | 300 | |
7fd59977 | 301 | return num; |
302 | } | |
303 | ||
304 | ||
305 | //======================================================================= | |
306 | //function : | |
307 | //purpose : | |
308 | //======================================================================= | |
309 | ||
7f56eba8 | 310 | Handle(TCollection_HAsciiString) IFSelect_WorkSession::EntityLabel (const Handle(Standard_Transient)& ent) const |
7fd59977 | 311 | { |
7f56eba8 | 312 | if (myModel.IsNull() || ent.IsNull()) return 0; |
313 | if (!myModel->Contains(ent)) return 0; | |
314 | return myModel->StringLabel(ent); | |
7fd59977 | 315 | } |
316 | ||
317 | ||
318 | //======================================================================= | |
319 | //function : | |
320 | //purpose : | |
321 | //======================================================================= | |
322 | ||
7f56eba8 | 323 | Handle(TCollection_HAsciiString) IFSelect_WorkSession::EntityName (const Handle(Standard_Transient)& ent) const |
7fd59977 | 324 | { |
7f56eba8 | 325 | if (myModel.IsNull() || ent.IsNull()) return 0; |
7fd59977 | 326 | Interface_ShareTool sht(thegraph->Graph()); |
327 | ||
328 | Standard_Integer CN; | |
329 | Handle(Interface_GeneralModule) module; | |
330 | if (!thegtool->Select (ent,module,CN)) return 0; | |
331 | return module->Name (CN,ent,sht); | |
332 | } | |
333 | ||
334 | ||
335 | //======================================================================= | |
336 | //function : | |
337 | //purpose : | |
338 | //======================================================================= | |
339 | ||
7f56eba8 | 340 | Standard_Integer IFSelect_WorkSession::CategoryNumber (const Handle(Standard_Transient)& ent) const |
7fd59977 | 341 | { |
7f56eba8 | 342 | return (myModel.IsNull()? -1 : myModel->CategoryNumber(StartingNumber(ent))); |
7fd59977 | 343 | } |
344 | ||
345 | ||
346 | //======================================================================= | |
347 | //function : | |
348 | //purpose : | |
349 | //======================================================================= | |
350 | ||
7f56eba8 | 351 | Standard_CString IFSelect_WorkSession::CategoryName (const Handle(Standard_Transient)& ent) const |
7fd59977 | 352 | { |
7f56eba8 | 353 | return Interface_Category::Name (CategoryNumber (ent)); |
7fd59977 | 354 | } |
355 | ||
356 | ||
357 | //======================================================================= | |
358 | //function : | |
359 | //purpose : | |
360 | //======================================================================= | |
361 | ||
7f56eba8 | 362 | Standard_CString IFSelect_WorkSession::ValidityName (const Handle(Standard_Transient)& ent) const |
7fd59977 | 363 | { |
7f56eba8 | 364 | return ((StartingNumber(ent) == 0)? "" : IFSelect_SignValidity::CVal (ent,myModel)); |
7fd59977 | 365 | } |
366 | ||
367 | ||
368 | //======================================================================= | |
369 | //function : | |
370 | //purpose : | |
371 | //======================================================================= | |
372 | ||
373 | void IFSelect_WorkSession::ClearData (const Standard_Integer mode) | |
374 | { | |
375 | switch (mode) { | |
376 | case 1 : { | |
377 | theloaded.Clear(); | |
7f56eba8 | 378 | if (!myModel.IsNull()) { |
379 | myModel->Clear(); | |
380 | myModel.Nullify(); | |
381 | } | |
7fd59977 | 382 | ClearData(2); ClearData(4); |
383 | thecheckrun.Clear(); | |
384 | break; | |
385 | } | |
386 | case 2 : { thegraph.Nullify(); thecheckdone = Standard_False; thecheckana.Clear(); break; } | |
387 | case 3 : { thecheckdone = Standard_False; break; } | |
388 | case 4 : { | |
389 | // MISE A JOUR des SelectPointed C-A-D on efface leur contenu | |
390 | // AINSI que des editeurs (en fait, les EditForm) | |
391 | // Des compteurs C-A-D on efface leur contenu (a reevaluer) | |
392 | Handle(TColStd_HSequenceOfInteger) list = | |
393 | ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed)); | |
394 | Standard_Integer nb = list->Length(); | |
395 | Standard_Integer i; // svv #1 | |
396 | for (i = 1; i <= nb; i ++) { | |
397 | DeclareAndCast(IFSelect_SelectPointed,sp,Item(list->Value(i))); | |
398 | if (!sp.IsNull()) sp->Clear(); | |
399 | } | |
400 | list = ItemIdents(STANDARD_TYPE(IFSelect_SignatureList)); | |
401 | nb = list->Length(); | |
402 | for (i = 1; i <= nb; i ++) { | |
403 | DeclareAndCast(IFSelect_SignatureList,sl,Item(list->Value(i))); | |
404 | if (!sl.IsNull()) sl->Clear(); | |
405 | DeclareAndCast(IFSelect_SignCounter,sc,sl); | |
406 | if (!sc.IsNull()) sc->SetSelMode(-1); | |
407 | } | |
408 | list = ItemIdents(STANDARD_TYPE(IFSelect_EditForm)); | |
409 | nb = list->Length(); | |
410 | Handle(Standard_Transient) nulent; | |
411 | for (i = 1; i <= nb; i ++) { | |
412 | DeclareAndCast(IFSelect_EditForm,edf,Item(list->Value(i))); | |
413 | edf->ClearData (); | |
414 | } | |
415 | theitems.Clear(); | |
416 | break; | |
417 | } | |
418 | default : break; | |
419 | } | |
420 | } | |
421 | ||
422 | ||
423 | //======================================================================= | |
424 | //function : | |
425 | //purpose : | |
426 | //======================================================================= | |
427 | ||
428 | Standard_Boolean IFSelect_WorkSession::ComputeGraph | |
429 | (const Standard_Boolean enforce) | |
430 | { | |
431 | if (theprotocol.IsNull()) return Standard_False; | |
7f56eba8 | 432 | if (myModel.IsNull()) return Standard_False; |
7fd59977 | 433 | if (enforce) thegraph.Nullify(); |
434 | if (!thegraph.IsNull()) { | |
7f56eba8 | 435 | if (myModel->NbEntities() == thegraph->Graph().Size()) return Standard_True; |
7fd59977 | 436 | thegraph.Nullify(); |
437 | } | |
7f56eba8 | 438 | if (myModel->NbEntities() == 0) return Standard_False; |
7fd59977 | 439 | // Il faut calculer le graphe pour de bon |
7f56eba8 | 440 | thegraph = new Interface_HGraph (myModel,themodelstat); |
441 | Standard_Integer nb = myModel->NbEntities(); | |
bc650d41 G |
442 | if(themodelstat) |
443 | { | |
444 | Standard_Integer i; // svv #1 | |
445 | for (i = 1; i <= nb; i ++) thegraph->CGraph().SetStatus(i,0); | |
446 | Interface_BitMap& bm = thegraph->CGraph().CBitMap(); | |
447 | bm.AddFlag(); | |
448 | bm.SetFlagName (Flag_Incorrect,"Incorrect"); | |
449 | } | |
7fd59977 | 450 | ComputeCheck(); |
451 | thecheckdone = Standard_True; | |
bc650d41 G |
452 | if(themodelstat) |
453 | { | |
454 | // Calcul des categories, a present memorisees dans le modele | |
455 | Interface_Category categ(thegtool); | |
456 | Interface_ShareTool sht(thegraph); | |
457 | Standard_Integer i =1; | |
7f56eba8 | 458 | for ( ; i <= nb; i ++) |
459 | myModel->SetCategoryNumber(i,categ.CatNum(myModel->Value(i),sht)); | |
bc650d41 | 460 | } |
7fd59977 | 461 | |
462 | return Standard_True; | |
463 | } | |
464 | ||
465 | ||
466 | //======================================================================= | |
467 | //function : | |
468 | //purpose : | |
469 | //======================================================================= | |
470 | ||
471 | Handle(Interface_HGraph) IFSelect_WorkSession::HGraph () | |
472 | { | |
473 | ComputeGraph(); | |
474 | return thegraph; | |
475 | } | |
476 | ||
477 | ||
478 | //======================================================================= | |
479 | //function : | |
480 | //purpose : | |
481 | //======================================================================= | |
482 | ||
483 | const Interface_Graph& IFSelect_WorkSession::Graph () | |
484 | { | |
485 | ComputeGraph(); | |
486 | if (thegraph.IsNull()) Standard_DomainError::Raise | |
487 | ("IFSelect WorkSession : Graph not available"); | |
488 | return thegraph->Graph(); | |
489 | } | |
490 | ||
491 | ||
492 | //======================================================================= | |
493 | //function : | |
494 | //purpose : | |
495 | //======================================================================= | |
496 | ||
497 | Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::Shareds | |
498 | (const Handle(Standard_Transient)& ent) | |
499 | { | |
500 | Handle(TColStd_HSequenceOfTransient) list; | |
501 | if (!ComputeGraph()) return list; | |
502 | if (StartingNumber(ent) == 0) return list; | |
503 | return thegraph->Graph().Shareds(ent).Content(); | |
504 | } | |
505 | ||
506 | ||
507 | //======================================================================= | |
508 | //function : | |
509 | //purpose : | |
510 | //======================================================================= | |
511 | ||
512 | Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::Sharings | |
513 | (const Handle(Standard_Transient)& ent) | |
514 | { | |
515 | Handle(TColStd_HSequenceOfTransient) list; | |
516 | if (!ComputeGraph()) return list; | |
517 | if (StartingNumber(ent) == 0) return list; | |
518 | return thegraph->Graph().Sharings(ent).Content(); | |
519 | } | |
520 | ||
521 | ||
522 | //======================================================================= | |
523 | //function : | |
524 | //purpose : | |
525 | //======================================================================= | |
526 | ||
527 | Standard_Boolean IFSelect_WorkSession::IsLoaded () const | |
528 | { | |
529 | if (theprotocol.IsNull()) return Standard_False; | |
7f56eba8 | 530 | if (myModel.IsNull()) return Standard_False; |
531 | if (myModel->NbEntities() == 0) return Standard_False; | |
7fd59977 | 532 | if (thegraph.IsNull()) return Standard_False; |
7f56eba8 | 533 | if (myModel->NbEntities() == thegraph->Graph().Size()) return Standard_True; |
7fd59977 | 534 | return Standard_False; |
535 | } | |
536 | ||
537 | ||
538 | //======================================================================= | |
539 | //function : | |
540 | //purpose : | |
541 | //======================================================================= | |
542 | ||
543 | Standard_Boolean IFSelect_WorkSession::ComputeCheck | |
544 | (const Standard_Boolean enforce) | |
545 | { | |
546 | if (enforce) thecheckdone = Standard_False; | |
547 | if (thecheckdone) return Standard_True; | |
548 | if (!IsLoaded()) return Standard_False; | |
549 | ||
550 | Interface_Graph& CG = thegraph->CGraph(); | |
551 | Interface_CheckTool cht(thegraph); | |
552 | Interface_CheckIterator checklist = cht.VerifyCheckList(); | |
7f56eba8 | 553 | myModel->FillSemanticChecks(checklist,Standard_False); |
bc650d41 G |
554 | if(themodelstat) |
555 | { | |
556 | // Et on met a jour le Graphe (BitMap) ! Flag Incorrect (STX + SEM) | |
557 | Interface_BitMap& BM = CG.CBitMap(); | |
558 | BM.Init (Standard_False,Flag_Incorrect); | |
559 | Standard_Integer num, nb = CG.Size(); | |
560 | for (checklist.Start(); checklist.More(); checklist.Next()) { | |
561 | const Handle(Interface_Check) chk = checklist.Value(); | |
562 | if (!chk->HasFailed()) continue; | |
563 | num = checklist.Number(); | |
564 | if (num > 0 && num <= nb) BM.SetTrue (num,Flag_Incorrect); | |
565 | } | |
566 | for (num = 1; num <= nb; num ++) | |
7f56eba8 | 567 | if (myModel->IsErrorEntity (num)) BM.SetTrue (num,Flag_Incorrect); |
7fd59977 | 568 | } |
7fd59977 | 569 | return Standard_True; |
570 | } | |
571 | ||
572 | ||
573 | //======================================================================= | |
574 | //function : | |
575 | //purpose : | |
576 | //======================================================================= | |
577 | ||
578 | Interface_CheckIterator IFSelect_WorkSession::ModelCheckList | |
579 | (const Standard_Boolean complete) | |
580 | { | |
581 | Interface_CheckIterator checks; | |
582 | if (!IsLoaded()) { | |
583 | checks.CCheck(0)->AddFail("DATA NOT AVAILABLE FOR CHECK"); | |
584 | return checks; | |
585 | } | |
586 | Interface_CheckTool cht(Graph()); | |
587 | checks = (complete ? cht.CompleteCheckList() : cht.AnalyseCheckList()); | |
588 | checks.SetName | |
589 | ((char*)(complete ? "Model Complete Check List" : "Model Syntactic Check List")); | |
590 | return checks; | |
591 | } | |
592 | ||
593 | ||
594 | //======================================================================= | |
595 | //function : | |
596 | //purpose : | |
597 | //======================================================================= | |
598 | ||
599 | Interface_CheckIterator IFSelect_WorkSession::CheckOne | |
600 | (const Handle(Standard_Transient)& ent, | |
601 | const Standard_Boolean complete) | |
602 | { | |
603 | Interface_CheckIterator checks; | |
7f56eba8 | 604 | checks.SetModel(myModel); |
7fd59977 | 605 | if (!IsLoaded()) { |
606 | checks.CCheck(0)->AddFail("DATA NOT AVAILABLE FOR CHECK"); | |
607 | return checks; | |
608 | } | |
609 | Standard_Integer num = -1; | |
7f56eba8 | 610 | if (ent.IsNull() || ent == myModel) num = 0; |
611 | else num = myModel->Number(ent); | |
7fd59977 | 612 | |
7f56eba8 | 613 | Handle(Interface_Check) ach = myModel->Check (num,Standard_True); |
614 | if (complete) ach->GetMessages (myModel->Check (num,Standard_False)); | |
7fd59977 | 615 | if (num > 0) ach->SetEntity(ent); |
616 | checks.Add (ach,num); | |
617 | checks.SetName ("Data Check (One Entity)"); | |
618 | return checks; | |
619 | } | |
620 | ||
621 | ||
7fd59977 | 622 | // ##################################################################### |
623 | // .... LES VARIABLES .... | |
624 | ||
625 | //======================================================================= | |
626 | //function : | |
627 | //purpose : | |
628 | //======================================================================= | |
629 | ||
630 | Standard_Integer IFSelect_WorkSession::MaxIdent () const | |
631 | { | |
632 | return theitems.Extent(); | |
633 | } | |
634 | ||
635 | ||
636 | //======================================================================= | |
637 | //function : | |
638 | //purpose : | |
639 | //======================================================================= | |
640 | ||
641 | Handle(Standard_Transient) IFSelect_WorkSession::Item | |
642 | (const Standard_Integer id) const | |
643 | { | |
644 | Handle(Standard_Transient) res; | |
645 | if (id <= 0 || id > MaxIdent()) return res; | |
646 | if (theitems.FindFromIndex(id).IsNull()) return res; | |
647 | return theitems.FindKey(id); | |
648 | } | |
649 | ||
650 | ||
651 | //======================================================================= | |
652 | //function : | |
653 | //purpose : | |
654 | //======================================================================= | |
655 | ||
656 | Standard_Integer IFSelect_WorkSession::ItemIdent | |
657 | (const Handle(Standard_Transient)& item) const | |
658 | { | |
659 | if (item.IsNull()) return 0; | |
660 | Standard_Integer id = theitems.FindIndex(item); | |
661 | if (id == 0) return 0; | |
662 | if (theitems.FindFromIndex(id).IsNull()) return 0; | |
663 | return id; | |
664 | } | |
665 | ||
666 | ||
667 | //======================================================================= | |
668 | //function : | |
669 | //purpose : | |
670 | //======================================================================= | |
671 | ||
672 | Handle(Standard_Transient) IFSelect_WorkSession::NamedItem | |
673 | (const Standard_CString name) const | |
674 | { | |
675 | Handle(Standard_Transient) res; | |
676 | if (name[0] == '\0') return res; | |
677 | if (name[0] == '#') { // #nnn : pas un nom mais un n0 id. | |
678 | Standard_Integer id = atoi( &name[1] ); | |
679 | return Item(id); | |
680 | } | |
681 | if (!thenames->GetItem(name,res)) res.Nullify(); | |
682 | return res; | |
683 | } | |
684 | ||
685 | ||
686 | //======================================================================= | |
687 | //function : | |
688 | //purpose : | |
689 | //======================================================================= | |
690 | ||
691 | Handle(Standard_Transient) IFSelect_WorkSession::NamedItem | |
692 | (const Handle(TCollection_HAsciiString)& name) const | |
693 | { | |
694 | Handle(Standard_Transient) res; | |
695 | if (!name.IsNull()) res = NamedItem (name->ToCString()); | |
696 | return res; | |
697 | } | |
698 | ||
699 | ||
700 | //======================================================================= | |
701 | //function : | |
702 | //purpose : | |
703 | //======================================================================= | |
704 | ||
705 | Standard_Integer IFSelect_WorkSession::NameIdent | |
706 | (const Standard_CString name) const | |
707 | { | |
708 | Handle(Standard_Transient) res; | |
709 | if (name[0] == '\0') return 0; | |
710 | if (name[0] == '#') { // #nnn : pas un nom mais un n0 id. | |
711 | Standard_Integer id = atoi( &name[1] ); | |
712 | return id; | |
713 | } | |
714 | if (!thenames->GetItem(name,res)) return 0; | |
715 | return ItemIdent(res); | |
716 | } | |
717 | ||
718 | ||
719 | //======================================================================= | |
720 | //function : | |
721 | //purpose : | |
722 | //======================================================================= | |
723 | ||
724 | Standard_Boolean IFSelect_WorkSession::HasName | |
725 | (const Handle(Standard_Transient)& item) const | |
726 | { | |
727 | if (item.IsNull()) return Standard_False; | |
728 | Standard_Integer id = theitems.FindIndex(item); | |
729 | if (id == 0) return Standard_False; | |
730 | Handle(Standard_Transient) att = theitems.FindFromIndex(id); | |
731 | if (att.IsNull()) return Standard_False; | |
732 | return att->IsKind(STANDARD_TYPE(TCollection_HAsciiString)); | |
733 | } | |
734 | ||
735 | ||
736 | //======================================================================= | |
737 | //function : | |
738 | //purpose : | |
739 | //======================================================================= | |
740 | ||
741 | Handle(TCollection_HAsciiString) IFSelect_WorkSession::Name | |
742 | (const Handle(Standard_Transient)& item) const | |
743 | { | |
744 | Handle(TCollection_HAsciiString) res; | |
745 | if (item.IsNull()) return res; | |
746 | Standard_Integer id = theitems.FindIndex(item); | |
747 | if (id == 0) return res; // Null | |
748 | Handle(Standard_Transient) att = theitems.FindFromIndex(id); | |
749 | return GetCasted(TCollection_HAsciiString,att); | |
750 | } | |
751 | ||
752 | ||
753 | //======================================================================= | |
754 | //function : | |
755 | //purpose : | |
756 | //======================================================================= | |
757 | ||
758 | Standard_Integer IFSelect_WorkSession::AddItem | |
759 | (const Handle(Standard_Transient)& item, | |
760 | const Standard_Boolean active) | |
761 | { | |
762 | if (item.IsNull()) return 0; | |
763 | Standard_Integer id = theitems.FindIndex(item); | |
764 | if (id > 0) { | |
765 | Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id); | |
766 | if (att.IsNull()) att = item; | |
7fd59977 | 767 | } |
768 | else id = theitems.Add(item,item); | |
769 | ||
770 | // Cas particuliers : Dispatch,Modifier | |
771 | if (active) SetActive(item,Standard_True); | |
772 | return id; | |
773 | } | |
774 | ||
775 | ||
776 | //======================================================================= | |
777 | //function : | |
778 | //purpose : | |
779 | //======================================================================= | |
780 | ||
781 | Standard_Integer IFSelect_WorkSession::AddNamedItem | |
782 | (const Standard_CString name, const Handle(Standard_Transient)& item, | |
783 | const Standard_Boolean active) | |
784 | { | |
785 | if (item.IsNull()) return 0; | |
786 | if (name[0] == '#' || name[0] == '!') return 0; | |
787 | // #nnn : pas un nom mais un numero. !... : reserve (interdit pour un nom) | |
788 | // nom deja pris : on ecrase l ancienne valeur | |
789 | if (name[0] != '\0') { | |
790 | Standard_Boolean deja; | |
791 | Handle(Standard_Transient)& newitem = thenames->NewItem(name,deja); | |
792 | // if (deja & item != newitem) return 0; | |
793 | newitem = item; | |
794 | } | |
795 | Standard_Integer id = theitems.FindIndex(item); | |
796 | if (id > 0) { | |
797 | Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id); | |
798 | if (att.IsNull()) att = item; | |
799 | if (name[0] != '\0') { | |
800 | // if (!att->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) ecrasement admis ! | |
801 | att = new TCollection_HAsciiString(name); | |
802 | } | |
803 | } | |
804 | else if (name[0] != '\0') | |
805 | id = theitems.Add(item,new TCollection_HAsciiString(name)); | |
806 | else id = theitems.Add(item,item); | |
807 | ||
808 | // Cas particuliers : Dispatch,Modifier | |
809 | if (active) SetActive(item,Standard_True); | |
810 | return id; | |
811 | } | |
812 | ||
813 | ||
814 | //======================================================================= | |
815 | //function : | |
816 | //purpose : | |
817 | //======================================================================= | |
818 | ||
819 | Standard_Boolean IFSelect_WorkSession::SetActive | |
820 | (const Handle(Standard_Transient)& item, const Standard_Boolean mode) | |
821 | { | |
822 | if (item->IsKind(STANDARD_TYPE(IFSelect_Dispatch))) { | |
823 | DeclareAndCast(IFSelect_Dispatch,disp,item); | |
824 | Standard_Integer num = theshareout->DispatchRank(disp); | |
825 | if ( num > theshareout->NbDispatches()) return Standard_False; | |
826 | if ( mode) { | |
827 | if (num > 0) return Standard_False; | |
828 | theshareout->AddDispatch (disp); | |
829 | return Standard_True; | |
830 | } else { | |
831 | if (num <= theshareout->LastRun()) return Standard_False; | |
832 | theshareout->RemoveDispatch(num); | |
833 | SetFileRoot(disp,""); // si onlynamed : nettoie aussi ShareOut | |
834 | return Standard_True; | |
835 | } | |
836 | } | |
bc650d41 | 837 | |
7fd59977 | 838 | return Standard_False; |
839 | } | |
840 | ||
841 | ||
842 | //======================================================================= | |
843 | //function : | |
844 | //purpose : | |
845 | //======================================================================= | |
846 | ||
847 | Standard_Boolean IFSelect_WorkSession::RemoveNamedItem | |
848 | (const Standard_CString name) | |
849 | { | |
850 | Handle(Standard_Transient) item = NamedItem(name); | |
851 | if (item.IsNull()) return Standard_False; | |
852 | if (!RemoveItem(item)) return Standard_False; // qui se charge de tout | |
853 | return Standard_True; | |
854 | } | |
855 | ||
856 | ||
857 | //======================================================================= | |
858 | //function : | |
859 | //purpose : | |
860 | //======================================================================= | |
861 | ||
862 | Standard_Boolean IFSelect_WorkSession::RemoveName | |
863 | (const Standard_CString name) | |
864 | { | |
865 | Handle(Standard_Transient) item = NamedItem(name); | |
866 | if (item.IsNull()) return Standard_False; | |
6e6cd5d9 | 867 | theitems.Add(item,item); // reste mais sans nom |
7fd59977 | 868 | return thenames->RemoveItem(name); |
869 | } | |
870 | ||
871 | ||
872 | //======================================================================= | |
873 | //function : | |
874 | //purpose : | |
875 | //======================================================================= | |
876 | ||
877 | Standard_Boolean IFSelect_WorkSession::RemoveItem | |
878 | (const Handle(Standard_Transient)& item) | |
879 | { | |
880 | if (item.IsNull()) return Standard_False; | |
881 | Standard_Integer id = theitems.FindIndex(item); | |
882 | if (id == 0) return Standard_False; | |
883 | Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id); | |
884 | if (att.IsNull()) return Standard_False; // deja annulle | |
885 | ||
886 | // Cas particuliers : Dispatch,Modifier | |
887 | theshareout->RemoveItem(item); | |
888 | ||
889 | // Marquer "Removed" dans la Map (on ne peut pas la vider) | |
890 | if (att->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) { | |
891 | if (!thenames->RemoveItem | |
892 | (GetCasted(TCollection_HAsciiString,att)->ToCString())) | |
893 | return Standard_False; | |
894 | } | |
895 | att.Nullify(); // cf ChangeFromIndex | |
896 | // id = theitems.Add(item,att); | |
897 | return Standard_True; | |
898 | } | |
899 | ||
900 | ||
901 | //======================================================================= | |
902 | //function : | |
903 | //purpose : | |
904 | //======================================================================= | |
905 | ||
906 | void IFSelect_WorkSession::ClearItems () | |
907 | { | |
908 | thenames->Clear(); | |
909 | theitems.Clear(); | |
910 | theshareout->Clear(Standard_False); | |
911 | } | |
912 | ||
913 | ||
914 | //======================================================================= | |
915 | //function : | |
916 | //purpose : | |
917 | //======================================================================= | |
918 | ||
919 | Handle(TCollection_HAsciiString) IFSelect_WorkSession::ItemLabel | |
920 | (const Standard_Integer id) const | |
921 | { | |
922 | Handle(TCollection_HAsciiString) res; | |
923 | Handle(Standard_Transient) var = Item(id); | |
924 | if (var.IsNull()) return res; | |
925 | DeclareAndCast(TCollection_HAsciiString,text,var); | |
926 | if (!text.IsNull()) { | |
927 | res = new TCollection_HAsciiString("Text:"); | |
928 | res->AssignCat(text); | |
929 | return res; | |
930 | } | |
931 | DeclareAndCast(IFSelect_IntParam,intpar,var); | |
932 | if (!intpar.IsNull()) { | |
933 | res = new TCollection_HAsciiString(intpar->Value()); | |
934 | res->Insert(1,"Integer:"); | |
935 | return res; | |
936 | } | |
937 | DeclareAndCast(IFSelect_Selection,sel,var); | |
938 | if (!sel.IsNull()) { | |
939 | res = new TCollection_HAsciiString("Selection:"); | |
940 | res->AssignCat(sel->Label().ToCString()); | |
941 | return res; | |
942 | } | |
943 | DeclareAndCast(IFSelect_GeneralModifier,mod,var); | |
944 | if (!mod.IsNull()) { | |
945 | if (mod->IsKind(STANDARD_TYPE(IFSelect_Modifier))) | |
946 | res = new TCollection_HAsciiString("ModelModifier:"); | |
947 | else res = new TCollection_HAsciiString("FileModifier:"); | |
948 | res->AssignCat(mod->Label().ToCString()); | |
949 | return res; | |
950 | } | |
951 | DeclareAndCast(IFSelect_Dispatch,disp,var); | |
952 | if (!disp.IsNull()) { | |
953 | res = new TCollection_HAsciiString("Dispatch:"); | |
954 | res->AssignCat(disp->Label().ToCString()); | |
955 | return res; | |
956 | } | |
957 | DeclareAndCast(IFSelect_Transformer,tsf,var); | |
958 | if (!tsf.IsNull()) { | |
959 | res = new TCollection_HAsciiString("Transformer:"); | |
960 | res->AssignCat(tsf->Label().ToCString()); | |
961 | return res; | |
962 | } | |
963 | DeclareAndCast(IFSelect_SignatureList,slc,var); | |
964 | if (!slc.IsNull()) { | |
965 | res = new TCollection_HAsciiString("Counter:"); | |
966 | res->AssignCat(slc->Name()); | |
967 | return res; | |
968 | } | |
969 | DeclareAndCast(IFSelect_Signature,sig,var); | |
970 | if (!sig.IsNull()) { | |
971 | res = new TCollection_HAsciiString("Signature:"); | |
972 | res->AssignCat(sig->Name()); | |
973 | return res; | |
974 | } | |
975 | DeclareAndCast(IFSelect_EditForm,edf,var); | |
976 | if (!edf.IsNull()) { | |
977 | res = new TCollection_HAsciiString("EditForm:"); | |
978 | res->AssignCat(edf->Label()); | |
979 | return res; | |
980 | } | |
981 | DeclareAndCast(IFSelect_Editor,edt,var); | |
982 | if (!edt.IsNull()) { | |
983 | res = new TCollection_HAsciiString("Editor:"); | |
984 | res->AssignCat(edt->Label().ToCString()); | |
985 | return res; | |
986 | } | |
987 | res = new TCollection_HAsciiString("VariableType:"); | |
988 | res->AssignCat(var->DynamicType()->Name()); | |
989 | return res; | |
990 | } | |
991 | ||
992 | ||
993 | //======================================================================= | |
994 | //function : | |
995 | //purpose : | |
996 | //======================================================================= | |
997 | ||
998 | Handle(TColStd_HSequenceOfInteger) IFSelect_WorkSession::ItemIdents | |
999 | (const Handle(Standard_Type)& type) const | |
1000 | { | |
1001 | Handle(TColStd_HSequenceOfInteger) list = | |
1002 | new TColStd_HSequenceOfInteger(); | |
1003 | Standard_Integer nb = theitems.Extent(); | |
1004 | for (Standard_Integer i = 1; i <= nb; i ++) { | |
1005 | if (theitems.FindKey(i)->IsKind(type)) list->Append(i); | |
1006 | } | |
1007 | return list; | |
1008 | } | |
1009 | ||
1010 | ||
1011 | //======================================================================= | |
1012 | //function : | |
1013 | //purpose : | |
1014 | //======================================================================= | |
1015 | ||
1016 | Handle(TColStd_HSequenceOfHAsciiString) IFSelect_WorkSession::ItemNames | |
1017 | (const Handle(Standard_Type)& type) const | |
1018 | { | |
1019 | Handle(TColStd_HSequenceOfHAsciiString) list = | |
1020 | new TColStd_HSequenceOfHAsciiString(); | |
1021 | for (Dico_IteratorOfDictionaryOfTransient IT(thenames); IT.More(); IT.Next()){ | |
1022 | if (IT.Value()->IsKind(type)) list->Append | |
1023 | (new TCollection_HAsciiString(IT.Name().ToCString())); | |
1024 | } | |
1025 | return list; | |
1026 | } | |
1027 | ||
1028 | ||
1029 | // .. Recherche par label : recherche en liste(noms) ou iterative | |
1030 | ||
1031 | //======================================================================= | |
1032 | //function : | |
1033 | //purpose : | |
1034 | //======================================================================= | |
1035 | ||
1036 | Handle(TColStd_HSequenceOfHAsciiString) IFSelect_WorkSession::ItemNamesForLabel | |
1037 | (const Standard_CString label) const | |
1038 | { | |
1039 | Handle(TColStd_HSequenceOfHAsciiString) list = | |
1040 | new TColStd_HSequenceOfHAsciiString(); | |
1041 | Standard_Integer i, nb = MaxIdent(); | |
1042 | for (i = 1; i <= nb; i ++) { | |
1043 | Handle(TCollection_HAsciiString) lab = ItemLabel(i); | |
1044 | Handle(Standard_Transient) item = Item(i); | |
1045 | if (lab.IsNull()) continue; | |
1046 | if (label[0] != '\0' && lab->Search(label) <= 0) continue; | |
1047 | ||
1048 | Handle(TCollection_HAsciiString) nom = Name(Item(i)); | |
1049 | if (nom.IsNull()) { nom = new TCollection_HAsciiString(i); nom->Insert(1,'#'); } | |
1050 | else nom = new TCollection_HAsciiString (nom); | |
1051 | list->Append (new TCollection_HAsciiString(lab)); | |
1052 | } | |
1053 | return list; | |
1054 | } | |
1055 | ||
1056 | ||
1057 | //======================================================================= | |
1058 | //function : | |
1059 | //purpose : | |
1060 | //======================================================================= | |
1061 | ||
1062 | Standard_Integer IFSelect_WorkSession::NextIdentForLabel | |
1063 | (const Standard_CString label, const Standard_Integer id, | |
1064 | const Standard_Integer mode) const | |
1065 | { | |
1066 | Standard_Integer nb = MaxIdent(); | |
1067 | for (Standard_Integer i = id+1; i <= nb; i ++) { | |
1068 | Handle(TCollection_HAsciiString) lab = ItemLabel(i); | |
1069 | if (lab.IsNull()) continue; | |
1070 | switch (mode) { | |
1071 | case 0 : if (!strcmp(lab->ToCString(),label)) return i; break; // switch | |
1072 | case 1 : if (lab->Search(label) == 1 ) return i; break; | |
1073 | case 2 : if (lab->Search(label) > 0 ) return i; break; | |
1074 | default : break; // break du switch | |
1075 | } | |
1076 | } | |
1077 | return 0; // ici : pas trouve | |
1078 | } | |
1079 | ||
1080 | ||
1081 | // ################################################################# | |
1082 | // .... Parametres (Int et Text) .... | |
1083 | ||
1084 | //======================================================================= | |
1085 | //function : | |
1086 | //purpose : | |
1087 | //======================================================================= | |
1088 | ||
1089 | Handle(Standard_Transient) IFSelect_WorkSession::NewParamFromStatic | |
1090 | (const Standard_CString statname, const Standard_CString name) | |
1091 | { | |
1092 | Handle(Standard_Transient) param; | |
1093 | Handle(Interface_Static) stat = Interface_Static::Static(statname); | |
1094 | if (stat.IsNull()) return param; | |
1095 | if (stat->Type() == Interface_ParamInteger) { | |
1096 | Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam; | |
1097 | intpar->SetStaticName (statname); | |
1098 | param = intpar; | |
1099 | } else { | |
1100 | param = stat->HStringValue(); | |
1101 | } | |
1102 | if (param.IsNull()) return param; | |
1103 | if ( AddNamedItem (name, param) == 0 ) param.Nullify(); | |
1104 | return param; | |
1105 | } | |
1106 | ||
1107 | ||
1108 | //======================================================================= | |
1109 | //function : | |
1110 | //purpose : | |
1111 | //======================================================================= | |
1112 | ||
1113 | Handle(IFSelect_IntParam) IFSelect_WorkSession::IntParam | |
1114 | (const Standard_Integer id) const | |
1115 | { return Handle(IFSelect_IntParam)::DownCast(Item(id)); } | |
1116 | ||
1117 | ||
1118 | //======================================================================= | |
1119 | //function : | |
1120 | //purpose : | |
1121 | //======================================================================= | |
1122 | ||
1123 | Standard_Integer IFSelect_WorkSession::IntValue | |
1124 | (const Handle(IFSelect_IntParam)& par) const | |
1125 | { | |
1126 | if (!par.IsNull()) return par->Value(); | |
1127 | else return 0; | |
1128 | } | |
1129 | ||
1130 | ||
1131 | //======================================================================= | |
1132 | //function : | |
1133 | //purpose : | |
1134 | //======================================================================= | |
1135 | ||
1136 | Handle(IFSelect_IntParam) IFSelect_WorkSession::NewIntParam | |
1137 | (const Standard_CString name) | |
1138 | { | |
1139 | Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam; | |
1140 | if ( AddNamedItem (name, intpar) == 0 ) intpar.Nullify(); | |
1141 | return intpar; | |
1142 | } | |
1143 | ||
1144 | ||
1145 | //======================================================================= | |
1146 | //function : | |
1147 | //purpose : | |
1148 | //======================================================================= | |
1149 | ||
1150 | Standard_Boolean IFSelect_WorkSession::SetIntValue | |
1151 | (const Handle(IFSelect_IntParam)& par, const Standard_Integer val) | |
1152 | { | |
1153 | if (ItemIdent(par) == 0) return Standard_False; | |
1154 | par->SetValue(val); | |
1155 | return Standard_True; | |
1156 | } | |
1157 | ||
1158 | ||
1159 | //======================================================================= | |
1160 | //function : | |
1161 | //purpose : | |
1162 | //======================================================================= | |
1163 | ||
1164 | Handle(TCollection_HAsciiString) IFSelect_WorkSession::TextParam | |
1165 | (const Standard_Integer id) const | |
1166 | { return Handle(TCollection_HAsciiString)::DownCast(Item(id)); } | |
1167 | ||
1168 | ||
1169 | //======================================================================= | |
1170 | //function : | |
1171 | //purpose : | |
1172 | //======================================================================= | |
1173 | ||
1174 | TCollection_AsciiString IFSelect_WorkSession::TextValue | |
1175 | (const Handle(TCollection_HAsciiString)& par) const | |
1176 | { | |
1177 | if (!par.IsNull()) return TCollection_AsciiString(par->ToCString()); | |
1178 | else return TCollection_AsciiString(); | |
1179 | } | |
1180 | ||
1181 | ||
1182 | Handle(TCollection_HAsciiString) IFSelect_WorkSession::NewTextParam | |
1183 | (const Standard_CString name) | |
1184 | { | |
1185 | Handle(TCollection_HAsciiString) textpar = new TCollection_HAsciiString(""); | |
1186 | if ( AddNamedItem (name, textpar) == 0 ) textpar.Nullify(); | |
1187 | return textpar; | |
1188 | } | |
1189 | ||
1190 | ||
1191 | //======================================================================= | |
1192 | //function : | |
1193 | //purpose : | |
1194 | //======================================================================= | |
1195 | ||
1196 | Standard_Boolean IFSelect_WorkSession::SetTextValue | |
1197 | (const Handle(TCollection_HAsciiString)& par, const Standard_CString val) | |
1198 | { | |
1199 | if (ItemIdent(par) == 0) return Standard_False; | |
1200 | par->Clear(); par->AssignCat(val); | |
1201 | return Standard_True; | |
1202 | } | |
1203 | ||
1204 | // ######################################################################## | |
1205 | // .... SIGNATURES .... | |
1206 | ||
1207 | //======================================================================= | |
1208 | //function : | |
1209 | //purpose : | |
1210 | //======================================================================= | |
1211 | ||
1212 | Handle(IFSelect_Signature) IFSelect_WorkSession::Signature | |
1213 | (const Standard_Integer id) const | |
1214 | { return GetCasted(IFSelect_Signature,Item(id)); } | |
1215 | ||
1216 | Standard_CString IFSelect_WorkSession::SignValue | |
1217 | (const Handle(IFSelect_Signature)& sign, const Handle(Standard_Transient)& ent) const | |
1218 | { | |
7f56eba8 | 1219 | if (sign.IsNull() || myModel.IsNull()) return ""; |
7fd59977 | 1220 | if (StartingNumber(ent) == 0) return ""; |
7f56eba8 | 1221 | return sign->Value (ent,myModel); |
7fd59977 | 1222 | } |
1223 | ||
1224 | // ######################################################################## | |
1225 | // .... SELECTIONS & Cie .... | |
1226 | ||
1227 | //======================================================================= | |
1228 | //function : | |
1229 | //purpose : | |
1230 | //======================================================================= | |
1231 | ||
1232 | Handle(IFSelect_Selection) IFSelect_WorkSession::Selection | |
1233 | (const Standard_Integer id) const | |
1234 | { return GetCasted(IFSelect_Selection,Item(id)); } | |
1235 | ||
1236 | ||
1237 | //======================================================================= | |
1238 | //function : | |
1239 | //purpose : | |
1240 | //======================================================================= | |
1241 | ||
1242 | Interface_EntityIterator IFSelect_WorkSession::EvalSelection | |
1243 | (const Handle(IFSelect_Selection)& sel) const | |
1244 | { | |
1245 | Interface_EntityIterator iter; | |
1246 | if (errhand) { | |
1247 | errhand = Standard_False; | |
1248 | try { | |
1249 | OCC_CATCH_SIGNALS | |
1250 | iter = EvalSelection(sel); // appel normal (donc, code pas duplique) | |
1251 | } | |
1252 | catch (Standard_Failure) { | |
1253 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
1254 | sout<<" **** Interruption EvalSelection par Exception : ****\n"; | |
1255 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
1256 | sout<<"\n Abandon"<<endl; | |
1257 | } | |
1258 | errhand = theerrhand; | |
1259 | return iter; | |
1260 | } | |
1261 | ||
1262 | if (thegraph.IsNull()) return iter; | |
bc650d41 | 1263 | iter = sel->UniqueResult(thegraph->Graph()); |
7fd59977 | 1264 | return iter; |
1265 | } | |
1266 | ||
1267 | ||
1268 | //======================================================================= | |
1269 | //function : | |
1270 | //purpose : | |
1271 | //======================================================================= | |
1272 | ||
1273 | IFSelect_SelectionIterator IFSelect_WorkSession::Sources | |
1274 | (const Handle(IFSelect_Selection)& sel) const | |
1275 | { | |
1276 | return IFSelect_SelectionIterator (sel); | |
1277 | } | |
1278 | ||
1279 | ||
1280 | //======================================================================= | |
1281 | //function : | |
1282 | //purpose : | |
1283 | //======================================================================= | |
1284 | ||
1285 | Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::SelectionResult | |
1286 | (const Handle(IFSelect_Selection)& sel) const | |
1287 | { | |
1288 | Handle(TColStd_HSequenceOfTransient) res; | |
1289 | if (errhand) { | |
1290 | errhand = Standard_False; | |
1291 | try { | |
1292 | OCC_CATCH_SIGNALS | |
1293 | res = SelectionResult(sel); // appel normal (->code unique) | |
1294 | } | |
1295 | catch (Standard_Failure) { | |
1296 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
1297 | sout<<" **** Interruption SelectionResult par Exception : ****\n"; | |
1298 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
1299 | sout<<"\n Abandon"<<endl; | |
1300 | } | |
1301 | errhand = theerrhand; | |
1302 | return res; | |
1303 | } | |
1304 | ||
1305 | if (!IsLoaded()) { | |
1306 | cout<< " *** Data for Evaluation not available ***"<<endl; | |
1307 | return new TColStd_HSequenceOfTransient(); | |
1308 | } | |
1309 | // if (ItemIdent(sel) == 0) | |
1310 | if (sel.IsNull()) | |
586db386 | 1311 | { cout << " Selection : Unknown"<<endl; return res; } //cout<<Handle |
7fd59977 | 1312 | return EvalSelection (sel).Content(); |
1313 | } | |
1314 | ||
1315 | ||
1316 | //======================================================================= | |
1317 | //function : | |
1318 | //purpose : | |
1319 | //======================================================================= | |
1320 | ||
1321 | Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::SelectionResultFromList | |
1322 | (const Handle(IFSelect_Selection)& sel, | |
1323 | const Handle(TColStd_HSequenceOfTransient)& list) const | |
1324 | { | |
1325 | if (list.IsNull()) return SelectionResult (sel); | |
1326 | DeclareAndCast(IFSelect_SelectDeduct,deduct,sel); | |
1327 | if (deduct.IsNull()) return SelectionResult (sel); | |
1328 | ||
1329 | // On va chercher la derniere deduction de la chaine des inputs | |
1330 | Handle(IFSelect_Selection) ssel, newinput; | |
1331 | ssel = sel; | |
1332 | Standard_Integer i, nb = MaxIdent(); | |
1333 | for (i = 1; i <= nb * 2; i ++) { | |
1334 | newinput = deduct->Input(); | |
1335 | deduct = GetCasted(IFSelect_SelectDeduct,newinput); | |
1336 | if (deduct.IsNull()) break; | |
1337 | ssel = newinput; | |
1338 | } | |
1339 | ||
1340 | // on y est (enfin, on devrait) | |
1341 | // ssel est la derniere selection auscultee, deduct son downcast | |
1342 | // input son Input (nulle si sel pas une deduction) | |
1343 | deduct = GetCasted(IFSelect_SelectDeduct,ssel); | |
bc650d41 | 1344 | |
7fd59977 | 1345 | deduct->Alternate()->SetList (list); |
1346 | ||
1347 | // On execute puis on nettoie | |
1348 | Handle(TColStd_HSequenceOfTransient) res = SelectionResult (sel); | |
1349 | //// deduct->SetInput (newinput); | |
1350 | return res; | |
1351 | } | |
1352 | ||
1353 | ||
1354 | //======================================================================= | |
1355 | //function : | |
1356 | //purpose : | |
1357 | //======================================================================= | |
1358 | ||
1359 | Standard_Boolean IFSelect_WorkSession::SetItemSelection | |
1360 | (const Handle(Standard_Transient)& item, | |
1361 | const Handle(IFSelect_Selection)& sel) | |
1362 | { | |
1363 | DeclareAndCast(IFSelect_Dispatch,disp,item); | |
1364 | DeclareAndCast(IFSelect_GeneralModifier,modif,item); | |
1365 | if (!disp.IsNull()) { | |
1366 | if (ItemIdent(disp) == 0) return Standard_False; | |
1367 | // Selection Nulle : Annuler FinalSelection | |
1368 | if (!sel.IsNull() && ItemIdent(sel) == 0) return Standard_False; | |
1369 | disp->SetFinalSelection(sel); | |
1370 | return Standard_True; | |
1371 | } | |
1372 | if (!modif.IsNull()) { | |
1373 | if (ItemIdent(modif) == 0) return Standard_False; | |
1374 | if (!sel.IsNull() && ItemIdent(sel) == 0) return Standard_False; | |
1375 | // Selection Nulle : Annuler Selection | |
1376 | modif->SetSelection(sel); | |
1377 | return Standard_True; | |
1378 | } | |
1379 | return Standard_False; | |
1380 | } | |
1381 | ||
1382 | ||
1383 | //======================================================================= | |
1384 | //function : | |
1385 | //purpose : | |
1386 | //======================================================================= | |
1387 | ||
1388 | Standard_Boolean IFSelect_WorkSession::ResetItemSelection | |
1389 | (const Handle(Standard_Transient)& item) | |
1390 | { | |
1391 | Handle(IFSelect_Selection) nulsel; | |
1392 | return SetItemSelection (item,nulsel); | |
1393 | } | |
1394 | ||
1395 | ||
1396 | //======================================================================= | |
1397 | //function : | |
1398 | //purpose : | |
1399 | //======================================================================= | |
1400 | ||
1401 | Handle(IFSelect_Selection) IFSelect_WorkSession::ItemSelection | |
1402 | (const Handle(Standard_Transient)& item) const | |
1403 | { | |
1404 | Handle(IFSelect_Selection) sel; | |
1405 | DeclareAndCast(IFSelect_Dispatch,disp,item); | |
1406 | DeclareAndCast(IFSelect_GeneralModifier,modif,item); | |
1407 | if (ItemIdent(disp) > 0) return disp->FinalSelection(); | |
1408 | if (ItemIdent(modif) > 0) return modif->Selection(); | |
1409 | return sel; // Nul ou inconnu -> Null | |
1410 | } | |
1411 | ||
1412 | // ###################################################################### | |
1413 | // .... Les COMPTEURS .... | |
1414 | ||
1415 | //======================================================================= | |
1416 | //function : | |
1417 | //purpose : | |
1418 | //======================================================================= | |
1419 | ||
1420 | Handle(IFSelect_SignCounter) IFSelect_WorkSession::SignCounter | |
1421 | (const Standard_Integer id) const | |
1422 | { return GetCasted(IFSelect_SignCounter,Item(id)); } | |
1423 | ||
1424 | ||
1425 | //======================================================================= | |
1426 | //function : | |
1427 | //purpose : | |
1428 | //======================================================================= | |
1429 | ||
1430 | Standard_Boolean IFSelect_WorkSession::ComputeCounter | |
1431 | (const Handle(IFSelect_SignCounter)& counter, const Standard_Boolean forced) | |
1432 | { | |
1433 | if (counter.IsNull()) return Standard_False; | |
1434 | if (!ComputeGraph()) return Standard_False; | |
1435 | return counter->ComputeSelected (Graph(),forced); | |
1436 | } | |
1437 | ||
1438 | ||
1439 | //======================================================================= | |
1440 | //function : | |
1441 | //purpose : | |
1442 | //======================================================================= | |
1443 | ||
1444 | Standard_Boolean IFSelect_WorkSession::ComputeCounterFromList | |
1445 | (const Handle(IFSelect_SignCounter)& counter, | |
1446 | const Handle(TColStd_HSequenceOfTransient)& list, | |
1447 | const Standard_Boolean clear) | |
1448 | { | |
1449 | if (counter.IsNull()) return Standard_False; | |
1450 | if (clear) counter->Clear(); | |
1451 | if (list.IsNull()) return ComputeCounter (counter,Standard_True); | |
7f56eba8 | 1452 | counter->AddList (list,myModel); |
7fd59977 | 1453 | return Standard_True; |
1454 | } | |
1455 | ||
1456 | // ###################################################################### | |
1457 | // .... Les DISPATCHES .... | |
1458 | ||
1459 | //======================================================================= | |
1460 | //function : | |
1461 | //purpose : | |
1462 | //======================================================================= | |
1463 | ||
1464 | Handle(TColStd_HSequenceOfInteger) IFSelect_WorkSession::AppliedDispatches | |
1465 | () const | |
1466 | { | |
1467 | Handle(TColStd_HSequenceOfInteger) list = new TColStd_HSequenceOfInteger(); | |
1468 | Standard_Integer nb = theshareout->NbDispatches(); | |
1469 | for (Standard_Integer i = 1; i <= nb; i ++) { | |
1470 | list->Append (ItemIdent(theshareout->Dispatch(i))); | |
1471 | } | |
1472 | return list; | |
1473 | } | |
1474 | ||
1475 | ||
1476 | //======================================================================= | |
1477 | //function : | |
1478 | //purpose : | |
1479 | //======================================================================= | |
1480 | ||
1481 | void IFSelect_WorkSession::ClearShareOut (const Standard_Boolean onlydisp) | |
1482 | { | |
1483 | theshareout->Clear(onlydisp); | |
1484 | } | |
1485 | ||
1486 | ||
1487 | //======================================================================= | |
1488 | //function : | |
1489 | //purpose : | |
1490 | //======================================================================= | |
1491 | ||
1492 | Handle(IFSelect_Dispatch) IFSelect_WorkSession::Dispatch | |
1493 | (const Standard_Integer id) const | |
1494 | { | |
1495 | return GetCasted(IFSelect_Dispatch,Item(id)); | |
1496 | } | |
1497 | ||
1498 | ||
1499 | //======================================================================= | |
1500 | //function : | |
1501 | //purpose : | |
1502 | //======================================================================= | |
1503 | ||
1504 | Standard_Integer IFSelect_WorkSession::DispatchRank | |
1505 | (const Handle(IFSelect_Dispatch)& disp) const | |
1506 | { | |
1507 | if (ItemIdent(disp) == 0) return 0; | |
1508 | return theshareout->DispatchRank(disp); | |
1509 | } | |
1510 | ||
1511 | // ###################################################################### | |
1512 | // .... Les MODIFIERS .... | |
1513 | ||
1514 | //======================================================================= | |
1515 | //function : | |
1516 | //purpose : | |
1517 | //======================================================================= | |
1518 | ||
7f56eba8 | 1519 | void IFSelect_WorkSession::SetModelCopier (const Handle(IFSelect_ModelCopier)& copier) |
7fd59977 | 1520 | { |
1521 | thecopier = copier; | |
1522 | thecopier->SetShareOut(theshareout); | |
1523 | } | |
1524 | ||
1525 | ||
1526 | //======================================================================= | |
1527 | //function : | |
1528 | //purpose : | |
1529 | //======================================================================= | |
1530 | ||
7f56eba8 | 1531 | Standard_Integer IFSelect_WorkSession::NbFinalModifiers (const Standard_Boolean formodel) const |
7fd59977 | 1532 | { |
1533 | return theshareout->NbModifiers(formodel); | |
1534 | } | |
1535 | ||
1536 | ||
1537 | //======================================================================= | |
1538 | //function : | |
1539 | //purpose : | |
1540 | //======================================================================= | |
1541 | ||
1542 | Handle(TColStd_HSequenceOfInteger) IFSelect_WorkSession::FinalModifierIdents | |
1543 | (const Standard_Boolean formodel) const | |
1544 | { | |
1545 | // return ItemIdents(STANDARD_TYPE(IFSelect_Modifier)); | |
1546 | // On donne la liste dans l ordre du ModelCopier, qui fait foi | |
1547 | Handle(TColStd_HSequenceOfInteger) list = new TColStd_HSequenceOfInteger(); | |
1548 | Standard_Integer nbm = theshareout->NbModifiers(formodel); | |
1549 | for (Standard_Integer i = 1; i <= nbm; i ++) | |
1550 | list->Append(ItemIdent(theshareout->GeneralModifier(formodel,i))); | |
1551 | return list; | |
1552 | } | |
1553 | ||
1554 | ||
1555 | //======================================================================= | |
1556 | //function : | |
1557 | //purpose : | |
1558 | //======================================================================= | |
1559 | ||
7f56eba8 | 1560 | Handle(IFSelect_GeneralModifier) IFSelect_WorkSession::GeneralModifier (const Standard_Integer id) const |
7fd59977 | 1561 | { |
1562 | return GetCasted(IFSelect_GeneralModifier,Item(id)); | |
1563 | } | |
1564 | ||
1565 | ||
1566 | //======================================================================= | |
1567 | //function : | |
1568 | //purpose : | |
1569 | //======================================================================= | |
1570 | ||
7f56eba8 | 1571 | Handle(IFSelect_Modifier) IFSelect_WorkSession::ModelModifier (const Standard_Integer id) const |
7fd59977 | 1572 | { |
1573 | return GetCasted(IFSelect_Modifier,Item(id)); | |
1574 | } | |
1575 | ||
1576 | ||
1577 | //======================================================================= | |
1578 | //function : | |
1579 | //purpose : | |
1580 | //======================================================================= | |
1581 | ||
7f56eba8 | 1582 | Standard_Integer IFSelect_WorkSession::ModifierRank (const Handle(IFSelect_GeneralModifier)& modif) const |
7fd59977 | 1583 | { |
1584 | if (ItemIdent(modif) == 0) return 0; | |
1585 | return theshareout->ModifierRank(modif); | |
1586 | } | |
1587 | ||
1588 | ||
1589 | //======================================================================= | |
1590 | //function : | |
1591 | //purpose : | |
1592 | //======================================================================= | |
1593 | ||
1594 | Standard_Boolean IFSelect_WorkSession::ChangeModifierRank | |
1595 | (const Standard_Boolean formodel, | |
1596 | const Standard_Integer before, const Standard_Integer after) | |
1597 | { | |
1598 | return theshareout->ChangeModifierRank(formodel,before,after); | |
1599 | } | |
1600 | ||
1601 | ||
1602 | //======================================================================= | |
1603 | //function : | |
1604 | //purpose : | |
1605 | //======================================================================= | |
1606 | ||
1607 | void IFSelect_WorkSession::ClearFinalModifiers () | |
1608 | { | |
1609 | Handle(TColStd_HSequenceOfInteger) list = FinalModifierIdents (Standard_True); | |
1610 | Standard_Integer nb = list->Length(); | |
1611 | Standard_Integer i; // svv #1 | |
1612 | for (i = 1; i <= nb; i ++) | |
1613 | RemoveItem(GeneralModifier(list->Value(i))); | |
1614 | list = FinalModifierIdents (Standard_False); | |
1615 | nb = list->Length(); | |
1616 | for (i = 1; i <= nb; i ++) | |
1617 | RemoveItem(GeneralModifier(list->Value(i))); | |
1618 | } | |
1619 | ||
1620 | ||
1621 | //======================================================================= | |
1622 | //function : | |
1623 | //purpose : | |
1624 | //======================================================================= | |
1625 | ||
1626 | Standard_Boolean IFSelect_WorkSession::SetAppliedModifier | |
1627 | (const Handle(IFSelect_GeneralModifier)& modif, | |
1628 | const Handle(Standard_Transient)& item) | |
1629 | { | |
1630 | if (ItemIdent(modif) == 0) return Standard_False; | |
1631 | ||
1632 | if (item.IsNull()) return Standard_False; | |
1633 | if (item == theshareout) { | |
1634 | theshareout->AddModifier(modif,0); | |
1635 | return Standard_True; | |
1636 | } | |
1637 | if (item->IsKind(STANDARD_TYPE(IFSelect_Dispatch))) { | |
1638 | DeclareAndCast(IFSelect_Dispatch,disp,item); | |
1639 | theshareout->AddModifier(modif,0); | |
1640 | modif->SetDispatch(disp); | |
1641 | return Standard_True; | |
1642 | } | |
1643 | if (item->IsKind(STANDARD_TYPE(IFSelect_TransformStandard))) { | |
1644 | DeclareAndCast(IFSelect_TransformStandard,stf,item); | |
1645 | DeclareAndCast(IFSelect_Modifier,tmod,modif); | |
1646 | if (tmod.IsNull()) return Standard_False; | |
1647 | stf->AddModifier (tmod); | |
1648 | theshareout->RemoveItem(modif); | |
1649 | return Standard_True; | |
1650 | } | |
1651 | return Standard_False; | |
1652 | } | |
1653 | ||
1654 | ||
1655 | //======================================================================= | |
1656 | //function : | |
1657 | //purpose : | |
1658 | //======================================================================= | |
1659 | ||
1660 | Standard_Boolean IFSelect_WorkSession::ResetAppliedModifier | |
1661 | (const Handle(IFSelect_GeneralModifier)& modif) | |
1662 | { | |
1663 | if (ItemIdent(modif) == 0) return Standard_False; | |
1664 | ||
1665 | return theshareout->RemoveItem(modif); | |
1666 | } | |
1667 | ||
1668 | ||
1669 | //======================================================================= | |
1670 | //function : | |
1671 | //purpose : | |
1672 | //======================================================================= | |
1673 | ||
1674 | Handle(Standard_Transient) IFSelect_WorkSession::UsesAppliedModifier | |
1675 | (const Handle(IFSelect_GeneralModifier)& modif) const | |
1676 | { | |
1677 | Handle(Standard_Transient) res; | |
1678 | if (ItemIdent(modif) == 0) return res; | |
1679 | if (theshareout->ModifierRank(modif) == 0) return res; | |
1680 | res = modif->Dispatch(); | |
1681 | if (res.IsNull()) res = theshareout; | |
1682 | return res; | |
1683 | } | |
1684 | ||
1685 | // ################################################################# | |
1686 | // .... Transformer .... | |
1687 | ||
1688 | //======================================================================= | |
1689 | //function : | |
1690 | //purpose : | |
1691 | //======================================================================= | |
1692 | ||
7f56eba8 | 1693 | Handle(IFSelect_Transformer) IFSelect_WorkSession::Transformer (const Standard_Integer id) const |
7fd59977 | 1694 | { |
1695 | return GetCasted(IFSelect_Transformer,Item(id)); | |
1696 | } | |
1697 | ||
1698 | ||
1699 | //======================================================================= | |
1700 | //function : | |
1701 | //purpose : | |
1702 | //======================================================================= | |
1703 | ||
1704 | Standard_Integer IFSelect_WorkSession::RunTransformer | |
1705 | (const Handle(IFSelect_Transformer)& transf) | |
1706 | { | |
1707 | Standard_Integer effect = 0; | |
1708 | if (transf.IsNull() || !IsLoaded()) return effect; | |
1709 | Handle(Interface_InterfaceModel) newmod; // Null au depart | |
1710 | Interface_CheckIterator checks; | |
1711 | checks.SetName("X-STEP WorkSession : RunTransformer"); | |
1712 | Standard_Boolean res = transf->Perform | |
1713 | (thegraph->Graph(),theprotocol,checks,newmod); | |
1714 | ||
1715 | if (!checks.IsEmpty(Standard_False)) { | |
1716 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
1717 | sout<<" ** RunTransformer has produced Check Messages : **"<<endl; | |
7f56eba8 | 1718 | checks.Print (sout,myModel,Standard_False); |
7fd59977 | 1719 | } |
1720 | thecheckdone = Standard_False; | |
1721 | thecheckrun = checks; | |
1722 | ||
1723 | if (newmod.IsNull()) return (res ? 1 : -1); | |
1724 | // MISE A JOUR des SelectPointed | |
1725 | Handle(TColStd_HSequenceOfInteger) list = | |
1726 | ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed)); | |
1727 | Standard_Integer nb = list->Length(); | |
1728 | for (Standard_Integer i = 1; i <= nb; i ++) { | |
1729 | DeclareAndCast(IFSelect_SelectPointed,sp,Item(list->Value(i))); | |
1730 | sp->Update(transf); | |
1731 | } | |
7f56eba8 | 1732 | if (newmod == myModel) { |
7fd59977 | 1733 | effect = (res ? 2 : -2); |
1734 | if (!res) return effect; | |
1735 | Handle(Interface_Protocol) newproto = theprotocol; | |
1736 | if (transf->ChangeProtocol(newproto)) | |
1737 | { effect = 4; theprotocol = newproto; thegtool->SetProtocol(newproto); } | |
1738 | return (ComputeGraph(Standard_True) ? 4 : -4); | |
1739 | } else { | |
1740 | effect = (res ? 3 : -3); | |
1741 | if (!res) return effect; | |
1742 | Handle(Interface_Protocol) newproto = theprotocol; | |
1743 | if (transf->ChangeProtocol(newproto)) | |
1744 | { effect = 5; theprotocol = newproto; thegtool->SetProtocol(newproto); } | |
7f56eba8 | 1745 | theoldel = myModel; |
7fd59977 | 1746 | SetModel(newmod,Standard_False); |
1747 | } | |
1748 | return effect; | |
1749 | } | |
1750 | ||
1751 | ||
1752 | //======================================================================= | |
1753 | //function : | |
1754 | //purpose : | |
1755 | //======================================================================= | |
1756 | ||
1757 | Standard_Integer IFSelect_WorkSession::RunModifier | |
1758 | (const Handle(IFSelect_Modifier)& modif, const Standard_Boolean copy) | |
1759 | { | |
1760 | Handle(IFSelect_Selection) sel; // null | |
1761 | return RunModifierSelected (modif,sel,copy); | |
1762 | } | |
1763 | ||
1764 | ||
1765 | //======================================================================= | |
1766 | //function : | |
1767 | //purpose : | |
1768 | //======================================================================= | |
1769 | ||
1770 | Standard_Integer IFSelect_WorkSession::RunModifierSelected | |
1771 | (const Handle(IFSelect_Modifier)& modif, | |
1772 | const Handle(IFSelect_Selection)& sel, const Standard_Boolean copy) | |
1773 | { | |
1774 | if (ItemIdent(modif) == 0) return Standard_False; | |
1775 | Handle(IFSelect_TransformStandard) stf = new IFSelect_TransformStandard; | |
1776 | stf->SetCopyOption(copy); | |
1777 | stf->SetSelection (sel); | |
1778 | stf->AddModifier (modif); | |
1779 | return RunTransformer (stf); | |
1780 | } | |
1781 | ||
1782 | ||
1783 | //======================================================================= | |
1784 | //function : | |
1785 | //purpose : | |
1786 | //======================================================================= | |
1787 | ||
1788 | Handle(IFSelect_Transformer) IFSelect_WorkSession::NewTransformStandard | |
1789 | (const Standard_Boolean copy, const Standard_CString name) | |
1790 | { | |
1791 | Handle(IFSelect_TransformStandard) stf = new IFSelect_TransformStandard; | |
1792 | stf->SetCopyOption(copy); | |
1793 | if (AddNamedItem (name, stf) == 0) stf.Nullify(); | |
1794 | return stf; | |
1795 | } | |
1796 | ||
1797 | ||
1798 | // Ceci est une action directe : pourrait etre fait par un Transformer ... | |
1799 | //======================================================================= | |
1800 | //function : | |
1801 | //purpose : | |
1802 | //======================================================================= | |
1803 | ||
1804 | Standard_Boolean IFSelect_WorkSession::SetModelContent | |
1805 | (const Handle(IFSelect_Selection)& sel, const Standard_Boolean keep) | |
1806 | { | |
1807 | if (sel.IsNull() || !IsLoaded()) return Standard_False; | |
1808 | Interface_EntityIterator list = sel->UniqueResult(thegraph->Graph()); | |
1809 | if (list.NbEntities() == 0) return Standard_False; | |
1810 | ||
7f56eba8 | 1811 | Handle(Interface_InterfaceModel) newmod = myModel->NewEmptyModel(); |
1812 | Interface_CopyTool TC(myModel,theprotocol); | |
1813 | Standard_Integer i, nb = myModel->NbEntities(); | |
7fd59977 | 1814 | if (keep) { |
1815 | for (list.Start(); list.More(); list.Next()) | |
1816 | TC.TransferEntity (list.Value()); | |
1817 | } else { | |
1818 | Standard_Integer* flags = new Standard_Integer[nb+1]; | |
1819 | for (i = 0; i <= nb; i ++) flags[i] = 0; | |
1820 | for (list.Start(); list.More(); list.Next()) { | |
7f56eba8 | 1821 | Standard_Integer num = myModel->Number(list.Value()); |
7fd59977 | 1822 | if (num <= nb) flags[num] = 1; |
1823 | } | |
1824 | for (i = 1; i <= nb; i ++) { | |
7f56eba8 | 1825 | if (flags[i] == 0) TC.TransferEntity (myModel->Value(i)); |
7fd59977 | 1826 | } |
1827 | delete [] flags; | |
1828 | } | |
1829 | TC.FillModel(newmod); | |
1830 | if (newmod->NbEntities() == 0) return Standard_False; | |
1831 | // Mettre a jour (ne pas oublier SelectPointed) | |
7f56eba8 | 1832 | theoldel = myModel; |
7fd59977 | 1833 | SetModel(newmod,Standard_False); |
1834 | // MISE A JOUR des SelectPointed | |
1835 | Handle(TColStd_HSequenceOfInteger) pts = | |
1836 | ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed)); | |
1837 | nb = pts->Length(); | |
1838 | for (i = 1; i <= nb; i ++) { | |
1839 | DeclareAndCast(IFSelect_SelectPointed,sp,Item(pts->Value(i))); | |
1840 | sp->Update(TC.Control()); | |
1841 | } | |
1842 | return Standard_True; | |
1843 | } | |
1844 | ||
1845 | ||
1846 | // ################################################################# | |
1847 | // .... File Name .... | |
1848 | ||
1849 | //======================================================================= | |
1850 | //function : | |
1851 | //purpose : | |
1852 | //======================================================================= | |
1853 | ||
1854 | Handle(TCollection_HAsciiString) IFSelect_WorkSession::FilePrefix () const | |
1855 | { | |
1856 | return theshareout->Prefix(); | |
1857 | } | |
1858 | ||
1859 | ||
1860 | //======================================================================= | |
1861 | //function : | |
1862 | //purpose : | |
1863 | //======================================================================= | |
1864 | ||
1865 | Handle(TCollection_HAsciiString) IFSelect_WorkSession::DefaultFileRoot () const | |
1866 | { | |
1867 | return theshareout->DefaultRootName(); | |
1868 | } | |
1869 | ||
1870 | ||
1871 | //======================================================================= | |
1872 | //function : | |
1873 | //purpose : | |
1874 | //======================================================================= | |
1875 | ||
1876 | Handle(TCollection_HAsciiString) IFSelect_WorkSession::FileExtension () const | |
1877 | { | |
1878 | return theshareout->Extension(); | |
1879 | } | |
1880 | ||
1881 | ||
1882 | //======================================================================= | |
1883 | //function : | |
1884 | //purpose : | |
1885 | //======================================================================= | |
1886 | ||
1887 | Handle(TCollection_HAsciiString) IFSelect_WorkSession::FileRoot | |
1888 | (const Handle(IFSelect_Dispatch)& disp) const | |
1889 | { | |
1890 | return theshareout->RootName(theshareout->DispatchRank(disp)); | |
1891 | } | |
1892 | ||
1893 | ||
1894 | //======================================================================= | |
1895 | //function : | |
1896 | //purpose : | |
1897 | //======================================================================= | |
1898 | ||
1899 | void IFSelect_WorkSession::SetFilePrefix (const Standard_CString name) | |
1900 | { | |
1901 | theshareout->SetPrefix (new TCollection_HAsciiString(name)); | |
1902 | } | |
1903 | ||
1904 | ||
1905 | //======================================================================= | |
1906 | //function : | |
1907 | //purpose : | |
1908 | //======================================================================= | |
1909 | ||
1910 | void IFSelect_WorkSession::SetFileExtension (const Standard_CString name) | |
1911 | { | |
1912 | theshareout->SetExtension (new TCollection_HAsciiString(name)); | |
1913 | } | |
1914 | ||
1915 | ||
1916 | //======================================================================= | |
1917 | //function : | |
1918 | //purpose : | |
1919 | //======================================================================= | |
1920 | ||
1921 | Standard_Boolean IFSelect_WorkSession::SetDefaultFileRoot | |
1922 | (const Standard_CString name) | |
1923 | { | |
1924 | Handle(TCollection_HAsciiString) defrt; | |
1925 | if (name[0] != '\0') defrt = new TCollection_HAsciiString(name); | |
1926 | return theshareout->SetDefaultRootName (defrt); | |
1927 | } | |
1928 | ||
1929 | ||
1930 | //======================================================================= | |
1931 | //function : | |
1932 | //purpose : | |
1933 | //======================================================================= | |
1934 | ||
1935 | Standard_Boolean IFSelect_WorkSession::SetFileRoot | |
1936 | (const Handle(IFSelect_Dispatch)& disp, const Standard_CString namefile) | |
1937 | { | |
1938 | Standard_Integer id = ItemIdent(disp); | |
1939 | if (id == 0) return Standard_False; | |
1940 | Standard_Integer nd = theshareout->DispatchRank(disp); | |
1941 | /* if (theonlynamed) { | |
1942 | if (nd == 0 && namefile[0] != 0) | |
1943 | theshareout->AddDispatch(disp); | |
1944 | else if (nd != 0 && namefile[0] == 0) | |
1945 | theshareout->RemoveDispatch (nd); | |
1946 | } */ | |
1947 | if (nd == 0) return Standard_False; | |
1948 | // The order below prevented to change the root name on a given dispatch ! | |
1949 | // if (theshareout->HasRootName(nd)) return Standard_False; | |
1950 | Handle(TCollection_HAsciiString) filename; | |
1951 | if (namefile[0] != '\0') filename = new TCollection_HAsciiString (namefile); | |
1952 | return theshareout->SetRootName(nd,filename); | |
1953 | } | |
1954 | ||
1955 | ||
1956 | //======================================================================= | |
1957 | //function : | |
1958 | //purpose : | |
1959 | //======================================================================= | |
1960 | ||
1961 | Standard_CString IFSelect_WorkSession::GiveFileRoot | |
1962 | (const Standard_CString file) const | |
1963 | { | |
1964 | OSD_Path path (file); | |
1965 | if (!path.IsValid(TCollection_AsciiString(file))) return file; // tant pis .. | |
1966 | bufstr = path.Name(); | |
1967 | return bufstr.ToCString(); | |
1968 | } | |
1969 | ||
1970 | ||
1971 | //======================================================================= | |
1972 | //function : | |
1973 | //purpose : | |
1974 | //======================================================================= | |
1975 | ||
1976 | Standard_CString IFSelect_WorkSession::GiveFileComplete | |
1977 | (const Standard_CString file) const | |
1978 | { | |
1979 | // ajouter si besoin : Prefix; Extension | |
1980 | bufstr.Clear(); bufstr.AssignCat (file); | |
1981 | Standard_Integer i,j = 0,nb = bufstr.Length(); | |
1982 | Handle(TCollection_HAsciiString) ext = FileExtension (); | |
1983 | if (!ext.IsNull()) { | |
1984 | char val0 = '\0'; if (ext->Length() > 0) val0 = ext->Value(1); | |
1985 | for (i = nb; i > 0; i --) if (bufstr.Value(i) == val0) { j = 1; break; } | |
1986 | if (j == 0) bufstr.AssignCat (ext->ToCString()); | |
1987 | } | |
1988 | Handle(TCollection_HAsciiString) pre = FilePrefix (); | |
1989 | if (!pre.IsNull()) { | |
1990 | char val1 = '\0'; if (pre->Length() > 0) val1 = pre->Value(pre->Length()); | |
1991 | j = 0; | |
1992 | for (i = nb; i > 0; i --) if (bufstr.Value(i) == val1) { j = 1; break; } | |
1993 | if (j == 0) bufstr.Insert (1,pre->ToCString()); | |
1994 | } | |
1995 | ||
1996 | return bufstr.ToCString(); | |
1997 | } | |
1998 | ||
1999 | ||
2000 | //======================================================================= | |
2001 | //function : | |
2002 | //purpose : | |
2003 | //======================================================================= | |
2004 | ||
2005 | void IFSelect_WorkSession::ClearFile () | |
2006 | { | |
2007 | thecopier->ClearResult(); | |
2008 | theshareout->ClearResult(Standard_True); | |
2009 | } | |
2010 | ||
2011 | ||
2012 | //======================================================================= | |
2013 | //function : | |
2014 | //purpose : | |
2015 | //======================================================================= | |
2016 | ||
2017 | void IFSelect_WorkSession::EvaluateFile () | |
2018 | { | |
2019 | ////... | |
2020 | if (!IsLoaded()) return; | |
2021 | Interface_CheckIterator checks; | |
2022 | if (errhand) { | |
2023 | errhand = Standard_False; | |
2024 | try { | |
2025 | OCC_CATCH_SIGNALS | |
2026 | EvaluateFile(); // appel normal (donc, code pas duplique) | |
2027 | } | |
2028 | catch (Standard_Failure) { | |
2029 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2030 | sout<<" **** Interruption EvaluateFile par Exception : ****\n"; | |
2031 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
2032 | sout<<"\n Abandon"<<endl; | |
2033 | checks.CCheck(0)->AddFail ("Exception Raised -> Abandon"); | |
2034 | } | |
2035 | errhand = theerrhand; | |
2036 | thecheckrun = checks; | |
2037 | return; | |
2038 | } | |
2039 | ||
2040 | IFSelect_ShareOutResult R(theshareout,thegraph->Graph()); | |
2041 | checks = thecopier->Copy (R,thelibrary,theprotocol); | |
2042 | if (!checks.IsEmpty(Standard_False)) { | |
2043 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2044 | sout<<" ** EvaluateFile has produced Check Messages : **"<<endl; | |
7f56eba8 | 2045 | checks.Print (sout,myModel,Standard_False); |
7fd59977 | 2046 | } |
2047 | thecopier->SetRemaining (thegraph->CGraph()); | |
2048 | thecheckrun = checks; | |
2049 | } | |
2050 | ||
2051 | ||
2052 | //======================================================================= | |
2053 | //function : | |
2054 | //purpose : | |
2055 | //======================================================================= | |
2056 | ||
2057 | Standard_Integer IFSelect_WorkSession::NbFiles () const | |
2058 | { | |
2059 | return thecopier->NbFiles(); | |
2060 | } | |
2061 | ||
2062 | ||
2063 | //======================================================================= | |
2064 | //function : | |
2065 | //purpose : | |
2066 | //======================================================================= | |
2067 | ||
2068 | Handle(Interface_InterfaceModel) IFSelect_WorkSession::FileModel | |
2069 | (const Standard_Integer num) const | |
2070 | { | |
2071 | Handle(Interface_InterfaceModel) mod; | |
2072 | if (num > 0 && num <= NbFiles()) mod = thecopier->FileModel(num); | |
2073 | return mod; | |
2074 | } | |
2075 | ||
2076 | ||
2077 | //======================================================================= | |
2078 | //function : | |
2079 | //purpose : | |
2080 | //======================================================================= | |
2081 | ||
2082 | TCollection_AsciiString IFSelect_WorkSession::FileName | |
2083 | (const Standard_Integer num) const | |
2084 | { | |
2085 | TCollection_AsciiString name; | |
2086 | if (num > 0 && num <= NbFiles()) name = thecopier->FileName(num); | |
2087 | return name; | |
2088 | } | |
2089 | ||
2090 | ||
2091 | //======================================================================= | |
2092 | //function : | |
2093 | //purpose : | |
2094 | //======================================================================= | |
2095 | ||
2096 | void IFSelect_WorkSession::BeginSentFiles (const Standard_Boolean record) | |
2097 | { | |
2098 | thecopier->BeginSentFiles(theshareout,record); | |
2099 | } | |
2100 | ||
2101 | ||
2102 | //======================================================================= | |
2103 | //function : | |
2104 | //purpose : | |
2105 | //======================================================================= | |
2106 | ||
2107 | Handle(TColStd_HSequenceOfHAsciiString) IFSelect_WorkSession::SentFiles () const | |
2108 | { | |
2109 | return thecopier->SentFiles(); | |
2110 | } | |
2111 | ||
2112 | ||
2113 | // ######################################################################### | |
2114 | // .... Action de Transfert proprement dite : la grande affaire ! .... | |
2115 | ||
2116 | //======================================================================= | |
2117 | //function : | |
2118 | //purpose : | |
2119 | //======================================================================= | |
2120 | ||
2121 | Standard_Boolean IFSelect_WorkSession::SendSplit () | |
2122 | { | |
2123 | ////... | |
2124 | Interface_CheckIterator checks; | |
2125 | ||
2126 | if (errhand) { | |
2127 | errhand = Standard_False; | |
2128 | try { | |
2129 | OCC_CATCH_SIGNALS | |
2130 | return SendSplit(); // appel normal (donc, code pas duplique) | |
2131 | } | |
2132 | catch (Standard_Failure) { | |
2133 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2134 | sout<<" **** Interruption SendSplit par Exception : ****\n"; | |
2135 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
2136 | sout<<"\n Abandon"<<endl; | |
2137 | checks.CCheck(0)->AddFail ("Exception Raised -> Abandon"); | |
2138 | } | |
2139 | errhand = theerrhand; | |
2140 | thecheckrun = checks; | |
2141 | return Standard_False; | |
2142 | } | |
2143 | ||
2144 | if (thelibrary.IsNull()) { | |
2145 | checks.CCheck(0)->AddFail("WorkLibrary undefined"); | |
2146 | thecheckrun = checks; | |
2147 | return Standard_False; | |
2148 | } | |
2149 | if (!IsLoaded()) { | |
2150 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2151 | sout<< " *** Data for SendSplit not available ***"<<endl; | |
2152 | checks.CCheck(0)->AddFail("Data not available"); | |
2153 | thecheckrun = checks; | |
2154 | return Standard_False; | |
2155 | } | |
2156 | ||
2157 | if (NbFiles() > 0) checks = thecopier->SendCopied (thelibrary,theprotocol); | |
2158 | else { | |
2159 | /* | |
2160 | IFSelect_ShareOutResult eval (ShareOut(), thegraph->Graph()); | |
2161 | checks = thecopier->Send (eval, thelibrary, theprotocol); | |
2162 | thecopier->SetRemaining (thegraph->CGraph()); | |
2163 | */ | |
2164 | // Decomposer | |
2165 | if (theshareout.IsNull()) return Standard_False; | |
2166 | Standard_Integer i, nbd = theshareout->NbDispatches(); | |
2167 | Standard_Integer nf = 0; | |
2168 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2169 | sout<<" SendSplit .. "; | |
2170 | for (i = 1; i <= nbd; i ++) { | |
2171 | Handle(IFSelect_Dispatch) disp = theshareout->Dispatch(i); | |
2172 | if (disp.IsNull()) continue; | |
2173 | IFGraph_SubPartsIterator packs(thegraph->Graph(),Standard_False); | |
2174 | disp->Packets (thegraph->Graph(),packs); | |
2175 | for (packs.Start(); packs.More(); packs.Next()) { | |
2176 | Interface_EntityIterator iter = packs.Entities(); | |
2177 | if (iter.NbEntities() == 0) continue; | |
2178 | // Ecrire une liste d entites | |
2179 | Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed; | |
2180 | sp->SetList (iter.Content()); | |
2181 | nf ++; | |
2182 | TCollection_AsciiString filnam (nf); | |
2183 | filnam.Insert (1,"_"); | |
2184 | Handle(TCollection_HAsciiString) filepart; | |
2185 | filepart = FileRoot(disp); | |
2186 | if (!filepart.IsNull()) filnam.Insert(1,filepart->ToCString()); | |
2187 | filepart = FilePrefix(); | |
2188 | if (!filepart.IsNull()) filnam.Insert(1,filepart->ToCString()); | |
2189 | filepart = FileExtension(); | |
2190 | if (!filepart.IsNull()) filnam.AssignCat (filepart->ToCString()); | |
2191 | IFSelect_ReturnStatus stat = SendSelected (filnam.ToCString(),sp); | |
2192 | if (stat != IFSelect_RetDone) cout<<"File "<<filnam<<" failed"<<endl; | |
2193 | } | |
2194 | } | |
2195 | sout<<" .. Files Written : "<<nf<<endl; | |
2196 | } | |
2197 | thecheckrun = checks; | |
2198 | return Standard_True; | |
2199 | } | |
2200 | ||
2201 | ||
2202 | //======================================================================= | |
2203 | //function : | |
2204 | //purpose : | |
2205 | //======================================================================= | |
2206 | ||
2207 | Handle(IFSelect_PacketList) IFSelect_WorkSession::EvalSplit () const | |
2208 | { | |
2209 | Handle(IFSelect_PacketList) pks; | |
2210 | if (!IsLoaded()) return pks; | |
2211 | IFSelect_ShareOutResult sho (ShareOut(), thegraph->Graph()); | |
2212 | return sho.Packets(); | |
2213 | } | |
2214 | ||
2215 | ||
2216 | //======================================================================= | |
2217 | //function : | |
2218 | //purpose : | |
2219 | //======================================================================= | |
2220 | ||
2221 | Interface_EntityIterator IFSelect_WorkSession::SentList | |
2222 | (const Standard_Integer newcount) const | |
2223 | { | |
2224 | Interface_EntityIterator iter; | |
2225 | if (!IsLoaded()) return iter; | |
2226 | const Interface_Graph& G = thegraph->Graph(); | |
2227 | Standard_Integer nb = G.Size(); | |
2228 | Standard_Integer i; | |
2229 | for ( i = 1; i <= nb; i ++) { | |
2230 | Standard_Integer stat = G.Status(i); | |
2231 | if ( (stat > 0 && newcount < 0) || stat == newcount) | |
2232 | iter.GetOneItem(G.Entity(i)); | |
2233 | } | |
2234 | return iter; | |
2235 | } | |
2236 | ||
2237 | ||
2238 | //======================================================================= | |
2239 | //function : | |
2240 | //purpose : | |
2241 | //======================================================================= | |
2242 | ||
2243 | Standard_Integer IFSelect_WorkSession::MaxSendingCount () const | |
2244 | { | |
2245 | Standard_Integer newcount = 0; | |
2246 | if (!IsLoaded()) return newcount; | |
2247 | const Interface_Graph& G = thegraph->Graph(); | |
2248 | Standard_Integer nb = G.Size(); | |
2249 | Standard_Integer i; | |
2250 | for (i = 1; i <= nb; i ++) { | |
2251 | Standard_Integer stat = G.Status(i); | |
2252 | if (stat > newcount) newcount = stat; | |
2253 | } | |
2254 | return newcount; | |
2255 | } | |
2256 | ||
2257 | ||
2258 | //======================================================================= | |
2259 | //function : | |
2260 | //purpose : | |
2261 | //======================================================================= | |
2262 | ||
2263 | Standard_Boolean IFSelect_WorkSession::SetRemaining | |
2264 | (const IFSelect_RemainMode mode) | |
2265 | { | |
2266 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2267 | if (!IsLoaded()) return Standard_False; | |
2268 | if (mode == IFSelect_RemainForget) { | |
2269 | Standard_Integer nb = thegraph->Graph().Size(); | |
2270 | for (Standard_Integer i = 1; i <= nb; i ++) | |
2271 | thegraph->CGraph().SetStatus (i,0); | |
2272 | theoldel.Nullify(); | |
2273 | return Standard_True; | |
2274 | } else if (mode == IFSelect_RemainCompute) { | |
2275 | Handle(Interface_InterfaceModel) newmod; | |
7f56eba8 | 2276 | Interface_CopyTool TC(myModel,theprotocol); |
7fd59977 | 2277 | thecopier->CopiedRemaining (thegraph->Graph(),thelibrary,TC,newmod); |
2278 | if (newmod.IsNull()) { | |
2279 | sout<<" No Remaining Data recorded"<<endl; return Standard_False; | |
7f56eba8 | 2280 | } else if (newmod == myModel) { |
7fd59977 | 2281 | sout<<" Remaining causes all original data to be kept"<<endl; |
2282 | thecopier->SetRemaining (thegraph->CGraph()); | |
2283 | return Standard_False; | |
2284 | } else { | |
7f56eba8 | 2285 | theoldel = myModel; |
7fd59977 | 2286 | SetModel(newmod,Standard_False); |
2287 | // MISE A JOUR des SelectPointed | |
2288 | Handle(TColStd_HSequenceOfInteger) list = | |
2289 | ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed)); | |
2290 | Standard_Integer nb = list->Length(); | |
2291 | for (Standard_Integer i = 1; i <= nb; i ++) { | |
2292 | DeclareAndCast(IFSelect_SelectPointed,sp,Item(list->Value(i))); | |
2293 | sp->Update(TC.Control()); | |
2294 | } | |
2295 | return Standard_True; | |
2296 | } | |
2297 | } else if (mode == IFSelect_RemainDisplay) { | |
2298 | Standard_Integer ne = 0; | |
2299 | Standard_Integer nb = thegraph->Graph().Size(); | |
2300 | for (Standard_Integer i = 1; i <= nb; i ++) | |
2301 | { if (thegraph->Graph().Status(i) >= 0) ne ++; } | |
2302 | if (ne == 0) { | |
2303 | sout<<" - All entities are remaining, none yet sent"<<endl; return Standard_True; | |
2304 | } | |
2305 | Interface_EntityIterator iter = SentList(0); | |
2306 | nb = iter.NbEntities(); | |
2307 | if (nb == 0) { | |
2308 | sout<<" - No recorded remaining entities"<<endl; return Standard_True; | |
2309 | } | |
2310 | sout <<" -- Recorded Remaining (not yet sent) Entities --"<<endl; | |
2311 | ListEntities(iter,2); | |
2312 | sout << " -- Maximum Sending Count (i.e. duplication in files) "<< | |
2313 | MaxSendingCount() << endl; | |
2314 | ||
2315 | /* | |
2316 | sout<< " - Now, dispatches are deactivated"<<endl; | |
2317 | nb = theshareout->NbDispatches(); | |
2318 | for (Standard_Integer i = nb; i > theshareout->LastRun(); i --) | |
2319 | theshareout->RemoveDispatch(i); | |
2320 | */ | |
2321 | return Standard_True; | |
2322 | } else if (mode == IFSelect_RemainUndo) { | |
2323 | if (theoldel.IsNull()) return Standard_False; | |
2324 | SetModel(theoldel); theoldel.Nullify(); | |
2325 | return Standard_True; | |
2326 | } | |
2327 | else return Standard_False; | |
2328 | } | |
2329 | ||
2330 | ||
2331 | //======================================================================= | |
2332 | //function : | |
2333 | //purpose : | |
2334 | //======================================================================= | |
2335 | ||
2336 | IFSelect_ReturnStatus IFSelect_WorkSession::SendAll | |
2337 | (const Standard_CString filename, const Standard_Boolean computegraph) | |
2338 | { | |
2339 | ////... | |
2340 | Interface_CheckIterator checks; | |
2341 | if (!IsLoaded()) return IFSelect_RetVoid; | |
2342 | if (thelibrary.IsNull()) { | |
2343 | checks.CCheck(0)->AddFail("WorkLibrary undefined"); | |
2344 | thecheckrun = checks; | |
2345 | return IFSelect_RetError; | |
2346 | } | |
2347 | ||
2348 | if (errhand) { | |
2349 | errhand = Standard_False; | |
2350 | try { | |
2351 | OCC_CATCH_SIGNALS | |
2352 | ComputeGraph(computegraph); | |
2353 | checks = thecopier->SendAll(filename,thegraph->Graph(),thelibrary,theprotocol); | |
2354 | } | |
2355 | catch (Standard_Failure) { | |
2356 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2357 | sout<<" **** Interruption SendAll par Exception : ****\n"; | |
2358 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
2359 | sout<<"\n Abandon"<<endl; | |
2360 | errhand = theerrhand; | |
2361 | checks.CCheck(0)->AddFail ("Exception Raised -> Abandon"); | |
2362 | thecheckrun = checks; | |
2363 | return IFSelect_RetFail; | |
2364 | } | |
2365 | } | |
2366 | else checks = thecopier->SendAll(filename,thegraph->Graph(),thelibrary,theprotocol); | |
857ffd5e | 2367 | Handle(Interface_Check) aMainFail = checks.CCheck(0); |
12bf87c5 P |
2368 | if (!aMainFail.IsNull() && aMainFail->HasFailed ()) |
2369 | { | |
bc650d41 | 2370 | return IFSelect_RetStop; |
12bf87c5 | 2371 | } |
7fd59977 | 2372 | if (theloaded.Length() == 0) theloaded.AssignCat(filename); |
2373 | thecheckrun = checks; | |
2374 | if (checks.IsEmpty(Standard_True)) return IFSelect_RetDone; | |
2375 | return IFSelect_RetError; | |
2376 | } | |
2377 | ||
2378 | ||
2379 | //======================================================================= | |
2380 | //function : | |
2381 | //purpose : | |
2382 | //======================================================================= | |
2383 | ||
2384 | IFSelect_ReturnStatus IFSelect_WorkSession::SendSelected | |
2385 | (const Standard_CString filename, | |
2386 | const Handle(IFSelect_Selection)& sel, | |
2387 | const Standard_Boolean computegraph) | |
2388 | { | |
2389 | ////... | |
2390 | if (!IsLoaded()) return IFSelect_RetVoid; | |
2391 | Interface_CheckIterator checks; | |
2392 | if (thelibrary.IsNull()) { | |
2393 | checks.CCheck(0)->AddFail("WorkLibrary undefined"); | |
2394 | thecheckrun = checks; | |
2395 | return IFSelect_RetVoid; | |
2396 | } | |
2397 | ||
2398 | if (errhand) { | |
2399 | errhand = Standard_False; | |
2400 | try { | |
2401 | OCC_CATCH_SIGNALS | |
2402 | ComputeGraph(computegraph); | |
2403 | return SendSelected (filename,sel); // appel normal | |
2404 | } | |
2405 | catch (Standard_Failure) { | |
2406 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2407 | sout<<" **** Interruption SendSelected par Exception : ****\n"; | |
2408 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
2409 | sout<<"\n Abandon"<<endl; | |
2410 | checks.CCheck(0)->AddFail ("Exception Raised -> Abandon"); | |
2411 | errhand = theerrhand; | |
2412 | thecheckrun = checks; | |
2413 | return IFSelect_RetFail; | |
2414 | } | |
2415 | } | |
2416 | // if (ItemIdent(sel) == 0) return 3; | |
2417 | Interface_EntityIterator iter = sel->UniqueResult(thegraph->Graph()); | |
2418 | if (iter.NbEntities() == 0) return IFSelect_RetVoid; | |
2419 | ||
2420 | checks = thecopier->SendSelected | |
2421 | (filename,thegraph->Graph(),thelibrary,theprotocol,iter); | |
2422 | thecopier->SetRemaining (thegraph->CGraph()); | |
2423 | thecheckrun = checks; | |
2424 | if (checks.IsEmpty(Standard_True)) return IFSelect_RetDone; | |
2425 | return IFSelect_RetError; | |
2426 | } | |
2427 | ||
2428 | ||
2429 | //======================================================================= | |
2430 | //function : | |
2431 | //purpose : | |
2432 | //======================================================================= | |
2433 | ||
2434 | IFSelect_ReturnStatus IFSelect_WorkSession::WriteFile | |
2435 | (const Standard_CString filename) | |
2436 | { | |
2437 | if (WorkLibrary().IsNull()) return IFSelect_RetVoid; | |
2438 | ComputeGraph(Standard_True); | |
2439 | if (!IsLoaded()) return IFSelect_RetVoid; | |
2440 | return SendAll (filename); | |
2441 | } | |
2442 | ||
2443 | ||
2444 | //======================================================================= | |
2445 | //function : | |
2446 | //purpose : | |
2447 | //======================================================================= | |
2448 | ||
2449 | IFSelect_ReturnStatus IFSelect_WorkSession::WriteFile | |
2450 | (const Standard_CString filename, const Handle(IFSelect_Selection)& sel) | |
2451 | { | |
2452 | if (WorkLibrary().IsNull() || sel.IsNull()) return IFSelect_RetVoid; | |
2453 | ComputeGraph(Standard_True); | |
2454 | if (!IsLoaded()) return IFSelect_RetVoid; | |
2455 | return SendSelected (filename,sel); | |
2456 | } | |
2457 | ||
2458 | // ################################################################ | |
2459 | // .... Actions particulieres sur les Selections .... | |
2460 | ||
2461 | //======================================================================= | |
2462 | //function : | |
2463 | //purpose : | |
2464 | //======================================================================= | |
2465 | ||
2466 | Standard_Integer IFSelect_WorkSession::NbSources | |
2467 | (const Handle(IFSelect_Selection)& sel) const | |
2468 | { | |
2469 | if (ItemIdent(sel) == 0) return 0; | |
2470 | if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectExtract)) || | |
2471 | sel->IsKind(STANDARD_TYPE(IFSelect_SelectDeduct)) ) return 1; | |
2472 | if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectControl)) ) return 2; | |
2473 | if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectCombine)) ) return | |
2474 | GetCasted(IFSelect_SelectCombine,sel)->NbInputs(); | |
2475 | return 0; | |
2476 | } | |
2477 | ||
2478 | ||
2479 | //======================================================================= | |
2480 | //function : | |
2481 | //purpose : | |
2482 | //======================================================================= | |
2483 | ||
2484 | Handle(IFSelect_Selection) IFSelect_WorkSession::Source | |
2485 | (const Handle(IFSelect_Selection)& sel, const Standard_Integer num) const | |
2486 | { | |
2487 | Handle(IFSelect_Selection) sr; | |
2488 | if (ItemIdent(sel) == 0) return sr; | |
2489 | if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectExtract)) ) sr = | |
2490 | GetCasted(IFSelect_SelectExtract,sel)->Input(); | |
2491 | else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectDeduct)) ) sr = | |
2492 | GetCasted(IFSelect_SelectDeduct,sel)->Input(); | |
2493 | else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectControl)) ) { | |
2494 | if (num == 1) sr = GetCasted(IFSelect_SelectControl,sel)->MainInput(); | |
2495 | else if (num == 2) sr = GetCasted(IFSelect_SelectControl,sel)->SecondInput(); | |
2496 | } | |
2497 | else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectCombine)) ) sr = | |
2498 | GetCasted(IFSelect_SelectCombine,sel)->Input(num); | |
2499 | return sr; | |
2500 | } | |
2501 | ||
2502 | ||
2503 | //======================================================================= | |
2504 | //function : | |
2505 | //purpose : | |
2506 | //======================================================================= | |
2507 | ||
2508 | Standard_Boolean IFSelect_WorkSession::IsReversedSelectExtract | |
2509 | (const Handle(IFSelect_Selection)& sel) const | |
2510 | { | |
2511 | if (ItemIdent(sel) == 0) return Standard_False; | |
2512 | DeclareAndCast(IFSelect_SelectExtract,sxt,sel); | |
2513 | if (sxt.IsNull()) return Standard_False; | |
2514 | return (!sxt->IsDirect()); | |
2515 | } | |
2516 | ||
2517 | ||
2518 | //======================================================================= | |
2519 | //function : | |
2520 | //purpose : | |
2521 | //======================================================================= | |
2522 | ||
2523 | Standard_Boolean IFSelect_WorkSession::ToggleSelectExtract | |
2524 | (const Handle(IFSelect_Selection)& sel) | |
2525 | { | |
2526 | if (ItemIdent(sel) == 0) return Standard_False; | |
2527 | DeclareAndCast(IFSelect_SelectExtract,sxt,sel); | |
2528 | if (sxt.IsNull()) return Standard_False; | |
2529 | sxt->SetDirect(!sxt->IsDirect()); | |
2530 | return Standard_True; | |
2531 | } | |
2532 | ||
2533 | ||
2534 | //======================================================================= | |
2535 | //function : | |
2536 | //purpose : | |
2537 | //======================================================================= | |
2538 | ||
2539 | Standard_Boolean IFSelect_WorkSession::SetInputSelection | |
2540 | (const Handle(IFSelect_Selection)& sel, | |
2541 | const Handle(IFSelect_Selection)& inp) | |
2542 | { | |
2543 | if (ItemIdent(sel) == 0) return Standard_False; | |
2544 | if (!inp.IsNull() && ItemIdent(inp) == 0) return Standard_False; | |
2545 | DeclareAndCast(IFSelect_SelectExtract,sxt,sel); | |
2546 | if (!sxt.IsNull()) { sxt->SetInput(inp); return Standard_True; } | |
2547 | DeclareAndCast(IFSelect_SelectDeduct,sdt,sel); | |
2548 | if (!sdt.IsNull()) { sdt->SetInput(inp); return Standard_True; } | |
2549 | return Standard_False; | |
2550 | } | |
2551 | ||
2552 | ||
2553 | //======================================================================= | |
2554 | //function : | |
2555 | //purpose : | |
2556 | //======================================================================= | |
2557 | ||
2558 | Standard_Boolean IFSelect_WorkSession::SetControl | |
2559 | (const Handle(IFSelect_Selection)& sel, | |
2560 | const Handle(IFSelect_Selection)& sc, | |
2561 | const Standard_Boolean formain) | |
2562 | { | |
2563 | DeclareAndCast(IFSelect_SelectControl,dsel,sel); | |
2564 | if (ItemIdent(dsel) == 0) return Standard_False; | |
2565 | if (ItemIdent(sc) == 0) return Standard_False; | |
2566 | if (formain) dsel->SetMainInput (sc); | |
2567 | else dsel->SetSecondInput (sc); | |
2568 | return Standard_True; | |
2569 | } | |
2570 | ||
2571 | ||
2572 | //======================================================================= | |
2573 | //function : | |
2574 | //purpose : | |
2575 | //======================================================================= | |
2576 | ||
2577 | Standard_Integer IFSelect_WorkSession::CombineAdd | |
2578 | (const Handle(IFSelect_Selection)& sel, | |
2579 | const Handle(IFSelect_Selection)& seladd, | |
2580 | const Standard_Integer atnum) | |
2581 | { | |
2582 | DeclareAndCast(IFSelect_SelectCombine,csel,sel); | |
2583 | if (ItemIdent(csel) == 0) return 0; | |
2584 | if (ItemIdent(seladd) == 0) return 0; | |
2585 | csel->Add (seladd,atnum); | |
2586 | return csel->NbInputs(); | |
2587 | } | |
2588 | ||
2589 | ||
2590 | //======================================================================= | |
2591 | //function : | |
2592 | //purpose : | |
2593 | //======================================================================= | |
2594 | ||
2595 | Standard_Boolean IFSelect_WorkSession::CombineRemove | |
2596 | (const Handle(IFSelect_Selection)& selcomb, | |
2597 | const Handle(IFSelect_Selection)& selrem) | |
2598 | { | |
2599 | DeclareAndCast(IFSelect_SelectCombine,csel,selcomb); | |
2600 | if (ItemIdent(csel) == 0) return Standard_False; | |
2601 | if (ItemIdent(selrem) == 0) return Standard_False; | |
2602 | Standard_Integer nb = csel->NbInputs(); | |
2603 | for (Standard_Integer i = nb; i > 0; i --) { | |
2604 | if (csel->Input(i) == selrem) { | |
2605 | csel->Remove(i); | |
2606 | return Standard_True; | |
2607 | } | |
2608 | } | |
2609 | return Standard_True; | |
2610 | } | |
2611 | ||
2612 | ||
2613 | //======================================================================= | |
2614 | //function : | |
2615 | //purpose : | |
2616 | //======================================================================= | |
2617 | ||
2618 | Handle(IFSelect_Selection) IFSelect_WorkSession::NewSelectPointed | |
2619 | (const Handle(TColStd_HSequenceOfTransient)& list, | |
2620 | const Standard_CString name) | |
2621 | { | |
2622 | Handle(IFSelect_SelectPointed) sel = new IFSelect_SelectPointed; | |
2623 | if (!list.IsNull()) sel->AddList (list); | |
2624 | if (AddNamedItem (name,sel) == 0) sel.Nullify(); | |
2625 | return sel; | |
2626 | } | |
2627 | ||
2628 | ||
2629 | //======================================================================= | |
2630 | //function : | |
2631 | //purpose : | |
2632 | //======================================================================= | |
2633 | ||
2634 | Standard_Boolean IFSelect_WorkSession::SetSelectPointed | |
2635 | (const Handle(IFSelect_Selection)& sel, | |
2636 | const Handle(TColStd_HSequenceOfTransient)& list, | |
2637 | const Standard_Integer mode) const | |
2638 | { | |
2639 | DeclareAndCast(IFSelect_SelectPointed,sp,sel); | |
2640 | if (sp.IsNull() || list.IsNull()) return Standard_False; | |
2641 | if (mode == 0) sp->Clear(); | |
2642 | if (mode >= 0) sp->AddList(list); | |
2643 | else sp->RemoveList(list); | |
2644 | return Standard_True; | |
2645 | } | |
2646 | ||
2647 | ||
2648 | // ########################################################################### | |
2649 | // .... Analyse d un CheckIterator par rapport a un graphe .... | |
2650 | ||
2651 | //======================================================================= | |
2652 | //function : | |
2653 | //purpose : | |
2654 | //======================================================================= | |
2655 | ||
2656 | static void IFSelect_QueryProp (Interface_IntList& list, | |
2657 | TCollection_AsciiString& ana, | |
2658 | const Standard_Integer num, const int quoi) | |
2659 | { | |
2660 | list.SetNumber(num); | |
2661 | Standard_Integer i, nb = list.Length(); | |
2662 | for (i = 1; i <= nb; i ++) { | |
2663 | if (i > 1) list.SetNumber(num); // because recursive call + depth first | |
2664 | Standard_Integer n = list.Value(i); | |
2665 | // y a t il lieu de propager ? | |
2666 | // 1 W/place 2 F/place 3 Wprop 4Wprop+W/place 5Wprop+F/place | |
2667 | // 6 Fprop 7 Fprop+W/place 8 Fprop+F/place | |
2668 | char val = ana.Value(n); | |
2669 | switch (val) { | |
2670 | case ' ' : val = (quoi ? '3' : '6'); break; | |
2671 | case '1' : val = (quoi ? '4' : '7'); break; | |
2672 | case '2' : val = (quoi ? '5' : '8'); break; | |
2673 | case '3' : val = (quoi ? ' ' : '6'); break; | |
2674 | case '4' : val = (quoi ? ' ' : '7'); break; | |
2675 | case '5' : val = (quoi ? ' ' : '8'); break; | |
2676 | case '6' : val = ' '; break; | |
2677 | case '7' : val = ' '; break; | |
2678 | case '8' : val = ' '; break; | |
2679 | default : val = ' '; break; | |
2680 | } | |
2681 | if (val == ' ') continue; | |
2682 | ana.SetValue(n,val); | |
2683 | IFSelect_QueryProp (list,ana,n,quoi); | |
2684 | } | |
2685 | } | |
2686 | ||
2687 | ||
2688 | //======================================================================= | |
2689 | //function : | |
2690 | //purpose : | |
2691 | //======================================================================= | |
2692 | ||
2693 | void IFSelect_WorkSession::QueryCheckList (const Interface_CheckIterator& chl) | |
2694 | { | |
2695 | if (!IsLoaded()) return; | |
7f56eba8 | 2696 | Standard_Integer i,nb = myModel->NbEntities(); |
4e76d93b | 2697 | thecheckana = TCollection_AsciiString (nb+1,' '); |
7fd59977 | 2698 | for (chl.Start(); chl.More(); chl.Next()) { |
2699 | Standard_Integer num = chl.Number(); | |
2700 | const Handle(Interface_Check) ach = chl.Value(); | |
2701 | if (ach->HasFailed()) thecheckana.SetValue(num,'2'); | |
2702 | else if (ach->HasWarnings()) thecheckana.SetValue(num,'1'); | |
2703 | } | |
2704 | // analyse selon le graphe ... codes : blc = rien | |
2705 | // 1 W/place 2 F/place 3 Wprop 4Wprop+W/place 5Wprop+F/place | |
2706 | // 6 Fprop 7 Fprop+W/place 8 Fprop+F/place | |
bc650d41 | 2707 | Interface_IntList list;// = thegraph->Graph().SharingNums(0); |
7fd59977 | 2708 | // deux passes : d abord Warning, puis Fail |
2709 | for (i = 1; i <= nb; i ++) { | |
2710 | char val = thecheckana.Value(i); | |
2711 | int quoi = -1; | |
2712 | if (val == '1' || val == '4' || val == '7') quoi = 0; | |
2713 | if (quoi >= 0) IFSelect_QueryProp (list,thecheckana,i,quoi); | |
2714 | } | |
2715 | for (i = 1; i <= nb; i ++) { | |
2716 | char val = thecheckana.Value(i); | |
2717 | int quoi = -1; | |
2718 | if (val == '2' || val == '5' || val == '8') quoi = 1; | |
2719 | if (quoi >= 0) IFSelect_QueryProp (list,thecheckana,i,quoi); | |
2720 | } | |
2721 | } | |
2722 | ||
2723 | ||
2724 | //======================================================================= | |
2725 | //function : | |
2726 | //purpose : | |
2727 | //======================================================================= | |
2728 | ||
2729 | Standard_Integer IFSelect_WorkSession::QueryCheckStatus | |
2730 | (const Handle(Standard_Transient)& ent) const | |
2731 | { | |
2732 | if (!IsLoaded()) return -1; | |
7f56eba8 | 2733 | Standard_Integer num = myModel->Number(ent); |
7fd59977 | 2734 | if (num == 0) return -1; |
2735 | if (thecheckana.Length() < num) return -1; | |
2736 | Standard_Character val = thecheckana.Value (num); | |
2737 | // codes : blc = rien -> 0 | |
2738 | // 1 W/place -> 1 2 F/place -> 2 | |
2739 | // 3 Wprop -> 10 4 Wprop+W/place -> 11 5 Wprop+F/place -> 12 | |
2740 | // 6 Fprop -> 20 7 Fprop+W/place -> 21 8 Fprop+F/place -> 22 | |
2741 | if (val == ' ') return 0; | |
2742 | if (val == '1') return 1; | |
2743 | if (val == '2') return 2; | |
2744 | if (val == '3') return 10; | |
2745 | if (val == '4') return 11; | |
2746 | if (val == '5') return 12; | |
2747 | if (val == '6') return 20; | |
2748 | if (val == '7') return 21; | |
2749 | if (val == '8') return 22; | |
2750 | return 0; | |
2751 | } | |
2752 | ||
2753 | ||
2754 | //======================================================================= | |
2755 | //function : | |
2756 | //purpose : | |
2757 | //======================================================================= | |
2758 | ||
2759 | Standard_Integer IFSelect_WorkSession::QueryParent | |
2760 | (const Handle(Standard_Transient)& entdad, | |
2761 | const Handle(Standard_Transient)& entson) const | |
2762 | { | |
2763 | Standard_Integer ndad = StartingNumber(entdad); | |
2764 | Standard_Integer nson = StartingNumber(entson); | |
2765 | if (ndad < 1 || nson < 1) return -1; | |
2766 | if (ndad == nson) return 0; | |
2767 | // on va calculer : pour chaque pere immediat, de <son>, status avec <dad> + 1 | |
2768 | // nb : pas protege contre les boucles ... | |
2769 | Handle(TColStd_HSequenceOfTransient) list = | |
2770 | thegraph->Graph().Sharings(entson).Content(); | |
2771 | if (list.IsNull()) return -1; | |
2772 | Standard_Integer i, nb = list->Length(); | |
2773 | for (i = 1; i <= nb; i ++) { | |
2774 | if (list->Value(i) == entdad) return 1; | |
2775 | Standard_Integer stat = QueryParent ( entdad,list->Value(i) ); | |
2776 | if (stat >= 0) return stat+1; | |
2777 | } | |
7fd59977 | 2778 | return -1; // not yet implemented ... |
2779 | } | |
2780 | ||
2781 | // ########################################################################### | |
2782 | // .... Dumps et Evaluations, pas faciles a passer en arguments .... | |
2783 | ||
2784 | // #### #### #### #### #### #### #### #### #### | |
2785 | // .... DumpShare .... | |
2786 | ||
2787 | //======================================================================= | |
2788 | //function : | |
2789 | //purpose : | |
2790 | //======================================================================= | |
2791 | ||
2792 | void IFSelect_WorkSession::SetParams | |
7f56eba8 | 2793 | (const NCollection_Vector<Handle(Standard_Transient)>& params, |
2794 | const NCollection_Vector<Standard_Integer>& uselist) | |
7fd59977 | 2795 | { |
2796 | Standard_Integer i, nbp = params.Length(), nbu = uselist.Length(); | |
2797 | Handle(IFSelect_ParamEditor) editor = new IFSelect_ParamEditor | |
2798 | (nbp+nbu+50,"Parameter Editor"); | |
3e64931d | 2799 | for (i = params.Lower(); i <= params.Upper(); i ++) { |
7fd59977 | 2800 | DeclareAndCast(Interface_TypedValue,val,params.Value(i)); |
2801 | if (val.IsNull()) continue; | |
2802 | editor->AddValue(val); | |
2803 | } | |
2804 | AddNamedItem("xst-params-edit",editor); | |
2805 | // Les EditForm | |
2806 | Handle(IFSelect_EditForm) paramsall = editor->Form(Standard_False); | |
2807 | AddNamedItem("xst-params-all",paramsall); | |
2808 | ||
2809 | // On attaque les EditForms partielles | |
2810 | TColStd_SequenceOfInteger listgen,listload,listsend,listsplit,listread,listwrite; | |
3e64931d | 2811 | for (i = uselist.Lower(); i <= uselist.Upper(); i ++) { |
7fd59977 | 2812 | Standard_Integer use = uselist.Value(i); |
2813 | switch (use) { | |
2814 | case 1 : listgen.Append(i); break; | |
2815 | case 2 : listread.Append(i); break; | |
2816 | case 3 : listsend.Append(i); break; | |
2817 | case 4 : listsplit.Append(i); break; | |
2818 | case 5 : listread.Append(i); break; | |
2819 | case 6 : listwrite.Append(i); break; | |
2820 | default : break; | |
2821 | } | |
2822 | } | |
2823 | Handle(IFSelect_EditForm) paramsgen = new IFSelect_EditForm | |
2824 | (editor,listgen ,Standard_False,Standard_True,"General Parameters"); | |
2825 | if (listgen.Length() > 0) AddNamedItem("xst-params-general",paramsgen); | |
2826 | Handle(IFSelect_EditForm) paramsload = new IFSelect_EditForm | |
2827 | (editor,listload,Standard_False,Standard_True,"Loading Parameters"); | |
2828 | if (listload.Length() > 0) AddNamedItem("xst-params-load", paramsload); | |
2829 | Handle(IFSelect_EditForm) paramssend = new IFSelect_EditForm | |
2830 | (editor,listsend,Standard_False,Standard_True,"Sending Parameters"); | |
2831 | if (listsend.Length() > 0) AddNamedItem("xst-params-send", paramssend); | |
2832 | Handle(IFSelect_EditForm) paramsplit = new IFSelect_EditForm | |
2833 | (editor,listsplit,Standard_False,Standard_True,"Split Parameters"); | |
2834 | if (listsplit.Length() > 0) AddNamedItem("xst-params-split", paramsplit); | |
2835 | Handle(IFSelect_EditForm) paramsread = new IFSelect_EditForm | |
2836 | (editor,listread,Standard_False,Standard_True,"Read(Transfer) Parameters"); | |
2837 | if (listread.Length() > 0) AddNamedItem("xst-params-read", paramsread); | |
2838 | Handle(IFSelect_EditForm) paramswrite = new IFSelect_EditForm | |
2839 | (editor,listwrite,Standard_False,Standard_True,"Write(Transfer) Parameters"); | |
2840 | if (listwrite.Length() > 0) AddNamedItem("xst-params-write", paramswrite); | |
2841 | } | |
2842 | ||
2843 | ||
2844 | //======================================================================= | |
2845 | //function : | |
2846 | //purpose : | |
2847 | //======================================================================= | |
2848 | ||
2849 | void IFSelect_WorkSession::TraceStatics | |
2850 | (const Standard_Integer use, const Standard_Integer mode) const | |
2851 | { | |
2852 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2853 | if (use > 0) { | |
2854 | if (mode == 0) sout<<"******************************************"<<endl; | |
2855 | if (use == 1) { | |
2856 | if (mode == 0) sout<<"***** General Parameters *****"<<endl; | |
2857 | } else if (use == 2) { | |
2858 | if (mode == 0) sout<<"***** Load File *****"<<endl; | |
2859 | } else if (use == 3) { | |
2860 | if (mode == 0) sout<<"***** Write File *****"<<endl; | |
2861 | } else if (use == 4) { | |
2862 | if (mode == 0) sout<<"***** Split File *****"<<endl; | |
2863 | } else if (use == 5) { | |
2864 | if (mode == 0) sout<<"***** Transfer (Read) *****"<<endl; | |
2865 | } else if (use == 6) { | |
2866 | if (mode == 0) sout<<"***** Transfer (Write) *****"<<endl; | |
2867 | } | |
2868 | if (mode == 0) sout<<"******************************************"<<endl<<endl; | |
2869 | } | |
2870 | ||
2871 | // Echainements particuliers (use > 0) | |
2872 | if (use == 5) { | |
2873 | TraceStatics (-2,mode); | |
2874 | if (mode == 0) sout<<endl; | |
2875 | } else if (use == 4 || use == 6) { | |
2876 | TraceStatics (-3,mode); | |
2877 | if (mode == 0) sout<<endl; | |
2878 | } | |
2879 | ||
2880 | // Valeurs particulieres | |
2881 | if (use == 1 || use == -1) { // General : trace | |
2882 | if (mode == 0) { | |
2883 | // sout << "Trace Level : "<<Message_PrinterOStream::Default()->GetTraceLevel()<<endl; | |
2884 | } | |
2885 | } else if (use == 4 || use == -4) { // Split : Prefix & cie | |
2886 | if (mode == 0) { | |
2887 | Handle(TCollection_HAsciiString) str = theshareout->Prefix(); | |
2888 | if (!str.IsNull()) sout << "Prefix : "<<str->ToCString()<<endl; | |
2889 | else sout << "Prefix not Defined" << endl; | |
2890 | str = theshareout->DefaultRootName(); | |
2891 | if (!str.IsNull()) sout << "Default Root : "<<str->ToCString()<<endl; | |
2892 | else sout << "Default Root not Defined" << endl; | |
2893 | str = theshareout->Extension(); | |
2894 | if (!str.IsNull()) sout << "Extension : "<<str->ToCString()<<endl; | |
2895 | else sout << "Extension not defined" << endl; | |
2896 | } | |
2897 | } | |
2898 | ||
2899 | // LISTER LES STATICS | |
2900 | // Passer par les ParamEditor ... | |
2901 | ||
2902 | // Fin | |
2903 | if (use > 0) { | |
2904 | if (mode == 0) sout<<"******************************************"<<endl<<endl; | |
2905 | } | |
2906 | } | |
2907 | ||
2908 | ||
2909 | //======================================================================= | |
2910 | //function : | |
2911 | //purpose : | |
2912 | //======================================================================= | |
2913 | ||
2914 | void IFSelect_WorkSession::DumpShare () const | |
2915 | { | |
2916 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2917 | sout<<" ********** Definition ShareOut (Complete) **********"<<endl; | |
2918 | ||
2919 | Handle(TCollection_HAsciiString) str = theshareout->Prefix(); | |
2920 | if (!str.IsNull()) sout << "Prefix : " << str->ToCString() << endl; | |
2921 | else sout << "Prefix not Defined" << endl; | |
2922 | str = theshareout->DefaultRootName(); | |
2923 | if (!str.IsNull()) sout << "Default Root : " << str->ToCString() << endl; | |
2924 | else sout << "Default Root not Defined" << endl; | |
2925 | str = theshareout->Extension(); | |
2926 | if (!str.IsNull()) sout << "Extension : " << str->ToCString() << endl; | |
2927 | else sout << "Extension not defined" << endl; | |
2928 | ||
2929 | Standard_Integer lr = theshareout->LastRun(); | |
2930 | Standard_Integer nb = theshareout->NbDispatches(); | |
2931 | sout << "Nb Dispatches : " << nb <<" (Last Run : " << lr << ") : "<<endl; | |
2932 | for (Standard_Integer i = 1; i <= nb; i ++) { | |
2933 | Handle(IFSelect_Dispatch) disp = theshareout->Dispatch(i); | |
2934 | sout << "Dispatch n0 " << i; | |
2935 | if (HasName(disp)) sout << " Name:"<< Name(disp)->ToCString(); | |
2936 | sout << " Label:" << disp->Label() << endl; | |
2937 | Handle(IFSelect_Selection) sel = disp->FinalSelection(); | |
2938 | if (sel.IsNull()) sout << " No Final Selection Defined" << endl; | |
2939 | else if (HasName(sel)) sout << " Final Selection : Name:" | |
2940 | << Name(sel)->ToCString() << " Label:" << sel->Label() << endl; | |
2941 | else sout << " Final Selection : " << sel->Label() << endl; | |
2942 | if (disp->HasRootName()) | |
2943 | sout<<" File Root Name : "<<disp->RootName()->ToCString()<<endl; | |
2944 | else sout<<" No specific file root name (see Default Root)"<<endl; | |
2945 | } | |
2946 | Standard_Integer nbm = theshareout->NbModifiers(Standard_True); | |
2947 | if (nbm > 0) sout<< | |
2948 | " *** "<<nbm<<" active Model Modifiers : see ListModifiers ***"<<endl; | |
2949 | Standard_Integer nbf = theshareout->NbModifiers(Standard_False); | |
2950 | if (nbf > 0) sout<< | |
2951 | " *** "<<nbf<<" active File Modifiers : see ListModifiers ***"<<endl; | |
2952 | if (nbm+nbf == 0) sout<<" *** No active Modifiers ***"<<endl; | |
2953 | } | |
2954 | ||
2955 | // #### #### #### #### #### #### #### #### #### | |
2956 | // .... ListItems .... | |
2957 | ||
2958 | //======================================================================= | |
2959 | //function : | |
2960 | //purpose : | |
2961 | //======================================================================= | |
2962 | ||
2963 | void IFSelect_WorkSession::ListItems (const Standard_CString lab) const | |
2964 | { | |
2965 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2966 | sout<< " ********** Items in Session **********"<<endl; | |
2967 | Standard_Integer nb = MaxIdent(); | |
2968 | Handle(TCollection_HAsciiString) str; | |
2969 | if (lab[0] != '\0') str = new TCollection_HAsciiString (lab); | |
2970 | for (Standard_Integer i = 1; i <= nb; i ++) { | |
2971 | const Handle(Standard_Transient)& var = theitems.FindKey(i); | |
2972 | Handle(TCollection_HAsciiString) label = ItemLabel(i); | |
2973 | if (label.IsNull()) continue; // -> item supprime | |
2974 | if (!str.IsNull()) { if (label->Location(str,1,label->Length()) == 0) continue; } | |
2975 | sout<<"#"<<i; | |
2976 | if (HasName(var)) sout<<" - Named : "<<Name(var)->ToCString()<<" - "; | |
2977 | else sout<<" - (no name) - "; | |
2978 | sout<<var->DynamicType()->Name()<<endl<<" "<<label->ToCString()<<endl; | |
2979 | } | |
2980 | } | |
2981 | ||
2982 | // #### #### #### #### #### #### #### #### #### | |
2983 | // .... ListModifiers | |
2984 | ||
2985 | //======================================================================= | |
2986 | //function : | |
2987 | //purpose : | |
2988 | //======================================================================= | |
2989 | ||
2990 | void IFSelect_WorkSession::ListFinalModifiers | |
2991 | (const Standard_Boolean formodel) const | |
2992 | { | |
2993 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
2994 | Standard_Integer nb = theshareout->NbModifiers(formodel); | |
2995 | sout<< " ********** Modifiers in Session "; | |
2996 | sout<<(formodel ? "(For Model)" : "(For File)"); | |
2997 | sout<<": "<<nb<<" **********"<<endl; | |
2998 | for (Standard_Integer i = 1; i <= nb; i ++) { | |
2999 | Handle(IFSelect_GeneralModifier) modif = | |
3000 | theshareout->GeneralModifier(formodel,i); | |
3001 | if (!modif.IsNull()) sout<<"Modifier n0."<<i<<" : "<<modif->Label(); | |
3002 | if (HasName(modif)) sout << " Named as : " << Name(modif)->ToCString(); | |
3003 | sout<<endl; | |
3004 | } | |
3005 | } | |
3006 | ||
3007 | // #### #### #### #### #### #### #### #### #### | |
3008 | // .... DumpSelection .... | |
3009 | ||
3010 | //======================================================================= | |
3011 | //function : | |
3012 | //purpose : | |
3013 | //======================================================================= | |
3014 | ||
3015 | void IFSelect_WorkSession::DumpSelection | |
3016 | (const Handle(IFSelect_Selection)& sel) const | |
3017 | { | |
3018 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
3019 | if (ItemIdent(sel) == 0) { | |
586db386 | 3020 | sout << "Selection : Unknown"<<endl; //sout<<Handle |
7fd59977 | 3021 | return; |
3022 | } | |
3023 | sout << " ********** Selection"; | |
3024 | if (HasName(sel)) sout << " , Name : " << Name(sel)->ToCString(); | |
3025 | sout <<" **********"<<endl; | |
3026 | sout<< "Label : " << sel->Label() << " . Input(s) : "<< endl; | |
3027 | Standard_Integer nb = 0; | |
3028 | IFSelect_SelectionIterator iter; sel->FillIterator(iter); | |
3029 | for (; iter.More(); iter.Next()) { | |
3030 | nb ++; | |
3031 | Handle(IFSelect_Selection) newsel = iter.Value(); | |
3032 | sout<<" -- "<<newsel->Label()<<endl; | |
3033 | } | |
3034 | sout << " Nb Inputs:"<<nb<<endl; | |
3035 | } | |
3036 | ||
3037 | ||
3038 | // ########################################## | |
3039 | // ######### Fonctions complementaires | |
3040 | // ########################################## | |
3041 | ||
3042 | // #### #### #### #### #### #### #### #### #### | |
3043 | // .... DumpModel .... | |
3044 | ||
3045 | //======================================================================= | |
3046 | //function : | |
3047 | //purpose : | |
3048 | //======================================================================= | |
3049 | ||
3050 | Handle(IFSelect_Selection) IFSelect_WorkSession::GiveSelection | |
3051 | (const Standard_CString selname) const | |
3052 | { | |
3053 | char nomsel[500]; | |
3054 | Standard_Integer np = -1, nf = -1, nivp = 0; | |
3055 | for (Standard_Integer n = 0; selname[n] != '\0'; n ++) { | |
3056 | nomsel[n] = selname[n]; nomsel[n+1] = '\0'; | |
3057 | if (selname[n] == '(') { np = n; nivp ++; } | |
3058 | if (selname[n] == ')') { nivp --; if (nivp <= 0) nf = n; } | |
3059 | //// if (selname[n] == ' ') { nb = n; break; } | |
3060 | } | |
3061 | ||
3062 | Handle(IFSelect_Selection) sel; | |
3063 | if (np >= 0) nomsel[np] = 0; if (nf >= 0) nomsel[nf] = '\0'; | |
3064 | Handle(Standard_Transient) item = NamedItem(nomsel); | |
3065 | ||
3066 | // Parentheses ? essayer Signature (plus tard : Selection parametree) | |
3067 | // NB : on compte les niveaux de parentheses (imbrications repercutees) | |
3068 | if (np > 0 && nf > 0) { | |
3069 | Handle(IFSelect_SelectSignature) selsign; | |
3070 | Standard_Integer debsign = np+1; | |
3071 | ||
3072 | DeclareAndCast(IFSelect_Signature,sign,item); | |
3073 | DeclareAndCast(IFSelect_SignCounter,cnt,item); | |
3074 | if (!sign.IsNull()) selsign = | |
3075 | new IFSelect_SelectSignature (sign,&nomsel[debsign],Standard_False); | |
3076 | else if (!cnt.IsNull()) selsign = | |
3077 | new IFSelect_SelectSignature (cnt,&nomsel[debsign],Standard_False); | |
3078 | else { | |
3079 | cout<<selname<<" : neither Signature nor Counter"<<endl; | |
3080 | return sel; | |
3081 | } | |
3082 | ||
3083 | selsign->SetInput (new IFSelect_SelectModelEntities); // par defaut | |
3084 | sel = selsign; | |
3085 | } | |
3086 | ||
3087 | else sel = GetCasted(IFSelect_Selection,item); | |
3088 | ||
3089 | return sel; | |
3090 | } | |
3091 | ||
3092 | ||
3093 | //======================================================================= | |
3094 | //function : | |
3095 | //purpose : | |
3096 | //======================================================================= | |
3097 | ||
3098 | Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveList | |
3099 | (const Handle(Standard_Transient)& obj) const | |
3100 | { | |
3101 | // Deja une liste | |
3102 | DeclareAndCast(TColStd_HSequenceOfTransient,list,obj); | |
3103 | if (!list.IsNull()) return list; | |
3104 | ||
3105 | // Rien du tout : retourne rien du tout | |
3106 | if (obj.IsNull()) return list; | |
3107 | ||
3108 | // Une selection : son resultat (standard) | |
3109 | DeclareAndCast(IFSelect_Selection,sel,obj); | |
3110 | if (!sel.IsNull()) { | |
3111 | Interface_EntityIterator iter = EvalSelection(sel); | |
3112 | return iter.Content(); | |
3113 | } | |
3114 | ||
3115 | // Le modele : son contenu | |
3116 | list = new TColStd_HSequenceOfTransient(); | |
7f56eba8 | 3117 | if (obj == myModel) { |
3118 | Standard_Integer i, nb = myModel->NbEntities(); | |
3119 | for (i = 1; i <= nb; i ++) list->Append (myModel->Value(i)); | |
7fd59977 | 3120 | } |
3121 | ||
3122 | // Une entite du modele : cette entite | |
3123 | else if (StartingNumber(obj) > 0) list->Append (obj); | |
3124 | ||
3125 | // Un Texte : son interpretation | |
3126 | else { | |
3127 | DeclareAndCast(TCollection_HAsciiString,str,obj); | |
3128 | if (!str.IsNull()) return GiveList (str->ToCString()); | |
3129 | } | |
3130 | ||
3131 | // Si c est pas tout ca : une liste vide | |
3132 | return list; | |
3133 | } | |
3134 | ||
3135 | ||
3136 | //======================================================================= | |
3137 | //function : | |
3138 | //purpose : | |
3139 | //======================================================================= | |
3140 | ||
3141 | Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveList | |
3142 | (const Standard_CString first, const Standard_CString second) const | |
3143 | { | |
3144 | Handle(TColStd_HSequenceOfTransient) list; | |
3145 | if (!first || first[0] == '\0') return list; | |
3146 | if (first[0] == ' ') return GiveList (&first[1],second); | |
3147 | if (second && second[0] == ' ') return GiveList (first,&second[1]); | |
3148 | ||
3149 | // list NULLE sera interpretee comme SelectionResult (selection toute crue) | |
3150 | // sinon comme SelectionResultFromList | |
3151 | if (second && second[0] != '\0') list = GiveList (second,""); | |
3152 | ||
3153 | list = GiveListFromList (first,list); | |
3154 | return list; | |
3155 | } | |
3156 | ||
3157 | ||
3158 | //======================================================================= | |
3159 | //function : | |
3160 | //purpose : | |
3161 | //======================================================================= | |
3162 | ||
3163 | Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveListFromList | |
3164 | (const Standard_CString selname, const Handle(Standard_Transient)& ent) const | |
3165 | { | |
3166 | Handle(TColStd_HSequenceOfTransient) list; | |
3167 | Standard_Integer num; | |
3168 | ||
3169 | // LISTE DEFINIE D OFFICE (en ce cas, la liste d entree est ignoree) | |
3170 | if (selname[0] == '(') { | |
3171 | // liste d entites donnees a la queue leu leu : (ID,ID,ID...) | |
3172 | char entid[50]; Standard_Integer i,j = 0; | |
3173 | TColStd_MapOfInteger numap; | |
3174 | list = new TColStd_HSequenceOfTransient(); | |
3175 | for (i = 1; selname[i] != '\0'; i ++) { | |
3176 | if (selname[i] == ' ') continue; | |
3177 | if (selname[i] == ',' || selname[i] == ')') { | |
3178 | entid[j] = '\0'; | |
3179 | if (j == 0) continue; j = 0; | |
3180 | num = NumberFromLabel (entid); | |
3181 | if (num <= 0 || !numap.Add (num)) continue; | |
3182 | Handle(Standard_Transient) anent = StartingEntity(num); | |
3183 | if (!anent.IsNull()) list->Append (anent); | |
3184 | if (selname[i] == ')') break; | |
3185 | continue; | |
3186 | } | |
3187 | entid[j] = selname[i]; j ++; | |
3188 | } | |
3189 | return list; | |
3190 | } | |
3191 | num = NumberFromLabel (selname); | |
3192 | if (num > 0) return GiveList(StartingEntity(num)); | |
3193 | ||
3194 | // Autres cas : y atil une liste d entree. | |
3195 | // Si OUI -> SelectionResultFromList. Si NON -> SelectionResult | |
3196 | // Si une entite isolee -> on en fait une liste | |
3197 | ||
3198 | list = GiveList(ent); // ent NULL -> list NULL sinon intreprete | |
3199 | ||
3200 | // Decomposition term1 term2 ... | |
3201 | ||
3202 | char nomsel[500]; nomsel[0] = '\0'; | |
3203 | Standard_Integer n= 0 , nb = -1; | |
3204 | for (n = 0; selname[n] != '\0'; n ++) { | |
3205 | nomsel[n] = selname[n]; nomsel[n+1] = '\0'; | |
3206 | // if (selname[n] == '(') { np = n; nivp ++; } | |
3207 | // if (selname[n] == ')') { nivp --; if (nivp <= 0) nf = n; } | |
3208 | if (selname[n] == ' ') { nb = n; nomsel[n] = '\0'; break; } | |
3209 | } | |
3210 | if (nomsel[0] == '\0') return list; | |
3211 | ||
3212 | Handle(IFSelect_Selection) sel = GiveSelection (nomsel); | |
3213 | if (sel.IsNull()) { | |
3214 | cout<<"Neither Entity Number/Label nor Selection :"<<nomsel<<endl; | |
3215 | return list; | |
3216 | } | |
3217 | ||
3218 | if (nb > 0) list = GiveListFromList (&selname[nb+1],list); | |
3219 | ||
3220 | if (list.IsNull()) list = SelectionResult (sel); | |
3221 | else list = SelectionResultFromList (sel,list); | |
3222 | ||
3223 | return list; | |
3224 | } | |
3225 | ||
3226 | ||
3227 | //======================================================================= | |
3228 | //function : | |
3229 | //purpose : | |
3230 | //======================================================================= | |
3231 | ||
3232 | Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveListCombined | |
3233 | (const Handle(TColStd_HSequenceOfTransient)& l1, | |
3234 | const Handle(TColStd_HSequenceOfTransient)& l2, | |
3235 | const Standard_Integer mode) const | |
3236 | { | |
3237 | Handle(TColStd_HSequenceOfTransient) list; | |
3238 | if (l1.IsNull() || l2.IsNull()) return list; | |
3239 | ||
3240 | // mode < 0 l1-l2 = 0 l1&l2 > 0 l1|l2 (l1+l2) | |
3241 | TColStd_MapOfTransient numap; | |
3242 | Standard_Integer i,n = l2->Length(); | |
3243 | for (i = n; i > 0; i --) { | |
3244 | Handle(Standard_Transient) ent = l2->Value(i); | |
3245 | if (ent.IsNull()) continue; | |
3246 | numap.Add (ent); | |
3247 | if (mode > 0) list->Append(ent); | |
3248 | } | |
3249 | ||
3250 | // ents de l1 pas deja dans l2 | |
3251 | n = l1->Length(); | |
3252 | for (i = n; i > 0; i --) { | |
3253 | Handle(Standard_Transient) ent = l1->Value(i); | |
3254 | if (ent.IsNull()) continue; | |
3255 | ||
3256 | if (numap.Contains(ent)) { | |
3257 | // dans l1 et dans l2 | |
3258 | if (mode == 0) list->Append(ent); | |
3259 | } else { | |
3260 | // dans l1 mais pas dans l2 | |
3261 | if (mode != 0) list->Append(ent); | |
3262 | } | |
3263 | } | |
3264 | ||
3265 | list->Reverse(); | |
3266 | return list; | |
3267 | } | |
3268 | ||
3269 | ||
3270 | //======================================================================= | |
3271 | //function : | |
3272 | //purpose : | |
3273 | //======================================================================= | |
3274 | ||
3275 | void IFSelect_WorkSession::DumpModel | |
3276 | (const Standard_Integer level, const Handle(Message_Messenger)& S) | |
3277 | { | |
3278 | if (!IsLoaded()) | |
3279 | { S<< " *** Data for List not available ***"<<endl; return; } | |
3280 | S << "\n *****************************************************************\n"; | |
3281 | if (theloaded.Length() > 0) | |
3282 | S << " ******** Loaded File : "<<theloaded.ToCString()<<Interface_MSG::Blanks(32-theloaded.Length())<<" ********"<<endl; | |
3283 | else S << " ******** No name for Loaded File"<<endl; | |
3284 | if (level == 0) { | |
586db386 | 3285 | S<<" ******** Short Dump of Header ********\n"; |
7fd59977 | 3286 | S << " *****************************************************************\n\n"; |
7f56eba8 | 3287 | myModel->DumpHeader(S); S<<endl; |
7fd59977 | 3288 | } |
3289 | ||
7f56eba8 | 3290 | Standard_Integer nbent = myModel->NbEntities(); |
7fd59977 | 3291 | Standard_Integer nbr = 0; |
3292 | Interface_ShareFlags shar(thegraph->Graph()); | |
3293 | ||
3294 | for (Standard_Integer i = 1; i <= nbent; i ++) { | |
7f56eba8 | 3295 | if (!shar.IsShared(myModel->Value(i))) nbr ++; |
7fd59977 | 3296 | } |
3297 | S << " *****************************************************************\n"; | |
586db386 | 3298 | S << " ******** Model : "<<nbent<<" Entities, of which "<<nbr<<" Root(s)\n"; |
7fd59977 | 3299 | S << " *****************************************************************\n"<<endl; |
3300 | ||
3301 | if (level <= 0) return; | |
3302 | else if (level == 1) { | |
3303 | S<<" ******** Root Entities ******** "; | |
3304 | ListEntities (shar.RootEntities(),1); | |
3305 | } else if (level == 2) { | |
3306 | S<<" ******** Complete List ******** "; | |
7f56eba8 | 3307 | ListEntities (myModel->Entities(),1); |
7fd59977 | 3308 | } else if (level > 2) { |
3309 | IFSelect_PrintCount mode = IFSelect_ItemsByEntity; | |
3310 | if (level == 5 || level == 8) mode = IFSelect_CountByItem; | |
3311 | if (level == 6 || level == 9) mode = IFSelect_ListByItem; | |
3312 | if (level == 7 || level == 10) mode = IFSelect_EntitiesByItem; | |
7fd59977 | 3313 | PrintCheckList (ModelCheckList(),Standard_False, mode); |
3314 | } else { | |
3315 | if (level == 3) S << " ******** Check Model (Fails) ********"<<endl; | |
3316 | else S << " ******** Check Model (Complete) ********"<<endl; | |
3317 | Interface_CheckTool CT (Graph()); | |
3318 | Interface_CheckIterator C; | |
3319 | if (theerrhand) { | |
3320 | try { | |
3321 | OCC_CATCH_SIGNALS | |
3322 | if (level == 3) C = CT.CheckList(); | |
3323 | else C = CT.CompleteCheckList(); | |
3324 | } | |
3325 | catch (Standard_Failure) { | |
3326 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
3327 | sout<<" **** Interruption DumpModel (Check) par Exception ****\n"; | |
3328 | S<<" ** ** Exception Raised during Check ! ** **\n"; | |
3329 | S<<" --> what could be determined is listed"<<endl; | |
3330 | } | |
3331 | } | |
3332 | else if (level == 3) C = CT.CheckList(); | |
3333 | else C = CT.CompleteCheckList(); | |
3334 | ||
3335 | // Check List : si vide (pas demandee), naturellement passee | |
3336 | try { | |
3337 | OCC_CATCH_SIGNALS | |
7f56eba8 | 3338 | C.Print(S,myModel, (level == 3)); |
7fd59977 | 3339 | } |
3340 | catch (Standard_Failure) { | |
3341 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
3342 | sout<<" **** Interruption DumpModel par Exception : ****\n"; | |
3343 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
3344 | sout<<"\n Abandon"<<endl; | |
3345 | } | |
3346 | ||
3347 | } | |
3348 | S<<endl<<"There are "<<nbent<<" Entities, of which "<<nbr<<" Root(s)"<<endl; | |
3349 | } | |
3350 | ||
3351 | // .... TraceDumpModel .... (Model + CheckList) | |
3352 | ||
3353 | //======================================================================= | |
3354 | //function : | |
3355 | //purpose : | |
3356 | //======================================================================= | |
3357 | ||
3358 | void IFSelect_WorkSession::TraceDumpModel | |
3359 | (const Standard_Integer mode) | |
3360 | { | |
3361 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
3362 | DumpModel (mode,sout); | |
3363 | // if (mode <= 4) { DumpModel (mode,sout); return; } | |
3364 | ||
3365 | // else if (mode <= 7) PrintCheckList (ModelCheckList(),Standard_False, mode-5); | |
3366 | // else if (mode <=10) PrintCheckList (ModelCheckList(),Standard_True , mode-8); | |
3367 | } | |
3368 | ||
3369 | // .... DumpEntity .... | |
3370 | ||
3371 | //======================================================================= | |
3372 | //function : | |
3373 | //purpose : | |
3374 | //======================================================================= | |
3375 | ||
3376 | void IFSelect_WorkSession::DumpEntity | |
3377 | (const Handle(Standard_Transient)& ent, const Standard_Integer level, | |
3378 | const Handle(Message_Messenger)& S) const | |
3379 | { | |
3380 | if (!IsLoaded()) | |
3381 | { S<< " *** Data for List not available ***"<<endl; return; } | |
7f56eba8 | 3382 | Standard_Integer num = myModel->Number(ent); |
7fd59977 | 3383 | if (num == 0) { S<<" *** Entity to Dump not in the Model ***"<<endl; return; } |
3384 | if (thelibrary.IsNull()) { S<<" *** WorkLibrary not defined ***"<<endl; return; } | |
3385 | S << " ******** Dumping Entity n0 "<<num | |
3386 | <<" level:"<<level<<" ********"<<endl; | |
7f56eba8 | 3387 | thelibrary->DumpEntity (myModel,theprotocol,ent,S,level); |
7fd59977 | 3388 | } |
3389 | ||
3390 | // .... DumpEntity .... | |
3391 | ||
3392 | //======================================================================= | |
3393 | //function : | |
3394 | //purpose : | |
3395 | //======================================================================= | |
3396 | ||
3397 | void IFSelect_WorkSession::TraceDumpEntity | |
3398 | (const Handle(Standard_Transient)& ent, const Standard_Integer level) const | |
3399 | { | |
3400 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
3401 | DumpEntity (ent,level,sout); | |
3402 | } | |
3403 | ||
3404 | // .... PrintEntityStatus .... | |
3405 | ||
3406 | //======================================================================= | |
3407 | //function : | |
3408 | //purpose : | |
3409 | //======================================================================= | |
3410 | ||
3411 | void IFSelect_WorkSession::PrintEntityStatus | |
3412 | (const Handle(Standard_Transient)& ent, const Handle(Message_Messenger)& S) | |
3413 | { | |
3414 | Standard_Integer i,nb; | |
3415 | Standard_Integer num = StartingNumber(ent); | |
3416 | if (num == 0) { cout<<" -- PrintEntityStatus : unknown"<<endl; return; } | |
3417 | ||
3418 | S <<" Ent. n0/id: "; | |
7f56eba8 | 3419 | myModel->Print(ent,S); |
7fd59977 | 3420 | Handle(TCollection_HAsciiString) hname = EntityName(ent); |
3421 | if (!hname.IsNull() && hname->Length() > 0) S<<" Name:"<<hname->ToCString(); | |
3422 | S<<endl; | |
3423 | Handle(IFSelect_Signature) signtype = SignType(); | |
3424 | if (signtype.IsNull()) S<<" Type(CDL):"<<ent->DynamicType()->Name()<<endl; | |
7f56eba8 | 3425 | else S <<" Type:"<<signtype->Value (ent,myModel)<<endl; |
7fd59977 | 3426 | S <<" Category : " <<CategoryName (ent) |
3427 | <<" Validity : " <<ValidityName (ent) << endl; | |
3428 | Interface_CheckIterator chl = CheckOne (ent); | |
7f56eba8 | 3429 | chl.Print (S,myModel,Standard_False,Standard_False); |
7fd59977 | 3430 | |
3431 | Handle(TColStd_HSequenceOfTransient) list = Sharings(ent); | |
3432 | if (list.IsNull()) S<<" Root"<<endl; | |
3433 | else { | |
3434 | nb = list->Length(); | |
3435 | if (nb == 0) S<<" Root"; | |
3436 | else S<<" Super-entities:"<<nb<<" : (n0/id):"; | |
7f56eba8 | 3437 | for (i = 1; i <= nb; i ++) { S<<" "; myModel->Print(list->Value(i),S); } |
7fd59977 | 3438 | S<<endl; |
3439 | } | |
3440 | list = Shareds (ent); | |
3441 | if (list.IsNull()) S<<" No sub-entity"<<endl; | |
3442 | else { | |
3443 | nb = list->Length(); | |
3444 | if (nb == 0) S<<" No sub-entity"; | |
3445 | else S<<" Sub-entities:"<<nb<<" , i.e. (n0/id):"; | |
7f56eba8 | 3446 | for (i = 1; i <= nb; i ++) { S<<" "; myModel->Print(list->Value(i),S); } |
7fd59977 | 3447 | S<<endl; |
3448 | } | |
3449 | } | |
3450 | ||
3451 | // .... PrintCheckList .... | |
3452 | ||
3453 | //======================================================================= | |
3454 | //function : | |
3455 | //purpose : | |
3456 | //======================================================================= | |
3457 | ||
3458 | void IFSelect_WorkSession::PrintCheckList | |
3459 | (const Interface_CheckIterator& checklist, | |
3460 | const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const | |
3461 | { | |
3462 | // mode : 0 comptage 1 n0s entites 2 n0s+id ents | |
3463 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
7f56eba8 | 3464 | if (mode == IFSelect_ItemsByEntity) checklist.Print (sout,myModel,failsonly); |
7fd59977 | 3465 | else { |
3466 | Interface_CheckIterator chks = checklist; | |
3467 | Handle(IFSelect_CheckCounter) counter = | |
3468 | new IFSelect_CheckCounter (mode>1 && mode != IFSelect_CountSummary); | |
7f56eba8 | 3469 | counter->Analyse (chks,myModel,Standard_True,failsonly); |
3470 | counter->PrintList (sout,myModel,mode); | |
7fd59977 | 3471 | } |
3472 | } | |
3473 | ||
3474 | // .... PrintSignatureList .... | |
3475 | ||
3476 | //======================================================================= | |
3477 | //function : | |
3478 | //purpose : | |
3479 | //======================================================================= | |
3480 | ||
3481 | void IFSelect_WorkSession::PrintSignatureList | |
3482 | (const Handle(IFSelect_SignatureList)& signlist, | |
3483 | const IFSelect_PrintCount mode) const | |
3484 | { | |
3485 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
3486 | if (signlist.IsNull()) return; | |
7f56eba8 | 3487 | signlist->PrintList (sout,myModel,mode); |
7fd59977 | 3488 | } |
3489 | ||
3490 | // #### #### #### #### #### #### #### #### #### | |
3491 | // .... EvaluateSelection .... | |
3492 | ||
3493 | //======================================================================= | |
3494 | //function : | |
3495 | //purpose : | |
3496 | //======================================================================= | |
3497 | ||
3498 | void IFSelect_WorkSession::EvaluateSelection | |
3499 | (const Handle(IFSelect_Selection)& sel) const | |
3500 | { | |
3501 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
3502 | if (errhand) { | |
3503 | errhand = Standard_False; | |
3504 | try { | |
3505 | OCC_CATCH_SIGNALS | |
3506 | EvaluateSelection(sel); // appel normal (->code unique) | |
3507 | } | |
3508 | catch (Standard_Failure) { | |
3509 | sout<<" **** Interruption EvaluateSelection par Exception **** Intitule\n"; | |
3510 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
3511 | sout<<"\n Abandon"<<endl; | |
3512 | } | |
3513 | errhand = theerrhand; | |
3514 | return; | |
3515 | } | |
3516 | ||
3517 | if (!IsLoaded()) | |
3518 | { sout<< " *** Data for Evaluation not available ***"<<endl; return; } | |
3519 | if (ItemIdent(sel) == 0) | |
586db386 | 3520 | { sout << " Selection : Unknown"<<endl; return; } //sout<<Handle |
7fd59977 | 3521 | Interface_EntityIterator iter = EvalSelection (sel); |
3522 | ListEntities (iter,1); | |
3523 | sout << "**** (Unique) RootResult, Selection : " | |
3524 | <<sel->Label()<<endl; | |
3525 | } | |
3526 | ||
3527 | ||
3528 | // #### #### #### #### #### #### #### #### #### | |
3529 | // .... EvaluateDispatch .... | |
3530 | ||
3531 | //======================================================================= | |
3532 | //function : | |
3533 | //purpose : | |
3534 | //======================================================================= | |
3535 | ||
3536 | void IFSelect_WorkSession::EvaluateDispatch | |
3537 | (const Handle(IFSelect_Dispatch)& disp, const Standard_Integer mode) const | |
3538 | { | |
3539 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
3540 | if (errhand) { | |
3541 | errhand = Standard_False; | |
3542 | try { | |
3543 | OCC_CATCH_SIGNALS | |
3544 | EvaluateDispatch(disp,mode); // appel normal (->code unique) | |
3545 | } | |
3546 | catch (Standard_Failure) { | |
3547 | sout<<" **** Interruption EvaluateDispatch par Exception **** Intitule\n"; | |
3548 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
3549 | sout<<"\n Abandon"<<endl; | |
3550 | } | |
3551 | errhand = theerrhand; | |
3552 | return; | |
3553 | } | |
3554 | ||
3555 | Standard_Integer numdisp = DispatchRank(disp); | |
3556 | if (!IsLoaded()) | |
3557 | { sout<< " *** Data for List not available ***"<<endl; return; } | |
3558 | if (theshareout->NbDispatches() < numdisp || numdisp <= 0) | |
586db386 | 3559 | { sout<<"Dispatch : Unknown"<<endl; return; } //sout<<Handle |
7fd59977 | 3560 | if (disp->FinalSelection().IsNull()) |
586db386 | 3561 | { sout<<"Dispatch : No Final Selection"<<endl; return; }//sout<<Handle |
7fd59977 | 3562 | sout<<" --- Dispatch Label : "<<disp->Label()<<endl; |
3563 | ||
3564 | IFSelect_ShareOutResult eval(disp,thegraph->Graph()); | |
3565 | eval.Evaluate(); | |
3566 | Standard_Integer numpack = 0; | |
3567 | Handle(IFSelect_PacketList) evres = | |
3568 | eval.Packets (mode ? Standard_True : Standard_False); | |
3569 | Standard_Integer nbpack = evres->NbPackets(); | |
3570 | ||
3571 | sout<<"Nb Packets produced : "<<nbpack<<" :"<<endl; | |
3572 | for (numpack = 1; numpack <= nbpack; numpack ++) { | |
3573 | sout<<"\n **** Packet n0 : "<<numpack<<" ****"<<endl; | |
3574 | if (!mode) cout<<"Root Entities :"<<endl; | |
3575 | ListEntities (evres->Entities(numpack), (mode ? 2 : -1)); | |
3576 | } | |
3577 | ||
3578 | //// Interface_EntityIterator iterem = disp->Remainder(thegraph->Graph()); | |
3579 | if (mode == 0) return; | |
3580 | if (mode == 1 || mode == 3) { | |
3581 | sout<<endl; | |
3582 | if (evres->NbDuplicated(0,Standard_False) == 0) | |
3583 | sout<<" **** All the Model is taken into account ****"<<endl; | |
3584 | else { | |
3585 | sout<<" **** Starting Entities not taken by this Dispatch ****"<<endl; | |
3586 | ListEntities (evres->Duplicated(0,Standard_False),2); | |
3587 | } | |
3588 | } | |
3589 | if (mode >= 2) { | |
3590 | sout<<" **** Entites in more than one packet ****"; | |
3591 | Standard_Integer max = evres->HighestDuplicationCount(); | |
3592 | if (max < 2) sout<<" : There are none"<<endl; | |
3593 | else { | |
3594 | Standard_Integer newcount; | |
3595 | sout<<endl; | |
3596 | for (newcount = 2; newcount <= max; newcount ++) { | |
3597 | if (evres->NbDuplicated(newcount,Standard_False) == 0) continue; | |
3598 | sout<<" **** Entities put in "<<newcount<<" packets ****"<<endl; | |
3599 | ListEntities (evres->Duplicated(newcount,Standard_False),2); | |
3600 | } | |
3601 | } | |
3602 | } | |
3603 | } | |
3604 | ||
3605 | ||
3606 | // #### #### #### #### #### #### #### #### #### | |
3607 | // .... EvaluateComplete .... | |
3608 | ||
3609 | //======================================================================= | |
3610 | //function : | |
3611 | //purpose : | |
3612 | //======================================================================= | |
3613 | ||
3614 | void IFSelect_WorkSession::EvaluateComplete | |
3615 | (const Standard_Integer mode) const | |
3616 | { | |
3617 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
3618 | if (errhand) { | |
3619 | errhand = Standard_False; | |
3620 | try { | |
3621 | OCC_CATCH_SIGNALS | |
3622 | EvaluateComplete(mode); // appel normal (donc, code pas duplique) | |
3623 | } | |
3624 | catch (Standard_Failure) { | |
3625 | sout<<" **** Interruption EvaluateComplete par Exception : ****\n"; | |
3626 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
3627 | sout<<"\n Abandon"<<endl; | |
3628 | } | |
3629 | errhand = theerrhand; | |
3630 | return; | |
3631 | } | |
3632 | ||
3633 | if (!IsLoaded()) | |
3634 | { sout<< " *** Data for List not available ***"<<endl; return; } | |
3635 | IFSelect_ShareOutResult eval(theshareout,thegraph->Graph()); | |
3636 | eval.Evaluate(); | |
3637 | sout<<"\n******** Evaluation ShareOutResult (Complete) ********\n"; | |
3638 | sout<<" **** List of Packets **** Count : "<<eval.NbPackets()<<endl; | |
3639 | if (mode == 0) sout << " ** (for each one : Root Entities) **"<<endl; | |
3640 | else sout << " ** (for each one : Evaluated Content) **"<<endl; | |
3641 | ||
3642 | Standard_Integer numpack = 0; | |
3643 | Handle(IFSelect_PacketList) evres = | |
3644 | eval.Packets (mode ? Standard_True : Standard_False); | |
3645 | Standard_Integer nbpack = evres->NbPackets(); | |
3646 | ||
3647 | sout<<"Nb Packets produced : "<<nbpack<<" :"<<endl; | |
3648 | for (numpack = 1; numpack <= nbpack; numpack ++) { | |
3649 | sout<<"\n **** Packet n0 : "<<numpack<<" ****"<<endl; | |
3650 | if (!mode) cout<<"Root Entities :"<<endl; | |
3651 | ListEntities (evres->Entities(numpack), (mode ? 2: -1)); | |
3652 | } | |
3653 | if (mode == 0) return; | |
3654 | if (mode == 1 || mode == 3) { | |
3655 | sout<<endl; | |
3656 | if (evres->NbDuplicated(0,Standard_False) == 0) | |
3657 | sout<<" **** All the Model is taken into account ****"<<endl; | |
3658 | else { | |
3659 | sout<<" **** Starting Entities Forgotten ****"<<endl; | |
3660 | ListEntities (evres->Duplicated(0,Standard_False),2); | |
3661 | } | |
3662 | } | |
3663 | if (mode >= 2) { | |
3664 | sout<<" **** Entites in more than one packet ****"<<endl; | |
3665 | Standard_Integer max = evres->HighestDuplicationCount(); | |
3666 | if (max < 2) sout<<" : There are none"<<endl; | |
3667 | else { | |
3668 | Standard_Integer newcount; | |
3669 | sout<<endl; | |
3670 | for (newcount = 2; newcount <= max; newcount ++) { | |
3671 | if (evres->NbDuplicated(newcount,Standard_False) == 0) continue; | |
3672 | sout<<" **** Entities put in "<<newcount<<" packets ****"<<endl; | |
3673 | ListEntities (evres->Duplicated(newcount,Standard_False),2); | |
3674 | } | |
3675 | } | |
3676 | } | |
3677 | } | |
3678 | ||
3679 | ||
3680 | // #### #### #### #### #### #### #### #### #### | |
3681 | // .... Routine Interne : ListEntities | |
3682 | ||
3683 | //======================================================================= | |
3684 | //function : | |
3685 | //purpose : | |
3686 | //======================================================================= | |
3687 | ||
3688 | void IFSelect_WorkSession::ListEntities | |
3689 | (const Interface_EntityIterator& iter, const Standard_Integer mmode) const | |
3690 | { | |
3691 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
3692 | int titre = 0; | |
3693 | Standard_Integer mode = (mmode < 0 ? -mmode : mmode); | |
3694 | if (mmode >= 0) sout << " List of " << iter.NbEntities() << " Entities :"<<endl; | |
3695 | if (!IsLoaded()) | |
3696 | { sout<< " *** Data for List not available ***"<<endl; return; } | |
3697 | Interface_ShareFlags tool(thegraph->Graph()); | |
3698 | ||
3699 | try { | |
3700 | OCC_CATCH_SIGNALS | |
3701 | int newcount = -1; int mods = 0; int cnt = 0; | |
3702 | for (iter.Start(); iter.More(); iter.Next()) { | |
3703 | if (!titre && mode == 1) sout | |
3704 | << "Number/Id. Category Validity Type\n----------- ----...."<<endl; | |
3705 | // 123456789 123456789 123456 123456789 123456789 123456 | |
3706 | if (!titre && mode == 0) sout<<" Keys : R Root ? Unknown * Unloaded"<<endl; | |
3707 | if (!titre && mode == 2) sout<<"("; | |
3708 | titre = 1; | |
3709 | Handle(Standard_Transient) ent = iter.Value(); | |
7f56eba8 | 3710 | Standard_Integer num = myModel->Number(ent); |
7fd59977 | 3711 | if (mode == 1) { |
7f56eba8 | 3712 | // n0 id (root?) category validity tracetype |
7fd59977 | 3713 | sout<<Interface_MSG::Blanks (num,6); |
7f56eba8 | 3714 | myModel->Print(ent,sout,0); |
7fd59977 | 3715 | if (!tool.IsShared(ent)) sout << " #ROOT#"; |
3716 | else sout << " "; | |
7f56eba8 | 3717 | Standard_Integer catnum = myModel->CategoryNumber(num); |
7fd59977 | 3718 | if (catnum > 0) sout<<" "<<Interface_Category::Name (catnum); |
3719 | sout << " (" << ValidityName (ent) << ") "; | |
3720 | ||
7f56eba8 | 3721 | sout<<" Type:"<<myModel->TypeName (ent, Standard_False)<<endl; |
7fd59977 | 3722 | } else if (mode == 2) { |
3723 | newcount ++; | |
3724 | if (newcount > 0) sout<<","; | |
3725 | sout<<num; | |
3726 | } else { | |
3727 | newcount ++; mods = 0; cnt ++; | |
3728 | if (newcount >= 10) { sout << endl<<"["<<cnt<<"]:"; newcount = 1; } | |
3729 | if (newcount > 0) sout << " "; | |
7f56eba8 | 3730 | myModel->Print(ent,sout,0); |
7fd59977 | 3731 | if (!tool.IsShared(ent)) { if(mods == 0) sout<<"("; sout<<"R"; mods++; } |
7f56eba8 | 3732 | if (myModel->IsUnknownEntity(num)) { sout<<(mods==0 ? '(' : ' ')<<"?"; mods ++; } |
3733 | if (myModel->IsRedefinedContent(num)) { sout<<(mods==0 ? '(' : ' ')<<"*"; mods ++; } | |
7fd59977 | 3734 | if (mods) { sout<<")"; newcount ++; } |
3735 | } | |
3736 | } | |
3737 | if (mode == 0) sout<<endl; | |
3738 | if (mode == 2) sout<<")"<<endl; | |
3739 | } | |
3740 | catch (Standard_Failure) { | |
3741 | sout<<" **** Interruption ListEntities par Exception : ****\n"; | |
3742 | sout<<Standard_Failure::Caught()->GetMessageString(); | |
3743 | sout<<"\n Abandon"<<endl; | |
3744 | } | |
3745 | } |