0031689: Coding Rules - including STEPCAFControl_Writer.hxx produces compilation...
[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
1b44ab4b 84 Standard_EXPORT Standard_Boolean Transfer (const Handle(TDocStd_Document)& doc, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
f5e92b04 85
86 //! Method to transfer part of the document specified by label
87 Standard_EXPORT Standard_Boolean Transfer (const TDF_Label& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0 );
1b44ab4b 88
42cf5bc1 89 Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc, const TCollection_AsciiString& filename);
90
91 //! Transfers a document and writes it to a STEP file
92 //! Returns True if translation is OK
93 Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc, const Standard_CString filename);
94
95 //! Returns data on external files
96 //! Returns Null handle if no external files are read
997e128f 97 Standard_EXPORT const NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& ExternFiles() const;
42cf5bc1 98
99 //! Returns data on external file by its original label
100 //! Returns False if no external file with given name is read
101 Standard_EXPORT Standard_Boolean ExternFile (const TDF_Label& L, Handle(STEPCAFControl_ExternFile)& ef) const;
102
103 //! Returns data on external file by its name
104 //! Returns False if no external file with given name is read
105 Standard_EXPORT Standard_Boolean ExternFile (const Standard_CString name, Handle(STEPCAFControl_ExternFile)& ef) const;
106
107 //! Returns basic reader for root file
108 Standard_EXPORT STEPControl_Writer& ChangeWriter();
109
110 //! Returns basic reader as const
111 Standard_EXPORT const STEPControl_Writer& Writer() const;
112
113 //! Set ColorMode for indicate write Colors or not.
114 Standard_EXPORT void SetColorMode (const Standard_Boolean colormode);
115
116 Standard_EXPORT Standard_Boolean GetColorMode() const;
117
118 //! Set NameMode for indicate write Name or not.
119 Standard_EXPORT void SetNameMode (const Standard_Boolean namemode);
120
121 Standard_EXPORT Standard_Boolean GetNameMode() const;
122
123 //! Set LayerMode for indicate write Layers or not.
124 Standard_EXPORT void SetLayerMode (const Standard_Boolean layermode);
125
126 Standard_EXPORT Standard_Boolean GetLayerMode() const;
127
128 //! PropsMode for indicate write Validation properties or not.
129 Standard_EXPORT void SetPropsMode (const Standard_Boolean propsmode);
130
131 Standard_EXPORT Standard_Boolean GetPropsMode() const;
132
133 //! Set SHUO mode for indicate write SHUO or not.
134 Standard_EXPORT void SetSHUOMode (const Standard_Boolean shuomode);
135
136 Standard_EXPORT Standard_Boolean GetSHUOMode() const;
137
138 //! Set dimtolmode for indicate write D&GTs or not.
139 Standard_EXPORT void SetDimTolMode (const Standard_Boolean dimtolmode);
140
141 Standard_EXPORT Standard_Boolean GetDimTolMode() const;
142
143 //! Set dimtolmode for indicate write D&GTs or not.
144 Standard_EXPORT void SetMaterialMode (const Standard_Boolean matmode);
145
146 Standard_EXPORT Standard_Boolean GetMaterialMode() const;
147
148
149
150
151protected:
f5e92b04 152 //! Mehod to writing sequence of root assemblies or part of the file specified by use by one label
153 Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
42cf5bc1 154
155 //! Transfers labels to a STEP model
156 //! Returns True if translation is OK
157 //! isExternFile setting from TransferExternFiles method
f5e92b04 158 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 159
160 //! Parses assembly structure of label L, writes all the simple
161 //! shapes each to its own file named by name of its label plus
162 //! prefix
163 //! Returns shape representing that assembly structure
164 //! in the form of nested empty compounds (and a sequence of
165 //! labels which are newly written nodes of this assembly)
166 Standard_EXPORT TopoDS_Shape TransferExternFiles (const TDF_Label& L, const STEPControl_StepModelType mode, TDF_LabelSequence& Lseq, const Standard_CString prefix = "");
167
168 //! Write external references to STEP
169 Standard_EXPORT Standard_Boolean WriteExternRefs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
170
171 //! Write colors assigned to specified labels, to STEP model
172 Standard_EXPORT Standard_Boolean WriteColors (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
173
174 //! Write names assigned to specified labels, to STEP model
175 Standard_EXPORT Standard_Boolean WriteNames (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
176
177 //! Write D&GTs assigned to specified labels, to STEP model
178 Standard_EXPORT Standard_Boolean WriteDGTs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
179
6595eee7 180 //! Write D&GTs assigned to specified labels, to STEP model, according AP242
1209c1b9 181 Standard_EXPORT Standard_Boolean WriteDGTsAP242 (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
6595eee7 182
42cf5bc1 183 //! Write materials assigned to specified labels, to STEP model
184 Standard_EXPORT Standard_Boolean WriteMaterials (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
185
186 //! Write validation properties assigned to specified labels,
187 //! to STEP model
188 Standard_EXPORT Standard_Boolean WriteValProps (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels, const Standard_CString multi) const;
189
190 //! Write layers assigned to specified labels, to STEP model
191 Standard_EXPORT Standard_Boolean WriteLayers (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
192
193 //! Write SHUO assigned to specified component, to STEP model
194 Standard_EXPORT Standard_Boolean WriteSHUOs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
195
f5e92b04 196
42cf5bc1 197
198private:
1209c1b9 199 Standard_EXPORT Handle(StepRepr_ShapeAspect) WriteShapeAspect(const Handle(XSControl_WorkSession) &WS,
200 const TDF_Label theLabel, const TopoDS_Shape theShape, Handle(StepRepr_RepresentationContext)& theRC,
201 Handle(StepAP242_GeometricItemSpecificUsage)& theGISU);
202
203 Standard_EXPORT void WritePresentation(const Handle(XSControl_WorkSession) &WS, const TopoDS_Shape thePresentation,
204 const Handle(TCollection_HAsciiString)& thePrsName, const Standard_Boolean hasSemantic, const Standard_Boolean hasPlane,
205 const gp_Ax2 theAnnotationPlane, const gp_Pnt theTextPosition, const Handle(Standard_Transient) theDimension);
206
207 Standard_EXPORT Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSession) &WS, const TDF_LabelSequence theShapeL,
208 const TDF_Label theDatumL, const Standard_Boolean isFirstDTarget, const Handle(StepDimTol_Datum) theWrittenDatum);
209
210 Standard_EXPORT void WriteToleranceZone(const Handle(XSControl_WorkSession) &WS, const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObject,
211 const Handle(StepDimTol_GeometricTolerance)& theEntity, const Handle(StepRepr_RepresentationContext)& theRC);
212
213 Standard_EXPORT void WriteGeomTolerance(const Handle(XSControl_WorkSession) &WS, const TDF_LabelSequence theShapeSeqL,
214 const TDF_Label theGeomTolL, const Handle(StepDimTol_HArray1OfDatumSystemOrReference)& theDatumSystem,
215 const Handle(StepRepr_RepresentationContext)& theRC);
42cf5bc1 216
217
218
219 STEPControl_Writer myWriter;
997e128f 220 NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
42cf5bc1 221 STEPCAFControl_DataMapOfLabelShape myLabels;
222 STEPCAFControl_DataMapOfLabelExternFile myLabEF;
223 Standard_Boolean myColorMode;
224 Standard_Boolean myNameMode;
225 Standard_Boolean myLayerMode;
226 Standard_Boolean myPropsMode;
227 Standard_Boolean mySHUOMode;
228 MoniTool_DataMapOfShapeTransient myMapCompMDGPR;
5b83cdb6 229 Standard_Boolean myGDTMode;
42cf5bc1 230 Standard_Boolean myMatMode;
1209c1b9 231 NCollection_Vector<Handle(StepRepr_RepresentationItem)> myGDTAnnotations;
232 Handle(StepVisual_DraughtingModel) myGDTPresentationDM;
233 Handle(StepVisual_HArray1OfPresentationStyleAssignment) myGDTPrsCurveStyle;
234 Handle(StepRepr_ProductDefinitionShape) myGDTCommonPDS;
42cf5bc1 235
236};
237
238
239
240
42cf5bc1 241#endif // _STEPCAFControl_Writer_HeaderFile