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