7fd59977 |
1 | #include <IFSelect_DispPerCount.ixx> |
2 | #include <IFSelect_Selection.hxx> |
3 | #include <IFGraph_SCRoots.hxx> |
4 | #include <Interface_InterfaceModel.hxx> |
5 | #include <Interface_EntityIterator.hxx> |
6 | |
7 | |
8 | IFSelect_DispPerCount::IFSelect_DispPerCount () { } |
9 | |
10 | Handle(IFSelect_IntParam) IFSelect_DispPerCount::Count () const |
11 | { return thecount; } |
12 | |
13 | void IFSelect_DispPerCount::SetCount |
14 | (const Handle(IFSelect_IntParam)& pcount) |
15 | { thecount = pcount; } |
16 | |
17 | Standard_Integer IFSelect_DispPerCount::CountValue () const |
18 | { |
19 | Standard_Integer pcount = 0; |
20 | if (!thecount.IsNull()) pcount = thecount->Value(); |
21 | if (pcount <= 0) pcount = 1; // option prise par defaut |
22 | return pcount; |
23 | } |
24 | |
25 | TCollection_AsciiString IFSelect_DispPerCount::Label () const |
26 | { |
27 | TCollection_AsciiString lab(CountValue()); |
28 | lab.Insert(1,"One File per "); |
29 | lab.AssignCat(" Entities"); |
30 | return lab; |
31 | } |
32 | |
33 | |
34 | Standard_Boolean IFSelect_DispPerCount::LimitedMax |
35 | (const Standard_Integer nbent, Standard_Integer& pcount) const |
36 | { |
37 | pcount = 1 + nbent / CountValue(); |
38 | return Standard_True; |
39 | } |
40 | |
41 | Standard_Boolean IFSelect_DispPerCount::PacketsCount |
42 | (const Interface_Graph& G, Standard_Integer& /*count*/) const |
43 | { return 1 + G.Size() / CountValue(); } |
44 | |
45 | void IFSelect_DispPerCount::Packets |
46 | (const Interface_Graph& G, IFGraph_SubPartsIterator& packs) const |
47 | { |
48 | // Ressemble a DispPerOne, mais fait un AddPart tous les "count" racines |
49 | Standard_Integer pcount = CountValue(); |
50 | |
51 | IFGraph_SCRoots roots(G,Standard_False); |
52 | roots.SetLoad(); |
53 | roots.GetFromIter(FinalSelection()->UniqueResult(G)); |
54 | // SCRoots a initie la resolution : decoupage en StrongComponants + selection |
55 | // des racines. Un paquet correspond des lors a <count> racines |
56 | // Donc, il faut iterer sur les Parts de roots et les prendre par <count> |
57 | |
58 | Standard_Integer i = 0; |
59 | for (roots.Start(); roots.More(); roots.Next()) { |
60 | if (i == 0) packs.AddPart(); |
61 | i ++; if (i >= pcount) i = 0; // regroupement selon "count" |
62 | packs.GetFromIter(roots.Entities()); |
63 | } |
64 | } |