1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
16 #include <Interface_EntityIterator.hxx>
17 #include <Interface_Graph.hxx>
18 #include <Interface_InterfaceModel.hxx>
19 #include <Interface_Protocol.hxx>
20 #include <Interface_ShareFlags.hxx>
21 #include <Standard_NoSuchObject.hxx>
22 #include <Standard_Transient.hxx>
23 #include <Transfer_ActorOfTransientProcess.hxx>
24 #include <Transfer_Binder.hxx>
25 #include <Transfer_TransferFailure.hxx>
26 #include <Transfer_TransferOutput.hxx>
27 #include <Transfer_TransientProcess.hxx>
29 Transfer_TransferOutput::Transfer_TransferOutput (const Handle(Transfer_ActorOfTransientProcess)& actor,
30 const Handle(Interface_InterfaceModel)& amodel)
32 theproc = new Transfer_TransientProcess (amodel->NbEntities());
33 theproc->SetActor(actor);
35 // thescope = Standard_False;
36 // theundef = Transfer_UndefIgnore;
39 Transfer_TransferOutput::Transfer_TransferOutput (const Handle(Transfer_TransientProcess)& proc,
40 const Handle(Interface_InterfaceModel)& amodel)
44 // thescope = Standard_False; //szv#4:S4163:12Mar99 initialization needed
45 // theundef = Transfer_UndefIgnore;
48 //Standard_Boolean& Transfer_TransferOutput::ScopeMode ()
49 //{ return thescope; }
51 Handle(Interface_InterfaceModel) Transfer_TransferOutput::Model () const
54 Handle(Transfer_TransientProcess) Transfer_TransferOutput::TransientProcess () const
57 void Transfer_TransferOutput::Transfer (const Handle(Standard_Transient)& obj)
59 if (themodel->Number(obj) == 0) throw Transfer_TransferFailure("TransferOutput : Transfer, entities do not come from same initial model");
60 // Standard_Integer scope = 0;
61 // if (thescope) scope = theproc->NewScope (obj);
63 //:1 modified by ABV 5 Nov 97
64 //:1 if (!theproc->Transfer(obj)) return; // auparavant, traitement Undefined
65 // Standard_Boolean ok =
66 theproc->Transfer ( obj );
67 // if (scope > 0) theproc->EndScope (scope);
68 // if ( ! ok ) return;
70 /* switch (theundef) {
71 case Transfer_UndefIgnore : return;
72 case Transfer_UndefFailure : throw Transfer_TransferFailure("TransferOutput : Transfer Undefined as Failure");
73 case Transfer_UndefContent : break; // on ne sait pas traiter ...
74 case Transfer_UndefUser : break; // idem
81 // Pour transferer tout simplement toutes les racines d'un modele d'interface
82 // Chacune est notee "Root" dans le Process final
84 void Transfer_TransferOutput::TransferRoots ()
85 { TransferRoots(Interface_Protocol::Active()); }
87 void Transfer_TransferOutput::TransferRoots (const Handle(Interface_Protocol)& protocol)
89 theproc->SetRootManagement (Standard_False);
90 Interface_ShareFlags tool(themodel,protocol);
91 Interface_EntityIterator list = tool.RootEntities();
92 for (list.Start(); list.More(); list.Next()) {
93 Handle(Standard_Transient) ent = list.Value();
94 // Standard_Integer scope = 0;
95 // if (thescope) scope = theproc->NewScope (ent);
96 if (theproc->Transfer(ent)) theproc->SetRoot(ent);
97 // if (scope > 0) theproc->EndScope (scope);
101 void Transfer_TransferOutput::TransferRoots (const Interface_Graph& G)
103 theproc->SetRootManagement (Standard_False);
104 Interface_ShareFlags tool(G);
105 theproc->SetModel (G.Model());
106 Interface_EntityIterator list = tool.RootEntities();
107 for (list.Start(); list.More(); list.Next()) {
108 Handle(Standard_Transient) ent = list.Value();
109 // Standard_Integer scope = 0;
110 // if (thescope) scope = theproc->NewScope (ent);
111 if (theproc->Transfer(ent)) theproc->SetRoot(ent);
112 // if (scope > 0) theproc->EndScope (scope);
117 Interface_EntityIterator Transfer_TransferOutput::ListForStatus (const Standard_Boolean normal,
118 const Standard_Boolean roots) const
120 Interface_EntityIterator list;
121 Standard_Integer max = (roots ? theproc->NbRoots() : theproc->NbMapped());
122 for (Standard_Integer i = 1; i <= max; i ++) {
123 const Handle(Transfer_Binder)& binder =
124 (roots ? theproc->RootItem(i) : theproc->MapItem(i));
125 if (binder.IsNull()) continue;
126 Transfer_StatusExec statex = binder->StatusExec();
127 Standard_Boolean ok =
128 (statex == Transfer_StatusInitial || statex == Transfer_StatusDone);
129 if (ok == normal) list.AddItem
130 ( (roots ? theproc->Root(i) : theproc->Mapped(i)) );
135 Handle(Interface_InterfaceModel) Transfer_TransferOutput::ModelForStatus
136 (const Handle(Interface_Protocol)& protocol,
137 const Standard_Boolean normal, const Standard_Boolean roots) const
139 Handle(Interface_InterfaceModel) newmod;
140 if (themodel.IsNull()) return newmod;
141 newmod = themodel->NewEmptyModel();
142 Interface_EntityIterator list = ListForStatus (normal, roots);
143 for (list.Start(); list.More(); list.Next())
144 newmod->AddWithRefs (list.Value(),protocol);