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