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