File indexing completed on 2026-09-17 09:22:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _STEPCAFControl_Writer_HeaderFile
0017 #define _STEPCAFControl_Writer_HeaderFile
0018
0019 #include <TopoDS_Shape.hxx>
0020 #include <Standard_Transient.hxx>
0021 #include <TopTools_ShapeMapHasher.hxx>
0022 #include <NCollection_DataMap.hxx>
0023 #include <NCollection_DynamicArray.hxx>
0024 #include <Standard_DefineAlloc.hxx>
0025 #include <Standard_Handle.hxx>
0026 #include <TDF_Label.hxx>
0027 #include <STEPCAFControl_ExternFile.hxx>
0028 #include <STEPControl_Writer.hxx>
0029 #include <StepAP242_GeometricItemSpecificUsage.hxx>
0030 #include <DESTEP_Parameters.hxx>
0031 #include <StepData_Factors.hxx>
0032 #include <StepDimTol_Datum.hxx>
0033 #include <StepDimTol_GeometricTolerance.hxx>
0034 #include <StepDimTol_DatumSystemOrReference.hxx>
0035 #include <NCollection_Array1.hxx>
0036 #include <NCollection_HArray1.hxx>
0037 #include <StepRepr_ProductDefinitionShape.hxx>
0038 #include <StepVisual_DraughtingModel.hxx>
0039 #include <StepVisual_PresentationStyleAssignment.hxx>
0040 #include <NCollection_Sequence.hxx>
0041 #include <NCollection_Map.hxx>
0042 #include <XCAFDimTolObjects_GeomToleranceObject.hxx>
0043
0044 class XSControl_WorkSession;
0045 class TDocStd_Document;
0046 class STEPCAFControl_ExternFile;
0047 class TopoDS_Shape;
0048 class StepShape_ShapeDefinitionRepresentation;
0049
0050
0051
0052
0053
0054
0055
0056 class STEPCAFControl_Writer
0057 {
0058 public:
0059 DEFINE_STANDARD_ALLOC
0060
0061 public:
0062
0063
0064
0065 Standard_EXPORT STEPCAFControl_Writer();
0066
0067
0068
0069
0070 Standard_EXPORT STEPCAFControl_Writer(const occ::handle<XSControl_WorkSession>& theWS,
0071 const bool theScratch = true);
0072
0073
0074
0075 Standard_EXPORT void Init(const occ::handle<XSControl_WorkSession>& theWS,
0076 const bool theScratch = true);
0077
0078
0079
0080
0081
0082
0083 Standard_EXPORT IFSelect_ReturnStatus Write(const char* const theFileName);
0084
0085
0086
0087 Standard_EXPORT IFSelect_ReturnStatus WriteStream(std::ostream& theStream);
0088
0089
0090
0091
0092
0093
0094
0095 Standard_EXPORT bool Transfer(const occ::handle<TDocStd_Document>& theDoc,
0096 const STEPControl_StepModelType theMode = STEPControl_AsIs,
0097 const char* const theIsMulti = nullptr,
0098 const Message_ProgressRange& theProgress = Message_ProgressRange());
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 Standard_EXPORT bool Transfer(const occ::handle<TDocStd_Document>& theDoc,
0111 const DESTEP_Parameters& theParams,
0112 const STEPControl_StepModelType theMode = STEPControl_AsIs,
0113 const char* const theIsMulti = nullptr,
0114 const Message_ProgressRange& theProgress = Message_ProgressRange());
0115
0116
0117 Standard_EXPORT bool Transfer(const TDF_Label& theLabel,
0118 const STEPControl_StepModelType theMode = STEPControl_AsIs,
0119 const char* const theIsMulti = nullptr,
0120 const Message_ProgressRange& theProgress = Message_ProgressRange());
0121
0122
0123
0124
0125 Standard_EXPORT bool Transfer(const TDF_Label& theLabel,
0126 const DESTEP_Parameters& theParams,
0127 const STEPControl_StepModelType theMode = STEPControl_AsIs,
0128 const char* const theIsMulti = nullptr,
0129 const Message_ProgressRange& theProgress = Message_ProgressRange());
0130
0131
0132
0133 Standard_EXPORT bool Transfer(const NCollection_Sequence<TDF_Label>& theLabelSeq,
0134 const STEPControl_StepModelType theMode = STEPControl_AsIs,
0135 const char* const theIsMulti = nullptr,
0136 const Message_ProgressRange& theProgress = Message_ProgressRange());
0137
0138
0139
0140
0141
0142 Standard_EXPORT bool Transfer(const NCollection_Sequence<TDF_Label>& theLabelSeq,
0143 const DESTEP_Parameters& theParams,
0144 const STEPControl_StepModelType theMode = STEPControl_AsIs,
0145 const char* const theIsMulti = nullptr,
0146 const Message_ProgressRange& theProgress = Message_ProgressRange());
0147
0148 Standard_EXPORT bool Perform(const occ::handle<TDocStd_Document>& theDoc,
0149 const TCollection_AsciiString& theFileName,
0150 const Message_ProgressRange& theProgress = Message_ProgressRange());
0151
0152
0153
0154 Standard_EXPORT bool Perform(const occ::handle<TDocStd_Document>& theDoc,
0155 const char* const theFileName,
0156 const Message_ProgressRange& theProgress = Message_ProgressRange());
0157
0158
0159
0160
0161
0162 Standard_EXPORT bool Perform(const occ::handle<TDocStd_Document>& theDoc,
0163 const char* const theFileName,
0164 const DESTEP_Parameters& theParams,
0165 const Message_ProgressRange& theProgress = Message_ProgressRange());
0166
0167
0168
0169 const NCollection_DataMap<TCollection_AsciiString, occ::handle<STEPCAFControl_ExternFile>>&
0170 ExternFiles() const
0171 {
0172 return myFiles;
0173 };
0174
0175
0176
0177 Standard_EXPORT bool ExternFile(const TDF_Label& theLabel,
0178 occ::handle<STEPCAFControl_ExternFile>& theExtFile) const;
0179
0180
0181
0182 Standard_EXPORT bool ExternFile(const char* const theName,
0183 occ::handle<STEPCAFControl_ExternFile>& theExtFile) const;
0184
0185
0186 STEPControl_Writer& ChangeWriter() { return myWriter; }
0187
0188
0189 const STEPControl_Writer& Writer() const { return myWriter; }
0190
0191
0192 void SetColorMode(const bool theColorMode) { myColorMode = theColorMode; }
0193
0194 bool GetColorMode() const { return myColorMode; }
0195
0196
0197 void SetNameMode(const bool theNameMode) { myNameMode = theNameMode; }
0198
0199 bool GetNameMode() const { return myNameMode; }
0200
0201
0202 void SetLayerMode(const bool theLayerMode) { myLayerMode = theLayerMode; }
0203
0204 bool GetLayerMode() const { return myLayerMode; }
0205
0206
0207 void SetPropsMode(const bool thePropsMode) { myPropsMode = thePropsMode; }
0208
0209 bool GetPropsMode() const { return myPropsMode; }
0210
0211
0212 void SetMetadataMode(const bool theMetadataMode) { myMetadataMode = theMetadataMode; }
0213
0214 bool GetMetadataMode() const { return myMetadataMode; }
0215
0216
0217 void SetSHUOMode(const bool theSHUOMode) { mySHUOMode = theSHUOMode; }
0218
0219 bool GetSHUOMode() const { return mySHUOMode; }
0220
0221
0222 void SetDimTolMode(const bool theDimTolMode) { myGDTMode = theDimTolMode; };
0223
0224 bool GetDimTolMode() const { return myGDTMode; }
0225
0226
0227 void SetMaterialMode(const bool theMaterialMode) { myMatMode = theMaterialMode; }
0228
0229 bool GetMaterialMode() const { return myMatMode; }
0230
0231
0232 void SetVisualMaterialMode(const bool theVisualMaterialMode)
0233 {
0234 myVisMatMode = theVisualMaterialMode;
0235 }
0236
0237 bool GetVisualMaterialMode() const { return myVisMatMode; }
0238
0239
0240
0241
0242 void SetCleanDuplicates(const bool theCleanDuplicates)
0243 {
0244 myIsCleanDuplicates = theCleanDuplicates;
0245 }
0246
0247
0248
0249 bool GetCleanDuplicates() const { return myIsCleanDuplicates; }
0250
0251
0252
0253 Standard_EXPORT void SetShapeFixParameters(
0254 const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
0255
0256
0257
0258
0259 Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
0260
0261
0262
0263
0264
0265
0266
0267 Standard_EXPORT void SetShapeFixParameters(
0268 const DE_ShapeFixParameters& theParameters,
0269 const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
0270
0271
0272
0273 Standard_EXPORT const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const;
0274
0275
0276
0277 Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
0278
0279
0280
0281
0282 Standard_EXPORT const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const;
0283
0284 protected:
0285
0286
0287
0288 bool transfer(STEPControl_Writer& theWriter,
0289 const NCollection_Sequence<TDF_Label>& theLabels,
0290 const STEPControl_StepModelType theMode = STEPControl_AsIs,
0291 const char* const theIsMulti = nullptr,
0292 const bool isExternFile = false,
0293 const Message_ProgressRange& theProgress = Message_ProgressRange());
0294
0295
0296
0297
0298
0299
0300
0301 TopoDS_Shape transferExternFiles(
0302 const TDF_Label& theLabel,
0303 const STEPControl_StepModelType theMode,
0304 NCollection_Sequence<TDF_Label>& theLabelSeq,
0305 const StepData_Factors& theLocalFactors = StepData_Factors(),
0306 const char* const thePrefix = "",
0307 const Message_ProgressRange& theProgress = Message_ProgressRange());
0308
0309
0310 bool writeExternRefs(const occ::handle<XSControl_WorkSession>& theWS,
0311 const NCollection_Sequence<TDF_Label>& theLabels) const;
0312
0313
0314 bool writeColors(const occ::handle<XSControl_WorkSession>& theWS,
0315 const NCollection_Sequence<TDF_Label>& theLabels);
0316
0317
0318 bool writeNames(const occ::handle<XSControl_WorkSession>& theWS,
0319 const NCollection_Sequence<TDF_Label>& theLabels) const;
0320
0321
0322 bool writeMetadata(const occ::handle<XSControl_WorkSession>& theWS,
0323 const NCollection_Sequence<TDF_Label>& theLabels) const;
0324
0325
0326
0327 bool writeMetadataForLabel(const occ::handle<XSControl_WorkSession>& theWS,
0328 const TDF_Label& theLabel) const;
0329
0330
0331
0332
0333
0334
0335
0336 void writeMetadataRepresentationItem(
0337 const TCollection_AsciiString& theKey,
0338 const occ::handle<StepData_StepModel>& theModel,
0339 const occ::handle<StepShape_ShapeDefinitionRepresentation>& theShapeDefRep,
0340 const occ::handle<StepBasic_ProductDefinition>& theProdDef,
0341 const occ::handle<StepRepr_RepresentationItem>& theItem) const;
0342
0343
0344 bool writeDGTs(const occ::handle<XSControl_WorkSession>& theWS,
0345 const NCollection_Sequence<TDF_Label>& theLabels) const;
0346
0347
0348 bool writeDGTsAP242(const occ::handle<XSControl_WorkSession>& theWS,
0349 const NCollection_Sequence<TDF_Label>& theLabels,
0350 const StepData_Factors& theLocalFactors = StepData_Factors());
0351
0352
0353 bool writeMaterials(const occ::handle<XSControl_WorkSession>& theWS,
0354 const NCollection_Sequence<TDF_Label>& theLabels) const;
0355
0356
0357
0358 bool writeValProps(const occ::handle<XSControl_WorkSession>& theWS,
0359 const NCollection_Sequence<TDF_Label>& theLabels,
0360 const char* const theIsMulti) const;
0361
0362
0363 bool writeLayers(const occ::handle<XSControl_WorkSession>& theWS,
0364 const NCollection_Sequence<TDF_Label>& theLabels) const;
0365
0366
0367 bool writeSHUOs(const occ::handle<XSControl_WorkSession>& theWS,
0368 const NCollection_Sequence<TDF_Label>& theLabels);
0369
0370
0371
0372
0373 void prepareUnit(const TDF_Label& theLabel,
0374 const occ::handle<StepData_StepModel>& theModel,
0375 StepData_Factors& theLocalFactors);
0376
0377 occ::handle<StepRepr_ShapeAspect> writeShapeAspect(
0378 const occ::handle<XSControl_WorkSession>& theWS,
0379 const TDF_Label theLabel,
0380 const TopoDS_Shape& theShape,
0381 occ::handle<StepRepr_RepresentationContext>& theRC,
0382 occ::handle<StepAP242_GeometricItemSpecificUsage>& theGISU);
0383
0384 void writePresentation(const occ::handle<XSControl_WorkSession>& theWS,
0385 const TopoDS_Shape& thePresentation,
0386 const occ::handle<TCollection_HAsciiString>& thePrsName,
0387 const bool theHasSemantic,
0388 const bool theHasPlane,
0389 const gp_Ax2& theAnnotationPlane,
0390 const gp_Pnt& theTextPosition,
0391 const occ::handle<Standard_Transient>& theDimension,
0392 const StepData_Factors& theLocalFactors = StepData_Factors());
0393
0394 occ::handle<StepDimTol_Datum> writeDatumAP242(
0395 const occ::handle<XSControl_WorkSession>& theWS,
0396 const NCollection_Sequence<TDF_Label>& theShapeL,
0397 const TDF_Label& theDatumL,
0398 const bool isFirstDTarget,
0399 const occ::handle<StepDimTol_Datum>& theWrittenDatum,
0400 const StepData_Factors& theLocalFactors = StepData_Factors());
0401
0402 void writeToleranceZone(const occ::handle<XSControl_WorkSession>& theWS,
0403 const occ::handle<XCAFDimTolObjects_GeomToleranceObject>& theObject,
0404 const occ::handle<StepDimTol_GeometricTolerance>& theEntity,
0405 const occ::handle<StepRepr_RepresentationContext>& theRC);
0406
0407 void writeGeomTolerance(
0408 const occ::handle<XSControl_WorkSession>& theWS,
0409 const NCollection_Sequence<TDF_Label>& theShapeSeqL,
0410 const TDF_Label& theGeomTolL,
0411 const occ::handle<NCollection_HArray1<StepDimTol_DatumSystemOrReference>>& theDatumSystem,
0412 const occ::handle<StepRepr_RepresentationContext>& theRC,
0413 const StepData_Factors& theLocalFactors = StepData_Factors());
0414
0415 private:
0416 STEPControl_Writer myWriter;
0417 NCollection_DataMap<TCollection_AsciiString, occ::handle<STEPCAFControl_ExternFile>> myFiles;
0418 NCollection_Map<TDF_Label> myRootLabels;
0419 NCollection_DataMap<TDF_Label, TopoDS_Shape> myLabels;
0420 NCollection_DataMap<TDF_Label, occ::handle<STEPCAFControl_ExternFile>> myLabEF;
0421 NCollection_DataMap<TDF_Label, TopoDS_Shape> myPureRefLabels;
0422 bool myColorMode;
0423 bool myNameMode;
0424 bool myLayerMode;
0425 bool myPropsMode;
0426 bool myMetadataMode;
0427 bool mySHUOMode;
0428 NCollection_DataMap<TopoDS_Shape, occ::handle<Standard_Transient>, TopTools_ShapeMapHasher>
0429 myMapCompMDGPR;
0430 bool myGDTMode;
0431 bool myMatMode;
0432 bool myVisMatMode;
0433 bool myIsCleanDuplicates;
0434 NCollection_DynamicArray<occ::handle<StepRepr_RepresentationItem>> myGDTAnnotations;
0435 occ::handle<StepVisual_DraughtingModel> myGDTPresentationDM;
0436 occ::handle<NCollection_HArray1<occ::handle<StepVisual_PresentationStyleAssignment>>>
0437 myGDTPrsCurveStyle;
0438 occ::handle<StepRepr_ProductDefinitionShape> myGDTCommonPDS;
0439 };
0440
0441 #endif