1 // Created on: 1993-08-26
2 // Created by: Christian CAILLET
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _IFSelect_ModelCopier_HeaderFile
18 #define _IFSelect_ModelCopier_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <IFSelect_SequenceOfInterfaceModel.hxx>
24 #include <TColStd_SequenceOfAsciiString.hxx>
25 #include <IFSelect_SequenceOfAppliedModifiers.hxx>
26 #include <TColStd_HArray1OfInteger.hxx>
27 #include <TColStd_HSequenceOfHAsciiString.hxx>
28 #include <MMgt_TShared.hxx>
29 #include <Standard_Boolean.hxx>
30 #include <Standard_Integer.hxx>
31 #include <Standard_CString.hxx>
32 class IFSelect_ShareOut;
33 class TCollection_AsciiString;
34 class Interface_InterfaceModel;
35 class IFSelect_AppliedModifiers;
36 class Interface_CheckIterator;
37 class IFSelect_ShareOutResult;
38 class IFSelect_WorkLibrary;
39 class Interface_Protocol;
40 class Interface_CopyTool;
41 class Interface_Graph;
42 class Interface_EntityIterator;
45 class IFSelect_ModelCopier;
46 DEFINE_STANDARD_HANDLE(IFSelect_ModelCopier, MMgt_TShared)
48 //! This class performs the Copy operations involved by the
49 //! description of a ShareOut (evaluated by a ShareOutResult)
50 //! plus, if there are, the Modifications on the results, with
51 //! the help of Modifiers. Each Modifier can work on one or more
52 //! resulting packets, accoding its criteria : it operates on a
53 //! Model once copied and filled with the content of the packet.
55 //! Modifiers can be :
56 //! - Model Modifiers, inheriting from the specific class Modifier
57 //! able to run on the content of a Model (header or entities),
58 //! activated by the ModelCopier itself
59 //! - File Modifiers, inheriting directly from GeneralModifier,
60 //! intended to be activated under the control of a WorkLibrary,
61 //! once the Model has been produced (i.e. to act on output
62 //! format, or other specific file features)
64 //! The Copy operations can be :
65 //! - immediately put to files : for each packet, a Model is
66 //! created and filled, then the file is output, at that's all
67 //! - memorized : for each packet, a Model is created and filled,
68 //! it is memorized with the corresponding file name.
69 //! it is possible to query the result of memorization (list of
70 //! produced Models and their file names)
71 //! -> it is also possible to send it into the files :
72 //! once files are written, the result is cleared
74 //! In addition, a list of really written files is managed :
75 //! A first call to BeginSentFiles clears the list and commands,
76 //! either to begin a new list, or to stop recording it. A call
77 //! to SentFiles returns the list (if recording has been required)
78 //! This list allows to globally exploit the set of produced files
80 //! Remark : For operations which concern specific Entities, see
81 //! also in package IFAdapt : a sub-class of ModelCopier allows
82 //! to work with EntityModifier, in addition to Modifier itself
83 //! which still applies to a whole copied Model.
84 class IFSelect_ModelCopier : public MMgt_TShared
90 //! Creates an empty ModelCopier
91 Standard_EXPORT IFSelect_ModelCopier();
93 //! Sets the ShareOut, which is used to define Modifiers to apply
94 Standard_EXPORT void SetShareOut (const Handle(IFSelect_ShareOut)& sho);
96 //! Clears the list of produced Models
97 Standard_EXPORT void ClearResult();
99 //! Records a new File to be sent, as a couple
100 //! (Name as AsciiString, Content as InterfaceModel)
101 //! Returns True if Done, False if <filename> is already attached
103 Standard_EXPORT Standard_Boolean AddFile (const TCollection_AsciiString& filename, const Handle(Interface_InterfaceModel)& content);
105 //! Changes the Name attached to a File which was formerly defined
106 //! by a call to AddFile
107 //! Returns True if Done, False else : if <num> out of range or if
108 //! the new <filename> is already attached to another File
109 //! Remark : Giving an empty File Name is equivalent to ClearFile
110 Standard_EXPORT Standard_Boolean NameFile (const Standard_Integer num, const TCollection_AsciiString& filename);
112 //! Clears the Name attached to a File which was formerly defined
113 //! by a call to AddFile. This Clearing can be undone by a call to
114 //! NameFile (with same <num>)
115 //! Returns True if Done, False else : if <num> is out of range
116 Standard_EXPORT Standard_Boolean ClearFile (const Standard_Integer num);
118 //! Sets a list of File Modifiers to be applied on a file
119 Standard_EXPORT Standard_Boolean SetAppliedModifiers (const Standard_Integer num, const Handle(IFSelect_AppliedModifiers)& applied);
121 //! Clears the list of File Modifiers to be applied on a file
122 Standard_EXPORT Standard_Boolean ClearAppliedModifiers (const Standard_Integer num);
124 //! Performs the Copy Operations, which include the Modifications
125 //! defined by the list of Modifiers. Memorizes the result, as a
126 //! list of InterfaceModels with the corresponding FileNames
127 //! They can then be sent, by the method Send, or queried
128 //! Copy calls internal method Copying.
129 //! Returns the produced CheckList
130 Standard_EXPORT Interface_CheckIterator Copy (IFSelect_ShareOutResult& eval, const Handle(IFSelect_WorkLibrary)& WL, const Handle(Interface_Protocol)& protocol);
132 //! Sends the formerly defined results (see method Copy) to files,
134 //! Remark : A Null File Name cause file to be not produced
135 Standard_EXPORT Interface_CheckIterator SendCopied (const Handle(IFSelect_WorkLibrary)& WL, const Handle(Interface_Protocol)& protocol);
137 //! Performs the Copy Operations (which include the Modifications)
138 //! and Sends the result on files, without memorizing it.
139 //! (the memorized result is ignored : neither queried not filled)
140 Standard_EXPORT Interface_CheckIterator Send (IFSelect_ShareOutResult& eval, const Handle(IFSelect_WorkLibrary)& WL, const Handle(Interface_Protocol)& protocol);
142 //! Sends a model (defined in <G>) into one file, without managing
143 //! remaining data, already sent files, etc. Applies the Model and
145 //! Returns True if well done, False else
146 Standard_EXPORT Interface_CheckIterator SendAll (const Standard_CString filename, const Interface_Graph& G, const Handle(IFSelect_WorkLibrary)& WL, const Handle(Interface_Protocol)& protocol);
148 //! Sends a part of a model into one file. Model is gotten from
149 //! <G>, the part is defined in <iter>.
150 //! Remaining data are managed and can be later be worked on.
151 //! Returns True if well done, False else
152 Standard_EXPORT Interface_CheckIterator SendSelected (const Standard_CString filename, const Interface_Graph& G, const Handle(IFSelect_WorkLibrary)& WL, const Handle(Interface_Protocol)& protocol, const Interface_EntityIterator& iter);
154 //! Produces a Model copied from the Remaining List as <newmod>
155 //! <newmod> is a Null Handle if this list is empty
156 //! <WL> performs the copy by using <TC>
157 //! <TC> is assumed to have been defined with the starting model
158 //! same as defined by <G>.
159 Standard_EXPORT void CopiedRemaining (const Interface_Graph& G, const Handle(IFSelect_WorkLibrary)& WL, Interface_CopyTool& TC, Handle(Interface_InterfaceModel)& newmod);
161 //! Updates Graph status for remaining data, for each entity :
162 //! - Entities just Sent to file or Copied (by CopiedRemaining)
163 //! have their status set to 1
164 //! - the other keep their former status (1 for Send/Copied,
166 //! These status are computed by Copying/Sending/CopiedRemaining
167 //! Then, SetRemaining updates graph status, and mustr be called
168 //! just after one of these method has been called
169 //! Returns True if done, False if remaining info if not in phase
170 //! which the Graph (not same counts of items)
171 Standard_EXPORT Standard_Boolean SetRemaining (Interface_Graph& CG) const;
173 //! Returns the count of Files produced, i.e. the count of Models
174 //! memorized (produced by the mmethod Copy) with their file names
175 Standard_EXPORT Standard_Integer NbFiles() const;
177 //! Returns the File Name for a file given its rank
178 //! It is empty after a call to ClearFile on same <num>
179 Standard_EXPORT TCollection_AsciiString FileName (const Standard_Integer num) const;
181 //! Returns the content of a file before sending, under the form
182 //! of an InterfaceModel, given its rank
183 Standard_EXPORT Handle(Interface_InterfaceModel) FileModel (const Standard_Integer num) const;
185 //! Returns the list of File Modifiers to be applied on a file
186 //! when it will be sent, as computed by CopiedModel :
187 //! If it is a null handle, no File Modifier has to be applied.
188 Standard_EXPORT Handle(IFSelect_AppliedModifiers) AppliedModifiers (const Standard_Integer num) const;
190 //! Begins a sequence of recording the really sent files
191 //! <sho> : the default file numbering is cleared
192 //! If <record> is False, clears the list and stops recording
193 //! If <record> is True, clears the list and commands recording
194 //! Creation time corresponds to "stop recording"
195 Standard_EXPORT void BeginSentFiles (const Handle(IFSelect_ShareOut)& sho, const Standard_Boolean record);
197 //! Adds the name of a just sent file, if BeginSentFiles
198 //! has commanded recording; else does nothing
199 //! It is called by methods SendCopied Sending
200 Standard_EXPORT void AddSentFile (const Standard_CString filename);
202 //! Returns the list of recorded names of sent files. Can be empty
203 //! (if no file has been sent). Returns a Null Handle if
204 //! BeginSentFiles has stopped recording.
205 Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) SentFiles() const;
210 DEFINE_STANDARD_RTTI(IFSelect_ModelCopier,MMgt_TShared)
215 //! Internal routine which does the effective Copy. It allows to
216 //! work, either with a standard CopyTool, or a specialised one
217 //! Copying itself is done by <WL> which uses a CopyTool
218 Standard_EXPORT Interface_CheckIterator Copying (IFSelect_ShareOutResult& eval, const Handle(IFSelect_WorkLibrary)& WL, const Handle(Interface_Protocol)& protocol, Interface_CopyTool& TC);
220 //! Internal routine which does the effective Send. It allows to
221 //! work, either with a standard CopyTool, or a specialised one
222 Standard_EXPORT Interface_CheckIterator Sending (IFSelect_ShareOutResult& eval, const Handle(IFSelect_WorkLibrary)& WL, const Handle(Interface_Protocol)& protocol, Interface_CopyTool& TC);
224 //! Performs the Copy of a unitary Packet
225 //! Input parameters are :
226 //! <G> is the graph which defines the starting entities, it
227 //! contains the original InterfaceModel
228 //! <WL> performs the copy by using <TC>
229 //! <protocol> is the used protocol (can be usefull for Modifiers)
230 //! <topcopy> is the list of Entities which are the Roots of the
231 //! packet to be copied
232 //! <filename> is the name of the file which will receive it
233 //! <dispid> is the Identifier of the Dispatch which have produced
234 //! this packet, <numod> is the rank of the packet for this
236 //! <TC> is a CopyTool, which performs the copy
238 //! Returned values (as arguments) are :
239 //! <newmod> is the result of the copy, as a new InterfaceModel on
240 //! which Model Modifiers have already been applied (if there are)
241 //! <applied> determines the File Modifiers which remain to be
242 //! applied (when the file itself will be output) : for each File
243 //! Modifier recorded in <me>, <applied>'s Value is :
244 //! - Null if this Modifier has not to be applied
245 //! - an empty list if this Modifier has to be applied without
246 //! distinguishing specific entities
247 //! - a list of numbers of entities in <model> if this Modifier
248 //! concerns particularly these entities (which are the results
249 //! of copying the result of its input selection)
250 //! <checks> is the produced Check List (by Modifiers as required)
252 //! Warning : File Modifiers are evaluated at the time of Copy itself
253 //! If their list is changed between this Copy and the Sending
254 //! itself of the file, these changes are ignored
255 Standard_EXPORT void CopiedModel (const Interface_Graph& G, const Handle(IFSelect_WorkLibrary)& WL, const Handle(Interface_Protocol)& protocol, const Interface_EntityIterator& topcopy, const TCollection_AsciiString& filename, const Standard_Integer dispnum, const Standard_Integer numod, Interface_CopyTool& TC, Handle(Interface_InterfaceModel)& newmod, Handle(IFSelect_AppliedModifiers)& applied, Interface_CheckIterator& checks) const;
262 IFSelect_SequenceOfInterfaceModel thefilemodels;
263 TColStd_SequenceOfAsciiString thefilenames;
264 IFSelect_SequenceOfAppliedModifiers theapplieds;
265 Handle(IFSelect_ShareOut) theshareout;
266 Handle(TColStd_HArray1OfInteger) theremain;
267 Handle(TColStd_HSequenceOfHAsciiString) thesentfiles;
278 #endif // _IFSelect_ModelCopier_HeaderFile