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