|
|
|||
File indexing completed on 2026-09-18 09:21:55
0001 // Created on: 1992-02-11 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1992-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _StepData_StepReaderData_HeaderFile 0018 #define _StepData_StepReaderData_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_Type.hxx> 0022 #include <Resource_FormatType.hxx> 0023 0024 #include <TCollection_AsciiString.hxx> 0025 #include <NCollection_IndexedMap.hxx> 0026 #include <Standard_Integer.hxx> 0027 #include <NCollection_DataMap.hxx> 0028 #include <Interface_FileReaderData.hxx> 0029 #include <Standard_CString.hxx> 0030 #include <Interface_ParamType.hxx> 0031 #include <NCollection_Sequence.hxx> 0032 #include <StepData_Logical.hxx> 0033 class Interface_Check; 0034 class TCollection_AsciiString; 0035 class StepData_PDescr; 0036 class Standard_Transient; 0037 class StepData_SelectMember; 0038 class StepData_Field; 0039 class StepData_ESDescr; 0040 class StepData_FieldList; 0041 class StepData_SelectType; 0042 class TCollection_HAsciiString; 0043 class StepData_EnumTool; 0044 0045 //! Specific FileReaderData for Step 0046 //! Contains literal description of entities (for each one : type 0047 //! as a string, ident, parameter list) 0048 //! provides references evaluation, plus access to literal data 0049 //! and specific access methods (Boolean, XY, XYZ) 0050 class StepData_StepReaderData : public Interface_FileReaderData 0051 { 0052 0053 public: 0054 //! creates StepReaderData correctly dimensioned (necessary at 0055 //! creation time, because it contains arrays) 0056 //! nbheader is nb of records for Header, nbtotal for Header+Data 0057 //! and nbpar gives the total count of parameters 0058 Standard_EXPORT StepData_StepReaderData( 0059 const int nbheader, 0060 const int nbtotal, 0061 const int nbpar, 0062 const Resource_FormatType theSourceCodePage = Resource_FormatType_UTF8); 0063 0064 //! Fills the fields of a record 0065 Standard_EXPORT void SetRecord(const int num, 0066 const char* const ident, 0067 const char* const type, 0068 const int nbpar); 0069 0070 //! Fills the fields of a parameter of a record. This is a variant 0071 //! of AddParam, Adapted to STEP (optimized for specific values) 0072 Standard_EXPORT void AddStepParam(const int num, 0073 const char* const aval, 0074 const Interface_ParamType atype, 0075 const int nument = 0); 0076 0077 //! Returns Record Type 0078 Standard_EXPORT const TCollection_AsciiString& RecordType(const int num) const; 0079 0080 //! Returns Record Type as a CString 0081 //! was C++ : return const 0082 Standard_EXPORT const char* CType(const int num) const; 0083 0084 //! Returns record identifier (Positive number) 0085 //! If returned ident is not positive : Sub-List or Scope mark 0086 Standard_EXPORT int RecordIdent(const int num) const; 0087 0088 //! Returns SubList numero designated by a parameter (nump) in a 0089 //! record (num), or zero if the parameter does not exist or is 0090 //! not a SubList address. Zero too If aslast is True and nump 0091 //! is not for the last parameter 0092 Standard_EXPORT int SubListNumber(const int num, const int nump, const bool aslast) const; 0093 0094 //! Returns True if <num> corresponds to a Complex Type Entity 0095 //! (as can be defined by ANDOR Express clause) 0096 Standard_EXPORT bool IsComplex(const int num) const; 0097 0098 //! Returns the List of Types which correspond to a Complex Type 0099 //! Entity. If not Complex, there is just one Type in it 0100 //! For a SubList or a Scope mark, <types> remains empty 0101 Standard_EXPORT void ComplexType(const int num, 0102 NCollection_Sequence<TCollection_AsciiString>& types) const; 0103 0104 //! Returns the Next "Component" for a Complex Type Entity, of 0105 //! which <num> is already a Component (the first one or a next one) 0106 //! Returns 0 for a Simple Type or for the last Component 0107 Standard_EXPORT int NextForComplex(const int num) const; 0108 0109 //! Determines the first component which brings a given name, for 0110 //! a Complex Type Entity 0111 //! <num0> is the very first record of this entity 0112 //! <num> is given the last NextNamedForComplex, starts at zero 0113 //! it is returned as the newly found number 0114 //! Hence, in the normal case, NextNamedForComplex starts by num0 0115 //! if <num> is zero, else by NextForComplex(num) 0116 //! If the alphabetic order is not respected, it restarts from 0117 //! num0 and loops on NextForComplex until finding <name> 0118 //! In case of "non-alphabetic order", <ach> is filled with a 0119 //! Warning for this name 0120 //! In case of "not-found at all", <ach> is filled with a Fail, 0121 //! and <num> is returned as zero 0122 //! 0123 //! Returns True if alphabetic order, False else 0124 Standard_EXPORT bool NamedForComplex(const char* const name, 0125 const int num0, 0126 int& num, 0127 occ::handle<Interface_Check>& ach) const; 0128 0129 //! Determines the first component which brings a given name, or 0130 //! short name for a Complex Type Entity 0131 //! <num0> is the very first record of this entity 0132 //! <num> is given the last NextNamedForComplex, starts at zero 0133 //! it is returned as the newly found number 0134 //! Hence, in the normal case, NextNamedForComplex starts by num0 0135 //! if <num> is zero, else by NextForComplex(num) 0136 //! If the alphabetic order is not respected, it restarts from 0137 //! num0 and loops on NextForComplex until finding <name> 0138 //! In case of "non-alphabetic order", <ach> is filled with a 0139 //! Warning for this name 0140 //! In case of "not-found at all", <ach> is filled with a Fail, 0141 //! and <num> is returned as zero 0142 //! 0143 //! Returns True if alphabetic order, False else 0144 Standard_EXPORT bool NamedForComplex(const char* const theName, 0145 const char* const theShortName, 0146 const int num0, 0147 int& num, 0148 occ::handle<Interface_Check>& ach) const; 0149 0150 //! Checks Count of Parameters of record <num> to equate <nbreq> 0151 //! If this Check is successful, returns True 0152 //! Else, fills <ach> with an Error Message then returns False 0153 //! <mess> is included in the Error message if given non empty 0154 Standard_EXPORT bool CheckNbParams(const int num, 0155 const int nbreq, 0156 occ::handle<Interface_Check>& ach, 0157 const char* const mess = "") const; 0158 0159 //! reads parameter <nump> of record <num> as a sub-list (may be 0160 //! typed, see ReadTypedParameter in this case) 0161 //! Returns True if OK. Else (not a LIST), returns false and 0162 //! feeds Check with appropriate check 0163 //! If <optional> is True and Param is not defined, returns True 0164 //! with <ach> not filled and <numsub> returned as 0 0165 //! Works with SubListNumber with <aslast> false (no specific case 0166 //! for last parameter) 0167 Standard_EXPORT bool ReadSubList(const int num, 0168 const int nump, 0169 const char* const mess, 0170 occ::handle<Interface_Check>& ach, 0171 int& numsub, 0172 const bool optional = false, 0173 const int lenmin = 0, 0174 const int lenmax = 0) const; 0175 0176 //! reads the content of a sub-list into a transient : 0177 //! SelectNamed, or HArray1 of Integer,Real,String,Transient ... 0178 //! recursive call if list of list ... 0179 //! If a sub-list has mixed types, an HArray1OfTransient is 0180 //! produced, it may contain SelectMember 0181 //! Intended to be called by ReadField 0182 //! The returned status is : negative if failed, 0 if empty. 0183 //! Else the kind to be recorded in the field 0184 Standard_EXPORT int ReadSub(const int numsub, 0185 const char* const mess, 0186 occ::handle<Interface_Check>& ach, 0187 const occ::handle<StepData_PDescr>& descr, 0188 occ::handle<Standard_Transient>& val) const; 0189 0190 //! Reads parameter <nump> of record <num> into a SelectMember, 0191 //! self-sufficient (no Description needed) 0192 //! If <val> is already created, it will be filled, as possible 0193 //! And if reading does not match its own description, the result 0194 //! will be False 0195 //! If <val> is not it not yet created, it will be (SelectNamed) 0196 //! useful if a field is defined as a SelectMember, directly 0197 //! (SELECT with no Entity as member) 0198 //! But SelectType also manages SelectMember (for SELECT with 0199 //! some members as Entity, some other not) 0200 Standard_EXPORT bool ReadMember(const int num, 0201 const int nump, 0202 const char* const mess, 0203 occ::handle<Interface_Check>& ach, 0204 occ::handle<StepData_SelectMember>& val) const; 0205 0206 //! Safe variant for arbitrary type of argument 0207 template <class T> 0208 bool ReadMember(const int num, 0209 const int nump, 0210 const char* const mess, 0211 occ::handle<Interface_Check>& ach, 0212 occ::handle<T>& val) const 0213 { 0214 occ::handle<StepData_SelectMember> aVal = val; 0215 return ReadMember(num, nump, mess, ach, aVal) && !(val = occ::down_cast<T>(aVal)).IsNull(); 0216 } 0217 0218 //! reads parameter <nump> of record <num> into a Field, 0219 //! controlled by a Parameter Descriptor (PDescr), which controls 0220 //! its allowed type(s) and value 0221 //! <ach> is filled if the read parameter does not match its 0222 //! description (but the field is read anyway) 0223 //! If the description is not defined, no control is done 0224 //! Returns True when done 0225 Standard_EXPORT bool ReadField(const int num, 0226 const int nump, 0227 const char* const mess, 0228 occ::handle<Interface_Check>& ach, 0229 const occ::handle<StepData_PDescr>& descr, 0230 StepData_Field& fild) const; 0231 0232 //! reads a list of fields controlled by an ESDescr 0233 Standard_EXPORT bool ReadList(const int num, 0234 occ::handle<Interface_Check>& ach, 0235 const occ::handle<StepData_ESDescr>& descr, 0236 StepData_FieldList& list) const; 0237 0238 //! Reads parameter <nump> of record <num> into a Transient Value 0239 //! according to the type of the parameter : 0240 //! Named for Integer,Boolean,Logical,Enum,Real : SelectNamed 0241 //! Immediate Integer,Boolean,Logical,Enum,Real : SelectInt/Real 0242 //! Text : HAsciiString 0243 //! Ident : the referenced Entity 0244 //! Sub-List not processed, see ReadSub 0245 //! This value is controlled by a Parameter Descriptor (PDescr), 0246 //! which controls its allowed type and value 0247 //! <ach> is filled if the read parameter does not match its 0248 //! description (the select is nevertheless created if possible) 0249 //! 0250 //! Warning : val is in out, hence it is possible to predefine a specific 0251 //! SelectMember then to fill it. If <val> is Null or if the 0252 //! result is not a SelectMember, val itself is returned a new ref 0253 //! For a Select with a Name, <val> must then be a SelectNamed 0254 Standard_EXPORT bool ReadAny(const int num, 0255 const int nump, 0256 const char* const mess, 0257 occ::handle<Interface_Check>& ach, 0258 const occ::handle<StepData_PDescr>& descr, 0259 occ::handle<Standard_Transient>& val) const; 0260 0261 //! reads parameter <nump> of record <num> as a sub-list of 0262 //! two Reals X,Y. Returns True if OK. Else, returns false and 0263 //! feeds Check with appropriate Fails (parameter not a sub-list, 0264 //! not two Reals in the sub-list) composed with "mess" which 0265 //! gives the name of the parameter 0266 Standard_EXPORT bool ReadXY(const int num, 0267 const int nump, 0268 const char* const mess, 0269 occ::handle<Interface_Check>& ach, 0270 double& X, 0271 double& Y) const; 0272 0273 //! reads parameter <nump> of record <num> as a sub-list of 0274 //! three Reals X,Y,Z. Return value and Check managed as by 0275 //! ReadXY (demands a sub-list of three Reals) 0276 Standard_EXPORT bool ReadXYZ(const int num, 0277 const int nump, 0278 const char* const mess, 0279 occ::handle<Interface_Check>& ach, 0280 double& X, 0281 double& Y, 0282 double& Z) const; 0283 0284 //! reads parameter <nump> of record <num> as a single Real value. 0285 //! Return value and Check managed as by ReadXY (demands a Real) 0286 Standard_EXPORT bool ReadReal(const int num, 0287 const int nump, 0288 const char* const mess, 0289 occ::handle<Interface_Check>& ach, 0290 double& val) const; 0291 0292 //! Reads parameter <nump> of record <num> as a single Entity. 0293 //! Return value and Check managed as by ReadReal (demands a 0294 //! reference to an Entity). In Addition, demands read Entity 0295 //! to be Kind of a required Type <atype>. 0296 //! Remark that returned status is False and <ent> is Null if 0297 //! parameter is not an Entity, <ent> remains Not Null is parameter 0298 //! is an Entity but is not Kind of required type 0299 Standard_EXPORT bool ReadEntity(const int num, 0300 const int nump, 0301 const char* const mess, 0302 occ::handle<Interface_Check>& ach, 0303 const occ::handle<Standard_Type>& atype, 0304 occ::handle<Standard_Transient>& ent) const; 0305 0306 //! Safe variant for arbitrary type of argument 0307 template <class T> 0308 bool ReadEntity(const int num, 0309 const int nump, 0310 const char* const mess, 0311 occ::handle<Interface_Check>& ach, 0312 const occ::handle<Standard_Type>& atype, 0313 occ::handle<T>& ent) const 0314 { 0315 occ::handle<Standard_Transient> anEnt = ent; 0316 return ReadEntity(num, nump, mess, ach, atype, anEnt) 0317 && !(ent = occ::down_cast<T>(anEnt)).IsNull(); 0318 } 0319 0320 //! Same as above, but a SelectType checks Type Matching, and 0321 //! records the read Entity (see method Value from SelectType) 0322 Standard_EXPORT bool ReadEntity(const int num, 0323 const int nump, 0324 const char* const mess, 0325 occ::handle<Interface_Check>& ach, 0326 StepData_SelectType& sel) const; 0327 0328 //! reads parameter <nump> of record <num> as a single Integer. 0329 //! Return value & Check managed as by ReadXY (demands an Integer) 0330 Standard_EXPORT bool ReadInteger(const int num, 0331 const int nump, 0332 const char* const mess, 0333 occ::handle<Interface_Check>& ach, 0334 int& val) const; 0335 0336 //! reads parameter <nump> of record <num> as a Boolean 0337 //! Return value and Check managed as by ReadReal (demands a 0338 //! Boolean enum, i.e. text ".T." for True or ".F." for False) 0339 Standard_EXPORT bool ReadBoolean(const int num, 0340 const int nump, 0341 const char* const mess, 0342 occ::handle<Interface_Check>& ach, 0343 bool& flag) const; 0344 0345 //! reads parameter <nump> of record <num> as a Logical 0346 //! Return value and Check managed as by ReadBoolean (demands a 0347 //! Logical enum, i.e. text ".T.", ".F.", or ".U.") 0348 Standard_EXPORT bool ReadLogical(const int num, 0349 const int nump, 0350 const char* const mess, 0351 occ::handle<Interface_Check>& ach, 0352 StepData_Logical& flag) const; 0353 0354 //! reads parameter <nump> of record <num> as a String (text 0355 //! between quotes, quotes are removed by the Read operation) 0356 //! Return value and Check managed as by ReadXY (demands a String) 0357 Standard_EXPORT bool ReadString(const int num, 0358 const int nump, 0359 const char* const mess, 0360 occ::handle<Interface_Check>& ach, 0361 occ::handle<TCollection_HAsciiString>& val) const; 0362 0363 Standard_EXPORT bool ReadEnumParam(const int num, 0364 const int nump, 0365 const char* const mess, 0366 occ::handle<Interface_Check>& ach, 0367 const char*& text) const; 0368 0369 //! Fills a check with a fail message if enumeration value does 0370 //! match parameter definition 0371 //! Just a help to centralize message definitions 0372 Standard_EXPORT void FailEnumValue(const int num, 0373 const int nump, 0374 const char* const mess, 0375 occ::handle<Interface_Check>& ach) const; 0376 0377 //! Reads parameter <nump> of record <num> as an Enumeration (text 0378 //! between dots) and converts it to an integer value, by an 0379 //! EnumTool. Returns True if OK, false if : this parameter is not 0380 //! enumeration, or is not recognized by the EnumTool (with fail) 0381 Standard_EXPORT bool ReadEnum(const int num, 0382 const int nump, 0383 const char* const mess, 0384 occ::handle<Interface_Check>& ach, 0385 const StepData_EnumTool& enumtool, 0386 int& val) const; 0387 0388 //! Resolves a parameter which can be enclosed in a type def., as 0389 //! TYPE(val). The parameter must then be read normally according 0390 //! its type. Parameter to be resolved is <nump> of record <num> 0391 //! <mustbetyped> True demands a typed parameter 0392 //! <mustbetyped> False accepts a non-typed parameter as option 0393 //! mess and ach as usual 0394 //! <numr>,<numrp> are the resolved record and parameter numbers 0395 //! = num,nump if no type, else numrp=1 0396 //! <typ> returns the recorded type, or empty string 0397 //! Remark : a non-typed list is considered as "non-typed" 0398 Standard_EXPORT bool ReadTypedParam(const int num, 0399 const int nump, 0400 const bool mustbetyped, 0401 const char* const mess, 0402 occ::handle<Interface_Check>& ach, 0403 int& numr, 0404 int& numrp, 0405 TCollection_AsciiString& typ) const; 0406 0407 //! Checks if parameter <nump> of record <num> is given as Derived 0408 //! If this Check is successful (i.e. Param = "*"), returns True 0409 //! Else, fills <ach> with a Message which contains <mess> and 0410 //! returns False. According to <errstat>, this message is Warning 0411 //! if errstat is False (Default), Fail if errstat is True 0412 Standard_EXPORT bool CheckDerived(const int num, 0413 const int nump, 0414 const char* const mess, 0415 occ::handle<Interface_Check>& ach, 0416 const bool errstat = false) const; 0417 0418 //! Returns total count of Entities (including Header) 0419 Standard_EXPORT int NbEntities() const override; 0420 0421 //! determines the first suitable record following a given one 0422 //! that is, skips SCOPE,ENDSCOPE and SUBLIST records 0423 //! Note : skips Header records, which are accessed separately 0424 Standard_EXPORT int FindNextRecord(const int num) const override; 0425 0426 //! determines reference numbers in EntityNumber fields 0427 //! called by Prepare from StepReaderTool to prepare later using 0428 //! by a StepModel. This method is attached to StepReaderData 0429 //! because it needs a massive amount of data accesses to work 0430 //! 0431 //! If <withmap> is given False, the basic exploration algorithm 0432 //! is activated, otherwise a map is used as far as it is possible 0433 //! this option can be used only to test this algorithm 0434 Standard_EXPORT void SetEntityNumbers(const bool withmap = true); 0435 0436 //! determine first suitable record of Header 0437 //! works as FindNextRecord, but treats only Header records 0438 Standard_EXPORT int FindNextHeaderRecord(const int num) const; 0439 0440 //! Works as SetEntityNumbers but for Header : more simple because 0441 //! there are no Reference, only Sub-Lists 0442 Standard_EXPORT void PrepareHeader(); 0443 0444 //! Returns the Global Check. It can record Fail messages about 0445 //! Undefined References (detected by SetEntityNumbers) 0446 Standard_EXPORT const occ::handle<Interface_Check> GlobalCheck() const; 0447 0448 DEFINE_STANDARD_RTTIEXT(StepData_StepReaderData, Interface_FileReaderData) 0449 0450 private: 0451 //! Searches for a Parameter of the record <num>, which refers to 0452 //! the Ident <id> (form #nnn). [Used by SetEntityNumbers] 0453 //! If found, returns its EntityNumber, else returns Zero. 0454 Standard_EXPORT int FindEntityNumber(const int num, const int id) const; 0455 0456 //! Prepare string to use in OCCT exchange structure. 0457 //! If code page is Resource_FormatType_NoConversion, 0458 //! clean only special characters without conversion; 0459 //! else convert a string to UTF8 using the code page 0460 //! and handle the control directives. 0461 Standard_EXPORT void cleanText(const occ::handle<TCollection_HAsciiString>& theVal) const; 0462 0463 private: 0464 NCollection_Array1<int> theidents; 0465 NCollection_Array1<int> thetypes; 0466 NCollection_IndexedMap<TCollection_AsciiString> thenametypes; 0467 NCollection_DataMap<int, int> themults; 0468 int thenbents; 0469 int thelastn; 0470 int thenbhead; 0471 int thenbscop; 0472 occ::handle<Interface_Check> thecheck; 0473 Resource_FormatType mySourceCodePage; 0474 }; 0475 0476 #endif // _StepData_StepReaderData_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|