-// Copyright (C) 2014 OPEN CASCADE
+// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <ACISPLUGIN_exports.h>
-#include <ACISPLUGIN_version.h>
+// internal includes
+#include "ACISPlugin_ExportDriver.hxx"
+#include "ACISPlugin_IExport.hxx"
+#include "ACISPlugin_Engine.hxx"
+// KERNEL includes
#include <Basics_Utils.hxx>
+#include <utilities.h>
+// GEOM includes
+#include <GEOM_Function.hxx>
+
+// OOCT includes
#include <IFSelect_ReturnStatus.hxx>
#include <SatControl_Writer.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Shape.hxx>
#ifdef ACIS_HASLICENSE
-#include <ACISPLUGIN_license.h>
+#include "ACISPlugin_license.h"
#include <OCCLicense_Activate.hxx>
#include <Standard_LicenseError.hxx>
#endif // ACIS_HASLICENSE
-extern "C"
+//=======================================================================
+//function : GetID
+//purpose :
+//=======================================================================
+const Standard_GUID& ACISPlugin_ExportDriver::GetID()
+{
+ static Standard_GUID aGUID("4a0b4b3f-e3c7-4a7a-91c3-1f004baa0813");
+ return aGUID;
+}
+
+//=======================================================================
+//function : ACISPlugin_ExportDriver
+//purpose :
+//=======================================================================
+ACISPlugin_ExportDriver::ACISPlugin_ExportDriver()
+{
+}
+
+//=======================================================================
+//function : Execute
+//purpose :
+//=======================================================================
+Standard_Integer ACISPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const
{
- /*!
- \brief Get version of the plugin.
- \return the version of the plugin
- */
- ACISPLUGIN_EXPORT
- int GetVersion()
- {
- return ACISPLUGIN_VERSION;
- }
-
- /*!
- \brief Get version of the plugin.
- \return the string representation of the plugin's version
- */
- ACISPLUGIN_EXPORT
- char* GetVersionStr()
- {
- return (char*)ACISPLUGIN_VERSION_STR;
- }
-
- /*!
- \brief Export shape to the ACIS format.
- \param theShape shape being exported
- \param theFileName file path
- \param theFormatName file format signature
- \return error status (0 in case of success)
- */
- ACISPLUGIN_EXPORT
- int Export(const TopoDS_Shape& theShape,
- const TCollection_AsciiString& theFileName,
- const TCollection_AsciiString& theFormatName)
- {
#ifdef ACIS_HASLICENSE
try {
OCCLicense_Activate("SAT-W-"OCC_VERSION_STRING, ACIS_WRITE_LICENSE);
return 1;
}
#endif // ACIS_HASLICENSE
-
- // Set "C" numeric locale to save numbers correctly
- Kernel_Utils::Localizer loc;
-
- SatControl_Writer aWriter;
-
- try {
- IFSelect_ReturnStatus status ;
- status = aWriter.TransferShape(theShape);
- if ( status == IFSelect_RetDone )
- status = aWriter.WriteFile( theFileName.ToCString() ) ;
- if ( status == IFSelect_RetDone )
- return 1;
- }
- catch(Standard_Failure) {
- return 1;
- }
+
+ if (Label().IsNull()) return 0;
+ Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() );
+
+ ACISPlugin_IExport aData (aFunction);
+
+ // retrieve the being exported shape
+ TopoDS_Shape aShape;
+ Handle(GEOM_Function) aRefFunction = aData.GetOriginal();
+ if( aRefFunction.IsNull() ) return 0;
+ aShape = aRefFunction->GetValue();
+ if( aShape.IsNull() ) return 0;
+ // set the result of function to be used by next operations
+ aFunction->SetValue( aShape );
+
+ TCollection_AsciiString aFileName = aData.GetFileName();
+
+ MESSAGE("Export ACIS into file " << aFileName.ToCString());
+
+ // Set "C" numeric locale to save numbers correctly
+ Kernel_Utils::Localizer loc;
+
+ SatControl_Writer aWriter;
+
+ IFSelect_ReturnStatus status;
+ status = aWriter.TransferShape( aShape );
+ if ( status == IFSelect_RetDone )
+ status = aWriter.WriteFile( aFileName.ToCString() ) ;
+ if ( status == IFSelect_RetDone )
+ return 1;
+ else
return 0;
- }
-} // end of extern "C"
+}
+
+//=======================================================================
+//function : MustExecute
+//purpose :
+//=======================================================================
+Standard_Boolean ACISPlugin_ExportDriver::MustExecute( const TFunction_Logbook& ) const
+{
+ return Standard_True;
+}
+
+//================================================================================
+/*!
+ * \brief Returns a name of creation operation and names and values of creation parameters
+ */
+//================================================================================
+bool ACISPlugin_ExportDriver::
+GetCreationInformation( std::string& theOperationName,
+ std::vector<GEOM_Param>& theParams )
+{
+ return false;
+}
+
+IMPLEMENT_STANDARD_HANDLE( ACISPlugin_ExportDriver,GEOM_BaseDriver );
+IMPLEMENT_STANDARD_RTTIEXT( ACISPlugin_ExportDriver,GEOM_BaseDriver );