summaryrefslogtreecommitdiff
path: root/src/Transfer/Transfer_TransferOutput.cxx
blob: ffc36a5999deb61e4c54aa5539b396a1be892eb2 (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
125
126
127
128
129
//szv#4 S4163
#include <Transfer_TransferOutput.ixx>
#include <Transfer_Binder.hxx>
#include <Interface_ShareFlags.hxx>
#include <Interface_EntityIterator.hxx>
#include <Transfer_TransferFailure.hxx>



Transfer_TransferOutput::Transfer_TransferOutput (const Handle(Transfer_ActorOfTransientProcess)& actor,
						  const Handle(Interface_InterfaceModel)& amodel)
{
  theproc  = new Transfer_TransientProcess (amodel->NbEntities());
  theproc->SetActor(actor);
  themodel = amodel;
//  thescope = Standard_False;
//  theundef = Transfer_UndefIgnore;
}

Transfer_TransferOutput::Transfer_TransferOutput (const Handle(Transfer_TransientProcess)& proc,
						  const Handle(Interface_InterfaceModel)& amodel)
{
  theproc  = proc;
  themodel = amodel;
//  thescope = Standard_False; //szv#4:S4163:12Mar99 initialization needed
//  theundef = Transfer_UndefIgnore;
}

//Standard_Boolean&  Transfer_TransferOutput::ScopeMode ()
//{  return  thescope;  }

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

Handle(Transfer_TransientProcess)  Transfer_TransferOutput::TransientProcess () const
{  return theproc;  }

void  Transfer_TransferOutput::Transfer (const Handle(Standard_Transient)& obj)
{
  if (themodel->Number(obj) == 0) Transfer_TransferFailure::Raise
    ("TransferOutput : Transfer, entities do not come from same initial model");
//  Standard_Integer scope = 0;
//  if (thescope) scope = theproc->NewScope (obj);

  //:1 modified by ABV 5 Nov 97
  //:1  if (!theproc->Transfer(obj)) return;    // auparavant, traitement Undefined
//  Standard_Boolean ok = 
  theproc->Transfer ( obj );  
//  if (scope > 0) theproc->EndScope (scope);
//  if ( ! ok ) return;                               

/*  switch (theundef) {
    case Transfer_UndefIgnore  : return;
    case Transfer_UndefFailure : Transfer_TransferFailure::Raise
      ("TransferOutput : Transfer Undefined as Failure");
    case Transfer_UndefContent : break; // on ne sait pas traiter ...
    case Transfer_UndefUser    : break; // idem
  }
*/
}


//  Resultats :
//   Pour transferer tout simplement toutes les racines d'un modele d'interface
//   Chacune est notee "Root" dans le Process final

void Transfer_TransferOutput::TransferRoots ()
{  TransferRoots(Interface_Protocol::Active());  }

void Transfer_TransferOutput::TransferRoots (const Handle(Interface_Protocol)& protocol)
{
  theproc->SetRootManagement (Standard_False);
  Interface_ShareFlags tool(themodel,protocol);
  Interface_EntityIterator list = tool.RootEntities();
  for (list.Start(); list.More(); list.Next()) {
    Handle(Standard_Transient) ent = list.Value();
//    Standard_Integer scope = 0;
//    if (thescope) scope = theproc->NewScope (ent);
    if (theproc->Transfer(ent)) theproc->SetRoot(ent);
//    if (scope > 0) theproc->EndScope (scope);
  }
}

void Transfer_TransferOutput::TransferRoots (const Interface_Graph& G)
{
  theproc->SetRootManagement (Standard_False);
  Interface_ShareFlags tool(G);
  theproc->SetModel (G.Model());
  Interface_EntityIterator list = tool.RootEntities();
  for (list.Start(); list.More(); list.Next()) {
    Handle(Standard_Transient) ent = list.Value();
//    Standard_Integer scope = 0;
//    if (thescope) scope = theproc->NewScope (ent);
    if (theproc->Transfer(ent)) theproc->SetRoot(ent);
//    if (scope > 0) theproc->EndScope (scope);
  }
}


Interface_EntityIterator  Transfer_TransferOutput::ListForStatus (const Standard_Boolean normal,
								  const Standard_Boolean roots) const
{
  Interface_EntityIterator list;
  Standard_Integer max = (roots ? theproc->NbRoots() : theproc->NbMapped());
  for (Standard_Integer i = 1; i <= max; i ++) {
    const Handle(Transfer_Binder)& binder =
      (roots ? theproc->RootItem(i) : theproc->MapItem(i));
    if (binder.IsNull()) continue;
    Transfer_StatusExec statex = binder->StatusExec();
    Standard_Boolean ok =
      (statex == Transfer_StatusInitial || statex == Transfer_StatusDone);
    if (ok == normal) list.AddItem
      ( (roots ? theproc->Root(i) : theproc->Mapped(i)) );
  }
  return list;
}

Handle(Interface_InterfaceModel)  Transfer_TransferOutput::ModelForStatus
  (const Handle(Interface_Protocol)& protocol,
   const Standard_Boolean normal, const Standard_Boolean roots) const
{
  Handle(Interface_InterfaceModel) newmod;
  if (themodel.IsNull()) return newmod;
  newmod = themodel->NewEmptyModel();
  Interface_EntityIterator list = ListForStatus (normal, roots);
  for (list.Start(); list.More(); list.Next())
    newmod->AddWithRefs (list.Value(),protocol);
  return newmod;
}