0028454: Data Exchange, STEP reader - names with special characters cannot be read
[occt.git] / src / StepData / StepData_StepModel.hxx
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_StepModel_HeaderFile
18 #define _StepData_StepModel_HeaderFile
19
20 #include <Interface_EntityList.hxx>
21 #include <TColStd_HArray1OfInteger.hxx>
22 #include <Interface_InterfaceModel.hxx>
23 #include <Resource_FormatType.hxx>
24
25 class Standard_NoSuchObject;
26 class Standard_Transient;
27 class Interface_InterfaceModel;
28 class Interface_EntityIterator;
29 class Interface_Check;
30 class TCollection_HAsciiString;
31
32 class StepData_StepModel;
33 DEFINE_STANDARD_HANDLE(StepData_StepModel, Interface_InterfaceModel)
34
35 //! Gives access to
36 //! - entities in a STEP file,
37 //! - the STEP file header.
38 class StepData_StepModel : public Interface_InterfaceModel
39 {
40
41 public:
42
43   
44   //! Creates an empty STEP model with an empty header.
45   Standard_EXPORT StepData_StepModel();
46   
47   //! returns entity given its rank.
48   //! Same as InterfaceEntity, but with a shorter name
49   Standard_EXPORT Handle(Standard_Transient) Entity (const Standard_Integer num) const;
50   
51   //! gets header from another Model (uses Header Protocol)
52   Standard_EXPORT void GetFromAnother (const Handle(Interface_InterfaceModel)& other) Standard_OVERRIDE;
53   
54   //! Returns a New Empty Model, same type as <me>, i.e. StepModel
55   Standard_EXPORT Handle(Interface_InterfaceModel) NewEmptyModel() const Standard_OVERRIDE;
56   
57   //! returns Header entities under the form of an iterator
58   Standard_EXPORT Interface_EntityIterator Header() const;
59   
60   //! says if a Header entity has a specifed type
61   Standard_EXPORT Standard_Boolean HasHeaderEntity (const Handle(Standard_Type)& atype) const;
62   
63   //! Returns Header entity with specified type, if there is
64   Standard_EXPORT Handle(Standard_Transient) HeaderEntity (const Handle(Standard_Type)& atype) const;
65   
66   //! Clears the Header
67   Standard_EXPORT void ClearHeader() Standard_OVERRIDE;
68   
69   //! Adds an Entity to the Header
70   Standard_EXPORT void AddHeaderEntity (const Handle(Standard_Transient)& ent);
71   
72   //! Specific Check, checks Header Items with HeaderProtocol
73   Standard_EXPORT virtual void VerifyCheck (Handle(Interface_Check)& ach) const Standard_OVERRIDE;
74   
75   //! Dumps the Header, with the Header Protocol of StepData.
76   //! If the Header Protocol is not defined, for each Header Entity,
77   //! prints its Type. Else sends the Header under the form of
78   //! HEADER Section of an Ascii Step File
79   //! <level> is not used because Header is not so big
80   Standard_EXPORT void DumpHeader (Standard_OStream& S, const Standard_Integer level = 0) const Standard_OVERRIDE;
81   
82   //! erases specific labels, i.e. clears the map (entity-ident)
83   Standard_EXPORT void ClearLabels() Standard_OVERRIDE;
84   
85   //! Attaches an ident to an entity to produce a label
86   //! (does nothing if <ent> is not in <me>)
87   Standard_EXPORT void SetIdentLabel (const Handle(Standard_Transient)& ent, const Standard_Integer ident);
88   
89   //! returns the label ident attached to an entity, 0 if not in me
90   Standard_EXPORT Standard_Integer IdentLabel (const Handle(Standard_Transient)& ent) const;
91   
92   //! Prints label specific to STEP norm for a given entity, i.e.
93   //! if a LabelIdent has been recorded, its value with '#', else
94   //! the number in the model with '#' and between ()
95   Standard_EXPORT void PrintLabel (const Handle(Standard_Transient)& ent, Standard_OStream& S) const Standard_OVERRIDE;
96   
97   //! Returns a string with the label attached to a given entity,
98   //! same form as for PrintLabel
99   Standard_EXPORT Handle(TCollection_HAsciiString) StringLabel (const Handle(Standard_Transient)& ent) const Standard_OVERRIDE;
100
101   //! Return the encoding of STEP file for converting names into UNICODE.
102   //! Initialized from "read.step.codepage" variable by constructor, which is Resource_UTF8 by default.
103   Resource_FormatType SourceCodePage() const { return mySourceCodePage; }
104
105   //! Return the encoding of STEP file for converting names into UNICODE.
106   void SetSourceCodePage (Resource_FormatType theCode) { mySourceCodePage = theCode; }
107
108
109   DEFINE_STANDARD_RTTIEXT(StepData_StepModel,Interface_InterfaceModel)
110
111 protected:
112
113
114
115
116 private:
117
118
119   Interface_EntityList theheader;
120   Handle(TColStd_HArray1OfInteger) theidnums;
121   Resource_FormatType mySourceCodePage;
122
123
124 };
125
126
127
128
129
130
131
132 #endif // _StepData_StepModel_HeaderFile