0024788: Foundation Classes - remove Dico_Dictionary
[occt.git] / src / STEPCAFControl / STEPCAFControl_Writer.hxx
CommitLineData
42cf5bc1 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#ifndef _STEPCAFControl_Writer_HeaderFile
17#define _STEPCAFControl_Writer_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_DefineAlloc.hxx>
21#include <Standard_Handle.hxx>
22
23#include <STEPControl_Writer.hxx>
24#include <STEPCAFControl_DataMapOfLabelShape.hxx>
25#include <STEPCAFControl_DataMapOfLabelExternFile.hxx>
26#include <Standard_Boolean.hxx>
27#include <MoniTool_DataMapOfShapeTransient.hxx>
28#include <IFSelect_ReturnStatus.hxx>
29#include <Standard_CString.hxx>
30#include <STEPControl_StepModelType.hxx>
31#include <TDF_LabelSequence.hxx>
42cf5bc1 32class XSControl_WorkSession;
33class TDocStd_Document;
34class TDF_Label;
35class TCollection_AsciiString;
36class STEPCAFControl_ExternFile;
37class STEPControl_Writer;
38class TopoDS_Shape;
39
42cf5bc1 40//! Provides a tool to write DECAF document to the
41//! STEP file. Besides transfer of shapes (including
42//! assemblies) provided by STEPControl, supports also
43//! colors and part names
44//!
45//! Also supports multifile writing
46class STEPCAFControl_Writer
47{
48public:
49
50 DEFINE_STANDARD_ALLOC
f5e92b04 51
42cf5bc1 52
53 //! Creates a writer with an empty
54 //! STEP model and sets ColorMode, LayerMode, NameMode and
55 //! PropsMode to Standard_True.
56 Standard_EXPORT STEPCAFControl_Writer();
57
58 //! Creates a reader tool and attaches it to an already existing Session
59 //! Clears the session if it was not yet set for STEP
60 //! Clears the internal data structures
61 Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
62
63 //! Clears the internal data structures and attaches to a new session
64 //! Clears the session if it was not yet set for STEP
65 Standard_EXPORT void Init (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
66
67 //! Writes all the produced models into file
68 //! In case of multimodel with extern references,
69 //! filename will be a name of root file, all other files
70 //! have names of corresponding parts
71 //! Provided for use like single-file writer
72 Standard_EXPORT IFSelect_ReturnStatus Write (const Standard_CString filename);
73
42cf5bc1 74 //! Transfers a document (or single label) to a STEP model
75 //! The mode of translation of shape is AsIs
76 //! If multi is not null pointer, it switches to multifile
77 //! mode (with external refs), and string pointed by <multi>
78 //! gives prefix for names of extern files (can be empty string)
79 //! Returns True if translation is OK
1b44ab4b 80 Standard_EXPORT Standard_Boolean Transfer (const Handle(TDocStd_Document)& doc, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
f5e92b04 81
82 //! Method to transfer part of the document specified by label
83 Standard_EXPORT Standard_Boolean Transfer (const TDF_Label& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0 );
1b44ab4b 84
42cf5bc1 85 Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc, const TCollection_AsciiString& filename);
86
87 //! Transfers a document and writes it to a STEP file
88 //! Returns True if translation is OK
89 Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc, const Standard_CString filename);
90
91 //! Returns data on external files
92 //! Returns Null handle if no external files are read
997e128f 93 Standard_EXPORT const NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& ExternFiles() const;
42cf5bc1 94
95 //! Returns data on external file by its original label
96 //! Returns False if no external file with given name is read
97 Standard_EXPORT Standard_Boolean ExternFile (const TDF_Label& L, Handle(STEPCAFControl_ExternFile)& ef) const;
98
99 //! Returns data on external file by its name
100 //! Returns False if no external file with given name is read
101 Standard_EXPORT Standard_Boolean ExternFile (const Standard_CString name, Handle(STEPCAFControl_ExternFile)& ef) const;
102
103 //! Returns basic reader for root file
104 Standard_EXPORT STEPControl_Writer& ChangeWriter();
105
106 //! Returns basic reader as const
107 Standard_EXPORT const STEPControl_Writer& Writer() const;
108
109 //! Set ColorMode for indicate write Colors or not.
110 Standard_EXPORT void SetColorMode (const Standard_Boolean colormode);
111
112 Standard_EXPORT Standard_Boolean GetColorMode() const;
113
114 //! Set NameMode for indicate write Name or not.
115 Standard_EXPORT void SetNameMode (const Standard_Boolean namemode);
116
117 Standard_EXPORT Standard_Boolean GetNameMode() const;
118
119 //! Set LayerMode for indicate write Layers or not.
120 Standard_EXPORT void SetLayerMode (const Standard_Boolean layermode);
121
122 Standard_EXPORT Standard_Boolean GetLayerMode() const;
123
124 //! PropsMode for indicate write Validation properties or not.
125 Standard_EXPORT void SetPropsMode (const Standard_Boolean propsmode);
126
127 Standard_EXPORT Standard_Boolean GetPropsMode() const;
128
129 //! Set SHUO mode for indicate write SHUO or not.
130 Standard_EXPORT void SetSHUOMode (const Standard_Boolean shuomode);
131
132 Standard_EXPORT Standard_Boolean GetSHUOMode() const;
133
134 //! Set dimtolmode for indicate write D&GTs or not.
135 Standard_EXPORT void SetDimTolMode (const Standard_Boolean dimtolmode);
136
137 Standard_EXPORT Standard_Boolean GetDimTolMode() const;
138
139 //! Set dimtolmode for indicate write D&GTs or not.
140 Standard_EXPORT void SetMaterialMode (const Standard_Boolean matmode);
141
142 Standard_EXPORT Standard_Boolean GetMaterialMode() const;
143
144
145
146
147protected:
f5e92b04 148 //! Mehod to writing sequence of root assemblies or part of the file specified by use by one label
149 Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
42cf5bc1 150
151 //! Transfers labels to a STEP model
152 //! Returns True if translation is OK
153 //! isExternFile setting from TransferExternFiles method
f5e92b04 154 Standard_EXPORT Standard_Boolean Transfer (STEPControl_Writer& wr, const TDF_LabelSequence& labels, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0, const Standard_Boolean isExternFile = Standard_False) ;
42cf5bc1 155
156 //! Parses assembly structure of label L, writes all the simple
157 //! shapes each to its own file named by name of its label plus
158 //! prefix
159 //! Returns shape representing that assembly structure
160 //! in the form of nested empty compounds (and a sequence of
161 //! labels which are newly written nodes of this assembly)
162 Standard_EXPORT TopoDS_Shape TransferExternFiles (const TDF_Label& L, const STEPControl_StepModelType mode, TDF_LabelSequence& Lseq, const Standard_CString prefix = "");
163
164 //! Write external references to STEP
165 Standard_EXPORT Standard_Boolean WriteExternRefs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
166
167 //! Write colors assigned to specified labels, to STEP model
168 Standard_EXPORT Standard_Boolean WriteColors (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
169
170 //! Write names assigned to specified labels, to STEP model
171 Standard_EXPORT Standard_Boolean WriteNames (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
172
173 //! Write D&GTs assigned to specified labels, to STEP model
174 Standard_EXPORT Standard_Boolean WriteDGTs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
175
6595eee7 176 //! Write D&GTs assigned to specified labels, to STEP model, according AP242
177 Standard_EXPORT Standard_Boolean WriteDGTsAP242 (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
178
42cf5bc1 179 //! Write materials assigned to specified labels, to STEP model
180 Standard_EXPORT Standard_Boolean WriteMaterials (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
181
182 //! Write validation properties assigned to specified labels,
183 //! to STEP model
184 Standard_EXPORT Standard_Boolean WriteValProps (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels, const Standard_CString multi) const;
185
186 //! Write layers assigned to specified labels, to STEP model
187 Standard_EXPORT Standard_Boolean WriteLayers (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
188
189 //! Write SHUO assigned to specified component, to STEP model
190 Standard_EXPORT Standard_Boolean WriteSHUOs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
191
f5e92b04 192
42cf5bc1 193
194private:
195
196
197
198 STEPControl_Writer myWriter;
997e128f 199 NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
42cf5bc1 200 STEPCAFControl_DataMapOfLabelShape myLabels;
201 STEPCAFControl_DataMapOfLabelExternFile myLabEF;
202 Standard_Boolean myColorMode;
203 Standard_Boolean myNameMode;
204 Standard_Boolean myLayerMode;
205 Standard_Boolean myPropsMode;
206 Standard_Boolean mySHUOMode;
207 MoniTool_DataMapOfShapeTransient myMapCompMDGPR;
208 Standard_Boolean myDGTMode;
209 Standard_Boolean myMatMode;
210
211
212};
213
214
215
216
42cf5bc1 217#endif // _STEPCAFControl_Writer_HeaderFile