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.
15 #include <Interface_Check.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <Interface_Graph.hxx>
18 #include <Interface_HGraph.hxx>
19 #include <Interface_InterfaceModel.hxx>
20 #include <Interface_MSG.hxx>
21 #include <Message_Messenger.hxx>
22 #include <Standard_Transient.hxx>
23 #include <Standard_Type.hxx>
24 #include <TColStd_HSequenceOfTransient.hxx>
25 #include <Transfer_Binder.hxx>
26 #include <Transfer_TransientProcess.hxx>
28 IMPLEMENT_STANDARD_RTTIEXT(Transfer_TransientProcess,Transfer_ProcessForTransient)
30 //=======================================================================
31 //function : Transfer_TransientProcess
33 //=======================================================================
34 Transfer_TransientProcess::Transfer_TransientProcess
35 (const Standard_Integer nb) : Transfer_ProcessForTransient (nb)
37 thetrroots = new TColStd_HSequenceOfTransient;
41 //=======================================================================
44 //=======================================================================
46 void Transfer_TransientProcess::SetModel
47 (const Handle(Interface_InterfaceModel)& model)
53 //=======================================================================
56 //=======================================================================
58 Handle(Interface_InterfaceModel) Transfer_TransientProcess::Model () const
64 void Transfer_TransientProcess::SetGraph(const Handle(Interface_HGraph)& HG)
67 if (!thegraph.IsNull())
68 SetModel(thegraph->Graph().Model());
74 //=======================================================================
77 //=======================================================================
79 Standard_Boolean Transfer_TransientProcess::HasGraph () const
81 return !thegraph.IsNull();
85 //=======================================================================
88 //=======================================================================
90 Handle(Interface_HGraph) Transfer_TransientProcess::HGraph () const
96 //=======================================================================
99 //=======================================================================
101 const Interface_Graph& Transfer_TransientProcess::Graph () const
103 return thegraph->Graph();
107 //=======================================================================
108 //function : SetContext
110 //=======================================================================
112 void Transfer_TransientProcess::SetContext(const Standard_CString name,
113 const Handle(Standard_Transient)& ctx)
115 thectx.Bind(name,ctx);
119 //=======================================================================
120 //function : GetContext
122 //=======================================================================
124 Standard_Boolean Transfer_TransientProcess::GetContext
125 (const Standard_CString name, const Handle(Standard_Type)& type,
126 Handle(Standard_Transient)& ctx) const
128 if (thectx.IsEmpty()) return Standard_False;
129 if (!thectx.Find(name, ctx))
132 if (ctx.IsNull()) return Standard_False;
133 if (type.IsNull()) return Standard_True;
134 if (!ctx->IsKind(type)) ctx.Nullify();
135 return !ctx.IsNull();
139 //=======================================================================
142 //=======================================================================
144 NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& Transfer_TransientProcess::Context ()
150 //=======================================================================
151 //function : PrintTrace
153 //=======================================================================
155 void Transfer_TransientProcess::PrintTrace
156 (const Handle(Standard_Transient)& start, const Handle(Message_Messenger)& S) const
158 if (!start.IsNull()) {
160 if (!themodel.IsNull()) {
161 themodel->Print (start,S,1);
162 // S<<"id "; themodel->Print (start,S);
163 // S<<" Type:"<<themodel->TypeName (start);
165 else S<<" Type:"<< Interface_InterfaceModel::ClassName(start->DynamicType()->Name());
166 // << start (handle) ??
171 //=======================================================================
172 //function : CheckNum
174 //=======================================================================
176 Standard_Integer Transfer_TransientProcess::CheckNum
177 (const Handle(Standard_Transient)& start) const
179 return (themodel.IsNull() ? 0 : themodel->Number(start));
183 //=======================================================================
184 //function : TypedSharings
186 //=======================================================================
188 Interface_EntityIterator Transfer_TransientProcess::TypedSharings
189 (const Handle(Standard_Transient)& start,
190 const Handle(Standard_Type)& type) const
192 Interface_EntityIterator iter;
193 if (thegraph.IsNull()) return iter;
194 return thegraph->Graph().TypedSharings (start,type);
198 //=======================================================================
199 //function : IsDataLoaded
201 //=======================================================================
203 Standard_Boolean Transfer_TransientProcess::IsDataLoaded
204 (const Handle(Standard_Transient)& start) const
206 if (themodel.IsNull()) return Standard_True;
207 Standard_Integer num = themodel->Number(start);
208 if (num == 0) return Standard_True;
209 if (themodel->IsUnknownEntity(num)) return Standard_False;
210 return !themodel->IsRedefinedContent(num);
214 //=======================================================================
215 //function : IsDataFail
217 //=======================================================================
219 Standard_Boolean Transfer_TransientProcess::IsDataFail
220 (const Handle(Standard_Transient)& start) const
222 if (themodel.IsNull()) return Standard_False;
223 Standard_Integer num = themodel->Number(start);
224 if (num == 0) return Standard_False;
225 if (themodel->IsErrorEntity(num)) return Standard_True;
226 const Handle(Interface_Check) ach = themodel->Check(num,Standard_False); // semantic
227 return ach->HasFailed();
231 //=======================================================================
232 //function : PrintStats
234 //=======================================================================
236 void Transfer_TransientProcess::PrintStats(const Standard_Integer /*mode*/,
237 const Handle(Message_Messenger)& S) const
239 S<<"\n*******************************************************************\n";
240 // if (mode == 1) { // Statistiques de base
241 S << "******** Basic Statistics ********"<<endl;
243 Handle(Interface_InterfaceModel) model = Model();
244 if (model.IsNull()) S<<"**** Model unknown"<<endl;
246 S<<"**** Nb Entities : "<<model->NbEntities()<<endl;
248 Standard_Integer nbr = 0, nbe = 0, nbw = 0;
249 Standard_Integer i, max = NbMapped(), nbroots = NbRoots();
250 S << "**** Nb Final Results : "<<nbroots<<endl;
252 for (i = 1; i <= max; i ++) {
253 const Handle(Transfer_Binder)& binder = MapItem(i);
254 if (binder.IsNull()) continue;
255 const Handle(Interface_Check) ach = binder->Check();
256 Transfer_StatusExec stat = binder->StatusExec();
257 if (stat != Transfer_StatusInitial && stat != Transfer_StatusDone)
260 if (ach->NbWarnings() > 0) nbw ++;
261 if (binder->HasResult()) nbr ++;
265 S<<"**** ( Itermediate Results : "<<nbr-nbroots<<" )\n";
267 S<<"**** Errors on : "<<Interface_MSG::Blanks(nbe,4)<<nbe<<" Entities\n";
269 S<<"**** Warnings on : "<<Interface_MSG::Blanks(nbw,4)<<nbw<<" Entities\n";
270 S<<"*******************************************************************";
276 //=======================================================================
277 //function : RootsForTransfer
279 //=======================================================================
281 Handle(TColStd_HSequenceOfTransient) Transfer_TransientProcess::RootsForTransfer()