|
|
|||
File indexing completed on 2026-05-04 08:46:43
0001 // Created on: 1995-12-05 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1995-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _XSControl_TransferReader_HeaderFile 0018 #define _XSControl_TransferReader_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_Type.hxx> 0022 0023 #include <TCollection_AsciiString.hxx> 0024 #include <TColStd_DataMapOfIntegerTransient.hxx> 0025 #include <TopTools_HSequenceOfShape.hxx> 0026 #include <Standard_Transient.hxx> 0027 #include <TColStd_HSequenceOfTransient.hxx> 0028 #include <Interface_CheckStatus.hxx> 0029 #include <Message_ProgressRange.hxx> 0030 0031 class XSControl_Controller; 0032 class Interface_InterfaceModel; 0033 class Interface_HGraph; 0034 class Transfer_ActorOfTransientProcess; 0035 class Transfer_TransientProcess; 0036 class Transfer_ResultFromModel; 0037 class TopoDS_Shape; 0038 class Interface_CheckIterator; 0039 class Interface_Graph; 0040 0041 class XSControl_TransferReader; 0042 DEFINE_STANDARD_HANDLE(XSControl_TransferReader, Standard_Transient) 0043 0044 //! A TransferReader performs, manages, handles results of, 0045 //! transfers done when reading a file (i.e. from entities of an 0046 //! InterfaceModel, to objects for Imagine) 0047 //! 0048 //! Running is organised around basic tools : TransientProcess and 0049 //! its Actor, results are Binders and CheckIterators. It implies 0050 //! control by a Controller (which prepares the Actor as required) 0051 //! 0052 //! Getting results can be done directly on TransientProcess, but 0053 //! these are immediate "last produced" results. Each transfer of 0054 //! an entity gives a final result, but also possible intermediate 0055 //! data, and checks, which can be attached to sub-entities. 0056 //! 0057 //! Hence, final results (which intermediates and checks) are 0058 //! recorded as ResultFromModel and can be queried individually. 0059 //! 0060 //! Some more direct access are given for results which are 0061 //! Transient or Shapes 0062 class XSControl_TransferReader : public Standard_Transient 0063 { 0064 public: 0065 //! Creates a TransferReader, empty 0066 XSControl_TransferReader() {} 0067 0068 //! Sets a Controller. It is required to generate the Actor. 0069 //! Elsewhere, the Actor must be provided directly 0070 Standard_EXPORT void SetController(const Handle(XSControl_Controller)& theControl); 0071 0072 //! Sets the Actor directly : this value will be used if the 0073 //! Controller is not set 0074 void SetActor(const Handle(Transfer_ActorOfTransientProcess)& theActor) { myActor = theActor; } 0075 0076 //! Returns the Actor, determined by the Controller, or if this 0077 //! one is unknown, directly set. 0078 //! Once it has been defined, it can then be edited. 0079 Standard_EXPORT Handle(Transfer_ActorOfTransientProcess) Actor(); 0080 0081 //! Sets an InterfaceModel. This causes former results, computed 0082 //! from another one, to be lost (see also Clear) 0083 Standard_EXPORT void SetModel(const Handle(Interface_InterfaceModel)& theModel); 0084 0085 //! Sets a Graph and its InterfaceModel (calls SetModel) 0086 Standard_EXPORT void SetGraph(const Handle(Interface_HGraph)& theGraph); 0087 0088 //! Returns the currently set InterfaceModel 0089 const Handle(Interface_InterfaceModel)& Model() const { return myModel; } 0090 0091 //! Sets a Context : according to receiving appli, to be 0092 //! interpreted by the Actor 0093 Standard_EXPORT void SetContext(const Standard_CString theName, 0094 const Handle(Standard_Transient)& theCtx); 0095 0096 //! Returns the Context attached to a name, if set and if it is 0097 //! Kind of the type, else a Null Handle 0098 //! Returns True if OK, False if no Context 0099 Standard_EXPORT Standard_Boolean GetContext(const Standard_CString theName, 0100 const Handle(Standard_Type)& theType, 0101 Handle(Standard_Transient)& theCtx) const; 0102 0103 //! Returns (modifiable) the whole definition of Context 0104 //! Rather for internal use (ex.: preparing and setting in once) 0105 NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& Context() 0106 { 0107 return myContext; 0108 } 0109 0110 //! Sets a new value for (loaded) file name 0111 void SetFileName(const Standard_CString theName) { myFileName = theName; } 0112 0113 //! Returns actual value of file name 0114 Standard_CString FileName() const { return myFileName.ToCString(); } 0115 0116 //! Clears data, according mode : 0117 //! -1 all 0118 //! 0 nothing done 0119 //! +1 final results 0120 //! +2 working data (model, context, transfer process) 0121 Standard_EXPORT void Clear(const Standard_Integer theMode); 0122 0123 //! Returns the currently used TransientProcess 0124 //! It is computed from the model by TransferReadRoots, or by 0125 //! BeginTransferRead 0126 const Handle(Transfer_TransientProcess)& TransientProcess() const { return myTP; } 0127 0128 //! Forces the TransientProcess 0129 //! Remark : it also changes the Model and the Actor, from those 0130 //! recorded in the new TransientProcess 0131 void SetTransientProcess(const Handle(Transfer_TransientProcess)& theTP) { myTP = theTP; } 0132 0133 //! Records a final result of transferring an entity 0134 //! This result is recorded as a ResultFromModel, taken from 0135 //! the TransientProcess 0136 //! Returns True if a result is available, False else 0137 Standard_EXPORT Standard_Boolean RecordResult(const Handle(Standard_Transient)& theEnt); 0138 0139 //! Returns True if a final result is recorded for an entity 0140 //! Remark that it can bring no effective result if transfer has 0141 //! completely failed (FinalResult brings only fail messages ...) 0142 Standard_EXPORT Standard_Boolean IsRecorded(const Handle(Standard_Transient)& theEnt) const; 0143 0144 //! Returns True if a final result is recorded AND BRINGS AN 0145 //! EFFECTIVE RESULT (else, it brings only fail messages) 0146 Standard_EXPORT Standard_Boolean HasResult(const Handle(Standard_Transient)& theEnt) const; 0147 0148 //! Returns the list of entities to which a final result is 0149 //! attached (i.e. processed by RecordResult) 0150 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) RecordedList() const; 0151 0152 //! Note that an entity has been required for transfer but no 0153 //! result at all is available (typically : case not implemented) 0154 //! It is not an error, but it gives a specific status : Skipped 0155 //! Returns True if done, False if <ent> is not in starting model 0156 Standard_EXPORT Standard_Boolean Skip(const Handle(Standard_Transient)& theEnt); 0157 0158 //! Returns True if an entity is noted as skipped 0159 Standard_EXPORT Standard_Boolean IsSkipped(const Handle(Standard_Transient)& theEnt) const; 0160 0161 //! Returns True if an entity has been asked for transfert, hence 0162 //! it is marked, as : Recorded (a computation has ran, with or 0163 //! without an effective result), or Skipped (case ignored) 0164 Standard_EXPORT Standard_Boolean IsMarked(const Handle(Standard_Transient)& theEnt) const; 0165 0166 //! Returns the final result recorded for an entity, as such 0167 Standard_EXPORT Handle(Transfer_ResultFromModel) FinalResult( 0168 const Handle(Standard_Transient)& theEnt) const; 0169 0170 //! Returns the label attached to an entity recorded for final, 0171 //! or an empty string if not recorded 0172 Standard_EXPORT Standard_CString FinalEntityLabel(const Handle(Standard_Transient)& theEnt) const; 0173 0174 //! Returns the number attached to the entity recorded for final, 0175 //! or zero if not recorded (looks in the ResultFromModel) 0176 Standard_EXPORT Standard_Integer 0177 FinalEntityNumber(const Handle(Standard_Transient)& theEnt) const; 0178 0179 //! Returns the final result recorded for a NUMBER of entity 0180 //! (internal use). Null if out of range 0181 Standard_EXPORT Handle(Transfer_ResultFromModel) ResultFromNumber( 0182 const Standard_Integer theNum) const; 0183 0184 //! Returns the resulting object as a Transient 0185 //! Null Handle if no result or result not transient 0186 Standard_EXPORT Handle(Standard_Transient) TransientResult( 0187 const Handle(Standard_Transient)& theEnt) const; 0188 0189 //! Returns the resulting object as a Shape 0190 //! Null Shape if no result or result not a shape 0191 Standard_EXPORT TopoDS_Shape ShapeResult(const Handle(Standard_Transient)& theEnt) const; 0192 0193 //! Clears recorded result for an entity, according mode 0194 //! <mode> = -1 : true, complete, clearing (erasing result) 0195 //! <mode> >= 0 : simple "stripping", see ResultFromModel, 0196 //! in particular, 0 for simple internal strip, 0197 //! 10 for all but final result, 0198 //! 11 for all : just label, status and filename are kept 0199 //! Returns True when done, False if nothing was to clear 0200 Standard_EXPORT Standard_Boolean ClearResult(const Handle(Standard_Transient)& theEnt, 0201 const Standard_Integer theMode); 0202 0203 //! Returns an entity from which a given result was produced. 0204 //! If <mode> = 0 (D), searches in last root transfers 0205 //! If <mode> = 1, searches in last (root & sub) transfers 0206 //! If <mode> = 2, searches in root recorded results 0207 //! If <mode> = 3, searches in all (root & sub) recordeds 0208 //! <res> can be, either a transient object (result itself) or 0209 //! a binder. For a binder of shape, calls EntityFromShapeResult 0210 //! Returns a Null Handle if <res> not recorded 0211 Standard_EXPORT Handle(Standard_Transient) EntityFromResult( 0212 const Handle(Standard_Transient)& theRes, 0213 const Standard_Integer theMode = 0) const; 0214 0215 //! Returns an entity from which a given shape result was produced 0216 //! Returns a Null Handle if <res> not recorded or not a Shape 0217 Standard_EXPORT Handle(Standard_Transient) EntityFromShapeResult( 0218 const TopoDS_Shape& theRes, 0219 const Standard_Integer theMode = 0) const; 0220 0221 //! Returns the list of entities from which some shapes were 0222 //! produced : it corresponds to a loop on EntityFromShapeResult, 0223 //! but is optimised 0224 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) EntitiesFromShapeList( 0225 const Handle(TopTools_HSequenceOfShape)& theRes, 0226 const Standard_Integer theMode = 0) const; 0227 0228 //! Returns the CheckList resulting from transferring <ent>, i.e. 0229 //! stored in its recorded form ResultFromModel 0230 //! (empty if transfer successful or not recorded ...) 0231 //! 0232 //! If <ent> is the Model, returns the complete cumulated 0233 //! check-list, <level> is ignored 0234 //! 0235 //! If <ent> is an entity of the Model, <level> applies as follows 0236 //! <level> : -1 for <ent> only, LAST transfer (TransientProcess) 0237 //! <level> : 0 for <ent> only (D) 0238 //! 1 for <ent> and its immediate subtransfers, if any 0239 //! 2 for <ent> and subtransferts at all levels 0240 Standard_EXPORT Interface_CheckIterator CheckList(const Handle(Standard_Transient)& theEnt, 0241 const Standard_Integer theLevel = 0) const; 0242 0243 //! Returns True if an entity (with a final result) has checks : 0244 //! - failsonly = False : any kind of check message 0245 //! - failsonly = True : fails only 0246 //! Returns False if <ent> is not recorded 0247 Standard_EXPORT Standard_Boolean HasChecks(const Handle(Standard_Transient)& theEnt, 0248 const Standard_Boolean FailsOnly) const; 0249 0250 //! Returns the list of starting entities to which a given check 0251 //! status is attached, IN FINAL RESULTS 0252 //! <ent> can be an entity, or the model to query all entities 0253 //! Below, "entities" are, either <ent> plus its sub-transferred, 0254 //! or all the entities of the model 0255 //! 0256 //! <check> = -2 , all entities whatever the check (see result) 0257 //! <check> = -1 , entities with no fail (warning allowed) 0258 //! <check> = 0 , entities with no check at all 0259 //! <check> = 1 , entities with warning but no fail 0260 //! <check> = 2 , entities with fail 0261 //! <result> : if True, only entities with an attached result 0262 //! Remark : result True and check=0 will give an empty list 0263 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) CheckedList( 0264 const Handle(Standard_Transient)& theEnt, 0265 const Interface_CheckStatus WithCheck = Interface_CheckAny, 0266 const Standard_Boolean theResult = Standard_True) const; 0267 0268 //! Defines a new TransferProcess for reading transfer 0269 //! Returns True if done, False if data are not properly defined 0270 //! (the Model, the Actor for Read) 0271 Standard_EXPORT Standard_Boolean BeginTransfer(); 0272 0273 //! Tells if an entity is recognized as a valid candidate for 0274 //! Transfer. Calls method Recognize from the Actor (if known) 0275 Standard_EXPORT Standard_Boolean Recognize(const Handle(Standard_Transient)& theEnt); 0276 0277 //! Commands the transfer on reading for an entity to data for 0278 //! Imagine, using the selected Actor for Read 0279 //! Returns count of transferred entities, ok or with fails (0/1) 0280 //! If <rec> is True (D), the result is recorded by RecordResult 0281 Standard_EXPORT Standard_Integer 0282 TransferOne(const Handle(Standard_Transient)& theEnt, 0283 const Standard_Boolean theRec = Standard_True, 0284 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0285 0286 //! Commands the transfer on reading for a list of entities to 0287 //! data for Imagine, using the selected Actor for Read 0288 //! Returns count of transferred entities, ok or with fails (0/1) 0289 //! If <rec> is True (D), the results are recorded by RecordResult 0290 Standard_EXPORT Standard_Integer 0291 TransferList(const Handle(TColStd_HSequenceOfTransient)& theList, 0292 const Standard_Boolean theRec = Standard_True, 0293 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0294 0295 //! Transfers the content of the current Interface Model to 0296 //! data handled by Imagine, starting from its Roots (determined 0297 //! by the Graph <G>), using the selected Actor for Read 0298 //! Returns the count of performed root transfers (i.e. 0 if none) 0299 //! or -1 if no actor is defined 0300 Standard_EXPORT Standard_Integer 0301 TransferRoots(const Interface_Graph& theGraph, 0302 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0303 0304 //! Clears the results attached to an entity 0305 //! if <ents> equates the starting model, clears all results 0306 Standard_EXPORT void TransferClear(const Handle(Standard_Transient)& theEnt, 0307 const Standard_Integer theLevel = 0); 0308 0309 //! Prints statistics on current Trace File, according <what> and 0310 //! <mode>. See PrintStatsProcess for details 0311 Standard_EXPORT void PrintStats(Standard_OStream& theStream, 0312 const Standard_Integer theWhat, 0313 const Standard_Integer theMode = 0) const; 0314 0315 //! Returns the CheckList resulting from last TransferRead 0316 //! i.e. from TransientProcess itself, recorded from last Clear 0317 Standard_EXPORT Interface_CheckIterator LastCheckList() const; 0318 0319 //! Returns the list of entities recorded as lastly transferred 0320 //! i.e. from TransientProcess itself, recorded from last Clear 0321 //! If <roots> is True , considers only roots of transfer 0322 //! If <roots> is False, considers all entities bound with result 0323 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) LastTransferList( 0324 const Standard_Boolean theRoots) const; 0325 0326 //! Returns a list of result Shapes 0327 //! If <rec> is True , sees RecordedList 0328 //! If <rec> is False, sees LastTransferList (last ROOT transfers) 0329 //! For each one, if it is a Shape, it is cumulated to the list 0330 //! If no Shape is found, returns an empty Sequence 0331 Standard_EXPORT const Handle(TopTools_HSequenceOfShape)& ShapeResultList( 0332 const Standard_Boolean theRec); 0333 0334 //! This routines prints statistics about a TransientProcess 0335 //! It can be called, by a TransferReader, or isolately 0336 //! Prints are done on the default trace file 0337 //! <what> defines what kind of statistics are to be printed : 0338 //! 0 : basic figures 0339 //! 1 : root results 0340 //! 2 : all recorded (roots, intermediate, checked entities) 0341 //! 3 : abnormal records 0342 //! 4 : check messages (warnings and fails) 0343 //! 5 : fail messages 0344 //! 0345 //! <mode> is used according <what> : 0346 //! <what> = 0 : <mode> is ignored 0347 //! <what> = 1,2,3 : <mode> as follows : 0348 //! 0 (D) : just lists numbers of concerned entities in the model 0349 //! 1 : for each entity, gives number,label, type and result 0350 //! type and/or status (fail/warning...) 0351 //! 2 : for each entity, gives maximal information (i.e. checks) 0352 //! 3 : counts per type of starting entity (class type) 0353 //! 4 : counts per result type and/or status 0354 //! 5 : counts per couple (starting type / result type/status) 0355 //! 6 : idem plus gives for each item, the list of numbers of 0356 //! entities in the starting model 0357 //! 0358 //! <what> = 4,5 : modes relays on an enum PrintCount : 0359 //! 0 (D) : ItemsByEntity (sequential list by entity) 0360 //! 1 : CountByItem 0361 //! 2 : ShortByItem (count + 5 first numbers) 0362 //! 3 : ListByItem (count + entity numbers) 0363 //! 4 : EntitiesByItem (count + entity numbers and labels) 0364 Standard_EXPORT static void PrintStatsProcess(const Handle(Transfer_TransientProcess)& theTP, 0365 const Standard_Integer theWhat, 0366 const Standard_Integer theMode = 0); 0367 0368 //! Works as PrintStatsProcess, but displays data only on the 0369 //! entities which are in <list> (filter) 0370 Standard_EXPORT static void PrintStatsOnList(const Handle(Transfer_TransientProcess)& theTP, 0371 const Handle(TColStd_HSequenceOfTransient)& theList, 0372 const Standard_Integer theWhat, 0373 const Standard_Integer theMode = 0); 0374 0375 DEFINE_STANDARD_RTTIEXT(XSControl_TransferReader, Standard_Transient) 0376 0377 private: 0378 Handle(XSControl_Controller) myController; 0379 TCollection_AsciiString myFileName; 0380 Handle(Interface_InterfaceModel) myModel; 0381 Handle(Interface_HGraph) myGraph; 0382 NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> myContext; 0383 Handle(Transfer_ActorOfTransientProcess) myActor; 0384 Handle(Transfer_TransientProcess) myTP; 0385 TColStd_DataMapOfIntegerTransient myResults; 0386 Handle(TopTools_HSequenceOfShape) myShapeResult; 0387 }; 0388 0389 #endif // _XSControl_TransferReader_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|