1 // Created on: 2000-08-15
2 // Created by: Andrey BETENEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _STEPCAFControl_Writer_HeaderFile
17 #define _STEPCAFControl_Writer_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
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>
32 #include <StepAP242_GeometricItemSpecificUsage.hxx>
33 #include <StepDimTol_Datum.hxx>
34 #include <StepDimTol_GeometricTolerance.hxx>
35 #include <StepDimTol_HArray1OfDatumSystemOrReference.hxx>
36 #include <StepRepr_ProductDefinitionShape.hxx>
37 #include <StepVisual_DraughtingModel.hxx>
38 #include <StepVisual_HArray1OfPresentationStyleAssignment.hxx>
39 #include <XCAFDimTolObjects_GeomToleranceObject.hxx>
41 class XSControl_WorkSession;
42 class TDocStd_Document;
44 class TCollection_AsciiString;
45 class STEPCAFControl_ExternFile;
46 class STEPControl_Writer;
49 //! Provides a tool to write DECAF document to the
50 //! STEP file. Besides transfer of shapes (including
51 //! assemblies) provided by STEPControl, supports also
52 //! colors and part names
54 //! Also supports multifile writing
55 class STEPCAFControl_Writer
62 //! Creates a writer with an empty
63 //! STEP model and sets ColorMode, LayerMode, NameMode and
64 //! PropsMode to Standard_True.
65 Standard_EXPORT STEPCAFControl_Writer();
67 //! Creates a reader tool and attaches it to an already existing Session
68 //! Clears the session if it was not yet set for STEP
69 //! Clears the internal data structures
70 Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
72 //! Clears the internal data structures and attaches to a new session
73 //! Clears the session if it was not yet set for STEP
74 Standard_EXPORT void Init (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
76 //! Writes all the produced models into file
77 //! In case of multimodel with extern references,
78 //! filename will be a name of root file, all other files
79 //! have names of corresponding parts
80 //! Provided for use like single-file writer
81 Standard_EXPORT IFSelect_ReturnStatus Write (const Standard_CString filename);
83 //! Transfers a document (or single label) to a STEP model
84 //! The mode of translation of shape is AsIs
85 //! If multi is not null pointer, it switches to multifile
86 //! mode (with external refs), and string pointed by <multi>
87 //! gives prefix for names of extern files (can be empty string)
88 //! Returns True if translation is OK
89 Standard_EXPORT Standard_Boolean Transfer (const Handle(TDocStd_Document)& doc, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
91 //! Method to transfer part of the document specified by label
92 Standard_EXPORT Standard_Boolean Transfer (const TDF_Label& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0 );
94 Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc, const TCollection_AsciiString& filename);
96 //! Transfers a document and writes it to a STEP file
97 //! Returns True if translation is OK
98 Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc, const Standard_CString filename);
100 //! Returns data on external files
101 //! Returns Null handle if no external files are read
102 Standard_EXPORT const NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& ExternFiles() const;
104 //! Returns data on external file by its original label
105 //! Returns False if no external file with given name is read
106 Standard_EXPORT Standard_Boolean ExternFile (const TDF_Label& L, Handle(STEPCAFControl_ExternFile)& ef) const;
108 //! Returns data on external file by its name
109 //! Returns False if no external file with given name is read
110 Standard_EXPORT Standard_Boolean ExternFile (const Standard_CString name, Handle(STEPCAFControl_ExternFile)& ef) const;
112 //! Returns basic reader for root file
113 Standard_EXPORT STEPControl_Writer& ChangeWriter();
115 //! Returns basic reader as const
116 Standard_EXPORT const STEPControl_Writer& Writer() const;
118 //! Set ColorMode for indicate write Colors or not.
119 Standard_EXPORT void SetColorMode (const Standard_Boolean colormode);
121 Standard_EXPORT Standard_Boolean GetColorMode() const;
123 //! Set NameMode for indicate write Name or not.
124 Standard_EXPORT void SetNameMode (const Standard_Boolean namemode);
126 Standard_EXPORT Standard_Boolean GetNameMode() const;
128 //! Set LayerMode for indicate write Layers or not.
129 Standard_EXPORT void SetLayerMode (const Standard_Boolean layermode);
131 Standard_EXPORT Standard_Boolean GetLayerMode() const;
133 //! PropsMode for indicate write Validation properties or not.
134 Standard_EXPORT void SetPropsMode (const Standard_Boolean propsmode);
136 Standard_EXPORT Standard_Boolean GetPropsMode() const;
138 //! Set SHUO mode for indicate write SHUO or not.
139 Standard_EXPORT void SetSHUOMode (const Standard_Boolean shuomode);
141 Standard_EXPORT Standard_Boolean GetSHUOMode() const;
143 //! Set dimtolmode for indicate write D>s or not.
144 Standard_EXPORT void SetDimTolMode (const Standard_Boolean dimtolmode);
146 Standard_EXPORT Standard_Boolean GetDimTolMode() const;
148 //! Set dimtolmode for indicate write D>s or not.
149 Standard_EXPORT void SetMaterialMode (const Standard_Boolean matmode);
151 Standard_EXPORT Standard_Boolean GetMaterialMode() const;
157 //! Mehod to writing sequence of root assemblies or part of the file specified by use by one label
158 Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
160 //! Transfers labels to a STEP model
161 //! Returns True if translation is OK
162 //! isExternFile setting from TransferExternFiles method
163 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) ;
165 //! Parses assembly structure of label L, writes all the simple
166 //! shapes each to its own file named by name of its label plus
168 //! Returns shape representing that assembly structure
169 //! in the form of nested empty compounds (and a sequence of
170 //! labels which are newly written nodes of this assembly)
171 Standard_EXPORT TopoDS_Shape TransferExternFiles (const TDF_Label& L, const STEPControl_StepModelType mode, TDF_LabelSequence& Lseq, const Standard_CString prefix = "");
173 //! Write external references to STEP
174 Standard_EXPORT Standard_Boolean WriteExternRefs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
176 //! Write colors assigned to specified labels, to STEP model
177 Standard_EXPORT Standard_Boolean WriteColors (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
179 //! Write names assigned to specified labels, to STEP model
180 Standard_EXPORT Standard_Boolean WriteNames (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
182 //! Write D>s assigned to specified labels, to STEP model
183 Standard_EXPORT Standard_Boolean WriteDGTs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
185 //! Write D>s assigned to specified labels, to STEP model, according AP242
186 Standard_EXPORT Standard_Boolean WriteDGTsAP242 (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
188 //! Write materials assigned to specified labels, to STEP model
189 Standard_EXPORT Standard_Boolean WriteMaterials (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
191 //! Write validation properties assigned to specified labels,
193 Standard_EXPORT Standard_Boolean WriteValProps (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels, const Standard_CString multi) const;
195 //! Write layers assigned to specified labels, to STEP model
196 Standard_EXPORT Standard_Boolean WriteLayers (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
198 //! Write SHUO assigned to specified component, to STEP model
199 Standard_EXPORT Standard_Boolean WriteSHUOs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
204 Standard_EXPORT Handle(StepRepr_ShapeAspect) WriteShapeAspect(const Handle(XSControl_WorkSession) &WS,
205 const TDF_Label theLabel, const TopoDS_Shape theShape, Handle(StepRepr_RepresentationContext)& theRC,
206 Handle(StepAP242_GeometricItemSpecificUsage)& theGISU);
208 Standard_EXPORT void WritePresentation(const Handle(XSControl_WorkSession) &WS, const TopoDS_Shape thePresentation,
209 const Handle(TCollection_HAsciiString)& thePrsName, const Standard_Boolean hasSemantic, const Standard_Boolean hasPlane,
210 const gp_Ax2 theAnnotationPlane, const gp_Pnt theTextPosition, const Handle(Standard_Transient) theDimension);
212 Standard_EXPORT Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSession) &WS, const TDF_LabelSequence theShapeL,
213 const TDF_Label theDatumL, const Standard_Boolean isFirstDTarget, const Handle(StepDimTol_Datum) theWrittenDatum);
215 Standard_EXPORT void WriteToleranceZone(const Handle(XSControl_WorkSession) &WS, const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObject,
216 const Handle(StepDimTol_GeometricTolerance)& theEntity, const Handle(StepRepr_RepresentationContext)& theRC);
218 Standard_EXPORT void WriteGeomTolerance(const Handle(XSControl_WorkSession) &WS, const TDF_LabelSequence theShapeSeqL,
219 const TDF_Label theGeomTolL, const Handle(StepDimTol_HArray1OfDatumSystemOrReference)& theDatumSystem,
220 const Handle(StepRepr_RepresentationContext)& theRC);
224 STEPControl_Writer myWriter;
225 NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
226 STEPCAFControl_DataMapOfLabelShape myLabels;
227 STEPCAFControl_DataMapOfLabelExternFile myLabEF;
228 Standard_Boolean myColorMode;
229 Standard_Boolean myNameMode;
230 Standard_Boolean myLayerMode;
231 Standard_Boolean myPropsMode;
232 Standard_Boolean mySHUOMode;
233 MoniTool_DataMapOfShapeTransient myMapCompMDGPR;
234 Standard_Boolean myDGTMode;
235 Standard_Boolean myMatMode;
236 NCollection_Vector<Handle(StepRepr_RepresentationItem)> myGDTAnnotations;
237 Handle(StepVisual_DraughtingModel) myGDTPresentationDM;
238 Handle(StepVisual_HArray1OfPresentationStyleAssignment) myGDTPrsCurveStyle;
239 Handle(StepRepr_ProductDefinitionShape) myGDTCommonPDS;
246 #endif // _STEPCAFControl_Writer_HeaderFile