1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include <GeomAlgoAPI_STEPExport.h>
23 #include "GeomAlgoAPI_Tools.h"
25 #include <TopoDS_Shape.hxx>
28 #include <IFSelect_ReturnStatus.hxx>
29 #include <STEPControl_Writer.hxx>
30 #include <Interface_Static.hxx>
32 bool STEPExport(const std::string& theFileName,
33 const std::string& theFormatName,
34 const std::shared_ptr<GeomAPI_Shape>& theShape,
35 std::string& theError)
38 std::cout << "Export STEP into file " << theFileName << std::endl;
41 if (!theShape.get()) {
42 theError = "STEP Export failed: An invalid argument";
48 // Set "C" numeric locale to save numbers correctly
49 GeomAlgoAPI_Tools::Localizer loc;
51 IFSelect_ReturnStatus status ;
52 //VRV: OCC 4.0 migration
53 STEPControl_Writer aWriter;
54 Interface_Static::SetCVal("xstep.cascade.unit","M");
55 Interface_Static::SetCVal("write.step.unit", "M");
56 Interface_Static::SetIVal("write.step.nonmanifold", 1);
57 status = aWriter.Transfer(theShape->impl<TopoDS_Shape>(), STEPControl_AsIs);
58 //VRV: OCC 4.0 migration
59 if( status == IFSelect_RetDone )
60 status = aWriter.Write(theFileName.c_str());
62 // Return previous locale
63 if( status == IFSelect_RetDone )
66 catch (Standard_Failure)
68 theError = "Exception catched in STEPExport";