1 //#1 svv 10.01.00 : porting on DEC
2 //smh#14 17.03.2000 : FRA62479 Clearing of gtool
3 #include <Standard_ErrorHandler.hxx>
4 #include <IFSelect_WorkSession.ixx>
5 #include <IFSelect_DispPerOne.hxx>
6 #include <IFSelect_DispPerCount.hxx>
7 #include <IFSelect_DispGlobal.hxx>
8 #include <IFSelect_ShareOutResult.hxx>
9 #include <Interface_Graph.hxx>
10 #include <IFGraph_SubPartsIterator.hxx>
11 #include <IFSelect_PacketList.hxx>
12 #include <Interface_ReportEntity.hxx>
13 #include <Interface_Static.hxx>
15 #include <IFSelect_SignValidity.hxx>
16 #include <Interface_Category.hxx>
17 #include <Interface_Check.hxx>
18 #include <Interface_CheckTool.hxx>
19 #include <Interface_CheckIterator.hxx>
20 #include <Interface_ShareTool.hxx>
21 #include <Interface_ShareFlags.hxx>
22 #include <Interface_GeneralLib.hxx>
23 #include <Interface_GeneralModule.hxx>
24 #include <Dico_IteratorOfDictionaryOfTransient.hxx>
25 #include <Dico_IteratorOfDictionaryOfInteger.hxx>
26 #include <Interface_CopyTool.hxx>
27 #include <Interface_CopyControl.hxx>
29 #include <IFSelect_SelectDeduct.hxx>
30 #include <IFSelect_SelectExtract.hxx>
31 #include <IFSelect_SelectModelRoots.hxx>
32 #include <IFSelect_SelectModelEntities.hxx>
33 #include <IFSelect_SelectEntityNumber.hxx>
34 #include <IFSelect_SelectPointed.hxx>
35 #include <IFSelect_SelectControl.hxx>
36 #include <IFSelect_SelectDiff.hxx>
37 #include <IFSelect_SelectCombine.hxx>
38 #include <IFSelect_SelectUnion.hxx>
39 #include <IFSelect_SelectIntersection.hxx>
40 #include <IFSelect_SelectSignature.hxx>
42 #include <IFSelect_EditForm.hxx>
43 #include <IFSelect_Editor.hxx>
44 #include <IFSelect_ParamEditor.hxx>
45 #include <IFSelect_CheckCounter.hxx>
46 #include <IFSelect_TransformStandard.hxx>
48 #include <TColStd_MapOfInteger.hxx>
49 #include <OSD_Path.hxx>
50 #include <Interface_Macros.hxx>
51 #include <Interface_MSG.hxx>
52 #include <Message_Messenger.hxx>
53 #include <Message.hxx>
54 #include <Standard_Failure.hxx>
56 #define Flag_Incorrect 2
60 static Standard_Boolean errhand; // pb : un seul a la fois, mais ca va si vite
61 static TCollection_AsciiString bufstr;
64 // #################################################################
67 //=======================================================================
70 //=======================================================================
72 IFSelect_WorkSession::IFSelect_WorkSession ()
74 theshareout = new IFSelect_ShareOut;
75 theerrhand = errhand = Standard_True;
76 thenames = new Dico_DictionaryOfTransient;
77 thecopier = new IFSelect_ModelCopier;
78 thecopier->SetShareOut (theshareout);
79 thecheckdone = Standard_False;
80 thegtool = new Interface_GTool;
84 //=======================================================================
87 //=======================================================================
89 void IFSelect_WorkSession::SetErrorHandle (const Standard_Boolean hand)
91 theerrhand = errhand = hand;
95 //=======================================================================
98 //=======================================================================
100 Standard_Boolean IFSelect_WorkSession::ErrorHandle () const
106 //=======================================================================
109 //=======================================================================
111 const Handle(IFSelect_ShareOut)& IFSelect_WorkSession::ShareOut () const
117 //=======================================================================
120 //=======================================================================
122 void IFSelect_WorkSession::SetLibrary (const Handle(IFSelect_WorkLibrary)& lib)
128 //=======================================================================
131 //=======================================================================
133 Handle(IFSelect_WorkLibrary) IFSelect_WorkSession::WorkLibrary () const
139 //=======================================================================
142 //=======================================================================
144 void IFSelect_WorkSession::SetProtocol
145 (const Handle(Interface_Protocol)& protocol)
147 theprotocol = protocol;
148 Interface_Protocol::SetActive(protocol);
149 thegtool->SetProtocol (protocol);
153 //=======================================================================
156 //=======================================================================
158 Handle(Interface_Protocol) IFSelect_WorkSession::Protocol () const
164 //=======================================================================
167 //=======================================================================
169 void IFSelect_WorkSession::SetSignType
170 (const Handle(IFSelect_Signature)& signtype)
172 thegtool->SetSignType (signtype);
173 if (signtype.IsNull()) thenames->RemoveItem ("xst-sign-type");
174 else thenames->SetItem ("xst-sign-type",signtype);
178 //=======================================================================
181 //=======================================================================
183 Handle(IFSelect_Signature) IFSelect_WorkSession::SignType () const
185 return Handle(IFSelect_Signature)::DownCast (thegtool->SignType());
189 //=======================================================================
192 //=======================================================================
194 void IFSelect_WorkSession::SetShareOut
195 (const Handle(IFSelect_ShareOut)& shareout)
197 theshareout = shareout;
198 thecopier->SetShareOut (theshareout);
199 // ... faudrait ajouter les Params, Dispatches, etc...
203 //=======================================================================
206 //=======================================================================
208 Standard_Boolean IFSelect_WorkSession::HasModel () const
210 return (!themodel.IsNull());
214 //=======================================================================
217 //=======================================================================
219 void IFSelect_WorkSession::SetModel
220 (const Handle(Interface_InterfaceModel)& model,
221 const Standard_Boolean clearpointed)
223 if (themodel != model) {
225 //skl if (!themodel.IsNull()) themodel->Clear();
228 if (!thegtool.IsNull()) thegtool->ClearEntities(); //smh#14 FRA62479
229 // themodel->SetProtocol(theprotocol);
230 themodel->SetGTool (thegtool);
231 thegtool->Reservate (themodel->NbEntities()+20,Standard_True);
233 ComputeGraph(); // fait qqchose si Protocol present. Sinon, ne fait rien
234 ClearData(3); // RAZ CheckList, a refaire
237 // MISE A JOUR des SelectPointed C-A-D on efface leur contenu
238 if (clearpointed) ClearData(4);
243 //=======================================================================
246 //=======================================================================
248 Handle(Interface_InterfaceModel) IFSelect_WorkSession::Model () const
254 //=======================================================================
257 //=======================================================================
259 void IFSelect_WorkSession::SetLoadedFile (const Standard_CString filename)
262 theloaded.AssignCat (filename);
266 //=======================================================================
269 //=======================================================================
271 Standard_CString IFSelect_WorkSession::LoadedFile () const
273 return theloaded.ToCString();
277 //=======================================================================
280 //=======================================================================
282 IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile
283 (const Standard_CString filename)
285 if (thelibrary.IsNull()) return IFSelect_RetVoid;
286 if (theprotocol.IsNull()) return IFSelect_RetVoid;
287 Handle(Interface_InterfaceModel) model;
288 IFSelect_ReturnStatus status = IFSelect_RetVoid;
291 Standard_Integer stat = thelibrary->ReadFile (filename,model,theprotocol);
292 if (stat == 0) status = IFSelect_RetDone;
293 else if (stat < 0) status = IFSelect_RetError;
294 else status = IFSelect_RetFail;
296 catch(Standard_Failure) {
297 Handle(Message_Messenger) sout = Message::DefaultMessenger();
298 sout<<" **** Interruption ReadFile par Exception : ****\n";
299 sout << Standard_Failure::Caught()->GetMessageString();
300 sout<<"\n Abandon"<<endl;
301 status = IFSelect_RetFail;
303 if (status != IFSelect_RetDone) return status;
304 if (model.IsNull()) return IFSelect_RetVoid;
306 SetLoadedFile (filename);
311 //=======================================================================
314 //=======================================================================
316 Standard_Integer IFSelect_WorkSession::NbStartingEntities () const
318 if (themodel.IsNull()) return 0;
319 return themodel->NbEntities();
323 //=======================================================================
326 //=======================================================================
328 Handle(Standard_Transient) IFSelect_WorkSession::StartingEntity
329 (const Standard_Integer num) const
331 Handle(Standard_Transient) res; // Null par defaut
332 if (themodel.IsNull()) return res;
333 if (num < 1 || num > themodel->NbEntities()) return res;
334 return themodel->Value(num);
338 //=======================================================================
341 //=======================================================================
343 Standard_Integer IFSelect_WorkSession::StartingNumber
344 (const Handle(Standard_Transient)& ent) const
346 if (themodel.IsNull()) return 0;
347 return themodel->Number(ent);
351 //=======================================================================
354 //=======================================================================
356 Standard_Integer IFSelect_WorkSession::NumberFromLabel
357 (const Standard_CString val, const Standard_Integer afternum) const
359 Standard_Integer i, cnt = 0, num = atoi(val);
360 if (num > 0 || themodel.IsNull()) return num; // un n0 direct : gagne !
361 // Sinon, on considere que c est un label; a traiter en CaseNonSensitive ...
362 if (num > themodel->NbEntities()) { num = 0; return num; }
363 Standard_Boolean exact = Standard_False;
364 Standard_Integer after = (afternum >= 0 ? afternum : -afternum);
365 for (i = themodel->NextNumberForLabel (val, after, exact) ; i != 0;
366 i = themodel->NextNumberForLabel (val, i, exact)) {
368 if (num <= 0) num = i;
370 if (cnt == 1) return num;
372 // if (cnt == 0) cout<<" Label:"<<val<<" -> 0 ent"<<endl;
373 // if (cnt > 0) cout<<" Label:"<<val<<" ->"<<cnt<<" ent.s, refus"<<endl;
378 //=======================================================================
381 //=======================================================================
383 Handle(TCollection_HAsciiString) IFSelect_WorkSession::EntityLabel
384 (const Handle(Standard_Transient)& ent) const
386 Handle(TCollection_HAsciiString) name;
387 if (themodel.IsNull() || ent.IsNull()) return name;
388 if (!themodel->Contains(ent)) return name;
389 name = themodel->StringLabel(ent);
394 //=======================================================================
397 //=======================================================================
399 Handle(TCollection_HAsciiString) IFSelect_WorkSession::EntityName
400 (const Handle(Standard_Transient)& ent) const
402 Handle(TCollection_HAsciiString) name;
403 if (themodel.IsNull() || ent.IsNull()) return name;
404 Interface_ShareTool sht(thegraph->Graph());
407 Handle(Interface_GeneralModule) module;
408 if (!thegtool->Select (ent,module,CN)) return 0;
409 return module->Name (CN,ent,sht);
413 //=======================================================================
416 //=======================================================================
418 Standard_Integer IFSelect_WorkSession::CategoryNumber
419 (const Handle(Standard_Transient)& ent) const
421 if (themodel.IsNull()) return -1;
422 Standard_Integer num = StartingNumber(ent);
423 return themodel->CategoryNumber(num);
427 //=======================================================================
430 //=======================================================================
432 Standard_CString IFSelect_WorkSession::CategoryName
433 (const Handle(Standard_Transient)& ent) const
435 Standard_Integer cn = CategoryNumber (ent);
436 return Interface_Category::Name (cn);
440 //=======================================================================
443 //=======================================================================
445 Standard_CString IFSelect_WorkSession::ValidityName
446 (const Handle(Standard_Transient)& ent) const
448 if (StartingNumber(ent) == 0) return "";
449 return IFSelect_SignValidity::CVal (ent,themodel);
453 //=======================================================================
456 //=======================================================================
458 void IFSelect_WorkSession::ClearData (const Standard_Integer mode)
463 if (!themodel.IsNull()) themodel->Clear();
465 ClearData(2); ClearData(4);
469 case 2 : { thegraph.Nullify(); thecheckdone = Standard_False; thecheckana.Clear(); break; }
470 case 3 : { thecheckdone = Standard_False; break; }
472 // MISE A JOUR des SelectPointed C-A-D on efface leur contenu
473 // AINSI que des editeurs (en fait, les EditForm)
474 // Des compteurs C-A-D on efface leur contenu (a reevaluer)
475 Handle(TColStd_HSequenceOfInteger) list =
476 ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed));
477 Standard_Integer nb = list->Length();
478 Standard_Integer i; // svv #1
479 for (i = 1; i <= nb; i ++) {
480 DeclareAndCast(IFSelect_SelectPointed,sp,Item(list->Value(i)));
481 if (!sp.IsNull()) sp->Clear();
483 list = ItemIdents(STANDARD_TYPE(IFSelect_SignatureList));
485 for (i = 1; i <= nb; i ++) {
486 DeclareAndCast(IFSelect_SignatureList,sl,Item(list->Value(i)));
487 if (!sl.IsNull()) sl->Clear();
488 DeclareAndCast(IFSelect_SignCounter,sc,sl);
489 if (!sc.IsNull()) sc->SetSelMode(-1);
491 list = ItemIdents(STANDARD_TYPE(IFSelect_EditForm));
493 Handle(Standard_Transient) nulent;
494 for (i = 1; i <= nb; i ++) {
495 DeclareAndCast(IFSelect_EditForm,edf,Item(list->Value(i)));
506 //=======================================================================
509 //=======================================================================
511 Standard_Boolean IFSelect_WorkSession::ComputeGraph
512 (const Standard_Boolean enforce)
514 if (theprotocol.IsNull()) return Standard_False;
515 if (themodel.IsNull()) return Standard_False;
516 if (themodel->NbEntities() == 0) return Standard_False;
517 if (enforce) thegraph.Nullify();
518 if (!thegraph.IsNull()) {
519 if (themodel->NbEntities() == thegraph->Graph().Size()) return Standard_True;
522 // Il faut calculer le graphe pour de bon
523 thegraph = new Interface_HGraph (themodel,thegtool);
524 Standard_Integer nb = themodel->NbEntities();
525 Standard_Integer i; // svv #1
526 for (i = 1; i <= nb; i ++) thegraph->CGraph().SetStatus(i,0);
527 Interface_BitMap& bm = thegraph->CGraph().CBitMap();
529 bm.SetFlagName (Flag_Incorrect,"Incorrect");
532 thecheckdone = Standard_True;
534 // Calcul des categories, a present memorisees dans le modele
535 Interface_Category categ(thegtool);
536 Interface_ShareTool sht(thegraph);
537 for (i = 1; i <= nb; i ++) themodel->SetCategoryNumber
538 (i,categ.CatNum(themodel->Value(i),sht));
540 return Standard_True;
544 //=======================================================================
547 //=======================================================================
549 Handle(Interface_HGraph) IFSelect_WorkSession::HGraph ()
556 //=======================================================================
559 //=======================================================================
561 const Interface_Graph& IFSelect_WorkSession::Graph ()
564 if (thegraph.IsNull()) Standard_DomainError::Raise
565 ("IFSelect WorkSession : Graph not available");
566 return thegraph->Graph();
570 //=======================================================================
573 //=======================================================================
575 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::Shareds
576 (const Handle(Standard_Transient)& ent)
578 Handle(TColStd_HSequenceOfTransient) list;
579 if (!ComputeGraph()) return list;
580 if (StartingNumber(ent) == 0) return list;
581 return thegraph->Graph().Shareds(ent).Content();
585 //=======================================================================
588 //=======================================================================
590 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::Sharings
591 (const Handle(Standard_Transient)& ent)
593 Handle(TColStd_HSequenceOfTransient) list;
594 if (!ComputeGraph()) return list;
595 if (StartingNumber(ent) == 0) return list;
596 return thegraph->Graph().Sharings(ent).Content();
600 //=======================================================================
603 //=======================================================================
605 Standard_Boolean IFSelect_WorkSession::IsLoaded () const
607 if (theprotocol.IsNull()) return Standard_False;
608 if (themodel.IsNull()) return Standard_False;
609 if (themodel->NbEntities() == 0) return Standard_False;
610 if (thegraph.IsNull()) return Standard_False;
611 if (themodel->NbEntities() == thegraph->Graph().Size()) return Standard_True;
612 return Standard_False;
616 //=======================================================================
619 //=======================================================================
621 Standard_Boolean IFSelect_WorkSession::ComputeCheck
622 (const Standard_Boolean enforce)
624 if (enforce) thecheckdone = Standard_False;
625 if (thecheckdone) return Standard_True;
626 if (!IsLoaded()) return Standard_False;
628 Interface_Graph& CG = thegraph->CGraph();
629 Interface_CheckTool cht(thegraph);
630 Interface_CheckIterator checklist = cht.VerifyCheckList();
631 themodel->FillSemanticChecks(checklist,Standard_False);
633 // Et on met a jour le Graphe (BitMap) ! Flag Incorrect (STX + SEM)
634 Interface_BitMap& BM = CG.CBitMap();
635 BM.Init (Standard_False,Flag_Incorrect);
636 Standard_Integer num, nb = CG.Size();
637 for (checklist.Start(); checklist.More(); checklist.Next()) {
638 const Handle(Interface_Check) chk = checklist.Value();
639 if (!chk->HasFailed()) continue;
640 num = checklist.Number();
641 if (num > 0 && num <= nb) BM.SetTrue (num,Flag_Incorrect);
643 for (num = 1; num <= nb; num ++)
644 if (themodel->IsErrorEntity (num)) BM.SetTrue (num,Flag_Incorrect);
646 return Standard_True;
650 //=======================================================================
653 //=======================================================================
655 Interface_CheckIterator IFSelect_WorkSession::ModelCheckList
656 (const Standard_Boolean complete)
658 Interface_CheckIterator checks;
660 checks.CCheck(0)->AddFail("DATA NOT AVAILABLE FOR CHECK");
663 Interface_CheckTool cht(Graph());
664 checks = (complete ? cht.CompleteCheckList() : cht.AnalyseCheckList());
666 ((char*)(complete ? "Model Complete Check List" : "Model Syntactic Check List"));
671 //=======================================================================
674 //=======================================================================
676 Interface_CheckIterator IFSelect_WorkSession::CheckOne
677 (const Handle(Standard_Transient)& ent,
678 const Standard_Boolean complete)
680 Interface_CheckIterator checks;
681 checks.SetModel(themodel);
683 checks.CCheck(0)->AddFail("DATA NOT AVAILABLE FOR CHECK");
686 Standard_Integer num = -1;
687 if (ent.IsNull() || ent == themodel) num = 0;
688 else num = themodel->Number(ent);
690 Handle(Interface_Check) ach = themodel->Check (num,Standard_True);
691 if (complete) ach->GetMessages (themodel->Check (num,Standard_False));
692 if (num > 0) ach->SetEntity(ent);
693 checks.Add (ach,num);
694 checks.SetName ("Data Check (One Entity)");
699 //=======================================================================
702 //=======================================================================
704 Interface_CheckIterator IFSelect_WorkSession::LastRunCheckList () const
710 // #####################################################################
711 // .... LES VARIABLES ....
713 //=======================================================================
716 //=======================================================================
718 Standard_Integer IFSelect_WorkSession::MaxIdent () const
720 return theitems.Extent();
724 //=======================================================================
727 //=======================================================================
729 Handle(Standard_Transient) IFSelect_WorkSession::Item
730 (const Standard_Integer id) const
732 Handle(Standard_Transient) res;
733 if (id <= 0 || id > MaxIdent()) return res;
734 if (theitems.FindFromIndex(id).IsNull()) return res;
735 return theitems.FindKey(id);
739 //=======================================================================
742 //=======================================================================
744 Standard_Integer IFSelect_WorkSession::ItemIdent
745 (const Handle(Standard_Transient)& item) const
747 if (item.IsNull()) return 0;
748 Standard_Integer id = theitems.FindIndex(item);
749 if (id == 0) return 0;
750 if (theitems.FindFromIndex(id).IsNull()) return 0;
755 //=======================================================================
758 //=======================================================================
760 Handle(Standard_Transient) IFSelect_WorkSession::NamedItem
761 (const Standard_CString name) const
763 Handle(Standard_Transient) res;
764 if (name[0] == '\0') return res;
765 if (name[0] == '#') { // #nnn : pas un nom mais un n0 id.
766 Standard_Integer id = atoi( &name[1] );
769 if (!thenames->GetItem(name,res)) res.Nullify();
774 //=======================================================================
777 //=======================================================================
779 Handle(Standard_Transient) IFSelect_WorkSession::NamedItem
780 (const Handle(TCollection_HAsciiString)& name) const
782 Handle(Standard_Transient) res;
783 if (!name.IsNull()) res = NamedItem (name->ToCString());
788 //=======================================================================
791 //=======================================================================
793 Standard_Integer IFSelect_WorkSession::NameIdent
794 (const Standard_CString name) const
796 Handle(Standard_Transient) res;
797 if (name[0] == '\0') return 0;
798 if (name[0] == '#') { // #nnn : pas un nom mais un n0 id.
799 Standard_Integer id = atoi( &name[1] );
802 if (!thenames->GetItem(name,res)) return 0;
803 return ItemIdent(res);
807 //=======================================================================
810 //=======================================================================
812 Standard_Boolean IFSelect_WorkSession::HasName
813 (const Handle(Standard_Transient)& item) const
815 if (item.IsNull()) return Standard_False;
816 Standard_Integer id = theitems.FindIndex(item);
817 if (id == 0) return Standard_False;
818 Handle(Standard_Transient) att = theitems.FindFromIndex(id);
819 if (att.IsNull()) return Standard_False;
820 return att->IsKind(STANDARD_TYPE(TCollection_HAsciiString));
824 //=======================================================================
827 //=======================================================================
829 Handle(TCollection_HAsciiString) IFSelect_WorkSession::Name
830 (const Handle(Standard_Transient)& item) const
832 Handle(TCollection_HAsciiString) res;
833 if (item.IsNull()) return res;
834 Standard_Integer id = theitems.FindIndex(item);
835 if (id == 0) return res; // Null
836 Handle(Standard_Transient) att = theitems.FindFromIndex(id);
837 return GetCasted(TCollection_HAsciiString,att);
841 //=======================================================================
844 //=======================================================================
846 Standard_Integer IFSelect_WorkSession::AddItem
847 (const Handle(Standard_Transient)& item,
848 const Standard_Boolean active)
850 if (item.IsNull()) return 0;
851 Standard_Integer id = theitems.FindIndex(item);
853 Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id);
854 if (att.IsNull()) att = item;
855 //// if (theitems.FindFromIndex(id).IsNull()) id0 = theitems.Add(item,item);
857 else id = theitems.Add(item,item);
859 // Cas particuliers : Dispatch,Modifier
860 if (active) SetActive(item,Standard_True);
865 //=======================================================================
868 //=======================================================================
870 Standard_Integer IFSelect_WorkSession::AddNamedItem
871 (const Standard_CString name, const Handle(Standard_Transient)& item,
872 const Standard_Boolean active)
874 if (item.IsNull()) return 0;
875 if (name[0] == '#' || name[0] == '!') return 0;
876 // #nnn : pas un nom mais un numero. !... : reserve (interdit pour un nom)
877 // nom deja pris : on ecrase l ancienne valeur
878 if (name[0] != '\0') {
879 Standard_Boolean deja;
880 Handle(Standard_Transient)& newitem = thenames->NewItem(name,deja);
881 // if (deja & item != newitem) return 0;
884 Standard_Integer id = theitems.FindIndex(item);
886 Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id);
887 if (att.IsNull()) att = item;
888 if (name[0] != '\0') {
889 // if (!att->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) ecrasement admis !
890 att = new TCollection_HAsciiString(name);
893 else if (name[0] != '\0')
894 id = theitems.Add(item,new TCollection_HAsciiString(name));
895 else id = theitems.Add(item,item);
897 // Cas particuliers : Dispatch,Modifier
898 if (active) SetActive(item,Standard_True);
903 //=======================================================================
906 //=======================================================================
908 Standard_Boolean IFSelect_WorkSession::SetActive
909 (const Handle(Standard_Transient)& item, const Standard_Boolean mode)
911 if (item->IsKind(STANDARD_TYPE(IFSelect_Dispatch))) {
912 DeclareAndCast(IFSelect_Dispatch,disp,item);
913 Standard_Integer num = theshareout->DispatchRank(disp);
914 if ( num > theshareout->NbDispatches()) return Standard_False;
916 if (num > 0) return Standard_False;
917 theshareout->AddDispatch (disp);
918 return Standard_True;
920 if (num <= theshareout->LastRun()) return Standard_False;
921 theshareout->RemoveDispatch(num);
922 SetFileRoot(disp,""); // si onlynamed : nettoie aussi ShareOut
923 return Standard_True;
926 /* UTILISER EXPLICITEMENT SetAppliedModifier
927 if (item->IsKind(STANDARD_TYPE(IFSelect_GeneralModifier))) {
928 DeclareAndCast(IFSelect_GeneralModifier,modif,item);
930 theshareout->AddModifier(modif,0);
931 return Standard_True;
933 return theshareout->RemoveItem(modif);
937 return Standard_False;
941 //=======================================================================
944 //=======================================================================
946 Standard_Boolean IFSelect_WorkSession::RemoveNamedItem
947 (const Standard_CString name)
949 Handle(Standard_Transient) item = NamedItem(name);
950 if (item.IsNull()) return Standard_False;
951 if (!RemoveItem(item)) return Standard_False; // qui se charge de tout
952 return Standard_True;
956 //=======================================================================
959 //=======================================================================
961 Standard_Boolean IFSelect_WorkSession::RemoveName
962 (const Standard_CString name)
964 Handle(Standard_Transient) item = NamedItem(name);
965 if (item.IsNull()) return Standard_False;
967 Standard_Integer bid =
969 theitems.Add(item,item); // reste mais sans nom
970 return thenames->RemoveItem(name);
974 //=======================================================================
977 //=======================================================================
979 Standard_Boolean IFSelect_WorkSession::RemoveItem
980 (const Handle(Standard_Transient)& item)
982 if (item.IsNull()) return Standard_False;
983 Standard_Integer id = theitems.FindIndex(item);
984 if (id == 0) return Standard_False;
985 Handle(Standard_Transient)& att = theitems.ChangeFromIndex(id);
986 if (att.IsNull()) return Standard_False; // deja annulle
988 // Cas particuliers : Dispatch,Modifier
989 theshareout->RemoveItem(item);
991 // Marquer "Removed" dans la Map (on ne peut pas la vider)
992 if (att->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) {
993 if (!thenames->RemoveItem
994 (GetCasted(TCollection_HAsciiString,att)->ToCString()))
995 return Standard_False;
997 att.Nullify(); // cf ChangeFromIndex
998 // id = theitems.Add(item,att);
999 return Standard_True;
1003 //=======================================================================
1006 //=======================================================================
1008 void IFSelect_WorkSession::ClearItems ()
1012 theshareout->Clear(Standard_False);
1016 //=======================================================================
1019 //=======================================================================
1021 Handle(TCollection_HAsciiString) IFSelect_WorkSession::ItemLabel
1022 (const Standard_Integer id) const
1024 Handle(TCollection_HAsciiString) res;
1025 Handle(Standard_Transient) var = Item(id);
1026 if (var.IsNull()) return res;
1027 DeclareAndCast(TCollection_HAsciiString,text,var);
1028 if (!text.IsNull()) {
1029 res = new TCollection_HAsciiString("Text:");
1030 res->AssignCat(text);
1033 DeclareAndCast(IFSelect_IntParam,intpar,var);
1034 if (!intpar.IsNull()) {
1035 res = new TCollection_HAsciiString(intpar->Value());
1036 res->Insert(1,"Integer:");
1039 DeclareAndCast(IFSelect_Selection,sel,var);
1040 if (!sel.IsNull()) {
1041 res = new TCollection_HAsciiString("Selection:");
1042 res->AssignCat(sel->Label().ToCString());
1045 DeclareAndCast(IFSelect_GeneralModifier,mod,var);
1046 if (!mod.IsNull()) {
1047 if (mod->IsKind(STANDARD_TYPE(IFSelect_Modifier)))
1048 res = new TCollection_HAsciiString("ModelModifier:");
1049 else res = new TCollection_HAsciiString("FileModifier:");
1050 res->AssignCat(mod->Label().ToCString());
1053 DeclareAndCast(IFSelect_Dispatch,disp,var);
1054 if (!disp.IsNull()) {
1055 res = new TCollection_HAsciiString("Dispatch:");
1056 res->AssignCat(disp->Label().ToCString());
1059 DeclareAndCast(IFSelect_Transformer,tsf,var);
1060 if (!tsf.IsNull()) {
1061 res = new TCollection_HAsciiString("Transformer:");
1062 res->AssignCat(tsf->Label().ToCString());
1065 DeclareAndCast(IFSelect_SignatureList,slc,var);
1066 if (!slc.IsNull()) {
1067 res = new TCollection_HAsciiString("Counter:");
1068 res->AssignCat(slc->Name());
1071 DeclareAndCast(IFSelect_Signature,sig,var);
1072 if (!sig.IsNull()) {
1073 res = new TCollection_HAsciiString("Signature:");
1074 res->AssignCat(sig->Name());
1077 DeclareAndCast(IFSelect_EditForm,edf,var);
1078 if (!edf.IsNull()) {
1079 res = new TCollection_HAsciiString("EditForm:");
1080 res->AssignCat(edf->Label());
1083 DeclareAndCast(IFSelect_Editor,edt,var);
1084 if (!edt.IsNull()) {
1085 res = new TCollection_HAsciiString("Editor:");
1086 res->AssignCat(edt->Label().ToCString());
1089 res = new TCollection_HAsciiString("VariableType:");
1090 res->AssignCat(var->DynamicType()->Name());
1095 //=======================================================================
1098 //=======================================================================
1100 Handle(TColStd_HSequenceOfInteger) IFSelect_WorkSession::ItemIdents
1101 (const Handle(Standard_Type)& type) const
1103 Handle(TColStd_HSequenceOfInteger) list =
1104 new TColStd_HSequenceOfInteger();
1105 Standard_Integer nb = theitems.Extent();
1106 for (Standard_Integer i = 1; i <= nb; i ++) {
1107 if (theitems.FindKey(i)->IsKind(type)) list->Append(i);
1113 //=======================================================================
1116 //=======================================================================
1118 Handle(TColStd_HSequenceOfHAsciiString) IFSelect_WorkSession::ItemNames
1119 (const Handle(Standard_Type)& type) const
1121 Handle(TColStd_HSequenceOfHAsciiString) list =
1122 new TColStd_HSequenceOfHAsciiString();
1123 for (Dico_IteratorOfDictionaryOfTransient IT(thenames); IT.More(); IT.Next()){
1124 if (IT.Value()->IsKind(type)) list->Append
1125 (new TCollection_HAsciiString(IT.Name().ToCString()));
1131 // .. Recherche par label : recherche en liste(noms) ou iterative
1133 //=======================================================================
1136 //=======================================================================
1138 Handle(TColStd_HSequenceOfHAsciiString) IFSelect_WorkSession::ItemNamesForLabel
1139 (const Standard_CString label) const
1141 Handle(TColStd_HSequenceOfHAsciiString) list =
1142 new TColStd_HSequenceOfHAsciiString();
1143 Standard_Integer i, nb = MaxIdent();
1144 for (i = 1; i <= nb; i ++) {
1145 Handle(TCollection_HAsciiString) lab = ItemLabel(i);
1146 Handle(Standard_Transient) item = Item(i);
1147 if (lab.IsNull()) continue;
1148 if (label[0] != '\0' && lab->Search(label) <= 0) continue;
1150 Handle(TCollection_HAsciiString) nom = Name(Item(i));
1151 if (nom.IsNull()) { nom = new TCollection_HAsciiString(i); nom->Insert(1,'#'); }
1152 else nom = new TCollection_HAsciiString (nom);
1153 list->Append (new TCollection_HAsciiString(lab));
1159 //=======================================================================
1162 //=======================================================================
1164 Standard_Integer IFSelect_WorkSession::NextIdentForLabel
1165 (const Standard_CString label, const Standard_Integer id,
1166 const Standard_Integer mode) const
1168 Standard_Integer nb = MaxIdent();
1169 for (Standard_Integer i = id+1; i <= nb; i ++) {
1170 Handle(TCollection_HAsciiString) lab = ItemLabel(i);
1171 if (lab.IsNull()) continue;
1173 case 0 : if (!strcmp(lab->ToCString(),label)) return i; break; // switch
1174 case 1 : if (lab->Search(label) == 1 ) return i; break;
1175 case 2 : if (lab->Search(label) > 0 ) return i; break;
1176 default : break; // break du switch
1179 return 0; // ici : pas trouve
1183 // #################################################################
1184 // .... Parametres (Int et Text) ....
1186 //=======================================================================
1189 //=======================================================================
1191 Handle(Standard_Transient) IFSelect_WorkSession::NewParamFromStatic
1192 (const Standard_CString statname, const Standard_CString name)
1194 Handle(Standard_Transient) param;
1195 Handle(Interface_Static) stat = Interface_Static::Static(statname);
1196 if (stat.IsNull()) return param;
1197 if (stat->Type() == Interface_ParamInteger) {
1198 Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam;
1199 intpar->SetStaticName (statname);
1202 param = stat->HStringValue();
1204 if (param.IsNull()) return param;
1205 if ( AddNamedItem (name, param) == 0 ) param.Nullify();
1210 //=======================================================================
1213 //=======================================================================
1215 Handle(IFSelect_IntParam) IFSelect_WorkSession::IntParam
1216 (const Standard_Integer id) const
1217 { return Handle(IFSelect_IntParam)::DownCast(Item(id)); }
1220 //=======================================================================
1223 //=======================================================================
1225 Standard_Integer IFSelect_WorkSession::IntValue
1226 (const Handle(IFSelect_IntParam)& par) const
1228 if (!par.IsNull()) return par->Value();
1233 //=======================================================================
1236 //=======================================================================
1238 Handle(IFSelect_IntParam) IFSelect_WorkSession::NewIntParam
1239 (const Standard_CString name)
1241 Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam;
1242 if ( AddNamedItem (name, intpar) == 0 ) intpar.Nullify();
1247 //=======================================================================
1250 //=======================================================================
1252 Standard_Boolean IFSelect_WorkSession::SetIntValue
1253 (const Handle(IFSelect_IntParam)& par, const Standard_Integer val)
1255 if (ItemIdent(par) == 0) return Standard_False;
1257 return Standard_True;
1261 //=======================================================================
1264 //=======================================================================
1266 Handle(TCollection_HAsciiString) IFSelect_WorkSession::TextParam
1267 (const Standard_Integer id) const
1268 { return Handle(TCollection_HAsciiString)::DownCast(Item(id)); }
1271 //=======================================================================
1274 //=======================================================================
1276 TCollection_AsciiString IFSelect_WorkSession::TextValue
1277 (const Handle(TCollection_HAsciiString)& par) const
1279 if (!par.IsNull()) return TCollection_AsciiString(par->ToCString());
1280 else return TCollection_AsciiString();
1284 Handle(TCollection_HAsciiString) IFSelect_WorkSession::NewTextParam
1285 (const Standard_CString name)
1287 Handle(TCollection_HAsciiString) textpar = new TCollection_HAsciiString("");
1288 if ( AddNamedItem (name, textpar) == 0 ) textpar.Nullify();
1293 //=======================================================================
1296 //=======================================================================
1298 Standard_Boolean IFSelect_WorkSession::SetTextValue
1299 (const Handle(TCollection_HAsciiString)& par, const Standard_CString val)
1301 if (ItemIdent(par) == 0) return Standard_False;
1302 par->Clear(); par->AssignCat(val);
1303 return Standard_True;
1306 // ########################################################################
1307 // .... SIGNATURES ....
1309 //=======================================================================
1312 //=======================================================================
1314 Handle(IFSelect_Signature) IFSelect_WorkSession::Signature
1315 (const Standard_Integer id) const
1316 { return GetCasted(IFSelect_Signature,Item(id)); }
1318 Standard_CString IFSelect_WorkSession::SignValue
1319 (const Handle(IFSelect_Signature)& sign, const Handle(Standard_Transient)& ent) const
1321 if (sign.IsNull() || themodel.IsNull()) return "";
1322 if (StartingNumber(ent) == 0) return "";
1323 return sign->Value (ent,themodel);
1326 // ########################################################################
1327 // .... SELECTIONS & Cie ....
1329 //=======================================================================
1332 //=======================================================================
1334 Handle(IFSelect_Selection) IFSelect_WorkSession::Selection
1335 (const Standard_Integer id) const
1336 { return GetCasted(IFSelect_Selection,Item(id)); }
1339 //=======================================================================
1342 //=======================================================================
1344 Interface_EntityIterator IFSelect_WorkSession::EvalSelection
1345 (const Handle(IFSelect_Selection)& sel) const
1347 Interface_EntityIterator iter;
1349 errhand = Standard_False;
1352 iter = EvalSelection(sel); // appel normal (donc, code pas duplique)
1354 catch (Standard_Failure) {
1355 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1356 sout<<" **** Interruption EvalSelection par Exception : ****\n";
1357 sout<<Standard_Failure::Caught()->GetMessageString();
1358 sout<<"\n Abandon"<<endl;
1360 errhand = theerrhand;
1364 if (thegraph.IsNull()) return iter;
1365 // if (ItemIdent(sel) != 0) iter = sel->UniqueResult(thegraph->Graph());
1366 iter = sel->UniqueResult(thegraph->Graph());
1371 //=======================================================================
1374 //=======================================================================
1376 IFSelect_SelectionIterator IFSelect_WorkSession::Sources
1377 (const Handle(IFSelect_Selection)& sel) const
1379 return IFSelect_SelectionIterator (sel);
1383 //=======================================================================
1386 //=======================================================================
1388 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::SelectionResult
1389 (const Handle(IFSelect_Selection)& sel) const
1391 Handle(TColStd_HSequenceOfTransient) res;
1393 errhand = Standard_False;
1396 res = SelectionResult(sel); // appel normal (->code unique)
1398 catch (Standard_Failure) {
1399 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1400 sout<<" **** Interruption SelectionResult par Exception : ****\n";
1401 sout<<Standard_Failure::Caught()->GetMessageString();
1402 sout<<"\n Abandon"<<endl;
1404 errhand = theerrhand;
1409 cout<< " *** Data for Evaluation not available ***"<<endl;
1410 return new TColStd_HSequenceOfTransient();
1412 // if (ItemIdent(sel) == 0)
1414 { cout << " Selection : "<<" Unknown"<<endl; return res; } //cout<<Handle
1415 return EvalSelection (sel).Content();
1419 //=======================================================================
1422 //=======================================================================
1424 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::SelectionResultFromList
1425 (const Handle(IFSelect_Selection)& sel,
1426 const Handle(TColStd_HSequenceOfTransient)& list) const
1428 if (list.IsNull()) return SelectionResult (sel);
1429 DeclareAndCast(IFSelect_SelectDeduct,deduct,sel);
1430 if (deduct.IsNull()) return SelectionResult (sel);
1432 // On va chercher la derniere deduction de la chaine des inputs
1433 Handle(IFSelect_Selection) ssel, newinput;
1435 Standard_Integer i, nb = MaxIdent();
1436 for (i = 1; i <= nb * 2; i ++) {
1437 newinput = deduct->Input();
1438 deduct = GetCasted(IFSelect_SelectDeduct,newinput);
1439 if (deduct.IsNull()) break;
1443 // on y est (enfin, on devrait)
1444 // ssel est la derniere selection auscultee, deduct son downcast
1445 // input son Input (nulle si sel pas une deduction)
1446 deduct = GetCasted(IFSelect_SelectDeduct,ssel);
1448 Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
1450 deduct->SetInput (sp);
1452 deduct->Alternate()->SetList (list);
1454 // On execute puis on nettoie
1455 Handle(TColStd_HSequenceOfTransient) res = SelectionResult (sel);
1456 //// deduct->SetInput (newinput);
1461 //=======================================================================
1464 //=======================================================================
1466 Standard_Boolean IFSelect_WorkSession::SetItemSelection
1467 (const Handle(Standard_Transient)& item,
1468 const Handle(IFSelect_Selection)& sel)
1470 DeclareAndCast(IFSelect_Dispatch,disp,item);
1471 DeclareAndCast(IFSelect_GeneralModifier,modif,item);
1472 if (!disp.IsNull()) {
1473 if (ItemIdent(disp) == 0) return Standard_False;
1474 // Selection Nulle : Annuler FinalSelection
1475 if (!sel.IsNull() && ItemIdent(sel) == 0) return Standard_False;
1476 disp->SetFinalSelection(sel);
1477 return Standard_True;
1479 if (!modif.IsNull()) {
1480 if (ItemIdent(modif) == 0) return Standard_False;
1481 if (!sel.IsNull() && ItemIdent(sel) == 0) return Standard_False;
1482 // Selection Nulle : Annuler Selection
1483 modif->SetSelection(sel);
1484 return Standard_True;
1486 return Standard_False;
1490 //=======================================================================
1493 //=======================================================================
1495 Standard_Boolean IFSelect_WorkSession::ResetItemSelection
1496 (const Handle(Standard_Transient)& item)
1498 Handle(IFSelect_Selection) nulsel;
1499 return SetItemSelection (item,nulsel);
1503 //=======================================================================
1506 //=======================================================================
1508 Handle(IFSelect_Selection) IFSelect_WorkSession::ItemSelection
1509 (const Handle(Standard_Transient)& item) const
1511 Handle(IFSelect_Selection) sel;
1512 DeclareAndCast(IFSelect_Dispatch,disp,item);
1513 DeclareAndCast(IFSelect_GeneralModifier,modif,item);
1514 if (ItemIdent(disp) > 0) return disp->FinalSelection();
1515 if (ItemIdent(modif) > 0) return modif->Selection();
1516 return sel; // Nul ou inconnu -> Null
1519 // ######################################################################
1520 // .... Les COMPTEURS ....
1522 //=======================================================================
1525 //=======================================================================
1527 Handle(IFSelect_SignCounter) IFSelect_WorkSession::SignCounter
1528 (const Standard_Integer id) const
1529 { return GetCasted(IFSelect_SignCounter,Item(id)); }
1532 //=======================================================================
1535 //=======================================================================
1537 Standard_Boolean IFSelect_WorkSession::ComputeCounter
1538 (const Handle(IFSelect_SignCounter)& counter, const Standard_Boolean forced)
1540 if (counter.IsNull()) return Standard_False;
1541 if (!ComputeGraph()) return Standard_False;
1542 return counter->ComputeSelected (Graph(),forced);
1546 //=======================================================================
1549 //=======================================================================
1551 Standard_Boolean IFSelect_WorkSession::ComputeCounterFromList
1552 (const Handle(IFSelect_SignCounter)& counter,
1553 const Handle(TColStd_HSequenceOfTransient)& list,
1554 const Standard_Boolean clear)
1556 if (counter.IsNull()) return Standard_False;
1557 if (clear) counter->Clear();
1558 if (list.IsNull()) return ComputeCounter (counter,Standard_True);
1559 counter->AddList (list,themodel);
1560 return Standard_True;
1563 // ######################################################################
1564 // .... Les DISPATCHES ....
1566 //=======================================================================
1569 //=======================================================================
1571 Handle(TColStd_HSequenceOfInteger) IFSelect_WorkSession::AppliedDispatches
1574 Handle(TColStd_HSequenceOfInteger) list = new TColStd_HSequenceOfInteger();
1575 Standard_Integer nb = theshareout->NbDispatches();
1576 for (Standard_Integer i = 1; i <= nb; i ++) {
1577 list->Append (ItemIdent(theshareout->Dispatch(i)));
1583 //=======================================================================
1586 //=======================================================================
1588 void IFSelect_WorkSession::ClearShareOut (const Standard_Boolean onlydisp)
1590 theshareout->Clear(onlydisp);
1594 //=======================================================================
1597 //=======================================================================
1599 Handle(IFSelect_Dispatch) IFSelect_WorkSession::Dispatch
1600 (const Standard_Integer id) const
1602 return GetCasted(IFSelect_Dispatch,Item(id));
1606 //=======================================================================
1609 //=======================================================================
1611 Standard_Integer IFSelect_WorkSession::DispatchRank
1612 (const Handle(IFSelect_Dispatch)& disp) const
1614 if (ItemIdent(disp) == 0) return 0;
1615 return theshareout->DispatchRank(disp);
1618 // ######################################################################
1619 // .... Les MODIFIERS ....
1621 //=======================================================================
1624 //=======================================================================
1626 Handle(IFSelect_ModelCopier) IFSelect_WorkSession::ModelCopier () const
1632 //=======================================================================
1635 //=======================================================================
1637 void IFSelect_WorkSession::SetModelCopier
1638 (const Handle(IFSelect_ModelCopier)& copier)
1641 thecopier->SetShareOut(theshareout);
1645 //=======================================================================
1648 //=======================================================================
1650 Standard_Integer IFSelect_WorkSession::NbFinalModifiers
1651 (const Standard_Boolean formodel) const
1653 return theshareout->NbModifiers(formodel);
1657 //=======================================================================
1660 //=======================================================================
1662 Handle(TColStd_HSequenceOfInteger) IFSelect_WorkSession::FinalModifierIdents
1663 (const Standard_Boolean formodel) const
1665 // return ItemIdents(STANDARD_TYPE(IFSelect_Modifier));
1666 // On donne la liste dans l ordre du ModelCopier, qui fait foi
1667 Handle(TColStd_HSequenceOfInteger) list = new TColStd_HSequenceOfInteger();
1668 Standard_Integer nbm = theshareout->NbModifiers(formodel);
1669 for (Standard_Integer i = 1; i <= nbm; i ++)
1670 list->Append(ItemIdent(theshareout->GeneralModifier(formodel,i)));
1675 //=======================================================================
1678 //=======================================================================
1680 Handle(IFSelect_GeneralModifier) IFSelect_WorkSession::GeneralModifier
1681 (const Standard_Integer id) const
1683 return GetCasted(IFSelect_GeneralModifier,Item(id));
1687 //=======================================================================
1690 //=======================================================================
1692 Handle(IFSelect_Modifier) IFSelect_WorkSession::ModelModifier
1693 (const Standard_Integer id) const
1695 return GetCasted(IFSelect_Modifier,Item(id));
1699 //=======================================================================
1702 //=======================================================================
1704 Standard_Integer IFSelect_WorkSession::ModifierRank
1705 (const Handle(IFSelect_GeneralModifier)& modif) const
1707 if (ItemIdent(modif) == 0) return 0;
1708 return theshareout->ModifierRank(modif);
1712 //=======================================================================
1715 //=======================================================================
1717 Standard_Boolean IFSelect_WorkSession::ChangeModifierRank
1718 (const Standard_Boolean formodel,
1719 const Standard_Integer before, const Standard_Integer after)
1721 return theshareout->ChangeModifierRank(formodel,before,after);
1725 //=======================================================================
1728 //=======================================================================
1730 void IFSelect_WorkSession::ClearFinalModifiers ()
1732 Handle(TColStd_HSequenceOfInteger) list = FinalModifierIdents (Standard_True);
1733 Standard_Integer nb = list->Length();
1734 Standard_Integer i; // svv #1
1735 for (i = 1; i <= nb; i ++)
1736 RemoveItem(GeneralModifier(list->Value(i)));
1737 list = FinalModifierIdents (Standard_False);
1738 nb = list->Length();
1739 for (i = 1; i <= nb; i ++)
1740 RemoveItem(GeneralModifier(list->Value(i)));
1744 //=======================================================================
1747 //=======================================================================
1749 Standard_Boolean IFSelect_WorkSession::SetAppliedModifier
1750 (const Handle(IFSelect_GeneralModifier)& modif,
1751 const Handle(Standard_Transient)& item)
1753 if (ItemIdent(modif) == 0) return Standard_False;
1755 if (item.IsNull()) return Standard_False;
1756 if (item == theshareout) {
1757 theshareout->AddModifier(modif,0);
1758 return Standard_True;
1760 if (item->IsKind(STANDARD_TYPE(IFSelect_Dispatch))) {
1761 DeclareAndCast(IFSelect_Dispatch,disp,item);
1762 theshareout->AddModifier(modif,0);
1763 modif->SetDispatch(disp);
1764 return Standard_True;
1766 if (item->IsKind(STANDARD_TYPE(IFSelect_TransformStandard))) {
1767 DeclareAndCast(IFSelect_TransformStandard,stf,item);
1768 DeclareAndCast(IFSelect_Modifier,tmod,modif);
1769 if (tmod.IsNull()) return Standard_False;
1770 stf->AddModifier (tmod);
1771 theshareout->RemoveItem(modif);
1772 return Standard_True;
1774 return Standard_False;
1778 //=======================================================================
1781 //=======================================================================
1783 Standard_Boolean IFSelect_WorkSession::ResetAppliedModifier
1784 (const Handle(IFSelect_GeneralModifier)& modif)
1786 if (ItemIdent(modif) == 0) return Standard_False;
1788 return theshareout->RemoveItem(modif);
1792 //=======================================================================
1795 //=======================================================================
1797 Handle(Standard_Transient) IFSelect_WorkSession::UsesAppliedModifier
1798 (const Handle(IFSelect_GeneralModifier)& modif) const
1800 Handle(Standard_Transient) res;
1801 if (ItemIdent(modif) == 0) return res;
1802 if (theshareout->ModifierRank(modif) == 0) return res;
1803 res = modif->Dispatch();
1804 if (res.IsNull()) res = theshareout;
1808 // #################################################################
1809 // .... Transformer ....
1811 //=======================================================================
1814 //=======================================================================
1816 Handle(IFSelect_Transformer) IFSelect_WorkSession::Transformer
1817 (const Standard_Integer id) const
1819 return GetCasted(IFSelect_Transformer,Item(id));
1823 //=======================================================================
1826 //=======================================================================
1828 Standard_Integer IFSelect_WorkSession::RunTransformer
1829 (const Handle(IFSelect_Transformer)& transf)
1831 Standard_Integer effect = 0;
1832 if (transf.IsNull() || !IsLoaded()) return effect;
1833 Handle(Interface_InterfaceModel) newmod; // Null au depart
1834 Interface_CheckIterator checks;
1835 checks.SetName("X-STEP WorkSession : RunTransformer");
1836 Standard_Boolean res = transf->Perform
1837 (thegraph->Graph(),theprotocol,checks,newmod);
1839 if (!checks.IsEmpty(Standard_False)) {
1840 Handle(Message_Messenger) sout = Message::DefaultMessenger();
1841 sout<<" ** RunTransformer has produced Check Messages : **"<<endl;
1842 checks.Print (sout,themodel,Standard_False);
1844 thecheckdone = Standard_False;
1845 thecheckrun = checks;
1847 if (newmod.IsNull()) return (res ? 1 : -1);
1848 // MISE A JOUR des SelectPointed
1849 Handle(TColStd_HSequenceOfInteger) list =
1850 ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed));
1851 Standard_Integer nb = list->Length();
1852 for (Standard_Integer i = 1; i <= nb; i ++) {
1853 DeclareAndCast(IFSelect_SelectPointed,sp,Item(list->Value(i)));
1856 if (newmod == themodel) {
1857 effect = (res ? 2 : -2);
1858 if (!res) return effect;
1859 Handle(Interface_Protocol) newproto = theprotocol;
1860 if (transf->ChangeProtocol(newproto))
1861 { effect = 4; theprotocol = newproto; thegtool->SetProtocol(newproto); }
1862 return (ComputeGraph(Standard_True) ? 4 : -4);
1864 effect = (res ? 3 : -3);
1865 if (!res) return effect;
1866 Handle(Interface_Protocol) newproto = theprotocol;
1867 if (transf->ChangeProtocol(newproto))
1868 { effect = 5; theprotocol = newproto; thegtool->SetProtocol(newproto); }
1869 theoldel = themodel;
1870 SetModel(newmod,Standard_False);
1876 //=======================================================================
1879 //=======================================================================
1881 Standard_Integer IFSelect_WorkSession::RunModifier
1882 (const Handle(IFSelect_Modifier)& modif, const Standard_Boolean copy)
1884 Handle(IFSelect_Selection) sel; // null
1885 return RunModifierSelected (modif,sel,copy);
1889 //=======================================================================
1892 //=======================================================================
1894 Standard_Integer IFSelect_WorkSession::RunModifierSelected
1895 (const Handle(IFSelect_Modifier)& modif,
1896 const Handle(IFSelect_Selection)& sel, const Standard_Boolean copy)
1898 if (ItemIdent(modif) == 0) return Standard_False;
1899 Handle(IFSelect_TransformStandard) stf = new IFSelect_TransformStandard;
1900 stf->SetCopyOption(copy);
1901 stf->SetSelection (sel);
1902 stf->AddModifier (modif);
1903 return RunTransformer (stf);
1907 //=======================================================================
1910 //=======================================================================
1912 Handle(IFSelect_Transformer) IFSelect_WorkSession::NewTransformStandard
1913 (const Standard_Boolean copy, const Standard_CString name)
1915 Handle(IFSelect_TransformStandard) stf = new IFSelect_TransformStandard;
1916 stf->SetCopyOption(copy);
1917 if (AddNamedItem (name, stf) == 0) stf.Nullify();
1922 // Ceci est une action directe : pourrait etre fait par un Transformer ...
1923 //=======================================================================
1926 //=======================================================================
1928 Standard_Boolean IFSelect_WorkSession::SetModelContent
1929 (const Handle(IFSelect_Selection)& sel, const Standard_Boolean keep)
1931 if (sel.IsNull() || !IsLoaded()) return Standard_False;
1932 Interface_EntityIterator list = sel->UniqueResult(thegraph->Graph());
1933 if (list.NbEntities() == 0) return Standard_False;
1935 Handle(Interface_InterfaceModel) newmod = themodel->NewEmptyModel();
1936 Interface_CopyTool TC(themodel,theprotocol);
1937 Standard_Integer i, nb = themodel->NbEntities();
1939 for (list.Start(); list.More(); list.Next())
1940 TC.TransferEntity (list.Value());
1942 Standard_Integer* flags = new Standard_Integer[nb+1];
1943 for (i = 0; i <= nb; i ++) flags[i] = 0;
1944 for (list.Start(); list.More(); list.Next()) {
1945 Standard_Integer num = themodel->Number(list.Value());
1946 if (num <= nb) flags[num] = 1;
1948 for (i = 1; i <= nb; i ++) {
1949 if (flags[i] == 0) TC.TransferEntity (themodel->Value(i));
1953 TC.FillModel(newmod);
1954 if (newmod->NbEntities() == 0) return Standard_False;
1955 // Mettre a jour (ne pas oublier SelectPointed)
1956 theoldel = themodel;
1957 SetModel(newmod,Standard_False);
1958 // MISE A JOUR des SelectPointed
1959 Handle(TColStd_HSequenceOfInteger) pts =
1960 ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed));
1962 for (i = 1; i <= nb; i ++) {
1963 DeclareAndCast(IFSelect_SelectPointed,sp,Item(pts->Value(i)));
1964 sp->Update(TC.Control());
1966 return Standard_True;
1970 // #################################################################
1971 // .... File Name ....
1973 //=======================================================================
1976 //=======================================================================
1978 Handle(TCollection_HAsciiString) IFSelect_WorkSession::FilePrefix () const
1980 return theshareout->Prefix();
1984 //=======================================================================
1987 //=======================================================================
1989 Handle(TCollection_HAsciiString) IFSelect_WorkSession::DefaultFileRoot () const
1991 return theshareout->DefaultRootName();
1995 //=======================================================================
1998 //=======================================================================
2000 Handle(TCollection_HAsciiString) IFSelect_WorkSession::FileExtension () const
2002 return theshareout->Extension();
2006 //=======================================================================
2009 //=======================================================================
2011 Handle(TCollection_HAsciiString) IFSelect_WorkSession::FileRoot
2012 (const Handle(IFSelect_Dispatch)& disp) const
2014 return theshareout->RootName(theshareout->DispatchRank(disp));
2018 //=======================================================================
2021 //=======================================================================
2023 void IFSelect_WorkSession::SetFilePrefix (const Standard_CString name)
2025 theshareout->SetPrefix (new TCollection_HAsciiString(name));
2029 //=======================================================================
2032 //=======================================================================
2034 void IFSelect_WorkSession::SetFileExtension (const Standard_CString name)
2036 theshareout->SetExtension (new TCollection_HAsciiString(name));
2040 //=======================================================================
2043 //=======================================================================
2045 Standard_Boolean IFSelect_WorkSession::SetDefaultFileRoot
2046 (const Standard_CString name)
2048 Handle(TCollection_HAsciiString) defrt;
2049 if (name[0] != '\0') defrt = new TCollection_HAsciiString(name);
2050 return theshareout->SetDefaultRootName (defrt);
2054 //=======================================================================
2057 //=======================================================================
2059 Standard_Boolean IFSelect_WorkSession::SetFileRoot
2060 (const Handle(IFSelect_Dispatch)& disp, const Standard_CString namefile)
2062 Standard_Integer id = ItemIdent(disp);
2063 if (id == 0) return Standard_False;
2064 Standard_Integer nd = theshareout->DispatchRank(disp);
2065 /* if (theonlynamed) {
2066 if (nd == 0 && namefile[0] != 0)
2067 theshareout->AddDispatch(disp);
2068 else if (nd != 0 && namefile[0] == 0)
2069 theshareout->RemoveDispatch (nd);
2071 if (nd == 0) return Standard_False;
2072 // The order below prevented to change the root name on a given dispatch !
2073 // if (theshareout->HasRootName(nd)) return Standard_False;
2074 Handle(TCollection_HAsciiString) filename;
2075 if (namefile[0] != '\0') filename = new TCollection_HAsciiString (namefile);
2076 return theshareout->SetRootName(nd,filename);
2080 //=======================================================================
2083 //=======================================================================
2085 Standard_CString IFSelect_WorkSession::GiveFileRoot
2086 (const Standard_CString file) const
2088 OSD_Path path (file);
2089 if (!path.IsValid(TCollection_AsciiString(file))) return file; // tant pis ..
2090 bufstr = path.Name();
2091 return bufstr.ToCString();
2095 //=======================================================================
2098 //=======================================================================
2100 Standard_CString IFSelect_WorkSession::GiveFileComplete
2101 (const Standard_CString file) const
2103 // ajouter si besoin : Prefix; Extension
2104 bufstr.Clear(); bufstr.AssignCat (file);
2105 Standard_Integer i,j = 0,nb = bufstr.Length();
2106 Handle(TCollection_HAsciiString) ext = FileExtension ();
2107 if (!ext.IsNull()) {
2108 char val0 = '\0'; if (ext->Length() > 0) val0 = ext->Value(1);
2109 for (i = nb; i > 0; i --) if (bufstr.Value(i) == val0) { j = 1; break; }
2110 if (j == 0) bufstr.AssignCat (ext->ToCString());
2112 Handle(TCollection_HAsciiString) pre = FilePrefix ();
2113 if (!pre.IsNull()) {
2114 char val1 = '\0'; if (pre->Length() > 0) val1 = pre->Value(pre->Length());
2116 for (i = nb; i > 0; i --) if (bufstr.Value(i) == val1) { j = 1; break; }
2117 if (j == 0) bufstr.Insert (1,pre->ToCString());
2120 return bufstr.ToCString();
2124 //=======================================================================
2127 //=======================================================================
2129 void IFSelect_WorkSession::ClearFile ()
2131 thecopier->ClearResult();
2132 theshareout->ClearResult(Standard_True);
2136 //=======================================================================
2139 //=======================================================================
2141 void IFSelect_WorkSession::EvaluateFile ()
2144 if (!IsLoaded()) return;
2145 Interface_CheckIterator checks;
2147 errhand = Standard_False;
2150 EvaluateFile(); // appel normal (donc, code pas duplique)
2152 catch (Standard_Failure) {
2153 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2154 sout<<" **** Interruption EvaluateFile par Exception : ****\n";
2155 sout<<Standard_Failure::Caught()->GetMessageString();
2156 sout<<"\n Abandon"<<endl;
2157 checks.CCheck(0)->AddFail ("Exception Raised -> Abandon");
2159 errhand = theerrhand;
2160 thecheckrun = checks;
2164 IFSelect_ShareOutResult R(theshareout,thegraph->Graph());
2165 checks = thecopier->Copy (R,thelibrary,theprotocol);
2166 if (!checks.IsEmpty(Standard_False)) {
2167 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2168 sout<<" ** EvaluateFile has produced Check Messages : **"<<endl;
2169 checks.Print (sout,themodel,Standard_False);
2171 thecopier->SetRemaining (thegraph->CGraph());
2172 thecheckrun = checks;
2176 //=======================================================================
2179 //=======================================================================
2181 Standard_Integer IFSelect_WorkSession::NbFiles () const
2183 return thecopier->NbFiles();
2187 //=======================================================================
2190 //=======================================================================
2192 Handle(Interface_InterfaceModel) IFSelect_WorkSession::FileModel
2193 (const Standard_Integer num) const
2195 Handle(Interface_InterfaceModel) mod;
2196 if (num > 0 && num <= NbFiles()) mod = thecopier->FileModel(num);
2201 //=======================================================================
2204 //=======================================================================
2206 TCollection_AsciiString IFSelect_WorkSession::FileName
2207 (const Standard_Integer num) const
2209 TCollection_AsciiString name;
2210 if (num > 0 && num <= NbFiles()) name = thecopier->FileName(num);
2215 //=======================================================================
2218 //=======================================================================
2220 void IFSelect_WorkSession::BeginSentFiles (const Standard_Boolean record)
2222 thecopier->BeginSentFiles(theshareout,record);
2226 //=======================================================================
2229 //=======================================================================
2231 Handle(TColStd_HSequenceOfHAsciiString) IFSelect_WorkSession::SentFiles () const
2233 return thecopier->SentFiles();
2237 // #########################################################################
2238 // .... Action de Transfert proprement dite : la grande affaire ! ....
2240 //=======================================================================
2243 //=======================================================================
2245 Standard_Boolean IFSelect_WorkSession::SendSplit ()
2248 Interface_CheckIterator checks;
2251 errhand = Standard_False;
2254 return SendSplit(); // appel normal (donc, code pas duplique)
2256 catch (Standard_Failure) {
2257 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2258 sout<<" **** Interruption SendSplit par Exception : ****\n";
2259 sout<<Standard_Failure::Caught()->GetMessageString();
2260 sout<<"\n Abandon"<<endl;
2261 checks.CCheck(0)->AddFail ("Exception Raised -> Abandon");
2263 errhand = theerrhand;
2264 thecheckrun = checks;
2265 return Standard_False;
2268 if (thelibrary.IsNull()) {
2269 checks.CCheck(0)->AddFail("WorkLibrary undefined");
2270 thecheckrun = checks;
2271 return Standard_False;
2274 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2275 sout<< " *** Data for SendSplit not available ***"<<endl;
2276 checks.CCheck(0)->AddFail("Data not available");
2277 thecheckrun = checks;
2278 return Standard_False;
2281 if (NbFiles() > 0) checks = thecopier->SendCopied (thelibrary,theprotocol);
2284 IFSelect_ShareOutResult eval (ShareOut(), thegraph->Graph());
2285 checks = thecopier->Send (eval, thelibrary, theprotocol);
2286 thecopier->SetRemaining (thegraph->CGraph());
2289 if (theshareout.IsNull()) return Standard_False;
2290 Standard_Integer i, nbd = theshareout->NbDispatches();
2291 Standard_Integer nf = 0;
2292 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2293 sout<<" SendSplit .. ";
2294 for (i = 1; i <= nbd; i ++) {
2295 Handle(IFSelect_Dispatch) disp = theshareout->Dispatch(i);
2296 if (disp.IsNull()) continue;
2297 IFGraph_SubPartsIterator packs(thegraph->Graph(),Standard_False);
2298 disp->Packets (thegraph->Graph(),packs);
2299 for (packs.Start(); packs.More(); packs.Next()) {
2300 Interface_EntityIterator iter = packs.Entities();
2301 if (iter.NbEntities() == 0) continue;
2302 // Ecrire une liste d entites
2303 Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
2304 sp->SetList (iter.Content());
2306 TCollection_AsciiString filnam (nf);
2307 filnam.Insert (1,"_");
2308 Handle(TCollection_HAsciiString) filepart;
2309 filepart = FileRoot(disp);
2310 if (!filepart.IsNull()) filnam.Insert(1,filepart->ToCString());
2311 filepart = FilePrefix();
2312 if (!filepart.IsNull()) filnam.Insert(1,filepart->ToCString());
2313 filepart = FileExtension();
2314 if (!filepart.IsNull()) filnam.AssignCat (filepart->ToCString());
2315 IFSelect_ReturnStatus stat = SendSelected (filnam.ToCString(),sp);
2316 if (stat != IFSelect_RetDone) cout<<"File "<<filnam<<" failed"<<endl;
2319 sout<<" .. Files Written : "<<nf<<endl;
2321 thecheckrun = checks;
2322 return Standard_True;
2326 //=======================================================================
2329 //=======================================================================
2331 Handle(IFSelect_PacketList) IFSelect_WorkSession::EvalSplit () const
2333 Handle(IFSelect_PacketList) pks;
2334 if (!IsLoaded()) return pks;
2335 IFSelect_ShareOutResult sho (ShareOut(), thegraph->Graph());
2336 return sho.Packets();
2340 //=======================================================================
2343 //=======================================================================
2345 Interface_EntityIterator IFSelect_WorkSession::SentList
2346 (const Standard_Integer newcount) const
2348 Interface_EntityIterator iter;
2349 if (!IsLoaded()) return iter;
2350 const Interface_Graph& G = thegraph->Graph();
2351 Standard_Integer nb = G.Size();
2353 for ( i = 1; i <= nb; i ++) {
2354 Standard_Integer stat = G.Status(i);
2355 if ( (stat > 0 && newcount < 0) || stat == newcount)
2356 iter.GetOneItem(G.Entity(i));
2362 //=======================================================================
2365 //=======================================================================
2367 Standard_Integer IFSelect_WorkSession::MaxSendingCount () const
2369 Standard_Integer newcount = 0;
2370 if (!IsLoaded()) return newcount;
2371 const Interface_Graph& G = thegraph->Graph();
2372 Standard_Integer nb = G.Size();
2374 for (i = 1; i <= nb; i ++) {
2375 Standard_Integer stat = G.Status(i);
2376 if (stat > newcount) newcount = stat;
2382 //=======================================================================
2385 //=======================================================================
2387 Standard_Boolean IFSelect_WorkSession::SetRemaining
2388 (const IFSelect_RemainMode mode)
2390 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2391 if (!IsLoaded()) return Standard_False;
2392 if (mode == IFSelect_RemainForget) {
2393 Standard_Integer nb = thegraph->Graph().Size();
2394 for (Standard_Integer i = 1; i <= nb; i ++)
2395 thegraph->CGraph().SetStatus (i,0);
2397 return Standard_True;
2398 } else if (mode == IFSelect_RemainCompute) {
2399 Handle(Interface_InterfaceModel) newmod;
2400 Interface_CopyTool TC(themodel,theprotocol);
2401 thecopier->CopiedRemaining (thegraph->Graph(),thelibrary,TC,newmod);
2402 if (newmod.IsNull()) {
2403 sout<<" No Remaining Data recorded"<<endl; return Standard_False;
2404 } else if (newmod == themodel) {
2405 sout<<" Remaining causes all original data to be kept"<<endl;
2406 thecopier->SetRemaining (thegraph->CGraph());
2407 return Standard_False;
2409 theoldel = themodel;
2410 SetModel(newmod,Standard_False);
2411 // MISE A JOUR des SelectPointed
2412 Handle(TColStd_HSequenceOfInteger) list =
2413 ItemIdents(STANDARD_TYPE(IFSelect_SelectPointed));
2414 Standard_Integer nb = list->Length();
2415 for (Standard_Integer i = 1; i <= nb; i ++) {
2416 DeclareAndCast(IFSelect_SelectPointed,sp,Item(list->Value(i)));
2417 sp->Update(TC.Control());
2419 return Standard_True;
2421 } else if (mode == IFSelect_RemainDisplay) {
2422 Standard_Integer ne = 0;
2423 Standard_Integer nb = thegraph->Graph().Size();
2424 for (Standard_Integer i = 1; i <= nb; i ++)
2425 { if (thegraph->Graph().Status(i) >= 0) ne ++; }
2427 sout<<" - All entities are remaining, none yet sent"<<endl; return Standard_True;
2429 Interface_EntityIterator iter = SentList(0);
2430 nb = iter.NbEntities();
2432 sout<<" - No recorded remaining entities"<<endl; return Standard_True;
2434 sout <<" -- Recorded Remaining (not yet sent) Entities --"<<endl;
2435 ListEntities(iter,2);
2436 sout << " -- Maximum Sending Count (i.e. duplication in files) "<<
2437 MaxSendingCount() << endl;
2440 sout<< " - Now, dispatches are deactivated"<<endl;
2441 nb = theshareout->NbDispatches();
2442 for (Standard_Integer i = nb; i > theshareout->LastRun(); i --)
2443 theshareout->RemoveDispatch(i);
2445 return Standard_True;
2446 } else if (mode == IFSelect_RemainUndo) {
2447 if (theoldel.IsNull()) return Standard_False;
2448 SetModel(theoldel); theoldel.Nullify();
2449 return Standard_True;
2451 else return Standard_False;
2455 //=======================================================================
2458 //=======================================================================
2460 IFSelect_ReturnStatus IFSelect_WorkSession::SendAll
2461 (const Standard_CString filename, const Standard_Boolean computegraph)
2464 Interface_CheckIterator checks;
2465 if (!IsLoaded()) return IFSelect_RetVoid;
2466 if (thelibrary.IsNull()) {
2467 checks.CCheck(0)->AddFail("WorkLibrary undefined");
2468 thecheckrun = checks;
2469 return IFSelect_RetError;
2473 errhand = Standard_False;
2476 ComputeGraph(computegraph);
2477 checks = thecopier->SendAll(filename,thegraph->Graph(),thelibrary,theprotocol);
2479 catch (Standard_Failure) {
2480 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2481 sout<<" **** Interruption SendAll par Exception : ****\n";
2482 sout<<Standard_Failure::Caught()->GetMessageString();
2483 sout<<"\n Abandon"<<endl;
2484 errhand = theerrhand;
2485 checks.CCheck(0)->AddFail ("Exception Raised -> Abandon");
2486 thecheckrun = checks;
2487 return IFSelect_RetFail;
2490 else checks = thecopier->SendAll(filename,thegraph->Graph(),thelibrary,theprotocol);
2491 Handle_Interface_Check aMainFail = checks.CCheck(0);
2492 if (!aMainFail.IsNull() && aMainFail->HasFailed ())
2494 return IFSelect_RetStop;
2496 if (theloaded.Length() == 0) theloaded.AssignCat(filename);
2497 thecheckrun = checks;
2498 if (checks.IsEmpty(Standard_True)) return IFSelect_RetDone;
2499 return IFSelect_RetError;
2503 //=======================================================================
2506 //=======================================================================
2508 IFSelect_ReturnStatus IFSelect_WorkSession::SendSelected
2509 (const Standard_CString filename,
2510 const Handle(IFSelect_Selection)& sel,
2511 const Standard_Boolean computegraph)
2514 if (!IsLoaded()) return IFSelect_RetVoid;
2515 Interface_CheckIterator checks;
2516 if (thelibrary.IsNull()) {
2517 checks.CCheck(0)->AddFail("WorkLibrary undefined");
2518 thecheckrun = checks;
2519 return IFSelect_RetVoid;
2523 errhand = Standard_False;
2526 ComputeGraph(computegraph);
2527 return SendSelected (filename,sel); // appel normal
2529 catch (Standard_Failure) {
2530 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2531 sout<<" **** Interruption SendSelected par Exception : ****\n";
2532 sout<<Standard_Failure::Caught()->GetMessageString();
2533 sout<<"\n Abandon"<<endl;
2534 checks.CCheck(0)->AddFail ("Exception Raised -> Abandon");
2535 errhand = theerrhand;
2536 thecheckrun = checks;
2537 return IFSelect_RetFail;
2540 // if (ItemIdent(sel) == 0) return 3;
2541 Interface_EntityIterator iter = sel->UniqueResult(thegraph->Graph());
2542 if (iter.NbEntities() == 0) return IFSelect_RetVoid;
2544 checks = thecopier->SendSelected
2545 (filename,thegraph->Graph(),thelibrary,theprotocol,iter);
2546 thecopier->SetRemaining (thegraph->CGraph());
2547 thecheckrun = checks;
2548 if (checks.IsEmpty(Standard_True)) return IFSelect_RetDone;
2549 return IFSelect_RetError;
2553 //=======================================================================
2556 //=======================================================================
2558 IFSelect_ReturnStatus IFSelect_WorkSession::WriteFile
2559 (const Standard_CString filename)
2561 if (WorkLibrary().IsNull()) return IFSelect_RetVoid;
2562 ComputeGraph(Standard_True);
2563 if (!IsLoaded()) return IFSelect_RetVoid;
2564 return SendAll (filename);
2568 //=======================================================================
2571 //=======================================================================
2573 IFSelect_ReturnStatus IFSelect_WorkSession::WriteFile
2574 (const Standard_CString filename, const Handle(IFSelect_Selection)& sel)
2576 if (WorkLibrary().IsNull() || sel.IsNull()) return IFSelect_RetVoid;
2577 ComputeGraph(Standard_True);
2578 if (!IsLoaded()) return IFSelect_RetVoid;
2579 return SendSelected (filename,sel);
2582 // ################################################################
2583 // .... Actions particulieres sur les Selections ....
2585 //=======================================================================
2588 //=======================================================================
2590 Standard_Integer IFSelect_WorkSession::NbSources
2591 (const Handle(IFSelect_Selection)& sel) const
2593 if (ItemIdent(sel) == 0) return 0;
2594 if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectExtract)) ||
2595 sel->IsKind(STANDARD_TYPE(IFSelect_SelectDeduct)) ) return 1;
2596 if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectControl)) ) return 2;
2597 if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectCombine)) ) return
2598 GetCasted(IFSelect_SelectCombine,sel)->NbInputs();
2603 //=======================================================================
2606 //=======================================================================
2608 Handle(IFSelect_Selection) IFSelect_WorkSession::Source
2609 (const Handle(IFSelect_Selection)& sel, const Standard_Integer num) const
2611 Handle(IFSelect_Selection) sr;
2612 if (ItemIdent(sel) == 0) return sr;
2613 if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectExtract)) ) sr =
2614 GetCasted(IFSelect_SelectExtract,sel)->Input();
2615 else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectDeduct)) ) sr =
2616 GetCasted(IFSelect_SelectDeduct,sel)->Input();
2617 else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectControl)) ) {
2618 if (num == 1) sr = GetCasted(IFSelect_SelectControl,sel)->MainInput();
2619 else if (num == 2) sr = GetCasted(IFSelect_SelectControl,sel)->SecondInput();
2621 else if (sel->IsKind(STANDARD_TYPE(IFSelect_SelectCombine)) ) sr =
2622 GetCasted(IFSelect_SelectCombine,sel)->Input(num);
2627 //=======================================================================
2630 //=======================================================================
2632 Standard_Boolean IFSelect_WorkSession::IsReversedSelectExtract
2633 (const Handle(IFSelect_Selection)& sel) const
2635 if (ItemIdent(sel) == 0) return Standard_False;
2636 DeclareAndCast(IFSelect_SelectExtract,sxt,sel);
2637 if (sxt.IsNull()) return Standard_False;
2638 return (!sxt->IsDirect());
2642 //=======================================================================
2645 //=======================================================================
2647 Standard_Boolean IFSelect_WorkSession::ToggleSelectExtract
2648 (const Handle(IFSelect_Selection)& sel)
2650 if (ItemIdent(sel) == 0) return Standard_False;
2651 DeclareAndCast(IFSelect_SelectExtract,sxt,sel);
2652 if (sxt.IsNull()) return Standard_False;
2653 sxt->SetDirect(!sxt->IsDirect());
2654 return Standard_True;
2658 //=======================================================================
2661 //=======================================================================
2663 Standard_Boolean IFSelect_WorkSession::SetInputSelection
2664 (const Handle(IFSelect_Selection)& sel,
2665 const Handle(IFSelect_Selection)& inp)
2667 if (ItemIdent(sel) == 0) return Standard_False;
2668 if (!inp.IsNull() && ItemIdent(inp) == 0) return Standard_False;
2669 DeclareAndCast(IFSelect_SelectExtract,sxt,sel);
2670 if (!sxt.IsNull()) { sxt->SetInput(inp); return Standard_True; }
2671 DeclareAndCast(IFSelect_SelectDeduct,sdt,sel);
2672 if (!sdt.IsNull()) { sdt->SetInput(inp); return Standard_True; }
2673 return Standard_False;
2677 //=======================================================================
2680 //=======================================================================
2682 Standard_Boolean IFSelect_WorkSession::SetControl
2683 (const Handle(IFSelect_Selection)& sel,
2684 const Handle(IFSelect_Selection)& sc,
2685 const Standard_Boolean formain)
2687 DeclareAndCast(IFSelect_SelectControl,dsel,sel);
2688 if (ItemIdent(dsel) == 0) return Standard_False;
2689 if (ItemIdent(sc) == 0) return Standard_False;
2690 if (formain) dsel->SetMainInput (sc);
2691 else dsel->SetSecondInput (sc);
2692 return Standard_True;
2696 //=======================================================================
2699 //=======================================================================
2701 Standard_Integer IFSelect_WorkSession::CombineAdd
2702 (const Handle(IFSelect_Selection)& sel,
2703 const Handle(IFSelect_Selection)& seladd,
2704 const Standard_Integer atnum)
2706 DeclareAndCast(IFSelect_SelectCombine,csel,sel);
2707 if (ItemIdent(csel) == 0) return 0;
2708 if (ItemIdent(seladd) == 0) return 0;
2709 csel->Add (seladd,atnum);
2710 return csel->NbInputs();
2714 //=======================================================================
2717 //=======================================================================
2719 Standard_Boolean IFSelect_WorkSession::CombineRemove
2720 (const Handle(IFSelect_Selection)& selcomb,
2721 const Handle(IFSelect_Selection)& selrem)
2723 DeclareAndCast(IFSelect_SelectCombine,csel,selcomb);
2724 if (ItemIdent(csel) == 0) return Standard_False;
2725 if (ItemIdent(selrem) == 0) return Standard_False;
2726 Standard_Integer nb = csel->NbInputs();
2727 for (Standard_Integer i = nb; i > 0; i --) {
2728 if (csel->Input(i) == selrem) {
2730 return Standard_True;
2733 return Standard_True;
2737 //=======================================================================
2740 //=======================================================================
2742 Handle(IFSelect_Selection) IFSelect_WorkSession::NewSelectPointed
2743 (const Handle(TColStd_HSequenceOfTransient)& list,
2744 const Standard_CString name)
2746 Handle(IFSelect_SelectPointed) sel = new IFSelect_SelectPointed;
2747 if (!list.IsNull()) sel->AddList (list);
2748 if (AddNamedItem (name,sel) == 0) sel.Nullify();
2753 //=======================================================================
2756 //=======================================================================
2758 Standard_Boolean IFSelect_WorkSession::SetSelectPointed
2759 (const Handle(IFSelect_Selection)& sel,
2760 const Handle(TColStd_HSequenceOfTransient)& list,
2761 const Standard_Integer mode) const
2763 DeclareAndCast(IFSelect_SelectPointed,sp,sel);
2764 if (sp.IsNull() || list.IsNull()) return Standard_False;
2765 if (mode == 0) sp->Clear();
2766 if (mode >= 0) sp->AddList(list);
2767 else sp->RemoveList(list);
2768 return Standard_True;
2772 // ###########################################################################
2773 // .... Analyse d un CheckIterator par rapport a un graphe ....
2775 //=======================================================================
2778 //=======================================================================
2780 static void IFSelect_QueryProp (Interface_IntList& list,
2781 TCollection_AsciiString& ana,
2782 const Standard_Integer num, const int quoi)
2784 list.SetNumber(num);
2785 Standard_Integer i, nb = list.Length();
2786 for (i = 1; i <= nb; i ++) {
2787 if (i > 1) list.SetNumber(num); // because recursive call + depth first
2788 Standard_Integer n = list.Value(i);
2789 // y a t il lieu de propager ?
2790 // 1 W/place 2 F/place 3 Wprop 4Wprop+W/place 5Wprop+F/place
2791 // 6 Fprop 7 Fprop+W/place 8 Fprop+F/place
2792 char val = ana.Value(n);
2794 case ' ' : val = (quoi ? '3' : '6'); break;
2795 case '1' : val = (quoi ? '4' : '7'); break;
2796 case '2' : val = (quoi ? '5' : '8'); break;
2797 case '3' : val = (quoi ? ' ' : '6'); break;
2798 case '4' : val = (quoi ? ' ' : '7'); break;
2799 case '5' : val = (quoi ? ' ' : '8'); break;
2800 case '6' : val = ' '; break;
2801 case '7' : val = ' '; break;
2802 case '8' : val = ' '; break;
2803 default : val = ' '; break;
2805 if (val == ' ') continue;
2806 ana.SetValue(n,val);
2807 IFSelect_QueryProp (list,ana,n,quoi);
2812 //=======================================================================
2815 //=======================================================================
2817 void IFSelect_WorkSession::QueryCheckList (const Interface_CheckIterator& chl)
2819 if (!IsLoaded()) return;
2820 Standard_Integer i,nb = themodel->NbEntities();
2821 thecheckana = TCollection_AsciiString (' ',nb+1);
2822 for (chl.Start(); chl.More(); chl.Next()) {
2823 Standard_Integer num = chl.Number();
2824 const Handle(Interface_Check) ach = chl.Value();
2825 if (ach->HasFailed()) thecheckana.SetValue(num,'2');
2826 else if (ach->HasWarnings()) thecheckana.SetValue(num,'1');
2828 // analyse selon le graphe ... codes : blc = rien
2829 // 1 W/place 2 F/place 3 Wprop 4Wprop+W/place 5Wprop+F/place
2830 // 6 Fprop 7 Fprop+W/place 8 Fprop+F/place
2831 Interface_IntList list = thegraph->Graph().SharingNums(0);
2832 // deux passes : d abord Warning, puis Fail
2833 for (i = 1; i <= nb; i ++) {
2834 char val = thecheckana.Value(i);
2836 if (val == '1' || val == '4' || val == '7') quoi = 0;
2837 if (quoi >= 0) IFSelect_QueryProp (list,thecheckana,i,quoi);
2839 for (i = 1; i <= nb; i ++) {
2840 char val = thecheckana.Value(i);
2842 if (val == '2' || val == '5' || val == '8') quoi = 1;
2843 if (quoi >= 0) IFSelect_QueryProp (list,thecheckana,i,quoi);
2848 //=======================================================================
2851 //=======================================================================
2853 Standard_Integer IFSelect_WorkSession::QueryCheckStatus
2854 (const Handle(Standard_Transient)& ent) const
2856 if (!IsLoaded()) return -1;
2857 Standard_Integer num = themodel->Number(ent);
2858 if (num == 0) return -1;
2859 if (thecheckana.Length() < num) return -1;
2860 Standard_Character val = thecheckana.Value (num);
2861 // codes : blc = rien -> 0
2862 // 1 W/place -> 1 2 F/place -> 2
2863 // 3 Wprop -> 10 4 Wprop+W/place -> 11 5 Wprop+F/place -> 12
2864 // 6 Fprop -> 20 7 Fprop+W/place -> 21 8 Fprop+F/place -> 22
2865 if (val == ' ') return 0;
2866 if (val == '1') return 1;
2867 if (val == '2') return 2;
2868 if (val == '3') return 10;
2869 if (val == '4') return 11;
2870 if (val == '5') return 12;
2871 if (val == '6') return 20;
2872 if (val == '7') return 21;
2873 if (val == '8') return 22;
2878 //=======================================================================
2881 //=======================================================================
2883 Standard_Integer IFSelect_WorkSession::QueryParent
2884 (const Handle(Standard_Transient)& entdad,
2885 const Handle(Standard_Transient)& entson) const
2887 Standard_Integer ndad = StartingNumber(entdad);
2888 Standard_Integer nson = StartingNumber(entson);
2889 if (ndad < 1 || nson < 1) return -1;
2890 if (ndad == nson) return 0;
2891 // on va calculer : pour chaque pere immediat, de <son>, status avec <dad> + 1
2892 // nb : pas protege contre les boucles ...
2893 Handle(TColStd_HSequenceOfTransient) list =
2894 thegraph->Graph().Sharings(entson).Content();
2895 if (list.IsNull()) return -1;
2896 Standard_Integer i, nb = list->Length();
2897 for (i = 1; i <= nb; i ++) {
2898 if (list->Value(i) == entdad) return 1;
2899 Standard_Integer stat = QueryParent ( entdad,list->Value(i) );
2900 if (stat >= 0) return stat+1;
2903 Interface_IntList sharings = thegraph->Graph().SharingNums (nson);
2904 Standard_Integer i, nb = sharings.Length();
2905 for (i = 1; i <= nb; i ++) {
2906 if (sharings.Value(i) == nson) return 1;
2907 Standard_Integer stat = QueryParent
2908 ( entson,StartingEntity(sharings.Value(i)) );
2909 if (stat >= 0) return stat+1;
2912 return -1; // not yet implemented ...
2915 // ###########################################################################
2916 // .... Dumps et Evaluations, pas faciles a passer en arguments ....
2918 // #### #### #### #### #### #### #### #### ####
2919 // .... DumpShare ....
2921 //=======================================================================
2924 //=======================================================================
2926 void IFSelect_WorkSession::SetParams
2927 (const TColStd_SequenceOfTransient& params,
2928 const TColStd_SequenceOfInteger& uselist)
2930 Standard_Integer i, nbp = params.Length(), nbu = uselist.Length();
2931 Handle(IFSelect_ParamEditor) editor = new IFSelect_ParamEditor
2932 (nbp+nbu+50,"Parameter Editor");
2933 for (i = 1; i <= nbp; i ++) {
2934 DeclareAndCast(Interface_TypedValue,val,params.Value(i));
2935 if (val.IsNull()) continue;
2936 editor->AddValue(val);
2938 AddNamedItem("xst-params-edit",editor);
2940 Handle(IFSelect_EditForm) paramsall = editor->Form(Standard_False);
2941 AddNamedItem("xst-params-all",paramsall);
2943 // On attaque les EditForms partielles
2944 TColStd_SequenceOfInteger listgen,listload,listsend,listsplit,listread,listwrite;
2945 for (i = 1; i <= nbu; i ++) {
2946 Standard_Integer use = uselist.Value(i);
2948 case 1 : listgen.Append(i); break;
2949 case 2 : listread.Append(i); break;
2950 case 3 : listsend.Append(i); break;
2951 case 4 : listsplit.Append(i); break;
2952 case 5 : listread.Append(i); break;
2953 case 6 : listwrite.Append(i); break;
2957 Handle(IFSelect_EditForm) paramsgen = new IFSelect_EditForm
2958 (editor,listgen ,Standard_False,Standard_True,"General Parameters");
2959 if (listgen.Length() > 0) AddNamedItem("xst-params-general",paramsgen);
2960 Handle(IFSelect_EditForm) paramsload = new IFSelect_EditForm
2961 (editor,listload,Standard_False,Standard_True,"Loading Parameters");
2962 if (listload.Length() > 0) AddNamedItem("xst-params-load", paramsload);
2963 Handle(IFSelect_EditForm) paramssend = new IFSelect_EditForm
2964 (editor,listsend,Standard_False,Standard_True,"Sending Parameters");
2965 if (listsend.Length() > 0) AddNamedItem("xst-params-send", paramssend);
2966 Handle(IFSelect_EditForm) paramsplit = new IFSelect_EditForm
2967 (editor,listsplit,Standard_False,Standard_True,"Split Parameters");
2968 if (listsplit.Length() > 0) AddNamedItem("xst-params-split", paramsplit);
2969 Handle(IFSelect_EditForm) paramsread = new IFSelect_EditForm
2970 (editor,listread,Standard_False,Standard_True,"Read(Transfer) Parameters");
2971 if (listread.Length() > 0) AddNamedItem("xst-params-read", paramsread);
2972 Handle(IFSelect_EditForm) paramswrite = new IFSelect_EditForm
2973 (editor,listwrite,Standard_False,Standard_True,"Write(Transfer) Parameters");
2974 if (listwrite.Length() > 0) AddNamedItem("xst-params-write", paramswrite);
2978 //=======================================================================
2981 //=======================================================================
2983 void IFSelect_WorkSession::TraceStatics
2984 (const Standard_Integer use, const Standard_Integer mode) const
2986 Handle(Message_Messenger) sout = Message::DefaultMessenger();
2988 if (mode == 0) sout<<"******************************************"<<endl;
2990 if (mode == 0) sout<<"***** General Parameters *****"<<endl;
2991 } else if (use == 2) {
2992 if (mode == 0) sout<<"***** Load File *****"<<endl;
2993 } else if (use == 3) {
2994 if (mode == 0) sout<<"***** Write File *****"<<endl;
2995 } else if (use == 4) {
2996 if (mode == 0) sout<<"***** Split File *****"<<endl;
2997 } else if (use == 5) {
2998 if (mode == 0) sout<<"***** Transfer (Read) *****"<<endl;
2999 } else if (use == 6) {
3000 if (mode == 0) sout<<"***** Transfer (Write) *****"<<endl;
3002 if (mode == 0) sout<<"******************************************"<<endl<<endl;
3005 // Echainements particuliers (use > 0)
3007 TraceStatics (-2,mode);
3008 if (mode == 0) sout<<endl;
3009 } else if (use == 4 || use == 6) {
3010 TraceStatics (-3,mode);
3011 if (mode == 0) sout<<endl;
3014 // Valeurs particulieres
3015 if (use == 1 || use == -1) { // General : trace
3017 // sout << "Trace Level : "<<Message_PrinterOStream::Default()->GetTraceLevel()<<endl;
3019 } else if (use == 4 || use == -4) { // Split : Prefix & cie
3021 Handle(TCollection_HAsciiString) str = theshareout->Prefix();
3022 if (!str.IsNull()) sout << "Prefix : "<<str->ToCString()<<endl;
3023 else sout << "Prefix not Defined" << endl;
3024 str = theshareout->DefaultRootName();
3025 if (!str.IsNull()) sout << "Default Root : "<<str->ToCString()<<endl;
3026 else sout << "Default Root not Defined" << endl;
3027 str = theshareout->Extension();
3028 if (!str.IsNull()) sout << "Extension : "<<str->ToCString()<<endl;
3029 else sout << "Extension not defined" << endl;
3033 // LISTER LES STATICS
3034 // Passer par les ParamEditor ...
3038 if (mode == 0) sout<<"******************************************"<<endl<<endl;
3043 //=======================================================================
3046 //=======================================================================
3048 void IFSelect_WorkSession::DumpShare () const
3050 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3051 sout<<" ********** Definition ShareOut (Complete) **********"<<endl;
3053 Handle(TCollection_HAsciiString) str = theshareout->Prefix();
3054 if (!str.IsNull()) sout << "Prefix : " << str->ToCString() << endl;
3055 else sout << "Prefix not Defined" << endl;
3056 str = theshareout->DefaultRootName();
3057 if (!str.IsNull()) sout << "Default Root : " << str->ToCString() << endl;
3058 else sout << "Default Root not Defined" << endl;
3059 str = theshareout->Extension();
3060 if (!str.IsNull()) sout << "Extension : " << str->ToCString() << endl;
3061 else sout << "Extension not defined" << endl;
3063 Standard_Integer lr = theshareout->LastRun();
3064 Standard_Integer nb = theshareout->NbDispatches();
3065 sout << "Nb Dispatches : " << nb <<" (Last Run : " << lr << ") : "<<endl;
3066 for (Standard_Integer i = 1; i <= nb; i ++) {
3067 Handle(IFSelect_Dispatch) disp = theshareout->Dispatch(i);
3068 sout << "Dispatch n0 " << i;
3069 if (HasName(disp)) sout << " Name:"<< Name(disp)->ToCString();
3070 sout << " Label:" << disp->Label() << endl;
3071 Handle(IFSelect_Selection) sel = disp->FinalSelection();
3072 if (sel.IsNull()) sout << " No Final Selection Defined" << endl;
3073 else if (HasName(sel)) sout << " Final Selection : Name:"
3074 << Name(sel)->ToCString() << " Label:" << sel->Label() << endl;
3075 else sout << " Final Selection : " << sel->Label() << endl;
3076 if (disp->HasRootName())
3077 sout<<" File Root Name : "<<disp->RootName()->ToCString()<<endl;
3078 else sout<<" No specific file root name (see Default Root)"<<endl;
3080 Standard_Integer nbm = theshareout->NbModifiers(Standard_True);
3082 " *** "<<nbm<<" active Model Modifiers : see ListModifiers ***"<<endl;
3083 Standard_Integer nbf = theshareout->NbModifiers(Standard_False);
3085 " *** "<<nbf<<" active File Modifiers : see ListModifiers ***"<<endl;
3086 if (nbm+nbf == 0) sout<<" *** No active Modifiers ***"<<endl;
3089 // #### #### #### #### #### #### #### #### ####
3090 // .... ListItems ....
3092 //=======================================================================
3095 //=======================================================================
3097 void IFSelect_WorkSession::ListItems (const Standard_CString lab) const
3099 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3100 sout<< " ********** Items in Session **********"<<endl;
3101 Standard_Integer nb = MaxIdent();
3102 Handle(TCollection_HAsciiString) str;
3103 if (lab[0] != '\0') str = new TCollection_HAsciiString (lab);
3104 for (Standard_Integer i = 1; i <= nb; i ++) {
3105 const Handle(Standard_Transient)& var = theitems.FindKey(i);
3106 Handle(TCollection_HAsciiString) label = ItemLabel(i);
3107 if (label.IsNull()) continue; // -> item supprime
3108 if (!str.IsNull()) { if (label->Location(str,1,label->Length()) == 0) continue; }
3110 if (HasName(var)) sout<<" - Named : "<<Name(var)->ToCString()<<" - ";
3111 else sout<<" - (no name) - ";
3112 sout<<var->DynamicType()->Name()<<endl<<" "<<label->ToCString()<<endl;
3116 // #### #### #### #### #### #### #### #### ####
3117 // .... ListModifiers
3119 //=======================================================================
3122 //=======================================================================
3124 void IFSelect_WorkSession::ListFinalModifiers
3125 (const Standard_Boolean formodel) const
3127 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3128 Standard_Integer nb = theshareout->NbModifiers(formodel);
3129 sout<< " ********** Modifiers in Session ";
3130 sout<<(formodel ? "(For Model)" : "(For File)");
3131 sout<<": "<<nb<<" **********"<<endl;
3132 for (Standard_Integer i = 1; i <= nb; i ++) {
3133 Handle(IFSelect_GeneralModifier) modif =
3134 theshareout->GeneralModifier(formodel,i);
3135 if (!modif.IsNull()) sout<<"Modifier n0."<<i<<" : "<<modif->Label();
3136 if (HasName(modif)) sout << " Named as : " << Name(modif)->ToCString();
3141 // #### #### #### #### #### #### #### #### ####
3142 // .... DumpSelection ....
3144 //=======================================================================
3147 //=======================================================================
3149 void IFSelect_WorkSession::DumpSelection
3150 (const Handle(IFSelect_Selection)& sel) const
3152 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3153 if (ItemIdent(sel) == 0) {
3154 sout << "Selection : "<<" Unknown"<<endl; //sout<<Handle
3157 sout << " ********** Selection";
3158 if (HasName(sel)) sout << " , Name : " << Name(sel)->ToCString();
3159 sout <<" **********"<<endl;
3160 sout<< "Label : " << sel->Label() << " . Input(s) : "<< endl;
3161 Standard_Integer nb = 0;
3162 IFSelect_SelectionIterator iter; sel->FillIterator(iter);
3163 for (; iter.More(); iter.Next()) {
3165 Handle(IFSelect_Selection) newsel = iter.Value();
3166 sout<<" -- "<<newsel->Label()<<endl;
3168 sout << " Nb Inputs:"<<nb<<endl;
3172 // ##########################################
3173 // ######### Fonctions complementaires
3174 // ##########################################
3176 // #### #### #### #### #### #### #### #### ####
3177 // .... DumpModel ....
3179 //=======================================================================
3182 //=======================================================================
3184 Handle(IFSelect_Selection) IFSelect_WorkSession::GiveSelection
3185 (const Standard_CString selname) const
3188 Standard_Integer np = -1, nf = -1, nivp = 0;
3189 for (Standard_Integer n = 0; selname[n] != '\0'; n ++) {
3190 nomsel[n] = selname[n]; nomsel[n+1] = '\0';
3191 if (selname[n] == '(') { np = n; nivp ++; }
3192 if (selname[n] == ')') { nivp --; if (nivp <= 0) nf = n; }
3193 //// if (selname[n] == ' ') { nb = n; break; }
3196 Handle(IFSelect_Selection) sel;
3197 if (np >= 0) nomsel[np] = 0; if (nf >= 0) nomsel[nf] = '\0';
3198 Handle(Standard_Transient) item = NamedItem(nomsel);
3200 // Parentheses ? essayer Signature (plus tard : Selection parametree)
3201 // NB : on compte les niveaux de parentheses (imbrications repercutees)
3202 if (np > 0 && nf > 0) {
3203 Handle(IFSelect_SelectSignature) selsign;
3204 Standard_Integer debsign = np+1;
3206 DeclareAndCast(IFSelect_Signature,sign,item);
3207 DeclareAndCast(IFSelect_SignCounter,cnt,item);
3208 if (!sign.IsNull()) selsign =
3209 new IFSelect_SelectSignature (sign,&nomsel[debsign],Standard_False);
3210 else if (!cnt.IsNull()) selsign =
3211 new IFSelect_SelectSignature (cnt,&nomsel[debsign],Standard_False);
3213 cout<<selname<<" : neither Signature nor Counter"<<endl;
3217 selsign->SetInput (new IFSelect_SelectModelEntities); // par defaut
3221 else sel = GetCasted(IFSelect_Selection,item);
3227 //=======================================================================
3230 //=======================================================================
3232 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveList
3233 (const Handle(Standard_Transient)& obj) const
3236 DeclareAndCast(TColStd_HSequenceOfTransient,list,obj);
3237 if (!list.IsNull()) return list;
3239 // Rien du tout : retourne rien du tout
3240 if (obj.IsNull()) return list;
3242 // Une selection : son resultat (standard)
3243 DeclareAndCast(IFSelect_Selection,sel,obj);
3244 if (!sel.IsNull()) {
3245 Interface_EntityIterator iter = EvalSelection(sel);
3246 return iter.Content();
3249 // Le modele : son contenu
3250 list = new TColStd_HSequenceOfTransient();
3251 if (obj == themodel) {
3252 Standard_Integer i, nb = themodel->NbEntities();
3253 for (i = 1; i <= nb; i ++) list->Append (themodel->Value(i));
3256 // Une entite du modele : cette entite
3257 else if (StartingNumber(obj) > 0) list->Append (obj);
3259 // Un Texte : son interpretation
3261 DeclareAndCast(TCollection_HAsciiString,str,obj);
3262 if (!str.IsNull()) return GiveList (str->ToCString());
3265 // Si c est pas tout ca : une liste vide
3270 //=======================================================================
3273 //=======================================================================
3275 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveList
3276 (const Standard_CString first, const Standard_CString second) const
3278 Handle(TColStd_HSequenceOfTransient) list;
3279 if (!first || first[0] == '\0') return list;
3280 if (first[0] == ' ') return GiveList (&first[1],second);
3281 if (second && second[0] == ' ') return GiveList (first,&second[1]);
3283 // list NULLE sera interpretee comme SelectionResult (selection toute crue)
3284 // sinon comme SelectionResultFromList
3285 if (second && second[0] != '\0') list = GiveList (second,"");
3287 list = GiveListFromList (first,list);
3292 //=======================================================================
3295 //=======================================================================
3297 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveListFromList
3298 (const Standard_CString selname, const Handle(Standard_Transient)& ent) const
3300 Handle(TColStd_HSequenceOfTransient) list;
3301 Standard_Integer num;
3303 // LISTE DEFINIE D OFFICE (en ce cas, la liste d entree est ignoree)
3304 if (selname[0] == '(') {
3305 // liste d entites donnees a la queue leu leu : (ID,ID,ID...)
3306 char entid[50]; Standard_Integer i,j = 0;
3307 TColStd_MapOfInteger numap;
3308 list = new TColStd_HSequenceOfTransient();
3309 for (i = 1; selname[i] != '\0'; i ++) {
3310 if (selname[i] == ' ') continue;
3311 if (selname[i] == ',' || selname[i] == ')') {
3313 if (j == 0) continue; j = 0;
3314 num = NumberFromLabel (entid);
3315 if (num <= 0 || !numap.Add (num)) continue;
3316 Handle(Standard_Transient) anent = StartingEntity(num);
3317 if (!anent.IsNull()) list->Append (anent);
3318 if (selname[i] == ')') break;
3321 entid[j] = selname[i]; j ++;
3325 num = NumberFromLabel (selname);
3326 if (num > 0) return GiveList(StartingEntity(num));
3328 // Autres cas : y atil une liste d entree.
3329 // Si OUI -> SelectionResultFromList. Si NON -> SelectionResult
3330 // Si une entite isolee -> on en fait une liste
3332 list = GiveList(ent); // ent NULL -> list NULL sinon intreprete
3334 // Decomposition term1 term2 ...
3336 char nomsel[500]; nomsel[0] = '\0';
3337 Standard_Integer n= 0 , nb = -1;
3338 for (n = 0; selname[n] != '\0'; n ++) {
3339 nomsel[n] = selname[n]; nomsel[n+1] = '\0';
3340 // if (selname[n] == '(') { np = n; nivp ++; }
3341 // if (selname[n] == ')') { nivp --; if (nivp <= 0) nf = n; }
3342 if (selname[n] == ' ') { nb = n; nomsel[n] = '\0'; break; }
3344 if (nomsel[0] == '\0') return list;
3346 Handle(IFSelect_Selection) sel = GiveSelection (nomsel);
3348 cout<<"Neither Entity Number/Label nor Selection :"<<nomsel<<endl;
3352 if (nb > 0) list = GiveListFromList (&selname[nb+1],list);
3354 if (list.IsNull()) list = SelectionResult (sel);
3355 else list = SelectionResultFromList (sel,list);
3361 //=======================================================================
3364 //=======================================================================
3366 Handle(TColStd_HSequenceOfTransient) IFSelect_WorkSession::GiveListCombined
3367 (const Handle(TColStd_HSequenceOfTransient)& l1,
3368 const Handle(TColStd_HSequenceOfTransient)& l2,
3369 const Standard_Integer mode) const
3371 Handle(TColStd_HSequenceOfTransient) list;
3372 if (l1.IsNull() || l2.IsNull()) return list;
3374 // mode < 0 l1-l2 = 0 l1&l2 > 0 l1|l2 (l1+l2)
3375 TColStd_MapOfTransient numap;
3376 Standard_Integer i,n = l2->Length();
3377 for (i = n; i > 0; i --) {
3378 Handle(Standard_Transient) ent = l2->Value(i);
3379 if (ent.IsNull()) continue;
3381 if (mode > 0) list->Append(ent);
3384 // ents de l1 pas deja dans l2
3386 for (i = n; i > 0; i --) {
3387 Handle(Standard_Transient) ent = l1->Value(i);
3388 if (ent.IsNull()) continue;
3390 if (numap.Contains(ent)) {
3391 // dans l1 et dans l2
3392 if (mode == 0) list->Append(ent);
3394 // dans l1 mais pas dans l2
3395 if (mode != 0) list->Append(ent);
3404 //=======================================================================
3407 //=======================================================================
3409 void IFSelect_WorkSession::DumpModel
3410 (const Standard_Integer level, const Handle(Message_Messenger)& S)
3413 { S<< " *** Data for List not available ***"<<endl; return; }
3414 S << "\n *****************************************************************\n";
3415 if (theloaded.Length() > 0)
3416 S << " ******** Loaded File : "<<theloaded.ToCString()<<Interface_MSG::Blanks(32-theloaded.Length())<<" ********"<<endl;
3417 else S << " ******** No name for Loaded File"<<endl;
3419 S<<" ******** Short Dump of Header ********"<<"\n";
3420 S << " *****************************************************************\n\n";
3421 themodel->DumpHeader(S); S<<endl;
3424 Standard_Integer nbent = themodel->NbEntities();
3425 Standard_Integer nbr = 0;
3426 Interface_ShareFlags shar(thegraph->Graph());
3428 for (Standard_Integer i = 1; i <= nbent; i ++) {
3429 if (!shar.IsShared(themodel->Value(i))) nbr ++;
3431 S << " *****************************************************************\n";
3432 S << " ******** Model : "<<nbent<<" Entities, of which "<<nbr<<" Root(s)"<<"\n";
3433 S << " *****************************************************************\n"<<endl;
3435 if (level <= 0) return;
3436 else if (level == 1) {
3437 S<<" ******** Root Entities ******** ";
3438 ListEntities (shar.RootEntities(),1);
3439 } else if (level == 2) {
3440 S<<" ******** Complete List ******** ";
3441 ListEntities (themodel->Entities(),1);
3442 } else if (level > 2) {
3443 IFSelect_PrintCount mode = IFSelect_ItemsByEntity;
3444 if (level == 5 || level == 8) mode = IFSelect_CountByItem;
3445 if (level == 6 || level == 9) mode = IFSelect_ListByItem;
3446 if (level == 7 || level == 10) mode = IFSelect_EntitiesByItem;
3447 Standard_Boolean failsonly = Standard_False;
3448 if (level < 8 && level != 4) failsonly = Standard_True;
3449 PrintCheckList (ModelCheckList(),Standard_False, mode);
3451 if (level == 3) S << " ******** Check Model (Fails) ********"<<endl;
3452 else S << " ******** Check Model (Complete) ********"<<endl;
3453 Interface_CheckTool CT (Graph());
3454 Interface_CheckIterator C;
3458 if (level == 3) C = CT.CheckList();
3459 else C = CT.CompleteCheckList();
3461 catch (Standard_Failure) {
3462 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3463 sout<<" **** Interruption DumpModel (Check) par Exception ****\n";
3464 S<<" ** ** Exception Raised during Check ! ** **\n";
3465 S<<" --> what could be determined is listed"<<endl;
3468 else if (level == 3) C = CT.CheckList();
3469 else C = CT.CompleteCheckList();
3471 // Check List : si vide (pas demandee), naturellement passee
3474 C.Print(S,themodel, (level == 3));
3476 catch (Standard_Failure) {
3477 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3478 sout<<" **** Interruption DumpModel par Exception : ****\n";
3479 sout<<Standard_Failure::Caught()->GetMessageString();
3480 sout<<"\n Abandon"<<endl;
3484 S<<endl<<"There are "<<nbent<<" Entities, of which "<<nbr<<" Root(s)"<<endl;
3487 // .... TraceDumpModel .... (Model + CheckList)
3489 //=======================================================================
3492 //=======================================================================
3494 void IFSelect_WorkSession::TraceDumpModel
3495 (const Standard_Integer mode)
3497 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3498 DumpModel (mode,sout);
3499 // if (mode <= 4) { DumpModel (mode,sout); return; }
3501 // else if (mode <= 7) PrintCheckList (ModelCheckList(),Standard_False, mode-5);
3502 // else if (mode <=10) PrintCheckList (ModelCheckList(),Standard_True , mode-8);
3505 // .... DumpEntity ....
3507 //=======================================================================
3510 //=======================================================================
3512 void IFSelect_WorkSession::DumpEntity
3513 (const Handle(Standard_Transient)& ent, const Standard_Integer level,
3514 const Handle(Message_Messenger)& S) const
3517 { S<< " *** Data for List not available ***"<<endl; return; }
3518 Standard_Integer num = themodel->Number(ent);
3519 if (num == 0) { S<<" *** Entity to Dump not in the Model ***"<<endl; return; }
3520 if (thelibrary.IsNull()) { S<<" *** WorkLibrary not defined ***"<<endl; return; }
3521 S << " ******** Dumping Entity n0 "<<num
3522 <<" level:"<<level<<" ********"<<endl;
3523 thelibrary->DumpEntity (themodel,theprotocol,ent,S,level);
3526 // .... DumpEntity ....
3528 //=======================================================================
3531 //=======================================================================
3533 void IFSelect_WorkSession::TraceDumpEntity
3534 (const Handle(Standard_Transient)& ent, const Standard_Integer level) const
3536 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3537 DumpEntity (ent,level,sout);
3540 // .... PrintEntityStatus ....
3542 //=======================================================================
3545 //=======================================================================
3547 void IFSelect_WorkSession::PrintEntityStatus
3548 (const Handle(Standard_Transient)& ent, const Handle(Message_Messenger)& S)
3550 Standard_Integer i,nb;
3551 Standard_Integer num = StartingNumber(ent);
3552 if (num == 0) { cout<<" -- PrintEntityStatus : unknown"<<endl; return; }
3554 S <<" Ent. n0/id: ";
3555 Model()->Print(ent,S);
3556 Handle(TCollection_HAsciiString) hname = EntityName(ent);
3557 if (!hname.IsNull() && hname->Length() > 0) S<<" Name:"<<hname->ToCString();
3559 Handle(IFSelect_Signature) signtype = SignType();
3560 if (signtype.IsNull()) S<<" Type(CDL):"<<ent->DynamicType()->Name()<<endl;
3561 else S <<" Type:"<<signtype->Value (ent,Model())<<endl;
3562 S <<" Category : " <<CategoryName (ent)
3563 <<" Validity : " <<ValidityName (ent) << endl;
3564 Interface_CheckIterator chl = CheckOne (ent);
3565 chl.Print (S,Model(),Standard_False,Standard_False);
3567 Handle(TColStd_HSequenceOfTransient) list = Sharings(ent);
3568 if (list.IsNull()) S<<" Root"<<endl;
3570 nb = list->Length();
3571 if (nb == 0) S<<" Root";
3572 else S<<" Super-entities:"<<nb<<" : (n0/id):";
3573 for (i = 1; i <= nb; i ++) { S<<" "; Model()->Print(list->Value(i),S); }
3576 list = Shareds (ent);
3577 if (list.IsNull()) S<<" No sub-entity"<<endl;
3579 nb = list->Length();
3580 if (nb == 0) S<<" No sub-entity";
3581 else S<<" Sub-entities:"<<nb<<" , i.e. (n0/id):";
3582 for (i = 1; i <= nb; i ++) { S<<" "; Model()->Print(list->Value(i),S); }
3587 // .... PrintCheckList ....
3589 //=======================================================================
3592 //=======================================================================
3594 void IFSelect_WorkSession::PrintCheckList
3595 (const Interface_CheckIterator& checklist,
3596 const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const
3598 // mode : 0 comptage 1 n0s entites 2 n0s+id ents
3599 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3600 if (mode == IFSelect_ItemsByEntity) checklist.Print (sout,themodel,failsonly);
3602 Interface_CheckIterator chks = checklist;
3603 Handle(IFSelect_CheckCounter) counter =
3604 new IFSelect_CheckCounter (mode>1 && mode != IFSelect_CountSummary);
3605 counter->Analyse (chks,themodel,Standard_False,failsonly);
3606 counter->PrintList (sout,themodel,mode);
3610 // .... PrintSignatureList ....
3612 //=======================================================================
3615 //=======================================================================
3617 void IFSelect_WorkSession::PrintSignatureList
3618 (const Handle(IFSelect_SignatureList)& signlist,
3619 const IFSelect_PrintCount mode) const
3621 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3622 if (signlist.IsNull()) return;
3623 signlist->PrintList (sout,themodel,mode);
3626 // #### #### #### #### #### #### #### #### ####
3627 // .... EvaluateSelection ....
3629 //=======================================================================
3632 //=======================================================================
3634 void IFSelect_WorkSession::EvaluateSelection
3635 (const Handle(IFSelect_Selection)& sel) const
3637 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3639 errhand = Standard_False;
3642 EvaluateSelection(sel); // appel normal (->code unique)
3644 catch (Standard_Failure) {
3645 sout<<" **** Interruption EvaluateSelection par Exception **** Intitule\n";
3646 sout<<Standard_Failure::Caught()->GetMessageString();
3647 sout<<"\n Abandon"<<endl;
3649 errhand = theerrhand;
3654 { sout<< " *** Data for Evaluation not available ***"<<endl; return; }
3655 if (ItemIdent(sel) == 0)
3656 { sout << " Selection : "<<" Unknown"<<endl; return; } //sout<<Handle
3657 Interface_EntityIterator iter = EvalSelection (sel);
3658 ListEntities (iter,1);
3659 sout << "**** (Unique) RootResult, Selection : "
3660 <<sel->Label()<<endl;
3664 // #### #### #### #### #### #### #### #### ####
3665 // .... EvaluateDispatch ....
3667 //=======================================================================
3670 //=======================================================================
3672 void IFSelect_WorkSession::EvaluateDispatch
3673 (const Handle(IFSelect_Dispatch)& disp, const Standard_Integer mode) const
3675 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3677 errhand = Standard_False;
3680 EvaluateDispatch(disp,mode); // appel normal (->code unique)
3682 catch (Standard_Failure) {
3683 sout<<" **** Interruption EvaluateDispatch par Exception **** Intitule\n";
3684 sout<<Standard_Failure::Caught()->GetMessageString();
3685 sout<<"\n Abandon"<<endl;
3687 errhand = theerrhand;
3691 Standard_Integer numdisp = DispatchRank(disp);
3693 { sout<< " *** Data for List not available ***"<<endl; return; }
3694 if (theshareout->NbDispatches() < numdisp || numdisp <= 0)
3695 { sout<<"Dispatch : "<<" Unknown"<<endl; return; } //sout<<Handle
3696 if (disp->FinalSelection().IsNull())
3697 { sout<<"Dispatch "<<" : No Final Selection"<<endl; return; }//sout<<Handle
3698 sout<<" --- Dispatch Label : "<<disp->Label()<<endl;
3700 IFSelect_ShareOutResult eval(disp,thegraph->Graph());
3702 Standard_Integer numpack = 0;
3703 Handle(IFSelect_PacketList) evres =
3704 eval.Packets (mode ? Standard_True : Standard_False);
3705 Standard_Integer nbpack = evres->NbPackets();
3707 sout<<"Nb Packets produced : "<<nbpack<<" :"<<endl;
3708 for (numpack = 1; numpack <= nbpack; numpack ++) {
3709 sout<<"\n **** Packet n0 : "<<numpack<<" ****"<<endl;
3710 if (!mode) cout<<"Root Entities :"<<endl;
3711 ListEntities (evres->Entities(numpack), (mode ? 2 : -1));
3714 //// Interface_EntityIterator iterem = disp->Remainder(thegraph->Graph());
3715 if (mode == 0) return;
3716 if (mode == 1 || mode == 3) {
3718 if (evres->NbDuplicated(0,Standard_False) == 0)
3719 sout<<" **** All the Model is taken into account ****"<<endl;
3721 sout<<" **** Starting Entities not taken by this Dispatch ****"<<endl;
3722 ListEntities (evres->Duplicated(0,Standard_False),2);
3726 sout<<" **** Entites in more than one packet ****";
3727 Standard_Integer max = evres->HighestDuplicationCount();
3728 if (max < 2) sout<<" : There are none"<<endl;
3730 Standard_Integer newcount;
3732 for (newcount = 2; newcount <= max; newcount ++) {
3733 if (evres->NbDuplicated(newcount,Standard_False) == 0) continue;
3734 sout<<" **** Entities put in "<<newcount<<" packets ****"<<endl;
3735 ListEntities (evres->Duplicated(newcount,Standard_False),2);
3742 // #### #### #### #### #### #### #### #### ####
3743 // .... EvaluateComplete ....
3745 //=======================================================================
3748 //=======================================================================
3750 void IFSelect_WorkSession::EvaluateComplete
3751 (const Standard_Integer mode) const
3753 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3755 errhand = Standard_False;
3758 EvaluateComplete(mode); // appel normal (donc, code pas duplique)
3760 catch (Standard_Failure) {
3761 sout<<" **** Interruption EvaluateComplete par Exception : ****\n";
3762 sout<<Standard_Failure::Caught()->GetMessageString();
3763 sout<<"\n Abandon"<<endl;
3765 errhand = theerrhand;
3770 { sout<< " *** Data for List not available ***"<<endl; return; }
3771 IFSelect_ShareOutResult eval(theshareout,thegraph->Graph());
3773 sout<<"\n******** Evaluation ShareOutResult (Complete) ********\n";
3774 sout<<" **** List of Packets **** Count : "<<eval.NbPackets()<<endl;
3775 if (mode == 0) sout << " ** (for each one : Root Entities) **"<<endl;
3776 else sout << " ** (for each one : Evaluated Content) **"<<endl;
3778 Standard_Integer numpack = 0;
3779 Handle(IFSelect_PacketList) evres =
3780 eval.Packets (mode ? Standard_True : Standard_False);
3781 Standard_Integer nbpack = evres->NbPackets();
3783 sout<<"Nb Packets produced : "<<nbpack<<" :"<<endl;
3784 for (numpack = 1; numpack <= nbpack; numpack ++) {
3785 sout<<"\n **** Packet n0 : "<<numpack<<" ****"<<endl;
3786 if (!mode) cout<<"Root Entities :"<<endl;
3787 ListEntities (evres->Entities(numpack), (mode ? 2: -1));
3789 if (mode == 0) return;
3790 if (mode == 1 || mode == 3) {
3792 if (evres->NbDuplicated(0,Standard_False) == 0)
3793 sout<<" **** All the Model is taken into account ****"<<endl;
3795 sout<<" **** Starting Entities Forgotten ****"<<endl;
3796 ListEntities (evres->Duplicated(0,Standard_False),2);
3800 sout<<" **** Entites in more than one packet ****"<<endl;
3801 Standard_Integer max = evres->HighestDuplicationCount();
3802 if (max < 2) sout<<" : There are none"<<endl;
3804 Standard_Integer newcount;
3806 for (newcount = 2; newcount <= max; newcount ++) {
3807 if (evres->NbDuplicated(newcount,Standard_False) == 0) continue;
3808 sout<<" **** Entities put in "<<newcount<<" packets ****"<<endl;
3809 ListEntities (evres->Duplicated(newcount,Standard_False),2);
3816 // #### #### #### #### #### #### #### #### ####
3817 // .... Routine Interne : ListEntities
3819 //=======================================================================
3822 //=======================================================================
3824 void IFSelect_WorkSession::ListEntities
3825 (const Interface_EntityIterator& iter, const Standard_Integer mmode) const
3827 Handle(Message_Messenger) sout = Message::DefaultMessenger();
3829 Standard_Integer mode = (mmode < 0 ? -mmode : mmode);
3830 if (mmode >= 0) sout << " List of " << iter.NbEntities() << " Entities :"<<endl;
3832 { sout<< " *** Data for List not available ***"<<endl; return; }
3833 Interface_ShareFlags tool(thegraph->Graph());
3837 int newcount = -1; int mods = 0; int cnt = 0;
3838 for (iter.Start(); iter.More(); iter.Next()) {
3839 if (!titre && mode == 1) sout
3840 << "Number/Id. Category Validity Type\n----------- ----...."<<endl;
3841 // 123456789 123456789 123456 123456789 123456789 123456
3842 if (!titre && mode == 0) sout<<" Keys : R Root ? Unknown * Unloaded"<<endl;
3843 if (!titre && mode == 2) sout<<"(";
3845 Handle(Standard_Transient) ent = iter.Value();
3846 Standard_Integer num = themodel->Number(ent);
3848 // n0 id (root?) category validity tracetype
3849 sout<<Interface_MSG::Blanks (num,6);
3850 themodel->Print(ent,sout,0);
3851 if (!tool.IsShared(ent)) sout << " #ROOT#";
3853 Standard_Integer catnum = themodel->CategoryNumber(num);
3854 if (catnum > 0) sout<<" "<<Interface_Category::Name (catnum);
3855 sout << " (" << ValidityName (ent) << ") ";
3857 sout<<" Type:"<<themodel->TypeName (ent, Standard_False);
3858 // Handle(Interface_GeneralModule) tracemod;
3859 // Standard_Integer CN;
3860 // if (thegtool->Select(ent,tracemod,CN))tracemod->TraceType(ent,CN,sout);
3861 // else sout << "(Not in Protocol) " << ent->DynamicType();
3863 } else if (mode == 2) {
3865 if (newcount > 0) sout<<",";
3868 newcount ++; mods = 0; cnt ++;
3869 if (newcount >= 10) { sout << endl<<"["<<cnt<<"]:"; newcount = 1; }
3870 if (newcount > 0) sout << " ";
3871 themodel->Print(ent,sout,0);
3872 if (!tool.IsShared(ent)) { if(mods == 0) sout<<"("; sout<<"R"; mods++; }
3873 if (themodel->IsUnknownEntity(num)) { sout<<(mods==0 ? '(' : ' ')<<"?"; mods ++; }
3874 if (themodel->IsRedefinedContent(num)) { sout<<(mods==0 ? '(' : ' ')<<"*"; mods ++; }
3875 if (mods) { sout<<")"; newcount ++; }
3878 if (mode == 0) sout<<endl;
3879 if (mode == 2) sout<<")"<<endl;
3881 catch (Standard_Failure) {
3882 sout<<" **** Interruption ListEntities par Exception : ****\n";
3883 sout<<Standard_Failure::Caught()->GetMessageString();
3884 sout<<"\n Abandon"<<endl;