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