summaryrefslogtreecommitdiff
path: root/src/IFGraph/IFGraph_Cumulate.cxx
blob: 083fc4397a95c363c3becf2ac926ec0f6ef36574 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <IFGraph_Cumulate.ixx>
#include <IFGraph_AllShared.hxx>
#include <Interface_InterfaceModel.hxx>



// Calcul de cumul
// Tres simple, on note les entites demandees, et a la fin
// on a le cumul lui-meme, et comme infos derivees, les doubles et les oublis
// Chaque recouvrement correspond a une augmentation de UN du status
// Les status demarrent a 2, ainsi a l ajout d une entite, on distingue bien
// entre les entites nouvelles, liees a cet appel (statut temporaire 1) et les
// autres (statut superieur ou egal a 2)

    IFGraph_Cumulate::IFGraph_Cumulate (const Interface_Graph& agraph)
      : thegraph (agraph)    {  }

    void  IFGraph_Cumulate::GetFromEntity
  (const Handle(Standard_Transient)& ent)
{
  IFGraph_AllShared iter(thegraph.Model(),ent);
  GetFromIter (iter);
}

    void  IFGraph_Cumulate::ResetData ()
      {  Reset();  thegraph.Reset();  }

    void  IFGraph_Cumulate::GetFromIter (const Interface_EntityIterator& iter)
{
  thegraph.GetFromIter(iter,1,1,Standard_True);
  thegraph.ChangeStatus (1,2);   // une fois le calcul fait
}

    void  IFGraph_Cumulate::Evaluate ()
{
  Reset();  GetFromGraph(thegraph);    // evaluation deja faite dans le graphe
}

    Interface_EntityIterator  IFGraph_Cumulate::Overlapped () const
{
  Interface_EntityIterator iter;
  Standard_Integer nb = thegraph.Size();
  for (Standard_Integer i = 1; i <= nb; i ++) {
    if (thegraph.IsPresent(i) && thegraph.Status(i) > 2)
      iter.GetOneItem(thegraph.Entity(i));
  }
  return iter;
}

    Interface_EntityIterator  IFGraph_Cumulate::Forgotten () const
{
  Interface_EntityIterator iter;
  Standard_Integer nb = thegraph.Size();
  for (Standard_Integer i = 1; i <= nb; i ++) {
    if (!thegraph.IsPresent(i))
      iter.GetOneItem(thegraph.Model()->Value(i));
  }
  return iter;
}

    Interface_EntityIterator  IFGraph_Cumulate::PerCount
  (const Standard_Integer count) const
{
  Interface_EntityIterator iter;
  Standard_Integer nb = thegraph.Size();
  for (Standard_Integer i = 1; i <= nb; i ++) {
    if (thegraph.IsPresent(i) && thegraph.Status(i) == (count + 1))
      iter.GetOneItem(thegraph.Model()->Value(i));
  }
  return iter;
}


    Standard_Integer  IFGraph_Cumulate::NbTimes
  (const Handle(Standard_Transient)& ent) const
{
  Standard_Integer num = thegraph.EntityNumber(ent);
  if (num == 0) return 0;
  Standard_Integer stat = thegraph.Status(num);
  return stat-1;
}

    Standard_Integer  IFGraph_Cumulate::HighestNbTimes () const
{
  Standard_Integer max = 0;
  Standard_Integer nb = thegraph.Size();
  for (Standard_Integer i = 1; i <= nb; i ++) {
    if (!thegraph.IsPresent(i)) continue;
    Standard_Integer count = thegraph.Status(i) - 1;
    if (count > max) max = count;
  }
  return max;
}