1 #include <IFSelect_ShareOutResult.ixx>
2 #include <IFSelect_Dispatch.hxx>
3 #include <IFGraph_AllShared.hxx>
4 #include <Interface_GraphContent.hxx>
8 IFSelect_ShareOutResult::IFSelect_ShareOutResult
9 (const Handle(IFSelect_ShareOut)& sho,
10 const Handle(Interface_InterfaceModel)& amodel)
11 : thegraph(amodel) , thedispres(amodel,Standard_False)
14 theeval = Standard_False;
15 // thedisplist = new TColStd_SequenceOfInteger();
18 IFSelect_ShareOutResult::IFSelect_ShareOutResult
19 (const Handle(IFSelect_ShareOut)& sho, const Interface_Graph& G)
20 : thegraph(G) , thedispres(G,Standard_False)
23 theeval = Standard_False;
24 // thedisplist = new TColStd_SequenceOfInteger();
27 IFSelect_ShareOutResult::IFSelect_ShareOutResult
28 (const Handle(IFSelect_Dispatch)& disp,
29 const Handle(Interface_InterfaceModel)& amodel)
30 : thegraph(amodel) , thedispres(amodel,Standard_False)
33 theeval = Standard_False;
34 // thedisplist = new TColStd_SequenceOfInteger();
37 IFSelect_ShareOutResult::IFSelect_ShareOutResult
38 (const Handle(IFSelect_Dispatch)& disp, const Interface_Graph& G)
39 : thegraph(G) , thedispres(G,Standard_False)
42 theeval = Standard_False;
43 // thedisplist = new TColStd_SequenceOfInteger();
47 Handle(IFSelect_ShareOut) IFSelect_ShareOutResult::ShareOut () const
48 { return theshareout; }
50 const Interface_Graph& IFSelect_ShareOutResult::Graph () const
53 void IFSelect_ShareOutResult::Reset ()
54 { theeval = Standard_False; }
56 void IFSelect_ShareOutResult::Evaluate ()
58 if (theeval) return; // deja fait. si pas OK, faire Reset avant
60 theeval = Standard_True;
64 Handle(IFSelect_PacketList) IFSelect_ShareOutResult::Packets
65 (const Standard_Boolean complete)
68 Handle(IFSelect_PacketList) list = new IFSelect_PacketList(thegraph.Model());
69 Interface_EntityIterator iter;
70 for ( ; More(); Next()) {
72 if (complete) list->AddList (PacketContent().Content());
73 else list->AddList (PacketRoot().Content());
78 Standard_Integer IFSelect_ShareOutResult::NbPackets ()
79 { Evaluate(); return thedispres.NbParts(); }
82 void IFSelect_ShareOutResult::Prepare ()
85 // On alimente thedispres, thedisplist
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;
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
107 thedisplist.Append(i); // n0 du dispatch producteur
110 thedispnum = thepacknum = 1;
111 thepackdisp = 1; // calcul sur 1er Dispatch
113 for (i = thepacknum; i <= thedisplist.Length(); i ++) {
114 if (thedisplist.Value(i) != thedispnum) break;
119 Standard_Boolean IFSelect_ShareOutResult::More ()
120 { return thedispres.More(); } // thepacknum < thedisplist.Length());
122 void IFSelect_ShareOutResult::Next ()
126 Standard_Integer dispnum;
127 if (thepacknum <= thedisplist.Length())
128 dispnum = thedisplist.Value(thepacknum);
131 #if !defined No_Exception
132 // cout<<" ** ** IFSelect_ShareOutResult::Next, void dispatch ignored"<<endl;
136 if (thedispnum == dispnum) thepackdisp ++;
138 thedispnum = dispnum;
141 for (Standard_Integer i = thepacknum; i <= thedisplist.Length(); i ++) {
142 if (thedisplist.Value(i) != thedispnum) break;
145 if (!theshareout.IsNull()) thedispatch = theshareout->Dispatch(thedispnum);
149 void IFSelect_ShareOutResult::NextDispatch ()
151 for (; thepacknum <= thedisplist.Length(); thepacknum ++) {
153 if (thedispnum != thedisplist.Value(thepacknum)) {
154 thedispnum = thedisplist.Value(thepacknum);
155 // Calcul donnees propres au Dispatch
158 for (Standard_Integer i = thepacknum; i <= thedisplist.Length(); i ++) {
159 if (thedisplist.Value(i) != thedispnum) break;
162 if (!theshareout.IsNull()) thedispatch = theshareout->Dispatch(thedispnum);
166 thepacknum = thedisplist.Length() + 1; // no next dispatch ...
167 thedispnum = thepackdisp = thenbindisp = 0;
170 Handle(IFSelect_Dispatch) IFSelect_ShareOutResult::Dispatch () const
171 { return thedispatch; }
173 Standard_Integer IFSelect_ShareOutResult::DispatchRank () const
174 { return thedispnum; }
176 void IFSelect_ShareOutResult::PacketsInDispatch
177 (Standard_Integer& numpack, Standard_Integer& nbpacks) const
178 { numpack = thepackdisp; nbpacks = thenbindisp; }
180 Interface_EntityIterator IFSelect_ShareOutResult::PacketRoot ()
181 { return thedispres.Entities(); }
183 Interface_EntityIterator IFSelect_ShareOutResult::PacketContent ()
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);
195 TCollection_AsciiString IFSelect_ShareOutResult::FileName () const
197 Standard_Integer nd = DispatchRank();
198 Standard_Integer np,nbp;
199 PacketsInDispatch(np,nbp);
200 return theshareout->FileName(nd,np,nbp);