0af1263b30084412a838ee53b807fbb3b21b8c73
[occt.git] / src / Transfer / Transfer_FinderProcess.cxx
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
15 #include <Interface_Check.hxx>
16 #include <Interface_InterfaceModel.hxx>
17 #include <Interface_MSG.hxx>
18 #include <Transfer_Binder.hxx>
19 #include <Transfer_Finder.hxx>
20 #include <Transfer_FinderProcess.hxx>
21 #include <Transfer_TransientMapper.hxx>
22
23 IMPLEMENT_STANDARD_RTTIEXT(Transfer_FinderProcess,Transfer_ProcessForFinder)
24
25 Transfer_FinderProcess::Transfer_FinderProcess (const Standard_Integer nb)
26     : Transfer_ProcessForFinder (nb)    {  }
27  
28     void Transfer_FinderProcess::SetModel
29   (const Handle(Interface_InterfaceModel)& model)
30       {  themodel = model;  }
31  
32     Handle(Interface_InterfaceModel)  Transfer_FinderProcess::Model () const
33       {  return themodel;  }
34  
35
36     Standard_Integer  Transfer_FinderProcess::NextMappedWithAttribute
37   (const Standard_CString name, const Standard_Integer num0) const
38 {
39   Standard_Integer num, nb = NbMapped();
40   for (num = num0+1; num <= nb; num ++) {
41     Handle(Transfer_Finder) fnd = Mapped (num);
42     if (fnd.IsNull()) continue;
43     if (!fnd->Attribute(name).IsNull()) return num;
44   }
45   return 0;
46 }
47
48     Handle(Transfer_TransientMapper)  Transfer_FinderProcess::TransientMapper
49   (const Handle(Standard_Transient)& obj) const
50 {
51   Handle(Transfer_TransientMapper) mapper = new Transfer_TransientMapper(obj);
52   Standard_Integer index = MapIndex (mapper);
53   if (index == 0) return mapper;
54   return Handle(Transfer_TransientMapper)::DownCast(Mapped(index));
55 }
56
57
58 void  Transfer_FinderProcess::PrintTrace (const Handle(Transfer_Finder)& start, Standard_OStream& S) const
59 {
60   if (!start.IsNull()) S << " Type:" << start->ValueTypeName();
61 }
62
63 void  Transfer_FinderProcess::PrintStats (const Standard_Integer mode, Standard_OStream& S) const
64 {
65   S<<"\n*******************************************************************\n";
66   if (mode == 1) {    //  Statistiques de base
67     S<< "********                 Basic Statistics                  ********"<<std::endl;
68
69     Standard_Integer nbr = 0, nbe = 0, nbw = 0;
70     Standard_Integer i, max = NbMapped(), nbroots = NbRoots();
71     S<< "****        Nb Final Results    : "<< nbroots <<std::endl;
72
73     for (i = 1; i <= max; i ++) {
74       const Handle(Transfer_Binder)& binder = MapItem(i);
75       if (binder.IsNull()) continue;
76       const Handle(Interface_Check) ach = binder->Check();
77       Transfer_StatusExec stat = binder->StatusExec();
78       if (stat != Transfer_StatusInitial && stat != Transfer_StatusDone)
79         nbe ++;
80       else {
81         if (ach->NbWarnings() > 0) nbw  ++;
82         if (binder->HasResult())  nbr ++;
83       }
84     }
85     if (nbr > nbroots)
86       S<<"****      ( Itermediate Results : "<<nbr-nbroots <<" )\n";
87     if (nbe > 0)
88       S<<"****                  Errors on :"<<Interface_MSG::Blanks(nbe,4)<<nbe<<" Entities\n";
89     if (nbw > 0)
90       S<<"****                Warnings on : "<<Interface_MSG::Blanks(nbw,4)<<nbw<<" Entities\n";
91     S<<"*******************************************************************";
92   }
93   S<<std::endl;
94 }