Salome HOME
203122417ff473a4cdd222ae907d16c8c9c15c2c
[modules/geom.git] / src / BREPPlugin / BREPPlugin_ExportDriver.cxx
1 // Copyright (C) 2014-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // internal includes
21 #include "BREPPlugin_ExportDriver.hxx"
22 #include "BREPPlugin_IExport.hxx"
23
24 // KERNEL includes
25 #include <utilities.h>
26 #include <Basics_Utils.hxx>
27
28 // GEOM includes
29 #include "GEOM_Function.hxx"
30
31 // OOCT includes
32 #include <BRepTools.hxx>
33 #include <TopoDS_Shape.hxx>
34
35 //=======================================================================
36 //function : GetID
37 //purpose  :
38 //=======================================================================
39 const Standard_GUID& BREPPlugin_ExportDriver::GetID()
40 {
41   static Standard_GUID aGUID("4c1fd92e-bcf3-4695-89b7-a8353038174f");
42   return aGUID;
43 }
44
45 //=======================================================================
46 //function : BREPPlugin_ExportDriver
47 //purpose  :
48 //=======================================================================
49 BREPPlugin_ExportDriver::BREPPlugin_ExportDriver()
50 {
51 }
52
53 //=======================================================================
54 //function : Execute
55 //purpose  :
56 //=======================================================================
57 Standard_Integer BREPPlugin_ExportDriver::Execute(Handle(TFunction_Logbook)& /*log*/) const
58 {
59   if (Label().IsNull()) return 0;
60   Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() );
61
62   BREPPlugin_IExport aData (aFunction);
63
64   // retrieve the being exported shape
65   TopoDS_Shape aShape;
66   Handle(GEOM_Function) aRefFunction = aData.GetOriginal();
67   if( aRefFunction.IsNull() ) return 0;
68   aShape = aRefFunction->GetValue();
69   if( aShape.IsNull() ) return 0;
70   // set the result of function to be used by next operations
71   aFunction->SetValue( aShape );
72
73   TCollection_AsciiString aFileName = aData.GetFileName();
74
75   MESSAGE("Export BREP into file " << aFileName.ToCString());
76
77   // Set "C" numeric locale to save numbers correctly
78   Kernel_Utils::Localizer loc;
79
80   if ( !BRepTools::Write( aShape, aFileName.ToCString() ) )
81     return 0;
82
83   return 1;
84 }
85
86 //================================================================================
87 /*!
88  * \brief Returns a name of creation operation and names and values of creation parameters
89  */
90 //================================================================================
91 bool BREPPlugin_ExportDriver::
92 GetCreationInformation( std::string&             /*theOperationName*/,
93                         std::vector<GEOM_Param>& /*theParams*/ )
94 {
95   return false;
96 }
97
98 IMPLEMENT_STANDARD_RTTIEXT( BREPPlugin_ExportDriver,GEOM_BaseDriver )