From: mpa Date: Thu, 4 Sep 2014 11:57:04 +0000 (+0400) Subject: Implementation of XTPLUGIN as a GEOM plugin (removed and renamed files) X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b063d8f21b18b5b58f421eb6ccc956efcb68724a;p=plugins%2Fxtplugin.git Implementation of XTPLUGIN as a GEOM plugin (removed and renamed files) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8eb62be..d24f7bf 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, XTPLUGIN 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 XTPLUGIN documentation" ON) #for use in the future +OPTION(SALOME_BUILD_DOC "Generate SALOME XTPLUGIN documentation" ON) OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON) IF(SALOME_BUILD_TESTS) @@ -77,8 +107,18 @@ ENDIF() ## XTPLUGIN specifics ## +FIND_PACKAGE(SalomePython REQUIRED) FIND_PACKAGE(SalomeCAS REQUIRED) FIND_PACKAGE(SalomeXT 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 # =========== @@ -89,6 +129,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 XTPLUGIN: SET(SALOME_XTPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/xtplugin" CACHE PATH. @@ -98,14 +139,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 XTPLUGIN 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 # ==================== @@ -120,15 +165,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 - XTImport + SalomeIDLXTPlugin XTPluginEngine ) +IF(SALOME_BUILD_GUI) + LIST(APPEND _${PROJECT_NAME}_exposed_targets + XTPluginGUI + ) +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(XT_ROOT_DIR "${XT_ROOT_DIR}") SET(OCCLICENSE_ROOT_DIR "${OCCLICENSE_ROOT_DIR}") @@ -136,12 +189,12 @@ SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/inc # Build variables that will be expanded when configuring SalomeConfig.cmake: SALOME_CONFIGURE_PREPARE(XT) - + 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 XT_ROOT_DIR OCCLICENSE_ROOT_DIR) + KERNEL_ROOT_DIR GUI_ROOT_DIR GEOM_ROOT_DIR XT_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/SalomeXTPLUGINConfig.cmake.in b/SalomeXTPLUGINConfig.cmake.in index b87d3e6..f9ee32b 100644 --- a/SalomeXTPLUGINConfig.cmake.in +++ b/SalomeXTPLUGINConfig.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 XTImport AND NOT @PROJECT_NAME@_BINARY_DIR) +IF(NOT TARGET XTPluginEngine AND NOT @PROJECT_NAME@_BINARY_DIR) INCLUDE("@PACKAGE_SALOME_INSTALL_CMAKE_LOCAL@/@PROJECT_NAME@Targets.cmake") ENDIF() @@ -47,9 +47,16 @@ SET(XTPLUGIN_DEFINITIONS) #### Now the specificities # Options exported by the package: -#SET(SALOME_XTPLUGIN_BUILD_DOC @SALOME_BUILD_DOC@) +SET(SALOME_XTPLUGIN_BUILD_DOC @SALOME_BUILD_DOC@) SET(SALOME_XTPLUGIN_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(XT_ROOT_DIR_EXP "@PACKAGE_XT_ROOT_DIR@") +SET_AND_CHECK(OCCLICENSE_ROOT_DIR_EXP "@PACKAGE_OCCLICENSE_ROOT_DIR@") + # For all prerequisites, load the corresponding targets if the package was used # in CONFIG mode. This ensures dependent projects link correctly # without having to set LD_LIBRARY_PATH: @@ -89,4 +96,6 @@ SET(SALOME_INSTALL_RES "@SALOME_INSTALL_RES@") SET(SALOME_INSTALL_DOC "@SALOME_INSTALL_DOC@") # Exposed XTPLUGIN targets: -SET(XTPLUGIN_XTImport XTImport) \ No newline at end of file +SET(XTPLUGIN_SalomeIDLXTPlugin SalomeIDLXTPlugin) +SET(XTPLUGIN_XTPluginEngine XTPluginEngine) +SET(XTPLUGIN_XTPluginGUI XTPluginGUI) diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index ea7016f..29a9e1a 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -18,7 +18,8 @@ # SET(XTPLUGIN_RESOURCES_FILES - ImportExport + SalomeApp.xml + XTPlugin.xml ) INSTALL(FILES ${XTPLUGIN_RESOURCES_FILES} DESTINATION ${SALOME_XTPLUGIN_INSTALL_RES_DATA}) diff --git a/resources/ImportExport b/resources/ImportExport deleted file mode 100644 index c5640fd..0000000 --- a/resources/ImportExport +++ /dev/null @@ -1,4 +0,0 @@ -Import: XT - -XT.Import: XTImport -XT.Pattern: Parasolid Files ( *.x_t *.xt ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7f5d47e..c6c5768 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,5 +17,137 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -ADD_SUBDIRECTORY(common) -ADD_SUBDIRECTORY(XTImport) +IF(SALOME_BUILD_GUI) + INCLUDE(UseQt4Ext) + INCLUDE(${QT_USE_FILE}) +ENDIF() + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} + ${XT_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} + ${XT_LIBRARIES} + ${KERNEL_SALOMEBasics} + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + ${GEOM_SalomeIDLGEOM} + ${GEOM_GEOMEngine} + ${GEOM_GEOMImpl} + ${GEOM_GEOMClient} + SalomeIDLXTPlugin + ) + +IF(SALOME_BUILD_GUI) + SET(_link_LIBRARIES + ${_link_LIBRARIES} + ${GEOM_GEOMBase} + ) +ENDIF() + + +# --- headers --- + +SET(XTPluginEngine_HEADERS + XTPlugin_Operations_i.hh + XTPlugin_Engine.hxx + XTPlugin_OperationsCreator.hh + XTPlugin_IOperations.hxx + XTPlugin_IImport.hxx + XTPlugin_ImportDriver.hxx + XTPlugin_IECallBack.hxx + ) + +IF(SALOME_BUILD_GUI) + # header files / to be processed by moc + SET(_moc_HEADERS + XTPlugin_ImportDlg.h + ) +ENDIF() + +# --- sources --- + +IF(SALOME_BUILD_GUI) + # sources / moc wrappings + QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) + + SET(XTPluginGUI_SOURCES + XTPluginGUI.cxx + XTPlugin_ImportDlg.cxx + ${_moc_SOURCES} + ) +ENDIF() + +SET(XTPluginEngine_SOURCES + XTPluginEngine.cxx + XTPlugin_OperationsCreator.cc + XTPlugin_Operations_i.cc + XTPlugin_IOperations.cxx + XTPlugin_ImportDriver.cxx + XTPlugin_IECallBack.cxx + ) + +# resource files / to be processed by lrelease +SET(XTPlugin_RESOURCES + resources/XTPlugin_msg_en.ts + resources/XTPlugin_msg_fr.ts + resources/XTPlugin_msg_ja.ts + ) + +# XT plugin scripts +SET(_python_XT_SCRIPTS + XTPluginBuilder.py + __init__.py +) + +# --- rules --- + +# install Engine library +ADD_LIBRARY(XTPluginEngine ${XTPluginEngine_SOURCES}) +TARGET_LINK_LIBRARIES(XTPluginEngine ${_link_LIBRARIES}) +INSTALL(TARGETS XTPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +# install GUI library +IF(SALOME_BUILD_GUI) + ADD_LIBRARY(XTPluginGUI ${XTPluginGUI_SOURCES}) + TARGET_LINK_LIBRARIES(XTPluginGUI ${_link_LIBRARIES}) + INSTALL(TARGETS XTPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + # install resources + QT4_INSTALL_TS_RESOURCES("${XTPlugin_RESOURCES}" "${SALOME_XTPLUGIN_INSTALL_RES_DATA}") +ENDIF() + +# install headers +INSTALL(FILES ${XTPluginEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) + +# install python scripts +SALOME_INSTALL_SCRIPTS("${_python_XT_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/XTPlugin DEF_PERMS) + +# configure license file +CONFIGURE_FILE(XTPlugin_license.h.in XTPlugin_license.h) diff --git a/src/XTImport/CMakeLists.txt b/src/XTImport/CMakeLists.txt deleted file mode 100644 index 00e61fb..0000000 --- a/src/XTImport/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} - ${XT_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} - ${XT_LIBRARIES} - ${KERNEL_SALOMEBasics} -) - -# --- sources --- - -# sources / static -SET(XTImport_SOURCES - XTImport.cxx -) - -# --- rules --- - -ADD_LIBRARY(XTImport ${XTImport_SOURCES}) -TARGET_LINK_LIBRARIES(XTImport ${_link_LIBRARIES} ) -INSTALL(TARGETS XTImport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/src/XTImport/XTImport.cxx b/src/XTImport/XTImport.cxx deleted file mode 100644 index 48dc23b..0000000 --- a/src/XTImport/XTImport.cxx +++ /dev/null @@ -1,218 +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 -// - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef XT_HASLICENSE -#include - -#include -#include -#endif // XT_HASLICENSE - -extern "C" -{ - /*! - \brief Get version of the plugin. - \return the version of the plugin - */ - XTPLUGIN_EXPORT - int GetVersion() - { - return XTPLUGIN_VERSION; - } - - /*! - \brief Get version of the plugin. - \return the string representation of the plugin's version - */ - XTPLUGIN_EXPORT - char* GetVersionStr() - { - return (char*)XTPLUGIN_VERSION_STR; - } - - /*! - \brief Import shape from the XT 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 - */ - XTPLUGIN_EXPORT - TopoDS_Shape Import(const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& /*theFormatName*/, - TCollection_AsciiString& theError, - const TDF_Label& theShapeLabel) - { - TopoDS_Shape aResShape; - -#ifdef XT_HASLICENSE - try { - OCCLicense_Activate( "DXF-R-"OCC_VERSION_STRING, DXF_READ_LICENSE); - } - catch (Standard_LicenseError) { - return aResShape; - } -#endif // XT_HASLICENSE - - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - XtControl_Reader aReader; - - try { - IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); - if (status == IFSelect_RetDone) { - aReader.TransferRoots(); - aResShape = aReader.OneShape(); - - // ATTENTION: this is a workaround for mantis issue 0020442 remark 0010776 - // It should be removed after patching OCCT for bug OCC22436 - // (fix for OCCT is expected in service pack next to OCCT6.3sp12) - if (aResShape.ShapeType() == TopAbs_COMPOUND) { - int nbSub1 = 0; - TopoDS_Shape currShape; - TopoDS_Iterator It (aResShape, Standard_True, Standard_True); - for (; It.More(); It.Next()) { - nbSub1++; - currShape = It.Value(); - } - if (nbSub1 == 1) - aResShape = currShape; - } - Handle(XtData_Model) aModel = Handle(XtData_Model)::DownCast( aReader.WS()->Model() ); - Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); - if (!TR.IsNull()) { - Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); - Standard_Integer nb = aModel->NbEntities(); - for (Standard_Integer i = 1; i <= nb; i ++) { - Handle(XtData_Object) XtOb = Handle(XtData_Object)::DownCast ( aModel->Value(i) ); - if (XtOb.IsNull()) continue; - - Handle(XtAttributes_AttribGroup) XtAG; - Standard_Boolean MayBeName = Standard_False; - - if (XtOb->IsKind(STANDARD_TYPE(XtTopoDS_Topology))) { - Handle(XtTopoDS_Topology) XtT = Handle(XtTopoDS_Topology)::DownCast(XtOb); - XtAG = XtT->AttributesGroups(); - MayBeName = Standard_True; - } - else if (XtOb->IsKind(STANDARD_TYPE(XtGeom_Surface))) { - Handle(XtGeom_Surface) XtGS = Handle(XtGeom_Surface)::DownCast(XtOb); - XtAG = XtGS->AttributesGroups(); - MayBeName = Standard_True; - } - else if (XtOb->IsKind(STANDARD_TYPE(XtGeom_Curve))) { - Handle(XtGeom_Curve) XtGC = Handle(XtGeom_Curve)::DownCast(XtOb); - XtAG = XtGC->AttributesGroups(); - MayBeName = Standard_True; - } - else if (XtOb->IsKind(STANDARD_TYPE(XtGeom_Point))) { - Handle(XtGeom_Point) XtGP = Handle(XtGeom_Point)::DownCast(XtOb); - XtAG = XtGP->AttributesGroups(); - MayBeName = Standard_True; - } - - if (MayBeName) { - TCollection_AsciiString string; - Standard_Boolean IsName = Standard_False; - Handle(XtAttributes_Attribute) XtA = Handle(XtAttributes_Attribute)::DownCast(XtAG); - if (!XtA.IsNull()) { - Handle(XtAttributes_AttribDef) XtAD = XtA->Definition(); - while (!XtAD.IsNull()) { - if (XtAD->TypeID()==8017) { - const Handle(XtData_HArray1OfObject) &HAFV = XtA->Fields(); - const Standard_Integer NbFV = HAFV->Length(); - for (Standard_Integer j=1; j<=NbFV; j++) { - const Handle(XtData_Object) &FV = HAFV->Value(j); - if(!FV.IsNull() && FV->IsKind(STANDARD_TYPE(XtAttributes_CharValues))) { - string = Handle(XtAttributes_CharValues)::DownCast(FV)->Values(); - IsName = Standard_True; - } - } - } - XtAD = XtAD->Next(); - } - } - - if (IsName) { - // find target shape - Handle(Transfer_Binder) binder = TP->Find ( XtOb ); - if ( binder.IsNull() ) continue; - TopoDS_Shape S = TransferBRep::ShapeResult (binder); - if ( S.IsNull() ) continue; - - TDF_Label L; - TDF_TagSource aTag; - L = aTag.NewChild(theShapeLabel); - TNaming_Builder tnBuild(L); - tnBuild.Generated(S); - - // set a name to the document - string.LeftAdjust(); - string.RightAdjust(); - TCollection_ExtendedString str ( string ); - TDataStd_Name::Set ( L, str ); - } - } - } - } - else { - theError = "Wrong format of the imported file. Can't import file."; - aResShape.Nullify(); - } - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - theError = aFail->GetMessageString(); - aResShape.Nullify(); - } - return aResShape; - } -} // end of extern "C" diff --git a/src/XTPlugin_Engine.hxx b/src/XTPlugin_Engine.hxx new file mode 100755 index 0000000..de7aaf3 --- /dev/null +++ b/src/XTPlugin_Engine.hxx @@ -0,0 +1,33 @@ +// 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 +// 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 +// + +#ifndef _XTPLUGIN_ENGINE_HXX_ +#define _XTPLUGIN_ENGINE_HXX_ + +#ifdef WIN32 + #if defined XTPLUGINENGINE_EXPORTS || defined XTPLUGINENGINE_EXPORTS + #define XTPLUGINENGINE_EXPORT __declspec( dllexport ) + #else + #define XTPLUGINENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define XTPLUGINENGINE_EXPORT +#endif + +#endif diff --git a/src/XTPlugin_ImportDriver.cxx b/src/XTPlugin_ImportDriver.cxx new file mode 100644 index 0000000..32f2feb --- /dev/null +++ b/src/XTPlugin_ImportDriver.cxx @@ -0,0 +1,265 @@ +// 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 +// 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 +// + +// internal includes +#include "XTPlugin_ImportDriver.hxx" +#include "XTPlugin_IImport.hxx" +#include "XTPlugin_Engine.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include +#include + +// OOCT includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef XT_HASLICENSE +#include "XTPlugin_license.h" + +#include +#include +#endif // XT_HASLICENSE + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& XTPlugin_ImportDriver::GetID() +{ + static Standard_GUID aGUID("81cc16bb-486f-4ec7-87b2-960b4aed557f"); + return aGUID; +} + +//======================================================================= +//function : XTPlugin_ImportDriver +//purpose : +//======================================================================= +XTPlugin_ImportDriver::XTPlugin_ImportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer XTPlugin_ImportDriver::Execute( TFunction_Logbook& log ) const +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + XTPlugin_IImport aData( aFunction ); + + TCollection_AsciiString aFileName = aData.GetFileName().ToCString(); + + MESSAGE("Import XT from file " << aFileName); + + TopoDS_Shape aResShape; + +#ifdef XT_HASLICENSE + try { + OCCLicense_Activate( "XT-R-"OCC_VERSION_STRING, XT_READ_LICENSE); + } + catch (Standard_LicenseError) { + return aResShape; + } +#endif // XT_HASLICENSE + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + XtControl_Reader aReader; + + IFSelect_ReturnStatus status = aReader.ReadFile(aFileName.ToCString()); + if (status == IFSelect_RetDone) { + aReader.TransferRoots(); + aResShape = aReader.OneShape(); + + // ATTENTION: this is a workaround for mantis issue 0020442 remark 0010776 + // It should be removed after patching OCCT for bug OCC22436 + // (fix for OCCT is expected in service pack next to OCCT6.3sp12) + if (aResShape.ShapeType() == TopAbs_COMPOUND) { + int nbSub1 = 0; + TopoDS_Shape currShape; + TopoDS_Iterator It (aResShape, Standard_True, Standard_True); + for (; It.More(); It.Next()) { + nbSub1++; + currShape = It.Value(); + } + if (nbSub1 == 1) + aResShape = currShape; + } + Handle(XtData_Model) aModel = Handle(XtData_Model)::DownCast( aReader.WS()->Model() ); + Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); + if (!TR.IsNull()) { + Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); + Standard_Integer nb = aModel->NbEntities(); + for (Standard_Integer i = 1; i <= nb; i ++) { + Handle(XtData_Object) XtOb = Handle(XtData_Object)::DownCast ( aModel->Value(i) ); + if (XtOb.IsNull()) continue; + + Handle(XtAttributes_AttribGroup) XtAG; + Standard_Boolean MayBeName = Standard_False; + + if (XtOb->IsKind(STANDARD_TYPE(XtTopoDS_Topology))) { + Handle(XtTopoDS_Topology) XtT = Handle(XtTopoDS_Topology)::DownCast(XtOb); + XtAG = XtT->AttributesGroups(); + MayBeName = Standard_True; + } + else if (XtOb->IsKind(STANDARD_TYPE(XtGeom_Surface))) { + Handle(XtGeom_Surface) XtGS = Handle(XtGeom_Surface)::DownCast(XtOb); + XtAG = XtGS->AttributesGroups(); + MayBeName = Standard_True; + } + else if (XtOb->IsKind(STANDARD_TYPE(XtGeom_Curve))) { + Handle(XtGeom_Curve) XtGC = Handle(XtGeom_Curve)::DownCast(XtOb); + XtAG = XtGC->AttributesGroups(); + MayBeName = Standard_True; + } + else if (XtOb->IsKind(STANDARD_TYPE(XtGeom_Point))) { + Handle(XtGeom_Point) XtGP = Handle(XtGeom_Point)::DownCast(XtOb); + XtAG = XtGP->AttributesGroups(); + MayBeName = Standard_True; + } + + if (MayBeName) { + TCollection_AsciiString string; + Standard_Boolean IsName = Standard_False; + Handle(XtAttributes_Attribute) XtA = Handle(XtAttributes_Attribute)::DownCast(XtAG); + if (!XtA.IsNull()) { + Handle(XtAttributes_AttribDef) XtAD = XtA->Definition(); + while (!XtAD.IsNull()) { + if (XtAD->TypeID()==8017) { + const Handle(XtData_HArray1OfObject) &HAFV = XtA->Fields(); + const Standard_Integer NbFV = HAFV->Length(); + for (Standard_Integer j=1; j<=NbFV; j++) { + const Handle(XtData_Object) &FV = HAFV->Value(j); + if(!FV.IsNull() && FV->IsKind(STANDARD_TYPE(XtAttributes_CharValues))) { + string = Handle(XtAttributes_CharValues)::DownCast(FV)->Values(); + IsName = Standard_True; + } + } + } + XtAD = XtAD->Next(); + } + } + if (IsName) { + // find target shape + Handle(Transfer_Binder) binder = TP->Find ( XtOb ); + if ( binder.IsNull() ) continue; + TopoDS_Shape S = TransferBRep::ShapeResult (binder); + if ( S.IsNull() ) continue; + + TDF_Label L; + TDF_TagSource aTag; + L = aTag.NewChild(aFunction->GetNamingEntry()); + TNaming_Builder tnBuild(L); + tnBuild.Generated(S); + + // set a name to the document + string.LeftAdjust(); + string.RightAdjust(); + TCollection_ExtendedString str ( string ); + TDataStd_Name::Set ( L, str ); + } + } + } + } + } + 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 XTPlugin_ImportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool XTPlugin_ImportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction( Label() ); + + XTPlugin_IImport aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "ImportXT"; + + switch ( aType ) { + case IMPORT_SHAPE: + AddParam( theParams, "File name", aCI.GetFileName() ); + break; + default: + return false; + } + return true; +} + +IMPLEMENT_STANDARD_HANDLE( XTPlugin_ImportDriver, GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( XTPlugin_ImportDriver, GEOM_BaseDriver ); diff --git a/src/XTPlugin_license.h.in b/src/XTPlugin_license.h.in new file mode 100644 index 0000000..12c7089 --- /dev/null +++ b/src/XTPlugin_license.h.in @@ -0,0 +1,25 @@ +// 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 +// + +#if !defined(__XTPLUGIN_LICENSE_H) +#define __XTPLUGIN_LICENSE_H + +#define XT_READ_LICENSE "@XT_READ_LICENSE@" + +#endif // __XTPLUGIN_LICENSE_H diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt deleted file mode 100644 index c476604..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(XTPLUGIN_license.h.in XTPLUGIN_license.h) diff --git a/src/common/XTPLUGIN_exports.h b/src/common/XTPLUGIN_exports.h deleted file mode 100644 index d494e6c..0000000 --- a/src/common/XTPLUGIN_exports.h +++ /dev/null @@ -1,33 +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 -// - -#if !defined (__XTPLUGIN_EXPORTS_H) -#define __XTPLUGIN_EXPORTS_H - -#ifdef WIN32 -# if defined XTImport_EXPORTS || defined XTIMPORT_EXPORTS -# define XTPLUGIN_EXPORT __declspec(dllexport) -# else -# define XTPLUGIN_EXPORT __declspec(dllimport) -# endif -#else // WIN32 -# define XTPLUGIN_EXPORT -#endif // WIN32 - -#endif // __XTPLUGIN_EXPORTS_H diff --git a/src/common/XTPLUGIN_license.h.in b/src/common/XTPLUGIN_license.h.in deleted file mode 100644 index 12c7089..0000000 --- a/src/common/XTPLUGIN_license.h.in +++ /dev/null @@ -1,25 +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 -// - -#if !defined(__XTPLUGIN_LICENSE_H) -#define __XTPLUGIN_LICENSE_H - -#define XT_READ_LICENSE "@XT_READ_LICENSE@" - -#endif // __XTPLUGIN_LICENSE_H