0030895: Coding Rules - specify std namespace explicitly for std::cout and streams
[occt.git] / src / Transfer / Transfer_TransferProcess.gxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 // DCE 21.01.99 S3767 Display original messages only 
15 //       if the level is greater than 2
16
17 //#include <Transfer_TransferProcess.ixx>
18 //  Class generique
19
20 //  TheStart est suppose Handle(Standard_Transient) ou (Transfer_Finder)
21 //  Il doit offrir : "==" , .IsNull() , ->DynamicType()
22
23 #include <Standard_ErrorHandler.hxx>
24 #include <Standard_Failure.hxx>
25
26 #include <Message_Messenger.hxx>
27 #include <Message_Msg.hxx>
28 #include <Message.hxx>
29
30 #include <Transfer_VoidBinder.hxx>
31 #include <Transfer_SimpleBinderOfTransient.hxx>
32 #include <Transfer_MultipleBinder.hxx>
33 #include <Transfer_StatusResult.hxx>
34 #include <Transfer_TransferFailure.hxx>
35 #include <Transfer_TransferDeadLoop.hxx>
36
37 #include <TCollection_HAsciiString.hxx>
38 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
39 #include <TColStd_Array1OfInteger.hxx>
40 #include <TColStd_HArray1OfInteger.hxx>
41
42
43 //#define TRANSLOG   // debug
44
45 static Handle(Standard_Transient)  nultrans;   // pour retour const&(Null) ...
46 static Handle(Transfer_Binder)     nulbinder;
47
48
49 //=======================================================================
50 //function : Transfer_TransferProcess
51 //purpose  : 
52 //=======================================================================
53
54 Transfer_TransferProcess::Transfer_TransferProcess (const Standard_Integer nb)
55       : themap (nb)
56 {
57   theerrh  = Standard_True;
58   therootm = Standard_False;
59   thelevel = 0;     therootl  = 0;
60   themessenger = Message::DefaultMessenger();
61   thetrace = 0;
62 //  theroots = new TColStd_HSequenceOfInteger ();
63   theindex = 0;
64 }
65
66
67 //=======================================================================
68 //function : Transfer_TransferProcess
69 //purpose  : 
70 //=======================================================================
71
72 Transfer_TransferProcess::Transfer_TransferProcess(const Handle(Message_Messenger)& messenger,
73                                                    const Standard_Integer nb)
74      : themap (nb)
75 {
76   theerrh  = Standard_True;
77   therootm = Standard_False;
78   thelevel = 0;     therootl  = 0;
79   SetMessenger (messenger);
80   thetrace = 1;
81 //  theroots = new TColStd_HSequenceOfInteger ();
82   theindex = 0;
83 }
84
85     void Transfer_TransferProcess::Clear ()
86 {
87   thelevel = 0;     therootl  = 0;
88   theroots.Clear();
89   themap.Clear();
90   theindex = 0;  thelastobj.Nullify();  thelastbnd.Nullify();
91 }
92
93     void Transfer_TransferProcess::Clean ()
94 {
95   Standard_Integer i, nb = NbMapped();
96   Standard_Integer j,unb = 0;
97   for (i = 1; i <= nb; i ++) {
98     if (themap(i).IsNull()) unb ++;
99   }
100   if (unb == 0) return;
101
102 //   Refaire la map -> decalages
103   TColStd_Array1OfInteger unbs (1,nb);  unbs.Init(0);
104   Transfer_TransferMap newmap (nb*2);
105   for (i = 1; i <= nb; i ++) {
106     TheStart ent = Mapped(i);
107     Handle(Transfer_Binder) bnd = MapItem(i);
108     if (bnd.IsNull()) continue;
109     j = newmap.Add (ent,bnd);
110     unbs.SetValue (i,j);
111   }
112   themap.Assign (newmap);
113
114   // Update   La liste des racines
115   TColStd_IndexedMapOfInteger aNewRoots;
116   for( i=1; i<= theroots.Extent(); i++ ) {
117     j = theroots.FindKey(i);
118     Standard_Integer k = unbs.Value(j);
119     if ( k ) aNewRoots.Add ( k );
120   }
121   theroots.Clear();
122   theroots = aNewRoots;
123
124 //    Le reste : nettoyage
125   thelastobj.Nullify();
126   thelastbnd.Nullify();
127   theindex = 0;
128 }
129
130
131 //=======================================================================
132 //function : Resize
133 //purpose  : 
134 //=======================================================================
135
136 void Transfer_TransferProcess::Resize (const Standard_Integer nb)
137 {
138   if (nb > themap.NbBuckets()) themap.ReSize(nb);
139 }
140
141
142 //=======================================================================
143 //function : SetActor
144 //purpose  : 
145 //=======================================================================
146
147 void  Transfer_TransferProcess::SetActor(const Handle(Transfer_Actor)& actor)
148 {
149   if (theactor == actor)         return;
150   if (theactor.IsNull())         theactor = actor;
151   else if (actor.IsNull())       theactor = actor;  // declenche RAZ
152   else if (theactor->IsLast()) { actor->SetNext(theactor);  theactor = actor; }
153   else                           theactor->SetNext(actor);
154 }
155
156
157 //=======================================================================
158 //function : Actor
159 //purpose  : 
160 //=======================================================================
161
162 Handle(Transfer_Actor)  Transfer_TransferProcess::Actor () const 
163 {
164   return theactor;
165 }
166
167
168 //  ########################################################################
169 //  ....                             MAPPING                            ....
170
171 //  ##    ##    ##       Actions Generales sur Binders       ##    ##    ##
172 //  ##    ##    ##               Consultations               ##    ##    ##
173
174
175 //        ##    ##    Find    ##    ##
176
177 //=======================================================================
178 //function : Find
179 //purpose  : 
180 //=======================================================================
181
182 Handle(Transfer_Binder) Transfer_TransferProcess::Find (const TheStart& start) const
183 //                                                       const Standard_Integer categ) const
184 {
185   if (thelastobj == start) {
186     //if (theindex > 0) return thelastbnd->Search(categ); //skl
187     if (theindex > 0) return thelastbnd; //skl
188   }
189   Standard_Integer index = themap.FindIndex (start);
190   if (index > 0) {
191     const Handle(Transfer_Binder)& binder = themap.FindFromIndex(index);
192     //if (binder.IsNull()) //skl
193     return binder;
194     //return binder->Search(categ); //skl
195   }
196   return nulbinder;
197 }
198
199 //        ##    ##    IsBound    ##    ##
200
201 //=======================================================================
202 //function : IsBound
203 //purpose  : 
204 //=======================================================================
205
206 Standard_Boolean  Transfer_TransferProcess::IsBound(const TheStart& start) const
207 //                                                  const Standard_Integer categ) const
208 {
209   Handle(Transfer_Binder) binder = Find(start); //,categ); skl
210   if (binder.IsNull()) return Standard_False;
211   return binder->HasResult();
212 }
213
214 //        ##    ##    IsAlreadyUsed    ##    ##
215
216 //=======================================================================
217 //function : IsAlreadyUsed
218 //purpose  : 
219 //=======================================================================
220
221 Standard_Boolean Transfer_TransferProcess::IsAlreadyUsed(const TheStart& start) const
222 //                                                       const Standard_Integer categ) const
223 {
224   Handle(Transfer_Binder) binder = Find(start); //,categ); skl
225   if (binder.IsNull()) {
226     StartTrace (binder,start,thelevel,4);
227     throw Transfer_TransferFailure("TransferProcess : IsAlreadyUsed, transfer not done cannot be used...");
228   }
229   return (binder->Status() == Transfer_StatusUsed);
230 }
231
232
233 //        ##    ##    FindAndMask (private)    ##    ##
234
235 //=======================================================================
236 //function : FindAndMask
237 //purpose  : 
238 //=======================================================================
239
240 Handle(Transfer_Binder) Transfer_TransferProcess::FindAndMask(const TheStart& start)
241 //                                                            const Standard_Integer categ)
242 {
243   if (thelastobj == start) {
244     if (theindex > 0) return thelastbnd; //skl ->Search(categ);
245   }
246   thelastobj = start;
247   theindex   = themap.FindIndex (start);
248   if (theindex > 0) thelastbnd = themap.FindFromIndex(theindex);
249   else thelastbnd.Nullify();
250   //if (thelastbnd.IsNull()) skl
251   return thelastbnd;
252   //return thelastbnd->Search(categ); //skl
253 }
254
255
256 //  ##    ##    ##               Modifications               ##    ##    ##
257
258
259 //=======================================================================
260 //function : Bind
261 //purpose  : 
262 //=======================================================================
263
264 void Transfer_TransferProcess::Bind (const TheStart& start,
265                                      const Handle(Transfer_Binder)& binder)
266 //                                    const Standard_Integer categ)
267 {
268   if (binder.IsNull()) return;
269   Handle(Transfer_Binder) former = FindAndMask(start);//,categ);skl
270   if (!former.IsNull()) {
271 //  On admet VoidBinder : alors on reprend son Check
272     if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) {
273       binder->Merge(former);
274       //binder->SetCategory(categ); //skl
275       themap(theindex) = binder;                          // Substitution
276     }
277     else if (former->Status() == Transfer_StatusUsed) {
278       StartTrace (former,start,thelevel,4);
279       throw Transfer_TransferFailure("TransferProcess : Bind, already Bound");
280     }
281     else {
282       if (thetrace > 2) StartTrace (former,start,thelevel,5);
283       binder->CCheck()->GetMessages (former->Check());
284     }
285   }
286   //binder->SetCategory(categ); //skl
287   if (theindex == 0 || thelastbnd.IsNull()) {
288     if (theindex == 0) theindex = themap.Add(start,binder);  // Nouveau
289     else themap(theindex) = binder;                          // idem en fait
290     thelastbnd = binder;
291   }
292   else { //skl
293     //binder->AddResult(thelastbnd);
294     thelastbnd  = binder;
295     themap(theindex) = binder;
296   }
297 /*skl else if (thelastbnd->Category() == categ) {   // Substitue cette categorie
298     binder->Next(Standard_False)->SetNext(thelastbnd->Next(Standard_True),Standard_True);
299     thelastbnd  = binder;
300     themap(theindex) = binder;
301   } else {
302     thelastbnd->AddNext (binder,categ,Standard_True);
303   } */
304 }
305
306
307 //=======================================================================
308 //function : Rebind
309 //purpose  : 
310 //=======================================================================
311
312 void  Transfer_TransferProcess::Rebind (const TheStart& start,
313                                         const Handle(Transfer_Binder)& binder)
314 //                                      const Standard_Integer categ)
315 {
316   Bind(start,binder); //,categ);skl
317   // entre les deux, les differences allaient s amenuisant
318   //  au debut, on criait si pas encore Bound (idiot)
319   //  ne restait plus comme difference que le test StatusUsed sur Rebind,
320   //    tandis que Bind refusait des lors qu il y avait un resultat
321   //  -> a present, Bind s aligne sur Rebind
322 }
323
324
325 //=======================================================================
326 //function : Unbind
327 //purpose  : 
328 //=======================================================================
329
330 Standard_Boolean Transfer_TransferProcess::Unbind(const TheStart& start)
331 //                                                 const Standard_Integer categ)
332 {
333   Handle(Transfer_Binder) former = FindAndMask(start);//,categ);skl
334   if (theindex == 0) return Standard_False;
335   if (former.IsNull()) return Standard_False;
336   if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) return Standard_True;
337   //const Interface_Check& ach = thelastbnd->Check();
338   //Handle(Transfer_Binder) newbinder = thelastbnd->RemoveNext(categ);skl
339   //if (newbinder != thelastbnd)skl
340     themap(theindex) = thelastbnd;// = newbinder;skl
341   if(theroots.Contains(theindex)) {
342     TColStd_IndexedMapOfInteger aNewRoots;
343     for(Standard_Integer i = 1; i <= theroots.Extent(); i++)
344       if(theindex!= theroots.FindKey(i))
345         aNewRoots.Add(theroots.FindKey(i));
346     
347     theroots.Clear();
348     theroots = aNewRoots;
349   }
350
351   thelastobj.Nullify();
352   thelastbnd.Nullify();
353   theindex = 0;
354   return Standard_True;
355 }
356
357
358 //=======================================================================
359 //function : FindElseBind
360 //purpose  : 
361 //=======================================================================
362
363 Handle(Transfer_Binder) Transfer_TransferProcess::FindElseBind(const TheStart& start)
364 //                                                             const Standard_Integer categ)
365 {
366   Handle(Transfer_Binder) binder = FindAndMask (start);//,categ);skl
367   if (!binder.IsNull()) return binder;
368   binder = new Transfer_VoidBinder;
369   Bind(start,binder);//,categ);skl
370   return binder;
371 }
372
373
374 //  ##    ##    ##              Messages associes              ##    ##    ##
375
376 //=======================================================================
377 //function : SetMessenger
378 //purpose  : 
379 //=======================================================================
380
381 void Transfer_TransferProcess::SetMessenger (const Handle(Message_Messenger)& messenger)
382 {
383   if ( messenger.IsNull() )
384     themessenger = Message::DefaultMessenger();
385   else   
386     themessenger = messenger;
387 }
388
389 //=======================================================================
390 //function : Messenger
391 //purpose  : 
392 //=======================================================================
393
394 Handle(Message_Messenger) Transfer_TransferProcess::Messenger () const
395 {
396   return themessenger;
397 }
398
399 //=======================================================================
400 //function : SetTraceLevel
401 //purpose  : 
402 //=======================================================================
403
404 void Transfer_TransferProcess::SetTraceLevel (const Standard_Integer tracelev)
405 {
406   thetrace = tracelev;
407 }
408
409 //=======================================================================
410 //function : TraceLevel
411 //purpose  : 
412 //=======================================================================
413
414 Standard_Integer Transfer_TransferProcess::TraceLevel () const
415 {
416   return thetrace;
417 }
418
419 //=======================================================================
420 //function : SendFail
421 //purpose  : 
422 //=======================================================================
423
424 void  Transfer_TransferProcess::SendFail(const TheStart& start,
425                                          const Message_Msg& amsg)
426 {
427   AddFail(start,amsg);
428 }
429
430
431 //=======================================================================
432 //function : SendWarning
433 //purpose  : 
434 //=======================================================================
435
436 void  Transfer_TransferProcess::SendWarning(const TheStart& start,
437                                             const Message_Msg& amsg)
438 {
439   AddWarning(start,amsg);
440 }
441
442
443 //=======================================================================
444 //function : SendMsg
445 //purpose  : 
446 //=======================================================================
447
448 void  Transfer_TransferProcess::SendMsg(const TheStart& start,
449                                         const Message_Msg& amsg)
450 {
451   Handle(Transfer_Binder) binder = FindAndMask(start);
452   if (binder.IsNull()) {
453     binder = new Transfer_VoidBinder;
454     Bind (start,binder);
455   }
456   // Alimente la trace : Regle causant (user messages)
457   if (thetrace > 0) {
458     StartTrace (binder,start,thelevel,6);
459     themessenger << amsg.Value();
460     if (amsg.IsEdited()&&thetrace>2)
461       themessenger << " [from: " << amsg.Original() << "]";
462     themessenger << Message_EndLine;
463   }
464 }
465
466
467 //=======================================================================
468 //function : AddFail
469 //purpose  : 
470 //=======================================================================
471
472 void Transfer_TransferProcess::AddFail(const TheStart& start,
473                                        const Standard_CString mess,
474                                        const Standard_CString orig)
475 {
476   Handle(Transfer_Binder) binder = FindAndMask(start);
477   if (binder.IsNull()) {
478     binder = new Transfer_VoidBinder;
479     Bind (start,binder);
480   }
481   binder->AddFail (mess,orig);
482   if (thetrace > 0) {
483     StartTrace (binder,start,thelevel,1);
484     themessenger << "    --> Fail : " << mess;
485     if (orig[0] != '\0'&&thetrace>2) themessenger << " [from: " << orig << "]";
486     themessenger << Message_EndLine;
487   }
488 }
489
490
491 //=======================================================================
492 //function : AddError
493 //purpose  : 
494 //=======================================================================
495
496 void Transfer_TransferProcess::AddError(const TheStart& start,
497                                         const Standard_CString mess,
498                                         const Standard_CString orig)
499 {
500   AddFail (start,mess,orig);
501 }
502
503
504 //=======================================================================
505 //function : AddFail
506 //purpose  : 
507 //=======================================================================
508
509 void Transfer_TransferProcess::AddFail(const TheStart& start,
510                                        const Message_Msg& amsg)
511 {
512   if (amsg.IsEdited()) AddFail (start,TCollection_AsciiString(amsg.Value()).ToCString(),
513                                 TCollection_AsciiString(amsg.Original()).ToCString());
514   else AddFail (start,TCollection_AsciiString(amsg.Value()).ToCString());
515 }
516
517
518 //=======================================================================
519 //function : AddWarning
520 //purpose  : 
521 //=======================================================================
522
523 void Transfer_TransferProcess::AddWarning(const TheStart& start,
524                                           const Standard_CString mess,
525                                           const Standard_CString orig)
526 {
527   Handle(Transfer_Binder) binder = FindAndMask(start);
528   if (binder.IsNull()) {
529     binder = new Transfer_VoidBinder;
530     Bind (start,binder);
531   }
532   binder->AddWarning(mess,orig);
533   if (thetrace > 1) {
534     StartTrace (binder,start,thelevel,2);
535     themessenger << "    --> Warning : " << mess;
536     if (orig[0] != '\0'&&thetrace>2) themessenger << " [from: " << orig << "]";
537     themessenger << Message_EndLine;
538   }
539 }
540
541
542 //=======================================================================
543 //function : AddWarning
544 //purpose  : 
545 //=======================================================================
546
547 void Transfer_TransferProcess::AddWarning(const TheStart& start,
548                                           const Message_Msg& amsg)
549 {
550   if (amsg.IsEdited()) AddWarning (start,TCollection_AsciiString(amsg.Value()).ToCString(),
551                                    TCollection_AsciiString(amsg.Original()).ToCString());
552   else AddWarning (start,TCollection_AsciiString(amsg.Value()).ToCString());
553 }
554
555
556 //=======================================================================
557 //function : Mend
558 //purpose  : 
559 //=======================================================================
560
561 void  Transfer_TransferProcess::Mend(const TheStart& start,
562                                      const Standard_CString pref)
563 {
564   Handle(Transfer_Binder) binder = FindAndMask(start);
565   if (binder.IsNull()) return;  // rien a faire ...
566   Handle(Interface_Check) ach =  binder->CCheck();
567   ach->Mend (pref);
568 }
569
570
571 //=======================================================================
572 //function : Check
573 //purpose  : 
574 //=======================================================================
575
576 Handle(Interface_Check) Transfer_TransferProcess::Check(const TheStart& start) const
577 {
578   const Handle(Transfer_Binder)& binder = Find(start);
579   if (binder.IsNull()) {
580     Handle(Interface_Check) check;
581     return check;
582   }
583   return binder->Check();
584 }
585
586 /*skl
587 void Transfer_TransferProcess::AddCaseName(const TheStart& start,
588                                            const Standard_CString casename)
589 {
590   AddCaseValue (start, new TCollection_HAsciiString (casename));
591 }
592
593
594 void Transfer_TransferProcess::AddCaseValue(const TheStart& start,
595                                             const Handle(Standard_Transient)& caseval)
596 {
597   Handle(Transfer_Binder) binder = FindAndMask(start);
598   if (binder.IsNull()) {
599     binder = new Transfer_VoidBinder;
600     Bind (start,binder);
601   }
602   binder->AddCaseValue (caseval);
603 }
604
605
606 Handle(TColStd_HSequenceOfTransient) Transfer_TransferProcess::CaseList
607        (const TheStart& start) const
608 {
609   Handle(TColStd_HSequenceOfTransient) list;
610   const Handle(Transfer_Binder)& binder = Find(start);
611   if (binder.IsNull()) return list;
612   return binder->CaseList();
613 }
614
615 Standard_Integer Transfer_TransferProcess::NextItemWithAttribute
616   (const Standard_CString name, const Standard_Integer num0) const
617 {
618   Standard_Integer num, nb = NbMapped();
619   for (num = num0+1; num <= nb; num ++) {
620     Handle(Transfer_Binder) bnd = MapItem (num);
621     if (bnd.IsNull()) continue;
622     if (!bnd->Attribute(name).IsNull()) return num;
623   }
624   return 0;
625 }
626
627
628 Interface_ParamType Transfer_TransferProcess::AttributeType
629   (const Standard_CString name) const
630 {
631   Interface_ParamType aty, res = Interface_ParamVoid;
632   Standard_Integer num, nb = NbMapped();
633   for (num = 1; num <= nb; num ++) {
634     Handle(Transfer_Binder) bnd = MapItem (num);
635     if (bnd.IsNull()) continue;
636     aty = bnd->AttributeType(name);
637     if (aty == Interface_ParamVoid) continue;
638     if (res == Interface_ParamVoid) res = aty;
639     else if (res != aty) return Interface_ParamMisc;
640   }
641   return res;
642 }
643
644 Handle(Dico_DictionaryOfInteger) Transfer_TransferProcess::Attributes
645   (const Standard_CString rootname) const
646 {
647   Handle(Dico_DictionaryOfInteger) list = new Dico_DictionaryOfInteger;
648   Standard_Integer num, nb = NbMapped();
649   for (num = 1; num <= nb; num ++) {
650     Handle(Transfer_Binder) bnd = MapItem (num);
651     if (bnd.IsNull()) continue;
652     Handle(Dico_DictionaryOfTransient) atr = bnd->AttrList();
653     if (atr.IsNull()) continue;
654     Dico_IteratorOfDictionaryOfTransient iatr(atr,rootname);
655     for (; iatr.More(); iatr.Next()) {
656       TCollection_AsciiString name = iatr.Name();
657       Standard_Boolean deja;
658       Standard_Integer& nbval = list->NewItem (name.ToCString(),deja);
659       if (!deja) nbval = 0;
660       nbval ++;
661     }
662
663   }
664   return list;
665 }
666 skl*/
667
668
669 //  ##    ##    ##        Actions sur Types Privilegies        ##    ##    ##
670 //  ##    ##    ##          (Transient)                        ##    ##    ##
671
672 // Bind associe un objet a un objet resultat; or la Map associe un Objet a un
673 // Binder (qui designe son resultat)
674 //  *Transient  travaillent avec un SimpleBinderOfTransient
675 // si  deja la, on considere son resultat
676 // sinon, on cree un Binder du bon type
677
678
679 //=======================================================================
680 //function : BindTransient
681 //purpose  : 
682 //=======================================================================
683
684 void Transfer_TransferProcess::BindTransient(const TheStart& start,
685                                              const Handle(Standard_Transient)& res)
686 //                                           const Standard_Integer categ)
687 {
688   if (res.IsNull()) return;
689   Handle(Transfer_Binder) former = Find(start);//,categ);skl
690   Handle(Transfer_SimpleBinderOfTransient) binder =
691     Handle(Transfer_SimpleBinderOfTransient)::DownCast(former);
692 //      Binding sur place ?
693   if (!binder.IsNull()) {
694     if (binder->Status() == Transfer_StatusVoid) { binder->SetResult(res); return; }
695   }
696 //      Sinon, refaire
697   binder = new Transfer_SimpleBinderOfTransient;
698   binder->SetResult (res);
699   if (former.IsNull()) Bind(start,binder);//,categ);skl
700   else Rebind(start,binder);//,categ);skl
701 }
702
703
704 //=======================================================================
705 //function : FindTransient
706 //purpose  : 
707 //=======================================================================
708
709 const Handle(Standard_Transient)& Transfer_TransferProcess::FindTransient
710        (const TheStart& start) const
711 {
712   Handle(Transfer_SimpleBinderOfTransient) binder =
713     Handle(Transfer_SimpleBinderOfTransient)::DownCast(Find(start));
714   if (binder.IsNull()) return nultrans;
715   if (!binder->HasResult()) return nultrans;
716   return binder->Result();
717 }
718
719
720 //  Binding Multiple : D abord le declarer par BindMultiple (si pas deja fait)
721 //  Puis ajouter les termes par AddMultiple
722
723 //=======================================================================
724 //function : BindMultiple
725 //purpose  : 
726 //=======================================================================
727
728 void Transfer_TransferProcess::BindMultiple(const TheStart& start)
729 //                                          const Standard_Integer categ)
730 {
731   Handle(Transfer_Binder) binder = FindAndMask (start);//,categ);skl
732   if (!binder.IsNull()) {
733     if (!binder->IsKind(STANDARD_TYPE(Transfer_MultipleBinder))) {
734       StartTrace (thelastbnd,start,thelevel,4);
735       throw Transfer_TransferFailure("TransferProcess : BindMultiple");
736     }
737   }
738   else Bind(start,new Transfer_MultipleBinder);//,categ);skl
739 }
740
741
742 //=======================================================================
743 //function : AddMultiple
744 //purpose  : 
745 //=======================================================================
746
747 void Transfer_TransferProcess::AddMultiple(const TheStart& start,
748                                            const Handle(Standard_Transient)& res)
749 //                                         const Standard_Integer categ)
750 {
751   Handle(Transfer_Binder) binder = FindAndMask(start);//,categ);skl
752   Handle(Transfer_MultipleBinder) multr =
753     Handle(Transfer_MultipleBinder)::DownCast(binder);
754   if (multr.IsNull()) {
755     StartTrace (binder,start,thelevel,4);
756     if (binder.IsNull()) throw Transfer_TransferFailure("TransferProcess : AddMultiple, nothing bound");
757     else                 throw Transfer_TransferFailure("TransferProcess : AddMultiple, Binder not a MultipleBinder");
758   }
759   multr->AddResult(res);
760 }
761
762
763 //=======================================================================
764 //function : FindTypedTransient
765 //purpose  : 
766 //=======================================================================
767
768 Standard_Boolean Transfer_TransferProcess::FindTypedTransient
769   (const TheStart& start, const Handle(Standard_Type)& atype,
770    Handle(Standard_Transient)& val) const
771 {
772   return GetTypedTransient (Find(start),atype,val);
773 }
774
775
776 //=======================================================================
777 //function : GetTypedTransient
778 //purpose  : 
779 //=======================================================================
780
781 Standard_Boolean  Transfer_TransferProcess::GetTypedTransient
782   (const Handle(Transfer_Binder)& binder, const Handle(Standard_Type)& atype,
783    Handle(Standard_Transient)& val) const
784 {
785   return Transfer_SimpleBinderOfTransient::GetTypedResult(binder,atype,val);
786 }
787
788
789 //  ##    ##    ##    ##    ##    Acces Atomique    ##    ##    ##    ##    ##
790 //    (ne gere pas le scope mais donne acces aux categories)
791
792 //=======================================================================
793 //function : NbMapped
794 //purpose  : 
795 //=======================================================================
796
797 Standard_Integer  Transfer_TransferProcess::NbMapped () const
798 {
799   return themap.Extent();
800 }
801
802
803 //=======================================================================
804 //function : Mapped
805 //purpose  : 
806 //=======================================================================
807
808 const TheStart& Transfer_TransferProcess::Mapped(const Standard_Integer num) const
809 {
810   return themap.FindKey(num);
811 }
812
813
814 //=======================================================================
815 //function : MapIndex
816 //purpose  : 
817 //=======================================================================
818
819 Standard_Integer Transfer_TransferProcess::MapIndex(const TheStart& start) const
820 {
821   return themap.FindIndex(start);
822 }
823
824
825 //=======================================================================
826 //function : MapItem
827 //purpose  : 
828 //=======================================================================
829
830 Handle(Transfer_Binder) Transfer_TransferProcess::MapItem(const Standard_Integer num) const
831 //                                                        const Standard_Integer categ) const
832 {
833   Handle(Transfer_Binder) binder = themap.FindFromIndex(num);
834   //sklif (binder.IsNull())
835   return binder;
836   //sklreturn binder->Search (categ);
837 }
838
839
840 //  ########################################################################
841 //  ....                         ROOT MANAGEMENT                        ....
842
843 //=======================================================================
844 //function : SetRoot
845 //purpose  : 
846 //=======================================================================
847
848 void Transfer_TransferProcess::SetRoot (const TheStart& start)
849 {
850   Standard_Integer index = MapIndex(start);
851   if (index == 0) {
852     //StartTrace (thelastbnd,start,thelevel,4);
853     //throw Transfer_TransferFailure("TransferProcess : SetRoot");
854     return;
855   }
856
857   theroots.Add(index);
858   if (thetrace > 2) StartTrace (MapItem(index),start,thelevel,3);
859 }
860
861
862 //=======================================================================
863 //function : SetRootManagement
864 //purpose  : 
865 //=======================================================================
866
867 void  Transfer_TransferProcess::SetRootManagement(const Standard_Boolean stat)
868 {
869   therootm = stat;
870 }
871
872
873 //=======================================================================
874 //function : NbRoots
875 //purpose  : 
876 //=======================================================================
877
878 Standard_Integer  Transfer_TransferProcess::NbRoots () const
879 {
880   return theroots.Extent();
881 }
882
883
884 //=======================================================================
885 //function : Root
886 //purpose  : 
887 //=======================================================================
888
889 const TheStart&  Transfer_TransferProcess::Root(const Standard_Integer num) const
890 {
891   Standard_Integer ind = 0;
892   if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num);
893   return themap.FindKey (ind);
894 }
895
896
897 //=======================================================================
898 //function : RootItem
899 //purpose  : 
900 //=======================================================================
901
902 Handle(Transfer_Binder) Transfer_TransferProcess::RootItem(const Standard_Integer num) const
903 //                                                         const Standard_Integer categ) const
904 {
905   Standard_Integer ind = 0;
906   if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num);
907   return themap.FindFromIndex(ind);//->Search(categ);skl
908 }
909
910
911 //=======================================================================
912 //function : RootIndex
913 //purpose  : 
914 //=======================================================================
915
916 Standard_Integer  Transfer_TransferProcess::RootIndex(const TheStart& start) const
917 {
918   Standard_Integer index = MapIndex(start);
919   if (index == 0) return 0;
920   return theroots.FindIndex(index);
921 }
922
923
924 //=======================================================================
925 //function : NestingLevel
926 //purpose  : 
927 //=======================================================================
928
929 Standard_Integer  Transfer_TransferProcess::NestingLevel () const
930 {
931   return thelevel;
932 }
933
934
935 //=======================================================================
936 //function : ResetNestingLevel
937 //purpose  : 
938 //=======================================================================
939
940 void Transfer_TransferProcess::ResetNestingLevel ()
941 {
942   thelevel = 0;
943 }
944
945
946 //  ########################################################################
947 //  ....                        SCOPE MANAGEMENT                        ....
948
949
950 //======================================================================
951 //Purpose : gka TRJ9 for writing SDR for solid
952 //          Check if binder has already been bound to the result binder.
953 //======================================================================
954
955 // static Standard_Boolean Contains(const Handle(Transfer_Binder)& resbinder, 
956 //                               const Handle(Transfer_Binder)& addbinder)
957 // {
958 //   Handle(Transfer_Binder) tmpbind = resbinder;
959 //   for ( ; ! tmpbind.IsNull(); tmpbind = tmpbind->NextResult() )
960 //     if ( tmpbind == addbinder ) return Standard_True;
961 //   return Standard_False;
962 // }
963
964 //  ########################################################################
965 //  ....                    AUTOMATISMES DE TRANSFERT                   ....
966
967 //  ##    ##    ##    ##    ##  Fonctions de Base  ##    ##    ##    ##    ##
968
969
970 //=======================================================================
971 //function : Recognize
972 //purpose  : 
973 //=======================================================================
974
975 Standard_Boolean  Transfer_TransferProcess::Recognize(const TheStart& start) const
976 {
977   Handle(Transfer_Actor) actor = theactor;
978   //   On balaie les Next jusqu a avoir un Resultat
979   while (!actor.IsNull()) {
980     if (actor->Recognize (start)) return Standard_True;
981     actor = actor->Next();
982   }
983   return Standard_False;
984 }
985
986
987 //=======================================================================
988 //function : Transferring
989 //purpose  : 
990 //=======================================================================
991
992 Handle(Transfer_Binder) Transfer_TransferProcess::Transferring(const TheStart& start)
993 {
994   //   Map deja alimentee ?
995   Handle(Transfer_Binder) former = FindAndMask(start);
996
997   //  ....    Transfert deja effectue avec Resultat ?    ....
998
999   //  On considere que cette nouvelle demande de Transfert correspond donc a une
1000   //  utilisation en plus : noter "AlreadyUsed", donc resultat non modifiable
1001   if (!former.IsNull()) {
1002     if (former->HasResult()) {
1003       former->SetAlreadyUsed();
1004       return former;
1005     }
1006   //}
1007
1008     //  ....    Etat Initial : peut-etre deja fait ... ou infaisable !
1009
1010   //if (!former.IsNull()) {
1011     Transfer_StatusExec statex = former->StatusExec();
1012     switch (statex) {
1013       case Transfer_StatusInitial :               // Transfert prepare a faire
1014         break;
1015       case Transfer_StatusDone :                  // Transfert deja fait
1016 //#ifdef TRANSLOG
1017         themessenger << " .. and Transfer done" << Message_EndLine;
1018 //#endif
1019 //      if (former->HasResult()) former->SetAlreadyUsed();
1020         return former;
1021       case Transfer_StatusRun :                   // ca y est, on boucle
1022         former->SetStatusExec(Transfer_StatusLoop);
1023         return former;
1024       case Transfer_StatusError :                 // pas propre, ca ...
1025         if (thetrace) {
1026           themessenger << "                  *** Transfer in Error Status  :" << Message_EndLine;
1027           StartTrace (former, start, thelevel,0);
1028 //        (*themessenger->Out()) << flush;
1029         }
1030         else StartTrace (former, start,thelevel,4);
1031         throw Transfer_TransferFailure("TransferProcess : Transfer in Error Status");
1032       case Transfer_StatusLoop :                  // la boucle est bouclee ...
1033         if (thetrace) {
1034           themessenger << "                  *** Transfer  Head of Dead Loop  :" << Message_EndLine;
1035           StartTrace (former, start, thelevel,0);
1036 //        (*themessenger->Out()) << flush;
1037         }
1038         else StartTrace (former, start,thelevel,4);
1039         throw Transfer_TransferDeadLoop("TransferProcess : Transfer at Head of a Dead Loop");
1040     }
1041 #ifdef TRANSLOG
1042     std::cout << "Transfer,level "<<thelevel<<Message_Flush;
1043 #endif
1044   //}
1045
1046   //  ....    OK, on peut lancer l Execution
1047   //if (!former.IsNull()) 
1048     former->SetStatusExec(Transfer_StatusRun);
1049   }
1050 #ifdef TRANSLOG
1051   std::cout << " GO .." << std::endl;
1052 #endif
1053
1054   Handle(Transfer_Binder) binder;
1055   Standard_Boolean newbind = Standard_False;
1056   if (theerrh) {
1057     //   Transfert sous protection pour les exceptions (pour notification en fait)
1058     Standard_Integer oldlev = thelevel;
1059     try {
1060       OCC_CATCH_SIGNALS
1061       binder = TransferProduct(start);
1062     }
1063
1064     //    ...  Exceptions a Rattraper : elles ne se ressemblent pas toutes ... !
1065     catch (Transfer_TransferDeadLoop const&) {
1066       if (binder.IsNull()) {
1067         themessenger << "                  *** Dead Loop with no Result" << Message_EndLine;
1068         if (thetrace) StartTrace (binder, start, thelevel-1,0);
1069         binder = new Transfer_VoidBinder;
1070         Bind (start,binder);  newbind = Standard_True;
1071       } else if (binder->StatusExec() == Transfer_StatusLoop) {
1072         if (thetrace) {
1073           themessenger << "                  *** Dead Loop : Finding head of Loop :" << Message_EndLine;
1074           StartTrace (binder, start, thelevel-1,0);
1075         }
1076         else StartTrace (binder, start,thelevel-1,4);
1077         throw Transfer_TransferFailure("TransferProcess : Head of Dead Loop");
1078 // Autrement dit, on change d exception (on est sorti de la boucle)
1079       } else {
1080         if (thetrace) {
1081           themessenger << "                  *** Dead Loop : Actor in Loop :" << Message_EndLine;
1082           StartTrace (binder, start, thelevel-1,0);
1083         }
1084       }
1085       binder->AddFail("Transfer in dead Loop");
1086       thelevel = oldlev;
1087     }
1088     catch (Standard_Failure const& anException) {
1089       if (binder.IsNull()) {
1090         themessenger << "                  *** Exception Raised with no Result" << Message_EndLine;
1091         binder = new Transfer_VoidBinder;
1092         Bind (start,binder);  newbind = Standard_True;
1093       }
1094       binder->AddFail("Transfer stopped by exception raising");
1095       if (thetrace) {
1096         themessenger << "    *** Raised : " << anException.GetMessageString() << Message_EndLine;
1097         StartTrace (binder, start, thelevel-1,4);
1098       }
1099       thelevel = oldlev;
1100     }
1101   }
1102
1103 //   Transfert non protege (ainsi, dbx a la main en cas de plantage par Raise)
1104   else  binder = TransferProduct(start);
1105
1106 //  ....                Conclusion : Noter dans la Map                ....
1107
1108   if (!newbind && !binder.IsNull()) {
1109     if (former.IsNull()) {
1110 //    Peut-etre <theactor> a fait lui meme Bind ... verifier sinon le faire
1111       if (!IsBound(start)) Bind(start,binder);     // resultat = categorie 0
1112       else {                                       // gka TRJ9 for writing SDR for solid
1113 //      Handle(Transfer_Binder) tmpbind = Find(start);
1114 //      if(!Contains(binder,tmpbind))
1115 //         binder->AddResult(tmpbind);
1116         Rebind(start,binder); // test_pattern.sat
1117       }
1118     }
1119     else Rebind(start,binder);
1120 //  (du coup, <thelastbnd> vaut <binder>)
1121 #ifdef TRANSLOG
1122     std::cout << " ... OK" << std::endl;
1123 #endif
1124   }
1125   else {
1126     //= by ABV: 5 Oct 97: nothing generated, but former can be in run state - drop it
1127     //= ASK: may be set it to StatusInitial ?
1128     if ( ! former.IsNull() ) former->SetStatusExec ( Transfer_StatusDone ); //+
1129     return nulbinder;    // Binder Null ... que faire d autre ?
1130   }
1131
1132 //  ....                Gerer les Racines (si prevu)                ....
1133
1134   if (therootl >= thelevel) {
1135     therootl = 0;
1136     if (therootm && binder->Status() != Transfer_StatusVoid) {
1137       SetRoot (start);
1138     }
1139   }
1140   return thelastbnd;
1141 }
1142
1143 //  ##    ##        TransferProduct : Action proprement dite        ##    ##
1144
1145     Handle(Transfer_Binder) Transfer_TransferProcess::TransferProduct
1146   (const TheStart& start)
1147 {
1148   thelevel ++;             // si decremente et == 0, transfert racine
1149   Handle(Transfer_Binder) binder;
1150   Handle(Transfer_Actor) actor = theactor;
1151
1152 //   On balaie les Next jusqu a avoir un Resultat
1153   while (!actor.IsNull()) {
1154     if (actor->Recognize (start)) binder = actor->Transferring(start,this);
1155     else binder.Nullify();
1156     if (!binder.IsNull()) break;
1157     actor = actor->Next();
1158   }
1159   if (binder.IsNull()) {
1160 //    if (thetrace) {
1161 //      themessenger << "Transfer has produced no Result" <<endl;
1162 //      StartTrace (binder, start, thelevel-1,0); sout << flush;
1163 //    }
1164     if (thelevel > 0) thelevel --;
1165     return binder;
1166   }
1167 //      Gestion du niveau racine (.. a regarder de pres ..)
1168   if (therootl == 0 && binder->StatusExec() == Transfer_StatusDone)
1169     therootl = thelevel - 1;
1170
1171   if (thelevel > 0) thelevel --;
1172   return binder;
1173 }
1174
1175
1176 //=======================================================================
1177 //function : Transfer
1178 //purpose  : 
1179 //=======================================================================
1180
1181 Standard_Boolean  Transfer_TransferProcess::Transfer(const TheStart& start)
1182 {
1183   Handle(Transfer_Binder) binder = Transferring(start);
1184   return (!binder.IsNull());
1185 }
1186
1187
1188 //  #########################################################################
1189 //  ....                      Error Handling + Trace                     ....
1190
1191 //  trace : 1 pour Fail et Exception , 2 pour Root et Warning
1192
1193
1194 //=======================================================================
1195 //function : SetErrorHandle
1196 //purpose  : 
1197 //=======================================================================
1198
1199 void Transfer_TransferProcess::SetErrorHandle(const Standard_Boolean err)
1200 {
1201   theerrh = err;
1202 }    // traite par Transferring
1203
1204
1205 //=======================================================================
1206 //function : ErrorHandle
1207 //purpose  : 
1208 //=======================================================================
1209
1210 Standard_Boolean  Transfer_TransferProcess::ErrorHandle() const
1211 {
1212   return theerrh;
1213 }
1214
1215 //=======================================================================
1216 //function : StartTrace
1217 //purpose  : 
1218 //=======================================================================
1219
1220 void Transfer_TransferProcess::StartTrace(const Handle(Transfer_Binder)& binder,
1221                                           const TheStart& start,
1222                                           const Standard_Integer level,
1223                                           const Standard_Integer mode) const 
1224 {
1225   // ###  Fail (Roots:50)  --  Start start->DynamicType()
1226   // ###  Fail (Roots:50)  --  Start id:#label.. Type:start->DynamicType()
1227   if (thetrace > 3) {  // Internal to be switch when searching bug (trace >= 4)
1228     if (mode == 1) themessenger << "  ###  Fail";
1229     if (mode == 2) themessenger << "  ###  Warning";
1230     if (mode == 3) themessenger << "  ###  New Root n0 " << theroots.Extent();
1231     if (mode == 4) themessenger << "  ###  Exception";
1232     if (mode == 5) themessenger << "  ###  Substitution";
1233     if (mode == 6) themessenger << "  ###  Information";
1234     if (level > 1)
1235       themessenger << " (nested)";  // " at nesting Level:"<<level;
1236     if (mode >= 0 && mode != 3)
1237       themessenger << " at " << theroots.Extent() << " Roots";
1238   }
1239   if (!start.IsNull()) PrintTrace (start,themessenger);
1240 ////  sout << endl;
1241
1242   if (!binder.IsNull()) {   // old: if IsNull sout <<endl<< "  ---  Not Bound";
1243     Handle(Transfer_Binder) bnd = binder;
1244     Standard_Boolean hasres = Standard_False;
1245     while (!bnd.IsNull()) {
1246       if (bnd->Status() != Transfer_StatusVoid) {
1247 // ---  Result Type: binder->ResultType()  ---  Binder : binder->DynamicType();
1248         if (!hasres)
1249           themessenger << "\n  ---  Result Type : ";
1250         else 
1251           themessenger << " , ";
1252         themessenger << bnd->ResultTypeName();
1253 //  CKY 9-JAN-1999:  waiting for XSTEP Kernel message (not IGES_2075)
1254 /*        Message_Msg Msg2075("IGES_2075");
1255           Msg2075.AddString(bnd->ResultTypeName());
1256           Msg2075.TraceEver();  */
1257         hasres = Standard_True;
1258       }
1259       bnd = bnd->NextResult();
1260     }
1261     if (!hasres && mode > 2) {
1262       themessenger << "\n  ---  No Result recorded";
1263 //  CKY 9-JAN-1999 : waiting for XSTEP Kernel message
1264 //     (not IGES_2075, no reference to specifically TopoDS_Shape)
1265 /*       Message_Msg Msg2075("IGES_2075");
1266          Msg2075.AddString("No TopoDS_Shape");
1267          Msg2075.TraceEver();  */
1268     }
1269 //old    if (isused) sout << "  --    (Already Used in another Transfer)";
1270   }
1271   themessenger << Message_EndLine;
1272 }
1273
1274
1275 //=======================================================================
1276 //function : PrintTrace
1277 //purpose  : 
1278 //=======================================================================
1279
1280 void  Transfer_TransferProcess::PrintTrace(const TheStart& start,
1281                                            const Handle(Message_Messenger)& S) const
1282 {
1283   if (!start.IsNull())   S <<" Type:" << start->DynamicType()->Name();
1284 }
1285
1286
1287 //=======================================================================
1288 //function : IsLooping
1289 //purpose  : 
1290 //=======================================================================
1291
1292 Standard_Boolean  Transfer_TransferProcess::IsLooping
1293   (const Standard_Integer alevel) const 
1294       {  return alevel > NbMapped();  }
1295
1296
1297
1298 //  #########################################################################
1299 //  ....                            RESULTATS                            ....
1300
1301
1302 //  ##    ##        RootResult : Les Racines        ##    ##
1303
1304
1305 //=======================================================================
1306 //function : RootResult
1307 //purpose  : 
1308 //=======================================================================
1309
1310 Transfer_Iterator Transfer_TransferProcess::RootResult(const Standard_Boolean withstart) const
1311 {
1312   Transfer_Iterator iter(withstart);
1313   Standard_Integer max = theroots.Extent();
1314   for (Standard_Integer j = 1; j <= max; j ++) {
1315     Standard_Integer i = theroots.FindKey(j);
1316     Handle(Transfer_Binder) binder = MapItem(i);
1317     if (binder.IsNull()) continue;
1318     if (withstart) iter.Add (binder,Mapped(i));
1319     else iter.Add (binder);
1320   }
1321   return iter;
1322 }
1323
1324
1325 //  ##    ##        CompleteResult : Tous les Resultats        ##    ##
1326
1327 //=======================================================================
1328 //function : CompleteResult
1329 //purpose  : 
1330 //=======================================================================
1331
1332 Transfer_Iterator Transfer_TransferProcess::CompleteResult
1333   (const Standard_Boolean withstart) const
1334 {
1335   Transfer_Iterator iter(withstart);
1336   Standard_Integer max = NbMapped();
1337   for (Standard_Integer i = 1; i <= max; i ++) {
1338     Handle(Transfer_Binder) binder = MapItem(i);
1339     if (binder.IsNull()) continue;
1340     if (withstart) iter.Add (binder,Mapped(i));
1341     else iter.Add (binder);
1342   }
1343   return iter;
1344 }
1345
1346
1347 //  ##    ##        AbnormalResult : Transferts a probleme        ##    ##
1348 //=======================================================================
1349 //function : AbnormalResult
1350 //purpose  : 
1351 //=======================================================================
1352
1353 Transfer_Iterator Transfer_TransferProcess::AbnormalResult() const
1354 {
1355   Transfer_Iterator iter(Standard_True);
1356   Standard_Integer max = NbMapped();
1357   for (Standard_Integer i = 1; i <= max; i ++) {
1358     Handle(Transfer_Binder) binder = MapItem(i);
1359     if (binder.IsNull()) continue;
1360     Transfer_StatusExec statex = binder->StatusExec();
1361     if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone)
1362       iter.Add (binder,Mapped(i));  // on note les cas "pas normaux"
1363   }
1364   return iter;
1365 }
1366
1367
1368 //  ##    ##    ##         CheckList : les messages         ##    ##    ##
1369 //=======================================================================
1370 //function : CheckList
1371 //purpose  : 
1372 //=======================================================================
1373
1374 Interface_CheckIterator  Transfer_TransferProcess::CheckList
1375   (const Standard_Boolean erronly) const
1376 {
1377   Interface_CheckIterator list;
1378   Standard_Integer num, max = NbMapped();
1379   for (Standard_Integer i = 1; i <= max; i ++) {
1380     Handle(Transfer_Binder) binder = MapItem(i);
1381     if (binder.IsNull()) continue;
1382     Transfer_StatusExec statex = binder->StatusExec();
1383     Handle(Interface_Check) check = binder->Check();
1384     if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone &&
1385         !check->HasFailed())
1386       check->AddFail("Transfer in Abnormal Status (!= Initial or Done)");
1387     if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue;
1388     const TheStart& ent = Mapped(i);
1389     num = CheckNum(ent);
1390     if (num == 0) num = i;
1391     check->SetEntity(ent);
1392     list.Add(check,num);
1393   }
1394   return list;
1395 }
1396
1397
1398 //  #########################################################################
1399 //  ....                       RESULTATS PAR ENTITE                      ....
1400
1401 //=======================================================================
1402 //function : ResultOne
1403 //purpose  : 
1404 //=======================================================================
1405
1406 Transfer_Iterator Transfer_TransferProcess::ResultOne(const TheStart& start,
1407                                                       const Standard_Integer level,
1408                                                       const Standard_Boolean withstart) const
1409 {
1410   Transfer_Iterator iter(withstart);
1411   Standard_Integer max = NbMapped();
1412   Standard_Integer ind = MapIndex (start);
1413   if (ind == 0) return iter;
1414   Standard_Integer i1 = (level == 0 ? ind : 1);
1415   Standard_Integer i2 = (level == 0 ? ind : max);
1416   Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
1417   //MarkScoped (ind,level,map);
1418
1419   for (Standard_Integer i = i1; i <= i2; i ++) {
1420     ind = map->Value(i);
1421     if (ind == 0) continue;
1422     Handle(Transfer_Binder) binder = MapItem(i);
1423     if (binder.IsNull()) continue;
1424     if (withstart) iter.Add (binder,Mapped(ind));
1425     else iter.Add (binder);
1426   }
1427   return iter;
1428 }
1429
1430
1431 //=======================================================================
1432 //function : CheckListOne
1433 //purpose  : 
1434 //=======================================================================
1435
1436 Interface_CheckIterator  Transfer_TransferProcess::CheckListOne
1437   (const TheStart& start,const Standard_Integer level,
1438    const Standard_Boolean erronly) const
1439 {
1440   Interface_CheckIterator list;
1441   Standard_Integer max = NbMapped();
1442   Standard_Integer num, ind = MapIndex (start);
1443   if (ind == 0) return list;
1444   Standard_Integer i1 = (level == 0 ? ind : 1);
1445   Standard_Integer i2 = (level == 0 ? ind : max);
1446   Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
1447   //MarkScoped (ind,level,map);
1448
1449   for (Standard_Integer i = i1; i <= i2; i ++) {
1450     ind = map->Value(i);
1451     if (ind == 0) continue;
1452     Handle(Transfer_Binder) binder = MapItem(ind);
1453     if (binder.IsNull()) continue;
1454     Transfer_StatusExec statex = binder->StatusExec();
1455     Handle(Interface_Check) check = binder->Check();
1456     if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone &&
1457         !check->HasFailed())
1458       check->AddFail("Transfer in Abnormal Status (!= Initial or Done)");
1459     if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue;
1460     const TheStart& ent = Mapped(ind);
1461     num = CheckNum(ent);  if (num == 0) num = ind;
1462     check->SetEntity(ent);
1463     list.Add(check,num);
1464   }
1465   return list;
1466 }
1467
1468
1469 //=======================================================================
1470 //function : IsCheckListEmpty
1471 //purpose  : 
1472 //=======================================================================
1473
1474 Standard_Boolean  Transfer_TransferProcess::IsCheckListEmpty
1475   (const TheStart& start, const Standard_Integer level,
1476    const Standard_Boolean erronly) const
1477 {
1478   Standard_Integer max = NbMapped();
1479   Standard_Integer ind = MapIndex (start);
1480   if (ind == 0) return Standard_False;
1481   Standard_Integer i1 = (level == 0 ? ind : 1);
1482   Standard_Integer i2 = (level == 0 ? ind : max);
1483   Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
1484 //  MarkScoped (ind,level,map);
1485
1486   for (Standard_Integer i = i1; i <= i2; i ++) {
1487     ind = map->Value(i);
1488     if (ind == 0) continue;
1489     Handle(Transfer_Binder) binder = MapItem(ind);
1490     if (binder.IsNull()) continue;
1491
1492     Transfer_StatusExec statex = binder->StatusExec();
1493     Handle(Interface_Check) check = binder->Check();
1494     if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone)
1495       return Standard_False;
1496     if (check->HasFailed() || (!erronly && check->NbWarnings() > 0)) return Standard_False;
1497   }
1498   return Standard_True;
1499 }
1500
1501
1502 //=======================================================================
1503 //function : RemoveResult
1504 //purpose  : 
1505 //=======================================================================
1506
1507 void  Transfer_TransferProcess::RemoveResult(const TheStart& start,
1508                                              const Standard_Integer level,
1509                                              const Standard_Boolean /*compute*/)
1510 {
1511   //if (compute) ComputeScopes();
1512   Standard_Integer max = NbMapped();
1513   Standard_Integer ind = MapIndex (start);
1514   if (ind == 0) return;
1515   Standard_Integer i1 = (level == 0 ? ind : 1);
1516   Standard_Integer i2 = (level == 0 ? ind : max);
1517   Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
1518 //  MarkScoped (ind,level,map);
1519
1520   Standard_Integer i; // svv Jan11 2000 : porting on DEC
1521   for (i = i1; i <= i2; i ++) {
1522     ind = map->Value(i);
1523     if (ind == 0) continue;
1524     Handle(Transfer_Binder) binder = MapItem(ind);
1525     if (binder.IsNull()) continue;
1526 //    Standard_Boolean cayest = binder->SetNbUserScopes (-1);
1527 //    if (cayest) themap(ind) = nulbinder;    // RAZ !
1528   }
1529
1530 //pdn commented  for (i = NbRoots(); i > 0; i --)
1531 //    if (theroots.Value(i) == ind) theroots.Remove(i);
1532 }
1533
1534
1535 Standard_Integer  Transfer_TransferProcess::CheckNum(const TheStart& ) const
1536 {
1537   return 0;
1538 }
1539
1540
1541 //=======================================================================
1542 //function : SetProgress
1543 //purpose  : Sets Progress indicator
1544 //=======================================================================
1545
1546 void Transfer_TransferProcess::SetProgress(const Handle(Message_ProgressIndicator)& theProgress)
1547 {
1548   myProgress = theProgress;
1549 }
1550
1551 //=======================================================================
1552 //function : GetProgress
1553 //purpose  : Returns Progress indicator
1554 //=======================================================================
1555
1556 Handle(Message_ProgressIndicator) Transfer_TransferProcess::GetProgress() const
1557 {
1558   return myProgress;
1559 }