1 // Created on: 1995-12-05
2 // Created by: Christian CAILLET
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _XSControl_TransferReader_HeaderFile
18 #define _XSControl_TransferReader_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <TCollection_AsciiString.hxx>
24 #include <TColStd_DataMapOfIntegerTransient.hxx>
25 #include <TopTools_HSequenceOfShape.hxx>
26 #include <MMgt_TShared.hxx>
27 #include <Standard_CString.hxx>
28 #include <Standard_Boolean.hxx>
29 #include <Standard_Type.hxx>
30 #include <Standard_Integer.hxx>
31 #include <TColStd_HSequenceOfTransient.hxx>
32 #include <Interface_CheckStatus.hxx>
33 class XSControl_Controller;
34 class Interface_InterfaceModel;
35 class Interface_HGraph;
36 class Dico_DictionaryOfTransient;
37 class Transfer_ActorOfTransientProcess;
38 class Transfer_TransientProcess;
39 class Standard_Transient;
40 class Transfer_ResultFromModel;
42 class Interface_CheckIterator;
43 class Interface_Graph;
46 class XSControl_TransferReader;
47 DEFINE_STANDARD_HANDLE(XSControl_TransferReader, MMgt_TShared)
49 //! A TransferReader performs, manages, handles results of,
50 //! transfers done when reading a file (i.e. from entities of an
51 //! InterfaceModel, to objects for Imagine)
53 //! Running is organised around basic tools : TransientProcess and
54 //! its Actor, results are Binders and CheckIterators. It implies
55 //! control by a Controller (which prepares the Actor as required)
57 //! Getting results can be done directly on TransientProcess, but
58 //! these are immediate "last produced" results. Each transfer of
59 //! an entity gives a final result, but also possible intermediate
60 //! data, and checks, which can be attached to sub-entities.
62 //! Hence, final results (which intermediates and checks) are
63 //! recorded as ResultFromModel and can be queried individually.
65 //! Some more direct access are given for results which are
66 //! Transient or Shapes
67 class XSControl_TransferReader : public MMgt_TShared
73 //! Creates a TransferReader, empty
74 Standard_EXPORT XSControl_TransferReader();
76 //! Sets a Controller. It is required to generate the Actor.
77 //! Elsewhere, the Actor must be provided directly
78 Standard_EXPORT void SetController (const Handle(XSControl_Controller)& control);
80 //! Sets the Actor directly : this value will be used if the
81 //! Controller is not set
82 Standard_EXPORT void SetActor (const Handle(Transfer_ActorOfTransientProcess)& actor);
84 //! Returns the Actor, determined by the Controller, or if this
85 //! one is unknown, directly set.
86 //! Once it has been defined, it can then be edited.
87 Standard_EXPORT Handle(Transfer_ActorOfTransientProcess) Actor();
89 //! Sets an InterfaceModel. This causes former results, computed
90 //! from another one, to be lost (see also Clear)
91 Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& model);
93 //! Sets a Graph and its InterfaceModel (calls SetModel)
94 Standard_EXPORT void SetGraph (const Handle(Interface_HGraph)& graph);
96 //! Returns the currently set InterfaceModel
97 Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
99 //! Sets a Context : according to receiving appli, to be
100 //! interpreted by the Actor
101 Standard_EXPORT void SetContext (const Standard_CString name, const Handle(Standard_Transient)& ctx);
103 //! Returns the Context attached to a name, if set and if it is
104 //! Kind of the type, else a Null Handle
105 //! Returns True if OK, False if no Context
106 Standard_EXPORT Standard_Boolean GetContext (const Standard_CString name, const Handle(Standard_Type)& type, Handle(Standard_Transient)& ctx) const;
108 //! Returns (modifiable) the whole definition of Context
109 //! Rather for internal use (ex.: preparing and setting in once)
110 Standard_EXPORT Handle(Dico_DictionaryOfTransient)& Context();
112 //! Sets a new value for (loaded) file name
113 Standard_EXPORT void SetFileName (const Standard_CString name);
115 //! Returns actual value of file name
116 Standard_EXPORT Standard_CString FileName() const;
118 //! Clears data, according mode :
122 //! +2 working data (model, context, transfer process)
123 Standard_EXPORT void Clear (const Standard_Integer mode);
125 //! Returns the currently used TransientProcess
126 //! It is computed from the model by TransferReadRoots, or by
127 //! BeginTransferRead
128 Standard_EXPORT Handle(Transfer_TransientProcess) TransientProcess() const;
130 //! Forces the TransientProcess
131 //! Remark : it also changes the Model and the Actor, from those
132 //! recorded in the new TransientProcess
133 Standard_EXPORT void SetTransientProcess (const Handle(Transfer_TransientProcess)& TP);
135 //! Records a final result of transferring an entity
136 //! This result is recorded as a ResultFromModel, taken from
137 //! the TransientProcess
138 //! Returns True if a result is available, False else
139 Standard_EXPORT Standard_Boolean RecordResult (const Handle(Standard_Transient)& ent);
141 //! Returns True if a final result is recorded for an entity
142 //! Remark that it can bring no effective result if transfer has
143 //! completely failed (FinalResult brings only fail messages ...)
144 Standard_EXPORT Standard_Boolean IsRecorded (const Handle(Standard_Transient)& ent) const;
146 //! Returns True if a final result is recorded AND BRINGS AN
147 //! EFFECTIVE RESULT (else, it brings only fail messages)
148 Standard_EXPORT Standard_Boolean HasResult (const Handle(Standard_Transient)& ent) const;
150 //! Returns the list of entities to which a final result is
151 //! attached (i.e. processed by RecordResult)
152 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) RecordedList() const;
154 //! Note that an entity has been required for transfer but no
155 //! result at all is available (typically : case not implemented)
156 //! It is not an error, but it gives a specific status : Skipped
157 //! Returns True if done, False if <ent> is not in starting model
158 Standard_EXPORT Standard_Boolean Skip (const Handle(Standard_Transient)& ent);
160 //! Returns True if an entity is noted as skipped
161 Standard_EXPORT Standard_Boolean IsSkipped (const Handle(Standard_Transient)& ent) const;
163 //! Returns True if an entity has been asked for transfert, hence
164 //! it is marked, as : Recorded (a computation has ran, with or
165 //! without an effective result), or Skipped (case ignored)
166 Standard_EXPORT Standard_Boolean IsMarked (const Handle(Standard_Transient)& ent) const;
168 //! Returns the final result recorded for an entity, as such
169 Standard_EXPORT Handle(Transfer_ResultFromModel) FinalResult (const Handle(Standard_Transient)& ent) const;
171 //! Returns the label attached to an entity recorded for final,
172 //! or an empty string if not recorded
173 Standard_EXPORT Standard_CString FinalEntityLabel (const Handle(Standard_Transient)& ent) const;
175 //! Returns the number attached to the entity recorded for final,
176 //! or zero if not recorded (looks in the ResultFromModel)
177 Standard_EXPORT Standard_Integer FinalEntityNumber (const Handle(Standard_Transient)& ent) const;
179 //! Returns the final result recorded for a NUMBER of entity
180 //! (internal use). Null if out of range
181 Standard_EXPORT Handle(Transfer_ResultFromModel) ResultFromNumber (const Standard_Integer num) const;
183 //! Returns the resulting object as a Transient
184 //! Null Handle if no result or result not transient
185 Standard_EXPORT Handle(Standard_Transient) TransientResult (const Handle(Standard_Transient)& ent) const;
187 //! Returns the resulting object as a Shape
188 //! Null Shape if no result or result not a shape
189 Standard_EXPORT TopoDS_Shape ShapeResult (const Handle(Standard_Transient)& ent) const;
191 //! Clears recorded result for an entity, according mode
192 //! <mode> = -1 : true, complete, clearing (erasing result)
193 //! <mode> >= 0 : simple "stripping", see ResultFromModel,
194 //! in particular, 0 for simple internal strip,
195 //! 10 for all but final result,
196 //! 11 for all : just label, status and filename are kept
197 //! Returns True when done, False if nothing was to clear
198 Standard_EXPORT Standard_Boolean ClearResult (const Handle(Standard_Transient)& ent, const Standard_Integer mode);
200 //! Returns an entity from which a given result was produced.
201 //! If <mode> = 0 (D), searches in last root transfers
202 //! If <mode> = 1, searches in last (root & sub) transfers
203 //! If <mode> = 2, searches in root recorded results
204 //! If <mode> = 3, searches in all (root & sub) recordeds
205 //! <res> can be, either a transient object (result itself) or
206 //! a binder. For a binder of shape, calls EntityFromShapeResult
207 //! Returns a Null Handle if <res> not recorded
208 Standard_EXPORT Handle(Standard_Transient) EntityFromResult (const Handle(Standard_Transient)& res, const Standard_Integer mode = 0) const;
210 //! Returns an entity from which a given shape result was produced
211 //! Returns a Null Handle if <res> not recorded or not a Shape
212 Standard_EXPORT Handle(Standard_Transient) EntityFromShapeResult (const TopoDS_Shape& res, const Standard_Integer mode = 0) const;
214 //! Returns the list of entities from which some shapes were
215 //! produced : it corresponds to a loop on EntityFromShapeResult,
217 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) EntitiesFromShapeList (const Handle(TopTools_HSequenceOfShape)& res, const Standard_Integer mode = 0) const;
219 //! Returns the CheckList resulting from transferring <ent>, i.e.
220 //! stored in its recorded form ResultFromModel
221 //! (empty if transfer successful or not recorded ...)
223 //! If <ent> is the Model, returns the complete cumulated
224 //! check-list, <level> is ignored
226 //! If <ent> is an entity of the Model, <level> applies as follows
227 //! <level> : -1 for <ent> only, LAST transfer (TransientProcess)
228 //! <level> : 0 for <ent> only (D)
229 //! 1 for <ent> and its immediate subtransfers, if any
230 //! 2 for <ent> and subtransferts at all levels
231 Standard_EXPORT Interface_CheckIterator CheckList (const Handle(Standard_Transient)& ent, const Standard_Integer level = 0) const;
233 //! Returns True if an entity (with a final result) has checks :
234 //! - failsonly = False : any kind of check message
235 //! - failsonly = True : fails only
236 //! Returns False if <ent> is not recorded
237 Standard_EXPORT Standard_Boolean HasChecks (const Handle(Standard_Transient)& ent, const Standard_Boolean failsonly) const;
239 //! Returns the list of starting entities to which a given check
240 //! status is attached, IN FINAL RESULTS
241 //! <ent> can be an entity, or the model to query all entities
242 //! Below, "entities" are, either <ent> plus its sub-transferred,
243 //! or all the entities of the model
245 //! <check> = -2 , all entities whatever the check (see result)
246 //! <check> = -1 , entities with no fail (warning allowed)
247 //! <check> = 0 , entities with no check at all
248 //! <check> = 1 , entities with warning but no fail
249 //! <check> = 2 , entities with fail
250 //! <result> : if True, only entities with an attached result
251 //! Remark : result True and check=0 will give an empty list
252 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) CheckedList (const Handle(Standard_Transient)& ent, const Interface_CheckStatus withcheck = Interface_CheckAny, const Standard_Boolean result = Standard_True) const;
254 //! Defines a new TransferProcess for reading transfer
255 //! Returns True if done, False if data are not properly defined
256 //! (the Model, the Actor for Read)
257 Standard_EXPORT Standard_Boolean BeginTransfer();
259 //! Tells if an entity is recognized as a valid candidate for
260 //! Transfer. Calls method Recognize from the Actor (if known)
261 Standard_EXPORT Standard_Boolean Recognize (const Handle(Standard_Transient)& ent);
263 //! Commands the transfer on reading for an entity to data for
264 //! Imagine, using the selected Actor for Read
265 //! Returns count of transferred entities, ok or with fails (0/1)
266 //! If <rec> is True (D), the result is recorded by RecordResult
267 Standard_EXPORT Standard_Integer TransferOne (const Handle(Standard_Transient)& ent, const Standard_Boolean rec = Standard_True);
269 //! Commands the transfer on reading for a list of entities to
270 //! data for Imagine, using the selected Actor for Read
271 //! Returns count of transferred entities, ok or with fails (0/1)
272 //! If <rec> is True (D), the results are recorded by RecordResult
273 Standard_EXPORT Standard_Integer TransferList (const Handle(TColStd_HSequenceOfTransient)& list, const Standard_Boolean rec = Standard_True);
275 //! Transfers the content of the current Interface Model to
276 //! data handled by Imagine, starting from its Roots (determined
277 //! by the Graph <G>), using the selected Actor for Read
278 //! Returns the count of performed root transfers (i.e. 0 if none)
279 //! or -1 if no actor is defined
280 Standard_EXPORT Standard_Integer TransferRoots (const Interface_Graph& G);
282 //! Clears the results attached to an entity
283 //! if <ents> equates the starting model, clears all results
284 Standard_EXPORT void TransferClear (const Handle(Standard_Transient)& ent, const Standard_Integer level = 0);
286 //! Prints statistics on current Trace File, according <what> and
287 //! <mode>. See PrintStatsProcess for details
288 Standard_EXPORT void PrintStats (const Standard_Integer what, const Standard_Integer mode = 0) const;
290 //! Returns the CheckList resulting from last TransferRead
291 //! i.e. from TransientProcess itself, recorded from last Clear
292 Standard_EXPORT Interface_CheckIterator LastCheckList() const;
294 //! Returns the list of entities recorded as lastly transferred
295 //! i.e. from TransientProcess itself, recorded from last Clear
296 //! If <roots> is True , considers only roots of transfer
297 //! If <roots> is False, considers all entities bound with result
298 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) LastTransferList (const Standard_Boolean roots) const;
300 //! Returns a list of result Shapes
301 //! If <rec> is True , sees RecordedList
302 //! If <rec> is False, sees LastTransferList (last ROOT transfers)
303 //! For each one, if it is a Shape, it is cumulated to the list
304 //! If no Shape is found, returns an empty Sequence
305 Standard_EXPORT Handle(TopTools_HSequenceOfShape) ShapeResultList (const Standard_Boolean rec);
307 //! This routines prints statistics about a TransientProcess
308 //! It can be called, by a TransferReader, or isolately
309 //! Prints are done on the default trace file
310 //! <what> defines what kind of statistics are to be printed :
311 //! 0 : basic figures
313 //! 2 : all recorded (roots, intermediate, checked entities)
314 //! 3 : abnormal records
315 //! 4 : check messages (warnings and fails)
316 //! 5 : fail messages
318 //! <mode> is used according <what> :
319 //! <what> = 0 : <mode> is ignored
320 //! <what> = 1,2,3 : <mode> as follows :
321 //! 0 (D) : just lists numbers of concerned entities in the model
322 //! 1 : for each entity, gives number,label, type and result
323 //! type and/or status (fail/warning...)
324 //! 2 : for each entity, gives maximal information (i.e. checks)
325 //! 3 : counts per type of starting entity (class type)
326 //! 4 : counts per result type and/or status
327 //! 5 : counts per couple (starting type / result type/status)
328 //! 6 : idem plus gives for each item, the list of numbers of
329 //! entities in the starting model
331 //! <what> = 4,5 : modes relays on an enum PrintCount :
332 //! 0 (D) : ItemsByEntity (sequential list by entity)
334 //! 2 : ShortByItem (count + 5 first numbers)
335 //! 3 : ListByItem (count + entity numbers)
336 //! 4 : EntitiesByItem (count + entity numbers and labels)
337 Standard_EXPORT static void PrintStatsProcess (const Handle(Transfer_TransientProcess)& TP, const Standard_Integer what, const Standard_Integer mode = 0);
339 //! Works as PrintStatsProcess, but displays data only on the
340 //! entities which are in <list> (filter)
341 Standard_EXPORT static void PrintStatsOnList (const Handle(Transfer_TransientProcess)& TP, const Handle(TColStd_HSequenceOfTransient)& list, const Standard_Integer what, const Standard_Integer mode = 0);
346 DEFINE_STANDARD_RTTIEXT(XSControl_TransferReader,MMgt_TShared)
356 Handle(XSControl_Controller) theController;
357 TCollection_AsciiString theFilename;
358 Handle(Interface_InterfaceModel) theModel;
359 Handle(Interface_HGraph) theGraph;
360 Handle(Dico_DictionaryOfTransient) theContext;
361 Handle(Transfer_ActorOfTransientProcess) theActor;
362 Handle(Transfer_TransientProcess) theTransfer;
363 TColStd_DataMapOfIntegerTransient theResults;
364 Handle(TopTools_HSequenceOfShape) theShapeResult;
375 #endif // _XSControl_TransferReader_HeaderFile