1 -- Created on: 1992-02-11
2 -- Created by: Christian CAILLET
3 -- Copyright (c) 1992-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
23 class StepReaderData from StepData inherits FileReaderData
25 ---Purpose : Specific FileReaderData for Step
26 -- Contains litteral description of entities (for each one : type
27 -- as a string, ident, parameter list)
28 -- provides references evaluation, plus access to litteral data
29 -- and specific access methods (Boolean, XY, XYZ)
31 uses Integer, Boolean, CString, Transient, Type, HAsciiString from TCollection,
32 Array1OfInteger from TColStd, AsciiString from TCollection,
33 Array1OfAsciiString, SequenceOfAsciiString from TColStd,
34 Check from Interface, ParamType from Interface,
35 Logical from StepData, SelectType from StepData, EnumTool from StepData,
36 SelectMember from StepData, Field from StepData, PDescr from StepData,
37 FieldList from StepData, ESDescr from StepData,
38 IndexedMapOfAsciiString from Interface,
39 DataMapOfIntegerInteger from TColStd
43 -- -- File data storing and access (specific) -- --
45 Create (nbheader,nbtotal,nbpar : Integer) returns mutable StepReaderData;
46 ---Purpose : creates StepReaderData correctly dimensionned (necessary at
47 -- creation time, because it contains arrays)
48 -- nbheader is nb of records for Header, nbtotal for Header+Data
49 -- and nbpar gives the total count of parameters
51 SetRecord (me : mutable; num : Integer;
52 ident : CString; type : CString; nbpar : Integer)
54 ---Purpose : Fills the fields of a record
56 AddStepParam (me : mutable; num : Integer;
57 aval : CString; atype : ParamType; nument : Integer = 0)
59 ---Purpose : Fills the fields of a parameter of a record. This is a variant
60 -- of AddParam, Adapted to STEP (optimized for specific values)
62 RecordType (me; num : Integer) returns AsciiString from TCollection
64 ---Purpose : Returns Record Type
65 ---C++ : return const &
67 CType (me; num : Integer) returns CString is static;
68 ---Purpose : Returns Record Type as a CString
69 -- was C++ : return const
71 RecordIdent (me; num : Integer) returns Integer is static;
72 ---Purpose : Returns record identifier (Positive number)
73 -- If returned ident is not positive : Sub-List or Scope mark
75 SubListNumber (me; num, nump : Integer; aslast : Boolean) returns Integer
77 ---Purpose : Returns SubList numero designated by a parameter (nump) in a
78 -- record (num), or zero if the parameter does not exist or is
79 -- not a SubList address. Zero too If aslast is True and nump
80 -- is not for the last parameter
82 IsComplex (me; num : Integer) returns Boolean is static;
83 ---Purpose : Returns True if <num> corresponds to a Complex Type Entity
84 -- (as can be defined by ANDOR Express clause)
86 ComplexType (me; num : Integer;
87 types : in out SequenceOfAsciiString from TColStd)
89 ---Purpose : Returns the List of Types which correspond to a Complex Type
90 -- Entity. If not Complex, there is just one Type in it
91 -- For a SubList or a Scope mark, <types> remains empty
93 NextForComplex (me; num : Integer) returns Integer is static;
94 ---Purpose : Returns the Next "Componant" for a Complex Type Entity, of
95 -- which <num> is already a Componant (the first one or a next one)
96 -- Returns 0 for a Simple Type or for the last Componant
98 NamedForComplex (me; name : CString; num0 : Integer;
99 num : in out Integer; ach : in out Check)
101 ---Purpose : Determines the first component which brings a given name, for
102 -- a Complex Type Entity
103 -- <num0> is the very first record of this entity
104 -- <num> is given the last NextNamedForComplex, starts at zero
105 -- it is returned as the newly found number
106 -- Hence, in the normal case, NextNamedForComplex starts by num0
107 -- if <num> is zero, else by NextForComplex(num)
108 -- If the alphabetic order is not respected, it restarts from
109 -- num0 and loops on NextForComplex until finding <name>
110 -- In case of "non-alphabetic order", <ach> is filled with a
111 -- Warning for this name
112 -- In case of "not-found at all", <ach> is filled with a Fail,
113 -- and <num> is returned as zero
115 -- Returns True if alphabetic order, False else
117 -- -- Some Useful Accesses which are provided -- --
119 CheckNbParams (me; num : Integer; nbreq : Integer; ach : in out Check;
120 mess : CString = "") returns Boolean is static;
121 ---Purpose : Checks Count of Parameters of record <num> to equate <nbreq>
122 -- If this Check is successful, returns True
123 -- Else, fills <ach> with an Error Message then returns False
124 -- <mess> is included in the Error message if given non empty
126 ReadSubList (me; num, nump : Integer; mess : CString; ach : in out Check;
127 numsub : out Integer;
128 optional : Boolean = Standard_False;
129 lenmin : Integer = 0; lenmax : Integer = 0)
130 returns Boolean is static;
131 ---Purpose : reads parameter <nump> of record <num> as a sub-list (may be
132 -- typed, see ReadTypedParameter in this case)
133 -- Returns True if OK. Else (not a LIST), returns false and
134 -- feeds Check with appropriate check
135 -- If <optional> is True and Param is not defined, returns True
136 -- with <ach> not filled and <numsub> returned as 0
137 -- Works with SubListNumber with <aslast> false (no specific case
138 -- for last parameter)
140 ReadSub (me; numsub : Integer; mess : CString; ach : in out Check;
141 descr : PDescr; val : out Transient) returns Integer;
142 ---Purpose : reads the content of a sub-list into a transient :
143 -- SelectNamed, or HArray1 of Integer,Real,String,Transient ...
144 -- recursive call if list of list ...
145 -- If a sub-list has mixed types, an HArray1OfTransient is
146 -- produced, it may contain SelectMember
147 -- Intended to be called by ReadField
148 -- The returned status is : negative if failed, 0 if empty.
149 -- Else the kind to be recorded in the field
151 ReadMember (me; num, nump : Integer; mess : CString; ach : in out Check;
152 val : in out mutable SelectMember) returns Boolean;
153 ---Purpose : Reads parameter <nump> of record <num> into a SelectMember,
154 -- self-sufficient (no Description needed)
155 -- If <val> is already created, it will be filled, as possible
156 -- And if reading does not match its own description, the result
158 -- If <val> is not it not yet created, it will be (SelectNamed)
159 -- Usefull if a field is defined as a SelectMember, directly
160 -- (SELECT with no Entity as member)
161 -- But SelectType also manages SelectMember (for SELECT with
162 -- some members as Entity, some other not)
164 ReadField (me; num, nump : Integer; mess : CString; ach : in out Check;
165 descr : PDescr; fild : in out Field) returns Boolean;
166 ---Purpose : reads parameter <nump> of record <num> into a Field,
167 -- controlled by a Parameter Descriptor (PDescr), which controls
168 -- its allowed type(s) and value
169 -- <ach> is filled if the read parameter does not match its
170 -- description (but the field is read anyway)
171 -- If the description is not defined, no control is done
172 -- Returns True when done
174 ReadList (me; num : Integer; ach : in out Check;
175 descr : ESDescr; list : in out FieldList) returns Boolean;
176 ---Purpose : reads a list of fields controlled by an ESDescr
178 ReadAny (me; num, nump : Integer; mess : CString; ach : in out Check;
179 descr : PDescr; val : in out mutable Transient) returns Boolean;
180 ---Purpose : Reads parameter <nump> of record <num> into a Transient Value
181 -- according to the type of the parameter :
182 -- Named for Integer,Boolean,Logical,Enum,Real : SelectNamed
183 -- Immediate Integer,Boolean,Logical,Enum,Real : SelectInt/Real
184 -- Text : HAsciiString
185 -- Ident : the referenced Entity
186 -- Sub-List not processed, see ReadSub
187 -- This value is controlled by a Parameter Descriptor (PDescr),
188 -- which controls its allowed type and value
189 -- <ach> is filled if the read parameter does not match its
190 -- description (the select is nevertheless created if possible)
192 -- Warning : val is in out, hence it is possible to predefine a specific
193 -- SelectMember then to fill it. If <val> is Null or if the
194 -- result is not a SelectMember, val itself is returned a new ref
195 -- For a Select with a Name, <val> must then be a SelectNamed
197 ReadXY (me; num, nump : Integer; mess : CString; ach : in out Check;
198 X,Y : out Real) returns Boolean is static;
199 ---Purpose : reads parameter <nump> of record <num> as a sub-list of
200 -- two Reals X,Y. Returns True if OK. Else, returns false and
201 -- feeds Check with appropriate Fails (parameter not a sub-list,
202 -- not two Reals in the sub-list) composed with "mess" which
203 -- gives the name of the parameter
205 ReadXYZ (me; num, nump : Integer; mess : CString; ach : in out Check;
206 X,Y,Z : out Real) returns Boolean is static;
207 ---Purpose : reads parameter <nump> of record <num> as a sub-list of
208 -- three Reals X,Y,Z. Return value and Check managed as by
209 -- ReadXY (demands a sub-list of three Reals)
211 ReadReal (me; num, nump : Integer; mess : CString; ach : in out Check;
212 val : out Real) returns Boolean is static;
213 ---Purpose : reads parameter <nump> of record <num> as a single Real value.
214 -- Return value and Check managed as by ReadXY (demands a Real)
216 ReadEntity (me; num, nump : Integer; mess : CString; ach : in out Check;
217 atype : Type; ent : out mutable Transient)
218 returns Boolean is static;
219 ---Purpose : Reads parameter <nump> of record <num> as a single Entity.
220 -- Return value and Check managed as by ReadReal (demands a
221 -- reference to an Entity). In Addition, demands read Entity
222 -- to be Kind of a required Type <atype>.
223 -- Remark that returned status is False and <ent> is Null if
224 -- parameter is not an Entity, <ent> remains Not Null is parameter
225 -- is an Entity but is not Kind of required type
227 ReadEntity (me; num, nump : Integer; mess : CString; ach : in out Check;
228 sel : in out SelectType) returns Boolean is static;
229 ---Purpose : Same as above, but a SelectType checks Type Matching, and
230 -- records the read Entity (see method Value from SelectType)
232 ReadInteger (me; num, nump : Integer; mess : CString; ach : in out Check;
233 val : out Integer) returns Boolean is static;
234 ---Purpose : reads parameter <nump> of record <num> as a single Integer.
235 -- Return value & Check managed as by ReadXY (demands an Integer)
237 ReadBoolean (me; num, nump : Integer; mess : CString; ach : in out Check;
238 flag : out Boolean) returns Boolean is static;
239 ---Purpose : reads parameter <nump> of record <num> as a Boolean
240 -- Return value and Check managed as by ReadReal (demands a
241 -- Boolean enum, i.e. text ".T." for True or ".F." for False)
243 ReadLogical (me; num, nump : Integer; mess : CString; ach : in out Check;
244 flag : out Logical from StepData) returns Boolean is static;
245 ---Purpose : reads parameter <nump> of record <num> as a Logical
246 -- Return value and Check managed as by ReadBoolean (demands a
247 -- Logical enum, i.e. text ".T.", ".F.", or ".U.")
249 ReadString (me; num, nump : Integer; mess : CString; ach : in out Check;
250 val : out mutable HAsciiString from TCollection)
251 returns Boolean is static;
252 ---Purpose : reads parameter <nump> of record <num> as a String (text
253 -- between quotes, quotes are removed by the Read operation)
254 -- Return value and Check managed as by ReadXY (demands a String)
256 ReadEnumParam (me; num, nump : Integer; mess : CString; ach : in out Check;
258 returns Boolean is static;
259 ---Puroise : Reads parameter <nump> of record <num>, checks if it is an
260 -- Enumeration, if yes returns its text value
261 -- Returns True if OK, False (+ empty string) if not an enum
264 FailEnumValue (me; num, nump : Integer; mess : CString; ach : in out Check);
265 ---Purpose : Fills a check with a fail message if enumeration value does
266 -- match parameter definition
267 -- Just a help to centralize message definitions
269 ReadEnum (me; num, nump : Integer; mess : CString; ach : in out Check;
270 enumtool : EnumTool from StepData; val : out Integer)
271 returns Boolean is static;
272 ---Purpose : Reads parameter <nump> of record <num> as an Enumeration (text
273 -- between dots) and converts it to an integer value, by an
274 -- EnumTool. Returns True if OK, false if : this parameter is not
275 -- enumeration, or is not recognized by the EnumTool (with fail)
277 ReadTypedParam (me; num,nump : Integer; mustbetyped : Boolean;
278 mess : CString; ach : in out Check;
279 numr,numrp : out Integer; typ : out AsciiString)
280 returns Boolean is static;
281 ---Purpose : Resolves a parameter which can be enclosed in a type def., as
282 -- TYPE(val). The parameter must then be read normally according
283 -- its type. Parameter to be resolved is <nump> of record <num>
284 -- <mustbetyped> True demands a typed parameter
285 -- <mustbetyped> False accepts a non-typed parameter as option
286 -- mess and ach as usual
287 -- <numr>,<numrp> are the resolved record and parameter numbers
288 -- = num,nump if no type, else numrp=1
289 -- <typ> returns the recorded type, or empty string
290 -- Remark : a non-typed list is considered as "non-typed"
292 CheckDerived (me; num, nump : Integer; mess : CString; ach : in out Check;
293 errstat : Boolean = Standard_False)
294 returns Boolean is static;
295 ---Purpose : Checks if parameter <nump> of record <num> is given as Derived
296 -- If this Check is successful (i.e. Param = "*"), returns True
297 -- Else, fills <ach> with a Message which contains <mess> and
298 -- returns False. According to <errstat>, this message is Warning
299 -- if errstat is False (Default), Fail if errstat is True
301 -- -- General exploitation methods -- --
303 NbEntities (me) returns Integer is redefined;
304 ---Purpose : Returns total count of Entities (including Header)
306 FindNextRecord (me; num : Integer) returns Integer;
307 ---Purpose : determines the first suitable record following a given one
308 -- that is, skips SCOPE,ENDSCOPE and SUBLIST records
309 -- Note : skips Header records, which are accessed separately
311 FindEntityNumber (me; num, id : Integer) returns Integer is static private;
312 ---Purpose : Searches for a Parameter of the record <num>, which refers to
313 -- the Ident <id> (form #nnn). [Used by SetEntityNumbers]
314 -- If found, returns its EntityNumber, else returns Zero.
316 -- -- Preparation before loading model -- --
318 SetEntityNumbers (me : mutable; withmap : Boolean = Standard_True);
319 ---Purpose : determines reference numbers in EntityNumber fields
320 -- called by Prepare from StepReaderTool to prepare later using
321 -- by a StepModel. This method is attached to StepReaderData
322 -- because it needs a massive amount of data accesses to work
324 -- If <withmap> is given False, the basic exploration algorithm
325 -- is activated, otherwise a map is used as far as it is possible
326 -- this option can be used only to test this algorithm
328 -- -- Managing Header -- --
329 -- Header is defined as a list of StepEntities (without ident)
331 FindNextHeaderRecord (me; num : Integer) returns Integer;
332 ---Purpose : determine first suitable record of Header
333 -- works as FindNextRecord, but treats only Header records
335 PrepareHeader (me : mutable);
336 ---Purpose : Works as SetEntityNumbers but for Header : more simple because
337 -- there are no Reference, only Sub-Lists
339 GlobalCheck (me) returns Check;
340 ---Purpose : Returns the Global Check. It can record Fail messages about
341 -- Undefined References (detected by SetEntityNumbers)
342 ---C++ : return const
346 theidents : Array1OfInteger from TColStd;
347 -- ident (entity/sub) or indicates SCOPE/END.
348 -- thetypes : Array1OfAsciiString;
349 thetypes : Array1OfInteger;
350 thenametypes : IndexedMapOfAsciiString from Interface;
351 themults : DataMapOfIntegerInteger from TColStd;
352 --themults : Array1OfInteger from TColStd; -- For Complex Type Entities
353 thenbents : Integer; -- internal data used for optimization
355 thenbhead : Integer; -- nb of records taken by Header