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