42cf5bc1 |
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 |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _XSControl_TransferReader_HeaderFile |
18 | #define _XSControl_TransferReader_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <TCollection_AsciiString.hxx> |
24 | #include <TColStd_DataMapOfIntegerTransient.hxx> |
25 | #include <TopTools_HSequenceOfShape.hxx> |
25e59720 |
26 | #include <Standard_Transient.hxx> |
42cf5bc1 |
27 | #include <TColStd_HSequenceOfTransient.hxx> |
28 | #include <Interface_CheckStatus.hxx> |
7e785937 |
29 | #include <Message_ProgressRange.hxx> |
30 | |
42cf5bc1 |
31 | class XSControl_Controller; |
32 | class Interface_InterfaceModel; |
33 | class Interface_HGraph; |
42cf5bc1 |
34 | class Transfer_ActorOfTransientProcess; |
35 | class Transfer_TransientProcess; |
42cf5bc1 |
36 | class Transfer_ResultFromModel; |
37 | class TopoDS_Shape; |
38 | class Interface_CheckIterator; |
39 | class Interface_Graph; |
40 | |
42cf5bc1 |
41 | class XSControl_TransferReader; |
25e59720 |
42 | DEFINE_STANDARD_HANDLE(XSControl_TransferReader, Standard_Transient) |
42cf5bc1 |
43 | |
44 | //! A TransferReader performs, manages, handles results of, |
45 | //! transfers done when reading a file (i.e. from entities of an |
46 | //! InterfaceModel, to objects for Imagine) |
47 | //! |
48 | //! Running is organised around basic tools : TransientProcess and |
49 | //! its Actor, results are Binders and CheckIterators. It implies |
50 | //! control by a Controller (which prepares the Actor as required) |
51 | //! |
52 | //! Getting results can be done directly on TransientProcess, but |
53 | //! these are immediate "last produced" results. Each transfer of |
54 | //! an entity gives a final result, but also possible intermediate |
55 | //! data, and checks, which can be attached to sub-entities. |
56 | //! |
57 | //! Hence, final results (which intermediates and checks) are |
58 | //! recorded as ResultFromModel and can be queried individually. |
59 | //! |
60 | //! Some more direct access are given for results which are |
61 | //! Transient or Shapes |
25e59720 |
62 | class XSControl_TransferReader : public Standard_Transient |
42cf5bc1 |
63 | { |
7f56eba8 |
64 | public: |
42cf5bc1 |
65 | |
42cf5bc1 |
66 | //! Creates a TransferReader, empty |
7f56eba8 |
67 | XSControl_TransferReader() |
68 | {} |
42cf5bc1 |
69 | |
70 | //! Sets a Controller. It is required to generate the Actor. |
71 | //! Elsewhere, the Actor must be provided directly |
7f56eba8 |
72 | Standard_EXPORT void SetController (const Handle(XSControl_Controller)& theControl); |
42cf5bc1 |
73 | |
74 | //! Sets the Actor directly : this value will be used if the |
75 | //! Controller is not set |
7f56eba8 |
76 | void SetActor (const Handle(Transfer_ActorOfTransientProcess)& theActor) |
77 | { myActor = theActor; } |
42cf5bc1 |
78 | |
79 | //! Returns the Actor, determined by the Controller, or if this |
80 | //! one is unknown, directly set. |
81 | //! Once it has been defined, it can then be edited. |
82 | Standard_EXPORT Handle(Transfer_ActorOfTransientProcess) Actor(); |
83 | |
84 | //! Sets an InterfaceModel. This causes former results, computed |
85 | //! from another one, to be lost (see also Clear) |
7f56eba8 |
86 | Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& theModel); |
42cf5bc1 |
87 | |
88 | //! Sets a Graph and its InterfaceModel (calls SetModel) |
7f56eba8 |
89 | Standard_EXPORT void SetGraph (const Handle(Interface_HGraph)& theGraph); |
42cf5bc1 |
90 | |
91 | //! Returns the currently set InterfaceModel |
7f56eba8 |
92 | const Handle(Interface_InterfaceModel) & Model() const |
93 | { return myModel; } |
42cf5bc1 |
94 | |
95 | //! Sets a Context : according to receiving appli, to be |
96 | //! interpreted by the Actor |
7f56eba8 |
97 | Standard_EXPORT void SetContext (const Standard_CString theName, const Handle(Standard_Transient)& theCtx); |
42cf5bc1 |
98 | |
99 | //! Returns the Context attached to a name, if set and if it is |
100 | //! Kind of the type, else a Null Handle |
101 | //! Returns True if OK, False if no Context |
7f56eba8 |
102 | Standard_EXPORT Standard_Boolean GetContext (const Standard_CString theName, const Handle(Standard_Type)& theType, Handle(Standard_Transient)& theCtx) const; |
42cf5bc1 |
103 | |
104 | //! Returns (modifiable) the whole definition of Context |
105 | //! Rather for internal use (ex.: preparing and setting in once) |
997e128f |
106 | NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& Context() |
7f56eba8 |
107 | { return myContext; } |
42cf5bc1 |
108 | |
109 | //! Sets a new value for (loaded) file name |
7f56eba8 |
110 | void SetFileName (const Standard_CString theName) |
111 | { myFileName = theName; } |
112 | |
42cf5bc1 |
113 | //! Returns actual value of file name |
7f56eba8 |
114 | Standard_CString FileName() const |
115 | { return myFileName.ToCString(); } |
42cf5bc1 |
116 | |
117 | //! Clears data, according mode : |
118 | //! -1 all |
119 | //! 0 nothing done |
120 | //! +1 final results |
121 | //! +2 working data (model, context, transfer process) |
7f56eba8 |
122 | Standard_EXPORT void Clear (const Standard_Integer theMode); |
42cf5bc1 |
123 | |
124 | //! Returns the currently used TransientProcess |
125 | //! It is computed from the model by TransferReadRoots, or by |
126 | //! BeginTransferRead |
7f56eba8 |
127 | const Handle(Transfer_TransientProcess) & TransientProcess () const |
128 | { return myTP; } |
42cf5bc1 |
129 | |
130 | //! Forces the TransientProcess |
131 | //! Remark : it also changes the Model and the Actor, from those |
132 | //! recorded in the new TransientProcess |
7f56eba8 |
133 | void SetTransientProcess (const Handle(Transfer_TransientProcess)& theTP) |
134 | { myTP = theTP; } |
42cf5bc1 |
135 | |
136 | //! Records a final result of transferring an entity |
137 | //! This result is recorded as a ResultFromModel, taken from |
138 | //! the TransientProcess |
139 | //! Returns True if a result is available, False else |
7f56eba8 |
140 | Standard_EXPORT Standard_Boolean RecordResult (const Handle(Standard_Transient)& theEnt); |
42cf5bc1 |
141 | |
142 | //! Returns True if a final result is recorded for an entity |
143 | //! Remark that it can bring no effective result if transfer has |
144 | //! completely failed (FinalResult brings only fail messages ...) |
7f56eba8 |
145 | Standard_EXPORT Standard_Boolean IsRecorded (const Handle(Standard_Transient)& theEnt) const; |
42cf5bc1 |
146 | |
147 | //! Returns True if a final result is recorded AND BRINGS AN |
148 | //! EFFECTIVE RESULT (else, it brings only fail messages) |
7f56eba8 |
149 | Standard_EXPORT Standard_Boolean HasResult (const Handle(Standard_Transient)& theEnt) const; |
42cf5bc1 |
150 | |
151 | //! Returns the list of entities to which a final result is |
152 | //! attached (i.e. processed by RecordResult) |
153 | Standard_EXPORT Handle(TColStd_HSequenceOfTransient) RecordedList() const; |
154 | |
155 | //! Note that an entity has been required for transfer but no |
156 | //! result at all is available (typically : case not implemented) |
157 | //! It is not an error, but it gives a specific status : Skipped |
158 | //! Returns True if done, False if <ent> is not in starting model |
7f56eba8 |
159 | Standard_EXPORT Standard_Boolean Skip (const Handle(Standard_Transient)& theEnt); |
42cf5bc1 |
160 | |
161 | //! Returns True if an entity is noted as skipped |
7f56eba8 |
162 | Standard_EXPORT Standard_Boolean IsSkipped (const Handle(Standard_Transient)& theEnt) const; |
42cf5bc1 |
163 | |
164 | //! Returns True if an entity has been asked for transfert, hence |
165 | //! it is marked, as : Recorded (a computation has ran, with or |
166 | //! without an effective result), or Skipped (case ignored) |
7f56eba8 |
167 | Standard_EXPORT Standard_Boolean IsMarked (const Handle(Standard_Transient)& theEnt) const; |
42cf5bc1 |
168 | |
169 | //! Returns the final result recorded for an entity, as such |
7f56eba8 |
170 | Standard_EXPORT Handle(Transfer_ResultFromModel) FinalResult (const Handle(Standard_Transient)& theEnt) const; |
42cf5bc1 |
171 | |
172 | //! Returns the label attached to an entity recorded for final, |
173 | //! or an empty string if not recorded |
7f56eba8 |
174 | Standard_EXPORT Standard_CString FinalEntityLabel (const Handle(Standard_Transient)& theEnt) const; |
42cf5bc1 |
175 | |
176 | //! Returns the number attached to the entity recorded for final, |
177 | //! or zero if not recorded (looks in the ResultFromModel) |
7f56eba8 |
178 | Standard_EXPORT Standard_Integer FinalEntityNumber (const Handle(Standard_Transient)& theEnt) const; |
42cf5bc1 |
179 | |
180 | //! Returns the final result recorded for a NUMBER of entity |
181 | //! (internal use). Null if out of range |
7f56eba8 |
182 | Standard_EXPORT Handle(Transfer_ResultFromModel) ResultFromNumber (const Standard_Integer theNum) const; |
42cf5bc1 |
183 | |
184 | //! Returns the resulting object as a Transient |
185 | //! Null Handle if no result or result not transient |
7f56eba8 |
186 | Standard_EXPORT Handle(Standard_Transient) TransientResult (const Handle(Standard_Transient)& theEnt) const; |
42cf5bc1 |
187 | |
188 | //! Returns the resulting object as a Shape |
189 | //! Null Shape if no result or result not a shape |
7f56eba8 |
190 | Standard_EXPORT TopoDS_Shape ShapeResult (const Handle(Standard_Transient)& theEnt) const; |
42cf5bc1 |
191 | |
192 | //! Clears recorded result for an entity, according mode |
193 | //! <mode> = -1 : true, complete, clearing (erasing result) |
194 | //! <mode> >= 0 : simple "stripping", see ResultFromModel, |
195 | //! in particular, 0 for simple internal strip, |
196 | //! 10 for all but final result, |
197 | //! 11 for all : just label, status and filename are kept |
198 | //! Returns True when done, False if nothing was to clear |
7f56eba8 |
199 | Standard_EXPORT Standard_Boolean ClearResult (const Handle(Standard_Transient)& theEnt, const Standard_Integer theMode); |
42cf5bc1 |
200 | |
201 | //! Returns an entity from which a given result was produced. |
202 | //! If <mode> = 0 (D), searches in last root transfers |
203 | //! If <mode> = 1, searches in last (root & sub) transfers |
204 | //! If <mode> = 2, searches in root recorded results |
205 | //! If <mode> = 3, searches in all (root & sub) recordeds |
206 | //! <res> can be, either a transient object (result itself) or |
207 | //! a binder. For a binder of shape, calls EntityFromShapeResult |
208 | //! Returns a Null Handle if <res> not recorded |
7f56eba8 |
209 | Standard_EXPORT Handle(Standard_Transient) EntityFromResult (const Handle(Standard_Transient)& theRes, const Standard_Integer theMode = 0) const; |
42cf5bc1 |
210 | |
211 | //! Returns an entity from which a given shape result was produced |
212 | //! Returns a Null Handle if <res> not recorded or not a Shape |
7f56eba8 |
213 | Standard_EXPORT Handle(Standard_Transient) EntityFromShapeResult (const TopoDS_Shape& theRes, const Standard_Integer theMode = 0) const; |
42cf5bc1 |
214 | |
215 | //! Returns the list of entities from which some shapes were |
216 | //! produced : it corresponds to a loop on EntityFromShapeResult, |
217 | //! but is optimised |
7f56eba8 |
218 | Standard_EXPORT Handle(TColStd_HSequenceOfTransient) EntitiesFromShapeList (const Handle(TopTools_HSequenceOfShape)& theRes, const Standard_Integer theMode = 0) const; |
42cf5bc1 |
219 | |
220 | //! Returns the CheckList resulting from transferring <ent>, i.e. |
221 | //! stored in its recorded form ResultFromModel |
222 | //! (empty if transfer successful or not recorded ...) |
223 | //! |
224 | //! If <ent> is the Model, returns the complete cumulated |
225 | //! check-list, <level> is ignored |
226 | //! |
227 | //! If <ent> is an entity of the Model, <level> applies as follows |
228 | //! <level> : -1 for <ent> only, LAST transfer (TransientProcess) |
229 | //! <level> : 0 for <ent> only (D) |
230 | //! 1 for <ent> and its immediate subtransfers, if any |
231 | //! 2 for <ent> and subtransferts at all levels |
7f56eba8 |
232 | Standard_EXPORT Interface_CheckIterator CheckList (const Handle(Standard_Transient)& theEnt, const Standard_Integer theLevel = 0) const; |
42cf5bc1 |
233 | |
234 | //! Returns True if an entity (with a final result) has checks : |
235 | //! - failsonly = False : any kind of check message |
236 | //! - failsonly = True : fails only |
237 | //! Returns False if <ent> is not recorded |
7f56eba8 |
238 | Standard_EXPORT Standard_Boolean HasChecks (const Handle(Standard_Transient)& theEnt, const Standard_Boolean FailsOnly) const; |
42cf5bc1 |
239 | |
240 | //! Returns the list of starting entities to which a given check |
241 | //! status is attached, IN FINAL RESULTS |
242 | //! <ent> can be an entity, or the model to query all entities |
243 | //! Below, "entities" are, either <ent> plus its sub-transferred, |
244 | //! or all the entities of the model |
245 | //! |
246 | //! <check> = -2 , all entities whatever the check (see result) |
247 | //! <check> = -1 , entities with no fail (warning allowed) |
248 | //! <check> = 0 , entities with no check at all |
249 | //! <check> = 1 , entities with warning but no fail |
250 | //! <check> = 2 , entities with fail |
251 | //! <result> : if True, only entities with an attached result |
252 | //! Remark : result True and check=0 will give an empty list |
7f56eba8 |
253 | Standard_EXPORT Handle(TColStd_HSequenceOfTransient) CheckedList (const Handle(Standard_Transient)& theEnt, const Interface_CheckStatus WithCheck = Interface_CheckAny, const Standard_Boolean theResult = Standard_True) const; |
42cf5bc1 |
254 | |
255 | //! Defines a new TransferProcess for reading transfer |
256 | //! Returns True if done, False if data are not properly defined |
257 | //! (the Model, the Actor for Read) |
258 | Standard_EXPORT Standard_Boolean BeginTransfer(); |
259 | |
260 | //! Tells if an entity is recognized as a valid candidate for |
261 | //! Transfer. Calls method Recognize from the Actor (if known) |
7f56eba8 |
262 | Standard_EXPORT Standard_Boolean Recognize (const Handle(Standard_Transient)& theEnt); |
42cf5bc1 |
263 | |
264 | //! Commands the transfer on reading for an entity to data for |
265 | //! Imagine, using the selected Actor for Read |
266 | //! Returns count of transferred entities, ok or with fails (0/1) |
267 | //! If <rec> is True (D), the result is recorded by RecordResult |
7e785937 |
268 | Standard_EXPORT Standard_Integer TransferOne (const Handle(Standard_Transient)& theEnt, |
269 | const Standard_Boolean theRec = Standard_True, |
270 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
271 | |
272 | //! Commands the transfer on reading for a list of entities to |
273 | //! data for Imagine, using the selected Actor for Read |
274 | //! Returns count of transferred entities, ok or with fails (0/1) |
275 | //! If <rec> is True (D), the results are recorded by RecordResult |
7e785937 |
276 | Standard_EXPORT Standard_Integer TransferList (const Handle(TColStd_HSequenceOfTransient)& theList, |
277 | const Standard_Boolean theRec = Standard_True, |
278 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
279 | |
280 | //! Transfers the content of the current Interface Model to |
281 | //! data handled by Imagine, starting from its Roots (determined |
282 | //! by the Graph <G>), using the selected Actor for Read |
283 | //! Returns the count of performed root transfers (i.e. 0 if none) |
284 | //! or -1 if no actor is defined |
7e785937 |
285 | Standard_EXPORT Standard_Integer TransferRoots (const Interface_Graph &theGraph, |
286 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
287 | |
288 | //! Clears the results attached to an entity |
289 | //! if <ents> equates the starting model, clears all results |
7f56eba8 |
290 | Standard_EXPORT void TransferClear (const Handle(Standard_Transient)& theEnt, const Standard_Integer theLevel = 0); |
42cf5bc1 |
291 | |
292 | //! Prints statistics on current Trace File, according <what> and |
293 | //! <mode>. See PrintStatsProcess for details |
0ebe5b0a |
294 | Standard_EXPORT void PrintStats (Standard_OStream& theStream, const Standard_Integer theWhat, const Standard_Integer theMode = 0) const; |
42cf5bc1 |
295 | |
296 | //! Returns the CheckList resulting from last TransferRead |
297 | //! i.e. from TransientProcess itself, recorded from last Clear |
298 | Standard_EXPORT Interface_CheckIterator LastCheckList() const; |
299 | |
300 | //! Returns the list of entities recorded as lastly transferred |
301 | //! i.e. from TransientProcess itself, recorded from last Clear |
302 | //! If <roots> is True , considers only roots of transfer |
303 | //! If <roots> is False, considers all entities bound with result |
7f56eba8 |
304 | Standard_EXPORT Handle(TColStd_HSequenceOfTransient) LastTransferList (const Standard_Boolean theRoots) const; |
42cf5bc1 |
305 | |
306 | //! Returns a list of result Shapes |
307 | //! If <rec> is True , sees RecordedList |
308 | //! If <rec> is False, sees LastTransferList (last ROOT transfers) |
309 | //! For each one, if it is a Shape, it is cumulated to the list |
310 | //! If no Shape is found, returns an empty Sequence |
7f56eba8 |
311 | Standard_EXPORT const Handle(TopTools_HSequenceOfShape) & ShapeResultList (const Standard_Boolean theRec); |
42cf5bc1 |
312 | |
313 | //! This routines prints statistics about a TransientProcess |
314 | //! It can be called, by a TransferReader, or isolately |
315 | //! Prints are done on the default trace file |
316 | //! <what> defines what kind of statistics are to be printed : |
317 | //! 0 : basic figures |
318 | //! 1 : root results |
319 | //! 2 : all recorded (roots, intermediate, checked entities) |
320 | //! 3 : abnormal records |
321 | //! 4 : check messages (warnings and fails) |
322 | //! 5 : fail messages |
323 | //! |
324 | //! <mode> is used according <what> : |
325 | //! <what> = 0 : <mode> is ignored |
326 | //! <what> = 1,2,3 : <mode> as follows : |
327 | //! 0 (D) : just lists numbers of concerned entities in the model |
328 | //! 1 : for each entity, gives number,label, type and result |
329 | //! type and/or status (fail/warning...) |
330 | //! 2 : for each entity, gives maximal information (i.e. checks) |
331 | //! 3 : counts per type of starting entity (class type) |
332 | //! 4 : counts per result type and/or status |
333 | //! 5 : counts per couple (starting type / result type/status) |
334 | //! 6 : idem plus gives for each item, the list of numbers of |
335 | //! entities in the starting model |
336 | //! |
337 | //! <what> = 4,5 : modes relays on an enum PrintCount : |
338 | //! 0 (D) : ItemsByEntity (sequential list by entity) |
339 | //! 1 : CountByItem |
340 | //! 2 : ShortByItem (count + 5 first numbers) |
341 | //! 3 : ListByItem (count + entity numbers) |
342 | //! 4 : EntitiesByItem (count + entity numbers and labels) |
7f56eba8 |
343 | Standard_EXPORT static void PrintStatsProcess (const Handle(Transfer_TransientProcess)& theTP, const Standard_Integer theWhat, const Standard_Integer theMode = 0); |
42cf5bc1 |
344 | |
345 | //! Works as PrintStatsProcess, but displays data only on the |
346 | //! entities which are in <list> (filter) |
7f56eba8 |
347 | Standard_EXPORT static void PrintStatsOnList (const Handle(Transfer_TransientProcess)& theTP, const Handle(TColStd_HSequenceOfTransient)& theList, const Standard_Integer theWhat, const Standard_Integer theMode = 0); |
42cf5bc1 |
348 | |
25e59720 |
349 | DEFINE_STANDARD_RTTIEXT(XSControl_TransferReader,Standard_Transient) |
42cf5bc1 |
350 | |
7f56eba8 |
351 | private: |
42cf5bc1 |
352 | |
7f56eba8 |
353 | Handle(XSControl_Controller) myController; |
354 | TCollection_AsciiString myFileName; |
355 | Handle(Interface_InterfaceModel) myModel; |
356 | Handle(Interface_HGraph) myGraph; |
997e128f |
357 | NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> myContext; |
7f56eba8 |
358 | Handle(Transfer_ActorOfTransientProcess) myActor; |
359 | Handle(Transfer_TransientProcess) myTP; |
360 | TColStd_DataMapOfIntegerTransient myResults; |
361 | Handle(TopTools_HSequenceOfShape) myShapeResult; |
42cf5bc1 |
362 | }; |
363 | |
42cf5bc1 |
364 | #endif // _XSControl_TransferReader_HeaderFile |