0024057: Eliminate compiler warning C4100 in MSVC++ with warning level 4
[occt.git] / src / IFSelect / IFSelect_ShareOutResult.cxx
CommitLineData
b311480e 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
7fd59977 18#include <IFSelect_ShareOutResult.ixx>
19#include <IFSelect_Dispatch.hxx>
20#include <IFGraph_AllShared.hxx>
21#include <Interface_GraphContent.hxx>
22
23
24
b311480e 25IFSelect_ShareOutResult::IFSelect_ShareOutResult
7fd59977 26 (const Handle(IFSelect_ShareOut)& sho,
27 const Handle(Interface_InterfaceModel)& amodel)
28 : thegraph(amodel) , thedispres(amodel,Standard_False)
29{
30 theshareout = sho;
31 theeval = Standard_False;
32// thedisplist = new TColStd_SequenceOfInteger();
33}
34
35 IFSelect_ShareOutResult::IFSelect_ShareOutResult
36 (const Handle(IFSelect_ShareOut)& sho, const Interface_Graph& G)
37 : thegraph(G) , thedispres(G,Standard_False)
38{
39 theshareout = sho;
40 theeval = Standard_False;
41// thedisplist = new TColStd_SequenceOfInteger();
42}
43
44 IFSelect_ShareOutResult::IFSelect_ShareOutResult
45 (const Handle(IFSelect_Dispatch)& disp,
46 const Handle(Interface_InterfaceModel)& amodel)
47 : thegraph(amodel) , thedispres(amodel,Standard_False)
48{
49 thedispatch = disp;
50 theeval = Standard_False;
51// thedisplist = new TColStd_SequenceOfInteger();
52}
53
54 IFSelect_ShareOutResult::IFSelect_ShareOutResult
55 (const Handle(IFSelect_Dispatch)& disp, const Interface_Graph& G)
56 : thegraph(G) , thedispres(G,Standard_False)
57{
58 thedispatch = disp;
59 theeval = Standard_False;
60// thedisplist = new TColStd_SequenceOfInteger();
61}
62
63
64 Handle(IFSelect_ShareOut) IFSelect_ShareOutResult::ShareOut () const
65 { return theshareout; }
66
67 const Interface_Graph& IFSelect_ShareOutResult::Graph () const
68 { return thegraph; }
69
70 void IFSelect_ShareOutResult::Reset ()
71 { theeval = Standard_False; }
72
73 void IFSelect_ShareOutResult::Evaluate ()
74{
75 if (theeval) return; // deja fait. si pas OK, faire Reset avant
76 Prepare();
77 theeval = Standard_True;
78}
79
80
81 Handle(IFSelect_PacketList) IFSelect_ShareOutResult::Packets
82 (const Standard_Boolean complete)
83{
84 Evaluate();
85 Handle(IFSelect_PacketList) list = new IFSelect_PacketList(thegraph.Model());
86 Interface_EntityIterator iter;
87 for ( ; More(); Next()) {
88 list->AddPacket();
89 if (complete) list->AddList (PacketContent().Content());
90 else list->AddList (PacketRoot().Content());
91 }
92 return list;
93}
94
95 Standard_Integer IFSelect_ShareOutResult::NbPackets ()
96 { Evaluate(); return thedispres.NbParts(); }
97
98
99 void IFSelect_ShareOutResult::Prepare ()
100{
101 thedisplist.Clear();
102// On alimente thedispres, thedisplist
103 thedispres.Reset();
104 IFGraph_AllShared A(thegraph);
105 Handle(IFSelect_Dispatch) disp = thedispatch;
106 Standard_Integer nb = 1, first = 1;
107 if (!theshareout.IsNull()) {
108 nb = theshareout->NbDispatches();
109 first = theshareout->LastRun() + 1;
110 }
111 Standard_Integer i; // svv Jan11 2000 : porting on DEC
112 for (i = first; i <= nb; i ++) {
113 if (!theshareout.IsNull()) disp = theshareout->Dispatch(i);
114 if (disp->FinalSelection().IsNull()) continue; // Dispatch neutralise
115 IFGraph_SubPartsIterator packs(thegraph,Standard_False);
116 disp->Packets(thegraph,packs);
117 for (packs.Start(); packs.More(); packs.Next()) {
118 Interface_EntityIterator iter = packs.Entities();
119 if (iter.NbEntities() == 0) continue;
120 thedispres.AddPart();
121 thedispres.GetFromIter(iter); // on enregistre ce paquet
122 A.ResetData();
123 A.GetFromIter(iter);
124 thedisplist.Append(i); // n0 du dispatch producteur
125 }
126 }
127 thedispnum = thepacknum = 1;
128 thepackdisp = 1; // calcul sur 1er Dispatch
129 thenbindisp = 0;
130 for (i = thepacknum; i <= thedisplist.Length(); i ++) {
131 if (thedisplist.Value(i) != thedispnum) break;
132 thenbindisp ++;
133 }
134}
135
136 Standard_Boolean IFSelect_ShareOutResult::More ()
137 { return thedispres.More(); } // thepacknum < thedisplist.Length());
138
139 void IFSelect_ShareOutResult::Next ()
140{
141 thedispres.Next();
142 thepacknum ++;
143 Standard_Integer dispnum;
144 if (thepacknum <= thedisplist.Length())
145 dispnum = thedisplist.Value(thepacknum);
146 else {
147 thenbindisp = 0;
148#if !defined No_Exception
149// cout<<" ** ** IFSelect_ShareOutResult::Next, void dispatch ignored"<<endl;
150#endif
151 return;
152 }
153 if (thedispnum == dispnum) thepackdisp ++;
154 else {
155 thedispnum = dispnum;
156 thepackdisp = 1;
157 thenbindisp = 0;
158 for (Standard_Integer i = thepacknum; i <= thedisplist.Length(); i ++) {
159 if (thedisplist.Value(i) != thedispnum) break;
160 thenbindisp ++;
161 }
162 if (!theshareout.IsNull()) thedispatch = theshareout->Dispatch(thedispnum);
163 }
164}
165
166 void IFSelect_ShareOutResult::NextDispatch ()
167{
168 for (; thepacknum <= thedisplist.Length(); thepacknum ++) {
169 thedispres.Next();
170 if (thedispnum != thedisplist.Value(thepacknum)) {
171 thedispnum = thedisplist.Value(thepacknum);
172// Calcul donnees propres au Dispatch
173 thepackdisp = 1;
174 thenbindisp = 0;
175 for (Standard_Integer i = thepacknum; i <= thedisplist.Length(); i ++) {
176 if (thedisplist.Value(i) != thedispnum) break;
177 thenbindisp ++;
178 }
179 if (!theshareout.IsNull()) thedispatch = theshareout->Dispatch(thedispnum);
180 return;
181 }
182 }
183 thepacknum = thedisplist.Length() + 1; // no next dispatch ...
184 thedispnum = thepackdisp = thenbindisp = 0;
185}
186
187 Handle(IFSelect_Dispatch) IFSelect_ShareOutResult::Dispatch () const
188 { return thedispatch; }
189
190 Standard_Integer IFSelect_ShareOutResult::DispatchRank () const
191 { return thedispnum; }
192
193 void IFSelect_ShareOutResult::PacketsInDispatch
194 (Standard_Integer& numpack, Standard_Integer& nbpacks) const
195 { numpack = thepackdisp; nbpacks = thenbindisp; }
196
197 Interface_EntityIterator IFSelect_ShareOutResult::PacketRoot ()
198 { return thedispres.Entities(); }
199
200 Interface_EntityIterator IFSelect_ShareOutResult::PacketContent ()
201{
202// IFGraph_Cumulate G(thegraph);
203 Interface_EntityIterator iter = thedispres.Entities();
204 Interface_Graph G(thegraph);
205// G.GetFromIter(thedispres.Entities(),0);
206 for (iter.Start(); iter.More(); iter.Next())
207 G.GetFromEntity(iter.Value(),Standard_True);
208 Interface_GraphContent GC(G);
209 return GC.Result();
210}
211
212 TCollection_AsciiString IFSelect_ShareOutResult::FileName () const
213{
214 Standard_Integer nd = DispatchRank();
215 Standard_Integer np,nbp;
216 PacketsInDispatch(np,nbp);
217 return theshareout->FileName(nd,np,nbp);
218}