Back to index

salome-geom  6.5.0
STEPExport.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:        STEPExport.cxx
00024 // Created:     Wed May 19 14:53:52 2004
00025 // Author:      Pavel TELKOV
00026 //              <ptv@mutex.nnov.opencascade.com>
00027 //
00028 #include "utilities.h"
00029 
00030 #include <Basics_Utils.hxx>
00031 
00032 #include <IFSelect_ReturnStatus.hxx>
00033 
00034 #include <STEPControl_Writer.hxx>
00035 #include <Interface_Static.hxx>
00036 
00037 #include <TCollection_AsciiString.hxx>
00038 #include <TopoDS_Shape.hxx>
00039 
00040 #ifdef WNT
00041  #if defined STEPEXPORT_EXPORTS || defined STEPExport_EXPORTS
00042   #if defined WIN32
00043    #define STEPEXPORT_EXPORT __declspec( dllexport )
00044   #else
00045    #define STEPEXPORT_EXPORT
00046   #endif
00047  #else
00048   #if defined WIN32
00049    #define STEPEXPORT_EXPORT __declspec( dllimport )
00050   #else
00051    #define STEPEXPORT_EXPORT
00052   #endif
00053  #endif
00054 #else
00055  #define STEPEXPORT_EXPORT
00056 #endif
00057 
00058 //=============================================================================
00062 //=============================================================================
00063 
00064 extern "C"
00065 {
00066 STEPEXPORT_EXPORT
00067   int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName)
00068   {
00069     MESSAGE("Export STEP into file " << theFileName.ToCString());
00070 
00071   try 
00072     {
00073       // Set "C" numeric locale to save numbers correctly
00074       Kernel_Utils::Localizer loc;
00075 
00076       IFSelect_ReturnStatus status ;
00077       //VRV: OCC 4.0 migration
00078       STEPControl_Writer aWriter;
00079       //VSR: 16/09/09: Convert to METERS
00080       Interface_Static::SetCVal("xstep.cascade.unit","M");
00081       Interface_Static::SetIVal("write.step.nonmanifold", 1);
00082 //JFA: PAL6162      status = aWriter.Transfer( theShape, STEPControl_ManifoldSolidBrep );
00083       status = aWriter.Transfer( theShape, STEPControl_AsIs );
00084       //VRV: OCC 4.0 migration
00085       if ( status == IFSelect_RetDone ) 
00086           status = aWriter.Write( theFileName.ToCString() );
00087 
00088       // Return previous locale
00089       if ( status == IFSelect_RetDone ) 
00090         return 1;
00091     }
00092   catch(Standard_Failure) 
00093     {
00094       //THROW_SALOME_CORBA_EXCEPTION("Exception catched in STEPExport", SALOME::BAD_PARAM);
00095     }
00096   return 0;
00097   }
00098 }