summaryrefslogtreecommitdiff
path: root/src/Interface/Interface_ShareFlags.cxx
blob: e8d2f8b80f1971d6dd801cfcf798338c43c80771 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <Interface_ShareFlags.ixx>
#include <Interface_GeneralModule.hxx>
#include <Interface_ReportEntity.hxx>
#include <Interface_IntList.hxx>
#include <Standard_DomainError.hxx>



    Interface_ShareFlags::Interface_ShareFlags
  (const Handle(Interface_InterfaceModel)& amodel,
   const Interface_GeneralLib& lib)
   : theflags (amodel->NbEntities())
{
  Handle(Interface_GTool) gtool;  // null
  themodel = amodel;
  Evaluate(lib,gtool);
}

    Interface_ShareFlags::Interface_ShareFlags
  (const Handle(Interface_InterfaceModel)& amodel,
   const Handle(Interface_GTool)& gtool)
   : theflags (amodel->NbEntities())
{
  themodel = amodel;
  Evaluate(gtool->Lib(),gtool);
}

    Interface_ShareFlags::Interface_ShareFlags
  (const Handle(Interface_InterfaceModel)& amodel,
   const Handle(Interface_Protocol)& protocol)
   : theflags (amodel->NbEntities())
{
  Handle(Interface_GTool) gtool;  // null
  themodel = amodel;
  Evaluate(Interface_GeneralLib(protocol),gtool);
}

    Interface_ShareFlags::Interface_ShareFlags
  (const Handle(Interface_InterfaceModel)& amodel)
   : theflags (amodel->NbEntities())
{
  Handle(Interface_GTool) gtool = themodel->GTool();
  gtool->Reservate(amodel->NbEntities());
  themodel = amodel;
  Evaluate (gtool->Lib(),gtool);
}

    Interface_ShareFlags::Interface_ShareFlags (const Interface_Graph& agraph)
   : theflags (agraph.Model()->NbEntities())
{
  themodel = agraph.Model();
  Standard_Integer nb = themodel->NbEntities();
  if (nb == 0) return;
  theroots = new TColStd_HSequenceOfTransient();
  for (Standard_Integer i = 1; i <= nb; i ++) {
//    Resultat obtenu depuis le Graph
    Interface_IntList list = agraph.SharingNums(i);
    if (list.Length() > 0) theflags.SetTrue(i);
    else theroots->Append (themodel->Value(i));
  }
}


    void  Interface_ShareFlags::Evaluate
  (const Interface_GeneralLib& lib, const Handle(Interface_GTool)& gtool)
{
  Standard_Boolean patool = gtool.IsNull();
  Standard_Integer nb = themodel->NbEntities();
  if (nb == 0) return;
  theroots = new TColStd_HSequenceOfTransient();
  Standard_Integer i; // svv Jan11 2000 : porting on DEC
  for (i = 1; i <= nb; i ++) {

//    ATTENTION : Si Entite non chargee donc illisible, basculer sur son
//    "Contenu" equivalent
    Handle(Standard_Transient) ent = themodel->Value(i);
    if (themodel->IsRedefinedContent(i)) ent = themodel->ReportEntity(i)->Content();

//    Resultat obtenu via GeneralLib
    Interface_EntityIterator iter;
    Handle(Interface_GeneralModule) module;
    Standard_Integer CN;
    if (patool) {
      if (lib.Select(ent,module,CN))  module->FillShared(themodel,CN,ent,iter);
    } else {
      if (gtool->Select(ent,module,CN))  module->FillShared(themodel,CN,ent,iter);
    }

//    Entites partagees par <ent> : reste a noter chacune comme "Shared"
    for (iter.Start(); iter.More(); iter.Next()) {
      Standard_Integer num = themodel->Number(iter.Value());
      theflags.SetTrue(num);    // Et Voila
    }
  }
  for (i = 1; i <= nb; i ++) {
    if (!theflags.Value(i)) theroots->Append (themodel->Value(i));
  }
}


    Handle(Interface_InterfaceModel)  Interface_ShareFlags::Model () const 
      {  return themodel;  }

    Standard_Boolean  Interface_ShareFlags::IsShared
  (const Handle(Standard_Transient)& ent) const 
{
  Standard_Integer num = themodel->Number(ent);
  if (num == 0 || num > themodel->NbEntities()) Standard_DomainError::Raise
    ("Interface ShareFlags : IsShared");
  return theflags.Value(num);
}

    Interface_EntityIterator  Interface_ShareFlags::RootEntities () const
{
  Interface_EntityIterator iter (theroots);
  return iter;
}

    Standard_Integer  Interface_ShareFlags::NbRoots () const
      {  return (theroots.IsNull() ? 0 : theroots->Length());  }

    Handle(Standard_Transient)  Interface_ShareFlags::Root
  (const Standard_Integer num) const
      {  return theroots->Value(num);  }