Salome HOME
2 servant implementations of GEOM::GEOM_GEN. One with Study and ModuleCatalog retrive...
[modules/geom.git] / src / STEPPlugin / STEPPlugin_IOperations_i.cc
index 1f4ded47ae05c4d0d7e1102f380075d80f678777..480e42c14a7a4c59baa32b984be7d1f820856d77 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -53,10 +53,12 @@ STEPPlugin_IOperations_i::~STEPPlugin_IOperations_i()
  *  Export a shape to STEP format
  *  \param theOriginal The shape to export
  *  \param theFileName The name of the exported file
+ *  \param theUnit the length unit.
  */
 //=============================================================================
-void STEPPlugin_IOperations_i::ExportSTEP( GEOM::GEOM_Object_ptr theOriginal,
-                                          const char*           theFileName )
+void STEPPlugin_IOperations_i::ExportSTEP(GEOM::GEOM_Object_ptr theOriginal,
+                                          const char*           theFileName,
+                                          GEOM::length_unit     theUnit)
 {
   // duplicate the original shape
   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate( theOriginal );
@@ -68,8 +70,45 @@ void STEPPlugin_IOperations_i::ExportSTEP( GEOM::GEOM_Object_ptr theOriginal,
   Handle(GEOM_Object) anOriginal = GetObjectImpl( theOriginal );
   if (anOriginal.IsNull()) return;
 
+  STEPPlugin_IOperations::LengthUnit aUnit;
+
+  switch (theUnit) {
+  case GEOM::LU_INCH:
+    aUnit = STEPPlugin_IOperations::LengthUnit_Inch;
+    break;
+  case GEOM::LU_MILLIMETER:
+    aUnit = STEPPlugin_IOperations::LengthUnit_Millimeter;
+    break;
+  case GEOM::LU_FOOT:
+    aUnit = STEPPlugin_IOperations::LengthUnit_Foot;
+    break;
+  case GEOM::LU_MILE:
+    aUnit = STEPPlugin_IOperations::LengthUnit_Mile;
+    break;
+  case GEOM::LU_METER:
+    aUnit = STEPPlugin_IOperations::LengthUnit_Meter;
+    break;
+  case GEOM::LU_KILOMETER:
+    aUnit = STEPPlugin_IOperations::LengthUnit_Kilometer;
+    break;
+  case GEOM::LU_MILLIINCH:
+    aUnit = STEPPlugin_IOperations::LengthUnit_Milliinch;
+    break;
+  case GEOM::LU_MICROMETER:
+    aUnit = STEPPlugin_IOperations::LengthUnit_Micrometer;
+    break;
+  case GEOM::LU_CENTIMETER:
+    aUnit = STEPPlugin_IOperations::LengthUnit_Centimeter;
+    break;
+  case GEOM::LU_MICROINCH:
+    aUnit = STEPPlugin_IOperations::LengthUnit_Microinch;
+    break;
+  default:
+    return;
+  }
+
   //Export the shape to the file
-  GetOperations()->ExportSTEP( anOriginal, theFileName );
+  GetOperations()->ExportSTEP( anOriginal, theFileName, aUnit );
 }
 
 //=============================================================================
@@ -80,11 +119,16 @@ void STEPPlugin_IOperations_i::ExportSTEP( GEOM::GEOM_Object_ptr theOriginal,
  *  \param theIsIgnoreUnits If True, file length units will be ignored (set to 'meter')
  *                          and result model will be scaled, if its units are not meters.
  *                          If False (default), file length units will be taken into account.
+ *  \param IsCreateAssemblies If True, for each assembly compound is created
+ *                          in the result. If False Compounds that contain a
+ *                          single shape are eliminated from the result.
  *  \return List of GEOM_Objects, containing the created shape and propagation groups.
  */
 //=============================================================================
-GEOM::ListOfGO* STEPPlugin_IOperations_i::ImportSTEP( const char* theFileName,
-                                                     const bool  theIsIgnoreUnits = false )
+GEOM::ListOfGO* STEPPlugin_IOperations_i::ImportSTEP
+                          (const char *theFileName,
+                           const bool  theIsIgnoreUnits,
+                           const bool  IsCreateAssemblies)
 {
   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
 
@@ -92,7 +136,8 @@ GEOM::ListOfGO* STEPPlugin_IOperations_i::ImportSTEP( const char* theFileName,
   GetOperations()->SetNotDone();
 
   //Import the shape from the file
-  Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportSTEP( theFileName, theIsIgnoreUnits );
+  Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportSTEP
+    (theFileName, theIsIgnoreUnits, IsCreateAssemblies);
 
   if( !GetOperations()->IsDone() || aHSeq.IsNull() )
     return aSeq._retn();