From: rnv Date: Wed, 4 Jun 2014 11:17:38 +0000 (+0400) Subject: 0022616: [CEA 1038] Improve the quality of stl and vtk exports X-Git-Tag: V7_5_0a1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aeddae77192d933be1aee8855d8f7c525878cad9;p=modules%2Fgeom.git 0022616: [CEA 1038] Improve the quality of stl and vtk exports --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 856676c05..d741a55cc 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,16 +234,18 @@ 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 - GEOMArchimede BREPExport BREPImport BlockFix GEOMbasic GEOMAlgo GEOMClient GEOMImpl - GEOMUtils GEOMEngine GEOM_SupervEngine IGESExport IGESImport GEOMSketcher - SalomeIDLGEOM STEPExport STEPImport STLExport STLImport ShHealOper XAO AdvancedEngine OCC2VTK - VTKExport + GEOMArchimede BlockFix GEOMbasic GEOMAlgo GEOMClient GEOMImpl + GEOMUtils GEOMEngine GEOM_SupervEngine GEOMSketcher + SalomeIDLGEOM SalomeIDLGEOMSuperv SalomeIDLAdvancedGEOM ShHealOper XAO AdvancedEngine OCC2VTK + SalomeIDLSTLPlugin SalomeIDLBREPPlugin SalomeIDLSTEPPlugin SalomeIDLIGESPlugin SalomeIDLXAOPlugin SalomeIDLVTKPlugin + STLPluginEngine BREPPluginEngine STEPPluginEngine IGESPluginEngine XAOPluginEngine VTKPluginEngine ) IF(SALOME_BUILD_GUI) LIST(APPEND _${PROJECT_NAME}_exposed_targets AdvancedGUI BasicGUI BlocksGUI BooleanGUI BuildGUI DisplayGUI DlgRef EntityGUI GEOMBase GEOMFiltersSelection GEOM GEOMToolsGUI GenerationGUI GroupGUI Material MeasureGUI GEOMObject - OperationGUI PrimitiveGUI RepairGUI TransformationGUI ImportExportGUI DependencyTree + OperationGUI PrimitiveGUI RepairGUI TransformationGUI DependencyTree + STLPluginGUI BREPPluginGUI STEPPluginGUI IGESPluginGUI XAOPluginGUI VTKPluginGUI ) ENDIF(SALOME_BUILD_GUI) diff --git a/SalomeGEOMConfig.cmake.in b/SalomeGEOMConfig.cmake.in index c72af1a38..43660c4f8 100644 --- a/SalomeGEOMConfig.cmake.in +++ b/SalomeGEOMConfig.cmake.in @@ -129,8 +129,6 @@ ENDIF(SALOME_GEOM_BUILD_GUI) # Exposed GEOM targets: SET(GEOM_GEOMArchimede GEOMArchimede) -SET(GEOM_BREPExport BREPExport) -SET(GEOM_BREPImport BREPImport) SET(GEOM_BlockFix BlockFix) SET(GEOM_GEOMbasic GEOMbasic) SET(GEOM_GEOMAlgo GEOMAlgo) @@ -139,14 +137,16 @@ SET(GEOM_GEOMImpl GEOMImpl) SET(GEOM_GEOMUtils GEOMUtils) SET(GEOM_GEOMEngine GEOMEngine) SET(GEOM_GEOM_SupervEngine GEOM_SupervEngine) -SET(GEOM_IGESExport IGESExport) -SET(GEOM_IGESImport IGESImport) SET(GEOM_GEOMSketcher GEOMSketcher) SET(GEOM_SalomeIDLGEOM SalomeIDLGEOM) -SET(GEOM_STEPExport STEPExport) -SET(GEOM_STEPImport STEPImport) -SET(GEOM_STLExport STLExport) -SET(GEOM_STLImport STLImport) +SET(GEOM_SalomeIDLGEOMSuperv SalomeIDLGEOMSuperv) +SET(GEOM_SalomeIDLAdvancedGEOM SalomeIDLAdvancedGEOM) +SET(GEOM_SalomeIDLSTLPlugin SalomeIDLSTLPlugin) +SET(GEOM_SalomeIDLBREPPlugin SalomeIDLBREPPlugin) +SET(GEOM_SalomeIDLSTEPPlugin SalomeIDLSTEPPlugin) +SET(GEOM_SalomeIDLIGESPlugin SalomeIDLIGESPlugin) +SET(GEOM_SalomeIDLXAOPlugin SalomeIDLXAOPlugin) +SET(GEOM_SalomeIDLVTKPlugin SalomeIDLVTKPlugin) SET(GEOM_ShHealOper ShHealOper) SET(GEOM_XAO XAO) SET(GEOM_AdvancedEngine AdvancedEngine) @@ -169,11 +169,21 @@ SET(GEOM_Material Material) SET(GEOM_MeasureGUI MeasureGUI) SET(GEOM_GEOMObject GEOMObject) SET(GEOM_OCC2VTK OCC2VTK) -SET(GEOM_VTKExport VTKExport) SET(GEOM_OperationGUI OperationGUI) SET(GEOM_PrimitiveGUI PrimitiveGUI) SET(GEOM_RepairGUI RepairGUI) SET(GEOM_TransformationGUI TransformationGUI) -SET(GEOM_ImportExportGUI ImportExportGUI) +SET(GEOM_STLPluginGUI STLPluginGUI) +SET(GEOM_STLPluginEngine STLPluginEngine) +SET(GEOM_BREPPluginGUI BREPPluginGUI) +SET(GEOM_BREPPluginEngine BREPPluginEngine) +SET(GEOM_STEPPluginGUI STEPPluginGUI) +SET(GEOM_STEPPluginEngine STEPPluginEngine) +SET(GEOM_IGESPluginGUI IGESPluginGUI) +SET(GEOM_IGESPluginEngine IGESPluginEngine) +SET(GEOM_XAOPluginGUI XAOPluginGUI) +SET(GEOM_XAOPluginEngine XAOPluginEngine) +SET(GEOM_VTKPluginGUI VTKPluginGUI) +SET(GEOM_VTKPluginEngine VTKPluginEngine) SET(GEOM_GEOMShapeRec GEOMShapeRec) SET(GEOM_CurveCreator CurveCreator) diff --git a/adm_local/cmake_files/FindGEOM.cmake b/adm_local/cmake_files/FindGEOM.cmake index 69722aa4e..0d408449a 100644 --- a/adm_local/cmake_files/FindGEOM.cmake +++ b/adm_local/cmake_files/FindGEOM.cmake @@ -21,8 +21,6 @@ SET(GEOM_CXXFLAGS -I${GEOM_ROOT_DIR}/include/salome) # to be removed SET(GEOM_INCLUDE_DIRS ${GEOM_ROOT_DIR}/include/salome) FIND_LIBRARY(GEOM_GEOMArchimede GEOMArchimede ${GEOM_ROOT_DIR}/lib/salome) -FIND_LIBRARY(GEOM_BREPExport BREPExport ${GEOM_ROOT_DIR}/lib/salome) -FIND_LIBRARY(GEOM_BREPImport BREPImport ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_BlockFix BlockFix ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GEOMbasic GEOMbasic ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GEOMAlgo GEOMAlgo ${GEOM_ROOT_DIR}/lib/salome) @@ -31,14 +29,14 @@ FIND_LIBRARY(GEOM_GEOMimpl GEOMimpl ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GEOMUtils GEOMUtils ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GEOMEngine GEOMEngine ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_SupervEngine GEOM_SupervEngine ${GEOM_ROOT_DIR}/lib/salome) -FIND_LIBRARY(GEOM_IGESExport IGESExport ${GEOM_ROOT_DIR}/lib/salome) -FIND_LIBRARY(GEOM_IGESImport IGESImport ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GEOMSketcher GEOMSketcher ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_SalomeIDLGEOM SalomeIDLGEOM ${GEOM_ROOT_DIR}/lib/salome) -FIND_LIBRARY(GEOM_STEPExport STEPExport ${GEOM_ROOT_DIR}/lib/salome) -FIND_LIBRARY(GEOM_STEPImport STEPImport ${GEOM_ROOT_DIR}/lib/salome) -FIND_LIBRARY(GEOM_STLExport STLExport ${GEOM_ROOT_DIR}/lib/salome) -FIND_LIBRARY(GEOM_STLImport STLImport ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_SalomeIDLSTLPlugin SalomeIDLSTLPlugin ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_SalomeIDLBREPPlugin SalomeIDLBREPPlugin ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_SalomeIDLSTEPPlugin SalomeIDLSTEPPlugin ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_SalomeIDLIGESPlugin SalomeIDLIGESPlugin ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_SalomeIDLVTKPlugin SalomeIDLVTKPlugin ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_SalomeIDLXAOPlugin SalomeIDLXAOPlugin ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_ShHealOper ShHealOper ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_XAO XAO ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_AdvancedEngine AdvancedEngine ${GEOM_ROOT_DIR}/lib/salome) @@ -61,11 +59,21 @@ FIND_LIBRARY(GEOM_Material Material ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_MeasureGUI MeasureGUI ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GEOMObject GEOMObject ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_OCC2VTK OCC2VTK ${GEOM_ROOT_DIR}/lib/salome) -FIND_LIBRARY(GEOM_VTKExport VTKExport ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_OperationGUI OperationGUI ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_PrimitiveGUI PrimitiveGUI ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_RepairGUI RepairGUI ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_TransformationGUI TransformationGUI ${GEOM_ROOT_DIR}/lib/salome) -FIND_LIBRARY(GEOM_ImportExportGUI ImportExportGUI ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_STLPluginGUI STLPluginGUI ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_STLPluginEngine STLPluginEngine ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_BREPPluginGUI BREPPluginGUI ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_BREPPluginEngine BREPPluginEngine ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_STEPPluginGUI STEPPluginGUI ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_STEPPluginEngine STEPPluginEngine ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_IGESPluginGUI IGESPluginGUI ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_IGESPluginEngine IGESPluginEngine ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_XAOPluginGUI XAOPluginGUI ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_XAOPluginEngine XAOPluginEngine ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_VTKPluginGUI VTKPluginGUI ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_VTKPluginEngine VTKPluginEngine ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GEOMShapeRec GEOMShapeRec ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_CurveCreator CurveCreator ${GEOM_ROOT_DIR}/lib/salome) diff --git a/bin/geom_setenv.py b/bin/geom_setenv.py index 35f9a0ef1..b4e8b747a 100644 --- a/bin/geom_setenv.py +++ b/bin/geom_setenv.py @@ -36,28 +36,28 @@ def set_env( args ): csf_list = ["Plugin", "GEOMDS_Resources", "ShHealing"] - for csf_file in csf_list: - uniteFiles( os.path.join( res_dir, csf_file ), os.path.join( env_dir, csf_file ) ) - pass - - for csf_string in csf_list: - csf_var = "CSF_" + csf_string + "Defaults" + for csf in csf_list: + uniteFiles( os.path.join( res_dir, csf ), os.path.join( env_dir, csf ) ) + csf_var = "CSF_%sDefaults" % csf if not os.getenv( csf_var ): os.environ[ csf_var ] = env_dir pass pass - # find plugins + # collect plugins plugin_list = [] resource_path_list = [] - plugins_dir_var = "GEOM_ENGINE_RESOURCES_DIR" - if os.environ.has_key(plugins_dir_var): - # reverse the user's paths list, because the used 'add_path' prepends a new path, - # but we want to append it: [a, b, c] => [c, b, a] - plugins_dirs = os.environ[plugins_dir_var].split(os.pathsep) - plugins_dirs.reverse() - os.environ[plugins_dir_var] = string.join(plugins_dirs, os.pathsep) - pass + + # standard plugins + plugin_list.append("BREPPlugin") + plugin_list.append("STEPPlugin") + plugin_list.append("IGESPlugin") + plugin_list.append("STLPlugin") + plugin_list.append("XAOPlugin") + plugin_list.append("VTKPlugin") + plugin_list.append("AdvancedGEOM") + + # find additional plugins for env_var in os.environ.keys(): value = os.environ[env_var] if env_var[-9:] == "_ROOT_DIR" and value: @@ -65,61 +65,48 @@ def set_env( args ): plugin = env_var[:-9] # plugin name may have wrong case # look for NAMEOFPlugin.xml file among resource files - resource_dir = os.path.join(plugin_root,"share",salome_subdir,"resources",plugin.lower()) - if not os.access( resource_dir, os.F_OK ): continue - for resource_file in os.listdir( resource_dir ): - if resource_file.endswith( ".xml") and \ + resource_dir = os.path.join(plugin_root, "share", salome_subdir, "resources", plugin.lower()) + if not os.access(resource_dir, os.F_OK): continue + + for resource_file in os.listdir(resource_dir): + if resource_file.endswith(".xml") and \ resource_file.lower() == plugin.lower() + ".xml": # use "name" attribute of "geom-plugin" as name of plugin in a right case - from xml.dom.minidom import parse try: - xml_doc = parse( os.path.join( resource_dir, resource_file )) + from xml.dom.minidom import parse + xml_doc = parse(os.path.join(resource_dir, resource_file)) plugin_nodes = xml_doc.getElementsByTagName("geom-plugin") - except: - continue - if not plugin_nodes or not plugin_nodes[0].hasAttribute("name"): continue - plugin = plugin_nodes[0].getAttribute("name") - if plugin in plugin_list: continue + if not plugin_nodes or not plugin_nodes[0].hasAttribute("name"): continue - # add paths of plugin - plugin_list.append(plugin) - if not os.environ.has_key("SALOME_"+plugin+"Resources"): - resource_path = os.path.join(plugin_root,"share",salome_subdir,"resources",plugin.lower()) - os.environ["SALOME_"+plugin+"Resources"] = resource_path - resource_path_list.append( resource_path ) - add_path(os.path.join(plugin_root,get_lib_dir(),python_version, "site-packages",salome_subdir), "PYTHONPATH") - add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PYTHONPATH") + plugin = plugin_nodes[0].getAttribute("name") + if plugin in plugin_list: continue - if sys.platform == "win32": - add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PATH") - add_path(os.path.join(plugin_root,"bin",salome_subdir), "PYTHONPATH") - else: - add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "LD_LIBRARY_PATH") - add_path(os.path.join(plugin_root,"bin",salome_subdir), "PYTHONPATH") - add_path(os.path.join(plugin_root,"bin",salome_subdir), "PATH") + plugin_list.append(plugin) + + # add paths of plugin + if not os.environ.has_key("SALOME_"+plugin+"Resources"): + resource_path = os.path.join(plugin_root, "share", salome_subdir, "resources", plugin.lower()) + os.environ["SALOME_"+plugin+"Resources"] = resource_path + resource_path_list.append(resource_path) + add_path(os.path.join(plugin_root, get_lib_dir(), python_version, "site-packages", salome_subdir), "PYTHONPATH") + add_path(os.path.join(plugin_root, get_lib_dir(), salome_subdir), "PYTHONPATH") + if sys.platform == "win32": + add_path(os.path.join(plugin_root, get_lib_dir(), salome_subdir), "PATH") + add_path(os.path.join(plugin_root, "bin", salome_subdir), "PYTHONPATH") + else: + add_path(os.path.join(plugin_root, get_lib_dir(), salome_subdir), "LD_LIBRARY_PATH") + add_path(os.path.join(plugin_root, "bin", salome_subdir), "PYTHONPATH") + add_path(os.path.join(plugin_root, "bin", salome_subdir), "PATH") + pass pass pass - pass - elif resource_file == "ImportExport" and plugin.upper() != "GEOM": - # add 'ImportExport' plugin file path into variable - add_path(resource_dir, plugins_dir_var) - # add plugin's library path into environment - if sys.platform == "win32": - add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PATH") - else: - add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "LD_LIBRARY_PATH") - pass + except: + continue pass pass - plugin_list.append("GEOMActions") + pass + pass + os.environ["GEOM_PluginsList"] = ":".join(plugin_list) os.environ["SalomeAppConfig"] = os.environ["SalomeAppConfig"] + psep + psep.join(resource_path_list) - - if os.environ.has_key(plugins_dir_var): - # reverse back the plugin paths: - # [f, e, d, c, b, a] => [a, b, c, d, e, f] - plugins_dirs = os.environ[plugins_dir_var].split(os.pathsep) - plugins_dirs.reverse() - os.environ[plugins_dir_var] = string.join(plugins_dirs, os.pathsep) - pass pass diff --git a/doc/salome/examples/import_export.py b/doc/salome/examples/import_export.py index 158fc6375..3b5f7df60 100644 --- a/doc/salome/examples/import_export.py +++ b/doc/salome/examples/import_export.py @@ -25,7 +25,7 @@ print "UnitName2 = ", UnitName2 # import shapes Shape1 = geompy.ImportIGES(theFileName1) Shape2 = geompy.ImportIGES(theFileName2) -Shape3 = geompy.ImportFile(theFileName2,"IGES_SCALE") +Shape3 = geompy.ImportIGES(theFileName2, True) [Xmin1,Xmax1, Ymin1,Ymax1, Zmin1,Zmax1] = geompy.BoundingBox(Shape1) [Xmin2,Xmax2, Ymin2,Ymax2, Zmin2,Zmax2] = geompy.BoundingBox(Shape2) [Xmin3,Xmax3, Ymin3,Ymax3, Zmin3,Zmax3] = geompy.BoundingBox(Shape3) diff --git a/doc/salome/gui/GEOM/CMakeLists.txt b/doc/salome/gui/GEOM/CMakeLists.txt index 1b8fbf299..3584bc193 100644 --- a/doc/salome/gui/GEOM/CMakeLists.txt +++ b/doc/salome/gui/GEOM/CMakeLists.txt @@ -25,12 +25,23 @@ SALOME_CONFIGURE_FILE(doxyfile_tui.in doxyfile_tui) SALOME_CONFIGURE_FILE(static/header.html.in ${CMAKE_CURRENT_BINARY_DIR}/static/header.html) SALOME_CONFIGURE_FILE(static/header_py.html.in ${CMAKE_CURRENT_BINARY_DIR}/static/header_py.html) +# Generate a temporary python file, needed for the genaration of the documentation +# of the built-in Geometry plugins. +SET(DOC_GEOM_PluginsList AdvancedGEOM STLPlugin BREPPlugin STEPPlugin IGESPlugin XAOPlugin VTKPlugin) +SALOME_ACCUMULATE_ENVIRONMENT(GEOM_PluginsList NOCHECK ${DOC_GEOM_PluginsList}) +SET(geom_file "${CMAKE_CURRENT_SOURCE_DIR}/collect_geom_methods.py") +SET(plugins_cmd_options ${geom_file} -o tmp1/geomBuilder.py ${DOC_GEOM_PluginsList}) +SALOME_GENERATE_ENVIRONMENT_SCRIPT(plugins_cmd env_script "${PYTHON_EXECUTABLE}" "${plugins_cmd_options}") +# Install a script +SALOME_INSTALL_SCRIPTS(collect_geom_methods.py ${SALOME_INSTALL_BINS}) + SET(f "$ENV{KERNEL_ROOT_DIR}/bin/salome/prepare_generating_doc.py") IF(WIN32) STRING(REPLACE "/" "\\" f ${f}) ENDIF(WIN32) ADD_CUSTOM_TARGET(usr_docs ${CMAKE_COMMAND} -E make_directory tmp + COMMAND ${CMAKE_COMMAND} -E make_directory tmp1 COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/geomBuilder.py ${CMAKE_SOURCE_DIR}/src/GEOM_SWIG/geomBuilder.py COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/gsketcher.py ${CMAKE_SOURCE_DIR}/src/GEOM_SWIG/gsketcher.py COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/geomtools.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/geomtools.py @@ -38,12 +49,14 @@ ADD_CUSTOM_TARGET(usr_docs ${CMAKE_COMMAND} -E make_directory tmp COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/structelem.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/structelem/__init__.py COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/parts.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/structelem/parts.py COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/orientation.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/structelem/orientation.py + COMMAND ${plugins_cmd} COMMAND ${DOXYGEN_EXECUTABLE} doxyfile_tui COMMAND ${DOXYGEN_EXECUTABLE} doxyfile_py COMMAND ${DOXYGEN_EXECUTABLE} doxyfile COMMAND ${CMAKE_COMMAND} -E remove_directory tmp + COMMAND ${CMAKE_COMMAND} -E remove_directory tmp1 VERBATIM - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) ADD_DEPENDENCIES(usr_docs html_docs) diff --git a/doc/salome/gui/GEOM/collect_geom_methods.py b/doc/salome/gui/GEOM/collect_geom_methods.py new file mode 100644 index 000000000..482f5f3fd --- /dev/null +++ b/doc/salome/gui/GEOM/collect_geom_methods.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2012-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 +# + +################################################################################# +# +# File: collect_geom_methods.py +# Author: Roman NIKOLAEV, Open CASCADE S.A.S (roman.nikolaev@opencascade.com) +# +################################################################################# +# +# Extraction of the methods dynamically added by the Geometry +# module plug-in(s) to the geomBuilder class. +# +# This script is intended for internal usage - only +# for generatation of the extra developer documentation for +# the Geometry module plug-in(s). +# +# Usage: +# collect_geom_methods.py +# where +# is a name of the plug-in module +# +# Notes: +# - the script is supposed to be run in correct environment +# i.e. PYTHONPATH, GEOM_PluginsList and other important +# variables are set properly; otherwise the script will fail. +# +################################################################################ + +import sys +import inspect + +def generate(plugin_name, output): + plugin_module_name = plugin_name + "Builder" + plugin_module = "salome.%s.%s" % (plugin_name, plugin_module_name) + import_str = "from salome.%s import %s" % (plugin_name, plugin_module_name) + exec( import_str ) + exec( "import %s" % plugin_module ) + exec( "mod = %s" % plugin_module ) + functions = [] + for attr in dir( mod ): + if attr.startswith( '_' ): continue # skip an internal methods + item = getattr( mod, attr ) + if type( item ).__name__ == 'function': + if item not in functions: + functions.append( item ) + pass + pass + pass + if functions: + for function in functions: + comments = inspect.getcomments(function) + if comments: + comments = comments.strip().split("\n") + comments = "\t" + "\n\t".join(comments) + output.append(comments) + pass + sources = inspect.getsource(function) + if sources is not None: + sources_list = sources.split("\n") + sources_new_list = [] + found = False + for item in sources_list: + if '"""' in item: + if found == True: + found = False + continue + else: + found = True + continue + pass + pass + if found == False : + sources_new_list.append(item) + pass + pass + sources = "\n".join(sources_new_list) + sources = "\t" + sources.replace("\n", "\n\t") + output.append(sources) + pass + pass + pass + pass + +if __name__ == "__main__": + import optparse + parser = optparse.OptionParser(usage="%prog [options] plugin") + h = "Output file (geomBuilder.py by default)" + parser.add_option("-o", "--output", dest="output", + action="store", default=None, metavar="file", + help=h) + h = "If this option is True, dummy help for geomBuiler class is added. " + h += "This option should be False (default) when building documentation for Geometry module " + h += "and True when building documentation for Geometry module plug-ins." + parser.add_option("-d", "--dummy-geom-help", dest="dummygeomhelp", + action="store_true", default=False, + help=h) + (options, args) = parser.parse_args() + if len( args ) < 1: sys.exit("Plugin name is not specified") + + f = open(options.output, "w") + + output = [] + if options.dummygeomhelp: + output.append( "## @package geomBuilder" ) + output.append( "# Documentation of the methods dynamically added by the " + plugin_name + " Geometry plug-in to the geomBuilder class." ) + # Add dummy Geometry help + # This is supposed to be done when generating documentation for Geometry module plug-ins + output.append( "# @note The documentation below does not provide complete description of class @b %geomBuilder" ) + output.append( "# from @b geomBuilder package. This documentation provides only information about" ) + output.append( "# the methods dynamically added to the %geomBuilder class by the " + plugin_name + " plugin" ) + output.append( "# For more details on the %geomBuilder class, please refer to the SALOME %Geometry module" ) + output.append( "# documentation." ) + pass + else: + # Extend documentation for geomBuilder class with information about dynamically added methods. + # This is supposed to be done only when building documentation for Geometry module + output.append( "## @package geomBuilder" ) + output.append( "# @note Some methods are dynamically added to the @b %geomBuilder class in runtime by the" ) + output.append( "# plug-in modules. If you fail to find help on some methods in the documentation of Geometry module, " ) + output.append( "# try to look into the documentation for the Geometry module plug-ins." ) + pass + output.append("class geomBuilder():") + + for arg in args: + generate( arg, output ) + pass + + for line in output: f.write( line + "\n" ) + f.close() diff --git a/doc/salome/gui/GEOM/doxyfile_py.in b/doc/salome/gui/GEOM/doxyfile_py.in index 493b7c65c..f3ad68298 100755 --- a/doc/salome/gui/GEOM/doxyfile_py.in +++ b/doc/salome/gui/GEOM/doxyfile_py.in @@ -99,7 +99,14 @@ EXAMPLE_RECURSIVE = NO #--------------------------------------------------------------------------- #Input related options #--------------------------------------------------------------------------- -INPUT = tmp @CMAKE_SOURCE_DIR@/idl/GEOM_Gen.idl +INPUT = tmp tmp1 @CMAKE_SOURCE_DIR@/idl/GEOM_Gen.idl \ + @CMAKE_SOURCE_DIR@/idl/AdvancedGEOM_Gen.idl \ + @CMAKE_SOURCE_DIR@/idl/STLPlugin.idl \ + @CMAKE_SOURCE_DIR@/idl/BREPPlugin.idl \ + @CMAKE_SOURCE_DIR@/idl/STEPPlugin.idl \ + @CMAKE_SOURCE_DIR@/idl/IGESPlugin.idl \ + @CMAKE_SOURCE_DIR@/idl/XAOPlugin.idl \ + @CMAKE_SOURCE_DIR@/idl/VTKPlugin.idl FILE_PATTERNS = IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/images EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/src/GEOM_SWIG diff --git a/doc/salome/gui/GEOM/images/exportxao_dlg.png b/doc/salome/gui/GEOM/images/exportxao_dlg.png index a7171c748..d273b9d78 100644 Binary files a/doc/salome/gui/GEOM/images/exportxao_dlg.png and b/doc/salome/gui/GEOM/images/exportxao_dlg.png differ diff --git a/doc/salome/gui/GEOM/images/geomexport.png b/doc/salome/gui/GEOM/images/geomexport.png index 4d4d3fb33..b8c181e73 100755 Binary files a/doc/salome/gui/GEOM/images/geomexport.png and b/doc/salome/gui/GEOM/images/geomexport.png differ diff --git a/doc/salome/gui/GEOM/images/geomimport.png b/doc/salome/gui/GEOM/images/geomimport.png index d194ec5b6..c25ded610 100755 Binary files a/doc/salome/gui/GEOM/images/geomimport.png and b/doc/salome/gui/GEOM/images/geomimport.png differ diff --git a/doc/salome/gui/GEOM/images/importxao_dlg.png b/doc/salome/gui/GEOM/images/importxao_dlg.png new file mode 100644 index 000000000..0ffda5124 Binary files /dev/null and b/doc/salome/gui/GEOM/images/importxao_dlg.png differ diff --git a/doc/salome/gui/GEOM/images/sat_named_shapes.png b/doc/salome/gui/GEOM/images/sat_named_shapes.png deleted file mode 100644 index cb3bca660..000000000 Binary files a/doc/salome/gui/GEOM/images/sat_named_shapes.png and /dev/null differ diff --git a/doc/salome/gui/GEOM/input/import_export.doc b/doc/salome/gui/GEOM/input/import_export.doc index 50b792030..93ddcc384 100644 --- a/doc/salome/gui/GEOM/input/import_export.doc +++ b/doc/salome/gui/GEOM/input/import_export.doc @@ -2,34 +2,44 @@ \page import_export_geom_obj_page Importing/exporting geometrical objects -In Geometry module you can import and export geometrical objects -from/into BREP, IGES, STEP, ACIS and STL files. The mechanisms of import and export -are implemented via plug-ins, which gives the opportunity to -expand the range of available formats by adding more plug-ins (for -example, CATIA 5). +\tableofcontents + +\section io_general General information -The \subpage xao_format_page "import and export of shapes in XAO format" is implemented differently. +In Geometry module you can import and export geometrical objects +from/into \b BREP, \b IGES, \b STEP, \b STL, \b XAO, \b VTK (only export) +and others files. +The mechanisms of import and export are implemented via plugins, +which gives the opportunity to expand the range of available formats +by adding more plugins (for example, CATIA 5 or ACIS). \note If a plugin supports import of materials associated with shapes, these shapes are grouped corresponding to the imported materials. For the moment STEP import is the only plugin that supports this feature. -To import geometrical objects from a BREP, IGES, STEP, ACIS or STL file: +Our TUI Scripts provide you with useful examples of the use of +\ref tui_import_export_page + +\section io_import Import file + +To import geometrical objects from a BREP, IGES, STEP or STL file: \par -From the \b File menu choose \b Import. In the opening dialog box \b Import -select the required format of the file for importation and search for -a *.brep, *.iges, *.step, *.sat or *.stl file. +From the \b File menu choose Import/, where is a name +of desirable format. In the Import dialog box select the file to import +and press \b Open. The file will be imported in the module and its contents (geometrical object) +will be displayed in the Object Browser. + +The dialog box to import the file can provide additional parameters. + +For example, dialog box for importing files in STL format: \image html geomimport.png -\par -Select the required file and click \b Open. Your file will be imported in -the module and its contents (geometrical object) will be displayed in -the Object Browser. +\par -\note If the selected file is in IGES or STEP format and the length -is not expressed in meters, it will be asked whether to take or not these +\note If the selected file is in IGES or STEP format and the model size +is not expressed in meters, the user will be asked whether to take or not the units into account (see the picture below). This feature can be helpful if some wrong units have been written to the IGES or STEP file by a 3rd-party software. @@ -38,15 +48,6 @@ helpful if some wrong units have been written to the IGES or STEP file by a \par -\note If the selected file is in ACIS format (the use of this format -requires licensing) and the file contains names for some shapes, it -will be suggested to create groups by types (solid, face, edge and -vertex) for all named shapes: - -\image html sat_named_shapes.png - -\par - \note It is possible to re-open from the initial file a previously imported shape if the file has been changed on disk. For this, select Reload From Disk in the context menu of the imported @@ -55,21 +56,52 @@ as before this operation. \image html geomimport_reopen.png -\n To export geometrical objects into a BREP, IGES, STEP, ACIS or STL +\section io_export Export file + +\n To export geometrical objects into a BREP, IGES, STEP, STL or VTK file: \par Select the object you wish to export, then from the \b File menu choose -\b Export. In the opening dialog box \b Export define the required format, -the name and the location of the file for exportation. +Export/, where is a name of desirable format. +In the Export dialog box define the name and the location +of the file to export and press \b Save. + +The dialog box to export the file can provide additional advanced parameters. + +For example, dialog box for exporting files in STL format: \image html geomexport.png \par -Click \b Save to confirm your exportation. -Our TUI Scripts provide you with useful examples of the use of -\ref tui_import_export_page +\section io_xao Import and export of shapes in XAO format -*/ +XAO is a file format which describes a shape with its topology, groups and fields. + +To import a shape in the \b XAO format: + +\par +In the \b File menu select Import/XAO. + +\image html importxao_dlg.png + +\par + +To export a shape in the \b XAO format: + +\par +In the \b File menu select Export/XAO. +\image html exportxao_dlg.png + +In this dialog: +- Click the arrow button and select in the Object Browser or in the Viewer the Shape to be exported. +- Input the File name to create a new file or click browse button to save in an existing file. +- Select the \b Groups of the chosen shape to be exported. +- Select the \b Fields of the chosen shape to be exported. +- Press "Apply" or "Apply & Close" button to get the result. + +It also possible to export a shape using the TUI Command: geompy.ExportXAO(Shape, FileName, Groups, Fields) + +*/ diff --git a/doc/salome/gui/GEOM/input/index.doc b/doc/salome/gui/GEOM/input/index.doc index b3e02ee68..df3131feb 100644 --- a/doc/salome/gui/GEOM/input/index.doc +++ b/doc/salome/gui/GEOM/input/index.doc @@ -6,7 +6,7 @@ \b Geometry module of SALOME is destined for: - \subpage import_export_geom_obj_page "import and export of geometrical models" - in IGES, BREP, STEP, ACIS and STL formats; + in IGES, BREP, STEP, STL, XAO and VTK formats; - \subpage create_geom_obj_page "construction of geometrical objects" using a wide range of functions; - \subpage view_geom_obj_page "viewing geometrical objects" in the OCC diff --git a/doc/salome/gui/GEOM/input/tui_importexport_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_importexport_geom_objs.doc index b4dc9afa0..59587b825 100644 --- a/doc/salome/gui/GEOM/input/tui_importexport_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_importexport_geom_objs.doc @@ -10,7 +10,7 @@ geompy = geomBuilder.New(salome.myStudy) gg = salome.ImportComponentGUI("GEOM") # create ExportXAO object -exportxao = geompy.MakeExportXAO([value], [value], [value], [value]) +exportxao = geompy.ExportXAO([value], [value], [value], [value]) # add object in the study id_exportxao = geompy.addToStudy(exportxao,"ExportXAO") diff --git a/doc/salome/gui/GEOM/input/xao_format.doc b/doc/salome/gui/GEOM/input/xao_format.doc deleted file mode 100644 index 00d810973..000000000 --- a/doc/salome/gui/GEOM/input/xao_format.doc +++ /dev/null @@ -1,24 +0,0 @@ -/*! - -\page xao_format_page Import and export of shapes in XAO format - -XAO is a file format which describes a shape with its topology, groups and fields. - -To import a shape in the \b XAO format, in the Main Menu select New Entity -> -Import / Export -> Import XAO. - -To export a shape in the \b XAO format, in the Main Menu select New Entity -> -Import / Export -> Export XAO. - -\image html exportxao_dlg.png - -In this dialog: -- Click the arrow button and select in the Object Browser or in the Viewer the Shape to be exported. -- Input the File name to create a new file or click browse button to save in an existing file. -- Select the \b Groups of the chosen shape to be exported. -- Select the \b Fields of the chosen shape to be exported. -- Press "Apply" or "Apply & Close" button to get the result. - -It also possible to export a shape using the TUI Command: geompy.MakeExportXAO(Shape, FileName, Groups, Fields) - -*/ diff --git a/idl/AdvancedGEOM.idl b/idl/AdvancedGEOM.idl new file mode 100644 index 000000000..c82edf11f --- /dev/null +++ b/idl/AdvancedGEOM.idl @@ -0,0 +1,479 @@ +// Copyright (C) 2007-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 +// +// File : AdvancedGEOM.idl +// Author : Roman NIKOLAEV + +#ifndef __AdvancedGEOM_IDL__ +#define __AdvancedGEOM_IDL__ + +#include "GEOM_Gen.idl" + +module GEOM +{ + /*! + * \brief Pattern for block division of the disk + */ + enum pattern { + /*! Square */ + SQUARE, + /*! Hexagon */ + HEXAGON + }; + + /*! + * \brief Interface for advanced modeling functions. + */ + interface IAdvancedOperations : GEOM::GEOM_IOperations + { + // T-Shape WITHOUT Thickness reduction + + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShape (in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in boolean theHexMesh); + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeWithPosition (in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in boolean theHexMesh, + in GEOM::GEOM_Object theP1, in GEOM::GEOM_Object theP2, + in GEOM::GEOM_Object theP3); + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of the chamfer. + * \param theW Width of the chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeChamfer (in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in double theH, in double theW, in boolean theHexMesh); + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * + * A chamfer is created on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of the chamfer. + * \param theW Width of the chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeChamferWithPosition (in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in double theH, in double theW, in boolean theHexMesh, + in GEOM::GEOM_Object theP1, in GEOM::GEOM_Object theP2, + in GEOM::GEOM_Object theP3); + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * + * A fillet is created on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeFillet (in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in double theRF, in boolean theHexMesh); + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * + * A fillet is created on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeFilletWithPosition (in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in double theRF, in boolean theHexMesh, + in GEOM::GEOM_Object theP1, in GEOM::GEOM_Object theP2, + in GEOM::GEOM_Object theP3); + + // T-Shape WITH Thickness reduction + + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * + * \param theRL Internal radius of left thickness reduction + * \param theWL Width of left thickness reduction + * \param theLtransL Length of left transition part + * \param theLthinL Length of left thin part + * + * \param theRR Internal radius of right thickness reduction + * \param theWR Width of right thickness reduction + * \param theLtransR Length of right transition part + * \param theLthinR Length of right thin part + * + * \param theRI Internal radius of incident thickness reduction + * \param theWI Width of incident thickness reduction + * \param theLtransI Length of incident transition part + * \param theLthinI Length of incident thin part + * + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeTR (in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in double theRL, in double theWL, in double theLtransL, in double theLthinL, + in double theRR, in double theWR, in double theLtransR, in double theLthinR, + in double theRI, in double theWI, in double theLtransI, in double theLthinI, + in boolean theHexMesh); + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * + * \param theRL Internal radius of left thickness reduction + * \param theWL Width of left thickness reduction + * \param theLtransL Length of left transition part + * \param theLthinL Length of left thin part + * + * \param theRR Internal radius of right thickness reduction + * \param theWR Width of right thickness reduction + * \param theLtransR Length of right transition part + * \param theLthinR Length of right thin part + * + * \param theRI Internal radius of incident thickness reduction + * \param theWI Width of incident thickness reduction + * \param theLtransI Length of incident transition part + * \param theLthinI Length of incident thin part + * + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeTRWithPosition(in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in double theRL, in double theWL, in double theLtransL, in double theLthinL, + in double theRR, in double theWR, in double theLtransR, in double theLthinR, + in double theRI, in double theWI, in double theLtransI, in double theLthinI, + in boolean theHexMesh, + in GEOM::GEOM_Object theP1, in GEOM::GEOM_Object theP2, in GEOM::GEOM_Object theP3); + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * + * \param theRL Internal radius of left thickness reduction + * \param theWL Width of left thickness reduction + * \param theLtransL Length of left transition part + * \param theLthinL Length of left thin part + * + * \param theRR Internal radius of right thickness reduction + * \param theWR Width of right thickness reduction + * \param theLtransR Length of right transition part + * \param theLthinR Length of right thin part + * + * \param theRI Internal radius of incident thickness reduction + * \param theWI Width of incident thickness reduction + * \param theLtransI Length of incident transition part + * \param theLthinI Length of incident thin part + * + * \param theH Height of the chamfer. + * \param theW Width of the chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeTRChamfer(in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in double theRL, in double theWL, in double theLtransL, in double theLthinL, + in double theRR, in double theWR, in double theLtransR, in double theLthinR, + in double theRI, in double theWI, in double theLtransI, in double theLthinI, + in double theH, in double theW, in boolean theHexMesh); + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * + * A chamfer is created on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * + * \param theRL Internal radius of left thickness reduction + * \param theWL Width of left thickness reduction + * \param theLtransL Length of left transition part + * \param theLthinL Length of left thin part + * + * \param theRR Internal radius of right thickness reduction + * \param theWR Width of right thickness reduction + * \param theLtransR Length of right transition part + * \param theLthinR Length of right thin part + * + * \param theRI Internal radius of incident thickness reduction + * \param theWI Width of incident thickness reduction + * \param theLtransI Length of incident transition part + * \param theLthinI Length of incident thin part + * + * \param theH Height of the chamfer. + * \param theW Width of the chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeTRChamferWithPosition(in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in double theRL, in double theWL, in double theLtransL, in double theLthinL, + in double theRR, in double theWR, in double theLtransR, in double theLthinR, + in double theRI, in double theWI, in double theLtransI, in double theLthinI, + in double theH, in double theW, in boolean theHexMesh, + in GEOM::GEOM_Object theP1, in GEOM::GEOM_Object theP2, in GEOM::GEOM_Object theP3); + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * + * A fillet is created on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * + * \param theRL Internal radius of left thickness reduction + * \param theWL Width of left thickness reduction + * \param theLtransL Length of left transition part + * \param theLthinL Length of left thin part + * + * \param theRR Internal radius of right thickness reduction + * \param theWR Width of right thickness reduction + * \param theLtransR Length of right transition part + * \param theLthinR Length of right thin part + * + * \param theRI Internal radius of incident thickness reduction + * \param theWI Width of incident thickness reduction + * \param theLtransI Length of incident transition part + * \param theLthinI Length of incident thin part + * + * \param theRF Radius of curvature of fillet. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeTRFillet(in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in double theRL, in double theWL, in double theLtransL, in double theLthinL, + in double theRR, in double theWR, in double theLtransR, in double theLthinR, + in double theRI, in double theWI, in double theLtransI, in double theLthinI, + in double theRF, in boolean theHexMesh); + /*! + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * + * A fillet is created on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * + * \param theRL Internal radius of left thickness reduction + * \param theWL Width of left thickness reduction + * \param theLtransL Length of left transition part + * \param theLthinL Length of left thin part + * + * \param theRR Internal radius of right thickness reduction + * \param theWR Width of right thickness reduction + * \param theLtransR Length of right transition part + * \param theLthinR Length of right thin part + * + * \param theRI Internal radius of incident thickness reduction + * \param theWI Width of incident thickness reduction + * \param theLtransI Length of incident transition part + * \param theLthinI Length of incident thin part + * + * \param theRF Radius of curvature of fillet. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Object, containing the created shape and propagation groups. + */ + GEOM::ListOfGO MakePipeTShapeTRFilletWithPosition(in double theR1, in double theW1, in double theL1, + in double theR2, in double theW2, in double theL2, + in double theRL, in double theWL, in double theLtransL, in double theLthinL, + in double theRR, in double theWR, in double theLtransR, in double theLthinR, + in double theRI, in double theWI, in double theLtransI, in double theLthinI, + in double theRF, in boolean theHexMesh, + in GEOM::GEOM_Object theP1, in GEOM::GEOM_Object theP2, + in GEOM::GEOM_Object theP3); + + /*! + * This function allows to create a disk already divided into blocks. It + * can be use to create divided pipes for later meshing in hexaedra. + * \param theR Radius of the disk + * \param theRatio Relative size of the central square diagonal against the disk diameter + * \param theOrientation Plane on which the disk will be built + * \param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + * \return New GEOM_Object, containing the created shape. + */ + GEOM::GEOM_Object MakeDividedDisk (in double theR, + in double theRatio, + in short theOrientation, + in GEOM::pattern thePattern); + + /*! + * \brief Create a Disk prepared for hexa meshing with given center, normal vector and radius. + * \param thePnt disk center. + * \param theVec Vector, normal to the plane of the disk. + * \param theR Disk radius. + * \param theRatio Relative size of the central square diagonal against the disk diameter + * \param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + * \return New GEOM_Object, containing the created disk. + */ + GEOM::GEOM_Object MakeDividedDiskPntVecR ( in GEOM::GEOM_Object thePnt, + in GEOM::GEOM_Object theVec, + in double theR, + in double theRatio, + in GEOM::pattern thePattern); + + /*! + * Builds a cylinder prepared for hexa meshes + * \param theR Radius of the cylinder + * \param theH Height of the cylinder + * \param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + * \return New GEOM_Object, containing the created shape. + */ + GEOM::GEOM_Object MakeDividedCylinder (in double theR, + in double theH, + in GEOM::pattern thePattern ); + /*! + * + * Create a smoothing surface from a set of points + * \param thelPoints list of points. Compounds of ggpoints are accepted as well. + * \param theNbMax maximum number of Bezier pieces in the resulting surface. + * \param theDegMax maximum degree of the resulting BSpline surface + * \param theDMax specifies maximum value of the GeomPlate_PlateG0Criterion criterion. + * \return New GEOM_Object, containing the created shape. + */ + GEOM::GEOM_Object MakeSmoothingSurface (in GEOM::ListOfGO thelPoints, + in long theNbMax, + in long theDegMax, + in double theDMax); + + /*@@ insert new functions before this line @@ do not remove this line @@*/ + }; +}; + +#endif // __AdvancedGEOM_IDL__ diff --git a/idl/BREPPlugin.idl b/idl/BREPPlugin.idl new file mode 100644 index 000000000..c5e59715f --- /dev/null +++ b/idl/BREPPlugin.idl @@ -0,0 +1,51 @@ +// 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 __BREPPlugin_IDL__ +#define __BREPPlugin_IDL__ + +#include "GEOM_Gen.idl" + +module GEOM +{ + /*! + * \brief Interface for BREPPlugin modeling functions. + */ + interface IBREPOperations : GEOM::GEOM_IOperations + { + /*! + * \brief Export the given shape into a file with given name in BREP format. + * + * \param theObject Shape to be stored in the file. + * \param theFileName Name of the file to store the given shape in. + */ + void ExportBREP( in GEOM::GEOM_Object theObject, + in string theFileName ); + + /*! + * \brief Import a shape from the BREP file. + * + * \param theFileName The file, containing the shape. + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ + GEOM::ListOfGO ImportBREP( in string theFileName ); + }; +}; + +#endif // __BREPPlugin_IDL__ diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index bdc32d9cf..e8ebb6082 100755 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -32,9 +32,40 @@ ENDIF(WIN32) SET(SalomeIDLGEOM_IDLSOURCES GEOM_Gen.idl +) + +SET(SalomeIDLGEOMSuperv_IDLSOURCES GEOM_Superv.idl ) +SET(SalomeIDLAdvancedGEOM_IDLSOURCES + AdvancedGEOM.idl +) + +SET(SalomeIDLSTLPlugin_IDLSOURCES + STLPlugin.idl +) + +SET(SalomeIDLBREPPlugin_IDLSOURCES + BREPPlugin.idl +) + +SET(SalomeIDLSTEPPlugin_IDLSOURCES + STEPPlugin.idl +) + +SET(SalomeIDLIGESPlugin_IDLSOURCES + IGESPlugin.idl +) + +SET(SalomeIDLXAOPlugin_IDLSOURCES + XAOPlugin.idl +) + +SET(SalomeIDLVTKPlugin_IDLSOURCES + VTKPlugin.idl +) + SET(IDL_INCLUDE_DIRS ${KERNEL_ROOT_DIR}/idl/salome ${CMAKE_CURRENT_SOURCE_DIR} @@ -45,3 +76,35 @@ SET(IDL_LINK_FLAGS OMNIORB_ADD_MODULE(SalomeIDLGEOM "${SalomeIDLGEOM_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_FLAGS}") INSTALL(TARGETS SalomeIDLGEOM EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLAdvancedGEOM "${SalomeIDLAdvancedGEOM_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_FLAGS}") +ADD_DEPENDENCIES(SalomeIDLAdvancedGEOM SalomeIDLGEOM) +INSTALL(TARGETS SalomeIDLAdvancedGEOM EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLSTLPlugin "${SalomeIDLSTLPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_FLAGS}") +ADD_DEPENDENCIES(SalomeIDLSTLPlugin SalomeIDLGEOM) +INSTALL(TARGETS SalomeIDLSTLPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLBREPPlugin "${SalomeIDLBREPPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_FLAGS}") +ADD_DEPENDENCIES(SalomeIDLBREPPlugin SalomeIDLGEOM) +INSTALL(TARGETS SalomeIDLBREPPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLSTEPPlugin "${SalomeIDLSTEPPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_FLAGS}") +ADD_DEPENDENCIES(SalomeIDLSTEPPlugin SalomeIDLGEOM) +INSTALL(TARGETS SalomeIDLSTEPPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLIGESPlugin "${SalomeIDLIGESPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_FLAGS}") +ADD_DEPENDENCIES(SalomeIDLIGESPlugin SalomeIDLGEOM) +INSTALL(TARGETS SalomeIDLIGESPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLXAOPlugin "${SalomeIDLXAOPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_FLAGS}") +ADD_DEPENDENCIES(SalomeIDLXAOPlugin SalomeIDLGEOM) +INSTALL(TARGETS SalomeIDLXAOPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLVTKPlugin "${SalomeIDLVTKPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_FLAGS}") +ADD_DEPENDENCIES(SalomeIDLVTKPlugin SalomeIDLGEOM) +INSTALL(TARGETS SalomeIDLVTKPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLGEOMSuperv "${SalomeIDLGEOMSuperv_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_FLAGS}") +ADD_DEPENDENCIES(SalomeIDLGEOMSuperv SalomeIDLGEOM SalomeIDLAdvancedGEOM) +INSTALL(TARGETS SalomeIDLGEOMSuperv EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 86b959374..149bf9674 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -177,19 +177,6 @@ module GEOM Interpolation }; - /*! - * \brief Pattern for block division of the disk - * - * Used in the functions GEOM_IAdvancedOperations.MakeDividedDisk(), GEOM_ICurvesOperations.MakeDividedDiskPntVecR() - */ - enum pattern { - /*! Square */ - SQUARE, - - /*! Hexagon */ - HEXAGON - }; - /*! * \brief Type of field data */ @@ -3710,20 +3697,24 @@ module GEOM GEOM_Object MakeCopy (in GEOM_Object theOriginal); /*! + * \brief Deprecated method. Use Export (from the + * corresponding plugin) instead; here is a name of format. + * * \brief Export the given shape into a file with given name. * \param theObject Shape to be stored in the file. * \param theFileName Name of the file to store the given shape in. * \param theFormatName Specify format for the shape storage. - * Available formats can be obtained with ImportTranslators() method. */ void Export (in GEOM_Object theObject, in string theFileName, in string theFormatName); /*! - * \brief Import a shape from the BRep or IGES or STEP file + * \brief Deprecated method. Use Import (from the + * corresponding plugin) instead; here is a name of format. + * + * \brief Import a shape from the STL, BREP, IGES or STEP file * (depends on given format) with given name. * \param theFileName The file, containing the shape. * \param theFormatName Specify format for the file reading. - * Available formats can be obtained with ImportTranslators() method. * If format 'IGES_SCALE' is used instead of 'IGES' or * format 'STEP_SCALE' is used instead of 'STEP', * file length unit will be ignored (set to 'meter') and result model will be scaled. @@ -3732,34 +3723,17 @@ module GEOM ListOfGO ImportFile (in string theFileName, in string theFormatName); /*! + * \brief Deprecated method. Use ReadValue (from the corresponding plugin) instead. + * * \brief Read a value of parameter from a file, containing a shape. * \param theFileName The file, containing the shape. * \param theFormatName Specify format for the file reading. - * Available formats can be obtained with ImportTranslators() method. * \param theParameterName Specify the parameter. For example, pass "LEN_UNITS" * to obtain length units, in which the file is written. * \return Value of requested parameter in form of text string. */ string ReadValue (in string theFileName, in string theFormatName, in string theParameterName); - /*! - * \brief Get the supported import formats and corresponding patterns for File dialog. - * \param theFormats Output. List of formats, available for import. - * \param thePatterns Output. List of file patterns, corresponding to available formats. - * \return Returns available formats and patterns through the arguments. - */ - void ImportTranslators (out string_array theFormats, - out string_array thePatterns); - - /*! - * \brief Get the supported export formats and corresponding patterns for File dialog. - * \param theFormats Output. List of formats, available for export. - * \param thePatterns Output. List of file patterns, corresponding to available formats. - * \return Returns available formats and patterns through the arguments. - */ - void ExportTranslators (out string_array theFormats, - out string_array thePatterns); - /*! * \brief Read a shape from the binary stream, containing its bounding representation (BRep). * \note GEOM_Object::GetShapeStream() method can be used to obtain the shape's BRep stream. @@ -3798,31 +3772,7 @@ module GEOM * \return list of all texture IDs avaiable for the current study */ ListOfLong GetAllTextures(); - - /*! - * Export a shape to XAO format - * \param shape The shape to export - * \param groups The list of groups to export - * \param fields The list of fields to export - * \param author The author of the export - * \param fileName The name of the file to export - * \return boolean indicating if export was successful. - */ - boolean ExportXAO(in GEOM_Object shape, - in ListOfGO groups, in ListOfFields fields, - in string author, in string fileName); - /*! - * Import a shape from XAO format - * \param fileName The name of the file to import - * \param shape The imported shape - * \param subShapes The list of imported subShapes - * \param groups The list of imported groups - * \param fields The list of imported fields - * \return boolean indicating if import was successful. - */ - boolean ImportXAO(in string fileName, out GEOM_Object shape, - out ListOfGO subShapes, out ListOfGO groups, out ListOfFields fields); }; // # GEOM_IKindOfShape: @@ -4391,448 +4341,7 @@ module GEOM ListOfLong GetObjects (in GEOM_Object theGroup); }; - // # GEOM_IAdvancedOperations: - /*! - * \brief Interface for advanced modeling functions. - */ - interface GEOM_IAdvancedOperations : GEOM_IOperations - { - // T-Shape WITHOUT Thickness reduction - - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShape (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in boolean theHexMesh); - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeWithPosition (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in boolean theHexMesh, - in GEOM_Object theP1, in GEOM_Object theP2, in GEOM_Object theP3); - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of the chamfer. - * \param theW Width of the chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeChamfer (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in double theH, in double theW, in boolean theHexMesh); - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * - * A chamfer is created on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of the chamfer. - * \param theW Width of the chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeChamferWithPosition (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in double theH, in double theW, in boolean theHexMesh, - in GEOM_Object theP1, in GEOM_Object theP2, in GEOM_Object theP3); - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * - * A fillet is created on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeFillet (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in double theRF, in boolean theHexMesh); - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * - * A fillet is created on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeFilletWithPosition (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in double theRF, in boolean theHexMesh, - in GEOM_Object theP1, in GEOM_Object theP2, in GEOM_Object theP3); - - // T-Shape WITH Thickness reduction - - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * - * \param theRL Internal radius of left thickness reduction - * \param theWL Width of left thickness reduction - * \param theLtransL Length of left transition part - * \param theLthinL Length of left thin part - * - * \param theRR Internal radius of right thickness reduction - * \param theWR Width of right thickness reduction - * \param theLtransR Length of right transition part - * \param theLthinR Length of right thin part - * - * \param theRI Internal radius of incident thickness reduction - * \param theWI Width of incident thickness reduction - * \param theLtransI Length of incident transition part - * \param theLthinI Length of incident thin part - * - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeTR (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in double theRL, in double theWL, in double theLtransL, in double theLthinL, - in double theRR, in double theWR, in double theLtransR, in double theLthinR, - in double theRI, in double theWI, in double theLtransI, in double theLthinI, - in boolean theHexMesh); - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * - * \param theRL Internal radius of left thickness reduction - * \param theWL Width of left thickness reduction - * \param theLtransL Length of left transition part - * \param theLthinL Length of left thin part - * - * \param theRR Internal radius of right thickness reduction - * \param theWR Width of right thickness reduction - * \param theLtransR Length of right transition part - * \param theLthinR Length of right thin part - * - * \param theRI Internal radius of incident thickness reduction - * \param theWI Width of incident thickness reduction - * \param theLtransI Length of incident transition part - * \param theLthinI Length of incident thin part - * - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeTRWithPosition - (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in double theRL, in double theWL, in double theLtransL, in double theLthinL, - in double theRR, in double theWR, in double theLtransR, in double theLthinR, - in double theRI, in double theWI, in double theLtransI, in double theLthinI, - in boolean theHexMesh, - in GEOM_Object theP1, in GEOM_Object theP2, in GEOM_Object theP3); - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * - * \param theRL Internal radius of left thickness reduction - * \param theWL Width of left thickness reduction - * \param theLtransL Length of left transition part - * \param theLthinL Length of left thin part - * - * \param theRR Internal radius of right thickness reduction - * \param theWR Width of right thickness reduction - * \param theLtransR Length of right transition part - * \param theLthinR Length of right thin part - * - * \param theRI Internal radius of incident thickness reduction - * \param theWI Width of incident thickness reduction - * \param theLtransI Length of incident transition part - * \param theLthinI Length of incident thin part - * - * \param theH Height of the chamfer. - * \param theW Width of the chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeTRChamfer - (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in double theRL, in double theWL, in double theLtransL, in double theLthinL, - in double theRR, in double theWR, in double theLtransR, in double theLthinR, - in double theRI, in double theWI, in double theLtransI, in double theLthinI, - in double theH, in double theW, in boolean theHexMesh); - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * - * A chamfer is created on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * - * \param theRL Internal radius of left thickness reduction - * \param theWL Width of left thickness reduction - * \param theLtransL Length of left transition part - * \param theLthinL Length of left thin part - * - * \param theRR Internal radius of right thickness reduction - * \param theWR Width of right thickness reduction - * \param theLtransR Length of right transition part - * \param theLthinR Length of right thin part - * - * \param theRI Internal radius of incident thickness reduction - * \param theWI Width of incident thickness reduction - * \param theLtransI Length of incident transition part - * \param theLthinI Length of incident thin part - * - * \param theH Height of the chamfer. - * \param theW Width of the chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeTRChamferWithPosition - (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in double theRL, in double theWL, in double theLtransL, in double theLthinL, - in double theRR, in double theWR, in double theLtransR, in double theLthinR, - in double theRI, in double theWI, in double theLtransI, in double theLthinI, - in double theH, in double theW, in boolean theHexMesh, - in GEOM_Object theP1, in GEOM_Object theP2, in GEOM_Object theP3); - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * - * A fillet is created on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * - * \param theRL Internal radius of left thickness reduction - * \param theWL Width of left thickness reduction - * \param theLtransL Length of left transition part - * \param theLthinL Length of left thin part - * - * \param theRR Internal radius of right thickness reduction - * \param theWR Width of right thickness reduction - * \param theLtransR Length of right transition part - * \param theLthinR Length of right thin part - * - * \param theRI Internal radius of incident thickness reduction - * \param theWI Width of incident thickness reduction - * \param theLtransI Length of incident transition part - * \param theLthinI Length of incident thin part - * - * \param theRF Radius of curvature of fillet. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeTRFillet - (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in double theRL, in double theWL, in double theLtransL, in double theLthinL, - in double theRR, in double theWR, in double theLtransR, in double theLthinR, - in double theRI, in double theWI, in double theLtransI, in double theLthinI, - in double theRF, in boolean theHexMesh); - /*! - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * - * A fillet is created on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * - * \param theRL Internal radius of left thickness reduction - * \param theWL Width of left thickness reduction - * \param theLtransL Length of left transition part - * \param theLthinL Length of left thin part - * - * \param theRR Internal radius of right thickness reduction - * \param theWR Width of right thickness reduction - * \param theLtransR Length of right transition part - * \param theLthinR Length of right thin part - * - * \param theRI Internal radius of incident thickness reduction - * \param theWI Width of incident thickness reduction - * \param theLtransI Length of incident transition part - * \param theLthinI Length of incident thin part - * - * \param theRF Radius of curvature of fillet. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=true) - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Object, containing the created shape and propagation groups. - */ - ListOfGO MakePipeTShapeTRFilletWithPosition - (in double theR1, in double theW1, in double theL1, - in double theR2, in double theW2, in double theL2, - in double theRL, in double theWL, in double theLtransL, in double theLthinL, - in double theRR, in double theWR, in double theLtransR, in double theLthinR, - in double theRI, in double theWI, in double theLtransI, in double theLthinI, - in double theRF, in boolean theHexMesh, - in GEOM_Object theP1, in GEOM_Object theP2, in GEOM_Object theP3); - - /*! - * This function allows to create a disk already divided into blocks. It - * can be use to create divided pipes for later meshing in hexaedra. - * \param theR Radius of the disk - * \param theRatio Relative size of the central square diagonal against the disk diameter - * \param theOrientation Plane on which the disk will be built - * \param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON - * \return New GEOM_Object, containing the created shape. - */ - GEOM_Object MakeDividedDisk (in double theR, - in double theRatio, - in short theOrientation, - in pattern thePattern); - - /*! - * \brief Create a Disk prepared for hexa meshing with given center, normal vector and radius. - * \param thePnt disk center. - * \param theVec Vector, normal to the plane of the disk. - * \param theR Disk radius. - * \param theRatio Relative size of the central square diagonal against the disk diameter - * \param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON - * \return New GEOM_Object, containing the created disk. - */ - GEOM_Object MakeDividedDiskPntVecR ( in GEOM_Object thePnt, - in GEOM_Object theVec, - in double theR, - in double theRatio, - in pattern thePattern); - - /*! - * Builds a cylinder prepared for hexa meshes - * \param theR Radius of the cylinder - * \param theH Height of the cylinder - * \param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON - * \return New GEOM_Object, containing the created shape. - */ - GEOM_Object MakeDividedCylinder (in double theR, - in double theH, - in pattern thePattern ); - /*! - * - * Create a smoothing surface from a set of points - * \param thelPoints list of points. Compounds of points are accepted as well. - * \param theNbMax maximum number of Bezier pieces in the resulting surface. - * \param theDegMax maximum degree of the resulting BSpline surface - * \param theDMax specifies maximum value of the GeomPlate_PlateG0Criterion criterion. - * \return New GEOM_Object, containing the created shape. - */ - GEOM_Object MakeSmoothingSurface (in ListOfGO thelPoints, - in long theNbMax, - in long theDegMax, - in double theDMax); - - /*@@ insert new functions before this line @@ do not remove this line @@*/ - }; - - // # GEOM_IFieldOperations: + // # GEOM_IFieldOperations: /*! * \brief Interface for field operation. */ diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 7787ff4cc..3bf0fea3f 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -26,6 +26,7 @@ #define __GEOM_SUPERV__ #include "GEOM_Gen.idl" +#include "AdvancedGEOM.idl" module GEOM { @@ -272,15 +273,6 @@ module GEOM GEOM_Object MakeCopy (in GEOM_Object theOriginal) ; void Export (in GEOM_Object theObject, in string theFileName, in string theFormatName) ; GEOM_Object ImportFile (in string theFileName, in string theFormatName) ; - void ImportTranslators (out string_array theFormats, - out string_array thePatterns) ; - void ExportTranslators (out string_array theFormats, - out string_array thePatterns) ; - boolean ExportXAO(in GEOM_Object shape, - in ListOfGO groups, in ListOfFields fields, - in string author, in string fileName); - boolean ImportXAO(in string fileName, out GEOM_Object shape, - out ListOfGO subShapes, out ListOfGO groups, out ListOfFields fields); //-----------------------------------------------------------// // TransformOperations // @@ -643,6 +635,46 @@ module GEOM in pattern thePattern); GEOM_Object MakeSmoothingSurface (in GEOM_List thelPoints); + + //-----------------------------------------------------------// + // Import/Export Operations // + //-----------------------------------------------------------// + void ExportSTL( in GEOM::GEOM_Object theObject, + in string theFileName, + in boolean theIsASCII, + in double theDeflection, + in boolean theIsRelative ); + GEOM_Object ImportSTL( in string theFileName ); + + void ExportBREP( in GEOM::GEOM_Object theObject, + in string theFileName ); + GEOM_Object ImportBREP( in string theFileName ); + + void ExportSTEP( in GEOM::GEOM_Object theObject, + in string theFileName ); + GEOM_Object ImportSTEP( in string theFileName, + in boolean theIsIgnoreUnits ); + + void ExportIGES( in GEOM::GEOM_Object theObject, + in string theFileName, + in string theVersion ); + GEOM_Object ImportIGES( in string theFileName, + in boolean theIsIgnoreUnits ); + + boolean ExportXAO( in GEOM_Object shape, + in ListOfGO groups, + in ListOfFields fields, + in string author, + in string fileName ); + boolean ImportXAO( in string fileName, + out GEOM_Object shape, + out ListOfGO subShapes, + out ListOfGO groups, + out ListOfFields fields ); + + void ExportVTK( in GEOM::GEOM_Object theObject, + in string theFileName, + in double theDeflection ); /*@@ insert new functions before this line @@ do not remove this line @@*/ }; diff --git a/idl/IGESPlugin.idl b/idl/IGESPlugin.idl new file mode 100644 index 000000000..e7d858b95 --- /dev/null +++ b/idl/IGESPlugin.idl @@ -0,0 +1,67 @@ +// 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 __IGESPlugin_IDL__ +#define __IGESPlugin_IDL__ + +#include "GEOM_Gen.idl" + +module GEOM +{ + /*! + * \brief Interface for IGESPlugin modeling functions. + */ + interface IIGESOperations : GEOM::GEOM_IOperations + { + /*! + * \brief Export the given shape into a file with given name in IGES format. + * + * \param theObject Shape to be stored in the file. + * \param theFileName Name of the file to store the given shape in. + * \param theVersion Version of IGES format which defines, whether to write + * only faces (5.1 IGES format) or shells and solids also (5.3 IGES format). + */ + void ExportIGES( in GEOM::GEOM_Object theObject, + in string theFileName, + in string theVersion ); + + /*! + * \brief Import a shape from the IGES file. + * + * \param theFileName The file, containing the shape. + * \param theIsIgnoreUnits If True, file length units will be ignored (set to 'meter') + * and result model will be scaled, if its units are not meters. + * If False (default), file length units will be taken into account. + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ + GEOM::ListOfGO ImportIGES( in string theFileName, + in boolean theIsIgnoreUnits ); + + /*! + * \brief Read a value of parameter from a file, containing a shape. + * \param theFileName The file, containing the shape. + * \param theParameterName Specify the parameter. For example, pass "LEN_UNITS" + * to obtain length units, in which the file is written. + * \return Value of requested parameter in form of text string. + */ + string ReadValue( in string theFileName, in string theParameterName); + }; +}; + +#endif // __IGESPlugin_IDL__ diff --git a/idl/STEPPlugin.idl b/idl/STEPPlugin.idl new file mode 100644 index 000000000..8021e6664 --- /dev/null +++ b/idl/STEPPlugin.idl @@ -0,0 +1,66 @@ +// 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 __STEPPlugin_IDL__ +#define __STEPPlugin_IDL__ + +#include "GEOM_Gen.idl" + +module GEOM +{ + /*! + * \brief Interface for STEPPlugin modeling functions. + */ + interface ISTEPOperations : GEOM::GEOM_IOperations + { + /*! + * \brief Export the given shape into a file with given name in STEP format. + * + * \param theObject Shape to be stored in the file. + * \param theFileName Name of the file to store the given shape in. + */ + void ExportSTEP( in GEOM::GEOM_Object theObject, + in string theFileName ); + + /*! + * \brief Import a shape from the STEP file. + * + * \param theFileName The file, containing the shape. + * \param theIsIgnoreUnits If True, file length units will be ignored (set to 'meter') + * and result model will be scaled, if its units are not meters. + * If False (default), file length units will be taken into account. + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ + GEOM::ListOfGO ImportSTEP( in string theFileName, + in boolean theIsIgnoreUnits ); + + /*! + * \brief Read a value of parameter from a file, containing a shape. + * \param theFileName The file, containing the shape. + * \param theParameterName Specify the parameter. For example, pass "LEN_UNITS" + * to obtain length units, in which the file is written. + * \return Value of requested parameter in form of text string. + */ + string ReadValue( in string theFileName, + in string theParameterName ); + + }; +}; + +#endif // __STEPPlugin_IDL__ diff --git a/idl/STLPlugin.idl b/idl/STLPlugin.idl new file mode 100644 index 000000000..7c8f82531 --- /dev/null +++ b/idl/STLPlugin.idl @@ -0,0 +1,59 @@ +// 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 __STLPlugin_IDL__ +#define __STLPlugin_IDL__ + +#include "GEOM_Gen.idl" + +module GEOM +{ + /*! + * \brief Interface for STLPlugin modeling functions. + */ + interface ISTLOperations : GEOM::GEOM_IOperations + { + /*! + * \brief Export the given shape into a file with given name in STL format. + * + * \param theObject Shape to be stored in the file. + * \param theFileName Name of the file to store the given shape in. + * \param theIsASCII The format of the exported file (ASCII or Binary). + * \param theDeflection Deflection of the given shape. + * \param theIsRelative Mode for writing the file. If True (default value), the + * deflection is calculated from the relative size of the + * shape; if False, the user defined deflection is used. + */ + void ExportSTL( in GEOM::GEOM_Object theObject, + in string theFileName, + in boolean theIsASCII, + in double theDeflection, + in boolean theIsRelative ); + + /*! + * \brief Import a shape from the STL file. + * + * \param theFileName The file, containing the shape. + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ + GEOM::ListOfGO ImportSTL( in string theFileName ); + }; +}; + +#endif // __STLPlugin_IDL__ diff --git a/idl/VTKPlugin.idl b/idl/VTKPlugin.idl new file mode 100644 index 000000000..2b5aa47de --- /dev/null +++ b/idl/VTKPlugin.idl @@ -0,0 +1,45 @@ +// 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 __VTKPlugin_IDL__ +#define __VTKPlugin_IDL__ + +#include "GEOM_Gen.idl" + +module GEOM +{ + /*! + * \brief Interface for VTKPlugin modeling functions. + */ + interface IVTKOperations : GEOM::GEOM_IOperations + { + /*! + * \brief Export the given shape into a file with given name in VTK format. + * + * \param theObject Shape to be stored in the file. + * \param theFileName Name of the file to store the given shape in. + * \param theDeflection Deflection of the given shape. + */ + void ExportVTK( in GEOM::GEOM_Object theObject, + in string theFileName, + in double theDeflection ); + }; +}; + +#endif // __VTKPlugin_IDL__ diff --git a/idl/XAOPlugin.idl b/idl/XAOPlugin.idl new file mode 100644 index 000000000..c382fd3d9 --- /dev/null +++ b/idl/XAOPlugin.idl @@ -0,0 +1,64 @@ +// 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 __XAOPlugin_IDL__ +#define __XAOPlugin_IDL__ + +#include "GEOM_Gen.idl" + +module GEOM +{ + /*! + * \brief Interface for XAOPlugin modeling functions. + */ + interface IXAOOperations : GEOM::GEOM_IOperations + { + /*! + * Export a shape to XAO format + * \param shape The shape to export + * \param groups The list of groups to export + * \param fields The list of fields to export + * \param author The author of the export + * \param fileName The name of the file to export + * \return boolean indicating if export was successful. + */ + boolean ExportXAO( in GEOM::GEOM_Object shape, + in GEOM::ListOfGO groups, + in GEOM::ListOfFields fields, + in string author, + in string fileName ); + + /*! + * Import a shape from XAO format + * \param fileName The name of the file to import + * \param shape The imported shape + * \param subShapes The list of imported subShapes + * \param groups The list of imported groups + * \param fields The list of imported fields + * \return boolean indicating if import was successful. + */ + boolean ImportXAO( in string fileName, + out GEOM::GEOM_Object shape, + out GEOM::ListOfGO subShapes, + out GEOM::ListOfGO groups, + out GEOM::ListOfFields fields ); + }; +}; + +#endif // __XAOPlugin_IDL__ diff --git a/resources/AdvancedGEOM.xml b/resources/AdvancedGEOM.xml new file mode 100644 index 000000000..1d6fda98d --- /dev/null +++ b/resources/AdvancedGEOM.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/BREPPlugin.xml b/resources/BREPPlugin.xml new file mode 100644 index 000000000..5b7c97167 --- /dev/null +++ b/resources/BREPPlugin.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 6097008d8..1fa4e9d9d 100755 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -23,12 +23,17 @@ # These files are data, module or lib files SET( _res_files - GEOMActions.xml + AdvancedGEOM.xml + STLPlugin.xml + BREPPlugin.xml + STEPPlugin.xml + IGESPlugin.xml + XAOPlugin.xml + VTKPlugin.xml GEOM_en.xml GEOM_fr.xml GEOM.config GEOMDS_Resources - ImportExport ShHealing 3dsketch.png isoline.png diff --git a/resources/GEOMActions.xml b/resources/GEOMActions.xml deleted file mode 100644 index 7dc5adee6..000000000 --- a/resources/GEOMActions.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/GEOMCatalog.xml.in b/resources/GEOMCatalog.xml.in index 7ac41f313..bb07e4de7 100644 --- a/resources/GEOMCatalog.xml.in +++ b/resources/GEOMCatalog.xml.in @@ -26,5477 +26,7164 @@ - + + + - - + + + + + + + GEOM/GEOM_BaseObject + + + GEOM/GEOM_BaseObject + + + GEOM/GEOM_BaseObject + + + GEOM/GEOM_FieldStep + + + GEOM/GEOM_FieldStep + + + GEOM/GEOM_FieldStep + + + GEOM/GEOM_FieldStep + + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + GEOM/GEOM_IOperations + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - GEOM - Geometry - Geom - NRI - @SALOMEGEOM_VERSION@ - Geometry component - 1 - ModuleGeom.png - 1 + + + + + + + + + + + + - - - - GEOM - No comment + + - - - - - Undo - - - - 1 - - - - theStudyID - long - - - - - - - - - Redo - - - - 1 - - - - theStudyID - long - - - - - - - - - AddInStudy - - - - 1 - - - - theStudy - Study - - - - theObject - GEOM_Object - - - - theName - string - - - - theFather - GEOM_Object - - - - - - return - SObject - - - - - - - - GetIBasicOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_IBasicOperations - - - - - - - - GetITransformOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_ITransformOperations - - - - - - - - GetI3DPrimOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_I3DPrimOperations - - - - - - - - GetIShapesOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_IShapesOperations - - - - - - - - GetIBooleanOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_IBooleanOperations - - - - - - - - GetICurvesOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_ICurvesOperations - - - - - - - - GetILocalOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_ILocalOperations - - - - - - - - GetIHealingOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_IHealingOperations - - - - - - - - GetIInsertOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_IInsertOperations - - - - - - - - GetIMeasureOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_IMeasureOperations - - - - - - - - GetIBlocksOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_IBlocksOperations - - - - - - - - GetIGroupOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_IGroupOperations - - - - - - - - GetIAdvancedOperations - - - - 1 - - - - theStudyID - long - - - - - - return - GEOM_IAdvancedOperations - - - - - - - - RemoveObject - - - - 1 - - - - theObject - GEOM_Object - - - - - - - - - GetObject - - - - 1 - - - - theStudyID - long - - - - theEntry - string - - - - - - return - GEOM_Object - - - - - - - - AddSubShape - - - - 1 - - - - theMainShape - GEOM_Object - - - - theIndices - ListOfLong - - - - - - return - GEOM_Object - - - - - - - - GetIORFromString - - - - 1 - - - - ior - string - - - - - - return - GEOM_Object - - - - - - - - GetStringFromIOR - - - - 1 - - - - theObject - GEOM_Object - - - - - - return - string - - - - - - - GetDumpName - - - unknown - 0 - - - theStudyEntry - string - unknown - - - - - return - string - unknown - - - - - - GetAllDumpNames - - - unknown - 0 - - - - return - string_array - unknown - - - - - - - hostname = localhost + + + + + + + + + + + + + GEOM + Geometry + GEOM + SALOME team + @SALOMEGEOM_VERSION@ + CAD modeler + 1 + ModuleGeom.png + 1 + + + + + GEOM/GEOM_Gen + GEOM module engine + + + + Undo + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + + + Redo + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + + + AddInStudy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudy + Study + unknown + + + theObject + GEOM/GEOM_BaseObject + unknown + + + theName + string + unknown + + + theFather + GEOM/GEOM_BaseObject + unknown + + + + + return + SObject + unknown + + + + + + RestoreSubShapesO + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudy + Study + unknown + + + theObject + GEOM/GEOM_Object + unknown + + + theArgs + GEOM/ListOfGO + unknown + + + theFindMethod + GEOM/find_shape_method + unknown + + + theInheritFirstArg + boolean + unknown + + + theAddPrefix + boolean + unknown + + + + + return + GEOM/ListOfGO + unknown + + + + + + RestoreGivenSubShapesO + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudy + Study + unknown + + + theObject + GEOM/GEOM_Object + unknown + + + theArgs + GEOM/ListOfGO + unknown + + + theFindMethod + GEOM/find_shape_method + unknown + + + theInheritFirstArg + boolean + unknown + + + theAddPrefix + boolean + unknown + + + + + return + GEOM/ListOfGO + unknown + + + + + + RestoreSubShapesSO + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudy + Study + unknown + + + theSObject + SObject + unknown + + + theArgs + GEOM/ListOfGO + unknown + + + theFindMethod + GEOM/find_shape_method + unknown + + + theInheritFirstArg + boolean + unknown + + + theAddPrefix + boolean + unknown + + + + + return + GEOM/ListOfGO + unknown + + + + + + GetIBasicOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_IBasicOperations + unknown + + + + + + GetITransformOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_ITransformOperations + unknown + + + + + + GetI3DPrimOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_I3DPrimOperations + unknown + + + + + + GetIShapesOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_IShapesOperations + unknown + + + + + + GetIBooleanOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_IBooleanOperations + unknown + + + + + + GetICurvesOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_ICurvesOperations + unknown + + + + + + GetILocalOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_ILocalOperations + unknown + + + + + + GetIHealingOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_IHealingOperations + unknown + + + + + + GetIInsertOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_IInsertOperations + unknown + + + + + + GetIMeasureOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_IMeasureOperations + unknown + + + + + + GetIBlocksOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_IBlocksOperations + unknown + + + + + + GetIGroupOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_IGroupOperations + unknown + + + + + + GetIFieldOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + return + GEOM/GEOM_IFieldOperations + unknown + + + + + + GetPluginOperations + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + theLibName + string + unknown + + + + + return + GEOM/GEOM_IOperations + unknown + + + + + + RemoveObject + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_BaseObject + unknown + + + + + + + GetObject + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + theEntry + string + unknown + + + + + return + GEOM/GEOM_BaseObject + unknown + + + + + + AddSubShape + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theMainShape + GEOM/GEOM_Object + unknown + + + theIndices + GEOM/ListOfLong + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetIORFromString + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theIOR + string + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetStringFromIOR + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + + + return + string + unknown + + + + + + GetDumpName + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyEntry + string + unknown + + + + + return + string + unknown + + + + + + GetAllDumpNames + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + + return + GEOM/string_array + unknown + + + + + + PublishNamedShapesInStudy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudy + Study + unknown + + + theObject + Object + unknown + + + + + return + GEOM/ListOfGO + unknown + + + + + + CreateFolder + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theName + string + unknown + + + theFather + SObject + unknown + + + + + return + SObject + unknown + + + + + + MoveToFolder + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theFolder + SObject + unknown + + + + + + + MoveListToFolder + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theListOfGO + GEOM/ListOfGO + unknown + + + theFolder + SObject + unknown + + + + + + + Move + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + what + GEOM/object_list + unknown + + + where + SObject + unknown + + + row + long + unknown + + + + + + + - + - GEOM_Superv - GEOM_Superv - OTHER - - @SALOMEGEOM_VERSION@ - Supervision wrapper for Geometry component - 1 - 1 - - - - GEOM_Superv - unknown - - - SetStudyID - - - unknown - 0 - - - theStudyID - long - unknown - - - - - - - CreateListOfGO - - - unknown - 0 - - - - return - GEOM_List - unknown - - - - - - AddItemToListOfGO - - - unknown - 0 - - - theList - GEOM_List - unknown - - - theObject - GEOM_Object - unknown - - - - - theList - GEOM_List - unknown - - - - - - CreateListOfLong - - - unknown - 0 - - - - return - GEOM_List - unknown - - - - - - AddItemToListOfLong - - - unknown - 0 - - - theList - GEOM_List - unknown - - - theObject - long - unknown - - - - - theList - GEOM_List - unknown - - - - - - CreateListOfDouble - - - unknown - 0 - - - - return - GEOM_List - unknown - - - - - - AddItemToListOfDouble - - - unknown - 0 - - - theList - GEOM_List - unknown - - - theObject - double - unknown - - - - - theList - GEOM_List - unknown - - - - - - MakePointXYZ - - - unknown - 0 - - - theX - double - unknown - - - theY - double - unknown - - - theZ - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePointWithReference - - - unknown - 0 - - - theReference - GEOM_Object - unknown - - - theX - double - unknown - - - theY - double - unknown - - - theZ - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePointOnCurve - - - unknown - 0 - - - theRefCurve - GEOM_Object - unknown - - - theParameter - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeTangentOnCurve - - - unknown - 0 - - - theRefCurve - GEOM_Object - unknown - - - theParameter - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeVectorDXDYDZ - - - unknown - 0 - - - theDX - double - unknown - - - theDY - double - unknown - - - theDZ - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeVectorTwoPnt - - - unknown - 0 - - - thePnt1 - GEOM_Object - unknown - - - thePnt2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeLineTwoPnt - - - unknown - 0 - - - thePnt1 - GEOM_Object - unknown - - - thePnt2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePlaneThreePnt - - - unknown - 0 - - - thePnt1 - GEOM_Object - unknown - - - thePnt2 - GEOM_Object - unknown - - - thePnt3 - GEOM_Object - unknown - - - theTrimSize - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePlanePntVec - - - unknown - 0 - - - thePnt - GEOM_Object - unknown - - - theVec - GEOM_Object - unknown - - - theTrimSize - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePlaneFace - - - unknown - 0 - - - theFace - GEOM_Object - unknown - - - theTrimSize - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeMarker - - - unknown - 0 - - - theOX - double - unknown - - - theOY - double - unknown - - - theOZ - double - unknown - - - theXDX - double - unknown - - - theXDY - double - unknown - - - theXDZ - double - unknown - - - theYDX - double - unknown - - - theYDY - double - unknown - - - theYDZ - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeTangentPlaneOnFace - - - unknown - 0 - - - theFace - GEOM_Object - unknown - - - theParameterU - double - unknown - - - theParameterV - double - unknown - - - theTrimSize - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeBox - - - unknown - 0 - - - theX1 - double - unknown - - - theY1 - double - unknown - - - theZ1 - double - unknown - - - theX2 - double - unknown - - - theY2 - double - unknown - - - theZ2 - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeBoxDXDYDZ - - - unknown - 0 - - - theDX - double - unknown - - - theDY - double - unknown - - - theDZ - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeBoxTwoPnt - - - unknown - 0 - - - thePnt1 - GEOM_Object - unknown - - - thePnt2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeCylinderPntVecRH - - - unknown - 0 - - - thePnt - GEOM_Object - unknown - - - theAxis - GEOM_Object - unknown - - - theRadius - double - unknown - - - theHeight - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeCylinderRH - - - unknown - 0 - - - theR - double - unknown - - - theH - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeCylinderPntVecRHA - - - unknown - 0 - - - thePnt - GEOM_Object - unknown - - - theAxis - GEOM_Object - unknown - - - theRadius - double - unknown - - - theHeight - double - unknown - - - theAngle - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeCylinderRHA - - - unknown - 0 - - - theR - double - unknown - - - theH - double - unknown - - - theA - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeSphere - - - unknown - 0 - - - theX - double - unknown - - - theY - double - unknown - - - theZ - double - unknown - - - theRadius - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeSphereR - - - unknown - 0 - - - theR - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeSpherePntR - - - unknown - 0 - - - thePnt - GEOM_Object - unknown - - - theR - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeTorusPntVecRR - - - unknown - 0 - - - thePnt - GEOM_Object - unknown - - - theVec - GEOM_Object - unknown - - - theRMajor - double - unknown - - - theRMinor - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeTorusRR - - - unknown - 0 - - - theRMajor - double - unknown - - - theRMinor - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeConePntVecR1R2H - - - unknown - 0 - - - thePnt - GEOM_Object - unknown - - - theAxis - GEOM_Object - unknown - - - theR1 - double - unknown - - - theR2 - double - unknown - - - theHeight - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeConeR1R2H - - - unknown - 0 - - - theR1 - double - unknown - - - theR2 - double - unknown - - - theHeight - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePrismVecH - - - unknown - 0 - - - theBase - GEOM_Object - unknown - - - theVec - GEOM_Object - unknown - - - theH - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePrismTwoPnt - - - unknown - 0 - - - theBase - GEOM_Object - unknown - - - thePoint1 - GEOM_Object - unknown - - - thePoint2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePipe - - - unknown - 0 - - - theBase - GEOM_Object - unknown - - - thePath - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeRevolutionAxisAngle - - - unknown - 0 - - - theBase - GEOM_Object - unknown - - - theAxis - GEOM_Object - unknown - - - theAngle - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeFilling - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theMinDeg - long - unknown - - - theMaxDeg - long - unknown - - - theTol2D - double - unknown - - - theTol3D - double - unknown - - - theNbIter - long - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeThruSections - - - unknown - 0 - - - theSeqSections - ListOfGO - unknown - - - theModeSolid - boolean - unknown - - - thePreci - double - unknown - - - theRuled - boolean - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePipeWithDifferentSections - - - unknown - 0 - - - theSeqBases - ListOfGO - unknown - - - theLocations - ListOfGO - unknown - - - thePath - GEOM_Object - unknown - - - theWithContact - boolean - unknown - - - theWithCorrection - boolean - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePipeWithShellSections - - - unknown - 0 - - - theSeqBases - ListOfGO - unknown - - - theSeqSubBases - ListOfGO - unknown - - - theLocations - ListOfGO - unknown - - - thePath - GEOM_Object - unknown - - - theWithContact - boolean - unknown - - - theWithCorrection - boolean - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeBoolean - - - unknown - 0 - - - theShape1 - GEOM_Object - unknown - - - theShape2 - GEOM_Object - unknown - - - theOperation - long - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeFuse - - - unknown - 0 - - - theShape1 - GEOM_Object - unknown - - - theShape2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeCut - - - unknown - 0 - - - theShape1 - GEOM_Object - unknown - - - theShape2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeCommon - - - unknown - 0 - - - theShape1 - GEOM_Object - unknown - - - theShape2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeSection - - - unknown - 0 - - - theShape1 - GEOM_Object - unknown - - - theShape2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePartition - - - unknown - 0 - - - theShapes - GEOM_List - unknown - - - theTools - GEOM_List - unknown - - - theKeepInside - GEOM_List - unknown - - - theRemoveInside - GEOM_List - unknown - - - theLimit - short - unknown - - - theRemoveWebs - boolean - unknown - - - theMaterials - GEOM_List - unknown - - - theKeepNonlimitShapes - short - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeHalfPartition - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - thePlane - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeCopy - - - unknown - 0 - - - theOriginal - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - Export - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theFileName - string - unknown - - - theFormatName - string - unknown - - - - - - - Import - - - unknown - 0 - - - theFileName - string - unknown - - - theFormatName - string - unknown - - - - - return - GEOM_Object - unknown - - - - - - ImportTranslators - - - unknown - 0 - - - - theFormats - string_array - unknown - - - thePatterns - string_array - unknown - - - - - - ExportTranslators - - - unknown - 0 - - - - theFormats - string_array - unknown - - - thePatterns - string_array - unknown - - - - - - TranslateTwoPoints - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - thePoint1 - GEOM_Object - unknown - - - thePoint2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - TranslateTwoPointsCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - thePoint1 - GEOM_Object - unknown - - - thePoint2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - TranslateDXDYDZ - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theDX - double - unknown - - - theDY - double - unknown - - - theDZ - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - TranslateDXDYDZCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theDX - double - unknown - - - theDY - double - unknown - - - theDZ - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - TranslateVector - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theVector - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - TranslateVectorCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theVector - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MultiTranslate1D - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theVector - GEOM_Object - unknown - - - theStep - double - unknown - - - theNbTimes - long - unknown - - - - - return - GEOM_Object - unknown - - - - - - MultiTranslate2D - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theVector1 - GEOM_Object - unknown - - - theStep1 - double - unknown - - - theNbTimes1 - long - unknown - - - theVector2 - GEOM_Object - unknown - - - theStep2 - double - unknown - - - theNbTimes2 - long - unknown - - - - - return - GEOM_Object - unknown - - - - - - Rotate - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theAxis - GEOM_Object - unknown - - - theAngle - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - RotateCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theAxis - GEOM_Object - unknown - - - theAngle - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - RotateThreePoints - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theCentPoint - GEOM_Object - unknown - - - thePoint1 - GEOM_Object - unknown - - - thePoint2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - RotateThreePointsCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theCentPoint - GEOM_Object - unknown - - - thePoint1 - GEOM_Object - unknown - - - thePoint2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MultiRotate1D - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theAxis - GEOM_Object - unknown - - - theNbTimes - long - unknown - - - - - return - GEOM_Object - unknown - - - - - - MultiRotate2D - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theAxis - GEOM_Object - unknown - - - theAngle - double - unknown - - - theNbTimes1 - long - unknown - - - theStep - double - unknown - - - theNbTimes2 - long - unknown - - - - - return - GEOM_Object - unknown - - - - - - MirrorPlane - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - thePlane - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MirrorPlaneCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - thePlane - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MirrorAxis - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theAxis - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MirrorAxisCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theAxis - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MirrorPoint - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - thePoint - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MirrorPointCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - thePoint - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - OffsetShape - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theOffset - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - OffsetShapeCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theOffset - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - ScaleShape - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - thePoint - GEOM_Object - unknown - - - theFactor - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - ScaleShapeCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - thePoint - GEOM_Object - unknown - - - theFactor - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - PositionShape - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theStartLCS - GEOM_Object - unknown - - - theEndLCS - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - PositionShapeCopy - - - unknown - 0 - - - theObject - GEOM_Object - unknown - - - theStartLCS - GEOM_Object - unknown - - - theEndLCS - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeEdge - - - unknown - 0 - - - thePnt1 - GEOM_Object - unknown - - - thePnt2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeWire - - - unknown - 0 - - - theEdgesAndWires - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeFace - - - unknown - 0 - - - theWire - GEOM_Object - unknown - - - isPlanarWanted - boolean - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeFaceWires - - - unknown - 0 - - - theWires - GEOM_List - unknown - - - isPlanarWanted - boolean - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeShell - - - unknown - 0 - - - theFacesAndShells - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeSolidShell - - - unknown - 0 - - - theShell - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeSolidShells - - - unknown - 0 - - - theShells - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeCompound - - - unknown - 0 - - - theShapes - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeGlueFaces - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theTolerance - double - unknown - - - doKeepNonSolids - boolean - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetGlueFaces - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theTolerance - double - unknown - - - - - return - GEOM_List - unknown - - - - - - MakeGlueFacesByList - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theTolerance - double - unknown - - - theFaces - ListOfGO - unknown - - - doKeepNonSolids - boolean - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeExplode - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theShapeType - long - unknown - - - isSorted - boolean - unknown - - - - - return - GEOM_List - unknown - - - - - - NumberOfFaces - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - - - return - long - unknown - - - - - - NumberOfEdges - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - - - return - long - unknown - - - - - - ChangeOrientation - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeQuad4Vertices - - - unknown - 0 - - - thePnt1 - GEOM_Object - unknown - - - thePnt2 - GEOM_Object - unknown - - - thePnt3 - GEOM_Object - unknown - - - thePnt4 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeQuad - - - unknown - 0 - - - theEdge1 - GEOM_Object - unknown - - - theEdge2 - GEOM_Object - unknown - - - theEdge3 - GEOM_Object - unknown - - - theEdge4 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeQuad2Edges - - - unknown - 0 - - - theEdge1 - GEOM_Object - unknown - - - theEdge2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeHexa - - - unknown - 0 - - - theFace1 - GEOM_Object - unknown - - - theFace2 - GEOM_Object - unknown - - - theFace3 - GEOM_Object - unknown - - - theFace4 - GEOM_Object - unknown - - - theFace5 - GEOM_Object - unknown - - - theFace6 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeHexa2Faces - - - unknown - 0 - - - theFace1 - GEOM_Object - unknown - - - theFace2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetPoint - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theX - double - unknown - - - theY - double - unknown - - - theZ - double - unknown - - - theEpsilon - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetEdge - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - thePoint1 - GEOM_Object - unknown - - - thePoint2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetEdgeNearPoint - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - thePoint - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetFaceByPoints - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - thePoint1 - GEOM_Object - unknown - - - thePoint2 - GEOM_Object - unknown - - - thePoint3 - GEOM_Object - unknown - - - thePoint4 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetFaceByEdges - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theEdge1 - GEOM_Object - unknown - - - theEdge2 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetOppositeFace - - - unknown - 0 - - - theBlock - GEOM_Object - unknown - - - theFace - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetFaceNearPoint - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - thePoint - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetFaceByNormale - - - unknown - 0 - - - theBlock - GEOM_Object - unknown - - - theVector - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - IsCompoundOfBlocks - - - unknown - 0 - - - theCompound - GEOM_Object - unknown - - - theMinNbFaces - long - unknown - - - theMaxNbFaces - long - unknown - - - - - return - boolean - unknown - - - theNbBlocks - long - unknown - - - - - - CheckCompoundOfBlocks - - - unknown - 0 - - - theCompound - GEOM_Object - unknown - - - - - return - boolean - unknown - - - theErrors - BCErrors - unknown - - - - - - PrintBCErrors - - - unknown - 0 - - - theCompound - GEOM_Object - unknown - - - theErrors - BCErrors - unknown - - - - - return - string - unknown - - - - - - ExplodeCompoundOfBlocks - - - unknown - 0 - - - theCompound - GEOM_Object - unknown - - - theMinNbFaces - long - unknown - - - theMaxNbFaces - long - unknown - - - - - return - GEOM_List - unknown - - - - - - GetBlockNearPoint - - - unknown - 0 - - - theCompound - GEOM_Object - unknown - - - thePoint - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetBlockByParts - - - unknown - 0 - - - theCompound - GEOM_Object - unknown - - - theParts - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetBlocksByParts - - - unknown - 0 - - - theCompound - GEOM_Object - unknown - - - theParts - GEOM_List - unknown - - - - - return - GEOM_List - unknown - - - - - - MakeMultiTransformation1D - - - unknown - 0 - - - theBlock - GEOM_Object - unknown - - - theDirFace1 - long - unknown - - - theDirFace2 - long - unknown - - - theNbTimes - long - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeMultiTransformation2D - - - unknown - 0 - - - theBlock - GEOM_Object - unknown - - - theDirFace1U - long - unknown - - - theDirFace2U - long - unknown - - - theNbTimesU - long - unknown - - - theDirFace1V - long - unknown - - - theDirFace2V - long - unknown - - - theNbTimesV - long - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeCirclePntVecR - - - unknown - 0 - - - thePnt - GEOM_Object - unknown - - - theVec - GEOM_Object - unknown - - - theR - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeCircleThreePnt - - - unknown - 0 - - - thePnt1 - GEOM_Object - unknown - - - thePnt2 - GEOM_Object - unknown - - - thePnt3 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeEllipse - - - unknown - 0 - - - thePnt - GEOM_Object - unknown - - - theVec - GEOM_Object - unknown - - - theRMajor - double - unknown - - - theRMinor - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeEllipseVec - - - unknown - 0 - - - thePnt - GEOM_Object - unknown - - - theVec - GEOM_Object - unknown - - - theRMajor - double - unknown - - - theRMinor - double - unknown - - - theVecMaj - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeArc - - - unknown - 0 - - - thePnt1 - GEOM_Object - unknown - - - thePnt2 - GEOM_Object - unknown - - - thePnt3 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeArcCenter - - - unknown - 0 - - - theCenter - GEOM_Object - unknown - - - thePnt1 - GEOM_Object - unknown - - - thePnt2 - GEOM_Object - unknown - - - theSense - boolean - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeArcOfEllipse - - - unknown - 0 - - - thePnt1 - GEOM_Object - unknown - - - thePnt2 - GEOM_Object - unknown - - - thePnt3 - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakePolyline - - - unknown - 0 - - - thePoints - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeSplineBezier - - - unknown - 0 - - - thePoints - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeSplineInterpolation - - - unknown - 0 - - - thePoints - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeSketcher - - - unknown - 0 - - - theCommand - string - unknown - - - theWorkingPlane - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeFilletAll - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theR - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeFilletEdges - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theR - double - unknown - - - theEdges - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeFilletFaces - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theR - double - unknown - - - theFaces - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeChamferAll - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theD - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeChamferEdge - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theD1 - double - unknown - - - theD2 - double - unknown - - - theFace1 - long - unknown - - - theFace2 - long - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeChamferFaces - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theD1 - double - unknown - - - theD2 - double - unknown - - - theFaces - GEOM_List - unknown - - - - - return - GEOM_Object - unknown - - - - - - MakeArchimede - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theWeight - double - unknown - - - theWaterDensity - double - unknown - - - theMeshDeflection - double - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetSubShapeIndex - - - unknown - 0 - - - theShape - GEOM_Object - unknown - - - theSubShape - GEOM_Object - unknown - - - - - return - long - unknown - - - - - - CreateGroup - - - unknown - 0 - - - theMainShape - GEOM_Object - unknown - - - theShapeType - long - unknown - - - - - return - GEOM_Object - unknown - - - - - - AddObject - - - unknown - 0 - - - theGroup - GEOM_Object - unknown - - - theSubShapeId - long - unknown - - - - - - - RemoveObject - - - unknown - 0 - - - theGroup - GEOM_Object - unknown - - - theSubShapeId - long - unknown - - - - - - - GetType - - - unknown - 0 - - - theGroup - GEOM_Object - unknown - - - - - return - long - unknown - - - - - - GetMainShape - - - unknown - 0 - - - theGroup - GEOM_Object - unknown - - - - - return - GEOM_Object - unknown - - - - - - GetObjects - - - unknown - 0 - - - theGroup - GEOM_Object - unknown - - - - - return - GEOM_List - unknown - - - - - - - MakePipeTShape - - - unknown - 0 - - - theR1 - double - unknown - - - theW1 - double - unknown - - - theL1 - double - unknown - - - theR2 - double - unknown - - - theW2 - double - unknown - - - theL2 - double - unknown - - - theHewMesh - boolean - unknown - - - - - return - GEOM_List - unknown - - - - - - MakePipeTShapeWithPosition - - - unknown - 0 - - - theR1 - double - unknown - - - theW1 - double - unknown - - - theL1 - double - unknown - - - theR2 - double - unknown - - - theW2 - double - unknown - - - theL2 - double - unknown - - - theHewMesh - boolean - unknown - - - theP1 - GEOM_Object - unknown - - - theP2 - GEOM_Object - unknown - - - theP3 - GEOM_Object - unknown - - - - - return - GEOM_List - unknown - - - - - - MakePipeTShapeChamfer - - - unknown - 0 - - - theR1 - double - unknown - - - theW1 - double - unknown - - - theL1 - double - unknown - - - theR2 - double - unknown - - - theW2 - double - unknown - - - theL2 - double - unknown - - - theH - double - unknown - - - theR - double - unknown - - - theHewMesh - boolean - unknown - - - - - return - GEOM_List - unknown - - - - - - MakePipeTShapeChamferWithPosition - - - unknown - 0 - - - theR1 - double - unknown - - - theW1 - double - unknown - - - theL1 - double - unknown - - - theR2 - double - unknown - - - theW2 - double - unknown - - - theL2 - double - unknown - - - theH - double - unknown - - - theR - double - unknown - - - theHewMesh - boolean - unknown - - - theP1 - GEOM_Object - unknown - - - theP2 - GEOM_Object - unknown - - - theP3 - GEOM_Object - unknown - - - - - return - GEOM_List - unknown - - - - - - - - MakePipeTShapeFillet - - - unknown - 0 - - - theR1 - double - unknown - - - theW1 - double - unknown - - - theL1 - double - unknown - - - theR2 - double - unknown - - - theW2 - double - unknown - - - theL2 - double - unknown - - - theRF - double - unknown - - - theHewMesh - boolean - unknown - - - - - return - GEOM_List - unknown - - - - - - MakePipeTShapeFilletWithPosition - - - unknown - 0 - - - theR1 - double - unknown - - - theW1 - double - unknown - - - theL1 - double - unknown - - - theR2 - double - unknown - - - theW2 - double - unknown - - - theL2 - double - unknown - - - theRF - double - unknown - - - theHewMesh - boolean - unknown - - - theP1 - GEOM_Object - unknown - - - theP2 - GEOM_Object - unknown - - - theP3 - GEOM_Object - unknown - - - - - return - GEOM_List - unknown - - - - - - MakeDividedDisk - - - unknown - 0 - - - theR - double - Radius of the disk - - - theRatio - double - Relative size of the central square diagonal against the disk diameter - - - - - return - GEOM_Object - Result object - - - - - - MakeDividedCylinder - - - unknown - 0 - - - theR - double - Radius of the cylinder - - - theH - double - Height of the cylinder - - - - - return - GEOM_Object - Result object - - - - - - MakeSmoothingSurface - - - unknown - 0 - - - thelPoints - double - list of points - - - - - return - GEOM_Object - Result object - - - - - - MakeExportXAO - - - unknown - 0 - - - theFileName - string - The name of the exported file - - - theExportingShape - GEOM_Object - Shape to export - - - thelGroups - GEOM_List - List of groups to export - - - thelFields - GEOM_List - List of fields to export - - - - - return - bool - Result object - - - - - - - + + + GEOM_Superv + GEOM_Superv + GEOM + + @SALOMEGEOM_VERSION@ + Supervision helper for Geometry component + 1 + 1 + + + + + + GEOM/GEOM_Superv + unknown + + + + SetStudyID + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theStudyID + long + unknown + + + + + + + CreateListOfGO + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + + return + GEOM/GEOM_List + unknown + + + + + + AddItemToListOfGO + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theList + GEOM/GEOM_List + unknown + + + theObject + GEOM/GEOM_Object + unknown + + + + + theList + GEOM/GEOM_List + unknown + + + + + + CreateListOfLong + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + + return + GEOM/GEOM_List + unknown + + + + + + AddItemToListOfLong + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theList + GEOM/GEOM_List + unknown + + + theObject + long + unknown + + + + + theList + GEOM/GEOM_List + unknown + + + + + + CreateListOfDouble + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + + return + GEOM/GEOM_List + unknown + + + + + + AddItemToListOfDouble + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theList + GEOM/GEOM_List + unknown + + + theObject + double + unknown + + + + + theList + GEOM/GEOM_List + unknown + + + + + + MakePointXYZ + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theX + double + unknown + + + theY + double + unknown + + + theZ + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePointWithReference + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theReference + GEOM/GEOM_Object + unknown + + + theX + double + unknown + + + theY + double + unknown + + + theZ + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePointOnCurve + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theRefCurve + GEOM/GEOM_Object + unknown + + + theParameter + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePointOnCurveByLength + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theRefCurve + GEOM/GEOM_Object + unknown + + + theLength + double + unknown + + + theStartPoint + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeTangentOnCurve + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theRefCurve + GEOM/GEOM_Object + unknown + + + theParameter + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeVectorDXDYDZ + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theDX + double + unknown + + + theDY + double + unknown + + + theDZ + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeVectorTwoPnt + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeLineTwoPnt + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeLineTwoFaces + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFace1 + GEOM/GEOM_Object + unknown + + + theFace2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePlaneThreePnt + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + thePnt3 + GEOM/GEOM_Object + unknown + + + theTrimSize + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePlanePntVec + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt + GEOM/GEOM_Object + unknown + + + theVec + GEOM/GEOM_Object + unknown + + + theTrimSize + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePlaneFace + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFace + GEOM/GEOM_Object + unknown + + + theTrimSize + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePlane2Vec + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theVec1 + GEOM/GEOM_Object + unknown + + + theVec2 + GEOM/GEOM_Object + unknown + + + theTrimSize + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePlaneLCS + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theLCS + GEOM/GEOM_Object + unknown + + + theTrimSize + double + unknown + + + theOrientation + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeMarker + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theOX + double + unknown + + + theOY + double + unknown + + + theOZ + double + unknown + + + theXDX + double + unknown + + + theXDY + double + unknown + + + theXDZ + double + unknown + + + theYDX + double + unknown + + + theYDY + double + unknown + + + theYDZ + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeMarkerFromShape + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeMarkerPntTwoVec + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theOrigin + GEOM/GEOM_Object + unknown + + + theXVec + GEOM/GEOM_Object + unknown + + + theYVec + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeTangentPlaneOnFace + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFace + GEOM/GEOM_Object + unknown + + + theParameterU + double + unknown + + + theParameterV + double + unknown + + + theTrimSize + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeBox + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theX1 + double + unknown + + + theY1 + double + unknown + + + theZ1 + double + unknown + + + theX2 + double + unknown + + + theY2 + double + unknown + + + theZ2 + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeBoxDXDYDZ + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theDX + double + unknown + + + theDY + double + unknown + + + theDZ + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeBoxTwoPnt + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFaceHW + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theH + double + unknown + + + theW + double + unknown + + + theOrientation + short + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFaceObjHW + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObj + GEOM/GEOM_Object + unknown + + + theH + double + unknown + + + theW + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeDiskPntVecR + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt + GEOM/GEOM_Object + unknown + + + theVec + GEOM/GEOM_Object + unknown + + + theR + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeDiskThreePnt + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + thePnt3 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeDiskR + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR + double + unknown + + + theOrientation + short + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCylinderPntVecRH + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + theRadius + double + unknown + + + theHeight + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCylinderRH + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR + double + unknown + + + theH + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCylinderPntVecRHA + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + theRadius + double + unknown + + + theHeight + double + unknown + + + theAngle + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCylinderRHA + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR + double + unknown + + + theH + double + unknown + + + theA + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeSphere + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theX + double + unknown + + + theY + double + unknown + + + theZ + double + unknown + + + theRadius + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeSphereR + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeSpherePntR + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt + GEOM/GEOM_Object + unknown + + + theR + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeTorusPntVecRR + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt + GEOM/GEOM_Object + unknown + + + theVec + GEOM/GEOM_Object + unknown + + + theRMajor + double + unknown + + + theRMinor + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeTorusRR + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theRMajor + double + unknown + + + theRMinor + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeConePntVecR1R2H + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + theR1 + double + unknown + + + theR2 + double + unknown + + + theHeight + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeConeR1R2H + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR1 + double + unknown + + + theR2 + double + unknown + + + theHeight + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePrismVecH + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBase + GEOM/GEOM_Object + unknown + + + theVec + GEOM/GEOM_Object + unknown + + + theH + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePrismVecH2Ways + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBase + GEOM/GEOM_Object + unknown + + + theVec + GEOM/GEOM_Object + unknown + + + theH + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePrismTwoPnt + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBase + GEOM/GEOM_Object + unknown + + + thePoint1 + GEOM/GEOM_Object + unknown + + + thePoint2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePrismTwoPnt2Ways + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBase + GEOM/GEOM_Object + unknown + + + thePoint1 + GEOM/GEOM_Object + unknown + + + thePoint2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePipe + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBase + GEOM/GEOM_Object + unknown + + + thePath + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeRevolutionAxisAngle + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBase + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + theAngle + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeRevolutionAxisAngle2Ways + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBase + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + theAngle + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFilling + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theMinDeg + long + unknown + + + theMaxDeg + long + unknown + + + theTol2D + double + unknown + + + theTol3D + double + unknown + + + theNbIter + long + unknown + + + theMethod + GEOM/filling_oper_method + unknown + + + theApprox + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeThruSections + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theSeqSections + GEOM/ListOfGO + unknown + + + theModeSolid + boolean + unknown + + + thePreci + double + unknown + + + theRuled + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePipeWithDifferentSections + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theSeqBases + GEOM/ListOfGO + unknown + + + theLocations + GEOM/ListOfGO + unknown + + + thePath + GEOM/GEOM_Object + unknown + + + theWithContact + boolean + unknown + + + theWithCorrection + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePipeWithShellSections + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theSeqBases + GEOM/ListOfGO + unknown + + + theSeqSubBases + GEOM/ListOfGO + unknown + + + theLocations + GEOM/ListOfGO + unknown + + + thePath + GEOM/GEOM_Object + unknown + + + theWithContact + boolean + unknown + + + theWithCorrection + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePipeShellsWithoutPath + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theSeqBases + GEOM/ListOfGO + unknown + + + theLocations + GEOM/ListOfGO + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePipeBiNormalAlongVector + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBase + GEOM/GEOM_Object + unknown + + + thePath + GEOM/GEOM_Object + unknown + + + theVec + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeBoolean + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape1 + GEOM/GEOM_Object + unknown + + + theShape2 + GEOM/GEOM_Object + unknown + + + theOperation + long + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFuse + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape1 + GEOM/GEOM_Object + unknown + + + theShape2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCommon + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape1 + GEOM/GEOM_Object + unknown + + + theShape2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCut + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape1 + GEOM/GEOM_Object + unknown + + + theShape2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeSection + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape1 + GEOM/GEOM_Object + unknown + + + theShape2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePartition + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShapes + GEOM/GEOM_List + unknown + + + theTools + GEOM/GEOM_List + unknown + + + theKeepInside + GEOM/GEOM_List + unknown + + + theRemoveInside + GEOM/GEOM_List + unknown + + + theLimit + short + unknown + + + theRemoveWebs + boolean + unknown + + + theMaterials + GEOM/GEOM_List + unknown + + + theKeepNonlimitShapes + short + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeHalfPartition + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + thePlane + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theOriginal + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + Export + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theFileName + string + unknown + + + theFormatName + string + unknown + + + + + + + ImportFile + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFileName + string + unknown + + + theFormatName + string + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + TranslateTwoPoints + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePoint1 + GEOM/GEOM_Object + unknown + + + thePoint2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + TranslateTwoPointsCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePoint1 + GEOM/GEOM_Object + unknown + + + thePoint2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + TranslateDXDYDZ + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theDX + double + unknown + + + theDY + double + unknown + + + theDZ + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + TranslateDXDYDZCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theDX + double + unknown + + + theDY + double + unknown + + + theDZ + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + TranslateVector + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theVector + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + TranslateVectorCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theVector + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + TranslateVectorDistance + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theVector + GEOM/GEOM_Object + unknown + + + theDistance + double + unknown + + + theCopy + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MultiTranslate1D + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theVector + GEOM/GEOM_Object + unknown + + + theStep + double + unknown + + + theNbTimes + long + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MultiTranslate2D + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theVector1 + GEOM/GEOM_Object + unknown + + + theStep1 + double + unknown + + + theNbTimes1 + long + unknown + + + theVector2 + GEOM/GEOM_Object + unknown + + + theStep2 + double + unknown + + + theNbTimes2 + long + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + Rotate + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + theAngle + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + RotateCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + theAngle + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + RotateThreePoints + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theCentPoint + GEOM/GEOM_Object + unknown + + + thePoint1 + GEOM/GEOM_Object + unknown + + + thePoint2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + RotateThreePointsCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theCentPoint + GEOM/GEOM_Object + unknown + + + thePoint1 + GEOM/GEOM_Object + unknown + + + thePoint2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MultiRotate1D + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + theNbTimes + long + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MultiRotate2D + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + theAngle + double + unknown + + + theNbTimes1 + long + unknown + + + theStep + double + unknown + + + theNbTimes2 + long + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MirrorPlane + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePlane + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MirrorPlaneCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePlane + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MirrorAxis + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MirrorAxisCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theAxis + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MirrorPoint + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePoint + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MirrorPointCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePoint + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + OffsetShape + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theOffset + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + OffsetShapeCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theOffset + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + ScaleShape + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePoint + GEOM/GEOM_Object + unknown + + + theFactor + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + ScaleShapeCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePoint + GEOM/GEOM_Object + unknown + + + theFactor + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + ScaleShapeAlongAxes + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePoint + GEOM/GEOM_Object + unknown + + + theFactorX + double + unknown + + + theFactorY + double + unknown + + + theFactorZ + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + ScaleShapeAlongAxesCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePoint + GEOM/GEOM_Object + unknown + + + theFactorX + double + unknown + + + theFactorY + double + unknown + + + theFactorZ + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + PositionShape + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theStartLCS + GEOM/GEOM_Object + unknown + + + theEndLCS + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + PositionShapeCopy + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theStartLCS + GEOM/GEOM_Object + unknown + + + theEndLCS + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + PositionAlongPath + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + thePath + GEOM/GEOM_Object + unknown + + + theDistance + double + unknown + + + theCopy + boolean + unknown + + + theReverse + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeEdge + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeEdgeOnCurveByLength + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theRefCurve + GEOM/GEOM_Object + unknown + + + theLength + double + unknown + + + theStartPoint + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeWire + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theEdgesAndWires + GEOM/GEOM_List + unknown + + + theTolerance + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFace + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theWire + GEOM/GEOM_Object + unknown + + + isPlanarWanted + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFaceWires + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theWires + GEOM/GEOM_List + unknown + + + isPlanarWanted + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeShell + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFacesAndShells + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeSolidShell + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShell + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeSolidShells + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShells + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCompound + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShapes + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeGlueFaces + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theTolerance + double + unknown + + + doKeepNonSolids + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetGlueFaces + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theTolerance + double + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + MakeGlueFacesByList + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theTolerance + double + unknown + + + theFaces + GEOM/ListOfGO + unknown + + + doKeepNonSolids + boolean + unknown + + + doGlueAllEdges + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeExplode + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theShapeType + long + unknown + + + isSorted + boolean + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + NumberOfFaces + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + + + return + long + unknown + + + + + + NumberOfEdges + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + + + return + long + unknown + + + + + + ChangeOrientation + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetShapesOnShape + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCheckShape + GEOM/GEOM_Object + unknown + + + theShape + GEOM/GEOM_Object + unknown + + + theShapeType + short + unknown + + + theState + GEOM/shape_state + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + GetShapesOnShapeAsCompound + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCheckShape + GEOM/GEOM_Object + unknown + + + theShape + GEOM/GEOM_Object + unknown + + + theShapeType + short + unknown + + + theState + GEOM/shape_state + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeQuad4Vertices + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + thePnt3 + GEOM/GEOM_Object + unknown + + + thePnt4 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeQuad + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theEdge1 + GEOM/GEOM_Object + unknown + + + theEdge2 + GEOM/GEOM_Object + unknown + + + theEdge3 + GEOM/GEOM_Object + unknown + + + theEdge4 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeQuad2Edges + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theEdge1 + GEOM/GEOM_Object + unknown + + + theEdge2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeHexa + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFace1 + GEOM/GEOM_Object + unknown + + + theFace2 + GEOM/GEOM_Object + unknown + + + theFace3 + GEOM/GEOM_Object + unknown + + + theFace4 + GEOM/GEOM_Object + unknown + + + theFace5 + GEOM/GEOM_Object + unknown + + + theFace6 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeHexa2Faces + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFace1 + GEOM/GEOM_Object + unknown + + + theFace2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetPoint + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theX + double + unknown + + + theY + double + unknown + + + theZ + double + unknown + + + theEpsilon + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetEdge + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + thePoint1 + GEOM/GEOM_Object + unknown + + + thePoint2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetEdgeNearPoint + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + thePoint + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetFaceByPoints + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + thePoint1 + GEOM/GEOM_Object + unknown + + + thePoint2 + GEOM/GEOM_Object + unknown + + + thePoint3 + GEOM/GEOM_Object + unknown + + + thePoint4 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetFaceByEdges + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theEdge1 + GEOM/GEOM_Object + unknown + + + theEdge2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetOppositeFace + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBlock + GEOM/GEOM_Object + unknown + + + theFace + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetFaceNearPoint + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + thePoint + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetFaceByNormale + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBlock + GEOM/GEOM_Object + unknown + + + theVector + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + IsCompoundOfBlocks + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCompound + GEOM/GEOM_Object + unknown + + + theMinNbFaces + long + unknown + + + theMaxNbFaces + long + unknown + + + + + return + boolean + unknown + + + theNbBlocks + long + unknown + + + + + + CheckCompoundOfBlocks + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCompound + GEOM/GEOM_Object + unknown + + + + + return + boolean + unknown + + + theErrors + GEOM/BCErrors + unknown + + + + + + PrintBCErrors + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCompound + GEOM/GEOM_Object + unknown + + + theErrors + GEOM/BCErrors + unknown + + + + + return + string + unknown + + + + + + ExplodeCompoundOfBlocks + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCompound + GEOM/GEOM_Object + unknown + + + theMinNbFaces + long + unknown + + + theMaxNbFaces + long + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + GetBlockNearPoint + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCompound + GEOM/GEOM_Object + unknown + + + thePoint + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetBlockByParts + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCompound + GEOM/GEOM_Object + unknown + + + theParts + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetBlocksByParts + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCompound + GEOM/GEOM_Object + unknown + + + theParts + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + MakeMultiTransformation1D + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBlock + GEOM/GEOM_Object + unknown + + + theDirFace1 + long + unknown + + + theDirFace2 + long + unknown + + + theNbTimes + long + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeMultiTransformation2D + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theBlock + GEOM/GEOM_Object + unknown + + + theDirFace1U + long + unknown + + + theDirFace2U + long + unknown + + + theNbTimesU + long + unknown + + + theDirFace1V + long + unknown + + + theDirFace2V + long + unknown + + + theNbTimesV + long + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCirclePntVecR + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt + GEOM/GEOM_Object + unknown + + + theVec + GEOM/GEOM_Object + unknown + + + theR + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCircleThreePnt + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + thePnt3 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeCircleCenter2Pnt + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + thePnt3 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeEllipse + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt + GEOM/GEOM_Object + unknown + + + theVec + GEOM/GEOM_Object + unknown + + + theRMajor + double + unknown + + + theRMinor + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeEllipseVec + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt + GEOM/GEOM_Object + unknown + + + theVec + GEOM/GEOM_Object + unknown + + + theRMajor + double + unknown + + + theRMinor + double + unknown + + + theVecMaj + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeArc + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + thePnt3 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeArcCenter + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCenter + GEOM/GEOM_Object + unknown + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + theSense + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeArcOfEllipse + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCenter + GEOM/GEOM_Object + unknown + + + thePnt1 + GEOM/GEOM_Object + unknown + + + thePnt2 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakePolyline + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePoints + GEOM/GEOM_List + unknown + + + theIsClosed + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeSplineBezier + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePoints + GEOM/GEOM_List + unknown + + + theIsClosed + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeSplineInterpolation + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thePoints + GEOM/GEOM_List + unknown + + + theIsClosed + boolean + unknown + + + theDoReordering + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeSketcher + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theCommand + string + unknown + + + theWorkingPlane + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFilletAll + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theR + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFilletEdges + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theR + double + unknown + + + theEdges + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFilletEdgesR1R2 + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theR1 + double + unknown + + + theR2 + double + unknown + + + theEdges + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFilletFaces + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theR + double + unknown + + + theFaces + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFilletFacesR1R2 + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theR1 + double + unknown + + + theR2 + double + unknown + + + theFaces + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeFillet2D + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theR + double + unknown + + + theVertexes + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeChamferAll + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theD + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeChamferEdge + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theD1 + double + unknown + + + theD2 + double + unknown + + + theFace1 + long + unknown + + + theFace2 + long + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeChamferEdgeAD + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theD + double + unknown + + + theAngle + double + unknown + + + theFace1 + long + unknown + + + theFace2 + long + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeChamferFaces + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theD1 + double + unknown + + + theD2 + double + unknown + + + theFaces + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeChamferFacesAD + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theD + double + unknown + + + theAngle + double + unknown + + + theFaces + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeChamferEdges + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theD1 + double + unknown + + + theD2 + double + unknown + + + theEdges + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeChamferEdgesAD + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theD + double + unknown + + + theAngle + double + unknown + + + theEdges + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeArchimede + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theWeight + double + unknown + + + theWaterDensity + double + unknown + + + theMeshDeflection + double + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetSubShapeIndex + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theShape + GEOM/GEOM_Object + unknown + + + theSubShape + GEOM/GEOM_Object + unknown + + + + + return + long + unknown + + + + + + CreateGroup + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theMainShape + GEOM/GEOM_Object + unknown + + + theShapeType + long + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + AddObject + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theGroup + GEOM/GEOM_Object + unknown + + + theSubShapeId + long + unknown + + + + + + + RemoveObject + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theGroup + GEOM/GEOM_Object + unknown + + + theSubShapeId + long + unknown + + + + + + + GetType + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theGroup + GEOM/GEOM_Object + unknown + + + + + return + long + unknown + + + + + + GetMainShape + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theGroup + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + GetObjects + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theGroup + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + MakePipeTShape + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR1 + double + unknown + + + theW1 + double + unknown + + + theL1 + double + unknown + + + theR2 + double + unknown + + + theW2 + double + unknown + + + theL2 + double + unknown + + + theHexMesh + boolean + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + MakePipeTShapeWithPosition + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR1 + double + unknown + + + theW1 + double + unknown + + + theL1 + double + unknown + + + theR2 + double + unknown + + + theW2 + double + unknown + + + theL2 + double + unknown + + + theHexMesh + boolean + unknown + + + theP1 + GEOM/GEOM_Object + unknown + + + theP2 + GEOM/GEOM_Object + unknown + + + theP3 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + MakePipeTShapeChamfer + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR1 + double + unknown + + + theW1 + double + unknown + + + theL1 + double + unknown + + + theR2 + double + unknown + + + theW2 + double + unknown + + + theL2 + double + unknown + + + theH + double + unknown + + + theW + double + unknown + + + theHexMesh + boolean + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + MakePipeTShapeChamferWithPosition + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR1 + double + unknown + + + theW1 + double + unknown + + + theL1 + double + unknown + + + theR2 + double + unknown + + + theW2 + double + unknown + + + theL2 + double + unknown + + + theH + double + unknown + + + theW + double + unknown + + + theHexMesh + boolean + unknown + + + theP1 + GEOM/GEOM_Object + unknown + + + theP2 + GEOM/GEOM_Object + unknown + + + theP3 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + MakePipeTShapeFillet + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR1 + double + unknown + + + theW1 + double + unknown + + + theL1 + double + unknown + + + theR2 + double + unknown + + + theW2 + double + unknown + + + theL2 + double + unknown + + + theRF + double + unknown + + + theHexMesh + boolean + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + MakePipeTShapeFilletWithPosition + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR1 + double + unknown + + + theW1 + double + unknown + + + theL1 + double + unknown + + + theR2 + double + unknown + + + theW2 + double + unknown + + + theL2 + double + unknown + + + theRF + double + unknown + + + theHexMesh + boolean + unknown + + + theP1 + GEOM/GEOM_Object + unknown + + + theP2 + GEOM/GEOM_Object + unknown + + + theP3 + GEOM/GEOM_Object + unknown + + + + + return + GEOM/GEOM_List + unknown + + + + + + MakeDividedDisk + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR + double + unknown + + + theRatio + double + unknown + + + theOrientation + short + unknown + + + thePattern + GEOM/pattern + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeDividedCylinder + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theR + double + unknown + + + theH + double + unknown + + + thePattern + GEOM/pattern + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + MakeSmoothingSurface + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + thelPoints + GEOM/GEOM_List + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + ExportSTL + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theFileName + string + unknown + + + theIsASCII + boolean + unknown + + + theDeflection + double + unknown + + + theIsRelative + boolean + unknown + + + + + + + ImportSTL + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFileName + string + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + ExportBREP + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theFileName + string + unknown + + + + + + + ImportBREP + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFileName + string + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + ExportSTEP + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theFileName + string + unknown + + + + + + + ImportSTEP + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFileName + string + unknown + + + theIsIgnoreUnits + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + ExportIGES + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theFileName + string + unknown + + + theVersion + string + unknown + + + + + + + ImportIGES + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theFileName + string + unknown + + + theIsIgnoreUnits + boolean + unknown + + + + + return + GEOM/GEOM_Object + unknown + + + + + + ExportXAO + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + shape + GEOM/GEOM_Object + unknown + + + groups + GEOM/ListOfGO + unknown + + + fields + GEOM/ListOfFields + unknown + + + author + string + unknown + + + fileName + string + unknown + + + + + return + boolean + unknown + + + + + + ImportXAO + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + fileName + string + unknown + + + + + return + boolean + unknown + + + shape + GEOM/GEOM_Object + unknown + + + subShapes + GEOM/ListOfGO + unknown + + + groups + GEOM/ListOfGO + unknown + + + fields + GEOM/ListOfFields + unknown + + + + + + ExportVTK + SALOME team + @SALOMEGEOM_VERSION@ + unknown + 0 + + + theObject + GEOM/GEOM_Object + unknown + + + theFileName + string + unknown + + + theDeflection + double + unknown + + + + + + + + - + + diff --git a/resources/IGESPlugin.xml b/resources/IGESPlugin.xml new file mode 100644 index 000000000..0810a4a0c --- /dev/null +++ b/resources/IGESPlugin.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + diff --git a/resources/ImportExport b/resources/ImportExport deleted file mode 100644 index fae46daf3..000000000 --- a/resources/ImportExport +++ /dev/null @@ -1,30 +0,0 @@ -Import: BREP|IGES|STEP|STL -Export: BREP|IGES|IGES_5_3|STEP|STL_Bin|STL_ASCII|VTK - -BREP.Import: BREPImport -BREP.Export: BREPExport -BREP.Pattern: BREP Files ( *.brep ) - -IGES.Import: IGESImport -IGES.Export: IGESExport -IGES.Pattern: IGES Files ( *.iges *.igs ) -IGES.ExportPattern: IGES 5.1 Files ( *.iges *.igs ) - -IGES_5_3.Export: IGESExport -IGES_5_3.Pattern: IGES 5.3 Files ( *.iges *.igs ) - -STEP.Import: STEPImport -STEP.Export: STEPExport -STEP.Pattern: STEP Files ( *.step *.stp ) - -STL.Import: STLImport -STL.Pattern: STL Files ( *.stl ) - -STL_Bin.Export: STLExport -STL_Bin.Pattern: STL Binary Files ( *.stl ) - -STL_ASCII.Export: STLExport -STL_ASCII.Pattern: STL ASCII Files ( *.stl ) - -VTK.Export: VTKExport -VTK.Pattern: VTK Files ( *.vtk ) diff --git a/resources/STEPPlugin.xml b/resources/STEPPlugin.xml new file mode 100644 index 000000000..0af939973 --- /dev/null +++ b/resources/STEPPlugin.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + diff --git a/resources/STLPlugin.xml b/resources/STLPlugin.xml new file mode 100644 index 000000000..81dd11bb6 --- /dev/null +++ b/resources/STLPlugin.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index eb36582fa..82a6f2b6c 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -37,8 +37,14 @@
- + + + + + + +
diff --git a/resources/VTKPlugin.xml b/resources/VTKPlugin.xml new file mode 100644 index 000000000..de58fd01b --- /dev/null +++ b/resources/VTKPlugin.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + diff --git a/resources/XAOPlugin.xml b/resources/XAOPlugin.xml new file mode 100644 index 000000000..c00137121 --- /dev/null +++ b/resources/XAOPlugin.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/AdvancedEngine/AdvancedEngine.cxx b/src/AdvancedEngine/AdvancedEngine.cxx index 270b1e60d..8745b3c3e 100644 --- a/src/AdvancedEngine/AdvancedEngine.cxx +++ b/src/AdvancedEngine/AdvancedEngine.cxx @@ -20,25 +20,14 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "GEOM_AdvancedEngine.hxx" - -#include "AdvancedEngine_OperationsCreator.hh" - -//============================================================================= -/*! - * - */ -//============================================================================= +#include "AdvancedEngine.hxx" +#include "AdvancedEngine_OperationsCreator.hxx" extern "C" { -ADVANCEDENGINE_EXPORT + ADVANCEDENGINE_EXPORT GEOM_GenericOperationsCreator* GetOperationsCreator() { - //MESSAGE("GetOperationsCreator"); - - AdvancedEngine_OperationsCreator* aCreator = new AdvancedEngine_OperationsCreator(); - - return aCreator; + return new AdvancedEngine_OperationsCreator(); } } diff --git a/src/AdvancedEngine/AdvancedEngine.hxx b/src/AdvancedEngine/AdvancedEngine.hxx new file mode 100755 index 000000000..b73287b2b --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine.hxx @@ -0,0 +1,36 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 _GEOM_ADVANCEDENGINE_HXX_ +#define _GEOM_ADVANCEDENGINE_HXX_ + +#ifdef WIN32 + #if defined ADVANCEDENGINE_EXPORTS || defined AdvancedEngine_EXPORTS + #define ADVANCEDENGINE_EXPORT __declspec( dllexport ) + #else + #define ADVANCEDENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define ADVANCEDENGINE_EXPORT +#endif + +#endif \ No newline at end of file diff --git a/src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.cxx b/src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.cxx new file mode 100644 index 000000000..d1391bc13 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.cxx @@ -0,0 +1,528 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 "AdvancedEngine_DividedDiskDriver.hxx" +#include "AdvancedEngine_IDividedDisk.hxx" +#include "AdvancedEngine_Types.hxx" + +#include "GEOM_Function.hxx" + +// OCCT includes +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +#include + +enum +{ + SQUARE, + HEXAGON +}; + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& AdvancedEngine_DividedDiskDriver::GetID() +{ + static Standard_GUID aGUID("0b01da9a-c5da-11e1-8d80-78e7d1879630"); + return aGUID; +} + +//======================================================================= +//function : AdvancedEngine_DividedDiskDriver +//purpose : +//======================================================================= +AdvancedEngine_DividedDiskDriver::AdvancedEngine_DividedDiskDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer AdvancedEngine_DividedDiskDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + AdvancedEngine_IDividedDisk aData (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + // Getting data + double R = aData.GetR(); + double Ratio = aData.GetRatio(); + int Pattern = aData.GetType(); + + // Build reference disk (in the global coordinate system) + TopoDS_Shape aDisk; + + if (Pattern == SQUARE) + aDisk = MakeDiskSquare( R, Ratio ); + else if (Pattern == HEXAGON) + aDisk = MakeDiskHexagon( R, Ratio ); + + if (aType == DIVIDEDDISK_R_RATIO) + { + int theOrientation = aData.GetOrientation(); + aShape = TransformShape(aDisk, theOrientation); + } + else if (aType == DIVIDEDDISK_R_VECTOR_PNT) + { + Handle(GEOM_Function) aRefPoint = aData.GetCenter(); + Handle(GEOM_Function) aRefVector = aData.GetVector(); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + TopoDS_Shape aShapeVec = aRefVector->GetValue(); + + if (aShapePnt.ShapeType() == TopAbs_VERTEX && + aShapeVec.ShapeType() == TopAbs_EDGE) + { + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); + TopoDS_Edge anE = TopoDS::Edge(aShapeVec); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (!V1.IsNull() && !V2.IsNull()) + { + gp_Vec aVec (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + gp_Dir aDir(aVec); + aShape = TransformShape(aDisk, aPnt, aDir); + } + } + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : MakeDiskHexagon +//purpose : +//======================================================================= +TopoDS_Shell AdvancedEngine_DividedDiskDriver::MakeDiskHexagon(double R, double Ratio) const +{ + // Geometry + gp_Dir ZDir(0,0,1); + gp_Dir XDir(1,0,0); + gp_Pnt Orig(0,0,0); + + // Circle + gp_Ax1 Ax1(Orig,ZDir); + gp_Ax2 Ax(Orig,ZDir,XDir); + gp_Circ aCircle(Ax, R); + + // Points +// gp_Pnt P4(0.01*Ratio*R,0,0); +// gp_Pnt P3(R,0,0); +// gp_Pnt P2 = P3.Rotated(Ax1,-M_PI/6.0); +// gp_Pnt P1(P4.X(), +// P4.X()/sqrt(3.0),0); + gp_Pnt P1(0.01*Ratio*R*sqrt(3.0)/2,0,0); + gp_Pnt P2(R,0,0); + gp_Pnt P3 = P2.Rotated(Ax1,M_PI/6.0); + gp_Pnt P4(P1.X(), + P1.X()/sqrt(3.0),0); + + + //surfaces + gp_Ax2 anAx (gp::XOY()); + Handle(Geom_Plane) aPlane = new Geom_Plane (anAx); + + // Topology + + // Vertices + TopoDS_Vertex O = BRepBuilderAPI_MakeVertex(Orig); + TopoDS_Vertex V1_init = BRepBuilderAPI_MakeVertex(P1); + TopoDS_Vertex V2_init = BRepBuilderAPI_MakeVertex(P2); + TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(P3); + TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(P4); + + TopoDS_Vertex V1 = V1_init; + TopoDS_Vertex V2 = V2_init; + + //Rotation + gp_Trsf myTrsf; + myTrsf.SetRotation(Ax1, M_PI/3.0); + + BRepBuilderAPI_Transform xform(myTrsf); + xform.Perform(V1,Standard_True); + TopoDS_Vertex V1_60 = TopoDS::Vertex(xform.Shape()); + xform.Perform(V2,Standard_True); + TopoDS_Vertex V2_60 = TopoDS::Vertex(xform.Shape()); + + // Declaration of shapes (used in the loop) + TopoDS_Edge E1, E2, E3, E4, E5, E6, E7, E8, E9; + TopoDS_Wire W1, W2, W3; + TopoDS_Face F1, F2, F3; + TopoDS_Shell S; + + BRep_Builder aBuilder; + aBuilder.MakeShell(S); + + // Initialisation of edges + TopoDS_Edge E1_init = BRepBuilderAPI_MakeEdge(V1,TopoDS::Vertex(V2.Reversed())); + E1 = E1_init; + TopoDS_Edge E8_init = BRepBuilderAPI_MakeEdge(O,TopoDS::Vertex(V1.Reversed())); + E8 = E8_init; + + for (int i=1;i<=6;i++) + { + // Edges + + // for Face1 + E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V3.Reversed())); + E3 = BRepBuilderAPI_MakeEdge(V3,TopoDS::Vertex(V4.Reversed())); + E4 = BRepBuilderAPI_MakeEdge(V4,TopoDS::Vertex(V1.Reversed())); + + // for Face2 + if (i==6) + { + E5 = BRepBuilderAPI_MakeEdge(aCircle, V3, TopoDS::Vertex(V2_init.Reversed())); + E7 = BRepBuilderAPI_MakeEdge(V1_init,TopoDS::Vertex(V4.Reversed())); + } + else + { + E5 = BRepBuilderAPI_MakeEdge(aCircle, V3, TopoDS::Vertex(V2_60.Reversed())); + E7 = BRepBuilderAPI_MakeEdge(V1_60,TopoDS::Vertex(V4.Reversed())); + } + E6 = BRepBuilderAPI_MakeEdge(V2_60,TopoDS::Vertex(V1_60.Reversed())); + + // for Face3 + E9 = BRepBuilderAPI_MakeEdge(V1_60,TopoDS::Vertex(O.Reversed())); + + + // Wires + + //Wire1 + aBuilder.MakeWire(W1); + if (i==1) + aBuilder.Add(W1,E1); + else + aBuilder.Add(W1,TopoDS::Edge(E1.Reversed())); + aBuilder.Add(W1,E2); + aBuilder.Add(W1,E3); + aBuilder.Add(W1,E4); + + // Wire 2 + aBuilder.MakeWire(W2); + aBuilder.Add(W2,TopoDS::Edge(E3.Reversed())); + aBuilder.Add(W2,E5); + if (i==6) + aBuilder.Add(W2,TopoDS::Edge(E1_init.Reversed())); + else + aBuilder.Add(W2,E6); + aBuilder.Add(W2,E7); + + // Wire3 + aBuilder.MakeWire(W3); + if (i==1) + aBuilder.Add(W3,E8); + else + aBuilder.Add(W3,TopoDS::Edge(E8.Reversed())); + aBuilder.Add(W3,TopoDS::Edge(E4.Reversed())); + aBuilder.Add(W3,TopoDS::Edge(E7.Reversed())); + if (i==6) + aBuilder.Add(W3,TopoDS::Edge(E8_init.Reversed())); + else + aBuilder.Add(W3,E9); + + // Faces creation + F1 = BRepBuilderAPI_MakeFace(aPlane,W1); + F2 = BRepBuilderAPI_MakeFace(aPlane,W2); + F3 = BRepBuilderAPI_MakeFace(aPlane,W3); + + //Shell + aBuilder.Add(S, F1); + aBuilder.Add(S, F2); + aBuilder.Add(S, F3); + + // rotation + V1=V1_60; + V2=V2_60; + + xform.Perform(V1_60,Standard_True); + V1_60 = TopoDS::Vertex(xform.Shape()); + xform.Perform(V2_60,Standard_True); + V2_60 = TopoDS::Vertex(xform.Shape()); + xform.Perform(V3,Standard_True); + V3 = TopoDS::Vertex(xform.Shape()); + xform.Perform(V4,Standard_True); + V4 = TopoDS::Vertex(xform.Shape()); + + // "Increment" of edges + E1=E6; + E8=E9; + } + + return S; +} + +//======================================================================= +//function : MakeDiskSquare +//purpose : +//======================================================================= +TopoDS_Shape AdvancedEngine_DividedDiskDriver::MakeDiskSquare(double R, double Ratio) const +{ + // Geometry + gp_Dir ZDir(0,0,1); + gp_Dir XDir(1,0,0); + gp_Pnt Orig(0,0,0); + + // Circle + gp_Ax1 Ax1(Orig,ZDir); + gp_Ax2 Ax(Orig,ZDir,XDir); + gp_Circ aCircle(Ax, R); + + // Points + gp_Pnt P1(0.01*Ratio*R,0,0); + gp_Pnt P2(R,0,0); + + //surfaces + gp_Ax2 anAx (gp::XOY()); + Handle(Geom_Plane) aPlane = new Geom_Plane (anAx); + + // Topology + + // Vertices + TopoDS_Vertex V1_init = BRepBuilderAPI_MakeVertex(P1); + TopoDS_Vertex V2_init = BRepBuilderAPI_MakeVertex(P2); + + TopoDS_Vertex V1 = V1_init; + TopoDS_Vertex V2 = V2_init; + + //Rotation + gp_Trsf myTrsf; + myTrsf.SetRotation(Ax1, M_PI/2); + + BRepBuilderAPI_Transform xform(myTrsf); + xform.Perform(V1,Standard_True); + TopoDS_Vertex V1_rotated = TopoDS::Vertex(xform.Shape()); + xform.Perform(V2,Standard_True); + TopoDS_Vertex V2_rotated = TopoDS::Vertex(xform.Shape()); + + // Declaration of shapes (used in the loop) + TopoDS_Edge E1, E2, E3, E4; + TopoDS_Wire W1, W2; + TopoDS_Face F1, F2; + TopoDS_Shell S; + + BRep_Builder aBuilder; + aBuilder.MakeWire(W2); // Central Wire + aBuilder.MakeShell(S); // Shell + + // Initialisation of edges + TopoDS_Edge E1_init = BRepBuilderAPI_MakeEdge(V1,TopoDS::Vertex(V2.Reversed())); + E1 = E1_init; + + for (int i=1;i<=4;i++) + { + // Edges + // for Face1 + + E3 = BRepBuilderAPI_MakeEdge(V2_rotated,TopoDS::Vertex(V1_rotated.Reversed())); + if (i == 4) + { + E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V2_init.Reversed())); + E4 = BRepBuilderAPI_MakeEdge(V1_init,TopoDS::Vertex(V1.Reversed())); + } + else + { + E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V2_rotated.Reversed())); + E4 = BRepBuilderAPI_MakeEdge(V1_rotated,TopoDS::Vertex(V1.Reversed())); + } + + // Wires + //Wire1 + aBuilder.MakeWire(W1); + if (i==1) + aBuilder.Add(W1,E1); + else + aBuilder.Add(W1,TopoDS::Edge(E1.Reversed())); + aBuilder.Add(W1,E2); + if (i==4) + aBuilder.Add(W1,TopoDS::Edge(E1_init.Reversed())); + else + aBuilder.Add(W1,E3); + aBuilder.Add(W1,E4); + + // Wire central + aBuilder.Add(W2,TopoDS::Edge(E4.Reversed())); + + // Faces creation + F1 = BRepBuilderAPI_MakeFace(aPlane,W1); + + //Shell + aBuilder.Add(S, F1); + + // rotation + V1=V1_rotated; + V2=V2_rotated; + + xform.Perform(V1_rotated,Standard_True); + V1_rotated = TopoDS::Vertex(xform.Shape()); + xform.Perform(V2_rotated,Standard_True); + V2_rotated = TopoDS::Vertex(xform.Shape()); + + // "Increment" of edges + E1=E3; + } + // Central square Face + F2 = BRepBuilderAPI_MakeFace(aPlane,W2); + aBuilder.Add(S, F2); + + return S; +} + + +//======================================================================= +//function : TrasformShape(TopoDS_Shape aShape,int theOrientation) +//purpose : Perform shape transformation accordingly with specified +// orientation +//======================================================================= +TopoDS_Shape AdvancedEngine_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, int theOrientation) const +{ + gp_Dir N, Vx; + gp_Pnt theOrigin = gp::Origin(); + + switch(theOrientation) + { + case 1: + { + N = gp::DZ(); + Vx = gp::DX(); + break; + } + case 2: + { + N = gp::DX(); + Vx = gp::DY(); + break; + } + case 3: + { + N = gp::DY(); + Vx = gp::DZ(); + break; + } + } + + gp_Ax3 aWPlane = gp_Ax3(theOrigin, N, Vx); + + return WPlaneTransform(theShape, aWPlane); +} + +//======================================================================= +//function : TrasformShape(TopoDS_Shape aShape, gp_Dir V, gp_Pnt P) +//purpose : Perform shape transformation accordingly with specified +// pnt and direction +//======================================================================= +TopoDS_Shape AdvancedEngine_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, gp_Pnt P, gp_Dir V) const +{ + gp_Ax3 aWPlane( P, V ); + return WPlaneTransform(theShape, aWPlane); +} + +//======================================================================= +//function : WPlaneTransform +//purpose : Perform shape transformation accordingly with the given +// Working Plane +//======================================================================= +TopoDS_Shape AdvancedEngine_DividedDiskDriver::WPlaneTransform(TopoDS_Shape theShape, gp_Ax3 theWPlane) const +{ + gp_Trsf aTrans; + aTrans.SetTransformation(theWPlane); + aTrans.Invert(); + BRepBuilderAPI_Transform aTransformation (theShape, aTrans, Standard_False); + return aTransformation.Shape(); +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool AdvancedEngine_DividedDiskDriver:: +GetCreationInformation(std::string& theOperationName, + std::vector& theParams) +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); + + AdvancedEngine_IDividedDisk aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "DIVIDEDDISK"; + + switch ( aType ) { + case DIVIDEDDISK_R_RATIO: + AddParam( theParams, "Radius", aCI.GetR() ); + AddParam( theParams, "Ratio", aCI.GetRatio() ); + AddParam( theParams, "Orientation", aCI.GetOrientation() ); + AddParam( theParams, "Division pattern", aCI.GetType() ); + break; + case DIVIDEDDISK_R_VECTOR_PNT: + AddParam( theParams, "Center Point", aCI.GetCenter() ); + AddParam( theParams, "Vector", aCI.GetVector() ); + AddParam( theParams, "Radius", aCI.GetR() ); + AddParam( theParams, "Division pattern", aCI.GetType() ); + break; + default: + return false; + } + + return true; +} + +IMPLEMENT_STANDARD_HANDLE (AdvancedEngine_DividedDiskDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_RTTIEXT (AdvancedEngine_DividedDiskDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.hxx b/src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.hxx new file mode 100644 index 000000000..f35b2811a --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.hxx @@ -0,0 +1,67 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 _AdvancedEngine_DividedDiskDriver_HXX +#define _AdvancedEngine_DividedDiskDriver_HXX + +#include "AdvancedEngine.hxx" + +#include "GEOM_BaseDriver.hxx" + +#include + +class TopoDS_Shape; +class TopoDS_Shell; +class gp_Pnt; +class gp_Dir; +class gp_Ax3; + +DEFINE_STANDARD_HANDLE( AdvancedEngine_DividedDiskDriver, GEOM_BaseDriver ); + +class ADVANCEDENGINE_EXPORT AdvancedEngine_DividedDiskDriver : public GEOM_BaseDriver +{ +public: + // Methods PUBLIC + // + AdvancedEngine_DividedDiskDriver(); + virtual Standard_Integer Execute(TFunction_Logbook& log) const; + virtual void Validate(TFunction_Logbook&) const {} + Standard_Boolean MustExecute(const TFunction_Logbook&) const + { + return Standard_True; + } + static const Standard_GUID& GetID(); + ~AdvancedEngine_DividedDiskDriver() {}; + + virtual bool GetCreationInformation(std::string& theOperationName, + std::vector& params); +private: + TopoDS_Shape TransformShape (TopoDS_Shape aShape, int theOrientation) const; + TopoDS_Shape TransformShape (TopoDS_Shape aShape, gp_Pnt P, gp_Dir V) const; + TopoDS_Shape WPlaneTransform (TopoDS_Shape aShape, gp_Ax3 theWPlane) const; + TopoDS_Shell MakeDiskHexagon (double R, double Ratio) const; + TopoDS_Shape MakeDiskSquare (double R, double Ratio) const; + + DEFINE_STANDARD_RTTI( AdvancedEngine_DividedDiskDriver ) +}; + +#endif // _AdvancedEngine_DividedDiskDriver_HXX diff --git a/src/AdvancedEngine/AdvancedEngine_IDividedDisk.hxx b/src/AdvancedEngine/AdvancedEngine_IDividedDisk.hxx new file mode 100644 index 000000000..c0f7e9c40 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_IDividedDisk.hxx @@ -0,0 +1,64 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 _AdvancedEngine_IDividedDisk_HXX_ +#define _AdvancedEngine_IDividedDisk_HXX_ + +#include "GEOM_Function.hxx" + +#define DIVIDEDDISK_ARG_R 1 +#define DIVIDEDDISK_ARG_RATIO 2 +#define DIVIDEDDISK_ARG_ORIENT 3 + +#define DIVIDEDDISK_ARG_CENTER 4 +#define DIVIDEDDISK_ARG_VECTOR 5 + +#define DIVIDEDDISK_ARG_TYPE 6 + +class AdvancedEngine_IDividedDisk +{ +public: + AdvancedEngine_IDividedDisk(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetR(double theR) { _func->SetReal(DIVIDEDDISK_ARG_R, theR); } + double GetR() { return _func->GetReal(DIVIDEDDISK_ARG_R); } + + void SetRatio(double theRatio) { _func->SetReal(DIVIDEDDISK_ARG_RATIO, theRatio); } + double GetRatio() { return _func->GetReal(DIVIDEDDISK_ARG_RATIO); } + + void SetOrientation(int theOrientation) { _func->SetInteger(DIVIDEDDISK_ARG_ORIENT, theOrientation); } + int GetOrientation() { return _func->GetInteger(DIVIDEDDISK_ARG_ORIENT); } + + void SetType(int theType) { _func->SetInteger(DIVIDEDDISK_ARG_TYPE, theType); } + int GetType() { return _func->GetInteger(DIVIDEDDISK_ARG_TYPE); } + + void SetCenter(Handle(GEOM_Function) theP) { _func->SetReference(DIVIDEDDISK_ARG_CENTER, theP); } + void SetVector(Handle(GEOM_Function) theV) { _func->SetReference(DIVIDEDDISK_ARG_VECTOR, theV); } + + Handle(GEOM_Function) GetCenter() { return _func->GetReference(DIVIDEDDISK_ARG_CENTER); } + Handle(GEOM_Function) GetVector() { return _func->GetReference(DIVIDEDDISK_ARG_VECTOR); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _AdvancedEngine_IDividedDisk_HXX_ diff --git a/src/AdvancedEngine/AdvancedEngine_IOperations.cxx b/src/AdvancedEngine/AdvancedEngine_IOperations.cxx new file mode 100644 index 000000000..079466a57 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_IOperations.cxx @@ -0,0 +1,3505 @@ +// Copyright (C) 2007-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 +// +// File : AdvancedEngine_IOperations.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#include "AdvancedEngine_IOperations.hxx" +#include "AdvancedEngine_PipeTShapeDriver.hxx" +#include "AdvancedEngine_IPipeTShape.hxx" +#include "AdvancedEngine_DividedDiskDriver.hxx" +#include "AdvancedEngine_IDividedDisk.hxx" +#include "AdvancedEngine_SmoothingSurfaceDriver.hxx" +#include "AdvancedEngine_ISmoothingSurface.hxx" + +#include + +#include +#include +#include + +#include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" +#include "GEOMUtils.hxx" +#include "GEOMAlgo_Splitter.hxx" +#include "GEOMAlgo_FinderShapeOn1.hxx" + +#include "GEOMImpl_Gen.hxx" +#include "GEOMImpl_Types.hxx" + +#include "GEOMImpl_IBasicOperations.hxx" +#include "GEOMImpl_IBooleanOperations.hxx" +#include "GEOMImpl_IShapesOperations.hxx" +#include "GEOMImpl_ITransformOperations.hxx" +#include "GEOMImpl_IBlocksOperations.hxx" +#include "GEOMImpl_I3DPrimOperations.hxx" +#include "GEOMImpl_ILocalOperations.hxx" +#include "GEOMImpl_IHealingOperations.hxx" +#include "GEOMImpl_IGroupOperations.hxx" +#include "GEOMImpl_GlueDriver.hxx" + +#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 +#include +#include + +#include + +#include + +#include "AdvancedEngine_Types.hxx" + +#include +#include +#include +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +#define HALF_LENGTH_MAIN_PIPE "Main pipe half length" //"Tuyau principal - demi longueur" +#define HALF_LENGTH_INCIDENT_PIPE "Incident pipe half length" //"Tuyau incident - demi longueur" +#define CIRCULAR_QUARTER_PIPE "Circular quarter of pipe" //"Circulaire - quart de tuyau" +#define THICKNESS "Thickness" //"Epaisseur" +#define FLANGE "Flange" // "Collerette" +#define CHAMFER_OR_FILLET "Chamfer or fillet" //"Chanfrein ou Raccord" +#define JUNCTION_FACE_1 "Junction 1" //"Face de jonction 1" +#define JUNCTION_FACE_2 "Junction 2" //"Face de jonction 2" +#define JUNCTION_FACE_3 "Junction 3" //"Face de jonction 3" + +#define FIND_GROUPS_BY_POINTS 1 + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +AdvancedEngine_IOperations::AdvancedEngine_IOperations(GEOM_Engine* theEngine, int theDocID) : + GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("AdvancedEngine_IOperations::AdvancedEngine_IOperations"); + myBasicOperations = new GEOMImpl_IBasicOperations(GetEngine(), GetDocID()); + myBooleanOperations = new GEOMImpl_IBooleanOperations(GetEngine(), GetDocID()); + myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID()); + myTransformOperations = new GEOMImpl_ITransformOperations(GetEngine(), GetDocID()); + myBlocksOperations = new GEOMImpl_IBlocksOperations(GetEngine(), GetDocID()); + my3DPrimOperations = new GEOMImpl_I3DPrimOperations(GetEngine(), GetDocID()); + myLocalOperations = new GEOMImpl_ILocalOperations(GetEngine(), GetDocID()); + myHealingOperations = new GEOMImpl_IHealingOperations(GetEngine(), GetDocID()); + myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID()); +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +AdvancedEngine_IOperations::~AdvancedEngine_IOperations() +{ + MESSAGE("AdvancedEngine_IOperations::~AdvancedEngine_IOperations"); + delete myBasicOperations; + delete myBooleanOperations; + delete myShapesOperations; + delete myTransformOperations; + delete myBlocksOperations; + delete my3DPrimOperations; + delete myLocalOperations; + delete myHealingOperations; + delete myGroupOperations; +} + +//============================================================================= +/*! + * SetPosition + */ +//============================================================================= +gp_Trsf AdvancedEngine_IOperations::GetPositionTrsf(double theL1, double theL2, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3) +{ + // Old Local Coordinates System oldLCS + gp_Pnt P0(0, 0, 0); + gp_Pnt P1(-theL1, 0, 0); + gp_Pnt P2(theL1, 0, 0); + gp_Pnt P3(0, 0, theL2); + + gp_Dir oldX(gp_Vec(P1, P2)); + gp_Dir oldZ(gp_Vec(P0, P3)); + gp_Ax3 oldLCS(P0, oldZ, oldX); + + // New Local Coordinates System newLCS + double LocX, LocY, LocZ; + gp_Pnt newP1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue())); + gp_Pnt newP2 = BRep_Tool::Pnt(TopoDS::Vertex(theP2->GetValue())); + gp_Pnt newP3 = BRep_Tool::Pnt(TopoDS::Vertex(theP3->GetValue())); + LocX = (newP1.X() + newP2.X()) / 2.; + LocY = (newP1.Y() + newP2.Y()) / 2.; + LocZ = (newP1.Z() + newP2.Z()) / 2.; + gp_Pnt newO(LocX, LocY, LocZ); + + gp_Dir newX(gp_Vec(newP1, newP2)); // P1P2 Vector + gp_Dir newZ(gp_Vec(newO, newP3)); // OP3 Vector + gp_Ax3 newLCS = gp_Ax3(newO, newZ, newX); + + gp_Trsf aTrsf; + aTrsf.SetDisplacement(oldLCS, newLCS); + + return aTrsf; +} + +//============================================================================= +/*! + * CheckCompatiblePosition + * + */ +//============================================================================= +bool AdvancedEngine_IOperations::CheckCompatiblePosition(double& theL1, double& theL2, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3, + double theTolerance) +{ + SetErrorCode(KO); + gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue())); + gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(theP2->GetValue())); + gp_Pnt P3 = BRep_Tool::Pnt(TopoDS::Vertex(theP3->GetValue())); + + double d12 = P1.Distance(P2); + double d13 = P1.Distance(P3); + double d23 = P2.Distance(P3); + // double d2 = newO.Distance(P3); + + if (Abs(d12) <= Precision::Confusion()) { + SetErrorCode("Junctions points P1 and P2 are identical"); + return false; + } + if (Abs(d13) <= Precision::Confusion()) { + SetErrorCode("Junctions points P1 and P3 are identical"); + return false; + } + if (Abs(d23) <= Precision::Confusion()) { + SetErrorCode("Junctions points P2 and P3 are identical"); + return false; + } + + + double newL1 = 0.5 * d12; + double newL2 = sqrt(pow(d13,2)-pow(newL1,2)); + // + // theL1*(1-theTolerance) <= newL1 <= theL1*(1+theTolerance) + // + if (fabs(newL1 - theL1) > Precision::Approximation()) { + if ( (newL1 * (1 - theTolerance) -theL1 <= Precision::Approximation()) && + (newL1 * (1 + theTolerance) -theL1 >= Precision::Approximation()) ) { + // std::cerr << "theL1 = newL1" << std::endl; + theL1 = newL1; + } else { + theL1 = -1; + SetErrorCode("Dimension for main pipe (L1) is incompatible with new position"); + return false; + } + } + + // + // theL2*(1-theTolerance) <= newL2 <= theL2*(1+theTolerance) + // + if (fabs(newL2 - theL2) > Precision::Approximation()) { + if ( (newL2 * (1 - theTolerance) -theL2 <= Precision::Approximation()) && + (newL2 * (1 + theTolerance) -theL2 >= Precision::Approximation()) ) { + theL2 = newL2; + } else { + theL2 = -1; + SetErrorCode("Dimension for incident pipe (L2) is incompatible with new position"); + return false; + } + } + + SetErrorCode(OK); + return true; + +} + +//============================================================================= +/*! + * Generate the propagation groups of a Pipe T-Shape used for hexa mesh + */ +//============================================================================= +bool AdvancedEngine_IOperations::MakeGroups(Handle(GEOM_Object) theShape, int shapeType, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theH, double theW, double theRF, + Handle(TColStd_HSequenceOfTransient) theSeq, + gp_Trsf aTrsf) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return false; + + TopoDS_Shape aShape = theShape->GetValue(); + if (aShape.IsNull()) { + SetErrorCode("Shape is not defined"); + return false; + } + + gp_Trsf aTrsfInv = aTrsf.Inverted(); + +// int expectedGroups = 0; +// if (shapeType == TSHAPE_BASIC) +// if (Abs(theR2+theW2-theR1-theW1) <= Precision::Approximation()) +// expectedGroups = 10; +// else +// expectedGroups = 11; +// else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) +// expectedGroups = 12; + + double aR1Ext = theR1 + theW1; + double aR2Ext = theR2 + theW2; + + ///////////////////////// + //// Groups of Faces //// + ///////////////////////// + + // + // Comment the following lines when GetInPlace bug is solved + // == BEGIN + // Workaround of GetInPlace bug + // Create a bounding box that fits the shape + Handle(GEOM_Object) aBox = my3DPrimOperations->MakeBoxDXDYDZ(2*theL1, 2*aR1Ext, aR1Ext+theL2); + aBox->GetLastFunction()->SetDescription(""); + myTransformOperations->TranslateDXDYDZ(aBox, -theL1, -aR1Ext, -aR1Ext); + aBox->GetLastFunction()->SetDescription(""); + // Apply transformation to box + BRepBuilderAPI_Transform aTransformationBox(aBox->GetValue(), aTrsf, Standard_False); + TopoDS_Shape aBoxShapeTrsf = aTransformationBox.Shape(); + aBox->GetLastFunction()->SetValue(aBoxShapeTrsf); + + // Get the shell of the box + Handle(GEOM_Object) aShell = Handle(GEOM_Object)::DownCast + (myShapesOperations->MakeExplode(aBox, TopAbs_SHELL, true)->Value(1)); + aBox->GetLastFunction()->SetDescription(""); + aShell->GetLastFunction()->SetDescription(""); + // Get the common shapes between shell and shape + Handle(GEOM_Object) aCommonCompound = myBooleanOperations->MakeBoolean + (theShape, aShell, 1, Standard_False); // MakeCommon + if (aCommonCompound.IsNull()) { + SetErrorCode(myBooleanOperations->GetErrorCode()); + return false; + } + aCommonCompound->GetLastFunction()->SetDescription(""); + // Explode the faces of common shapes => 3 faces + Handle(TColStd_HSequenceOfTransient) aCommonFaces = + myShapesOperations->MakeExplode(aCommonCompound, TopAbs_FACE, true); + aCommonCompound->GetLastFunction()->SetDescription(""); + std::list aCompoundOfFacesList; + + for (int i=0 ; i<= aCommonFaces->Length()-4 ; i+=4) { + std::list aFacesList; + for (int j = 1 ; j <= 4 ; j++) { + Handle(GEOM_Object) aFace = Handle(GEOM_Object)::DownCast(aCommonFaces->Value(i+j)); // Junction faces + if (!aFace.IsNull()) { + aFace->GetLastFunction()->SetDescription(""); + aFacesList.push_back(aFace); + } + } + Handle(GEOM_Object) aCompoundOfFaces = myShapesOperations->MakeCompound(aFacesList); + if (!aCompoundOfFaces.IsNull()) { + aCompoundOfFaces->GetLastFunction()->SetDescription(""); + aCompoundOfFacesList.push_back(aCompoundOfFaces); + } + } + + if (aCompoundOfFacesList.size() == 3) { + Handle(GEOM_Object) aPln1 = aCompoundOfFacesList.front(); + aCompoundOfFacesList.pop_front(); + Handle(GEOM_Object) aPln2 = aCompoundOfFacesList.front(); + aCompoundOfFacesList.pop_front(); + Handle(GEOM_Object) aPln3 = aCompoundOfFacesList.front(); + aCompoundOfFacesList.pop_front(); + // == END + // + + + // Uncomment the following lines when GetInPlace bug is solved + // == BEGIN +// Handle(GEOM_Object) aP1 = myBasicOperations->MakePointXYZ(-theL1, 0, 0); +// Handle(GEOM_Object) aP2 = myBasicOperations->MakePointXYZ(-0, 0, theL2); +// Handle(GEOM_Object) aP3 = myBasicOperations->MakePointXYZ(theL1, 0, 0); +// aP1->GetLastFunction()->SetDescription(""); +// aP2->GetLastFunction()->SetDescription(""); +// aP3->GetLastFunction()->SetDescription(""); +// Handle(GEOM_Object) aV1 = myBasicOperations->MakeVectorDXDYDZ(-1, 0, 0); +// Handle(GEOM_Object) aV2 = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); +// Handle(GEOM_Object) aV3 = myBasicOperations->MakeVectorDXDYDZ(1, 0, 0); +// aV1->GetLastFunction()->SetDescription(""); +// aV2->GetLastFunction()->SetDescription(""); +// aV3->GetLastFunction()->SetDescription(""); +// Handle(GEOM_Object) aPln1 = myBasicOperations->MakePlanePntVec(aP1, aV1, 2*(aR1Ext+theL2)); +// Handle(GEOM_Object) aPln2 = myBasicOperations->MakePlanePntVec(aP2, aV2, 2*(aR2Ext)); +// Handle(GEOM_Object) aPln3 = myBasicOperations->MakePlanePntVec(aP3, aV3, 2*(aR1Ext+theL2)); +// aPln1->GetLastFunction()->SetDescription(""); +// aPln2->GetLastFunction()->SetDescription(""); +// aPln3->GetLastFunction()->SetDescription(""); +// +// BRepBuilderAPI_Transform aTransformation1(aPln1->GetValue(), aTrsf, Standard_False); +// TopoDS_Shape aTrsf_Shape1 = aTransformation1.Shape(); +// aPln1->GetLastFunction()->SetValue(aTrsf_Shape1); +// BRepBuilderAPI_Transform aTransformation2(aPln2->GetValue(), aTrsf, Standard_False); +// TopoDS_Shape aTrsf_Shape2 = aTransformation2.Shape(); +// aPln2->GetLastFunction()->SetValue(aTrsf_Shape2); +// BRepBuilderAPI_Transform aTransformation3(aPln3->GetValue(), aTrsf, Standard_False); +// TopoDS_Shape aTrsf_Shape3 = aTransformation3.Shape(); +// aPln3->GetLastFunction()->SetValue(aTrsf_Shape3); + // == END + // + + Handle(GEOM_Object) junctionFaces1 = myShapesOperations->GetInPlace(theShape, aPln1); + if (junctionFaces1.IsNull()) + junctionFaces1 = myShapesOperations->GetShapesOnShapeAsCompound + (aPln1, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); + if (!junctionFaces1.IsNull()) { + junctionFaces1->GetLastFunction()->SetDescription(""); + junctionFaces1->SetName("JUNCTION_FACE_1"); + theSeq->Append(junctionFaces1); + } + else { + SetErrorCode("Junction face 1 not found"); + // theSeq->Append(aPln1); + // return false; + } + Handle(GEOM_Object) junctionFaces2 = myShapesOperations->GetInPlace(theShape, aPln2); + if (junctionFaces2.IsNull()) + junctionFaces2 = myShapesOperations->GetShapesOnShapeAsCompound + (aPln2, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); + if (!junctionFaces2.IsNull()) { + junctionFaces2->GetLastFunction()->SetDescription(""); + junctionFaces2->SetName("JUNCTION_FACE_2"); + theSeq->Append(junctionFaces2); + } + else { + SetErrorCode("Junction face 2 not found"); + // theSeq->Append(aPln2); + // return false; + } + Handle(GEOM_Object) junctionFaces3 = myShapesOperations->GetInPlace(theShape, aPln3); + if (junctionFaces3.IsNull()) + junctionFaces3 = myShapesOperations->GetShapesOnShapeAsCompound + (aPln3, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); + if (!junctionFaces3.IsNull()) { + junctionFaces3->GetLastFunction()->SetDescription(""); + junctionFaces3->SetName("JUNCTION_FACE_3"); + theSeq->Append(junctionFaces3); + } + else { + SetErrorCode("Junction face 3 not found"); + // theSeq->Append(aPln3); + // return false; + } + // Comment the following lines when GetInPlace bug is solved + // == BEGIN + } + // == END + + ///////////////////////// + //// Groups of Edges //// + ///////////////////////// + // Result of propagate + + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + TCollection_AsciiString theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) aSeqPropagate = myBlocksOperations->Propagate(theShape); + if (aSeqPropagate.IsNull() || aSeqPropagate->Length() == 0) { + SetErrorCode("Propagation groups not found"); + return false; + } + Standard_Integer aNbGroups = aSeqPropagate->Length(); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + +#ifdef FIND_GROUPS_BY_POINTS + // BEGIN: new groups search + + // W2 R2 + // .----.-----.----. + // e| | | | | + // | | | | | + // . | | | . + // g / ''..| | |..'' \ + // f / ''''''' \ + // .---.--'.. | | | ..'--.---. + // |a \ '''...........''' / | + // |-------\------' | '------/-------. + // | \ | / | + // c| \ | / | + // | R1 \ | / | + // | \ | / | + // ._________________|_________________. + // | L1 | | + // | | | + // | | | + // b| | | + // | | | + // |-----------------|-----------------| + // | W1 | | + // '-----------------'-----------------' + // d + + // "Thickness" group (a) + gp_Pnt aPntA (-theL1, 0, theR1 + theW1/2.); + aPntA.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexA (aPntA); + TopoDS_Vertex aVertA = TopoDS::Vertex(mkVertexA.Shape()); + TopoDS_Shape anEdgeA = GEOMUtils::GetEdgeNearPoint(aShape, aVertA); + + // "Circular quarter of pipe" group (b) + gp_Pnt aPntB (-theL1, -aR1Ext * sin(M_PI/4.), -aR1Ext * sin(M_PI/4.)); + aPntB.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexB (aPntB); + TopoDS_Vertex aVertB = TopoDS::Vertex(mkVertexB.Shape()); + TopoDS_Shape anEdgeB = GEOMUtils::GetEdgeNearPoint(aShape, aVertB); + + // "Circular quarter of pipe" group (c) + gp_Pnt aPntC (-theL1, -aR1Ext * sin(M_PI/4.), aR1Ext * sin(M_PI/4.)); + aPntC.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexC (aPntC); + TopoDS_Vertex aVertC = TopoDS::Vertex(mkVertexC.Shape()); + TopoDS_Shape anEdgeC = GEOMUtils::GetEdgeNearPoint(aShape, aVertC); + + // "Main pipe half length" group (d) + gp_Pnt aPntD (-theL1/2., 0, -aR1Ext); + aPntD.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexD (aPntD); + TopoDS_Vertex aVertD = TopoDS::Vertex(mkVertexD.Shape()); + TopoDS_Shape anEdgeD = GEOMUtils::GetEdgeNearPoint(aShape, aVertD); + + // "Incident pipe half length" group (e) + double aTol10 = Precision::Confusion() * 10.; + gp_Pnt aPntE (-aR2Ext, 0, theL2 - aTol10); + aPntE.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexE (aPntE); + TopoDS_Vertex aVertE = TopoDS::Vertex(mkVertexE.Shape()); + TopoDS_Shape anEdgeE = GEOMUtils::GetEdgeNearPoint(aShape, aVertE); + + // "Flange" group (f) + double aFx = - aR2Ext - aTol10; + if (shapeType == TSHAPE_CHAMFER) + aFx -= theW; + else if (shapeType == TSHAPE_FILLET) + aFx -= theRF; + gp_Pnt aPntF (aFx, 0, aR1Ext); + aPntF.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexF (aPntF); + TopoDS_Vertex aVertF = TopoDS::Vertex(mkVertexF.Shape()); + TopoDS_Shape anEdgeF = GEOMUtils::GetEdgeNearPoint(aShape, aVertF); + + // "Chamfer or Fillet" group (g) + TopoDS_Shape anEdgeG; + if (shapeType == TSHAPE_CHAMFER) { + gp_Pnt aPntG (-aR2Ext - theW/2., 0, aR1Ext + theH/2.); + aPntG.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexG (aPntG); + TopoDS_Vertex aVertG = TopoDS::Vertex(mkVertexG.Shape()); + anEdgeG = GEOMUtils::GetEdgeNearPoint(aShape, aVertG); + } + else if (shapeType == TSHAPE_FILLET) { + gp_Pnt aPntG (-aR2Ext - theRF/2., 0, aR1Ext + theRF/2.); + aPntG.Transform(aTrsf); + BRepBuilderAPI_MakeVertex mkVertexG (aPntG); + TopoDS_Vertex aVertG = TopoDS::Vertex(mkVertexG.Shape()); + anEdgeG = GEOMUtils::GetEdgeNearPoint(aShape, aVertG); + } + + for (int i = 1 ; i <= aNbGroups; i++) { + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(aSeqPropagate->Value(i)); + if (aGroup.IsNull()) + continue; + + TopoDS_Shape aGroupShape = aGroup->GetValue(); + TopTools_IndexedMapOfShape anEdgesMap; + TopExp::MapShapes(aGroupShape, TopAbs_EDGE, anEdgesMap); + + if (anEdgesMap.Contains(anEdgeA)) { // a + aGroup->SetName("THICKNESS"); + theSeq->Append(aGroup); + } + else if (anEdgesMap.Contains(anEdgeB)) { // b + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + theSeq->Append(aGroup); + } + else if (anEdgesMap.Contains(anEdgeC)) { // c + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + theSeq->Append(aGroup); + } + else if (anEdgesMap.Contains(anEdgeD)) { // d + aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); + theSeq->Append(aGroup); + } + else if (anEdgesMap.Contains(anEdgeE)) { // e + aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); + theSeq->Append(aGroup); + } + else if (anEdgesMap.Contains(anEdgeF)) { // f + aGroup->SetName("FLANGE"); + theSeq->Append(aGroup); + } + else if (shapeType == TSHAPE_CHAMFER) { // g + if (anEdgesMap.Contains(anEdgeG)) { + aGroup->SetName("CHAMFER"); + theSeq->Append(aGroup); + } + } + else if (shapeType == TSHAPE_FILLET) { // g + if (anEdgesMap.Contains(anEdgeG)) { + aGroup->SetName("FILLET"); + theSeq->Append(aGroup); + } + } + else { + } + } + // END: new groups search +#else + bool addGroup; + bool circularFoundAndAdded = false; + bool circularFound10 = false; + bool incidentPipeFound = false; + bool mainPipeFound = false; + bool mainPipeFoundAndAdded = false; + bool radialFound =false; + bool flangeFound = false; + bool flangeFoundAndAdded = false; + bool chamferOrFilletFound = false; + + for (int i = 1 ; i <= aNbGroups; i++) { + addGroup = false; + + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(aSeqPropagate->Value(i)); + if (aGroup.IsNull()) + continue; + + TopoDS_Shape aGroupShape = aGroup->GetValue(); + BRepBuilderAPI_Transform aTransformationShapeInv (aGroupShape, aTrsfInv, Standard_False); + TopoDS_Shape aGroupShapeTrsfInv = aTransformationShapeInv.Shape(); + + TopTools_IndexedMapOfShape anEdgesMap; + TopExp::MapShapes(aGroupShapeTrsfInv,TopAbs_EDGE, anEdgesMap); + Standard_Integer nbEdges = anEdgesMap.Extent(); + + if (shapeType == TSHAPE_BASIC) { + if ((nbEdges >= 21) || /*R1Ext = R2Ext*/(nbEdges == 17)) { // 17, 17+8*{1,2,3}, 21, 21+8*{1,2,3} + addGroup = true; + aGroup->SetName("THICKNESS"); + } + else if (nbEdges == 6) { + if (!circularFoundAndAdded) { + circularFoundAndAdded = true; + addGroup = true; + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + } + } + else if (nbEdges == 8) { + incidentPipeFound = true; + mainPipeFound = false; + radialFound = false; + flangeFound = false; + + TopExp_Explorer Ex(aGroupShapeTrsfInv,TopAbs_VERTEX); + while (Ex.More()) { + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + double x=aP.X(), y=aP.Y(), z=aP.Z(); + + + if ((Abs(x) > aR2Ext + Precision::Confusion()) || + (Abs(y) > aR2Ext + Precision::Confusion())) { + incidentPipeFound = false; + } + + if ( z < -Precision::Confusion()) { + // length of main pipe + mainPipeFound = true; + if (!mainPipeFoundAndAdded) { + mainPipeFoundAndAdded = true; + addGroup = true; + aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); + } + } + + else if (Abs(x) > (theL1-Precision::Confusion())) { + // discretisation circulaire + radialFound = true; + if (!circularFoundAndAdded) { + circularFoundAndAdded = true; + addGroup = true; + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + } + } + Ex.Next(); + } + if (incidentPipeFound) { + addGroup = true; + aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); + } + if (!addGroup && (!incidentPipeFound && + !radialFound && + !mainPipeFound && + !flangeFound)) { + // Flange (collerette) + flangeFound = true; + addGroup = true; + aGroup->SetName("FLANGE"); + } + } + else + continue; + } + else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) { + if (nbEdges >= 25) { // 25, 25+8, 25+16, 25+24 + addGroup = true; + aGroup->SetName("THICKNESS"); + } + else if ((nbEdges == 10) || (nbEdges == 6)) { + if (!circularFoundAndAdded) { + addGroup = true; + circularFoundAndAdded = true; + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + if (nbEdges == 10) { + circularFound10 = true; + } + } + else if (!circularFound10 && nbEdges == 10) { + circularFound10 = true; + addGroup = true; + aGroup->SetName("CIRCULAR_QUARTER_PIPE"); + } + } + else if (nbEdges == 8) { + incidentPipeFound = true; + mainPipeFound = true; + flangeFound = false; + + bool isNearZ0 = false; + bool isBelowZ0 = false; + + TopExp_Explorer Ex (aGroupShapeTrsfInv,TopAbs_VERTEX); + while (Ex.More()) { + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + double x=aP.X(), y=aP.Y(), z=aP.Z(); + + // tuy_princ_long_avant & tuy_princ_long_apres + //bool isMain = (((z < Precision::Confusion()) || (x < Precision::Confusion())) && + // ((y <= aR1Ext + Precision::Confusion()) || + // (y <= -(aR1Ext + Precision::Confusion())) || + // (y <= theR1 + Precision::Confusion()) || + // (y == -(theR1 + Precision::Confusion())))); + bool isMain = ((z < Precision::Confusion() || x < Precision::Confusion()) && + (fabs(y) > theR1 - Precision::Confusion() || + fabs(y) < Precision::Confusion())); + + if (!isMain) { + mainPipeFound = false; + } + + // collerette + //if (z < Precision::Confusion() && !isMain) { + // flangeFound = true; + // if (!flangeFoundAndAdded) { + // flangeFoundAndAdded = true; + // addGroup = true; + // aGroup->SetName("FLANGE"); + // } + //} + if (fabs(z) < Precision::Confusion()) isNearZ0 = true; + if (z < - Precision::Confusion()) isBelowZ0 = true; + + // tuyau incident + if ((Abs(x) > aR2Ext + Precision::Confusion()) || + (Abs(y) > aR2Ext + Precision::Confusion())) { + incidentPipeFound = false; + } + Ex.Next(); + } + if (mainPipeFound) { + addGroup = true; + aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); + } + if (incidentPipeFound) { + addGroup = true; + aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); + } + if (isNearZ0 && !isBelowZ0) { + flangeFound = true; + if (!flangeFoundAndAdded) { + flangeFoundAndAdded = true; + addGroup = true; + aGroup->SetName("FLANGE"); + } + } + if (!addGroup && (!incidentPipeFound && + !mainPipeFound && + !flangeFound && + !chamferOrFilletFound)) { + addGroup = true; + chamferOrFilletFound = true; + if (shapeType == TSHAPE_CHAMFER) + aGroup->SetName("CHAMFER"); + else + aGroup->SetName("FILLET"); + } + } + else + continue; + } + // Add group to the list + if (addGroup) + theSeq->Append(aGroup); + } +#endif + + SetErrorCode(OK); + return true; +} + +//============================================================================= +/*! + * Return faces that are laying on surface. + */ +//============================================================================= +bool AdvancedEngine_IOperations::GetFacesOnSurf + (const TopoDS_Shape &theShape, + const Handle_Geom_Surface& theSurface, + const Standard_Real theTolerance, + TopTools_ListOfShape &theFaces) +{ + GEOMAlgo_FinderShapeOn1 aFinder; + + aFinder.SetShape(theShape); + aFinder.SetTolerance(theTolerance); + aFinder.SetSurface(theSurface); + aFinder.SetShapeType(TopAbs_FACE); + aFinder.SetState(GEOMAlgo_ST_ON); + + // Sets the minimal number of inner points for the faces that do not have own + // inner points at all (for e.g. rectangular planar faces have just 2 triangles). + // Default value=3 + aFinder.SetNbPntsMin(3); + // Sets the maximal number of inner points for edges or faces. + // It is usefull for the cases when this number is very big (e.g =2000) to improve + // the performance. If this value =0, all inner points will be taken into account. + // Default value=0 + aFinder.SetNbPntsMax(100); + aFinder.Perform(); + + // Interprete results + Standard_Integer iErr = aFinder.ErrorStatus(); + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + if (iErr) { + MESSAGE(" iErr : " << iErr); + TCollection_AsciiString aMsg (" iErr : "); + aMsg += TCollection_AsciiString(iErr); + SetErrorCode(aMsg); + return false; + } + Standard_Integer iWrn = aFinder.WarningStatus(); + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx + if (iWrn) { + MESSAGE(" *** iWrn : " << iWrn); + } + + const TopTools_ListOfShape &aListRes = aFinder.Shapes(); // the result + TopTools_ListIteratorOfListOfShape anIter (aListRes); + + for (; anIter.More(); anIter.Next()) { + theFaces.Append(anIter.Value()); + } + + return true; +} + +//============================================================================= +/*! + * Creates and returns conical face. + */ +//============================================================================= +TopoDS_Shape AdvancedEngine_IOperations::MakeConicalFace + (const gp_Ax2 &theAxis, + const double theRadius, + const double theRadiusThin, + const double theHeight, + const gp_Trsf &theTrsf) +{ + BRepPrimAPI_MakeCone aMkCone (theAxis, theRadius, theRadiusThin, theHeight); + TopoDS_Shape aResult; + + aMkCone.Build(); + if (aMkCone.IsDone()) { + TopExp_Explorer anExp(aMkCone.Shape(), TopAbs_FACE); + + for (; anExp.More(); anExp.Next()) { + TopoDS_Face aFace = TopoDS::Face(anExp.Current()); + + if (aFace.IsNull() == Standard_False) { + BRepAdaptor_Surface anAdaptor(aFace, Standard_False); + + if (anAdaptor.GetType() == GeomAbs_Cone) { + // This is a conical face. Transform and return it. + BRepBuilderAPI_Transform aTransf(aFace, theTrsf, Standard_False); + + aResult = aTransf.Shape(); + break; + } + } + } + } + + return aResult; +} + +//============================================================================= +/*! + * Generate the internal group of a Pipe T-Shape + */ +//============================================================================= +bool AdvancedEngine_IOperations::MakeInternalGroup + (const Handle(GEOM_Object) &theShape, + const double theR1, const double theLen1, + const double theR2, const double theLen2, + const double theRL, double theTransLenL, + const double theRR, double theTransLenR, + const double theRI, double theTransLenI, + const Handle(TColStd_HSequenceOfTransient) &theSeq, + const gp_Trsf &theTrsf) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) { + return false; + } + + TopoDS_Shape aShape = theShape->GetValue(); + + if (aShape.IsNull()) { + SetErrorCode("Shape is not defined"); + return false; + } + + // Compute tolerance + Standard_Real aMaxTol = -RealLast(); + TopExp_Explorer anExp(aShape, TopAbs_VERTEX); + + for (; anExp.More(); anExp.Next()) { + TopoDS_Vertex aVertex = TopoDS::Vertex(anExp.Current()); + + if (aVertex.IsNull() == Standard_False) { + const Standard_Real aTol = BRep_Tool::Tolerance(aVertex); + + if (aTol > aMaxTol) { + aMaxTol = aTol; + } + } + } + + // Construct internal surfaces. + Standard_Integer i = 0; + const Standard_Integer aMaxNbSurf = 5; + Handle(Geom_Surface) aSurface[aMaxNbSurf]; + TopTools_ListOfShape aConicalFaces; + Standard_Real aTolConf = Precision::Confusion(); + + // 1. Construct the internal surface of main pipe. + gp_Ax2 anAxis1 (gp::Origin(), gp::DX(), gp::DZ()); + gp_Ax2 anAxis2 (gp::Origin(), gp::DZ(), gp::DX()); + + aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theR1); + + // 2. Construct the internal surface of incident pipe. + aSurface[i++] = new Geom_CylindricalSurface(anAxis2, theR2); + + // 3. Construct the internal surface of left reduction pipe. + if (theRL > aTolConf) { + aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theRL); + + if (theTransLenL > aTolConf) { + // 3.1. Construct the internal surface of left transition pipe. + gp_Pnt aPLeft (-theLen1, 0., 0.); + gp_Ax2 anAxisLeft (aPLeft, -gp::DX(), gp::DZ()); + TopoDS_Shape aConeLeft = + MakeConicalFace(anAxisLeft, theR1, theRL, theTransLenL, theTrsf); + + if (aConeLeft.IsNull() == Standard_False) { + aConicalFaces.Append(aConeLeft); + } + } + } + + // 4. Construct the internal surface of right reduction pipe. + if (theRR > aTolConf) { + // There is no need to construct another cylinder of the same radius. Skip it. + if (Abs(theRR - theRL) > aTolConf) { + aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theRR); + } + + if (theTransLenL > aTolConf) { + // 4.1. Construct the internal surface of right transition pipe. + gp_Pnt aPRight (theLen1, 0., 0.); + gp_Ax2 anAxisRight (aPRight, gp::DX(), gp::DZ()); + TopoDS_Shape aConeRight = + MakeConicalFace(anAxisRight, theR1, theRR, theTransLenR, theTrsf); + + if (aConeRight.IsNull() == Standard_False) { + aConicalFaces.Append(aConeRight); + } + } + } + + // 5. Construct the internal surface of incident reduction pipe. + if (theRI > aTolConf) { + aSurface[i++] = new Geom_CylindricalSurface(anAxis2, theRI); + + if (theTransLenI > aTolConf) { + // 5.1. Construct the internal surface of incident transition pipe. + gp_Pnt aPInci (0., 0., theLen2); + gp_Ax2 anAxisInci (aPInci, gp::DZ(), gp::DX()); + TopoDS_Shape aConeInci = + MakeConicalFace(anAxisInci, theR2, theRI, theTransLenI, theTrsf); + + if (aConeInci.IsNull() == Standard_False) { + aConicalFaces.Append(aConeInci); + } + } + } + + // Get faces that are laying on cylindrical surfaces. + TopTools_ListOfShape aFaces; + gp_Trsf anInvTrsf = theTrsf.Inverted(); + + for (i = 0; i < aMaxNbSurf; i++) { + if (aSurface[i].IsNull()) { + break; + } + + aSurface[i]->Transform(theTrsf); + + TopTools_ListOfShape aLocalFaces; + + if (!GetFacesOnSurf(aShape, aSurface[i], aMaxTol, aLocalFaces)) { + return false; + } + + if (i < 2) { + // Check if the result contains outer cylinders. + // It is required for main and incident pipes. + TopTools_ListIteratorOfListOfShape anIter(aLocalFaces); + + while (anIter.More()) { + TopExp_Explorer anExp(anIter.Value(), TopAbs_VERTEX); + Standard_Boolean isInside = Standard_False; + + // Get a vertex from this shape + if (anExp.More()) { + TopoDS_Vertex aVtx = TopoDS::Vertex(anExp.Current()); + + if (aVtx.IsNull() == Standard_False) { + gp_Pnt aPnt = BRep_Tool::Pnt(aVtx); + + aPnt.Transform(anInvTrsf); + + if (i == 0) { + // Check if the point is inside the main pipe. + isInside = (Abs(aPnt.X()) <= theLen1); + } else { // i == 1 + // Check if the point is inside the incident pipe. + isInside = (aPnt.Z() <= theLen2); + } + } + } + + if (isInside) { + // Keep this face. + anIter.Next(); + } else { + // Remove this face. + aLocalFaces.Remove(anIter); + } + } + } + + aFaces.Append(aLocalFaces); + } + + // Get faces that are laying on conical faces. + if (aConicalFaces.IsEmpty() == Standard_False) { + Handle(GEOM_Object) aCone = + GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + Handle(GEOM_Function) aFunction = + aCone->AddFunction(AdvancedEngine_PipeTShapeDriver::GetID(), TSHAPE_BASIC); + TopTools_ListIteratorOfListOfShape aFIter(aConicalFaces); + Handle(GEOM_Object) aConeFromShape; + + for (; aFIter.More(); aFIter.Next()) { + aFunction->SetValue(aFIter.Value()); + aConeFromShape = myShapesOperations->GetInPlace(theShape, aCone); + + if (aConeFromShape.IsNull() == Standard_False) { + aConeFromShape->GetLastFunction()->SetDescription(""); + TopoDS_Shape aConeFaces = aConeFromShape->GetValue(); + TopExp_Explorer anExp(aConeFaces, TopAbs_FACE); + + for (; anExp.More(); anExp.Next()) { + TopoDS_Face aConeFace = TopoDS::Face(anExp.Current()); + + if (aConeFace.IsNull() == Standard_False) { + aFaces.Append(aConeFace); + } + } + } + } + } + + // Create a group of internal faces. + if (aFaces.IsEmpty() == Standard_False) { + Handle(GEOM_Object) aGroup = myGroupOperations->CreateGroup(theShape, TopAbs_FACE); + + if (aGroup.IsNull() == Standard_False) { + aGroup->GetLastFunction()->SetDescription(""); + aGroup->SetName("INTERNAL_FACES"); + + TopTools_IndexedMapOfShape anIndices; + Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger; + + TopExp::MapShapes(aShape, anIndices); + + TopTools_ListIteratorOfListOfShape anIter(aFaces); + + for (; anIter.More(); anIter.Next()) { + const TopoDS_Shape &aFace = anIter.Value(); + const Standard_Integer anIndex = anIndices.FindIndex(aFace); + + if (anIndex > 0) { + aSeqIDs->Append(anIndex); + } + } + + myGroupOperations->UnionIDs(aGroup, aSeqIDs); + aGroup->GetLastFunction()->SetDescription(""); + theSeq->Append(aGroup); + } + } + + SetErrorCode(OK); + + return true; +} + +bool AdvancedEngine_IOperations::MakePipeTShapePartition(Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theH, double theW, + double theRF, bool isNormal) +{ + SetErrorCode(KO); + + // Build tools for partition operation: + // 1 face and 2 planes + // Face + Handle(GEOM_Object) arete_intersect_int, arete_intersect_ext; + Handle(GEOM_Object) wire_t, wire_t2, face_t, face_t2; + Handle(GEOM_Object) chan_racc; + Handle(GEOM_Object) vi1, vi2; + Handle(GEOM_Object) Te3; + + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + Handle(GEOM_Object) Vector_Z = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); + Vector_Z->GetLastFunction()->SetDescription(""); + + // Useful values + double aSize = 2*(theL1 + theL2); + double aR1Ext = theR1 + theW1; + double aR2Ext = theR2 + theW2; + double theVertCylinderRadius = aR2Ext + theW + theRF; + double theHoriCylinderRadius = aR1Ext + theH + theRF; + + // Common edges on internal cylinder + Handle(GEOM_Object) box_i = my3DPrimOperations->MakeBoxDXDYDZ(theR2, theR2, theR1); + box_i->GetLastFunction()->SetDescription(""); + box_i = myTransformOperations->TranslateDXDYDZ(box_i, -theR2, -theR2, 0); + box_i->GetLastFunction()->SetDescription(""); + + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + TCollection_AsciiString theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) edges_i = + myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + if (edges_i.IsNull() || edges_i->Length() == 0) { + SetErrorCode("Internal edges not found"); + return false; + } + for (int i=1; i<=edges_i->Length();i++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(edges_i->Value(i)); + anObj->GetLastFunction()->SetDescription(""); + } + arete_intersect_int = Handle(GEOM_Object)::DownCast(edges_i->Value(1)); + + // search for vertices located on both internal pipes + aFunction = theShape->GetLastFunction(); + theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) vertices_i = + myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + if (vertices_i.IsNull() || vertices_i->Length() == 0) { + SetErrorCode("Internal vertices not found"); + return false; + } + + double d1min = theR2+theW2, d2min=theR2+theW2; + for (int i = 1; i <= vertices_i->Length(); i++) { + Handle(GEOM_Object) v = Handle(GEOM_Object)::DownCast(vertices_i->Value(i)); + v->GetLastFunction()->SetDescription(""); + TopoDS_Vertex aVertex = TopoDS::Vertex(v->GetValue()); + gp_Pnt aP = BRep_Tool::Pnt(aVertex); + if (Abs(aP.X()) <= Precision::Confusion()) { + if (Abs(aP.Y()) < d1min) { + vi1 = v; + d1min = Abs(aP.Y()); + } + } else if (Abs(aP.Y()) <= Precision::Confusion()) { + if (Abs(aP.X()) < d2min) { + vi2 = v; + d2min = Abs(aP.X()); + } + } + } + if (vi1.IsNull() || vi2.IsNull()) { + SetErrorCode("Cannot find internal intersection vertices"); + return false; + } + + std::list theShapes; + + if (isNormal) { + Handle(GEOM_Object) ve1, ve2; + TopoDS_Vertex vertex1, vertex2; + + Handle(GEOM_Object) box_e = my3DPrimOperations->MakeBoxDXDYDZ(aR2Ext, aR2Ext, aR1Ext); + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ(box_e, -aR2Ext, -aR2Ext, 0); + box_e->GetLastFunction()->SetDescription(""); + + // search for vertices located on both external pipes + aFunction = theShape->GetLastFunction(); + theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) vertices_e = + myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + if (vertices_e.IsNull() || vertices_e->Length() == 0) { + SetErrorCode("External vertices not found"); + return false; + } + + double d1max = 0, d2max = 0; + for (int i = 1; i <= vertices_e->Length(); i++) { + Handle(GEOM_Object) v = Handle(GEOM_Object)::DownCast(vertices_e->Value(i)); + v->GetLastFunction()->SetDescription(""); + TopoDS_Vertex aVertex = TopoDS::Vertex(v->GetValue()); + gp_Pnt aP = BRep_Tool::Pnt(aVertex); + if (Abs(aP.X()) <= Precision::Confusion()) { + if (Abs(aP.Y()) > d1max) { + ve1 = v; + vertex1 = aVertex; + d1max = Abs(aP.Y()); + } + } else if (Abs(aP.Y()) <= Precision::Confusion()) { + if (Abs(aP.X()) > d2max) { + ve2 = v; + vertex2 = aVertex; + d2max = Abs(aP.X()); + } + } + } + if (ve1.IsNull() || ve2.IsNull()) { + SetErrorCode("Cannot find external intersection vertices"); + return false; + } + Handle(GEOM_Object) edge_e1, edge_e2; + + // Common edges on external cylinder + aFunction = theShape->GetLastFunction(); + theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) edges_e = + myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + if (edges_e.IsNull() || edges_e->Length() == 0) { + SetErrorCode("External edges not found"); + return false; + } + ShapeAnalysis_Edge sae; + for (int i=1; i<=edges_e->Length();i++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(edges_e->Value(i)); + anObj->GetLastFunction()->SetDescription(""); + TopoDS_Edge anEdge = TopoDS::Edge(anObj->GetValue()); + if ( !anEdge.IsNull() && + (sae.FirstVertex(anEdge).IsSame(vertex1) || sae.LastVertex(anEdge).IsSame(vertex1)) && + (sae.FirstVertex(anEdge).IsSame(vertex2) || sae.LastVertex(anEdge).IsSame(vertex2))) { + arete_intersect_ext = anObj; + } + } + + edge_e1 = myBasicOperations->MakeLineTwoPnt(ve1, vi1); + if (edge_e1.IsNull()) { + SetErrorCode("Edge 1 could not be built"); + return false; + } + + edge_e2 = myBasicOperations->MakeLineTwoPnt(ve2, vi2); + if (edge_e2.IsNull()) { + SetErrorCode("Edge 2 could not be built"); + return false; + } + + edge_e1->GetLastFunction()->SetDescription(""); + edge_e2->GetLastFunction()->SetDescription(""); + + std::list edge_e_elist; + edge_e_elist.push_back(arete_intersect_int); + edge_e_elist.push_back(edge_e1); + edge_e_elist.push_back(arete_intersect_ext); + edge_e_elist.push_back(edge_e2); + wire_t = myShapesOperations->MakeWire(edge_e_elist, 1e-7); + if (wire_t.IsNull()) { + SetErrorCode("Impossible to build wire"); + return false; + } + wire_t->GetLastFunction()->SetDescription(""); + face_t = myShapesOperations->MakeFace(wire_t, false); + if (face_t.IsNull()) { + SetErrorCode("Impossible to build face"); + return false; + } + face_t->GetLastFunction()->SetDescription(""); + + theShapes.push_back(theShape); + theShapes.push_back(vi1); + theShapes.push_back(vi2); + theShapes.push_back(ve1); + theShapes.push_back(ve2); + theShapes.push_back(edge_e1); + theShapes.push_back(edge_e2); + theShapes.push_back(wire_t); + theShapes.push_back(face_t); + } + else { + Handle(GEOM_Object) P1, P2, P3, P4, P5, P6; + int idP1, idP2, idP3, idP4; + int PZX, PZY; + double ZX=0, ZY=0; + std::vector LX; + std::vector LY; + Handle(GEOM_Object) box_e = my3DPrimOperations->MakeBoxDXDYDZ + (theVertCylinderRadius, theVertCylinderRadius, theHoriCylinderRadius); + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ + (box_e, -theVertCylinderRadius, -theVertCylinderRadius, 0); + box_e->GetLastFunction()->SetDescription(""); + + aFunction = theShape->GetLastFunction(); + theDesc = aFunction->GetDescription(); + Handle(TColStd_HSequenceOfTransient) extremVertices = + myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); + // Recover previous description to get rid of Propagate dump + aFunction->SetDescription(theDesc); + + if (extremVertices.IsNull() || extremVertices->Length() == 0) { + if (theRF == 0) + SetErrorCode("Vertices on chamfer not found"); + else + SetErrorCode("Vertices on fillet not found"); + return false; + } + + theShapes.push_back(theShape); + theShapes.push_back(box_e); + if (extremVertices->Length() != 6) { + // for (int i=1; i<=extremVertices->Length(); i++){ + // theShapes.push_back(Handle(GEOM_Object)::DownCast(extremVertices->Value(i))); + // } + // Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes); + // TopoDS_Shape aCompoundShape = aCompound->GetValue(); + // theShape->GetLastFunction()->SetValue(aCompoundShape); + SetErrorCode("Bad number of vertices on chamfer found"); + return false; + } + + for (int i=1; i<=extremVertices->Length(); i++){ + Handle(GEOM_Object) aV = Handle(GEOM_Object)::DownCast(extremVertices->Value(i)); + aV->GetLastFunction()->SetDescription(""); + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aV->GetValue())); + + if (Abs(aP.X()) <= Precision::Confusion()) { + if (Abs(aP.Y()) - theR2 > Precision::Confusion()) { + LX.push_back(i); + if (aP.Z()-ZX > Precision::Confusion()) { + ZX = aP.Z(); + PZX = i; + } + } + } + else { + if (Abs(aP.X()) - theR2 > Precision::Confusion()) { + LY.push_back(i); + if (aP.Z() - ZY > Precision::Confusion()) { + ZY = aP.Z(); + PZY = i; + } + } + } + } + + idP2 = PZX; + idP4 = PZY; + idP1 = LX.at(0); + if (LX.at(0) == PZX) + idP1 = LX.at(1); + idP3 = LY.at(0); + if (LY.at(0) == PZY) + idP3 = LY.at(1); + + P1 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP1)); + P2 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP2)); + P3 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP3)); + P4 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP4)); + + Handle(GEOM_Object) Cote_1 = myBasicOperations->MakeLineTwoPnt(P1, vi1); + if (Cote_1.IsNull()) { + SetErrorCode("Impossible to build edge in thickness"); + return false; + } + Cote_1->GetLastFunction()->SetDescription(""); + + Handle(GEOM_Object) Cote_2 = myBasicOperations->MakeLineTwoPnt(vi2, P3); + if (Cote_2.IsNull()) { + SetErrorCode("Impossible to build edge in thickness"); + return false; + } + Cote_2->GetLastFunction()->SetDescription(""); + + // edge_chan_princ = arete du chanfrein (ou raccord) sur le tuyau principal + // edge_chan_inc = arete du chanfrein (ou raccord) sur le tuyau incident + // std::cerr << "Getting chamfer edge on main pipe" << std::endl; + Handle(GEOM_Object) edge_chan_princ = myBlocksOperations->GetEdge(theShape, P1, P3); + if (edge_chan_princ.IsNull()) { + SetErrorCode("Impossible to find edge on main pipe"); + return false; + } + edge_chan_princ->GetLastFunction()->SetDescription(""); + + Handle(GEOM_Object) edge_chan_inc = myBlocksOperations->GetEdge(theShape, P2, P4); + if (edge_chan_inc.IsNull()) { + SetErrorCode("Impossible to find edge on incident pipe"); + return false; + } + edge_chan_inc->GetLastFunction()->SetDescription(""); + + std::list edgeList1; + edgeList1.push_back(edge_chan_princ); + edgeList1.push_back(Cote_1); + edgeList1.push_back(arete_intersect_int); + edgeList1.push_back(Cote_2); + + // std::cerr << "Creating wire 1" << std::endl; + wire_t = myShapesOperations->MakeWire(edgeList1, 1e-7); + if (wire_t.IsNull()) { + SetErrorCode("Impossible to build wire"); + return false; + } + wire_t->GetLastFunction()->SetDescription(""); + + // std::cerr << "Creating face 1" << std::endl; + face_t = myShapesOperations->MakeFace(wire_t, false); + if (face_t.IsNull()) { + SetErrorCode("Impossible to build face"); + return false; + } + face_t->GetLastFunction()->SetDescription(""); + theShapes.push_back(face_t); + + gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(P2->GetValue())); + gp_Pnt aP5 = BRep_Tool::Pnt(TopoDS::Vertex(vi1->GetValue())); + double deltaZ = aP2.Z() - aP5.Z(); + // std::cerr << "Creating new point from vi1 with deltaZ = " << deltaZ << std::endl; + Handle(GEOM_Object) P5bis = myTransformOperations->TranslateDXDYDZCopy(vi1, 0, 0, deltaZ); + if (P5bis.IsNull()) { + SetErrorCode("Impossible to translate vertex"); + return false; + } + P5bis->GetLastFunction()->SetDescription(""); + + gp_Pnt aP4 = BRep_Tool::Pnt(TopoDS::Vertex(P4->GetValue())); + gp_Pnt aP6 = BRep_Tool::Pnt(TopoDS::Vertex(vi2->GetValue())); + deltaZ = aP4.Z() - aP6.Z(); + // std::cerr << "Creating new point from vi2 with deltaZ = " << deltaZ << std::endl; + Handle(GEOM_Object) P6bis = myTransformOperations->TranslateDXDYDZCopy(vi2, 0, 0, deltaZ); + if (P6bis.IsNull()) { + SetErrorCode("Impossible to translate vertex"); + return false; + } + P6bis->GetLastFunction()->SetDescription(""); + + // std::cerr << "Creating new line 1 from 2 previous points" << std::endl; + Handle(GEOM_Object) Cote_3 = myBasicOperations->MakeLineTwoPnt(P5bis, P2); + if (Cote_3.IsNull()) { + SetErrorCode("Impossible to build edge in thickness"); + return false; + } + Cote_3->GetLastFunction()->SetDescription(""); + + // std::cerr << "Creating new line 2 from 2 previous points" << std::endl; + Handle(GEOM_Object) Cote_4 = myBasicOperations->MakeLineTwoPnt(P6bis, P4); + if (Cote_4.IsNull()) { + SetErrorCode("Impossible to build edge in thickness"); + return false; + } + Cote_4->GetLastFunction()->SetDescription(""); + + // std::cerr << "Creating new line 3 from 2 previous points" << std::endl; + Handle(GEOM_Object) Cote_5 = myBasicOperations->MakeLineTwoPnt(P5bis, P6bis); + if (Cote_4.IsNull()) { + SetErrorCode("Impossible to build edge in thickness"); + return false; + } + Cote_5->GetLastFunction()->SetDescription(""); + + //std::list edgeList2; + //edgeList2.push_back(edge_chan_inc); + //edgeList2.push_back(Cote_3); + //edgeList2.push_back(Cote_5); + //edgeList2.push_back(Cote_4); + // std::cerr << "Creating wire 2" << std::endl; + //wire_t2 = myShapesOperations->MakeWire(edgeList2, 1e-7); + //if (wire_t2.IsNull()) { + // SetErrorCode("Impossible to build wire"); + // return false; + //} + //wire_t2->GetLastFunction()->SetDescription(""); + // std::cerr << "Creating face 2" << std::endl; + //face_t2 = myShapesOperations->MakeFace(wire_t2, false); + + // Mantis issue 0021682 + face_t2 = my3DPrimOperations->MakePrismVecH(edge_chan_inc, Cote_4, - (theR2 + theW2)); + //face_t2 = my3DPrimOperations->MakePrismVecH(edge_chan_inc, Cote_4, - 2.0*theR2); + if (face_t2.IsNull()) { + SetErrorCode("Impossible to build face"); + return false; + } + face_t2->GetLastFunction()->SetDescription(""); + theShapes.push_back(face_t2); + } + + // Planes + Handle(GEOM_Object) aP0 = myBasicOperations->MakePointXYZ(0, 0, 0); + Handle(GEOM_Object) aVZ = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); + Handle(GEOM_Object) aVXZ = myBasicOperations->MakeVectorDXDYDZ(aR1Ext, 0, 0.5*(theL1+theVertCylinderRadius)); + Handle(GEOM_Object) aPlnOZ = myBasicOperations->MakePlanePntVec(aP0, aVZ, aSize); + Handle(GEOM_Object) aPlnOXZ = myBasicOperations->MakePlanePntVec(aP0, aVXZ, aSize); + aP0->GetLastFunction()->SetDescription(""); + aVZ->GetLastFunction()->SetDescription(""); + aVXZ->GetLastFunction()->SetDescription(""); + aPlnOZ->GetLastFunction()->SetDescription(""); + aPlnOXZ->GetLastFunction()->SetDescription(""); + theShapes.push_back(aPlnOZ); + theShapes.push_back(aPlnOXZ); + + // Partition + Handle(TColStd_HSequenceOfTransient) partitionShapes = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) theTools = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) theKeepInside = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) theRemoveInside = new TColStd_HSequenceOfTransient; + Handle(TColStd_HArray1OfInteger) theMaterials; + + partitionShapes->Append(theShape); + theTools->Append(aPlnOZ); + if (Abs(aR1Ext - aR2Ext) > Precision::Confusion()) + theTools->Append(aPlnOXZ); + theTools->Append(face_t); + if (!isNormal) + theTools->Append(face_t2); + + Te3 = myBooleanOperations->MakePartition + (partitionShapes, theTools, theKeepInside, theRemoveInside, + TopAbs_SOLID, false, theMaterials, 0, false, Standard_False); + if (Te3.IsNull()) { + SetErrorCode("Impossible to build partition of TShape"); + return false; + } + Te3->GetLastFunction()->SetDescription(""); + + // Last verification: result should be a block + std::list errList; + if (!myBlocksOperations->CheckCompoundOfBlocks(Te3,errList)) { + SetErrorCode("TShape is not a compound of block"); + return false; + } + +// // BEGIN Compound of created shapes - Only for debug purpose +// theShapes.clear(); +// theShapes.push_back(theShape); +// theShapes.push_back(aPlnOZ); +// if (Abs(aR1Ext - aR2Ext) > Precision::Confusion() ) +// theShapes.push_back(aPlnOXZ); +// theShapes.push_back(face_t); +// if (!isNormal) +// theShapes.push_back(face_t2); +// +// Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes); +// TopoDS_Shape aCompoundShape = aCompound->GetValue(); +// theShape->GetLastFunction()->SetValue(aCompoundShape); +// // END Compound of created shapes - Only for debug purpose + + TopoDS_Shape aShape = Te3->GetValue(); + theShape->GetLastFunction()->SetValue(aShape); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return false; + } + + SetErrorCode(OK); + return true; +} + +// Mirror and glue faces +bool AdvancedEngine_IOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2) +{ + SetErrorCode(KO); + + // Useful values + double aSize = 2*(theL1 + theL2); + double aR1Ext = theR1 + theW1; + + // Planes + Handle(GEOM_Object) aP0 = myBasicOperations->MakePointXYZ(0, 0, 0); + aP0->GetLastFunction()->SetDescription(""); + Handle(GEOM_Object) aVX = myBasicOperations->MakeVectorDXDYDZ(1, 0, 0); + Handle(GEOM_Object) aVY = myBasicOperations->MakeVectorDXDYDZ(0, 1, 0); + aVX->GetLastFunction()->SetDescription(""); + aVY->GetLastFunction()->SetDescription(""); + Handle(GEOM_Object) aPlane_OX = myBasicOperations->MakePlanePntVec(aP0, aVX, 2*(aR1Ext + theL2)); + Handle(GEOM_Object) aPlane_OY = myBasicOperations->MakePlanePntVec(aP0, aVY, aSize); + aPlane_OX->GetLastFunction()->SetDescription(""); + aPlane_OY->GetLastFunction()->SetDescription(""); + + Handle(GEOM_Object) Te4 = myTransformOperations->MirrorPlaneCopy(theShape, aPlane_OX); + if (Te4.IsNull()) { + SetErrorCode("Impossible to build mirror of quarter TShape"); + return false; + } + + Handle(GEOM_Object) Te5 = myTransformOperations->MirrorPlaneCopy(theShape, aPlane_OY); + if (Te5.IsNull()) { + SetErrorCode("Impossible to build mirror of half TShape"); + return false; + } + + Handle(GEOM_Object) Te6 = myTransformOperations->MirrorPlaneCopy(Te4, aPlane_OY); + if (Te6.IsNull()) { + SetErrorCode("Impossible to build mirror of half TShape"); + return false; + } + + std::list aShapesList; + aShapesList.push_back(theShape); + aShapesList.push_back(Te4); + aShapesList.push_back(Te5); + aShapesList.push_back(Te6); + Handle(GEOM_Object) Te7 = myShapesOperations->MakeCompound(aShapesList); + if (Te7.IsNull()) { + SetErrorCode("Impossible to build compound"); + return false; + } + + // Copy source shape + TopoDS_Shape aShapeCopy; + TColStd_IndexedDataMapOfTransientTransient aMapTShapes; + TNaming_CopyShape::CopyTool(Te7->GetValue(), aMapTShapes, aShapeCopy); + + Handle(GEOM_Object) Te8 = myShapesOperations->MakeGlueFaces(Te7, 1e-7, true); + if (Te8.IsNull()) { + SetErrorCode("Impossible to glue faces of TShape"); + return false; + } + + TopoDS_Shape aShape = Te8->GetValue(); + BRepCheck_Analyzer anAna (aShape, Standard_True); + + if (!anAna.IsValid()) { + // Try to do gluing with the tolerance equal to maximal + // tolerance of vertices of the source shape. + Standard_Real aTolMax = -RealLast(); + + for (TopExp_Explorer ExV (aShapeCopy, TopAbs_VERTEX); ExV.More(); ExV.Next()) { + TopoDS_Vertex aVertex = TopoDS::Vertex(ExV.Current()); + Standard_Real aTol = BRep_Tool::Tolerance(aVertex); + + if (aTol > aTolMax) { + aTolMax = aTol; + } + } + + // Perform gluing + Te7->GetLastFunction()->SetValue(aShapeCopy); + Te8 = myShapesOperations->MakeGlueFaces(Te7, aTolMax, true); + + if (Te8.IsNull()) { + SetErrorCode("Impossible to glue faces of TShape"); + return false; + } + + aShape = Te8->GetValue(); + } + + + theShape->GetLastFunction()->SetValue(aShape); + + Te4->GetLastFunction()->SetDescription(""); + Te5->GetLastFunction()->SetDescription(""); + Te6->GetLastFunction()->SetDescription(""); + Te7->GetLastFunction()->SetDescription(""); + Te8->GetLastFunction()->SetDescription(""); + + SetErrorCode(OK); + return true; +} + +//======================================================================= +//function : MakePipeTShapeThicknessReduction +//purpose : Static method. Add thiskness reduction elements at the three +// open ends of the T-Shape. +//======================================================================= +TopoDS_Shape AdvancedEngine_IOperations::MakePipeTShapeThicknessReduction + (TopoDS_Shape theShape, + double r1, double w1, double l1, + double r2, double w2, double l2, + double rL, double wL, double ltransL, double lthinL, + double rR, double wR, double ltransR, double lthinR, + double rI, double wI, double ltransI, double lthinI, + bool fuseReductions) +{ + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + // + // ---------------------. + // W \ + // ---------------------. \ + // ^ \ '-----------------. + // |R \ Wthin | + // | '-----------------' + // v Rthin + // --.--.--.--.--.--.--.--.--.--.--.--.--.--.-- + // Ltrans Lthin + + TopoDS_Shape aResult = theShape; + double aTol = Precision::Confusion(); + + gp_Vec aVX = gp::DX(), aVZ = gp::DZ(); + + // Left reduction (rL, wL, ltransL, lthinL) + if (rL > aTol && wL > aTol && ltransL > aTol) { + gp_Pnt aPLeft (-l1, 0, 0); + gp_Ax2 anAxesLeft (aPLeft, -aVX, aVZ); + TopoDS_Shape aReductionLeft = AdvancedEngine_IOperations::MakeThicknessReduction + (anAxesLeft, r1, w1, rL, wL, ltransL, lthinL, fuseReductions); + + if (fuseReductions) { + BRepAlgoAPI_Fuse fuseL (aResult, aReductionLeft); + if (!fuseL.IsDone()) + StdFail_NotDone::Raise("Cannot fuse Te with left reduction"); + aResult = fuseL.Shape(); + } + else { + BRep_Builder B; + TopoDS_Compound C; + B.MakeCompound(C); + B.Add(C, aResult); + B.Add(C, aReductionLeft); + aResult = C; + } + } + + // Right reduction + if (rR > aTol && wR > aTol && ltransR > aTol) { + gp_Pnt aPRight (l1, 0, 0); + gp_Ax2 anAxesRight (aPRight, aVX, aVZ); + TopoDS_Shape aReductionRight = AdvancedEngine_IOperations::MakeThicknessReduction + (anAxesRight, r1, w1, rR, wR, ltransR, lthinR, fuseReductions); + + if (fuseReductions) { + BRepAlgoAPI_Fuse fuseR (aResult, aReductionRight); + if (!fuseR.IsDone()) + StdFail_NotDone::Raise("Cannot fuse Te with right reduction"); + aResult = fuseR.Shape(); + } + else { + BRep_Builder B; + TopoDS_Compound C; + B.MakeCompound(C); + B.Add(C, aResult); + B.Add(C, aReductionRight); + aResult = C; + } + } + + // Incident reduction + if (rI > aTol && wI > aTol && ltransI > aTol) { + gp_Pnt aPInci (0, 0, l2); + gp_Ax2 anAxesInci (aPInci, aVZ, aVX); + TopoDS_Shape aReductionInci = AdvancedEngine_IOperations::MakeThicknessReduction + (anAxesInci, r2, w2, rI, wI, ltransI, lthinI, fuseReductions); + + if (fuseReductions) { + BRepAlgoAPI_Fuse fuseInci (aResult, aReductionInci); + if (!fuseInci.IsDone()) + StdFail_NotDone::Raise("Cannot fuse Te with incident reduction"); + aResult = fuseInci.Shape(); + } + else { + BRep_Builder B; + TopoDS_Compound C; + B.MakeCompound(C); + B.Add(C, aResult); + B.Add(C, aReductionInci); + aResult = C; + } + } + + // Get rid of extra compounds + TopTools_ListOfShape listShapeRes; + GEOMUtils::AddSimpleShapes(aResult, listShapeRes); + aResult = listShapeRes.First(); // useful for the case "fuseReductions == true" + + if (!fuseReductions && listShapeRes.Extent() > 1) { + // Simplify T-Shape compound (get rid of sub-compounds) and glue duplicated faces + BRep_Builder B; + TopoDS_Compound C; + B.MakeCompound(C); + + TopTools_ListIteratorOfListOfShape itSub (listShapeRes); + for (; itSub.More(); itSub.Next()) + B.Add(C, itSub.Value()); + + // GlueFaces + aResult = GEOMImpl_GlueDriver::GlueFaces(C, Precision::Confusion(), Standard_True); + } + + return aResult; +} + +//======================================================================= +//function : MakeThicknessReduction +//purpose : Static method. Create one thickness reduction element. +//======================================================================= +TopoDS_Shape AdvancedEngine_IOperations::MakeThicknessReduction (gp_Ax2 theAxes, + const double R, const double W, + const double Rthin, const double Wthin, + const double Ltrans, const double Lthin, + bool fuse) +{ + double aTol = Precision::Confusion(); + if (Rthin < aTol || Wthin < aTol || Ltrans < aTol) { + StdFail_NotDone::Raise("Cannot build thickness reduction: too small values"); + } + bool isThinPart = (Lthin > aTol); + + // . + // W |\ + // . \ + // ^ \ '-----------------. + // |R \| | Wthin + // | '-----------------' + // v Rthin + // --.--.--.--.--.--.--.--.--.--.--.--.--> theAxes.Direction() + // Ltrans Lthin + + double RExt = R + W; + double RthinExt = Rthin + Wthin; + + gp_Dir aNormal = theAxes.Direction(); + gp_Dir anXDir = theAxes.XDirection(); + gp_Pnt aPntCyl (theAxes.Location().XYZ() + aNormal.XYZ()*Ltrans); + gp_Ax2 anAxesCyl (aPntCyl, aNormal, anXDir); + + // Build the transition part + BRepPrimAPI_MakeCone ConeExt (theAxes, RExt, RthinExt, Ltrans); + BRepPrimAPI_MakeCone ConeInt (theAxes, R, Rthin, Ltrans); + ConeExt.Build(); + ConeInt.Build(); + if (!ConeExt.IsDone() || !ConeInt.IsDone()) + StdFail_NotDone::Raise("Cannot build cones of thickness reduction"); + BRepAlgoAPI_Cut cut1 (ConeExt.Shape(), ConeInt.Shape()); + if (!cut1.IsDone()) + StdFail_NotDone::Raise("Coudn't build transition part of thickness reduction"); + TopoDS_Shape aReduction = cut1.Shape(); + + // Build the thin part, if required + TopoDS_Shape aThinPart; + if (isThinPart) { + BRepPrimAPI_MakeCylinder CExt (anAxesCyl, RthinExt, Lthin); + BRepPrimAPI_MakeCylinder CInt (anAxesCyl, Rthin, Lthin); + CExt.Build(); + CInt.Build(); + if (!CExt.IsDone() || !CInt.IsDone()) + StdFail_NotDone::Raise("Cannot build cylinders of thickness reduction"); + BRepAlgoAPI_Cut cut2 (CExt.Shape(), CInt.Shape()); + if (!cut2.IsDone()) + StdFail_NotDone::Raise("Coudn't build thin part of thickness reduction"); + aThinPart = cut2.Shape(); + } + + // Join parts + if (fuse) { + if (isThinPart) { + BRepAlgoAPI_Fuse fuse1 (aReduction, aThinPart); + if (!fuse1.IsDone()) + StdFail_NotDone::Raise("Cannot fuse parts of thickness reduction"); + aReduction = fuse1.Shape(); + } + } + else { + // Partition the reduction on blocks + gp_Ax3 anAxesPln1 (aPntCyl, theAxes.XDirection(), aNormal); + gp_Ax3 anAxesPln2 (aPntCyl, theAxes.YDirection(), aNormal); + gp_Pln aPln1 (anAxesPln1); + gp_Pln aPln2 (anAxesPln2); + double aSize = Ltrans + Lthin + R + Rthin + Wthin; // to guarantee enough size in all directions + TopoDS_Shape aTool1 = BRepBuilderAPI_MakeFace(aPln1, -aSize, +aSize, -aSize, +aSize).Shape(); + TopoDS_Shape aTool2 = BRepBuilderAPI_MakeFace(aPln2, -aSize, +aSize, -aSize, +aSize).Shape(); + + GEOMAlgo_Splitter PS; + PS.AddArgument(aReduction); + if (isThinPart) + PS.AddArgument(aThinPart); + PS.AddTool(aTool1); + PS.AddTool(aTool2); + PS.SetLimit(TopAbs_SOLID); + PS.Perform(); + + aReduction = PS.Shape(); + } + + return aReduction; +} + +//============================================================================= +/*! + * MakePipeTShape + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) + AdvancedEngine_IOperations::MakePipeTShape(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + bool theHexMesh) +{ + MESSAGE("AdvancedEngine_IOperations::MakePipeTShape"); + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(AdvancedEngine_PipeTShapeDriver::GetID(), TSHAPE_BASIC); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; + + AdvancedEngine_IPipeTShape aData (aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + if (isTRL || isTRR || isTRI) { + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape, TSHAPE_BASIC, theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., aSeq, gp_Trsf())) + return NULL; + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, gp_Trsf())) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShape(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theHexMesh; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * MakePipeTShapeWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups.. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +AdvancedEngine_IOperations::MakePipeTShapeWithPosition + (double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + bool theHexMesh, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3) +{ + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + ///////////////// + // TSHAPE CODE + ///////////////// + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(AdvancedEngine_PipeTShapeDriver::GetID(), TSHAPE_BASIC); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; + + // Check new position + if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { + return NULL; + } + + AdvancedEngine_IPipeTShape aData(aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + if (isTRL || isTRR || isTRI) { + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + TopoDS_Shape Te = aShape->GetValue(); + + // Set Position + gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); + BRepBuilderAPI_Transform aTransformation(Te, aTrsf, Standard_False); + TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); + aFunction->SetValue(aTrsf_Shape); + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape,TSHAPE_BASIC, theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., aSeq, aTrsf)) { + return NULL; + } + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, aTrsf)) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShape(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theHexMesh << ", " << theP1 << ", " << theP2 << ", " << theP3; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * MakePipeTShapeChamfer + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of chamfer. + * \param theW Width of chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +AdvancedEngine_IOperations::MakePipeTShapeChamfer + (double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theH, double theW, + bool theHexMesh) +{ + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(AdvancedEngine_PipeTShapeDriver::GetID(), TSHAPE_CHAMFER); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; + + AdvancedEngine_IPipeTShape aData(aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetH(theH); + aData.SetW(theW); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // BEGIN of chamfer + TopoDS_Shape aShapeShape = aShape->GetValue(); + TopTools_IndexedMapOfShape anEdgesIndices; + TopExp::MapShapes(aShapeShape, anEdgesIndices); + // Common edges on external cylinders + Handle(GEOM_Object) box_e; + if (theHexMesh) { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); + } + else { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); + } + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); + box_e->GetLastFunction()->SetDescription(""); + + Handle(TColStd_HSequenceOfInteger) edges_e = + myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + box_e->GetLastFunction()->SetDescription(""); + + if (edges_e.IsNull() || edges_e->Length() == 0) { + SetErrorCode("External edges not found"); + return NULL; + } + int nbEdgesInChamfer = 0; + std::list theEdges; + for (int i=1; i<=edges_e->Length();i++) { + int edgeID = edges_e->Value(i); + TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); + TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); + int iv=0; + while (Ex.More()) { + iv ++; + gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { + nbEdgesInChamfer ++; + theEdges.push_back(edgeID); + } + Ex.Next(); + } + if (theHexMesh && nbEdgesInChamfer == 1) + break; + } + Handle(GEOM_Object) aChamfer; + try { + aChamfer = myLocalOperations->MakeChamferEdges(aShape, theW, theH, theEdges); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + if (aChamfer.IsNull()) { + SetErrorCode("Chamfer can not be computed on the given shape with the given parameters"); + return NULL; + } + aChamfer->GetLastFunction()->SetDescription(""); + + TopoDS_Shape aChamferShape = aChamfer->GetValue(); + aFunction->SetValue(aChamferShape); + // END of chamfer + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, 0, false)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (isTRL || isTRR || isTRI) { + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, + theH, theW, 0., aSeq, gp_Trsf())) + return NULL; + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, gp_Trsf())) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeChamfer(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theH << ", " << theW << ", " << theHexMesh; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * MakePipeTShapeChamferWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of chamfer. + * \param theW Width of chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +AdvancedEngine_IOperations::MakePipeTShapeChamferWithPosition + (double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theH, double theW, + bool theHexMesh, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3) +{ + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(AdvancedEngine_PipeTShapeDriver::GetID(), TSHAPE_CHAMFER); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; + + // Check new position + if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { + return NULL; + } + + AdvancedEngine_IPipeTShape aData(aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetH(theH); + aData.SetW(theW); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // BEGIN of chamfer + TopoDS_Shape aShapeShape = aShape->GetValue(); + TopTools_IndexedMapOfShape anEdgesIndices; + TopExp::MapShapes(aShapeShape, anEdgesIndices); + // Common edges on external cylinders + Handle(GEOM_Object) box_e; + if (theHexMesh) { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); + } + else { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); + } + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); + box_e->GetLastFunction()->SetDescription(""); + + Handle(TColStd_HSequenceOfInteger) edges_e = + myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + box_e->GetLastFunction()->SetDescription(""); + + if (edges_e.IsNull() || edges_e->Length() == 0) { + SetErrorCode("External edges not found"); + return NULL; + } + int nbEdgesInChamfer = 0; + std::list theEdges; + for (int i=1; i<=edges_e->Length();i++) { + int edgeID = edges_e->Value(i); + TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); + TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); + while (Ex.More()) { + gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { + nbEdgesInChamfer ++; + theEdges.push_back(edgeID); + } + Ex.Next(); + } + if (theHexMesh && nbEdgesInChamfer == 1) + break; + } + Handle(GEOM_Object) aChamfer; + try { + aChamfer = myLocalOperations->MakeChamferEdges(aShape, theW, theH, theEdges); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + if (aChamfer.IsNull()) { + SetErrorCode("Chamfer can not be computed on the given shape with the given parameters"); + return NULL; + } + aChamfer->GetLastFunction()->SetDescription(""); + + TopoDS_Shape aChamferShape = aChamfer->GetValue(); + aFunction->SetValue(aChamferShape); + // END of chamfer + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, 0, false)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (isTRL || isTRR || isTRI) { + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // Set Position + gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); + BRepBuilderAPI_Transform aTransformation (aShape->GetValue(), aTrsf, Standard_False); + TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); + aFunction->SetValue(aTrsf_Shape); + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, + theH, theW, 0., aSeq, aTrsf)) + return NULL; + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, aTrsf)) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeChamfer(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theH << ", " << theW << ", " << theHexMesh << ", " + << theP1 << ", " << theP2 << ", " << theP3; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * MakePipeTShapeFillet + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +AdvancedEngine_IOperations::MakePipeTShapeFillet + (double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theRF, bool theHexMesh) +{ + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(AdvancedEngine_PipeTShapeDriver::GetID(), TSHAPE_FILLET); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; + + AdvancedEngine_IPipeTShape aData(aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetRF(theRF); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // BEGIN of fillet + TopoDS_Shape aShapeShape = aShape->GetValue(); + TopTools_IndexedMapOfShape anEdgesIndices; + TopExp::MapShapes(aShapeShape, anEdgesIndices); + // Common edges on external cylinders + Handle(GEOM_Object) box_e; + if (theHexMesh) { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); + } + else { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); + } + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); + box_e->GetLastFunction()->SetDescription(""); + + Handle(TColStd_HSequenceOfInteger) edges_e = + myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + box_e->GetLastFunction()->SetDescription(""); + + if (edges_e.IsNull() || edges_e->Length() == 0) { + SetErrorCode("External edges not found"); + return NULL; + } + int nbEdgesInFillet = 0; + std::list theEdges; + for (int i=1; i<=edges_e->Length();i++) { + int edgeID = edges_e->Value(i); + TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); + TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); + while (Ex.More()) { + gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { + nbEdgesInFillet ++; + theEdges.push_back(edgeID); + } + Ex.Next(); + } + if (theHexMesh && nbEdgesInFillet == 1) + break; + } + + Handle(GEOM_Object) aFillet; + try { + aFillet = myLocalOperations->MakeFilletEdges(aShape, theRF, theEdges); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + if (aFillet.IsNull()) { + //SetErrorCode("Fillet can not be computed on the given shape with the given parameters"); + SetErrorCode(myLocalOperations->GetErrorCode()); + return NULL; + } + aFillet->GetLastFunction()->SetDescription(""); + + TopoDS_Shape aFilletShape = aFillet->GetValue(); + aFunction->SetValue(aFilletShape); + // END of fillet + +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (1) +// the following block, when enabled, leads to partitioning problems +#if 0 +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (1) + // BEGIN: Limit tolerances (debug) + Handle(GEOM_Object) aCorr1 = myHealingOperations->LimitTolerance(aShape, 1e-07); + TopoDS_Shape aCorr1Shape = aCorr1->GetValue(); + aShape->GetLastFunction()->SetValue(aCorr1Shape); + aCorr1->GetLastFunction()->SetDescription(""); + // END: Limit tolerances (debug) +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (2) +#endif +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (2) + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, 0, 0, theRF, false)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (isTRL || isTRR || isTRI) { + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape, TSHAPE_FILLET, theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., theRF, aSeq, gp_Trsf())) + return NULL; + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, gp_Trsf())) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeFillet(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theRF << ", " << theHexMesh; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * MakePipeTShapeFilletWithPosition + * \brief Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +AdvancedEngine_IOperations::MakePipeTShapeFilletWithPosition + (double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theRF, bool theHexMesh, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3) +{ + SetErrorCode(KO); + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(AdvancedEngine_PipeTShapeDriver::GetID(), TSHAPE_FILLET); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; + + // Check new position + if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { + return NULL; + } + + AdvancedEngine_IPipeTShape aData(aFunction); + + aData.SetR1(theR1); + aData.SetW1(theW1); + aData.SetL1(theL1); + aData.SetR2(theR2); + aData.SetW2(theW2); + aData.SetL2(theL2); + aData.SetRF(theRF); + aData.SetHexMesh(theHexMesh); + + bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); + bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); + bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); + + //Compute the resulting value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("TShape driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // BEGIN of fillet + TopoDS_Shape aShapeShape = aShape->GetValue(); + TopTools_IndexedMapOfShape anEdgesIndices; + TopExp::MapShapes(aShapeShape, anEdgesIndices); + // Common edges on external cylinders + Handle(GEOM_Object) box_e; + if (theHexMesh) { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); + } + else { + box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); + } + box_e->GetLastFunction()->SetDescription(""); + box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); + box_e->GetLastFunction()->SetDescription(""); + + Handle(TColStd_HSequenceOfInteger) edges_e = + myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); + box_e->GetLastFunction()->SetDescription(""); + + if (edges_e.IsNull() || edges_e->Length() == 0) { + SetErrorCode("External edges not found"); + return NULL; + } + int nbEdgesInFillet = 0; + std::list theEdges; + for (int i=1; i<=edges_e->Length();i++) { + int edgeID = edges_e->Value(i); + TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); + TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); + while (Ex.More()) { + gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); + if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { + nbEdgesInFillet ++; + theEdges.push_back(edgeID); + } + Ex.Next(); + } + if (theHexMesh && nbEdgesInFillet == 1) + break; + } + + Handle(GEOM_Object) aFillet; + try { + aFillet = myLocalOperations->MakeFilletEdges(aShape, theRF, theEdges); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + if (aFillet.IsNull()) { + SetErrorCode("Fillet can not be computed on the given shape with the given parameters"); + return NULL; + } + aFillet->GetLastFunction()->SetDescription(""); + + TopoDS_Shape aFilletShape = aFillet->GetValue(); + aFunction->SetValue(aFilletShape); + // END of fillet + +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (3) +// the following block, when enabled, leads to partitioning problems +#if 0 +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (3) + // BEGIN: Limit tolerances (debug) + Handle(GEOM_Object) aCorr1 = myHealingOperations->LimitTolerance(aShape, 1e-07); + TopoDS_Shape aCorr1Shape = aCorr1->GetValue(); + aShape->GetLastFunction()->SetValue(aCorr1Shape); + aCorr1->GetLastFunction()->SetDescription(""); + // END: Limit tolerances (debug) +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (4) +#endif +// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (4) + + if (theHexMesh) { + if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, 0, 0, theRF, false)) + return NULL; + if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) + return NULL; + } + + // Add thickness reduction elements + // at the three extremities: Left, Right and Incident + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (isTRL || isTRR || isTRI) { + TopoDS_Shape aResShape = + MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + !theHexMesh); + aFunction->SetValue(aResShape); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // Set Position + gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); + BRepBuilderAPI_Transform aTransformation (aShape->GetValue(), aTrsf, Standard_False); + TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); + aFunction->SetValue(aTrsf_Shape); + + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append(aShape); + + try { + if (theHexMesh) { + // Get the groups + if (!MakeGroups(aShape, TSHAPE_FILLET, theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., theRF, aSeq, aTrsf)) + return NULL; + } + + // Get internal group. + if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, + theRR, theLtransR, theRI, theLtransI, + aSeq, aTrsf)) { + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aListRes("["); + // Iterate over the sequence aSeq + Standard_Integer aNbGroups = aSeq->Length(); + Standard_Integer i = 1; + for (; i <= aNbGroups; i++) { + Handle(Standard_Transient) anItem = aSeq->Value(i); + if (anItem.IsNull()) continue; + Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); + if (aGroup.IsNull()) continue; + //Make a Python command + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aListRes += anEntry + ", "; + } + aListRes.Trunc(aListRes.Length() - 2); + + GEOM::TPythonDump pd (aFunction); + + pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeFillet(" + << theR1 << ", " << theW1 << ", " << theL1 << ", " + << theR2 << ", " << theW2 << ", " << theL2 << ", " + << theRF << ", " << theHexMesh << ", " + << theP1 << ", " << theP2 << ", " << theP3; + + // thickness reduction + if (isTRL) + pd << ", theRL=" << theRL << ", theWL=" << theWL + << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; + if (isTRR) + pd << ", theRR=" << theRR << ", theWR=" << theWR + << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; + if (isTRI) + pd << ", theRI=" << theRI << ", theWI=" << theWI + << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; + + pd << ")"; + + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * This function allows to create a disk already divided into blocks. It can be + * used to create divided pipes for later meshing in hexaedra. + * \param theR Radius of the disk + * \param theRatio Relative size of the central square diagonal against the disk diameter + * \param theOrientation Plane on which the disk will be built + * \param thePattern The division pattern of the disk (hexagon or square in the center) + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedDisk (double theR, double theRatio, + int theOrientation, int thePattern) +{ + SetErrorCode(KO); + + if (theOrientation != 1 && + theOrientation != 2 && + theOrientation != 3) + { + SetErrorCode("theOrientation must be 1(=OXY), 2(=OYZ) or 3(=OZX)"); + return NULL; + } + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDDISK); + + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(AdvancedEngine_DividedDiskDriver::GetID(), DIVIDEDDISK_R_RATIO); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != AdvancedEngine_DividedDiskDriver::GetID()) return NULL; + + AdvancedEngine_IDividedDisk aData (aFunction); + + aData.SetR(theR); + aData.SetRatio(theRatio); + aData.SetOrientation(theOrientation); + aData.SetType(thePattern); + + //Compute the resulting value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("DividedDisk driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + std::string aPatternStr; + + switch(thePattern) + { + case 0: + aPatternStr = "GEOM.SQUARE"; + break; + case 1: + aPatternStr = "GEOM.HEXAGON"; + break; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedDisk(" << theR << ", " << theOrientation << ", " << aPatternStr.c_str() << ")"; + + SetErrorCode(OK); + + return aShape; +} + +//============================================================================= +/*! + * This function allows to create a disk already divided into blocks. It can be + * used to create divided pipes for later meshing in hexaedra. + * \param theR Radius of the disk + * \param theRatio Relative size of the central square diagonal against the disk diameter + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedDiskPntVecR (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR, + double theRatio, + int thePattern) +{ + SetErrorCode(KO); + + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDDISK); + + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(AdvancedEngine_DividedDiskDriver::GetID(), DIVIDEDDISK_R_VECTOR_PNT); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != AdvancedEngine_DividedDiskDriver::GetID()) return NULL; + + AdvancedEngine_IDividedDisk aData (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + + aData.SetCenter(aRefPnt); + aData.SetVector(aRefVec); + + aData.SetR(theR); + aData.SetRatio(theRatio); + aData.SetType(thePattern); + + //Compute the resulting value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("DividedDisk driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + std::string aPatternStr; + + switch(thePattern) + { + case 0: + aPatternStr = "GEOM.SQUARE"; + break; + case 1: + aPatternStr = "GEOM.HEXAGON"; + break; + } + + + //Make a Python command + GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedDiskPntVecR(" << thePnt << ", " << theVec << ", " << theR << ", " << aPatternStr.c_str() << ")"; + + SetErrorCode(OK); + + return aShape; +} + +//============================================================================= +/*! + * Builds a cylinder prepared for hexa meshes + * \param theR Radius of the cylinder + * \param theH Height of the cylinder + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedCylinder (double theR, + double theH, + int thePattern) +{ + SetErrorCode(KO); + + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDCYLINDER); + + Handle(GEOM_Object) aBaseShape = MakeDividedDisk(theR, 67.0, 1, thePattern); + aBaseShape->GetLastFunction()->SetDescription(""); // Erase dump of MakeDividedDisk + + aShape = my3DPrimOperations->MakePrismDXDYDZ(aBaseShape,0.0,0.0,theH, -1.0); + + Handle(GEOM_Function) aFunction = aShape->GetLastFunction(); + aFunction->SetDescription(""); // Erase dump of MakePrismDXDYDZ + aShape->SetType(GEOM_DIVIDEDCYLINDER); + + std::string aPatternStr; + + switch(thePattern) + { + case 0: + aPatternStr = "GEOM.SQUARE"; + break; + case 1: + aPatternStr = "GEOM.HEXAGON"; + break; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedCylinder(" << theR << ", " << theH << ", " << aPatternStr.c_str() << ")"; + + SetErrorCode(OK); + + return aShape; +} +//============================================================================= +/*! + * Create a smoothing surface from a set of points + * \param thelPoints list of points or compounds of points + * \param theNbMax maximum number of Bezier pieces in the resulting surface. + * \param theDegMax maximum degree of the resulting BSpline surface + * \param theDMax specifies maximum value of the GeomPlate_PlateG0Criterion criterion. + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +Handle(GEOM_Object) AdvancedEngine_IOperations::MakeSmoothingSurface (std::list thelPoints, + int theNbMax, + int theDegMax, + double theDMax) +{ + SetErrorCode(KO); + + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_SMOOTHINGSURFACE); + + //Add a new shape function with parameters + Handle(GEOM_Function) aFunction = aShape->AddFunction(AdvancedEngine_SmoothingSurfaceDriver::GetID(), SMOOTHINGSURFACE_LPOINTS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != AdvancedEngine_SmoothingSurfaceDriver::GetID()) return NULL; + + AdvancedEngine_ISmoothingSurface aData (aFunction); + + int aLen = thelPoints.size(); + aData.SetLength(aLen); + int ind = 1; + std::list::iterator it = thelPoints.begin(); + for (; it != thelPoints.end(); it++, ind++) { + Handle(GEOM_Function) aRefObj = (*it)->GetLastFunction(); + if (aRefObj.IsNull()) { + SetErrorCode("NULL point or compound for bSplineFaceShape"); + return NULL; + } + aData.SetPntOrComp(ind, aRefObj); + } + + aData.SetNbMax(theNbMax); + aData.SetDegMax(theDegMax); + aData.SetDMax(theDMax); + + //Compute the resulting value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("SmoothingSurface driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump pd (aFunction); + pd << aShape << " = geompy.MakeSmoothingSurface(["; + it = thelPoints.begin(); + pd << (*it++); + while (it != thelPoints.end()) { + pd << ", " << (*it++); + } + pd << "], " + << theNbMax << ", " + << theDegMax << ", " + << theDMax <<")"; + + SetErrorCode(OK); + + return aShape; +} diff --git a/src/AdvancedEngine/AdvancedEngine_IOperations.hxx b/src/AdvancedEngine/AdvancedEngine_IOperations.hxx new file mode 100644 index 000000000..939dd0171 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_IOperations.hxx @@ -0,0 +1,247 @@ +// Copyright (C) 2007-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 +// +// File : AdvancedEngine_IOperations.hxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#ifndef _AdvancedEngine_IOperations_HXX_ +#define _AdvancedEngine_IOperations_HXX_ + +#include "AdvancedEngine.hxx" + +#include "GEOM_IOperations.hxx" +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +#include +#include + +class GEOMImpl_IBasicOperations; +class GEOMImpl_IBooleanOperations; +class GEOMImpl_IShapesOperations; +class GEOMImpl_ITransformOperations; +class GEOMImpl_IBlocksOperations; +class GEOMImpl_I3DPrimOperations; +class GEOMImpl_ILocalOperations; +class GEOMImpl_IHealingOperations; +class GEOMImpl_IGroupOperations; +class Handle_Geom_Surface; +class TopTools_ListOfShape; + +class ADVANCEDENGINE_EXPORT AdvancedEngine_IOperations: public GEOM_IOperations +{ +private: + bool MakePipeTShapePartition(Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theH = 0, double theW = 0, + double theRF = 0, bool isNormal = true); + + bool MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2); + + bool MakePipeTShapeThicknessReduction (Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI); + + bool MakeGroups(Handle(GEOM_Object) theShape, int shapType, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theH, double theW, double theRF, + Handle(TColStd_HSequenceOfTransient) theSeq, + gp_Trsf aTrsf); + + bool GetFacesOnSurf(const TopoDS_Shape &theShape, + const Handle_Geom_Surface& theSurface, + const Standard_Real theTolerance, + TopTools_ListOfShape &theFaces); + + TopoDS_Shape MakeConicalFace(const gp_Ax2 &theAxis, + const double theRadius, + const double theRadiusThin, + const double theHeight, + const gp_Trsf &theTrsf); + + bool MakeInternalGroup(const Handle(GEOM_Object) &theShape, + const double theR1, const double theLen1, + const double theR2, const double theLen2, + const double theRL, const double theTransLenL, + const double theRR, const double theTransLenR, + const double theRI, const double theTransLenI, + const Handle(TColStd_HSequenceOfTransient) &theSeq, + const gp_Trsf &theTrsf); + + gp_Trsf GetPositionTrsf(double theL1, double theL2, + Handle(GEOM_Object) P1 = 0, + Handle(GEOM_Object) P2 = 0, + Handle(GEOM_Object) P3 = 0); + + bool CheckCompatiblePosition(double& theL1, double& theL2, + Handle(GEOM_Object) theP1, + Handle(GEOM_Object) theP2, + Handle(GEOM_Object) theP3, + double theTolerance); + +private: + GEOMImpl_IBasicOperations* myBasicOperations; + GEOMImpl_IBooleanOperations* myBooleanOperations; + GEOMImpl_IShapesOperations* myShapesOperations; + GEOMImpl_ITransformOperations* myTransformOperations; + GEOMImpl_IBlocksOperations* myBlocksOperations; + GEOMImpl_I3DPrimOperations* my3DPrimOperations; + GEOMImpl_ILocalOperations* myLocalOperations; + GEOMImpl_IHealingOperations* myHealingOperations; + GEOMImpl_IGroupOperations* myGroupOperations; + +public: + + /*! + * \brief Add three thickness reductions at the open ends of the pipe T-Shape + * + * \param theShape - the pipe T-Shape + * \param r1 - the internal radius of main pipe + * \param w1 - the thickness of main pipe + * \param l1 - the half-length of main pipe + * \param r2 - the internal radius of incident pipe + * \param w2 - the thickness of incident pipe + * \param l2 - the half-length of main pipe + * \param r*, w*, ltrans* and lthin* - internal radius, thickness, length of transition part + * and length of thin part of left(L), right(R) and + * incident(I) thickness reduction correspondingly + * \param fuseReductions - boolean flag (use true to generate single solid, + * false to obtain parts, useful for hexameshing) + * \retval TopoDS_Shape - Resulting shape + */ + static TopoDS_Shape MakePipeTShapeThicknessReduction + (TopoDS_Shape theShape, + double r1, double w1, double l1, + double r2, double w2, double l2, + double rL, double wL, double ltransL, double lthinL, + double rR, double wR, double ltransR, double lthinR, + double rI, double wI, double ltransI, double lthinI, + bool fuseReductions); + + /*! + * \brief Create one thickness reduction element + * + * This method is called three times from MakePipeTShapeThicknessReduction + * to create three thickness reductions (one per each open end of a pipe T-Shape) + * + * \param theAxes - the position + * \param R - the internal radius of main pipe + * \param W - the thickness of main pipe + * \param Rthin - the internal radius of thin part + * \param Wthin - the thickness of thin part + * \param Ltrans - the length of transition part + * \param Lthin - the length of thin part + * \param fuse - boolean flag (use true to generate single solid, + * false to obtain parts, useful for hexameshing) + * \retval TopoDS_Shape - Resulting shape + */ + static TopoDS_Shape MakeThicknessReduction (gp_Ax2 theAxes, + const double R, const double W, + const double Rthin, const double Wthin, + const double Ltrans, const double Lthin, + bool fuse); + +public: + AdvancedEngine_IOperations(GEOM_Engine* theEngine, int theDocID); + ~AdvancedEngine_IOperations(); + + Handle(TColStd_HSequenceOfTransient) + MakePipeTShape(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + bool theHexMesh = true); + + Handle(TColStd_HSequenceOfTransient) + MakePipeTShapeWithPosition(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + bool theHexMesh = true, + Handle(GEOM_Object) P1 = 0, + Handle(GEOM_Object) P2 = 0, + Handle(GEOM_Object) P3 = 0); + + Handle(TColStd_HSequenceOfTransient) + MakePipeTShapeChamfer(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theH, double theW, + bool theHexMesh = true); + + Handle(TColStd_HSequenceOfTransient) + MakePipeTShapeChamferWithPosition(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theH, double theW, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + bool theHexMesh = true, + Handle(GEOM_Object) P1 = 0, + Handle(GEOM_Object) P2 = 0, + Handle(GEOM_Object) P3 = 0); + + Handle(TColStd_HSequenceOfTransient) + MakePipeTShapeFillet(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theRF, bool theHexMesh = true); + + Handle(TColStd_HSequenceOfTransient) + MakePipeTShapeFilletWithPosition(double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2, + double theRL, double theWL, double theLtransL, double theLthinL, + double theRR, double theWR, double theLtransR, double theLthinR, + double theRI, double theWI, double theLtransI, double theLthinI, + double theRF, bool theHexMesh = true, + Handle(GEOM_Object) P1 = 0, + Handle(GEOM_Object) P2 = 0, + Handle(GEOM_Object) P3 = 0); + + Handle(GEOM_Object) MakeDividedDisk (double theR, double theRatio, + int theOrientation, int thePattern); + Handle(GEOM_Object) MakeDividedDiskPntVecR (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR, + double theRatio, + int thePattern); + + Handle(GEOM_Object) MakeDividedCylinder (double theR, + double theH, + int thePattern); + + Handle(GEOM_Object) MakeSmoothingSurface (std::list thelPoints, + int theNbMax, + int theDegMax, + double theDMax); +}; + +#endif diff --git a/src/AdvancedEngine/AdvancedEngine_IOperations_i.cc b/src/AdvancedEngine/AdvancedEngine_IOperations_i.cc new file mode 100644 index 000000000..5afb75b59 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_IOperations_i.cc @@ -0,0 +1,797 @@ +// Copyright (C) 2007-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 +// + +// File : GEOM_IAdvancedOperations.cc +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#include + +#include "AdvancedEngine_IOperations_i.hh" +#include "AdvancedEngine_IOperations.hxx" + +#include +#include +#include + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +AdvancedEngine_IOperations_i::AdvancedEngine_IOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, AdvancedEngine_IOperations* theImpl) +:GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("AdvancedEngine_IOperations_i::AdvancedEngine_IOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +AdvancedEngine_IOperations_i::~AdvancedEngine_IOperations_i() +{ + MESSAGE("AdvancedEngine_IOperations_i::~AdvancedEngine_IOperations_i"); +} + +//============================================================================= +/*! + * MakePipeTShape + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShape + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + if (aP1.IsNull() || aP2.IsNull() || aP3.IsNull())return aSeq._retn(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeChamfer + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of chamfer. + * \param theW Width of chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeChamfer + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theH, theW, theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeChamferWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of the chamfer. + * \param theW Width of the chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeChamferWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theH, theW, theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeFillet + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeFillet + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRF, CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theRF, theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeFilletWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeFilletWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRF, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + theRF, theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTR + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeTR + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTRWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeTRWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + if (aP1.IsNull() || aP2.IsNull() || aP3.IsNull()) return aSeq._retn(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTRChamfer + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of chamfer. + * \param theW Width of chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeTRChamfer + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theH, theW, theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTRChamferWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A chamfer is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theH Height of the chamfer. + * \param theW Width of the chamfer. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeTRChamferWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theH, theW, theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTRFillet + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet. + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeTRFillet + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theRF, CORBA::Boolean theHexMesh) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theRF, theHexMesh); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * MakePipeTShapeTRFilletWithPosition + * Create a T-shape object with specified caracteristics for the main and + * the incident pipes (radius, width, half-length). A fillet is created + * on the junction of the pipes. + * The extremities of the main pipe are located on junctions points P1 and P2. + * The extremity of the incident pipe is located on junction point P3. + * \param theR1 Internal radius of main pipe + * \param theW1 Width of main pipe + * \param theL1 Half-length of main pipe + * \param theR2 Internal radius of incident pipe (R2 < R1) + * \param theW2 Width of incident pipe (R2+W2 < R1+W1) + * \param theL2 Half-length of incident pipe + * \param theRF Radius of curvature of fillet + * \param theHexMesh Boolean indicating if shape is prepared for hex mesh + * \param theP1 1st junction point of main pipe + * \param theP2 2nd junction point of main pipe + * \param theP3 Junction point of incident pipe + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* AdvancedEngine_IOperations_i::MakePipeTShapeTRFilletWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theRF, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference vertices + Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); + Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); + Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); + + //Create the TShape + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theRF, theHexMesh, aP1, aP2, aP3); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * This function allows to create a disk already divided into blocks. It can be + * use to create divided pipes for later meshing in hexaedra. + * \param theR Radius of the disk + * \param theRatio Relative size of the central square diagonal against the disk diameter + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +GEOM::GEOM_Object_ptr AdvancedEngine_IOperations_i::MakeDividedDisk (CORBA::Double theR, + CORBA::Double theRatio, + CORBA::Short theOrientation, + GEOM::pattern thePattern) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the DividedDisk + Handle(GEOM_Object) anObject = GetOperations()->MakeDividedDisk(theR, theRatio, theOrientation, thePattern); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeDividedDiskPntVecR + */ +//============================================================================= +GEOM::GEOM_Object_ptr AdvancedEngine_IOperations_i::MakeDividedDiskPntVecR (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theR, + CORBA::Double theRatio, + GEOM::pattern thePattern) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference points + Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt); + Handle(GEOM_Object) aVec = GetObjectImpl(theVec); + + if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); + + // Make DividedDisk + Handle(GEOM_Object) anObject = + GetOperations()->MakeDividedDiskPntVecR(aPnt, aVec, theR, theRatio, thePattern); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * Builds a cylinder prepared for hexa meshes + * \param theR Radius of the cylinder + * \param theH Height of the cylinder + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +GEOM::GEOM_Object_ptr AdvancedEngine_IOperations_i::MakeDividedCylinder (CORBA::Double theR, + CORBA::Double theH, + GEOM::pattern thePattern) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the DividedCylinder + Handle(GEOM_Object) anObject = GetOperations()->MakeDividedCylinder(theR, theH, thePattern); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * + * \param thelPoints list of points + * \param theNbMax maximum number of Bezier pieces in the resulting surface. + * \param theDegMax maximum degree of the resulting BSpline surface + * \param theDMax specifies maximum value of the GeomPlate_PlateG0Criterion criterion. + * \return New GEOM_Object, containing the created shape. + */ +//============================================================================= +GEOM::GEOM_Object_ptr AdvancedEngine_IOperations_i::MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints, + CORBA::Long theNbMax, + CORBA::Long theDegMax, + CORBA::Double theDMax) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference point + int ind = 0; + int aLen = thelPoints.length(); + std::list aPoints; + for (; ind < aLen; ind++) { + Handle(GEOM_Object) aPnt = GetObjectImpl(thelPoints[ind]); + if (aPnt.IsNull()) return aGEOMObject._retn(); + aPoints.push_back(aPnt); + } + //Create the SmoothingSurface + Handle(GEOM_Object) anObject = GetOperations()->MakeSmoothingSurface + (aPoints, theNbMax, theDegMax, theDMax); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +AdvancedEngine_IOperations* AdvancedEngine_IOperations_i::GetOperations() +{ + return (AdvancedEngine_IOperations*)GetImpl(); +} + diff --git a/src/AdvancedEngine/AdvancedEngine_IOperations_i.hh b/src/AdvancedEngine/AdvancedEngine_IOperations_i.hh new file mode 100644 index 000000000..0711b6ab0 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_IOperations_i.hh @@ -0,0 +1,138 @@ +// Copyright (C) 2007-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 +// + +// File : AdvancedEngine_IOperations_i.hh +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#ifndef _AdvancedEngine_IOperations_i_HeaderFile +#define _AdvancedEngine_IOperations_i_HeaderFile + +#include "AdvancedEngine.hxx" + +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(AdvancedGEOM) + +class AdvancedEngine_IOperations; + +class ADVANCEDENGINE_EXPORT AdvancedEngine_IOperations_i : + public virtual POA_GEOM::IAdvancedOperations, + public virtual GEOM_IOperations_i +{ + public: + AdvancedEngine_IOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + AdvancedEngine_IOperations* theImpl); + ~AdvancedEngine_IOperations_i(); + + // PipeTShape without thickness reduction + GEOM::ListOfGO* MakePipeTShape (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + GEOM::ListOfGO* MakePipeTShapeChamfer (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeChamferWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + GEOM::ListOfGO* MakePipeTShapeFillet (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRF, CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeFilletWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRF, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + + // PipeTShape with thickness reduction + GEOM::ListOfGO* MakePipeTShapeTR + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeTRWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + GEOM::ListOfGO* MakePipeTShapeTRChamfer + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeTRChamferWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + GEOM::ListOfGO* MakePipeTShapeTRFillet + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theRF, CORBA::Boolean theHexMesh); + GEOM::ListOfGO* MakePipeTShapeTRFilletWithPosition + (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, + CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, + CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, + CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, + CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, + CORBA::Double theRF, CORBA::Boolean theHexMesh, + GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); + + GEOM::GEOM_Object_ptr MakeDividedDisk (CORBA::Double theR, + CORBA::Double theRatio, + CORBA::Short theOrientation, + GEOM::pattern thePattern); + + GEOM::GEOM_Object_ptr MakeDividedDiskPntVecR (GEOM::GEOM_Object_ptr theCenter, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theR, + CORBA::Double theRatio, + GEOM::pattern thePattern); + + GEOM::GEOM_Object_ptr MakeDividedCylinder (CORBA::Double theR, + CORBA::Double theH, + GEOM::pattern thePattern); + GEOM::GEOM_Object_ptr MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints, + CORBA::Long theNbMax, + CORBA::Long theDegMax, + CORBA::Double theDMax); + + AdvancedEngine_IOperations* GetOperations(); +}; + +#endif diff --git a/src/AdvancedEngine/AdvancedEngine_IPipeTShape.hxx b/src/AdvancedEngine/AdvancedEngine_IPipeTShape.hxx new file mode 100644 index 000000000..b4a26fe9a --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_IPipeTShape.hxx @@ -0,0 +1,103 @@ +// Copyright (C) 2007-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 _AdvancedEngine_IPipeTShape_HXX_ +#define _AdvancedEngine_IPipeTShape_HXX_ + +#include "GEOM_Function.hxx" + +#include + +class AdvancedEngine_IPipeTShape +{ +public: + AdvancedEngine_IPipeTShape(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetR1(double theR1) { _func->SetReal(TSHAPE_ARG_R1, theR1); } + double GetR1() { return _func->GetReal(TSHAPE_ARG_R1); } + + void SetW1(double theW1) { _func->SetReal(TSHAPE_ARG_W1, theW1); } + double GetW1() { return _func->GetReal(TSHAPE_ARG_W1); } + + void SetL1(double theL1) { _func->SetReal(TSHAPE_ARG_L1, theL1); } + double GetL1() { return _func->GetReal(TSHAPE_ARG_L1); } + + void SetR2(double theR2) { _func->SetReal(TSHAPE_ARG_R2, theR2); } + double GetR2() { return _func->GetReal(TSHAPE_ARG_R2); } + + void SetW2(double theW2) { _func->SetReal(TSHAPE_ARG_W2, theW2); } + double GetW2() { return _func->GetReal(TSHAPE_ARG_W2); } + + void SetL2(double theL2) { _func->SetReal(TSHAPE_ARG_L2, theL2); } + double GetL2() { return _func->GetReal(TSHAPE_ARG_L2); } + + void SetH(double theH) { _func->SetReal(TSHAPE_ARG_H, theH); } + double GetH() { return _func->GetReal(TSHAPE_ARG_H); } + + void SetW(double theW) { _func->SetReal(TSHAPE_ARG_W, theW); } + double GetW() { return _func->GetReal(TSHAPE_ARG_W); } + + void SetRF(double theRF) { _func->SetReal(TSHAPE_ARG_RF, theRF); } + double GetRF() { return _func->GetReal(TSHAPE_ARG_RF); } + + void SetHexMesh(int theHexMesh) { _func->SetInteger(TSHAPE_ARG_HEXMESH, theHexMesh); } + int GetHexMesh() { return _func->GetInteger(TSHAPE_ARG_HEXMESH); } + + void SetP1(const Handle(GEOM_Function)& theP1){_func->SetReference(TSHAPE_ARG_P1, theP1); } + Handle(GEOM_Function) GetP1() { return _func->GetReference(TSHAPE_ARG_P1); } + + void SetP2(const Handle(GEOM_Function)& theP2){_func->SetReference(TSHAPE_ARG_P2, theP2); } + Handle(GEOM_Function) GetP2() { return _func->GetReference(TSHAPE_ARG_P2); } + + void SetP3(const Handle(GEOM_Function)& theP3){_func->SetReference(TSHAPE_ARG_P3, theP3); } + Handle(GEOM_Function) GetP3() { return _func->GetReference(TSHAPE_ARG_P3); } + +private: + enum { + // main pipe + TSHAPE_ARG_R1 = 1, + TSHAPE_ARG_W1 = 2, + TSHAPE_ARG_L1 = 3, + + // incident pipe + TSHAPE_ARG_R2 = 4, + TSHAPE_ARG_W2 = 5, + TSHAPE_ARG_L2 = 6, + + // chamfer + TSHAPE_ARG_H = 7, + TSHAPE_ARG_W = 8, + + // fillet + TSHAPE_ARG_RF = 9, + + // partition + TSHAPE_ARG_HEXMESH = 10, + + // junction points + TSHAPE_ARG_P1 = 11, + TSHAPE_ARG_P2 = 12, + TSHAPE_ARG_P3 = 13 + }; + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _AdvancedEngine_IPipeTShape_HXX_ diff --git a/src/AdvancedEngine/AdvancedEngine_ISmoothingSurface.hxx b/src/AdvancedEngine/AdvancedEngine_ISmoothingSurface.hxx new file mode 100644 index 000000000..3ee9bde3e --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_ISmoothingSurface.hxx @@ -0,0 +1,58 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 _AdvancedEngine_ISmoothingSurface_HXX_ +#define _AdvancedEngine_ISmoothingSurface_HXX_ + +#include "GEOM_Function.hxx" + +#define SMOOTHINGSURFACE_ARG_LENG 1 +#define SMOOTHINGSURFACE_ARG_LAST 2 +#define SMOOTHINGSURFACE_ARG_NB_MAX 3 +#define SMOOTHINGSURFACE_ARG_DEG_MAX 4 +#define SMOOTHINGSURFACE_ARG_D_MAX 5 + +class AdvancedEngine_ISmoothingSurface +{ +public: + AdvancedEngine_ISmoothingSurface(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetLength(int theLen) { _func->SetInteger(SMOOTHINGSURFACE_ARG_LENG, theLen); } + int GetLength() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_LENG); } + + void SetPntOrComp(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SMOOTHINGSURFACE_ARG_LAST + theId, theP); } + Handle(GEOM_Function) GetPntOrComp(int theId) { return _func->GetReference(SMOOTHINGSURFACE_ARG_LAST + theId); } + + void SetNbMax(int theNbMax) { _func->SetInteger(SMOOTHINGSURFACE_ARG_NB_MAX, theNbMax); } + int GetNbMax() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_NB_MAX); } + + void SetDegMax(int theDegMax) { _func->SetInteger(SMOOTHINGSURFACE_ARG_DEG_MAX, theDegMax); } + int GetDegMax() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_DEG_MAX); } + + void SetDMax(double theDMax) { _func->SetReal(SMOOTHINGSURFACE_ARG_D_MAX, theDMax); } + double GetDMax() { return _func->GetReal(SMOOTHINGSURFACE_ARG_D_MAX); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _AdvancedEngine_ISmoothingSurface_HXX_ diff --git a/src/AdvancedEngine/AdvancedEngine_OperationsCreator.cc b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.cc deleted file mode 100644 index cf9bf8cea..000000000 --- a/src/AdvancedEngine/AdvancedEngine_OperationsCreator.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 "GEOM_AdvancedEngine.hxx" - -#include "AdvancedEngine_OperationsCreator.hh" - -#include "GEOM_IAdvancedOperations_i.hh" - -// Operations -#include -#include -// #include -#include -/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ - -#include -#include - -#include "Utils_ExceptHandlers.hxx" -#include "utilities.h" - -//============================================================================ -// function : Create -// purpose : -//============================================================================ -GEOM_IOperations_i* AdvancedEngine_OperationsCreator::Create (PortableServer::POA_ptr thePOA, - int theStudyId, - GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_Gen* theGenImpl) -{ - Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "AdvancedEngine_OperationsCreator::Create" ); - - if (_mapOfOperations.find(theStudyId) == _mapOfOperations.end()) { - _mapOfOperations[theStudyId] = new GEOMImpl_IAdvancedOperations (theGenImpl, theStudyId); - - // Advanced operations - TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PipeTShapeDriver::GetID(), - new GEOMImpl_PipeTShapeDriver()); - TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DividedDiskDriver::GetID(), - new GEOMImpl_DividedDiskDriver()); - //TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DividedCylinderDriver::GetID(), - // new GEOMImpl_DividedCylinderDriver()); - TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SmoothingSurfaceDriver::GetID(), - new GEOMImpl_SmoothingSurfaceDriver()); - /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ - } - - GEOM_IAdvancedOperations_i* aServant = - new GEOM_IAdvancedOperations_i (thePOA, theEngine, _mapOfOperations[theStudyId]); - - return aServant; -} diff --git a/src/AdvancedEngine/AdvancedEngine_OperationsCreator.cxx b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.cxx new file mode 100644 index 000000000..4ca0a05c5 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.cxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 "AdvancedEngine_OperationsCreator.hxx" +#include "AdvancedEngine_IOperations_i.hh" +#include "AdvancedEngine_IOperations.hxx" +#include +#include +#include + +#include +#include + +#include "Utils_ExceptHandlers.hxx" +#include "utilities.h" + +std::map AdvancedEngine_OperationsCreator::_mapOfOperations; + +AdvancedEngine_OperationsCreator::AdvancedEngine_OperationsCreator() +{ + // Register drivers + TFunction_DriverTable::Get()->AddDriver(AdvancedEngine_PipeTShapeDriver::GetID(), + new AdvancedEngine_PipeTShapeDriver()); + TFunction_DriverTable::Get()->AddDriver(AdvancedEngine_DividedDiskDriver::GetID(), + new AdvancedEngine_DividedDiskDriver()); + TFunction_DriverTable::Get()->AddDriver(AdvancedEngine_SmoothingSurfaceDriver::GetID(), + new AdvancedEngine_SmoothingSurfaceDriver()); +} + +AdvancedEngine_OperationsCreator::~AdvancedEngine_OperationsCreator() +{ +} + +GEOM_IOperations_i* AdvancedEngine_OperationsCreator::Create (PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "AdvancedEngine_OperationsCreator::Create" ); + return new AdvancedEngine_IOperations_i( thePOA, theEngine, get( theGenImpl, theStudyId ) ); +} + +AdvancedEngine_IOperations* AdvancedEngine_OperationsCreator::get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ) +{ + if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) + _mapOfOperations[theStudyId] = new AdvancedEngine_IOperations( theGenImpl, theStudyId ); + return _mapOfOperations[theStudyId]; +} diff --git a/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hh b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hh deleted file mode 100755 index 261721eee..000000000 --- a/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hh +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 _GEOM_ADVANCEDENGINE_OPERATIONSCREATOR_HXX_ -#define _GEOM_ADVANCEDENGINE_OPERATIONSCREATOR_HXX_ - -#include "GEOM_AdvancedEngine.hxx" - -#include "GEOM_Gen_i.hh" - -#include "GEOMImpl_IAdvancedOperations.hxx" - -#include - -//===================================================================== -// Operations creator -//===================================================================== -class ADVANCEDENGINE_EXPORT AdvancedEngine_OperationsCreator : public GEOM_GenericOperationsCreator -{ - public: - // Create operations - virtual GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA, - int theStudyId, - GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_Gen* theGenImpl); - // return the name of IDL module - //virtual std::string GetModuleName(); - - private: - std::map _mapOfOperations; -}; - -#endif diff --git a/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hxx b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hxx new file mode 100755 index 000000000..1264035ca --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hxx @@ -0,0 +1,55 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 _GEOM_ADVANCEDENGINE_OPERATIONSCREATOR_HXX_ +#define _GEOM_ADVANCEDENGINE_OPERATIONSCREATOR_HXX_ + +#include "AdvancedEngine.hxx" + +#include "GEOM_Gen_i.hh" + +#include + +class AdvancedEngine_IOperations; + +//===================================================================== +// Operations creator +//===================================================================== +class ADVANCEDENGINE_EXPORT AdvancedEngine_OperationsCreator : public GEOM_GenericOperationsCreator +{ +public: + AdvancedEngine_OperationsCreator(); + ~AdvancedEngine_OperationsCreator(); + + GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl); + +private: + static AdvancedEngine_IOperations* get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ); +private: + static std::map _mapOfOperations; +}; + +#endif diff --git a/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.cxx b/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.cxx new file mode 100644 index 000000000..7551b43f7 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.cxx @@ -0,0 +1,668 @@ +// Copyright (C) 2007-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 +// + +#include "AdvancedEngine_PipeTShapeDriver.hxx" +#include "AdvancedEngine_IPipeTShape.hxx" +#include "AdvancedEngine_Types.hxx" +#include "AdvancedEngine_IOperations.hxx" + +#include "GEOMImpl_Block6Explorer.hxx" +#include "GEOM_Function.hxx" +#include "GEOM_IOperations.hxx" +#include "GEOMUtils.hxx" +#include "GEOMAlgo_FinderShapeOn1.hxx" +#include "GEOMAlgo_FinderShapeOn2.hxx" +#include "GEOMAlgo_ClsfBox.hxx" +#include "GEOMAlgo_Splitter.hxx" + +#include "Geom_CylindricalSurface.hxx" +#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 +#include +#include + +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& AdvancedEngine_PipeTShapeDriver::GetID() +{ + static Standard_GUID aGUID("1C3A0F3F-729D-4E83-8232-78E74FC5637C"); + return aGUID; +} + +//======================================================================= +//function : AdvancedEngine_PipeTShapeDriver +//purpose : +//======================================================================= +AdvancedEngine_PipeTShapeDriver::AdvancedEngine_PipeTShapeDriver() +{ +} + +//======================================================================= +//function : getShapesOnBoxIDs + /*! + * \brief Find IDs of sub-shapes complying with given status about surface + * \param theBox - the box to check state of sub-shapes against + * \param theShape - the shape to explore + * \param theShapeType - type of sub-shape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes + */ +//======================================================================= +Handle(TColStd_HSequenceOfInteger) +AdvancedEngine_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox, + const TopoDS_Shape& aShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState) const +{ + Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; + + // Check presence of triangulation, build if need + if (!GEOMUtils::CheckTriangulation(aShape)) { + StdFail_NotDone::Raise("Cannot build triangulation on the shape"); + return aSeqOfIDs; + } + + // Call algo + GEOMAlgo_FinderShapeOn2 aFinder; + Standard_Real aTol = 0.0001; // default value + + Handle(GEOMAlgo_ClsfBox) aClsfBox = new GEOMAlgo_ClsfBox; + aClsfBox->SetBox(aBox); + + aFinder.SetShape(aShape); + aFinder.SetTolerance(aTol); + aFinder.SetClsf(aClsfBox); + aFinder.SetShapeType( (TopAbs_ShapeEnum)theShapeType ); + aFinder.SetState(theState); + aFinder.Perform(); + + // Interprete results + Standard_Integer iErr = aFinder.ErrorStatus(); + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + if (iErr) { + TCollection_AsciiString aMsg (" iErr : "); + aMsg += TCollection_AsciiString(iErr); + StdFail_NotDone::Raise(aMsg.ToCString()); + return aSeqOfIDs; + } + + + const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result + + if (listSS.Extent() < 1) { + StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017 + return aSeqOfIDs; + } + + // Fill sequence of object IDs + aSeqOfIDs = new TColStd_HSequenceOfInteger; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + + TopTools_ListIteratorOfListOfShape itSub (listSS); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + int id = anIndices.FindIndex(itSub.Value()); +// std::cerr << "Shape with ID " << id << " found" << std::endl; + aSeqOfIDs->Append(id); + } + + return aSeqOfIDs; +} + +//======================================================================= +//function : GetShapesOnSurfaceIDs + /*! + * \brief Find IDs of sub-shapes complying with given status about surface + * \param theSurface - the surface to check state of sub-shapes against + * \param theShape - the shape to explore + * \param theShapeType - type of sub-shape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes + */ +//======================================================================= +Handle(TColStd_HSequenceOfInteger) + AdvancedEngine_PipeTShapeDriver::GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, + const TopoDS_Shape& theShape, + TopAbs_ShapeEnum theShapeType, + GEOMAlgo_State theState) const +{ + Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; + + // Check presence of triangulation, build if need + if (!GEOMUtils::CheckTriangulation(theShape)) { + StdFail_NotDone::Raise("Cannot build triangulation on the shape"); + return aSeqOfIDs; + } + + // Call algo + GEOMAlgo_FinderShapeOn1 aFinder; + Standard_Real aTol = 1e-6; + + aFinder.SetShape(theShape); + aFinder.SetTolerance(aTol); + aFinder.SetSurface(theSurface); + aFinder.SetShapeType(theShapeType); + aFinder.SetState(theState); + + // Sets the minimal number of inner points for the faces that do not have own + // inner points at all (for e.g. rectangular planar faces have just 2 triangles). + // Default value=3 + aFinder.SetNbPntsMin(3); + // Sets the maximal number of inner points for edges or faces. + // It is usefull for the cases when this number is very big (e.g =2000) to improve + // the performance. If this value =0, all inner points will be taken into account. + // Default value=0 + aFinder.SetNbPntsMax(0); + + aFinder.Perform(); + + // Interprete results + Standard_Integer iErr = aFinder.ErrorStatus(); + // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx + if (iErr) { +// MESSAGE(" iErr : " << iErr); + TCollection_AsciiString aMsg (" iErr : "); + aMsg += TCollection_AsciiString(iErr); + StdFail_NotDone::Raise(aMsg.ToCString()); + return aSeqOfIDs; + } +// Standard_Integer iWrn = aFinder.WarningStatus(); + // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx +// if (iWrn) { +// MESSAGE(" *** iWrn : " << iWrn); +// } + + const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result + + if (listSS.Extent() < 1) { + //StdFail_NotDone::Raise("Not a single sub-shape of the requested type found on the given surface"); + StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017 + return aSeqOfIDs; + } + + // Fill sequence of object IDs + aSeqOfIDs = new TColStd_HSequenceOfInteger; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(theShape, anIndices); + + TopTools_ListIteratorOfListOfShape itSub (listSS); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + int id = anIndices.FindIndex(itSub.Value()); + aSeqOfIDs->Append(id); + } + + return aSeqOfIDs; +} + +//======================================================================= +//function : GetCommonShapesOnCylinders +//purpose : return the common shapes between 2 cylindrical surfaces +// along OX and OZ +//======================================================================= +void AdvancedEngine_PipeTShapeDriver::GetCommonShapesOnCylinders(const TopoDS_Shape& theShape, + TopAbs_ShapeEnum theShapeType, + double r1, + double r2, + Handle(TopTools_HSequenceOfShape)& commonShapes) const +{ + gp_Pnt aP0 (0, 0, 0); + gp_Vec aVX = gp::DX(), aVZ = gp::DZ(); + gp_Ax3 anAxis1 (aP0, aVX, aVZ), anAxis2 (aP0, aVZ, aVX); + + TopTools_IndexedMapOfShape aMapOfShapes; + aMapOfShapes.Clear(); + TopExp::MapShapes(theShape, aMapOfShapes); + + commonShapes->Clear(); + + int myID; + bool found = false; + + // Create a cylinder surface + Handle(Geom_Surface) aC1Ext = new Geom_CylindricalSurface(anAxis1, r1); + if ( aC1Ext.IsNull() ) + StdFail_NotDone::Raise("Couldn't build main cylindrical surface"); + // Find object IDs + Handle(TColStd_HSequenceOfInteger) aSeqExt1 = GetShapesOnSurfaceIDs( aC1Ext, theShape, theShapeType, GEOMAlgo_ST_ON ); + // Create a cylinder surface + Handle(Geom_Surface) aC2Ext = new Geom_CylindricalSurface(anAxis2, r2); + if ( aC2Ext.IsNull() ) + StdFail_NotDone::Raise("Couldn't build incident cylindrical surface"); + // Find object IDs + Handle(TColStd_HSequenceOfInteger) aSeqExt2 = GetShapesOnSurfaceIDs( aC2Ext, theShape, theShapeType, GEOMAlgo_ST_ON ); + // # Recherche (dans le quart de Te) de l'arete d'intersection des 2 cylindres + // # Search in theShape for common shape of type theShapeType on the intersection of 2 pipes + found = false; + for (int i=1; i<=aSeqExt2->Length();i++) { +// std::cerr << "aSeqExt2->Value(i): " << aSeqExt2->Value(i) << std::endl; + for (int j=1; j<=aSeqExt1->Length();j++) { +// std::cerr << "aSeqExt1->Value(j): " << aSeqExt1->Value(j) << std::endl; + if (aSeqExt1->Value(j) == aSeqExt2->Value(i)) { + myID = aSeqExt1->Value(j); + commonShapes->Append(aMapOfShapes.FindKey(myID)); + found = true; + } + } + } + if (!found) + StdFail_NotDone::Raise("Common shapes couldn't be found"); +} + +//======================================================================= +//function : MakePipeTShape +//purpose : +//======================================================================= +TopoDS_Shape AdvancedEngine_PipeTShapeDriver::MakePipeTShape (const double r1, const double w1, const double l1, + const double r2, const double w2, const double l2) const +{ + double r1Ext = r1 + w1; + double r2Ext = r2 + w2; + + gp_Pnt aP0 (0, 0, 0); + gp_Pnt aP1 (-l1, 0, 0); + gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ(); + gp_Ax2 anAxes1 (aP1, aVX, aVZ); + gp_Ax2 anAxes2 (aP0, aVZ, aVX); + + // Build the initial pipes + BRepPrimAPI_MakeCylinder C1Int (anAxes1, r1, Abs(2 * l1)); + BRepPrimAPI_MakeCylinder C1Ext (anAxes1, r1Ext, Abs(2 * l1)); + BRepPrimAPI_MakeCylinder C2Int (anAxes2, r2, Abs(l2)); + BRepPrimAPI_MakeCylinder C2Ext (anAxes2, r2Ext, Abs(l2)); + C1Int.Build(); + C1Ext.Build(); + C2Int.Build(); + C2Ext.Build(); + if (!C1Int.IsDone() || !C1Ext.IsDone() || !C2Int.IsDone() || !C2Ext.IsDone()) { + StdFail_NotDone::Raise("Cannot build cylinders"); + } + + // Fuse the 2 pipes + BRepAlgoAPI_Fuse fuse1 (C1Ext.Shape(), C2Ext.Shape()); + if (!fuse1.IsDone()) { + StdFail_NotDone::Raise("Cannot fuse cylinders"); + } + + // Remove small radius main pipe + BRepAlgoAPI_Cut cut1 (fuse1.Shape(), C1Int.Shape()); + if (!cut1.IsDone()) { + StdFail_NotDone::Raise("Coudn't cut cylinders"); + } + + // Remove small radius incident pipe => Te + BRepAlgoAPI_Cut Te (cut1.Shape(), C2Int.Shape()); + if (!Te.IsDone()) { + StdFail_NotDone::Raise("Coudn't cut cylinders"); + } + + return Te.Shape(); +} + +//======================================================================= +//function : MakeQuarterPipeTShape +//purpose : +//======================================================================= +TopoDS_Shape AdvancedEngine_PipeTShapeDriver::MakeQuarterPipeTShape (const double r1, const double w1, const double l1, + const double r2, const double w2, const double l2) const +{ + TopoDS_Shape Te = MakePipeTShape(r1, w1, l1, r2, w2, l2); + if (Te.IsNull()) + StdFail_NotDone::Raise("Couldn't build Pipe TShape"); + + // Get a quarter of shape => Te2 + double r1Ext = r1 + w1; + BRepPrimAPI_MakeBox box1 (gp_Pnt(0, -2*r1Ext, -2*r1Ext), gp_Pnt( Abs(2 * l1), 2*r1Ext, Abs(2*l2))); + BRepPrimAPI_MakeBox box2 (gp_Pnt(0, 2*r1Ext, -2*r1Ext), gp_Pnt(-Abs(2 * l1), 0, Abs(2*l2))); + box1.Build(); + box2.Build(); + if (!box1.IsDone() || !box2.IsDone()) { + StdFail_NotDone::Raise("Couldn't build boxes"); + } + BRepAlgoAPI_Cut cut3 (Te, box1.Shape()); + if (!cut3.IsDone()) { + StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box"); + } + BRepAlgoAPI_Cut Te4 (cut3.Shape(), box2.Shape()); + if (!Te4.IsDone()) { + StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box"); + } + + return Te4.Shape(); +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer AdvancedEngine_PipeTShapeDriver::Execute (TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + AdvancedEngine_IPipeTShape aData (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape, Te4, Te4Part; + //TopoDS_Edge arete_intersect_int; + //Handle(TopTools_HSequenceOfShape) edges_e = new TopTools_HSequenceOfShape; + Handle(TColStd_HSequenceOfInteger) edges_e; + //Handle(TopTools_HSequenceOfShape) edges_i = new TopTools_HSequenceOfShape; + //gp_Pnt aP0 (0, 0, 0); + //gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ(); + bool hexMesh = (bool) aData.GetHexMesh(); + + // Useful values + //double aSize = 2*(aData.GetL1() + aData.GetL2()); + double epsilon = Precision::Approximation(); + double aR1Ext = aData.GetR1() + aData.GetW1(); + double aR2Ext = aData.GetR2() + aData.GetW2(); + + if (aData.GetR2() > aData.GetR1() + epsilon) { + StdFail_NotDone::Raise("TShape cannot be computed if R2 > R1"); + } + + if (aR2Ext > aR1Ext + epsilon) { + StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 > R1+W1"); + } + + // external radius are equal + if (fabs(aR2Ext - aR1Ext) < epsilon) { + if (aType == TSHAPE_CHAMFER) + StdFail_NotDone::Raise("TShape with chamfer cannot be computed if R2+W2 = R1+W1"); + if (aType == TSHAPE_FILLET) + StdFail_NotDone::Raise("TShape with fillet cannot be computed if R2+W2 = R1+W1"); + // internal radius are different => not possible + if (fabs(aData.GetR2() - aData.GetR1()) > epsilon) { + StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 = R1+W1 and R2 != R1"); + } + } + + if (aR1Ext >= aData.GetL2() + epsilon) { + StdFail_NotDone::Raise("TShape cannot be computed if R1+W1 >= L2"); + } + if (aR2Ext >= aData.GetL1() + epsilon) { + StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 >= L1"); + } + + if (aType == TSHAPE_CHAMFER) { + if (aData.GetH() >= (aData.GetL2() - aR1Ext + epsilon)) { + StdFail_NotDone::Raise("TShape cannot be computed: height of chamfer is too high"); + } + + if (aData.GetW() >= (aData.GetL1() - aR2Ext + epsilon)) + StdFail_NotDone::Raise("TShape cannot be computed: width of chamfer is too high"); + } + + if (aType == TSHAPE_FILLET) { + if (aData.GetRF() >= (aData.GetL2() - aR1Ext + epsilon) || + aData.GetRF() >= (aData.GetL1() - aR2Ext + epsilon)) + StdFail_NotDone::Raise("TShape cannot be computed: radius of fillet is too high"); + } + + if (hexMesh) { + // Create a quarter of a basic T-Shape pipe + //std::cerr << "Create a quarter of a basic T-Shape pipe" << std::endl; + Te4 = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), + aData.GetR2(), aData.GetW2(), aData.GetL2()); + } + else { + // No need to cut pipe t-shape + //std::cerr << "Create a basic T-Shape pipe" << std::endl; + Te4 = MakePipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), + aData.GetR2(), aData.GetW2(), aData.GetL2()); + } + aShape = Te4; +/* + if (aType == TSHAPE_BASIC) { + aShape = Te4; +// aShape = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), +// aData.GetR2(), aData.GetW2(), aData.GetL2()); + } + else if (aType == TSHAPE_CHAMFER) { + // TShape with chamfer +// BRep_Builder BB; +// TopoDS_Compound CC; +// BB.MakeCompound(CC); + // Create chamfer on the edges edges_e + BRepFilletAPI_MakeChamfer chamfer (Te4); + TopTools_IndexedMapOfShape anEdgesIndices; + TopExp::MapShapes(Te4, anEdgesIndices); + + TopoDS_Shape theBox; + if (hexMesh) { + BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); + aBox.Build(); + if (!aBox.IsDone()) { + StdFail_NotDone::Raise("Couldn't build box"); + } + theBox = aBox.Shape(); + } + else { + BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); + aBox.Build(); + if (!aBox.IsDone()) { + StdFail_NotDone::Raise("Couldn't build box"); + } + theBox = aBox.Shape(); + } + Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger; + edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN); + if (edges_e.IsNull() || edges_e->Length() == 0) { + StdFail_NotDone::Raise("Common edges not found"); + } + + TopTools_IndexedDataMapOfShapeListOfShape M; + GEOMImpl_Block6Explorer::MapShapesAndAncestors(Te4, TopAbs_EDGE, TopAbs_FACE, M); +// std::cerr << "Number of IDs: " << edges_e->Length() << std::endl; + int nbEdgesInChamfer = 0; + for (int i=1;i<=edges_e->Length();i++) { +// std::cerr << "Get Edge with ID #" << i << std::endl; + int theId = edges_e->Value(i); +// std::cerr << "ID #" << i << "= " << theId << std::endl; +// std::cerr << "Search for edge in shape" << std::endl; + TopoDS_Edge theEdge = TopoDS::Edge(anEdgesIndices.FindKey(theId)); +// std::cerr << "Found" << std::endl; +// std::cerr << "Keep only edges with a vertex on (x, x, re1)" << std::endl; + TopExp_Explorer ExVertices; + for (ExVertices.Init(theEdge,TopAbs_VERTEX); ExVertices.More(); ExVertices.Next()) { + gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(ExVertices.Current())); + if (aPt.Z() - aR1Ext <= epsilon) { +// std::cerr << "aPt.Z() = aR1Ext => keep this edge" << std::endl; + nbEdgesInChamfer ++; + const TopTools_ListOfShape& aFL = M.FindFromKey(theEdge); + TopoDS_Face F = TopoDS::Face( aFL.First() ); + if (hexMesh) + chamfer.Add(aData.GetH(), aData.GetW(), theEdge, F); + else + chamfer.Add(aData.GetW(), aData.GetH(), theEdge, F); + break; + } + } +// std::cerr << "Test if hexMesh: "; + if (hexMesh && nbEdgesInChamfer == 1) { +// std::cerr << "Yes => stop after 1 edge" << std::endl; + break; + } +// std::cerr << "No => continue for other edges" << std::endl; + // BB.Add(CC, edges_e->Value(i)); + // const TopTools_ListOfShape& aFL = M.FindFromKey(TopoDS::Edge(edges_e->Value(i))); + // chamfer.Add(aData.GetW(), aData.GetH(), TopoDS::Edge(edges_e->Value(i)), F); + } +// std::cerr << "Build chamfer with " << nbEdgesInChamfer << " edges" << std::endl; +// } + chamfer.Build(); + if (!chamfer.IsDone()) { + StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters"); + } + +// BB.Add(CC, chamfer.Shape()); + +// aShape = CC; + aShape = chamfer.Shape(); + } + else if (aType == TSHAPE_FILLET) { + // TShape with fillet + // Create fillet on the edge arete_intersect_ext + BRepFilletAPI_MakeFillet fill (Te4); + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(Te4, anIndices); + + TopoDS_Shape theBox; + if (hexMesh) { + BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); + aBox.Build(); + if (!aBox.IsDone()) { + StdFail_NotDone::Raise("Couldn't build box"); + } + theBox = aBox.Shape(); + } + else { + BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); + aBox.Build(); + if (!aBox.IsDone()) { + StdFail_NotDone::Raise("Couldn't build box"); + } + theBox = aBox.Shape(); + } + Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger; + edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN); + if (edges_e.IsNull() || edges_e->Length() == 0) { + StdFail_NotDone::Raise("Common edges not found"); + } + +// fill.Add(TopoDS::Edge(edges_e->Value(1))); +// if (!hexMesh) { + for (int i=1;i<=edges_e->Length();i++) { + if (hexMesh && (i > 1)) + break; + TopoDS_Edge theEdge = TopoDS::Edge(anIndices.FindKey(edges_e->Value(i))); + fill.Add(theEdge); +// fill.Add(TopoDS::Edge(edges_e->Value(i))); + } +// } + fill.SetRadius(aData.GetRF(), 1, 1); + fill.Build(); + if (!fill.IsDone()) { + StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius"); + } + + aShape = fill.Shape(); + } + else { + // other construction modes here + } +*/ + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool AdvancedEngine_PipeTShapeDriver:: +GetCreationInformation(std::string& theOperationName, + std::vector& theParams) +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); + + AdvancedEngine_IPipeTShape aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "PIPETSHAPE"; + + switch ( aType ) { + case TSHAPE_BASIC: + AddParam( theParams, "Main radius", aCI.GetR1() ); + AddParam( theParams, "Main width", aCI.GetW1() ); + AddParam( theParams, "Main half-length", aCI.GetL1() ); + AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); + AddParam( theParams, "Incident pipe width", aCI.GetW2() ); + AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); + AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); + break; + case TSHAPE_CHAMFER: + AddParam( theParams, "Main radius", aCI.GetR1() ); + AddParam( theParams, "Main width", aCI.GetW1() ); + AddParam( theParams, "Main half-length", aCI.GetL1() ); + AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); + AddParam( theParams, "Incident pipe width", aCI.GetW2() ); + AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); + AddParam( theParams, "Chamfer height", aCI.GetH() ); + AddParam( theParams, "Chamfer width", aCI.GetW() ); + AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); + break; + case TSHAPE_FILLET: + AddParam( theParams, "Main radius", aCI.GetR1() ); + AddParam( theParams, "Main width", aCI.GetW1() ); + AddParam( theParams, "Main half-length", aCI.GetL1() ); + AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); + AddParam( theParams, "Incident pipe width", aCI.GetW2() ); + AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); + AddParam( theParams, "Fillet radius", aCI.GetRF() ); + AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); + break; + default: + return false; + } + + return true; +} + +IMPLEMENT_STANDARD_HANDLE (AdvancedEngine_PipeTShapeDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_RTTIEXT (AdvancedEngine_PipeTShapeDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.hxx b/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.hxx new file mode 100644 index 000000000..cba5d1492 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.hxx @@ -0,0 +1,124 @@ +// Copyright (C) 2007-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 _AdvancedEngine_PipeTShapeDriver_HXX +#define _AdvancedEngine_PipeTShapeDriver_HXX + +#include "AdvancedEngine.hxx" + +#include "GEOM_BaseDriver.hxx" +#include "GEOMAlgo_State.hxx" + +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE( AdvancedEngine_PipeTShapeDriver, GEOM_BaseDriver ); + +class ADVANCEDENGINE_EXPORT AdvancedEngine_PipeTShapeDriver : public GEOM_BaseDriver +{ +public: + // Methods PUBLIC + // + AdvancedEngine_PipeTShapeDriver(); + virtual Standard_Integer Execute(TFunction_Logbook& log) const; + virtual void Validate(TFunction_Logbook&) const {} + Standard_Boolean MustExecute(const TFunction_Logbook&) const + { + return Standard_True; + } + static const Standard_GUID& GetID(); + ~AdvancedEngine_PipeTShapeDriver() {}; + + virtual bool GetCreationInformation(std::string& theOperationName, + std::vector& params); + // Type management + // +DEFINE_STANDARD_RTTI( AdvancedEngine_PipeTShapeDriver ) + +private: + + /*! + * \brief Create a T-Shape based on pipes + * \param r1 - the internal radius of main pipe + * \param w1 - the thickness of main pipe + * \param l1 - the half-length of main pipe + * \param r2 - the internal radius of incident pipe + * \param w2 - the thickness of incident pipe + * \param l2 - the half-length of main pipe + * \retval TopoDS_Shape - Resulting shape + */ + TopoDS_Shape MakePipeTShape(double r1, double w1, double l1, + double r2, double w2, double l2) const; + + /*! + * \brief Create a quarter of a T-Shape based on pipes + * \param r1 - the internal radius of main pipe + * \param w1 - the thickness of main pipe + * \param l1 - the half-length of main pipe + * \param r2 - the internal radius of incident pipe + * \param w2 - the thickness of incident pipe + * \param l2 - the half-length of main pipe + * \retval TopoDS_Shape - Resulting shape + */ + TopoDS_Shape MakeQuarterPipeTShape(double r1, double w1, double l1, + double r2, double w2, double l2) const; + + /*! + * \brief Find IDs of sub-shapes complying with given status about surface + * \param theSurface - the surface to check state of sub-shapes against + * \param theShape - the shape to explore + * \param theShapeType - type of sub-shape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes + */ + Handle(TColStd_HSequenceOfInteger) + GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, + const TopoDS_Shape& theShape, + TopAbs_ShapeEnum theShapeType, + GEOMAlgo_State theState) const; + + /*! + * \brief Find IDs of sub-shapes complying with given status about surface + * \param theBox - the box to check state of sub-shapes against + * \param theShape - the shape to explore + * \param theShapeType - type of sub-shape of theShape + * \param theState - required state + * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes + */ + Handle(TColStd_HSequenceOfInteger) + GetShapesOnBoxIDs(const TopoDS_Shape& aBox, + const TopoDS_Shape& aShape, + const Standard_Integer theShapeType, + GEOMAlgo_State theState) const; + + //======================================================================= + //function : getCommonShapesOnCylinders + //purpose : return the common edge between 2 cylindrical surfaces + // along OX and OZ + //======================================================================= + void GetCommonShapesOnCylinders(const TopoDS_Shape& theShape, + TopAbs_ShapeEnum theShapeType, + double r, double r2, + Handle(TopTools_HSequenceOfShape)& commonShapes) const; + +}; + +#endif // _AdvancedEngine_PipeTShapeDriver_HXX diff --git a/src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.cxx b/src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.cxx new file mode 100644 index 000000000..19fef9c52 --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.cxx @@ -0,0 +1,275 @@ +// Copyright (C) 2013-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 +// + +#include + +#include "AdvancedEngine_SmoothingSurfaceDriver.hxx" +#include "AdvancedEngine_ISmoothingSurface.hxx" +#include "AdvancedEngine_Types.hxx" + +#include "GEOM_Function.hxx" + +#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 +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& AdvancedEngine_SmoothingSurfaceDriver::GetID() +{ + static Standard_GUID aGUID("1C3A0F30-729D-4E83-8232-78E74FC5637C"); + return aGUID; +} + +//======================================================================= +//function : AdvancedEngine_SmoothingSurfaceDriver +//purpose : +//======================================================================= +AdvancedEngine_SmoothingSurfaceDriver::AdvancedEngine_SmoothingSurfaceDriver() +{ +} + +//======================================================================= +//function : MakeSmoothingSurfaceUnClosed +//purpose : +//======================================================================= +TopoDS_Shape AdvancedEngine_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed + (const Handle_TColgp_HArray1OfPnt &theListOfPoints, + const Standard_Integer theNbMax, + const Standard_Integer theDegMax, + const Standard_Real theDMax) const +{ + TopoDS_Face aInitShape; + + // Create an average Plane + //Handle(TColgp_HArray1OfPnt) HAP = new TColgp_HArray1OfPnt(1,theListOfPoints.Length()) + GeomPlate_BuildAveragePlane gpbap(theListOfPoints,theListOfPoints->Length(),Precision::Confusion(),1,1); + Handle(Geom_Plane) plane(gpbap.Plane()); + Standard_Real Umin, Umax, Vmin, Vmax; + gpbap.MinMaxBox(Umin,Umax,Vmin,Vmax); + // cout << "Vals : " << Umin << ", " << Umax << ", " << Vmin << ", " << Vmax << endl; + BRepBuilderAPI_MakeFace mf(plane,Umin,Umax,Vmin,Vmax,Precision::Confusion()); + aInitShape = mf.Face(); + //return aInitShape; + + GeomPlate_BuildPlateSurface aBuilder(3,10); + // ** Initialization of surface + Handle(BRepAdaptor_HSurface) HSI = new BRepAdaptor_HSurface(); + HSI->ChangeSurface().Initialize(aInitShape); + aBuilder.LoadInitSurface( BRep_Tool::Surface(HSI->ChangeSurface().Face())); + + Standard_Integer j, j1, j2; + // cout << "Init surface" << endl; + j1 = theListOfPoints->Lower(); + j2 = theListOfPoints->Upper(); + for (j=j1; j<=j2 ; j++) + { + gp_Pnt aPnt = theListOfPoints->Value(j); + Handle(GeomPlate_PointConstraint) PCont = new GeomPlate_PointConstraint(aPnt,0); + aBuilder.Add(PCont); + } + // cout << "avant Perform surface" << endl; + aBuilder.Perform(); + // cout << "Perform surface" << endl; + + // A ce niveau : surface algo + Handle(GeomPlate_Surface) gpPlate = aBuilder.Surface(); + + Standard_Integer nbcarreau = (theNbMax > 0 ? theNbMax : 2); + Standard_Integer degmax = (theDegMax > 0 ? theDegMax : 8); + Standard_Real seuil = theDMax; + + if (seuil <= 0.) { + seuil = Max(0.0001,10*aBuilder.G0Error()); + } + + GeomPlate_MakeApprox Mapp(gpPlate,0.0001,nbcarreau,degmax,seuil); + // cout << "Approx surface" << endl; + + Handle (Geom_Surface) Surf (Mapp.Surface()); + + aBuilder.Surface()->Bounds( Umin, Umax, Vmin, Vmax); + + BRepBuilderAPI_MakeFace MF(Surf,Umin, Umax, Vmin, Vmax, Precision::Confusion()); + TopoDS_Shape aShape = MF.Shape(); + + return aShape; +} + + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer AdvancedEngine_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + if (aFunction.IsNull()) return 0; + + Standard_Integer aType = aFunction->GetType(); + + if (aType != SMOOTHINGSURFACE_LPOINTS) return 0; + // cout << "Youhou : " << aType << endl; + + AdvancedEngine_ISmoothingSurface aData (aFunction); + + // Fill the map of vertices. + Standard_Integer aNbShapes = aData.GetLength(); + TopTools_MapOfShape aMapPoints; + Standard_Integer i; + + for (i = 1; i <= aNbShapes; i++) { + Handle(GEOM_Function) aFShape = aData.GetPntOrComp(i); + TopoDS_Shape aShape = aFShape->GetValue(); + + if (aShape.ShapeType() == TopAbs_VERTEX) { + aMapPoints.Add(aShape); + } else { + TopExp_Explorer anExp(aShape, TopAbs_VERTEX); + + for (; anExp.More(); anExp.Next()) { + aMapPoints.Add(anExp.Current()); + } + } + } + + // Add points to the array of points. + const Standard_Integer aNbPoints = aMapPoints.Extent(); + Handle(TColgp_HArray1OfPnt) anArrayofPnt = + new TColgp_HArray1OfPnt(1, aNbPoints); + TopTools_MapIteratorOfMapOfShape anIter(aMapPoints); + + for (i = 1; anIter.More(); anIter.Next(), i++) { + TopoDS_Vertex aPoint = TopoDS::Vertex(anIter.Key()); + gp_Pnt aPnt = BRep_Tool::Pnt(aPoint); + + anArrayofPnt->SetValue(i, aPnt); + } + + const Standard_Integer aNbMax = aData.GetNbMax(); + const Standard_Integer aDegMax = aData.GetDegMax(); + const Standard_Real aDMax = aData.GetDMax(); + + // Make smoothing surface. + TopoDS_Shape aShape = AdvancedEngine_SmoothingSurfaceDriver:: + MakeSmoothingSurfaceUnClosed(anArrayofPnt, aNbMax, aDegMax, aDMax); + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool AdvancedEngine_SmoothingSurfaceDriver:: +GetCreationInformation(std::string& theOperationName, + std::vector& theParams) +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); + + AdvancedEngine_ISmoothingSurface aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "SMOOTHINGSURFACE"; + + switch ( aType ) { + case SMOOTHINGSURFACE_LPOINTS: + { + AddParam( theParams, "Points" ); + if ( aCI.GetLength() > 1 ) + theParams[0] << aCI.GetLength() << " points: "; + for ( int i = 1, nb = aCI.GetLength(); i <= nb; ++i ) + theParams[0] << aCI.GetPntOrComp( i ) << " "; + + const Standard_Integer aNbMax = aCI.GetNbMax(); + const Standard_Integer aDegMax = aCI.GetDegMax(); + const Standard_Real aDMax = aCI.GetDMax(); + + AddParam(theParams, "Max nbr of Bezier pieces", aCI.GetNbMax()); + AddParam(theParams, "Max BSpline surface degree", aCI.GetDegMax()); + AddParam(theParams, "3D tolerance of initial approximation", aCI.GetDMax()); + } + break; + default: + return false; + } + + return true; +} + +IMPLEMENT_STANDARD_HANDLE (AdvancedEngine_SmoothingSurfaceDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_RTTIEXT (AdvancedEngine_SmoothingSurfaceDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.hxx b/src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.hxx new file mode 100644 index 000000000..fd5f28bec --- /dev/null +++ b/src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.hxx @@ -0,0 +1,62 @@ +// Copyright (C) 2013-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 _AdvancedEngine_SmoothingSurfaceDriver_HXX +#define _AdvancedEngine_SmoothingSurfaceDriver_HXX + +#include "AdvancedEngine.hxx" + +#include "GEOM_BaseDriver.hxx" + +#include +#include +#include + +DEFINE_STANDARD_HANDLE( AdvancedEngine_SmoothingSurfaceDriver, GEOM_BaseDriver ); + +class ADVANCEDENGINE_EXPORT AdvancedEngine_SmoothingSurfaceDriver : public GEOM_BaseDriver +{ +public: + // Methods PUBLIC + // + AdvancedEngine_SmoothingSurfaceDriver(); + virtual Standard_Integer Execute(TFunction_Logbook& log) const; + virtual void Validate(TFunction_Logbook&) const {} + Standard_Boolean MustExecute(const TFunction_Logbook&) const + { + return Standard_True; + } + static const Standard_GUID& GetID(); + ~AdvancedEngine_SmoothingSurfaceDriver() {}; + + virtual bool GetCreationInformation(std::string& theOperationName, + std::vector& params); + // Type management + // +DEFINE_STANDARD_RTTI( AdvancedEngine_SmoothingSurfaceDriver ) + +private: + TopoDS_Shape MakeSmoothingSurfaceUnClosed + (const Handle_TColgp_HArray1OfPnt &theListOfPoints, + const Standard_Integer theNbMax, + const Standard_Integer theDegMax, + const Standard_Real theDMax) const; +}; + +#endif // _AdvancedEngine_SmoothingSurfaceDriver_HXX diff --git a/src/AdvancedEngine/AdvancedEngine_Types.hxx b/src/AdvancedEngine/AdvancedEngine_Types.hxx index aa552a15d..63ee5b5ca 100644 --- a/src/AdvancedEngine/AdvancedEngine_Types.hxx +++ b/src/AdvancedEngine/AdvancedEngine_Types.hxx @@ -20,13 +20,14 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "GEOMImpl_Types.hxx" + // Advanced functions (base = 200) -#define ADVANCED_BASE 200 // NO OPERATION (advanced operations base) -#define GEOM_TSHAPE 201 -#define GEOM_DIVIDEDDISK 202 -#define GEOM_DIVIDEDCYLINDER 203 -#define GEOM_SMOOTHINGSURFACE 204 -/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ +#define GEOM_TSHAPE ( USER_TYPE + 1 ) +#define GEOM_DIVIDEDDISK ( USER_TYPE + 2 ) +#define GEOM_DIVIDEDCYLINDER ( USER_TYPE + 3 ) +#define GEOM_SMOOTHINGSURFACE ( USER_TYPE + 4 ) + // Advanced functions sub-operations codes #define TSHAPE_BASIC 1 #define TSHAPE_CHAMFER 2 @@ -35,4 +36,3 @@ #define DIVIDEDDISK_R_VECTOR_PNT 2 #define DIVIDEDCYLINDER_R_H 1 #define SMOOTHINGSURFACE_LPOINTS 1 -/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ diff --git a/src/AdvancedEngine/CMakeLists.txt b/src/AdvancedEngine/CMakeLists.txt index b6073f353..7a2c8e13a 100755 --- a/src/AdvancedEngine/CMakeLists.txt +++ b/src/AdvancedEngine/CMakeLists.txt @@ -45,6 +45,7 @@ ADD_DEFINITIONS( SET(_link_LIBRARIES GEOMEngine SalomeIDLGEOM + SalomeIDLAdvancedGEOM ${KERNEL_SALOMELocalTrace} ${KERNEL_SalomeGenericObj} ${KERNEL_TOOLSDS} @@ -55,30 +56,28 @@ SET(_link_LIBRARIES # --- headers --- SET(AdvancedEngine_HEADERS + AdvancedEngine.hxx AdvancedEngine_Types.hxx - # AdvancedEngine_OperationsCreator.hh - # GEOM_AdvancedEngine.hxx - # GEOMImpl_IAdvancedOperations.hxx - # GEOM_IAdvancedOperations_i.hh - # #ADVANCED_INCLUDES: - # GEOMImpl_IPipeTShape.hxx GEOMImpl_PipeTShapeDriver.hxx - # GEOMImpl_IDividedDisk.hxx GEOMImpl_DividedDiskDriver.hxx - # GEOMImpl_IDividedCylinder.hxx GEOMImpl_DividedCylinderDriver.hxx - # GEOMImpl_ISmoothingSurface.hxx GEOMImpl_SmoothingSurfaceDriver.hxx + AdvancedEngine_DividedDiskDriver.hxx + AdvancedEngine_PipeTShapeDriver.hxx + AdvancedEngine_SmoothingSurfaceDriver.hxx + AdvancedEngine_IPipeTShape.hxx + AdvancedEngine_ISmoothingSurface.hxx + AdvancedEngine_IDividedDisk.hxx + AdvancedEngine_IOperations.hxx + AdvancedEngine_IOperations_i.hh + AdvancedEngine_OperationsCreator.hxx ) # --- sources --- SET(AdvancedEngine_SOURCES AdvancedEngine.cxx - AdvancedEngine_OperationsCreator.cc - GEOMImpl_IAdvancedOperations.cxx - GEOM_IAdvancedOperations_i.cc - # ADVANCED_SOURCES: - GEOMImpl_PipeTShapeDriver.cxx - GEOMImpl_DividedDiskDriver.cxx - #GEOMImpl_DividedCylinderDriver.cxx - GEOMImpl_SmoothingSurfaceDriver.cxx - ##@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@## + AdvancedEngine_DividedDiskDriver.cxx + AdvancedEngine_PipeTShapeDriver.cxx + AdvancedEngine_SmoothingSurfaceDriver.cxx + AdvancedEngine_IOperations.cxx + AdvancedEngine_IOperations_i.cc + AdvancedEngine_OperationsCreator.cxx ) # --- rules --- @@ -87,4 +86,4 @@ ADD_LIBRARY(AdvancedEngine ${AdvancedEngine_SOURCES}) TARGET_LINK_LIBRARIES(AdvancedEngine ${_link_LIBRARIES}) INSTALL(TARGETS AdvancedEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) -INSTALL(FILES ${AdvancedEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) \ No newline at end of file +INSTALL(FILES ${AdvancedEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.cxx b/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.cxx deleted file mode 100644 index 24876c489..000000000 --- a/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.cxx +++ /dev/null @@ -1,529 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 "AdvancedEngine_Types.hxx" - -#include -#include -#include -#include - -// OCCT includes -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include - -#include -//@@ include required header files here @@// - -enum -{ - SQUARE, - HEXAGON -}; -//======================================================================= -//function : GetID -//purpose : -//======================================================================= -const Standard_GUID& GEOMImpl_DividedDiskDriver::GetID() -{ - static Standard_GUID aGUID("0b01da9a-c5da-11e1-8d80-78e7d1879630"); - return aGUID; -} - -//======================================================================= -//function : GEOMImpl_DividedDiskDriver -//purpose : -//======================================================================= -GEOMImpl_DividedDiskDriver::GEOMImpl_DividedDiskDriver() -{ -} - -//======================================================================= -//function : Execute -//purpose : -//======================================================================= -Standard_Integer GEOMImpl_DividedDiskDriver::Execute(TFunction_Logbook& log) const -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - - GEOMImpl_IDividedDisk aData (aFunction); - Standard_Integer aType = aFunction->GetType(); - - TopoDS_Shape aShape; - - // Getting data - double R = aData.GetR(); - double Ratio = aData.GetRatio(); - int Pattern = aData.GetType(); - - // Build reference disk (in the global coordinate system) - TopoDS_Shape aDisk; - - if (Pattern == SQUARE) - aDisk = MakeDiskSquare( R, Ratio ); - else if (Pattern == HEXAGON) - aDisk = MakeDiskHexagon( R, Ratio ); - - if (aType == DIVIDEDDISK_R_RATIO) - { - int theOrientation = aData.GetOrientation(); - aShape = TransformShape(aDisk, theOrientation); - } - else if (aType == DIVIDEDDISK_R_VECTOR_PNT) - { - Handle(GEOM_Function) aRefPoint = aData.GetCenter(); - Handle(GEOM_Function) aRefVector = aData.GetVector(); - TopoDS_Shape aShapePnt = aRefPoint->GetValue(); - TopoDS_Shape aShapeVec = aRefVector->GetValue(); - - if (aShapePnt.ShapeType() == TopAbs_VERTEX && - aShapeVec.ShapeType() == TopAbs_EDGE) - { - gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); - TopoDS_Edge anE = TopoDS::Edge(aShapeVec); - TopoDS_Vertex V1, V2; - TopExp::Vertices(anE, V1, V2, Standard_True); - if (!V1.IsNull() && !V2.IsNull()) - { - gp_Vec aVec (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); - gp_Dir aDir(aVec); - aShape = TransformShape(aDisk, aPnt, aDir); - } - } - } - - if (aShape.IsNull()) return 0; - - aFunction->SetValue(aShape); - - log.SetTouched(Label()); - - return 1; -} - - -//======================================================================= -//function : MakeDiskHexagon -//purpose : -//======================================================================= -TopoDS_Shell GEOMImpl_DividedDiskDriver::MakeDiskHexagon(double R, double Ratio) const -{ - // Geometry - gp_Dir ZDir(0,0,1); - gp_Dir XDir(1,0,0); - gp_Pnt Orig(0,0,0); - - // Circle - gp_Ax1 Ax1(Orig,ZDir); - gp_Ax2 Ax(Orig,ZDir,XDir); - gp_Circ aCircle(Ax, R); - - // Points -// gp_Pnt P4(0.01*Ratio*R,0,0); -// gp_Pnt P3(R,0,0); -// gp_Pnt P2 = P3.Rotated(Ax1,-M_PI/6.0); -// gp_Pnt P1(P4.X(), -// P4.X()/sqrt(3.0),0); - gp_Pnt P1(0.01*Ratio*R*sqrt(3.0)/2,0,0); - gp_Pnt P2(R,0,0); - gp_Pnt P3 = P2.Rotated(Ax1,M_PI/6.0); - gp_Pnt P4(P1.X(), - P1.X()/sqrt(3.0),0); - - - //surfaces - gp_Ax2 anAx (gp::XOY()); - Handle(Geom_Plane) aPlane = new Geom_Plane (anAx); - - // Topology - - // Vertices - TopoDS_Vertex O = BRepBuilderAPI_MakeVertex(Orig); - TopoDS_Vertex V1_init = BRepBuilderAPI_MakeVertex(P1); - TopoDS_Vertex V2_init = BRepBuilderAPI_MakeVertex(P2); - TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(P3); - TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(P4); - - TopoDS_Vertex V1 = V1_init; - TopoDS_Vertex V2 = V2_init; - - //Rotation - gp_Trsf myTrsf; - myTrsf.SetRotation(Ax1, M_PI/3.0); - - BRepBuilderAPI_Transform xform(myTrsf); - xform.Perform(V1,Standard_True); - TopoDS_Vertex V1_60 = TopoDS::Vertex(xform.Shape()); - xform.Perform(V2,Standard_True); - TopoDS_Vertex V2_60 = TopoDS::Vertex(xform.Shape()); - - // Declaration of shapes (used in the loop) - TopoDS_Edge E1, E2, E3, E4, E5, E6, E7, E8, E9; - TopoDS_Wire W1, W2, W3; - TopoDS_Face F1, F2, F3; - TopoDS_Shell S; - - BRep_Builder aBuilder; - aBuilder.MakeShell(S); - - // Initialisation of edges - TopoDS_Edge E1_init = BRepBuilderAPI_MakeEdge(V1,TopoDS::Vertex(V2.Reversed())); - E1 = E1_init; - TopoDS_Edge E8_init = BRepBuilderAPI_MakeEdge(O,TopoDS::Vertex(V1.Reversed())); - E8 = E8_init; - - for (int i=1;i<=6;i++) - { - // Edges - - // for Face1 - E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V3.Reversed())); - E3 = BRepBuilderAPI_MakeEdge(V3,TopoDS::Vertex(V4.Reversed())); - E4 = BRepBuilderAPI_MakeEdge(V4,TopoDS::Vertex(V1.Reversed())); - - // for Face2 - if (i==6) - { - E5 = BRepBuilderAPI_MakeEdge(aCircle, V3, TopoDS::Vertex(V2_init.Reversed())); - E7 = BRepBuilderAPI_MakeEdge(V1_init,TopoDS::Vertex(V4.Reversed())); - } - else - { - E5 = BRepBuilderAPI_MakeEdge(aCircle, V3, TopoDS::Vertex(V2_60.Reversed())); - E7 = BRepBuilderAPI_MakeEdge(V1_60,TopoDS::Vertex(V4.Reversed())); - } - E6 = BRepBuilderAPI_MakeEdge(V2_60,TopoDS::Vertex(V1_60.Reversed())); - - // for Face3 - E9 = BRepBuilderAPI_MakeEdge(V1_60,TopoDS::Vertex(O.Reversed())); - - - // Wires - - //Wire1 - aBuilder.MakeWire(W1); - if (i==1) - aBuilder.Add(W1,E1); - else - aBuilder.Add(W1,TopoDS::Edge(E1.Reversed())); - aBuilder.Add(W1,E2); - aBuilder.Add(W1,E3); - aBuilder.Add(W1,E4); - - // Wire 2 - aBuilder.MakeWire(W2); - aBuilder.Add(W2,TopoDS::Edge(E3.Reversed())); - aBuilder.Add(W2,E5); - if (i==6) - aBuilder.Add(W2,TopoDS::Edge(E1_init.Reversed())); - else - aBuilder.Add(W2,E6); - aBuilder.Add(W2,E7); - - // Wire3 - aBuilder.MakeWire(W3); - if (i==1) - aBuilder.Add(W3,E8); - else - aBuilder.Add(W3,TopoDS::Edge(E8.Reversed())); - aBuilder.Add(W3,TopoDS::Edge(E4.Reversed())); - aBuilder.Add(W3,TopoDS::Edge(E7.Reversed())); - if (i==6) - aBuilder.Add(W3,TopoDS::Edge(E8_init.Reversed())); - else - aBuilder.Add(W3,E9); - - // Faces creation - F1 = BRepBuilderAPI_MakeFace(aPlane,W1); - F2 = BRepBuilderAPI_MakeFace(aPlane,W2); - F3 = BRepBuilderAPI_MakeFace(aPlane,W3); - - //Shell - aBuilder.Add(S, F1); - aBuilder.Add(S, F2); - aBuilder.Add(S, F3); - - // rotation - V1=V1_60; - V2=V2_60; - - xform.Perform(V1_60,Standard_True); - V1_60 = TopoDS::Vertex(xform.Shape()); - xform.Perform(V2_60,Standard_True); - V2_60 = TopoDS::Vertex(xform.Shape()); - xform.Perform(V3,Standard_True); - V3 = TopoDS::Vertex(xform.Shape()); - xform.Perform(V4,Standard_True); - V4 = TopoDS::Vertex(xform.Shape()); - - // "Increment" of edges - E1=E6; - E8=E9; - } - - return S; -} - -//======================================================================= -//function : MakeDiskSquare -//purpose : -//======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::MakeDiskSquare(double R, double Ratio) const -{ - // Geometry - gp_Dir ZDir(0,0,1); - gp_Dir XDir(1,0,0); - gp_Pnt Orig(0,0,0); - - // Circle - gp_Ax1 Ax1(Orig,ZDir); - gp_Ax2 Ax(Orig,ZDir,XDir); - gp_Circ aCircle(Ax, R); - - // Points - gp_Pnt P1(0.01*Ratio*R,0,0); - gp_Pnt P2(R,0,0); - - //surfaces - gp_Ax2 anAx (gp::XOY()); - Handle(Geom_Plane) aPlane = new Geom_Plane (anAx); - - // Topology - - // Vertices - TopoDS_Vertex V1_init = BRepBuilderAPI_MakeVertex(P1); - TopoDS_Vertex V2_init = BRepBuilderAPI_MakeVertex(P2); - - TopoDS_Vertex V1 = V1_init; - TopoDS_Vertex V2 = V2_init; - - //Rotation - gp_Trsf myTrsf; - myTrsf.SetRotation(Ax1, M_PI/2); - - BRepBuilderAPI_Transform xform(myTrsf); - xform.Perform(V1,Standard_True); - TopoDS_Vertex V1_rotated = TopoDS::Vertex(xform.Shape()); - xform.Perform(V2,Standard_True); - TopoDS_Vertex V2_rotated = TopoDS::Vertex(xform.Shape()); - - // Declaration of shapes (used in the loop) - TopoDS_Edge E1, E2, E3, E4; - TopoDS_Wire W1, W2; - TopoDS_Face F1, F2; - TopoDS_Shell S; - - BRep_Builder aBuilder; - aBuilder.MakeWire(W2); // Central Wire - aBuilder.MakeShell(S); // Shell - - // Initialisation of edges - TopoDS_Edge E1_init = BRepBuilderAPI_MakeEdge(V1,TopoDS::Vertex(V2.Reversed())); - E1 = E1_init; - - for (int i=1;i<=4;i++) - { - // Edges - // for Face1 - - E3 = BRepBuilderAPI_MakeEdge(V2_rotated,TopoDS::Vertex(V1_rotated.Reversed())); - if (i == 4) - { - E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V2_init.Reversed())); - E4 = BRepBuilderAPI_MakeEdge(V1_init,TopoDS::Vertex(V1.Reversed())); - } - else - { - E2 = BRepBuilderAPI_MakeEdge(aCircle, V2, TopoDS::Vertex(V2_rotated.Reversed())); - E4 = BRepBuilderAPI_MakeEdge(V1_rotated,TopoDS::Vertex(V1.Reversed())); - } - - // Wires - //Wire1 - aBuilder.MakeWire(W1); - if (i==1) - aBuilder.Add(W1,E1); - else - aBuilder.Add(W1,TopoDS::Edge(E1.Reversed())); - aBuilder.Add(W1,E2); - if (i==4) - aBuilder.Add(W1,TopoDS::Edge(E1_init.Reversed())); - else - aBuilder.Add(W1,E3); - aBuilder.Add(W1,E4); - - // Wire central - aBuilder.Add(W2,TopoDS::Edge(E4.Reversed())); - - // Faces creation - F1 = BRepBuilderAPI_MakeFace(aPlane,W1); - - //Shell - aBuilder.Add(S, F1); - - // rotation - V1=V1_rotated; - V2=V2_rotated; - - xform.Perform(V1_rotated,Standard_True); - V1_rotated = TopoDS::Vertex(xform.Shape()); - xform.Perform(V2_rotated,Standard_True); - V2_rotated = TopoDS::Vertex(xform.Shape()); - - // "Increment" of edges - E1=E3; - } - // Central square Face - F2 = BRepBuilderAPI_MakeFace(aPlane,W2); - aBuilder.Add(S, F2); - - return S; -} - - -//======================================================================= -//function : TrasformShape(TopoDS_Shape aShape,int theOrientation) -//purpose : Perform shape transformation accordingly with specified -// orientation -//======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, int theOrientation) const -{ - gp_Dir N, Vx; - gp_Pnt theOrigin = gp::Origin(); - - switch(theOrientation) - { - case 1: - { - N = gp::DZ(); - Vx = gp::DX(); - break; - } - case 2: - { - N = gp::DX(); - Vx = gp::DY(); - break; - } - case 3: - { - N = gp::DY(); - Vx = gp::DZ(); - break; - } - } - - gp_Ax3 aWPlane = gp_Ax3(theOrigin, N, Vx); - - return WPlaneTransform(theShape, aWPlane); -} - -//======================================================================= -//function : TrasformShape(TopoDS_Shape aShape, gp_Dir V, gp_Pnt P) -//purpose : Perform shape transformation accordingly with specified -// pnt and direction -//======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, gp_Pnt P, gp_Dir V) const -{ - gp_Ax3 aWPlane( P, V ); - return WPlaneTransform(theShape, aWPlane); -} - -//======================================================================= -//function : WPlaneTransform -//purpose : Perform shape transformation accordingly with the given -// Working Plane -//======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::WPlaneTransform(TopoDS_Shape theShape, gp_Ax3 theWPlane) const -{ - gp_Trsf aTrans; - aTrans.SetTransformation(theWPlane); - aTrans.Invert(); - BRepBuilderAPI_Transform aTransformation (theShape, aTrans, Standard_False); - return aTransformation.Shape(); -} - -//================================================================================ -/*! - * \brief Returns a name of creation operation and names and values of creation parameters - */ -//================================================================================ - -bool GEOMImpl_DividedDiskDriver:: -GetCreationInformation(std::string& theOperationName, - std::vector& theParams) -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); - - GEOMImpl_IDividedDisk aCI( function ); - Standard_Integer aType = function->GetType(); - - theOperationName = "DIVIDEDDISK"; - - switch ( aType ) { - case DIVIDEDDISK_R_RATIO: - AddParam( theParams, "Radius", aCI.GetR() ); - AddParam( theParams, "Ratio", aCI.GetRatio() ); - AddParam( theParams, "Orientation", aCI.GetOrientation() ); - AddParam( theParams, "Division pattern", aCI.GetType() ); - break; - case DIVIDEDDISK_R_VECTOR_PNT: - AddParam( theParams, "Center Point", aCI.GetCenter() ); - AddParam( theParams, "Vector", aCI.GetVector() ); - AddParam( theParams, "Radius", aCI.GetR() ); - AddParam( theParams, "Division pattern", aCI.GetType() ); - break; - default: - return false; - } - - return true; -} - -IMPLEMENT_STANDARD_HANDLE (GEOMImpl_DividedDiskDriver,GEOM_BaseDriver); -IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_DividedDiskDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.hxx b/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.hxx deleted file mode 100644 index 9b774c5df..000000000 --- a/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.hxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 _GEOMImpl_DividedDiskDriver_HXX -#define _GEOMImpl_DividedDiskDriver_HXX - -#include - -class Handle_Standard_Type; -class GEOMImpl_DividedDiskDriver; -class TopoDS_Shape; -class TopoDS_Shell; -class gp_Pnt; -class gp_Dir; -class gp_Ax3; - -#include "GEOM_BaseDriver.hxx" - -DEFINE_STANDARD_HANDLE( GEOMImpl_DividedDiskDriver, GEOM_BaseDriver ); - -class GEOMImpl_DividedDiskDriver : public GEOM_BaseDriver { -public: - // Methods PUBLIC - // - Standard_EXPORT GEOMImpl_DividedDiskDriver(); - Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; - Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} - Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const - { - return Standard_True; - } - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT ~GEOMImpl_DividedDiskDriver() {}; - - Standard_EXPORT virtual - bool GetCreationInformation(std::string& theOperationName, - std::vector& params); -private: - TopoDS_Shape TransformShape (TopoDS_Shape aShape, int theOrientation) const; - TopoDS_Shape TransformShape (TopoDS_Shape aShape, gp_Pnt P, gp_Dir V) const; - TopoDS_Shape WPlaneTransform (TopoDS_Shape aShape, gp_Ax3 theWPlane) const; - TopoDS_Shell MakeDiskHexagon (double R, double Ratio) const; - TopoDS_Shape MakeDiskSquare (double R, double Ratio) const; - - DEFINE_STANDARD_RTTI( GEOMImpl_DividedDiskDriver ) -}; - -#endif // _GEOMImpl_DividedDiskDriver_HXX diff --git a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx b/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx deleted file mode 100644 index 59c4d95f8..000000000 --- a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx +++ /dev/null @@ -1,3508 +0,0 @@ -// Copyright (C) 2007-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 -// -// File : GEOMImpl_IAdvancedOperations.cxx -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) - -#include "GEOMImpl_IAdvancedOperations.hxx" - -#include - -#include -#include -#include - -#include "GEOM_Function.hxx" -#include "GEOM_PythonDump.hxx" -#include "GEOMUtils.hxx" -#include "GEOMAlgo_Splitter.hxx" -#include "GEOMAlgo_FinderShapeOn1.hxx" - -#include "GEOMImpl_Gen.hxx" -#include "GEOMImpl_Types.hxx" - -#include "GEOMImpl_IBasicOperations.hxx" -#include "GEOMImpl_IBooleanOperations.hxx" -#include "GEOMImpl_IShapesOperations.hxx" -#include "GEOMImpl_ITransformOperations.hxx" -#include "GEOMImpl_IBlocksOperations.hxx" -#include "GEOMImpl_I3DPrimOperations.hxx" -#include "GEOMImpl_ILocalOperations.hxx" -#include "GEOMImpl_IHealingOperations.hxx" -#include "GEOMImpl_IGroupOperations.hxx" - -#include "GEOMImpl_GlueDriver.hxx" -#include "GEOMImpl_PipeTShapeDriver.hxx" -#include "GEOMImpl_IPipeTShape.hxx" -#include "GEOMImpl_DividedDiskDriver.hxx" -#include "GEOMImpl_IDividedDisk.hxx" -#include -#include -/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ - -#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 -#include -#include - -#include - -#include - -#include "AdvancedEngine_Types.hxx" - -#include -#include -#include -#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC - -#define HALF_LENGTH_MAIN_PIPE "Main pipe half length" //"Tuyau principal - demi longueur" -#define HALF_LENGTH_INCIDENT_PIPE "Incident pipe half length" //"Tuyau incident - demi longueur" -#define CIRCULAR_QUARTER_PIPE "Circular quarter of pipe" //"Circulaire - quart de tuyau" -#define THICKNESS "Thickness" //"Epaisseur" -#define FLANGE "Flange" // "Collerette" -#define CHAMFER_OR_FILLET "Chamfer or fillet" //"Chanfrein ou Raccord" -#define JUNCTION_FACE_1 "Junction 1" //"Face de jonction 1" -#define JUNCTION_FACE_2 "Junction 2" //"Face de jonction 2" -#define JUNCTION_FACE_3 "Junction 3" //"Face de jonction 3" - -#define FIND_GROUPS_BY_POINTS 1 - -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -GEOMImpl_IAdvancedOperations::GEOMImpl_IAdvancedOperations(GEOM_Engine* theEngine, int theDocID) : - GEOM_IOperations(theEngine, theDocID) -{ - MESSAGE("GEOMImpl_IAdvancedOperations::GEOMImpl_IAdvancedOperations"); - myBasicOperations = new GEOMImpl_IBasicOperations(GetEngine(), GetDocID()); - myBooleanOperations = new GEOMImpl_IBooleanOperations(GetEngine(), GetDocID()); - myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID()); - myTransformOperations = new GEOMImpl_ITransformOperations(GetEngine(), GetDocID()); - myBlocksOperations = new GEOMImpl_IBlocksOperations(GetEngine(), GetDocID()); - my3DPrimOperations = new GEOMImpl_I3DPrimOperations(GetEngine(), GetDocID()); - myLocalOperations = new GEOMImpl_ILocalOperations(GetEngine(), GetDocID()); - myHealingOperations = new GEOMImpl_IHealingOperations(GetEngine(), GetDocID()); - myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID()); -} - -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -GEOMImpl_IAdvancedOperations::~GEOMImpl_IAdvancedOperations() -{ - MESSAGE("GEOMImpl_IAdvancedOperations::~GEOMImpl_IAdvancedOperations"); - delete myBasicOperations; - delete myBooleanOperations; - delete myShapesOperations; - delete myTransformOperations; - delete myBlocksOperations; - delete my3DPrimOperations; - delete myLocalOperations; - delete myHealingOperations; - delete myGroupOperations; -} - -//============================================================================= -/*! - * SetPosition - */ -//============================================================================= -gp_Trsf GEOMImpl_IAdvancedOperations::GetPositionTrsf(double theL1, double theL2, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3) -{ - // Old Local Coordinates System oldLCS - gp_Pnt P0(0, 0, 0); - gp_Pnt P1(-theL1, 0, 0); - gp_Pnt P2(theL1, 0, 0); - gp_Pnt P3(0, 0, theL2); - - gp_Dir oldX(gp_Vec(P1, P2)); - gp_Dir oldZ(gp_Vec(P0, P3)); - gp_Ax3 oldLCS(P0, oldZ, oldX); - - // New Local Coordinates System newLCS - double LocX, LocY, LocZ; - gp_Pnt newP1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue())); - gp_Pnt newP2 = BRep_Tool::Pnt(TopoDS::Vertex(theP2->GetValue())); - gp_Pnt newP3 = BRep_Tool::Pnt(TopoDS::Vertex(theP3->GetValue())); - LocX = (newP1.X() + newP2.X()) / 2.; - LocY = (newP1.Y() + newP2.Y()) / 2.; - LocZ = (newP1.Z() + newP2.Z()) / 2.; - gp_Pnt newO(LocX, LocY, LocZ); - - gp_Dir newX(gp_Vec(newP1, newP2)); // P1P2 Vector - gp_Dir newZ(gp_Vec(newO, newP3)); // OP3 Vector - gp_Ax3 newLCS = gp_Ax3(newO, newZ, newX); - - gp_Trsf aTrsf; - aTrsf.SetDisplacement(oldLCS, newLCS); - - return aTrsf; -} - -//============================================================================= -/*! - * CheckCompatiblePosition - * - */ -//============================================================================= -bool GEOMImpl_IAdvancedOperations::CheckCompatiblePosition(double& theL1, double& theL2, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3, - double theTolerance) -{ - SetErrorCode(KO); - gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue())); - gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(theP2->GetValue())); - gp_Pnt P3 = BRep_Tool::Pnt(TopoDS::Vertex(theP3->GetValue())); - - double d12 = P1.Distance(P2); - double d13 = P1.Distance(P3); - double d23 = P2.Distance(P3); - // double d2 = newO.Distance(P3); - - if (Abs(d12) <= Precision::Confusion()) { - SetErrorCode("Junctions points P1 and P2 are identical"); - return false; - } - if (Abs(d13) <= Precision::Confusion()) { - SetErrorCode("Junctions points P1 and P3 are identical"); - return false; - } - if (Abs(d23) <= Precision::Confusion()) { - SetErrorCode("Junctions points P2 and P3 are identical"); - return false; - } - - - double newL1 = 0.5 * d12; - double newL2 = sqrt(pow(d13,2)-pow(newL1,2)); - // - // theL1*(1-theTolerance) <= newL1 <= theL1*(1+theTolerance) - // - if (fabs(newL1 - theL1) > Precision::Approximation()) { - if ( (newL1 * (1 - theTolerance) -theL1 <= Precision::Approximation()) && - (newL1 * (1 + theTolerance) -theL1 >= Precision::Approximation()) ) { - // std::cerr << "theL1 = newL1" << std::endl; - theL1 = newL1; - } else { - theL1 = -1; - SetErrorCode("Dimension for main pipe (L1) is incompatible with new position"); - return false; - } - } - - // - // theL2*(1-theTolerance) <= newL2 <= theL2*(1+theTolerance) - // - if (fabs(newL2 - theL2) > Precision::Approximation()) { - if ( (newL2 * (1 - theTolerance) -theL2 <= Precision::Approximation()) && - (newL2 * (1 + theTolerance) -theL2 >= Precision::Approximation()) ) { - theL2 = newL2; - } else { - theL2 = -1; - SetErrorCode("Dimension for incident pipe (L2) is incompatible with new position"); - return false; - } - } - - SetErrorCode(OK); - return true; - -} - -//============================================================================= -/*! - * Generate the propagation groups of a Pipe T-Shape used for hexa mesh - */ -//============================================================================= -bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int shapeType, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theH, double theW, double theRF, - Handle(TColStd_HSequenceOfTransient) theSeq, - gp_Trsf aTrsf) -{ - SetErrorCode(KO); - - if (theShape.IsNull()) return false; - - TopoDS_Shape aShape = theShape->GetValue(); - if (aShape.IsNull()) { - SetErrorCode("Shape is not defined"); - return false; - } - - gp_Trsf aTrsfInv = aTrsf.Inverted(); - -// int expectedGroups = 0; -// if (shapeType == TSHAPE_BASIC) -// if (Abs(theR2+theW2-theR1-theW1) <= Precision::Approximation()) -// expectedGroups = 10; -// else -// expectedGroups = 11; -// else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) -// expectedGroups = 12; - - double aR1Ext = theR1 + theW1; - double aR2Ext = theR2 + theW2; - - ///////////////////////// - //// Groups of Faces //// - ///////////////////////// - - // - // Comment the following lines when GetInPlace bug is solved - // == BEGIN - // Workaround of GetInPlace bug - // Create a bounding box that fits the shape - Handle(GEOM_Object) aBox = my3DPrimOperations->MakeBoxDXDYDZ(2*theL1, 2*aR1Ext, aR1Ext+theL2); - aBox->GetLastFunction()->SetDescription(""); - myTransformOperations->TranslateDXDYDZ(aBox, -theL1, -aR1Ext, -aR1Ext); - aBox->GetLastFunction()->SetDescription(""); - // Apply transformation to box - BRepBuilderAPI_Transform aTransformationBox(aBox->GetValue(), aTrsf, Standard_False); - TopoDS_Shape aBoxShapeTrsf = aTransformationBox.Shape(); - aBox->GetLastFunction()->SetValue(aBoxShapeTrsf); - - // Get the shell of the box - Handle(GEOM_Object) aShell = Handle(GEOM_Object)::DownCast - (myShapesOperations->MakeExplode(aBox, TopAbs_SHELL, true)->Value(1)); - aBox->GetLastFunction()->SetDescription(""); - aShell->GetLastFunction()->SetDescription(""); - // Get the common shapes between shell and shape - Handle(GEOM_Object) aCommonCompound = myBooleanOperations->MakeBoolean - (theShape, aShell, 1, Standard_False); // MakeCommon - if (aCommonCompound.IsNull()) { - SetErrorCode(myBooleanOperations->GetErrorCode()); - return false; - } - aCommonCompound->GetLastFunction()->SetDescription(""); - // Explode the faces of common shapes => 3 faces - Handle(TColStd_HSequenceOfTransient) aCommonFaces = - myShapesOperations->MakeExplode(aCommonCompound, TopAbs_FACE, true); - aCommonCompound->GetLastFunction()->SetDescription(""); - std::list aCompoundOfFacesList; - - for (int i=0 ; i<= aCommonFaces->Length()-4 ; i+=4) { - std::list aFacesList; - for (int j = 1 ; j <= 4 ; j++) { - Handle(GEOM_Object) aFace = Handle(GEOM_Object)::DownCast(aCommonFaces->Value(i+j)); // Junction faces - if (!aFace.IsNull()) { - aFace->GetLastFunction()->SetDescription(""); - aFacesList.push_back(aFace); - } - } - Handle(GEOM_Object) aCompoundOfFaces = myShapesOperations->MakeCompound(aFacesList); - if (!aCompoundOfFaces.IsNull()) { - aCompoundOfFaces->GetLastFunction()->SetDescription(""); - aCompoundOfFacesList.push_back(aCompoundOfFaces); - } - } - - if (aCompoundOfFacesList.size() == 3) { - Handle(GEOM_Object) aPln1 = aCompoundOfFacesList.front(); - aCompoundOfFacesList.pop_front(); - Handle(GEOM_Object) aPln2 = aCompoundOfFacesList.front(); - aCompoundOfFacesList.pop_front(); - Handle(GEOM_Object) aPln3 = aCompoundOfFacesList.front(); - aCompoundOfFacesList.pop_front(); - // == END - // - - - // Uncomment the following lines when GetInPlace bug is solved - // == BEGIN -// Handle(GEOM_Object) aP1 = myBasicOperations->MakePointXYZ(-theL1, 0, 0); -// Handle(GEOM_Object) aP2 = myBasicOperations->MakePointXYZ(-0, 0, theL2); -// Handle(GEOM_Object) aP3 = myBasicOperations->MakePointXYZ(theL1, 0, 0); -// aP1->GetLastFunction()->SetDescription(""); -// aP2->GetLastFunction()->SetDescription(""); -// aP3->GetLastFunction()->SetDescription(""); -// Handle(GEOM_Object) aV1 = myBasicOperations->MakeVectorDXDYDZ(-1, 0, 0); -// Handle(GEOM_Object) aV2 = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); -// Handle(GEOM_Object) aV3 = myBasicOperations->MakeVectorDXDYDZ(1, 0, 0); -// aV1->GetLastFunction()->SetDescription(""); -// aV2->GetLastFunction()->SetDescription(""); -// aV3->GetLastFunction()->SetDescription(""); -// Handle(GEOM_Object) aPln1 = myBasicOperations->MakePlanePntVec(aP1, aV1, 2*(aR1Ext+theL2)); -// Handle(GEOM_Object) aPln2 = myBasicOperations->MakePlanePntVec(aP2, aV2, 2*(aR2Ext)); -// Handle(GEOM_Object) aPln3 = myBasicOperations->MakePlanePntVec(aP3, aV3, 2*(aR1Ext+theL2)); -// aPln1->GetLastFunction()->SetDescription(""); -// aPln2->GetLastFunction()->SetDescription(""); -// aPln3->GetLastFunction()->SetDescription(""); -// -// BRepBuilderAPI_Transform aTransformation1(aPln1->GetValue(), aTrsf, Standard_False); -// TopoDS_Shape aTrsf_Shape1 = aTransformation1.Shape(); -// aPln1->GetLastFunction()->SetValue(aTrsf_Shape1); -// BRepBuilderAPI_Transform aTransformation2(aPln2->GetValue(), aTrsf, Standard_False); -// TopoDS_Shape aTrsf_Shape2 = aTransformation2.Shape(); -// aPln2->GetLastFunction()->SetValue(aTrsf_Shape2); -// BRepBuilderAPI_Transform aTransformation3(aPln3->GetValue(), aTrsf, Standard_False); -// TopoDS_Shape aTrsf_Shape3 = aTransformation3.Shape(); -// aPln3->GetLastFunction()->SetValue(aTrsf_Shape3); - // == END - // - - Handle(GEOM_Object) junctionFaces1 = myShapesOperations->GetInPlace(theShape, aPln1); - if (junctionFaces1.IsNull()) - junctionFaces1 = myShapesOperations->GetShapesOnShapeAsCompound - (aPln1, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); - if (!junctionFaces1.IsNull()) { - junctionFaces1->GetLastFunction()->SetDescription(""); - junctionFaces1->SetName("JUNCTION_FACE_1"); - theSeq->Append(junctionFaces1); - } - else { - SetErrorCode("Junction face 1 not found"); - // theSeq->Append(aPln1); - // return false; - } - Handle(GEOM_Object) junctionFaces2 = myShapesOperations->GetInPlace(theShape, aPln2); - if (junctionFaces2.IsNull()) - junctionFaces2 = myShapesOperations->GetShapesOnShapeAsCompound - (aPln2, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); - if (!junctionFaces2.IsNull()) { - junctionFaces2->GetLastFunction()->SetDescription(""); - junctionFaces2->SetName("JUNCTION_FACE_2"); - theSeq->Append(junctionFaces2); - } - else { - SetErrorCode("Junction face 2 not found"); - // theSeq->Append(aPln2); - // return false; - } - Handle(GEOM_Object) junctionFaces3 = myShapesOperations->GetInPlace(theShape, aPln3); - if (junctionFaces3.IsNull()) - junctionFaces3 = myShapesOperations->GetShapesOnShapeAsCompound - (aPln3, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); - if (!junctionFaces3.IsNull()) { - junctionFaces3->GetLastFunction()->SetDescription(""); - junctionFaces3->SetName("JUNCTION_FACE_3"); - theSeq->Append(junctionFaces3); - } - else { - SetErrorCode("Junction face 3 not found"); - // theSeq->Append(aPln3); - // return false; - } - // Comment the following lines when GetInPlace bug is solved - // == BEGIN - } - // == END - - ///////////////////////// - //// Groups of Edges //// - ///////////////////////// - // Result of propagate - - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); - - TCollection_AsciiString theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) aSeqPropagate = myBlocksOperations->Propagate(theShape); - if (aSeqPropagate.IsNull() || aSeqPropagate->Length() == 0) { - SetErrorCode("Propagation groups not found"); - return false; - } - Standard_Integer aNbGroups = aSeqPropagate->Length(); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - -#ifdef FIND_GROUPS_BY_POINTS - // BEGIN: new groups search - - // W2 R2 - // .----.-----.----. - // e| | | | | - // | | | | | - // . | | | . - // g / ''..| | |..'' \ - // f / ''''''' \ - // .---.--'.. | | | ..'--.---. - // |a \ '''...........''' / | - // |-------\------' | '------/-------. - // | \ | / | - // c| \ | / | - // | R1 \ | / | - // | \ | / | - // ._________________|_________________. - // | L1 | | - // | | | - // | | | - // b| | | - // | | | - // |-----------------|-----------------| - // | W1 | | - // '-----------------'-----------------' - // d - - // "Thickness" group (a) - gp_Pnt aPntA (-theL1, 0, theR1 + theW1/2.); - aPntA.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexA (aPntA); - TopoDS_Vertex aVertA = TopoDS::Vertex(mkVertexA.Shape()); - TopoDS_Shape anEdgeA = GEOMUtils::GetEdgeNearPoint(aShape, aVertA); - - // "Circular quarter of pipe" group (b) - gp_Pnt aPntB (-theL1, -aR1Ext * sin(M_PI/4.), -aR1Ext * sin(M_PI/4.)); - aPntB.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexB (aPntB); - TopoDS_Vertex aVertB = TopoDS::Vertex(mkVertexB.Shape()); - TopoDS_Shape anEdgeB = GEOMUtils::GetEdgeNearPoint(aShape, aVertB); - - // "Circular quarter of pipe" group (c) - gp_Pnt aPntC (-theL1, -aR1Ext * sin(M_PI/4.), aR1Ext * sin(M_PI/4.)); - aPntC.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexC (aPntC); - TopoDS_Vertex aVertC = TopoDS::Vertex(mkVertexC.Shape()); - TopoDS_Shape anEdgeC = GEOMUtils::GetEdgeNearPoint(aShape, aVertC); - - // "Main pipe half length" group (d) - gp_Pnt aPntD (-theL1/2., 0, -aR1Ext); - aPntD.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexD (aPntD); - TopoDS_Vertex aVertD = TopoDS::Vertex(mkVertexD.Shape()); - TopoDS_Shape anEdgeD = GEOMUtils::GetEdgeNearPoint(aShape, aVertD); - - // "Incident pipe half length" group (e) - double aTol10 = Precision::Confusion() * 10.; - gp_Pnt aPntE (-aR2Ext, 0, theL2 - aTol10); - aPntE.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexE (aPntE); - TopoDS_Vertex aVertE = TopoDS::Vertex(mkVertexE.Shape()); - TopoDS_Shape anEdgeE = GEOMUtils::GetEdgeNearPoint(aShape, aVertE); - - // "Flange" group (f) - double aFx = - aR2Ext - aTol10; - if (shapeType == TSHAPE_CHAMFER) - aFx -= theW; - else if (shapeType == TSHAPE_FILLET) - aFx -= theRF; - gp_Pnt aPntF (aFx, 0, aR1Ext); - aPntF.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexF (aPntF); - TopoDS_Vertex aVertF = TopoDS::Vertex(mkVertexF.Shape()); - TopoDS_Shape anEdgeF = GEOMUtils::GetEdgeNearPoint(aShape, aVertF); - - // "Chamfer or Fillet" group (g) - TopoDS_Shape anEdgeG; - if (shapeType == TSHAPE_CHAMFER) { - gp_Pnt aPntG (-aR2Ext - theW/2., 0, aR1Ext + theH/2.); - aPntG.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexG (aPntG); - TopoDS_Vertex aVertG = TopoDS::Vertex(mkVertexG.Shape()); - anEdgeG = GEOMUtils::GetEdgeNearPoint(aShape, aVertG); - } - else if (shapeType == TSHAPE_FILLET) { - gp_Pnt aPntG (-aR2Ext - theRF/2., 0, aR1Ext + theRF/2.); - aPntG.Transform(aTrsf); - BRepBuilderAPI_MakeVertex mkVertexG (aPntG); - TopoDS_Vertex aVertG = TopoDS::Vertex(mkVertexG.Shape()); - anEdgeG = GEOMUtils::GetEdgeNearPoint(aShape, aVertG); - } - - for (int i = 1 ; i <= aNbGroups; i++) { - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(aSeqPropagate->Value(i)); - if (aGroup.IsNull()) - continue; - - TopoDS_Shape aGroupShape = aGroup->GetValue(); - TopTools_IndexedMapOfShape anEdgesMap; - TopExp::MapShapes(aGroupShape, TopAbs_EDGE, anEdgesMap); - - if (anEdgesMap.Contains(anEdgeA)) { // a - aGroup->SetName("THICKNESS"); - theSeq->Append(aGroup); - } - else if (anEdgesMap.Contains(anEdgeB)) { // b - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - theSeq->Append(aGroup); - } - else if (anEdgesMap.Contains(anEdgeC)) { // c - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - theSeq->Append(aGroup); - } - else if (anEdgesMap.Contains(anEdgeD)) { // d - aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); - theSeq->Append(aGroup); - } - else if (anEdgesMap.Contains(anEdgeE)) { // e - aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); - theSeq->Append(aGroup); - } - else if (anEdgesMap.Contains(anEdgeF)) { // f - aGroup->SetName("FLANGE"); - theSeq->Append(aGroup); - } - else if (shapeType == TSHAPE_CHAMFER) { // g - if (anEdgesMap.Contains(anEdgeG)) { - aGroup->SetName("CHAMFER"); - theSeq->Append(aGroup); - } - } - else if (shapeType == TSHAPE_FILLET) { // g - if (anEdgesMap.Contains(anEdgeG)) { - aGroup->SetName("FILLET"); - theSeq->Append(aGroup); - } - } - else { - } - } - // END: new groups search -#else - bool addGroup; - bool circularFoundAndAdded = false; - bool circularFound10 = false; - bool incidentPipeFound = false; - bool mainPipeFound = false; - bool mainPipeFoundAndAdded = false; - bool radialFound =false; - bool flangeFound = false; - bool flangeFoundAndAdded = false; - bool chamferOrFilletFound = false; - - for (int i = 1 ; i <= aNbGroups; i++) { - addGroup = false; - - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(aSeqPropagate->Value(i)); - if (aGroup.IsNull()) - continue; - - TopoDS_Shape aGroupShape = aGroup->GetValue(); - BRepBuilderAPI_Transform aTransformationShapeInv (aGroupShape, aTrsfInv, Standard_False); - TopoDS_Shape aGroupShapeTrsfInv = aTransformationShapeInv.Shape(); - - TopTools_IndexedMapOfShape anEdgesMap; - TopExp::MapShapes(aGroupShapeTrsfInv,TopAbs_EDGE, anEdgesMap); - Standard_Integer nbEdges = anEdgesMap.Extent(); - - if (shapeType == TSHAPE_BASIC) { - if ((nbEdges >= 21) || /*R1Ext = R2Ext*/(nbEdges == 17)) { // 17, 17+8*{1,2,3}, 21, 21+8*{1,2,3} - addGroup = true; - aGroup->SetName("THICKNESS"); - } - else if (nbEdges == 6) { - if (!circularFoundAndAdded) { - circularFoundAndAdded = true; - addGroup = true; - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - } - } - else if (nbEdges == 8) { - incidentPipeFound = true; - mainPipeFound = false; - radialFound = false; - flangeFound = false; - - TopExp_Explorer Ex(aGroupShapeTrsfInv,TopAbs_VERTEX); - while (Ex.More()) { - gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - double x=aP.X(), y=aP.Y(), z=aP.Z(); - - - if ((Abs(x) > aR2Ext + Precision::Confusion()) || - (Abs(y) > aR2Ext + Precision::Confusion())) { - incidentPipeFound = false; - } - - if ( z < -Precision::Confusion()) { - // length of main pipe - mainPipeFound = true; - if (!mainPipeFoundAndAdded) { - mainPipeFoundAndAdded = true; - addGroup = true; - aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); - } - } - - else if (Abs(x) > (theL1-Precision::Confusion())) { - // discretisation circulaire - radialFound = true; - if (!circularFoundAndAdded) { - circularFoundAndAdded = true; - addGroup = true; - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - } - } - Ex.Next(); - } - if (incidentPipeFound) { - addGroup = true; - aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); - } - if (!addGroup && (!incidentPipeFound && - !radialFound && - !mainPipeFound && - !flangeFound)) { - // Flange (collerette) - flangeFound = true; - addGroup = true; - aGroup->SetName("FLANGE"); - } - } - else - continue; - } - else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) { - if (nbEdges >= 25) { // 25, 25+8, 25+16, 25+24 - addGroup = true; - aGroup->SetName("THICKNESS"); - } - else if ((nbEdges == 10) || (nbEdges == 6)) { - if (!circularFoundAndAdded) { - addGroup = true; - circularFoundAndAdded = true; - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - if (nbEdges == 10) { - circularFound10 = true; - } - } - else if (!circularFound10 && nbEdges == 10) { - circularFound10 = true; - addGroup = true; - aGroup->SetName("CIRCULAR_QUARTER_PIPE"); - } - } - else if (nbEdges == 8) { - incidentPipeFound = true; - mainPipeFound = true; - flangeFound = false; - - bool isNearZ0 = false; - bool isBelowZ0 = false; - - TopExp_Explorer Ex (aGroupShapeTrsfInv,TopAbs_VERTEX); - while (Ex.More()) { - gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - double x=aP.X(), y=aP.Y(), z=aP.Z(); - - // tuy_princ_long_avant & tuy_princ_long_apres - //bool isMain = (((z < Precision::Confusion()) || (x < Precision::Confusion())) && - // ((y <= aR1Ext + Precision::Confusion()) || - // (y <= -(aR1Ext + Precision::Confusion())) || - // (y <= theR1 + Precision::Confusion()) || - // (y == -(theR1 + Precision::Confusion())))); - bool isMain = ((z < Precision::Confusion() || x < Precision::Confusion()) && - (fabs(y) > theR1 - Precision::Confusion() || - fabs(y) < Precision::Confusion())); - - if (!isMain) { - mainPipeFound = false; - } - - // collerette - //if (z < Precision::Confusion() && !isMain) { - // flangeFound = true; - // if (!flangeFoundAndAdded) { - // flangeFoundAndAdded = true; - // addGroup = true; - // aGroup->SetName("FLANGE"); - // } - //} - if (fabs(z) < Precision::Confusion()) isNearZ0 = true; - if (z < - Precision::Confusion()) isBelowZ0 = true; - - // tuyau incident - if ((Abs(x) > aR2Ext + Precision::Confusion()) || - (Abs(y) > aR2Ext + Precision::Confusion())) { - incidentPipeFound = false; - } - Ex.Next(); - } - if (mainPipeFound) { - addGroup = true; - aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); - } - if (incidentPipeFound) { - addGroup = true; - aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); - } - if (isNearZ0 && !isBelowZ0) { - flangeFound = true; - if (!flangeFoundAndAdded) { - flangeFoundAndAdded = true; - addGroup = true; - aGroup->SetName("FLANGE"); - } - } - if (!addGroup && (!incidentPipeFound && - !mainPipeFound && - !flangeFound && - !chamferOrFilletFound)) { - addGroup = true; - chamferOrFilletFound = true; - if (shapeType == TSHAPE_CHAMFER) - aGroup->SetName("CHAMFER"); - else - aGroup->SetName("FILLET"); - } - } - else - continue; - } - // Add group to the list - if (addGroup) - theSeq->Append(aGroup); - } -#endif - - SetErrorCode(OK); - return true; -} - -//============================================================================= -/*! - * Return faces that are laying on surface. - */ -//============================================================================= -bool GEOMImpl_IAdvancedOperations::GetFacesOnSurf - (const TopoDS_Shape &theShape, - const Handle_Geom_Surface& theSurface, - const Standard_Real theTolerance, - TopTools_ListOfShape &theFaces) -{ - GEOMAlgo_FinderShapeOn1 aFinder; - - aFinder.SetShape(theShape); - aFinder.SetTolerance(theTolerance); - aFinder.SetSurface(theSurface); - aFinder.SetShapeType(TopAbs_FACE); - aFinder.SetState(GEOMAlgo_ST_ON); - - // Sets the minimal number of inner points for the faces that do not have own - // inner points at all (for e.g. rectangular planar faces have just 2 triangles). - // Default value=3 - aFinder.SetNbPntsMin(3); - // Sets the maximal number of inner points for edges or faces. - // It is usefull for the cases when this number is very big (e.g =2000) to improve - // the performance. If this value =0, all inner points will be taken into account. - // Default value=0 - aFinder.SetNbPntsMax(100); - aFinder.Perform(); - - // Interprete results - Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx - if (iErr) { - MESSAGE(" iErr : " << iErr); - TCollection_AsciiString aMsg (" iErr : "); - aMsg += TCollection_AsciiString(iErr); - SetErrorCode(aMsg); - return false; - } - Standard_Integer iWrn = aFinder.WarningStatus(); - // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx - if (iWrn) { - MESSAGE(" *** iWrn : " << iWrn); - } - - const TopTools_ListOfShape &aListRes = aFinder.Shapes(); // the result - TopTools_ListIteratorOfListOfShape anIter (aListRes); - - for (; anIter.More(); anIter.Next()) { - theFaces.Append(anIter.Value()); - } - - return true; -} - -//============================================================================= -/*! - * Creates and returns conical face. - */ -//============================================================================= -TopoDS_Shape GEOMImpl_IAdvancedOperations::MakeConicalFace - (const gp_Ax2 &theAxis, - const double theRadius, - const double theRadiusThin, - const double theHeight, - const gp_Trsf &theTrsf) -{ - BRepPrimAPI_MakeCone aMkCone (theAxis, theRadius, theRadiusThin, theHeight); - TopoDS_Shape aResult; - - aMkCone.Build(); - if (aMkCone.IsDone()) { - TopExp_Explorer anExp(aMkCone.Shape(), TopAbs_FACE); - - for (; anExp.More(); anExp.Next()) { - TopoDS_Face aFace = TopoDS::Face(anExp.Current()); - - if (aFace.IsNull() == Standard_False) { - BRepAdaptor_Surface anAdaptor(aFace, Standard_False); - - if (anAdaptor.GetType() == GeomAbs_Cone) { - // This is a conical face. Transform and return it. - BRepBuilderAPI_Transform aTransf(aFace, theTrsf, Standard_False); - - aResult = aTransf.Shape(); - break; - } - } - } - } - - return aResult; -} - -//============================================================================= -/*! - * Generate the internal group of a Pipe T-Shape - */ -//============================================================================= -bool GEOMImpl_IAdvancedOperations::MakeInternalGroup - (const Handle(GEOM_Object) &theShape, - const double theR1, const double theLen1, - const double theR2, const double theLen2, - const double theRL, double theTransLenL, - const double theRR, double theTransLenR, - const double theRI, double theTransLenI, - const Handle(TColStd_HSequenceOfTransient) &theSeq, - const gp_Trsf &theTrsf) -{ - SetErrorCode(KO); - - if (theShape.IsNull()) { - return false; - } - - TopoDS_Shape aShape = theShape->GetValue(); - - if (aShape.IsNull()) { - SetErrorCode("Shape is not defined"); - return false; - } - - // Compute tolerance - Standard_Real aMaxTol = -RealLast(); - TopExp_Explorer anExp(aShape, TopAbs_VERTEX); - - for (; anExp.More(); anExp.Next()) { - TopoDS_Vertex aVertex = TopoDS::Vertex(anExp.Current()); - - if (aVertex.IsNull() == Standard_False) { - const Standard_Real aTol = BRep_Tool::Tolerance(aVertex); - - if (aTol > aMaxTol) { - aMaxTol = aTol; - } - } - } - - // Construct internal surfaces. - Standard_Integer i = 0; - const Standard_Integer aMaxNbSurf = 5; - Handle(Geom_Surface) aSurface[aMaxNbSurf]; - TopTools_ListOfShape aConicalFaces; - Standard_Real aTolConf = Precision::Confusion(); - - // 1. Construct the internal surface of main pipe. - gp_Ax2 anAxis1 (gp::Origin(), gp::DX(), gp::DZ()); - gp_Ax2 anAxis2 (gp::Origin(), gp::DZ(), gp::DX()); - - aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theR1); - - // 2. Construct the internal surface of incident pipe. - aSurface[i++] = new Geom_CylindricalSurface(anAxis2, theR2); - - // 3. Construct the internal surface of left reduction pipe. - if (theRL > aTolConf) { - aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theRL); - - if (theTransLenL > aTolConf) { - // 3.1. Construct the internal surface of left transition pipe. - gp_Pnt aPLeft (-theLen1, 0., 0.); - gp_Ax2 anAxisLeft (aPLeft, -gp::DX(), gp::DZ()); - TopoDS_Shape aConeLeft = - MakeConicalFace(anAxisLeft, theR1, theRL, theTransLenL, theTrsf); - - if (aConeLeft.IsNull() == Standard_False) { - aConicalFaces.Append(aConeLeft); - } - } - } - - // 4. Construct the internal surface of right reduction pipe. - if (theRR > aTolConf) { - // There is no need to construct another cylinder of the same radius. Skip it. - if (Abs(theRR - theRL) > aTolConf) { - aSurface[i++] = new Geom_CylindricalSurface(anAxis1, theRR); - } - - if (theTransLenL > aTolConf) { - // 4.1. Construct the internal surface of right transition pipe. - gp_Pnt aPRight (theLen1, 0., 0.); - gp_Ax2 anAxisRight (aPRight, gp::DX(), gp::DZ()); - TopoDS_Shape aConeRight = - MakeConicalFace(anAxisRight, theR1, theRR, theTransLenR, theTrsf); - - if (aConeRight.IsNull() == Standard_False) { - aConicalFaces.Append(aConeRight); - } - } - } - - // 5. Construct the internal surface of incident reduction pipe. - if (theRI > aTolConf) { - aSurface[i++] = new Geom_CylindricalSurface(anAxis2, theRI); - - if (theTransLenI > aTolConf) { - // 5.1. Construct the internal surface of incident transition pipe. - gp_Pnt aPInci (0., 0., theLen2); - gp_Ax2 anAxisInci (aPInci, gp::DZ(), gp::DX()); - TopoDS_Shape aConeInci = - MakeConicalFace(anAxisInci, theR2, theRI, theTransLenI, theTrsf); - - if (aConeInci.IsNull() == Standard_False) { - aConicalFaces.Append(aConeInci); - } - } - } - - // Get faces that are laying on cylindrical surfaces. - TopTools_ListOfShape aFaces; - gp_Trsf anInvTrsf = theTrsf.Inverted(); - - for (i = 0; i < aMaxNbSurf; i++) { - if (aSurface[i].IsNull()) { - break; - } - - aSurface[i]->Transform(theTrsf); - - TopTools_ListOfShape aLocalFaces; - - if (!GetFacesOnSurf(aShape, aSurface[i], aMaxTol, aLocalFaces)) { - return false; - } - - if (i < 2) { - // Check if the result contains outer cylinders. - // It is required for main and incident pipes. - TopTools_ListIteratorOfListOfShape anIter(aLocalFaces); - - while (anIter.More()) { - TopExp_Explorer anExp(anIter.Value(), TopAbs_VERTEX); - Standard_Boolean isInside = Standard_False; - - // Get a vertex from this shape - if (anExp.More()) { - TopoDS_Vertex aVtx = TopoDS::Vertex(anExp.Current()); - - if (aVtx.IsNull() == Standard_False) { - gp_Pnt aPnt = BRep_Tool::Pnt(aVtx); - - aPnt.Transform(anInvTrsf); - - if (i == 0) { - // Check if the point is inside the main pipe. - isInside = (Abs(aPnt.X()) <= theLen1); - } else { // i == 1 - // Check if the point is inside the incident pipe. - isInside = (aPnt.Z() <= theLen2); - } - } - } - - if (isInside) { - // Keep this face. - anIter.Next(); - } else { - // Remove this face. - aLocalFaces.Remove(anIter); - } - } - } - - aFaces.Append(aLocalFaces); - } - - // Get faces that are laying on conical faces. - if (aConicalFaces.IsEmpty() == Standard_False) { - Handle(GEOM_Object) aCone = - GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - Handle(GEOM_Function) aFunction = - aCone->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); - TopTools_ListIteratorOfListOfShape aFIter(aConicalFaces); - Handle(GEOM_Object) aConeFromShape; - - for (; aFIter.More(); aFIter.Next()) { - aFunction->SetValue(aFIter.Value()); - aConeFromShape = myShapesOperations->GetInPlace(theShape, aCone); - - if (aConeFromShape.IsNull() == Standard_False) { - aConeFromShape->GetLastFunction()->SetDescription(""); - TopoDS_Shape aConeFaces = aConeFromShape->GetValue(); - TopExp_Explorer anExp(aConeFaces, TopAbs_FACE); - - for (; anExp.More(); anExp.Next()) { - TopoDS_Face aConeFace = TopoDS::Face(anExp.Current()); - - if (aConeFace.IsNull() == Standard_False) { - aFaces.Append(aConeFace); - } - } - } - } - } - - // Create a group of internal faces. - if (aFaces.IsEmpty() == Standard_False) { - Handle(GEOM_Object) aGroup = myGroupOperations->CreateGroup(theShape, TopAbs_FACE); - - if (aGroup.IsNull() == Standard_False) { - aGroup->GetLastFunction()->SetDescription(""); - aGroup->SetName("INTERNAL_FACES"); - - TopTools_IndexedMapOfShape anIndices; - Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger; - - TopExp::MapShapes(aShape, anIndices); - - TopTools_ListIteratorOfListOfShape anIter(aFaces); - - for (; anIter.More(); anIter.Next()) { - const TopoDS_Shape &aFace = anIter.Value(); - const Standard_Integer anIndex = anIndices.FindIndex(aFace); - - if (anIndex > 0) { - aSeqIDs->Append(anIndex); - } - } - - myGroupOperations->UnionIDs(aGroup, aSeqIDs); - aGroup->GetLastFunction()->SetDescription(""); - theSeq->Append(aGroup); - } - } - - SetErrorCode(OK); - - return true; -} - -bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theH, double theW, - double theRF, bool isNormal) -{ - SetErrorCode(KO); - - // Build tools for partition operation: - // 1 face and 2 planes - // Face - Handle(GEOM_Object) arete_intersect_int, arete_intersect_ext; - Handle(GEOM_Object) wire_t, wire_t2, face_t, face_t2; - Handle(GEOM_Object) chan_racc; - Handle(GEOM_Object) vi1, vi2; - Handle(GEOM_Object) Te3; - - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - Handle(GEOM_Object) Vector_Z = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); - Vector_Z->GetLastFunction()->SetDescription(""); - - // Useful values - double aSize = 2*(theL1 + theL2); - double aR1Ext = theR1 + theW1; - double aR2Ext = theR2 + theW2; - double theVertCylinderRadius = aR2Ext + theW + theRF; - double theHoriCylinderRadius = aR1Ext + theH + theRF; - - // Common edges on internal cylinder - Handle(GEOM_Object) box_i = my3DPrimOperations->MakeBoxDXDYDZ(theR2, theR2, theR1); - box_i->GetLastFunction()->SetDescription(""); - box_i = myTransformOperations->TranslateDXDYDZ(box_i, -theR2, -theR2, 0); - box_i->GetLastFunction()->SetDescription(""); - - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); - TCollection_AsciiString theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) edges_i = - myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - if (edges_i.IsNull() || edges_i->Length() == 0) { - SetErrorCode("Internal edges not found"); - return false; - } - for (int i=1; i<=edges_i->Length();i++) { - Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(edges_i->Value(i)); - anObj->GetLastFunction()->SetDescription(""); - } - arete_intersect_int = Handle(GEOM_Object)::DownCast(edges_i->Value(1)); - - // search for vertices located on both internal pipes - aFunction = theShape->GetLastFunction(); - theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) vertices_i = - myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - if (vertices_i.IsNull() || vertices_i->Length() == 0) { - SetErrorCode("Internal vertices not found"); - return false; - } - - double d1min = theR2+theW2, d2min=theR2+theW2; - for (int i = 1; i <= vertices_i->Length(); i++) { - Handle(GEOM_Object) v = Handle(GEOM_Object)::DownCast(vertices_i->Value(i)); - v->GetLastFunction()->SetDescription(""); - TopoDS_Vertex aVertex = TopoDS::Vertex(v->GetValue()); - gp_Pnt aP = BRep_Tool::Pnt(aVertex); - if (Abs(aP.X()) <= Precision::Confusion()) { - if (Abs(aP.Y()) < d1min) { - vi1 = v; - d1min = Abs(aP.Y()); - } - } else if (Abs(aP.Y()) <= Precision::Confusion()) { - if (Abs(aP.X()) < d2min) { - vi2 = v; - d2min = Abs(aP.X()); - } - } - } - if (vi1.IsNull() || vi2.IsNull()) { - SetErrorCode("Cannot find internal intersection vertices"); - return false; - } - - std::list theShapes; - - if (isNormal) { - Handle(GEOM_Object) ve1, ve2; - TopoDS_Vertex vertex1, vertex2; - - Handle(GEOM_Object) box_e = my3DPrimOperations->MakeBoxDXDYDZ(aR2Ext, aR2Ext, aR1Ext); - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ(box_e, -aR2Ext, -aR2Ext, 0); - box_e->GetLastFunction()->SetDescription(""); - - // search for vertices located on both external pipes - aFunction = theShape->GetLastFunction(); - theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) vertices_e = - myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - if (vertices_e.IsNull() || vertices_e->Length() == 0) { - SetErrorCode("External vertices not found"); - return false; - } - - double d1max = 0, d2max = 0; - for (int i = 1; i <= vertices_e->Length(); i++) { - Handle(GEOM_Object) v = Handle(GEOM_Object)::DownCast(vertices_e->Value(i)); - v->GetLastFunction()->SetDescription(""); - TopoDS_Vertex aVertex = TopoDS::Vertex(v->GetValue()); - gp_Pnt aP = BRep_Tool::Pnt(aVertex); - if (Abs(aP.X()) <= Precision::Confusion()) { - if (Abs(aP.Y()) > d1max) { - ve1 = v; - vertex1 = aVertex; - d1max = Abs(aP.Y()); - } - } else if (Abs(aP.Y()) <= Precision::Confusion()) { - if (Abs(aP.X()) > d2max) { - ve2 = v; - vertex2 = aVertex; - d2max = Abs(aP.X()); - } - } - } - if (ve1.IsNull() || ve2.IsNull()) { - SetErrorCode("Cannot find external intersection vertices"); - return false; - } - Handle(GEOM_Object) edge_e1, edge_e2; - - // Common edges on external cylinder - aFunction = theShape->GetLastFunction(); - theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) edges_e = - myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - if (edges_e.IsNull() || edges_e->Length() == 0) { - SetErrorCode("External edges not found"); - return false; - } - ShapeAnalysis_Edge sae; - for (int i=1; i<=edges_e->Length();i++) { - Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(edges_e->Value(i)); - anObj->GetLastFunction()->SetDescription(""); - TopoDS_Edge anEdge = TopoDS::Edge(anObj->GetValue()); - if ( !anEdge.IsNull() && - (sae.FirstVertex(anEdge).IsSame(vertex1) || sae.LastVertex(anEdge).IsSame(vertex1)) && - (sae.FirstVertex(anEdge).IsSame(vertex2) || sae.LastVertex(anEdge).IsSame(vertex2))) { - arete_intersect_ext = anObj; - } - } - - edge_e1 = myBasicOperations->MakeLineTwoPnt(ve1, vi1); - if (edge_e1.IsNull()) { - SetErrorCode("Edge 1 could not be built"); - return false; - } - - edge_e2 = myBasicOperations->MakeLineTwoPnt(ve2, vi2); - if (edge_e2.IsNull()) { - SetErrorCode("Edge 2 could not be built"); - return false; - } - - edge_e1->GetLastFunction()->SetDescription(""); - edge_e2->GetLastFunction()->SetDescription(""); - - std::list edge_e_elist; - edge_e_elist.push_back(arete_intersect_int); - edge_e_elist.push_back(edge_e1); - edge_e_elist.push_back(arete_intersect_ext); - edge_e_elist.push_back(edge_e2); - wire_t = myShapesOperations->MakeWire(edge_e_elist, 1e-7); - if (wire_t.IsNull()) { - SetErrorCode("Impossible to build wire"); - return false; - } - wire_t->GetLastFunction()->SetDescription(""); - face_t = myShapesOperations->MakeFace(wire_t, false); - if (face_t.IsNull()) { - SetErrorCode("Impossible to build face"); - return false; - } - face_t->GetLastFunction()->SetDescription(""); - - theShapes.push_back(theShape); - theShapes.push_back(vi1); - theShapes.push_back(vi2); - theShapes.push_back(ve1); - theShapes.push_back(ve2); - theShapes.push_back(edge_e1); - theShapes.push_back(edge_e2); - theShapes.push_back(wire_t); - theShapes.push_back(face_t); - } - else { - Handle(GEOM_Object) P1, P2, P3, P4, P5, P6; - int idP1, idP2, idP3, idP4; - int PZX, PZY; - double ZX=0, ZY=0; - std::vector LX; - std::vector LY; - Handle(GEOM_Object) box_e = my3DPrimOperations->MakeBoxDXDYDZ - (theVertCylinderRadius, theVertCylinderRadius, theHoriCylinderRadius); - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ - (box_e, -theVertCylinderRadius, -theVertCylinderRadius, 0); - box_e->GetLastFunction()->SetDescription(""); - - aFunction = theShape->GetLastFunction(); - theDesc = aFunction->GetDescription(); - Handle(TColStd_HSequenceOfTransient) extremVertices = - myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); - // Recover previous description to get rid of Propagate dump - aFunction->SetDescription(theDesc); - - if (extremVertices.IsNull() || extremVertices->Length() == 0) { - if (theRF == 0) - SetErrorCode("Vertices on chamfer not found"); - else - SetErrorCode("Vertices on fillet not found"); - return false; - } - - theShapes.push_back(theShape); - theShapes.push_back(box_e); - if (extremVertices->Length() != 6) { - // for (int i=1; i<=extremVertices->Length(); i++){ - // theShapes.push_back(Handle(GEOM_Object)::DownCast(extremVertices->Value(i))); - // } - // Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes); - // TopoDS_Shape aCompoundShape = aCompound->GetValue(); - // theShape->GetLastFunction()->SetValue(aCompoundShape); - SetErrorCode("Bad number of vertices on chamfer found"); - return false; - } - - for (int i=1; i<=extremVertices->Length(); i++){ - Handle(GEOM_Object) aV = Handle(GEOM_Object)::DownCast(extremVertices->Value(i)); - aV->GetLastFunction()->SetDescription(""); - gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aV->GetValue())); - - if (Abs(aP.X()) <= Precision::Confusion()) { - if (Abs(aP.Y()) - theR2 > Precision::Confusion()) { - LX.push_back(i); - if (aP.Z()-ZX > Precision::Confusion()) { - ZX = aP.Z(); - PZX = i; - } - } - } - else { - if (Abs(aP.X()) - theR2 > Precision::Confusion()) { - LY.push_back(i); - if (aP.Z() - ZY > Precision::Confusion()) { - ZY = aP.Z(); - PZY = i; - } - } - } - } - - idP2 = PZX; - idP4 = PZY; - idP1 = LX.at(0); - if (LX.at(0) == PZX) - idP1 = LX.at(1); - idP3 = LY.at(0); - if (LY.at(0) == PZY) - idP3 = LY.at(1); - - P1 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP1)); - P2 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP2)); - P3 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP3)); - P4 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP4)); - - Handle(GEOM_Object) Cote_1 = myBasicOperations->MakeLineTwoPnt(P1, vi1); - if (Cote_1.IsNull()) { - SetErrorCode("Impossible to build edge in thickness"); - return false; - } - Cote_1->GetLastFunction()->SetDescription(""); - - Handle(GEOM_Object) Cote_2 = myBasicOperations->MakeLineTwoPnt(vi2, P3); - if (Cote_2.IsNull()) { - SetErrorCode("Impossible to build edge in thickness"); - return false; - } - Cote_2->GetLastFunction()->SetDescription(""); - - // edge_chan_princ = arete du chanfrein (ou raccord) sur le tuyau principal - // edge_chan_inc = arete du chanfrein (ou raccord) sur le tuyau incident - // std::cerr << "Getting chamfer edge on main pipe" << std::endl; - Handle(GEOM_Object) edge_chan_princ = myBlocksOperations->GetEdge(theShape, P1, P3); - if (edge_chan_princ.IsNull()) { - SetErrorCode("Impossible to find edge on main pipe"); - return false; - } - edge_chan_princ->GetLastFunction()->SetDescription(""); - - Handle(GEOM_Object) edge_chan_inc = myBlocksOperations->GetEdge(theShape, P2, P4); - if (edge_chan_inc.IsNull()) { - SetErrorCode("Impossible to find edge on incident pipe"); - return false; - } - edge_chan_inc->GetLastFunction()->SetDescription(""); - - std::list edgeList1; - edgeList1.push_back(edge_chan_princ); - edgeList1.push_back(Cote_1); - edgeList1.push_back(arete_intersect_int); - edgeList1.push_back(Cote_2); - - // std::cerr << "Creating wire 1" << std::endl; - wire_t = myShapesOperations->MakeWire(edgeList1, 1e-7); - if (wire_t.IsNull()) { - SetErrorCode("Impossible to build wire"); - return false; - } - wire_t->GetLastFunction()->SetDescription(""); - - // std::cerr << "Creating face 1" << std::endl; - face_t = myShapesOperations->MakeFace(wire_t, false); - if (face_t.IsNull()) { - SetErrorCode("Impossible to build face"); - return false; - } - face_t->GetLastFunction()->SetDescription(""); - theShapes.push_back(face_t); - - gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(P2->GetValue())); - gp_Pnt aP5 = BRep_Tool::Pnt(TopoDS::Vertex(vi1->GetValue())); - double deltaZ = aP2.Z() - aP5.Z(); - // std::cerr << "Creating new point from vi1 with deltaZ = " << deltaZ << std::endl; - Handle(GEOM_Object) P5bis = myTransformOperations->TranslateDXDYDZCopy(vi1, 0, 0, deltaZ); - if (P5bis.IsNull()) { - SetErrorCode("Impossible to translate vertex"); - return false; - } - P5bis->GetLastFunction()->SetDescription(""); - - gp_Pnt aP4 = BRep_Tool::Pnt(TopoDS::Vertex(P4->GetValue())); - gp_Pnt aP6 = BRep_Tool::Pnt(TopoDS::Vertex(vi2->GetValue())); - deltaZ = aP4.Z() - aP6.Z(); - // std::cerr << "Creating new point from vi2 with deltaZ = " << deltaZ << std::endl; - Handle(GEOM_Object) P6bis = myTransformOperations->TranslateDXDYDZCopy(vi2, 0, 0, deltaZ); - if (P6bis.IsNull()) { - SetErrorCode("Impossible to translate vertex"); - return false; - } - P6bis->GetLastFunction()->SetDescription(""); - - // std::cerr << "Creating new line 1 from 2 previous points" << std::endl; - Handle(GEOM_Object) Cote_3 = myBasicOperations->MakeLineTwoPnt(P5bis, P2); - if (Cote_3.IsNull()) { - SetErrorCode("Impossible to build edge in thickness"); - return false; - } - Cote_3->GetLastFunction()->SetDescription(""); - - // std::cerr << "Creating new line 2 from 2 previous points" << std::endl; - Handle(GEOM_Object) Cote_4 = myBasicOperations->MakeLineTwoPnt(P6bis, P4); - if (Cote_4.IsNull()) { - SetErrorCode("Impossible to build edge in thickness"); - return false; - } - Cote_4->GetLastFunction()->SetDescription(""); - - // std::cerr << "Creating new line 3 from 2 previous points" << std::endl; - Handle(GEOM_Object) Cote_5 = myBasicOperations->MakeLineTwoPnt(P5bis, P6bis); - if (Cote_4.IsNull()) { - SetErrorCode("Impossible to build edge in thickness"); - return false; - } - Cote_5->GetLastFunction()->SetDescription(""); - - //std::list edgeList2; - //edgeList2.push_back(edge_chan_inc); - //edgeList2.push_back(Cote_3); - //edgeList2.push_back(Cote_5); - //edgeList2.push_back(Cote_4); - // std::cerr << "Creating wire 2" << std::endl; - //wire_t2 = myShapesOperations->MakeWire(edgeList2, 1e-7); - //if (wire_t2.IsNull()) { - // SetErrorCode("Impossible to build wire"); - // return false; - //} - //wire_t2->GetLastFunction()->SetDescription(""); - // std::cerr << "Creating face 2" << std::endl; - //face_t2 = myShapesOperations->MakeFace(wire_t2, false); - - // Mantis issue 0021682 - face_t2 = my3DPrimOperations->MakePrismVecH(edge_chan_inc, Cote_4, - (theR2 + theW2)); - //face_t2 = my3DPrimOperations->MakePrismVecH(edge_chan_inc, Cote_4, - 2.0*theR2); - if (face_t2.IsNull()) { - SetErrorCode("Impossible to build face"); - return false; - } - face_t2->GetLastFunction()->SetDescription(""); - theShapes.push_back(face_t2); - } - - // Planes - Handle(GEOM_Object) aP0 = myBasicOperations->MakePointXYZ(0, 0, 0); - Handle(GEOM_Object) aVZ = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); - Handle(GEOM_Object) aVXZ = myBasicOperations->MakeVectorDXDYDZ(aR1Ext, 0, 0.5*(theL1+theVertCylinderRadius)); - Handle(GEOM_Object) aPlnOZ = myBasicOperations->MakePlanePntVec(aP0, aVZ, aSize); - Handle(GEOM_Object) aPlnOXZ = myBasicOperations->MakePlanePntVec(aP0, aVXZ, aSize); - aP0->GetLastFunction()->SetDescription(""); - aVZ->GetLastFunction()->SetDescription(""); - aVXZ->GetLastFunction()->SetDescription(""); - aPlnOZ->GetLastFunction()->SetDescription(""); - aPlnOXZ->GetLastFunction()->SetDescription(""); - theShapes.push_back(aPlnOZ); - theShapes.push_back(aPlnOXZ); - - // Partition - Handle(TColStd_HSequenceOfTransient) partitionShapes = new TColStd_HSequenceOfTransient; - Handle(TColStd_HSequenceOfTransient) theTools = new TColStd_HSequenceOfTransient; - Handle(TColStd_HSequenceOfTransient) theKeepInside = new TColStd_HSequenceOfTransient; - Handle(TColStd_HSequenceOfTransient) theRemoveInside = new TColStd_HSequenceOfTransient; - Handle(TColStd_HArray1OfInteger) theMaterials; - - partitionShapes->Append(theShape); - theTools->Append(aPlnOZ); - if (Abs(aR1Ext - aR2Ext) > Precision::Confusion()) - theTools->Append(aPlnOXZ); - theTools->Append(face_t); - if (!isNormal) - theTools->Append(face_t2); - - Te3 = myBooleanOperations->MakePartition - (partitionShapes, theTools, theKeepInside, theRemoveInside, - TopAbs_SOLID, false, theMaterials, 0, false, Standard_False); - if (Te3.IsNull()) { - SetErrorCode("Impossible to build partition of TShape"); - return false; - } - Te3->GetLastFunction()->SetDescription(""); - - // Last verification: result should be a block - std::list errList; - if (!myBlocksOperations->CheckCompoundOfBlocks(Te3,errList)) { - SetErrorCode("TShape is not a compound of block"); - return false; - } - -// // BEGIN Compound of created shapes - Only for debug purpose -// theShapes.clear(); -// theShapes.push_back(theShape); -// theShapes.push_back(aPlnOZ); -// if (Abs(aR1Ext - aR2Ext) > Precision::Confusion() ) -// theShapes.push_back(aPlnOXZ); -// theShapes.push_back(face_t); -// if (!isNormal) -// theShapes.push_back(face_t2); -// -// Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes); -// TopoDS_Shape aCompoundShape = aCompound->GetValue(); -// theShape->GetLastFunction()->SetValue(aCompoundShape); -// // END Compound of created shapes - Only for debug purpose - - TopoDS_Shape aShape = Te3->GetValue(); - theShape->GetLastFunction()->SetValue(aShape); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return false; - } - - SetErrorCode(OK); - return true; -} - -// Mirror and glue faces -bool GEOMImpl_IAdvancedOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2) -{ - SetErrorCode(KO); - - // Useful values - double aSize = 2*(theL1 + theL2); - double aR1Ext = theR1 + theW1; - - // Planes - Handle(GEOM_Object) aP0 = myBasicOperations->MakePointXYZ(0, 0, 0); - aP0->GetLastFunction()->SetDescription(""); - Handle(GEOM_Object) aVX = myBasicOperations->MakeVectorDXDYDZ(1, 0, 0); - Handle(GEOM_Object) aVY = myBasicOperations->MakeVectorDXDYDZ(0, 1, 0); - aVX->GetLastFunction()->SetDescription(""); - aVY->GetLastFunction()->SetDescription(""); - Handle(GEOM_Object) aPlane_OX = myBasicOperations->MakePlanePntVec(aP0, aVX, 2*(aR1Ext + theL2)); - Handle(GEOM_Object) aPlane_OY = myBasicOperations->MakePlanePntVec(aP0, aVY, aSize); - aPlane_OX->GetLastFunction()->SetDescription(""); - aPlane_OY->GetLastFunction()->SetDescription(""); - - Handle(GEOM_Object) Te4 = myTransformOperations->MirrorPlaneCopy(theShape, aPlane_OX); - if (Te4.IsNull()) { - SetErrorCode("Impossible to build mirror of quarter TShape"); - return false; - } - - Handle(GEOM_Object) Te5 = myTransformOperations->MirrorPlaneCopy(theShape, aPlane_OY); - if (Te5.IsNull()) { - SetErrorCode("Impossible to build mirror of half TShape"); - return false; - } - - Handle(GEOM_Object) Te6 = myTransformOperations->MirrorPlaneCopy(Te4, aPlane_OY); - if (Te6.IsNull()) { - SetErrorCode("Impossible to build mirror of half TShape"); - return false; - } - - std::list aShapesList; - aShapesList.push_back(theShape); - aShapesList.push_back(Te4); - aShapesList.push_back(Te5); - aShapesList.push_back(Te6); - Handle(GEOM_Object) Te7 = myShapesOperations->MakeCompound(aShapesList); - if (Te7.IsNull()) { - SetErrorCode("Impossible to build compound"); - return false; - } - - // Copy source shape - TopoDS_Shape aShapeCopy; - TColStd_IndexedDataMapOfTransientTransient aMapTShapes; - TNaming_CopyShape::CopyTool(Te7->GetValue(), aMapTShapes, aShapeCopy); - - Handle(GEOM_Object) Te8 = myShapesOperations->MakeGlueFaces(Te7, 1e-7, true); - if (Te8.IsNull()) { - SetErrorCode("Impossible to glue faces of TShape"); - return false; - } - - TopoDS_Shape aShape = Te8->GetValue(); - BRepCheck_Analyzer anAna (aShape, Standard_True); - - if (!anAna.IsValid()) { - // Try to do gluing with the tolerance equal to maximal - // tolerance of vertices of the source shape. - Standard_Real aTolMax = -RealLast(); - - for (TopExp_Explorer ExV (aShapeCopy, TopAbs_VERTEX); ExV.More(); ExV.Next()) { - TopoDS_Vertex aVertex = TopoDS::Vertex(ExV.Current()); - Standard_Real aTol = BRep_Tool::Tolerance(aVertex); - - if (aTol > aTolMax) { - aTolMax = aTol; - } - } - - // Perform gluing - Te7->GetLastFunction()->SetValue(aShapeCopy); - Te8 = myShapesOperations->MakeGlueFaces(Te7, aTolMax, true); - - if (Te8.IsNull()) { - SetErrorCode("Impossible to glue faces of TShape"); - return false; - } - - aShape = Te8->GetValue(); - } - - - theShape->GetLastFunction()->SetValue(aShape); - - Te4->GetLastFunction()->SetDescription(""); - Te5->GetLastFunction()->SetDescription(""); - Te6->GetLastFunction()->SetDescription(""); - Te7->GetLastFunction()->SetDescription(""); - Te8->GetLastFunction()->SetDescription(""); - - SetErrorCode(OK); - return true; -} - -//======================================================================= -//function : MakePipeTShapeThicknessReduction -//purpose : Static method. Add thiskness reduction elements at the three -// open ends of the T-Shape. -//======================================================================= -TopoDS_Shape GEOMImpl_IAdvancedOperations::MakePipeTShapeThicknessReduction - (TopoDS_Shape theShape, - double r1, double w1, double l1, - double r2, double w2, double l2, - double rL, double wL, double ltransL, double lthinL, - double rR, double wR, double ltransR, double lthinR, - double rI, double wI, double ltransI, double lthinI, - bool fuseReductions) -{ - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - // - // ---------------------. - // W \ - // ---------------------. \ - // ^ \ '-----------------. - // |R \ Wthin | - // | '-----------------' - // v Rthin - // --.--.--.--.--.--.--.--.--.--.--.--.--.--.-- - // Ltrans Lthin - - TopoDS_Shape aResult = theShape; - double aTol = Precision::Confusion(); - - gp_Vec aVX = gp::DX(), aVZ = gp::DZ(); - - // Left reduction (rL, wL, ltransL, lthinL) - if (rL > aTol && wL > aTol && ltransL > aTol) { - gp_Pnt aPLeft (-l1, 0, 0); - gp_Ax2 anAxesLeft (aPLeft, -aVX, aVZ); - TopoDS_Shape aReductionLeft = GEOMImpl_IAdvancedOperations::MakeThicknessReduction - (anAxesLeft, r1, w1, rL, wL, ltransL, lthinL, fuseReductions); - - if (fuseReductions) { - BRepAlgoAPI_Fuse fuseL (aResult, aReductionLeft); - if (!fuseL.IsDone()) - StdFail_NotDone::Raise("Cannot fuse Te with left reduction"); - aResult = fuseL.Shape(); - } - else { - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - B.Add(C, aResult); - B.Add(C, aReductionLeft); - aResult = C; - } - } - - // Right reduction - if (rR > aTol && wR > aTol && ltransR > aTol) { - gp_Pnt aPRight (l1, 0, 0); - gp_Ax2 anAxesRight (aPRight, aVX, aVZ); - TopoDS_Shape aReductionRight = GEOMImpl_IAdvancedOperations::MakeThicknessReduction - (anAxesRight, r1, w1, rR, wR, ltransR, lthinR, fuseReductions); - - if (fuseReductions) { - BRepAlgoAPI_Fuse fuseR (aResult, aReductionRight); - if (!fuseR.IsDone()) - StdFail_NotDone::Raise("Cannot fuse Te with right reduction"); - aResult = fuseR.Shape(); - } - else { - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - B.Add(C, aResult); - B.Add(C, aReductionRight); - aResult = C; - } - } - - // Incident reduction - if (rI > aTol && wI > aTol && ltransI > aTol) { - gp_Pnt aPInci (0, 0, l2); - gp_Ax2 anAxesInci (aPInci, aVZ, aVX); - TopoDS_Shape aReductionInci = GEOMImpl_IAdvancedOperations::MakeThicknessReduction - (anAxesInci, r2, w2, rI, wI, ltransI, lthinI, fuseReductions); - - if (fuseReductions) { - BRepAlgoAPI_Fuse fuseInci (aResult, aReductionInci); - if (!fuseInci.IsDone()) - StdFail_NotDone::Raise("Cannot fuse Te with incident reduction"); - aResult = fuseInci.Shape(); - } - else { - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - B.Add(C, aResult); - B.Add(C, aReductionInci); - aResult = C; - } - } - - // Get rid of extra compounds - TopTools_ListOfShape listShapeRes; - GEOMUtils::AddSimpleShapes(aResult, listShapeRes); - aResult = listShapeRes.First(); // useful for the case "fuseReductions == true" - - if (!fuseReductions && listShapeRes.Extent() > 1) { - // Simplify T-Shape compound (get rid of sub-compounds) and glue duplicated faces - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - - TopTools_ListIteratorOfListOfShape itSub (listShapeRes); - for (; itSub.More(); itSub.Next()) - B.Add(C, itSub.Value()); - - // GlueFaces - aResult = GEOMImpl_GlueDriver::GlueFaces(C, Precision::Confusion(), Standard_True); - } - - return aResult; -} - -//======================================================================= -//function : MakeThicknessReduction -//purpose : Static method. Create one thickness reduction element. -//======================================================================= -TopoDS_Shape GEOMImpl_IAdvancedOperations::MakeThicknessReduction (gp_Ax2 theAxes, - const double R, const double W, - const double Rthin, const double Wthin, - const double Ltrans, const double Lthin, - bool fuse) -{ - double aTol = Precision::Confusion(); - if (Rthin < aTol || Wthin < aTol || Ltrans < aTol) { - StdFail_NotDone::Raise("Cannot build thickness reduction: too small values"); - } - bool isThinPart = (Lthin > aTol); - - // . - // W |\ - // . \ - // ^ \ '-----------------. - // |R \| | Wthin - // | '-----------------' - // v Rthin - // --.--.--.--.--.--.--.--.--.--.--.--.--> theAxes.Direction() - // Ltrans Lthin - - double RExt = R + W; - double RthinExt = Rthin + Wthin; - - gp_Dir aNormal = theAxes.Direction(); - gp_Dir anXDir = theAxes.XDirection(); - gp_Pnt aPntCyl (theAxes.Location().XYZ() + aNormal.XYZ()*Ltrans); - gp_Ax2 anAxesCyl (aPntCyl, aNormal, anXDir); - - // Build the transition part - BRepPrimAPI_MakeCone ConeExt (theAxes, RExt, RthinExt, Ltrans); - BRepPrimAPI_MakeCone ConeInt (theAxes, R, Rthin, Ltrans); - ConeExt.Build(); - ConeInt.Build(); - if (!ConeExt.IsDone() || !ConeInt.IsDone()) - StdFail_NotDone::Raise("Cannot build cones of thickness reduction"); - BRepAlgoAPI_Cut cut1 (ConeExt.Shape(), ConeInt.Shape()); - if (!cut1.IsDone()) - StdFail_NotDone::Raise("Coudn't build transition part of thickness reduction"); - TopoDS_Shape aReduction = cut1.Shape(); - - // Build the thin part, if required - TopoDS_Shape aThinPart; - if (isThinPart) { - BRepPrimAPI_MakeCylinder CExt (anAxesCyl, RthinExt, Lthin); - BRepPrimAPI_MakeCylinder CInt (anAxesCyl, Rthin, Lthin); - CExt.Build(); - CInt.Build(); - if (!CExt.IsDone() || !CInt.IsDone()) - StdFail_NotDone::Raise("Cannot build cylinders of thickness reduction"); - BRepAlgoAPI_Cut cut2 (CExt.Shape(), CInt.Shape()); - if (!cut2.IsDone()) - StdFail_NotDone::Raise("Coudn't build thin part of thickness reduction"); - aThinPart = cut2.Shape(); - } - - // Join parts - if (fuse) { - if (isThinPart) { - BRepAlgoAPI_Fuse fuse1 (aReduction, aThinPart); - if (!fuse1.IsDone()) - StdFail_NotDone::Raise("Cannot fuse parts of thickness reduction"); - aReduction = fuse1.Shape(); - } - } - else { - // Partition the reduction on blocks - gp_Ax3 anAxesPln1 (aPntCyl, theAxes.XDirection(), aNormal); - gp_Ax3 anAxesPln2 (aPntCyl, theAxes.YDirection(), aNormal); - gp_Pln aPln1 (anAxesPln1); - gp_Pln aPln2 (anAxesPln2); - double aSize = Ltrans + Lthin + R + Rthin + Wthin; // to guarantee enough size in all directions - TopoDS_Shape aTool1 = BRepBuilderAPI_MakeFace(aPln1, -aSize, +aSize, -aSize, +aSize).Shape(); - TopoDS_Shape aTool2 = BRepBuilderAPI_MakeFace(aPln2, -aSize, +aSize, -aSize, +aSize).Shape(); - - GEOMAlgo_Splitter PS; - PS.AddArgument(aReduction); - if (isThinPart) - PS.AddArgument(aThinPart); - PS.AddTool(aTool1); - PS.AddTool(aTool2); - PS.SetLimit(TopAbs_SOLID); - PS.Perform(); - - aReduction = PS.Shape(); - } - - return aReduction; -} - -//============================================================================= -/*! - * MakePipeTShape - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) - GEOMImpl_IAdvancedOperations::MakePipeTShape(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - bool theHexMesh) -{ - MESSAGE("GEOMImpl_IAdvancedOperations::MakePipeTShape"); - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - GEOMImpl_IPipeTShape aData (aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - if (isTRL || isTRR || isTRI) { - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape, TSHAPE_BASIC, theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., aSeq, gp_Trsf())) - return NULL; - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, gp_Trsf())) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShape(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theHexMesh; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * MakePipeTShapeWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups.. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition - (double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - bool theHexMesh, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3) -{ - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - ///////////////// - // TSHAPE CODE - ///////////////// - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - // Check new position - if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { - return NULL; - } - - GEOMImpl_IPipeTShape aData(aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - if (isTRL || isTRR || isTRI) { - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - TopoDS_Shape Te = aShape->GetValue(); - - // Set Position - gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); - BRepBuilderAPI_Transform aTransformation(Te, aTrsf, Standard_False); - TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); - aFunction->SetValue(aTrsf_Shape); - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape,TSHAPE_BASIC, theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., aSeq, aTrsf)) { - return NULL; - } - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, aTrsf)) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShape(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theHexMesh << ", " << theP1 << ", " << theP2 << ", " << theP3; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * MakePipeTShapeChamfer - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of chamfer. - * \param theW Width of chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer - (double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theH, double theW, - bool theHexMesh) -{ - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_CHAMFER); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - GEOMImpl_IPipeTShape aData(aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetH(theH); - aData.SetW(theW); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // BEGIN of chamfer - TopoDS_Shape aShapeShape = aShape->GetValue(); - TopTools_IndexedMapOfShape anEdgesIndices; - TopExp::MapShapes(aShapeShape, anEdgesIndices); - // Common edges on external cylinders - Handle(GEOM_Object) box_e; - if (theHexMesh) { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); - } - else { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); - } - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); - box_e->GetLastFunction()->SetDescription(""); - - Handle(TColStd_HSequenceOfInteger) edges_e = - myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - box_e->GetLastFunction()->SetDescription(""); - - if (edges_e.IsNull() || edges_e->Length() == 0) { - SetErrorCode("External edges not found"); - return NULL; - } - int nbEdgesInChamfer = 0; - std::list theEdges; - for (int i=1; i<=edges_e->Length();i++) { - int edgeID = edges_e->Value(i); - TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); - TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); - int iv=0; - while (Ex.More()) { - iv ++; - gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { - nbEdgesInChamfer ++; - theEdges.push_back(edgeID); - } - Ex.Next(); - } - if (theHexMesh && nbEdgesInChamfer == 1) - break; - } - Handle(GEOM_Object) aChamfer; - try { - aChamfer = myLocalOperations->MakeChamferEdges(aShape, theW, theH, theEdges); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - if (aChamfer.IsNull()) { - SetErrorCode("Chamfer can not be computed on the given shape with the given parameters"); - return NULL; - } - aChamfer->GetLastFunction()->SetDescription(""); - - TopoDS_Shape aChamferShape = aChamfer->GetValue(); - aFunction->SetValue(aChamferShape); - // END of chamfer - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, 0, false)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (isTRL || isTRR || isTRI) { - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, - theH, theW, 0., aSeq, gp_Trsf())) - return NULL; - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, gp_Trsf())) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeChamfer(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theH << ", " << theW << ", " << theHexMesh; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * MakePipeTShapeChamferWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of chamfer. - * \param theW Width of chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition - (double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theH, double theW, - bool theHexMesh, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3) -{ - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_CHAMFER); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - // Check new position - if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { - return NULL; - } - - GEOMImpl_IPipeTShape aData(aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetH(theH); - aData.SetW(theW); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // BEGIN of chamfer - TopoDS_Shape aShapeShape = aShape->GetValue(); - TopTools_IndexedMapOfShape anEdgesIndices; - TopExp::MapShapes(aShapeShape, anEdgesIndices); - // Common edges on external cylinders - Handle(GEOM_Object) box_e; - if (theHexMesh) { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); - } - else { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); - } - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); - box_e->GetLastFunction()->SetDescription(""); - - Handle(TColStd_HSequenceOfInteger) edges_e = - myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - box_e->GetLastFunction()->SetDescription(""); - - if (edges_e.IsNull() || edges_e->Length() == 0) { - SetErrorCode("External edges not found"); - return NULL; - } - int nbEdgesInChamfer = 0; - std::list theEdges; - for (int i=1; i<=edges_e->Length();i++) { - int edgeID = edges_e->Value(i); - TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); - TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); - while (Ex.More()) { - gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { - nbEdgesInChamfer ++; - theEdges.push_back(edgeID); - } - Ex.Next(); - } - if (theHexMesh && nbEdgesInChamfer == 1) - break; - } - Handle(GEOM_Object) aChamfer; - try { - aChamfer = myLocalOperations->MakeChamferEdges(aShape, theW, theH, theEdges); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - if (aChamfer.IsNull()) { - SetErrorCode("Chamfer can not be computed on the given shape with the given parameters"); - return NULL; - } - aChamfer->GetLastFunction()->SetDescription(""); - - TopoDS_Shape aChamferShape = aChamfer->GetValue(); - aFunction->SetValue(aChamferShape); - // END of chamfer - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, 0, false)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (isTRL || isTRR || isTRI) { - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // Set Position - gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); - BRepBuilderAPI_Transform aTransformation (aShape->GetValue(), aTrsf, Standard_False); - TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); - aFunction->SetValue(aTrsf_Shape); - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, - theH, theW, 0., aSeq, aTrsf)) - return NULL; - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, aTrsf)) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeChamfer(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theH << ", " << theW << ", " << theHexMesh << ", " - << theP1 << ", " << theP2 << ", " << theP3; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * MakePipeTShapeFillet - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet - (double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theRF, bool theHexMesh) -{ - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_FILLET); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - GEOMImpl_IPipeTShape aData(aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetRF(theRF); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // BEGIN of fillet - TopoDS_Shape aShapeShape = aShape->GetValue(); - TopTools_IndexedMapOfShape anEdgesIndices; - TopExp::MapShapes(aShapeShape, anEdgesIndices); - // Common edges on external cylinders - Handle(GEOM_Object) box_e; - if (theHexMesh) { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); - } - else { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); - } - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); - box_e->GetLastFunction()->SetDescription(""); - - Handle(TColStd_HSequenceOfInteger) edges_e = - myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - box_e->GetLastFunction()->SetDescription(""); - - if (edges_e.IsNull() || edges_e->Length() == 0) { - SetErrorCode("External edges not found"); - return NULL; - } - int nbEdgesInFillet = 0; - std::list theEdges; - for (int i=1; i<=edges_e->Length();i++) { - int edgeID = edges_e->Value(i); - TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); - TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); - while (Ex.More()) { - gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { - nbEdgesInFillet ++; - theEdges.push_back(edgeID); - } - Ex.Next(); - } - if (theHexMesh && nbEdgesInFillet == 1) - break; - } - - Handle(GEOM_Object) aFillet; - try { - aFillet = myLocalOperations->MakeFilletEdges(aShape, theRF, theEdges); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - if (aFillet.IsNull()) { - //SetErrorCode("Fillet can not be computed on the given shape with the given parameters"); - SetErrorCode(myLocalOperations->GetErrorCode()); - return NULL; - } - aFillet->GetLastFunction()->SetDescription(""); - - TopoDS_Shape aFilletShape = aFillet->GetValue(); - aFunction->SetValue(aFilletShape); - // END of fillet - -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (1) -// the following block, when enabled, leads to partitioning problems -#if 0 -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (1) - // BEGIN: Limit tolerances (debug) - Handle(GEOM_Object) aCorr1 = myHealingOperations->LimitTolerance(aShape, 1e-07); - TopoDS_Shape aCorr1Shape = aCorr1->GetValue(); - aShape->GetLastFunction()->SetValue(aCorr1Shape); - aCorr1->GetLastFunction()->SetDescription(""); - // END: Limit tolerances (debug) -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (2) -#endif -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (2) - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, 0, 0, theRF, false)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (isTRL || isTRR || isTRI) { - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape, TSHAPE_FILLET, theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., theRF, aSeq, gp_Trsf())) - return NULL; - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, gp_Trsf())) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeFillet(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theRF << ", " << theHexMesh; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * MakePipeTShapeFilletWithPosition - * \brief Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition - (double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theRF, bool theHexMesh, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3) -{ - SetErrorCode(KO); - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_FILLET); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; - - // Check new position - if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { - return NULL; - } - - GEOMImpl_IPipeTShape aData(aFunction); - - aData.SetR1(theR1); - aData.SetW1(theW1); - aData.SetL1(theL1); - aData.SetR2(theR2); - aData.SetW2(theW2); - aData.SetL2(theL2); - aData.SetRF(theRF); - aData.SetHexMesh(theHexMesh); - - bool isTRL = (theRL + theWL + theLtransL + theLthinL) > Precision::Confusion(); - bool isTRR = (theRR + theWR + theLtransR + theLthinR) > Precision::Confusion(); - bool isTRI = (theRI + theWI + theLtransI + theLthinI) > Precision::Confusion(); - - //Compute the resulting value - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("TShape driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // BEGIN of fillet - TopoDS_Shape aShapeShape = aShape->GetValue(); - TopTools_IndexedMapOfShape anEdgesIndices; - TopExp::MapShapes(aShapeShape, anEdgesIndices); - // Common edges on external cylinders - Handle(GEOM_Object) box_e; - if (theHexMesh) { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(theR2+theW2, theR2+theW2, theR1+theW1); - } - else { - box_e = my3DPrimOperations->MakeBoxDXDYDZ(2*(theR2+theW2), 2*(theR2+theW2), theR1+theW1); - } - box_e->GetLastFunction()->SetDescription(""); - box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); - box_e->GetLastFunction()->SetDescription(""); - - Handle(TColStd_HSequenceOfInteger) edges_e = - myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); - box_e->GetLastFunction()->SetDescription(""); - - if (edges_e.IsNull() || edges_e->Length() == 0) { - SetErrorCode("External edges not found"); - return NULL; - } - int nbEdgesInFillet = 0; - std::list theEdges; - for (int i=1; i<=edges_e->Length();i++) { - int edgeID = edges_e->Value(i); - TopoDS_Shape theEdge = anEdgesIndices.FindKey(edgeID); - TopExp_Explorer Ex(theEdge,TopAbs_VERTEX); - while (Ex.More()) { - gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); - if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { - nbEdgesInFillet ++; - theEdges.push_back(edgeID); - } - Ex.Next(); - } - if (theHexMesh && nbEdgesInFillet == 1) - break; - } - - Handle(GEOM_Object) aFillet; - try { - aFillet = myLocalOperations->MakeFilletEdges(aShape, theRF, theEdges); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - if (aFillet.IsNull()) { - SetErrorCode("Fillet can not be computed on the given shape with the given parameters"); - return NULL; - } - aFillet->GetLastFunction()->SetDescription(""); - - TopoDS_Shape aFilletShape = aFillet->GetValue(); - aFunction->SetValue(aFilletShape); - // END of fillet - -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (3) -// the following block, when enabled, leads to partitioning problems -#if 0 -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (3) - // BEGIN: Limit tolerances (debug) - Handle(GEOM_Object) aCorr1 = myHealingOperations->LimitTolerance(aShape, 1e-07); - TopoDS_Shape aCorr1Shape = aCorr1->GetValue(); - aShape->GetLastFunction()->SetValue(aCorr1Shape); - aCorr1->GetLastFunction()->SetDescription(""); - // END: Limit tolerances (debug) -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN (4) -#endif -// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END (4) - - if (theHexMesh) { - if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, 0, 0, theRF, false)) - return NULL; - if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) - return NULL; - } - - // Add thickness reduction elements - // at the three extremities: Left, Right and Incident - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (isTRL || isTRR || isTRI) { - TopoDS_Shape aResShape = - MakePipeTShapeThicknessReduction(aShape->GetValue(), theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - !theHexMesh); - aFunction->SetValue(aResShape); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - // Set Position - gp_Trsf aTrsf = GetPositionTrsf(theL1, theL2, theP1, theP2, theP3); - BRepBuilderAPI_Transform aTransformation (aShape->GetValue(), aTrsf, Standard_False); - TopoDS_Shape aTrsf_Shape = aTransformation.Shape(); - aFunction->SetValue(aTrsf_Shape); - - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - aSeq->Append(aShape); - - try { - if (theHexMesh) { - // Get the groups - if (!MakeGroups(aShape, TSHAPE_FILLET, theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., theRF, aSeq, aTrsf)) - return NULL; - } - - // Get internal group. - if (!MakeInternalGroup(aShape, theR1, theL1, theR2, theL2, theRL, theLtransL, - theRR, theLtransR, theRI, theLtransI, - aSeq, aTrsf)) { - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - TCollection_AsciiString anEntry, aListRes("["); - // Iterate over the sequence aSeq - Standard_Integer aNbGroups = aSeq->Length(); - Standard_Integer i = 1; - for (; i <= aNbGroups; i++) { - Handle(Standard_Transient) anItem = aSeq->Value(i); - if (anItem.IsNull()) continue; - Handle(GEOM_Object) aGroup = Handle(GEOM_Object)::DownCast(anItem); - if (aGroup.IsNull()) continue; - //Make a Python command - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aListRes += anEntry + ", "; - } - aListRes.Trunc(aListRes.Length() - 2); - - GEOM::TPythonDump pd (aFunction); - - pd << aListRes.ToCString() << "] = geompy.MakePipeTShapeFillet(" - << theR1 << ", " << theW1 << ", " << theL1 << ", " - << theR2 << ", " << theW2 << ", " << theL2 << ", " - << theRF << ", " << theHexMesh << ", " - << theP1 << ", " << theP2 << ", " << theP3; - - // thickness reduction - if (isTRL) - pd << ", theRL=" << theRL << ", theWL=" << theWL - << ", theLtransL=" << theLtransL << ", theLthinL=" << theLthinL; - if (isTRR) - pd << ", theRR=" << theRR << ", theWR=" << theWR - << ", theLtransR=" << theLtransR << ", theLthinR=" << theLthinR; - if (isTRI) - pd << ", theRI=" << theRI << ", theWI=" << theWI - << ", theLtransI=" << theLtransI << ", theLthinI=" << theLthinI; - - pd << ")"; - - SetErrorCode(OK); - - return aSeq; -} - -//============================================================================= -/*! - * This function allows to create a disk already divided into blocks. It can be - * used to create divided pipes for later meshing in hexaedra. - * \param theR Radius of the disk - * \param theRatio Relative size of the central square diagonal against the disk diameter - * \param theOrientation Plane on which the disk will be built - * \param thePattern The division pattern of the disk (hexagon or square in the center) - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDisk (double theR, double theRatio, - int theOrientation, int thePattern) -{ - SetErrorCode(KO); - - if (theOrientation != 1 && - theOrientation != 2 && - theOrientation != 3) - { - SetErrorCode("theOrientation must be 1(=OXY), 2(=OYZ) or 3(=OZX)"); - return NULL; - } - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDDISK); - - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_DividedDiskDriver::GetID(), DIVIDEDDISK_R_RATIO); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_DividedDiskDriver::GetID()) return NULL; - - GEOMImpl_IDividedDisk aData (aFunction); - - aData.SetR(theR); - aData.SetRatio(theRatio); - aData.SetOrientation(theOrientation); - aData.SetType(thePattern); - - //Compute the resulting value - try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("DividedDisk driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - std::string aPatternStr; - - switch(thePattern) - { - case 0: - aPatternStr = "GEOM.SQUARE"; - break; - case 1: - aPatternStr = "GEOM.HEXAGON"; - break; - } - - //Make a Python command - GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedDisk(" << theR << ", " << theOrientation << ", " << aPatternStr.c_str() << ")"; - - SetErrorCode(OK); - - return aShape; -} - -//============================================================================= -/*! - * This function allows to create a disk already divided into blocks. It can be - * used to create divided pipes for later meshing in hexaedra. - * \param theR Radius of the disk - * \param theRatio Relative size of the central square diagonal against the disk diameter - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDiskPntVecR (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, - double theRatio, - int thePattern) -{ - SetErrorCode(KO); - - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDDISK); - - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_DividedDiskDriver::GetID(), DIVIDEDDISK_R_VECTOR_PNT); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_DividedDiskDriver::GetID()) return NULL; - - GEOMImpl_IDividedDisk aData (aFunction); - - Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); - Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); - - if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; - - aData.SetCenter(aRefPnt); - aData.SetVector(aRefVec); - - aData.SetR(theR); - aData.SetRatio(theRatio); - aData.SetType(thePattern); - - //Compute the resulting value - try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("DividedDisk driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - std::string aPatternStr; - - switch(thePattern) - { - case 0: - aPatternStr = "GEOM.SQUARE"; - break; - case 1: - aPatternStr = "GEOM.HEXAGON"; - break; - } - - - //Make a Python command - GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedDiskPntVecR(" << thePnt << ", " << theVec << ", " << theR << ", " << aPatternStr.c_str() << ")"; - - SetErrorCode(OK); - - return aShape; -} - -//============================================================================= -/*! - * Builds a cylinder prepared for hexa meshes - * \param theR Radius of the cylinder - * \param theH Height of the cylinder - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedCylinder (double theR, - double theH, - int thePattern) -{ - SetErrorCode(KO); - - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_DIVIDEDCYLINDER); - - Handle(GEOM_Object) aBaseShape = MakeDividedDisk(theR, 67.0, 1, thePattern); - aBaseShape->GetLastFunction()->SetDescription(""); // Erase dump of MakeDividedDisk - - aShape = my3DPrimOperations->MakePrismDXDYDZ(aBaseShape,0.0,0.0,theH, -1.0); - - Handle(GEOM_Function) aFunction = aShape->GetLastFunction(); - aFunction->SetDescription(""); // Erase dump of MakePrismDXDYDZ - aShape->SetType(GEOM_DIVIDEDCYLINDER); - - std::string aPatternStr; - - switch(thePattern) - { - case 0: - aPatternStr = "GEOM.SQUARE"; - break; - case 1: - aPatternStr = "GEOM.HEXAGON"; - break; - } - - //Make a Python command - GEOM::TPythonDump(aFunction) << aShape << " = geompy.MakeDividedCylinder(" << theR << ", " << theH << ", " << aPatternStr.c_str() << ")"; - - SetErrorCode(OK); - - return aShape; -} -//============================================================================= -/*! - * Create a smoothing surface from a set of points - * \param thelPoints list of points or compounds of points - * \param theNbMax maximum number of Bezier pieces in the resulting surface. - * \param theDegMax maximum degree of the resulting BSpline surface - * \param theDMax specifies maximum value of the GeomPlate_PlateG0Criterion criterion. - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::list thelPoints, - int theNbMax, - int theDegMax, - double theDMax) -{ - SetErrorCode(KO); - - //Add a new object - Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_SMOOTHINGSURFACE); - - //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_SmoothingSurfaceDriver::GetID(), SMOOTHINGSURFACE_LPOINTS); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_SmoothingSurfaceDriver::GetID()) return NULL; - - GEOMImpl_ISmoothingSurface aData (aFunction); - - int aLen = thelPoints.size(); - aData.SetLength(aLen); - int ind = 1; - std::list::iterator it = thelPoints.begin(); - for (; it != thelPoints.end(); it++, ind++) { - Handle(GEOM_Function) aRefObj = (*it)->GetLastFunction(); - if (aRefObj.IsNull()) { - SetErrorCode("NULL point or compound for bSplineFaceShape"); - return NULL; - } - aData.SetPntOrComp(ind, aRefObj); - } - - aData.SetNbMax(theNbMax); - aData.SetDegMax(theDegMax); - aData.SetDMax(theDMax); - - //Compute the resulting value - try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("SmoothingSurface driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - GEOM::TPythonDump pd (aFunction); - pd << aShape << " = geompy.MakeSmoothingSurface(["; - it = thelPoints.begin(); - pd << (*it++); - while (it != thelPoints.end()) { - pd << ", " << (*it++); - } - pd << "], " - << theNbMax << ", " - << theDegMax << ", " - << theDMax <<")"; - - SetErrorCode(OK); - - return aShape; -} -/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ diff --git a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.hxx b/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.hxx deleted file mode 100644 index 8f59a9590..000000000 --- a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.hxx +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (C) 2007-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 -// -// File : GEOMImpl_IAdvancedOperations.hxx -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) - -#ifndef _GEOMImpl_IAdvancedOperations_HXX_ -#define _GEOMImpl_IAdvancedOperations_HXX_ - -#include -#include "GEOM_IOperations.hxx" -#include "GEOM_Engine.hxx" -#include "GEOM_Object.hxx" - -#include -#include - -class GEOMImpl_IBasicOperations; -class GEOMImpl_IBooleanOperations; -class GEOMImpl_IShapesOperations; -class GEOMImpl_ITransformOperations; -class GEOMImpl_IBlocksOperations; -class GEOMImpl_I3DPrimOperations; -class GEOMImpl_ILocalOperations; -class GEOMImpl_IHealingOperations; -class GEOMImpl_IGroupOperations; -class Handle_Geom_Surface; -class TopTools_ListOfShape; - -class GEOMImpl_IAdvancedOperations: public GEOM_IOperations { -private: - bool MakePipeTShapePartition(Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theH = 0, double theW = 0, - double theRF = 0, bool isNormal = true); - - bool MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2); - - bool MakePipeTShapeThicknessReduction (Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI); - - bool MakeGroups(Handle(GEOM_Object) theShape, int shapType, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theH, double theW, double theRF, - Handle(TColStd_HSequenceOfTransient) theSeq, - gp_Trsf aTrsf); - - bool GetFacesOnSurf(const TopoDS_Shape &theShape, - const Handle_Geom_Surface& theSurface, - const Standard_Real theTolerance, - TopTools_ListOfShape &theFaces); - - TopoDS_Shape MakeConicalFace(const gp_Ax2 &theAxis, - const double theRadius, - const double theRadiusThin, - const double theHeight, - const gp_Trsf &theTrsf); - - bool MakeInternalGroup(const Handle(GEOM_Object) &theShape, - const double theR1, const double theLen1, - const double theR2, const double theLen2, - const double theRL, const double theTransLenL, - const double theRR, const double theTransLenR, - const double theRI, const double theTransLenI, - const Handle(TColStd_HSequenceOfTransient) &theSeq, - const gp_Trsf &theTrsf); - - gp_Trsf GetPositionTrsf(double theL1, double theL2, - Handle(GEOM_Object) P1 = 0, - Handle(GEOM_Object) P2 = 0, - Handle(GEOM_Object) P3 = 0); - - bool CheckCompatiblePosition(double& theL1, double& theL2, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3, - double theTolerance); - -private: - GEOMImpl_IBasicOperations* myBasicOperations; - GEOMImpl_IBooleanOperations* myBooleanOperations; - GEOMImpl_IShapesOperations* myShapesOperations; - GEOMImpl_ITransformOperations* myTransformOperations; - GEOMImpl_IBlocksOperations* myBlocksOperations; - GEOMImpl_I3DPrimOperations* my3DPrimOperations; - GEOMImpl_ILocalOperations* myLocalOperations; - GEOMImpl_IHealingOperations* myHealingOperations; - GEOMImpl_IGroupOperations* myGroupOperations; - -public: - - /*! - * \brief Add three thickness reductions at the open ends of the pipe T-Shape - * - * \param theShape - the pipe T-Shape - * \param r1 - the internal radius of main pipe - * \param w1 - the thickness of main pipe - * \param l1 - the half-length of main pipe - * \param r2 - the internal radius of incident pipe - * \param w2 - the thickness of incident pipe - * \param l2 - the half-length of main pipe - * \param r*, w*, ltrans* and lthin* - internal radius, thickness, length of transition part - * and length of thin part of left(L), right(R) and - * incident(I) thickness reduction correspondingly - * \param fuseReductions - boolean flag (use true to generate single solid, - * false to obtain parts, useful for hexameshing) - * \retval TopoDS_Shape - Resulting shape - */ - Standard_EXPORT static TopoDS_Shape MakePipeTShapeThicknessReduction - (TopoDS_Shape theShape, - double r1, double w1, double l1, - double r2, double w2, double l2, - double rL, double wL, double ltransL, double lthinL, - double rR, double wR, double ltransR, double lthinR, - double rI, double wI, double ltransI, double lthinI, - bool fuseReductions); - - /*! - * \brief Create one thickness reduction element - * - * This method is called three times from MakePipeTShapeThicknessReduction - * to create three thickness reductions (one per each open end of a pipe T-Shape) - * - * \param theAxes - the position - * \param R - the internal radius of main pipe - * \param W - the thickness of main pipe - * \param Rthin - the internal radius of thin part - * \param Wthin - the thickness of thin part - * \param Ltrans - the length of transition part - * \param Lthin - the length of thin part - * \param fuse - boolean flag (use true to generate single solid, - * false to obtain parts, useful for hexameshing) - * \retval TopoDS_Shape - Resulting shape - */ - Standard_EXPORT static TopoDS_Shape MakeThicknessReduction (gp_Ax2 theAxes, - const double R, const double W, - const double Rthin, const double Wthin, - const double Ltrans, const double Lthin, - bool fuse); - -public: - Standard_EXPORT GEOMImpl_IAdvancedOperations(GEOM_Engine* theEngine, int theDocID); - Standard_EXPORT ~GEOMImpl_IAdvancedOperations(); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShape(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - bool theHexMesh = true); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShapeWithPosition(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - bool theHexMesh = true, - Handle(GEOM_Object) P1 = 0, - Handle(GEOM_Object) P2 = 0, - Handle(GEOM_Object) P3 = 0); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShapeChamfer(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theH, double theW, - bool theHexMesh = true); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShapeChamferWithPosition(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theH, double theW, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - bool theHexMesh = true, - Handle(GEOM_Object) P1 = 0, - Handle(GEOM_Object) P2 = 0, - Handle(GEOM_Object) P3 = 0); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShapeFillet(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theRF, bool theHexMesh = true); - - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) - MakePipeTShapeFilletWithPosition(double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2, - double theRL, double theWL, double theLtransL, double theLthinL, - double theRR, double theWR, double theLtransR, double theLthinR, - double theRI, double theWI, double theLtransI, double theLthinI, - double theRF, bool theHexMesh = true, - Handle(GEOM_Object) P1 = 0, - Handle(GEOM_Object) P2 = 0, - Handle(GEOM_Object) P3 = 0); - - Standard_EXPORT Handle(GEOM_Object) MakeDividedDisk (double theR, double theRatio, - int theOrientation, int thePattern); - Standard_EXPORT Handle(GEOM_Object) MakeDividedDiskPntVecR (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, - double theRatio, - int thePattern); - - Standard_EXPORT Handle(GEOM_Object) MakeDividedCylinder (double theR, - double theH, - int thePattern); - - Standard_EXPORT Handle(GEOM_Object) MakeSmoothingSurface (std::list thelPoints, - int theNbMax, - int theDegMax, - double theDMax); - /*@@ insert new functions before this line @@ do not remove this line @@*/ -}; -#endif diff --git a/src/AdvancedEngine/GEOMImpl_IDividedDisk.hxx b/src/AdvancedEngine/GEOMImpl_IDividedDisk.hxx deleted file mode 100644 index 88a9944d9..000000000 --- a/src/AdvancedEngine/GEOMImpl_IDividedDisk.hxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 _GEOMImpl_IDividedDisk_HXX_ -#define _GEOMImpl_IDividedDisk_HXX_ - -#include "GEOM_Function.hxx" - -#define DIVIDEDDISK_ARG_R 1 -#define DIVIDEDDISK_ARG_RATIO 2 -#define DIVIDEDDISK_ARG_ORIENT 3 - -#define DIVIDEDDISK_ARG_CENTER 4 -#define DIVIDEDDISK_ARG_VECTOR 5 - -#define DIVIDEDDISK_ARG_TYPE 6 - -class GEOMImpl_IDividedDisk -{ -public: - GEOMImpl_IDividedDisk(Handle(GEOM_Function) theFunction): _func(theFunction) {} - - void SetR(double theR) { _func->SetReal(DIVIDEDDISK_ARG_R, theR); } - double GetR() { return _func->GetReal(DIVIDEDDISK_ARG_R); } - - void SetRatio(double theRatio) { _func->SetReal(DIVIDEDDISK_ARG_RATIO, theRatio); } - double GetRatio() { return _func->GetReal(DIVIDEDDISK_ARG_RATIO); } - - void SetOrientation(int theOrientation) { _func->SetInteger(DIVIDEDDISK_ARG_ORIENT, theOrientation); } - int GetOrientation() { return _func->GetInteger(DIVIDEDDISK_ARG_ORIENT); } - - void SetType(int theType) { _func->SetInteger(DIVIDEDDISK_ARG_TYPE, theType); } - int GetType() { return _func->GetInteger(DIVIDEDDISK_ARG_TYPE); } - - void SetCenter(Handle(GEOM_Function) theP) { _func->SetReference(DIVIDEDDISK_ARG_CENTER, theP); } - void SetVector(Handle(GEOM_Function) theV) { _func->SetReference(DIVIDEDDISK_ARG_VECTOR, theV); } - - Handle(GEOM_Function) GetCenter() { return _func->GetReference(DIVIDEDDISK_ARG_CENTER); } - Handle(GEOM_Function) GetVector() { return _func->GetReference(DIVIDEDDISK_ARG_VECTOR); } - -private: - Handle(GEOM_Function) _func; -}; - -#endif // _GEOMImpl_IDividedDisk_HXX_ diff --git a/src/AdvancedEngine/GEOMImpl_IPipeTShape.hxx b/src/AdvancedEngine/GEOMImpl_IPipeTShape.hxx deleted file mode 100644 index 430856921..000000000 --- a/src/AdvancedEngine/GEOMImpl_IPipeTShape.hxx +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2007-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 _GEOMImpl_IPipeTShape_HXX_ -#define _GEOMImpl_IPipeTShape_HXX_ - -#include "GEOM_Function.hxx" - -#include - -class GEOMImpl_IPipeTShape -{ -public: - GEOMImpl_IPipeTShape(Handle(GEOM_Function) theFunction): _func(theFunction) {} - - void SetR1(double theR1) { _func->SetReal(TSHAPE_ARG_R1, theR1); } - double GetR1() { return _func->GetReal(TSHAPE_ARG_R1); } - - void SetW1(double theW1) { _func->SetReal(TSHAPE_ARG_W1, theW1); } - double GetW1() { return _func->GetReal(TSHAPE_ARG_W1); } - - void SetL1(double theL1) { _func->SetReal(TSHAPE_ARG_L1, theL1); } - double GetL1() { return _func->GetReal(TSHAPE_ARG_L1); } - - void SetR2(double theR2) { _func->SetReal(TSHAPE_ARG_R2, theR2); } - double GetR2() { return _func->GetReal(TSHAPE_ARG_R2); } - - void SetW2(double theW2) { _func->SetReal(TSHAPE_ARG_W2, theW2); } - double GetW2() { return _func->GetReal(TSHAPE_ARG_W2); } - - void SetL2(double theL2) { _func->SetReal(TSHAPE_ARG_L2, theL2); } - double GetL2() { return _func->GetReal(TSHAPE_ARG_L2); } - - void SetH(double theH) { _func->SetReal(TSHAPE_ARG_H, theH); } - double GetH() { return _func->GetReal(TSHAPE_ARG_H); } - - void SetW(double theW) { _func->SetReal(TSHAPE_ARG_W, theW); } - double GetW() { return _func->GetReal(TSHAPE_ARG_W); } - - void SetRF(double theRF) { _func->SetReal(TSHAPE_ARG_RF, theRF); } - double GetRF() { return _func->GetReal(TSHAPE_ARG_RF); } - - void SetHexMesh(int theHexMesh) { _func->SetInteger(TSHAPE_ARG_HEXMESH, theHexMesh); } - int GetHexMesh() { return _func->GetInteger(TSHAPE_ARG_HEXMESH); } - - void SetP1(const Handle(GEOM_Function)& theP1){_func->SetReference(TSHAPE_ARG_P1, theP1); } - Handle(GEOM_Function) GetP1() { return _func->GetReference(TSHAPE_ARG_P1); } - - void SetP2(const Handle(GEOM_Function)& theP2){_func->SetReference(TSHAPE_ARG_P2, theP2); } - Handle(GEOM_Function) GetP2() { return _func->GetReference(TSHAPE_ARG_P2); } - - void SetP3(const Handle(GEOM_Function)& theP3){_func->SetReference(TSHAPE_ARG_P3, theP3); } - Handle(GEOM_Function) GetP3() { return _func->GetReference(TSHAPE_ARG_P3); } - -private: - enum { - // main pipe - TSHAPE_ARG_R1 = 1, - TSHAPE_ARG_W1 = 2, - TSHAPE_ARG_L1 = 3, - - // incident pipe - TSHAPE_ARG_R2 = 4, - TSHAPE_ARG_W2 = 5, - TSHAPE_ARG_L2 = 6, - - // chamfer - TSHAPE_ARG_H = 7, - TSHAPE_ARG_W = 8, - - // fillet - TSHAPE_ARG_RF = 9, - - // partition - TSHAPE_ARG_HEXMESH = 10, - - // junction points - TSHAPE_ARG_P1 = 11, - TSHAPE_ARG_P2 = 12, - TSHAPE_ARG_P3 = 13 - }; - -private: - Handle(GEOM_Function) _func; -}; - -#endif // _GEOMImpl_IPipeTShape_HXX_ diff --git a/src/AdvancedEngine/GEOMImpl_ISmoothingSurface.hxx b/src/AdvancedEngine/GEOMImpl_ISmoothingSurface.hxx deleted file mode 100644 index ec3cf1a24..000000000 --- a/src/AdvancedEngine/GEOMImpl_ISmoothingSurface.hxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 _GEOMImpl_ISmoothingSurface_HXX_ -#define _GEOMImpl_ISmoothingSurface_HXX_ - -#include "GEOM_Function.hxx" - -#define SMOOTHINGSURFACE_ARG_LENG 1 -#define SMOOTHINGSURFACE_ARG_LAST 2 -#define SMOOTHINGSURFACE_ARG_NB_MAX 3 -#define SMOOTHINGSURFACE_ARG_DEG_MAX 4 -#define SMOOTHINGSURFACE_ARG_D_MAX 5 - -class GEOMImpl_ISmoothingSurface -{ -public: - GEOMImpl_ISmoothingSurface(Handle(GEOM_Function) theFunction): _func(theFunction) {} - - void SetLength(int theLen) { _func->SetInteger(SMOOTHINGSURFACE_ARG_LENG, theLen); } - int GetLength() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_LENG); } - - void SetPntOrComp(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SMOOTHINGSURFACE_ARG_LAST + theId, theP); } - Handle(GEOM_Function) GetPntOrComp(int theId) { return _func->GetReference(SMOOTHINGSURFACE_ARG_LAST + theId); } - - void SetNbMax(int theNbMax) { _func->SetInteger(SMOOTHINGSURFACE_ARG_NB_MAX, theNbMax); } - int GetNbMax() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_NB_MAX); } - - void SetDegMax(int theDegMax) { _func->SetInteger(SMOOTHINGSURFACE_ARG_DEG_MAX, theDegMax); } - int GetDegMax() { return _func->GetInteger(SMOOTHINGSURFACE_ARG_DEG_MAX); } - - void SetDMax(double theDMax) { _func->SetReal(SMOOTHINGSURFACE_ARG_D_MAX, theDMax); } - double GetDMax() { return _func->GetReal(SMOOTHINGSURFACE_ARG_D_MAX); } - -private: - Handle(GEOM_Function) _func; -}; - -#endif // _GEOMImpl_ISmoothingSurface_HXX_ diff --git a/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.cxx b/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.cxx deleted file mode 100644 index 613806b16..000000000 --- a/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.cxx +++ /dev/null @@ -1,678 +0,0 @@ -// Copyright (C) 2007-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 -// - -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include - -// Partition 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 -#include -#include -#include -#include - -#include -//@@ include required header files here @@// - -#include "AdvancedEngine_Types.hxx" - -//======================================================================= -//function : GetID -//purpose : -//======================================================================= -const Standard_GUID& GEOMImpl_PipeTShapeDriver::GetID() -{ - static Standard_GUID aGUID("1C3A0F3F-729D-4E83-8232-78E74FC5637C"); - return aGUID; -} - -//======================================================================= -//function : GEOMImpl_PipeTShapeDriver -//purpose : -//======================================================================= -GEOMImpl_PipeTShapeDriver::GEOMImpl_PipeTShapeDriver() -{ -} - -//======================================================================= -//function : getShapesOnBoxIDs - /*! - * \brief Find IDs of sub-shapes complying with given status about surface - * \param theBox - the box to check state of sub-shapes against - * \param theShape - the shape to explore - * \param theShapeType - type of sub-shape of theShape - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes - */ -//======================================================================= -Handle(TColStd_HSequenceOfInteger) -GEOMImpl_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox, - const TopoDS_Shape& aShape, - const Standard_Integer theShapeType, - GEOMAlgo_State theState) const -{ - Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; - - // Check presence of triangulation, build if need - if (!GEOMUtils::CheckTriangulation(aShape)) { - StdFail_NotDone::Raise("Cannot build triangulation on the shape"); - return aSeqOfIDs; - } - - // Call algo - GEOMAlgo_FinderShapeOn2 aFinder; - Standard_Real aTol = 0.0001; // default value - - Handle(GEOMAlgo_ClsfBox) aClsfBox = new GEOMAlgo_ClsfBox; - aClsfBox->SetBox(aBox); - - aFinder.SetShape(aShape); - aFinder.SetTolerance(aTol); - aFinder.SetClsf(aClsfBox); - aFinder.SetShapeType( (TopAbs_ShapeEnum)theShapeType ); - aFinder.SetState(theState); - aFinder.Perform(); - - // Interprete results - Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx - if (iErr) { - TCollection_AsciiString aMsg (" iErr : "); - aMsg += TCollection_AsciiString(iErr); - StdFail_NotDone::Raise(aMsg.ToCString()); - return aSeqOfIDs; - } - - - const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result - - if (listSS.Extent() < 1) { - StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017 - return aSeqOfIDs; - } - - // Fill sequence of object IDs - aSeqOfIDs = new TColStd_HSequenceOfInteger; - - TopTools_IndexedMapOfShape anIndices; - TopExp::MapShapes(aShape, anIndices); - - TopTools_ListIteratorOfListOfShape itSub (listSS); - for (int index = 1; itSub.More(); itSub.Next(), ++index) { - int id = anIndices.FindIndex(itSub.Value()); -// std::cerr << "Shape with ID " << id << " found" << std::endl; - aSeqOfIDs->Append(id); - } - - return aSeqOfIDs; -} - -//======================================================================= -//function : GetShapesOnSurfaceIDs - /*! - * \brief Find IDs of sub-shapes complying with given status about surface - * \param theSurface - the surface to check state of sub-shapes against - * \param theShape - the shape to explore - * \param theShapeType - type of sub-shape of theShape - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes - */ -//======================================================================= -Handle(TColStd_HSequenceOfInteger) - GEOMImpl_PipeTShapeDriver::GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, - const TopoDS_Shape& theShape, - TopAbs_ShapeEnum theShapeType, - GEOMAlgo_State theState) const -{ - Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; - - // Check presence of triangulation, build if need - if (!GEOMUtils::CheckTriangulation(theShape)) { - StdFail_NotDone::Raise("Cannot build triangulation on the shape"); - return aSeqOfIDs; - } - - // Call algo - GEOMAlgo_FinderShapeOn1 aFinder; - Standard_Real aTol = 1e-6; - - aFinder.SetShape(theShape); - aFinder.SetTolerance(aTol); - aFinder.SetSurface(theSurface); - aFinder.SetShapeType(theShapeType); - aFinder.SetState(theState); - - // Sets the minimal number of inner points for the faces that do not have own - // inner points at all (for e.g. rectangular planar faces have just 2 triangles). - // Default value=3 - aFinder.SetNbPntsMin(3); - // Sets the maximal number of inner points for edges or faces. - // It is usefull for the cases when this number is very big (e.g =2000) to improve - // the performance. If this value =0, all inner points will be taken into account. - // Default value=0 - aFinder.SetNbPntsMax(0); - - aFinder.Perform(); - - // Interprete results - Standard_Integer iErr = aFinder.ErrorStatus(); - // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx - if (iErr) { -// MESSAGE(" iErr : " << iErr); - TCollection_AsciiString aMsg (" iErr : "); - aMsg += TCollection_AsciiString(iErr); - StdFail_NotDone::Raise(aMsg.ToCString()); - return aSeqOfIDs; - } -// Standard_Integer iWrn = aFinder.WarningStatus(); - // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx -// if (iWrn) { -// MESSAGE(" *** iWrn : " << iWrn); -// } - - const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result - - if (listSS.Extent() < 1) { - //StdFail_NotDone::Raise("Not a single sub-shape of the requested type found on the given surface"); - StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017 - return aSeqOfIDs; - } - - // Fill sequence of object IDs - aSeqOfIDs = new TColStd_HSequenceOfInteger; - - TopTools_IndexedMapOfShape anIndices; - TopExp::MapShapes(theShape, anIndices); - - TopTools_ListIteratorOfListOfShape itSub (listSS); - for (int index = 1; itSub.More(); itSub.Next(), ++index) { - int id = anIndices.FindIndex(itSub.Value()); - aSeqOfIDs->Append(id); - } - - return aSeqOfIDs; -} - -//======================================================================= -//function : GetCommonShapesOnCylinders -//purpose : return the common shapes between 2 cylindrical surfaces -// along OX and OZ -//======================================================================= -void GEOMImpl_PipeTShapeDriver::GetCommonShapesOnCylinders(const TopoDS_Shape& theShape, - TopAbs_ShapeEnum theShapeType, - double r1, - double r2, - Handle(TopTools_HSequenceOfShape)& commonShapes) const -{ - gp_Pnt aP0 (0, 0, 0); - gp_Vec aVX = gp::DX(), aVZ = gp::DZ(); - gp_Ax3 anAxis1 (aP0, aVX, aVZ), anAxis2 (aP0, aVZ, aVX); - - TopTools_IndexedMapOfShape aMapOfShapes; - aMapOfShapes.Clear(); - TopExp::MapShapes(theShape, aMapOfShapes); - - commonShapes->Clear(); - - int myID; - bool found = false; - - // Create a cylinder surface - Handle(Geom_Surface) aC1Ext = new Geom_CylindricalSurface(anAxis1, r1); - if ( aC1Ext.IsNull() ) - StdFail_NotDone::Raise("Couldn't build main cylindrical surface"); - // Find object IDs - Handle(TColStd_HSequenceOfInteger) aSeqExt1 = GetShapesOnSurfaceIDs( aC1Ext, theShape, theShapeType, GEOMAlgo_ST_ON ); - // Create a cylinder surface - Handle(Geom_Surface) aC2Ext = new Geom_CylindricalSurface(anAxis2, r2); - if ( aC2Ext.IsNull() ) - StdFail_NotDone::Raise("Couldn't build incident cylindrical surface"); - // Find object IDs - Handle(TColStd_HSequenceOfInteger) aSeqExt2 = GetShapesOnSurfaceIDs( aC2Ext, theShape, theShapeType, GEOMAlgo_ST_ON ); - // # Recherche (dans le quart de Te) de l'arete d'intersection des 2 cylindres - // # Search in theShape for common shape of type theShapeType on the intersection of 2 pipes - found = false; - for (int i=1; i<=aSeqExt2->Length();i++) { -// std::cerr << "aSeqExt2->Value(i): " << aSeqExt2->Value(i) << std::endl; - for (int j=1; j<=aSeqExt1->Length();j++) { -// std::cerr << "aSeqExt1->Value(j): " << aSeqExt1->Value(j) << std::endl; - if (aSeqExt1->Value(j) == aSeqExt2->Value(i)) { - myID = aSeqExt1->Value(j); - commonShapes->Append(aMapOfShapes.FindKey(myID)); - found = true; - } - } - } - if (!found) - StdFail_NotDone::Raise("Common shapes couldn't be found"); -} - -//======================================================================= -//function : MakePipeTShape -//purpose : -//======================================================================= -TopoDS_Shape GEOMImpl_PipeTShapeDriver::MakePipeTShape (const double r1, const double w1, const double l1, - const double r2, const double w2, const double l2) const -{ - double r1Ext = r1 + w1; - double r2Ext = r2 + w2; - - gp_Pnt aP0 (0, 0, 0); - gp_Pnt aP1 (-l1, 0, 0); - gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ(); - gp_Ax2 anAxes1 (aP1, aVX, aVZ); - gp_Ax2 anAxes2 (aP0, aVZ, aVX); - - // Build the initial pipes - BRepPrimAPI_MakeCylinder C1Int (anAxes1, r1, Abs(2 * l1)); - BRepPrimAPI_MakeCylinder C1Ext (anAxes1, r1Ext, Abs(2 * l1)); - BRepPrimAPI_MakeCylinder C2Int (anAxes2, r2, Abs(l2)); - BRepPrimAPI_MakeCylinder C2Ext (anAxes2, r2Ext, Abs(l2)); - C1Int.Build(); - C1Ext.Build(); - C2Int.Build(); - C2Ext.Build(); - if (!C1Int.IsDone() || !C1Ext.IsDone() || !C2Int.IsDone() || !C2Ext.IsDone()) { - StdFail_NotDone::Raise("Cannot build cylinders"); - } - - // Fuse the 2 pipes - BRepAlgoAPI_Fuse fuse1 (C1Ext.Shape(), C2Ext.Shape()); - if (!fuse1.IsDone()) { - StdFail_NotDone::Raise("Cannot fuse cylinders"); - } - - // Remove small radius main pipe - BRepAlgoAPI_Cut cut1 (fuse1.Shape(), C1Int.Shape()); - if (!cut1.IsDone()) { - StdFail_NotDone::Raise("Coudn't cut cylinders"); - } - - // Remove small radius incident pipe => Te - BRepAlgoAPI_Cut Te (cut1.Shape(), C2Int.Shape()); - if (!Te.IsDone()) { - StdFail_NotDone::Raise("Coudn't cut cylinders"); - } - - return Te.Shape(); -} - -//======================================================================= -//function : MakeQuarterPipeTShape -//purpose : -//======================================================================= -TopoDS_Shape GEOMImpl_PipeTShapeDriver::MakeQuarterPipeTShape (const double r1, const double w1, const double l1, - const double r2, const double w2, const double l2) const -{ - TopoDS_Shape Te = MakePipeTShape(r1, w1, l1, r2, w2, l2); - if (Te.IsNull()) - StdFail_NotDone::Raise("Couldn't build Pipe TShape"); - - // Get a quarter of shape => Te2 - double r1Ext = r1 + w1; - BRepPrimAPI_MakeBox box1 (gp_Pnt(0, -2*r1Ext, -2*r1Ext), gp_Pnt( Abs(2 * l1), 2*r1Ext, Abs(2*l2))); - BRepPrimAPI_MakeBox box2 (gp_Pnt(0, 2*r1Ext, -2*r1Ext), gp_Pnt(-Abs(2 * l1), 0, Abs(2*l2))); - box1.Build(); - box2.Build(); - if (!box1.IsDone() || !box2.IsDone()) { - StdFail_NotDone::Raise("Couldn't build boxes"); - } - BRepAlgoAPI_Cut cut3 (Te, box1.Shape()); - if (!cut3.IsDone()) { - StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box"); - } - BRepAlgoAPI_Cut Te4 (cut3.Shape(), box2.Shape()); - if (!Te4.IsDone()) { - StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box"); - } - - return Te4.Shape(); -} - -//======================================================================= -//function : Execute -//purpose : -//======================================================================= -Standard_Integer GEOMImpl_PipeTShapeDriver::Execute (TFunction_Logbook& log) const -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - - GEOMImpl_IPipeTShape aData (aFunction); - Standard_Integer aType = aFunction->GetType(); - - TopoDS_Shape aShape, Te4, Te4Part; - //TopoDS_Edge arete_intersect_int; - //Handle(TopTools_HSequenceOfShape) edges_e = new TopTools_HSequenceOfShape; - Handle(TColStd_HSequenceOfInteger) edges_e; - //Handle(TopTools_HSequenceOfShape) edges_i = new TopTools_HSequenceOfShape; - //gp_Pnt aP0 (0, 0, 0); - //gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ(); - bool hexMesh = (bool) aData.GetHexMesh(); - - // Useful values - //double aSize = 2*(aData.GetL1() + aData.GetL2()); - double epsilon = Precision::Approximation(); - double aR1Ext = aData.GetR1() + aData.GetW1(); - double aR2Ext = aData.GetR2() + aData.GetW2(); - - if (aData.GetR2() > aData.GetR1() + epsilon) { - StdFail_NotDone::Raise("TShape cannot be computed if R2 > R1"); - } - - if (aR2Ext > aR1Ext + epsilon) { - StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 > R1+W1"); - } - - // external radius are equal - if (fabs(aR2Ext - aR1Ext) < epsilon) { - if (aType == TSHAPE_CHAMFER) - StdFail_NotDone::Raise("TShape with chamfer cannot be computed if R2+W2 = R1+W1"); - if (aType == TSHAPE_FILLET) - StdFail_NotDone::Raise("TShape with fillet cannot be computed if R2+W2 = R1+W1"); - // internal radius are different => not possible - if (fabs(aData.GetR2() - aData.GetR1()) > epsilon) { - StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 = R1+W1 and R2 != R1"); - } - } - - if (aR1Ext >= aData.GetL2() + epsilon) { - StdFail_NotDone::Raise("TShape cannot be computed if R1+W1 >= L2"); - } - if (aR2Ext >= aData.GetL1() + epsilon) { - StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 >= L1"); - } - - if (aType == TSHAPE_CHAMFER) { - if (aData.GetH() >= (aData.GetL2() - aR1Ext + epsilon)) { - StdFail_NotDone::Raise("TShape cannot be computed: height of chamfer is too high"); - } - - if (aData.GetW() >= (aData.GetL1() - aR2Ext + epsilon)) - StdFail_NotDone::Raise("TShape cannot be computed: width of chamfer is too high"); - } - - if (aType == TSHAPE_FILLET) { - if (aData.GetRF() >= (aData.GetL2() - aR1Ext + epsilon) || - aData.GetRF() >= (aData.GetL1() - aR2Ext + epsilon)) - StdFail_NotDone::Raise("TShape cannot be computed: radius of fillet is too high"); - } - - if (hexMesh) { - // Create a quarter of a basic T-Shape pipe - //std::cerr << "Create a quarter of a basic T-Shape pipe" << std::endl; - Te4 = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), - aData.GetR2(), aData.GetW2(), aData.GetL2()); - } - else { - // No need to cut pipe t-shape - //std::cerr << "Create a basic T-Shape pipe" << std::endl; - Te4 = MakePipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), - aData.GetR2(), aData.GetW2(), aData.GetL2()); - } - aShape = Te4; -/* - if (aType == TSHAPE_BASIC) { - aShape = Te4; -// aShape = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(), -// aData.GetR2(), aData.GetW2(), aData.GetL2()); - } - else if (aType == TSHAPE_CHAMFER) { - // TShape with chamfer -// BRep_Builder BB; -// TopoDS_Compound CC; -// BB.MakeCompound(CC); - // Create chamfer on the edges edges_e - BRepFilletAPI_MakeChamfer chamfer (Te4); - TopTools_IndexedMapOfShape anEdgesIndices; - TopExp::MapShapes(Te4, anEdgesIndices); - - TopoDS_Shape theBox; - if (hexMesh) { - BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); - aBox.Build(); - if (!aBox.IsDone()) { - StdFail_NotDone::Raise("Couldn't build box"); - } - theBox = aBox.Shape(); - } - else { - BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); - aBox.Build(); - if (!aBox.IsDone()) { - StdFail_NotDone::Raise("Couldn't build box"); - } - theBox = aBox.Shape(); - } - Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger; - edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN); - if (edges_e.IsNull() || edges_e->Length() == 0) { - StdFail_NotDone::Raise("Common edges not found"); - } - - TopTools_IndexedDataMapOfShapeListOfShape M; - GEOMImpl_Block6Explorer::MapShapesAndAncestors(Te4, TopAbs_EDGE, TopAbs_FACE, M); -// std::cerr << "Number of IDs: " << edges_e->Length() << std::endl; - int nbEdgesInChamfer = 0; - for (int i=1;i<=edges_e->Length();i++) { -// std::cerr << "Get Edge with ID #" << i << std::endl; - int theId = edges_e->Value(i); -// std::cerr << "ID #" << i << "= " << theId << std::endl; -// std::cerr << "Search for edge in shape" << std::endl; - TopoDS_Edge theEdge = TopoDS::Edge(anEdgesIndices.FindKey(theId)); -// std::cerr << "Found" << std::endl; -// std::cerr << "Keep only edges with a vertex on (x, x, re1)" << std::endl; - TopExp_Explorer ExVertices; - for (ExVertices.Init(theEdge,TopAbs_VERTEX); ExVertices.More(); ExVertices.Next()) { - gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(ExVertices.Current())); - if (aPt.Z() - aR1Ext <= epsilon) { -// std::cerr << "aPt.Z() = aR1Ext => keep this edge" << std::endl; - nbEdgesInChamfer ++; - const TopTools_ListOfShape& aFL = M.FindFromKey(theEdge); - TopoDS_Face F = TopoDS::Face( aFL.First() ); - if (hexMesh) - chamfer.Add(aData.GetH(), aData.GetW(), theEdge, F); - else - chamfer.Add(aData.GetW(), aData.GetH(), theEdge, F); - break; - } - } -// std::cerr << "Test if hexMesh: "; - if (hexMesh && nbEdgesInChamfer == 1) { -// std::cerr << "Yes => stop after 1 edge" << std::endl; - break; - } -// std::cerr << "No => continue for other edges" << std::endl; - // BB.Add(CC, edges_e->Value(i)); - // const TopTools_ListOfShape& aFL = M.FindFromKey(TopoDS::Edge(edges_e->Value(i))); - // chamfer.Add(aData.GetW(), aData.GetH(), TopoDS::Edge(edges_e->Value(i)), F); - } -// std::cerr << "Build chamfer with " << nbEdgesInChamfer << " edges" << std::endl; -// } - chamfer.Build(); - if (!chamfer.IsDone()) { - StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters"); - } - -// BB.Add(CC, chamfer.Shape()); - -// aShape = CC; - aShape = chamfer.Shape(); - } - else if (aType == TSHAPE_FILLET) { - // TShape with fillet - // Create fillet on the edge arete_intersect_ext - BRepFilletAPI_MakeFillet fill (Te4); - - TopTools_IndexedMapOfShape anIndices; - TopExp::MapShapes(Te4, anIndices); - - TopoDS_Shape theBox; - if (hexMesh) { - BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); - aBox.Build(); - if (!aBox.IsDone()) { - StdFail_NotDone::Raise("Couldn't build box"); - } - theBox = aBox.Shape(); - } - else { - BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext)); - aBox.Build(); - if (!aBox.IsDone()) { - StdFail_NotDone::Raise("Couldn't build box"); - } - theBox = aBox.Shape(); - } - Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger; - edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN); - if (edges_e.IsNull() || edges_e->Length() == 0) { - StdFail_NotDone::Raise("Common edges not found"); - } - -// fill.Add(TopoDS::Edge(edges_e->Value(1))); -// if (!hexMesh) { - for (int i=1;i<=edges_e->Length();i++) { - if (hexMesh && (i > 1)) - break; - TopoDS_Edge theEdge = TopoDS::Edge(anIndices.FindKey(edges_e->Value(i))); - fill.Add(theEdge); -// fill.Add(TopoDS::Edge(edges_e->Value(i))); - } -// } - fill.SetRadius(aData.GetRF(), 1, 1); - fill.Build(); - if (!fill.IsDone()) { - StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius"); - } - - aShape = fill.Shape(); - } - else { - // other construction modes here - } -*/ - if (aShape.IsNull()) return 0; - - aFunction->SetValue(aShape); - - log.SetTouched(Label()); - - return 1; -} - -//================================================================================ -/*! - * \brief Returns a name of creation operation and names and values of creation parameters - */ -//================================================================================ - -bool GEOMImpl_PipeTShapeDriver:: -GetCreationInformation(std::string& theOperationName, - std::vector& theParams) -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); - - GEOMImpl_IPipeTShape aCI( function ); - Standard_Integer aType = function->GetType(); - - theOperationName = "PIPETSHAPE"; - - switch ( aType ) { - case TSHAPE_BASIC: - AddParam( theParams, "Main radius", aCI.GetR1() ); - AddParam( theParams, "Main width", aCI.GetW1() ); - AddParam( theParams, "Main half-length", aCI.GetL1() ); - AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); - AddParam( theParams, "Incident pipe width", aCI.GetW2() ); - AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); - AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); - break; - case TSHAPE_CHAMFER: - AddParam( theParams, "Main radius", aCI.GetR1() ); - AddParam( theParams, "Main width", aCI.GetW1() ); - AddParam( theParams, "Main half-length", aCI.GetL1() ); - AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); - AddParam( theParams, "Incident pipe width", aCI.GetW2() ); - AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); - AddParam( theParams, "Chamfer height", aCI.GetH() ); - AddParam( theParams, "Chamfer width", aCI.GetW() ); - AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); - break; - case TSHAPE_FILLET: - AddParam( theParams, "Main radius", aCI.GetR1() ); - AddParam( theParams, "Main width", aCI.GetW1() ); - AddParam( theParams, "Main half-length", aCI.GetL1() ); - AddParam( theParams, "Incident pipe radius", aCI.GetR2() ); - AddParam( theParams, "Incident pipe width", aCI.GetW2() ); - AddParam( theParams, "Incident pipe half-length", aCI.GetL2() ); - AddParam( theParams, "Fillet radius", aCI.GetRF() ); - AddParam( theParams, "For hex mesh", aCI.GetHexMesh() ); - break; - default: - return false; - } - - return true; -} - -IMPLEMENT_STANDARD_HANDLE (GEOMImpl_PipeTShapeDriver,GEOM_BaseDriver); -IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_PipeTShapeDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.hxx b/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.hxx deleted file mode 100644 index 3bcdd5574..000000000 --- a/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.hxx +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2007-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 _GEOMImpl_PipeTShapeDriver_HXX -#define _GEOMImpl_PipeTShapeDriver_HXX - -#include - -#include "GEOMAlgo_State.hxx" - -#include -#include -#include -#include -#include -#include - -#include - -class Handle_Standard_Type; -class GEOMImpl_PipeTShapeDriver; - - - -#include "GEOM_BaseDriver.hxx" - -DEFINE_STANDARD_HANDLE( GEOMImpl_PipeTShapeDriver, GEOM_BaseDriver ); - -class GEOMImpl_PipeTShapeDriver : public GEOM_BaseDriver { -public: - // Methods PUBLIC - // - Standard_EXPORT GEOMImpl_PipeTShapeDriver(); - Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; - Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} - Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const - { - return Standard_True; - } - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT ~GEOMImpl_PipeTShapeDriver() {}; - - Standard_EXPORT virtual - bool GetCreationInformation(std::string& theOperationName, - std::vector& params); - // Type management - // -DEFINE_STANDARD_RTTI( GEOMImpl_PipeTShapeDriver ) - -private: - - /*! - * \brief Create a T-Shape based on pipes - * \param r1 - the internal radius of main pipe - * \param w1 - the thickness of main pipe - * \param l1 - the half-length of main pipe - * \param r2 - the internal radius of incident pipe - * \param w2 - the thickness of incident pipe - * \param l2 - the half-length of main pipe - * \retval TopoDS_Shape - Resulting shape - */ - TopoDS_Shape MakePipeTShape(double r1, double w1, double l1, - double r2, double w2, double l2) const; - - /*! - * \brief Create a quarter of a T-Shape based on pipes - * \param r1 - the internal radius of main pipe - * \param w1 - the thickness of main pipe - * \param l1 - the half-length of main pipe - * \param r2 - the internal radius of incident pipe - * \param w2 - the thickness of incident pipe - * \param l2 - the half-length of main pipe - * \retval TopoDS_Shape - Resulting shape - */ - TopoDS_Shape MakeQuarterPipeTShape(double r1, double w1, double l1, - double r2, double w2, double l2) const; - - /*! - * \brief Find IDs of sub-shapes complying with given status about surface - * \param theSurface - the surface to check state of sub-shapes against - * \param theShape - the shape to explore - * \param theShapeType - type of sub-shape of theShape - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes - */ - Handle(TColStd_HSequenceOfInteger) - GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, - const TopoDS_Shape& theShape, - TopAbs_ShapeEnum theShapeType, - GEOMAlgo_State theState) const; - - /*! - * \brief Find IDs of sub-shapes complying with given status about surface - * \param theBox - the box to check state of sub-shapes against - * \param theShape - the shape to explore - * \param theShapeType - type of sub-shape of theShape - * \param theState - required state - * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes - */ - Handle(TColStd_HSequenceOfInteger) - GetShapesOnBoxIDs(const TopoDS_Shape& aBox, - const TopoDS_Shape& aShape, - const Standard_Integer theShapeType, - GEOMAlgo_State theState) const; - - //======================================================================= - //function : getCommonShapesOnCylinders - //purpose : return the common edge between 2 cylindrical surfaces - // along OX and OZ - //======================================================================= - void GetCommonShapesOnCylinders(const TopoDS_Shape& theShape, - TopAbs_ShapeEnum theShapeType, - double r, double r2, - Handle(TopTools_HSequenceOfShape)& commonShapes) const; - -}; - -#endif // _GEOMImpl_PipeTShapeDriver_HXX diff --git a/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.cxx b/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.cxx deleted file mode 100644 index 2b0345522..000000000 --- a/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.cxx +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright (C) 2013-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 -// - -#include - -#include "AdvancedEngine_Types.hxx" - -#include -#include -#include -#include - -#include -#include - -//@@ include required header files here @@// -#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 - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -//======================================================================= -//function : GetID -//purpose : -//======================================================================= -const Standard_GUID& GEOMImpl_SmoothingSurfaceDriver::GetID() -{ - static Standard_GUID aGUID("1C3A0F30-729D-4E83-8232-78E74FC5637C"); - return aGUID; -} - -//======================================================================= -//function : GEOMImpl_SmoothingSurfaceDriver -//purpose : -//======================================================================= -GEOMImpl_SmoothingSurfaceDriver::GEOMImpl_SmoothingSurfaceDriver() -{ -} - -//======================================================================= -//function : MakeSmoothingSurfaceUnClosed -//purpose : -//======================================================================= -TopoDS_Shape GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed - (const Handle_TColgp_HArray1OfPnt &theListOfPoints, - const Standard_Integer theNbMax, - const Standard_Integer theDegMax, - const Standard_Real theDMax) const -{ - TopoDS_Face aInitShape; - - // Create an average Plane - //Handle(TColgp_HArray1OfPnt) HAP = new TColgp_HArray1OfPnt(1,theListOfPoints.Length()) - GeomPlate_BuildAveragePlane gpbap(theListOfPoints,theListOfPoints->Length(),Precision::Confusion(),1,1); - Handle(Geom_Plane) plane(gpbap.Plane()); - Standard_Real Umin, Umax, Vmin, Vmax; - gpbap.MinMaxBox(Umin,Umax,Vmin,Vmax); - // cout << "Vals : " << Umin << ", " << Umax << ", " << Vmin << ", " << Vmax << endl; - BRepBuilderAPI_MakeFace mf(plane,Umin,Umax,Vmin,Vmax,Precision::Confusion()); - aInitShape = mf.Face(); - //return aInitShape; - - GeomPlate_BuildPlateSurface aBuilder(3,10); - // ** Initialization of surface - Handle(BRepAdaptor_HSurface) HSI = new BRepAdaptor_HSurface(); - HSI->ChangeSurface().Initialize(aInitShape); - aBuilder.LoadInitSurface( BRep_Tool::Surface(HSI->ChangeSurface().Face())); - - Standard_Integer j, j1, j2; - // cout << "Init surface" << endl; - j1 = theListOfPoints->Lower(); - j2 = theListOfPoints->Upper(); - for (j=j1; j<=j2 ; j++) - { - gp_Pnt aPnt = theListOfPoints->Value(j); - Handle(GeomPlate_PointConstraint) PCont = new GeomPlate_PointConstraint(aPnt,0); - aBuilder.Add(PCont); - } - // cout << "avant Perform surface" << endl; - aBuilder.Perform(); - // cout << "Perform surface" << endl; - - // A ce niveau : surface algo - Handle(GeomPlate_Surface) gpPlate = aBuilder.Surface(); - - Standard_Integer nbcarreau = (theNbMax > 0 ? theNbMax : 2); - Standard_Integer degmax = (theDegMax > 0 ? theDegMax : 8); - Standard_Real seuil = theDMax; - - if (seuil <= 0.) { - seuil = Max(0.0001,10*aBuilder.G0Error()); - } - - GeomPlate_MakeApprox Mapp(gpPlate,0.0001,nbcarreau,degmax,seuil); - // cout << "Approx surface" << endl; - - Handle (Geom_Surface) Surf (Mapp.Surface()); - - aBuilder.Surface()->Bounds( Umin, Umax, Vmin, Vmax); - - BRepBuilderAPI_MakeFace MF(Surf,Umin, Umax, Vmin, Vmax, Precision::Confusion()); - TopoDS_Shape aShape = MF.Shape(); - - return aShape; -} - - -//======================================================================= -//function : Execute -//purpose : -//======================================================================= -Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log) const -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - if (aFunction.IsNull()) return 0; - - Standard_Integer aType = aFunction->GetType(); - - if (aType != SMOOTHINGSURFACE_LPOINTS) return 0; - // cout << "Youhou : " << aType << endl; - - GEOMImpl_ISmoothingSurface aData (aFunction); - - // Fill the map of vertices. - Standard_Integer aNbShapes = aData.GetLength(); - TopTools_MapOfShape aMapPoints; - Standard_Integer i; - - for (i = 1; i <= aNbShapes; i++) { - Handle(GEOM_Function) aFShape = aData.GetPntOrComp(i); - TopoDS_Shape aShape = aFShape->GetValue(); - - if (aShape.ShapeType() == TopAbs_VERTEX) { - aMapPoints.Add(aShape); - } else { - TopExp_Explorer anExp(aShape, TopAbs_VERTEX); - - for (; anExp.More(); anExp.Next()) { - aMapPoints.Add(anExp.Current()); - } - } - } - - // Add points to the array of points. - const Standard_Integer aNbPoints = aMapPoints.Extent(); - Handle(TColgp_HArray1OfPnt) anArrayofPnt = - new TColgp_HArray1OfPnt(1, aNbPoints); - TopTools_MapIteratorOfMapOfShape anIter(aMapPoints); - - for (i = 1; anIter.More(); anIter.Next(), i++) { - TopoDS_Vertex aPoint = TopoDS::Vertex(anIter.Key()); - gp_Pnt aPnt = BRep_Tool::Pnt(aPoint); - - anArrayofPnt->SetValue(i, aPnt); - } - - const Standard_Integer aNbMax = aData.GetNbMax(); - const Standard_Integer aDegMax = aData.GetDegMax(); - const Standard_Real aDMax = aData.GetDMax(); - - // Make smoothing surface. - TopoDS_Shape aShape = GEOMImpl_SmoothingSurfaceDriver:: - MakeSmoothingSurfaceUnClosed(anArrayofPnt, aNbMax, aDegMax, aDMax); - - if (aShape.IsNull()) return 0; - - aFunction->SetValue(aShape); - - log.SetTouched(Label()); - - return 1; -} - -//================================================================================ -/*! - * \brief Returns a name of creation operation and names and values of creation parameters - */ -//================================================================================ - -bool GEOMImpl_SmoothingSurfaceDriver:: -GetCreationInformation(std::string& theOperationName, - std::vector& theParams) -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); - - GEOMImpl_ISmoothingSurface aCI( function ); - Standard_Integer aType = function->GetType(); - - theOperationName = "SMOOTHINGSURFACE"; - - switch ( aType ) { - case SMOOTHINGSURFACE_LPOINTS: - { - AddParam( theParams, "Points" ); - if ( aCI.GetLength() > 1 ) - theParams[0] << aCI.GetLength() << " points: "; - for ( int i = 1, nb = aCI.GetLength(); i <= nb; ++i ) - theParams[0] << aCI.GetPntOrComp( i ) << " "; - - const Standard_Integer aNbMax = aCI.GetNbMax(); - const Standard_Integer aDegMax = aCI.GetDegMax(); - const Standard_Real aDMax = aCI.GetDMax(); - - AddParam(theParams, "Max nbr of Bezier pieces", aCI.GetNbMax()); - AddParam(theParams, "Max BSpline surface degree", aCI.GetDegMax()); - AddParam(theParams, "3D tolerance of initial approximation", aCI.GetDMax()); - } - break; - default: - return false; - } - - return true; -} - -IMPLEMENT_STANDARD_HANDLE (GEOMImpl_SmoothingSurfaceDriver,GEOM_BaseDriver); -IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_SmoothingSurfaceDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.hxx b/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.hxx deleted file mode 100644 index 6a22f65dc..000000000 --- a/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.hxx +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2013-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 _GEOMImpl_SmoothingSurfaceDriver_HXX -#define _GEOMImpl_SmoothingSurfaceDriver_HXX - -#ifndef _TFunction_Driver_HeaderFile -#include -#endif -#ifndef _TFunction_Logbook_HeaderFile -#include -#endif -#ifndef _Standard_CString_HeaderFile -#include -#endif -#include -#include - -class Handle_Standard_Type; -class GEOMImpl_SmoothingSurfaceDriver; - - - -#include "GEOM_BaseDriver.hxx" - -DEFINE_STANDARD_HANDLE( GEOMImpl_SmoothingSurfaceDriver, GEOM_BaseDriver ); - -class GEOMImpl_SmoothingSurfaceDriver : public GEOM_BaseDriver { -public: - // Methods PUBLIC - // - Standard_EXPORT GEOMImpl_SmoothingSurfaceDriver(); - Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; - Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} - Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const - { - return Standard_True; - } - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT ~GEOMImpl_SmoothingSurfaceDriver() {}; - - Standard_EXPORT virtual - bool GetCreationInformation(std::string& theOperationName, - std::vector& params); - // Type management - // -DEFINE_STANDARD_RTTI( GEOMImpl_SmoothingSurfaceDriver ) - -private: - TopoDS_Shape MakeSmoothingSurfaceUnClosed - (const Handle_TColgp_HArray1OfPnt &theListOfPoints, - const Standard_Integer theNbMax, - const Standard_Integer theDegMax, - const Standard_Real theDMax) const; -}; - -#endif // _GEOMImpl_SmoothingSurfaceDriver_HXX diff --git a/src/AdvancedEngine/GEOM_AdvancedEngine.hxx b/src/AdvancedEngine/GEOM_AdvancedEngine.hxx deleted file mode 100755 index b73287b2b..000000000 --- a/src/AdvancedEngine/GEOM_AdvancedEngine.hxx +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 _GEOM_ADVANCEDENGINE_HXX_ -#define _GEOM_ADVANCEDENGINE_HXX_ - -#ifdef WIN32 - #if defined ADVANCEDENGINE_EXPORTS || defined AdvancedEngine_EXPORTS - #define ADVANCEDENGINE_EXPORT __declspec( dllexport ) - #else - #define ADVANCEDENGINE_EXPORT __declspec( dllimport ) - #endif -#else - #define ADVANCEDENGINE_EXPORT -#endif - -#endif \ No newline at end of file diff --git a/src/AdvancedEngine/GEOM_IAdvancedOperations_i.cc b/src/AdvancedEngine/GEOM_IAdvancedOperations_i.cc deleted file mode 100644 index 7ff12c39d..000000000 --- a/src/AdvancedEngine/GEOM_IAdvancedOperations_i.cc +++ /dev/null @@ -1,792 +0,0 @@ -// Copyright (C) 2007-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 -// - -// File : GEOM_IAdvancedOperations.cc -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) - -#include - -#include "GEOM_IAdvancedOperations_i.hh" - -#include -#include -#include - -#include "GEOM_Engine.hxx" -#include "GEOM_Object.hxx" - -//============================================================================= -/*! - * constructor: - */ -//============================================================================= -GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IAdvancedOperations* theImpl) -:GEOM_IOperations_i(thePOA, theEngine, theImpl) -{ - MESSAGE("GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i"); -} - -//============================================================================= -/*! - * destructor - */ -//============================================================================= -GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i() -{ - MESSAGE("GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i"); -} - -//============================================================================= -/*! - * MakePipeTShape - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShape - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - if (aP1.IsNull() || aP2.IsNull() || aP3.IsNull())return aSeq._retn(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeChamfer - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of chamfer. - * \param theW Width of chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamfer - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theH, theW, theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeChamferWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of the chamfer. - * \param theW Width of the chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamferWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theH, theW, theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeFillet - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFillet - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRF, CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theRF, theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeFilletWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFilletWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRF, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - theRF, theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTR - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTR - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTRWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - if (aP1.IsNull() || aP2.IsNull() || aP3.IsNull()) return aSeq._retn(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTRChamfer - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of chamfer. - * \param theW Width of chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRChamfer - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theH, theW, theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTRChamferWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A chamfer is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theH Height of the chamfer. - * \param theW Width of the chamfer. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRChamferWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theH, theW, theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTRFillet - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * Center of the shape is (0,0,0). The main plane of the T-shape is XOY. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet. - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRFillet - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theRF, CORBA::Boolean theHexMesh) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theRF, theHexMesh); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * MakePipeTShapeTRFilletWithPosition - * Create a T-shape object with specified caracteristics for the main and - * the incident pipes (radius, width, half-length). A fillet is created - * on the junction of the pipes. - * The extremities of the main pipe are located on junctions points P1 and P2. - * The extremity of the incident pipe is located on junction point P3. - * \param theR1 Internal radius of main pipe - * \param theW1 Width of main pipe - * \param theL1 Half-length of main pipe - * \param theR2 Internal radius of incident pipe (R2 < R1) - * \param theW2 Width of incident pipe (R2+W2 < R1+W1) - * \param theL2 Half-length of incident pipe - * \param theRF Radius of curvature of fillet - * \param theHexMesh Boolean indicating if shape is prepared for hex mesh - * \param theP1 1st junction point of main pipe - * \param theP2 2nd junction point of main pipe - * \param theP3 Junction point of incident pipe - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRFilletWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theRF, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference vertices - Handle(GEOM_Object) aP1 = GetObjectImpl(theP1); - Handle(GEOM_Object) aP2 = GetObjectImpl(theP2); - Handle(GEOM_Object) aP3 = GetObjectImpl(theP3); - - //Create the TShape - Handle(TColStd_HSequenceOfTransient) aHSeq = - GetOperations()->MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theRF, theHexMesh, aP1, aP2, aP3); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) - return aSeq._retn(); - - Standard_Integer aLength = aHSeq->Length(); - aSeq->length(aLength); - for (Standard_Integer i = 1; i <= aLength; i++) - aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * This function allows to create a disk already divided into blocks. It can be - * use to create divided pipes for later meshing in hexaedra. - * \param theR Radius of the disk - * \param theRatio Relative size of the central square diagonal against the disk diameter - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedDisk (CORBA::Double theR, - CORBA::Double theRatio, - CORBA::Short theOrientation, - GEOM::pattern thePattern) -{ - GEOM::GEOM_Object_var aGEOMObject; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the DividedDisk - Handle(GEOM_Object) anObject = GetOperations()->MakeDividedDisk(theR, theRatio, theOrientation, thePattern); - if (!GetOperations()->IsDone() || anObject.IsNull()) - return aGEOMObject._retn(); - - return GetObject(anObject); -} - -//============================================================================= -/*! - * MakeDividedDiskPntVecR - */ -//============================================================================= -GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedDiskPntVecR (GEOM::GEOM_Object_ptr thePnt, - GEOM::GEOM_Object_ptr theVec, - CORBA::Double theR, - CORBA::Double theRatio, - GEOM::pattern thePattern) -{ - GEOM::GEOM_Object_var aGEOMObject; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference points - Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt); - Handle(GEOM_Object) aVec = GetObjectImpl(theVec); - - if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); - - // Make DividedDisk - Handle(GEOM_Object) anObject = - GetOperations()->MakeDividedDiskPntVecR(aPnt, aVec, theR, theRatio, thePattern); - if (!GetOperations()->IsDone() || anObject.IsNull()) - return aGEOMObject._retn(); - - return GetObject(anObject); -} - -//============================================================================= -/*! - * Builds a cylinder prepared for hexa meshes - * \param theR Radius of the cylinder - * \param theH Height of the cylinder - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedCylinder (CORBA::Double theR, - CORBA::Double theH, - GEOM::pattern thePattern) -{ - GEOM::GEOM_Object_var aGEOMObject; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Create the DividedCylinder - Handle(GEOM_Object) anObject = GetOperations()->MakeDividedCylinder(theR, theH, thePattern); - if (!GetOperations()->IsDone() || anObject.IsNull()) - return aGEOMObject._retn(); - - return GetObject(anObject); -} - -//============================================================================= -/*! - * - * \param thelPoints list of points - * \param theNbMax maximum number of Bezier pieces in the resulting surface. - * \param theDegMax maximum degree of the resulting BSpline surface - * \param theDMax specifies maximum value of the GeomPlate_PlateG0Criterion criterion. - * \return New GEOM_Object, containing the created shape. - */ -//============================================================================= -GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints, - CORBA::Long theNbMax, - CORBA::Long theDegMax, - CORBA::Double theDMax) -{ - GEOM::GEOM_Object_var aGEOMObject; - - //Set a not done flag - GetOperations()->SetNotDone(); - - //Get the reference point - int ind = 0; - int aLen = thelPoints.length(); - std::list aPoints; - for (; ind < aLen; ind++) { - Handle(GEOM_Object) aPnt = GetObjectImpl(thelPoints[ind]); - if (aPnt.IsNull()) return aGEOMObject._retn(); - aPoints.push_back(aPnt); - } - //Create the SmoothingSurface - Handle(GEOM_Object) anObject = GetOperations()->MakeSmoothingSurface - (aPoints, theNbMax, theDegMax, theDMax); - if (!GetOperations()->IsDone() || anObject.IsNull()) - return aGEOMObject._retn(); - - return GetObject(anObject); -} - -/*@@ insert new functions before this line @@ do not remove this line @@*/ diff --git a/src/AdvancedEngine/GEOM_IAdvancedOperations_i.hh b/src/AdvancedEngine/GEOM_IAdvancedOperations_i.hh deleted file mode 100644 index 7f700132d..000000000 --- a/src/AdvancedEngine/GEOM_IAdvancedOperations_i.hh +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2007-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 -// - -// File : GEOM_IAdvancedOperations.hh -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) - -#ifndef _GEOM_IAdvancedOperations_i_HeaderFile -#define _GEOM_IAdvancedOperations_i_HeaderFile - -#include "GEOMImpl_Gen.hxx" - -#include - -#include CORBA_SERVER_HEADER(GEOM_Gen) -#include "GEOM_IOperations_i.hh" -#include "GEOM_Object_i.hh" -#include "GEOM_AdvancedEngine.hxx" - -#include "GEOMImpl_IAdvancedOperations.hxx" - -class ADVANCEDENGINE_EXPORT GEOM_IAdvancedOperations_i : - public virtual POA_GEOM::GEOM_IAdvancedOperations, - public virtual GEOM_IOperations_i -{ - public: - GEOM_IAdvancedOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_IAdvancedOperations* theImpl); - ~GEOM_IAdvancedOperations_i(); - - // PipeTShape without thickness reduction - GEOM::ListOfGO* MakePipeTShape (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - GEOM::ListOfGO* MakePipeTShapeChamfer (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeChamferWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - GEOM::ListOfGO* MakePipeTShapeFillet (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRF, CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeFilletWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRF, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - - // PipeTShape with thickness reduction - GEOM::ListOfGO* MakePipeTShapeTR - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeTRWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - GEOM::ListOfGO* MakePipeTShapeTRChamfer - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeTRChamferWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - GEOM::ListOfGO* MakePipeTShapeTRFillet - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theRF, CORBA::Boolean theHexMesh); - GEOM::ListOfGO* MakePipeTShapeTRFilletWithPosition - (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, - CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, - CORBA::Double theRL, CORBA::Double theWL, CORBA::Double theLtransL, CORBA::Double theLthinL, - CORBA::Double theRR, CORBA::Double theWR, CORBA::Double theLtransR, CORBA::Double theLthinR, - CORBA::Double theRI, CORBA::Double theWI, CORBA::Double theLtransI, CORBA::Double theLthinI, - CORBA::Double theRF, CORBA::Boolean theHexMesh, - GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3); - - GEOM::GEOM_Object_ptr MakeDividedDisk (CORBA::Double theR, - CORBA::Double theRatio, - CORBA::Short theOrientation, - GEOM::pattern thePattern); - - GEOM::GEOM_Object_ptr MakeDividedDiskPntVecR (GEOM::GEOM_Object_ptr theCenter, - GEOM::GEOM_Object_ptr theVector, - CORBA::Double theR, - CORBA::Double theRatio, - GEOM::pattern thePattern); - - GEOM::GEOM_Object_ptr MakeDividedCylinder (CORBA::Double theR, - CORBA::Double theH, - GEOM::pattern thePattern); - GEOM::GEOM_Object_ptr MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints, - CORBA::Long theNbMax, - CORBA::Long theDegMax, - CORBA::Double theDMax); - /*@@ insert new functions before this line @@ do not remove this line @@*/ - - ::GEOMImpl_IAdvancedOperations* GetOperations() - { return (::GEOMImpl_IAdvancedOperations*)GetImpl(); } -}; - -#endif diff --git a/src/AdvancedGUI/AdvancedGEOM_images.ts b/src/AdvancedGUI/AdvancedGEOM_images.ts new file mode 100644 index 000000000..3dd602c67 --- /dev/null +++ b/src/AdvancedGUI/AdvancedGEOM_images.ts @@ -0,0 +1,177 @@ + + + + + @default + + ICON_OBJBROWSER_ADVANCED_201 + tree_pipetshape.png + + + ICON_OBJBROWSER_ADVANCED_202 + divided_disk.png + + + ICON_OBJBROWSER_ADVANCED_203 + dividedcylinder.png + + + ICON_OBJBROWSER_ADVANCED_204 + tree_smoothingsurface.png + + + + ICON_DLG_PIPETSHAPE + pipetshape.png + + + ICO_PIPETSHAPE + pipetshape.png + + + ICO_PIPETSHAPE_IMPORT + pipetshape_import_icon.png + + + DLG_PIPETSHAPE + dlg_pipetshape.png + + + IMG_PIPETSHAPE_SECT + pipetshape_section.png + + + DLG_PIPETSHAPE_L1 + dlg_pipetshapel1.png + + + DLG_PIPETSHAPE_R1 + dlg_pipetshaper1.png + + + DLG_PIPETSHAPE_W1 + dlg_pipetshapew1.png + + + DLG_PIPETSHAPE_L2 + dlg_pipetshapel2.png + + + DLG_PIPETSHAPE_R2 + dlg_pipetshaper2.png + + + DLG_PIPETSHAPE_W2 + dlg_pipetshapew2.png + + + + DLG_PIPETSHAPE_FILLET + dlg_pipetshapefillet.png + + + DLG_PIPETSHAPE_FILLET_L1 + dlg_pipetshapefilletl1.png + + + DLG_PIPETSHAPE_FILLET_R1 + dlg_pipetshapefilletr1.png + + + DLG_PIPETSHAPE_FILLET_W1 + dlg_pipetshapefilletw1.png + + + DLG_PIPETSHAPE_FILLET_L2 + dlg_pipetshapefilletl2.png + + + DLG_PIPETSHAPE_FILLET_R2 + dlg_pipetshapefilletr2.png + + + DLG_PIPETSHAPE_FILLET_W2 + dlg_pipetshapefilletw2.png + + + DLG_PIPETSHAPE_FILLET_RF + dlg_pipetshapefilletrf.png + + + + DLG_PIPETSHAPE_CHAMFER + dlg_pipetshapechamfer.png + + + DLG_PIPETSHAPE_CHAMFER_L1 + dlg_pipetshapechamferl1.png + + + DLG_PIPETSHAPE_CHAMFER_R1 + dlg_pipetshapechamferr1.png + + + DLG_PIPETSHAPE_CHAMFER_W1 + dlg_pipetshapechamferw1.png + + + DLG_PIPETSHAPE_CHAMFER_L2 + dlg_pipetshapechamferl2.png + + + DLG_PIPETSHAPE_CHAMFER_R2 + dlg_pipetshapechamferr2.png + + + DLG_PIPETSHAPE_CHAMFER_W2 + dlg_pipetshapechamferw2.png + + + DLG_PIPETSHAPE_CHAMFER_H + dlg_pipetshapechamferh.png + + + DLG_PIPETSHAPE_CHAMFER_W + dlg_pipetshapechamferw.png + + + + + + ICON_DLG_DIVIDEDDISK_R_RATIO + divided_disk.png + + + ICO_DIVIDEDDISK + divided_disk.png + + + + ICON_DLG_DIVIDEDCYLINDER_R_H + dividedcylinder_r_h.png + + + ICO_DIVIDEDCYLINDER + dividedcylinder.png + + + + ICON_DLG_SMOOTHINGSURFACE_LPOINTS + smoothingsurface_lpoints.png + + + ICO_SMOOTHINGSURFACE + smoothingsurface.png + + + + diff --git a/src/AdvancedGUI/AdvancedGEOM_msg_en.ts b/src/AdvancedGUI/AdvancedGEOM_msg_en.ts new file mode 100644 index 000000000..06ab04312 --- /dev/null +++ b/src/AdvancedGUI/AdvancedGEOM_msg_en.ts @@ -0,0 +1,313 @@ + + + + + @default + + GEOM_ADVANCED + Advanced shape: type %1 + + + GEOM_ADVANCED_201 + Pipe TShape + + + GEOM_ADVANCED_202 + Divided Disk + + + GEOM_ADVANCED_203 + Divided Cylinder + + + GEOM_DIVIDEDDISK + Divided Disk + + + GEOM_DIVIDEDDISK_TITLE + Divided Disk construction + + + GEOM_DIVIDEDCYLINDER + Divided Cylinder + + + GEOM_DIVIDEDCYLINDER_TITLE + Divided Cylinder construction + + + MEN_DIVIDEDCYLINDER + Divided Cylinder + + + TOP_DIVIDEDCYLINDER + Divided Cylinder + + + STB_DIVIDEDCYLINDER + Divided Cylinder + + + MEN_DIVIDEDDISK + Divided Disk + + + TOP_DIVIDEDDISK + Divided Disk + + + STB_DIVIDEDDISK + Divided Disk + + + TOP_PIPETSHAPE + Create Pipe TShape + + + MEN_PIPETSHAPE + Pipe TShape + + + STB_PIPETSHAPE + Create new Pipe TShape object + + + TOP_SMOOTHINGSURFACE + Smoothing Surface + + + MEN_SMOOTHINGSURFACE + Smoothing Surface + + + STB_SMOOTHINGSURFACE + Smoothing Surface + + + HALF_LENGTH_MAIN_PIPE + Main pipe half length + + + HALF_LENGTH_INCIDENT_PIPE + Incident pipe half length + + + CIRCULAR_QUARTER_PIPE + Circular quarter of pipe + + + THICKNESS + Thickness + + + FLANGE + Flange + + + CHAMFER_OR_FILLET + Chamfer or fillet + + + CHAMFER + Chamfer + + + FILLET + Fillet + + + JUNCTION_FACE_1 + Junction 1 + + + JUNCTION_FACE_2 + Junction 2 + + + JUNCTION_FACE_3 + Junction 3 + + + INTERNAL_FACES + Internal faces + + + + AdvancedGUI_PipeTShapeDlg + + GEOM_PIPE_TSHAPE_TITLE + Pipe TShape Construction + + + GEOM_PIPE_TSHAPE + PipeTShape + + + GEOM_PIPE_TSHAPE_MPIPE + Main pipe + + + GEOM_PIPE_TSHAPE_R + Radius + + + GEOM_PIPE_TSHAPE_W + Width + + + GEOM_PIPE_TSHAPE_L + Half-length + + + GEOM_PIPE_TSHAPE_IPIPE + Incident pipe + + + GEOM_PIPE_TSHAPE_CHAMFER + Chamfer + + + GEOM_PIPE_TSHAPE_CHAMFER_H + Height + + + GEOM_PIPE_TSHAPE_CHAMFER_W + Width + + + GEOM_PIPE_TSHAPE_FILLET + Fillet + + + GEOM_PIPE_TSHAPE_HEX + Prepare for hex mesh + + + GEOM_PIPE_TSHAPE_POSITION + Set position + + + GEOM_PIPE_TSHAPE_POSITION_P1 + Junction P1 + + + GEOM_PIPE_TSHAPE_POSITION_P2 + Junction P2 + + + GEOM_PIPE_TSHAPE_POSITION_P3 + Junction P3 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L1 + New L1 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L2 + New L2 + + + GEOM_PIPE_TSHAPE_LEFT_TR + Left thickness reduction + + + GEOM_PIPE_TSHAPE_RIGHT_TR + Right thickness reduction + + + GEOM_PIPE_TSHAPE_INCI_TR + Incident pipe thickness reduction + + + GEOM_PIPE_TSHAPE_TR_R + Radius (r%1) + + + GEOM_PIPE_TSHAPE_TR_W + Width (w%1) + + + GEOM_PIPE_TSHAPE_TR_L_TRANS + Transition length (ltrans%1) + + + GEOM_PIPE_TSHAPE_TR_L_THIN + Thin part length (lthin%1) + + + GEOM_PIPETSHAPE_GROUPMAIN + Main parameters + + + GEOM_PIPETSHAPE_GROUPREDUCT + Thickness reduction + + + GEOM_PIPETSHAPE_GROUPPOS + Position + + + GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L + The main pipe radius can't be equal to the left thickness reduction radius (rL) + + + GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_L + The main pipe external radius (Radius + Width) can't be equal to the left thickness reduction external radius (rL + wL) + + + GEOM_PIPETSHAPE_ERR_EQUAL_RADII_R + The main pipe radius can't be equal to the right thickness reduction radius (rR) + + + GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_R + The main pipe external radius (Radius + Width) can't be equal to the right thickness reduction external radius (rR + wR) + + + GEOM_PIPETSHAPE_ERR_EQUAL_RADII_I + The incident pipe radius can't be equal to the incident pipe thickness reduction radius (rI) + + + GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_I + The incident pipe external radius (Radius + Width) can't be equal to the incident pipe thickness reduction external radius (rI + wI) + + + + AdvancedGUI_SmoothingSurfaceDlg + + GEOM_SMOOTHINGSURFACE_TITLE + Smoothing surface Construction + + + GEOM_SMOOTHINGSURFACE + Smoothing surface + + + GEOM_SMOOTHINGSURFACE_RESULT + Result name + + + GEOM_SMOOTHINGSURFACE_ARG + Arguments + + + GEOM_SMOOTHINGSURFACE_ARG_POINTS + Points + + + GEOM_SMOOTHINGSURFACE_ARG_NB_MAX + Max nbr of Bezier pieces + + + GEOM_SMOOTHINGSURFACE_ARG_DEG_MAX + Max BSpline surface degree + + + GEOM_SMOOTHINGSURFACE_ARG_D_MAX + 3D tolerance of initial approximation + + + GEOM_SMOOTHINGSURFACE_NO_POINTS + No points selected + + + diff --git a/src/AdvancedGUI/AdvancedGEOM_msg_fr.ts b/src/AdvancedGUI/AdvancedGEOM_msg_fr.ts new file mode 100644 index 000000000..912a3008c --- /dev/null +++ b/src/AdvancedGUI/AdvancedGEOM_msg_fr.ts @@ -0,0 +1,313 @@ + + + + + @default + + GEOM_ADVANCED + Objet géométrique avancé : type %1 + + + GEOM_ADVANCED_201 + Tuyau en T + + + GEOM_ADVANCED_202 + Disque prédécoupé + + + GEOM_ADVANCED_203 + Cylindre prédécoupé + + + GEOM_DIVIDEDDISK + Disque prédécoupé + + + GEOM_DIVIDEDDISK_TITLE + Construction d'un disque prédécoupé + + + GEOM_DIVIDEDCYLINDER + Cylinder prédécoupé + + + GEOM_DIVIDEDCYLINDER_TITLE + Construction d'un cylindre prédécoupé + + + MEN_DIVIDEDCYLINDER + Cylinder prédécoupé + + + TOP_DIVIDEDCYLINDER + Cylinder prédécoupé + + + STB_DIVIDEDCYLINDER + Cylinder prédécoupé + + + MEN_DIVIDEDDISK + Disque prédécoupé + + + TOP_DIVIDEDDISK + Disque prédécoupé + + + STB_DIVIDEDDISK + Disque prédécoupé + + + TOP_PIPETSHAPE + Créer un tuyau en T + + + MEN_PIPETSHAPE + Tuyau en T + + + STB_PIPETSHAPE + Créer un tuyau en T + + + TOP_SMOOTHINGSURFACE + Ajustement de surface + + + MEN_SMOOTHINGSURFACE + Ajustement de surface + + + STB_SMOOTHINGSURFACE + Ajustement de surface + + + HALF_LENGTH_MAIN_PIPE + Demi-longueur du tuyau principal + + + HALF_LENGTH_INCIDENT_PIPE + Demi-longueur du tuyau incident + + + CIRCULAR_QUARTER_PIPE + Un quart circulaire du tuyau + + + THICKNESS + Epaisseur + + + FLANGE + Collerette + + + CHAMFER_OR_FILLET + Chanfrein ou congé + + + CHAMFER + Chanfrein + + + FILLET + Congé + + + JUNCTION_FACE_1 + Jonction 1 + + + JUNCTION_FACE_2 + Jonction 2 + + + JUNCTION_FACE_3 + Jonction 3 + + + INTERNAL_FACES + Faces internes + + + + AdvancedGUI_PipeTShapeDlg + + GEOM_PIPE_TSHAPE_TITLE + Construction d'un tuyau en T + + + GEOM_PIPE_TSHAPE + Tuyau en T + + + GEOM_PIPE_TSHAPE_MPIPE + Tuyau principal + + + GEOM_PIPE_TSHAPE_R + Rayon + + + GEOM_PIPE_TSHAPE_W + Largeur + + + GEOM_PIPE_TSHAPE_L + Demi-longueur + + + GEOM_PIPE_TSHAPE_IPIPE + Tuyau incident + + + GEOM_PIPE_TSHAPE_CHAMFER + Chanfrein + + + GEOM_PIPE_TSHAPE_CHAMFER_H + Hauteur + + + GEOM_PIPE_TSHAPE_CHAMFER_W + Largeur + + + GEOM_PIPE_TSHAPE_FILLET + Congé + + + GEOM_PIPE_TSHAPE_HEX + Préparer pour un maillage hexaédrique + + + GEOM_PIPE_TSHAPE_POSITION + Définir la position + + + GEOM_PIPE_TSHAPE_POSITION_P1 + Jonction P1 + + + GEOM_PIPE_TSHAPE_POSITION_P2 + Jonction P2 + + + GEOM_PIPE_TSHAPE_POSITION_P3 + Jonction P3 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L1 + Nouvelle L1 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L2 + Nouvelle L2 + + + GEOM_PIPE_TSHAPE_LEFT_TR + Réduction d'épaisseur à gauche + + + GEOM_PIPE_TSHAPE_RIGHT_TR + Réduction d'épaisseur à droite + + + GEOM_PIPE_TSHAPE_INCI_TR + Réduction d'épaisseur du tuyau incident + + + GEOM_PIPE_TSHAPE_TR_R + Rayon (r%1) + + + GEOM_PIPE_TSHAPE_TR_W + Epaisseur (w%1) + + + GEOM_PIPE_TSHAPE_TR_L_TRANS + Longueur de transition (ltrans%1) + + + GEOM_PIPE_TSHAPE_TR_L_THIN + Longueur de la partie étroite (lthin%1) + + + GEOM_PIPETSHAPE_GROUPMAIN + Paramètres principaux + + + GEOM_PIPETSHAPE_GROUPREDUCT + Réduction d'épaisseur + + + GEOM_PIPETSHAPE_GROUPPOS + Position + + + GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L + Le rayon du tuyau principal ne peut pas être égal à la réduction d'épaisseur à gauche (rL) + + + GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_L + Le rayon extérieur du tuyau principal (Rayon + épaisseur) ne peut pas être égal au rayon externe de la réduction d'épaisseur à gauche (rL + wL) + + + GEOM_PIPETSHAPE_ERR_EQUAL_RADII_R + Le rayon du tuyau principal ne peut pas être égal au rayon de la réduction d'épaisseur à droite (rR) + + + GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_R + Le rayon extérieur du tuyau principal (Rayon + épaisseur) ne peut pas être égal au rayon externe de la réduction d'épaisseur à droite (rL + wL) + + + GEOM_PIPETSHAPE_ERR_EQUAL_RADII_I + Le rayon du tuyau incident ne peut pas être égal au rayon de la réduction d'épaisseur du tuyau incident (rI) + + + GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_I + Le rayon externe du tuyau incident (Rayon + Epaisseur) ne peut pas être égal au rayon extérieur de la réduction du tuyau incident (rI + wI) + + + + AdvancedGUI_SmoothingSurfaceDlg + + GEOM_SMOOTHINGSURFACE_TITLE + Ajustement de surface sur des points + + + GEOM_SMOOTHINGSURFACE + Ajustement de surface + + + GEOM_SMOOTHINGSURFACE_RESULT + Nom du résultat + + + GEOM_SMOOTHINGSURFACE_ARG + Noeuds + + + GEOM_SMOOTHINGSURFACE_ARG_POINTS + Points + + + GEOM_SMOOTHINGSURFACE_ARG_NB_MAX + Nombre max de patchs Bezier + + + GEOM_SMOOTHINGSURFACE_ARG_DEG_MAX + Degré max de la surface + + + GEOM_SMOOTHINGSURFACE_ARG_D_MAX + Tolerance 3D de l'approximation initiale + + + GEOM_SMOOTHINGSURFACE_NO_POINTS + Aucun point sélectionné + + + diff --git a/src/AdvancedGUI/AdvancedGEOM_msg_ja.ts b/src/AdvancedGUI/AdvancedGEOM_msg_ja.ts new file mode 100644 index 000000000..a5e5e0851 --- /dev/null +++ b/src/AdvancedGUI/AdvancedGEOM_msg_ja.ts @@ -0,0 +1,313 @@ + + + + + @default + + GEOM_ADVANCED + 高度な形状: タイプ %1 + + + GEOM_ADVANCED_201 + T型パイプ + + + GEOM_ADVANCED_202 + カット済みディスク + + + GEOM_ADVANCED_203 + カット シリンダー + + + GEOM_DIVIDEDDISK + Divided_Disk + + + GEOM_DIVIDEDDISK_TITLE + 分割ディスクの構築 + + + GEOM_DIVIDEDCYLINDER + Divided_Cylinder + + + GEOM_DIVIDEDCYLINDER_TITLE + 分割シリンダの構築 + + + MEN_DIVIDEDCYLINDER + 分割シリンダ + + + TOP_DIVIDEDCYLINDER + 分割シリンダ + + + STB_DIVIDEDCYLINDER + 分割シリンダ + + + MEN_DIVIDEDDISK + 分割ディスク + + + TOP_DIVIDEDDISK + 分割ディスク + + + STB_DIVIDEDDISK + 分割ディスク + + + TOP_PIPETSHAPE + T型パイプを作成 + + + MEN_PIPETSHAPE + T型パイプを作成 + + + STB_PIPETSHAPE + T型パイプを作成 + + + TOP_SMOOTHINGSURFACE + 表面のスムージング + + + MEN_SMOOTHINGSURFACE + 表面の平滑化 + + + STB_SMOOTHINGSURFACE + 表面のスムージング + + + HALF_LENGTH_MAIN_PIPE + 半分の長さのパイプを作成 + + + HALF_LENGTH_INCIDENT_PIPE + 入射管長さ半分 + + + CIRCULAR_QUARTER_PIPE + パイプの1/4形状 + + + THICKNESS + 厚み + + + FLANGE + フランジ + + + CHAMFER_OR_FILLET + 面取り 又は フィレット + + + CHAMFER + 面取り + + + FILLET + フィレット + + + JUNCTION_FACE_1 + Junction 1 + + + JUNCTION_FACE_2 + Junction 2 + + + JUNCTION_FACE_3 + Junction 3 + + + INTERNAL_FACES + 内部の顔 + + + + AdvancedGUI_PipeTShapeDlg + + GEOM_PIPE_TSHAPE_TITLE + T型パイプの作成 + + + GEOM_PIPE_TSHAPE + PipeTShape + + + GEOM_PIPE_TSHAPE_MPIPE + メインパイプ + + + GEOM_PIPE_TSHAPE_R + 半径 + + + GEOM_PIPE_TSHAPE_W + 幅 + + + GEOM_PIPE_TSHAPE_L + 半分の長さ + + + GEOM_PIPE_TSHAPE_IPIPE + 付随パイプ + + + GEOM_PIPE_TSHAPE_CHAMFER + 面取り + + + GEOM_PIPE_TSHAPE_CHAMFER_H + 高さ + + + GEOM_PIPE_TSHAPE_CHAMFER_W + 幅 + + + GEOM_PIPE_TSHAPE_FILLET + フィレット + + + GEOM_PIPE_TSHAPE_HEX + 六面体メッシュの準備 + + + GEOM_PIPE_TSHAPE_POSITION + 位置を設定 + + + GEOM_PIPE_TSHAPE_POSITION_P1 + 接続部 P1 + + + GEOM_PIPE_TSHAPE_POSITION_P2 + 接続部 P2 + + + GEOM_PIPE_TSHAPE_POSITION_P3 + 接続部 P3 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L1 + New L1 + + + GEOM_PIPE_TSHAPE_POSITION_LBL_L2 + New L2 + + + GEOM_PIPE_TSHAPE_LEFT_TR + 左側肉厚変更 + + + GEOM_PIPE_TSHAPE_RIGHT_TR + 右側肉厚変更 + + + GEOM_PIPE_TSHAPE_INCI_TR + 付随パイプ肉厚変更 + + + GEOM_PIPE_TSHAPE_TR_R + 半径 (r%1) + + + GEOM_PIPE_TSHAPE_TR_W + 厚み (w%1) + + + GEOM_PIPE_TSHAPE_TR_L_TRANS + 拡張部長さ (ltrans %1) + + + GEOM_PIPE_TSHAPE_TR_L_THIN + 接続部長さ (lthin %1) + + + GEOM_PIPETSHAPE_GROUPMAIN + メインの設定 + + + GEOM_PIPETSHAPE_GROUPREDUCT + 接続部詳細設定 + + + GEOM_PIPETSHAPE_GROUPPOS + 位置による設定 + + + GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L + メインパイプの半径は、左側薄型化(rL)と等しくすることはできません! + + + GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_L + メインパイプの外半径(半径+幅)は、左側薄型化外半径(rL+wL)と等しくすることはできません! + + + GEOM_PIPETSHAPE_ERR_EQUAL_RADII_R + メインパイプの半径は、右側薄型化半径(rR)と同じにすることはできません! + + + GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_R + メインパイプの外半径(半径+幅)は、右側薄型化外半径(rR+wR)と等しくすることはできません! + + + GEOM_PIPETSHAPE_ERR_EQUAL_RADII_I + インシデントパイプの半径は、インシデントパイプ薄肉化半径(rl)と等しくすることはできません! + + + GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_I + インシデントパイプの外半径(半径+厚さ)は、インシデントパイプの薄肉化外半径(rI+wI)と等しくすることはできません! + + + + AdvancedGUI_SmoothingSurfaceDlg + + GEOM_SMOOTHINGSURFACE_TITLE + 滑らかな表面の構造 + + + GEOM_SMOOTHINGSURFACE + 表面 lissee + + + GEOM_SMOOTHINGSURFACE_RESULT + 結果の名前 + + + GEOM_SMOOTHINGSURFACE_ARG + 節点 + + + GEOM_SMOOTHINGSURFACE_ARG_POINTS + ポイント + + + GEOM_SMOOTHINGSURFACE_ARG_NB_MAX + ベジェパッチの最大数 + + + GEOM_SMOOTHINGSURFACE_ARG_DEG_MAX + Bスプライン面の最大自由度 + + + GEOM_SMOOTHINGSURFACE_ARG_D_MAX + 初期近似の3次元公差 + + + GEOM_SMOOTHINGSURFACE_NO_POINTS + 点が選択されていない + + + diff --git a/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx b/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx index 4b1a9f288..721667206 100644 --- a/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx +++ b/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx @@ -216,7 +216,6 @@ void AdvancedGUI_DividedCylinderDlg::ValueChangedInSpinBox() //================================================================================= GEOM::GEOM_IOperations_ptr AdvancedGUI_DividedCylinderDlg::createOperation() { - //return getGeomEngine()->GetIAdvancedOperations(getStudyId()); return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine"); } @@ -243,7 +242,7 @@ bool AdvancedGUI_DividedCylinderDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; - GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation()); + GEOM::IAdvancedOperations_var anOper = GEOM::IAdvancedOperations::_narrow(getOperation()); //@@ retrieve input values from the widgets here @@// CORBA::Double theR = GroupParams->SpinBox_DX->value(); diff --git a/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.h b/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.h index 3fef245e9..bc1760cae 100644 --- a/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.h +++ b/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.h @@ -25,6 +25,9 @@ #include +#include +#include CORBA_SERVER_HEADER(AdvancedGEOM) + class DlgRef_2Spin; class DlgRef_3Radio; diff --git a/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.cxx b/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.cxx index 974a66a89..2b409e91f 100644 --- a/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.cxx +++ b/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.cxx @@ -392,7 +392,6 @@ void AdvancedGUI_DividedDiskDlg::ValueChangedInSpinBox() //================================================================================= GEOM::GEOM_IOperations_ptr AdvancedGUI_DividedDiskDlg::createOperation() { - //return getGeomEngine()->GetIAdvancedOperations(getStudyId()); return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine"); } @@ -419,7 +418,8 @@ bool AdvancedGUI_DividedDiskDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; - GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation()); + GEOM::IAdvancedOperations_var anOper = GEOM::IAdvancedOperations::_narrow(getOperation()); + CORBA::Double theRatio = 67; // About 2/3 CORBA::Double theR = 0; diff --git a/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.h b/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.h index aac6532cb..60ce1fc07 100644 --- a/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.h +++ b/src/AdvancedGUI/AdvancedGUI_DividedDiskDlg.h @@ -25,6 +25,9 @@ #include +#include +#include CORBA_SERVER_HEADER(AdvancedGEOM) + class DlgRef_1Spin; class DlgRef_3Radio; class DlgRef_2Sel1Spin; diff --git a/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx b/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx index 1eac6f55f..ee07a99cd 100644 --- a/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx +++ b/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx @@ -19,6 +19,9 @@ #include "AdvancedGUI_PipeTShapeDlg.h" +#include +#include CORBA_SERVER_HEADER(AdvancedGEOM) + #include #include #include @@ -844,7 +847,6 @@ void AdvancedGUI_PipeTShapeDlg::DisplayPreview (const bool activate, const bool //================================================================================= GEOM::GEOM_IOperations_ptr AdvancedGUI_PipeTShapeDlg::createOperation() { - //return getGeomEngine()->GetIAdvancedOperations(getStudyId()); return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine"); } @@ -1059,7 +1061,7 @@ bool AdvancedGUI_PipeTShapeDlg::executeNoCheck (ObjectList& objects) // GEOM::GEOM_Object_var anObj; GEOM::ListOfGO_var anObj; - GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation()); + GEOM::IAdvancedOperations_var anOper = GEOM::IAdvancedOperations::_narrow(getOperation()); //@@ retrieve input values from the widgets here @@// CORBA::Double theR1 = MainTubeGroupParams->SpinBox_DX->value(); diff --git a/src/AdvancedGUI/AdvancedGUI_SmoothingSurfaceDlg.cxx b/src/AdvancedGUI/AdvancedGUI_SmoothingSurfaceDlg.cxx index 151af6348..89c5f68ce 100644 --- a/src/AdvancedGUI/AdvancedGUI_SmoothingSurfaceDlg.cxx +++ b/src/AdvancedGUI/AdvancedGUI_SmoothingSurfaceDlg.cxx @@ -19,6 +19,9 @@ #include "AdvancedGUI_SmoothingSurfaceDlg.h" +#include +#include CORBA_SERVER_HEADER(AdvancedGEOM) + #include #include #include @@ -187,7 +190,6 @@ void AdvancedGUI_SmoothingSurfaceDlg::enterEvent (QEvent*) //================================================================================= GEOM::GEOM_IOperations_ptr AdvancedGUI_SmoothingSurfaceDlg::createOperation() { - //return getGeomEngine()->GetIAdvancedOperations(getStudyId()); return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine"); } @@ -219,7 +221,7 @@ bool AdvancedGUI_SmoothingSurfaceDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; - GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation()); + GEOM::IAdvancedOperations_var anOper = GEOM::IAdvancedOperations::_narrow(getOperation()); //@@ retrieve input values from the widgets here @@// GEOM::ListOfGO_var points = new GEOM::ListOfGO(); diff --git a/src/AdvancedGUI/AdvancedGUI_images.ts b/src/AdvancedGUI/AdvancedGUI_images.ts deleted file mode 100644 index 3dd602c67..000000000 --- a/src/AdvancedGUI/AdvancedGUI_images.ts +++ /dev/null @@ -1,177 +0,0 @@ - - - - - @default - - ICON_OBJBROWSER_ADVANCED_201 - tree_pipetshape.png - - - ICON_OBJBROWSER_ADVANCED_202 - divided_disk.png - - - ICON_OBJBROWSER_ADVANCED_203 - dividedcylinder.png - - - ICON_OBJBROWSER_ADVANCED_204 - tree_smoothingsurface.png - - - - ICON_DLG_PIPETSHAPE - pipetshape.png - - - ICO_PIPETSHAPE - pipetshape.png - - - ICO_PIPETSHAPE_IMPORT - pipetshape_import_icon.png - - - DLG_PIPETSHAPE - dlg_pipetshape.png - - - IMG_PIPETSHAPE_SECT - pipetshape_section.png - - - DLG_PIPETSHAPE_L1 - dlg_pipetshapel1.png - - - DLG_PIPETSHAPE_R1 - dlg_pipetshaper1.png - - - DLG_PIPETSHAPE_W1 - dlg_pipetshapew1.png - - - DLG_PIPETSHAPE_L2 - dlg_pipetshapel2.png - - - DLG_PIPETSHAPE_R2 - dlg_pipetshaper2.png - - - DLG_PIPETSHAPE_W2 - dlg_pipetshapew2.png - - - - DLG_PIPETSHAPE_FILLET - dlg_pipetshapefillet.png - - - DLG_PIPETSHAPE_FILLET_L1 - dlg_pipetshapefilletl1.png - - - DLG_PIPETSHAPE_FILLET_R1 - dlg_pipetshapefilletr1.png - - - DLG_PIPETSHAPE_FILLET_W1 - dlg_pipetshapefilletw1.png - - - DLG_PIPETSHAPE_FILLET_L2 - dlg_pipetshapefilletl2.png - - - DLG_PIPETSHAPE_FILLET_R2 - dlg_pipetshapefilletr2.png - - - DLG_PIPETSHAPE_FILLET_W2 - dlg_pipetshapefilletw2.png - - - DLG_PIPETSHAPE_FILLET_RF - dlg_pipetshapefilletrf.png - - - - DLG_PIPETSHAPE_CHAMFER - dlg_pipetshapechamfer.png - - - DLG_PIPETSHAPE_CHAMFER_L1 - dlg_pipetshapechamferl1.png - - - DLG_PIPETSHAPE_CHAMFER_R1 - dlg_pipetshapechamferr1.png - - - DLG_PIPETSHAPE_CHAMFER_W1 - dlg_pipetshapechamferw1.png - - - DLG_PIPETSHAPE_CHAMFER_L2 - dlg_pipetshapechamferl2.png - - - DLG_PIPETSHAPE_CHAMFER_R2 - dlg_pipetshapechamferr2.png - - - DLG_PIPETSHAPE_CHAMFER_W2 - dlg_pipetshapechamferw2.png - - - DLG_PIPETSHAPE_CHAMFER_H - dlg_pipetshapechamferh.png - - - DLG_PIPETSHAPE_CHAMFER_W - dlg_pipetshapechamferw.png - - - - - - ICON_DLG_DIVIDEDDISK_R_RATIO - divided_disk.png - - - ICO_DIVIDEDDISK - divided_disk.png - - - - ICON_DLG_DIVIDEDCYLINDER_R_H - dividedcylinder_r_h.png - - - ICO_DIVIDEDCYLINDER - dividedcylinder.png - - - - ICON_DLG_SMOOTHINGSURFACE_LPOINTS - smoothingsurface_lpoints.png - - - ICO_SMOOTHINGSURFACE - smoothingsurface.png - - - - diff --git a/src/AdvancedGUI/AdvancedGUI_msg_en.ts b/src/AdvancedGUI/AdvancedGUI_msg_en.ts deleted file mode 100644 index 06ab04312..000000000 --- a/src/AdvancedGUI/AdvancedGUI_msg_en.ts +++ /dev/null @@ -1,313 +0,0 @@ - - - - - @default - - GEOM_ADVANCED - Advanced shape: type %1 - - - GEOM_ADVANCED_201 - Pipe TShape - - - GEOM_ADVANCED_202 - Divided Disk - - - GEOM_ADVANCED_203 - Divided Cylinder - - - GEOM_DIVIDEDDISK - Divided Disk - - - GEOM_DIVIDEDDISK_TITLE - Divided Disk construction - - - GEOM_DIVIDEDCYLINDER - Divided Cylinder - - - GEOM_DIVIDEDCYLINDER_TITLE - Divided Cylinder construction - - - MEN_DIVIDEDCYLINDER - Divided Cylinder - - - TOP_DIVIDEDCYLINDER - Divided Cylinder - - - STB_DIVIDEDCYLINDER - Divided Cylinder - - - MEN_DIVIDEDDISK - Divided Disk - - - TOP_DIVIDEDDISK - Divided Disk - - - STB_DIVIDEDDISK - Divided Disk - - - TOP_PIPETSHAPE - Create Pipe TShape - - - MEN_PIPETSHAPE - Pipe TShape - - - STB_PIPETSHAPE - Create new Pipe TShape object - - - TOP_SMOOTHINGSURFACE - Smoothing Surface - - - MEN_SMOOTHINGSURFACE - Smoothing Surface - - - STB_SMOOTHINGSURFACE - Smoothing Surface - - - HALF_LENGTH_MAIN_PIPE - Main pipe half length - - - HALF_LENGTH_INCIDENT_PIPE - Incident pipe half length - - - CIRCULAR_QUARTER_PIPE - Circular quarter of pipe - - - THICKNESS - Thickness - - - FLANGE - Flange - - - CHAMFER_OR_FILLET - Chamfer or fillet - - - CHAMFER - Chamfer - - - FILLET - Fillet - - - JUNCTION_FACE_1 - Junction 1 - - - JUNCTION_FACE_2 - Junction 2 - - - JUNCTION_FACE_3 - Junction 3 - - - INTERNAL_FACES - Internal faces - - - - AdvancedGUI_PipeTShapeDlg - - GEOM_PIPE_TSHAPE_TITLE - Pipe TShape Construction - - - GEOM_PIPE_TSHAPE - PipeTShape - - - GEOM_PIPE_TSHAPE_MPIPE - Main pipe - - - GEOM_PIPE_TSHAPE_R - Radius - - - GEOM_PIPE_TSHAPE_W - Width - - - GEOM_PIPE_TSHAPE_L - Half-length - - - GEOM_PIPE_TSHAPE_IPIPE - Incident pipe - - - GEOM_PIPE_TSHAPE_CHAMFER - Chamfer - - - GEOM_PIPE_TSHAPE_CHAMFER_H - Height - - - GEOM_PIPE_TSHAPE_CHAMFER_W - Width - - - GEOM_PIPE_TSHAPE_FILLET - Fillet - - - GEOM_PIPE_TSHAPE_HEX - Prepare for hex mesh - - - GEOM_PIPE_TSHAPE_POSITION - Set position - - - GEOM_PIPE_TSHAPE_POSITION_P1 - Junction P1 - - - GEOM_PIPE_TSHAPE_POSITION_P2 - Junction P2 - - - GEOM_PIPE_TSHAPE_POSITION_P3 - Junction P3 - - - GEOM_PIPE_TSHAPE_POSITION_LBL_L1 - New L1 - - - GEOM_PIPE_TSHAPE_POSITION_LBL_L2 - New L2 - - - GEOM_PIPE_TSHAPE_LEFT_TR - Left thickness reduction - - - GEOM_PIPE_TSHAPE_RIGHT_TR - Right thickness reduction - - - GEOM_PIPE_TSHAPE_INCI_TR - Incident pipe thickness reduction - - - GEOM_PIPE_TSHAPE_TR_R - Radius (r%1) - - - GEOM_PIPE_TSHAPE_TR_W - Width (w%1) - - - GEOM_PIPE_TSHAPE_TR_L_TRANS - Transition length (ltrans%1) - - - GEOM_PIPE_TSHAPE_TR_L_THIN - Thin part length (lthin%1) - - - GEOM_PIPETSHAPE_GROUPMAIN - Main parameters - - - GEOM_PIPETSHAPE_GROUPREDUCT - Thickness reduction - - - GEOM_PIPETSHAPE_GROUPPOS - Position - - - GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L - The main pipe radius can't be equal to the left thickness reduction radius (rL) - - - GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_L - The main pipe external radius (Radius + Width) can't be equal to the left thickness reduction external radius (rL + wL) - - - GEOM_PIPETSHAPE_ERR_EQUAL_RADII_R - The main pipe radius can't be equal to the right thickness reduction radius (rR) - - - GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_R - The main pipe external radius (Radius + Width) can't be equal to the right thickness reduction external radius (rR + wR) - - - GEOM_PIPETSHAPE_ERR_EQUAL_RADII_I - The incident pipe radius can't be equal to the incident pipe thickness reduction radius (rI) - - - GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_I - The incident pipe external radius (Radius + Width) can't be equal to the incident pipe thickness reduction external radius (rI + wI) - - - - AdvancedGUI_SmoothingSurfaceDlg - - GEOM_SMOOTHINGSURFACE_TITLE - Smoothing surface Construction - - - GEOM_SMOOTHINGSURFACE - Smoothing surface - - - GEOM_SMOOTHINGSURFACE_RESULT - Result name - - - GEOM_SMOOTHINGSURFACE_ARG - Arguments - - - GEOM_SMOOTHINGSURFACE_ARG_POINTS - Points - - - GEOM_SMOOTHINGSURFACE_ARG_NB_MAX - Max nbr of Bezier pieces - - - GEOM_SMOOTHINGSURFACE_ARG_DEG_MAX - Max BSpline surface degree - - - GEOM_SMOOTHINGSURFACE_ARG_D_MAX - 3D tolerance of initial approximation - - - GEOM_SMOOTHINGSURFACE_NO_POINTS - No points selected - - - diff --git a/src/AdvancedGUI/AdvancedGUI_msg_fr.ts b/src/AdvancedGUI/AdvancedGUI_msg_fr.ts deleted file mode 100644 index 912a3008c..000000000 --- a/src/AdvancedGUI/AdvancedGUI_msg_fr.ts +++ /dev/null @@ -1,313 +0,0 @@ - - - - - @default - - GEOM_ADVANCED - Objet géométrique avancé : type %1 - - - GEOM_ADVANCED_201 - Tuyau en T - - - GEOM_ADVANCED_202 - Disque prédécoupé - - - GEOM_ADVANCED_203 - Cylindre prédécoupé - - - GEOM_DIVIDEDDISK - Disque prédécoupé - - - GEOM_DIVIDEDDISK_TITLE - Construction d'un disque prédécoupé - - - GEOM_DIVIDEDCYLINDER - Cylinder prédécoupé - - - GEOM_DIVIDEDCYLINDER_TITLE - Construction d'un cylindre prédécoupé - - - MEN_DIVIDEDCYLINDER - Cylinder prédécoupé - - - TOP_DIVIDEDCYLINDER - Cylinder prédécoupé - - - STB_DIVIDEDCYLINDER - Cylinder prédécoupé - - - MEN_DIVIDEDDISK - Disque prédécoupé - - - TOP_DIVIDEDDISK - Disque prédécoupé - - - STB_DIVIDEDDISK - Disque prédécoupé - - - TOP_PIPETSHAPE - Créer un tuyau en T - - - MEN_PIPETSHAPE - Tuyau en T - - - STB_PIPETSHAPE - Créer un tuyau en T - - - TOP_SMOOTHINGSURFACE - Ajustement de surface - - - MEN_SMOOTHINGSURFACE - Ajustement de surface - - - STB_SMOOTHINGSURFACE - Ajustement de surface - - - HALF_LENGTH_MAIN_PIPE - Demi-longueur du tuyau principal - - - HALF_LENGTH_INCIDENT_PIPE - Demi-longueur du tuyau incident - - - CIRCULAR_QUARTER_PIPE - Un quart circulaire du tuyau - - - THICKNESS - Epaisseur - - - FLANGE - Collerette - - - CHAMFER_OR_FILLET - Chanfrein ou congé - - - CHAMFER - Chanfrein - - - FILLET - Congé - - - JUNCTION_FACE_1 - Jonction 1 - - - JUNCTION_FACE_2 - Jonction 2 - - - JUNCTION_FACE_3 - Jonction 3 - - - INTERNAL_FACES - Faces internes - - - - AdvancedGUI_PipeTShapeDlg - - GEOM_PIPE_TSHAPE_TITLE - Construction d'un tuyau en T - - - GEOM_PIPE_TSHAPE - Tuyau en T - - - GEOM_PIPE_TSHAPE_MPIPE - Tuyau principal - - - GEOM_PIPE_TSHAPE_R - Rayon - - - GEOM_PIPE_TSHAPE_W - Largeur - - - GEOM_PIPE_TSHAPE_L - Demi-longueur - - - GEOM_PIPE_TSHAPE_IPIPE - Tuyau incident - - - GEOM_PIPE_TSHAPE_CHAMFER - Chanfrein - - - GEOM_PIPE_TSHAPE_CHAMFER_H - Hauteur - - - GEOM_PIPE_TSHAPE_CHAMFER_W - Largeur - - - GEOM_PIPE_TSHAPE_FILLET - Congé - - - GEOM_PIPE_TSHAPE_HEX - Préparer pour un maillage hexaédrique - - - GEOM_PIPE_TSHAPE_POSITION - Définir la position - - - GEOM_PIPE_TSHAPE_POSITION_P1 - Jonction P1 - - - GEOM_PIPE_TSHAPE_POSITION_P2 - Jonction P2 - - - GEOM_PIPE_TSHAPE_POSITION_P3 - Jonction P3 - - - GEOM_PIPE_TSHAPE_POSITION_LBL_L1 - Nouvelle L1 - - - GEOM_PIPE_TSHAPE_POSITION_LBL_L2 - Nouvelle L2 - - - GEOM_PIPE_TSHAPE_LEFT_TR - Réduction d'épaisseur à gauche - - - GEOM_PIPE_TSHAPE_RIGHT_TR - Réduction d'épaisseur à droite - - - GEOM_PIPE_TSHAPE_INCI_TR - Réduction d'épaisseur du tuyau incident - - - GEOM_PIPE_TSHAPE_TR_R - Rayon (r%1) - - - GEOM_PIPE_TSHAPE_TR_W - Epaisseur (w%1) - - - GEOM_PIPE_TSHAPE_TR_L_TRANS - Longueur de transition (ltrans%1) - - - GEOM_PIPE_TSHAPE_TR_L_THIN - Longueur de la partie étroite (lthin%1) - - - GEOM_PIPETSHAPE_GROUPMAIN - Paramètres principaux - - - GEOM_PIPETSHAPE_GROUPREDUCT - Réduction d'épaisseur - - - GEOM_PIPETSHAPE_GROUPPOS - Position - - - GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L - Le rayon du tuyau principal ne peut pas être égal à la réduction d'épaisseur à gauche (rL) - - - GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_L - Le rayon extérieur du tuyau principal (Rayon + épaisseur) ne peut pas être égal au rayon externe de la réduction d'épaisseur à gauche (rL + wL) - - - GEOM_PIPETSHAPE_ERR_EQUAL_RADII_R - Le rayon du tuyau principal ne peut pas être égal au rayon de la réduction d'épaisseur à droite (rR) - - - GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_R - Le rayon extérieur du tuyau principal (Rayon + épaisseur) ne peut pas être égal au rayon externe de la réduction d'épaisseur à droite (rL + wL) - - - GEOM_PIPETSHAPE_ERR_EQUAL_RADII_I - Le rayon du tuyau incident ne peut pas être égal au rayon de la réduction d'épaisseur du tuyau incident (rI) - - - GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_I - Le rayon externe du tuyau incident (Rayon + Epaisseur) ne peut pas être égal au rayon extérieur de la réduction du tuyau incident (rI + wI) - - - - AdvancedGUI_SmoothingSurfaceDlg - - GEOM_SMOOTHINGSURFACE_TITLE - Ajustement de surface sur des points - - - GEOM_SMOOTHINGSURFACE - Ajustement de surface - - - GEOM_SMOOTHINGSURFACE_RESULT - Nom du résultat - - - GEOM_SMOOTHINGSURFACE_ARG - Noeuds - - - GEOM_SMOOTHINGSURFACE_ARG_POINTS - Points - - - GEOM_SMOOTHINGSURFACE_ARG_NB_MAX - Nombre max de patchs Bezier - - - GEOM_SMOOTHINGSURFACE_ARG_DEG_MAX - Degré max de la surface - - - GEOM_SMOOTHINGSURFACE_ARG_D_MAX - Tolerance 3D de l'approximation initiale - - - GEOM_SMOOTHINGSURFACE_NO_POINTS - Aucun point sélectionné - - - diff --git a/src/AdvancedGUI/AdvancedGUI_msg_ja.ts b/src/AdvancedGUI/AdvancedGUI_msg_ja.ts deleted file mode 100644 index a5e5e0851..000000000 --- a/src/AdvancedGUI/AdvancedGUI_msg_ja.ts +++ /dev/null @@ -1,313 +0,0 @@ - - - - - @default - - GEOM_ADVANCED - 高度な形状: タイプ %1 - - - GEOM_ADVANCED_201 - T型パイプ - - - GEOM_ADVANCED_202 - カット済みディスク - - - GEOM_ADVANCED_203 - カット シリンダー - - - GEOM_DIVIDEDDISK - Divided_Disk - - - GEOM_DIVIDEDDISK_TITLE - 分割ディスクの構築 - - - GEOM_DIVIDEDCYLINDER - Divided_Cylinder - - - GEOM_DIVIDEDCYLINDER_TITLE - 分割シリンダの構築 - - - MEN_DIVIDEDCYLINDER - 分割シリンダ - - - TOP_DIVIDEDCYLINDER - 分割シリンダ - - - STB_DIVIDEDCYLINDER - 分割シリンダ - - - MEN_DIVIDEDDISK - 分割ディスク - - - TOP_DIVIDEDDISK - 分割ディスク - - - STB_DIVIDEDDISK - 分割ディスク - - - TOP_PIPETSHAPE - T型パイプを作成 - - - MEN_PIPETSHAPE - T型パイプを作成 - - - STB_PIPETSHAPE - T型パイプを作成 - - - TOP_SMOOTHINGSURFACE - 表面のスムージング - - - MEN_SMOOTHINGSURFACE - 表面の平滑化 - - - STB_SMOOTHINGSURFACE - 表面のスムージング - - - HALF_LENGTH_MAIN_PIPE - 半分の長さのパイプを作成 - - - HALF_LENGTH_INCIDENT_PIPE - 入射管長さ半分 - - - CIRCULAR_QUARTER_PIPE - パイプの1/4形状 - - - THICKNESS - 厚み - - - FLANGE - フランジ - - - CHAMFER_OR_FILLET - 面取り 又は フィレット - - - CHAMFER - 面取り - - - FILLET - フィレット - - - JUNCTION_FACE_1 - Junction 1 - - - JUNCTION_FACE_2 - Junction 2 - - - JUNCTION_FACE_3 - Junction 3 - - - INTERNAL_FACES - 内部の顔 - - - - AdvancedGUI_PipeTShapeDlg - - GEOM_PIPE_TSHAPE_TITLE - T型パイプの作成 - - - GEOM_PIPE_TSHAPE - PipeTShape - - - GEOM_PIPE_TSHAPE_MPIPE - メインパイプ - - - GEOM_PIPE_TSHAPE_R - 半径 - - - GEOM_PIPE_TSHAPE_W - 幅 - - - GEOM_PIPE_TSHAPE_L - 半分の長さ - - - GEOM_PIPE_TSHAPE_IPIPE - 付随パイプ - - - GEOM_PIPE_TSHAPE_CHAMFER - 面取り - - - GEOM_PIPE_TSHAPE_CHAMFER_H - 高さ - - - GEOM_PIPE_TSHAPE_CHAMFER_W - 幅 - - - GEOM_PIPE_TSHAPE_FILLET - フィレット - - - GEOM_PIPE_TSHAPE_HEX - 六面体メッシュの準備 - - - GEOM_PIPE_TSHAPE_POSITION - 位置を設定 - - - GEOM_PIPE_TSHAPE_POSITION_P1 - 接続部 P1 - - - GEOM_PIPE_TSHAPE_POSITION_P2 - 接続部 P2 - - - GEOM_PIPE_TSHAPE_POSITION_P3 - 接続部 P3 - - - GEOM_PIPE_TSHAPE_POSITION_LBL_L1 - New L1 - - - GEOM_PIPE_TSHAPE_POSITION_LBL_L2 - New L2 - - - GEOM_PIPE_TSHAPE_LEFT_TR - 左側肉厚変更 - - - GEOM_PIPE_TSHAPE_RIGHT_TR - 右側肉厚変更 - - - GEOM_PIPE_TSHAPE_INCI_TR - 付随パイプ肉厚変更 - - - GEOM_PIPE_TSHAPE_TR_R - 半径 (r%1) - - - GEOM_PIPE_TSHAPE_TR_W - 厚み (w%1) - - - GEOM_PIPE_TSHAPE_TR_L_TRANS - 拡張部長さ (ltrans %1) - - - GEOM_PIPE_TSHAPE_TR_L_THIN - 接続部長さ (lthin %1) - - - GEOM_PIPETSHAPE_GROUPMAIN - メインの設定 - - - GEOM_PIPETSHAPE_GROUPREDUCT - 接続部詳細設定 - - - GEOM_PIPETSHAPE_GROUPPOS - 位置による設定 - - - GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L - メインパイプの半径は、左側薄型化(rL)と等しくすることはできません! - - - GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_L - メインパイプの外半径(半径+幅)は、左側薄型化外半径(rL+wL)と等しくすることはできません! - - - GEOM_PIPETSHAPE_ERR_EQUAL_RADII_R - メインパイプの半径は、右側薄型化半径(rR)と同じにすることはできません! - - - GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_R - メインパイプの外半径(半径+幅)は、右側薄型化外半径(rR+wR)と等しくすることはできません! - - - GEOM_PIPETSHAPE_ERR_EQUAL_RADII_I - インシデントパイプの半径は、インシデントパイプ薄肉化半径(rl)と等しくすることはできません! - - - GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_I - インシデントパイプの外半径(半径+厚さ)は、インシデントパイプの薄肉化外半径(rI+wI)と等しくすることはできません! - - - - AdvancedGUI_SmoothingSurfaceDlg - - GEOM_SMOOTHINGSURFACE_TITLE - 滑らかな表面の構造 - - - GEOM_SMOOTHINGSURFACE - 表面 lissee - - - GEOM_SMOOTHINGSURFACE_RESULT - 結果の名前 - - - GEOM_SMOOTHINGSURFACE_ARG - 節点 - - - GEOM_SMOOTHINGSURFACE_ARG_POINTS - ポイント - - - GEOM_SMOOTHINGSURFACE_ARG_NB_MAX - ベジェパッチの最大数 - - - GEOM_SMOOTHINGSURFACE_ARG_DEG_MAX - Bスプライン面の最大自由度 - - - GEOM_SMOOTHINGSURFACE_ARG_D_MAX - 初期近似の3次元公差 - - - GEOM_SMOOTHINGSURFACE_NO_POINTS - 点が選択されていない - - - diff --git a/src/AdvancedGUI/CMakeLists.txt b/src/AdvancedGUI/CMakeLists.txt index 74fe3dc94..1051f2b19 100755 --- a/src/AdvancedGUI/CMakeLists.txt +++ b/src/AdvancedGUI/CMakeLists.txt @@ -38,7 +38,11 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GEOMImpl ${PROJECT_SOURCE_DIR}/src/GEOMGUI ${PROJECT_SOURCE_DIR}/src/GEOMBase + ${PROJECT_SOURCE_DIR}/src/GEOM + ${PROJECT_SOURCE_DIR}/src/GEOMAlgo ${PROJECT_SOURCE_DIR}/src/DlgRef + ${PROJECT_SOURCE_DIR}/src/AdvancedEngine + ${PROJECT_SOURCE_DIR}/src/GEOM_I ${PROJECT_BINARY_DIR}/src/DlgRef ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} @@ -54,6 +58,7 @@ ADD_DEFINITIONS( # libraries to link to SET(_link_LIBRARIES GEOMBase + SalomeIDLAdvancedGEOM ) # --- resources --- @@ -64,10 +69,10 @@ SET(_uic_files # resource files / to be processed by lrelease SET(AdvancedGUI_RESOURCES - AdvancedGUI_images.ts - AdvancedGUI_msg_en.ts - AdvancedGUI_msg_fr.ts - AdvancedGUI_msg_ja.ts + AdvancedGEOM_images.ts + AdvancedGEOM_msg_en.ts + AdvancedGEOM_msg_fr.ts + AdvancedGEOM_msg_ja.ts ) # --- headers --- diff --git a/src/BREPExport/BREPExport.cxx b/src/BREPExport/BREPExport.cxx deleted file mode 100644 index 2d468398a..000000000 --- a/src/BREPExport/BREPExport.cxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// - -// File: BREPExport.cxx -// Created: Wed May 19 13:10:05 2004 -// Author: Pavel TELKOV -// -// -#include "utilities.h" - -#include - -#include -#include - -#ifdef WIN32 - #if defined BREPEXPORT_EXPORTS || defined BREPExport_EXPORTS - #define BREPEXPORT_EXPORT __declspec( dllexport ) - #else - #define BREPEXPORT_EXPORT __declspec( dllimport ) - #endif -#else - #define BREPEXPORT_EXPORT -#endif - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ - BREPEXPORT_EXPORT int Export (const TopoDS_Shape& theShape, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& /*theFormatName*/) - { - MESSAGE("Export BREP into file " << theFileName.ToCString()); - - if ( !BRepTools::Write( theShape, theFileName.ToCString() ) ) - return 0; - - return 1; - } -} diff --git a/src/BREPExport/CMakeLists.txt b/src/BREPExport/CMakeLists.txt deleted file mode 100755 index 2dbaedad8..000000000 --- a/src/BREPExport/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2012-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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIR} - ${KERNEL_INCLUDE_DIRS} - ) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKBRep} - ${KERNEL_SALOMELocalTrace} - ) - -# --- sources --- - -SET(BREPExport_SOURCES - BREPExport.cxx - ) - -# --- rules --- - -ADD_LIBRARY(BREPExport ${BREPExport_SOURCES}) -TARGET_LINK_LIBRARIES(BREPExport ${_link_LIBRARIES}) -INSTALL(TARGETS BREPExport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) - - diff --git a/src/BREPImport/BREPImport.cxx b/src/BREPImport/BREPImport.cxx deleted file mode 100644 index 4d2545167..000000000 --- a/src/BREPImport/BREPImport.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// - -// File: BREPImport.cxx -// Created: Wed May 19 14:29:52 2004 -// Author: Pavel TELKOV -// -// -#include "utilities.h" - -#include -#include - -#include -#include -#include - -#ifdef WIN32 - #if defined BREPIMPORT_EXPORTS || defined BREPImport_EXPORTS - #define BREPIMPORT_EXPORT __declspec( dllexport ) - #else - #define BREPIMPORT_EXPORT __declspec( dllimport ) - #endif -#else - #define BREPIMPORT_EXPORT -#endif - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ -BREPIMPORT_EXPORT - TopoDS_Shape Import (const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& /*theFormatName*/, - TCollection_AsciiString& theError, - const TDF_Label&) - { - MESSAGE("Import BREP from file " << theFileName); - TopoDS_Shape aShape; - BRep_Builder B; - BRepTools::Read(aShape, theFileName.ToCString(), B); - if (aShape.IsNull()) { - theError = "BREP Import failed"; - } - return aShape; - } -} diff --git a/src/BREPImport/CMakeLists.txt b/src/BREPImport/CMakeLists.txt deleted file mode 100755 index 459deb5df..000000000 --- a/src/BREPImport/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2012-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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIR} - ${KERNEL_INCLUDE_DIRS} - ) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKBRep} - ${KERNEL_SALOMELocalTrace} - ) - -# --- sources --- - -SET(BREPImport_SOURCES - BREPImport.cxx - ) - -# --- rules --- - -ADD_LIBRARY(BREPImport ${BREPImport_SOURCES}) -TARGET_LINK_LIBRARIES(BREPImport ${_link_LIBRARIES}) -INSTALL(TARGETS BREPImport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) - - diff --git a/src/BREPPlugin/BREPPlugin_Engine.cxx b/src/BREPPlugin/BREPPlugin_Engine.cxx new file mode 100644 index 000000000..03f57d63a --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_Engine.cxx @@ -0,0 +1,31 @@ +// 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 "BREPPlugin_Engine.hxx" +#include "BREPPlugin_OperationsCreator.hxx" + +extern "C" +{ + BREPPLUGINENGINE_EXPORT + GEOM_GenericOperationsCreator* GetOperationsCreator() + { + return new BREPPlugin_OperationsCreator(); + } +} diff --git a/src/BREPPlugin/BREPPlugin_Engine.hxx b/src/BREPPlugin/BREPPlugin_Engine.hxx new file mode 100755 index 000000000..e37624924 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_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 _BREPPLUGIN_ENGINE_HXX_ +#define _BREPPLUGIN_ENGINE_HXX_ + +#ifdef WIN32 + #if defined BREPPLUGINENGINE_EXPORTS || defined BREPPLUGINENGINE_EXPORTS + #define BREPPLUGINENGINE_EXPORT __declspec( dllexport ) + #else + #define BREPPLUGINENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define BREPPLUGINENGINE_EXPORT +#endif + +#endif diff --git a/src/BREPPlugin/BREPPlugin_ExportDriver.cxx b/src/BREPPlugin/BREPPlugin_ExportDriver.cxx new file mode 100644 index 000000000..2af1fbbef --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_ExportDriver.cxx @@ -0,0 +1,108 @@ +// 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 "BREPPlugin_ExportDriver.hxx" +#include "BREPPlugin_IExport.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOM_Function.hxx" + +// OOCT includes +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& BREPPlugin_ExportDriver::GetID() +{ + static Standard_GUID aGUID("4c1fd92e-bcf3-4695-89b7-a8353038174f"); + return aGUID; +} + +//======================================================================= +//function : BREPPlugin_ExportDriver +//purpose : +//======================================================================= +BREPPlugin_ExportDriver::BREPPlugin_ExportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer BREPPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + BREPPlugin_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 BREP into file " << aFileName.ToCString()); + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + if ( !BRepTools::Write( aShape, aFileName.ToCString() ) ) + return 0; + + return 1; +} + +//======================================================================= +//function : MustExecute +//purpose : +//======================================================================= +Standard_Boolean BREPPlugin_ExportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ +bool BREPPlugin_ExportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + return false; +} + +IMPLEMENT_STANDARD_HANDLE( BREPPlugin_ExportDriver,GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( BREPPlugin_ExportDriver,GEOM_BaseDriver ); diff --git a/src/BREPPlugin/BREPPlugin_ExportDriver.hxx b/src/BREPPlugin/BREPPlugin_ExportDriver.hxx new file mode 100644 index 000000000..fbd7dd8f5 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_ExportDriver.hxx @@ -0,0 +1,51 @@ +// 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 _BREPPlugin_ExportDriver_HXX +#define _BREPPlugin_ExportDriver_HXX + +// internal includes +#include "BREPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( BREPPlugin_ExportDriver, GEOM_BaseDriver ); + +class BREPPLUGINENGINE_EXPORT BREPPlugin_ExportDriver : public GEOM_BaseDriver +{ +public: + BREPPlugin_ExportDriver(); + ~BREPPlugin_ExportDriver() {}; + + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} + + virtual bool GetCreationInformation( std::string& theOperationName, + std::vector& params ); + +DEFINE_STANDARD_RTTI( BREPPlugin_ExportDriver ) +}; + +#endif // _BREPPlugin_ExportDriver_HXX diff --git a/src/BREPPlugin/BREPPlugin_GUI.cxx b/src/BREPPlugin/BREPPlugin_GUI.cxx new file mode 100644 index 000000000..e6430947a --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_GUI.cxx @@ -0,0 +1,266 @@ +// 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 "BREPPlugin_GUI.h" + +// GUI includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// GEOM includes +#include "GeometryGUI.h" +#include "GEOM_Operation.h" +#include "GEOMBase.h" +#include "GEOM_Displayer.h" + +#include +#include CORBA_SERVER_HEADER(BREPPlugin) + +//======================================================================= +// function : BREPPlugin_GUI() +// purpose : Constructor +//======================================================================= +BREPPlugin_GUI::BREPPlugin_GUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) +{ +} + +//======================================================================= +// function : ~BREPPlugin_GUI +// purpose : Destructor +//======================================================================= +BREPPlugin_GUI::~BREPPlugin_GUI() +{ +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool BREPPlugin_GUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) +{ + QString cmd; + switch ( theCommandID ) { + case 1: + cmd = "Export_BREP"; break; + case 2: + cmd = "Import_BREP"; break; + default: + break; + } + return OnGUIEvent( cmd, parent ); +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool BREPPlugin_GUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) +{ + bool result = false; + + if ( theCommandID == "Export_BREP" ) + { + result = exportBREP( parent ); + } + else if ( theCommandID == "Import_BREP" ) + { + result = importBREP( parent ); + } + else + { + getGeometryGUI()->getApp()->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) ); + } + + return result; +} + +//======================================================================= +// function : importBREP +// purpose : +//======================================================================= +bool BREPPlugin_GUI::importBREP( SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); + if ( !study ) return false; + + SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "BREPPluginEngine" ); + GEOM::IBREPOperations_var brepOp = GEOM::IBREPOperations::_narrow( op ); + if ( CORBA::is_nil( brepOp ) ) return false; + + QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), + tr( "BREP_FILES" ), + tr( "IMPORT_TITLE" ), + parent ); + if ( fileNames.count() > 0 ) + { + QStringList entryList; + QStringList errors; + + foreach( QString fileName, fileNames ) + { + SUIT_OverrideCursor wc; + GEOM_Operation transaction( app, brepOp.in() ); + + try + { + app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( fileName ) ); + transaction.start(); + GEOM::ListOfGO_var result = brepOp->ImportBREP( fileName.toUtf8().constData() ); + if ( result->length() > 0 && brepOp->IsDone() ) + { + GEOM::GEOM_Object_var main = result[0]; + QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) ); + SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy, + SALOMEDS::SObject::_nil(), + main.in(), + publishName.toUtf8().constData() ); + + entryList.append( so->GetID() ); + transaction.commit(); + GEOM_Displayer( study ).Display( main.in() ); + } + else + { + transaction.abort(); + errors.append( QString( "%1 : %2" ).arg( fileName ).arg( brepOp->GetErrorCode() ) ); + } + } + catch( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + } + } + getGeometryGUI()->updateObjBrowser( true ); + app->browseObjects( entryList ); + + if ( errors.count() > 0 ) + { + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + } + } + return fileNames.count() > 0; +} + +//======================================================================= +// function : exportBREP +// purpose : +//======================================================================= +bool BREPPlugin_GUI::exportBREP( SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); + if ( !study ) return false; + + SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "BREPPluginEngine" ); + GEOM::IBREPOperations_var brepOp = GEOM::IBREPOperations::_narrow( op ); + if ( CORBA::is_nil( brepOp ) ) return false; + + LightApp_SelectionMgr* sm = app->selectionMgr(); + if ( !sm ) return false; + + SALOME_ListIO selectedObjects; + sm->selectedObjects( selectedObjects ); + bool ok = false; + + SALOME_ListIteratorOfListIO it( selectedObjects ); + for ( ; it.More(); it.Next() ) + { + Handle(SALOME_InteractiveObject) io = it.Value(); + GEOM::GEOM_Object_var obj = GEOMBase::ConvertIOinGEOMObject( io ); + + if ( CORBA::is_nil( obj ) ) continue; + + QString fileName = app->getFileName( false, + QString( io->getName() ), + tr( "BREP_FILES" ), + tr( "EXPORT_TITLE" ), + parent ); + + if ( fileName.isEmpty() ) + return false; + + SUIT_OverrideCursor wc; + + GEOM_Operation transaction( app, brepOp.in() ); + + try + { + app->putInfo( tr( "GEOM_PRP_EXPORT" ).arg( fileName ) ); + transaction.start(); + + brepOp->ExportBREP( obj, fileName.toUtf8().constData() ); + + if ( brepOp->IsDone() ) + { + transaction.commit(); + } + else + { + transaction.abort(); + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_PRP_ABORT" ) + "\n" + tr( brepOp->GetErrorCode() ) ); + return false; + } + } + catch ( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + return false; + } + ok = true; + } + + if ( !ok ) + { + SUIT_MessageBox::warning( parent, + tr( "WRN_WARNING" ), + tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) ); + } + return ok; +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ +#ifdef WIN32 + __declspec( dllexport ) +#endif + GEOMGUI* GetLibGUI( GeometryGUI* parent ) + { + return new BREPPlugin_GUI( parent ); + } +} diff --git a/src/BREPPlugin/BREPPlugin_GUI.h b/src/BREPPlugin/BREPPlugin_GUI.h new file mode 100644 index 000000000..89ec7ebc2 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_GUI.h @@ -0,0 +1,40 @@ +// 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 BREPPlugin_GUI_H +#define BREPPlugin_GUI_H + +#include "GEOMPluginGUI.h" + +class BREPPlugin_GUI: public GEOMPluginGUI +{ + Q_OBJECT +public: + BREPPlugin_GUI( GeometryGUI* parent ); + ~BREPPlugin_GUI(); + + bool OnGUIEvent( int commandId, SUIT_Desktop* ); + bool OnGUIEvent( const QString&, SUIT_Desktop* ); + +private: + bool importBREP( SUIT_Desktop* ); + bool exportBREP( SUIT_Desktop* ); +}; + +#endif // BREPPlugin_GUI_H diff --git a/src/BREPPlugin/BREPPlugin_IECallBack.cxx b/src/BREPPlugin/BREPPlugin_IECallBack.cxx new file mode 100755 index 000000000..83e1cbbb8 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_IECallBack.cxx @@ -0,0 +1,72 @@ +// 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 "BREPPlugin_IECallBack.hxx" +#include "BREPPlugin_IOperations.hxx" +#include "BREPPlugin_OperationsCreator.hxx" + +//============================================================================= +/*! + * constructor + */ +//============================================================================= +BREPPlugin_IECallBack::BREPPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +BREPPlugin_IECallBack::~BREPPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * Export + */ +//============================================================================= +bool +BREPPlugin_IECallBack::Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ) +{ + BREPPlugin_IOperations* aPluginOperations = BREPPlugin_OperationsCreator::get( GetEngine(), theDocId ); + aPluginOperations->ExportBREP( theOriginal, theFileName ); + return true; +} + +//============================================================================= +/*! + * Import + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +BREPPlugin_IECallBack::Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ) +{ + BREPPlugin_IOperations* aPluginOperations = BREPPlugin_OperationsCreator::get( GetEngine(), theDocId ); + return aPluginOperations->ImportBREP( theFileName ); +} + diff --git a/src/BREPPlugin/BREPPlugin_IECallBack.hxx b/src/BREPPlugin/BREPPlugin_IECallBack.hxx new file mode 100644 index 000000000..dfa66b06b --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_IECallBack.hxx @@ -0,0 +1,49 @@ +// 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 _BREPPlugin_IECallBack_HXX_ +#define _BREPPlugin_IECallBack_HXX_ + +// internal includes +#include "BREPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Object.hxx" +#include "GEOMImpl_IECallBack.hxx" + +// OCC includes +#include + +class BREPPLUGINENGINE_EXPORT BREPPlugin_IECallBack : public GEOMImpl_IECallBack +{ +public: + BREPPlugin_IECallBack(); + ~BREPPlugin_IECallBack(); + + bool Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ); + + Handle(TColStd_HSequenceOfTransient) Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ); +}; + +#endif diff --git a/src/BREPPlugin/BREPPlugin_IExport.hxx b/src/BREPPlugin/BREPPlugin_IExport.hxx new file mode 100644 index 000000000..28b00e780 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_IExport.hxx @@ -0,0 +1,48 @@ +// 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 _BREPPlugin_IExport_HXX_ +#define _BREPPlugin_IExport_HXX_ + +#include "GEOM_Function.hxx" + +#define EXPORTBREP_ARG_ORIGINAL 1 +#define EXPORTBREP_ARG_FILENAME 2 + +class BREPPlugin_IExport +{ +public: + BREPPlugin_IExport( Handle(GEOM_Function) theFunction ) + : _func(theFunction) {} + + void SetOriginal( Handle( GEOM_Function ) theOriginal) + { _func->SetReference( EXPORTBREP_ARG_ORIGINAL, theOriginal ); } + Handle( GEOM_Function ) GetOriginal() + { return _func->GetReference( EXPORTBREP_ARG_ORIGINAL ); } + + void SetFileName( const TCollection_AsciiString& theFileName ) + { _func->SetString( EXPORTBREP_ARG_FILENAME, theFileName ); } + TCollection_AsciiString GetFileName() + { return _func->GetString( EXPORTBREP_ARG_FILENAME ); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _BREPPlugin_IExport_HXX_ diff --git a/src/BREPPlugin/BREPPlugin_IImport.hxx b/src/BREPPlugin/BREPPlugin_IImport.hxx new file mode 100644 index 000000000..1eac3d403 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_IImport.hxx @@ -0,0 +1,42 @@ +// 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 _BREPPlugin_IImport_HXX_ +#define _BREPPlugin_IImport_HXX_ + +#include "GEOM_Function.hxx" + +#define IMPORTBREP_ARG_FILENAME 1 + +class BREPPlugin_IImport +{ +public: + BREPPlugin_IImport( Handle(GEOM_Function) theFunction) + : _func(theFunction) {} + + void SetFileName( const TCollection_AsciiString& theFileName ) + { _func->SetString( IMPORTBREP_ARG_FILENAME, theFileName ); } + TCollection_AsciiString GetFileName() + { return _func->GetString( IMPORTBREP_ARG_FILENAME ); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _BREPPlugin_IImport_HXX_ diff --git a/src/BREPPlugin/BREPPlugin_IOperations.cxx b/src/BREPPlugin/BREPPlugin_IOperations.cxx new file mode 100644 index 000000000..dc90c9990 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_IOperations.cxx @@ -0,0 +1,171 @@ +// 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 "BREPPlugin_IOperations.hxx" +#include "BREPPlugin_ExportDriver.hxx" +#include "BREPPlugin_ImportDriver.hxx" +#include "BREPPlugin_IExport.hxx" +#include "BREPPlugin_IImport.hxx" + +// KERNEL includes +#include + +// GEOM includes +#include "GEOM_PythonDump.hxx" +#include "GEOMImpl_Types.hxx" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +BREPPlugin_IOperations::BREPPlugin_IOperations( GEOM_Engine* theEngine, int theDocID ) +: GEOMImpl_IBaseIEOperations( theEngine, theDocID ) +{ + MESSAGE( "BREPPlugin_IOperations::BREPPlugin_IOperations" ); +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +BREPPlugin_IOperations::~BREPPlugin_IOperations() +{ + MESSAGE( "BREPPlugin_IOperations::~BREPPlugin_IOperations" ); +} + +//============================================================================= +/*! + * ExportBREP + * Export a shape to BREP format + * \param theOriginal The shape to export + * \param theFileName The name of the file to exported + * \param theIsASCII The format of the exported file (ASCII or Binary) + * \param theDeflection The deflection of the shape to exported + */ +//============================================================================= +void BREPPlugin_IOperations::ExportBREP( const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName ) +{ + SetErrorCode(KO); + if( theOriginal.IsNull() ) return; + + Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction(); + if( aRefFunction.IsNull() ) return; //There is no function which creates an object to be exported + + //Add a new result object + Handle(GEOM_Object) result = GetEngine()->AddObject( GetDocID(), GEOM_IMPORT); + + //Add an Export function + Handle(GEOM_Function) aFunction = result->AddFunction( BREPPlugin_ExportDriver::GetID(), EXPORT_SHAPE ); + if( aFunction.IsNull() ) return; + + //Check if the function is set correctly + if( aFunction->GetDriverGUID() != BREPPlugin_ExportDriver::GetID() ) return; + + //Set parameters + BREPPlugin_IExport aCI( aFunction ); + aCI.SetOriginal( aRefFunction ); + aCI.SetFileName( theFileName ); + + //Perform the Export + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if( !GetSolver()->ComputeFunction( aFunction ) ) { + SetErrorCode( "Not enough space on disk, or you haven't permissions to write this directory" ); + return; + } + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode( aFail->GetMessageString() ); + return; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << "geompy.ExportBREP(" << theOriginal << ", \"" + << theFileName.ToCString() << "\" )"; + + SetErrorCode(OK); +} + +//============================================================================= +/*! + * ImportBREP + * Import a shape from BREP format + * \param theFileName The name of the file to import + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +BREPPlugin_IOperations::ImportBREP( const TCollection_AsciiString& theFileName ) +{ + SetErrorCode(KO); + if( theFileName.IsEmpty() ) return NULL; + + //Add a new result object + Handle(GEOM_Object) anImported = GetEngine()->AddObject( GetDocID(), GEOM_IMPORT ); + + //Add an Import function + Handle(GEOM_Function) aFunction = + anImported->AddFunction( BREPPlugin_ImportDriver::GetID(), IMPORT_SHAPE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != BREPPlugin_ImportDriver::GetID()) return NULL; + + //Set parameters + BREPPlugin_IImport aCI( aFunction ); + aCI.SetFileName( theFileName ); + + //Perform the Import + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if( !GetSolver()->ComputeFunction( aFunction ) ) { + SetErrorCode( "Import driver failed" ); + return NULL; + } + aSeq->Append(anImported); + + // Greate material groups. + // MakeMaterialGroups( anImported, aSeq ); + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode( aFail->GetMessageString() ); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump pd (aFunction); + pd << aSeq << " = geompy.ImportBREP(\"" << theFileName.ToCString() << "\" )"; + SetErrorCode(OK); + + return aSeq; +} diff --git a/src/BREPPlugin/BREPPlugin_IOperations.hxx b/src/BREPPlugin/BREPPlugin_IOperations.hxx new file mode 100644 index 000000000..b5950e7cd --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_IOperations.hxx @@ -0,0 +1,42 @@ +// 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 +// +// File : BREPPlugin_IOperations.hxx + +#ifndef _BREPPlugin_IOperations_HXX_ +#define _BREPPlugin_IOperations_HXX_ + +// internal includes +#include "BREPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOMImpl_IBaseIEOperations.hxx" + +class BREPPLUGINENGINE_EXPORT BREPPlugin_IOperations: public GEOMImpl_IBaseIEOperations +{ +public: + BREPPlugin_IOperations( GEOM_Engine*, int ); + ~BREPPlugin_IOperations(); + + void ExportBREP( const Handle(GEOM_Object), + const TCollection_AsciiString& ); + + Handle(TColStd_HSequenceOfTransient) ImportBREP( const TCollection_AsciiString& ); +}; + +#endif diff --git a/src/BREPPlugin/BREPPlugin_IOperations_i.cc b/src/BREPPlugin/BREPPlugin_IOperations_i.cc new file mode 100644 index 000000000..aee5e9eb0 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_IOperations_i.cc @@ -0,0 +1,108 @@ +// 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 "BREPPlugin_IOperations_i.hh" +#include "BREPPlugin_IOperations.hxx" + +// KERNEL includes +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +BREPPlugin_IOperations_i::BREPPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + BREPPlugin_IOperations* theImpl ) +:GEOM_IOperations_i( thePOA, theEngine, theImpl ) +{ + MESSAGE( "BREPPlugin_IOperations_i::BREPPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +BREPPlugin_IOperations_i::~BREPPlugin_IOperations_i() +{ + MESSAGE( "BREPPlugin_IOperations_i::~BREPPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * ExportBREP + * Export a shape to BREP format + * \param theOriginal The shape to export + * \param theFileName The name of the exported file + */ +//============================================================================= +void BREPPlugin_IOperations_i::ExportBREP( GEOM::GEOM_Object_ptr theOriginal, + const char* theFileName ) +{ + // duplicate the original shape + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate( theOriginal ); + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(GEOM_Object) anOriginal = GetObjectImpl( theOriginal ); + if (anOriginal.IsNull()) return; + + //Export the shape to the file + GetOperations()->ExportBREP( anOriginal, theFileName ); +} + +//============================================================================= +/*! + * ImportBREP + * Import a shape from BREP format + * \param theFileName The name of the file to import + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* BREPPlugin_IOperations_i::ImportBREP( const char* theFileName ) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Import the shape from the file + Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportBREP( theFileName ); + + if( !GetOperations()->IsDone() || aHSeq.IsNull() ) + return aSeq._retn(); + + // Copy created objects. + Standard_Integer aLength = aHSeq->Length(); + aSeq->length( aLength ); + for( Standard_Integer i = 1; i <= aLength; i++ ) + aSeq[i-1] = GetObject( Handle(GEOM_Object)::DownCast( aHSeq->Value(i) ) ); + + return aSeq._retn(); +} + +BREPPlugin_IOperations* BREPPlugin_IOperations_i::GetOperations() +{ + return (BREPPlugin_IOperations*)GetImpl(); +} diff --git a/src/BREPPlugin/BREPPlugin_IOperations_i.hh b/src/BREPPlugin/BREPPlugin_IOperations_i.hh new file mode 100644 index 000000000..02f9d8138 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_IOperations_i.hh @@ -0,0 +1,52 @@ +// 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 _BREPPlugin_IOperations_i_HeaderFile +#define _BREPPlugin_IOperations_i_HeaderFile + +// idl includes +#include +#include CORBA_SERVER_HEADER( GEOM_Gen ) +#include CORBA_SERVER_HEADER( BREPPlugin ) + +// internal includes +#include "BREPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_IOperations_i.hh" + +class BREPPlugin_IOperations; + +class BREPPLUGINENGINE_EXPORT BREPPlugin_IOperations_i : + public virtual POA_GEOM::IBREPOperations, + public virtual GEOM_IOperations_i +{ +public: + BREPPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + BREPPlugin_IOperations* theImpl ); + ~BREPPlugin_IOperations_i(); + + void ExportBREP( GEOM::GEOM_Object_ptr, const char* ); + GEOM::ListOfGO* ImportBREP( const char* ); + + BREPPlugin_IOperations* GetOperations(); +}; + +#endif // _BREPPlugin_IOperations_i_HeaderFile diff --git a/src/BREPPlugin/BREPPlugin_ImportDriver.cxx b/src/BREPPlugin/BREPPlugin_ImportDriver.cxx new file mode 100644 index 000000000..3f24fea44 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_ImportDriver.cxx @@ -0,0 +1,122 @@ +// 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 "BREPPlugin_ImportDriver.hxx" +#include "BREPPlugin_IImport.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOM_Function.hxx" +#include "GEOMImpl_Types.hxx" + +// OOCT includes +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& BREPPlugin_ImportDriver::GetID() +{ + static Standard_GUID aGUID("7e1b28ec-8513-4217-b09c-7652fbe8149e"); + return aGUID; +} + +//======================================================================= +//function : BREPPlugin_ImportDriver +//purpose : +//======================================================================= +BREPPlugin_ImportDriver::BREPPlugin_ImportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer BREPPlugin_ImportDriver::Execute( TFunction_Logbook& log ) const +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + BREPPlugin_IImport aData( aFunction ); + + TCollection_AsciiString aFileName = aData.GetFileName().ToCString(); + + MESSAGE("Import BREP from file " << aFileName); + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + TopoDS_Shape aShape; + BRep_Builder B; + BRepTools::Read(aShape, aFileName.ToCString(), B); + if( aShape.IsNull() ) return 0; + + aFunction->SetValue( aShape ); + + log.SetTouched( Label() ); + + return 1; +} + +//======================================================================= +//function : MustExecute +//purpose : +//======================================================================= +Standard_Boolean BREPPlugin_ImportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool BREPPlugin_ImportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction( Label() ); + + BREPPlugin_IImport aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "ImportBREP"; + + switch ( aType ) { + case IMPORT_SHAPE: + AddParam( theParams, "File name", aCI.GetFileName() ); + break; + default: + return false; + } + return true; +} + +IMPLEMENT_STANDARD_HANDLE( BREPPlugin_ImportDriver, GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( BREPPlugin_ImportDriver, GEOM_BaseDriver ); diff --git a/src/BREPPlugin/BREPPlugin_ImportDriver.hxx b/src/BREPPlugin/BREPPlugin_ImportDriver.hxx new file mode 100644 index 000000000..1f043659b --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_ImportDriver.hxx @@ -0,0 +1,51 @@ +// 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 _BREPPlugin_ImportDriver_HXX +#define _BREPPlugin_ImportDriver_HXX + +// internal includes +#include "BREPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( BREPPlugin_ImportDriver, GEOM_BaseDriver ); + +class BREPPLUGINENGINE_EXPORT BREPPlugin_ImportDriver : public GEOM_BaseDriver +{ +public: + BREPPlugin_ImportDriver(); + ~BREPPlugin_ImportDriver() {}; + + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} + + virtual bool GetCreationInformation( std::string& theOperationName, + std::vector& params ); + +DEFINE_STANDARD_RTTI( BREPPlugin_ImportDriver ) +}; + +#endif // _BREPPlugin_ImportDriver_HXX diff --git a/src/BREPPlugin/BREPPlugin_OperationsCreator.cxx b/src/BREPPlugin/BREPPlugin_OperationsCreator.cxx new file mode 100644 index 000000000..27808c748 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_OperationsCreator.cxx @@ -0,0 +1,69 @@ +// 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 "BREPPlugin_OperationsCreator.hxx" +#include "BREPPlugin_IOperations_i.hh" +#include "BREPPlugin_IOperations.hxx" +#include "BREPPlugin_ExportDriver.hxx" +#include "BREPPlugin_ImportDriver.hxx" +#include "BREPPlugin_IECallBack.hxx" + +// KERNEL includes +#include +#include + +// OCCT includes +#include + +std::map BREPPlugin_OperationsCreator::_mapOfOperations; + +BREPPlugin_OperationsCreator::BREPPlugin_OperationsCreator() +{ + // Register drivers + TFunction_DriverTable::Get()->AddDriver( BREPPlugin_ExportDriver::GetID(), + new BREPPlugin_ExportDriver() ); + TFunction_DriverTable::Get()->AddDriver( BREPPlugin_ImportDriver::GetID(), + new BREPPlugin_ImportDriver() ); + // Register callback + BREPPlugin_IECallBack* callback = new BREPPlugin_IECallBack(); + GEOMImpl_IECallBack::Register( "BREP", callback ); +} + +BREPPlugin_OperationsCreator::~BREPPlugin_OperationsCreator() +{ +} + +GEOM_IOperations_i* BREPPlugin_OperationsCreator::Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ) +{ + Unexpect aCatch( SALOME_SalomeException ); + MESSAGE( "BREPPlugin_OperationsCreator::Create" ); + return new BREPPlugin_IOperations_i( thePOA, theEngine, get( theGenImpl, theStudyId ) ); +} + +BREPPlugin_IOperations* BREPPlugin_OperationsCreator::get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ) +{ + if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) + _mapOfOperations[theStudyId] = new BREPPlugin_IOperations( theGenImpl, theStudyId ); + return _mapOfOperations[theStudyId]; +} diff --git a/src/BREPPlugin/BREPPlugin_OperationsCreator.hxx b/src/BREPPlugin/BREPPlugin_OperationsCreator.hxx new file mode 100755 index 000000000..687014436 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_OperationsCreator.hxx @@ -0,0 +1,57 @@ +// 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 _GEOM_BREPPlugin_OperationsCreator_HXX_ +#define _GEOM_BREPPlugin_OperationsCreator_HXX_ + +// internal includes +#include "BREPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Gen_i.hh" + +// C++ includes +#include + +class BREPPlugin_IOperations; + +//===================================================================== +// Operations creator +//===================================================================== +class BREPPLUGINENGINE_EXPORT BREPPlugin_OperationsCreator : public GEOM_GenericOperationsCreator +{ +public: + BREPPlugin_OperationsCreator(); + ~BREPPlugin_OperationsCreator(); + + GEOM_IOperations_i* Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ); +private: + static BREPPlugin_IOperations* get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ); + +private: + static std::map _mapOfOperations; + + friend class BREPPlugin_IECallBack; +}; + +#endif diff --git a/src/BREPPlugin/BREPPlugin_msg_en.ts b/src/BREPPlugin/BREPPlugin_msg_en.ts new file mode 100644 index 000000000..6ca54d154 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_msg_en.ts @@ -0,0 +1,46 @@ + + + + + @default + + MEN_EXPORTBREP + BREP + + + TOP_EXPORTBREP + Export BREP + + + STB_EXPORTBREP + Export BREP + + + MEN_IMPORTBREP + BREP + + + TOP_IMPORTBREP + Import BREP + + + STB_IMPORTBREP + Import BREP + + + + BREPPlugin_GUI + + BREP_FILES + BREP files( *.brep ) + + + EXPORT_TITLE + Export BREP + + + IMPORT_TITLE + Import BREP + + + diff --git a/src/BREPPlugin/BREPPlugin_msg_fr.ts b/src/BREPPlugin/BREPPlugin_msg_fr.ts new file mode 100644 index 000000000..ff0cd50e2 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_msg_fr.ts @@ -0,0 +1,46 @@ + + + + + @default + + MEN_EXPORTBREP + BREP + + + TOP_EXPORTBREP + Exporter BREP + + + STB_EXPORTBREP + Exporter BREP + + + MEN_IMPORTBREP + BREP + + + TOP_IMPORTBREP + Importer BREP + + + STB_IMPORTBREP + Importer BREP + + + + BREPPlugin_GUI + + BREP_FILES + BREP Fichiers( *.brep ) + + + EXPORT_TITLE + Exporter BREP + + + IMPORT_TITLE + Importer BREP + + + diff --git a/src/BREPPlugin/BREPPlugin_msg_ja.ts b/src/BREPPlugin/BREPPlugin_msg_ja.ts new file mode 100644 index 000000000..4a23773a3 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_msg_ja.ts @@ -0,0 +1,46 @@ + + + + + @default + + MEN_EXPORTBREP + BREP + + + TOP_EXPORTBREP + Export BREP + + + STB_EXPORTBREP + Export BREP + + + MEN_IMPORTBREP + BREP + + + TOP_IMPORTBREP + Import BREP + + + STB_IMPORTBREP + Import BREP + + + + BREPPlugin_GUI + + BREP_FILES + BREP files( *.brep ) + + + EXPORT_TITLE + Export BREP + + + IMPORT_TITLE + Import BREP + + + diff --git a/src/BREPPlugin/CMakeLists.txt b/src/BREPPlugin/CMakeLists.txt new file mode 100644 index 000000000..b9e443dc8 --- /dev/null +++ b/src/BREPPlugin/CMakeLists.txt @@ -0,0 +1,147 @@ +# 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 +# + +IF(SALOME_BUILD_GUI) + INCLUDE(UseQt4Ext) + INCLUDE(${QT_USE_FILE}) +ENDIF() + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} + ${KERNEL_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR}/idl + ${PROJECT_SOURCE_DIR}/src/GEOMAlgo + ${PROJECT_SOURCE_DIR}/src/GEOM + ${PROJECT_SOURCE_DIR}/src/GEOMImpl + ${PROJECT_SOURCE_DIR}/src/GEOM_I + ${PROJECT_SOURCE_DIR}/src/GEOMClient + ${PROJECT_SOURCE_DIR}/src/GEOMUtils + ) + +IF(SALOME_BUILD_GUI) + INCLUDE_DIRECTORIES( + ${QT_INCLUDE_DIRS} + ${GUI_INCLUDE_DIRS} + ${PROJECT_SOURCE_DIR}/src/OBJECT + ${PROJECT_SOURCE_DIR}/src/GEOMGUI + ${PROJECT_SOURCE_DIR}/src/GEOMBase + ) +ENDIF() + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${CAS_DEFINITIONS} + ) + +IF(SALOME_BUILD_GUI) +ADD_DEFINITIONS( + ${QT_DEFINITIONS} + ) +ENDIF() + +# libraries to link to +SET(_link_engine_LIBRARIES + ${CAS_TKBREP} + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + SalomeIDLGEOM + SalomeIDLBREPPlugin + GEOMEngine + GEOMClient + ) + +IF(SALOME_BUILD_GUI) + SET(_link_gui_LIBRARIES + SalomeIDLBREPPlugin + GEOMObject + GEOM + GEOMBase + ) +ENDIF() + + +# --- headers --- + +SET(BREPPluginEngine_HEADERS + BREPPlugin_IOperations_i.hh + BREPPlugin_Engine.hxx + BREPPlugin_OperationsCreator.hxx + BREPPlugin_IOperations.hxx + BREPPlugin_IExport.hxx + BREPPlugin_IImport.hxx + BREPPlugin_ImportDriver.hxx + BREPPlugin_ExportDriver.hxx + BREPPlugin_IECallBack.hxx + ) + +IF(SALOME_BUILD_GUI) + # header files / to be processed by moc + SET(_moc_HEADERS + BREPPlugin_GUI.h + ) +ENDIF() + +# --- sources --- + +IF(SALOME_BUILD_GUI) + # sources / moc wrappings + QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) + + SET(BREPPluginGUI_SOURCES + BREPPlugin_GUI.cxx + ${_moc_SOURCES} + ) +ENDIF() + +SET(BREPPluginEngine_SOURCES + BREPPlugin_Engine.cxx + BREPPlugin_OperationsCreator.cxx + BREPPlugin_IOperations_i.cc + BREPPlugin_IOperations.cxx + BREPPlugin_ExportDriver.cxx + BREPPlugin_ImportDriver.cxx + BREPPlugin_IECallBack.cxx + ) + +# resource files / to be processed by lrelease +SET(BREPPlugin_RESOURCES + BREPPlugin_msg_en.ts + BREPPlugin_msg_fr.ts + BREPPlugin_msg_ja.ts + ) + +# --- rules --- + +ADD_LIBRARY(BREPPluginEngine ${BREPPluginEngine_SOURCES}) +TARGET_LINK_LIBRARIES(BREPPluginEngine ${_link_engine_LIBRARIES}) +INSTALL(TARGETS BREPPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +IF(SALOME_BUILD_GUI) + ADD_LIBRARY(BREPPluginGUI ${BREPPluginGUI_SOURCES}) + TARGET_LINK_LIBRARIES(BREPPluginGUI ${_link_gui_LIBRARIES}) + INSTALL(TARGETS BREPPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + + QT4_INSTALL_TS_RESOURCES("${BREPPlugin_RESOURCES}" "${SALOME_GEOM_INSTALL_RES_DATA}") +ENDIF() + + +INSTALL(FILES ${BREPPluginEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 641853c22..7c10ef0d4 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,10 +21,10 @@ # Common packages ## SET(SUBDIRS_COMMON - ARCHIMEDE BlockFix GEOMAlgo SKETCHER GEOM BREPExport - BREPImport IGESExport IGESImport STEPExport STEPImport STLExport STLImport - ShHealOper GEOMUtils XAO XAO_Swig GEOMImpl GEOM_I GEOMClient GEOM_I_Superv GEOM_SWIG GEOM_PY - AdvancedEngine OCC2VTK VTKExport + ARCHIMEDE BlockFix GEOMAlgo SKETCHER GEOM ShHealOper GEOMUtils XAO XAO_Swig + GEOMImpl GEOM_I GEOMClient GEOM_I_Superv GEOM_SWIG GEOM_PY + AdvancedEngine OCC2VTK + STLPlugin BREPPlugin STEPPlugin IGESPlugin XAOPlugin VTKPlugin ) ## @@ -53,7 +53,7 @@ IF(SALOME_BUILD_GUI) OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase DependencyTree GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI - RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI ImportExportGUI + RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM ) ENDIF() diff --git a/src/DlgRef/CMakeLists.txt b/src/DlgRef/CMakeLists.txt index 61e6a2dfa..29874d83c 100755 --- a/src/DlgRef/CMakeLists.txt +++ b/src/DlgRef/CMakeLists.txt @@ -101,7 +101,6 @@ SET(_uic_files DlgRef_4Sel1Spin3Check_QTD.ui DlgRef_4Spin_QTD.ui DlgRef_6Sel_QTD.ui - DlgRef_Skeleton_QTD.ui ) # --- headers --- diff --git a/src/DlgRef/DlgRef.cxx b/src/DlgRef/DlgRef.cxx index efeefa4c2..1e242cb95 100644 --- a/src/DlgRef/DlgRef.cxx +++ b/src/DlgRef/DlgRef.cxx @@ -898,20 +898,6 @@ DlgRef_6Sel::~DlgRef_6Sel() { } -////////////////////////////////////////// -// DlgRef_Skeleton -////////////////////////////////////////// - -DlgRef_Skeleton::DlgRef_Skeleton( QWidget* parent, Qt::WindowFlags f ) -: QWidget( parent, f ) -{ - setupUi( this ); -} - -DlgRef_Skeleton::~DlgRef_Skeleton() -{ -} - ////////////////////////////////////////// // Utility functions ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.h b/src/DlgRef/DlgRef.h index fb3c8e047..918183677 100644 --- a/src/DlgRef/DlgRef.h +++ b/src/DlgRef/DlgRef.h @@ -972,22 +972,6 @@ public: ~DlgRef_6Sel(); }; -////////////////////////////////////////// -// DlgRef_Skeleton -////////////////////////////////////////// - -#include "ui_DlgRef_Skeleton_QTD.h" - -class DLGREF_EXPORT DlgRef_Skeleton : public QWidget, - public Ui::DlgRef_Skeleton_QTD -{ - Q_OBJECT - -public: - DlgRef_Skeleton( QWidget* = 0, Qt::WindowFlags = 0 ); - ~DlgRef_Skeleton(); -}; - ////////////////////////////////////////// // Utility functions ////////////////////////////////////////// diff --git a/src/GEOM/CMakeLists.txt b/src/GEOM/CMakeLists.txt index 067056152..92dd5f5c4 100755 --- a/src/GEOM/CMakeLists.txt +++ b/src/GEOM/CMakeLists.txt @@ -65,6 +65,7 @@ SET(GEOM_HEADERS GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx GEOM_DataMapOfAsciiStringTransient.hxx Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx + GEOM_BaseObject.hxx ) # --- sources --- diff --git a/src/GEOM/GEOM_BaseDriver.cxx b/src/GEOM/GEOM_BaseDriver.cxx index 2097da593..2ace1ce54 100644 --- a/src/GEOM/GEOM_BaseDriver.cxx +++ b/src/GEOM/GEOM_BaseDriver.cxx @@ -28,13 +28,29 @@ #include "GEOM_Function.hxx" #include "GEOM_Object.hxx" +#include "GEOM_Engine.hxx" #include #include +#include IMPLEMENT_STANDARD_HANDLE (GEOM_BaseDriver,TFunction_Driver); IMPLEMENT_STANDARD_RTTIEXT(GEOM_BaseDriver,TFunction_Driver); +//================================================================================ +/*! + * Returns document id + */ +//================================================================================ +int GEOM_BaseDriver::GetDocID() const +{ + int docId = 0; + if (!Label().IsNull()) { + Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(Label().Data()); + docId = GEOM_Engine::GetEngine()->GetDocID(aDoc); + } + return docId; +} //================================================================================ /*! diff --git a/src/GEOM/GEOM_BaseDriver.hxx b/src/GEOM/GEOM_BaseDriver.hxx index a90dd6813..7313ea602 100644 --- a/src/GEOM/GEOM_BaseDriver.hxx +++ b/src/GEOM/GEOM_BaseDriver.hxx @@ -67,7 +67,9 @@ struct GEOM_Param class GEOM_BaseDriver : public TFunction_Driver { public: - + // Returns document id + Standard_EXPORT int GetDocID() const; + // Returns a name of creation operation and names and values of creation parameters // (Use AddParam() methods declared below to fill params vector while implementing // this method in derived drivers) diff --git a/src/GEOMBase/CMakeLists.txt b/src/GEOMBase/CMakeLists.txt index b29c2204b..5c5f3c885 100755 --- a/src/GEOMBase/CMakeLists.txt +++ b/src/GEOMBase/CMakeLists.txt @@ -64,6 +64,7 @@ SET(_link_LIBRARIES SET(GEOMBase_HEADERS GEOMBase.h GEOMBase_Skeleton.h + GEOMBase_DlgSkeleton.h GEOMBase_Helper.h GEOM_Operation.h GEOM_GEOMBase.hxx @@ -73,6 +74,7 @@ SET(GEOMBase_HEADERS # header files / to be processed by moc SET(_moc_HEADERS GEOMBase_Skeleton.h + GEOMBase_DlgSkeleton.h ) # --- sources --- @@ -86,6 +88,7 @@ SET(GEOMBase_SOURCES GEOMBase_Helper.cxx GEOM_Operation.cxx GEOM_GenericObjPtr.cxx + GEOMBase_DlgSkeleton.cxx ${_moc_SOURCES} ) diff --git a/src/GEOMBase/GEOMBase_DlgSkeleton.cxx b/src/GEOMBase/GEOMBase_DlgSkeleton.cxx new file mode 100644 index 000000000..ab464279f --- /dev/null +++ b/src/GEOMBase/GEOMBase_DlgSkeleton.cxx @@ -0,0 +1,168 @@ +// 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 +// + +// GEOM GEOMGUI : GUI for Geometry component +// File : GEOMBase_DlgSkeleton.cxx +// Author : Roman NIKOLAEV, Open CASCADE S.A.S. + +#include "GEOMBase_DlgSkeleton.h" + +//Qt includes +#include +#include +#include +#include +#include +#include +#include + + +/*! + Constructor. +*/ +GEOMBase_DlgSkeleton::GEOMBase_DlgSkeleton( QWidget* parent, Qt::WindowFlags flags ) : + QWidget(parent,flags) +{ + init(); +} + +/*! + Destructor. +*/ +GEOMBase_DlgSkeleton::~GEOMBase_DlgSkeleton( ) { + +} + +/*! + Initialize the widget +*/ +void GEOMBase_DlgSkeleton::init( ) { + // Main layout + gridLayout = new QGridLayout(this); + + //Constructors group + GroupConstructors = new QGroupBox(this); + GroupConstructors->setObjectName(QString::fromUtf8("GroupConstructors")); + QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(GroupConstructors->sizePolicy().hasHeightForWidth()); + GroupConstructors->setSizePolicy(sizePolicy); + hboxLayout = new QHBoxLayout(GroupConstructors); + + RadioButton1 = new QRadioButton(GroupConstructors); + hboxLayout->addWidget(RadioButton1); + + RadioButton2 = new QRadioButton(GroupConstructors); + hboxLayout->addWidget(RadioButton2); + + RadioButton3 = new QRadioButton(GroupConstructors); + hboxLayout->addWidget(RadioButton3); + + RadioButton4 = new QRadioButton(GroupConstructors); + hboxLayout->addWidget(RadioButton4); + + RadioButton5 = new QRadioButton(GroupConstructors); + hboxLayout->addWidget(RadioButton5); + gridLayout->addWidget(GroupConstructors, 0, 0, 1, 1); + + //Name group + GroupBoxName = new QGroupBox(this); + sizePolicy.setHeightForWidth(GroupBoxName->sizePolicy().hasHeightForWidth()); + GroupBoxName->setSizePolicy(sizePolicy); + hboxLayout1 = new QHBoxLayout(GroupBoxName); + hboxLayout1->setContentsMargins(9, 9, 9, 9); + + NameLabel = new QLabel(GroupBoxName); + NameLabel->setWordWrap(false); + hboxLayout1->addWidget(NameLabel); + + ResultName = new QLineEdit(GroupBoxName); + hboxLayout1->addWidget(ResultName); + gridLayout->addWidget(GroupBoxName, 1, 0, 1, 1); + + //Group box with the check-boxes + GroupMedium = new QWidget(this); + QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Expanding); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(GroupMedium->sizePolicy().hasHeightForWidth()); + GroupMedium->setSizePolicy(sizePolicy1); + + gridLayout->addWidget(GroupMedium, 2, 0, 1, 1); + GroupBoxPublish = new QGroupBox(this); + vboxLayout = new QVBoxLayout(GroupBoxPublish); + + CheckBoxRestoreSS = new QCheckBox(GroupBoxPublish); + vboxLayout->addWidget(CheckBoxRestoreSS); + + CheckBoxAddPrefix = new QCheckBox(GroupBoxPublish); + vboxLayout->addWidget(CheckBoxAddPrefix); + + CheckBoxPreview = new QCheckBox(GroupBoxPublish); + vboxLayout->addWidget(CheckBoxPreview); + gridLayout->addWidget(GroupBoxPublish, 3, 0, 1, 1); + + //Group with buttons + GroupButtons = new QGroupBox(this); + + QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed); + sizePolicy2.setHorizontalStretch(0); + sizePolicy2.setVerticalStretch(0); + sizePolicy2.setHeightForWidth(GroupButtons->sizePolicy().hasHeightForWidth()); + GroupButtons->setSizePolicy(sizePolicy2); + + hboxLayout2 = new QHBoxLayout(GroupButtons); + hboxLayout2->setContentsMargins(9, 9, 9, 9); + buttonOk = new QPushButton(GroupButtons); + hboxLayout2->addWidget(buttonOk); + + buttonApply = new QPushButton(GroupButtons); + hboxLayout2->addWidget(buttonApply); + + QSpacerItem* spacerItem = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + hboxLayout2->addItem(spacerItem); + + buttonCancel = new QPushButton(GroupButtons); + hboxLayout2->addWidget(buttonCancel); + + buttonHelp = new QPushButton(GroupButtons); + + hboxLayout2->addWidget(buttonHelp); + + gridLayout->addWidget(GroupButtons, 4, 0, 1, 1); + + setTabOrder(CheckBoxRestoreSS, CheckBoxAddPrefix); + setTabOrder(CheckBoxAddPrefix, CheckBoxPreview); + setTabOrder(CheckBoxPreview, buttonOk); + setTabOrder(buttonOk, buttonApply); + setTabOrder(buttonApply, buttonCancel); + setTabOrder(buttonCancel, buttonHelp); + setTabOrder(buttonHelp, RadioButton1); + setTabOrder(RadioButton1, RadioButton2); + setTabOrder(RadioButton2, RadioButton3); + setTabOrder(RadioButton3, RadioButton4); + setTabOrder(RadioButton4, RadioButton5); + setTabOrder(RadioButton5, ResultName); + + buttonOk->setText(tr("A&pply and Close")); + buttonApply->setText("&Apply"); + buttonCancel->setText("&Close"); + buttonHelp->setText("&Help"); +} diff --git a/src/GEOMBase/GEOMBase_DlgSkeleton.h b/src/GEOMBase/GEOMBase_DlgSkeleton.h new file mode 100644 index 000000000..2b4db808d --- /dev/null +++ b/src/GEOMBase/GEOMBase_DlgSkeleton.h @@ -0,0 +1,75 @@ +// 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 +// + +// GEOM GEOMGUI : GUI for Geometry component +// File : GEOMBase_DlgSkeleton.h +// Author : Roman NIKOLAEV, Open CASCADE S.A.S. + +#ifndef GEOMBASE_DLGSKELETON_N +#define GEOMBASE_DLGSKELETON_N + +#include +#include "GEOM_GEOMBase.hxx" + +class QGridLayout; +class QGroupBox; +class QHBoxLayout; +class QVBoxLayout; +class QRadioButton; +class QLabel; +class QLineEdit; +class QCheckBox; +class QPushButton; + +class GEOMBASE_EXPORT GEOMBase_DlgSkeleton : public QWidget +{ + Q_OBJECT + public: + GEOMBase_DlgSkeleton( QWidget* = 0, Qt::WindowFlags = 0 ); + ~GEOMBase_DlgSkeleton(); + private: + void init(); + public: + QGridLayout *gridLayout; + QGroupBox *GroupConstructors; + QHBoxLayout *hboxLayout; + QRadioButton *RadioButton1; + QRadioButton *RadioButton2; + QRadioButton *RadioButton3; + QRadioButton *RadioButton4; + QRadioButton *RadioButton5; + QGroupBox *GroupBoxName; + QHBoxLayout *hboxLayout1; + QLabel *NameLabel; + QLineEdit *ResultName; + QWidget *GroupMedium; + QGroupBox *GroupBoxPublish; + QVBoxLayout *vboxLayout; + QCheckBox *CheckBoxRestoreSS; + QCheckBox *CheckBoxAddPrefix; + QCheckBox *CheckBoxPreview; + QGroupBox *GroupButtons; + QHBoxLayout *hboxLayout2; + QPushButton *buttonOk; + QPushButton *buttonApply; + QPushButton *buttonCancel; + QPushButton *buttonHelp; +}; + +#endif //GEOMBASE_DLGSKELETON_N diff --git a/src/GEOMBase/GEOMBase_Skeleton.cxx b/src/GEOMBase/GEOMBase_Skeleton.cxx index b49649447..7ed88f0b0 100644 --- a/src/GEOMBase/GEOMBase_Skeleton.cxx +++ b/src/GEOMBase/GEOMBase_Skeleton.cxx @@ -25,6 +25,7 @@ // Author : Damien COQUERET, Open CASCADE S.A.S. #include "GEOMBase_Skeleton.h" +#include "GEOMBase_DlgSkeleton.h" #include "GEOMBase.h" #include @@ -62,7 +63,7 @@ GEOMBase_Skeleton::GEOMBase_Skeleton( GeometryGUI* theGeometryGUI, QWidget* pare setModal( modal ); - myMainFrame = new DlgRef_Skeleton( this ); + myMainFrame = new GEOMBase_DlgSkeleton( this ); QVBoxLayout* topLayout = new QVBoxLayout( this ); topLayout->setMargin( 0 ); topLayout->setSpacing( 0 ); topLayout->addWidget( myMainFrame ); @@ -347,8 +348,15 @@ void GEOMBase_Skeleton::unsetConstructorId() void GEOMBase_Skeleton::ClickOnHelp() { LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() ); + + QString context; + if(myHelpContext.isEmpty()) { + context = myGeomGUI ? app->moduleName( myGeomGUI->moduleName() ) : QString(""); + } else { + context = myHelpContext; + } if ( app ) - app->onHelpContextModule( myGeomGUI ? app->moduleName( myGeomGUI->moduleName() ) : QString(""), myHelpFileName ); + app->onHelpContextModule( context , myHelpFileName ); else { QString platform; #ifdef WIN32 @@ -372,7 +380,7 @@ void GEOMBase_Skeleton::setHelpFileName( const QString& theName ) myHelpFileName = theName; } -DlgRef_Skeleton* GEOMBase_Skeleton::mainFrame() +GEOMBase_DlgSkeleton* GEOMBase_Skeleton::mainFrame() { return myMainFrame; } diff --git a/src/GEOMBase/GEOMBase_Skeleton.h b/src/GEOMBase/GEOMBase_Skeleton.h index e4f5f4d94..b41b5d875 100644 --- a/src/GEOMBase/GEOMBase_Skeleton.h +++ b/src/GEOMBase/GEOMBase_Skeleton.h @@ -28,13 +28,14 @@ #define GEOMBASE_SKELETON_H #include "GEOM_GEOMBase.hxx" +#include "GEOMBase_DlgSkeleton.h" #include "GEOMBase_Helper.h" #include class SalomeApp_DoubleSpinBox; class GeometryGUI; -class DlgRef_Skeleton; +class GEOMBase_DlgSkeleton; class QSpinBox; class QDoubleSpinBox; class QLineEdit; @@ -90,7 +91,7 @@ protected: void setHelpFileName( const QString& ); - DlgRef_Skeleton* mainFrame(); + GEOMBase_DlgSkeleton* mainFrame(); QWidget* centralWidget(); QPushButton* buttonCancel() const; QPushButton* buttonOk() const; @@ -103,7 +104,9 @@ protected: QString myHelpFileName; //!< Associated HTML help file name QButtonGroup* myRBGroup; //!< radio button group - DlgRef_Skeleton* myMainFrame; //!< dialog box's mainframe widgetx + GEOMBase_DlgSkeleton* myMainFrame; //!< dialog box's mainframe widget + QString myHelpContext; //!< Help context, needed for the customization + //!< path where located plugins help HTML pages protected slots: virtual void ClickOnCancel(); @@ -111,7 +114,7 @@ protected slots: void LineEditReturnPressed(); void DeactivateActiveDialog(); void ActivateThisDialog(); - void ClickOnHelp(); + virtual void ClickOnHelp(); signals: void constructorsClicked( int ); diff --git a/src/GEOMBase/GEOM_GenericObjPtr.h b/src/GEOMBase/GEOM_GenericObjPtr.h index 552e3143d..ce5fb31bf 100644 --- a/src/GEOMBase/GEOM_GenericObjPtr.h +++ b/src/GEOMBase/GEOM_GenericObjPtr.h @@ -229,7 +229,6 @@ namespace GEOM typedef GenericObjPtr InsertOpPtr; typedef GenericObjPtr MeasureOpPtr; typedef GenericObjPtr GroupOpPtr; - typedef GenericObjPtr AdvancedOpPtr; template<> bool GEOMBASE_EXPORT GenericObjPtr::isSame( GEOM::GEOM_Object_ptr theLeft, GEOM::GEOM_Object_ptr theRight ); } diff --git a/src/GEOMGUI/CMakeLists.txt b/src/GEOMGUI/CMakeLists.txt index c5dc25f8a..74e2f4f0f 100755 --- a/src/GEOMGUI/CMakeLists.txt +++ b/src/GEOMGUI/CMakeLists.txt @@ -62,7 +62,6 @@ SET(_link_LIBRARIES ${KERNEL_SalomeDS} ${KERNEL_SalomeDSClient} ${GUI_SalomeApp} - ${QT_QTXML_LIBRARY} ) # --- headers --- @@ -72,7 +71,6 @@ SET(GEOMGUI_HEADERS GeometryGUI_Operations.h GEOMGUI.h GEOMPluginGUI.h - GEOMGUI_XmlHandler.h GEOM_Displayer.h GEOMGUI_OCCSelector.h GEOMGUI_Selection.h @@ -112,7 +110,6 @@ SET(GEOMGUI_SOURCES GeometryGUI.cxx GEOMGUI.cxx GEOMPluginGUI.cxx - GEOMGUI_XmlHandler.cxx GEOM_Displayer.cxx GEOMGUI_OCCSelector.cxx GEOMGUI_Selection.cxx diff --git a/src/GEOMGUI/GEOMGUI_CreationInfoWdg.cxx b/src/GEOMGUI/GEOMGUI_CreationInfoWdg.cxx index 6bf1369e3..bd319bfab 100644 --- a/src/GEOMGUI/GEOMGUI_CreationInfoWdg.cxx +++ b/src/GEOMGUI/GEOMGUI_CreationInfoWdg.cxx @@ -77,7 +77,6 @@ void GEOMGUI_CreationInfoWdg::setOperation(const QPixmap& icon, const QString& n { myIconLbl->setPixmap( icon ); myOperaionLnEd->setText( name ); - myParamsTreeWd->clear(); if ( name.isEmpty() ) myOperaionLnEd->setText( tr("NO_INFO")); diff --git a/src/GEOMGUI/GEOMGUI_XmlHandler.cxx b/src/GEOMGUI/GEOMGUI_XmlHandler.cxx deleted file mode 100644 index db66695a7..000000000 --- a/src/GEOMGUI/GEOMGUI_XmlHandler.cxx +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// - -// GEOM GEOMGUI : reading of xml file with list of available plugin actions -// File : GEOMGUI_XmlHandler.cxx -// Author : Julia DOROVSKIKH, Open CASCADE S.A.S. - -#include "GEOMGUI_XmlHandler.h" - -#include "GEOMGUI.h" - -// SALOME KERNEL includes -#include - -/*! - * Constructor - */ -GEOMGUI_XmlHandler::GEOMGUI_XmlHandler() -{ -} - -/*! - * Destructor - */ -GEOMGUI_XmlHandler::~GEOMGUI_XmlHandler() -{ -} - -/*! - * Starts parsing of document. Does some initialization - * - * Reimplemented from QXmlDefaultHandler. - */ -bool GEOMGUI_XmlHandler::startDocument() -{ - myErrorProt = ""; - return true; -} - -/*! - * Does different actions depending on the name of the tag and the - * state you are in document. - * - * Reimplemented from QXmlDefaultHandler. - */ -bool GEOMGUI_XmlHandler::startElement (const QString&, const QString&, - const QString& qName, - const QXmlAttributes& atts) -{ - if (qName == "geom-plugins") { // set of plugins - //myHypothesesMap.clear(); - //myAlgorithmsMap.clear(); - } - else if (qName == "geom-plugin") { // group of actions - myPluginData.myName = atts.value("name"); - myPluginData.myServerLib = atts.value("server-lib"); - myPluginData.myClientLib = atts.value("gui-lib"); - - //QString aResName = atts.value("resources"); - //if (aResName != "") { - // SUIT_ResourceMgr* resMgr = GEOMGUI::resourceMgr(); - // QString lang = resMgr->stringValue( resMgr->langSection(), "language", "en" ); - // resMgr->loadTranslator( "resources", QString( "%1_msg_%2.qm" ).arg( aResName, lang ) ); - // resMgr->loadTranslator( "resources", QString( "%1_images.qm" ).arg( aResName, lang ) ); - //} - } - else if (qName == "actions") { // group of actions - } - else if (qName == "action") { // an action - GEOMGUI_ActionData aData; - aData.myLabel = atts.value("label"); - aData.myIcon = atts.value("icon"); - aData.myMenu = atts.value("menu"); - aData.myTooltip = atts.value("tooltip"); - aData.myStatusBar = atts.value("status-bar"); - - myPluginData.myListOfActions.append(aData); - } - else { - // error - return false; - } - return true; -} - -/*! - * Reimplemented from QXmlDefaultHandler. - */ -bool GEOMGUI_XmlHandler::endElement (const QString&, const QString&, const QString&) -{ - return true; -} - -/*! - * Reimplemented from QXmlDefaultHandler. - */ -bool GEOMGUI_XmlHandler::characters (const QString& ch) -{ - // we are not interested in whitespaces - //QString ch_simplified = ch.simplified(); - //if ( ch_simplified.isEmpty() ) - // return true; - return true; -} - -/*! - * Returns the default error string. - * - * Reimplemented from QXmlDefaultHandler. - */ -QString GEOMGUI_XmlHandler::errorString() -{ - return "the document is not in the quote file format"; -} - -/*! - * Returns the error protocol if parsing failed - * - * Reimplemented from QXmlDefaultHandler. - */ -QString GEOMGUI_XmlHandler::errorProtocol() -{ - return myErrorProt; -} - -/*! - * Returns exception - * - * Reimplemented from QXmlDefaultHandler. - */ -bool GEOMGUI_XmlHandler::fatalError (const QXmlParseException& exception) -{ - myErrorProt += QString("fatal parsing error: %1 in line %2, column %3\n") - .arg(exception.message()) - .arg(exception.lineNumber()) - .arg(exception.columnNumber()); - - return QXmlDefaultHandler::fatalError( exception ); -} diff --git a/src/GEOMGUI/GEOMGUI_XmlHandler.h b/src/GEOMGUI/GEOMGUI_XmlHandler.h deleted file mode 100644 index dc1b64dbe..000000000 --- a/src/GEOMGUI/GEOMGUI_XmlHandler.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// - -// GEOM GEOMGUI : reading of xml file with list of available plugin actions -// File : GEOMGUI_XmlHandler.h -// Author : Julia DOROVSKIKH, Open CASCADE S.A.S. - -#ifndef GEOMGUI_XMLHANDLER_H -#define GEOMGUI_XMLHANDLER_H - -// GEOM includes -#include "GEOMGUI.h" - -// Qt includes -#include -#include -#include - -//GUI includes -#include - -//class HypothesisData; -//class HypothesesSet; - -struct GEOMGUI_ActionData -{ - QString myLabel; // unique ID - QString myIcon; - QString myMenu; - QString myTooltip; - QString myStatusBar; - - //int myAccel; - //bool myToggle; - //QString myShortcut; -}; - -struct GEOMGUI_PluginData -{ - QString myName; - QString myServerLib; - QString myClientLib; - - //QList myListOfActions; - QList myListOfActions; -}; - -class GEOMGUI_EXPORT GEOMGUI_XmlHandler : public QXmlDefaultHandler -{ -public: - GEOMGUI_XmlHandler(); - virtual ~GEOMGUI_XmlHandler(); - - bool startDocument(); - bool startElement( const QString&, const QString&, - const QString&, const QXmlAttributes& ); - bool endElement( const QString&, const QString&, const QString& ); - bool characters( const QString& ); - - QString errorString(); - QString errorProtocol(); - bool fatalError( const QXmlParseException& ); - -public: - GEOMGUI_PluginData myPluginData; - -private: - QString myErrorProt; -}; - -#endif // GEOMGUI_XMLHANDLER_H diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 467cc55de..115e51e67 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -1315,26 +1315,6 @@ ICON_DLG_SCALE_ALONG_AXES scale_along_axes.png - - ICON_DLG_EXPORTXAO - exportxao.png - - - ICO_EXPORTXAO - exportxao.png - - - ICON_DLG_IMPORTXAO - importxao.png - - - ICO_IMPORTXAO - importxao.png - - - ICON_OBJBROWSER_IMPORTEXPORT_204 - tree_exportxao.png - diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 13449596d..89480676b 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -1012,14 +1012,6 @@ Please, select face, shell or solid and try again GEOM_MEN_ENTER_ANGLE Enter An Angle In Degrees - - GEOM_MEN_EXPORT - Export - - - GEOM_MEN_IMPORT - Import - GEOM_MEN_ISOS Select Number Of Isos @@ -2594,7 +2586,7 @@ Please, select face, shell or solid and try again MEN_EXPORT - Export... + Export MEN_EXTRUSION @@ -2702,7 +2694,7 @@ Please, select face, shell or solid and try again MEN_IMPORT - Import... + Import MEN_INERTIA @@ -3544,10 +3536,6 @@ Please, select face, shell or solid and try again STB_EXPLODE_BLOCKS Explode on Blocks - - STB_EXPORT - Export geometry to BREP file - STB_EXTRUSION Create an extrusion @@ -3632,10 +3620,6 @@ Please, select face, shell or solid and try again STB_HEX_SOLID Hexahedral Solid - - STB_IMPORT - Import geometry from BREP file - STB_INERTIA Compute moments of intertia of the shape @@ -4152,10 +4136,6 @@ Please, select face, shell or solid and try again TOP_EXPLODE_BLOCKS Explode on Blocks - - TOP_EXPORT - Export geometry to BREP file - TOP_EXTRUSION Create an extrusion @@ -4232,10 +4212,6 @@ Please, select face, shell or solid and try again TOP_HEX_SOLID Hexahedral Solid - - TOP_IMPORT - Import geometry from BREP file - TOP_INERTIA Moments of intertia @@ -5095,11 +5071,6 @@ shells and solids on the other hand. GEOM_PUBLISH_NAMED_SHAPES Create groups for named shapes (if there are any)? - - GEOM_SCALE_DIMENSIONS - Take into account the units (%1) embedded to the file? -Ignoring units will cause model scaling (as dimensions are supposed to be specified in meters). - GEOM_PRECISION_HINT Input value precision can be adjusted using @@ -5129,54 +5100,6 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif GEOM_SELECT_IMAGE Select image... - - MEN_IMPORTEXPORT - Import / Export XAO - - - TOP_EXPORTXAO - Export to XAO - - - MEN_EXPORTXAO - Export XAO - - - STB_EXPORTXAO - Export shape to XAO format - - - TOP_IMPORTXAO - Import from XAO - - - MEN_IMPORTXAO - Import XAO - - - STB_IMPORTXAO - Import shape from XAO format - - - GEOM_IMPORTEXPORT_204 - Export XAO - - - GEOM_SELECT_IMPORT_XAO - Import from XAO - - - GEOM_SELECT_EXPORT_XAO - Export to XAO - - - XAO_FILES - XAO files (*.xao) - - - TOOLS_IMPORTEXPORT - Import / Export - CC_PNT_ITEM_X_Y X=%1, Y=%2 @@ -7009,72 +6932,6 @@ Do you want to create new material? (No info available) - - ImportExportGUI_ExportXAODlg - - GEOM_EXPORTXAO_TITLE - Export XAO - - - GEOM_EXPORTXAO - Export XAO - - - GEOM_EXPORTXAO_EXPORTINGSHAPE - Shape - - - GEOM_EXPORTXAO_FILENAME - File Name - - - GEOM_EXPORTXAO_AUTHOR - Author - - - GEOM_EXPORTXAO_LGROUPS - Groups - - - GEOM_EXPORTXAO_LFIELDS - Fields - - - EXPORT_DLG_ACCEPT - OK - - - - ImportExportGUI_ImportXAODlg - - GEOM_IMPORTXAO_TITLE - Import XAO - - - GEOM_IMPORTXAO - Import XAO - - - GEOM_IMPORTXAO_IMPORTINGSHAPE - Shape - - - GEOM_IMPORTXAO_FILENAME - File Name - - - GEOM_IMPORTXAO_LGROUPS - Groups - - - GEOM_IMPORTXAO_LFIELDS - Fields - - - STEP - Step - - EntityGUI_IsolineDlg diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index 8f0b1cf93..07c02e244 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -1024,14 +1024,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau GEOM_MEN_ENTER_ANGLE Indiquez l'angle en degrés - - GEOM_MEN_EXPORT - Exporter - - - GEOM_MEN_IMPORT - Importer - GEOM_MEN_ISOS Choisir le nombre d'isolignes @@ -2602,7 +2594,7 @@ Choisissez une face, une coque ou un solide et essayez de nouveau MEN_EXPORT - Exporter... + Exporter MEN_EXTRUSION @@ -2710,7 +2702,7 @@ Choisissez une face, une coque ou un solide et essayez de nouveau MEN_IMPORT - Importer... + Importer MEN_INERTIA @@ -3548,10 +3540,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau STB_EXPLODE_BLOCKS Eclater en blocs - - STB_EXPORT - Exporter la géométrie au fichier BREP - STB_EXTRUSION Créer une extrusion @@ -3636,10 +3624,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau STB_HEX_SOLID Solide hexaédrique - - STB_IMPORT - Importer une géométrie d'un fichier BREP - STB_INERTIA Calculer les moments d'inertie de l'objet @@ -4156,10 +4140,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau TOP_EXPLODE_BLOCKS Eclater en blocs - - TOP_EXPORT - Exporter une géométrie au format BREP - TOP_EXTRUSION Créer une extrusion @@ -4236,10 +4216,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau TOP_HEX_SOLID Solide hexaédrique - - TOP_IMPORT - Importer une géométrie d'un fichier BREP - TOP_INERTIA Moments d'inertie @@ -5095,11 +5071,6 @@ les coques et solides d'un autre. GEOM_PUBLISH_NAMED_SHAPES Créer des groupes pour les objets indiqués (s'ils existent)? - - GEOM_SCALE_DIMENSIONS - Voulez-vous prendre les unités du fichier (%1) en considération? -Sinon le modèle sera mis à l'échelle GEOM (unités interprétées comme des mètres). - GEOM_PRECISION_HINT Il est possible d'ajuster la précision de la valeur d'entrée avec @@ -5129,54 +5100,6 @@ le paramètre '%1' aux préférences du module Géométrie.GEOM_SELECT_IMAGE Sélectionner une image... - - MEN_IMPORTEXPORT - Import / Export XAO - - - TOP_EXPORTXAO - Export XAO - - - MEN_EXPORTXAO - Export XAO - - - STB_EXPORTXAO - Exporter une forme au format XAO - - - TOP_IMPORTXAO - Import XAO - - - MEN_IMPORTXAO - Import XAO - - - STB_IMPORTXAO - Importer une forme au format XAO - - - GEOM_IMPORTEXPORT_204 - Export XAO - - - GEOM_SELECT_IMPORT_XAO - Import XAO - - - GEOM_SELECT_EXPORT_XAO - Export XAO - - - XAO_FILES - Fichiers XAO (*.xao) - - - TOOLS_IMPORTEXPORT - Import / Export XAO - CC_PNT_ITEM_X_Y X=%1, Y=%2 @@ -7009,72 +6932,6 @@ Voulez-vous en créer un nouveau ? (aucune information disponible) - - ImportExportGUI_ExportXAODlg - - GEOM_EXPORTXAO_TITLE - Export XAO - - - GEOM_EXPORTXAO - Export XAO - - - GEOM_EXPORTXAO_EXPORTINGSHAPE - Objet - - - GEOM_EXPORTXAO_FILENAME - Fichier - - - GEOM_EXPORTXAO_AUTHOR - Auteur - - - GEOM_EXPORTXAO_LGROUPS - Groupes - - - GEOM_EXPORTXAO_LFIELDS - Champs - - - EXPORT_DLG_ACCEPT - OK - - - - ImportExportGUI_ImportXAODlg - - GEOM_IMPORTXAO_TITLE - Import XAO - - - GEOM_IMPORTXAO - Import XAO - - - GEOM_IMPORTXAO_IMPORTINGSHAPE - Objet - - - GEOM_IMPORTXAO_FILENAME - Fichier - - - GEOM_IMPORTXAO_LGROUPS - Groupes - - - GEOM_IMPORTXAO_LFIELDS - Champs - - - STEP - Pas - - EntityGUI_IsolineDlg diff --git a/src/GEOMGUI/GEOM_msg_ja.ts b/src/GEOMGUI/GEOM_msg_ja.ts index 11b374459..8d7cd8e2d 100644 --- a/src/GEOMGUI/GEOM_msg_ja.ts +++ b/src/GEOMGUI/GEOM_msg_ja.ts @@ -1003,14 +1003,6 @@ GEOM_MEN_ENTER_ANGLE 角度を度数で指定します - - GEOM_MEN_EXPORT - エクスポート - - - GEOM_MEN_IMPORT - インポート - GEOM_MEN_ISOS 輪郭線の数を選択します。 @@ -1465,7 +1457,7 @@ GEOM_PRP_EXPORT - ジオメトリを %1 にエクスポート... + ジオメトリを %1 にエクスポート GEOM_PRP_LOADING @@ -2693,7 +2685,7 @@ MEN_IMPORT - インポート... + インポート MEN_INERTIA @@ -3535,10 +3527,6 @@ STB_EXPLODE_BLOCKS ブロックで展開 - - STB_EXPORT - ジオメトリをBREPファイルにエクスポート - STB_EXTRUSION 押し出しを作成 @@ -3623,10 +3611,6 @@ STB_HEX_SOLID Hexahedral_Solid - - STB_IMPORT - BREPファイルをジオメトリにインポート - STB_INERTIA オブジェクトの慣性モーメントを計算します。 @@ -4143,10 +4127,6 @@ TOP_EXPLODE_BLOCKS ブロックで展開 - - TOP_EXPORT - ジオメトリをBREPファイルでエクスポート - TOP_EXTRUSION 押し出しを作成 @@ -4223,10 +4203,6 @@ TOP_HEX_SOLID Hexahedral_Solid - - TOP_IMPORT - BREPファイルをジオメトリにインポート - TOP_INERTIA 慣性モーメント @@ -5083,10 +5059,6 @@ GEOM_PUBLISH_NAMED_SHAPES 指定したオブジェクトのグループ(存在する場合)を作成しますか? - - GEOM_SCALE_DIMENSIONS - インポートしたファイルの単位をミリメートルからメートルに変換しますか?いいえを選んだ場合、メートル単位として解釈します。 - GEOM_PRECISION_HINT パラメーターの入力値の精度を調整することは '%1' の好みにジオメトリ モジュールの。 @@ -5115,54 +5087,6 @@ GEOM_SELECT_IMAGE イメージの選択. - - MEN_IMPORTEXPORT - インポート/エクスポート - - - TOP_EXPORTXAO - エクスポートしました。 - - - MEN_EXPORTXAO - エクスポートしました。 - - - STB_EXPORTXAO - ソテーした形式でフォームをエクスポートします。 - - - TOP_IMPORTXAO - インポートしました。 - - - MEN_IMPORTXAO - インポートしました。 - - - STB_IMPORTXAO - ソテーしたフォームをインポートします。 - - - GEOM_IMPORTEXPORT_204 - エクスポートしました。 - - - GEOM_SELECT_IMPORT_XAO - XAOからインポート - - - GEOM_SELECT_EXPORT_XAO - エクスポートしました。 - - - XAO_FILES - ファイルした (*.xao) - - - TOOLS_IMPORTEXPORT - インポート/エクスポート - CC_PNT_ITEM_X_Y X=%1, Y=%2 @@ -6985,72 +6909,6 @@ (有効情報なし) - - ImportExportGUI_ExportXAODlg - - GEOM_EXPORTXAO_TITLE - エクスポートしました。 - - - GEOM_EXPORTXAO - エクスポートしました。 - - - GEOM_EXPORTXAO_EXPORTINGSHAPE - オブジェクト - - - GEOM_EXPORTXAO_FILENAME - ファイル - - - GEOM_EXPORTXAO_AUTHOR - 作成者 - - - GEOM_EXPORTXAO_LGROUPS - グループ - - - GEOM_EXPORTXAO_LFIELDS - フィールド - - - EXPORT_DLG_ACCEPT - OK - - - - ImportExportGUI_ImportXAODlg - - GEOM_IMPORTXAO_TITLE - インポートしました。 - - - GEOM_IMPORTXAO - インポートしました。 - - - GEOM_IMPORTXAO_IMPORTINGSHAPE - オブジェクト - - - GEOM_IMPORTXAO_FILENAME - ファイル - - - GEOM_IMPORTXAO_LGROUPS - グループ - - - GEOM_IMPORTXAO_LFIELDS - フィールド - - - STEP - Step - - EntityGUI_IsolineDlg diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 044f0692f..e5ec40e37 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -30,7 +30,6 @@ #include "GeometryGUI.h" #include "GeometryGUI_Operations.h" #include "GEOMPluginGUI.h" -#include "GEOMGUI_XmlHandler.h" #include "GEOMGUI_OCCSelector.h" #include "GEOMGUI_Selection.h" #include "GEOMGUI_CreationInfoWdg.h" @@ -38,6 +37,7 @@ #include "GEOM_Constants.h" #include "GEOM_Displayer.h" #include "GEOM_AISShape.hxx" +#include "GEOMUtils_XmlHandler.hxx" #include "GEOM_Actor.h" @@ -467,8 +467,6 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS createOriginAndBaseVectors(); // internal operation return; - case GEOMOp::OpImport: // MENU FILE - IMPORT - case GEOMOp::OpExport: // MENU FILE - EXPORT case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE @@ -665,10 +663,6 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS libName = "BlocksGUI"; break; - case GEOMOp::OpExportXAO: // MENU NEW ENTITY - IMPORTEXPORT - EXPORTXAO - case GEOMOp::OpImportXAO: // MENU NEW ENTITY - IMPORTEXPORT - IMPORTXAO - libName = "ImportExportGUI"; - break; //case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base) //case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE //case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS @@ -901,9 +895,6 @@ void GeometryGUI::initialize( CAM_Application* app ) // ----- create actions -------------- - createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I ); - createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E ); - createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete ); createGeomAction( GEOMOp::OpPoint, "POINT" ); @@ -1103,10 +1094,6 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false, "Geometry:Decrease number of isolines"); - // Import/Export XAO - createGeomAction( GEOMOp::OpExportXAO, "EXPORTXAO" ); - createGeomAction( GEOMOp::OpImportXAO, "IMPORTXAO" ); - //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" ); //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" ); //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" ); @@ -1116,13 +1103,6 @@ void GeometryGUI::initialize( CAM_Application* app ) // ---- create menus -------------------------- int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 ); - createMenu( separator(), fileId, 10 ); - createMenu( GEOMOp::OpImport, fileId, 10 ); - createMenu( GEOMOp::OpExport, fileId, 10 ); - int impexpId = createMenu( tr( "MEN_IMPORTEXPORT" ), fileId, -1, 10 ); - createMenu( GEOMOp::OpExportXAO, impexpId, -1 ); - createMenu( GEOMOp::OpImportXAO, impexpId, -1 ); - createMenu( separator(), fileId, -1 ); int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 ); createMenu( GEOMOp::OpDelete, editId, -1 ); @@ -1458,11 +1438,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpFeatureDetect, picturesTbId ); #endif - int impexpTbId = createTool( tr( "TOOL_IMPORTEXPORT" ), QString( "GEOMImportExportXAO" ) ); - createTool( GEOMOp::OpExportXAO, impexpTbId ); - createTool( GEOMOp::OpImportXAO, impexpTbId ); - - //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ), QString( "GEOMAdvanced" ) ); + //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //createTool( GEOMOp::OpSmoothingSurface, advancedTbId ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// @@ -1667,131 +1643,77 @@ void GeometryGUI::addPluginActions() SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); if (!resMgr) return; - // Find names of a resource XML files ("GEOMActions.xml" and others); - QString PluginsXml; - char* cenv = getenv("GEOM_PluginsList"); - if (cenv) - PluginsXml.sprintf("%s", cenv); - - QStringList PluginsXmlList = PluginsXml.split(":", QString::SkipEmptyParts); - if (PluginsXmlList.count() == 0) return; - - // get full names of xml files from PluginsXmlList - QStringList xmlFiles; - xmlFiles.append(QDir::home().filePath("CustomGeomPlugins.xml")); // may be inexistent - for (int i = 0; i < PluginsXmlList.count(); i++) { - PluginsXml = PluginsXmlList[ i ]; - - // Find full path to the resource XML file - QString xmlFile = resMgr->path("resources", "GEOM", PluginsXml + ".xml"); - if ( xmlFile.isEmpty() ) // try PLUGIN resources - xmlFile = resMgr->path("resources", PluginsXml, PluginsXml + ".xml"); - if ( !xmlFile.isEmpty() ) - xmlFiles.append( xmlFile ); - } - - // create "Advanced Operations" menu and corresponding toolbar - //int advancedMenuId = createMenu(tr("MEN_ADVANCED"), -1, -1, 10); - //int advancedTbarId = createTool(tr("TOOL_ADVANCED"), QString( "Advanced" )); - int id = GEOMOp::OpLastOperationID; // TODO? + SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); + if (!appStudy) return; - // loop on xmlFiles - QString aNoAccessFiles; - for (int i = 0; i < xmlFiles.count(); i++) { - QString xmlFile = xmlFiles[ i ]; - - QFile file (xmlFile); - if (file.exists() && file.open(QIODevice::ReadOnly)) { - file.close(); - - GEOMGUI_XmlHandler* aXmlHandler = new GEOMGUI_XmlHandler(); - ASSERT(aXmlHandler); - - QXmlInputSource source (&file); - QXmlSimpleReader reader; - reader.setContentHandler(aXmlHandler); - reader.setErrorHandler(aXmlHandler); - bool ok = reader.parse(source); - file.close(); - - if (ok) { - // bind action lib and label to its ID for activateOperation() method proper work - myPluginLibs[aXmlHandler->myPluginData.myName] = aXmlHandler->myPluginData.myClientLib; - - QListIterator anActionsIter (aXmlHandler->myPluginData.myListOfActions); - while (anActionsIter.hasNext()) { - GEOMGUI_ActionData anActionData = anActionsIter.next(); - - //QPixmap icon = resMgr->loadPixmap("GEOM", tr(anActionData.myIcon.toLatin1().constData())); - QPixmap icon = resMgr->loadPixmap(aXmlHandler->myPluginData.myName, - anActionData.myIcon.toLatin1().constData()); - - // path to action in menu - QStringList smenus = anActionData.myMenu.split( "/" ); - QString actionName = smenus.last(); - actionName = actionName.toUpper().prepend("MEN_"); - smenus.removeLast(); - - // path to action in toolbar - QStringList stools = anActionData.myTooltip.split( "/" ); - QString actionTool = stools.last(); - actionTool = actionTool.toUpper().prepend("TOP_"); - stools.removeLast(); - - QString actionStat = anActionData.myStatusBar; - actionStat = actionStat.toUpper().prepend("STB_"); - - createAction(id, // ~ anActionData.myLabel - tr(actionTool.toLatin1().constData()), - icon, - tr(actionName.toLatin1().constData()), - tr(actionStat.toLatin1().constData()), - 0 /*accel*/, - application()->desktop(), - false /*toggle*/, - this, SLOT(OnGUIEvent()), - QString() /*shortcutAction*/); - - int menuId = -1; - foreach (QString subMenu, smenus) { - subMenu = subMenu.toUpper().prepend("MEN_"); - menuId = createMenu(tr(subMenu.toLatin1().constData()), menuId, -1); - } - //createMenu(id, pluginMenuId, -1); - createMenu(id, menuId, -1); + // Find names of a resource XML files ("AdvancedGEOM.xml" and others); - QString subTool = stools[0]; - subTool = subTool.toUpper().prepend("TOOL_"); - int toolId = createTool(tr(subTool.toLatin1().constData()), subTool.toLatin1().constData()); - //createTool(id, advancedTbarId); - createTool(id, toolId); + GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo(); - // add action id to map - PluginAction anAction (aXmlHandler->myPluginData.myClientLib, anActionData.myLabel); - myPluginActions[id] = anAction; + int id = GEOMOp::OpLastOperationID; // TODO? - id++; - } + // loop on plugins + GEOMUtils::PluginInfo::const_iterator it; + for ( it = plugins.begin(); it != plugins.end(); ++it ) { + // bind action lib and label to its ID for activateOperation() method proper work + GEOMUtils::PluginData pdata = (*it); + myPluginLibs[pdata.name.c_str()] = pdata.clientLib.c_str(); + std::list actions = (*it).actions; + std::list::const_iterator ait; + for ( ait = actions.begin(); ait != actions.end(); ++ait ) { + GEOMUtils::ActionData adata = (*ait); + // icon + QPixmap icon; + if ( !adata.icon.empty() ) + icon = resMgr->loadPixmap( pdata.name.c_str(), adata.icon.c_str() ); + // menu text (path) + QStringList smenus = QString( adata.menuText.c_str() ).split( "/" ); + QString actionName = smenus.last(); + actionName = actionName.toUpper().prepend( "MEN_" ); + smenus.removeLast(); + + // path to action in toolbar + QStringList stools = QString( adata.toolTip.c_str() ).split( "/" ); + QString actionTool = stools.last(); + actionTool = actionTool.toUpper().prepend( "TOP_" ); + stools.removeLast(); + + QString actionStat = adata.statusText.c_str(); + actionStat = actionStat.toUpper().prepend( "STB_" ); + + createAction( id, // ~ adata.label + tr( actionTool.toLatin1().constData() ), + icon, + tr( actionName.toLatin1().constData() ), + tr( actionStat.toLatin1().constData() ), + QKeySequence( tr( adata.accel.c_str() ) ), + application()->desktop(), + false /*toggle*/, + this, SLOT( OnGUIEvent() ), + QString() /*shortcutAction*/ ); + + int menuId = -1; + foreach ( QString subMenu, smenus ) { + QStringList subMenuList = subMenu.split( ":" ); + QString subMenuName = subMenuList[0].toUpper().prepend( "MEN_" ); + int subMenuGroup = subMenuList.size() > 1 ? subMenuList[1].toInt() : -1; + menuId = createMenu( tr( subMenuName.toLatin1().constData() ), menuId, -1, subMenuGroup ); } - else { - SUIT_MessageBox::critical(application()->desktop(), - tr("INF_PARSE_ERROR"), - tr(aXmlHandler->errorProtocol().toLatin1().data())); + createMenu( id, menuId, -1 ); + + if ( !stools.isEmpty() ) { + QString subTool = stools[0]; + subTool = subTool.toUpper().prepend( "TOOL_" ); + int toolId = createTool( tr( subTool.toLatin1().constData() ) ); + createTool(id, toolId); } - delete aXmlHandler; - } - else if ( i > 0 ) { // 1st is ~/CustomGeomPlugins.xml - if (aNoAccessFiles.isEmpty()) - aNoAccessFiles = xmlFile; - else - aNoAccessFiles += ", " + xmlFile; - } - } // end loop on xmlFiles - if (!aNoAccessFiles.isEmpty()) { - QString aMess = QObject::tr("PLUGIN_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n"; - aMess += QObject::tr("PLUGIN_FILE_CHECK_VARIABLE"); - SUIT_MessageBox::warning(application()->desktop(), tr("GEOM_WRN_WARNING"), aMess); + // add action id to map + PluginAction anAction( pdata.clientLib.c_str(), adata.label.c_str() ); + myPluginActions[id] = anAction; + + id++; + } } } @@ -1832,8 +1754,6 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); // Reset actions accelerator keys - action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I - action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete GUIMap::Iterator it; @@ -1922,8 +1842,6 @@ bool GeometryGUI::deactivateModule( SUIT_Study* study ) it.value()->deactivate(); // Unset actions accelerator keys - action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I - action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete qDeleteAll(myOCCSelectors); @@ -2099,15 +2017,22 @@ void GeometryGUI::updateCreationInfo() SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); QString name = info->operationName.in(); if ( !name.isEmpty() ) { - icon = resMgr->loadPixmap( "GEOM", tr( ("ICO_"+name).toLatin1().constData() ), false ); + + QString plugin_name; + for ( size_t i = 0; i < info->params.length(); ++i ) { + myCreationInfoWdg->addParam( info->params[i].name.in(), + info->params[i].value.in() ); + QString value = info->params[i].name.in(); + if( value == PLUGIN_NAME ) { + plugin_name = info->params[i].value.in(); + } + } + QString prefix = plugin_name.isEmpty() ? "GEOM" : plugin_name; + icon = resMgr->loadPixmap( prefix, tr( ("ICO_"+name).toLatin1().constData() ), false ); operationName = tr( ("MEN_"+name).toLatin1().constData() ); if ( operationName.startsWith( "MEN_" )) operationName = name; // no translation myCreationInfoWdg->setOperation( icon, operationName ); - - for ( size_t i = 0; i < info->params.length(); ++i ) - myCreationInfoWdg->addParam( info->params[i].name.in(), - info->params[i].value.in() ); } } } diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index 4a109372a..f392e4df6 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -25,8 +25,6 @@ namespace GEOMOp { enum { // ToolsGUI --------------------//-------------------------------- - OpImport = 1000, // MENU FILE - IMPORT - OpExport = 1001, // MENU FILE - EXPORT OpDelete = 1020, // MENU EDIT - DELETE OpCheckGeom = 1030, // MENU TOOLS - CHECK GEOMETRY OpMaterialsLibrary = 1040, // MENU TOOLS - MATERIALS LIBRARY @@ -209,9 +207,6 @@ namespace GEOMOp { OpQuadFace = 6102, // MENU BLOCKS - QUADRANGLE FACE OpPropagate = 6103, // MENU BLOCKS - PROPAGATE OpExplodeBlock = 6104, // MENU BLOCKS - EXPLODE ON BLOCKS - // ImportExport ----------------//-------------------------------- - OpExportXAO = 6200, // MENU NEW ENTITY - IMPORTEXPORT - EXPORTXAO - OpImportXAO = 6201, // MENU NEW ENTITY - IMPORTEXPORT - IMPORTXAO // AdvancedGUI -----------------//-------------------------------- OpAdvancedNoOp = 10000, // NO OPERATION (advanced operations base) //OpPipeTShape = 10001, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE diff --git a/src/GEOMImpl/CMakeLists.txt b/src/GEOMImpl/CMakeLists.txt index 854c54755..0fb145931 100755 --- a/src/GEOMImpl/CMakeLists.txt +++ b/src/GEOMImpl/CMakeLists.txt @@ -65,9 +65,11 @@ SET(GEOMImpl_HEADERS GEOMImpl_ICurvesOperations.hxx GEOMImpl_ILocalOperations.hxx GEOMImpl_IInsertOperations.hxx + GEOMImpl_IECallBack.hxx GEOMImpl_IMeasureOperations.hxx GEOMImpl_IGroupOperations.hxx GEOMImpl_IFieldOperations.hxx + GEOMImpl_IBaseIEOperations.hxx GEOMImpl_IGlue.hxx GEOMImpl_PointDriver.hxx GEOMImpl_IPoint.hxx @@ -171,8 +173,6 @@ SET(GEOMImpl_HEADERS GEOMImpl_GlueDriver.hxx GEOMImpl_Types.hxx GEOM_GEOMImpl.hxx - GEOMImpl_IImportExportXAO.hxx - GEOMImpl_XAODriver.hxx ) # --- sources --- @@ -187,9 +187,11 @@ SET(GEOMImpl_SOURCES GEOMImpl_ICurvesOperations.cxx GEOMImpl_ILocalOperations.cxx GEOMImpl_IInsertOperations.cxx + GEOMImpl_IECallBack.cxx GEOMImpl_IMeasureOperations.cxx GEOMImpl_IGroupOperations.cxx GEOMImpl_IFieldOperations.cxx + GEOMImpl_IBaseIEOperations.cxx GEOMImpl_Gen.cxx GEOMImpl_PointDriver.cxx GEOMImpl_VectorDriver.cxx @@ -241,7 +243,6 @@ SET(GEOMImpl_SOURCES GEOMImpl_FillingDriver.cxx GEOMImpl_GlueDriver.cxx GEOMImpl_FieldDriver.cxx - GEOMImpl_XAODriver.cxx ) # --- rules --- diff --git a/src/GEOMImpl/GEOMImpl_ExportDriver.cxx b/src/GEOMImpl/GEOMImpl_ExportDriver.cxx index 84ad697e4..8e177e9a6 100644 --- a/src/GEOMImpl/GEOMImpl_ExportDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ExportDriver.cxx @@ -20,39 +20,19 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include +// internal includes +#include "GEOMImpl_ExportDriver.hxx" +#include "GEOMImpl_IImportExport.hxx" +#include "GEOMImpl_IECallBack.hxx" +#include "GEOMImpl_Types.hxx" -#include -#include -#include +// GEOM includes #include +// OCC includes +#include #include -#include - -#include - -#ifdef WIN32 -#include -#else -#include -#endif - -#ifdef WIN32 -#define LibHandle HMODULE -#define LoadLib( name ) LoadLibrary( name ) -#define GetProc GetProcAddress -#define UnLoadLib( handle ) FreeLibrary( handle ); -#else -#define LibHandle void* -#define LoadLib( name ) dlopen( name, RTLD_LAZY ) -#define GetProc dlsym -#define UnLoadLib( handle ) dlclose( handle ); -#endif - -typedef int (*funcPoint)(const TopoDS_Shape&, - const TCollection_AsciiString&, - const TCollection_AsciiString&); + //======================================================================= //function : GetID @@ -93,6 +73,11 @@ Standard_Integer GEOMImpl_ExportDriver::Execute(TFunction_Logbook& log) const // !!! set the result of function to be used by next operations aFunction->SetValue(aShape); + TDF_Label aLabel = aRefFunction->GetOwnerEntry(); + if (aLabel.IsRoot()) return 0; + Handle(GEOM_Object) obj = GEOM_Object::GetObject( aLabel ); + if ( obj.IsNull() ) return 0; + // retrieve the file and format names TCollection_AsciiString aFileName = aCI.GetFileName(); TCollection_AsciiString aFormatName = aCI.GetFormatName(); @@ -100,30 +85,12 @@ Standard_Integer GEOMImpl_ExportDriver::Execute(TFunction_Logbook& log) const if (aFileName.IsEmpty() || aFormatName.IsEmpty() || aLibName.IsEmpty()) return 0; - // load plugin library - LibHandle anExportLib = LoadLib( aLibName.ToCString() ); //This is workaround of BUG OCC13051 - funcPoint fp = 0; - if ( anExportLib ) - fp = (funcPoint)GetProc( anExportLib, "Export" ); - - if ( !fp ) { - TCollection_AsciiString aMsg = aFormatName; - aMsg += " plugin was not installed"; - Standard_Failure::Raise(aMsg.ToCString()); - } - - // perform the export - int res = fp( aShape, aFileName, aFormatName ); - - // unload plugin library - // commented by enk: - // the bug was occured: using ACIS Import/Export plugin - // UnLoadLib( anExportLib ); + if( !GEOMImpl_IECallBack::GetCallBack( aFormatName )->Export( GetDocID(), obj, aFileName, aFormatName ) ); + return 0; - if ( res ) - log.SetTouched(Label()); + log.SetTouched(Label()); - return res; + return 1; } //================================================================================ diff --git a/src/GEOMImpl/GEOMImpl_ExportDriver.hxx b/src/GEOMImpl/GEOMImpl_ExportDriver.hxx index d14f51be2..62933b053 100644 --- a/src/GEOMImpl/GEOMImpl_ExportDriver.hxx +++ b/src/GEOMImpl/GEOMImpl_ExportDriver.hxx @@ -26,23 +26,6 @@ #ifndef _GEOMImpl_ExportDriver_HeaderFile #define _GEOMImpl_ExportDriver_HeaderFile -#ifndef _TColStd_SequenceOfExtendedString_HeaderFile -#include -#endif -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif #ifndef _Standard_GUID_HeaderFile #include #endif diff --git a/src/GEOMImpl/GEOMImpl_Gen.cxx b/src/GEOMImpl/GEOMImpl_Gen.cxx index ae1418e27..081bf2125 100644 --- a/src/GEOMImpl/GEOMImpl_Gen.cxx +++ b/src/GEOMImpl/GEOMImpl_Gen.cxx @@ -83,7 +83,6 @@ #include #include #include -#include //============================================================================= /*! @@ -168,9 +167,6 @@ GEOMImpl_Gen::GEOMImpl_Gen() // Field TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FieldDriver::GetID(), new GEOMImpl_FieldDriver()); - // XAO operations - TFunction_DriverTable::Get()->AddDriver(GEOMImpl_XAODriver::GetID(), new GEOMImpl_XAODriver()); - /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ SetEngine(this); diff --git a/src/GEOMImpl/GEOMImpl_IBaseIEOperations.cxx b/src/GEOMImpl/GEOMImpl_IBaseIEOperations.cxx new file mode 100755 index 000000000..0f494319a --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBaseIEOperations.cxx @@ -0,0 +1,230 @@ +// 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 "GEOMImpl_IBaseIEOperations.hxx" +#include "GEOMImpl_IGroupOperations.hxx" +#include "GEOMImpl_IFieldOperations.hxx" +#include "GEOMImpl_IShapesOperations.hxx" + +// OCC includes +#include +#include +#include +#include +#include +#include + +typedef NCollection_DataMap< TCollection_ExtendedString, NCollection_List > + DataMapOfStringListOfShape; + +//============================================================================= +/*! + * constructor + */ +//============================================================================= +GEOMImpl_IBaseIEOperations::GEOMImpl_IBaseIEOperations(GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + myGroupOperations = new GEOMImpl_IGroupOperations( GetEngine(), GetDocID() ); + myFieldOperations = new GEOMImpl_IFieldOperations( GetEngine(), GetDocID() ); + myShapesOperations = new GEOMImpl_IShapesOperations( GetEngine(), GetDocID() ); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_IBaseIEOperations::~GEOMImpl_IBaseIEOperations() +{ + delete myGroupOperations; + delete myFieldOperations; + delete myShapesOperations; +} + +//============================================================================= +/*! + * This method creates material groups for an imported object. + * \param theObject the imported object. + */ +//============================================================================= +void GEOMImpl_IBaseIEOperations::MakeMaterialGroups + (const Handle(GEOM_Object) &theObject, + const Handle(TColStd_HSequenceOfTransient) &theSeq) +{ + TopoDS_Shape aResShape = theObject->GetValue(); + + if (aResShape.IsNull() == Standard_False) { + // Group shapes by material names. + Handle(GEOM_Function) aFunction = theObject->GetLastFunction(); + DataMapOfStringListOfShape aMapMaterialShapes; + + // check all named shapes using iterator + TDF_ChildIDIterator anIt (aFunction->GetNamingEntry(), + TNaming_NamedShape::GetID(), Standard_True); + + for (; anIt.More(); anIt.Next()) { + Handle(TNaming_NamedShape) anAttr = + Handle(TNaming_NamedShape)::DownCast(anIt.Value()); + + if (anAttr.IsNull() == Standard_False) { + TDF_Label aLabel = anAttr->Label(); + Handle(TDataStd_Comment) aComment; + + if (aLabel.FindAttribute(TDataStd_Comment::GetID(), aComment)) { + TCollection_ExtendedString aMatName = aComment->Get(); + TopoDS_Shape aShape = anAttr->Get(); + + if (aMapMaterialShapes.IsBound(aMatName) == Standard_False) { + NCollection_List anEmptyList; + + aMapMaterialShapes.Bind(aMatName, anEmptyList); + } + + aMapMaterialShapes(aMatName).Append(aShape); + } + } + } + + if (aMapMaterialShapes.IsEmpty() == Standard_False) { + // Construct groups. + TopAbs_ShapeEnum aType = aResShape.ShapeType(); + Standard_Integer i; + DataMapOfStringListOfShape::Iterator aMapIter; + + // Check each shape type. + for(i = aType; i <= TopAbs_VERTEX; i++) { + DataMapOfStringListOfShape::Iterator aMapIter(aMapMaterialShapes); + + for (; aMapIter.More(); aMapIter.Next()) { + NCollection_List &aShList = aMapIter.ChangeValue(); + NCollection_List::Iterator aShIter(aShList); + NCollection_List aShListSameType; + + while (aShIter.More()) { + const TopoDS_Shape &aShape = aShIter.Value(); + + if (i == aShape.ShapeType()) { + // Treat this element. + aShListSameType.Append(aShape); + aShList.Remove(aShIter); + } else { + // Go to the next element. + aShIter.Next(); + } + } + + if (aShListSameType.IsEmpty() == Standard_False) { + // Construct a group. + Handle(GEOM_Object) aGroup = + MakeGroup(theObject, aMapIter.Key(), aShListSameType); + + if (aGroup.IsNull() == Standard_False) { + theSeq->Append(aGroup); + } + } + } + } + } + } +} + + +//============================================================================= +/*! + * This method creates a group of shapes of certain type. + * \param theObject the imported object. + * \param theName the material name. + * \param theShapes the list of shapes to be added to this group. + * \return the created group. + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBaseIEOperations::MakeGroup + (const Handle(GEOM_Object) &theObject, + const TCollection_ExtendedString &theName, + const NCollection_List &theShapes) +{ + Handle(GEOM_Object) aGroup; + TopTools_IndexedMapOfShape anIndices; + Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger; + NCollection_List::Iterator anIter(theShapes); + + TopExp::MapShapes(theObject->GetValue(), anIndices); + + // Compose shape IDs. + for (; anIter.More(); anIter.Next()) { + const TopoDS_Shape &aShape = anIter.Value(); + const Standard_Integer anIndex = anIndices.FindIndex(aShape); + + if (anIndex > 0) { + aSeqIDs->Append(anIndex); + } + } + + if (aSeqIDs->IsEmpty() == Standard_False) { + // Create a group. + const TopAbs_ShapeEnum aType = theShapes.First().ShapeType(); + + aGroup = myGroupOperations->CreateGroup(theObject, aType); + + if (aGroup.IsNull() == Standard_False) { + aGroup->GetLastFunction()->SetDescription(""); + myGroupOperations->UnionIDs(aGroup, aSeqIDs); + aGroup->GetLastFunction()->SetDescription(""); + + // Compose the group name. + TCollection_AsciiString aGroupName(theName); + + switch(aType) { + case TopAbs_VERTEX: + aGroupName += "_VERTEX"; + break; + case TopAbs_EDGE: + aGroupName += "_EDGE"; + break; + case TopAbs_WIRE: + aGroupName += "_WIRE"; + break; + case TopAbs_FACE: + aGroupName += "_FACE"; + break; + case TopAbs_SHELL: + aGroupName += "_SHELL"; + break; + case TopAbs_SOLID: + aGroupName += "_SOLID"; + break; + case TopAbs_COMPSOLID: + aGroupName += "_COMPSOLID"; + break; + case TopAbs_COMPOUND: + aGroupName += "_COMPOUND"; + break; + default: + aGroupName += "_SHAPE"; + break; + } + + aGroup->SetName(aGroupName.ToCString()); + } + } + + return aGroup; +} diff --git a/src/GEOMImpl/GEOMImpl_IBaseIEOperations.hxx b/src/GEOMImpl/GEOMImpl_IBaseIEOperations.hxx new file mode 100644 index 000000000..c5c751b32 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBaseIEOperations.hxx @@ -0,0 +1,53 @@ +// 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 _GEOMImpl_IBaseIEOperations_HXX_ +#define _GEOMImpl_IBaseIEOperations_HXX_ + +// GEOM includes +#include + +// OCC includes +#include + +class GEOMImpl_IGroupOperations; +class GEOMImpl_IFieldOperations; +class GEOMImpl_IShapesOperations; + +class GEOMImpl_IBaseIEOperations : public GEOM_IOperations +{ +public: + Standard_EXPORT GEOMImpl_IBaseIEOperations(GEOM_Engine* theEngine, int theDocID); + Standard_EXPORT ~GEOMImpl_IBaseIEOperations(); + +protected: + void MakeMaterialGroups(const Handle(GEOM_Object) &theObject, + const Handle(TColStd_HSequenceOfTransient) &theSeq); + + Handle(GEOM_Object) MakeGroup + (const Handle(GEOM_Object) &theObject, + const TCollection_ExtendedString &theName, + const NCollection_List &theShapes); +protected: + GEOMImpl_IGroupOperations* myGroupOperations; + GEOMImpl_IFieldOperations* myFieldOperations; + GEOMImpl_IShapesOperations* myShapesOperations; +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IECallBack.cxx b/src/GEOMImpl/GEOMImpl_IECallBack.cxx new file mode 100755 index 000000000..1cd65c135 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IECallBack.cxx @@ -0,0 +1,115 @@ +// 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 "GEOMImpl_IECallBack.hxx" +#include "GEOMImpl_Gen.hxx" + +std::map GEOMImpl_IECallBack::myCallBacks; + +//============================================================================= +/*! + * constructor + */ +//============================================================================= +GEOMImpl_IECallBack::GEOMImpl_IECallBack() +{ +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_IECallBack::~GEOMImpl_IECallBack() +{ +} + +//============================================================================= +/*! + * GetEngine + */ +//============================================================================= +GEOMImpl_Gen* GEOMImpl_IECallBack::GetEngine() +{ + return dynamic_cast( GEOM_Engine::GetEngine() ); +} + +//============================================================================= +/*! + * Export + */ +//============================================================================= +bool GEOMImpl_IECallBack::Export( int /*theDocId*/, + const Handle(GEOM_Object) /*theOriginal*/, + const TCollection_AsciiString& /*theFileName*/, + const TCollection_AsciiString& /*theFormatName*/ ) +{ + return false; +} + +//============================================================================= +/*! + * Import + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +GEOMImpl_IECallBack::Import( int /*theDocId*/, + const TCollection_AsciiString& /*theFormatName*/, + const TCollection_AsciiString& /*theFileName*/ ) +{ + return NULL; +} + +//============================================================================= +/*! + * ReadValue + */ +//============================================================================= +TCollection_AsciiString +GEOMImpl_IECallBack::ReadValue( int /*theDocId*/, + const TCollection_AsciiString& /*theFileName*/, + const TCollection_AsciiString& /*theFormatName*/, + const TCollection_AsciiString& /*theParameterName*/ ) +{ + return ""; +} + +//============================================================================= +/*! + * Register + */ +//============================================================================= +void GEOMImpl_IECallBack::Register( const TCollection_AsciiString& theFormatName, + GEOMImpl_IECallBack* theCallBack ) +{ + myCallBacks[theFormatName] = theCallBack; +} + +//============================================================================= +/*! + * GetCallBack + */ +//============================================================================= +GEOMImpl_IECallBack* GEOMImpl_IECallBack::GetCallBack( const TCollection_AsciiString& theFormatName ) +{ + return myCallBacks.find(theFormatName) == myCallBacks.end() ? + new GEOMImpl_IECallBack() : myCallBacks[theFormatName]; +} + diff --git a/src/GEOMImpl/GEOMImpl_IECallBack.hxx b/src/GEOMImpl/GEOMImpl_IECallBack.hxx new file mode 100644 index 000000000..890e879d2 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IECallBack.hxx @@ -0,0 +1,67 @@ +// 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 _GEOMImpl_IECallBack_HXX_ +#define _GEOMImpl_IECallBack_HXX_ + +// GEOM includes +#include "GEOM_Object.hxx" + +// OCC includes +#include + +// C++ includes +#include + +class GEOMImpl_Gen; + +class GEOMImpl_IECallBack +{ + public: + Standard_EXPORT GEOMImpl_IECallBack(); + Standard_EXPORT ~GEOMImpl_IECallBack(); + + Standard_EXPORT virtual bool Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ); + + Standard_EXPORT virtual + Handle(TColStd_HSequenceOfTransient) Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ); + + Standard_EXPORT virtual + TCollection_AsciiString ReadValue( int theDocId, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theParameterName ); + + static void Register( const TCollection_AsciiString& theFormatName, GEOMImpl_IECallBack* theCallBack ); + + static GEOMImpl_IECallBack* GetCallBack( const TCollection_AsciiString& theFormatName ); + +protected: + GEOMImpl_Gen* GetEngine(); + +private: + static std::map myCallBacks; +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IImportExportXAO.hxx b/src/GEOMImpl/GEOMImpl_IImportExportXAO.hxx deleted file mode 100644 index bcbd4de28..000000000 --- a/src/GEOMImpl/GEOMImpl_IImportExportXAO.hxx +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2013-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 _GEOMImpl_IImportExportXAO_HXX_ -#define _GEOMImpl_IImportExportXAO_HXX_ - -#include "GEOM_Function.hxx" - -#define IMPORTEXPORTXAO_ARG_DATA 1 - -class GEOMImpl_IImportExportXAO -{ -public: - GEOMImpl_IImportExportXAO(Handle(GEOM_Function) theFunction): _func(theFunction) {} - - void SetData(const TCollection_AsciiString& data) { _func->SetString(IMPORTEXPORTXAO_ARG_DATA, data); } - const TCollection_AsciiString GetData() { return _func->GetString(IMPORTEXPORTXAO_ARG_DATA); } - -private: - Handle(GEOM_Function) _func; -}; - -#endif // _GEOMImpl_IExportXAO_HXX_ diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx index 86e7566d5..7e7606700 100755 --- a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx @@ -33,28 +33,12 @@ #include "GEOMImpl_IShapesOperations.hxx" #include "GEOMImpl_IGroupOperations.hxx" #include "GEOMImpl_IFieldOperations.hxx" -#include "GEOMImpl_XAODriver.hxx" -#include "GEOMImpl_IImportExportXAO.hxx" +#include "GEOMImpl_IECallBack.hxx" #include #include #include "GEOM_ISubShape.hxx" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include "utilities.h" @@ -89,15 +73,6 @@ #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC -/** - * This function returns the input format name from the original format name. - */ -static TCollection_AsciiString GetImportFormatName - (const TCollection_AsciiString& theFormatName) -{ - return theFormatName.Token("_"); -} - //============================================================================= /*! * constructor @@ -189,52 +164,8 @@ void GEOMImpl_IInsertOperations::Export if (theOriginal.IsNull()) return; - Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction(); - if (aRefFunction.IsNull()) return; //There is no function which creates an object to be exported - - //Add a new result object - Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT); - - //Add an Export function - Handle(GEOM_Function) aFunction = result->AddFunction(GEOMImpl_ExportDriver::GetID(), EXPORT_SHAPE); - if (aFunction.IsNull()) return; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_ExportDriver::GetID()) return; - - Handle(TCollection_HAsciiString) aHLibName; - if (!IsSupported(Standard_False, theFormatName, aHLibName)) { - return; - } - TCollection_AsciiString aLibName = aHLibName->String(); - - //Set parameters - GEOMImpl_IImportExport aCI (aFunction); - aCI.SetOriginal(aRefFunction); - aCI.SetFileName(theFileName); - aCI.SetFormatName(theFormatName); - aCI.SetPluginName(aLibName); - - //Perform the Export - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("Not enough space on disk, or you haven't permissions to write this directory"); - return; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); + if ( !GEOMImpl_IECallBack::GetCallBack( theFormatName )->Export( GetDocID(), theOriginal, theFileName, theFormatName ) ) return; - } - - //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal << ", \"" - << theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")"; - SetErrorCode(OK); } @@ -251,91 +182,9 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IInsertOperations::Import if (theFileName.IsEmpty() || theFormatName.IsEmpty()) return NULL; - //Add a new result object - Handle(GEOM_Object) anImported = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT); - - //Add an Import function - Handle(GEOM_Function) aFunction = - anImported->AddFunction(GEOMImpl_ImportDriver::GetID(), IMPORT_SHAPE); - - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return NULL; - - Handle(TCollection_HAsciiString) aHLibName; - if (!IsSupported - (Standard_True, GetImportFormatName(theFormatName), aHLibName)) { - return NULL; - } - TCollection_AsciiString aLibName = aHLibName->String(); - - //Set parameters - GEOMImpl_IImportExport aCI (aFunction); - aCI.SetFileName(theFileName); - aCI.SetFormatName(theFormatName); - aCI.SetPluginName(aLibName); - - //Perform the Import - Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; - - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("Import driver failed"); - return NULL; - } - - aSeq->Append(anImported); - - // Greate material groups. - MakeMaterialGroups(anImported, aSeq); - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - if (theFormatName != "IGES_UNIT") { - GEOM::TPythonDump pd (aFunction); - if (theFormatName == "BREP") - pd << aSeq << " = geompy.ImportBREP(\"" << theFileName.ToCString() << "\")"; - else if (theFormatName == "IGES") - pd << aSeq << " = geompy.ImportIGES(\"" << theFileName.ToCString() << "\")"; - else if (theFormatName == "IGES_SCALE") - pd << aSeq << " = geompy.ImportIGES(\"" << theFileName.ToCString() << "\", True)"; - else if (theFormatName == "STEP") - pd << aSeq << " = geompy.ImportSTEP(\"" << theFileName.ToCString() << "\")"; - else if (theFormatName == "STEP_SCALE") - pd << aSeq << " = geompy.ImportSTEP(\"" << theFileName.ToCString() << "\", True)"; - else { - pd << aSeq << " = geompy.ImportFile(\"" - << theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")"; - } - } - + Handle(TColStd_HSequenceOfTransient) aSeq = + GEOMImpl_IECallBack::GetCallBack( theFormatName )->Import( GetDocID(), theFormatName, theFileName ); SetErrorCode(OK); - - // OLD CODE: begin - if (theFormatName == "IGES_UNIT") { - TopoDS_Shape S = aFunction->GetValue(); - TopoDS_Vertex V = TopoDS::Vertex(S); - gp_Pnt P = BRep_Tool::Pnt(V); - double scale = P.X(); - TCollection_AsciiString aUnitName = "UNIT_M"; - if (fabs(scale-0.01) < 1.e-6) - aUnitName = "UNIT_CM"; - else if (fabs(scale-0.001) < 1.e-6) - aUnitName = "UNIT_MM"; - //cout<<"IIO: aUnitName = "<String(); - - aValue = GEOMImpl_ImportDriver::ReadValue(theFileName, aLibName, theParameterName, anError); - if (anError.IsEmpty()) - SetErrorCode(OK); - else - SetErrorCode(anError.ToCString()); + aValue = GEOMImpl_IECallBack::GetCallBack( theFormatName )->ReadValue( GetDocID(), theFileName, theFormatName, theParameterName ); + SetErrorCode(OK); return aValue; } -//============================================================================= -/*! - * ImportTranslators - */ -//============================================================================= -Standard_Boolean GEOMImpl_IInsertOperations::ImportTranslators - (Handle(TColStd_HSequenceOfAsciiString)& theFormats, - Handle(TColStd_HSequenceOfAsciiString)& thePatterns) -{ - if (theFormats.IsNull()) - theFormats = new TColStd_HSequenceOfAsciiString; - else - theFormats->Clear(); - - if (thePatterns.IsNull()) - thePatterns = new TColStd_HSequenceOfAsciiString; - else - thePatterns->Clear(); - - if (!InitResMgr()) return Standard_False; - - // Read Import formats from directories - Handle(Resource_Manager) aResMgr; - Handle(TColStd_HSequenceOfAsciiString) aFormatsToAdd; - for(int index = 0; index < myResMgrList.size(); index++) { - int anOldLen = theFormats->Length(); - aResMgr = myResMgrList.at(index); - if (aResMgr->Find("Import")) { - TCollection_AsciiString aFormats (aResMgr->Value("Import")); - TCollection_AsciiString aToken = aFormats.Token("| \t", 1); - for (int i = 1; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) { - int aLenFormats = theFormats->Length(); - bool isFound = false; - for(int aInd=1;aInd<=aLenFormats;aInd++){ - if( theFormats->Value(aInd) == aToken ){ - isFound = true; - break; - } - } - if(!isFound) - theFormats->Append(aToken); - } - } - - // Read Patterns for each supported format - for (int j = anOldLen+1; j <= theFormats->Length(); j++) { - TCollection_AsciiString aKey, aPattern; - aKey = theFormats->Value(j) + ".ImportPattern"; - if (aResMgr->Find(aKey.ToCString())) - aPattern = aResMgr->Value(aKey.ToCString()); - else { - aKey = theFormats->Value(j) + ".Pattern"; - if (aResMgr->Find(aKey.ToCString())) - aPattern = aResMgr->Value(aKey.ToCString()); - else { - aPattern = theFormats->Value(j); - aPattern += " Files ( *.* )"; - } - } - thePatterns->Append(aPattern); - } - } - - return (!theFormats->IsEmpty()); -} - -//============================================================================= -/*! - * ExportTranslators - */ -//============================================================================= -Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators - (Handle(TColStd_HSequenceOfAsciiString)& theFormats, - Handle(TColStd_HSequenceOfAsciiString)& thePatterns) -{ - if (theFormats.IsNull()) - theFormats = new TColStd_HSequenceOfAsciiString; - else - theFormats->Clear(); - - if (thePatterns.IsNull()) - thePatterns = new TColStd_HSequenceOfAsciiString; - else - thePatterns->Clear(); - - if (!InitResMgr()) return Standard_False; - - // Read Export formats list from directories - Handle(Resource_Manager) aResMgr; - for(int index=0; index < myResMgrList.size(); index++) { - int anOldLen = theFormats->Length(); - aResMgr = myResMgrList.at(index); - if (aResMgr->Find("Export")) { - TCollection_AsciiString aFormats (aResMgr->Value("Export")); - TCollection_AsciiString aToken = aFormats.Token("| \t", 1); - for (int i = 1; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) { - int aLenFormats = theFormats->Length(); - bool isFound = false; - for(int aInd=1;aInd<=aLenFormats;aInd++){ - if( theFormats->Value(aInd) == aToken){ - isFound = true; - break; - } - } - if(!isFound) - theFormats->Append(aToken); - } - } - - // Read Patterns for each supported format - for (int j = anOldLen+1; j <= theFormats->Length(); j++) { - TCollection_AsciiString aKey, aPattern; - aKey = theFormats->Value(j) + ".ExportPattern"; - if (aResMgr->Find(aKey.ToCString())) - aPattern = aResMgr->Value(aKey.ToCString()); - else { - aKey = theFormats->Value(j) + ".Pattern"; - if (aResMgr->Find(aKey.ToCString())) - aPattern = aResMgr->Value(aKey.ToCString()); - else { - aPattern = theFormats->Value(j); - aPattern += " Files ( *.* )"; - } - } - thePatterns->Append(aPattern); - } - } - - return (!theFormats->IsEmpty()); -} - -//============================================================================= -/*! - * IsSupported - */ -//============================================================================= -Standard_Boolean GEOMImpl_IInsertOperations::IsSupported - (const Standard_Boolean isImport, - const TCollection_AsciiString& theFormat, - Handle(TCollection_HAsciiString)& theLibName) -{ - if (!InitResMgr()) return Standard_False; - - // Import/Export mode - TCollection_AsciiString aMode; - //Standard_CString aMode; - if (isImport) aMode = "Import"; - else aMode = "Export"; - - // Read supported formats for the certain mode from user directory - Handle(Resource_Manager) aResMgr; - for(int index=0; index < myResMgrList.size(); index++) { - aResMgr = myResMgrList.at(index); - if (aResMgr->Find(aMode.ToCString())) { - TCollection_AsciiString aFormats (aResMgr->Value(aMode.ToCString())); - if (aFormats.Search(theFormat) > -1) { - // Read library name for the supported format - TCollection_AsciiString aKey (theFormat); - aKey += "."; - aKey += aMode; - if (aResMgr->Find(aKey.ToCString())) { - TCollection_AsciiString aLibName (aResMgr->Value(aKey.ToCString())); - #ifndef WIN32 - if ( aLibName.Length() > 3 && aLibName.SubString(1,3) != "lib" ) - aLibName.Prepend("lib"); - aLibName += ".so"; - #else - aLibName += ".dll"; - #endif - theLibName = new TCollection_HAsciiString (aLibName); - return Standard_True; - } - } - } - } - - return Standard_False; -} - -//============================================================================= -/*! - * InitResMgr - */ -//============================================================================= -Standard_Boolean GEOMImpl_IInsertOperations::InitResMgr() -{ - bool isResourceFound = false; - TCollection_AsciiString aNull; - - myResMgrList.clear(); - - // Initialize the GEOM Resource Manager - TCollection_AsciiString aResDir; - aResDir = getenv("GEOM_ROOT_DIR"); -#ifdef WIN32 - aResDir += "\\share\\salome\\resources\\geom"; -#else - aResDir += "/share/salome/resources/geom"; -#endif - Handle(Resource_Manager) aGeomResMgr = new Resource_Manager ("ImportExport", aResDir, aNull, Standard_False); - if ( aGeomResMgr->Find("Import") || aGeomResMgr->Find("Export") ) { - myResMgrList.push_back( aGeomResMgr ); - isResourceFound = true; - } - - // Initialize the user's Resource Manager - TCollection_AsciiString aResDirsStr; - aResDirsStr = getenv("GEOM_ENGINE_RESOURCES_DIR"); - if ( !aResDirsStr.IsEmpty() ) - { - std::string aSep = ":"; -#ifdef WIN32 - aSep = ";"; -#endif - aResDir = aResDirsStr.Token(aSep.c_str(), 1); - for (int i = 1; !aResDir.IsEmpty(); aResDir = aResDirsStr.Token(aSep.c_str(), ++i)) { - Handle(Resource_Manager) anUserResMgr = new Resource_Manager ("ImportExport", aNull, aResDir, Standard_False); - if (anUserResMgr->Find("Import") || anUserResMgr->Find("Export")) { - myResMgrList.push_back( anUserResMgr ); - isResourceFound = true; - } - } - } - else - { - aResDir = getenv("HOME"); -#ifdef WIN32 - aResDir += "\\.config\\salome"; -#else - aResDir += "/.config/salome"; -#endif - Handle(Resource_Manager) anUserResMgr = new Resource_Manager ("ImportExport", aNull, aResDir, Standard_False); - if (anUserResMgr->Find("Import") || anUserResMgr->Find("Export")) { - myResMgrList.push_back( anUserResMgr ); - isResourceFound = true; - } - } - return isResourceFound; -} - //============================================================================= /*! * RestoreShape @@ -769,763 +366,3 @@ std::list GEOMImpl_IInsertOperations::GetAllTextures() SetErrorCode(OK); return id_list; } - -TopAbs_ShapeEnum getGroupDimension(XAO::Group* group) -{ - XAO::Dimension dim = group->getDimension(); - TopAbs_ShapeEnum rdim; - switch ( dim ) - { - case XAO::VERTEX: - rdim = TopAbs_VERTEX; break; - case XAO::EDGE: - rdim = TopAbs_EDGE; break; - case XAO::FACE: - rdim = TopAbs_FACE; break; - case XAO::SOLID: - rdim = TopAbs_SOLID; break; - default: - rdim = TopAbs_COMPOUND; break; - } - return rdim; -} - -XAO::Dimension shapeEnumToDimension(const TopAbs_ShapeEnum& shape) -{ - XAO::Dimension dim; - switch( shape ) { - case TopAbs_VERTEX: - dim = XAO::VERTEX; break; - case TopAbs_EDGE: - dim = XAO::EDGE; break; - case TopAbs_FACE: - dim = XAO::FACE; break; - case TopAbs_SOLID: - dim = XAO::SOLID; break; - default: - throw SALOME_Exception("Bad type"); // TODO - } - return dim; -} - -void GEOMImpl_IInsertOperations::exportGroups(std::list groupList, - XAO::Xao* xaoObject, - XAO::BrepGeometry* geometry) -{ - // add the groups - std::list::iterator groupIterator = groupList.begin(); - while (groupIterator != groupList.end()) - { - Handle(GEOM_Object) currGroup = (*groupIterator++); - Handle(TColStd_HArray1OfInteger) groupIds = myGroupOperations->GetObjects(currGroup); - - TopAbs_ShapeEnum shapeGroup = myGroupOperations->GetType(currGroup); - XAO::Dimension dim = shapeEnumToDimension(shapeGroup); - XAO::Group* group = xaoObject->addGroup(dim, currGroup->GetName().ToCString()); - - switch (shapeGroup) - { - case TopAbs_VERTEX: - for (int i = 1; i <= groupIds->Length(); i++) - { - std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i)); - int index = geometry->getVertexIndexByReference(ref); - group->add(index); - } - break; - case TopAbs_EDGE: - for (int i = 1; i <= groupIds->Length(); i++) - { - std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i)); - int index = geometry->getEdgeIndexByReference(ref); - group->add(index); - } - break; - case TopAbs_FACE: - for (int i = 1; i <= groupIds->Length(); i++) - { - std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i)); - int index = geometry->getFaceIndexByReference(ref); - group->add(index); - } - break; - case TopAbs_SOLID: - for (int i = 1; i <= groupIds->Length(); i++) - { - std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i)); - int index = geometry->getSolidIndexByReference(ref); - group->add(index); - } - break; - } - } -} - -void GEOMImpl_IInsertOperations::exportFields(std::list fieldList, - XAO::Xao* xaoObject, - XAO::BrepGeometry* geometry) -{ - std::list::iterator fieldIterator = fieldList.begin(); - while (fieldIterator != fieldList.end()) - { - Handle(GEOM_Field) currField = (*fieldIterator++); - - int fdim = currField->GetDimension(); - int ftype = currField->GetDataType(); - int nbComponents = currField->GetNbComponents(); - std::string name = currField->GetName().ToCString(); - - XAO::Field* field = xaoObject->addField((XAO::Type)ftype, (XAO::Dimension)fdim, nbComponents, name); - - Handle(TColStd_HArray1OfExtendedString) components = currField->GetComponents(); - for (int i = components->Lower(), j = 0; i <= components->Upper(); ++i, ++j) - { - field->setComponentName(j, TCollection_AsciiString(components->Value(i)).ToCString()); - } - - std::list< Handle(GEOM_FieldStep)> steps = currField->GetSteps(); - std::list::iterator stepIterator = steps.begin(); - while (stepIterator != steps.end()) - { - Handle(GEOM_FieldStep) currStep = (*stepIterator++); - - XAO::Step* step = field->addNewStep(currStep->GetID()); - step->setStamp(currStep->GetStamp()); - - switch (ftype) - { - case 0: // bool - { - XAO::BooleanStep* bs = (XAO::BooleanStep*)step; - Handle(TColStd_HArray1OfInteger) bvalues = currStep->GetIntValues(); - std::vector bv; - bv.reserve(bvalues->Upper()); - for ( int i = bvalues->Lower(), nb = bvalues->Upper(); i <= nb; ++i ) - { - bv.push_back(bvalues->Value(i) != 0); - } - bs->setValues(bv); - break; - } - case 1: // integer - { - XAO::IntegerStep* is = (XAO::IntegerStep*)step; - Handle(TColStd_HArray1OfInteger) ivalues = currStep->GetIntValues(); - std::vector iv; - iv.reserve(ivalues->Upper()); - for ( int i = ivalues->Lower(), nb = ivalues->Upper(); i <= nb; ++i ) - { - iv.push_back(ivalues->Value(i)); - } - is->setValues(iv); - break; - } - case 2: // double - { - XAO::DoubleStep* ds = (XAO::DoubleStep*)step; - Handle(TColStd_HArray1OfReal) dvalues = currStep->GetDoubleValues(); - std::vector dv; - dv.reserve(dvalues->Upper()); - for ( int i = dvalues->Lower(), nb = dvalues->Upper(); i <= nb; ++i ) - { - dv.push_back(dvalues->Value(i)); - } - ds->setValues(dv); - break; - } - case 3: // string - { - XAO::StringStep* ss = (XAO::StringStep*)step; - Handle(TColStd_HArray1OfExtendedString) svalues = currStep->GetStringValues(); - std::vector sv; - sv.reserve(svalues->Upper()); - for ( int i = svalues->Lower(), nb = svalues->Upper(); i <= nb; ++i ) - { - sv.push_back(TCollection_AsciiString(svalues->Value(i)).ToCString()); - } - ss->setValues(sv); - break; - } - } - } - } -} - -void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry) -{ - Handle(TColStd_HSequenceOfTransient) subObjects = myShapesOperations->GetExistingSubObjects(shape, false); - int nbSubObjects = subObjects->Length(); - // set the names of the sub shapes - for (int i = 1; i <= nbSubObjects; i++) - { - Handle(Standard_Transient) transientSubObject = subObjects->Value(i); - if (transientSubObject.IsNull()) - continue; - - Handle(GEOM_Object) subObject = Handle(GEOM_Object)::DownCast(transientSubObject); - if (subObject->GetType() != GEOM_GROUP) - { - int subIndex = myShapesOperations->GetSubShapeIndex(shape, subObject); - switch (subObject->GetValue().ShapeType()) - { - case TopAbs_VERTEX: - geometry->changeVertexName(subIndex, subObject->GetName().ToCString()); - break; - case TopAbs_EDGE: - geometry->changeEdgeName(subIndex, subObject->GetName().ToCString()); - break; - case TopAbs_FACE: - geometry->changeFaceName(subIndex, subObject->GetName().ToCString()); - break; - case TopAbs_SOLID: - geometry->changeSolidName(subIndex, subObject->GetName().ToCString()); - break; - } - } - } -} - -//============================================================================= -/*! - * Export a shape to XAO format - * \param shape The shape to export - * \param groups The list of groups to export - * \param fields The list of fields to export - * \param fileName The name of the file to exported - * \return boolean indicating if export was succeful. - */ -//============================================================================= -bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape, - std::list groupList, - std::list fieldList, - const char* author, - const char* fileName) -{ - SetErrorCode(KO); - - if (shape.IsNull()) return false; - - // add a new shape function with parameters - Handle(GEOM_Function) lastFunction = shape->GetLastFunction(); - if (lastFunction.IsNull()) return false; - - // add a new result object - Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT); - - // add an Export function - Handle(GEOM_Function) exportFunction = result->AddFunction(GEOMImpl_XAODriver::GetID(), IMPORTEXPORT_EXPORTXAO); - if (exportFunction.IsNull()) return false; - if (exportFunction->GetDriverGUID() != GEOMImpl_XAODriver::GetID()) return false; - - // create the XAO object - XAO::Xao* xaoObject = new XAO::Xao(); - xaoObject->setAuthor(author); - - // add the geometry - XAO::BrepGeometry* geometry = (XAO::BrepGeometry*)XAO::Geometry::createGeometry(XAO::BREP); - TopoDS_Shape topoShape = shape->GetValue(); - exportFunction->SetValue(topoShape); - XAO::BrepGeometry* brep = (XAO::BrepGeometry*)geometry; - brep->setTopoDS_Shape(topoShape); - - geometry->setName(shape->GetName().ToCString()); - exportSubshapes(shape, geometry); - xaoObject->setGeometry(geometry); - - exportGroups(groupList, xaoObject, geometry); - exportFields(fieldList, xaoObject, geometry); - - // export the XAO to the file - xaoObject->exportXAO(fileName); - - // make a Python command - GEOM::TPythonDump pd(exportFunction); - pd << "exported = geompy.ExportXAO(" << shape; - - // list of groups - pd << ", ["; - if (groupList.size() > 0) - { - std::list::iterator itGroup = groupList.begin(); - pd << (*itGroup++); - while (itGroup != groupList.end()) - { - pd << ", " << (*itGroup++); - } - } - - // list of fields - pd << "], ["; - if (fieldList.size() > 0) - { - std::list::iterator itField = fieldList.begin(); - pd << (*itField++); - while (itField != fieldList.end()) - { - pd << ", " << (*itField++); - } - } - pd << "], "; - pd << "\"" << author << "\", \"" << fileName << "\")"; - - SetErrorCode(OK); - delete xaoObject; - - return true; -} - -void GEOMImpl_IInsertOperations::importSubShapes(XAO::Geometry* xaoGeometry, - Handle(GEOM_Function) function, int shapeType, int dim, - Handle(TColStd_HSequenceOfTransient)& subShapeList) -{ - Handle(GEOM_Object) subShape; - Handle(GEOM_Function) aFunction; - Handle(TColStd_HArray1OfInteger) anArray; - - XAO::GeometricElementList::iterator elementIterator = xaoGeometry->begin((XAO::Dimension)dim); - for (; elementIterator != xaoGeometry->end((XAO::Dimension)dim); elementIterator++) - { - XAO::GeometricElement element = elementIterator->second; - if (!element.hasName()) - continue; - - std::string name = element.getName(); - std::string ref = element.getReference(); - int iref = XAO::XaoUtils::stringToInt(ref); - - anArray = new TColStd_HArray1OfInteger(1, 1); - anArray->SetValue(1, iref); - - subShape = GetEngine()->AddObject(GetDocID(), GEOM_SUBSHAPE); - Handle(GEOM_Function) aFunction = subShape->AddFunction(GEOM_Object::GetSubShapeID(), 1); - if (aFunction.IsNull()) - return; - - subShape->SetName(name.c_str()); - subShape->SetType(shapeType); - - GEOM_ISubShape aSSI(aFunction); - aSSI.SetMainShape(function); - aSSI.SetIndices(anArray); - - //aFunction->SetValue(aValue); - subShapeList->Append(subShape); - - // Put this subshape in the list of sub-shapes of theMainShape - function->AddSubShapeReference(aFunction); - } -} - -//============================================================================= -/*! - * Import a shape from XAO format - * \param fileName The name of the file to import - * \param shape The imported shape - * \param subShapes The list of imported groups - * \param groups The list of imported groups - * \param fields The list of imported fields - * \return boolean indicating if import was succeful. - */ -//============================================================================= -bool GEOMImpl_IInsertOperations::ImportXAO(const char* fileName, - Handle(GEOM_Object)& shape, - Handle(TColStd_HSequenceOfTransient)& subShapes, - Handle(TColStd_HSequenceOfTransient)& groups, - Handle(TColStd_HSequenceOfTransient)& fields) -{ - SetErrorCode(KO); - - if (fileName == NULL || groups.IsNull() || fields.IsNull()) - return false; - - // Read the XAO - XAO::Xao* xaoObject = new XAO::Xao(); - try - { - xaoObject->importXAO(fileName); - } - catch (XAO::XAO_Exception& exc) - { - delete xaoObject; - SetErrorCode(exc.what()); - return false; - } - - XAO::Geometry* xaoGeometry = xaoObject->getGeometry(); - if (xaoGeometry == NULL) - { - delete xaoObject; - SetErrorCode("Cannot import XAO: geometry format not supported."); - return false; - } - - // create the shape - shape = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT); - Handle(GEOM_Function) function = shape->AddFunction(GEOMImpl_XAODriver::GetID(), IMPORTEXPORT_EXPORTXAO); - if (function.IsNull()) return false; - if (function->GetDriverGUID() != GEOMImpl_XAODriver::GetID()) return false; - - // set the geometry - if (xaoGeometry->getFormat() == XAO::BREP) - { - XAO::BrepGeometry* brep = (XAO::BrepGeometry*)xaoGeometry; - TopoDS_Shape geomShape = brep->getTopoDS_Shape(); - function->SetValue(geomShape); - shape->SetName(xaoGeometry->getName().c_str()); - } - else - { - delete xaoObject; - SetErrorCode("Cannot import XAO: geometry format not supported."); - return false; - } - - // create sub shapes with names - importSubShapes(xaoGeometry, function, GEOM_POINT, XAO::VERTEX, subShapes); - importSubShapes(xaoGeometry, function, GEOM_EDGE, XAO::EDGE, subShapes); - importSubShapes(xaoGeometry, function, GEOM_FACE, XAO::FACE, subShapes); - importSubShapes(xaoGeometry, function, GEOM_SOLID, XAO::SOLID, subShapes); - - // create groups - int nbGroups = xaoObject->countGroups(); - for (int i = 0; i < nbGroups; ++i) - { - XAO::Group* xaoGroup = xaoObject->getGroup(i); - - // build an array with the indexes of the sub shapes - int nbElt = xaoGroup->count(); - Handle(TColStd_HArray1OfInteger) array = new TColStd_HArray1OfInteger(1, nbElt); - int j = 0; - for (std::set::iterator it = xaoGroup->begin(); it != xaoGroup->end(); ++it) - { - int index = (*it); - std::string ref = xaoGeometry->getElementReference(xaoGroup->getDimension(), index); - array->SetValue(++j, XAO::XaoUtils::stringToInt(ref)); - } - - // create the group with the array of sub shapes indexes - Handle(GEOM_Object) group = GetEngine()->AddSubShape(shape, array); - group->SetType(GEOM_GROUP); - group->SetName(xaoGroup->getName().c_str()); - - // Set a sub-shape type - TDF_Label freeLabel = group->GetFreeLabel(); - TDataStd_Integer::Set(freeLabel, (Standard_Integer) getGroupDimension(xaoGroup)); - groups->Append(group); - - function = group->GetLastFunction(); - } - - // create the fields - int nbFields = xaoObject->countFields(); - for (int i = 0; i < nbFields; ++i) - { - XAO::Field* xaoField = xaoObject->getField(i); - - Handle(TColStd_HArray1OfExtendedString) components = new TColStd_HArray1OfExtendedString(0, xaoField->countComponents()-1); - for (int j = 0; j < xaoField->countComponents(); ++j) - { - components->SetValue(j, (TCollection_ExtendedString)xaoField->getComponentName(j).c_str()); - } - - Handle(GEOM_Field) field = myFieldOperations->CreateField(shape, - xaoField->getName().c_str(), - (int)xaoField->getType(), - (int)xaoField->getDimension(), - components); - - switch (xaoField->getType()) - { - case XAO::BOOLEAN: - { - XAO::BooleanField* bfield = (XAO::BooleanField*)xaoField; - for (int j = 0; j < xaoField->countSteps(); ++j) - { - XAO::BooleanStep* bstep = bfield->getStep(j); - Handle(GEOM_FieldStep) step = field->AddStep(bstep->getStep(), bstep->getStamp()); - - Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, bstep->countValues()-1); - std::vector bvalues = bstep->getValues(); - for (int k = 0; k < bstep->countValues(); ++k) - { - values->SetValue(k, bvalues[k] ? 1 : 0); - } - step->SetValues(values); - } - break; - } - case XAO::INTEGER: - { - XAO::IntegerField* ifield = (XAO::IntegerField*)xaoField; - for (int j = 0; j < xaoField->countSteps(); ++j) - { - XAO::IntegerStep* istep = ifield->getStep(j); - Handle(GEOM_FieldStep) step = field->AddStep(istep->getStep(), istep->getStamp()); - - Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, istep->countValues()-1); - std::vector ivalues = istep->getValues(); - for (int k = 0; k < istep->countValues(); ++k) - { - values->SetValue(k, ivalues[k]); - } - step->SetValues(values); - } - break; - } - case XAO::DOUBLE: - { - XAO::DoubleField* dfield = (XAO::DoubleField*)xaoField; - for (int j = 0; j < xaoField->countSteps(); ++j) - { - XAO::DoubleStep* dstep = dfield->getStep(j); - Handle(GEOM_FieldStep) step = field->AddStep(dstep->getStep(), dstep->getStamp()); - - Handle(TColStd_HArray1OfReal) values = new TColStd_HArray1OfReal(0, dstep->countValues()-1); - std::vector dvalues = dstep->getValues(); - for (int k = 0; k < dstep->countValues(); ++k) - { - values->SetValue(k, dvalues[k]); - } - step->SetValues(values); - } - break; - } - case XAO::STRING: - { - XAO::StringField* sfield = (XAO::StringField*)xaoField; - for (int j = 0; j < xaoField->countSteps(); ++j) - { - XAO::StringStep* sstep = sfield->getStep(j); - Handle(GEOM_FieldStep) step = field->AddStep(sstep->getStep(), sstep->getStamp()); - - Handle(TColStd_HArray1OfExtendedString) values = new TColStd_HArray1OfExtendedString(0, sstep->countValues()-1); - std::vector svalues = sstep->getValues(); - for (int k = 0; k < sstep->countValues(); ++k) - { - values->SetValue(k, TCollection_ExtendedString(svalues[k].c_str())); - } - step->SetValues(values); - } - break; - } - } - - fields->Append(field); - } - - // make a Python command - GEOM::TPythonDump pd(function); - pd << "(imported, " << shape << ", "; - - // list of sub shapes - pd << "["; - int nbSubshapes = subShapes->Length(); - if (nbSubshapes > 0) - { - for (int i = 1; i <= nbSubshapes; i++) - { - Handle(GEOM_Object) obj = Handle(GEOM_Object)::DownCast(subShapes->Value(i)); - pd << obj << ((i < nbSubshapes) ? ", " : ""); - } - } - pd << "], ["; - - // list of groups - if (nbGroups > 0) - { - for (int i = 1; i <= nbGroups; i++) - { - Handle(GEOM_Object) obj = Handle(GEOM_Object)::DownCast(groups->Value(i)); - pd << obj << ((i < nbGroups) ? ", " : ""); - } - } - - pd << "], ["; - - // list of fields - if (nbFields > 0) - { - for (int i = 1; i <= nbFields; i++) - { - Handle(GEOM_Field) obj = Handle(GEOM_Field)::DownCast(fields->Value(i)); - pd << obj << ((i < nbFields) ? ", " : ""); - } - } - pd << "]"; - pd << ") = geompy.ImportXAO(\"" << fileName << "\")"; - - delete xaoObject; - SetErrorCode(OK); - - return true; -} - -//============================================================================= -/*! - * This method creates material groups for an imported object. - * \param theObject the imported object. - */ -//============================================================================= -void GEOMImpl_IInsertOperations::MakeMaterialGroups - (const Handle(GEOM_Object) &theObject, - const Handle(TColStd_HSequenceOfTransient) &theSeq) -{ - TopoDS_Shape aResShape = theObject->GetValue(); - - if (aResShape.IsNull() == Standard_False) { - // Group shapes by material names. - Handle(GEOM_Function) aFunction = theObject->GetLastFunction(); - DataMapOfStringListOfShape aMapMaterialShapes; - - // check all named shapes using iterator - TDF_ChildIDIterator anIt (aFunction->GetNamingEntry(), - TNaming_NamedShape::GetID(), Standard_True); - - for (; anIt.More(); anIt.Next()) { - Handle(TNaming_NamedShape) anAttr = - Handle(TNaming_NamedShape)::DownCast(anIt.Value()); - - if (anAttr.IsNull() == Standard_False) { - TDF_Label aLabel = anAttr->Label(); - Handle(TDataStd_Comment) aComment; - - if (aLabel.FindAttribute(TDataStd_Comment::GetID(), aComment)) { - TCollection_ExtendedString aMatName = aComment->Get(); - TopoDS_Shape aShape = anAttr->Get(); - - if (aMapMaterialShapes.IsBound(aMatName) == Standard_False) { - NCollection_List anEmptyList; - - aMapMaterialShapes.Bind(aMatName, anEmptyList); - } - - aMapMaterialShapes(aMatName).Append(aShape); - } - } - } - - if (aMapMaterialShapes.IsEmpty() == Standard_False) { - // Construct groups. - TopAbs_ShapeEnum aType = aResShape.ShapeType(); - Standard_Integer i; - DataMapOfStringListOfShape::Iterator aMapIter; - - // Check each shape type. - for(i = aType; i <= TopAbs_VERTEX; i++) { - DataMapOfStringListOfShape::Iterator aMapIter(aMapMaterialShapes); - - for (; aMapIter.More(); aMapIter.Next()) { - NCollection_List &aShList = aMapIter.ChangeValue(); - NCollection_List::Iterator aShIter(aShList); - NCollection_List aShListSameType; - - while (aShIter.More()) { - const TopoDS_Shape &aShape = aShIter.Value(); - - if (i == aShape.ShapeType()) { - // Treat this element. - aShListSameType.Append(aShape); - aShList.Remove(aShIter); - } else { - // Go to the next element. - aShIter.Next(); - } - } - - if (aShListSameType.IsEmpty() == Standard_False) { - // Construct a group. - Handle(GEOM_Object) aGroup = - MakeGroup(theObject, aMapIter.Key(), aShListSameType); - - if (aGroup.IsNull() == Standard_False) { - theSeq->Append(aGroup); - } - } - } - } - } - } -} - - -//============================================================================= -/*! - * This method creates a group of shapes of certain type. - * \param theObject the imported object. - * \param theName the material name. - * \param theShapes the list of shapes to be added to this group. - * \return the created group. - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeGroup - (const Handle(GEOM_Object) &theObject, - const TCollection_ExtendedString &theName, - const NCollection_List &theShapes) -{ - Handle(GEOM_Object) aGroup; - TopTools_IndexedMapOfShape anIndices; - Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger; - NCollection_List::Iterator anIter(theShapes); - - TopExp::MapShapes(theObject->GetValue(), anIndices); - - // Compose shape IDs. - for (; anIter.More(); anIter.Next()) { - const TopoDS_Shape &aShape = anIter.Value(); - const Standard_Integer anIndex = anIndices.FindIndex(aShape); - - if (anIndex > 0) { - aSeqIDs->Append(anIndex); - } - } - - if (aSeqIDs->IsEmpty() == Standard_False) { - // Create a group. - const TopAbs_ShapeEnum aType = theShapes.First().ShapeType(); - - aGroup = myGroupOperations->CreateGroup(theObject, aType); - - if (aGroup.IsNull() == Standard_False) { - aGroup->GetLastFunction()->SetDescription(""); - myGroupOperations->UnionIDs(aGroup, aSeqIDs); - aGroup->GetLastFunction()->SetDescription(""); - - // Compose the group name. - TCollection_AsciiString aGroupName(theName); - - switch(aType) { - case TopAbs_VERTEX: - aGroupName += "_VERTEX"; - break; - case TopAbs_EDGE: - aGroupName += "_EDGE"; - break; - case TopAbs_WIRE: - aGroupName += "_WIRE"; - break; - case TopAbs_FACE: - aGroupName += "_FACE"; - break; - case TopAbs_SHELL: - aGroupName += "_SHELL"; - break; - case TopAbs_SOLID: - aGroupName += "_SOLID"; - break; - case TopAbs_COMPSOLID: - aGroupName += "_COMPSOLID"; - break; - case TopAbs_COMPOUND: - aGroupName += "_COMPOUND"; - break; - default: - aGroupName += "_SHAPE"; - break; - } - - aGroup->SetName(aGroupName.ToCString()); - } - } - - return aGroup; -} diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx index c3c982fec..e205f024a 100644 --- a/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx @@ -51,15 +51,6 @@ class Handle_TColStd_HArray1OfByte; class Handle_TDataStd_HArray1OfByte; #endif -namespace XAO { - class Geometry; - class BrepGeometry; - class Xao; -} - -typedef NCollection_DataMap > - DataMapOfStringListOfShape; - class GEOMImpl_IInsertOperations : public GEOM_IOperations { public: Standard_EXPORT GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID); @@ -80,16 +71,6 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations { const TCollection_AsciiString& theFileName, const TCollection_AsciiString& theFormatType); - Standard_EXPORT Standard_Boolean ImportTranslators (Handle(TColStd_HSequenceOfAsciiString)& theFormats, - Handle(TColStd_HSequenceOfAsciiString)& thePatterns); - - Standard_EXPORT Standard_Boolean ExportTranslators (Handle(TColStd_HSequenceOfAsciiString)& theFormats, - Handle(TColStd_HSequenceOfAsciiString)& thePatterns); - - Standard_EXPORT Standard_Boolean IsSupported (const Standard_Boolean isImport, - const TCollection_AsciiString& theFormat, - Handle(TCollection_HAsciiString)& theLibName); - Standard_EXPORT Handle(GEOM_Object) RestoreShape (std::istringstream& theStream); Standard_EXPORT int LoadTexture(const TCollection_AsciiString& theTextureFile); @@ -110,38 +91,6 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations { Standard_EXPORT std::list GetAllTextures(); - Standard_EXPORT bool ExportXAO(Handle(GEOM_Object) shape, - std::list groupList, - std::list fieldList, - const char* author, - const char* fileName); - - Standard_EXPORT bool ImportXAO(const char* fileName, - Handle(GEOM_Object)& shape, - Handle(TColStd_HSequenceOfTransient)& subShapes, - Handle(TColStd_HSequenceOfTransient)& groups, - Handle(TColStd_HSequenceOfTransient)& fields); - - private: - Standard_Boolean InitResMgr (); - - void importSubShapes(XAO::Geometry* xaoGeometry, Handle(GEOM_Function) function, - int shapeType, int dim, - Handle(TColStd_HSequenceOfTransient)& subshapeList); - void exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry); - void exportFields(std::list fieldList, XAO::Xao* xaoObject, - XAO::BrepGeometry* geometry); - void exportGroups(std::list groupList, XAO::Xao* xaoObject, - XAO::BrepGeometry* geometry); - - void MakeMaterialGroups(const Handle(GEOM_Object) &theObject, - const Handle(TColStd_HSequenceOfTransient) &theSeq); - - Handle(GEOM_Object) MakeGroup - (const Handle(GEOM_Object) &theObject, - const TCollection_ExtendedString &theName, - const NCollection_List &theShapes); - private: std::vector myResMgrList; GEOMImpl_IShapesOperations* myShapesOperations; diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index 31233a94f..d9bbe3062 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -121,7 +121,7 @@ GEOMImpl_IMeasureOperations::ShapeKind GEOMImpl_IMeasureOperations::KindOfShape int geom_type = theShape->GetType(); // check if it's advanced shape - if ( geom_type > ADVANCED_BASE ) { + if ( geom_type > USER_TYPE ) { SetErrorCode(OK); return SK_ADVANCED; } diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index efb82f39b..548ee1050 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -1151,9 +1151,38 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdgesByList * GetExistingSubObjects */ //============================================================================= -Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetExistingSubObjects - (Handle(GEOM_Object) theShape, - const Standard_Boolean theGroupsOnly) +Handle(TColStd_HSequenceOfTransient) +GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object) theShape, + const Standard_Boolean theGroupsOnly) +{ + // note: this method does not return fields + + Standard_Integer types = theGroupsOnly ? Groups : Groups|SubShapes; + Handle(TColStd_HSequenceOfTransient) results = GetExistingSubObjects(theShape, types); + + if (results->Length() > 0) { + //Make a Python command + TCollection_AsciiString anAsciiList; + for (int i = 1; i <= results->Length(); i++) + { + Handle(GEOM_BaseObject) obj = Handle(GEOM_BaseObject)::DownCast( results->Value(i)); + obj->GetEntryString(); + if ( i < results->Length() ) + anAsciiList += ","; + } + + GEOM::TPythonDump pd (theShape->GetLastFunction(), /*append=*/true); + pd << "[" << anAsciiList.ToCString(); + pd << "] = geompy.GetExistingSubObjects("; + pd << theShape << ", " << (bool)theGroupsOnly << ")"; + } + + return results; +} + +Handle(TColStd_HSequenceOfTransient) +GEOMImpl_IShapesOperations::GetExistingSubObjects(Handle(GEOM_Object) theShape, + const Standard_Integer theTypes) { SetErrorCode(KO); @@ -1171,8 +1200,6 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetExistingSubO SetErrorCode(KO); - TCollection_AsciiString anAsciiList; - TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries); for (; anIt.More(); anIt.Next()) { TCollection_ExtendedString anEntry = anIt.Value(); @@ -1180,13 +1207,14 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetExistingSubO char* anEntryStr = new char[aStrLen+1]; anEntry.ToUTF8CString(anEntryStr); Handle(GEOM_BaseObject) anObj = GetEngine()->GetObject(GetDocID(), anEntryStr, false); - if (!anObj.IsNull() && anObj->IsKind(STANDARD_TYPE(GEOM_Object))) { - if (!theGroupsOnly || anObj->GetType() == GEOM_GROUP) { + if (!anObj.IsNull() ) { + bool isGroup = anObj->IsKind(STANDARD_TYPE(GEOM_Object)) && anObj->GetType() == GEOM_GROUP; + bool isSubShape = anObj->IsKind(STANDARD_TYPE(GEOM_Object)) && anObj->GetType() != GEOM_GROUP; + bool isField = anObj->IsKind(STANDARD_TYPE(GEOM_Field)); + if (theTypes & Groups && isGroup || + theTypes & SubShapes && isSubShape || + theTypes & Fields && isField) { aSeq->Append(anObj); - - // for python command - anAsciiList += anEntryStr; - anAsciiList += ","; } } delete [] anEntryStr; @@ -1197,14 +1225,6 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetExistingSubO return aSeq; } - //Make a Python command - anAsciiList.Trunc(anAsciiList.Length() - 1); - - GEOM::TPythonDump pd (aMainShape, /*append=*/true); - pd << "[" << anAsciiList.ToCString(); - pd << "] = geompy.GetExistingSubObjects("; - pd << theShape << ", " << (bool)theGroupsOnly << ")"; - SetErrorCode(OK); return aSeq; diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx index e620817fe..d12642a36 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -54,6 +54,15 @@ class Handle(TColStd_HArray1OfInteger); class GEOMImpl_IShapesOperations : public GEOM_IOperations { public: + + enum SubShapeType { + None = 0x00, + Groups = 0x01, + Fields = 0x02, + SubShapes = 0x04, + All = Groups | Fields | SubShapes, + }; + Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID); Standard_EXPORT ~GEOMImpl_IShapesOperations(); @@ -106,10 +115,11 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations const Standard_Real theTolerance, std::list theEdges); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects - (Handle(GEOM_Object) theShape, - const Standard_Boolean theGroupsOnly); - + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape, + const Standard_Boolean theGroupsOnly); + Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape, + const Standard_Integer theTypes = All); + enum ExplodeType { EXPLODE_OLD_INCLUDE_MAIN, EXPLODE_NEW_INCLUDE_MAIN, diff --git a/src/GEOMImpl/GEOMImpl_ImportDriver.cxx b/src/GEOMImpl/GEOMImpl_ImportDriver.cxx index 768690584..86b3f32e6 100644 --- a/src/GEOMImpl/GEOMImpl_ImportDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ImportDriver.cxx @@ -20,49 +20,19 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include +// internal includes +#include "GEOMImpl_ImportDriver.hxx" +#include "GEOMImpl_IImportExport.hxx" +#include "GEOMImpl_IECallBack.hxx" +#include "GEOMImpl_Types.hxx" -#include -#include -#include +// GEOM includes #include +// OCC includes +#include #include -#include - -#include "utilities.h" - -#include -#include - -#ifdef WIN32 -#include -#else -#include -#endif - -#ifdef WIN32 -#define LibHandle HMODULE -#define LoadLib( name ) LoadLibrary( name ) -#define GetProc GetProcAddress -#define UnLoadLib( handle ) FreeLibrary( handle ); -#else -#define LibHandle void* -#define LoadLib( name ) dlopen( name, RTLD_LAZY ) -#define GetProc dlsym -#define UnLoadLib( handle ) dlclose( handle ); -#endif - -typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&, - const TCollection_AsciiString&, - TCollection_AsciiString&, - const TDF_Label&); - -typedef Handle(TCollection_HAsciiString) (*pGetValue)(const TCollection_AsciiString&, - const TCollection_AsciiString&, - TCollection_AsciiString&); - //======================================================================= //function : GetID //purpose : @@ -91,104 +61,26 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); GEOMImpl_IImportExport aCI (aFunction); - //Standard_Integer aType = aFunction->GetType(); // retrieve the file and plugin library names TCollection_AsciiString aFileName = aCI.GetFileName(); TCollection_AsciiString aFormatName = aCI.GetFormatName(); - TCollection_AsciiString aLibName = aCI.GetPluginName(); - if (aFileName.IsEmpty() || aFormatName.IsEmpty() || aLibName.IsEmpty()) + if (aFileName.IsEmpty() || aFormatName.IsEmpty() ) return 0; - // load plugin library - LibHandle anImportLib = LoadLib( aLibName.ToCString() ); //This is workaround of BUG OCC13051 - - // Get Import method - funcPoint fp = 0; - if ( anImportLib ) - fp = (funcPoint)GetProc( anImportLib, "Import" ); - - if ( !fp ) { - TCollection_AsciiString aMsg = aFormatName.SubString(1,4); - aMsg += " plugin was not installed"; - Standard_Failure::Raise(aMsg.ToCString()); - } - - // perform the import - TCollection_AsciiString anError; - TopoDS_Shape aShape = fp(aFileName, aFormatName, anError, aFunction->GetNamingEntry()); - - // unload plugin library - // commented by enk: - // the bug was occured: using ACIS Import/Export plugin - //UnLoadLib( anImportLib ); //This is workaround of BUG OCC13051 - - if ( aShape.IsNull() ) { - StdFail_NotDone::Raise(anError.ToCString()); + Handle(TColStd_HSequenceOfTransient) aSeq = + GEOMImpl_IECallBack::GetCallBack( aFormatName )->Import( GetDocID(), aFormatName, aFileName ); + if( aSeq.IsNull() ) return 0; - } - - // set the function result - aFunction->SetValue(aShape); + Handle(GEOM_Object) anImported = Handle(GEOM_Object)::DownCast( aSeq->Value(1) ); + TopoDS_Shape aShape = anImported->GetValue(); + aFunction->SetValue( aShape ); log.SetTouched(Label()); return 1; } -//======================================================================= -//function : ReadValue -//purpose : -//======================================================================= -TCollection_AsciiString GEOMImpl_ImportDriver::ReadValue(const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theLibName, - const TCollection_AsciiString& theParameterName, - TCollection_AsciiString& theError) -{ - TCollection_AsciiString aValue; - - if (theFileName.IsEmpty() || theLibName.IsEmpty() || theParameterName.IsEmpty()) - return aValue; - - // load plugin library - LibHandle anImportLib = LoadLib(theLibName.ToCString()); //This is workaround of BUG OCC13051 - if (!anImportLib) { - theError = theLibName + " library was not installed"; - return aValue; - } - - // Get GetValue method - pGetValue pGV = (pGetValue)GetProc(anImportLib, "GetValue"); - - if (!pGV) { - theError = theLibName + " library doesn't support GetValue method"; - return aValue; - } - - Handle(TCollection_HAsciiString) aHValue = pGV(theFileName, theParameterName, theError); - - if (aHValue.IsNull()) { - if (theError.IsEmpty()) - theError = theFileName + " doesn't contain requested parameter"; - return aValue; - } - - aValue = aHValue->String(); - - // unload plugin library - // commented by enk: - // the bug was occured: using ACIS Import/Export plugin - //UnLoadLib( anImportLib ); //This is workaround of BUG OCC13051 - - return aValue; -} - -//================================================================================ -/*! - * \brief Returns a name of creation operation and names and values of creation parameters - */ -//================================================================================ - bool GEOMImpl_ImportDriver:: GetCreationInformation(std::string& theOperationName, std::vector& theParams) diff --git a/src/GEOMImpl/GEOMImpl_ImportDriver.hxx b/src/GEOMImpl/GEOMImpl_ImportDriver.hxx index 47dbb356f..c6e4b7b68 100644 --- a/src/GEOMImpl/GEOMImpl_ImportDriver.hxx +++ b/src/GEOMImpl/GEOMImpl_ImportDriver.hxx @@ -26,23 +26,7 @@ #ifndef _GEOMImpl_ImportDriver_HeaderFile #define _GEOMImpl_ImportDriver_HeaderFile -#ifndef _TColStd_SequenceOfExtendedString_HeaderFile -#include -#endif -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif #ifndef _Standard_GUID_HeaderFile #include #endif @@ -82,13 +66,6 @@ Standard_EXPORT ~GEOMImpl_ImportDriver() {}; Standard_EXPORT virtual bool GetCreationInformation(std::string& theOperationName, std::vector& params); - - // Static method - Standard_EXPORT static TCollection_AsciiString ReadValue (const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theLibName, - const TCollection_AsciiString& theParameterName, - TCollection_AsciiString& theError); - DEFINE_STANDARD_RTTI( GEOMImpl_ImportDriver ) }; diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx index ffc758bcb..037e62900 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -1153,7 +1153,7 @@ TopoDS_Shape GEOMImpl_ShapeDriver::MakeIsoline const double theParameter) const { TopoDS_Shape aResult; - GEOMUtils_Hatcher aHatcher(theFace); + GEOMUtils::Hatcher aHatcher(theFace); const GeomAbs_IsoType aType = (IsUIso ? GeomAbs_IsoU : GeomAbs_IsoV); aHatcher.Init(aType, theParameter); diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index b57080a9c..0bc7505c1 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -109,8 +109,6 @@ #define GEOM_FIELD 52 // == GEOM_FIELD_OBJTYPE constant #define GEOM_FIELD_STEP 53 // == GEOM_FIELD_STEP_OBJTYPE constant -#define GEOM_EXPORTXAO 54 - #define GEOM_ISOLINE 55 //GEOM_Function types @@ -118,8 +116,8 @@ #define COPY_WITH_REF 1 #define COPY_WITHOUT_REF 2 -#define EXPORT_SHAPE 1 #define IMPORT_SHAPE 1 +#define EXPORT_SHAPE 2 #define POINT_XYZ 1 #define POINT_XYZ_REF 2 @@ -363,9 +361,10 @@ #define MARKER_SHAPE 2 #define MARKER_PNT2VEC 3 -// import/export XAO -#define IMPORTEXPORT_EXPORTXAO 1 -#define IMPORTEXPORT_IMPORTXAO 2 +// Advanced functions +#define USER_TYPE 200 // Base type for GEOM advanced shapes +#define USER_TYPE_EX 1000 // Base type for GEOM plugins + -// Advanced functions (base = 200) -#define ADVANCED_BASE 200 // NO OPERATION (advanced operations base) +//Plugins specified constants +#define PLUGIN_NAME "Plugin Name" diff --git a/src/GEOMImpl/GEOMImpl_XAODriver.cxx b/src/GEOMImpl/GEOMImpl_XAODriver.cxx deleted file mode 100644 index 4a7e7dfcf..000000000 --- a/src/GEOMImpl/GEOMImpl_XAODriver.cxx +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (C) 2013-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 -// - -#include - -#include -#include -#include -#include - -#include -#include - -#include "XAO_Xao.hxx" -#include "XAO_Geometry.hxx" -#include "XAO_Group.hxx" -#include "XAO_XaoUtils.hxx" -//@@ include required header files here @@// - -//======================================================================= -//function : GetID -//purpose : -//======================================================================= -const Standard_GUID& GEOMImpl_XAODriver::GetID() -{ - static Standard_GUID aGUID("FF1BBB71-5D14-4df2-980B-3A668264EA16"); - return aGUID; -} - -//======================================================================= -//function : GEOMImpl_XAODriver -//purpose : -//======================================================================= -GEOMImpl_XAODriver::GEOMImpl_XAODriver() -{ -} - -//======================================================================= -//function : Execute -//purpose : -//======================================================================= -Standard_Integer GEOMImpl_XAODriver::Execute(TFunction_Logbook& log) const -{ - if (Label().IsNull()) return 0; - Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); - - GEOMImpl_IImportExportXAO iexao(function); - TCollection_AsciiString xao = iexao.GetData(); - - TopoDS_Shape shape; - - Standard_Integer functionType = function->GetType(); - if (functionType == IMPORTEXPORT_EXPORTXAO) - { - } - else if (functionType == IMPORTEXPORT_IMPORTXAO) - { - } - else - { - // other construction modes here - } - - if (shape.IsNull()) return 0; - - function->SetValue(shape); - - log.SetTouched(Label()); - - return 1; -} - -//======================================================================= -//function : GEOMImpl_XAODriver_Type_ -//purpose : -//======================================================================= -Standard_EXPORT Handle_Standard_Type& GEOMImpl_XAODriver_Type_() -{ - static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); - if (aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); - static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if (aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); - static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); - if (aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - - static Handle_Standard_Transient _Ancestors[] = { aType1, aType2, aType3, NULL }; - static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_XAODriver", - sizeof(GEOMImpl_XAODriver), - 1, - (Standard_Address) _Ancestors, - (Standard_Address) NULL); - return _aType; -} - -//======================================================================= -//function : DownCast -//purpose : -//======================================================================= -const Handle(GEOMImpl_XAODriver) Handle(GEOMImpl_XAODriver)::DownCast( - const Handle(Standard_Transient)& AnObject) -{ - Handle(GEOMImpl_XAODriver) _anOtherObject; - - if (!AnObject.IsNull()) - { - if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_XAODriver))) - { - _anOtherObject = Handle(GEOMImpl_XAODriver)((Handle(GEOMImpl_XAODriver)&) AnObject); - } - } - - return _anOtherObject; -} diff --git a/src/GEOMImpl/GEOMImpl_XAODriver.hxx b/src/GEOMImpl/GEOMImpl_XAODriver.hxx deleted file mode 100644 index c67b6909a..000000000 --- a/src/GEOMImpl/GEOMImpl_XAODriver.hxx +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 _GEOMImpl_XAODriver_HXX -#define _GEOMImpl_XAODriver_HXX - -#include - -class Handle_Standard_Type; -class GEOMImpl_XAODriver; - -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_XAODriver); - -class Handle(GEOMImpl_XAODriver): public Handle(TFunction_Driver) -{ -public: - inline void* operator new(size_t, void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&) anAddress); - } - - Handle(GEOMImpl_XAODriver) () : - Handle(TFunction_Driver)() - { - } - Handle(GEOMImpl_XAODriver) (const Handle(GEOMImpl_XAODriver)& aHandle) : - Handle(TFunction_Driver)(aHandle) - { - } - - Handle(GEOMImpl_XAODriver) (const GEOMImpl_XAODriver* anItem) : - Handle(TFunction_Driver)((TFunction_Driver *) anItem) - { - } - - Handle(GEOMImpl_XAODriver)& operator=(const Handle(GEOMImpl_XAODriver)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(GEOMImpl_XAODriver)& operator=(const GEOMImpl_XAODriver* anItem) - { - Assign((Standard_Transient *) anItem); - return *this; - } - - GEOMImpl_XAODriver* operator->() - { - return (GEOMImpl_XAODriver *) ControlAccess(); - } - - GEOMImpl_XAODriver* operator->() const - { - return (GEOMImpl_XAODriver *) ControlAccess(); - } - - Standard_EXPORT - ~Handle(GEOMImpl_XAODriver)() - { - } - - Standard_EXPORT - static const Handle(GEOMImpl_XAODriver) DownCast(const Handle(Standard_Transient)& AnObject); -}; - -class GEOMImpl_XAODriver: public TFunction_Driver -{ -public: - inline void* operator new(size_t, void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&) anAddress); - } - - // Methods PUBLIC - // - Standard_EXPORT - GEOMImpl_XAODriver(); - Standard_EXPORT - virtual Standard_Integer Execute(TFunction_Logbook& log) const; - Standard_EXPORT - virtual void Validate(TFunction_Logbook&) const - { - } - Standard_EXPORT - Standard_Boolean MustExecute(const TFunction_Logbook&) const - { - return Standard_True; - } - Standard_EXPORT - static const Standard_GUID& GetID(); - Standard_EXPORT - ~GEOMImpl_XAODriver() - { - } - - // Type management - // - Standard_EXPORT - friend Handle_Standard_Type& GEOMImpl_ExportXAODriver_Type_(); - Standard_EXPORT - const Handle(Standard_Type)& DynamicType() const - { - return STANDARD_TYPE(GEOMImpl_XAODriver); - } - Standard_EXPORT - Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const - { - return (STANDARD_TYPE(GEOMImpl_XAODriver) == AType || TFunction_Driver::IsKind(AType)); - } -}; - -#endif // _GEOMImpl_XAODriver_HXX diff --git a/src/GEOMImpl/GUID.txt b/src/GEOMImpl/GUID.txt index 34a83e707..d11591d0f 100755 --- a/src/GEOMImpl/GUID.txt +++ b/src/GEOMImpl/GUID.txt @@ -71,8 +71,6 @@ FF1BBB69-5D14-4df2-980B-3A668264EA16 // Modify the Location FF1BBB70-5D14-4df2-980B-3A668264EA16 // Projection -FF1BBB71-5D14-4df2-980B-3A668264EA16 // Export XAO - 1C3A0F3F-729D-4E83-8232-78E74FC5637C // Pipe T-Shape 1C3A0F30-729D-4E83-8232-78E74FC5637C // Smoothing Surface diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index 0c514cb78..950b181c5 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -62,116 +62,6 @@ typedef QMap FilterMap; static QString lastUsedFilter; -//======================================================================= -// function : getFileName -// purpose : Selection of a file name for Import/Export. Returns also -// the selected file type code through argument. -//======================================================================= -static QString getFileName( QWidget* parent, - const QString& initial, - const FilterMap& filterMap, - const QStringList& filters, - const QString& caption, - bool open, - QString& format, - bool showCurrentDirInitially = false ) -{ - //QStringList filters; - QString aBrepFilter; - for (FilterMap::const_iterator it = filterMap.begin(); it != filterMap.end(); ++it) { - //filters.push_back( it.key() ); - if (it.key().contains( "BREP", Qt::CaseInsensitive )) - aBrepFilter = it.key(); - } - - SUIT_FileDlg* fd = new SUIT_FileDlg( parent, open, true, true ); - if ( !caption.isEmpty() ) - fd->setWindowTitle( caption ); - - if ( !initial.isEmpty() ) - fd->selectFile( initial ); - - if ( showCurrentDirInitially && SUIT_FileDlg::getLastVisitedPath().isEmpty() ) - fd->setDirectory( QDir::currentPath() ); - - fd->setFilters( filters ); - - if ( !lastUsedFilter.isEmpty() && filterMap.contains( lastUsedFilter ) ) { - fd->selectFilter( lastUsedFilter ); - } - else if ( !aBrepFilter.isEmpty() ) { - fd->selectFilter( aBrepFilter ); - } - - QString filename; - if ( fd->exec() == QDialog::Accepted ) { - filename = fd->selectedFile(); - format = filterMap[fd->selectedFilter()]; - lastUsedFilter = fd->selectedFilter(); - } - - delete fd; - qApp->processEvents(); - return filename; -} - -//======================================================================= -// function : getFileNames -// purpose : Select list of files for Import operation. Returns also -// the selected file type code through argument. -//======================================================================= -static QStringList getFileNames( QWidget* parent, - const QString& initial, - const FilterMap& filterMap, - const QString& caption, - QString& format, - bool showCurrentDirInitially = false) -{ - QString aBrepFilter; - QStringList allFilters; - QStringList filters; - QRegExp re( "\\((.*)\\)" ); - re.setMinimal( true ); - for ( FilterMap::const_iterator it = filterMap.begin(); it != filterMap.end(); ++it ) { - if ( it.value().contains( "BREP", Qt::CaseInsensitive ) && aBrepFilter.isEmpty() ) - aBrepFilter = it.key(); - filters.append( it.key() ); - int pos = 0; - while ( re.indexIn( it.key(), pos ) >= 0 ) { - QString f = re.cap(1); - pos = re.pos() + f.length() + 2; - allFilters.append( f.simplified() ); - } - } - filters.append( QObject::tr( "GEOM_ALL_IMPORT_FILES" ).arg( allFilters.join( " " ) ) ); - - SUIT_FileDlg fd( parent, true, true, true ); - fd.setFileMode( SUIT_FileDlg::ExistingFiles ); - if ( !caption.isEmpty() ) - fd.setWindowTitle( caption ); - if ( !initial.isEmpty() ) - fd.selectFile( initial ); - - if ( showCurrentDirInitially && SUIT_FileDlg::getLastVisitedPath().isEmpty() ) - fd.setDirectory( QDir::currentPath() ); - - fd.setFilters( filters ); - - if ( !lastUsedFilter.isEmpty() && filterMap.contains( lastUsedFilter ) ) - fd.selectFilter( lastUsedFilter ); - else if ( !aBrepFilter.isEmpty() ) - fd.selectFilter( aBrepFilter ); - - QStringList filenames; - if ( fd.exec() ) { - filenames = fd.selectedFiles(); - format = filterMap.contains( fd.selectedFilter() ) ? filterMap[ fd.selectedFilter() ] : QString(); - lastUsedFilter = fd.selectedFilter(); - } - qApp->processEvents(); - return filenames; -} - //======================================================================= // function : getParentComponent // purpose : Get object's parent component entry @@ -317,12 +207,6 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) case GEOMOp::OpDelete: // EDIT - DELETE OnEditDelete(); break; - case GEOMOp::OpImport: // FILE - IMPORT - Import(); - break; - case GEOMOp::OpExport: // FILE - EXPORT - Export(); - break; case GEOMOp::OpCheckGeom: // TOOLS - CHECK GEOMETRY OnCheckGeometry(); break; @@ -628,365 +512,6 @@ void GEOMToolsGUI::OnEditDelete() app->updateActions(); //SRN: To update a Save button in the toolbar } -//===================================================================================== -// function : Import -// purpose : BRep, Iges, Step, ... -//===================================================================================== -bool GEOMToolsGUI::Import() -{ - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( getGeometryGUI()->getApp() ); - if ( !app ) return false; - - SalomeApp_Study* stud = dynamic_cast ( app->activeStudy() ); - if ( !stud ) { - MESSAGE ( "FAILED to cast active study to SalomeApp_Study" ); - return false; - } - _PTR(Study) aStudy = stud->studyDS(); - - // check if study is locked - bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked(); - if ( aLocked ) { - SUIT_MessageBox::warning( app->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED") ); - return false; - } - - // check if GEOM engine is available - GEOM::GEOM_Gen_var eng = GeometryGUI::GetGeomGen(); - if ( CORBA::is_nil( eng ) ) { - SUIT_MessageBox::critical( app->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr( "GEOM Engine is not started" ) ); - return false; - } - - GEOM::GEOM_IInsertOperations_var aInsOp = eng->GetIInsertOperations( aStudy->StudyId() ); - if ( aInsOp->_is_nil() ) - return false; - - // obtain a list of available import formats - FilterMap aMap; - GEOM::string_array_var aFormats, aPatterns; - aInsOp->ImportTranslators( aFormats, aPatterns ); - - for ( int i = 0, n = aFormats->length(); i < n; i++ ) - aMap.insert( (char*)aPatterns[i], (char*)aFormats[i] ); - - // select files to be imported - QString fileType; - QStringList fileNames = getFileNames( app->desktop(), "", aMap, - tr( "GEOM_MEN_IMPORT" ), fileType, true ); - - // set Wait cursor - SUIT_OverrideCursor wc; - - if ( fileNames.count() == 0 ) - return false; // nothing selected, return - - QStringList errors; - - QList< GEOM::GEOM_Object_var > objsForDisplay; - - QStringList anEntryList; - - // iterate through all selected files - - SUIT_MessageBox::StandardButton igesAnswer = SUIT_MessageBox::NoButton; - SUIT_MessageBox::StandardButton acisAnswer = SUIT_MessageBox::NoButton; - - for ( int i = 0; i < fileNames.count(); i++ ) { - QString fileName = fileNames[i]; - - if ( fileName.isEmpty() ) - continue; - - QString aCurrentType; - if ( fileType.isEmpty() ) { - // file type is not defined, try to detect - QString ext = QFileInfo( fileName ).suffix().toUpper(); - QRegExp re( "\\*\\.(\\w+)" ); - for ( FilterMap::const_iterator it = aMap.begin(); - it != aMap.end() && aCurrentType.isEmpty(); ++it ) { - int pos = 0; - while ( re.indexIn( it.key(), pos ) >= 0 ) { - QString f = re.cap(1).trimmed().toUpper(); - if ( ext == f ) { aCurrentType = it.value(); break; } - pos = re.pos() + re.cap(1).length() + 2; - } - } - } - else { - aCurrentType = fileType; - } - - if ( aCurrentType.isEmpty() ) { - errors.append( QString( "%1 : %2" ).arg( fileName ).arg( tr( "GEOM_UNSUPPORTED_TYPE" ) ) ); - continue; - } - - GEOM_Operation* anOp = new GEOM_Operation( app, aInsOp.in() ); - try { - app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( fileName, /*withExten=*/true ) ) ); - anOp->start(); - - CORBA::String_var fileN = fileName.toUtf8().constData(); - CORBA::String_var fileT = aCurrentType.toUtf8().constData(); - - // jfa 21.08.2012 for mantis issue 21511 (STEP file units) - CORBA::String_var aUnits = aInsOp->ReadValue(fileN, fileT, "LEN_UNITS"); - QString aUnitsStr (aUnits.in()); - bool needConvert = true; - if (aUnitsStr.isEmpty() || aUnitsStr == "M" || aUnitsStr.toLower() == "metre") - needConvert = false; - - if (needConvert) { - if (igesAnswer == SUIT_MessageBox::NoToAll) { - // converting for all files is already approved - fileT = (aCurrentType + "_SCALE").toLatin1().constData(); - } - else if (igesAnswer != SUIT_MessageBox::YesToAll) { - SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No; - if (i < fileNames.count() - 1) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll; - igesAnswer = SUIT_MessageBox::question(app->desktop(), - "Question",//tr("WRN_WARNING"), - tr("GEOM_SCALE_DIMENSIONS").arg(aUnitsStr), - btns | SUIT_MessageBox::Cancel, - SUIT_MessageBox::No); - switch (igesAnswer) { - case SUIT_MessageBox::Cancel: - return false; // cancel (break) import operation - case SUIT_MessageBox::Yes: - case SUIT_MessageBox::YesToAll: - break; // scaling is confirmed - case SUIT_MessageBox::No: - case SUIT_MessageBox::NoAll: - fileT = (aCurrentType + "_SCALE").toLatin1().constData(); - default: - break; // scaling is rejected - } // switch ( igesAnswer ) - } // if ( igeAnswer != NoToAll ) - } // if ( needConvert ) - - /* - // skl 29.05.2009 - if ( aCurrentType == "IGES" ) { - GEOM::GEOM_Object_var anObj = aInsOp->ImportFile( fileN, "IGES_UNIT" ); - bool needConvert = false; - TCollection_AsciiString aUnitName = aInsOp->GetErrorCode(); - if ( aUnitName.SubString( 1, 4 ) == "UNIT" ) - needConvert = aUnitName.SubString( 6, aUnitName.Length() ) != "M"; - - if ( needConvert ) { - if ( igesAnswer == SUIT_MessageBox::NoToAll ) { - // converting for all files is already approved - fileT = "IGES_SCALE"; - } - else if ( igesAnswer != SUIT_MessageBox::YesToAll ) { - SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No; - if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll; - igesAnswer = SUIT_MessageBox::question( app->desktop(), - "Question",//tr("WRN_WARNING"), - tr("GEOM_SCALE_DIMENSIONS"), - btns | SUIT_MessageBox::Cancel, - SUIT_MessageBox::No ); - switch ( igesAnswer ) { - case SUIT_MessageBox::Cancel: - return false; // cancel (break) import operation - case SUIT_MessageBox::Yes: - case SUIT_MessageBox::YesToAll: - break; // scaling is confirmed - case SUIT_MessageBox::No: - case SUIT_MessageBox::NoAll: - fileT = "IGES_SCALE"; - default: - break; // scaling is rejected - } // switch ( igesAnswer ) - } // if ( igeAnswer != NoToAll ) - } // if ( needConvert ) - } // if ( aCurrentType == "IGES" ) - else if ( aCurrentType == "ACIS" ) { - */ - - if ( aCurrentType == "ACIS" ) { - if ( acisAnswer != SUIT_MessageBox::YesToAll && acisAnswer != SUIT_MessageBox::NoToAll ) { - SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No; - if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll; - acisAnswer = SUIT_MessageBox::question( app->desktop(), - "Question",//tr("WRN_WARNING"), - tr("GEOM_PUBLISH_NAMED_SHAPES"), - btns | SUIT_MessageBox::Cancel, - SUIT_MessageBox::No ); - if ( acisAnswer == SUIT_MessageBox::Cancel ) - return false; // cancel (break) import operation - } // if ( acisAnswer != YesToAll && acisAnswer != NoToAll ) - } // else if ( aCurrentType == "ACIS" ) - - // IMPORT - GEOM::ListOfGO_var anObj = aInsOp->ImportFile( fileN, fileT ); - - if ( anObj->length() > 0 && aInsOp->IsDone() ) { - GEOM::GEOM_Object_ptr aFather = anObj[0]._retn(); - QString aPublishObjName = - GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, /*withExten=*/true ) ); - - SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy ); - SALOMEDS::SObject_var aSO = - GeometryGUI::GetGeomGen()->PublishInStudy( aDSStudy, - SALOMEDS::SObject::_nil(), - aFather, - aPublishObjName.toLatin1().constData() ); - if ( ( !aSO->_is_nil() ) ) - anEntryList.append( aSO->GetID() ); - - objsForDisplay.append( aFather ); - - if ( aCurrentType == "ACIS" ) { - if ( acisAnswer == SUIT_MessageBox::Yes || acisAnswer == SUIT_MessageBox::YesToAll ) - GeometryGUI::GetGeomGen()->PublishNamedShapesInStudy( aDSStudy, aFather ); - } - - anOp->commit(); - - // Treat group objects. - for (int i = 1, n = anObj->length(); i < n; i++) { - GEOM::GEOM_Object_ptr anObject = anObj[i]._retn(); - GeometryGUI::GetGeomGen()->AddInStudy(aDSStudy, - anObject, tr(anObject->GetName()).toStdString().c_str(), aFather); - } - } - else { - anOp->abort(); - errors.append( QString( "%1 : %2" ).arg( fileName ).arg( aInsOp->GetErrorCode() ) ); - } - } - catch( const SALOME::SALOME_Exception& S_ex ) { - anOp->abort(); - errors.append( QString( "%1 : %2" ).arg( fileName ).arg( tr( "GEOM_UNKNOWN_IMPORT_ERROR" ) ) ); - } - } - - // update object browser - getGeometryGUI()->updateObjBrowser( true ); - - // browse published objects - app->browseObjects( anEntryList ); - - // display imported model (if only one file is selected) - if ( objsForDisplay.count() == 1 ) - GEOM_Displayer( stud ).Display( objsForDisplay[0].in() ); - - if ( errors.count() > 0 ) { - SUIT_MessageBox::critical( app->desktop(), - QObject::tr( "GEOM_ERROR" ), - QObject::tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); - } - - app->updateActions(); //SRN: To update a Save button in the toolbar - - return objsForDisplay.count() > 0; -} - -//===================================================================================== -// function : Export -// purpose : BRep, Iges, Step -//===================================================================================== -bool GEOMToolsGUI::Export() -{ - SalomeApp_Application* app = getGeometryGUI()->getApp(); - if (!app) return false; - - SalomeApp_Study* stud = dynamic_cast ( app->activeStudy() ); - if ( !stud ) { - MESSAGE ( "FAILED to cast active study to SalomeApp_Study" ); - return false; - } - _PTR(Study) aStudy = stud->studyDS(); - - GEOM::GEOM_Gen_var eng = GeometryGUI::GetGeomGen(); - if ( CORBA::is_nil( eng ) ) { - SUIT_MessageBox::critical( app->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr( "GEOM Engine is not started" ) ); - return false; - } - - GEOM::GEOM_IInsertOperations_var aInsOp = eng->GetIInsertOperations( aStudy->StudyId() ); - if ( aInsOp->_is_nil() ) - return false; - - // Obtain a list of available export formats - FilterMap aMap; - QStringList filters; - GEOM::string_array_var aFormats, aPatterns; - aInsOp->ExportTranslators( aFormats, aPatterns ); - for ( int i = 0, n = aFormats->length(); i < n; i++ ) { - aMap.insert( (char*)aPatterns[i], (char*)aFormats[i] ); - filters.push_back( (char*)aPatterns[i] ); - } - - // Get selected objects - LightApp_SelectionMgr* sm = app->selectionMgr(); - if ( !sm ) - return false; - - SALOME_ListIO selectedObjects; - sm->selectedObjects( selectedObjects ); - bool appropriateObj = false; - - SALOME_ListIteratorOfListIO It( selectedObjects ); - for (; It.More(); It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject( IObject ); - - if ( anObj->_is_nil() ) - continue; - - QString fileType; - QString file = getFileName(app->desktop(), QString( IObject->getName() ), aMap, filters, - tr("GEOM_MEN_EXPORT"), false, fileType, true); - - // User has pressed "Cancel" --> stop the operation - if ( file.isEmpty() || fileType.isEmpty() ) - return false; - - GEOM_Operation* anOp = new GEOM_Operation( app, aInsOp.in() ); - try { - SUIT_OverrideCursor wc; - - app->putInfo( tr("GEOM_PRP_EXPORT").arg(SUIT_Tools::file( file, /*withExten=*/true )) ); - - anOp->start(); - - aInsOp->Export( anObj, file.toUtf8().constData(), fileType.toUtf8().constData() ); - - if (aInsOp->IsDone()) - anOp->commit(); - else { - anOp->abort(); - wc.suspend(); - SUIT_MessageBox::critical(app->desktop(), - QObject::tr("GEOM_ERROR"), - QObject::tr("GEOM_PRP_ABORT") + "\n" + QObject::tr(aInsOp->GetErrorCode())); - return false; - } - } - catch (const SALOME::SALOME_Exception& S_ex) { - //QtCatchCorbaException(S_ex); - anOp->abort(); - return false; - } - appropriateObj = true; - } - - if ( !appropriateObj ) - SUIT_MessageBox::warning( app->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("GEOM_WRN_NO_APPROPRIATE_SELECTION") ); - return true; -} - //===================================================================================== // function : RemoveObjectWithChildren // purpose : used by OnEditDelete() method diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h index 4ed7f9495..a79c7d30c 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI.h @@ -61,9 +61,6 @@ public: enum ActionType { SHOWDLG, INCR, DECR }; private: - // Import and export topology methods - bool Import(); - bool Export(); void OnEditDelete(); void OnCheckGeometry(); diff --git a/src/GEOMUtils/CMakeLists.txt b/src/GEOMUtils/CMakeLists.txt index b4969f0d9..fdd98a686 100755 --- a/src/GEOMUtils/CMakeLists.txt +++ b/src/GEOMUtils/CMakeLists.txt @@ -23,6 +23,7 @@ INCLUDE_DIRECTORIES( ${CAS_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIR} + ${LIBXML2_INCLUDE_DIR} ${KERNEL_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -30,6 +31,7 @@ INCLUDE_DIRECTORIES( # additional preprocessor / compiler flags ADD_DEFINITIONS( ${CAS_DEFINITIONS} + ${LIBXML2_DEFINITIONS} ) # libraries to link to @@ -40,6 +42,7 @@ SET(_link_LIBRARIES ${CAS_TKG3d} ${CAS_TKV3d} ${CAS_TKGeomBase} + ${LIBXML2_LIBRARIES} ${KERNEL_SALOMELocalTrace} ) @@ -48,12 +51,14 @@ SET(_link_LIBRARIES SET(GEOMUtils_HEADERS GEOMUtils.hxx GEOMUtils_Hatcher.hxx + GEOMUtils_XmlHandler.hxx ) # --- sources --- SET(GEOMUtils_SOURCES GEOMUtils.cxx GEOMUtils_Hatcher.cxx + GEOMUtils_XmlHandler.cxx ) # --- rules --- diff --git a/src/GEOMUtils/GEOMUtils.cxx b/src/GEOMUtils/GEOMUtils.cxx index 89b13d96b..aa8c3d7a3 100644 --- a/src/GEOMUtils/GEOMUtils.cxx +++ b/src/GEOMUtils/GEOMUtils.cxx @@ -95,13 +95,240 @@ #define STD_SORT_ALGO 1 -namespace GEOMUtils { +namespace +{ + /** + * This function constructs and returns modified shape from the original one + * for singular cases. It is used for the method GetMinDistanceSingular. + * + * \param theShape the original shape + * \param theModifiedShape output parameter. The modified shape. + * \param theAddDist output parameter. The added distance for modified shape. + * \retval true if the shape is modified; false otherwise. + * + * \internal + */ + Standard_Boolean ModifyShape(const TopoDS_Shape &theShape, + TopoDS_Shape &theModifiedShape, + Standard_Real &theAddDist) + { + Standard_Boolean isModified = Standard_False; + TopExp_Explorer anExp; + int nbf = 0; + + theAddDist = 0.; + theModifiedShape.Nullify(); + + for ( anExp.Init( theShape, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + nbf++; + theModifiedShape = anExp.Current(); + } + if(nbf==1) { + TopoDS_Shape sh = theShape; + while(sh.ShapeType()==TopAbs_COMPOUND) { + TopoDS_Iterator it(sh); + sh = it.Value(); + } + Handle(Geom_Surface) S = BRep_Tool::Surface(TopoDS::Face(theModifiedShape)); + if( S->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || + S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) || + S->IsUPeriodic()) { + const Standard_Boolean isShell = + (sh.ShapeType()==TopAbs_SHELL || sh.ShapeType()==TopAbs_FACE); + + if( isShell || S->IsUPeriodic() ) { + // non solid case or any periodic surface (Mantis 22454). + double U1,U2,V1,V2; + // changes for 0020677: EDF 1219 GEOM: MinDistance gives 0 instead of 20.88 + //S->Bounds(U1,U2,V1,V2); changed by + ShapeAnalysis::GetFaceUVBounds(TopoDS::Face(theModifiedShape),U1,U2,V1,V2); + // end of changes for 020677 (dmv) + Handle(Geom_RectangularTrimmedSurface) TrS1 = + new Geom_RectangularTrimmedSurface(S,U1,(U1+U2)/2.,V1,V2); + Handle(Geom_RectangularTrimmedSurface) TrS2 = + new Geom_RectangularTrimmedSurface(S,(U1+U2)/2.,U2,V1,V2); + BRep_Builder B; + TopoDS_Face F1,F2; + TopoDS_Shape aMShape; + + if (isShell) { + B.MakeCompound(TopoDS::Compound(aMShape)); + } else { + B.MakeShell(TopoDS::Shell(aMShape)); + } + + B.MakeFace(F1,TrS1,1.e-7); + B.Add(aMShape,F1); + B.MakeFace(F2,TrS2,1.e-7); + B.Add(aMShape,F2); + Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape; + + if (!isShell) { + // The original shape is a solid. + TopoDS_Solid aSolid; + + B.MakeSolid(aSolid); + B.Add(aSolid, aMShape); + aMShape = aSolid; + } + + sfs->Init(aMShape); + sfs->SetPrecision(1.e-6); + sfs->SetMaxTolerance(1.0); + sfs->Perform(); + theModifiedShape = sfs->Shape(); + isModified = Standard_True; + } + else { + if( S->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ) { + Handle(Geom_SphericalSurface) SS = Handle(Geom_SphericalSurface)::DownCast(S); + gp_Pnt PC = SS->Location(); + BRep_Builder B; + TopoDS_Vertex V; + B.MakeVertex(V,PC,1.e-7); + theModifiedShape = V; + theAddDist = SS->Radius(); + isModified = Standard_True; + } + else { + Handle(Geom_ToroidalSurface) TS = Handle(Geom_ToroidalSurface)::DownCast(S); + gp_Ax3 ax3 = TS->Position(); + Handle(Geom_Circle) C = new Geom_Circle(ax3.Ax2(),TS->MajorRadius()); + BRep_Builder B; + TopoDS_Edge E; + B.MakeEdge(E,C,1.e-7); + theModifiedShape = E; + theAddDist = TS->MinorRadius(); + isModified = Standard_True; + } + } + } else { + theModifiedShape = theShape; + } + } + else + theModifiedShape = theShape; + + return isModified; + } + + //======================================================================= + //function : ShapeToDouble + //purpose : used by CompareShapes::operator() + //======================================================================= + std::pair ShapeToDouble (const TopoDS_Shape& S, bool isOldSorting) + { + // Computing of CentreOfMass + gp_Pnt GPoint; + double Len; + + if (S.ShapeType() == TopAbs_VERTEX) { + GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S)); + Len = (double)S.Orientation(); + } + else { + GProp_GProps GPr; + // BEGIN: fix for Mantis issue 0020842 + if (isOldSorting) { + BRepGProp::LinearProperties(S, GPr); + } + else { + if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties(S, GPr); + } + else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(S, GPr); + } + else { + BRepGProp::VolumeProperties(S, GPr); + } + } + // END: fix for Mantis issue 0020842 + GPoint = GPr.CentreOfMass(); + Len = GPr.Mass(); + } + + double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9; + return std::make_pair(dMidXYZ, Len); + } + + void parseWard( const GEOMUtils::LevelsList &theLevelList, std::string &treeStr ) + { + treeStr.append( "{" ); + for( GEOMUtils::LevelsList::const_iterator j = theLevelList.begin(); + j != theLevelList.end(); ++j ) { + if ( j != theLevelList.begin() ) { + treeStr.append( ";" ); + } + GEOMUtils::LevelInfo level = (*j); + GEOMUtils::LevelInfo::iterator upIter; + for ( upIter = level.begin(); upIter != level.end(); ++upIter ) { + if ( upIter != level.begin() ) { + treeStr.append( "," ); + } + treeStr.append( upIter->first ); + for ( std::vector::iterator k = upIter->second.begin(); k != upIter->second.end(); ++k ) { + treeStr.append( "_" ); + treeStr.append( *k ); + } + } + } + treeStr.append( "}" ); + } + + GEOMUtils::LevelsList parseWard( const std::string& theData, std::size_t& theCursor ) + { + std::size_t indexStart = theData.find( "{", theCursor ) + 1; + std::size_t indexEnd = theData.find( "}", indexStart ); + + std::string ward = theData.substr( indexStart, indexEnd - indexStart ); + std::stringstream ss(ward); + std::string substr; + std::vector levelsListStr; + while ( std::getline( ss, substr, ';' ) ) { + if ( !substr.empty() ) + levelsListStr.push_back( substr ); + } + GEOMUtils::LevelsList levelsListData; + for( int level = 0; level < levelsListStr.size(); level++ ) { + std::vector namesListStr; + std::stringstream ss1( levelsListStr[level] ); + while ( std::getline( ss1, substr, ',' ) ) { + if ( !substr.empty() ) + namesListStr.push_back( substr ); + } + GEOMUtils::LevelInfo levelInfoData; + for( int node = 0; node < namesListStr.size(); node++ ) { + std::vector linksListStr; + std::stringstream ss2( namesListStr[node] ); + while ( std::getline( ss2, substr, '_' ) ) { + if ( !substr.empty() ) + linksListStr.push_back( substr ); + } + std::string nodeItem = linksListStr[0]; + if( !nodeItem.empty() ) { + GEOMUtils::NodeLinks linksListData; + for( int link = 1; link < linksListStr.size(); link++ ) { + std::string linkItem = linksListStr[link]; + linksListData.push_back( linkItem ); + }// Links + levelInfoData[nodeItem] = linksListData; + } + }// Level's objects + levelsListData.push_back(levelInfoData); + }// Levels + + theCursor = indexEnd + 1; + return levelsListData; + } + +} //======================================================================= //function : GetPosition //purpose : //======================================================================= -gp_Ax3 GetPosition (const TopoDS_Shape& theShape) +gp_Ax3 GEOMUtils::GetPosition (const TopoDS_Shape& theShape) { gp_Ax3 aResult; @@ -161,7 +388,7 @@ gp_Ax3 GetPosition (const TopoDS_Shape& theShape) //function : GetVector //purpose : //======================================================================= -gp_Vec GetVector (const TopoDS_Shape& theShape, +gp_Vec GEOMUtils::GetVector (const TopoDS_Shape& theShape, Standard_Boolean doConsiderOrientation) { if (theShape.IsNull()) @@ -186,51 +413,11 @@ gp_Vec GetVector (const TopoDS_Shape& theShape, return aV; } -//======================================================================= -//function : ShapeToDouble -//purpose : used by CompareShapes::operator() -//======================================================================= -std::pair ShapeToDouble (const TopoDS_Shape& S, bool isOldSorting) -{ - // Computing of CentreOfMass - gp_Pnt GPoint; - double Len; - - if (S.ShapeType() == TopAbs_VERTEX) { - GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S)); - Len = (double)S.Orientation(); - } - else { - GProp_GProps GPr; - // BEGIN: fix for Mantis issue 0020842 - if (isOldSorting) { - BRepGProp::LinearProperties(S, GPr); - } - else { - if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { - BRepGProp::LinearProperties(S, GPr); - } - else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { - BRepGProp::SurfaceProperties(S, GPr); - } - else { - BRepGProp::VolumeProperties(S, GPr); - } - } - // END: fix for Mantis issue 0020842 - GPoint = GPr.CentreOfMass(); - Len = GPr.Mass(); - } - - double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9; - return std::make_pair(dMidXYZ, Len); -} - //======================================================================= //function : CompareShapes::operator() //purpose : used by std::sort(), called from SortShapes() //======================================================================= -bool CompareShapes::operator() (const TopoDS_Shape& theShape1, +bool GEOMUtils::CompareShapes::operator() (const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2) { if (!myMap.IsBound(theShape1)) { @@ -290,7 +477,7 @@ bool CompareShapes::operator() (const TopoDS_Shape& theShape1, //function : SortShapes //purpose : //======================================================================= -void SortShapes (TopTools_ListOfShape& SL, +void GEOMUtils::SortShapes (TopTools_ListOfShape& SL, const Standard_Boolean isOldSorting) { #ifdef STD_SORT_ALGO @@ -428,7 +615,7 @@ void SortShapes (TopTools_ListOfShape& SL, //function : CompsolidToCompound //purpose : //======================================================================= -TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid) +TopoDS_Shape GEOMUtils::CompsolidToCompound (const TopoDS_Shape& theCompsolid) { if (theCompsolid.ShapeType() != TopAbs_COMPSOLID) { return theCompsolid; @@ -455,7 +642,7 @@ TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid) //function : AddSimpleShapes //purpose : //======================================================================= -void AddSimpleShapes (const TopoDS_Shape& theShape, TopTools_ListOfShape& theList) +void GEOMUtils::AddSimpleShapes (const TopoDS_Shape& theShape, TopTools_ListOfShape& theList) { if (theShape.ShapeType() != TopAbs_COMPOUND && theShape.ShapeType() != TopAbs_COMPSOLID) { @@ -483,7 +670,7 @@ void AddSimpleShapes (const TopoDS_Shape& theShape, TopTools_ListOfShape& theLis //function : CheckTriangulation //purpose : //======================================================================= -bool CheckTriangulation (const TopoDS_Shape& aShape) +bool GEOMUtils::CheckTriangulation (const TopoDS_Shape& aShape) { bool isTriangulation = true; @@ -533,7 +720,7 @@ bool CheckTriangulation (const TopoDS_Shape& aShape) //function : GetTypeOfSimplePart //purpose : //======================================================================= -TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape) +TopAbs_ShapeEnum GEOMUtils::GetTypeOfSimplePart (const TopoDS_Shape& theShape) { TopAbs_ShapeEnum aType = theShape.ShapeType(); if (aType == TopAbs_VERTEX) return TopAbs_VERTEX; @@ -554,7 +741,7 @@ TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape) //function : GetEdgeNearPoint //purpose : //======================================================================= -TopoDS_Shape GetEdgeNearPoint (const TopoDS_Shape& theShape, +TopoDS_Shape GEOMUtils::GetEdgeNearPoint (const TopoDS_Shape& theShape, const TopoDS_Vertex& thePoint) { TopoDS_Shape aResult; @@ -622,7 +809,7 @@ TopoDS_Shape GetEdgeNearPoint (const TopoDS_Shape& theShape, //function : PreciseBoundingBox //purpose : //======================================================================= -Standard_Boolean PreciseBoundingBox +Standard_Boolean GEOMUtils::PreciseBoundingBox (const TopoDS_Shape &theShape, Bnd_Box &theBox) { Standard_Real aBound[6]; @@ -668,7 +855,7 @@ Standard_Boolean PreciseBoundingBox // Get minimal distance between planar face and shape. Standard_Real aMinDist = - GetMinDistance(aFace, theShape, aPMin[0], aPMin[1]); + GEOMUtils::GetMinDistance(aFace, theShape, aPMin[0], aPMin[1]); if (aMinDist < 0.) { return Standard_False; @@ -684,128 +871,11 @@ Standard_Boolean PreciseBoundingBox return Standard_True; } -//======================================================================= -// function : ModifyShape -// purpose : This function constructs and returns modified shape -// from the original one for singular cases. -// It is used for the method GetMinDistanceSingular. -// -// \param theShape the original shape -// \param theModifiedShape output parameter. The modified shape. -// \param theAddDist output parameter. The added distance for modified shape. -// \retval true if the shape is modified; false otherwise. -// - -//======================================================================= -Standard_Boolean ModifyShape(const TopoDS_Shape &theShape, - TopoDS_Shape &theModifiedShape, - Standard_Real &theAddDist) -{ - Standard_Boolean isModified = Standard_False; - TopExp_Explorer anExp; - int nbf = 0; - - theAddDist = 0.; - theModifiedShape.Nullify(); - - for ( anExp.Init( theShape, TopAbs_FACE ); anExp.More(); anExp.Next() ) { - nbf++; - theModifiedShape = anExp.Current(); - } - if(nbf==1) { - TopoDS_Shape sh = theShape; - while(sh.ShapeType()==TopAbs_COMPOUND) { - TopoDS_Iterator it(sh); - sh = it.Value(); - } - Handle(Geom_Surface) S = BRep_Tool::Surface(TopoDS::Face(theModifiedShape)); - if( S->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || - S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) || - S->IsUPeriodic()) { - const Standard_Boolean isShell = - (sh.ShapeType()==TopAbs_SHELL || sh.ShapeType()==TopAbs_FACE); - - if( isShell || S->IsUPeriodic() ) { - // non solid case or any periodic surface (Mantis 22454). - double U1,U2,V1,V2; - // changes for 0020677: EDF 1219 GEOM: MinDistance gives 0 instead of 20.88 - //S->Bounds(U1,U2,V1,V2); changed by - ShapeAnalysis::GetFaceUVBounds(TopoDS::Face(theModifiedShape),U1,U2,V1,V2); - // end of changes for 020677 (dmv) - Handle(Geom_RectangularTrimmedSurface) TrS1 = - new Geom_RectangularTrimmedSurface(S,U1,(U1+U2)/2.,V1,V2); - Handle(Geom_RectangularTrimmedSurface) TrS2 = - new Geom_RectangularTrimmedSurface(S,(U1+U2)/2.,U2,V1,V2); - BRep_Builder B; - TopoDS_Face F1,F2; - TopoDS_Shape aMShape; - - if (isShell) { - B.MakeCompound(TopoDS::Compound(aMShape)); - } else { - B.MakeShell(TopoDS::Shell(aMShape)); - } - - B.MakeFace(F1,TrS1,1.e-7); - B.Add(aMShape,F1); - B.MakeFace(F2,TrS2,1.e-7); - B.Add(aMShape,F2); - Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape; - - if (!isShell) { - // The original shape is a solid. - TopoDS_Solid aSolid; - - B.MakeSolid(aSolid); - B.Add(aSolid, aMShape); - aMShape = aSolid; - } - - sfs->Init(aMShape); - sfs->SetPrecision(1.e-6); - sfs->SetMaxTolerance(1.0); - sfs->Perform(); - theModifiedShape = sfs->Shape(); - isModified = Standard_True; - } - else { - if( S->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ) { - Handle(Geom_SphericalSurface) SS = Handle(Geom_SphericalSurface)::DownCast(S); - gp_Pnt PC = SS->Location(); - BRep_Builder B; - TopoDS_Vertex V; - B.MakeVertex(V,PC,1.e-7); - theModifiedShape = V; - theAddDist = SS->Radius(); - isModified = Standard_True; - } - else { - Handle(Geom_ToroidalSurface) TS = Handle(Geom_ToroidalSurface)::DownCast(S); - gp_Ax3 ax3 = TS->Position(); - Handle(Geom_Circle) C = new Geom_Circle(ax3.Ax2(),TS->MajorRadius()); - BRep_Builder B; - TopoDS_Edge E; - B.MakeEdge(E,C,1.e-7); - theModifiedShape = E; - theAddDist = TS->MinorRadius(); - isModified = Standard_True; - } - } - } else { - theModifiedShape = theShape; - } - } - else - theModifiedShape = theShape; - - return isModified; -} - //======================================================================= //function : GetMinDistanceSingular //purpose : //======================================================================= -double GetMinDistanceSingular(const TopoDS_Shape& aSh1, +double GEOMUtils::GetMinDistanceSingular(const TopoDS_Shape& aSh1, const TopoDS_Shape& aSh2, gp_Pnt& Ptmp1, gp_Pnt& Ptmp2) { @@ -874,7 +944,7 @@ double GetMinDistanceSingular(const TopoDS_Shape& aSh1, //function : GetMinDistance //purpose : //======================================================================= -Standard_Real GetMinDistance +Standard_Real GEOMUtils::GetMinDistance (const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2, gp_Pnt& thePnt1, gp_Pnt& thePnt2) @@ -910,7 +980,7 @@ Standard_Real GetMinDistance // skl 30.06.2008 // additional workaround for bugs 19899, 19908 and 19910 from Mantis - double dist = GetMinDistanceSingular + double dist = GEOMUtils::GetMinDistanceSingular (theShape1, theShape2, thePnt1, thePnt2); if (dist > -1.0) { @@ -941,7 +1011,7 @@ Standard_Real GetMinDistance // function : ConvertClickToPoint() // purpose : Returns the point clicked in 3D view //======================================================================= -gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) aView ) +gp_Pnt GEOMUtils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView ) { V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt; aView->Eye( XEye, YEye, ZEye ); @@ -963,36 +1033,12 @@ gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) aView ) return ResultPoint; } -void parseWard( const LevelsList &theLevelList, std::string &treeStr ) -{ - treeStr.append( "{" ); - for( LevelsList::const_iterator j = theLevelList.begin(); - j != theLevelList.end(); ++j ) { - if ( j != theLevelList.begin() ) { - treeStr.append( ";" ); - } - LevelInfo level = (*j); - LevelInfo::iterator upIter; - for ( upIter = level.begin(); upIter != level.end(); ++upIter ) { - if ( upIter != level.begin() ) { - treeStr.append( "," ); - } - treeStr.append( upIter->first ); - for ( std::vector::iterator k = upIter->second.begin(); k != upIter->second.end(); ++k ) { - treeStr.append( "_" ); - treeStr.append( *k ); - } - } - } - treeStr.append( "}" ); -} - //======================================================================= // function : ConvertTreeToString() // purpose : Returns the string representation of dependency tree //======================================================================= -void ConvertTreeToString( const TreeModel &tree, - std::string &treeStr ) +void GEOMUtils::ConvertTreeToString( const TreeModel &tree, + std::string &treeStr ) { TreeModel::const_iterator i; for ( i = tree.begin(); i != tree.end(); ++i ) { @@ -1007,58 +1053,12 @@ void ConvertTreeToString( const TreeModel &tree, } } -LevelsList parseWard( const std::string& theData, std::size_t& theCursor ) -{ - std::size_t indexStart = theData.find( "{", theCursor ) + 1; - std::size_t indexEnd = theData.find( "}", indexStart ); - - std::string ward = theData.substr( indexStart, indexEnd - indexStart ); - std::stringstream ss(ward); - std::string substr; - std::vector levelsListStr; - while ( std::getline( ss, substr, ';' ) ) { - if ( !substr.empty() ) - levelsListStr.push_back( substr ); - } - LevelsList levelsListData; - for( int level = 0; level < levelsListStr.size(); level++ ) { - std::vector namesListStr; - std::stringstream ss1( levelsListStr[level] ); - while ( std::getline( ss1, substr, ',' ) ) { - if ( !substr.empty() ) - namesListStr.push_back( substr ); - } - LevelInfo levelInfoData; - for( int node = 0; node < namesListStr.size(); node++ ) { - std::vector linksListStr; - std::stringstream ss2( namesListStr[node] ); - while ( std::getline( ss2, substr, '_' ) ) { - if ( !substr.empty() ) - linksListStr.push_back( substr ); - } - std::string nodeItem = linksListStr[0]; - if( !nodeItem.empty() ) { - NodeLinks linksListData; - for( int link = 1; link < linksListStr.size(); link++ ) { - std::string linkItem = linksListStr[link]; - linksListData.push_back( linkItem ); - }// Links - levelInfoData[nodeItem] = linksListData; - } - }// Level's objects - levelsListData.push_back(levelInfoData); - }// Levels - - theCursor = indexEnd + 1; - return levelsListData; -} - //======================================================================= // function : ConvertStringToTree() // purpose : Returns the dependency tree //======================================================================= -void ConvertStringToTree( const std::string &theData, - TreeModel &tree ) +void GEOMUtils::ConvertStringToTree( const std::string &theData, + TreeModel &tree ) { std::size_t cursor = 0; @@ -1077,5 +1077,3 @@ void ConvertStringToTree( const std::string &theData, tree[objectEntry] = std::pair( upwardList, downwardList ); } } - -} //namespace GEOMUtils diff --git a/src/GEOMUtils/GEOMUtils.hxx b/src/GEOMUtils/GEOMUtils.hxx index b35495b62..95c0e7c0f 100644 --- a/src/GEOMUtils/GEOMUtils.hxx +++ b/src/GEOMUtils/GEOMUtils.hxx @@ -52,7 +52,8 @@ inline Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2) return S1.IsSame(S2); } -namespace GEOMUtils { +namespace GEOMUtils +{ typedef std::vector NodeLinks; typedef std::map LevelInfo; @@ -77,7 +78,7 @@ namespace GEOMUtils { * extracted from a shape. */ Standard_EXPORT gp_Vec GetVector (const TopoDS_Shape& theShape, - Standard_Boolean doConsiderOrientation); + Standard_Boolean doConsiderOrientation); /*! * \brief Sort shapes in the list by their coordinates. @@ -99,7 +100,7 @@ namespace GEOMUtils { * \brief Sort shapes by their centers of mass, using formula X*999 + Y*99 + Z*0.9 */ Standard_EXPORT void SortShapes (TopTools_ListOfShape& SL, - const Standard_Boolean isOldSorting = Standard_True); + const Standard_Boolean isOldSorting = Standard_True); /*! * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND. @@ -120,7 +121,7 @@ namespace GEOMUtils { * \param theList Output parameter. */ Standard_EXPORT void AddSimpleShapes (const TopoDS_Shape& theShape, - TopTools_ListOfShape& theList); + TopTools_ListOfShape& theList); /*! * \brief Build a triangulation on \a theShape if it is absent. @@ -128,7 +129,7 @@ namespace GEOMUtils { * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation. */ Standard_EXPORT bool CheckTriangulation (const TopoDS_Shape& theShape); - + /*! * \brief Return type of shape for explode. In case of compound it will be a type of its first sub shape. * \param theShape The shape to get type of. @@ -144,7 +145,7 @@ namespace GEOMUtils { * \retval TopoDS_Shape Returns the found edge or an empty shape if multiple edges found. */ Standard_EXPORT TopoDS_Shape GetEdgeNearPoint (const TopoDS_Shape& theShape, - const TopoDS_Vertex& thePoint); + const TopoDS_Vertex& thePoint); /*! * \brief Compute precise bounding box of the shape based on the rough bounding box. @@ -153,8 +154,7 @@ namespace GEOMUtils { * \param theBox rough bounding box on input; precise bounding box on output. * \retval Standard_True in case of success; Standard_False otherwise. */ - Standard_EXPORT Standard_Boolean PreciseBoundingBox - (const TopoDS_Shape &theShape, Bnd_Box &theBox); + Standard_EXPORT Standard_Boolean PreciseBoundingBox(const TopoDS_Shape &theShape, Bnd_Box &theBox); /*! * \brief Computes minumal distance between two shapes for singular cases @@ -166,11 +166,10 @@ namespace GEOMUtils { * \param Ptmp2 the output result point on the second shape * \retval negative value if it is not a singular case; actual distance for singular case. */ - Standard_EXPORT Standard_Real GetMinDistanceSingular - (const TopoDS_Shape& aSh1, - const TopoDS_Shape& aSh2, - gp_Pnt& Ptmp1, gp_Pnt& Ptmp2); - + Standard_EXPORT Standard_Real GetMinDistanceSingular(const TopoDS_Shape& aSh1, + const TopoDS_Shape& aSh2, + gp_Pnt& Ptmp1, gp_Pnt& Ptmp2); + /*! * \brief Computes minumal distance between two shapes. * @@ -180,11 +179,10 @@ namespace GEOMUtils { * \param thePnt2 the output result point on the second shape * \retval negative value in case of failure; otherwise the real distance. */ - Standard_EXPORT Standard_Real GetMinDistance - (const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2, - gp_Pnt& thePnt1, gp_Pnt& thePnt2); - + Standard_EXPORT Standard_Real GetMinDistance(const TopoDS_Shape& theShape1, + const TopoDS_Shape& theShape2, + gp_Pnt& thePnt1, gp_Pnt& thePnt2); + /*! * \brief Returns the point clicked in 3D view. * diff --git a/src/GEOMUtils/GEOMUtils_Hatcher.cxx b/src/GEOMUtils/GEOMUtils_Hatcher.cxx index be3500b2a..7f0d5083b 100755 --- a/src/GEOMUtils/GEOMUtils_Hatcher.cxx +++ b/src/GEOMUtils/GEOMUtils_Hatcher.cxx @@ -46,7 +46,7 @@ static float InfiniteValue = 1e38; //function : GEOMUtils_Hatcher //purpose : //======================================================================= -GEOMUtils_Hatcher::GEOMUtils_Hatcher(const TopoDS_Face &theFace) +GEOMUtils::Hatcher::Hatcher(const TopoDS_Face &theFace) : myHatcher(Geom2dHatch_Intersector (IntersectorConfusion, IntersectorTangency), HatcherConfusion2d, HatcherConfusion3d, Standard_True, Standard_False), @@ -140,7 +140,7 @@ GEOMUtils_Hatcher::GEOMUtils_Hatcher(const TopoDS_Face &theFace) //function : Init //purpose : //======================================================================= -void GEOMUtils_Hatcher::Init(const Standard_Integer theNbIsos) +void GEOMUtils::Hatcher::Init(const Standard_Integer theNbIsos) { Init(theNbIsos, theNbIsos); } @@ -149,8 +149,8 @@ void GEOMUtils_Hatcher::Init(const Standard_Integer theNbIsos) //function : Init //purpose : //======================================================================= -void GEOMUtils_Hatcher::Init(const Standard_Integer theNbIsoU, - const Standard_Integer theNbIsoV) +void GEOMUtils::Hatcher::Init(const Standard_Integer theNbIsoU, + const Standard_Integer theNbIsoV) { // Initialize data. Clear(); @@ -209,8 +209,8 @@ void GEOMUtils_Hatcher::Init(const Standard_Integer theNbIsoU, //function : Init //purpose : //======================================================================= -void GEOMUtils_Hatcher::Init(const GeomAbs_IsoType theIsoType, - const Standard_Real theParameter) +void GEOMUtils::Hatcher::Init(const GeomAbs_IsoType theIsoType, + const Standard_Real theParameter) { // Initialize data. Clear(); @@ -249,7 +249,7 @@ void GEOMUtils_Hatcher::Init(const GeomAbs_IsoType theIsoType, //function : Perform //purpose : //======================================================================= -void GEOMUtils_Hatcher::Perform() +void GEOMUtils::Hatcher::Perform() { myHatcher.Trim(); @@ -294,7 +294,7 @@ void GEOMUtils_Hatcher::Perform() //function : GetNbDomains //purpose : //======================================================================= -Standard_Integer GEOMUtils_Hatcher::GetNbDomains +Standard_Integer GEOMUtils::Hatcher::GetNbDomains (const Standard_Integer theHatchingIndex) const { Standard_Integer aResult = -1; @@ -310,7 +310,7 @@ Standard_Integer GEOMUtils_Hatcher::GetNbDomains //function : GetDomain //purpose : //======================================================================= -Standard_Boolean GEOMUtils_Hatcher::GetDomain +Standard_Boolean GEOMUtils::Hatcher::GetDomain (const Standard_Integer theHatchingIndex, const Standard_Integer theDomainIndex, Standard_Real &theParam1, @@ -348,7 +348,7 @@ Standard_Boolean GEOMUtils_Hatcher::GetDomain //function : IsDomainInfinite //purpose : //======================================================================= -Standard_Boolean GEOMUtils_Hatcher::IsDomainInfinite +Standard_Boolean GEOMUtils::Hatcher::IsDomainInfinite (const Standard_Integer theHatchingIndex, const Standard_Integer theDomainIndex) const { @@ -374,7 +374,7 @@ Standard_Boolean GEOMUtils_Hatcher::IsDomainInfinite //function : GetHatching //purpose : //======================================================================= -const Handle(Geom2d_Curve) &GEOMUtils_Hatcher::GetHatching +const Handle(Geom2d_Curve) &GEOMUtils::Hatcher::GetHatching (const Standard_Integer theHatchingIndex) const { const Geom2dAdaptor_Curve &aGACurve = @@ -387,7 +387,7 @@ const Handle(Geom2d_Curve) &GEOMUtils_Hatcher::GetHatching //function : Clear //purpose : //======================================================================= -void GEOMUtils_Hatcher::Clear() +void GEOMUtils::Hatcher::Clear() { myIsDone = Standard_False; myUPrm.Nullify(); diff --git a/src/GEOMUtils/GEOMUtils_Hatcher.hxx b/src/GEOMUtils/GEOMUtils_Hatcher.hxx index adcc2a258..845fa5dcc 100755 --- a/src/GEOMUtils/GEOMUtils_Hatcher.hxx +++ b/src/GEOMUtils/GEOMUtils_Hatcher.hxx @@ -34,175 +34,178 @@ /*! * This class represents a hatcher for topological faces. */ -class GEOMUtils_Hatcher { - -public: - - /** - * Constructor. Initializes the object with the face. - */ - Standard_EXPORT GEOMUtils_Hatcher(const TopoDS_Face &theFace); - - /** - * This method initializes the hatcher with hatchings. - * - * \param theNbIsos the number of U- and V-isolines. - */ - Standard_EXPORT void Init(const Standard_Integer theNbIsos); - - /** - * This method initializes the hatcher with hatchings. - * - * \param theNbIsoU the number of U-isolines. - * \param theNbIsoV the number of V-isolines. - */ - Standard_EXPORT void Init(const Standard_Integer theNbIsoU, - const Standard_Integer theNbIsoV); - - /** - * This method initializes the hatcher with a hatching. - * - * \param theIsoType the isoline type. - * \param theParameter the isoline parameter. - */ - Standard_EXPORT void Init(const GeomAbs_IsoType theIsoType, - const Standard_Real theParameter); - - /** - * Compute hatching domatins. - */ - Standard_EXPORT void Perform(); - - /** - * This method returns true if at least one hatching's domains - * are computed successfully. - * - * \return Standard_True is case of success. - */ - Standard_Boolean IsDone() const - { return myIsDone; } - - /** - * This method returns the initial face. - * - * \return the initial face. - */ - const TopoDS_Face &GetFace() const - { return myFace; } - - /** - * This method returns the number of domains for a particular hatching. - * If the operation is not done or there is no real hatching for - * a particular index a negative value is returned. - * - * \param theHatchingIndex the hatching index. - * \return the number of domains computed for the hatching. - */ - Standard_EXPORT Standard_Integer GetNbDomains - (const Standard_Integer theHatchingIndex) const; - - /** - * This method returns the domputed domain range computed for a particular - * hatching. theDomainIndex should be in the range [1..GetNbDomains]. - * - * \param theHatchingIndex the hatching index. - * \param theDomainIndex the domain index for the particular hatching. - * \param theParam1 (output) the first parameter of the domain. - * \param theParam2 (output) the last parameter of the domain. - * \return Standard_True in case of success; Standard_False otherwise. - */ - Standard_EXPORT Standard_Boolean GetDomain - (const Standard_Integer theHatchingIndex, - const Standard_Integer theDomainIndex, - Standard_Real &theParam1, - Standard_Real &theParam2) const; - - /** - * This method returns Standard_True if a domain has infinite first - * or last parameter. - * - * \param theHatchingIndex the hatching index. - * \param theDomainIndex the domain index for the particular hatching. - * \return Standard_True if a domain is infinite; Standard_False otherwise. - */ - Standard_EXPORT Standard_Boolean IsDomainInfinite - (const Standard_Integer theHatchingIndex, - const Standard_Integer theDomainIndex) const; - - /** - * This method returns the reference to OCCT hatcher. - * - * \return the reference to OCCT hatcher. - */ - Standard_EXPORT const Geom2dHatch_Hatcher &GetHatcher() const - { return myHatcher; } - - /** - * This method returns the array of indices of U-isoline hatchings. - * Can be null if the object is initialized by 0 U-isolines. - * - * \return the array of U-isoline hatching indices. - */ - Standard_EXPORT const Handle(TColStd_HArray1OfInteger) &GetUIndices() const - { return myUInd; } - - /** - * This method returns the array of indices of V-isoline hatchings. - * Can be null if the object is initialized by 0 V-isolines. - * - * \return the array of V-isoline hatching indices. - */ - Standard_EXPORT const Handle(TColStd_HArray1OfInteger) &GetVIndices() const - { return myVInd; } - - /** - * This method returns the array of parameters of U-isoline hatchings. - * Can be null if the object is initialized by 0 U-isolines. - * - * \return the array of U-isoline hatching parameters. - */ - Standard_EXPORT const Handle(TColStd_HArray1OfReal) &GetUParams() const - { return myUPrm; } - - /** - * This method returns the array of parameters of V-isoline hatchings. - * Can be null if the object is initialized by 0 V-isolines. - * - * \return the array of V-isoline hatching parameters. - */ - Standard_EXPORT const Handle(TColStd_HArray1OfReal) &GetVParams() const - { return myVPrm; } - - /** - * This method returns a hatching curve by its index. - * If the curve is not found null handle is returned. - * - * \param theHatchingIndex the hatching curve index. - */ - Standard_EXPORT const Handle(Geom2d_Curve) &GetHatching - (const Standard_Integer theHatchingIndex) const; - -protected: - - /** - * This method clears all hatchings data. - */ - void Clear(); - -private: - - Geom2dHatch_Hatcher myHatcher; - TopoDS_Face myFace; - Standard_Boolean myIsDone; - Standard_Real myUMin; - Standard_Real myUMax; - Standard_Real myVMin; - Standard_Real myVMax; - Handle(TColStd_HArray1OfReal) myUPrm; - Handle(TColStd_HArray1OfReal) myVPrm; - Handle(TColStd_HArray1OfInteger) myUInd; - Handle(TColStd_HArray1OfInteger) myVInd; - -}; +namespace GEOMUtils +{ + class Hatcher + { + public: + + /** + * Constructor. Initializes the object with the face. + */ + Standard_EXPORT Hatcher(const TopoDS_Face &theFace); + + /** + * This method initializes the hatcher with hatchings. + * + * \param theNbIsos the number of U- and V-isolines. + */ + Standard_EXPORT void Init(const Standard_Integer theNbIsos); + + /** + * This method initializes the hatcher with hatchings. + * + * \param theNbIsoU the number of U-isolines. + * \param theNbIsoV the number of V-isolines. + */ + Standard_EXPORT void Init(const Standard_Integer theNbIsoU, + const Standard_Integer theNbIsoV); + + /** + * This method initializes the hatcher with a hatching. + * + * \param theIsoType the isoline type. + * \param theParameter the isoline parameter. + */ + Standard_EXPORT void Init(const GeomAbs_IsoType theIsoType, + const Standard_Real theParameter); + + /** + * Compute hatching domatins. + */ + Standard_EXPORT void Perform(); + + /** + * This method returns true if at least one hatching's domains + * are computed successfully. + * + * \return Standard_True is case of success. + */ + Standard_Boolean IsDone() const + { return myIsDone; } + + /** + * This method returns the initial face. + * + * \return the initial face. + */ + const TopoDS_Face &GetFace() const + { return myFace; } + + /** + * This method returns the number of domains for a particular hatching. + * If the operation is not done or there is no real hatching for + * a particular index a negative value is returned. + * + * \param theHatchingIndex the hatching index. + * \return the number of domains computed for the hatching. + */ + Standard_EXPORT Standard_Integer GetNbDomains + (const Standard_Integer theHatchingIndex) const; + + /** + * This method returns the domputed domain range computed for a particular + * hatching. theDomainIndex should be in the range [1..GetNbDomains]. + * + * \param theHatchingIndex the hatching index. + * \param theDomainIndex the domain index for the particular hatching. + * \param theParam1 (output) the first parameter of the domain. + * \param theParam2 (output) the last parameter of the domain. + * \return Standard_True in case of success; Standard_False otherwise. + */ + Standard_EXPORT Standard_Boolean GetDomain + (const Standard_Integer theHatchingIndex, + const Standard_Integer theDomainIndex, + Standard_Real &theParam1, + Standard_Real &theParam2) const; + + /** + * This method returns Standard_True if a domain has infinite first + * or last parameter. + * + * \param theHatchingIndex the hatching index. + * \param theDomainIndex the domain index for the particular hatching. + * \return Standard_True if a domain is infinite; Standard_False otherwise. + */ + Standard_EXPORT Standard_Boolean IsDomainInfinite + (const Standard_Integer theHatchingIndex, + const Standard_Integer theDomainIndex) const; + + /** + * This method returns the reference to OCCT hatcher. + * + * \return the reference to OCCT hatcher. + */ + Standard_EXPORT const Geom2dHatch_Hatcher &GetHatcher() const + { return myHatcher; } + + /** + * This method returns the array of indices of U-isoline hatchings. + * Can be null if the object is initialized by 0 U-isolines. + * + * \return the array of U-isoline hatching indices. + */ + Standard_EXPORT const Handle(TColStd_HArray1OfInteger) &GetUIndices() const + { return myUInd; } + + /** + * This method returns the array of indices of V-isoline hatchings. + * Can be null if the object is initialized by 0 V-isolines. + * + * \return the array of V-isoline hatching indices. + */ + Standard_EXPORT const Handle(TColStd_HArray1OfInteger) &GetVIndices() const + { return myVInd; } + + /** + * This method returns the array of parameters of U-isoline hatchings. + * Can be null if the object is initialized by 0 U-isolines. + * + * \return the array of U-isoline hatching parameters. + */ + Standard_EXPORT const Handle(TColStd_HArray1OfReal) &GetUParams() const + { return myUPrm; } + + /** + * This method returns the array of parameters of V-isoline hatchings. + * Can be null if the object is initialized by 0 V-isolines. + * + * \return the array of V-isoline hatching parameters. + */ + Standard_EXPORT const Handle(TColStd_HArray1OfReal) &GetVParams() const + { return myVPrm; } + + /** + * This method returns a hatching curve by its index. + * If the curve is not found null handle is returned. + * + * \param theHatchingIndex the hatching curve index. + */ + Standard_EXPORT const Handle(Geom2d_Curve) &GetHatching + (const Standard_Integer theHatchingIndex) const; + + protected: + + /** + * This method clears all hatchings data. + */ + void Clear(); + + private: + + Geom2dHatch_Hatcher myHatcher; + TopoDS_Face myFace; + Standard_Boolean myIsDone; + Standard_Real myUMin; + Standard_Real myUMax; + Standard_Real myVMin; + Standard_Real myVMax; + Handle(TColStd_HArray1OfReal) myUPrm; + Handle(TColStd_HArray1OfReal) myVPrm; + Handle(TColStd_HArray1OfInteger) myUInd; + Handle(TColStd_HArray1OfInteger) myVInd; + + }; +} #endif diff --git a/src/GEOMUtils/GEOMUtils_XmlHandler.cxx b/src/GEOMUtils/GEOMUtils_XmlHandler.cxx new file mode 100644 index 000000000..00ad15878 --- /dev/null +++ b/src/GEOMUtils/GEOMUtils_XmlHandler.cxx @@ -0,0 +1,235 @@ +// Copyright (C) 2013-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 +// + +#include "GEOMUtils_XmlHandler.hxx" + +#include +#include + +//#define MYDEBUG + +namespace +{ + const char* env_var = "GEOM_PluginsList"; + + const xmlChar* root_tag = (xmlChar*)"geom-plugins"; + const xmlChar* plugin_tag = (xmlChar*)"geom-plugin"; + const xmlChar* name_tag = (xmlChar*)"name"; + const xmlChar* server_tag = (xmlChar*)"server-lib"; + const xmlChar* gui_tag = (xmlChar*)"gui-lib"; + const xmlChar* actions_tag = (xmlChar*)"actions"; + const xmlChar* action_tag = (xmlChar*)"action"; + const xmlChar* label_tag = (xmlChar*)"label"; + const xmlChar* icon_tag = (xmlChar*)"icon"; + const xmlChar* menu_tag = (xmlChar*)"menu"; + const xmlChar* tooltip_tag = (xmlChar*)"tooltip"; + const xmlChar* status_tag = (xmlChar*)"status-bar"; + const xmlChar* accel_tag = (xmlChar*)"accel"; + + std::string toUpper( const std::string& s ) + { + std::string r = s; + std::transform( r.begin(), r.end(), r.begin(), toupper ); + return r; + } + + std::string toLower( const std::string& s ) + { + std::string r = s; + std::transform( r.begin(), r.end(), r.begin(), tolower ); + return r; + } + + std::string readXmlAttribute(xmlNodePtr node, const xmlChar* attribute) + { + std::string result = ""; + xmlChar* strAttr = xmlGetProp(node, attribute); + if (strAttr != NULL) { + result = (char*)strAttr; + xmlFree(strAttr); + } + return result; + } + + std::list getPluginXMLFiles() + { + std::list xmlPaths; + +#ifdef WIN32 + std::string sep = "\\"; +#else + std::string sep = "/"; +#endif + + if ( const char* var = getenv( env_var ) ) + { + std::string plugins = var; + + std::string::size_type from = 0, pos; + while ( from < plugins.size() ) + { + pos = plugins.find( ':', from ); + std::string plugin; + if ( pos != std::string::npos ) + plugin = plugins.substr( from, pos-from ); + else + plugin = plugins.substr( from ), pos = plugins.size(); + from = pos + 1; + + if ( plugin.size() == 0 ) continue; + + std::string pluginRoot = toUpper( plugin+"_ROOT_DIR" ); + + const char* rootDirGeom = getenv( "GEOM_ROOT_DIR" ); + const char* rootDirPlugin = getenv( pluginRoot.c_str() ); + + bool fileOK = false; + if ( rootDirGeom ) { + std::string xmlPath = rootDirGeom; + if ( xmlPath[ xmlPath.size()-1 ] != sep[0] ) + xmlPath += sep; + xmlPath += "share" + sep + "salome" + sep + "resources" + sep + "geom" + sep + plugin + ".xml"; +#ifdef WIN32 + fileOK = (GetFileAttributes(xmlPath.c_str()) != INVALID_FILE_ATTRIBUTES); +#else + fileOK = (access(xmlPath.c_str(), F_OK) == 0); +#endif + if ( fileOK ) + xmlPaths.push_back( xmlPath ); + } + if ( !fileOK && rootDirPlugin ) { + std::string xmlPath = rootDirPlugin; + if ( xmlPath[ xmlPath.size()-1 ] != sep[0] ) + xmlPath += sep; + xmlPath += "share" + sep + "salome" + sep + "resources" + sep + toLower(plugin) + sep + plugin + ".xml"; +#ifdef WIN32 + fileOK = (GetFileAttributes(xmlPath.c_str()) != INVALID_FILE_ATTRIBUTES); +#else + fileOK = (access(xmlPath.c_str(), F_OK) == 0); +#endif + if ( fileOK ) + xmlPaths.push_back( xmlPath ); + } + } + } + return xmlPaths; + } + + void dumpinfo(const GEOMUtils::PluginInfo& info) + { + printf("DUMPING PLUGIN INFO\n"); + GEOMUtils::PluginInfo::const_iterator it; + for (it = info.begin(); it != info.end(); ++it) { + GEOMUtils::PluginData pdata = *it; + printf("Plugin: %s\n", pdata.name.c_str()); + printf(" serverLib = %s\n", pdata.serverLib.c_str()); + printf(" clientLib = %s\n", pdata.clientLib.c_str()); + printf(" actions:\n"); + std::list::const_iterator ait; + for (ait = pdata.actions.begin(); ait != pdata.actions.end(); ++ait) { + GEOMUtils::ActionData adata = *ait; + printf(" label = %s\n", adata.label.c_str()); + printf(" icon = %s\n", adata.icon.c_str()); + printf(" menuText = %s\n", adata.menuText.c_str()); + printf(" toolTip = %s\n", adata.toolTip.c_str()); + printf(" statusText = %s\n", adata.statusText.c_str()); + printf("\n"); + } + printf("-----\n"); + } + } +} + +namespace GEOMUtils +{ + PluginInfo ReadPluginInfo() + { + PluginInfo info; + + std::list xmlPaths = getPluginXMLFiles(); + + std::list::const_iterator fit; + + for ( fit = xmlPaths.begin(); fit != xmlPaths.end(); ++fit ) + { + std::string fileName = *fit; + + int options = XML_PARSE_HUGE | XML_PARSE_NOCDATA; + xmlDocPtr doc = xmlReadFile( fileName.c_str(), NULL, options ); + + if ( doc ) + { + // get root node + xmlNodePtr root = xmlDocGetRootElement(doc); + + // check if it is plugins container node + if (xmlStrcmp(root->name, root_tag) == 0) + { + // iterate through children, to get plugins data + for (xmlNodePtr node = root->children; node; node = node->next) + { + if (xmlStrcmp(node->name, plugin_tag) == 0) + { + // plugin node + PluginData data; + data.name = readXmlAttribute(node, name_tag); + data.serverLib = readXmlAttribute(node, server_tag); + data.clientLib = readXmlAttribute(node, gui_tag); + // iterate through children, to find actions container node + for (xmlNodePtr subnode = node->children; subnode; subnode = subnode->next) + { + if (xmlStrcmp(subnode->name, actions_tag) == 0) + { + // actions container node + // iterate through children, to get actions data + for (xmlNodePtr subsubnode = subnode->children; subsubnode; subsubnode = subsubnode->next) + { + if (xmlStrcmp(subsubnode->name, action_tag) == 0) + { + // action node + ActionData action; + action.label = readXmlAttribute(subsubnode, label_tag); + action.icon = readXmlAttribute(subsubnode, icon_tag); + action.menuText = readXmlAttribute(subsubnode, menu_tag); + action.toolTip = readXmlAttribute(subsubnode, tooltip_tag); + action.statusText = readXmlAttribute(subsubnode, status_tag); + action.accel = readXmlAttribute(subsubnode, accel_tag); + if (action.label != "") + data.actions.push_back(action); + } // end action node + } // end iteration through actions container node children + } // end actions container node + } // end iterations through plugin node children + + if (data.name != "") + info.push_back(data); + } // end plugin node + } // end iterations through plugins container node children + } // end root node + + xmlFreeDoc(doc); + xmlCleanupParser(); + } // end xml doc + } +#ifdef MYDEBUG + dumpinfo(info); +#endif + return info; + } +} diff --git a/src/GEOMUtils/GEOMUtils_XmlHandler.hxx b/src/GEOMUtils/GEOMUtils_XmlHandler.hxx new file mode 100644 index 000000000..e5952cff0 --- /dev/null +++ b/src/GEOMUtils/GEOMUtils_XmlHandler.hxx @@ -0,0 +1,56 @@ +// Copyright (C) 2013-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 +// + +#include + +#ifndef _GEOMUtils_XmlHandler_HXX_ +#define _GEOMUtils_XmlHandler_HXX_ + +#include +#include + +namespace GEOMUtils +{ + //! Plugin action data + struct ActionData + { + std::string label; //!< unique ID + std::string icon; //!< icon + std::string menuText; //!< menu text + std::string toolTip; //!< tooltip + std::string statusText; //!< status bar text + std::string accel; //!< shortcut + }; + + //! Plugin data + struct PluginData + { + std::string name; //!< plugin name + std::string serverLib; //!< engine library + std::string clientLib; //!< GUI library + std::list actions; //!< actions + }; + + //! Plugins information + typedef std::list PluginInfo; + + PluginInfo ReadPluginInfo(); +} + +#endif // _GEOMUtils_XmlHandler_HXX_ diff --git a/src/GEOM_I/CMakeLists.txt b/src/GEOM_I/CMakeLists.txt index ca49d2aca..d916ffe60 100755 --- a/src/GEOM_I/CMakeLists.txt +++ b/src/GEOM_I/CMakeLists.txt @@ -29,7 +29,6 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GEOM ${PROJECT_SOURCE_DIR}/src/GEOMAlgo ${PROJECT_SOURCE_DIR}/src/GEOMUtils - ${PROJECT_SOURCE_DIR}/src/XAO ${PROJECT_BINARY_DIR}/idl ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_BINARY_DIR} @@ -45,6 +44,7 @@ ADD_DEFINITIONS( # libraries to link to SET(_link_LIBRARIES GEOMImpl + GEOMUtils SalomeIDLGEOM ${KERNEL_SALOMELocalTrace} ${KERNEL_SalomeGenericObj} @@ -56,6 +56,8 @@ SET(_link_LIBRARIES # --- headers --- SET(GEOMEngine_HEADERS + GEOM_IFieldOperations_i.hh + GEOM_BaseObject_i.hh GEOM_Object_i.hh GEOM_IOperations_i.hh GEOM_IBasicOperations_i.hh diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index a764d3aeb..8069f40fe 100755 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -44,6 +44,7 @@ #include "GEOMImpl_CopyDriver.hxx" #include "GEOMImpl_IInsertOperations.hxx" #include "GEOM_wrap.hxx" +#include "GEOMUtils_XmlHandler.hxx" // Cascade headers #include @@ -121,6 +122,18 @@ GEOM_Gen_i::GEOM_Gen_i(CORBA::ORB_ptr orb, #endif OSD::SetSignal( raiseFPE ); } + + GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo(); + GEOMUtils::PluginInfo::const_iterator it; + for (it = plugins.begin(); it != plugins.end(); ++it) + { + try { + LoadPlugin((*it).serverLib); + } + catch (...) { + MESSAGE("Warning: can't load plugin library " << (*it).serverLib); + } + } } //============================================================================ @@ -303,7 +316,26 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, } else if ( mytype == GEOM_MARKER ) { aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_LCS"); aNamePrefix = "LocalCS_"; - } else if ( mytype > ADVANCED_BASE ) { + } else if ( mytype >= USER_TYPE_EX ) { + char buf[20]; + sprintf( buf, "%d", aBaseObj->GetType() ); + GEOM::CreationInformation_var info = aBaseObj->GetCreationInformation(); + std::string plgId; + for ( size_t i = 0; i < info->params.length(); ++i ) { + std::string param_name = info->params[i].name.in(); + std::string param_value = info->params[i].value.in(); + if( param_name == PLUGIN_NAME) { + plgId = param_value; + break; + } + } + if(plgId.length() > 0 ) { + plgId += "::"; + } + plgId +="ICON_OBJBROWSER_"; + plgId += buf; + aResultSO->SetAttrString("AttributePixMap",plgId.c_str()); + } else if ( mytype > USER_TYPE ) { char buf[20]; sprintf( buf, "%d", aBaseObj->GetType() ); std::string advId = "ICON_OBJBROWSER_ADVANCED_"; advId += buf; @@ -2405,74 +2437,84 @@ GEOM::GEOM_IOperations_ptr GEOM_Gen_i::GetPluginOperations(CORBA::Long theStudyI const char* theLibName) throw ( SALOME::SALOME_Exception ) { - std::string aPlatformLibName; -#ifdef WIN32 - aPlatformLibName = theLibName; - aPlatformLibName += ".dll" ; -#else - aPlatformLibName = "lib"; - aPlatformLibName += theLibName; - aPlatformLibName += ".so"; -#endif - Unexpect aCatch(SALOME_SalomeException); MESSAGE( "GEOM_Gen_i::GetPluginOperations" ); GEOM::GEOM_Gen_ptr engine = _this(); - GEOM_IOperations_i* aServant = 0; GEOM::GEOM_IOperations_var operations; - try { - // check, if corresponding operations are already created - if (myOpCreatorMap.find(std::string(theLibName)) == myOpCreatorMap.end()) { - // load plugin library - LibHandle libHandle = LoadLib( aPlatformLibName.c_str()/*theLibName*/ ); - if (!libHandle) { - // report any error, if occured -#ifndef WIN32 - const char* anError = dlerror(); - throw(SALOME_Exception(anError)); -#else - throw(SALOME_Exception(LOCALIZED( "Can't load server geometry plugin library" ))); -#endif - } - - // get method, returning operations creator - typedef GEOM_GenericOperationsCreator* (*GetOperationsCreator)(); - GetOperationsCreator procHandle = - (GetOperationsCreator)GetProc( libHandle, "GetOperationsCreator" ); - if (!procHandle) { - throw(SALOME_Exception(LOCALIZED("bad geometry plugin library"))); - UnLoadLib(libHandle); - } - - // get operations creator - GEOM_GenericOperationsCreator* aCreator = procHandle(); - if (!aCreator) { - throw(SALOME_Exception(LOCALIZED("bad geometry plugin library implementation"))); - } - - // map operations creator to a plugin name - myOpCreatorMap[std::string(theLibName)] = aCreator; - } + std::string aLibName = theLibName; + try { + // load plugin library + LoadPlugin(aLibName); // create a new operations object, store its ref. in engine - aServant = myOpCreatorMap[std::string(theLibName)]->Create(_poa, theStudyID, engine, _impl); - //??? aServant->SetLibName(aPlatformLibName/*theLibName*/); // for persistency assurance + if ( myOpCreatorMap.find(aLibName) != myOpCreatorMap.end() ) { + GEOM_IOperations_i* aServant = 0; + aServant = myOpCreatorMap[aLibName]->Create(_poa, theStudyID, engine, _impl); + // activate the CORBA servant + if (aServant) + operations = aServant->_this(); + } } catch (SALOME_Exception& S_ex) { THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); } - if (!aServant) - return operations._retn(); - - // activate the CORBA servant - operations = GEOM::GEOM_IOperations::_narrow( aServant->_this() ); return operations._retn(); } +//============================================================================ +// function : LoadPlugin +// purpose : load plugin library and retrieve an instance of operations creator +//============================================================================ +void GEOM_Gen_i::LoadPlugin(const std::string& theLibName) +{ + std::string aPlatformLibName; +#ifdef WIN32 + aPlatformLibName = theLibName; + aPlatformLibName += ".dll" ; +#else + aPlatformLibName = "lib"; + aPlatformLibName += theLibName; + aPlatformLibName += ".so"; +#endif + + // check, if corresponding operations are already created + if (myOpCreatorMap.find(theLibName) == myOpCreatorMap.end()) { + // load plugin library + LibHandle libHandle = LoadLib( aPlatformLibName.c_str() ); + if (!libHandle) { + // report any error, if occured +#ifndef WIN32 + throw(SALOME_Exception(dlerror())); +#else + throw(SALOME_Exception(LOCALIZED( "Can't load server geometry plugin library" ))); +#endif + } + + // get method, returning operations creator + typedef GEOM_GenericOperationsCreator* (*GetOperationsCreator)(); + GetOperationsCreator procHandle = + (GetOperationsCreator)GetProc( libHandle, "GetOperationsCreator" ); + if (!procHandle) { + UnLoadLib(libHandle); + throw(SALOME_Exception(LOCALIZED("bad geometry plugin library"))); + } + + // get operations creator + GEOM_GenericOperationsCreator* aCreator = procHandle(); + if (aCreator) { + // map operations creator to a plugin name + myOpCreatorMap[theLibName] = aCreator; + } + else { + throw(SALOME_Exception(LOCALIZED("bad geometry plugin library implementation"))); + } + } +} + //============================================================================= /*! * AddSubShape @@ -2925,30 +2967,26 @@ Engines::ListOfIdentifiers* GEOM_Gen_i::importData( aFile.write(aBuffer, aFileStream->length()); aFile.close(); - GEOM::GEOM_Object_var aShapeObj; - GEOM::ListOfGO_var aSubShape = new GEOM::ListOfGO; - GEOM::ListOfGO_var aGroups = new GEOM::ListOfGO; - GEOM::ListOfFields_var aFields = new GEOM::ListOfFields; - - CORBA::Boolean isResultOK = aInsOp->ImportXAO(aFullPath.c_str(), aShapeObj.out(), aSubShape.out(), aGroups.out(), aFields.out()); - - if ( isResultOK && !aShapeObj->_is_nil() && aInsOp->IsDone() ) { - SALOMEDS::SObject_var aSO = PublishInStudy(aStudy, SALOMEDS::SObject::_nil(), aShapeObj, aShapeObj->GetName()); - aResult->length(aGroups->length() + 1); - aResult[0] = aSO->GetID(); // unioque identifer of the object in GEOM is entry of SObject - //Iteration for objects of the group. - for (int i = 0; i < aGroups->length(); i++) { - SALOMEDS::SObject_var aSOChild = AddInStudy(aStudy, aGroups[i], aGroups[i]->GetName(), aShapeObj); - aResult[i+1] = aSOChild->GetID(); + GEOM::ListOfGO_var aObjects = aInsOp->ImportFile(aFullPath.c_str(), "XAO"); + + if ( aObjects->length() > 0 && aInsOp->IsDone() ) { + aResult->length(aObjects->length()); + // publish main object (first in the list of returned geom objects) + CORBA::String_var aName = aObjects[0]->GetName(); + SALOMEDS::SObject_var aSO = PublishInStudy(aStudy.in(), SALOMEDS::SObject::_nil(), aObjects[0].in(), aName.in()); + aResult[0] = aSO->GetID(); + // publish groups && fields + for (int i = 1; i < aObjects->length(); i++ ) { + aName = aObjects[i]->GetName(); + aSO = AddInStudy(aStudy.in(), aObjects[0].in(), aName.in(), aObjects[0].in()); + aResult[i] = aSO->GetID(); } } else { - if (aShapeObj->_is_nil()) - MESSAGE("Result of the import operation is incorrect for file "<length() == 0) + MESSAGE("ImportXAO operation is failed for file "<IsDone()) MESSAGE("Import operation is not done for file "<Resolve("/myStudyManager"); SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject ); + if (CORBA::is_nil(aStudyManager)) + return aResult._retn(); SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId ); + if (CORBA::is_nil(aStudy)) + return aResult._retn(); SALOMEDS::SComponent_var aComponent = aStudy->FindComponent("GEOM"); if (CORBA::is_nil(aComponent)) return aResult._retn(); SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(aComponent); // check only published shapes + GEOM::GEOM_IInsertOperations_var aInsOp = GetIInsertOperations(aStudy->StudyId()); + if (aInsOp->_is_nil()) { + MESSAGE("No insert operations!"); + return aResult._retn(); + } + GEOM::GEOM_Object_var shapeObj; - GEOM::ListOfGO_var groups = new GEOM::ListOfGO; - GEOM::ListOfFields_var fields = new GEOM::ListOfFields; - std::string anAuthorName = "SIMAN Author"; - GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(aStudy->StudyId()); - GEOM::GEOM_IInsertOperations_var aInsOp = GetIInsertOperations(aStudy->StudyId()); - - int aSeqLength = 0; // the sequence length for(; anIter->More(); anIter->Next()) { SALOMEDS::SObject_var aSO = anIter->Value(); SALOMEDS::SObject_var aRefSO; @@ -3006,13 +3047,7 @@ Engines::ListOfData* GEOM_Gen_i::getModifiedData(CORBA::Long studyId) GEOM::shape_type aCORBAShapeType = aCORBAMainShape->GetShapeType(); if (!aMainShape.IsNull() && !(aCORBAShapeType == GEOM::VERTEX) && !(aCORBAShapeType == GEOM::EDGE)) { - aSeqLength++; shapeObj = aCORBAMainShape; - if (aShapesOp->_is_nil()) { - MESSAGE("No shapes operations!"); - return aResult._retn(); - } - groups = aShapesOp->GetExistingSubObjects(aCORBAMainShape, true); break; } } @@ -3020,19 +3055,12 @@ Engines::ListOfData* GEOM_Gen_i::getModifiedData(CORBA::Long studyId) } } - if (aInsOp->_is_nil()) { - MESSAGE("No insert operations!"); - return aResult._retn(); - } - - if (aSeqLength > 0) { // Shape is correct, write it to the temporary file - - std::string aFullXaoPath = Kernel_Utils::GetTmpFileName() + ".xao"; - CORBA::Boolean isResultOK = aInsOp->ExportXAO(shapeObj.in(), groups.in(), fields.in(), anAuthorName.c_str(), aFullXaoPath.c_str()); - + if (!CORBA::is_nil(shapeObj)) { // Shape is correct, write it to the temporary file + std::string aPath = Kernel_Utils::GetTmpFileName() + ".xao"; + aInsOp->Export(shapeObj.in(), aPath.c_str(), "XAO"); aResult->length(1); Engines::DataContainer_var aData = (new Engines_DataContainer_i( - aFullXaoPath.c_str(), "", "", true))->_this(); + aPath.c_str(), "", "", true))->_this(); aResult[0] = aData; } else { MESSAGE("No shapes to export"); diff --git a/src/GEOM_I/GEOM_Gen_i.hh b/src/GEOM_I/GEOM_Gen_i.hh index 5a2c0382b..5af305551 100644 --- a/src/GEOM_I/GEOM_Gen_i.hh +++ b/src/GEOM_I/GEOM_Gen_i.hh @@ -404,6 +404,8 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi std::set& aChildren, std::set& anOthers); + void LoadPlugin(const std::string& theLibName); + private: ::GEOMImpl_Gen* _impl; diff --git a/src/GEOM_I/GEOM_IInsertOperations_i.cc b/src/GEOM_I/GEOM_IInsertOperations_i.cc index 3d8f79751..476e29ad7 100644 --- a/src/GEOM_I/GEOM_IInsertOperations_i.cc +++ b/src/GEOM_I/GEOM_IInsertOperations_i.cc @@ -113,11 +113,7 @@ void GEOM_IInsertOperations_i::Export if (anOriginal.IsNull()) return; //Export the shape to the file - char* aFileName = strdup(theFileName); - char* aFormatName = strdup(theFormatName); - GetOperations()->Export(anOriginal, aFileName, aFormatName); - free(aFileName); - free(aFormatName); + GetOperations()->Export(anOriginal, theFileName, theFormatName); } //============================================================================= @@ -135,18 +131,7 @@ GEOM::ListOfGO* GEOM_IInsertOperations_i::ImportFile GetOperations()->SetNotDone(); //Import the shape from the file - char* aFileName = strdup(theFileName); - char* aFormatName = strdup(theFormatName); - Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->Import(aFileName, aFormatName); - - if( strcmp(aFormatName,"IGES_UNIT")==0 && !aHSeq.IsNull() ) { - free(aFileName); - free(aFormatName); - return aSeq._retn(); - } - - free(aFileName); - free(aFormatName); + Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->Import(theFileName, theFormatName); if (!GetOperations()->IsDone() || aHSeq.IsNull()) { return aSeq._retn(); @@ -156,10 +141,8 @@ GEOM::ListOfGO* GEOM_IInsertOperations_i::ImportFile Standard_Integer aLength = aHSeq->Length(); aSeq->length(aLength); - - for (Standard_Integer i = 1; i <= aLength; i++) { + for (Standard_Integer i = 1; i <= aLength; i++) aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); - } return aSeq._retn(); } @@ -176,90 +159,12 @@ char* GEOM_IInsertOperations_i::ReadValue(const char* theFileName, //Set a not done flag GetOperations()->SetNotDone(); - char* aFileName = strdup(theFileName); - char* aFormatName = strdup(theFormatName); - char* aParameterName = strdup(theParameterName); - TCollection_AsciiString aUnits = GetOperations()->ReadValue - (aFileName, aFormatName, aParameterName); - - free(aFileName); - free(aFormatName); - free(aParameterName); + (theFileName, theFormatName, theParameterName); return CORBA::string_dup(aUnits.ToCString()); } -//============================================================================= -/*! - * ImportTranslators - */ -//============================================================================= -void GEOM_IInsertOperations_i::ImportTranslators - (GEOM::string_array_out theFormats, GEOM::string_array_out thePatterns) -{ - // allocate the CORBA arrays - GEOM::string_array_var aFormatsArray = new GEOM::string_array(); - GEOM::string_array_var aPatternsArray = new GEOM::string_array(); - - // Get sequences of available formats - Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString; - Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString; - if (GetOperations()->ImportTranslators(aFormats, aPatterns)) { - const int formSize = aFormats->Length(); - if (formSize == aPatterns->Length()) { - aFormatsArray->length(formSize); - aPatternsArray->length(formSize); - - // fill the local CORBA arrays with values from sequences - CORBA::Long i = 1; - for (; i <= formSize; i++) { - aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString()); - aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString()); - } - } - } - - // initialize out-parameters with local arrays - theFormats = aFormatsArray._retn(); - thePatterns = aPatternsArray._retn(); -} - -//============================================================================= -/*! - * ExportTranslators - */ -//============================================================================= -void GEOM_IInsertOperations_i::ExportTranslators - (GEOM::string_array_out theFormats, GEOM::string_array_out thePatterns) -{ - // allocate the CORBA arrays - GEOM::string_array_var aFormatsArray = new GEOM::string_array(); - GEOM::string_array_var aPatternsArray = new GEOM::string_array(); - - // Get sequences of available formats - Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString; - Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString; - if (GetOperations()->ExportTranslators(aFormats, aPatterns)) { - const int formSize = aFormats->Length(); - if (formSize == aPatterns->Length()) { - aFormatsArray->length(formSize); - aPatternsArray->length(formSize); - - // fill the local CORBA arrays with values from sequences - CORBA::Long i = 1; - for (; i <= formSize; i++) { - aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString()); - aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString()); - } - } - } - - // initialize out-parameters with local arrays - theFormats = aFormatsArray._retn(); - thePatterns = aPatternsArray._retn(); -} - //============================================================================= /*! * RestoreShape @@ -370,121 +275,4 @@ GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures() return anIDs._retn(); } -//============================================================================= -/*! - * Export a shape to XAO format - * \param shape The shape to export - * \param groups The list of groups to export - * \param fields The list of fields to export - * \param author The author of the export - * \param fileName The name of the exported file - * \return boolean indicating if export was succeful. - */ -//============================================================================= -CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape, - const GEOM::ListOfGO& groups, - const GEOM::ListOfFields& fields, - const char* author, - const char* fileName) -{ - bool isGood = false; - // Set a not done flag - GetOperations()->SetNotDone(); - - // Get the reference shape - Handle(GEOM_Object) reference = GetObjectImpl(shape); - - // Get the reference groups - int ind = 0; - std::list groupsObj; - for (; ind < groups.length(); ind++) - { - Handle(GEOM_Object) gobj = GetObjectImpl(groups[ind]); - if (gobj.IsNull()) return false; - groupsObj.push_back(gobj); - } - // Get the reference fields - ind = 0; - std::list fieldsObj; - for (; ind < fields.length(); ind++) - { - Handle(GEOM_Field) fobj = Handle(GEOM_Field)::DownCast(GetBaseObjectImpl(fields[ind])); - if (fobj.IsNull()) return false; - fieldsObj.push_back(fobj); - } - - if (!reference.IsNull()) - { - // Export XAO - isGood = GetOperations()->ExportXAO(reference, groupsObj, fieldsObj, author, fileName); - } - - return isGood; -} - -//============================================================================= -/*! - * Import a shape from XAO format - * \param fileName The name of the file to import - * \param shape The imported shape - * \param subShapes The list of imported subShapes - * \param groups The list of imported groups - * \param fields The list of imported fields - * \return boolean indicating if import was succeful. - */ -//============================================================================= -CORBA::Boolean GEOM_IInsertOperations_i::ImportXAO(const char* fileName, - GEOM::GEOM_Object_out shape, - GEOM::ListOfGO_out subShapes, - GEOM::ListOfGO_out groups, - GEOM::ListOfFields_out fields) -{ - GEOM::GEOM_Object_var vshape; - shape = vshape._retn(); - - subShapes = new GEOM::ListOfGO; - groups = new GEOM::ListOfGO; - fields = new GEOM::ListOfFields; - - // Set a not done flag - GetOperations()->SetNotDone(); - - Handle(TColStd_HSequenceOfTransient) importedSubShapes = new TColStd_HSequenceOfTransient(); - Handle(TColStd_HSequenceOfTransient) importedGroups = new TColStd_HSequenceOfTransient(); - Handle(TColStd_HSequenceOfTransient) importedFields = new TColStd_HSequenceOfTransient(); - Handle(GEOM_Object) hshape; - bool res = GetOperations()->ImportXAO(fileName, hshape, importedSubShapes, importedGroups, importedFields); - - if (!GetOperations()->IsDone() || !res) - return false; - - // parse fields - int n = importedSubShapes->Length(); - subShapes->length(n); - for (int i = 1; i <= n; i++) - { - (*subShapes)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedSubShapes->Value(i))); - } - - // parse groups - n = importedGroups->Length(); - groups->length(n); - for (int i = 1; i <= n; i++) - { - (*groups)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedGroups->Value(i))); - } - - // parse fields - n = importedFields->Length(); - fields->length(n); - for (int i = 1; i <= n; i++) - { - (*fields)[i - 1] = GEOM::GEOM_Field::_narrow( - GetBaseObject(Handle(GEOM_Field)::DownCast(importedFields->Value(i)))); - } - - shape = GetObject(hshape); - - return res; -} diff --git a/src/GEOM_I/GEOM_IInsertOperations_i.hh b/src/GEOM_I/GEOM_IInsertOperations_i.hh index d36e0446d..e06ffa08e 100644 --- a/src/GEOM_I/GEOM_IInsertOperations_i.hh +++ b/src/GEOM_I/GEOM_IInsertOperations_i.hh @@ -56,12 +56,6 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i : const char* theFormatName, const char* theParameterName); - void ImportTranslators (GEOM::string_array_out theFormats, - GEOM::string_array_out thePatterns); - - void ExportTranslators (GEOM::string_array_out theFormats, - GEOM::string_array_out thePatterns); - GEOM::GEOM_Object_ptr RestoreShape (const SALOMEDS::TMPFile& theStream); CORBA::Long LoadTexture(const char* theTextureFile); @@ -73,18 +67,6 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i : GEOM::ListOfLong* GetAllTextures(); - CORBA::Boolean ExportXAO (GEOM::GEOM_Object_ptr shape, - const GEOM::ListOfGO& groups, - const GEOM::ListOfFields& fields, - const char* author, - const char* fileName); - - CORBA::Boolean ImportXAO (const char* fileName, - GEOM::GEOM_Object_out shape, - GEOM::ListOfGO_out subShapes, - GEOM::ListOfGO_out groups, - GEOM::ListOfFields_out fields); - ::GEOMImpl_IInsertOperations* GetOperations() { return (::GEOMImpl_IInsertOperations*)GetImpl(); } }; diff --git a/src/GEOM_I/GEOM_wrap.hxx b/src/GEOM_I/GEOM_wrap.hxx index 181e7b18f..d4d99f776 100644 --- a/src/GEOM_I/GEOM_wrap.hxx +++ b/src/GEOM_I/GEOM_wrap.hxx @@ -60,7 +60,6 @@ namespace GEOM class GEOM_IInsertOperations; class GEOM_IMeasureOperations; class GEOM_IGroupOperations; - class GEOM_IAdvancedOperations; class GEOM_IFieldOperations; typedef SALOME::GenericObj_wrap< GEOM_IBasicOperations > GEOM_IBasicOperations_wrap; typedef SALOME::GenericObj_wrap< GEOM_ITransformOperations> GEOM_ITransformOperations_wrap; @@ -74,7 +73,6 @@ namespace GEOM typedef SALOME::GenericObj_wrap< GEOM_IInsertOperations > GEOM_IInsertOperations_wrap; typedef SALOME::GenericObj_wrap< GEOM_IMeasureOperations > GEOM_IMeasureOperations_wrap; typedef SALOME::GenericObj_wrap< GEOM_IGroupOperations > GEOM_IGroupOperations_wrap; - typedef SALOME::GenericObj_wrap< GEOM_IAdvancedOperations > GEOM_IAdvancedOperations_wrap; typedef SALOME::GenericObj_wrap< GEOM_IFieldOperations > GEOM_IFieldOperations_wrap; } diff --git a/src/GEOM_I_Superv/CMakeLists.txt b/src/GEOM_I_Superv/CMakeLists.txt index 6fe8abeac..0d5323d4d 100755 --- a/src/GEOM_I_Superv/CMakeLists.txt +++ b/src/GEOM_I_Superv/CMakeLists.txt @@ -37,6 +37,14 @@ ADD_DEFINITIONS( # libraries to link to SET(_link_LIBRARIES SalomeIDLGEOM + SalomeIDLGEOMSuperv + SalomeIDLAdvancedGEOM + SalomeIDLBREPPlugin + SalomeIDLIGESPlugin + SalomeIDLSTEPPlugin + SalomeIDLSTLPlugin + SalomeIDLVTKPlugin + SalomeIDLXAOPlugin ${KERNEL_SALOMELocalTrace} ${KERNEL_SalomeDSClient} ${KERNEL_SalomeLifeCycleCORBA} diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index de9ef8b3d..9070d8e9b 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -394,13 +394,108 @@ void GEOM_Superv_i::getAdvancedOp() { if (CORBA::is_nil(myGeomEngine)) setGeomEngine(); - // get GEOM_IAdvancedOperations interface + // get GEOM::IAdvancedOperations interface if (CORBA::is_nil(myAdvancedOp) || isNewStudy(myLastStudyID,myStudyID)) { //rnv: to fix bug "IPAL22461 6.3.0: Incorrect study storage if study contains shape modified with YACS" // Try to get id of the study from the SALOME Session if(myStudyID < 0 ) SetStudyID(-1); - //myAdvancedOp = myGeomEngine->GetIAdvancedOperations(myStudyID); - myAdvancedOp = GEOM::GEOM_IAdvancedOperations::_narrow(myGeomEngine->GetPluginOperations(myStudyID, "AdvancedEngine")); + myAdvancedOp = GEOM::IAdvancedOperations::_narrow(myGeomEngine->GetPluginOperations(myStudyID, "AdvancedEngine")); + } +} + +//============================================================================= +// getSTLPluginOp: +//============================================================================= +void GEOM_Superv_i::getSTLPluginOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM::ISTLOperations interface + if (CORBA::is_nil(mySTLOp) || isNewStudy(myLastStudyID,myStudyID)) { + //rnv: to fix bug "IPAL22461 6.3.0: Incorrect study storage if study contains shape modified with YACS" + // Try to get id of the study from the SALOME Session + if(myStudyID < 0 ) SetStudyID(-1); + mySTLOp = GEOM::ISTLOperations::_narrow(myGeomEngine->GetPluginOperations(myStudyID, "STLPluginEngine")); + } +} + +//============================================================================= +// getBREPPluginOp: +//============================================================================= +void GEOM_Superv_i::getBREPPluginOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM:IBREPOperations interface + if (CORBA::is_nil(myBREPOp) || isNewStudy(myLastStudyID,myStudyID)) { + //rnv: to fix bug "IPAL22461 6.3.0: Incorrect study storage if study contains shape modified with YACS" + // Try to get id of the study from the SALOME Session + if(myStudyID < 0 ) SetStudyID(-1); + myBREPOp = GEOM::IBREPOperations::_narrow(myGeomEngine->GetPluginOperations(myStudyID, "BREPPluginEngine")); + } +} + +//============================================================================= +// getSTEPPluginOp: +//============================================================================= +void GEOM_Superv_i::getSTEPPluginOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM::ISTEPOperations interface + if (CORBA::is_nil(mySTEPOp) || isNewStudy(myLastStudyID,myStudyID)) { + //rnv: to fix bug "IPAL22461 6.3.0: Incorrect study storage if study contains shape modified with YACS" + // Try to get id of the study from the SALOME Session + if(myStudyID < 0 ) SetStudyID(-1); + mySTEPOp = GEOM::ISTEPOperations::_narrow(myGeomEngine->GetPluginOperations(myStudyID, "STEPPluginEngine")); + } +} + +//============================================================================= +// getIGESPluginOp: +//============================================================================= +void GEOM_Superv_i::getIGESPluginOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM::IIGESOperations interface + if (CORBA::is_nil(myIGESOp) || isNewStudy(myLastStudyID,myStudyID)) { + //rnv: to fix bug "IPAL22461 6.3.0: Incorrect study storage if study contains shape modified with YACS" + // Try to get id of the study from the SALOME Session + if(myStudyID < 0 ) SetStudyID(-1); + myIGESOp = GEOM::IIGESOperations::_narrow(myGeomEngine->GetPluginOperations(myStudyID, "IGESPluginEngine")); + } +} + +//============================================================================= +// getXAOPluginOp: +//============================================================================= +void GEOM_Superv_i::getXAOPluginOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM::IXAOOperations interface + if (CORBA::is_nil(myXAOOp) || isNewStudy(myLastStudyID,myStudyID)) { + //rnv: to fix bug "IPAL22461 6.3.0: Incorrect study storage if study contains shape modified with YACS" + // Try to get id of the study from the SALOME Session + if(myStudyID < 0 ) SetStudyID(-1); + myXAOOp = GEOM::IXAOOperations::_narrow(myGeomEngine->GetPluginOperations(myStudyID, "XAOPluginEngine")); + } +} + +//============================================================================= +// getVTKPluginOp: +//============================================================================= +void GEOM_Superv_i::getVTKPluginOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM::IVTKOperations interface + if (CORBA::is_nil(myVTKOp) || isNewStudy(myLastStudyID,myStudyID)) { + //rnv: to fix bug "IPAL22461 6.3.0: Incorrect study storage if study contains shape modified with YACS" + // Try to get id of the study from the SALOME Session + if(myStudyID < 0 ) SetStudyID(-1); + myVTKOp = GEOM::IVTKOperations::_narrow(myGeomEngine->GetPluginOperations(myStudyID, "VTKPluginEngine")); } } @@ -1631,32 +1726,6 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::ImportFile (const char* theFileName, return anObj; } -//============================================================================= -// ImportTranslators: -//============================================================================= -void GEOM_Superv_i::ImportTranslators (GEOM::string_array_out theFormats, - GEOM::string_array_out thePatterns) -{ - beginService( " GEOM_Superv_i::ImportTranslators" ); - MESSAGE("GEOM_Superv_i::ImportTranslators"); - getInsOp(); - myInsOp->ImportTranslators(theFormats, thePatterns); - endService( " GEOM_Superv_i::ImportTranslators" ); -} - -//============================================================================= -// ExportTranslators: -//============================================================================= -void GEOM_Superv_i::ExportTranslators (GEOM::string_array_out theFormats, - GEOM::string_array_out thePatterns) -{ - beginService( " GEOM_Superv_i::ExportTranslators" ); - MESSAGE("GEOM_Superv_i::ExportTranslators"); - getInsOp(); - myInsOp->ExportTranslators(theFormats, thePatterns); - endService( " GEOM_Superv_i::ExportTranslators" ); -} - //============================= TransformOperations =========================== //============================================================================= // TranslateTwoPoints: @@ -3367,30 +3436,183 @@ GEOM::GEOM_List_ptr GEOM_Superv_i::GetObjects (GEOM::GEOM_Object_ptr theGroup) return aListPtr->_this(); } +//=============================== Import/Export Operations ============================= +//============================================================================= +// Export STL +//============================================================================= +void GEOM_Superv_i::ExportSTL( GEOM::GEOM_Object_ptr theObject, + const char* theFileName, + const bool theIsASCII, + CORBA::Double theDeflection, + const bool theIsRelative ) +{ + beginService( " GEOM_Superv_i::ExportSTL" ); + MESSAGE("GEOM_Superv_i::ExportSTL"); + getSTLPluginOp(); + mySTLOp->ExportSTL( theObject, theFileName, theIsASCII, theDeflection, theIsRelative ); + endService( " GEOM_Superv_i::ExportSTL" ); +} + +//============================================================================= +// Import STL +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::ImportSTL( const char* theFileName ) +{ + beginService( " GEOM_Superv_i::ImportSTL" ); + MESSAGE("GEOM_Superv_i::ImportSTL"); + getSTLPluginOp(); + GEOM::ListOfGO* aSeq = mySTLOp->ImportSTL(theFileName ); + GEOM::GEOM_Object_ptr anObj; + + if (aSeq->length() > 0) { + anObj = aSeq->operator[](0); + } + + endService( " GEOM_Superv_i::ImportSTL" ); + return anObj; +} + +//============================================================================= +// Export BREP +//============================================================================= +void GEOM_Superv_i::ExportBREP( GEOM::GEOM_Object_ptr theObject, + const char* theFileName ) +{ + beginService( " GEOM_Superv_i::ExportBREP" ); + MESSAGE("GEOM_Superv_i::ExportBREP"); + getBREPPluginOp(); + myBREPOp->ExportBREP( theObject, theFileName ); + endService( " GEOM_Superv_i::ExportBREP" ); +} + +//============================================================================= +// Import BREP +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::ImportBREP( const char* theFileName ) +{ + beginService( " GEOM_Superv_i::ImportBREP" ); + MESSAGE("GEOM_Superv_i::ImportBREP"); + getBREPPluginOp(); + GEOM::ListOfGO* aSeq = myBREPOp->ImportBREP(theFileName ); + GEOM::GEOM_Object_ptr anObj; + + if (aSeq->length() > 0) { + anObj = aSeq->operator[](0); + } + + endService( " GEOM_Superv_i::ImportBREP" ); + return anObj; +} + +//============================================================================= +// Export STEP +//============================================================================= +void GEOM_Superv_i::ExportSTEP( GEOM::GEOM_Object_ptr theObject, + const char* theFileName ) +{ + beginService( " GEOM_Superv_i::ExportSTEP" ); + MESSAGE("GEOM_Superv_i::ExportSTEP"); + getSTEPPluginOp(); + mySTEPOp->ExportSTEP( theObject, theFileName ); + endService( " GEOM_Superv_i::ExportSTEP" ); +} + +//============================================================================= +// Import STEP +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::ImportSTEP( const char* theFileName, + const bool theIsIgnoreUnits ) +{ + beginService( " GEOM_Superv_i::ImportSTEP" ); + MESSAGE("GEOM_Superv_i::ImportSTEP"); + getSTEPPluginOp(); + GEOM::ListOfGO* aSeq = mySTEPOp->ImportSTEP(theFileName, theIsIgnoreUnits ); + GEOM::GEOM_Object_ptr anObj; + + if (aSeq->length() > 0) { + anObj = aSeq->operator[](0); + } + + endService( " GEOM_Superv_i::ImportSTEP" ); + return anObj; +} + +//============================================================================= +// Export IGES +//============================================================================= +void GEOM_Superv_i::ExportIGES( GEOM::GEOM_Object_ptr theObject, + const char* theFileName, + const char* theVersion ) +{ + beginService( " GEOM_Superv_i::ExportIGES" ); + MESSAGE("GEOM_Superv_i::ExportIGES"); + getIGESPluginOp(); + myIGESOp->ExportIGES( theObject, theFileName, theVersion ); + endService( " GEOM_Superv_i::ExportIGES" ); +} + //============================================================================= -// ExportXAO +// Import IGES //============================================================================= -CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape, - const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields, - const char* author, const char* fileName) +GEOM::GEOM_Object_ptr GEOM_Superv_i::ImportIGES( const char* theFileName, + const bool theIsIgnoreUnits ) +{ + beginService( " GEOM_Superv_i::ImportIGES" ); + MESSAGE("GEOM_Superv_i::ImportIGES"); + getIGESPluginOp(); + GEOM::ListOfGO* aSeq = myIGESOp->ImportIGES(theFileName, theIsIgnoreUnits ); + GEOM::GEOM_Object_ptr anObj; + + if (aSeq->length() > 0) { + anObj = aSeq->operator[](0); + } + + endService( " GEOM_Superv_i::ImportIGES" ); + return anObj; +} + +//============================================================================= +// Export XAO +//============================================================================= +CORBA::Boolean GEOM_Superv_i::ExportXAO( GEOM::GEOM_Object_ptr shape, + const GEOM::ListOfGO& groups, + const GEOM::ListOfFields& fields, + const char* author, const char* fileName ) { beginService( " GEOM_Superv_i::ExportXAO" ); MESSAGE("GEOM_Superv_i::ExportXAO"); - getInsOp(); - CORBA::Boolean isGood = myInsOp->ExportXAO(shape, groups, fields, author, fileName); + getXAOPluginOp(); + CORBA::Boolean isGood = myXAOOp->ExportXAO( shape, groups, fields, author, fileName ); endService( " GEOM_Superv_i::ExportXAO" ); return isGood; } //============================================================================= -// ImportXAO +// Import XAO //============================================================================= -CORBA::Boolean GEOM_Superv_i::ImportXAO (const char* fileName, GEOM::GEOM_Object_out shape, - GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfFields_out fields) +CORBA::Boolean GEOM_Superv_i::ImportXAO( const char* fileName, + GEOM::GEOM_Object_out shape, + GEOM::ListOfGO_out subShapes, + GEOM::ListOfGO_out groups, + GEOM::ListOfFields_out fields ) { return false; } +//============================================================================= +// Export VTK +//============================================================================= +void GEOM_Superv_i::ExportVTK( GEOM::GEOM_Object_ptr theObject, + const char* theFileName, + CORBA::Double theDeflection ) +{ + beginService( " GEOM_Superv_i::ExportVTK" ); + MESSAGE("GEOM_Superv_i::ExportVTK"); + getVTKPluginOp(); + myVTKOp->ExportVTK( theObject, theFileName, theDeflection ); + endService( " GEOM_Superv_i::ExportVTK" ); +} + //=============================== Advanced Operations ============================= //============================================================================= // MakePipeTShape diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 708a0dab6..f33f4f8bb 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -28,6 +28,13 @@ // IDL headers #include #include CORBA_CLIENT_HEADER(GEOM_Gen) +#include CORBA_CLIENT_HEADER(AdvancedGEOM) +#include CORBA_CLIENT_HEADER(STLPlugin) +#include CORBA_CLIENT_HEADER(BREPPlugin) +#include CORBA_CLIENT_HEADER(STEPPlugin) +#include CORBA_CLIENT_HEADER(IGESPlugin) +#include CORBA_CLIENT_HEADER(XAOPlugin) +#include CORBA_CLIENT_HEADER(VTKPlugin) #include CORBA_SERVER_HEADER(GEOM_Superv) #include "SALOME_Component_i.hxx" @@ -61,6 +68,12 @@ public: void getLocalOp(); void getGroupOp(); void getAdvancedOp(); + void getSTLPluginOp(); + void getBREPPluginOp(); + void getSTEPPluginOp(); + void getIGESPluginOp(); + void getXAOPluginOp(); + void getVTKPluginOp(); PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject, PortableServer::POA_ptr thePOA); @@ -369,10 +382,6 @@ public: const char* theFormatName); GEOM::GEOM_Object_ptr ImportFile (const char* theFileName, const char* theFormatName); - void ImportTranslators (GEOM::string_array_out theFormats, - GEOM::string_array_out thePatterns); - void ExportTranslators (GEOM::string_array_out theFormats, - GEOM::string_array_out thePatterns); //-----------------------------------------------------------// // TransformOperations // @@ -699,11 +708,47 @@ public: //-----------------------------------------------------------// // ImportExport Operations // //-----------------------------------------------------------// - CORBA::Boolean ExportXAO(GEOM::GEOM_Object_ptr shape, - const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields, - const char* author, const char* fileName); - CORBA::Boolean ImportXAO(const char* fileName, GEOM::GEOM_Object_out shape, - GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfFields_out fields); + + void ExportSTL( GEOM::GEOM_Object_ptr theObject, + const char* theFileName, + const bool theIsASCII, + CORBA::Double theDeflection, + const bool theIsRelative ); + + GEOM::GEOM_Object_ptr ImportSTL( const char* theFileName ); + + void ExportBREP( GEOM::GEOM_Object_ptr theObject, + const char* theFileName ); + + GEOM::GEOM_Object_ptr ImportBREP( const char* theFileName ); + + void ExportSTEP( GEOM::GEOM_Object_ptr theObject, + const char* theFileName ); + + GEOM::GEOM_Object_ptr ImportSTEP( const char* theFileName, + const bool theIsIgnoreUnits ); + + void ExportIGES( GEOM::GEOM_Object_ptr theObject, + const char* theFileName, + const char* theVersion ); + + GEOM::GEOM_Object_ptr ImportIGES( const char* theFileName, + const bool theIsIgnoreUnits ); + + CORBA::Boolean ExportXAO( GEOM::GEOM_Object_ptr shape, + const GEOM::ListOfGO& groups, + const GEOM::ListOfFields& fields, + const char* author, + const char* fileName); + CORBA::Boolean ImportXAO( const char* fileName, + GEOM::GEOM_Object_out shape, + GEOM::ListOfGO_out subShapes, + GEOM::ListOfGO_out groups, + GEOM::ListOfFields_out fields ); + + void ExportVTK( GEOM::GEOM_Object_ptr theObject, + const char* theFileName, + CORBA::Double theDeflection ); //-----------------------------------------------------------// // Advanced Operations // @@ -754,7 +799,13 @@ private: GEOM::GEOM_ICurvesOperations_var myCurvesOp; GEOM::GEOM_ILocalOperations_var myLocalOp; GEOM::GEOM_IGroupOperations_var myGroupOp; - GEOM::GEOM_IAdvancedOperations_var myAdvancedOp; + GEOM::IAdvancedOperations_var myAdvancedOp; + GEOM::ISTLOperations_var mySTLOp; + GEOM::IBREPOperations_var myBREPOp; + GEOM::ISTEPOperations_var mySTEPOp; + GEOM::IIGESOperations_var myIGESOp; + GEOM::IXAOOperations_var myXAOOp; + GEOM::IVTKOperations_var myVTKOp; }; #endif diff --git a/src/GEOM_SWIG/AdvancedGEOMBuilder.py b/src/GEOM_SWIG/AdvancedGEOMBuilder.py new file mode 100644 index 000000000..4c9b16dbf --- /dev/null +++ b/src/GEOM_SWIG/AdvancedGEOMBuilder.py @@ -0,0 +1,572 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-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 +# +from GEOM import IAdvancedOperations + +# Engine Library Name +__libraryName__ = "AdvancedEngine" + +def GetAdvancedOperations(self): + anOp = self.GetPluginOperations(self.myStudyId, __libraryName__) + return anOp._narrow(IAdvancedOperations) + +## Create a T-shape object with specified caracteristics for the main +# and the incident pipes (radius, width, half-length). +# The extremities of the main pipe are located on junctions points P1 and P2. +# The extremity of the incident pipe is located on junction point P3. +# If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and +# the main plane of the T-shape is XOY. +# +# @param theR1 Internal radius of main pipe +# @param theW1 Width of main pipe +# @param theL1 Half-length of main pipe +# @param theR2 Internal radius of incident pipe (R2 < R1) +# @param theW2 Width of incident pipe (R2+W2 < R1+W1) +# @param theL2 Half-length of incident pipe +# +# @param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) +# @param theP1 1st junction point of main pipe +# @param theP2 2nd junction point of main pipe +# @param theP3 Junction point of incident pipe +# +# @param theRL Internal radius of left thickness reduction +# @param theWL Width of left thickness reduction +# @param theLtransL Length of left transition part +# @param theLthinL Length of left thin part +# +# @param theRR Internal radius of right thickness reduction +# @param theWR Width of right thickness reduction +# @param theLtransR Length of right transition part +# @param theLthinR Length of right thin part +# +# @param theRI Internal radius of incident thickness reduction +# @param theWI Width of incident thickness reduction +# @param theLtransI Length of incident transition part +# @param theLthinI Length of incident thin part +# +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# +# @return List of GEOM.GEOM_Object, containing the created shape and propagation groups. +# +# @ref tui_creation_pipetshape "Example" +# @ingroup l4_advanced +def MakePipeTShape (self, theR1, theW1, theL1, theR2, theW2, theL2, + theHexMesh=True, theP1=None, theP2=None, theP3=None, + theRL=0, theWL=0, theLtransL=0, theLthinL=0, + theRR=0, theWR=0, theLtransR=0, theLthinR=0, + theRI=0, theWI=0, theLtransI=0, theLthinI=0, + theName=None): + """ + Create a T-shape object with specified caracteristics for the main + and the incident pipes (radius, width, half-length). + The extremities of the main pipe are located on junctions points P1 and P2. + The extremity of the incident pipe is located on junction point P3. + If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and + the main plane of the T-shape is XOY. + + Parameters: + theR1 Internal radius of main pipe + theW1 Width of main pipe + theL1 Half-length of main pipe + theR2 Internal radius of incident pipe (R2 < R1) + theW2 Width of incident pipe (R2+W2 < R1+W1) + theL2 Half-length of incident pipe + theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) + theP1 1st junction point of main pipe + theP2 2nd junction point of main pipe + theP3 Junction point of incident pipe + + theRL Internal radius of left thickness reduction + theWL Width of left thickness reduction + theLtransL Length of left transition part + theLthinL Length of left thin part + + theRR Internal radius of right thickness reduction + theWR Width of right thickness reduction + theLtransR Length of right transition part + theLthinR Length of right thin part + + theRI Internal radius of incident thickness reduction + theWI Width of incident thickness reduction + theLtransI Length of incident transition part + theLthinI Length of incident thin part + + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + List of GEOM_Object, containing the created shape and propagation groups. + + Example of usage: + # create PipeTShape object + pipetshape = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0) + # create PipeTShape object with position + pipetshape_position = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, True, P1, P2, P3) + # create PipeTShape object with left thickness reduction + pipetshape_thr = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, theRL=60, theWL=20, theLtransL=40, theLthinL=20) + """ + from salome.geom.geomBuilder import ParseParameters, RaiseIfFailed, _toListOfNames + theR1, theW1, theL1, theR2, theW2, theL2, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI, Parameters = ParseParameters(theR1, theW1, theL1, theR2, theW2, theL2, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI) + anOp = GetAdvancedOperations(self) + if (theP1 and theP2 and theP3): + anObj = anOp.MakePipeTShapeTRWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theHexMesh, theP1, theP2, theP3) + else: + anObj = anOp.MakePipeTShapeTR(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theHexMesh) + pass + RaiseIfFailed("MakePipeTShape", anOp) + if Parameters: anObj[0].SetParameters(Parameters) + self.def_names = [ "pipeTShape" ] + [ "pipeTShape_grp_%d" % i for i in range(1, len(anObj)) ] + self._autoPublish(anObj, _toListOfNames(theName, len(anObj)), self.def_names) + anOp.UnRegister() + return anObj + +## Create a T-shape object with chamfer and with specified caracteristics for the main +# and the incident pipes (radius, width, half-length). The chamfer is +# created on the junction of the pipes. +# The extremities of the main pipe are located on junctions points P1 and P2. +# The extremity of the incident pipe is located on junction point P3. +# If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and +# the main plane of the T-shape is XOY. +# @param theR1 Internal radius of main pipe +# @param theW1 Width of main pipe +# @param theL1 Half-length of main pipe +# @param theR2 Internal radius of incident pipe (R2 < R1) +# @param theW2 Width of incident pipe (R2+W2 < R1+W1) +# @param theL2 Half-length of incident pipe +# @param theH Height of the chamfer. +# @param theW Width of the chamfer. +# @param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) +# @param theP1 1st junction point of main pipe +# @param theP2 2nd junction point of main pipe +# @param theP3 Junction point of incident pipe +# +# @param theRL Internal radius of left thickness reduction +# @param theWL Width of left thickness reduction +# @param theLtransL Length of left transition part +# @param theLthinL Length of left thin part +# +# @param theRR Internal radius of right thickness reduction +# @param theWR Width of right thickness reduction +# @param theLtransR Length of right transition part +# @param theLthinR Length of right thin part +# +# @param theRI Internal radius of incident thickness reduction +# @param theWI Width of incident thickness reduction +# @param theLtransI Length of incident transition part +# @param theLthinI Length of incident thin part +# +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# +# @return List of GEOM.GEOM_Object, containing the created shape and propagation groups. +# +# @ref tui_creation_pipetshape "Example" +# @ingroup l4_advanced +def MakePipeTShapeChamfer (self, theR1, theW1, theL1, theR2, theW2, theL2, + theH, theW, theHexMesh=True, theP1=None, theP2=None, theP3=None, + theRL=0, theWL=0, theLtransL=0, theLthinL=0, + theRR=0, theWR=0, theLtransR=0, theLthinR=0, + theRI=0, theWI=0, theLtransI=0, theLthinI=0, + theName=None): + """ + Create a T-shape object with chamfer and with specified caracteristics for the main + and the incident pipes (radius, width, half-length). The chamfer is + created on the junction of the pipes. + The extremities of the main pipe are located on junctions points P1 and P2. + The extremity of the incident pipe is located on junction point P3. + If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and + the main plane of the T-shape is XOY. + + Parameters: + theR1 Internal radius of main pipe + theW1 Width of main pipe + theL1 Half-length of main pipe + theR2 Internal radius of incident pipe (R2 < R1) + theW2 Width of incident pipe (R2+W2 < R1+W1) + theL2 Half-length of incident pipe + theH Height of the chamfer. + theW Width of the chamfer. + theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) + theP1 1st junction point of main pipe + theP2 2nd junction point of main pipe + theP3 Junction point of incident pipe + + theRL Internal radius of left thickness reduction + theWL Width of left thickness reduction + theLtransL Length of left transition part + theLthinL Length of left thin part + + theRR Internal radius of right thickness reduction + theWR Width of right thickness reduction + theLtransR Length of right transition part + theLthinR Length of right thin part + + theRI Internal radius of incident thickness reduction + theWI Width of incident thickness reduction + theLtransI Length of incident transition part + theLthinI Length of incident thin part + + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + List of GEOM_Object, containing the created shape and propagation groups. + + Example of usage: + # create PipeTShape with chamfer object + pipetshapechamfer = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0) + # create PipeTShape with chamfer object with position + pipetshapechamfer_position = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0, True, P1, P2, P3) + # create PipeTShape with chamfer object with left thickness reduction + pipetshapechamfer_thr = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0, theRL=60, theWL=20, theLtransL=40, theLthinL=20) + """ + from salome.geom.geomBuilder import ParseParameters, RaiseIfFailed, _toListOfNames + theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI, Parameters = ParseParameters(theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI) + anOp = GetAdvancedOperations(self) + if (theP1 and theP2 and theP3): + anObj = anOp.MakePipeTShapeTRChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theH, theW, theHexMesh, theP1, theP2, theP3) + else: + anObj = anOp.MakePipeTShapeTRChamfer(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theH, theW, theHexMesh) + pass + + RaiseIfFailed("MakePipeTShapeChamfer", anOp) + if Parameters: anObj[0].SetParameters(Parameters) + self.def_names = [ "pipeTShape" ] + [ "pipeTShape_grp_%d" % i for i in range(1, len(anObj)) ] + self._autoPublish(anObj, _toListOfNames(theName, len(anObj)), self.def_names) + anOp.UnRegister() + return anObj + +## Create a T-shape object with fillet and with specified caracteristics for the main +# and the incident pipes (radius, width, half-length). The fillet is +# created on the junction of the pipes. +# The extremities of the main pipe are located on junctions points P1 and P2. +# The extremity of the incident pipe is located on junction point P3. +# If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and +# the main plane of the T-shape is XOY. +# @param theR1 Internal radius of main pipe +# @param theW1 Width of main pipe +# @param theL1 Half-length of main pipe +# @param theR2 Internal radius of incident pipe (R2 < R1) +# @param theW2 Width of incident pipe (R2+W2 < R1+W1) +# @param theL2 Half-length of incident pipe +# @param theRF Radius of curvature of fillet. +# @param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) +# @param theP1 1st junction point of main pipe +# @param theP2 2nd junction point of main pipe +# @param theP3 Junction point of incident pipe +# +# @param theRL Internal radius of left thickness reduction +# @param theWL Width of left thickness reduction +# @param theLtransL Length of left transition part +# @param theLthinL Length of left thin part +# +# @param theRR Internal radius of right thickness reduction +# @param theWR Width of right thickness reduction +# @param theLtransR Length of right transition part +# @param theLthinR Length of right thin part +# +# @param theRI Internal radius of incident thickness reduction +# @param theWI Width of incident thickness reduction +# @param theLtransI Length of incident transition part +# @param theLthinI Length of incident thin part +# +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# +# @return List of GEOM.GEOM_Object, containing the created shape and propagation groups. +# +# @ref tui_creation_pipetshape "Example" +# @ingroup l4_advanced +def MakePipeTShapeFillet (self, theR1, theW1, theL1, theR2, theW2, theL2, + theRF, theHexMesh=True, theP1=None, theP2=None, theP3=None, + theRL=0, theWL=0, theLtransL=0, theLthinL=0, + theRR=0, theWR=0, theLtransR=0, theLthinR=0, + theRI=0, theWI=0, theLtransI=0, theLthinI=0, + theName=None): + """ + Create a T-shape object with fillet and with specified caracteristics for the main + and the incident pipes (radius, width, half-length). The fillet is + created on the junction of the pipes. + The extremities of the main pipe are located on junctions points P1 and P2. + The extremity of the incident pipe is located on junction point P3. + + Parameters: + If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and + the main plane of the T-shape is XOY. + theR1 Internal radius of main pipe + theW1 Width of main pipe + heL1 Half-length of main pipe + theR2 Internal radius of incident pipe (R2 < R1) + theW2 Width of incident pipe (R2+W2 < R1+W1) + theL2 Half-length of incident pipe + theRF Radius of curvature of fillet. + theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) + theP1 1st junction point of main pipe + theP2 2nd junction point of main pipe + theP3 Junction point of incident pipe + + theRL Internal radius of left thickness reduction + theWL Width of left thickness reduction + theLtransL Length of left transition part + theLthinL Length of left thin part + + theRR Internal radius of right thickness reduction + theWR Width of right thickness reduction + theLtransR Length of right transition part + theLthinR Length of right thin part + + theRI Internal radius of incident thickness reduction + theWI Width of incident thickness reduction + theLtransI Length of incident transition part + theLthinI Length of incident thin part + + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + List of GEOM_Object, containing the created shape and propagation groups. + + Example of usage: + # create PipeTShape with fillet object + pipetshapefillet = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0) + # create PipeTShape with fillet object with position + pipetshapefillet_position = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0, True, P1, P2, P3) + # create PipeTShape with fillet object with left thickness reduction + pipetshapefillet_thr = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0, theRL=60, theWL=20, theLtransL=40, theLthinL=20) + """ + from salome.geom.geomBuilder import ParseParameters, RaiseIfFailed, _toListOfNames + theR1, theW1, theL1, theR2, theW2, theL2, theRF, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI, Parameters = ParseParameters(theR1, theW1, theL1, theR2, theW2, theL2, theRF, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI) + anOp = GetAdvancedOperations(self) + if (theP1 and theP2 and theP3): + anObj = anOp.MakePipeTShapeTRFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theRF, theHexMesh, theP1, theP2, theP3) + else: + anObj = anOp.MakePipeTShapeTRFillet(theR1, theW1, theL1, theR2, theW2, theL2, + theRL, theWL, theLtransL, theLthinL, + theRR, theWR, theLtransR, theLthinR, + theRI, theWI, theLtransI, theLthinI, + theRF, theHexMesh) + pass + RaiseIfFailed("MakePipeTShapeFillet", anOp) + if Parameters: anObj[0].SetParameters(Parameters) + self.def_names = [ "pipeTShape" ] + [ "pipeTShape_grp_%d" % i for i in range(1, len(anObj)) ] + self._autoPublish(anObj, _toListOfNames(theName, len(anObj)), self.def_names) + anOp.UnRegister() + return anObj + +## This function allows creating a disk already divided into blocks. It +# can be used to create divided pipes for later meshing in hexaedra. +# @param theR Radius of the disk +# @param theOrientation Orientation of the plane on which the disk will be built +# 1 = XOY, 2 = OYZ, 3 = OZX +# @param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# +# @return New GEOM_Object, containing the created shape. +# +# @ref tui_creation_divideddisk "Example" +# @ingroup l4_advanced +def MakeDividedDisk(self, theR, theOrientation, thePattern, theName=None): + """ + Creates a disk, divided into blocks. It can be used to create divided pipes + for later meshing in hexaedra. + + Parameters: + theR Radius of the disk + theOrientation Orientation of the plane on which the disk will be built: + 1 = XOY, 2 = OYZ, 3 = OZX + thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM_Object, containing the created shape. + """ + from salome.geom.geomBuilder import ParseParameters, RaiseIfFailed, _toListOfNames + theR, Parameters = ParseParameters(theR) + anOp = GetAdvancedOperations(self) + anObj = anOp.MakeDividedDisk(theR, 67.0, theOrientation, thePattern) + RaiseIfFailed("MakeDividedDisk", anOp) + if Parameters: anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "dividedDisk") + anOp.UnRegister() + return anObj + +## This function allows creating a disk already divided into blocks. It +# can be used to create divided pipes for later meshing in hexaedra. +# @param theCenter Center of the disk +# @param theVector Normal vector to the plane of the created disk +# @param theRadius Radius of the disk +# @param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# +# @return New GEOM_Object, containing the created shape. +# +# @ref tui_creation_divideddisk "Example" +# @ingroup l4_advanced +def MakeDividedDiskPntVecR(self, theCenter, theVector, theRadius, thePattern, theName=None): + """ + Creates a disk already divided into blocks. It can be used to create divided pipes + for later meshing in hexaedra. + + Parameters: + theCenter Center of the disk + theVector Normal vector to the plane of the created disk + theRadius Radius of the disk + thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM_Object, containing the created shape. + """ + from salome.geom.geomBuilder import ParseParameters, RaiseIfFailed, _toListOfNames + theRadius, Parameters = ParseParameters(theRadius) + anOp = GetAdvancedOperations(self) + anObj = anOp.MakeDividedDiskPntVecR(theCenter, theVector, theRadius, 67.0, thePattern) + RaiseIfFailed("MakeDividedDiskPntVecR", anOp) + if Parameters: anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "dividedDisk") + anOp.UnRegister() + return anObj + +## Builds a cylinder prepared for hexa meshes +# @param theR Radius of the cylinder +# @param theH Height of the cylinder +# @param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# +# @return New GEOM_Object, containing the created shape. +# +# @ref tui_creation_dividedcylinder "Example" +# @ingroup l4_advanced +def MakeDividedCylinder(self, theR, theH, thePattern, theName=None): + """ + Builds a cylinder prepared for hexa meshes + + Parameters: + theR Radius of the cylinder + theH Height of the cylinder + thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM_Object, containing the created shape. + """ + from salome.geom.geomBuilder import ParseParameters, RaiseIfFailed, _toListOfNames + theR, theH, Parameters = ParseParameters(theR, theH) + anOp = GetAdvancedOperations(self) + anObj = anOp.MakeDividedCylinder(theR, theH, thePattern) + RaiseIfFailed("MakeDividedCylinder", anOp) + if Parameters: anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "dividedCylinder") + anOp.UnRegister() + return anObj + +## Create a surface from a cloud of points +# @param thelPoints list of points. Compounds of points are +# accepted as well. +# @param theNbMax maximum number of Bezier pieces in the resulting +# surface. +# @param theDegMax maximum degree of the resulting BSpline surface. +# @param theDMax 3D tolerance of initial approximation. +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# @return New GEOM_Object, containing the created shape. +# @note 3D tolerance of initial approximation represents a tolerance of +# initial plate surface approximation. If this parameter is equal +# to 0 (default value) it is computed. In this case an error of +# initial plate surface computation is used as the approximation +# tolerance. This error represents a maximal distance between +# computed plate surface and given points. +# +# @ref tui_creation_smoothingsurface "Example" +# @ingroup l4_advanced +def MakeSmoothingSurface(self, thelPoints, theNbMax=2, theDegMax=8, + theDMax=0.0, theName=None): + """ + Create a surface from a cloud of points + + Parameters: + thelPoints list of points. Compounds of points are + accepted as well. + theNbMax maximum number of Bezier pieces in the resulting + surface. + theDegMax maximum degree of the resulting BSpline surface. + theDMax 3D tolerance of initial approximation. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM_Object, containing the created shape. + + Note: + 3D tolerance of initial approximation represents a tolerance of + initial plate surface approximation. If this parameter is equal + to 0 (default value) it is computed. In this case an error of + initial plate surface computation is used as the approximation + tolerance. This error represents a maximal distance between + computed plate surface and given points. + """ + from salome.geom.geomBuilder import RaiseIfFailed + anOp = GetAdvancedOperations(self) + anObj = anOp.MakeSmoothingSurface(thelPoints, theNbMax, + theDegMax, theDMax) + RaiseIfFailed("MakeSmoothingSurface", anOp) + self._autoPublish(anObj, theName, "smoothing") + anOp.UnRegister() + return anObj diff --git a/src/GEOM_SWIG/BREPPluginBuilder.py b/src/GEOM_SWIG/BREPPluginBuilder.py new file mode 100644 index 000000000..edaba77a0 --- /dev/null +++ b/src/GEOM_SWIG/BREPPluginBuilder.py @@ -0,0 +1,91 @@ +# -*- coding: iso-8859-1 -*- +# 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 +# + +from GEOM import IBREPOperations + +# Engine Library Name +__libraryName__ = "BREPPluginEngine" + +def GetBREPPluginOperations(self): + anOp = self.GetPluginOperations(self.myStudyId, __libraryName__) + return anOp._narrow(IBREPOperations) + +## Export the given shape into a file with given name in BREP format. +# @param theObject Shape to be stored in the file. +# @param theFileName Name of the file to store the given shape in. +# @ingroup l2_import_export +def ExportBREP(self, theObject, theFileName): + """ + Export the given shape into a file with given name in BREP format. + + Parameters: + theObject Shape to be stored in the file. + theFileName Name of the file to store the given shape in. + """ + anOp = GetBREPPluginOperations(self) + anOp.ExportBREP(theObject, theFileName) + if anOp.IsDone() == 0: + raise RuntimeError, "Export : " + anOp.GetErrorCode() + pass + pass + + +## Import a shape from the BREP file +# @param theFileName The file, containing the shape. +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# +# @return New GEOM.GEOM_Object, containing the imported shape. +# If material names are imported it returns the list of +# objects. The first one is the imported object followed by +# material groups. +# @note Auto publishing is allowed for the shape itself. Imported +# material groups are not automatically published. +# @ingroup l2_import_export +def ImportBREP(self, theFileName, theName=None): + """ + Import a shape from the BREP file + + Parameters: + theFileName The file, containing the shape. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing the imported shape. + If material names are imported it returns the list of + objects. The first one is the imported object followed by + material groups. + Note: + Auto publishing is allowed for the shape itself. Imported + material groups are not automatically published. + """ + from salome.geom.geomBuilder import RaiseIfFailed + anOp = GetBREPPluginOperations(self) + aListObj = anOp.ImportBREP(theFileName) + RaiseIfFailed("ImportBREP", anOp) + aNbObj = len(aListObj) + if aNbObj > 0: + self._autoPublish(aListObj[0], theName, "imported") + if aNbObj == 1: + return aListObj[0] + return aListObj diff --git a/src/GEOM_SWIG/CMakeLists.txt b/src/GEOM_SWIG/CMakeLists.txt index e8460ba0a..02af16cdf 100755 --- a/src/GEOM_SWIG/CMakeLists.txt +++ b/src/GEOM_SWIG/CMakeLists.txt @@ -64,6 +64,55 @@ SET(_python_SCRIPTS gsketcher.py ) +# Advanced scripts + +SET(_python_advanced_SCRIPTS + AdvancedGEOMBuilder.py + __init__.py +) + +# STL plugin scripts + +SET(_python_STL_SCRIPTS + STLPluginBuilder.py + __init__.py +) + +# BREP plugin scripts + +SET(_python_BREP_SCRIPTS + BREPPluginBuilder.py + __init__.py +) + +# STEP plugin scripts + +SET(_python_STEP_SCRIPTS + STEPPluginBuilder.py + __init__.py +) + +# IGES plugin scripts + +SET(_python_IGES_SCRIPTS + IGESPluginBuilder.py + __init__.py +) + +# XAO plugin scripts + +SET(_python_XAO_SCRIPTS + XAOPluginBuilder.py + __init__.py +) + +# VTK plugin scripts + +SET(_python_VTK_SCRIPTS + VTKPluginBuilder.py + __init__.py +) + # scripts / shared SET(_shared_SCRIPTS @@ -75,3 +124,12 @@ SET(_shared_SCRIPTS SALOME_INSTALL_SCRIPTS("${_other_SCRIPTS}" ${SALOME_INSTALL_SCRIPT_DATA} DEF_PERMS) SALOME_INSTALL_SCRIPTS("${_shared_SCRIPTS}" ${SALOME_INSTALL_PYTHON_SHARED} DEF_PERMS) SALOME_INSTALL_SCRIPTS("${_python_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/geom DEF_PERMS) + +# Install plugin scripts +SALOME_INSTALL_SCRIPTS("${_python_advanced_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/AdvancedGEOM DEF_PERMS) +SALOME_INSTALL_SCRIPTS("${_python_STL_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/STLPlugin DEF_PERMS) +SALOME_INSTALL_SCRIPTS("${_python_BREP_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/BREPPlugin DEF_PERMS) +SALOME_INSTALL_SCRIPTS("${_python_STEP_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/STEPPlugin DEF_PERMS) +SALOME_INSTALL_SCRIPTS("${_python_IGES_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/IGESPlugin DEF_PERMS) +SALOME_INSTALL_SCRIPTS("${_python_XAO_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/XAOPlugin DEF_PERMS) +SALOME_INSTALL_SCRIPTS("${_python_VTK_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/VTKPlugin DEF_PERMS) diff --git a/src/GEOM_SWIG/IGESPluginBuilder.py b/src/GEOM_SWIG/IGESPluginBuilder.py new file mode 100644 index 000000000..684b0296f --- /dev/null +++ b/src/GEOM_SWIG/IGESPluginBuilder.py @@ -0,0 +1,132 @@ +# -*- coding: iso-8859-1 -*- +# 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 +# + +from GEOM import IIGESOperations + +# Engine Library Name +__libraryName__ = "IGESPluginEngine" + +def GetIGESPluginOperations(self): + anOp = self.GetPluginOperations(self.myStudyId, __libraryName__) + return anOp._narrow(IIGESOperations) + +## Export the given shape into a file with given name in IGES format. +# @param theObject Shape to be stored in the file. +# @param theFileName Name of the file to store the given shape in. +# @param theVersion Version of IGES format which defines, whether to write +# only faces (5.1 IGES format) or shells and solids also (5.3 IGES format). +# @ingroup l2_import_export +def ExportIGES(self, theObject, theFileName, theVersion="5.1"): + """ + Export the given shape into a file with given name in IGES format. + + Parameters: + theObject Shape to be stored in the file. + theFileName Name of the file to store the given shape in. + theVersion Version of IGES format which defines, whether to write + only faces (5.1 IGES format) or shells and solids also (5.3 IGES format). + """ + anOp = GetIGESPluginOperations(self) + anOp.ExportIGES(theObject, theFileName, theVersion) + if anOp.IsDone() == 0: + raise RuntimeError, "Export : " + anOp.GetErrorCode() + pass + pass + +## Import a shape from the IGES file with given name. +# @param theFileName The file, containing the shape. +# @param theIsIgnoreUnits If True, file length units will be ignored (set to 'meter') +# and result model will be scaled, if its units are not meters. +# If False (default), file length units will be taken into account. +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# +# @return New GEOM.GEOM_Object, containing the imported shape. +# If material names are imported it returns the list of +# objects. The first one is the imported object followed by +# material groups. +# @note Auto publishing is allowed for the shape itself. Imported +# material groups are not automatically published. +# +# @ref swig_Import_Export "Example" +# @ingroup l2_import_export +def ImportIGES(self, theFileName, theIsIgnoreUnits = False, theName=None): + """ + Import a shape from the IGES file with given name. + + Parameters: + theFileName The file, containing the shape. + ignoreUnits If True, file length units will be ignored (set to 'meter') + and result model will be scaled, if its units are not meters. + If False (default), file length units will be taken into account. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing the imported shape. + If material names are imported it returns the list of + objects. The first one is the imported object followed by + material groups. + Note: + Auto publishing is allowed for the shape itself. Imported + material groups are not automatically published. + """ + # Example: see GEOM_TestOthers.py + from salome.geom.geomBuilder import RaiseIfFailed + anOp = GetIGESPluginOperations(self) + + anIsIgnoreUnits = theIsIgnoreUnits + aName = theName + if isinstance( theIsIgnoreUnits, basestring ): + anIsIgnoreUnits = False + aName = theIsIgnoreUnits + pass + + aListObj = anOp.ImportIGES(theFileName,anIsIgnoreUnits) + RaiseIfFailed("ImportIGES", anOp) + aNbObj = len(aListObj) + if aNbObj > 0: + self._autoPublish(aListObj[0], aName, "imported") + if aNbObj == 1: + return aListObj[0] + return aListObj + +## Return length unit from given IGES file +# @param theFileName The file, containing the shape. +# @return String, containing the units name. +# +# @ref swig_Import_Export "Example" +# @ingroup l2_import_export +def GetIGESUnit(self, theFileName): + """ + Return length units from given IGES file + + Parameters: + theFileName The file, containing the shape. + + Returns: + String, containing the units name. + """ + # Example: see GEOM_TestOthers.py + anOp = GetIGESPluginOperations(self) + aUnitName = anOp.ReadValue( theFileName, "LEN_UNITS") + return aUnitName diff --git a/src/GEOM_SWIG/STEPPluginBuilder.py b/src/GEOM_SWIG/STEPPluginBuilder.py new file mode 100644 index 000000000..1a12060dd --- /dev/null +++ b/src/GEOM_SWIG/STEPPluginBuilder.py @@ -0,0 +1,128 @@ +# -*- coding: iso-8859-1 -*- +# 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 +# + +from GEOM import ISTEPOperations + +# Engine Library Name +__libraryName__ = "STEPPluginEngine" + +def GetSTEPPluginOperations(self): + anOp = self.GetPluginOperations(self.myStudyId, __libraryName__) + return anOp._narrow(ISTEPOperations) + +## Export the given shape into a file with given name in STEP format. +# @param theObject Shape to be stored in the file. +# @param theFileName Name of the file to store the given shape in. +# @ingroup l2_import_export +def ExportSTEP(self, theObject, theFileName): + """ + Export the given shape into a file with given name in STEP format. + + Parameters: + theObject Shape to be stored in the file. + theFileName Name of the file to store the given shape in. + """ + anOp = GetSTEPPluginOperations(self) + anOp.ExportSTEP(theObject, theFileName) + if anOp.IsDone() == 0: + raise RuntimeError, "Export : " + anOp.GetErrorCode() + pass + pass + +## Import a shape from the STEP file with given name. +# @param theFileName The file, containing the shape. +# @param theIsIgnoreUnits If True, file length units will be ignored (set to 'meter') +# and result model will be scaled, if its units are not meters. +# If False (default), file length units will be taken into account. +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# +# @return New GEOM.GEOM_Object, containing the imported shape. +# If material names are imported it returns the list of +# objects. The first one is the imported object followed by +# material groups. +# @note Auto publishing is allowed for the shape itself. Imported +# material groups are not automatically published. +# +# @ref swig_Import_Export "Example" +# @ingroup l2_import_export +def ImportSTEP(self, theFileName, theIsIgnoreUnits = False, theName=None): + """ + Import a shape from the STEP file with given name. + + Parameters: + theFileName The file, containing the shape. + ignoreUnits If True, file length units will be ignored (set to 'meter') + and result model will be scaled, if its units are not meters. + If False (default), file length units will be taken into account. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing the imported shape. + If material names are imported it returns the list of + objects. The first one is the imported object followed by + material groups. + Note: + Auto publishing is allowed for the shape itself. Imported + material groups are not automatically published. + """ + # Example: see GEOM_TestOthers.py + from salome.geom.geomBuilder import RaiseIfFailed + anOp = GetSTEPPluginOperations(self) + + anIsIgnoreUnits = theIsIgnoreUnits + aName = theName + if isinstance( theIsIgnoreUnits, basestring ): + anIsIgnoreUnits = False + aName = theIsIgnoreUnits + pass + + aListObj = anOp.ImportSTEP(theFileName,anIsIgnoreUnits) + RaiseIfFailed("ImportSTEP", anOp) + aNbObj = len(aListObj) + if aNbObj > 0: + self._autoPublish(aListObj[0], aName, "imported") + if aNbObj == 1: + return aListObj[0] + return aListObj + +## Return length unit from given STEP file +# @param theFileName The file, containing the shape. +# @return String, containing the units name. +# +# @ref swig_Import_Export "Example" +# @ingroup l2_import_export +def GetSTEPUnit(self, theFileName): + """ + Return length units from given STEP file + + Parameters: + theFileName The file, containing the shape. + + Returns: + String, containing the units name. + """ + # Example: see GEOM_TestOthers.py + anOp = GetSTEPPluginOperations(self) + aUnitName = anOp.ReadValue( theFileName, "LEN_UNITS") + return aUnitName diff --git a/src/GEOM_SWIG/STLPluginBuilder.py b/src/GEOM_SWIG/STLPluginBuilder.py new file mode 100644 index 000000000..39674429f --- /dev/null +++ b/src/GEOM_SWIG/STLPluginBuilder.py @@ -0,0 +1,100 @@ +# -*- coding: iso-8859-1 -*- +# 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 +# + +from GEOM import ISTLOperations + +# Engine Library Name +__libraryName__ = "STLPluginEngine" + +def GetSTLPluginOperations(self): + anOp = self.GetPluginOperations(self.myStudyId, __libraryName__) + return anOp._narrow(ISTLOperations) + +## Export the given shape into a file with given name in STL format. +# @param theObject Shape to be stored in the file. +# @param theFileName Name of the file to store the given shape in. +# @param theIsASCII The format of the exported file (ASCII or Binary) +# @param theDeflection Deflection of the given shape. +# @param theIsRelative If True (default value), the deflection +# is calculated relatively to the size of the shape; +# if False, the user defined deflection is used. +# @ingroup l2_import_export +def ExportSTL(self, theObject, theFileName, theIsASCII = True, theDeflection = 0.001, theIsRelative = True ): + """ + Export the given shape into a file with given name in STL format. + + Parameters: + theObject Shape to be stored in the file. + theFileName Name of the file to store the given shape in. + theIsASCII The format of the exported file (ASCII or Binary). + theDeflection Deflection of the given shape. + theRelative If True (default value), the deflection + is calculated relatively to the size of the shape; + if False, the user defined deflection is used. + """ + anOp = GetSTLPluginOperations(self) + anOp.ExportSTL(theObject, theFileName, theIsASCII, theDeflection, theIsRelative ) + if anOp.IsDone() == 0: + raise RuntimeError, "Export : " + anOp.GetErrorCode() + pass + pass + +## Import a shape from the STL file +# @param theFileName The file, containing the shape. +# @param theName Object name; when specified, this parameter is used +# for result publication in the study. Otherwise, if automatic +# publication is switched on, default value is used for result name. +# +# @return New GEOM.GEOM_Object, containing the imported shape. +# If material names are imported it returns the list of +# objects. The first one is the imported object followed by +# material groups. +# @note Auto publishing is allowed for the shape itself. Imported +# material groups are not automatically published. +# @ingroup l2_import_export +def ImportSTL(self, theFileName, theName=None): + """ + Import a shape from the STL file + + Parameters: + theFileName The file, containing the shape. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing the imported shape. + If material names are imported it returns the list of + objects. The first one is the imported object followed by + material groups. + Note: + Auto publishing is allowed for the shape itself. Imported + material groups are not automatically published. + """ + from salome.geom.geomBuilder import RaiseIfFailed + anOp = GetSTLPluginOperations(self) + aListObj = anOp.ImportSTL(theFileName) + RaiseIfFailed("ImportSTL", anOp) + aNbObj = len(aListObj) + if aNbObj > 0: + self._autoPublish(aListObj[0], theName, "imported") + if aNbObj == 1: + return aListObj[0] + return aListObj diff --git a/src/GEOM_SWIG/VTKPluginBuilder.py b/src/GEOM_SWIG/VTKPluginBuilder.py new file mode 100644 index 000000000..300535737 --- /dev/null +++ b/src/GEOM_SWIG/VTKPluginBuilder.py @@ -0,0 +1,50 @@ +# -*- coding: iso-8859-1 -*- +# 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 +# + +from GEOM import IVTKOperations + +# Engine Library Name +__libraryName__ = "VTKPluginEngine" + +def GetVTKPluginOperations(self): + anOp = self.GetPluginOperations(self.myStudyId, __libraryName__) + return anOp._narrow(IVTKOperations) + +## Export the given shape into a file with given name in VTK format. +# @param theObject Shape to be stored in the file. +# @param theFileName Name of the file to store the given shape in. +# @param theDeflection Deflection of the given shape. +# @ingroup l2_import_export +def ExportVTK(self, theObject, theFileName, theDeflection=0.001): + """ + Export the given shape into a file with given name in VTK format. + + Parameters: + theObject Shape to be stored in the file. + theFileName Name of the file to store the given shape in. + theIsASCII The format of the exported file (ASCII or Binary). + theDeflection Deflection of the given shape. + """ + anOp = GetVTKPluginOperations(self) + anOp.ExportVTK(theObject, theFileName, theDeflection) + if anOp.IsDone() == 0: + raise RuntimeError, "Export : " + anOp.GetErrorCode() + pass + pass diff --git a/src/GEOM_SWIG/XAOPluginBuilder.py b/src/GEOM_SWIG/XAOPluginBuilder.py new file mode 100644 index 000000000..aa9eef681 --- /dev/null +++ b/src/GEOM_SWIG/XAOPluginBuilder.py @@ -0,0 +1,61 @@ +# -*- coding: iso-8859-1 -*- +# 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 +# + +from GEOM import IXAOOperations + +# Engine Library Name +__libraryName__ = "XAOPluginEngine" + +def GetXAOPluginOperations(self): + anOp = self.GetPluginOperations(self.myStudyId, __libraryName__) + return anOp._narrow(IXAOOperations) + +## Export a shape to XAO format +# @param shape The shape to export +# @param groups The list of groups to export +# @param fields The list of fields to export +# @param author The author of the export +# @param fileName The name of the file to export +# @return boolean +# +# @ingroup l2_import_export +def ExportXAO(self, shape, groups, fields, author, fileName): + from salome.geom.geomBuilder import RaiseIfFailed + anOp = GetXAOPluginOperations(self) + res = anOp.ExportXAO(shape, groups, fields, author, fileName) + RaiseIfFailed("ExportXAO", anOp) + return res + +## Import a shape from XAO format +# @param fileName The name of the file to import +# @return tuple (res, shape, subShapes, groups, fields) +# res Flag indicating if the import was successful +# shape The imported shape +# subShapes The list of imported subShapes +# groups The list of imported groups +# fields The list of imported fields +# +# @ingroup l2_import_export +def ImportXAO(self, fileName): + from salome.geom.geomBuilder import RaiseIfFailed + anOp = GetXAOPluginOperations(self) + res = anOp.ImportXAO(fileName) + RaiseIfFailed("ImportXAO", anOp) + return res diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index c64bd6f40..c0cd25a60 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -657,7 +657,6 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self.MeasuOp = None self.BlocksOp = None self.GroupOp = None - self.AdvOp = None self.FieldOp = None pass @@ -774,14 +773,6 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self.GroupOp = self.GetIGroupOperations (self.myStudyId) self.FieldOp = self.GetIFieldOperations (self.myStudyId) - # The below line is a right way to map all plugin functions to geomBuilder, - # but AdvancedOperations are already mapped, that is why this line is commented - # and presents here only as an axample - #self.AdvOp = self.GetPluginOperations (self.myStudyId, "AdvancedEngine") - - # self.AdvOp is used by functions MakePipeTShape*, MakeDividedDisk, etc. - self.AdvOp = GEOM._objref_GEOM_Gen.GetPluginOperations (self, self.myStudyId, "AdvancedEngine") - # set GEOM as root in the use case tree self.myUseCaseBuilder = self.myStudy.GetUseCaseBuilder() self.myUseCaseBuilder.SetRootCurrent() @@ -790,16 +781,6 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): def GetPluginOperations(self, studyID, libraryName): op = GEOM._objref_GEOM_Gen.GetPluginOperations(self, studyID, libraryName) - if op: - # bind methods of operations to self - methods = op.__class__.__dict__['__methods__'] - avoid_methods = self.BasicOp.__class__.__dict__['__methods__'] - for meth_name in methods: - if not meth_name in avoid_methods: # avoid basic methods - function = getattr(op.__class__, meth_name) - if callable(function): - #self.__dict__[meth_name] = self.__PluginOperation(op, function) - self.__dict__[meth_name] = PluginOperation(op, function) return op ## Enable / disable results auto-publishing @@ -10706,8 +10687,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## @addtogroup l2_import_export ## @{ - ## Import a shape from the BREP or IGES or STEP file + ## Import a shape from the BREP, IGES, STEP or other file # (depends on given format) with given name. + # + # Note: this function is deprecated, it is kept for backward compatibility only + # Use Import instead, where is a name of desirable format to import. + # # @param theFileName The file, containing the shape. # @param theFormatName Specify format for the file reading. # Available formats can be obtained with InsertOp.ImportTranslators() method. @@ -10729,10 +10714,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): @ManageTransactions("InsertOp") def ImportFile(self, theFileName, theFormatName, theName=None): """ - Import a shape from the BREP or IGES or STEP file + Import a shape from the BREP, IGES, STEP or other file (depends on given format) with given name. - Parameters: + Note: this function is deprecated, it is kept for backward compatibility only + Use Import instead, where is a name of desirable format to import. + + Parameters: theFileName The file, containing the shape. theFormatName Specify format for the file reading. Available formats can be obtained with geompy.InsertOp.ImportTranslators() method. @@ -10753,6 +10741,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): material groups are not automatically published. """ # Example: see GEOM_TestOthers.py + print """ + WARNING: Function ImportFile is deprecated, use Import instead, + where is a name of desirable format for importing. + """ aListObj = self.InsertOp.ImportFile(theFileName, theFormatName) RaiseIfFailed("ImportFile", self.InsertOp) aNbObj = len(aListObj) @@ -10767,159 +10759,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ Deprecated analog of geompy.ImportFile, kept for backward compatibility only. """ - print "WARNING: Function Import is deprecated, use ImportFile instead" # note: auto-publishing is done in self.ImportFile() return self.ImportFile(theFileName, theFormatName, theName) - ## Shortcut to ImportFile() for BREP format. - # Import a shape from the BREP file with given name. - # @param theFileName The file, containing the shape. - # @param theName Object name; when specified, this parameter is used - # for result publication in the study. Otherwise, if automatic - # publication is switched on, default value is used for result name. - # - # @return New GEOM.GEOM_Object, containing the imported shape. - # - # @ref swig_Import_Export "Example" - def ImportBREP(self, theFileName, theName=None): - """ - geompy.ImportFile(...) function for BREP format - Import a shape from the BREP file with given name. - - Parameters: - theFileName The file, containing the shape. - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. - - Returns: - New GEOM.GEOM_Object, containing the imported shape. - """ - # Example: see GEOM_TestOthers.py - # note: auto-publishing is done in self.ImportFile() - return self.ImportFile(theFileName, "BREP", theName) - - ## Shortcut to ImportFile() for IGES format - # Import a shape from the IGES file with given name. - # @param theFileName The file, containing the shape. - # @param ignoreUnits If True, file length units will be ignored (set to 'meter') - # and result model will be scaled, if its units are not meters. - # If False (default), file length units will be taken into account. - # @param theName Object name; when specified, this parameter is used - # for result publication in the study. Otherwise, if automatic - # publication is switched on, default value is used for result name. - # - # @return New GEOM.GEOM_Object, containing the imported shape. - # - # @ref swig_Import_Export "Example" - def ImportIGES(self, theFileName, ignoreUnits = False, theName=None): - """ - geompy.ImportFile(...) function for IGES format - - Parameters: - theFileName The file, containing the shape. - ignoreUnits If True, file length units will be ignored (set to 'meter') - and result model will be scaled, if its units are not meters. - If False (default), file length units will be taken into account. - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. - - Returns: - New GEOM.GEOM_Object, containing the imported shape. - """ - # Example: see GEOM_TestOthers.py - # note: auto-publishing is done in self.ImportFile() - if ignoreUnits: - return self.ImportFile(theFileName, "IGES_SCALE", theName) - return self.ImportFile(theFileName, "IGES", theName) - - ## Return length unit from given IGES file - # @param theFileName The file, containing the shape. - # @return String, containing the units name. - # - # @ref swig_Import_Export "Example" - @ManageTransactions("InsertOp") - def GetIGESUnit(self, theFileName): - """ - Return length units from given IGES file - - Parameters: - theFileName The file, containing the shape. - - Returns: - String, containing the units name. - """ - # Example: see GEOM_TestOthers.py - aUnitName = self.InsertOp.ReadValue(theFileName, "IGES", "LEN_UNITS") - return aUnitName - - ## Shortcut to ImportFile() for STEP format - # Import a shape from the STEP file with given name. - # @param theFileName The file, containing the shape. - # @param ignoreUnits If True, file length units will be ignored (set to 'meter') - # and result model will be scaled, if its units are not meters. - # If False (default), file length units will be taken into account. - # @param theName Object name; when specified, this parameter is used - # for result publication in the study. Otherwise, if automatic - # publication is switched on, default value is used for result name. - # - # @return New GEOM.GEOM_Object, containing the imported shape. - # If material names are imported it returns the list of - # objects. The first one is the imported object followed by - # material groups. - # @note Auto publishing is allowed for the shape itself. Imported - # material groups are not automatically published. - # - # @ref swig_Import_Export "Example" - def ImportSTEP(self, theFileName, ignoreUnits = False, theName=None): - """ - geompy.ImportFile(...) function for STEP format - - Parameters: - theFileName The file, containing the shape. - ignoreUnits If True, file length units will be ignored (set to 'meter') - and result model will be scaled, if its units are not meters. - If False (default), file length units will be taken into account. - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. - - Returns: - New GEOM.GEOM_Object, containing the imported shape. - If material names are imported it returns the list of - objects. The first one is the imported object followed by - material groups. - Note: - Auto publishing is allowed for the shape itself. Imported - material groups are not automatically published. - """ - # Example: see GEOM_TestOthers.py - # note: auto-publishing is done in self.ImportFile() - if ignoreUnits: - return self.ImportFile(theFileName, "STEP_SCALE", theName) - return self.ImportFile(theFileName, "STEP", theName) - - ## Return length unit from given IGES or STEP file - # @param theFileName The file, containing the shape. - # @return String, containing the units name. - # - # @ref swig_Import_Export "Example" - @ManageTransactions("InsertOp") - def GetSTEPUnit(self, theFileName): - """ - Return length units from given STEP file - - Parameters: - theFileName The file, containing the shape. - - Returns: - String, containing the units name. - """ - # Example: see GEOM_TestOthers.py - aUnitName = self.InsertOp.ReadValue(theFileName, "STEP", "LEN_UNITS") - return aUnitName - ## Read a shape from the binary stream, containing its bounding representation (BRep). # @note This method will not be dumped to the python script by DumpStudy functionality. # @note GEOM.GEOM_Object.GetShapeStream() method can be used to obtain the shape's BRep stream. @@ -10955,6 +10797,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return anObj ## Export the given shape into a file with given name. + # + # Note: this function is deprecated, it is kept for backward compatibility only + # Use Export instead, where is a name of desirable format to export. + # # @param theObject Shape to be stored in the file. # @param theFileName Name of the file to store the given shape in. # @param theFormatName Specify format for the shape storage. @@ -10967,7 +10813,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ Export the given shape into a file with given name. - Parameters: + Note: this function is deprecated, it is kept for backward compatibility only + Use Export instead, where is a name of desirable format to export. + + Parameters: theObject Shape to be stored in the file. theFileName Name of the file to store the given shape in. theFormatName Specify format for the shape storage. @@ -10975,42 +10824,16 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): geompy.InsertOp.ExportTranslators()[0] method. """ # Example: see GEOM_TestOthers.py + print """ + WARNING: Function Export is deprecated, use Export instead, + where is a name of desirable format for exporting. + """ self.InsertOp.Export(theObject, theFileName, theFormatName) if self.InsertOp.IsDone() == 0: raise RuntimeError, "Export : " + self.InsertOp.GetErrorCode() pass pass - ## Shortcut to Export() for BREP format - # - # @ref swig_Import_Export "Example" - def ExportBREP(self,theObject, theFileName): - """ - geompy.Export(...) function for BREP format - """ - # Example: see GEOM_TestOthers.py - return self.Export(theObject, theFileName, "BREP") - - ## Shortcut to Export() for IGES format - # - # @ref swig_Import_Export "Example" - def ExportIGES(self,theObject, theFileName): - """ - geompy.Export(...) function for IGES format - """ - # Example: see GEOM_TestOthers.py - return self.Export(theObject, theFileName, "IGES") - - ## Shortcut to Export() for STEP format - # - # @ref swig_Import_Export "Example" - def ExportSTEP(self,theObject, theFileName): - """ - geompy.Export(...) function for STEP format - """ - # Example: see GEOM_TestOthers.py - return self.Export(theObject, theFileName, "STEP") - # end of l2_import_export ## @} @@ -12645,566 +12468,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # end of l3_groups ## @} - ## @addtogroup l4_advanced - ## @{ - - ## Create a T-shape object with specified caracteristics for the main - # and the incident pipes (radius, width, half-length). - # The extremities of the main pipe are located on junctions points P1 and P2. - # The extremity of the incident pipe is located on junction point P3. - # If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and - # the main plane of the T-shape is XOY. - # - # @param theR1 Internal radius of main pipe - # @param theW1 Width of main pipe - # @param theL1 Half-length of main pipe - # @param theR2 Internal radius of incident pipe (R2 < R1) - # @param theW2 Width of incident pipe (R2+W2 < R1+W1) - # @param theL2 Half-length of incident pipe - # - # @param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) - # @param theP1 1st junction point of main pipe - # @param theP2 2nd junction point of main pipe - # @param theP3 Junction point of incident pipe - # - # @param theRL Internal radius of left thickness reduction - # @param theWL Width of left thickness reduction - # @param theLtransL Length of left transition part - # @param theLthinL Length of left thin part - # - # @param theRR Internal radius of right thickness reduction - # @param theWR Width of right thickness reduction - # @param theLtransR Length of right transition part - # @param theLthinR Length of right thin part - # - # @param theRI Internal radius of incident thickness reduction - # @param theWI Width of incident thickness reduction - # @param theLtransI Length of incident transition part - # @param theLthinI Length of incident thin part - # - # @param theName Object name; when specified, this parameter is used - # for result publication in the study. Otherwise, if automatic - # publication is switched on, default value is used for result name. - # - # @return List of GEOM.GEOM_Object, containing the created shape and propagation groups. - # - # @ref tui_creation_pipetshape "Example" - @ManageTransactions("AdvOp") - def MakePipeTShape (self, theR1, theW1, theL1, theR2, theW2, theL2, - theHexMesh=True, theP1=None, theP2=None, theP3=None, - theRL=0, theWL=0, theLtransL=0, theLthinL=0, - theRR=0, theWR=0, theLtransR=0, theLthinR=0, - theRI=0, theWI=0, theLtransI=0, theLthinI=0, - theName=None): - """ - Create a T-shape object with specified caracteristics for the main - and the incident pipes (radius, width, half-length). - The extremities of the main pipe are located on junctions points P1 and P2. - The extremity of the incident pipe is located on junction point P3. - If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and - the main plane of the T-shape is XOY. - - Parameters: - theR1 Internal radius of main pipe - theW1 Width of main pipe - theL1 Half-length of main pipe - theR2 Internal radius of incident pipe (R2 < R1) - theW2 Width of incident pipe (R2+W2 < R1+W1) - theL2 Half-length of incident pipe - theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) - theP1 1st junction point of main pipe - theP2 2nd junction point of main pipe - theP3 Junction point of incident pipe - - theRL Internal radius of left thickness reduction - theWL Width of left thickness reduction - theLtransL Length of left transition part - theLthinL Length of left thin part - - theRR Internal radius of right thickness reduction - theWR Width of right thickness reduction - theLtransR Length of right transition part - theLthinR Length of right thin part - - theRI Internal radius of incident thickness reduction - theWI Width of incident thickness reduction - theLtransI Length of incident transition part - theLthinI Length of incident thin part - - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. - - Returns: - List of GEOM_Object, containing the created shape and propagation groups. - - Example of usage: - # create PipeTShape object - pipetshape = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0) - # create PipeTShape object with position - pipetshape_position = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, True, P1, P2, P3) - # create PipeTShape object with left thickness reduction - pipetshape_thr = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, theRL=60, theWL=20, theLtransL=40, theLthinL=20) - """ - theR1, theW1, theL1, theR2, theW2, theL2, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI, Parameters = ParseParameters(theR1, theW1, theL1, theR2, theW2, theL2, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI) - if (theP1 and theP2 and theP3): - anObj = self.AdvOp.MakePipeTShapeTRWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theHexMesh, theP1, theP2, theP3) - else: - anObj = self.AdvOp.MakePipeTShapeTR(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theHexMesh) - RaiseIfFailed("MakePipeTShape", self.AdvOp) - if Parameters: anObj[0].SetParameters(Parameters) - def_names = [ "pipeTShape" ] + [ "pipeTShape_grp_%d" % i for i in range(1, len(anObj)) ] - self._autoPublish(anObj, _toListOfNames(theName, len(anObj)), def_names) - return anObj - - ## Create a T-shape object with chamfer and with specified caracteristics for the main - # and the incident pipes (radius, width, half-length). The chamfer is - # created on the junction of the pipes. - # The extremities of the main pipe are located on junctions points P1 and P2. - # The extremity of the incident pipe is located on junction point P3. - # If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and - # the main plane of the T-shape is XOY. - # @param theR1 Internal radius of main pipe - # @param theW1 Width of main pipe - # @param theL1 Half-length of main pipe - # @param theR2 Internal radius of incident pipe (R2 < R1) - # @param theW2 Width of incident pipe (R2+W2 < R1+W1) - # @param theL2 Half-length of incident pipe - # @param theH Height of the chamfer. - # @param theW Width of the chamfer. - # @param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) - # @param theP1 1st junction point of main pipe - # @param theP2 2nd junction point of main pipe - # @param theP3 Junction point of incident pipe - # - # @param theRL Internal radius of left thickness reduction - # @param theWL Width of left thickness reduction - # @param theLtransL Length of left transition part - # @param theLthinL Length of left thin part - # - # @param theRR Internal radius of right thickness reduction - # @param theWR Width of right thickness reduction - # @param theLtransR Length of right transition part - # @param theLthinR Length of right thin part - # - # @param theRI Internal radius of incident thickness reduction - # @param theWI Width of incident thickness reduction - # @param theLtransI Length of incident transition part - # @param theLthinI Length of incident thin part - # - # @param theName Object name; when specified, this parameter is used - # for result publication in the study. Otherwise, if automatic - # publication is switched on, default value is used for result name. - # - # @return List of GEOM.GEOM_Object, containing the created shape and propagation groups. - # - # @ref tui_creation_pipetshape "Example" - @ManageTransactions("AdvOp") - def MakePipeTShapeChamfer (self, theR1, theW1, theL1, theR2, theW2, theL2, - theH, theW, theHexMesh=True, theP1=None, theP2=None, theP3=None, - theRL=0, theWL=0, theLtransL=0, theLthinL=0, - theRR=0, theWR=0, theLtransR=0, theLthinR=0, - theRI=0, theWI=0, theLtransI=0, theLthinI=0, - theName=None): - """ - Create a T-shape object with chamfer and with specified caracteristics for the main - and the incident pipes (radius, width, half-length). The chamfer is - created on the junction of the pipes. - The extremities of the main pipe are located on junctions points P1 and P2. - The extremity of the incident pipe is located on junction point P3. - If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and - the main plane of the T-shape is XOY. - - Parameters: - theR1 Internal radius of main pipe - theW1 Width of main pipe - theL1 Half-length of main pipe - theR2 Internal radius of incident pipe (R2 < R1) - theW2 Width of incident pipe (R2+W2 < R1+W1) - theL2 Half-length of incident pipe - theH Height of the chamfer. - theW Width of the chamfer. - theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) - theP1 1st junction point of main pipe - theP2 2nd junction point of main pipe - theP3 Junction point of incident pipe - - theRL Internal radius of left thickness reduction - theWL Width of left thickness reduction - theLtransL Length of left transition part - theLthinL Length of left thin part - - theRR Internal radius of right thickness reduction - theWR Width of right thickness reduction - theLtransR Length of right transition part - theLthinR Length of right thin part - - theRI Internal radius of incident thickness reduction - theWI Width of incident thickness reduction - theLtransI Length of incident transition part - theLthinI Length of incident thin part - - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. - - Returns: - List of GEOM_Object, containing the created shape and propagation groups. - - Example of usage: - # create PipeTShape with chamfer object - pipetshapechamfer = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0) - # create PipeTShape with chamfer object with position - pipetshapechamfer_position = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0, True, P1, P2, P3) - # create PipeTShape with chamfer object with left thickness reduction - pipetshapechamfer_thr = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0, theRL=60, theWL=20, theLtransL=40, theLthinL=20) - """ - theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI, Parameters = ParseParameters(theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI) - if (theP1 and theP2 and theP3): - anObj = self.AdvOp.MakePipeTShapeTRChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theH, theW, theHexMesh, theP1, theP2, theP3) - else: - anObj = self.AdvOp.MakePipeTShapeTRChamfer(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theH, theW, theHexMesh) - RaiseIfFailed("MakePipeTShapeChamfer", self.AdvOp) - if Parameters: anObj[0].SetParameters(Parameters) - def_names = [ "pipeTShape" ] + [ "pipeTShape_grp_%d" % i for i in range(1, len(anObj)) ] - self._autoPublish(anObj, _toListOfNames(theName, len(anObj)), def_names) - return anObj - - ## Create a T-shape object with fillet and with specified caracteristics for the main - # and the incident pipes (radius, width, half-length). The fillet is - # created on the junction of the pipes. - # The extremities of the main pipe are located on junctions points P1 and P2. - # The extremity of the incident pipe is located on junction point P3. - # If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and - # the main plane of the T-shape is XOY. - # @param theR1 Internal radius of main pipe - # @param theW1 Width of main pipe - # @param theL1 Half-length of main pipe - # @param theR2 Internal radius of incident pipe (R2 < R1) - # @param theW2 Width of incident pipe (R2+W2 < R1+W1) - # @param theL2 Half-length of incident pipe - # @param theRF Radius of curvature of fillet. - # @param theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) - # @param theP1 1st junction point of main pipe - # @param theP2 2nd junction point of main pipe - # @param theP3 Junction point of incident pipe - # - # @param theRL Internal radius of left thickness reduction - # @param theWL Width of left thickness reduction - # @param theLtransL Length of left transition part - # @param theLthinL Length of left thin part - # - # @param theRR Internal radius of right thickness reduction - # @param theWR Width of right thickness reduction - # @param theLtransR Length of right transition part - # @param theLthinR Length of right thin part - # - # @param theRI Internal radius of incident thickness reduction - # @param theWI Width of incident thickness reduction - # @param theLtransI Length of incident transition part - # @param theLthinI Length of incident thin part - # - # @param theName Object name; when specified, this parameter is used - # for result publication in the study. Otherwise, if automatic - # publication is switched on, default value is used for result name. - # - # @return List of GEOM.GEOM_Object, containing the created shape and propagation groups. - # - # @ref tui_creation_pipetshape "Example" - @ManageTransactions("AdvOp") - def MakePipeTShapeFillet (self, theR1, theW1, theL1, theR2, theW2, theL2, - theRF, theHexMesh=True, theP1=None, theP2=None, theP3=None, - theRL=0, theWL=0, theLtransL=0, theLthinL=0, - theRR=0, theWR=0, theLtransR=0, theLthinR=0, - theRI=0, theWI=0, theLtransI=0, theLthinI=0, - theName=None): - """ - Create a T-shape object with fillet and with specified caracteristics for the main - and the incident pipes (radius, width, half-length). The fillet is - created on the junction of the pipes. - The extremities of the main pipe are located on junctions points P1 and P2. - The extremity of the incident pipe is located on junction point P3. - - Parameters: - If P1, P2 and P3 are not given, the center of the shape is (0,0,0) and - the main plane of the T-shape is XOY. - theR1 Internal radius of main pipe - theW1 Width of main pipe - heL1 Half-length of main pipe - theR2 Internal radius of incident pipe (R2 < R1) - theW2 Width of incident pipe (R2+W2 < R1+W1) - theL2 Half-length of incident pipe - theRF Radius of curvature of fillet. - theHexMesh Boolean indicating if shape is prepared for hex mesh (default=True) - theP1 1st junction point of main pipe - theP2 2nd junction point of main pipe - theP3 Junction point of incident pipe - - theRL Internal radius of left thickness reduction - theWL Width of left thickness reduction - theLtransL Length of left transition part - theLthinL Length of left thin part - - theRR Internal radius of right thickness reduction - theWR Width of right thickness reduction - theLtransR Length of right transition part - theLthinR Length of right thin part - - theRI Internal radius of incident thickness reduction - theWI Width of incident thickness reduction - theLtransI Length of incident transition part - theLthinI Length of incident thin part - - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. - - Returns: - List of GEOM_Object, containing the created shape and propagation groups. - - Example of usage: - # create PipeTShape with fillet object - pipetshapefillet = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0) - # create PipeTShape with fillet object with position - pipetshapefillet_position = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0, True, P1, P2, P3) - # create PipeTShape with fillet object with left thickness reduction - pipetshapefillet_thr = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0, theRL=60, theWL=20, theLtransL=40, theLthinL=20) - """ - theR1, theW1, theL1, theR2, theW2, theL2, theRF, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI, Parameters = ParseParameters(theR1, theW1, theL1, theR2, theW2, theL2, theRF, theRL, theWL, theLtransL, theLthinL, theRR, theWR, theLtransR, theLthinR, theRI, theWI, theLtransI, theLthinI) - if (theP1 and theP2 and theP3): - anObj = self.AdvOp.MakePipeTShapeTRFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theRF, theHexMesh, theP1, theP2, theP3) - else: - anObj = self.AdvOp.MakePipeTShapeTRFillet(theR1, theW1, theL1, theR2, theW2, theL2, - theRL, theWL, theLtransL, theLthinL, - theRR, theWR, theLtransR, theLthinR, - theRI, theWI, theLtransI, theLthinI, - theRF, theHexMesh) - RaiseIfFailed("MakePipeTShapeFillet", self.AdvOp) - if Parameters: anObj[0].SetParameters(Parameters) - def_names = [ "pipeTShape" ] + [ "pipeTShape_grp_%d" % i for i in range(1, len(anObj)) ] - self._autoPublish(anObj, _toListOfNames(theName, len(anObj)), def_names) - return anObj - - ## This function allows creating a disk already divided into blocks. It - # can be used to create divided pipes for later meshing in hexaedra. - # @param theR Radius of the disk - # @param theOrientation Orientation of the plane on which the disk will be built - # 1 = XOY, 2 = OYZ, 3 = OZX - # @param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON - # @param theName Object name; when specified, this parameter is used - # for result publication in the study. Otherwise, if automatic - # publication is switched on, default value is used for result name. - # - # @return New GEOM_Object, containing the created shape. - # - # @ref tui_creation_divideddisk "Example" - @ManageTransactions("AdvOp") - def MakeDividedDisk(self, theR, theOrientation, thePattern, theName=None): - """ - Creates a disk, divided into blocks. It can be used to create divided pipes - for later meshing in hexaedra. - - Parameters: - theR Radius of the disk - theOrientation Orientation of the plane on which the disk will be built: - 1 = XOY, 2 = OYZ, 3 = OZX - thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. - - Returns: - New GEOM_Object, containing the created shape. - """ - theR, Parameters = ParseParameters(theR) - anObj = self.AdvOp.MakeDividedDisk(theR, 67.0, theOrientation, thePattern) - RaiseIfFailed("MakeDividedDisk", self.AdvOp) - if Parameters: anObj.SetParameters(Parameters) - self._autoPublish(anObj, theName, "dividedDisk") - return anObj - - ## This function allows creating a disk already divided into blocks. It - # can be used to create divided pipes for later meshing in hexaedra. - # @param theCenter Center of the disk - # @param theVector Normal vector to the plane of the created disk - # @param theRadius Radius of the disk - # @param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON - # @param theName Object name; when specified, this parameter is used - # for result publication in the study. Otherwise, if automatic - # publication is switched on, default value is used for result name. - # - # @return New GEOM_Object, containing the created shape. - # - # @ref tui_creation_divideddisk "Example" - @ManageTransactions("AdvOp") - def MakeDividedDiskPntVecR(self, theCenter, theVector, theRadius, thePattern, theName=None): - """ - Creates a disk already divided into blocks. It can be used to create divided pipes - for later meshing in hexaedra. - - Parameters: - theCenter Center of the disk - theVector Normal vector to the plane of the created disk - theRadius Radius of the disk - thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. - - Returns: - New GEOM_Object, containing the created shape. - """ - theRadius, Parameters = ParseParameters(theRadius) - anObj = self.AdvOp.MakeDividedDiskPntVecR(theCenter, theVector, theRadius, 67.0, thePattern) - RaiseIfFailed("MakeDividedDiskPntVecR", self.AdvOp) - if Parameters: anObj.SetParameters(Parameters) - self._autoPublish(anObj, theName, "dividedDisk") - return anObj - - ## Builds a cylinder prepared for hexa meshes - # @param theR Radius of the cylinder - # @param theH Height of the cylinder - # @param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON - # @param theName Object name; when specified, this parameter is used - # for result publication in the study. Otherwise, if automatic - # publication is switched on, default value is used for result name. - # - # @return New GEOM_Object, containing the created shape. - # - # @ref tui_creation_dividedcylinder "Example" - @ManageTransactions("AdvOp") - def MakeDividedCylinder(self, theR, theH, thePattern, theName=None): - """ - Builds a cylinder prepared for hexa meshes - - Parameters: - theR Radius of the cylinder - theH Height of the cylinder - thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. - - Returns: - New GEOM_Object, containing the created shape. - """ - theR, theH, Parameters = ParseParameters(theR, theH) - anObj = self.AdvOp.MakeDividedCylinder(theR, theH, thePattern) - RaiseIfFailed("MakeDividedCylinder", self.AdvOp) - if Parameters: anObj.SetParameters(Parameters) - self._autoPublish(anObj, theName, "dividedCylinder") - return anObj - - ## Create a surface from a cloud of points - # @param thelPoints list of points. Compounds of points are - # accepted as well. - # @param theNbMax maximum number of Bezier pieces in the resulting - # surface. - # @param theDegMax maximum degree of the resulting BSpline surface. - # @param theDMax 3D tolerance of initial approximation. - # @param theName Object name; when specified, this parameter is used - # for result publication in the study. Otherwise, if automatic - # publication is switched on, default value is used for result name. - # @return New GEOM_Object, containing the created shape. - # @note 3D tolerance of initial approximation represents a tolerance of - # initial plate surface approximation. If this parameter is equal - # to 0 (default value) it is computed. In this case an error of - # initial plate surface computation is used as the approximation - # tolerance. This error represents a maximal distance between - # computed plate surface and given points. - # - # @ref tui_creation_smoothingsurface "Example" - @ManageTransactions("AdvOp") - def MakeSmoothingSurface(self, thelPoints, theNbMax=2, theDegMax=8, - theDMax=0.0, theName=None): - """ - Create a surface from a cloud of points - - Parameters: - thelPoints list of points. Compounds of points are - accepted as well. - theNbMax maximum number of Bezier pieces in the resulting - surface. - theDegMax maximum degree of the resulting BSpline surface. - theDMax 3D tolerance of initial approximation. - theName Object name; when specified, this parameter is used - for result publication in the study. Otherwise, if automatic - publication is switched on, default value is used for result name. - - Returns: - New GEOM_Object, containing the created shape. - - Note: - 3D tolerance of initial approximation represents a tolerance of - initial plate surface approximation. If this parameter is equal - to 0 (default value) it is computed. In this case an error of - initial plate surface computation is used as the approximation - tolerance. This error represents a maximal distance between - computed plate surface and given points. - """ - anObj = self.AdvOp.MakeSmoothingSurface(thelPoints, theNbMax, - theDegMax, theDMax) - RaiseIfFailed("MakeSmoothingSurface", self.AdvOp) - self._autoPublish(anObj, theName, "smoothing") - return anObj - - ## Export a shape to XAO format - # @param shape The shape to export - # @param groups The list of groups to export - # @param fields The list of fields to export - # @param author The author of the export - # @param fileName The name of the file to export - # @return boolean - # - # @ref tui_exportxao "Example" - @ManageTransactions("InsertOp") - def ExportXAO(self, shape, groups, fields, author, fileName): - res = self.InsertOp.ExportXAO(shape, groups, fields, author, fileName) - RaiseIfFailed("ExportXAO", self.InsertOp) - return res - - ## Import a shape from XAO format - # @param shape Shape to export - # @param fileName The name of the file to import - # @return tuple (res, shape, subShapes, groups, fields) - # res Flag indicating if the import was successful - # shape The imported shape - # subShapes The list of imported subShapes - # groups The list of imported groups - # fields The list of imported fields - # - # @ref tui_importxao "Example" - @ManageTransactions("InsertOp") - def ImportXAO(self, fileName): - res = self.InsertOp.ImportXAO(fileName) - RaiseIfFailed("ImportXAO", self.InsertOp) - return res - #@@ insert new functions before this line @@ do not remove this line @@# - # end of l4_advanced - ## @} - ## Create a copy of the given object # # @param theOriginal geometry object for copy @@ -13652,3 +12917,36 @@ def New( study, instance=None): assert isinstance(geom,geomBuilder), "Geom engine class is %s but should be geomBuilder.geomBuilder. Import geomBuilder before creating the instance."%geom.__class__ geom.init_geom(study) return geom + + +# Register methods from the plug-ins in the geomBuilder class +plugins_var = os.environ.get( "GEOM_PluginsList" ) + +plugins = None +if plugins_var is not None: + plugins = plugins_var.split( ":" ) + plugins=filter(lambda x: len(x)>0, plugins) +if plugins is not None: + for pluginName in plugins: + pluginBuilderName = pluginName + "Builder" + try: + exec( "from salome.%s.%s import *" % (pluginName, pluginBuilderName)) + except Exception, e: + from salome_utils import verbose + print "Exception while loading %s: %s" % ( pluginBuilderName, e ) + continue + exec( "from salome.%s import %s" % (pluginName, pluginBuilderName)) + plugin = eval( pluginBuilderName ) + + # add methods from plugin module to the geomBuilder class + for k in dir( plugin ): + if k[0] == '_': continue + method = getattr( plugin, k ) + if type( method ).__name__ == 'function': + if not hasattr( geomBuilder, k ): + setattr( geomBuilder, k, method ) + pass + pass + del pluginName + pass + pass diff --git a/src/IGESExport/CMakeLists.txt b/src/IGESExport/CMakeLists.txt deleted file mode 100755 index 4ad448cbd..000000000 --- a/src/IGESExport/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2012-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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIR} - ${KERNEL_INCLUDE_DIRS} - ) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKIGES} - ${KERNEL_SALOMELocalTrace} - ) - -# --- sources --- - -SET(IGESExport_SOURCES - IGESExport.cxx - ) - -# --- rules --- - -ADD_LIBRARY(IGESExport ${IGESExport_SOURCES}) -TARGET_LINK_LIBRARIES(IGESExport ${_link_LIBRARIES}) -INSTALL(TARGETS IGESExport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) - - diff --git a/src/IGESExport/IGESExport.cxx b/src/IGESExport/IGESExport.cxx deleted file mode 100644 index 894c2a5ba..000000000 --- a/src/IGESExport/IGESExport.cxx +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// - -// File: IGESExport.cxx -// Created: Wed May 19 14:49:45 2004 -// Author: Pavel TELKOV - -#include "utilities.h" - -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -#ifdef WIN32 - #if defined IGESEXPORT_EXPORTS || defined IGESExport_EXPORTS - #define IGESEXPORT_EXPORT __declspec( dllexport ) - #else - #define IGESEXPORT_EXPORT __declspec( dllimport ) - #endif -#else - #define IGESEXPORT_EXPORT -#endif - -//============================================================================= -/*! - * KindOfBRep - * \return 0 if theShape contains only simple entities (wires, edges and vertices), - * 1 if theShape contains only complex entities (shells, solids and compsolids) - * 2 if theShape contains only indifferent entities (faces) - * -1 if theShape contains both simple and complex entities (and in this case it - * cannot be saved without any loss neither in BRepMode == 0 nor in BRepMode == 1) - */ -//============================================================================= -int KindOfBRep (const TopoDS_Shape& theShape) -{ - int aKind = 2; - - switch (theShape.ShapeType()) - { - case TopAbs_COMPOUND: - { - bool isSimple = false; - bool isComplex = false; - TopoDS_Iterator anIt (theShape, Standard_True, Standard_True); - for (; anIt.More(); anIt.Next()) { - TopoDS_Shape aS = anIt.Value(); - int aKindSub = KindOfBRep(aS); - if (aKindSub == 0) - isSimple = true; - else if (aKindSub == 1) - isComplex = true; - else if (aKindSub == -1) { - return -1; // heterogeneous - } - } - if (isSimple && isComplex) - aKind = -1; // heterogeneous - else if (isSimple) - aKind = 0; - else if (isComplex) - aKind = 1; - } - break; - case TopAbs_COMPSOLID: - case TopAbs_SOLID: - case TopAbs_SHELL: - aKind = 1; - break; - case TopAbs_WIRE: - case TopAbs_EDGE: - case TopAbs_VERTEX: - aKind = 0; - break; - default: - aKind = 2; - } - - return aKind; -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ -IGESEXPORT_EXPORT - int Export( const TopoDS_Shape& theShape, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName ) - { - bool ok = false; - - // define, whether to write only faces (5.1 IGES format) - // or shells and solids also (5.3 IGES format) - int aBrepMode = 0; - if (theFormatName.IsEqual("IGES_5_3")) - aBrepMode = 1; - - MESSAGE("Export IGES into file " << theFileName.ToCString()); - - // Mantis issue 0021350: check being exported shape, as some standalone - // entities (edges, wires and vertices) cannot be saved in BRepMode - if (aBrepMode == 1) { - int aKind = KindOfBRep(theShape); - if (aKind == -1) - Standard_Failure::Raise("EXPORT_IGES_HETEROGENEOUS_COMPOUND"); - else if (aKind == 2) - aBrepMode = 1; - else - aBrepMode = aKind; - } - - // commented for 0021350: Please don't catch exceptions silently and send an - // inappropriate error message instead, it is disturbing for the user and for us - //try - { - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - // initialize writer - IGESControl_Controller::Init(); - //IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"), - // Interface_Static::IVal("write.iges.brep.mode")); - IGESControl_Writer ICW ("M", aBrepMode); // "write.iges.unit" ->> VSR 15.09.09: export explicitly in meters - Interface_Static::SetCVal("xstep.cascade.unit","M"); - - // 09.03.2010 skl for bug 0020726 - // change default value "Average" to "Max" - Interface_Static::SetCVal("write.precision.mode","Max"); - - // perform shape writing - if (ICW.AddShape( theShape )) { - ICW.ComputeModel(); - ok = ICW.Write( theFileName.ToCString() ); - } - } - //catch(Standard_Failure) - //{ - //} - return ok; - } -} diff --git a/src/IGESImport/CMakeLists.txt b/src/IGESImport/CMakeLists.txt deleted file mode 100755 index 61d020ced..000000000 --- a/src/IGESImport/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (C) 2012-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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIR} - ${KERNEL_INCLUDE_DIRS} - ) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKIGES} ${CAS_TKCAF} - ${CAS_TKLCAF} - ${KERNEL_SALOMELocalTrace} - ) - -# --- sources --- - -SET(IGESImport_SOURCES - IGESImport.cxx - ) - -# --- rules --- - -ADD_LIBRARY(IGESImport ${IGESImport_SOURCES}) -TARGET_LINK_LIBRARIES(IGESImport ${_link_LIBRARIES}) -INSTALL(TARGETS IGESImport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) - - diff --git a/src/IGESImport/IGESImport.cxx b/src/IGESImport/IGESImport.cxx deleted file mode 100644 index 711cceabb..000000000 --- a/src/IGESImport/IGESImport.cxx +++ /dev/null @@ -1,250 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// -// File: IGESImport.cxx -// Created: Wed May 19 14:36:35 2004 -// Author: Pavel TELKOV - -#include "utilities.h" - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC - -#ifdef WIN32 - #if defined IGESIMPORT_EXPORTS || defined IGESImport_EXPORTS - #define IGESIMPORT_EXPORT __declspec( dllexport ) - #else - #define IGESIMPORT_EXPORT __declspec( dllimport ) - #endif -#else - #define IGESIMPORT_EXPORT -#endif - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ - IGESIMPORT_EXPORT - Handle(TCollection_HAsciiString) GetValue (const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theParameterName, - TCollection_AsciiString& theError) - { - Handle(TCollection_HAsciiString) aValue; - - if (theParameterName != "LEN_UNITS") { - theError = theParameterName + " parameter reading is not supported by IGES plugin"; - return aValue; - } - - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - IGESControl_Reader aReader; - - Interface_Static::SetCVal("xstep.cascade.unit","M"); - - try { - OCC_CATCH_SIGNALS; - - IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); - if (status == IFSelect_RetDone) { - Handle(IGESData_IGESModel) aModel = - Handle(IGESData_IGESModel)::DownCast(aReader.Model()); - if (!aModel.IsNull()) { - aValue = aModel->GlobalSection().UnitName(); - - //if (!aValue.IsNull()) { - // Handle(TCollection_HAsciiString) aPrefix = new TCollection_HAsciiString ("UNIT_"); - // aValue->Prepend(aPrefix); - //} - } - } - else { - theError = theFileName + " reading failed"; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - theError = aFail->GetMessageString(); - } - - return aValue; - } - -IGESIMPORT_EXPORT - TopoDS_Shape Import (const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName, - TCollection_AsciiString& theError, - const TDF_Label& theShapeLabel) - { - TopoDS_Shape aResShape; - - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - IGESControl_Reader aReader; - - Interface_Static::SetCVal("xstep.cascade.unit","M"); - - try { - OCC_CATCH_SIGNALS; - - IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); - - if (status == IFSelect_RetDone) { - - // BEGIN: old code - if (theFormatName == "IGES_UNIT") { - Handle(IGESData_IGESModel) aModel = - Handle(IGESData_IGESModel)::DownCast(aReader.Model()); - gp_Pnt P (1.0, 0.0, 0.0); - if (!aModel.IsNull()) { - Handle(TCollection_HAsciiString) aUnitName = - aModel->GlobalSection().UnitName(); - if (!aUnitName.IsNull()) { - if (aUnitName->String()=="MM") { - P = gp_Pnt(0.001,0.0,0.0); - } - else if (aUnitName->String()=="CM") { - P = gp_Pnt(0.01,0.0,0.0); - } - } - } - BRep_Builder B; - TopoDS_Vertex V; - B.MakeVertex(V,P,1.e-7); - aResShape = V; - return aResShape; - } - // END: old code - - if (theFormatName == "IGES_SCALE") { - //cout<<"need re-scale a model"<GlobalSection(); - aGS.SetUnitFlag(6); - aModel->SetGlobalSection(aGS); - } - } - - MESSAGE("ImportIGES : all Geometry Transfer"); - //OCC 5.1.2 porting - // aReader.Clear(); - // aReader.TransferRoots(false); - aReader.ClearShapes(); - aReader.TransferRoots(); - - MESSAGE("ImportIGES : count of shapes produced = " << aReader.NbShapes()); - aResShape = aReader.OneShape(); - - // BEGIN: Store names of sub-shapes from file - Handle(Interface_InterfaceModel) Model = aReader.WS()->Model(); - Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); - if (!TR.IsNull()) { - Handle(Transfer_TransientProcess) TP = /*TransientProcess();*/TR->TransientProcess(); - Standard_Integer nb = Model->NbEntities(); - for (Standard_Integer i = 1; i <= nb; i++) { - Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(Model->Value(i)); - if (ent.IsNull() || ! ent->HasName()) continue; - - // 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(theShapeLabel); - TNaming_Builder tnBuild (L); - tnBuild.Generated(S); - - // set a name - TCollection_AsciiString string = ent->NameValue()->String(); - string.LeftAdjust(); - string.RightAdjust(); - TCollection_ExtendedString str (string); - TDataStd_Name::Set(L, str); - } - } - // END: Store names - } else { -// switch (status) { -// case IFSelect_RetVoid: -// theError = "Nothing created or No data to process"; -// break; -// case IFSelect_RetError: -// theError = "Error in command or input data"; -// break; -// case IFSelect_RetFail: -// theError = "Execution was run, but has failed"; -// break; -// case IFSelect_RetStop: -// theError = "Execution has been stopped. Quite possible, an exception was raised"; -// break; -// default: -// break; -// } - 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; - } -} diff --git a/src/IGESPlugin/CMakeLists.txt b/src/IGESPlugin/CMakeLists.txt new file mode 100644 index 000000000..caa229704 --- /dev/null +++ b/src/IGESPlugin/CMakeLists.txt @@ -0,0 +1,149 @@ +# 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 +# + +IF(SALOME_BUILD_GUI) + INCLUDE(UseQt4Ext) + INCLUDE(${QT_USE_FILE}) +ENDIF() + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} + ${KERNEL_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR}/idl + ${PROJECT_SOURCE_DIR}/src/GEOMAlgo + ${PROJECT_SOURCE_DIR}/src/GEOM + ${PROJECT_SOURCE_DIR}/src/GEOMImpl + ${PROJECT_SOURCE_DIR}/src/GEOM_I + ${PROJECT_SOURCE_DIR}/src/GEOMClient + ${PROJECT_SOURCE_DIR}/src/GEOMUtils + ) + +IF(SALOME_BUILD_GUI) + INCLUDE_DIRECTORIES( + ${QT_INCLUDE_DIRS} + ${GUI_INCLUDE_DIRS} + ${PROJECT_SOURCE_DIR}/src/OBJECT + ${PROJECT_SOURCE_DIR}/src/GEOMGUI + ${PROJECT_SOURCE_DIR}/src/GEOMBase + ) +ENDIF() + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${CAS_DEFINITIONS} + ) + +IF(SALOME_BUILD_GUI) +ADD_DEFINITIONS( + ${QT_DEFINITIONS} + ) +ENDIF() + +# libraries to link to +SET(_link_engine_LIBRARIES + ${CAS_TKIGES} + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + SalomeIDLGEOM + SalomeIDLIGESPlugin + GEOMEngine + GEOMClient + ) + +IF(SALOME_BUILD_GUI) + SET(_link_gui_LIBRARIES + SalomeIDLIGESPlugin + GEOMObject + GEOM + GEOMBase + ) +ENDIF() + + +# --- headers --- + +SET(IGESPluginEngine_HEADERS + IGESPlugin_IOperations_i.hh + IGESPlugin_Engine.hxx + IGESPlugin_OperationsCreator.hxx + IGESPlugin_IOperations.hxx + IGESPlugin_IExport.hxx + IGESPlugin_IImport.hxx + IGESPlugin_ImportDriver.hxx + IGESPlugin_ExportDriver.hxx + IGESPlugin_IECallBack.hxx + ) + +IF(SALOME_BUILD_GUI) + # header files / to be processed by moc + SET(_moc_HEADERS + IGESPlugin_GUI.h + IGESPlugin_ExportDlg.h + ) +ENDIF() + +# --- sources --- + +IF(SALOME_BUILD_GUI) + # sources / moc wrappings + QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) + + SET(IGESPluginGUI_SOURCES + IGESPlugin_GUI.cxx + IGESPlugin_ExportDlg.cxx + ${_moc_SOURCES} + ) +ENDIF() + +SET(IGESPluginEngine_SOURCES + IGESPlugin_Engine.cxx + IGESPlugin_OperationsCreator.cxx + IGESPlugin_IOperations_i.cc + IGESPlugin_IOperations.cxx + IGESPlugin_ExportDriver.cxx + IGESPlugin_ImportDriver.cxx + IGESPlugin_IECallBack.cxx + ) + +# resource files / to be processed by lrelease +SET(IGESPlugin_RESOURCES + IGESPlugin_msg_en.ts + IGESPlugin_msg_fr.ts + IGESPlugin_msg_ja.ts + ) + +# --- rules --- + +ADD_LIBRARY(IGESPluginEngine ${IGESPluginEngine_SOURCES}) +TARGET_LINK_LIBRARIES(IGESPluginEngine ${_link_engine_LIBRARIES}) +INSTALL(TARGETS IGESPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +IF(SALOME_BUILD_GUI) + ADD_LIBRARY(IGESPluginGUI ${IGESPluginGUI_SOURCES}) + TARGET_LINK_LIBRARIES(IGESPluginGUI ${_link_gui_LIBRARIES}) + INSTALL(TARGETS IGESPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + + QT4_INSTALL_TS_RESOURCES("${IGESPlugin_RESOURCES}" "${SALOME_GEOM_INSTALL_RES_DATA}") +ENDIF() + + +INSTALL(FILES ${IGESPluginEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/IGESPlugin/IGESPlugin_Engine.cxx b/src/IGESPlugin/IGESPlugin_Engine.cxx new file mode 100644 index 000000000..6f0c726ee --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_Engine.cxx @@ -0,0 +1,31 @@ +// 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 "IGESPlugin_Engine.hxx" +#include "IGESPlugin_OperationsCreator.hxx" + +extern "C" +{ + IGESPLUGINENGINE_EXPORT + GEOM_GenericOperationsCreator* GetOperationsCreator() + { + return new IGESPlugin_OperationsCreator(); + } +} diff --git a/src/IGESPlugin/IGESPlugin_Engine.hxx b/src/IGESPlugin/IGESPlugin_Engine.hxx new file mode 100755 index 000000000..5d01abe8c --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_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 _GEOM_IGESPLUGIN_ENGINE_HXX_ +#define _GEOM_IGESPLUGIN_ENGINE_HXX_ + +#ifdef WIN32 + #if defined IGESPLUGINENGINE_EXPORTS || defined IGESPLUGINENGINE_EXPORTS + #define IGESPLUGINENGINE_EXPORT __declspec( dllexport ) + #else + #define IGESPLUGINENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define IGESPLUGINENGINE_EXPORT +#endif + +#endif diff --git a/src/IGESPlugin/IGESPlugin_ExportDlg.cxx b/src/IGESPlugin/IGESPlugin_ExportDlg.cxx new file mode 100644 index 000000000..1b21c2c30 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_ExportDlg.cxx @@ -0,0 +1,88 @@ +// 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 +// + +#include "IGESPlugin_ExportDlg.h" + +#include +#include +#include +#include + +//================================================================================= +// Constructor +//================================================================================= +IGESPlugin_ExportDlg::IGESPlugin_ExportDlg( QWidget* parent ) + : SUIT_FileDlg( parent, false, true, true ) +{ + QLabel* versionLabel = new QLabel( tr( "IGES_VERSION" ), this ); + + myVersionCB = new QComboBox( this ); + myVersionCB->addItem( tr( "5.1" ) ); + myVersionCB->addItem( tr( "5.3" ) ); + + layout()->addWidget( versionLabel ); + layout()->addWidget( myVersionCB ); +} + +//================================================================================= +// Destructor +//================================================================================= +IGESPlugin_ExportDlg::~IGESPlugin_ExportDlg() +{ +} + +//================================================================================= +// getVersion +//================================================================================= +QString IGESPlugin_ExportDlg::getVersion() const +{ + return myVersionCB->currentText(); +} + +//================================================================================= +// getFileName +//================================================================================= +QString IGESPlugin_ExportDlg::getFileName( const QString& initial, const QString& filters, + const QString& caption, QWidget* parent, QString& version ) +{ + QStringList fls = filters.split( ";;", QString::SkipEmptyParts ); + + QString tmpfilename = initial; + tmpfilename = tmpfilename.simplified(); + tmpfilename = tmpfilename.replace( QRegExp( "\\*" ), "" ).replace( QRegExp( "\\?" ), "" ); + + IGESPlugin_ExportDlg fd( parent ); + fd.setFileMode( AnyFile ); + fd.setFilters( fls ); + fd.setWindowTitle( caption ); + if ( !tmpfilename.isEmpty() ) + fd.processPath( tmpfilename ); + + QString filename; + + if ( fd.exec() == QDialog::Accepted ) { + filename = fd.selectedFile(); + version = fd.getVersion(); + } + + QApplication::processEvents(); + + return filename; +} + diff --git a/src/IGESPlugin/IGESPlugin_ExportDlg.h b/src/IGESPlugin/IGESPlugin_ExportDlg.h new file mode 100644 index 000000000..454b09a2a --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_ExportDlg.h @@ -0,0 +1,44 @@ +// 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 IGESPlugin_ExportDlg_H +#define IGESPlugin_ExportDlg_H + +#include + +class QComboBox; + +class IGESPlugin_ExportDlg: public SUIT_FileDlg +{ + Q_OBJECT + +public: + IGESPlugin_ExportDlg( QWidget* parent ); + ~IGESPlugin_ExportDlg(); + + QString getVersion() const; + + static QString getFileName( const QString& initial, const QString& filters, + const QString& caption, QWidget* parent, QString& version ); + +private: + QComboBox* myVersionCB; +}; + +#endif // IGESPlugin_ExportDlg_H diff --git a/src/IGESPlugin/IGESPlugin_ExportDriver.cxx b/src/IGESPlugin/IGESPlugin_ExportDriver.cxx new file mode 100644 index 000000000..29d1ea789 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_ExportDriver.cxx @@ -0,0 +1,198 @@ +// 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 "IGESPlugin_ExportDriver.hxx" +#include "IGESPlugin_IExport.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOM_Function.hxx" + +// OOCT includes +#include +#include +#include + +#include +#include + +//============================================================================= +/*! + * KindOfBRep + * \return 0 if theShape contains only simple entities (wires, edges and vertices), + * 1 if theShape contains only complex entities (shells, solids and compsolids) + * 2 if theShape contains only indifferent entities (faces) + * -1 if theShape contains both simple and complex entities (and in this case it + * cannot be saved without any loss neither in BRepMode == 0 nor in BRepMode == 1) + */ +//============================================================================= +int KindOfBRep (const TopoDS_Shape& theShape) +{ + int aKind = 2; + + switch (theShape.ShapeType()) + { + case TopAbs_COMPOUND: + { + bool isSimple = false; + bool isComplex = false; + TopoDS_Iterator anIt (theShape, Standard_True, Standard_True); + for (; anIt.More(); anIt.Next()) { + TopoDS_Shape aS = anIt.Value(); + int aKindSub = KindOfBRep(aS); + if (aKindSub == 0) + isSimple = true; + else if (aKindSub == 1) + isComplex = true; + else if (aKindSub == -1) { + return -1; // heterogeneous + } + } + if (isSimple && isComplex) + aKind = -1; // heterogeneous + else if (isSimple) + aKind = 0; + else if (isComplex) + aKind = 1; + } + break; + case TopAbs_COMPSOLID: + case TopAbs_SOLID: + case TopAbs_SHELL: + aKind = 1; + break; + case TopAbs_WIRE: + case TopAbs_EDGE: + case TopAbs_VERTEX: + aKind = 0; + break; + default: + aKind = 2; + } + + return aKind; +} + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& IGESPlugin_ExportDriver::GetID() +{ + static Standard_GUID aGUID("8fa4111a-24cb-4819-8f03-b0e2890d2a2a"); + return aGUID; +} + +//======================================================================= +//function : IGESPlugin_ExportDriver +//purpose : +//======================================================================= +IGESPlugin_ExportDriver::IGESPlugin_ExportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer IGESPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + IGESPlugin_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(); + TCollection_AsciiString aVersion = aData.GetVersion(); + // define, whether to write only faces (5.1 IGES format) + // or shells and solids also (5.3 IGES format) + int aBrepMode = 0; + if( aVersion.IsEqual( "5.3" ) ) + aBrepMode = 1; + + MESSAGE("Export IGES into file " << aFileName.ToCString()); + + // Mantis issue 0021350: check being exported shape, as some standalone + // entities (edges, wires and vertices) cannot be saved in BRepMode + if( aBrepMode == 1 ) { + int aKind = KindOfBRep( aShape ); + if( aKind == -1 ) + Standard_Failure::Raise( "EXPORT_IGES_HETEROGENEOUS_COMPOUND" ); + else if( aKind == 2 ) + aBrepMode = 1; + else + aBrepMode = aKind; + } + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + // initialize writer + IGESControl_Controller::Init(); + IGESControl_Writer ICW( "M", aBrepMode ); // export explicitly in meters + Interface_Static::SetCVal( "xstep.cascade.unit", "M" ); + + // 09.03.2010 skl for bug 0020726 + // change default value "Average" to "Max" + Interface_Static::SetCVal( "write.precision.mode", "Max" ); + + // perform shape writing + if( ICW.AddShape( aShape ) ) { + ICW.ComputeModel(); + return ICW.Write( aFileName.ToCString() ); + } + return 0; +} + +//======================================================================= +//function : MustExecute +//purpose : +//======================================================================= +Standard_Boolean IGESPlugin_ExportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ +bool IGESPlugin_ExportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + return false; +} + +IMPLEMENT_STANDARD_HANDLE( IGESPlugin_ExportDriver,GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( IGESPlugin_ExportDriver,GEOM_BaseDriver ); diff --git a/src/IGESPlugin/IGESPlugin_ExportDriver.hxx b/src/IGESPlugin/IGESPlugin_ExportDriver.hxx new file mode 100644 index 000000000..353324deb --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_ExportDriver.hxx @@ -0,0 +1,51 @@ +// 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 _IGESPlugin_ExportDriver_HXX +#define _IGESPlugin_ExportDriver_HXX + +// internal includes +#include "IGESPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( IGESPlugin_ExportDriver, GEOM_BaseDriver ); + +class IGESPLUGINENGINE_EXPORT IGESPlugin_ExportDriver : public GEOM_BaseDriver +{ +public: + IGESPlugin_ExportDriver(); + ~IGESPlugin_ExportDriver() {}; + + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} + + virtual bool GetCreationInformation( std::string& theOperationName, + std::vector& params ); + +DEFINE_STANDARD_RTTI( IGESPlugin_ExportDriver ) +}; + +#endif // _IGESPlugin_ExportDriver_HXX diff --git a/src/IGESPlugin/IGESPlugin_GUI.cxx b/src/IGESPlugin/IGESPlugin_GUI.cxx new file mode 100644 index 000000000..0dc269914 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_GUI.cxx @@ -0,0 +1,305 @@ +// 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 "IGESPlugin_GUI.h" +#include "IGESPlugin_ExportDlg.h" + +// GUI includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// GEOM includes +#include "GeometryGUI.h" +#include "GEOM_Operation.h" +#include "GEOMBase.h" +#include "GEOM_Displayer.h" + +#include +#include CORBA_SERVER_HEADER(IGESPlugin) + +//======================================================================= +// function : IGESPlugin_GUI() +// purpose : Constructor +//======================================================================= +IGESPlugin_GUI::IGESPlugin_GUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) +{ +} + +//======================================================================= +// function : ~IGESPlugin_GUI +// purpose : Destructor +//======================================================================= +IGESPlugin_GUI::~IGESPlugin_GUI() +{ +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool IGESPlugin_GUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) +{ + QString cmd; + switch ( theCommandID ) { + case 1: + cmd = "Export_IGES"; break; + case 2: + cmd = "Import_IGES"; break; + default: + break; + } + return OnGUIEvent( cmd, parent ); +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool IGESPlugin_GUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) +{ + bool result = false; + + if( theCommandID == "Export_IGES" ) { + result = exportIGES( parent ); + } + else if (theCommandID == "Import_IGES") { + result = importIGES( parent ); + } + else { + getGeometryGUI()->getApp()->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) ); + } + + return true; +} + +//======================================================================= +// function : importIGES +// purpose : +//======================================================================= +bool IGESPlugin_GUI::importIGES( SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); + if ( !study ) return false; + + SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "IGESPluginEngine" ); + GEOM::IIGESOperations_var igesOp = GEOM::IIGESOperations::_narrow( op ); + if ( CORBA::is_nil( igesOp ) ) return false; + + QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), + tr( "IGES_FILES" ), + tr( "IMPORT_TITLE" ), + parent ); + if ( fileNames.count() > 0 ) + { + QStringList entryList; + QStringList errors; + SUIT_MessageBox::StandardButton igesAnswer = SUIT_MessageBox::NoButton; + + for ( int i = 0; i < fileNames.count(); i++ ) + { + QString fileName = fileNames.at( i ); + SUIT_OverrideCursor wc; + GEOM_Operation transaction( app, igesOp.in() ); + bool ignoreUnits = false; + + try + { + app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( fileName, true ) ) ); + transaction.start(); + + CORBA::String_var units = igesOp->ReadValue( fileName.toUtf8().constData(), "LEN_UNITS" ); + QString unitsStr( units.in() ); + bool unitsOK = unitsStr.isEmpty() || unitsStr == "M" || unitsStr.toLower() == "metre"; + + if ( !unitsOK ) + { + if( igesAnswer == SUIT_MessageBox::NoToAll ) + { + ignoreUnits = true; + } + else if( igesAnswer != SUIT_MessageBox::YesToAll ) + { + SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel; + if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll; + igesAnswer = SUIT_MessageBox::question( parent, + tr( "WRN_WARNING" ), + tr( "SCALE_DIMENSIONS" ).arg( unitsStr ), + btns, + SUIT_MessageBox::No ); + switch ( igesAnswer ) + { + case SUIT_MessageBox::Cancel: + return true; // cancel (break) import operation + case SUIT_MessageBox::Yes: + case SUIT_MessageBox::YesToAll: + break; // scaling is confirmed + case SUIT_MessageBox::No: + case SUIT_MessageBox::NoAll: + ignoreUnits = true; // scaling is rejected + default: + break; + } + } + } + + GEOM::ListOfGO_var result = igesOp->ImportIGES( fileName.toUtf8().constData(), ignoreUnits ); + if ( result->length() > 0 && igesOp->IsDone() ) + { + GEOM::GEOM_Object_var main = result[0]; + QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) ); + SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy, + SALOMEDS::SObject::_nil(), + main.in(), + publishName.toUtf8().constData() ); + + entryList.append( so->GetID() ); + transaction.commit(); + GEOM_Displayer( study ).Display( main.in() ); + } + else + { + transaction.abort(); + errors.append( QString( "%1 : %2" ).arg( fileName ).arg( igesOp->GetErrorCode() ) ); + } + } + catch( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + } + } + + getGeometryGUI()->updateObjBrowser( true ); + app->browseObjects( entryList ); + + if ( errors.count() > 0 ) + { + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + } + } + return fileNames.count() > 0; +} + +//======================================================================= +// function : exportIGES +// purpose : +//======================================================================= +bool IGESPlugin_GUI::exportIGES( SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); + if ( !study ) return false; + + SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "IGESPluginEngine" ); + GEOM::IIGESOperations_var igesOp = GEOM::IIGESOperations::_narrow( op ); + if ( CORBA::is_nil( igesOp ) ) return false; + + LightApp_SelectionMgr* sm = app->selectionMgr(); + if ( !sm ) return false; + + SALOME_ListIO selectedObjects; + sm->selectedObjects( selectedObjects ); + bool ok = false; + + SALOME_ListIteratorOfListIO it( selectedObjects ); + for ( ; it.More(); it.Next() ) + { + Handle(SALOME_InteractiveObject) io = it.Value(); + GEOM::GEOM_Object_var obj = GEOMBase::ConvertIOinGEOMObject( io ); + + if ( CORBA::is_nil( obj ) ) continue; + + QString version; + QString fileName = IGESPlugin_ExportDlg::getFileName( QString( io->getName() ), + tr( "IGES_FILES" ), + tr( "EXPORT_TITLE" ), + parent, + version ); + + if ( fileName.isEmpty() ) + return false; + + SUIT_OverrideCursor wc; + + GEOM_Operation transaction( app, igesOp.in() ); + + try + { + app->putInfo( tr( "GEOM_PRP_EXPORT" ).arg( fileName ) ); + transaction.start(); + + igesOp->ExportIGES( obj, fileName.toUtf8().constData(), version.toUtf8().constData() ); + + if ( igesOp->IsDone() ) + { + transaction.commit(); + } + else + { + transaction.abort(); + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_PRP_ABORT" ) + "\n" + tr( igesOp->GetErrorCode() ) ); + return false; + } + } + catch ( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + return false; + } + ok = true; + } + + if ( !ok ) + { + SUIT_MessageBox::warning( parent, + tr( "WRN_WARNING" ), + tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) ); + } + return ok; +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ +#ifdef WIN32 + __declspec( dllexport ) +#endif + GEOMGUI* GetLibGUI( GeometryGUI* parent ) + { + return new IGESPlugin_GUI( parent ); + } +} diff --git a/src/IGESPlugin/IGESPlugin_GUI.h b/src/IGESPlugin/IGESPlugin_GUI.h new file mode 100644 index 000000000..58f6f9ccd --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_GUI.h @@ -0,0 +1,40 @@ +// 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 IGESPlugin_GUI_H +#define IGESPlugin_GUI_H + +#include "GEOMPluginGUI.h" + +class IGESPlugin_GUI: public GEOMPluginGUI +{ + Q_OBJECT +public: + IGESPlugin_GUI( GeometryGUI* parent ); + ~IGESPlugin_GUI(); + + bool OnGUIEvent( int commandId, SUIT_Desktop* ); + bool OnGUIEvent( const QString&, SUIT_Desktop* ); + +private: + bool importIGES( SUIT_Desktop* ); + bool exportIGES( SUIT_Desktop* ); +}; + +#endif // IGESPlugin_GUI_H diff --git a/src/IGESPlugin/IGESPlugin_IECallBack.cxx b/src/IGESPlugin/IGESPlugin_IECallBack.cxx new file mode 100755 index 000000000..85937db65 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_IECallBack.cxx @@ -0,0 +1,87 @@ +// 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 "IGESPlugin_IECallBack.hxx" +#include "IGESPlugin_IOperations.hxx" +#include "IGESPlugin_OperationsCreator.hxx" + +//============================================================================= +/*! + * constructor + */ +//============================================================================= +IGESPlugin_IECallBack::IGESPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +IGESPlugin_IECallBack::~IGESPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * Export + */ +//============================================================================= +bool IGESPlugin_IECallBack::Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ) +{ + IGESPlugin_IOperations* aPluginOperations = IGESPlugin_OperationsCreator::get( GetEngine(), theDocId ); + TCollection_AsciiString aVersion = ( theFormatName == "IGES_5_3" ) ? "5.3" : "5.1"; + aPluginOperations->ExportIGES( theOriginal, theFileName, aVersion ); + return true; +} + +//============================================================================= +/*! + * Import + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +IGESPlugin_IECallBack::Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ) +{ + IGESPlugin_IOperations* aPluginOperations = IGESPlugin_OperationsCreator::get( GetEngine(), theDocId ); + bool anIsIgnoreUnits = ( theFormatName == "IGES_SCALE" ) ? true : false; + return aPluginOperations->ImportIGES( theFileName, anIsIgnoreUnits ); +} + +//============================================================================= +/*! + * ReadValue + */ +//============================================================================= +TCollection_AsciiString +IGESPlugin_IECallBack::ReadValue( int theDocId, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theParameterName ) +{ + IGESPlugin_IOperations* aPluginOperations = IGESPlugin_OperationsCreator::get( GetEngine(), theDocId ); + return aPluginOperations->ReadValue( theFileName, theParameterName ); +} diff --git a/src/IGESPlugin/IGESPlugin_IECallBack.hxx b/src/IGESPlugin/IGESPlugin_IECallBack.hxx new file mode 100644 index 000000000..49b1f14e1 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_IECallBack.hxx @@ -0,0 +1,54 @@ +// 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 _IGESPlugin_IECallBack_HXX_ +#define _IGESPlugin_IECallBack_HXX_ + +// internal includes +#include "IGESPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Object.hxx" +#include "GEOMImpl_IECallBack.hxx" + +// OCC includes +#include + +class IGESPLUGINENGINE_EXPORT IGESPlugin_IECallBack : public GEOMImpl_IECallBack +{ +public: + IGESPlugin_IECallBack(); + ~IGESPlugin_IECallBack(); + + bool Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ); + + Handle(TColStd_HSequenceOfTransient) Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ); + + TCollection_AsciiString ReadValue( int theDocId, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theParameterName ); +}; + +#endif diff --git a/src/IGESPlugin/IGESPlugin_IExport.hxx b/src/IGESPlugin/IGESPlugin_IExport.hxx new file mode 100644 index 000000000..212480193 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_IExport.hxx @@ -0,0 +1,54 @@ +// 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 _IGESPlugin_IExport_HXX_ +#define _IGESPlugin_IExport_HXX_ + +#include "GEOM_Function.hxx" + +#define EXPORTIGES_ARG_ORIGINAL 1 +#define EXPORTIGES_ARG_FILENAME 2 +#define EXPORTIGES_ARG_VERSION 3 + +class IGESPlugin_IExport +{ +public: + IGESPlugin_IExport( Handle(GEOM_Function) theFunction ) + : _func(theFunction) {} + + void SetOriginal( Handle( GEOM_Function ) theOriginal) + { _func->SetReference( EXPORTIGES_ARG_ORIGINAL, theOriginal ); } + Handle( GEOM_Function ) GetOriginal() + { return _func->GetReference( EXPORTIGES_ARG_ORIGINAL ); } + + void SetFileName( const TCollection_AsciiString& theFileName ) + { _func->SetString( EXPORTIGES_ARG_FILENAME, theFileName ); } + TCollection_AsciiString GetFileName() + { return _func->GetString( EXPORTIGES_ARG_FILENAME ); } + + void SetVersion( const TCollection_AsciiString& theVersion ) + { _func->SetString( EXPORTIGES_ARG_VERSION, theVersion ); } + TCollection_AsciiString GetVersion() + { return _func->GetString( EXPORTIGES_ARG_VERSION ); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _IGESPlugin_IExport_HXX_ diff --git a/src/IGESPlugin/IGESPlugin_IImport.hxx b/src/IGESPlugin/IGESPlugin_IImport.hxx new file mode 100644 index 000000000..da1953d80 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_IImport.hxx @@ -0,0 +1,48 @@ +// 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 _IGESPlugin_IImport_HXX_ +#define _IGESPlugin_IImport_HXX_ + +#include "GEOM_Function.hxx" + +#define IMPORTIGES_ARG_FILENAME 1 +#define IMPORTIGES_ARG_IGNORE_UNITS 2 + +class IGESPlugin_IImport +{ +public: + IGESPlugin_IImport( Handle(GEOM_Function) theFunction) + : _func(theFunction) {} + + void SetFileName( const TCollection_AsciiString& theFileName ) + { _func->SetString( IMPORTIGES_ARG_FILENAME, theFileName ); } + TCollection_AsciiString GetFileName() + { return _func->GetString( IMPORTIGES_ARG_FILENAME ); } + + void SetIsIgnoreUnits( bool theIsIgnoreUnits ) + { _func->SetInteger( IMPORTIGES_ARG_IGNORE_UNITS, int( theIsIgnoreUnits ) ); } + bool GetIsIgnoreUnits() + { return bool( _func->GetInteger( IMPORTIGES_ARG_IGNORE_UNITS ) ); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _IGESPlugin_IImport_HXX_ diff --git a/src/IGESPlugin/IGESPlugin_IOperations.cxx b/src/IGESPlugin/IGESPlugin_IOperations.cxx new file mode 100644 index 000000000..a6af6a7aa --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_IOperations.cxx @@ -0,0 +1,210 @@ +// 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 "IGESPlugin_IOperations.hxx" +#include "IGESPlugin_ExportDriver.hxx" +#include "IGESPlugin_ImportDriver.hxx" +#include "IGESPlugin_IExport.hxx" +#include "IGESPlugin_IImport.hxx" + +// KERNEL includes +#include + +// GEOM includes +#include "GEOM_PythonDump.hxx" +#include "GEOMImpl_Types.hxx" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +IGESPlugin_IOperations::IGESPlugin_IOperations( GEOM_Engine* theEngine, int theDocID ) +: GEOMImpl_IBaseIEOperations( theEngine, theDocID ) +{ + MESSAGE( "IGESPlugin_IOperations::IGESPlugin_IOperations" ); +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +IGESPlugin_IOperations::~IGESPlugin_IOperations() +{ + MESSAGE( "IGESPlugin_IOperations::~IGESPlugin_IOperations" ); +} + +//============================================================================= +/*! + * ExportIGES + * Export a shape to IGES format + * \param theOriginal The shape to export + * \param theFileName The name of the file to exported + * \param theIsASCII The format of the exported file (ASCII or Binary) + * \param theDeflection The deflection of the shape to exported + * \param theVersion The version of IGES format which defines, whether to write + * only faces (5.1 IGES format) or shells and solids also (5.3 IGES format). + */ +//============================================================================= +void IGESPlugin_IOperations::ExportIGES( const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theVersion ) +{ + SetErrorCode(KO); + if( theOriginal.IsNull() ) return; + + Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction(); + if( aRefFunction.IsNull() ) return; //There is no function which creates an object to be exported + + //Add a new result object + Handle(GEOM_Object) result = GetEngine()->AddObject( GetDocID(), GEOM_IMPORT); + + //Add an Export function + Handle(GEOM_Function) aFunction = result->AddFunction( IGESPlugin_ExportDriver::GetID(), EXPORT_SHAPE ); + if( aFunction.IsNull() ) return; + + //Check if the function is set correctly + if( aFunction->GetDriverGUID() != IGESPlugin_ExportDriver::GetID() ) return; + + //Set parameters + IGESPlugin_IExport aCI( aFunction ); + aCI.SetOriginal( aRefFunction ); + aCI.SetFileName( theFileName ); + aCI.SetVersion( theVersion ); + + //Perform the Export + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if( !GetSolver()->ComputeFunction( aFunction ) ) { + SetErrorCode( "Not enough space on disk, or you haven't permissions to write this directory" ); + return; + } + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode( aFail->GetMessageString() ); + return; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << "geompy.ExportIGES(" << theOriginal << ", \"" + << theFileName.ToCString() << "\", \"" << theVersion.ToCString() << "\" )"; + + SetErrorCode(OK); +} + +//============================================================================= +/*! + * ImportIGES + * Import a shape from IGES format + * \param theFileName The name of the file to import + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +IGESPlugin_IOperations::ImportIGES( const TCollection_AsciiString& theFileName, + const bool theIsIgnoreUnits ) +{ + SetErrorCode(KO); + if( theFileName.IsEmpty() ) return NULL; + + //Add a new result object + Handle(GEOM_Object) anImported = GetEngine()->AddObject( GetDocID(), GEOM_IMPORT ); + + //Add an Import function + Handle(GEOM_Function) aFunction = + anImported->AddFunction( IGESPlugin_ImportDriver::GetID(), IMPORT_SHAPE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != IGESPlugin_ImportDriver::GetID()) return NULL; + + //Set parameters + IGESPlugin_IImport aCI( aFunction ); + aCI.SetFileName( theFileName ); + aCI.SetIsIgnoreUnits( theIsIgnoreUnits ); + + //Perform the Import + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if( !GetSolver()->ComputeFunction( aFunction ) ) { + SetErrorCode( "Import driver failed" ); + return NULL; + } + aSeq->Append(anImported); + + // Greate material groups. + // MakeMaterialGroups( anImported, aSeq ); + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode( aFail->GetMessageString() ); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump pd (aFunction); + if( theIsIgnoreUnits ) + pd << aSeq << " = geompy.ImportIGES(\"" << theFileName.ToCString() << "\", True)"; + else + pd << aSeq << " = geompy.ImportIGES(\"" << theFileName.ToCString() << "\")"; + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * ReadValue + */ +//============================================================================= +TCollection_AsciiString IGESPlugin_IOperations::ReadValue + ( const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theParameterName ) +{ + SetErrorCode(KO); + + TCollection_AsciiString aValue, anError; + + if (theFileName.IsEmpty() || theParameterName.IsEmpty()) return aValue; + + aValue = IGESPlugin_ImportDriver::GetValue( theFileName, theParameterName, anError ); + + if( aValue.IsEmpty() ) { + if( anError.IsEmpty() ) + anError = theFileName + " doesn't contain requested parameter"; + return aValue; + } + if (anError.IsEmpty()) + SetErrorCode(OK); + else + SetErrorCode(anError.ToCString()); + + return aValue; +} diff --git a/src/IGESPlugin/IGESPlugin_IOperations.hxx b/src/IGESPlugin/IGESPlugin_IOperations.hxx new file mode 100644 index 000000000..a834f5765 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_IOperations.hxx @@ -0,0 +1,47 @@ +// 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 +// +// File : IGESPlugin_IOperations.hxx + +#ifndef _IGESPlugin_IOperations_HXX_ +#define _IGESPlugin_IOperations_HXX_ + +// internal includes +#include "IGESPlugin_Engine.hxx" + +// GEOM includes +#include "GEOMImpl_IBaseIEOperations.hxx" + +class IGESPLUGINENGINE_EXPORT IGESPlugin_IOperations: public GEOMImpl_IBaseIEOperations +{ +public: + IGESPlugin_IOperations( GEOM_Engine*, int ); + ~IGESPlugin_IOperations(); + + void ExportIGES( const Handle(GEOM_Object), + const TCollection_AsciiString&, + const TCollection_AsciiString& ); + + Handle(TColStd_HSequenceOfTransient) ImportIGES( const TCollection_AsciiString&, + const bool ); + + TCollection_AsciiString ReadValue( const TCollection_AsciiString&, + const TCollection_AsciiString& ); +}; + +#endif diff --git a/src/IGESPlugin/IGESPlugin_IOperations_i.cc b/src/IGESPlugin/IGESPlugin_IOperations_i.cc new file mode 100644 index 000000000..0b8766629 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_IOperations_i.cc @@ -0,0 +1,130 @@ +// 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 "IGESPlugin_IOperations_i.hh" +#include "IGESPlugin_IOperations.hxx" + +// KERNEL includes +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +IGESPlugin_IOperations_i::IGESPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + IGESPlugin_IOperations* theImpl ) +:GEOM_IOperations_i( thePOA, theEngine, theImpl ) +{ + MESSAGE( "IGESPlugin_IOperations_i::IGESPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +IGESPlugin_IOperations_i::~IGESPlugin_IOperations_i() +{ + MESSAGE( "IGESPlugin_IOperations_i::~IGESPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * ExportIGES + * Export a shape to IGES format + * \param theOriginal The shape to export + * \param theFileName The name of the exported file + * \param theVersion The version of IGES format which defines, whether to write + * only faces (5.1 IGES format) or shells and solids also (5.3 IGES format). + */ +//============================================================================= +void IGESPlugin_IOperations_i::ExportIGES( GEOM::GEOM_Object_ptr theOriginal, + const char* theFileName, + const char* theVersion ) +{ + // duplicate the original shape + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate( theOriginal ); + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(GEOM_Object) anOriginal = GetObjectImpl( theOriginal ); + if (anOriginal.IsNull()) return; + + GetOperations()->ExportIGES( anOriginal, theFileName, theVersion ); +} + +//============================================================================= +/*! + * ImportIGES + * Import a shape from IGES format + * \param theFileName The name of the file to import + * \param theIsIgnoreUnits If True, file length units will be ignored (set to 'meter') + * and result model will be scaled, if its units are not meters. + * If False (default), file length units will be taken into account. + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* IGESPlugin_IOperations_i::ImportIGES( const char* theFileName, + const bool theIsIgnoreUnits = false ) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Import the shape from the file + Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportIGES( theFileName, theIsIgnoreUnits ); + + if( !GetOperations()->IsDone() || aHSeq.IsNull() ) + return aSeq._retn(); + + // Copy created objects. + Standard_Integer aLength = aHSeq->Length(); + aSeq->length( aLength ); + for( Standard_Integer i = 1; i <= aLength; i++ ) + aSeq[i-1] = GetObject( Handle(GEOM_Object)::DownCast( aHSeq->Value(i) ) ); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * ReadValue + */ +//============================================================================= +char* IGESPlugin_IOperations_i::ReadValue( const char* theFileName, + const char* theParameterName ) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + TCollection_AsciiString aParam = GetOperations()->ReadValue( theFileName, theParameterName ); + + return CORBA::string_dup( aParam.ToCString() ); +} + +IGESPlugin_IOperations* IGESPlugin_IOperations_i::GetOperations() +{ + return (IGESPlugin_IOperations*)GetImpl(); +} diff --git a/src/IGESPlugin/IGESPlugin_IOperations_i.hh b/src/IGESPlugin/IGESPlugin_IOperations_i.hh new file mode 100644 index 000000000..755b09769 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_IOperations_i.hh @@ -0,0 +1,53 @@ +// 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 _IGESPlugin_IOperations_i_HeaderFile +#define _IGESPlugin_IOperations_i_HeaderFile + +// idl includes +#include +#include CORBA_SERVER_HEADER( GEOM_Gen ) +#include CORBA_SERVER_HEADER( IGESPlugin ) + +// internal includes +#include "IGESPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_IOperations_i.hh" + +class IGESPlugin_IOperations; + +class IGESPLUGINENGINE_EXPORT IGESPlugin_IOperations_i : + public virtual POA_GEOM::IIGESOperations, + public virtual GEOM_IOperations_i +{ +public: + IGESPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + IGESPlugin_IOperations* theImpl ); + ~IGESPlugin_IOperations_i(); + + void ExportIGES( GEOM::GEOM_Object_ptr, const char*, const char* ); + GEOM::ListOfGO* ImportIGES( const char*, const bool ); + char* ReadValue( const char*, const char* ); + + IGESPlugin_IOperations* GetOperations(); +}; + +#endif diff --git a/src/IGESPlugin/IGESPlugin_ImportDriver.cxx b/src/IGESPlugin/IGESPlugin_ImportDriver.cxx new file mode 100644 index 000000000..4ae420e9b --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_ImportDriver.cxx @@ -0,0 +1,292 @@ +// 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 "IGESPlugin_ImportDriver.hxx" +#include "IGESPlugin_IImport.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOM_Function.hxx" +#include "GEOMImpl_Types.hxx" + +// 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 // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& IGESPlugin_ImportDriver::GetID() +{ + static Standard_GUID aGUID("3dbb09b8-659f-4a0f-88b9-d9968c43a448"); + return aGUID; +} + +//======================================================================= +//function : IGESPlugin_ImportDriver +//purpose : +//======================================================================= +IGESPlugin_ImportDriver::IGESPlugin_ImportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer IGESPlugin_ImportDriver::Execute( TFunction_Logbook& log ) const +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + IGESPlugin_IImport aData( aFunction ); + + TCollection_AsciiString aFileName = aData.GetFileName().ToCString(); + bool anIsIgnoreUnits = aData.GetIsIgnoreUnits(); + TDF_Label aShapeLabel = aFunction->GetNamingEntry(); + + TopoDS_Shape aResShape; + TCollection_AsciiString anError; + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + IGESControl_Reader aReader; + + Interface_Static::SetCVal( "xstep.cascade.unit", "M" ); + + try { + OCC_CATCH_SIGNALS; + + IFSelect_ReturnStatus status = aReader.ReadFile( aFileName.ToCString() ); + + if (status == IFSelect_RetDone) { + if( anIsIgnoreUnits ) { + // need re-scale a model, set UnitFlag to 'meter' + Handle(IGESData_IGESModel) aModel = + Handle(IGESData_IGESModel)::DownCast( aReader.Model() ); + if( !aModel.IsNull() ) { + IGESData_GlobalSection aGS = aModel->GlobalSection(); + aGS.SetUnitFlag(6); + aModel->SetGlobalSection(aGS); + } + } + + MESSAGE("ImportIGES : all Geometry Transfer"); + //OCC 5.1.2 porting + // aReader.Clear(); + // aReader.TransferRoots(false); + aReader.ClearShapes(); + aReader.TransferRoots(); + + MESSAGE("ImportIGES : count of shapes produced = " << aReader.NbShapes()); + aResShape = aReader.OneShape(); + + // BEGIN: Store names of sub-shapes from file + Handle(Interface_InterfaceModel) Model = aReader.WS()->Model(); + Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); + if (!TR.IsNull()) { + Handle(Transfer_TransientProcess) TP = /*TransientProcess();*/TR->TransientProcess(); + Standard_Integer nb = Model->NbEntities(); + for (Standard_Integer i = 1; i <= nb; i++) { + Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(Model->Value(i)); + if (ent.IsNull() || ! ent->HasName()) continue; + + // 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( aShapeLabel ); + TNaming_Builder tnBuild (L); + tnBuild.Generated(S); + + // set a name + TCollection_AsciiString string = ent->NameValue()->String(); + string.LeftAdjust(); + string.RightAdjust(); + TCollection_ExtendedString str (string); + TDataStd_Name::Set(L, str); + } + } + // END: Store names + } + else { + switch (status) { + case IFSelect_RetVoid: + anError = "Nothing created or No data to process"; + break; + case IFSelect_RetError: + anError = "Error in command or input data"; + break; + case IFSelect_RetFail: + anError = "Execution was run, but has failed"; + break; + case IFSelect_RetStop: + anError = "Execution has been stopped. Quite possible, an exception was raised"; + break; + default: + break; + } + anError = "Wrong format of the imported file. Can't import file."; + aResShape.Nullify(); + } + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + anError = aFail->GetMessageString(); + aResShape.Nullify(); + } + + if( aResShape.IsNull() ) { + StdFail_NotDone::Raise( anError.ToCString() ); + return 0; + } + + aFunction->SetValue( aResShape ); + + log.SetTouched( Label() ); + + return 1; +} + +//======================================================================= +//function : MustExecute +//purpose : +//======================================================================= +Standard_Boolean IGESPlugin_ImportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool IGESPlugin_ImportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction( Label() ); + + IGESPlugin_IImport aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "ImportIGES"; + + switch ( aType ) { + case IMPORT_SHAPE: + AddParam( theParams, "File name", aCI.GetFileName() ); + if( aCI.GetIsIgnoreUnits() ) + AddParam( theParams, "Format", "IGES_SCALE" ); + break; + default: + return false; + } + return true; +} + +TCollection_AsciiString +IGESPlugin_ImportDriver::GetValue( const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theParameterName, + TCollection_AsciiString& theError ) +{ + Handle(TCollection_HAsciiString) aValue; + + if (theParameterName != "LEN_UNITS") { + theError = theParameterName + " parameter reading is not supported by IGES plugin"; + return TCollection_AsciiString(); + } + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + IGESControl_Reader aReader; + + Interface_Static::SetCVal("xstep.cascade.unit","M"); + + try { + OCC_CATCH_SIGNALS; + + IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); + if (status == IFSelect_RetDone) { + Handle(IGESData_IGESModel) aModel = + Handle(IGESData_IGESModel)::DownCast(aReader.Model()); + if (!aModel.IsNull()) { + aValue = aModel->GlobalSection().UnitName(); + //if (!aValue.IsNull()) { + // Handle(TCollection_HAsciiString) aPrefix = new TCollection_HAsciiString ("UNIT_"); + // aValue->Prepend(aPrefix); + //} + } + } + else { + theError = theFileName + " reading failed"; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + theError = aFail->GetMessageString(); + } + if (!aValue.IsNull()) + return aValue->String(); + else + return TCollection_AsciiString(); +} + + +IMPLEMENT_STANDARD_HANDLE( IGESPlugin_ImportDriver, GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( IGESPlugin_ImportDriver, GEOM_BaseDriver ); diff --git a/src/IGESPlugin/IGESPlugin_ImportDriver.hxx b/src/IGESPlugin/IGESPlugin_ImportDriver.hxx new file mode 100644 index 000000000..2ab850f85 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_ImportDriver.hxx @@ -0,0 +1,56 @@ +// 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 _IGESPlugin_ImportDriver_HXX +#define _IGESPlugin_ImportDriver_HXX + +// internal includes +#include "IGESPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( IGESPlugin_ImportDriver, GEOM_BaseDriver ); + +class IGESPLUGINENGINE_EXPORT IGESPlugin_ImportDriver : public GEOM_BaseDriver +{ +public: + IGESPlugin_ImportDriver(); + ~IGESPlugin_ImportDriver() {}; + + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} + + virtual bool GetCreationInformation( std::string& theOperationName, + std::vector& params ); + + static + TCollection_AsciiString GetValue( const TCollection_AsciiString&, + const TCollection_AsciiString&, + TCollection_AsciiString& ); + +DEFINE_STANDARD_RTTI( IGESPlugin_ImportDriver ) +}; + +#endif // _IGESPlugin_ImportDriver_HXX diff --git a/src/IGESPlugin/IGESPlugin_OperationsCreator.cxx b/src/IGESPlugin/IGESPlugin_OperationsCreator.cxx new file mode 100644 index 000000000..3ea6fc73d --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_OperationsCreator.cxx @@ -0,0 +1,72 @@ +// 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 "IGESPlugin_OperationsCreator.hxx" +#include "IGESPlugin_IOperations_i.hh" +#include "IGESPlugin_IOperations.hxx" +#include "IGESPlugin_ExportDriver.hxx" +#include "IGESPlugin_ImportDriver.hxx" +#include "IGESPlugin_IECallBack.hxx" + +// KERNEL includes +#include +#include + +// OCCT includes +#include + +std::map IGESPlugin_OperationsCreator::_mapOfOperations; + +IGESPlugin_OperationsCreator::IGESPlugin_OperationsCreator() +{ + // Register drivers + TFunction_DriverTable::Get()->AddDriver( IGESPlugin_ExportDriver::GetID(), + new IGESPlugin_ExportDriver() ); + TFunction_DriverTable::Get()->AddDriver( IGESPlugin_ImportDriver::GetID(), + new IGESPlugin_ImportDriver() ); + + // Register callback + IGESPlugin_IECallBack* callback = new IGESPlugin_IECallBack(); + GEOMImpl_IECallBack::Register( "IGES", callback ); + GEOMImpl_IECallBack::Register( "IGES_5_3", callback ); + GEOMImpl_IECallBack::Register( "IGES_SCALE", callback ); +} + +IGESPlugin_OperationsCreator::~IGESPlugin_OperationsCreator() +{ +} + +GEOM_IOperations_i* IGESPlugin_OperationsCreator::Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ) +{ + Unexpect aCatch( SALOME_SalomeException ); + MESSAGE( "IGESPlugin_OperationsCreator::Create" ); + return new IGESPlugin_IOperations_i( thePOA, theEngine, get( theGenImpl, theStudyId ) ); +} + +IGESPlugin_IOperations* IGESPlugin_OperationsCreator::get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ) +{ + if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) + _mapOfOperations[theStudyId] = new IGESPlugin_IOperations( theGenImpl, theStudyId ); + return _mapOfOperations[theStudyId]; +} diff --git a/src/IGESPlugin/IGESPlugin_OperationsCreator.hxx b/src/IGESPlugin/IGESPlugin_OperationsCreator.hxx new file mode 100755 index 000000000..fa2eeb014 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_OperationsCreator.hxx @@ -0,0 +1,57 @@ +// 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 _GEOM_IGESPlugin_OperationsCreator_HXX_ +#define _GEOM_IGESPlugin_OperationsCreator_HXX_ + +// internal includes +#include "IGESPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Gen_i.hh" + +// C++ includes +#include + +class IGESPlugin_IOperations; + +//===================================================================== +// Operations creator +//===================================================================== +class IGESPLUGINENGINE_EXPORT IGESPlugin_OperationsCreator : public GEOM_GenericOperationsCreator +{ +public: + IGESPlugin_OperationsCreator(); + ~IGESPlugin_OperationsCreator(); + + GEOM_IOperations_i* Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ); +private: + static IGESPlugin_IOperations* get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ); + +private: + static std::map _mapOfOperations; + + friend class IGESPlugin_IECallBack; +}; + +#endif diff --git a/src/IGESPlugin/IGESPlugin_msg_en.ts b/src/IGESPlugin/IGESPlugin_msg_en.ts new file mode 100644 index 000000000..7e1586624 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_msg_en.ts @@ -0,0 +1,58 @@ + + + + + @default + + MEN_EXPORTIGES + IGES + + + TOP_EXPORTIGES + Export IGES + + + STB_EXPORTIGES + Export IGES + + + MEN_IMPORTIGES + IGES + + + TOP_IMPORTIGES + Import IGES + + + STB_IMPORTIGES + Import IGES + + + + IGESPlugin_GUI + + IGES_FILES + IGES Files ( *.iges *.igs ) + + + EXPORT_TITLE + Export IGES + + + IMPORT_TITLE + Import IGES + + + SCALE_DIMENSIONS + Take into account the units (%1) embedded to the file? +Ignoring units will cause model scaling (as dimensions are supposed to be specified in meters). + + + + IGESPlugin_ExportDlg + + IGES_VERSION + Version + + + diff --git a/src/IGESPlugin/IGESPlugin_msg_fr.ts b/src/IGESPlugin/IGESPlugin_msg_fr.ts new file mode 100644 index 000000000..f5b26302c --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_msg_fr.ts @@ -0,0 +1,58 @@ + + + + + @default + + MEN_EXPORTIGES + IGES + + + TOP_EXPORTIGES + Exporter IGES + + + STB_EXPORTIGES + Exporter IGES + + + MEN_IMPORTIGES + IGES + + + TOP_IMPORTIGES + Importer IGES + + + STB_IMPORTIGES + Importer IGES + + + + IGESPlugin_GUI + + IGES_FILES + IGES Fichiers ( *.iges *.igs ) + + + EXPORT_TITLE + Exporter IGES + + + IMPORT_TITLE + Importer IGES + + + SCALE_DIMENSIONS + Voulez-vous prendre les unités du fichier (%1) en considération? +Sinon le modèle sera mis à l'échelle GEOM (unités interprétées comme des mètres). + + + + IGESPlugin_ExportDlg + + IGES_VERSION + Version + + + diff --git a/src/IGESPlugin/IGESPlugin_msg_ja.ts b/src/IGESPlugin/IGESPlugin_msg_ja.ts new file mode 100644 index 000000000..5064dead2 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_msg_ja.ts @@ -0,0 +1,57 @@ + + + + + @default + + MEN_EXPORTIGES + IGES + + + TOP_EXPORTIGES + Export IGES + + + STB_EXPORTIGES + Export IGES + + + MEN_IMPORTIGES + IGES + + + TOP_IMPORTIGES + Import IGES + + + STB_IMPORTIGES + Import IGES + + + + IGESPlugin_GUI + + IGES_FILES + IGES Files ( *.iges *.igs ) + + + EXPORT_TITLE + Export IGES + + + IMPORT_TITLE + Import IGES + + + SCALE_DIMENSIONS + インポートしたファイルの単位をミリメートルからメートルに変換しますか?いいえを選んだ場合、メートル単位として解釈します。 + + + + IGESPlugin_ExportDlg + + IGES_VERSION + Version + + + diff --git a/src/ImportExportGUI/CMakeLists.txt b/src/ImportExportGUI/CMakeLists.txt deleted file mode 100644 index f5d9416af..000000000 --- a/src/ImportExportGUI/CMakeLists.txt +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright (C) 2012-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 -# - -INCLUDE(UseQt4Ext) -INCLUDE(${QT_USE_FILE}) - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${QT_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIR} - ${VTK_INCLUDE_DIRS} - ${OMNIORB_INCLUDE_DIR} - ${CAS_INCLUDE_DIRS} - ${KERNEL_INCLUDE_DIRS} - ${GUI_INCLUDE_DIRS} - ${PROJECT_BINARY_DIR}/idl - ${PROJECT_BINARY_DIR} - ${PROJECT_SOURCE_DIR}/src/OBJECT - ${PROJECT_SOURCE_DIR}/src/GEOMClient - ${PROJECT_SOURCE_DIR}/src/GEOMImpl - ${PROJECT_SOURCE_DIR}/src/GEOMGUI - ${PROJECT_SOURCE_DIR}/src/GEOMBase - ${PROJECT_SOURCE_DIR}/src/GEOM - ${PROJECT_SOURCE_DIR}/src/DlgRef - ${PROJECT_BINARY_DIR}/src/DlgRef - ) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ${OMNIORB_DEFINITIONS} - ${QT_DEFINITIONS} - ) - -# libraries to link to -SET(_link_LIBRARIES - GEOMObject - GEOMClient - GEOMImpl - GEOMBase - GEOM - DlgRef - ) - -# --- headers --- - -# header files / no moc processing -SET(ImportExportGUI_HEADERS - ImportExportGUI.h - ) - -# header files / to be processed by moc -SET(_moc_HEADERS - ImportExportGUI_ExportXAODlg.h - ImportExportGUI_ImportXAODlg.h - ) - -# --- sources --- - -# sources / moc wrappings -QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) - -SET(ImportExportGUI_SOURCES - ImportExportGUI.cxx - ImportExportGUI_ExportXAODlg.cxx - ImportExportGUI_ImportXAODlg.cxx - ${_moc_SOURCES} - ) - -# --- rules --- - -ADD_LIBRARY(ImportExportGUI ${ImportExportGUI_SOURCES}) -TARGET_LINK_LIBRARIES(ImportExportGUI ${_link_LIBRARIES}) -INSTALL(TARGETS ImportExportGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/src/ImportExportGUI/ImportExportGUI.cxx b/src/ImportExportGUI/ImportExportGUI.cxx deleted file mode 100644 index 27de1ef59..000000000 --- a/src/ImportExportGUI/ImportExportGUI.cxx +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2013-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 -// - -#include -#include - -#include "GeometryGUI.h" -#include "GeometryGUI_Operations.h" - -#include -#include -#include -#include -#include - -#include "ImportExportGUI_ExportXAODlg.h" -#include "ImportExportGUI_ImportXAODlg.h" -#include "ImportExportGUI.h" -//@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@// - - -//======================================================================= -// function : ImportExportGUI() -// purpose : Constructor -//======================================================================= -ImportExportGUI::ImportExportGUI(GeometryGUI* parent) : - GEOMGUI(parent) -{ -} - -//======================================================================= -// function : ~ImportExportGUI -// purpose : Destructor -//======================================================================= -ImportExportGUI::~ImportExportGUI() -{ -} - -//======================================================================= -// function : OnGUIEvent() -// purpose : -//======================================================================= -bool ImportExportGUI::OnGUIEvent(int commandId, SUIT_Desktop* parent) -{ - SalomeApp_Application* app = getGeometryGUI()->getApp(); - if (!app) return false; - - getGeometryGUI()->EmitSignalDeactivateDialog(); - - QDialog* dialog = NULL; - switch (commandId) - { - case GEOMOp::OpExportXAO: - dialog = new ImportExportGUI_ExportXAODlg(getGeometryGUI(), parent); - break; - case GEOMOp::OpImportXAO: - dialog = new ImportExportGUI_ImportXAODlg(getGeometryGUI(), parent); - break; - //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@// - default: - app->putInfo(tr("GEOM_PRP_COMMAND").arg(commandId)); - break; - } - - if (dialog != NULL) - dialog->show(); - - return true; -} - -//===================================================================================== -// EXPORTED METHODS -//===================================================================================== -extern "C" -{ -#ifdef WIN32 - __declspec( dllexport ) -#endif - GEOMGUI* GetLibGUI(GeometryGUI* parent) - { - return new ImportExportGUI(parent); - } -} diff --git a/src/ImportExportGUI/ImportExportGUI.h b/src/ImportExportGUI/ImportExportGUI.h deleted file mode 100644 index 1c3864a27..000000000 --- a/src/ImportExportGUI/ImportExportGUI.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2013-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 -// - -// File : ImportExportGUI.h -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// -#ifndef IMPORTEXPORTGUI_H -#define IMPORTEXPORTGUI_H - -#include "GEOMGUI.h" - -//================================================================================= -// class : ImportExportGUI -// purpose : -//================================================================================= -class ImportExportGUI: public GEOMGUI -{ -public: - ImportExportGUI(GeometryGUI* parent); - ~ImportExportGUI(); - - bool OnGUIEvent(int commandId, SUIT_Desktop* parent); -}; - -#endif // IMPORTEXPORTGUI_H diff --git a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx deleted file mode 100644 index e620fc8c6..000000000 --- a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx +++ /dev/null @@ -1,450 +0,0 @@ -// Copyright (C) 2013-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 -// - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -// OCCT Includes -#include -#include -#include -#include -#include - -#include -#include "ImportExportGUI_ExportXAODlg.h" - -//================================================================================= -// Constructor -//================================================================================= -ImportExportGUI_ExportXAODlg::ImportExportGUI_ExportXAODlg(GeometryGUI* geometryGUI, QWidget* parent) -: - GEOMBase_Skeleton(geometryGUI, parent, false) -{ - m_mainObj = GEOM::GEOM_Object::_nil(); - - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - QPixmap imageOp(resMgr->loadPixmap("GEOM", tr("ICON_DLG_EXPORTXAO"))); - QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); - - setWindowTitle(tr("GEOM_EXPORTXAO_TITLE")); - - /***************************************************************/ - mainFrame()->GroupConstructors->setTitle(tr("GEOM_EXPORTXAO_TITLE")); - mainFrame()->RadioButton1->setIcon(imageOp); - mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); - mainFrame()->RadioButton2->close(); - mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); - mainFrame()->RadioButton3->close(); - - // hide name - mainFrame()->GroupBoxName->hide(); - - //**************************** - // Selection Group box - QGroupBox* gbxExport = new QGroupBox(parent); - - QGridLayout* gridLayoutExport = new QGridLayout(gbxExport); -#ifndef Q_OS_MAC - gridLayoutExport->setSpacing(6); - gridLayoutExport->setContentsMargins(9, 9, 9, 9); -#endif - gridLayoutExport->setObjectName(QString::fromUtf8("gridLayoutExport")); - - // Line 0 - QLabel* lblShape = new QLabel(tr("GEOM_EXPORTXAO_EXPORTINGSHAPE"), gbxExport); - btnShapeSelect = new QPushButton(gbxExport); - btnShapeSelect->setIcon(iconSelect); - ledShape = new QLineEdit(gbxExport); - ledShape->setMinimumSize(QSize(100, 0)); - - int line = 0, col = 0; - gridLayoutExport->addWidget(lblShape, line, col++, 1, 1); - gridLayoutExport->addWidget(btnShapeSelect, line, col++, 1, 1); - gridLayoutExport->addWidget(ledShape, line, col++, 1, 1); - - // Line 1 - QLabel* lblFileName = new QLabel(tr("GEOM_EXPORTXAO_FILENAME"), gbxExport); - btnFileSelect = new QPushButton(gbxExport); - ledFileName = new QLineEdit(gbxExport); - btnFileSelect->setText("..."); - - line++; col = 0; - gridLayoutExport->addWidget(lblFileName, line, col++, 1, 1); - gridLayoutExport->addWidget(btnFileSelect, line, col++, 1, 1); - gridLayoutExport->addWidget(ledFileName, line, col++, 1, 1); - - // Line 2 - QLabel* lblAuthor = new QLabel(tr("GEOM_EXPORTXAO_AUTHOR"), gbxExport); - ledAuthor = new QLineEdit(gbxExport); - - line++; col = 0; - gridLayoutExport->addWidget(lblAuthor, line, col++, 2, 1); - col++; // span - gridLayoutExport->addWidget(ledAuthor, line, col++, 1, 1); - - //**************************** - // Filter Group box - QGroupBox* gbxFilter = new QGroupBox(parent); - - QGridLayout* gridLayoutFilter = new QGridLayout(gbxFilter); -#ifndef Q_OS_MAC - gridLayoutFilter->setSpacing(6); - gridLayoutFilter->setContentsMargins(9, 9, 9, 9); -#endif - gridLayoutFilter->setObjectName(QString::fromUtf8("gbxFilter")); - - // Line 0 - QLabel* lblGroups = new QLabel(tr("GEOM_EXPORTXAO_LGROUPS"), gbxFilter); - QLabel* lblFields = new QLabel(tr("GEOM_EXPORTXAO_LFIELDS"), gbxFilter); - - line = 0, col = 0; - gridLayoutFilter->addWidget(lblGroups, line, col++, 1, 1); - gridLayoutFilter->addWidget(lblFields, line, col++, 1, 1); - - // Line 1 - lstGroups = new QListWidget(gbxFilter); - lstGroups->setSelectionMode(QAbstractItemView::NoSelection); - lstFields = new QListWidget(gbxFilter); - lstFields->setSelectionMode(QAbstractItemView::NoSelection); - - line++; col = 0; - gridLayoutFilter->addWidget(lstGroups, line, col++, 1, 1); - gridLayoutFilter->addWidget(lstFields, line, col++, 1, 1); - - //**************************** - QVBoxLayout* layout = new QVBoxLayout(centralWidget()); - layout->setMargin(0); - layout->setSpacing(6); - layout->addWidget(gbxExport); - layout->addWidget(gbxFilter); - - // set help - setHelpFileName("xao_format_page.html"); - - Init(); -} - -//================================================================================= -// Destructor -//================================================================================= -ImportExportGUI_ExportXAODlg::~ImportExportGUI_ExportXAODlg() -{ - // no need to delete child widgets, Qt does it all for us -} - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void ImportExportGUI_ExportXAODlg::Init() -{ - // Get setting of step value from file configuration - m_groups.clear(); - m_fields.clear(); - - // Signal/slot connections - connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(btnShapeSelect, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(((SalomeApp_Application*) (SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked())); - - initName(tr("GEOM_EXPORTXAO")); - SelectionIntoArgument(); -} - -//================================================================================= -// function : processObject() -// purpose : Fill dialog fields in accordance with myObj -//================================================================================= -void ImportExportGUI_ExportXAODlg::processObject() -{ - lstGroups->clear(); - lstFields->clear(); - m_groups.clear(); - m_fields.clear(); - - if (m_mainObj->_is_nil()) - { - ledShape->setText(""); - } - else - { - ledShape->setText(GEOMBase::GetName(m_mainObj)); - GEOM::GEOM_IShapesOperations_var shapeOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - - // add groups names - GEOM::ListOfGO_var groups = shapeOp->GetExistingSubObjects(m_mainObj, true); - for (int i = 0, n = groups->length(); i < n; i++) - { - QListWidgetItem* item = new QListWidgetItem(); - item->setData(Qt::UserRole, QVariant(i)); - item->setText(GEOMBase::GetName(groups[i])); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - item->setCheckState(Qt::Checked); - lstGroups->addItem(item); - m_groups.append(GEOM::GeomObjPtr(groups[i].in())); - } - lstGroups->sortItems(Qt::AscendingOrder); - - // add fields - GEOM::GEOM_IFieldOperations_var fieldOp = getGeomEngine()->GetIFieldOperations(getStudyId()); - - GEOM::ListOfFields_var fields = fieldOp->GetFields(m_mainObj); - for (int i = 0, n = fields->length(); i < n; i++) - { - QListWidgetItem* item = new QListWidgetItem(); - item->setData(Qt::UserRole, QVariant(i)); - item->setText(fields[i]->GetName()); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - item->setCheckState(Qt::Checked); - lstFields->addItem(item); - m_fields.append(GEOM::GeomFieldPtr(fields[i].in())); - } - lstFields->sortItems(Qt::AscendingOrder); - } -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void ImportExportGUI_ExportXAODlg::ClickOnOk() -{ - setIsApplyAndClose(true); - if (ClickOnApply()) - ClickOnCancel(); - setIsApplyAndClose(false); -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -bool ImportExportGUI_ExportXAODlg::ClickOnApply() -{ - if (!isApplyAndClose()) - { - setIsDisableBrowsing(true); - setIsDisplayResult(false); - } - - QString msg; - if (!isValid(msg)) - { - showError(msg); - return false; - } - SUIT_OverrideCursor wc; - SUIT_Session::session()->activeApplication()->putInfo(""); - - try - { - if (openCommand()) - if (!execute()) - { - abortCommand(); - showError(); - return false; - } - } - catch (const SALOME::SALOME_Exception& e) - { - SalomeApp_Tools::QtCatchCorbaException(e); - abortCommand(); - return false; - } - commitCommand(); - - if (!isApplyAndClose()) - { - setIsDisableBrowsing(false); - setIsDisplayResult(true); - } - - processObject(); - - return true; -} - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void ImportExportGUI_ExportXAODlg::SelectionIntoArgument() -{ - m_mainObj = GEOM::GEOM_Object::_nil(); - - LightApp_SelectionMgr* selMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO selList; - selMgr->selectedObjects(selList); - - if (selList.Extent() == 1) - { - m_mainObj = GEOMBase::ConvertIOinGEOMObject(selList.First()); - } - - processObject(); -} - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void ImportExportGUI_ExportXAODlg::SetEditCurrentArgument() -{ - ledShape->setFocus(); - myEditCurrentArgument = ledShape; - SelectionIntoArgument(); -} - -//================================================================================= -// function : btnFileSelectClicked() -// purpose : -//================================================================================= -void ImportExportGUI_ExportXAODlg::btnFileSelectClicked() -{ - QString file = SUIT_FileDlg::getFileName(this, ledFileName->text(), - tr("XAO_FILES"), - tr("GEOM_SELECT_EXPORT_XAO"), false); - if ( !file.isEmpty() ) - ledFileName->setText( file ); -} - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void ImportExportGUI_ExportXAODlg::ActivateThisDialog() -{ - GEOMBase_Skeleton::ActivateThisDialog(); -} - -//================================================================================= -// function : enterEvent [REDEFINED] -// purpose : -//================================================================================= -void ImportExportGUI_ExportXAODlg::enterEvent(QEvent*) -{ - if (!mainFrame()->GroupConstructors->isEnabled()) - ActivateThisDialog(); -} - -//================================================================================= -// function : createOperation -// purpose : -//================================================================================= -GEOM::GEOM_IOperations_ptr ImportExportGUI_ExportXAODlg::createOperation() -{ - return getGeomEngine()->GetIInsertOperations(getStudyId()); -} - -//================================================================================= -// function : isValid -// purpose : -//================================================================================= -bool ImportExportGUI_ExportXAODlg::isValid(QString& msg) -{ - // check shape - if (ledShape->text().isEmpty()) - return false; - - // check file name - if (ledFileName->text().isEmpty()) - return false; - - return true; -} - -//================================================================================= -// function : execute -// purpose : -//================================================================================= -bool ImportExportGUI_ExportXAODlg::execute() -{ - bool res = false; - - QString author = ledAuthor->text(); - QString fileName = ledFileName->text(); - - // get selected groups - QList selGroups; - for (int j = 0; j < lstGroups->count(); ++j) - { - if (lstGroups->item(j)->checkState() == Qt::Checked) - selGroups.append(lstGroups->item(j)); - } - - GEOM::ListOfGO_var groups = new GEOM::ListOfGO(); - groups->length(selGroups.count()); - int i = 0; - for (QList::iterator it = selGroups.begin(); it != selGroups.end(); ++it) - { - QListWidgetItem* item = (*it); - int index = item->data(Qt::UserRole).toInt(); - groups[i++] = m_groups[index].copy(); - } - - // get selected fields - QList selFields; - for (int j = 0; j < lstFields->count(); ++j) - { - if (lstFields->item(j)->checkState() == Qt::Checked) - selFields.append(lstFields->item(j)); - } - - GEOM::ListOfFields_var fields = new GEOM::ListOfFields(); - fields->length(selFields.count()); - i = 0; - for (QList::iterator it = selFields.begin(); it != selFields.end(); ++it) - { - QListWidgetItem* item = (*it); - int index = item->data(Qt::UserRole).toInt(); - fields[i++] = m_fields[index].copy(); - } - - // call engine function - GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation()); - res = ieOp->ExportXAO(m_mainObj, groups, fields, - author.toStdString().c_str(), - fileName.toStdString().c_str()); - - return res; -} diff --git a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h deleted file mode 100644 index 61ceffda1..000000000 --- a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2013-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 IMPORTEXPORTGUI_EXPORTXAODLG_H -#define IMPORTEXPORTGUI_EXPORTXAODLG_H - -#include -#include - -class QLineEdit; -class QButtonGroup; -class QListWidget; - -//class ImportExportGUI_1Sel1LineEdit2ListWidget; - -//================================================================================= -// class : ImportExportGUI_ExportXAODlg -// purpose : -//================================================================================= -class ImportExportGUI_ExportXAODlg: public GEOMBase_Skeleton -{ - Q_OBJECT - -public: - ImportExportGUI_ExportXAODlg(GeometryGUI*, QWidget* = 0); - ~ImportExportGUI_ExportXAODlg(); - -protected: - // redefined from GEOMBase_Helper - virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool isValid(QString&); - virtual bool execute(); - -private: - void Init(); - void enterEvent(QEvent*); - void processObject(); - -private: - GEOM::GEOM_Object_var m_mainObj; - QList m_groups; - QList m_fields; - QLineEdit* ledShape; - QLineEdit* ledFileName; - QLineEdit* ledAuthor; - QListWidget* lstGroups; - QListWidget* lstFields; - QPushButton* btnShapeSelect; - QPushButton* btnFileSelect; - -private slots: - void ClickOnOk(); - bool ClickOnApply(); - void ActivateThisDialog(); - void SelectionIntoArgument(); - void SetEditCurrentArgument(); - void btnFileSelectClicked(); -}; - -#endif // IMPORTEXPORTGUI_EXPORTXAODLG_H diff --git a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx b/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx deleted file mode 100644 index 5272fa788..000000000 --- a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx +++ /dev/null @@ -1,350 +0,0 @@ -// Copyright (C) 2013-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 -// - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -// OCCT Includes -#include -#include -#include -#include -#include - -#include -#include "ImportExportGUI_ImportXAODlg.h" - -#include - -//================================================================================= -// Constructor -//================================================================================= -ImportExportGUI_ImportXAODlg::ImportExportGUI_ImportXAODlg(GeometryGUI* geometryGUI, QWidget* parent) -: - GEOMBase_Skeleton(geometryGUI, parent, false) -{ - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - QPixmap imageOp(resMgr->loadPixmap("GEOM", tr("ICON_DLG_IMPORTXAO"))); - QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); - - setWindowTitle(tr("GEOM_IMPORTXAO_TITLE")); - - /***************************************************************/ - mainFrame()->GroupConstructors->setTitle(tr("GEOM_IMPORTXAO_TITLE")); - mainFrame()->RadioButton1->setIcon(imageOp); - mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); - mainFrame()->RadioButton2->close(); - mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); - mainFrame()->RadioButton3->close(); - - // hide name - mainFrame()->GroupBoxName->hide(); - - //**************************** - // Selection Group box - QGroupBox* gbxExport = new QGroupBox(parent); - - QGridLayout* gridLayoutExport = new QGridLayout(gbxExport); -#ifndef Q_OS_MAC - gridLayoutExport->setSpacing(6); - gridLayoutExport->setContentsMargins(9, 9, 9, 9); -#endif - gridLayoutExport->setObjectName(QString::fromUtf8("gridLayoutExport")); - - int line = 0, col = 0; - QLabel* lblFileName = new QLabel(tr("GEOM_IMPORTXAO_FILENAME"), gbxExport); - btnFileSelect = new QPushButton(gbxExport); - ledFileName = new QLineEdit(gbxExport); - btnFileSelect->setText("..."); - - line++; col = 0; - gridLayoutExport->addWidget(lblFileName, line, col++, 1, 1); - gridLayoutExport->addWidget(btnFileSelect, line, col++, 1, 1); - gridLayoutExport->addWidget(ledFileName, line, col++, 1, 1); - - //**************************** - QVBoxLayout* layout = new QVBoxLayout(centralWidget()); - layout->setMargin(0); - layout->setSpacing(6); - layout->addWidget(gbxExport); - - // set help - setHelpFileName("xao_format_page.html"); - - Init(); -} - -//================================================================================= -// Destructor -//================================================================================= -ImportExportGUI_ImportXAODlg::~ImportExportGUI_ImportXAODlg() -{ - // no need to delete child widgets, Qt does it all for us -} - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void ImportExportGUI_ImportXAODlg::Init() -{ - // Signal/slot connections - connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked())); - - initName(tr("GEOM_IMPORTXAO")); - //SelectionIntoArgument(); -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void ImportExportGUI_ImportXAODlg::ClickOnOk() -{ - setIsApplyAndClose(true); - if (ClickOnApply()) - ClickOnCancel(); - setIsApplyAndClose(false); -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -bool ImportExportGUI_ImportXAODlg::ClickOnApply() -{ - if(!isApplyAndClose()) { - setIsDisableBrowsing( true ); - setIsDisplayResult( false ); - } - - QString msg; - if ( !isValid( msg ) ) { - showError( msg ); - return false; - } - SUIT_OverrideCursor wc; - SUIT_Session::session()->activeApplication()->putInfo( "" ); - - try { - if ( openCommand() ) - if (!execute (/*isApplyAndClose()*/)) - { - abortCommand(); - showError(); - return false; - } - } - catch( const SALOME::SALOME_Exception& e ) { - SalomeApp_Tools::QtCatchCorbaException( e ); - abortCommand(); - return false; - } - commitCommand(); - - if(!isApplyAndClose()) { - setIsDisableBrowsing( false ); - setIsDisplayResult( true ); - } - - return true; -} - -//================================================================================= -// function : btnFileSelectClicked() -// purpose : -//================================================================================= -void ImportExportGUI_ImportXAODlg::btnFileSelectClicked() -{ - QString file = SUIT_FileDlg::getFileName(this, ledFileName->text(), - tr("XAO_FILES"), - tr("GEOM_SELECT_IMPORT_XAO")); - if ( !file.isEmpty() ) - ledFileName->setText( file ); -} - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void ImportExportGUI_ImportXAODlg::ActivateThisDialog() -{ - GEOMBase_Skeleton::ActivateThisDialog(); -} - -//================================================================================= -// function : enterEvent [REDEFINED] -// purpose : -//================================================================================= -void ImportExportGUI_ImportXAODlg::enterEvent(QEvent*) -{ - if (!mainFrame()->GroupConstructors->isEnabled()) - ActivateThisDialog(); -} - -//================================================================================= -// function : createOperation -// purpose : -//================================================================================= -GEOM::GEOM_IOperations_ptr ImportExportGUI_ImportXAODlg::createOperation() -{ - return getGeomEngine()->GetIInsertOperations(getStudyId()); -} - -//================================================================================= -// function : isValid -// purpose : -//================================================================================= -bool ImportExportGUI_ImportXAODlg::isValid(QString& msg) -{ - // check file name - if (ledFileName->text().isEmpty()) - return false; - - return true; -} - -//================================================================================= -// function : execute -// purpose : -//================================================================================= -bool ImportExportGUI_ImportXAODlg::execute() -{ - bool res = false; - - QString fileName = ledFileName->text(); - GEOM::GEOM_Object_var shape; - GEOM::ListOfGO_var groups, subShapes; - GEOM::ListOfFields_var fields; - - GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation()); - res = ieOp->ImportXAO(fileName.toUtf8().constData(), shape, subShapes, groups, fields); - - if (!shape->_is_nil()) - { - m_mainShape = shape; - } - else - { - m_mainShape = NULL; - } - - if (m_mainShape != NULL) - { - QStringList anEntryList; - anEntryList << addInStudy(m_mainShape, m_mainShape->GetName()); - - for (int i = 0; i < subShapes->length(); i++) - { - addInStudy(subShapes[i].in(), subShapes[i]->GetName()); - } - for (int i = 0; i < groups->length(); i++) - { - addInStudy(groups[i].in(), groups[i]->GetName()); - } - for (int i = 0; i < fields->length(); i++) - { - addFieldInStudy(fields[i].in(), m_mainShape); - } - - updateObjBrowser(); - if( SUIT_Application* anApp = SUIT_Session::session()->activeApplication() ) { - LightApp_Application* aLightApp = dynamic_cast( anApp ); - aLightApp->browseObjects( anEntryList ); - } - } - - return res; -} - -QString ImportExportGUI_ImportXAODlg::addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEOM::GEOM_Object_ptr theFather) -{ - if ( !hasCommand() ) - return QString(); - - _PTR(Study) aStudy = getStudy()->studyDS(); - if ( !aStudy || theField->_is_nil() ) - return QString(); - - SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy(aStudy); - - SALOMEDS::SObject_var aSO = - getGeomEngine()->AddInStudy(aStudyDS, theField, theField->GetName(), theFather); - - QString anEntry; - if ( !aSO->_is_nil() ) { - CORBA::String_var entry = aSO->GetID(); - anEntry = entry.in(); - } - - // add steps - GEOM::ListOfLong_var steps = theField->GetSteps(); - for (int i = 0; i < steps->length(); ++i) - { - GEOM::GEOM_FieldStep_ptr step = theField->GetStep(steps[i]); - QString stepName = (tr("STEP") + " %1 %2").arg( step->GetID() ).arg( step->GetStamp() ); - SALOMEDS::SObject_wrap aSOField = - getGeomEngine()->AddInStudy( aStudyDS, step, stepName.toLatin1().constData(), theField ); - } - - aSO->UnRegister(); - - return anEntry; -} - -GEOM::GEOM_Object_ptr ImportExportGUI_ImportXAODlg::getFather(GEOM::GEOM_Object_ptr object) -{ - GEOM::GEOM_Object_var fatherObj; - if (object->GetType() != GEOM_IMPORT && m_mainShape != NULL) - { - //GEOM::GEOM_IGroupOperations_var groupOper = getGeomEngine()->GetIGroupOperations(getStudyId()); - //fatherObj = groupOper->GetMainShape(object); - fatherObj = m_mainShape; - } - return fatherObj._retn(); -} - -QString ImportExportGUI_ImportXAODlg::getObjectName(GEOM::GEOM_Object_ptr object) const -{ - if (object->_is_nil()) - return QString::null; - return object->GetName(); -} - diff --git a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h b/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h deleted file mode 100644 index d241ace6b..000000000 --- a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2013-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 IMPORTEXPORTGUI_IMPORTXAODLG_H -#define IMPORTEXPORTGUI_IMPORTXAODLG_H - -#include -#include - -class QLineEdit; -class QButtonGroup; -class QListWidget; - -//================================================================================= -// class : ImportExportGUI_ImportXAODlg -// purpose : -//================================================================================= -class ImportExportGUI_ImportXAODlg: public GEOMBase_Skeleton -{ - Q_OBJECT - -public: - ImportExportGUI_ImportXAODlg(GeometryGUI*, QWidget* = 0); - ~ImportExportGUI_ImportXAODlg(); - -protected: - // redefined from GEOMBase_Helper - virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool isValid(QString&); - virtual bool execute(); - virtual GEOM::GEOM_Object_ptr getFather(GEOM::GEOM_Object_ptr object); - virtual QString getObjectName(GEOM::GEOM_Object_ptr object) const; - virtual QString addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEOM::GEOM_Object_ptr theFather ); - -private: - void Init(); - void enterEvent(QEvent*); - -private: - QLineEdit* ledFileName; - QPushButton* btnFileSelect; - GEOM::GEOM_Object_var m_mainShape; - -private slots: - void ClickOnOk(); - bool ClickOnApply(); - void ActivateThisDialog(); -// void LineEditReturnPressed(); - void btnFileSelectClicked(); -}; - -#endif // IMPORTEXPORTGUI_EXPORTXAODLG_H diff --git a/src/OBJECT/GEOM_OCCReader.cxx b/src/OBJECT/GEOM_OCCReader.cxx index 02e81bdf1..61e7208b3 100644 --- a/src/OBJECT/GEOM_OCCReader.cxx +++ b/src/OBJECT/GEOM_OCCReader.cxx @@ -213,7 +213,7 @@ void GEOM_OCCReader::createISO (const TopoDS_Face &TopologicalFace, vtkPoints *Pts, vtkCellArray *Cell) { - GEOMUtils_Hatcher aHatcher(TopologicalFace); + GEOMUtils::Hatcher aHatcher(TopologicalFace); aHatcher.Init(NbIsos); aHatcher.Perform(); @@ -231,7 +231,7 @@ void GEOM_OCCReader::createISO (const TopoDS_Face &TopologicalFace, // Function : createIsos // Purpose : Create isolines obtained from hatcher. //======================================================================= -void GEOM_OCCReader::createIsos(const GEOMUtils_Hatcher &theHatcher, +void GEOM_OCCReader::createIsos(const GEOMUtils::Hatcher &theHatcher, const Standard_Boolean IsUIso, Standard_Integer &pt_start_idx, vtkPoints *Pts, diff --git a/src/OBJECT/GEOM_OCCReader.h b/src/OBJECT/GEOM_OCCReader.h index ed47445a7..63b622fb8 100644 --- a/src/OBJECT/GEOM_OCCReader.h +++ b/src/OBJECT/GEOM_OCCReader.h @@ -39,7 +39,10 @@ class vtkPoints; class vtkCellArray; -class GEOMUtils_Hatcher; +namespace GEOMUtils +{ + class Hatcher; +} // OpenCASCADE #include @@ -100,12 +103,12 @@ class GEOM_OBJECT_EXPORT GEOM_OCCReader : public vtkAlgorithm { vtkPoints* Pts, vtkCellArray* Cells); - void createIsos(const GEOMUtils_Hatcher &theHatcher, + void createIsos(const GEOMUtils::Hatcher &theHatcher, const Standard_Boolean IsUIso, - Standard_Integer &pt_start_idx, - vtkPoints *Pts, - vtkCellArray *Cell); - + Standard_Integer &pt_start_idx, + vtkPoints *Pts, + vtkCellArray *Cell); + void DrawIso(GeomAbs_IsoType aType, Standard_Real PParm, Standard_Real p1, diff --git a/src/OCC2VTK/GEOM_FaceSource.h b/src/OCC2VTK/GEOM_FaceSource.h index 4627f7a48..68d507657 100755 --- a/src/OCC2VTK/GEOM_FaceSource.h +++ b/src/OCC2VTK/GEOM_FaceSource.h @@ -1,4 +1,4 @@ -#include // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-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 diff --git a/src/OCC2VTK/GEOM_WireframeFace.cxx b/src/OCC2VTK/GEOM_WireframeFace.cxx index 8c94300f5..f9d31608e 100755 --- a/src/OCC2VTK/GEOM_WireframeFace.cxx +++ b/src/OCC2VTK/GEOM_WireframeFace.cxx @@ -109,7 +109,7 @@ CreateIso(const TopoDS_Face& theFace, vtkPolyData* thePolyData, vtkPoints* thePts) { - GEOMUtils_Hatcher aHatcher(theFace); + GEOMUtils::Hatcher aHatcher(theFace); aHatcher.Init(theNbIso[0], theNbIso[1]); aHatcher.Perform(); @@ -125,11 +125,11 @@ CreateIso(const TopoDS_Face& theFace, void GEOM_WireframeFace:: -CreateIso(const GEOMUtils_Hatcher &theHatcher, +CreateIso(const GEOMUtils::Hatcher &theHatcher, const Standard_Boolean IsUIso, const int theDiscret, - vtkPolyData *thePolyData, - vtkPoints *thePts) + vtkPolyData *thePolyData, + vtkPoints *thePts) { Handle(TColStd_HArray1OfInteger) anIndices; Handle(TColStd_HArray1OfReal) aParams; diff --git a/src/OCC2VTK/GEOM_WireframeFace.h b/src/OCC2VTK/GEOM_WireframeFace.h index 27947dd20..c4dcbc96b 100755 --- a/src/OCC2VTK/GEOM_WireframeFace.h +++ b/src/OCC2VTK/GEOM_WireframeFace.h @@ -27,7 +27,11 @@ #include class vtkPolyData; -class GEOMUtils_Hatcher; + +namespace GEOMUtils +{ + class Hatcher; +} class OCC2VTK_EXPORT GEOM_WireframeFace: public GEOM_FaceSource { @@ -67,11 +71,11 @@ protected: static void - CreateIso(const GEOMUtils_Hatcher &theHatcher, - const Standard_Boolean IsUIso, - const int theDiscret, - vtkPolyData *thePolyData, - vtkPoints *thePts); + CreateIso(const GEOMUtils::Hatcher &theHatcher, + const Standard_Boolean IsUIso, + const int theDiscret, + vtkPolyData *thePolyData, + vtkPoints *thePts); static void diff --git a/src/STEPExport/CMakeLists.txt b/src/STEPExport/CMakeLists.txt deleted file mode 100755 index 45965bf43..000000000 --- a/src/STEPExport/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2012-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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIR} - ${KERNEL_INCLUDE_DIRS} - ) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKSTEP} - ${KERNEL_SALOMELocalTrace} - ) - -# --- sources --- - -SET(STEPExport_SOURCES - STEPExport.cxx - ) - -# --- rules --- - -ADD_LIBRARY(STEPExport ${STEPExport_SOURCES}) -TARGET_LINK_LIBRARIES(STEPExport ${_link_LIBRARIES}) -INSTALL(TARGETS STEPExport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) - - diff --git a/src/STEPExport/STEPExport.cxx b/src/STEPExport/STEPExport.cxx deleted file mode 100644 index 35f14f27b..000000000 --- a/src/STEPExport/STEPExport.cxx +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// - -// File: STEPExport.cxx -// Created: Wed May 19 14:53:52 2004 -// Author: Pavel TELKOV - -#include "utilities.h" - -#include - -#include - -#include -#include - -#include -#include - -#ifdef WIN32 - #if defined STEPEXPORT_EXPORTS || defined STEPExport_EXPORTS - #define STEPEXPORT_EXPORT __declspec( dllexport ) - #else - #define STEPEXPORT_EXPORT __declspec( dllimport ) - #endif -#else - #define STEPEXPORT_EXPORT -#endif - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ - STEPEXPORT_EXPORT int Export (const TopoDS_Shape& theShape, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& /*theFormatName*/) - { - MESSAGE("Export STEP into file " << theFileName.ToCString()); - - try - { - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - IFSelect_ReturnStatus status ; - //VRV: OCC 4.0 migration - STEPControl_Writer aWriter; - //VSR: 16/09/09: Convert to METERS - Interface_Static::SetCVal("xstep.cascade.unit","M"); - Interface_Static::SetCVal("write.step.unit", "M"); - Interface_Static::SetIVal("write.step.nonmanifold", 1); - //JFA: PAL6162 status = aWriter.Transfer( theShape, STEPControl_ManifoldSolidBrep ); - status = aWriter.Transfer( theShape, STEPControl_AsIs ); - //VRV: OCC 4.0 migration - if ( status == IFSelect_RetDone ) - status = aWriter.Write( theFileName.ToCString() ); - - // Return previous locale - if ( status == IFSelect_RetDone ) - return 1; - } - catch (Standard_Failure) - { - //THROW_SALOME_CORBA_EXCEPTION("Exception catched in STEPExport", SALOME::BAD_PARAM); - } - return 0; - } -} diff --git a/src/STEPImport/CMakeLists.txt b/src/STEPImport/CMakeLists.txt deleted file mode 100755 index 47ebea3e1..000000000 --- a/src/STEPImport/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (C) 2012-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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIR} - ${KERNEL_INCLUDE_DIRS} - ) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKSTEP} ${CAS_TKCAF} - ${CAS_TKLCAF} - ${CAS_TKSTEPBase} - ${KERNEL_SALOMELocalTrace} - ) - -# --- sources --- - -SET(STEPImport_SOURCES - STEPImport.cxx - ) - -# --- rules --- - -ADD_LIBRARY(STEPImport ${STEPImport_SOURCES}) -TARGET_LINK_LIBRARIES(STEPImport ${_link_LIBRARIES}) -INSTALL(TARGETS STEPImport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) - - diff --git a/src/STEPImport/STEPImport.cxx b/src/STEPImport/STEPImport.cxx deleted file mode 100644 index 0dc8d7057..000000000 --- a/src/STEPImport/STEPImport.cxx +++ /dev/null @@ -1,581 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// - -// File: STEPImport.cxx -// Created: Wed May 19 14:41:10 2004 -// Author: Pavel TELKOV - -#include "utilities.h" - -#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 -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC - -#ifdef WIN32 - #if defined STEPIMPORT_EXPORTS || defined STEPImport_EXPORTS - #define STEPIMPORT_EXPORT __declspec( dllexport ) - #else - #define STEPIMPORT_EXPORT __declspec( dllimport ) - #endif -#else - #define STEPIMPORT_EXPORT -#endif - - -//============================================================================= -/*! - * GetShape() - */ -//============================================================================= - -static TopoDS_Shape GetShape(const Handle(Standard_Transient) &theEnti, - const Handle(Transfer_TransientProcess) &theTP) -{ - TopoDS_Shape aResult; - Handle(Transfer_Binder) aBinder = theTP->Find(theEnti); - - if (aBinder.IsNull()) { - return aResult; - } - - aResult = TransferBRep::ShapeResult(aBinder); - - return aResult; -} - -//============================================================================= -/*! - * GetLabel() - */ -//============================================================================= - -static TDF_Label GetLabel(const Handle(Standard_Transient) &theEnti, - const TDF_Label &theShapeLabel, - const TopoDS_Shape &aShape) -{ - TDF_Label aResult; - - if (theEnti->IsKind - (STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) { - // check all named shapes using iterator - TDF_ChildIDIterator anIt - (theShapeLabel, TDataStd_Name::GetID(), Standard_True); - - for (; anIt.More(); anIt.Next()) { - Handle(TDataStd_Name) nameAttr = - Handle(TDataStd_Name)::DownCast(anIt.Value()); - - if (nameAttr.IsNull()) { - continue; - } - - TDF_Label aLab = nameAttr->Label(); - Handle(TNaming_NamedShape) shAttr; - - if (aLab.FindAttribute(TNaming_NamedShape::GetID(), shAttr) && - shAttr->Get().IsEqual(aShape)) { - aResult = aLab; - } - } - } - - // create label and set shape - if (aResult.IsNull()) { - TDF_TagSource aTag; - - aResult = aTag.NewChild(theShapeLabel); - - TNaming_Builder tnBuild (aResult); - - tnBuild.Generated(aShape); - } - - return aResult; -} - -//============================================================================= -/*! - * StoreName() - */ -//============================================================================= - -static void StoreName(const Handle(Standard_Transient) &theEnti, - const TopTools_IndexedMapOfShape &theIndices, - const Handle(Transfer_TransientProcess) &theTP, - const TDF_Label &theShapeLabel) -{ - Handle(TCollection_HAsciiString) aName; - - if (theEnti->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem)) || - theEnti->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) { - aName = Handle(StepRepr_RepresentationItem)::DownCast(theEnti)->Name(); - } else { - Handle(StepBasic_ProductDefinition) PD = - Handle(StepBasic_ProductDefinition)::DownCast(theEnti); - - if (PD.IsNull() == Standard_False) { - Handle(StepBasic_Product) Prod = PD->Formation()->OfProduct(); - aName = Prod->Name(); - } - } - - bool isValidName = false; - - if (aName.IsNull() == Standard_False) { - isValidName = true; - - if (aName->UsefullLength() < 1) { - isValidName = false; - } else if (aName->UsefullLength() == 4 && - toupper (aName->Value(1)) == 'N' && - toupper (aName->Value(2)) == 'O' && - toupper (aName->Value(3)) == 'N' && - toupper (aName->Value(4)) == 'E') { - // skip 'N0NE' name - isValidName = false; - } else { - // special check to pass names like "Open CASCADE STEP translator 6.3 1" - TCollection_AsciiString aSkipName ("Open CASCADE STEP translator"); - - if (aName->Length() >= aSkipName.Length()) { - if (aName->String().SubString - (1, aSkipName.Length()).IsEqual(aSkipName)) { - isValidName = false; - } - } - } - } - - if (isValidName) { - TCollection_ExtendedString aNameExt (aName->ToCString()); - - // find target shape - TopoDS_Shape S = GetShape(theEnti, theTP); - - if (S.IsNull()) { - return; - } - - // as PRODUCT can be included in the main shape - // several times, we look here for all iclusions. - Standard_Integer isub, nbSubs = theIndices.Extent(); - - for (isub = 1; isub <= nbSubs; isub++) { - TopoDS_Shape aSub = theIndices.FindKey(isub); - - if (aSub.IsPartner(S)) { - TDF_Label L = GetLabel(theEnti, theShapeLabel, aSub); - - // set a name - TDataStd_Name::Set(L, aNameExt); - } - } - } -} - -//============================================================================= -/*! - * StoreMaterial() - */ -//============================================================================= - -static void StoreMaterial - (const Handle(Standard_Transient) &theEnti, - const TopTools_IndexedMapOfShape &theIndices, - const Handle(Transfer_TransientProcess) &theTP, - const TDF_Label &theShapeLabel) -{ - // Treat Product Definition Shape only. - Handle(StepRepr_ProductDefinitionShape) aPDS = - Handle(StepRepr_ProductDefinitionShape)::DownCast(theEnti); - Handle(StepBasic_ProductDefinition) aProdDef; - - if(aPDS.IsNull() == Standard_False) { - // Product Definition Shape ==> Product Definition - aProdDef = aPDS->Definition().ProductDefinition(); - } - - if (aProdDef.IsNull() == Standard_False) { - // Product Definition ==> Property Definition - const Interface_Graph &aGraph = theTP->Graph(); - Interface_EntityIterator aSubs = aGraph.Sharings(aProdDef); - TopoDS_Shape aShape; - - for(aSubs.Start(); aSubs.More(); aSubs.Next()) { - Handle(StepRepr_PropertyDefinition) aPropD = - Handle(StepRepr_PropertyDefinition)::DownCast(aSubs.Value()); - - if(aPropD.IsNull() == Standard_False) { - // Property Definition ==> Representation. - Interface_EntityIterator aSubs1 = aGraph.Sharings(aPropD); - - for(aSubs1.Start(); aSubs1.More(); aSubs1.Next()) { - Handle(StepRepr_PropertyDefinitionRepresentation) aPDR = - Handle(StepRepr_PropertyDefinitionRepresentation):: - DownCast(aSubs1.Value()); - - if(aPDR.IsNull() == Standard_False) { - // Property Definition ==> Material Name. - Handle(StepRepr_Representation) aRepr = aPDR->UsedRepresentation(); - - if(aRepr.IsNull() == Standard_False) { - Standard_Integer ir; - - for(ir = 1; ir <= aRepr->NbItems(); ir++) { - Handle(StepRepr_RepresentationItem) aRI = aRepr->ItemsValue(ir); - Handle(StepRepr_DescriptiveRepresentationItem) aDRI = - Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(aRI); - - if(aDRI.IsNull() == Standard_False) { - // Get shape from Product Definition - Handle(TCollection_HAsciiString) aMatName = aDRI->Name(); - - if(aMatName.IsNull() == Standard_False) { - TCollection_ExtendedString - aMatNameExt (aMatName->ToCString()); - - if (aShape.IsNull()) { - // Get the shape. - aShape = GetShape(aProdDef, theTP); - - if (aShape.IsNull()) { - return; - } - } - - // as PRODUCT can be included in the main shape - // several times, we look here for all iclusions. - Standard_Integer isub, nbSubs = theIndices.Extent(); - - for (isub = 1; isub <= nbSubs; isub++) { - TopoDS_Shape aSub = theIndices.FindKey(isub); - - if (aSub.IsPartner(aShape)) { - TDF_Label aLabel = - GetLabel(aProdDef, theShapeLabel, aSub); - - // set a name - TDataStd_Comment::Set(aLabel, aMatNameExt); - } - } - } - } - } - } - } - } - } - } - } -} - -//============================================================================= -/*! - * Import() - */ -//============================================================================= - -extern "C" -{ - STEPIMPORT_EXPORT - Handle(TCollection_HAsciiString) GetValue (const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theParameterName, - TCollection_AsciiString& theError) - { - Handle(TCollection_HAsciiString) aValue; - - if (theParameterName != "LEN_UNITS") { - theError = theParameterName + " parameter reading is not supported by STEP plugin"; - return aValue; - } - - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - STEPControl_Reader aReader; - - Interface_Static::SetCVal("xstep.cascade.unit","M"); - Interface_Static::SetIVal("read.step.ideas", 1); - Interface_Static::SetIVal("read.step.nonmanifold", 1); - - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); - if (status == IFSelect_RetDone) { - TColStd_SequenceOfAsciiString anUnitLengthNames; - TColStd_SequenceOfAsciiString anUnitAngleNames; - TColStd_SequenceOfAsciiString anUnitSolidAngleNames; - aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames); - if (anUnitLengthNames.Length() > 0) { - aValue = new TCollection_HAsciiString( anUnitLengthNames.First() ); - /* - TCollection_AsciiString aLenUnits = anUnitLengthNames.First(); - if (aLenUnits == "millimetre") - aValue = new TCollection_HAsciiString ("MM"); - else if (aLenUnits == "centimetre") - aValue = new TCollection_HAsciiString ("CM"); - else if (aLenUnits == "metre") - aValue = new TCollection_HAsciiString ("M"); - else if (aLenUnits == "INCH") - aValue = new TCollection_HAsciiString ("INCH"); - // TODO (for other units than mm, cm, m or inch) - //else if (aLenUnits == "") - // aValue = new TCollection_HAsciiString (""); - - // tmp begin - //std::cout << "$$$ --- " << anUnitLengthNames.First(); - //for (int ii = 2; ii <= anUnitLengthNames.Length(); ii++) - // std::cout << ", " << anUnitLengthNames.Value(ii); - //std::cout << std::endl; - // tmp end - */ - } - } - else { - theError = theFileName + " reading failed"; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - theError = aFail->GetMessageString(); - } - - return aValue; - } - - STEPIMPORT_EXPORT - TopoDS_Shape Import (const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName, - TCollection_AsciiString& theError, - const TDF_Label& theShapeLabel) - { - TopoDS_Shape aResShape; - - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - STEPControl_Reader aReader; - - //VSR: 16/09/09: Convert to METERS - Interface_Static::SetCVal("xstep.cascade.unit","M"); - Interface_Static::SetIVal("read.step.ideas", 1); - Interface_Static::SetIVal("read.step.nonmanifold", 1); - - BRep_Builder B; - TopoDS_Compound compound; - B.MakeCompound(compound); - - try { - OCC_CATCH_SIGNALS; - - IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); - - if (status == IFSelect_RetDone) { - - // Regard or not the model units - if (theFormatName == "STEP_SCALE") { - // set UnitFlag to units from file - TColStd_SequenceOfAsciiString anUnitLengthNames; - TColStd_SequenceOfAsciiString anUnitAngleNames; - TColStd_SequenceOfAsciiString anUnitSolidAngleNames; - aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames); - if (anUnitLengthNames.Length() > 0) { - TCollection_AsciiString aLenUnits = anUnitLengthNames.First(); - if (aLenUnits == "millimetre") - Interface_Static::SetCVal("xstep.cascade.unit", "MM"); - else if (aLenUnits == "centimetre") - Interface_Static::SetCVal("xstep.cascade.unit", "CM"); - else if (aLenUnits == "metre" || aLenUnits.IsEmpty()) - Interface_Static::SetCVal("xstep.cascade.unit", "M"); - else if (aLenUnits == "INCH") - Interface_Static::SetCVal("xstep.cascade.unit", "INCH"); - else { - theError = "The file contains not supported units."; - return aResShape; - } - // TODO (for other units than mm, cm, m or inch) - //else if (aLenUnits == "") - // Interface_Static::SetCVal("xstep.cascade.unit", "???"); - } - } - else { - //cout<<"need re-scale a model"<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 ie = 1; ie <= nb; ie++) { - Handle(Standard_Transient) enti = Model->Value(ie); - - // Store names. - StoreName(enti, anIndices, TP, theShapeLabel); - - // Store materials. - StoreMaterial(enti, anIndices, TP, theShapeLabel); - } - } - // END: Store names and materials - } - else { -// switch (status) { -// case IFSelect_RetVoid: -// theError = "Nothing created or No data to process"; -// break; -// case IFSelect_RetError: -// theError = "Error in command or input data"; -// break; -// case IFSelect_RetFail: -// theError = "Execution was run, but has failed"; -// break; -// case IFSelect_RetStop: -// theError = "Execution has been stopped. Quite possible, an exception was raised"; -// break; -// default: -// break; -// } - 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 previous locale - return aResShape; - } -} diff --git a/src/STEPPlugin/CMakeLists.txt b/src/STEPPlugin/CMakeLists.txt new file mode 100644 index 000000000..71c1097dc --- /dev/null +++ b/src/STEPPlugin/CMakeLists.txt @@ -0,0 +1,147 @@ +# 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 +# + +IF(SALOME_BUILD_GUI) + INCLUDE(UseQt4Ext) + INCLUDE(${QT_USE_FILE}) +ENDIF() + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} + ${KERNEL_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR}/idl + ${PROJECT_SOURCE_DIR}/src/GEOMAlgo + ${PROJECT_SOURCE_DIR}/src/GEOM + ${PROJECT_SOURCE_DIR}/src/GEOMImpl + ${PROJECT_SOURCE_DIR}/src/GEOM_I + ${PROJECT_SOURCE_DIR}/src/GEOMClient + ${PROJECT_SOURCE_DIR}/src/GEOMUtils + ) + +IF(SALOME_BUILD_GUI) + INCLUDE_DIRECTORIES( + ${QT_INCLUDE_DIRS} + ${GUI_INCLUDE_DIRS} + ${PROJECT_SOURCE_DIR}/src/OBJECT + ${PROJECT_SOURCE_DIR}/src/GEOMGUI + ${PROJECT_SOURCE_DIR}/src/GEOMBase + ) +ENDIF() + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${CAS_DEFINITIONS} + ) + +IF(SALOME_BUILD_GUI) +ADD_DEFINITIONS( + ${QT_DEFINITIONS} + ) +ENDIF() + +# libraries to link to +SET(_link_engine_LIBRARIES + ${CAS_TKSTEP} + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + SalomeIDLGEOM + SalomeIDLSTEPPlugin + GEOMEngine + GEOMClient + ) + +IF(SALOME_BUILD_GUI) + SET(_link_gui_LIBRARIES + SalomeIDLSTEPPlugin + GEOMObject + GEOM + GEOMBase + ) +ENDIF() + + +# --- headers --- + +SET(STEPPluginEngine_HEADERS + STEPPlugin_IOperations_i.hh + STEPPlugin_Engine.hxx + STEPPlugin_OperationsCreator.hxx + STEPPlugin_IOperations.hxx + STEPPlugin_IExport.hxx + STEPPlugin_IImport.hxx + STEPPlugin_ImportDriver.hxx + STEPPlugin_ExportDriver.hxx + STEPPlugin_IECallBack.hxx + ) + +IF(SALOME_BUILD_GUI) + # header files / to be processed by moc + SET(_moc_HEADERS + STEPPlugin_GUI.h + ) +ENDIF() + +# --- sources --- + +IF(SALOME_BUILD_GUI) + # sources / moc wrappings + QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) + + SET(STEPPluginGUI_SOURCES + STEPPlugin_GUI.cxx + ${_moc_SOURCES} + ) +ENDIF() + +SET(STEPPluginEngine_SOURCES + STEPPlugin_Engine.cxx + STEPPlugin_OperationsCreator.cxx + STEPPlugin_IOperations_i.cc + STEPPlugin_IOperations.cxx + STEPPlugin_ExportDriver.cxx + STEPPlugin_ImportDriver.cxx + STEPPlugin_IECallBack.cxx + ) + +# resource files / to be processed by lrelease +SET(STEPPlugin_RESOURCES + STEPPlugin_msg_en.ts + STEPPlugin_msg_fr.ts + STEPPlugin_msg_ja.ts + ) + +# --- rules --- + +ADD_LIBRARY(STEPPluginEngine ${STEPPluginEngine_SOURCES}) +TARGET_LINK_LIBRARIES(STEPPluginEngine ${_link_engine_LIBRARIES}) +INSTALL(TARGETS STEPPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +IF(SALOME_BUILD_GUI) + ADD_LIBRARY(STEPPluginGUI ${STEPPluginGUI_SOURCES}) + TARGET_LINK_LIBRARIES(STEPPluginGUI ${_link_gui_LIBRARIES}) + INSTALL(TARGETS STEPPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + + QT4_INSTALL_TS_RESOURCES("${STEPPlugin_RESOURCES}" "${SALOME_GEOM_INSTALL_RES_DATA}") +ENDIF() + + +INSTALL(FILES ${STEPPluginEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/STEPPlugin/STEPPlugin_Engine.cxx b/src/STEPPlugin/STEPPlugin_Engine.cxx new file mode 100644 index 000000000..c1718744a --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_Engine.cxx @@ -0,0 +1,32 @@ +// 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 "STEPPlugin_Engine.hxx" +#include "STEPPlugin_OperationsCreator.hxx" + +extern "C" +{ + STEPPLUGINENGINE_EXPORT + GEOM_GenericOperationsCreator* GetOperationsCreator() + { + STEPPlugin_OperationsCreator* aCreator = new STEPPlugin_OperationsCreator(); + return aCreator; + } +} diff --git a/src/STEPPlugin/STEPPlugin_Engine.hxx b/src/STEPPlugin/STEPPlugin_Engine.hxx new file mode 100755 index 000000000..624eb2210 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_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 _STEPPLUGIN_ENGINE_HXX_ +#define _STEPPLUGIN_ENGINE_HXX_ + +#ifdef WIN32 + #if defined STEPPLUGINENGINE_EXPORTS || defined STEPPluginEngine_EXPORTS + #define STEPPLUGINENGINE_EXPORT __declspec( dllexport ) + #else + #define STEPPLUGINENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define STEPPLUGINENGINE_EXPORT +#endif + +#endif diff --git a/src/STEPPlugin/STEPPlugin_ExportDriver.cxx b/src/STEPPlugin/STEPPlugin_ExportDriver.cxx new file mode 100644 index 000000000..ba35ffbe3 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_ExportDriver.cxx @@ -0,0 +1,129 @@ +// 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 "STEPPlugin_ExportDriver.hxx" +#include "STEPPlugin_IExport.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOM_Function.hxx" + +// OOCT includes +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& STEPPlugin_ExportDriver::GetID() +{ + static Standard_GUID aGUID("c47b9a61-c6a4-4335-8b13-6badb16b036f"); + return aGUID; +} + +//======================================================================= +//function : STEPPlugin_ExportDriver +//purpose : +//======================================================================= +STEPPlugin_ExportDriver::STEPPlugin_ExportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer STEPPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + STEPPlugin_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 STEP into file " << aFileName.ToCString()); + + try + { + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + IFSelect_ReturnStatus status ; + //VRV: OCC 4.0 migration + STEPControl_Writer aWriter; + Interface_Static::SetCVal("xstep.cascade.unit","M"); + Interface_Static::SetCVal("write.step.unit", "M"); + Interface_Static::SetIVal("write.step.nonmanifold", 1); + status = aWriter.Transfer( aShape, STEPControl_AsIs ); + //VRV: OCC 4.0 migration + if( status == IFSelect_RetDone ) + status = aWriter.Write( aFileName.ToCString() ); + + // Return previous locale + if( status == IFSelect_RetDone ) + return 1; + } + catch (Standard_Failure) + { + //THROW_SALOME_CORBA_EXCEPTION("Exception catched in STEPExport", SALOME::BAD_PARAM); + } + return 0; +} + +//======================================================================= +//function : MustExecute +//purpose : +//======================================================================= +Standard_Boolean STEPPlugin_ExportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ +bool STEPPlugin_ExportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + return false; +} + +IMPLEMENT_STANDARD_HANDLE( STEPPlugin_ExportDriver,GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( STEPPlugin_ExportDriver,GEOM_BaseDriver ); diff --git a/src/STEPPlugin/STEPPlugin_ExportDriver.hxx b/src/STEPPlugin/STEPPlugin_ExportDriver.hxx new file mode 100644 index 000000000..000226491 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_ExportDriver.hxx @@ -0,0 +1,51 @@ +// 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 _STEPPlugin_ExportDriver_HXX +#define _STEPPlugin_ExportDriver_HXX + +// internal includes +#include "STEPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( STEPPlugin_ExportDriver, GEOM_BaseDriver ); + +class STEPPLUGINENGINE_EXPORT STEPPlugin_ExportDriver : public GEOM_BaseDriver +{ +public: + STEPPlugin_ExportDriver(); + ~STEPPlugin_ExportDriver() {}; + + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} + + virtual bool GetCreationInformation( std::string& theOperationName, + std::vector& params ); + +DEFINE_STANDARD_RTTI( STEPPlugin_ExportDriver ) +}; + +#endif // _STEPPlugin_ExportDriver_HXX diff --git a/src/STEPPlugin/STEPPlugin_GUI.cxx b/src/STEPPlugin/STEPPlugin_GUI.cxx new file mode 100644 index 000000000..b43651a15 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_GUI.cxx @@ -0,0 +1,311 @@ +// 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 "STEPPlugin_GUI.h" + +// GUI includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// GEOM includes +#include "GeometryGUI.h" +#include "GEOM_Operation.h" +#include "GEOMBase.h" +#include "GEOM_Displayer.h" + +#include +#include CORBA_SERVER_HEADER(STEPPlugin) + +//======================================================================= +// function : STEPPlugin_GUI() +// purpose : Constructor +//======================================================================= +STEPPlugin_GUI::STEPPlugin_GUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) +{ +} + +//======================================================================= +// function : ~STEPPlugin_GUI +// purpose : Destructor +//======================================================================= +STEPPlugin_GUI::~STEPPlugin_GUI() +{ +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool STEPPlugin_GUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) +{ + QString cmd; + switch ( theCommandID ) { + case 1: + cmd = "Export_STEP"; break; + case 2: + cmd = "Import_STEP"; break; + default: + break; + } + return OnGUIEvent( cmd, parent ); +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool STEPPlugin_GUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) +{ + bool result = false; + + if ( theCommandID == "Export_STEP" ) + { + result = exportSTEP( parent ); + } + else if ( theCommandID == "Import_STEP" ) + { + result = importSTEP( parent ); + } + else + { + getGeometryGUI()->getApp()->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) ); + } + + return result; +} + +//======================================================================= +// function : importSTEP +// purpose : +//======================================================================= +bool STEPPlugin_GUI::importSTEP( SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); + if ( !study ) return false; + + SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STEPPluginEngine" ); + GEOM::ISTEPOperations_var stepOp = GEOM::ISTEPOperations::_narrow( op ); + if ( CORBA::is_nil( stepOp ) ) return false; + + QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), + tr( "STEP_FILES" ), + tr( "IMPORT_TITLE" ), + parent ); + if ( fileNames.count() > 0 ) + { + QStringList entryList; + QStringList errors; + SUIT_MessageBox::StandardButton stepAnswer = SUIT_MessageBox::NoButton; + + for ( int i = 0; i < fileNames.count(); i++ ) + { + QString fileName = fileNames.at( i ); + SUIT_OverrideCursor wc; + GEOM_Operation transaction( app, stepOp.in() ); + bool ignoreUnits = false; + + try + { + app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( fileName, true ) ) ); + transaction.start(); + + CORBA::String_var units = stepOp->ReadValue( fileName.toUtf8().constData(), "LEN_UNITS" ); + QString unitsStr( units.in() ); + bool unitsOK = unitsStr.isEmpty() || unitsStr == "M" || unitsStr.toLower() == "metre"; + + if ( !unitsOK ) + { + if( stepAnswer == SUIT_MessageBox::NoToAll ) + { + ignoreUnits = true; + } + else if( stepAnswer != SUIT_MessageBox::YesToAll ) + { + SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel; + if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll; + stepAnswer = SUIT_MessageBox::question( parent, + tr( "WRN_WARNING" ), + tr( "SCALE_DIMENSIONS" ).arg( unitsStr ), + btns, + SUIT_MessageBox::No ); + switch ( stepAnswer ) + { + case SUIT_MessageBox::Cancel: + return true; // cancel (break) import operation + case SUIT_MessageBox::Yes: + case SUIT_MessageBox::YesToAll: + break; // scaling is confirmed + case SUIT_MessageBox::No: + case SUIT_MessageBox::NoAll: + ignoreUnits = true; // scaling is rejected + default: + break; + } + } + } + + GEOM::ListOfGO_var result = stepOp->ImportSTEP( fileName.toUtf8().constData(), ignoreUnits ); + if ( result->length() > 0 && stepOp->IsDone() ) + { + GEOM::GEOM_Object_var main = result[0]; + QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) ); + SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy, + SALOMEDS::SObject::_nil(), + main.in(), + publishName.toUtf8().constData() ); + + entryList.append( so->GetID() ); + for ( int i = 1, n = result->length(); i < n; i++ ) { + GEOM::GEOM_Object_ptr group = result[i]; + CORBA::String_var grpName = group->GetName(); + GeometryGUI::GetGeomGen()->AddInStudy( dsStudy, group, grpName.in(), main ); + } + transaction.commit(); + GEOM_Displayer( study ).Display( main.in() ); + } + else + { + transaction.abort(); + errors.append( QString( "%1 : %2" ).arg( fileName ).arg( stepOp->GetErrorCode() ) ); + } + } + catch( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + } + } + + getGeometryGUI()->updateObjBrowser( true ); + app->browseObjects( entryList ); + + if ( errors.count() > 0 ) + { + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + } + } + return fileNames.count() > 0; +} + +//======================================================================= +// function : exportSTEP +// purpose : +//======================================================================= +bool STEPPlugin_GUI::exportSTEP( SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); + if ( !study ) return false; + + SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STEPPluginEngine" ); + GEOM::ISTEPOperations_var stepOp = GEOM::ISTEPOperations::_narrow( op ); + if ( CORBA::is_nil( stepOp ) ) return false; + + LightApp_SelectionMgr* sm = app->selectionMgr(); + if ( !sm ) return false; + + SALOME_ListIO selectedObjects; + sm->selectedObjects( selectedObjects ); + bool ok = false; + + SALOME_ListIteratorOfListIO it( selectedObjects ); + for ( ; it.More(); it.Next() ) + { + Handle(SALOME_InteractiveObject) io = it.Value(); + GEOM::GEOM_Object_var obj = GEOMBase::ConvertIOinGEOMObject( io ); + + if ( CORBA::is_nil( obj ) ) continue; + + QString fileName = app->getFileName( false, + QString( io->getName() ), + tr( "STEP_FILES" ), + tr( "EXPORT_TITLE" ), + parent ); + + if ( fileName.isEmpty() ) + return false; + + SUIT_OverrideCursor wc; + + GEOM_Operation transaction( app, stepOp.in() ); + + try + { + app->putInfo( tr( "GEOM_PRP_EXPORT" ).arg( fileName ) ); + transaction.start(); + + stepOp->ExportSTEP( obj, fileName.toUtf8().constData() ); + + if ( stepOp->IsDone() ) + { + transaction.commit(); + } + else + { + transaction.abort(); + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_PRP_ABORT" ) + "\n" + tr( stepOp->GetErrorCode() ) ); + return false; + } + } + catch ( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + return false; + } + ok = true; + } + + if ( !ok ) + { + SUIT_MessageBox::warning( parent, + tr( "WRN_WARNING" ), + tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) ); + } + return ok; +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ +#ifdef WIN32 + __declspec( dllexport ) +#endif + GEOMGUI* GetLibGUI( GeometryGUI* parent ) + { + return new STEPPlugin_GUI( parent ); + } +} diff --git a/src/STEPPlugin/STEPPlugin_GUI.h b/src/STEPPlugin/STEPPlugin_GUI.h new file mode 100644 index 000000000..05d989474 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_GUI.h @@ -0,0 +1,40 @@ +// 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 STEPPlugin_GUI_H +#define STEPPlugin_GUI_H + +#include "GEOMPluginGUI.h" + +class STEPPlugin_GUI: public GEOMPluginGUI +{ + Q_OBJECT +public: + STEPPlugin_GUI( GeometryGUI* parent ); + ~STEPPlugin_GUI(); + + bool OnGUIEvent( int commandId, SUIT_Desktop* ); + bool OnGUIEvent( const QString&, SUIT_Desktop* ); + +private: + bool importSTEP( SUIT_Desktop* ); + bool exportSTEP( SUIT_Desktop* ); +}; + +#endif // STEPPlugin_GUI_H diff --git a/src/STEPPlugin/STEPPlugin_IECallBack.cxx b/src/STEPPlugin/STEPPlugin_IECallBack.cxx new file mode 100755 index 000000000..6089df832 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_IECallBack.cxx @@ -0,0 +1,87 @@ +// 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 "STEPPlugin_IECallBack.hxx" +#include "STEPPlugin_IOperations.hxx" +#include "STEPPlugin_OperationsCreator.hxx" + +//============================================================================= +/*! + * constructor + */ +//============================================================================= +STEPPlugin_IECallBack::STEPPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +STEPPlugin_IECallBack::~STEPPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * Export + */ +//============================================================================= +bool +STEPPlugin_IECallBack::Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ) +{ + STEPPlugin_IOperations* aPluginOperations = STEPPlugin_OperationsCreator::get( GetEngine(), theDocId ); + aPluginOperations->ExportSTEP( theOriginal, theFileName ); + return true; +} + +//============================================================================= +/*! + * Import + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +STEPPlugin_IECallBack::Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ) +{ + STEPPlugin_IOperations* aPluginOperations = STEPPlugin_OperationsCreator::get( GetEngine(), theDocId ); + bool anIsIgnoreUnits = ( theFormatName == "STEP_SCALE" ) ? true : false; + return aPluginOperations->ImportSTEP( theFileName, anIsIgnoreUnits ); +} + +//============================================================================= +/*! + * ReadValue + */ +//============================================================================= +TCollection_AsciiString +STEPPlugin_IECallBack::ReadValue( int theDocId, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theParameterName ) +{ + STEPPlugin_IOperations* aPluginOperations = STEPPlugin_OperationsCreator::get( GetEngine(), theDocId ); + return aPluginOperations->ReadValue( theFileName, theParameterName ); +} diff --git a/src/STEPPlugin/STEPPlugin_IECallBack.hxx b/src/STEPPlugin/STEPPlugin_IECallBack.hxx new file mode 100644 index 000000000..4f6f571c3 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_IECallBack.hxx @@ -0,0 +1,54 @@ +// 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 _STEPPlugin_IECallBack_HXX_ +#define _STEPPlugin_IECallBack_HXX_ + +// internal includes +#include "STEPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Object.hxx" +#include "GEOMImpl_IECallBack.hxx" + +// OCC includes +#include + +class STEPPLUGINENGINE_EXPORT STEPPlugin_IECallBack : public GEOMImpl_IECallBack +{ +public: + STEPPlugin_IECallBack(); + ~STEPPlugin_IECallBack(); + + bool Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ); + + Handle(TColStd_HSequenceOfTransient) Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ); + + TCollection_AsciiString ReadValue( int theDocId, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theParameterName ); +}; + +#endif diff --git a/src/STEPPlugin/STEPPlugin_IExport.hxx b/src/STEPPlugin/STEPPlugin_IExport.hxx new file mode 100644 index 000000000..70fc5da19 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_IExport.hxx @@ -0,0 +1,48 @@ +// 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 _STEPPlugin_IExport_HXX_ +#define _STEPPlugin_IExport_HXX_ + +#include "GEOM_Function.hxx" + +#define EXPORTSTEP_ARG_ORIGINAL 1 +#define EXPORTSTEP_ARG_FILENAME 2 + +class STEPPlugin_IExport +{ +public: + STEPPlugin_IExport( Handle(GEOM_Function) theFunction ) + : _func(theFunction) {} + + void SetOriginal( Handle( GEOM_Function ) theOriginal) + { _func->SetReference( EXPORTSTEP_ARG_ORIGINAL, theOriginal ); } + Handle( GEOM_Function ) GetOriginal() + { return _func->GetReference( EXPORTSTEP_ARG_ORIGINAL ); } + + void SetFileName( const TCollection_AsciiString& theFileName ) + { _func->SetString( EXPORTSTEP_ARG_FILENAME, theFileName ); } + TCollection_AsciiString GetFileName() + { return _func->GetString( EXPORTSTEP_ARG_FILENAME ); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _STEPPlugin_IExport_HXX_ diff --git a/src/STEPPlugin/STEPPlugin_IImport.hxx b/src/STEPPlugin/STEPPlugin_IImport.hxx new file mode 100644 index 000000000..9c2679a0c --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_IImport.hxx @@ -0,0 +1,48 @@ +// 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 _STEPPlugin_IImport_HXX_ +#define _STEPPlugin_IImport_HXX_ + +#include "GEOM_Function.hxx" + +#define IMPORTSTEP_ARG_FILENAME 1 +#define IMPORTSTEP_ARG_IGNORE_UNITS 2 + +class STEPPlugin_IImport +{ +public: + STEPPlugin_IImport( Handle(GEOM_Function) theFunction) + : _func(theFunction) {} + + void SetFileName( const TCollection_AsciiString& theFileName ) + { _func->SetString( IMPORTSTEP_ARG_FILENAME, theFileName ); } + TCollection_AsciiString GetFileName() + { return _func->GetString( IMPORTSTEP_ARG_FILENAME ); } + + void SetIsIgnoreUnits( bool theIsIgnoreUnits ) + { _func->SetInteger( IMPORTSTEP_ARG_IGNORE_UNITS, int( theIsIgnoreUnits ) ); } + bool GetIsIgnoreUnits() + { return bool( _func->GetInteger( IMPORTSTEP_ARG_IGNORE_UNITS ) ); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _STEPPlugin_IImport_HXX_ diff --git a/src/STEPPlugin/STEPPlugin_IOperations.cxx b/src/STEPPlugin/STEPPlugin_IOperations.cxx new file mode 100644 index 000000000..7a0de8b8e --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_IOperations.cxx @@ -0,0 +1,206 @@ +// 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 "STEPPlugin_IOperations.hxx" +#include "STEPPlugin_ExportDriver.hxx" +#include "STEPPlugin_ImportDriver.hxx" +#include "STEPPlugin_IExport.hxx" +#include "STEPPlugin_IImport.hxx" + +// KERNEL includes +#include + +// GEOM includes +#include "GEOM_PythonDump.hxx" +#include "GEOMImpl_Types.hxx" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +STEPPlugin_IOperations::STEPPlugin_IOperations( GEOM_Engine* theEngine, int theDocID ) +: GEOMImpl_IBaseIEOperations( theEngine, theDocID ) +{ + MESSAGE( "STEPPlugin_IOperations::STEPPlugin_IOperations" ); +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +STEPPlugin_IOperations::~STEPPlugin_IOperations() +{ + MESSAGE( "STEPPlugin_IOperations::~STEPPlugin_IOperations" ); +} + +//============================================================================= +/*! + * ExportSTEP + * Export a shape to STEP format + * \param theOriginal The shape to export + * \param theFileName The name of the file to exported + * \param theIsASCII The format of the exported file (ASCII or Binary) + * \param theDeflection The deflection of the shape to exported + */ +//============================================================================= +void STEPPlugin_IOperations::ExportSTEP( const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName ) +{ + SetErrorCode(KO); + if( theOriginal.IsNull() ) return; + + Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction(); + if( aRefFunction.IsNull() ) return; //There is no function which creates an object to be exported + + //Add a new result object + Handle(GEOM_Object) result = GetEngine()->AddObject( GetDocID(), GEOM_IMPORT); + + //Add an Export function + Handle(GEOM_Function) aFunction = result->AddFunction( STEPPlugin_ExportDriver::GetID(), EXPORT_SHAPE ); + if( aFunction.IsNull() ) return; + + //Check if the function is set correctly + if( aFunction->GetDriverGUID() != STEPPlugin_ExportDriver::GetID() ) return; + + //Set parameters + STEPPlugin_IExport aCI( aFunction ); + aCI.SetOriginal( aRefFunction ); + aCI.SetFileName( theFileName ); + + //Perform the Export + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if( !GetSolver()->ComputeFunction( aFunction ) ) { + SetErrorCode( "Not enough space on disk, or you haven't permissions to write this directory" ); + return; + } + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode( aFail->GetMessageString() ); + return; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << "geompy.ExportSTEP(" << theOriginal << ", \"" + << theFileName.ToCString() << "\" )"; + + SetErrorCode(OK); +} + +//============================================================================= +/*! + * ImportSTEP + * Import a shape from STEP format + * \param theFileName The name of the file to import + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +STEPPlugin_IOperations::ImportSTEP( const TCollection_AsciiString& theFileName, + const bool theIsIgnoreUnits ) +{ + SetErrorCode(KO); + if( theFileName.IsEmpty() ) return NULL; + + //Add a new result object + Handle(GEOM_Object) anImported = GetEngine()->AddObject( GetDocID(), GEOM_IMPORT ); + + //Add an Import function + Handle(GEOM_Function) aFunction = + anImported->AddFunction( STEPPlugin_ImportDriver::GetID(), IMPORT_SHAPE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != STEPPlugin_ImportDriver::GetID()) return NULL; + + //Set parameters + STEPPlugin_IImport aCI( aFunction ); + aCI.SetFileName( theFileName ); + aCI.SetIsIgnoreUnits( theIsIgnoreUnits ); + + //Perform the Import + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if( !GetSolver()->ComputeFunction( aFunction ) ) { + SetErrorCode( "Import driver failed" ); + return NULL; + } + aSeq->Append(anImported); + + // Greate material groups. + MakeMaterialGroups( anImported, aSeq ); + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode( aFail->GetMessageString() ); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump pd (aFunction); + if( theIsIgnoreUnits ) + pd << aSeq << " = geompy.ImportSTEP(\"" << theFileName.ToCString() << "\", True)"; + else + pd << aSeq << " = geompy.ImportSTEP(\"" << theFileName.ToCString() << "\")"; + SetErrorCode(OK); + + return aSeq; +} + +//============================================================================= +/*! + * ReadValue + */ +//============================================================================= +TCollection_AsciiString +STEPPlugin_IOperations::ReadValue( const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theParameterName ) +{ + SetErrorCode(KO); + + TCollection_AsciiString aValue, anError; + + if (theFileName.IsEmpty() || theParameterName.IsEmpty()) return aValue; + + aValue = STEPPlugin_ImportDriver::GetValue( theFileName, theParameterName, anError ); + + if( aValue.IsEmpty() ) { + if( anError.IsEmpty() ) + anError = theFileName + " doesn't contain requested parameter"; + return aValue; + } + if (anError.IsEmpty()) + SetErrorCode(OK); + else + SetErrorCode(anError.ToCString()); + + return aValue; +} diff --git a/src/STEPPlugin/STEPPlugin_IOperations.hxx b/src/STEPPlugin/STEPPlugin_IOperations.hxx new file mode 100644 index 000000000..6d4999815 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_IOperations.hxx @@ -0,0 +1,46 @@ +// 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 +// +// File : STEPPlugin_IOperations.hxx + +#ifndef _STEPPlugin_IOperations_HXX_ +#define _STEPPlugin_IOperations_HXX_ + +// internal includes +#include "STEPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOMImpl_IBaseIEOperations.hxx" + +class STEPPLUGINENGINE_EXPORT STEPPlugin_IOperations: public GEOMImpl_IBaseIEOperations +{ +public: + STEPPlugin_IOperations( GEOM_Engine*, int ); + ~STEPPlugin_IOperations(); + + void ExportSTEP( const Handle(GEOM_Object), + const TCollection_AsciiString& ); + + Handle(TColStd_HSequenceOfTransient) ImportSTEP( const TCollection_AsciiString&, + const bool ); + + TCollection_AsciiString ReadValue( const TCollection_AsciiString&, + const TCollection_AsciiString& ); +}; + +#endif diff --git a/src/STEPPlugin/STEPPlugin_IOperations_i.cc b/src/STEPPlugin/STEPPlugin_IOperations_i.cc new file mode 100644 index 000000000..1f4ded47a --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_IOperations_i.cc @@ -0,0 +1,128 @@ +// 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 "STEPPlugin_IOperations_i.hh" +#include "STEPPlugin_IOperations.hxx" + +// KERNEL includes +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +STEPPlugin_IOperations_i::STEPPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + STEPPlugin_IOperations* theImpl ) +:GEOM_IOperations_i( thePOA, theEngine, theImpl ) +{ + MESSAGE( "STEPPlugin_IOperations_i::STEPPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +STEPPlugin_IOperations_i::~STEPPlugin_IOperations_i() +{ + MESSAGE( "STEPPlugin_IOperations_i::~STEPPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * ExportSTEP + * Export a shape to STEP format + * \param theOriginal The shape to export + * \param theFileName The name of the exported file + */ +//============================================================================= +void STEPPlugin_IOperations_i::ExportSTEP( GEOM::GEOM_Object_ptr theOriginal, + const char* theFileName ) +{ + // duplicate the original shape + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate( theOriginal ); + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(GEOM_Object) anOriginal = GetObjectImpl( theOriginal ); + if (anOriginal.IsNull()) return; + + //Export the shape to the file + GetOperations()->ExportSTEP( anOriginal, theFileName ); +} + +//============================================================================= +/*! + * ImportSTEP + * Import a shape from STEP format + * \param theFileName The name of the file to import + * \param theIsIgnoreUnits If True, file length units will be ignored (set to 'meter') + * and result model will be scaled, if its units are not meters. + * If False (default), file length units will be taken into account. + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* STEPPlugin_IOperations_i::ImportSTEP( const char* theFileName, + const bool theIsIgnoreUnits = false ) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Import the shape from the file + Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportSTEP( theFileName, theIsIgnoreUnits ); + + if( !GetOperations()->IsDone() || aHSeq.IsNull() ) + return aSeq._retn(); + + // Copy created objects. + Standard_Integer aLength = aHSeq->Length(); + aSeq->length( aLength ); + for( Standard_Integer i = 1; i <= aLength; i++ ) + aSeq[i-1] = GetObject( Handle(GEOM_Object)::DownCast( aHSeq->Value(i) ) ); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * ReadValue + */ +//============================================================================= +char* STEPPlugin_IOperations_i::ReadValue( const char* theFileName, + const char* theParameterName ) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + TCollection_AsciiString aParam = GetOperations()->ReadValue( theFileName, theParameterName ); + + return CORBA::string_dup( aParam.ToCString() ); +} + +STEPPlugin_IOperations* STEPPlugin_IOperations_i::GetOperations() +{ + return (STEPPlugin_IOperations*)GetImpl(); +} diff --git a/src/STEPPlugin/STEPPlugin_IOperations_i.hh b/src/STEPPlugin/STEPPlugin_IOperations_i.hh new file mode 100644 index 000000000..41833f822 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_IOperations_i.hh @@ -0,0 +1,53 @@ +// 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 _STEPPlugin_IOperations_i_HeaderFile +#define _STEPPlugin_IOperations_i_HeaderFile + +// idl includes +#include +#include CORBA_SERVER_HEADER( GEOM_Gen ) +#include CORBA_SERVER_HEADER( STEPPlugin ) + +// internal includes +#include "STEPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_IOperations_i.hh" + +class STEPPlugin_IOperations; + +class STEPPLUGINENGINE_EXPORT STEPPlugin_IOperations_i : + public virtual POA_GEOM::ISTEPOperations, + public virtual GEOM_IOperations_i +{ +public: + STEPPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + STEPPlugin_IOperations* theImpl ); + ~STEPPlugin_IOperations_i(); + + void ExportSTEP( GEOM::GEOM_Object_ptr, const char* ); + GEOM::ListOfGO* ImportSTEP( const char*, const bool ); + char* ReadValue( const char*, const char* ); + + STEPPlugin_IOperations* GetOperations(); +}; + +#endif diff --git a/src/STEPPlugin/STEPPlugin_ImportDriver.cxx b/src/STEPPlugin/STEPPlugin_ImportDriver.cxx new file mode 100644 index 000000000..3fb26c5cf --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_ImportDriver.cxx @@ -0,0 +1,614 @@ +// 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 "STEPPlugin_ImportDriver.hxx" +#include "STEPPlugin_IImport.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOM_Function.hxx" +#include "GEOMImpl_Types.hxx" + +// 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * GetShape() + */ +//============================================================================= + +TopoDS_Shape GetShape(const Handle(Standard_Transient) &theEnti, + const Handle(Transfer_TransientProcess) &theTP) +{ + TopoDS_Shape aResult; + Handle(Transfer_Binder) aBinder = theTP->Find(theEnti); + + if (aBinder.IsNull()) { + return aResult; + } + + aResult = TransferBRep::ShapeResult(aBinder); + + return aResult; +} + +//============================================================================= +/*! + * GetLabel() + */ +//============================================================================= + +TDF_Label GetLabel(const Handle(Standard_Transient) &theEnti, + const TDF_Label &theShapeLabel, + const TopoDS_Shape &aShape) +{ + TDF_Label aResult; + + if (theEnti->IsKind + (STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) { + // check all named shapes using iterator + TDF_ChildIDIterator anIt + (theShapeLabel, TDataStd_Name::GetID(), Standard_True); + + for (; anIt.More(); anIt.Next()) { + Handle(TDataStd_Name) nameAttr = + Handle(TDataStd_Name)::DownCast(anIt.Value()); + + if (nameAttr.IsNull()) { + continue; + } + + TDF_Label aLab = nameAttr->Label(); + Handle(TNaming_NamedShape) shAttr; + + if (aLab.FindAttribute(TNaming_NamedShape::GetID(), shAttr) && + shAttr->Get().IsEqual(aShape)) { + aResult = aLab; + } + } + } + + // create label and set shape + if (aResult.IsNull()) { + TDF_TagSource aTag; + + aResult = aTag.NewChild(theShapeLabel); + + TNaming_Builder tnBuild (aResult); + + tnBuild.Generated(aShape); + } + + return aResult; +} + +//============================================================================= +/*! + * StoreName() + */ +//============================================================================= + +void StoreName( const Handle(Standard_Transient) &theEnti, + const TopTools_IndexedMapOfShape &theIndices, + const Handle(Transfer_TransientProcess) &theTP, + const TDF_Label &theShapeLabel) +{ + Handle(TCollection_HAsciiString) aName; + + if (theEnti->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem)) || + theEnti->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem))) { + aName = Handle(StepRepr_RepresentationItem)::DownCast(theEnti)->Name(); + } else { + Handle(StepBasic_ProductDefinition) PD = + Handle(StepBasic_ProductDefinition)::DownCast(theEnti); + + if (PD.IsNull() == Standard_False) { + Handle(StepBasic_Product) Prod = PD->Formation()->OfProduct(); + aName = Prod->Name(); + } + } + + bool isValidName = false; + + if (aName.IsNull() == Standard_False) { + isValidName = true; + + if (aName->UsefullLength() < 1) { + isValidName = false; + } else if (aName->UsefullLength() == 4 && + toupper (aName->Value(1)) == 'N' && + toupper (aName->Value(2)) == 'O' && + toupper (aName->Value(3)) == 'N' && + toupper (aName->Value(4)) == 'E') { + // skip 'N0NE' name + isValidName = false; + } else { + // special check to pass names like "Open CASCADE STEP translator 6.3 1" + TCollection_AsciiString aSkipName ("Open CASCADE STEP translator"); + + if (aName->Length() >= aSkipName.Length()) { + if (aName->String().SubString + (1, aSkipName.Length()).IsEqual(aSkipName)) { + isValidName = false; + } + } + } + } + + if (isValidName) { + TCollection_ExtendedString aNameExt (aName->ToCString()); + + // find target shape + TopoDS_Shape S = GetShape(theEnti, theTP); + + if (S.IsNull()) { + return; + } + + // as PRODUCT can be included in the main shape + // several times, we look here for all iclusions. + Standard_Integer isub, nbSubs = theIndices.Extent(); + + for (isub = 1; isub <= nbSubs; isub++) { + TopoDS_Shape aSub = theIndices.FindKey(isub); + + if (aSub.IsPartner(S)) { + TDF_Label L = GetLabel(theEnti, theShapeLabel, aSub); + + // set a name + TDataStd_Name::Set(L, aNameExt); + } + } + } +} + +//============================================================================= +/*! + * StoreMaterial() + */ +//============================================================================= + +void StoreMaterial( const Handle(Standard_Transient) &theEnti, + const TopTools_IndexedMapOfShape &theIndices, + const Handle(Transfer_TransientProcess) &theTP, + const TDF_Label &theShapeLabel ) +{ + // Treat Product Definition Shape only. + Handle(StepRepr_ProductDefinitionShape) aPDS = + Handle(StepRepr_ProductDefinitionShape)::DownCast(theEnti); + Handle(StepBasic_ProductDefinition) aProdDef; + + if(aPDS.IsNull() == Standard_False) { + // Product Definition Shape ==> Product Definition + aProdDef = aPDS->Definition().ProductDefinition(); + } + + if (aProdDef.IsNull() == Standard_False) { + // Product Definition ==> Property Definition + const Interface_Graph &aGraph = theTP->Graph(); + Interface_EntityIterator aSubs = aGraph.Sharings(aProdDef); + TopoDS_Shape aShape; + + for(aSubs.Start(); aSubs.More(); aSubs.Next()) { + Handle(StepRepr_PropertyDefinition) aPropD = + Handle(StepRepr_PropertyDefinition)::DownCast(aSubs.Value()); + + if(aPropD.IsNull() == Standard_False) { + // Property Definition ==> Representation. + Interface_EntityIterator aSubs1 = aGraph.Sharings(aPropD); + + for(aSubs1.Start(); aSubs1.More(); aSubs1.Next()) { + Handle(StepRepr_PropertyDefinitionRepresentation) aPDR = + Handle(StepRepr_PropertyDefinitionRepresentation):: + DownCast(aSubs1.Value()); + + if(aPDR.IsNull() == Standard_False) { + // Property Definition ==> Material Name. + Handle(StepRepr_Representation) aRepr = aPDR->UsedRepresentation(); + + if(aRepr.IsNull() == Standard_False) { + Standard_Integer ir; + + for(ir = 1; ir <= aRepr->NbItems(); ir++) { + Handle(StepRepr_RepresentationItem) aRI = aRepr->ItemsValue(ir); + Handle(StepRepr_DescriptiveRepresentationItem) aDRI = + Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(aRI); + + if(aDRI.IsNull() == Standard_False) { + // Get shape from Product Definition + Handle(TCollection_HAsciiString) aMatName = aDRI->Name(); + + if(aMatName.IsNull() == Standard_False) { + TCollection_ExtendedString + aMatNameExt (aMatName->ToCString()); + + if (aShape.IsNull()) { + // Get the shape. + aShape = GetShape(aProdDef, theTP); + + if (aShape.IsNull()) { + return; + } + } + + // as PRODUCT can be included in the main shape + // several times, we look here for all iclusions. + Standard_Integer isub, nbSubs = theIndices.Extent(); + + for (isub = 1; isub <= nbSubs; isub++) { + TopoDS_Shape aSub = theIndices.FindKey(isub); + + if (aSub.IsPartner(aShape)) { + TDF_Label aLabel = + GetLabel(aProdDef, theShapeLabel, aSub); + + // set a name + TDataStd_Comment::Set(aLabel, aMatNameExt); + } + } + } + } + } + } + } + } + } + } + } +} + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& STEPPlugin_ImportDriver::GetID() +{ + static Standard_GUID aGUID("a25f88df-461b-45c0-ab6b-a82101fe6ce7"); + return aGUID; +} + +//======================================================================= +//function : STEPPlugin_ImportDriver +//purpose : +//======================================================================= +STEPPlugin_ImportDriver::STEPPlugin_ImportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer STEPPlugin_ImportDriver::Execute( TFunction_Logbook& log ) const +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + STEPPlugin_IImport aData( aFunction ); + + TCollection_AsciiString aFileName = aData.GetFileName().ToCString(); + bool anIsIgnoreUnits = aData.GetIsIgnoreUnits(); + TDF_Label aShapeLabel = aFunction->GetNamingEntry(); + + MESSAGE("Import STEP from file " << aFileName.ToCString() ); + + TopoDS_Shape aResShape; + TCollection_AsciiString anError; + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + STEPControl_Reader aReader; + + //VSR: 16/09/09: Convert to METERS + Interface_Static::SetCVal("xstep.cascade.unit","M"); + Interface_Static::SetIVal("read.step.ideas", 1); + Interface_Static::SetIVal("read.step.nonmanifold", 1); + + BRep_Builder B; + TopoDS_Compound compound; + B.MakeCompound(compound); + + try + { + OCC_CATCH_SIGNALS; + IFSelect_ReturnStatus status = aReader.ReadFile(aFileName.ToCString()); + if (status == IFSelect_RetDone) { + // Regard or not the model units + if( anIsIgnoreUnits ) { + // set UnitFlag to units from file + TColStd_SequenceOfAsciiString anUnitLengthNames; + TColStd_SequenceOfAsciiString anUnitAngleNames; + TColStd_SequenceOfAsciiString anUnitSolidAngleNames; + aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames); + if (anUnitLengthNames.Length() > 0) { + TCollection_AsciiString aLenUnits = anUnitLengthNames.First(); + if (aLenUnits == "millimetre") + Interface_Static::SetCVal("xstep.cascade.unit", "MM"); + else if (aLenUnits == "centimetre") + Interface_Static::SetCVal("xstep.cascade.unit", "CM"); + else if (aLenUnits == "metre" || aLenUnits.IsEmpty()) + Interface_Static::SetCVal("xstep.cascade.unit", "M"); + else if (aLenUnits == "INCH") + Interface_Static::SetCVal("xstep.cascade.unit", "INCH"); + else { + anError = "The file contains not supported units."; + } + // TODO (for other units than mm, cm, m or inch) + // else if (aLenUnits == "") + // Interface_Static::SetCVal("xstep.cascade.unit", "???"); + } + } + else { + // Need re-scale a model (set UnitFlag to 'meter') + Interface_Static::SetCVal("xstep.cascade.unit","M"); + } + + Standard_Boolean failsonly = Standard_False; + aReader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity); + + // Root transfers + Standard_Integer nbr = aReader.NbRootsForTransfer(); + aReader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity); + + for (Standard_Integer n = 1; n <= nbr; n++) { + Standard_Boolean ok = aReader.TransferRoot(n); + // Collecting resulting entities + Standard_Integer nbs = aReader.NbShapes(); + if (!ok || nbs == 0) + continue; // skip empty root + + // For a single entity + else if (nbr == 1 && nbs == 1) { + aResShape = aReader.Shape(1); + 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; + } + break; + } + + for (Standard_Integer i = 1; i <= nbs; i++) { + TopoDS_Shape aShape = aReader.Shape(i); + if (aShape.IsNull()) + continue; + else + B.Add(compound, aShape); + } + } + if( aResShape.IsNull() ) + aResShape = compound; + + // Check if any BRep entity has been read, there must be at least a vertex + if ( !TopExp_Explorer( aResShape, TopAbs_VERTEX ).More() ) + anError = "No geometrical data in the imported file."; + + // BEGIN: Store names and materials of sub-shapes from file + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aResShape, anIndices); + + 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 ie = 1; ie <= nb; ie++) { + Handle(Standard_Transient) enti = Model->Value(ie); + + // Store names. + StoreName(enti, anIndices, TP, aShapeLabel); + + // Store materials. + StoreMaterial(enti, anIndices, TP, aShapeLabel); + } + } + // END: Store names and materials + } + else { + switch (status) { + case IFSelect_RetVoid: + anError = "Nothing created or No data to process"; + break; + case IFSelect_RetError: + anError = "Error in command or input data"; + break; + case IFSelect_RetFail: + anError = "Execution was run, but has failed"; + break; + case IFSelect_RetStop: + anError = "Execution has been stopped. Quite possible, an exception was raised"; + break; + default: + break; + } + anError = "Wrong format of the imported file. Can't import file."; + aResShape.Nullify(); + } + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + anError = aFail->GetMessageString(); + aResShape.Nullify(); + } + + if( aResShape.IsNull() ) { + StdFail_NotDone::Raise( anError.ToCString() ); + return 0; + } + + aFunction->SetValue( aResShape ); + + log.SetTouched( Label() ); + + return 1; +} + +//======================================================================= +//function : MustExecute +//purpose : +//======================================================================= +Standard_Boolean STEPPlugin_ImportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool STEPPlugin_ImportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction( Label() ); + + STEPPlugin_IImport aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "ImportSTEP"; + + switch ( aType ) { + case IMPORT_SHAPE: + AddParam( theParams, "File name", aCI.GetFileName() ); + if( aCI.GetIsIgnoreUnits() ) + AddParam( theParams, "Format", "STEP_SCALE" ); + break; + default: + return false; + } + return true; +} + +TCollection_AsciiString +STEPPlugin_ImportDriver::GetValue( const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theParameterName, + TCollection_AsciiString& theError ) +{ + Handle(TCollection_HAsciiString) aValue; + + if (theParameterName != "LEN_UNITS") { + theError = theParameterName + " parameter reading is not supported by STEP plugin"; + return TCollection_AsciiString(); + } + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + STEPControl_Reader aReader; + + Interface_Static::SetCVal( "xstep.cascade.unit","M" ); + Interface_Static::SetIVal( "read.step.ideas", 1 ); + Interface_Static::SetIVal( "read.step.nonmanifold", 1 ); + + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + IFSelect_ReturnStatus status = aReader.ReadFile( theFileName.ToCString() ); + if (status == IFSelect_RetDone) { + TColStd_SequenceOfAsciiString anUnitLengthNames; + TColStd_SequenceOfAsciiString anUnitAngleNames; + TColStd_SequenceOfAsciiString anUnitSolidAngleNames; + aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames); + if (anUnitLengthNames.Length() > 0) { + aValue = new TCollection_HAsciiString( anUnitLengthNames.First() ); + /* + TCollection_AsciiString aLenUnits = anUnitLengthNames.First(); + if (aLenUnits == "millimetre") + aValue = new TCollection_HAsciiString ("MM"); + else if (aLenUnits == "centimetre") + aValue = new TCollection_HAsciiString ("CM"); + else if (aLenUnits == "metre") + aValue = new TCollection_HAsciiString ("M"); + else if (aLenUnits == "INCH") + aValue = new TCollection_HAsciiString ("INCH"); + // TODO (for other units than mm, cm, m or inch) + //else if (aLenUnits == "") + // aValue = new TCollection_HAsciiString (""); + */ + } + } + else { + theError = theFileName + " reading failed"; + } + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + theError = aFail->GetMessageString(); + } + if (!aValue.IsNull()) + return aValue->String(); + else + return TCollection_AsciiString(); +} + + +IMPLEMENT_STANDARD_HANDLE( STEPPlugin_ImportDriver, GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( STEPPlugin_ImportDriver, GEOM_BaseDriver ); diff --git a/src/STEPPlugin/STEPPlugin_ImportDriver.hxx b/src/STEPPlugin/STEPPlugin_ImportDriver.hxx new file mode 100644 index 000000000..a8c2b0cf0 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_ImportDriver.hxx @@ -0,0 +1,56 @@ +// 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 _STEPPlugin_ImportDriver_HXX +#define _STEPPlugin_ImportDriver_HXX + +// internal includes +#include "STEPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( STEPPlugin_ImportDriver, GEOM_BaseDriver ); + +class STEPPLUGINENGINE_EXPORT STEPPlugin_ImportDriver : public GEOM_BaseDriver +{ +public: + STEPPlugin_ImportDriver(); + ~STEPPlugin_ImportDriver() {}; + + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} + + virtual bool GetCreationInformation( std::string& theOperationName, + std::vector& params ); + + static + TCollection_AsciiString GetValue( const TCollection_AsciiString&, + const TCollection_AsciiString&, + TCollection_AsciiString& ); + +DEFINE_STANDARD_RTTI( STEPPlugin_ImportDriver ) +}; + +#endif // _STEPPlugin_ImportDriver_HXX diff --git a/src/STEPPlugin/STEPPlugin_OperationsCreator.cxx b/src/STEPPlugin/STEPPlugin_OperationsCreator.cxx new file mode 100644 index 000000000..d3d31a18d --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_OperationsCreator.cxx @@ -0,0 +1,74 @@ +// 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 "STEPPlugin_OperationsCreator.hxx" +#include "STEPPlugin_IOperations_i.hh" +#include "STEPPlugin_IOperations.hxx" +#include "STEPPlugin_ExportDriver.hxx" +#include "STEPPlugin_ImportDriver.hxx" +#include "STEPPlugin_IECallBack.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOMImpl_IECallBack.hxx" + +// OCCT includes +#include + +std::map STEPPlugin_OperationsCreator::_mapOfOperations; + +STEPPlugin_OperationsCreator::STEPPlugin_OperationsCreator() +{ + // Register drivers + TFunction_DriverTable::Get()->AddDriver( STEPPlugin_ExportDriver::GetID(), + new STEPPlugin_ExportDriver() ); + TFunction_DriverTable::Get()->AddDriver( STEPPlugin_ImportDriver::GetID(), + new STEPPlugin_ImportDriver() ); + + // Register callback + STEPPlugin_IECallBack* callback = new STEPPlugin_IECallBack(); + GEOMImpl_IECallBack::Register( "STEP", callback ); + GEOMImpl_IECallBack::Register( "STEP_SCALE", callback ); +} + +STEPPlugin_OperationsCreator::~STEPPlugin_OperationsCreator() +{ +} + +GEOM_IOperations_i* STEPPlugin_OperationsCreator::Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ) +{ + Unexpect aCatch( SALOME_SalomeException ); + MESSAGE( "STEPPlugin_OperationsCreator::Create" ); + return new STEPPlugin_IOperations_i( thePOA, theEngine, get( theGenImpl, theStudyId ) ); +} + +STEPPlugin_IOperations* STEPPlugin_OperationsCreator::get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ) +{ + if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) + _mapOfOperations[theStudyId] = new STEPPlugin_IOperations( theGenImpl, theStudyId ); + return _mapOfOperations[theStudyId]; +} diff --git a/src/STEPPlugin/STEPPlugin_OperationsCreator.hxx b/src/STEPPlugin/STEPPlugin_OperationsCreator.hxx new file mode 100755 index 000000000..5e3cb9575 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_OperationsCreator.hxx @@ -0,0 +1,58 @@ +// 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 _GEOM_STEPPlugin_OperationsCreator_HXX_ +#define _GEOM_STEPPlugin_OperationsCreator_HXX_ + +// internal includes +#include "STEPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Gen_i.hh" + +// C++ includes +#include + +class STEPPlugin_IOperations; + +//===================================================================== +// Operations creator +//===================================================================== +class STEPPLUGINENGINE_EXPORT STEPPlugin_OperationsCreator : public GEOM_GenericOperationsCreator +{ +public: + STEPPlugin_OperationsCreator(); + ~STEPPlugin_OperationsCreator(); + + GEOM_IOperations_i* Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ); + +private: + static STEPPlugin_IOperations* get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ); + +private: + static std::map _mapOfOperations; + + friend class STEPPlugin_IECallBack; +}; + +#endif diff --git a/src/STEPPlugin/STEPPlugin_msg_en.ts b/src/STEPPlugin/STEPPlugin_msg_en.ts new file mode 100644 index 000000000..d24fc9014 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_msg_en.ts @@ -0,0 +1,51 @@ + + + + + @default + + MEN_EXPORTSTEP + STEP + + + TOP_EXPORTSTEP + Export STEP + + + STB_EXPORTSTEP + Export STEP + + + MEN_IMPORTSTEP + STEP + + + TOP_IMPORTSTEP + Import STEP + + + STB_IMPORTSTEP + Import STEP + + + + STEPPlugin_GUI + + STEP_FILES + STEP Files ( *.step *.stp ) + + + EXPORT_TITLE + Export STEP + + + IMPORT_TITLE + Import STEP + + + SCALE_DIMENSIONS + Take into account the units (%1) embedded to the file? +Ignoring units will cause model scaling (as dimensions are supposed to be specified in meters). + + + diff --git a/src/STEPPlugin/STEPPlugin_msg_fr.ts b/src/STEPPlugin/STEPPlugin_msg_fr.ts new file mode 100644 index 000000000..077fc096f --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_msg_fr.ts @@ -0,0 +1,51 @@ + + + + + @default + + MEN_EXPORTSTEP + STEP + + + TOP_EXPORTSTEP + Exporter STEP + + + STB_EXPORTSTEP + Exporter STEP + + + MEN_IMPORTSTEP + STEP + + + TOP_IMPORTSTEP + Importer STEP + + + STB_IMPORTSTEP + Importer STEP + + + + STEPPlugin_GUI + + STEP_FILES + STEP Fichiers ( *.step *.stp ) + + + EXPORT_TITLE + Exporter STEP + + + IMPORT_TITLE + Importer STEP + + + SCALE_DIMENSIONS + Voulez-vous prendre les unités du fichier (%1) en considération? +Sinon le modèle sera mis à l'échelle GEOM (unités interprétées comme des mètres). + + + diff --git a/src/STEPPlugin/STEPPlugin_msg_ja.ts b/src/STEPPlugin/STEPPlugin_msg_ja.ts new file mode 100644 index 000000000..459ee3442 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_msg_ja.ts @@ -0,0 +1,50 @@ + + + + + @default + + MEN_EXPORTSTEP + STEP + + + TOP_EXPORTSTEP + Export STEP + + + STB_EXPORTSTEP + Export STEP + + + MEN_IMPORTSTEP + STEP + + + TOP_IMPORTSTEP + Import STEP + + + STB_IMPORTSTEP + Import STEP + + + + STEPPlugin_GUI + + STEP_FILES + STEP Files ( *.step *.stp ) + + + EXPORT_TITLE + Export STEP + + + IMPORT_TITLE + Import STEP + + + SCALE_DIMENSIONS + インポートしたファイルの単位をミリメートルからメートルに変換しますか?いいえを選んだ場合、メートル単位として解釈します。 + + + diff --git a/src/STLExport/CMakeLists.txt b/src/STLExport/CMakeLists.txt deleted file mode 100755 index ce8046fb7..000000000 --- a/src/STLExport/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2012-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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIR} - ${KERNEL_INCLUDE_DIRS} - ) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKSTL} - ${KERNEL_SALOMELocalTrace} - ) - -# --- sources --- - -SET(STLExport_SOURCES - STLExport.cxx - ) - -# --- rules --- - -ADD_LIBRARY(STLExport ${STLExport_SOURCES}) -TARGET_LINK_LIBRARIES(STLExport ${_link_LIBRARIES}) -INSTALL(TARGETS STLExport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) - - diff --git a/src/STLExport/STLExport.cxx b/src/STLExport/STLExport.cxx deleted file mode 100644 index dc0dfb631..000000000 --- a/src/STLExport/STLExport.cxx +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// - -// File: STLExport.cxx -// Created: Wed May 19 14:53:52 2004 -// Author: Pavel TELKOV -// -// -#include "utilities.h" - -#include - -#include -#include - -#ifdef WIN32 -# if defined STLEXPORT_EXPORTS || defined STLExport_EXPORTS -# define STLEXPORT_EXPORT __declspec( dllexport ) -# else -# define STLEXPORT_EXPORT __declspec( dllimport ) -# endif -#else -# define STLEXPORT_EXPORT -#endif - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ - STLEXPORT_EXPORT - int Export(const TopoDS_Shape& theShape, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName) - { - MESSAGE("Export STL into file " << theFileName.ToCString()); - - try - { - StlAPI_Writer aWriter; - bool aIsASCIIMode; - aIsASCIIMode = (theFormatName.IsEqual("STL_ASCII")) ? true : false; - aWriter.ASCIIMode() = aIsASCIIMode; - aWriter.Write(theShape, theFileName.ToCString()) ; - return 1; - } - catch(Standard_Failure) - { - //THROW_SALOME_CORBA_EXCEPTION("Exception catched in STLExport", SALOME::BAD_PARAM); - } - return 0; - } -} diff --git a/src/STLImport/CMakeLists.txt b/src/STLImport/CMakeLists.txt deleted file mode 100755 index 54750b83d..000000000 --- a/src/STLImport/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (C) 2012-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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIR} - ${KERNEL_INCLUDE_DIRS} - ) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKSTL} - ${KERNEL_SALOMELocalTrace} - ${CAS_TKTopAlgo} - ${CAS_TKBRep} - ${CAS_TKG3d} - ) - -# --- sources --- - -SET(STLImport_SOURCES - STLImport.cxx - ) - -# --- rules --- - -ADD_LIBRARY(STLImport ${STLImport_SOURCES}) -TARGET_LINK_LIBRARIES(STLImport ${_link_LIBRARIES}) -INSTALL(TARGETS STLImport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) - - diff --git a/src/STLImport/STLImport.cxx b/src/STLImport/STLImport.cxx deleted file mode 100755 index 0b4189e0a..000000000 --- a/src/STLImport/STLImport.cxx +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// - -// File: STLImport.cxx -// Author: Sergey KHROMOV - - -#include "utilities.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#ifdef WIN32 - #if defined STLIMPORT_EXPORTS || defined STLImport_EXPORTS - #define STLIMPORT_EXPORT __declspec( dllexport ) - #else - #define STLIMPORT_EXPORT __declspec( dllimport ) - #endif -#else - #define STLIMPORT_EXPORT -#endif - - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ -STLIMPORT_EXPORT - TopoDS_Shape Import (const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& /*theFormatName*/, - TCollection_AsciiString& theError, - const TDF_Label&) - { - MESSAGE("Import STL from file " << theFileName.ToCString()); - - StlAPI_Reader aReader; - TopoDS_Shape aShape; - - aReader.Read(aShape, theFileName.ToCString()); - - if (aShape.IsNull()) { - theError = "STL Import failed"; - } else { - // Fix the orientation of closed shell or solid. - if (BRep_Tool::IsClosed(aShape)) { - TopAbs_ShapeEnum aType = aShape.ShapeType(); - - if (aType == TopAbs_SHELL || aType == TopAbs_SOLID) { - TopoDS_Solid aSolid; - - if (aType == TopAbs_SHELL) { - // Create a solid. - BRep_Builder aBuilder; - - aBuilder.MakeSolid(aSolid); - aBuilder.Add(aSolid, aShape); - } else { - aSolid = TopoDS::Solid(aShape); - } - - // Classify infinite point against solid. - BRepClass3d_SolidClassifier aClassifier(aSolid); - - aClassifier.PerformInfinitePoint(Precision::Confusion()); - - if (aClassifier.State() == TopAbs_IN) { - // The shape is inverted. Reverse it. - aShape.Reverse(); - } - } - } - } - - return aShape; - } -} diff --git a/src/STLPlugin/CMakeLists.txt b/src/STLPlugin/CMakeLists.txt new file mode 100644 index 000000000..0b9420c3f --- /dev/null +++ b/src/STLPlugin/CMakeLists.txt @@ -0,0 +1,149 @@ +# 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 +# + +IF(SALOME_BUILD_GUI) + INCLUDE(UseQt4Ext) + INCLUDE(${QT_USE_FILE}) +ENDIF() + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} + ${KERNEL_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR}/idl + ${PROJECT_SOURCE_DIR}/src/GEOMAlgo + ${PROJECT_SOURCE_DIR}/src/GEOM + ${PROJECT_SOURCE_DIR}/src/GEOMImpl + ${PROJECT_SOURCE_DIR}/src/GEOM_I + ${PROJECT_SOURCE_DIR}/src/GEOMClient + ${PROJECT_SOURCE_DIR}/src/GEOMUtils + ) + +IF(SALOME_BUILD_GUI) + INCLUDE_DIRECTORIES( + ${QT_INCLUDE_DIRS} + ${GUI_INCLUDE_DIRS} + ${PROJECT_SOURCE_DIR}/src/OBJECT + ${PROJECT_SOURCE_DIR}/src/GEOMGUI + ${PROJECT_SOURCE_DIR}/src/GEOMBase + ) +ENDIF() + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${CAS_DEFINITIONS} + ) + +IF(SALOME_BUILD_GUI) +ADD_DEFINITIONS( + ${QT_DEFINITIONS} + ) +ENDIF() + +# libraries to link to +SET(_link_engine_LIBRARIES + ${CAS_TKSTL} + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + SalomeIDLGEOM + SalomeIDLSTLPlugin + GEOMEngine + GEOMClient + ) + +IF(SALOME_BUILD_GUI) + SET(_link_gui_LIBRARIES + SalomeIDLSTLPlugin + GEOMObject + GEOM + GEOMBase + ) +ENDIF() + + +# --- headers --- + +SET(STLPluginEngine_HEADERS + STLPlugin_IOperations_i.hh + STLPlugin_Engine.hxx + STLPlugin_OperationsCreator.hxx + STLPlugin_IOperations.hxx + STLPlugin_IExport.hxx + STLPlugin_IImport.hxx + STLPlugin_ImportDriver.hxx + STLPlugin_ExportDriver.hxx + STLPlugin_IECallBack.hxx + ) + +IF(SALOME_BUILD_GUI) + # header files / to be processed by moc + SET(_moc_HEADERS + STLPlugin_GUI.h + STLPlugin_ExportDlg.h + ) +ENDIF() + +# --- sources --- + +IF(SALOME_BUILD_GUI) + # sources / moc wrappings + QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) + + SET(STLPluginGUI_SOURCES + STLPlugin_GUI.cxx + STLPlugin_ExportDlg.cxx + ${_moc_SOURCES} + ) +ENDIF() + +SET(STLPluginEngine_SOURCES + STLPlugin_Engine.cxx + STLPlugin_OperationsCreator.cxx + STLPlugin_IOperations_i.cc + STLPlugin_IOperations.cxx + STLPlugin_ExportDriver.cxx + STLPlugin_ImportDriver.cxx + STLPlugin_IECallBack.cxx + ) + +# resource files / to be processed by lrelease +SET(STLPlugin_RESOURCES + STLPlugin_msg_en.ts + STLPlugin_msg_fr.ts + STLPlugin_msg_ja.ts + ) + +# --- rules --- + +ADD_LIBRARY(STLPluginEngine ${STLPluginEngine_SOURCES}) +TARGET_LINK_LIBRARIES(STLPluginEngine ${_link_engine_LIBRARIES}) +INSTALL(TARGETS STLPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +IF(SALOME_BUILD_GUI) + ADD_LIBRARY(STLPluginGUI ${STLPluginGUI_SOURCES}) + TARGET_LINK_LIBRARIES(STLPluginGUI ${_link_gui_LIBRARIES}) + INSTALL(TARGETS STLPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + + QT4_INSTALL_TS_RESOURCES("${STLPlugin_RESOURCES}" "${SALOME_GEOM_INSTALL_RES_DATA}") +ENDIF() + + +INSTALL(FILES ${STLPluginEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/STLPlugin/STLPlugin_Engine.cxx b/src/STLPlugin/STLPlugin_Engine.cxx new file mode 100644 index 000000000..49fb94c80 --- /dev/null +++ b/src/STLPlugin/STLPlugin_Engine.cxx @@ -0,0 +1,31 @@ +// 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 "STLPlugin_Engine.hxx" +#include "STLPlugin_OperationsCreator.hxx" + +extern "C" +{ + STLPLUGINENGINE_EXPORT + GEOM_GenericOperationsCreator* GetOperationsCreator() + { + return new STLPlugin_OperationsCreator(); + } +} diff --git a/src/STLPlugin/STLPlugin_Engine.hxx b/src/STLPlugin/STLPlugin_Engine.hxx new file mode 100755 index 000000000..df3244fa2 --- /dev/null +++ b/src/STLPlugin/STLPlugin_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 _STLPLUGIN_ENGINE_HXX_ +#define _STLPLUGIN_ENGINE_HXX_ + +#ifdef WIN32 + #if defined STLPLUGINENGINE_EXPORTS || defined STLPluginEngine_EXPORTS + #define STLPLUGINENGINE_EXPORT __declspec( dllexport ) + #else + #define STLPLUGINENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define STLPLUGINENGINE_EXPORT +#endif + +#endif diff --git a/src/STLPlugin/STLPlugin_ExportDlg.cxx b/src/STLPlugin/STLPlugin_ExportDlg.cxx new file mode 100644 index 000000000..8d16f234e --- /dev/null +++ b/src/STLPlugin/STLPlugin_ExportDlg.cxx @@ -0,0 +1,196 @@ +// 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 "STLPlugin_ExportDlg.h" + +// GUI includes +#include +#include +#include + +#include +#include +#include + +// GEOM includes +#include "GEOMBase.h" +#include "GEOM_Constants.h" + +// OCC includes +#include + +// QT includes +#include +#include +#include +#include +#include + +//================================================================================= +// Constructor +//================================================================================= +STLPlugin_ExportDlg::STLPlugin_ExportDlg( const Handle(SALOME_InteractiveObject)& io, QWidget* parent ) +: SUIT_FileDlg( parent, false, true, true ) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + + QLabel* deflectionLabel = new QLabel( tr( "DEFLECTION" ), this ); + + QWidget* options = new QWidget( this ); + QHBoxLayout* optionsLayout = new QHBoxLayout( options ); + optionsLayout->setMargin( 0 ); + optionsLayout->setSpacing( 5 ); + + myDeflectionSB = new SalomeApp_DoubleSpinBox( options ); + int aPrecision = resMgr->integerValue( "Geometry", "parametric_precision", 6 ); + myDeflectionSB->setAcceptNames( false ); + myDeflectionSB->setPrecision( aPrecision ); + myDeflectionSB->setDecimals( aPrecision ); + myDeflectionSB->setRange( GEOM::minDeflection(), 1.0 ); + myDeflectionSB->setSingleStep( 1.0e-04 ); + + myModeCB = new QCheckBox( tr( "RELATIVE" ), options ); + + myFormatCB = new QCheckBox( tr( "ASCII" ) ); + + optionsLayout->addWidget( myDeflectionSB ); + optionsLayout->addWidget( myModeCB ); + optionsLayout->addWidget( myFormatCB ); + + layout()->addWidget( deflectionLabel ); + layout()->addWidget( options ); + + myShapeSize = getShapeSize( io ); + + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Study* study = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + int mgrId = app->activeViewManager()->getGlobalId(); + QVariant v = study->getObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Deflection ), QVariant() ); + double deflection = v.isValid() ? v.toDouble() : SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "deflection_coef", 0.001 ); + + myDeflectionSB->setValue( deflection ); + myModeCB->setChecked( true ); + myFormatCB->setChecked( true ); + + connect( myModeCB, SIGNAL( clicked ( bool ) ), this, SLOT( modeChanged() ) ); +} + +//================================================================================= +// Destructor +//================================================================================= +STLPlugin_ExportDlg::~STLPlugin_ExportDlg() +{ +} + +//================================================================================= +// modeChanged +//================================================================================= +void STLPlugin_ExportDlg::modeChanged() +{ + if ( myModeCB->isChecked() ) { + double deflection = myDeflectionSB->value() / myShapeSize; + deflection = ( deflection > 1.0 ) ? 1.0 : deflection; + myDeflectionSB->setRange( GEOM::minDeflection(), 1.0 ); + myDeflectionSB->setValue( deflection ); + } + else { + double deflection = myDeflectionSB->value() * myShapeSize; + myDeflectionSB->setRange( GEOM::minDeflection(), 10000.0 ); + myDeflectionSB->setValue( deflection ); + } +} + +//================================================================================= +// getShapeSize +//================================================================================= +double STLPlugin_ExportDlg::getShapeSize( const Handle(SALOME_InteractiveObject)& io ) +{ + TopoDS_Shape shape; + GEOM::GEOM_Object_var obj = GEOMBase::ConvertIOinGEOMObject( io ); + GEOMBase::GetShape( obj, shape, TopAbs_SHAPE ); + Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; + Bnd_Box bnd; + BRepBndLib::Add( shape, bnd ); + bnd.Get( xmin, ymin, zmin, xmax, ymax, zmax ); + double xd = fabs( xmax-xmin ); + double yd = fabs( ymax-ymin ); + double zd = fabs( zmax-zmin ); + return std::max( std::max ( xd, yd ), zd ); +} + +//================================================================================= +// isAscii +//================================================================================= +bool STLPlugin_ExportDlg::isAscii() const +{ + return myFormatCB->isChecked(); +} + +//================================================================================= +// getDeflection +//================================================================================= +double STLPlugin_ExportDlg::getDeflection() const +{ + return myDeflectionSB->value(); +} + +//================================================================================= +// isDeflectionRelative +//================================================================================= +bool STLPlugin_ExportDlg::isDeflectionRelative() const +{ + return myModeCB->isChecked(); +} + +//================================================================================= +// getFileName +//================================================================================= +QString STLPlugin_ExportDlg::getFileName( const Handle(SALOME_InteractiveObject)& io, + const QString& filters, const QString& caption, + QWidget* parent, bool& isAscii, + double& deflection, bool& isRelative ) +{ + QStringList fls = filters.split( ";;", QString::SkipEmptyParts ); + + QString tmpfilename = io->getName(); + tmpfilename = tmpfilename.simplified(); + tmpfilename = tmpfilename.replace( QRegExp( "\\*" ), "" ).replace( QRegExp( "\\?" ), "" ); + + STLPlugin_ExportDlg fd( io, parent ); + fd.setFileMode( AnyFile ); + fd.setFilters( fls ); + fd.setWindowTitle( caption ); + if ( !tmpfilename.isEmpty() ) + fd.processPath( tmpfilename ); + + QString filename; + + if ( fd.exec() == QDialog::Accepted ) { + filename = fd.selectedFile(); + isAscii = fd.isAscii(); + deflection = fd.getDeflection(); + isRelative = fd.isDeflectionRelative(); + } + + QApplication::processEvents(); + + return filename; +} + diff --git a/src/STLPlugin/STLPlugin_ExportDlg.h b/src/STLPlugin/STLPlugin_ExportDlg.h new file mode 100644 index 000000000..e79722e1a --- /dev/null +++ b/src/STLPlugin/STLPlugin_ExportDlg.h @@ -0,0 +1,62 @@ +// 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 STLPlugin_ExportDlg_H +#define STLPlugin_ExportDlg_H + +#include +#include + +class QCheckBox; +class SalomeApp_DoubleSpinBox; + +class STLPlugin_ExportDlg: public SUIT_FileDlg +{ + Q_OBJECT + +public: + STLPlugin_ExportDlg( const Handle(SALOME_InteractiveObject)& io, QWidget* parent ); + ~STLPlugin_ExportDlg(); + + bool isAscii() const; + double getDeflection() const; + bool isDeflectionRelative() const; + + static QString getFileName( const Handle(SALOME_InteractiveObject)& io, + const QString& filters, + const QString& caption, + QWidget* parent, + bool& isAscii, + double& deflection, + bool& isRelative ); + +private slots: + void modeChanged(); + +private: + static double getShapeSize( const Handle(SALOME_InteractiveObject)& io ); + +private: + SalomeApp_DoubleSpinBox* myDeflectionSB; + QCheckBox* myModeCB; + QCheckBox* myFormatCB; + double myShapeSize; +}; + +#endif // STLPlugin_ExportDlg_H diff --git a/src/STLPlugin/STLPlugin_ExportDriver.cxx b/src/STLPlugin/STLPlugin_ExportDriver.cxx new file mode 100644 index 000000000..f800a7d0b --- /dev/null +++ b/src/STLPlugin/STLPlugin_ExportDriver.cxx @@ -0,0 +1,128 @@ +// 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 "STLPlugin_ExportDriver.hxx" +#include "STLPlugin_IExport.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOM_Function.hxx" + +// OOCT includes +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& STLPlugin_ExportDriver::GetID() +{ + static Standard_GUID aGUID("88678a6a-885c-477c-b90b-51934572c61d"); + return aGUID; +} + +//======================================================================= +//function : STLPlugin_ExportDriver +//purpose : +//======================================================================= +STLPlugin_ExportDriver::STLPlugin_ExportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer STLPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + STLPlugin_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(); + double aDeflection = aData.GetDeflection(); + bool anIsASCII = aData.GetIsASCII(); + bool anIsRelative = aData.GetIsRelative(); + + MESSAGE( "Export STL into file " << aFileName ); + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + try + { + StlAPI_Writer aWriter; + // set relative mode on false for using custom deflection coefficient + aWriter.RelativeMode( ) = anIsRelative; + aWriter.ASCIIMode() = anIsASCII; + if( anIsRelative ) + aWriter.SetCoefficient( aDeflection ); + else + aWriter.SetDeflection( aDeflection ); + BRepBuilderAPI_Copy aCopy( aShape, Standard_False ); + aWriter.Write( aCopy.Shape(), aFileName.ToCString() ); + log.SetTouched( Label() ); + return 1; + } + catch( Standard_Failure ) + { + //THROW_SALOME_CORBA_EXCEPTION("Exception catched in ExportSTL", SALOME::BAD_PARAM); + } + return 0; +} + +//======================================================================= +//function : MustExecute +//purpose : +//======================================================================= +Standard_Boolean STLPlugin_ExportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ +bool STLPlugin_ExportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + return false; +} + +IMPLEMENT_STANDARD_HANDLE( STLPlugin_ExportDriver,GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( STLPlugin_ExportDriver,GEOM_BaseDriver ); diff --git a/src/STLPlugin/STLPlugin_ExportDriver.hxx b/src/STLPlugin/STLPlugin_ExportDriver.hxx new file mode 100644 index 000000000..4726a16d3 --- /dev/null +++ b/src/STLPlugin/STLPlugin_ExportDriver.hxx @@ -0,0 +1,51 @@ +// 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 _STLPlugin_ExportDriver_HXX +#define _STLPlugin_ExportDriver_HXX + +// internal includes +#include "STLPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( STLPlugin_ExportDriver, GEOM_BaseDriver ); + +class STLPLUGINENGINE_EXPORT STLPlugin_ExportDriver : public GEOM_BaseDriver +{ +public: + STLPlugin_ExportDriver(); + ~STLPlugin_ExportDriver() {}; + + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} + + virtual bool GetCreationInformation( std::string& theOperationName, + std::vector& params ); + +DEFINE_STANDARD_RTTI( STLPlugin_ExportDriver ) +}; + +#endif // _STLPlugin_ExportDriver_HXX diff --git a/src/STLPlugin/STLPlugin_GUI.cxx b/src/STLPlugin/STLPlugin_GUI.cxx new file mode 100644 index 000000000..d0ee88ef8 --- /dev/null +++ b/src/STLPlugin/STLPlugin_GUI.cxx @@ -0,0 +1,269 @@ +// 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 "STLPlugin_GUI.h" +#include "STLPlugin_ExportDlg.h" + +// GUI includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// GEOM includes +#include "GeometryGUI.h" +#include "GEOM_Operation.h" +#include "GEOMBase.h" +#include "GEOM_Displayer.h" + +#include +#include CORBA_SERVER_HEADER(STLPlugin) + +//======================================================================= +// function : STLPlugin_GUI() +// purpose : Constructor +//======================================================================= +STLPlugin_GUI::STLPlugin_GUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) +{ +} + +//======================================================================= +// function : ~STLPlugin_GUI +// purpose : Destructor +//======================================================================= +STLPlugin_GUI::~STLPlugin_GUI() +{ +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool STLPlugin_GUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) +{ + QString cmd; + switch ( theCommandID ) { + case 1: + cmd = "Export_STL"; break; + case 2: + cmd = "Import_STL"; break; + default: + break; + } + return OnGUIEvent( cmd, parent ); +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool STLPlugin_GUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) +{ + bool result = false; + + if( theCommandID == "Export_STL" ) { + result = exportSTL( parent ); + } + else if (theCommandID == "Import_STL") { + result = importSTL( parent ); + } + else { + getGeometryGUI()->getApp()->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) ); + } + + return true; +} + +//======================================================================= +// function : importSTL +// purpose : +//======================================================================= +bool STLPlugin_GUI::importSTL( SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); + if ( !study ) return false; + + SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STLPluginEngine" ); + GEOM::ISTLOperations_var stlOp = GEOM::ISTLOperations::_narrow( op ); + if ( CORBA::is_nil( stlOp ) ) return false; + + QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), + tr( "STL_FILES" ), + tr( "IMPORT_TITLE" ), + parent ); + if ( fileNames.count() > 0 ) + { + QStringList entryList; + QStringList errors; + + foreach( QString fileName, fileNames ) + { + SUIT_OverrideCursor wc; + GEOM_Operation transaction( app, stlOp.in() ); + + try + { + app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( fileName ) ); + transaction.start(); + GEOM::ListOfGO_var result = stlOp->ImportSTL( fileName.toUtf8().constData() ); + if ( result->length() > 0 && stlOp->IsDone() ) + { + GEOM::GEOM_Object_var main = result[0]; + QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) ); + SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy, + SALOMEDS::SObject::_nil(), + main.in(), + publishName.toUtf8().constData() ); + + entryList.append( so->GetID() ); + transaction.commit(); + GEOM_Displayer( study ).Display( main.in() ); + } + else + { + transaction.abort(); + errors.append( QString( "%1 : %2" ).arg( fileName ).arg( stlOp->GetErrorCode() ) ); + } + } + catch( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + } + } + getGeometryGUI()->updateObjBrowser( true ); + app->browseObjects( entryList ); + + if ( errors.count() > 0 ) + { + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + } + } + return fileNames.count() > 0; +} + +//======================================================================= +// function : exportSTL +// purpose : +//======================================================================= +bool STLPlugin_GUI::exportSTL( SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); + if ( !study ) return false; + + SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STLPluginEngine" ); + GEOM::ISTLOperations_var stlOp = GEOM::ISTLOperations::_narrow( op ); + if ( CORBA::is_nil( stlOp ) ) return false; + + LightApp_SelectionMgr* sm = app->selectionMgr(); + if ( !sm ) return false; + + SALOME_ListIO selectedObjects; + sm->selectedObjects( selectedObjects ); + bool ok = false; + + SALOME_ListIteratorOfListIO it( selectedObjects ); + for ( ; it.More(); it.Next() ) + { + Handle(SALOME_InteractiveObject) io = it.Value(); + GEOM::GEOM_Object_var obj = GEOMBase::ConvertIOinGEOMObject( io ); + + if ( CORBA::is_nil( obj ) ) continue; + + bool isASCII = false; + double deflection = 0.; + bool isRelative = false; + QString fileName = STLPlugin_ExportDlg::getFileName( io, + tr( "STL_FILES" ), + tr( "EXPORT_TITLE" ), + parent, + isASCII, + deflection, + isRelative ); + + if ( fileName.isEmpty() ) + return false; + + SUIT_OverrideCursor wc; + + GEOM_Operation transaction( app, stlOp.in() ); + + try + { + app->putInfo( tr( "GEOM_PRP_EXPORT" ).arg( fileName ) ); + transaction.start(); + + stlOp->ExportSTL( obj, fileName.toUtf8().constData(), isASCII, deflection, isRelative ); + + if ( stlOp->IsDone() ) + { + transaction.commit(); + } + else + { + transaction.abort(); + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_PRP_ABORT" ) + "\n" + tr( stlOp->GetErrorCode() ) ); + return false; + } + } + catch ( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + return false; + } + ok = true; + } + + if ( !ok ) + { + SUIT_MessageBox::warning( parent, + tr( "WRN_WARNING" ), + tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) ); + } + return ok; +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ +#ifdef WIN32 + __declspec( dllexport ) +#endif + GEOMGUI* GetLibGUI( GeometryGUI* parent ) + { + return new STLPlugin_GUI( parent ); + } +} diff --git a/src/STLPlugin/STLPlugin_GUI.h b/src/STLPlugin/STLPlugin_GUI.h new file mode 100644 index 000000000..061afb986 --- /dev/null +++ b/src/STLPlugin/STLPlugin_GUI.h @@ -0,0 +1,40 @@ +// 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 STLPlugin_GUI_H +#define STLPlugin_GUI_H + +#include "GEOMPluginGUI.h" + +class STLPlugin_GUI: public GEOMPluginGUI +{ + Q_OBJECT +public: + STLPlugin_GUI( GeometryGUI* parent ); + ~STLPlugin_GUI(); + + bool OnGUIEvent( int commandId, SUIT_Desktop* ); + bool OnGUIEvent( const QString&, SUIT_Desktop* ); + +private: + bool importSTL( SUIT_Desktop* ); + bool exportSTL( SUIT_Desktop* ); +}; + +#endif // STLPlugin_GUI_H diff --git a/src/STLPlugin/STLPlugin_IECallBack.cxx b/src/STLPlugin/STLPlugin_IECallBack.cxx new file mode 100755 index 000000000..14d365cc1 --- /dev/null +++ b/src/STLPlugin/STLPlugin_IECallBack.cxx @@ -0,0 +1,75 @@ +// 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 "STLPlugin_IECallBack.hxx" +#include "STLPlugin_IOperations.hxx" +#include "STLPlugin_OperationsCreator.hxx" + +//============================================================================= +/*! + * constructor + */ +//============================================================================= +STLPlugin_IECallBack::STLPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +STLPlugin_IECallBack::~STLPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * Export + */ +//============================================================================= +bool +STLPlugin_IECallBack::Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ) +{ + STLPlugin_IOperations* aPluginOperations = STLPlugin_OperationsCreator::get( GetEngine(), theDocId ); + bool anIsASCII = ( theFormatName == "STL_Bin") ? false : true; + const double aDeflection = 0.001; + const bool anIsRelative = true; + aPluginOperations->ExportSTL( theOriginal, theFileName, anIsASCII, aDeflection, anIsRelative ); + return true; +} + +//============================================================================= +/*! + * Import + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +STLPlugin_IECallBack::Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ) +{ + STLPlugin_IOperations* aPluginOperations = STLPlugin_OperationsCreator::get( GetEngine(), theDocId ); + return aPluginOperations->ImportSTL( theFileName ); +} + diff --git a/src/STLPlugin/STLPlugin_IECallBack.hxx b/src/STLPlugin/STLPlugin_IECallBack.hxx new file mode 100644 index 000000000..a833ced7f --- /dev/null +++ b/src/STLPlugin/STLPlugin_IECallBack.hxx @@ -0,0 +1,50 @@ +// 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 _STLPlugin_IECallBack_HXX_ +#define _STLPlugin_IECallBack_HXX_ + +// internal includes +#include "STLPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Object.hxx" +#include "GEOMImpl_IECallBack.hxx" + +// OCC includes +#include + +class STLPLUGINENGINE_EXPORT STLPlugin_IECallBack : public GEOMImpl_IECallBack +{ +public: + STLPlugin_IECallBack(); + ~STLPlugin_IECallBack(); + + virtual bool Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ); + + virtual + Handle(TColStd_HSequenceOfTransient) Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ); +}; + +#endif diff --git a/src/STLPlugin/STLPlugin_IExport.hxx b/src/STLPlugin/STLPlugin_IExport.hxx new file mode 100644 index 000000000..8c2573d82 --- /dev/null +++ b/src/STLPlugin/STLPlugin_IExport.hxx @@ -0,0 +1,66 @@ +// 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 _STLPlugin_IExport_HXX_ +#define _STLPlugin_IExport_HXX_ + +#include "GEOM_Function.hxx" + +#define EXPORTSTL_ARG_ORIGINAL 1 +#define EXPORTSTL_ARG_FILENAME 2 +#define EXPORTSTL_ARG_DEFLECTION 3 +#define EXPORTSTL_ARG_ISASCII 4 +#define EXPORTSTL_ARG_ISRELATIVE 5 + +class STLPlugin_IExport +{ +public: + STLPlugin_IExport( Handle(GEOM_Function) theFunction ) + : _func(theFunction) {} + + void SetOriginal( Handle( GEOM_Function ) theOriginal) + { _func->SetReference( EXPORTSTL_ARG_ORIGINAL, theOriginal ); } + Handle( GEOM_Function ) GetOriginal() + { return _func->GetReference( EXPORTSTL_ARG_ORIGINAL ); } + + void SetFileName( const TCollection_AsciiString& theFileName ) + { _func->SetString( EXPORTSTL_ARG_FILENAME, theFileName ); } + TCollection_AsciiString GetFileName() + { return _func->GetString( EXPORTSTL_ARG_FILENAME ); } + + void SetIsASCII( bool theIsASCII ) + { _func->SetInteger( EXPORTSTL_ARG_ISASCII, int( theIsASCII ) ); } + bool GetIsASCII() + { return bool( _func->GetInteger( EXPORTSTL_ARG_ISASCII ) ); } + + void SetIsRelative( bool theIsRelative ) + { _func->SetInteger( EXPORTSTL_ARG_ISRELATIVE, int( theIsRelative ) ); } + bool GetIsRelative() + { return bool( _func->GetInteger( EXPORTSTL_ARG_ISRELATIVE ) ); } + + void SetDeflection( double theDeflection ) + { _func->SetReal( EXPORTSTL_ARG_DEFLECTION, theDeflection ); } + double GetDeflection() + { return _func->GetReal( EXPORTSTL_ARG_DEFLECTION ); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _STLPlugin_IExport_HXX_ diff --git a/src/STLPlugin/STLPlugin_IImport.hxx b/src/STLPlugin/STLPlugin_IImport.hxx new file mode 100644 index 000000000..247b1be10 --- /dev/null +++ b/src/STLPlugin/STLPlugin_IImport.hxx @@ -0,0 +1,42 @@ +// 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 _STLPlugin_IImport_HXX_ +#define _STLPlugin_IImport_HXX_ + +#include "GEOM_Function.hxx" + +#define IMPORTSTL_ARG_FILENAME 1 + +class STLPlugin_IImport +{ +public: + STLPlugin_IImport( Handle(GEOM_Function) theFunction) + : _func(theFunction) {} + + void SetFileName( const TCollection_AsciiString& theFileName ) + { _func->SetString( IMPORTSTL_ARG_FILENAME, theFileName ); } + TCollection_AsciiString GetFileName() + { return _func->GetString( IMPORTSTL_ARG_FILENAME ); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _STLPlugin_IImport_HXX_ diff --git a/src/STLPlugin/STLPlugin_IOperations.cxx b/src/STLPlugin/STLPlugin_IOperations.cxx new file mode 100644 index 000000000..f089fdc29 --- /dev/null +++ b/src/STLPlugin/STLPlugin_IOperations.cxx @@ -0,0 +1,181 @@ +// 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 "STLPlugin_IOperations.hxx" +#include "STLPlugin_ExportDriver.hxx" +#include "STLPlugin_ImportDriver.hxx" +#include "STLPlugin_IExport.hxx" +#include "STLPlugin_IImport.hxx" + +// KERNEL includes +#include + +// GEOM includes +#include "GEOM_PythonDump.hxx" +#include "GEOMImpl_Types.hxx" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +STLPlugin_IOperations::STLPlugin_IOperations( GEOM_Engine* theEngine, int theDocID ) +: GEOMImpl_IBaseIEOperations( theEngine, theDocID ) +{ + MESSAGE( "STLPlugin_IOperations::STLPlugin_IOperations" ); +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +STLPlugin_IOperations::~STLPlugin_IOperations() +{ + MESSAGE( "STLPlugin_IOperations::~STLPlugin_IOperations" ); +} + +//============================================================================= +/*! + * ExportSTL + * Export a shape to STL format + * \param theOriginal The shape to export + * \param theFileName The name of the file to exported + * \param theIsASCII The format of the exported file (ASCII or Binary) + * \param theDeflection The deflection of the shape to exported + * \param theIsRelative The mode for writing the file. If True (default value), + * the deflection is calculated relatively to the size of the shape; + * if False, the user defined deflection is used. + */ +//============================================================================= +void STLPlugin_IOperations::ExportSTL( const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const bool theIsASCII, + const double theDeflection, + const bool theIsRelative ) +{ + SetErrorCode(KO); + if( theOriginal.IsNull() ) return; + + Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction(); + if( aRefFunction.IsNull() ) return; //There is no function which creates an object to be exported + + //Add a new result object + Handle(GEOM_Object) result = GetEngine()->AddObject( GetDocID(), GEOM_IMPORT); + + //Add an Export function + Handle(GEOM_Function) aFunction = result->AddFunction( STLPlugin_ExportDriver::GetID(), EXPORT_SHAPE ); + if( aFunction.IsNull() ) return; + + //Check if the function is set correctly + if( aFunction->GetDriverGUID() != STLPlugin_ExportDriver::GetID() ) return; + + //Set parameters + STLPlugin_IExport aCI( aFunction ); + aCI.SetOriginal( aRefFunction ); + aCI.SetFileName( theFileName ); + aCI.SetIsASCII( theIsASCII ); + aCI.SetIsRelative( theIsRelative ); + aCI.SetDeflection( theDeflection ); + + //Perform the Export + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if( !GetSolver()->ComputeFunction( aFunction ) ) { + SetErrorCode( "Not enough space on disk, or you haven't permissions to write this directory" ); + return; + } + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode( aFail->GetMessageString() ); + return; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << "geompy.ExportSTL(" << theOriginal << ", \"" + << theFileName.ToCString() << "\", " << theIsASCII << ", " << theDeflection << ", " + << theIsRelative << ")"; + + SetErrorCode(OK); +} + +//============================================================================= +/*! + * ImportSTL + * Import a shape from STL format + * \param theFileName The name of the file to import + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +STLPlugin_IOperations::ImportSTL( const TCollection_AsciiString& theFileName ) +{ + SetErrorCode(KO); + if( theFileName.IsEmpty() ) return NULL; + + //Add a new result object + Handle(GEOM_Object) anImported = GetEngine()->AddObject( GetDocID(), GEOM_IMPORT ); + + //Add an Import function + Handle(GEOM_Function) aFunction = + anImported->AddFunction( STLPlugin_ImportDriver::GetID(), IMPORT_SHAPE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != STLPlugin_ImportDriver::GetID()) return NULL; + + //Set parameters + STLPlugin_IImport aCI( aFunction ); + aCI.SetFileName( theFileName ); + + //Perform the Import + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if( !GetSolver()->ComputeFunction( aFunction ) ) { + SetErrorCode( "Import driver failed" ); + return NULL; + } + aSeq->Append(anImported); + + // Greate material groups. + // MakeMaterialGroups( anImported, aSeq ); + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode( aFail->GetMessageString() ); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump pd (aFunction); + pd << aSeq << " = geompy.ImportSTL(\"" << theFileName.ToCString() << "\" )"; + SetErrorCode(OK); + + return aSeq; +} diff --git a/src/STLPlugin/STLPlugin_IOperations.hxx b/src/STLPlugin/STLPlugin_IOperations.hxx new file mode 100644 index 000000000..c6c39daaa --- /dev/null +++ b/src/STLPlugin/STLPlugin_IOperations.hxx @@ -0,0 +1,46 @@ +// 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 +// +// File : STLPlugin_IOperations.hxx + +#ifndef _STLPlugin_IOperations_HXX_ +#define _STLPlugin_IOperations_HXX_ + +// internal includes +#include "STLPlugin_Engine.hxx" + +// GEOM includes +#include "GEOMImpl_IBaseIEOperations.hxx" + +class STLPLUGINENGINE_EXPORT STLPlugin_IOperations: public GEOMImpl_IBaseIEOperations +{ +public: + STLPlugin_IOperations( GEOM_Engine*, int ); + ~STLPlugin_IOperations(); + + void ExportSTL( const Handle(GEOM_Object), + const TCollection_AsciiString&, + const bool, + const double, + const bool ); + + Handle(TColStd_HSequenceOfTransient) + ImportSTL( const TCollection_AsciiString& ); +}; + +#endif diff --git a/src/STLPlugin/STLPlugin_IOperations_i.cc b/src/STLPlugin/STLPlugin_IOperations_i.cc new file mode 100644 index 000000000..ebb81ef06 --- /dev/null +++ b/src/STLPlugin/STLPlugin_IOperations_i.cc @@ -0,0 +1,112 @@ +// 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 "STLPlugin_IOperations_i.hh" +#include "STLPlugin_IOperations.hxx" + +// KERNEL includes +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +STLPlugin_IOperations_i::STLPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + STLPlugin_IOperations* theImpl ) +:GEOM_IOperations_i( thePOA, theEngine, theImpl ) +{ + MESSAGE( "STLPlugin_IOperations_i::STLPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +STLPlugin_IOperations_i::~STLPlugin_IOperations_i() +{ + MESSAGE( "STLPlugin_IOperations_i::~STLPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * ExportSTL + * Export a shape to STL format + * \param theOriginal The shape to export + * \param theIsASCII The format of the exported file (ASCII or Binary) + * \param theFileName The name of the exported file + * \param theDeflection The deflection of the exported shape + */ +//============================================================================= +void STLPlugin_IOperations_i::ExportSTL( GEOM::GEOM_Object_ptr theOriginal, + const char* theFileName, + const bool theIsASCII, + const double theDeflection, + const bool theIsRelative ) +{ + // duplicate the original shape + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate( theOriginal ); + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(GEOM_Object) anOriginal = GetObjectImpl( theOriginal ); + if (anOriginal.IsNull()) return; + + GetOperations()->ExportSTL( anOriginal, theFileName, theIsASCII, theDeflection, theIsRelative ); +} + +//============================================================================= +/*! + * ImportSTL + * Import a shape from STL format + * \param theFileName The name of the file to import + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* STLPlugin_IOperations_i::ImportSTL( const char* theFileName ) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Import the shape from the file + Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportSTL( theFileName ); + + if( !GetOperations()->IsDone() || aHSeq.IsNull() ) + return aSeq._retn(); + + // Copy created objects. + Standard_Integer aLength = aHSeq->Length(); + aSeq->length( aLength ); + for( Standard_Integer i = 1; i <= aLength; i++ ) + aSeq[i-1] = GetObject( Handle(GEOM_Object)::DownCast( aHSeq->Value(i) ) ); + + return aSeq._retn(); +} + +STLPlugin_IOperations* STLPlugin_IOperations_i::GetOperations() +{ + return (STLPlugin_IOperations*)GetImpl(); +} diff --git a/src/STLPlugin/STLPlugin_IOperations_i.hh b/src/STLPlugin/STLPlugin_IOperations_i.hh new file mode 100644 index 000000000..f0733e1e0 --- /dev/null +++ b/src/STLPlugin/STLPlugin_IOperations_i.hh @@ -0,0 +1,52 @@ +// 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 _STLPlugin_IOperations_i_HeaderFile +#define _STLPlugin_IOperations_i_HeaderFile + +// idl includes +#include +#include CORBA_SERVER_HEADER( GEOM_Gen ) +#include CORBA_SERVER_HEADER( STLPlugin ) + +// internal includes +#include "STLPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_IOperations_i.hh" + +class STLPlugin_IOperations; + +class STLPLUGINENGINE_EXPORT STLPlugin_IOperations_i : + public virtual POA_GEOM::ISTLOperations, + public virtual GEOM_IOperations_i +{ +public: + STLPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + STLPlugin_IOperations* theImpl ); + ~STLPlugin_IOperations_i(); + + void ExportSTL( GEOM::GEOM_Object_ptr, const char*, const bool, const double, const bool ); + GEOM::ListOfGO* ImportSTL( const char* ); + + STLPlugin_IOperations* GetOperations(); +}; + +#endif diff --git a/src/STLPlugin/STLPlugin_ImportDriver.cxx b/src/STLPlugin/STLPlugin_ImportDriver.cxx new file mode 100644 index 000000000..40a96a889 --- /dev/null +++ b/src/STLPlugin/STLPlugin_ImportDriver.cxx @@ -0,0 +1,155 @@ +// 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 "STLPlugin_ImportDriver.hxx" +#include "STLPlugin_IImport.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOM_Function.hxx" +#include "GEOMImpl_Types.hxx" + +// OOCT includes +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& STLPlugin_ImportDriver::GetID() +{ + static Standard_GUID aGUID("69e33dc7-9630-4a73-ac19-cc4da1f659b8"); + return aGUID; +} + +//======================================================================= +//function : STLPlugin_ImportDriver +//purpose : +//======================================================================= +STLPlugin_ImportDriver::STLPlugin_ImportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer STLPlugin_ImportDriver::Execute( TFunction_Logbook& log ) const +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + STLPlugin_IImport aData( aFunction ); + + TCollection_AsciiString aFileName = aData.GetFileName().ToCString(); + + MESSAGE( "Import STL to file " << aFileName ); + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + StlAPI_Reader aReader; + TopoDS_Shape aShape; + + aReader.Read( aShape, aData.GetFileName().ToCString() ); + + if( aShape.IsNull() ) return 0; + + // Fix the orientation of closed shell or solid. + if( BRep_Tool::IsClosed( aShape ) ) { + TopAbs_ShapeEnum aType = aShape.ShapeType(); + if( aType == TopAbs_SHELL || aType == TopAbs_SOLID ) { + TopoDS_Solid aSolid; + if( aType == TopAbs_SHELL ) { + // Create a solid. + BRep_Builder aBuilder; + aBuilder.MakeSolid( aSolid ); + aBuilder.Add(aSolid, aShape ); + } + else + aSolid = TopoDS::Solid( aShape ); + + // Classify infinite point against solid. + BRepClass3d_SolidClassifier aClassifier( aSolid ); + aClassifier.PerformInfinitePoint(Precision::Confusion()); + + if( aClassifier.State() == TopAbs_IN ) { + // The shape is inverted. Reverse it. + aShape.Reverse(); + } + } + } + + aFunction->SetValue( aShape ); + + log.SetTouched( Label() ); + + return 1; +} + +//======================================================================= +//function : MustExecute +//purpose : +//======================================================================= +Standard_Boolean STLPlugin_ImportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ + +bool STLPlugin_ImportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + if( Label().IsNull() ) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction( Label() ); + + STLPlugin_IImport aCI( function ); + Standard_Integer aType = function->GetType(); + + theOperationName = "ImportSTL"; + + switch ( aType ) { + case IMPORT_SHAPE: + AddParam( theParams, "File name", aCI.GetFileName() ); + break; + default: + return false; + } + return true; +} + +IMPLEMENT_STANDARD_HANDLE( STLPlugin_ImportDriver, GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( STLPlugin_ImportDriver, GEOM_BaseDriver ); diff --git a/src/STLPlugin/STLPlugin_ImportDriver.hxx b/src/STLPlugin/STLPlugin_ImportDriver.hxx new file mode 100644 index 000000000..8373e59d7 --- /dev/null +++ b/src/STLPlugin/STLPlugin_ImportDriver.hxx @@ -0,0 +1,51 @@ +// 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 _STLPlugin_ImportDriver_HXX +#define _STLPlugin_ImportDriver_HXX + +// internal includes +#include "STLPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( STLPlugin_ImportDriver, GEOM_BaseDriver ); + +class STLPLUGINENGINE_EXPORT STLPlugin_ImportDriver : public GEOM_BaseDriver +{ +public: + STLPlugin_ImportDriver(); + ~STLPlugin_ImportDriver() {}; + + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} + + virtual bool GetCreationInformation( std::string& theOperationName, + std::vector& params ); + +DEFINE_STANDARD_RTTI( STLPlugin_ImportDriver ) +}; + +#endif // _STLPlugin_ImportDriver_HXX diff --git a/src/STLPlugin/STLPlugin_OperationsCreator.cxx b/src/STLPlugin/STLPlugin_OperationsCreator.cxx new file mode 100644 index 000000000..f2a47a07b --- /dev/null +++ b/src/STLPlugin/STLPlugin_OperationsCreator.cxx @@ -0,0 +1,71 @@ +// 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 "STLPlugin_OperationsCreator.hxx" +#include "STLPlugin_IOperations_i.hh" +#include "STLPlugin_IOperations.hxx" +#include "STLPlugin_ExportDriver.hxx" +#include "STLPlugin_ImportDriver.hxx" +#include "STLPlugin_IECallBack.hxx" + +// KERNEL includes +#include +#include + +// OCCT includes +#include + +std::map STLPlugin_OperationsCreator::_mapOfOperations; + +STLPlugin_OperationsCreator::STLPlugin_OperationsCreator() +{ + // Register drivers + TFunction_DriverTable::Get()->AddDriver( STLPlugin_ExportDriver::GetID(), + new STLPlugin_ExportDriver() ); + TFunction_DriverTable::Get()->AddDriver( STLPlugin_ImportDriver::GetID(), + new STLPlugin_ImportDriver() ); + // Register callback + STLPlugin_IECallBack* callback = new STLPlugin_IECallBack(); + GEOMImpl_IECallBack::Register( "STL", callback ); + GEOMImpl_IECallBack::Register( "STL_Bin", callback ); + GEOMImpl_IECallBack::Register( "STL_ASCII", callback ); +} + +STLPlugin_OperationsCreator::~STLPlugin_OperationsCreator() +{ +} + +GEOM_IOperations_i* STLPlugin_OperationsCreator::Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ) +{ + Unexpect aCatch( SALOME_SalomeException ); + MESSAGE( "STLPlugin_OperationsCreator::Create" ); + return new STLPlugin_IOperations_i( thePOA, theEngine, get( theGenImpl, theStudyId ) ); +} + +STLPlugin_IOperations* STLPlugin_OperationsCreator::get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ) +{ + if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) + _mapOfOperations[theStudyId] = new STLPlugin_IOperations( theGenImpl, theStudyId ); + return _mapOfOperations[theStudyId]; +} diff --git a/src/STLPlugin/STLPlugin_OperationsCreator.hxx b/src/STLPlugin/STLPlugin_OperationsCreator.hxx new file mode 100755 index 000000000..62314324e --- /dev/null +++ b/src/STLPlugin/STLPlugin_OperationsCreator.hxx @@ -0,0 +1,57 @@ +// 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 _GEOM_STLPlugin_OperationsCreator_HXX_ +#define _GEOM_STLPlugin_OperationsCreator_HXX_ + +// internal includes +#include "STLPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Gen_i.hh" + +// C++ includes +#include + +class STLPlugin_IOperations; + +//===================================================================== +// Operations creator +//===================================================================== +class STLPLUGINENGINE_EXPORT STLPlugin_OperationsCreator : public GEOM_GenericOperationsCreator +{ +public: + STLPlugin_OperationsCreator(); + ~STLPlugin_OperationsCreator(); + + GEOM_IOperations_i* Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ); +private: + static STLPlugin_IOperations* get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ); + +private: + static std::map _mapOfOperations; + + friend class STLPlugin_IECallBack; +}; + +#endif diff --git a/src/STLPlugin/STLPlugin_msg_en.ts b/src/STLPlugin/STLPlugin_msg_en.ts new file mode 100644 index 000000000..c8f10a272 --- /dev/null +++ b/src/STLPlugin/STLPlugin_msg_en.ts @@ -0,0 +1,61 @@ + + + + + @default + + MEN_EXPORTSTL + STL + + + TOP_EXPORTSTL + Export STL + + + STB_EXPORTSTL + Export STL + + + MEN_IMPORTSTL + STL + + + TOP_IMPORTSTL + Import STL + + + STB_IMPORTSTL + Import STL + + + + STLPlugin_GUI + + STL_FILES + STL files( *.stl ) + + + EXPORT_TITLE + Export STL + + + IMPORT_TITLE + Import STL + + + + STLPlugin_ExportDlg + + ASCII + Save as ASCII + + + RELATIVE + Relative + + + DEFLECTION + Deflection + + + diff --git a/src/STLPlugin/STLPlugin_msg_fr.ts b/src/STLPlugin/STLPlugin_msg_fr.ts new file mode 100644 index 000000000..e4347f829 --- /dev/null +++ b/src/STLPlugin/STLPlugin_msg_fr.ts @@ -0,0 +1,61 @@ + + + + + @default + + MEN_EXPORTSTL + STL + + + TOP_EXPORTSTL + Exporter STL + + + STB_EXPORTSTL + Exporter STL + + + MEN_IMPORTSTL + STL + + + TOP_IMPORTSTL + Importer STL + + + STB_IMPORTSTL + Importer STL + + + + STLPlugin_GUI + + STL_FILES + STL fichiers( *.stl ) + + + EXPORT_TITLE + Exporter STL + + + IMPORT_TITLE + Importer STL + + + + STLPlugin_ExportDlg + + ASCII + Save as ASCII + + + RELATIVE + Relative + + + DEFLECTION + Déflexion + + + diff --git a/src/STLPlugin/STLPlugin_msg_ja.ts b/src/STLPlugin/STLPlugin_msg_ja.ts new file mode 100644 index 000000000..1c10df04f --- /dev/null +++ b/src/STLPlugin/STLPlugin_msg_ja.ts @@ -0,0 +1,61 @@ + + + + + @default + + MEN_EXPORTSTL + STL + + + TOP_EXPORTSTL + Export STL + + + STB_EXPORTSTL + Export STL + + + MEN_IMPORTSTL + STL + + + TOP_IMPORTSTL + Import STL + + + STB_IMPORTSTL + Import STL + + + + STLPlugin_GUI + + STL_FILES + STL files( *.stl ) + + + EXPORT_TITLE + Export STL + + + IMPORT_TITLE + Import STL + + + + STLPlugin_ExportDlg + + ASCII + Save as ASCII + + + RELATIVE + Relative + + + DEFLECTION + Deflection + + + diff --git a/src/VTKExport/CMakeLists.txt b/src/VTKExport/CMakeLists.txt deleted file mode 100755 index 04081e0a3..000000000 --- a/src/VTKExport/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (C) 2012-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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIR} - ${KERNEL_INCLUDE_DIRS} - ${VTK_INCLUDE_DIRS} - ${PROJECT_SOURCE_DIR}/src/OCC2VTK - ) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ) - -# libraries to link to -SET(_link_LIBRARIES - vtkIOLegacy - OCC2VTK - ${KERNEL_SALOMELocalTrace} - ) - -# --- sources --- - -SET(VTKExport_SOURCES - VTKExport.cxx - ) - -# --- rules --- - -ADD_LIBRARY(VTKExport ${VTKExport_SOURCES}) -TARGET_LINK_LIBRARIES(VTKExport ${_link_LIBRARIES}) -INSTALL(TARGETS VTKExport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) - - diff --git a/src/VTKExport/VTKExport.cxx b/src/VTKExport/VTKExport.cxx deleted file mode 100644 index ab853c4af..000000000 --- a/src/VTKExport/VTKExport.cxx +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// - -// File: VTKExport.cxx -// Author: Oleg UVAROV -// -#include "utilities.h" - -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef WIN32 -# if defined VTKEXPORT_EXPORTS || defined VTKExport_EXPORTS -# define VTKEXPORT_EXPORT __declspec( dllexport ) -# else -# define VTKEXPORT_EXPORT __declspec( dllimport ) -# endif -#else -# define VTKEXPORT_EXPORT -#endif - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ - VTKEXPORT_EXPORT - int Export(const TopoDS_Shape& theShape, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName) - { - MESSAGE("Export VTK into file " << theFileName.ToCString()); - - try - { - GEOM_VertexSource* myVertexSource = GEOM_VertexSource::New(); - GEOM_EdgeSource* myIsolatedEdgeSource = GEOM_EdgeSource::New(); - GEOM_EdgeSource* myOneFaceEdgeSource = GEOM_EdgeSource::New(); - GEOM_EdgeSource* mySharedEdgeSource = GEOM_EdgeSource::New(); - GEOM_WireframeFace* myWireframeFaceSource = GEOM_WireframeFace::New(); - GEOM_ShadingFace* myShadingFaceSource = GEOM_ShadingFace::New(); - - vtkAppendPolyData* myAppendFilter = vtkAppendPolyData::New(); - myAppendFilter->AddInputConnection( myVertexSource->GetOutputPort() ); - myAppendFilter->AddInputConnection( myIsolatedEdgeSource->GetOutputPort() ); - myAppendFilter->AddInputConnection( myOneFaceEdgeSource->GetOutputPort() ); - myAppendFilter->AddInputConnection( mySharedEdgeSource->GetOutputPort() ); - //myAppendFilter->AddInputConnection( myWireframeFaceSource->GetOutputPort() ); // iso-lines are unnecessary - myAppendFilter->AddInputConnection( myShadingFaceSource->GetOutputPort() ); - - float aDeflection = 0.001; - bool anIsVector = false; - - // Is shape triangulated? - bool wasMeshed = true; - TopExp_Explorer ex; - TopLoc_Location aLoc; - for (ex.Init(theShape, TopAbs_FACE); ex.More(); ex.Next()) { - const TopoDS_Face& aFace = TopoDS::Face(ex.Current()); - Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc); - if(aPoly.IsNull()) { - wasMeshed = false; - break; - } - } - - GEOM::MeshShape( theShape, aDeflection ); - - TopExp_Explorer aVertexExp( theShape, TopAbs_VERTEX ); - for( ; aVertexExp.More(); aVertexExp.Next() ) - { - const TopoDS_Vertex& aVertex = TopoDS::Vertex( aVertexExp.Current() ); - myVertexSource->AddVertex( aVertex ); - } - - TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap; - TopExp::MapShapesAndAncestors( theShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap ); - - GEOM::SetShape( theShape, - anEdgeMap, - anIsVector, - 0, // all vertices were added above - myIsolatedEdgeSource, - myOneFaceEdgeSource, - mySharedEdgeSource, - myWireframeFaceSource, - myShadingFaceSource ); - - myAppendFilter->Update(); - - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New(); - aWriter->SetInputConnection( myAppendFilter->GetOutputPort() ); - aWriter->SetFileName( theFileName.ToCString() ); - aWriter->Write(); - aWriter->Delete(); - - myVertexSource->Delete(); - myIsolatedEdgeSource->Delete(); - myOneFaceEdgeSource->Delete(); - mySharedEdgeSource->Delete(); - myWireframeFaceSource->Delete(); - myShadingFaceSource->Delete(); - - myAppendFilter->Delete(); - - if(!wasMeshed) - BRepTools::Clean(theShape); - - return 1; - } - catch(Standard_Failure) - { - //THROW_SALOME_CORBA_EXCEPTION("Exception catched in VTKExport", SALOME::BAD_PARAM); - } - return 0; - } -} diff --git a/src/VTKPlugin/CMakeLists.txt b/src/VTKPlugin/CMakeLists.txt new file mode 100644 index 000000000..afab5da2f --- /dev/null +++ b/src/VTKPlugin/CMakeLists.txt @@ -0,0 +1,149 @@ +# 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 +# + +IF(SALOME_BUILD_GUI) + INCLUDE(UseQt4Ext) + INCLUDE(${QT_USE_FILE}) +ENDIF() + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} + ${KERNEL_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR}/idl + ${PROJECT_SOURCE_DIR}/src/GEOMAlgo + ${PROJECT_SOURCE_DIR}/src/GEOM + ${PROJECT_SOURCE_DIR}/src/GEOMImpl + ${PROJECT_SOURCE_DIR}/src/GEOM_I + ${PROJECT_SOURCE_DIR}/src/GEOMClient + ${PROJECT_SOURCE_DIR}/src/OCC2VTK + ${PROJECT_SOURCE_DIR}/src/GEOMUtils + ) + +IF(SALOME_BUILD_GUI) + INCLUDE_DIRECTORIES( + ${QT_INCLUDE_DIRS} + ${GUI_INCLUDE_DIRS} + ${PROJECT_SOURCE_DIR}/src/OBJECT + ${PROJECT_SOURCE_DIR}/src/GEOMGUI + ${PROJECT_SOURCE_DIR}/src/GEOMBase + ) +ENDIF() + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${CAS_DEFINITIONS} + ) + +IF(SALOME_BUILD_GUI) +ADD_DEFINITIONS( + ${QT_DEFINITIONS} + ) +ENDIF() + +# libraries to link to +SET(_link_engine_LIBRARIES + ${CAS_TKVTK} + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + SalomeIDLGEOM + SalomeIDLVTKPlugin + GEOMEngine + GEOMClient + vtkIOLegacy + OCC2VTK + ) + +IF(SALOME_BUILD_GUI) + SET(_link_gui_LIBRARIES + SalomeIDLVTKPlugin + GEOMObject + GEOM + GEOMBase + ) +ENDIF() + + +# --- headers --- + +SET(VTKPluginEngine_HEADERS + VTKPlugin_IOperations_i.hh + VTKPlugin_Engine.hxx + VTKPlugin_OperationsCreator.hxx + VTKPlugin_IOperations.hxx + VTKPlugin_IExport.hxx + VTKPlugin_ExportDriver.hxx + VTKPlugin_IECallBack.hxx + ) + +IF(SALOME_BUILD_GUI) + # header files / to be processed by moc + SET(_moc_HEADERS + VTKPlugin_GUI.h + VTKPlugin_ExportDlg.h + ) +ENDIF() + +# --- sources --- + +IF(SALOME_BUILD_GUI) + # sources / moc wrappings + QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) + + SET(VTKPluginGUI_SOURCES + VTKPlugin_GUI.cxx + VTKPlugin_ExportDlg.cxx + ${_moc_SOURCES} + ) +ENDIF() + +SET(VTKPluginEngine_SOURCES + VTKPlugin_Engine.cxx + VTKPlugin_OperationsCreator.cxx + VTKPlugin_IOperations_i.cc + VTKPlugin_IOperations.cxx + VTKPlugin_ExportDriver.cxx + VTKPlugin_IECallBack.cxx + ) + +# resource files / to be processed by lrelease +SET(VTKPlugin_RESOURCES + VTKPlugin_msg_en.ts + VTKPlugin_msg_fr.ts + VTKPlugin_msg_ja.ts + ) + +# --- rules --- + +ADD_LIBRARY(VTKPluginEngine ${VTKPluginEngine_SOURCES}) +TARGET_LINK_LIBRARIES(VTKPluginEngine ${_link_engine_LIBRARIES}) +INSTALL(TARGETS VTKPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +IF(SALOME_BUILD_GUI) + ADD_LIBRARY(VTKPluginGUI ${VTKPluginGUI_SOURCES}) + TARGET_LINK_LIBRARIES(VTKPluginGUI ${_link_gui_LIBRARIES}) + INSTALL(TARGETS VTKPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + + QT4_INSTALL_TS_RESOURCES("${VTKPlugin_RESOURCES}" "${SALOME_GEOM_INSTALL_RES_DATA}") +ENDIF() + + +INSTALL(FILES ${VTKPluginEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/VTKPlugin/VTKPlugin_Engine.cxx b/src/VTKPlugin/VTKPlugin_Engine.cxx new file mode 100644 index 000000000..5c0ed2e53 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_Engine.cxx @@ -0,0 +1,32 @@ +// 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 "VTKPlugin_Engine.hxx" +#include "VTKPlugin_OperationsCreator.hxx" + +extern "C" +{ + VTKPLUGINENGINE_EXPORT + GEOM_GenericOperationsCreator* GetOperationsCreator() + { + VTKPlugin_OperationsCreator* aCreator = new VTKPlugin_OperationsCreator(); + return aCreator; + } +} diff --git a/src/VTKPlugin/VTKPlugin_Engine.hxx b/src/VTKPlugin/VTKPlugin_Engine.hxx new file mode 100755 index 000000000..cd373e1d7 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_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 _VTKPLUGIN_ENGINE_HXX_ +#define _VTKPLUGIN_ENGINE_HXX_ + +#ifdef WIN32 + #if defined VTKPLUGINENGINE_EXPORTS || defined VTKPluginEngine_EXPORTS + #define VTKPLUGINENGINE_EXPORT __declspec( dllexport ) + #else + #define VTKPLUGINENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define VTKPLUGINENGINE_EXPORT +#endif + +#endif diff --git a/src/VTKPlugin/VTKPlugin_ExportDlg.cxx b/src/VTKPlugin/VTKPlugin_ExportDlg.cxx new file mode 100644 index 000000000..901221594 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_ExportDlg.cxx @@ -0,0 +1,118 @@ +// 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 "VTKPlugin_ExportDlg.h" + +#include +#include CORBA_SERVER_HEADER(VTKPlugin) + +// GUI includes +#include +#include +#include + +#include +#include +#include + +// GEOM includes +#include "GEOM_Constants.h" + +// QT includes +#include +#include +#include + +//================================================================================= +// Constructor +//================================================================================= +VTKPlugin_ExportDlg::VTKPlugin_ExportDlg( const Handle(SALOME_InteractiveObject)& io, QWidget* parent ) +: SUIT_FileDlg( parent, false, true, true ) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + + QLabel* deflectionLabel = new QLabel( tr( "DEFLECTION" ), this ); + + myDeflectionSB = new SalomeApp_DoubleSpinBox( this ); + int aPrecision = resMgr->integerValue( "Geometry", "parametric_precision", 6 ); + myDeflectionSB->setAcceptNames( false ); + myDeflectionSB->setPrecision( aPrecision ); + myDeflectionSB->setDecimals( aPrecision ); + myDeflectionSB->setRange( GEOM::minDeflection(), 1.0 ); + myDeflectionSB->setSingleStep( 1.0e-04 ); + + layout()->addWidget( deflectionLabel ); + layout()->addWidget( myDeflectionSB ); + + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Study* study = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + int mgrId = app->activeViewManager()->getGlobalId(); + QVariant v = study->getObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Deflection ), QVariant() ); + double deflection = v.isValid() ? v.toDouble() : SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "deflection_coef", 0.001 ); + myDeflectionSB->setValue( deflection ); +} + +//================================================================================= +// Destructor +//================================================================================= +VTKPlugin_ExportDlg::~VTKPlugin_ExportDlg() +{ +} + +//================================================================================= +// getDeflection +//================================================================================= +double VTKPlugin_ExportDlg::getDeflection() const +{ + return myDeflectionSB->value(); +} + +//================================================================================= +// getFileName +//================================================================================= +QString VTKPlugin_ExportDlg::getFileName( const Handle(SALOME_InteractiveObject)& io, + const QString& filters, const QString& caption, + QWidget* parent, double& deflection ) +{ + QStringList fls = filters.split( ";;", QString::SkipEmptyParts ); + + QString tmpfilename = io->getName(); + tmpfilename = tmpfilename.simplified(); + tmpfilename = tmpfilename.replace( QRegExp( "\\*" ), "" ).replace( QRegExp( "\\?" ), "" ); + + VTKPlugin_ExportDlg fd( io, parent ); + fd.setFileMode( AnyFile ); + fd.setFilters( fls ); + fd.setWindowTitle( caption ); + if ( !tmpfilename.isEmpty() ) + fd.processPath( tmpfilename ); + + QString filename; + + if ( fd.exec() == QDialog::Accepted ) { + filename = fd.selectedFile(); + deflection = fd.getDeflection(); + } + + QApplication::processEvents(); + + return filename; +} + diff --git a/src/VTKPlugin/VTKPlugin_ExportDlg.h b/src/VTKPlugin/VTKPlugin_ExportDlg.h new file mode 100644 index 000000000..d8e4095d4 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_ExportDlg.h @@ -0,0 +1,50 @@ +// 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 VTKPlugin_ExportDlg_H +#define VTKPlugin_ExportDlg_H + +// GUI includes +#include +#include + +class SalomeApp_DoubleSpinBox; + +class VTKPlugin_ExportDlg: public SUIT_FileDlg +{ + Q_OBJECT + +public: + VTKPlugin_ExportDlg( const Handle(SALOME_InteractiveObject)&, QWidget* parent ); + ~VTKPlugin_ExportDlg(); + + double getDeflection() const; + + static QString getFileName( const Handle(SALOME_InteractiveObject)& io, + const QString& filters, + const QString& caption, + QWidget* parent, + double& deflection ); + +private: + SalomeApp_DoubleSpinBox* myDeflectionSB; + Handle(SALOME_InteractiveObject) myObject; +}; + +#endif // VTKPlugin_ExportDlg_H diff --git a/src/VTKPlugin/VTKPlugin_ExportDriver.cxx b/src/VTKPlugin/VTKPlugin_ExportDriver.cxx new file mode 100644 index 000000000..a77897278 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_ExportDriver.cxx @@ -0,0 +1,200 @@ +// 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 "VTKPlugin_ExportDriver.hxx" +#include "VTKPlugin_IExport.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOM_Function.hxx" +#include "OCC2VTK_Tools.h" +#include "GEOM_VertexSource.h" +#include "GEOM_EdgeSource.h" +#include "GEOM_WireframeFace.h" +#include "GEOM_ShadingFace.h" + +// OOCT includes +#include +#include +#include +#include +#include +#include +#include +#include + +// VTK includes +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& VTKPlugin_ExportDriver::GetID() +{ + static Standard_GUID aGUID("0966443c-6f3c-4ebe-ba46-c0833786d817"); + return aGUID; +} + +//======================================================================= +//function : VTKPlugin_ExportDriver +//purpose : +//======================================================================= +VTKPlugin_ExportDriver::VTKPlugin_ExportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer VTKPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction( Label() ); + + VTKPlugin_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(); + float aDeflection = float( aData.GetDeflection() ); + + MESSAGE( "Export VTK into file " << aFileName ); + try + { + GEOM_VertexSource* myVertexSource = GEOM_VertexSource::New(); + GEOM_EdgeSource* myIsolatedEdgeSource = GEOM_EdgeSource::New(); + GEOM_EdgeSource* myOneFaceEdgeSource = GEOM_EdgeSource::New(); + GEOM_EdgeSource* mySharedEdgeSource = GEOM_EdgeSource::New(); + GEOM_WireframeFace* myWireframeFaceSource = GEOM_WireframeFace::New(); + GEOM_ShadingFace* myShadingFaceSource = GEOM_ShadingFace::New(); + + vtkAppendPolyData* myAppendFilter = vtkAppendPolyData::New(); + myAppendFilter->AddInputConnection( myVertexSource->GetOutputPort() ); + myAppendFilter->AddInputConnection( myIsolatedEdgeSource->GetOutputPort() ); + myAppendFilter->AddInputConnection( myOneFaceEdgeSource->GetOutputPort() ); + myAppendFilter->AddInputConnection( mySharedEdgeSource->GetOutputPort() ); + //myAppendFilter->AddInputConnection( myWireframeFaceSource->GetOutputPort() ); // iso-lines are unnecessary + myAppendFilter->AddInputConnection( myShadingFaceSource->GetOutputPort() ); + + bool anIsVector = false; + + // Is shape triangulated? + bool wasMeshed = true; + TopExp_Explorer ex; + TopLoc_Location aLoc; + for (ex.Init(aShape, TopAbs_FACE); ex.More(); ex.Next()) { + const TopoDS_Face& aFace = TopoDS::Face(ex.Current()); + Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc); + if(aPoly.IsNull()) { + wasMeshed = false; + break; + } + } + + GEOM::MeshShape( aShape, aDeflection ); + + TopExp_Explorer aVertexExp( aShape, TopAbs_VERTEX ); + for( ; aVertexExp.More(); aVertexExp.Next() ) + { + const TopoDS_Vertex& aVertex = TopoDS::Vertex( aVertexExp.Current() ); + myVertexSource->AddVertex( aVertex ); + } + + TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap; + TopExp::MapShapesAndAncestors( aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap ); + + GEOM::SetShape( aShape, + anEdgeMap, + anIsVector, + 0, + myIsolatedEdgeSource, + myOneFaceEdgeSource, + mySharedEdgeSource, + myWireframeFaceSource, + myShadingFaceSource ); + + myAppendFilter->Update(); + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New(); + aWriter->SetInputConnection( myAppendFilter->GetOutputPort() ); + aWriter->SetFileName( aFileName.ToCString() ); + aWriter->Write(); + aWriter->Delete(); + + myVertexSource->Delete(); + myIsolatedEdgeSource->Delete(); + myOneFaceEdgeSource->Delete(); + mySharedEdgeSource->Delete(); + myWireframeFaceSource->Delete(); + myShadingFaceSource->Delete(); + + myAppendFilter->Delete(); + + if(!wasMeshed) + BRepTools::Clean(aShape); + + return 1; + } + catch( Standard_Failure ) + { + //THROW_SALOME_CORBA_EXCEPTION("Exception catched in ExportVTK", SALOME::BAD_PARAM); + } + return 0; +} + +//======================================================================= +//function : MustExecute +//purpose : +//======================================================================= +Standard_Boolean VTKPlugin_ExportDriver::MustExecute( const TFunction_Logbook& ) const +{ + return Standard_True; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ +bool VTKPlugin_ExportDriver:: +GetCreationInformation( std::string& theOperationName, + std::vector& theParams ) +{ + return false; +} + +IMPLEMENT_STANDARD_HANDLE( VTKPlugin_ExportDriver,GEOM_BaseDriver ); +IMPLEMENT_STANDARD_RTTIEXT( VTKPlugin_ExportDriver,GEOM_BaseDriver ); diff --git a/src/VTKPlugin/VTKPlugin_ExportDriver.hxx b/src/VTKPlugin/VTKPlugin_ExportDriver.hxx new file mode 100644 index 000000000..cc055b9d9 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_ExportDriver.hxx @@ -0,0 +1,51 @@ +// 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 _VTKPlugin_ExportDriver_HXX +#define _VTKPlugin_ExportDriver_HXX + +// internal includes +#include "VTKPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( VTKPlugin_ExportDriver, GEOM_BaseDriver ); + +class VTKPLUGINENGINE_EXPORT VTKPlugin_ExportDriver : public GEOM_BaseDriver +{ +public: + VTKPlugin_ExportDriver(); + ~VTKPlugin_ExportDriver() {}; + + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} + + virtual bool GetCreationInformation( std::string& theOperationName, + std::vector& params ); + +DEFINE_STANDARD_RTTI( VTKPlugin_ExportDriver ) +}; + +#endif // _VTKPlugin_ExportDriver_HXX diff --git a/src/VTKPlugin/VTKPlugin_GUI.cxx b/src/VTKPlugin/VTKPlugin_GUI.cxx new file mode 100644 index 000000000..d5bec2d72 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_GUI.cxx @@ -0,0 +1,186 @@ +// 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 "VTKPlugin_GUI.h" +#include "VTKPlugin_ExportDlg.h" + +// GUI includes +#include +#include +#include +#include +#include +#include +#include + +// GEOM includes +#include "GeometryGUI.h" +#include "GEOM_Operation.h" +#include "GEOMBase.h" +#include "GEOM_Displayer.h" + +#include +#include CORBA_SERVER_HEADER(VTKPlugin) + +//======================================================================= +// function : VTKPlugin_GUI() +// purpose : Constructor +//======================================================================= +VTKPlugin_GUI::VTKPlugin_GUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) +{ +} + +//======================================================================= +// function : ~VTKPlugin_GUI +// purpose : Destructor +//======================================================================= +VTKPlugin_GUI::~VTKPlugin_GUI() +{ +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool VTKPlugin_GUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) +{ + QString cmd; + switch ( theCommandID ) { + case 1: + cmd = "Export_VTK"; break; + default: + break; + } + return OnGUIEvent( cmd, parent ); +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool VTKPlugin_GUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) +{ + bool result = false; + + if( theCommandID == "Export_VTK" ) { + result = exportVTK( parent ); + } + else { + getGeometryGUI()->getApp()->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) ); + } + + return true; +} + +//======================================================================= +// function : exportVTK +// purpose : +//======================================================================= +bool VTKPlugin_GUI::exportVTK( SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); + if ( !study ) return false; + + SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "VTKPluginEngine" ); + GEOM::IVTKOperations_var stlOp = GEOM::IVTKOperations::_narrow( op ); + if ( CORBA::is_nil( stlOp ) ) return false; + + LightApp_SelectionMgr* sm = app->selectionMgr(); + if ( !sm ) return false; + + SALOME_ListIO selectedObjects; + sm->selectedObjects( selectedObjects ); + bool ok = false; + + SALOME_ListIteratorOfListIO it( selectedObjects ); + for ( ; it.More(); it.Next() ) + { + Handle(SALOME_InteractiveObject) io = it.Value(); + GEOM::GEOM_Object_var obj = GEOMBase::ConvertIOinGEOMObject( io ); + + if ( CORBA::is_nil( obj ) ) continue; + + double deflection = 0.; + QString fileName = VTKPlugin_ExportDlg::getFileName( io, + tr( "VTK_FILES" ), + tr( "EXPORT_TITLE" ), + parent, + deflection ); + + if ( fileName.isEmpty() ) + return false; + + SUIT_OverrideCursor wc; + + GEOM_Operation transaction( app, stlOp.in() ); + + try + { + app->putInfo( tr( "GEOM_PRP_EXPORT" ).arg( fileName ) ); + transaction.start(); + + stlOp->ExportVTK( obj, fileName.toUtf8().constData(), deflection ); + + if ( stlOp->IsDone() ) + { + transaction.commit(); + } + else + { + transaction.abort(); + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_PRP_ABORT" ) + "\n" + tr( stlOp->GetErrorCode() ) ); + return false; + } + } + catch ( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + return false; + } + ok = true; + } + + if ( !ok ) + { + SUIT_MessageBox::warning( parent, + tr( "WRN_WARNING" ), + tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) ); + } + return ok; +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ +#ifdef WIN32 + __declspec( dllexport ) +#endif + GEOMGUI* GetLibGUI( GeometryGUI* parent ) + { + return new VTKPlugin_GUI( parent ); + } +} diff --git a/src/VTKPlugin/VTKPlugin_GUI.h b/src/VTKPlugin/VTKPlugin_GUI.h new file mode 100644 index 000000000..a24f5dfdc --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_GUI.h @@ -0,0 +1,39 @@ +// 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 VTKPlugin_GUI_H +#define VTKPlugin_GUI_H + +#include "GEOMPluginGUI.h" + +class VTKPlugin_GUI: public GEOMPluginGUI +{ + Q_OBJECT +public: + VTKPlugin_GUI( GeometryGUI* parent ); + ~VTKPlugin_GUI(); + + bool OnGUIEvent( int commandId, SUIT_Desktop* ); + bool OnGUIEvent( const QString&, SUIT_Desktop* ); + +private: + bool exportVTK( SUIT_Desktop* ); +}; + +#endif // VTKPlugin_GUI_H diff --git a/src/VTKPlugin/VTKPlugin_IECallBack.cxx b/src/VTKPlugin/VTKPlugin_IECallBack.cxx new file mode 100755 index 000000000..25f1658f4 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_IECallBack.cxx @@ -0,0 +1,57 @@ +// 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 "VTKPlugin_IECallBack.hxx" +#include "VTKPlugin_IOperations.hxx" +#include "VTKPlugin_OperationsCreator.hxx" + +//============================================================================= +/*! + * constructor + */ +//============================================================================= +VTKPlugin_IECallBack::VTKPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +VTKPlugin_IECallBack::~VTKPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * Export + */ +//============================================================================= +bool VTKPlugin_IECallBack::Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ) +{ + VTKPlugin_IOperations* aPluginOperations = VTKPlugin_OperationsCreator::get( GetEngine(), theDocId ); + const double aDeflection = 0.001; + aPluginOperations->ExportVTK( theOriginal, theFileName, aDeflection ); + return true; +} diff --git a/src/VTKPlugin/VTKPlugin_IECallBack.hxx b/src/VTKPlugin/VTKPlugin_IECallBack.hxx new file mode 100644 index 000000000..a0e91f4a4 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_IECallBack.hxx @@ -0,0 +1,45 @@ +// 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 _VTKPlugin_IECallBack_HXX_ +#define _VTKPlugin_IECallBack_HXX_ + +// internal includes +#include "VTKPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Object.hxx" +#include "GEOMImpl_IECallBack.hxx" + +// OCC includes +#include + +class VTKPLUGINENGINE_EXPORT VTKPlugin_IECallBack : public GEOMImpl_IECallBack +{ +public: + VTKPlugin_IECallBack(); + ~VTKPlugin_IECallBack(); + + bool Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ); +}; + +#endif diff --git a/src/VTKPlugin/VTKPlugin_IExport.hxx b/src/VTKPlugin/VTKPlugin_IExport.hxx new file mode 100644 index 000000000..5fe83e646 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_IExport.hxx @@ -0,0 +1,54 @@ +// 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 _VTKPlugin_IExport_HXX_ +#define _VTKPlugin_IExport_HXX_ + +#include "GEOM_Function.hxx" + +#define EXPORTVTK_ARG_ORIGINAL 1 +#define EXPORTVTK_ARG_FILENAME 2 +#define EXPORTVTK_ARG_DEFLECTION 3 + +class VTKPlugin_IExport +{ +public: + VTKPlugin_IExport( Handle(GEOM_Function) theFunction ) + : _func(theFunction) {} + + void SetOriginal( Handle( GEOM_Function ) theOriginal) + { _func->SetReference( EXPORTVTK_ARG_ORIGINAL, theOriginal ); } + Handle( GEOM_Function ) GetOriginal() + { return _func->GetReference( EXPORTVTK_ARG_ORIGINAL ); } + + void SetFileName( const TCollection_AsciiString& theFileName ) + { _func->SetString( EXPORTVTK_ARG_FILENAME, theFileName ); } + TCollection_AsciiString GetFileName() + { return _func->GetString( EXPORTVTK_ARG_FILENAME ); } + + void SetDeflection( double theDeflection ) + { _func->SetReal( EXPORTVTK_ARG_DEFLECTION, theDeflection ); } + double GetDeflection() + { return _func->GetReal( EXPORTVTK_ARG_DEFLECTION ); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _VTKPlugin_IExport_HXX_ diff --git a/src/VTKPlugin/VTKPlugin_IOperations.cxx b/src/VTKPlugin/VTKPlugin_IOperations.cxx new file mode 100644 index 000000000..6e18dd154 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_IOperations.cxx @@ -0,0 +1,111 @@ +// 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 "VTKPlugin_IOperations.hxx" +#include "VTKPlugin_ExportDriver.hxx" +#include "VTKPlugin_IExport.hxx" + +// KERNEL includes +#include + +// GEOM includes +#include "GEOM_PythonDump.hxx" +#include "GEOMImpl_Types.hxx" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +VTKPlugin_IOperations::VTKPlugin_IOperations( GEOM_Engine* theEngine, int theDocID ) +: GEOMImpl_IBaseIEOperations( theEngine, theDocID ) +{ + MESSAGE( "VTKPlugin_IOperations::VTKPlugin_IOperations" ); +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +VTKPlugin_IOperations::~VTKPlugin_IOperations() +{ + MESSAGE( "VTKPlugin_IOperations::~VTKPlugin_IOperations" ); +} + +//============================================================================= +/*! + * ExportVTK + * Export a shape to VTK format + * \param theOriginal The shape to export + * \param theFileName The name of the file to exported + * \param theDeflection The deflection of the shape to exported + */ +//============================================================================= +void VTKPlugin_IOperations::ExportVTK( const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const double theDeflection ) +{ + SetErrorCode(KO); + if( theOriginal.IsNull() ) return; + + Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction(); + if( aRefFunction.IsNull() ) return; //There is no function which creates an object to be exported + + //Add a new result object + Handle(GEOM_Object) result = GetEngine()->AddObject( GetDocID(), GEOM_IMPORT); + + //Add an Export function + Handle(GEOM_Function) aFunction = result->AddFunction( VTKPlugin_ExportDriver::GetID(), EXPORT_SHAPE ); + if( aFunction.IsNull() ) return; + + //Check if the function is set correctly + if( aFunction->GetDriverGUID() != VTKPlugin_ExportDriver::GetID() ) return; + + //Set parameters + VTKPlugin_IExport aCI( aFunction ); + aCI.SetOriginal( aRefFunction ); + aCI.SetFileName( theFileName ); + aCI.SetDeflection( theDeflection ); + + //Perform the Export + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if( !GetSolver()->ComputeFunction( aFunction ) ) { + SetErrorCode( "Not enough space on disk, or you haven't permissions to write this directory" ); + return; + } + } + catch( Standard_Failure ) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode( aFail->GetMessageString() ); + return; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << "geompy.ExportVTK(" << theOriginal << ", \"" + << theFileName.ToCString() << "\", " << theDeflection << ")"; + + SetErrorCode(OK); +} diff --git a/src/VTKPlugin/VTKPlugin_IOperations.hxx b/src/VTKPlugin/VTKPlugin_IOperations.hxx new file mode 100644 index 000000000..dc7a6174c --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_IOperations.hxx @@ -0,0 +1,41 @@ +// 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 +// +// File : VTKPlugin_IOperations.hxx + +#ifndef _VTKPlugin_IOperations_HXX_ +#define _VTKPlugin_IOperations_HXX_ + +// internal includes +#include "VTKPlugin_Engine.hxx" + +// GEOM includes +#include "GEOMImpl_IBaseIEOperations.hxx" + +class VTKPLUGINENGINE_EXPORT VTKPlugin_IOperations: public GEOMImpl_IBaseIEOperations +{ +public: + VTKPlugin_IOperations( GEOM_Engine*, int ); + ~VTKPlugin_IOperations(); + + void ExportVTK( const Handle(GEOM_Object), + const TCollection_AsciiString&, + const double ); +}; + +#endif diff --git a/src/VTKPlugin/VTKPlugin_IOperations_i.cc b/src/VTKPlugin/VTKPlugin_IOperations_i.cc new file mode 100644 index 000000000..f73c9486b --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_IOperations_i.cc @@ -0,0 +1,80 @@ +// 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 "VTKPlugin_IOperations_i.hh" +#include "VTKPlugin_IOperations.hxx" + +// KERNEL includes +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +VTKPlugin_IOperations_i::VTKPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + VTKPlugin_IOperations* theImpl ) +:GEOM_IOperations_i( thePOA, theEngine, theImpl ) +{ + MESSAGE( "VTKPlugin_IOperations_i::VTKPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +VTKPlugin_IOperations_i::~VTKPlugin_IOperations_i() +{ + MESSAGE( "VTKPlugin_IOperations_i::~VTKPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * ExportVTK + * Export a shape to VTK format + * \param theOriginal The shape to export + * \param theFileName The name of the exported file + * \param theDeflection The deflection of the exported shape + */ +//============================================================================= +void VTKPlugin_IOperations_i::ExportVTK( GEOM::GEOM_Object_ptr theOriginal, + const char* theFileName, + const double theDeflection ) +{ + // duplicate the original shape + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate( theOriginal ); + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(GEOM_Object) anOriginal = GetObjectImpl( theOriginal ); + if (anOriginal.IsNull()) return; + + //Export the shape to the file + GetOperations()->ExportVTK( anOriginal, theFileName, theDeflection ); +} + +VTKPlugin_IOperations* VTKPlugin_IOperations_i::GetOperations() +{ + return (VTKPlugin_IOperations*)GetImpl(); +} diff --git a/src/VTKPlugin/VTKPlugin_IOperations_i.hh b/src/VTKPlugin/VTKPlugin_IOperations_i.hh new file mode 100644 index 000000000..1a0d0aec6 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_IOperations_i.hh @@ -0,0 +1,51 @@ +// 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 _VTKPlugin_IOperations_i_HeaderFile +#define _VTKPlugin_IOperations_i_HeaderFile + +// idl includes +#include +#include CORBA_SERVER_HEADER( GEOM_Gen ) +#include CORBA_SERVER_HEADER( VTKPlugin ) + +// internal includes +#include "VTKPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_IOperations_i.hh" + +class VTKPlugin_IOperations; + +class VTKPLUGINENGINE_EXPORT VTKPlugin_IOperations_i : + public virtual POA_GEOM::IVTKOperations, + public virtual GEOM_IOperations_i +{ +public: + VTKPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + VTKPlugin_IOperations* theImpl ); + ~VTKPlugin_IOperations_i(); + + void ExportVTK( GEOM::GEOM_Object_ptr, const char*, const double ); + + VTKPlugin_IOperations* GetOperations(); +}; + +#endif diff --git a/src/VTKPlugin/VTKPlugin_OperationsCreator.cxx b/src/VTKPlugin/VTKPlugin_OperationsCreator.cxx new file mode 100644 index 000000000..c71ab52ed --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_OperationsCreator.cxx @@ -0,0 +1,67 @@ +// 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 "VTKPlugin_OperationsCreator.hxx" +#include "VTKPlugin_IOperations_i.hh" +#include "VTKPlugin_IOperations.hxx" +#include "VTKPlugin_ExportDriver.hxx" +#include "VTKPlugin_IECallBack.hxx" + +// KERNEL includes +#include +#include + +// OCCT includes +#include + +std::map VTKPlugin_OperationsCreator::_mapOfOperations; + +VTKPlugin_OperationsCreator::VTKPlugin_OperationsCreator() +{ + // Register drivers + TFunction_DriverTable::Get()->AddDriver( VTKPlugin_ExportDriver::GetID(), + new VTKPlugin_ExportDriver() ); + + // Register callback + VTKPlugin_IECallBack* callback = new VTKPlugin_IECallBack(); + GEOMImpl_IECallBack::Register( "VTK", callback ); +} + +VTKPlugin_OperationsCreator::~VTKPlugin_OperationsCreator() +{ +} + +GEOM_IOperations_i* VTKPlugin_OperationsCreator::Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ) +{ + Unexpect aCatch( SALOME_SalomeException ); + MESSAGE( "VTKPlugin_OperationsCreator::Create" ); + return new VTKPlugin_IOperations_i( thePOA, theEngine, get( theGenImpl, theStudyId ) ); +} + +VTKPlugin_IOperations* VTKPlugin_OperationsCreator::get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ) +{ + if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) + _mapOfOperations[theStudyId] = new VTKPlugin_IOperations( theGenImpl, theStudyId ); + return _mapOfOperations[theStudyId]; +} diff --git a/src/VTKPlugin/VTKPlugin_OperationsCreator.hxx b/src/VTKPlugin/VTKPlugin_OperationsCreator.hxx new file mode 100755 index 000000000..9d9b1aeaf --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_OperationsCreator.hxx @@ -0,0 +1,57 @@ +// 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 _GEOM_VTKPlugin_OperationsCreator_HXX_ +#define _GEOM_VTKPlugin_OperationsCreator_HXX_ + +// internal includes +#include "VTKPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Gen_i.hh" + +// C++ includes +#include + +class VTKPlugin_IOperations; + +//===================================================================== +// Operations creator +//===================================================================== +class VTKPLUGINENGINE_EXPORT VTKPlugin_OperationsCreator : public GEOM_GenericOperationsCreator +{ +public: + VTKPlugin_OperationsCreator(); + ~VTKPlugin_OperationsCreator(); + + GEOM_IOperations_i* Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ); +private: + static VTKPlugin_IOperations* get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ); + +private: + static std::map _mapOfOperations; + + friend class VTKPlugin_IECallBack; +}; + +#endif diff --git a/src/VTKPlugin/VTKPlugin_msg_en.ts b/src/VTKPlugin/VTKPlugin_msg_en.ts new file mode 100644 index 000000000..720bfcac1 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_msg_en.ts @@ -0,0 +1,49 @@ + + + + + @default + + MEN_EXPORTVTK + VTK + + + TOP_EXPORTVTK + Export VTK + + + STB_EXPORTVTK + Export VTK + + + MEN_IMPORTVTK + VTK + + + TOP_IMPORTVTK + Import VTK + + + STB_IMPORTVTK + Import VTK + + + + VTKPlugin_GUI + + VTK_FILES + VTK files( *.vtk ) + + + EXPORT_TITLE + Export VTK + + + + VTKPlugin_ExportDlg + + DEFLECTION + Deflection + + + diff --git a/src/VTKPlugin/VTKPlugin_msg_fr.ts b/src/VTKPlugin/VTKPlugin_msg_fr.ts new file mode 100644 index 000000000..276a5ab48 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_msg_fr.ts @@ -0,0 +1,49 @@ + + + + + @default + + MEN_EXPORTVTK + VTK + + + TOP_EXPORTVTK + Exporter VTK + + + STB_EXPORTVTK + Exporter VTK + + + MEN_IMPORTVTK + VTK + + + TOP_IMPORTVTK + Importer VTK + + + STB_IMPORTVTK + Importer VTK + + + + VTKPlugin_GUI + + VTK_FILES + VTK fichiers( *.vtk ) + + + EXPORT_TITLE + Exporter VTK + + + + VTKPlugin_ExportDlg + + DEFLECTION + Déflexion + + + diff --git a/src/VTKPlugin/VTKPlugin_msg_ja.ts b/src/VTKPlugin/VTKPlugin_msg_ja.ts new file mode 100644 index 000000000..8b0df3ae8 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_msg_ja.ts @@ -0,0 +1,49 @@ + + + + + @default + + MEN_EXPORTVTK + VTK + + + TOP_EXPORTVTK + Export VTK + + + STB_EXPORTVTK + Export VTK + + + MEN_IMPORTVTK + VTK + + + TOP_IMPORTVTK + Import VTK + + + STB_IMPORTVTK + Import VTK + + + + VTKPlugin_GUI + + VTK_FILES + VTK files( *.vtk ) + + + EXPORT_TITLE + Export VTK + + + + VTKPlugin_ExportDlg + + DEFLECTION + Deflection + + + diff --git a/src/XAOPlugin/CMakeLists.txt b/src/XAOPlugin/CMakeLists.txt new file mode 100644 index 000000000..7d24c4345 --- /dev/null +++ b/src/XAOPlugin/CMakeLists.txt @@ -0,0 +1,151 @@ +# Copyright (C) 2012-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 +# + +IF(SALOME_BUILD_GUI) + INCLUDE(UseQt4Ext) + INCLUDE(${QT_USE_FILE}) +ENDIF() + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} + ${KERNEL_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR}/idl + ${PROJECT_SOURCE_DIR}/src/GEOMAlgo + ${PROJECT_SOURCE_DIR}/src/GEOM + ${PROJECT_SOURCE_DIR}/src/GEOMImpl + ${PROJECT_SOURCE_DIR}/src/GEOM_I + ${PROJECT_SOURCE_DIR}/src/GEOMClient + ${PROJECT_SOURCE_DIR}/src/GEOMUtils + ${PROJECT_SOURCE_DIR}/src/XAO + ) + +IF(SALOME_BUILD_GUI) + INCLUDE_DIRECTORIES( + ${QT_INCLUDE_DIRS} + ${GUI_INCLUDE_DIRS} + ${PROJECT_SOURCE_DIR}/src/OBJECT + ${PROJECT_SOURCE_DIR}/src/GEOMGUI + ${PROJECT_SOURCE_DIR}/src/GEOMBase + ${PROJECT_SOURCE_DIR}/src/DlgRef + ) +ENDIF() + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${CAS_DEFINITIONS} + ) + +IF(SALOME_BUILD_GUI) +ADD_DEFINITIONS( + ${QT_DEFINITIONS} + ) +ENDIF() + +# libraries to link to +SET(_link_engine_LIBRARIES + ${CAS_TKXAO} + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + SalomeIDLGEOM + SalomeIDLXAOPlugin + GEOMEngine + GEOMClient + XAO + ) + +IF(SALOME_BUILD_GUI) + SET(_link_gui_LIBRARIES + SalomeIDLXAOPlugin + DlgRef + GEOMObject + GEOM + GEOMBase + ) +ENDIF() + +# --- headers --- + +SET(XAOPluginEngine_HEADERS + XAOPlugin_IOperations_i.hh + XAOPlugin_Engine.hxx + XAOPlugin_OperationsCreator.hxx + XAOPlugin_IOperations.hxx + XAOPlugin_IImportExport.hxx + XAOPlugin_Driver.hxx + XAOPlugin_IECallBack.hxx + ) + +IF(SALOME_BUILD_GUI) + # header files / to be processed by moc + SET(_moc_HEADERS + XAOPlugin_ExportDlg.h + XAOPlugin_ImportDlg.h + ) +ENDIF() + +# --- sources --- + +IF(SALOME_BUILD_GUI) + # sources / moc wrappings + QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) + + SET(XAOPluginGUI_SOURCES + XAOPlugin_GUI.cxx + XAOPlugin_ExportDlg.cxx + XAOPlugin_ImportDlg.cxx + ${_moc_SOURCES} + ) +ENDIF() + +SET(XAOPluginEngine_SOURCES + XAOPlugin_Engine.cxx + XAOPlugin_OperationsCreator.cxx + XAOPlugin_IOperations_i.cc + XAOPlugin_IOperations.cxx + XAOPlugin_Driver.cxx + XAOPlugin_IECallBack.cxx + ) + +# resource files / to be processed by lrelease +SET(XAOPlugin_RESOURCES + XAOPlugin_images.ts + XAOPlugin_msg_en.ts + XAOPlugin_msg_fr.ts + XAOPlugin_msg_ja.ts + ) + +# --- rules --- + +ADD_LIBRARY(XAOPluginEngine ${XAOPluginEngine_SOURCES}) +TARGET_LINK_LIBRARIES(XAOPluginEngine ${_link_engine_LIBRARIES}) +INSTALL(TARGETS XAOPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +IF(SALOME_BUILD_GUI) + ADD_LIBRARY(XAOPluginGUI ${XAOPluginGUI_SOURCES}) + TARGET_LINK_LIBRARIES(XAOPluginGUI ${_link_gui_LIBRARIES}) + INSTALL(TARGETS XAOPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + + QT4_INSTALL_TS_RESOURCES("${XAOPlugin_RESOURCES}" "${SALOME_GEOM_INSTALL_RES_DATA}") +ENDIF() + + +INSTALL(FILES ${XAOPluginEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/XAOPlugin/XAOPlugin_Driver.cxx b/src/XAOPlugin/XAOPlugin_Driver.cxx new file mode 100644 index 000000000..1c16ae792 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_Driver.cxx @@ -0,0 +1,105 @@ +// Copyright (C) 2013-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 "XAOPlugin_Driver.hxx" +#include "XAOPlugin_IImportExport.hxx" + +// GEOM includes +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include + +// OCC includes +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& XAOPlugin_Driver::GetID() +{ + static Standard_GUID aGUID("FF1BBB71-5D14-4df2-980B-3A668264EA16"); + return aGUID; +} + +//======================================================================= +//function : XAOPlugin_Driver +//purpose : +//======================================================================= +XAOPlugin_Driver::XAOPlugin_Driver() +{ +} + +//======================================================================= +//function : ~XAOPlugin_Driver +//purpose : +//======================================================================= +XAOPlugin_Driver::~XAOPlugin_Driver() +{ +} + +Standard_Boolean XAOPlugin_Driver::MustExecute(const TFunction_Logbook&) const +{ + return Standard_True; +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer XAOPlugin_Driver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); + + XAOPlugin_IImportExport iexao(function); + TCollection_AsciiString xao = iexao.GetData(); + + TopoDS_Shape shape; + + Standard_Integer functionType = function->GetType(); + if (functionType == EXPORT_SHAPE) + { + } + else if (functionType == IMPORT_SHAPE) + { + } + else + { + // other construction modes here + } + + if (shape.IsNull()) return 0; + function->SetValue(shape); + + log.SetTouched(Label()); + + return 1; +} + +IMPLEMENT_STANDARD_HANDLE (XAOPlugin_Driver, TFunction_Driver); +IMPLEMENT_STANDARD_RTTIEXT(XAOPlugin_Driver, TFunction_Driver); + diff --git a/src/XAOPlugin/XAOPlugin_Driver.hxx b/src/XAOPlugin/XAOPlugin_Driver.hxx new file mode 100644 index 000000000..855b533d1 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_Driver.hxx @@ -0,0 +1,48 @@ +// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 _XAOPlugin_Driver_HXX +#define _XAOPlugin_Driver_HXX + +// internal includes +#include "XAOPlugin_Engine.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE(XAOPlugin_Driver, TFunction_Driver); + +class XAOPLUGINENGINE_EXPORT XAOPlugin_Driver: public TFunction_Driver +{ +public: + XAOPlugin_Driver(); + ~XAOPlugin_Driver(); + + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute(TFunction_Logbook& log) const; + Standard_Boolean MustExecute(const TFunction_Logbook&) const; + virtual void Validate(TFunction_Logbook&) const {} + +DEFINE_STANDARD_RTTI(XAOPlugin_Driver) +}; + +#endif // _XAOPlugin_Driver_HXX diff --git a/src/XAOPlugin/XAOPlugin_Engine.cxx b/src/XAOPlugin/XAOPlugin_Engine.cxx new file mode 100644 index 000000000..e78ce5a47 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_Engine.cxx @@ -0,0 +1,31 @@ +// 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 "XAOPlugin_Engine.hxx" +#include "XAOPlugin_OperationsCreator.hxx" + +extern "C" +{ + XAOPLUGINENGINE_EXPORT + GEOM_GenericOperationsCreator* GetOperationsCreator() + { + return new XAOPlugin_OperationsCreator(); + } +} diff --git a/src/XAOPlugin/XAOPlugin_Engine.hxx b/src/XAOPlugin/XAOPlugin_Engine.hxx new file mode 100755 index 000000000..9dd44dce1 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_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 _XAOPLUGIN_ENGINE_HXX_ +#define _XAOPLUGIN_ENGINE_HXX_ + +#ifdef WIN32 + #if defined XAOPLUGINENGINE_EXPORTS || defined XAOPluginEngine_EXPORTS + #define XAOPLUGINENGINE_EXPORT __declspec( dllexport ) + #else + #define XAOPLUGINENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define XAOPLUGINENGINE_EXPORT +#endif + +#endif diff --git a/src/XAOPlugin/XAOPlugin_ExportDlg.cxx b/src/XAOPlugin/XAOPlugin_ExportDlg.cxx new file mode 100644 index 000000000..01e570f64 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_ExportDlg.cxx @@ -0,0 +1,456 @@ +// Copyright (C) 2013-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 "XAOPlugin_ExportDlg.h" +#include "XAOPlugin_IOperations_i.hh" + +// GUI includes +#include +#include +#include +#include + +#include +#include +#include +#include + +// GEOM includes +#include "GeometryGUI.h" +#include "GEOMBase.h" +#include "GEOMImpl_Types.hxx" + +// OCCT Includes +#include +#include +#include +#include +#include + +// QT includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// Constructor +//================================================================================= +XAOPlugin_ExportDlg::XAOPlugin_ExportDlg(GeometryGUI* geometryGUI, QWidget* parent) +: + GEOMBase_Skeleton(geometryGUI, parent, false) +{ + m_mainObj = GEOM::GEOM_Object::_nil(); + + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + QPixmap imageOp(resMgr->loadPixmap("GEOM", tr("XAOPLUGIN_EXPORT_ICON"))); + QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("XAOPLUGIN_EXPORT_TITLE")); + + /***************************************************************/ + mainFrame()->GroupConstructors->setTitle(tr("XAOPLUGIN_EXPORT_TITLE")); + mainFrame()->RadioButton1->setIcon(imageOp); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->close(); + + // hide name + mainFrame()->GroupBoxName->hide(); + + //**************************** + // Selection Group box + QGroupBox* gbxExport = new QGroupBox(parent); + + QGridLayout* gridLayoutExport = new QGridLayout(gbxExport); +#ifndef Q_OS_MAC + gridLayoutExport->setSpacing(6); + gridLayoutExport->setContentsMargins(9, 9, 9, 9); +#endif + gridLayoutExport->setObjectName(QString::fromUtf8("gridLayoutExport")); + + // Line 0 + QLabel* lblShape = new QLabel(tr("XAOPLUGIN_EXPORT_INGSHAPE"), gbxExport); + btnShapeSelect = new QPushButton(gbxExport); + btnShapeSelect->setIcon(iconSelect); + ledShape = new QLineEdit(gbxExport); + ledShape->setMinimumSize(QSize(100, 0)); + + int line = 0, col = 0; + gridLayoutExport->addWidget(lblShape, line, col++, 1, 1); + gridLayoutExport->addWidget(btnShapeSelect, line, col++, 1, 1); + gridLayoutExport->addWidget(ledShape, line, col++, 1, 1); + + // Line 1 + QLabel* lblFileName = new QLabel(tr("XAOPLUGIN_EXPORT_FILENAME"), gbxExport); + btnFileSelect = new QPushButton(gbxExport); + ledFileName = new QLineEdit(gbxExport); + btnFileSelect->setText("..."); + + line++; col = 0; + gridLayoutExport->addWidget(lblFileName, line, col++, 1, 1); + gridLayoutExport->addWidget(btnFileSelect, line, col++, 1, 1); + gridLayoutExport->addWidget(ledFileName, line, col++, 1, 1); + + // Line 2 + QLabel* lblAuthor = new QLabel(tr("XAOPLUGIN_EXPORT_AUTHOR"), gbxExport); + ledAuthor = new QLineEdit(gbxExport); + + line++; col = 0; + gridLayoutExport->addWidget(lblAuthor, line, col++, 2, 1); + col++; // span + gridLayoutExport->addWidget(ledAuthor, line, col++, 1, 1); + + //**************************** + // Filter Group box + QGroupBox* gbxFilter = new QGroupBox(parent); + + QGridLayout* gridLayoutFilter = new QGridLayout(gbxFilter); +#ifndef Q_OS_MAC + gridLayoutFilter->setSpacing(6); + gridLayoutFilter->setContentsMargins(9, 9, 9, 9); +#endif + gridLayoutFilter->setObjectName(QString::fromUtf8("gbxFilter")); + + // Line 0 + QLabel* lblGroups = new QLabel(tr("XAOPLUGIN_EXPORT_LGROUPS"), gbxFilter); + QLabel* lblFields = new QLabel(tr("XAOPLUGIN_EXPORT_LFIELDS"), gbxFilter); + + line = 0, col = 0; + gridLayoutFilter->addWidget(lblGroups, line, col++, 1, 1); + gridLayoutFilter->addWidget(lblFields, line, col++, 1, 1); + + // Line 1 + lstGroups = new QListWidget(gbxFilter); + lstGroups->setSelectionMode(QAbstractItemView::NoSelection); + lstFields = new QListWidget(gbxFilter); + lstFields->setSelectionMode(QAbstractItemView::NoSelection); + + line++; col = 0; + gridLayoutFilter->addWidget(lstGroups, line, col++, 1, 1); + gridLayoutFilter->addWidget(lstFields, line, col++, 1, 1); + + //**************************** + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); + layout->setSpacing(6); + layout->addWidget(gbxExport); + layout->addWidget(gbxFilter); + + // set help + setHelpFileName("xao_format_page.html"); + + Init(); +} + +//================================================================================= +// Destructor +//================================================================================= +XAOPlugin_ExportDlg::~XAOPlugin_ExportDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void XAOPlugin_ExportDlg::Init() +{ + // Get setting of step value from file configuration + m_groups.clear(); + m_fields.clear(); + + // Signal/slot connections + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(btnShapeSelect, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(((SalomeApp_Application*) (SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked())); + + initName(tr("XAOPLUGIN_EXPORTXAO")); + SelectionIntoArgument(); +} + +//================================================================================= +// function : processObject() +// purpose : Fill dialog fields in accordance with myObj +//================================================================================= +void XAOPlugin_ExportDlg::processObject() +{ + lstGroups->clear(); + lstFields->clear(); + m_groups.clear(); + m_fields.clear(); + + if (m_mainObj->_is_nil()) + { + ledShape->setText(""); + } + else + { + ledShape->setText(GEOMBase::GetName(m_mainObj)); + GEOM::GEOM_IShapesOperations_var shapeOp = getGeomEngine()->GetIShapesOperations(getStudyId()); + + // add groups names + GEOM::ListOfGO_var groups = shapeOp->GetExistingSubObjects(m_mainObj, true); + for (int i = 0, n = groups->length(); i < n; i++) + { + QListWidgetItem* item = new QListWidgetItem(); + item->setData(Qt::UserRole, QVariant(i)); + item->setText(GEOMBase::GetName(groups[i])); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Checked); + lstGroups->addItem(item); + m_groups.append(GEOM::GeomObjPtr(groups[i].in())); + } + lstGroups->sortItems(Qt::AscendingOrder); + + // add fields + GEOM::GEOM_IFieldOperations_var fieldOp = getGeomEngine()->GetIFieldOperations(getStudyId()); + + GEOM::ListOfFields_var fields = fieldOp->GetFields(m_mainObj); + for (int i = 0, n = fields->length(); i < n; i++) + { + QListWidgetItem* item = new QListWidgetItem(); + item->setData(Qt::UserRole, QVariant(i)); + item->setText(fields[i]->GetName()); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Checked); + lstFields->addItem(item); + m_fields.append(GEOM::GeomFieldPtr(fields[i].in())); + } + lstFields->sortItems(Qt::AscendingOrder); + } +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void XAOPlugin_ExportDlg::ClickOnOk() +{ + setIsApplyAndClose(true); + if (ClickOnApply()) + ClickOnCancel(); + setIsApplyAndClose(false); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool XAOPlugin_ExportDlg::ClickOnApply() +{ + if (!isApplyAndClose()) + { + setIsDisableBrowsing(true); + setIsDisplayResult(false); + } + + QString msg; + if (!isValid(msg)) + { + showError(msg); + return false; + } + SUIT_OverrideCursor wc; + SUIT_Session::session()->activeApplication()->putInfo(""); + + try + { + if (openCommand()) + if (!execute()) + { + abortCommand(); + showError(); + return false; + } + } + catch (const SALOME::SALOME_Exception& e) + { + SalomeApp_Tools::QtCatchCorbaException(e); + abortCommand(); + return false; + } + commitCommand(); + + if (!isApplyAndClose()) + { + setIsDisableBrowsing(false); + setIsDisplayResult(true); + } + + processObject(); + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void XAOPlugin_ExportDlg::SelectionIntoArgument() +{ + m_mainObj = GEOM::GEOM_Object::_nil(); + LightApp_SelectionMgr* selMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO selList; + selMgr->selectedObjects(selList); + + if (selList.Extent() == 1) + { + m_mainObj = GEOMBase::ConvertIOinGEOMObject(selList.First()); + } + + processObject(); +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void XAOPlugin_ExportDlg::SetEditCurrentArgument() +{ + ledShape->setFocus(); + myEditCurrentArgument = ledShape; + SelectionIntoArgument(); +} + +//================================================================================= +// function : btnFileSelectClicked() +// purpose : +//================================================================================= +void XAOPlugin_ExportDlg::btnFileSelectClicked() +{ + QString file = SUIT_FileDlg::getFileName(this, ledFileName->text(), + tr("XAOPLUGIN_FILES"), + tr("XAOPLUGIN_EXPORT_SELECT"), false); + if ( !file.isEmpty() ) + ledFileName->setText( file ); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void XAOPlugin_ExportDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); +} + +//================================================================================= +// function : enterEvent [REDEFINED] +// purpose : +//================================================================================= +void XAOPlugin_ExportDlg::enterEvent(QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr XAOPlugin_ExportDlg::createOperation() +{ + return getGeomEngine()->GetPluginOperations( getStudyId(), "XAOPluginEngine" ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool XAOPlugin_ExportDlg::isValid(QString& msg) +{ + // check shape + if (ledShape->text().isEmpty()) + return false; + + // check file name + if (ledFileName->text().isEmpty()) + return false; + + return true; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool XAOPlugin_ExportDlg::execute() +{ + bool res = false; + + QString author = ledAuthor->text(); + QString fileName = ledFileName->text(); + + // get selected groups + QList selGroups; + for (int j = 0; j < lstGroups->count(); ++j) + { + if (lstGroups->item(j)->checkState() == Qt::Checked) + selGroups.append(lstGroups->item(j)); + } + + GEOM::ListOfGO_var groups = new GEOM::ListOfGO(); + groups->length(selGroups.count()); + int i = 0; + for (QList::iterator it = selGroups.begin(); it != selGroups.end(); ++it) + { + QListWidgetItem* item = (*it); + int index = item->data(Qt::UserRole).toInt(); + groups[i++] = m_groups[index].copy(); + } + + // get selected fields + QList selFields; + for (int j = 0; j < lstFields->count(); ++j) + { + if (lstFields->item(j)->checkState() == Qt::Checked) + selFields.append(lstFields->item(j)); + } + + GEOM::ListOfFields_var fields = new GEOM::ListOfFields(); + fields->length(selFields.count()); + i = 0; + for (QList::iterator it = selFields.begin(); it != selFields.end(); ++it) + { + QListWidgetItem* item = (*it); + int index = item->data(Qt::UserRole).toInt(); + fields[i++] = m_fields[index].copy(); + } + + // call engine function + GEOM::IXAOOperations_var aXAOOp = GEOM::IXAOOperations::_narrow( getOperation() ); + res = aXAOOp->ExportXAO(m_mainObj, groups, fields, + author.toStdString().c_str(), + fileName.toStdString().c_str()); + return res; +} diff --git a/src/XAOPlugin/XAOPlugin_ExportDlg.h b/src/XAOPlugin/XAOPlugin_ExportDlg.h new file mode 100644 index 000000000..a2338e2e5 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_ExportDlg.h @@ -0,0 +1,75 @@ +// Copyright (C) 2013-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 XAOPlugin_ExportDlg_H +#define XAOPlugin_ExportDlg_H + +// GEOM includes +#include "GEOMBase_Skeleton.h" + +class QLineEdit; +class QButtonGroup; +class QListWidget; +class QPushButton; + +//================================================================================= +// class : XAOPlugin_ExportDlg +// purpose : +//================================================================================= +class XAOPlugin_ExportDlg: public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + XAOPlugin_ExportDlg(GeometryGUI*, QWidget* = 0); + ~XAOPlugin_ExportDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid(QString&); + virtual bool execute(); + +private: + void Init(); + void enterEvent(QEvent*); + void processObject(); + +private: + GEOM::GEOM_Object_var m_mainObj; + QList m_groups; + QList m_fields; + QLineEdit* ledShape; + QLineEdit* ledFileName; + QLineEdit* ledAuthor; + QListWidget* lstGroups; + QListWidget* lstFields; + QPushButton* btnShapeSelect; + QPushButton* btnFileSelect; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void btnFileSelectClicked(); +}; + +#endif // XAOPlugin_ExportDlg_H diff --git a/src/XAOPlugin/XAOPlugin_GUI.cxx b/src/XAOPlugin/XAOPlugin_GUI.cxx new file mode 100644 index 000000000..6bb816445 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_GUI.cxx @@ -0,0 +1,102 @@ +// 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 "XAOPlugin_GUI.h" +#include "XAOPlugin_ExportDlg.h" +#include "XAOPlugin_ImportDlg.h" + +// GUI includes +#include +#include + +// GEOM includes +#include "GeometryGUI.h" + +//======================================================================= +// function : XAOPlugin_GUI() +// purpose : Constructor +//======================================================================= +XAOPlugin_GUI::XAOPlugin_GUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) +{ +} + +//======================================================================= +// function : ~XAOPlugin_GUI +// purpose : Destructor +//======================================================================= +XAOPlugin_GUI::~XAOPlugin_GUI() +{ +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool XAOPlugin_GUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) +{ + switch ( theCommandID ) { + case 1: + return OnGUIEvent("Export_XAO", parent); + case 2: + return OnGUIEvent("Import_XAO", parent); + default: + return OnGUIEvent("", parent); + } + return false; +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool XAOPlugin_GUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if (!app) return false; + + getGeometryGUI()->EmitSignalDeactivateDialog(); + + QDialog* dialog = NULL; + if( theCommandID == "Export_XAO" ) + dialog = new XAOPlugin_ExportDlg(getGeometryGUI(), parent); + else if( theCommandID == "Import_XAO" ) + dialog = new XAOPlugin_ImportDlg(getGeometryGUI(), parent); + else + app->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) ); + + if (dialog != NULL) + dialog->show(); + + return true; +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ +#ifdef WIN32 + __declspec( dllexport ) +#endif + GEOMGUI* GetLibGUI(GeometryGUI* parent) + { + return new XAOPlugin_GUI(parent); + } +} diff --git a/src/XAOPlugin/XAOPlugin_GUI.h b/src/XAOPlugin/XAOPlugin_GUI.h new file mode 100644 index 000000000..bbd83db36 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_GUI.h @@ -0,0 +1,39 @@ +// 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 XAOPlugin_GUI_H +#define XAOPlugin_GUI_H + +#include "GEOMPluginGUI.h" + +//================================================================================= +// class : XAOPlugin_GUI +// purpose : +//================================================================================= +class XAOPlugin_GUI: public GEOMPluginGUI +{ +public: + XAOPlugin_GUI(GeometryGUI* parent); + ~XAOPlugin_GUI(); + + bool OnGUIEvent( int commandId, SUIT_Desktop* ); + bool OnGUIEvent( const QString&, SUIT_Desktop* ); +}; + +#endif // XAOPlugin_GUI_H diff --git a/src/XAOPlugin/XAOPlugin_IECallBack.cxx b/src/XAOPlugin/XAOPlugin_IECallBack.cxx new file mode 100644 index 000000000..f6b19e580 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_IECallBack.cxx @@ -0,0 +1,97 @@ +// 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 "XAOPlugin_IECallBack.hxx" +#include "XAOPlugin_IOperations.hxx" +#include "XAOPlugin_OperationsCreator.hxx" +#include "GEOMImpl_IShapesOperations.hxx" + +//============================================================================= +/*! + * constructor + */ +//============================================================================= +XAOPlugin_IECallBack::XAOPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +XAOPlugin_IECallBack::~XAOPlugin_IECallBack() +{ +} + +//============================================================================= +/*! + * Export + */ +//============================================================================= +bool +XAOPlugin_IECallBack::Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ) +{ + XAOPlugin_IOperations* aPluginOperations = XAOPlugin_OperationsCreator::get( GetEngine(), theDocId ); + GEOMImpl_IShapesOperations* aShapesOperations = GetEngine()->GetIShapesOperations( theDocId ); + + Handle(TColStd_HSequenceOfTransient) groups = aShapesOperations->GetExistingSubObjects( theOriginal, GEOMImpl_IShapesOperations::Groups ); + Handle(TColStd_HSequenceOfTransient) fields = aShapesOperations->GetExistingSubObjects( theOriginal, GEOMImpl_IShapesOperations::Fields ); + std::list lgroups; + std::list lfields; + for (int i = 1; i <= groups->Length(); i++) + lgroups.push_back( Handle(GEOM_Object)::DownCast( groups->Value(i) ) ); + for (int i = 1; i <= fields->Length(); i++) + lfields.push_back( Handle(GEOM_Field)::DownCast( fields->Value(i) ) ); + aPluginOperations->ExportXAO( theOriginal, lgroups, lfields, "SIMAN Author", theFileName.ToCString() ); + return true; +} + +//============================================================================= +/*! + * Import + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) +XAOPlugin_IECallBack::Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ) +{ + XAOPlugin_IOperations* aPluginOperations = XAOPlugin_OperationsCreator::get( GetEngine(), theDocId ); + + Handle(TColStd_HSequenceOfTransient) result = new TColStd_HSequenceOfTransient(); + Handle(TColStd_HSequenceOfTransient) subshapes = new TColStd_HSequenceOfTransient(); + Handle(TColStd_HSequenceOfTransient) groups = new TColStd_HSequenceOfTransient(); + Handle(TColStd_HSequenceOfTransient) fields = new TColStd_HSequenceOfTransient(); + Handle(GEOM_Object) shape; + + bool ok = aPluginOperations->ImportXAO( theFileName.ToCString(), shape, subshapes, groups, fields ); + if ( ok ) { + result->Append( shape ); + for ( int i = 1; i <= groups->Length(); i++ ) + result->Append( groups->Value(i) ); + for ( int i = 1; i <= fields->Length(); i++ ) + result->Append( fields->Value(i) ); + } + return result; +} diff --git a/src/XAOPlugin/XAOPlugin_IECallBack.hxx b/src/XAOPlugin/XAOPlugin_IECallBack.hxx new file mode 100644 index 000000000..50168eac9 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_IECallBack.hxx @@ -0,0 +1,50 @@ +// 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 _XAOPlugin_IECallBack_HXX_ +#define _XAOPlugin_IECallBack_HXX_ + +// internal includes +#include "XAOPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Object.hxx" +#include "GEOMImpl_IECallBack.hxx" + +// OCC includes +#include + +class XAOPLUGINENGINE_EXPORT XAOPlugin_IECallBack : public GEOMImpl_IECallBack +{ +public: + XAOPlugin_IECallBack(); + ~XAOPlugin_IECallBack(); + + virtual bool Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ); + + virtual + Handle(TColStd_HSequenceOfTransient) Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ); +}; + +#endif diff --git a/src/XAOPlugin/XAOPlugin_IImportExport.hxx b/src/XAOPlugin/XAOPlugin_IImportExport.hxx new file mode 100644 index 000000000..4f5727536 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_IImportExport.hxx @@ -0,0 +1,39 @@ +// Copyright (C) 2013-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 _XAOPlugin_IImportExport_HXX_ +#define _XAOPlugin_IImportExport_HXX_ + +#include "GEOM_Function.hxx" + +#define IMPORTEXPORTXAO_ARG_DATA 1 + +class XAOPlugin_IImportExport +{ +public: + XAOPlugin_IImportExport(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetData(const TCollection_AsciiString& data) { _func->SetString(IMPORTEXPORTXAO_ARG_DATA, data); } + const TCollection_AsciiString GetData() { return _func->GetString(IMPORTEXPORTXAO_ARG_DATA); } + +private: + Handle(GEOM_Function) _func; +}; + +#endif // _XAOPlugin_IImportExport_HXX_ diff --git a/src/XAOPlugin/XAOPlugin_IOperations.cxx b/src/XAOPlugin/XAOPlugin_IOperations.cxx new file mode 100644 index 000000000..a2eae44db --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_IOperations.cxx @@ -0,0 +1,670 @@ +// 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 "XAOPlugin_IOperations.hxx" +#include "XAOPlugin_Driver.hxx" +#include "XAOPlugin_IImportExport.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include "GEOM_PythonDump.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOMImpl_IGroupOperations.hxx" +#include "GEOMImpl_IShapesOperations.hxx" +#include "GEOMImpl_IFieldOperations.hxx" +#include "GEOM_ISubShape.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +// OCC includes +#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 +#include +#include +#else +#include +#endif +#include + + +XAO::Dimension shapeEnumToDimension(const TopAbs_ShapeEnum& shape) +{ + XAO::Dimension dim; + switch( shape ) { + case TopAbs_VERTEX: + dim = XAO::VERTEX; break; + case TopAbs_EDGE: + dim = XAO::EDGE; break; + case TopAbs_FACE: + dim = XAO::FACE; break; + case TopAbs_SOLID: + dim = XAO::SOLID; break; + default: + throw SALOME_Exception("Bad type"); // TODO + } + return dim; +} + +TopAbs_ShapeEnum getGroupDimension(XAO::Group* group) +{ + XAO::Dimension dim = group->getDimension(); + TopAbs_ShapeEnum rdim; + switch ( dim ) + { + case XAO::VERTEX: + rdim = TopAbs_VERTEX; break; + case XAO::EDGE: + rdim = TopAbs_EDGE; break; + case XAO::FACE: + rdim = TopAbs_FACE; break; + case XAO::SOLID: + rdim = TopAbs_SOLID; break; + default: + rdim = TopAbs_COMPOUND; break; + } + return rdim; +} + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +XAOPlugin_IOperations::XAOPlugin_IOperations( GEOM_Engine* theEngine, int theDocID ) +: GEOMImpl_IBaseIEOperations( theEngine, theDocID ) +{ + MESSAGE( "XAOPlugin_IOperations::XAOPlugin_IOperations" ); +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +XAOPlugin_IOperations::~XAOPlugin_IOperations() +{ + MESSAGE( "XAOPlugin_IOperations::~XAOPlugin_IOperations" ); +} + +void XAOPlugin_IOperations::exportGroups( std::list groupList, + XAO::Xao* xaoObject, + XAO::BrepGeometry* geometry ) +{ + // add the groups + std::list::iterator groupIterator = groupList.begin(); + while (groupIterator != groupList.end()) + { + Handle(GEOM_Object) currGroup = (*groupIterator++); + Handle(TColStd_HArray1OfInteger) groupIds = myGroupOperations->GetObjects(currGroup); + + TopAbs_ShapeEnum shapeGroup = myGroupOperations->GetType(currGroup); + XAO::Dimension dim = shapeEnumToDimension(shapeGroup); + XAO::Group* group = xaoObject->addGroup(dim, currGroup->GetName().ToCString()); + + switch (shapeGroup) + { + case TopAbs_VERTEX: + for (int i = 1; i <= groupIds->Length(); i++) + { + std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i)); + int index = geometry->getVertexIndexByReference(ref); + group->add(index); + } + break; + case TopAbs_EDGE: + for (int i = 1; i <= groupIds->Length(); i++) + { + std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i)); + int index = geometry->getEdgeIndexByReference(ref); + group->add(index); + } + break; + case TopAbs_FACE: + for (int i = 1; i <= groupIds->Length(); i++) + { + std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i)); + int index = geometry->getFaceIndexByReference(ref); + group->add(index); + } + break; + case TopAbs_SOLID: + for (int i = 1; i <= groupIds->Length(); i++) + { + std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i)); + int index = geometry->getSolidIndexByReference(ref); + group->add(index); + } + break; + } + } +} + +void XAOPlugin_IOperations::exportFields( std::list fieldList, + XAO::Xao* xaoObject, + XAO::BrepGeometry* geometry ) +{ + std::list::iterator fieldIterator = fieldList.begin(); + while (fieldIterator != fieldList.end()) + { + Handle(GEOM_Field) currField = (*fieldIterator++); + + int fdim = currField->GetDimension(); + int ftype = currField->GetDataType(); + int nbComponents = currField->GetNbComponents(); + std::string name = currField->GetName().ToCString(); + + XAO::Field* field = xaoObject->addField((XAO::Type)ftype, (XAO::Dimension)fdim, nbComponents, name); + + Handle(TColStd_HArray1OfExtendedString) components = currField->GetComponents(); + for (int i = components->Lower(), j = 0; i <= components->Upper(); ++i, ++j) + { + field->setComponentName(j, TCollection_AsciiString(components->Value(i)).ToCString()); + } + + std::list< Handle(GEOM_FieldStep)> steps = currField->GetSteps(); + std::list::iterator stepIterator = steps.begin(); + while (stepIterator != steps.end()) + { + Handle(GEOM_FieldStep) currStep = (*stepIterator++); + + XAO::Step* step = field->addNewStep(currStep->GetID()); + step->setStamp(currStep->GetStamp()); + + switch (ftype) + { + case 0: // bool + { + XAO::BooleanStep* bs = (XAO::BooleanStep*)step; + Handle(TColStd_HArray1OfInteger) bvalues = currStep->GetIntValues(); + std::vector bv; + bv.reserve(bvalues->Upper()); + for ( int i = bvalues->Lower(), nb = bvalues->Upper(); i <= nb; ++i ) + { + bv.push_back(bvalues->Value(i) != 0); + } + bs->setValues(bv); + break; + } + case 1: // integer + { + XAO::IntegerStep* is = (XAO::IntegerStep*)step; + Handle(TColStd_HArray1OfInteger) ivalues = currStep->GetIntValues(); + std::vector iv; + iv.reserve(ivalues->Upper()); + for ( int i = ivalues->Lower(), nb = ivalues->Upper(); i <= nb; ++i ) + { + iv.push_back(ivalues->Value(i)); + } + is->setValues(iv); + break; + } + case 2: // double + { + XAO::DoubleStep* ds = (XAO::DoubleStep*)step; + Handle(TColStd_HArray1OfReal) dvalues = currStep->GetDoubleValues(); + std::vector dv; + dv.reserve(dvalues->Upper()); + for ( int i = dvalues->Lower(), nb = dvalues->Upper(); i <= nb; ++i ) + { + dv.push_back(dvalues->Value(i)); + } + ds->setValues(dv); + break; + } + case 3: // string + { + XAO::StringStep* ss = (XAO::StringStep*)step; + Handle(TColStd_HArray1OfExtendedString) svalues = currStep->GetStringValues(); + std::vector sv; + sv.reserve(svalues->Upper()); + for ( int i = svalues->Lower(), nb = svalues->Upper(); i <= nb; ++i ) + { + sv.push_back(TCollection_AsciiString(svalues->Value(i)).ToCString()); + } + ss->setValues(sv); + break; + } + } + } + } +} + +void XAOPlugin_IOperations::exportSubshapes( const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry ) +{ + Handle(TColStd_HSequenceOfTransient) subObjects = myShapesOperations->GetExistingSubObjects( shape, false ); + int nbSubObjects = subObjects->Length(); + // set the names of the sub shapes + for (int i = 1; i <= nbSubObjects; i++) + { + Handle(Standard_Transient) transientSubObject = subObjects->Value(i); + if (transientSubObject.IsNull()) + continue; + + Handle(GEOM_Object) subObject = Handle(GEOM_Object)::DownCast( transientSubObject ); + if (subObject->GetType() != GEOM_GROUP) + { + int subIndex = myShapesOperations->GetSubShapeIndex( shape, subObject ); + switch (subObject->GetValue().ShapeType()) + { + case TopAbs_VERTEX: + geometry->changeVertexName(subIndex, subObject->GetName().ToCString()); + break; + case TopAbs_EDGE: + geometry->changeEdgeName(subIndex, subObject->GetName().ToCString()); + break; + case TopAbs_FACE: + geometry->changeFaceName(subIndex, subObject->GetName().ToCString()); + break; + case TopAbs_SOLID: + geometry->changeSolidName(subIndex, subObject->GetName().ToCString()); + break; + } + } + } +} + +//============================================================================= +/*! + * Export a shape to XAO format + * \param shape The shape to export + * \param groups The list of groups to export + * \param fields The list of fields to export + * \param fileName The name of the file to exported + * \return boolean indicating if export was succeful. + */ +//============================================================================= +bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape, + std::list groupList, + std::list fieldList, + const char* author, + const char* fileName ) +{ + SetErrorCode(KO); + + if (shape.IsNull()) return false; + + // add a new shape function with parameters + Handle(GEOM_Function) lastFunction = shape->GetLastFunction(); + if (lastFunction.IsNull()) return false; + + // add a new result object + Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT); + + // add an Export function + Handle(GEOM_Function) exportFunction = result->AddFunction(XAOPlugin_Driver::GetID(), EXPORT_SHAPE); + if (exportFunction.IsNull()) return false; + if (exportFunction->GetDriverGUID() != XAOPlugin_Driver::GetID()) return false; + + // create the XAO object + XAO::Xao* xaoObject = new XAO::Xao(); + xaoObject->setAuthor(author); + + // add the geometry + XAO::BrepGeometry* geometry = (XAO::BrepGeometry*)XAO::Geometry::createGeometry(XAO::BREP); + TopoDS_Shape topoShape = shape->GetValue(); + exportFunction->SetValue(topoShape); + XAO::BrepGeometry* brep = (XAO::BrepGeometry*)geometry; + brep->setTopoDS_Shape(topoShape); + + geometry->setName(shape->GetName().ToCString()); + exportSubshapes(shape, geometry); + xaoObject->setGeometry(geometry); + + exportGroups(groupList, xaoObject, geometry); + exportFields(fieldList, xaoObject, geometry); + + // export the XAO to the file + xaoObject->exportXAO(fileName); + + // make a Python command + GEOM::TPythonDump pd(exportFunction); + pd << "exported = geompy.ExportXAO(" << shape; + + // list of groups + pd << ", ["; + if (groupList.size() > 0) + { + std::list::iterator itGroup = groupList.begin(); + pd << (*itGroup++); + while (itGroup != groupList.end()) + { + pd << ", " << (*itGroup++); + } + } + + // list of fields + pd << "], ["; + if (fieldList.size() > 0) + { + std::list::iterator itField = fieldList.begin(); + pd << (*itField++); + while (itField != fieldList.end()) + { + pd << ", " << (*itField++); + } + } + pd << "], "; + pd << "\"" << author << "\", \"" << fileName << "\")"; + + SetErrorCode(OK); + delete xaoObject; + + return true; +} + +void XAOPlugin_IOperations::importSubShapes( XAO::Geometry* xaoGeometry, + Handle(GEOM_Function) function, int shapeType, int dim, + Handle(TColStd_HSequenceOfTransient)& subShapeList ) +{ + Handle(GEOM_Object) subShape; + Handle(GEOM_Function) aFunction; + Handle(TColStd_HArray1OfInteger) anArray; + + XAO::GeometricElementList::iterator elementIterator = xaoGeometry->begin((XAO::Dimension)dim); + for (; elementIterator != xaoGeometry->end((XAO::Dimension)dim); elementIterator++) + { + XAO::GeometricElement element = elementIterator->second; + if (!element.hasName()) + continue; + + std::string name = element.getName(); + std::string ref = element.getReference(); + int iref = XAO::XaoUtils::stringToInt(ref); + + anArray = new TColStd_HArray1OfInteger(1, 1); + anArray->SetValue(1, iref); + + subShape = GetEngine()->AddObject(GetDocID(), GEOM_SUBSHAPE); + Handle(GEOM_Function) aFunction = subShape->AddFunction(GEOM_Object::GetSubShapeID(), 1); + if (aFunction.IsNull()) + return; + + subShape->SetName(name.c_str()); + subShape->SetType(shapeType); + + GEOM_ISubShape aSSI(aFunction); + aSSI.SetMainShape(function); + aSSI.SetIndices(anArray); + + //aFunction->SetValue(aValue); + subShapeList->Append(subShape); + + // Put this subshape in the list of sub-shapes of theMainShape + function->AddSubShapeReference(aFunction); + } +} + +//============================================================================= +/*! + * Import a shape from XAO format + * \param fileName The name of the file to import + * \param shape The imported shape + * \param subShapes The list of imported groups + * \param groups The list of imported groups + * \param fields The list of imported fields + * \return boolean indicating if import was succeful. + */ +//============================================================================= +bool XAOPlugin_IOperations::ImportXAO( const char* fileName, + Handle(GEOM_Object)& shape, + Handle(TColStd_HSequenceOfTransient)& subShapes, + Handle(TColStd_HSequenceOfTransient)& groups, + Handle(TColStd_HSequenceOfTransient)& fields ) +{ + SetErrorCode(KO); + + if (fileName == NULL || groups.IsNull() || fields.IsNull()) + return false; + + // Read the XAO + XAO::Xao* xaoObject = new XAO::Xao(); + try + { + xaoObject->importXAO(fileName); + } + catch (XAO::XAO_Exception& exc) + { + delete xaoObject; + SetErrorCode(exc.what()); + return false; + } + + XAO::Geometry* xaoGeometry = xaoObject->getGeometry(); + if (xaoGeometry == NULL) + { + delete xaoObject; + SetErrorCode("Cannot import XAO: geometry format not supported."); + return false; + } + + // create the shape + shape = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT); + Handle(GEOM_Function) function = shape->AddFunction(XAOPlugin_Driver::GetID(), IMPORT_SHAPE); + if (function.IsNull()) return false; + if (function->GetDriverGUID() != XAOPlugin_Driver::GetID()) return false; + + // set the geometry + if (xaoGeometry->getFormat() == XAO::BREP) + { + XAO::BrepGeometry* brep = (XAO::BrepGeometry*)xaoGeometry; + TopoDS_Shape geomShape = brep->getTopoDS_Shape(); + function->SetValue(geomShape); + shape->SetName(xaoGeometry->getName().c_str()); + } + else + { + delete xaoObject; + SetErrorCode("Cannot import XAO: geometry format not supported."); + return false; + } + + // create sub shapes with names + importSubShapes(xaoGeometry, function, GEOM_POINT, XAO::VERTEX, subShapes); + importSubShapes(xaoGeometry, function, GEOM_EDGE, XAO::EDGE, subShapes); + importSubShapes(xaoGeometry, function, GEOM_FACE, XAO::FACE, subShapes); + importSubShapes(xaoGeometry, function, GEOM_SOLID, XAO::SOLID, subShapes); + + // create groups + int nbGroups = xaoObject->countGroups(); + for (int i = 0; i < nbGroups; ++i) + { + XAO::Group* xaoGroup = xaoObject->getGroup(i); + + // build an array with the indexes of the sub shapes + int nbElt = xaoGroup->count(); + Handle(TColStd_HArray1OfInteger) array = new TColStd_HArray1OfInteger(1, nbElt); + int j = 0; + for (std::set::iterator it = xaoGroup->begin(); it != xaoGroup->end(); ++it) + { + int index = (*it); + std::string ref = xaoGeometry->getElementReference(xaoGroup->getDimension(), index); + array->SetValue(++j, XAO::XaoUtils::stringToInt(ref)); + } + + // create the group with the array of sub shapes indexes + Handle(GEOM_Object) group = GetEngine()->AddSubShape(shape, array); + group->SetType(GEOM_GROUP); + group->SetName(xaoGroup->getName().c_str()); + + // Set a sub-shape type + TDF_Label freeLabel = group->GetFreeLabel(); + TDataStd_Integer::Set(freeLabel, (Standard_Integer) getGroupDimension(xaoGroup)); + groups->Append(group); + + function = group->GetLastFunction(); + } + + // create the fields + int nbFields = xaoObject->countFields(); + for (int i = 0; i < nbFields; ++i) + { + XAO::Field* xaoField = xaoObject->getField(i); + + Handle(TColStd_HArray1OfExtendedString) components = new TColStd_HArray1OfExtendedString(0, xaoField->countComponents()-1); + for (int j = 0; j < xaoField->countComponents(); ++j) + { + components->SetValue(j, (TCollection_ExtendedString)xaoField->getComponentName(j).c_str()); + } + + Handle(GEOM_Field) field = myFieldOperations->CreateField(shape, + xaoField->getName().c_str(), + (int)xaoField->getType(), + (int)xaoField->getDimension(), + components); + + switch (xaoField->getType()) + { + case XAO::BOOLEAN: + { + XAO::BooleanField* bfield = (XAO::BooleanField*)xaoField; + for (int j = 0; j < xaoField->countSteps(); ++j) + { + XAO::BooleanStep* bstep = bfield->getStep(j); + Handle(GEOM_FieldStep) step = field->AddStep(bstep->getStep(), bstep->getStamp()); + + Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, bstep->countValues()-1); + std::vector bvalues = bstep->getValues(); + for (int k = 0; k < bstep->countValues(); ++k) + { + values->SetValue(k, bvalues[k] ? 1 : 0); + } + step->SetValues(values); + } + break; + } + case XAO::INTEGER: + { + XAO::IntegerField* ifield = (XAO::IntegerField*)xaoField; + for (int j = 0; j < xaoField->countSteps(); ++j) + { + XAO::IntegerStep* istep = ifield->getStep(j); + Handle(GEOM_FieldStep) step = field->AddStep(istep->getStep(), istep->getStamp()); + + Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, istep->countValues()-1); + std::vector ivalues = istep->getValues(); + for (int k = 0; k < istep->countValues(); ++k) + { + values->SetValue(k, ivalues[k]); + } + step->SetValues(values); + } + break; + } + case XAO::DOUBLE: + { + XAO::DoubleField* dfield = (XAO::DoubleField*)xaoField; + for (int j = 0; j < xaoField->countSteps(); ++j) + { + XAO::DoubleStep* dstep = dfield->getStep(j); + Handle(GEOM_FieldStep) step = field->AddStep(dstep->getStep(), dstep->getStamp()); + + Handle(TColStd_HArray1OfReal) values = new TColStd_HArray1OfReal(0, dstep->countValues()-1); + std::vector dvalues = dstep->getValues(); + for (int k = 0; k < dstep->countValues(); ++k) + { + values->SetValue(k, dvalues[k]); + } + step->SetValues(values); + } + break; + } + case XAO::STRING: + { + XAO::StringField* sfield = (XAO::StringField*)xaoField; + for (int j = 0; j < xaoField->countSteps(); ++j) + { + XAO::StringStep* sstep = sfield->getStep(j); + Handle(GEOM_FieldStep) step = field->AddStep(sstep->getStep(), sstep->getStamp()); + + Handle(TColStd_HArray1OfExtendedString) values = new TColStd_HArray1OfExtendedString(0, sstep->countValues()-1); + std::vector svalues = sstep->getValues(); + for (int k = 0; k < sstep->countValues(); ++k) + { + values->SetValue(k, TCollection_ExtendedString(svalues[k].c_str())); + } + step->SetValues(values); + } + break; + } + } + + fields->Append(field); + } + + // make a Python command + GEOM::TPythonDump pd(function); + pd << "(imported, " << shape << ", "; + + // list of sub shapes + pd << "["; + int nbSubshapes = subShapes->Length(); + if (nbSubshapes > 0) + { + for (int i = 1; i <= nbSubshapes; i++) + { + Handle(GEOM_Object) obj = Handle(GEOM_Object)::DownCast(subShapes->Value(i)); + pd << obj << ((i < nbSubshapes) ? ", " : ""); + } + } + pd << "], ["; + + // list of groups + if (nbGroups > 0) + { + for (int i = 1; i <= nbGroups; i++) + { + Handle(GEOM_Object) obj = Handle(GEOM_Object)::DownCast(groups->Value(i)); + pd << obj << ((i < nbGroups) ? ", " : ""); + } + } + + pd << "], ["; + + // list of fields + if (nbFields > 0) + { + for (int i = 1; i <= nbFields; i++) + { + Handle(GEOM_Field) obj = Handle(GEOM_Field)::DownCast(fields->Value(i)); + pd << obj << ((i < nbFields) ? ", " : ""); + } + } + pd << "]"; + pd << ") = geompy.ImportXAO(\"" << fileName << "\")"; + + delete xaoObject; + SetErrorCode(OK); + + return true; +} diff --git a/src/XAOPlugin/XAOPlugin_IOperations.hxx b/src/XAOPlugin/XAOPlugin_IOperations.hxx new file mode 100644 index 000000000..34e17b2c5 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_IOperations.hxx @@ -0,0 +1,74 @@ +// 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 +// +// File : XAOPlugin_IOperations.hxx + +#ifndef _XAOPlugin_IOperations_HXX_ +#define _XAOPlugin_IOperations_HXX_ + +// internal includes +#include "XAOPlugin_Engine.hxx" + +// GEOM includes +#include "GEOMImpl_IBaseIEOperations.hxx" +#include "GEOM_Object.hxx" +#include "GEOM_Field.hxx" + +#include + +namespace XAO { + class Geometry; + class BrepGeometry; + class Xao; +} + +class XAOPLUGINENGINE_EXPORT XAOPlugin_IOperations: public GEOMImpl_IBaseIEOperations +{ +public: + XAOPlugin_IOperations( GEOM_Engine*, int ); + ~XAOPlugin_IOperations(); + + bool ExportXAO( Handle(GEOM_Object) shape, + std::list groupList, + std::list fieldList, + const char* author, + const char* fileName ); + + bool ImportXAO( const char* fileName, + Handle(GEOM_Object)& shape, + Handle(TColStd_HSequenceOfTransient)& subShapes, + Handle(TColStd_HSequenceOfTransient)& groups, + Handle(TColStd_HSequenceOfTransient)& fields ); + +private: + void importSubShapes( XAO::Geometry* xaoGeometry, + Handle(GEOM_Function) function, + int shapeType, + int dim, + Handle(TColStd_HSequenceOfTransient)& subshapeList ); + void exportSubshapes( const Handle(GEOM_Object)& shape, + XAO::BrepGeometry* geometry ); + void exportFields( std::list fieldList, + XAO::Xao* xaoObject, + XAO::BrepGeometry* geometry ); + void exportGroups( std::list groupList, + XAO::Xao* xaoObject, + XAO::BrepGeometry* geometry ); +}; + +#endif diff --git a/src/XAOPlugin/XAOPlugin_IOperations_i.cc b/src/XAOPlugin/XAOPlugin_IOperations_i.cc new file mode 100644 index 000000000..cbda713a9 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_IOperations_i.cc @@ -0,0 +1,172 @@ +// 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 "XAOPlugin_IOperations_i.hh" +#include "XAOPlugin_IOperations.hxx" + +// KERNEL includes +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +XAOPlugin_IOperations_i::XAOPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + XAOPlugin_IOperations* theImpl ) +:GEOM_IOperations_i( thePOA, theEngine, theImpl ) +{ + MESSAGE( "XAOPlugin_IOperations_i::XAOPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +XAOPlugin_IOperations_i::~XAOPlugin_IOperations_i() +{ + MESSAGE( "XAOPlugin_IOperations_i::~XAOPlugin_IOperations_i" ); +} + +//============================================================================= +/*! + * Export a shape to XAO format + * \param shape The shape to export + * \param groups The list of groups to export + * \param fields The list of fields to export + * \param author The author of the export + * \param fileName The name of the exported file + * \return boolean indicating if export was succeful. + */ +//============================================================================= +CORBA::Boolean XAOPlugin_IOperations_i::ExportXAO( GEOM::GEOM_Object_ptr shape, + const GEOM::ListOfGO& groups, + const GEOM::ListOfFields& fields, + const char* author, + const char* fileName) +{ + bool isGood = false; + // Set a not done flag + GetOperations()->SetNotDone(); + + // Get the reference shape + Handle(GEOM_Object) reference = GetObjectImpl( shape ); + + // Get the reference groups + int ind = 0; + std::list groupsObj; + for (; ind < groups.length(); ind++) + { + Handle(GEOM_Object) gobj = GetObjectImpl( groups[ind] ); + if (gobj.IsNull()) return false; + groupsObj.push_back(gobj); + } + + // Get the reference fields + ind = 0; + std::list fieldsObj; + for( ; ind < fields.length(); ind++ ) + { + Handle(GEOM_Field) fobj = Handle(GEOM_Field)::DownCast( GetBaseObjectImpl( fields[ind] ) ); + if( fobj.IsNull() ) return false; + fieldsObj.push_back(fobj); + } + + if( !reference.IsNull() ) + { + // Export XAO + isGood = GetOperations()->ExportXAO( reference, groupsObj, fieldsObj, author, fileName ); + } + + return isGood; +} + +//============================================================================= +/*! + * Import a shape from XAO format + * \param fileName The name of the file to import + * \param shape The imported shape + * \param subShapes The list of imported subShapes + * \param groups The list of imported groups + * \param fields The list of imported fields + * \return boolean indicating if import was succeful. + */ +//============================================================================= +CORBA::Boolean XAOPlugin_IOperations_i::ImportXAO( const char* fileName, + GEOM::GEOM_Object_out shape, + GEOM::ListOfGO_out subShapes, + GEOM::ListOfGO_out groups, + GEOM::ListOfFields_out fields) +{ + GEOM::GEOM_Object_var vshape; + shape = vshape._retn(); + + subShapes = new GEOM::ListOfGO; + groups = new GEOM::ListOfGO; + fields = new GEOM::ListOfFields; + + // Set a not done flag + GetOperations()->SetNotDone(); + + Handle(TColStd_HSequenceOfTransient) importedSubShapes = new TColStd_HSequenceOfTransient(); + Handle(TColStd_HSequenceOfTransient) importedGroups = new TColStd_HSequenceOfTransient(); + Handle(TColStd_HSequenceOfTransient) importedFields = new TColStd_HSequenceOfTransient(); + Handle(GEOM_Object) hshape; + bool res = GetOperations()->ImportXAO( fileName, hshape, importedSubShapes, importedGroups, importedFields ); + + if( !GetOperations()->IsDone() || !res ) + return false; + + // parse fields + int n = importedSubShapes->Length(); + subShapes->length(n); + for( int i = 1; i <= n; i++ ) + { + (*subShapes)[i - 1] = GetObject( Handle(GEOM_Object)::DownCast( importedSubShapes->Value(i) ) ); + } + + // parse groups + n = importedGroups->Length(); + groups->length(n); + for( int i = 1; i <= n; i++ ) + { + (*groups)[i - 1] = GetObject( Handle(GEOM_Object)::DownCast( importedGroups->Value(i) ) ); + } + + // parse fields + n = importedFields->Length(); + fields->length(n); + for( int i = 1; i <= n; i++ ) + { + (*fields)[i - 1] = GEOM::GEOM_Field::_narrow( + GetBaseObject( Handle(GEOM_Field)::DownCast( importedFields->Value(i) ) ) ); + } + + shape = GetObject( hshape ); + + return res; +} + +XAOPlugin_IOperations* XAOPlugin_IOperations_i::GetOperations() +{ + return (XAOPlugin_IOperations*)GetImpl(); +} diff --git a/src/XAOPlugin/XAOPlugin_IOperations_i.hh b/src/XAOPlugin/XAOPlugin_IOperations_i.hh new file mode 100644 index 000000000..6e7b89cda --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_IOperations_i.hh @@ -0,0 +1,61 @@ +// 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 _XAOPlugin_IOperations_i_HeaderFile +#define _XAOPlugin_IOperations_i_HeaderFile + +// idl includes +#include +#include CORBA_SERVER_HEADER( GEOM_Gen ) +#include CORBA_SERVER_HEADER( XAOPlugin ) + +// internal includes +#include "XAOPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_IOperations_i.hh" + +class XAOPlugin_IOperations; + +class XAOPLUGINENGINE_EXPORT XAOPlugin_IOperations_i : + public virtual POA_GEOM::IXAOOperations, + public virtual GEOM_IOperations_i +{ +public: + XAOPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + XAOPlugin_IOperations* theImpl ); + ~XAOPlugin_IOperations_i(); + + CORBA::Boolean ExportXAO( GEOM::GEOM_Object_ptr shape, + const GEOM::ListOfGO& groups, + const GEOM::ListOfFields& fields, + const char* author, + const char* fileName ); + + CORBA::Boolean ImportXAO( const char* fileName, + GEOM::GEOM_Object_out shape, + GEOM::ListOfGO_out subShapes, + GEOM::ListOfGO_out groups, + GEOM::ListOfFields_out fields ); + + XAOPlugin_IOperations* GetOperations(); +}; + +#endif diff --git a/src/XAOPlugin/XAOPlugin_ImportDlg.cxx b/src/XAOPlugin/XAOPlugin_ImportDlg.cxx new file mode 100644 index 000000000..6acce2f5e --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_ImportDlg.cxx @@ -0,0 +1,359 @@ +// Copyright (C) 2013-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 "XAOPlugin_ImportDlg.h" +#include "XAOPlugin_IOperations_i.hh" + +// KERNEL includes +#include + +// GUI includes +#include +#include +#include +#include + +#include +#include +#include +#include + +// GEOM includes +#include "GeometryGUI.h" +#include "GEOMBase.h" +#include "GEOM_Field.hxx" +#include "GEOMImpl_Types.hxx" + +// OCCT Includes +#include +#include +#include +#include +#include + +// QT includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// Constructor +//================================================================================= +XAOPlugin_ImportDlg::XAOPlugin_ImportDlg(GeometryGUI* geometryGUI, QWidget* parent) +: + GEOMBase_Skeleton(geometryGUI, parent, false) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + QPixmap imageOp(resMgr->loadPixmap("GEOM", tr("XAOPLUGIN_IMPORT_ICON"))); + QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("XAOPLUGIN_IMPORT_TITLE")); + + /***************************************************************/ + mainFrame()->GroupConstructors->setTitle(tr("XAOPLUGIN_IMPORT_TITLE")); + mainFrame()->RadioButton1->setIcon(imageOp); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->close(); + + // hide name + mainFrame()->GroupBoxName->hide(); + + //**************************** + // Selection Group box + QGroupBox* gbxExport = new QGroupBox(parent); + + QGridLayout* gridLayoutExport = new QGridLayout(gbxExport); +#ifndef Q_OS_MAC + gridLayoutExport->setSpacing(6); + gridLayoutExport->setContentsMargins(9, 9, 9, 9); +#endif + gridLayoutExport->setObjectName(QString::fromUtf8("gridLayoutExport")); + + int line = 0, col = 0; + QLabel* lblFileName = new QLabel(tr("XAOPLUGIN_IMPORT_FILENAME"), gbxExport); + btnFileSelect = new QPushButton(gbxExport); + ledFileName = new QLineEdit(gbxExport); + btnFileSelect->setText("..."); + + line++; col = 0; + gridLayoutExport->addWidget(lblFileName, line, col++, 1, 1); + gridLayoutExport->addWidget(btnFileSelect, line, col++, 1, 1); + gridLayoutExport->addWidget(ledFileName, line, col++, 1, 1); + + //**************************** + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); + layout->setSpacing(6); + layout->addWidget(gbxExport); + + // set help + setHelpFileName("xao_format_page.html"); + + Init(); +} + +//================================================================================= +// Destructor +//================================================================================= +XAOPlugin_ImportDlg::~XAOPlugin_ImportDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void XAOPlugin_ImportDlg::Init() +{ + // Signal/slot connections + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked())); + + initName(tr("XAOPLUGIN_IMPORTXAO")); + //SelectionIntoArgument(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void XAOPlugin_ImportDlg::ClickOnOk() +{ + setIsApplyAndClose(true); + if (ClickOnApply()) + ClickOnCancel(); + setIsApplyAndClose(false); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool XAOPlugin_ImportDlg::ClickOnApply() +{ + if(!isApplyAndClose()) { + setIsDisableBrowsing( true ); + setIsDisplayResult( false ); + } + + QString msg; + if ( !isValid( msg ) ) { + showError( msg ); + return false; + } + SUIT_OverrideCursor wc; + SUIT_Session::session()->activeApplication()->putInfo( "" ); + + try { + if ( openCommand() ) + if (!execute (/*isApplyAndClose()*/)) + { + abortCommand(); + showError(); + return false; + } + } + catch( const SALOME::SALOME_Exception& e ) { + SalomeApp_Tools::QtCatchCorbaException( e ); + abortCommand(); + return false; + } + commitCommand(); + + if(!isApplyAndClose()) { + setIsDisableBrowsing( false ); + setIsDisplayResult( true ); + } + + return true; +} + +//================================================================================= +// function : btnFileSelectClicked() +// purpose : +//================================================================================= +void XAOPlugin_ImportDlg::btnFileSelectClicked() +{ + QString file = SUIT_FileDlg::getFileName(this, ledFileName->text(), + tr("XAOPLUGIN_FILES"), + tr("XAOPLUGIN_IMPORT_SELECT")); + if ( !file.isEmpty() ) + ledFileName->setText( file ); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void XAOPlugin_ImportDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); +} + +//================================================================================= +// function : enterEvent [REDEFINED] +// purpose : +//================================================================================= +void XAOPlugin_ImportDlg::enterEvent(QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr XAOPlugin_ImportDlg::createOperation() +{ + return getGeomEngine()->GetPluginOperations( getStudyId(), "XAOPluginEngine" ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool XAOPlugin_ImportDlg::isValid(QString& msg) +{ + // check file name + if (ledFileName->text().isEmpty()) + return false; + + return true; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool XAOPlugin_ImportDlg::execute() +{ + bool res = false; + + QString fileName = ledFileName->text(); + GEOM::GEOM_Object_var shape; + GEOM::ListOfGO_var groups, subShapes; + GEOM::ListOfFields_var fields; + + GEOM::IXAOOperations_var ieOp = GEOM::IXAOOperations::_narrow(getOperation()); + res = ieOp->ImportXAO(fileName.toUtf8().constData(), shape, subShapes, groups, fields); + + if (!shape->_is_nil()) + { + m_mainShape = shape; + } + else + { + m_mainShape = NULL; + } + + if (m_mainShape != NULL) + { + QStringList anEntryList; + anEntryList << addInStudy(m_mainShape, m_mainShape->GetName()); + for (int i = 0; i < subShapes->length(); i++) + { + addInStudy(subShapes[i].in(), subShapes[i]->GetName()); + } + for (int i = 0; i < groups->length(); i++) + { + addInStudy(groups[i].in(), groups[i]->GetName()); + } + for (int i = 0; i < fields->length(); i++) + { + addFieldInStudy(fields[i].in(), m_mainShape); + } + + updateObjBrowser(); + if( SUIT_Application* anApp = SUIT_Session::session()->activeApplication() ) { + LightApp_Application* aLightApp = dynamic_cast( anApp ); + aLightApp->browseObjects( anEntryList ); + } + } + + return res; +} + +QString XAOPlugin_ImportDlg::addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEOM::GEOM_Object_ptr theFather) +{ + if ( !hasCommand() ) + return QString(); + + _PTR(Study) aStudy = getStudy()->studyDS(); + if ( !aStudy || theField->_is_nil() ) + return QString(); + + SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy(aStudy); + + SALOMEDS::SObject_var aSO = + getGeomEngine()->AddInStudy(aStudyDS, theField, theField->GetName(), theFather); + + QString anEntry; + if ( !aSO->_is_nil() ) { + CORBA::String_var entry = aSO->GetID(); + anEntry = entry.in(); + } + + // add steps + GEOM::ListOfLong_var steps = theField->GetSteps(); + for (int i = 0; i < steps->length(); ++i) + { + GEOM::GEOM_FieldStep_ptr step = theField->GetStep(steps[i]); + QString stepName = (tr("XAOPLUGIN_STEP") + " %1 %2").arg( step->GetID() ).arg( step->GetStamp() ); + SALOMEDS::SObject_wrap aSOField = + getGeomEngine()->AddInStudy( aStudyDS, step, stepName.toLatin1().constData(), theField ); + } + + aSO->UnRegister(); + + return anEntry; +} + +GEOM::GEOM_Object_ptr XAOPlugin_ImportDlg::getFather(GEOM::GEOM_Object_ptr object) +{ + GEOM::GEOM_Object_var fatherObj; + if (object->GetType() != GEOM_IMPORT && m_mainShape != NULL) + { + //GEOM::GEOM_IGroupOperations_var groupOper = getGeomEngine()->GetIGroupOperations(getStudyId()); + //fatherObj = groupOper->GetMainShape(object); + fatherObj = m_mainShape; + } + return fatherObj._retn(); +} + +QString XAOPlugin_ImportDlg::getObjectName(GEOM::GEOM_Object_ptr object) const +{ + if (object->_is_nil()) + return QString::null; + return object->GetName(); +} + diff --git a/src/XAOPlugin/XAOPlugin_ImportDlg.h b/src/XAOPlugin/XAOPlugin_ImportDlg.h new file mode 100644 index 000000000..2f32db08a --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_ImportDlg.h @@ -0,0 +1,68 @@ +// Copyright (C) 2013-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 XAOPlugin_ImportDlg_H +#define XAOPlugin_ImportDlg_H + +// GEOM includes +#include "GEOMBase_Skeleton.h" + +class QLineEdit; +class QButtonGroup; +class QListWidget; + +//================================================================================= +// class : XAOPlugin_ImportDlg +// purpose : +//================================================================================= +class XAOPlugin_ImportDlg: public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + XAOPlugin_ImportDlg(GeometryGUI*, QWidget* = 0); + ~XAOPlugin_ImportDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute(); + virtual GEOM::GEOM_Object_ptr getFather( GEOM::GEOM_Object_ptr object ); + virtual QString getObjectName( GEOM::GEOM_Object_ptr object ) const; + virtual QString addFieldInStudy( GEOM::GEOM_Field_ptr theField, + GEOM::GEOM_Object_ptr theFather ); + +private: + void Init(); + void enterEvent(QEvent*); + +private: + QLineEdit* ledFileName; + QPushButton* btnFileSelect; + GEOM::GEOM_Object_var m_mainShape; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void btnFileSelectClicked(); +}; + +#endif // XAOPlugin_ImportDlg_H diff --git a/src/XAOPlugin/XAOPlugin_OperationsCreator.cxx b/src/XAOPlugin/XAOPlugin_OperationsCreator.cxx new file mode 100644 index 000000000..21827c0be --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_OperationsCreator.cxx @@ -0,0 +1,66 @@ +// 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 "XAOPlugin_OperationsCreator.hxx" +#include "XAOPlugin_IOperations_i.hh" +#include "XAOPlugin_IOperations.hxx" +#include "XAOPlugin_Driver.hxx" +#include "XAOPlugin_IECallBack.hxx" + +// KERNEL includes +#include +#include + +// OCCT includes +#include + +std::map XAOPlugin_OperationsCreator::_mapOfOperations; + +XAOPlugin_OperationsCreator::XAOPlugin_OperationsCreator() +{ + // Register drivers + TFunction_DriverTable::Get()->AddDriver( XAOPlugin_Driver::GetID(), + new XAOPlugin_Driver() ); + + // Register callback + GEOMImpl_IECallBack::Register( "XAO", new XAOPlugin_IECallBack() ); +} + +XAOPlugin_OperationsCreator::~XAOPlugin_OperationsCreator() +{ +} + +GEOM_IOperations_i* XAOPlugin_OperationsCreator::Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ) +{ + Unexpect aCatch( SALOME_SalomeException ); + MESSAGE( "XAOPlugin_OperationsCreator::Create" ); + return new XAOPlugin_IOperations_i( thePOA, theEngine, get( theGenImpl, theStudyId ) ); +} + +XAOPlugin_IOperations* XAOPlugin_OperationsCreator::get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ) +{ + if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) + _mapOfOperations[theStudyId] = new XAOPlugin_IOperations( theGenImpl, theStudyId ); + return _mapOfOperations[theStudyId]; +} diff --git a/src/XAOPlugin/XAOPlugin_OperationsCreator.hxx b/src/XAOPlugin/XAOPlugin_OperationsCreator.hxx new file mode 100755 index 000000000..d90589d52 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_OperationsCreator.hxx @@ -0,0 +1,57 @@ +// 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 _GEOM_XAOPlugin_OperationsCreator_HXX_ +#define _GEOM_XAOPlugin_OperationsCreator_HXX_ + +// internal includes +#include "XAOPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Gen_i.hh" + +// C++ includes +#include + +class XAOPlugin_IOperations; + +//===================================================================== +// Operations creator +//===================================================================== +class XAOPLUGINENGINE_EXPORT XAOPlugin_OperationsCreator : public GEOM_GenericOperationsCreator +{ +public: + XAOPlugin_OperationsCreator(); + ~XAOPlugin_OperationsCreator(); + + GEOM_IOperations_i* Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ); +private: + static XAOPlugin_IOperations* get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ); + +private: + static std::map _mapOfOperations; + + friend class XAOPlugin_IECallBack; +}; + +#endif diff --git a/src/XAOPlugin/XAOPlugin_images.ts b/src/XAOPlugin/XAOPlugin_images.ts new file mode 100644 index 000000000..48e672f7f --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_images.ts @@ -0,0 +1,16 @@ + + + + + @default + + XAOPLUGIN_EXPORT_ICON + exportxao.png + + + XAOPLUGIN_IMPORT_ICON + importxao.png + + + + diff --git a/src/XAOPlugin/XAOPlugin_msg_en.ts b/src/XAOPlugin/XAOPlugin_msg_en.ts new file mode 100644 index 000000000..c37ffd620 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_msg_en.ts @@ -0,0 +1,105 @@ + + + + + @default + + MEN_EXPORTXAO + XAO + + + TOP_EXPORTXAO + Export XAO + + + STB_EXPORTXAO + Export XAO + + + MEN_IMPORTXAO + XAO + + + TOP_IMPORTXAO + Import XAO + + + STB_IMPORTXAO + Import XAO + + + XAOPLUGIN_IMPORT_SELECT + Import from XAO + + + XAOPLUGIN_EXPORT_SELECT + Export to XAO + + + XAOPLUGIN_FILES + XAO files (*.xao) + + + + XAOPlugin_ExportDlg + + XAOPLUGIN_EXPORT_TITLE + Export XAO + + + XAOPLUGIN_EXPORTXAO + Export XAO + + + XAOPLUGIN_EXPORT_INGSHAPE + Shape + + + XAOPLUGIN_EXPORT_FILENAME + File Name + + + XAOPLUGIN_EXPORT_AUTHOR + Author + + + XAOPLUGIN_EXPORT_LGROUPS + Groups + + + XAOPLUGIN_EXPORT_LFIELDS + Fields + + + + XAOPlugin_ImportDlg + + XAOPLUGIN_IMPORT_TITLE + Import XAO + + + XAOPLUGIN_IMPORTXAO + Import XAO + + + XAOPLUGIN_IMPORT_INGSHAPE + Shape + + + XAOPLUGIN_IMPORT_FILENAME + File Name + + + XAOPLUGIN_IMPORT_LGROUPS + Groups + + + XAOPLUGIN_IMPORT_LFIELDS + Fields + + + XAOPLUGIN_STEP + Step + + + diff --git a/src/XAOPlugin/XAOPlugin_msg_fr.ts b/src/XAOPlugin/XAOPlugin_msg_fr.ts new file mode 100644 index 000000000..7d3a6deec --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_msg_fr.ts @@ -0,0 +1,105 @@ + + + + + @default + + MEN_EXPORTXAO + XAO + + + TOP_EXPORTXAO + Exporter XAO + + + STB_EXPORTXAO + Exporter XAO + + + MEN_IMPORTXAO + XAO + + + TOP_IMPORTXAO + Importer XAO + + + STB_IMPORTXAO + Importer XAO + + + XAOPLUGIN_IMPORT_SELECT + Import XAO + + + XAOPLUGIN_EXPORT_SELECT + Export XAO + + + XAOPLUGIN_FILES + Fichiers XAO (*.xao) + + + + XAOPlugin_ExportDlg + + XAOPLUGIN_EXPORT_TITLE + Export XAO + + + XAOPLUGIN_EXPORTXAO + Export XAO + + + XAOPLUGIN_EXPORT_INGSHAPE + Objet + + + XAOPLUGIN_EXPORT_FILENAME + Fichier + + + XAOPLUGIN_EXPORT_AUTHOR + Auteur + + + XAOPLUGIN_EXPORT_LGROUPS + Groupes + + + XAOPLUGIN_EXPORT_LFIELDS + Champs + + + + XAOPlugin_ImportDlg + + XAOPLUGIN_IMPORT_TITLE + Import XAO + + + XAOPLUGIN_IMPORTXAO + Import XAO + + + XAOPLUGIN_IMPORT_INGSHAPE + Objet + + + XAOPLUGIN_IMPORT_FILENAME + Fichier + + + XAOPLUGIN_IMPORT_LGROUPS + Groupes + + + XAOPLUGIN_IMPORT_LFIELDS + Champs + + + XAOPLUGIN_STEP + Pas + + + \ No newline at end of file diff --git a/src/XAOPlugin/XAOPlugin_msg_ja.ts b/src/XAOPlugin/XAOPlugin_msg_ja.ts new file mode 100644 index 000000000..307f0146b --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_msg_ja.ts @@ -0,0 +1,105 @@ + + + + + @default + + MEN_EXPORTXAO + エクスポートしました。 + + + TOP_EXPORTXAO + エクスポートしました。 + + + STB_EXPORTXAO + ソテーした形式でフォームをエクスポートします。 + + + MEN_IMPORTXAO + インポートしました。 + + + TOP_IMPORTXAO + インポートしました。 + + + STB_IMPORTXAO + ソテーしたフォームをインポートします。 + + + XAOPLUGIN_IMPORT_SELECT + XAOからインポート + + + XAOPLUGIN_EXPORT_SELECT + エクスポートしました。 + + + XAOPLUGIN_FILES + ファイルした (*.xao) + + + + XAOPlugin_ExportDlg + + XAOPLUGIN_EXPORT_TITLE + エクスポートしました。 + + + XAOPLUGIN_EXPORTXAO + エクスポートしました。 + + + XAOPLUGIN_EXPORT_INGSHAPE + オブジェクト + + + XAOPLUGIN_EXPORT_FILENAME + ファイル + + + XAOPLUGIN_EXPORT_AUTHOR + 作成者 + + + XAOPLUGIN_EXPORT_LGROUPS + グループ + + + XAOPLUGIN_EXPORT_LFIELDS + フィールド + + + + XAOPlugin_ImportDlg + + XAOPLUGIN_IMPORT_TITLE + インポートしました。 + + + XAOPLUGIN_IMPORTXAO + インポートしました。 + + + XAOPLUGIN_IMPORT_INGSHAPE + オブジェクト + + + XAOPLUGIN_IMPORT_FILENAME + ファイル + + + XAOPLUGIN_IMPORT_LGROUPS + グループ + + + XAOPLUGIN_IMPORT_LFIELDS + フィールド + + + XAOPLUGIN_STEP + Step + + + \ No newline at end of file