0024057: Eliminate compiler warning C4100 in MSVC++ with warning level 4
[occt.git] / src / IGESSelect / IGESSelect_CounterOfLevelNumber.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
7 //
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10 //
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
17
18 #include <IGESSelect_CounterOfLevelNumber.ixx>
19 #include <IGESData_IGESEntity.hxx>
20 #include <IGESGraph_DefinitionLevel.hxx>
21 #include <Dico_DictionaryOfInteger.hxx>
22 #include <Interface_Macros.hxx>
23 #include <stdio.h>
24
25 #include <Message_Messenger.hxx>
26
27 IGESSelect_CounterOfLevelNumber::IGESSelect_CounterOfLevelNumber
28   (const Standard_Boolean withmap, const Standard_Boolean withlist)
29     : IFSelect_SignCounter (withmap,withlist)
30       {  thehigh = thenblists = 0;  SetName("IGES Level Number");  }
31
32     void  IGESSelect_CounterOfLevelNumber::Clear ()
33       {  IFSelect_SignCounter::Clear();
34          thelevels.Nullify();  thehigh = thenblists = 0;  }
35
36
37     void  IGESSelect_CounterOfLevelNumber::AddSign
38   (const Handle(Standard_Transient)& ent,
39    const Handle(Interface_InterfaceModel)& /*model*/)
40 {
41   DeclareAndCast(IGESData_IGESEntity,igesent,ent);
42   if (igesent.IsNull()) return;
43   DeclareAndCast(IGESGraph_DefinitionLevel,levelist,igesent->LevelList());
44   Standard_Integer level = igesent->Level();
45   if (levelist.IsNull() && level < 0) return;
46
47 //  Enregistrer ce/ces niveau(x)
48   if (levelist.IsNull()) AddLevel(ent,level);
49   else {
50     Standard_Integer nb = levelist->NbPropertyValues();
51     for (Standard_Integer i = 1; i <= nb; i ++) {
52       level = levelist->LevelNumber(i);
53       AddLevel(ent,level);
54     }
55     AddLevel(ent,-1);
56   }
57 }
58
59
60     void  IGESSelect_CounterOfLevelNumber::AddLevel
61   (const Handle(Standard_Transient)& ent, const Standard_Integer level)
62 {
63   if (level < 0) {
64     thenblists ++;
65     Add (ent,"LEVEL LIST");
66     return;
67   }
68   if (thelevels.IsNull()) { thelevels =
69     new TColStd_HArray1OfInteger ( 0, (level > 100 ? level : 100) );
70                             thelevels->Init(0); }
71   Standard_Integer upper = thelevels->Upper();
72   if (level > upper) {
73     Handle(TColStd_HArray1OfInteger) levels =
74       new TColStd_HArray1OfInteger (0,level + 100);  levels->Init(0);
75     for (Standard_Integer i = 1; i <= upper; i ++)
76       levels->SetValue(i,thelevels->Value(i));
77     thelevels = levels;
78   }
79   thelevels->SetValue (level,thelevels->Value(level)+1);
80   if (level > thehigh) thehigh = level;
81
82 //  if (level == 0) Add(ent," NO LEVEL");
83 //  else {
84     char signature[30];
85     sprintf (signature,"%7d",level);
86     Add (ent,signature);
87 //  }
88 }
89
90
91     Standard_Integer  IGESSelect_CounterOfLevelNumber::HighestLevel () const
92       {  return thehigh;  }
93
94     Standard_Integer  IGESSelect_CounterOfLevelNumber::NbTimesLevel
95   (const Standard_Integer level) const
96 {
97   if (level < 0) return thenblists;
98   if (level > thehigh) return 0;
99   return thelevels->Value(level);
100 }
101
102
103     Handle(TColStd_HSequenceOfInteger)  IGESSelect_CounterOfLevelNumber::Levels
104   () const
105 {
106   Handle(TColStd_HSequenceOfInteger) list = new TColStd_HSequenceOfInteger ();
107   for (Standard_Integer i = 1; i <= thehigh; i ++) {
108     if (thelevels->Value(i) > 0) list->Append(i);
109   }
110   return list;
111 }
112
113
114     Handle(TCollection_HAsciiString)  IGESSelect_CounterOfLevelNumber::Sign
115   (const Handle(Standard_Transient)& ent,
116    const Handle(Interface_InterfaceModel)& /*model*/) const
117 {
118   Handle(TCollection_HAsciiString) res;
119 //  reprend les termes de AddSign pour la preparation (lecture du level) ...
120   DeclareAndCast(IGESData_IGESEntity,igesent,ent);
121   if (igesent.IsNull()) return res;
122   DeclareAndCast(IGESGraph_DefinitionLevel,levelist,igesent->LevelList());
123   Standard_Integer level = igesent->Level();
124   if (levelist.IsNull() && level < 0) return res;
125
126 //  puis ceux de AddLevel pour calculer la signature
127   if (level < 0) return new TCollection_HAsciiString ("LEVEL LIST");
128   char signature[30];
129   sprintf (signature,"%7d",level);
130   return new TCollection_HAsciiString (signature);
131 }
132
133
134     void  IGESSelect_CounterOfLevelNumber::PrintCount
135   (const Handle(Message_Messenger)& S) const
136 {
137   IFSelect_SignatureList::PrintCount(S);
138   S<<" Highest value : " << thehigh << endl;
139   if (thenblists > 0) S<<"REMARK for LEVEL LIST : Entities are counted in"
140     <<" <LEVEL LIST>\n, and in each Level value of their list"<<endl;
141 }