From: mpa Date: Wed, 3 Sep 2014 09:49:02 +0000 (+0400) Subject: Implementation of ACISPLUGIN as a GEOM plugin (removed and modified files) X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1e393665b60debfa24c4ffa63c85dc5f4b013af4;p=plugins%2Facisplugin.git Implementation of ACISPLUGIN as a GEOM plugin (removed and modified files) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c3c84ea..5911278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ IF(EXISTS ${KERNEL_ROOT_DIR}) LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files") INCLUDE(SalomeMacros) FIND_PACKAGE(SalomeKERNEL REQUIRED) + KERNEL_WITH_CORBA() #check whether KERNEL builded with CORBA ADD_DEFINITIONS(${KERNEL_DEFINITIONS}) INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS}) ELSE(EXISTS ${KERNEL_ROOT_DIR}) @@ -56,9 +57,38 @@ SET(BUILD_SHARED_LIBS TRUE) # Local macros: LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files") +# Find GEOM +# =========== +SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM") +IF(EXISTS ${GEOM_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files") + FIND_PACKAGE(SalomeGEOM REQUIRED) + ADD_DEFINITIONS(${GEOM_DEFINITIONS}) + INCLUDE_DIRECTORIES(${GEOM_INCLUDE_DIRS}) +ELSE(EXISTS ${GEOM_ROOT_DIR}) + MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR") +ENDIF(EXISTS ${GEOM_ROOT_DIR}) + +SET(SALOME_BUILD_GUI ${SALOME_GEOM_BUILD_GUI}) + +# Find GUI(optional) +IF(SALOME_BUILD_GUI) + SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI") + IF(EXISTS ${GUI_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files") + FIND_PACKAGE(SalomeGUI) + FULL_GUI(FALSE) #check whether GUI builded in full mode and with CORBA + ADD_DEFINITIONS(${GUI_DEFINITIONS}) + INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS}) + ELSE(EXISTS ${GUI_ROOT_DIR}) + MESSAGE(STATUS "GUI_ROOT_DIR is not well defined, ACISPLUGIN will be built without GUI!!!") + ENDIF(EXISTS ${GUI_ROOT_DIR}) + SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI) +ENDIF(SALOME_BUILD_GUI) + # User options # ============ -#OPTION(SALOME_BUILD_DOC "Generate SALOME ACISPLUGIN documentation" ON) #for use in the future +OPTION(SALOME_BUILD_DOC "Generate SALOME ACISPLUGIN documentation" ON) OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON) IF(SALOME_BUILD_TESTS) @@ -70,7 +100,7 @@ OPTION(ACIS_WRITE_LICENSE "ACIS write license key" "") IF(ACIS_READ_LICENSE OR ACIS_WRITE_LICENSE) IF(NOT ACIS_READ_LICENSE) - MESSAGE(WARNING "ACIS read license keys are not specified! Runtime license will be required!") + MESSAGE(WARNING "ACIS read license key is not specified! Runtime license will be required!") ELSEIF(NOT ACIS_WRITE_LICENSE) MESSAGE(WARNING "ACIS write license key is not specified! Runtime license will be required!") ENDIF() @@ -83,8 +113,18 @@ ENDIF() ## ACISPLUGIN specifics ## +FIND_PACKAGE(SalomePython REQUIRED) FIND_PACKAGE(SalomeCAS REQUIRED) FIND_PACKAGE(SalomeACIS REQUIRED) +FIND_PACKAGE(SalomeOmniORB REQUIRED) +FIND_PACKAGE(SalomeOmniORBPy REQUIRED) +IF(SALOME_BUILD_GUI) + FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui) +ENDIF() +IF(SALOME_BUILD_DOC) + FIND_PACKAGE(SalomeDoxygen) + SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC) +ENDIF() # Directories # =========== @@ -95,6 +135,7 @@ SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH "Install path: local SALOME CMake files") SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources") SET(SALOME_INSTALL_DOC share/doc/salome CACHE PATH "Install path: SALOME documentation") +SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff") # Specific to ACISPLUGIN: SET(SALOME_ACISPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/acisplugin" CACHE PATH. @@ -104,14 +145,18 @@ MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_HEADERS) MARK_AS_ADVANCED(SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES SALOME_INSTALL_DOC) # Accumulate environment variables for ACISPLUGIN module +SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}) SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) # Sources # ======== - +ADD_SUBDIRECTORY(idl) ADD_SUBDIRECTORY(adm_local) ADD_SUBDIRECTORY(resources) ADD_SUBDIRECTORY(src) +IF(SALOME_BUILD_DOC) + ADD_SUBDIRECTORY(doc) +ENDIF() # Header configuration # ==================== @@ -126,15 +171,23 @@ INCLUDE(CMakePackageConfigHelpers) # List of targets in this project we want to make visible to the rest of the world. # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup" SET(_${PROJECT_NAME}_exposed_targets - ACISExport ACISImport + SalomeIDLACISPlugin ACISPluginEngine ) +IF(SALOME_BUILD_GUI) + LIST(APPEND _${PROJECT_NAME}_exposed_targets + ACISPluginGUI + ) +ENDIF() + # Add all targets to the build-tree export set EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets} FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake) # Ensure the variables are always defined for the configure: SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}") +SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}") +SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}") SET(ACIS_ROOT_DIR "${ACIS_ROOT_DIR}") SET(OCCLICENSE_ROOT_DIR "${OCCLICENSE_ROOT_DIR}") @@ -147,7 +200,7 @@ CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX - KERNEL_ROOT_DIR ACIS_ROOT_DIR OCCLICENSE_ROOT_DIR) + KERNEL_ROOT_DIR GUI_ROOT_DIR GEOM_ROOT_DIR ACIS_ROOT_DIR OCCLICENSE_ROOT_DIR) WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${${PROJECT_NAME_UC}_VERSION} diff --git a/SalomeACISPLUGINConfig.cmake.in b/SalomeACISPLUGINConfig.cmake.in index b325e7a..7f172f7 100644 --- a/SalomeACISPLUGINConfig.cmake.in +++ b/SalomeACISPLUGINConfig.cmake.in @@ -29,7 +29,7 @@ # Load the dependencies for the libraries of @PROJECT_NAME@ # (contains definitions for IMPORTED targets). This is only # imported if we are not built as a subproject (in this case targets are already there) -IF(NOT TARGET ACISExport AND NOT @PROJECT_NAME@_BINARY_DIR) +IF(NOT TARGET ACISPluginEngine AND NOT @PROJECT_NAME@_BINARY_DIR) INCLUDE("@PACKAGE_SALOME_INSTALL_CMAKE_LOCAL@/@PROJECT_NAME@Targets.cmake") ENDIF() @@ -47,11 +47,13 @@ SET(ACISPLUGIN_DEFINITIONS) #### Now the specificities # Options exported by the package: -#SET(SALOME_ACISPLUGIN_BUILD_DOC @SALOME_BUILD_DOC@) +SET(SALOME_ACISPLUGIN_BUILD_DOC @SALOME_BUILD_DOC@) SET(SALOME_ACISPLUGIN_BUILD_TESTS @SALOME_BUILD_TESTS@) # Level 1 prerequisites: SET_AND_CHECK(KERNEL_ROOT_DIR_EXP "@PACKAGE_KERNEL_ROOT_DIR@") +SET_AND_CHECK(GUI_ROOT_DIR_EXP "@PACKAGE_GUI_ROOT_DIR@") +SET_AND_CHECK(GEOM_ROOT_DIR_EXP "@PACKAGE_GEOM_ROOT_DIR@") SET_AND_CHECK(ACIS_ROOT_DIR_EXP "@PACKAGE_ACIS_ROOT_DIR@") SET_AND_CHECK(OCCLICENSE_ROOT_DIR_EXP "@PACKAGE_OCCLICENSE_ROOT_DIR@") @@ -94,5 +96,6 @@ SET(SALOME_INSTALL_RES "@SALOME_INSTALL_RES@") SET(SALOME_INSTALL_DOC "@SALOME_INSTALL_DOC@") # Exposed ACISPLUGIN targets: -SET(ACISPLUGIN_ACISExport ACISExport) -SET(ACISPLUGIN_ACISImport ACISImport) \ No newline at end of file +SET(ACISPLUGIN_SalomeIDLACISPlugin SalomeIDLACISPlugin) +SET(ACISPLUGIN_ACISPluginEngine ACISPluginEngine) +SET(ACISPLUGIN_ACISPluginGUI ACISPluginGUI) diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index be45365..efa7be6 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -18,7 +18,8 @@ # SET(ACISPLUGIN_RESOURCES_FILES - ImportExport + SalomeApp.xml + ACISPlugin.xml ) INSTALL(FILES ${ACISPLUGIN_RESOURCES_FILES} DESTINATION ${SALOME_ACISPLUGIN_INSTALL_RES_DATA}) diff --git a/src/ACISExport/CMakeLists.txt b/src/ACISExport/CMakeLists.txt deleted file mode 100644 index 8c067fc..0000000 --- a/src/ACISExport/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (C) 2014 OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${ACIS_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/src/common - ${CMAKE_SOURCE_DIR}/src/common -) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} -) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKernel} - ${CAS_TKXSBase} - ${ACIS_LIBRARIES} - ${KERNEL_SALOMEBasics} -) - -# --- sources --- - -# sources / static -SET(ACISExport_SOURCES - ACISExport.cxx -) - -# --- rules --- - -ADD_LIBRARY(ACISExport ${ACISExport_SOURCES}) -TARGET_LINK_LIBRARIES(ACISExport ${_link_LIBRARIES} ) -INSTALL(TARGETS ACISExport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/src/ACISImport/CMakeLists.txt b/src/ACISImport/CMakeLists.txt deleted file mode 100644 index 3269faf..0000000 --- a/src/ACISImport/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2014 OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${ACIS_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/src/common - ${CMAKE_SOURCE_DIR}/src/common -) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} -) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKernel} - ${CAS_TKXSBase} - ${CAS_TKCAF} - ${CAS_TKLCAF} - ${CAS_TKMath} - ${CAS_TKBRep} - ${ACIS_LIBRARIES} - ${KERNEL_SALOMEBasics} -) - -# --- sources --- - -# sources / static -SET(ACISImport_SOURCES - ACISImport.cxx -) - -# --- rules --- - -ADD_LIBRARY(ACISImport ${ACISImport_SOURCES}) -TARGET_LINK_LIBRARIES(ACISImport ${_link_LIBRARIES} ) -INSTALL(TARGETS ACISImport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/src/ACISPlugin_Engine.hxx b/src/ACISPlugin_Engine.hxx old mode 100644 new mode 100755 index 94ba750..d7dbb92 --- a/src/ACISPlugin_Engine.hxx +++ b/src/ACISPlugin_Engine.hxx @@ -1,4 +1,4 @@ -// 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 @@ -17,17 +17,17 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#if !defined (__ACISPLUGIN_EXPORTS_H) -#define __ACISPLUGIN_EXPORTS_H +#ifndef _ACISPLUGIN_ENGINE_HXX_ +#define _ACISPLUGIN_ENGINE_HXX_ #ifdef WIN32 -# if defined ACISExport_EXPORTS || defined ACISEXPORTS_EXPORTS || defined ACISImport_EXPORTS || defined ACISIMPORT_EXPORTS -# define ACISPLUGIN_EXPORT __declspec(dllexport) -# else -# define ACISPLUGIN_EXPORT __declspec(dllimport) -# endif -#else // WIN32 -# define ACISPLUGIN_EXPORT -#endif // WIN32 + #if defined ACISPLUGINENGINE_EXPORTS || defined ACISPLUGINENGINE_EXPORTS + #define ACISPLUGINENGINE_EXPORT __declspec( dllexport ) + #else + #define ACISPLUGINENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define ACISPLUGINENGINE_EXPORT +#endif -#endif // __ACISPLUGIN_EXPORTS_H +#endif diff --git a/src/ACISPlugin_ExportDriver.cxx b/src/ACISPlugin_ExportDriver.cxx index aaecd27..455033b 100644 --- a/src/ACISPlugin_ExportDriver.cxx +++ b/src/ACISPlugin_ExportDriver.cxx @@ -1,4 +1,4 @@ -// 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 @@ -17,57 +17,55 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include -#include +// internal includes +#include "ACISPlugin_ExportDriver.hxx" +#include "ACISPlugin_IExport.hxx" +#include "ACISPlugin_Engine.hxx" +// KERNEL includes #include +#include +// GEOM includes +#include + +// OOCT includes #include #include #include #include #ifdef ACIS_HASLICENSE -#include +#include "ACISPlugin_license.h" #include #include #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); @@ -76,23 +74,60 @@ extern "C" 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& theParams ) +{ + return false; +} + +IMPLEMENT_STANDARD_HANDLE( ACISPlugin_ExportDriver,GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( ACISPlugin_ExportDriver,GEOM_BaseDriver ); diff --git a/src/ACISPlugin_ImportDriver.cxx b/src/ACISPlugin_ImportDriver.cxx index 352cc63..c7cd2ec 100644 --- a/src/ACISPlugin_ImportDriver.cxx +++ b/src/ACISPlugin_ImportDriver.cxx @@ -1,4 +1,4 @@ -// 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 @@ -17,11 +17,20 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include -#include +// internal includes +#include "ACISPlugin_ImportDriver.hxx" +#include "ACISPlugin_IImport.hxx" +#include "ACISPlugin_Engine.hxx" +// KERNEL includes #include +#include +// GEOM includes +#include +#include + +// OOCT includes #include #include #include @@ -38,126 +47,161 @@ #include #include +#include + #ifdef ACIS_HASLICENSE -#include +#include "ACISPlugin_license.h" #include #include #endif // ACIS_HASLICENSE -extern "C" +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& ACISPlugin_ImportDriver::GetID() { - /*! - \brief Get version of the plugin. - \return the version of the plugin - */ - ACISPLUGIN_EXPORT - int GetVersion() - { - return ACISPLUGIN_VERSION; - } + static Standard_GUID aGUID("4e2fea67-84bc-44fe-9a32-ac52a246154c"); + return aGUID; +} - /*! - \brief Get version of the plugin. - \return the string representation of the plugin's version - */ - ACISPLUGIN_EXPORT - char* GetVersionStr() - { - return (char*)ACISPLUGIN_VERSION_STR; - } +//======================================================================= +//function : ACISPlugin_ImportDriver +//purpose : +//======================================================================= +ACISPlugin_ImportDriver::ACISPlugin_ImportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer ACISPlugin_ImportDriver::Execute( TFunction_Logbook& log ) const +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + ACISPlugin_IImport aData( aFunction ); + + TCollection_AsciiString aFileName = aData.GetFileName().ToCString(); + + MESSAGE("Import ACIS from file " << aFileName); + TopoDS_Shape aResShape; - /*! - \brief Import shape from the ACIS format. - \param theFileName file path - \param theFormatName file format signature - \param theError error description, if there's any, is returned via this parameter - \param theShapeLabel a label in the CAF tree where shape attributes are set to - \return imported shape - */ - ACISPLUGIN_EXPORT - TopoDS_Shape Import(const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& /*theFormatName*/, - TCollection_AsciiString& theError, - const TDF_Label& theShapeLabel) - { - TopoDS_Shape aResShape; - #ifdef ACIS_HASLICENSE - try { - OCCLicense_Activate( "SAT-R-"OCC_VERSION_STRING, ACIS_READ_LICENSE); - } - catch (Standard_LicenseError) { - return aResShape; - } + try { + OCCLicense_Activate( "SAT-R-"OCC_VERSION_STRING, ACIS_READ_LICENSE); + } + catch (Standard_LicenseError) { + return aResShape; + } #endif // ACIS_HASLICENSE - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - SatControl_Reader aReader; - - try { - IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); - if (status == IFSelect_RetDone) { - aReader.TransferRoots(); - aResShape = aReader.OneShape(); - Handle(Interface_InterfaceModel) Model = aReader.WS()->Model(); - Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); - if( !TR.IsNull() ) { - Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); - Standard_Integer nb = Model->NbEntities(); - for (Standard_Integer i = 1; i <= nb; i ++) { - Handle(AcisEnt_Attrib) attr = Handle(AcisEnt_Attrib)::DownCast ( Model->Value(i) ); - if ( attr.IsNull() ) continue; //not only Entity Label (f.18) but Name Property also - - TCollection_AsciiString aName; - if ( attr->IsKind(STANDARD_TYPE(AcisAttr_AttribGenName)) ) { - Handle(AcisAttr_AttribGenName) attrname = Handle(AcisAttr_AttribGenName)::DownCast ( attr ); - aName = attrname->myNameAttr; - } - else continue; // no name assigned - - // find target entity - Handle(AcisEnt_Entity) ent; - do { - ent = attr->myEntity; - attr = Handle(AcisEnt_Attrib)::DownCast ( ent ); - } while ( ! attr.IsNull() ); - if ( ent.IsNull() ) continue; // strange - no normal entity found ? - - // find target shape - Handle(Transfer_Binder) binder = TP->Find ( ent ); - if ( binder.IsNull() ) continue; - TopoDS_Shape S = TransferBRep::ShapeResult (binder); - if ( S.IsNull() ) continue; - - //if( S.IsEqual(aResShape) ) continue; - - // create label and set shape - TDF_Label L; - TDF_TagSource aTag; - L = aTag.NewChild(theShapeLabel); - TNaming_Builder tnBuild(L); - tnBuild.Generated(S); - - // set a name - TCollection_ExtendedString str(aName); - TDataStd_Name::Set(L,str); - } - } - } - else { - theError = "Wrong format of the imported file. Can't import file."; - aResShape.Nullify(); + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + SatControl_Reader aReader; + + IFSelect_ReturnStatus status = aReader.ReadFile( aFileName.ToCString() ); + if (status == IFSelect_RetDone) { + aReader.TransferRoots(); + aResShape = aReader.OneShape(); + Handle(Interface_InterfaceModel) Model = aReader.WS()->Model(); + Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); + if( !TR.IsNull() ) { + Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); + Standard_Integer nb = Model->NbEntities(); + for (Standard_Integer i = 1; i <= nb; i ++) { + Handle(AcisEnt_Attrib) attr = Handle(AcisEnt_Attrib)::DownCast ( Model->Value(i) ); + if ( attr.IsNull() ) continue; //not only Entity Label (f.18) but Name Property also + + TCollection_AsciiString aName; + if( attr->IsKind(STANDARD_TYPE(AcisAttr_AttribGenName)) ) { + Handle(AcisAttr_AttribGenName) attrname = Handle(AcisAttr_AttribGenName)::DownCast ( attr ); + aName = attrname->myNameAttr; + } + else continue; // no name assigned + + // find target entity + Handle(AcisEnt_Entity) ent; + do { + ent = attr->myEntity; + attr = Handle(AcisEnt_Attrib)::DownCast ( ent ); + } while ( ! attr.IsNull() ); + if ( ent.IsNull() ) continue; // strange - no normal entity found ? + + // find target shape + Handle(Transfer_Binder) binder = TP->Find ( ent ); + if( binder.IsNull() ) continue; + TopoDS_Shape S = TransferBRep::ShapeResult (binder); + if( S.IsNull() ) continue; + + // create label and set shape + TDF_Label L; + TDF_TagSource aTag; + L = aTag.NewChild(aFunction->GetNamingEntry()); + TNaming_Builder tnBuild(L); + tnBuild.Generated(S); + + // set a name + TCollection_ExtendedString str(aName); + TDataStd_Name::Set(L,str); } } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - theError = aFail->GetMessageString(); - aResShape.Nullify(); - } - return aResShape; } -} // end of extern "C" + else { + TCollection_AsciiString anError = "Wrong format of the imported file. Can't import file."; + StdFail_NotDone::Raise( anError.ToCString() ); + aResShape.Nullify(); + } + + if( aResShape.IsNull() ) return 0; + + aFunction->SetValue( aResShape ); + + log.SetTouched( Label() ); + + return 1; +} + +//======================================================================= +//function : MustExecute +//purpose : +//======================================================================= +Standard_Boolean ACISPlugin_ImportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool ACISPlugin_ImportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction( Label() ); + + ACISPlugin_IImport aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "ImportACIS"; + + switch ( aType ) { + case IMPORT_SHAPE: + AddParam( theParams, "File name", aCI.GetFileName() ); + break; + default: + return false; + } + return true; +} +IMPLEMENT_STANDARD_HANDLE( ACISPlugin_ImportDriver, GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( ACISPlugin_ImportDriver, GEOM_BaseDriver ); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d61376f..e737dd5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# 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 @@ -17,6 +17,142 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -ADD_SUBDIRECTORY(common) -ADD_SUBDIRECTORY(ACISExport) -ADD_SUBDIRECTORY(ACISImport) +IF(SALOME_BUILD_GUI) + INCLUDE(UseQt4Ext) + INCLUDE(${QT_USE_FILE}) +ENDIF() + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} + ${ACIS_INCLUDE_DIRS} + ${KERNEL_INCLUDE_DIRS} + ${GUI_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR} + ${PROJECT_BINARY_DIR}/idl + ) + +IF(SALOME_BUILD_GUI) + INCLUDE_DIRECTORIES( + ${QT_INCLUDE_DIRS} + ) +ENDIF() + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${CAS_DEFINITIONS} + ) + +IF(SALOME_BUILD_GUI) +ADD_DEFINITIONS( + ${QT_DEFINITIONS} + ) +ENDIF() + +# libraries to link to +SET(_link_LIBRARIES + ${CAS_TKXSBase} + ${ACIS_LIBRARIES} + ${KERNEL_SALOMEBasics} + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + ${GEOM_SalomeIDLGEOM} + ${GEOM_GEOMEngine} + ${GEOM_GEOMImpl} + ${GEOM_GEOMClient} + SalomeIDLACISPlugin + ) + +IF(SALOME_BUILD_GUI) + SET(_link_LIBRARIES + ${_link_LIBRARIES} + ${GEOM_GEOMBase} + ) +ENDIF() + + +# --- headers --- + +SET(ACISPluginEngine_HEADERS + ACISPlugin_Operations_i.hh + ACISPlugin_Engine.hxx + ACISPlugin_OperationsCreator.hh + ACISPlugin_IOperations.hxx + ACISPlugin_IExport.hxx + ACISPlugin_IImport.hxx + ACISPlugin_ImportDriver.hxx + ACISPlugin_ExportDriver.hxx + ACISPlugin_IECallBack.hxx + ) + +IF(SALOME_BUILD_GUI) + # header files / to be processed by moc + SET(_moc_HEADERS + ACISPlugin_ExportDlg.h + ACISPlugin_ImportDlg.h + ) +ENDIF() + +# --- sources --- + +IF(SALOME_BUILD_GUI) + # sources / moc wrappings + QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) + + SET(ACISPluginGUI_SOURCES + ACISPluginGUI.cxx + ACISPlugin_ExportDlg.cxx + ACISPlugin_ImportDlg.cxx + ${_moc_SOURCES} + ) +ENDIF() + +SET(ACISPluginEngine_SOURCES + ACISPluginEngine.cxx + ACISPlugin_OperationsCreator.cc + ACISPlugin_Operations_i.cc + ACISPlugin_IOperations.cxx + ACISPlugin_ExportDriver.cxx + ACISPlugin_ImportDriver.cxx + ACISPlugin_IECallBack.cxx + ) + +# resource files / to be processed by lrelease +SET(ACISPlugin_RESOURCES + resources/ACISPlugin_msg_en.ts + resources/ACISPlugin_msg_fr.ts + resources/ACISPlugin_msg_ja.ts + ) + +# ACIS plugin scripts +SET(_python_ACIS_SCRIPTS + ACISPluginBuilder.py + __init__.py +) + +# --- rules --- + +# install Engine library +ADD_LIBRARY(ACISPluginEngine ${ACISPluginEngine_SOURCES}) +TARGET_LINK_LIBRARIES(ACISPluginEngine ${_link_LIBRARIES}) +INSTALL(TARGETS ACISPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +# install GUI library +IF(SALOME_BUILD_GUI) + ADD_LIBRARY(ACISPluginGUI ${ACISPluginGUI_SOURCES}) + TARGET_LINK_LIBRARIES(ACISPluginGUI ${_link_LIBRARIES}) + INSTALL(TARGETS ACISPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + # install resources + QT4_INSTALL_TS_RESOURCES("${ACISPlugin_RESOURCES}" "${SALOME_ACISPLUGIN_INSTALL_RES_DATA}") +ENDIF() + +# install headers +INSTALL(FILES ${ACISPluginEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) + +# install python scripts +SALOME_INSTALL_SCRIPTS("${_python_ACIS_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/ACISPlugin DEF_PERMS) + +# configure license file +CONFIGURE_FILE(ACISPlugin_license.h.in ACISPlugin_license.h) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt deleted file mode 100644 index 4a6e068..0000000 --- a/src/common/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (C) 2014 OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -CONFIGURE_FILE(ACISPLUGIN_license.h.in ACISPLUGIN_license.h)