1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
18 #include <IFSelect_ShareOutResult.ixx>
19 #include <IFSelect_Dispatch.hxx>
20 #include <IFGraph_AllShared.hxx>
21 #include <Interface_GraphContent.hxx>
25 IFSelect_ShareOutResult::IFSelect_ShareOutResult
26 (const Handle(IFSelect_ShareOut)& sho,
27 const Handle(Interface_InterfaceModel)& amodel)
28 : thegraph(amodel) , thedispres(amodel,Standard_False)
31 theeval = Standard_False;
32 // thedisplist = new TColStd_SequenceOfInteger();
35 IFSelect_ShareOutResult::IFSelect_ShareOutResult
36 (const Handle(IFSelect_ShareOut)& sho, const Interface_Graph& G)
37 : thegraph(G) , thedispres(G,Standard_False)
40 theeval = Standard_False;
41 // thedisplist = new TColStd_SequenceOfInteger();
44 IFSelect_ShareOutResult::IFSelect_ShareOutResult
45 (const Handle(IFSelect_Dispatch)& disp,
46 const Handle(Interface_InterfaceModel)& amodel)
47 : thegraph(amodel) , thedispres(amodel,Standard_False)
50 theeval = Standard_False;
51 // thedisplist = new TColStd_SequenceOfInteger();
54 IFSelect_ShareOutResult::IFSelect_ShareOutResult
55 (const Handle(IFSelect_Dispatch)& disp, const Interface_Graph& G)
56 : thegraph(G) , thedispres(G,Standard_False)
59 theeval = Standard_False;
60 // thedisplist = new TColStd_SequenceOfInteger();
64 Handle(IFSelect_ShareOut) IFSelect_ShareOutResult::ShareOut () const
65 { return theshareout; }
67 const Interface_Graph& IFSelect_ShareOutResult::Graph () const
70 void IFSelect_ShareOutResult::Reset ()
71 { theeval = Standard_False; }
73 void IFSelect_ShareOutResult::Evaluate ()
75 if (theeval) return; // deja fait. si pas OK, faire Reset avant
77 theeval = Standard_True;
81 Handle(IFSelect_PacketList) IFSelect_ShareOutResult::Packets
82 (const Standard_Boolean complete)
85 Handle(IFSelect_PacketList) list = new IFSelect_PacketList(thegraph.Model());
86 Interface_EntityIterator iter;
87 for ( ; More(); Next()) {
89 if (complete) list->AddList (PacketContent().Content());
90 else list->AddList (PacketRoot().Content());
95 Standard_Integer IFSelect_ShareOutResult::NbPackets ()
96 { Evaluate(); return thedispres.NbParts(); }
99 void IFSelect_ShareOutResult::Prepare ()
102 // On alimente thedispres, thedisplist
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;
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
124 thedisplist.Append(i); // n0 du dispatch producteur
127 thedispnum = thepacknum = 1;
128 thepackdisp = 1; // calcul sur 1er Dispatch
130 for (i = thepacknum; i <= thedisplist.Length(); i ++) {
131 if (thedisplist.Value(i) != thedispnum) break;
136 Standard_Boolean IFSelect_ShareOutResult::More ()
137 { return thedispres.More(); } // thepacknum < thedisplist.Length());
139 void IFSelect_ShareOutResult::Next ()
143 Standard_Integer dispnum;
144 if (thepacknum <= thedisplist.Length())
145 dispnum = thedisplist.Value(thepacknum);
148 #if !defined No_Exception
149 // cout<<" ** ** IFSelect_ShareOutResult::Next, void dispatch ignored"<<endl;
153 if (thedispnum == dispnum) thepackdisp ++;
155 thedispnum = dispnum;
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 void IFSelect_ShareOutResult::NextDispatch ()
168 for (; thepacknum <= thedisplist.Length(); thepacknum ++) {
170 if (thedispnum != thedisplist.Value(thepacknum)) {
171 thedispnum = thedisplist.Value(thepacknum);
172 // Calcul donnees propres au Dispatch
175 for (Standard_Integer i = thepacknum; i <= thedisplist.Length(); i ++) {
176 if (thedisplist.Value(i) != thedispnum) break;
179 if (!theshareout.IsNull()) thedispatch = theshareout->Dispatch(thedispnum);
183 thepacknum = thedisplist.Length() + 1; // no next dispatch ...
184 thedispnum = thepackdisp = thenbindisp = 0;
187 Handle(IFSelect_Dispatch) IFSelect_ShareOutResult::Dispatch () const
188 { return thedispatch; }
190 Standard_Integer IFSelect_ShareOutResult::DispatchRank () const
191 { return thedispnum; }
193 void IFSelect_ShareOutResult::PacketsInDispatch
194 (Standard_Integer& numpack, Standard_Integer& nbpacks) const
195 { numpack = thepackdisp; nbpacks = thenbindisp; }
197 Interface_EntityIterator IFSelect_ShareOutResult::PacketRoot ()
198 { return thedispres.Entities(); }
200 Interface_EntityIterator IFSelect_ShareOutResult::PacketContent ()
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);
212 TCollection_AsciiString IFSelect_ShareOutResult::FileName () const
214 Standard_Integer nd = DispatchRank();
215 Standard_Integer np,nbp;
216 PacketsInDispatch(np,nbp);
217 return theshareout->FileName(nd,np,nbp);