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 //:   abv 09.04.99: S4136: remove parameter lastpreci
15 // szv#11:CASCADE30:01Feb00 BRepBuilderAPI::Precision(p) removed
16 
17 #include <BRepBuilderAPI.hxx>
18 #include <BRepLib.hxx>
19 #include <IFSelect_CheckCounter.hxx>
20 #include <IFSelect_SignatureList.hxx>
21 #include <Interface_Check.hxx>
22 #include <Interface_CheckIterator.hxx>
23 #include <Interface_EntityIterator.hxx>
24 #include <Interface_Graph.hxx>
25 #include <Interface_HGraph.hxx>
26 #include <Interface_InterfaceModel.hxx>
27 #include <Interface_Macros.hxx>
28 #include <Interface_MSG.hxx>
29 #include <Interface_SignLabel.hxx>
30 #include <Interface_Static.hxx>
31 #include <Message_Messenger.hxx>
32 #include <Message_ProgressScope.hxx>
33 #include <ShapeFix.hxx>
34 #include <Standard_ErrorHandler.hxx>
35 #include <Standard_Failure.hxx>
36 #include <Standard_Transient.hxx>
37 #include <Standard_Type.hxx>
38 #include <TCollection_HAsciiString.hxx>
39 #include <TColStd_HSequenceOfTransient.hxx>
40 #include <TopoDS_HShape.hxx>
41 #include <TopoDS_Shape.hxx>
42 #include <TopTools_MapOfShape.hxx>
43 #include <Transfer_ActorOfTransientProcess.hxx>
44 #include <Transfer_IteratorOfProcessForTransient.hxx>
45 #include <Transfer_ResultFromModel.hxx>
46 #include <Transfer_ResultFromTransient.hxx>
47 #include <Transfer_SimpleBinderOfTransient.hxx>
48 #include <Transfer_TransferOutput.hxx>
49 #include <Transfer_TransientProcess.hxx>
50 #include <TransferBRep.hxx>
51 #include <TransferBRep_BinderOfShape.hxx>
52 #include <TransferBRep_ShapeBinder.hxx>
53 #include <XSControl_Controller.hxx>
54 #include <XSControl_TransferReader.hxx>
55 #include <XSControl_Utils.hxx>
56 #include <Message.hxx>
57 
58 #include <stdio.h>
IMPLEMENT_STANDARD_RTTIEXT(XSControl_TransferReader,Standard_Transient)59 IMPLEMENT_STANDARD_RTTIEXT(XSControl_TransferReader,Standard_Transient)
60 
61 //=======================================================================
62 //function : SetController
63 //purpose  :
64 //=======================================================================
65 
66 void XSControl_TransferReader::SetController(const Handle(XSControl_Controller)& control)
67 {
68   myController = control;
69   myActor.Nullify();
70   Clear(-1);
71 }
72 
73 
74 //=======================================================================
75 //function : Actor
76 //purpose  :
77 //=======================================================================
78 
Handle(Transfer_ActorOfTransientProcess)79 Handle(Transfer_ActorOfTransientProcess) XSControl_TransferReader::Actor ()
80 {
81   if ( myActor.IsNull() && !myController.IsNull() && !myModel.IsNull())
82     myActor = myController->ActorRead(myModel);
83   return myActor;
84 }
85 
86 
87 //=======================================================================
88 //function : SetModel
89 //purpose  :
90 //=======================================================================
91 
SetModel(const Handle (Interface_InterfaceModel)& model)92 void XSControl_TransferReader::SetModel(const Handle(Interface_InterfaceModel)& model)
93 {
94   myModel = model;
95   if (!myTP.IsNull()) myTP->SetModel(model);
96 }
97 
98 
99 //=======================================================================
100 //function : SetGraph
101 //purpose  :
102 //=======================================================================
103 
SetGraph(const Handle (Interface_HGraph)& graph)104 void XSControl_TransferReader::SetGraph(const Handle(Interface_HGraph)& graph)
105 {
106   if (graph.IsNull())
107   {
108     myModel.Nullify();
109   }
110   else
111     myModel = graph->Graph().Model();
112 
113   myGraph = graph;
114 
115   if (!myTP.IsNull()) myTP->SetGraph(graph);
116 }
117 
118 
119 //=======================================================================
120 //function : SetContext
121 //purpose  :
122 //=======================================================================
123 
SetContext(const Standard_CString name,const Handle (Standard_Transient)& ctx)124 void XSControl_TransferReader::SetContext(const Standard_CString name,
125                                           const Handle(Standard_Transient)& ctx)
126 {
127   myContext.Bind(name,ctx);
128 }
129 
130 
131 //=======================================================================
132 //function : GetContext
133 //purpose  :
134 //=======================================================================
135 
GetContext(const Standard_CString name,const Handle (Standard_Type)& type,Handle (Standard_Transient)& ctx) const136 Standard_Boolean XSControl_TransferReader::GetContext
137   (const Standard_CString name, const Handle(Standard_Type)& type,
138    Handle(Standard_Transient)& ctx) const
139 {
140   if (myContext.IsEmpty()) return Standard_False;
141   if (!myContext.Find(name, ctx))
142     ctx.Nullify();
143   if (ctx.IsNull()) return Standard_False;
144   if (type.IsNull()) return Standard_True;
145   if (!ctx->IsKind(type)) ctx.Nullify();
146   return !ctx.IsNull();
147 }
148 
149 
150 //=======================================================================
151 //function : Clear
152 //purpose  :
153 //=======================================================================
154 
Clear(const Standard_Integer mode)155 void XSControl_TransferReader::Clear (const Standard_Integer mode)
156 {
157   if (mode & 1) {
158     myResults.Clear();
159     myShapeResult.Nullify();
160   }
161   if (mode & 2) {
162     myModel.Nullify();
163     myGraph.Nullify();
164     myTP.Nullify();
165     myActor.Nullify();
166     myFileName.Clear();
167   }
168 }
169 
170 
171 //  ########################################################
172 //  ###########            RESULTATS            ############
173 
174 
175 //=======================================================================
176 //function : RecordResult
177 //purpose  :
178 //=======================================================================
179 
RecordResult(const Handle (Standard_Transient)& ent)180 Standard_Boolean XSControl_TransferReader::RecordResult
181   (const Handle(Standard_Transient)& ent)
182 {
183   if (myModel.IsNull() || myTP.IsNull()) return Standard_False;
184   Standard_Integer num = myModel->Number(ent);
185   if (num == 0) return Standard_False;
186   Handle(TCollection_HAsciiString) lab = myModel->StringLabel(ent);
187 
188   Handle(Transfer_ResultFromModel) res = new Transfer_ResultFromModel;
189   res->Fill (myTP,ent);
190 
191   //   Cas du resultat Shape : pour resultat principal, faire HShape ...
192   Handle(Transfer_Binder) binder = res->MainResult()->Binder();
193   DeclareAndCast(TransferBRep_ShapeBinder,shb,binder);
194   if (!shb.IsNull()) {
195     Handle(Transfer_SimpleBinderOfTransient) trb = new Transfer_SimpleBinderOfTransient;
196     trb->SetResult ( new TopoDS_HShape(shb->Result()) );
197     trb->Merge(binder);
198     res->MainResult()->SetBinder (trb);
199   }
200 
201   res->SetFileName(myFileName.ToCString());
202   myResults.Bind(num,res);
203   return Standard_True;
204 }
205 
206 
207 //=======================================================================
208 //function : IsRecorded
209 //purpose  :
210 //=======================================================================
211 
IsRecorded(const Handle (Standard_Transient)& ent) const212 Standard_Boolean XSControl_TransferReader::IsRecorded
213   (const Handle(Standard_Transient)& ent) const
214 {
215   if (myModel.IsNull()) return Standard_False;
216   Standard_Integer num = myModel->Number(ent);
217   if (num == 0) return Standard_False;
218   if(!myResults.IsBound(num)) return Standard_False;
219   return (myResults.Find(num)->DynamicType() == STANDARD_TYPE(Transfer_ResultFromModel) );
220 }
221 
222 
223 //=======================================================================
224 //function : HasResult
225 //purpose  :
226 //=======================================================================
227 
HasResult(const Handle (Standard_Transient)& ent) const228 Standard_Boolean  XSControl_TransferReader::HasResult
229   (const Handle(Standard_Transient)& ent) const
230 {
231   if (myModel.IsNull()) return Standard_False;
232   Standard_Integer num = myModel->Number(ent);
233   if (num == 0) return Standard_False;
234   if(!myResults.IsBound(num)) return Standard_False;
235   DeclareAndCast(Transfer_ResultFromModel,fr,myResults.Find(num));
236   if (fr.IsNull()) return Standard_False;
237   return fr->HasResult();
238 }
239 
240 
241 //=======================================================================
242 //function : RecordedList
243 //purpose  :
244 //=======================================================================
245 
Handle(TColStd_HSequenceOfTransient)246 Handle(TColStd_HSequenceOfTransient) XSControl_TransferReader::RecordedList () const
247 {
248   Handle(TColStd_HSequenceOfTransient) li = new TColStd_HSequenceOfTransient();
249   if (myModel.IsNull())   return li;
250   Standard_Integer i, nb = myModel->NbEntities();
251   for (i = 1; i <= nb; i ++) {
252     if(myResults.IsBound(i))
253       if(!myResults.Find(i).IsNull()) li->Append (myModel->Value(i));
254   }
255   return li;
256 }
257 
258 
259 //=======================================================================
260 //function : Skip
261 //purpose  :
262 //=======================================================================
263 
Skip(const Handle (Standard_Transient)& ent)264 Standard_Boolean XSControl_TransferReader::Skip(const Handle(Standard_Transient)& ent)
265 {
266   if (myModel.IsNull() || myTP.IsNull()) return Standard_False;
267   Standard_Integer num = myModel->Number(ent);
268   if (num == 0) return Standard_False;
269   myResults.Bind(num,ent);
270   return Standard_True;
271 }
272 
273 
274 //=======================================================================
275 //function : IsSkipped
276 //purpose  :
277 //=======================================================================
278 
IsSkipped(const Handle (Standard_Transient)& ent) const279 Standard_Boolean XSControl_TransferReader::IsSkipped
280   (const Handle(Standard_Transient)& ent) const
281 {
282   if (myModel.IsNull()) return Standard_False;
283   Standard_Integer num = myModel->Number(ent);
284   if (num == 0) return Standard_False;
285   if(!myResults.IsBound(num)) return Standard_False;
286   return (myResults.Find(num)->DynamicType() != STANDARD_TYPE(Transfer_ResultFromModel) );
287 }
288 
289 
290 //=======================================================================
291 //function : IsMarked
292 //purpose  :
293 //=======================================================================
294 
IsMarked(const Handle (Standard_Transient)& ent) const295 Standard_Boolean XSControl_TransferReader::IsMarked
296   (const Handle(Standard_Transient)& ent) const
297 {
298   if (myModel.IsNull()) return Standard_False;
299   Standard_Integer num = myModel->Number(ent);
300   if (num == 0) return Standard_False;
301   if(!myResults.IsBound(num)) return Standard_False;
302   if (myResults.Find(num).IsNull()) return Standard_False;
303   return Standard_True;
304 }
305 
306 
307 //  #########    ACCES UN PEU PLUS FIN    #########
308 
309 
310 //=======================================================================
311 //function : FinalResult
312 //purpose  :
313 //=======================================================================
314 
Handle(Transfer_ResultFromModel)315 Handle(Transfer_ResultFromModel) XSControl_TransferReader::FinalResult
316        (const Handle(Standard_Transient)& ent) const
317 {
318   Handle(Transfer_ResultFromModel) res;
319   if (myModel.IsNull())   return res;
320   Standard_Integer num = myModel->Number(ent);
321   if (num == 0) return res;
322   if(!myResults.IsBound(num)) return res;
323   res = GetCasted(Transfer_ResultFromModel,myResults.Find(num));
324   return res;
325 }
326 
327 
328 //=======================================================================
329 //function : FinalEntityLabel
330 //purpose  :
331 //=======================================================================
332 
FinalEntityLabel(const Handle (Standard_Transient)& ent) const333 Standard_CString XSControl_TransferReader::FinalEntityLabel
334   (const Handle(Standard_Transient)& ent) const
335 {
336   Handle(Transfer_ResultFromModel) resu = FinalResult (ent);
337   if (resu.IsNull()) return "";
338   return resu->MainLabel();
339 }
340 
341 
342 //=======================================================================
343 //function : FinalEntityNumber
344 //purpose  :
345 //=======================================================================
346 
FinalEntityNumber(const Handle (Standard_Transient)& ent) const347 Standard_Integer XSControl_TransferReader::FinalEntityNumber
348   (const Handle(Standard_Transient)& ent) const
349 {
350   Handle(Transfer_ResultFromModel) resu = FinalResult (ent);
351   if (resu.IsNull()) return 0;
352   return resu->MainNumber();
353 }
354 
355 
356 //=======================================================================
357 //function : ResultFromNumber
358 //purpose  :
359 //=======================================================================
360 
Handle(Transfer_ResultFromModel)361 Handle(Transfer_ResultFromModel) XSControl_TransferReader::ResultFromNumber
362   (const Standard_Integer num) const
363 {
364   Handle(Transfer_ResultFromModel) res;
365   if ( num<1 || num>myModel->NbEntities() ) return res;
366   if(!myResults.IsBound(num)) return res;
367   res = GetCasted(Transfer_ResultFromModel,myResults.Find(num));
368   return res;
369 }
370 
371 
372 //=======================================================================
373 //function : TransientResult
374 //purpose  :
375 //=======================================================================
376 
Handle(Standard_Transient)377 Handle(Standard_Transient) XSControl_TransferReader::TransientResult
378        (const Handle(Standard_Transient)& ent) const
379 {
380   Handle(Standard_Transient) tres;
381   Handle(Transfer_ResultFromModel) res = FinalResult(ent);
382   if (res.IsNull()) return tres;
383   Handle(Transfer_ResultFromTransient) mres = res->MainResult();
384   if (mres.IsNull()) return tres;
385   DeclareAndCast(Transfer_SimpleBinderOfTransient,bnd,mres->Binder());
386   if (bnd.IsNull()) return tres;
387   if (!bnd->HasResult()) return tres;
388   return bnd->Result();
389 }
390 
391 
392 //=======================================================================
393 //function : ShapeResult
394 //purpose  :
395 //=======================================================================
396 
ShapeResult(const Handle (Standard_Transient)& ent) const397 TopoDS_Shape XSControl_TransferReader::ShapeResult
398   (const Handle(Standard_Transient)& ent) const
399 {
400   TopoDS_Shape tres;    // DOIT RESTER NULL
401   Handle(Transfer_ResultFromModel) res = FinalResult(ent);
402   if (res.IsNull()) return tres;
403   Handle(Transfer_ResultFromTransient) mres = res->MainResult();
404   if (mres.IsNull()) return tres;
405   XSControl_Utils xu;
406   TopoDS_Shape sh = xu.BinderShape (mres->Binder());
407 
408 //   Ouh la vilaine verrue
409   Standard_Real tolang = Interface_Static::RVal("read.encoderegularity.angle");
410   if (tolang <= 0 || sh.IsNull()) return sh;
411   ShapeFix::EncodeRegularity (sh,tolang);
412   return sh;
413 }
414 
415 
416 //=======================================================================
417 //function : ClearResult
418 //purpose  :
419 //=======================================================================
420 
ClearResult(const Handle (Standard_Transient)& ent,const Standard_Integer mode)421 Standard_Boolean XSControl_TransferReader::ClearResult
422   (const Handle(Standard_Transient)& ent, const Standard_Integer mode)
423 {
424   if (myModel.IsNull()) return Standard_False;
425   Standard_Integer num = myModel->Number(ent);
426   if (num == 0) return Standard_False;
427   if(!myResults.IsBound(num)) return Standard_False;
428   if (mode < 0)
429     myResults.ChangeFind(num).Nullify();
430   else {
431     DeclareAndCast(Transfer_ResultFromModel,resu,myResults.Find(num));
432     if (resu.IsNull()) return Standard_False;
433     resu->Strip (mode);
434   }
435   return Standard_True;
436 }
437 
438 
439 //  <<<< >>>>  ATTENTION, pas terrible : mieux vaudrait
440 //             faire une map inverse et la consulter
441 //             ou muscler ResultFromModel ...
442 
443 
444 //=======================================================================
445 //function : EntityFromResult
446 //purpose  :
447 //=======================================================================
448 
Handle(Standard_Transient)449 Handle(Standard_Transient) XSControl_TransferReader::EntityFromResult
450        (const Handle(Standard_Transient)& res, const Standard_Integer mode) const
451 {
452   Handle(Standard_Transient) nulh;
453   //  cas de la shape
454   XSControl_Utils xu;
455   TopoDS_Shape sh = xu.BinderShape (res);
456   if (!sh.IsNull()) return EntityFromShapeResult (sh,mode);
457 
458   Handle(Transfer_Binder) abinder;
459   DeclareAndCast(Transfer_Binder,binder,res);
460   Standard_Integer i,j,nb;
461 
462   if (mode == 0 || mode == 1) {
463     //  on regarde dans le TransientProcess (Roots ou tous Mappeds)
464     if (!myTP.IsNull()) {
465       nb = (mode == 0 ? myTP->NbRoots() : myTP->NbMapped());
466       for (j = 1; j <= nb; j ++) {
467 	i = (mode == 0 ? myModel->Number (myTP->Root(j)) : j);
468 	if (i == 0) continue;
469 	abinder = myTP->MapItem(i);
470 	if (abinder.IsNull()) continue;
471 	if (!binder.IsNull()) {
472 	  if (binder == abinder) return myTP->Mapped(i);
473 	  continue;
474 	}
475 	DeclareAndCast(Transfer_SimpleBinderOfTransient,trb,abinder);
476 	if (trb.IsNull()) continue;
477 	if (trb->Result() == res) return myTP->Mapped(i);
478       }
479     }
480     return nulh;  // Null
481   }
482 
483   //   Recherche dans myResults (racines)
484   //     2 : Main only  3 : Main + one sub;  4 : all
485   if (mode >= 2) {
486     nb = myModel->NbEntities();
487     for (i = 1; i <= nb; i ++) {
488       Handle(Transfer_ResultFromModel) rec = ResultFromNumber (i);
489       if (rec.IsNull()) return nulh;
490       Handle(TColStd_HSequenceOfTransient) list = rec->Results (mode-2);
491       Standard_Integer ir,nr = list->Length();
492       for (ir = 1; ir <= nr; ir ++) {
493         DeclareAndCast(Transfer_ResultFromTransient,rft,list->Value(ir));
494         if (rft.IsNull()) continue;
495         if (rft->Binder() == binder) return rft->Start();
496       }
497 
498     }
499   }
500 
501   //  autres cas non encore implementes
502   return nulh;
503 }
504 
505 
506 //  <<<< >>>>  ATTENTION, encore moins bien que le precedent
507 
508 
509 //=======================================================================
510 //function : EntityFromShapeResult
511 //purpose  :
512 //=======================================================================
513 
Handle(Standard_Transient)514 Handle(Standard_Transient) XSControl_TransferReader::EntityFromShapeResult
515   (const TopoDS_Shape& res, const Standard_Integer mode) const
516 {
517   Handle(Standard_Transient) nulh, samesh, partner;
518   if (res.IsNull()) return nulh;
519   Standard_Integer i,j,nb;
520 
521   XSControl_Utils xu;
522   if (mode == 0 || mode == 1 || mode == -1) {
523     //  on regarde dans le TransientProcess
524     if (!myTP.IsNull()) {
525       nb = (mode == 0 ? myTP->NbRoots() : myTP->NbMapped());
526       for (j = 1; j <= nb; j ++) {
527 	i = (mode == 0 ? myModel->Number (myTP->Root(j)) : j);
528 	if (i == 0) continue;
529 	Handle(Standard_Transient) ent = myTP->Mapped(i);
530 	TopoDS_Shape sh = TransferBRep::ShapeResult (myTP,ent);
531 	if (!sh.IsNull()) {
532 	  if (sh == res) return ent;
533 	  // priorites moindre : Same (tjrs) ou Partner (mode < 0)
534 	  if (sh.IsSame(res)) samesh = ent;
535 	  if (mode == -1 && sh.IsPartner(res)) partner= ent;
536 	}
537       }
538     }
539     //    Ici, pas trouve de vraie egalite. Priorites moindres : Same puis Partner
540     if (!samesh.IsNull())  return samesh;
541     if (!partner.IsNull()) return partner;  // calcule si mode = -1
542     return nulh;
543   }
544 
545   //   Recherche dans myResults (racines)
546   //     2 : Main only  3 : Main + one sub;  4 : all
547   if (mode >= 2) {
548     nb = myModel->NbEntities();
549     for (i = 1; i <= nb; i ++) {
550       Handle(Transfer_ResultFromModel) rec = ResultFromNumber (i);
551       if (rec.IsNull()) continue;
552 
553       Handle(TColStd_HSequenceOfTransient) list = rec->Results (mode-2);
554       Standard_Integer ir,nr = list->Length();
555       for (ir = 1; ir <= nr; ir ++) {
556         DeclareAndCast(Transfer_ResultFromTransient,rft,list->Value(ir));
557         if (rft.IsNull()) continue;
558         TopoDS_Shape sh = xu.BinderShape (rft->Binder());
559         if (!sh.IsNull() && sh == res) return rft->Start();
560       }
561 
562     }
563   }
564 
565   return nulh;
566 }
567 
568 
569 //=======================================================================
570 //function : EntitiesFromShapeList
571 //purpose  :
572 //=======================================================================
573 
Handle(TColStd_HSequenceOfTransient)574 Handle(TColStd_HSequenceOfTransient) XSControl_TransferReader::EntitiesFromShapeList
575        (const Handle(TopTools_HSequenceOfShape)& res,
576         const Standard_Integer mode) const
577 {
578   Handle(TColStd_HSequenceOfTransient) lt = new TColStd_HSequenceOfTransient();
579   if (res.IsNull()) return lt;
580   TopTools_MapOfShape shapes;
581 
582   //  On convertit res en une map, pour test de presence rapide
583   Standard_Integer i, j, nb = res->Length();
584   if (nb == 0) return lt;
585   for (i = 1; i <= nb; i ++)  shapes.Add (res->Value(i));
586 
587   //  A present, recherche et enregistrement
588 
589   XSControl_Utils xu;
590   if (mode == 0 || mode == 1) {
591     //  on regarde dans le TransientProcess
592     if (!myTP.IsNull()) {
593       nb = (mode == 0 ? myTP->NbRoots() : myTP->NbMapped());
594       for (j = 1; j <= nb; j ++) {
595 	i = (mode == 0 ? myModel->Number (myTP->Root(j)) : j);
596 	if (i == 0) continue;
597 	TopoDS_Shape sh = xu.BinderShape (myTP->MapItem(i));
598 	if (!sh.IsNull() && shapes.Contains(sh)) {
599 	  lt->Append (myTP->Mapped(i));
600           j=nb; //skl (for looking for entities in checkbrep)
601         }
602       }
603     }
604   }
605 
606   //   Recherche dans myResults (racines)
607   //     2 : Main only  3 : Main + one sub;  4 : all
608   if (mode >= 2) {
609     nb = myModel->NbEntities();
610     for (i = 1; i <= nb; i ++) {
611       Handle(Transfer_ResultFromModel) rec = ResultFromNumber (i);
612       if (rec.IsNull()) continue;
613 
614       Handle(TColStd_HSequenceOfTransient) list = rec->Results (mode-2);
615       Standard_Integer ir,nr = list->Length();
616       for (ir = 1; ir <= nr; ir ++) {
617         DeclareAndCast(Transfer_ResultFromTransient,rft,list->Value(i));
618         if (rft.IsNull()) continue;
619         TopoDS_Shape sh = xu.BinderShape (rft->Binder());
620         if (!sh.IsNull() && shapes.Contains(sh)) lt->Append (rft->Start());
621       }
622 
623     }
624   }
625 
626   return lt;
627 }
628 
629 
630 //  <<<< >>>>  ATTENTION, level pas traite (utile ?) -> ResultFromModel
631 
632 
633 //=======================================================================
634 //function : CheckList
635 //purpose  :
636 //=======================================================================
637 
CheckList(const Handle (Standard_Transient)& ent,const Standard_Integer level) const638 Interface_CheckIterator XSControl_TransferReader::CheckList
639   (const Handle(Standard_Transient)& ent, const Standard_Integer level) const
640 {
641   Interface_CheckIterator chl;
642   if (myModel.IsNull() || ent.IsNull()) return chl;
643   //  Check-List COMPLETE ... tout le Modele
644   if (ent == myModel) {
645     Standard_Integer i,nb = myModel->NbEntities();
646     for (i = 1; i <= nb; i ++) {
647       Handle(Transfer_ResultFromModel) rec = ResultFromNumber (i);
648       if (!rec.IsNull()) {
649 	Interface_CheckIterator chiter  = rec->CheckList (Standard_False,2);
650 	chl.Merge (chiter);
651       }
652     }
653   }
654   //  Check-List sur une LISTE ...
655   else if (ent->IsKind(STANDARD_TYPE(TColStd_HSequenceOfTransient))) {
656     DeclareAndCast(TColStd_HSequenceOfTransient,list,ent);
657     Standard_Integer i,nb = list->Length();
658     for (i = 1; i <= nb; i ++) {
659       Handle(Transfer_ResultFromModel) rec = FinalResult (list->Value(i));
660       if (!rec.IsNull()) {
661 	Interface_CheckIterator chiter = rec->CheckList (Standard_False,level);
662 	chl.Merge (chiter);
663       }
664     }
665   }
666 
667   //  sinon, Check-List sur une entite : Last ou FinalResult
668   else if (level < 0) {
669     if (myTP.IsNull()) return chl;
670     chl.Add (myTP->Check(ent),myModel->Number(ent));
671   } else {
672     Handle(Transfer_ResultFromModel) rec = FinalResult (ent);
673     if (rec.IsNull()) return chl;
674     chl = rec->CheckList(Standard_False,level);  // manque level ...
675   }
676   if (ent == myModel) chl.SetName ("XSControl : CheckList complete Model");
677   else if (level <  0) chl.SetName ("XSControl : CheckList Last");
678   else if (level == 0) chl.SetName ("XSControl : CheckList Final Main");
679   else if (level == 1) chl.SetName ("XSControl : CheckList Final Main+Subs");
680   else if (level >= 2) chl.SetName ("XSControl : CheckList Final Complete");
681   return chl;
682 }
683 
684 
685 //=======================================================================
686 //function : HasChecks
687 //purpose  :
688 //=======================================================================
689 
HasChecks(const Handle (Standard_Transient)& ent,const Standard_Boolean failsonly) const690 Standard_Boolean XSControl_TransferReader::HasChecks
691   (const Handle(Standard_Transient)& ent, const Standard_Boolean failsonly) const
692 {
693   Handle(Transfer_ResultFromModel) resu = FinalResult (ent);
694   if (resu.IsNull()) return Standard_False;
695   Standard_Integer stat = resu->ComputeCheckStatus (Standard_False);
696   if (stat == 0) return Standard_False;
697   if (stat >  1) return Standard_True;
698   return (!failsonly);
699 }
700 
701 
702 //=======================================================================
703 //function : CheckedList
704 //purpose  :
705 //=======================================================================
706 
Handle(TColStd_HSequenceOfTransient)707 Handle(TColStd_HSequenceOfTransient)  XSControl_TransferReader::CheckedList
708        (const Handle(Standard_Transient)& ent,
709         const Interface_CheckStatus withcheck, const Standard_Boolean level) const
710 {
711   Handle(TColStd_HSequenceOfTransient) res = new TColStd_HSequenceOfTransient();
712   if (ent.IsNull()) return res;
713 
714   if (ent == myModel) {
715     Standard_Integer i,nb = myModel->NbEntities();
716     for (i = 1; i <= nb; i ++) {
717       Handle(Transfer_ResultFromModel) rec = ResultFromNumber (i);
718       if (!rec.IsNull()) res->Append (rec->CheckedList(withcheck,level));
719     }
720   } else if (ent->IsKind(STANDARD_TYPE(TColStd_HSequenceOfTransient))) {
721     DeclareAndCast(TColStd_HSequenceOfTransient,list,ent);
722     Standard_Integer i,nb = list->Length();
723     for (i = 1; i <= nb; i ++) {
724       Handle(Transfer_ResultFromModel) rec = FinalResult (list->Value(i));
725       if (!rec.IsNull()) res->Append (rec->CheckedList(withcheck,level));
726     }
727   } else {
728     Handle(Transfer_ResultFromModel) rec = FinalResult (ent);
729     if (!rec.IsNull()) res = rec->CheckedList(withcheck,level);
730   }
731   return res;
732 }
733 
734 
735 //  ########################################################
736 //  ###########            TRANSFERT            ############
737 //  ########################################################
738 
739 
740 //=======================================================================
741 //function : BeginTransfer
742 //purpose  :
743 //=======================================================================
744 
BeginTransfer()745 Standard_Boolean XSControl_TransferReader::BeginTransfer ()
746 {
747   if (myModel.IsNull()) return Standard_False;
748   if (Actor().IsNull())  return Standard_False;
749   myShapeResult.Nullify();
750 
751   if (myTP.IsNull()) myTP = new Transfer_TransientProcess
752     (myModel->NbEntities());
753 
754   Handle(Transfer_ActorOfTransientProcess) actor;
755   myTP->SetActor (actor);        // -> RAZ
756   actor = Actor();
757   myTP->SetActor (actor);        // Set proprement dit
758   myTP->SetErrorHandle (Standard_True);
759   NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& aTPContext = myTP->Context();
760   aTPContext = myContext;
761   return Standard_True;
762 }
763 
764 
765 //=======================================================================
766 //function : Recognize
767 //purpose  :
768 //=======================================================================
769 
Recognize(const Handle (Standard_Transient)& ent)770 Standard_Boolean XSControl_TransferReader::Recognize
771   (const Handle(Standard_Transient)& ent)
772 {
773   if (myActor.IsNull()) return Standard_False;
774   return myActor->Recognize (ent);
775 }
776 
777 
778 //=======================================================================
779 //function : TransferOne
780 //purpose  :
781 //=======================================================================
782 
TransferOne(const Handle (Standard_Transient)& ent,const Standard_Boolean rec,const Message_ProgressRange & theProgress)783 Standard_Integer XSControl_TransferReader::TransferOne
784   (const Handle(Standard_Transient)& ent,
785    const Standard_Boolean rec,
786    const Message_ProgressRange& theProgress)
787 {
788   if (myActor.IsNull() || myModel.IsNull()) return 0;
789 
790   if (myTP.IsNull())  {  if (!BeginTransfer()) return 0;  }
791 
792   Message_Messenger::StreamBuffer sout = myTP->Messenger()->SendInfo();
793   Standard_Integer level = myTP->TraceLevel();
794 
795 
796   Transfer_TransferOutput TP (myTP,myModel);
797   if (myGraph.IsNull()) myTP->SetModel(myModel);
798   else                  myTP->SetGraph(myGraph);
799 
800   //  pour le log-file
801   if (level > 1) {
802     Standard_Integer num = myModel->Number(ent);
803     Handle(TCollection_HAsciiString) lab = myModel->StringLabel(ent);
804     sout<<"\n*******************************************************************\n";
805     sout << "******           Transferring one Entity                     ******"<<std::endl;
806     if (!lab.IsNull())
807       sout<<"******    N0 in file : "<<Interface_MSG::Blanks(num,5)<<num
808 	  <<"      Ident : "<<lab->ToCString()
809 	  <<  Interface_MSG::Blanks(14 - lab->Length())<<"******\n";
810     sout << "******    Type : "<<myModel->TypeName(ent,Standard_False)
811         <<  Interface_MSG::Blanks((Standard_Integer) (44 - strlen(myModel->TypeName(ent,Standard_False))))
812 	<<  "******";
813     sout<<"\n*******************************************************************\n";
814   }
815 
816   //  seule difference entre TransferRoots et TransferOne
817   Standard_Integer res = 0;
818   Handle(Standard_Transient) obj = ent;
819   TP.Transfer (obj, theProgress);
820   if (theProgress.UserBreak())
821     return res;
822   myTP->SetRoot (obj);
823 
824   //  Resultat ...
825   Handle(Transfer_Binder) binder = myTP->Find (obj);
826   if (binder.IsNull()) return res;
827   if (rec) RecordResult (obj);
828 
829   if (!binder->HasResult()) return res;
830   res ++;
831 
832   return res;
833 }
834 
835 
836 //=======================================================================
837 //function : TransferList
838 //purpose  :
839 //=======================================================================
840 
TransferList(const Handle (TColStd_HSequenceOfTransient)& list,const Standard_Boolean rec,const Message_ProgressRange & theProgress)841 Standard_Integer XSControl_TransferReader::TransferList
842   (const Handle(TColStd_HSequenceOfTransient)& list,
843    const Standard_Boolean rec,
844    const Message_ProgressRange& theProgress)
845 {
846   if (myActor.IsNull() || myModel.IsNull()) return 0;
847 
848   if (myTP.IsNull())  {  if (!BeginTransfer()) return 0;  }
849 
850   Standard_Integer level = myTP->TraceLevel();
851 
852   Transfer_TransferOutput TP (myTP,myModel);
853   if (myGraph.IsNull()) myTP->SetModel(myModel);
854   else                  myTP->SetGraph(myGraph);
855 
856   Standard_Integer i,nb = list->Length();
857 
858   //   Pour le log-file
859   if (level > 0) {
860     Message_Messenger::StreamBuffer sout = myTP->Messenger()->SendInfo();
861     sout<<"\n*******************************************************************\n";
862     sout << "******           Transferring a list of "<<Interface_MSG::Blanks(nb,5)<<" Entities       ******"<<std::endl;
863     sout<<"\n*******************************************************************\n";
864 
865     Handle(IFSelect_SignatureList) sl = new IFSelect_SignatureList;
866     for (i = 1; i <= nb; i ++)
867       sl->Add (list->Value(i), myModel->TypeName(list->Value(i),Standard_False));
868     sl->SetName ("Entities to Transfer");
869     sl->PrintCount (sout);
870     sout<<"\n*******************************************************************\n";
871   }
872 
873   //  seule difference entre TransferRoots et TransferOne
874   Standard_Integer res = 0;
875   nb = list->Length();
876   Handle(Standard_Transient) obj;
877   Message_ProgressScope aPS(theProgress, NULL, nb);
878   for (i = 1; i <= nb && aPS.More(); i++) {
879     obj = list->Value(i);
880     TP.Transfer (obj, aPS.Next());
881     myTP->SetRoot (obj);
882 
883     //  Resultat ...
884     Handle(Transfer_Binder) binder = myTP->Find (obj);
885     if (binder.IsNull()) continue;
886     if (rec) RecordResult (obj);
887 
888     if (!binder->HasResult()) continue;
889     res ++;
890   }
891   return res;
892 }
893 
894 
895 //  <<<< >>>>  passage Graph : judicieux ?
896 
897 
898 //=======================================================================
899 //function : TransferRoots
900 //purpose  :
901 //=======================================================================
902 
TransferRoots(const Interface_Graph & G,const Message_ProgressRange & theProgress)903 Standard_Integer XSControl_TransferReader::TransferRoots(const Interface_Graph& G,
904                                                          const Message_ProgressRange& theProgress)
905 {
906   if (myModel != G.Model()) return -1;
907   if (!BeginTransfer()) return -1;
908   Standard_Integer level = myTP->TraceLevel();
909 
910   Transfer_TransferOutput TP (myTP,myModel);
911   if (myGraph.IsNull()) myTP->SetModel(myModel);
912   else                  myTP->SetGraph(myGraph);
913 
914   //   Pour le log-file
915   if (level > 0) {
916     Interface_EntityIterator roots = G.RootEntities();
917     Standard_Integer nb = roots.NbEntities();
918     Message_Messenger::StreamBuffer sout = myTP->Messenger()->SendInfo();
919     sout<<"\n*******************************************************************\n";
920     sout << "******           Transferring the "<<Interface_MSG::Blanks(nb,5)<<" Root Entities        ******"<<std::endl;
921     sout<<"\n*******************************************************************\n";
922     Handle(IFSelect_SignatureList) sl = new IFSelect_SignatureList;
923     for (roots.Start(); roots.More(); roots.Next())
924       sl->Add (roots.Value(),myModel->TypeName(roots.Value(),Standard_False));
925     sl->SetName ("Entities to Transfer");
926     sl->PrintCount (sout);
927     sout<<"\n*******************************************************************\n";
928   }
929 
930   TP.TransferRoots (G, theProgress);
931   if (theProgress.UserBreak())
932     return -1;
933 
934   //  Les entites transferees sont notees "asmain"
935   Standard_Integer i,n = myTP->NbMapped();
936   for (i = 1; i <= n; i ++) {
937     Handle(Standard_Transient) ent = myTP->Mapped(i);
938     Handle(Transfer_Binder)    bnd = myTP->MapItem(i);
939     if (bnd.IsNull()) continue;
940     if (!bnd->HasResult()) continue;
941     RecordResult (ent);
942   }
943 
944   //  Resultat ... on note soigneuseument les Shapes
945   myShapeResult = TransferBRep::Shapes (myTP,Standard_True);
946   // ????  Et ici, il faut alimenter Imagine ...
947   return myShapeResult->Length();
948 }
949 
950 
951 //=======================================================================
952 //function : TransferClear
953 //purpose  :
954 //=======================================================================
955 
TransferClear(const Handle (Standard_Transient)& ent,const Standard_Integer level)956 void XSControl_TransferReader::TransferClear(const Handle(Standard_Transient)& ent,
957                                              const Standard_Integer level)
958 {
959   if (myTP.IsNull()) return;
960   if (ent == myModel) {  myTP->Clear();  return;  }
961 
962   myTP->RemoveResult (ent,level);
963   ClearResult (ent,-1);
964 
965 }
966 
967 
968 //=======================================================================
969 //function : PrintStats
970 //purpose  :
971 //=======================================================================
972 
PrintStats(Standard_OStream & sout,const Standard_Integer what,const Standard_Integer mode) const973 void XSControl_TransferReader::PrintStats (Standard_OStream& sout,
974                                            const Standard_Integer what,
975                                            const Standard_Integer mode) const
976 {
977   //  A ameliorer ... !
978   sout<<"\n*******************************************************************\n";
979   sout << "******        Statistics on Transfer (Read)                  ******"<<std::endl;
980   sout<<"\n*******************************************************************\n";
981   if (what > 10)  {  sout<<" ***  Not yet implemented"<<std::endl;  return;  }
982   if (what < 10)  {
983     sout << "******        Data recorded on Last Transfer                 ******"<<std::endl;
984     PrintStatsProcess (myTP,what,mode);
985   }
986   //  reste  what = 10 : on liste les racines des final results
987   sout << "******        Final Results                                  ******"<<std::endl;
988   if (myModel.IsNull())  {  sout<<"****    Model unknown"<<std::endl;  return;  }
989   Handle(TColStd_HSequenceOfTransient) list = RecordedList();
990   Standard_Integer i, nb = list->Length();
991   Handle(IFSelect_SignatureList) counter;
992   if (mode > 2) counter = new IFSelect_SignatureList (mode == 6);
993   IFSelect_PrintCount pcm = IFSelect_CountByItem;
994   if (mode == 6) pcm = IFSelect_ListByItem;
995 
996   sout<<"****    Nb Recorded : "<<nb<<" : entities n0s : ";
997   for (i = 1; i <= nb; i ++) {
998     Handle(Standard_Transient) ent = list->Value(i);
999     if (mode == 0)  {  sout<<"  "<<myModel->Number(ent); continue;  }
1000     if (mode == 1 || mode == 2) {
1001       sout<<"[ "<<Interface_MSG::Blanks (i,6)<<" ]:";
1002       myModel->Print (ent, sout);
1003       sout<<"  Type:"<<myModel->TypeName(ent,Standard_False);
1004     }
1005     if (mode >= 3 && mode <= 6) {
1006       counter->Add (ent,myModel->TypeName(ent,Standard_False));
1007     }
1008   }
1009   if (!counter.IsNull()) counter->PrintList (sout, myModel, pcm);
1010 
1011   sout<<std::endl;
1012 }
1013 
1014 
1015 //  ########################################################
1016 //  ###########            TRANSFERT            ############
1017 
1018 
1019 //=======================================================================
1020 //function : LastCheckList
1021 //purpose  :
1022 //=======================================================================
1023 
LastCheckList() const1024 Interface_CheckIterator  XSControl_TransferReader::LastCheckList () const
1025 {
1026   Interface_CheckIterator chl;
1027   if (!myTP.IsNull()) chl = myTP->CheckList (Standard_False);
1028   return chl;
1029 }
1030 
1031 
1032 //=======================================================================
1033 //function : LastTransferList
1034 //purpose  :
1035 //=======================================================================
1036 
Handle(TColStd_HSequenceOfTransient)1037 Handle(TColStd_HSequenceOfTransient) XSControl_TransferReader::LastTransferList
1038        (const Standard_Boolean roots) const
1039 {
1040   Handle(TColStd_HSequenceOfTransient) li = new TColStd_HSequenceOfTransient();
1041   if (myTP.IsNull()) return li;
1042   Standard_Integer i,j,nb =
1043     (roots ? myTP->NbRoots() : myTP->NbMapped());
1044   for (j = 1; j <= nb; j ++) {
1045     i = (roots ? myModel->Number (myTP->Root(j)) : j);
1046     Handle(Transfer_Binder) bnd = myTP->MapItem(i);
1047     if (bnd.IsNull()) continue;
1048     if (!bnd->HasResult()) continue;
1049     li->Append (myTP->Mapped(i));
1050   }
1051   return li;
1052 }
1053 
1054 
1055 //=======================================================================
1056 //function : ShapeResultList
1057 //purpose  :
1058 //=======================================================================
1059 
Handle(TopTools_HSequenceOfShape)1060 const Handle(TopTools_HSequenceOfShape) & XSControl_TransferReader::ShapeResultList
1061   (const Standard_Boolean rec)
1062 {
1063   if (!rec) {
1064     if (myShapeResult.IsNull()) myShapeResult = TransferBRep::Shapes (myTP,Standard_True);
1065     if (myShapeResult.IsNull()) myShapeResult = new TopTools_HSequenceOfShape();
1066   } else {
1067     if (myShapeResult.IsNull()) myShapeResult = new TopTools_HSequenceOfShape();
1068     if (myModel.IsNull()) return myShapeResult;
1069     Handle(TColStd_HSequenceOfTransient) li = RecordedList();
1070     myShapeResult = new TopTools_HSequenceOfShape();
1071     Standard_Integer i, nb = myModel->NbEntities();
1072     TopoDS_Shape sh;
1073     for (i = 1; i <= nb; i ++) {
1074       sh = ShapeResult (myModel->Value(i));
1075       if (!sh.IsNull()) myShapeResult->Append(sh);
1076     }
1077   }
1078   return myShapeResult;
1079 }
1080 
1081 
1082 //  ****    UTILITAIRE DE STATISTIQUES GENERALES
1083 
1084 // BinderStatus retourne une valeur :
1085 // 0 Binder Null.   1 void  2 Warning seul  3 Fail seul
1086 // 11 Resultat OK. 12 Resultat+Warning. 13 Resultat+Fail
1087 
1088 //=======================================================================
1089 //function :
1090 //purpose  :
1091 //=======================================================================
BinderStatus(const Handle (Transfer_Binder)& binder,char * mess)1092 static Standard_Integer BinderStatus (const Handle(Transfer_Binder)& binder, char* mess)
1093 {
1094   Standard_Integer stat = 0;
1095   mess[0] = '\0';
1096   if (binder.IsNull())  {  sprintf (mess,"(no data recorded)");  return 0;  }
1097   Interface_CheckStatus cst = binder->Check()->Status();
1098   if (cst == Interface_CheckOK) {
1099     stat = 11;
1100     if (binder->HasResult()) sprintf(mess,"%s",binder->ResultTypeName());
1101     else { sprintf(mess,"(no result)"); stat = 1; }
1102   } else if (cst == Interface_CheckWarning) {
1103     stat = 12;
1104     if (binder->HasResult()) sprintf(mess,"%s  (+ warning)",binder->ResultTypeName());
1105     else { sprintf(mess,"(warning)"); stat = 2; }
1106   } else if (cst == Interface_CheckFail) {
1107     stat = 13;
1108     if (binder->HasResult()) sprintf(mess,"%s  (+ FAIL)",binder->ResultTypeName());
1109     else { sprintf(mess,"(FAIL)"); stat = 3; }
1110   }
1111   return stat;
1112 }
1113 
1114 
1115 //=======================================================================
1116 //function :
1117 //purpose  :
1118 //=======================================================================
PrintPercent(const Handle (Message_Messenger)& sout,const Standard_CString mess,const Standard_Integer nb,const Standard_Integer nl)1119 static void PrintPercent(const Handle(Message_Messenger)& sout, const Standard_CString mess,
1120                          const Standard_Integer nb, const Standard_Integer nl)
1121 {
1122   if (nb <= 0 || nl == 0) return;
1123   Message_Messenger::StreamBuffer aSender = sout->SendInfo();
1124   aSender<<"******      "<<mess<<": ";
1125   if      (nb == nl)       aSender<<"100 %"<<std::endl;
1126   else if (nb*100/nl == 0) aSender<<"< 1 %"<<std::endl;
1127   else            aSender<<(nb*100/nl < 10 ? "  " : " ")<<nb*100/nl<<" %"<<std::endl;
1128 }
1129 
1130 
1131 //=======================================================================
1132 //function : PrintStatsProcess
1133 //purpose  :
1134 //=======================================================================
1135 
PrintStatsProcess(const Handle (Transfer_TransientProcess)& TP,const Standard_Integer what,const Standard_Integer mode)1136 void XSControl_TransferReader::PrintStatsProcess(const Handle(Transfer_TransientProcess)& TP,
1137                                                  const Standard_Integer what,
1138                                                  const Standard_Integer mode)
1139 {
1140   Handle(TColStd_HSequenceOfTransient) list;  // null
1141   XSControl_TransferReader::PrintStatsOnList (TP,list,what,mode);
1142 }
1143 
1144 
1145 //=======================================================================
1146 //function : PrintStatsOnList
1147 //purpose  :
1148 //=======================================================================
1149 
PrintStatsOnList(const Handle (Transfer_TransientProcess)& TP,const Handle (TColStd_HSequenceOfTransient)& list,const Standard_Integer what,const Standard_Integer mode)1150 void XSControl_TransferReader::PrintStatsOnList(const Handle(Transfer_TransientProcess)& TP,
1151                                                 const Handle(TColStd_HSequenceOfTransient)& list,
1152                                                 const Standard_Integer what,
1153                                                 const Standard_Integer mode)
1154 {
1155   Message_Messenger::StreamBuffer sout = TP->Messenger()->SendInfo();
1156 
1157   char mess[250];
1158   if (TP.IsNull()) return;
1159   if (what == 0) {  TP->PrintStats(0,sout);  return;  }
1160 
1161   sout<<"\n*******************************************************************\n";
1162   sout << "******        Statistics on Transfer Process (Read)          ******"<<std::endl;
1163   if (what == 1) sout << "******        Individual Transfers  (Roots)                  ******\n";
1164   if (what == 2) sout << "******        All recorded data about Transfer               ******\n";
1165   if (what == 3) sout << "******        Abnormal records                               ******\n";
1166   if (what == 1 || what == 2 || what == 3) {
1167     if (mode == 0) sout<<"******        (n0s of recorded entities)                     ******\n";
1168     if (mode == 1) sout<<"******        (per entity : type + result)                   ******\n";
1169     if (mode == 2) sout<<"******        (per entity : type + result/status)            ******\n";
1170     if (mode == 3) sout<<"******        (count per type of entity)                     ******\n";
1171     if (mode == 4) sout<<"******        (count per type of result)                     ******\n";
1172     if (mode == 5) sout<<"******   (count per couple entity-type / result-type/status) ******\n";
1173     if (mode == 6) sout<<"******   (list per couple entity-type / result-type/status)  ******\n";
1174   }
1175   if (what == 4) sout << "******        Check messages                                 ******\n";
1176   if (what == 5) sout << "******        Fail  messages                                 ******\n";
1177   sout<<"*******************************************************************\n";
1178 
1179   //  Cas what = 1,2,3 : contenu du TP (binders)
1180 
1181   Standard_Boolean nolist = list.IsNull();
1182   Handle(Interface_InterfaceModel) model = TP->Model();
1183   if (what >= 1 && what <= 3) {
1184 
1185     Standard_Integer stat;
1186     Standard_Integer nbv = 0, nbw = 0, nbf = 0, nbr = 0, nbrw = 0, nbrf = 0, nbnr = 0, nbi = 0;
1187     Transfer_IteratorOfProcessForTransient itrp(Standard_True);
1188     if (what == 1) itrp = TP->RootResult(Standard_True);
1189     if (what == 2) itrp = TP->CompleteResult(Standard_True);
1190     if (what == 3) itrp = TP->AbnormalResult();
1191     Standard_Integer i = 0, nb = itrp.Number();
1192     if (!nolist) itrp.Filter (list);
1193     Standard_Integer nl = itrp.Number();    // apres filtrage
1194     Handle(IFSelect_SignatureList) counter;
1195     if (mode > 2) counter = new IFSelect_SignatureList (mode == 6);
1196     Standard_Boolean notrec = (!nolist && mode > 2);  // noter les "no record"
1197     IFSelect_PrintCount pcm = IFSelect_CountByItem;
1198     if (mode == 6) pcm = IFSelect_ListByItem;
1199 
1200     sout  <<"****        Entities in Model   : "<<model->NbEntities()<<std::endl;
1201     sout  <<"****        Nb Items (Transfer) : "<<nb<<std::endl;
1202     if (!nolist)
1203       sout<<"****        Nb Items (Listed)   : "<<nl<<std::endl;
1204 
1205     for (itrp.Start(); itrp.More(); itrp.Next()) {
1206       nbi ++;
1207       Handle(Transfer_Binder) binder = itrp.Value();
1208       Handle(Standard_Transient) ent = itrp.Starting();
1209       if (binder.IsNull())  {
1210 	nbnr ++;
1211 	if (notrec) counter->Add(ent,"(not recorded)");
1212 	else if (mode == 1 || mode == 2) {
1213 	  sout<<"["<<Interface_MSG::Blanks (nbi,4)<<nbi<<" ]:";
1214 	  model->Print (ent, sout);
1215 	  sout<<"   "<<model->TypeName(ent,Standard_False)<<"  (not recorded)"<<std::endl;
1216 	  continue;
1217 	}
1218       }
1219       if (mode == 0)  {  sout<<"  "<<model->Number(ent); continue;  }
1220       if (mode != 3) {
1221 	stat = BinderStatus(binder,mess);
1222         // 0 Binder Null.   1 void  2 Warning seul  3 Fail seul
1223         // 11 Resultat OK. 12 Resultat+Warning. 13 Resultat+Fail
1224 	if (stat ==  0 || stat == 1) nbv ++;
1225 	if (stat ==  2) nbw ++;
1226 	if (stat ==  3) nbf ++;
1227 	if (stat == 11) nbr ++;
1228 	if (stat == 12) nbrw ++;
1229 	if (stat == 13) nbrf ++;
1230       }
1231 
1232       //  mode : 0 list num;  1 : num+label + type + result (abrege);  2 : complet
1233       if (mode == 1 || mode == 2) {
1234 	sout<<"["<<Interface_MSG::Blanks (i,4)<<i<<" ]:";
1235 	model->Print (ent, sout);
1236 	sout<<"   "<<model->TypeName(ent,Standard_False);
1237 	sout<<"	Result:"<<mess<<std::endl;
1238 	if (mode == 1) continue;
1239 
1240 	const Handle(Interface_Check)& ch = binder->Check();
1241 	Standard_Integer newi,newnbw = ch->NbWarnings(), newnbf = ch->NbFails();
1242 
1243 	if (newnbw > 0) {
1244 	  sout<<" - Warnings : "<<newnbw<<":\n";
1245 	  for (newi = 1; newi <= newnbw; newi ++) sout<<ch->CWarning(newi)<<std::endl;
1246 	}
1247 	if (newnbf > 0) {
1248 	  sout<<" - Fails : "<<newnbf<<":\n";
1249 	  for (newi = 1; newi <= newnbf; newi ++) sout<<ch->CFail(newi)<<std::endl;
1250 	}
1251 	continue;
1252       }
1253 
1254       //  mode : 3, counts per type of starting entity (class type)
1255       //         4 : counts per result type and/or status
1256       //         5 : counts per couple (starting type / result type/status)
1257       //         6 : idem plus gives for each item, the list of numbers of
1258       //                  entities in the starting model
1259       if (mode >= 3 && mode <= 6) {
1260         //IFSelect_PrintCount newpcm = IFSelect_CountByItem;
1261         //if (mode == 6) newpcm = IFSelect_ListByItem;
1262 	if (mode == 3) counter->Add (ent,model->TypeName(ent,Standard_False));
1263 	if (mode == 4) counter->Add (ent,mess);
1264 	if (mode >= 5) {
1265 	  TCollection_AsciiString mest (model->TypeName(ent,Standard_False));
1266 	  mest.AssignCat("	-> ");
1267 	  mest.AssignCat(mess);
1268           //sprintf(mest,"%s	-> %s",model->TypeName(ent,Standard_False),mess);
1269 	  counter->Add (ent,mest.ToCString());
1270 	}
1271       }
1272 
1273       //    Fin de l iteration
1274     }
1275     if (!counter.IsNull()) counter->PrintList (sout, model, pcm);
1276     else sout<<std::endl;
1277     //    Pourcentages
1278     if (mode != 3 && nbi > 0) {
1279       sout << "******        Percentages according Transfer Status          ******"<<std::endl;
1280       PrintPercent (TP->Messenger(),"Result          ",nbr+nbrw,nl);
1281       PrintPercent (TP->Messenger(),"Result + FAIL   ",nbrf,nl);
1282       PrintPercent (TP->Messenger(),"FAIL, no Result ",nbf,nl);
1283       PrintPercent (TP->Messenger(),"Just Warning    ",nbw,nl);
1284       PrintPercent (TP->Messenger(),"Nothing Recorded",nbnr,nl);
1285 /*      if (nbr+nbrw > 0)
1286 	sout<<"******      Result          : "<< (nbr+nbrw)*100/nl<<" %"<<std::endl;
1287       if (nbrf > 0)
1288 	sout<<"******      Result + FAIL   : "<< (nbrf)*100/nl<<" %"<<std::endl;
1289       if (nbf > 0)
1290 	sout<<"******      FAIL, no Result : "<< (nbf)*100/nl<<" %"<<std::endl;
1291       if (nbw > 0)
1292 	sout<<"******      Just Warning    : "<< (nbw)*100/nl<<" %"<<std::endl;
1293       if (nbnr > 0)
1294 	sout<<"******      Nothing Recorded: "<< (nbnr)*100/nl<<" %"<<std::endl; */
1295     }
1296     return;
1297   }
1298 
1299   //  Cas  what = 4,5 : check-list
1300 
1301   if (what == 4 || what == 5) {
1302 
1303     Interface_CheckIterator chl = TP->CheckList(Standard_False);
1304     chl.SetName("** TRANSFER READ CHECK **");
1305     if (mode == 0)
1306     {
1307       chl.Print (sout, model, (what == 5));
1308     }
1309     else {
1310       IFSelect_PrintCount pcm = IFSelect_CountByItem;
1311       if (mode == 2) pcm = IFSelect_ListByItem;
1312       Handle(IFSelect_CheckCounter) counter = new IFSelect_CheckCounter(Standard_True);
1313       counter->Analyse   (chl,model,Standard_True,(what == 5));
1314       counter->PrintList (sout, model, pcm);
1315     }
1316   }
1317 
1318 }
1319