Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:36

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 
0066   //! Creates a TransferReader, empty
0067   XSControl_TransferReader()
0068   {}
0069   
0070   //! Sets a Controller. It is required to generate the Actor.
0071   //! Elsewhere, the Actor must be provided directly
0072   Standard_EXPORT void SetController (const Handle(XSControl_Controller)& theControl);
0073   
0074   //! Sets the Actor directly : this value will be used if the
0075   //! Controller is not set
0076   void SetActor (const Handle(Transfer_ActorOfTransientProcess)& theActor)
0077   { myActor = theActor; }
0078   
0079   //! Returns the Actor, determined by the Controller, or if this
0080   //! one is unknown, directly set.
0081   //! Once it has been defined, it can then be edited.
0082   Standard_EXPORT Handle(Transfer_ActorOfTransientProcess) Actor();
0083   
0084   //! Sets an InterfaceModel. This causes former results, computed
0085   //! from another one, to be lost (see also Clear)
0086   Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& theModel);
0087   
0088   //! Sets a Graph and its InterfaceModel (calls SetModel)
0089   Standard_EXPORT void SetGraph (const Handle(Interface_HGraph)& theGraph);
0090   
0091   //! Returns the currently set InterfaceModel
0092   const Handle(Interface_InterfaceModel) & Model() const
0093   { return myModel; }
0094   
0095   //! Sets a Context : according to receiving appli, to be
0096   //! interpreted by the Actor
0097   Standard_EXPORT void SetContext (const Standard_CString theName, const Handle(Standard_Transient)& theCtx);
0098   
0099   //! Returns the Context attached to a name, if set and if it is
0100   //! Kind of the type, else a Null Handle
0101   //! Returns True if OK, False if no Context
0102   Standard_EXPORT Standard_Boolean GetContext (const Standard_CString theName, const Handle(Standard_Type)& theType, Handle(Standard_Transient)& theCtx) const;
0103   
0104   //! Returns (modifiable) the whole definition of Context
0105   //! Rather for internal use (ex.: preparing and setting in once)
0106   NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& Context()
0107   { return myContext; }
0108   
0109   //! Sets a new value for (loaded) file name
0110   void SetFileName (const Standard_CString theName)
0111   { myFileName = theName; }
0112 
0113   //! Returns actual value of file name
0114   Standard_CString FileName() const
0115   { return myFileName.ToCString(); }
0116   
0117   //! Clears data, according mode :
0118   //! -1 all
0119   //! 0 nothing done
0120   //! +1 final results
0121   //! +2 working data (model, context, transfer process)
0122   Standard_EXPORT void Clear (const Standard_Integer theMode);
0123   
0124   //! Returns the currently used TransientProcess
0125   //! It is computed from the model by TransferReadRoots, or by
0126   //! BeginTransferRead
0127   const Handle(Transfer_TransientProcess) & TransientProcess () const
0128   { return myTP; }
0129   
0130   //! Forces the TransientProcess
0131   //! Remark : it also changes the Model and the Actor, from those
0132   //! recorded in the new TransientProcess
0133   void SetTransientProcess (const Handle(Transfer_TransientProcess)& theTP)
0134   { myTP = theTP; }
0135   
0136   //! Records a final result of transferring an entity
0137   //! This result is recorded as a ResultFromModel, taken from
0138   //! the TransientProcess
0139   //! Returns True if a result is available, False else
0140   Standard_EXPORT Standard_Boolean RecordResult (const Handle(Standard_Transient)& theEnt);
0141   
0142   //! Returns True if a final result is recorded for an entity
0143   //! Remark that it can bring no effective result if transfer has
0144   //! completely failed (FinalResult brings only fail messages ...)
0145   Standard_EXPORT Standard_Boolean IsRecorded (const Handle(Standard_Transient)& theEnt) const;
0146   
0147   //! Returns True if a final result is recorded AND BRINGS AN
0148   //! EFFECTIVE RESULT (else, it brings only fail messages)
0149   Standard_EXPORT Standard_Boolean HasResult (const Handle(Standard_Transient)& theEnt) const;
0150   
0151   //! Returns the list of entities to which a final result is
0152   //! attached (i.e. processed by RecordResult)
0153   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) RecordedList() const;
0154   
0155   //! Note that an entity has been required for transfer but no
0156   //! result at all is available (typically : case not implemented)
0157   //! It is not an error, but it gives a specific status : Skipped
0158   //! Returns True if done, False if <ent> is not in starting model
0159   Standard_EXPORT Standard_Boolean Skip (const Handle(Standard_Transient)& theEnt);
0160   
0161   //! Returns True if an entity is noted as skipped
0162   Standard_EXPORT Standard_Boolean IsSkipped (const Handle(Standard_Transient)& theEnt) const;
0163   
0164   //! Returns True if an entity has been asked for transfert, hence
0165   //! it is marked, as : Recorded (a computation has ran, with or
0166   //! without an effective result), or Skipped (case ignored)
0167   Standard_EXPORT Standard_Boolean IsMarked (const Handle(Standard_Transient)& theEnt) const;
0168   
0169   //! Returns the final result recorded for an entity, as such
0170   Standard_EXPORT Handle(Transfer_ResultFromModel) FinalResult (const Handle(Standard_Transient)& theEnt) const;
0171   
0172   //! Returns the label attached to an entity recorded for final,
0173   //! or an empty string if not recorded
0174   Standard_EXPORT Standard_CString FinalEntityLabel (const Handle(Standard_Transient)& theEnt) const;
0175   
0176   //! Returns the number attached to the entity recorded for final,
0177   //! or zero if not recorded (looks in the ResultFromModel)
0178   Standard_EXPORT Standard_Integer FinalEntityNumber (const Handle(Standard_Transient)& theEnt) const;
0179   
0180   //! Returns the final result recorded for a NUMBER of entity
0181   //! (internal use). Null if out of range
0182   Standard_EXPORT Handle(Transfer_ResultFromModel) ResultFromNumber (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 (const Handle(Standard_Transient)& theEnt) const;
0187   
0188   //! Returns the resulting object as a Shape
0189   //! Null Shape if no result or result not a shape
0190   Standard_EXPORT TopoDS_Shape ShapeResult (const Handle(Standard_Transient)& theEnt) const;
0191   
0192   //! Clears recorded result for an entity, according mode
0193   //! <mode> = -1 : true, complete, clearing (erasing result)
0194   //! <mode> >= 0 : simple "stripping", see ResultFromModel,
0195   //! in particular, 0 for simple internal strip,
0196   //! 10 for all but final result,
0197   //! 11 for all : just label, status and filename are kept
0198   //! Returns True when done, False if nothing was to clear
0199   Standard_EXPORT Standard_Boolean ClearResult (const Handle(Standard_Transient)& theEnt, const Standard_Integer theMode);
0200   
0201   //! Returns an entity from which a given result was produced.
0202   //! If <mode> = 0 (D), searches in last root transfers
0203   //! If <mode> = 1,     searches in last (root & sub) transfers
0204   //! If <mode> = 2,     searches in root recorded results
0205   //! If <mode> = 3,     searches in all (root & sub) recordeds
0206   //! <res> can be, either a transient object (result itself) or
0207   //! a binder. For a binder of shape, calls EntityFromShapeResult
0208   //! Returns a Null Handle if <res> not recorded
0209   Standard_EXPORT Handle(Standard_Transient) EntityFromResult (const Handle(Standard_Transient)& theRes, const Standard_Integer theMode = 0) const;
0210   
0211   //! Returns an entity from which a given shape result was produced
0212   //! Returns a Null Handle if <res> not recorded or not a Shape
0213   Standard_EXPORT Handle(Standard_Transient) EntityFromShapeResult (const TopoDS_Shape& theRes, const Standard_Integer theMode = 0) const;
0214   
0215   //! Returns the list of entities from which some shapes were
0216   //! produced : it corresponds to a loop on EntityFromShapeResult,
0217   //! but is optimised
0218   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) EntitiesFromShapeList (const Handle(TopTools_HSequenceOfShape)& theRes, const Standard_Integer theMode = 0) const;
0219   
0220   //! Returns the CheckList resulting from transferring <ent>, i.e.
0221   //! stored in its recorded form ResultFromModel
0222   //! (empty if transfer successful or not recorded ...)
0223   //!
0224   //! If <ent> is the Model, returns the complete cumulated
0225   //! check-list, <level> is ignored
0226   //!
0227   //! If <ent> is an entity of the Model, <level> applies as follows
0228   //! <level> : -1 for <ent> only, LAST transfer (TransientProcess)
0229   //! <level> : 0  for <ent> only (D)
0230   //! 1  for <ent> and its immediate subtransfers, if any
0231   //! 2  for <ent> and subtransferts at all levels
0232   Standard_EXPORT Interface_CheckIterator CheckList (const Handle(Standard_Transient)& theEnt, const Standard_Integer theLevel = 0) const;
0233   
0234   //! Returns True if an entity (with a final result) has checks :
0235   //! - failsonly = False : any kind of check message
0236   //! - failsonly = True  : fails only
0237   //! Returns False if <ent> is not recorded
0238   Standard_EXPORT Standard_Boolean HasChecks (const Handle(Standard_Transient)& theEnt, const Standard_Boolean FailsOnly) const;
0239   
0240   //! Returns the list of starting entities to which a given check
0241   //! status is attached, IN FINAL RESULTS
0242   //! <ent> can be an entity, or the model to query all entities
0243   //! Below, "entities" are, either <ent> plus its sub-transferred,
0244   //! or all the entities of the model
0245   //!
0246   //! <check> = -2 , all entities whatever the check (see result)
0247   //! <check> = -1 , entities with no fail (warning allowed)
0248   //! <check> =  0 , entities with no check at all
0249   //! <check> =  1 , entities with warning but no fail
0250   //! <check> =  2 , entities with fail
0251   //! <result> : if True, only entities with an attached result
0252   //! Remark : result True and check=0 will give an empty list
0253   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) CheckedList (const Handle(Standard_Transient)& theEnt, const Interface_CheckStatus WithCheck = Interface_CheckAny, const Standard_Boolean theResult = Standard_True) const;
0254   
0255   //! Defines a new TransferProcess for reading transfer
0256   //! Returns True if done, False if data are not properly defined
0257   //! (the Model, the Actor for Read)
0258   Standard_EXPORT Standard_Boolean BeginTransfer();
0259   
0260   //! Tells if an entity is recognized as a valid candidate for
0261   //! Transfer. Calls method Recognize from the Actor (if known)
0262   Standard_EXPORT Standard_Boolean Recognize (const Handle(Standard_Transient)& theEnt);
0263   
0264   //! Commands the transfer on reading for an entity to data for
0265   //! Imagine, using the selected Actor for Read
0266   //! Returns count of transferred entities, ok or with fails (0/1)
0267   //! If <rec> is True (D), the result is recorded by RecordResult
0268   Standard_EXPORT Standard_Integer TransferOne (const Handle(Standard_Transient)& theEnt,
0269                                                 const Standard_Boolean theRec = Standard_True,
0270                                                 const Message_ProgressRange& theProgress = Message_ProgressRange());
0271   
0272   //! Commands the transfer on reading for a list of entities to
0273   //! data for Imagine, using the selected Actor for Read
0274   //! Returns count of transferred entities, ok or with fails (0/1)
0275   //! If <rec> is True (D), the results are recorded by RecordResult
0276   Standard_EXPORT Standard_Integer TransferList (const Handle(TColStd_HSequenceOfTransient)& theList,
0277                                                  const Standard_Boolean theRec = Standard_True,
0278                                                  const Message_ProgressRange& theProgress = Message_ProgressRange());
0279   
0280   //! Transfers the content of the current Interface Model to
0281   //! data handled by Imagine, starting from its Roots (determined
0282   //! by the Graph <G>),  using the selected Actor for Read
0283   //! Returns the count of performed root transfers (i.e. 0 if none)
0284   //! or -1 if no actor is defined
0285   Standard_EXPORT Standard_Integer TransferRoots (const Interface_Graph &theGraph,
0286                                                   const Message_ProgressRange& theProgress = Message_ProgressRange());
0287   
0288   //! Clears the results attached to an entity
0289   //! if <ents> equates the starting model, clears all results
0290   Standard_EXPORT void TransferClear (const Handle(Standard_Transient)& theEnt, const Standard_Integer theLevel = 0);
0291   
0292   //! Prints statistics on current Trace File, according <what> and
0293   //! <mode>.  See PrintStatsProcess for details
0294   Standard_EXPORT void PrintStats (Standard_OStream& theStream, const Standard_Integer theWhat, const Standard_Integer theMode = 0) const;
0295   
0296   //! Returns the CheckList resulting from last TransferRead
0297   //! i.e. from TransientProcess itself, recorded from last Clear
0298   Standard_EXPORT Interface_CheckIterator LastCheckList() const;
0299   
0300   //! Returns the list of entities recorded as lastly transferred
0301   //! i.e. from TransientProcess itself, recorded from last Clear
0302   //! If <roots> is True , considers only roots of transfer
0303   //! If <roots> is False, considers all entities bound with result
0304   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) LastTransferList (const Standard_Boolean theRoots) const;
0305   
0306   //! Returns a list of result Shapes
0307   //! If <rec> is True , sees RecordedList
0308   //! If <rec> is False, sees LastTransferList (last ROOT transfers)
0309   //! For each one, if it is a Shape, it is cumulated to the list
0310   //! If no Shape is found, returns an empty Sequence
0311   Standard_EXPORT const Handle(TopTools_HSequenceOfShape) & ShapeResultList (const Standard_Boolean theRec);
0312   
0313   //! This routines prints statistics about a TransientProcess
0314   //! It can be called, by a TransferReader, or isolately
0315   //! Prints are done on the default trace file
0316   //! <what> defines what kind of statistics are to be printed :
0317   //! 0 : basic figures
0318   //! 1 : root results
0319   //! 2 : all recorded (roots, intermediate, checked entities)
0320   //! 3 : abnormal records
0321   //! 4 : check messages (warnings and fails)
0322   //! 5 : fail messages
0323   //!
0324   //! <mode> is used according <what> :
0325   //! <what> = 0 : <mode> is ignored
0326   //! <what> = 1,2,3 : <mode> as follows :
0327   //! 0 (D) : just lists numbers of concerned entities in the model
0328   //! 1 : for each entity, gives number,label, type and result
0329   //! type and/or status (fail/warning...)
0330   //! 2 : for each entity, gives maximal information (i.e. checks)
0331   //! 3 : counts per type of starting entity (class type)
0332   //! 4 : counts per result type and/or status
0333   //! 5 : counts per couple (starting type / result type/status)
0334   //! 6 : idem plus gives for each item, the list of numbers of
0335   //! entities in the starting model
0336   //!
0337   //! <what> = 4,5 : modes relays on an enum PrintCount :
0338   //! 0 (D) : ItemsByEntity (sequential list by entity)
0339   //! 1 : CountByItem
0340   //! 2 : ShortByItem       (count + 5 first numbers)
0341   //! 3 : ListByItem        (count + entity numbers)
0342   //! 4 : EntitiesByItem    (count + entity numbers and labels)
0343   Standard_EXPORT static void PrintStatsProcess (const Handle(Transfer_TransientProcess)& theTP, const Standard_Integer theWhat, const Standard_Integer theMode = 0);
0344   
0345   //! Works as PrintStatsProcess, but displays data only on the
0346   //! entities which are in <list> (filter)
0347   Standard_EXPORT static void PrintStatsOnList (const Handle(Transfer_TransientProcess)& theTP, const Handle(TColStd_HSequenceOfTransient)& theList, const Standard_Integer theWhat, const Standard_Integer theMode = 0);
0348 
0349   DEFINE_STANDARD_RTTIEXT(XSControl_TransferReader,Standard_Transient)
0350 
0351  private:
0352 
0353   Handle(XSControl_Controller) myController;
0354   TCollection_AsciiString myFileName;
0355   Handle(Interface_InterfaceModel) myModel;
0356   Handle(Interface_HGraph) myGraph;
0357   NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> myContext;
0358   Handle(Transfer_ActorOfTransientProcess) myActor;
0359   Handle(Transfer_TransientProcess) myTP;
0360   TColStd_DataMapOfIntegerTransient myResults;
0361   Handle(TopTools_HSequenceOfShape) myShapeResult;
0362 };
0363 
0364 #endif // _XSControl_TransferReader_HeaderFile