0024023: Revamp the OCCT Handle -- general
[occt.git] / src / STEPCAFControl / STEPCAFControl_Reader.cdl
1 -- Created on: 2000-08-15
2 -- Created by: Andrey BETENEV
3 -- Copyright (c) 2000-2014 OPEN CASCADE SAS
4 --
5 -- This file is part of Open CASCADE Technology software library.
6 --
7 -- This library is free software; you can redistribute it and/or modify it under
8 -- the terms of the GNU Lesser General Public License version 2.1 as published
9 -- by the Free Software Foundation, with special exception defined in the file
10 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 -- distribution for complete text of the license and disclaimer of any warranty.
12 --
13 -- Alternatively, this file may be used under the terms of Open CASCADE
14 -- commercial license or contractual agreement.
15
16 class Reader from STEPCAFControl 
17 -- inherits Reader from STEPControl
18
19     ---Purpose: Provides a tool to read STEP file and put it into
20     --          DECAF document. Besides transfer of shapes (including 
21     --          assemblies) provided by STEPControl, supports also 
22     --          colors and part names
23     --
24     --          This reader supports reading files with external references
25     --          i.e. multifile reading
26     --          It behaves as usual Reader (from STEPControl) for the main
27     --          file (e.g. if it is single file)
28     --          Results of reading other files can be accessed by name of the
29     --          file or by iterating on a readers
30
31 uses
32     AsciiString from TCollection,
33     WorkSession from XSControl,
34     ReturnStatus from IFSelect,
35     Shape from TopoDS,
36     Document from TDocStd,
37     Reader from STEPControl,
38     NextAssemblyUsageOccurrence from StepRepr,
39     DictionaryOfExternFile from STEPCAFControl,
40     ExternFile from STEPCAFControl,
41     ExternRefs from STEPConstruct,
42     Tool from STEPConstruct,
43     DataMapOfShapePD from STEPCAFControl,
44     DataMapOfPDExternFile from STEPCAFControl,
45     DataMapOfShapeLabel from XCAFDoc,
46     MapOfShape from TopTools,
47     ShapeTool from XCAFDoc,
48     Label from TDF,
49     LabelSequence from TDF,
50     HSequenceOfTransient from TColStd,
51     RepresentationItem from StepRepr,
52     TransientProcess from Transfer,
53     ConnectedFaceSet from StepShape
54
55 is
56
57     Create returns Reader;
58         ---Purpose: Creates a reader with an empty
59 -- STEP model and sets ColorMode, LayerMode, NameMode and
60 -- PropsMode to Standard_True.
61
62     Create (WS : WorkSession from XSControl;
63                  scratch : Boolean = Standard_True) returns Reader;
64         ---Purpose: Creates a reader tool and attaches it to an already existing Session
65         --          Clears the session if it was not yet set for STEP
66
67     Init (me: in out; WS : WorkSession from XSControl;
68                       scratch : Boolean = Standard_True);
69         ---Purpose: Clears the internal data structures and attaches to a new session
70         --          Clears the session if it was not yet set for STEP
71
72     ReadFile (me : in out; filename : CString) 
73     returns ReturnStatus from IFSelect;
74         ---Purpose: Loads a file and returns the read status
75         --          Provided for use like single-file reader
76
77     NbRootsForTransfer (me: in out) returns Integer;
78         ---Purpose: Returns number of roots recognized for transfer
79         --          Shortcut for Reader().NbRootsForTransfer()
80
81     TransferOneRoot (me: in out; num: Integer; doc: in out Document from TDocStd) 
82     returns Boolean;
83         ---Purpose: Translates currently loaded STEP file into the document
84         --          Returns True if succeeded, and False in case of fail
85         --          Provided for use like single-file reader
86
87     Transfer (me: in out; doc: in out Document from TDocStd) 
88     returns Boolean;
89         ---Purpose: Translates currently loaded STEP file into the document
90         --          Returns True if succeeded, and False in case of fail
91         --          Provided for use like single-file reader
92
93     Perform (me: in out; filename: AsciiString from TCollection; 
94                          doc: in out Document from TDocStd) returns Boolean;
95
96     Perform (me: in out; filename: CString; doc: in out Document from TDocStd) 
97     returns Boolean;
98         ---Purpose: Translate STEP file given by filename into the document
99         --          Return True if succeeded, and False in case of fail
100
101     ---Scope: Access to fields
102     
103     ExternFiles (me) returns DictionaryOfExternFile from STEPCAFControl;
104         ---Purpose: Returns data on external files
105         --          Returns Null handle if no external files are read
106         ---C++: return const &
107         
108     ExternFile (me; name: CString; ef: out ExternFile from STEPCAFControl)
109     returns Boolean;
110         ---Purpose: Returns data on external file by its name
111         --          Returns False if no external file with given name is read
112         
113     ChangeReader (me: in out) returns Reader from STEPControl;
114         ---Purpose: Returns basic reader 
115         ---C++: return &
116
117     Reader (me) returns Reader from STEPControl;
118         ---Purpose: Returns basic reader as const
119         ---C++: return const &
120
121     ---Scope: Internal methods
122
123     Transfer (me: in out; rd: in out Reader from STEPControl; 
124                           num: Integer;
125                           doc: in out Document from TDocStd;
126                           Lseq: out LabelSequence from TDF;
127                           asOne: Boolean = Standard_False)
128     returns Boolean is protected;
129         ---Purpose: Translates STEP file already loaded into the reader 
130         --          into the document
131         --          If num==0, translates all roots, else only root number num
132         --          Returns True if succeeded, and False in case of fail
133         --          If asOne is True, in case of multiple results composes
134         --          them into assembly. Fills sequence of produced labels
135
136     AddShape (me; S: Shape from TopoDS; STool: ShapeTool from XCAFDoc;
137                   NewShapesMap : MapOfShape from TopTools;
138                   ShapePDMap: DataMapOfShapePD from STEPCAFControl;
139                   PDFileMap : DataMapOfPDExternFile from STEPCAFControl;
140                   ShapeLabelMap: in out DataMapOfShapeLabel from XCAFDoc)
141     returns Label from TDF is protected;
142         ---Purpose: Add a shape to a document
143         --          Depending on a case, this shape can be added as one, or
144         --          as assembly, or (in case if it is associated with external
145         --          reference) taken as that referred shape
146
147     ReadExternFile (me: in out; file, fullpath: CString; doc: in out Document from TDocStd) 
148     returns ExternFile from STEPCAFControl is protected;
149         ---Purpose: Reads (or if returns already read) extern file with 
150         --          given name
151
152     ReadColors (me; WS: WorkSession from XSControl;
153                     doc: in out Document from TDocStd;
154                     PDFileMap : DataMapOfPDExternFile from STEPCAFControl;
155                     ShapeLabelMap: DataMapOfShapeLabel from XCAFDoc)
156     returns Boolean is protected;
157         ---Purpose: Reads style assignments from STEP model and sets
158         --          corresponding color assignments in the DECAF document
159
160     ReadNames (me; WS: WorkSession from XSControl; 
161                    doc: in out Document from TDocStd;
162                    PDFileMap : DataMapOfPDExternFile from STEPCAFControl;
163                    ShapeLabelMap: DataMapOfShapeLabel from XCAFDoc) 
164     returns Boolean is protected;
165         ---Purpose: Reads names of parts defined in the STEP model and 
166         --          assigns them to corresponding labels in the DECAF document
167
168     ReadValProps (me; WS: WorkSession from XSControl; 
169                       doc: in out Document from TDocStd;
170                       PDFileMap : DataMapOfPDExternFile from STEPCAFControl;
171                       ShapeLabelMap: DataMapOfShapeLabel from XCAFDoc)
172     returns Boolean is protected;
173         ---Purpose: Reads validation properties assigned to shapes in the STEP 
174         --          model and assigns them to corresponding labels in the DECAF 
175         --          document
176
177     ReadLayers (me; WS: WorkSession from XSControl; 
178                    doc: in out Document from TDocStd) 
179     returns Boolean is protected;
180         ---Purpose: Reads layers of parts defined in the STEP model and 
181         --          set reference between shape and layers in the DECAF document
182
183     ReadSHUOs (me; WS: WorkSession from XSControl;
184                    doc: in out Document from TDocStd;
185                    PDFileMap : DataMapOfPDExternFile from STEPCAFControl;
186                    ShapeLabelMap: DataMapOfShapeLabel from XCAFDoc)
187     returns Boolean is protected;
188         ---Purpose: Reads SHUO for instances defined in the STEP model and 
189         --          set reference between shape instances from different assemblyes 
190
191     ReadGDTs (me; WS: WorkSession from XSControl;
192                   doc: in out Document from TDocStd)
193     returns Boolean is protected;
194         ---Purpose: Reads D&GT for instances defined in the STEP model and 
195         --          set reference between shape instances from different assemblyes 
196
197     ReadMaterials (me; WS: WorkSession from XSControl;
198                        doc: in out Document from TDocStd;
199                        SeqPDS : HSequenceOfTransient from TColStd)
200     returns Boolean is protected;
201         ---Purpose: Reads materials for instances defined in the STEP model and 
202         --          set reference between shape instances from different assemblyes 
203
204     SettleShapeData(me; theItem: RepresentationItem from StepRepr;
205                         theLab: out Label from TDF;
206                         theShapeTool: ShapeTool from XCAFDoc;
207                         theTP: TransientProcess from Transfer)
208     returns Label from TDF is protected;
209     --- Purpose: Populates the sub-Label of the passed TDF Label with shape
210      --          data associated with the given STEP Representation Item,
211      --          including naming and topological information.
212
213     ExpandSubShapes(me; theShapeTool: ShapeTool from XCAFDoc;
214                         theShapeLabelMap: DataMapOfShapeLabel from XCAFDoc;
215                         theShapePDMap: DataMapOfShapePD from STEPCAFControl)
216     is protected;
217     --- Purpose: Given the maps of already translated shapes, this method
218      --          expands their correspondent Labels in XDE Document so that
219      --          to have a dedicated sub-Label for each sub-shape coming
220      --          with associated name in its STEP Representation Item.
221
222     ExpandManifoldSolidBrep(me; theLab: out Label from TDF;
223                                 theItem: RepresentationItem from StepRepr;
224                                 theTP: TransientProcess from Transfer;
225                                 theShapeTool: ShapeTool from XCAFDoc)
226     is protected;
227     ---  Purpose: Expands the topological structure of Manifold Solid BRep
228      --           STEP entity to OCAF sub-tree. Entities having no names
229      --           associated via their Representation Items are skipped.
230
231     ExpandSBSM(me; theLab: out Label from TDF;
232                theItem: RepresentationItem from StepRepr;
233                theTP: TransientProcess from Transfer;
234                theShapeTool: ShapeTool from XCAFDoc)
235     is protected;
236     ---  Purpose: Expands the topological structure of Shell-Based Surface
237      --           Model STEP entity to OCAF sub-tree. Entities having no names
238      --           associated via their Representation Items are skipped.
239
240     ExpandShell(me; theShell: ConnectedFaceSet from StepShape;
241                     theLab: out Label from TDF;
242                     theTP: TransientProcess from Transfer;
243                     theShapeTool: ShapeTool from XCAFDoc)
244     is protected;
245     ---  Purpose: Expands STEP Shell structure to OCAF sub-tree. Entities
246      --           having no names associated via their Representation Items
247      --           are skipped.
248
249     FindInstance (myclass; NAUO: NextAssemblyUsageOccurrence from StepRepr;
250                       STool: ShapeTool from XCAFDoc;
251                       Tool: Tool from STEPConstruct; 
252                       PDRFileMap : DataMapOfPDExternFile from STEPCAFControl;
253                       ShapeLabelMap: DataMapOfShapeLabel from XCAFDoc)
254     returns Label from TDF;
255         ---Purpose: Returns label of instance of an assembly component
256         --          corresponding to a given NAUO
257
258     --- Work with fileds for different mode of reading STEP file.
259
260     SetColorMode(me: in out; colormode: Boolean from Standard);
261         ---Purpose: Set ColorMode for indicate read Colors or not.
262
263     GetColorMode(me) returns Boolean;
264
265     SetNameMode(me: in out; namemode: Boolean from Standard);
266         ---Purpose: Set NameMode for indicate read Name or not.
267     
268     GetNameMode(me) returns Boolean;
269
270     SetLayerMode(me: in out; layermode: Boolean from Standard);
271         ---Purpose: Set LayerMode for indicate read Layers or not.
272
273     GetLayerMode(me) returns Boolean; 
274
275     
276     SetPropsMode(me: in out; propsmode: Boolean from Standard);
277         ---Purpose: PropsMode for indicate read Validation properties or not.
278
279     GetPropsMode(me) returns Boolean;
280         
281     SetSHUOMode(me: in out; shuomode: Boolean from Standard);
282         ---Purpose: Set SHUO mode for indicate write SHUO or not.
283
284     GetSHUOMode(me) returns Boolean;
285         
286     SetGDTMode(me: in out; gdtmode: Boolean from Standard);
287         ---Purpose: Set GDT mode for indicate write GDT or not.
288
289     GetGDTMode(me) returns Boolean;
290         
291     SetMatMode(me: in out; matmode: Boolean from Standard);
292         ---Purpose: Set Material mode
293
294     GetMatMode(me) returns Boolean;
295         
296 fields
297
298     myReader : Reader from STEPControl;
299     myFiles  : DictionaryOfExternFile from STEPCAFControl;
300     myColorMode : Boolean;
301     myNameMode  : Boolean;
302     myLayerMode : Boolean;
303     myPropsMode : Boolean;
304     mySHUOMode  : Boolean;
305     myGDTMode   : Boolean;
306     myMatMode   : Boolean;
307
308 end Reader;