0024428: Implementation of LGPL license
[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//
973c2be1 5// This library is free software; you can redistribute it and / or modify it
6// under the terms of the GNU Lesser General Public version 2.1 as published
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
7fd59977 14#include <IFGraph_Cumulate.ixx>
15#include <IFGraph_AllShared.hxx>
16#include <Interface_InterfaceModel.hxx>
17
18
19
20// Calcul de cumul
21// Tres simple, on note les entites demandees, et a la fin
22// on a le cumul lui-meme, et comme infos derivees, les doubles et les oublis
23// Chaque recouvrement correspond a une augmentation de UN du status
24// Les status demarrent a 2, ainsi a l ajout d une entite, on distingue bien
25// entre les entites nouvelles, liees a cet appel (statut temporaire 1) et les
26// autres (statut superieur ou egal a 2)
27
b311480e 28IFGraph_Cumulate::IFGraph_Cumulate (const Interface_Graph& agraph)
7fd59977 29 : thegraph (agraph) { }
30
31 void IFGraph_Cumulate::GetFromEntity
32 (const Handle(Standard_Transient)& ent)
33{
34 IFGraph_AllShared iter(thegraph.Model(),ent);
35 GetFromIter (iter);
36}
37
38 void IFGraph_Cumulate::ResetData ()
39 { Reset(); thegraph.Reset(); }
40
41 void IFGraph_Cumulate::GetFromIter (const Interface_EntityIterator& iter)
42{
43 thegraph.GetFromIter(iter,1,1,Standard_True);
44 thegraph.ChangeStatus (1,2); // une fois le calcul fait
45}
46
47 void IFGraph_Cumulate::Evaluate ()
48{
49 Reset(); GetFromGraph(thegraph); // evaluation deja faite dans le graphe
50}
51
52 Interface_EntityIterator IFGraph_Cumulate::Overlapped () const
53{
54 Interface_EntityIterator iter;
55 Standard_Integer nb = thegraph.Size();
56 for (Standard_Integer i = 1; i <= nb; i ++) {
57 if (thegraph.IsPresent(i) && thegraph.Status(i) > 2)
58 iter.GetOneItem(thegraph.Entity(i));
59 }
60 return iter;
61}
62
63 Interface_EntityIterator IFGraph_Cumulate::Forgotten () const
64{
65 Interface_EntityIterator iter;
66 Standard_Integer nb = thegraph.Size();
67 for (Standard_Integer i = 1; i <= nb; i ++) {
68 if (!thegraph.IsPresent(i))
69 iter.GetOneItem(thegraph.Model()->Value(i));
70 }
71 return iter;
72}
73
74 Interface_EntityIterator IFGraph_Cumulate::PerCount
75 (const Standard_Integer count) const
76{
77 Interface_EntityIterator iter;
78 Standard_Integer nb = thegraph.Size();
79 for (Standard_Integer i = 1; i <= nb; i ++) {
80 if (thegraph.IsPresent(i) && thegraph.Status(i) == (count + 1))
81 iter.GetOneItem(thegraph.Model()->Value(i));
82 }
83 return iter;
84}
85
86
87 Standard_Integer IFGraph_Cumulate::NbTimes
88 (const Handle(Standard_Transient)& ent) const
89{
90 Standard_Integer num = thegraph.EntityNumber(ent);
91 if (num == 0) return 0;
92 Standard_Integer stat = thegraph.Status(num);
93 return stat-1;
94}
95
96 Standard_Integer IFGraph_Cumulate::HighestNbTimes () const
97{
98 Standard_Integer max = 0;
99 Standard_Integer nb = thegraph.Size();
100 for (Standard_Integer i = 1; i <= nb; i ++) {
101 if (!thegraph.IsPresent(i)) continue;
102 Standard_Integer count = thegraph.Status(i) - 1;
103 if (count > max) max = count;
104 }
105 return max;
106}