42cf5bc1 |
1 | // Created on: 1997-05-14 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1997-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 _XSControl_Reader_HeaderFile |
18 | #define _XSControl_Reader_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Boolean.hxx> |
25 | #include <TColStd_SequenceOfTransient.hxx> |
26 | #include <TopTools_SequenceOfShape.hxx> |
27 | #include <Standard_CString.hxx> |
28 | #include <IFSelect_ReturnStatus.hxx> |
29 | #include <TColStd_HSequenceOfTransient.hxx> |
30 | #include <Standard_Integer.hxx> |
31 | #include <IFSelect_PrintCount.hxx> |
7e785937 |
32 | #include <Message_ProgressRange.hxx> |
33 | |
42cf5bc1 |
34 | class XSControl_WorkSession; |
35 | class Interface_InterfaceModel; |
36 | class Standard_Transient; |
37 | class TopoDS_Shape; |
38 | |
39 | |
42cf5bc1 |
40 | //! A groundwork to convert a shape to data which complies |
41 | //! with a particular norm. This data can be that of a whole |
42 | //! model or that of a specific list of entities in the model. |
43 | //! You specify the list using a single selection or a |
44 | //! combination of selections. A selection is an operator which |
45 | //! computes a list of entities from a list given in input. To |
46 | //! specify the input, you can use: |
47 | //! - A predefined selection such as "xst-transferrable-roots" |
48 | //! - A filter based on a signature. |
49 | //! A signature is an operator which returns a string from an |
50 | //! entity according to its type. |
51 | //! For example: |
52 | //! - "xst-type" (CDL) |
53 | //! - "iges-level" |
54 | //! - "step-type". |
55 | //! A filter can be based on a signature by giving a value to |
56 | //! be matched by the string returned. For example, |
57 | //! "xst-type(Curve)". |
58 | //! If no list is specified, the selection computes its list of |
59 | //! entities from the whole model. To use this class, you have to |
60 | //! initialize the transfer norm first, as shown in the example below. |
61 | //! Example: |
62 | //! Control_Reader reader; |
63 | //! IFSelect_ReturnStatus status = reader.ReadFile (filename.); |
64 | //! When using IGESControl_Reader or STEPControl_Reader - as the |
65 | //! above example shows - the reader initializes the norm directly. |
66 | //! Note that loading the file only stores the data. It does |
67 | //! not translate this data. Shapes are accumulated by |
68 | //! successive transfers. The last shape is cleared by: |
69 | //! - ClearShapes which allows you to handle a new batch |
70 | //! - TransferRoots which restarts the list of shapes from scratch. |
71 | class XSControl_Reader |
72 | { |
73 | public: |
74 | |
75 | DEFINE_STANDARD_ALLOC |
76 | |
77 | |
78 | //! Creates a Reader from scratch (creates an empty WorkSession) |
79 | //! A WorkSession or a Controller must be provided before running |
80 | Standard_EXPORT XSControl_Reader(); |
81 | |
82 | //! Creates a Reader from scratch, with a norm name which |
83 | //! identifies a Controller |
84 | Standard_EXPORT XSControl_Reader(const Standard_CString norm); |
85 | |
86 | //! Creates a Reader from an already existing Session, with a |
87 | //! Controller already set |
88 | //! Virtual destructor |
89 | Standard_EXPORT XSControl_Reader(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); |
0f57ab75 |
90 | |
91 | //! Empty virtual destructor |
92 | virtual ~XSControl_Reader() {} |
42cf5bc1 |
93 | |
94 | //! Sets a specific norm to <me> |
95 | //! Returns True if done, False if <norm> is not available |
96 | Standard_EXPORT Standard_Boolean SetNorm (const Standard_CString norm); |
97 | |
98 | //! Sets a specific session to <me> |
99 | Standard_EXPORT void SetWS (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); |
100 | |
101 | //! Returns the session used in <me> |
102 | Standard_EXPORT Handle(XSControl_WorkSession) WS() const; |
103 | |
104 | //! Loads a file and returns the read status |
105 | //! Zero for a Model which compies with the Controller |
106 | Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString filename); |
107 | |
108 | //! Returns the model. It can then be consulted (header, product) |
109 | Standard_EXPORT Handle(Interface_InterfaceModel) Model() const; |
110 | |
111 | //! Returns a list of entities from the IGES or STEP file |
112 | //! according to the following rules: |
113 | //! - if first and second are empty strings, the whole file is selected. |
114 | //! - if first is an entity number or label, the entity referred to is selected. |
115 | //! - if first is a list of entity numbers/labels separated by commas, the entities referred to are selected, |
116 | //! - if first is the name of a selection in the worksession and second is not defined, |
117 | //! the list contains the standard output for that selection. |
118 | //! - if first is the name of a selection and second is defined, the criterion defined |
119 | //! by second is applied to the result of the first selection. |
120 | //! A selection is an operator which computes a list of entities from a list given in |
121 | //! input according to its type. If no list is specified, the selection computes its |
122 | //! list of entities from the whole model. |
123 | //! A selection can be: |
124 | //! - A predefined selection (xst-transferrable-mode) |
125 | //! - A filter based on a signature |
126 | //! A Signature is an operator which returns a string from an entity according to its type. For example: |
127 | //! - "xst-type" (CDL) |
128 | //! - "iges-level" |
129 | //! - "step-type". |
130 | //! For example, if you wanted to select only the advanced_faces in a STEP file you |
131 | //! would use the following code: |
132 | //! Example |
133 | //! Reader.GiveList("xst-transferrable-roots","step-type(ADVANCED_FACE)"); |
134 | //! Warning |
135 | //! If the value given to second is incorrect, it will simply be ignored. |
136 | Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GiveList (const Standard_CString first = "", const Standard_CString second = ""); |
137 | |
138 | //! Computes a List of entities from the model as follows |
139 | //! <first> beeing a Selection, <ent> beeing an entity or a list |
140 | //! of entities (as a HSequenceOfTransient) : |
141 | //! the standard result of this selection applied to this list |
142 | //! if <first> is erroneous, a null handle is returned |
143 | Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GiveList (const Standard_CString first, const Handle(Standard_Transient)& ent); |
144 | |
145 | //! Determines the list of root entities which are candidate for |
146 | //! a transfer to a Shape, and returns the number |
147 | //! of entities in the list |
148 | Standard_EXPORT virtual Standard_Integer NbRootsForTransfer(); |
149 | |
150 | //! Returns an IGES or STEP root |
151 | //! entity for translation. The entity is identified by its |
152 | //! rank in a list. |
153 | Standard_EXPORT Handle(Standard_Transient) RootForTransfer (const Standard_Integer num = 1); |
154 | |
155 | //! Translates a root identified by the rank num in the model. |
156 | //! false is returned if no shape is produced. |
7e785937 |
157 | Standard_EXPORT Standard_Boolean TransferOneRoot (const Standard_Integer num = 1, |
158 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
159 | |
160 | //! Translates an IGES or STEP |
161 | //! entity identified by the rank num in the model. |
162 | //! false is returned if no shape is produced. |
7e785937 |
163 | Standard_EXPORT Standard_Boolean TransferOne (const Standard_Integer num, |
164 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
165 | |
166 | //! Translates an IGES or STEP |
167 | //! entity in the model. true is returned if a shape is |
168 | //! produced; otherwise, false is returned. |
7e785937 |
169 | Standard_EXPORT Standard_Boolean TransferEntity (const Handle(Standard_Transient)& start, |
170 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
171 | |
172 | //! Translates a list of entities. |
173 | //! Returns the number of IGES or STEP entities that were |
174 | //! successfully translated. The list can be produced with GiveList. |
175 | //! Warning - This function does not clear the existing output shapes. |
7e785937 |
176 | Standard_EXPORT Standard_Integer TransferList (const Handle(TColStd_HSequenceOfTransient)& list, |
177 | const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
178 | |
179 | //! Translates all translatable |
180 | //! roots and returns the number of successful translations. |
181 | //! Warning - This function clears existing output shapes first. |
7e785937 |
182 | Standard_EXPORT Standard_Integer TransferRoots(const Message_ProgressRange& theProgress = Message_ProgressRange()); |
42cf5bc1 |
183 | |
184 | //! Clears the list of shapes that |
185 | //! may have accumulated in calls to TransferOne or TransferRoot.C |
186 | Standard_EXPORT void ClearShapes(); |
187 | |
188 | //! Returns the number of shapes produced by translation. |
189 | Standard_EXPORT Standard_Integer NbShapes() const; |
190 | |
191 | //! Returns the shape resulting |
192 | //! from a translation and identified by the rank num. |
193 | //! num equals 1 by default. In other words, the first shape |
194 | //! resulting from the translation is returned. |
195 | Standard_EXPORT TopoDS_Shape Shape (const Standard_Integer num = 1) const; |
196 | |
197 | //! Returns all of the results in |
198 | //! a single shape which is: |
199 | //! - a null shape if there are no results, |
200 | //! - a shape if there is one result, |
201 | //! - a compound containing the resulting shapes if there are more than one. |
202 | Standard_EXPORT TopoDS_Shape OneShape() const; |
203 | |
204 | //! Prints the check list attached to loaded data, on the Standard |
04232180 |
205 | //! Trace File (starts at std::cout) |
42cf5bc1 |
206 | //! All messages or fails only, according to <failsonly> |
207 | //! mode = 0 : per entity, prints messages |
208 | //! mode = 1 : per message, just gives count of entities per check |
209 | //! mode = 2 : also gives entity numbers |
210 | Standard_EXPORT void PrintCheckLoad (const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const; |
0ebe5b0a |
211 | |
212 | //! Prints the check list attached to loaded data. |
213 | Standard_EXPORT void PrintCheckLoad (Standard_OStream& theStream, const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const; |
42cf5bc1 |
214 | |
215 | //! Displays check results for the |
216 | //! last translation of IGES or STEP entities to Open CASCADE |
217 | //! entities. Only fail messages are displayed if failsonly is |
218 | //! true. All messages are displayed if failsonly is |
219 | //! false. mode determines the contents and the order of the |
220 | //! messages according to the terms of the IFSelect_PrintCount enumeration. |
221 | Standard_EXPORT void PrintCheckTransfer (const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const; |
0ebe5b0a |
222 | |
223 | //! Displays check results for the last translation of IGES or STEP entities to Open CASCADE entities. |
224 | Standard_EXPORT void PrintCheckTransfer (Standard_OStream& theStream, const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const; |
42cf5bc1 |
225 | |
226 | //! Displays the statistics for |
227 | //! the last translation. what defines the kind of |
228 | //! statistics that are displayed as follows: |
229 | //! - 0 gives general statistics (number of translated roots, |
230 | //! number of warnings, number of fail messages), |
231 | //! - 1 gives root results, |
232 | //! - 2 gives statistics for all checked entities, |
233 | //! - 3 gives the list of translated entities, |
234 | //! - 4 gives warning and fail messages, |
235 | //! - 5 gives fail messages only. |
236 | //! The use of mode depends on the value of what. If what is 0, |
237 | //! mode is ignored. If what is 1, 2 or 3, mode defines the following: |
238 | //! - 0 lists the numbers of IGES or STEP entities in the respective model |
239 | //! - 1 gives the number, identifier, type and result |
240 | //! type for each IGES or STEP entity and/or its status |
241 | //! (fail, warning, etc.) |
242 | //! - 2 gives maximum information for each IGES or STEP entity (i.e. checks) |
243 | //! - 3 gives the number of entities per type of IGES or STEP entity |
244 | //! - 4 gives the number of IGES or STEP entities per result type and/or status |
245 | //! - 5 gives the number of pairs (IGES or STEP or result type and status) |
246 | //! - 6 gives the number of pairs (IGES or STEP or result type |
247 | //! and status) AND the list of entity numbers in the IGES or STEP model. |
248 | //! If what is 4 or 5, mode defines the warning and fail |
249 | //! messages as follows: |
250 | //! - if mode is 0 all warnings and checks per entity are returned |
251 | //! - if mode is 2 the list of entities per warning is returned. |
252 | //! If mode is not set, only the list of all entities per warning is given. |
253 | Standard_EXPORT void PrintStatsTransfer (const Standard_Integer what, const Standard_Integer mode = 0) const; |
0ebe5b0a |
254 | |
255 | //! Displays the statistics for the last translation. |
256 | Standard_EXPORT void PrintStatsTransfer (Standard_OStream& theStream, const Standard_Integer what, const Standard_Integer mode = 0) const; |
42cf5bc1 |
257 | |
258 | //! Gives statistics about Transfer |
259 | Standard_EXPORT void GetStatsTransfer (const Handle(TColStd_HSequenceOfTransient)& list, Standard_Integer& nbMapped, Standard_Integer& nbWithResult, Standard_Integer& nbWithFail) const; |
260 | |
261 | |
262 | |
263 | |
264 | protected: |
265 | |
266 | |
267 | //! Returns a sequence of produced shapes |
268 | Standard_EXPORT TopTools_SequenceOfShape& Shapes(); |
269 | |
270 | |
271 | Standard_Boolean therootsta; |
272 | TColStd_SequenceOfTransient theroots; |
273 | |
274 | |
275 | private: |
276 | |
277 | |
278 | |
279 | Handle(XSControl_WorkSession) thesession; |
280 | TopTools_SequenceOfShape theshapes; |
281 | |
282 | |
283 | }; |
284 | |
285 | |
286 | |
287 | |
288 | |
289 | |
290 | |
291 | #endif // _XSControl_Reader_HeaderFile |