Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-06 09:20:50

0001 // Created on: 1993-08-26
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 _IFSelect_ModelCopier_HeaderFile
0018 #define _IFSelect_ModelCopier_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Interface_InterfaceModel.hxx>
0024 #include <NCollection_Sequence.hxx>
0025 #include <TCollection_AsciiString.hxx>
0026 #include <IFSelect_AppliedModifiers.hxx>
0027 #include <Standard_Integer.hxx>
0028 #include <NCollection_Array1.hxx>
0029 #include <NCollection_HArray1.hxx>
0030 #include <TCollection_HAsciiString.hxx>
0031 #include <NCollection_HSequence.hxx>
0032 #include <Standard_Transient.hxx>
0033 class IFSelect_ShareOut;
0034 class TCollection_AsciiString;
0035 class Interface_InterfaceModel;
0036 class IFSelect_AppliedModifiers;
0037 class Interface_CheckIterator;
0038 class IFSelect_ShareOutResult;
0039 class IFSelect_WorkLibrary;
0040 class Interface_Protocol;
0041 class Interface_CopyTool;
0042 class Interface_Graph;
0043 class Interface_EntityIterator;
0044 
0045 //! This class performs the Copy operations involved by the
0046 //! description of a ShareOut (evaluated by a ShareOutResult)
0047 //! plus, if there are, the Modifications on the results, with
0048 //! the help of Modifiers. Each Modifier can work on one or more
0049 //! resulting packets, according to its criteria : it operates on
0050 //! a Model once copied and filled with the content of the packet.
0051 //!
0052 //! Modifiers can be :
0053 //! - Model Modifiers, inheriting from the specific class Modifier
0054 //! able to run on the content of a Model (header or entities),
0055 //! activated by the ModelCopier itself
0056 //! - File Modifiers, inheriting directly from GeneralModifier,
0057 //! intended to be activated under the control of a WorkLibrary,
0058 //! once the Model has been produced (i.e. to act on output
0059 //! format, or other specific file features)
0060 //!
0061 //! The Copy operations can be :
0062 //! - immediately put to files : for each packet, a Model is
0063 //! created and filled, then the file is output, at that's all
0064 //! - memorized : for each packet, a Model is created and filled,
0065 //! it is memorized with the corresponding file name.
0066 //! it is possible to query the result of memorization (list of
0067 //! produced Models and their file names)
0068 //! -> it is also possible to send it into the files :
0069 //! once files are written, the result is cleared
0070 //!
0071 //! In addition, a list of really written files is managed :
0072 //! A first call to BeginSentFiles clears the list and commands,
0073 //! either to begin a new list, or to stop recording it. A call
0074 //! to SentFiles returns the list (if recording has been required)
0075 //! This list allows to globally exploit the set of produced files
0076 //!
0077 //! Remark : For operations which concern specific Entities, see
0078 //! also in package IFAdapt : a sub-class of ModelCopier allows
0079 //! to work with EntityModifier, in addition to Modifier itself
0080 //! which still applies to a whole copied Model.
0081 class IFSelect_ModelCopier : public Standard_Transient
0082 {
0083 
0084 public:
0085   //! Creates an empty ModelCopier
0086   Standard_EXPORT IFSelect_ModelCopier();
0087 
0088   //! Sets the ShareOut, which is used to define Modifiers to apply
0089   Standard_EXPORT void SetShareOut(const occ::handle<IFSelect_ShareOut>& sho);
0090 
0091   //! Clears the list of produced Models
0092   Standard_EXPORT void ClearResult();
0093 
0094   //! Records a new File to be sent, as a couple
0095   //! (Name as AsciiString, Content as InterfaceModel)
0096   //! Returns True if Done, False if <filename> is already attached
0097   //! to another File
0098   Standard_EXPORT bool AddFile(const TCollection_AsciiString&               filename,
0099                                const occ::handle<Interface_InterfaceModel>& content);
0100 
0101   //! Changes the Name attached to a File which was formerly defined
0102   //! by a call to AddFile
0103   //! Returns True if Done, False else : if <num> out of range or if
0104   //! the new <filename> is already attached to another File
0105   //! Remark : Giving an empty File Name is equivalent to ClearFile
0106   Standard_EXPORT bool NameFile(const int num, const TCollection_AsciiString& filename);
0107 
0108   //! Clears the Name attached to a File which was formerly defined
0109   //! by a call to AddFile. This Clearing can be undone by a call to
0110   //! NameFile (with same <num>)
0111   //! Returns True if Done, False else : if <num> is out of range
0112   Standard_EXPORT bool ClearFile(const int num);
0113 
0114   //! Sets a list of File Modifiers to be applied on a file
0115   Standard_EXPORT bool SetAppliedModifiers(const int                                     num,
0116                                            const occ::handle<IFSelect_AppliedModifiers>& applied);
0117 
0118   //! Clears the list of File Modifiers to be applied on a file
0119   Standard_EXPORT bool ClearAppliedModifiers(const int num);
0120 
0121   //! Performs the Copy Operations, which include the Modifications
0122   //! defined by the list of Modifiers. Memorizes the result, as a
0123   //! list of InterfaceModels with the corresponding FileNames
0124   //! They can then be sent, by the method Send, or queried
0125   //! Copy calls internal method Copying.
0126   //! Returns the produced CheckList
0127   Standard_EXPORT Interface_CheckIterator Copy(IFSelect_ShareOutResult&                 eval,
0128                                                const occ::handle<IFSelect_WorkLibrary>& WL,
0129                                                const occ::handle<Interface_Protocol>&   protocol);
0130 
0131   //! Sends the formerly defined results (see method Copy) to files,
0132   //! then clears it
0133   //! Remark : A Null File Name cause file to be not produced
0134   Standard_EXPORT Interface_CheckIterator
0135     SendCopied(const occ::handle<IFSelect_WorkLibrary>& WL,
0136                const occ::handle<Interface_Protocol>&   protocol);
0137 
0138   //! Performs the Copy Operations (which include the Modifications)
0139   //! and Sends the result on files, without memorizing it.
0140   //! (the memorized result is ignored : neither queried not filled)
0141   Standard_EXPORT Interface_CheckIterator Send(IFSelect_ShareOutResult&                 eval,
0142                                                const occ::handle<IFSelect_WorkLibrary>& WL,
0143                                                const occ::handle<Interface_Protocol>&   protocol);
0144 
0145   //! Sends a model (defined in <G>) into one file, without managing
0146   //! remaining data, already sent files, etc. Applies the Model and
0147   //! File Modifiers.
0148   //! Returns True if well done, False else
0149   Standard_EXPORT Interface_CheckIterator SendAll(const char* const                        filename,
0150                                                   const Interface_Graph&                   G,
0151                                                   const occ::handle<IFSelect_WorkLibrary>& WL,
0152                                                   const occ::handle<Interface_Protocol>& protocol);
0153 
0154   //! Sends a part of a model into one file. Model is gotten from
0155   //! <G>, the part is defined in <iter>.
0156   //! Remaining data are managed and can be later be worked on.
0157   //! Returns True if well done, False else
0158   Standard_EXPORT Interface_CheckIterator
0159     SendSelected(const char* const                        filename,
0160                  const Interface_Graph&                   G,
0161                  const occ::handle<IFSelect_WorkLibrary>& WL,
0162                  const occ::handle<Interface_Protocol>&   protocol,
0163                  const Interface_EntityIterator&          iter);
0164 
0165   //! Produces a Model copied from the Remaining List as <newmod>
0166   //! <newmod> is a Null Handle if this list is empty
0167   //! <WL> performs the copy by using <TC>
0168   //! <TC> is assumed to have been defined with the starting model
0169   //! same as defined by <G>.
0170   //! Produces a model copied from the remaining list.
0171   //! @param[in] G the interface graph
0172   //! @param[in] WL the work library performing the copy
0173   //! @param[in,out] TC the copy tool
0174   //! @return the new model with remaining data, or null handle if empty
0175   [[nodiscard]] Standard_EXPORT occ::handle<Interface_InterfaceModel> CopiedRemaining(
0176     const Interface_Graph&                   G,
0177     const occ::handle<IFSelect_WorkLibrary>& WL,
0178     Interface_CopyTool&                      TC);
0179 
0180   //! @deprecated Use CopiedRemaining() returning handle by value instead.
0181   Standard_DEPRECATED("Use CopiedRemaining() returning handle by value instead")
0182   Standard_EXPORT void CopiedRemaining(const Interface_Graph&                   G,
0183                                        const occ::handle<IFSelect_WorkLibrary>& WL,
0184                                        Interface_CopyTool&                      TC,
0185                                        occ::handle<Interface_InterfaceModel>&   newmod);
0186 
0187   //! Updates Graph status for remaining data, for each entity :
0188   //! - Entities just Sent to file or Copied (by CopiedRemaining)
0189   //! have their status set to 1
0190   //! - the other keep their former status (1 for Send/Copied,
0191   //! 0 for Remaining)
0192   //! These status are computed by Copying/Sending/CopiedRemaining
0193   //! Then, SetRemaining updates graph status, and mustr be called
0194   //! just after one of these method has been called
0195   //! Returns True if done, False if remaining info if not in phase
0196   //! which the Graph (not same counts of items)
0197   Standard_EXPORT bool SetRemaining(Interface_Graph& CG) const;
0198 
0199   //! Returns the count of Files produced, i.e. the count of Models
0200   //! memorized (produced by the mmethod Copy) with their file names
0201   Standard_EXPORT int NbFiles() const;
0202 
0203   //! Returns the File Name for a file given its rank
0204   //! It is empty after a call to ClearFile on same <num>
0205   Standard_EXPORT TCollection_AsciiString FileName(const int num) const;
0206 
0207   //! Returns the content of a file before sending, under the form
0208   //! of an InterfaceModel, given its rank
0209   Standard_EXPORT occ::handle<Interface_InterfaceModel> FileModel(const int num) const;
0210 
0211   //! Returns the list of File Modifiers to be applied on a file
0212   //! when it will be sent, as computed by CopiedModel :
0213   //! If it is a null handle, no File Modifier has to be applied.
0214   Standard_EXPORT occ::handle<IFSelect_AppliedModifiers> AppliedModifiers(const int num) const;
0215 
0216   //! Begins a sequence of recording the really sent files
0217   //! <sho> : the default file numbering is cleared
0218   //! If <record> is False, clears the list and stops recording
0219   //! If <record> is True, clears the list and commands recording
0220   //! Creation time corresponds to "stop recording"
0221   Standard_EXPORT void BeginSentFiles(const occ::handle<IFSelect_ShareOut>& sho, const bool record);
0222 
0223   //! Adds the name of a just sent file, if BeginSentFiles
0224   //! has commanded recording; else does nothing
0225   //! It is called by methods SendCopied Sending
0226   Standard_EXPORT void AddSentFile(const char* const filename);
0227 
0228   //! Returns the list of recorded names of sent files. Can be empty
0229   //! (if no file has been sent). Returns a Null Handle if
0230   //! BeginSentFiles has stopped recording.
0231   Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>>
0232                   SentFiles() const;
0233 
0234   DEFINE_STANDARD_RTTIEXT(IFSelect_ModelCopier, Standard_Transient)
0235 
0236 protected:
0237   //! Internal routine which does the effective Copy. It allows to
0238   //! work, either with a standard CopyTool, or a specialised one
0239   //! Copying itself is done by <WL> which uses a CopyTool
0240   Standard_EXPORT Interface_CheckIterator Copying(IFSelect_ShareOutResult&                 eval,
0241                                                   const occ::handle<IFSelect_WorkLibrary>& WL,
0242                                                   const occ::handle<Interface_Protocol>&   protocol,
0243                                                   Interface_CopyTool&                      TC);
0244 
0245   //! Internal routine which does the effective Send. It allows to
0246   //! work, either with a standard CopyTool, or a specialised one
0247   Standard_EXPORT Interface_CheckIterator Sending(IFSelect_ShareOutResult&                 eval,
0248                                                   const occ::handle<IFSelect_WorkLibrary>& WL,
0249                                                   const occ::handle<Interface_Protocol>&   protocol,
0250                                                   Interface_CopyTool&                      TC);
0251 
0252   //! Performs the Copy of a unitary Packet
0253   //! Input parameters are :
0254   //! <G> is the graph which defines the starting entities, it
0255   //! contains the original InterfaceModel
0256   //! <WL> performs the copy by using <TC>
0257   //! <protocol> is the used protocol (can be useful for Modifiers)
0258   //! <topcopy> is the list of Entities which are the Roots of the
0259   //! packet to be copied
0260   //! <filename> is the name of the file which will receive it
0261   //! <dispid> is the Identifier of the Dispatch which have produced
0262   //! this packet, <numod> is the rank of the packet for this
0263   //! Dispatch
0264   //! <TC> is a CopyTool, which performs the copy
0265   //!
0266   //! Returned values (as arguments) are :
0267   //! <newmod> is the result of the copy, as a new InterfaceModel on
0268   //! which Model Modifiers have already been applied (if there are)
0269   //! <applied> determines the File Modifiers which remain to be
0270   //! applied (when the file itself will be output) : for each File
0271   //! Modifier recorded in <me>, <applied>'s Value is :
0272   //! - Null if this Modifier has not to be applied
0273   //! - an empty list if this Modifier has to be applied without
0274   //! distinguishing specific entities
0275   //! - a list of numbers of entities in <model> if this Modifier
0276   //! concerns particularly these entities (which are the results
0277   //! of copying the result of its input selection)
0278   //! <checks> is the produced Check List (by Modifiers as required)
0279   //!
0280   //! Warning : File Modifiers are evaluated at the time of Copy itself
0281   //! If their list is changed between this Copy and the Sending
0282   //! itself of the file, these changes are ignored
0283   Standard_EXPORT void CopiedModel(const Interface_Graph&                   G,
0284                                    const occ::handle<IFSelect_WorkLibrary>& WL,
0285                                    const occ::handle<Interface_Protocol>&   protocol,
0286                                    const Interface_EntityIterator&          topcopy,
0287                                    const TCollection_AsciiString&           filename,
0288                                    const int                                dispnum,
0289                                    const int                                numod,
0290                                    Interface_CopyTool&                      TC,
0291                                    occ::handle<Interface_InterfaceModel>&   newmod,
0292                                    occ::handle<IFSelect_AppliedModifiers>&  applied,
0293                                    Interface_CheckIterator&                 checks) const;
0294 
0295 private:
0296   NCollection_Sequence<occ::handle<Interface_InterfaceModel>>               thefilemodels;
0297   NCollection_Sequence<TCollection_AsciiString>                             thefilenames;
0298   NCollection_Sequence<occ::handle<IFSelect_AppliedModifiers>>              theapplieds;
0299   occ::handle<IFSelect_ShareOut>                                            theshareout;
0300   occ::handle<NCollection_HArray1<int>>                                     theremain;
0301   occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>> thesentfiles;
0302 };
0303 
0304 #endif // _IFSelect_ModelCopier_HeaderFile