0025748: Parallel version of progress indicator
[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
148820b2 19#include <IFSelect_ReturnStatus.hxx>
20#include <MoniTool_DataMapOfShapeTransient.hxx>
21#include <NCollection_Vector.hxx>
42cf5bc1 22#include <Standard_DefineAlloc.hxx>
23#include <Standard_Handle.hxx>
42cf5bc1 24#include <STEPCAFControl_DataMapOfLabelShape.hxx>
25#include <STEPCAFControl_DataMapOfLabelExternFile.hxx>
42cf5bc1 26#include <STEPControl_StepModelType.hxx>
148820b2 27#include <STEPControl_Writer.hxx>
1209c1b9 28#include <StepAP242_GeometricItemSpecificUsage.hxx>
29#include <StepDimTol_Datum.hxx>
30#include <StepDimTol_GeometricTolerance.hxx>
31#include <StepDimTol_HArray1OfDatumSystemOrReference.hxx>
32#include <StepRepr_ProductDefinitionShape.hxx>
33#include <StepVisual_DraughtingModel.hxx>
34#include <StepVisual_HArray1OfPresentationStyleAssignment.hxx>
148820b2 35#include <TDF_LabelSequence.hxx>
1209c1b9 36#include <XCAFDimTolObjects_GeomToleranceObject.hxx>
37
42cf5bc1 38class XSControl_WorkSession;
39class TDocStd_Document;
42cf5bc1 40class TCollection_AsciiString;
41class STEPCAFControl_ExternFile;
42cf5bc1 42class TopoDS_Shape;
43
42cf5bc1 44//! Provides a tool to write DECAF document to the
45//! STEP file. Besides transfer of shapes (including
46//! assemblies) provided by STEPControl, supports also
47//! colors and part names
48//!
49//! Also supports multifile writing
50class STEPCAFControl_Writer
51{
52public:
53
54 DEFINE_STANDARD_ALLOC
f5e92b04 55
42cf5bc1 56
57 //! Creates a writer with an empty
58 //! STEP model and sets ColorMode, LayerMode, NameMode and
59 //! PropsMode to Standard_True.
60 Standard_EXPORT STEPCAFControl_Writer();
61
62 //! Creates a reader tool and attaches it to an already existing Session
63 //! Clears the session if it was not yet set for STEP
64 //! Clears the internal data structures
65 Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
66
67 //! Clears the internal data structures and attaches to a new session
68 //! Clears the session if it was not yet set for STEP
69 Standard_EXPORT void Init (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
70
71 //! Writes all the produced models into file
72 //! In case of multimodel with extern references,
73 //! filename will be a name of root file, all other files
74 //! have names of corresponding parts
75 //! Provided for use like single-file writer
76 Standard_EXPORT IFSelect_ReturnStatus Write (const Standard_CString filename);
77
42cf5bc1 78 //! Transfers a document (or single label) to a STEP model
79 //! The mode of translation of shape is AsIs
80 //! If multi is not null pointer, it switches to multifile
81 //! mode (with external refs), and string pointed by <multi>
82 //! gives prefix for names of extern files (can be empty string)
83 //! Returns True if translation is OK
7e785937 84 Standard_EXPORT Standard_Boolean Transfer (const Handle(TDocStd_Document)& doc,
85 const STEPControl_StepModelType mode = STEPControl_AsIs,
86 const Standard_CString multi = 0,
87 const Message_ProgressRange& theProgress = Message_ProgressRange());
f5e92b04 88
89 //! Method to transfer part of the document specified by label
7e785937 90 Standard_EXPORT Standard_Boolean Transfer (const TDF_Label& L,
91 const STEPControl_StepModelType mode = STEPControl_AsIs,
92 const Standard_CString multi = 0,
93 const Message_ProgressRange& theProgress = Message_ProgressRange());
1b44ab4b 94
7e785937 95 Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc,
96 const TCollection_AsciiString& filename,
97 const Message_ProgressRange& theProgress = Message_ProgressRange());
42cf5bc1 98
99 //! Transfers a document and writes it to a STEP file
100 //! Returns True if translation is OK
7e785937 101 Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc,
102 const Standard_CString filename,
103 const Message_ProgressRange& theProgress = Message_ProgressRange());
42cf5bc1 104
105 //! Returns data on external files
106 //! Returns Null handle if no external files are read
997e128f 107 Standard_EXPORT const NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& ExternFiles() const;
42cf5bc1 108
109 //! Returns data on external file by its original label
110 //! Returns False if no external file with given name is read
111 Standard_EXPORT Standard_Boolean ExternFile (const TDF_Label& L, Handle(STEPCAFControl_ExternFile)& ef) const;
112
113 //! Returns data on external file by its name
114 //! Returns False if no external file with given name is read
115 Standard_EXPORT Standard_Boolean ExternFile (const Standard_CString name, Handle(STEPCAFControl_ExternFile)& ef) const;
116
117 //! Returns basic reader for root file
118 Standard_EXPORT STEPControl_Writer& ChangeWriter();
119
120 //! Returns basic reader as const
121 Standard_EXPORT const STEPControl_Writer& Writer() const;
122
123 //! Set ColorMode for indicate write Colors or not.
124 Standard_EXPORT void SetColorMode (const Standard_Boolean colormode);
125
126 Standard_EXPORT Standard_Boolean GetColorMode() const;
127
128 //! Set NameMode for indicate write Name or not.
129 Standard_EXPORT void SetNameMode (const Standard_Boolean namemode);
130
131 Standard_EXPORT Standard_Boolean GetNameMode() const;
132
133 //! Set LayerMode for indicate write Layers or not.
134 Standard_EXPORT void SetLayerMode (const Standard_Boolean layermode);
135
136 Standard_EXPORT Standard_Boolean GetLayerMode() const;
137
138 //! PropsMode for indicate write Validation properties or not.
139 Standard_EXPORT void SetPropsMode (const Standard_Boolean propsmode);
140
141 Standard_EXPORT Standard_Boolean GetPropsMode() const;
142
143 //! Set SHUO mode for indicate write SHUO or not.
144 Standard_EXPORT void SetSHUOMode (const Standard_Boolean shuomode);
145
146 Standard_EXPORT Standard_Boolean GetSHUOMode() const;
147
148 //! Set dimtolmode for indicate write D&GTs or not.
149 Standard_EXPORT void SetDimTolMode (const Standard_Boolean dimtolmode);
150
151 Standard_EXPORT Standard_Boolean GetDimTolMode() const;
152
153 //! Set dimtolmode for indicate write D&GTs or not.
154 Standard_EXPORT void SetMaterialMode (const Standard_Boolean matmode);
155
156 Standard_EXPORT Standard_Boolean GetMaterialMode() const;
157
158
159
160
161protected:
f5e92b04 162 //! Mehod to writing sequence of root assemblies or part of the file specified by use by one label
7e785937 163 Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L,
164 const STEPControl_StepModelType mode = STEPControl_AsIs,
165 const Standard_CString multi = 0,
166 const Message_ProgressRange& theProgress = Message_ProgressRange());
42cf5bc1 167
168 //! Transfers labels to a STEP model
169 //! Returns True if translation is OK
170 //! isExternFile setting from TransferExternFiles method
7e785937 171 Standard_EXPORT Standard_Boolean Transfer (STEPControl_Writer& wr,
172 const TDF_LabelSequence& labels,
173 const STEPControl_StepModelType mode = STEPControl_AsIs,
174 const Standard_CString multi = 0,
175 const Standard_Boolean isExternFile = Standard_False,
176 const Message_ProgressRange& theProgress = Message_ProgressRange()) ;
42cf5bc1 177
178 //! Parses assembly structure of label L, writes all the simple
179 //! shapes each to its own file named by name of its label plus
180 //! prefix
181 //! Returns shape representing that assembly structure
182 //! in the form of nested empty compounds (and a sequence of
183 //! labels which are newly written nodes of this assembly)
7e785937 184 Standard_EXPORT TopoDS_Shape TransferExternFiles (const TDF_Label& L,
185 const STEPControl_StepModelType mode,
186 TDF_LabelSequence& Lseq,
187 const Standard_CString prefix = "",
188 const Message_ProgressRange& theProgress = Message_ProgressRange());
42cf5bc1 189
190 //! Write external references to STEP
191 Standard_EXPORT Standard_Boolean WriteExternRefs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
192
193 //! Write colors assigned to specified labels, to STEP model
194 Standard_EXPORT Standard_Boolean WriteColors (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
195
196 //! Write names assigned to specified labels, to STEP model
197 Standard_EXPORT Standard_Boolean WriteNames (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
198
199 //! Write D&GTs assigned to specified labels, to STEP model
200 Standard_EXPORT Standard_Boolean WriteDGTs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
201
6595eee7 202 //! Write D&GTs assigned to specified labels, to STEP model, according AP242
1209c1b9 203 Standard_EXPORT Standard_Boolean WriteDGTsAP242 (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
6595eee7 204
42cf5bc1 205 //! Write materials assigned to specified labels, to STEP model
206 Standard_EXPORT Standard_Boolean WriteMaterials (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
207
208 //! Write validation properties assigned to specified labels,
209 //! to STEP model
210 Standard_EXPORT Standard_Boolean WriteValProps (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels, const Standard_CString multi) const;
211
212 //! Write layers assigned to specified labels, to STEP model
213 Standard_EXPORT Standard_Boolean WriteLayers (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
214
215 //! Write SHUO assigned to specified component, to STEP model
216 Standard_EXPORT Standard_Boolean WriteSHUOs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
217
f5e92b04 218
42cf5bc1 219
220private:
1209c1b9 221 Standard_EXPORT Handle(StepRepr_ShapeAspect) WriteShapeAspect(const Handle(XSControl_WorkSession) &WS,
222 const TDF_Label theLabel, const TopoDS_Shape theShape, Handle(StepRepr_RepresentationContext)& theRC,
223 Handle(StepAP242_GeometricItemSpecificUsage)& theGISU);
224
225 Standard_EXPORT void WritePresentation(const Handle(XSControl_WorkSession) &WS, const TopoDS_Shape thePresentation,
226 const Handle(TCollection_HAsciiString)& thePrsName, const Standard_Boolean hasSemantic, const Standard_Boolean hasPlane,
227 const gp_Ax2 theAnnotationPlane, const gp_Pnt theTextPosition, const Handle(Standard_Transient) theDimension);
228
229 Standard_EXPORT Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSession) &WS, const TDF_LabelSequence theShapeL,
230 const TDF_Label theDatumL, const Standard_Boolean isFirstDTarget, const Handle(StepDimTol_Datum) theWrittenDatum);
231
232 Standard_EXPORT void WriteToleranceZone(const Handle(XSControl_WorkSession) &WS, const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObject,
233 const Handle(StepDimTol_GeometricTolerance)& theEntity, const Handle(StepRepr_RepresentationContext)& theRC);
234
235 Standard_EXPORT void WriteGeomTolerance(const Handle(XSControl_WorkSession) &WS, const TDF_LabelSequence theShapeSeqL,
236 const TDF_Label theGeomTolL, const Handle(StepDimTol_HArray1OfDatumSystemOrReference)& theDatumSystem,
237 const Handle(StepRepr_RepresentationContext)& theRC);
42cf5bc1 238
239
240
241 STEPControl_Writer myWriter;
997e128f 242 NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
42cf5bc1 243 STEPCAFControl_DataMapOfLabelShape myLabels;
244 STEPCAFControl_DataMapOfLabelExternFile myLabEF;
245 Standard_Boolean myColorMode;
246 Standard_Boolean myNameMode;
247 Standard_Boolean myLayerMode;
248 Standard_Boolean myPropsMode;
249 Standard_Boolean mySHUOMode;
250 MoniTool_DataMapOfShapeTransient myMapCompMDGPR;
5b83cdb6 251 Standard_Boolean myGDTMode;
42cf5bc1 252 Standard_Boolean myMatMode;
1209c1b9 253 NCollection_Vector<Handle(StepRepr_RepresentationItem)> myGDTAnnotations;
254 Handle(StepVisual_DraughtingModel) myGDTPresentationDM;
255 Handle(StepVisual_HArray1OfPresentationStyleAssignment) myGDTPrsCurveStyle;
256 Handle(StepRepr_ProductDefinitionShape) myGDTCommonPDS;
42cf5bc1 257
258};
259
260
261
262
42cf5bc1 263#endif // _STEPCAFControl_Writer_HeaderFile