0026377: Passing Handle objects as arguments to functions as non-const reference...
[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);
89Standard_EXPORT virtual ~XSControl_Reader() {}
90
91 //! Sets a specific norm to <me>
92 //! Returns True if done, False if <norm> is not available
93 Standard_EXPORT Standard_Boolean SetNorm (const Standard_CString norm);
94
95 //! Sets a specific session to <me>
96 Standard_EXPORT void SetWS (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
97
98 //! Returns the session used in <me>
99 Standard_EXPORT Handle(XSControl_WorkSession) WS() const;
100
101 //! Loads a file and returns the read status
102 //! Zero for a Model which compies with the Controller
103 Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString filename);
104
105 //! Returns the model. It can then be consulted (header, product)
106 Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
107
108 //! Returns a list of entities from the IGES or STEP file
109 //! according to the following rules:
110 //! - if first and second are empty strings, the whole file is selected.
111 //! - if first is an entity number or label, the entity referred to is selected.
112 //! - if first is a list of entity numbers/labels separated by commas, the entities referred to are selected,
113 //! - if first is the name of a selection in the worksession and second is not defined,
114 //! the list contains the standard output for that selection.
115 //! - if first is the name of a selection and second is defined, the criterion defined
116 //! by second is applied to the result of the first selection.
117 //! A selection is an operator which computes a list of entities from a list given in
118 //! input according to its type. If no list is specified, the selection computes its
119 //! list of entities from the whole model.
120 //! A selection can be:
121 //! - A predefined selection (xst-transferrable-mode)
122 //! - A filter based on a signature
123 //! A Signature is an operator which returns a string from an entity according to its type. For example:
124 //! - "xst-type" (CDL)
125 //! - "iges-level"
126 //! - "step-type".
127 //! For example, if you wanted to select only the advanced_faces in a STEP file you
128 //! would use the following code:
129 //! Example
130 //! Reader.GiveList("xst-transferrable-roots","step-type(ADVANCED_FACE)");
131 //! Warning
132 //! If the value given to second is incorrect, it will simply be ignored.
133 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GiveList (const Standard_CString first = "", const Standard_CString second = "");
134
135 //! Computes a List of entities from the model as follows
136 //! <first> beeing a Selection, <ent> beeing an entity or a list
137 //! of entities (as a HSequenceOfTransient) :
138 //! the standard result of this selection applied to this list
139 //! if <first> is erroneous, a null handle is returned
140 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GiveList (const Standard_CString first, const Handle(Standard_Transient)& ent);
141
142 //! Determines the list of root entities which are candidate for
143 //! a transfer to a Shape, and returns the number
144 //! of entities in the list
145 Standard_EXPORT virtual Standard_Integer NbRootsForTransfer();
146
147 //! Returns an IGES or STEP root
148 //! entity for translation. The entity is identified by its
149 //! rank in a list.
150 Standard_EXPORT Handle(Standard_Transient) RootForTransfer (const Standard_Integer num = 1);
151
152 //! Translates a root identified by the rank num in the model.
153 //! false is returned if no shape is produced.
154 Standard_EXPORT Standard_Boolean TransferOneRoot (const Standard_Integer num = 1);
155
156 //! Translates an IGES or STEP
157 //! entity identified by the rank num in the model.
158 //! false is returned if no shape is produced.
159 Standard_EXPORT Standard_Boolean TransferOne (const Standard_Integer num);
160
161 //! Translates an IGES or STEP
162 //! entity in the model. true is returned if a shape is
163 //! produced; otherwise, false is returned.
164 Standard_EXPORT Standard_Boolean TransferEntity (const Handle(Standard_Transient)& start);
165
166 //! Translates a list of entities.
167 //! Returns the number of IGES or STEP entities that were
168 //! successfully translated. The list can be produced with GiveList.
169 //! Warning - This function does not clear the existing output shapes.
170 Standard_EXPORT Standard_Integer TransferList (const Handle(TColStd_HSequenceOfTransient)& list);
171
172 //! Translates all translatable
173 //! roots and returns the number of successful translations.
174 //! Warning - This function clears existing output shapes first.
175 Standard_EXPORT Standard_Integer TransferRoots();
176
177 //! Clears the list of shapes that
178 //! may have accumulated in calls to TransferOne or TransferRoot.C
179 Standard_EXPORT void ClearShapes();
180
181 //! Returns the number of shapes produced by translation.
182 Standard_EXPORT Standard_Integer NbShapes() const;
183
184 //! Returns the shape resulting
185 //! from a translation and identified by the rank num.
186 //! num equals 1 by default. In other words, the first shape
187 //! resulting from the translation is returned.
188 Standard_EXPORT TopoDS_Shape Shape (const Standard_Integer num = 1) const;
189
190 //! Returns all of the results in
191 //! a single shape which is:
192 //! - a null shape if there are no results,
193 //! - a shape if there is one result,
194 //! - a compound containing the resulting shapes if there are more than one.
195 Standard_EXPORT TopoDS_Shape OneShape() const;
196
197 //! Prints the check list attached to loaded data, on the Standard
198 //! Trace File (starts at cout)
199 //! All messages or fails only, according to <failsonly>
200 //! mode = 0 : per entity, prints messages
201 //! mode = 1 : per message, just gives count of entities per check
202 //! mode = 2 : also gives entity numbers
203 Standard_EXPORT void PrintCheckLoad (const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const;
204
205 //! Displays check results for the
206 //! last translation of IGES or STEP entities to Open CASCADE
207 //! entities. Only fail messages are displayed if failsonly is
208 //! true. All messages are displayed if failsonly is
209 //! false. mode determines the contents and the order of the
210 //! messages according to the terms of the IFSelect_PrintCount enumeration.
211 Standard_EXPORT void PrintCheckTransfer (const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const;
212
213 //! Displays the statistics for
214 //! the last translation. what defines the kind of
215 //! statistics that are displayed as follows:
216 //! - 0 gives general statistics (number of translated roots,
217 //! number of warnings, number of fail messages),
218 //! - 1 gives root results,
219 //! - 2 gives statistics for all checked entities,
220 //! - 3 gives the list of translated entities,
221 //! - 4 gives warning and fail messages,
222 //! - 5 gives fail messages only.
223 //! The use of mode depends on the value of what. If what is 0,
224 //! mode is ignored. If what is 1, 2 or 3, mode defines the following:
225 //! - 0 lists the numbers of IGES or STEP entities in the respective model
226 //! - 1 gives the number, identifier, type and result
227 //! type for each IGES or STEP entity and/or its status
228 //! (fail, warning, etc.)
229 //! - 2 gives maximum information for each IGES or STEP entity (i.e. checks)
230 //! - 3 gives the number of entities per type of IGES or STEP entity
231 //! - 4 gives the number of IGES or STEP entities per result type and/or status
232 //! - 5 gives the number of pairs (IGES or STEP or result type and status)
233 //! - 6 gives the number of pairs (IGES or STEP or result type
234 //! and status) AND the list of entity numbers in the IGES or STEP model.
235 //! If what is 4 or 5, mode defines the warning and fail
236 //! messages as follows:
237 //! - if mode is 0 all warnings and checks per entity are returned
238 //! - if mode is 2 the list of entities per warning is returned.
239 //! If mode is not set, only the list of all entities per warning is given.
240 Standard_EXPORT void PrintStatsTransfer (const Standard_Integer what, const Standard_Integer mode = 0) const;
241
242 //! Gives statistics about Transfer
243 Standard_EXPORT void GetStatsTransfer (const Handle(TColStd_HSequenceOfTransient)& list, Standard_Integer& nbMapped, Standard_Integer& nbWithResult, Standard_Integer& nbWithFail) const;
244
245
246
247
248protected:
249
250
251 //! Returns a sequence of produced shapes
252 Standard_EXPORT TopTools_SequenceOfShape& Shapes();
253
254
255 Standard_Boolean therootsta;
256 TColStd_SequenceOfTransient theroots;
257
258
259private:
260
261
262
263 Handle(XSControl_WorkSession) thesession;
264 TopTools_SequenceOfShape theshapes;
265
266
267};
268
269
270
271
272
273
274
275#endif // _XSControl_Reader_HeaderFile