7fd59977 |
1 | #include <IFGraph_Cumulate.ixx> |
2 | #include <IFGraph_AllShared.hxx> |
3 | #include <Interface_InterfaceModel.hxx> |
4 | |
5 | |
6 | |
7 | // Calcul de cumul |
8 | // Tres simple, on note les entites demandees, et a la fin |
9 | // on a le cumul lui-meme, et comme infos derivees, les doubles et les oublis |
10 | // Chaque recouvrement correspond a une augmentation de UN du status |
11 | // Les status demarrent a 2, ainsi a l ajout d une entite, on distingue bien |
12 | // entre les entites nouvelles, liees a cet appel (statut temporaire 1) et les |
13 | // autres (statut superieur ou egal a 2) |
14 | |
15 | IFGraph_Cumulate::IFGraph_Cumulate (const Interface_Graph& agraph) |
16 | : thegraph (agraph) { } |
17 | |
18 | void IFGraph_Cumulate::GetFromEntity |
19 | (const Handle(Standard_Transient)& ent) |
20 | { |
21 | IFGraph_AllShared iter(thegraph.Model(),ent); |
22 | GetFromIter (iter); |
23 | } |
24 | |
25 | void IFGraph_Cumulate::ResetData () |
26 | { Reset(); thegraph.Reset(); } |
27 | |
28 | void IFGraph_Cumulate::GetFromIter (const Interface_EntityIterator& iter) |
29 | { |
30 | thegraph.GetFromIter(iter,1,1,Standard_True); |
31 | thegraph.ChangeStatus (1,2); // une fois le calcul fait |
32 | } |
33 | |
34 | void IFGraph_Cumulate::Evaluate () |
35 | { |
36 | Reset(); GetFromGraph(thegraph); // evaluation deja faite dans le graphe |
37 | } |
38 | |
39 | Interface_EntityIterator IFGraph_Cumulate::Overlapped () const |
40 | { |
41 | Interface_EntityIterator iter; |
42 | Standard_Integer nb = thegraph.Size(); |
43 | for (Standard_Integer i = 1; i <= nb; i ++) { |
44 | if (thegraph.IsPresent(i) && thegraph.Status(i) > 2) |
45 | iter.GetOneItem(thegraph.Entity(i)); |
46 | } |
47 | return iter; |
48 | } |
49 | |
50 | Interface_EntityIterator IFGraph_Cumulate::Forgotten () const |
51 | { |
52 | Interface_EntityIterator iter; |
53 | Standard_Integer nb = thegraph.Size(); |
54 | for (Standard_Integer i = 1; i <= nb; i ++) { |
55 | if (!thegraph.IsPresent(i)) |
56 | iter.GetOneItem(thegraph.Model()->Value(i)); |
57 | } |
58 | return iter; |
59 | } |
60 | |
61 | Interface_EntityIterator IFGraph_Cumulate::PerCount |
62 | (const Standard_Integer count) const |
63 | { |
64 | Interface_EntityIterator iter; |
65 | Standard_Integer nb = thegraph.Size(); |
66 | for (Standard_Integer i = 1; i <= nb; i ++) { |
67 | if (thegraph.IsPresent(i) && thegraph.Status(i) == (count + 1)) |
68 | iter.GetOneItem(thegraph.Model()->Value(i)); |
69 | } |
70 | return iter; |
71 | } |
72 | |
73 | |
74 | Standard_Integer IFGraph_Cumulate::NbTimes |
75 | (const Handle(Standard_Transient)& ent) const |
76 | { |
77 | Standard_Integer num = thegraph.EntityNumber(ent); |
78 | if (num == 0) return 0; |
79 | Standard_Integer stat = thegraph.Status(num); |
80 | return stat-1; |
81 | } |
82 | |
83 | Standard_Integer IFGraph_Cumulate::HighestNbTimes () const |
84 | { |
85 | Standard_Integer max = 0; |
86 | Standard_Integer nb = thegraph.Size(); |
87 | for (Standard_Integer i = 1; i <= nb; i ++) { |
88 | if (!thegraph.IsPresent(i)) continue; |
89 | Standard_Integer count = thegraph.Status(i) - 1; |
90 | if (count > max) max = count; |
91 | } |
92 | return max; |
93 | } |