1 // Copyright (C) 2014-2016 OPEN CASCADE
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 email : webmaster.salome@opencascade.com
21 #include "ACISPlugin_ExportDriver.hxx"
22 #include "ACISPlugin_IExport.hxx"
25 #include <Basics_Utils.hxx>
26 #include <utilities.h>
29 #include <GEOM_Function.hxx>
32 #include <IFSelect_ReturnStatus.hxx>
33 #include <SatControl_Writer.hxx>
34 #include <TCollection_AsciiString.hxx>
35 #include <TopoDS_Shape.hxx>
36 #include <Standard_Version.hxx>
38 #ifdef ACIS_HASLICENSE
39 #include "ACISPlugin_license.h"
41 #include <OCCLicense_Activate.hxx>
42 #include <Standard_LicenseError.hxx>
43 #endif // ACIS_HASLICENSE
45 //=======================================================================
48 //=======================================================================
49 const Standard_GUID& ACISPlugin_ExportDriver::GetID()
51 static Standard_GUID aGUID("4a0b4b3f-e3c7-4a7a-91c3-1f004baa0813");
55 //=======================================================================
56 //function : ACISPlugin_ExportDriver
58 //=======================================================================
59 ACISPlugin_ExportDriver::ACISPlugin_ExportDriver()
63 //=======================================================================
66 //=======================================================================
67 Standard_Integer ACISPlugin_ExportDriver::Execute( Handle(TFunction_Logbook)& log ) const
69 #ifdef ACIS_HASLICENSE
71 OCCLicense_Activate("SAT-W-"OCC_VERSION_STRING, ACIS_WRITE_LICENSE);
73 catch (Standard_LicenseError) {
76 #endif // ACIS_HASLICENSE
78 if (Label().IsNull()) return 0;
79 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() );
81 ACISPlugin_IExport aData (aFunction);
83 // retrieve the being exported shape
85 Handle(GEOM_Function) aRefFunction = aData.GetOriginal();
86 if( aRefFunction.IsNull() ) return 0;
87 aShape = aRefFunction->GetValue();
88 if( aShape.IsNull() ) return 0;
89 // set the result of function to be used by next operations
90 aFunction->SetValue( aShape );
92 TCollection_AsciiString aFileName = aData.GetFileName();
94 MESSAGE("Export ACIS into file " << aFileName.ToCString());
96 // Set "C" numeric locale to save numbers correctly
97 Kernel_Utils::Localizer loc;
99 SatControl_Writer aWriter;
101 IFSelect_ReturnStatus status;
102 status = aWriter.TransferShape( aShape );
103 if ( status == IFSelect_RetDone )
104 status = aWriter.WriteFile( aFileName.ToCString() ) ;
105 if ( status == IFSelect_RetDone )
111 //================================================================================
113 * \brief Returns a name of creation operation and names and values of creation parameters
115 //================================================================================
116 bool ACISPlugin_ExportDriver::
117 GetCreationInformation( std::string& theOperationName,
118 std::vector<GEOM_Param>& theParams )
123 IMPLEMENT_STANDARD_RTTIEXT( ACISPlugin_ExportDriver,GEOM_BaseDriver );