X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSTEPPlugin%2FSTEPPlugin_ExportDriver.cxx;h=fa7492ea1a13dcea85cadcf5802f3c4227e3779c;hb=HEAD;hp=8f5f0db18ca296283bd5fe79cb4015af3fcb97df;hpb=ff7fc4d6c2f5e6de741fd7f0b9ebf01de04d0e10;p=modules%2Fgeom.git diff --git a/src/STEPPlugin/STEPPlugin_ExportDriver.cxx b/src/STEPPlugin/STEPPlugin_ExportDriver.cxx index 8f5f0db18..fa7492ea1 100644 --- a/src/STEPPlugin/STEPPlugin_ExportDriver.cxx +++ b/src/STEPPlugin/STEPPlugin_ExportDriver.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2014-2024 CEA, EDF, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -20,10 +20,12 @@ // internal includes #include "STEPPlugin_ExportDriver.hxx" #include "STEPPlugin_IExport.hxx" +#include "STEPPlugin_IOperations.hxx" // KERNEL includes #include #include +#include // GEOM includes #include "GEOM_Function.hxx" @@ -31,6 +33,8 @@ // OOCT includes #include #include +#include +#include #include #include #include @@ -57,7 +61,7 @@ STEPPlugin_ExportDriver::STEPPlugin_ExportDriver() //function : Execute //purpose : //======================================================================= -Standard_Integer STEPPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const +Standard_Integer STEPPlugin_ExportDriver::Execute(Handle(TFunction_Logbook)& /*log*/) const { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); @@ -74,6 +78,43 @@ Standard_Integer STEPPlugin_ExportDriver::Execute( TFunction_Logbook& log ) cons aFunction->SetValue( aShape ); TCollection_AsciiString aFileName = aData.GetFileName(); + Standard_Integer anUnit = aData.GetUnit(); + TCollection_AsciiString aWriteUnit; + + switch (anUnit) { + case STEPPlugin_IOperations::LengthUnit_Inch: + aWriteUnit = "INCH"; + break; + case STEPPlugin_IOperations::LengthUnit_Millimeter: + aWriteUnit = "MM"; + break; + case STEPPlugin_IOperations::LengthUnit_Foot: + aWriteUnit = "FT"; + break; + case STEPPlugin_IOperations::LengthUnit_Mile: + aWriteUnit = "MI"; + break; + case STEPPlugin_IOperations::LengthUnit_Meter: + aWriteUnit = "M"; + break; + case STEPPlugin_IOperations::LengthUnit_Kilometer: + aWriteUnit = "KM"; + break; + case STEPPlugin_IOperations::LengthUnit_Milliinch: + aWriteUnit = "MIL"; + break; + case STEPPlugin_IOperations::LengthUnit_Micrometer: + aWriteUnit = "UM"; + break; + case STEPPlugin_IOperations::LengthUnit_Centimeter: + aWriteUnit = "CM"; + break; + case STEPPlugin_IOperations::LengthUnit_Microinch: + aWriteUnit = "UIN"; + break; + default: + return 0; + } MESSAGE("Export STEP into file " << aFileName.ToCString()); @@ -82,14 +123,30 @@ Standard_Integer STEPPlugin_ExportDriver::Execute( TFunction_Logbook& log ) cons // Set "C" numeric locale to save numbers correctly Kernel_Utils::Localizer loc; - IFSelect_ReturnStatus status ; - //VRV: OCC 4.0 migration +#if OCC_VERSION_LARGE < 0x07070000 + STEPControl_Writer aWriter; + Interface_Static::SetCVal("xstep.cascade.unit","M"); + Interface_Static::SetCVal("write.step.unit", aWriteUnit.ToCString()); + Interface_Static::SetIVal("write.step.nonmanifold", 1); +#elif OCC_VERSION_LARGE < 0x07080000 + STEPControl_Writer aWriterTmp; + Interface_Static::SetCVal("xstep.cascade.unit","M"); + Interface_Static::SetCVal("write.step.unit", aWriteUnit.ToCString()); + Interface_Static::SetIVal("write.step.nonmanifold", 1); + STEPControl_Writer aWriter; +#else STEPControl_Writer aWriter; Interface_Static::SetCVal("xstep.cascade.unit","M"); - Interface_Static::SetCVal("write.step.unit", "M"); + Interface_Static::SetCVal("write.step.unit", aWriteUnit.ToCString()); Interface_Static::SetIVal("write.step.nonmanifold", 1); - status = aWriter.Transfer( aShape, STEPControl_AsIs ); - //VRV: OCC 4.0 migration + Handle(StepData_StepModel) aModel = aWriter.Model(); + aModel->InternalParameters.InitFromStatic(); + Standard_Integer aWriteUnitInt = Interface_Static::IVal("write.step.unit"); + Standard_Real aWriteUnitReal = UnitsMethods::GetLengthFactorValue(aWriteUnitInt); + aModel->SetWriteLengthUnit(aWriteUnitReal); +#endif + + IFSelect_ReturnStatus status = aWriter.Transfer( aShape, STEPControl_AsIs ); if( status == IFSelect_RetDone ) status = aWriter.Write( aFileName.ToCString() ); @@ -97,33 +154,23 @@ Standard_Integer STEPPlugin_ExportDriver::Execute( TFunction_Logbook& log ) cons if( status == IFSelect_RetDone ) return 1; } - catch (Standard_Failure) + catch (Standard_Failure&) { - //THROW_SALOME_CORBA_EXCEPTION("Exception catched in STEPExport", SALOME::BAD_PARAM); + //THROW_SALOME_CORBA_EXCEPTION("Exception caught in STEPExport", SALOME::BAD_PARAM); } return 0; } -//======================================================================= -//function : MustExecute -//purpose : -//======================================================================= -Standard_Boolean STEPPlugin_ExportDriver::MustExecute( const TFunction_Logbook& ) const -{ - return Standard_True; -} - //================================================================================ /*! * \brief Returns a name of creation operation and names and values of creation parameters */ //================================================================================ bool STEPPlugin_ExportDriver:: -GetCreationInformation( std::string& theOperationName, - std::vector& theParams ) +GetCreationInformation( std::string& /*theOperationName*/, + std::vector& /*theParams*/ ) { return false; } -IMPLEMENT_STANDARD_HANDLE( STEPPlugin_ExportDriver,GEOM_BaseDriver ); -IMPLEMENT_STANDARD_RTTIEXT( STEPPlugin_ExportDriver,GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( STEPPlugin_ExportDriver,GEOM_BaseDriver )