From 4aa8d04044438d641dd943a3982469a33c980b23 Mon Sep 17 00:00:00 2001 From: asozinov Date: Mon, 27 Mar 2023 12:03:45 +0100 Subject: [PATCH] DXF plugin Import as Shape/Sketcj License check --- CMakeCommon/FindDXF.cmake | 29 + CMakeCommon/FindTBB.cmake | 103 + CMakeLists.txt | 9 + src/CTestTestfileInstall.cmake | 1 + src/Config/plugins.xml.in | 1 + src/DXFAPI/CMakeLists.txt | 86 + src/DXFAPI/DXFAPI.h | 33 + src/DXFAPI/DXFAPI.i | 40 + src/DXFAPI/DXFAPI_Import.cpp | 92 + src/DXFAPI/DXFAPI_Import.h | 82 + src/DXFAPI/DXFAPI_swig.h | 24 + src/DXFAPI/dxf/__init__.py | 16 + src/DXFPlugin/CMakeLists.txt | 87 + src/DXFPlugin/DXFPlugin.h | 33 + src/DXFPlugin/DXFPlugin_Import.cpp | 219 + src/DXFPlugin/DXFPlugin_Import.h | 137 + src/DXFPlugin/DXFPlugin_ImportAlgoAPI.cpp | 282 + src/DXFPlugin/DXFPlugin_ImportAlgoAPI.h | 62 + src/DXFPlugin/DXFPlugin_Plugin.cpp | 53 + src/DXFPlugin/DXFPlugin_Plugin.h | 37 + src/DXFPlugin/Test/CMakeLists.txt | 40 + src/DXFPlugin/Test/CTestTestfileInstall.cmake | 26 + .../Test/TestImportDXF_importModel.py | 49 + src/DXFPlugin/Test/data/Grass.dxf | 24020 ++++++++++++++++ src/DXFPlugin/Test/tests.set | 5 + src/DXFPlugin/doc/DXFPlugin.rst | 13 + src/DXFPlugin/doc/TUI_importDXFFeature.rst | 12 + src/DXFPlugin/doc/examples/importDXF.py | 1042 + src/DXFPlugin/doc/images/ImportDXF_start.png | Bin 0 -> 5237 bytes src/DXFPlugin/doc/images/exportDXF.png | Bin 0 -> 629 bytes src/DXFPlugin/doc/images/importDXF.png | Bin 0 -> 629 bytes .../doc/images/importDXF_example.png | Bin 0 -> 8896 bytes .../doc/images/importDXF_fileDialog.png | Bin 0 -> 58076 bytes src/DXFPlugin/doc/importDXFFeature.rst | 47 + src/DXFPlugin/icons/exportDXF.png | Bin 0 -> 629 bytes src/DXFPlugin/icons/importDXF.png | Bin 0 -> 629 bytes src/DXFPlugin/plugin-DXF.xml | 72 + src/ModuleBase/ModuleBase_IModule.cpp | 6 +- 38 files changed, 26757 insertions(+), 1 deletion(-) create mode 100644 CMakeCommon/FindDXF.cmake create mode 100644 CMakeCommon/FindTBB.cmake create mode 100644 src/DXFAPI/CMakeLists.txt create mode 100644 src/DXFAPI/DXFAPI.h create mode 100644 src/DXFAPI/DXFAPI.i create mode 100644 src/DXFAPI/DXFAPI_Import.cpp create mode 100644 src/DXFAPI/DXFAPI_Import.h create mode 100644 src/DXFAPI/DXFAPI_swig.h create mode 100644 src/DXFAPI/dxf/__init__.py create mode 100644 src/DXFPlugin/CMakeLists.txt create mode 100644 src/DXFPlugin/DXFPlugin.h create mode 100644 src/DXFPlugin/DXFPlugin_Import.cpp create mode 100644 src/DXFPlugin/DXFPlugin_Import.h create mode 100644 src/DXFPlugin/DXFPlugin_ImportAlgoAPI.cpp create mode 100644 src/DXFPlugin/DXFPlugin_ImportAlgoAPI.h create mode 100644 src/DXFPlugin/DXFPlugin_Plugin.cpp create mode 100644 src/DXFPlugin/DXFPlugin_Plugin.h create mode 100644 src/DXFPlugin/Test/CMakeLists.txt create mode 100644 src/DXFPlugin/Test/CTestTestfileInstall.cmake create mode 100644 src/DXFPlugin/Test/TestImportDXF_importModel.py create mode 100644 src/DXFPlugin/Test/data/Grass.dxf create mode 100644 src/DXFPlugin/Test/tests.set create mode 100644 src/DXFPlugin/doc/DXFPlugin.rst create mode 100644 src/DXFPlugin/doc/TUI_importDXFFeature.rst create mode 100644 src/DXFPlugin/doc/examples/importDXF.py create mode 100644 src/DXFPlugin/doc/images/ImportDXF_start.png create mode 100644 src/DXFPlugin/doc/images/exportDXF.png create mode 100644 src/DXFPlugin/doc/images/importDXF.png create mode 100644 src/DXFPlugin/doc/images/importDXF_example.png create mode 100644 src/DXFPlugin/doc/images/importDXF_fileDialog.png create mode 100644 src/DXFPlugin/doc/importDXFFeature.rst create mode 100644 src/DXFPlugin/icons/exportDXF.png create mode 100644 src/DXFPlugin/icons/importDXF.png create mode 100644 src/DXFPlugin/plugin-DXF.xml diff --git a/CMakeCommon/FindDXF.cmake b/CMakeCommon/FindDXF.cmake new file mode 100644 index 000000000..71c7c9708 --- /dev/null +++ b/CMakeCommon/FindDXF.cmake @@ -0,0 +1,29 @@ +# Copyright (c) 2021-present OPEN CASCADE SAS +# +# This file is part of commercial software by OPEN CASCADE SAS. +# +# This software is furnished in accordance with the terms and conditions +# of the contract and with the inclusion of this copyright notice. +# This software or any other copy thereof may not be provided or otherwise +# be made available to any third party. +# No ownership title to the software is transferred hereby. +# +# OPEN CASCADE SAS makes no representation or warranties with respect to the +# performance of this software, and specifically disclaims any responsibility +# for any damages, special or consequential, connected with its use. +# + +#path to DXF component dir +set(DXF_DIR "D:/C/SALOME-master/W64/DXF") + +if(EXISTS ${DXF_DIR}) + set(CMAKE_PREFIX_PATH ${DXF_DIR}/cmake ${CMAKE_PREFIX_PATH}) + include(FindTBB) + #find_package(PRODUCTS) + set(HAVE_DXF True) + set(PRODUCTS_DXF_FOUND True) + #if(PRODUCTS_DXF_LIBRARIES) + # set(HAVE_DXF True) + # set(PRODUCTS_DXF_FOUND True) + #endif() +endif() diff --git a/CMakeCommon/FindTBB.cmake b/CMakeCommon/FindTBB.cmake new file mode 100644 index 000000000..8745fe35a --- /dev/null +++ b/CMakeCommon/FindTBB.cmake @@ -0,0 +1,103 @@ +# - Find TBB +# Sets the following variables: +# TBB_INCLUDE_DIRS - path to the TBB include directory +# TBB_LIBRARIES - path to the TBB libraries to be linked against +# + +######################################################################### +# Copyright (C) 2007-2020 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 +# + +# ------ + +MESSAGE(STATUS "Check for TBB ...") + +# ------ + +SET(TBB_ROOT_DIR $ENV{TBB_ROOT_DIR}) + +IF(TBB_ROOT_DIR) + LIST(APPEND CMAKE_PREFIX_PATH "${TBB_ROOT_DIR}") +ENDIF(TBB_ROOT_DIR) + +FIND_PATH(TBB_INCLUDE_DIRS tbb/tbb.h PATH_SUFFIXES include) + +IF(MACHINE_IS_64) + SET(PLT_SUFFIX intel64) +ELSE(MACHINE_IS_64) + SET(PLT_SUFFIX ia32) +ENDIF(MACHINE_IS_64) + +include(CheckCXXSourceCompiles) + +SET(_PATH_SUFFIXES) +IF(TBB_ROOT_DIR) + FOREACH(_PATH cc4.1.0_libc2.4_kernel2.6.16.21 gcc4.4 gcc4.1) + LIST(APPEND _PATH_SUFFIXES ${PLT_SUFFIX}/${_PATH}) + ENDFOREACH() +ENDIF() + +FIND_LIBRARY(_tbb_library_tbb + NAMES tbb + PATH_SUFFIXES ${_PATH_SUFFIXES}) +FIND_LIBRARY(_tbb_library_tbb_debug + NAMES tbb_debug + PATH_SUFFIXES ${_PATH_SUFFIXES}) +FIND_LIBRARY(_tbb_library_tbbmalloc + NAMES tbbmalloc + PATH_SUFFIXES ${_PATH_SUFFIXES}) + +SET(_tbb_libraries ${_tbb_library_tbb} ${_tbb_library_tbbmalloc} ${_tbb_library_tbb_debug}) + +IF(_tbb_libraries) + + SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${TBB_INCLUDE_DIRS}") + SET(CMAKE_REQUIRED_LIBRARIES "${_tbb_libraries}") + + UNSET(_tbb_link_ok CACHE) + CHECK_CXX_SOURCE_COMPILES(" + #include + using namespace tbb; + size_t testme(size_t n) + { + return n*n; + } + int main(int argc, char* argv[]) + { + parallel_for( 1, 10, 1, testme ); + } + " + _tbb_link_ok + ) + + SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + + IF(_tbb_link_ok) + SET(TBB_LIBRARY_tbb ${_tbb_library_tbb} CACHE FILEPATH "Path to a library") + SET(TBB_LIBRARY_tbbmalloc ${_tbb_library_tbbmalloc} CACHE FILEPATH "Path to a library") + SET(TBB_LIBRARIES ${TBB_LIBRARY_tbb} ${TBB_LIBRARY_tbbmalloc}) + ENDIF() + +ENDIF(_tbb_libraries) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(TBB REQUIRED_VARS TBB_INCLUDE_DIRS TBB_LIBRARY_tbb TBB_LIBRARY_tbbmalloc) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0804d5a4e..bc881adc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,8 @@ INCLUDE(FindEclipse) INCLUDE(Common) INCLUDE(FindTInspector) INCLUDE(FindSalomeQt5) +INCLUDE(FindDXF) +INCLUDE(FindTBB) IF(HAVE_SALOME) INCLUDE(SalomeSetupPlatform) # From CONFIGURATION @@ -190,6 +192,9 @@ ADD_SUBDIRECTORY (src/SketchPlugin) ADD_SUBDIRECTORY (src/SketchSolver) ADD_SUBDIRECTORY (src/ModuleBase) ADD_SUBDIRECTORY (src/PartSet) +IF(${HAVE_DXF}) + ADD_SUBDIRECTORY (src/DXFPlugin) +ENDIF(${HAVE_DXF}) ADD_SUBDIRECTORY (src/XGUI) ADD_SUBDIRECTORY (src/ExchangePlugin) @@ -213,6 +218,10 @@ ADD_SUBDIRECTORY (src/SketchAPI) ADD_SUBDIRECTORY (src/GDMLAPI) ADD_SUBDIRECTORY (src/ConnectorAPI) ADD_SUBDIRECTORY (src/FiltersAPI) +IF(${HAVE_DXF}) + ADD_SUBDIRECTORY (src/DXFAPI) +ENDIF(${HAVE_DXF}) + # Tests ADD_SUBDIRECTORY (test.API/SHAPER) diff --git a/src/CTestTestfileInstall.cmake b/src/CTestTestfileInstall.cmake index c559f1a55..746b8af7c 100644 --- a/src/CTestTestfileInstall.cmake +++ b/src/CTestTestfileInstall.cmake @@ -44,6 +44,7 @@ SUBDIRS(ConnectorAPI Config ExchangeAPI ModelGeomAlgo + DXFPlugin Locale test_API ) diff --git a/src/Config/plugins.xml.in b/src/Config/plugins.xml.in index 7c23b377e..ff72aaea5 100644 --- a/src/Config/plugins.xml.in +++ b/src/Config/plugins.xml.in @@ -15,6 +15,7 @@ + @DEFAULT_SOLVER@