0026715: Problems in reading STEP short names in complex entities
[occt.git] / src / StepData / StepData_StepReaderData.hxx
CommitLineData
42cf5bc1 1// Created on: 1992-02-11
2// Created by: Christian CAILLET
3// Copyright (c) 1992-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 _StepData_StepReaderData_HeaderFile
18#define _StepData_StepReaderData_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <TColStd_Array1OfInteger.hxx>
24#include <Interface_IndexedMapOfAsciiString.hxx>
25#include <TColStd_DataMapOfIntegerInteger.hxx>
26#include <Standard_Integer.hxx>
27#include <Interface_FileReaderData.hxx>
28#include <Standard_CString.hxx>
29#include <Interface_ParamType.hxx>
30#include <Standard_Boolean.hxx>
31#include <TColStd_SequenceOfAsciiString.hxx>
32#include <Standard_Real.hxx>
33#include <Standard_Type.hxx>
34#include <StepData_Logical.hxx>
35class Interface_Check;
36class TCollection_AsciiString;
37class StepData_PDescr;
38class Standard_Transient;
39class StepData_SelectMember;
40class StepData_Field;
41class StepData_ESDescr;
42class StepData_FieldList;
43class StepData_SelectType;
44class TCollection_HAsciiString;
45class StepData_EnumTool;
46
47
48class StepData_StepReaderData;
49DEFINE_STANDARD_HANDLE(StepData_StepReaderData, Interface_FileReaderData)
50
51//! Specific FileReaderData for Step
52//! Contains litteral description of entities (for each one : type
53//! as a string, ident, parameter list)
54//! provides references evaluation, plus access to litteral data
55//! and specific access methods (Boolean, XY, XYZ)
56class StepData_StepReaderData : public Interface_FileReaderData
57{
58
59public:
60
61
62 //! creates StepReaderData correctly dimensionned (necessary at
63 //! creation time, because it contains arrays)
64 //! nbheader is nb of records for Header, nbtotal for Header+Data
65 //! and nbpar gives the total count of parameters
66 Standard_EXPORT StepData_StepReaderData(const Standard_Integer nbheader, const Standard_Integer nbtotal, const Standard_Integer nbpar);
67
68 //! Fills the fields of a record
69 Standard_EXPORT void SetRecord (const Standard_Integer num, const Standard_CString ident, const Standard_CString type, const Standard_Integer nbpar);
70
71 //! Fills the fields of a parameter of a record. This is a variant
72 //! of AddParam, Adapted to STEP (optimized for specific values)
73 Standard_EXPORT void AddStepParam (const Standard_Integer num, const Standard_CString aval, const Interface_ParamType atype, const Standard_Integer nument = 0);
74
75 //! Returns Record Type
76 Standard_EXPORT const TCollection_AsciiString& RecordType (const Standard_Integer num) const;
77
78 //! Returns Record Type as a CString
79 //! was C++ : return const
80 Standard_EXPORT Standard_CString CType (const Standard_Integer num) const;
81
82 //! Returns record identifier (Positive number)
83 //! If returned ident is not positive : Sub-List or Scope mark
84 Standard_EXPORT Standard_Integer RecordIdent (const Standard_Integer num) const;
85
86 //! Returns SubList numero designated by a parameter (nump) in a
87 //! record (num), or zero if the parameter does not exist or is
88 //! not a SubList address. Zero too If aslast is True and nump
89 //! is not for the last parameter
90 Standard_EXPORT Standard_Integer SubListNumber (const Standard_Integer num, const Standard_Integer nump, const Standard_Boolean aslast) const;
91
92 //! Returns True if <num> corresponds to a Complex Type Entity
93 //! (as can be defined by ANDOR Express clause)
94 Standard_EXPORT Standard_Boolean IsComplex (const Standard_Integer num) const;
95
96 //! Returns the List of Types which correspond to a Complex Type
97 //! Entity. If not Complex, there is just one Type in it
98 //! For a SubList or a Scope mark, <types> remains empty
99 Standard_EXPORT void ComplexType (const Standard_Integer num, TColStd_SequenceOfAsciiString& types) const;
100
101 //! Returns the Next "Componant" for a Complex Type Entity, of
102 //! which <num> is already a Componant (the first one or a next one)
103 //! Returns 0 for a Simple Type or for the last Componant
104 Standard_EXPORT Standard_Integer NextForComplex (const Standard_Integer num) const;
105
106 //! Determines the first component which brings a given name, for
107 //! a Complex Type Entity
108 //! <num0> is the very first record of this entity
109 //! <num> is given the last NextNamedForComplex, starts at zero
110 //! it is returned as the newly found number
111 //! Hence, in the normal case, NextNamedForComplex starts by num0
112 //! if <num> is zero, else by NextForComplex(num)
113 //! If the alphabetic order is not respected, it restarts from
114 //! num0 and loops on NextForComplex until finding <name>
115 //! In case of "non-alphabetic order", <ach> is filled with a
116 //! Warning for this name
117 //! In case of "not-found at all", <ach> is filled with a Fail,
118 //! and <num> is returned as zero
119 //!
120 //! Returns True if alphabetic order, False else
121 Standard_EXPORT Standard_Boolean NamedForComplex (const Standard_CString name, const Standard_Integer num0, Standard_Integer& num, Handle(Interface_Check)& ach) const;
122
a7197ef3 123 //! Determines the first component which brings a given name, or
124 //! short name for a Complex Type Entity
125 //! <num0> is the very first record of this entity
126 //! <num> is given the last NextNamedForComplex, starts at zero
127 //! it is returned as the newly found number
128 //! Hence, in the normal case, NextNamedForComplex starts by num0
129 //! if <num> is zero, else by NextForComplex(num)
130 //! If the alphabetic order is not respected, it restarts from
131 //! num0 and loops on NextForComplex until finding <name>
132 //! In case of "non-alphabetic order", <ach> is filled with a
133 //! Warning for this name
134 //! In case of "not-found at all", <ach> is filled with a Fail,
135 //! and <num> is returned as zero
136 //!
137 //! Returns True if alphabetic order, False else
138 Standard_EXPORT Standard_Boolean NamedForComplex (const Standard_CString theName, const Standard_CString theShortName, const Standard_Integer num0, Standard_Integer& num, Handle(Interface_Check)& ach) const;
139
42cf5bc1 140 //! Checks Count of Parameters of record <num> to equate <nbreq>
141 //! If this Check is successful, returns True
142 //! Else, fills <ach> with an Error Message then returns False
143 //! <mess> is included in the Error message if given non empty
144 Standard_EXPORT Standard_Boolean CheckNbParams (const Standard_Integer num, const Standard_Integer nbreq, Handle(Interface_Check)& ach, const Standard_CString mess = "") const;
145
146 //! reads parameter <nump> of record <num> as a sub-list (may be
147 //! typed, see ReadTypedParameter in this case)
148 //! Returns True if OK. Else (not a LIST), returns false and
149 //! feeds Check with appropriate check
150 //! If <optional> is True and Param is not defined, returns True
151 //! with <ach> not filled and <numsub> returned as 0
152 //! Works with SubListNumber with <aslast> false (no specific case
153 //! for last parameter)
154 Standard_EXPORT Standard_Boolean ReadSubList (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Integer& numsub, const Standard_Boolean optional = Standard_False, const Standard_Integer lenmin = 0, const Standard_Integer lenmax = 0) const;
155
156 //! reads the content of a sub-list into a transient :
157 //! SelectNamed, or HArray1 of Integer,Real,String,Transient ...
158 //! recursive call if list of list ...
159 //! If a sub-list has mixed types, an HArray1OfTransient is
160 //! produced, it may contain SelectMember
161 //! Intended to be called by ReadField
162 //! The returned status is : negative if failed, 0 if empty.
163 //! Else the kind to be recorded in the field
164 Standard_EXPORT Standard_Integer ReadSub (const Standard_Integer numsub, const Standard_CString mess, Handle(Interface_Check)& ach, const Handle(StepData_PDescr)& descr, Handle(Standard_Transient)& val) const;
165
166 //! Reads parameter <nump> of record <num> into a SelectMember,
167 //! self-sufficient (no Description needed)
168 //! If <val> is already created, it will be filled, as possible
169 //! And if reading does not match its own description, the result
170 //! will be False
171 //! If <val> is not it not yet created, it will be (SelectNamed)
172 //! Usefull if a field is defined as a SelectMember, directly
173 //! (SELECT with no Entity as member)
174 //! But SelectType also manages SelectMember (for SELECT with
175 //! some members as Entity, some other not)
176 Standard_EXPORT Standard_Boolean ReadMember (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Handle(StepData_SelectMember)& val) const;
177
178 //! reads parameter <nump> of record <num> into a Field,
179 //! controlled by a Parameter Descriptor (PDescr), which controls
180 //! its allowed type(s) and value
181 //! <ach> is filled if the read parameter does not match its
182 //! description (but the field is read anyway)
183 //! If the description is not defined, no control is done
184 //! Returns True when done
185 Standard_EXPORT Standard_Boolean ReadField (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const Handle(StepData_PDescr)& descr, StepData_Field& fild) const;
186
187 //! reads a list of fields controlled by an ESDescr
188 Standard_EXPORT Standard_Boolean ReadList (const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepData_ESDescr)& descr, StepData_FieldList& list) const;
189
190 //! Reads parameter <nump> of record <num> into a Transient Value
191 //! according to the type of the parameter :
192 //! Named for Integer,Boolean,Logical,Enum,Real : SelectNamed
193 //! Immediate Integer,Boolean,Logical,Enum,Real : SelectInt/Real
194 //! Text : HAsciiString
195 //! Ident : the referenced Entity
196 //! Sub-List not processed, see ReadSub
197 //! This value is controlled by a Parameter Descriptor (PDescr),
198 //! which controls its allowed type and value
199 //! <ach> is filled if the read parameter does not match its
200 //! description (the select is nevertheless created if possible)
201 //!
202 //! Warning : val is in out, hence it is possible to predefine a specific
203 //! SelectMember then to fill it. If <val> is Null or if the
204 //! result is not a SelectMember, val itself is returned a new ref
205 //! For a Select with a Name, <val> must then be a SelectNamed
206 Standard_EXPORT Standard_Boolean ReadAny (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const Handle(StepData_PDescr)& descr, Handle(Standard_Transient)& val) const;
207
208 //! reads parameter <nump> of record <num> as a sub-list of
209 //! two Reals X,Y. Returns True if OK. Else, returns false and
210 //! feeds Check with appropriate Fails (parameter not a sub-list,
211 //! not two Reals in the sub-list) composed with "mess" which
212 //! gives the name of the parameter
213 Standard_EXPORT Standard_Boolean ReadXY (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Real& X, Standard_Real& Y) const;
214
215 //! reads parameter <nump> of record <num> as a sub-list of
216 //! three Reals X,Y,Z. Return value and Check managed as by
217 //! ReadXY (demands a sub-list of three Reals)
218 Standard_EXPORT Standard_Boolean ReadXYZ (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const;
219
220 //! reads parameter <nump> of record <num> as a single Real value.
221 //! Return value and Check managed as by ReadXY (demands a Real)
222 Standard_EXPORT Standard_Boolean ReadReal (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Real& val) const;
223
224 //! Reads parameter <nump> of record <num> as a single Entity.
225 //! Return value and Check managed as by ReadReal (demands a
226 //! reference to an Entity). In Addition, demands read Entity
227 //! to be Kind of a required Type <atype>.
228 //! Remark that returned status is False and <ent> is Null if
229 //! parameter is not an Entity, <ent> remains Not Null is parameter
230 //! is an Entity but is not Kind of required type
231 Standard_EXPORT Standard_Boolean ReadEntity (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const Handle(Standard_Type)& atype, Handle(Standard_Transient)& ent) const;
232
233 //! Same as above, but a SelectType checks Type Matching, and
234 //! records the read Entity (see method Value from SelectType)
235 Standard_EXPORT Standard_Boolean ReadEntity (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, StepData_SelectType& sel) const;
236
237 //! reads parameter <nump> of record <num> as a single Integer.
238 //! Return value & Check managed as by ReadXY (demands an Integer)
239 Standard_EXPORT Standard_Boolean ReadInteger (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Integer& val) const;
240
241 //! reads parameter <nump> of record <num> as a Boolean
242 //! Return value and Check managed as by ReadReal (demands a
243 //! Boolean enum, i.e. text ".T." for True or ".F." for False)
244 Standard_EXPORT Standard_Boolean ReadBoolean (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Boolean& flag) const;
245
246 //! reads parameter <nump> of record <num> as a Logical
247 //! Return value and Check managed as by ReadBoolean (demands a
248 //! Logical enum, i.e. text ".T.", ".F.", or ".U.")
249 Standard_EXPORT Standard_Boolean ReadLogical (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, StepData_Logical& flag) const;
250
251 //! reads parameter <nump> of record <num> as a String (text
252 //! between quotes, quotes are removed by the Read operation)
253 //! Return value and Check managed as by ReadXY (demands a String)
254 Standard_EXPORT Standard_Boolean ReadString (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Handle(TCollection_HAsciiString)& val) const;
255
256 Standard_EXPORT Standard_Boolean ReadEnumParam (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_CString& text) const;
257
258 //! Fills a check with a fail message if enumeration value does
259 //! match parameter definition
260 //! Just a help to centralize message definitions
261 Standard_EXPORT void FailEnumValue (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach) const;
262
263 //! Reads parameter <nump> of record <num> as an Enumeration (text
264 //! between dots) and converts it to an integer value, by an
265 //! EnumTool. Returns True if OK, false if : this parameter is not
266 //! enumeration, or is not recognized by the EnumTool (with fail)
267 Standard_EXPORT Standard_Boolean ReadEnum (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const StepData_EnumTool& enumtool, Standard_Integer& val) const;
268
269 //! Resolves a parameter which can be enclosed in a type def., as
270 //! TYPE(val). The parameter must then be read normally according
271 //! its type. Parameter to be resolved is <nump> of record <num>
272 //! <mustbetyped> True demands a typed parameter
273 //! <mustbetyped> False accepts a non-typed parameter as option
274 //! mess and ach as usual
275 //! <numr>,<numrp> are the resolved record and parameter numbers
276 //! = num,nump if no type, else numrp=1
277 //! <typ> returns the recorded type, or empty string
278 //! Remark : a non-typed list is considered as "non-typed"
279 Standard_EXPORT Standard_Boolean ReadTypedParam (const Standard_Integer num, const Standard_Integer nump, const Standard_Boolean mustbetyped, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Integer& numr, Standard_Integer& numrp, TCollection_AsciiString& typ) const;
280
281 //! Checks if parameter <nump> of record <num> is given as Derived
282 //! If this Check is successful (i.e. Param = "*"), returns True
283 //! Else, fills <ach> with a Message which contains <mess> and
284 //! returns False. According to <errstat>, this message is Warning
285 //! if errstat is False (Default), Fail if errstat is True
286 Standard_EXPORT Standard_Boolean CheckDerived (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const Standard_Boolean errstat = Standard_False) const;
287
288 //! Returns total count of Entities (including Header)
289 Standard_EXPORT virtual Standard_Integer NbEntities() const Standard_OVERRIDE;
290
291 //! determines the first suitable record following a given one
292 //! that is, skips SCOPE,ENDSCOPE and SUBLIST records
293 //! Note : skips Header records, which are accessed separately
294 Standard_EXPORT Standard_Integer FindNextRecord (const Standard_Integer num) const;
295
296 //! determines reference numbers in EntityNumber fields
297 //! called by Prepare from StepReaderTool to prepare later using
298 //! by a StepModel. This method is attached to StepReaderData
299 //! because it needs a massive amount of data accesses to work
300 //!
301 //! If <withmap> is given False, the basic exploration algorithm
302 //! is activated, otherwise a map is used as far as it is possible
303 //! this option can be used only to test this algorithm
304 Standard_EXPORT void SetEntityNumbers (const Standard_Boolean withmap = Standard_True);
305
306 //! determine first suitable record of Header
307 //! works as FindNextRecord, but treats only Header records
308 Standard_EXPORT Standard_Integer FindNextHeaderRecord (const Standard_Integer num) const;
309
310 //! Works as SetEntityNumbers but for Header : more simple because
311 //! there are no Reference, only Sub-Lists
312 Standard_EXPORT void PrepareHeader();
313
314 //! Returns the Global Check. It can record Fail messages about
315 //! Undefined References (detected by SetEntityNumbers)
316 Standard_EXPORT const Handle(Interface_Check) GlobalCheck() const;
317
318
319
320
321 DEFINE_STANDARD_RTTI(StepData_StepReaderData,Interface_FileReaderData)
322
323protected:
324
325
326
327
328private:
329
330
331 //! Searches for a Parameter of the record <num>, which refers to
332 //! the Ident <id> (form #nnn). [Used by SetEntityNumbers]
333 //! If found, returns its EntityNumber, else returns Zero.
334 Standard_EXPORT Standard_Integer FindEntityNumber (const Standard_Integer num, const Standard_Integer id) const;
335
336 TColStd_Array1OfInteger theidents;
337 TColStd_Array1OfInteger thetypes;
338 Interface_IndexedMapOfAsciiString thenametypes;
339 TColStd_DataMapOfIntegerInteger themults;
340 Standard_Integer thenbents;
341 Standard_Integer thelastn;
342 Standard_Integer thenbhead;
343 Standard_Integer thenbscop;
344 Handle(Interface_Check) thecheck;
345
346
347};
348
349
350
351
352
353
354
355#endif // _StepData_StepReaderData_HeaderFile