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