0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / IFSelect / IFSelect_CheckCounter.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
42cf5bc1 15#include <IFSelect_CheckCounter.hxx>
16#include <Interface_Check.hxx>
17#include <Interface_CheckIterator.hxx>
18#include <Interface_InterfaceModel.hxx>
19#include <MoniTool_SignText.hxx>
20#include <Standard_Transient.hxx>
21#include <Standard_Type.hxx>
7fd59977 22
42cf5bc1 23#include <stdio.h>
92efcf78 24IMPLEMENT_STANDARD_RTTIEXT(IFSelect_CheckCounter,IFSelect_SignatureList)
25
7fd59977 26//=======================================================================
27//function : IFSelect_CheckCounter
28//purpose :
29//=======================================================================
7fd59977 30IFSelect_CheckCounter::IFSelect_CheckCounter(const Standard_Boolean withlist)
31 : IFSelect_SignatureList (withlist)
32{
33 SetName("Check");
34}
35
36
37//=======================================================================
38//function : SetSignature
39//purpose :
40//=======================================================================
41
42void IFSelect_CheckCounter::SetSignature(const Handle(MoniTool_SignText)& sign)
43{
44 thesign = sign;
45}
46
47
48//=======================================================================
49//function : Signature
50//purpose :
51//=======================================================================
52
53Handle(MoniTool_SignText) IFSelect_CheckCounter::Signature () const
54{
55 return thesign;
56}
57
58
59//=======================================================================
60//function : Analyse
61//purpose :
62//=======================================================================
63
64void IFSelect_CheckCounter::Analyse(const Interface_CheckIterator& list,
65 const Handle(Interface_InterfaceModel)& model,
66 const Standard_Boolean original,
67 const Standard_Boolean failsonly)
68{
69 Standard_Integer i,nb,num, nbe = (model.IsNull() ? 0 : model->NbEntities());
70 char mess[300];
71 sprintf (mess,"Check %s",list.Name());
72 SetName (mess);
73 for (list.Start(); list.More(); list.Next()) {
74 num = list.Number();
75 Handle(Standard_Transient) ent;
76 const Handle(Interface_Check) check = list.Value();
77 ent = check->Entity();
78 if (ent.IsNull() && num > 0 && num <= nbe) ent = model->Value(num);
79 nb = check->NbFails();
80 Standard_CString tystr = NULL;
81 if (!ent.IsNull()) {
82 if (!thesign.IsNull()) tystr = thesign->Text (ent,model).ToCString();
83 else if (!model.IsNull()) tystr = model->TypeName (ent);
84 else tystr =
85 Interface_InterfaceModel::ClassName(ent->DynamicType()->Name());
86 }
87 for (i = 1; i <= nb; i ++) {
88 if (ent.IsNull()) sprintf(mess,"F: %s",check->CFail(i,original));
89 else sprintf(mess,"F:%s: %s",tystr,check->CFail(i,original));
90 Add (ent,mess);
91 }
92 nb = 0;
93 if (!failsonly) nb = check->NbWarnings();
94 for (i = 1; i <= nb; i ++) {
95 if (ent.IsNull()) sprintf(mess,"W: %s",check->CWarning(i,original));
96 else sprintf(mess,"W:%s: %s",tystr,check->CWarning(i,original));
97 Add (ent,mess);
98 }
99 }
100}