0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / IFGraph / IFGraph_Cumulate.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
42cf5bc1 14
7fd59977 15#include <IFGraph_AllShared.hxx>
42cf5bc1 16#include <IFGraph_Cumulate.hxx>
17#include <Interface_EntityIterator.hxx>
18#include <Interface_Graph.hxx>
7fd59977 19#include <Interface_InterfaceModel.hxx>
42cf5bc1 20#include <Standard_Transient.hxx>
7fd59977 21
22// Calcul de cumul
23// Tres simple, on note les entites demandees, et a la fin
24// on a le cumul lui-meme, et comme infos derivees, les doubles et les oublis
25// Chaque recouvrement correspond a une augmentation de UN du status
26// Les status demarrent a 2, ainsi a l ajout d une entite, on distingue bien
27// entre les entites nouvelles, liees a cet appel (statut temporaire 1) et les
28// autres (statut superieur ou egal a 2)
b311480e 29IFGraph_Cumulate::IFGraph_Cumulate (const Interface_Graph& agraph)
7fd59977 30 : thegraph (agraph) { }
31
32 void IFGraph_Cumulate::GetFromEntity
33 (const Handle(Standard_Transient)& ent)
34{
35 IFGraph_AllShared iter(thegraph.Model(),ent);
36 GetFromIter (iter);
37}
38
39 void IFGraph_Cumulate::ResetData ()
40 { Reset(); thegraph.Reset(); }
41
42 void IFGraph_Cumulate::GetFromIter (const Interface_EntityIterator& iter)
43{
44 thegraph.GetFromIter(iter,1,1,Standard_True);
45 thegraph.ChangeStatus (1,2); // une fois le calcul fait
46}
47
48 void IFGraph_Cumulate::Evaluate ()
49{
50 Reset(); GetFromGraph(thegraph); // evaluation deja faite dans le graphe
51}
52
53 Interface_EntityIterator IFGraph_Cumulate::Overlapped () const
54{
55 Interface_EntityIterator iter;
56 Standard_Integer nb = thegraph.Size();
57 for (Standard_Integer i = 1; i <= nb; i ++) {
58 if (thegraph.IsPresent(i) && thegraph.Status(i) > 2)
59 iter.GetOneItem(thegraph.Entity(i));
60 }
61 return iter;
62}
63
64 Interface_EntityIterator IFGraph_Cumulate::Forgotten () const
65{
66 Interface_EntityIterator iter;
67 Standard_Integer nb = thegraph.Size();
68 for (Standard_Integer i = 1; i <= nb; i ++) {
69 if (!thegraph.IsPresent(i))
70 iter.GetOneItem(thegraph.Model()->Value(i));
71 }
72 return iter;
73}
74
75 Interface_EntityIterator IFGraph_Cumulate::PerCount
76 (const Standard_Integer count) const
77{
78 Interface_EntityIterator iter;
79 Standard_Integer nb = thegraph.Size();
80 for (Standard_Integer i = 1; i <= nb; i ++) {
81 if (thegraph.IsPresent(i) && thegraph.Status(i) == (count + 1))
82 iter.GetOneItem(thegraph.Model()->Value(i));
83 }
84 return iter;
85}
86
87
88 Standard_Integer IFGraph_Cumulate::NbTimes
89 (const Handle(Standard_Transient)& ent) const
90{
91 Standard_Integer num = thegraph.EntityNumber(ent);
92 if (num == 0) return 0;
93 Standard_Integer stat = thegraph.Status(num);
94 return stat-1;
95}
96
97 Standard_Integer IFGraph_Cumulate::HighestNbTimes () const
98{
99 Standard_Integer max = 0;
100 Standard_Integer nb = thegraph.Size();
101 for (Standard_Integer i = 1; i <= nb; i ++) {
102 if (!thegraph.IsPresent(i)) continue;
103 Standard_Integer count = thegraph.Status(i) - 1;
104 if (count > max) max = count;
105 }
106 return max;
107}