Salome HOME
Porting Salome to OCCT 7.7.0
authorjfa <jfa@opencascade.com>
Thu, 9 Mar 2023 14:33:04 +0000 (14:33 +0000)
committerjfa <jfa@opencascade.com>
Thu, 9 Mar 2023 14:33:04 +0000 (14:33 +0000)
src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp

index 38ecc3fe24cd76dbeb4bf854739fe69ae5dd77c9..7cc6a022ffc9fe4c03b897644744a0c3c093cdac 100644 (file)
 
 #include "GeomAlgoAPI_Tools.h"
 
+#include <Basics_OCCTVersion.hxx>
+
 // OOCT includes
 #include <IGESControl_Controller.hxx>
 #include <IGESControl_Writer.hxx>
+#include <IGESData_IGESModel.hxx>
 #include <Interface_Static.hxx>
 
+#include <XSAlgo.hxx>
+#include <XSAlgo_AlgoContainer.hxx>
+
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Iterator.hxx>
 
+#include <UnitsMethods.hxx>
+
 //=============================================================================
 /*!
  *
@@ -140,6 +148,13 @@ bool IGESExport(const std::string& theFileName,
   IGESControl_Writer ICW( "M", aBrepMode ); // export explicitly in meters
   Interface_Static::SetCVal( "xstep.cascade.unit", "M" );
 
+#if OCC_VERSION_LARGE >= 0x07070000
+  Interface_Static::SetCVal("write.iges.unit", "M");
+  XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+  Standard_Real aScaleFactorMM = UnitsMethods::GetCasCadeLengthUnit();
+  ICW.Model()->ChangeGlobalSection().SetCascadeUnit(aScaleFactorMM);
+#endif
+
   // 09.03.2010 skl for bug 0020726
   // change default value "Average" to "Max"
   Interface_Static::SetCVal( "write.precision.mode", "Max" );
index 224840ec50b989f833cfc5dadecd8ac266c5fd1e..9f8370c284561a329bcc06fcc4c02ee564ff03d3 100644 (file)
@@ -34,6 +34,8 @@
 #include <Interface_Static.hxx>
 #include <Quantity_Color.hxx>
 
+#include <Basics_OCCTVersion.hxx>
+
 // a structure to manage step document exported attributes
 struct GeomAlgoAPI_STEPAttributes {
   bool myHasColor; ///< true if color is defined
@@ -145,10 +147,19 @@ bool STEPExport(const std::string& theFileName,
   // store the XCAF document to STEP file
   try {
     GeomAlgoAPI_Tools::Localizer aLocalizer; // Set "C" numeric locale to save numbers correctly
+
+#if OCC_VERSION_LARGE < 0x07070000
     STEPCAFControl_Writer aWriter;
     Interface_Static::SetCVal("xstep.cascade.unit", "M");
     Interface_Static::SetIVal("write.step.nonmanifold", 0); // 1 don't allow to export assemly tree
     Interface_Static::SetCVal("write.step.unit", "M");
+#else
+    STEPCAFControl_Writer aWriterTmp;
+    Interface_Static::SetCVal("xstep.cascade.unit", "M");
+    Interface_Static::SetIVal("write.step.nonmanifold", 0); // 1 don't allow to export assemly tree
+    Interface_Static::SetCVal("write.step.unit", "M");
+    STEPCAFControl_Writer aWriter;
+#endif
 
     auto aStatus = aWriter.Transfer(aDoc, STEPControl_AsIs);
     if (aStatus == IFSelect_RetDone)
@@ -156,7 +167,7 @@ bool STEPExport(const std::string& theFileName,
     if (aStatus != IFSelect_RetDone)
       theError = "STEP Export failed";
   }
-  catch (Standard_Failure exception) {
+  catch (Standard_Failure&) {
     theError = "Exception catched in STEPExport";
   }
   return theError.empty();