1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 //#1 svv 10.01.00 : porting on DEC
15 //smh#14 17.03.2000 : FRA62479 Clearing of gtool
17 #include <Dico_DictionaryOfTransient.hxx>
18 #include <Dico_IteratorOfDictionaryOfInteger.hxx>
19 #include <Dico_IteratorOfDictionaryOfTransient.hxx>
20 #include <IFGraph_SubPartsIterator.hxx>
21 #include <IFSelect_CheckCounter.hxx>
22 #include <IFSelect_Dispatch.hxx>
23 #include <IFSelect_DispGlobal.hxx>
24 #include <IFSelect_DispPerCount.hxx>
25 #include <IFSelect_DispPerOne.hxx>
26 #include <IFSelect_EditForm.hxx>
27 #include <IFSelect_Editor.hxx>
28 #include <IFSelect_GeneralModifier.hxx>
29 #include <IFSelect_IntParam.hxx>
30 #include <IFSelect_ModelCopier.hxx>
31 #include <IFSelect_Modifier.hxx>
32 #include <IFSelect_PacketList.hxx>
33 #include <IFSelect_ParamEditor.hxx>
34 #include <IFSelect_SelectCombine.hxx>
35 #include <IFSelect_SelectControl.hxx>
36 #include <IFSelect_SelectDeduct.hxx>
37 #include <IFSelect_SelectDiff.hxx>
38 #include <IFSelect_SelectEntityNumber.hxx>
39 #include <IFSelect_SelectExtract.hxx>
40 #include <IFSelect_SelectIntersection.hxx>
41 #include <IFSelect_Selection.hxx>
42 #include <IFSelect_SelectionIterator.hxx>
43 #include <IFSelect_SelectModelEntities.hxx>
44 #include <IFSelect_SelectModelRoots.hxx>
45 #include <IFSelect_SelectPointed.hxx>
46 #include <IFSelect_SelectSignature.hxx>
47 #include <IFSelect_SelectUnion.hxx>
48 #include <IFSelect_ShareOut.hxx>
49 #include <IFSelect_ShareOutResult.hxx>
50 #include <IFSelect_Signature.hxx>
51 #include <IFSelect_SignatureList.hxx>
52 #include <IFSelect_SignCounter.hxx>
53 #include <IFSelect_SignValidity.hxx>
54 #include <IFSelect_Transformer.hxx>
55 #include <IFSelect_TransformStandard.hxx>
56 #include <IFSelect_WorkLibrary.hxx>
57 #include <IFSelect_WorkSession.hxx>
58 #include <Interface_Category.hxx>
59 #include <Interface_Check.hxx>
60 #include <Interface_CheckIterator.hxx>
61 #include <Interface_CheckTool.hxx>
62 #include <Interface_CopyControl.hxx>
63 #include <Interface_CopyTool.hxx>
64 #include <Interface_EntityIterator.hxx>
65 #include <Interface_GeneralLib.hxx>
66 #include <Interface_GeneralModule.hxx>
67 #include <Interface_Graph.hxx>
68 #include <Interface_GTool.hxx>
69 #include <Interface_HGraph.hxx>
70 #include <Interface_InterfaceModel.hxx>
71 #include <Interface_Macros.hxx>
72 #include <Interface_MSG.hxx>
73 #include <Interface_Protocol.hxx>
74 #include <Interface_ReportEntity.hxx>
75 #include <Interface_ShareFlags.hxx>
76 #include <Interface_ShareTool.hxx>
77 #include <Interface_Static.hxx>
78 #include <Message.hxx>
79 #include <Message_Messenger.hxx>
80 #include <OSD_Path.hxx>
81 #include <Standard_DomainError.hxx>
82 #include <Standard_ErrorHandler.hxx>
83 #include <Standard_Failure.hxx>
84 #include <Standard_Transient.hxx>
85 #include <Standard_Type.hxx>
86 #include <TCollection_AsciiString.hxx>
87 #include <TCollection_HAsciiString.hxx>
88 #include <TColStd_MapOfInteger.hxx>
90 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_WorkSession,MMgt_TShared)
92 #define Flag_Incorrect 2
96 static Standard_Boolean errhand; // pb : un seul a la fois, mais ca va si vite
97 static TCollection_AsciiString bufstr;
100 // #################################################################
103 //=======================================================================
106 //=======================================================================
108 IFSelect_WorkSession::IFSelect_WorkSession ()
110 theshareout = new IFSelect_ShareOut;
111 theerrhand = errhand = Standard_True;
112 thenames = new Dico_DictionaryOfTransient;
113 thecopier = new IFSelect_ModelCopier;
114 thecopier->SetShareOut (theshareout);
115 thecheckdone = Standard_False;
116 thegtool = new Interface_GTool;
117 themodelstat = Standard_False;
121 //=======================================================================
124 //=======================================================================
126 void IFSelect_WorkSession::SetErrorHandle (const Standard_Boolean hand)
128 theerrhand = errhand = hand;
132 //=======================================================================
135 //=======================================================================
137 Standard_Boolean IFSelect_WorkSession::ErrorHandle () const
143 //=======================================================================
146 //=======================================================================
148 const Handle(IFSelect_ShareOut)& IFSelect_WorkSession::ShareOut () const
154 //=======================================================================
157 //=======================================================================
159 void IFSelect_WorkSession::SetLibrary (const Handle(IFSelect_WorkLibrary)& lib)
165 //=======================================================================
168 //=======================================================================
170 Handle(IFSelect_WorkLibrary) IFSelect_WorkSession::WorkLibrary () const
176 //=======================================================================
179 //=======================================================================
181 void IFSelect_WorkSession::SetProtocol
182 (const Handle(Interface_Protocol)& protocol)
184 theprotocol = protocol;
185 Interface_Protocol::SetActive(protocol);
186 thegtool->SetProtocol (protocol);
190 //=======================================================================
193 //=======================================================================
195 Handle(Interface_Protocol) IFSelect_WorkSession::Protocol () const
201 //=======================================================================
204 //=======================================================================
206 void IFSelect_WorkSession::SetSignType
207 (const Handle(IFSelect_Signature)& signtype)
209 thegtool->SetSignType (signtype);
210 if (signtype.IsNull()) thenames->RemoveItem ("xst-sign-type");
211 else thenames->SetItem ("xst-sign-type",signtype);
215 //=======================================================================
218 //=======================================================================
220 Handle(IFSelect_Signature) IFSelect_WorkSession::SignType () const
222 return Handle(IFSelect_Signature)::DownCast (thegtool->SignType());
226 //=======================================================================
229 //=======================================================================
231 void IFSelect_WorkSession::SetShareOut
232 (const Handle(IFSelect_ShareOut)& shareout)
234 theshareout = shareout;
235 thecopier->SetShareOut (theshareout);
236 // ... faudrait ajouter les Params, Dispatches, etc...
240 //=======================================================================
243 //=======================================================================
245 Standard_Boolean IFSelect_WorkSession::HasModel () const
247 return (!themodel.IsNull());
251 //=======================================================================
254 //=======================================================================
256 void IFSelect_WorkSession::SetModel
257 (const Handle(Interface_InterfaceModel)& model,
258 const Standard_Boolean clearpointed)
260 if (themodel != model) {
262 //skl if (!themodel.IsNull()) themodel->Clear();
265 if (!thegtool.IsNull()) thegtool->ClearEntities(); //smh#14 FRA62479
266 // themodel->SetProtocol(theprotocol);
267 themodel->SetGTool (thegtool);
270 ComputeGraph(); // fait qqchose si Protocol present. Sinon, ne fait rien
271 ClearData(3); // RAZ CheckList, a refaire
274 // MISE A JOUR des SelectPointed C-A-D on efface leur contenu
275 if (clearpointed) ClearData(4);
280 //=======================================================================
283 //=======================================================================
284 Handle(Interface_InterfaceModel) IFSelect_WorkSession::Model () const
290 //=======================================================================
293 //=======================================================================
295 void IFSelect_WorkSession::SetLoadedFile (const Standard_CString filename)
298 theloaded.AssignCat (filename);
302 //=======================================================================
305 //=======================================================================
307 Standard_CString IFSelect_WorkSession::LoadedFile () const
309 return theloaded.ToCString();
313 //=======================================================================
316 //=======================================================================
318 IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile
319 (const Standard_CString filename)
321 if (thelibrary.IsNull()) return IFSelect_RetVoid;
322 if (theprotocol.IsNull()) return IFSelect_RetVoid;
323 Handle(Interface_InterfaceModel) model;
324 IFSelect_ReturnStatus status = IFSelect_RetVoid;
327 Standard_Integer stat = thelibrary->ReadFile (filename,model,theprotocol);
328 if (stat == 0) status = IFSelect_RetDone;
329 else if (stat < 0) status = IFSelect_RetError;
330 else status = IFSelect_RetFail;
332 catch(Standard_Failure) {
333 Handle(Message_Messenger) sout = Message::DefaultMessenger();
334 sout<<" **** Interruption ReadFile par Exception : ****\n";
335 sout << Standard_Failure::Caught()->GetMessageString();
336 sout<<"\n Abandon"<<endl;
337 status = IFSelect_RetFail;
339 if (status != IFSelect_RetDone) return status;
340 if (model.IsNull()) return IFSelect_RetVoid;
342 SetLoadedFile (filename);
347 //=======================================================================
350 //=======================================================================
352 Standard_Integer IFSelect_WorkSession::NbStartingEntities () const
354 if (themodel.IsNull()) return 0;
355 return themodel->NbEntities();
359 //=======================================================================
362 //=======================================================================
364 Handle(Standard_Transient) IFSelect_WorkSession::StartingEntity
365 (const Standard_Integer num) const
367 Handle(Standard_Transient) res; // Null par defaut
368 if (themodel.IsNull()) return res;
369 if (num < 1 || num > themodel->NbEntities()) return res;
370 return themodel->Value(num);
374 //=======================================================================
377 //=======================================================================
379 Standard_Integer IFSelect_WorkSession::StartingNumber
380 (const Handle(Standard_Transient)& ent) const
382 if (themodel.IsNull()) return 0;
383 return themodel->Number(ent);
387 //=======================================================================
390 //=======================================================================
392 Standard_Integer IFSelect_WorkSession::NumberFromLabel
393 (const Standard_CString val, const Standard_Integer afternum) const
395 Standard_Integer i, cnt = 0, num = atoi(val);
396 if (num > 0 || themodel.IsNull()) return num; // un n0 direct : gagne !
397 // Sinon, on considere que c est un label; a traiter en CaseNonSensitive ...
398 if (num > themodel->NbEntities()) { num = 0; return num; }
399 Standard_Boolean exact = Standard_False;
400 Standard_Integer after = (afternum >= 0 ? afternum : -afternum);
401 for (i = themodel->NextNumberForLabel (val, after, exact) ; i != 0;
402 i = themodel->NextNumberForLabel (val, i, exact)) {
404 if (num <= 0) num = i;
406 if (cnt == 1) return num;
413 //=======================================================================
416 //=======================================================================
418 Handle(TCollection_HAsciiString) IFSelect_WorkSession::EntityLabel
419 (const Handle(Standard_Transient)& ent) const
421 Handle(TCollection_HAsciiString) name;
422 if (themodel.IsNull() || ent.IsNull()) return name;
423 if (!themodel->Contains(ent)) return name;
424 name = themodel->StringLabel(ent);
429 //=======================================================================
432 //=======================================================================
434 Handle(TCollection_HAsciiString) IFSelect_WorkSession::EntityName
435 (const Handle(Standard_Transient)& ent) const
437 Handle(TCollection_HAsciiString) name;
438 if (themodel.IsNull() || ent.IsNull()) return name;
439 Interface_ShareTool sht(thegraph->Graph());
442 Handle(Interface_GeneralModule) module;
443 if (!thegtool->Select (ent,module,CN)) return 0;
444 return module->Name (CN,ent,sht);
448 //=======================================================================
451 //=======================================================================
453 Standard_Integer IFSelect_WorkSession::CategoryNumber
454 (const Handle(Standard_Transient)& ent) const
456 if (themodel.IsNull()) return -1;
457 Standard_Integer num = StartingNumber(ent);
458 return themodel->CategoryNumber(num);
462 //=======================================================================
465 //=======================================================================
467 Standard_CString IFSelect_WorkSession::CategoryName
468 (const Handle(Standard_Transient)& ent) const
470 Standard_Integer cn = CategoryNumber (ent);
471 return Interface_Category::Name (cn);
475 //=======================================================================
478 //=======================================================================
480 Standard_CString IFSelect_WorkSession::ValidityName
481 (const Handle(Standard_Transient)& ent) const
483 if (StartingNumber(ent) == 0) return "";
484 return IFSelect_SignValidity::CVal (ent,themodel);
488 //=======================================================================
491 //=======================================================================
493 void IFSelect_WorkSession::ClearData (const Standard_Integer mode)
498 if (!themodel.IsNull()) themodel->Clear();
500 ClearData(2); ClearData(4);
504 case 2 : { thegraph.Nullify(); thecheckdone = Standard_False; thecheckana.Clear(); break; }
505 case 3 : { thecheckdone = Standard_False; break; }
507 // MISE A JOUR des SelectPointed C-A-D on efface leur contenu
508 // AINSI que des editeurs (en fait, les EditForm)
509 // Des compteurs C-A-D on efface leur contenu (a reevaluer)
510 Handle(TColStd_HSequenceOfInteger) list =
511 ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed));
512 Standard_Integer nb = list->Length();
513 Standard_Integer i; // svv #1
514 for (i = 1; i <= nb; i ++) {
515 DeclareAndCast(IFSelect_SelectPointed,sp,Item(list->Value(i)));
516 if (!sp.IsNull()) sp->Clear();
518 list = ItemIdents(STANDARD_TYPE(IFSelect_SignatureList));
520 for (i = 1; i <= nb; i ++) {
521 DeclareAndCast(IFSelect_SignatureList,sl,Item(list->Value(i)));
522 if (!sl.IsNull()) sl->Clear();
523 DeclareAndCast(IFSelect_SignCounter,sc,sl);
524 if (!sc.IsNull()) sc->SetSelMode(-1);
526 list = ItemIdents(STANDARD_TYPE(IFSelect_EditForm));
528 Handle(Standard_Transient) nulent;
529 for (i = 1; i <= nb; i ++) {
530 DeclareAndCast(IFSelect_EditForm,edf,Item(list->Value(i)));
541 //=======================================================================
544 //=======================================================================
546 Standard_Boolean IFSelect_WorkSession::ComputeGraph
547 (const Standard_Boolean enforce)
549 if (theprotocol.IsNull()) return Standard_False;
550 if (themodel.IsNull()) return Standard_False;
551 //if (themodel->NbEntities() == 0) return Standard_False;
552 if (enforce) thegraph.Nullify();
553 if (!thegraph.IsNull()) {
554 if (themodel->NbEntities() == thegraph->Graph().Size()) return Standard_True;
557 if (themodel->NbEntities() == 0) return Standard_False;
558 // Il faut calculer le graphe pour de bon
559 thegraph = new Interface_HGraph (themodel,themodelstat);
560 Standard_Integer nb = themodel->NbEntities();
563 Standard_Integer i; // svv #1
564 for (i = 1; i <= nb; i ++) thegraph->CGraph().SetStatus(i,0);
565 Interface_BitMap& bm = thegraph->CGraph().CBitMap();
567 bm.SetFlagName (Flag_Incorrect,"Incorrect");
570 thecheckdone = Standard_True;
573 // Calcul des categories, a present memorisees dans le modele
574 Interface_Category categ(thegtool);
575 Interface_ShareTool sht(thegraph);
576 Standard_Integer i =1;
577 for ( ; i <= nb; i ++) themodel->SetCategoryNumber
578 (i,categ.CatNum(themodel->Value(i),sht));
581 return Standard_True;
585 //=======================================================================
588 //=======================================================================
590 Handle(Interface_HGraph) IFSelect_WorkSession::HGraph ()
597 //=======================================================================
600 //=======================================================================
602 const Interface_Graph& IFSelect_WorkSession::Graph ()
605 if (thegraph.IsNull()) Standard_DomainError::Raise
606 ("IFSelect WorkSession : Graph not available");
607 return thegraph->Graph();
611 //=======================================================================
614 //=======================================================================
616 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::Shareds
617 (const Handle(Standard_Transient)& ent)
619 Handle(TColStd_HSequenceOfTransient) list;
620 if (!ComputeGraph()) return list;
621 if (StartingNumber(ent) == 0) return list;
622 return thegraph->Graph().Shareds(ent).Content();
626 //=======================================================================
629 //=======================================================================
631 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::Sharings
632 (const Handle(Standard_Transient)& ent)
634 Handle(TColStd_HSequenceOfTransient) list;
635 if (!ComputeGraph()) return list;
636 if (StartingNumber(ent) == 0) return list;
637 return thegraph->Graph().Sharings(ent).Content();
641 //=======================================================================
644 //=======================================================================
646 Standard_Boolean IFSelect_WorkSession::IsLoaded () const
648 if (theprotocol.IsNull()) return Standard_False;
649 if (themodel.IsNull()) return Standard_False;
650 if (themodel->NbEntities() == 0) return Standard_False;
651 if (thegraph.IsNull()) return Standard_False;
652 if (themodel->NbEntities() == thegraph->Graph().Size()) return Standard_True;
653 return Standard_False;
657 //=======================================================================
660 //=======================================================================
662 Standard_Boolean IFSelect_WorkSession::ComputeCheck
663 (const Standard_Boolean enforce)
665 if (enforce) thecheckdone = Standard_False;
666 if (thecheckdone) return Standard_True;
667 if (!IsLoaded()) return Standard_False;
669 Interface_Graph& CG = thegraph->CGraph();
670 Interface_CheckTool cht(thegraph);
671 Interface_CheckIterator checklist = cht.VerifyCheckList();
672 themodel->FillSemanticChecks(checklist,Standard_False);
675 // Et on met a jour le Graphe (BitMap) ! Flag Incorrect (STX + SEM)
676 Interface_BitMap& BM = CG.CBitMap();
677 BM.Init (Standard_False,Flag_Incorrect);
678 Standard_Integer num, nb = CG.Size();
679 for (checklist.Start(); checklist.More(); checklist.Next()) {
680 const Handle(Interface_Check) chk = checklist.Value();
681 if (!chk->HasFailed()) continue;
682 num = checklist.Number();
683 if (num > 0 && num <= nb) BM.SetTrue (num,Flag_Incorrect);
685 for (num = 1; num <= nb; num ++)
686 if (themodel->IsErrorEntity (num)) BM.SetTrue (num,Flag_Incorrect);
688 return Standard_True;
692 //=======================================================================
695 //=======================================================================
697 Interface_CheckIterator IFSelect_WorkSession::ModelCheckList
698 (const Standard_Boolean complete)
700 Interface_CheckIterator checks;
702 checks.CCheck(0)->AddFail("DATA NOT AVAILABLE FOR CHECK");
705 Interface_CheckTool cht(Graph());
706 checks = (complete ? cht.CompleteCheckList() : cht.AnalyseCheckList());
708 ((char*)(complete ? "Model Complete Check List" : "Model Syntactic Check List"));
713 //=======================================================================
716 //=======================================================================
718 Interface_CheckIterator IFSelect_WorkSession::CheckOne
719 (const Handle(Standard_Transient)& ent,
720 const Standard_Boolean complete)
722 Interface_CheckIterator checks;
723 checks.SetModel(themodel);
725 checks.CCheck(0)->AddFail("DATA NOT AVAILABLE FOR CHECK");
728 Standard_Integer num = -1;
729 if (ent.IsNull() || ent == themodel) num = 0;
730 else num = themodel->Number(ent);
732 Handle(Interface_Check) ach = themodel->Check (num,Standard_True);
733 if (complete) ach->GetMessages (themodel->Check (num,Standard_False));
734 if (num > 0) ach->SetEntity(ent);
735 checks.Add (ach,num);
736 checks.SetName ("Data Check (One Entity)");
741 //=======================================================================
744 //=======================================================================
746 Interface_CheckIterator IFSelect_WorkSession::LastRunCheckList () const
752 // #####################################################################
753 // .... LES VARIABLES ....
755 //=======================================================================
758 //=======================================================================
760 Standard_Integer IFSelect_WorkSession::MaxIdent () const
762 return theitems.Extent();
766 //=======================================================================
769 //=======================================================================
771 Handle(Standard_Transient) IFSelect_WorkSession::Item
772 (const Standard_Integer id) const
774 Handle(Standard_Transient) res;
775 if (id <= 0 || id > MaxIdent()) return res;
776 if (theitems.FindFromIndex(id).IsNull()) return res;
777 return theitems.FindKey(id);
781 //=======================================================================
784 //=======================================================================
786 Standard_Integer IFSelect_WorkSession::ItemIdent
787 (const Handle(Standard_Transient)& item) const
789 if (item.IsNull()) return 0;
790 Standard_Integer id = theitems.FindIndex(item);
791 if (id == 0) return 0;
792 if (theitems.FindFromIndex(id).IsNull()) return 0;
797 //=======================================================================
800 //=======================================================================
802 Handle(Standard_Transient) IFSelect_WorkSession::NamedItem
803 (const Standard_CString name) const
805 Handle(Standard_Transient) res;
806 if (name[0] == '\0') return res;
807 if (name[0] == '#') { // #nnn : pas un nom mais un n0 id.
808 Standard_Integer id = atoi( &name[1] );
811 if (!thenames->GetItem(name,res)) res.Nullify();
816 //=======================================================================
819 //=======================================================================
821 Handle(Standard_Transient) IFSelect_WorkSession::NamedItem
822 (const Handle(TCollection_HAsciiString)& name) const
824 Handle(Standard_Transient) res;
825 if (!name.IsNull()) res = NamedItem (name->ToCString());
830 //=======================================================================
833 //=======================================================================
835 Standard_Integer IFSelect_WorkSession::NameIdent
836 (const Standard_CString name) const
838 Handle(Standard_Transient) res;
839 if (name[0] == '\0') return 0;
840 if (name[0] == '#') { // #nnn : pas un nom mais un n0 id.
841 Standard_Integer id = atoi( &name[1] );
844 if (!thenames->GetItem(name,res)) return 0;
845 return ItemIdent(res);
849 //=======================================================================
852 //=======================================================================
854 Standard_Boolean IFSelect_WorkSession::HasName
855 (const Handle(Standard_Transient)& item) const
857 if (item.IsNull()) return Standard_False;
858 Standard_Integer id = theitems.FindIndex(item);
859 if (id == 0) return Standard_False;
860 Handle(Standard_Transient) att = theitems.FindFromIndex(id);
861 if (att.IsNull()) return Standard_False;
862 return att->IsKind(STANDARD_TYPE(TCollection_HAsciiString));
866 //=======================================================================
869 //=======================================================================
871 Handle(TCollection_HAsciiString) IFSelect_WorkSession::Name
872 (const Handle(Standard_Transient)& item) const
874 Handle(TCollection_HAsciiString) res;
875 if (item.IsNull()) return res;
876 Standard_Integer id = theitems.FindIndex(item);
877 if (id == 0) return res; // Null
878 Handle(Standard_Transient) att = theitems.FindFromIndex(id);
879 return GetCasted(TCollection_HAsciiString,att);
883 //=======================================================================
886 //=======================================================================
888 Standard_Integer IFSelect_WorkSession::AddItem
889 (const Handle(Standard_Transient)& item,
890 const Standard_Boolean active)
892 if (item.IsNull()) return 0;
893 Standard_Integer id = theitems.FindIndex(item);
895 Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id);
896 if (att.IsNull()) att = item;
898 else id = theitems.Add(item,item);
900 // Cas particuliers : Dispatch,Modifier
901 if (active) SetActive(item,Standard_True);
906 //=======================================================================
909 //=======================================================================
911 Standard_Integer IFSelect_WorkSession::AddNamedItem
912 (const Standard_CString name, const Handle(Standard_Transient)& item,
913 const Standard_Boolean active)
915 if (item.IsNull()) return 0;
916 if (name[0] == '#' || name[0] == '!') return 0;
917 // #nnn : pas un nom mais un numero. !... : reserve (interdit pour un nom)
918 // nom deja pris : on ecrase l ancienne valeur
919 if (name[0] != '\0') {
920 Standard_Boolean deja;
921 Handle(Standard_Transient)& newitem = thenames->NewItem(name,deja);
922 // if (deja & item != newitem) return 0;
925 Standard_Integer id = theitems.FindIndex(item);
927 Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id);
928 if (att.IsNull()) att = item;
929 if (name[0] != '\0') {
930 // if (!att->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) ecrasement admis !
931 att = new TCollection_HAsciiString(name);
934 else if (name[0] != '\0')
935 id = theitems.Add(item,new TCollection_HAsciiString(name));
936 else id = theitems.Add(item,item);
938 // Cas particuliers : Dispatch,Modifier
939 if (active) SetActive(item,Standard_True);
944 //=======================================================================
947 //=======================================================================
949 Standard_Boolean IFSelect_WorkSession::SetActive
950 (const Handle(Standard_Transient)& item, const Standard_Boolean mode)
952 if (item->IsKind(STANDARD_TYPE(IFSelect_Dispatch))) {
953 DeclareAndCast(IFSelect_Dispatch,disp,item);
954 Standard_Integer num = theshareout->DispatchRank(disp);
955 if ( num > theshareout->NbDispatches()) return Standard_False;
957 if (num > 0) return Standard_False;
958 theshareout->AddDispatch (disp);
959 return Standard_True;
961 if (num <= theshareout->LastRun()) return Standard_False;
962 theshareout->RemoveDispatch(num);
963 SetFileRoot(disp,""); // si onlynamed : nettoie aussi ShareOut
964 return Standard_True;
968 return Standard_False;
972 //=======================================================================
975 //=======================================================================
977 Standard_Boolean IFSelect_WorkSession::RemoveNamedItem
978 (const Standard_CString name)
980 Handle(Standard_Transient) item = NamedItem(name);
981 if (item.IsNull()) return Standard_False;
982 if (!RemoveItem(item)) return Standard_False; // qui se charge de tout
983 return Standard_True;
987 //=======================================================================
990 //=======================================================================
992 Standard_Boolean IFSelect_WorkSession::RemoveName
993 (const Standard_CString name)
995 Handle(Standard_Transient) item = NamedItem(name);
996 if (item.IsNull()) return Standard_False;
997 theitems.Add(item,item); // reste mais sans nom
998 return thenames->RemoveItem(name);
1002 //=======================================================================
1005 //=======================================================================
1007 Standard_Boolean IFSelect_WorkSession::RemoveItem
1008 (const Handle(Standard_Transient)& item)
1010 if (item.IsNull()) return Standard_False;
1011 Standard_Integer id = theitems.FindIndex(item);
1012 if (id == 0) return Standard_False;
1013 Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id);
1014 if (att.IsNull()) return Standard_False; // deja annulle
1016 // Cas particuliers : Dispatch,Modifier
1017 theshareout->RemoveItem(item);
1019 // Marquer "Removed" dans la Map (on ne peut pas la vider)
1020 if (att->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) {
1021 if (!thenames->RemoveItem
1022 (GetCasted(TCollection_HAsciiString,att)->ToCString()))
1023 return Standard_False;
1025 att.Nullify(); // cf ChangeFromIndex
1026 // id = theitems.Add(item,att);
1027 return Standard_True;
1031 //=======================================================================
1034 //=======================================================================
1036 void IFSelect_WorkSession::ClearItems ()
1040 theshareout->Clear(Standard_False);
1044 //=======================================================================
1047 //=======================================================================
1049 Handle(TCollection_HAsciiString) IFSelect_WorkSession::ItemLabel
1050 (const Standard_Integer id) const
1052 Handle(TCollection_HAsciiString) res;
1053 Handle(Standard_Transient) var = Item(id);
1054 if (var.IsNull()) return res;
1055 DeclareAndCast(TCollection_HAsciiString,text,var);
1056 if (!text.IsNull()) {
1057 res = new TCollection_HAsciiString("Text:");
1058 res->AssignCat(text);
1061 DeclareAndCast(IFSelect_IntParam,intpar,var);
1062 if (!intpar.IsNull()) {
1063 res = new TCollection_HAsciiString(intpar->Value());
1064 res->Insert(1,"Integer:");
1067 DeclareAndCast(IFSelect_Selection,sel,var);
1068 if (!sel.IsNull()) {
1069 res = new TCollection_HAsciiString("Selection:");
1070 res->AssignCat(sel->Label().ToCString());
1073 DeclareAndCast(IFSelect_GeneralModifier,mod,var);
1074 if (!mod.IsNull()) {
1075 if (mod->IsKind(STANDARD_TYPE(IFSelect_Modifier)))
1076 res = new TCollection_HAsciiString("ModelModifier:");
1077 else res = new TCollection_HAsciiString("FileModifier:");
1078 res->AssignCat(mod->Label().ToCString());
1081 DeclareAndCast(IFSelect_Dispatch,disp,var);
1082 if (!disp.IsNull()) {
1083 res = new TCollection_HAsciiString("Dispatch:");
1084 res->AssignCat(disp->Label().ToCString());
1087 DeclareAndCast(IFSelect_Transformer,tsf,var);
1088 if (!tsf.IsNull()) {
1089 res = new TCollection_HAsciiString("Transformer:");
1090 res->AssignCat(tsf->Label().ToCString());
1093 DeclareAndCast(IFSelect_SignatureList,slc,var);
1094 if (!slc.IsNull()) {
1095 res = new TCollection_HAsciiString("Counter:");
1096 res->AssignCat(slc->Name());
1099 DeclareAndCast(IFSelect_Signature,sig,var);
1100 if (!sig.IsNull()) {
1101 res = new TCollection_HAsciiString("Signature:");
1102 res->AssignCat(sig->Name());
1105 DeclareAndCast(IFSelect_EditForm,edf,var);
1106 if (!edf.IsNull()) {
1107 res = new TCollection_HAsciiString("EditForm:");
1108 res->AssignCat(edf->Label());
1111 DeclareAndCast(IFSelect_Editor,edt,var);
1112 if (!edt.IsNull()) {
1113 res = new TCollection_HAsciiString("Editor:");
1114 res->AssignCat(edt->Label().ToCString());
1117 res = new TCollection_HAsciiString("VariableType:");
1118 res->AssignCat(var->DynamicType()->Name());
1123 //=======================================================================
1126 //=======================================================================
1128 Handle(TColStd_HSequenceOfInteger) IFSelect_WorkSession::ItemIdents
1129 (const Handle(Standard_Type)& type) const
1131 Handle(TColStd_HSequenceOfInteger) list =
1132 new TColStd_HSequenceOfInteger();
1133 Standard_Integer nb = theitems.Extent();
1134 for (Standard_Integer i = 1; i <= nb; i ++) {
1135 if (theitems.FindKey(i)->IsKind(type)) list->Append(i);
1141 //=======================================================================
1144 //=======================================================================
1146 Handle(TColStd_HSequenceOfHAsciiString) IFSelect_WorkSession::ItemNames
1147 (const Handle(Standard_Type)& type) const
1149 Handle(TColStd_HSequenceOfHAsciiString) list =
1150 new TColStd_HSequenceOfHAsciiString();
1151 for (Dico_IteratorOfDictionaryOfTransient IT(thenames); IT.More(); IT.Next()){
1152 if (IT.Value()->IsKind(type)) list->Append
1153 (new TCollection_HAsciiString(IT.Name().ToCString()));
1159 // .. Recherche par label : recherche en liste(noms) ou iterative
1161 //=======================================================================
1164 //=======================================================================
1166 Handle(TColStd_HSequenceOfHAsciiString) IFSelect_WorkSession::ItemNamesForLabel
1167 (const Standard_CString label) const
1169 Handle(TColStd_HSequenceOfHAsciiString) list =
1170 new TColStd_HSequenceOfHAsciiString();
1171 Standard_Integer i, nb = MaxIdent();
1172 for (i = 1; i <= nb; i ++) {
1173 Handle(TCollection_HAsciiString) lab = ItemLabel(i);
1174 Handle(Standard_Transient) item = Item(i);
1175 if (lab.IsNull()) continue;
1176 if (label[0] != '\0' && lab->Search(label) <= 0) continue;
1178 Handle(TCollection_HAsciiString) nom = Name(Item(i));
1179 if (nom.IsNull()) { nom = new TCollection_HAsciiString(i); nom->Insert(1,'#'); }
1180 else nom = new TCollection_HAsciiString (nom);
1181 list->Append (new TCollection_HAsciiString(lab));
1187 //=======================================================================
1190 //=======================================================================
1192 Standard_Integer IFSelect_WorkSession::NextIdentForLabel
1193 (const Standard_CString label, const Standard_Integer id,
1194 const Standard_Integer mode) const
1196 Standard_Integer nb = MaxIdent();
1197 for (Standard_Integer i = id+1; i <= nb; i ++) {
1198 Handle(TCollection_HAsciiString) lab = ItemLabel(i);
1199 if (lab.IsNull()) continue;
1201 case 0 : if (!strcmp(lab->ToCString(),label)) return i; break; // switch
1202 case 1 : if (lab->Search(label) == 1 ) return i; break;
1203 case 2 : if (lab->Search(label) > 0 ) return i; break;
1204 default : break; // break du switch
1207 return 0; // ici : pas trouve
1211 // #################################################################
1212 // .... Parametres (Int et Text) ....
1214 //=======================================================================
1217 //=======================================================================
1219 Handle(Standard_Transient) IFSelect_WorkSession::NewParamFromStatic
1220 (const Standard_CString statname, const Standard_CString name)
1222 Handle(Standard_Transient) param;
1223 Handle(Interface_Static) stat = Interface_Static::Static(statname);
1224 if (stat.IsNull()) return param;
1225 if (stat->Type() == Interface_ParamInteger) {
1226 Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam;
1227 intpar->SetStaticName (statname);
1230 param = stat->HStringValue();
1232 if (param.IsNull()) return param;
1233 if ( AddNamedItem (name, param) == 0 ) param.Nullify();
1238 //=======================================================================
1241 //=======================================================================
1243 Handle(IFSelect_IntParam) IFSelect_WorkSession::IntParam
1244 (const Standard_Integer id) const
1245 { return Handle(IFSelect_IntParam)::DownCast(Item(id)); }
1248 //=======================================================================
1251 //=======================================================================
1253 Standard_Integer IFSelect_WorkSession::IntValue
1254 (const Handle(IFSelect_IntParam)& par) const
1256 if (!par.IsNull()) return par->Value();
1261 //=======================================================================
1264 //=======================================================================
1266 Handle(IFSelect_IntParam) IFSelect_WorkSession::NewIntParam
1267 (const Standard_CString name)
1269 Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam;
1270 if ( AddNamedItem (name, intpar) == 0 ) intpar.Nullify();
1275 //=======================================================================
1278 //=======================================================================
1280 Standard_Boolean IFSelect_WorkSession::SetIntValue
1281 (const Handle(IFSelect_IntParam)& par, const Standard_Integer val)
1283 if (ItemIdent(par) == 0) return Standard_False;
1285 return Standard_True;
1289 //=======================================================================
1292 //=======================================================================
1294 Handle(TCollection_HAsciiString) IFSelect_WorkSession::TextParam
1295 (const Standard_Integer id) const
1296 { return Handle(TCollection_HAsciiString)::DownCast(Item(id)); }
1299 //=======================================================================
1302 //=======================================================================
1304 TCollection_AsciiString IFSelect_WorkSession::TextValue
1305 (const Handle(TCollection_HAsciiString)& par) const
1307 if (!par.IsNull()) return TCollection_AsciiString(par->ToCString());
1308 else return TCollection_AsciiString();
1312 Handle(TCollection_HAsciiString) IFSelect_WorkSession::NewTextParam
1313 (const Standard_CString name)
1315 Handle(TCollection_HAsciiString) textpar = new TCollection_HAsciiString("");
1316 if ( AddNamedItem (name, textpar) == 0 ) textpar.Nullify();
1321 //=======================================================================
1324 //=======================================================================
1326 Standard_Boolean IFSelect_WorkSession::SetTextValue
1327 (const Handle(TCollection_HAsciiString)& par, const Standard_CString val)
1329 if (ItemIdent(par) == 0) return Standard_False;
1330 par->Clear(); par->AssignCat(val);
1331 return Standard_True;
1334 // ########################################################################
1335 // .... SIGNATURES ....
1337 //=======================================================================
1340 //=======================================================================
1342 Handle(IFSelect_Signature) IFSelect_WorkSession::Signature
1343 (const Standard_Integer id) const
1344 { return GetCasted(IFSelect_Signature,Item(id)); }
1346 Standard_CString IFSelect_WorkSession::SignValue
1347 (const Handle(IFSelect_Signature)& sign, const Handle(Standard_Transient)& ent) const
1349 if (sign.IsNull() || themodel.IsNull()) return "";
1350 if (StartingNumber(ent) == 0) return "";
1351 return sign->Value (ent,themodel);
1354 // ########################################################################
1355 // .... SELECTIONS & Cie ....
1357 //=======================================================================
1360 //=======================================================================
1362 Handle(IFSelect_Selection) IFSelect_WorkSession::Selection
1363 (const Standard_Integer id) const
1364 { return GetCasted(IFSelect_Selection,Item(id)); }
1367 //=======================================================================
1370 //=======================================================================
1372 Interface_EntityIterator IFSelect_WorkSession::EvalSelection
1373 (const Handle(IFSelect_Selection)& sel) const
1375 Interface_EntityIterator iter;
1377 errhand = Standard_False;
1380 iter = EvalSelection(sel); // appel normal (donc, code pas duplique)
1382 catch (Standard_Failure) {
1383 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1384 sout<<" **** Interruption EvalSelection par Exception : ****\n";
1385 sout<<Standard_Failure::Caught()->GetMessageString();
1386 sout<<"\n Abandon"<<endl;
1388 errhand = theerrhand;
1392 if (thegraph.IsNull()) return iter;
1393 iter = sel->UniqueResult(thegraph->Graph());
1398 //=======================================================================
1401 //=======================================================================
1403 IFSelect_SelectionIterator IFSelect_WorkSession::Sources
1404 (const Handle(IFSelect_Selection)& sel) const
1406 return IFSelect_SelectionIterator (sel);
1410 //=======================================================================
1413 //=======================================================================
1415 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::SelectionResult
1416 (const Handle(IFSelect_Selection)& sel) const
1418 Handle(TColStd_HSequenceOfTransient) res;
1420 errhand = Standard_False;
1423 res = SelectionResult(sel); // appel normal (->code unique)
1425 catch (Standard_Failure) {
1426 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1427 sout<<" **** Interruption SelectionResult par Exception : ****\n";
1428 sout<<Standard_Failure::Caught()->GetMessageString();
1429 sout<<"\n Abandon"<<endl;
1431 errhand = theerrhand;
1436 cout<< " *** Data for Evaluation not available ***"<<endl;
1437 return new TColStd_HSequenceOfTransient();
1439 // if (ItemIdent(sel) == 0)
1441 { cout << " Selection : Unknown"<<endl; return res; } //cout<<Handle
1442 return EvalSelection (sel).Content();
1446 //=======================================================================
1449 //=======================================================================
1451 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::SelectionResultFromList
1452 (const Handle(IFSelect_Selection)& sel,
1453 const Handle(TColStd_HSequenceOfTransient)& list) const
1455 if (list.IsNull()) return SelectionResult (sel);
1456 DeclareAndCast(IFSelect_SelectDeduct,deduct,sel);
1457 if (deduct.IsNull()) return SelectionResult (sel);
1459 // On va chercher la derniere deduction de la chaine des inputs
1460 Handle(IFSelect_Selection) ssel, newinput;
1462 Standard_Integer i, nb = MaxIdent();
1463 for (i = 1; i <= nb * 2; i ++) {
1464 newinput = deduct->Input();
1465 deduct = GetCasted(IFSelect_SelectDeduct,newinput);
1466 if (deduct.IsNull()) break;
1470 // on y est (enfin, on devrait)
1471 // ssel est la derniere selection auscultee, deduct son downcast
1472 // input son Input (nulle si sel pas une deduction)
1473 deduct = GetCasted(IFSelect_SelectDeduct,ssel);
1475 deduct->Alternate()->SetList (list);
1477 // On execute puis on nettoie
1478 Handle(TColStd_HSequenceOfTransient) res = SelectionResult (sel);
1479 //// deduct->SetInput (newinput);
1484 //=======================================================================
1487 //=======================================================================
1489 Standard_Boolean IFSelect_WorkSession::SetItemSelection
1490 (const Handle(Standard_Transient)& item,
1491 const Handle(IFSelect_Selection)& sel)
1493 DeclareAndCast(IFSelect_Dispatch,disp,item);
1494 DeclareAndCast(IFSelect_GeneralModifier,modif,item);
1495 if (!disp.IsNull()) {
1496 if (ItemIdent(disp) == 0) return Standard_False;
1497 // Selection Nulle : Annuler FinalSelection
1498 if (!sel.IsNull() && ItemIdent(sel) == 0) return Standard_False;
1499 disp->SetFinalSelection(sel);
1500 return Standard_True;
1502 if (!modif.IsNull()) {
1503 if (ItemIdent(modif) == 0) return Standard_False;
1504 if (!sel.IsNull() && ItemIdent(sel) == 0) return Standard_False;
1505 // Selection Nulle : Annuler Selection
1506 modif->SetSelection(sel);
1507 return Standard_True;
1509 return Standard_False;
1513 //=======================================================================
1516 //=======================================================================
1518 Standard_Boolean IFSelect_WorkSession::ResetItemSelection
1519 (const Handle(Standard_Transient)& item)
1521 Handle(IFSelect_Selection) nulsel;
1522 return SetItemSelection (item,nulsel);
1526 //=======================================================================
1529 //=======================================================================
1531 Handle(IFSelect_Selection) IFSelect_WorkSession::ItemSelection
1532 (const Handle(Standard_Transient)& item) const
1534 Handle(IFSelect_Selection) sel;
1535 DeclareAndCast(IFSelect_Dispatch,disp,item);
1536 DeclareAndCast(IFSelect_GeneralModifier,modif,item);
1537 if (ItemIdent(disp) > 0) return disp->FinalSelection();
1538 if (ItemIdent(modif) > 0) return modif->Selection();
1539 return sel; // Nul ou inconnu -> Null
1542 // ######################################################################
1543 // .... Les COMPTEURS ....
1545 //=======================================================================
1548 //=======================================================================
1550 Handle(IFSelect_SignCounter) IFSelect_WorkSession::SignCounter
1551 (const Standard_Integer id) const
1552 { return GetCasted(IFSelect_SignCounter,Item(id)); }
1555 //=======================================================================
1558 //=======================================================================
1560 Standard_Boolean IFSelect_WorkSession::ComputeCounter
1561 (const Handle(IFSelect_SignCounter)& counter, const Standard_Boolean forced)
1563 if (counter.IsNull()) return Standard_False;
1564 if (!ComputeGraph()) return Standard_False;
1565 return counter->ComputeSelected (Graph(),forced);
1569 //=======================================================================
1572 //=======================================================================
1574 Standard_Boolean IFSelect_WorkSession::ComputeCounterFromList
1575 (const Handle(IFSelect_SignCounter)& counter,
1576 const Handle(TColStd_HSequenceOfTransient)& list,
1577 const Standard_Boolean clear)
1579 if (counter.IsNull()) return Standard_False;
1580 if (clear) counter->Clear();
1581 if (list.IsNull()) return ComputeCounter (counter,Standard_True);
1582 counter->AddList (list,themodel);
1583 return Standard_True;
1586 // ######################################################################
1587 // .... Les DISPATCHES ....
1589 //=======================================================================
1592 //=======================================================================
1594 Handle(TColStd_HSequenceOfInteger) IFSelect_WorkSession::AppliedDispatches
1597 Handle(TColStd_HSequenceOfInteger) list = new TColStd_HSequenceOfInteger();
1598 Standard_Integer nb = theshareout->NbDispatches();
1599 for (Standard_Integer i = 1; i <= nb; i ++) {
1600 list->Append (ItemIdent(theshareout->Dispatch(i)));
1606 //=======================================================================
1609 //=======================================================================
1611 void IFSelect_WorkSession::ClearShareOut (const Standard_Boolean onlydisp)
1613 theshareout->Clear(onlydisp);
1617 //=======================================================================
1620 //=======================================================================
1622 Handle(IFSelect_Dispatch) IFSelect_WorkSession::Dispatch
1623 (const Standard_Integer id) const
1625 return GetCasted(IFSelect_Dispatch,Item(id));
1629 //=======================================================================
1632 //=======================================================================
1634 Standard_Integer IFSelect_WorkSession::DispatchRank
1635 (const Handle(IFSelect_Dispatch)& disp) const
1637 if (ItemIdent(disp) == 0) return 0;
1638 return theshareout->DispatchRank(disp);
1641 // ######################################################################
1642 // .... Les MODIFIERS ....
1644 //=======================================================================
1647 //=======================================================================
1649 Handle(IFSelect_ModelCopier) IFSelect_WorkSession::ModelCopier () const
1655 //=======================================================================
1658 //=======================================================================
1660 void IFSelect_WorkSession::SetModelCopier
1661 (const Handle(IFSelect_ModelCopier)& copier)
1664 thecopier->SetShareOut(theshareout);
1668 //=======================================================================
1671 //=======================================================================
1673 Standard_Integer IFSelect_WorkSession::NbFinalModifiers
1674 (const Standard_Boolean formodel) const
1676 return theshareout->NbModifiers(formodel);
1680 //=======================================================================
1683 //=======================================================================
1685 Handle(TColStd_HSequenceOfInteger) IFSelect_WorkSession::FinalModifierIdents
1686 (const Standard_Boolean formodel) const
1688 // return ItemIdents(STANDARD_TYPE(IFSelect_Modifier));
1689 // On donne la liste dans l ordre du ModelCopier, qui fait foi
1690 Handle(TColStd_HSequenceOfInteger) list = new TColStd_HSequenceOfInteger();
1691 Standard_Integer nbm = theshareout->NbModifiers(formodel);
1692 for (Standard_Integer i = 1; i <= nbm; i ++)
1693 list->Append(ItemIdent(theshareout->GeneralModifier(formodel,i)));
1698 //=======================================================================
1701 //=======================================================================
1703 Handle(IFSelect_GeneralModifier) IFSelect_WorkSession::GeneralModifier
1704 (const Standard_Integer id) const
1706 return GetCasted(IFSelect_GeneralModifier,Item(id));
1710 //=======================================================================
1713 //=======================================================================
1715 Handle(IFSelect_Modifier) IFSelect_WorkSession::ModelModifier
1716 (const Standard_Integer id) const
1718 return GetCasted(IFSelect_Modifier,Item(id));
1722 //=======================================================================
1725 //=======================================================================
1727 Standard_Integer IFSelect_WorkSession::ModifierRank
1728 (const Handle(IFSelect_GeneralModifier)& modif) const
1730 if (ItemIdent(modif) == 0) return 0;
1731 return theshareout->ModifierRank(modif);
1735 //=======================================================================
1738 //=======================================================================
1740 Standard_Boolean IFSelect_WorkSession::ChangeModifierRank
1741 (const Standard_Boolean formodel,
1742 const Standard_Integer before, const Standard_Integer after)
1744 return theshareout->ChangeModifierRank(formodel,before,after);
1748 //=======================================================================
1751 //=======================================================================
1753 void IFSelect_WorkSession::ClearFinalModifiers ()
1755 Handle(TColStd_HSequenceOfInteger) list = FinalModifierIdents (Standard_True);
1756 Standard_Integer nb = list->Length();
1757 Standard_Integer i; // svv #1
1758 for (i = 1; i <= nb; i ++)
1759 RemoveItem(GeneralModifier(list->Value(i)));
1760 list = FinalModifierIdents (Standard_False);
1761 nb = list->Length();
1762 for (i = 1; i <= nb; i ++)
1763 RemoveItem(GeneralModifier(list->Value(i)));
1767 //=======================================================================
1770 //=======================================================================
1772 Standard_Boolean IFSelect_WorkSession::SetAppliedModifier
1773 (const Handle(IFSelect_GeneralModifier)& modif,
1774 const Handle(Standard_Transient)& item)
1776 if (ItemIdent(modif) == 0) return Standard_False;
1778 if (item.IsNull()) return Standard_False;
1779 if (item == theshareout) {
1780 theshareout->AddModifier(modif,0);
1781 return Standard_True;
1783 if (item->IsKind(STANDARD_TYPE(IFSelect_Dispatch))) {
1784 DeclareAndCast(IFSelect_Dispatch,disp,item);
1785 theshareout->AddModifier(modif,0);
1786 modif->SetDispatch(disp);
1787 return Standard_True;
1789 if (item->IsKind(STANDARD_TYPE(IFSelect_TransformStandard))) {
1790 DeclareAndCast(IFSelect_TransformStandard,stf,item);
1791 DeclareAndCast(IFSelect_Modifier,tmod,modif);
1792 if (tmod.IsNull()) return Standard_False;
1793 stf->AddModifier (tmod);
1794 theshareout->RemoveItem(modif);
1795 return Standard_True;
1797 return Standard_False;
1801 //=======================================================================
1804 //=======================================================================
1806 Standard_Boolean IFSelect_WorkSession::ResetAppliedModifier
1807 (const Handle(IFSelect_GeneralModifier)& modif)
1809 if (ItemIdent(modif) == 0) return Standard_False;
1811 return theshareout->RemoveItem(modif);
1815 //=======================================================================
1818 //=======================================================================
1820 Handle(Standard_Transient) IFSelect_WorkSession::UsesAppliedModifier
1821 (const Handle(IFSelect_GeneralModifier)& modif) const
1823 Handle(Standard_Transient) res;
1824 if (ItemIdent(modif) == 0) return res;
1825 if (theshareout->ModifierRank(modif) == 0) return res;
1826 res = modif->Dispatch();
1827 if (res.IsNull()) res = theshareout;
1831 // #################################################################
1832 // .... Transformer ....
1834 //=======================================================================
1837 //=======================================================================
1839 Handle(IFSelect_Transformer) IFSelect_WorkSession::Transformer
1840 (const Standard_Integer id) const
1842 return GetCasted(IFSelect_Transformer,Item(id));
1846 //=======================================================================
1849 //=======================================================================
1851 Standard_Integer IFSelect_WorkSession::RunTransformer
1852 (const Handle(IFSelect_Transformer)& transf)
1854 Standard_Integer effect = 0;
1855 if (transf.IsNull() || !IsLoaded()) return effect;
1856 Handle(Interface_InterfaceModel) newmod; // Null au depart
1857 Interface_CheckIterator checks;
1858 checks.SetName("X-STEP WorkSession : RunTransformer");
1859 Standard_Boolean res = transf->Perform
1860 (thegraph->Graph(),theprotocol,checks,newmod);
1862 if (!checks.IsEmpty(Standard_False)) {
1863 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1864 sout<<" ** RunTransformer has produced Check Messages : **"<<endl;
1865 checks.Print (sout,themodel,Standard_False);
1867 thecheckdone = Standard_False;
1868 thecheckrun = checks;
1870 if (newmod.IsNull()) return (res ? 1 : -1);
1871 // MISE A JOUR des SelectPointed
1872 Handle(TColStd_HSequenceOfInteger) list =
1873 ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed));
1874 Standard_Integer nb = list->Length();
1875 for (Standard_Integer i = 1; i <= nb; i ++) {
1876 DeclareAndCast(IFSelect_SelectPointed,sp,Item(list->Value(i)));
1879 if (newmod == themodel) {
1880 effect = (res ? 2 : -2);
1881 if (!res) return effect;
1882 Handle(Interface_Protocol) newproto = theprotocol;
1883 if (transf->ChangeProtocol(newproto))
1884 { effect = 4; theprotocol = newproto; thegtool->SetProtocol(newproto); }
1885 return (ComputeGraph(Standard_True) ? 4 : -4);
1887 effect = (res ? 3 : -3);
1888 if (!res) return effect;
1889 Handle(Interface_Protocol) newproto = theprotocol;
1890 if (transf->ChangeProtocol(newproto))
1891 { effect = 5; theprotocol = newproto; thegtool->SetProtocol(newproto); }
1892 theoldel = themodel;
1893 SetModel(newmod,Standard_False);
1899 //=======================================================================
1902 //=======================================================================
1904 Standard_Integer IFSelect_WorkSession::RunModifier
1905 (const Handle(IFSelect_Modifier)& modif, const Standard_Boolean copy)
1907 Handle(IFSelect_Selection) sel; // null
1908 return RunModifierSelected (modif,sel,copy);
1912 //=======================================================================
1915 //=======================================================================
1917 Standard_Integer IFSelect_WorkSession::RunModifierSelected
1918 (const Handle(IFSelect_Modifier)& modif,
1919 const Handle(IFSelect_Selection)& sel, const Standard_Boolean copy)
1921 if (ItemIdent(modif) == 0) return Standard_False;
1922 Handle(IFSelect_TransformStandard) stf = new IFSelect_TransformStandard;
1923 stf->SetCopyOption(copy);
1924 stf->SetSelection (sel);
1925 stf->AddModifier (modif);
1926 return RunTransformer (stf);
1930 //=======================================================================
1933 //=======================================================================
1935 Handle(IFSelect_Transformer) IFSelect_WorkSession::NewTransformStandard
1936 (const Standard_Boolean copy, const Standard_CString name)
1938 Handle(IFSelect_TransformStandard) stf = new IFSelect_TransformStandard;
1939 stf->SetCopyOption(copy);
1940 if (AddNamedItem (name, stf) == 0) stf.Nullify();
1945 // Ceci est une action directe : pourrait etre fait par un Transformer ...
1946 //=======================================================================
1949 //=======================================================================
1951 Standard_Boolean IFSelect_WorkSession::SetModelContent
1952 (const Handle(IFSelect_Selection)& sel, const Standard_Boolean keep)
1954 if (sel.IsNull() || !IsLoaded()) return Standard_False;
1955 Interface_EntityIterator list = sel->UniqueResult(thegraph->Graph());
1956 if (list.NbEntities() == 0) return Standard_False;
1958 Handle(Interface_InterfaceModel) newmod = themodel->NewEmptyModel();
1959 Interface_CopyTool TC(themodel,theprotocol);
1960 Standard_Integer i, nb = themodel->NbEntities();
1962 for (list.Start(); list.More(); list.Next())
1963 TC.TransferEntity (list.Value());
1965 Standard_Integer* flags = new Standard_Integer[nb+1];
1966 for (i = 0; i <= nb; i ++) flags[i] = 0;
1967 for (list.Start(); list.More(); list.Next()) {
1968 Standard_Integer num = themodel->Number(list.Value());
1969 if (num <= nb) flags[num] = 1;
1971 for (i = 1; i <= nb; i ++) {
1972 if (flags[i] == 0) TC.TransferEntity (themodel->Value(i));
1976 TC.FillModel(newmod);
1977 if (newmod->NbEntities() == 0) return Standard_False;
1978 // Mettre a jour (ne pas oublier SelectPointed)
1979 theoldel = themodel;
1980 SetModel(newmod,Standard_False);
1981 // MISE A JOUR des SelectPointed
1982 Handle(TColStd_HSequenceOfInteger) pts =
1983 ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed));
1985 for (i = 1; i <= nb; i ++) {
1986 DeclareAndCast(IFSelect_SelectPointed,sp,Item(pts->Value(i)));
1987 sp->Update(TC.Control());
1989 return Standard_True;
1993 // #################################################################
1994 // .... File Name ....
1996 //=======================================================================
1999 //=======================================================================
2001 Handle(TCollection_HAsciiString) IFSelect_WorkSession::FilePrefix () const
2003 return theshareout->Prefix();
2007 //=======================================================================
2010 //=======================================================================
2012 Handle(TCollection_HAsciiString) IFSelect_WorkSession::DefaultFileRoot () const
2014 return theshareout->DefaultRootName();
2018 //=======================================================================
2021 //=======================================================================
2023 Handle(TCollection_HAsciiString) IFSelect_WorkSession::FileExtension () const
2025 return theshareout->Extension();
2029 //=======================================================================
2032 //=======================================================================
2034 Handle(TCollection_HAsciiString) IFSelect_WorkSession::FileRoot
2035 (const Handle(IFSelect_Dispatch)& disp) const
2037 return theshareout->RootName(theshareout->DispatchRank(disp));
2041 //=======================================================================
2044 //=======================================================================
2046 void IFSelect_WorkSession::SetFilePrefix (const Standard_CString name)
2048 theshareout->SetPrefix (new TCollection_HAsciiString(name));
2052 //=======================================================================
2055 //=======================================================================
2057 void IFSelect_WorkSession::SetFileExtension (const Standard_CString name)
2059 theshareout->SetExtension (new TCollection_HAsciiString(name));
2063 //=======================================================================
2066 //=======================================================================
2068 Standard_Boolean IFSelect_WorkSession::SetDefaultFileRoot
2069 (const Standard_CString name)
2071 Handle(TCollection_HAsciiString) defrt;
2072 if (name[0] != '\0') defrt = new TCollection_HAsciiString(name);
2073 return theshareout->SetDefaultRootName (defrt);
2077 //=======================================================================
2080 //=======================================================================
2082 Standard_Boolean IFSelect_WorkSession::SetFileRoot
2083 (const Handle(IFSelect_Dispatch)& disp, const Standard_CString namefile)
2085 Standard_Integer id = ItemIdent(disp);
2086 if (id == 0) return Standard_False;
2087 Standard_Integer nd = theshareout->DispatchRank(disp);
2088 /* if (theonlynamed) {
2089 if (nd == 0 && namefile[0] != 0)
2090 theshareout->AddDispatch(disp);
2091 else if (nd != 0 && namefile[0] == 0)
2092 theshareout->RemoveDispatch (nd);
2094 if (nd == 0) return Standard_False;
2095 // The order below prevented to change the root name on a given dispatch !
2096 // if (theshareout->HasRootName(nd)) return Standard_False;
2097 Handle(TCollection_HAsciiString) filename;
2098 if (namefile[0] != '\0') filename = new TCollection_HAsciiString (namefile);
2099 return theshareout->SetRootName(nd,filename);
2103 //=======================================================================
2106 //=======================================================================
2108 Standard_CString IFSelect_WorkSession::GiveFileRoot
2109 (const Standard_CString file) const
2111 OSD_Path path (file);
2112 if (!path.IsValid(TCollection_AsciiString(file))) return file; // tant pis ..
2113 bufstr = path.Name();
2114 return bufstr.ToCString();
2118 //=======================================================================
2121 //=======================================================================
2123 Standard_CString IFSelect_WorkSession::GiveFileComplete
2124 (const Standard_CString file) const
2126 // ajouter si besoin : Prefix; Extension
2127 bufstr.Clear(); bufstr.AssignCat (file);
2128 Standard_Integer i,j = 0,nb = bufstr.Length();
2129 Handle(TCollection_HAsciiString) ext = FileExtension ();
2130 if (!ext.IsNull()) {
2131 char val0 = '\0'; if (ext->Length() > 0) val0 = ext->Value(1);
2132 for (i = nb; i > 0; i --) if (bufstr.Value(i) == val0) { j = 1; break; }
2133 if (j == 0) bufstr.AssignCat (ext->ToCString());
2135 Handle(TCollection_HAsciiString) pre = FilePrefix ();
2136 if (!pre.IsNull()) {
2137 char val1 = '\0'; if (pre->Length() > 0) val1 = pre->Value(pre->Length());
2139 for (i = nb; i > 0; i --) if (bufstr.Value(i) == val1) { j = 1; break; }
2140 if (j == 0) bufstr.Insert (1,pre->ToCString());
2143 return bufstr.ToCString();
2147 //=======================================================================
2150 //=======================================================================
2152 void IFSelect_WorkSession::ClearFile ()
2154 thecopier->ClearResult();
2155 theshareout->ClearResult(Standard_True);
2159 //=======================================================================
2162 //=======================================================================
2164 void IFSelect_WorkSession::EvaluateFile ()
2167 if (!IsLoaded()) return;
2168 Interface_CheckIterator checks;
2170 errhand = Standard_False;
2173 EvaluateFile(); // appel normal (donc, code pas duplique)
2175 catch (Standard_Failure) {
2176 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2177 sout<<" **** Interruption EvaluateFile par Exception : ****\n";
2178 sout<<Standard_Failure::Caught()->GetMessageString();
2179 sout<<"\n Abandon"<<endl;
2180 checks.CCheck(0)->AddFail ("Exception Raised -> Abandon");
2182 errhand = theerrhand;
2183 thecheckrun = checks;
2187 IFSelect_ShareOutResult R(theshareout,thegraph->Graph());
2188 checks = thecopier->Copy (R,thelibrary,theprotocol);
2189 if (!checks.IsEmpty(Standard_False)) {
2190 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2191 sout<<" ** EvaluateFile has produced Check Messages : **"<<endl;
2192 checks.Print (sout,themodel,Standard_False);
2194 thecopier->SetRemaining (thegraph->CGraph());
2195 thecheckrun = checks;
2199 //=======================================================================
2202 //=======================================================================
2204 Standard_Integer IFSelect_WorkSession::NbFiles () const
2206 return thecopier->NbFiles();
2210 //=======================================================================
2213 //=======================================================================
2215 Handle(Interface_InterfaceModel) IFSelect_WorkSession::FileModel
2216 (const Standard_Integer num) const
2218 Handle(Interface_InterfaceModel) mod;
2219 if (num > 0 && num <= NbFiles()) mod = thecopier->FileModel(num);
2224 //=======================================================================
2227 //=======================================================================
2229 TCollection_AsciiString IFSelect_WorkSession::FileName
2230 (const Standard_Integer num) const
2232 TCollection_AsciiString name;
2233 if (num > 0 && num <= NbFiles()) name = thecopier->FileName(num);
2238 //=======================================================================
2241 //=======================================================================
2243 void IFSelect_WorkSession::BeginSentFiles (const Standard_Boolean record)
2245 thecopier->BeginSentFiles(theshareout,record);
2249 //=======================================================================
2252 //=======================================================================
2254 Handle(TColStd_HSequenceOfHAsciiString) IFSelect_WorkSession::SentFiles () const
2256 return thecopier->SentFiles();
2260 // #########################################################################
2261 // .... Action de Transfert proprement dite : la grande affaire ! ....
2263 //=======================================================================
2266 //=======================================================================
2268 Standard_Boolean IFSelect_WorkSession::SendSplit ()
2271 Interface_CheckIterator checks;
2274 errhand = Standard_False;
2277 return SendSplit(); // appel normal (donc, code pas duplique)
2279 catch (Standard_Failure) {
2280 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2281 sout<<" **** Interruption SendSplit par Exception : ****\n";
2282 sout<<Standard_Failure::Caught()->GetMessageString();
2283 sout<<"\n Abandon"<<endl;
2284 checks.CCheck(0)->AddFail ("Exception Raised -> Abandon");
2286 errhand = theerrhand;
2287 thecheckrun = checks;
2288 return Standard_False;
2291 if (thelibrary.IsNull()) {
2292 checks.CCheck(0)->AddFail("WorkLibrary undefined");
2293 thecheckrun = checks;
2294 return Standard_False;
2297 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2298 sout<< " *** Data for SendSplit not available ***"<<endl;
2299 checks.CCheck(0)->AddFail("Data not available");
2300 thecheckrun = checks;
2301 return Standard_False;
2304 if (NbFiles() > 0) checks = thecopier->SendCopied (thelibrary,theprotocol);
2307 IFSelect_ShareOutResult eval (ShareOut(), thegraph->Graph());
2308 checks = thecopier->Send (eval, thelibrary, theprotocol);
2309 thecopier->SetRemaining (thegraph->CGraph());
2312 if (theshareout.IsNull()) return Standard_False;
2313 Standard_Integer i, nbd = theshareout->NbDispatches();
2314 Standard_Integer nf = 0;
2315 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2316 sout<<" SendSplit .. ";
2317 for (i = 1; i <= nbd; i ++) {
2318 Handle(IFSelect_Dispatch) disp = theshareout->Dispatch(i);
2319 if (disp.IsNull()) continue;
2320 IFGraph_SubPartsIterator packs(thegraph->Graph(),Standard_False);
2321 disp->Packets (thegraph->Graph(),packs);
2322 for (packs.Start(); packs.More(); packs.Next()) {
2323 Interface_EntityIterator iter = packs.Entities();
2324 if (iter.NbEntities() == 0) continue;
2325 // Ecrire une liste d entites
2326 Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
2327 sp->SetList (iter.Content());
2329 TCollection_AsciiString filnam (nf);
2330 filnam.Insert (1,"_");
2331 Handle(TCollection_HAsciiString) filepart;
2332 filepart = FileRoot(disp);
2333 if (!filepart.IsNull()) filnam.Insert(1,filepart->ToCString());
2334 filepart = FilePrefix();
2335 if (!filepart.IsNull()) filnam.Insert(1,filepart->ToCString());
2336 filepart = FileExtension();
2337 if (!filepart.IsNull()) filnam.AssignCat (filepart->ToCString());
2338 IFSelect_ReturnStatus stat = SendSelected (filnam.ToCString(),sp);
2339 if (stat != IFSelect_RetDone) cout<<"File "<<filnam<<" failed"<<endl;
2342 sout<<" .. Files Written : "<<nf<<endl;
2344 thecheckrun = checks;
2345 return Standard_True;
2349 //=======================================================================
2352 //=======================================================================
2354 Handle(IFSelect_PacketList) IFSelect_WorkSession::EvalSplit () const
2356 Handle(IFSelect_PacketList) pks;
2357 if (!IsLoaded()) return pks;
2358 IFSelect_ShareOutResult sho (ShareOut(), thegraph->Graph());
2359 return sho.Packets();
2363 //=======================================================================
2366 //=======================================================================
2368 Interface_EntityIterator IFSelect_WorkSession::SentList
2369 (const Standard_Integer newcount) const
2371 Interface_EntityIterator iter;
2372 if (!IsLoaded()) return iter;
2373 const Interface_Graph& G = thegraph->Graph();
2374 Standard_Integer nb = G.Size();
2376 for ( i = 1; i <= nb; i ++) {
2377 Standard_Integer stat = G.Status(i);
2378 if ( (stat > 0 && newcount < 0) || stat == newcount)
2379 iter.GetOneItem(G.Entity(i));
2385 //=======================================================================
2388 //=======================================================================
2390 Standard_Integer IFSelect_WorkSession::MaxSendingCount () const
2392 Standard_Integer newcount = 0;
2393 if (!IsLoaded()) return newcount;
2394 const Interface_Graph& G = thegraph->Graph();
2395 Standard_Integer nb = G.Size();
2397 for (i = 1; i <= nb; i ++) {
2398 Standard_Integer stat = G.Status(i);
2399 if (stat > newcount) newcount = stat;
2405 //=======================================================================
2408 //=======================================================================
2410 Standard_Boolean IFSelect_WorkSession::SetRemaining
2411 (const IFSelect_RemainMode mode)
2413 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2414 if (!IsLoaded()) return Standard_False;
2415 if (mode == IFSelect_RemainForget) {
2416 Standard_Integer nb = thegraph->Graph().Size();
2417 for (Standard_Integer i = 1; i <= nb; i ++)
2418 thegraph->CGraph().SetStatus (i,0);
2420 return Standard_True;
2421 } else if (mode == IFSelect_RemainCompute) {
2422 Handle(Interface_InterfaceModel) newmod;
2423 Interface_CopyTool TC(themodel,theprotocol);
2424 thecopier->CopiedRemaining (thegraph->Graph(),thelibrary,TC,newmod);
2425 if (newmod.IsNull()) {
2426 sout<<" No Remaining Data recorded"<<endl; return Standard_False;
2427 } else if (newmod == themodel) {
2428 sout<<" Remaining causes all original data to be kept"<<endl;
2429 thecopier->SetRemaining (thegraph->CGraph());
2430 return Standard_False;
2432 theoldel = themodel;
2433 SetModel(newmod,Standard_False);
2434 // MISE A JOUR des SelectPointed
2435 Handle(TColStd_HSequenceOfInteger) list =
2436 ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed));
2437 Standard_Integer nb = list->Length();
2438 for (Standard_Integer i = 1; i <= nb; i ++) {
2439 DeclareAndCast(IFSelect_SelectPointed,sp,Item(list->Value(i)));
2440 sp->Update(TC.Control());
2442 return Standard_True;
2444 } else if (mode == IFSelect_RemainDisplay) {
2445 Standard_Integer ne = 0;
2446 Standard_Integer nb = thegraph->Graph().Size();
2447 for (Standard_Integer i = 1; i <= nb; i ++)
2448 { if (thegraph->Graph().Status(i) >= 0) ne ++; }
2450 sout<<" - All entities are remaining, none yet sent"<<endl; return Standard_True;
2452 Interface_EntityIterator iter = SentList(0);
2453 nb = iter.NbEntities();
2455 sout<<" - No recorded remaining entities"<<endl; return Standard_True;
2457 sout <<" -- Recorded Remaining (not yet sent) Entities --"<<endl;
2458 ListEntities(iter,2);
2459 sout << " -- Maximum Sending Count (i.e. duplication in files) "<<
2460 MaxSendingCount() << endl;
2463 sout<< " - Now, dispatches are deactivated"<<endl;
2464 nb = theshareout->NbDispatches();
2465 for (Standard_Integer i = nb; i > theshareout->LastRun(); i --)
2466 theshareout->RemoveDispatch(i);
2468 return Standard_True;
2469 } else if (mode == IFSelect_RemainUndo) {
2470 if (theoldel.IsNull()) return Standard_False;
2471 SetModel(theoldel); theoldel.Nullify();
2472 return Standard_True;
2474 else return Standard_False;
2478 //=======================================================================
2481 //=======================================================================
2483 IFSelect_ReturnStatus IFSelect_WorkSession::SendAll
2484 (const Standard_CString filename, const Standard_Boolean computegraph)
2487 Interface_CheckIterator checks;
2488 if (!IsLoaded()) return IFSelect_RetVoid;
2489 if (thelibrary.IsNull()) {
2490 checks.CCheck(0)->AddFail("WorkLibrary undefined");
2491 thecheckrun = checks;
2492 return IFSelect_RetError;
2496 errhand = Standard_False;
2499 ComputeGraph(computegraph);
2500 checks = thecopier->SendAll(filename,thegraph->Graph(),thelibrary,theprotocol);
2502 catch (Standard_Failure) {
2503 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2504 sout<<" **** Interruption SendAll par Exception : ****\n";
2505 sout<<Standard_Failure::Caught()->GetMessageString();
2506 sout<<"\n Abandon"<<endl;
2507 errhand = theerrhand;
2508 checks.CCheck(0)->AddFail ("Exception Raised -> Abandon");
2509 thecheckrun = checks;
2510 return IFSelect_RetFail;
2513 else checks = thecopier->SendAll(filename,thegraph->Graph(),thelibrary,theprotocol);
2514 Handle(Interface_Check) aMainFail = checks.CCheck(0);
2515 if (!aMainFail.IsNull() && aMainFail->HasFailed ())
2517 return IFSelect_RetStop;
2519 if (theloaded.Length() == 0) theloaded.AssignCat(filename);
2520 thecheckrun = checks;
2521 if (checks.IsEmpty(Standard_True)) return IFSelect_RetDone;
2522 return IFSelect_RetError;
2526 //=======================================================================
2529 //=======================================================================
2531 IFSelect_ReturnStatus IFSelect_WorkSession::SendSelected
2532 (const Standard_CString filename,
2533 const Handle(IFSelect_Selection)& sel,
2534 const Standard_Boolean computegraph)
2537 if (!IsLoaded()) return IFSelect_RetVoid;
2538 Interface_CheckIterator checks;
2539 if (thelibrary.IsNull()) {
2540 checks.CCheck(0)->AddFail("WorkLibrary undefined");
2541 thecheckrun = checks;
2542 return IFSelect_RetVoid;
2546 errhand = Standard_False;
2549 ComputeGraph(computegraph);
2550 return SendSelected (filename,sel); // appel normal
2552 catch (Standard_Failure) {
2553 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2554 sout<<" **** Interruption SendSelected par Exception : ****\n";
2555 sout<<Standard_Failure::Caught()->GetMessageString();
2556 sout<<"\n Abandon"<<endl;
2557 checks.CCheck(0)->AddFail ("Exception Raised -> Abandon");
2558 errhand = theerrhand;
2559 thecheckrun = checks;
2560 return IFSelect_RetFail;
2563 // if (ItemIdent(sel) == 0) return 3;
2564 Interface_EntityIterator iter = sel->UniqueResult(thegraph->Graph());
2565 if (iter.NbEntities() == 0) return IFSelect_RetVoid;
2567 checks = thecopier->SendSelected
2568 (filename,thegraph->Graph(),thelibrary,theprotocol,iter);
2569 thecopier->SetRemaining (thegraph->CGraph());
2570 thecheckrun = checks;
2571 if (checks.IsEmpty(Standard_True)) return IFSelect_RetDone;
2572 return IFSelect_RetError;
2576 //=======================================================================
2579 //=======================================================================
2581 IFSelect_ReturnStatus IFSelect_WorkSession::WriteFile
2582 (const Standard_CString filename)
2584 if (WorkLibrary().IsNull()) return IFSelect_RetVoid;
2585 ComputeGraph(Standard_True);
2586 if (!IsLoaded()) return IFSelect_RetVoid;
2587 return SendAll (filename);
2591 //=======================================================================
2594 //=======================================================================
2596 IFSelect_ReturnStatus IFSelect_WorkSession::WriteFile
2597 (const Standard_CString filename, const Handle(IFSelect_Selection)& sel)
2599 if (WorkLibrary().IsNull() || sel.IsNull()) return IFSelect_RetVoid;
2600 ComputeGraph(Standard_True);
2601 if (!IsLoaded()) return IFSelect_RetVoid;
2602 return SendSelected (filename,sel);
2605 // ################################################################
2606 // .... Actions particulieres sur les Selections ....
2608 //=======================================================================
2611 //=======================================================================
2613 Standard_Integer IFSelect_WorkSession::NbSources
2614 (const Handle(IFSelect_Selection)& sel) const
2616 if (ItemIdent(sel) == 0) return 0;
2617 if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectExtract)) ||
2618 sel->IsKind(STANDARD_TYPE(IFSelect_SelectDeduct)) ) return 1;
2619 if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectControl)) ) return 2;
2620 if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectCombine)) ) return
2621 GetCasted(IFSelect_SelectCombine,sel)->NbInputs();
2626 //=======================================================================
2629 //=======================================================================
2631 Handle(IFSelect_Selection) IFSelect_WorkSession::Source
2632 (const Handle(IFSelect_Selection)& sel, const Standard_Integer num) const
2634 Handle(IFSelect_Selection) sr;
2635 if (ItemIdent(sel) == 0) return sr;
2636 if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectExtract)) ) sr =
2637 GetCasted(IFSelect_SelectExtract,sel)->Input();
2638 else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectDeduct)) ) sr =
2639 GetCasted(IFSelect_SelectDeduct,sel)->Input();
2640 else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectControl)) ) {
2641 if (num == 1) sr = GetCasted(IFSelect_SelectControl,sel)->MainInput();
2642 else if (num == 2) sr = GetCasted(IFSelect_SelectControl,sel)->SecondInput();
2644 else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectCombine)) ) sr =
2645 GetCasted(IFSelect_SelectCombine,sel)->Input(num);
2650 //=======================================================================
2653 //=======================================================================
2655 Standard_Boolean IFSelect_WorkSession::IsReversedSelectExtract
2656 (const Handle(IFSelect_Selection)& sel) const
2658 if (ItemIdent(sel) == 0) return Standard_False;
2659 DeclareAndCast(IFSelect_SelectExtract,sxt,sel);
2660 if (sxt.IsNull()) return Standard_False;
2661 return (!sxt->IsDirect());
2665 //=======================================================================
2668 //=======================================================================
2670 Standard_Boolean IFSelect_WorkSession::ToggleSelectExtract
2671 (const Handle(IFSelect_Selection)& sel)
2673 if (ItemIdent(sel) == 0) return Standard_False;
2674 DeclareAndCast(IFSelect_SelectExtract,sxt,sel);
2675 if (sxt.IsNull()) return Standard_False;
2676 sxt->SetDirect(!sxt->IsDirect());
2677 return Standard_True;
2681 //=======================================================================
2684 //=======================================================================
2686 Standard_Boolean IFSelect_WorkSession::SetInputSelection
2687 (const Handle(IFSelect_Selection)& sel,
2688 const Handle(IFSelect_Selection)& inp)
2690 if (ItemIdent(sel) == 0) return Standard_False;
2691 if (!inp.IsNull() && ItemIdent(inp) == 0) return Standard_False;
2692 DeclareAndCast(IFSelect_SelectExtract,sxt,sel);
2693 if (!sxt.IsNull()) { sxt->SetInput(inp); return Standard_True; }
2694 DeclareAndCast(IFSelect_SelectDeduct,sdt,sel);
2695 if (!sdt.IsNull()) { sdt->SetInput(inp); return Standard_True; }
2696 return Standard_False;
2700 //=======================================================================
2703 //=======================================================================
2705 Standard_Boolean IFSelect_WorkSession::SetControl
2706 (const Handle(IFSelect_Selection)& sel,
2707 const Handle(IFSelect_Selection)& sc,
2708 const Standard_Boolean formain)
2710 DeclareAndCast(IFSelect_SelectControl,dsel,sel);
2711 if (ItemIdent(dsel) == 0) return Standard_False;
2712 if (ItemIdent(sc) == 0) return Standard_False;
2713 if (formain) dsel->SetMainInput (sc);
2714 else dsel->SetSecondInput (sc);
2715 return Standard_True;
2719 //=======================================================================
2722 //=======================================================================
2724 Standard_Integer IFSelect_WorkSession::CombineAdd
2725 (const Handle(IFSelect_Selection)& sel,
2726 const Handle(IFSelect_Selection)& seladd,
2727 const Standard_Integer atnum)
2729 DeclareAndCast(IFSelect_SelectCombine,csel,sel);
2730 if (ItemIdent(csel) == 0) return 0;
2731 if (ItemIdent(seladd) == 0) return 0;
2732 csel->Add (seladd,atnum);
2733 return csel->NbInputs();
2737 //=======================================================================
2740 //=======================================================================
2742 Standard_Boolean IFSelect_WorkSession::CombineRemove
2743 (const Handle(IFSelect_Selection)& selcomb,
2744 const Handle(IFSelect_Selection)& selrem)
2746 DeclareAndCast(IFSelect_SelectCombine,csel,selcomb);
2747 if (ItemIdent(csel) == 0) return Standard_False;
2748 if (ItemIdent(selrem) == 0) return Standard_False;
2749 Standard_Integer nb = csel->NbInputs();
2750 for (Standard_Integer i = nb; i > 0; i --) {
2751 if (csel->Input(i) == selrem) {
2753 return Standard_True;
2756 return Standard_True;
2760 //=======================================================================
2763 //=======================================================================
2765 Handle(IFSelect_Selection) IFSelect_WorkSession::NewSelectPointed
2766 (const Handle(TColStd_HSequenceOfTransient)& list,
2767 const Standard_CString name)
2769 Handle(IFSelect_SelectPointed) sel = new IFSelect_SelectPointed;
2770 if (!list.IsNull()) sel->AddList (list);
2771 if (AddNamedItem (name,sel) == 0) sel.Nullify();
2776 //=======================================================================
2779 //=======================================================================
2781 Standard_Boolean IFSelect_WorkSession::SetSelectPointed
2782 (const Handle(IFSelect_Selection)& sel,
2783 const Handle(TColStd_HSequenceOfTransient)& list,
2784 const Standard_Integer mode) const
2786 DeclareAndCast(IFSelect_SelectPointed,sp,sel);
2787 if (sp.IsNull() || list.IsNull()) return Standard_False;
2788 if (mode == 0) sp->Clear();
2789 if (mode >= 0) sp->AddList(list);
2790 else sp->RemoveList(list);
2791 return Standard_True;
2795 // ###########################################################################
2796 // .... Analyse d un CheckIterator par rapport a un graphe ....
2798 //=======================================================================
2801 //=======================================================================
2803 static void IFSelect_QueryProp (Interface_IntList& list,
2804 TCollection_AsciiString& ana,
2805 const Standard_Integer num, const int quoi)
2807 list.SetNumber(num);
2808 Standard_Integer i, nb = list.Length();
2809 for (i = 1; i <= nb; i ++) {
2810 if (i > 1) list.SetNumber(num); // because recursive call + depth first
2811 Standard_Integer n = list.Value(i);
2812 // y a t il lieu de propager ?
2813 // 1 W/place 2 F/place 3 Wprop 4Wprop+W/place 5Wprop+F/place
2814 // 6 Fprop 7 Fprop+W/place 8 Fprop+F/place
2815 char val = ana.Value(n);
2817 case ' ' : val = (quoi ? '3' : '6'); break;
2818 case '1' : val = (quoi ? '4' : '7'); break;
2819 case '2' : val = (quoi ? '5' : '8'); break;
2820 case '3' : val = (quoi ? ' ' : '6'); break;
2821 case '4' : val = (quoi ? ' ' : '7'); break;
2822 case '5' : val = (quoi ? ' ' : '8'); break;
2823 case '6' : val = ' '; break;
2824 case '7' : val = ' '; break;
2825 case '8' : val = ' '; break;
2826 default : val = ' '; break;
2828 if (val == ' ') continue;
2829 ana.SetValue(n,val);
2830 IFSelect_QueryProp (list,ana,n,quoi);
2835 //=======================================================================
2838 //=======================================================================
2840 void IFSelect_WorkSession::QueryCheckList (const Interface_CheckIterator& chl)
2842 if (!IsLoaded()) return;
2843 Standard_Integer i,nb = themodel->NbEntities();
2844 thecheckana = TCollection_AsciiString (nb+1,' ');
2845 for (chl.Start(); chl.More(); chl.Next()) {
2846 Standard_Integer num = chl.Number();
2847 const Handle(Interface_Check) ach = chl.Value();
2848 if (ach->HasFailed()) thecheckana.SetValue(num,'2');
2849 else if (ach->HasWarnings()) thecheckana.SetValue(num,'1');
2851 // analyse selon le graphe ... codes : blc = rien
2852 // 1 W/place 2 F/place 3 Wprop 4Wprop+W/place 5Wprop+F/place
2853 // 6 Fprop 7 Fprop+W/place 8 Fprop+F/place
2854 Interface_IntList list;// = thegraph->Graph().SharingNums(0);
2855 // deux passes : d abord Warning, puis Fail
2856 for (i = 1; i <= nb; i ++) {
2857 char val = thecheckana.Value(i);
2859 if (val == '1' || val == '4' || val == '7') quoi = 0;
2860 if (quoi >= 0) IFSelect_QueryProp (list,thecheckana,i,quoi);
2862 for (i = 1; i <= nb; i ++) {
2863 char val = thecheckana.Value(i);
2865 if (val == '2' || val == '5' || val == '8') quoi = 1;
2866 if (quoi >= 0) IFSelect_QueryProp (list,thecheckana,i,quoi);
2871 //=======================================================================
2874 //=======================================================================
2876 Standard_Integer IFSelect_WorkSession::QueryCheckStatus
2877 (const Handle(Standard_Transient)& ent) const
2879 if (!IsLoaded()) return -1;
2880 Standard_Integer num = themodel->Number(ent);
2881 if (num == 0) return -1;
2882 if (thecheckana.Length() < num) return -1;
2883 Standard_Character val = thecheckana.Value (num);
2884 // codes : blc = rien -> 0
2885 // 1 W/place -> 1 2 F/place -> 2
2886 // 3 Wprop -> 10 4 Wprop+W/place -> 11 5 Wprop+F/place -> 12
2887 // 6 Fprop -> 20 7 Fprop+W/place -> 21 8 Fprop+F/place -> 22
2888 if (val == ' ') return 0;
2889 if (val == '1') return 1;
2890 if (val == '2') return 2;
2891 if (val == '3') return 10;
2892 if (val == '4') return 11;
2893 if (val == '5') return 12;
2894 if (val == '6') return 20;
2895 if (val == '7') return 21;
2896 if (val == '8') return 22;
2901 //=======================================================================
2904 //=======================================================================
2906 Standard_Integer IFSelect_WorkSession::QueryParent
2907 (const Handle(Standard_Transient)& entdad,
2908 const Handle(Standard_Transient)& entson) const
2910 Standard_Integer ndad = StartingNumber(entdad);
2911 Standard_Integer nson = StartingNumber(entson);
2912 if (ndad < 1 || nson < 1) return -1;
2913 if (ndad == nson) return 0;
2914 // on va calculer : pour chaque pere immediat, de <son>, status avec <dad> + 1
2915 // nb : pas protege contre les boucles ...
2916 Handle(TColStd_HSequenceOfTransient) list =
2917 thegraph->Graph().Sharings(entson).Content();
2918 if (list.IsNull()) return -1;
2919 Standard_Integer i, nb = list->Length();
2920 for (i = 1; i <= nb; i ++) {
2921 if (list->Value(i) == entdad) return 1;
2922 Standard_Integer stat = QueryParent ( entdad,list->Value(i) );
2923 if (stat >= 0) return stat+1;
2925 return -1; // not yet implemented ...
2928 // ###########################################################################
2929 // .... Dumps et Evaluations, pas faciles a passer en arguments ....
2931 // #### #### #### #### #### #### #### #### ####
2932 // .... DumpShare ....
2934 //=======================================================================
2937 //=======================================================================
2939 void IFSelect_WorkSession::SetParams
2940 (const TColStd_SequenceOfTransient& params,
2941 const TColStd_SequenceOfInteger& uselist)
2943 Standard_Integer i, nbp = params.Length(), nbu = uselist.Length();
2944 Handle(IFSelect_ParamEditor) editor = new IFSelect_ParamEditor
2945 (nbp+nbu+50,"Parameter Editor");
2946 for (i = 1; i <= nbp; i ++) {
2947 DeclareAndCast(Interface_TypedValue,val,params.Value(i));
2948 if (val.IsNull()) continue;
2949 editor->AddValue(val);
2951 AddNamedItem("xst-params-edit",editor);
2953 Handle(IFSelect_EditForm) paramsall = editor->Form(Standard_False);
2954 AddNamedItem("xst-params-all",paramsall);
2956 // On attaque les EditForms partielles
2957 TColStd_SequenceOfInteger listgen,listload,listsend,listsplit,listread,listwrite;
2958 for (i = 1; i <= nbu; i ++) {
2959 Standard_Integer use = uselist.Value(i);
2961 case 1 : listgen.Append(i); break;
2962 case 2 : listread.Append(i); break;
2963 case 3 : listsend.Append(i); break;
2964 case 4 : listsplit.Append(i); break;
2965 case 5 : listread.Append(i); break;
2966 case 6 : listwrite.Append(i); break;
2970 Handle(IFSelect_EditForm) paramsgen = new IFSelect_EditForm
2971 (editor,listgen ,Standard_False,Standard_True,"General Parameters");
2972 if (listgen.Length() > 0) AddNamedItem("xst-params-general",paramsgen);
2973 Handle(IFSelect_EditForm) paramsload = new IFSelect_EditForm
2974 (editor,listload,Standard_False,Standard_True,"Loading Parameters");
2975 if (listload.Length() > 0) AddNamedItem("xst-params-load", paramsload);
2976 Handle(IFSelect_EditForm) paramssend = new IFSelect_EditForm
2977 (editor,listsend,Standard_False,Standard_True,"Sending Parameters");
2978 if (listsend.Length() > 0) AddNamedItem("xst-params-send", paramssend);
2979 Handle(IFSelect_EditForm) paramsplit = new IFSelect_EditForm
2980 (editor,listsplit,Standard_False,Standard_True,"Split Parameters");
2981 if (listsplit.Length() > 0) AddNamedItem("xst-params-split", paramsplit);
2982 Handle(IFSelect_EditForm) paramsread = new IFSelect_EditForm
2983 (editor,listread,Standard_False,Standard_True,"Read(Transfer) Parameters");
2984 if (listread.Length() > 0) AddNamedItem("xst-params-read", paramsread);
2985 Handle(IFSelect_EditForm) paramswrite = new IFSelect_EditForm
2986 (editor,listwrite,Standard_False,Standard_True,"Write(Transfer) Parameters");
2987 if (listwrite.Length() > 0) AddNamedItem("xst-params-write", paramswrite);
2991 //=======================================================================
2994 //=======================================================================
2996 void IFSelect_WorkSession::TraceStatics
2997 (const Standard_Integer use, const Standard_Integer mode) const
2999 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3001 if (mode == 0) sout<<"******************************************"<<endl;
3003 if (mode == 0) sout<<"***** General Parameters *****"<<endl;
3004 } else if (use == 2) {
3005 if (mode == 0) sout<<"***** Load File *****"<<endl;
3006 } else if (use == 3) {
3007 if (mode == 0) sout<<"***** Write File *****"<<endl;
3008 } else if (use == 4) {
3009 if (mode == 0) sout<<"***** Split File *****"<<endl;
3010 } else if (use == 5) {
3011 if (mode == 0) sout<<"***** Transfer (Read) *****"<<endl;
3012 } else if (use == 6) {
3013 if (mode == 0) sout<<"***** Transfer (Write) *****"<<endl;
3015 if (mode == 0) sout<<"******************************************"<<endl<<endl;
3018 // Echainements particuliers (use > 0)
3020 TraceStatics (-2,mode);
3021 if (mode == 0) sout<<endl;
3022 } else if (use == 4 || use == 6) {
3023 TraceStatics (-3,mode);
3024 if (mode == 0) sout<<endl;
3027 // Valeurs particulieres
3028 if (use == 1 || use == -1) { // General : trace
3030 // sout << "Trace Level : "<<Message_PrinterOStream::Default()->GetTraceLevel()<<endl;
3032 } else if (use == 4 || use == -4) { // Split : Prefix & cie
3034 Handle(TCollection_HAsciiString) str = theshareout->Prefix();
3035 if (!str.IsNull()) sout << "Prefix : "<<str->ToCString()<<endl;
3036 else sout << "Prefix not Defined" << endl;
3037 str = theshareout->DefaultRootName();
3038 if (!str.IsNull()) sout << "Default Root : "<<str->ToCString()<<endl;
3039 else sout << "Default Root not Defined" << endl;
3040 str = theshareout->Extension();
3041 if (!str.IsNull()) sout << "Extension : "<<str->ToCString()<<endl;
3042 else sout << "Extension not defined" << endl;
3046 // LISTER LES STATICS
3047 // Passer par les ParamEditor ...
3051 if (mode == 0) sout<<"******************************************"<<endl<<endl;
3056 //=======================================================================
3059 //=======================================================================
3061 void IFSelect_WorkSession::DumpShare () const
3063 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3064 sout<<" ********** Definition ShareOut (Complete) **********"<<endl;
3066 Handle(TCollection_HAsciiString) str = theshareout->Prefix();
3067 if (!str.IsNull()) sout << "Prefix : " << str->ToCString() << endl;
3068 else sout << "Prefix not Defined" << endl;
3069 str = theshareout->DefaultRootName();
3070 if (!str.IsNull()) sout << "Default Root : " << str->ToCString() << endl;
3071 else sout << "Default Root not Defined" << endl;
3072 str = theshareout->Extension();
3073 if (!str.IsNull()) sout << "Extension : " << str->ToCString() << endl;
3074 else sout << "Extension not defined" << endl;
3076 Standard_Integer lr = theshareout->LastRun();
3077 Standard_Integer nb = theshareout->NbDispatches();
3078 sout << "Nb Dispatches : " << nb <<" (Last Run : " << lr << ") : "<<endl;
3079 for (Standard_Integer i = 1; i <= nb; i ++) {
3080 Handle(IFSelect_Dispatch) disp = theshareout->Dispatch(i);
3081 sout << "Dispatch n0 " << i;
3082 if (HasName(disp)) sout << " Name:"<< Name(disp)->ToCString();
3083 sout << " Label:" << disp->Label() << endl;
3084 Handle(IFSelect_Selection) sel = disp->FinalSelection();
3085 if (sel.IsNull()) sout << " No Final Selection Defined" << endl;
3086 else if (HasName(sel)) sout << " Final Selection : Name:"
3087 << Name(sel)->ToCString() << " Label:" << sel->Label() << endl;
3088 else sout << " Final Selection : " << sel->Label() << endl;
3089 if (disp->HasRootName())
3090 sout<<" File Root Name : "<<disp->RootName()->ToCString()<<endl;
3091 else sout<<" No specific file root name (see Default Root)"<<endl;
3093 Standard_Integer nbm = theshareout->NbModifiers(Standard_True);
3095 " *** "<<nbm<<" active Model Modifiers : see ListModifiers ***"<<endl;
3096 Standard_Integer nbf = theshareout->NbModifiers(Standard_False);
3098 " *** "<<nbf<<" active File Modifiers : see ListModifiers ***"<<endl;
3099 if (nbm+nbf == 0) sout<<" *** No active Modifiers ***"<<endl;
3102 // #### #### #### #### #### #### #### #### ####
3103 // .... ListItems ....
3105 //=======================================================================
3108 //=======================================================================
3110 void IFSelect_WorkSession::ListItems (const Standard_CString lab) const
3112 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3113 sout<< " ********** Items in Session **********"<<endl;
3114 Standard_Integer nb = MaxIdent();
3115 Handle(TCollection_HAsciiString) str;
3116 if (lab[0] != '\0') str = new TCollection_HAsciiString (lab);
3117 for (Standard_Integer i = 1; i <= nb; i ++) {
3118 const Handle(Standard_Transient)& var = theitems.FindKey(i);
3119 Handle(TCollection_HAsciiString) label = ItemLabel(i);
3120 if (label.IsNull()) continue; // -> item supprime
3121 if (!str.IsNull()) { if (label->Location(str,1,label->Length()) == 0) continue; }
3123 if (HasName(var)) sout<<" - Named : "<<Name(var)->ToCString()<<" - ";
3124 else sout<<" - (no name) - ";
3125 sout<<var->DynamicType()->Name()<<endl<<" "<<label->ToCString()<<endl;
3129 // #### #### #### #### #### #### #### #### ####
3130 // .... ListModifiers
3132 //=======================================================================
3135 //=======================================================================
3137 void IFSelect_WorkSession::ListFinalModifiers
3138 (const Standard_Boolean formodel) const
3140 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3141 Standard_Integer nb = theshareout->NbModifiers(formodel);
3142 sout<< " ********** Modifiers in Session ";
3143 sout<<(formodel ? "(For Model)" : "(For File)");
3144 sout<<": "<<nb<<" **********"<<endl;
3145 for (Standard_Integer i = 1; i <= nb; i ++) {
3146 Handle(IFSelect_GeneralModifier) modif =
3147 theshareout->GeneralModifier(formodel,i);
3148 if (!modif.IsNull()) sout<<"Modifier n0."<<i<<" : "<<modif->Label();
3149 if (HasName(modif)) sout << " Named as : " << Name(modif)->ToCString();
3154 // #### #### #### #### #### #### #### #### ####
3155 // .... DumpSelection ....
3157 //=======================================================================
3160 //=======================================================================
3162 void IFSelect_WorkSession::DumpSelection
3163 (const Handle(IFSelect_Selection)& sel) const
3165 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3166 if (ItemIdent(sel) == 0) {
3167 sout << "Selection : Unknown"<<endl; //sout<<Handle
3170 sout << " ********** Selection";
3171 if (HasName(sel)) sout << " , Name : " << Name(sel)->ToCString();
3172 sout <<" **********"<<endl;
3173 sout<< "Label : " << sel->Label() << " . Input(s) : "<< endl;
3174 Standard_Integer nb = 0;
3175 IFSelect_SelectionIterator iter; sel->FillIterator(iter);
3176 for (; iter.More(); iter.Next()) {
3178 Handle(IFSelect_Selection) newsel = iter.Value();
3179 sout<<" -- "<<newsel->Label()<<endl;
3181 sout << " Nb Inputs:"<<nb<<endl;
3185 // ##########################################
3186 // ######### Fonctions complementaires
3187 // ##########################################
3189 // #### #### #### #### #### #### #### #### ####
3190 // .... DumpModel ....
3192 //=======================================================================
3195 //=======================================================================
3197 Handle(IFSelect_Selection) IFSelect_WorkSession::GiveSelection
3198 (const Standard_CString selname) const
3201 Standard_Integer np = -1, nf = -1, nivp = 0;
3202 for (Standard_Integer n = 0; selname[n] != '\0'; n ++) {
3203 nomsel[n] = selname[n]; nomsel[n+1] = '\0';
3204 if (selname[n] == '(') { np = n; nivp ++; }
3205 if (selname[n] == ')') { nivp --; if (nivp <= 0) nf = n; }
3206 //// if (selname[n] == ' ') { nb = n; break; }
3209 Handle(IFSelect_Selection) sel;
3210 if (np >= 0) nomsel[np] = 0; if (nf >= 0) nomsel[nf] = '\0';
3211 Handle(Standard_Transient) item = NamedItem(nomsel);
3213 // Parentheses ? essayer Signature (plus tard : Selection parametree)
3214 // NB : on compte les niveaux de parentheses (imbrications repercutees)
3215 if (np > 0 && nf > 0) {
3216 Handle(IFSelect_SelectSignature) selsign;
3217 Standard_Integer debsign = np+1;
3219 DeclareAndCast(IFSelect_Signature,sign,item);
3220 DeclareAndCast(IFSelect_SignCounter,cnt,item);
3221 if (!sign.IsNull()) selsign =
3222 new IFSelect_SelectSignature (sign,&nomsel[debsign],Standard_False);
3223 else if (!cnt.IsNull()) selsign =
3224 new IFSelect_SelectSignature (cnt,&nomsel[debsign],Standard_False);
3226 cout<<selname<<" : neither Signature nor Counter"<<endl;
3230 selsign->SetInput (new IFSelect_SelectModelEntities); // par defaut
3234 else sel = GetCasted(IFSelect_Selection,item);
3240 //=======================================================================
3243 //=======================================================================
3245 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveList
3246 (const Handle(Standard_Transient)& obj) const
3249 DeclareAndCast(TColStd_HSequenceOfTransient,list,obj);
3250 if (!list.IsNull()) return list;
3252 // Rien du tout : retourne rien du tout
3253 if (obj.IsNull()) return list;
3255 // Une selection : son resultat (standard)
3256 DeclareAndCast(IFSelect_Selection,sel,obj);
3257 if (!sel.IsNull()) {
3258 Interface_EntityIterator iter = EvalSelection(sel);
3259 return iter.Content();
3262 // Le modele : son contenu
3263 list = new TColStd_HSequenceOfTransient();
3264 if (obj == themodel) {
3265 Standard_Integer i, nb = themodel->NbEntities();
3266 for (i = 1; i <= nb; i ++) list->Append (themodel->Value(i));
3269 // Une entite du modele : cette entite
3270 else if (StartingNumber(obj) > 0) list->Append (obj);
3272 // Un Texte : son interpretation
3274 DeclareAndCast(TCollection_HAsciiString,str,obj);
3275 if (!str.IsNull()) return GiveList (str->ToCString());
3278 // Si c est pas tout ca : une liste vide
3283 //=======================================================================
3286 //=======================================================================
3288 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveList
3289 (const Standard_CString first, const Standard_CString second) const
3291 Handle(TColStd_HSequenceOfTransient) list;
3292 if (!first || first[0] == '\0') return list;
3293 if (first[0] == ' ') return GiveList (&first[1],second);
3294 if (second && second[0] == ' ') return GiveList (first,&second[1]);
3296 // list NULLE sera interpretee comme SelectionResult (selection toute crue)
3297 // sinon comme SelectionResultFromList
3298 if (second && second[0] != '\0') list = GiveList (second,"");
3300 list = GiveListFromList (first,list);
3305 //=======================================================================
3308 //=======================================================================
3310 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveListFromList
3311 (const Standard_CString selname, const Handle(Standard_Transient)& ent) const
3313 Handle(TColStd_HSequenceOfTransient) list;
3314 Standard_Integer num;
3316 // LISTE DEFINIE D OFFICE (en ce cas, la liste d entree est ignoree)
3317 if (selname[0] == '(') {
3318 // liste d entites donnees a la queue leu leu : (ID,ID,ID...)
3319 char entid[50]; Standard_Integer i,j = 0;
3320 TColStd_MapOfInteger numap;
3321 list = new TColStd_HSequenceOfTransient();
3322 for (i = 1; selname[i] != '\0'; i ++) {
3323 if (selname[i] == ' ') continue;
3324 if (selname[i] == ',' || selname[i] == ')') {
3326 if (j == 0) continue; j = 0;
3327 num = NumberFromLabel (entid);
3328 if (num <= 0 || !numap.Add (num)) continue;
3329 Handle(Standard_Transient) anent = StartingEntity(num);
3330 if (!anent.IsNull()) list->Append (anent);
3331 if (selname[i] == ')') break;
3334 entid[j] = selname[i]; j ++;
3338 num = NumberFromLabel (selname);
3339 if (num > 0) return GiveList(StartingEntity(num));
3341 // Autres cas : y atil une liste d entree.
3342 // Si OUI -> SelectionResultFromList. Si NON -> SelectionResult
3343 // Si une entite isolee -> on en fait une liste
3345 list = GiveList(ent); // ent NULL -> list NULL sinon intreprete
3347 // Decomposition term1 term2 ...
3349 char nomsel[500]; nomsel[0] = '\0';
3350 Standard_Integer n= 0 , nb = -1;
3351 for (n = 0; selname[n] != '\0'; n ++) {
3352 nomsel[n] = selname[n]; nomsel[n+1] = '\0';
3353 // if (selname[n] == '(') { np = n; nivp ++; }
3354 // if (selname[n] == ')') { nivp --; if (nivp <= 0) nf = n; }
3355 if (selname[n] == ' ') { nb = n; nomsel[n] = '\0'; break; }
3357 if (nomsel[0] == '\0') return list;
3359 Handle(IFSelect_Selection) sel = GiveSelection (nomsel);
3361 cout<<"Neither Entity Number/Label nor Selection :"<<nomsel<<endl;
3365 if (nb > 0) list = GiveListFromList (&selname[nb+1],list);
3367 if (list.IsNull()) list = SelectionResult (sel);
3368 else list = SelectionResultFromList (sel,list);
3374 //=======================================================================
3377 //=======================================================================
3379 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveListCombined
3380 (const Handle(TColStd_HSequenceOfTransient)& l1,
3381 const Handle(TColStd_HSequenceOfTransient)& l2,
3382 const Standard_Integer mode) const
3384 Handle(TColStd_HSequenceOfTransient) list;
3385 if (l1.IsNull() || l2.IsNull()) return list;
3387 // mode < 0 l1-l2 = 0 l1&l2 > 0 l1|l2 (l1+l2)
3388 TColStd_MapOfTransient numap;
3389 Standard_Integer i,n = l2->Length();
3390 for (i = n; i > 0; i --) {
3391 Handle(Standard_Transient) ent = l2->Value(i);
3392 if (ent.IsNull()) continue;
3394 if (mode > 0) list->Append(ent);
3397 // ents de l1 pas deja dans l2
3399 for (i = n; i > 0; i --) {
3400 Handle(Standard_Transient) ent = l1->Value(i);
3401 if (ent.IsNull()) continue;
3403 if (numap.Contains(ent)) {
3404 // dans l1 et dans l2
3405 if (mode == 0) list->Append(ent);
3407 // dans l1 mais pas dans l2
3408 if (mode != 0) list->Append(ent);
3417 //=======================================================================
3420 //=======================================================================
3422 void IFSelect_WorkSession::DumpModel
3423 (const Standard_Integer level, const Handle(Message_Messenger)& S)
3426 { S<< " *** Data for List not available ***"<<endl; return; }
3427 S << "\n *****************************************************************\n";
3428 if (theloaded.Length() > 0)
3429 S << " ******** Loaded File : "<<theloaded.ToCString()<<Interface_MSG::Blanks(32-theloaded.Length())<<" ********"<<endl;
3430 else S << " ******** No name for Loaded File"<<endl;
3432 S<<" ******** Short Dump of Header ********\n";
3433 S << " *****************************************************************\n\n";
3434 themodel->DumpHeader(S); S<<endl;
3437 Standard_Integer nbent = themodel->NbEntities();
3438 Standard_Integer nbr = 0;
3439 Interface_ShareFlags shar(thegraph->Graph());
3441 for (Standard_Integer i = 1; i <= nbent; i ++) {
3442 if (!shar.IsShared(themodel->Value(i))) nbr ++;
3444 S << " *****************************************************************\n";
3445 S << " ******** Model : "<<nbent<<" Entities, of which "<<nbr<<" Root(s)\n";
3446 S << " *****************************************************************\n"<<endl;
3448 if (level <= 0) return;
3449 else if (level == 1) {
3450 S<<" ******** Root Entities ******** ";
3451 ListEntities (shar.RootEntities(),1);
3452 } else if (level == 2) {
3453 S<<" ******** Complete List ******** ";
3454 ListEntities (themodel->Entities(),1);
3455 } else if (level > 2) {
3456 IFSelect_PrintCount mode = IFSelect_ItemsByEntity;
3457 if (level == 5 || level == 8) mode = IFSelect_CountByItem;
3458 if (level == 6 || level == 9) mode = IFSelect_ListByItem;
3459 if (level == 7 || level == 10) mode = IFSelect_EntitiesByItem;
3460 PrintCheckList (ModelCheckList(),Standard_False, mode);
3462 if (level == 3) S << " ******** Check Model (Fails) ********"<<endl;
3463 else S << " ******** Check Model (Complete) ********"<<endl;
3464 Interface_CheckTool CT (Graph());
3465 Interface_CheckIterator C;
3469 if (level == 3) C = CT.CheckList();
3470 else C = CT.CompleteCheckList();
3472 catch (Standard_Failure) {
3473 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3474 sout<<" **** Interruption DumpModel (Check) par Exception ****\n";
3475 S<<" ** ** Exception Raised during Check ! ** **\n";
3476 S<<" --> what could be determined is listed"<<endl;
3479 else if (level == 3) C = CT.CheckList();
3480 else C = CT.CompleteCheckList();
3482 // Check List : si vide (pas demandee), naturellement passee
3485 C.Print(S,themodel, (level == 3));
3487 catch (Standard_Failure) {
3488 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3489 sout<<" **** Interruption DumpModel par Exception : ****\n";
3490 sout<<Standard_Failure::Caught()->GetMessageString();
3491 sout<<"\n Abandon"<<endl;
3495 S<<endl<<"There are "<<nbent<<" Entities, of which "<<nbr<<" Root(s)"<<endl;
3498 // .... TraceDumpModel .... (Model + CheckList)
3500 //=======================================================================
3503 //=======================================================================
3505 void IFSelect_WorkSession::TraceDumpModel
3506 (const Standard_Integer mode)
3508 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3509 DumpModel (mode,sout);
3510 // if (mode <= 4) { DumpModel (mode,sout); return; }
3512 // else if (mode <= 7) PrintCheckList (ModelCheckList(),Standard_False, mode-5);
3513 // else if (mode <=10) PrintCheckList (ModelCheckList(),Standard_True , mode-8);
3516 // .... DumpEntity ....
3518 //=======================================================================
3521 //=======================================================================
3523 void IFSelect_WorkSession::DumpEntity
3524 (const Handle(Standard_Transient)& ent, const Standard_Integer level,
3525 const Handle(Message_Messenger)& S) const
3528 { S<< " *** Data for List not available ***"<<endl; return; }
3529 Standard_Integer num = themodel->Number(ent);
3530 if (num == 0) { S<<" *** Entity to Dump not in the Model ***"<<endl; return; }
3531 if (thelibrary.IsNull()) { S<<" *** WorkLibrary not defined ***"<<endl; return; }
3532 S << " ******** Dumping Entity n0 "<<num
3533 <<" level:"<<level<<" ********"<<endl;
3534 thelibrary->DumpEntity (themodel,theprotocol,ent,S,level);
3537 // .... DumpEntity ....
3539 //=======================================================================
3542 //=======================================================================
3544 void IFSelect_WorkSession::TraceDumpEntity
3545 (const Handle(Standard_Transient)& ent, const Standard_Integer level) const
3547 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3548 DumpEntity (ent,level,sout);
3551 // .... PrintEntityStatus ....
3553 //=======================================================================
3556 //=======================================================================
3558 void IFSelect_WorkSession::PrintEntityStatus
3559 (const Handle(Standard_Transient)& ent, const Handle(Message_Messenger)& S)
3561 Standard_Integer i,nb;
3562 Standard_Integer num = StartingNumber(ent);
3563 if (num == 0) { cout<<" -- PrintEntityStatus : unknown"<<endl; return; }
3565 S <<" Ent. n0/id: ";
3566 Model()->Print(ent,S);
3567 Handle(TCollection_HAsciiString) hname = EntityName(ent);
3568 if (!hname.IsNull() && hname->Length() > 0) S<<" Name:"<<hname->ToCString();
3570 Handle(IFSelect_Signature) signtype = SignType();
3571 if (signtype.IsNull()) S<<" Type(CDL):"<<ent->DynamicType()->Name()<<endl;
3572 else S <<" Type:"<<signtype->Value (ent,Model())<<endl;
3573 S <<" Category : " <<CategoryName (ent)
3574 <<" Validity : " <<ValidityName (ent) << endl;
3575 Interface_CheckIterator chl = CheckOne (ent);
3576 chl.Print (S,Model(),Standard_False,Standard_False);
3578 Handle(TColStd_HSequenceOfTransient) list = Sharings(ent);
3579 if (list.IsNull()) S<<" Root"<<endl;
3581 nb = list->Length();
3582 if (nb == 0) S<<" Root";
3583 else S<<" Super-entities:"<<nb<<" : (n0/id):";
3584 for (i = 1; i <= nb; i ++) { S<<" "; Model()->Print(list->Value(i),S); }
3587 list = Shareds (ent);
3588 if (list.IsNull()) S<<" No sub-entity"<<endl;
3590 nb = list->Length();
3591 if (nb == 0) S<<" No sub-entity";
3592 else S<<" Sub-entities:"<<nb<<" , i.e. (n0/id):";
3593 for (i = 1; i <= nb; i ++) { S<<" "; Model()->Print(list->Value(i),S); }
3598 // .... PrintCheckList ....
3600 //=======================================================================
3603 //=======================================================================
3605 void IFSelect_WorkSession::PrintCheckList
3606 (const Interface_CheckIterator& checklist,
3607 const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const
3609 // mode : 0 comptage 1 n0s entites 2 n0s+id ents
3610 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3611 if (mode == IFSelect_ItemsByEntity) checklist.Print (sout,themodel,failsonly);
3613 Interface_CheckIterator chks = checklist;
3614 Handle(IFSelect_CheckCounter) counter =
3615 new IFSelect_CheckCounter (mode>1 && mode != IFSelect_CountSummary);
3616 counter->Analyse (chks,themodel,Standard_True,failsonly);
3617 counter->PrintList (sout,themodel,mode);
3621 // .... PrintSignatureList ....
3623 //=======================================================================
3626 //=======================================================================
3628 void IFSelect_WorkSession::PrintSignatureList
3629 (const Handle(IFSelect_SignatureList)& signlist,
3630 const IFSelect_PrintCount mode) const
3632 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3633 if (signlist.IsNull()) return;
3634 signlist->PrintList (sout,themodel,mode);
3637 // #### #### #### #### #### #### #### #### ####
3638 // .... EvaluateSelection ....
3640 //=======================================================================
3643 //=======================================================================
3645 void IFSelect_WorkSession::EvaluateSelection
3646 (const Handle(IFSelect_Selection)& sel) const
3648 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3650 errhand = Standard_False;
3653 EvaluateSelection(sel); // appel normal (->code unique)
3655 catch (Standard_Failure) {
3656 sout<<" **** Interruption EvaluateSelection par Exception **** Intitule\n";
3657 sout<<Standard_Failure::Caught()->GetMessageString();
3658 sout<<"\n Abandon"<<endl;
3660 errhand = theerrhand;
3665 { sout<< " *** Data for Evaluation not available ***"<<endl; return; }
3666 if (ItemIdent(sel) == 0)
3667 { sout << " Selection : Unknown"<<endl; return; } //sout<<Handle
3668 Interface_EntityIterator iter = EvalSelection (sel);
3669 ListEntities (iter,1);
3670 sout << "**** (Unique) RootResult, Selection : "
3671 <<sel->Label()<<endl;
3675 // #### #### #### #### #### #### #### #### ####
3676 // .... EvaluateDispatch ....
3678 //=======================================================================
3681 //=======================================================================
3683 void IFSelect_WorkSession::EvaluateDispatch
3684 (const Handle(IFSelect_Dispatch)& disp, const Standard_Integer mode) const
3686 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3688 errhand = Standard_False;
3691 EvaluateDispatch(disp,mode); // appel normal (->code unique)
3693 catch (Standard_Failure) {
3694 sout<<" **** Interruption EvaluateDispatch par Exception **** Intitule\n";
3695 sout<<Standard_Failure::Caught()->GetMessageString();
3696 sout<<"\n Abandon"<<endl;
3698 errhand = theerrhand;
3702 Standard_Integer numdisp = DispatchRank(disp);
3704 { sout<< " *** Data for List not available ***"<<endl; return; }
3705 if (theshareout->NbDispatches() < numdisp || numdisp <= 0)
3706 { sout<<"Dispatch : Unknown"<<endl; return; } //sout<<Handle
3707 if (disp->FinalSelection().IsNull())
3708 { sout<<"Dispatch : No Final Selection"<<endl; return; }//sout<<Handle
3709 sout<<" --- Dispatch Label : "<<disp->Label()<<endl;
3711 IFSelect_ShareOutResult eval(disp,thegraph->Graph());
3713 Standard_Integer numpack = 0;
3714 Handle(IFSelect_PacketList) evres =
3715 eval.Packets (mode ? Standard_True : Standard_False);
3716 Standard_Integer nbpack = evres->NbPackets();
3718 sout<<"Nb Packets produced : "<<nbpack<<" :"<<endl;
3719 for (numpack = 1; numpack <= nbpack; numpack ++) {
3720 sout<<"\n **** Packet n0 : "<<numpack<<" ****"<<endl;
3721 if (!mode) cout<<"Root Entities :"<<endl;
3722 ListEntities (evres->Entities(numpack), (mode ? 2 : -1));
3725 //// Interface_EntityIterator iterem = disp->Remainder(thegraph->Graph());
3726 if (mode == 0) return;
3727 if (mode == 1 || mode == 3) {
3729 if (evres->NbDuplicated(0,Standard_False) == 0)
3730 sout<<" **** All the Model is taken into account ****"<<endl;
3732 sout<<" **** Starting Entities not taken by this Dispatch ****"<<endl;
3733 ListEntities (evres->Duplicated(0,Standard_False),2);
3737 sout<<" **** Entites in more than one packet ****";
3738 Standard_Integer max = evres->HighestDuplicationCount();
3739 if (max < 2) sout<<" : There are none"<<endl;
3741 Standard_Integer newcount;
3743 for (newcount = 2; newcount <= max; newcount ++) {
3744 if (evres->NbDuplicated(newcount,Standard_False) == 0) continue;
3745 sout<<" **** Entities put in "<<newcount<<" packets ****"<<endl;
3746 ListEntities (evres->Duplicated(newcount,Standard_False),2);
3753 // #### #### #### #### #### #### #### #### ####
3754 // .... EvaluateComplete ....
3756 //=======================================================================
3759 //=======================================================================
3761 void IFSelect_WorkSession::EvaluateComplete
3762 (const Standard_Integer mode) const
3764 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3766 errhand = Standard_False;
3769 EvaluateComplete(mode); // appel normal (donc, code pas duplique)
3771 catch (Standard_Failure) {
3772 sout<<" **** Interruption EvaluateComplete par Exception : ****\n";
3773 sout<<Standard_Failure::Caught()->GetMessageString();
3774 sout<<"\n Abandon"<<endl;
3776 errhand = theerrhand;
3781 { sout<< " *** Data for List not available ***"<<endl; return; }
3782 IFSelect_ShareOutResult eval(theshareout,thegraph->Graph());
3784 sout<<"\n******** Evaluation ShareOutResult (Complete) ********\n";
3785 sout<<" **** List of Packets **** Count : "<<eval.NbPackets()<<endl;
3786 if (mode == 0) sout << " ** (for each one : Root Entities) **"<<endl;
3787 else sout << " ** (for each one : Evaluated Content) **"<<endl;
3789 Standard_Integer numpack = 0;
3790 Handle(IFSelect_PacketList) evres =
3791 eval.Packets (mode ? Standard_True : Standard_False);
3792 Standard_Integer nbpack = evres->NbPackets();
3794 sout<<"Nb Packets produced : "<<nbpack<<" :"<<endl;
3795 for (numpack = 1; numpack <= nbpack; numpack ++) {
3796 sout<<"\n **** Packet n0 : "<<numpack<<" ****"<<endl;
3797 if (!mode) cout<<"Root Entities :"<<endl;
3798 ListEntities (evres->Entities(numpack), (mode ? 2: -1));
3800 if (mode == 0) return;
3801 if (mode == 1 || mode == 3) {
3803 if (evres->NbDuplicated(0,Standard_False) == 0)
3804 sout<<" **** All the Model is taken into account ****"<<endl;
3806 sout<<" **** Starting Entities Forgotten ****"<<endl;
3807 ListEntities (evres->Duplicated(0,Standard_False),2);
3811 sout<<" **** Entites in more than one packet ****"<<endl;
3812 Standard_Integer max = evres->HighestDuplicationCount();
3813 if (max < 2) sout<<" : There are none"<<endl;
3815 Standard_Integer newcount;
3817 for (newcount = 2; newcount <= max; newcount ++) {
3818 if (evres->NbDuplicated(newcount,Standard_False) == 0) continue;
3819 sout<<" **** Entities put in "<<newcount<<" packets ****"<<endl;
3820 ListEntities (evres->Duplicated(newcount,Standard_False),2);
3827 // #### #### #### #### #### #### #### #### ####
3828 // .... Routine Interne : ListEntities
3830 //=======================================================================
3833 //=======================================================================
3835 void IFSelect_WorkSession::ListEntities
3836 (const Interface_EntityIterator& iter, const Standard_Integer mmode) const
3838 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3840 Standard_Integer mode = (mmode < 0 ? -mmode : mmode);
3841 if (mmode >= 0) sout << " List of " << iter.NbEntities() << " Entities :"<<endl;
3843 { sout<< " *** Data for List not available ***"<<endl; return; }
3844 Interface_ShareFlags tool(thegraph->Graph());
3848 int newcount = -1; int mods = 0; int cnt = 0;
3849 for (iter.Start(); iter.More(); iter.Next()) {
3850 if (!titre && mode == 1) sout
3851 << "Number/Id. Category Validity Type\n----------- ----...."<<endl;
3852 // 123456789 123456789 123456 123456789 123456789 123456
3853 if (!titre && mode == 0) sout<<" Keys : R Root ? Unknown * Unloaded"<<endl;
3854 if (!titre && mode == 2) sout<<"(";
3856 Handle(Standard_Transient) ent = iter.Value();
3857 Standard_Integer num = themodel->Number(ent);
3859 // n0 id (root?) category validity tracetype
3860 sout<<Interface_MSG::Blanks (num,6);
3861 themodel->Print(ent,sout,0);
3862 if (!tool.IsShared(ent)) sout << " #ROOT#";
3864 Standard_Integer catnum = themodel->CategoryNumber(num);
3865 if (catnum > 0) sout<<" "<<Interface_Category::Name (catnum);
3866 sout << " (" << ValidityName (ent) << ") ";
3868 sout<<" Type:"<<themodel->TypeName (ent, Standard_False);
3869 // Handle(Interface_GeneralModule) tracemod;
3870 // Standard_Integer CN;
3871 // if (thegtool->Select(ent,tracemod,CN))tracemod->TraceType(ent,CN,sout);
3872 // else sout << "(Not in Protocol) " << ent->DynamicType();
3874 } else if (mode == 2) {
3876 if (newcount > 0) sout<<",";
3879 newcount ++; mods = 0; cnt ++;
3880 if (newcount >= 10) { sout << endl<<"["<<cnt<<"]:"; newcount = 1; }
3881 if (newcount > 0) sout << " ";
3882 themodel->Print(ent,sout,0);
3883 if (!tool.IsShared(ent)) { if(mods == 0) sout<<"("; sout<<"R"; mods++; }
3884 if (themodel->IsUnknownEntity(num)) { sout<<(mods==0 ? '(' : ' ')<<"?"; mods ++; }
3885 if (themodel->IsRedefinedContent(num)) { sout<<(mods==0 ? '(' : ' ')<<"*"; mods ++; }
3886 if (mods) { sout<<")"; newcount ++; }
3889 if (mode == 0) sout<<endl;
3890 if (mode == 2) sout<<")"<<endl;
3892 catch (Standard_Failure) {
3893 sout<<" **** Interruption ListEntities par Exception : ****\n";
3894 sout<<Standard_Failure::Caught()->GetMessageString();
3895 sout<<"\n Abandon"<<endl;
3899 void IFSelect_WorkSession::SetModeStat( Standard_Boolean theStatMode)
3901 themodelstat = theStatMode;
3904 Standard_Boolean IFSelect_WorkSession::GetModeStat() const
3906 return themodelstat;