Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:07

0001 // Created on: 1993-02-02
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1993-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 _Interface_CopyTool_HeaderFile
0018 #define _Interface_CopyTool_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Interface_BitMap.hxx>
0025 #include <Interface_GeneralLib.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <TColStd_SequenceOfInteger.hxx>
0028 class Interface_InterfaceModel;
0029 class Interface_CopyControl;
0030 class Interface_CopyMap;
0031 class Standard_Transient;
0032 class Interface_GeneralModule;
0033 class Interface_Protocol;
0034 class Interface_EntityIterator;
0035 
0036 
0037 //! Performs Deep Copies of sets of Entities
0038 //! Allows to perform Copy of Interface Entities from a Model to
0039 //! another one. Works by calling general services GetFromAnother
0040 //! and GetImplied.
0041 //! Uses a CopyMap to bind a unique Result to each Copied Entity
0042 //!
0043 //! It is possible to command Copies of Entities (and those they
0044 //! reference) by call to the General Service Library, or to
0045 //! enforce results for transfer of some Entities (calling Bind)
0046 //!
0047 //! A Same CopyTool can be used for several successive Copies from
0048 //! the same Model : either by restarting from scratch (e.g. to
0049 //! copy different parts of a starting Model to several Targets),
0050 //! or incremental : in that case, it is possible to know what is
0051 //! the content of the last increment (defined by last call to
0052 //! ClearLastFlags  and queried by call to LastCopiedAfter)
0053 //!
0054 //! Works in two times : first, create the list of copied Entities
0055 //! second, pushes them to a target Model (manages also Model's
0056 //! Header) or returns the Result as an Iterator, as desired
0057 //!
0058 //! The core action (Copy) works by using ShallowCopy (method
0059 //! attached to each class) and Copy from GeneralLib (itself using
0060 //! dedicated tools). It can be redefined for specific actions.
0061 class Interface_CopyTool 
0062 {
0063 public:
0064 
0065   DEFINE_STANDARD_ALLOC
0066 
0067   
0068   //! Creates a CopyTool adapted to work from a Model. Works
0069   //! with a General Service Library, given as an argument
0070   Standard_EXPORT Interface_CopyTool(const Handle(Interface_InterfaceModel)& amodel, const Interface_GeneralLib& lib);
0071   
0072   //! Same as above, but Library is defined through a Protocol
0073   Standard_EXPORT Interface_CopyTool(const Handle(Interface_InterfaceModel)& amodel, const Handle(Interface_Protocol)& protocol);
0074   
0075   //! Same as above, but works with the Active Protocol
0076   Standard_EXPORT Interface_CopyTool(const Handle(Interface_InterfaceModel)& amodel);
0077   
0078   //! Returns the Model on which the CopyTool works
0079   Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
0080   
0081   //! Changes the Map of Result for another one. This allows to work
0082   //! with a more sophisticated Mapping Control than the Standard
0083   //! one which is CopyMap (e.g. TransferProcess from Transfer)
0084   Standard_EXPORT void SetControl (const Handle(Interface_CopyControl)& othermap);
0085   
0086   //! Returns the object used for Control
0087   Standard_EXPORT Handle(Interface_CopyControl) Control() const;
0088   
0089   //! Clears Transfer List. Gets Ready to begin another Transfer
0090   Standard_EXPORT virtual void Clear();
0091   
0092   //! Creates the CounterPart of an Entity (by ShallowCopy), Binds
0093   //! it, then Copies the content of the former Entity to the other
0094   //! one (same Type), by call to the General Service Library
0095   //! It may command the Copy of Referenced Entities
0096   //! Then, its returns True.
0097   //!
0098   //! If <mapped> is True, the Map is used to store the Result
0099   //! Else, the Result is simply produced : it can be used to Copy
0100   //! internal sub-parts of Entities, which are not intended to be
0101   //! shared (Strings, Arrays, etc...)
0102   //! If <errstat> is True, this means that the Entity is recorded
0103   //! in the Model as Erroneous : in this case, the General Service
0104   //! for Deep Copy is not called (this could be dangerous) : hence
0105   //! the Counter-Part is produced but empty, it can be referenced.
0106   //!
0107   //! This method does nothing and returns False if the Protocol
0108   //! does not recognize <ent>.
0109   //! It basically makes a Deep Copy without changing the Types.
0110   //! It can be redefined for special uses.
0111   Standard_EXPORT virtual Standard_Boolean Copy (const Handle(Standard_Transient)& entfrom, Handle(Standard_Transient)& entto, const Standard_Boolean mapped, const Standard_Boolean errstat);
0112   
0113   //! Transfers one Entity, if not yet bound to a result
0114   //! Remark : For an Entity which is reported in the Starting Model,
0115   //! the ReportEntity will also be copied with its Content if it
0116   //! has one (at least ShallowCopy; Complete Copy if the Protocol
0117   //! recognizes the Content : see method Copy)
0118   Standard_EXPORT Handle(Standard_Transient) Transferred (const Handle(Standard_Transient)& ent);
0119   
0120   //! Defines a Result for the Transfer of a Starting object.
0121   //! Used by method Transferred (which performs a normal Copy),
0122   //! but can also be called to enforce a result : in the latter
0123   //! case, the enforced result must be compatible with the other
0124   //! Transfers which are performed
0125   Standard_EXPORT void Bind (const Handle(Standard_Transient)& ent, const Handle(Standard_Transient)& res);
0126   
0127   //! Search for the result of a Starting Object (i.e. an Entity)
0128   //! Returns True  if a  Result is Bound (and fills "result")
0129   //! Returns False if no result is Bound
0130   Standard_EXPORT Standard_Boolean Search (const Handle(Standard_Transient)& ent, Handle(Standard_Transient)& res) const;
0131   
0132   //! Clears LastFlags only. This allows to know what Entities are
0133   //! copied after its call (see method LastCopiedAfter). It can be
0134   //! used when copies are done by increments, which must be
0135   //! distinghished. ClearLastFlags is also called by Clear.
0136   Standard_EXPORT void ClearLastFlags();
0137   
0138   //! Returns an copied Entity and its Result which were operated
0139   //! after last call to ClearLastFlags. It returns the first
0140   //! "Last Copied Entity" which Number follows <numfrom>, Zero if
0141   //! none. It is used in a loop as follow :
0142   //! Integer num = 0;
0143   //! while ( (num = CopyTool.LastCopiedAfter(num,ent,res)) ) {
0144   //! .. Process Starting <ent> and its Result <res>
0145   //! }
0146   Standard_EXPORT Standard_Integer LastCopiedAfter (const Standard_Integer numfrom, Handle(Standard_Transient)& ent, Handle(Standard_Transient)& res) const;
0147   
0148   //! Transfers one Entity and records result into the Transfer List
0149   //! Calls method Transferred
0150   Standard_EXPORT void TransferEntity (const Handle(Standard_Transient)& ent);
0151   
0152   //! Renews the Implied References. These References do not involve
0153   //! Copying of referenced Entities. For such a Reference, if the
0154   //! Entity which defines it AND the referenced Entity are both
0155   //! copied, then this Reference is renewed. Else it is deleted in
0156   //! the copied Entities.
0157   //! Remark : this concerns only some specific references, such as
0158   //! "back pointers".
0159   Standard_EXPORT void RenewImpliedRefs();
0160   
0161   //! Fills a Model with the result of the transfer (TransferList)
0162   //! Commands copy of Header too, and calls RenewImpliedRefs
0163   Standard_EXPORT void FillModel (const Handle(Interface_InterfaceModel)& bmodel);
0164   
0165   //! Returns the complete list of copied Entities
0166   //! If <withreports> is given True, the entities which were
0167   //! reported in the Starting Model are replaced in the list
0168   //! by the copied ReportEntities
0169   Standard_EXPORT Interface_EntityIterator CompleteResult (const Standard_Boolean withreports = Standard_False) const;
0170   
0171   //! Returns the list of Root copied Entities (those which were
0172   //! asked for copy by the user of CopyTool, not by copying
0173   //! another Entity)
0174   Standard_EXPORT Interface_EntityIterator RootResult (const Standard_Boolean withreports = Standard_False) const;
0175   Standard_EXPORT virtual ~Interface_CopyTool();
0176 
0177 
0178 
0179 
0180 protected:
0181 
0182   
0183   //! Creates a new void instance (just created) of the same class
0184   //! as <entfrom>. Uses the general service GeneralModule:NewVoid
0185   //! Returns True if OK (Recognize has succeeded), False else
0186   //! (in such a case, the standard method ShallowCopy is called
0187   //! to produce <ento> from <entfrom> : hence it is not void)
0188   //!
0189   //! No mapping is managed by this method
0190   Standard_EXPORT virtual Standard_Boolean NewVoid (const Handle(Standard_Transient)& entfrom, Handle(Standard_Transient)& entto);
0191 
0192 
0193   Interface_GeneralLib thelib;
0194 
0195 
0196 private:
0197 
0198   
0199   //! Renews the Implied References of one already Copied Entity
0200   Standard_EXPORT virtual void Implied (const Handle(Standard_Transient)& entfrom, const Handle(Standard_Transient)& entto);
0201 
0202 
0203   Handle(Interface_InterfaceModel) themod;
0204   Handle(Interface_CopyControl) themap;
0205   Handle(Interface_CopyMap) therep;
0206   Interface_BitMap thelst;
0207   Standard_Integer thelev;
0208   TColStd_SequenceOfInteger therts;
0209   Standard_Boolean theimp;
0210   Handle(Standard_Transient) theent;
0211   Handle(Interface_GeneralModule) themdu;
0212   Standard_Integer theCN;
0213 
0214 
0215 };
0216 
0217 
0218 
0219 
0220 
0221 
0222 
0223 #endif // _Interface_CopyTool_HeaderFile