Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:06

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 <Interface_IndexedMapOfAsciiString.hxx>
0025 #include <TColStd_DataMapOfIntegerInteger.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <Interface_FileReaderData.hxx>
0028 #include <Standard_CString.hxx>
0029 #include <Interface_ParamType.hxx>
0030 #include <TColStd_SequenceOfAsciiString.hxx>
0031 #include <StepData_Logical.hxx>
0032 class Interface_Check;
0033 class TCollection_AsciiString;
0034 class StepData_PDescr;
0035 class Standard_Transient;
0036 class StepData_SelectMember;
0037 class StepData_Field;
0038 class StepData_ESDescr;
0039 class StepData_FieldList;
0040 class StepData_SelectType;
0041 class TCollection_HAsciiString;
0042 class StepData_EnumTool;
0043 
0044 
0045 class StepData_StepReaderData;
0046 DEFINE_STANDARD_HANDLE(StepData_StepReaderData, Interface_FileReaderData)
0047 
0048 //! Specific FileReaderData for Step
0049 //! Contains literal description of entities (for each one : type
0050 //! as a string, ident, parameter list)
0051 //! provides references evaluation, plus access to literal data
0052 //! and specific access methods (Boolean, XY, XYZ)
0053 class StepData_StepReaderData : public Interface_FileReaderData
0054 {
0055 
0056 public:
0057 
0058   
0059   //! creates StepReaderData correctly dimensionned (necessary at
0060   //! creation time, because it contains arrays)
0061   //! nbheader is nb of records for Header, nbtotal for Header+Data
0062   //! and nbpar gives the total count of parameters
0063   Standard_EXPORT StepData_StepReaderData(const Standard_Integer nbheader, const Standard_Integer nbtotal, const Standard_Integer nbpar, const Resource_FormatType theSourceCodePage = Resource_FormatType_UTF8);
0064   
0065   //! Fills the fields of a record
0066   Standard_EXPORT void SetRecord (const Standard_Integer num, const Standard_CString ident, const Standard_CString type, const Standard_Integer nbpar);
0067   
0068   //! Fills the fields of a parameter of a record. This is a variant
0069   //! of AddParam, Adapted to STEP (optimized for specific values)
0070   Standard_EXPORT void AddStepParam (const Standard_Integer num, const Standard_CString aval, const Interface_ParamType atype, const Standard_Integer nument = 0);
0071   
0072   //! Returns Record Type
0073   Standard_EXPORT const TCollection_AsciiString& RecordType (const Standard_Integer num) const;
0074   
0075   //! Returns Record Type as a CString
0076   //! was C++ : return const
0077   Standard_EXPORT Standard_CString CType (const Standard_Integer num) const;
0078   
0079   //! Returns record identifier (Positive number)
0080   //! If returned ident is not positive : Sub-List or Scope mark
0081   Standard_EXPORT Standard_Integer RecordIdent (const Standard_Integer num) const;
0082   
0083   //! Returns SubList numero designated by a parameter (nump) in a
0084   //! record (num), or zero if the parameter does not exist or is
0085   //! not a SubList address. Zero too If aslast is True and nump
0086   //! is not for the last parameter
0087   Standard_EXPORT Standard_Integer SubListNumber (const Standard_Integer num, const Standard_Integer nump, const Standard_Boolean aslast) const;
0088   
0089   //! Returns True if <num> corresponds to a Complex Type Entity
0090   //! (as can be defined by ANDOR Express clause)
0091   Standard_EXPORT Standard_Boolean IsComplex (const Standard_Integer num) const;
0092   
0093   //! Returns the List of Types which correspond to a Complex Type
0094   //! Entity. If not Complex, there is just one Type in it
0095   //! For a SubList or a Scope mark, <types> remains empty
0096   Standard_EXPORT void ComplexType (const Standard_Integer num, TColStd_SequenceOfAsciiString& types) const;
0097   
0098   //! Returns the Next "Component" for a Complex Type Entity, of
0099   //! which <num> is already a Component (the first one or a next one)
0100   //! Returns 0 for a Simple Type or for the last Component
0101   Standard_EXPORT Standard_Integer NextForComplex (const Standard_Integer num) const;
0102   
0103   //! Determines the first component which brings a given name, for
0104   //! a Complex Type Entity
0105   //! <num0> is the very first record of this entity
0106   //! <num> is given the last NextNamedForComplex, starts at zero
0107   //! it is returned as the newly found number
0108   //! Hence, in the normal case, NextNamedForComplex starts by num0
0109   //! if <num> is zero, else by NextForComplex(num)
0110   //! If the alphabetic order is not respected, it restarts from
0111   //! num0 and loops on NextForComplex until finding <name>
0112   //! In case of "non-alphabetic order", <ach> is filled with a
0113   //! Warning for this name
0114   //! In case of "not-found at all", <ach> is filled with a Fail,
0115   //! and <num> is returned as zero
0116   //!
0117   //! Returns True if alphabetic order, False else
0118   Standard_EXPORT Standard_Boolean NamedForComplex (const Standard_CString name, const Standard_Integer num0, Standard_Integer& num, Handle(Interface_Check)& ach) const;
0119   
0120   //! Determines the first component which brings a given name, or
0121   //! short name for a Complex Type Entity
0122   //! <num0> is the very first record of this entity
0123   //! <num> is given the last NextNamedForComplex, starts at zero
0124   //! it is returned as the newly found number
0125   //! Hence, in the normal case, NextNamedForComplex starts by num0
0126   //! if <num> is zero, else by NextForComplex(num)
0127   //! If the alphabetic order is not respected, it restarts from
0128   //! num0 and loops on NextForComplex until finding <name>
0129   //! In case of "non-alphabetic order", <ach> is filled with a
0130   //! Warning for this name
0131   //! In case of "not-found at all", <ach> is filled with a Fail,
0132   //! and <num> is returned as zero
0133   //!
0134   //! Returns True if alphabetic order, False else
0135   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;
0136 
0137   //! Checks Count of Parameters of record <num> to equate <nbreq>
0138   //! If this Check is successful, returns True
0139   //! Else, fills <ach> with an Error Message then returns False
0140   //! <mess> is included in the Error message if given non empty
0141   Standard_EXPORT Standard_Boolean CheckNbParams (const Standard_Integer num, const Standard_Integer nbreq, Handle(Interface_Check)& ach, const Standard_CString mess = "") const;
0142   
0143   //! reads parameter <nump> of record <num> as a sub-list (may be
0144   //! typed, see ReadTypedParameter in this case)
0145   //! Returns True if OK. Else (not a LIST), returns false and
0146   //! feeds Check with appropriate check
0147   //! If <optional> is True and Param is not defined, returns True
0148   //! with <ach> not filled and <numsub> returned as 0
0149   //! Works with SubListNumber with <aslast> false (no specific case
0150   //! for last parameter)
0151   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;
0152   
0153   //! reads the content of a sub-list into a transient :
0154   //! SelectNamed, or HArray1 of Integer,Real,String,Transient ...
0155   //! recursive call if list of list ...
0156   //! If a sub-list has mixed types, an HArray1OfTransient is
0157   //! produced, it may contain SelectMember
0158   //! Intended to be called by ReadField
0159   //! The returned status is : negative if failed, 0 if empty.
0160   //! Else the kind to be recorded in the field
0161   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;
0162   
0163   //! Reads parameter <nump> of record <num> into a SelectMember,
0164   //! self-sufficient (no Description needed)
0165   //! If <val> is already created, it will be filled, as possible
0166   //! And if reading does not match its own description, the result
0167   //! will be False
0168   //! If <val> is not it not yet created, it will be (SelectNamed)
0169   //! useful if a field is defined as a SelectMember, directly
0170   //! (SELECT with no Entity as member)
0171   //! But SelectType also manages SelectMember (for SELECT with
0172   //! some members as Entity, some other not)
0173   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;
0174   
0175   //! Safe variant for arbitrary type of argument
0176   template <class T> 
0177   Standard_Boolean ReadMember (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Handle(T)& val) const
0178   {
0179     Handle(StepData_SelectMember) aVal = val;
0180     return ReadMember (num, nump, mess, ach, aVal) && ! (val = Handle(T)::DownCast(aVal)).IsNull();
0181   }
0182 
0183   //! reads parameter <nump> of record <num> into a Field,
0184   //! controlled by a Parameter Descriptor (PDescr), which controls
0185   //! its allowed type(s) and value
0186   //! <ach> is filled if the read parameter does not match its
0187   //! description (but the field is read anyway)
0188   //! If the description is not defined, no control is done
0189   //! Returns True when done
0190   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;
0191   
0192   //! reads a list of fields controlled by an ESDescr
0193   Standard_EXPORT Standard_Boolean ReadList (const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepData_ESDescr)& descr, StepData_FieldList& list) const;
0194   
0195   //! Reads parameter <nump> of record <num> into a Transient Value
0196   //! according to the type of the parameter :
0197   //! Named for Integer,Boolean,Logical,Enum,Real : SelectNamed
0198   //! Immediate Integer,Boolean,Logical,Enum,Real : SelectInt/Real
0199   //! Text  : HAsciiString
0200   //! Ident : the referenced Entity
0201   //! Sub-List not processed, see ReadSub
0202   //! This value is controlled by a Parameter Descriptor (PDescr),
0203   //! which controls its allowed type and value
0204   //! <ach> is filled if the read parameter does not match its
0205   //! description (the select is nevertheless created if possible)
0206   //!
0207   //! Warning : val is in out, hence it is possible to predefine a specific
0208   //! SelectMember then to fill it. If <val> is Null or if the
0209   //! result is not a SelectMember, val itself is returned a new ref
0210   //! For a Select with a Name, <val> must then be a SelectNamed
0211   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;
0212   
0213   //! reads parameter <nump> of record <num> as a sub-list of
0214   //! two Reals X,Y. Returns True if OK. Else, returns false and
0215   //! feeds Check with appropriate Fails (parameter not a sub-list,
0216   //! not two Reals in the sub-list) composed with "mess" which
0217   //! gives the name of the parameter
0218   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;
0219   
0220   //! reads parameter <nump> of record <num> as a sub-list of
0221   //! three Reals X,Y,Z. Return value and Check managed as by
0222   //! ReadXY (demands a sub-list of three Reals)
0223   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;
0224   
0225   //! reads parameter <nump> of record <num> as a single Real value.
0226   //! Return value and Check managed as by ReadXY (demands a Real)
0227   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;
0228   
0229   //! Reads parameter <nump> of record <num> as a single Entity.
0230   //! Return value and Check managed as by ReadReal (demands a
0231   //! reference to an Entity). In Addition, demands read Entity
0232   //! to be Kind of a required Type <atype>.
0233   //! Remark that returned status is False and <ent> is Null if
0234   //! parameter is not an Entity, <ent> remains Not Null is parameter
0235   //! is an Entity but is not Kind of required type
0236   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;
0237   
0238   //! Safe variant for arbitrary type of argument
0239   template <class T> 
0240   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(T)& ent) const
0241   {
0242     Handle(Standard_Transient) anEnt = ent;
0243     return ReadEntity (num, nump, mess, ach, atype, anEnt) && ! (ent = Handle(T)::DownCast(anEnt)).IsNull();
0244   }
0245 
0246   //! Same as above, but a SelectType checks Type Matching, and
0247   //! records the read Entity (see method Value from SelectType)
0248   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;
0249   
0250   //! reads parameter <nump> of record <num> as a single Integer.
0251   //! Return value & Check managed as by ReadXY (demands an Integer)
0252   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;
0253   
0254   //! reads parameter <nump> of record <num> as a Boolean
0255   //! Return value and Check managed as by ReadReal (demands a
0256   //! Boolean enum, i.e. text ".T." for True or ".F." for False)
0257   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;
0258   
0259   //! reads parameter <nump> of record <num> as a Logical
0260   //! Return value and Check managed as by ReadBoolean (demands a
0261   //! Logical enum, i.e. text ".T.", ".F.", or ".U.")
0262   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;
0263   
0264   //! reads parameter <nump> of record <num> as a String (text
0265   //! between quotes, quotes are removed by the Read operation)
0266   //! Return value and Check managed as by ReadXY (demands a String)
0267   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;
0268   
0269   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;
0270   
0271   //! Fills a check with a fail message if enumeration value does
0272   //! match parameter definition
0273   //! Just a help to centralize message definitions
0274   Standard_EXPORT void FailEnumValue (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach) const;
0275   
0276   //! Reads parameter <nump> of record <num> as an Enumeration (text
0277   //! between dots) and converts it to an integer value, by an
0278   //! EnumTool. Returns True if OK, false if : this parameter is not
0279   //! enumeration, or is not recognized by the EnumTool (with fail)
0280   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;
0281   
0282   //! Resolves a parameter which can be enclosed in a type def., as
0283   //! TYPE(val). The parameter must then be read normally according
0284   //! its type.  Parameter to be resolved is <nump> of record <num>
0285   //! <mustbetyped> True  demands a typed parameter
0286   //! <mustbetyped> False accepts a non-typed parameter as option
0287   //! mess and ach as usual
0288   //! <numr>,<numrp> are the resolved record and parameter numbers
0289   //! = num,nump if no type,  else numrp=1
0290   //! <typ> returns the recorded type, or empty string
0291   //! Remark : a non-typed list is considered as "non-typed"
0292   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;
0293   
0294   //! Checks if parameter <nump> of record <num> is given as Derived
0295   //! If this Check is successful (i.e. Param = "*"), returns True
0296   //! Else, fills <ach> with a Message which contains <mess> and
0297   //! returns False. According to <errstat>, this message is Warning
0298   //! if errstat is False (Default), Fail if errstat is True
0299   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;
0300   
0301   //! Returns total count of Entities (including Header)
0302   Standard_EXPORT virtual Standard_Integer NbEntities() const Standard_OVERRIDE;
0303   
0304   //! determines the first suitable record following a given one
0305   //! that is, skips SCOPE,ENDSCOPE and SUBLIST records
0306   //! Note : skips Header records, which are accessed separately
0307   Standard_EXPORT Standard_Integer FindNextRecord (const Standard_Integer num) const Standard_OVERRIDE;
0308   
0309   //! determines reference numbers in EntityNumber fields
0310   //! called by Prepare from StepReaderTool to prepare later using
0311   //! by a StepModel. This method is attached to StepReaderData
0312   //! because it needs a massive amount of data accesses to work
0313   //!
0314   //! If <withmap> is given False, the basic exploration algorithm
0315   //! is activated, otherwise a map is used as far as it is possible
0316   //! this option can be used only to test this algorithm
0317   Standard_EXPORT void SetEntityNumbers (const Standard_Boolean withmap = Standard_True);
0318   
0319   //! determine first suitable record of Header
0320   //! works as FindNextRecord, but treats only Header records
0321   Standard_EXPORT Standard_Integer FindNextHeaderRecord (const Standard_Integer num) const;
0322   
0323   //! Works as SetEntityNumbers but for Header : more simple because
0324   //! there are no Reference, only Sub-Lists
0325   Standard_EXPORT void PrepareHeader();
0326   
0327   //! Returns the Global Check. It can record Fail messages about
0328   //! Undefined References (detected by SetEntityNumbers)
0329   Standard_EXPORT const Handle(Interface_Check) GlobalCheck() const;
0330 
0331 
0332 
0333 
0334   DEFINE_STANDARD_RTTIEXT(StepData_StepReaderData,Interface_FileReaderData)
0335 
0336 protected:
0337 
0338 
0339 
0340 
0341 private:
0342 
0343   
0344   //! Searches for a Parameter of the record <num>, which refers to
0345   //! the Ident <id> (form #nnn). [Used by SetEntityNumbers]
0346   //! If found, returns its EntityNumber, else returns Zero.
0347   Standard_EXPORT Standard_Integer FindEntityNumber (const Standard_Integer num, const Standard_Integer id) const;
0348 
0349   //! Prepare string to use in OCCT exchange structure.
0350   //! If code page is Resource_FormatType_NoConversion,
0351   //! clean only special characters without conversion;
0352   //! else convert a string to UTF8 using the code page
0353   //! and handle the control directives.
0354   Standard_EXPORT void cleanText(const Handle(TCollection_HAsciiString)& theVal) const;
0355 
0356 private:
0357 
0358 
0359   TColStd_Array1OfInteger theidents;
0360   TColStd_Array1OfInteger thetypes;
0361   Interface_IndexedMapOfAsciiString thenametypes;
0362   TColStd_DataMapOfIntegerInteger themults;
0363   Standard_Integer thenbents;
0364   Standard_Integer thelastn;
0365   Standard_Integer thenbhead;
0366   Standard_Integer thenbscop;
0367   Handle(Interface_Check) thecheck;
0368   Resource_FormatType mySourceCodePage;
0369 
0370 
0371 };
0372 
0373 
0374 
0375 
0376 
0377 
0378 
0379 #endif // _StepData_StepReaderData_HeaderFile