diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c9446aa6..c03791e8c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,10 +31,10 @@ STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7) SET(${PROJECT_NAME_UC}_MINOR_VERSION 4) -SET(${PROJECT_NAME_UC}_PATCH_VERSION 0) +SET(${PROJECT_NAME_UC}_PATCH_VERSION 1) SET(${PROJECT_NAME_UC}_VERSION ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION}) -SET(${PROJECT_NAME_UC}_VERSION_DEV 0) +SET(${PROJECT_NAME_UC}_VERSION_DEV 1) # Find KERNEL # =========== @@ -67,20 +67,7 @@ OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON) OPTION(SALOME_BUILD_GUI "Enable GUI" ON) CMAKE_DEPENDENT_OPTION(SALOME_GEOM_USE_OPENCV "Enable shape recognition from picture" OFF "SALOME_BUILD_GUI" OFF) -CMAKE_DEPENDENT_OPTION(SALOME_GEOM_BUILD_CC "Enable curve creator (experimental)" OFF - "SALOME_BUILD_GUI" OFF) -MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_GEOM_USE_OPENCV SALOME_GEOM_BUILD_CC) - -# Debug options (!!! FOR DEVELOPERS ONLY !!! TO BE REMOVED LATER !!!) -IF(CMAKE_BUILD_TYPE MATCHES "^Debug$") - CMAKE_DEPENDENT_OPTION(SALOME_GEOM_DEBUG_CC "Debug curve creator" OFF - "SALOME_GEOM_BUILD_CC" OFF) - MARK_AS_ADVANCED(SALOME_GEOM_DEBUG_CC) - - IF(SALOME_GEOM_DEBUG_CC) - ADD_DEFINITIONS(-DDEBUG_CURVE_CREATOR) - ENDIF(SALOME_GEOM_DEBUG_CC) -ENDIF() +MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_GEOM_USE_OPENCV) # Prerequisites # ============= @@ -151,7 +138,7 @@ ENDIF(SALOME_BUILD_GUI) ## FIND_PACKAGE(SalomeCAS REQUIRED) -FIND_PACKAGE(SalomeVTK 6.1 REQUIRED) +FIND_PACKAGE(SalomeVTK REQUIRED) # OpenCV IF(SALOME_GEOM_USE_OPENCV) @@ -234,16 +221,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 + AdvancedGUI BasicGUI BlocksGUI BooleanGUI BuildGUI DisplayGUI DlgRef CurveCreator EntityGUI GEOMBase GEOMFiltersSelection GEOM GEOMToolsGUI GenerationGUI GroupGUI Material MeasureGUI GEOMObject - OperationGUI PrimitiveGUI RepairGUI TransformationGUI ImportExportGUI + OperationGUI PrimitiveGUI RepairGUI TransformationGUI DependencyTree + STLPluginGUI BREPPluginGUI STEPPluginGUI IGESPluginGUI XAOPluginGUI VTKPluginGUI ) ENDIF(SALOME_BUILD_GUI) @@ -253,12 +242,6 @@ IF(SALOME_GEOM_USE_OPENCV) ) ENDIF(SALOME_GEOM_USE_OPENCV) -IF(SALOME_GEOM_BUILD_CC) - LIST(APPEND _${PROJECT_NAME}_exposed_targets - CurveCreator - ) -ENDIF(SALOME_GEOM_BUILD_CC) - # Add all targets to the build-tree export set EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets} FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake) diff --git a/SalomeGEOMConfig.cmake.in b/SalomeGEOMConfig.cmake.in index 9e0392028..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) @@ -162,17 +162,28 @@ SET(GEOM_GEOMBase GEOMBase) SET(GEOM_GEOMFiltersSelection GEOMFiltersSelection) SET(GEOM_GEOM GEOM) SET(GEOM_GEOMToolsGUI GEOMToolsGUI) +SET(GEOM_DependencyTree DependencyTree) SET(GEOM_GenerationGUI GenerationGUI) SET(GEOM_GroupGUI GroupGUI) 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 1f882bc78..1c99fe09f 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,15 @@ 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_SalomeIDLGEOMSuperv SalomeIDLGEOMSuperv ${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) @@ -54,17 +53,28 @@ FIND_LIBRARY(GEOM_GEOMBase GEOMBase ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GEOMFiltersSelection GEOMFiltersSelection ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GEOM GEOM ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GEOMToolsGUI GEOMToolsGUI ${GEOM_ROOT_DIR}/lib/salome) +FIND_LIBRARY(GEOM_DependencyTree DependencyTree ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GenerationGUI GenerationGUI ${GEOM_ROOT_DIR}/lib/salome) FIND_LIBRARY(GEOM_GroupGUI GroupGUI ${GEOM_ROOT_DIR}/lib/salome) 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/examples/polyline.py b/doc/salome/examples/polyline.py new file mode 100644 index 000000000..8b7925607 --- /dev/null +++ b/doc/salome/examples/polyline.py @@ -0,0 +1,48 @@ +# 2D polyline + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p1 = geompy.MakeVertex(70., 0., 0.) +p2 = geompy.MakeVertex(70., 70., 80.) +p3 = geompy.MakeVertex( 0., 70., 0.) + +#create a vector from two points +vector_arc = geompy.MakeVector(p1, p3) + +# create an arc from three points +arc = geompy.MakeArc(p1, p2, p3) + +# create a wire +wire = geompy.MakeWire([vector_arc, arc]) + +# create a planar face +isPlanarWanted = 1 +face = geompy.MakeFace(wire, isPlanarWanted) + +# Create a 2D polyline with Polyline2D interface +pl = geompy.Polyline2D() +pl.addSection("section 1", GEOM.Polyline, True, [0, 0, 10, 0, 10, 10]) +polyline1 = pl.result([100, 0, 0, 1, 1, 1, -1, 1, 0]) + +pl = geompy.Polyline2D() +pl.addSection("section 2", GEOM.Interpolation, False) +pl.addPoints([20, 0, 30, 0, 30, 10]) +polyline2 = pl.result(face) + +# add objects in the study +id_face = geompy.addToStudy(face,"Face") +id_polyline1 = geompy.addToStudy(polyline1, "Polyline1") +id_polyline2 = geompy.addToStudy(polyline2, "Polyline2") + +# display the first polyline and the second polyline with its planar face +gg.createAndDisplayGO(id_face) +gg.setDisplayMode(id_face,1) +gg.setTransparency(id_face,0.5) +gg.createAndDisplayGO(id_polyline1) +gg.createAndDisplayGO(id_polyline2) diff --git a/doc/salome/examples/primitives_ex02.py b/doc/salome/examples/primitives_ex02.py index d55d6510f..82cf5e449 100644 --- a/doc/salome/examples/primitives_ex02.py +++ b/doc/salome/examples/primitives_ex02.py @@ -1,5 +1,7 @@ # Creation of a Cylinder +import math + import salome salome.salome_init() import GEOM @@ -11,23 +13,37 @@ gg = salome.ImportComponentGUI("GEOM") # create a vertex and a vector p1 = geompy.MakeVertex(25, 35, 45) p2 = geompy.MakeVertex(70, 70, 70) -v = geompy.MakeVector(p1, p2) +v = geompy.MakeVector(p1, p2) # create cylinders -height = 40 - +height = 40 radius1 = 15 +radius2 = 30 +angle1 = 45. * math.pi / 180. +angle2 = 210. * math.pi / 180. + cylinder1 = geompy.MakeCylinder(p1, v, radius1, height) -radius2 = 30 cylinder2 = geompy.MakeCylinderRH(radius2, height) +cylinder3 = geompy.MakeCylinderA(p1, v, radius1, height, angle1) +geompy.TranslateDXDYDZ(cylinder3, 80., 0., 0.) + +cylinder4 = geompy.MakeCylinderRHA(radius2, height, angle2) +geompy.TranslateDXDYDZ(cylinder4, 80., 0., 0.) + # add objects in the study id_cylinder1 = geompy.addToStudy(cylinder1,"Cylinder1") id_cylinder2 = geompy.addToStudy(cylinder2,"Cylinder2") +id_cylinder3 = geompy.addToStudy(cylinder3,"Cylinder3") +id_cylinder4 = geompy.addToStudy(cylinder4,"Cylinder4") # display the cylinders gg.createAndDisplayGO(id_cylinder1) gg.setDisplayMode(id_cylinder1,1) gg.createAndDisplayGO(id_cylinder2) gg.setDisplayMode(id_cylinder2,1) +gg.createAndDisplayGO(id_cylinder3) +gg.setDisplayMode(id_cylinder3,1) +gg.createAndDisplayGO(id_cylinder4) +gg.setDisplayMode(id_cylinder4,1) diff --git a/doc/salome/examples/viewing_geom_objs_ex01.py b/doc/salome/examples/viewing_geom_objs_ex01.py index 0458d42bf..17387b724 100644 --- a/doc/salome/examples/viewing_geom_objs_ex01.py +++ b/doc/salome/examples/viewing_geom_objs_ex01.py @@ -11,10 +11,9 @@ box2 = geompy.MakeBox(-50,-50,-50, 0,0,0) sphere = geompy.MakeSphere(50,50,50, 30) fuse = geompy.MakeBoolean(box,sphere,3) fuse_id = geompy.addToStudy(fuse,"Fuse") -box_id = geompy.addToStudy(box2, "Box") gg = salome.ImportComponentGUI("GEOM") gg.createAndDisplayGO(fuse_id) gg.setDisplayMode(fuse_id,1) -gg.createAndDisplayGO(box_id) -gg.setVectorsMode(box_id, 1) +gg.setVectorsMode(fuse_id, 1) +gg.setVerticesMode(fuse_id, 1) 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/cylinder1.png b/doc/salome/gui/GEOM/images/cylinder1.png index 089dac282..6dc21ce51 100755 Binary files a/doc/salome/gui/GEOM/images/cylinder1.png and b/doc/salome/gui/GEOM/images/cylinder1.png differ diff --git a/doc/salome/gui/GEOM/images/cylinder2.png b/doc/salome/gui/GEOM/images/cylinder2.png index ad6af2947..b9ed9cd82 100755 Binary files a/doc/salome/gui/GEOM/images/cylinder2.png and b/doc/salome/gui/GEOM/images/cylinder2.png differ diff --git a/doc/salome/gui/GEOM/images/cylinders.png b/doc/salome/gui/GEOM/images/cylinders.png index fc0d43276..b9a2608a7 100755 Binary files a/doc/salome/gui/GEOM/images/cylinders.png and b/doc/salome/gui/GEOM/images/cylinders.png differ diff --git a/doc/salome/gui/GEOM/images/dialog.png b/doc/salome/gui/GEOM/images/dialog.png old mode 100755 new mode 100644 index c46b6b571..8d7e48a96 Binary files a/doc/salome/gui/GEOM/images/dialog.png and b/doc/salome/gui/GEOM/images/dialog.png differ 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/ob_popup_menu.png b/doc/salome/gui/GEOM/images/ob_popup_menu.png index 1d9f0e321..3aafa729e 100644 Binary files a/doc/salome/gui/GEOM/images/ob_popup_menu.png and b/doc/salome/gui/GEOM/images/ob_popup_menu.png differ diff --git a/doc/salome/gui/GEOM/images/polyline_dlg.png b/doc/salome/gui/GEOM/images/polyline_dlg.png new file mode 100644 index 000000000..532817c40 Binary files /dev/null and b/doc/salome/gui/GEOM/images/polyline_dlg.png differ diff --git a/doc/salome/gui/GEOM/images/polyline_dlg_add_section.png b/doc/salome/gui/GEOM/images/polyline_dlg_add_section.png new file mode 100644 index 000000000..9a6c1b9e5 Binary files /dev/null and b/doc/salome/gui/GEOM/images/polyline_dlg_add_section.png differ diff --git a/doc/salome/gui/GEOM/images/polyline_dlg_edit_section.png b/doc/salome/gui/GEOM/images/polyline_dlg_edit_section.png new file mode 100644 index 000000000..69df41e8f Binary files /dev/null and b/doc/salome/gui/GEOM/images/polyline_dlg_edit_section.png differ diff --git a/doc/salome/gui/GEOM/images/pref15.png b/doc/salome/gui/GEOM/images/pref15.png old mode 100755 new mode 100644 index c4b2cac4d..64aa25d74 Binary files a/doc/salome/gui/GEOM/images/pref15.png and b/doc/salome/gui/GEOM/images/pref15.png differ diff --git a/doc/salome/gui/GEOM/images/pref_dep_tree.png b/doc/salome/gui/GEOM/images/pref_dep_tree.png new file mode 100644 index 000000000..c02134335 Binary files /dev/null and b/doc/salome/gui/GEOM/images/pref_dep_tree.png differ diff --git a/doc/salome/gui/GEOM/images/reduce_study_dialog.png b/doc/salome/gui/GEOM/images/reduce_study_dialog.png new file mode 100644 index 000000000..8f53d7aaf Binary files /dev/null and b/doc/salome/gui/GEOM/images/reduce_study_dialog.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/images/tree_bidir_link.png b/doc/salome/gui/GEOM/images/tree_bidir_link.png new file mode 100644 index 000000000..1697ada69 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_bidir_link.png differ diff --git a/doc/salome/gui/GEOM/images/tree_button_update.png b/doc/salome/gui/GEOM/images/tree_button_update.png new file mode 100644 index 000000000..190454b19 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_button_update.png differ diff --git a/doc/salome/gui/GEOM/images/tree_cycldep_link.png b/doc/salome/gui/GEOM/images/tree_cycldep_link.png new file mode 100644 index 000000000..ea00164a1 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_cycldep_link.png differ diff --git a/doc/salome/gui/GEOM/images/tree_default_node.png b/doc/salome/gui/GEOM/images/tree_default_node.png new file mode 100644 index 000000000..2a369dd3a Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_default_node.png differ diff --git a/doc/salome/gui/GEOM/images/tree_disp_ascendants.png b/doc/salome/gui/GEOM/images/tree_disp_ascendants.png new file mode 100644 index 000000000..9f7debc30 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_disp_ascendants.png differ diff --git a/doc/salome/gui/GEOM/images/tree_disp_descendants.png b/doc/salome/gui/GEOM/images/tree_disp_descendants.png new file mode 100644 index 000000000..aaed30738 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_disp_descendants.png differ diff --git a/doc/salome/gui/GEOM/images/tree_example.png b/doc/salome/gui/GEOM/images/tree_example.png new file mode 100644 index 000000000..e41c1b1f8 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_example.png differ diff --git a/doc/salome/gui/GEOM/images/tree_hierarchy_type.png b/doc/salome/gui/GEOM/images/tree_hierarchy_type.png new file mode 100644 index 000000000..4e708fd6a Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_hierarchy_type.png differ diff --git a/doc/salome/gui/GEOM/images/tree_highlighted_node.png b/doc/salome/gui/GEOM/images/tree_highlighted_node.png new file mode 100644 index 000000000..6a6743020 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_highlighted_node.png differ diff --git a/doc/salome/gui/GEOM/images/tree_main_node.png b/doc/salome/gui/GEOM/images/tree_main_node.png new file mode 100644 index 000000000..fc4009b66 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_main_node.png differ diff --git a/doc/salome/gui/GEOM/images/tree_move_nodes.png b/doc/salome/gui/GEOM/images/tree_move_nodes.png new file mode 100644 index 000000000..d358c1f7c Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_move_nodes.png differ diff --git a/doc/salome/gui/GEOM/images/tree_popup_menu1.png b/doc/salome/gui/GEOM/images/tree_popup_menu1.png new file mode 100644 index 000000000..bfc90aca7 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_popup_menu1.png differ diff --git a/doc/salome/gui/GEOM/images/tree_popup_menu2.png b/doc/salome/gui/GEOM/images/tree_popup_menu2.png new file mode 100644 index 000000000..f33e4f3cc Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_popup_menu2.png differ diff --git a/doc/salome/gui/GEOM/images/tree_selected_node.png b/doc/salome/gui/GEOM/images/tree_selected_node.png new file mode 100644 index 000000000..5f44ee521 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_selected_node.png differ diff --git a/doc/salome/gui/GEOM/images/tree_selfdep_link.png b/doc/salome/gui/GEOM/images/tree_selfdep_link.png new file mode 100644 index 000000000..21121230b Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_selfdep_link.png differ diff --git a/doc/salome/gui/GEOM/images/tree_tool_bar.png b/doc/salome/gui/GEOM/images/tree_tool_bar.png new file mode 100644 index 000000000..eab734638 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_tool_bar.png differ diff --git a/doc/salome/gui/GEOM/images/tree_unidir_link.png b/doc/salome/gui/GEOM/images/tree_unidir_link.png new file mode 100644 index 000000000..6afe3f35b Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_unidir_link.png differ diff --git a/doc/salome/gui/GEOM/images/tree_unpublished_node.png b/doc/salome/gui/GEOM/images/tree_unpublished_node.png new file mode 100644 index 000000000..95f9b1629 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_unpublished_node.png differ diff --git a/doc/salome/gui/GEOM/images/tree_view_dump.png b/doc/salome/gui/GEOM/images/tree_view_dump.png new file mode 100644 index 000000000..b02616f29 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_view_dump.png differ diff --git a/doc/salome/gui/GEOM/images/tree_view_fitall.png b/doc/salome/gui/GEOM/images/tree_view_fitall.png new file mode 100644 index 000000000..87e001dd8 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_view_fitall.png differ diff --git a/doc/salome/gui/GEOM/images/tree_view_fitarea.png b/doc/salome/gui/GEOM/images/tree_view_fitarea.png new file mode 100644 index 000000000..e83d023a3 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_view_fitarea.png differ diff --git a/doc/salome/gui/GEOM/images/tree_view_fitselect.png b/doc/salome/gui/GEOM/images/tree_view_fitselect.png new file mode 100755 index 000000000..e52598d7b Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_view_fitselect.png differ diff --git a/doc/salome/gui/GEOM/images/tree_view_glpan.png b/doc/salome/gui/GEOM/images/tree_view_glpan.png new file mode 100644 index 000000000..28ab547ea Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_view_glpan.png differ diff --git a/doc/salome/gui/GEOM/images/tree_view_pan.png b/doc/salome/gui/GEOM/images/tree_view_pan.png new file mode 100644 index 000000000..ec56cacc7 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_view_pan.png differ diff --git a/doc/salome/gui/GEOM/images/tree_view_zoom.png b/doc/salome/gui/GEOM/images/tree_view_zoom.png new file mode 100644 index 000000000..386c966d1 Binary files /dev/null and b/doc/salome/gui/GEOM/images/tree_view_zoom.png differ diff --git a/doc/salome/gui/GEOM/images/vertices_mode.png b/doc/salome/gui/GEOM/images/vertices_mode.png new file mode 100644 index 000000000..deee2b8a7 Binary files /dev/null and b/doc/salome/gui/GEOM/images/vertices_mode.png differ diff --git a/doc/salome/gui/GEOM/input/arranging_study_objects_page.doc b/doc/salome/gui/GEOM/input/arranging_study_objects_page.doc index 8821198e3..88aea81d4 100644 --- a/doc/salome/gui/GEOM/input/arranging_study_objects_page.doc +++ b/doc/salome/gui/GEOM/input/arranging_study_objects_page.doc @@ -20,6 +20,7 @@ parent object is highlighted with bold font. and then displays only the children of the selected object(s). +\anchor publish_hidden_objects
  • Unpublish - hides the selected geometric object from the Object Browser and erases it from all viewers. To publish unpublished geometric objects select in the context menu of the Geometry root object Publish... item. @@ -34,6 +35,12 @@ and then displays only the children of the selected object(s). unpublished objects are sorted by name in ascending order. It is possible to change the order (ascending / descending) by clicking the corresponding title bar of the objects list.
  • + +
  • \ref dependency_tree_page "Show dependency tree" - shows dependency tree of selected objects +in new 2D View Window.
  • + +
  • \ref reduce_study_page "Reduce study" - allows to reduce study +by automatic removing objects according to user's options.
  • Folders

    diff --git a/doc/salome/gui/GEOM/input/creating_basic_go.doc b/doc/salome/gui/GEOM/input/creating_basic_go.doc index 6693b469d..efdff9511 100644 --- a/doc/salome/gui/GEOM/input/creating_basic_go.doc +++ b/doc/salome/gui/GEOM/input/creating_basic_go.doc @@ -15,6 +15,7 @@ geometrical objects as:
  • \subpage create_isoline_page
  • \subpage create_sketcher_page
  • \subpage create_3dsketcher_page
  • +
  • \subpage create_polyline_page
  • \subpage create_vector_page
  • \subpage create_plane_page
  • \subpage create_lcs_page
  • diff --git a/doc/salome/gui/GEOM/input/creating_cylinder.doc b/doc/salome/gui/GEOM/input/creating_cylinder.doc index 1e1cbc16d..d2c9f78e3 100644 --- a/doc/salome/gui/GEOM/input/creating_cylinder.doc +++ b/doc/salome/gui/GEOM/input/creating_cylinder.doc @@ -10,20 +10,33 @@ Entity - > Primitives - > Cylinder \n Firstly, you can define a \b Cylinder by the Base Point (the central point of the cylinder base), the \b Vector (the axis of the cylinder), -and its dimensions: the Radius and the Height. +and its dimensions: the \b Radius and the \b Height. Also, you can optionally specify +the \b Angle in order to create a portion of cylinder. + \n TUI Command: geompy.MakeCylinder(Point, Axis, Radius, Height) \n Arguments: Name + 1 vertex + 1 vector + 2 values (Dimensions: radius and height). +\n TUI Command: geompy.MakeCylinderA(Point, Axis, Radius, Height, Angle) +\n Arguments: Name + 1 vertex + 1 vector + 3 values +(Dimensions: radius, height and angle). + \image html cylinder1.png -\n Secondly, you can define a \b Cylinder by the given radius and the -height at the origin of coordinate system. The axis of the cylinder -will be collinear to the OZ axis of the coordinate system. +\n Secondly, you can define a \b Cylinder by the given \b Radius and +\b Height at the origin of coordinate system. The axis of the cylinder +will be collinear to the OZ axis of the coordinate system. +Similarly to first constructor, you can optionally specify the \b Angle +in order to create a portion of cylinder. + \n TUI Command: geompy.MakeCylinderRH(Radius, Height) \n Arguments: Name + 2 values (Dimensions at origin: radius and height). +\n TUI Command: geompy.MakeCylinderRHA(Radius, Height, Angle) +\n Arguments: Name + 3 values +(Dimensions at origin: radius, height and angle). + \image html cylinder2.png Example: diff --git a/doc/salome/gui/GEOM/input/creating_explode.doc b/doc/salome/gui/GEOM/input/creating_explode.doc index b2f971864..1de29847a 100644 --- a/doc/salome/gui/GEOM/input/creating_explode.doc +++ b/doc/salome/gui/GEOM/input/creating_explode.doc @@ -25,11 +25,13 @@ sub-shapes of a given Type and returns a List of sub-shapes. sub-shapes of a given Type and returns a List of IDs of sub-shapes.
  • geompy.SubShapeAllSortedCentres(Shape, Type) explodes a -shape on sub-shapes of a given type and sorts them by coordinates of -their gravity centers, returning a list of sub-shapes.
  • +shape on sub-shapes of a given type and sorts them taking into account +their gravity centers, to provide stable order of sub-shapes. +It returns a list of sub-shapes.
  • geompy.SubShapeAllSortedCentresIDs(Shape, Type) explodes -a shape on sub-shapes of a given type and sorts them by coordinates of -their gravity centers, returning a List of IDs of sub-shapes.
  • +a shape on sub-shapes of a given type and sorts them taking into +account their gravity centers, to provide stable order of sub-shapes. +It returns a List of IDs of sub-shapes.
  • geompy.SubShape(Shape, Type, ListOfInd) allows to obtain a compound of sub-shapes of the Shape, selected by they indices in a list of all sub-shapes of the given Type. Each index is in the range diff --git a/doc/salome/gui/GEOM/input/creating_polyline.doc b/doc/salome/gui/GEOM/input/creating_polyline.doc new file mode 100644 index 000000000..7ec36434d --- /dev/null +++ b/doc/salome/gui/GEOM/input/creating_polyline.doc @@ -0,0 +1,107 @@ +/*! + +\page create_polyline_page 2D Polyline + +The 2D Polyline allows drawing arbitrary 2D shapes. + +To create a 2D Polyline select in the main menu New Entity -> Basic -> 2D Polyline. + +\image html polyline_dlg.png + +A polyline represents a section or a set of sections. Each section is constructed from a sequence of 2D points +connected either by linear setgments or an interpolation curve. Every section has its own attributes: +- \b Name, +- \b Type (Polyline or Spline), +- \b Closed flag. + +A Polyline created represents a shape that lies on the XOY plane. It can have the following types: +- \b Vertex for a single section with only 1 point. +- \b Wire for a single section with 2 or more points. A Wire can have multiple edges for more then 2 points if the section type is Polyline. +A single edge in the result wire is obtained for a Spline or Polyline with 2 points. +- \b Compound of Wires and/or Vertices if there are several sections. + +For the moment only one reference coordinate system for polyline creation is supported. The XOY plane of the Global coordinate system +is suggested. Implementation of another reference coordinate system is a subject of further development of this functionality. +Restore button orientates the viewer correspondingly to the chosen working plane and fits the scene to show all objects. +For the moment this button works with only one plane. + +It is possible to import a shape in this dialog using Import polyline selection button. To do it an imported object should satisfy conditions +for polyline shapes mentioned above. If a valid shape is selected, when dialog is opened, it is initialized by this shape. +Though the shape can be on any plane, an imported polyline will be defined on XOY plane only due to the limitation. + +The group \b Sections in this dialog represents the Polyline construction framework. Its toolbar has the following operations: +- \b Undo +- \b Redo +- Insert new section +- Addition mode +- Modification mode - not implemented +- Detection mode - not implemented +- \b Remove +- Join selected sections + +Undo/Redo buttons allows to undo/redo changes of the polyline. + +Insert new section button opens a dialog that allows to add a new section: + +\image html polyline_dlg_add_section.png + +In this dialog it is possible to choose: +- \b Name of section +- \b Type of section +- \b Closed flag + +To create a new section \b Add button should be clicked. \b Cancel button is used to cancel this operation. +After clicking \b Add button a new section is appeared on the list. Its name supplemented by its type and closedness +information (see icon) and the number of points (equal to 0 after creation). + +To modify section parameters it is possible to double-click on a section in the list. In this case the following dialog appears: + +\image html polyline_dlg_edit_section.png + +To apply modifications the button \b Ok should be clicked. + +Addition mode allows to add points to a section. It is necessary to select a particular section in a list of sections +and make some mouse clicks in the viewer. A section preview is recomputed after each click. + +Modification mode and Detection mode are not implemented for the moment. + +\b Remove button allows to remove a section. It is available if all modes are deactivated and one section is selected. + +Join selected sections button is available in modification mode if two or more sections are selected. It is used to +merge several sections into the first one from selection list. Joined section has parameters of the first selected one. Points of +the other sections are appended at the end of the list of the first section points. + +Some actions are available via popup menu by right mouse button click. + +If all modes are deactivated: +- Join all sections - join all defined sections into the first one. +- \b Join - join sections. Available if two or more sections are selected. + +In Addition mode: +- Join all sections - join all defined sections into the first one. + +In Modification mode: +- Join all sections - join all defined sections into the first one. +- \b Join - join sections. Available if two or more sections are selected. +- Clear all - remove all sections. Available if at least one section is selected. +- Set closed - set all selected section's Closed flag. Available if at least one section is selected. +- Set open - reset all selected section's Closed flag. Available if at least one section is selected. +- Set polyline - set all selected section's type to Polyline. Available if at least one section is selected. +- Set spline - set all selected section's type to Spline. Available if at least one section is selected. + +In Detection mode: +- Join all sections - join all defined sections into the first one. +- \b Join - join sections. Available if two or more sections are selected. + +

    TUI Commands

    + + +To create the 2D polyline in TUI Polyline2D interface is used. + +pl = geompy.Polyline2D() - returns an instance of Polyline2D interface pl. + +See the \ref gsketcher.Polyline2D "Polyline2D" interface documentation for more information. + +Our TUI Scripts provide you with useful examples of the use of +\ref tui_polyline_page "2D Polyline". +*/ diff --git a/doc/salome/gui/GEOM/input/dependency_tree.doc b/doc/salome/gui/GEOM/input/dependency_tree.doc new file mode 100644 index 000000000..e44dba400 --- /dev/null +++ b/doc/salome/gui/GEOM/input/dependency_tree.doc @@ -0,0 +1,211 @@ +/*! + +\page dependency_tree_page Dependency Tree + +
      +
    • \ref dependency_tree_general_description_anchor "General description"
    • +
    • \ref dependency_tree_nodes_anchor "Nodes"
    • +
    • \ref dependency_tree_links_anchor "Links"
    • +
    • \ref dependency_tree_operations_anchor "Operations"
    • +
    • \ref dependency_tree_navigation_anchor "Navigation"
    • +
    • \ref dependency_tree_popup_menu_anchor "Context menu"
    • +
    + +\anchor dependency_tree_general_description_anchor

    General description

    + +In order to better understand the relations between the %GEOM +objects in a study the user has a possibility to display the +ascendants and descendant of the object(s) in a family tree. + +User can build the dependency tree by selecting desirable object +in Object Browser or OCC Viewer and calling "Show dependency tree" +popup item. It will open a new or clear the existing "Dependency +Tree" view window (only one view is supported) and display a +dependency tree for the selected object or objects (multiple +selection is supported). Also user can rebuild the tree if to select +some object(s) right in the "Dependency Tree" view and call +"Rebuild the tree" popup menu item. + +\image html tree_example.png + +User can change all necessary parameters of Dependency Tree Viewer +in \ref pref_dependency_tree "Preferences". + +
    +\anchor dependency_tree_nodes_anchor

    Nodes

    + +Tree nodes in the Dependency Viewer are named according to the study +names of the corresponding objects. + +Non-published objects are shown in the tree as "unpublished" and +colored in special color. + +All nodes have the fixed size, so the long names are cut and shown +with ellipsis; full name of the object can be seen in the tooltip +if to keep the cursor over the node. + +"Dependency Tree" view supports the following states of nodes: + +
    • Main node - node of main object(s), which were selected in Object +Browser, OCC Viewer or Dependency Tree Viewer in order to build the +dependency tree;
    +\image html tree_main_node.png + +
    • Default node - node of published in study object, which participate in building of +dependency tree as ascendant or descendant;
    +\image html tree_default_node.png + +
    • Unpublished node - the same as "Default node", but +corresponding object was not published in study;
    +\image html tree_unpublished_node.png + +
    • Highlighted node - the state of node when mouse +cursor is over it;
    +\image html tree_highlighted_node.png + +
    • Selected node - the state of node when user +clicks the left mouse button on node.
    +\image html tree_selected_node.png + +
    +\anchor dependency_tree_links_anchor

    Links

    + +Dependency Tree Viewer shows oriented links between nodes to +represent dependency direction. Viewer supports the following states +of links: + +
    • Unidirectional link - shows that A object depends on +B object;
    +\image html tree_unidir_link.png + +
    • Bidirectional link - shows that A object depends on +B object and, at the same time, B object depends on +A object;
    +\image html tree_bidir_link.png + +
    • Self-dependency link - shows that object depends on +itself;
    +\image html tree_selfdep_link.png + +
    • Cyclic dependency links - shows cyclic dependency of +some nodes.
    +\image html tree_cycldep_link.png + +
    +\anchor dependency_tree_operations_anchor

    Operations

    + +The dependency tree of a chosen %GEOM object is displayed in +the dedicated 2D view window. +\n The functionalities of 2D viewer are available via its Viewer +Toolbar. + +Buttons marked with small downward triangles have extended +functionality which can be accessed by locking on them with left +mouse button. + +\image tree_tool_bar + +Dump View - exports an object from the viewer in bmp, png or +jpeg image format. +\image html tree_view_dump.png + +Fit all - scales the presentation so that it could fit within +the Viewer boundaries. +\image html tree_view_fitall.png + +Fit area - resizes the view to place in the visible area only +the contents of a frame drawn with pressed left mouse button. +\image html tree_view_fitarea.png + +Fit selection - resizes the view to fit in the visible area +only currently selected objects. +\image html tree_view_fitselect.png + +Zoom - allows to zoom in and out. +\image html tree_view_zoom.png + +Panning - if the represented objects are greater that the +visible area and you don't wish to use Fit all functionality, +click on this button and you'll be able to drag the scene to see its +remote parts. +\image html tree_view_pan.png + +Global panning - allows to select a point to be the center of +the presentation showing all displayed objects in the visible ares. +\image html tree_view_glpan.png + +Hierarchy depth - allows to change the number of hierarchy +levels to be shown in the dependency tree. +\image html tree_hierarchy_type.png +
      +
    • Level 1 corresponds to the parents and children of the selected +object(s);
    • +
    • Level 2 is Level 1 plus the grand-parents and grand-children +of the selected object(s);
    • +
    • etc...
    • +
    + +Display ascendants - allows user to control the displaying +of ascendants. +\image html tree_disp_ascendants.png + +Display descendants - allows user to control the displaying +of descendants. +\image html tree_disp_descendants.png + +Move nodes - enables/disables of moving the nodes. +\image html tree_move_nodes.png + +Update - allows user to update a dependency tree model and the view. +\image html tree_button_update.png + +
    +\anchor dependency_tree_navigation_anchor

    Navigation

    + +Dependency Tree 2D Viewer supports the following navigation mode: + +
      +
    • rectangle selection in this mode is performed by the left mouse +button
    • ; +
    • multiple selection is available when \b Shift button +is pressed.
    • +
    + +Also, holding \b Ctrl key with pressed mouse buttons performs +the following view transformations: +
      +
    • Ctrl + left mouse button - zooming;
    • +
    • Ctrl + middle mouse button - panning;
    • +
    + +
    +\anchor dependency_tree_popup_menu_anchor

    Popup Menu

    + +After the object has appeared in the Dependency Tree 2D Viewer, +user can select it with left mouse click to change its presentation +parameters and get access to other useful options by right-clicking on +the selected object. + +\image html tree_popup_menu1.png + +
      +
    • \b Show - allows to show selected object(s) in OCC 3D Viewer;
    • +
    • Show Only - allows to show only selected object(s) +in OCC 3D Viewer;
    • +
    • Rebuild the tree - allows to rebuild the dependency tree +for selected object(s);
    • +
    • \ref reduce_study_page "Reduce study" - allows to reduce study.
    • +
    + +Some functionalities are available through right-clicking on +the viewer background: + +\image html tree_popup_menu2.png + +Dependency Tree 2D Viewer background can be customized using the +"Change background" popup menu command that opens standard +"Select Color" dialog box: + +\image html selectcolor.png + +*/ diff --git a/doc/salome/gui/GEOM/input/display_mode.doc b/doc/salome/gui/GEOM/input/display_mode.doc index f8eaeccf0..f8f2184e7 100644 --- a/doc/salome/gui/GEOM/input/display_mode.doc +++ b/doc/salome/gui/GEOM/input/display_mode.doc @@ -29,6 +29,17 @@ functionality for all objects in the current view via the main menu \n TUI Command: gg.setVectorsMode(ID, Bool) +\n Also it is possible to show the vertices of the selected +shape. For this, choose in the context menu of the shape +Display mode -> Show Vertices, or apply this +functionality for all objects in the current view via the main menu + View -> Display Mode -> Show/Hide Vertices. + +\image html vertices_mode.png +
    Vertices Mode (Show Vertices)
    + +\n TUI Command: gg.setVerticesMode(ID, Bool) + Our TUI Scripts provide you with useful examples of \ref tui_change_disp_mode "Changing Display Parameters". diff --git a/doc/salome/gui/GEOM/input/geometry_preferences.doc b/doc/salome/gui/GEOM/input/geometry_preferences.doc index 6ad3270cb..5e9e94e7d 100644 --- a/doc/salome/gui/GEOM/input/geometry_preferences.doc +++ b/doc/salome/gui/GEOM/input/geometry_preferences.doc @@ -2,6 +2,8 @@ \page geometry_preferences_page Geometry preferences +\anchor pref_settings

    Settings

    + In the \b Geometry module you can set preferences for visualisation of geometrical figures, which can be used in later sessions with this module. There is also a special group of preferences controlling input @@ -31,8 +33,21 @@ default color for edges, vectors and wires (isolated lines).
  • vertices.
  • Color of isolines - allows to select default color for isolines.
  • -
  • Step value for spin boxes - allows to define the increment -of values set in spin boxes.
  • +
  • Top level color - allows to select default color for objects which +were brought to the viewer foreground.
  • +
  • Top level display mode - allows to select default top level display mode between:
  • + +
  • Transparency - allows to define default transparency value.
  • Deflection coefficient - allows to define default deflection coefficient for lines and surfaces. A smaller coefficient provides better quality of a shape in the viewer.
  • @@ -44,6 +59,8 @@ predefined materials.
  • Isolines width - allows to define default width of the isolines.
  • Preview edges width - allows to define width of the edges for preview.
  • Measures line width - allows to define lines width of measurements tools.
  • +
  • Step value for spin boxes - allows to define the increment +of values set in spin boxes.
  • Automatic bring to front - when the option is on, the objects selected by the user automatically become "top-level".
  • @@ -128,5 +145,35 @@ system immediately after the module activation. +\anchor pref_dependency_tree

    Dependency Tree

    + +Also user can set preferences for visualisation of Dependency Tree in 2D Viewer. + +\image html pref_dep_tree.png + + + + */ 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 -The \subpage xao_format_page "import and export of shapes in XAO format" is implemented differently. +\section io_general General information + +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/reduce_study.doc b/doc/salome/gui/GEOM/input/reduce_study.doc new file mode 100644 index 000000000..8a3c7e766 --- /dev/null +++ b/doc/salome/gui/GEOM/input/reduce_study.doc @@ -0,0 +1,58 @@ +/*! + +\page reduce_study_page Reduce Study + +The user sometimes needs to keep in the study only some objects that +present the final result(s) of the design operations and to delete all +other objects which do not contribute to these results. + +The feature is especially useful when the user designs the whole model +through the GUI and wants to generate simplified "clean" Python dump only +at the end of the model construction with no "useless" objects in the +%GEOM module. + +User can open dialog box by selecting desirable object(s) in Object +Browser or OCC Viewer and calling "Reduce study" popup item. + +\image html reduce_study_dialog.png + +
      + +
    • Objects to be kept - objects that will be kept in the study after +applying operation of reduce study. The list of objects being selected by +the user are highlighted in bold font.
    • + +
    • Objects to be removed - objects that will be deleted.
    • + +\note Mentioned views provide possibility to show/hide object(s) in +current Viewer using "eye" icon near each item of tree. Also user can +show/hide ALL objects in tree by clicking "eye" icon in the head of tree view. + +
    • Intermediate objects group box allows to choose an action +that will be performed with the objects that took part in the operations +chain to produce the selected object(s): +
        +
      • Keep - object(s) will be kept in the study;
      • +
      • Unpublish - object(s) will be unpublished (hidden) from the study;
      • +
      • Remove - object(s) will be removed from the study. \note Since use of +this option can lead to the broken Dump Python script, the warning message +will be shown at the operation commiting to confirm/reject removing +intermediate objects.
      • +
      +
    • + +
    • Sub-objects group box allows to choose the same operations for +sub-objects of selected item(s): keep, unpublish or remove.
    • + +
    • Remove empty folders - if this option is checked, then all folders, +which will become empty after removing unused objects from the study, +will be also removed; otherwise, empty folders will be kept.
    • + +
    • Soft removal - if this option is checked, operation will just +unpublish the redundant objects from the study instead of their hard delete. +\n Soft removal would keep all the data in the study to give the user a +chance to revert this operation using \ref publish_hidden_objects +"Publish Objects" dialog box.
    • + +
    +*/ 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/tui_polyline.doc b/doc/salome/gui/GEOM/input/tui_polyline.doc new file mode 100644 index 000000000..ff83b9053 --- /dev/null +++ b/doc/salome/gui/GEOM/input/tui_polyline.doc @@ -0,0 +1,6 @@ +/*! + +\page tui_polyline_page 2D Polyline +\tui_script{polyline.py} + +*/ diff --git a/doc/salome/gui/GEOM/input/viewing_geom_obj.doc b/doc/salome/gui/GEOM/input/viewing_geom_obj.doc index 38246c570..29a43cfbf 100644 --- a/doc/salome/gui/GEOM/input/viewing_geom_obj.doc +++ b/doc/salome/gui/GEOM/input/viewing_geom_obj.doc @@ -21,6 +21,7 @@ other useful options by right-clicking on the selected object. object.
  • Delete - irreversibly deletes the selected object from the viewer and from the Object Browser.
  • +
  • Create Group - allows to create group.
  • \subpage display_mode_page "Display Mode" - allows to select between Wireframe and Shading presentation.
  • \subpage bring_to_front_page "Bring To Front" - allows to bring to @@ -63,6 +64,10 @@ geometrical object. TUI Command: sg.DisplayOnly(ID)
  • Show all dimensions - shows all of the persistent dimensions created for the selected geometrical object.
  • Hide all dimensions - hides all of the persistent dimensions created for the selected geometrical object.
  • +
  • \subpage dependency_tree_page "Show dependency tree" - shows dependency tree of selected objects +in new 2D View Window.
  • +
  • \subpage reduce_study_page "Reduce study" - allows to reduce study +by automatic removing objects according to user's options.
  • Dump view - exports an object from the viewer in bmp, png, jpg or jpeg image format.
  • Change background - allows to redefine the background 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..3b4210096 100755 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -32,16 +32,83 @@ 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} ) + SET(IDL_LINK_FLAGS ${KERNEL_SalomeIDLKernel} ) +SET(IDL_LINK_PLUGIN_FLAGS + ${KERNEL_SalomeIDLKernel} + SalomeIDLGEOM +) + +SET(IDL_LINK_SUPERV_FLAGS + ${KERNEL_SalomeIDLKernel} + SalomeIDLGEOM + SalomeIDLAdvancedGEOM +) + 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_PLUGIN_FLAGS}") +INSTALL(TARGETS SalomeIDLAdvancedGEOM EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLSTLPlugin "${SalomeIDLSTLPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_PLUGIN_FLAGS}") +INSTALL(TARGETS SalomeIDLSTLPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLBREPPlugin "${SalomeIDLBREPPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_PLUGIN_FLAGS}") +INSTALL(TARGETS SalomeIDLBREPPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLSTEPPlugin "${SalomeIDLSTEPPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_PLUGIN_FLAGS}") +INSTALL(TARGETS SalomeIDLSTEPPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLIGESPlugin "${SalomeIDLIGESPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_PLUGIN_FLAGS}") +INSTALL(TARGETS SalomeIDLIGESPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLXAOPlugin "${SalomeIDLXAOPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_PLUGIN_FLAGS}") +INSTALL(TARGETS SalomeIDLXAOPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLVTKPlugin "${SalomeIDLVTKPlugin_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_PLUGIN_FLAGS}") +INSTALL(TARGETS SalomeIDLVTKPlugin EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +OMNIORB_ADD_MODULE(SalomeIDLGEOMSuperv "${SalomeIDLGEOMSuperv_IDLSOURCES}" "${IDL_INCLUDE_DIRS}" "${IDL_LINK_SUPERV_FLAGS}") +INSTALL(TARGETS SalomeIDLGEOMSuperv EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index ecf0308db..8863bae26 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -164,7 +164,8 @@ module GEOM /*! * \brief Kind of the curves. * - * Used in the functions GEOM_ICurvesOperations.MakeCurveParametric(), GEOM_ICurvesOperations.MakeCurveParametricNew() + * Used in the functions GEOM_ICurvesOperations.MakeCurveParametric(), GEOM_ICurvesOperations.MakeCurveParametricNew(), + * GEOM_ICurvesOperations.MakePolyline2D, GEOM_ICurvesOperations.MakePolyline2DOnPlane. */ enum curve_type { /*! Polyline curve */ @@ -177,19 +178,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 */ @@ -221,11 +209,12 @@ module GEOM }; - typedef sequence string_array; - typedef sequence short_array; - typedef sequence ListOfBool; - typedef sequence ListOfLong; - typedef sequence ListOfDouble; + typedef sequence string_array; + typedef sequence short_array; + typedef sequence ListOfBool; + typedef sequence ListOfLong; + typedef sequence ListOfDouble; + typedef sequence ListOfListOfDouble; interface GEOM_Object; interface GEOM_BaseObject; @@ -1481,6 +1470,18 @@ module GEOM */ GEOM_Object MakeCylinderRH (in double theR, in double theH); + /*! + * \brief Create a portion of cylinder with given radius, height and angle at + * the origin of coordinate system. + * + * Axis of the cylinder will be collinear to the OZ axis of the coordinate system. + * \param theR Cylinder radius. + * \param theH Cylinder height. + * \param theA Cylinder angle. + * \return New GEOM_Object, containing the created cylinder. + */ + GEOM_Object MakeCylinderRHA (in double theR, in double theH, in double theA); + /*! * \brief Create a cylinder with given base point, axis, radius and height. * \param thePnt Central point of cylinder base. @@ -1493,6 +1494,20 @@ module GEOM in GEOM_Object theAxis, in double theR, in double theH); + /*! + * \brief Create a portion of cylinder with given base point, axis, radius, height and angle. + * \param thePnt Central point of cylinder base. + * \param theAxis Cylinder axis. + * \param theR Cylinder radius. + * \param theH Cylinder height. + * \param theA Cylinder angle. + * \return New GEOM_Object, containing the created cylinder. + */ + GEOM_Object MakeCylinderPntVecRHA (in GEOM_Object thePnt, + in GEOM_Object theAxis, + in double theR, + in double theH, + in double theA); /*! * \brief Create a cone with given height and radiuses at @@ -3319,6 +3334,72 @@ module GEOM * \return New GEOM_Object, containing the created wire. */ GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates); + + /*! + * \brief Create a 2D polyline (wire or a compound of wires). + * + * The polyline can have several sections. Each section represents a set + * of points in the form of list of coordinates of the following order: + * x1, y1, x2, y2, ..., xN, yN + * Each section has its own name, type of curve (can be either + * GEOM::Polyline or GEOM::Interpolation) and Closed flag. + * For each section a wire is created. It represents either a polyline or + * interpolation BSpline either closed or not depending on the Closed flag. + * The result represents a wire if there is only one section is defined. + * Otherwise a compound of wires is returned. + * + * \param theCoordsList the list of coordinates list. theCoordsList[0] + * is the coordinates list of the first section. theCoordsList[1] + * is for the second section etc. + * \param theNamesList the list of names. The order corresponds to + * theCoordsList. + * \param theTypesList the list of curve types. The order corresponds to + * theCoordsList. + * \param theClosedList the list of Closed flags. The order corresponds to + * theCoordsList. + * \param theWorkingPlane 9 double values, defining origin, + * OZ and OX directions of the working plane. + * \return New GEOM_Object, containing the created wire or a compound + * of wires. + */ + GEOM_Object MakePolyline2D (in ListOfListOfDouble theCoordsList, + in string_array theNamesList, + in short_array theTypesList, + in ListOfBool theClosedList, + in ListOfDouble theWorkingPlane); + + /*! + * \brief Create a 2D polyline (wire or a compound of wires). + * + * The polyline can have several sections. Each section represents a set + * of points in the form of list of coordinates of the following order: + * x1, y1, x2, y2, ..., xN, yN + * Each section has its own name, type of curve (can be either + * GEOM::Polyline or GEOM::Interpolation) and Closed flag. + * For each section a wire is created. It represents either a polyline or + * interpolation BSpline either closed or not depending on the Closed flag. + * The result represents a wire if there is only one section is defined. + * Otherwise a compound of wires is returned. + * + * \param theCoordsList the list of coordinates list. theCoordsList[0] + * is the coordinates list of the first section. theCoordsList[1] + * is for the second section etc. + * \param theNamesList the list of names. The order corresponds to + * theCoordsList. + * \param theTypesList the list of curve types. The order corresponds to + * theCoordsList. + * \param theClosedList the list of Closed flags. The order corresponds to + * theCoordsList. + * \param theWorkingPlane planar Face or LCS(Marker) of the working plane. + * \return New GEOM_Object, containing the created wire or a compound + * of wires. + */ + GEOM_Object MakePolyline2DOnPlane (in ListOfListOfDouble theCoordsList, + in string_array theNamesList, + in short_array theTypesList, + in ListOfBool theClosedList, + in GEOM_Object theWorkingPlane); + }; // # GEOM_ILocalOperations: @@ -3684,56 +3765,43 @@ 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. * \return List of GEOM_Object, containing the created shape and groups of materials. */ - ListOfGO ImportFile (in string theFileName, in string theFormatName); + ListOfGBO 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. @@ -3772,31 +3840,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: @@ -4365,448 +4409,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. */ @@ -5089,6 +4692,35 @@ module GEOM void Move( in object_list what, in SALOMEDS::SObject where, in long row ); + + /*! + * \brief Collects dependencies of the given objects from other ones + * \param theStudy The study in which the object is published + * \param theListOfEntries List of GEOM object entries in OCAF tree (not in study) + * \return Struct of dependent entries and its links as a byte array + * \note This method is supposed to be used by GUI only. + */ + SALOMEDS::TMPFile GetDependencyTree(in SALOMEDS::Study theStudy, + in string_array theListOfEntries); + + /*! + * \brief Fills 3 lists that is used to reduce study of redundant objects: + * - dependencies of the given objects from other ones; + * - children of the given objects; + * - all other objects in study. + * \param theStudy The study in which the object was published + * \param theSelectedEntries List of GEOM object entries in OCAF tree + * \param theParentEntries List of GEOM object entries on which the given objects depend + * \param theSubEntries Children entries list of the given objects + * \param theOtherEntries List of GEOM object entries which are in the study, but not in parents and children lists + * \note This method is supposed to be used by GUI only. + */ + void GetEntriesToReduceStudy(in SALOMEDS::Study theStudy, + inout string_array theSelectedEntries, + inout string_array theParentEntries, + inout string_array theSubEntries, + inout string_array theOtherEntries); + }; }; diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 07f7fe92f..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 { @@ -161,6 +162,14 @@ module GEOM in double theHeight) ; GEOM_Object MakeCylinderRH (in double theR, in double theH) ; + GEOM_Object MakeCylinderPntVecRHA (in GEOM_Object thePnt, + in GEOM_Object theAxis, + in double theRadius, + in double theHeight, + in double theAngle) ; + GEOM_Object MakeCylinderRHA (in double theR, + in double theH, + in double theA) ; GEOM_Object MakeSphere (in double theX, in double theY, in double theZ, @@ -264,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 // @@ -635,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/GEOMActions.xml b/resources/AdvancedGEOM.xml similarity index 98% rename from resources/GEOMActions.xml rename to resources/AdvancedGEOM.xml index 7dc5adee6..1d6fda98d 100644 --- a/resources/GEOMActions.xml +++ b/resources/AdvancedGEOM.xml @@ -28,7 +28,7 @@ - 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/GEOMCatalog.xml.in b/resources/GEOMCatalog.xml.in index e9d665cd2..bb07e4de7 100644 --- a/resources/GEOMCatalog.xml.in +++ b/resources/GEOMCatalog.xml.in @@ -26,5403 +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 - - - - - - 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 0cdf1cf72..569ff16a8 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -37,12 +37,20 @@
    - + + + + + + + +
    + @@ -67,6 +75,17 @@ + + + + + + + + + + + @@ -99,9 +118,9 @@
    - +
    - +
    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/GEOM_AdvancedEngine.hxx b/src/AdvancedEngine/AdvancedEngine.hxx similarity index 100% rename from src/AdvancedEngine/GEOM_AdvancedEngine.hxx rename to src/AdvancedEngine/AdvancedEngine.hxx diff --git a/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.cxx b/src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.cxx similarity index 92% rename from src/AdvancedEngine/GEOMImpl_DividedDiskDriver.cxx rename to src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.cxx index 24876c489..d1391bc13 100644 --- a/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.cxx +++ b/src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.cxx @@ -22,12 +22,11 @@ #include +#include "AdvancedEngine_DividedDiskDriver.hxx" +#include "AdvancedEngine_IDividedDisk.hxx" #include "AdvancedEngine_Types.hxx" -#include -#include -#include -#include +#include "GEOM_Function.hxx" // OCCT includes #include @@ -56,28 +55,28 @@ #include #include -//@@ include required header files here @@// enum { SQUARE, HEXAGON }; + //======================================================================= //function : GetID //purpose : //======================================================================= -const Standard_GUID& GEOMImpl_DividedDiskDriver::GetID() +const Standard_GUID& AdvancedEngine_DividedDiskDriver::GetID() { static Standard_GUID aGUID("0b01da9a-c5da-11e1-8d80-78e7d1879630"); return aGUID; } //======================================================================= -//function : GEOMImpl_DividedDiskDriver +//function : AdvancedEngine_DividedDiskDriver //purpose : //======================================================================= -GEOMImpl_DividedDiskDriver::GEOMImpl_DividedDiskDriver() +AdvancedEngine_DividedDiskDriver::AdvancedEngine_DividedDiskDriver() { } @@ -85,12 +84,12 @@ GEOMImpl_DividedDiskDriver::GEOMImpl_DividedDiskDriver() //function : Execute //purpose : //======================================================================= -Standard_Integer GEOMImpl_DividedDiskDriver::Execute(TFunction_Logbook& log) const +Standard_Integer AdvancedEngine_DividedDiskDriver::Execute(TFunction_Logbook& log) const { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - GEOMImpl_IDividedDisk aData (aFunction); + AdvancedEngine_IDividedDisk aData (aFunction); Standard_Integer aType = aFunction->GetType(); TopoDS_Shape aShape; @@ -150,7 +149,7 @@ Standard_Integer GEOMImpl_DividedDiskDriver::Execute(TFunction_Logbook& log) con //function : MakeDiskHexagon //purpose : //======================================================================= -TopoDS_Shell GEOMImpl_DividedDiskDriver::MakeDiskHexagon(double R, double Ratio) const +TopoDS_Shell AdvancedEngine_DividedDiskDriver::MakeDiskHexagon(double R, double Ratio) const { // Geometry gp_Dir ZDir(0,0,1); @@ -312,7 +311,7 @@ TopoDS_Shell GEOMImpl_DividedDiskDriver::MakeDiskHexagon(double R, double Ratio) //function : MakeDiskSquare //purpose : //======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::MakeDiskSquare(double R, double Ratio) const +TopoDS_Shape AdvancedEngine_DividedDiskDriver::MakeDiskSquare(double R, double Ratio) const { // Geometry gp_Dir ZDir(0,0,1); @@ -430,7 +429,7 @@ TopoDS_Shape GEOMImpl_DividedDiskDriver::MakeDiskSquare(double R, double Ratio) //purpose : Perform shape transformation accordingly with specified // orientation //======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, int theOrientation) const +TopoDS_Shape AdvancedEngine_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, int theOrientation) const { gp_Dir N, Vx; gp_Pnt theOrigin = gp::Origin(); @@ -467,7 +466,7 @@ TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, i //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 +TopoDS_Shape AdvancedEngine_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, gp_Pnt P, gp_Dir V) const { gp_Ax3 aWPlane( P, V ); return WPlaneTransform(theShape, aWPlane); @@ -478,7 +477,7 @@ TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, g //purpose : Perform shape transformation accordingly with the given // Working Plane //======================================================================= -TopoDS_Shape GEOMImpl_DividedDiskDriver::WPlaneTransform(TopoDS_Shape theShape, gp_Ax3 theWPlane) const +TopoDS_Shape AdvancedEngine_DividedDiskDriver::WPlaneTransform(TopoDS_Shape theShape, gp_Ax3 theWPlane) const { gp_Trsf aTrans; aTrans.SetTransformation(theWPlane); @@ -493,14 +492,14 @@ TopoDS_Shape GEOMImpl_DividedDiskDriver::WPlaneTransform(TopoDS_Shape theShape, */ //================================================================================ -bool GEOMImpl_DividedDiskDriver:: +bool AdvancedEngine_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 ); + AdvancedEngine_IDividedDisk aCI( function ); Standard_Integer aType = function->GetType(); theOperationName = "DIVIDEDDISK"; @@ -525,5 +524,5 @@ GetCreationInformation(std::string& theOperationName, return true; } -IMPLEMENT_STANDARD_HANDLE (GEOMImpl_DividedDiskDriver,GEOM_BaseDriver); -IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_DividedDiskDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_HANDLE (AdvancedEngine_DividedDiskDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_RTTIEXT (AdvancedEngine_DividedDiskDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.hxx b/src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.hxx similarity index 63% rename from src/AdvancedEngine/GEOMImpl_DividedDiskDriver.hxx rename to src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.hxx index 9b774c5df..9bda25fc4 100644 --- a/src/AdvancedEngine/GEOMImpl_DividedDiskDriver.hxx +++ b/src/AdvancedEngine/AdvancedEngine_DividedDiskDriver.hxx @@ -20,40 +20,38 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef _GEOMImpl_DividedDiskDriver_HXX -#define _GEOMImpl_DividedDiskDriver_HXX +#ifndef _AdvancedEngine_DividedDiskDriver_HXX +#define _AdvancedEngine_DividedDiskDriver_HXX + +#include "GEOM_BaseDriver.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( AdvancedEngine_DividedDiskDriver, GEOM_BaseDriver ); -DEFINE_STANDARD_HANDLE( GEOMImpl_DividedDiskDriver, GEOM_BaseDriver ); - -class GEOMImpl_DividedDiskDriver : public GEOM_BaseDriver { +class AdvancedEngine_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 + 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; } - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT ~GEOMImpl_DividedDiskDriver() {}; + static const Standard_GUID& GetID(); + ~AdvancedEngine_DividedDiskDriver() {}; - Standard_EXPORT virtual - bool GetCreationInformation(std::string& theOperationName, - std::vector& params); + 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; @@ -61,7 +59,7 @@ private: TopoDS_Shell MakeDiskHexagon (double R, double Ratio) const; TopoDS_Shape MakeDiskSquare (double R, double Ratio) const; - DEFINE_STANDARD_RTTI( GEOMImpl_DividedDiskDriver ) + DEFINE_STANDARD_RTTI( AdvancedEngine_DividedDiskDriver ) }; -#endif // _GEOMImpl_DividedDiskDriver_HXX +#endif // _AdvancedEngine_DividedDiskDriver_HXX diff --git a/src/AdvancedEngine/GEOMImpl_IDividedDisk.hxx b/src/AdvancedEngine/AdvancedEngine_IDividedDisk.hxx similarity index 90% rename from src/AdvancedEngine/GEOMImpl_IDividedDisk.hxx rename to src/AdvancedEngine/AdvancedEngine_IDividedDisk.hxx index 88a9944d9..c0f7e9c40 100644 --- a/src/AdvancedEngine/GEOMImpl_IDividedDisk.hxx +++ b/src/AdvancedEngine/AdvancedEngine_IDividedDisk.hxx @@ -20,8 +20,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef _GEOMImpl_IDividedDisk_HXX_ -#define _GEOMImpl_IDividedDisk_HXX_ +#ifndef _AdvancedEngine_IDividedDisk_HXX_ +#define _AdvancedEngine_IDividedDisk_HXX_ #include "GEOM_Function.hxx" @@ -34,10 +34,10 @@ #define DIVIDEDDISK_ARG_TYPE 6 -class GEOMImpl_IDividedDisk +class AdvancedEngine_IDividedDisk { public: - GEOMImpl_IDividedDisk(Handle(GEOM_Function) theFunction): _func(theFunction) {} + 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); } @@ -61,4 +61,4 @@ private: Handle(GEOM_Function) _func; }; -#endif // _GEOMImpl_IDividedDisk_HXX_ +#endif // _AdvancedEngine_IDividedDisk_HXX_ diff --git a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx b/src/AdvancedEngine/AdvancedEngine_IOperations.cxx similarity index 92% rename from src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx rename to src/AdvancedEngine/AdvancedEngine_IOperations.cxx index 59c4d95f8..e713e003a 100644 --- a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.cxx +++ b/src/AdvancedEngine/AdvancedEngine_IOperations.cxx @@ -16,10 +16,16 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : GEOMImpl_IAdvancedOperations.cxx +// File : AdvancedEngine_IOperations.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -#include "GEOMImpl_IAdvancedOperations.hxx" +#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 @@ -45,15 +51,7 @@ #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 @@ -116,10 +114,10 @@ * Constructor */ //============================================================================= -GEOMImpl_IAdvancedOperations::GEOMImpl_IAdvancedOperations(GEOM_Engine* theEngine, int theDocID) : +AdvancedEngine_IOperations::AdvancedEngine_IOperations(GEOM_Engine* theEngine, int theDocID) : GEOM_IOperations(theEngine, theDocID) { - MESSAGE("GEOMImpl_IAdvancedOperations::GEOMImpl_IAdvancedOperations"); + MESSAGE("AdvancedEngine_IOperations::AdvancedEngine_IOperations"); myBasicOperations = new GEOMImpl_IBasicOperations(GetEngine(), GetDocID()); myBooleanOperations = new GEOMImpl_IBooleanOperations(GetEngine(), GetDocID()); myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID()); @@ -136,9 +134,9 @@ GEOMImpl_IAdvancedOperations::GEOMImpl_IAdvancedOperations(GEOM_Engine* theEngin * Destructor */ //============================================================================= -GEOMImpl_IAdvancedOperations::~GEOMImpl_IAdvancedOperations() +AdvancedEngine_IOperations::~AdvancedEngine_IOperations() { - MESSAGE("GEOMImpl_IAdvancedOperations::~GEOMImpl_IAdvancedOperations"); + MESSAGE("AdvancedEngine_IOperations::~AdvancedEngine_IOperations"); delete myBasicOperations; delete myBooleanOperations; delete myShapesOperations; @@ -155,10 +153,10 @@ GEOMImpl_IAdvancedOperations::~GEOMImpl_IAdvancedOperations() * SetPosition */ //============================================================================= -gp_Trsf GEOMImpl_IAdvancedOperations::GetPositionTrsf(double theL1, double theL2, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3) +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); @@ -196,11 +194,11 @@ gp_Trsf GEOMImpl_IAdvancedOperations::GetPositionTrsf(double theL1, double theL2 * */ //============================================================================= -bool GEOMImpl_IAdvancedOperations::CheckCompatiblePosition(double& theL1, double& theL2, - Handle(GEOM_Object) theP1, - Handle(GEOM_Object) theP2, - Handle(GEOM_Object) theP3, - double theTolerance) +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())); @@ -267,12 +265,12 @@ bool GEOMImpl_IAdvancedOperations::CheckCompatiblePosition(double& theL1, double * 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) +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); @@ -807,7 +805,7 @@ bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int * Return faces that are laying on surface. */ //============================================================================= -bool GEOMImpl_IAdvancedOperations::GetFacesOnSurf +bool AdvancedEngine_IOperations::GetFacesOnSurf (const TopoDS_Shape &theShape, const Handle_Geom_Surface& theSurface, const Standard_Real theTolerance, @@ -863,7 +861,7 @@ bool GEOMImpl_IAdvancedOperations::GetFacesOnSurf * Creates and returns conical face. */ //============================================================================= -TopoDS_Shape GEOMImpl_IAdvancedOperations::MakeConicalFace +TopoDS_Shape AdvancedEngine_IOperations::MakeConicalFace (const gp_Ax2 &theAxis, const double theRadius, const double theRadiusThin, @@ -902,7 +900,7 @@ TopoDS_Shape GEOMImpl_IAdvancedOperations::MakeConicalFace * Generate the internal group of a Pipe T-Shape */ //============================================================================= -bool GEOMImpl_IAdvancedOperations::MakeInternalGroup +bool AdvancedEngine_IOperations::MakeInternalGroup (const Handle(GEOM_Object) &theShape, const double theR1, const double theLen1, const double theR2, const double theLen2, @@ -1074,7 +1072,7 @@ bool GEOMImpl_IAdvancedOperations::MakeInternalGroup Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_TSHAPE); Handle(GEOM_Function) aFunction = - aCone->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); + aCone->AddFunction(AdvancedEngine_PipeTShapeDriver::GetID(), TSHAPE_BASIC); TopTools_ListIteratorOfListOfShape aFIter(aConicalFaces); Handle(GEOM_Object) aConeFromShape; @@ -1133,11 +1131,11 @@ bool GEOMImpl_IAdvancedOperations::MakeInternalGroup 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) +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); @@ -1151,9 +1149,7 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t 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(""); @@ -1617,9 +1613,9 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t } // Mirror and glue faces -bool GEOMImpl_IAdvancedOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, - double theR1, double theW1, double theL1, - double theR2, double theW2, double theL2) +bool AdvancedEngine_IOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, + double theR1, double theW1, double theL1, + double theR2, double theW2, double theL2) { SetErrorCode(KO); @@ -1726,7 +1722,7 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Objec //purpose : Static method. Add thiskness reduction elements at the three // open ends of the T-Shape. //======================================================================= -TopoDS_Shape GEOMImpl_IAdvancedOperations::MakePipeTShapeThicknessReduction +TopoDS_Shape AdvancedEngine_IOperations::MakePipeTShapeThicknessReduction (TopoDS_Shape theShape, double r1, double w1, double l1, double r2, double w2, double l2, @@ -1757,7 +1753,7 @@ TopoDS_Shape GEOMImpl_IAdvancedOperations::MakePipeTShapeThicknessReduction 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 + TopoDS_Shape aReductionLeft = AdvancedEngine_IOperations::MakeThicknessReduction (anAxesLeft, r1, w1, rL, wL, ltransL, lthinL, fuseReductions); if (fuseReductions) { @@ -1780,7 +1776,7 @@ TopoDS_Shape GEOMImpl_IAdvancedOperations::MakePipeTShapeThicknessReduction 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 + TopoDS_Shape aReductionRight = AdvancedEngine_IOperations::MakeThicknessReduction (anAxesRight, r1, w1, rR, wR, ltransR, lthinR, fuseReductions); if (fuseReductions) { @@ -1803,7 +1799,7 @@ TopoDS_Shape GEOMImpl_IAdvancedOperations::MakePipeTShapeThicknessReduction 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 + TopoDS_Shape aReductionInci = AdvancedEngine_IOperations::MakeThicknessReduction (anAxesInci, r2, w2, rI, wI, ltransI, lthinI, fuseReductions); if (fuseReductions) { @@ -1848,11 +1844,11 @@ TopoDS_Shape GEOMImpl_IAdvancedOperations::MakePipeTShapeThicknessReduction //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) +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) { @@ -1956,26 +1952,26 @@ TopoDS_Shape GEOMImpl_IAdvancedOperations::MakeThicknessReduction (gp_Ax2 theAxe */ //============================================================================= 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) + 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("GEOMImpl_IAdvancedOperations::MakePipeTShape"); + 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(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); + 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() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; - GEOMImpl_IPipeTShape aData (aFunction); + AdvancedEngine_IPipeTShape aData (aFunction); aData.SetR1(theR1); aData.SetW1(theW1); @@ -1991,9 +1987,7 @@ Handle(TColStd_HSequenceOfTransient) //Compute the resulting value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("TShape driver failed"); return NULL; @@ -2110,7 +2104,7 @@ Handle(TColStd_HSequenceOfTransient) */ //============================================================================= Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition +AdvancedEngine_IOperations::MakePipeTShapeWithPosition (double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theRL, double theWL, double theLtransL, double theLthinL, @@ -2128,18 +2122,18 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition // TSHAPE CODE ///////////////// //Add a new shape function with parameters - Handle(GEOM_Function) aFunction = aShape->AddFunction(GEOMImpl_PipeTShapeDriver::GetID(), TSHAPE_BASIC); + 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() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; // Check new position if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { return NULL; } - GEOMImpl_IPipeTShape aData(aFunction); + AdvancedEngine_IPipeTShape aData(aFunction); aData.SetR1(theR1); aData.SetW1(theW1); @@ -2155,9 +2149,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition //Compute the resulting value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("TShape driver failed"); return NULL; @@ -2282,7 +2274,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition */ //============================================================================= Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer +AdvancedEngine_IOperations::MakePipeTShapeChamfer (double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theRL, double theWL, double theLtransL, double theLthinL, @@ -2295,13 +2287,13 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer //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); + 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() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; - GEOMImpl_IPipeTShape aData(aFunction); + AdvancedEngine_IPipeTShape aData(aFunction); aData.SetR1(theR1); aData.SetW1(theW1); @@ -2319,9 +2311,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer //Compute the resulting value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("TShape driver failed"); return NULL; @@ -2405,9 +2395,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer // 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, @@ -2513,7 +2501,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer */ //============================================================================= Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition +AdvancedEngine_IOperations::MakePipeTShapeChamferWithPosition (double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theRL, double theWL, double theLtransL, double theLthinL, @@ -2529,18 +2517,18 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition //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); + 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() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; // Check new position if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { return NULL; } - GEOMImpl_IPipeTShape aData(aFunction); + AdvancedEngine_IPipeTShape aData(aFunction); aData.SetR1(theR1); aData.SetW1(theW1); @@ -2558,9 +2546,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition //Compute the resulting value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("TShape driver failed"); return NULL; @@ -2642,9 +2628,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition // 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, @@ -2752,7 +2736,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition */ //============================================================================= Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet +AdvancedEngine_IOperations::MakePipeTShapeFillet (double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theRL, double theWL, double theLtransL, double theLthinL, @@ -2764,13 +2748,13 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet //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); + 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() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; - GEOMImpl_IPipeTShape aData(aFunction); + AdvancedEngine_IPipeTShape aData(aFunction); aData.SetR1(theR1); aData.SetW1(theW1); @@ -2787,9 +2771,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet //Compute the resulting value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("TShape driver failed"); return NULL; @@ -2887,9 +2869,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet // 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, @@ -2994,7 +2974,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet */ //============================================================================= Handle(TColStd_HSequenceOfTransient) -GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition +AdvancedEngine_IOperations::MakePipeTShapeFilletWithPosition (double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theRL, double theWL, double theLtransL, double theLthinL, @@ -3009,18 +2989,18 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition //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); + 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() != GEOMImpl_PipeTShapeDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != AdvancedEngine_PipeTShapeDriver::GetID()) return NULL; // Check new position if (!CheckCompatiblePosition(theL1, theL2, theP1, theP2, theP3, 0.01)) { return NULL; } - GEOMImpl_IPipeTShape aData(aFunction); + AdvancedEngine_IPipeTShape aData(aFunction); aData.SetR1(theR1); aData.SetW1(theW1); @@ -3037,9 +3017,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition //Compute the resulting value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("TShape driver failed"); return NULL; @@ -3136,9 +3114,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition // 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, @@ -3238,8 +3214,8 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition * \return New GEOM_Object, containing the created shape. */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDisk (double theR, double theRatio, - int theOrientation, int thePattern) +Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedDisk (double theR, double theRatio, + int theOrientation, int thePattern) { SetErrorCode(KO); @@ -3254,13 +3230,13 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDisk (double theR, 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); + 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() != GEOMImpl_DividedDiskDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != AdvancedEngine_DividedDiskDriver::GetID()) return NULL; - GEOMImpl_IDividedDisk aData (aFunction); + AdvancedEngine_IDividedDisk aData (aFunction); aData.SetR(theR); aData.SetRatio(theRatio); @@ -3269,9 +3245,7 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDisk (double theR, //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; @@ -3312,11 +3286,11 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDisk (double theR, * \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) +Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedDiskPntVecR (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR, + double theRatio, + int thePattern) { SetErrorCode(KO); @@ -3324,13 +3298,13 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDiskPntVecR (Handle 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); + 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() != GEOMImpl_DividedDiskDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != AdvancedEngine_DividedDiskDriver::GetID()) return NULL; - GEOMImpl_IDividedDisk aData (aFunction); + AdvancedEngine_IDividedDisk aData (aFunction); Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); @@ -3346,9 +3320,7 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDiskPntVecR (Handle //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; @@ -3389,9 +3361,9 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedDiskPntVecR (Handle * \return New GEOM_Object, containing the created shape. */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedCylinder (double theR, - double theH, - int thePattern) +Handle(GEOM_Object) AdvancedEngine_IOperations::MakeDividedCylinder (double theR, + double theH, + int thePattern) { SetErrorCode(KO); @@ -3436,10 +3408,10 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeDividedCylinder (double th * \return New GEOM_Object, containing the created shape. */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::list thelPoints, - int theNbMax, - int theDegMax, - double theDMax) +Handle(GEOM_Object) AdvancedEngine_IOperations::MakeSmoothingSurface (std::list thelPoints, + int theNbMax, + int theDegMax, + double theDMax) { SetErrorCode(KO); @@ -3447,13 +3419,13 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::lis 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); + 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() != GEOMImpl_SmoothingSurfaceDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != AdvancedEngine_SmoothingSurfaceDriver::GetID()) return NULL; - GEOMImpl_ISmoothingSurface aData (aFunction); + AdvancedEngine_ISmoothingSurface aData (aFunction); int aLen = thelPoints.size(); aData.SetLength(aLen); @@ -3474,9 +3446,7 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::lis //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; @@ -3505,4 +3475,3 @@ Handle(GEOM_Object) GEOMImpl_IAdvancedOperations::MakeSmoothingSurface (std::lis 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/AdvancedEngine_IOperations.hxx similarity index 81% rename from src/AdvancedEngine/GEOMImpl_IAdvancedOperations.hxx rename to src/AdvancedEngine/AdvancedEngine_IOperations.hxx index 8f59a9590..939dd0171 100644 --- a/src/AdvancedEngine/GEOMImpl_IAdvancedOperations.hxx +++ b/src/AdvancedEngine/AdvancedEngine_IOperations.hxx @@ -16,13 +16,14 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : GEOMImpl_IAdvancedOperations.hxx +// File : AdvancedEngine_IOperations.hxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -#ifndef _GEOMImpl_IAdvancedOperations_HXX_ -#define _GEOMImpl_IAdvancedOperations_HXX_ +#ifndef _AdvancedEngine_IOperations_HXX_ +#define _AdvancedEngine_IOperations_HXX_ + +#include "AdvancedEngine.hxx" -#include #include "GEOM_IOperations.hxx" #include "GEOM_Engine.hxx" #include "GEOM_Object.hxx" @@ -42,7 +43,8 @@ class GEOMImpl_IGroupOperations; class Handle_Geom_Surface; class TopTools_ListOfShape; -class GEOMImpl_IAdvancedOperations: public GEOM_IOperations { +class ADVANCEDENGINE_EXPORT AdvancedEngine_IOperations: public GEOM_IOperations +{ private: bool MakePipeTShapePartition(Handle(GEOM_Object) theShape, double theR1, double theW1, double theL1, @@ -129,7 +131,7 @@ public: * false to obtain parts, useful for hexameshing) * \retval TopoDS_Shape - Resulting shape */ - Standard_EXPORT static TopoDS_Shape MakePipeTShapeThicknessReduction + static TopoDS_Shape MakePipeTShapeThicknessReduction (TopoDS_Shape theShape, double r1, double w1, double l1, double r2, double w2, double l2, @@ -155,17 +157,17 @@ public: * 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); - + 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(); + AdvancedEngine_IOperations(GEOM_Engine* theEngine, int theDocID); + ~AdvancedEngine_IOperations(); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + Handle(TColStd_HSequenceOfTransient) MakePipeTShape(double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theRL, double theWL, double theLtransL, double theLthinL, @@ -173,7 +175,7 @@ public: double theRI, double theWI, double theLtransI, double theLthinI, bool theHexMesh = true); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + Handle(TColStd_HSequenceOfTransient) MakePipeTShapeWithPosition(double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theRL, double theWL, double theLtransL, double theLthinL, @@ -184,7 +186,7 @@ public: Handle(GEOM_Object) P2 = 0, Handle(GEOM_Object) P3 = 0); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + Handle(TColStd_HSequenceOfTransient) MakePipeTShapeChamfer(double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theRL, double theWL, double theLtransL, double theLthinL, @@ -193,7 +195,7 @@ public: double theH, double theW, bool theHexMesh = true); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + Handle(TColStd_HSequenceOfTransient) MakePipeTShapeChamferWithPosition(double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theH, double theW, @@ -205,7 +207,7 @@ public: Handle(GEOM_Object) P2 = 0, Handle(GEOM_Object) P3 = 0); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + Handle(TColStd_HSequenceOfTransient) MakePipeTShapeFillet(double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theRL, double theWL, double theLtransL, double theLthinL, @@ -213,7 +215,7 @@ public: double theRI, double theWI, double theLtransI, double theLthinI, double theRF, bool theHexMesh = true); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) + Handle(TColStd_HSequenceOfTransient) MakePipeTShapeFilletWithPosition(double theR1, double theW1, double theL1, double theR2, double theW2, double theL2, double theRL, double theWL, double theLtransL, double theLthinL, @@ -224,22 +226,22 @@ public: 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); + 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); - Standard_EXPORT Handle(GEOM_Object) MakeDividedCylinder (double theR, - double theH, - int thePattern); + 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 @@*/ + Handle(GEOM_Object) MakeSmoothingSurface (std::list thelPoints, + int theNbMax, + int theDegMax, + double theDMax); }; + #endif diff --git a/src/AdvancedEngine/GEOM_IAdvancedOperations_i.cc b/src/AdvancedEngine/AdvancedEngine_IOperations_i.cc similarity index 92% rename from src/AdvancedEngine/GEOM_IAdvancedOperations_i.cc rename to src/AdvancedEngine/AdvancedEngine_IOperations_i.cc index 7ff12c39d..5afb75b59 100644 --- a/src/AdvancedEngine/GEOM_IAdvancedOperations_i.cc +++ b/src/AdvancedEngine/AdvancedEngine_IOperations_i.cc @@ -22,7 +22,8 @@ #include -#include "GEOM_IAdvancedOperations_i.hh" +#include "AdvancedEngine_IOperations_i.hh" +#include "AdvancedEngine_IOperations.hxx" #include #include @@ -36,10 +37,10 @@ * constructor: */ //============================================================================= -GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IAdvancedOperations* theImpl) +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("GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i"); + MESSAGE("AdvancedEngine_IOperations_i::AdvancedEngine_IOperations_i"); } //============================================================================= @@ -47,9 +48,9 @@ GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i(PortableServer::POA_ptr t * destructor */ //============================================================================= -GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i() +AdvancedEngine_IOperations_i::~AdvancedEngine_IOperations_i() { - MESSAGE("GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i"); + MESSAGE("AdvancedEngine_IOperations_i::~AdvancedEngine_IOperations_i"); } //============================================================================= @@ -68,7 +69,7 @@ GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i() * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShape +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) @@ -114,7 +115,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShape * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeWithPosition +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, @@ -166,7 +167,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeWithPosition * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamfer +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) @@ -215,7 +216,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamfer * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamferWithPosition +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, @@ -265,7 +266,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamferWithPosition * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFillet +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) @@ -313,7 +314,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFillet * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFilletWithPosition +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, @@ -361,7 +362,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFilletWithPosition * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTR +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, @@ -412,7 +413,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTR * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRWithPosition +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, @@ -469,7 +470,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRWithPosition * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRChamfer +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, @@ -523,7 +524,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRChamfer * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRChamferWithPosition +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, @@ -578,7 +579,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRChamferWithPosition * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRFillet +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, @@ -631,7 +632,7 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRFillet * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRFilletWithPosition +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, @@ -677,10 +678,10 @@ GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeTRFilletWithPosition * \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_ptr AdvancedEngine_IOperations_i::MakeDividedDisk (CORBA::Double theR, + CORBA::Double theRatio, + CORBA::Short theOrientation, + GEOM::pattern thePattern) { GEOM::GEOM_Object_var aGEOMObject; @@ -700,11 +701,11 @@ GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedDisk (CORBA::Double * 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_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; @@ -734,9 +735,9 @@ GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedDiskPntVecR (GEOM:: * \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_ptr AdvancedEngine_IOperations_i::MakeDividedCylinder (CORBA::Double theR, + CORBA::Double theH, + GEOM::pattern thePattern) { GEOM::GEOM_Object_var aGEOMObject; @@ -761,10 +762,10 @@ GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeDividedCylinder (CORBA::Do * \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_ptr AdvancedEngine_IOperations_i::MakeSmoothingSurface (const GEOM::ListOfGO& thelPoints, + CORBA::Long theNbMax, + CORBA::Long theDegMax, + CORBA::Double theDMax) { GEOM::GEOM_Object_var aGEOMObject; @@ -789,4 +790,8 @@ GEOM::GEOM_Object_ptr GEOM_IAdvancedOperations_i::MakeSmoothingSurface (const GE return GetObject(anObject); } -/*@@ insert new functions before this line @@ do not remove this line @@*/ +AdvancedEngine_IOperations* AdvancedEngine_IOperations_i::GetOperations() +{ + return (AdvancedEngine_IOperations*)GetImpl(); +} + diff --git a/src/AdvancedEngine/GEOM_IAdvancedOperations_i.hh b/src/AdvancedEngine/AdvancedEngine_IOperations_i.hh similarity index 91% rename from src/AdvancedEngine/GEOM_IAdvancedOperations_i.hh rename to src/AdvancedEngine/AdvancedEngine_IOperations_i.hh index 7f700132d..0711b6ab0 100644 --- a/src/AdvancedEngine/GEOM_IAdvancedOperations_i.hh +++ b/src/AdvancedEngine/AdvancedEngine_IOperations_i.hh @@ -17,31 +17,31 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : GEOM_IAdvancedOperations.hh +// File : AdvancedEngine_IOperations_i.hh // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -#ifndef _GEOM_IAdvancedOperations_i_HeaderFile -#define _GEOM_IAdvancedOperations_i_HeaderFile +#ifndef _AdvancedEngine_IOperations_i_HeaderFile +#define _AdvancedEngine_IOperations_i_HeaderFile -#include "GEOMImpl_Gen.hxx" +#include "AdvancedEngine.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" +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(AdvancedGEOM) -class ADVANCEDENGINE_EXPORT GEOM_IAdvancedOperations_i : - public virtual POA_GEOM::GEOM_IAdvancedOperations, +class AdvancedEngine_IOperations; + +class ADVANCEDENGINE_EXPORT AdvancedEngine_IOperations_i : + public virtual POA_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(); + 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, @@ -131,10 +131,8 @@ class ADVANCEDENGINE_EXPORT GEOM_IAdvancedOperations_i : 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(); } + AdvancedEngine_IOperations* GetOperations(); }; #endif diff --git a/src/AdvancedEngine/GEOMImpl_IPipeTShape.hxx b/src/AdvancedEngine/AdvancedEngine_IPipeTShape.hxx similarity index 93% rename from src/AdvancedEngine/GEOMImpl_IPipeTShape.hxx rename to src/AdvancedEngine/AdvancedEngine_IPipeTShape.hxx index 430856921..b4a26fe9a 100644 --- a/src/AdvancedEngine/GEOMImpl_IPipeTShape.hxx +++ b/src/AdvancedEngine/AdvancedEngine_IPipeTShape.hxx @@ -17,17 +17,17 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef _GEOMImpl_IPipeTShape_HXX_ -#define _GEOMImpl_IPipeTShape_HXX_ +#ifndef _AdvancedEngine_IPipeTShape_HXX_ +#define _AdvancedEngine_IPipeTShape_HXX_ #include "GEOM_Function.hxx" #include -class GEOMImpl_IPipeTShape +class AdvancedEngine_IPipeTShape { public: - GEOMImpl_IPipeTShape(Handle(GEOM_Function) theFunction): _func(theFunction) {} + 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); } @@ -100,4 +100,4 @@ private: Handle(GEOM_Function) _func; }; -#endif // _GEOMImpl_IPipeTShape_HXX_ +#endif // _AdvancedEngine_IPipeTShape_HXX_ diff --git a/src/AdvancedEngine/GEOMImpl_ISmoothingSurface.hxx b/src/AdvancedEngine/AdvancedEngine_ISmoothingSurface.hxx similarity index 89% rename from src/AdvancedEngine/GEOMImpl_ISmoothingSurface.hxx rename to src/AdvancedEngine/AdvancedEngine_ISmoothingSurface.hxx index ec3cf1a24..3ee9bde3e 100644 --- a/src/AdvancedEngine/GEOMImpl_ISmoothingSurface.hxx +++ b/src/AdvancedEngine/AdvancedEngine_ISmoothingSurface.hxx @@ -20,8 +20,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef _GEOMImpl_ISmoothingSurface_HXX_ -#define _GEOMImpl_ISmoothingSurface_HXX_ +#ifndef _AdvancedEngine_ISmoothingSurface_HXX_ +#define _AdvancedEngine_ISmoothingSurface_HXX_ #include "GEOM_Function.hxx" @@ -31,10 +31,10 @@ #define SMOOTHINGSURFACE_ARG_DEG_MAX 4 #define SMOOTHINGSURFACE_ARG_D_MAX 5 -class GEOMImpl_ISmoothingSurface +class AdvancedEngine_ISmoothingSurface { public: - GEOMImpl_ISmoothingSurface(Handle(GEOM_Function) theFunction): _func(theFunction) {} + 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); } @@ -55,4 +55,4 @@ private: Handle(GEOM_Function) _func; }; -#endif // _GEOMImpl_ISmoothingSurface_HXX_ +#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.hxx similarity index 72% rename from src/AdvancedEngine/AdvancedEngine_OperationsCreator.hh rename to src/AdvancedEngine/AdvancedEngine_OperationsCreator.hxx index 261721eee..1264035ca 100755 --- a/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hh +++ b/src/AdvancedEngine/AdvancedEngine_OperationsCreator.hxx @@ -23,30 +23,33 @@ #ifndef _GEOM_ADVANCEDENGINE_OPERATIONSCREATOR_HXX_ #define _GEOM_ADVANCEDENGINE_OPERATIONSCREATOR_HXX_ -#include "GEOM_AdvancedEngine.hxx" +#include "AdvancedEngine.hxx" #include "GEOM_Gen_i.hh" -#include "GEOMImpl_IAdvancedOperations.hxx" - #include +class AdvancedEngine_IOperations; + //===================================================================== // 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(); +public: + AdvancedEngine_OperationsCreator(); + ~AdvancedEngine_OperationsCreator(); - private: - std::map _mapOfOperations; + 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/GEOMImpl_PipeTShapeDriver.cxx b/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.cxx similarity index 93% rename from src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.cxx rename to src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.cxx index 613806b16..7551b43f7 100644 --- a/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.cxx +++ b/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.cxx @@ -17,36 +17,29 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include +#include "AdvancedEngine_PipeTShapeDriver.hxx" +#include "AdvancedEngine_IPipeTShape.hxx" +#include "AdvancedEngine_Types.hxx" +#include "AdvancedEngine_IOperations.hxx" -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include - -// Partition includes -#include -#include +#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 @@ -69,25 +62,22 @@ #include #include -//@@ include required header files here @@// - -#include "AdvancedEngine_Types.hxx" //======================================================================= //function : GetID //purpose : //======================================================================= -const Standard_GUID& GEOMImpl_PipeTShapeDriver::GetID() +const Standard_GUID& AdvancedEngine_PipeTShapeDriver::GetID() { static Standard_GUID aGUID("1C3A0F3F-729D-4E83-8232-78E74FC5637C"); return aGUID; } //======================================================================= -//function : GEOMImpl_PipeTShapeDriver +//function : AdvancedEngine_PipeTShapeDriver //purpose : //======================================================================= -GEOMImpl_PipeTShapeDriver::GEOMImpl_PipeTShapeDriver() +AdvancedEngine_PipeTShapeDriver::AdvancedEngine_PipeTShapeDriver() { } @@ -103,7 +93,7 @@ GEOMImpl_PipeTShapeDriver::GEOMImpl_PipeTShapeDriver() */ //======================================================================= Handle(TColStd_HSequenceOfInteger) -GEOMImpl_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox, +AdvancedEngine_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox, const TopoDS_Shape& aShape, const Standard_Integer theShapeType, GEOMAlgo_State theState) const @@ -176,7 +166,7 @@ GEOMImpl_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox, */ //======================================================================= Handle(TColStd_HSequenceOfInteger) - GEOMImpl_PipeTShapeDriver::GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, + AdvancedEngine_PipeTShapeDriver::GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface, const TopoDS_Shape& theShape, TopAbs_ShapeEnum theShapeType, GEOMAlgo_State theState) const @@ -255,7 +245,7 @@ Handle(TColStd_HSequenceOfInteger) //purpose : return the common shapes between 2 cylindrical surfaces // along OX and OZ //======================================================================= -void GEOMImpl_PipeTShapeDriver::GetCommonShapesOnCylinders(const TopoDS_Shape& theShape, +void AdvancedEngine_PipeTShapeDriver::GetCommonShapesOnCylinders(const TopoDS_Shape& theShape, TopAbs_ShapeEnum theShapeType, double r1, double r2, @@ -308,7 +298,7 @@ void GEOMImpl_PipeTShapeDriver::GetCommonShapesOnCylinders(const TopoDS_Shape& t //function : MakePipeTShape //purpose : //======================================================================= -TopoDS_Shape GEOMImpl_PipeTShapeDriver::MakePipeTShape (const double r1, const double w1, const double l1, +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; @@ -358,7 +348,7 @@ TopoDS_Shape GEOMImpl_PipeTShapeDriver::MakePipeTShape (const double r1, const d //function : MakeQuarterPipeTShape //purpose : //======================================================================= -TopoDS_Shape GEOMImpl_PipeTShapeDriver::MakeQuarterPipeTShape (const double r1, const double w1, const double l1, +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); @@ -390,12 +380,12 @@ TopoDS_Shape GEOMImpl_PipeTShapeDriver::MakeQuarterPipeTShape (const double r1, //function : Execute //purpose : //======================================================================= -Standard_Integer GEOMImpl_PipeTShapeDriver::Execute (TFunction_Logbook& log) const +Standard_Integer AdvancedEngine_PipeTShapeDriver::Execute (TFunction_Logbook& log) const { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - GEOMImpl_IPipeTShape aData (aFunction); + AdvancedEngine_IPipeTShape aData (aFunction); Standard_Integer aType = aFunction->GetType(); TopoDS_Shape aShape, Te4, Te4Part; @@ -624,14 +614,14 @@ Standard_Integer GEOMImpl_PipeTShapeDriver::Execute (TFunction_Logbook& log) con */ //================================================================================ -bool GEOMImpl_PipeTShapeDriver:: +bool AdvancedEngine_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 ); + AdvancedEngine_IPipeTShape aCI( function ); Standard_Integer aType = function->GetType(); theOperationName = "PIPETSHAPE"; @@ -674,5 +664,5 @@ GetCreationInformation(std::string& theOperationName, return true; } -IMPLEMENT_STANDARD_HANDLE (GEOMImpl_PipeTShapeDriver,GEOM_BaseDriver); -IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_PipeTShapeDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_HANDLE (AdvancedEngine_PipeTShapeDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_RTTIEXT (AdvancedEngine_PipeTShapeDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.hxx b/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.hxx similarity index 79% rename from src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.hxx rename to src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.hxx index 3bcdd5574..68e6c254e 100644 --- a/src/AdvancedEngine/GEOMImpl_PipeTShapeDriver.hxx +++ b/src/AdvancedEngine/AdvancedEngine_PipeTShapeDriver.hxx @@ -17,51 +17,39 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef _GEOMImpl_PipeTShapeDriver_HXX -#define _GEOMImpl_PipeTShapeDriver_HXX - -#include +#ifndef _AdvancedEngine_PipeTShapeDriver_HXX +#define _AdvancedEngine_PipeTShapeDriver_HXX +#include "GEOM_BaseDriver.hxx" #include "GEOMAlgo_State.hxx" #include -#include #include -#include #include -#include +#include -#include +DEFINE_STANDARD_HANDLE( AdvancedEngine_PipeTShapeDriver, GEOM_BaseDriver ); -class Handle_Standard_Type; -class GEOMImpl_PipeTShapeDriver; - - - -#include "GEOM_BaseDriver.hxx" - -DEFINE_STANDARD_HANDLE( GEOMImpl_PipeTShapeDriver, GEOM_BaseDriver ); - -class GEOMImpl_PipeTShapeDriver : public GEOM_BaseDriver { +class AdvancedEngine_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 + 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; } - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT ~GEOMImpl_PipeTShapeDriver() {}; + static const Standard_GUID& GetID(); + ~AdvancedEngine_PipeTShapeDriver() {}; - Standard_EXPORT virtual - bool GetCreationInformation(std::string& theOperationName, - std::vector& params); + virtual bool GetCreationInformation(std::string& theOperationName, + std::vector& params); // Type management // -DEFINE_STANDARD_RTTI( GEOMImpl_PipeTShapeDriver ) +DEFINE_STANDARD_RTTI( AdvancedEngine_PipeTShapeDriver ) private: @@ -131,4 +119,4 @@ private: }; -#endif // _GEOMImpl_PipeTShapeDriver_HXX +#endif // _AdvancedEngine_PipeTShapeDriver_HXX diff --git a/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.cxx b/src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.cxx similarity index 90% rename from src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.cxx rename to src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.cxx index 2b0345522..19fef9c52 100644 --- a/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.cxx +++ b/src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.cxx @@ -19,17 +19,15 @@ #include +#include "AdvancedEngine_SmoothingSurfaceDriver.hxx" +#include "AdvancedEngine_ISmoothingSurface.hxx" #include "AdvancedEngine_Types.hxx" -#include -#include -#include -#include +#include "GEOM_Function.hxx" #include #include -//@@ include required header files here @@// #include #include #include @@ -76,21 +74,22 @@ #include #include + //======================================================================= //function : GetID //purpose : //======================================================================= -const Standard_GUID& GEOMImpl_SmoothingSurfaceDriver::GetID() +const Standard_GUID& AdvancedEngine_SmoothingSurfaceDriver::GetID() { static Standard_GUID aGUID("1C3A0F30-729D-4E83-8232-78E74FC5637C"); return aGUID; } //======================================================================= -//function : GEOMImpl_SmoothingSurfaceDriver +//function : AdvancedEngine_SmoothingSurfaceDriver //purpose : //======================================================================= -GEOMImpl_SmoothingSurfaceDriver::GEOMImpl_SmoothingSurfaceDriver() +AdvancedEngine_SmoothingSurfaceDriver::AdvancedEngine_SmoothingSurfaceDriver() { } @@ -98,7 +97,7 @@ GEOMImpl_SmoothingSurfaceDriver::GEOMImpl_SmoothingSurfaceDriver() //function : MakeSmoothingSurfaceUnClosed //purpose : //======================================================================= -TopoDS_Shape GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed +TopoDS_Shape AdvancedEngine_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed (const Handle_TColgp_HArray1OfPnt &theListOfPoints, const Standard_Integer theNbMax, const Standard_Integer theDegMax, @@ -166,7 +165,7 @@ TopoDS_Shape GEOMImpl_SmoothingSurfaceDriver::MakeSmoothingSurfaceUnClosed //function : Execute //purpose : //======================================================================= -Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log) const +Standard_Integer AdvancedEngine_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log) const { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); @@ -177,7 +176,7 @@ Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log if (aType != SMOOTHINGSURFACE_LPOINTS) return 0; // cout << "Youhou : " << aType << endl; - GEOMImpl_ISmoothingSurface aData (aFunction); + AdvancedEngine_ISmoothingSurface aData (aFunction); // Fill the map of vertices. Standard_Integer aNbShapes = aData.GetLength(); @@ -217,7 +216,7 @@ Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log const Standard_Real aDMax = aData.GetDMax(); // Make smoothing surface. - TopoDS_Shape aShape = GEOMImpl_SmoothingSurfaceDriver:: + TopoDS_Shape aShape = AdvancedEngine_SmoothingSurfaceDriver:: MakeSmoothingSurfaceUnClosed(anArrayofPnt, aNbMax, aDegMax, aDMax); if (aShape.IsNull()) return 0; @@ -235,14 +234,14 @@ Standard_Integer GEOMImpl_SmoothingSurfaceDriver::Execute(TFunction_Logbook& log */ //================================================================================ -bool GEOMImpl_SmoothingSurfaceDriver:: +bool AdvancedEngine_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 ); + AdvancedEngine_ISmoothingSurface aCI( function ); Standard_Integer aType = function->GetType(); theOperationName = "SMOOTHINGSURFACE"; @@ -272,5 +271,5 @@ GetCreationInformation(std::string& theOperationName, return true; } -IMPLEMENT_STANDARD_HANDLE (GEOMImpl_SmoothingSurfaceDriver,GEOM_BaseDriver); -IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_SmoothingSurfaceDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_HANDLE (AdvancedEngine_SmoothingSurfaceDriver,GEOM_BaseDriver); +IMPLEMENT_STANDARD_RTTIEXT (AdvancedEngine_SmoothingSurfaceDriver,GEOM_BaseDriver); diff --git a/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.hxx b/src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.hxx similarity index 55% rename from src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.hxx rename to src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.hxx index 6a22f65dc..2e2015fe1 100644 --- a/src/AdvancedEngine/GEOMImpl_SmoothingSurfaceDriver.hxx +++ b/src/AdvancedEngine/AdvancedEngine_SmoothingSurfaceDriver.hxx @@ -17,50 +17,37 @@ // 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; - - +#ifndef _AdvancedEngine_SmoothingSurfaceDriver_HXX +#define _AdvancedEngine_SmoothingSurfaceDriver_HXX #include "GEOM_BaseDriver.hxx" -DEFINE_STANDARD_HANDLE( GEOMImpl_SmoothingSurfaceDriver, GEOM_BaseDriver ); +#include +#include +#include -class GEOMImpl_SmoothingSurfaceDriver : public GEOM_BaseDriver { +DEFINE_STANDARD_HANDLE( AdvancedEngine_SmoothingSurfaceDriver, GEOM_BaseDriver ); + +class AdvancedEngine_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 + 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; } - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT ~GEOMImpl_SmoothingSurfaceDriver() {}; + static const Standard_GUID& GetID(); + ~AdvancedEngine_SmoothingSurfaceDriver() {}; - Standard_EXPORT virtual - bool GetCreationInformation(std::string& theOperationName, - std::vector& params); + virtual bool GetCreationInformation(std::string& theOperationName, + std::vector& params); // Type management // -DEFINE_STANDARD_RTTI( GEOMImpl_SmoothingSurfaceDriver ) +DEFINE_STANDARD_RTTI( AdvancedEngine_SmoothingSurfaceDriver ) private: TopoDS_Shape MakeSmoothingSurfaceUnClosed @@ -70,4 +57,4 @@ private: const Standard_Real theDMax) const; }; -#endif // _GEOMImpl_SmoothingSurfaceDriver_HXX +#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/AdvancedGUI/AdvancedGUI_images.ts b/src/AdvancedGUI/AdvancedGEOM_images.ts similarity index 100% rename from src/AdvancedGUI/AdvancedGUI_images.ts rename to src/AdvancedGUI/AdvancedGEOM_images.ts diff --git a/src/AdvancedGUI/AdvancedGUI_msg_en.ts b/src/AdvancedGUI/AdvancedGEOM_msg_en.ts similarity index 89% rename from src/AdvancedGUI/AdvancedGUI_msg_en.ts rename to src/AdvancedGUI/AdvancedGEOM_msg_en.ts index 172d0b42f..06ab04312 100644 --- a/src/AdvancedGUI/AdvancedGUI_msg_en.ts +++ b/src/AdvancedGUI/AdvancedGEOM_msg_en.ts @@ -248,27 +248,27 @@ GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L - Le rayon du tuyau principale ne peut pas être égal à la réduction d'épaisseur à gauche (rL)! + The main pipe radius can't be equal to the left thickness reduction radius (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)! + 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 - Le rayon du tuyau principal ne peut pas être égal au rayon de la réduction d'épaisseur à droite (rR)! + The main pipe radius can't be equal to the right thickness reduction radius (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)! + 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 - Le rayon du tuyau incident ne peut pas être égal au rayon de la réduction d'épaisseur du tuyau incident (rI)! + The incident pipe radius can't be equal to the incident pipe thickness reduction radius (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)! + The incident pipe external radius (Radius + Width) can't be equal to the incident pipe thickness reduction external radius (rI + wI) diff --git a/src/AdvancedGUI/AdvancedGUI_msg_fr.ts b/src/AdvancedGUI/AdvancedGEOM_msg_fr.ts similarity index 90% rename from src/AdvancedGUI/AdvancedGUI_msg_fr.ts rename to src/AdvancedGUI/AdvancedGEOM_msg_fr.ts index b3f38261a..912a3008c 100644 --- a/src/AdvancedGUI/AdvancedGUI_msg_fr.ts +++ b/src/AdvancedGUI/AdvancedGEOM_msg_fr.ts @@ -248,27 +248,27 @@ GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L - Main pipe Radius can't be equal to Left thickness reduction Radius (rL)! + Le rayon du tuyau principal ne peut pas être égal à la réduction d'épaisseur à gauche (rL) GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_L - Main pipe external Radius (Radius + Width) can't be equal to Left thickness reduction external Radius (rL + wL)! + 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 - Main pipe Radius can't be equal to Right thickness reduction Radius (rR)! + 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 - Main pipe external Radius (Radius + Width) can't be equal to Right thickness reduction external Radius (rR + wR)! + 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 - Incident pipe Radius can't be equal to Incident pipe thickness reduction Radius (rI)! + 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 - Incident pipe external Radius (Rayon + Epaisseur) can't be equal to Incident pipe thickness reduction external Radius (rI + wI)! + 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) diff --git a/src/AdvancedGUI/AdvancedGUI_msg_ja.ts b/src/AdvancedGUI/AdvancedGEOM_msg_ja.ts similarity index 100% rename from src/AdvancedGUI/AdvancedGUI_msg_ja.ts rename to src/AdvancedGUI/AdvancedGEOM_msg_ja.ts diff --git a/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx b/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx index 682433f1e..721667206 100644 --- a/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx +++ b/src/AdvancedGUI/AdvancedGUI_DividedCylinderDlg.cxx @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -217,7 +216,6 @@ void AdvancedGUI_DividedCylinderDlg::ValueChangedInSpinBox() //================================================================================= GEOM::GEOM_IOperations_ptr AdvancedGUI_DividedCylinderDlg::createOperation() { - //return getGeomEngine()->GetIAdvancedOperations(getStudyId()); return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine"); } @@ -244,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 46be04e60..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 @@ -33,7 +36,6 @@ #include #include #include -#include #include #include @@ -188,7 +190,6 @@ void AdvancedGUI_SmoothingSurfaceDlg::enterEvent (QEvent*) //================================================================================= GEOM::GEOM_IOperations_ptr AdvancedGUI_SmoothingSurfaceDlg::createOperation() { - //return getGeomEngine()->GetIAdvancedOperations(getStudyId()); return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine"); } @@ -220,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/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/OBJECT/GEOM_InteractiveObject.jxx b/src/BREPPlugin/BREPPlugin_Engine.hxx old mode 100644 new mode 100755 similarity index 63% rename from src/OBJECT/GEOM_InteractiveObject.jxx rename to src/BREPPlugin/BREPPlugin_Engine.hxx index f7ea09ed3..3dde5d56b --- a/src/OBJECT/GEOM_InteractiveObject.jxx +++ b/src/BREPPlugin/BREPPlugin_Engine.hxx @@ -1,7 +1,4 @@ -// 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 +// 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 @@ -20,13 +17,17 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// GEOM OBJECT : interactive object for Geometry entities visualization -// File : GEOM_InteractiveObject.jxx -// Module : GEOM -// -#ifndef _SALOME_InteractiveObject_HeaderFile -#include "SALOME_InteractiveObject.hxx" +#ifndef _BREPPLUGIN_ENGINE_HXX_ +#define _BREPPLUGIN_ENGINE_HXX_ + +#ifdef WIN32 + #if defined BREPPluginEngine_EXPORTS + #define BREPPLUGINENGINE_EXPORT __declspec( dllexport ) + #else + #define BREPPLUGINENGINE_EXPORT __declspec( dllimport ) + #endif +#else + #define BREPPLUGINENGINE_EXPORT #endif -#ifndef _GEOM_InteractiveObject_HeaderFile -#include "GEOM_InteractiveObject.hxx" + #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..00c6dbdf3 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_ExportDriver.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_ExportDriver_HXX +#define _BREPPlugin_ExportDriver_HXX + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( BREPPlugin_ExportDriver, GEOM_BaseDriver ); + +class 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..8ccabe9a8 --- /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..d92940798 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_IOperations.cxx @@ -0,0 +1,167 @@ +// 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 { + OCC_CATCH_SIGNALS; + 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 { + OCC_CATCH_SIGNALS; + 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..e6a2940d0 --- /dev/null +++ b/src/BREPPlugin/BREPPlugin_ImportDriver.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_ImportDriver_HXX +#define _BREPPlugin_ImportDriver_HXX + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( BREPPlugin_ImportDriver, GEOM_BaseDriver ); + +class 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..34a88046b --- /dev/null +++ b/src/BREPPlugin/CMakeLists.txt @@ -0,0 +1,152 @@ +# 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} + ${OMNIORB_DEFINITIONS} + ) + +IF(WIN32) + ADD_DEFINITIONS(-DNOGDI) +ENDIF(WIN32) + +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/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx index 4f0d910de..fff94014c 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.cxx +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -35,7 +35,6 @@ #include #include -#include #include #include #include diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx index bd5781fdc..54cbb52be 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.cxx +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -36,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/src/BasicGUI/BasicGUI_CurveDlg.cxx b/src/BasicGUI/BasicGUI_CurveDlg.cxx index e3b91042d..500f204d4 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.cxx +++ b/src/BasicGUI/BasicGUI_CurveDlg.cxx @@ -37,7 +37,6 @@ #include #include -#include #include #include diff --git a/src/BlockFix/BlockFix_UnionEdges.cxx b/src/BlockFix/BlockFix_UnionEdges.cxx index eff6eda75..09c2caf0d 100644 --- a/src/BlockFix/BlockFix_UnionEdges.cxx +++ b/src/BlockFix/BlockFix_UnionEdges.cxx @@ -30,7 +30,6 @@ #include -#include #include #include @@ -39,16 +38,16 @@ #include #include #include -#include #include #include +#include #include #include #include -#include #include +#include #include #include #include @@ -57,15 +56,12 @@ #include #include #include -#include #include -#include #include -#include - #include +#include #include #include #include @@ -85,12 +81,144 @@ #include #include #include -#include #include +#include +#include #include #include "utilities.h" + +//======================================================================= +//function : IsToMerge +//purpose : This method return Standard_True if two consequent edges can +// be merged. The edges can be merged if: +// 1. They belong to same faces. +// 2. They either both seam or both not seam on each face. +// 3. They are based on coincident lines, or: +// 4. They are based on coincident circles, or: +// 5. They are based on either Bezier of BSplines. +//======================================================================= +static Standard_Boolean IsToMerge + (const TopoDS_Edge &theEdge1, + const TopoDS_Edge &theEdge2, + const TopTools_IndexedDataMapOfShapeListOfShape &theMapEdgeFaces, + const Standard_Real theTolerance) +{ + Standard_Boolean aResult = Standard_False; + Standard_Boolean isDegen1 = BRep_Tool::Degenerated(theEdge1); + Standard_Boolean isDegen2 = BRep_Tool::Degenerated(theEdge2); + Standard_Boolean isCompareGeom = Standard_False; + + if (isDegen1 && isDegen2) { + // Both of edges are degenerated. + aResult = Standard_True; + } else if (!isDegen1 && !isDegen2) { + // Both of edges are not degenerated. + // Check if they belong to the same faces. + Standard_Boolean isSame = Standard_False; + Standard_Boolean has1 = theMapEdgeFaces.Contains(theEdge1); + Standard_Boolean has2 = theMapEdgeFaces.Contains(theEdge1); + + if (has1 && has2) { + const TopTools_ListOfShape &aLst1 = theMapEdgeFaces.FindFromKey(theEdge1); + const TopTools_ListOfShape &aLst2 = theMapEdgeFaces.FindFromKey(theEdge2); + + if (aLst1.Extent() == aLst2.Extent()) { + TopTools_ListIteratorOfListOfShape anIter1(aLst1); + + isSame = Standard_True; + + for (; anIter1.More(); anIter1.Next()) { + TopoDS_Face aFace1 = TopoDS::Face(anIter1.Value()); + TopTools_ListIteratorOfListOfShape anIter2(aLst2); + + for (; anIter2.More(); anIter2.Next()) { + if (aFace1.IsSame(anIter2.Value())) { + // Same face is detected. Break the loop. + // Check if edges either both seam or both not seam on this face. + Standard_Boolean isSeam1 = BRep_Tool::IsClosed(theEdge1, aFace1); + Standard_Boolean isSeam2 = BRep_Tool::IsClosed(theEdge2, aFace1); + + isSame = (isSeam1 && isSeam2) || (isSeam1 == isSeam2); + break; + } + } + + if (isSame && !anIter2.More()) { + // No same face is detected. Break the loop. + isSame = Standard_False; + break; + } + } + } + } else { + isSame = (has1 == has2); // True if the both of has are negative. + } + + if (isSame) { + // Check edges geometry. + Standard_Real aFP1; + Standard_Real aFP2; + Standard_Real aLP1; + Standard_Real aLP2; + Handle(Geom_Curve) aC3d1 = BRep_Tool::Curve(theEdge1, aFP1, aLP1); + Handle(Geom_Curve) aC3d2 = BRep_Tool::Curve(theEdge2, aFP2, aLP2); + + if (aC3d1.IsNull() == Standard_False && + aC3d2.IsNull() == Standard_False) { + // Get the basis curves. + while(aC3d1->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) aTc = + Handle(Geom_TrimmedCurve)::DownCast(aC3d1); + aC3d1 = aTc->BasisCurve(); + } + + while(aC3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) aTc = + Handle(Geom_TrimmedCurve)::DownCast(aC3d2); + aC3d2 = aTc->BasisCurve(); + } + + if(aC3d1->IsKind(STANDARD_TYPE(Geom_Line)) && + aC3d2->IsKind(STANDARD_TYPE(Geom_Line))) { + // Two curves are lines. + Handle(Geom_Line) aL1 = Handle(Geom_Line)::DownCast(aC3d1); + Handle(Geom_Line) aL2 = Handle(Geom_Line)::DownCast(aC3d2); + gp_Dir aDir1 = aL1->Position().Direction(); + gp_Dir aDir2 = aL2->Position().Direction(); + + if(aDir1.IsParallel(aDir2, theTolerance)) { + // Two coincident lines. + aResult = Standard_True; + } + } else if(aC3d1->IsKind(STANDARD_TYPE(Geom_Circle)) && + aC3d2->IsKind(STANDARD_TYPE(Geom_Circle))) { + // Two curves are circles. + Handle(Geom_Circle) aC1 = Handle(Geom_Circle)::DownCast(aC3d1); + Handle(Geom_Circle) aC2 = Handle(Geom_Circle)::DownCast(aC3d2); + gp_Pnt aP01 = aC1->Location(); + gp_Pnt aP02 = aC2->Location(); + + if (aP01.Distance(aP02) <= Precision::Confusion()) { + // Two coincident circles. + aResult = Standard_True; + } + } else if (aC3d1->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) || + aC3d1->IsKind(STANDARD_TYPE(Geom_BezierCurve))) { + if (aC3d2->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) || + aC3d2->IsKind(STANDARD_TYPE(Geom_BezierCurve))) { + // Both of the curves are either bezier or BSplines. + aResult = Standard_True; + } + } + } + } + } + + return aResult; +} + //======================================================================= //function : BlockFix_UnionEdges() //purpose : Constructor @@ -263,55 +391,11 @@ static TopoDS_Edge GlueEdgesWithPCurves(const TopTools_SequenceOfShape& aChain, return ResEdge; } -//======================================================================= -//function : IsFixed -//purpose : Returns true if this vertex should be kept in the result. -//======================================================================= -static Standard_Boolean IsFixed - (const TopoDS_Vertex &theVtx, - const TopoDS_Face &theFace, - const TopTools_IndexedDataMapOfShapeListOfShape &theMapVtxEdgeOnFace) -{ - Standard_Boolean aResult = Standard_False; - - if (theMapVtxEdgeOnFace.Contains(theVtx)) { - const TopTools_ListOfShape& aList = theMapVtxEdgeOnFace.FindFromKey(theVtx); - TopTools_ListIteratorOfListOfShape anIter(aList); - Standard_Boolean isFirst = Standard_True; - Standard_Boolean isSeam = Standard_False; - - for ( ; anIter.More(); anIter.Next()) { - TopoDS_Edge anEdge = TopoDS::Edge(anIter.Value()); - - if (isFirst) { - // This is the first treated edge. - isFirst = Standard_False; - isSeam = BRep_Tool::IsClosed(anEdge, theFace); - } else if (BRep_Tool::IsClosed(anEdge, theFace)) { - // Seam edge. - if (!isSeam) { - // The previous one was not seam. - aResult = Standard_True; - break; - } - } else if (isSeam) { - // This is not a seam edge however the previous one was seam. - aResult = Standard_True; - break; - } - } - } - - return aResult; -} - //======================================================================= //function : MergeEdges //purpose : auxilary //======================================================================= static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, - const TopoDS_Face& theFace1, - const TopoDS_Face& theFace2, const Standard_Real Tol, TopoDS_Edge& anEdge) { @@ -352,61 +436,6 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, return Standard_False; } - // Check if there are vertices that should be kept in the result. - const Standard_Boolean isClosed = VF.IsSame(VL); - TopTools_IndexedDataMapOfShapeListOfShape theMapVtxEdge1; - TopTools_IndexedDataMapOfShapeListOfShape theMapVtxEdge2; - Standard_Integer jSplit = -1; - - TopExp::MapShapesAndAncestors(theFace1, TopAbs_VERTEX, TopAbs_EDGE, theMapVtxEdge1); - TopExp::MapShapesAndAncestors(theFace2, TopAbs_VERTEX, TopAbs_EDGE, theMapVtxEdge2); - - // Check if intermediate vertices should be in the result. - for(j = 1; j < aChain.Length(); j++) { - TopoDS_Edge anEdge = TopoDS::Edge(aChain.Value(j)); - TopoDS_Vertex aVtx = sae.LastVertex(anEdge); - - if (IsFixed(aVtx, theFace1, theMapVtxEdge1) || - IsFixed(aVtx, theFace2, theMapVtxEdge2)) { - // This vertex should be kept. - if (jSplit > 0) { - // There is already split vertex detected. - // It means that these edges can't be merged. - MESSAGE ("Two edges on closed contour can't be merged."); - return Standard_False; - } else if (isClosed) { - // This is a closed contour. - // It is possible to merge it starting from the next edge. - jSplit = j; - } else { - // The contour is not closed, this vertex sould be kept. - // It means that these edges can't be merged. - MESSAGE ("Two edges on not closed contour can't be merged."); - return Standard_False; - } - } - } - - if (jSplit > 0) { - // This is closed contour. Check the last (it is first as well) vertex, - // as it becomes intermediate after reordering. - TopoDS_Edge anEdge = TopoDS::Edge(aChain.Last()); - TopoDS_Vertex aVtx = sae.LastVertex(anEdge); - - if (IsFixed(aVtx, theFace1, theMapVtxEdge1) || - IsFixed(aVtx, theFace2, theMapVtxEdge2)) { - // This vertex should be kept. So we can't merge this contour. - MESSAGE ("Two edges on closed contour can't be merged."); - return Standard_False; - } - - // Reorder edges in the sequence to have jSplit-th edge last. - for(j = 1; j <= jSplit; j++) { - aChain.Append(aChain.First()); - aChain.Remove(1); - } - } - // union edges in chain // first step: union lines and circles TopLoc_Location Loc; @@ -453,9 +482,6 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, B.Add (E,V1); B.Add (E,V2); B.UpdateVertex(V1, 0., E, 0.); B.UpdateVertex(V2, dist, E, 0.); - //ShapeFix_Edge sfe; - //sfe.FixAddPCurve(E,aFace,Standard_False); - //sfe.FixSameParameter(E); aChain.Remove(j); aChain.SetValue(j,E); j--; @@ -555,21 +581,6 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, if(NeedUnion) { MESSAGE ("can not make analitical union => make approximation"); TopoDS_Edge E = GlueEdgesWithPCurves(aChain, VF, VL); - /* - TopoDS_Wire W; - B.MakeWire(W); - for(j=1; j<=aChain.Length(); j++) { - TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); - B.Add(W,edge); - } - Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W); - Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000); - Handle(Geom_BSplineCurve) bc = Conv.Curve(); - TopoDS_Edge E; - B.MakeEdge (E,bc,Precision::Confusion()); - B.Add (E,VF); - B.Add (E,VL); - */ aChain.SetValue(1,E); } else { @@ -586,120 +597,186 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, //function : Perform //purpose : //======================================================================= -TopoDS_Shape BlockFix_UnionEdges::Perform(const TopoDS_Shape& Shape, - const Standard_Real Tol) +TopoDS_Shape BlockFix_UnionEdges::Perform(const TopoDS_Shape& theShape, + const Standard_Real theTol) { - myContext = new ShapeBuild_ReShape; - myTolerance = Tol; - TopoDS_Shape aResult = myContext->Apply(Shape); + // Fill Map of edges as keys and list of faces as items. + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + Standard_Boolean isModified = Standard_False; - // processing each solid - TopAbs_ShapeEnum aType = TopAbs_SOLID; - TopExp_Explorer exps (Shape, aType); - if (!exps.More()) { - aType = TopAbs_SHELL; - exps.Init(Shape, aType); + TopExp::MapShapesAndAncestors + (theShape, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + // processing each face + Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; + TopTools_MapOfShape aProcessed; + TopTools_MapOfShape aModifiedFaces; + TopExp_Explorer anExpF(theShape, TopAbs_FACE); + + for (; anExpF.More(); anExpF.Next()) { + // Processing of each wire of the face + TopoDS_Face aFace = TopoDS::Face(anExpF.Current()); + + if (!aProcessed.Add(aFace)) { + continue; + } + + TopExp_Explorer anExpW(aFace, TopAbs_WIRE); + + for (; anExpW.More(); anExpW.Next()) { + // Get the ordered list of edges in the wire. + TopoDS_Wire aWire = TopoDS::Wire(anExpW.Current()); + BRepTools_WireExplorer aWExp(aWire, aFace); + TopTools_ListOfShape aChainEdges; + Standard_Integer aNbEdges = 0; + + for (; aWExp.More(); aWExp.Next(), aNbEdges++) { + aChainEdges.Append(aWExp.Current()); + } + + if (aNbEdges < 2) { + // Nothing to merge. + continue; + } + + // Fill the list of flags that neighbour edges can be merged. + TColStd_ListOfInteger aChainCanMerged; + TopoDS_Edge anEdge1 = TopoDS::Edge(aChainEdges.Last()); + TopoDS_Edge anEdge2; + Standard_Boolean isToMerge; + TopTools_ListIteratorOfListOfShape anIter(aChainEdges); + Standard_Boolean isFirstMerge = Standard_False; + Standard_Boolean isFirst = Standard_True; + Standard_Boolean isReorder = Standard_False; + + // The first element is the flag between last and first edges. + for (; anIter.More(); anIter.Next()) { + anEdge2 = TopoDS::Edge(anIter.Value()); + + if (aProcessed.Contains(anEdge1) || aProcessed.Contains(anEdge2)) { + // No need to merge already processed edges. + isToMerge = Standard_False; + } else { + isToMerge = IsToMerge(anEdge1, anEdge2, aMapEdgeFaces, theTol); + } + + aChainCanMerged.Append(isToMerge); + anEdge1 = anEdge2; + + if (isFirst) { + isFirstMerge = isToMerge; + isFirst = Standard_False; + } else if (isFirstMerge && !isToMerge) { + isReorder = Standard_True; + } + } + + // Fill the map of processed shape by the edges. + for (anIter.Initialize(aChainEdges); anIter.More(); anIter.Next()) { + aProcessed.Add(anIter.Value()); + } + + // Reorder edges in the chain. + if (isReorder) { + // Find the first edge that can't be merged. + while (aChainCanMerged.First()) { + TopoDS_Shape aTmpShape = aChainEdges.First(); + + isToMerge = aChainCanMerged.First(); + aChainCanMerged.RemoveFirst(); + aChainCanMerged.Append(isToMerge); + aChainEdges.RemoveFirst(); + aChainEdges.Append(aTmpShape); + } + } + + // Merge parts of chain to be merged. + TColStd_ListIteratorOfListOfInteger aFlagIter(aChainCanMerged); + anIter.Initialize(aChainEdges); + + while (anIter.More()) { + TopTools_SequenceOfShape aSeqEdges; + + aSeqEdges.Append(anIter.Value()); + aFlagIter.Next(); + anIter.Next(); + + for (; anIter.More(); anIter.Next(), aFlagIter.Next()) { + if (aFlagIter.Value()) { + // Continue the chain. + aSeqEdges.Append(anIter.Value()); + } else { + // Stop the chain. + break; + } + } + + const Standard_Integer aNbEdges = aSeqEdges.Length(); + + if (aNbEdges > 1) { + // There are several edges to be merged. + TopoDS_Edge aMergedEdge; + + if (MergeEdges(aSeqEdges, theTol, aMergedEdge)) { + isModified = Standard_True; + // now we have only one edge - aMergedEdge. + // we have to replace old ListEdges with this new edge + const TopoDS_Shape &anEdge = aSeqEdges.Value(1); + + aContext->Replace(anEdge, aMergedEdge); + + for (Standard_Integer j = 2; j <= aNbEdges; j++) { + aContext->Remove(aSeqEdges(j)); + } + + // Fix affected faces. + if (aMapEdgeFaces.Contains(anEdge)) { + const TopTools_ListOfShape &aList = + aMapEdgeFaces.FindFromKey(anEdge); + TopTools_ListIteratorOfListOfShape anIter(aList); + + for (; anIter.More(); anIter.Next()) { + aModifiedFaces.Add(anIter.Value()); + } + } + } + } + } + } } - for (; exps.More(); exps.Next()) { - //TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); - TopoDS_Shape aSolid = exps.Current(); - TopTools_IndexedMapOfShape ChangedFaces; + if (isModified) { + // Fix modified faces. + TopTools_MapIteratorOfMapOfShape aModifIt(aModifiedFaces); - // creating map of edge faces - TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; - TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + for (; aModifIt.More(); aModifIt.Next()) { + TopoDS_Face aModifiedFace = + TopoDS::Face(aContext->Apply(aModifIt.Key())); + Handle(ShapeFix_Face) aSff = new ShapeFix_Face(aModifiedFace); - Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; - TopoDS_Shape aRes = aSolid; - aRes = aContext->Apply(aSolid); - - // processing each face - TopExp_Explorer exp; - for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) { - TopoDS_Face aFace = - TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD))); - TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; - - for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { - TopoDS_Edge edge = TopoDS::Edge(expe.Current()); - if (!aMapEdgeFaces.Contains(edge)) continue; - const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); - TopTools_ListIteratorOfListOfShape anIter(aList); - for ( ; anIter.More(); anIter.Next()) { - TopoDS_Face face = TopoDS::Face(anIter.Value()); - TopoDS_Face face1 = TopoDS::Face(aContext->Apply(anIter.Value())); - if (face1.IsSame(aFace)) continue; - if (aMapFacesEdges.Contains(face)) { - aMapFacesEdges.ChangeFromKey(face).Append(edge); - } - else { - TopTools_ListOfShape ListEdges; - ListEdges.Append(edge); - aMapFacesEdges.Add(face,ListEdges); - } - } - } - - for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) { - const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); - TopTools_SequenceOfShape SeqEdges; - TopTools_ListIteratorOfListOfShape anIter(ListEdges); - for ( ; anIter.More(); anIter.Next()) { - SeqEdges.Append(anIter.Value()); - } - if (SeqEdges.Length()==1) continue; - - TopoDS_Face aFace2 = - TopoDS::Face(aContext->Apply(aMapFacesEdges.FindKey(i))); - TopoDS_Edge E; - if ( MergeEdges(SeqEdges,aFace,aFace2,Tol,E) ) { - // now we have only one edge - aChain.Value(1) - // we have to replace old ListEdges with this new edge - aContext->Replace(SeqEdges(1),E); - for (Standard_Integer j=2; j<=SeqEdges.Length(); j++) { - aContext->Remove(SeqEdges(j)); - } - TopoDS_Face tmpF = TopoDS::Face(exp.Current()); - if ( !ChangedFaces.Contains(tmpF) ) - ChangedFaces.Add(tmpF); - tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i)); - if ( !ChangedFaces.Contains(tmpF) ) - ChangedFaces.Add(tmpF); - } - } - - } // end processing each face - - // fix changed faces and replace them in the local context - for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) { - TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i))); - Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace); - sff->SetContext(myContext); - sff->SetPrecision(myTolerance); - sff->SetMinTolerance(myTolerance); - sff->SetMaxTolerance(Max(1.,myTolerance*1000.)); - sff->Perform(); - aContext->Replace(aFace,sff->Face()); + aSff->SetContext(aContext); + aSff->SetPrecision(theTol); + aSff->SetMinTolerance(theTol); + aSff->SetMaxTolerance(Max(1., theTol*1000.)); + aSff->Perform(); + aContext->Replace(aModifiedFace, aSff->Face()); } - if (ChangedFaces.Extent() > 0) { - // fix changed shell and replace it in the local context - TopoDS_Shape aRes1 = aContext->Apply(aRes); - TopExp_Explorer expsh; - for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) { - TopoDS_Shell aShell = TopoDS::Shell(expsh.Current()); - Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell; - sfsh->FixFaceOrientation(aShell); - aContext->Replace(aShell,sfsh->Shell()); - } - TopoDS_Shape aRes2 = aContext->Apply(aRes1); - // put new solid into global context - myContext->Replace(aSolid,aRes2); + // Check if the result shape contains shells. + // If yes, fix the faces orientation in the shell. + TopoDS_Shape aModifShape = aContext->Apply(theShape); + TopExp_Explorer anExpSh(aModifShape, TopAbs_SHELL); + + for (; anExpSh.More(); anExpSh.Next()) { + TopoDS_Shell aShell = TopoDS::Shell(anExpSh.Current()); + Handle(ShapeFix_Shell) aSfsh = new ShapeFix_Shell; + + aSfsh->FixFaceOrientation(aShell); + aContext->Replace(aShell, aSfsh->Shell()); } + } - } // end processing each solid + const TopoDS_Shape aResult = aContext->Apply(theShape); - aResult = myContext->Apply(Shape); return aResult; } diff --git a/src/BlockFix/BlockFix_UnionFaces.cxx b/src/BlockFix/BlockFix_UnionFaces.cxx old mode 100755 new mode 100644 index 4c6d17e08..86f1065c3 --- a/src/BlockFix/BlockFix_UnionFaces.cxx +++ b/src/BlockFix/BlockFix_UnionFaces.cxx @@ -44,11 +44,7 @@ #include #include -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #include -#else -#include -#endif #include #include @@ -274,9 +270,6 @@ static Standard_Boolean IsEdgeValidToMerge(const TopoDS_Edge &theEdge, //======================================================================= TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) { - Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape; - TopoDS_Shape aResShape = myContext->Apply(Shape); - // Fill Map of faces as keys and list of solids or shells as items. TopTools_IndexedDataMapOfShapeListOfShape aMapFaceSoOrSh; @@ -290,6 +283,8 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) (Shape, TopAbs_FACE, aType, aMapFaceSoOrSh); // processing each solid + Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; + TopTools_MapOfShape aProcessed; TopExp_Explorer exps; for (exps.Init(Shape, aType); exps.More(); exps.Next()) { TopoDS_Shape aSoOrSh = exps.Current(); @@ -298,11 +293,6 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; TopExp::MapShapesAndAncestors(aSoOrSh, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); - // map of processed shapes - TopTools_MapOfShape aProcessed; - - Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; - Standard_Integer NbModif = 0; Standard_Boolean hasFailed = Standard_False; Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1); @@ -324,8 +314,9 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) for (exp.Init(aSoOrSh, TopAbs_FACE); exp.More() && doUnion; exp.Next()) { TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); - if (aProcessed.Contains(aFace)) + if (aProcessed.Contains(aFace)) { continue; + } Standard_Integer dummy; TopTools_SequenceOfShape edges; @@ -338,6 +329,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) TopLoc_Location aBaseLocation; Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation); aBaseSurface = ClearRts(aBaseSurface); + aBaseSurface = Handle(Geom_Surface)::DownCast(aBaseSurface->Copy()); // find adjacent faces to union Standard_Integer i; @@ -439,8 +431,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) // sorting any type of edges aWire = TopoDS::Wire(aContext->Apply(aWire)); - TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD))); - Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion()); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,aResult,Precision::Confusion()); sfw->FixReorder(); Standard_Boolean isDegRemoved = Standard_False; if(!sfw->StatusReorder ( ShapeExtend_FAIL )) { @@ -478,7 +469,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) Standard_Real f,l; //smh protection on NULL pcurve Handle(Geom2d_Curve) c2d; - if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) { + if(!sae.PCurve(sbwd->Edge(j),aResult,c2d,f,l)) { aLastEdge--; continue; } @@ -499,8 +490,8 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) gp_XY aVec = anEnd-aStart; Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart)); - B.UpdateEdge(E,aLine,tmpF,0.); - B.Range(E,tmpF,0.,aVec.Modulus()); + B.UpdateEdge(E,aLine,aResult,0.); + B.Range(E,aResult,0.,aVec.Modulus()); Handle(Geom_Curve) C3d; B.UpdateEdge(E,C3d,0.); B.Degenerated(E,Standard_True); @@ -585,30 +576,27 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) // ptv add fix same parameter sfe.FixSameParameter(E, myTolerance); } - - myContext->Replace(aSoOrSh, aResult); } - //else - { - for (exp.Init(aSoOrSh, TopAbs_FACE); exp.More(); exp.Next()) { - TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); - Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; - sfw->SetContext(myContext); - sfw->SetPrecision(myTolerance); - sfw->SetMinTolerance(myTolerance); - sfw->SetMaxTolerance(Max(1.,myTolerance*1000.)); - sfw->SetFace(aFace); - for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) { - TopoDS_Wire wire = TopoDS::Wire(iter.Value()); - sfw->Load(wire); - sfw->FixReorder(); - sfw->FixShifted(); - } + + for (exp.Init(aSoOrSh, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; + sfw->SetContext(aContext); + sfw->SetPrecision(myTolerance); + sfw->SetMinTolerance(myTolerance); + sfw->SetMaxTolerance(Max(1.,myTolerance*1000.)); + sfw->SetFace(aFace); + for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) { + TopoDS_Wire wire = TopoDS::Wire(iter.Value()); + sfw->Load(wire); + sfw->FixReorder(); + sfw->FixShifted(); } } } // end processing each solid - aResShape = myContext->Apply(Shape); + const TopoDS_Shape aResShape = aContext->Apply(Shape); + return aResShape; } @@ -711,15 +699,10 @@ Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace, Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool(); try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 IntPatch_ImpImpIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); -#else - IntPatch_TheIIIntOfIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); -#endif + if (!anIIInt.IsDone() || anIIInt.IsEmpty()) return false; diff --git a/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx b/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx index b21c722ca..93122335a 100644 --- a/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx @@ -39,7 +39,7 @@ #include #include #include -#include +#include //================================================================================= // class : BlocksGUI_ExplodeDlg() diff --git a/src/BooleanGUI/BooleanGUI_Dialog.cxx b/src/BooleanGUI/BooleanGUI_Dialog.cxx index 3ee6ba47c..bbf88ebe1 100644 --- a/src/BooleanGUI/BooleanGUI_Dialog.cxx +++ b/src/BooleanGUI/BooleanGUI_Dialog.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include // VSR 22/08/2012: issue 0021787: remove "Preview" button from BOP and Partition operations // Comment next line to enable preview in BOP dialog box diff --git a/src/BuildGUI/BuildGUI_WireDlg.cxx b/src/BuildGUI/BuildGUI_WireDlg.cxx index 56625e30d..c0d98db63 100644 --- a/src/BuildGUI/BuildGUI_WireDlg.cxx +++ b/src/BuildGUI/BuildGUI_WireDlg.cxx @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a40066e58..b4f792af1 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,21 +21,12 @@ # 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 ) -## -# Curve creator -## -IF(SALOME_GEOM_BUILD_CC) - SET(SUBDIRS_CC - CurveCreator - ) -ENDIF() - ## # OPENCV ## @@ -51,9 +42,9 @@ ENDIF() IF(SALOME_BUILD_GUI) SET(SUBDIRS_GUI OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI - GEOMBase GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI - EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI - RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI ImportExportGUI + GEOMBase DependencyTree GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI + CurveCreator EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI + RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM ) ENDIF() diff --git a/src/CurveCreator/CMakeLists.txt b/src/CurveCreator/CMakeLists.txt index 34582d31c..15677b68c 100644 --- a/src/CurveCreator/CMakeLists.txt +++ b/src/CurveCreator/CMakeLists.txt @@ -57,9 +57,8 @@ IF(SALOME_BUILD_GUI) # header files / to be processed by moc SET(_moc_HEADERS CurveCreator_NewSectionDlg.h - CurveCreator_NewPointDlg.h + CurveCreator_TableView.h CurveCreator_TreeView.h -# CurveCreator_UndoOptsDlg.h CurveCreator_Widget.h ) ENDIF(SALOME_BUILD_GUI) @@ -68,13 +67,15 @@ ENDIF(SALOME_BUILD_GUI) SET(_other_HEADERS CurveCreator.hxx CurveCreator_Curve.hxx - CurveCreator_CurveEditor.hxx CurveCreator_Diff.hxx + CurveCreator_Displayer.hxx CurveCreator_ICurve.hxx - CurveCreator_Listener.hxx CurveCreator_Macro.hxx CurveCreator_Operation.hxx + CurveCreator_PosPoint.hxx CurveCreator_Section.hxx + CurveCreator_UtilsICurve.hxx + CurveCreator_Utils.hxx ) # header files / to install @@ -90,17 +91,17 @@ ENDIF(SALOME_BUILD_GUI) # sources / static SET(_other_SOURCES CurveCreator_Curve.cxx - CurveCreator_CurveEditor.cxx CurveCreator_Diff.cxx - CurveCreator_ICurve.cxx + CurveCreator_Displayer.cxx CurveCreator_Operation.cxx + CurveCreator_Utils.cxx + CurveCreator_UtilsICurve.cxx ) IF(SALOME_BUILD_GUI) LIST(APPEND _other_SOURCES - CurveCreator_NewPointDlg.cxx CurveCreator_NewSectionDlg.cxx + CurveCreator_TableView.cxx CurveCreator_TreeView.cxx -# CurveCreator_UndoOptsDlg.cxx CurveCreator_Widget.cxx ) ENDIF(SALOME_BUILD_GUI) diff --git a/src/CurveCreator/CurveCreator.hxx b/src/CurveCreator/CurveCreator.hxx index 74a3faec4..9cd7ec720 100644 --- a/src/CurveCreator/CurveCreator.hxx +++ b/src/CurveCreator/CurveCreator.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,29 +24,30 @@ #define _CurveCreator_HeaderFile #include +#include +#include + +struct CurveCreator_Section; +struct CurveCreator_PosPoint; namespace CurveCreator { - - //! Dimension of the curve - enum Dimension - { - Dim2d = 2, - Dim3d = 3 - }; - - //! Type of the section - enum Type - { - Polyline, - BSpline - }; - //! Points coordinates typedef float TypeCoord; + /** List of coordinates in format depends on section dimension: + * 2D: [x1, y1, x2, y2, x3, y3, ..] + * 3D: [x1, y1, z1, x2, y2, z2, x3, y3, z3, ..] + */ typedef std::deque Coordinates; + //! List of sections + typedef std::deque Sections; + + // List of positioned points (points with coordinates) + typedef std::list PosPointsList; + //! Map of sections with positioned points + typedef std::map SectionsMap; }; #endif diff --git a/src/CurveCreator/CurveCreator_Curve.cxx b/src/CurveCreator/CurveCreator_Curve.cxx index b4fa90ffc..e20705c46 100644 --- a/src/CurveCreator/CurveCreator_Curve.cxx +++ b/src/CurveCreator/CurveCreator_Curve.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,8 +21,21 @@ // Author: Sergey KHROMOV #include "CurveCreator_Curve.hxx" + +#include "CurveCreator.hxx" +#include "CurveCreator_PosPoint.hxx" #include "CurveCreator_Section.hxx" -#include "CurveCreator_Listener.hxx" +#include "CurveCreator_Displayer.hxx" +#include "CurveCreator_Utils.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -30,24 +43,995 @@ // function: Constructor // purpose: //======================================================================= -CurveCreator_Curve::CurveCreator_Curve - (const CurveCreator::Dimension theDimension) -: CurveCreator_ICurve(theDimension) +CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimension ) +: myIsLocked (false), + myDimension (theDimension), + myDisplayer (NULL), + myAISShape (NULL), + myNbUndos (0), + myNbRedos (0), + myUndoDepth (-1), + myOpLevel(0), + mySkipSorting(false) { } //======================================================================= -// function: addPoints +// function: Destructor // purpose: //======================================================================= -void CurveCreator_Curve::addPoints - (const CurveCreator::Coordinates &thePoints, const int theISection) +CurveCreator_Curve::~CurveCreator_Curve() { - CurveCreator_Section *aSection = - (theISection == -1 ? mySections.back() : mySections.at(theISection)); - - aSection->myPoints.insert(aSection->myPoints.end(), - thePoints.begin(), thePoints.end()); - if( myListener ) - myListener->pointInserted( theISection, -1 ); + // Delete all allocated data. + clear(); +} + +//======================================================================= +// function: getDimension +// purpose: +//======================================================================= +CurveCreator::Dimension CurveCreator_Curve::getDimension() const +{ + return myDimension; +} + +//======================================================================= +// function: getUniqSectionName +// purpose: return unique section name +//======================================================================= +std::string CurveCreator_Curve::getUniqSectionName() const +{ + CurveCreator_Section* aSection; + for( int i = 0 ; i < 1000000 ; i++ ){ + char aBuffer[255]; + sprintf( aBuffer, "Section_%d", i+1 ); + std::string aName(aBuffer); + int j; + for( j = 0 ; j < mySections.size() ; j++ ){ + aSection = getSection( j ); + if ( aSection && aSection->myName == aName ) + break; + } + if( j == mySections.size() ) + return aName; + } + return ""; +} + +//======================================================================= +// function: setDisplayer +// purpose: set curve changes Displayer +//======================================================================= +void CurveCreator_Curve::setDisplayer( CurveCreator_Displayer* theDisplayer ) +{ + myDisplayer = theDisplayer; +} + +//======================================================================= +// function: getDisplayer +// purpose: get curve changes Displayer +//======================================================================= +CurveCreator_Displayer* CurveCreator_Curve::getDisplayer() +{ + return myDisplayer; +} + +//======================================================================= +// function: removeDisplayer +// purpose: remove the attached Displayer +//======================================================================= +void CurveCreator_Curve::removeDisplayer() +{ + myDisplayer = NULL; +} + +//======================================================================= +// function: addDiff +// purpose: +//======================================================================= +bool CurveCreator_Curve::addEmptyDiff() +{ + bool isEnabled = false; + + if (myUndoDepth != 0) { + // Forget all Redos after the current one. + if (myNbRedos > 0) { + myNbRedos = 0; + myListDiffs.erase(myCurrenPos, myListDiffs.end()); + } + + if (myUndoDepth == -1 || myNbUndos < myUndoDepth) { + // Increase the number of undos. + myNbUndos++; + } else { + // If there are too many differences, remove the first one. + myListDiffs.pop_front(); + } + + // Add new difference. + myListDiffs.push_back(CurveCreator_Diff()); + myCurrenPos = myListDiffs.end(); + isEnabled = true; + } + + return isEnabled; +} + +void CurveCreator_Curve::startOperation() +{ + myOpLevel++; +} + +void CurveCreator_Curve::finishOperation() +{ + myOpLevel--; +} + +//======================================================================= +// function: toICoord +// purpose: +//======================================================================= +int CurveCreator_Curve::toICoord(const int theIPnt) const +{ + return theIPnt * myDimension; +} + +//======================================================================= +// function: setUndoDepth +// purpose: +//======================================================================= +void CurveCreator_Curve::setUndoDepth(const int theDepth) +{ + if (theDepth == 0) { + // Reset all undo/redo data. + myNbUndos = 0; + myNbRedos = 0; + myListDiffs.clear(); + myCurrenPos = myListDiffs.end(); + myUndoDepth = 0; + } else if (theDepth == -1) { + // There is nothing to do as the depth become unlimited. + myUndoDepth = -1; + } else if (theDepth > 0) { + // The new "real" depth is set. + if (theDepth < myNbRedos) { + // The new depth is less then number of redos. Remove the latest redos. + int aShift = (myNbRedos - theDepth); + ListDiff::iterator aFromPos = myListDiffs.end(); + + while (aShift--) { + aFromPos--; + } + + myListDiffs.erase(aFromPos, myListDiffs.end()); + myNbRedos = theDepth; + } + + if (theDepth < myNbUndos + myNbRedos) { + // The new depth is less then the total number of differences. + // Remove the first undos. + int aShift = (myNbUndos + myNbRedos - theDepth); + ListDiff::iterator aToPos = myListDiffs.begin(); + + while (aShift--) { + aToPos++; + } + + myListDiffs.erase(myListDiffs.begin(), aToPos); + myNbUndos = theDepth - myNbRedos; + } + + myUndoDepth = theDepth; + } +} + +//======================================================================= +// function: getUndoDepth +// purpose: +//======================================================================= +int CurveCreator_Curve::getUndoDepth() const +{ + return myUndoDepth; +} + +void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const +{ + CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint ); + theX = aCoords[0]; + theY = aCoords[1]; + theZ = 0.; + if( getDimension() == CurveCreator::Dim3d ){ + theZ = aCoords[2]; + } +} + +void CurveCreator_Curve::redisplayCurve() +{ + if( myDisplayer ) { + myDisplayer->eraseAll( false ); + myAISShape = NULL; + + myDisplayer->display( getAISObject( true ), true ); + } +} + +//! For internal use only! Undo/Redo are not used here. +bool CurveCreator_Curve::moveSectionInternal(const int theISection, + const int theNewIndex) +{ + bool res = false; + int aMovedSectionId = theISection >= 0 ? theISection : mySections.size()-1; + + if (aMovedSectionId != theNewIndex) { + CurveCreator_Section* aSection = getSection( aMovedSectionId ); + + // Remove section + CurveCreator::Sections::iterator anIter = mySections.begin() + aMovedSectionId; + + mySections.erase(anIter); + + // Insert section. + anIter = mySections.begin() + theNewIndex; + mySections.insert(anIter, aSection); + res = true; + } + return res; +} + +//======================================================================= +// function: moveSection +// purpose: +//======================================================================= +bool CurveCreator_Curve::moveSection(const int theISection, + const int theNewIndex) +{ + bool res = false; + // Set the difference. + startOperation(); + if (addEmptyDiff()) { + myListDiffs.back().init(this, CurveCreator_Operation::MoveSection, + theISection, theNewIndex); + } + + // Update the curve. + res = moveSectionInternal(theISection, theNewIndex); + finishOperation(); + return res; +} + +/************ Implementation of INTERFACE methods ************/ + +/***********************************************/ +/*** Undo/Redo methods ***/ +/***********************************************/ + +//! Get number of available undo operations +int CurveCreator_Curve::getNbUndo() const +{ + return myNbUndos; +} + +//! Undo previous operation +bool CurveCreator_Curve::undo() +{ + bool res = false; + if (myNbUndos > 0) { + myNbUndos--; + myNbRedos++; + myCurrenPos--; + myCurrenPos->applyUndo(this); + res = true; + } + return res; +} + +//! Get number of available redo operations +int CurveCreator_Curve::getNbRedo() const +{ + return myNbRedos; +} + +//! Redo last previously "undone" operation +bool CurveCreator_Curve::redo() +{ + bool res = false; + if (myNbRedos > 0) { + myCurrenPos->applyRedo(this); + myCurrenPos++; + myNbRedos--; + myNbUndos++; + res = true; + } + return res; +} + +/***********************************************/ +/*** Section methods ***/ +/***********************************************/ +//! For internal use only! Undo/Redo are not used here. +bool CurveCreator_Curve::clearInternal() +{ + // erase curve from the viewer + if( myDisplayer ) { + myDisplayer->eraseAll( true ); + myAISShape = NULL; + } + // Delete all allocated data. + int i = 0; + const int aNbSections = getNbSections(); + + CurveCreator_Section* aSection; + for (; i < aNbSections; i++) { + aSection = getSection( i ); + if ( aSection ) + delete aSection; + } + + mySections.clear(); + + return true; +} + +//======================================================================= +// function: clear +// purpose: +//======================================================================= +bool CurveCreator_Curve::clear() +{ + bool res = false; + startOperation(); + // Set the difference. + if (addEmptyDiff()) { + myListDiffs.back().init(this); + } + res = clearInternal(); + finishOperation(); + return res; +} + +//! For internal use only! Undo/Redo are not used here. +bool CurveCreator_Curve::joinInternal( const std::list& theSections ) +{ + bool res = false; + if ( theSections.empty() ) + return res; + + int anISectionMain = theSections.front(); + CurveCreator_Section* aSectionMain = getSection( anISectionMain ); + + std::list aSectionsToJoin = theSections; + aSectionsToJoin.erase( aSectionsToJoin.begin() ); // skip the main section + // it is important to sort and reverse the section ids in order to correctly remove them + aSectionsToJoin.sort(); + aSectionsToJoin.reverse(); + + std::list::const_iterator anIt = aSectionsToJoin.begin(), aLast = aSectionsToJoin.end(); + CurveCreator_Section* aSection; + for (; anIt != aLast; anIt++) { + aSection = getSection( *anIt ); + aSectionMain->myPoints.insert(aSectionMain->myPoints.end(), aSection->myPoints.begin(), + aSection->myPoints.end()); + res = removeSectionInternal(*anIt); + if ( !res ) + break; + } + + redisplayCurve(); + return res; +} + +bool CurveCreator_Curve::join( const std::list& theSections ) +{ + bool res = false; + + if ( !theSections.empty() ) + { + startOperation(); + if (addEmptyDiff()) + myListDiffs.back().init(this, CurveCreator_Operation::Join, theSections); + + res = joinInternal( theSections ); + + finishOperation(); + } + return res; +} + +//! Get number of sections +int CurveCreator_Curve::getNbSections() const +{ + return mySections.size(); +} + +//! For internal use only! Undo/Redo are not used here. +int CurveCreator_Curve::addSectionInternal + (const std::string& theName, const CurveCreator::SectionType theType, + const bool theIsClosed, const CurveCreator::Coordinates &thePoints) +{ + CurveCreator_Section *aSection = new CurveCreator_Section; + + std::string aName = theName; + if( aName.empty() ){ + aName = getUniqSectionName(); + } + aSection->myName = aName; + aSection->myType = theType; + aSection->myIsClosed = theIsClosed; + aSection->myPoints = thePoints; + mySections.push_back(aSection); + redisplayCurve(); + return mySections.size()-1; +} + +//======================================================================= +// function: addSection +// purpose: adds an empty section +//======================================================================= +int CurveCreator_Curve::addSection + (const std::string& theName, const CurveCreator::SectionType theType, + const bool theIsClosed) +{ + int resISection = -1; + // Set the difference. + startOperation(); + CurveCreator::Coordinates aCoords; //empty list + if (addEmptyDiff()) { + myListDiffs.back().init(this, CurveCreator_Operation::AddSection, + theName, aCoords, theType, theIsClosed); + } + + resISection = addSectionInternal(theName, theType, theIsClosed, aCoords); + + finishOperation(); + return resISection; +} +//======================================================================= +// function: addSection +// purpose: adds a section with the given points +//======================================================================= +int CurveCreator_Curve::addSection + (const std::string& theName, const CurveCreator::SectionType theType, + const bool theIsClosed, const CurveCreator::Coordinates &thePoints) +{ + int resISection = -1; + // Set the difference. + startOperation(); + if (addEmptyDiff()) { + myListDiffs.back().init(this, CurveCreator_Operation::AddSection, + theName, thePoints, theType, theIsClosed); + } + + resISection = addSectionInternal(theName, theType, theIsClosed, thePoints); + + finishOperation(); + return resISection; +} + +//! For internal use only! Undo/Redo are not used here. +bool CurveCreator_Curve::removeSectionInternal( const int theISection ) +{ + if (theISection == -1) { + delete mySections.back(); + mySections.pop_back(); + } else { + CurveCreator::Sections::iterator anIterRm = mySections.begin() + theISection; + + delete *anIterRm; + mySections.erase(anIterRm); + } + redisplayCurve(); + return true; +} + +//! Removes the given sections. +bool CurveCreator_Curve::removeSection( const int theISection ) +{ + bool res = false; + // Set the difference. + startOperation(); + if (addEmptyDiff()) + myListDiffs.back().init(this, CurveCreator_Operation::RemoveSection, theISection); + + res = removeSectionInternal( theISection ); + + finishOperation(); + return res; +} + +/** + * Get number of points in specified section or (the total number of points + * in Curve if theISection is equal to -1). + */ +int CurveCreator_Curve::getNbPoints( const int theISection ) const +{ + int aNbCoords = 0; + + CurveCreator_Section* aSection; + if (theISection == -1) { + int i = 0; + const int aNbSections = getNbSections(); + + for (; i < aNbSections; i++) { + aSection = getSection( i ); + if ( aSection ) + aNbCoords += aSection->myPoints.size(); + } + } else { + aSection = getSection( theISection ); + if ( aSection ) + aNbCoords = aSection->myPoints.size(); + } + + return aNbCoords/myDimension; +} + +void CurveCreator_Curve::setSkipSorting( const bool theIsToSkip ) +{ + mySkipSorting = theIsToSkip; +} + +bool CurveCreator_Curve::canPointsBeSorted() +{ + return false; +} + +/** + * Saves points coordinates difference. + * \param theOldCoords the old points coordinates + */ +void CurveCreator_Curve::saveCoordDiff( const SectionToPointCoordsList &theOldCoords ) +{ + // Set the difference. + startOperation(); + if (addEmptyDiff()) { + myListDiffs.back().init(this, theOldCoords); + } + finishOperation(); +} + +//! Get "closed" flag of the specified section +bool CurveCreator_Curve::isClosed( const int theISection ) const +{ + CurveCreator_Section* aSection = getSection( theISection ); + return aSection ? aSection->myIsClosed : false; +} + +//! For internal use only! Undo/Redo are not used here. +bool CurveCreator_Curve::setClosedInternal( const int theISection, + const bool theIsClosed ) +{ + CurveCreator_Section* aSection = 0; + if (theISection == -1) { + int aSize = mySections.size(); + int i; + + for (i = 0; i < aSize; i++) { + aSection = getSection( i ); + if( aSection ) { + aSection->myIsClosed = theIsClosed; + redisplayCurve(); + } + } + } else { + aSection = getSection( theISection ); + if ( aSection ) { + aSection->myIsClosed = theIsClosed; + redisplayCurve(); + } + } + return true; +} + +/** + * Set "closed" flag of the specified section (all sections if + * \a theISection is -1). + */ +bool CurveCreator_Curve::setClosed( const int theISection, + const bool theIsClosed ) +{ + bool res = false; + // Set the difference. + startOperation(); + if (addEmptyDiff()) { + myListDiffs.back().init(this, CurveCreator_Operation::SetClosed, + theIsClosed, theISection); + } + res = setClosedInternal( theISection, theIsClosed ); + finishOperation(); + return res; +} + +//! Returns specified section name +std::string CurveCreator_Curve::getSectionName( const int theISection ) const +{ + CurveCreator_Section* aSection = getSection( theISection ); + return aSection ? aSection->myName : ""; +} + +//! For internal use only! Undo/Redo are not used here. +bool CurveCreator_Curve::setSectionNameInternal( const int theISection, + const std::string& theName ) +{ + bool res = false; + CurveCreator_Section* aSection = getSection( theISection ); + if( aSection ) { + aSection->myName = theName; + res = true; + } + return res; +} + +/** Set name of the specified section */ +bool CurveCreator_Curve::setSectionName( const int theISection, + const std::string& theName ) +{ + bool res = false; + // Set the difference. + startOperation(); + if (addEmptyDiff()) { + myListDiffs.back().init(this, CurveCreator_Operation::RenameSection, + theName, theISection); + } + res = setSectionNameInternal( theISection, theName ); + finishOperation(); + return res; +} + +//! Get type of the specified section +CurveCreator::SectionType CurveCreator_Curve::getSectionType + ( const int theISection ) const +{ + CurveCreator_Section* aSection = getSection( theISection ); + return aSection ? aSection->myType : CurveCreator::Polyline; +} + +//! For internal use only! Undo/Redo are not used here. +bool CurveCreator_Curve::setSectionTypeInternal( const int theISection, + const CurveCreator::SectionType theType ) +{ + CurveCreator_Section* aSection; + if (theISection == -1) { + int i = 0; + const int aNbSections = getNbSections(); + + for (; i < aNbSections; i++) { + aSection = getSection( i ); + if ( aSection ) + aSection->myType = theType; + } + redisplayCurve(); + } else { + aSection = getSection( theISection ); + if ( aSection && aSection->myType != theType ){ + aSection->myType = theType; + redisplayCurve(); + } + } + return true; +} + +/** + * Set type of the specified section (or all sections + * if \a theISection is -1). + */ +bool CurveCreator_Curve::setSectionType( const int theISection, + const CurveCreator::SectionType theType ) +{ + bool res = false; + startOperation(); + // Set the difference. + if (addEmptyDiff()) { + myListDiffs.back().init(this, CurveCreator_Operation::SetType, + theType, theISection); + } + + res = setSectionTypeInternal( theISection, theType ); + + finishOperation(); + return res; +} + + +/***********************************************/ +/*** Point methods ***/ +/***********************************************/ + +//! For internal use only! Undo/Redo are not used here. +bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap ) +{ + bool res = false; + CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin(); + CurveCreator_Section *aSection = 0; + for ( ; anIt != theSectionsMap.end(); anIt++ ) { + int anISection = anIt->first; + aSection = getSection( anISection ); + if( aSection ) { + CurveCreator::PosPointsList aSectionPoints = anIt->second; + CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin(); + for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){ + int anIPnt = (*aPntIt)->myID; + CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords; + CurveCreator::Coordinates::iterator anIterPosition; + if(anIPnt == -1) + anIterPosition = aSection->myPoints.end(); + else + anIterPosition = aSection->myPoints.begin() + toICoord(anIPnt); + CurveCreator::Coordinates::const_iterator aFirstPosition = + aCoords.begin(); + aSection->myPoints.insert(anIterPosition, + aCoords.begin(), aCoords.end()); + } + res = true; + } + } + if(res) + redisplayCurve(); + return res; +} + +/** + * Add one point to the specified section starting from the given theIPnt index + * (or at the end of points if \a theIPnt is -1). + */ +bool CurveCreator_Curve::addPoints( const CurveCreator::Coordinates& theCoords, + const int theISection, + const int theIPnt ) +{ + bool res = false; + CurveCreator::Coordinates aCoords = theCoords; + // Set the difference. + startOperation(); + if (addEmptyDiff()) { + CurveCreator_ICurve::SectionToPointCoordsList aList; + aList.push_back(std::make_pair(std::make_pair(theISection, theIPnt), theCoords)); + myListDiffs.back().init(this, CurveCreator_Operation::InsertPoints, + aList); + } + CurveCreator::SectionsMap aSectionsMap; + CurveCreator::PosPointsList aPoints; + CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( theIPnt, theCoords ); + aPoints.push_back( aPosPoint ); + aSectionsMap[theISection] = aPoints; + + res = addPointsInternal( aSectionsMap ); + + finishOperation(); + return res; +} + +//! For internal use only! Undo/Redo are not used here. +bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theSectionsMap ) +{ + bool res = false; + // Update the curve. + CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin(); + CurveCreator_Section *aSection = 0; + for ( ; anIt != theSectionsMap.end(); anIt++ ) { + int anISection = anIt->first; + aSection = getSection( anISection ); + if( aSection ) { + CurveCreator::PosPointsList aSectionPoints = anIt->second; + CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin(); + for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){ + int anIPnt = (*aPntIt)->myID; + CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords; + for ( int i = 0; i < myDimension; i++) + aSection->myPoints.at(toICoord(anIPnt) + i) = aCoords[i]; + } + res = true; + } + } + if(res) + redisplayCurve(); + + return res; +} + +//! Set coordinates of specified point +bool CurveCreator_Curve::setPoint( const int theISection, + const int theIPnt, + const CurveCreator::Coordinates& theNewCoords ) +{ + bool res = false; + // Set the difference. + startOperation(); + if (addEmptyDiff()) { + CurveCreator_ICurve::SectionToPointCoordsList aList; + aList.push_back(std::make_pair(std::make_pair(theISection, theIPnt), theNewCoords)); + myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates, + aList); + } + CurveCreator::SectionsMap aSectionsMap; + CurveCreator::PosPointsList aPoints; + CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( theIPnt, theNewCoords ); + aPoints.push_back( aPosPoint ); + aSectionsMap[theISection] = aPoints; + + int aSize1 = getNbPoints( theISection ); + res = setPointInternal( aSectionsMap ); + int aSize2 = getNbPoints( theISection ); + + finishOperation(); + + return res; +} + +//! Set coordinates of specified points from different sections +bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords, + const bool theIsToSaveDiff ) +{ + bool res = false; + // Set the difference. + startOperation(); + if (theIsToSaveDiff && addEmptyDiff()) { + myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates, + theSectionToPntCoords); + } + CurveCreator::SectionsMap aSectionsMap; + CurveCreator::PosPointsList aPosPoints; + CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = + theSectionToPntCoords.begin(), aLast = theSectionToPntCoords.end(); + int aSectionId, aPointId; + for ( ; anIt != aLast; anIt++ ) { + aPosPoints.clear(); + aSectionId = anIt->first.first; + aPointId = anIt->first.second; + CurveCreator::Coordinates aNewCoords = anIt->second; + CurveCreator_PosPoint* aPosPoint = + new CurveCreator_PosPoint( aPointId, aNewCoords ); + if( aSectionsMap.find(aSectionId) != aSectionsMap.end() ) + aPosPoints = aSectionsMap[aSectionId]; + aPosPoints.push_back( aPosPoint ); + aSectionsMap[aSectionId] = aPosPoints; + + } + res = setPointInternal( aSectionsMap ); + finishOperation(); + + return res; +} + +//! For internal use only! Undo/Redo are not used here. +bool CurveCreator_Curve::removePointsInternal( const SectionToPointList &thePoints ) +{ + bool aRes = false; + std::map > aConvPoints; + convert( thePoints, aConvPoints ); + std::map >::const_iterator anIt = aConvPoints.begin(), + aLast = aConvPoints.end(); + for ( ; anIt != aLast; anIt++ ) { + int aSectionId = anIt->first; + aRes = removeSectionPoints(aSectionId, anIt->second); + } + if( aRes) + redisplayCurve(); + + return aRes; +} + +//! Remove point with given id +bool CurveCreator_Curve::removePoint( const int theISection, const int theIPnt ) +{ + bool res = false; + // Set the difference. + startOperation(); + SectionToPointList aListOfSectionsToPoints; + aListOfSectionsToPoints.push_back(std::make_pair(theISection, theIPnt)); + if (addEmptyDiff()) { + myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints, + aListOfSectionsToPoints); + } + res = removePointsInternal( aListOfSectionsToPoints ); + finishOperation(); + return res; +} + +//! Remove several points from different sections with given ids +bool CurveCreator_Curve::removeSeveralPoints( const SectionToPointList &theSectionToPntIDs) +{ + bool res = false; + // Set the difference. + startOperation(); + if (addEmptyDiff()) { + myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints, + theSectionToPntIDs); + } + res = removePointsInternal( theSectionToPntIDs ); + finishOperation(); + return res; +} + + //======================================================================= +// function: getCoordinates +// purpose: +//======================================================================= +CurveCreator::Coordinates CurveCreator_Curve::getPoint( const int theISection, + const int theIPnt) const +{ + CurveCreator_Section* aSection = getSection( theISection ); + CurveCreator::Coordinates::const_iterator + anIter = aSection->myPoints.begin() + toICoord(theIPnt); + CurveCreator::Coordinates aResult(anIter, anIter + myDimension); + + return aResult; +} + +//======================================================================= +// function: getPoints +// purpose: +//======================================================================= +CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const +{ + CurveCreator_Section* aSection = getSection( theISection ); + return aSection ? aSection->myPoints : CurveCreator::Coordinates(); +} + +void CurveCreator_Curve::constructAISObject() +{ + TopoDS_Shape aShape; + CurveCreator_Utils::constructShape( this, aShape ); + + myAISShape = new AIS_Shape( aShape ); +} + +CurveCreator_Section* CurveCreator_Curve::getSection( const int theSectionId ) const +{ + CurveCreator_Section *aSection = 0; + if ( theSectionId >= 0 && theSectionId < mySections.size() ) + aSection = mySections.at( theSectionId ); + + return aSection; +} + +Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const +{ + if ( !myAISShape && theNeedToBuild ) { + CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this; + aCurve->constructAISObject(); + } + return myAISShape; +} + +bool CurveCreator_Curve::removeSectionPoints( const int theSectionId, + const std::list& thePointIds ) +{ + bool aRes = false; + + CurveCreator_Section* aSection = getSection( theSectionId ); + if ( !aSection ) + return aRes; + + std::list aSectionPoints = thePointIds; + aSectionPoints.sort(); + std::list::const_reverse_iterator aPntIt = aSectionPoints.rbegin(); + for ( ; aPntIt != aSectionPoints.rend(); aPntIt++ ) { + int aPntIndx = *aPntIt; + CurveCreator::Coordinates::iterator aFirstPosition; + if ( aPntIndx == -1 ) + aFirstPosition = aSection->myPoints.end() - getDimension(); + else + aFirstPosition = aSection->myPoints.begin() + toICoord( aPntIndx ); + aSection->myPoints.erase( aFirstPosition, aFirstPosition + getDimension() ); + aRes = true; + } + return aRes; +} + +void CurveCreator_Curve::convert( const SectionToPointList& thePoints, + std::map< int, std::list >& theConvPoints ) +{ + theConvPoints.clear(); + + SectionToPointList::const_iterator anIt = thePoints.begin(), aLast = thePoints.end(); + std::list aPoints; + int aSectionId, aPointId; + for ( ; anIt != aLast; anIt++ ) { + aSectionId = anIt->first; + aPointId = anIt->second; + aPoints.clear(); + if ( theConvPoints.find( aSectionId ) != theConvPoints.end() ) + aPoints = theConvPoints[aSectionId]; + aPoints.push_back( aPointId ); + theConvPoints[aSectionId] = aPoints; + } } diff --git a/src/CurveCreator/CurveCreator_Curve.hxx b/src/CurveCreator/CurveCreator_Curve.hxx index 309d06a84..adcfc87a8 100644 --- a/src/CurveCreator/CurveCreator_Curve.hxx +++ b/src/CurveCreator/CurveCreator_Curve.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -23,23 +23,32 @@ #ifndef _CurveCreator_Curve_HeaderFile #define _CurveCreator_Curve_HeaderFile -#include "CurveCreator.hxx" #include "CurveCreator_ICurve.hxx" -#include "CurveCreator_Macro.hxx" -#include "CurveCreator_Operation.hxx" -class CurveCreator_Section; -class CurveCreator_Listener; +#include "CurveCreator_Macro.hxx" +#include "CurveCreator.hxx" +#include "CurveCreator_Diff.hxx" + +#include +#include + +struct CurveCreator_Section; +class CurveCreator_Displayer; +class AIS_Shape; +class Handle_AIS_InteractiveObject; /** * The CurveCreator_Curve object is represented as one or more sets of * connected points; thus CurveCreator_Curve object can contain several * not connected curves (polylines or b-splines), each such curve has two - * only ends � start and end points � in other words non-manifold curves + * only ends "start and end points" in other words non-manifold curves * are not supported. */ class CURVECREATOR_EXPORT CurveCreator_Curve : public CurveCreator_ICurve { +protected: + typedef std::list ListDiff; + public: //! Constructor of the curve. /** The dimension is explicitly specified in the constructor @@ -47,15 +56,273 @@ public: */ CurveCreator_Curve(const CurveCreator::Dimension theDimension); - /** Add points to the specified section (or last section + //! Destructor. + virtual ~CurveCreator_Curve(); + + //! Get the dimension. + virtual CurveCreator::Dimension getDimension() const; + + //! Return unique section name + virtual std::string getUniqSectionName() const; + + //! Set curve creator Displayer object + virtual void setDisplayer( CurveCreator_Displayer* theDisplayer ); + + //! Return curve creator Displayer object + CurveCreator_Displayer* getDisplayer(); + + //! Remove curve creator Displayer object + virtual void removeDisplayer(); + + /** Set depth of undo operations (unlimited if \a theDepth is -1 + * or disabled if \a theDepth is 0) + */ + virtual void setUndoDepth(const int theDepth = -1); + + //! Get depth of undo operations. + virtual int getUndoDepth() const; + + virtual void startOperation(); + virtual void finishOperation(); + + /** + * This method converts the point index to the index in + * an array of coordinates. + */ + virtual int toICoord(const int theIPnt) const; + + //! For internal use only! Undo/Redo are not used here. + virtual bool moveSectionInternal(const int theISection, + const int theNewIndex); + //! Move section to new position in list + virtual bool moveSection(const int theISection, + const int theNewIndex); + +protected: + /** This method updates all undo/redo information required to be updated + * after curve modification operation. It returns false if undo/redo + * is disabled and true otherwise. + */ + virtual bool addEmptyDiff(); + +public: // TODO: remove public + void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const; +protected: // TODO: remove public + void redisplayCurve(); + +public: + /************ Implementation of INTERFACE methods ************/ + + /***********************************************/ + /*** Undo/Redo methods ***/ + /***********************************************/ + + //! Get number of available undo operations + virtual int getNbUndo() const; + + //! Undo previous operation + virtual bool undo(); + + //! Get number of available redo operations + virtual int getNbRedo() const; + + //! Redo last previously "undone" operation + virtual bool redo(); + + + /***********************************************/ + /*** Section methods ***/ + /***********************************************/ + + //! For internal use only! Undo/Redo are not used here. + virtual bool clearInternal(); + //! Clear the polyline (remove all sections) + virtual bool clear(); + + //! For internal use only! Undo/Redo are not used here. + virtual bool joinInternal( const std::list& theSections ); + + //! Join list of sections to one section (join all if the list is empty) + // The first section in the list is a leader, another sections are joined to it + virtual bool join( const std::list& theSections ); + + //! Get number of sections + virtual int getNbSections() const; + + //! For internal use only! Undo/Redo are not used here. + virtual int addSectionInternal( const std::string &theName, + const CurveCreator::SectionType theType, + const bool theIsClosed, + const CurveCreator::Coordinates &thePoints); + //! Add a new section. + virtual int addSection( const std::string &theName, + const CurveCreator::SectionType theType, + const bool theIsClosed ); + //! Add a new section. + virtual int addSection( const std::string &theName, + const CurveCreator::SectionType theType, + const bool theIsClosed, + const CurveCreator::Coordinates &thePoints); + + //! For internal use only! Undo/Redo are not used here. + virtual bool removeSectionInternal( const int theISection ); + //! Removes the given sections. + virtual bool removeSection( const int theISection ); + + //! Get "closed" flag of the specified section + virtual bool isClosed( const int theISection ) const; + + //! For internal use only! Undo/Redo are not used here. + virtual bool setClosedInternal( const int theISection, + const bool theIsClosed ); + /** + * Set "closed" flag of the specified section (all sections if + * \a theISection is -1). + */ + virtual bool setClosed( const int theISection, + const bool theIsClosed ); + + //! Returns specifyed section name + virtual std::string getSectionName( const int theISection ) const; + + //! For internal use only! Undo/Redo are not used here. + virtual bool setSectionNameInternal( const int theISection, + const std::string& theName ); + /** Set name of the specified section */ + virtual bool setSectionName( const int theISection, + const std::string& theName ); + + //! Get type of the specified section + virtual CurveCreator::SectionType getSectionType( const int theISection ) const; + + //! For internal use only! Undo/Redo are not used here. + virtual bool setSectionTypeInternal( const int theISection, + const CurveCreator::SectionType theType ); + /** + * Set type of the specified section (or all sections * if \a theISection is -1). */ - virtual void addPoints - (const CurveCreator::Coordinates &thePoints, const int theISection = -1); + virtual bool setSectionType( const int theISection, + const CurveCreator::SectionType theType ); - friend class CurveCreator_CurveEditor; - friend class CurveCreator_Operation; + /***********************************************/ + /*** Point methods ***/ + /***********************************************/ + + //! For internal use only! Undo/Redo are not used here. + virtual bool addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap ); + /** + * Add one point to the specified section starting from the given theIPnt index + * (or at the end of points if \a theIPnt is -1). + */ + virtual bool addPoints( const CurveCreator::Coordinates &theCoords, + const int theISection, + const int theIPnt = -1 ); + + //! For internal use only! Undo/Redo are not used here. + virtual bool setPointInternal( const CurveCreator::SectionsMap &theSectionsMap ); + //! Set coordinates of specified point + virtual bool setPoint( const int theISection, + const int theIPnt, + const CurveCreator::Coordinates& theNewCoords ); + + //! Set coordinates of specified points from different sections + virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords, + const bool theIsToSaveDiff = true ); + + //! For internal use only! Undo/Redo are not used here. + virtual bool removePointsInternal( const SectionToPointList &thePoints ); + /** Remove point with given id */ + virtual bool removePoint( const int theISection, const int theIPnt = -1 ); + + //! Remove several points from different sections with given ids + virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs); + + //! Get coordinates of specified point + virtual CurveCreator::Coordinates getPoint( const int theISection, + const int theIPnt ) const; + + /** + * Get points of a section (the total points in Curve if theISection is equal to -1).. + */ + virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const; + + + /** + * Get number of points in specified section or (the total number of points + * in Curve if theISection is equal to -1). + */ + virtual int getNbPoints( const int theISection ) const; + + /** + * Set skip sorting flag. If the flag is true - points sorting will be skipped. + */ + virtual void setSkipSorting( const bool theIsToSkip ); + + /** + * Indicates whether the points can be sorted. + */ + virtual bool canPointsBeSorted(); + + /** + * Saves points coordinates difference. + * \param theOldCoords the old points coordinates + */ + virtual void saveCoordDiff( const SectionToPointCoordsList &theOldCoords ); + + /***********************************************/ + /*** Presentation methods ***/ + /***********************************************/ + /** + * Get the curve AIS object + */ + virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const; + +protected: + /** + * Removes the points from the section. It sortes the points and remove them + * in the decreasing order + * \param theSectionId a section index + * \param thePointIds a list of section points + */ + bool removeSectionPoints( const int theSectionId, + const std::list& thePointIds ); + /** + * Converts the list of pairs of section to point into map of a section to list of points + * \param thePoints an source list + * \param theConvPoints a converted map + */ + void convert( const SectionToPointList &thePoints, + std::map > &theConvPoints ); + +protected: + virtual void constructAISObject(); + /** + * Returns the section by the section index or NULL if the index is out of the section + * list range + * \param theSectionId the section index + */ + CurveCreator_Section* getSection( const int theSectionId ) const; + +protected: + bool mySkipSorting; + +public: + bool myIsLocked; + CurveCreator::Sections mySections; //!< curve data + CurveCreator::Dimension myDimension; //!< curve dimension + CurveCreator_Displayer* myDisplayer; //!< curve displayer + +private: + + int myNbUndos; + int myNbRedos; + ListDiff::iterator myCurrenPos; + ListDiff myListDiffs; + int myUndoDepth; + int myOpLevel; + AIS_Shape* myAISShape; //!< AIS shape }; #endif diff --git a/src/CurveCreator/CurveCreator_CurveEditor.cxx b/src/CurveCreator/CurveCreator_CurveEditor.cxx deleted file mode 100644 index 559eabd5a..000000000 --- a/src/CurveCreator/CurveCreator_CurveEditor.cxx +++ /dev/null @@ -1,511 +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: CurveCreator_CurveEditor.cxx -// Author: Sergey KHROMOV - -#include "CurveCreator_CurveEditor.hxx" - -//======================================================================= -// function: Constructor -// purpose: -//======================================================================= -CurveCreator_CurveEditor::CurveCreator_CurveEditor - (CurveCreator_Curve* thePCurve) - : myNbUndos (0), - myNbRedos (0), - myPCurve (thePCurve), - myUndoDepth (-1), - myOpLevel(0) -{ - if (myPCurve != NULL) { - if (myPCurve->isLocked()) { - // This curve is locked by another editor. Invalid case. - myPCurve = NULL; - } else { - // Lock the curve. - myPCurve->myIsLocked = true; - myCurrenPos = myListDiffs.end(); - } - } -} - -//======================================================================= -// function: Destructor -// purpose: -//======================================================================= -CurveCreator_CurveEditor::~CurveCreator_CurveEditor() -{ - if (myPCurve != NULL) { - // Unlock the curve. - myPCurve->myIsLocked = false; - } -} - -//======================================================================= -// function: getCurve -// purpose: -//======================================================================= -CurveCreator_Curve *CurveCreator_CurveEditor::getCurve() const -{ - return myPCurve; -} - -//======================================================================= -// function: isAttached -// purpose: -//======================================================================= -bool CurveCreator_CurveEditor::isAttached() const -{ - return (myPCurve != NULL); -} - -//======================================================================= -// function: undo -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::undo() -{ - if (myNbUndos > 0) { - myNbUndos--; - myNbRedos++; - myCurrenPos--; - myCurrenPos->applyUndo(myPCurve); - } -} - -//======================================================================= -// function: redo -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::redo() -{ - if (myNbRedos > 0) { - myCurrenPos->applyRedo(myPCurve); - myCurrenPos++; - myNbRedos--; - myNbUndos++; - } -} - -//======================================================================= -// function: getNbUndo -// purpose: -//======================================================================= -int CurveCreator_CurveEditor::getNbUndo() const -{ - return myNbUndos; -} - -//======================================================================= -// function: getNbRedo -// purpose: -//======================================================================= -int CurveCreator_CurveEditor::getNbRedo() const -{ - return myNbRedos; -} - -//======================================================================= -// function: setUndoDepth -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::setUndoDepth(const int theDepth) -{ - if (theDepth == 0) { - // Reset all undo/redo data. - myNbUndos = 0; - myNbRedos = 0; - myListDiffs.clear(); - myCurrenPos = myListDiffs.end(); - myUndoDepth = 0; - } else if (theDepth == -1) { - // There is nothing to do as the depth become unlimited. - myUndoDepth = -1; - } else if (theDepth > 0) { - // The new "real" depth is set. - if (theDepth < myNbRedos) { - // The new depth is less then number of redos. Remove the latest redos. - int aShift = (myNbRedos - theDepth); - ListDiff::iterator aFromPos = myListDiffs.end(); - - while (aShift--) { - aFromPos--; - } - - myListDiffs.erase(aFromPos, myListDiffs.end()); - myNbRedos = theDepth; - } - - if (theDepth < myNbUndos + myNbRedos) { - // The new depth is less then the total number of differences. - // Remove the first undos. - int aShift = (myNbUndos + myNbRedos - theDepth); - ListDiff::iterator aToPos = myListDiffs.begin(); - - while (aShift--) { - aToPos++; - } - - myListDiffs.erase(myListDiffs.begin(), aToPos); - myNbUndos = theDepth - myNbRedos; - } - - myUndoDepth = theDepth; - } -} - -//======================================================================= -// function: getUndoDepth -// purpose: -//======================================================================= -int CurveCreator_CurveEditor::getUndoDepth() const -{ - return myUndoDepth; -} - -//======================================================================= -// function: setType -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::setType(const CurveCreator::Type theType, - const int theISection) -{ - if (myPCurve != NULL) { - startOperation(); - // Set the difference. - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::SetType, - theType, theISection); - } - - // Update the curve. - myPCurve->setType(theType, theISection); - finishOperation(); - } -} - -//======================================================================= -// function: addPoints -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::addPoints - (const CurveCreator::Coordinates &thePoints, - const int theISection) -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::AddPoints, - thePoints, theISection); - } - - // Update the curve. - myPCurve->addPoints(thePoints, theISection); - finishOperation(); - } -} - -//======================================================================= -// function: addSection -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::addSection - (const std::string& theName, const CurveCreator::Type theType, - const bool theIsClosed, - const CurveCreator::Coordinates &thePoints) -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::AddSection, - theName, thePoints, theType, theIsClosed); - } - - // Update the curve. - myPCurve->addSection(theName, theType, theIsClosed, thePoints); - finishOperation(); - } -} - -//======================================================================= -// function: removeSection -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::removeSection(const int theISection) -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::RemoveSection, - theISection); - } - - // Update the curve. - myPCurve->removeSection(theISection); - finishOperation(); - } -} - -//======================================================================= -// function: insertPoints -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::insertPoints - (const CurveCreator::Coordinates &thePoints, - const int theISection, - const int theIPnt) -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::InsertPoints, - thePoints, theISection, theIPnt); - } - - // Update the curve. - myPCurve->insertPoints(thePoints, theISection, theIPnt); - finishOperation(); - } -} - -//======================================================================= -// function: movePoints -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::movePoint(const int theISection, - const int theOrigIPnt, - const int theNewIPnt ) -{ - startOperation(); - myPCurve->movePoint(theISection, theOrigIPnt, theNewIPnt); - finishOperation(); -} - -//======================================================================= -// function: removePoints -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::removePoints - (const int theISection, - const int theIPnt, - const int theNbPoints) -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::RemovePoints, - theISection, theIPnt, theNbPoints); - } - - // Update the curve. - myPCurve->removePoints(theISection, theIPnt, theNbPoints); - finishOperation(); - } -} - -//======================================================================= -// function: clear -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::clear() -{ - if (myPCurve != NULL) { - startOperation(); - // Set the difference. - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::Clear); - } - - // Update the curve. - myPCurve->clear(); - finishOperation(); - } -} - -//======================================================================= -// function: setCoordinates -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::setCoordinates - (const CurveCreator::Coordinates &theCoords, - const int theISection, - const int theIPnt) -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::SetCoordinates, - theCoords, theISection, theIPnt); - } - - // Update the curve. - myPCurve->setCoordinates(theCoords, theISection, theIPnt); - finishOperation(); - } -} - -//======================================================================= -// function: setClosed -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::setClosed(const bool theIsClosed, - const int theISection) -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::SetClosed, - theIsClosed, theISection); - } - - // Update the curve. - myPCurve->setClosed(theIsClosed, theISection); - finishOperation(); - } -} - -//======================================================================= -// function: setName -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::setName(const std::string& theName, - const int theISection) -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::RenameSection, - theName, theISection); - } - myPCurve->setName( theName, theISection ); - finishOperation(); - } -} - -//======================================================================= -// function: moveSection -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::moveSection(const int theISection, - const int theNewIndex) -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::MoveSection, - theISection, theNewIndex); - } - - // Update the curve. - myPCurve->moveSection(theISection, theNewIndex); - finishOperation(); - } -} - -//======================================================================= -// function: join -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::join(const int theISectionTo, - const int theISectionFrom) -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::Join, - theISectionTo, theISectionFrom); - } - - // Update the curve. - myPCurve->join(theISectionTo, theISectionFrom); - finishOperation(); - } -} - -//======================================================================= -// function: join -// purpose: -//======================================================================= -void CurveCreator_CurveEditor::join() -{ - if (myPCurve != NULL) { - // Set the difference. - startOperation(); - if (addEmptyDiff()) { - myListDiffs.back().init(myPCurve, CurveCreator_Operation::Join); - } - - // Update the curve. - myPCurve->join(); - finishOperation(); - } -} - -//======================================================================= -// function: addDiff -// purpose: -//======================================================================= -bool CurveCreator_CurveEditor::addEmptyDiff() -{ - bool isEnabled = false; - - if (myUndoDepth != 0) { - // Forget all Redos after the current one. - if (myNbRedos > 0) { - myNbRedos = 0; - myListDiffs.erase(myCurrenPos, myListDiffs.end()); - } - - if (myUndoDepth == -1 || myNbUndos < myUndoDepth) { - // Increase the number of undos. - myNbUndos++; - } else { - // If there are too many differences, remove the first one. - myListDiffs.pop_front(); - } - - // Add new difference. - myListDiffs.push_back(CurveCreator_Diff()); - myCurrenPos = myListDiffs.end(); - isEnabled = true; - } - - return isEnabled; -} - -void CurveCreator_CurveEditor::startOperation() -{ - myOpLevel++; -} - -void CurveCreator_CurveEditor::finishOperation() -{ - myOpLevel--; -} diff --git a/src/CurveCreator/CurveCreator_CurveEditor.hxx b/src/CurveCreator/CurveCreator_CurveEditor.hxx deleted file mode 100644 index 32aa00948..000000000 --- a/src/CurveCreator/CurveCreator_CurveEditor.hxx +++ /dev/null @@ -1,166 +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: CurveCreator_CurveEditor.hxx -// Author: Sergey KHROMOV - -#ifndef _CurveCreator_CurveEditor_HeaderFile -#define _CurveCreator_CurveEditor_HeaderFile - -#include "CurveCreator_Diff.hxx" -#include "CurveCreator_Curve.hxx" - -#include - -/** - * The CurveCreator_CurveEditor is designed to manage of - * editing operations of CurveCreator_Curve class. - */ -class CURVECREATOR_EXPORT CurveCreator_CurveEditor -{ - -private: - - typedef std::list ListDiff; - -public: - - //! Constuctor, initialized by the curve object - CurveCreator_CurveEditor(CurveCreator_Curve* thePCurve); - - //! Destructor, detaches from the Curve - ~CurveCreator_CurveEditor(); - - //! Returns the curve. - CurveCreator_Curve *getCurve() const; - - //! This method returns true if this editor is attached to a valid curve. - bool isAttached() const; - - //! Undo previous operation - void undo(); - - //! Redo last previously �undoed� operation - void redo(); - - //! Get number of available undo operations - int getNbUndo() const; - - //! Get number of available redo operations - int getNbRedo() const; - - //! Set depth of undo operations (unlimited if \a theDepth is -1 - // or disabled if \a theDepth is 0) - void setUndoDepth(const int theDepth = -1); - - //! Get depth of undo operations. - int getUndoDepth() const; - - /** Set type of the specified section (or all sections - * if \a theISection is -1). - */ - void setType(const CurveCreator::Type theType, const int theISection = -1); - - /** Set section closed (or all sections - * if \a theISection is -1). - */ - void setClosed(const bool theIsClosed, const int theISection); - - /** Set section name (if theISection is invalid it is ignored). - */ - void setName(const std::string& theName, const int theISection); - - /** Add points to the specified section (or last section - * if \a theISection is -1). - */ - void addPoints(const CurveCreator::Coordinates &thePoints, - const int theISection = -1); - - //! Add a new section. - void addSection(const std::string &theName, const CurveCreator::Type theType, - const bool theIsClosed, - const CurveCreator::Coordinates &thePoints); - - //! Removes the section. If theISection equals -1, removes the last section. - void removeSection(const int theISection = -1); - - /** Insert points in the given position (add to the end of list - * if \a theIPnt parameter is -1) of the specified section - * (or last section if \a theISection parameter is -1). - */ - void insertPoints(const CurveCreator::Coordinates &thePoints, - const int theISection = -1, - const int theIPnt = -1); - - /** Remove \a nbPoints points from given \a theISection, - * starting from given \a theIPnt (of all points up to the end of - * section if \a theNbPoints is -1). - */ - void removePoints(const int theISection, - const int theIPnt, - const int theNbPoints = -1); - - /** Mobe point in \a theISection from given position \a theOrigIPnt - * to new position \a theNewIPnt. - */ - void movePoint(const int theISection, - const int theOrigIPnt, - const int theNewIPnt ); - - //! Remove all sections. - void clear(); - - //! Set coordinates of specified point - void setCoordinates(const CurveCreator::Coordinates &theCoords, - const int theISection, - const int theIPnt); - - /** Move specified \a theISection to the specified position - * in the sections list. - */ - void moveSection(const int theISection, const int theNewIndex); - - //! Join two sections to one section - void join(const int theISectionTo, const int theISectionFrom); - - //! Join all sections to the single curve - void join(); - - void startOperation(); - void finishOperation(); -private: - - /** This method updates all undo/redo information required to be updated - * after curve modification operation. It returns false if undo/redo - * is disabled and true otherwise. - */ - bool addEmptyDiff(); - -private: - - int myNbUndos; - int myNbRedos; - ListDiff::iterator myCurrenPos; - ListDiff myListDiffs; - CurveCreator_Curve* myPCurve; - int myUndoDepth; - int myOpLevel; -}; - -#endif diff --git a/src/CurveCreator/CurveCreator_Diff.cxx b/src/CurveCreator/CurveCreator_Diff.cxx index 22f099e11..d1a7dc322 100644 --- a/src/CurveCreator/CurveCreator_Diff.cxx +++ b/src/CurveCreator/CurveCreator_Diff.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -49,9 +49,9 @@ CurveCreator_Diff::~CurveCreator_Diff() // function: init // purpose: //======================================================================= -bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, - const CurveCreator_Operation::Type theType) +bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve) { + CurveCreator_Operation::Type aType = CurveCreator_Operation::Clear; bool isOK = false; if (theCurve != NULL) { @@ -60,36 +60,18 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, // Set redo. myPRedo = new CurveCreator_Operation; - if (myPRedo->init(theType)) { + if (myPRedo->init(aType)) { isOK = true; const int aNbSections = theCurve->getNbSections(); - if (theType == CurveCreator_Operation::Clear) { - // Construct undo for Clear command. - if (aNbSections > 0) { - setNbUndos(aNbSections); + // Construct undo for Clear command. + if (aNbSections > 0) { + setNbUndos(aNbSections); - for (int i = 0; i < aNbSections && isOK; i++) { - // Add AddSection command. - isOK = addSectionToUndo(theCurve, i, myPUndo[i]); - } - } - } else { // theType == CurveCreator_Operation::Join - // Construct undo for Join command. - if (aNbSections > 1) { - // Add the RemovePoints command to remove points of - // the second section fron the first one. - const int aNbPoints = theCurve->getNbPoints(0); - - setNbUndos(aNbSections); - isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints, - 0, aNbPoints, -1); - - for (int i = 1; i < aNbSections && isOK; i++) { - // Add AddSection command. - isOK = addSectionToUndo(theCurve, i, myPUndo[i]); - } + for (int i = 0; i < aNbSections && isOK; i++) { + // Add AddSection command. + isOK = addSectionToUndo(theCurve, i, myPUndo[i]); } } } @@ -176,33 +158,6 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, setNbUndos(1); isOK = myPUndo[0].init(theType, theIntParam2, theIntParam1); break; - case CurveCreator_Operation::Join: - { - // If the last section is removed, one AddSection command is - // enough. If not last section is removed, two commands are - // requred: AddSection and MoveSection. - const int aLastIndex = theCurve->getNbSections() - 1; - const int aNbPoints = theCurve->getNbPoints(theIntParam1); - - if (theIntParam2 == aLastIndex) { - setNbUndos(2); - } else { - setNbUndos(3); - } - - isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints, - theIntParam1, aNbPoints, -1); - - if (isOK) { - isOK = addSectionToUndo(theCurve, theIntParam2, myPUndo[1]); - - if (isOK && theIntParam2 != aLastIndex) { - isOK = myPUndo[2].init(CurveCreator_Operation::MoveSection, - aLastIndex, theIntParam2); - } - } - } - break; default: break; } @@ -222,77 +177,68 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, //======================================================================= bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, - const int theIntParam1, - const int theIntParam2, - const int theIntParam3) + const std::list& theParams) { bool isOK = false; - if (theCurve != NULL) { + if (theCurve != NULL || theParams.empty()) { clear(); // Set redo. myPRedo = new CurveCreator_Operation; - if (myPRedo->init(theType, theIntParam1, theIntParam2, theIntParam3)) { - // Construct undo for RemovePoints command. - const CurveCreator::Dimension aDim = theCurve->getDimension(); - const CurveCreator::Coordinates &aPoints = - theCurve->getPoints(theIntParam1); - CurveCreator::Coordinates::const_iterator anIterBegin = - aPoints.begin() + (aDim*theIntParam2); - CurveCreator::Coordinates::const_iterator anIterEnd; + if (myPRedo->init(theType, theParams)) { + // Construct undo for different commands. + switch (theType) { + case CurveCreator_Operation::Join: + { + int aSectionMain = theParams.front(); + const int aNbPointsMain = theCurve->getNbPoints(aSectionMain); - if (theIntParam3 == -1) { - anIterEnd = aPoints.end(); - } else { - anIterEnd = anIterBegin + (aDim*theIntParam3); + std::list aSectionsToJoin = theParams; + aSectionsToJoin.erase( aSectionsToJoin.begin() ); + // it is important to sort the section indices in order to correct perform undo + // for the move sections to the previous positions + aSectionsToJoin.sort(); + // 1rst undo for remove points from the main and n-1 undoes to contain joined sections + int aSectionsToJoinNb = aSectionsToJoin.size(); + int aNbUndos = 2*aSectionsToJoinNb + 1; + setNbUndos( aNbUndos ); + + // Add joined sections to undo + std::list::const_iterator anIt = aSectionsToJoin.begin(), + aLast = aSectionsToJoin.end(); + anIt = aSectionsToJoin.begin(); + int aLastSectionId = -1; + for (int i = 0; anIt != aLast && i < aSectionsToJoinNb; anIt++, i++) { + int anISection = *anIt; + isOK = addSectionToUndo( theCurve, anISection, myPUndo[i*2] ); + if (isOK) { + isOK = myPUndo[i*2+1].init(CurveCreator_Operation::MoveSection, + aLastSectionId, anISection); + if (!isOK) + break; + } + } + // Construct undo for RemovePoints command. + if (isOK) { + int aNbPointsInJoined = 0; + anIt = aSectionsToJoin.begin(); + for ( ; anIt != aLast; anIt++ ) + aNbPointsInJoined += theCurve->getNbPoints( *anIt ); + + int aJoinedSize = aNbPointsMain + aNbPointsInJoined; + CurveCreator_ICurve::SectionToPointList aSectionToPointList; + for (int anIPoint = aNbPointsMain; anIPoint < aJoinedSize; anIPoint++) + aSectionToPointList.push_back(std::make_pair(aSectionMain, anIPoint)); + + isOK = myPUndo[aNbUndos-1].init(CurveCreator_Operation::RemovePoints, aSectionToPointList); + } + } + break; + default: + break; } - - CurveCreator::Coordinates aPointsToAdd; - - setNbUndos(1); - aPointsToAdd.insert(aPointsToAdd.end(), anIterBegin, anIterEnd); - isOK = myPUndo[0].init(CurveCreator_Operation::InsertPoints, - aPointsToAdd, theIntParam1, theIntParam2); - } - - if (!isOK) { - clear(); - } - } - - return isOK; -} - -//======================================================================= -// function: init -// purpose: -//======================================================================= -bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, - const CurveCreator_Operation::Type theType, - const CurveCreator::Coordinates &theCoords, - const int theIntParam) -{ - bool isOK = false; - - if (theCurve != NULL) { - clear(); - - // Set redo. - myPRedo = new CurveCreator_Operation; - - if (myPRedo->init(theType, theCoords, theIntParam)) { - // Construct undo for AddPoints command. - const int aSectionInd = getSectionIndex(theCurve, theIntParam); - const CurveCreator::Dimension aDim = theCurve->getDimension(); - const CurveCreator::Coordinates &aPoints = - theCurve->getPoints(aSectionInd); - const int aNbPoints = (aPoints.size()/aDim); - - setNbUndos(1); - isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints, - aSectionInd, aNbPoints, -1); } if (!isOK) { @@ -337,68 +283,6 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, return isOK; } -//======================================================================= -// function: init -// purpose: -//======================================================================= -bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, - const CurveCreator_Operation::Type theType, - const CurveCreator::Coordinates &theCoords, - const int theIntParam1, - const int theIntParam2) -{ - bool isOK = false; - - if (theCurve != NULL) { - clear(); - - // Set redo. - myPRedo = new CurveCreator_Operation; - - if (myPRedo->init(theType, theCoords, theIntParam1, theIntParam2)) { - // Construct undo for different commands. - switch (theType) { - case CurveCreator_Operation::InsertPoints: - { - const CurveCreator::Dimension aDim = theCurve->getDimension(); - const int aNbPoints = (theCoords.size()/aDim); - const int aSectionInd = getSectionIndex(theCurve, theIntParam1); - int aPointInd; - - if (theIntParam2 == -1) { - aPointInd = theCurve->getNbPoints(aSectionInd); - } else { - aPointInd = theIntParam2; - } - - setNbUndos(1); - isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints, - aSectionInd, aPointInd, aNbPoints); - } - break; - case CurveCreator_Operation::SetCoordinates: - { - const CurveCreator::Coordinates anOldCoords = - theCurve->getCoordinates(theIntParam1, theIntParam2); - - setNbUndos(1); - isOK = myPUndo[0].init(CurveCreator_Operation::SetCoordinates, - anOldCoords, theIntParam1, theIntParam2); - } - break; - default: - break; - } - } - - if (!isOK) { - clear(); - } - } - - return isOK; -} - bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, const std::string &theName, @@ -423,6 +307,152 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, return isOK; } +bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, + const CurveCreator_Operation::Type theType, + const CurveCreator_ICurve::SectionToPointList &theParamList1) +{ + bool isOK = false; + + if (theCurve != NULL) { + clear(); + + // Set redo. + myPRedo = new CurveCreator_Operation; + + if (myPRedo->init(theType, theParamList1)) { + // Construct undo for different commands. + switch (theType) { + case CurveCreator_Operation::RemovePoints: + { + // Construct undo for RemovePoints command. + CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointCoords; + CurveCreator::Coordinates aPointsToAdd; + const CurveCreator::Dimension aDim = theCurve->getDimension(); + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = theParamList1.begin(), aLast = theParamList1.end(); + std::list aPoints; + int aSectionId, aPointId; + for ( ; anIt != aLast; anIt++ ) { + aPointsToAdd.clear(); + aSectionId = anIt->first; + aPointId = anIt->second; + const CurveCreator::Coordinates &aPoints = + theCurve->getPoints(aSectionId); + CurveCreator::Coordinates::const_iterator anIterBegin = + aPoints.begin() + (aDim*aPointId); + CurveCreator::Coordinates::const_iterator anIterEnd = + anIterBegin + aDim; + aPointsToAdd.insert(aPointsToAdd.end(), anIterBegin, anIterEnd); + aSectionToPointCoords.push_back(std::make_pair(*anIt, aPointsToAdd)); + } + setNbUndos(1); + isOK = myPUndo[0].init(CurveCreator_Operation::InsertPoints, + aSectionToPointCoords); + } + break; + default: + break; + } + } + + if (!isOK) { + clear(); + } + } + + return isOK; +} + +bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, + const CurveCreator_Operation::Type theType, + const CurveCreator_ICurve::SectionToPointCoordsList &theParamList1) +{ + bool isOK = false; + + if (theCurve != NULL) { + clear(); + + // Set redo. + myPRedo = new CurveCreator_Operation; + + if (myPRedo->init(theType, theParamList1)) { + // Construct undo for different commands. + switch (theType) { + case CurveCreator_Operation::InsertPoints: + { + // Construct undo for RemovePoints command. + CurveCreator_ICurve::SectionToPointList aSectionToPointList; + CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = theParamList1.begin(), aLast = theParamList1.end(); + for ( ; anIt != aLast; anIt++ ) { + aSectionToPointList.push_back(anIt->first); + } + setNbUndos(1); + isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints, + aSectionToPointList); + } + break; + case CurveCreator_Operation::SetCoordinates: + { + // Construct undo for SetCoordinates command. + CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointOldCoords; + CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = theParamList1.begin(), aLast = theParamList1.end(); + for ( ; anIt != aLast; anIt++ ) { + CurveCreator::Coordinates anOldCoords = theCurve->getPoint(anIt->first.first, anIt->first.second); + aSectionToPointOldCoords.push_back(std::make_pair(anIt->first, anOldCoords)); + } + + setNbUndos(1); + isOK = myPUndo[0].init(CurveCreator_Operation::SetCoordinates, + aSectionToPointOldCoords); + } + break; + default: + break; + } + } + + if (!isOK) { + clear(); + } + } + + return isOK; +} + +bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, + const CurveCreator_ICurve::SectionToPointCoordsList &theOldParamList) +{ + bool isOK = false; + + if (theCurve != NULL && theOldParamList.size() > 0) { + clear(); + + // Set redo. + myPRedo = new CurveCreator_Operation; + + // Construct redo for SetCoordinates command. + CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointActualCoords; + CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = + theOldParamList.begin(), aLast = theOldParamList.end(); + for ( ; anIt != aLast; anIt++ ) { + CurveCreator::Coordinates anActualCoords = theCurve->getPoint(anIt->first.first, anIt->first.second); + aSectionToPointActualCoords.push_back(std::make_pair(anIt->first, anActualCoords)); + } + + if (myPRedo->init(CurveCreator_Operation::SetCoordinates, aSectionToPointActualCoords)) { + // Undo for SetCoordinates command. + setNbUndos(1); + isOK = myPUndo[0].init(CurveCreator_Operation::SetCoordinates, + theOldParamList); + } + + if (!isOK) { + clear(); + } + } + + return isOK; +} + //======================================================================= // function: applyUndo // purpose: @@ -495,12 +525,13 @@ bool CurveCreator_Diff::addSectionToUndo const int theIndex, CurveCreator_Operation &theOperation) const { + const std::string aName = theCurve->getSectionName(theIndex); const CurveCreator::Coordinates &aPnts = theCurve->getPoints(theIndex); - const CurveCreator::Type aType = theCurve->getType(theIndex); + const CurveCreator::SectionType aType = theCurve->getSectionType(theIndex); const bool isClosed = theCurve->isClosed(theIndex); bool isOK = theOperation.init(CurveCreator_Operation::AddSection, - aPnts, aType, isClosed); + aName, aPnts, aType, isClosed); return isOK; } @@ -533,7 +564,7 @@ bool CurveCreator_Diff::setTypeOrClosedToUndo // Get sections to be modified. for (i = 0; i < aNbSections; i++) { if (isSetType) { - aValue = theCurve->getType(i); + aValue = theCurve->getSectionType(i); } else { aValue = theCurve->isClosed(i); } @@ -556,7 +587,7 @@ bool CurveCreator_Diff::setTypeOrClosedToUndo // There is only particular section modified. // Check if there is a real modification required. if (isSetType) { - aValue = theCurve->getType(theIntParam2); + aValue = theCurve->getSectionType(theIntParam2); } else { aValue = theCurve->isClosed(theIntParam2); } @@ -572,7 +603,7 @@ bool CurveCreator_Diff::setTypeOrClosedToUndo std::list::iterator anIter = aListOfInd.begin(); if (isSetType) { - aValue = theCurve->getType(*anIter); + aValue = theCurve->getSectionType(*anIter); } else { aValue = theCurve->isClosed(*anIter); } diff --git a/src/CurveCreator/CurveCreator_Diff.hxx b/src/CurveCreator/CurveCreator_Diff.hxx index e56b294f2..f55f5306f 100644 --- a/src/CurveCreator/CurveCreator_Diff.hxx +++ b/src/CurveCreator/CurveCreator_Diff.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -56,11 +56,9 @@ public: * parameters. It is applicable to the following operations: *
      *
    • Clear
    • - *
    • Join (without arguments)
    • *
    */ - bool init(const CurveCreator_Curve *theCurve, - const CurveCreator_Operation::Type theType); + bool init(const CurveCreator_Curve *theCurve); /** * This method initializes the difference with an operation with one integer @@ -80,7 +78,6 @@ public: *
  • SetType
  • *
  • SetClosed
  • *
  • MoveSection
  • - *
  • Join (with 2 int arguments)
  • * */ bool init(const CurveCreator_Curve *theCurve, @@ -88,46 +85,16 @@ public: const int theIntParam1, const int theIntParam2); - /** - * This method initializes the difference with an operation with three - * integer parameters. It is applicable to the following operations: + /** + * This method initializes the difference with an operation with two integer + * parameters. It is applicable to the following operations: *
      - *
    • RemovePoints
    • + *
    • Join (with a list of int arguments)
    • *
    */ bool init(const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, - const int theIntParam1, - const int theIntParam2, - const int theIntParam3); - - /** - * This method initializes the difference with an operation with one - * CurveCreator::Coordinates parameter and one integer parameter. - * It is applicable to the following operations: - *
      - *
    • AddPoints
    • - *
    - */ - bool init(const CurveCreator_Curve *theCurve, - const CurveCreator_Operation::Type theType, - const CurveCreator::Coordinates &theCoords, - const int theIntParam); - - /** - * This method initializes the difference with an operation with one - * CurveCreator::Coordinates parameter and two integer parameters. - * It is applicable to the following operations: - *
      - *
    • InsertPoints
    • - *
    • SetCoordinates
    • - *
    - */ - bool init(const CurveCreator_Curve *theCurve, - const CurveCreator_Operation::Type theType, - const CurveCreator::Coordinates &theCoords, - const int theIntParam1, - const int theIntParam2); + const std::list& theParams); /** * This method initializes the difference with an operation with one @@ -157,6 +124,39 @@ public: const std::string &theName, const int theIntParam1 ); + /** + * This method initializes the difference with an operation with + * list of pairs of integer parameters. + * It is applicable to the following operations: + *
      + *
    • RemovePoints
    • + *
    + */ + bool init(const CurveCreator_Curve *theCurve, + const CurveCreator_Operation::Type theType, + const CurveCreator_ICurve::SectionToPointList &theParamList); + + /** + * This method initializes the difference with an operation with + * list of pairs of integer parameters with point coordinates. + * It is applicable to the following operations: + *
      + *
    • RemovePoints
    • + *
    + */ + bool init(const CurveCreator_Curve *theCurve, + const CurveCreator_Operation::Type theType, + const CurveCreator_ICurve::SectionToPointCoordsList &theParamList); + + /** + * This method initializes the difference with an operation with + * list of pairs of integer parameters with point coordinates. + * \param theCurve the modified curve + * \param theOldParamList the old parameters (to be saved for undo) + */ + bool init(const CurveCreator_Curve *theCurve, + const CurveCreator_ICurve::SectionToPointCoordsList &theOldParamList); + /** * This method applies undo operation to theCurve. */ diff --git a/src/CurveCreator/CurveCreator_Displayer.cxx b/src/CurveCreator/CurveCreator_Displayer.cxx new file mode 100644 index 000000000..22ae3990c --- /dev/null +++ b/src/CurveCreator/CurveCreator_Displayer.cxx @@ -0,0 +1,64 @@ +#include "CurveCreator_Displayer.hxx" + +CurveCreator_Displayer::CurveCreator_Displayer( Handle_AIS_InteractiveContext theContext, + const int theZLayer ) : + myContext( theContext ), myZLayer( theZLayer ) +{ + myObjects.clear(); +} + +CurveCreator_Displayer::~CurveCreator_Displayer(void) +{ + eraseAll( true ); + for( int i = 0 ; i < myObjects.size() ; i++ ){ + myObjects[i].Nullify(); + } + myObjects.clear(); +} + +void CurveCreator_Displayer::display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate ) +{ + if ( theObject.IsNull() ) + return; + + myObjects.push_back( theObject ); + myContext->Display( theObject, Standard_False ); + + if ( myZLayer >= 0 ) + myContext->SetZLayer( theObject, myZLayer ); + + if( isUpdate ) + myContext->UpdateCurrentViewer(); +} + +void CurveCreator_Displayer::eraseAll( bool isUpdate ) +{ + if(myObjects.empty()) + return; + for( int i = 0 ; i < myObjects.size() ; i++ ){ + myContext->Erase(myObjects[i], Standard_False); + } + myObjects.clear(); + if( isUpdate ) + myContext->UpdateCurrentViewer(); +} + +Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL ) +{ + if( isHL ){ + return Quantity_Color( 1., 0., 0., Quantity_TOC_RGB ); + } + return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB ); +} + +/*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL ) +{ + return; + //TODO: + Quantity_Color aColor = getActiveColor( isHL ); + for( int i = 0 ; i < theObjects.size() ; i++ ){ + theObjects[i]->SetColor(aColor); + myContext->Display(theObjects[i], Standard_False); + } + myContext->UpdateCurrentViewer(); +}*/ diff --git a/src/CurveCreator/CurveCreator_Displayer.hxx b/src/CurveCreator/CurveCreator_Displayer.hxx new file mode 100644 index 000000000..f65e9d2ec --- /dev/null +++ b/src/CurveCreator/CurveCreator_Displayer.hxx @@ -0,0 +1,33 @@ +#ifndef CURVECREATOR_DISPLAYER_H +#define CURVECREATOR_DISPLAYER_H + +#include "CurveCreator_Macro.hxx" + +#include +#include + +#include + +class CURVECREATOR_EXPORT CurveCreator_Displayer +{ +typedef std::vector AISObjectsList; + +public: + CurveCreator_Displayer( Handle_AIS_InteractiveContext theContext, + const int theZLayer = -1 ); + ~CurveCreator_Displayer(void); + + void display( const Handle_AIS_InteractiveObject& theObject, bool isUpdate ); + void eraseAll( bool isUpdate ); + //void highlight( const AISObjectsList& theObjects, bool isHL ); + +protected: + Quantity_Color getActiveColor( bool isHL ); + +private: + Handle_AIS_InteractiveContext myContext; + AISObjectsList myObjects; + int myZLayer; +}; + +#endif diff --git a/src/CurveCreator/CurveCreator_ICurve.cxx b/src/CurveCreator/CurveCreator_ICurve.cxx deleted file mode 100644 index fc73f56e7..000000000 --- a/src/CurveCreator/CurveCreator_ICurve.cxx +++ /dev/null @@ -1,459 +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: CurveCreator_ICurve.cxx -// Author: Sergey KHROMOV - -#include "CurveCreator_ICurve.hxx" -#include "CurveCreator_Section.hxx" -#include "CurveCreator_Listener.hxx" - -#include - -//======================================================================= -// function: Constructor -// purpose: -//======================================================================= -CurveCreator_ICurve::CurveCreator_ICurve - (const CurveCreator::Dimension theDimension) -: myIsLocked (false), - myDimension (theDimension), - myListener(NULL) -{ -} - -//======================================================================= -// function: Destructor -// purpose: -//======================================================================= -CurveCreator_ICurve::~CurveCreator_ICurve() -{ - // Delete all allocated data. - clear(); -} - -//======================================================================= -// function: isLocked -// purpose: -//======================================================================= -bool CurveCreator_ICurve::isLocked() const -{ - return myIsLocked; -} - -//======================================================================= -// function: getDimension -// purpose: -//======================================================================= -CurveCreator::Dimension CurveCreator_ICurve::getDimension() const -{ - return myDimension; -} - -//======================================================================= -// function: getNbPoints -// purpose: -//======================================================================= -int CurveCreator_ICurve::getNbPoints(const int theISection) const -{ - int aNbCoords = 0; - - if (theISection == -1) { - int i = 0; - const int aNbSections = getNbSections(); - - for (; i < aNbSections; i++) { - aNbCoords += mySections[i]->myPoints.size(); - } - } else { - aNbCoords = mySections.at(theISection)->myPoints.size(); - } - - return aNbCoords/myDimension; -} - -//======================================================================= -// function: getNbSections -// purpose: -//======================================================================= -int CurveCreator_ICurve::getNbSections() const -{ - return mySections.size(); -} - -//======================================================================= -// function: getCoordinates -// purpose: -//======================================================================= -CurveCreator::Coordinates CurveCreator_ICurve::getCoordinates - (const int theISection, const int theIPnt) const -{ - CurveCreator_Section *aSection = mySections.at(theISection); - CurveCreator::Coordinates::const_iterator - anIter = aSection->myPoints.begin() + toICoord(theIPnt); - CurveCreator::Coordinates aResult(anIter, anIter + myDimension); - - return aResult; -} - -//======================================================================= -// function: getType -// purpose: -//======================================================================= -CurveCreator::Type CurveCreator_ICurve::getType(const int theISection) const -{ - return mySections.at(theISection)->myType; -} - -//======================================================================= -// function: getPoints -// purpose: -//======================================================================= -const CurveCreator::Coordinates &CurveCreator_ICurve::getPoints - (const int theISection) const -{ - return mySections.at(theISection)->myPoints; -} - -//======================================================================= -// function: isClosed -// purpose: -//======================================================================= -bool CurveCreator_ICurve::isClosed(const int theISection) const -{ - return mySections.at(theISection)->myIsClosed; -} - -std::string CurveCreator_ICurve::getSectionName(const int theISection) const -{ - return mySections.at(theISection)->myName; -} - -//======================================================================= -// function: setType -// purpose: -//======================================================================= -void CurveCreator_ICurve::setType - (const CurveCreator::Type theType, const int theISection) -{ - if (theISection == -1) { - int i = 0; - const int aNbSections = getNbSections(); - - for (; i < aNbSections; i++) { - mySections[i]->myType = theType; - } - if( myListener ) - myListener->curveChanged(); - } else { - if( mySections.at(theISection)->myType != theType ){ - mySections.at(theISection)->myType = theType; - if( myListener ) - myListener->sectionTypeChanged(theISection); - } - } -} - -//======================================================================= -// function: addSection -// purpose: -//======================================================================= -void CurveCreator_ICurve::addSection - (const std::string& theName, - const CurveCreator::Type theType, - const bool theIsClosed, - const CurveCreator::Coordinates &thePoints) -{ - CurveCreator_Section *aSection = new CurveCreator_Section; - - std::string aName = theName; - if( aName.empty() ){ - aName = getUnicSectionName(); - } - aSection->myName = aName; - aSection->myType = theType; - aSection->myIsClosed = theIsClosed; - aSection->myPoints = thePoints; - mySections.push_back(aSection); - if( myListener ) - myListener->sectionAdded( -1 ); -} - -//======================================================================= -// function: removeSection -// purpose: -//======================================================================= -void CurveCreator_ICurve::removeSection(const int theISection) -{ - if (theISection == -1) { - delete mySections.back(); - mySections.pop_back(); - } else { - Sections::iterator anIterRm = mySections.begin() + theISection; - - delete *anIterRm; - mySections.erase(anIterRm); - } - if( myListener ) - myListener->sectionRemoved(theISection); -} - -//======================================================================= -// function: insertPoints -// purpose: -//======================================================================= -void CurveCreator_ICurve::insertPoints - (const CurveCreator::Coordinates &thePoints, - const int theISection, - const int theIPnt) -{ - if (theIPnt == -1) { - // Add points to the end of section points. - addPoints(thePoints, theISection); - } else { - CurveCreator_Section *aSection = - (theISection == -1 ? mySections.back() : mySections.at(theISection)); - - aSection->myPoints.insert(aSection->myPoints.begin() + toICoord(theIPnt), - thePoints.begin(), thePoints.end()); - if( myListener ) - myListener->pointInserted( theISection, theIPnt ); - } -} - -void CurveCreator_ICurve::movePoint(const int theISection, const int theIPointFrom, const int theNewIndex) -{ - CurveCreator::Coordinates aCoords = getCoordinates(theISection, theIPointFrom ); - insertPoints(aCoords, theISection, theNewIndex+1); - int aRemPntIndx = theIPointFrom; - if( theNewIndex < theIPointFrom ) - aRemPntIndx++; - removePoints(theISection, aRemPntIndx, 1 ); -} - -//======================================================================= -// function: removePoints -// purpose: -//======================================================================= -void CurveCreator_ICurve::removePoints(const int theISection, - const int theIPnt, - const int theNbPoints) -{ - CurveCreator_Section *aSection = mySections.at(theISection); - CurveCreator::Coordinates::iterator anIterBegin = - aSection->myPoints.begin() + toICoord(theIPnt); - CurveCreator::Coordinates::iterator anIterEnd = - (theNbPoints == -1 ? - aSection->myPoints.end() : anIterBegin + toICoord(theNbPoints)); - - aSection->myPoints.erase(anIterBegin, anIterEnd); - if( myListener ) - myListener->pointRemoved(theISection, theIPnt, theNbPoints ); -} - -//======================================================================= -// function: clear -// purpose: -//======================================================================= -void CurveCreator_ICurve::clear() -{ - // Delete all allocated data. - int i = 0; - const int aNbSections = getNbSections(); - - for (; i < aNbSections; i++) { - delete mySections[i]; - } - - mySections.clear(); - if( myListener ) - myListener->curveChanged(); -} - -//======================================================================= -// function: setCoordinates -// purpose: -//======================================================================= -void CurveCreator_ICurve::setCoordinates - (const CurveCreator::Coordinates &theCoords, - const int theISection, - const int theIPnt) -{ - if (theCoords.size() == myDimension) { - CurveCreator_Section *aSection = mySections.at(theISection); - int i; - - for (i = 0; i < myDimension; i++) { - aSection->myPoints.at(toICoord(theIPnt) + i) = theCoords[i]; - } - - if( myListener ) - myListener->pointChanged( theISection, theIPnt ); - } -} - -//======================================================================= -// function: setClosed -// purpose: -//======================================================================= -void CurveCreator_ICurve::setClosed(const bool theIsClosed, - const int theISection) -{ - if (theISection == -1) { - int aSize = mySections.size(); - int i; - - for (i = 0; i < aSize; i++) { - mySections[i]->myIsClosed = theIsClosed; - if( myListener ){ - myListener->sectionClosed( theISection, theIsClosed ); - } - } - } else { - mySections.at(theISection)->myIsClosed = theIsClosed; - if( myListener ){ - myListener->sectionClosed( theISection, theIsClosed ); - } - } -} - -/** Set name of the specified section. - */ -void CurveCreator_ICurve::setName( const std::string& theName, const int theISection ) -{ - if( ( theISection >= 0 ) && ( theISection < mySections.size() )){ - mySections.at(theISection)->myName = theName; - } -} - -//======================================================================= -// function: moveSection -// purpose: -//======================================================================= -void CurveCreator_ICurve::moveSection(const int theISection, - const int theNewIndex) -{ - if (theISection != theNewIndex) { - CurveCreator_Section *aSection = mySections.at(theISection); - - // Remove section - Sections::iterator anIter = mySections.begin() + theISection; - - mySections.erase(anIter); - - // Insert section. - anIter = mySections.begin() + theNewIndex; - mySections.insert(anIter, aSection); - } -} - -//======================================================================= -// function: join -// purpose: -//======================================================================= -void CurveCreator_ICurve::join(const int theISectionTo, - const int theISectionFrom) -{ - if (theISectionTo != theISectionFrom) { - CurveCreator_Section *aSection1 = mySections.at(theISectionTo); - CurveCreator_Section *aSection2 = mySections.at(theISectionFrom); - - aSection1->myPoints.insert(aSection1->myPoints.end(), - aSection2->myPoints.begin(), aSection2->myPoints.end()); - - removeSection(theISectionFrom); - if( myListener ) - myListener->curveChanged(); - } -} - -//======================================================================= -// function: join -// purpose: -//======================================================================= -void CurveCreator_ICurve::join() -{ - const int aSize = mySections.size(); - - if (aSize > 1) { - CurveCreator_Section *aSection1 = mySections[0]; - int i; - - for (i = 1; i < aSize; i++) { - CurveCreator_Section *aSection2 = mySections[i]; - - aSection1->myPoints.insert(aSection1->myPoints.end(), - aSection2->myPoints.begin(), aSection2->myPoints.end()); - delete aSection2; - } - - // Just erace section pointers as they were deleted before. - mySections.erase(mySections.begin() + 1, mySections.end()); - if( myListener ) - myListener->curveChanged(); - } -} - -//======================================================================= -// function: toICoord -// purpose: -//======================================================================= -int CurveCreator_ICurve::toICoord(const int theIPnt) const -{ - return theIPnt*myDimension; -} - -//======================================================================= -// function: getUnicSectionName -// purpose: return unic section name -//======================================================================= -std::string CurveCreator_ICurve::getUnicSectionName() -{ - for( int i = 0 ; i < 1000000 ; i++ ){ - char aBuffer[255]; - sprintf( aBuffer, "Section_%d", i+1 ); - std::string aName(aBuffer); - int j; - for( j = 0 ; j < mySections.size() ; j++ ){ - if( mySections[j]->myName == aName ) - break; - } - if( j == mySections.size() ) - return aName; - } - return ""; -} - -//======================================================================= -// function: setListener -// purpose: set curve changes listener -//======================================================================= -void CurveCreator_ICurve::setListener( CurveCreator_Listener* theListener ) -{ - myListener = theListener; -} - -//======================================================================= -// function: setListener -// purpose: set curve changes listener -//======================================================================= -void CurveCreator_ICurve::removeListener() -{ - myListener = NULL; -} diff --git a/src/CurveCreator/CurveCreator_ICurve.hxx b/src/CurveCreator/CurveCreator_ICurve.hxx index ca662be1d..9effa478a 100644 --- a/src/CurveCreator/CurveCreator_ICurve.hxx +++ b/src/CurveCreator/CurveCreator_ICurve.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,170 +17,189 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: CurveCreator_Curve.hxx -// Author: Sergey KHROMOV +// File: CurveCreator_ICurve.hxx +// Author: Alexander KOVALEV and Alexander SOLOVYOV #ifndef _CurveCreator_ICurve_HeaderFile #define _CurveCreator_ICurve_HeaderFile -#include "CurveCreator.hxx" #include "CurveCreator_Macro.hxx" -#include "CurveCreator_Operation.hxx" +#include +#include +#include +#include -class CurveCreator_Section; -class CurveCreator_Listener; +class Handle_AIS_InteractiveObject; + +namespace CurveCreator +{ + //! Type of the section + enum SectionType + { + Polyline, + Spline, + }; + + //! Dimension of the curve + enum Dimension + { + Dim2d = 2, + Dim3d = 3 + }; + +}; /** * The CurveCreator_ICurve object is represented as one or more sets of * connected points; thus CurveCreator_ICurve object can contain several * not connected curves (polylines or b-splines), each such curve has two - * only ends � start and end points � in other words non-manifold curves + * only ends "start and end points" in other words non-manifold curves * are not supported. */ class CURVECREATOR_EXPORT CurveCreator_ICurve { +public: + typedef std::pair SectionToPoint; + typedef std::deque SectionToPointList; - //! List of curves - typedef std::deque Sections; + typedef std::deque< std::pair< SectionToPoint,std::deque< float > > > SectionToPointCoordsList; public: - //! Constructor of the curve. - /** The dimension is explicitly specified in the constructor - * and cannot be changed later. - */ - CurveCreator_ICurve(const CurveCreator::Dimension theDimension); + /***********************************************/ + /*** Undo/Redo methods ***/ + /***********************************************/ - //! Destructor. - virtual ~CurveCreator_ICurve(); + //! Get number of available undo operations + virtual int getNbUndo() const = 0; - //! Returns true if this curve is locked by a curve editor. - virtual bool isLocked() const; + //! Undo previous operation + virtual bool undo() = 0; - //! Get the dimension. - virtual CurveCreator::Dimension getDimension() const; + //! Get number of available redo operations + virtual int getNbRedo() const = 0; - //! Get number of sections. - virtual int getNbSections() const; + //! Redo last previously "undone" operation + virtual bool redo() = 0; - /** Get number of points in specified section or (the total number of points - * in Curve if theISection is equal to -1). - */ - virtual int getNbPoints(const int theISection = -1) const; - //! Get coordinates of specified point - virtual CurveCreator::Coordinates getCoordinates - (const int theISection, const int theIPnt) const; + /***********************************************/ + /*** Section methods ***/ + /***********************************************/ - //! Get points of a section. - virtual const CurveCreator::Coordinates &getPoints(const int theISection) const; + //! Clear the polyline (remove all sections) + virtual bool clear() = 0; - //! Get type of the specified section - virtual CurveCreator::Type getType(const int theISection) const; + //! Join list of sections to one section (join all if the list is empty) + // The first section in the list is a leader, another sections are joined to it + virtual bool join( const std::list& theSections ) = 0; - //! Get �closed� flag of the specified section - virtual bool isClosed(const int theISection) const; - - //! Returns specifyed section name - virtual std::string getSectionName(const int theISection) const; - - /** - * Return unic section name - */ - virtual std::string getUnicSectionName(); - - /** - * Set curve creator listener object - */ - virtual void setListener( CurveCreator_Listener* myWatcher ); - - /** - * Remove curve creator listener object - */ - virtual void removeListener(); - -protected: - - /** Set type of the specified section (or all sections - * if \a theISection is -1). - */ - virtual void setType(const CurveCreator::Type theType, const int theISection = -1); - - /** Add points to the specified section (or last section - * if \a theISection is -1). - */ - virtual void addPoints - (const CurveCreator::Coordinates &thePoints, const int theISection = -1) = 0; + //! Get number of sections + virtual int getNbSections() const = 0; //! Add a new section. - virtual void addSection (const std::string &theName, const CurveCreator::Type theType, - const bool theIsClosed, - const CurveCreator::Coordinates &thePoints); + virtual int addSection( const std::string& theName, + const CurveCreator::SectionType theType, + const bool theIsClosed ) = 0; - //! Removes the section. If theISection equals -1, removes the last section. - virtual void removeSection(const int theISection = -1); + //! Removes the given sections. + virtual bool removeSection( const int theISection ) = 0; - /** Insert points in the given position (add to the end of list - * if \a theIPnt parameter is -1) of the specified section - * (or last section if \a theISection parameter is -1). - */ - virtual void insertPoints(const CurveCreator::Coordinates &thePoints, - const int theISection = -1, - const int theIPnt = -1); - - /** Remove \a nbPoints points from given \a theISection, - * starting from given \a theIPnt (of all points up to the end of - * section if \a theNbPoints is -1). - */ - virtual void removePoints(const int theISection, - const int theIPnt, - const int theNbPoints = -1); - - /** Move specified point within section to new position - */ - virtual void movePoint(const int theISection, - const int theIPointFrom, - const int theNewIndex); - - //! Remove all sections. - virtual void clear(); - - //! Set coordinates of specified point - virtual void setCoordinates(const CurveCreator::Coordinates &theCoords, - const int theISection, - const int theIPnt); - - /** Set �closed� flag of the specified section (all sections if - * \a theISection is -1). - */ - virtual void setClosed(const bool theIsClosed, const int theISection = -1); - - /** Set name of the specified section. - */ - virtual void setName( const std::string& theName, const int theISection ); - - /** Move specified \a theISection to the specified position - * in the sections list. - */ - virtual void moveSection(const int theISection, const int theNewIndex); - - //! Join two sections to one section - virtual void join(const int theISectionTo, const int theISectionFrom); - - //! Join all sections to the single curve - virtual void join(); + //! Get "closed" flag of the specified section + virtual bool isClosed( const int theISection ) const = 0; /** - * This method converts the point index to the index in - * an array of coordinates. + * Set "closed" flag of the specified section (all sections if + * \a theISection is -1). */ - virtual int toICoord(const int theIPnt) const; + virtual bool setClosed( const int theISection, + const bool theIsClosed ) = 0; -public: + //! Returns specifyed section name + virtual std::string getSectionName( const int theISection ) const = 0; - bool myIsLocked; - Sections mySections; //!< curve data - CurveCreator::Dimension myDimension; //!< curve dimension - CurveCreator_Listener* myListener; //!< listener + /** Set name of the specified section */ + virtual bool setSectionName( const int theISection, + const std::string& theName ) = 0; + + //! Get type of the specified section + virtual CurveCreator::SectionType getSectionType( const int theISection ) const = 0; + + /** + * Set type of the specified section (or all sections + * if \a theISection is -1). + */ + virtual bool setSectionType( const int theISection, + const CurveCreator::SectionType theType ) = 0; + + + /***********************************************/ + /*** Point methods ***/ + /***********************************************/ + + //! Get the dimension. + virtual CurveCreator::Dimension getDimension() const = 0; + + /** + * Insert one or several points to the specified section starting from the given theIPnt index + * (or add these at the end of section points if \a theIPnt is -1). + */ + virtual bool addPoints( const std::deque& theCoords, + const int theISection, + const int theIPnt = -1 ) = 0; + + //! Set coordinates of specified point + virtual bool setPoint( const int theISection, + const int theIPnt, + const std::deque& theNewCoords ) = 0; + + //! Set coordinates of specified points from different sections + virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords, + const bool theIsToSaveDiff = true ) = 0; + + //! Remove point with given id + virtual bool removePoint( const int theISection, const int theIPnt = -1 ) = 0; + //! Remove several points from different sections + virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs) = 0; + + //! Get coordinates of specified point + virtual std::deque getPoint( const int theISection, + const int theIPnt ) const = 0; + + /** + * Get points of a section (the total points in Curve if theISection is equal to -1).. + */ + virtual std::deque getPoints( const int theISection = -1 ) const = 0; + + /** + * Get number of points in specified section or (the total number of points + * in Curve if theISection is equal to -1). + */ + virtual int getNbPoints( const int theISection ) const = 0; + + /** + * Set skip sorting flag. If the flag is true - points sorting will be skipped. + */ + virtual void setSkipSorting( const bool ) = 0; + + /** + * Indicates whether the points can be sorted. + */ + virtual bool canPointsBeSorted() = 0; + + /** + * Saves points coordinates difference. + * \param theOldCoords the old points coordinates + */ + virtual void saveCoordDiff( const SectionToPointCoordsList &theOldCoords ) = 0; + + /***********************************************/ + /*** Presentation methods ***/ + /***********************************************/ + + virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const = 0; + +protected: + virtual void constructAISObject() = 0; }; diff --git a/src/CurveCreator/CurveCreator_Macro.hxx b/src/CurveCreator/CurveCreator_Macro.hxx index 9e6c31c68..ec814eb49 100644 --- a/src/CurveCreator/CurveCreator_Macro.hxx +++ b/src/CurveCreator/CurveCreator_Macro.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/CurveCreator/CurveCreator_NewPointDlg.cxx b/src/CurveCreator/CurveCreator_NewPointDlg.cxx deleted file mode 100755 index bb15571e8..000000000 --- a/src/CurveCreator/CurveCreator_NewPointDlg.cxx +++ /dev/null @@ -1,196 +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 "CurveCreator_NewPointDlg.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) : - QWidget(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false), myDim(theDim), - myIsInstantSketchingEnabled(false) -{ - QString aTitle = QString(tr("ADD_NEW_POINT")); - setWindowTitle(aTitle); - - QFrame* aFrame = new QFrame( this ); - QVBoxLayout* aLayout = new QVBoxLayout( aFrame ); - - QFrame* aCoordFrame = new QFrame( aFrame ); - QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame ); - - QLabel* aLbl = new QLabel( tr("X_COORD"), this); - myX = new QDoubleSpinBox(this); - aCoordLayout->addWidget(aLbl, 0, 0); - aCoordLayout->addWidget(myX, 0, 1 ); - - aLbl = new QLabel( tr("Y_COORD"), this); - myY = new QDoubleSpinBox(this); - aCoordLayout->addWidget(aLbl, 1, 0 ); - aCoordLayout->addWidget(myY, 1, 1 ); - - myZLabel = new QLabel( tr("Z_COORD"), this); - myZ = new QDoubleSpinBox(this); - aCoordLayout->addWidget(myZLabel, 2,0 ); - aCoordLayout->addWidget(myZ, 2,1 ); - - if( theDim != CurveCreator::Dim3d ){ - myZ->hide(); - myZLabel->hide(); - } - - myBtnFrame = new QFrame( aFrame ); - QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame ); - - myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame ); - myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame ); - - connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelPoint() ) ); - - aBtnsLayout->addWidget( myAddBtn ); - aBtnsLayout->addStretch( 1 ); - aBtnsLayout->addWidget( myCancelBtn ); - - aLayout->addWidget( aCoordFrame, 0 ); - aLayout->addWidget( myBtnFrame, 1 ); - - clear(); - updateTitle(); -} - -void CurveCreator_NewPointDlg::setSectionName( const QString& theName ) -{ - mySectionName = theName; - updateTitle(); -} - -void CurveCreator_NewPointDlg::setEditMode( bool isEdit ) -{ - myIsEdit = isEdit; - if( myIsEdit ){ - myAddBtn->setText(tr("OK")); - myAddBtn->disconnect( SIGNAL( clicked() ) ); - connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifyPoint() ) ); - } - else{ - myAddBtn->setText(tr("ADD_BTN")); - myAddBtn->disconnect( SIGNAL( clicked() ) ); - connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addPoint() ) ); - } - updateTitle(); -} - -void CurveCreator_NewPointDlg::updateTitle() -{ - QString aTitle; - if( !myIsEdit ){ - if( mySectionName.isEmpty() ){ - aTitle = tr("ADD_NEW_POINT"); - } - else{ - aTitle = QString(tr("ADD_NEW_POINT_TO_%1")).arg(mySectionName); - } - } - else{ - aTitle = tr("SET_POINT_COORDINATES"); - } - setWindowTitle(aTitle); -} - -CurveCreator::Coordinates CurveCreator_NewPointDlg::getCoordinates() const -{ - CurveCreator::Coordinates aCoords; - double anX = myX->value(); - aCoords.push_back(anX); - double anY = myY->value(); - aCoords.push_back(anY); - if( myDim == CurveCreator::Dim3d ){ - double aZ = myZ->value(); - aCoords.push_back(aZ); - } - return aCoords; -} - -void CurveCreator_NewPointDlg::clear() -{ - initSpinBox(myX); - initSpinBox(myY); - initSpinBox(myZ); -} - -void CurveCreator_NewPointDlg::setDimension(CurveCreator::Dimension theDim) -{ - if( theDim == CurveCreator::Dim2d ){ - myZ->hide(); - myZLabel->hide(); - } - else{ - myZ->show(); - myZLabel->show(); - } -} - -void CurveCreator_NewPointDlg::setCoordinates( const CurveCreator::Coordinates& theCoords ) -{ - double anX = theCoords[0]; - myX->setValue(anX); - double anY = theCoords[1]; - myY->setValue(anY); - if( theCoords.size() == 3 ){ - double aZ = theCoords[2]; - myZ->setValue(aZ); - } - if( isInstantSketchingEnabled() ) - emit addPoint(); -} - -bool CurveCreator_NewPointDlg::isInstantSketchingEnabled() const -{ - return myIsInstantSketchingEnabled; -} - -void CurveCreator_NewPointDlg::setInstantSketchingEnabled( const bool theState ) -{ - myIsInstantSketchingEnabled = theState; -} - -//======================================================================= -// function: initSpinBox -// purpose: -//======================================================================= -void CurveCreator_NewPointDlg::initSpinBox(QDoubleSpinBox *theSpinBox) -{ - const double aCoordMin = -1.e+15; - const double aCoordMax = 1.e+15; - const double aStep = 10; - const int aPrecision = 6; - - theSpinBox->setDecimals( qAbs( aPrecision ) ); - theSpinBox->setRange(aCoordMin, aCoordMax); - theSpinBox->setSingleStep(aStep); - theSpinBox->setValue(0.0); -} diff --git a/src/CurveCreator/CurveCreator_NewPointDlg.h b/src/CurveCreator/CurveCreator_NewPointDlg.h deleted file mode 100755 index a86189e54..000000000 --- a/src/CurveCreator/CurveCreator_NewPointDlg.h +++ /dev/null @@ -1,70 +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 CURVECREATOR_NEWPOINTDLG_H -#define CURVECREATOR_NEWPOINTDLG_H - -#include "CurveCreator.hxx" - -#include - -class QDoubleSpinBox; -class QDialogButtonBox; -class QAbstractButton; -class QPushButton; -class QLabel; -class QFrame; - -class CurveCreator_NewPointDlg : public QWidget -{ - Q_OBJECT -public: - explicit CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent = 0); - CurveCreator::Coordinates getCoordinates() const; - void clear(); - void setSectionName( const QString& theName ); - void setEditMode( bool isEdit ); - void setCoordinates( const CurveCreator::Coordinates& theCoords ); - void setDimension(CurveCreator::Dimension theDim); - bool isInstantSketchingEnabled() const; - void setInstantSketchingEnabled( const bool theState ); -signals: - void addPoint(); - void modifyPoint(); - void cancelPoint(); -public slots: -protected slots: -protected: - void updateTitle(); - void initSpinBox(QDoubleSpinBox *theSpinBox); -private: - QFrame* myBtnFrame; - CurveCreator::Dimension myDim; - QDoubleSpinBox* myX; - QDoubleSpinBox* myY; - QDoubleSpinBox* myZ; - QLabel* myZLabel; - QPushButton* myAddBtn; - QPushButton* myCancelBtn; - bool myIsEdit; - QString mySectionName; - bool myIsInstantSketchingEnabled; -}; - -#endif // CURVECREATOR_NEWPOINTDLG_H diff --git a/src/CurveCreator/CurveCreator_NewSectionDlg.cxx b/src/CurveCreator/CurveCreator_NewSectionDlg.cxx old mode 100755 new mode 100644 index 275a94625..f5f602a3c --- a/src/CurveCreator/CurveCreator_NewSectionDlg.cxx +++ b/src/CurveCreator/CurveCreator_NewSectionDlg.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,7 +18,7 @@ // #include "CurveCreator_NewSectionDlg.h" -#include "CurveCreator_Curve.hxx" +//#include "CurveCreator_Curve.hxx" #include #include @@ -31,21 +31,27 @@ #include #include -CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) : - QWidget(parent) +CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent, bool enableClosed ) : + QWidget(parent), myIsEnableClosed( enableClosed ) { + QVBoxLayout* aMainLayout = new QVBoxLayout( this ); + aMainLayout->setMargin( 0 ); + QFrame* aFrame = new QFrame( this ); + aMainLayout->addWidget( aFrame ); + QVBoxLayout* aLayout = new QVBoxLayout( aFrame ); + aLayout->setMargin( 0 ); QFrame* aCoordFrame = new QFrame( aFrame ); QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame ); - QLabel* aLbl = new QLabel(tr("NAME"), this); + QLabel* aLbl = new QLabel(tr("SECTION_NAME"), this); myName = new QLineEdit(this); aCoordLayout->addWidget(aLbl, 0, 0); aCoordLayout->addWidget(myName, 0 , 1); - aLbl = new QLabel(tr("LINE_TYPE")); + aLbl = new QLabel(tr("SECTION_LINE_TYPE")); myLineType = new QComboBox(this); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); @@ -54,22 +60,26 @@ CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) : // QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE")); // QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE")); - myLineType->addItem(aPolylinePixmap, tr("POLYLINE_TYPE")); - myLineType->addItem(aSplinePixmap, tr("SPLINE_TYPE")); + myLineType->addItem(aPolylinePixmap, tr("SECTION_POLYLINE_TYPE")); + myLineType->addItem(aSplinePixmap, tr("SECTION_SPLINE_TYPE")); myLineType->setCurrentIndex(0); aCoordLayout->addWidget(aLbl, 1, 0); aCoordLayout->addWidget(myLineType, 1 , 1); - aLbl = new QLabel(tr("LINE_CLOSED")); + aLbl = new QLabel(tr("SECTION_LINE_CLOSED")); myIsClosed = new QCheckBox(this); aCoordLayout->addWidget(aLbl, 2, 0); aCoordLayout->addWidget(myIsClosed, 2, 1); + if ( !myIsEnableClosed ) { + aLbl->hide(); + myIsClosed->hide(); + } myBtnFrame = new QFrame( aFrame ); QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame ); - myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame ); - myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame ); + myAddBtn = new QPushButton( tr( "SECTION_ADD_BTN" ), myBtnFrame ); + myCancelBtn = new QPushButton( tr( "SECTION_CANCEL_BTN" ), myBtnFrame ); connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) ); connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelSection() ) ); @@ -82,7 +92,7 @@ CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) : aLayout->addWidget( myBtnFrame, 1 ); } -void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType ) +void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::SectionType theType ) { myName->setText(theName); myIsClosed->setChecked(isClosed); @@ -103,12 +113,12 @@ void CurveCreator_NewSectionDlg::setEditMode( bool isEdit ) { myIsEdit = isEdit; if( myIsEdit ){ - myAddBtn->setText(tr("OK")); + myAddBtn->setText(tr("SECTION_OK_BTN")); myAddBtn->disconnect( SIGNAL( clicked() ) ); connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifySection() ) ); } else{ - myAddBtn->setText(tr("ADD_BTN")); + myAddBtn->setText(tr("SECTION_ADD_BTN")); myAddBtn->disconnect( SIGNAL( clicked() ) ); connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) ); } @@ -125,12 +135,12 @@ bool CurveCreator_NewSectionDlg::isClosed() const return myIsClosed->isChecked(); } -CurveCreator::Type CurveCreator_NewSectionDlg::getSectionType() const +CurveCreator::SectionType CurveCreator_NewSectionDlg::getSectionType() const { if( myLineType->currentIndex() == 0 ) return CurveCreator::Polyline; else - return CurveCreator::BSpline; + return CurveCreator::Spline; } void CurveCreator_NewSectionDlg::updateTitle() diff --git a/src/CurveCreator/CurveCreator_NewSectionDlg.h b/src/CurveCreator/CurveCreator_NewSectionDlg.h old mode 100755 new mode 100644 index 7f028f20e..d37ed1176 --- a/src/CurveCreator/CurveCreator_NewSectionDlg.h +++ b/src/CurveCreator/CurveCreator_NewSectionDlg.h @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,10 +21,11 @@ #define CURVECREATOR_NEWSECTION_H #include "CurveCreator.hxx" +#include "CurveCreator_ICurve.hxx" #include -class CurveCreator_Curve; +//class CurveCreator_Curve; class QLineEdit; class QComboBox; @@ -38,16 +39,17 @@ class CurveCreator_NewSectionDlg : public QWidget { Q_OBJECT public: - explicit CurveCreator_NewSectionDlg(QWidget *parent = 0); + explicit CurveCreator_NewSectionDlg(QWidget *parent = 0, bool enableClosed = true ); QString getName() const; bool isClosed() const; - CurveCreator::Type getSectionType() const; + CurveCreator::SectionType getSectionType() const; - void setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType ); + void setSectionParameters( const QString& theName, bool isClosed, CurveCreator::SectionType theType ); void setSectionName(const QString& theName ); void clear(); void setEditMode( bool isEdit ); + bool isEnableClosed() const { return myIsEnableClosed; } signals: void addSection(); @@ -63,6 +65,7 @@ private: QComboBox* myLineType; QCheckBox* myIsClosed; bool myIsEdit; + bool myIsEnableClosed; QPushButton* myAddBtn; QPushButton* myCancelBtn; }; diff --git a/src/CurveCreator/CurveCreator_Operation.cxx b/src/CurveCreator/CurveCreator_Operation.cxx index 2e4b6416a..173e1c881 100644 --- a/src/CurveCreator/CurveCreator_Operation.cxx +++ b/src/CurveCreator/CurveCreator_Operation.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,6 +22,7 @@ #include "CurveCreator_Operation.hxx" #include "CurveCreator_Curve.hxx" +#include "CurveCreator.hxx" #include #include @@ -46,6 +47,11 @@ CurveCreator_Operation::~CurveCreator_Operation() clear(); } +bool compId(CurveCreator_PosPoint* p1, CurveCreator_PosPoint* p2) +{ + return p1->myID < p2->myID; +} + //======================================================================= // function: Constructor // purpose: @@ -54,8 +60,7 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType) { bool isOK = false; - if (theType == CurveCreator_Operation::Clear || - theType == CurveCreator_Operation::Join) { + if (theType == CurveCreator_Operation::Clear) { clear(); myType = theType; isOK = true; @@ -113,23 +118,28 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType, // function: Constructor // purpose: //======================================================================= -bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType, - const int theIntParam1, - const int theIntParam2, - const int theIntParam3) +bool CurveCreator_Operation::init(const Type theType, const std::list theParamList) { bool isOK = false; - if (theType == CurveCreator_Operation::RemovePoints) { - int *pData = (int *)allocate(3*sizeof(int)); + if (theType == CurveCreator_Operation::Join) + { + const int aNbPoints = theParamList.size(); + + const size_t aSize = + sizeof(aNbPoints) + + aNbPoints * (sizeof(int)); + + int *pIntData = (int *)allocate(aSize); + + *pIntData++ = aNbPoints; + std::list::const_iterator anIt = theParamList.begin(), aLast = theParamList.end(); + for ( ; anIt != aLast; anIt++ ) + *pIntData++ = *anIt; - pData[0] = theIntParam1; - pData[1] = theIntParam2; - pData[2] = theIntParam3; myType = theType; - isOK = true; + isOK = true; } - return isOK; } @@ -166,43 +176,6 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType, return isOK; } -//======================================================================= -// function: Constructor -// purpose: -//======================================================================= -bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType, - const CurveCreator::Coordinates &theCoords, - const int theIntParam1, - const int theIntParam2) -{ - bool isOK = false; - - if (theType == CurveCreator_Operation::AddSection || - theType == CurveCreator_Operation::InsertPoints || - theType == CurveCreator_Operation::SetCoordinates) { - const int aNbCoords = theCoords.size(); - const size_t aSize = - 3*sizeof(theIntParam1) + aNbCoords*sizeof(CurveCreator::TypeCoord); - int *pIntData = (int *)allocate(aSize); - - *pIntData++ = theIntParam1; - *pIntData++ = theIntParam2; - *pIntData++ = aNbCoords; - - CurveCreator::TypeCoord *pRealData = (CurveCreator::TypeCoord *)pIntData; - int i = 0; - - for (; i < aNbCoords; i++) { - *pRealData++ = theCoords[i]; - } - - myType = theType; - isOK = true; - } - - return isOK; -} - //======================================================================= // function: Constructor // purpose: @@ -234,7 +207,7 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType, pIntData = (int*)aStrPtr; *pIntData++ = aNbCoords; - CurveCreator::TypeCoord *pRealData = (CurveCreator::TypeCoord *)aStrPtr; + CurveCreator::TypeCoord *pRealData = (CurveCreator::TypeCoord *)pIntData; int i = 0; for (; i < aNbCoords; i++) { @@ -269,6 +242,84 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType, return false; } +bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType, + const CurveCreator_ICurve::SectionToPointCoordsList &theParamList1) +{ + bool isOK = false; + + if (theType == CurveCreator_Operation::InsertPoints || + theType == CurveCreator_Operation::SetCoordinates ) { + + const int aNbPoints = theParamList1.size(); + + CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = + theParamList1.begin(); + const int aNbCoords = anIt->second.size(); + + const size_t aSize = + sizeof(aNbPoints) + sizeof(aNbCoords) + + aNbPoints * (3*sizeof(int) + aNbCoords*sizeof(CurveCreator::TypeCoord)); + int *pIntData = (int *)allocate(aSize); + + *pIntData++ = aNbPoints; + *pIntData++ = aNbCoords; + int aSectionId, aPointId; + for ( ; anIt != theParamList1.end(); anIt++ ) { + aSectionId = anIt->first.first; + aPointId = anIt->first.second; + + *pIntData++ = aSectionId; + *pIntData++ = aPointId; + *pIntData++ = aNbCoords; + + const CurveCreator::Coordinates &aCoords = anIt->second; + CurveCreator::TypeCoord *pRealData = (CurveCreator::TypeCoord *)pIntData; + for (int i = 0; i < aNbCoords; i++) { + *pRealData++ = aCoords[i]; + } + pIntData = (int *)pRealData; + } + + myType = theType; + isOK = true; + } + + return isOK; +} + +bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType, + const CurveCreator_ICurve::SectionToPointList &theParamList1) +{ + bool isOK = false; + + if (theType == CurveCreator_Operation::RemovePoints) { + const int aNbPoints = theParamList1.size(); + + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = + theParamList1.begin(); + + const size_t aSize = + sizeof(aNbPoints) + + aNbPoints * (2*sizeof(int)); + int *pIntData = (int *)allocate(aSize); + + *pIntData++ = aNbPoints; + int aSectionId, aPointId; + for ( ; anIt != theParamList1.end(); anIt++ ) { + aSectionId = anIt->first; + aPointId = anIt->second; + + *pIntData++ = aSectionId; + *pIntData++ = aPointId; + } + + myType = theType; + isOK = true; + } + + return isOK; +} + //======================================================================= // function: apply // purpose: @@ -280,58 +331,81 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve) switch (myType) { case CurveCreator_Operation::AddPoints: + case CurveCreator_Operation::InsertPoints: + case CurveCreator_Operation::SetCoordinates: { + int aSectionId, aPointId; + CurveCreator::SectionsMap aSectionsMap; + CurveCreator::PosPointsList aPoints; CurveCreator::Coordinates aCoords; - getCoords(&pInt[1], aCoords); - theCurve->addPoints(aCoords, pInt[0]); + int nbPoints = pInt[0]; + int nbCoords = pInt[1]; + int nbParams = 3+nbCoords; + for (int i = 0; i < nbPoints*nbParams; i=i+nbParams) { + aCoords.clear(); + aPoints.clear(); + getCoords(&pInt[4+i], aCoords); + aSectionId = pInt[2+i]; + aPointId = pInt[3+i]; + if ( aSectionsMap.find( aSectionId ) != aSectionsMap.end() ) + aPoints = aSectionsMap[aSectionId]; + CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( aPointId, aCoords ); + aPoints.push_back( aPosPoint ); + aPoints.sort(compId); + aSectionsMap[aSectionId] = aPoints; + } + switch (myType) { + case CurveCreator_Operation::AddPoints: + case CurveCreator_Operation::InsertPoints: + theCurve->addPointsInternal( aSectionsMap ); + break; + case CurveCreator_Operation::SetCoordinates: + theCurve->setPointInternal( aSectionsMap ); + break; + } } break; case CurveCreator_Operation::RemovePoints: - theCurve->removePoints(pInt[0], pInt[1], pInt[2]); - break; - case CurveCreator_Operation::InsertPoints: { - CurveCreator::Coordinates aCoords; - - getCoords(&pInt[2], aCoords); - theCurve->insertPoints(aCoords, pInt[0], pInt[1]); + CurveCreator_ICurve::SectionToPointList aListOfSectionsToPoints; + int nbPoints = pInt[0]; + for (int i = 1; i < nbPoints*2; i=i+2) { + aListOfSectionsToPoints.push_back(std::make_pair(pInt[i], pInt[i+1])); + } + theCurve->removePointsInternal(aListOfSectionsToPoints); } break; case CurveCreator_Operation::SetType: { - const CurveCreator::Type aType = (CurveCreator::Type) pInt[0]; + const CurveCreator::SectionType aType = (CurveCreator::SectionType) pInt[0]; - theCurve->setType(aType, pInt[1]); + theCurve->setSectionTypeInternal( pInt[1], aType ); } break; case CurveCreator_Operation::Clear: - theCurve->clear(); - break; - case CurveCreator_Operation::SetCoordinates: - { - CurveCreator::Coordinates aCoords; - - getCoords(&pInt[2], aCoords); - theCurve->setCoordinates(aCoords, pInt[0], pInt[1]); - } + theCurve->clearInternal(); break; case CurveCreator_Operation::SetClosed: - theCurve->setClosed((pInt[0] != 0), pInt[1]); + theCurve->setClosedInternal(pInt[1], (pInt[0] != 0)); break; case CurveCreator_Operation::MoveSection: - theCurve->moveSection(pInt[0], pInt[1]); + theCurve->moveSectionInternal(pInt[0], pInt[1]); break; case CurveCreator_Operation::Join: - if (myPData == NULL) { - theCurve->join(); - } else { - theCurve->join(pInt[0], pInt[1]); + if (myPData != NULL) + { + std::list aListOfSections; + int nbSections = pInt[0]; + for (int i = 1; i < nbSections+1; i++) { + aListOfSections.push_back(pInt[i]); + } + theCurve->joinInternal(aListOfSections); } break; case CurveCreator_Operation::AddSection: { - const CurveCreator::Type aType = (CurveCreator::Type) pInt[0]; + const CurveCreator::SectionType aType = (CurveCreator::SectionType) pInt[0]; std::string aName = std::string((char*)&pInt[2]); @@ -340,16 +414,16 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve) char* aPtr = ((char*)&pInt[2]); aPtr += (aName.length()) + 1; getCoords((int*)aPtr, aCoords); - theCurve->addSection(aName, aType, (pInt[1] != 0), aCoords); + theCurve->addSectionInternal(aName, aType, (pInt[1] != 0), aCoords); } break; case CurveCreator_Operation::RemoveSection: - theCurve->removeSection(pInt[0]); + theCurve->removeSectionInternal(pInt[0]); break; case CurveCreator_Operation::RenameSection: { std::string aName = std::string((char*)&pInt[1]); - theCurve->setName(aName, pInt[0]); + theCurve->setSectionNameInternal(pInt[0], aName); } break; default: diff --git a/src/CurveCreator/CurveCreator_Operation.hxx b/src/CurveCreator/CurveCreator_Operation.hxx index a74ac19ca..855d0da2a 100644 --- a/src/CurveCreator/CurveCreator_Operation.hxx +++ b/src/CurveCreator/CurveCreator_Operation.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,8 +24,11 @@ #define _CurveCreator_Operation_HeaderFile #include "CurveCreator.hxx" +#include "CurveCreator_ICurve.hxx" +#include "CurveCreator_PosPoint.hxx" #include +#include class CurveCreator_Curve; @@ -74,7 +77,6 @@ public: * It is applicable to the following operations: *
      *
    • Clear
    • - *
    • Join (without arguments)
    • *
    * @return true in case of success; false otherwise. */ @@ -105,15 +107,26 @@ public: const int theIntParam2); /** - * This method initializes the object with an operation with three integer + * This method initializes the object with an operation with two integer * parameters. It is applicable to the following operations: *
      + *
    • Join (with a list of int arguments)
    • + *
    + * @return true in case of success; false otherwise. + */ + bool init(const Type theType, const std::list theParamList); + + /** + * This method initializes the object with an operation with + * list of pairs of integer parameters. + * It is applicable to the following operations: + *
      *
    • RemovePoints
    • *
    * @return true in case of success; false otherwise. */ - bool init(const Type theType, const int theIntParam1, - const int theIntParam2, const int theIntParam3); + bool init(const Type theType, + const CurveCreator_ICurve::SectionToPointList &theParamList1); /** * This method initializes the object with an operation with one @@ -128,18 +141,16 @@ public: const int theIntParam); /** - * This method initializes the object with an operation with one - * CurveCreator::Coordinates parameter and two integer parameters. + * This method initializes the object with an operation with + * list of pairs of integer parameters and CurveCreator::Coordinates parameters. * It is applicable to the following operations: *
      - *
    • AddSection
    • *
    • InsertPoints
    • - *
    • SetCoordinates
    • *
    * @return true in case of success; false otherwise. */ - bool init(const Type theType, const CurveCreator::Coordinates &theCoords, - const int theIntParam1, const int theIntParam2); + bool init(const Type theType, + const CurveCreator_ICurve::SectionToPointCoordsList &theParamList1); /** * This method initializes the object with an operation with one diff --git a/src/CurveCreator/CurveCreator_PosPoint.hxx b/src/CurveCreator/CurveCreator_PosPoint.hxx new file mode 100644 index 000000000..230137423 --- /dev/null +++ b/src/CurveCreator/CurveCreator_PosPoint.hxx @@ -0,0 +1,46 @@ +// Copyright (C) 2013 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. +// +// 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: CurveCreator_PosPoint.hxx +// Author: Alexander KOVALEV + +#ifndef _CurveCreator_PosPoint_HeaderFile +#define _CurveCreator_PosPoint_HeaderFile + +#include "CurveCreator.hxx" + +struct CurveCreator_PosPoint +{ +public: + CurveCreator_PosPoint( int theID, CurveCreator::Coordinates theCoords ) + : myID( theID ), myCoords( theCoords ) + { }; + + ////! Overloaded operator to use sorting. + //bool operator < (CurveCreator_PosPoint const & thePosPoint) const + //{ + // return myID < thePosPoint.myID; + //} + + int myID; // point ID + CurveCreator::Coordinates myCoords; // point coordinates + +}; + +#endif diff --git a/src/CurveCreator/CurveCreator_Section.hxx b/src/CurveCreator/CurveCreator_Section.hxx index 0eafa0629..68b03aaa7 100644 --- a/src/CurveCreator/CurveCreator_Section.hxx +++ b/src/CurveCreator/CurveCreator_Section.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -36,7 +36,7 @@ struct CurveCreator_Section std::string myName; //!< section name CurveCreator::Coordinates myPoints; //!< points coordinates - CurveCreator::Type myType; //!< type of the section + CurveCreator::SectionType myType; //!< type of the section bool myIsClosed; //!< closed or not }; diff --git a/src/CurveCreator/CurveCreator_TableView.cxx b/src/CurveCreator/CurveCreator_TableView.cxx new file mode 100644 index 000000000..b40760511 --- /dev/null +++ b/src/CurveCreator/CurveCreator_TableView.cxx @@ -0,0 +1,178 @@ +// Copyright (C) 2013 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. +// +// 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 "CurveCreator_TableView.h" +#include "CurveCreator_UtilsICurve.hxx" + +#include + +#include +#include + +#include + +const double DBL_MINIMUM = -10000000.; +const double DBL_MAXIMUM = 10000000.; + +const int SECTION_NAME_COLUMN_WIDTH = 75; +const int POINT_INDEX_COLUMN_WIDTH = 40; + +const double LOCAL_SELECTION_TOLERANCE = 0.0001; + +CurveCreator_TableItemDelegate::CurveCreator_TableItemDelegate( QObject* theParent ) +: QItemDelegate( theParent ) +{ +} + +/** + * Creates an editor for the cell + */ +QWidget* CurveCreator_TableItemDelegate::createEditor( QWidget* theParent, + const QStyleOptionViewItem& theOption, + const QModelIndex& theIndex ) const +{ + QWidget* anEditor = 0; + + int aColumnId = theIndex.column(); + if ( aColumnId == 2 || aColumnId == 3 ) { + QDoubleSpinBox* aSpin = new QtxDoubleSpinBox( theParent ); + aSpin->setDecimals( 2 ); + aSpin->setRange( DBL_MINIMUM, DBL_MAXIMUM ); + anEditor = aSpin; + } + else + anEditor = QItemDelegate::createEditor( theParent, theOption, theIndex ); + + return anEditor; +} + +void CurveCreator_TableItemDelegate::setEditorData( QWidget* theEditor, + const QModelIndex& theIndex ) const +{ + int aColumnId = theIndex.column(); + if ( aColumnId == 2 || aColumnId == 3 ) { + QDoubleSpinBox* aDblSpin = dynamic_cast( theEditor ); + if ( aDblSpin ) { + double aValue = theIndex.model()->data( theIndex, Qt::EditRole ).toDouble(); + aDblSpin->setValue( aValue ); + } + } + else + QItemDelegate::setEditorData( theEditor, theIndex ); +} + +void CurveCreator_TableItemDelegate::setModelData( QWidget* theEditor, + QAbstractItemModel* theModel, + const QModelIndex& theIndex ) const +{ + int aColumnId = theIndex.column(); + if ( aColumnId == 2 || aColumnId == 3 ) { + QDoubleSpinBox* aDblSpin = dynamic_cast( theEditor ); + if ( aDblSpin ) { + double aValue = aDblSpin->value(); + theModel->setData( theIndex, aValue, Qt::UserRole); + } + } + else + QItemDelegate::setModelData( theEditor, theModel, theIndex ); +} + +CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve, + QWidget* theParent, + const QStringList& theCoordTitles ) +: QTableWidget( theParent ), myCurve( theCurve ) +{ + setItemDelegate( new CurveCreator_TableItemDelegate( this ) ); + setVisible( false ); + setColumnCount( 4 ); + setColumnWidth( 0, SECTION_NAME_COLUMN_WIDTH ); + setColumnWidth( 1, POINT_INDEX_COLUMN_WIDTH ); + QStringList aLabels; + QString aCoord1 = theCoordTitles.size() > 0 ? theCoordTitles[0] : tr( "TABLE_X" ); // tr( "X_POSITION_LBL" ) + QString aCoord2 = theCoordTitles.size() > 1 ? theCoordTitles[1] : tr( "TABLE_Y" ); // tr( "Y_POSITION_LBL" ) + //aLabels << tr( "SECTION_LABEL" ) << tr( "IDENTIFIER_LABEL" ) << aCoord1 << aCoord2; + aLabels << tr( "TABLE_SECTION" ) << tr("TABLE_INDEX") << aCoord1 << aCoord2; + setHorizontalHeaderLabels( aLabels ); +} + +void CurveCreator_TableView::setCurve( CurveCreator_ICurve* theCurve ) +{ + myCurve = theCurve; +} + +void CurveCreator_TableView::setLocalPointsToTable( + const CurveCreator_ICurve::SectionToPointList& thePoints ) +{ + setRowCount( thePoints.size() ); + + int aRowId = 0; + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(), + aLast = thePoints.end(); + for ( ; anIt != aLast; anIt++ ) { + CurveCreator_ICurve::SectionToPoint aSPoint = *anIt; + int anISection = aSPoint.first; + int anIPoint = aSPoint.second; + + QTableWidgetItem* anItem; + anItem = new QTableWidgetItem( myCurve->getSectionName( anISection ).c_str() ); + anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled ); + anItem->setData( Qt::UserRole, anISection ); + setItem( aRowId, 0, anItem ); + + anItem = new QTableWidgetItem( QString::number( anIPoint + 1 ) ); + anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled ); + anItem->setData( Qt::UserRole, anIPoint ); + setItem( aRowId, 1, anItem ); + + gp_Pnt aPoint; + CurveCreator_UtilsICurve::getPoint( myCurve, anISection, anIPoint, aPoint ); + + anItem = item( aRowId, 2 ); + if ( !anItem ) { + anItem = new QTableWidgetItem(); + setItem( aRowId, 2, anItem ); + } + anItem->setData( Qt::UserRole, aPoint.X() ); + anItem->setData( Qt::DisplayRole, QString::number( aPoint.X(), 'f', 2 ) ); + + anItem = item( aRowId, 3 ); + if ( !anItem ) { + anItem = new QTableWidgetItem(); + setItem( aRowId, 3, anItem ); + } + anItem->setData( Qt::UserRole, aPoint.Y() ); + anItem->setData( Qt::DisplayRole, QString::number( aPoint.Y(), 'f', 2 ) ); + + aRowId++; + } +} + +int CurveCreator_TableView::getSectionId( const int theRowId ) const +{ + return item( theRowId, 0 )->data( Qt::UserRole ).toInt(); +} + +/** + * Returns a point index from the table + * \param theRowId a table row + */ +int CurveCreator_TableView::getPointId( const int theRowId ) const +{ + return item( theRowId, 1 )->data( Qt::UserRole ).toInt(); +} diff --git a/src/CurveCreator/CurveCreator_TableView.h b/src/CurveCreator/CurveCreator_TableView.h new file mode 100644 index 000000000..4565ab5d7 --- /dev/null +++ b/src/CurveCreator/CurveCreator_TableView.h @@ -0,0 +1,69 @@ +// Copyright (C) 2013 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. +// +// 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 CURVECREATOR_TABLEVIEW_H +#define CURVECREATOR_TABLEVIEW_H + +#include "CurveCreator_ICurve.hxx" + +#include +#include + +class CurveCreator_TableItemDelegate : public QItemDelegate +{ +public: + CurveCreator_TableItemDelegate( QObject* theParent ); + ~CurveCreator_TableItemDelegate() {} + + virtual QWidget* createEditor( QWidget* theParent, + const QStyleOptionViewItem& theOption, + const QModelIndex& theIndex ) const; + virtual void setEditorData( QWidget* theEditor, const QModelIndex& theIndex ) const; + virtual void setModelData( QWidget* theEditor, QAbstractItemModel* theModel, + const QModelIndex& theIndex ) const; +}; + +class CurveCreator_TableView : public QTableWidget +{ +public: + CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent = 0, + const QStringList& theCoordTitles = QStringList() ); + ~CurveCreator_TableView() {}; + + void setCurve( CurveCreator_ICurve* theCurve ); + + void setLocalPointsToTable( const CurveCreator_ICurve::SectionToPointList& thePoints ); + + /** + * Returns a section index from the table + * \param theRowId a table row + */ + int getSectionId( const int theRowId ) const; + /** + * Returns a point index from the table + * \param theRowId a table row + */ + int getPointId( const int theRowId ) const; + +private: + CurveCreator_ICurve* myCurve; + +}; + +#endif // CURVECREATOR_TABLEVIEW_H diff --git a/src/CurveCreator/CurveCreator_TreeView.cxx b/src/CurveCreator/CurveCreator_TreeView.cxx old mode 100755 new mode 100644 index 1b7fa9587..36d1dfcfb --- a/src/CurveCreator/CurveCreator_TreeView.cxx +++ b/src/CurveCreator/CurveCreator_TreeView.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,7 +18,7 @@ // #include "CurveCreator_TreeView.h" -#include "CurveCreator_Curve.hxx" +#include "CurveCreator_ICurve.hxx" #include #include @@ -28,7 +28,7 @@ #define ID_SECTION -1 -CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent ) : +CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent ) : QAbstractItemModel(parent), myCurve(theCurve) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); @@ -86,7 +86,7 @@ QVariant CurveCreator_TreeViewModel::data(const QModelIndex & index, int role ) } else if( role == Qt::DecorationRole ){ if( aColumn == 0 ){ - CurveCreator::Type aSectionType = myCurve->getType(aRow); + CurveCreator::SectionType aSectionType = myCurve->getSectionType(aRow); if( aSectionType == CurveCreator::Polyline ){ if( myCurve->isClosed(aRow) ){ return myCachedIcons[ICON_CLOSED_POLYLINE]; @@ -161,12 +161,12 @@ int CurveCreator_TreeViewModel::rowCount(const QModelIndex & parent ) const int aRowCnt = 0; if( myCurve != NULL ){ if( !parent.isValid() ){ - //Points level + //Section level aRowCnt = myCurve->getNbSections(); } else{ - //Section level if( parent.internalId() == ID_SECTION ){ + //Points level aRowCnt = myCurve->getNbPoints(parent.row()); } } @@ -210,14 +210,14 @@ int CurveCreator_TreeViewModel::getPoint( const QModelIndex& theIndx ) const return theIndx.row(); } -void CurveCreator_TreeViewModel::setCurve( CurveCreator_Curve* theCurve ) +void CurveCreator_TreeViewModel::setCurve( CurveCreator_ICurve* theCurve ) { myCurve = theCurve; reset(); } /*****************************************************************************************/ -CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent) : +CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent) : QTreeView(parent) { header()->hide(); @@ -249,7 +249,6 @@ QList CurveCreator_TreeView::getSelectedSections() const aSect << aModel->getSection( anIndxs[i] ); } } - qSort(aSect.begin(), aSect.end()); return aSect; } @@ -290,7 +289,11 @@ void CurveCreator_TreeView::sectionAdded( int theSection ) { CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); if( aModel ){ - rowsInserted(QModelIndex(), theSection, theSection ); + int nbRows = aModel->rowCount(); + int aSection = (theSection == -1 ? (nbRows==0 ? 0 : nbRows-1) : theSection); + rowsInserted(QModelIndex(), aSection, aSection ); + QModelIndex aSectIndx = aModel->sectionIndex(aSection); + selectionModel()->select(aSectIndx, QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect); } } @@ -361,16 +364,6 @@ void CurveCreator_TreeView::sectionsSwapped( int theSection, int theOffset ) } } -void CurveCreator_TreeView::pointsSwapped( int theSection, int thePointNum, int theOffset ) -{ - CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); - if( aModel ){ - QModelIndex aFirstIndex = aModel->pointIndex( theSection, thePointNum ); - QModelIndex aSecondIndex = aModel->pointIndex( theSection, thePointNum + theOffset ); - swapIndexes( aFirstIndex, aSecondIndex ); - } -} - void CurveCreator_TreeView::setSelectedSections( const QList& theList ) { CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); @@ -378,19 +371,7 @@ void CurveCreator_TreeView::setSelectedSections( const QList& theList ) selectionModel()->clearSelection(); for( int i = 0 ; i < theList.size() ; i++ ){ QModelIndex aSectIndx = aModel->sectionIndex(theList[i]); - selectionModel()->select(aSectIndx, QItemSelectionModel::Select ); - } - } -} - -void CurveCreator_TreeView::setSelectedPoints( const QList< QPair >& thePointsList ) -{ - CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); - if( aModel ){ - selectionModel()->clearSelection(); - for( int i = 0 ; i < thePointsList.size() ; i++ ){ - QModelIndex aSectIndx = aModel->pointIndex( thePointsList[i].first, thePointsList[i].second ); - selectionModel()->select(aSectIndx, QItemSelectionModel::Select ); + selectionModel()->select(aSectIndx, QItemSelectionModel::Select | QItemSelectionModel::Rows ); } } } @@ -404,25 +385,6 @@ bool pointLessThan(const QPair &s1, const QPair &s2) return s1.second < s2.second; } -QList< QPair< int, int > > CurveCreator_TreeView::getSelectedPoints() const -{ - QList< QPair< int, int > > aPoints; - CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); - if( !aModel ) - return aPoints; - QModelIndexList anIndxs = selectionModel()->selectedIndexes(); - for( int i = 0 ; i < anIndxs.size() ; i++ ){ - if( !aModel->isSection( anIndxs[i] ) ){ - int aSect = aModel->getSection(anIndxs[i]); - int aPointNum = aModel->getPoint(anIndxs[i]); - QPair< int, int > aPoint = QPair( aSect, aPointNum ); - aPoints.push_back( aPoint ); - } - } - qSort( aPoints.begin(), aPoints.end(), pointLessThan ); - return aPoints; -} - CurveCreator_TreeView::SelectionType CurveCreator_TreeView::getSelectionType() const { CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); @@ -470,16 +432,20 @@ void CurveCreator_TreeView::onActivated( QModelIndex theIndx ) int aSect = aModel->getSection(theIndx); if( aModel->isSection(theIndx) ){ emit sectionEntered( aSect ); - return; } - int aPointNum = aModel->getPoint( theIndx ); - emit pointEntered( aSect, aPointNum ); } -void CurveCreator_TreeView::setCurve( CurveCreator_Curve* theCurve ) +void CurveCreator_TreeView::setCurve( CurveCreator_ICurve* theCurve ) { CurveCreator_TreeViewModel* aModel = dynamic_cast(model()); if( aModel ) aModel->setCurve(theCurve); reset(); } + +void CurveCreator_TreeView::reset() +{ + QList aSelSections = getSelectedSections(); + QTreeView::reset(); + setSelectedSections(aSelSections); +} diff --git a/src/CurveCreator/CurveCreator_TreeView.h b/src/CurveCreator/CurveCreator_TreeView.h old mode 100755 new mode 100644 index 09929bf35..be00a75d3 --- a/src/CurveCreator/CurveCreator_TreeView.h +++ b/src/CurveCreator/CurveCreator_TreeView.h @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -23,12 +23,12 @@ #include #include -class CurveCreator_Curve; +class CurveCreator_ICurve; class CurveCreator_TreeViewModel : public QAbstractItemModel { public: - CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent ); + CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent ); virtual int columnCount(const QModelIndex & parent = QModelIndex()) const; virtual int rowCount(const QModelIndex & parent = QModelIndex()) const; virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; @@ -44,12 +44,12 @@ public: int getSection( const QModelIndex& theIndx ) const; int getPoint( const QModelIndex& theIndx ) const; - void setCurve( CurveCreator_Curve* theCurve ); + void setCurve( CurveCreator_ICurve* theCurve ); private: enum IconType{ ICON_POLYLINE, ICON_SPLINE, ICON_CLOSED_SPLINE, ICON_CLOSED_POLYLINE, ICON_POINT }; private: - CurveCreator_Curve* myCurve; + CurveCreator_ICurve* myCurve; QMap myCachedIcons; }; @@ -59,15 +59,13 @@ class CurveCreator_TreeView : public QTreeView public: enum SelectionType{ ST_NOSEL, ST_POINTS, ST_POINTS_ONE_SECTION, ST_SECTIONS, ST_MIXED }; public: - explicit CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent = 0); + explicit CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent = 0); SelectionType getSelectionType() const; QList getSelectedSections() const; - QList< QPair< int, int > > getSelectedPoints() const; void pointsAdded( int theSection, int thePoint, int thePointsCnt=1 ); void pointDataChanged( int theSection, int thePoint ); void pointsRemoved(int theSection, int thePoint, int thePointsCnt=1 ); - void pointsSwapped( int theSection, int thePointNum, int theOffset ); void sectionAdded( int theSection ); void sectionChanged(int theSection , int aSectCnt = 1); @@ -75,15 +73,15 @@ public: void sectionsSwapped( int theSection, int theOffset ); void setSelectedSections( const QList& theList ); - void setSelectedPoints( const QList< QPair >& thePointsList ); - void setCurve( CurveCreator_Curve* theCurve ); + void setCurve( CurveCreator_ICurve* theCurve ); + + void reset(); signals: void selectionChanged(); void sectionEntered(int); - void pointEntered(int,int); -public slots: + protected slots: void onActivated( QModelIndex theIndx ); protected: diff --git a/src/CurveCreator/CurveCreator_UndoOptsDlg.cxx b/src/CurveCreator/CurveCreator_UndoOptsDlg.cxx deleted file mode 100644 index ec8fd5898..000000000 --- a/src/CurveCreator/CurveCreator_UndoOptsDlg.cxx +++ /dev/null @@ -1,237 +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: CurveCreator_UndoOptsDlg.cxx -// Author: Sergey KHROMOV - -#include "CurveCreator_UndoOptsDlg.h" - -#include -#include -#include -#include -#include -#include -#include - -#define UNDO_DEPTH_UNLIMITED 0 -#define UNDO_DEPTH_DISABLED 1 -#define UNDO_DEPTH_FIX_SIZE 2 - -//======================================================================= -// function: Constructor -// purpose: -//======================================================================= -CurveCreator_UndoOptsDlg::CurveCreator_UndoOptsDlg(QWidget* parent) - : QDialog (parent), - myUndoDepth (UNDO_DEPTH_UNLIMITED), - myOptsBtnGrp (NULL), - myBufferSizeEdit (NULL), - myOkBtn (NULL), - myCancelBtn (NULL) -{ - setWindowTitle(tr("CC_UNDO_OPTIONS_TITLE")); - - // Set Undo/Redo options group - QGroupBox *anUndoOptsGrp = - new QGroupBox(tr("CC_UNDO_OPTIONS_MODIFY")); - QGridLayout *anUndoOptsLO = new QGridLayout(anUndoOptsGrp); - QRadioButton *aDisabledRdBtn = - new QRadioButton(tr("CC_UNDO_OPTIONS_DISABLED"), anUndoOptsGrp); - QRadioButton *aFixSizeRdBtn = - new QRadioButton(tr("CC_UNDO_OPTIONS_FIXED_SIZE"), anUndoOptsGrp); - QRadioButton *anUnlimRdBtn = - new QRadioButton(tr("CC_UNDO_OPTIONS_UNLIMITED"), anUndoOptsGrp); - - myOptsBtnGrp = new QButtonGroup(anUndoOptsGrp); - myBufferSizeEdit = new QLineEdit(anUndoOptsGrp); - anUndoOptsLO->setMargin(9); - anUndoOptsLO->setSpacing(6); - anUndoOptsLO->addWidget(aDisabledRdBtn, 0, 0); - anUndoOptsLO->addWidget(aFixSizeRdBtn, 1, 0); - anUndoOptsLO->addWidget(anUnlimRdBtn, 2, 0); - anUndoOptsLO->addWidget(myBufferSizeEdit, 1, 1); - myOptsBtnGrp->addButton(anUnlimRdBtn, UNDO_DEPTH_UNLIMITED); - myOptsBtnGrp->addButton(aDisabledRdBtn, UNDO_DEPTH_DISABLED); - myOptsBtnGrp->addButton(aFixSizeRdBtn, UNDO_DEPTH_FIX_SIZE); - - // Set OK/Cancel buttons group - QGroupBox *anOkCancelGrp = new QGroupBox; - QGridLayout *anOkCancelLO = new QGridLayout(anOkCancelGrp); - - myOkBtn = new QPushButton(tr("GEOM_BUT_OK"), anOkCancelGrp); - myCancelBtn = new QPushButton(tr("GEOM_BUT_CANCEL"), anOkCancelGrp); - anOkCancelLO->setMargin(9); - anOkCancelLO->setSpacing(6); - anOkCancelLO->addWidget(myOkBtn, 0, 0); - anOkCancelLO->addWidget(myCancelBtn, 0, 1); - - // Set main group - QGroupBox *aMainGrp = new QGroupBox; - QVBoxLayout *aMainLO = new QVBoxLayout(aMainGrp); - - aMainLO->addWidget(anUndoOptsGrp); - aMainLO->addWidget(anOkCancelGrp); - - setLayout(aMainLO); - - init(); -} - -//======================================================================= -// function: Destructor -// purpose: -//======================================================================= -CurveCreator_UndoOptsDlg::~CurveCreator_UndoOptsDlg() -{ -} - -//======================================================================= -// function: setUndoDepth -// purpose: -//======================================================================= -void CurveCreator_UndoOptsDlg::setUndoDepth(const int theDepth) -{ - myUndoDepth = theDepth; - - const int aDepthId = myUndoDepth + 1; - int anId = UNDO_DEPTH_FIX_SIZE; - - if (aDepthId == UNDO_DEPTH_UNLIMITED || - aDepthId == UNDO_DEPTH_DISABLED) { - anId = aDepthId; - } else if (myUndoDepth > 0) { - myBufferSizeEdit->setText(QString::number(myUndoDepth)); - } - - myOptsBtnGrp->button(anId)->setChecked(true); - optionChanged(anId); -} - -//======================================================================= -// function: getUndoDepth -// purpose: -//======================================================================= -int CurveCreator_UndoOptsDlg::getUndoDepth() const -{ - return myUndoDepth; -} - -//======================================================================= -// function: isEnabled -// purpose: -//======================================================================= -bool CurveCreator_UndoOptsDlg::isEnabled() const -{ - return (myUndoDepth + 1 != UNDO_DEPTH_DISABLED); -} - -//======================================================================= -// function: isUnlimited -// purpose: -//======================================================================= -bool CurveCreator_UndoOptsDlg::isUnlimited() const -{ - return (myUndoDepth + 1 == UNDO_DEPTH_UNLIMITED); -} - -//======================================================================= -// function: init -// purpose: -//======================================================================= -void CurveCreator_UndoOptsDlg::init() -{ - // Initialize sections group. - myOptsBtnGrp->setExclusive(true); - myOptsBtnGrp->button(UNDO_DEPTH_UNLIMITED)->setChecked(true); - connect(myOptsBtnGrp, SIGNAL(buttonClicked(int)), - this, SLOT(optionChanged(int))); - - // Initialize line edit. - QIntValidator *aValidator = new QIntValidator(myBufferSizeEdit); - - aValidator->setBottom(1); - myBufferSizeEdit->setValidator(aValidator); - optionChanged(UNDO_DEPTH_UNLIMITED); - - // Init buttons. - myOkBtn->setDefault(true); - - connect(myOkBtn, SIGNAL(clicked()), this, SLOT(accept())); - connect(myCancelBtn, SIGNAL(clicked()), this, SLOT(reject())); - - setTabOrder(); -} - -//======================================================================= -// function: setTabOrder -// purpose: -//======================================================================= -void CurveCreator_UndoOptsDlg::setTabOrder() -{ - QWidget::setTabOrder(myOptsBtnGrp->button(UNDO_DEPTH_DISABLED), - myOptsBtnGrp->button(UNDO_DEPTH_FIX_SIZE)); - QWidget::setTabOrder(myOptsBtnGrp->button(UNDO_DEPTH_FIX_SIZE), - myBufferSizeEdit); - QWidget::setTabOrder(myBufferSizeEdit, - myOptsBtnGrp->button(UNDO_DEPTH_UNLIMITED)); - QWidget::setTabOrder(myOptsBtnGrp->button(UNDO_DEPTH_UNLIMITED), myOkBtn); - QWidget::setTabOrder(myOkBtn, myCancelBtn); -} - -//======================================================================= -// function: optionChanged -// purpose: -//======================================================================= -void CurveCreator_UndoOptsDlg::optionChanged(int theId) -{ - switch (theId) { - case UNDO_DEPTH_FIX_SIZE: - myBufferSizeEdit->setEnabled(true); - break; - case UNDO_DEPTH_UNLIMITED: - case UNDO_DEPTH_DISABLED: - default: - myBufferSizeEdit->setEnabled(false); - break; - } -} - -//======================================================================= -// function: accept -// purpose: -//======================================================================= -void CurveCreator_UndoOptsDlg::accept() -{ - const int anId = myOptsBtnGrp->checkedId(); - - switch (anId) { - case UNDO_DEPTH_FIX_SIZE: - myUndoDepth = myBufferSizeEdit->text().toInt(); - break; - case UNDO_DEPTH_UNLIMITED: - case UNDO_DEPTH_DISABLED: - myUndoDepth = anId - 1; - break; - default: - break; - } - - QDialog::accept(); -} diff --git a/src/CurveCreator/CurveCreator_Utils.cxx b/src/CurveCreator/CurveCreator_Utils.cxx new file mode 100644 index 000000000..146676c95 --- /dev/null +++ b/src/CurveCreator/CurveCreator_Utils.cxx @@ -0,0 +1,994 @@ +// Copyright (C) 2013 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. +// +// 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 "CurveCreator_Utils.hxx" +#include "CurveCreator.hxx" +#include "CurveCreator_Curve.hxx" +#include "CurveCreator_UtilsICurve.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 "CurveCreator_ICurve.hxx" + +const double LOCAL_SELECTION_TOLERANCE = 0.0001; +const int SCENE_PIXEL_PROJECTION_TOLERANCE = 10; +const int SCENE_PIXEL_POINT_TOLERANCE = 5; + +#define PLN_FREE 0 +#define PLN_ORIGIN 1 +#define PLN_OX 2 +#define PLN_FIXED 3 + +/** + * This static function returns the curve of original type from the edge. + * + * \param theEdge the edge + * \return the curve of original type. Can be null handle. + */ +static Handle(Geom_Curve) GetCurve(const TopoDS_Edge &theEdge) +{ + Handle(Geom_Curve) aResult; + + if (theEdge.IsNull()) { + return aResult; + } + + Standard_Real aF; + Standard_Real aL; + + aResult = BRep_Tool::Curve(theEdge, aF, aL); + + if (aResult.IsNull()) { + return aResult; + } + + // Get the curve of original type + Handle(Standard_Type) aType = aResult->DynamicType(); + + while (aType == STANDARD_TYPE(Geom_TrimmedCurve)) { + Handle(Geom_TrimmedCurve) aTrCurve = + Handle(Geom_TrimmedCurve)::DownCast(aResult); + + aResult = aTrCurve->BasisCurve(); + aType = aResult->DynamicType(); + } + + return aResult; +} + +//======================================================================= +// function : ConvertClickToPoint() +// purpose : Returns the point clicked in 3D view +//======================================================================= +void CurveCreator_Utils::ConvertPointToClick( const gp_Pnt& thePoint, + Handle(V3d_View) theView, + int& x, int& y ) +{ + theView->Convert(thePoint.X(), thePoint.Y(), thePoint.Z(), x, y ); +} + + +//======================================================================= +// function : ConvertClickToPoint() +// purpose : Returns the point clicked in 3D view +//======================================================================= +gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView ) +{ + // the 3D point, that is a projection of the pixels to the XYZ view plane + //return GEOMUtils::ConvertClickToPoint( x, y, aView ); + + // we need the projection to the XOY plane + // 1. find a point in the plane of the eye and the normal to the plane + Standard_Real X, Y, Z; + Quantity_Parameter Vx, Vy, Vz; + aView->ConvertWithProj( x, y, X, Y, Z, Vx, Vy, Vz ); + + // 2. build a ray from the point by the normal to the XOY plane and intersect it + // The ray equation is the following : p(x,y,z) = p0(x,y,z) + t*V(x,y,z) + // X,Y,Z - defines p0(x,y,z), Vx,Vy,Vz - defines V(x,y,z) + // p(x,y,z) - is a searched point, t - should to be calculated by the condition of XOY plane + // The system of equations is the following: + // p(x) = p0(x)+t*V(x) + // p(y) = p0(y)+t*V(y) + // p(z) = p0(z)+t*V(z) + // p(z) = 0 + + Standard_Real aXp, aYp, aZp; + //It is not possible to use Precision::Confusion(), because it is e-0.8, but V is sometimes e-6 + Standard_Real aPrec = LOCAL_SELECTION_TOLERANCE; + if ( fabs( Vz ) > aPrec ) { + Standard_Real aT = -Z/Vz; + aXp = X + aT*Vx; + aYp = Y + aT*Vy; + aZp = Z + aT*Vz; + } + else { // Vz = 0 - the eyed plane is orthogonal to Z plane - XOZ, or YOZ + aXp = aYp = aZp = 0; + if ( fabs( Vy ) < aPrec ) // Vy = 0 - the YOZ plane + aYp = Y; + else if ( fabs( Vx ) < aPrec ) // Vx = 0 - the XOZ plane + aXp = X; + } + /*std::cout << "ConvertClickToPoint: " << std::endl + << "XYZ1 = (" << X << ", " << Y << ", " << Z << "); " << std::endl + << "Vxyz = (" << Vx << ", " << Vy << ", " << Vz << "); " << std::endl + << "Resp = (" << aXp << ", " << aYp << ", " << aZp << "); " << std::endl;*/ + + gp_Pnt ResultPoint( aXp, aYp, aZp ); + return ResultPoint; +} + +void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, + TopoDS_Shape& theShape ) +{ + BRep_Builder aBuilder; + TopoDS_Compound aComp; + aBuilder.MakeCompound( aComp ); + for( int iSection = 0 ; iSection < theCurve->getNbSections() ; iSection++ ) + { + int theISection = iSection; + + CurveCreator::SectionType aSectType = theCurve->getSectionType( theISection ); + int aPointSize = theCurve->getNbPoints( theISection ); + if ( aPointSize == 0 ) + continue; + + bool aSectIsClosed = theCurve->isClosed( theISection ); + bool isPolyline = aSectType == CurveCreator::Polyline; + + int iPoint = 0; + gp_Pnt aPrevPoint, aPoint; + // filters the curve points to skip equal points + std::vector aPoints; + CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint ); + aPoints.push_back( aPoint ); + aPrevPoint = aPoint; + iPoint++; + for( ; iPoint < aPointSize; iPoint++ ) { + CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint ); + if ( !isEqualPoints( aPrevPoint, aPoint ) ) + aPoints.push_back( aPoint ); + aPrevPoint = aPoint; + } + int aNbPoints = aPoints.size(); + + if ( aNbPoints == 1 ) { + aPoint = aPoints.front(); + TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex(); + aBuilder.Add( aComp, aVertex ); + } + else if ( aNbPoints > 1 ) { + Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt(1, aNbPoints); + TColgp_Array1OfVec aTangents(1, aNbPoints); + Handle(TColStd_HArray1OfBoolean) aTangentFlags = new TColStd_HArray1OfBoolean(1, aNbPoints); + gp_Vec aNullVec(0, 0, 0); + + TopoDS_Edge aPointEdge; + TopoDS_Vertex aVertex; + + std::vector::const_iterator aPointIt = aPoints.begin(), aPointLast = aPoints.end(); + aPoint = *aPointIt; + + int aHIndex = 1; + aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex(); + aBuilder.Add( aComp, aVertex ); + if ( !isPolyline ) { + aHCurvePoints->SetValue( aHIndex, aPoint ); + aTangents.SetValue( aHIndex, aNullVec ); + aTangentFlags->SetValue( aHIndex, Standard_False ); + aHIndex++; + } + + aPrevPoint = aPoint; + aPointIt++; + for( ; aPointIt != aPointLast; aPointIt++ ) { + aPoint = *aPointIt; + aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex(); + aBuilder.Add( aComp, aVertex ); + if ( isPolyline ) { + TopoDS_Edge aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge(); + aBuilder.Add( aComp, aPointEdge ); + } + else { + aHCurvePoints->SetValue( aHIndex, aPoint ); + aTangents.SetValue( aHIndex, aNullVec ); + aTangentFlags->SetValue( aHIndex, Standard_False ); + aHIndex++; + } + aPrevPoint = aPoint; + } + if( aSectIsClosed && ( aNbPoints > 2 ) ) { + aPoint = aPoints.front(); + aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex(); + aBuilder.Add( aComp, aVertex ); + if ( isPolyline ) { + aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge(); + aBuilder.Add( aComp, aPointEdge ); + } + } + if( !isPolyline ) { + // compute BSpline + Handle(Geom_BSplineCurve) aBSplineCurve; + GeomAPI_Interpolate aGBC(aHCurvePoints, aSectIsClosed, gp::Resolution()); + // correct the spline degree to be as 3 for non-periodic spline if number of points + // less than 3. It is need to have a knot in each spline point. This knots are used + // to found a neighbour points when a new point is inserted between two existing. + if (!aSectIsClosed ) { + if (aHCurvePoints->Length() == 3) + aGBC.Load(aTangents, aTangentFlags); + } + + aGBC.Perform(); + if ( aGBC.IsDone() ) + aBSplineCurve = aGBC.Curve(); + TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSplineCurve ).Edge(); + TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire(); + aBuilder.Add( aComp, aWire ); + } + } + } + theShape = aComp; +} + +/** + * This is an intermediate structure for curve construction. + */ +struct Section3D +{ + Section3D() : myIsClosed(false), myIsBSpline(false) + { } + + bool myIsClosed; + bool myIsBSpline; + Handle(TColgp_HArray1OfPnt) myPoints; +}; + +//======================================================================= +// function : constructCurve +// purpose : +//======================================================================= +bool CurveCreator_Utils::constructCurve + (const TopoDS_Shape theShape, + CurveCreator_Curve *theCurve, + gp_Ax3 &theLocalCS) +{ + if (theShape.IsNull()) { + return false; + } + + // Collect wires or vertices from shape. + TopTools_ListOfShape aWOrV; + TopAbs_ShapeEnum aType = theShape.ShapeType(); + + if (aType == TopAbs_WIRE || aType == TopAbs_VERTEX) { + aWOrV.Append(theShape); + } else if (aType == TopAbs_COMPOUND) { + TopoDS_Iterator aShIter(theShape); + + for (; aShIter.More(); aShIter.Next()) { + const TopoDS_Shape &aSubShape = aShIter.Value(); + + aType = aSubShape.ShapeType(); + + if (aType == TopAbs_WIRE || aType == TopAbs_VERTEX) { + aWOrV.Append(aSubShape); + } else { + // Only subshapes of types wire or vertex are supported. + return false; + } + } + } else { + // Only wire (vertex) or compound of wires (vertices) are supported. + return false; + } + + // Treat each wire or vertex. Get points, compute the working plane. + gp_Pln aPlane; + Standard_Integer aPlaneStatus = PLN_FREE; + TopTools_ListIteratorOfListOfShape anIter(aWOrV); + std::list aListSec; + + for (; anIter.More(); anIter.Next()) { + Section3D aSec3D; + + aSec3D.myPoints = CurveCreator_Utils::getPoints + (anIter.Value(), aSec3D.myIsClosed, aSec3D.myIsBSpline); + + if (aSec3D.myPoints.IsNull()) { + return false; + } + + aListSec.push_back(aSec3D); + + if (aPlaneStatus != PLN_FIXED) { + // Compute plane + CurveCreator_Utils::FindPlane(aSec3D.myPoints, aPlane, aPlaneStatus); + } + } + + // Check if it is possible to change a computed coordinate system by + // XOY, XOZ or YOZ or parallel to them. + gp_Pnt aO(0., 0., 0.); + gp_Dir aNDir(0., 0., 1.); + gp_Dir aXDir(1., 0., 0.); + gp_Ax3 anAxis; + Standard_Real aTolAng = Precision::Confusion(); // Angular() is too small. + + switch (aPlaneStatus) { + case PLN_ORIGIN: + { + // Change the location. + aO.SetZ(aPlane.Location().Z()); + anAxis.SetLocation(aO); + aPlane.SetPosition(anAxis); + } + break; + case PLN_OX: + { + // Fixed origin + OX axis + const gp_Dir &aPlnX = aPlane.Position().XDirection(); + + if (Abs(aPlnX.Z()) <= aTolAng) { + // Make a coordinate system parallel to XOY. + aO.SetZ(aPlane.Location().Z()); + anAxis.SetLocation(aO); + aPlane.SetPosition(anAxis); + } else if (Abs(aPlnX.Y()) <= aTolAng) { + // Make a coordinate system parallel to XOZ. + aO.SetY(aPlane.Location().Y()); + aNDir.SetCoord(0., 1., 0.); + aXDir.SetCoord(0., 0., 1.); + anAxis = gp_Ax3(aO, aNDir, aXDir); + aPlane.SetPosition(anAxis); + } else if (Abs(aPlnX.X()) <= aTolAng) { + // Make a coordinate system parallel to YOZ. + aO.SetX(aPlane.Location().X()); + aNDir.SetCoord(1., 0., 0.); + aXDir.SetCoord(0., 1., 0.); + anAxis = gp_Ax3(aO, aNDir, aXDir); + aPlane.SetPosition(anAxis); + } + } + break; + case PLN_FIXED: + { + const gp_Dir &aPlnN = aPlane.Position().Direction(); + gp_Dir aYDir(0., 1., 0.); + + if (aPlnN.IsParallel(aNDir, aTolAng)) { + // Make a coordinate system parallel to XOY. + aO.SetZ(aPlane.Location().Z()); + anAxis.SetLocation(aO); + aPlane.SetPosition(anAxis); + } else if (aPlnN.IsParallel(aYDir, aTolAng)) { + // Make a coordinate system parallel to XOZ. + aO.SetY(aPlane.Location().Y()); + aNDir.SetCoord(0., 1., 0.); + aXDir.SetCoord(0., 0., 1.); + anAxis = gp_Ax3(aO, aNDir, aXDir); + aPlane.SetPosition(anAxis); + } else if (aPlnN.IsParallel(aXDir, aTolAng)) { + // Make a coordinate system parallel to YOZ. + aO.SetX(aPlane.Location().X()); + aNDir.SetCoord(1., 0., 0.); + aXDir.SetCoord(0., 1., 0.); + anAxis = gp_Ax3(aO, aNDir, aXDir); + aPlane.SetPosition(anAxis); + } + } + break; + case PLN_FREE: + default: + // Use XOY plane. + aPlane.SetPosition(anAxis); + break; + } + + // Compute 2d points. + std::list::const_iterator aSecIt = aListSec.begin(); + Standard_Real aTolConf2 = + Precision::Confusion()*Precision::Confusion(); + Standard_Real aX; + Standard_Real aY; + + for (; aSecIt != aListSec.end(); ++aSecIt) { + Standard_Integer i; + CurveCreator::Coordinates aCoords; + + for (i = aSecIt->myPoints->Lower(); i <= aSecIt->myPoints->Upper(); ++i) { + const gp_Pnt &aPnt = aSecIt->myPoints->Value(i); + + if (aPlane.SquareDistance(aPnt) > aTolConf2) { + // The point doesn't lie on the plane. + return false; + } + + ElSLib::Parameters(aPlane, aPnt, aX, aY); + aCoords.push_back(aX); + aCoords.push_back(aY); + } + + // Add a new section to the curve. + const std::string aSecName = + CurveCreator_UtilsICurve::getUniqSectionName(theCurve); + const CurveCreator::SectionType aSecType = aSecIt->myIsBSpline ? + CurveCreator::Spline : CurveCreator::Polyline; + + theCurve->addSectionInternal(aSecName, aSecType, + aSecIt->myIsClosed, aCoords); + } + + // Set the local coordinate system. + theLocalCS = aPlane.Position(); + + return true; +} + +class CompareSectionToPoint +{ +public: + CompareSectionToPoint( const int theISection = -1, const int theIPoint = -1 ) + : mySectionId( theISection ), myPointId( theIPoint ) {}; + ~CompareSectionToPoint() {} + + bool operator < ( const CompareSectionToPoint& theOther ) const + { + bool isLess = mySectionId < theOther.mySectionId; + if ( !isLess && mySectionId == theOther.mySectionId ) + isLess = myPointId < theOther.myPointId; + return isLess; + } + +private: + int mySectionId; + int myPointId; +}; + + +void CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext, + const CurveCreator_ICurve* theCurve, + CurveCreator_ICurve::SectionToPointList& thePoints ) +{ + thePoints.clear(); + + std::list aSelectedPoints; + gp_Pnt aPnt; + std::map aPointsMap; + + CurveCreator_ICurve::SectionToPointList aPoints; + for ( theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected() ) { + TopoDS_Vertex aVertex; + TopoDS_Shape aShape = theContext->SelectedShape(); + if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) + aVertex = TopoDS::Vertex( theContext->SelectedShape() ); + + if ( aVertex.IsNull() ) + continue; + aPnt = BRep_Tool::Pnt( aVertex ); + + CurveCreator_UtilsICurve::findSectionsToPoints( theCurve, aPnt.X(), aPnt.Y(), aPoints ); + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints.begin(), + aLast = aPoints.end(); + CompareSectionToPoint aPoint; + for ( ; anIt != aLast; anIt++ ) { + aPoint = CompareSectionToPoint( (*anIt).first, (*anIt).second ); + if ( aPointsMap.find( aPoint ) != aPointsMap.end() ) + continue; + aPointsMap[aPoint] = 0; + + thePoints.push_back( *anIt ); + } + } +} + +void CurveCreator_Utils::setSelectedPoints( Handle(AIS_InteractiveContext) theContext, + const CurveCreator_ICurve* theCurve, + const CurveCreator_ICurve::SectionToPointList& thePoints ) +{ + if ( !theCurve ) + return; + + Handle(AIS_InteractiveObject) anAIS = theCurve->getAISObject(); + if ( anAIS.IsNull() ) + return; + Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast( anAIS ); + if ( anAISShape.IsNull() ) + return; + + //ASL: we convert list of point indices to list of points coordinates + int aSize = thePoints.size(); + std::vector aPntsToSelect( aSize ); + + CurveCreator_ICurve::SectionToPointList::const_iterator + aPIt = thePoints.begin(), aPLast = thePoints.end(); + CurveCreator_ICurve::SectionToPoint aSToPoint; + for( int i=0; aPIt != aPLast; aPIt++, i++ ) + { + gp_Pnt aPntToSelect; + CurveCreator_UtilsICurve::getPoint( theCurve, aPIt->first, aPIt->second, aPntToSelect ); + aPntsToSelect[i] = aPntToSelect; + } + + theContext->ClearSelected( Standard_False ); + //ASL: we switch off automatic highlight to improve performance of selection + theContext->SetAutomaticHilight( Standard_False ); + + Handle_SelectMgr_Selection aSelection = anAISShape->Selection( AIS_Shape::SelectionMode( TopAbs_VERTEX ) ); + for( aSelection->Init(); aSelection->More(); aSelection->Next() ) + { + Handle_SelectBasics_SensitiveEntity aSenEntity = aSelection->Sensitive(); + Handle_Select3D_SensitivePoint aSenPnt = Handle_Select3D_SensitivePoint::DownCast( aSenEntity ); + + gp_Pnt anOwnerPnt = aSenPnt->Point(); + Handle_SelectMgr_EntityOwner anOwner = Handle_SelectMgr_EntityOwner::DownCast( aSenPnt->OwnerId() ); + + + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(), + aLast = thePoints.end(); + bool isFound = false; + for( int i=0; iAddOrRemoveSelected( anOwner, Standard_False ); + break; + } + } + } + + //ASL: we switch on again automatic highlight (otherwise selection will not be shown) + // and call HilightPicked to draw selected owners + theContext->SetAutomaticHilight( Standard_True ); + theContext->LocalContext()->HilightPicked( Standard_True ); +} + +//======================================================================= +// function : setLocalPointContext +// purpose : Open/close the viewer local context +//======================================================================= +void CurveCreator_Utils::setLocalPointContext( const CurveCreator_ICurve* theCurve, + Handle(AIS_InteractiveContext) theContext, + const bool theOpen ) +{ + if ( !theContext ) + return; + + if ( theOpen ) { + // Open local context if there is no one + if ( !theContext->HasOpenedContext() ) { + theContext->ClearCurrents( false ); + theContext->OpenLocalContext( false/*use displayed objects*/, true/*allow shape decomposition*/ ); + } + // load the curve AIS object to the local context with the point selection + Handle(AIS_InteractiveObject) anAIS = theCurve->getAISObject(); + if ( !anAIS.IsNull() ) + { + if ( anAIS->IsKind( STANDARD_TYPE( AIS_Shape ) ) ) + { + theContext->Load( anAIS, -1/*selection mode*/, true/*allow decomposition*/ ); + theContext->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) ); + } + } + } + else { + if ( theContext->HasOpenedContext() ) + theContext->CloseAllContexts(); + } +} + +bool CurveCreator_Utils::pointOnObject( Handle(V3d_View) theView, + Handle(AIS_InteractiveObject) theObject, + const int theX, const int theY, + gp_Pnt& thePoint, + gp_Pnt& thePoint1, gp_Pnt& thePoint2 ) +{ + bool isFullFound = false; + + if ( theObject.IsNull() || theView.IsNull() ) + return isFullFound; + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast( theObject ); + if ( aShape.IsNull() ) + return isFullFound; + const TopoDS_Compound& aCompound = TopoDS::Compound( aShape->Shape() ); + if ( aCompound.IsNull() ) + return isFullFound; + + gp_Pnt aCurPoint, aCurPoint1, aCurPoint2; + gp_Pnt aFoundPoint, aFoundPnt1, aFoundPnt2; + Standard_Real aParameter; + bool isFound = false; + int aDelta, aMinDelta = 2*SCENE_PIXEL_PROJECTION_TOLERANCE*SCENE_PIXEL_PROJECTION_TOLERANCE; + TopExp_Explorer anExp( aCompound, TopAbs_EDGE ); + for ( ; anExp.More(); anExp.Next()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge(anExp.Current()); + if ( anEdge.IsNull() ) + continue; + Standard_Real aFirst, aLast; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve( anEdge, aFirst, aLast ); + if ( aCurve->IsKind( STANDARD_TYPE(Geom_BSplineCurve) ) ) { + Handle(Geom_BSplineCurve) aBSplineCurve = + Handle(Geom_BSplineCurve)::DownCast( aCurve ); + if ( !aBSplineCurve.IsNull() ) { + isFound = hasProjectPointOnCurve( theView, theX, theY, aBSplineCurve, + aParameter, aDelta ); + if ( isFound ) { + aCurPoint = aBSplineCurve->Value( aParameter ); + Standard_Integer anI1, anI2; + aBSplineCurve->LocateU( aParameter, LOCAL_SELECTION_TOLERANCE, anI1, anI2 ); + aCurPoint1 = aBSplineCurve->Value( aBSplineCurve->Knot( anI1 ) ); + aCurPoint2 = aBSplineCurve->Value( aBSplineCurve->Knot( anI2 ) ); + } + } + } + else { // a curve built on a polyline edge + Handle(Geom_Line) aGLine = Handle(Geom_Line)::DownCast( aCurve ); + if ( aGLine.IsNull() ) + continue; + isFound = hasProjectPointOnCurve( theView, theX, theY, aGLine, aParameter, + aDelta ); + if ( isFound ) { + aCurPoint = aGLine->Value( aParameter ); + TopoDS_Vertex V1, V2; + TopExp::Vertices( anEdge, V1, V2, Standard_True ); + if ( V1.IsNull() || V2.IsNull() ) + continue; + aCurPoint1 = BRep_Tool::Pnt(V1); + aCurPoint2 = BRep_Tool::Pnt(V2); + + // check that the projected point is on the bounded curve + gp_Vec aVec1( aCurPoint1, aCurPoint ); + gp_Vec aVec2( aCurPoint2, aCurPoint ); + isFound = fabs( aVec1.Angle( aVec2 ) - M_PI ) < LOCAL_SELECTION_TOLERANCE; + } + } + if ( isFound && aMinDelta >= aDelta ) { + aMinDelta = aDelta; + + isFullFound = true; + aFoundPnt1 = aCurPoint1; + aFoundPnt2 = aCurPoint2; + aFoundPoint = aCurPoint; + } + } + if ( isFullFound ) { + int aX, anY, aX1, anY1, aX2, anY2; + int aDelta; + CurveCreator_Utils::ConvertPointToClick( aFoundPoint, theView, aX, anY ); + CurveCreator_Utils::ConvertPointToClick( aFoundPnt1, theView, aX1, anY1 ); + CurveCreator_Utils::ConvertPointToClick( aFoundPnt2, theView, aX2, anY2 ); + + isFullFound = !isEqualPixels( aX, anY, aX1, anY1, SCENE_PIXEL_POINT_TOLERANCE, aDelta ) && + !isEqualPixels( aX, anY, aX2, anY2, SCENE_PIXEL_POINT_TOLERANCE, aDelta ); + if ( isFullFound ) { + thePoint = aFoundPoint; + thePoint1 = aFoundPnt1; + thePoint2 = aFoundPnt2; + } + } + return isFullFound; +} + +bool CurveCreator_Utils::hasProjectPointOnCurve( Handle(V3d_View) theView, + const int theX, const int theY, + const Handle(Geom_Curve)& theCurve, + Standard_Real& theParameter, + int& theDelta ) +{ + bool isFound = false; + if ( theView.IsNull() ) + return isFound; + + gp_Pnt aPoint = CurveCreator_Utils::ConvertClickToPoint( theX, theY, theView ); + + GeomAPI_ProjectPointOnCurve aProj( aPoint, theCurve ); + Standard_Integer aNbPoint = aProj.NbPoints(); + if (aNbPoint > 0) { + for (Standard_Integer j = 1; j <= aNbPoint && !isFound; j++) { + gp_Pnt aNewPoint = aProj.Point( j ); + theParameter = aProj.Parameter( j ); + + int aX, anY; + CurveCreator_Utils::ConvertPointToClick( aNewPoint, theView, aX, anY ); + + isFound = isEqualPixels( aX, anY, theX, theY, SCENE_PIXEL_PROJECTION_TOLERANCE, theDelta ); + } + } + return isFound; +} + +bool CurveCreator_Utils::isEqualPixels( const int theX, const int theY, const int theOtherX, + const int theOtherY, const double theTolerance, int& theDelta ) +{ + int aXDelta = abs( theX - theOtherX ); + int anYDelta = abs( theY - theOtherY ); + + theDelta = aXDelta*aXDelta + anYDelta*anYDelta; + + return aXDelta < theTolerance && anYDelta < theTolerance; +} + +bool CurveCreator_Utils::isEqualPoints( const gp_Pnt& thePoint, const gp_Pnt& theOtherPoint ) +{ + return theOtherPoint.IsEqual( thePoint, LOCAL_SELECTION_TOLERANCE ); +} + +//======================================================================= +// function : getPoints +// purpose : +//======================================================================= +Handle(TColgp_HArray1OfPnt) CurveCreator_Utils::getPoints + (const TopoDS_Shape &theShape, + bool &IsClosed, + bool &IsBSpline) +{ + Handle(TColgp_HArray1OfPnt) aResult; + + IsClosed = false; + IsBSpline = false; + + if (theShape.IsNull()) { + return aResult; + } + + const TopAbs_ShapeEnum aShType = theShape.ShapeType(); + + if (aShType == TopAbs_VERTEX) { + // There is a single point. + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(theShape)); + + aResult = new TColgp_HArray1OfPnt(1, 1, aPnt); + + return aResult; + } else if (aShType != TopAbs_WIRE) { + // The shape is neither a vertex nor a wire. + return aResult; + } + + // Treat wire. + BRepTools_WireExplorer anExp(TopoDS::Wire(theShape)); + + if (!anExp.More()) { + // Empty wires are not allowed. + return aResult; + } + + // Treat the first edge. + TopoDS_Edge anEdge = anExp.Current(); + Handle(Geom_Curve) aCurve = GetCurve(anEdge); + + if (aCurve.IsNull()) { + return aResult; + } + + // Check the curve type. + Handle(Standard_Type) aType = aCurve->DynamicType(); + + if (aType == STANDARD_TYPE(Geom_BSplineCurve)) { + IsBSpline = true; + } else if (aType != STANDARD_TYPE(Geom_Line)) { + // The curve is neither a line or a BSpline. It is not valid. + return aResult; + } + + // Go to the next edge. + TopoDS_Vertex aFirstVtx = anExp.CurrentVertex(); + + anExp.Next(); + + if (IsBSpline) { + // There should be a single BSpline curve in the wire. + if (anExp.More()) { + return aResult; + } + + // Construct a section from poles of BSpline. + Handle(Geom_BSplineCurve) aBSplCurve = + Handle(Geom_BSplineCurve)::DownCast(aCurve); + + // Check if the edge is valid. It should not be based on trimmed curve. + gp_Pnt aCP[2] = { aBSplCurve->StartPoint(), aBSplCurve->EndPoint() }; + TopoDS_Vertex aV[2]; + Standard_Integer i; + + TopExp::Vertices(anEdge, aV[0], aV[1]); + + for (i = 0; i < 2; i++) { + gp_Pnt aPnt = BRep_Tool::Pnt(aV[i]); + Standard_Real aTol = BRep_Tool::Tolerance(aV[i]); + + if (!aPnt.IsEqual(aCP[i], aTol)) { + return aResult; + } + } + + IsClosed = aV[0].IsSame(aV[1]) ? true : false; + + const Standard_Integer aNbPoints = aBSplCurve->NbKnots(); + TColStd_Array1OfReal aKnots(1, aNbPoints); + + aBSplCurve->Knots(aKnots); + aResult = new TColgp_HArray1OfPnt(1, aBSplCurve->NbKnots()); + + for (i = aKnots.Lower(); i <= aKnots.Upper(); ++i) { + aResult->SetValue(i, aBSplCurve->Value(aKnots.Value(i))); + } + } else { + // This is a polyline. + TopTools_ListOfShape aVertices; + Standard_Integer aNbVtx = 1; + + + aVertices.Append(aFirstVtx); + + for (; anExp.More(); anExp.Next(), ++aNbVtx) { + anEdge = anExp.Current(); + aCurve = GetCurve(anEdge); + + if (aCurve.IsNull()) { + return aResult; + } + + aType = aCurve->DynamicType(); + + if (aType != STANDARD_TYPE(Geom_Line)) { + // The curve is not a line. It is not valid. + return aResult; + } + + // Add the current vertex to the list. + aVertices.Append(anExp.CurrentVertex()); + } + + // Check if the section is closed. + TopoDS_Vertex aLastVtx = TopExp::LastVertex(anEdge, Standard_True); + + IsClosed = aFirstVtx.IsSame(aLastVtx) ? true : false; + + // Fill the array of points. + aResult = new TColgp_HArray1OfPnt(1, aNbVtx); + + Standard_Integer i; + TopTools_ListIteratorOfListOfShape aVtxIter(aVertices); + + for (i = 1; aVtxIter.More(); aVtxIter.Next(), ++i) { + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aVtxIter.Value())); + + aResult->SetValue(i, aPnt); + } + } + + return aResult; +} +//======================================================================= +// function : FindPlane +// purpose : +//======================================================================= +void CurveCreator_Utils::FindPlane + (const Handle_TColgp_HArray1OfPnt &thePoints, + gp_Pln &thePlane, + Standard_Integer &thePlnStatus) +{ + if (thePoints.IsNull() || thePlnStatus == PLN_FIXED) { + // The plane can't be defined or is fixed. Nothing to change. + return; + } + + Standard_Integer i; + const Standard_Real aTolConf = Precision::Confusion(); + + for (i = thePoints->Lower(); i <= thePoints->Upper(); ++i) { + const gp_Pnt &aPnt = thePoints->Value(i); + + switch (thePlnStatus) { + case PLN_FREE: + // Fix the origin. + thePlane.SetLocation(aPnt); + thePlnStatus = PLN_ORIGIN; + break; + case PLN_ORIGIN: + { + // Fix origin + OX axis + const gp_Pnt &aPlnLoc = thePlane.Location(); + + if (!aPnt.IsEqual(aPlnLoc, aTolConf)) { + // Set the X axis. + gp_Dir aXDir(aPnt.XYZ().Subtracted(aPlnLoc.XYZ())); + gp_Ax3 aXNorm(aPlnLoc, aXDir); + gp_Ax3 aNewPlnPos(aPlnLoc, aXNorm.XDirection(), aXNorm.Direction()); + + thePlane.SetPosition(aNewPlnPos); + thePlnStatus = PLN_OX; + } + } + break; + case PLN_OX: + { + // Fix OY axis + gp_Lin aXLin(thePlane.XAxis()); + Standard_Real aSqrDist = aXLin.SquareDistance(aPnt); + + if (aSqrDist > aTolConf*aTolConf) { + // Compute main axis. + const gp_Pnt &aPlnLoc = thePlane.Location(); + gp_Dir aDir(aPnt.XYZ().Subtracted(aPlnLoc.XYZ())); + gp_Ax3 aXNorm(aPlnLoc, aXLin.Direction(), aDir); + gp_Ax3 aNewPlnPos(aPlnLoc, aXNorm.YDirection(), + aXNorm.Direction()); + + thePlane.SetPosition(aNewPlnPos); + thePlnStatus = PLN_FIXED; + return; + } + } + break; + default: + return; + } + } +} diff --git a/src/CurveCreator/CurveCreator_Utils.hxx b/src/CurveCreator/CurveCreator_Utils.hxx new file mode 100644 index 000000000..8dddaf2ff --- /dev/null +++ b/src/CurveCreator/CurveCreator_Utils.hxx @@ -0,0 +1,211 @@ +// Copyright (C) 2013 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. +// +// 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 CURVECREATOR_UTILS_H +#define CURVECREATOR_UTILS_H + +#include "CurveCreator_Macro.hxx" +#include "CurveCreator_ICurve.hxx" + +#include +#include // TODO: remove +#include +#include +#include +#include +#include + +#include +#include // TODO: remove + +class CurveCreator_Curve; + + +class CurveCreator_Utils +{ +public: + + /*! + * \brief Returns the point clicked in 3D view. + * + * \param x The X coordinate in the view. + * \param y The Y coordinate in the view. + * \param theView View where the given point takes place. + * \retval gp_Pnt Returns the point clicked in 3D view + */ + CURVECREATOR_EXPORT static void ConvertPointToClick( const gp_Pnt& thePoint, + Handle(V3d_View) theView, + int& x, int& y ); + + /*! + * \brief Returns the point clicked in 3D view. + * + * \param x The X coordinate in the view. + * \param y The Y coordinate in the view. + * \param theView View where the given point takes place. + * \retval gp_Pnt Returns the point clicked in 3D view + */ + CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y, + Handle(V3d_View) theView ); + + /** + * Generates shape on the curve + * \param theCurve a curve object, that contains data + * \param theShape a generated shape + */ + CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve, + TopoDS_Shape& theShape ); + + /** + * Generates a curve from a shape. + * \param theShape a shape to be converted to curve. + * \param theCurve a curve object to be initialized. + * \param theLocalCS the local coordinate system of the curve. + * \return true in case of success; false otherwise. Warning: the curve can + * be modified even if the shape is not valid for curve construction. + */ + CURVECREATOR_EXPORT static bool constructCurve + (const TopoDS_Shape theShape, + CurveCreator_Curve *theCurve, + gp_Ax3 &theLocalCS); + + /** + * Find selected points in the context + * \param theContext the viewer context + * \param theCurve a curve object, that contains data + */ + CURVECREATOR_EXPORT static void getSelectedPoints( Handle(AIS_InteractiveContext) theContext, + const CurveCreator_ICurve* theCurve, + CurveCreator_ICurve::SectionToPointList& thePoints ); + + /** + * Set selected points to the context + * \param theContext the viewer context + * \param theCurve a curve object, that contains data + * \param thePoints the curve point indices to be selected in the context + */ + CURVECREATOR_EXPORT static void setSelectedPoints( + Handle(AIS_InteractiveContext) theContext, + const CurveCreator_ICurve* theCurve, + const CurveCreator_ICurve::SectionToPointList& thePoints = + CurveCreator_ICurve::SectionToPointList() ); + + /*! + * \brief Sets the local point context for the 3D viewer. + * \param theCurve a curve object, that contains data + * \param theContext the viewer context + * \param theOpen The flag to open or close the local context. + */ + CURVECREATOR_EXPORT static void setLocalPointContext( + const CurveCreator_ICurve* theCurve, + Handle(AIS_InteractiveContext) theContext, + const bool theOpen ); + + /** + * Checks whether the point belongs to the OCC object + * \param theObject a line or shape with a bspline inside + * \param theX the X coordinate in the view. + * \param theY the Y coordinate in the view. + * \param thePoint the output point to be append to the model curve + * \param thePoint1 the output point to bound the line where a new point should be inserted + * \param thePoint2 the output point to bound the line where a new point should be inserted + */ + CURVECREATOR_EXPORT static bool pointOnObject( Handle(V3d_View) theView, + Handle(AIS_InteractiveObject) theObject, + const int theX, const int theY, + gp_Pnt& thePoint, gp_Pnt& thePoint1, + gp_Pnt& thePoint2 ); + +protected: + /* + * Returns whether the clicked point belong to the curve or has a very near projection + * \param theX the X coordinate of a point clicked in the OCC viewer + * \param theY the Y coordinate of a point clicked in the OCC viewer + * \param theCurve a geometry curve + * \param theOutPoint a found projected point on the curve + */ + static bool hasProjectPointOnCurve( + Handle(V3d_View) theView, + const int theX, const int theY, + const Handle(Geom_Curve)& theCurve, + Standard_Real& theParameter, + int& theDelta ); + + /* + * Returns whether the X and Y coordinates is in the pixel tolerance + * \param theX the X coordinate of the first point + * \param theY the Y coordinate of the first point + * \param theOtherX the X coordinate of the second point + * \param theOtherY the Y coordinate of the second point + * \param theTolerance the tolerance to compare + * \param theDelta the sum of the a square of X and a square of Y + * \returns whether the points are provide to the pixel tolerance + */ + static bool isEqualPixels( const int theX, const int theY, + const int theOtherX, const int theOtherY, + const double theTolerance, int& theDelta ); + + + /* + * Returns whether the points are the same + * \param thePoint the first point + * \param theOtherPoint the second point + * \returns whether the points are provide to the pixel tolerance + */ + static bool isEqualPoints( const gp_Pnt& thePoint, + const gp_Pnt& theOtherPoint ); + + /** + * Returns the array of points of a shape to construct a curve section. The + * shape can be either a wire or a vertex. For vertex a single point in the + * array is returned. + * + * \param theShape the shape. Can be either a wire or a vertex. + * \param IsClosed closed flag. Output parameter. + * \param IsBSpline BSpline flag. Output parameter. + * \return the array of points. Null handle in case of failure. + */ + static Handle_TColgp_HArray1OfPnt getPoints + (const TopoDS_Shape &theShape, + bool &IsClosed, + bool &IsBSpline); + + /** + * This method computes a plane using the input points. The plane is defined + * by gp_Pln object and the status. The status can have one of the following + * values: + * - 0 plane is not set.
    + * - 1 origin of the plane is fixed. The plane is defined by 1 or several + * coincident points.
    + * - 2 origin + OX axis of the plane is fixed. The plane is defined by 2 + * or more points that lie on a particular line.
    + * - 3 plane is fixed. Plane is defined by 3 not coincident points.
    + * + * \param thePoints the points. + * \param thePlane the current plane on input. It can be modified on output. + * \param thePlnStatus the current status on input. It can be modified on + * output. + */ + static void FindPlane(const Handle_TColgp_HArray1OfPnt &thePoints, + gp_Pln &thePlane, + Standard_Integer &thePlnStatus); + +}; + +#endif // CURVECREATOR_UTILS_H diff --git a/src/CurveCreator/CurveCreator_UtilsICurve.cxx b/src/CurveCreator/CurveCreator_UtilsICurve.cxx new file mode 100644 index 000000000..d11598e25 --- /dev/null +++ b/src/CurveCreator/CurveCreator_UtilsICurve.cxx @@ -0,0 +1,126 @@ +// Copyright (C) 2013 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. +// +// 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 "CurveCreator_UtilsICurve.hxx" + +#include "CurveCreator.hxx" +#include + +const double LOCAL_SELECTION_TOLERANCE = 0.0001; + +int CurveCreator_UtilsICurve::findLocalPointIndex( const CurveCreator_ICurve* theCurve, + int theSectionId, float theX, float theY ) +{ + int aPntIndex = -1; + if ( !theCurve ) + return aPntIndex; + + CurveCreator::Coordinates aCoords; + for ( int i = 0, aNb = theCurve->getNbPoints( theSectionId ); i < aNb && aPntIndex < 0; i++ ) { + aCoords = theCurve->getPoint( theSectionId, i ); + if ( aCoords.size() < 2 ) + continue; + if ( fabs( aCoords[0] - theX ) < LOCAL_SELECTION_TOLERANCE && + fabs( aCoords[1] - theY ) < LOCAL_SELECTION_TOLERANCE ) + aPntIndex = i; + } + + return aPntIndex; +} + +void CurveCreator_UtilsICurve::findSectionsToPoints( const CurveCreator_ICurve* theCurve, + const double theX, const double theY, + CurveCreator_ICurve::SectionToPointList& thePoints ) +{ + thePoints.clear(); + + int aPointId = -1; + for ( int i = 0, aNb = theCurve->getNbSections(); i < aNb; i++ ) { + aPointId = CurveCreator_UtilsICurve::findLocalPointIndex( theCurve, i, theX, theY ); + if ( aPointId < 0 ) + continue; + CurveCreator_ICurve::SectionToPoint aPoint = std::make_pair( i, aPointId ); + if ( !CurveCreator_UtilsICurve::contains( thePoints, aPoint ) ) + thePoints.push_back( aPoint ); + } +} + +void CurveCreator_UtilsICurve::convert( const CurveCreator_ICurve::SectionToPointList& thePoints, + QMap >& theConvPoints ) +{ + theConvPoints.clear(); + + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(), + aLast = thePoints.end(); + QList aPoints; + int aSectionId, aPointId; + for ( ; anIt != aLast; anIt++ ) { + aSectionId = anIt->first; + aPointId = anIt->second; + aPoints.clear(); + if ( theConvPoints.contains( aSectionId ) ) + aPoints = theConvPoints[aSectionId]; + if ( aPoints.contains( aPointId ) ) + continue; + aPoints.append( aPointId ); + theConvPoints[aSectionId] = aPoints; + } +} + +#include "CurveCreator_Curve.hxx" // TODO +void CurveCreator_UtilsICurve::getPoint( const CurveCreator_ICurve* theCurve, const int theISection, + const int theIPoint, gp_Pnt& thePoint ) +{ + double anX, anY, aZ; + // TODO + const CurveCreator_Curve* aCurve = dynamic_cast( theCurve ); + if ( aCurve ) + aCurve->getCoordinates( theISection, theIPoint, anX, anY, aZ ); + thePoint = gp_Pnt( anX, anY, aZ); +} + +std::string CurveCreator_UtilsICurve::getUniqSectionName( CurveCreator_ICurve* theCurve ) +{ + for( int i = 0 ; i < 1000000 ; i++ ){ + char aBuffer[255]; + sprintf( aBuffer, "Section_%d", i+1 ); + std::string aName(aBuffer); + int j; + for( j = 0 ; j < theCurve->getNbSections() ; j++ ){ + if( theCurve->getSectionName(j) == aName ) + break; + } + if( j == theCurve->getNbSections() ) + return aName; + } + return ""; +} + +bool CurveCreator_UtilsICurve::contains( const CurveCreator_ICurve::SectionToPointList& theList, + const CurveCreator_ICurve::SectionToPoint& theValue ) +{ + bool isFound = false; + + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = theList.begin(), + aLast = theList.end(); + for ( ; anIt != aLast && !isFound; anIt++ ) + isFound = anIt->first == theValue.first && anIt->second == theValue.second; + + return isFound; +} diff --git a/src/CurveCreator/CurveCreator_UtilsICurve.hxx b/src/CurveCreator/CurveCreator_UtilsICurve.hxx new file mode 100644 index 000000000..96b4e454b --- /dev/null +++ b/src/CurveCreator/CurveCreator_UtilsICurve.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2013 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. +// +// 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 CURVECREATOR_UTILS_ICURVE_H +#define CURVECREATOR_UTILS_ICURVE_H + +#include "CurveCreator_Macro.hxx" + +#include "CurveCreator_ICurve.hxx" + +#include + +#include +#include + +class CurveCreator_UtilsICurve +{ +public: + + /*! + * Returns a point index in the model curve by the point coordinates in the viewer + * \param theX the X coordinate of the point + * \param theY the Y coordinate of the point + */ + CURVECREATOR_EXPORT static int findLocalPointIndex( const CurveCreator_ICurve* theCurve, + int theSectionId, float theX, float theY ); + + CURVECREATOR_EXPORT static void findSectionsToPoints( const CurveCreator_ICurve* theCurve, + const double theX, const double theY, + CurveCreator_ICurve::SectionToPointList& thePoints ); + CURVECREATOR_EXPORT static void convert( const CurveCreator_ICurve::SectionToPointList& thePoints, + QMap >& theConvPoints ); + + CURVECREATOR_EXPORT static void getPoint( const CurveCreator_ICurve* theCurve, const int theISection, + const int theIPoint, gp_Pnt& thePoint ); + + /*! + * Returns a unique section name + * \param theCurve a curve interface + */ + CURVECREATOR_EXPORT static std::string getUniqSectionName( + CurveCreator_ICurve* theCurve ); + + /** + * Returns whethe the container has the value + * \param theList a container of values + * \param theValue a value + */ + CURVECREATOR_EXPORT static bool contains( const CurveCreator_ICurve::SectionToPointList& theList, + const CurveCreator_ICurve::SectionToPoint& theValue ); +}; + +#endif // CURVECREATOR_UTILS_ICURVE_H diff --git a/src/CurveCreator/CurveCreator_Widget.cxx b/src/CurveCreator/CurveCreator_Widget.cxx index 180284fc1..9cd21e3b7 100644 --- a/src/CurveCreator/CurveCreator_Widget.cxx +++ b/src/CurveCreator/CurveCreator_Widget.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,25 +19,21 @@ #include "CurveCreator_Widget.h" #include "CurveCreator_TreeView.h" -#include "CurveCreator_Curve.hxx" -#include "CurveCreator_CurveEditor.hxx" +#include "CurveCreator_ICurve.hxx" #include "CurveCreator.hxx" -#include "CurveCreator_NewPointDlg.h" #include "CurveCreator_NewSectionDlg.h" - -#include +#include "CurveCreator_Utils.hxx" +#include "CurveCreator_UtilsICurve.hxx" +#include "CurveCreator_TableView.h" #include #include #include #include -#include #include #include - -#include -#include +#include #include #include @@ -50,204 +46,304 @@ #include #include #include +#include +#include + +//#define MEASURE_TIME + +#ifdef MEASURE_TIME + + #define START_MEASURE_TIME \ + QTime aTimer; \ + aTimer.start(); \ + + #define END_MEASURE_TIME( theMsg ) \ + double aTime = aTimer.elapsed() * 0.001; \ + FILE* aFile = fopen( "performance", "a" ); \ + fprintf( aFile, "%s = %.3lf sec\n", theMsg, aTime ); \ + fclose( aFile ); \ + +#else + + #define START_MEASURE_TIME + #define END_MEASURE_TIME( theMsg ) + +#endif + + + + + CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, - CurveCreator_Curve *theCurve, - Qt::WindowFlags fl) : - QWidget(parent), myNewPointEditor(NULL), myNewSectionEditor(NULL), myEdit(NULL), myCurve(theCurve) + CurveCreator_ICurve *theCurve, + const int theActionFlags, + const QStringList& theCoordTitles, + Qt::WindowFlags fl, + int theLocalPointRowLimit ) +: QWidget(parent), myNewSectionEditor(NULL), myCurve(theCurve), mySection(0), + myDragStarted( false ), myDragInteractionStyle( SUIT_ViewModel::STANDARD ), + myOCCViewer( 0 ), myLocalPointRowLimit( theLocalPointRowLimit ), + myOld2DMode(OCCViewer_ViewWindow::No2dMode) { - if( myCurve ) - myEdit = new CurveCreator_CurveEditor( myCurve ); + bool isToEnableClosed = !( theActionFlags & DisableClosedSection ); + myNewSectionEditor = new CurveCreator_NewSectionDlg( this, isToEnableClosed ); + myNewSectionEditor->hide(); + connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()) ); + connect( myNewSectionEditor, SIGNAL(modifySection()), this, SLOT(onModifySection()) ); + connect( myNewSectionEditor, SIGNAL(cancelSection()), this, SLOT(onCancelSection()) ); - CurveCreator::Dimension aDim = CurveCreator::Dim2d; - if( myCurve ) - aDim = myCurve->getDimension(); - myNewPointEditor = new CurveCreator_NewPointDlg( aDim, this ); - myNewPointEditor->hide(); -// connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()) ); - connect( myNewPointEditor, SIGNAL(modifyPoint()), this, SLOT(onModifyPoint()) ); - connect( myNewPointEditor, SIGNAL(cancelPoint()), this, SLOT(onCancelPoint()) ); + QGroupBox* aSectionGroup = new QGroupBox(tr("SECTION_GROUP_TITLE"),this); - myNewSectionEditor = new CurveCreator_NewSectionDlg( this ); - myNewSectionEditor->hide(); - connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()) ); - connect( myNewSectionEditor, SIGNAL(modifySection()), this, SLOT(onModifySection()) ); - connect( myNewSectionEditor, SIGNAL(cancelSection()), this, SLOT(onCancelSection()) ); + mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup); + mySectionView->setSelectionMode( QTreeView::ExtendedSelection ); + connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) ); + connect( mySectionView, SIGNAL(sectionEntered(int)), this, SLOT(onEditSection(int)) ); + connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) ); - QGroupBox* aSectionGroup = new QGroupBox(tr("Sections"),this); + myLocalPointView = new CurveCreator_TableView( myCurve, this, theCoordTitles ); + connect( myLocalPointView, SIGNAL( cellChanged( int, int ) ), + this, SLOT( onCellChanged( int, int ) ) ); - mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup); - connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) ); - connect( mySectionView, SIGNAL(pointEntered(int,int)), this, SLOT(onEditPoint(int,int)) ); - connect( mySectionView, SIGNAL(sectionEntered(int)), this, SLOT(onEditSection(int)) ); - connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) ); - QToolBar* aTB = new QToolBar(tr("TOOL_BAR_TLT"), aSectionGroup); + QToolBar* aTB = new QToolBar(tr("SECTION_GROUP_TITLE"), aSectionGroup); // QToolButton* anUndoBtn = new QToolButton(aTB); - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - QPixmap anUndoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_UNDO"))); - QPixmap aRedoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_REDO"))); - QPixmap aNewSectionPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_SECTION"))); - QPixmap aNewPointPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_POINT"))); - QPixmap anEditPointsPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_EDIT_POINTS"))); - QPixmap aDetectPointsPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_EDIT_POINTS"))); - QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE"))); - QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE"))); - QPixmap aRemovePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_DELETE"))); - QPixmap aJoinPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_JOIN"))); - QPixmap aStepUpPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP"))); - QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN"))); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QPixmap anUndoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_UNDO"))); + QPixmap aRedoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_REDO"))); + QPixmap aNewSectionPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_SECTION"))); + QPixmap aNewPointPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_POINT"))); + QPixmap anEditPointsPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_EDIT_POINTS"))); + QPixmap aDetectPointsPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_EDIT_POINTS"))); + QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE"))); + QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE"))); + QPixmap aRemovePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_DELETE"))); + QPixmap aJoinPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_JOIN"))); + QPixmap aStepUpPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP"))); + QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN"))); -/* QPixmap anUndoPixmap = QPixmap(tr(":images/ICON_UNDO")); - QPixmap aRedoPixmap = QPixmap(tr(":images/ICON_REDO")); - QPixmap aNewSectionPixmap = QPixmap(tr(":images/ICON_NEW_SECTION")); - QPixmap aNewPointPixmap = QPixmap(tr(":images/ICON_NEW_POINT")); - QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE")); - QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE")); - QPixmap aRemovePixmap = QPixmap(tr(":images/ICON_REMOVE")); - QPixmap aJoinPixmap = QPixmap(tr(":images/ICON_JOIN")); - QPixmap aStepUpPixmap = QPixmap(tr(":images/ICON_STEP_UP")); - QPixmap aStepDownPixmap = QPixmap(tr(":images/ICON_STEP_DOWN"));*/ + QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoPixmap, tr("UNDO_TLT"), + QKeySequence(Qt::ControlModifier|Qt::Key_Z) ); + connect(anAct, SIGNAL(triggered()), this, SLOT(onUndo()) ); + aTB->addAction(anAct); - QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoPixmap, tr("UNDO_TLT"), - QKeySequence(Qt::ControlModifier|Qt::Key_Z) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onUndo()) ); - aTB->addAction(anAct); + anAct = createAction( REDO_ID, tr("REDO"), aRedoPixmap, tr("REDO_TLT"), + QKeySequence(Qt::ControlModifier|Qt::Key_Y) ); + connect(anAct, SIGNAL(triggered()), this, SLOT(onRedo()) ); + aTB->addAction(anAct); - anAct = createAction( REDO_ID, tr("REDO"), aRedoPixmap, tr("REDO_TLT"), - QKeySequence(Qt::ControlModifier|Qt::Key_Y) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onRedo()) ); - aTB->addAction(anAct); - - aTB->addSeparator(); - - anAct = createAction( NEW_SECTION_ID, tr("NEW_SECTION"), aNewSectionPixmap, tr("NEW_SECTION_TLT"), - QKeySequence(Qt::ControlModifier|Qt::Key_N) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onNewSection()) ); + aTB->addSeparator(); + + anAct = createAction( NEW_SECTION_ID, tr("NEW_SECTION"), aNewSectionPixmap, tr("NEW_SECTION_TLT"), + QKeySequence(Qt::ControlModifier|Qt::Key_N) ); + connect(anAct, SIGNAL(triggered()), this, SLOT(onNewSection()) ); + if ( !(theActionFlags & DisableNewSection) ) { aTB->addAction(anAct); aTB->addSeparator(); + } - anAct = createAction( INSERT_SECTION_BEFORE_ID, tr("INSERT_SECTION_BEFORE"), QPixmap(), - tr("INSERT_SECTION_BEFORE_TLT"), - QKeySequence(Qt::ControlModifier | Qt::Key_Insert ) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionBefore()) ); + anAct = createAction( ADDITION_MODE_ID, tr("ADDITION_MODE"), aNewPointPixmap, tr("ADDITION_MODE_TLT"), + QKeySequence() ); + anAct->setCheckable(true); + connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onAdditionMode(bool)) ); + connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) ); + aTB->addAction(anAct); + + anAct = createAction( MODIFICATION_MODE_ID, tr("MODIFICATION_MODE"), anEditPointsPixmap, tr("MODIFICATION_MODE_TLT"), + QKeySequence() ); + anAct->setCheckable(true); + connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onModificationMode(bool)) ); + connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) ); + aTB->addAction(anAct); - anAct = createAction( INSERT_SECTION_AFTER_ID, tr("INSERT_SECTION_AFTER"), QPixmap(), - tr("INSERT_SECTION_AFTER_TLT"), - QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Insert ) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionAfter()) ); - - anAct = createAction( ADDITION_MODE_ID, tr("ADDITION_MODE"), aNewPointPixmap, tr("ADDITION_MODE_TLT"), - QKeySequence() ); - anAct->setCheckable(true); - connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onAdditionMode(bool)) ); - connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) ); - aTB->addAction(anAct); - - anAct = createAction( MODIFICATION_MODE_ID, tr("MODIFICATION_MODE"), anEditPointsPixmap, tr("MODIFICATION_MODE_TLT"), - QKeySequence() ); - anAct->setCheckable(true); - connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onModificationMode(bool)) ); - connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) ); + anAct = createAction( DETECTION_MODE_ID, tr("DETECTION_MODE"), aDetectPointsPixmap, tr("DETECTION_MODE_TLT"), + QKeySequence() ); + anAct->setCheckable(true); + connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onDetectionMode(bool)) ); + connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) ); + if ( !(theActionFlags & DisableDetectionMode) ) { aTB->addAction(anAct); + } + + anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), QPixmap(), tr("CLOSE_SECTIONS_TLT"), + QKeySequence(Qt::ControlModifier|Qt::Key_W) ); + connect(anAct, SIGNAL(triggered()), this, SLOT(onCloseSections()) ); - anAct = createAction( DETECTION_MODE_ID, tr("DETECTION_MODE"), aDetectPointsPixmap, tr("DETECTION_MODE_TLT"), - QKeySequence() ); - anAct->setCheckable(true); - connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onDetectPoints(bool)) ); - connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) ); - aTB->addAction(anAct); + anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), QPixmap(), + tr("UNCLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_S) ); + connect(anAct, SIGNAL(triggered()), this, SLOT(onUncloseSections()) ); - anAct = createAction( INSERT_POINT_BEFORE_ID, tr("INSERT_POINT_BEFORE"), QPixmap(), - tr("INSERT_POINT_BEFORE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_B) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointBefore()) ); + anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"), + aPolylinePixmap, tr("SET_SECTIONS_POLYLINE_TLT"), + QKeySequence(Qt::ControlModifier|Qt::Key_E) ); + connect(anAct, SIGNAL(triggered()), this, SLOT(onSetPolyline()) ); - anAct = createAction( INSERT_POINT_AFTER_ID, tr("INSERT_POINT_AFTER"), QPixmap(), - tr("INSERT_POINT_AFTER_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_M) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointAfter()) ); - - anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), QPixmap(), tr("CLOSE_SECTIONS_TLT"), - QKeySequence(Qt::ControlModifier|Qt::Key_W) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onCloseSections()) ); + anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), aSplinePixmap, + tr("SET_SECTIONS_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) ); + connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) ); - anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), QPixmap(), - tr("UNCLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_S) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onUncloseSections()) ); + anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"), + QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) ); + connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) ); + aTB->addAction(anAct); + + aTB->addSeparator(); - anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"), - aPolylinePixmap, tr("SET_POLYLINE_TLT"), - QKeySequence(Qt::ControlModifier|Qt::Key_E) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onSetPolyline()) ); + anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"), + QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) ); + connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) ); + aTB->addAction(anAct); - anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), aSplinePixmap, - tr("SET_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) ); + anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"), + QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) ); + connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) ); - anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"), - QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) ); - connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) ); - aTB->addAction(anAct); - aTB->addSeparator(); + anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"), + QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) ); + connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) ); - anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"), - QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) ); - connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) ); - aTB->addAction(anAct); - aTB->addSeparator(); - - anAct = createAction( UP_ID, tr("STEP_UP"), aStepUpPixmap, tr("STEP_UP_TLT"), - QKeySequence(Qt::ControlModifier|Qt::Key_Up ) ); - connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveUp()) ); - - anAct = createAction( DOWN_ID, tr("STEP_DOWN"), aStepDownPixmap, tr("STEP_DOWN"), - QKeySequence(Qt::ControlModifier|Qt::Key_Down ) ); - connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveDown()) ); - - anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"), - QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) ); - connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) ); - - anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"), - QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) ); - connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) ); - - QVBoxLayout* aSectLayout = new QVBoxLayout(); - aSectLayout->setMargin( 5 ); - aSectLayout->setSpacing( 5 ); - aSectLayout->addWidget(aTB); - aSectLayout->addWidget(mySectionView); - aSectionGroup->setLayout(aSectLayout); - QVBoxLayout* aLay = new QVBoxLayout(); - aLay->setMargin( 0 ); - aLay->setSpacing( 5 ); + QVBoxLayout* aSectLayout = new QVBoxLayout(); + aSectLayout->setMargin( 5 ); + aSectLayout->setSpacing( 5 ); + aSectLayout->addWidget(aTB); + aSectLayout->addWidget(mySectionView); + aSectLayout->addWidget( myLocalPointView ); + aSectionGroup->setLayout(aSectLayout); + QVBoxLayout* aLay = new QVBoxLayout(); + aLay->setMargin( 0 ); + aLay->setSpacing( 5 ); // aLay->addLayout(aNameLayout); - aLay->addWidget(aSectionGroup); - setLayout(aLay); - onSelectionChanged(); + aLay->addWidget(aSectionGroup); + setLayout(aLay); + + updateActionsStates(); + updateUndoRedo(); } -void CurveCreator_Widget::setCurve( CurveCreator_Curve* theCurve ) +/** + * Set an OCC viewer + */ +void CurveCreator_Widget::setOCCViewer( OCCViewer_Viewer* theViewer ) { - if( myEdit != NULL ){ - delete myEdit; - myEdit = NULL; + if ( myOCCViewer == theViewer ) + return; + + if ( myOCCViewer ) { + OCCViewer_ViewManager* aViewManager = dynamic_cast + ( myOCCViewer->getViewManager() ); + disconnect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ), + this, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) ); + disconnect( aViewManager, SIGNAL( mouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ), + this, SLOT( onMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) ); + disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ), + this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) ); + disconnect( aViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), + this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); + // restore normal mode in the viewer + SetViewer2DMode(false); + // all local contexts should be closed if the viewer is not more used + setLocalPointContext( false, true ); } + + myOCCViewer = theViewer; + if ( myOCCViewer ) { + OCCViewer_ViewManager* aViewManager = dynamic_cast + ( myOCCViewer->getViewManager() ); + connect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ), + this, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) ); + connect( aViewManager, SIGNAL( mouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ), + this, SLOT( onMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) ); + connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ), + this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) ); + connect( aViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), + this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); + SetViewer2DMode(true); + } +} + +/** + * Returns current OCC viewer + */ +OCCViewer_Viewer* CurveCreator_Widget::getOCCViewer() +{ + return myOCCViewer; +} + +/** + * Returns OCC viewer context + */ +Handle(AIS_InteractiveContext) CurveCreator_Widget::getAISContext() +{ + Handle(AIS_InteractiveContext) aContext; + OCCViewer_Viewer* aViewer = getOCCViewer(); + if ( aViewer ) + aContext = aViewer->getAISContext(); + + return aContext; +} + +/** + * Returns OCC viewer view port + */ +OCCViewer_ViewPort3d* CurveCreator_Widget::getViewPort() +{ + OCCViewer_ViewPort3d* aViewPort = 0; + OCCViewer_Viewer* aViewer = getOCCViewer(); + if ( aViewer ) + aViewPort = ((OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView())->getViewPort(); + + return aViewPort; +} + +/** + * Set interaction style in the OCC viewer + * \param theStyle a new style + * \return the previous style + */ +int CurveCreator_Widget::changeInteractionStyle( int theStyle ) +{ + OCCViewer_Viewer* aViewer = getOCCViewer(); + if ( !aViewer ) + return -1; + + int aPrevStyle = aViewer->interactionStyle(); + aViewer->setInteractionStyle( theStyle ); + + return aPrevStyle; +} + +//======================================================================= +// function: reset +// purpose: reset the widget viewer, close local context, clear selection +//======================================================================= +void CurveCreator_Widget::reset() +{ +} + +void CurveCreator_Widget::setCurve( CurveCreator_ICurve* theCurve ) +{ myCurve = theCurve; - mySectionView->setCurve(myCurve); - if( myCurve != NULL ){ - myEdit = new CurveCreator_CurveEditor(myCurve); - } - onSelectionChanged(); + mySectionView->setCurve( myCurve ); + myLocalPointView->setCurve( myCurve ); + updateActionsStates(); updateUndoRedo(); } void CurveCreator_Widget::onSelectionChanged() +{ + updateActionsStates(); + updateUndoRedo(); + emit selectionChanged(); +} + +void CurveCreator_Widget::updateActionsStates() { QList anEnabledAct; if( myCurve ){ - anEnabledAct << NEW_SECTION_ID; + anEnabledAct << NEW_SECTION_ID << MODIFICATION_MODE_ID; + if ( removeEnabled() ) + anEnabledAct << REMOVE_ID; QList aSelSections = mySectionView->getSelectedSections(); - QList< QPair< int, int > > aSelPoints = mySectionView->getSelectedPoints(); CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType(); switch( aSelType ){ case CurveCreator_TreeView::ST_NOSEL:{ @@ -258,29 +354,47 @@ void CurveCreator_Widget::onSelectionChanged() anEnabledAct << UP_ID; }*/ if( aSelSections.size() == 1 ){ - anEnabledAct << ADDITION_MODE_ID << MODIFICATION_MODE_ID << DETECTION_MODE_ID; + anEnabledAct << ADDITION_MODE_ID << DETECTION_MODE_ID; } - if (myActionMap[ADDITION_MODE_ID]->isChecked()) { - mySection = -1; - myPointNum = -1; - QList aSelSection = mySectionView->getSelectedSections(); - if( aSelSection.size() > 0 ){ - mySection = aSelSection[0]; - myPointNum = myCurve->getNbPoints(mySection); + switch ( getActionMode() ) { + case AdditionMode: { + mySection = -1; + myPointNum = -1; + QList aSelSection = mySectionView->getSelectedSections(); + if( aSelSection.size() > 0 ){ + mySection = aSelSection[0]; + myPointNum = myCurve->getNbPoints(mySection); + } } - } else if (myActionMap[MODIFICATION_MODE_ID]->isChecked()) { - anEnabledAct << REMOVE_ID; - anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID; - int aSectCnt = myCurve->getNbSections(); - if( aSectCnt > 0 ) - anEnabledAct << CLEAR_ALL_ID; - if( aSectCnt > 1 ) - anEnabledAct << JOIN_ALL_ID; - if( aSelSections.size() > 1 ){ - anEnabledAct << JOIN_ID; + break; + case ModificationMode: { + if ( myNewSectionEditor->isEnableClosed() ) + anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID; + anEnabledAct << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID; + int aSectCnt = myCurve->getNbSections(); + if( aSectCnt > 0 ) + anEnabledAct << CLEAR_ALL_ID; + if( aSectCnt > 1 ) + anEnabledAct << JOIN_ALL_ID; + if( aSelSections.size() > 1 ){ + anEnabledAct << JOIN_ID; + } } - } else if (myActionMap[DETECTION_MODE_ID]->isChecked()) { - } else { //no active mode + break; + case DetectionMode: { + } + break; + case NoneMode: + { + int aSectCnt = myCurve->getNbSections(); + if( aSectCnt > 1 ) + anEnabledAct << JOIN_ALL_ID; + if( aSelSections.size() > 1 ) + anEnabledAct << JOIN_ID; + } + break; + default: + break; } /*if( aSelSections[ aSelSections.size() - 1 ] < ( myCurve->getNbSections() - 1 ) ){ anEnabledAct << DOWN_ID; @@ -326,32 +440,16 @@ void CurveCreator_Widget::onSelectionChanged() } } } - emit selectionChanged(); } void CurveCreator_Widget::onAdditionMode(bool checked) { - if( !myEdit ) + if (!checked) return; - SUIT_ViewWindow* aViewWindow = 0; - SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy(); - if ( activeStudy ) - aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - if ( aViewWindow == 0 ) + Handle(AIS_InteractiveContext) aContext = getAISContext(); + if( !myCurve || aContext.IsNull() ) return; - SUIT_ViewManager* aViewManager = aViewWindow->getViewManager(); - - if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) { - if (checked) { - connect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ), - this, SLOT( onGetPointByClick( SUIT_ViewWindow*, QMouseEvent* ) ) ); - } else { - disconnect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ), - this, SLOT( onGetPointByClick( SUIT_ViewWindow*, QMouseEvent* ) ) ); - return; - } - } mySection= -1; myPointNum = -1; @@ -359,78 +457,40 @@ void CurveCreator_Widget::onAdditionMode(bool checked) if( aSelSection.size() > 0 ){ mySection = aSelSection[0]; } - else{ - QList< QPair > aSelPoints = mySectionView->getSelectedPoints(); - if( aSelPoints.size() > 0 ){ - mySection = aSelPoints[0].first; - myPointNum = aSelPoints[0].second + 1; - } - } -/* - QString aSectName; - if( mySection < 0 ){ - mySection = myCurve->getNbSections() - 1; - } - aSectName = QString::fromStdString( myCurve->getSectionName(mySection)); - if( myPointNum < 0 ){ - myPointNum = myCurve->getNbPoints(mySection); - } - myNewPointEditor->clear(); - myNewPointEditor->setEditMode(false); - myNewPointEditor->setSectionName(aSectName); - myNewPointEditor->setDimension(myCurve->getDimension()); -*/ // emit subOperationStarted( myNewPointEditor ); } void CurveCreator_Widget::onModificationMode(bool checked) { - SUIT_ViewWindow* aViewWindow = 0; - SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy(); - if ( activeStudy ) - aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - if ( aViewWindow == 0 ) - return; - SUIT_ViewManager* aViewManager = aViewWindow->getViewManager(); - if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) { - if (checked) { -// connect( aViewManager, SIGNAL( mouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ), -// this, SLOT( onPointSelect( SUIT_ViewWindow*, QMouseEvent* ) ) ); - connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ), - this, SLOT( onPointDrag( SUIT_ViewWindow*, QMouseEvent* ) ) ); - } - else { -// disconnect( aViewManager, SIGNAL( mouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ), -// this, SLOT( onPointSelect( SUIT_ViewWindow*, QMouseEvent* ) ) ); - disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ), - this, SLOT( onPointDrag( SUIT_ViewWindow*, QMouseEvent* ) ) ); - return; - } - } + myLocalPointView->setVisible( checked ); } -void CurveCreator_Widget::onDetectPoints(bool checked) +void CurveCreator_Widget::onDetectionMode(bool checked) { } void CurveCreator_Widget::onModeChanged(bool checked) { + ActionMode aMode = NoneMode; if (checked) { QAction* anAction = (QAction*)sender(); switch(myActionMap.key(anAction)) { case ADDITION_MODE_ID: + aMode = AdditionMode; if (myActionMap[MODIFICATION_MODE_ID]->isChecked()) myActionMap[MODIFICATION_MODE_ID]->trigger(); else if (myActionMap[DETECTION_MODE_ID]->isChecked()) myActionMap[DETECTION_MODE_ID]->trigger(); break; case MODIFICATION_MODE_ID: + aMode = ModificationMode; if (myActionMap[ADDITION_MODE_ID]->isChecked()) myActionMap[ADDITION_MODE_ID]->trigger(); else if (myActionMap[DETECTION_MODE_ID]->isChecked()) myActionMap[DETECTION_MODE_ID]->trigger(); break; case DETECTION_MODE_ID: + aMode = DetectionMode; if (myActionMap[ADDITION_MODE_ID]->isChecked()) myActionMap[ADDITION_MODE_ID]->trigger(); else if (myActionMap[MODIFICATION_MODE_ID]->isChecked()) @@ -438,54 +498,39 @@ void CurveCreator_Widget::onModeChanged(bool checked) break; } } - onSelectionChanged(); -} - -void CurveCreator_Widget::onAddNewPoint(const CurveCreator::Coordinates& theCoords) -{ - if( !myEdit ) - return; -// CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates(); - myEdit->insertPoints(theCoords, mySection, myPointNum ); - mySectionView->pointsAdded( mySection, myPointNum ); -// myNewPointEditor->clear(); - myPointNum++; - onSelectionChanged(); + updateActionsStates(); updateUndoRedo(); + setLocalPointContext( aMode == ModificationMode, true ); } void CurveCreator_Widget::onNewSection() { - if( !myEdit ) + if( !myCurve ) return; + + stopActionMode(); myNewSectionEditor->clear(); myNewSectionEditor->setEditMode(false); - QString aSectName = QString( myCurve->getUnicSectionName().c_str() ); + QString aSectName = QString( CurveCreator_UtilsICurve::getUniqSectionName( myCurve ).c_str() ); myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline ); - emit subOperationStarted( myNewSectionEditor ); + emit subOperationStarted( myNewSectionEditor, false ); } void CurveCreator_Widget::onAddNewSection() { - if( !myEdit ) + if( !myCurve ) return; - CurveCreator::Coordinates aCoords; - myEdit->addSection( myNewSectionEditor->getName().toStdString(), myNewSectionEditor->getSectionType(), - myNewSectionEditor->isClosed(), aCoords ); - mySectionView->sectionAdded( mySection ); - QString aNewName = QString(myCurve->getUnicSectionName().c_str()); + myCurve->addSection( myNewSectionEditor->getName().toStdString(), + myNewSectionEditor->getSectionType(), + myNewSectionEditor->isClosed() ); + mySectionView->sectionAdded( -1 ); // add a new section to the end of list + QString aNewName = QString( CurveCreator_UtilsICurve::getUniqSectionName( myCurve ).c_str() ); myNewSectionEditor->setSectionName(aNewName); - mySection++; - onSelectionChanged(); + updateActionsStates(); updateUndoRedo(); onCancelSection(); } -void CurveCreator_Widget::onCancelPoint() -{ - emit subOperationFinished( myNewPointEditor ); -} - void CurveCreator_Widget::onCancelSection() { emit subOperationFinished( myNewSectionEditor ); @@ -504,212 +549,161 @@ QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theNa return anAct; } -QAction* CurveCreator_Widget::getAction(ActionId theId) +QAction* CurveCreator_Widget::getAction( ActionId theId ) { if( myActionMap.contains(theId) ) return myActionMap[theId]; return NULL; } +QAction* CurveCreator_Widget::getAction( ActionMode theMode ) +{ + ActionId anActionId = NONE_ID; + switch ( theMode ) { + case AdditionMode: + anActionId = ADDITION_MODE_ID; + break; + case ModificationMode: + anActionId = MODIFICATION_MODE_ID; + break; + case DetectionMode: + anActionId = DETECTION_MODE_ID; + break; + default: + break; + } + QAction* anAction = 0; + if ( anActionId != NONE_ID && myActionMap.contains( anActionId ) ) + anAction = myActionMap[anActionId]; + return anAction; +} + void CurveCreator_Widget::onEditSection( int theSection ) { - if( !myEdit ) + if( !myCurve ) return; + + stopActionMode(); mySection = theSection; QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection)); bool isClosed = myCurve->isClosed(theSection); - CurveCreator::Type aType = myCurve->getType(theSection); + CurveCreator::SectionType aType = myCurve->getSectionType(theSection); myNewSectionEditor->setEditMode(true); myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType ); - emit subOperationStarted( myNewSectionEditor ); + emit subOperationStarted( myNewSectionEditor, true ); } void CurveCreator_Widget::onModifySection() { - if( !myEdit ) + if( !myCurve ) return; QString aName = myNewSectionEditor->getName(); bool isClosed = myNewSectionEditor->isClosed(); - CurveCreator::Type aSectType = myNewSectionEditor->getSectionType(); - myEdit->startOperation(); - myEdit->setClosed( isClosed, mySection ); - myEdit->setName( aName.toStdString(), mySection ); - myEdit->setType( aSectType, mySection ); - myEdit->finishOperation(); + CurveCreator::SectionType aSectType = myNewSectionEditor->getSectionType(); + if( myCurve->getSectionName(mySection) != aName.toStdString() ) + myCurve->setSectionName( mySection , aName.toStdString() ); + + bool isGeomModified = false; + + if( myCurve->getSectionType(mySection) != aSectType ) { + myCurve->setSectionType( mySection, aSectType ); + isGeomModified = true; + } + + if( myCurve->isClosed(mySection) != isClosed ) { + myCurve->setClosed( mySection, isClosed ); + isGeomModified = true; + } mySectionView->sectionChanged(mySection); updateUndoRedo(); onCancelSection(); -} -void CurveCreator_Widget::onEditPoint( int theSection, int thePoint ) -{ - if( !myNewPointEditor || !myEdit ) - return; - mySection = theSection; - myPointNum = thePoint; - QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection)); - myNewPointEditor->setEditMode(true); - myNewPointEditor->setSectionName(aSectName); - myNewPointEditor->setDimension( myCurve->getDimension() ); - CurveCreator::Coordinates aCoords = myCurve->getCoordinates(theSection,thePoint); - myNewPointEditor->setCoordinates(aCoords); - emit subOperationStarted( myNewPointEditor ); -} - -void CurveCreator_Widget::onModifyPoint() -{ - if( !myEdit ) - return; - CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates(); - myEdit->setCoordinates( aCoords, mySection, myPointNum ); - mySectionView->pointDataChanged( mySection, myPointNum ); - updateUndoRedo(); - onCancelPoint(); + emit curveModified(); } void CurveCreator_Widget::onJoin() { - if( !myEdit ) + if( !myCurve ) return; QList aSections = mySectionView->getSelectedSections(); if( aSections.size() == 0 ){ return; } - int aMainSect = aSections[0]; - int aMainSectSize = myCurve->getNbPoints(aMainSect); - myEdit->startOperation(); - for( int i = 1 ; i < aSections.size() ; i++ ){ - int aSectNum = aSections[i] - (i-1); - myEdit->join( aMainSect, aSectNum ); - mySectionView->sectionsRemoved( aSectNum ); + stopActionMode(); + + std::list aSectionsToJoin; + for( int i = 0; i < aSections.size() ; i++ ){ + aSectionsToJoin.push_back( aSections[i] ); } - myEdit->finishOperation(); + //int aMainSect = aSectionsToJoin.front(); + //int aMainSectSize = myCurve->getNbPoints(aMainSect); + if ( myCurve->join( aSectionsToJoin ) ) + { + std::list::const_iterator anIt = aSectionsToJoin.begin(), + aLast = aSectionsToJoin.end(); + // the first section should be skipped. It is not removed, but is modified + anIt++; + for ( ; anIt != aLast; anIt++ ) + mySectionView->sectionsRemoved( *anIt ); + } + + /* The update for the points of the main section int aNewSectSize = myCurve->getNbPoints(aMainSect); if( aNewSectSize != aMainSectSize ) - mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize ); + mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );*/ updateUndoRedo(); + + emit curveModified(); } void CurveCreator_Widget::onRemove() { - if( !myEdit ) + if( !myCurve ) return; - QList< QPair > aSelPoints = mySectionView->getSelectedPoints(); - int aCurrSect=-1; - int aRemoveCnt = 0; - myEdit->startOperation(); - for( int i = 0 ; i < aSelPoints.size() ; i++ ){ - if( aCurrSect != aSelPoints[i].first ){ - aRemoveCnt = 0; - aCurrSect = aSelPoints[i].first; - } - int aPntIndx = aSelPoints[i].second - aRemoveCnt; - myEdit->removePoints(aCurrSect,aPntIndx, 1); - mySectionView->pointsRemoved( aCurrSect, aPntIndx ); - aRemoveCnt++; - } - QList aSections = mySectionView->getSelectedSections(); - for( int i = 0 ; i < aSections.size() ; i++ ){ - int aSectNum = aSections[i] - (i); - myEdit->removeSection( aSectNum ); - mySectionView->sectionsRemoved( aSectNum ); - } - myEdit->finishOperation(); - mySectionView->clearSelection(); - updateUndoRedo(); -} -void CurveCreator_Widget::onMoveUp() -{ - if( !myEdit ) - return; - if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){ - //Move sections - QList aSections = mySectionView->getSelectedSections(); - for( int i = 0 ; i < aSections.size() ; i++ ){ - int anIndx = aSections[i]; - myEdit->moveSection( anIndx, anIndx-1); - mySectionView->sectionsSwapped( anIndx, -1 ); - } + switch( getActionMode() ) { + case NoneMode: + removeSection(); + break; + case ModificationMode: + removePoint(); + break; + default: + break; } - else{ - //Move points - QList< QPair > aPoints = mySectionView->getSelectedPoints(); - for( int i = 0 ; i < aPoints.size() ; i++ ){ - int aSection = aPoints[i].first; - int aPoint = aPoints[i].second; - myEdit->movePoint(aSection, aPoint, aPoint-2); - mySectionView->pointsSwapped( aSection, aPoint, -1 ); - } - } - updateUndoRedo(); -} - -void CurveCreator_Widget::onMoveDown() -{ - if( !myEdit ) - return; - if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){ - //Move sections - QList aSections = mySectionView->getSelectedSections(); - for( int i = aSections.size()-1 ; i >=0 ; i-- ){ - int anIndx = aSections[i]; - myEdit->moveSection( anIndx, anIndx+1); - mySectionView->sectionsSwapped( anIndx, 1 ); - } - } - else{ - //Move points - QList< QPair > aPoints = mySectionView->getSelectedPoints(); - for( int i = aPoints.size() - 1; i >= 0 ; i-- ){ - int aSection = aPoints[i].first; - int aPoint = aPoints[i].second; - myEdit->movePoint(aSection, aPoint, aPoint+1); - mySectionView->pointsSwapped( aSection, aPoint, 1 ); - } - } - updateUndoRedo(); } void CurveCreator_Widget::onClearAll() { - if( !myEdit ) + if( !myCurve ) return; - myEdit->clear(); + stopActionMode(); + myCurve->clear(); mySectionView->reset(); - onSelectionChanged(); + updateActionsStates(); updateUndoRedo(); + + emit curveModified(); } void CurveCreator_Widget::onJoinAll() { - if( !myEdit ) + if( !myCurve ) return; - myEdit->join(); + stopActionMode(); + + std::list aSectionsToJoin; + for( int i = 0, aNb = myCurve->getNbSections(); i < aNb ; i++ ){ + aSectionsToJoin.push_back( i ); + } + bool aRes = myCurve->join( aSectionsToJoin ); + mySectionView->reset(); - onSelectionChanged(); + updateActionsStates(); updateUndoRedo(); -} - -void CurveCreator_Widget::onInsertSectionBefore() -{ - -} - -void CurveCreator_Widget::onInsertSectionAfter() -{ - -} - -void CurveCreator_Widget::onInsertPointBefore() -{ - -} - -void CurveCreator_Widget::onInsertPointAfter() -{ + emit curveModified(); } void CurveCreator_Widget::onUndoSettings() @@ -719,104 +713,119 @@ void CurveCreator_Widget::onUndoSettings() void CurveCreator_Widget::onSetSpline() { - if( !myEdit ) + if( !myCurve ) return; + stopActionMode(); QList aSelSections = mySectionView->getSelectedSections(); - myEdit->startOperation(); for( int i = 0 ; i < aSelSections.size() ; i++ ){ - myEdit->setType(CurveCreator::BSpline, aSelSections[i]); + myCurve->setSectionType(aSelSections[i], CurveCreator::Spline ); mySectionView->sectionChanged(aSelSections[i]); } - myEdit->finishOperation(); updateUndoRedo(); + + emit curveModified(); } void CurveCreator_Widget::onSetPolyline() { - if( !myEdit ) + if( !myCurve ) return; - myEdit->startOperation(); + stopActionMode(); QList aSelSections = mySectionView->getSelectedSections(); for( int i = 0 ; i < aSelSections.size() ; i++ ){ - myEdit->setType(CurveCreator::Polyline, aSelSections[i]); - mySectionView->sectionChanged(aSelSections[i]); + myCurve->setSectionType( aSelSections[i], CurveCreator::Polyline ); + mySectionView->sectionChanged( aSelSections[i] ); } - myEdit->finishOperation(); updateUndoRedo(); + + emit curveModified(); } void CurveCreator_Widget::onCloseSections() { - if( !myEdit ) + if( !myCurve ) return; - myEdit->startOperation(); + stopActionMode(); QList aSelSections = mySectionView->getSelectedSections(); for( int i = 0 ; i < aSelSections.size() ; i++ ){ - myEdit->setClosed(true, aSelSections[i]); + myCurve->setClosed(aSelSections[i], true); mySectionView->sectionChanged(aSelSections[i]); } - myEdit->finishOperation(); updateUndoRedo(); + + emit curveModified(); } void CurveCreator_Widget::onUncloseSections() { - if( !myEdit ) + if( !myCurve ) return; - myEdit->startOperation(); + stopActionMode(); QList aSelSections = mySectionView->getSelectedSections(); for( int i = 0 ; i < aSelSections.size() ; i++ ){ - myEdit->setClosed(false, aSelSections[i]); + myCurve->setClosed(aSelSections[i], false); mySectionView->sectionChanged(aSelSections[i]); } - myEdit->finishOperation(); updateUndoRedo(); + + emit curveModified(); } void CurveCreator_Widget::onUndo() { - if( !myEdit ) - return; - myEdit->undo(); - mySectionView->reset(); - updateUndoRedo(); + if( !myCurve ) + return; + + CurveCreator_ICurve::SectionToPointList aPoints; + startCurveModification( aPoints, false ); + myCurve->undo(); + finishCurveModification(); + mySectionView->reset(); + + emit curveModified(); } void CurveCreator_Widget::onRedo() { - if( !myEdit ) - return; - myEdit->redo(); - mySectionView->reset(); - updateUndoRedo(); + if( !myCurve ) + return; + CurveCreator_ICurve::SectionToPointList aPoints; + startCurveModification( aPoints, false ); + myCurve->redo(); + finishCurveModification(); + mySectionView->reset(); + + emit curveModified(); } void CurveCreator_Widget::updateUndoRedo() { - QAction* anAct = myActionMap[UNDO_ID]; - if( anAct != 0 ){ - if( myEdit->getNbUndo() != 0 ){ - anAct->setEnabled(true); - } - else{ - anAct->setDisabled(true); - } + if( !myCurve ) + return; + QAction* anAct = myActionMap[UNDO_ID]; + if( anAct != 0 ){ + if( myCurve->getNbUndo() != 0 ){ + anAct->setEnabled(true); } - anAct = myActionMap[REDO_ID]; - if( anAct != 0 ){ - if( myEdit->getNbRedo() != 0 ){ - anAct->setEnabled(true); - } - else{ - anAct->setDisabled(true); - } + else{ + anAct->setDisabled(true); } + } + anAct = myActionMap[REDO_ID]; + if( anAct != 0 ){ + if( myCurve->getNbRedo() != 0 ){ + anAct->setEnabled(true); + } + else{ + anAct->setDisabled(true); + } + } } void CurveCreator_Widget::onContextMenu( QPoint thePoint ) { QList aContextActions; - aContextActions << CLEAR_ALL_ID << JOIN_ALL_ID << SEPARATOR_ID << + aContextActions << CLEAR_ALL_ID << JOIN_ID << JOIN_ALL_ID << SEPARATOR_ID << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID; QPoint aGlPoint = mySectionView->mapToGlobal(thePoint); @@ -857,35 +866,111 @@ QList CurveCreator_Widget::getSelectedSections() return mySectionView->getSelectedSections(); } -QList< QPair< int, int > > CurveCreator_Widget::getSelectedPoints() +void CurveCreator_Widget::setSelectedSections( const QList& theSections ) { - return mySectionView->getSelectedPoints(); + mySectionView->setSelectedSections( theSections ); + updateActionsStates(); + updateUndoRedo(); } -bool CurveCreator_Widget::isInstantSketchingEnabled() const +/** + * According to the widget state, performs the remove action + */ +void CurveCreator_Widget::removeSelected() { - if( myNewPointEditor ) - return myNewPointEditor->isInstantSketchingEnabled(); - return false; + onRemove(); } -void CurveCreator_Widget::setInstantSketchingEnabled( const bool theState ) +/** + * Checks whether there are some selection to be removed + */ +bool CurveCreator_Widget::removeEnabled() { - if( myNewPointEditor ) - myNewPointEditor->setInstantSketchingEnabled( theState ); + bool isEnabled = getActionMode() == ModificationMode; + if ( !isEnabled ) { + QList aSelSections = mySectionView->getSelectedSections(); + CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType(); + isEnabled = aSelType == CurveCreator_TreeView::ST_SECTIONS && + aSelSections.size() == 1; + } + return isEnabled; +} + +void CurveCreator_Widget::setActionMode( const ActionMode& theMode ) +{ + ActionMode aPrevMode = getActionMode(); + QAction* aPrevAction = getAction( aPrevMode ); + QAction* anAction = getAction( theMode ); + switch ( theMode ) { + case NoneMode: + case AdditionMode: { + if ( aPrevAction ) { + if ( aPrevAction->isChecked() ) { + aPrevAction->setChecked( false ); + } + } + if ( aPrevMode == ModificationMode ) + onModificationMode( false ); + if ( aPrevMode == AdditionMode ) + onAdditionMode( false ); + + if ( theMode == AdditionMode ) + { + anAction->setChecked( true ); + onModeChanged( true ); + } + } + break; + break; + case ModificationMode: + { + //TODO + } + break; + case DetectionMode: + break; + } +} + +CurveCreator_Widget::ActionMode CurveCreator_Widget::getActionMode() const +{ + ActionMode aMode = NoneMode; + + if ( myActionMap[ADDITION_MODE_ID]->isChecked() ) + aMode = AdditionMode; + else if ( myActionMap[MODIFICATION_MODE_ID]->isChecked() ) + aMode = ModificationMode; + else if ( myActionMap[DETECTION_MODE_ID]->isChecked() ) + aMode = DetectionMode; + + return aMode; +} + +void CurveCreator_Widget::SetViewer2DMode(const bool To2D) +{ + if (myOCCViewer) { + if (To2D) { + myOld2DMode = OCCViewer_Utilities::setViewer2DMode + (myOCCViewer, OCCViewer_ViewWindow::XYPlane); + } else { + OCCViewer_Utilities::setViewer2DMode(myOCCViewer, myOld2DMode); + } + } } //================================================================================= -// function : GeometryGUI::onGetPointByClick() +// function : GeometryGUI::addCoordsByClick() // purpose : Manage mouse press events in Additon mode //================================================================================= -void CurveCreator_Widget::onGetPointByClick( SUIT_ViewWindow* theViewWindow, QMouseEvent* pe ) +void CurveCreator_Widget::addCoordsByClick( QMouseEvent* pe ) { - if ( myNewPointEditor && theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() && - pe->modifiers() != Qt::ControlModifier ) { - OCCViewer_Viewer* anOCCViewer = - ( (OCCViewer_ViewManager*)( theViewWindow->getViewManager() ) )->getOCCViewer(); - Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext(); + if (pe->button() != Qt::LeftButton) + return; + + if ( pe->modifiers() != Qt::ControlModifier ) { + Handle(AIS_InteractiveContext) ic = getAISContext(); + if ( ic.IsNull() ) + return; gp_Pnt aPnt; @@ -895,18 +980,9 @@ void CurveCreator_Widget::onGetPointByClick( SUIT_ViewWindow* theViewWindow, QMo else ic->Select(); // New selection - /*TopoDS_Shape aShape; - - ic->InitSelected(); - if ( ic->MoreSelected() ) - aShape = ic->SelectedShape(); - - if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) - aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) ); - else*/ { - OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort(); - aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() ); + OCCViewer_ViewPort3d* vp = getViewPort(); + aPnt = CurveCreator_Utils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() ); } // set the coordinates into dialog CurveCreator::Coordinates aCoords; @@ -915,28 +991,522 @@ void CurveCreator_Widget::onGetPointByClick( SUIT_ViewWindow* theViewWindow, QMo if ( myCurve->getDimension() == 3 ) { aCoords.push_back( aPnt.Z() ); } - onAddNewPoint(aCoords); -// myNewPointEditor->setCoordinates( aCoords ); + addNewPoint(aCoords); } } -//================================================================================= -// function : GeometryGUI::onPointDrag() -// purpose : Manage mouse move events in Modification mode -//================================================================================= -void CurveCreator_Widget::onPointDrag( SUIT_ViewWindow* theViewWindow, QMouseEvent* pe ) +/** + * Manage mouse press events + * \param theWindow an owner of the signal + * \param theEvent a mouse event + */ +void CurveCreator_Widget::onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent ) { - if ( !(pe->buttons() & Qt::LeftButton) ) + if ( theEvent->button() != Qt::LeftButton ) return; - if ( (pe->pos() - myDragStartPosition).manhattanLength() < QApplication::startDragDistance() ) - return; -/* - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - - mimeData->setData(mimeType, data); - drag->setMimeData(mimeData); - - Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction); - */ + + myPressedX = theEvent->x(); + myPressedY = theEvent->y(); + + switch( getActionMode() ) { + case ModificationMode: { + //store initial cursor position for Drag&Drop + setDragStarted( true, theEvent->pos() ); + break; + } + case AdditionMode: { + addCoordsByClick( theEvent ); + break; + } + default: + break; + } +} + +/** + * Manage mouse release events in Modification mode + * \param theWindow an owner of the signal + * \param theEvent a mouse event + */ +void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent ) +{ + if ( getActionMode() != ModificationMode ) + return; + + if ( myDragStarted ) { + bool isDragged = myDragged; + CurveCreator_ICurve::SectionToPointList aDraggedPoints; + QMap > anInitialDragPointsCoords; + if ( myDragged ) { + aDraggedPoints = myDragPoints; + anInitialDragPointsCoords = myInitialDragPointsCoords; + } + + setDragStarted( false ); + + if ( aDraggedPoints.size() > 0 ) { + // Collect old coordinates of the dragged points + CurveCreator_ICurve::SectionToPointCoordsList anOldPoints; + foreach ( const CurveCreator_ICurve::SectionToPoint aSectionToPoint, anInitialDragPointsCoords.keys() ) { + CurveCreator::Coordinates aCoords = anInitialDragPointsCoords.value( aSectionToPoint ); + anOldPoints.push_back( std::make_pair( aSectionToPoint, aCoords ) ); + } + + if ( myCurve->canPointsBeSorted() ) { + // Add old coordinates of the curve points (except the dragged points) to the list + for( int aSectionId = 0 ; aSectionId < myCurve->getNbSections() ; aSectionId++ ) { + CurveCreator::Coordinates aCoords; + for ( int aPointId = 0, aNb = myCurve->getNbPoints( aSectionId ); aPointId < aNb; aPointId++ ) { + aCoords = myCurve->getPoint( aSectionId, aPointId ); + if ( aCoords.size() < 2 ) { + continue; + } + + CurveCreator_ICurve::SectionToPoint aSectionToPoint = std::make_pair( aSectionId, aPointId ); + + if ( !anInitialDragPointsCoords.contains( aSectionToPoint ) ) { + anOldPoints.push_back( std::make_pair( aSectionToPoint, aCoords ) ); + } + } + } + + // Apply points sorting + CurveCreator_ICurve::SectionToPointList aPoints; + startCurveModification( aPoints, false ); + + myCurve->setSkipSorting( false ); + + CurveCreator_ICurve::SectionToPointCoordsList aCoordList; + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aDraggedPoints.begin(), + aLast = aDraggedPoints.end(); + for ( ; anIt != aLast; anIt++ ) { + int aSectionId = anIt->first; + int aPointId = anIt->second; + std::deque aPos = myCurve->getPoint( aSectionId, aPointId ); + + aCoordList.push_back( + std::make_pair( std::make_pair( aSectionId, aPointId ), aPos ) ); + } + + myCurve->setSeveralPoints( aCoordList, false ); + + finishCurveModification( aDraggedPoints ); + } else { + // if the drag of some points has happened, restore the drag selection + START_MEASURE_TIME; + setSelectedPoints( aDraggedPoints ); + END_MEASURE_TIME( "drop" ); + } + + // Save drag difference + myCurve->saveCoordDiff( anOldPoints ); + } + } + else // check whether the segment is clicked an a new point should be added to the segment + { + int aReleasedX = theEvent->x(); + int aReleasedY = theEvent->y(); + if ( myPressedX == aReleasedX && myPressedY == aReleasedY ) + insertPointToSelectedSegment( aReleasedX, aReleasedY ); + } + + // updates the input panel table to show the selected point coordinates + updateLocalPointView(); + updateUndoRedo(); + + emit curveModified(); +} + +/** + * Manage mouse move events in Modification mode + * \param theWindow an owner of the signal + * \param theEvent a mouse event + */ +void CurveCreator_Widget::onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent ) +{ + if ( getActionMode() != ModificationMode || !myDragStarted ) + return; + + QPoint aPos = theEvent->pos(); + if ( (aPos - myDragStartPosition).manhattanLength() < QApplication::startDragDistance() ) + return; + + START_MEASURE_TIME; + + moveSelectedPoints( aPos.x(), aPos.y() ); + myDragStartPosition = aPos; + + END_MEASURE_TIME( "drag" ); +} + +/** + * Set zero viewer by the last view closed in + * \param theManager a viewer manager + */ +void CurveCreator_Widget::onLastViewClosed( SUIT_ViewManager* theManager ) +{ + myOCCViewer = 0; +} + +void CurveCreator_Widget::onMousePress( QMouseEvent* theEvent ) +{ + onMousePress( 0, theEvent ); +} + +void CurveCreator_Widget::onMouseRelease( QMouseEvent* theEvent ) +{ + onMouseRelease( 0, theEvent ); +} + +void CurveCreator_Widget::onMouseMove( QMouseEvent* theEvent ) +{ + onMouseMove( 0, theEvent ); +} + +void CurveCreator_Widget::onCellChanged( int theRow, int theColumn ) +{ + int aCurrSect = myLocalPointView->getSectionId( theRow ); + int aPntIndex = myLocalPointView->getPointId( theRow ); + + if ( aPntIndex < 0 ) + return; + + CurveCreator_ICurve::SectionToPointList aSelPoints; + startCurveModification( aSelPoints ); + + double aX = myLocalPointView->item( theRow, 2 )->data( Qt::UserRole ).toDouble(); + double anY = myLocalPointView->item( theRow, 3 )->data( Qt::UserRole ).toDouble(); + std::deque aChangedPos; + aChangedPos.push_back( aX ); + aChangedPos.push_back( anY ); + myCurve->setPoint( aCurrSect, aPntIndex, aChangedPos ); + + finishCurveModification( aSelPoints ); + + emit curveModified(); +} + +/** + * Removes a selected section from the curve. Updates undo/redo status + */ +void CurveCreator_Widget::removeSection() +{ + stopActionMode(); + + QList aSections = mySectionView->getSelectedSections(); + for( int i = 0 ; i < aSections.size() ; i++ ){ + int aSectNum = aSections[i] - (i); + myCurve->removeSection( aSectNum ); + mySectionView->sectionsRemoved( aSectNum ); + } + mySectionView->clearSelection(); + updateUndoRedo(); + + emit curveModified(); +} + +/** + * Removes a selected points from the curve. Updates undo/redo status + */ +void CurveCreator_Widget::removePoint() +{ + CurveCreator_ICurve::SectionToPointList aPoints; + getSelectedPoints( aPoints ); + if ( aPoints.size() == 0 ) + return; + + CurveCreator_ICurve::SectionToPointList aSelPoints; + startCurveModification( aSelPoints, false ); + + myCurve->removeSeveralPoints( aPoints ); + finishCurveModification( CurveCreator_ICurve::SectionToPointList() ); + mySectionView->reset(); + + emit curveModified(); +} + +void CurveCreator_Widget::addNewPoint(const CurveCreator::Coordinates& theCoords) +{ + if( !myCurve ) + return; + QList aSections = mySectionView->getSelectedSections(); + if( aSections.size() == 0 ){ + return; + } + int aSection = aSections[0]; + myCurve->addPoints(theCoords, aSection); // add to the end of section + mySectionView->pointsAdded( aSection, myCurve->getNbPoints( aSection ) ); + updateActionsStates(); + updateUndoRedo(); + + emit curveModified(); +} + +void CurveCreator_Widget::insertPointToSelectedSegment( const int theX, + const int theY ) +{ + Handle(AIS_InteractiveContext) aContext = getAISContext(); + + OCCViewer_ViewPort3d* aViewPort = getViewPort(); + Handle(V3d_View) aView; + if ( aViewPort ) + aView = aViewPort->getView(); + + if ( aContext.IsNull() || aView.IsNull() ) + return; + gp_Pnt aPoint; + gp_Pnt aPoint1, aPoint2; + Handle(AIS_InteractiveObject) anAISObject = myCurve->getAISObject(); + bool isFoundPoint = CurveCreator_Utils::pointOnObject( aView, anAISObject, theX, theY, + aPoint, aPoint1, aPoint2 ); + if ( !isFoundPoint ) + return; + + // insert the point to the model curve + CurveCreator_ICurve::SectionToPointList aSelPoints; + startCurveModification( aSelPoints ); + + CurveCreator::Coordinates aCoords; + aCoords.push_back( aPoint.X() ); + aCoords.push_back( aPoint.Y() ); + + CurveCreator_ICurve::SectionToPointList aPoints1, aPoints2; + findSectionsToPoints( aPoint1.X(), aPoint1.Y(), aPoints1 ); + findSectionsToPoints( aPoint2.X(), aPoint2.Y(), aPoints2 ); + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints1.begin(), + aLast = aPoints1.end(); + int aSectionId = -1; + // find the indices of the neighbour point + // there can be a case when a new point is added into two sections + int aPoint1Id = -1, aPoint2Id = -1; + for ( ; anIt != aLast && aSectionId < 0; anIt++ ) { + int aSectionCur = anIt->first; + CurveCreator_ICurve::SectionToPointList::const_iterator anIt2 = aPoints2.begin(), + aLast2 = aPoints2.end(); + for ( ; anIt2 != aLast2 && aSectionId < 0; anIt2++ ) { + if ( anIt2->first == aSectionCur ) { + aSectionId = aSectionCur; + aPoint1Id = anIt->second; + aPoint2Id = anIt2->second; + } + } + } + + int anInsertPos = -1; + int aLastPoint = myCurve->getNbPoints( aSectionId )-1; + if ( ( aPoint1Id == aLastPoint && aPoint2Id == 0 ) || + ( aPoint2Id == aLastPoint && aPoint1Id == 0 ) ) + anInsertPos = -1; // if the section happens between first and last points + else + anInsertPos = aPoint1Id < aPoint2Id ? aPoint1Id + 1 : aPoint2Id + 1; + + myCurve->addPoints( aCoords, aSectionId, anInsertPos ); + mySectionView->pointsAdded( aSectionId, myCurve->getNbPoints( aSectionId ) ); + + finishCurveModification( aSelPoints ); + + setSelectedPoints(); + + emit curveModified(); +} + +void CurveCreator_Widget::moveSelectedPoints( const int theXPosition, + const int theYPosition ) +{ + OCCViewer_ViewPort3d* aViewPort = getViewPort(); + if ( !aViewPort ) + return; + + CurveCreator_ICurve::SectionToPointList aPoints; + startCurveModification( aPoints, false ); + + gp_Pnt aStartPnt = CurveCreator_Utils::ConvertClickToPoint( myDragStartPosition.x(), + myDragStartPosition.y(), + aViewPort->getView() ); + gp_Pnt anEndPnt = CurveCreator_Utils::ConvertClickToPoint( theXPosition, theYPosition, + aViewPort->getView() ); + double aXDelta = aStartPnt.X() - anEndPnt.X(); + double anYDelta = aStartPnt.Y() - anEndPnt.Y(); + + CurveCreator_ICurve::SectionToPointCoordsList aCoordList; + std::deque aChangedPos; + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = myDragPoints.begin(), + aLast = myDragPoints.end(); + for ( ; anIt != aLast; anIt++ ) { + int aSectionId = anIt->first; + int aPointId = anIt->second; + aChangedPos = myCurve->getPoint( aSectionId, aPointId ); + if ( aChangedPos.size() < 2 ) + continue; + + // Remember drag points coordinates + if ( !myDragged ) { + myInitialDragPointsCoords.insert( std::make_pair( aSectionId, aPointId ), aChangedPos ); + } + + aChangedPos[0] = aChangedPos[0] - aXDelta; + aChangedPos[1] = aChangedPos[1] - anYDelta; + + aCoordList.push_back( + std::make_pair(std::make_pair( aSectionId, aPointId ), + aChangedPos )); + } + myCurve->setSeveralPoints( aCoordList, false ); + + myDragged = true; + finishCurveModification( myDragPoints ); + + emit curveModified(); +} + +void CurveCreator_Widget::updateLocalPointView() +{ + if ( myDragStarted ) + return; + Handle(AIS_InteractiveContext) aContext = getAISContext(); + if ( aContext.IsNull() ) + return; + + CurveCreator_Utils::getSelectedPoints( aContext, myCurve, myLocalPoints ); + int aNbPoints = myLocalPoints.size(); + + bool isRowLimit = aNbPoints > myLocalPointRowLimit; + myLocalPointView->setVisible( getActionMode() == ModificationMode && !isRowLimit ); + + if ( !isRowLimit ) { + bool isBlocked = myLocalPointView->blockSignals(true); + + myLocalPointView->setLocalPointsToTable( myLocalPoints ); + + myLocalPointView->blockSignals( isBlocked ); + } +} + +/** + * + */ +void CurveCreator_Widget::setLocalPointContext( const bool theOpen, const bool isUpdateTable ) +{ + CurveCreator_Utils::setLocalPointContext( myCurve, getAISContext(), theOpen ); + if ( !theOpen && isUpdateTable ) + updateLocalPointView(); +} + +/** + * Set drag operation started. Save the position and a list of dragged points + * \param theState the drag operation state: started/finished + * \param thePoint the start drag position + */ +void CurveCreator_Widget::setDragStarted( const bool theState, const QPoint& thePoint ) +{ + if ( theState ) { + getSelectedPoints( myDragPoints ); + + myDragStarted = myDragPoints.size(); + myDragStartPosition = thePoint; + if ( myDragStarted ) { + // change a viewer interaction style in order to avoid a select rectangle build + myDragInteractionStyle = changeInteractionStyle( SUIT_ViewModel::KEY_FREE ); + myCurve->setSkipSorting( true ); + } + } + else { + if ( myDragStarted ) + changeInteractionStyle( myDragInteractionStyle ); + myDragStarted = false; + myDragPoints.clear(); + myInitialDragPointsCoords.clear(); + } + myDragged = false; +} + +void CurveCreator_Widget::getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints ) +{ + thePoints.clear(); + thePoints = myLocalPoints; +} + +void CurveCreator_Widget::setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& thePoints ) +{ + if ( myDragStarted ) + return; + Handle(AIS_InteractiveContext) aContext = getAISContext(); + if ( aContext.IsNull() || !aContext->HasOpenedContext() ) + return; + + CurveCreator_Utils::setSelectedPoints( aContext, myCurve, thePoints ); + + updateLocalPointView(); +} + +void CurveCreator_Widget::stopActionMode() +{ + setActionMode( NoneMode ); +} + +/** + * Get viewer information before perform the curve modification. + * Take a list of selected cuve points an close local context. + * The context should be closed because the curve presentation is + * redisplayed and if it is not closed, when we close the local context + * later, the presentation shown in the local context is disappeared. + * \param thePoints an output list of curve selected points + * \param theFillPoints a flag whether the selection list should be filled + */ +void CurveCreator_Widget::startCurveModification( + CurveCreator_ICurve::SectionToPointList& thePoints, + const bool theFillPoints ) +{ + if ( theFillPoints ) { + thePoints.clear(); + getSelectedPoints( thePoints ); + } + setLocalPointContext( false ); +} + +/** + * Restore the viewer state after the curve modification is done. + * Open local context and select given points inside it. + * \param thePoints a list of curve selected points + */ +void CurveCreator_Widget::finishCurveModification( + const CurveCreator_ICurve::SectionToPointList& thePoints ) +{ + if ( getActionMode() == ModificationMode ) + setLocalPointContext( true ); + setSelectedPoints( thePoints ); + updateUndoRedo(); +} + +/** + * Returns a point index in the model curve by the point coordinates in the viewer + * \param theX the X coordinate of the point + * \param theY the Y coordinate of the point + */ +int CurveCreator_Widget::findLocalPointIndex( int theSectionId, float theX, float theY ) +{ + return CurveCreator_UtilsICurve::findLocalPointIndex( myCurve, theSectionId, theX, theY ); +} + +void CurveCreator_Widget::findSectionsToPoints( const double theX, const double theY, + CurveCreator_ICurve::SectionToPointList& thePoints ) +{ + return CurveCreator_UtilsICurve::findSectionsToPoints( myCurve, theX, theY, thePoints ); +} + +void CurveCreator_Widget::convert( const CurveCreator_ICurve::SectionToPointList& thePoints, + QMap >& theConvPoints ) +{ + return CurveCreator_UtilsICurve::convert( thePoints, theConvPoints ); +} + +/** + * Returns whethe the container has the value + * \param theList a container of values + * \param theValue a value + */ +bool CurveCreator_Widget::contains( const CurveCreator_ICurve::SectionToPointList& theList, + const CurveCreator_ICurve::SectionToPoint& theValue ) const +{ + return CurveCreator_UtilsICurve::contains( theList, theValue ); } diff --git a/src/CurveCreator/CurveCreator_Widget.h b/src/CurveCreator/CurveCreator_Widget.h index 7f335e8db..e15e92309 100644 --- a/src/CurveCreator/CurveCreator_Widget.h +++ b/src/CurveCreator/CurveCreator_Widget.h @@ -1,9 +1,9 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013 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. +// version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,101 +20,212 @@ #ifndef CURVECREATOR_WIDGET_H #define CURVECREATOR_WIDGET_H -#include "CurveCreator_Curve.hxx" +#include "CurveCreator_Macro.hxx" #include "CurveCreator.hxx" +#include "CurveCreator_ICurve.hxx" #include #include +#include #include +#include +#include + +#include +#include +#include +#include // TODO - remove + +class OCCViewer_Viewer; +class OCCViewer_ViewPort3d; + +class AIS_ListOfInteractive; class QAction; class QPixmap; -class CurveCreator_CurveEditor; +class CurveCreator_TableView; class CurveCreator_TreeView; -class CurveCreator_NewPointDlg; class CurveCreator_NewSectionDlg; class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget { - Q_OBJECT + Q_OBJECT + public: - explicit CurveCreator_Widget( QWidget* parent, - CurveCreator_Curve *theCurve, - Qt::WindowFlags fl=0 ); + enum ActionFlags { + NoFlags = 0x00000000, + DisableDetectionMode = 0x00000001, + DisableNewSection = 0x00000002, + DisableClosedSection = 0x00000004 + }; - void setCurve( CurveCreator_Curve* theCurve ); + enum ActionMode { + NoneMode, + AdditionMode, + ModificationMode, + DetectionMode + }; - QList getSelectedSections(); - QList< QPair< int, int > > getSelectedPoints(); +public: + explicit CurveCreator_Widget( QWidget* parent, + CurveCreator_ICurve *theCurve, + const int theActionFlags = NoFlags, + const QStringList& theCoordTitles = QStringList(), + Qt::WindowFlags fl=0, + int theLocalPointRowLimit = 20); - bool isInstantSketchingEnabled() const; - void setInstantSketchingEnabled( const bool theState ); + // OCC viewer manipulation + void setOCCViewer( OCCViewer_Viewer* theViewer ); + + Handle(AIS_InteractiveContext) getAISContext(); + OCCViewer_ViewPort3d* getViewPort(); + int changeInteractionStyle( int theStyle ); + + void reset(); + void setCurve( CurveCreator_ICurve* theCurve ); + + QList getSelectedSections(); + void setSelectedSections( const QList& theSections ); + + void removeSelected(); + bool removeEnabled(); + + void setActionMode( const ActionMode& theMode ); + ActionMode getActionMode() const; + + void SetViewer2DMode(const bool To2D); signals: - void selectionChanged(); - void subOperationStarted( QWidget* ); - void subOperationFinished( QWidget* ); + void selectionChanged(); + void subOperationStarted( QWidget*, bool ); + void subOperationFinished( QWidget* ); + void curveModified(); public slots: protected slots: - void onAdditionMode(bool checked); - void onModificationMode(bool checked); - void onDetectPoints(bool checked); - void onModeChanged(bool checked); - void onNewSection(); - void onSelectionChanged(); - void onAddNewPoint(const CurveCreator::Coordinates& theCoords); - void onAddNewSection(); - void onEditSection( int theSection ); - void onEditPoint( int theSection, int thePoint ); - void onModifyPoint(); - void onModifySection(); - void onCancelPoint(); - void onCancelSection(); - void onJoin(); - void onRemove(); - void onMoveUp(); - void onMoveDown(); - void onClearAll(); - void onJoinAll(); - void onInsertSectionBefore(); - void onInsertSectionAfter(); - void onSetSpline(); - void onSetPolyline(); - void onCloseSections(); - void onUncloseSections(); - void onInsertPointBefore(); - void onInsertPointAfter(); - void onUndo(); - void onRedo(); - void onUndoSettings(); - void onContextMenu(QPoint thePoint); - void onGetPointByClick( SUIT_ViewWindow*, QMouseEvent* ); -// void onPointSelect( SUIT_ViewWindow*, QMouseEvent* ); - void onPointDrag( SUIT_ViewWindow*, QMouseEvent* ); + void onAdditionMode(bool checked); + void onModificationMode(bool checked); + void onDetectionMode(bool checked); + void onModeChanged(bool checked); + void onNewSection(); + void onSelectionChanged(); + void onAddNewSection(); + void onEditSection( int theSection ); + void onModifySection(); + void onCancelSection(); + void onJoin(); + void onRemove(); + void onClearAll(); + void onJoinAll(); + void onSetSpline(); + void onSetPolyline(); + void onCloseSections(); + void onUncloseSections(); + void onUndo(); + void onRedo(); + void onUndoSettings(); + void onContextMenu(QPoint thePoint); + + void onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent ); + void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent ); + void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent ); + void onLastViewClosed( SUIT_ViewManager* theManager ); + + void onMousePress( QMouseEvent* theEvent ); + void onMouseRelease( QMouseEvent* theEvent ); + void onMouseMove( QMouseEvent* theEvent ); + + void onCellChanged( int theRow, int theColumn ); + protected: - enum ActionId{ UNDO_ID, REDO_ID, NEW_SECTION_ID, ADDITION_MODE_ID, REMOVE_ID, REMOVE_ALL_ID, JOIN_ID, - JOIN_ALL_ID, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID, - INSERT_POINT_BEFORE_ID, INSERT_POINT_AFTER_ID, CLOSE_SECTIONS_ID, UNCLOSE_SECTIONS_ID, - SET_SECTIONS_POLYLINE_ID, SET_SECTIONS_SPLINE_ID, CLEAR_ALL_ID, SEPARATOR_ID, - MODIFICATION_MODE_ID, DETECTION_MODE_ID }; + void addCoordsByClick( QMouseEvent* ); + +protected: + enum ActionId{ NONE_ID, + UNDO_ID, + REDO_ID, + NEW_SECTION_ID, + ADDITION_MODE_ID, + REMOVE_ID, + REMOVE_ALL_ID, + JOIN_ID, + JOIN_ALL_ID, + CLOSE_SECTIONS_ID, + UNCLOSE_SECTIONS_ID, + SET_SECTIONS_POLYLINE_ID, + SET_SECTIONS_SPLINE_ID, + CLEAR_ALL_ID, + SEPARATOR_ID, + MODIFICATION_MODE_ID, + DETECTION_MODE_ID + }; + private: - QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage, - const QString& theToolTip, const QKeySequence& theShortcut ); - QAction* getAction(ActionId theId); - void updateUndoRedo(); + OCCViewer_Viewer* getOCCViewer(); + + QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage, + const QString& theToolTip, const QKeySequence& theShortcut ); + QAction* getAction(ActionId theId); + QAction* getAction(ActionMode theMode); + + void updateActionsStates(); + void updateUndoRedo(); + + void removeSection(); + void removePoint(); + void addNewPoint(const CurveCreator::Coordinates& theCoords); + void insertPointToSelectedSegment( const int theXPosition, + const int theYPosition ); + void moveSelectedPoints( const int theXPosition, const int theYPosition ); + void updateLocalPointView(); + void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false ); + + void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() ); + + void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints ); + void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& = + CurveCreator_ICurve::SectionToPointList() ); + + void stopActionMode(); + + void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints, + const bool theFillPoints = true ); + void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints = + CurveCreator_ICurve::SectionToPointList() ); + + // curve algorithm + int findLocalPointIndex( int theSectionId, float theX, float theY ); + void findSectionsToPoints( const double theX, const double theY, + CurveCreator_ICurve::SectionToPointList& thePoints ); + void convert( const CurveCreator_ICurve::SectionToPointList& thePoints, + QMap >& theConvPoints ); + + bool contains( const CurveCreator_ICurve::SectionToPointList& theList, + const CurveCreator_ICurve::SectionToPoint& theValue ) const; + private: - QMap myActionMap; - CurveCreator_Curve* myCurve; - CurveCreator_CurveEditor* myEdit; - CurveCreator_TreeView* mySectionView; - CurveCreator_NewPointDlg* myNewPointEditor; - CurveCreator_NewSectionDlg* myNewSectionEditor; - int mySection; - int myPointNum; - QPoint myDragStartPosition; + QMap myActionMap; + CurveCreator_ICurve* myCurve; + CurveCreator_TreeView* mySectionView; + CurveCreator_TableView* myLocalPointView; + CurveCreator_ICurve::SectionToPointList myLocalPoints; + CurveCreator_NewSectionDlg* myNewSectionEditor; + OCCViewer_Viewer* myOCCViewer; + int myLocalPointRowLimit; + int mySection; + int myPointNum; + bool myDragStarted; + QPoint myDragStartPosition; + int myDragInteractionStyle; + CurveCreator_ICurve::SectionToPointList myDragPoints; + QMap myInitialDragPointsCoords; + bool myDragged; + QByteArray myGuiState; + int myPressedX; + int myPressedY; + OCCViewer_ViewWindow::Mode2dType myOld2DMode; }; #endif // CURVECREATOR_WIDGET_H diff --git a/src/ImportExportGUI/CMakeLists.txt b/src/DependencyTree/CMakeLists.txt similarity index 56% rename from src/ImportExportGUI/CMakeLists.txt rename to src/DependencyTree/CMakeLists.txt index f5d9416af..b48e32760 100644 --- a/src/ImportExportGUI/CMakeLists.txt +++ b/src/DependencyTree/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2012-2014 CEA/DEN, EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,59 +18,56 @@ # 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} + ${QT_INCLUDES} ${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 + ${CAS_INCLUDE_DIRS} ${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 + ${PROJECT_SOURCE_DIR}/src/OBJECT + ${PROJECT_SOURCE_DIR}/src/GEOMUtils + ${PROJECT_SOURCE_DIR}/src/GEOMClient + ${PROJECT_BINARY_DIR}/idl ) # additional preprocessor / compiler flags ADD_DEFINITIONS( - ${CAS_DEFINITIONS} - ${OMNIORB_DEFINITIONS} ${QT_DEFINITIONS} + ${GUI_DEFINITIONS} + ${OMNIORB_DEFINITIONS} + ${CAS_DEFINITIONS} ) +IF(WIN32) + ADD_DEFINITIONS(-DNOGDI) +ENDIF(WIN32) # libraries to link to SET(_link_LIBRARIES - GEOMObject - GEOMClient - GEOMImpl - GEOMBase + ${QT_LIBRARIES} + ${GUI_SalomeApp} + ${GUI_GraphicsView} GEOM - DlgRef + GEOMBase ) # --- headers --- -# header files / no moc processing -SET(ImportExportGUI_HEADERS - ImportExportGUI.h +SET(DependencyTree_HEADERS + DependencyTree_Arrow.h + DependencyTree_Object.h + DependencyTree_Selector.h + DependencyTree.h ) # header files / to be processed by moc SET(_moc_HEADERS - ImportExportGUI_ExportXAODlg.h - ImportExportGUI_ImportXAODlg.h + DependencyTree_View.h + DependencyTree_ViewModel.h ) # --- sources --- @@ -78,15 +75,30 @@ SET(_moc_HEADERS # sources / moc wrappings QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) -SET(ImportExportGUI_SOURCES - ImportExportGUI.cxx - ImportExportGUI_ExportXAODlg.cxx - ImportExportGUI_ImportXAODlg.cxx +SET(DependencyTree_SOURCES + DependencyTree_Arrow.cxx + DependencyTree_Object.cxx + DependencyTree_Selector.cxx + DependencyTree_View.cxx + DependencyTree_ViewModel.cxx ${_moc_SOURCES} ) +# --- resources --- + +# resource files / to be processed by lrelease +SET(_res_files + resources/DependencyTree_msg_en.ts + resources/DependencyTree_msg_fr.ts + resources/DependencyTree_msg_ja.ts + ) + # --- rules --- -ADD_LIBRARY(ImportExportGUI ${ImportExportGUI_SOURCES}) -TARGET_LINK_LIBRARIES(ImportExportGUI ${_link_LIBRARIES}) -INSTALL(TARGETS ImportExportGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) +ADD_LIBRARY(DependencyTree ${DependencyTree_SOURCES}) +TARGET_LINK_LIBRARIES(DependencyTree ${_link_LIBRARIES}) +INSTALL(TARGETS DependencyTree EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +INSTALL(FILES ${DependencyTree_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) + +QT4_INSTALL_TS_RESOURCES("${_res_files}" "${SALOME_GEOM_INSTALL_RES_DATA}") diff --git a/src/DependencyTree/DependencyTree.h b/src/DependencyTree/DependencyTree.h new file mode 100644 index 000000000..4f47eb3a9 --- /dev/null +++ b/src/DependencyTree/DependencyTree.h @@ -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 DEPENDENCYTREE_H +#define DEPENDENCYTREE_H + +#if defined WIN32 +# if defined DEPENDENCYTREE_EXPORTS || defined DependencyTree_EXPORTS +# define DEPENDENCYTREE_EXPORT __declspec( dllexport ) +# else +# define DEPENDENCYTREE_EXPORT __declspec( dllimport ) +# endif +#else +# define DEPENDENCYTREE_EXPORT +#endif + +#endif // DEPENDENCYTREE_H diff --git a/src/DependencyTree/DependencyTree_Arrow.cxx b/src/DependencyTree/DependencyTree_Arrow.cxx new file mode 100644 index 000000000..945b631bc --- /dev/null +++ b/src/DependencyTree/DependencyTree_Arrow.cxx @@ -0,0 +1,264 @@ +// 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 "DependencyTree_Arrow.h" +#include "DependencyTree_Object.h" + +// GUI includes +#include +#include + +// Qt includes +#include + +#ifdef _MSC_VER +#define _USE_MATH_DEFINES +#endif + +#include + +const qreal arrowSize = 20; + +DependencyTree_Arrow::DependencyTree_Arrow( DependencyTree_Object* theStartItem, + DependencyTree_Object* theEndItem, + QGraphicsItem* parent, QGraphicsScene* scene ) +:QGraphicsLineItem( parent, scene ), +myIsBiLink( false ), +myStartItem( theStartItem ), +myEndItem( theEndItem ) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + + myColor = resMgr->colorValue( "Geometry", "dependency_tree_arrow_color", QColor( 0, 0, 130 ) ); + myHighlightColor = resMgr->colorValue( "Geometry", "dependency_tree_highlight_arrow_color", QColor( 0, 0, 255 ) ); + mySelectColor = resMgr->colorValue( "Geometry", "dependency_tree_select_arrow_color", QColor( 255, 0, 0 ) ); + + myStartItem = theStartItem; + myEndItem = theEndItem; + + myLine = QLineF( myStartItem->pos(), myEndItem->pos() ); + myArrowHead = createArrowHead( myStartItem->pos(), myEndItem->pos() ); + myReverseArrowHead = createArrowHead( myEndItem->pos(), myStartItem->pos() ); + + mySelfDependencyArrow = QRectF(); + + setPen( QPen( myColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) ); + setColor( myColor ); + + setFlag( QGraphicsItem::ItemIsSelectable, true ); + setZValue( -1000.0 ); +} + +DependencyTree_Arrow::~DependencyTree_Arrow() +{ +} + +//================================================================================= +// function : boundingRect() +// purpose : return the outer bounds of the item as a rectangle. +// QGraphicsView uses this to determine whether the item requires redrawing +//================================================================================= +QRectF DependencyTree_Arrow::boundingRect() const +{ + qreal extra; + QRectF boundingRect; + if( myStartItem == myEndItem ) { + extra = arrowSize / 2.0 + 2.0; + boundingRect = mySelfDependencyArrow; + } + else { + extra = ( pen().width() + 20 ) / 2.0; + boundingRect = QRectF( myLine.p1(), QSizeF( myLine.p2().x() - myLine.p1().x(), + myLine.p2().y() - myLine.p1().y() ) ); + } + return boundingRect.normalized().adjusted( -extra, -extra, extra, extra ); +} + +//================================================================================= +// function : shape() +// purpose : return the shape of this item to define an area of preselection +//================================================================================= +QPainterPath DependencyTree_Arrow::shape() const +{ + QPainterPath path; + + if( myStartItem == myEndItem ) { + qreal extra = 5; + QPolygonF aPolygonBigger( mySelfDependencyArrow.normalized() + .adjusted( -extra, -extra, extra, extra ) ); + QPolygonF aPolygonSmaller( mySelfDependencyArrow.normalized() + .adjusted( extra, extra, -extra, -extra ) ); + path.addPolygon( aPolygonBigger.subtracted( aPolygonSmaller ) ); + path.addPolygon(myArrowHead); + } + else { + QPolygonF aShapePolygon; + QPolygon anArrowHead = myArrowHead.toPolygon(); + QPolygon anReverseArrowHead = myReverseArrowHead.toPolygon(); + aShapePolygon << anArrowHead.point(1) << anArrowHead.point(0) << anArrowHead.point(2) << + anReverseArrowHead.point(1) << anReverseArrowHead.point(0) << anReverseArrowHead.point(2); + path.addPolygon( aShapePolygon ); + } + return path; + } + +//================================================================================= +// function : setColor() +// purpose : set default color for arrow +//================================================================================= +void DependencyTree_Arrow::setColor( const QColor& theColor ) +{ + myColor = theColor; +} + +//================================================================================= +// function : setHighlightColor() +// purpose : set color for highlighted arrow +//================================================================================= +void DependencyTree_Arrow::setHighlightColor( const QColor& theColor ) +{ + myHighlightColor = theColor; +} + +//================================================================================= +// function : setSelectColor() +// purpose : set color for selected arrow +//================================================================================= +void DependencyTree_Arrow::setSelectColor( const QColor& theColor ) +{ + mySelectColor = theColor; +} + +//================================================================================= +// function : getStartItem() +// purpose : get start item of arrow +//================================================================================= +DependencyTree_Object* DependencyTree_Arrow::getStartItem() const +{ + return myStartItem; +} + +//================================================================================= +// function : getEndItem() +// purpose : get end item of arrow +//================================================================================= +DependencyTree_Object* DependencyTree_Arrow::getEndItem() const +{ + return myEndItem; +} + +//================================================================================= +// function : setIsBiLink() +// purpose : set true if current arrow is bi-directional link, else set false +//================================================================================= +void DependencyTree_Arrow::setIsBiLink( bool theIsBiLink ) +{ + myIsBiLink = theIsBiLink; +} + +//================================================================================= +// function : paint() +// purpose : paint the contents of an item in local coordinates (called by QGraphicsView) +//================================================================================= +void DependencyTree_Arrow::paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* ) +{ + if( isSelected() ) { + painter->setBrush( mySelectColor ); + painter->setPen( QPen( mySelectColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) ); + } + else if( isUnderMouse() ) { + painter->setBrush( myHighlightColor ); + painter->setPen( QPen( myHighlightColor, 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) ); + } + else { + painter->setBrush( myColor ); + painter->setPen( QPen( myColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) ); + } + + if( myStartItem == myEndItem ) { + int lineSize = 60; + QPointF p1( myStartItem->pos().x() - myStartItem->boundingRect().width()/2, + myStartItem->pos().y() ); + QPointF p2( p1.x() - lineSize + myStartItem->boundingRect().height()/2, p1.y() ); + QPointF p3( p2.x(), p2.y() - lineSize ); + QPointF p4( p3.x() + lineSize, p3.y() ); + QPointF p5( p4.x(), p4.y() + lineSize - myStartItem->boundingRect().height()/2 ); + mySelfDependencyArrow = QRectF( p3.x(), p3.y(), lineSize, lineSize ); + myArrowHead = createArrowHead( p4, p5, false ); + QVector pointVector; + pointVector << p1 << p2 << p2 << p3 << p3 << p4 << p4 << p5; + + painter->drawLines( pointVector); + painter->drawPolygon(myArrowHead); + } + else { + if (myStartItem->collidesWithItem(myEndItem)) + return; + + myArrowHead = createArrowHead( myStartItem->pos(), myEndItem->pos() ); + myReverseArrowHead = createArrowHead( myEndItem->pos(), myStartItem->pos() ); + + painter->drawLine( myLine ); + painter->drawPolygon( myArrowHead ); + if( myIsBiLink ) + painter->drawPolygon( myReverseArrowHead ); + } +} + +//================================================================================= +// function : createArrowHead() +// purpose : create a head of arrow from start point to end point +//================================================================================= +QPolygonF DependencyTree_Arrow::createArrowHead( QPointF theStartPoint, QPointF theEndPoint, + bool theIsDynamic ) +{ + if( theIsDynamic ) { + QLineF centerLine( theStartPoint, theEndPoint ); + QPolygonF endPolygon = QPolygonF( myEndItem->boundingRect() ); + QPointF p1 = endPolygon.first() + theEndPoint; + QPointF p2; + QPointF intersectPoint; + QLineF polyLine; + for( int i = 1; i < endPolygon.count(); ++i ) { + p2 = endPolygon.at(i) + theEndPoint; + polyLine = QLineF( p1, p2 ); + QLineF::IntersectType intersectType = polyLine.intersect( centerLine, &intersectPoint ); + if( intersectType == QLineF::BoundedIntersection ) + break; + p1 = p2; + } + myLine = QLineF( intersectPoint, theStartPoint ); + } + else + myLine = QLineF( theEndPoint, theStartPoint ); + + double angle = acos(myLine.dx() / myLine.length()); + if( myLine.dy() >= 0 ) + angle = ( M_PI * 2 ) - angle; + + QPointF arrowP1 = myLine.p1() + QPointF( sin( angle + M_PI / 3 ) * arrowSize, + cos( angle + M_PI / 3 ) * arrowSize ); + QPointF arrowP2 = myLine.p1() + QPointF( sin( angle + M_PI - M_PI / 3 ) * arrowSize, + cos( angle + M_PI - M_PI / 3 ) * arrowSize ); + + QPolygonF anArrowHead; + anArrowHead << myLine.p1() << arrowP1 << arrowP2; + return anArrowHead; +} diff --git a/src/DependencyTree/DependencyTree_Arrow.h b/src/DependencyTree/DependencyTree_Arrow.h new file mode 100644 index 000000000..9f73bfe51 --- /dev/null +++ b/src/DependencyTree/DependencyTree_Arrow.h @@ -0,0 +1,76 @@ +// 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 DEPENDENCYTREE_ARROW_H +#define DEPENDENCYTREE_ARROW_H + +#include + +#include "DependencyTree.h" + +class DependencyTree_Object; + +class DEPENDENCYTREE_EXPORT DependencyTree_Arrow : public QGraphicsLineItem +{ + +public: + + DependencyTree_Arrow( DependencyTree_Object* startItem, DependencyTree_Object* endItem, + QGraphicsItem* parent = 0, QGraphicsScene* scene = 0 ); + ~DependencyTree_Arrow(); + + virtual QRectF boundingRect() const; + virtual QPainterPath shape() const; + + void setColor(const QColor& ); + void setHighlightColor(const QColor& ); + void setSelectColor(const QColor& ); + + DependencyTree_Object* getStartItem() const; + DependencyTree_Object* getEndItem() const; + + void setIsBiLink( bool ); + +protected: + + void paint( QPainter*, const QStyleOptionGraphicsItem*, QWidget* = 0 ); + +private: + + QPolygonF createArrowHead( QPointF , QPointF, bool = true ); + + DependencyTree_Object* myStartItem; + DependencyTree_Object* myEndItem; + + QColor myColor; + QColor mySelectColor; + QColor myHighlightColor; + + QPolygonF myArrowHead; + QPolygonF myReverseArrowHead; + + bool myIsBiLink; + + QRectF mySelfDependencyArrow; + + QLineF myLine; + +}; + +#endif diff --git a/src/DependencyTree/DependencyTree_Object.cxx b/src/DependencyTree/DependencyTree_Object.cxx new file mode 100644 index 000000000..25203629e --- /dev/null +++ b/src/DependencyTree/DependencyTree_Object.cxx @@ -0,0 +1,271 @@ +// 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 "DependencyTree_Object.h" + +// GEOM includes +#include + +// GUI includes +#include +#include +#include +#include + +// Qt includes +#include + +const int itemH = 20; +const int itemW = 90; + +DependencyTree_Object::DependencyTree_Object( const std::string& theEntry, QGraphicsItem* theParent ) +:GraphicsView_Object( theParent ), +myIsMainObject( false ) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + + myColor = resMgr->colorValue( "Geometry", "dependency_tree_node_color", QColor( 62, 180, 238 ) ); + mySelectColor = resMgr->colorValue( "Geometry", "dependency_tree_select_node_color", QColor( 237, 243, 58 ) ); + myMainObjectColor = resMgr->colorValue( "Geometry", "dependency_tree_main_node_color", QColor( 238, 90, 125 ) ); + myUnpublishObjectColor = resMgr->colorValue( "Geometry", "dependency_tree_unpublish_node_color", QColor( 255, 255, 255 ) ); + + myPolygonItem = new QGraphicsPolygonItem(); + QPolygonF myPolygon; + myPolygon << QPointF( -itemW, -itemH ) << QPointF( itemW, -itemH ) << QPointF( itemW, itemH ) + << QPointF( -itemW, itemH ) << QPointF( -itemW, -itemH ); + + myPolygonItem->setPolygon( myPolygon ); + + myTextItem = new QGraphicsSimpleTextItem(); + QFont textFont; + textFont.setPointSize( itemH ); + myTextItem->setFont( textFont ); + + myEntry = theEntry; + + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + SalomeApp_Study* study = dynamic_cast(app->activeStudy()); + SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy( study->studyDS() ); + int studyId = aStudyDS->StudyId(); + myGeomObject = GeometryGUI::GetGeomGen()->GetObject( studyId, myEntry.c_str() ); + + updateName(); + + addToGroup( myPolygonItem ); + addToGroup( myTextItem ); +} + +DependencyTree_Object::~DependencyTree_Object() +{ +} + +//================================================================================= +// function : highlight() +// purpose : highlight current item +//================================================================================= +bool DependencyTree_Object::highlight( double theX, double theY ) +{ + if( !isHighlighted() ) { + QColor color = myPolygonItem->brush().color(); + int saturation = ( color.saturation() - 100 ) > 10 ? color.saturation() - 100 : 10; + color.setHsv( color.hsvHue(), saturation, color.value() ); + + myPolygonItem->setBrush( color ); + myPolygonItem->setPen( getPen( color ) ); + + myPolygonItem->setToolTip( getName() ); + } + return GraphicsView_Object::highlight( theX, theY ); +} + +//================================================================================= +// function : unhighlight() +// purpose : set properties for unhighlighted item +//================================================================================= +void DependencyTree_Object::unhighlight() +{ + if( isSelected() ) + myPolygonItem->setBrush( mySelectColor ); + else if( myIsMainObject ) + myPolygonItem->setBrush( myMainObjectColor ); + else + myPolygonItem->setBrush( myColor ); + + myPolygonItem->setPen( getPen( myPolygonItem->brush().color() ) ); + + GraphicsView_Object::unhighlight(); +} + +//================================================================================= +// function : select() +// purpose : select current item +//================================================================================= +bool DependencyTree_Object::select( double theX, double theY, const QRectF& theRect ) +{ + myPolygonItem->setBrush( mySelectColor ); + myPolygonItem->setPen( getPen( mySelectColor ) ); + + return GraphicsView_Object::select( theX, theY, theRect ); +} + +//================================================================================= +// function : unselect() +// purpose : set properties for unselected item +//================================================================================= +void DependencyTree_Object::unselect() +{ + if( myIsMainObject ) + myPolygonItem->setBrush( myMainObjectColor ); + else + myPolygonItem->setBrush( myColor ); + + myPolygonItem->setPen( getPen( myPolygonItem->brush().color() ) ); + + GraphicsView_Object::unselect(); +} + +//================================================================================= +// function : getEntry() +// purpose : get entry of current item +//================================================================================= +std::string DependencyTree_Object::getEntry() const +{ + return myEntry; +} + +//================================================================================= +// function : getGeomObject() +// purpose : get geometry object of current item +//================================================================================= +GEOM::GEOM_BaseObject_var DependencyTree_Object::getGeomObject() const +{ + return myGeomObject; +} + +//================================================================================= +// function : updateName() +// purpose : update name of current item using its entry +//================================================================================= +void DependencyTree_Object::updateName() +{ + + QString name = myGeomObject->GetName(); + CORBA::String_var studyEntryVar = myGeomObject->GetStudyEntry(); + + if( QString( studyEntryVar.in() ).isEmpty() ) { + if( name.isEmpty() ) + name = "unpublished"; + myColor = myUnpublishObjectColor; + } + + myPolygonItem->setBrush( myColor ); + myPolygonItem->setPen( getPen( myColor ) ); + + setName( name ); + + myTextItem->setText( name ); + double textWidth = myTextItem->sceneBoundingRect().width(); + double textHeight = myTextItem->sceneBoundingRect().height(); + + double polygonWidth = myPolygonItem->sceneBoundingRect().width(); + double polygonHeight = myPolygonItem->sceneBoundingRect().height(); + + if( ( textWidth - 4 ) > polygonWidth ) { + int numberSymbol = int( polygonWidth * name.length() / textWidth ); + QString newName = name.left( numberSymbol - 3 ) + "..."; + myTextItem->setText( newName ); + textWidth = myTextItem->sceneBoundingRect().width(); + } + myTextItem->setPos( ( polygonWidth - textWidth ) / 2 - itemW, + ( polygonHeight - textHeight ) / 2 - itemH ); +} + +//================================================================================= +// function : setColor() +// purpose : set default color of current item +//================================================================================= +void DependencyTree_Object::setColor( const QColor& theColor ) +{ + CORBA::String_var studyEntryVar = myGeomObject->GetStudyEntry(); + if( QString( studyEntryVar.in() ).isEmpty() ) + myColor = myUnpublishObjectColor; + else + myColor = theColor; + +} + +//================================================================================= +// function : setSelectColor() +// purpose : set color of selected item +//================================================================================= +void DependencyTree_Object::setSelectColor( const QColor& theColor ) +{ + mySelectColor = theColor; +} + +//================================================================================= +// function : setMainObjectColor() +// purpose : set color if current item is main object of dependency tree +//================================================================================= +void DependencyTree_Object::setMainObjectColor( const QColor& theColor ) +{ + myMainObjectColor = theColor; +} + +//================================================================================= +// function : setUnpublishObjectColor() +// purpose : set color if current item is unpublished object +//================================================================================= +void DependencyTree_Object::setUnpublishObjectColor( const QColor& theColor ) +{ + myUnpublishObjectColor = theColor; + CORBA::String_var studyEntryVar = myGeomObject->GetStudyEntry(); + if( QString( studyEntryVar.in() ).isEmpty() ) + myColor = myUnpublishObjectColor; +} + +//================================================================================= +// function : setIsMainObject() +// purpose : set true if current item is main object of dependency tree +//================================================================================= +void DependencyTree_Object::setIsMainObject( bool theIsMainObject ) +{ + myIsMainObject = theIsMainObject; + + if( myIsMainObject ) + myPolygonItem->setBrush( myMainObjectColor ); + else + myPolygonItem->setBrush( myColor ); + + myPolygonItem->setPen( getPen( myPolygonItem->brush().color() ) ); +} + +//================================================================================= +// function : getPen() +// purpose : get pen which is dependent of current color +//================================================================================= +QPen DependencyTree_Object::getPen( const QColor& theColor ) +{ + int value = ( theColor.value() - 100 ) > 10 ? theColor.value() - 100 : 10; + QColor penColor; + penColor.setHsv( theColor.hsvHue(), theColor.saturation(), value ); + return QPen( QBrush( penColor ), 4 ); +} diff --git a/src/DependencyTree/DependencyTree_Object.h b/src/DependencyTree/DependencyTree_Object.h new file mode 100644 index 000000000..db2c4a22b --- /dev/null +++ b/src/DependencyTree/DependencyTree_Object.h @@ -0,0 +1,81 @@ +// 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 DEPENDENCYTREE_OBJECT_H +#define DEPENDENCYTREE_OBJECT_H + +#include + +// GEOM includes +#include +#include CORBA_CLIENT_HEADER(GEOM_Gen) + +#include + +#include "DependencyTree.h" + +class DEPENDENCYTREE_EXPORT DependencyTree_Object: public GraphicsView_Object +{ + +public: + + DependencyTree_Object( const std::string&, QGraphicsItem* = 0 ); + ~DependencyTree_Object(); + + virtual void compute() {}; + + virtual bool highlight( double, double ); + virtual void unhighlight(); + + virtual bool select( double, double, const QRectF& ); + virtual void unselect(); + + std::string getEntry() const; + + GEOM::GEOM_BaseObject_var getGeomObject() const; + + void updateName(); + + void setColor( const QColor& ); + void setSelectColor( const QColor& ); + void setMainObjectColor( const QColor& ); + void setUnpublishObjectColor( const QColor& ); + + void setIsMainObject( bool ); + +private: + + QPen getPen( const QColor& ); + + QColor myColor; + QColor mySelectColor; + QColor myMainObjectColor; + QColor myUnpublishObjectColor; + + QGraphicsPolygonItem* myPolygonItem; + QGraphicsSimpleTextItem* myTextItem; + + GEOM::GEOM_BaseObject_var myGeomObject; + std::string myEntry; + + bool myIsMainObject; + +}; + +#endif diff --git a/src/DependencyTree/DependencyTree_Selector.cxx b/src/DependencyTree/DependencyTree_Selector.cxx new file mode 100644 index 000000000..98f0cc030 --- /dev/null +++ b/src/DependencyTree/DependencyTree_Selector.cxx @@ -0,0 +1,107 @@ +// 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 "DependencyTree_Selector.h" +#include "DependencyTree_View.h" +#include "DependencyTree_ViewModel.h" +#include "DependencyTree_Object.h" + +// GUI includes +#include + +//GEOM includes +#include +#include + +DependencyTree_Selector::DependencyTree_Selector( DependencyTree_ViewModel* theModel, SUIT_SelectionMgr* theSelMgr ) +:LightApp_GVSelector( (GraphicsView_Viewer*)theModel, theSelMgr ) +{ + myView = dynamic_cast( theModel->getActiveViewPort() ); +} + +DependencyTree_Selector::~DependencyTree_Selector() +{ +} + +//================================================================================= +// function : getSelection() +// purpose : get list of selected Data Owner objects. +//================================================================================= +void DependencyTree_Selector::getSelection( SUIT_DataOwnerPtrList& theList ) const +{ + for( myView->initSelected(); myView->moreSelected(); myView->nextSelected() ) + if( DependencyTree_Object* treeObject = dynamic_cast( myView->selectedObject() ) ) { + QString studyEntry; + QString name; + GEOM::GEOM_BaseObject_var anObj = GeometryGUI::GetGeomGen()->GetObject( myView->getStudyId(), + treeObject->getEntry().c_str() ); + if( anObj->_is_nil() ) + continue; + CORBA::String_var studyEntryVar = anObj->GetStudyEntry(); + studyEntry = studyEntryVar.in(); + if( studyEntry.isEmpty() ) { + studyEntry = treeObject->getEntry().c_str(); + name = "TEMP_IO_UNPUBLISHED"; + } + else { + name = "TEMP_IO"; + } + Handle(SALOME_InteractiveObject) tmpIO = + new SALOME_InteractiveObject( studyEntry.toStdString().c_str(), + "GEOM", + name.toStdString().c_str()); + + theList.append( new LightApp_DataOwner( tmpIO ) ); + } +} + +//================================================================================= +// function : setSelection() +// purpose : set to selected list of Data Owner objects. +//================================================================================= +void DependencyTree_Selector::setSelection( const SUIT_DataOwnerPtrList& theList ) +{ + myView->clearSelected(); + + for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it ) { + const LightApp_DataOwner* owner = dynamic_cast( (*it).operator->() ); + if ( owner ) + if( !owner->IO().IsNull() ) { + const char* name = owner->IO()->getName(); + const char* entry; + if( strcmp( owner->IO()->getComponentDataType(), "GEOM" ) != 0 ) + return; + + if( strcmp( name, "TEMP_IO_UNPUBLISHED" ) == 0 ) + entry = owner->IO()->getEntry(); + else { + GEOM::GEOM_Object_var geomObject = GEOMBase::ConvertIOinGEOMObject( owner->IO() ); + if( geomObject->_is_nil() ) + return; + entry = geomObject->GetEntry(); + } + DependencyTree_Object* object = myView->getObjectByEntry( entry ); + if( object ) { + myView->setSelected( object ); + object->select( object->pos().x(), object->pos().y(), object->getRect() ); + } + } + } +} diff --git a/src/DependencyTree/DependencyTree_Selector.h b/src/DependencyTree/DependencyTree_Selector.h new file mode 100644 index 000000000..5203d4d55 --- /dev/null +++ b/src/DependencyTree/DependencyTree_Selector.h @@ -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 DEPENDENCYTREE_SELECTOR_H +#define DEPENDENCYTREE_SELECTOR_H + +#include + +#include "DependencyTree.h" + +class DependencyTree_ViewModel; +class DependencyTree_View; + +class DEPENDENCYTREE_EXPORT DependencyTree_Selector: public LightApp_GVSelector +{ + +public: + + DependencyTree_Selector( DependencyTree_ViewModel*, SUIT_SelectionMgr* ); + ~DependencyTree_Selector(); + +protected: + + virtual void getSelection( SUIT_DataOwnerPtrList& ) const; + virtual void setSelection( const SUIT_DataOwnerPtrList& ); + +private: + + DependencyTree_View* myView; + +}; + +#endif diff --git a/src/DependencyTree/DependencyTree_View.cxx b/src/DependencyTree/DependencyTree_View.cxx new file mode 100644 index 000000000..230bfa53a --- /dev/null +++ b/src/DependencyTree/DependencyTree_View.cxx @@ -0,0 +1,798 @@ +// 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 "DependencyTree_View.h" +#include "DependencyTree_Object.h" +#include "DependencyTree_Arrow.h" + +// GUI includes +#include +#include +#include +#include +#include +#include + +// GEOM includes +#include + +// Qt includes +#include +#include +#include + +DependencyTree_View::DependencyTree_View( QWidget* theParent ) +:GraphicsView_ViewPort( theParent ), +myLevelsNumber(0), +myMaxDownwardLevelsNumber(0), +myMaxUpwardLevelsNumber(0), +myIsUpdate( true ) +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + myStudy = GeometryGUI::ClientStudyToStudy( study->studyDS()); + + mySelectionMgr = app->selectionMgr(); + if ( !mySelectionMgr ) return; + + myMainEntries = new GEOM::string_array(); + + getNewTreeModel(); +} + +DependencyTree_View::~DependencyTree_View() +{ + clearView( true ); +} + +//================================================================================= +// function : init() +// purpose : this method is obligatory for initialize view frame actions +//================================================================================= +void DependencyTree_View::init( GraphicsView_ViewFrame* theViewFrame ) +{ + myNodesMovable = new QCheckBox( tr( "MOVE_NODES" ) ); + QWidgetAction* nodesMovableAction = new QWidgetAction( theViewFrame ); + nodesMovableAction->setDefaultWidget( myNodesMovable ); + + myDisplayAscendants = new QCheckBox( tr( "DISPLAY_ASCENDANTS" ) ); + QWidgetAction* displayAscendantsAction = new QWidgetAction( theViewFrame ); + displayAscendantsAction->setDefaultWidget( myDisplayAscendants ); + + myDisplayDescendants = new QCheckBox(tr("DISPLAY_DESCENDANTS")); + QWidgetAction* displayDescendantsAction = new QWidgetAction( theViewFrame ); + displayDescendantsAction->setDefaultWidget( myDisplayDescendants ); + + QLabel* hierarchyDepthLabel = new QLabel( tr( "HIERARCHY_DEPTH" ) ); + QWidgetAction* hierarchyDepthLabelAction = new QWidgetAction( theViewFrame ); + hierarchyDepthLabelAction->setDefaultWidget( hierarchyDepthLabel ); + + myLevelsNumber = checkMaxLevelsNumber(); + + myHierarchyDepth = new QSpinBox(); + myHierarchyDepth->setRange( 0, checkMaxLevelsNumber() ); + myHierarchyDepth->setSpecialValueText( tr( "SHOW_ALL" ) ); + myHierarchyDepth->setValue( 0 ); + QWidgetAction* hierarchyDepthAction = new QWidgetAction( theViewFrame ); + hierarchyDepthAction->setDefaultWidget( myHierarchyDepth ); + + updateButton = new QPushButton( tr( "UPDATE" ) ); + QWidgetAction* updateAction = new QWidgetAction( theViewFrame ); + updateAction->setDefaultWidget( updateButton ); + + QAction* separator1 = theViewFrame->toolMgr()->separator( false ); + QAction* separator2 = theViewFrame->toolMgr()->separator( false ); + + theViewFrame->toolMgr()->append( separator1, theViewFrame->getToolBarId() ); + theViewFrame->toolMgr()->append( hierarchyDepthLabelAction, theViewFrame->getToolBarId() ); + theViewFrame->toolMgr()->append( hierarchyDepthAction, theViewFrame->getToolBarId() ); + theViewFrame->toolMgr()->append( displayAscendantsAction, theViewFrame->getToolBarId() ); + theViewFrame->toolMgr()->append( displayDescendantsAction, theViewFrame->getToolBarId() ); + theViewFrame->toolMgr()->append( nodesMovableAction, theViewFrame->getToolBarId() ); + + theViewFrame->toolMgr()->append( separator2, theViewFrame->getToolBarId() ); + theViewFrame->toolMgr()->append( updateAction, theViewFrame->getToolBarId() ); + + connect( myNodesMovable, SIGNAL( toggled( bool ) ), this, SLOT( onMoveNodes( bool ) ) ); + connect( myHierarchyDepth, SIGNAL( valueChanged ( int ) ), this, SLOT( onHierarchyType() ) ); + connect( myDisplayAscendants , SIGNAL( toggled( bool ) ), this, SLOT( onHierarchyType() ) ); + connect( myDisplayDescendants, SIGNAL( toggled( bool ) ), this, SLOT( onHierarchyType() ) ); + connect( updateButton, SIGNAL( clicked() ), this, SLOT( onUpdateModel() ) ); + + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + GeometryGUI* aGeomGUI = dynamic_cast( app->module( "Geometry" ) ); + if ( aGeomGUI ) { + connect( aGeomGUI, SIGNAL( SignalDependencyTreeParamChanged( const QString&, const QString& ) ), + this, SLOT( onPreferenceChanged( const QString&, const QString& ) ) ); + connect( aGeomGUI, SIGNAL( SignalDependencyTreeRenameObject( const QString& ) ), + this, SLOT( onRenameObject( const QString& ) ) ); + } + + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + setPrefBackgroundColor( resMgr->colorValue( "Geometry", "dependency_tree_background_color", QColor( 255, 255, 255 ) ) ); + setNodesMovable( resMgr->booleanValue( "Geometry", "dependency_tree_move_nodes", true ) ); + setHierarchyType( resMgr->integerValue( "Geometry", "dependency_tree_hierarchy_type", 0 ) ); +} + +//================================================================================= +// function : updateModel() +// purpose : run all stage of dependency tree creation +//================================================================================= +void DependencyTree_View::updateModel( bool theUseSelectedObject, bool theUseOB ) +{ + getNewTreeModel( theUseSelectedObject, theUseOB ); + onHierarchyType(); +} + +//================================================================================= +// function : mouseMoveEvent() +// purpose : make some actions when mouse was moved +//================================================================================= +void DependencyTree_View::mouseMoveEvent( QMouseEvent *event ) +{ + QGraphicsView::mouseMoveEvent( event ); + ArrowsInfo::const_iterator i; + for( i = myArrows.begin(); i != myArrows.end(); i++ ) { + if( DependencyTree_Arrow* arrow = myArrows[ i->first ] ) + arrow->update(); + } +} + +//================================================================================= +// function : wheelEvent() +// purpose : add zoom action when wheel is spinning +//================================================================================= +void DependencyTree_View::wheelEvent( QWheelEvent* event ) +{ + int inc = 10; // zoom coefficient + double cx = width() / 2; + double cy = height() / 2; + if( event->delta() > 0 ) + zoom( cx, cy, cx + inc, cy + inc ); + else + zoom( cx, cy, cx - inc, cy - inc ); + + QGraphicsView::wheelEvent( event ); +} + +//================================================================================= +// function : getViewName() +// purpose : return the name of current view +//================================================================================= +QString DependencyTree_View::getViewName() const +{ + return tr( "DEPENDENCY_TREE" ); +} + +//================================================================================= +// function : getStudyId() +// purpose : return Id of current study +//================================================================================= +int DependencyTree_View::getStudyId() const +{ + return myStudy->StudyId(); +} + +//================================================================================= +// function : getObjectByEntry() +// purpose : return DependencyTree_Object by entry +//================================================================================= +DependencyTree_Object* DependencyTree_View::getObjectByEntry( const std::string& theEntry ) +{ + return myTreeMap[ theEntry ]; +} + +//================================================================================= +// function : setHierarchyType() +// purpose : set hierarchy type of dependency tree +//================================================================================= +void DependencyTree_View::setHierarchyType( const int theType ) +{ + myIsUpdate = false; + switch( theType ) { + case 0: + myDisplayAscendants->setChecked( true ); + myDisplayDescendants->setChecked( true ); + break; + case 1: + myDisplayAscendants->setChecked( true ); + myDisplayDescendants->setChecked( false ); + break; + case 2: + myDisplayAscendants->setChecked( false ); + myDisplayDescendants->setChecked( true ); + break; + } + myIsUpdate = true; + myLevelsNumber = checkMaxLevelsNumber(); + onHierarchyType(); +} + +//================================================================================= +// function : setNodesMovable() +// purpose : set possibility to move nodes or not +//================================================================================= +void DependencyTree_View::setNodesMovable( const bool theIsMovable ) +{ + myNodesMovable->setChecked( theIsMovable ); +} + +//================================================================================= +// function : setPrefBackgroundColor() +// purpose : set background color from preferences +//================================================================================= +void DependencyTree_View::setPrefBackgroundColor( const QColor& theColor ) +{ + if( isForegroundEnabled() ) + { + setForegroundColor( theColor ); + updateForeground(); + } + else + setBackgroundColor( theColor ); +} + +//================================================================================= +// function : setNodeColor() +// purpose : set node color from preferences +//================================================================================= +void DependencyTree_View::setNodeColor( const QColor& theColor ) +{ + EntryObjectMap::const_iterator i; + for( i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { + DependencyTree_Object* object = myTreeMap[ i->first ]; + object->setColor( theColor ); + } +} + +//================================================================================= +// function : setMainNodeColor() +// purpose : set main node color from preferences +//================================================================================= +void DependencyTree_View::setMainNodeColor( const QColor& theColor ) +{ + EntryObjectMap::const_iterator i; + for( i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { + DependencyTree_Object* object = myTreeMap[ i->first ]; + object->setMainObjectColor( theColor ); + } +} + +//================================================================================= +// function : setUnpublishNodeColor() +// purpose : set unpublished node color from preferences +//================================================================================= +void DependencyTree_View::setUnpublishNodeColor( const QColor& theColor ) +{ + EntryObjectMap::const_iterator i; + for( i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { + DependencyTree_Object* object = myTreeMap[ i->first ]; + object->setUnpublishObjectColor( theColor ); + } +} + +//================================================================================= +// function : setSelectNodeColor() +// purpose : set selected node color from preferences +//================================================================================= +void DependencyTree_View::setSelectNodeColor( const QColor& theColor ) +{ + EntryObjectMap::const_iterator i; + for( i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { + DependencyTree_Object* object = myTreeMap[ i->first ]; + object->setSelectColor( theColor ); + } +} + +//================================================================================= +// function : setArrowColor() +// purpose : set arrow color from preferences +//================================================================================= +void DependencyTree_View::setArrowColor( const QColor& theColor ) +{ + ArrowsInfo::const_iterator i; + for( i = myArrows.begin(); i != myArrows.end(); i++ ) { + DependencyTree_Arrow* arrow = myArrows[ i->first ]; + arrow->setColor( theColor ); + } +} + +//================================================================================= +// function : setHighlightArrowColor() +// purpose : set highlighted arrow color from preferences +//================================================================================= +void DependencyTree_View::setHighlightArrowColor( const QColor& theColor ) +{ + ArrowsInfo::const_iterator i; + for( i = myArrows.begin(); i != myArrows.end(); i++ ) { + DependencyTree_Arrow* arrow = myArrows[ i->first ]; + arrow->setHighlightColor( theColor ); + } +} + +//================================================================================= +// function : setSelectArrowColor() +// purpose : set selected arrow color from preferences +//================================================================================= +void DependencyTree_View::setSelectArrowColor( const QColor& theColor ) +{ + ArrowsInfo::const_iterator i; + for( i = myArrows.begin(); i != myArrows.end(); i++ ) { + DependencyTree_Arrow* arrow = myArrows[ i->first ]; + arrow->setSelectColor( theColor ); + } +} + +//================================================================================= +// function : onRebuildModel() +// purpose : slot for updating tree model using selected objects in viewer +//================================================================================= +void DependencyTree_View::onRebuildModel() +{ + updateModel( true, false ); +} + +//================================================================================= +// function : onUpdateModel() +// purpose : slot for updating tree model for main objects in viewer +//================================================================================= +void DependencyTree_View::onUpdateModel() +{ + updateModel( false ); +} + +//================================================================================= +// function : onMoveNodes() +// purpose : slot for setting the possibility to move nodes in viewer +//================================================================================= +void DependencyTree_View::onMoveNodes( bool theIsMoveNodes ) +{ + EntryObjectMap::const_iterator i; + for( i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { + DependencyTree_Object* object = myTreeMap[ i->first ]; + if( object ) + object->setMovable( theIsMoveNodes ); + } +} + +//================================================================================= +// function : onHierarchyType() +// purpose : slot for setting the hierarchy type of tree +//================================================================================= +void DependencyTree_View::onHierarchyType() +{ + myHierarchyDepth->setRange( 0, checkMaxLevelsNumber() ); + if( myHierarchyDepth->value() > checkMaxLevelsNumber() ) + myHierarchyDepth->setValue( checkMaxLevelsNumber() ); + + if( myHierarchyDepth->value() == 0 ) + myLevelsNumber = myHierarchyDepth->maximum(); + else + myLevelsNumber = myHierarchyDepth->value(); + + updateView(); +} + +//================================================================================= +// function : onPreferencesChanged() +// purpose : slot for changing tree parameters from preferences +//================================================================================= +void DependencyTree_View::onPreferenceChanged( const QString& section, const QString& param ) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + + if( param == QString("dependency_tree_hierarchy_type") ) { + int hierarchyType = resMgr->integerValue( section, param, 0); + setHierarchyType( hierarchyType ); + } + else if( param == QString("dependency_tree_move_nodes") ) { + bool isNodesMovable = resMgr->booleanValue( section, param, true); + setNodesMovable( isNodesMovable ); + } + else if( param == QString("dependency_tree_background_color") ) { + QColor c = resMgr->colorValue( section, param, QColor( 255, 255, 255 ) ); + setPrefBackgroundColor( c ); + } + else if( param == QString("dependency_tree_node_color") ) { + QColor c = resMgr->colorValue( section, param, QColor( 62, 180, 238 ) ); + setNodeColor( c ); + } + else if( param == QString("dependency_tree_main_node_color") ) { + QColor c = resMgr->colorValue( section, param, QColor( 238, 90, 125 ) ); + setMainNodeColor( c ); + } + else if( param == QString("dependency_tree_unpublish_node_color") ) { + QColor c = resMgr->colorValue( section, param, QColor( 255, 255, 255 ) ); + setUnpublishNodeColor( c ); + } + else if( param == QString("dependency_tree_select_node_color") ) { + QColor c = resMgr->colorValue( section, param, QColor( 237, 243, 58 ) ); + setSelectNodeColor( c ); + } + else if( param == QString("dependency_tree_arrow_color") ) { + QColor c = resMgr->colorValue( section, param, QColor( 0, 0, 130 ) ); + setArrowColor( c ); + } + else if( param == QString("dependency_tree_highlight_arrow_color") ) { + QColor c = resMgr->colorValue( section, param, QColor( 0, 0, 255 ) ); + setHighlightArrowColor( c ); + } + else if( param == QString("dependency_tree_select_arrow_color") ) { + QColor c = resMgr->colorValue( section, param, QColor( 255, 0, 0 ) ); + setSelectArrowColor( c ); + } +} + +//================================================================================= +// function : onRenameObject() +// purpose : update object name, having edited it in Object Browser +//================================================================================= +void DependencyTree_View::onRenameObject( const QString& theEntry ) +{ + if( DependencyTree_Object* object = getObjectByEntry( theEntry.toStdString() ) ) + object->updateName(); +} + +//================================================================================= +// function : parseTree() +// purpose : parse created model to initialize all nodes and arrows +//================================================================================= +void DependencyTree_View::parseTree() +{ + GEOMUtils::TreeModel::const_iterator i; + for( i = myTreeModel.begin(); i != myTreeModel.end(); i++ ) { + std::string objectEntry = i->first; + addNode( objectEntry ); + parseTreeWard( i->second.first ); + if( i->second.first.size() > myMaxUpwardLevelsNumber ) + myMaxUpwardLevelsNumber = i->second.first.size(); + parseTreeWard( i->second.second ); + if( i->second.second.size() > myMaxDownwardLevelsNumber ) + myMaxDownwardLevelsNumber = i->second.second.size(); + } + + for( i = myTreeModel.begin(); i != myTreeModel.end(); i++ ) { + DependencyTree_Object* Main_object = myTreeMap[ i->first ]; + if( i->second.first.size() > 0 ) { + GEOMUtils::LevelInfo Levelup = i->second.first.at(0); + GEOMUtils::LevelInfo::const_iterator node; + for( node = Levelup.begin(); node != Levelup.end(); node++ ) { + DependencyTree_Object* object = myTreeMap[ node->first ]; + addArrow( Main_object, object ); + } + } + parseTreeWardArrow( i->second.first ); + parseTreeWardArrow( i->second.second ); + } +} + +//================================================================================= +// function : parseTreeWard() +// purpose : parse tree ward to initialize all nodes of current ward +//================================================================================= +void DependencyTree_View::parseTreeWard( const GEOMUtils::LevelsList& theWard ) +{ + int levelsNumber = theWard.size(); + for( int level = 0; level < levelsNumber; level++ ) { + GEOMUtils::LevelInfo levelInfo = theWard[ level ]; + GEOMUtils::LevelInfo::const_iterator node; + for( node = levelInfo.begin(); node != levelInfo.end(); node++ ) + addNode( node->first ); + } +} + +//================================================================================= +// function : parseTreeWardArrow() +// purpose : parse tree ward to initialize all arrows of current ward +//================================================================================= +void DependencyTree_View::parseTreeWardArrow( const GEOMUtils::LevelsList& theWard) +{ + for( int j = 0; j < theWard.size(); j++ ) { + GEOMUtils::LevelInfo Level = theWard.at(j); + GEOMUtils::LevelInfo::const_iterator node; + for( node = Level.begin(); node != Level.end(); node++ ) { + DependencyTree_Object* object = myTreeMap[ node->first ]; + std::vector Links = node->second; + for( int link = 0; link < Links.size(); link++ ) { + DependencyTree_Object* LinkObject = myTreeMap[ Links[ link ] ]; + if( object && LinkObject ) + addArrow( object, LinkObject ); + } + } + } +} + +//================================================================================= +// function : addNode() +// purpose : add node to viewer +//================================================================================= +void DependencyTree_View::addNode( const std::string& theEntry ) +{ + if( !myTreeMap[theEntry] ) + myTreeMap[theEntry] = new DependencyTree_Object( theEntry ); +} + +//================================================================================= +// function : addArrow() +// purpose : add arrow to viewer +//================================================================================= +void DependencyTree_View::addArrow( DependencyTree_Object* startItem, DependencyTree_Object* endItem ) +{ + bool isFind = false; + + ArrowsInfo::const_iterator i; + for( i = myArrows.begin(); i != myArrows.end(); i++ ) { + DependencyTree_Arrow* arrow = i->second; + if( arrow->getStartItem() == startItem && arrow->getEndItem() == endItem ) + isFind = true; + else if( arrow->getStartItem() == endItem && arrow->getEndItem() == startItem ) { + arrow->setIsBiLink( true ); + isFind = true; + } + } + if( !isFind ) { + DependencyTree_Arrow *arrow = new DependencyTree_Arrow( startItem, endItem ); + myArrows[ std::pair( startItem, endItem ) ] = arrow; + } +} + +//================================================================================= +// function : drawTree() +// purpose : redraw dependency tree using existing model +//================================================================================= +void DependencyTree_View::drawTree() +{ + clearView( false ); + clearSelected(); + + // draw nodes on scene + std::map< std::string, int > entryLevelMap; + std::map< int, std::vector< std::string > > levelObjects; + int currentLevel; + int horDistance, verDistance; + GEOMUtils::TreeModel::const_reverse_iterator i; + for( i = myTreeModel.rbegin(); i != myTreeModel.rend(); i++ ) { + currentLevel = 0; + std::string objectEntry = i->first; + DependencyTree_Object* objectItem = myTreeMap[ objectEntry ]; + horDistance = 100 + int( objectItem->boundingRect().width() ); + verDistance = 3 * int( objectItem->boundingRect().height() ); + if( isItemAdded( objectItem ) ) + currentLevel = entryLevelMap[ objectEntry ]; + else { + addItem( objectItem ); + objectItem->unselect(); + entryLevelMap[ objectEntry ] = currentLevel; + levelObjects[ currentLevel ].push_back( objectEntry ); + } + objectItem->setIsMainObject( true ); + + if( myDisplayAscendants->isChecked() ) + drawWard( i->second.first, entryLevelMap, levelObjects, currentLevel, -1 ); + if( myDisplayDescendants->isChecked() ) + drawWard( i->second.second, entryLevelMap, levelObjects, currentLevel, 1 ); + } + + std::map< int, std::vector< std::string > >::const_iterator level; + for( level = levelObjects.begin(); level != levelObjects.end(); level++ ) { + int step = -horDistance * ( int(level->second.size()) - 1 ) / 2; + for( int objIter = 0; objIter < level->second.size(); objIter++ ) { + DependencyTree_Object* anObject = myTreeMap[ level->second.at( objIter ) ]; + anObject->setPos( step, verDistance * level->first ); + step += horDistance; + } + } + + // draw arrows on scene + GEOMUtils::TreeModel::const_iterator j; + for( j = myTreeModel.begin(); j != myTreeModel.end(); j++ ) { + DependencyTree_Object* Main_object = myTreeMap[ j->first ]; + if( j->second.first.size() > 0 ) { + GEOMUtils::LevelInfo Levelup = j->second.first.at(0); + if( myDisplayAscendants ->isChecked() ) { + GEOMUtils::LevelInfo::const_iterator node; + for( node = Levelup.begin(); node != Levelup.end(); node++ ) { + DependencyTree_Object* object = myTreeMap[ node->first ]; + DependencyTree_Arrow* arrow = + myArrows[ std::pair( Main_object, object )]; + if( arrow && !isItemAdded( arrow ) ) + addItem( arrow ); + } + } + } + if( myDisplayAscendants->isChecked() ) + drawWardArrows( j->second.first ); + if( myDisplayDescendants->isChecked() ) + drawWardArrows( j->second.second ); + } +} + +//================================================================================= +// function : drawWard() +// purpose : draw nodes of dependency tree ward (ascendant or descendant) +//================================================================================= +void DependencyTree_View::drawWard( const GEOMUtils::LevelsList& theWard, + std::map< std::string, int >& theEntryLevelMap, + std::map< int, std::vector< std::string > >& theLevelObjects, + int theCurrentLevel, const int theLevelStep ) +{ + for( int level = 0; level < theWard.size(); level++ ) { + if( level >= myLevelsNumber ) + return; + theCurrentLevel += theLevelStep; + GEOMUtils::LevelInfo levelInfo = theWard.at( level ); + GEOMUtils::LevelInfo::const_iterator node; + for( node = levelInfo.begin(); node != levelInfo.end(); node++ ) { + DependencyTree_Object* object = myTreeMap[ node->first ]; + if( object && !isItemAdded( object ) ) { + addItem( object ); + object->unselect(); + theEntryLevelMap[ node->first ] = theCurrentLevel; + theLevelObjects[ theCurrentLevel ].push_back( node->first ); + } + } + } +} + +//================================================================================= +// function : drawWardArrows() +// purpose : draw arrows of dependency tree ward (ascendant or descendant) +//================================================================================= +void DependencyTree_View::drawWardArrows( const GEOMUtils::LevelsList& theWard ) +{ + for( int j = 0; j < theWard.size(); j++ ) { + if( j >= myLevelsNumber ) + break; + GEOMUtils::LevelInfo Level = theWard.at(j); + GEOMUtils::LevelInfo::const_iterator node; + for( node = Level.begin(); node != Level.end(); node++ ) { + DependencyTree_Object* object = myTreeMap[ node->first ]; + GEOMUtils::NodeLinks Links = node->second; + for( int link = 0; link < Links.size(); link++ ) { + DependencyTree_Object* LinkObject = myTreeMap[ Links[ link ] ]; + if( isItemAdded( object ) && isItemAdded( LinkObject ) ) { + DependencyTree_Arrow* arrow = myArrows[ std::pair( object, LinkObject ) ]; + if( arrow && !isItemAdded( arrow ) ) + addItem( arrow ); + } + } + } + } +} + +//================================================================================= +// function : updateView() +// purpose : update viewer using created dependency tree model +//================================================================================= +void DependencyTree_View::updateView() +{ + if( !myIsUpdate ) + return; + + drawTree(); + fitAll(); +} + +//================================================================================= +// function : clearView() +// purpose : clear viewer and initialize all variables +//================================================================================= +void DependencyTree_View::clearView( bool isClearModel ) +{ + EntryObjectMap::const_iterator objectIter; + for( objectIter = myTreeMap.begin(); objectIter != myTreeMap.end(); objectIter++ ) { + if( DependencyTree_Object* object = objectIter->second ) + if( isItemAdded( object ) ) + removeItem( object ); + } + + ArrowsInfo::const_iterator arrowIter; + for( arrowIter = myArrows.begin(); arrowIter != myArrows.end(); arrowIter++ ) { + if( DependencyTree_Arrow* arrow = arrowIter->second ) + if( isItemAdded( arrow ) ) + removeItem( arrow ); + } + + if( isClearModel ) { + EntryObjectMap::const_iterator objectIter; + for( objectIter = myTreeMap.begin(); objectIter != myTreeMap.end(); objectIter++ ) { + if( DependencyTree_Object* object = objectIter->second ) + delete object; + } + + ArrowsInfo::const_iterator arrowIter; + for( arrowIter = myArrows.begin(); arrowIter != myArrows.end(); arrowIter++ ) { + if( DependencyTree_Arrow* arrow = arrowIter->second ) + delete arrow; + } + myTreeMap.clear(); + myArrows.clear(); + myTreeModel.clear(); + myLevelsNumber = 0; + myMaxDownwardLevelsNumber = 0; + myMaxUpwardLevelsNumber = 0; + myIsUpdate = true; + } +} + +//================================================================================= +// function : getNewTreeModel() +// purpose : get dependency tree model from engine +//================================================================================= +void DependencyTree_View::getNewTreeModel( bool theUseSelectedObject, bool theUseOB ) +{ + GEOM::string_array_var objectsEntry = new GEOM::string_array(); + int iter = 0; + + if( theUseSelectedObject ) { + if( theUseOB ) { + SALOME_ListIO mainObjects; + mySelectionMgr->selectedObjects( mainObjects ); + // create a list of selected object entry + objectsEntry->length( mainObjects.Extent() ); + for ( SALOME_ListIteratorOfListIO It( mainObjects ); It.More(); It.Next(), iter++ ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + if( !io->hasEntry() ) + continue; + GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_nil(); + geomObject = GEOMBase::ConvertIOinGEOMObject( io ); + QString entry = geomObject->GetEntry(); + objectsEntry[ iter ] = entry.toLatin1().constData(); + } + } + else { + objectsEntry->length( nbSelected() ); + for( initSelected(); moreSelected(); nextSelected(), iter++ ) + if( DependencyTree_Object* treeObject = dynamic_cast( selectedObject() ) ) + objectsEntry[ iter ] = treeObject->getEntry().c_str(); + } + myMainEntries = objectsEntry; + } + + // get string which describes dependency tree structure + SALOMEDS::TMPFile_var SeqFile = + GeometryGUI::GetGeomGen()->GetDependencyTree( myStudy, myMainEntries ); + char* buf = (char*)&SeqFile[0]; + + clearView( true ); + mySelectionMgr->clearSelected(); + + // get dependency tree structure + GEOMUtils::ConvertStringToTree( buf, myTreeModel ); + + parseTree(); +} + +//================================================================================= +// function : checkMaxLevelsNumber() +// purpose : calculate max levels number +//================================================================================= +int DependencyTree_View::checkMaxLevelsNumber() +{ + if( myDisplayAscendants->isChecked() && myDisplayDescendants->isChecked() ) + return myMaxUpwardLevelsNumber > myMaxDownwardLevelsNumber ? + myMaxUpwardLevelsNumber : myMaxDownwardLevelsNumber; + else if( myDisplayAscendants ->isChecked() ) + return myMaxUpwardLevelsNumber; + else if( myDisplayDescendants->isChecked() ) + return myMaxDownwardLevelsNumber; +} diff --git a/src/DependencyTree/DependencyTree_View.h b/src/DependencyTree/DependencyTree_View.h new file mode 100644 index 000000000..298933729 --- /dev/null +++ b/src/DependencyTree/DependencyTree_View.h @@ -0,0 +1,134 @@ +// 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 DEPENDENCYTREE_VIEW_H +#define DEPENDENCYTREE_VIEW_H + +// GEOM includes +#include +#include + +// GUI includes +#include +#include + +#include + +// QT includes +#include +#include +#include + +#include "DependencyTree.h" + +class DependencyTree_Object; +class DependencyTree_Arrow; +class DependencyTree_View; + +typedef std::map EntryObjectMap; +typedef std::map,DependencyTree_Arrow*> ArrowsInfo; + +class DEPENDENCYTREE_EXPORT DependencyTree_View: public GraphicsView_ViewPort +{ + Q_OBJECT + +public: + + DependencyTree_View( QWidget* = 0 ); + ~DependencyTree_View(); + + void init( GraphicsView_ViewFrame* ); + void updateModel( bool = true, bool = true ); + + void mouseMoveEvent(QMouseEvent* event); + void wheelEvent( QWheelEvent* event ); + + QString getViewName() const; + int getStudyId() const; + + DependencyTree_Object* getObjectByEntry( const std::string& ); + +public slots: + + void onRebuildModel(); + +private slots: + + void onUpdateModel(); + void onMoveNodes( bool ); + void onHierarchyType(); + void onPreferenceChanged( const QString&, const QString& ); + void onRenameObject( const QString& theEntry ); + +private: + + void parseTree(); + void parseTreeWard( const GEOMUtils::LevelsList& ); + void parseTreeWardArrow( const GEOMUtils::LevelsList& ); + + void addNode( const std::string& ); + void addArrow( DependencyTree_Object*, DependencyTree_Object* ); + + void drawTree(); + void drawWard( const GEOMUtils::LevelsList&, std::map< std::string, int >&, + std::map< int, std::vector< std::string > >&, int, const int ); + void drawWardArrows( const GEOMUtils::LevelsList& ); + + void updateView(); + void clearView( bool ); + + int checkMaxLevelsNumber(); + + void getNewTreeModel( bool = true, bool = true ); + + void setHierarchyType( const int ); + void setNodesMovable( const bool ); + void setPrefBackgroundColor( const QColor& ); + void setNodeColor( const QColor& ); + void setMainNodeColor( const QColor& ); + void setUnpublishNodeColor( const QColor& ); + void setSelectNodeColor( const QColor& ); + void setArrowColor( const QColor& ); + void setHighlightArrowColor( const QColor& ); + void setSelectArrowColor( const QColor& ); + + GEOMUtils::TreeModel myTreeModel; + + EntryObjectMap myTreeMap; + ArrowsInfo myArrows; + + int myLevelsNumber; + int myMaxDownwardLevelsNumber; + int myMaxUpwardLevelsNumber; + + QCheckBox* myNodesMovable; + QSpinBox* myHierarchyDepth; + QCheckBox* myDisplayAscendants; + QCheckBox* myDisplayDescendants; + QPushButton* updateButton; + + SALOMEDS::Study_var myStudy; + LightApp_SelectionMgr* mySelectionMgr; + GEOM::string_array_var myMainEntries; + + bool myIsUpdate; + +}; + +#endif diff --git a/src/DependencyTree/DependencyTree_ViewModel.cxx b/src/DependencyTree/DependencyTree_ViewModel.cxx new file mode 100644 index 000000000..750de6f80 --- /dev/null +++ b/src/DependencyTree/DependencyTree_ViewModel.cxx @@ -0,0 +1,137 @@ +// 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 "DependencyTree_ViewModel.h" +#include "DependencyTree_View.h" + +// GUI includes +#include +#include +#include +#include +#include + +// GEOM includes +#include +#include + +// QT includes +#include + +DependencyTree_ViewModel::DependencyTree_ViewModel( const QString& title ) +: GraphicsView_Viewer( title ) +{ +} + +DependencyTree_ViewModel::DependencyTree_ViewModel( const QString& title, QWidget* w ) +: GraphicsView_Viewer( title, w ) +{ +} + +DependencyTree_ViewModel::~DependencyTree_ViewModel() +{ +} + +//================================================================================= +// function : onShowSelected() +// purpose : slot for showing selected objects in OCC Viewer +//================================================================================= +void DependencyTree_ViewModel::onShowSelected() +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + + app->getViewManager( OCCViewer_Viewer::Type(), /*create=*/ true ); + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + GEOM_Displayer disp( appStudy ); + + OCCViewer_ViewManager* anOCCVM = ( OCCViewer_ViewManager* ) app->getViewManager( OCCViewer_Viewer::Type(), /*create=*/ true ); + + if ( SUIT_ViewModel* viewModel = anOCCVM->getViewModel() ) { + if ( SALOME_View* viewFrame = dynamic_cast( viewModel ) ) { + SALOME_ListIteratorOfListIO Iter( aSelList ); + for ( ; Iter.More(); Iter.Next() ) + disp.Display( Iter.Value(), false, viewFrame ); + viewFrame->Repaint(); + } + } +} + +//================================================================================= +// function : onShowOnlySelected() +// purpose : slot for showing only selected objects in OCC Viewer +//================================================================================= +void DependencyTree_ViewModel::onShowOnlySelected() +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO aSelList; + aSelMgr->selectedObjects( aSelList ); + + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + GEOM_Displayer disp( appStudy ); + + OCCViewer_ViewManager* anOCCVM = (OCCViewer_ViewManager*) app->getViewManager( OCCViewer_Viewer::Type(), /*create=*/ true ); + + if ( SUIT_ViewModel* viewModel = anOCCVM->getViewModel() ) { + if ( SALOME_View* viewFrame = dynamic_cast( viewModel ) ) { + disp.EraseAll( true, false, viewFrame ); + SALOME_ListIteratorOfListIO Iter( aSelList ); + for ( ; Iter.More(); Iter.Next() ) + disp.Display( Iter.Value(), false, viewFrame ); + viewFrame->Repaint(); + } + } +} + +//================================================================================= +// function : contextMenuPopup() +// purpose : process calling of context menu popup +//================================================================================= +void DependencyTree_ViewModel::contextMenuPopup( QMenu* theMenu ) +{ + GraphicsView_Viewer::contextMenuPopup( theMenu ); + + if( DependencyTree_View* viewPort = dynamic_cast( getActiveViewPort() ) ) + { + int aNbSelected = viewPort->nbSelected(); + if( aNbSelected > 0 ) { + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + GeometryGUI* aGeomGUI = dynamic_cast( app->module( "Geometry" ) ); + theMenu->clear(); + theMenu->addAction( tr( "MEN_DISPLAY" ), this, SLOT( onShowSelected() ) ); + theMenu->addAction( tr( "MEN_DISPLAY_ONLY" ), this, SLOT( onShowOnlySelected() ) ); + theMenu->addAction( tr( "MEN_REBUILD_THE_TREE"), viewPort, SLOT( onRebuildModel() ) ); + theMenu->addSeparator(); + theMenu->addAction( aGeomGUI->action( GEOMOp::OpReduceStudy ) ); + } + } +} diff --git a/src/DependencyTree/DependencyTree_ViewModel.h b/src/DependencyTree/DependencyTree_ViewModel.h new file mode 100644 index 000000000..9bac8cbce --- /dev/null +++ b/src/DependencyTree/DependencyTree_ViewModel.h @@ -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 +// + +#ifndef DEPENDENCYTREE_VIEWMODEL_H +#define DEPENDENCYTREE_VIEWMODEL_H + +#include + +#include "DependencyTree.h" + +class DEPENDENCYTREE_EXPORT DependencyTree_ViewModel: public GraphicsView_Viewer +{ + + Q_OBJECT + +public: + + DependencyTree_ViewModel( const QString& title ); + DependencyTree_ViewModel( const QString& title, QWidget* w ); + ~DependencyTree_ViewModel(); + + virtual void contextMenuPopup( QMenu* ); + +private slots: + + void onShowSelected(); + void onShowOnlySelected(); + +}; + +#endif diff --git a/src/DependencyTree/resources/DependencyTree_msg_en.ts b/src/DependencyTree/resources/DependencyTree_msg_en.ts new file mode 100644 index 000000000..c1c04a16d --- /dev/null +++ b/src/DependencyTree/resources/DependencyTree_msg_en.ts @@ -0,0 +1,44 @@ + + + + + DependencyTree_View + + DEPENDENCY_TREE + Dependency Tree + + + MOVE_NODES + Move nodes + + + HIERARCHY_DEPTH + Hierarchy depth + + + DISPLAY_ASCENDANTS + Display ascendants + + + DISPLAY_DESCENDANTS + Display descendants + + + SHOW_ALL + Show all + + + UPDATE + Update + + DependencyTree_ViewModel + + MEN_REBUILD_THE_TREE + Rebuild the tree + + + MEN_REDUCE_STUDY + Reduce study + + + diff --git a/src/DependencyTree/resources/DependencyTree_msg_fr.ts b/src/DependencyTree/resources/DependencyTree_msg_fr.ts new file mode 100644 index 000000000..ffeb404bc --- /dev/null +++ b/src/DependencyTree/resources/DependencyTree_msg_fr.ts @@ -0,0 +1,44 @@ + + + + + DependencyTree_View + + DEPENDENCY_TREE + Dependency Tree + + + MOVE_NODES + Move nodes + + + HIERARCHY_DEPTH + Hierarchy depth + + + DISPLAY_ASCENDANTS + Display ascendants + + + DISPLAY_DESCENDANTS + Display descendants + + + SHOW_ALL + Show all + + + UPDATE + Update + + DependencyTree_ViewModel + + MEN_REBUILD_THE_TREE + Rebuild the tree + + + MEN_REDUCE_STUDY + Reduce study + + + diff --git a/src/DependencyTree/resources/DependencyTree_msg_ja.ts b/src/DependencyTree/resources/DependencyTree_msg_ja.ts new file mode 100644 index 000000000..642f04c6a --- /dev/null +++ b/src/DependencyTree/resources/DependencyTree_msg_ja.ts @@ -0,0 +1,44 @@ + + + + + DependencyTree_View + + DEPENDENCY_TREE + Dependency Tree + + + MOVE_NODES + Move nodes + + + HIERARCHY_DEPTH + Hierarchy depth + + + DISPLAY_ASCENDANTS + Display ascendants + + + DISPLAY_DESCENDANTS + Display descendants + + + SHOW_ALL + Show all + + + UPDATE + Update + + DependencyTree_ViewModel + + MEN_REBUILD_THE_TREE + Rebuild the tree + + + MEN_REDUCE_STUDY + Reduce study + + + \ No newline at end of file diff --git a/src/DependencyTree/resources/tree_view_dump.png b/src/DependencyTree/resources/tree_view_dump.png new file mode 100644 index 000000000..b02616f29 Binary files /dev/null and b/src/DependencyTree/resources/tree_view_dump.png differ diff --git a/src/DependencyTree/resources/tree_view_fitall.png b/src/DependencyTree/resources/tree_view_fitall.png new file mode 100644 index 000000000..386c966d1 Binary files /dev/null and b/src/DependencyTree/resources/tree_view_fitall.png differ diff --git a/src/DependencyTree/resources/tree_view_fitarea.png b/src/DependencyTree/resources/tree_view_fitarea.png new file mode 100644 index 000000000..e83d023a3 Binary files /dev/null and b/src/DependencyTree/resources/tree_view_fitarea.png differ diff --git a/src/DependencyTree/resources/tree_view_fitselect.png b/src/DependencyTree/resources/tree_view_fitselect.png new file mode 100755 index 000000000..e52598d7b Binary files /dev/null and b/src/DependencyTree/resources/tree_view_fitselect.png differ diff --git a/src/DependencyTree/resources/tree_view_glpan.png b/src/DependencyTree/resources/tree_view_glpan.png new file mode 100644 index 000000000..28ab547ea Binary files /dev/null and b/src/DependencyTree/resources/tree_view_glpan.png differ diff --git a/src/DependencyTree/resources/tree_view_pan.png b/src/DependencyTree/resources/tree_view_pan.png new file mode 100644 index 000000000..ec56cacc7 Binary files /dev/null and b/src/DependencyTree/resources/tree_view_pan.png differ diff --git a/src/DependencyTree/resources/tree_view_reset.png b/src/DependencyTree/resources/tree_view_reset.png new file mode 100644 index 000000000..66f81e604 Binary files /dev/null and b/src/DependencyTree/resources/tree_view_reset.png differ diff --git a/src/DependencyTree/resources/tree_view_zoom.png b/src/DependencyTree/resources/tree_view_zoom.png new file mode 100644 index 000000000..386c966d1 Binary files /dev/null and b/src/DependencyTree/resources/tree_view_zoom.png differ diff --git a/src/DisplayGUI/DisplayGUI.cxx b/src/DisplayGUI/DisplayGUI.cxx index fcd23e997..29f51945d 100644 --- a/src/DisplayGUI/DisplayGUI.cxx +++ b/src/DisplayGUI/DisplayGUI.cxx @@ -40,7 +40,6 @@ #include #include -#include #include #include @@ -136,6 +135,12 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) ( GetVectorMode() ? tr("MEN_VECTOR_MODE_ON") : tr( "MEN_VECTOR_MODE_OFF" ) ); getGeometryGUI()->menuMgr()->update(); break; + case GEOMOp::OpSwitchVertices: // MENU VIEW - DISPLAY MODE - SHOW/HIDE VERTICES + SetVerticesMode(!GetVerticesMode()); + getGeometryGUI()->action( GEOMOp::OpSwitchVertices )->setText + ( GetVerticesMode() ? tr("MEN_VERTICES_MODE_ON") : tr( "MEN_VERTICES_MODE_OFF" ) ); + getGeometryGUI()->menuMgr()->update(); + break; case GEOMOp::OpWireframe: // POPUP MENU - DISPLAY MODE - WIREFRAME ChangeDisplayMode( 0 ); break; @@ -151,6 +156,9 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) case GEOMOp::OpVectors: // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION ChangeDisplayMode( 4 ); break; + case GEOMOp::OpVertices: // POPUP MENU - DISPLAY MODE - SHOW VERTICES + ChangeDisplayMode( 5 ); + break; default: app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); break; @@ -485,6 +493,52 @@ int DisplayGUI::GetVectorMode( SUIT_ViewWindow* viewWindow ) return viewWindow->property( "VectorsMode" ).toBool(); } +//===================================================================================== +// function : DisplayGUI::SetVerticesMode() +// purpose : Set vertices mode for the viewer +//===================================================================================== +void DisplayGUI::SetVerticesMode( const bool mode, SUIT_ViewWindow* viewWindow ) +{ + SUIT_OverrideCursor(); + + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return; + + SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + if ( !aStudy ) return; + + if ( !viewWindow ) + viewWindow = app->desktop()->activeWindow(); + + GEOM_Displayer displayer( aStudy ); + + viewWindow->setProperty( "VerticesMode", mode ); + + int aMgrId = viewWindow->getViewManager()->getGlobalId(); + + SALOME_ListIO anIOlst; + displayer.GetActiveView()->GetVisible( anIOlst ); + + for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::Vertices ), mode ); + displayer.Redisplay( io, false ); + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); +} + +//===================================================================================== +// function : DisplayGUI::GetVerticesMode() +// purpose : Get the "show vertices" mode of the viewer +//===================================================================================== +int DisplayGUI::GetVerticesMode( SUIT_ViewWindow* viewWindow ) +{ + if ( !viewWindow ) + viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow(); + return viewWindow->property( "VerticesMode" ).toBool(); +} + //===================================================================================== // function : DisplayGUI::ChangeDisplayMode() // purpose : Set display mode for selected objects in the viewer given @@ -516,6 +570,8 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow QVariant v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), QVariant() ); bool vectorMode = v.isValid() ? !v.toBool() : false; + v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Vertices ), QVariant() ); + bool verticesMode = v.isValid() ? !v.toBool() : false; for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { Handle( SALOME_InteractiveObject ) io = It.Value(); @@ -525,6 +581,9 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow else if ( mode == 4 ) { aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), vectorMode ); } + else if ( mode == 5 ) { + aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Vertices ), verticesMode ); + } displayer.Redisplay( io, false ); } displayer.UpdateViewer(); diff --git a/src/DisplayGUI/DisplayGUI.h b/src/DisplayGUI/DisplayGUI.h index 64207c557..5ad5933c7 100644 --- a/src/DisplayGUI/DisplayGUI.h +++ b/src/DisplayGUI/DisplayGUI.h @@ -69,6 +69,12 @@ public: int GetVectorMode( SUIT_ViewWindow* = 0 ); // Invert vector mode ( shadin <-> wireframe ) for the viewer + // VERTICES MODE methods + // Set vertices mode for the viewer + void SetVerticesMode( const bool, SUIT_ViewWindow* = 0 ); + // Get vertices mode of the viewer + int GetVerticesMode( SUIT_ViewWindow* = 0 ); + // Set display mode for selected objects in the viewer given // (current viewer if = 0 ) void ChangeDisplayMode( const int, SUIT_ViewWindow* = 0 ); diff --git a/src/DlgRef/CMakeLists.txt b/src/DlgRef/CMakeLists.txt index 3c365438f..29874d83c 100755 --- a/src/DlgRef/CMakeLists.txt +++ b/src/DlgRef/CMakeLists.txt @@ -77,6 +77,7 @@ SET(_uic_files DlgRef_2Sel2Spin_QTD.ui DlgRef_2Sel3Spin2Rb_QTD.ui DlgRef_2Sel3Spin_QTD.ui + DlgRef_2Sel3Spin1Check_QTD.ui DlgRef_2SelExt_QTD.ui DlgRef_2Sel_QTD.ui DlgRef_2Spin_QTD.ui @@ -92,6 +93,7 @@ SET(_uic_files DlgRef_3Sel4Spin2Check_QTD.ui DlgRef_3Sel_QTD.ui DlgRef_3Spin1Check_QTD.ui + DlgRef_3Spin1CheckCyl_QTD.ui DlgRef_3Spin_QTD.ui DlgRef_4Sel1List1Check_QTD.ui DlgRef_4Sel1List_QTD.ui @@ -99,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 9a6efd718..1e242cb95 100644 --- a/src/DlgRef/DlgRef.cxx +++ b/src/DlgRef/DlgRef.cxx @@ -470,6 +470,20 @@ DlgRef_2Sel2Spin2Push::~DlgRef_2Sel2Spin2Push() { } +////////////////////////////////////////// +// DlgRef_2Sel3Spin1Check +////////////////////////////////////////// + +DlgRef_2Sel3Spin1Check::DlgRef_2Sel3Spin1Check( QWidget* parent, Qt::WindowFlags f ) +: QWidget( parent, f ) +{ + setupUi( this ); +} + +DlgRef_2Sel3Spin1Check::~DlgRef_2Sel3Spin1Check() +{ +} + ////////////////////////////////////////// // DlgRef_2Sel3Spin2Rb ////////////////////////////////////////// @@ -756,6 +770,20 @@ DlgRef_3Spin1Check::~DlgRef_3Spin1Check() { } +////////////////////////////////////////// +// DlgRef_3Spin1CheckCyl +////////////////////////////////////////// + +DlgRef_3Spin1CheckCyl::DlgRef_3Spin1CheckCyl( QWidget* parent, Qt::WindowFlags f ) +: QWidget( parent, f ) +{ + setupUi( this ); +} + +DlgRef_3Spin1CheckCyl::~DlgRef_3Spin1CheckCyl() +{ +} + ////////////////////////////////////////// // DlgRef_3Spin ////////////////////////////////////////// @@ -870,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 c68358d11..918183677 100644 --- a/src/DlgRef/DlgRef.h +++ b/src/DlgRef/DlgRef.h @@ -548,6 +548,22 @@ public: ~DlgRef_2Sel2Spin2Push(); }; +////////////////////////////////////////// +// DlgRef_2Sel3Spin1Check +////////////////////////////////////////// + +#include "ui_DlgRef_2Sel3Spin1Check_QTD.h" + +class DLGREF_EXPORT DlgRef_2Sel3Spin1Check : public QWidget, + public Ui::DlgRef_2Sel3Spin1Check_QTD +{ + Q_OBJECT + +public: + DlgRef_2Sel3Spin1Check( QWidget* = 0, Qt::WindowFlags = 0 ); + ~DlgRef_2Sel3Spin1Check(); +}; + ////////////////////////////////////////// // DlgRef_2Sel3Spin2Rb ////////////////////////////////////////// @@ -826,6 +842,22 @@ public: ~DlgRef_3Spin1Check(); }; +////////////////////////////////////////// +// DlgRef_3Spin1CheckCyl +////////////////////////////////////////// + +#include "ui_DlgRef_3Spin1CheckCyl_QTD.h" + +class DLGREF_EXPORT DlgRef_3Spin1CheckCyl : public QWidget, + public Ui::DlgRef_3Spin1CheckCyl_QTD +{ + Q_OBJECT + +public: + DlgRef_3Spin1CheckCyl( QWidget* = 0, Qt::WindowFlags = 0 ); + ~DlgRef_3Spin1CheckCyl(); +}; + ////////////////////////////////////////// // DlgRef_3Spin ////////////////////////////////////////// @@ -940,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/DlgRef/DlgRef_2Sel3Spin1Check_QTD.ui b/src/DlgRef/DlgRef_2Sel3Spin1Check_QTD.ui new file mode 100644 index 000000000..07489104b --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel3Spin1Check_QTD.ui @@ -0,0 +1,189 @@ + + + DlgRef_2Sel3Spin1Check_QTD + + + + 0 + 0 + 323 + 223 + + + + + + + + 0 + + + 6 + + + + + + + + + 9 + + + 6 + + + + + + 0 + 0 + + + + TL4 + + + false + + + + + + + + 0 + 0 + + + + TL3 + + + false + + + + + + + + 0 + 0 + + + + TL1 + + + false + + + + + + + + + + + 0 + 0 + + + + TL2 + + + false + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + TL5 + + + false + + + + + + + CB + + + + + + + + + + qPixmapFromMimeSource + + + SalomeApp_DoubleSpinBox + QDoubleSpinBox +
    SalomeApp_DoubleSpinBox.h
    +
    +
    + + PushButton1 + LineEdit1 + PushButton2 + LineEdit2 + SpinBox_DX + SpinBox_DY + SpinBox_DZ + checkBox + + + +
    diff --git a/src/DlgRef/DlgRef_3Spin1CheckCyl_QTD.ui b/src/DlgRef/DlgRef_3Spin1CheckCyl_QTD.ui new file mode 100644 index 000000000..7307c920b --- /dev/null +++ b/src/DlgRef/DlgRef_3Spin1CheckCyl_QTD.ui @@ -0,0 +1,124 @@ + + + DlgRef_3Spin1CheckCyl_QTD + + + + 0 + 0 + 611 + 154 + + + + + + + + 0 + + + 0 + + + + + true + + + + + + + 9 + + + 6 + + + + + + 0 + 0 + + + + TL3 + + + false + + + + + + + + 0 + 0 + + + + TL2 + + + false + + + + + + + + 0 + 0 + + + + TL1 + + + false + + + + + + + + + + + + + + + + CB + + + + + + + + + + qPixmapFromMimeSource + + + SalomeApp_DoubleSpinBox + QDoubleSpinBox +
    SalomeApp_DoubleSpinBox.h
    +
    +
    + + SpinBox_DX + SpinBox_DY + SpinBox_DZ + checkBox + + + +
    diff --git a/src/EntityGUI/CMakeLists.txt b/src/EntityGUI/CMakeLists.txt index 865678ad3..79668add1 100755 --- a/src/EntityGUI/CMakeLists.txt +++ b/src/EntityGUI/CMakeLists.txt @@ -40,6 +40,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GEOMGUI ${PROJECT_SOURCE_DIR}/src/GEOMBase ${PROJECT_SOURCE_DIR}/src/SKETCHER + ${PROJECT_SOURCE_DIR}/src/CurveCreator ${PROJECT_SOURCE_DIR}/src/ShapeRecognition ${PROJECT_SOURCE_DIR}/src/DlgRef ${PROJECT_BINARY_DIR}/src/DlgRef @@ -65,6 +66,7 @@ SET(_link_LIBRARIES GEOM DlgRef GEOMSketcher + CurveCreator ) # optional sources @@ -103,6 +105,7 @@ SET(EntityGUI_HEADERS EntityGUI.h EntityGUI_Widgets.h EntityGUI_SketcherDlg.h + EntityGUI_PolylineDlg.h EntityGUI_3DSketcherDlg.h EntityGUI_IsolineDlg.h EntityGUI_SubShapeDlg.h @@ -115,6 +118,7 @@ SET(_moc_HEADERS EntityGUI_Widgets.h EntityGUI_FieldDlg.h EntityGUI_SketcherDlg.h + EntityGUI_PolylineDlg.h EntityGUI_3DSketcherDlg.h EntityGUI_IsolineDlg.h EntityGUI_SubShapeDlg.h @@ -135,6 +139,7 @@ SET(EntityGUI_SOURCES EntityGUI_Widgets.cxx EntityGUI_FieldDlg.cxx EntityGUI_SketcherDlg.cxx + EntityGUI_PolylineDlg.cxx EntityGUI_3DSketcherDlg.cxx EntityGUI_IsolineDlg.cxx EntityGUI_SubShapeDlg.cxx diff --git a/src/EntityGUI/EntityGUI.cxx b/src/EntityGUI/EntityGUI.cxx index 81e1b6272..95e5f1565 100644 --- a/src/EntityGUI/EntityGUI.cxx +++ b/src/EntityGUI/EntityGUI.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -59,6 +59,7 @@ #include "EntityGUI_FeatureDetectorDlg.h" // Feature Detection #include "EntityGUI_PictureImportDlg.h" // Import Picture in viewer #include "EntityGUI_FieldDlg.h" // Create/Edit Field +#include "EntityGUI_PolylineDlg.h" // Create/Edit 2d polyline #include "GEOMImpl_Types.hxx" @@ -188,6 +189,10 @@ bool EntityGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) SUIT_MessageBox::warning(parent, tr("WRN_WARNING"), tr("NO_FIELD")); break; } + case GEOMOp::Op2dPolylineEditor: // POLYLINE EDITOR + getGeometryGUI()->ActiveWorkingPlane(); + aDlg = new EntityGUI_PolylineDlg( getGeometryGUI(), parent ); + break; default: app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; @@ -354,11 +359,7 @@ void EntityGUI::DisplaySimulationShape( const TopoDS_Shape& S1, const TopoDS_Sha try { if ( !S1.IsNull() ) { /* erase any previous */ -#if OCC_VERSION_LARGE <= 0x06060000 - ic->Erase( mySimulationShape1, Standard_True, Standard_False ); -#else ic->Erase( mySimulationShape1, Standard_True ); -#endif ic->ClearPrs( mySimulationShape1 ); mySimulationShape1 = new AIS_Shape( TopoDS_Shape() ); @@ -370,11 +371,7 @@ void EntityGUI::DisplaySimulationShape( const TopoDS_Shape& S1, const TopoDS_Sha mySimulationShape1->UnsetColor(); } if ( !S2.IsNull() ) { -#if OCC_VERSION_LARGE <= 0x06060000 - ic->Erase( mySimulationShape2, Standard_True, Standard_False ); -#else ic->Erase( mySimulationShape2, Standard_True ); -#endif ic->ClearPrs( mySimulationShape2 ); mySimulationShape2 = new AIS_Shape( TopoDS_Shape() ); @@ -418,13 +415,8 @@ void EntityGUI::EraseSimulationShape() if ( vw->getViewManager()->getType() == OCCViewer_Viewer::Type() ) { OCCViewer_Viewer* v3d = ( (OCCViewer_ViewManager*)( vw->getViewManager() ) )->getOCCViewer(); Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); -#if OCC_VERSION_LARGE <= 0x06060000 - ic->Erase( mySimulationShape1, Standard_True, Standard_False ); - ic->Erase( mySimulationShape2, Standard_True, Standard_False ); -#else ic->Erase( mySimulationShape1, Standard_True ); ic->Erase( mySimulationShape2, Standard_True ); -#endif ic->ClearPrs( mySimulationShape1 ); ic->ClearPrs( mySimulationShape2 ); ic->UpdateCurrentViewer(); diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx index 609b7e8a3..09b96a294 100755 --- a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx @@ -67,7 +67,6 @@ #include #include #include -#if OCC_VERSION_LARGE > 0x06050300 #include #include #include @@ -75,7 +74,6 @@ #include #include #include -#endif // OCC_VERSION_LARGE > 0x06050300 // This include must be *AFTER* SOCC_ViewModel.h because // of the constant ROTATE which is a #define in @@ -103,7 +101,6 @@ private: bool& myLock; }; -#if OCC_VERSION_LARGE > 0x06050300 DEFINE_STANDARD_HANDLE(AIS_Text, AIS_InteractiveObject) class AIS_Text:public AIS_InteractiveObject @@ -197,7 +194,6 @@ void AIS_Text::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentation asp->Aspect()->SetTextFontAspect(aFontAspect); Prs3d_Text::Draw(aPresentation, asp, aText, aPosition); }; -#endif // OCC_VERSION_LARGE > 0x06050300 bool isSame (double d1, double d2) { @@ -330,9 +326,7 @@ void EntityGUI_3DSketcherDlg::Init() SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); myAnglePrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); myLengthPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); -#if OCC_VERSION_LARGE > 0x06050300 myTextPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); -#endif // OCC_VERSION_LARGE > 0x06050300 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); @@ -1626,7 +1620,6 @@ void EntityGUI_3DSketcherDlg::displayText ( std::string theText, gp_Pnt P, bool store ) { -#if OCC_VERSION_LARGE > 0x06050300 SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); Handle(AIS_Text) anIO = new AIS_Text(TCollection_ExtendedString(theText.c_str()), P); @@ -1653,7 +1646,7 @@ void EntityGUI_3DSketcherDlg::displayText ( std::string theText, GEOMBase_Helper::displayPreview(aSPrs, true, true); } } -#endif // OCC_VERSION_LARGE > 0x06050300 + } //================================================================ @@ -1714,7 +1707,7 @@ Handle(AIS_AngleDimension) EntityGUI_3DSketcherDlg::createAISAngleDimension(doub Handle(AIS_AngleDimension) anIO = new AIS_AngleDimension( P1, P0, P2 ); - anIO->SetCustomValue( theAngle ); + //anIO->SetCustomValue( theAngle ); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); int w = resMgr->integerValue( "Geometry", "measures_line_width", 1 ); diff --git a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx index 9ac38a334..5636e4a18 100644 --- a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx +++ b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx @@ -46,7 +46,7 @@ #include #include -#include +#include #include @@ -83,12 +83,6 @@ enum{ LINES }; -enum { - RADIO_BUTTONS, - MSG, - PUSH_BUTTON, -}; - enum { KERNEL_SIZE, FIND_CONTOURS_METHOD, @@ -859,11 +853,11 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) double u_v_det = (it->x - it_previous->x) * (it_next->y - it->y) - (it->y - it_previous->y) * (it_next->x - it->x); - double norme_u = sqrt ( (it->x - it_previous->x)*(it->x - it_previous->x) + - (it->y - it_previous->y)*(it->y - it_previous->y) ); + double norme_u = sqrt ( double(it->x - it_previous->x) * double(it->x - it_previous->x) + + double(it->y - it_previous->y) * double(it->y - it_previous->y) ); - double norme_v = sqrt ( (it->x - it_next->x)*(it->x - it_next->x) + - (it->y - it_next->y)*(it->y - it_next->y) ); + double norme_v = sqrt ( double(it->x - it_next->x) * double(it->x - it_next->x) + + double(it->y - it_next->y) * double(it->y - it_next->y) ); double u_v_sinus = u_v_det / (norme_u * norme_v); diff --git a/src/EntityGUI/EntityGUI_FieldDlg.cxx b/src/EntityGUI/EntityGUI_FieldDlg.cxx index cead457e7..d940f5040 100644 --- a/src/EntityGUI/EntityGUI_FieldDlg.cxx +++ b/src/EntityGUI/EntityGUI_FieldDlg.cxx @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/EntityGUI/EntityGUI_PolylineDlg.cxx b/src/EntityGUI/EntityGUI_PolylineDlg.cxx new file mode 100644 index 000000000..50c12462a --- /dev/null +++ b/src/EntityGUI/EntityGUI_PolylineDlg.cxx @@ -0,0 +1,670 @@ +// Copyright (C) 2007-2013 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. +// +// 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 "EntityGUI_PolylineDlg.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +//#define SET_PLANE + +//================================================================================= +// function : Constructor +// purpose : +//================================================================================= +EntityGUI_PolylineDlg::EntityGUI_PolylineDlg + (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl) + : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ), + myCurve (0), + myEditorWidget (0), + myAddElementBox (0), + myPlnComboBox (0), + myPlnButton (0), + myPlnSelButton (0), + myWPlaneLineEdit (0), + myPolylineSelButton (0), + myPolylineEdit (0), + myEditCurrentArgument (0) +{ + QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE"))); + QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("POLYLINE_DLG_TITLE")); + + /***************************************************************/ + mainFrame()->GroupConstructors->setTitle(tr("POLYLINE_TITLE")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); + mainFrame()->RadioButton3->close(); + + QGroupBox *aGroupBox1 = new QGroupBox(tr("GEOM_CS"), this); + QGridLayout *aPlaneLayout = new QGridLayout(aGroupBox1); + + aPlaneLayout->setSpacing(6); + aPlaneLayout->setMargin(11); + + myPlnComboBox = new QComboBox(aGroupBox1); + aPlaneLayout->addWidget(myPlnComboBox, 0, 0, 1, 3); + + myPlnButton = new QPushButton (aGroupBox1); + myPlnButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) ); + aPlaneLayout->addWidget(myPlnButton, 0, 3); + +#ifdef SET_PLANE + QLabel *aPlaneLbl = new QLabel(tr("GEOM_PLANE"), aGroupBox1); + + myPlnSelButton = new QPushButton (aGroupBox1); + myPlnSelButton->setIcon(image1); + myWPlaneLineEdit = new QLineEdit (aGroupBox1); + myWPlaneLineEdit->setReadOnly(true); +#endif + + QLabel *aPolylineLbl = new QLabel(tr("POLYLINE_IMPORT"), aGroupBox1); + + myPolylineSelButton = new QPushButton (aGroupBox1); + myPolylineSelButton->setIcon(image1); + myPolylineEdit = new QLineEdit (aGroupBox1); + myPolylineEdit->setReadOnly(true); + +#ifdef SET_PLANE + aPlaneLayout->addWidget(aPlaneLbl, 1, 0); + aPlaneLayout->addWidget(myPlnSelButton, 1, 1); + aPlaneLayout->addWidget(myWPlaneLineEdit, 1, 2, 1, 2); +#endif + aPlaneLayout->addWidget(aPolylineLbl, 2, 0); + aPlaneLayout->addWidget(myPolylineSelButton, 2, 1); + aPlaneLayout->addWidget(myPolylineEdit, 2, 2, 1, 2); + + aPlaneLayout->setColumnStretch(2, 1); + + myCurve = new CurveCreator_Curve( CurveCreator::Dim2d ); + myEditorWidget = new CurveCreator_Widget (centralWidget(), myCurve); + myAddElementBox = new QGroupBox (tr("POLYLINE_ADD_SECTION"), centralWidget()); + + QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox ); + + anAddElementLayout->setMargin( 0 ); + anAddElementLayout->setSpacing( 6 ); + + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); + + layout->setMargin( 0 ); + layout->setSpacing( 6 ); + layout->addWidget( aGroupBox1 ); + layout->addWidget( myEditorWidget ); + layout->addWidget( myAddElementBox ); + + /***************************************************************/ + + setHelpFileName( "create_polyline_page.html" ); + + /* Initialisations */ + Init(); +} + +//================================================================================= +// function : Destructor +// purpose : +//================================================================================= +EntityGUI_PolylineDlg::~EntityGUI_PolylineDlg() +{ + delete myCurve; +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::Init() +{ + initName(tr("POLYLINE_NAME")); + + SalomeApp_Application *anApp = myGeomGUI->getApp(); + OCCViewer_ViewManager *aViewManager = dynamic_cast + (anApp->getViewManager(OCCViewer_Viewer::Type(), true)); + LightApp_SelectionMgr *aSelMgr = myGeomGUI->getApp()->selectionMgr(); + + myEditorWidget->setOCCViewer(aViewManager ? aViewManager->getOCCViewer() : 0); + + // Init the list of local coordinate system + gp_Pnt aPnt(0., 0., 0.); + gp_Dir aDirN(0., 0., 1.); + gp_Dir aDirX(1., 0., 0.); + gp_Ax3 aLCS(aPnt, aDirN, aDirX); + + //add Global CS + myPlnComboBox->addItem(tr("GEOM_GCS"), false); + myWPlaneList.push_back(GEOM::GeomObjPtr()); + myLCSList.push_back(aLCS); + + connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + +#ifdef SET_PLANE + connect(myPlnSelButton, SIGNAL(clicked()), + this, SLOT(SetEditCurrentArgument())); +#endif + connect(myPolylineSelButton, SIGNAL(clicked()), + this, SLOT(SetEditCurrentArgument())); + connect(aSelMgr, SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + connect(myEditorWidget, SIGNAL(subOperationStarted(QWidget*, bool)), + this, SLOT(processStartedSubOperation(QWidget*, bool))); + connect(myEditorWidget, SIGNAL(subOperationFinished(QWidget*)), + this, SLOT(processFinishedSubOperation(QWidget*))); + connect(myEditorWidget, SIGNAL(curveModified()), + this, SLOT(onUpdatePreview())); +#ifdef SET_PLANE + connect(myPlnComboBox, SIGNAL(activated(int)), + this, SLOT(ActivateLocalCS())); + connect(myPlnButton, SIGNAL(clicked()), + this, SLOT(ActivateLocalCS())); +#endif + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + myAddElementBox->hide(); + myPolylineSelButton->click(); + SelectionIntoArgument(); +} + +//================================================================================= +// function : Clear +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::Clear() +{ + delete myCurve; + + myCurve = new CurveCreator_Curve( CurveCreator::Dim2d ); + myEditorWidget->setCurve(myCurve); +} + +//================================================================================= +// function : GetCurveParams +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::GetCurveParams(GEOM::ListOfListOfDouble &theCoords, + GEOM::string_array &theNames, + GEOM::short_array &theTypes, + GEOM::ListOfBool &theCloseds) +{ + const int aNbSec = myCurve->getNbSections(); + int i; + int j; + + theCoords.length(aNbSec); + theNames.length(aNbSec); + theTypes.length(aNbSec); + theCloseds.length(aNbSec); + + for (i = 0; i < aNbSec; ++i) { + // Set coordinates + CurveCreator::Coordinates aCoords = myCurve->getPoints(i); + const int aNbPoints = aCoords.size(); + + theCoords[i].length(aNbPoints); + + for (j = 0; j < aNbPoints; ++j) { + theCoords[i][j] = aCoords[j]; + } + + // Set section type + const CurveCreator::SectionType aType = myCurve->getSectionType(i); + + switch (aType) { + case CurveCreator::Spline: + theTypes[i] = GEOM::Interpolation; + break; + case CurveCreator::Polyline: + default: + theTypes[i] = GEOM::Polyline; + break; + } + + // Set section names and closed flags. + theNames[i] = CORBA::string_dup(myCurve->getSectionName(i).c_str()); + theCloseds[i] = myCurve->isClosed(i); + } +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr EntityGUI_PolylineDlg::createOperation() +{ + return getGeomEngine()->GetICurvesOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool EntityGUI_PolylineDlg::isValid( QString& msg ) +{ + return true; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool EntityGUI_PolylineDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_ICurvesOperations_var anOper = + GEOM::GEOM_ICurvesOperations::_narrow(getOperation()); + + // Get the polyline creation parameters. + GEOM::ListOfListOfDouble aCoords; + GEOM::string_array aNames; + GEOM::short_array aTypes; + GEOM::ListOfBool aCloseds; + + GetCurveParams(aCoords, aNames, aTypes, aCloseds); + + // Get Working Plane. + int ind = myPlnComboBox->currentIndex(); + + if (ind != -1) { + bool isPlane = myPlnComboBox->itemData(ind).toBool(); + GEOM::GEOM_Object_var anObj; + + // Perform operation + if (isPlane) { + anObj = anOper->MakePolyline2DOnPlane + (aCoords, aNames, aTypes, aCloseds, myWPlaneList.at(ind).get()); + } else { + gp_Ax3 anAxis = myLCSList.at(ind); + GEOM::ListOfDouble aPlane; + + aPlane.length(9); + aPlane[0] = anAxis.Location().X(); + aPlane[1] = anAxis.Location().Y(); + aPlane[2] = anAxis.Location().Z(); + aPlane[3] = anAxis.Direction().X(); + aPlane[4] = anAxis.Direction().Y(); + aPlane[5] = anAxis.Direction().Z(); + aPlane[6] = anAxis.XDirection().X(); + aPlane[7] = anAxis.XDirection().Y(); + aPlane[8] = anAxis.XDirection().Z(); + + anObj = anOper->MakePolyline2D + (aCoords, aNames, aTypes, aCloseds, aPlane); + } + + if (!anObj->_is_nil()) { + objects.push_back(anObj._retn()); + } + } + + return true; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::ClickOnOk() +{ + setIsApplyAndClose( true ); + + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool EntityGUI_PolylineDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + initName(); + + return true; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::ClickOnCancel() +{ + myEditorWidget->SetViewer2DMode(false); + GEOMBase_Skeleton::ClickOnCancel(); +} + +//================================================================================= +// function : processStartedSubOperation +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit ) +{ + myEditorWidget->setEnabled( false ); + + myAddElementBox->setTitle( theIsEdit ? tr( "POLYLINE_EDIT_SECTION" ) : tr( "POLYLINE_ADD_SECTION" ) ); + QBoxLayout* anAddElementLayout = dynamic_cast( myAddElementBox->layout() ); + anAddElementLayout->addWidget( theWidget ); + + theWidget->show(); + myAddElementBox->show(); +} + + +//================================================================================= +// function : processFinishedSubOperation +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget ) +{ + myEditorWidget->setEnabled( true ); + + QBoxLayout* anAddElementLayout = dynamic_cast( myAddElementBox->layout() ); + anAddElementLayout->removeWidget( theWidget ); + + theWidget->hide(); + myAddElementBox->hide(); +} + +//================================================================================= +// function : deleteSelected +// purpose : Redirect the delete action to editor widget +//================================================================================= +void EntityGUI_PolylineDlg::deleteSelected() +{ + myEditorWidget->removeSelected(); +} + +//================================================================================= +// function : deleteEnabled +// purpose : Checks whether there are some to delete +//================================================================================= +bool EntityGUI_PolylineDlg::deleteEnabled() +{ + return myEditorWidget->removeEnabled(); +} + +//================================================================================= +// function : SelectionIntoArgument +// purpose : Called when selection is changed +//================================================================================= +void EntityGUI_PolylineDlg::SelectionIntoArgument() +{ + bool isModified = false; + GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_SHAPE); + TopoDS_Shape aShape; + + if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && + !aShape.IsNull()) { + QString aName = GEOMBase::GetName(aSelectedObject.get()); + + if (myEditCurrentArgument == myPolylineEdit) { + // Import a curve + CurveCreator_Curve *aNewCurve = + new CurveCreator_Curve(CurveCreator::Dim2d); + gp_Ax3 aLocalCS; + + if (CurveCreator_Utils::constructCurve(aShape, aNewCurve, aLocalCS)) { + // Change the current curve be the new one. + myEditorWidget->setCurve(aNewCurve); + delete myCurve; + myCurve = aNewCurve; + isModified = true; + myPolylineEdit->setText(aName); +#ifdef SET_PLANE + AddLocalCS(aSelectedObject.get(), false, aLocalCS); + myWPlaneLineEdit->clear(); + myPlnSelButton->setDown(false); +#endif + myPolylineSelButton->setDown(true); + } else { + // Does nothing, just clears selection. + delete aNewCurve; + } +#ifdef SET_PLANE + } else if (myEditCurrentArgument == myWPlaneLineEdit) { + // Import planar face. + if (aShape.ShapeType() == TopAbs_FACE) { + // Check if the face is planar + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape)); + GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion()); + + if (aPlanarCheck.IsPlanar()) { + myWPlaneLineEdit->setText(aName); + myPolylineEdit->clear(); + AddLocalCS(aSelectedObject.get(), true, + WPlaneToLCS(aSelectedObject.get())); + isModified = true; + myPlnSelButton->setDown(true); + myPolylineSelButton->setDown(false); + } + } + + if (!isModified) { + myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE")); + } +#endif + } + } + + if (!isModified) { + // Does nothing, just clears selection. + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::SetEditCurrentArgument() +{ + if (sender() == myPlnSelButton) { +#ifdef SET_PLANE + myEditCurrentArgument = myWPlaneLineEdit; + myEditCurrentArgument->setFocus(); + myPlnSelButton->setDown(true); + myPolylineSelButton->setDown(false); +#endif + } else if (sender() == myPolylineSelButton) { + myEditCurrentArgument = myPolylineEdit; + myEditCurrentArgument->setFocus(); +#ifdef SET_PLANE + myPlnSelButton->setDown(false); +#endif + myPolylineSelButton->setDown(true); + } +} + +//================================================================================= +// function : ActivateThisDialog +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::enterEvent (QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); +} + +//================================================================================= +// function : onUpdatePreview +// purpose : +//================================================================================= +void EntityGUI_PolylineDlg::onUpdatePreview() +{ + displayPreview(true); +} + +//================================================================================= +// function : ActivateLocalCS +// purpose : Activate & Fit Working plane +//================================================================================= +void EntityGUI_PolylineDlg::ActivateLocalCS() +{ + const int ind = myPlnComboBox->currentIndex(); + + if (ind == 0) { + // Default plane +#ifdef SET_PLANE + myWPlaneLineEdit->clear(); +#endif + myPolylineEdit->clear(); + } else if (ind > 0) { // Skip 0 as it is default + // Update text on line edits. + QString aName = GEOMBase::GetName(GetActiveWPlane().get()); + bool isPlane = myPlnComboBox->itemData(ind).toBool(); + + if (isPlane) { +#ifdef SET_PLANE + myWPlaneLineEdit->setText(aName); +#endif + myPolylineEdit->clear(); + } else { + myPolylineEdit->setText(aName); +#ifdef SET_PLANE + myWPlaneLineEdit->clear(); +#endif + } + } + + gp_Ax3 anAxis = GetActiveLocalCS(); + + myGeomGUI->SetWorkingPlane(anAxis); + myGeomGUI->ActiveWorkingPlane(); +} + +//================================================================================= +// function : GetActiveLocalCS +// purpose : Get Working plane +//================================================================================= +gp_Ax3 EntityGUI_PolylineDlg::GetActiveLocalCS() +{ + const int ind = myPlnComboBox->currentIndex(); + + return ind >= 0 ? myLCSList.at(ind) : myGeomGUI->GetWorkingPlane(); +} + +//================================================================================= +// function : GetActiveWPlane +// purpose : Get Working plane +//================================================================================= +GEOM::GeomObjPtr EntityGUI_PolylineDlg::GetActiveWPlane() +{ + const int ind = myPlnComboBox->currentIndex(); + + return ind >= 0 ? myWPlaneList.at(ind) : GEOM::GeomObjPtr(); +} + +//================================================================================= +// function : AddLocalCS() +// purpose : Add All Coordinates systems in study +//================================================================================= +void EntityGUI_PolylineDlg::AddLocalCS(GEOM::GeomObjPtr theSelectedObject, + const bool IsPlane, + const gp_Ax3 &theLCS) +{ + QString aName = GEOMBase::GetName(theSelectedObject.get()); + + int index = myPlnComboBox->findText(aName, Qt::MatchExactly); + + if (index == -1) { // If the working plane hasn't been added yet + myWPlaneList.push_back(theSelectedObject); + myLCSList.push_back(theLCS); + myPlnComboBox->addItem(aName, QVariant(IsPlane)); + index = myPlnComboBox->count(); + myPlnComboBox->setCurrentIndex(index - 1); + } else { + myPlnComboBox->setCurrentIndex(index); + } + ActivateLocalCS(); +} + +//================================================================================= +// function : WPlaneToLCS ( aWPlane ) +// purpose : +//================================================================================= +gp_Ax3 EntityGUI_PolylineDlg::WPlaneToLCS(GEOM::GeomObjPtr theGeomObj) +{ + TopoDS_Shape aShape = + GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), theGeomObj.get()); + gp_Ax3 aLCS; + + if (theGeomObj || aShape.IsNull()) { + MESSAGE("CORBA::is_nil(theGeomObj) || aShape.IsNull()") + } + + aLCS.Transform(aShape.Location().Transformation()); + + if (aShape.ShapeType() == TopAbs_FACE) { + GEOM::GEOM_IMeasureOperations_ptr aMeasureOp = + myGeomGUI->GetGeomGen()->GetIMeasureOperations(getStudyId()); + double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz; + + aMeasureOp->GetPosition(theGeomObj.get(), Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz); + + if (aMeasureOp->IsDone()) { + gp_Pnt aPnt (Ox, Oy, Oz); + gp_Dir aDirN (Zx, Zy, Zz); + gp_Dir aDirX (Xx, Xy, Xz); + aLCS = gp_Ax3(aPnt, aDirN, aDirX); + } + } + + return aLCS; +} diff --git a/src/EntityGUI/EntityGUI_PolylineDlg.h b/src/EntityGUI/EntityGUI_PolylineDlg.h new file mode 100644 index 000000000..6f7b009a5 --- /dev/null +++ b/src/EntityGUI/EntityGUI_PolylineDlg.h @@ -0,0 +1,152 @@ +// Copyright (C) 2007-2013 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. +// +// 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 ENTITYGUI_POLYLINEDLG_H +#define ENTITYGUI_POLYLINEDLG_H + + +#include + +class CurveCreator_Curve; +class CurveCreator_Widget; +class QGroupBox; +class QComboBox; + + +//================================================================================= +// class : EntityGUI_PolylineDlg +// purpose : +//================================================================================= +class EntityGUI_PolylineDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + + EntityGUI_PolylineDlg (GeometryGUI*, QWidget* = 0, + bool = false, Qt::WindowFlags = 0); + + virtual ~EntityGUI_PolylineDlg(); + + void deleteSelected(); + bool deleteEnabled(); + +protected: + + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& ); + +private: + + void Init(); + void Clear(); + void enterEvent(QEvent *); + + /** + * This method converts the curve into curve parameters required to + * construct an object using the interface + * GEOM_ICurvesOperations::MakePolyline2DOnPlane. + * + * \param theCurve a curve object, that contains data. + * \param theCoordsList the list of coordinates list. theCoordsList[0] + * is the coordinates list of the first section. theCoordsList[1] + * is for the second section etc. Output parameter. + * \param theNamesList the list of names. The order corresponds to + * theCoordsList. Output parameter. + * \param theTypesList the list of curve types. The order corresponds to + * theCoordsList. Output parameter. + * \param theClosedList the list of Closed flags. The order corresponds to + * theCoordsList. Output parameter. + */ + void GetCurveParams(GEOM::ListOfListOfDouble &theCoords, + GEOM::string_array &theNames, + GEOM::short_array &theTypes, + GEOM::ListOfBool &theCloseds); + + /** + * This method returns the current local coordinate system. + * + * \return local coordinate system. + */ + gp_Ax3 GetActiveLocalCS(); + + /** + * This method returns the current working plane. Can be null. + * + * \return the current working plane. + */ + GEOM::GeomObjPtr GetActiveWPlane(); + + /** + * This method add a local coordinate system of the selected object. + * + * \param theSelectedObject the selected object. It can be a planar face + * or an inported polyline. + * \param IsPlane true for planar face; false for imported polyline. + * \param theLCS the local coordinate system. + */ + void AddLocalCS(GEOM::GeomObjPtr theSelectedObject, + const bool IsPlane, + const gp_Ax3 &theLCS); + + /** + * This method converts the working plane object into + * the local coordinate system of the polyline. + * + * \param theGeomObj the working plane + * \return the local coordinate system + */ + gp_Ax3 WPlaneToLCS(GEOM::GeomObjPtr theGeomObj); + +protected slots: + + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + void processStartedSubOperation( QWidget*, bool ); + void processFinishedSubOperation( QWidget* ); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void ActivateThisDialog(); + void onUpdatePreview(); + void ActivateLocalCS(); + +private: + + CurveCreator_Curve *myCurve; + CurveCreator_Widget *myEditorWidget; + QGroupBox *myAddElementBox; + QComboBox *myPlnComboBox; + QPushButton *myPlnButton; + QPushButton *myPlnSelButton; + QPushButton *myPolylineSelButton; + QLineEdit *myWPlaneLineEdit; + QLineEdit *myPolylineEdit; + QLineEdit *myEditCurrentArgument; /* Current LineEdit */ + QList myLCSList; + QList myWPlaneList; + +}; + +#endif // ENTITYGUI_POLYLINEDLG_H diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx index 1b2060f3f..667ddd303 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/GEOM/CMakeLists.txt b/src/GEOM/CMakeLists.txt index 067056152..74de5cb4b 100755 --- a/src/GEOM/CMakeLists.txt +++ b/src/GEOM/CMakeLists.txt @@ -48,9 +48,6 @@ SET(_link_LIBRARIES SET(GEOM_HEADERS GEOM_Application.hxx - GEOM_Application.ixx - GEOM_Application.jxx - Handle_GEOM_Application.hxx GEOM_Engine.hxx GEOM_Function.hxx GEOM_Object.hxx @@ -61,10 +58,8 @@ SET(GEOM_HEADERS GEOM_ISubShape.hxx GEOM_Solver.hxx GEOM_PythonDump.hxx - GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx - GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx GEOM_DataMapOfAsciiStringTransient.hxx - Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx + GEOM_BaseObject.hxx ) # --- sources --- @@ -81,9 +76,6 @@ SET(GEOM_SOURCES GEOM_BaseDriver.cxx GEOM_SubShapeDriver.cxx GEOM_PythonDump.cxx - GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx - GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx - GEOM_DataMapOfAsciiStringTransient_0.cxx ) # --- rules --- diff --git a/src/GEOM/GEOM_Application.cxx b/src/GEOM/GEOM_Application.cxx index 8c13b8cce..79b8dcc24 100644 --- a/src/GEOM/GEOM_Application.cxx +++ b/src/GEOM/GEOM_Application.cxx @@ -20,8 +20,12 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include -#include +#include + +#include + +IMPLEMENT_STANDARD_HANDLE (GEOM_Application, TDocStd_Application) +IMPLEMENT_STANDARD_RTTIEXT(GEOM_Application, TDocStd_Application) //======================================================================= //function : GEOM_Application @@ -32,6 +36,14 @@ GEOM_Application::GEOM_Application() { } +//======================================================================= +//function : ~GEOM_Application +//purpose : +//======================================================================= + +GEOM_Application::~GEOM_Application() +{ +} //======================================================================= //function : Formats @@ -53,8 +65,3 @@ Standard_CString GEOM_Application::ResourcesName() { return Standard_CString ("GEOMDS_Resources"); } - - - - - diff --git a/src/GEOM/GEOM_Application.hxx b/src/GEOM/GEOM_Application.hxx index e6d98f164..1fad0e099 100644 --- a/src/GEOM/GEOM_Application.hxx +++ b/src/GEOM/GEOM_Application.hxx @@ -20,92 +20,28 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : GEOM_Application.hxx -// Module : GEOM -// #ifndef _GEOM_Application_HeaderFile #define _GEOM_Application_HeaderFile -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_GEOM_Application_HeaderFile -#include -#endif - -#ifndef _TDocStd_Application_HeaderFile #include -#endif -#ifndef _Standard_CString_HeaderFile -#include -#endif +#include +#include + class TColStd_SequenceOfExtendedString; +class GEOM_Application : public TDocStd_Application +{ +public: + Standard_EXPORT GEOM_Application(); + Standard_EXPORT ~GEOM_Application(); -class GEOM_Application : public TDocStd_Application { + Standard_EXPORT virtual void Formats(TColStd_SequenceOfExtendedString& Formats); + Standard_EXPORT Standard_CString ResourcesName(); 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); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT GEOM_Application(); -Standard_EXPORT virtual void Formats(TColStd_SequenceOfExtendedString& Formats) ; -Standard_EXPORT Standard_CString ResourcesName() ; -Standard_EXPORT ~GEOM_Application(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& GEOM_Application_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - + DEFINE_STANDARD_RTTI(GEOM_Application); }; - - - - -// other inline functions and methods (like "C++: function call" methods) -// - +DEFINE_STANDARD_HANDLE(GEOM_Application, TDocStd_Application) #endif diff --git a/src/GEOM/GEOM_Application.ixx b/src/GEOM/GEOM_Application.ixx deleted file mode 100644 index ccf2e0681..000000000 --- a/src/GEOM/GEOM_Application.ixx +++ /dev/null @@ -1,85 +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 : GEOM_Application.ixx -// Module : GEOM -// -#include "GEOM_Application.jxx" - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -GEOM_Application::~GEOM_Application() {} - - - -Standard_EXPORT Handle_Standard_Type& GEOM_Application_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(TDocStd_Application); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDocStd_Application); - static Handle_Standard_Type aType2 = STANDARD_TYPE(CDF_Application); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(CDF_Application); - static Handle_Standard_Type aType3 = STANDARD_TYPE(CDM_Application); - if ( aType3.IsNull()) aType3 = STANDARD_TYPE(CDM_Application); - static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); - if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); - - - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; - static Handle_Standard_Type _aType = new Standard_Type("GEOM_Application", - sizeof(GEOM_Application), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - -// DownCast method -// allow safe downcasting - - -const Handle(GEOM_Application) Handle(GEOM_Application)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(GEOM_Application) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(GEOM_Application))) { - _anOtherObject = Handle(GEOM_Application)((Handle(GEOM_Application)&)AnObject); - } - } - - return _anOtherObject ; -} - - -const Handle(Standard_Type)& GEOM_Application::DynamicType() const -{ - return STANDARD_TYPE(GEOM_Application) ; -} -Standard_Boolean GEOM_Application::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(GEOM_Application) == AType || TDocStd_Application::IsKind(AType)); -} -Handle_GEOM_Application::~Handle_GEOM_Application() {} 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/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx b/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx deleted file mode 100644 index f7c3959eb..000000000 --- a/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx +++ /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 -// - -#ifndef _GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_HeaderFile -#define _GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_HeaderFile - -#ifndef _TCollection_BasicMapIterator_HeaderFile -#include -#endif -#ifndef _Handle_Standard_Transient_HeaderFile -#include -#endif -#ifndef _Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile -#include -#endif -class Standard_NoSuchObject; -class TCollection_AsciiString; -class Standard_Transient; -class GEOM_DataMapOfAsciiStringTransient; -class GEOM_DataMapNodeOfDataMapOfAsciiStringTransient; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient : public TCollection_BasicMapIterator { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient(); -Standard_EXPORT GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient(const GEOM_DataMapOfAsciiStringTransient& aMap); -Standard_EXPORT void Initialize(const GEOM_DataMapOfAsciiStringTransient& aMap) ; -Standard_EXPORT const TCollection_AsciiString& Key() const; -Standard_EXPORT const Handle_Standard_Transient& Value() const; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx b/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx deleted file mode 100644 index 508d3458c..000000000 --- a/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx +++ /dev/null @@ -1,57 +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 - -#ifndef _Standard_NoSuchObject_HeaderFile -#include -#endif -#ifndef _TCollection_AsciiString_HeaderFile -#include -#endif -#ifndef _Standard_Transient_HeaderFile -#include -#endif -#ifndef _GEOM_DataMapOfAsciiStringTransient_HeaderFile -#include -#endif -#ifndef _GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile -#include -#endif - - -#define TheKey TCollection_AsciiString -#define TheKey_hxx -#define TheItem Handle_Standard_Transient -#define TheItem_hxx -#define Hasher TCollection_AsciiString -#define Hasher_hxx -#define TCollection_DataMapNode GEOM_DataMapNodeOfDataMapOfAsciiStringTransient -#define TCollection_DataMapNode_hxx -#define TCollection_DataMapIterator GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient -#define TCollection_DataMapIterator_hxx -#define Handle_TCollection_DataMapNode Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient -#define TCollection_DataMapNode_Type_() GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_Type_() -#define TCollection_DataMap GEOM_DataMapOfAsciiStringTransient -#define TCollection_DataMap_hxx -#include - diff --git a/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx b/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx deleted file mode 100644 index 92ab1a2d2..000000000 --- a/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx +++ /dev/null @@ -1,144 +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_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile -#define _GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile -#include -#endif - -#ifndef _TCollection_AsciiString_HeaderFile -#include -#endif -#ifndef _Handle_Standard_Transient_HeaderFile -#include -#endif -#ifndef _TCollection_MapNode_HeaderFile -#include -#endif -#ifndef _TCollection_MapNodePtr_HeaderFile -#include -#endif -class Standard_Transient; -class TCollection_AsciiString; -class GEOM_DataMapOfAsciiStringTransient; -class GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient; - - -class GEOM_DataMapNodeOfDataMapOfAsciiStringTransient : public TCollection_MapNode { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -GEOM_DataMapNodeOfDataMapOfAsciiStringTransient(const TCollection_AsciiString& K,const Handle(Standard_Transient)& I,const TCollection_MapNodePtr& n); - TCollection_AsciiString& Key() const; - Handle_Standard_Transient& Value() const; -Standard_EXPORT ~GEOM_DataMapNodeOfDataMapOfAsciiStringTransient(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -TCollection_AsciiString myKey; -Handle_Standard_Transient myValue; - - -}; - -#define TheKey TCollection_AsciiString -#define TheKey_hxx -#define TheItem Handle_Standard_Transient -#define TheItem_hxx -#define Hasher TCollection_AsciiString -#define Hasher_hxx -#define TCollection_DataMapNode GEOM_DataMapNodeOfDataMapOfAsciiStringTransient -#define TCollection_DataMapNode_hxx -#define TCollection_DataMapIterator GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient -#define TCollection_DataMapIterator_hxx -#define Handle_TCollection_DataMapNode Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient -#define TCollection_DataMapNode_Type_() GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_Type_() -#define TCollection_DataMap GEOM_DataMapOfAsciiStringTransient -#define TCollection_DataMap_hxx - -#include - -#undef TheKey -#undef TheKey_hxx -#undef TheItem -#undef TheItem_hxx -#undef Hasher -#undef Hasher_hxx -#undef TCollection_DataMapNode -#undef TCollection_DataMapNode_hxx -#undef TCollection_DataMapIterator -#undef TCollection_DataMapIterator_hxx -#undef Handle_TCollection_DataMapNode -#undef TCollection_DataMapNode_Type_ -#undef TCollection_DataMap -#undef TCollection_DataMap_hxx - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx b/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx deleted file mode 100644 index c60f7fa19..000000000 --- a/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx +++ /dev/null @@ -1,106 +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 - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -#ifndef _Standard_Transient_HeaderFile -#include -#endif -#ifndef _TCollection_AsciiString_HeaderFile -#include -#endif -#ifndef _GEOM_DataMapOfAsciiStringTransient_HeaderFile -#include -#endif -#ifndef _GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_HeaderFile -#include -#endif -GEOM_DataMapNodeOfDataMapOfAsciiStringTransient::~GEOM_DataMapNodeOfDataMapOfAsciiStringTransient() {} - - - -Standard_EXPORT Handle_Standard_Type& GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); - 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("GEOM_DataMapNodeOfDataMapOfAsciiStringTransient", - sizeof(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient))) { - _anOtherObject = Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)((Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& GEOM_DataMapNodeOfDataMapOfAsciiStringTransient::DynamicType() const -{ - return STANDARD_TYPE(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) ; -} -Standard_Boolean GEOM_DataMapNodeOfDataMapOfAsciiStringTransient::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) == AType || TCollection_MapNode::IsKind(AType)); -} -Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient::~Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient() {} -#define TheKey TCollection_AsciiString -#define TheKey_hxx -#define TheItem Handle_Standard_Transient -#define TheItem_hxx -#define Hasher TCollection_AsciiString -#define Hasher_hxx -#define TCollection_DataMapNode GEOM_DataMapNodeOfDataMapOfAsciiStringTransient -#define TCollection_DataMapNode_hxx -#define TCollection_DataMapIterator GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient -#define TCollection_DataMapIterator_hxx -#define Handle_TCollection_DataMapNode Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient -#define TCollection_DataMapNode_Type_() GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_Type_() -#define TCollection_DataMap GEOM_DataMapOfAsciiStringTransient -#define TCollection_DataMap_hxx -#include - diff --git a/src/GEOM/GEOM_DataMapOfAsciiStringTransient.hxx b/src/GEOM/GEOM_DataMapOfAsciiStringTransient.hxx index 41fbc77d8..1a1b70044 100644 --- a/src/GEOM/GEOM_DataMapOfAsciiStringTransient.hxx +++ b/src/GEOM/GEOM_DataMapOfAsciiStringTransient.hxx @@ -23,98 +23,11 @@ #ifndef _GEOM_DataMapOfAsciiStringTransient_HeaderFile #define _GEOM_DataMapOfAsciiStringTransient_HeaderFile -#ifndef _TCollection_BasicMap_HeaderFile -#include -#endif -#ifndef _Handle_Standard_Transient_HeaderFile -#include -#endif -#ifndef _Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile -#include -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif +#include +#include +#include -class Standard_DomainError; -class Standard_NoSuchObject; -class TCollection_AsciiString; -class Standard_Transient; -class GEOM_DataMapNodeOfDataMapOfAsciiStringTransient; -class GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient; +typedef NCollection_DataMap GEOM_DataMapOfAsciiStringTransient; +typedef GEOM_DataMapOfAsciiStringTransient::Iterator GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient; -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -#include - -class GEOM_DataMapOfAsciiStringTransient : public TCollection_BasicMap { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - - // Methods PUBLIC - // -Standard_EXPORT GEOM_DataMapOfAsciiStringTransient(const Standard_Integer NbBuckets = 1); -Standard_EXPORT GEOM_DataMapOfAsciiStringTransient& Assign(const GEOM_DataMapOfAsciiStringTransient& Other) ; - GEOM_DataMapOfAsciiStringTransient& operator =(const GEOM_DataMapOfAsciiStringTransient& Other) -{ - return Assign(Other); -} - -Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; -Standard_EXPORT void Clear() ; -~GEOM_DataMapOfAsciiStringTransient() -{ - Clear(); -} - -Standard_EXPORT Standard_Boolean Bind(const TCollection_AsciiString& K,const Handle(Standard_Transient)& I) ; -Standard_EXPORT Standard_Boolean IsBound(const TCollection_AsciiString& K) const; -Standard_EXPORT Standard_Boolean UnBind(const TCollection_AsciiString& K) ; -Standard_EXPORT const Handle_Standard_Transient& Find(const TCollection_AsciiString& K) const; - const Handle_Standard_Transient& operator()(const TCollection_AsciiString& K) const -{ - return Find(K); -} - -Standard_EXPORT Handle_Standard_Transient& ChangeFind(const TCollection_AsciiString& K) ; - Handle_Standard_Transient& operator()(const TCollection_AsciiString& K) -{ - return ChangeFind(K); -} - -#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version - Standard_EXPORT Standard_Address Find1 (const TCollection_AsciiString& K) const; - Standard_EXPORT Standard_Address ChangeFind1 (const TCollection_AsciiString& K); -#endif - -private: - // Methods PRIVATE - // -Standard_EXPORT GEOM_DataMapOfAsciiStringTransient(const GEOM_DataMapOfAsciiStringTransient& Other); -}; - -// other Inline functions and methods (like "C++: function call" methods) -// - -#endif +#endif // _GEOM_DataMapOfAsciiStringTransient_HeaderFile diff --git a/src/GEOM/GEOM_DataMapOfAsciiStringTransient_0.cxx b/src/GEOM/GEOM_DataMapOfAsciiStringTransient_0.cxx deleted file mode 100644 index 8e14c0d01..000000000 --- a/src/GEOM/GEOM_DataMapOfAsciiStringTransient_0.cxx +++ /dev/null @@ -1,60 +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 - -#ifndef _Standard_DomainError_HeaderFile -#include -#endif -#ifndef _Standard_NoSuchObject_HeaderFile -#include -#endif -#ifndef _TCollection_AsciiString_HeaderFile -#include -#endif -#ifndef _Standard_Transient_HeaderFile -#include -#endif -#ifndef _GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile -#include -#endif -#ifndef _GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_HeaderFile -#include -#endif - - -#define TheKey TCollection_AsciiString -#define TheKey_hxx -#define TheItem Handle_Standard_Transient -#define TheItem_hxx -#define Hasher TCollection_AsciiString -#define Hasher_hxx -#define TCollection_DataMapNode GEOM_DataMapNodeOfDataMapOfAsciiStringTransient -#define TCollection_DataMapNode_hxx -#define TCollection_DataMapIterator GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient -#define TCollection_DataMapIterator_hxx -#define Handle_TCollection_DataMapNode Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient -#define TCollection_DataMapNode_Type_() GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_Type_() -#define TCollection_DataMap GEOM_DataMapOfAsciiStringTransient -#define TCollection_DataMap_hxx -#include - diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index 9d804abfd..a2617ff40 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -26,7 +26,6 @@ #include "GEOM_Engine.hxx" -#include "GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx" #include "GEOM_Field.hxx" #include "GEOM_Function.hxx" #include "GEOM_ISubShape.hxx" @@ -215,7 +214,7 @@ GEOM_Engine::GEOM_Engine() TFunction_DriverTable::Get()->AddDriver(GEOM_Object::GetSubShapeID(), new GEOM_SubShapeDriver()); _OCAFApp = new GEOM_Application(); - _UndoLimit = 10; + _UndoLimit = 0; } /*! @@ -408,9 +407,7 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) th aSSI.SetIndices(theIndices); try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif GEOM_Solver aSolver (GEOM_Engine::GetEngine()); if (!aSolver.ComputeFunction(aFunction)) { MESSAGE("GEOM_Engine::AddSubShape Error: Can't build a sub shape"); @@ -860,11 +857,7 @@ Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const #define TEXTURE_LABEL_DATA 5 int GEOM_Engine::addTexture(int theDocID, int theWidth, int theHeight, -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 const Handle(TColStd_HArray1OfByte)& theTexture, -#else - const Handle(TDataStd_HArray1OfByte)& theTexture, -#endif const TCollection_AsciiString& theFileName) { Handle(TDocStd_Document) aDoc = GetDocument(theDocID); @@ -909,19 +902,11 @@ int GEOM_Engine::addTexture(int theDocID, int theWidth, int theHeight, return aTextureID; } -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) GEOM_Engine::getTexture(int theDocID, int theTextureID, -#else -Handle(TDataStd_HArray1OfByte) GEOM_Engine::getTexture(int theDocID, int theTextureID, -#endif int& theWidth, int& theHeight, TCollection_AsciiString& theFileName) { -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) anArray; -#else - Handle(TDataStd_HArray1OfByte) anArray; -#endif theWidth = theHeight = 0; Handle(TDocStd_Document) aDoc = GetDocument(theDocID); @@ -1661,11 +1646,7 @@ void AddObjectColors (int theDocID, } } -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 static TCollection_AsciiString pack_data (const Handle(TColStd_HArray1OfByte)& aData) -#else -static TCollection_AsciiString pack_data (const Handle(TDataStd_HArray1OfByte)& aData) -#endif { TCollection_AsciiString stream; if (!aData.IsNull()) { @@ -1693,11 +1674,7 @@ void AddTextures (int theDocID, TCollection_AsciiString& theScript) if (*it <= 0) continue; Standard_Integer aWidth, aHeight; TCollection_AsciiString aFileName; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) aTexture = -#else - Handle(TDataStd_HArray1OfByte) aTexture = -#endif engine->getTexture(theDocID, *it, aWidth, aHeight, aFileName); if (aWidth > 0 && aHeight > 0 && !aTexture.IsNull() && aTexture->Length() > 0 ) { TCollection_AsciiString aCommand = "\n\t"; diff --git a/src/GEOM/GEOM_Engine.hxx b/src/GEOM/GEOM_Engine.hxx index 111096e72..e802b3a25 100644 --- a/src/GEOM/GEOM_Engine.hxx +++ b/src/GEOM/GEOM_Engine.hxx @@ -29,11 +29,7 @@ #include -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #include -#else -#include -#endif #include #include @@ -59,11 +55,7 @@ struct TObjectData bool _unpublished; }; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 class Handle_TColStd_HArray1OfByte; -#else -class Handle_TDataStd_HArray1OfByte; -#endif struct TVariable{ TCollection_AsciiString myVariable; diff --git a/src/GEOM/GEOM_Function.cxx b/src/GEOM/GEOM_Function.cxx index db4658cf2..458e0a0bc 100644 --- a/src/GEOM/GEOM_Function.cxx +++ b/src/GEOM/GEOM_Function.cxx @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include #include #include @@ -227,9 +229,7 @@ TopoDS_Shape GEOM_Function::GetValue() if (!isResult) { try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif GEOM_Solver aSolver(GEOM_Engine::GetEngine()); if (!aSolver.ComputeFunction(this)) { MESSAGE("GEOM_Object::GetValue Error : Can't build a sub-shape"); @@ -476,6 +476,74 @@ Handle(TColStd_HArray1OfInteger) GEOM_Function::GetIntegerArray(int thePosition) return anIntegerArray->Array(); } +//============================================================================= +/*! + * SetByteArray + */ +//============================================================================= +void GEOM_Function::SetByteArray (int thePosition, + const Handle(TColStd_HArray1OfByte)& theArray) +{ + _isDone = false; + if(thePosition <= 0) return; + TDF_Label anArgLabel = ARGUMENT(thePosition); + Handle(TDataStd_ByteArray) anAttr = + TDataStd_ByteArray::Set(anArgLabel, theArray->Lower(), theArray->Upper()); + anAttr->ChangeArray(theArray); + _isDone = true; +} + +//============================================================================= +/*! + * GetByteArray + */ +//============================================================================= +Handle(TColStd_HArray1OfByte) GEOM_Function::GetByteArray(int thePosition) +{ + _isDone = false; + if(thePosition <= 0) return 0; + Handle(TDataStd_ByteArray) aByteArray; + TDF_Label anArgLabel = ARGUMENT(thePosition); + if(!anArgLabel.FindAttribute(TDataStd_ByteArray::GetID(), aByteArray)) return 0; + + _isDone = true; + return aByteArray->InternalArray(); +} + +//============================================================================= +/*! + * SetBooleanArray + */ +//============================================================================= +void GEOM_Function::SetBooleanArray (int thePosition, + const Handle(TColStd_HArray1OfByte)& theArray) +{ + _isDone = false; + if(thePosition <= 0) return; + TDF_Label anArgLabel = ARGUMENT(thePosition); + Handle(TDataStd_BooleanArray) anAttr = + TDataStd_BooleanArray::Set(anArgLabel, theArray->Lower(), theArray->Upper()); + anAttr->SetInternalArray(theArray); + _isDone = true; +} + +//============================================================================= +/*! + * GetBooleanArray + */ +//============================================================================= +Handle(TColStd_HArray1OfByte) GEOM_Function::GetBooleanArray(int thePosition) +{ + _isDone = false; + if(thePosition <= 0) return 0; + Handle(TDataStd_BooleanArray) aBooleanArray; + TDF_Label anArgLabel = ARGUMENT(thePosition); + if(!anArgLabel.FindAttribute(TDataStd_BooleanArray::GetID(), aBooleanArray)) return 0; + + _isDone = true; + return aBooleanArray->InternalArray(); +} + //============================================================================= /*! * SetString diff --git a/src/GEOM/GEOM_Function.hxx b/src/GEOM/GEOM_Function.hxx index 702acb959..688324dae 100644 --- a/src/GEOM/GEOM_Function.hxx +++ b/src/GEOM/GEOM_Function.hxx @@ -32,6 +32,7 @@ #include #include +class Handle_TColStd_HArray1OfByte; class Handle_TColStd_HArray1OfReal; class Handle_TColStd_HArray1OfInteger; class Handle_TColStd_HSequenceOfTransient; @@ -108,6 +109,18 @@ public: //Returns an integer array argument at position thePosition Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetIntegerArray(int thePosition); + //Sets a byte array argument at position thePosition + Standard_EXPORT void SetByteArray(int thePosition, const Handle(TColStd_HArray1OfByte)& theArray); + + //Returns a byte array argument at position thePosition + Standard_EXPORT Handle(TColStd_HArray1OfByte) GetByteArray(int thePosition); + + //Sets a boolean array argument at position thePosition + Standard_EXPORT void SetBooleanArray(int thePosition, const Handle(TColStd_HArray1OfByte)& theArray); + + //Returns a boolean array argument at position thePosition + Standard_EXPORT Handle(TColStd_HArray1OfByte) GetBooleanArray(int thePosition); + //Sets a reference to other function argument at position thePosition Standard_EXPORT void SetReference(int thePosition, Handle(GEOM_Function) theReference); diff --git a/src/GEOM/Handle_GEOM_Application.hxx b/src/GEOM/Handle_GEOM_Application.hxx deleted file mode 100644 index 4c8e8a522..000000000 --- a/src/GEOM/Handle_GEOM_Application.hxx +++ /dev/null @@ -1,99 +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 : Handle_GEOM_Application.hxx -// Module : GEOM -// -#ifndef _Handle_GEOM_Application_HeaderFile -#define _Handle_GEOM_Application_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_TDocStd_Application_HeaderFile -#include -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(TDocStd_Application); -class GEOM_Application; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SimpleOCAF_Application); - -class Handle(GEOM_Application) : public Handle(TDocStd_Application) { - 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); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - Handle(GEOM_Application)():Handle(TDocStd_Application)() {} - Handle(GEOM_Application)(const Handle(GEOM_Application)& aHandle) : Handle(TDocStd_Application)(aHandle) - { - } - - Handle(GEOM_Application)(const GEOM_Application* anItem) : Handle(TDocStd_Application)((TDocStd_Application *)anItem) - { - } - - Handle(GEOM_Application)& operator=(const Handle(GEOM_Application)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(GEOM_Application)& operator=(const GEOM_Application* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - GEOM_Application* operator->() - { - return (GEOM_Application *)ControlAccess(); - } - - GEOM_Application* operator->() const - { - return (GEOM_Application *)ControlAccess(); - } - - Standard_EXPORT ~Handle(GEOM_Application)(); - - Standard_EXPORT static const Handle(GEOM_Application) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/GEOM/Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx b/src/GEOM/Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx deleted file mode 100644 index b6d7d3225..000000000 --- a/src/GEOM/Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx +++ /dev/null @@ -1,95 +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 : Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx -// Module : GEOM -// -#ifndef _Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile -#define _Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_TCollection_MapNode_HeaderFile -#include -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(TCollection_MapNode); -class GEOM_DataMapNodeOfDataMapOfAsciiStringTransient; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient); - -class Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) : public Handle(TCollection_MapNode) { - public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)():Handle(TCollection_MapNode)() {} - Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)(const Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)& aHandle) : Handle(TCollection_MapNode)(aHandle) - { - } - - Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)(const GEOM_DataMapNodeOfDataMapOfAsciiStringTransient* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) - { - } - - Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)& operator=(const Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)& operator=(const GEOM_DataMapNodeOfDataMapOfAsciiStringTransient* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - GEOM_DataMapNodeOfDataMapOfAsciiStringTransient* operator->() - { - return (GEOM_DataMapNodeOfDataMapOfAsciiStringTransient *)ControlAccess(); - } - - GEOM_DataMapNodeOfDataMapOfAsciiStringTransient* operator->() const - { - return (GEOM_DataMapNodeOfDataMapOfAsciiStringTransient *)ControlAccess(); - } - - Standard_EXPORT ~Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)(); - - Standard_EXPORT static const Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx index d68bcb7c4..b98c7de00 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx @@ -28,9 +28,7 @@ #include -#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version #include -#endif #include @@ -393,11 +391,7 @@ void GEOMAlgo_FinderShapeOn::MakeArgument1() // // Argument 1 if (!myIsAnalytic) { -#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version aMF.Init(mySurface, Standard_True, Precision::Confusion()); -#else - aMF.Init(mySurface, Standard_True); -#endif aFErr=aMF.Error(); if (aFErr!=BRepLib_FaceDone) { diff --git a/src/GEOMAlgo/GEOMAlgo_WireSolid.cxx b/src/GEOMAlgo/GEOMAlgo_WireSolid.cxx index 958d4270f..0cc8b5610 100644 --- a/src/GEOMAlgo/GEOMAlgo_WireSolid.cxx +++ b/src/GEOMAlgo/GEOMAlgo_WireSolid.cxx @@ -186,11 +186,7 @@ void GEOMAlgo_WireSolid::BuildResult() } else if (aNbPB==1) { const Handle(BOPDS_PaveBlock)& aPB=aLPB.First(); -#if OCC_VERSION_LARGE > 0x06060000 // Porting to OCCT higher 6.6.0 version if (pDS->IsCommonBlock(aPB)) { -#else - if (aPB->IsCommonBlock()) { -#endif aState=TopAbs_ON; } else{ 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.cxx b/src/GEOMBase/GEOMBase.cxx index 26110fe1e..849e433af 100644 --- a/src/GEOMBase/GEOMBase.cxx +++ b/src/GEOMBase/GEOMBase.cxx @@ -40,7 +40,6 @@ #include #include -#include #include #include @@ -303,9 +302,6 @@ Handle(GEOM_AISShape) GEOMBase::ConvertIORinGEOMAISShape(const QString& IOR, boo AIS_ListOfInteractive displayed; ic->DisplayedObjects( displayed ); -#if OCC_VERSION_LARGE <= 0x06060000 - ic->ObjectsInCollector( displayed ); -#endif AIS_ListIteratorOfListOfInteractive it( displayed ); while ( it.More() && shape.IsNull() ) { if ( it.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) { 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_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index e7b02e6b4..93c4c2da6 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include @@ -381,7 +381,7 @@ void GEOMBase_Helper::displayPreview( const SALOME_Prs* prs, SUIT_ViewModel* aViewModel = aViewManager->getViewModel(); SALOME_View* aView = dynamic_cast(aViewModel); if (aView) - aView->Display( prs ); + aView->Display( getDisplayer(), prs ); } // Add prs to the preview list @@ -401,19 +401,20 @@ void GEOMBase_Helper::erasePreview( const bool update ) // check view frame where the preview was displayed bool vfOK = checkViewWindow() && myViewWindow; // Iterate through presentations and delete them - for ( PrsList::iterator anIter = myPreview.begin(); anIter != myPreview.end(); ++anIter ) { + for ( PrsList::iterator anIter = myPreview.begin(); anIter != myPreview.end(); ++anIter ) + { if ( vfOK ) + { + SUIT_ViewManager* aViewManager = myViewWindow->getViewManager(); + if ( aViewManager->getType() == OCCViewer_Viewer::Type() || + aViewManager->getType() == SVTK_Viewer::Type() ) { - SUIT_ViewManager* aViewManager = myViewWindow->getViewManager(); - if ( aViewManager->getType() == OCCViewer_Viewer::Type() || - aViewManager->getType() == SVTK_Viewer::Type() ) - { - SUIT_ViewModel* aViewModel = aViewManager->getViewModel(); - SALOME_View* aView = dynamic_cast(aViewModel); - if (aView) - aView->Erase( *anIter, true ); - } + SUIT_ViewModel* aViewModel = aViewManager->getViewModel(); + SALOME_View* aView = dynamic_cast(aViewModel); + if (aView) + aView->Erase( getDisplayer(), *anIter, true ); } + } delete *anIter; } myPreview.clear(); 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 0429e9be5..bd319bfab 100644 --- a/src/GEOMGUI/GEOMGUI_CreationInfoWdg.cxx +++ b/src/GEOMGUI/GEOMGUI_CreationInfoWdg.cxx @@ -37,7 +37,8 @@ GEOMGUI_CreationInfoWdg::GEOMGUI_CreationInfoWdg( SalomeApp_Application* app ) //:QWidget( app->desktop() ) { - setWindowTitle(tr("CREATION_INFO_TITLE")); + setWindowTitle( tr( "CREATION_INFO_TITLE" ) ); + setObjectName( "geomCreationInformation" ); QFrame* frame = new QFrame( this ); @@ -76,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_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index 3e6f31a31..014c622c2 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -171,6 +171,8 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const v = isAutoColor( idx ); else if ( p == "isVectorsMode" ) v = isVectorsMode( idx ); + else if ( p == "isVerticesMode" ) + v = isVerticesMode( idx ); else if ( p == "topLevel" ) v = topLevel( idx ); else if ( p == "autoBringToFront" ) @@ -378,7 +380,7 @@ QString GEOMGUI_Selection::displayMode( const int index ) const bool GEOMGUI_Selection::autoBringToFront( const int /*index*/ ) const { - return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" ); + return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" ); } bool GEOMGUI_Selection::isVectorsMode( const int index ) const @@ -428,6 +430,53 @@ bool GEOMGUI_Selection::isVectorsMode( const int index ) const return res; } +bool GEOMGUI_Selection::isVerticesMode( const int index ) const +{ +#ifdef USE_VISUAL_PROP_MAP + QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::Vertices ) ); + if ( v.canConvert( QVariant::Bool ) ) + return v.toBool(); +#endif + + bool res = false; + + SALOME_View* view = GEOM_Displayer::GetActiveView(); + QString viewType = activeViewType(); + if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) { + SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() ); + if ( prs ) { + if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC + SOCC_Prs* occPrs = (SOCC_Prs*) prs; + AIS_ListOfInteractive lst; + occPrs->GetObjects( lst ); + if ( lst.Extent() ) { + Handle(AIS_InteractiveObject) io = lst.First(); + if ( !io.IsNull() ) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); + if ( !aSh.IsNull() ) + res = aSh->isShowVertices(); + } + } + } + else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK + SVTK_Prs* vtkPrs = dynamic_cast( prs ); + vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0; + if ( lst ) { + lst->InitTraversal(); + vtkActor* actor = lst->GetNextActor(); + if ( actor ) { + GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor); + if ( aGeomActor ) + res = aGeomActor->GetVerticesMode(); + } + } + } + } + } + + return res; +} + bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj ) { if ( obj ) { @@ -672,7 +721,8 @@ bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor ); if ( aGeomGActor ) { GEOM_VTKPropertyMaterial* mat = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty()); - res = mat->GetPhysical(); + if ( mat ) + res = mat->GetPhysical(); } // if ( salome actor ) } // if ( actor ) } // if ( lst == vtkPrs->GetObjects() ) diff --git a/src/GEOMGUI/GEOMGUI_Selection.h b/src/GEOMGUI/GEOMGUI_Selection.h index be21acfb4..d7b692609 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.h +++ b/src/GEOMGUI/GEOMGUI_Selection.h @@ -67,6 +67,7 @@ private: QString displayMode( const int ) const; QString selectionMode() const; bool isVectorsMode( const int ) const; + bool isVerticesMode( const int ) const; bool hasChildren( const int ) const; int nbChildren( const int ) const; bool hasConcealedChildren( const int ) const; 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_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 4cd41a6eb..7d79a2cd5 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -65,7 +65,6 @@ #include #include -#include #include #include @@ -77,6 +76,7 @@ #include #include +#include // OCCT Includes #include @@ -122,11 +122,7 @@ #include -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #include -#else -#include -#endif // If the next macro is defined, autocolor feature works for all sub-shapes; // if it is undefined, autocolor feature works for groups only @@ -138,7 +134,6 @@ // Hard-coded value of shape deflection coefficient for VTK viewer const double VTK_MIN_DEFLECTION = 0.001; -#if OCC_VERSION_LARGE > 0x06070000 // Pixmap caching support namespace { @@ -158,47 +153,6 @@ namespace return aMap; } - //=========================================================================== - // Function : imageToPixmap - // Purpose : Concert QImage to OCCT pixmap - //=========================================================================== - static inline Handle(Image_PixMap) imageToPixmap( const QImage& anImage ) - { - Handle(Image_PixMap) aPixmap = new Image_PixMap(); - if ( !anImage.isNull() ) { - aPixmap->InitTrash( Image_PixMap::ImgBGRA, anImage.width(), anImage.height() ); - aPixmap->SetTopDown( Standard_True ); - - const uchar* aImageBytes = anImage.bits(); - - for ( int aLine = anImage.height() - 1; aLine >= 0; --aLine ) { -#if OCC_VERSION_LARGE > 0x06070100 - // convert pixels from ARGB to renderer-compatible RGBA - for ( int aByte = 0; aByte < anImage.width(); ++aByte ) { - Image_ColorBGRA& aPixmapBytes = aPixmap->ChangeValue(aLine, aByte); - - aPixmapBytes.b() = (Standard_Byte) *aImageBytes++; - aPixmapBytes.g() = (Standard_Byte) *aImageBytes++; - aPixmapBytes.r() = (Standard_Byte) *aImageBytes++; - aPixmapBytes.a() = (Standard_Byte) *aImageBytes++; - } -#else - Image_ColorBGRA* aPixmapBytes = aPixmap->EditData().ChangeRow(aLine); - - // convert pixels from ARGB to renderer-compatible RGBA - for ( int aByte = 0; aByte < anImage.width(); ++aByte ) { - aPixmapBytes->b() = (Standard_Byte) *aImageBytes++; - aPixmapBytes->g() = (Standard_Byte) *aImageBytes++; - aPixmapBytes->r() = (Standard_Byte) *aImageBytes++; - aPixmapBytes->a() = (Standard_Byte) *aImageBytes++; - aPixmapBytes++; - } -#endif - } - } - return aPixmap; - } - //=========================================================================== // Function : getDefaultTexture // Purpose : Get default texture @@ -209,7 +163,7 @@ namespace if ( aPixmap.IsNull() ) { QPixmap px(":images/default_texture.png"); if ( !px.isNull() ) - aPixmap = imageToPixmap( px.toImage() ); + aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() ); } return aPixmap; } @@ -243,7 +197,7 @@ namespace if ( anImage.isNull() ) return NULL; - aPixmap = imageToPixmap( anImage ); + aPixmap = OCCViewer_Utilities::imageToPixmap( anImage ); aPixmapCacheMap.insert( thePath, aPixmap ); @@ -280,6 +234,7 @@ namespace if ( aAISShape.IsNull() ) continue; +#ifdef USE_TEXTURED_SHAPE const Handle(Image_PixMap)& aPixmap = aAISShape->TexturePixMap(); if ( aPixmap.IsNull() ) continue; @@ -295,10 +250,10 @@ namespace aPixmapUsersMap.UnBind( aPixmap ); aPixmapCacheMap.remove( aPixmapCacheMap.key( aPixmap ) ); } +#endif } } } -#endif //================================================================ // Function : getActiveStudy @@ -507,6 +462,9 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st ) int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS); myWidth = resMgr->integerValue("Geometry", "edge_width", -1); myIsosWidth = resMgr->integerValue("Geometry", "isolines_width", -1); + + myTransparency = resMgr->integerValue("Geometry", "transparency", 0) / 100.; + myHasTransparency = false; myTypeOfMarker = (Aspect_TypeOfMarker)(std::min((int)Aspect_TOM_RING3, std::max((int)Aspect_TOM_POINT, aType))); myScaleOfMarker = (resMgr->integerValue("Geometry", "marker_scale", 1)-(int)GEOM::MS_10)*0.5 + 1.0; @@ -519,11 +477,9 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st ) myWidth = -1; myType = -1; - myTransparency = -1.0; myToActivate = true; // This parameter is used for activisation/deactivisation of objects to be displayed - #if OCC_VERSION_LARGE > 0x06050100 // Functionnality available only in OCCT 6.5.2 // Activate parallel vizualisation only for testing purpose // and if the corresponding env variable is set to 1 char* parallel_visu = getenv("PARALLEL_VISU"); @@ -532,7 +488,6 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st ) MESSAGE("Parallel visualisation on"); BRepMesh_IncrementalMesh::SetParallelDefault(Standard_True); } - #endif myViewFrame = 0; @@ -570,18 +525,12 @@ void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO, if ( prs ) { vf->BeforeDisplay( this, prs ); - vf->Display( prs ); + vf->Display( this, prs ); vf->AfterDisplay( this, prs ); if ( updateViewer ) vf->Repaint(); - int aMgrId = getViewManagerId(vf); - SalomeApp_Study* aStudy = getStudy(); - aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 1 ); - - setVisibilityState(theIO->getEntry(), Qtx::ShownState); - delete prs; // delete presentation because displayer is its owner } } @@ -626,17 +575,11 @@ void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO, SALOME_Prs* prs = vf->CreatePrs( theIO->getEntry() ); if ( prs ) { vf->BeforeErase( this, prs ); - vf->Erase( prs, forced ); + vf->Erase( this, prs, forced ); vf->AfterErase( this, prs ); if ( updateViewer ) vf->Repaint(); delete prs; // delete presentation because displayer is its owner - - int aMgrId = getViewManagerId(vf); - SalomeApp_Study* aStudy = getStudy(); - aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 0 ); - - setVisibilityState(theIO->getEntry(), Qtx::HiddenState); } } } @@ -739,6 +682,27 @@ void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateV UpdateViewer(); } +void GEOM_Displayer::UpdateVisibility( SALOME_View* v, const SALOME_Prs* p, bool on ) +{ + SalomeApp_Study* aStudy = getStudy(); + int vId = -1; + if ( v ) vId = getViewManagerId( v ); + + if ( p ) { + QString entry = p->GetEntry(); + if ( !entry.isEmpty() ) { + if ( vId != -1 ) + aStudy->setObjectProperty( vId, entry, GEOM::propertyName( GEOM::Visibility ), on ); + setVisibilityState( entry, on ? Qtx::ShownState : Qtx::HiddenState ); + } + } + else { + if ( vId != -1 ) { + aStudy->setObjectProperty( vId, GEOM::propertyName( GEOM::Visibility ), on ); + } + } +} + Quantity_Color GEOM_Displayer::qColorFromResources( const QString& property, const QColor& defColor ) { // VSR: this method can be improved in future: @@ -851,9 +815,6 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap // - color for edges in shading+edges mode AISShape->SetEdgesInShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value() ) ); - - // ??? - AISShape->storeBoundaryColors(); // set display mode AISShape->SetDisplayMode( HasDisplayMode() ? @@ -862,9 +823,20 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap // display mode from properties propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt() ); + // - face boundaries color + if( AISShape->DisplayMode() == GEOM_AISShape::ShadingWithEdges ) + AISShape->Attributes()->SetFaceBoundaryDraw( Standard_True ); + anAspect = AISShape->Attributes()->FaceBoundaryAspect(); + anAspect->SetColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value() ) ); + AISShape->Attributes()->SetFaceBoundaryAspect( anAspect ); + // set display vectors flag AISShape->SetDisplayVectors( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() ); + // set display vertices flag + bool isVerticesMode = propMap.value( GEOM::propertyName( GEOM::Vertices ) ).toBool(); + AISShape->SetDisplayVertices( isVerticesMode ); + // set transparency if( HasTransparency() ) { AISShape->SetTransparency( GetTransparency() ); @@ -914,7 +886,7 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap aImagePath = propMap.value( GEOM::propertyName( GEOM::Texture ) ).toString(); } -#if OCC_VERSION_LARGE > 0x06070000 +#ifdef USE_TEXTURED_SHAPE Handle(Image_PixMap) aPixmap; if ( !aImagePath.isEmpty() ) aPixmap = cacheTextureFor( aImagePath, AISShape ); @@ -930,12 +902,6 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap else { AISShape->SetTextureMapOff(); } -#else - if ( !aImagePath.isEmpty() ) { - AISShape->SetTextureFileName( TCollection_AsciiString( aImagePath.toUtf8().constData() ) ); - AISShape->SetTextureMapOn(); - AISShape->DisableTextureModulate(); - } #endif // set line width @@ -949,7 +915,7 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap AISShape->setTopLevel( propMap.value( GEOM::propertyName( GEOM::TopLevel ) ).toBool() ); // set point marker (for vertex / compound of vertices only) - if ( onlyVertex ) { + if ( onlyVertex || isVerticesMode ) { QStringList aList = propMap.value( GEOM::propertyName( GEOM::PointMarker ) ).toString().split( GEOM::subSectionSeparator() ); if ( aList.size() == 2 ) { // standard marker string contains "TypeOfMarker:ScaleOfMarker" @@ -969,14 +935,9 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap // custom marker string contains "IdOfTexture" int textureId = aList[0].toInt(); Standard_Integer aWidth, aHeight; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) aTexture = -#else - Handle(Graphic3d_HArray1OfBytes) aTexture = -#endif GeometryGUI::getTexture( study, textureId, aWidth, aHeight ); if ( !aTexture.IsNull() ) { -#if OCC_VERSION_LARGE > 0x06060000 // Porting to OCCT higher 6.6.0 version Handle(Prs3d_PointAspect) aTextureAspect = new Prs3d_PointAspect( HasColor() ? // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function @@ -985,18 +946,6 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value() ), aWidth, aHeight, aTexture ); -#else - int TextureId = 0; - Handle(Prs3d_PointAspect) aTextureAspect = - new Prs3d_PointAspect( HasColor() ? - // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function - (Quantity_NameOfColor)GetColor() : - // color from properties - SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value() ), - ++TextureId, - aWidth, aHeight, - aTexture ); -#endif AISShape->Attributes()->SetPointAspect( aTextureAspect ); } } @@ -1012,7 +961,7 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap if ( create && !isTemporary && aMgrId != -1 ) { // set properties to the study - study->setObjectPropMap( aMgrId, entry, propMap ); + study->setObjectProperties( aMgrId, entry, propMap ); } // AISShape->SetName(???); ??? necessary to set name ??? @@ -1138,6 +1087,9 @@ void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create ) // set display vectors flag actor->SetVectorMode( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() ); + // set display vertices flag + actor->SetVerticesMode( propMap.value( GEOM::propertyName( GEOM::Vertices ) ).toBool() ); + // set display mode int displayMode = HasDisplayMode() ? // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function @@ -1163,7 +1115,7 @@ void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create ) if ( create && !isTemporary && aMgrId != -1 ) { // set properties to the study - study->setObjectPropMap( aMgrId, entry, propMap ); + study->setObjectProperties( aMgrId, entry, propMap ); } } @@ -2000,13 +1952,11 @@ void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p ) UpdateColorScale(false,false); } -#if OCC_VERSION_LARGE > 0x06070000 void GEOM_Displayer::BeforeErase( SALOME_View* v, const SALOME_OCCPrs* p ) { LightApp_Displayer::BeforeErase( v, p ); releaseTextures( p ); } -#endif void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p ) { @@ -2057,24 +2007,54 @@ void GEOM_Displayer::UnsetColor() * Set transparency for shape displaying. */ //================================================================= -void GEOM_Displayer::SetTransparency( const double transparency ) +double GEOM_Displayer::SetTransparency( const double transparency ) { - myTransparency = transparency; + double aPrevTransparency = myTransparency; + if ( transparency < 0 ) { + UnsetTransparency(); + } + else { + myTransparency = transparency; + myHasTransparency = true; + } + return aPrevTransparency; } +//================================================================= +/*! + * GEOM_Displayer::GetTransparency + * Get transparency for shape displaying. + */ +//================================================================= double GEOM_Displayer::GetTransparency() const { return myTransparency; } +//================================================================= +/*! + * GEOM_Displayer::HasTransparency + * Check if transparency for shape displaying is set. + */ +//================================================================= bool GEOM_Displayer::HasTransparency() const { - return myTransparency != -1.0; + return myHasTransparency; } -void GEOM_Displayer::UnsetTransparency() +//================================================================= +/*! + * GEOM_Displayer::UnsetTransparency + * Unset transparency for shape displaying. + */ +//================================================================= +double GEOM_Displayer::UnsetTransparency() { - myTransparency = -1.0; + double aPrevTransparency = myTransparency; + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + myTransparency = resMgr->integerValue("Geometry", "transparency", 0) / 100.; + myHasTransparency = false; + return aPrevTransparency; } @@ -2365,7 +2345,7 @@ PropMap GEOM_Displayer::getObjectProperties( SalomeApp_Study* study, if ( viewModel && viewId != -1 ) { // get properties from the study - PropMap storedMap = study->getObjectPropMap( viewId, entry ); + PropMap storedMap = study->getObjectProperties( viewId, entry ); // overwrite default properties from stored ones (that are specified) for ( int prop = GEOM::Visibility; prop <= GEOM::LastProperty; prop++ ) { if ( storedMap.contains( GEOM::propertyName( (GEOM::Property)prop ) ) ) @@ -2452,7 +2432,8 @@ PropMap GEOM_Displayer::getDefaultPropertyMap() arg( resMgr->integerValue( "Geometry", "iso_number_v", 1 ) ) ); // - transparency (opacity = 1-transparency) - propMap.insert( GEOM::propertyName( GEOM::Transparency ), 0.0 ); + propMap.insert( GEOM::propertyName( GEOM::Transparency ), + resMgr->integerValue( "Geometry", "transparency", 0 ) / 100. ); // - display mode (take default value from preferences) propMap.insert( GEOM::propertyName( GEOM::DisplayMode ), @@ -2461,6 +2442,9 @@ PropMap GEOM_Displayer::getDefaultPropertyMap() // - show edges direction flag (false by default) propMap.insert( GEOM::propertyName( GEOM::EdgesDirection ), false ); + // - show vertices flag (false by default) + propMap.insert( GEOM::propertyName( GEOM::Vertices ), false ); + // - shading color (take default value from preferences) propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), colorFromResources( "shading_color", QColor( 255, 255, 0 ) ) ); @@ -2971,7 +2955,7 @@ void GEOM_Displayer::UpdateColorScale( const bool theIsRedisplayFieldSteps, cons { if( SUIT_ViewManager* aViewManager = *vmIt ) { - const ObjMap anObjects = aStudy->getObjectMap( aViewManager->getGlobalId() ); + const ObjMap& anObjects = aStudy->getObjectProperties( aViewManager->getGlobalId() ); for( ObjMap::ConstIterator objIt = anObjects.begin(); objIt != anObjects.end(); objIt++ ) { _PTR(SObject) aSObj( aStudyDS->FindObjectID( objIt.key().toLatin1().constData() ) ); diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h index 257b4494e..0096c51b2 100644 --- a/src/GEOMGUI/GEOM_Displayer.h +++ b/src/GEOMGUI/GEOM_Displayer.h @@ -128,6 +128,9 @@ public: const bool theUpdateViewer, SALOME_View* theViewFrame ); + /* Update visibility state */ + void UpdateVisibility( SALOME_View*, const SALOME_Prs*, bool ); + /* build presentation accordint to the current viewer type*/ SALOME_Prs* BuildPrs ( GEOM::GEOM_Object_ptr ); SALOME_Prs* BuildPrs ( const TopoDS_Shape& ); @@ -139,8 +142,8 @@ public: int GetColor () const; bool HasColor () const; - void SetTransparency ( const double ); - void UnsetTransparency(); + double SetTransparency ( const double ); + double UnsetTransparency(); double GetTransparency () const; bool HasTransparency () const; @@ -175,9 +178,7 @@ public: virtual void Update( SALOME_VTKPrs* ); virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* ); virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* ); -#if OCC_VERSION_LARGE > 0x06070000 virtual void BeforeErase ( SALOME_View*, const SALOME_OCCPrs* ); -#endif virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* ); /* This methos is used for activisation/deactivisation of objects to be displayed*/ @@ -294,6 +295,7 @@ protected: Aspect_TypeOfMarker myTypeOfMarker; double myScaleOfMarker; double myTransparency; + bool myHasTransparency; private: SalomeApp_Application* myApp; diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 467cc55de..40c06a632 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -1215,6 +1215,10 @@ ICO_SHELL_SEL_ONLY build_shell.png + + ICO_CURVE_CREATOR + polyline.png + ICO_SKETCH sketch.png @@ -1315,26 +1319,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 30942dd61..06cb15a74 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -535,6 +535,10 @@ Please, select face, shell or solid and try again GEOM_CYLINDER_TITLE Cylinder Construction + + GEOM_CYLINDER_ANGLE_ERR + Angle values 0 and 360 are unsafe to build proper volumes. Please uncheck the "Angle" box to use the regular cylinder constructor. + GEOM_D1 D1 : @@ -904,14 +908,6 @@ Please, select face, shell or solid and try again GEOM_INERTIA_CONSTR Matrix And Moments Of Inertia - - GEOM_INERTIA_I - %1:1 : - - - GEOM_INERTIA_IXYZ - IX & IY & IZ : - GEOM_INERTIA_TITLE Calculs Of Inertia @@ -1008,14 +1004,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 @@ -2234,7 +2222,7 @@ Please, select face, shell or solid and try again GEOM_VERTEXES - Vertexes + Vertices GEOM_WATER_DENSITY @@ -2370,7 +2358,15 @@ Please, select face, shell or solid and try again MEN_CURVE_CREATOR - Curve creator + 2D Polyline + + + TOP_CURVE_CREATOR + Create 2D polyline + + + STB_CURVE_CREATOR + Create 2D polyline MEN_ALL_SEL_ONLY @@ -2590,7 +2586,7 @@ Please, select face, shell or solid and try again MEN_EXPORT - Export... + Export MEN_EXTRUSION @@ -2698,7 +2694,7 @@ Please, select face, shell or solid and try again MEN_IMPORT - Import... + Import MEN_INERTIA @@ -2896,6 +2892,10 @@ Please, select face, shell or solid and try again MEN_POP_VECTORS Show Edge Direction + + MEN_POP_VERTICES + Show Vertices + MEN_PREFERENCES Preferences @@ -3068,6 +3068,14 @@ Please, select face, shell or solid and try again MEN_VECTOR_MODE_OFF Hide Edge Direction + + MEN_VERTICES_MODE_ON + Show Vertices + + + MEN_VERTICES_MODE_OFF + Hide Vertices + MEN_WIREFRAME Wireframe @@ -3148,6 +3156,10 @@ Please, select face, shell or solid and try again PREF_DISPLAY_MODE Default display mode + + PREF_TRANSPARENCY + Transparency + PREF_FREE_BOUND_COLOR Color of free boundaries @@ -3524,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 @@ -3612,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 @@ -3760,6 +3764,10 @@ Please, select face, shell or solid and try again STB_POP_VECTORS Show Edge Direction + + STB_POP_VERTICES + Show Vertices + STB_POP_SETTEXTURE Add a texture @@ -3984,54 +3992,6 @@ Please, select face, shell or solid and try again TOM_X X - - TOOL_BASIC - Basic - - - TOOL_BLOCKS - Blocks - - - TOOL_BOOLEAN - Boolean operations - - - TOOL_FEATURES - Modification - - - TOOL_GENERATION - Generation - - - TOOL_PRIMITIVES - Primitives - - - TOOL_TRANSFORMATION - Transformation - - - TOOL_BUILD - Build - - - TOOL_OPERATIONS - Operations - - - TOOL_PICTURES - Pictures - - - TOOL_ADVANCED - Advanced - - - TOOL_MEASURES - Measures - TOP_ARC Create an arc @@ -4176,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 @@ -4256,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 @@ -4760,6 +4712,14 @@ Please, select face, shell or solid and try again STB_MANAGE_DIMENSIONS Manage measurement dimensions of an object + + MEN_POP_SHOW_DEPENDENCY_TREE + Show dependency tree + + + MEN_POP_REDUCE_STUDY + Reduce study + MEN_POP_SHOW_ALL_DIMENSIONS Show all dimensions @@ -5024,6 +4984,66 @@ Please, select face, shell or solid and try again GEOM_PREVIEW Preview + + PREF_TAB_DEPENDENCY_VIEW + Dependency Tree + + + PREF_HIERARCHY_TYPE + Hierarchy type + + + MEN_ONLY_ASCENDANTS + Display only ascendants tree + + + MEN_ONLY_DESCENDANTS + Display only descendants tree + + + MEN_BOTH_ASCENDANTS_DESCENDANTS + Display both ascendants and descendants trees + + + GEOM_MOVE_POSSIBILITY + Possibility to move nodes + + + PREF_GROUP_DEPENDENCY_VIEW_COLOR + Color + + + PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR + Background color + + + PREF_DEPENDENCY_VIEW_NODE_COLOR + Default node color + + + PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR + Main node color + + + PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR + Unpublished node color + + + PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR + Selected node color + + + PREF_DEPENDENCY_VIEW_ARROW_COLOR + Default arrow color + + + PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR + Highlighted arrow color + + + PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR + Selected arrow color + GEOM_ALL_IMPORT_FILES All supported formats ( %1 ) @@ -5051,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 @@ -5085,58 +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 - - - TOOL_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 @@ -5146,6 +5109,77 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif X=%1, Y=%2, Z=%3 + + GeometryGUI + + TOOL_BASIC + Basic + + + TOOL_BLOCKS + Blocks + + + TOOL_BOOLEAN + Boolean operations + + + TOOL_FEATURES + Modification + + + TOOL_GENERATION + Generation + + + TOOL_PRIMITIVES + Primitives + + + TOOL_TRANSFORMATION + Transformation + + + TOOL_BUILD + Build + + + TOOL_OPERATIONS + Operations + + + TOOL_PICTURES + Pictures + + + TOOL_ADVANCED + Advanced + + + TOOL_MEASURES + Measures + + + TOOL_IMPORTEXPORT + Import / Export XAO + + + TABLE_SECTION + Section + + + TABLE_INDEX + Index + + + TABLE_X + X + + + TABLE_Y + Y + + BasicGUI_CurveDlg @@ -5386,74 +5420,39 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif Face 2 V - - CurveCreator_NewPointDlg - - ADD_NEW_POINT - Add new points - - - X_COORD - X - - - Y_COORD - Y - - - Z_COORD - Z - - - ADD_BTN - Add - - - ADD_CONTINUE_BTN - Add and continue - - - ADD_NEW_POINT_TO_%1 - Add new point to %1 - - - SET_POINT_COORDINATES - Set point coordinates - - CurveCreator_NewSectionDlg - NAME + SECTION_NAME Name - LINE_TYPE + SECTION_LINE_TYPE Type - POLYLINE_TYPE + SECTION_POLYLINE_TYPE Polyline - SPLINE_TYPE + SECTION_SPLINE_TYPE Spline - LINE_CLOSED + SECTION_LINE_CLOSED Closed - OK - Ok - - - ADD_BTN + SECTION_ADD_BTN Add - ADD_CONTINUE_BTN - Add and continue + SECTION_OK_BTN + Ok + + + SECTION_CANCEL_BTN + Cancel ADD_NEW_SECTION @@ -5478,11 +5477,7 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif CurveCreator_Widget - CURVE_NAME_TLT - Name - - - SECTION_GROUP_TLT + SECTION_GROUP_TITLE Sections @@ -5509,22 +5504,6 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif NEW_SECTION_TLT Insert new section - - INSERT_SECTION_BEFORE - Insert section before - - - INSERT_SECTION_BEFORE_TLT - Insert section before - - - INSERT_SECTION_AFTER - Insert section after - - - INSERT_SECTION_AFTER_TLT - Insert section after - ADDITION_MODE Addition mode @@ -5549,18 +5528,6 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif DETECTION_MODE_TLT Detection mode - - INSERT_POINT_BEFORE - Insert point before - - - INSERT_POINT_BEFORE_TLT - Insert point before - - - INSERT_POINT_AFTER - Insert point after - CLOSE_SECTIONS Set closed @@ -5609,22 +5576,6 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif JOIN_TLT Join selected sections - - STEP_UP - Move up - - - STEP_UP_TLT - Move selected objects up - - - STEP_DOWN - Move down - - - STEP_DOWN_TLT - Move selected objects down - CLEAR_ALL Clear all @@ -5642,6 +5593,33 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif Join all sections + + EntityGUI_PolylineDlg + + POLYLINE_DLG_TITLE + Polyline Construction + + + POLYLINE_TITLE + Polyline + + + POLYLINE_NAME + Polyline + + + POLYLINE_IMPORT + Import polyline + + + POLYLINE_ADD_SECTION + Add section + + + POLYLINE_EDIT_SECTION + Edit section + + EntityGUI_SketcherDlg @@ -6821,6 +6799,61 @@ Do you want to create new material? P&ublish And Close + + GEOMToolsGUI_ReduceStudyDlg + + GEOM_REDUCE_STUDY_TITLE + Reduce study + + + GEOM_REDUCE_STUDY_KEPT_OBJECTS + Objects to be kept + + + GEOM_REDUCE_STUDY_REMOVE_OBJECTS + Objects to be removed + + + GEOM_REDUCE_STUDY_NAME + Name + + + GEOM_REDUCE_STUDY_OPTIONS + Options + + + GEOM_REDUCE_STUDY_INTERMEDIATES + Intermediate objects + + + GEOM_REDUCE_STUDY_SUB_OBJECTS + Sub-objects + + + GEOM_REDUCE_STUDY_KEEP + Keep + + + GEOM_REDUCE_STUDY_UNPUBLISH + Unpublish + + + GEOM_REDUCE_STUDY_REMOVE + Remove + + + GEOM_REDUCE_STUDY_REMOVE_EMPTY_FOLDER + Remove empty folders + + + GEOM_REDUCE_STUDY_SOFT_REMOVAL + Soft removal + + + GEOM_REDUCE_STUDY_WARNING_DELETE + Do you really want to delete intermediate objects? After applying this operation study will be broken. + + RepairGUI_UnionFacesDlg @@ -6859,72 +6892,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 df93751d1..7bb28365f 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -547,6 +547,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau GEOM_CYLINDER_TITLE Construction d'un cylindre + + GEOM_CYLINDER_ANGLE_ERR + Les valeurs de l'angle 0 et 360 sont à éviter pour construire des volumes sains. Veuillez décocher la case "Angle" pour utiliser le constructeur de cylindre complet. + GEOM_D1 D1 : @@ -916,14 +920,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau GEOM_INERTIA_CONSTR Matrice et moment d'inertie - - GEOM_INERTIA_I - %1:1 : - - - GEOM_INERTIA_IXYZ - IX & IY & IZ : - GEOM_INERTIA_TITLE Calcul de l'inertie @@ -1020,14 +1016,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 @@ -2598,7 +2586,7 @@ Choisissez une face, une coque ou un solide et essayez de nouveau MEN_EXPORT - Exporter... + Exporter MEN_EXTRUSION @@ -2706,7 +2694,7 @@ Choisissez une face, une coque ou un solide et essayez de nouveau MEN_IMPORT - Importer... + Importer MEN_INERTIA @@ -2904,6 +2892,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau MEN_POP_VECTORS Afficher l'orientation des arêtes + + MEN_POP_VERTICES + Show Vertices + MEN_PREFERENCES Préférences @@ -3072,6 +3064,14 @@ Choisissez une face, une coque ou un solide et essayez de nouveau MEN_VECTOR_MODE_OFF Cacher l'orientation de l'arête + + MEN_VERTICES_MODE_ON + Show Vertices + + + MEN_VERTICES_MODE_OFF + Hide Vertices + MEN_WIREFRAME Filaire @@ -3152,6 +3152,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau PREF_DISPLAY_MODE Mode de visualisation + + PREF_TRANSPARENCY + Transparence + PREF_FREE_BOUND_COLOR Couleur des contours libres @@ -3528,10 +3532,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 @@ -3616,10 +3616,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 @@ -3764,6 +3760,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau STB_POP_VECTORS Afficher l'orientation des arêtes + + STB_POP_VERTICES + Show Vertices + STB_POP_SETTEXTURE Ajoute une texture @@ -3988,54 +3988,6 @@ Choisissez une face, une coque ou un solide et essayez de nouveau TOM_X X - - TOOL_BASIC - Objets de base - - - TOOL_BLOCKS - Blocs - - - TOOL_BOOLEAN - Opérations booléennes - - - TOOL_FEATURES - Modification - - - TOOL_GENERATION - Génération - - - TOOL_PRIMITIVES - Primitives - - - TOOL_TRANSFORMATION - Transformation - - - TOOL_BUILD - Construire - - - TOOL_OPERATIONS - Opérations - - - TOOL_PICTURES - Images - - - TOOL_ADVANCED - Avancé - - - TOOL_MEASURES - Informations - TOP_ARC Créer un arc @@ -4180,10 +4132,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 @@ -4260,10 +4208,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 @@ -4760,6 +4704,14 @@ Choisissez une face, une coque ou un solide et essayez de nouveau STB_MANAGE_DIMENSIONS Gérer la cotation d'un objet + + MEN_POP_SHOW_DEPENDENCY_TREE + Show dependency tree + + + MEN_POP_SHOW_REDUCE_STUDY + Reduce study + MEN_POP_SHOW_ALL_DIMENSIONS Afficher les cotations @@ -5024,6 +4976,66 @@ Choisissez une face, une coque ou un solide et essayez de nouveau GEOM_PREVIEW Prévisualiser + + PREF_TAB_DEPENDENCY_VIEW + Dependency Tree + + + PREF_HIERARCHY_TYPE + Hierarchy type + + + MEN_ONLY_ASCENDANTS + Display only ascendants tree + + + MEN_ONLY_DESCENDANTS + Display only descendants tree + + + MEN_BOTH_ASCENDANTS_DESCENDANTS + Display both ascendants and descendants trees + + + GEOM_MOVE_POSSIBILITY + Possibility to move nodes + + + PREF_GROUP_DEPENDENCY_VIEW_COLOR + Color + + + PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR + Background color + + + PREF_DEPENDENCY_VIEW_NODE_COLOR + Default node color + + + PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR + Main node color + + + PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR + Unpublished node color + + + PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR + Selected node color + + + PREF_DEPENDENCY_VIEW_ARROW_COLOR + Arrow color + + + PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR + Highlighted arrow color + + + PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR + Selected arrow color + GEOM_ALL_IMPORT_FILES Tous les formats supportés ( %1 ) @@ -5051,11 +5063,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 @@ -5085,58 +5092,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 - - - TOOL_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 @@ -5146,6 +5101,61 @@ le paramètre '%1' aux préférences du module Géométrie.X=%1, Y=%2, Z=%3 + + GeometryGUI + + TOOL_BASIC + Objets de base + + + TOOL_BLOCKS + Blocs + + + TOOL_BOOLEAN + Opérations booléennes + + + TOOL_FEATURES + Modification + + + TOOL_GENERATION + Génération + + + TOOL_PRIMITIVES + Primitives + + + TOOL_TRANSFORMATION + Transformation + + + TOOL_BUILD + Construire + + + TOOL_OPERATIONS + Opérations + + + TOOL_PICTURES + Images + + + TOOL_ADVANCED + Avancé + + + TOOL_MEASURES + Informations + + + TOOL_IMPORTEXPORT + Import / Export XAO + + BasicGUI_CurveDlg @@ -6821,6 +6831,61 @@ Voulez-vous en créer un nouveau ? P&ublier et fermer + + GEOMToolsGUI_ReduceStudyDlg + + GEOM_REDUCE_STUDY_TITLE + Reduce study + + + GEOM_REDUCE_STUDY_KEPT_OBJECTS + Objects to be kept + + + GEOM_REDUCE_STUDY_REMOVE_OBJECTS + Objects to be removed + + + GEOM_REDUCE_STUDY_NAME + Name + + + GEOM_REDUCE_STUDY_OPTIONS + Options + + + GEOM_REDUCE_STUDY_INTERMEDIATES + Intermediate objects + + + GEOM_REDUCE_STUDY_SUB_OBJECTS + Sub-objects + + + GEOM_REDUCE_STUDY_KEEP + Keep + + + GEOM_REDUCE_STUDY_UNPUBLISH + Unpublish + + + GEOM_REDUCE_STUDY_REMOVE + Remove + + + GEOM_REDUCE_STUDY_REMOVE_EMPTY_FOLDER + Remove empty folders + + + GEOM_REDUCE_STUDY_SOFT_REMOVAL + Soft removal + + + GEOM_REDUCE_STUDY_WARNING_DELETE + Do you really want to delete intermediate objects? After applying this operation study will be broken. + + RepairGUI_UnionFacesDlg @@ -6859,72 +6924,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 dc0079230..8ee7476d7 100644 --- a/src/GEOMGUI/GEOM_msg_ja.ts +++ b/src/GEOMGUI/GEOM_msg_ja.ts @@ -899,14 +899,6 @@ GEOM_INERTIA_CONSTR 行列とモーメント - - GEOM_INERTIA_I - %1:1。 - - - GEOM_INERTIA_IXYZ - IX & IY & IZ : - GEOM_INERTIA_TITLE 慣性の計算 @@ -1003,14 +995,6 @@ GEOM_MEN_ENTER_ANGLE 角度を度数で指定します - - GEOM_MEN_EXPORT - エクスポート - - - GEOM_MEN_IMPORT - インポート - GEOM_MEN_ISOS 輪郭線の数を選択します。 @@ -1465,7 +1449,7 @@ GEOM_PRP_EXPORT - ジオメトリを %1 にエクスポート... + ジオメトリを %1 にエクスポート GEOM_PRP_LOADING @@ -2693,7 +2677,7 @@ MEN_IMPORT - インポート... + インポート MEN_INERTIA @@ -2891,6 +2875,10 @@ MEN_POP_VECTORS ベクトル方向表示 + + MEN_POP_VERTICES + Show Vertices + MEN_PREFERENCES 設定 @@ -3063,6 +3051,14 @@ MEN_VECTOR_MODE_OFF エッジの方向を非表示 + + MEN_VERTICES_MODE_ON + Show Vertices + + + MEN_VERTICES_MODE_OFF + Hide Vertices + MEN_WIREFRAME ワイヤ フレーム @@ -3143,6 +3139,10 @@ PREF_DISPLAY_MODE 表示モード + + PREF_TRANSPARENCY + 透明度 + PREF_FREE_BOUND_COLOR 自由境界の色 @@ -3519,10 +3519,6 @@ STB_EXPLODE_BLOCKS ブロックで展開 - - STB_EXPORT - ジオメトリをBREPファイルにエクスポート - STB_EXTRUSION 押し出しを作成 @@ -3607,10 +3603,6 @@ STB_HEX_SOLID Hexahedral_Solid - - STB_IMPORT - BREPファイルをジオメトリにインポート - STB_INERTIA オブジェクトの慣性モーメントを計算します。 @@ -3755,6 +3747,10 @@ STB_POP_VECTORS エッジの方向を表示します。 + + STB_POP_VERTICES + Show Vertices + STB_POP_SETTEXTURE テクスチャを追加します。 @@ -3979,54 +3975,6 @@ TOM_X X - - TOOL_BASIC - 基礎オブジェクト - - - TOOL_BLOCKS - ブロック分割 - - - TOOL_BOOLEAN - ブーリアン操作 - - - TOOL_FEATURES - フィーチャー - - - TOOL_GENERATION - 押し出し/回転 - - - TOOL_PRIMITIVES - 基本図形 - - - TOOL_TRANSFORMATION - 変形/移動/回転 - - - TOOL_BUILD - 構築 - - - TOOL_OPERATIONS - 操作 - - - TOOL_PICTURES - 画像 - - - TOOL_ADVANCED - 高度なツール - - - TOOL_MEASURES - 情報/測定 - TOP_ARC 円弧を作成 @@ -4171,10 +4119,6 @@ TOP_EXPLODE_BLOCKS ブロックで展開 - - TOP_EXPORT - ジオメトリをBREPファイルでエクスポート - TOP_EXTRUSION 押し出しを作成 @@ -4251,10 +4195,6 @@ TOP_HEX_SOLID Hexahedral_Solid - - TOP_IMPORT - BREPファイルをジオメトリにインポート - TOP_INERTIA 慣性モーメント @@ -4755,6 +4695,14 @@ STB_MANAGE_DIMENSIONS オブジェクトの基準寸法を管理 + + MEN_POP_SHOW_DEPENDENCY_TREE + Show dependency tree + + + MEN_POP_SHOW_REDUCE_STUDY + Reduce study + MEN_POP_SHOW_ALL_DIMENSIONS すべての寸法を表示 @@ -5019,6 +4967,66 @@ GEOM_PREVIEW プレビュー + + PREF_TAB_DEPENDENCY_VIEW + Dependency Tree + + + PREF_HIERARCHY_TYPE + Hierarchy type + + + MEN_ONLY_ASCENDANTS + Display only ascendants tree + + + MEN_ONLY_DESCENDANTS + Display only descendants tree + + + MEN_BOTH_ASCENDANTS_DESCENDANTS + Display both ascendants and descendants trees + + + GEOM_MOVE_POSSIBILITY + Possibility to move nodes + + + PREF_GROUP_DEPENDENCY_VIEW_COLOR + Color + + + PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR + Background color + + + PREF_DEPENDENCY_VIEW_NODE_COLOR + Default node color + + + PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR + Main node color + + + PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR + Unpublished node color + + + PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR + Selected node color + + + PREF_DEPENDENCY_VIEW_ARROW_COLOR + Arrow color + + + PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR + Highlighted arrow color + + + PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR + Selected arrow color + GEOM_ALL_IMPORT_FILES サポートされているすべての形式 (%1) @@ -5043,10 +5051,6 @@ GEOM_PUBLISH_NAMED_SHAPES 指定したオブジェクトのグループ(存在する場合)を作成しますか? - - GEOM_SCALE_DIMENSIONS - インポートしたファイルの単位をミリメートルからメートルに変換しますか?いいえを選んだ場合、メートル単位として解釈します。 - GEOM_PRECISION_HINT パラメーターの入力値の精度を調整することは '%1' の好みにジオメトリ モジュールの。 @@ -5075,58 +5079,6 @@ GEOM_SELECT_IMAGE イメージの選択. - - MEN_IMPORTEXPORT - インポート/エクスポート - - - TOOL_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 @@ -5136,6 +5088,61 @@ X=%1, Y=%2, Z=%3 + + GeometryGUI + + TOOL_BASIC + 基礎オブジェクト + + + TOOL_BLOCKS + ブロック分割 + + + TOOL_BOOLEAN + ブーリアン操作 + + + TOOL_FEATURES + フィーチャー + + + TOOL_GENERATION + 押し出し/回転 + + + TOOL_PRIMITIVES + 基本図形 + + + TOOL_TRANSFORMATION + 変形/移動/回転 + + + TOOL_BUILD + 構築 + + + TOOL_OPERATIONS + 操作 + + + TOOL_PICTURES + 画像 + + + TOOL_ADVANCED + 高度なツール + + + TOOL_MEASURES + 情報/測定 + + + TOOL_IMPORTEXPORT + インポート/エクスポート + + BasicGUI_CurveDlg @@ -6801,6 +6808,61 @@ 発行し閉じる(&u) + + GEOMToolsGUI_ReduceStudyDlg + + GEOM_REDUCE_STUDY_TITLE + Reduce study + + + GEOM_REDUCE_STUDY_KEPT_OBJECTS + Objects to be kept + + + GEOM_REDUCE_STUDY_REMOVE_OBJECTS + Objects to be removed + + + GEOM_REDUCE_STUDY_NAME + Name + + + GEOM_REDUCE_STUDY_OPTIONS + Options + + + GEOM_REDUCE_STUDY_INTERMEDIATES + Intermediate objects + + + GEOM_REDUCE_STUDY_SUB_OBJECTS + Sub-objects + + + GEOM_REDUCE_STUDY_KEEP + Keep + + + GEOM_REDUCE_STUDY_UNPUBLISH + Unpublish + + + GEOM_REDUCE_STUDY_REMOVE + Remove + + + GEOM_REDUCE_STUDY_REMOVE_EMPTY_FOLDER + Remove empty folders + + + GEOM_REDUCE_STUDY_SOFT_REMOVAL + Soft removal + + + GEOM_REDUCE_STUDY_WARNING_DELETE + Do you really want to delete intermediate objects? After applying this operation study will be broken. + + RepairGUI_UnionFacesDlg @@ -6839,72 +6901,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 f10e4a026..c7e69aec2 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" @@ -65,6 +65,8 @@ #include #include +#include + #include #include #include @@ -76,8 +78,7 @@ #include #include -// #include -#include +#include #include #include @@ -106,11 +107,7 @@ #include #include -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #include -#else -#include -#endif #include @@ -433,6 +430,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) SUIT_ViewWindow* window = desk->activeWindow(); bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); + bool ViewDep = ( window && window->getViewManager()->getType() == GraphicsView_Viewer::Type() ); // if current viewframe is not of OCC and not of VTK type - return immediately // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example) QList NotViewerDependentCommands; @@ -447,7 +445,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) << GEOMOp::OpPointMarker << GEOMOp::OpCreateFolder << GEOMOp::OpSortChildren; - if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) ) { + if ( !ViewOCC && !ViewVTK && !ViewDep && !NotViewerDependentCommands.contains( id ) ) { // activate OCC viewer getApp()->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true); } @@ -464,8 +462,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 @@ -502,6 +498,8 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpClsBringToFront: // case GEOMOp::OpCreateFolder: // POPUP MENU - CREATE FOLDER case GEOMOp::OpSortChildren: // POPUP MENU - SORT CHILD ITEMS + case GEOMOp::OpShowDependencyTree: // POPUP MENU - SHOW DEPENDENCY TREE + case GEOMOp::OpReduceStudy: // POPUP MENU - REDUCE STUDY libName = "GEOMToolsGUI"; break; case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME @@ -515,11 +513,13 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpHide: // MENU VIEW - ERASE case GEOMOp::OpShow: // MENU VIEW - DISPLAY case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE + case GEOMOp::OpSwitchVertices: // MENU VIEW - VERTICES MODE case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME case GEOMOp::OpShading: // POPUP MENU - SHADING case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES case GEOMOp::OpTexture: // POPUP MENU - TEXTURE case GEOMOp::OpVectors: // POPUP MENU - VECTORS + case GEOMOp::OpVertices: // POPUP MENU - VERTICES libName = "DisplayGUI"; break; case GEOMOp::OpPoint: // MENU BASIC - POINT @@ -560,6 +560,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpCreateField: // MENU FIELD - CREATE FIELD case GEOMOp::OpEditField: // MENU FIELD - EDIT FIELD case GEOMOp::OpEditFieldPopup: // POPUP MENU - EDIT FIELD + case GEOMOp::Op2dPolylineEditor: // MENU BASIC - POLYLINE EDITOR libName = "EntityGUI"; break; case GEOMOp::OpEdge: // MENU BUILD - EDGE @@ -599,10 +600,6 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT -#ifdef DEBUG_CURVE_CREATOR - // for debug purposes, to be removed - case GEOMOp::OpCurveCreator: // MENU OPERATION - CURVE CREATOR -#endif libName = "OperationGUI"; break; case GEOMOp::OpSewing: // MENU REPAIR - SEWING @@ -658,10 +655,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 @@ -894,9 +887,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" ); @@ -947,6 +937,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" ); #endif createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" ); + createGeomAction( GEOMOp::Op2dPolylineEditor, "CURVE_CREATOR" ); createGeomAction( GEOMOp::OpEdge, "EDGE" ); createGeomAction( GEOMOp::OpWire, "WIRE" ); @@ -979,10 +970,6 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" ); createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" ); createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" ); -#ifdef DEBUG_CURVE_CREATOR - // for debug purposes, to be removed - createGeomAction( GEOMOp::OpCurveCreator, "CURVE_CREATOR" ); -#endif createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" ); createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" ); @@ -1038,6 +1025,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" ); createGeomAction( GEOMOp::OpShow, "DISPLAY" ); createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE"); + createGeomAction( GEOMOp::OpSwitchVertices, "VERTICES_MODE"); createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true ); createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true ); createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true ); @@ -1059,6 +1047,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpEdgeWidth, "EDGE_WIDTH"); createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH"); createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true ); + createGeomAction( GEOMOp::OpVertices, "POP_VERTICES", "", 0, true ); createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" ); createGeomAction( GEOMOp::OpColor, "POP_COLOR" ); createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" ); @@ -1077,6 +1066,8 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" ); createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" ); createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" ); + createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" ); + createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" ); createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" ); createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" ); @@ -1092,10 +1083,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" ); @@ -1105,13 +1092,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 ); @@ -1119,19 +1099,20 @@ void GeometryGUI::initialize( CAM_Application* app ) int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 ); int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 ); - createMenu( GEOMOp::OpPoint, basicId, -1 ); - createMenu( GEOMOp::OpLine, basicId, -1 ); - createMenu( GEOMOp::OpCircle, basicId, -1 ); - createMenu( GEOMOp::OpEllipse, basicId, -1 ); - createMenu( GEOMOp::OpArc, basicId, -1 ); - createMenu( GEOMOp::OpCurve, basicId, -1 ); - createMenu( GEOMOp::Op2dSketcher, basicId, -1 ); - createMenu( GEOMOp::Op3dSketcher, basicId, -1 ); - createMenu( GEOMOp::OpIsoline, basicId, -1 ); - createMenu( separator(), basicId, -1 ); - createMenu( GEOMOp::OpVector, basicId, -1 ); - createMenu( GEOMOp::OpPlane, basicId, -1 ); - createMenu( GEOMOp::OpLCS, basicId, -1 ); + createMenu( GEOMOp::OpPoint, basicId, -1 ); + createMenu( GEOMOp::OpLine, basicId, -1 ); + createMenu( GEOMOp::OpCircle, basicId, -1 ); + createMenu( GEOMOp::OpEllipse, basicId, -1 ); + createMenu( GEOMOp::OpArc, basicId, -1 ); + createMenu( GEOMOp::OpCurve, basicId, -1 ); + createMenu( GEOMOp::Op2dSketcher, basicId, -1 ); + createMenu( GEOMOp::Op2dPolylineEditor, basicId, -1 ); + createMenu( GEOMOp::Op3dSketcher, basicId, -1 ); + createMenu( GEOMOp::OpIsoline, basicId, -1 ); + createMenu( separator(), basicId, -1 ); + createMenu( GEOMOp::OpVector, basicId, -1 ); + createMenu( GEOMOp::OpPlane, basicId, -1 ); + createMenu( GEOMOp::OpLCS, basicId, -1 ); createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 ); int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 ); @@ -1149,9 +1130,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpRevolution, genId, -1 ); createMenu( GEOMOp::OpFilling, genId, -1 ); createMenu( GEOMOp::OpPipe, genId, -1 ); -#if OCC_VERSION_LARGE > 0x06050300 createMenu( GEOMOp::OpPipePath, genId, -1 ); -#endif //int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 ); //createMenu( GEOMOp::OpSmoothingSurface, advId, -1 ); @@ -1239,11 +1218,6 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpChamfer, operId, -1 ); createMenu( GEOMOp::OpExtrudedBoss, operId, -1 ); createMenu( GEOMOp::OpExtrudedCut, operId, -1 ); -#ifdef DEBUG_CURVE_CREATOR - // for debug purposes, to be removed - createMenu( separator(), operId, -1 ); - createMenu( GEOMOp::OpCurveCreator, operId, -1 ); -#endif //createMenu( GEOMOp::OpClipping, operId, -1 ); int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 ); @@ -1312,6 +1286,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpDMTexture, dispmodeId, -1 ); createMenu( separator(), dispmodeId, -1 ); createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 ); + createMenu( GEOMOp::OpSwitchVertices, dispmodeId, -1 ); createMenu( separator(), viewId, -1 ); createMenu( GEOMOp::OpShowAll, viewId, -1 ); @@ -1332,26 +1307,27 @@ void GeometryGUI::initialize( CAM_Application* app ) // ---- create toolbars -------------------------- - int basicTbId = createTool( tr( "TOOL_BASIC" ) ); - createTool( GEOMOp::OpPoint, basicTbId ); - createTool( GEOMOp::OpLine, basicTbId ); - createTool( GEOMOp::OpCircle, basicTbId ); - createTool( GEOMOp::OpEllipse, basicTbId ); - createTool( GEOMOp::OpArc, basicTbId ); - createTool( GEOMOp::OpCurve, basicTbId ); - createTool( GEOMOp::OpVector, basicTbId ); - createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc - createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc - createTool( GEOMOp::OpIsoline, basicTbId ); - createTool( GEOMOp::OpPlane, basicTbId ); - createTool( GEOMOp::OpLCS, basicTbId ); + int basicTbId = createTool( tr( "TOOL_BASIC" ), QString( "GEOMBasic" ) ); + createTool( GEOMOp::OpPoint, basicTbId ); + createTool( GEOMOp::OpLine, basicTbId ); + createTool( GEOMOp::OpCircle, basicTbId ); + createTool( GEOMOp::OpEllipse, basicTbId ); + createTool( GEOMOp::OpArc, basicTbId ); + createTool( GEOMOp::OpCurve, basicTbId ); + createTool( GEOMOp::OpVector, basicTbId ); + createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc + createTool( GEOMOp::Op2dPolylineEditor, basicTbId ); + createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc + createTool( GEOMOp::OpIsoline, basicTbId ); + createTool( GEOMOp::OpPlane, basicTbId ); + createTool( GEOMOp::OpLCS, basicTbId ); createTool( GEOMOp::OpOriginAndVectors, basicTbId ); -// int sketchTbId = createTool( tr( "TOOL_SKETCH" ) ); +// int sketchTbId = createTool( tr( "TOOL_SKETCH" ), QString( "GEOMSketch" ) ); // createTool( GEOMOp::Op2dSketcher, sketchTbId ); // createTool( GEOMOp::Op3dSketcher, sketchTbId ); - int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) ); + int primTbId = createTool( tr( "TOOL_PRIMITIVES" ), QString( "GEOMPrimitives" ) ); createTool( GEOMOp::OpBox, primTbId ); createTool( GEOMOp::OpCylinder, primTbId ); createTool( GEOMOp::OpSphere, primTbId ); @@ -1361,26 +1337,24 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpDisk, primTbId ); //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc - //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ) ); + //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ), QString( "GEOMBlocks" ) ); //createTool( GEOMOp::OpDividedDisk, blocksTbId ); //createTool( GEOMOp::OpDividedCylinder, blocksTbId ); - int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) ); + int boolTbId = createTool( tr( "TOOL_BOOLEAN" ), QString( "GEOMBooleanOperations" ) ); createTool( GEOMOp::OpFuse, boolTbId ); createTool( GEOMOp::OpCommon, boolTbId ); createTool( GEOMOp::OpCut, boolTbId ); createTool( GEOMOp::OpSection, boolTbId ); - int genTbId = createTool( tr( "TOOL_GENERATION" ) ); + int genTbId = createTool( tr( "TOOL_GENERATION" ), QString( "GEOMGeneration" ) ); createTool( GEOMOp::OpPrism, genTbId ); createTool( GEOMOp::OpRevolution, genTbId ); createTool( GEOMOp::OpFilling, genTbId ); createTool( GEOMOp::OpPipe, genTbId ); -#if OCC_VERSION_LARGE > 0x06050300 createTool( GEOMOp::OpPipePath, genTbId ); -#endif - int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) ); + int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ), QString( "GEOMTransformation" ) ); createTool( GEOMOp::OpTranslate, transTbId ); createTool( GEOMOp::OpRotate, transTbId ); createTool( GEOMOp::OpChangeLoc, transTbId ); @@ -1392,26 +1366,22 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpMultiTranslate, transTbId ); createTool( GEOMOp::OpMultiRotate, transTbId ); - int operTbId = createTool( tr( "TOOL_OPERATIONS" ) ); + int operTbId = createTool( tr( "TOOL_OPERATIONS" ), QString( "GEOMOperations" ) ); createTool( GEOMOp::OpExplode, operTbId ); createTool( GEOMOp::OpPartition, operTbId ); createTool( GEOMOp::OpArchimede, operTbId ); createTool( GEOMOp::OpShapesOnShape, operTbId ); createTool( GEOMOp::OpSharedShapes, operTbId ); - int featTbId = createTool( tr( "TOOL_FEATURES" ) ); + int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) ); createTool( GEOMOp::OpFillet1d, featTbId ); createTool( GEOMOp::OpFillet2d, featTbId ); createTool( GEOMOp::OpFillet3d, featTbId ); createTool( GEOMOp::OpChamfer, featTbId ); createTool( GEOMOp::OpExtrudedBoss, featTbId ); createTool( GEOMOp::OpExtrudedCut, featTbId ); -#ifdef DEBUG_CURVE_CREATOR - // for debug purposes, to be removed - createTool( GEOMOp::OpCurveCreator, featTbId ); -#endif - int buildTbId = createTool( tr( "TOOL_BUILD" ) ); + int buildTbId = createTool( tr( "TOOL_BUILD" ), QString( "GEOMBuild" ) ); createTool( GEOMOp::OpEdge, buildTbId ); createTool( GEOMOp::OpWire, buildTbId ); createTool( GEOMOp::OpFace, buildTbId ); @@ -1419,7 +1389,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpSolid, buildTbId ); createTool( GEOMOp::OpCompound, buildTbId ); - int measureTbId = createTool( tr( "TOOL_MEASURES" ) ); + int measureTbId = createTool( tr( "TOOL_MEASURES" ), QString( "GEOMMeasures" ) ); createTool( GEOMOp::OpPointCoordinates, measureTbId ); createTool( GEOMOp::OpProperties, measureTbId ); createTool( GEOMOp::OpCenterMass, measureTbId ); @@ -1440,16 +1410,12 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpGetNonBlocks, measureTbId ); createTool( GEOMOp::OpCheckSelfInters, measureTbId ); - int picturesTbId = createTool( tr( "TOOL_PICTURES" ) ); + int picturesTbId = createTool( tr( "TOOL_PICTURES" ), QString( "GEOMPictures" ) ); createTool( GEOMOp::OpPictureImport, picturesTbId ); #ifdef WITH_OPENCV createTool( GEOMOp::OpFeatureDetect, picturesTbId ); #endif - int impexpTbId = createTool( tr( "TOOL_IMPORTEXPORT" ) ); - createTool( GEOMOp::OpExportXAO, impexpTbId ); - createTool( GEOMOp::OpImportXAO, impexpTbId ); - //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 @@// @@ -1486,7 +1452,6 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule ); mgr->insert( separator(), -1, -1 ); // ----------- -#if OCC_VERSION_LARGE > 0x06050200 //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false"; QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and isFolder=false and (selcount>0) and isOCC=true"; mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front @@ -1494,7 +1459,6 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule ); mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule ); -#endif mgr->insert( separator(), -1, -1 ); // ----------- dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe @@ -1513,6 +1477,9 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule ); + mgr->insert( action( GEOMOp::OpVertices ), dispmodeId, -1 ); // vertices + mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK + " and isVerticesMode", QtxPopupMgr::ToggleRule ); mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color @@ -1524,8 +1491,7 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker - //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule ); - mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpPointMarker ), clientOCCorOB + " and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0 and isOCC=true", QtxPopupMgr::VisibleRule ); // material properties mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 ); @@ -1622,6 +1588,14 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule ); + mgr->insert( separator(), -1, -1 ); // ----------- + mgr->insert( action( GEOMOp::OpShowDependencyTree ), -1, -1 ); // Show dependency tree + mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule ); + + mgr->insert( separator(), -1, -1 ); // ----------- + mgr->insert( action( GEOMOp::OpReduceStudy ), -1, -1 ); // Reduce Study + mgr->setRule( action( GEOMOp::OpReduceStudy ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule ); + mgr->hide( mgr->actionId( action( myEraseAll ) ) ); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -1645,131 +1619,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); + SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); + if (!appStudy) return; - QStringList PluginsXmlList = PluginsXml.split(":", QString::SkipEmptyParts); - if (PluginsXmlList.count() == 0) return; + // Find names of a resource XML files ("AdvancedGEOM.xml" and others); - // 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 ]; + GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo(); - // 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")); int id = GEOMOp::OpLastOperationID; // TODO? - // loop on xmlFiles - QString aNoAccessFiles; - for (int i = 0; i < xmlFiles.count(); i++) { - QString xmlFile = xmlFiles[ i ]; + // 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(); - QFile file (xmlFile); - if (file.exists() && file.open(QIODevice::ReadOnly)) { - file.close(); + // 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_" ); - 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); - - QString subTool = stools[0]; - subTool = subTool.toUpper().prepend("TOOL_"); - int toolId = createTool(tr(subTool.toLatin1().constData())); - //createTool(id, advancedTbarId); - createTool(id, toolId); - - // add action id to map - PluginAction anAction (aXmlHandler->myPluginData.myClientLib, anActionData.myLabel); - myPluginActions[id] = anAction; - - id++; - } + 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++; + } } } @@ -1810,8 +1730,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; @@ -1829,37 +1747,23 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg ); getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea ); + //NPAL 19674 + SALOME_ListIO selected; + sm->selectedObjects( selected ); + sm->clearSelected(); + SUIT_ViewManager* vm; ViewManagerList OCCViewManagers, VTKViewManagers; application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers ); QListIterator itOCC( OCCViewManagers ); while ( itOCC.hasNext() && (vm = itOCC.next()) ) - myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) ); + onViewManagerAdded(vm); application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers ); QListIterator itVTK( VTKViewManagers ); while ( itVTK.hasNext() && (vm = itVTK.next()) ) - myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast( vm->getViewModel() ), sm ) ); - - //NPAL 19674 - SALOME_ListIO selected; - sm->selectedObjects( selected ); - sm->clearSelected(); - - // disable OCC selectors - getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() ); - QListIterator itOCCSel( myOCCSelectors ); - while ( itOCCSel.hasNext() ) - if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() ) - sr->setEnabled(true); - - // disable VTK selectors - getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() ); - QListIterator itVTKSel( myVTKSelectors ); - while ( itVTKSel.hasNext() ) - if ( LightApp_VTKSelector* sr = itVTKSel.next() ) - sr->setEnabled(true); + onViewManagerAdded(vm); sm->setSelectedObjects( selected, true ); //NPAL 19674 @@ -1914,8 +1818,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); @@ -2091,15 +1993,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() ); } } } @@ -2110,7 +2019,7 @@ void GeometryGUI::updateCreationInfo() void GeometryGUI::onAutoBringToFront() { - bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" ); + bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" ); if( !isAutoBringToFront ) return; @@ -2178,20 +2087,12 @@ QString GeometryGUI::engineIOR() const return ""; } -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture -#else -Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture -#endif (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight) { theWidth = theHeight = 0; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) aTexture; -#else - Handle(Graphic3d_HArray1OfBytes) aTexture; -#endif if (theStudy) { TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ]; @@ -2205,11 +2106,7 @@ Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture theWidth = aWidth; theHeight = aHeight; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 aTexture = new TColStd_HArray1OfByte (1, aStream->length()); -#else - aTexture = new Graphic3d_HArray1OfBytes (1, aStream->length()); -#endif for (int i = 0; i < aStream->length(); i++) aTexture->SetValue( i+1, (Standard_Byte)aStream[i] ); @@ -2340,8 +2237,8 @@ void GeometryGUI::createPreferences() int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup, LightApp_Preferences::Selector, "Geometry", "toplevel_dm" ); - int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup, - LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" ); + int transparency = addPreference( tr( "PREF_TRANSPARENCY" ), genGroup, + LightApp_Preferences::IntSpin, "Geometry", "transparency" ); int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup, LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" ); @@ -2377,6 +2274,9 @@ void GeometryGUI::createPreferences() setPreferenceProperty( wd[i], "max", 5 ); } + int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup, + LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" ); + addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup, LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" ); @@ -2525,6 +2425,10 @@ void GeometryGUI::createPreferences() setPreferenceProperty( step, "max", 10000 ); setPreferenceProperty( step, "precision", 3 ); + // Set property for trandparency value for spinboxes + setPreferenceProperty( transparency, "min", 0 ); + setPreferenceProperty( transparency, "max", 100 ); + // Set property for deflection value for spinboxes setPreferenceProperty( defl, "min", GEOM::minDeflection() ); setPreferenceProperty( defl, "max", 1.0 ); @@ -2617,6 +2521,54 @@ void GeometryGUI::createPreferences() addPreference( tr( "GEOM_PREVIEW" ), operationsGroup, LightApp_Preferences::Bool, "Geometry", "geom_preview" ); + + int DependencyViewId = addPreference( tr( "PREF_TAB_DEPENDENCY_VIEW" ) ); + + int treeGeneralGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), DependencyViewId ); + + int hierarchy_type = addPreference( tr( "PREF_HIERARCHY_TYPE" ), treeGeneralGroup, + LightApp_Preferences::Selector, "Geometry", "dependency_tree_hierarchy_type" ); + + QStringList aHierarchyTypeList; + aHierarchyTypeList.append( tr("MEN_BOTH_ASCENDANTS_DESCENDANTS") ); + aHierarchyTypeList.append( tr("MEN_ONLY_ASCENDANTS") ); + aHierarchyTypeList.append( tr("MEN_ONLY_DESCENDANTS") ); + + QList aHierarchyTypeIndexesList; + aHierarchyTypeIndexesList.append(0); + aHierarchyTypeIndexesList.append(1); + aHierarchyTypeIndexesList.append(2); + + setPreferenceProperty( hierarchy_type, "strings", aHierarchyTypeList ); + setPreferenceProperty( hierarchy_type, "indexes", aHierarchyTypeIndexesList ); + + addPreference( tr( "GEOM_MOVE_POSSIBILITY" ), treeGeneralGroup, + LightApp_Preferences::Bool, "Geometry", "dependency_tree_move_nodes" ); + + int treeColorGroup = addPreference( tr( "PREF_GROUP_DEPENDENCY_VIEW_COLOR" ), DependencyViewId ); + + addPreference( tr( "PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR"), treeColorGroup, + LightApp_Preferences::Color, "Geometry", "dependency_tree_background_color" ); + + addPreference( tr( "PREF_DEPENDENCY_VIEW_NODE_COLOR"), treeColorGroup, + LightApp_Preferences::Color, "Geometry", "dependency_tree_node_color" ); + addPreference( tr( "PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR"), treeColorGroup, + LightApp_Preferences::Color, "Geometry", "dependency_tree_main_node_color" ); + addPreference( tr( "PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR"), treeColorGroup, + LightApp_Preferences::Color, "Geometry", "dependency_tree_unpublish_node_color" ); + addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR"), treeColorGroup, + LightApp_Preferences::Color, "Geometry", "dependency_tree_select_node_color" ); + + addPreference( tr( "PREF_DEPENDENCY_VIEW_ARROW_COLOR"), treeColorGroup, + LightApp_Preferences::Color, "Geometry", "dependency_tree_arrow_color" ); + addPreference( tr( "PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR"), treeColorGroup, + LightApp_Preferences::Color, "Geometry", "dependency_tree_highlight_arrow_color" ); + addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR"), treeColorGroup, + LightApp_Preferences::Color, "Geometry", "dependency_tree_select_arrow_color" ); + + + + } void GeometryGUI::preferencesChanged( const QString& section, const QString& param ) @@ -2687,6 +2639,8 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par aDisplayer.UpdateViewer(); } + else if ( param.startsWith( "dependency_tree") ) + emit SignalDependencyTreeParamChanged( section, param ); } } @@ -2748,10 +2702,10 @@ void GeometryGUI::storeVisualParameters (int savePoint) // saving VTK actors properties QVector views = vman->getViews(); for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) { - const ObjMap anObjects = appStudy->getObjectMap(aMgrId); + const ObjMap& anObjects = appStudy->getObjectProperties(aMgrId); ObjMap::ConstIterator o_it = anObjects.begin(); for (; o_it != anObjects.end(); o_it++) { - const PropMap aProps = o_it.value(); + const PropMap& aProps = o_it.value(); //Check that object exists in the study _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) ); @@ -2830,6 +2784,11 @@ void GeometryGUI::storeVisualParameters (int savePoint) ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString()); } + if (aProps.contains(GEOM::propertyName( GEOM::Vertices ))) { + param = occParam + GEOM::propertyName( GEOM::Vertices ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Vertices )).toString().toStdString()); + } + if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) { param = occParam + GEOM::propertyName( GEOM::Deflection ); ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString()); @@ -3000,6 +2959,8 @@ void GeometryGUI::restoreVisualParameters (int savePoint) aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val ); } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) { aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1"); + } else if (paramNameStr == GEOM::propertyName( GEOM::Vertices )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Vertices ), val == "true" || val == "1"); } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) { aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble()); } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) { @@ -3016,8 +2977,7 @@ void GeometryGUI::restoreVisualParameters (int savePoint) QList lst = getApp()->viewManagers(); for (int index = 0; index < aListOfMap.count(); index++) { - - appStudy->setObjectPropMap(index, entry, aListOfMap[index]); + appStudy->setObjectProperties(index, entry, aListOfMap[index]); //Get Visibility property of the current PropMap if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) { @@ -3053,13 +3013,19 @@ void GeometryGUI::onViewAboutToShow() { SUIT_ViewWindow* window = application()->desktop()->activeWindow(); QAction* a = action( GEOMOp::OpSwitchVectors ); + QAction* aVerticesAction = action( GEOMOp::OpSwitchVertices ); if ( window ) { a->setEnabled(true); bool vmode = window->property("VectorsMode").toBool(); a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") ); + aVerticesAction->setEnabled(true); + vmode = window->property("VerticesMode").toBool(); + aVerticesAction->setText ( vmode == 1 ? tr( "MEN_VERTICES_MODE_OFF" ) : tr("MEN_VERTICES_MODE_ON") ); } else { a->setText ( tr("MEN_VECTOR_MODE_ON") ); a->setEnabled(false); + aVerticesAction->setText ( tr("MEN_VERTICES_MODE_ON") ); + aVerticesAction->setEnabled(false); } } @@ -3240,6 +3206,7 @@ bool GeometryGUI::renameObject( const QString& entry, const QString& name) GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj)); if (!CORBA::is_nil(anObj)) { anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object + emit SignalDependencyTreeRenameObject( anObj->GetEntry() ); } result = true; } diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index 4f28fc928..5dde1ed7f 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -47,11 +47,7 @@ // OCCT Includes #include -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #include -#else -#include -#endif // IDL headers #include "SALOMEconfig.h" @@ -88,11 +84,7 @@ public: virtual void initialize( CAM_Application* ); virtual QString engineIOR() const; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&); -#else - static Handle(Graphic3d_HArray1OfBytes) getTexture (SalomeApp_Study*, int, int&, int&); -#endif static bool InitGeomGen(); @@ -182,6 +174,8 @@ signals : void SignalDeactivateActiveDialog(); void SignalCloseAllDialogs(); void SignalDefaultStepValueChanged( double newVal ); + void SignalDependencyTreeParamChanged( const QString&, const QString& ); + void SignalDependencyTreeRenameObject( const QString& ); protected: virtual LightApp_Selection* createSelection() const; @@ -206,11 +200,7 @@ public: private: -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 typedef QMap TextureMap; -#else - typedef QMap TextureMap; -#endif typedef QMap StudyTextureMap; typedef QMap GUIMap; diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index 1f2dc8186..f66c19df1 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 @@ -61,6 +59,8 @@ namespace GEOMOp { OpIsosWidth = 1261, // POPUP MENU - LINE WIDTH - ISOS WIDTH OpCreateFolder = 1262, // POPUP MENU - CREATE FOLDER OpSortChildren = 1263, // POPUP MENU - SORT CHILD ITEMS + OpShowDependencyTree = 1264, // POPUP MENU - SHOW DEPENDENCY TREE + OpReduceStudy = 1265, // POPUP MENU - REDUCE STUDY // DisplayGUI ------------------//-------------------------------- OpSwitchVectors = 2001, // MENU VIEW - DISPLAY MODE - SHOW/HIDE EDGE DIRECTION OpShowAll = 2002, // MENU VIEW - SHOW ALL @@ -69,6 +69,7 @@ namespace GEOMOp { OpDMShading = 2011, // MENU VIEW - DISPLAY MODE - SHADING OpDMShadingWithEdges = 2012, // MENU VIEW - DISPLAY MODE - SHADING WITH EDGES OpDMTexture = 2013, // MENU VIEW - DISPLAY MODE - TEXTURE + OpSwitchVertices = 2014, // MENU VIEW - DISPLAY MODE - SHOW/HIDE VERTICES OpShow = 2100, // POPUP MENU - SHOW OpShowOnly = 2101, // POPUP MENU - SHOW ONLY OpHide = 2102, // POPUP MENU - HIDE @@ -80,6 +81,7 @@ namespace GEOMOp { OpTexture = 2204, // POPUP MENU - DISPLAY MODE - TEXTURE OpBringToFront = 2205, // POPUP MENU - BRING TO FRONT OpClsBringToFront = 2206, + OpVertices = 2208, // POPUP MENU - DISPLAY MODE - SHOW VERTICES // BasicGUI --------------------//-------------------------------- OpPoint = 3000, // MENU NEW ENTITY - BASIC - POINT OpLine = 3001, // MENU NEW ENTITY - BASIC - LINE @@ -117,6 +119,7 @@ namespace GEOMOp { OpCreateField = 3305, // MENU FIELD - CREATE FIELD OpEditField = 3306, // MENU FIELD - EDIT FIELD OpEditFieldPopup = 3307, // POPUP MENU - EDIT FIELD + Op2dPolylineEditor = 3308, // MENU NEW ENTITY - BASIC - POLYLINE EDITOR // BuildGUI --------------------//-------------------------------- OpEdge = 3400, // MENU NEW ENTITY - BUILD - EDGE OpWire = 3401, // MENU NEW ENTITY - BUILD - WIRE @@ -152,10 +155,6 @@ namespace GEOMOp { OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT -#ifdef DEBUG_CURVE_CREATOR - OpCurveCreator = 3799, // MENU OPERATION - CURVE CREATOR -#endif - // for debug purposes, to be removed // RepairGUI -------------------//-------------------------------- OpSewing = 4000, // MENU REPAIR - SEWING OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES @@ -205,9 +204,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..a09066811 100755 --- a/src/GEOMImpl/CMakeLists.txt +++ b/src/GEOMImpl/CMakeLists.txt @@ -65,13 +65,16 @@ 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 GEOMImpl_IPolyline.hxx + GEOMImpl_IPolyline2D.hxx GEOMImpl_ICircle.hxx GEOMImpl_ISpline.hxx GEOMImpl_IEllipse.hxx @@ -148,6 +151,7 @@ SET(GEOMImpl_HEADERS GEOMImpl_Block6Explorer.hxx GEOMImpl_MeasureDriver.hxx GEOMImpl_PolylineDriver.hxx + GEOMImpl_PolylineDumper.hxx GEOMImpl_CircleDriver.hxx GEOMImpl_EllipseDriver.hxx GEOMImpl_ArcDriver.hxx @@ -171,8 +175,6 @@ SET(GEOMImpl_HEADERS GEOMImpl_GlueDriver.hxx GEOMImpl_Types.hxx GEOM_GEOMImpl.hxx - GEOMImpl_IImportExportXAO.hxx - GEOMImpl_XAODriver.hxx ) # --- sources --- @@ -187,9 +189,12 @@ 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_IPolyline2D.cxx GEOMImpl_Gen.cxx GEOMImpl_PointDriver.cxx GEOMImpl_VectorDriver.cxx @@ -219,6 +224,7 @@ SET(GEOMImpl_SOURCES GEOMImpl_Block6Explorer.cxx GEOMImpl_MeasureDriver.cxx GEOMImpl_PolylineDriver.cxx + GEOMImpl_PolylineDumper.cxx GEOMImpl_CircleDriver.cxx GEOMImpl_EllipseDriver.cxx GEOMImpl_ArcDriver.cxx @@ -241,7 +247,6 @@ SET(GEOMImpl_SOURCES GEOMImpl_FillingDriver.cxx GEOMImpl_GlueDriver.cxx GEOMImpl_FieldDriver.cxx - GEOMImpl_XAODriver.cxx ) # --- rules --- diff --git a/src/GEOMImpl/GEOMImpl_ArchimedeDriver.cxx b/src/GEOMImpl/GEOMImpl_ArchimedeDriver.cxx index efe0bee51..a5c99d930 100644 --- a/src/GEOMImpl/GEOMImpl_ArchimedeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ArchimedeDriver.cxx @@ -130,11 +130,7 @@ Standard_Integer GEOMImpl_ArchimedeDriver::Execute(TFunction_Logbook& log) const Standard_Real u1,u2,v1,v2; SurfaceTrimmee->Bounds(u1,u2,v1,v2); -#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version TopoDS_Face tirant = BRepBuilderAPI_MakeFace(SurfaceTrimmee, u1, u2, v1, v2, Precision::Confusion()); -#else - TopoDS_Face tirant = BRepBuilderAPI_MakeFace(SurfaceTrimmee, u1, u2, v1, v2); -#endif if (tirant.IsNull()) { StdFail_NotDone::Raise("Failed to build secant face"); diff --git a/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx b/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx index d6b7cbfc9..ac7176133 100644 --- a/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx +++ b/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx @@ -1365,7 +1365,6 @@ TCollection_AsciiString GEOMImpl_Block6Explorer::MakeAnyFace (const TopoDS_Wire& // VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN // the following block, when enabled, leads to extra vertices generation by partition algorithm // in some cases, for example when fillet is made on a PipeTShape -//#if OCC_VERSION_LARGE > 0x06050200 #if 0 // VSR: debug issues 0021568 and 0021550 (15/05/2012) - END BRep_Builder BB; diff --git a/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx b/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx index 9f2d816ab..3c91625b3 100644 --- a/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx @@ -76,11 +76,11 @@ Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const gp_Pnt aP; gp_Vec aV; - if (aType == CYLINDER_R_H) { + if (aType == CYLINDER_R_H || aType == CYLINDER_R_H_A) { aP = gp::Origin(); aV = gp::DZ(); } - else if (aType == CYLINDER_PNT_VEC_R_H) { + else if (aType == CYLINDER_PNT_VEC_R_H || aType == CYLINDER_PNT_VEC_R_H_A) { Handle(GEOM_Function) aRefPoint = aCI.GetPoint(); Handle(GEOM_Function) aRefVector = aCI.GetVector(); TopoDS_Shape aShapePnt = aRefPoint->GetValue(); @@ -110,19 +110,39 @@ Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const if (aCI.GetH() < 0.0) aV.Reverse(); gp_Ax2 anAxes (aP, aV); - BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH())); - MC.Build(); - if (!MC.IsDone()) { - StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters"); + TopoDS_Shape aShape; + + switch (aType) { + case CYLINDER_R_H: + case CYLINDER_PNT_VEC_R_H: + { + BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH())); + MC.Build(); + if (!MC.IsDone()) { + StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters"); + } + aShape = MC.Shape(); + break; + } + case CYLINDER_R_H_A: + case CYLINDER_PNT_VEC_R_H_A: + { + BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH()), aCI.GetA()); + MC.Build(); + if (!MC.IsDone()) { + StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters. Failure."); + } + aShape = MC.Shape(); + break; + } + default: + break; } - - TopoDS_Shape aShape = MC.Shape(); + if (aShape.IsNull()) return 0; - aFunction->SetValue(aShape); log.SetTouched(Label()); - return 1; } 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( !GEOMImpl_IECallBack::GetCallBack( aFormatName )->Export( GetDocID(), obj, aFileName, aFormatName ) ); + return 0; - if ( !fp ) { - TCollection_AsciiString aMsg = aFormatName; - aMsg += " plugin was not installed"; - Standard_Failure::Raise(aMsg.ToCString()); - } + log.SetTouched(Label()); - // 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 ( res ) - 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_FillingDriver.cxx b/src/GEOMImpl/GEOMImpl_FillingDriver.cxx index f0daab0a8..57d0317cb 100644 --- a/src/GEOMImpl/GEOMImpl_FillingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FillingDriver.cxx @@ -219,11 +219,7 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const App.SurfUMults(), App.SurfVMults(), App.UDegree(), App.VDegree()); if (GBS.IsNull()) return 0; -#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version aShape = BRepBuilderAPI_MakeFace(GBS, Precision::Confusion()); -#else - aShape = BRepBuilderAPI_MakeFace(GBS); -#endif } else { // implemented by skl 20.03.2008 for bug 16568 @@ -287,11 +283,7 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const } GeomAPI_PointsToBSplineSurface PTB (Points, mindeg, maxdeg, GeomAbs_C2, tol3d); Handle(Geom_BSplineSurface) BS = PTB.Surface(); -#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version BRepBuilderAPI_MakeFace BB (BS, Precision::Confusion()); -#else - BRepBuilderAPI_MakeFace BB (BS); -#endif TopoDS_Face NewF = BB.Face(); Handle(ShapeFix_Face) sff = new ShapeFix_Face (NewF); sff->Perform(); 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_GlueDriver.cxx b/src/GEOMImpl/GEOMImpl_GlueDriver.cxx index 8e2fd5220..1f03275c5 100644 --- a/src/GEOMImpl/GEOMImpl_GlueDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_GlueDriver.cxx @@ -436,12 +436,10 @@ TopoDS_Shape GEOMImpl_GlueDriver::GlueWithWarnings (const TopoDS_Shape& theShape aGA.Detect(); //modified by NIZNHY-PKV Tue Mar 13 14:07:12 2012f -#if OCC_VERSION_LARGE > 0x06050200 Standard_Integer iWrnDetect = aGA.WarningStatus(); if (iWrnDetect == 2) { Standard_Failure::Raise("GLUE_ERROR_STICKED_SHAPES"); } -#endif //modified by NIZNHY-PKV Tue Mar 13 14:07:14 2012t Standard_Integer iErr = aGA.ErrorStatus(); @@ -596,7 +594,6 @@ TopoDS_Shape GEOMImpl_GlueDriver::GlueByList (const TopoDS_Shape& theShape, aGA.Detect(); //modified by NIZNHY-PKV Tue Mar 13 14:07:12 2012f -#if OCC_VERSION_LARGE > 0x06050200 Standard_Integer iWrnDetect = aGA.WarningStatus(); if (iWrnDetect == 2) { /* @@ -622,7 +619,6 @@ TopoDS_Shape GEOMImpl_GlueDriver::GlueByList (const TopoDS_Shape& theShape, */ Standard_Failure::Raise("GLUE_ERROR_STICKED_SHAPES"); } -#endif //modified by NIZNHY-PKV Tue Mar 13 14:07:14 2012t Standard_Integer iErr = aGA.ErrorStatus(); diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index 1e345fa04..27c366d8e 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -128,9 +128,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, dou //Compute the box value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Box driver failed"); return NULL; @@ -185,9 +183,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Objec //Compute the Box value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Box driver failed"); return NULL; @@ -236,9 +232,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double //Compute the Face try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Face driver failed"); return NULL; @@ -293,9 +287,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Objec //Compute the Face try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Face driver failed"); return NULL; @@ -351,9 +343,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR //Compute the Disk value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Disk driver failed"); return NULL; @@ -411,9 +401,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Ob //Compute the Disk value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Disk driver failed"); return NULL; @@ -461,9 +449,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theO //Compute the Disk try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Disk driver failed"); return NULL; @@ -509,9 +495,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, dou //Compute the Cylinder value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Cylinder driver failed"); return NULL; @@ -531,6 +515,52 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, dou return aCylinder; } +//============================================================================= +/*! + * MakeCylinderRHA + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRHA (double theR, double theH, double theA) +{ + SetErrorCode(KO); + + //Add a new Cylinder object + Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER); + + //Add a new Cylinder function with R and H parameters + Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H_A); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL; + + GEOMImpl_ICylinder aCI (aFunction); + + aCI.SetR(theR); + aCI.SetH(theH); + aCI.SetA(theA); + + //Compute the Cylinder value + try { + OCC_CATCH_SIGNALS; + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Cylinder 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(aFunction) << aCylinder + << " = geompy.MakeCylinderRHA(" << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)"; + + SetErrorCode(OK); + return aCylinder; +} //============================================================================= /*! @@ -570,9 +600,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO //Compute the Cylinder value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Cylinder driver failed"); return NULL; @@ -592,6 +620,65 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO return aCylinder; } +//============================================================================= +/*! + * MakeCylinderPntVecRHA + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR, double theH, double theA) +{ + SetErrorCode(KO); + + if (thePnt.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Cylinder object + Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER); + + //Add a new Cylinder function for creation a cylinder relatively to point and vector + Handle(GEOM_Function) aFunction = + aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H_A); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL; + + GEOMImpl_ICylinder aCI (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + + aCI.SetPoint(aRefPnt); + aCI.SetVector(aRefVec); + aCI.SetR(theR); + aCI.SetH(theH); + aCI.SetA(theA); + + //Compute the Cylinder value + try { + OCC_CATCH_SIGNALS; + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Cylinder 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(aFunction) << aCylinder << " = geompy.MakeCylinderA(" + << thePnt << ", " << theVec << ", " << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)"; + + SetErrorCode(OK); + return aCylinder; +} + //============================================================================= /*! @@ -622,9 +709,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, dou //Compute the Cone value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Cone driver failed"); return NULL; @@ -685,9 +770,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM //Compute the Cone value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Cone driver failed"); return NULL; @@ -733,9 +816,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR) //Compute the Sphere value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Sphere driver failed"); return NULL; @@ -788,9 +869,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Obje //Compute the Sphere value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Sphere driver failed"); return NULL; @@ -839,9 +918,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR //Compute the Torus value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Torus driver failed"); return NULL; @@ -899,9 +976,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR //Compute the Torus value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Torus driver failed"); return NULL; @@ -960,9 +1035,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Objec //Compute the Prism value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { //SetErrorCode("Prism driver failed"); SetErrorCode("Extrusion can not be created, check input data"); @@ -1024,9 +1097,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_ //Compute the Prism value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { //SetErrorCode("Prism driver failed"); SetErrorCode("Extrusion can not be created, check input data"); @@ -1087,9 +1158,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt //Compute the Prism value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { //SetErrorCode("Prism driver failed"); SetErrorCode("Extrusion can not be created, check input data"); @@ -1152,9 +1221,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways //Compute the Prism value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { //SetErrorCode("Prism driver failed"); SetErrorCode("Extrusion can not be created, check input data"); @@ -1213,9 +1280,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ //Compute the Prism value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Extrusion can not be created, check input data"); return NULL; @@ -1276,9 +1341,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways //Compute the Prism value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Extrusion can not be created, check input data"); return NULL; @@ -1350,9 +1413,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism //Compute the Draft Prism Feature value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Extrusion can not be created, check input data"); return NULL; @@ -1415,9 +1476,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) th //Compute the Pipe value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Pipe driver failed"); return NULL; @@ -1475,9 +1534,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle( //Compute the Revolution value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Revolution driver failed"); return NULL; @@ -1533,9 +1590,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways //Compute the Revolution value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Revolution driver failed"); return NULL; @@ -1596,9 +1651,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling //Compute the Solid value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Filling driver failed"); return NULL; @@ -1695,9 +1748,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections( //Compute the ThruSections value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("ThruSections driver failed"); return anObj; @@ -1819,9 +1870,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections( //Compute the Pipe value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Pipe with defferent section driver failed"); return anObj; @@ -1978,9 +2027,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections( //Compute the Pipe value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Pipe with shell sections driver failed"); return anObj; @@ -2125,9 +2172,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath( //Compute the Pipe value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Pipe with shell sections without path driver failed"); return anObj; @@ -2218,9 +2263,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Han //Compute the Pipe value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Pipe driver failed"); return NULL; @@ -2279,9 +2322,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening(Handle(GEOM_Objec //Compute the offset try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Offset driver failed"); return NULL; @@ -2348,9 +2389,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) // Compute the Path value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("PipePath driver failed"); return NULL; @@ -2440,9 +2479,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath // Compute the Path value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("PipePath driver failed"); return NULL; diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index 36d0ac6b2..de227452e 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -50,13 +50,17 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeDiskR (double theR, int theOrientation); Standard_EXPORT Handle(GEOM_Object) MakeCylinderRH (double theR, double theH); Standard_EXPORT Handle(GEOM_Object) MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, double theH); + Handle(GEOM_Object) theVec, + double theR, double theH); + Standard_EXPORT Handle(GEOM_Object) MakeCylinderRHA (double theR, double theH, double theA); + Standard_EXPORT Handle(GEOM_Object) MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR, double theH, double theA); Standard_EXPORT Handle(GEOM_Object) MakeConeR1R2H (double theR1, double theR2, double theH); Standard_EXPORT Handle(GEOM_Object) MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR1, double theR2, double theH); + Handle(GEOM_Object) theVec, + double theR1, double theR2, double theH); Standard_EXPORT Handle(GEOM_Object) MakeSphereR (double theR); Standard_EXPORT Handle(GEOM_Object) MakeSpherePntR (Handle(GEOM_Object) thePnt, double theR); @@ -64,8 +68,8 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeTorusRR (double theRMajor, double theRMinor); Standard_EXPORT Handle(GEOM_Object) MakeTorusPntVecRR (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theRMajor, double theRMinor); + Handle(GEOM_Object) theVec, + double theRMajor, double theRMinor); Standard_EXPORT Handle(GEOM_Object) MakePrismVecH (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theVec, 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..e547cb3ed --- /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: + Standard_EXPORT 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_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx index 43058dd35..cb81f958f 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -106,9 +106,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ //Compute the point value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Point driver failed"); return NULL; @@ -161,9 +159,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference //Compute the point value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Point driver failed"); return NULL; @@ -264,9 +260,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom //Compute the point value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Point driver failed"); return NULL; @@ -422,9 +416,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection //Compute the point value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Point driver failed"); return NULL; @@ -475,9 +467,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve //Compute the vector value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Vector driver failed"); return NULL; @@ -526,9 +516,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ //Compute the Vector value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Vector driver failed"); return NULL; @@ -581,9 +569,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt //Compute the Vector value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Vector driver failed"); return NULL; @@ -637,9 +623,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine //Compute the Line value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Line driver failed"); return NULL; @@ -692,9 +676,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt //Compute the Line value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Line driver failed"); return NULL; @@ -747,9 +729,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces //Compute the Line value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Line driver failed"); return NULL; @@ -806,9 +786,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt //Compute the Plane value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Plane driver failed"); return NULL; @@ -863,9 +841,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec //Compute the Plane value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Plane driver failed"); return NULL; @@ -917,9 +893,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace //Compute the Plane value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Plane driver failed"); return NULL; @@ -974,9 +948,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec //Compute the Plane value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Plane driver failed"); return NULL; @@ -1028,9 +1000,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS //Compute the Plane value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Plane driver failed"); return NULL; @@ -1082,9 +1052,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker //Compute the marker value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Marker driver failed"); return NULL; @@ -1136,9 +1104,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape //Compute the marker value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Marker driver failed"); return NULL; @@ -1193,9 +1159,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec //Compute the marker value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Marker driver failed"); return NULL; @@ -1252,9 +1216,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Hand //Compute the Plane value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Plane driver failed"); return NULL; diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx index e51931b8e..cca9f381f 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx @@ -168,9 +168,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad //Compute the Face value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a face"); return NULL; @@ -226,9 +224,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad2Edges //Compute the Face value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a face"); return NULL; @@ -291,9 +287,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad4Vertices //Compute the Face value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a face"); return NULL; @@ -363,9 +357,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeHexa //Compute the Block value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a block"); return NULL; @@ -422,9 +414,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeHexa2Faces //Compute the Block value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a block"); return NULL; @@ -478,9 +468,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeBlockCompound //Compute the Blocks Compound value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a blocks compound"); return NULL; @@ -683,9 +671,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetEdge //Compute the Edge value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopTools_IndexedDataMapOfShapeListOfShape MVE; GEOMImpl_Block6Explorer::MapShapesAndAncestors (aBlockOrComp, TopAbs_VERTEX, TopAbs_EDGE, MVE); @@ -789,9 +775,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetEdgeNearPoint //Compute the Edge value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Vertex aVert = TopoDS::Vertex(anArg); TopoDS_Shape aShape = GEOMUtils::GetEdgeNearPoint(aBlockOrComp, aVert); @@ -864,9 +848,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByPoints //Compute the Face value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Shape aShape; TopTools_IndexedDataMapOfShapeListOfShape MVF; @@ -999,9 +981,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByEdges //Compute the Face value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Shape aShape; TopTools_IndexedDataMapOfShapeListOfShape MEF; @@ -1124,9 +1104,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetOppositeFace //Compute the Face value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Shape aShape; GEOMImpl_Block6Explorer aBlockTool; @@ -1190,9 +1168,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint //Compute the Face value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Shape aShape; TopoDS_Vertex aVert = TopoDS::Vertex(anArg); @@ -1382,9 +1358,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByNormale //Compute the Face value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Shape aShape; TopoDS_Edge anEdge = TopoDS::Edge(anArg); @@ -1524,9 +1498,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetShapesNearPoint // Compute the result try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Vertex aVert = TopoDS::Vertex(anArg); TopTools_MapOfShape mapShape; @@ -1629,9 +1601,7 @@ Standard_Boolean GEOMImpl_IBlocksOperations::IsCompoundOfBlocks //Check isCompOfBlocks = Standard_True; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopTools_MapOfShape mapShape; TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); for (; exp.More(); exp.Next()) { @@ -2628,9 +2598,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges //Compute the fixed shape try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to remove extra edges of the given shape"); return NULL; @@ -2681,9 +2649,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::UnionFaces //Compute the fixed shape try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to remove extra edges of the given shape"); return NULL; @@ -2737,9 +2703,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::CheckAndImprove //Compute the fixed shape try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to improve the given blocks compound"); return NULL; @@ -2789,9 +2753,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::ExplodeCompound // Explode try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); for (; exp.More(); exp.Next()) { if (mapShape.Add(exp.Current())) { @@ -2884,9 +2846,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockNearPoint //Compute the Block value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Shape aShape; TopoDS_Vertex aVert = TopoDS::Vertex(anArg); @@ -3063,9 +3023,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockByParts //Compute the Block value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif // 1. Explode compound on solids TopTools_MapOfShape mapShape; Standard_Integer nbSolids = 0; @@ -3182,9 +3140,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByPart //Get the Blocks try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopTools_MapOfShape mapShape; Standard_Integer nbSolids = 0; TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); @@ -3305,9 +3261,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation1D //Compute the transformation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to make multi-transformation"); return NULL; @@ -3369,9 +3323,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation2D //Compute the transformation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to make multi-transformation"); return NULL; diff --git a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx index 644422c4c..eddc96add 100644 --- a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx @@ -114,9 +114,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean //Compute the Boolean value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Boolean driver failed"); return NULL; @@ -189,9 +187,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuse //Compute the Boolean value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Boolean driver failed"); return NULL; @@ -254,9 +250,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuseList //Compute the Boolean value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Boolean driver failed"); return NULL; @@ -316,9 +310,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCommonList //Compute the Boolean value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Boolean driver failed"); return NULL; @@ -389,9 +381,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCutList //Compute the Boolean value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Boolean driver failed"); return NULL; @@ -516,9 +506,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition //Compute the Partition try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Partition driver failed"); return NULL; @@ -599,9 +587,7 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition //Compute the Partition value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Partition driver failed"); return NULL; diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index 8046dbb63..f6c452b95 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -51,6 +51,7 @@ #include "GEOMImpl_3DSketcherDriver.hxx" #include "GEOMImpl_IPolyline.hxx" +#include "GEOMImpl_IPolyline2D.hxx" #include "GEOMImpl_ICircle.hxx" #include "GEOMImpl_ISpline.hxx" #include "GEOMImpl_IEllipse.hxx" @@ -59,12 +60,14 @@ #include "GEOMImpl_I3DSketcher.hxx" #include "GEOMImpl_ICurveParametric.hxx" #include "GEOMImpl_IIsoline.hxx" +#include "GEOMImpl_PolylineDumper.hxx" #include #include "utilities.h" #include +#include #include #include @@ -235,9 +238,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_ //Compute the Circle value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Circle driver failed"); return NULL; @@ -295,9 +296,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEO //Compute the Circle value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Circle driver failed"); return NULL; @@ -360,9 +359,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR //Compute the Circle value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Circle driver failed"); return NULL; @@ -435,9 +432,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse //Compute the Ellipse value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Ellipse driver failed"); return NULL; @@ -502,9 +497,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) the //Compute the Arc value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Arc driver failed"); return NULL; @@ -563,12 +556,10 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Objec //Compute the Arc value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("Arc driver failed"); - return NULL; + SetErrorCode("Arc driver failed"); + return NULL; } } catch (Standard_Failure) { @@ -622,9 +613,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Ob //Compute the Arc value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Arc driver failed"); return NULL; @@ -686,9 +675,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Polyline driver failed"); return NULL; @@ -757,9 +744,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier //Compute the Spline value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Spline driver failed"); return NULL; @@ -829,9 +814,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation //Compute the Spline value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Spline driver failed"); return NULL; @@ -908,9 +891,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolWithTangents //Compute the Spline value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Spline driver failed"); return NULL; @@ -1159,9 +1140,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric //Compute the Curve value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Curve driver failed !!!"); return NULL; @@ -1228,9 +1207,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom //Compute the Sketcher value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Sketcher driver failed"); return NULL; @@ -1292,9 +1269,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane //Compute the Sketcher value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Sketcher driver failed"); return NULL; @@ -1343,9 +1318,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcherCommand (const cha //Compute the 3D Sketcher value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("3D Sketcher driver failed"); return NULL; @@ -1403,9 +1376,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("3D Sketcher driver failed"); return NULL; @@ -1478,9 +1449,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeIsoline //Compute the isoline curve try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed"); return NULL; @@ -1499,3 +1468,155 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeIsoline SetErrorCode(OK); return anIsoline; } + +//============================================================================= +/*! + * MakePolyline2D + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2D + (const std::list > &theCoords, + const Handle(TColStd_HArray1OfExtendedString) &theNames, + const Handle(TColStd_HArray1OfByte) &theTypes, + const Handle(TColStd_HArray1OfByte) &theCloseds, + const Handle(TColStd_HArray1OfReal) &theWorkingPlane) +{ + SetErrorCode(KO); + + if (theCoords.empty() || theNames.IsNull() || theTypes.IsNull() || + theCloseds.IsNull() || theWorkingPlane.IsNull()) { + return NULL; + } + + // Add a new Polyline object + Handle(GEOM_Object) aResult = + GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE2D); + Handle(GEOM_Function) aFunction = aResult->AddFunction + (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_COORDS); + + if (aFunction.IsNull()) { + return NULL; + } + + // Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) { + return NULL; + } + + GEOMImpl_IPolyline2D aCI(aFunction); + + aCI.SetCoords(theCoords); + aCI.SetNames(theNames); + aCI.SetTypes(theTypes); + aCI.SetClosedFlags(theCloseds); + aCI.SetWorkingPlaneDbls(theWorkingPlane); + + // Compute the isoline curve + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Polyline driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes, + theCloseds, theWorkingPlane); + + aDumper.Dump(aResult); + + if (aDumper.IsDone() == Standard_False) { + SetErrorCode("Python dump failed"); + return NULL; + } + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * MakePolyline2DOnPlane + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2DOnPlane + (const std::list > &theCoords, + const Handle(TColStd_HArray1OfExtendedString) &theNames, + const Handle(TColStd_HArray1OfByte) &theTypes, + const Handle(TColStd_HArray1OfByte) &theCloseds, + const Handle(GEOM_Object) &theWorkingPlane) +{ + SetErrorCode(KO); + + if (theCoords.empty() || theNames.IsNull() || theTypes.IsNull() || + theCloseds.IsNull() || theWorkingPlane.IsNull()) { + return NULL; + } + + //Add a new Polyline object + Handle(GEOM_Object) aResult = + GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE2D); + Handle(GEOM_Function) aFunction = aResult->AddFunction + (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_OBJECT); + + if (aFunction.IsNull()) { + return NULL; + } + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) { + return NULL; + } + + Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction(); + + if (aRefPlane.IsNull()) { + return NULL; + } + + GEOMImpl_IPolyline2D aCI(aFunction); + + aCI.SetCoords(theCoords); + aCI.SetNames(theNames); + aCI.SetTypes(theTypes); + aCI.SetClosedFlags(theCloseds); + aCI.SetWorkingPlane(aRefPlane); + + //Compute the isoline curve + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Polyline driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes, + theCloseds, theWorkingPlane); + + aDumper.Dump(aResult); + + if (aDumper.IsDone() == Standard_False) { + SetErrorCode("Python dump failed"); + return NULL; + } + + SetErrorCode(OK); + return aResult; +} diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx index 15591a64f..fe4278cc6 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx @@ -100,6 +100,19 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations { const bool IsUIso, const double theParameter); + Standard_EXPORT Handle(GEOM_Object) MakePolyline2D + (const std::list > &theCoords, + const Handle(TColStd_HArray1OfExtendedString) &theNames, + const Handle(TColStd_HArray1OfByte) &theTypes, + const Handle(TColStd_HArray1OfByte) &theCloseds, + const Handle(TColStd_HArray1OfReal) &theWorkingPlane); + + Standard_EXPORT Handle(GEOM_Object) MakePolyline2DOnPlane + (const std::list > &theCoords, + const Handle(TColStd_HArray1OfExtendedString) &theNames, + const Handle(TColStd_HArray1OfByte) &theTypes, + const Handle(TColStd_HArray1OfByte) &theCloseds, + const Handle(GEOM_Object) &theWorkingPlane); }; #endif diff --git a/src/GEOMImpl/GEOMImpl_ICylinder.hxx b/src/GEOMImpl/GEOMImpl_ICylinder.hxx index f13ac7760..c092c950e 100644 --- a/src/GEOMImpl/GEOMImpl_ICylinder.hxx +++ b/src/GEOMImpl/GEOMImpl_ICylinder.hxx @@ -28,6 +28,7 @@ #define CYL_ARG_H 2 #define CYL_ARG_PNT 3 #define CYL_ARG_VEC 4 +#define CYL_ARG_A 5 class GEOMImpl_ICylinder { @@ -50,6 +51,10 @@ class GEOMImpl_ICylinder void SetVector(Handle(GEOM_Function) theRefVector) { _func->SetReference(CYL_ARG_VEC, theRefVector); } Handle(GEOM_Function) GetVector() { return _func->GetReference(CYL_ARG_VEC); } + + void SetA(double theA) { _func->SetReal(CYL_ARG_A, theA); } + + double GetA() { return _func->GetReal(CYL_ARG_A); } private: 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..a6c26b7e0 --- /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 ); + + Standard_EXPORT static void Register( const TCollection_AsciiString& theFormatName, GEOMImpl_IECallBack* theCallBack ); + + static GEOMImpl_IECallBack* GetCallBack( const TCollection_AsciiString& theFormatName ); + +protected: + Standard_EXPORT GEOMImpl_Gen* GetEngine(); + +private: + static std::map myCallBacks; +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index 7f58ddfe7..b45374c45 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -141,9 +141,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Objec //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape Healing algorithm failed"); @@ -350,9 +348,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); @@ -420,9 +416,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); @@ -489,9 +483,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); @@ -557,9 +549,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); @@ -628,9 +618,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj //Compute the result try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); @@ -690,9 +678,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveInternalFaces (Handle(GEO //Compute the result try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); @@ -751,9 +737,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); return NULL; @@ -817,9 +801,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FuseCollinearEdgesWithinWire // Compute the new wire try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); return NULL; @@ -869,12 +851,8 @@ bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject // get free boundary shapes -#if OCC_VERSION_LARGE > 0x06030008 ShapeAnalysis_FreeBounds anAnalizer(aShape, Standard_False, Standard_True, Standard_True); -#else - ShapeAnalysis_FreeBounds anAnalizer(aShape); -#endif TopoDS_Compound aClosed = anAnalizer.GetClosedWires(); TopoDS_Compound anOpen = anAnalizer.GetOpenWires(); @@ -985,9 +963,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_ //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); return NULL; @@ -1054,9 +1030,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(G // Compute the result try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); return NULL; @@ -1113,9 +1087,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::LimitTolerance (Handle(GEOM_Obj // Compute try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Healing driver failed"); return NULL; diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx index 86e7566d5..e5f5a1f94 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" @@ -79,25 +63,12 @@ #include #include -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #include #include -#else -#include -#endif #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 @@ -154,9 +125,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy (Handle(GEOM_Object) th //Compute the Copy value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Copy driver failed"); return NULL; @@ -189,52 +158,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)) { + if ( !GEOMImpl_IECallBack::GetCallBack( theFormatName )->Export( GetDocID(), theOriginal, theFileName, theFormatName ) ) 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()); - return; - } - - //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal << ", \"" - << theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")"; - SetErrorCode(OK); } @@ -251,91 +176,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 @@ -659,11 +250,7 @@ int GEOMImpl_IInsertOperations::LoadTexture(const TCollection_AsciiString& theTe if (theTextureFile.IsEmpty()) return 0; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) aTexture; -#else - Handle(TDataStd_HArray1OfByte) aTexture; -#endif FILE* fp = fopen(theTextureFile.ToCString(), "r"); if (!fp) return 0; @@ -705,11 +292,7 @@ int GEOMImpl_IInsertOperations::LoadTexture(const TCollection_AsciiString& theTe if (bytedata.empty() || bytedata.size() != lines.size()*lenbytes) return 0; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 aTexture = new TColStd_HArray1OfByte (1, lines.size()*lenbytes); -#else - aTexture = new TDataStd_HArray1OfByte (1, lines.size()*lenbytes); -#endif std::list::iterator bdit; int i; @@ -722,11 +305,7 @@ int GEOMImpl_IInsertOperations::LoadTexture(const TCollection_AsciiString& theTe } int GEOMImpl_IInsertOperations::AddTexture(int theWidth, int theHeight, -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 const Handle(TColStd_HArray1OfByte)& theTexture) -#else - const Handle(TDataStd_HArray1OfByte)& theTexture) -#endif { SetErrorCode(KO); int aTextureId = GetEngine()->addTexture(GetDocID(), theWidth, theHeight, theTexture); @@ -734,20 +313,12 @@ int GEOMImpl_IInsertOperations::AddTexture(int theWidth, int theHeight, return aTextureId; } -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) GEOMImpl_IInsertOperations::GetTexture(int theTextureId, -#else -Handle(TDataStd_HArray1OfByte) GEOMImpl_IInsertOperations::GetTexture(int theTextureId, -#endif - int& theWidth, int& theHeight) + int& theWidth, int& theHeight) { SetErrorCode(KO); -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) aTexture; -#else - Handle(TDataStd_HArray1OfByte) aTexture; -#endif theWidth = theHeight = 0; TCollection_AsciiString aFileName; @@ -769,763 +340,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..9341c2b8d 100644 --- a/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx @@ -45,20 +45,7 @@ class GEOMImpl_IShapesOperations; class GEOMImpl_IGroupOperations; class GEOMImpl_IFieldOperations; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 class Handle_TColStd_HArray1OfByte; -#else -class Handle_TDataStd_HArray1OfByte; -#endif - -namespace XAO { - class Geometry; - class BrepGeometry; - class Xao; -} - -typedef NCollection_DataMap > - DataMapOfStringListOfShape; class GEOMImpl_IInsertOperations : public GEOM_IOperations { public: @@ -80,68 +67,18 @@ 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); Standard_EXPORT int AddTexture(int theWidth, int theHeight, -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 const Handle(TColStd_HArray1OfByte)& theTexture); -#else - const Handle(TDataStd_HArray1OfByte)& theTexture); -#endif -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Standard_EXPORT Handle(TColStd_HArray1OfByte) GetTexture(int theTextureId, -#else - Standard_EXPORT Handle(TDataStd_HArray1OfByte) GetTexture(int theTextureId, -#endif - int& theWidth, int& theHeight); + int& theWidth, int& theHeight); 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_ILocalOperations.cxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx index cb2c4698c..b3c270ef8 100644 --- a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx @@ -116,9 +116,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll //Compute the Fillet value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Fillet driver failed"); return NULL; @@ -177,9 +175,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges //Compute the Fillet value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Fillet driver failed"); return NULL; @@ -247,9 +243,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2 //Compute the Fillet value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Fillet driver failed"); return NULL; @@ -317,9 +311,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces //Compute the Fillet value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Fillet driver failed"); return NULL; @@ -387,9 +379,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2 //Compute the Fillet value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Fillet driver failed"); return NULL; @@ -456,9 +446,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D //Compute the Fillet value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("2D Fillet driver failed"); return NULL; @@ -527,9 +515,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D //Compute the Fillet value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("1D Fillet driver failed"); return NULL; @@ -588,9 +574,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Objec //Compute the Chamfer value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Chamfer driver failed"); return NULL; @@ -645,9 +629,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge //Compute the Chamfer value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Chamfer driver failed"); return NULL; @@ -703,9 +685,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD //Compute the Chamfer value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Chamfer driver failed"); return NULL; @@ -766,9 +746,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces //Compute the Chamfer value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Chamfer driver failed"); return NULL; @@ -837,9 +815,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD //Compute the Chamfer value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Chamfer driver failed"); return NULL; @@ -909,9 +885,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges //Compute the Chamfer value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Chamfer driver failed"); return NULL; @@ -981,9 +955,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD //Compute the Chamfer value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Chamfer driver failed"); return NULL; @@ -1045,9 +1017,7 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object //Compute the Archimede value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Archimede driver failed"); return NULL; diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index 31233a94f..0cf9dd339 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; } @@ -742,9 +742,7 @@ void GEOMImpl_IMeasureOperations::GetPosition } try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif gp_Ax3 anAx3 = GEOMUtils::GetPosition(aShape); @@ -798,9 +796,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass //Compute the CentreOfMass value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Measure driver failed to compute centre of mass"); return NULL; @@ -852,9 +848,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex //Compute try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Vertex by index driver failed."); return NULL; @@ -911,9 +905,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetNormal //Compute the Normale value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Measure driver failed to compute normake of face"); return NULL; @@ -963,9 +955,7 @@ void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theSha //Compute the parameters GProp_GProps LProps, SProps; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif BRepGProp::LinearProperties(aShape, LProps); theLength = LProps.Mass(); @@ -1019,9 +1009,7 @@ void GEOMImpl_IMeasureOperations::GetInertia GProp_GProps System; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (aShape.ShapeType() == TopAbs_VERTEX || aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE) { @@ -1087,9 +1075,7 @@ void GEOMImpl_IMeasureOperations::GetBoundingBox Bnd_Box B; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif BRepBuilderAPI_Copy aCopyTool (aShape); if (!aCopyTool.IsDone()) { SetErrorCode("GetBoundingBox Error: Bad shape detected"); @@ -1155,9 +1141,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetBoundingBox //Compute the BoundingBox value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Measure driver failed to compute a bounding box"); return NULL; @@ -1214,9 +1198,7 @@ void GEOMImpl_IMeasureOperations::GetTolerance FaceMax = EdgeMax = VertMax = -RealLast(); try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif for (TopExp_Explorer ExF (aShape, TopAbs_FACE); ExF.More(); ExF.Next()) { TopoDS_Face Face = TopoDS::Face(ExF.Current()); T = BRep_Tool::Tolerance(Face); @@ -1277,9 +1259,7 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape, //Compute the parameters bool isValid = false; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif BRepCheck_Analyzer ana (aShape, theIsCheckGeom); if (ana.IsValid()) { isValid = true; @@ -1673,9 +1653,7 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object) Astr = Astr + " Number of sub-shapes : \n"; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif int iType, nbTypes [TopAbs_SHAPE]; for (iType = 0; iType < TopAbs_SHAPE; ++iType) nbTypes[iType] = 0; @@ -1868,9 +1846,7 @@ GEOMImpl_IMeasureOperations::GetMinDistance (Handle(GEOM_Object) theShape1, //Compute the parameters try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif gp_Pnt aPnt1, aPnt2; @@ -1920,9 +1896,7 @@ Standard_Integer GEOMImpl_IMeasureOperations::ClosestPoints (Handle(GEOM_Object) // Compute the extremities try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif // skl 30.06.2008 // additional workaround for bugs 19899, 19908 and 19910 from Mantis @@ -1996,9 +1970,7 @@ void GEOMImpl_IMeasureOperations::PointCoordinates (Handle(GEOM_Object) theShape } try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); theX = aPnt.X(); theY = aPnt.Y(); @@ -2048,9 +2020,7 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngle (Handle(GEOM_Object) theLine } try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Edge E1 = TopoDS::Edge(aLine1); TopoDS_Edge E2 = TopoDS::Edge(aLine2); @@ -2126,9 +2096,7 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngleBtwVectors (Handle(GEOM_Objec } try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Edge aE1 = TopoDS::Edge(aVec1); TopoDS_Edge aE2 = TopoDS::Edge(aVec2); @@ -2188,9 +2156,7 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByParam //Compute curvature try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif GeomLProp_CLProps Prop = GeomLProp_CLProps (aCurve, aP, 2, Precision::Confusion()); aRes = fabs(Prop.Curvature()); @@ -2242,9 +2208,7 @@ Standard_Real GEOMImpl_IMeasureOperations::CurveCurvatureByPoint //Compute curvature try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif GeomAPI_ProjectPointOnCurve PPCurve(aPoint, aCurve, aFP, aLP); if(PPCurve.NbPoints()>0) { GeomLProp_CLProps Prop = GeomLProp_CLProps @@ -2285,9 +2249,7 @@ Standard_Real GEOMImpl_IMeasureOperations::getSurfaceCurvatures if (aSurf.IsNull()) return aRes; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif GeomLProp_SLProps Prop = GeomLProp_SLProps (aSurf, theUParam, theVParam, 2, Precision::Confusion()); if(Prop.IsCurvatureDefined()) { diff --git a/src/GEOMImpl/GEOMImpl_IPolyline2D.cxx b/src/GEOMImpl/GEOMImpl_IPolyline2D.cxx new file mode 100644 index 000000000..eb1bcfdd7 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPolyline2D.cxx @@ -0,0 +1,112 @@ +// 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 "GEOMImpl_IPolyline2D.hxx" + +#include + + +//============================================================================= +/*! + * SetCoords + */ +//============================================================================= +void GEOMImpl_IPolyline2D::SetCoords + (const std::list > &theValue) +{ + const Standard_Integer aNbSec = theValue.size(); + + if (aNbSec > 0) { + // Compute the total number of points and fill the array of start indices. + Standard_Integer i; + Standard_Integer aNbCoords = 0; + Handle(TColStd_HArray1OfInteger) anIndices = + new TColStd_HArray1OfInteger(1, aNbSec); + Handle(TColStd_HArray1OfReal) aCoords; + std::list >::const_iterator aSecIter = theValue.begin(); + + for (i = 1; aSecIter != theValue.end(); ++aSecIter, ++i) { + anIndices->SetValue(i, aNbCoords + 1); + aNbCoords += aSecIter->size(); + } + + if (aNbCoords > 0) { + // Fill the array of coordinates. + std::list::const_iterator aCIter; + + aCoords = new TColStd_HArray1OfReal(1, aNbCoords); + aSecIter = theValue.begin(); + + for (i = 1; aSecIter != theValue.end(); ++aSecIter) { + for (aCIter = aSecIter->begin(); aCIter != aSecIter->end(); ++aCIter) { + aCoords->SetValue(i++, *aCIter); + } + } + } + + // Store the coordinates. + if (aCoords.IsNull() == Standard_False) { + _func->SetRealArray(POLY_ARG_COORDS, aCoords); + } + + _func->SetIntegerArray(POLY_ARG_START_INDICES, anIndices); + } +} + +//============================================================================= +/*! + * GetCoords + */ +//============================================================================= +void GEOMImpl_IPolyline2D::GetCoords(std::list > &theValue) +{ + theValue.clear(); + + Handle(TColStd_HArray1OfReal) aCoords = + _func->GetRealArray(POLY_ARG_COORDS); + Handle(TColStd_HArray1OfInteger) anIndices = + _func->GetIntegerArray(POLY_ARG_START_INDICES); + + if (anIndices.IsNull() == Standard_False) { + const Standard_Integer aNbSec = anIndices->Length(); + + // Create an empty sections. + theValue.resize(aNbSec); + + if (aCoords.IsNull() == Standard_False) { + Standard_Integer i; + Standard_Integer j; + std::list >::iterator anIt = theValue.begin(); + + for (i = anIndices->Lower(); i <= anIndices->Upper(); ++i, ++anIt) { + const Standard_Integer iCoord1 = anIndices->Value(i); + const Standard_Integer iCoord2 = i + 1 > anIndices->Upper() ? + aCoords->Upper() + 1 : anIndices->Value(i + 1); + + for (j = iCoord1; j < iCoord2; ++j) { + anIt->push_back(aCoords->Value(j)); + } + } + } + } +} diff --git a/src/GEOMImpl/GEOMImpl_IPolyline2D.hxx b/src/GEOMImpl/GEOMImpl_IPolyline2D.hxx new file mode 100644 index 000000000..302e9f899 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPolyline2D.hxx @@ -0,0 +1,94 @@ +// 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 +// + +//NOTE: This is an interface to a function for the Polyline2D creation. + + +#ifndef _GEOMImpl_IPolyline2D_HXX_ +#define _GEOMImpl_IPolyline2D_HXX_ + + +#include +#include + +#include + +#include +#include +#include + + +#define POLY_ARG_NAMES 1 +#define POLY_ARG_TYPES 2 +#define POLY_ARG_CLOSEDS 3 +#define POLY_ARG_COORDS 4 +#define POLY_ARG_START_INDICES 5 +#define POLY_ARG_WPLANE_DBLS 6 +#define POLY_ARG_WPLANE_OBJ 7 + + +class GEOMIMPL_EXPORT GEOMImpl_IPolyline2D +{ + public: + + GEOMImpl_IPolyline2D(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetNames(const Handle_TColStd_HArray1OfExtendedString &theValue) + { _func->SetStringArray(POLY_ARG_NAMES, theValue); } + + Handle_TColStd_HArray1OfExtendedString GetNames() + { return _func->GetStringArray(POLY_ARG_NAMES); } + + void SetTypes(const Handle_TColStd_HArray1OfByte &theValue) + { _func->SetByteArray(POLY_ARG_TYPES, theValue); } + + Handle_TColStd_HArray1OfByte GetTypes() + { return _func->GetByteArray(POLY_ARG_TYPES); } + + void SetClosedFlags(const Handle_TColStd_HArray1OfByte &theValue) + { _func->SetBooleanArray(POLY_ARG_CLOSEDS, theValue); } + + Handle_TColStd_HArray1OfByte GetClosedFlags() + { return _func->GetBooleanArray(POLY_ARG_CLOSEDS); } + + void SetWorkingPlaneDbls(const Handle_TColStd_HArray1OfReal &thePlane) + { _func->SetRealArray(POLY_ARG_WPLANE_DBLS, thePlane); } + + Handle_TColStd_HArray1OfReal GetWorkingPlaneDbls() + { return _func->GetRealArray(POLY_ARG_WPLANE_DBLS); } + + void SetWorkingPlane(const Handle_GEOM_Function &thePlane) + { _func->SetReference(POLY_ARG_WPLANE_OBJ, thePlane); } + + Handle_GEOM_Function GetWorkingPlane() + { return _func->GetReference(POLY_ARG_WPLANE_OBJ); } + + void SetCoords(const std::list > &theValue); + + void GetCoords(std::list > &theValue); + + private: + + Handle(GEOM_Function) _func; +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index efb82f39b..fab086b96 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -197,9 +197,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdge //Compute the Edge value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Vector driver failed"); return NULL; @@ -258,9 +256,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdgeOnCurveByLength //Compute the Edge value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Vector driver failed"); return NULL; @@ -316,9 +312,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdgeWire //Compute the Edge value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed"); return NULL; @@ -392,9 +386,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeWire //Compute the shape try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed"); return NULL; @@ -459,9 +451,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) th //Compute the Face value Standard_Boolean isWarning = Standard_False; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed to compute a face"); return NULL; @@ -530,9 +520,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires //Compute the shape Standard_Boolean isWarning = Standard_False; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed"); return NULL; @@ -643,9 +631,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape //Compute the shape try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed"); return NULL; @@ -712,9 +698,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces //Compute the sub-shape value Standard_Boolean isWarning = Standard_False; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed to glue faces"); return NULL; @@ -869,9 +853,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFacesByList //Compute the sub-shape value Standard_Boolean isWarning = Standard_False; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed to glue faces"); return NULL; @@ -944,9 +926,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdges //Compute the sub-shape value Standard_Boolean isWarning = Standard_False; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed to glue edges"); return NULL; @@ -1107,9 +1087,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueEdgesByList //Compute the sub-shape value Standard_Boolean isWarning = Standard_False; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed to glue edges"); return NULL; @@ -1151,9 +1129,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 +1178,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 +1185,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 +1203,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; @@ -1787,9 +1785,7 @@ Standard_Integer GEOMImpl_IShapesOperations::NumberOfSubShapes */ try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif int iType, nbTypes [TopAbs_SHAPE]; for (iType = 0; iType < TopAbs_SHAPE; ++iType) nbTypes[iType] = 0; @@ -1859,9 +1855,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object) //Compute the sub-shape value try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed to reverse shape"); return NULL; @@ -2670,9 +2664,7 @@ Handle(TColStd_HSequenceOfInteger) // Compute tolerance Standard_Real T, VertMax = -RealLast(); try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif for (TopExp_Explorer ExV (theShape, TopAbs_VERTEX); ExV.More(); ExV.Next()) { TopoDS_Vertex Vertex = TopoDS::Vertex(ExV.Current()); T = BRep_Tool::Tolerance(Vertex); 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_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx index 89c1d2b9c..8e04e15ec 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -129,9 +129,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -182,9 +180,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -238,9 +234,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -293,9 +287,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -348,9 +340,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -401,9 +391,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -462,9 +450,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -525,9 +511,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -590,9 +574,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Obje //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -788,9 +770,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -841,9 +821,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -895,9 +873,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -948,9 +924,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -1002,9 +976,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -1055,9 +1027,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -1107,9 +1077,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape //Compute the offset try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Offset driver failed"); return NULL; @@ -1161,9 +1129,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy //Compute the offset try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Offset driver failed"); return NULL; @@ -1215,9 +1181,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy //Compute the Projection try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Projection driver failed"); return NULL; @@ -1281,9 +1245,7 @@ Standard_Real GEOMImpl_ITransformOperations::ProjectPointOnWire //Compute the Projection try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Projection driver failed"); return aResult; @@ -1345,9 +1307,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape //Compute the scale try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Scale driver failed"); return NULL; @@ -1406,9 +1366,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy //Compute the scale try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Scale driver failed"); return NULL; @@ -1477,9 +1435,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(G //Compute the scale try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Scale driver failed"); return NULL; @@ -1542,9 +1498,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape //Compute the Position try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Position driver failed"); return NULL; @@ -1601,9 +1555,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy //Compute the position try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Position driver failed"); return NULL; @@ -1663,9 +1615,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath //Compute the position try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Position driver failed"); return NULL; @@ -1726,9 +1676,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) t //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1781,9 +1729,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Objec //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1837,9 +1783,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1898,9 +1842,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1962,9 +1904,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -2028,9 +1968,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -2091,9 +2029,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEO //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -2148,9 +2084,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -2294,9 +2228,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy // Compute the transformation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Driver failed"); return NULL; 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_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index af4f40df9..5f580ddb9 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -152,6 +152,26 @@ static GeomFill_Trihedron EvaluateBestSweepMode(const TopoDS_Shape& Spine) return theMode; } +//======================================================================= +//function : BuildPipeShell +//purpose : Builds a pipe shell. If failed, try to build in Descrete Trihedron +// mode. Returns Standard_True if the building is done successfully. +//======================================================================= +static Standard_Boolean BuildPipeShell(BRepOffsetAPI_MakePipeShell &theBuilder) +{ + theBuilder.Build(); + + Standard_Boolean isDone = theBuilder.IsDone(); + + if (!isDone) { + // Try to use Descrete Trihedron mode. + theBuilder.SetDiscreteMode(); + theBuilder.Build(); + isDone = theBuilder.IsDone(); + } + + return isDone; +} //======================================================================= //function : FillForOtherEdges @@ -256,7 +276,9 @@ static bool FillCorrespondingEdges(const TopoDS_Shape& FS1, if (!aBuilder.IsReady()) { return false; } - aBuilder.Build(); + + BuildPipeShell(aBuilder); + TopoDS_Shape aShape = aBuilder.Shape(); /* TopoDS_Compound C; @@ -681,6 +703,7 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections TopTools_SequenceOfShape aSeqBases; TopTools_SequenceOfShape aSeqLocs; TopTools_SequenceOfShape aSeqFaces; + Standard_Boolean NeedCreateSolid = Standard_False; Standard_Integer i = 1; for (i = 1; i <= nbBases; i++) { @@ -697,7 +720,6 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections //if for section was specified face with a few wires then a few // pipes were build and make solid - Standard_Boolean NeedCreateSolid = Standard_False; if (aTypeBase == TopAbs_SHELL) { // create wire as boundary contour if shell is no closed // get free boundary shapes @@ -930,7 +952,9 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections if (!aBuilder.IsReady()) { Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); } - aBuilder.Build(); + + BuildPipeShell(aBuilder); + TopoDS_Shape resShape = aBuilder.Shape(); aSeqRes.Append(resShape); } @@ -961,7 +985,9 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections if (!aBuilder.IsReady()) { Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); } - aBuilder.Build(); + + BuildPipeShell(aBuilder); + TopoDS_Shape resShape = aBuilder.Shape(); aSeqRes.Append(resShape); // make sewing for result @@ -1014,22 +1040,20 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections aBuilder.SetTolerance(aTolConf, aTolConf, aTolAng); - aBuilder.Build(); + Standard_Boolean isDone = BuildPipeShell(aBuilder); + + if (isDone && NeedCreateSolid) { + isDone = aBuilder.MakeSolid(); + } + + if (!isDone) { + Standard_ConstructionError::Raise("Pipe construction failure"); + } aShape = aBuilder.Shape(); aSeqFaces.Append(aShape); for (j = 1; j <=usedBases.Length(); j++) aBuilder.Delete(usedBases.Value(j)); } - - //for case if section is face - if (aSeqFaces.Length() >1) { - BRep_Builder aB; - TopoDS_Compound aComp; - aB.MakeCompound(aComp); - for (i = 1; i <= aSeqFaces.Length(); i++) - aB.Add(aComp,aSeqFaces.Value(i)); - aShape = aComp; - } } return aShape; @@ -1512,7 +1536,9 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); } - aBuilder.Build(); + + BuildPipeShell(aBuilder); + TopoDS_Shape aShape = aBuilder.Shape(); TopoDS_Shell aShell; B.MakeShell(aShell); @@ -1750,7 +1776,9 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, if (aCI) delete aCI; Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); } - aBuilder.Build(); + + BuildPipeShell(aBuilder); + TopoDS_Shape aShape = aBuilder.Shape(); TopoDS_Shell aShell; B.MakeShell(aShell); @@ -2333,8 +2361,10 @@ static TopoDS_Shape CreatePipeBiNormalAlongVector(const TopoDS_Wire& aWirePath, gp_Vec aVec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); gp_Dir BiNormal(aVec); PipeBuilder.SetMode(BiNormal); - PipeBuilder.Build(); - if (aShapeBase.ShapeType() == TopAbs_FACE) { + + Standard_Boolean isDone = BuildPipeShell(PipeBuilder); + + if (isDone && aShapeBase.ShapeType() == TopAbs_FACE) { PipeBuilder.MakeSolid(); } @@ -2444,9 +2474,10 @@ Standard_Integer GEOMImpl_PipeDriver::Execute (TFunction_Logbook& log) const if (FaceBuilder.IsDone()) Sweep.SetMode(FaceBuilder.Face()); Sweep.Add(Profile); - Sweep.Build(); - - if (!Sweep.IsDone()) + + Standard_Boolean isDone = BuildPipeShell(Sweep); + + if (!isDone) { if (aCI) delete aCI; Standard_ConstructionError::Raise("MakePipeShell failed"); @@ -2458,7 +2489,19 @@ Standard_Integer GEOMImpl_PipeDriver::Execute (TFunction_Logbook& log) const else { GeomFill_Trihedron theBestMode = EvaluateBestSweepMode(aWirePath); - aShape = BRepOffsetAPI_MakePipe(aWirePath, aShapeBase, theBestMode); + BRepOffsetAPI_MakePipe aMkPipe(aWirePath, aShapeBase, theBestMode); + + if (aMkPipe.IsDone()) { + aShape = aMkPipe.Shape(); + } else if (theBestMode != GeomFill_IsDiscreteTrihedron) { + // Try to use Descrete Trihedron mode. + BRepOffsetAPI_MakePipe aMkPipeDescrete + (aWirePath, aShapeBase, GeomFill_IsDiscreteTrihedron); + + if (aMkPipeDescrete.IsDone()) { + aShape = aMkPipeDescrete.Shape(); + } + } } } diff --git a/src/GEOMImpl/GEOMImpl_PipePathDriver.cxx b/src/GEOMImpl/GEOMImpl_PipePathDriver.cxx index 0dbbbffb2..25bf5cdff 100644 --- a/src/GEOMImpl/GEOMImpl_PipePathDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipePathDriver.cxx @@ -50,9 +50,7 @@ #include #include -#if OCC_VERSION_LARGE > 0x06050300 #include -#endif #include #include @@ -145,15 +143,11 @@ Standard_Integer GEOMImpl_PipePathDriver::Execute (TFunction_Logbook& log) const if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull()) Standard_NullObject::Raise("RestorePath aborted : null argument"); -#if OCC_VERSION_LARGE > 0x06050300 BRepOffsetAPI_MiddlePath aMPB (aShape, aBase1, aBase2); aMPB.Build(); if (aMPB.IsDone()) { aRes = aMPB.Shape(); } -#else - Standard_NullObject::Raise("RestorePath is not implemented in used OCCT version"); -#endif } else if (aType == PIPE_PATH_TWO_SEQS) { GEOMImpl_IPipePath aPI (aFunction); @@ -181,15 +175,11 @@ Standard_Integer GEOMImpl_PipePathDriver::Execute (TFunction_Logbook& log) const if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull()) Standard_NullObject::Raise("RestorePath aborted : null argument"); -#if OCC_VERSION_LARGE > 0x06050300 BRepOffsetAPI_MiddlePath aMPB (aShape, aBase1, aBase2); aMPB.Build(); if (aMPB.IsDone()) { aRes = aMPB.Shape(); } -#else - Standard_NullObject::Raise("RestorePath is not implemented in used OCCT version"); -#endif } else { } diff --git a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx index 80734dc8f..ef21d1764 100644 --- a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx @@ -127,12 +127,8 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const if (gp_Vec(aP1, aP2).IsParallel(gp_Vec(aP1, aP3), Precision::Angular())) Standard_ConstructionError::Raise("Plane creation aborted: points lay on one line"); GC_MakePlane aMakePlane (aP1, aP2, aP3); -#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version aShape = BRepBuilderAPI_MakeFace(aMakePlane, -aSize, +aSize, -aSize, +aSize, Precision::Confusion()).Shape(); -#else - aShape = BRepBuilderAPI_MakeFace(aMakePlane, -aSize, +aSize, -aSize, +aSize).Shape(); -#endif } else if (aType == PLANE_FACE) { Handle(GEOM_Function) aRef = aPI.GetFace(); TopoDS_Shape aRefShape = aRef->GetValue(); diff --git a/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx b/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx index 1eeeaf277..1a996c1e5 100644 --- a/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx @@ -23,12 +23,17 @@ #include "GEOMImpl_PolylineDriver.hxx" #include "GEOMImpl_ICurveParametric.hxx" +#include "GEOMImpl_ICurvesOperations.hxx" #include "GEOMImpl_IPolyline.hxx" +#include "GEOMImpl_IPolyline2D.hxx" #include "GEOMImpl_Types.hxx" #include "GEOM_Function.hxx" +#include +#include #include #include +#include #include #include #include @@ -38,6 +43,7 @@ #include #include #include +#include #include //======================================================================= @@ -59,6 +65,125 @@ GEOMImpl_PolylineDriver::GEOMImpl_PolylineDriver() { } +//======================================================================= +//function : MakePolyline2D +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PolylineDriver::MakePolyline2D + (TFunction_Logbook& log) const +{ + if (Label().IsNull()) { + return 0; + } + + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + GEOMImpl_IPolyline2D aCI(aFunction); + Standard_Integer aType = aFunction->GetType(); + TopoDS_Shape aShape; + + // Get data. + Handle(TColStd_HArray1OfExtendedString) aNames = aCI.GetNames(); + Handle(TColStd_HArray1OfByte) aTypes = aCI.GetTypes(); + Handle(TColStd_HArray1OfByte) aClosedFlags = aCI.GetClosedFlags(); + std::list > aCoords; + gp_Ax3 aWPlane; + + aCI.GetCoords(aCoords); + + // Check the data validity + if (aNames.IsNull()) { + return 0; + } + + Standard_Integer aNbSections = aNames->Length(); + + if (aTypes.IsNull() || aNbSections != aTypes->Length()) { + return 0; + } + + if (aClosedFlags.IsNull() || aNbSections != aClosedFlags->Length()) { + return 0; + } + + if (aNbSections != aCoords.size()) { + return 0; + } + + if (aType == POLYLINE2D_PLN_COORDS) { + Handle(TColStd_HArray1OfReal) aPlaneCoords = aCI.GetWorkingPlaneDbls(); + + if (aPlaneCoords.IsNull()) { + return 0; + } + + if (aPlaneCoords->Length() != 9) { + return 0; + } + + Standard_Integer i = aPlaneCoords->Lower(); + gp_Pnt aOrigin(aPlaneCoords->Value(i), aPlaneCoords->Value(i + 1), + aPlaneCoords->Value(i + 2)); + gp_Dir aDirZ(aPlaneCoords->Value(i + 3), aPlaneCoords->Value(i + 4), + aPlaneCoords->Value(i + 5)); + gp_Dir aDirX(aPlaneCoords->Value(i + 6), aPlaneCoords->Value(i + 7), + aPlaneCoords->Value(i + 8)); + aWPlane = gp_Ax3(aOrigin, aDirZ, aDirX); + } else if (aType == POLYLINE2D_PLN_OBJECT) { + Handle(GEOM_Function) aRefFace = aCI.GetWorkingPlane(); + TopoDS_Shape aShape = aRefFace->GetValue(); + + aWPlane = GEOMUtils::GetPosition(aShape); + } else { + return 0; + } + + // Construct a shape. + Standard_Integer iN = aNames->Lower(); + Standard_Integer iT = aTypes->Lower(); + Standard_Integer iC = aClosedFlags->Lower(); + std::list >::const_iterator anIter = aCoords.begin(); + BRep_Builder aBuilder; + Standard_Boolean isEmpty = Standard_True; + + if (aNbSections > 1) { + aBuilder.MakeCompound(TopoDS::Compound(aShape)); + } + + for (; anIter != aCoords.end(); ++anIter, ++iN, ++iT, ++iC) { + Standard_Integer aType = aTypes->Value(iT); + TopoDS_Shape aSection; + + if (aType == GEOMImpl_ICurvesOperations::Polyline) { + aSection = Sketcher_Utils::MakePolyline + (*anIter, aClosedFlags->Value(iC), aWPlane); + } else if (aType == GEOMImpl_ICurvesOperations::Interpolation) { + aSection = Sketcher_Utils::MakeInterpolation + (*anIter, aClosedFlags->Value(iC), aWPlane); + } + + if (aNbSections > 1) { + // There are multiple sections. + if (aSection.IsNull() == Standard_False) { + aBuilder.Add(aShape, aSection); + isEmpty = Standard_False; + } + } else { + // There is only one section. + isEmpty = aSection.IsNull(); + aShape = aSection; + } + } + + if (isEmpty) { + return 0; + } + + aFunction->SetValue(aShape); + log.SetTouched(Label()); + + return 1; +} + //======================================================================= //function : Execute //purpose : @@ -67,9 +192,13 @@ Standard_Integer GEOMImpl_PolylineDriver::Execute(TFunction_Logbook& log) const { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + Standard_Integer aType = aFunction->GetType(); + + if (aType == POLYLINE2D_PLN_COORDS || aType == POLYLINE2D_PLN_OBJECT) { + return MakePolyline2D(log); + } GEOMImpl_IPolyline aCI (aFunction); - Standard_Integer aType = aFunction->GetType(); TopoDS_Shape aShape; @@ -166,10 +295,9 @@ GetCreationInformation(std::string& theOperationName, GEOMImpl_ICurveParametric aIP( function ); Standard_Integer aType = function->GetType(); - theOperationName = "CURVE"; - switch ( aType ) { case POLYLINE_POINTS: + theOperationName = "CURVE"; AddParam( theParams, "Type", "Polyline"); if ( aIP.HasData() ) { @@ -206,6 +334,103 @@ GetCreationInformation(std::string& theOperationName, AddParam( theParams, "Is closed", aCI.GetIsClosed() ); } break; + case POLYLINE2D_PLN_COORDS: + case POLYLINE2D_PLN_OBJECT: + { + theOperationName = "SKETCH"; + + GEOMImpl_IPolyline2D aP2d(function); + Handle(TColStd_HArray1OfExtendedString) aNames = aP2d.GetNames(); + + if (aNames.IsNull() == Standard_False) { + if (aNames->Length() == 1) { + // This is the single curve. Make its full dump. + AddParam(theParams, "Name", aNames->Value(aNames->Lower())); + + Handle(TColStd_HArray1OfByte) aTypes = aP2d.GetTypes(); + + if (aTypes.IsNull() == Standard_False && aTypes->Length() == 1) { + Standard_Integer aType = aTypes->Value(aTypes->Lower()); + + if (aType == GEOMImpl_ICurvesOperations::Polyline) { + AddParam(theParams, "Type") << "Polyline"; + } else if (aType == GEOMImpl_ICurvesOperations::Interpolation) { + AddParam(theParams, "Type") << "Interpolation"; + } + } + + Handle(TColStd_HArray1OfByte) aCloseds = aP2d.GetClosedFlags(); + + if (aCloseds.IsNull() == Standard_False && aCloseds->Length() == 1) { + const char *aYesNo = + aCloseds->Value(aCloseds->Lower()) ? "Yes" : "No"; + + AddParam(theParams, "Is closed", aYesNo); + } + + std::list > aCoords; + + aP2d.GetCoords(aCoords); + + if (aCoords.size() == 1) { + AddParam(theParams, "Number of points", aCoords.front().size()/2); + } + } else { + // There are more than 1 curve. + Standard_Integer aNbCurves = aNames->Length(); + Standard_Integer i; + std::list > aCoords; + + AddParam(theParams, "Number of curves", aNbCurves); + aP2d.GetCoords(aCoords); + + Standard_Integer aNbCoords = aCoords.size(); + std::list >::const_iterator + anIt = aCoords.begin(); + + for (i = 0; i < aNbCurves; i++) { + TCollection_AsciiString aName("Curve "); + TCollection_ExtendedString + aValue(aNames->Value(aNames->Lower() + i)); + + aName.AssignCat(i + 1); + + if (anIt != aCoords.end()) { + aValue.AssignCat(" ("); + aValue.AssignCat(Standard_Integer(anIt->size())); + aValue.AssignCat(" points)"); + anIt++; + } + + AddParam(theParams, aName.ToCString(), aValue); + } + } + } + + if (aType == POLYLINE2D_PLN_COORDS) { + Handle(TColStd_HArray1OfReal) aPln = aP2d.GetWorkingPlaneDbls(); + + if (aPln.IsNull() == Standard_False && aPln->Length() == 9) { + Standard_Integer i = aPln->Lower(); + + AddParam( theParams, "Origin") + << aPln->Value(i) << " " + << aPln->Value(i + 1) << " " + << aPln->Value(i + 2); + AddParam( theParams, "OZ") + << aPln->Value(i + 3) << " " + << aPln->Value(i + 4) << " " + << aPln->Value(i + 5); + AddParam( theParams, "OX") + << aPln->Value(i + 6) << " " + << aPln->Value(i + 7) << " " + << aPln->Value(i + 8); + } + } else { + AddParam(theParams, "Working plane", aP2d.GetWorkingPlane(), "XOY"); + } + } + break; default: return false; } diff --git a/src/GEOMImpl/GEOMImpl_PolylineDriver.hxx b/src/GEOMImpl/GEOMImpl_PolylineDriver.hxx index 3f8165537..b3f89d91e 100644 --- a/src/GEOMImpl/GEOMImpl_PolylineDriver.hxx +++ b/src/GEOMImpl/GEOMImpl_PolylineDriver.hxx @@ -80,6 +80,9 @@ Standard_EXPORT ~GEOMImpl_PolylineDriver() {}; Standard_EXPORT virtual bool GetCreationInformation(std::string& theOperationName, std::vector& params); +private: + + Standard_Integer MakePolyline2D(TFunction_Logbook& log) const; DEFINE_STANDARD_RTTI( GEOMImpl_PolylineDriver ) }; diff --git a/src/GEOMImpl/GEOMImpl_PolylineDumper.cxx b/src/GEOMImpl/GEOMImpl_PolylineDumper.cxx new file mode 100644 index 000000000..05fb9a61a --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PolylineDumper.cxx @@ -0,0 +1,251 @@ +// 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 : GEOMImpl_PolylineDumper.cxx +// Author : Sergey KHROMOV +// Module : GEOM + + +#include "GEOMImpl_PolylineDumper.hxx" +#include "GEOMImpl_ICurvesOperations.hxx" + +#include + + +//======================================================================= +// function : Constructor +// purpose : +//======================================================================= +GEOMImpl_PolylineDumper::GEOMImpl_PolylineDumper + (const std::list > &theCoords, + const Handle(TColStd_HArray1OfExtendedString) &theNames, + const Handle(TColStd_HArray1OfByte) &theTypes, + const Handle(TColStd_HArray1OfByte) &theCloseds, + const Handle(TColStd_HArray1OfReal) &thePlnCoords) + : myCoords (theCoords), + myNames (theNames), + myTypes (theTypes), + myCloseds (theCloseds), + myPlnCoords (thePlnCoords), + myIsDone (Standard_False) +{ + init(); +} + + +//======================================================================= +// function : Constructor +// purpose : +//======================================================================= +GEOMImpl_PolylineDumper::GEOMImpl_PolylineDumper + (const std::list > &theCoords, + const Handle(TColStd_HArray1OfExtendedString) &theNames, + const Handle(TColStd_HArray1OfByte) &theTypes, + const Handle(TColStd_HArray1OfByte) &theCloseds, + const Handle(GEOM_Object) &theWorkingPlane) + : myCoords (theCoords), + myNames (theNames), + myTypes (theTypes), + myCloseds (theCloseds), + myWorkingPlane (theWorkingPlane), + myIsDone (Standard_False) +{ + init(); +} + +//======================================================================= +// function : Dump +// purpose : +//======================================================================= +Standard_Boolean GEOMImpl_PolylineDumper::Dump + (const Handle(GEOM_Object) &theObject) +{ + if (theObject.IsNull()) { + return Standard_False; + } + + if (myIsDone) { + Handle(GEOM_Function) aFunction = theObject->GetLastFunction(); + GEOM::TPythonDump aPD(aFunction); + + aPD << myDescr; + aPD << theObject << " = pl.result("; + + if (myWorkingPlane.IsNull()) { + // Add coodinates of working plane. + Standard_Integer i; + + aPD << "["; + for (i = 0; i < 9; ++i) { + aPD << myPlnCoords->Value(myPlnCoords->Lower() + i); + + if (i < 8) { + aPD << ", "; + } + } + aPD << "]"; + } else { + aPD << myWorkingPlane; + } + + aPD << ")"; + } + + return myIsDone; +} + +//======================================================================= +// function : init +// purpose : +//======================================================================= +void GEOMImpl_PolylineDumper::init() +{ + // Check input parameters. + if (myCoords.empty() || myNames.IsNull() || + myTypes.IsNull() || myCloseds.IsNull()) { + // One or more input parameters are null or empty() + return; + } + + const Standard_Integer aNbSec = myCoords.size(); + + if (aNbSec != myNames->Length() || aNbSec != myTypes->Length() || + aNbSec != myCloseds->Length()) { + // Inconsistent data. + return; + } + + // Check the reference plane + if (myPlnCoords.IsNull()) { + if (myWorkingPlane.IsNull()) { + // Null working plane + return; + } + } else { + if (myWorkingPlane.IsNull() == Standard_False) { + // Ambiguous working plane + return; + } + + if (myPlnCoords->Length() != 9) { + // Invalid number of plane coordinates. + return; + } + } + + char *aSeparator = "\n\t"; + Standard_Integer i; + std::list >::const_iterator anIt = myCoords.begin(); + + myDescr += "pl = geompy.Polyline2D()"; + + // Add sections. + for (i = 0; i < aNbSec && anIt != myCoords.end(); ++i, ++anIt) { + myDescr += aSeparator; + myDescr += "pl.addSection("; + // Add name + myDescr += "\""; + myDescr += myNames->Value(myNames->Lower() + i) + "\", "; + // Add type + const Standard_Integer aType = myTypes->Value(myTypes->Lower() + i); + + switch (aType) { + case GEOMImpl_ICurvesOperations::Polyline: + myDescr += "GEOM.Polyline, "; + break; + case GEOMImpl_ICurvesOperations::Interpolation: + myDescr += "GEOM.Interpolation, "; + break; + default: + myDescr.Clear(); + return; + break; // NEVERREACHED + } + + // Add Closed flag. + if (myCloseds->Value(myCloseds->Lower() + i)) { + myDescr += "True"; + } else { + myDescr += "False"; + } + + // Add points. + const Standard_Integer aNbCoords = anIt->size(); + + if (aNbCoords > 0) { + if (aNbCoords % 2) { + // Odd number of coordinates. + myDescr.Clear(); + return; + } + + if (aNbCoords <= 4) { + // Add 2 points to the same command addSection. + myDescr += ", ["; + + std::list ::const_iterator aCIt = anIt->begin(); + + while (aCIt != anIt->end()) { + myDescr += *aCIt; + + if (++aCIt != anIt->end()) { + myDescr += ", "; + } + } + } else { + // Add points to a separate command addPoints. + // Add maximum 4 points in a command. + std::list ::const_iterator aCIt = anIt->begin(); + Standard_Integer aMaxNbCoord = 8; + Standard_Integer j = 1; + + myDescr += ")"; + myDescr += aSeparator; + myDescr += "pl.addPoints(["; + + while (aCIt != anIt->end()) { + myDescr += *aCIt; + + if (++aCIt != anIt->end()) { + if (j == aMaxNbCoord) { + // 4 points are added. Add a new command. + myDescr += "])"; + myDescr += aSeparator; + myDescr += "pl.addPoints(["; + j = 1; + } else { + myDescr += ", "; + j++; + } + } + } + } + + myDescr += "]"; + } + + myDescr += ")"; + } + + myDescr += aSeparator; + myIsDone = Standard_True; +} diff --git a/src/GEOMImpl/GEOMImpl_PolylineDumper.hxx b/src/GEOMImpl/GEOMImpl_PolylineDumper.hxx new file mode 100644 index 000000000..1fe396bfd --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PolylineDumper.hxx @@ -0,0 +1,132 @@ +// 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 : GEOMImpl_PolylineDumper.h +// Author : Sergey KHROMOV + + +#ifndef _GEOMImpl_PolylineDumper_HXX_ +#define _GEOMImpl_PolylineDumper_HXX_ + + +#include "GEOM_GEOMImpl.hxx" + +#include + +#include +#include +#include + +#include + + +/** + * This is a helper class to form a dump of a polyline 2d curves creation + * algorithm. + */ +class GEOMIMPL_EXPORT GEOMImpl_PolylineDumper +{ + +public: + + /** + * This construcor initializes the object with 2D polyline creation + * parameters. + * + * \param theCoords the list of coordinates list. theCoordsList[0] + * is the coordinates list of the first section. theCoordsList[1] + * is for the second section etc. + * \param theNames the list of names. The order corresponds to theCoords. + * \param theTypes the list of curve types. The order corresponds to + * theCoords. + * \param theCloseds the list of Closed flags. The order corresponds to + * theCoords. + * \param thePlnCoords 9 double values, defining origin, + * OZ and OX directions of the working plane. + */ + GEOMImpl_PolylineDumper + (const std::list > &theCoords, + const Handle_TColStd_HArray1OfExtendedString &theNames, + const Handle_TColStd_HArray1OfByte &theTypes, + const Handle_TColStd_HArray1OfByte &theCloseds, + const Handle_TColStd_HArray1OfReal &thePlnCoords); + + /** + * This construcor initializes the object with 2D polyline creation + * parameters. + * + * \param theCoords the list of coordinates list. theCoordsList[0] + * is the coordinates list of the first section. theCoordsList[1] + * is for the second section etc. + * \param theNames the list of names. The order corresponds to theCoords. + * \param theTypes the list of curve types. The order corresponds to + * theCoords. + * \param theCloseds the list of Closed flags. The order corresponds to + * theCoords. + * \param theWorkingPlane planar Face or LCS(Marker) of the working plane. + */ + GEOMImpl_PolylineDumper + (const std::list > &theCoords, + const Handle_TColStd_HArray1OfExtendedString &theNames, + const Handle_TColStd_HArray1OfByte &theTypes, + const Handle_TColStd_HArray1OfByte &theCloseds, + const Handle_GEOM_Object &theWorkingPlane); + + /** + * This method returns Standard_True if the dump description is created + * successfully. + * + * \return Standard_True in case of success; Standard_False otherwise. + */ + Standard_Boolean IsDone() const + { return myIsDone; } + + /** + * This method performs dump of the polyline. + * + * \param theObject the newly created object. + * \return Standard_True in case of success; Standard_False otherwise. + */ + Standard_Boolean Dump(const Handle_GEOM_Object &theObject); + +protected: + + /** + * This method generates the description required for python dump. + * It is called from constructor. + */ + void init(); + +private: + + const std::list > &myCoords; + Handle_TColStd_HArray1OfExtendedString myNames; + Handle_TColStd_HArray1OfByte myTypes; + Handle_TColStd_HArray1OfByte myCloseds; + Handle_TColStd_HArray1OfReal myPlnCoords; + Handle_GEOM_Object myWorkingPlane; + Standard_Boolean myIsDone; + TCollection_ExtendedString myDescr; + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx index 96f0bb6c6..037e62900 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -94,6 +95,11 @@ #include #include +// Uncomment this definition to check if type of created shape is the same +// as expected. For further details please see the Mantis issue +// http://salome.mantis.opencascade.com/view.php?id=22674 +//#define RESULT_TYPE_CHECK + //modified by NIZNHY-PKV Wed Dec 28 13:48:20 2011f //static // void KeepEdgesOrder(const Handle(TopTools_HSequenceOfShape)& aEdges, @@ -133,10 +139,17 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const TopoDS_Shape aShape; TCollection_AsciiString aWarning; +#ifdef RESULT_TYPE_CHECK + TopAbs_ShapeEnum anExpectedType = TopAbs_SHAPE; +#endif BRep_Builder B; if (aType == WIRE_EDGES) { +#ifdef RESULT_TYPE_CHECK + anExpectedType = TopAbs_WIRE; +#endif + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); Standard_Real aTolerance = aCI.GetTolerance(); @@ -146,6 +159,10 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const aShape = MakeWireFromEdges(aShapes, aTolerance); } else if (aType == FACE_WIRE) { +#ifdef RESULT_TYPE_CHECK + anExpectedType = TopAbs_FACE; +#endif + Handle(GEOM_Function) aRefBase = aCI.GetBase(); TopoDS_Shape aShapeBase = aRefBase->GetValue(); if (aShapeBase.IsNull()) Standard_NullObject::Raise("Argument Shape is null"); @@ -179,6 +196,10 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const } } else if (aType == FACE_WIRES) { +#ifdef RESULT_TYPE_CHECK + anExpectedType = TopAbs_FACE; +#endif + // Try to build a face from a set of wires and edges int ind; @@ -295,6 +316,10 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const } } else if (aType == SHELL_FACES) { +#ifdef RESULT_TYPE_CHECK + anExpectedType = TopAbs_SHELL; +#endif + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); unsigned int ind, nbshapes = aShapes->Length(); @@ -352,6 +377,10 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const } else if (aType == SOLID_SHELL) { +#ifdef RESULT_TYPE_CHECK + anExpectedType = TopAbs_SOLID; +#endif + Handle(GEOM_Function) aRefShell = aCI.GetBase(); TopoDS_Shape aShapeShell = aRefShell->GetValue(); if (!aShapeShell.IsNull() && aShapeShell.ShapeType() == TopAbs_COMPOUND) { @@ -379,11 +408,14 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const } else if (aType == SOLID_SHELLS) { +#ifdef RESULT_TYPE_CHECK + anExpectedType = TopAbs_SOLID; +#endif + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); unsigned int ind, nbshapes = aShapes->Length(); Standard_Integer ish = 0; - TopoDS_Solid Sol; - B.MakeSolid(Sol); + BRepBuilderAPI_MakeSolid aMkSolid; // add shapes for (ind = 1; ind <= nbshapes; ind++) { @@ -397,11 +429,13 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const if (It.More()) aShapeShell = It.Value(); } if (aShapeShell.ShapeType() == TopAbs_SHELL) { - B.Add(Sol, aShapeShell); + aMkSolid.Add(TopoDS::Shell(aShapeShell)); ish++; } } - if (ish == 0) return 0; + if (ish == 0 || !aMkSolid.IsDone()) return 0; + + TopoDS_Solid Sol = aMkSolid.Solid(); BRepClass3d_SolidClassifier SC (Sol); SC.PerformInfinitePoint(Precision::Confusion()); if (SC.State() == TopAbs_IN) @@ -410,6 +444,10 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const aShape = Sol; } else if (aType == COMPOUND_SHAPES) { +#ifdef RESULT_TYPE_CHECK + anExpectedType = TopAbs_COMPOUND; +#endif + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); unsigned int ind, nbshapes = aShapes->Length(); @@ -453,6 +491,10 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const } */ else if (aType == EDGE_WIRE) { +#ifdef RESULT_TYPE_CHECK + anExpectedType = TopAbs_EDGE; +#endif + Handle(GEOM_Function) aRefBase = aCI.GetBase(); TopoDS_Shape aWire = aRefBase->GetValue(); Standard_Real LinTol = aCI.GetTolerance(); @@ -462,6 +504,10 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const aShape = MakeEdgeFromWire(aWire, LinTol, AngTol); } else if (aType == EDGE_CURVE_LENGTH) { +#ifdef RESULT_TYPE_CHECK + anExpectedType = TopAbs_EDGE; +#endif + GEOMImpl_IVector aVI (aFunction); // RefCurve @@ -536,6 +582,10 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const if (aME.IsDone()) aShape = aME.Shape(); } else if (aType == SHAPE_ISOLINE) { +#ifdef RESULT_TYPE_CHECK + anExpectedType = TopAbs_EDGE; +#endif + GEOMImpl_IIsoline aII (aFunction); Handle(GEOM_Function) aRefFace = aII.GetFace(); TopoDS_Shape aShapeFace = aRefFace->GetValue(); @@ -577,6 +627,35 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const aShape = aSfs->Shape(); } +#ifdef RESULT_TYPE_CHECK + // Check if the result shape type is compatible with the expected. + const TopAbs_ShapeEnum aShType = aShape.ShapeType(); + + if (anExpectedType != TopAbs_SHAPE && anExpectedType != aShType) { + if (aShType == TopAbs_COMPOUND) { + // The result is compound. Check its sub-shapes. + TopoDS_Iterator anIter(aShape); + + if (!anIter.More()) { + // The result is an empty compound. + Standard_ConstructionError::Raise("Result type check failed"); + } + + for (; anIter.More(); anIter.Next()) { + const TopAbs_ShapeEnum aSubType = anIter.Value().ShapeType(); + + if (anExpectedType != aSubType) { + // There is an incompatible type. + Standard_ConstructionError::Raise("Result type check failed"); + } + } + } else { + // There is an incompatible type. + Standard_ConstructionError::Raise("Result type check failed"); + } + } +#endif + aFunction->SetValue(aShape); log.SetTouched(Label()); @@ -1074,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 old mode 100755 new mode 100644 index 4f4792448..0ea9449e2 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -109,17 +109,17 @@ #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 +#define GEOM_POLYLINE2D 56 + //GEOM_Function types #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 @@ -205,8 +205,10 @@ #define DISK_THREE_PNT 2 #define DISK_R 3 -#define CYLINDER_R_H 1 -#define CYLINDER_PNT_VEC_R_H 2 +#define CYLINDER_R_H 1 +#define CYLINDER_PNT_VEC_R_H 2 +#define CYLINDER_R_H_A 3 +#define CYLINDER_PNT_VEC_R_H_A 4 #define CONE_R1_R2_H 1 #define CONE_PNT_VEC_R1_R2_H 2 @@ -250,7 +252,9 @@ #define PARTITION_HALF 2 #define PARTITION_NO_SELF_INTERSECTIONS 3 -#define POLYLINE_POINTS 1 +#define POLYLINE_POINTS 1 +#define POLYLINE2D_PLN_COORDS 2 +#define POLYLINE2D_PLN_OBJECT 3 #define SPLINE_BEZIER 1 #define SPLINE_INTERPOLATION 2 @@ -361,9 +365,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/CMakeLists.txt b/src/GEOMToolsGUI/CMakeLists.txt index 143d07826..fe6a01b4e 100755 --- a/src/GEOMToolsGUI/CMakeLists.txt +++ b/src/GEOMToolsGUI/CMakeLists.txt @@ -38,6 +38,8 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GEOMGUI ${PROJECT_SOURCE_DIR}/src/GEOMBase ${PROJECT_SOURCE_DIR}/src/Material + ${PROJECT_SOURCE_DIR}/src/DependencyTree + ${PROJECT_SOURCE_DIR}/src/GEOMUtils ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -56,6 +58,7 @@ SET(_link_LIBRARIES GEOM GEOMBase Material + DependencyTree ) # --- headers --- @@ -71,6 +74,7 @@ SET(GEOMToolsGUI_HEADERS GEOMToolsGUI_PublishDlg.h GEOMToolsGUI_MaterialPropertiesDlg.h GEOMToolsGUI_LineWidthDlg.h + GEOMToolsGUI_ReduceStudyDlg.h ) # header files / to be processed by moc @@ -83,6 +87,7 @@ SET(_moc_HEADERS GEOMToolsGUI_PublishDlg.h GEOMToolsGUI_MaterialPropertiesDlg.h GEOMToolsGUI_LineWidthDlg.h + GEOMToolsGUI_ReduceStudyDlg.h ) # --- sources --- @@ -101,6 +106,7 @@ SET(GEOMToolsGUI_SOURCES GEOMToolsGUI_PublishDlg.cxx GEOMToolsGUI_MaterialPropertiesDlg.cxx GEOMToolsGUI_LineWidthDlg.cxx + GEOMToolsGUI_ReduceStudyDlg.cxx ${_moc_SOURCES} ) diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index daf888e2d..b56bc9c67 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -48,7 +48,6 @@ #include #include -#include #include // QT Includes @@ -62,116 +61,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 +206,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; @@ -422,7 +305,13 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) break; case GEOMOp::OpSortChildren: OnSortChildren(); + break; + case GEOMOp::OpShowDependencyTree: + OnShowDependencyTree(); break; + case GEOMOp::OpReduceStudy: + OnReduceStudy(); + break; default: SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); break; @@ -622,365 +511,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 @@ -1013,7 +543,7 @@ void GEOMToolsGUI::removeObjectWithChildren(_PTR(SObject) obj, if (!CORBA::is_nil(geomObj)) { //Remove visual properties of the object - appStudy->removeObjectFromAll(obj->GetID().c_str()); + appStudy->removeObjectProperties(obj->GetID().c_str()); // Erase graphical object QListIterator it( views ); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h index 683fffc7c..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(); @@ -90,6 +87,8 @@ private: void OnClsBringToFront(); void OnCreateFolder(); void OnSortChildren(); + void OnShowDependencyTree(); + void OnReduceStudy(); // Shortcut commands void OnChangeTransparency( bool ); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index ea5f7b1c9..4c8d4c7d8 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -34,6 +34,7 @@ #include "GEOMToolsGUI_PublishDlg.h" #include "GEOMToolsGUI_MaterialPropertiesDlg.h" #include "GEOMToolsGUI_LineWidthDlg.h" +#include "GEOMToolsGUI_ReduceStudyDlg.h" #include #include @@ -46,10 +47,13 @@ #include #include +#include +#include +#include + #include #include -#include #include @@ -90,12 +94,7 @@ #include #include - -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #include -#else -#include -#endif // QT Includes #include @@ -585,6 +584,13 @@ void GEOMToolsGUI::OnUnpublishObject() { _PTR(AttributeDrawable) aDrw = B->FindOrCreateAttribute( obj, "AttributeDrawable" ); aDrw->SetDrawable( false ); disp->EraseWithChildren(IObject); + // hide references if any + std::vector< _PTR(SObject) > vso = aStudy->FindDependances(obj); + for ( int i = 0; i < vso.size(); i++ ) { + _PTR(SObject) refObj = vso[i]; + aDrw = B->FindOrCreateAttribute( refObj, "AttributeDrawable" ); + aDrw->SetDrawable( false ); + } } // if ( obj ) } // iterator aSelMgr->clearSelected(); @@ -862,3 +868,43 @@ void GEOMToolsGUI::OnSortChildren() app->updateObjectBrowser( true ); } + +void GEOMToolsGUI::OnShowDependencyTree() +{ + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + + SUIT_ViewManager *svm = app->getViewManager( GraphicsView_Viewer::Type(), false ); + + if( !svm ) { + DependencyTree_View* view = new DependencyTree_View(); + DependencyTree_ViewModel* viewModel = new DependencyTree_ViewModel( GraphicsView_Viewer::Type(), view ); + SUIT_ViewManager *svm = app->createViewManager( viewModel ); + + LightApp_SelectionMgr* selMgr = app->selectionMgr(); + new DependencyTree_Selector( viewModel, (SUIT_SelectionMgr*)selMgr ); + + SUIT_ViewWindow* svw = svm->getActiveView(); + GraphicsView_ViewFrame* aViewFrame = 0; + if (!svw) svw = svm->createViewWindow(); + if (svw) aViewFrame = dynamic_cast(svw); + + view->init( aViewFrame ); + svm->setTitle( view->getViewName() ); + } + else + if( DependencyTree_ViewModel* viewModel = dynamic_cast( svm->getViewModel() ) ) + if( DependencyTree_View* view = dynamic_cast( viewModel->getActiveViewPort() ) ) { + svm->getActiveView()->setFocus(); + view->updateModel(); + } +} + +void GEOMToolsGUI::OnReduceStudy() +{ + QDialog* dlg = new GEOMToolsGUI_ReduceStudyDlg( SUIT_Session::session()->activeApplication()->desktop() ); + if( dlg != NULL ) + dlg->show(); +} diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx index e17d041d7..3d8686c7d 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -340,11 +339,7 @@ void GEOMToolsGUI_MarkerDlg::addTexture( int id, bool select ) const if ( id > 0 && myCustomTypeCombo->index( id ) == -1 ) { int tWidth, tHeight; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) texture = GeometryGUI::getTexture(getStudy(), id, tWidth, tHeight); -#else - Handle(Graphic3d_HArray1OfBytes) texture = GeometryGUI::getTexture(getStudy(), id, tWidth, tHeight); -#endif if ( !texture.IsNull() && texture->Length() == tWidth*tHeight/8 ) { QImage image( tWidth, tHeight, QImage::Format_Mono ); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx index 2f35c6595..657230a11 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include @@ -328,7 +328,7 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* SUIT_ViewWindow* window = app->desktop()->activeWindow(); if ( window ) { int mgrId = window->getViewManager()->getGlobalId(); - PropMap propMap = study->getObjectPropMap( mgrId, io->getEntry() ); + PropMap propMap = study->getObjectProperties( mgrId, io->getEntry() ); QString matProp = propMap.value(GEOM::propertyName( GEOM::Material )).toString(); if ( !matProp.isEmpty() ) myCurrentModel.fromProperties( matProp ); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.cxx index 514a5f200..17c3a2b3f 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.cxx @@ -340,6 +340,13 @@ void GEOMToolsGUI_PublishDlg::clickOnApply() { item->setData(0,Qt::CheckStateRole,QVariant()); } } + // show references if any + std::vector< _PTR(SObject) > vso = aStudy->FindDependances(SO); + for ( int i = 0; i < vso.size(); i++ ) { + _PTR(SObject) refObj = vso[i]; + aDrw = aBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" ); + aDrw->SetDrawable( true ); + } } } toProcess.clear(); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.cxx new file mode 100644 index 000000000..ffa36f27c --- /dev/null +++ b/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.cxx @@ -0,0 +1,734 @@ +// 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 "GEOMToolsGUI_ReduceStudyDlg.h" + +// GEOM includes +#include + +// GUI includes +#include +#include +#include + +#include + +#include +#include +#include + +// Qt includes +#include +#include +#include +#include +#include + +GEOMToolsGUI_ReduceStudyDlg::GEOMToolsGUI_ReduceStudyDlg( QWidget* parent ) +:QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), +myDisplayer(NULL) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + myVisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_VISIBLE" ) ) ); + myInvisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_INVISIBLE" ) ) ); + + myApp = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !myApp ) return; + SalomeApp_Study* study = dynamic_cast( myApp->activeStudy() ); + myStudy = dynamic_cast( myApp->activeStudy() )->studyDS(); + myDisplayer = GEOM_Displayer( study ); + + setWindowTitle( tr( "GEOM_REDUCE_STUDY_TITLE" ) ); + setAttribute(Qt::WA_DeleteOnClose); + + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setMargin( 11 ); topLayout->setSpacing( 6 ); + + /********************** Objects to be kept **********************/ + QGroupBox* groupKeptObjects = new QGroupBox( tr( "GEOM_REDUCE_STUDY_KEPT_OBJECTS" ) ); + QGridLayout* layoutKeptObjects = new QGridLayout( groupKeptObjects ); + createTreeWidget( myTreeKeptObjects = new QTreeWidget() ); + layoutKeptObjects->addWidget( myTreeKeptObjects ); + + /********************** Objects to be removed **********************/ + QGroupBox* groupRemoveObjects = new QGroupBox( tr( "GEOM_REDUCE_STUDY_REMOVE_OBJECTS" ) ); + QGridLayout* layoutRemoveObjects = new QGridLayout( groupRemoveObjects ); + createTreeWidget( myTreeRemoveObjects = new QTreeWidget() ); + layoutRemoveObjects->addWidget( myTreeRemoveObjects ); + + /********************** Options **********************/ + QGroupBox* groupOptions = new QGroupBox( tr( "GEOM_REDUCE_STUDY_OPTIONS" ) ); + QVBoxLayout* layoutOptions = new QVBoxLayout( groupOptions ); + + // Intermediate objects + QGroupBox* groupIntermediates = createButtonGroup( myGroupIntermediates = new QButtonGroup() ); + groupIntermediates->setTitle( tr( "GEOM_REDUCE_STUDY_INTERMEDIATES" ) ); + + // Sub-objects + QGroupBox* groupSubObjects = createButtonGroup( myGroupSubObjects = new QButtonGroup() ); + groupSubObjects->setTitle( tr( "GEOM_REDUCE_STUDY_SUB_OBJECTS" ) ); + + // Others + myCBRemoveEmptyFolder = new QCheckBox( tr( "GEOM_REDUCE_STUDY_REMOVE_EMPTY_FOLDER" ) ); + myCBRemoveEmptyFolder->setChecked( true ); + myCBSoftRemoval = new QCheckBox( tr( "GEOM_REDUCE_STUDY_SOFT_REMOVAL" ) ); + + layoutOptions->addWidget( groupIntermediates ); + layoutOptions->addWidget( groupSubObjects ); + layoutOptions->addWidget( myCBRemoveEmptyFolder ); + layoutOptions->addWidget( myCBSoftRemoval ); + + /********************** Buttons **********************/ + QGroupBox* groupButtons = new QGroupBox(); + QHBoxLayout* layoutButtons = new QHBoxLayout( groupButtons ); + + QPushButton* buttonOk = new QPushButton( tr( "GEOM_BUT_OK" ) ); + QPushButton* buttonCancel = new QPushButton( tr( "GEOM_BUT_CANCEL" ) ); + QPushButton* buttonHelp = new QPushButton( tr( "GEOM_BUT_HELP" ) ); + + layoutButtons->addWidget( buttonOk ); + layoutButtons->addStretch(); + layoutButtons->addWidget( buttonCancel ); + layoutButtons->addWidget( buttonHelp ); + + topLayout->addWidget( groupKeptObjects, 0, 0 ); + topLayout->addWidget( groupRemoveObjects, 0, 1 ); + topLayout->addWidget( groupOptions, 1, 0, 1, 2 ); + topLayout->addWidget( groupButtons, 2, 0, 1, 2 ); + + // Signals and slots connections + + connect( myTreeKeptObjects, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) ); + connect( myTreeRemoveObjects, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) ); + connect( myTreeKeptObjects->header(), SIGNAL( sectionClicked ( int ) ), this, SLOT( onHeaderClicked( int ) ) ); + connect( myTreeRemoveObjects->header(), SIGNAL( sectionClicked ( int ) ), this, SLOT( onHeaderClicked( int ) ) ); + + connect( myGroupIntermediates, SIGNAL( buttonClicked( int ) ), this, SLOT( update() ) ); + connect( myGroupSubObjects, SIGNAL( buttonClicked( int ) ), this, SLOT( update() ) ); + + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( clickOnHelp() ) ); + + connect( myApp->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( selectionChanged() ) ); + + init( getSelectedObjects() ); +} + +GEOMToolsGUI_ReduceStudyDlg::~GEOMToolsGUI_ReduceStudyDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : init() +// purpose : initialize dialog data +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::init( const std::set& theObjectEntries ) +{ + myMainEntries.clear(); + + myKeptObjects.clear(); + myListParents.clear(); + myListSubObjects.clear(); + myRemovedObjects.clear(); + + myMainEntries = theObjectEntries; + + GEOM::string_array_var keptObjects = new GEOM::string_array(); + int It = 0; + keptObjects->length( theObjectEntries.size() ); + std::set::iterator iter; + for( iter=theObjectEntries.begin(); iter!=theObjectEntries.end(); ++iter, It++ ) + keptObjects[ It ] = (*iter).c_str(); + + GEOM::string_array_var parentsObjects = new GEOM::string_array(); + GEOM::string_array_var subObjects = new GEOM::string_array(); + GEOM::string_array_var otherObjects = new GEOM::string_array(); + + GeometryGUI::GetGeomGen()->GetEntriesToReduceStudy( GeometryGUI::ClientStudyToStudy( myStudy ), + keptObjects, parentsObjects, + subObjects, otherObjects ); + + for ( int i = 0; i < keptObjects->length(); i++ ) + myKeptObjects.insert( keptObjects[i].in() ); + for( int i = 0; i< otherObjects->length(); i++ ) + myRemovedObjects.insert( otherObjects[i].in() ); + for( int i = 0; i< parentsObjects->length(); i++ ) + myListParents.insert( parentsObjects[i].in() ); + for( int i = 0; i< subObjects->length(); i++ ) + myListSubObjects.insert( subObjects[i].in() ); + + update(); + + checkVisibleIcon( myTreeKeptObjects ); + checkVisibleIcon( myTreeRemoveObjects ); +} + +//================================================================================= +// function : getSelectedObjects() +// purpose : get selected objects in object browser +//================================================================================= +std::set GEOMToolsGUI_ReduceStudyDlg::getSelectedObjects() const +{ + std::set objects; + + SALOME_ListIO selected; + myApp->selectionMgr()->selectedObjects( selected ); + + for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + if( !io->hasEntry() ) + continue; + GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_nil(); + geomObject = GEOMBase::ConvertIOinGEOMObject( io ); + if( geomObject->_is_nil() ) + continue; + QString entry = geomObject->GetEntry(); + objects.insert( entry.toStdString().c_str() ); + } + return objects; +} + +//================================================================================= +// function : createTreeWidget() +// purpose : create tree widget for unpublished or removed objects +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::createTreeWidget( QTreeWidget* theTreeWidget ) +{ + theTreeWidget->setColumnCount( 2 ); + QStringList columnNames; + columnNames.append(tr( "GEOM_REDUCE_STUDY_NAME" )); + columnNames.append(""); + theTreeWidget->setHeaderLabels( columnNames ); + QTreeWidgetItem * headerItem = new QTreeWidgetItem( columnNames ); + theTreeWidget->setHeaderItem ( headerItem ); + theTreeWidget->header()->moveSection( 1, 0 ); + theTreeWidget->header()->setClickable( true ); + theTreeWidget->header()->setMovable( false ); + theTreeWidget->header()->setResizeMode( 1, QHeaderView::ResizeToContents ); + theTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection ); +} + +//================================================================================= +// function : createButtonGroup() +// purpose : create button group for intermediate objects or sub-objects +//================================================================================= +QGroupBox* GEOMToolsGUI_ReduceStudyDlg::createButtonGroup( QButtonGroup* theButtonGroup ) +{ + QGroupBox* groupObjects = new QGroupBox(); + QHBoxLayout* layoutObjects = new QHBoxLayout( groupObjects ); + + QRadioButton* buttonKeep = new QRadioButton( tr( "GEOM_REDUCE_STUDY_KEEP") ); + theButtonGroup->addButton( buttonKeep, 0 ); + QRadioButton* buttonUnpublish = new QRadioButton( tr( "GEOM_REDUCE_STUDY_UNPUBLISH") ); + theButtonGroup->addButton( buttonUnpublish, 1 ); + QRadioButton* buttonRemove = new QRadioButton( tr( "GEOM_REDUCE_STUDY_REMOVE") ); + theButtonGroup->addButton( buttonRemove, 2 ); + + theButtonGroup->button( 0 )->setChecked( true ); + theButtonGroup->setExclusive( true ); + + layoutObjects->addWidget( buttonKeep ); + layoutObjects->addWidget( buttonUnpublish ); + layoutObjects->addWidget( buttonRemove ); + + return groupObjects; +} + +//================================================================================= +// function : addObjectsToTree() +// purpose : add the list of objects to tree +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::addObjectsToTree( QTreeWidget* theWidget, std::set& theObjects ) +{ + std::set::iterator it; + for( it = theObjects.begin(); it != theObjects.end(); ++it ) { + std::string objectEntry = *it; + GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( myStudy->StudyId(), objectEntry.c_str() ); + GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject ); + QString studyEntry = GeomBaseObject->GetStudyEntry(); + if( GeomObject->_is_nil() || studyEntry.isEmpty() || !isObjectDrawable( studyEntry.toStdString() ) ) + continue; + addSubObject( theWidget, theObjects, GeomObject ); + } +} + +//================================================================================= +// function : addSubObject() +// purpose : add sub-object to parent object in the tree +//================================================================================= +GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::addSubObject( QTreeWidget* theWidget, + std::set& theObjects, + GEOM::GEOM_Object_var theObject ) +{ + GEOMToolsGUI_TreeWidgetItem* item; + if( !theObject->IsMainShape() ) { + GEOMToolsGUI_TreeWidgetItem* parentItem = addSubObject( theWidget, theObjects, theObject->GetMainShape() ); + item = findObjectInTree( theWidget, theObject ); + if( !item ) + item = new GEOMToolsGUI_TreeWidgetItem( parentItem, QStringList() << theObject->GetName(), theObject->GetStudyEntry() ); + } + else { + item = findObjectInTree( theWidget, theObject ); + if( !item ) + item = new GEOMToolsGUI_TreeWidgetItem( theWidget, QStringList() << theObject->GetName(), theObject->GetStudyEntry() ); + } + + bool isDisplayed = false; + if( theObjects.find( theObject->GetEntry() ) != theObjects.end() ) { + isDisplayed = myDisplayer.IsDisplayed( theObject->GetStudyEntry() ); + if ( isDisplayed ) + item->setVisible( true, myVisible ); + else + item->setVisible( false, myInvisible ); + + if( myMainEntries.find( theObject->GetEntry() ) != myMainEntries.end() ) { + QFont Textfont = item->font(0); + Textfont.setBold( true ); + item->setFont( 0, Textfont ); + } + } + else { + item->setFlags( item->flags() & ~Qt::ItemIsSelectable ); + item->setTextColor( 0, QColor( 150, 150, 150 ) ); + } + return item; +} + +//================================================================================= +// function : findObjectInTree() +// purpose : find object in the tree +//================================================================================= +GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::findObjectInTree( QTreeWidget* theWidget, GEOM::GEOM_Object_var theObject ) +{ + QTreeWidgetItemIterator it( theWidget ); + while(*it) { + GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); + if( QString( item->getStudyEntry() ) == QString( theObject->GetStudyEntry() ) ) + return item; + ++it; + } + return NULL; +} + +//================================================================================= +// function : checkVisibleIcon() +// purpose : set visible or invisible icon in the header of tree +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::checkVisibleIcon( QTreeWidget* theWidget ) +{ + bool isInvisible = false; + QTreeWidgetItemIterator it( theWidget ); + while(*it) { + GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); + const char* entry = item->getStudyEntry(); + if( item->flags() & Qt::ItemIsSelectable ) + if( !item->isVisible() ) + isInvisible = true; + ++it; + } + + if( isInvisible ) { + theWidget->headerItem()->setIcon( 1, myInvisible ); + myMapTreeSelectAll[ theWidget ] = false; + } + else { + theWidget->headerItem()->setIcon( 1, myVisible ); + myMapTreeSelectAll[ theWidget ] = true; + } +} + +//================================================================================= +// function : isObjectDrawable() +// purpose : return true if object is drawable, and false if object is hidden in the study +//================================================================================= +bool GEOMToolsGUI_ReduceStudyDlg::isObjectDrawable( std::string theStudyEntry ) +{ + _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder(); + //If object hasn't "AttributeDrawable" => it visible + bool isDrawable = true; + _PTR(SObject) SO ( myStudy->FindObjectID( theStudyEntry ) ); + _PTR(GenericAttribute) anAttr; + if ( SO && SO->FindAttribute( anAttr, "AttributeDrawable" ) ) { + _PTR(AttributeDrawable) aDrw (anAttr); + isDrawable = aDrw->IsDrawable(); + } + return isDrawable; +} + +//================================================================================= +// function : unpublishObjects() +// purpose : unpublish(hide) objects in the study +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::unpublishObjects( std::set& theObjects ) +{ + _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder(); + std::set::iterator it; + for( it = theObjects.begin(); it != theObjects.end(); ++it ) { + std::string objectEntry = *it; + GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( myStudy->StudyId(), + objectEntry.c_str() ); + std::string studyEntry = GeomBaseObject->GetStudyEntry(); + if ( studyEntry == "" || !isObjectDrawable( studyEntry ) ) + continue; + _PTR(SObject) obj ( myStudy->FindObjectID( studyEntry.c_str() ) ); + _PTR(GenericAttribute) anAttr; + if ( obj ) { + _PTR(AttributeDrawable) aDrw = aStudyBuilder->FindOrCreateAttribute( obj, "AttributeDrawable" ); + aDrw->SetDrawable( false ); + myDisplayer.EraseWithChildren( new SALOME_InteractiveObject( studyEntry.c_str(), "GEOM", "TEMP_IO" ) ); + // hide references if any + std::vector< _PTR(SObject) > vso = myStudy->FindDependances(obj); + for ( int i = 0; i < vso.size(); i++ ) { + _PTR(SObject) refObj = vso[i]; + aDrw = aStudyBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" ); + aDrw->SetDrawable( false ); + } + } + } + myApp->updateObjectBrowser( false ); + myApp->updateActions(); +} + +//================================================================================= +// function : removeObjects() +// purpose : remove objects from the study +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::removeObjects( std::set& theObjects ) +{ + std::set::iterator it; + for( it = theObjects.begin(); it != theObjects.end(); ++it ) { + std::string objectEntry = *it; + GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( myStudy->StudyId(), + objectEntry.c_str() ); + std::string studyEntry = GeomBaseObject->GetStudyEntry(); + if ( studyEntry == "" ) + GeometryGUI::GetGeomGen()->RemoveObject( GeomBaseObject ); + else { + if( !isObjectDrawable( studyEntry ) ) + continue; + removeObject( studyEntry ); + } + } + myApp->updateObjectBrowser( false ); + myApp->updateActions(); +} + +//================================================================================= +// function : removeObject() +// purpose : remove object with given study entry +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::removeObject( std::string& theStudyEntry ) +{ + SalomeApp_Study* appStudy = dynamic_cast( myApp->activeStudy() ); + _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder(); + _PTR(UseCaseBuilder) aUseCaseBuilder = myStudy->GetUseCaseBuilder(); + + _PTR(SObject) obj ( myStudy->FindObjectID( theStudyEntry.c_str() ) ); + if ( obj ) { + // remove visual properties of the object + appStudy->removeObjectProperties(obj->GetID().c_str()); + // remove references to this object + appStudy->deleteReferencesTo( obj ); + // remove objects from study + aStudyBuilder->RemoveObjectWithChildren( obj ); + // remove object from use case tree + aUseCaseBuilder->Remove( obj ); + myDisplayer.EraseWithChildren( new SALOME_InteractiveObject( theStudyEntry.c_str(), "GEOM", "TEMP_IO" ) ); + } +} + +//================================================================================= +// function : removeEmptyFolders() +// purpose : remove empty folders from the study +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::removeEmptyFolders() +{ + std::set emptyFolders; + + _PTR(SComponent) SC ( myStudy->FindComponent( "GEOM" ) ); + if ( !SC ) + return; + _PTR(ChildIterator) anIter ( myStudy->NewChildIterator( SC ) ); + anIter->InitEx( true ); + while( anIter->More() ) { + _PTR(SObject) valSO ( anIter->Value() ); + _PTR(SObject) refSO; + if ( !valSO->ReferencedObject( refSO ) ) + getEmptyFolders( valSO, emptyFolders ); + anIter->Next(); + } + + std::set::iterator iter; + for( iter = emptyFolders.begin(); iter != emptyFolders.end(); ++iter ) { + std::string studyEntry = *iter; + removeObject( studyEntry ); + } + myApp->updateObjectBrowser( false ); + myApp->updateActions(); +} + +//================================================================================= +// function : removeEmptyFolders() +// purpose : remove empty folders from the study +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::getEmptyFolders( _PTR(SObject) theSO, std::set& theFolders ) +{ + _PTR(UseCaseBuilder) aUseCaseBuilder = myStudy->GetUseCaseBuilder(); + + bool isFolder = false; + _PTR(GenericAttribute) anAttr; + if ( theSO->FindAttribute(anAttr, "AttributeLocalID") ) { + _PTR(AttributeLocalID) aLocalID( anAttr ); + isFolder = aLocalID->Value() == 999; + } + QString studyEntry = theSO->GetID().c_str(); + if ( isFolder ) { + if( !aUseCaseBuilder->HasChildren( theSO ) ) + theFolders.insert( studyEntry.toStdString() ); + else { + _PTR(UseCaseIterator) ucit ( aUseCaseBuilder->GetUseCaseIterator( theSO ) ); + for ( ucit->Init( false ); ucit->More(); ucit->Next() ) + getEmptyFolders( ucit->Value(), theFolders ); + } + } +} + +//================================================================================= +// function : onItemClicked() +// purpose : called when tree item was clicked +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::onItemClicked( QTreeWidgetItem* theItem, int theColumn ) +{ + if( theColumn != 1 || !( theItem->flags() & Qt::ItemIsSelectable ) ) + return; + + GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast( theItem ); + + const char* entry = item->getStudyEntry(); + Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ); + if( myDisplayer.IsDisplayed( entry ) ) { + item->setVisible( false, myInvisible ); + myDisplayer.Erase( io ); + } + else { + item->setVisible( true, myVisible ); + myDisplayer.Display( io ); + } + myDisplayer.UpdateViewer(); + checkVisibleIcon( item->treeWidget() ); +} + +//================================================================================= +// function : onHeaderClicked() +// purpose : called when header item of tree was clicked +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::onHeaderClicked( int theColumn ) +{ + if( theColumn != 1 ) + return; + + QTreeWidget* treeWidget = dynamic_cast(sender()->parent()); + if( myMapTreeSelectAll[ treeWidget ] ) { + myMapTreeSelectAll[ treeWidget ] = false; + treeWidget->headerItem()->setIcon( 1, myInvisible ); + QTreeWidgetItemIterator it( treeWidget ); + while(*it) { + GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); + if( ( item->flags() & Qt::ItemIsSelectable ) && item->isVisible() ) { + const char* entry = item->getStudyEntry(); + item->setVisible( false, myInvisible ); + myDisplayer.Erase( new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ) ); + } + ++it; + } + } + else { + myMapTreeSelectAll[ treeWidget ] = true; + treeWidget->headerItem()->setIcon( 1, myVisible ); + QTreeWidgetItemIterator it( treeWidget ); + while(*it) { + GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast(*it); + if( ( item->flags() & Qt::ItemIsSelectable ) && !item->isVisible() ) { + const char* entry = item->getStudyEntry(); + item->setVisible( true, myVisible ); + myDisplayer.Display( new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ) ); + } + ++it; + } + } + myDisplayer.UpdateViewer(); +} + +//================================================================================= +// function : selectionChanged() +// purpose : called when selection of object browser was changed +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::selectionChanged() +{ + init( getSelectedObjects() ); +} + +//================================================================================= +// function : update() +// purpose : update tree data +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::update() +{ + myTreeKeptObjects->clear(); + myTreeRemoveObjects->clear(); + + std::set keptObjects( myKeptObjects ); + std::set removeObjects( myRemovedObjects ); + + // Intermediate objects + if( myGroupIntermediates->checkedId() == 2 ) { // remove + std::set::iterator iter; + for( iter=myListParents.begin(); iter!=myListParents.end(); ++iter) + removeObjects.insert( *iter ); + } + else { // keep or unpublish + std::set::iterator iter; + for( iter=myListParents.begin(); iter!=myListParents.end(); ++iter) + keptObjects.insert( *iter ); + } + + // Sub-objects + if( myGroupSubObjects->checkedId() == 2 ) { + std::set::iterator iter; + for( iter=myListSubObjects.begin(); iter!=myListSubObjects.end(); ++iter) + removeObjects.insert( *iter ); + } + else { + std::set::iterator iter; + for( iter=myListSubObjects.begin(); iter!=myListSubObjects.end(); ++iter) + keptObjects.insert( *iter ); + } + + addObjectsToTree( myTreeKeptObjects, keptObjects ); + addObjectsToTree( myTreeRemoveObjects, removeObjects ); + + myTreeKeptObjects->collapseAll(); + myTreeRemoveObjects->collapseAll(); + +} + +//================================================================================= +// function : clickOnOk() +// purpose : called when OK button was clicked +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::clickOnOk() +{ + std::set objectsToBeRemoved = myRemovedObjects; + std::set objectsToBeUnpublished; + + // Create lists of intermediate objects to be removed or to be unpublished + std::set::iterator iter; + if( myGroupIntermediates->checkedId() == 1 ) { // unpublish + for( iter = myListParents.begin(); iter != myListParents.end(); ++iter ) + objectsToBeUnpublished.insert( *iter ); + } + if( myGroupIntermediates->checkedId() == 2 ) { // remove + if( !myCBSoftRemoval->isChecked() && + SUIT_MessageBox::question( this, + tr( "GEOM_WRN_WARNING" ), + tr( "GEOM_REDUCE_STUDY_WARNING_DELETE" ), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::Yes ) == QMessageBox::No ) { + return; + } + for( iter = myListParents.begin(); iter != myListParents.end(); ++iter ) + objectsToBeRemoved.insert( *iter ); + } + + // Create lists of sub-objects to be removed or to be unpublished + if( myGroupSubObjects->checkedId() == 1 ) { // unpublish + for( iter = myListSubObjects.begin(); iter != myListSubObjects.end(); ++iter ) + objectsToBeUnpublished.insert( *iter ); + } + else if( myGroupSubObjects->checkedId() == 2 ) { // remove + for( iter = myListSubObjects.begin(); iter != myListSubObjects.end(); ++iter ) + objectsToBeRemoved.insert( *iter ); + } + + // if user chosen the soft removal + if( myCBSoftRemoval->isChecked() ) { + for( iter = objectsToBeRemoved.begin(); iter != objectsToBeRemoved.end(); ++iter ) + objectsToBeUnpublished.insert( *iter ); + unpublishObjects( objectsToBeUnpublished ); + } + else { + unpublishObjects( objectsToBeUnpublished ); + removeObjects( objectsToBeRemoved ); + } + + // if user want to delete the empty folders + if( myCBRemoveEmptyFolder->isChecked() ) + removeEmptyFolders(); + + accept(); +} + +//================================================================================= +// function : clickOnHelp() +// purpose : called when Help button was clicked to open a help page +//================================================================================= +void GEOMToolsGUI_ReduceStudyDlg::clickOnHelp() +{ + myApp->onHelpContextModule( "GEOM", "reduce_study_page.html" ); +} + +GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidget* view, const QStringList &strings, + char* studyEntry, int type ) +:QTreeWidgetItem( view, strings, type ), + myStudyEntry( studyEntry ), + myVisible( false ) +{ +} + +GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem* parent, const QStringList &strings, + char* studyEntry, int type ) +:QTreeWidgetItem( parent, strings, type ), + myStudyEntry( studyEntry ), + myVisible( false ) +{ +} + +GEOMToolsGUI_TreeWidgetItem::~GEOMToolsGUI_TreeWidgetItem() +{ +} + +bool GEOMToolsGUI_TreeWidgetItem::isVisible() +{ + return myVisible; +} + +void GEOMToolsGUI_TreeWidgetItem::setVisible( bool theIsVisible, QIcon& theIcon ) +{ + myVisible = theIsVisible; + setIcon( 1, theIcon ); +} + +char* GEOMToolsGUI_TreeWidgetItem::getStudyEntry() const +{ + return myStudyEntry; +} diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.h new file mode 100644 index 000000000..ce69292e8 --- /dev/null +++ b/src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.h @@ -0,0 +1,127 @@ +// 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 GEOMTOOLSGUI_REDUCESTUDYDLG_H +#define GEOMTOOLSGUI_REDUCESTUDYDLG_H + +// internal includes +#include "GEOM_ToolsGUI.hxx" + +// GEOM includes +#include +#include +#include + +// Qt includes +#include +#include +#include +#include +#include + +// Cpp includes +#include + +class GEOMToolsGUI_TreeWidgetItem : public QTreeWidgetItem +{ + +public: + GEOMToolsGUI_TreeWidgetItem( QTreeWidget*, const QStringList&, char*, int = Type ); + GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem*, const QStringList&, char*, int = Type ); + ~GEOMToolsGUI_TreeWidgetItem(); + + bool isVisible(); + void setVisible( bool, QIcon& ); + + char* getStudyEntry() const; + +private: + bool myVisible; + char* myStudyEntry; + +}; + +class GEOMTOOLSGUI_EXPORT GEOMToolsGUI_ReduceStudyDlg : public QDialog +{ + Q_OBJECT + +public: + GEOMToolsGUI_ReduceStudyDlg( QWidget* ); + ~GEOMToolsGUI_ReduceStudyDlg(); + +private slots: + void onItemClicked(QTreeWidgetItem*, int ); + void onHeaderClicked( int ); + + void selectionChanged(); + + void update(); + + void clickOnOk(); + void clickOnHelp(); + +private: + void init( const std::set& theObjectEntries ); + std::set getSelectedObjects() const; + + void createTreeWidget( QTreeWidget* ); + QGroupBox* createButtonGroup( QButtonGroup* ); + + void addObjectsToTree( QTreeWidget*, std::set& ); + GEOMToolsGUI_TreeWidgetItem* addSubObject( QTreeWidget*, std::set&, GEOM::GEOM_Object_var ); + GEOMToolsGUI_TreeWidgetItem* findObjectInTree( QTreeWidget*, GEOM::GEOM_Object_var ); + + void checkVisibleIcon( QTreeWidget* ); + bool isObjectDrawable( std::string ); + + void unpublishObjects( std::set& ); + + void removeObjects( std::set& ); + void removeObject( std::string& ); + + void removeEmptyFolders(); + void getEmptyFolders( _PTR(SObject), std::set& ); + + QTreeWidget* myTreeKeptObjects; + QTreeWidget* myTreeRemoveObjects; + std::map myMapTreeSelectAll; + + QButtonGroup* myGroupIntermediates; + QButtonGroup* myGroupSubObjects; + + QCheckBox* myCBRemoveEmptyFolder; + QCheckBox* myCBSoftRemoval; + + std::set myMainEntries; + + std::set myKeptObjects; + std::set myRemovedObjects; + std::set myListParents; + std::set myListSubObjects; + + QIcon myVisible; + QIcon myInvisible; + + GEOM_Displayer myDisplayer; + SalomeApp_Application* myApp; + _PTR(Study) myStudy; + +}; + +#endif diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx index 66b43f728..2175e005b 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx @@ -31,7 +31,6 @@ #include #include -#include #include #include 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 468a7f883..44e55da79 100644 --- a/src/GEOMUtils/GEOMUtils.cxx +++ b/src/GEOMUtils/GEOMUtils.cxx @@ -87,6 +87,7 @@ #include #include +#include #include #include @@ -94,6 +95,235 @@ #define STD_SORT_ALGO 1 +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 : @@ -183,46 +413,6 @@ gp_Vec GEOMUtils::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() @@ -622,8 +812,9 @@ TopoDS_Shape GEOMUtils::GetEdgeNearPoint (const TopoDS_Shape& theShape, Standard_Boolean GEOMUtils::PreciseBoundingBox (const TopoDS_Shape &theShape, Bnd_Box &theBox) { - Standard_Real aBound[6]; + if ( theBox.IsVoid() ) BRepBndLib::Add( theShape, theBox ); + Standard_Real aBound[6]; theBox.Get(aBound[0], aBound[2], aBound[4], aBound[1], aBound[3], aBound[5]); Standard_Integer i; @@ -655,7 +846,7 @@ Standard_Boolean GEOMUtils::PreciseBoundingBox const Standard_Integer iHalf = i/2; const gp_Pln aPln(aPnt[i], aDir[iHalf]); BRepBuilderAPI_MakeFace aMkFace(aPln, -aPlnSize[iHalf], aPlnSize[iHalf], - -aPlnSize[iHalf], aPlnSize[iHalf]); + -aPlnSize[iHalf], aPlnSize[iHalf]); if (!aMkFace.IsDone()) { return Standard_False; @@ -693,8 +884,8 @@ double GEOMUtils::GetMinDistanceSingular(const TopoDS_Shape& aSh1, TopoDS_Shape tmpSh2; Standard_Real AddDist1 = 0.; Standard_Real AddDist2 = 0.; - Standard_Boolean IsChange1 = GEOMUtils::ModifyShape(aSh1, tmpSh1, AddDist1); - Standard_Boolean IsChange2 = GEOMUtils::ModifyShape(aSh2, tmpSh2, AddDist2); + Standard_Boolean IsChange1 = ModifyShape(aSh1, tmpSh1, AddDist1); + Standard_Boolean IsChange2 = ModifyShape(aSh2, tmpSh2, AddDist2); if( !IsChange1 && !IsChange2 ) return -2.0; @@ -844,109 +1035,46 @@ gp_Pnt GEOMUtils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView ) } //======================================================================= -// function : ModifyShape -// purpose : +// function : ConvertTreeToString() +// purpose : Returns the string representation of dependency tree //======================================================================= -Standard_Boolean GEOMUtils::ModifyShape(const TopoDS_Shape &theShape, - TopoDS_Shape &theModifiedShape, - Standard_Real &theAddDist) +void GEOMUtils::ConvertTreeToString( const TreeModel &tree, + std::string &treeStr ) { - 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(); + TreeModel::const_iterator i; + for ( i = tree.begin(); i != tree.end(); ++i ) { + treeStr.append( i->first ); + treeStr.append( "-" ); + std::vector upLevelList = i->second.first; + treeStr.append( "upward" ); + parseWard( upLevelList, treeStr ); + std::vector downLevelList = i->second.second; + treeStr.append( "downward" ); + parseWard( downLevelList, treeStr ); + } +} + +//======================================================================= +// function : ConvertStringToTree() +// purpose : Returns the dependency tree +//======================================================================= +void GEOMUtils::ConvertStringToTree( const std::string &theData, + TreeModel &tree ) +{ + std::size_t cursor = 0; + + while( theData.find('-',cursor) != std::string::npos ) //find next selected object + { + std::size_t objectIndex = theData.find( '-', cursor ); + std::string objectEntry = theData.substr( cursor, objectIndex - cursor ); + cursor = objectIndex; + + std::size_t upwardIndexBegin = theData.find("{",cursor) + 1; + std::size_t upwardIndexFinish = theData.find("}",upwardIndexBegin); + LevelsList upwardList = parseWard( theData, cursor ); + + LevelsList downwardList = parseWard( theData, cursor ); + + tree[objectEntry] = std::pair( upwardList, downwardList ); } - 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; } diff --git a/src/GEOMUtils/GEOMUtils.hxx b/src/GEOMUtils/GEOMUtils.hxx index bbf8a7dbe..95c0e7c0f 100644 --- a/src/GEOMUtils/GEOMUtils.hxx +++ b/src/GEOMUtils/GEOMUtils.hxx @@ -40,6 +40,11 @@ #include +#include +#include +#include +#include + class Bnd_Box; inline Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2) @@ -47,9 +52,14 @@ inline Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2) return S1.IsSame(S2); } -class GEOMUtils { +namespace GEOMUtils +{ + + typedef std::vector NodeLinks; + typedef std::map LevelInfo; + typedef std::vector LevelsList; + typedef std::map > TreeModel; - public: /*! * \brief Get Local Coordinate System, corresponding to the given shape. * @@ -57,7 +67,7 @@ class GEOMUtils { * Axes of the LCS are obtained from shape's location or, * if the shape is a planar face, from position of its plane. */ - Standard_EXPORT static gp_Ax3 GetPosition (const TopoDS_Shape& theShape); + Standard_EXPORT gp_Ax3 GetPosition (const TopoDS_Shape& theShape); /*! * \brief Get vector, defined by the given edge. @@ -67,8 +77,8 @@ class GEOMUtils { * the same edge can have different orientation depending on the way it was * extracted from a shape. */ - Standard_EXPORT static gp_Vec GetVector (const TopoDS_Shape& theShape, - Standard_Boolean doConsiderOrientation); + Standard_EXPORT gp_Vec GetVector (const TopoDS_Shape& theShape, + Standard_Boolean doConsiderOrientation); /*! * \brief Sort shapes in the list by their coordinates. @@ -89,8 +99,8 @@ class GEOMUtils { /*! * \brief Sort shapes by their centers of mass, using formula X*999 + Y*99 + Z*0.9 */ - Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL, - const Standard_Boolean isOldSorting = Standard_True); + Standard_EXPORT void SortShapes (TopTools_ListOfShape& SL, + const Standard_Boolean isOldSorting = Standard_True); /*! * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND. @@ -100,7 +110,7 @@ class GEOMUtils { * \param theCompsolid The compsolid to be converted. * \retval TopoDS_Shape Returns the resulting compound. */ - Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid); + Standard_EXPORT TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid); /*! * \brief Recursively extract all shapes from compounds and compsolids of the given shape into theList. @@ -110,22 +120,22 @@ class GEOMUtils { * \param theShape The shape to be exploded. * \param theList Output parameter. */ - Standard_EXPORT static void AddSimpleShapes (const TopoDS_Shape& theShape, - TopTools_ListOfShape& theList); + Standard_EXPORT void AddSimpleShapes (const TopoDS_Shape& theShape, + TopTools_ListOfShape& theList); /*! * \brief Build a triangulation on \a theShape if it is absent. * \param theShape The shape to check/build triangulation on. * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation. */ - Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape); - + 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. * \retval TopAbs_ShapeEnum Return type of shape for explode. */ - Standard_EXPORT static TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape); + Standard_EXPORT TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape); /*! * \brief Find an edge of theShape, closest to thePoint. @@ -134,8 +144,8 @@ class GEOMUtils { * \param thePoint The point near the required edge. * \retval TopoDS_Shape Returns the found edge or an empty shape if multiple edges found. */ - Standard_EXPORT static TopoDS_Shape GetEdgeNearPoint (const TopoDS_Shape& theShape, - const TopoDS_Vertex& thePoint); + Standard_EXPORT TopoDS_Shape GetEdgeNearPoint (const TopoDS_Shape& theShape, + const TopoDS_Vertex& thePoint); /*! * \brief Compute precise bounding box of the shape based on the rough bounding box. @@ -144,8 +154,7 @@ class 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 static 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 @@ -157,11 +166,10 @@ class 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 static 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. * @@ -171,11 +179,10 @@ class GEOMUtils { * \param thePnt2 the output result point on the second shape * \retval negative value in case of failure; otherwise the real distance. */ - Standard_EXPORT static 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. * @@ -184,23 +191,13 @@ class GEOMUtils { * \param theView View where the given point takes place. * \retval gp_Pnt Returns the point clicked in 3D view */ - Standard_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) theView ); + Standard_EXPORT gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) theView ); -private: - - /** - * 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. - */ - static Standard_Boolean ModifyShape(const TopoDS_Shape &theShape, - TopoDS_Shape &theModifiedShape, - Standard_Real &theAddDist); + Standard_EXPORT void ConvertTreeToString( const TreeModel &theTree, + std::string &DependencyStr ); + Standard_EXPORT void ConvertStringToTree( const std::string &theDependencyStr, + TreeModel &tree ); }; 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 { +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); -public: + /** + * Compute hatching domatins. + */ + Standard_EXPORT void Perform(); - /** - * Constructor. Initializes the object with the face. - */ - Standard_EXPORT GEOMUtils_Hatcher(const TopoDS_Face &theFace); + /** + * 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 initializes the hatcher with hatchings. - * - * \param theNbIsos the number of U- and V-isolines. - */ - Standard_EXPORT void Init(const Standard_Integer theNbIsos); + /** + * This method returns the initial face. + * + * \return the initial face. + */ + const TopoDS_Face &GetFace() const + { return myFace; } - /** - * 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 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 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); + /** + * 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; - /** - * Compute hatching domatins. - */ - Standard_EXPORT void Perform(); + /** + * 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 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 reference to OCCT hatcher. + * + * \return the reference to OCCT hatcher. + */ + Standard_EXPORT const Geom2dHatch_Hatcher &GetHatcher() const + { return myHatcher; } - /** - * This method returns the initial face. - * - * \return the initial face. - */ - const TopoDS_Face &GetFace() const - { return myFace; } + /** + * 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 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 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 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 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 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 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 the reference to OCCT hatcher. - * - * \return the reference to OCCT hatcher. - */ - Standard_EXPORT const Geom2dHatch_Hatcher &GetHatcher() const - { return myHatcher; } + /** + * 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; - /** - * 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; } + protected: - /** - * 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 clears all hatchings data. + */ + void Clear(); - /** - * 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; } + private: - /** - * 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; } + 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; - /** - * 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..a05371b1c --- /dev/null +++ b/src/GEOMUtils/GEOMUtils_XmlHandler.cxx @@ -0,0 +1,241 @@ +// 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 + +#ifdef WIN32 +#include +#else +#include +#endif + +//#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();//vsr: xmlCleanupParser should not be called from the application + } // 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..4617fe7f7 --- /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 +// + +#ifndef _GEOMUtils_XmlHandler_HXX_ +#define _GEOMUtils_XmlHandler_HXX_ + +#include + +#include +#include + +namespace GEOMUtils +{ + //! Plugin action data + struct Standard_EXPORT 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 Standard_EXPORT 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; + + Standard_EXPORT PluginInfo ReadPluginInfo(); +} + +#endif // _GEOMUtils_XmlHandler_HXX_ diff --git a/src/GEOM_I/CMakeLists.txt b/src/GEOM_I/CMakeLists.txt index fb2a677a7..d916ffe60 100755 --- a/src/GEOM_I/CMakeLists.txt +++ b/src/GEOM_I/CMakeLists.txt @@ -28,7 +28,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GEOMImpl ${PROJECT_SOURCE_DIR}/src/GEOM ${PROJECT_SOURCE_DIR}/src/GEOMAlgo - ${PROJECT_SOURCE_DIR}/src/XAO + ${PROJECT_SOURCE_DIR}/src/GEOMUtils ${PROJECT_BINARY_DIR}/idl ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_BINARY_DIR} @@ -44,6 +44,7 @@ ADD_DEFINITIONS( # libraries to link to SET(_link_LIBRARIES GEOMImpl + GEOMUtils SalomeIDLGEOM ${KERNEL_SALOMELocalTrace} ${KERNEL_SalomeGenericObj} @@ -55,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 4732c1f5a..e939d30f1 100755 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -36,7 +36,6 @@ #include "Utils_ExceptHandlers.hxx" #include "utilities.h" -#include "GEOM_Object_i.hh" #include "GEOM_Object.hxx" #include "GEOM_Function.hxx" #include "GEOM_ISubShape.hxx" @@ -45,6 +44,7 @@ #include "GEOMImpl_CopyDriver.hxx" #include "GEOMImpl_IInsertOperations.hxx" #include "GEOM_wrap.hxx" +#include "GEOMUtils_XmlHandler.hxx" // Cascade headers #include @@ -60,6 +60,9 @@ #include #include #include +#include +#include +#include #include #include @@ -119,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); + } + } } //============================================================================ @@ -301,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; @@ -2402,6 +2436,40 @@ GEOM::GEOM_IFieldOperations_ptr GEOM_Gen_i::GetIFieldOperations(CORBA::Long theS GEOM::GEOM_IOperations_ptr GEOM_Gen_i::GetPluginOperations(CORBA::Long theStudyID, const char* theLibName) throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetPluginOperations" ); + + GEOM::GEOM_Gen_ptr engine = _this(); + + GEOM::GEOM_IOperations_var operations; + + std::string aLibName = theLibName; + + try { + // load plugin library + LoadPlugin(aLibName); + // create a new operations object, store its ref. in engine + 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); + } + + 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 @@ -2412,63 +2480,39 @@ GEOM::GEOM_IOperations_ptr GEOM_Gen_i::GetPluginOperations(CORBA::Long theStudyI 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 + + // 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 - const char* anError = dlerror(); - throw(SALOME_Exception(anError)); + throw(SALOME_Exception(dlerror())); #else - throw(SALOME_Exception(LOCALIZED( "Can't load server geometry plugin library" ))); + 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; } - - // 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 + + // 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"))); + } } - 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(); } //============================================================================= @@ -2923,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; + GEOM::ListOfGBO_var aObjects = aInsOp->ImportFile(aFullPath.c_str(), "XAO"); - 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(); + 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_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()); + GEOM::GEOM_IInsertOperations_var aInsOp = GetIInsertOperations(aStudy->StudyId()); + if (aInsOp->_is_nil()) { + MESSAGE("No insert operations!"); + return aResult._retn(); + } - int aSeqLength = 0; // the sequence length + GEOM::GEOM_Object_var shapeObj; + for(; anIter->More(); anIter->Next()) { SALOMEDS::SObject_var aSO = anIter->Value(); SALOMEDS::SObject_var aRefSO; @@ -3004,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; } } @@ -3018,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"); @@ -3039,6 +3069,354 @@ Engines::ListOfData* GEOM_Gen_i::getModifiedData(CORBA::Long studyId) return aResult._retn(); } +//======================================================================= +// function : GetDependencyTree +// purpose : Collects dependencies of the given objects from other ones +//======================================================================= +SALOMEDS::TMPFile* GEOM_Gen_i::GetDependencyTree( SALOMEDS::Study_ptr theStudy, + const GEOM::string_array& theObjectEntries ) { + // fill in the tree structure + GEOMUtils::TreeModel tree; + + std::string entry; + for ( int i = 0; i < theObjectEntries.length(); i++ ) { + // process objects one-by-one + entry = theObjectEntries[i].in(); + GEOM::GEOM_BaseObject_var anObj = GetObject( theStudy->StudyId(), entry.c_str() ); + if ( anObj->_is_nil() ) + continue; + std::map< std::string, std::set > passedEntries; + GEOMUtils::LevelsList upLevelList; + // get objects from which current one depends on recursively + getUpwardDependency( anObj, upLevelList, passedEntries ); + GEOMUtils::LevelsList downLevelList; + // get objects that depends on current one recursively + getDownwardDependency( anObj, downLevelList, passedEntries ); + tree.insert( std::pair >(entry, std::pair( upLevelList, downLevelList ) ) ); + } + + // translation the tree into string + std::string treeStr; + GEOMUtils::ConvertTreeToString( tree, treeStr ); + + // put string into stream + char* aBuffer = (char*)CORBA::string_dup(treeStr.c_str()); + int aBufferSize = strlen((char*)aBuffer); + + CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; + + SALOMEDS::TMPFile_var aStream = new SALOMEDS::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1); + + return aStream._retn(); +} + +//======================================================================= +// function : getUpwardDependency +// purpose : Collects the entries of objects on that the given one depends +//======================================================================= +void GEOM_Gen_i::getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo, + GEOMUtils::LevelsList &upLevelList, + std::map< std::string, std::set > &passedEntries, + int level ) { + std::string aGboEntry = gbo->GetEntry(); + GEOMUtils::NodeLinks anEntries; + GEOMUtils::LevelInfo aLevelMap; + if ( level > 0 ) { + if ( level-1 >= upLevelList.size() ) { + // create a new map + upLevelList.push_back( aLevelMap ); + } else { + // get the existent map + aLevelMap = upLevelList.at(level-1); + if ( aLevelMap.count( aGboEntry ) > 0 ) { + anEntries = aLevelMap[ aGboEntry ]; + } + } + } + // get objects on that the current one depends + GEOM::ListOfGBO_var depList = gbo->GetDependency(); + std::string aDepEntry; + for( int j = 0; j < depList->length(); j++ ) { + if ( depList[j]->_is_nil() ) + continue; + aDepEntry = depList[j]->GetEntry(); + if ( passedEntries.count( aGboEntry ) > 0 && + passedEntries[aGboEntry].count( aDepEntry ) > 0 ) { + //avoid checking the passed objects + continue; + } + passedEntries[aGboEntry].insert( aDepEntry ); + if ( level > 0 ) { + anEntries.push_back( aDepEntry ); + } + // get dependencies recursively + getUpwardDependency(depList[j], upLevelList, passedEntries, level+1); + } + if ( level > 0 ) { + aLevelMap.insert( std::pair(aGboEntry, anEntries) ); + upLevelList[level-1] = aLevelMap; + } +} + +//======================================================================= +// function : getDownwardDependency +// purpose : Collects the entries of objects that depends on the given one +//======================================================================= +void GEOM_Gen_i::getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo, + GEOMUtils::LevelsList &downLevelList, + std::map< std::string, std::set > &passedEntries, + int level ) { + std::string aGboEntry = gbo->GetEntry(); + Handle(TDocStd_Document) aDoc = GEOM_Engine::GetEngine()->GetDocument(gbo->GetStudyID()); + Handle(TDataStd_TreeNode) aNode, aRoot; + Handle(GEOM_Function) aFunction; + if (aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) { + // go through the whole OCAF tree + TDataStd_ChildNodeIterator Itr( aRoot ); + for (; Itr.More(); Itr.Next()) { + aNode = Itr.Value(); + aFunction = GEOM_Function::GetFunction(aNode->Label()); + if (aFunction.IsNull()) { + continue; + } + TDF_Label aLabel = aFunction->GetOwnerEntry(); + if(aLabel.IsNull()) continue; + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aLabel, anEntry); + GEOM::GEOM_BaseObject_var geomObj = GetObject( gbo->GetStudyID(), anEntry.ToCString() ); + if( CORBA::is_nil( geomObj ) ) + continue; + // get dependencies for current object in the tree + GEOM::ListOfGBO_var depList = geomObj->GetDependency(); + if( depList->length() == 0 ) + continue; + std::string aGoEntry = geomObj->GetEntry(); + // go through dependencies of current object to check whether it depends on the given object + for( int i = 0; i < depList->length(); i++ ) { + if ( depList[i]->_is_nil() ) + continue; + if ( depList[i]->_is_equivalent( gbo ) ) { + // yes, the current object depends on the given object + if ( passedEntries.count( aGoEntry ) > 0 && + passedEntries[aGoEntry].count( aGboEntry ) > 0 ) { + //avoid checking the passed objects + continue; + } + passedEntries[aGoEntry].insert( aGboEntry ); + GEOMUtils::NodeLinks anEntries; + GEOMUtils::LevelInfo aLevelMap; + anEntries.push_back( aGboEntry ); + if ( level >= downLevelList.size() ) { + downLevelList.push_back( aLevelMap ); + } else { + aLevelMap = downLevelList.at(level); + if ( aLevelMap.count( aGoEntry ) > 0 ) { + anEntries = aLevelMap[ aGoEntry ]; + } + } + aLevelMap.insert( std::pair(aGoEntry, anEntries) ); + downLevelList[level] = aLevelMap; + // get dependencies of the current object recursively + getDownwardDependency(geomObj, downLevelList, passedEntries, level+1); + break; + } + } + } + } +} + +//============================================================================== +// function : GetEntriesToReduceStudy +// purpose : Fills 3 lists that is used to clean study of redundant objects +//============================================================================== +void GEOM_Gen_i::GetEntriesToReduceStudy(SALOMEDS::Study_ptr theStudy, + GEOM::string_array& theSelectedEntries, + GEOM::string_array& theParentEntries, + GEOM::string_array& theSubEntries, + GEOM::string_array& theOtherEntries) +{ + std::set aSelected, aParents, aChildren, anOthers; + for ( int i = 0; i < theSelectedEntries.length(); i++ ) { + aSelected.insert( CORBA::string_dup( theSelectedEntries[i] ) ); + } + + Handle(TDocStd_Document) aDoc = GEOM_Engine::GetEngine()->GetDocument(theStudy->StudyId()); + Handle(TDataStd_TreeNode) aNode, aRoot; + Handle(GEOM_Function) aFunction; + if (aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) { + // go through the whole OCAF tree + TDF_Label aLabel; + std::string anEntry; + TCollection_AsciiString anAsciiEntry; + TDataStd_ChildNodeIterator Itr( aRoot ); + for (; Itr.More(); Itr.Next()) { + aNode = Itr.Value(); + aFunction = GEOM_Function::GetFunction(aNode->Label()); + if (aFunction.IsNull()) { + continue; + } + aLabel = aFunction->GetOwnerEntry(); + if(aLabel.IsNull()) + continue; + TDF_Tool::Entry(aLabel, anAsciiEntry); + anEntry = anAsciiEntry.ToCString(); + GEOM::GEOM_BaseObject_var geomObj = GetObject( theStudy->StudyId(), anEntry.c_str() ); + if( CORBA::is_nil( geomObj ) ) + continue; + + if ( aSelected.count( anEntry ) > 0 && + aParents.count( anEntry ) == 0 ) { + includeParentDependencies( geomObj, aSelected, aParents, aChildren, anOthers ); + } else if ( aParents.count( anEntry ) == 0 && + aChildren.count( anEntry ) == 0 ) { + anOthers.insert( geomObj->GetEntry() ); + } + } + + std::set::iterator it; + std::set::iterator foundIt; + TCollection_AsciiString stringIOR; + GEOM::GEOM_Object_var geomObj; + + // filling list of sub-objects + for ( it = aSelected.begin(); it != aSelected.end(); ++it ) { + includeSubObjects( theStudy, *it, aSelected, aParents, aChildren, anOthers ); + } + + // if some selected object is not a main shape, + // we move it's main shapes into 'selected' list, + // because they could not be modified anyhow. + std::set aToBeInSelected; + for ( it = aSelected.begin(); it != aSelected.end(); ++it ) { + Handle(GEOM_BaseObject) handle_object = _impl->GetObject( theStudy->StudyId(), (*it).c_str(), false); + if ( handle_object.IsNull() ) + continue; + + stringIOR = handle_object->GetIOR(); + if ( !stringIOR.Length() > 1 ) + continue; + + geomObj = GetIORFromString( stringIOR.ToCString() ); + while ( !geomObj->IsMainShape() ) { + geomObj = geomObj->GetMainShape(); + anEntry = geomObj->GetEntry(); + + foundIt = aParents.find( anEntry ); + if ( foundIt != aParents.end() ) + aParents.erase( foundIt ); + + foundIt = aChildren.find( anEntry ); + if ( foundIt != aChildren.end() ) + aChildren.erase( foundIt ); + + foundIt = anOthers.find( anEntry ); + if ( foundIt != anOthers.end() ) + anOthers.erase( foundIt ); + + aToBeInSelected.insert( anEntry ); + } + } + aSelected.insert( aToBeInSelected.begin(), aToBeInSelected.end() ); + + // fill the CORBA arrays with values from sets + int i; + theSelectedEntries.length( aSelected.size() ); + for ( i = 0, it = aSelected.begin(); it != aSelected.end(); ++it, i++ ) + theSelectedEntries[i] = CORBA::string_dup( (*it).c_str() ); + theParentEntries.length( aParents.size() ); + for ( i = 0, it = aParents.begin(); it != aParents.end(); ++it, i++ ) + theParentEntries[i] = CORBA::string_dup( (*it).c_str() ); + theSubEntries.length( aChildren.size() ); + for ( i = 0, it = aChildren.begin(); it != aChildren.end(); ++it, i++ ) + theSubEntries[i] = CORBA::string_dup( (*it).c_str() ); + theOtherEntries.length( anOthers.size() ); + for ( i = 0, it = anOthers.begin(); it != anOthers.end(); ++it, i++ ) + theOtherEntries[i] = CORBA::string_dup( (*it).c_str() ); + } +} + +//============================================================================== +// function : includeParentDependencies +// purpose : +//============================================================================== +void GEOM_Gen_i::includeParentDependencies(GEOM::GEOM_BaseObject_ptr geomObj, + std::set& aSelected, + std::set& aParents, + std::set& aChildren, + std::set& anOthers) +{ + std::string anEntry = geomObj->GetEntry(); + if ( aSelected.count( anEntry ) == 0 ) { + aParents.insert( anEntry ); + std::set::iterator it; + it = aChildren.find( anEntry ); + if ( it != aChildren.end() ) + aChildren.erase( it ); + it = anOthers.find( anEntry ); + if ( it != anOthers.end() ) + anOthers.erase( it ); + } + // get dependencies for current object in the tree + GEOM::ListOfGBO_var depList = geomObj->GetDependency(); + if( depList->length() == 0 ) + return; + // go through dependencies of current object to check whether it depends on the given object + std::string aDepEntry; + for( int i = 0; i < depList->length(); i++ ) { + aDepEntry = depList[i]->GetEntry(); + if ( depList[i]->_is_nil() || + aDepEntry == anEntry || // skip self-depending + aSelected.count( aDepEntry ) > 0 || // skip selected objects + aParents.count( aDepEntry ) > 0 // skip already processed objects + ) + continue; + includeParentDependencies( depList[i], aSelected, aParents, aChildren, anOthers ); + } +} + +//============================================================================== +// function : includeSubObjects +// purpose : +//============================================================================== +void GEOM_Gen_i::includeSubObjects(SALOMEDS::Study_ptr theStudy, + const std::string& aSelectedEntry, + std::set& aSelected, + std::set& aParents, + std::set& aChildren, + std::set& anOthers) +{ + std::set::iterator foundIt; + Handle(GEOM_BaseObject) handle_object = _impl->GetObject( theStudy->StudyId(), aSelectedEntry.c_str(), false); + if ( handle_object.IsNull() ) + return; + + Handle(GEOM_Function) aShapeFun = handle_object->GetFunction(1); + if ( aShapeFun.IsNull() || !aShapeFun->HasSubShapeReferences() ) + return; + + const TDataStd_ListOfExtendedString& aListEntries = aShapeFun->GetSubShapeReferences(); + if ( aListEntries.IsEmpty() ) + return; + + TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries); + for ( ; anIt.More(); anIt.Next() ) { + TCollection_ExtendedString aSubEntry = anIt.Value(); + Standard_Integer aStrLen = aSubEntry.LengthOfCString(); + char* aSubEntryStr = new char[aStrLen+1]; + aSubEntry.ToUTF8CString( aSubEntryStr ); + foundIt = aParents.find( aSubEntryStr ); + if ( foundIt == aParents.end() ) { // add to sub-objects if it is not in parents list + foundIt = aSelected.find( aSubEntryStr ); + if ( foundIt == aSelected.end() ) { // add to sub-objects if it is not in selected list + aChildren.insert( aSubEntryStr ); + foundIt = anOthers.find( aSubEntryStr ); + if ( foundIt != anOthers.end() ) + anOthers.erase( foundIt ); + } + } + includeSubObjects( theStudy, aSubEntryStr, aSelected, aParents, aChildren, anOthers ); + } +} //===================================================================================== // EXPORTED METHODS //===================================================================================== diff --git a/src/GEOM_I/GEOM_Gen_i.hh b/src/GEOM_I/GEOM_Gen_i.hh index 81771124b..5af305551 100644 --- a/src/GEOM_I/GEOM_Gen_i.hh +++ b/src/GEOM_I/GEOM_Gen_i.hh @@ -51,11 +51,13 @@ #include "GEOM_IMeasureOperations_i.hh" #include "GEOM_IGroupOperations_i.hh" #include "GEOM_IFieldOperations_i.hh" +#include "GEOMUtils.hxx" #include #include #include +#include #include //#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -197,6 +199,10 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi CORBA::Boolean theInheritFirstArg, CORBA::Boolean theAddPrefix); + //Collects dependencies of the given objects from other ones + SALOMEDS::TMPFile* GetDependencyTree(SALOMEDS::Study_ptr theStudy, + const GEOM::string_array& theObjectEntries); + //-----------------------------------------------------------------------// // Transaction methods // //-----------------------------------------------------------------------// @@ -318,6 +324,15 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi // SIMAN-related functions (check out/check in) : get modified data virtual Engines::ListOfData* getModifiedData(CORBA::Long studyId); + /*! \brief Fills 3 lists that is used to clean study of redundant objects. + * To be used from GUI. + */ + void GetEntriesToReduceStudy(SALOMEDS::Study_ptr theStudy, + GEOM::string_array& theSelectedEntries, + GEOM::string_array& theParentEntries, + GEOM::string_array& theSubEntries, + GEOM::string_array& theOtherEntries); + //-----------------------------------------------------------------------// // Internal methods // //-----------------------------------------------------------------------// @@ -366,6 +381,31 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi const Standard_CString& GrName, GEOM::ListOfGO_var aResList); + void getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo, + GEOMUtils::LevelsList &upLevelList, + std::map< std::string, std::set > &passedEntries, + int level = 0 ); + + void getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo, + GEOMUtils::LevelsList &downLevelList, + std::map< std::string, std::set > &passedEntries, + int level = 0 ); + + void includeParentDependencies(GEOM::GEOM_BaseObject_ptr gbo, + std::set& aSelected, + std::set& aParents, + std::set& aChildren, + std::set& anOthers); + + void includeSubObjects(SALOMEDS::Study_ptr theStudy, + const std::string& aSelectedEntry, + std::set& aSelected, + std::set& aParents, + std::set& aChildren, + std::set& anOthers); + + void LoadPlugin(const std::string& theLibName); + private: ::GEOMImpl_Gen* _impl; diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index 2d1960361..ef874e824 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -261,6 +261,28 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double th return GetObject(anObject); } +//============================================================================= +/*! + * MakeCylinderRHA + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRHA (CORBA::Double theR, + CORBA::Double theH, + CORBA::Double theA) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the Cylinder + Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderRHA(theR, theH, theA); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeCylinderPntVecRH @@ -289,6 +311,34 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH return GetObject(anObject); } +//============================================================================= +/*! + * MakeCylinderPntVecRHA + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRHA + (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec, + CORBA::Double theR, CORBA::Double theH, CORBA::Double theA) +{ + 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(); + + //Create the Cylinder + Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderPntVecRHA(aPnt, aVec, theR, theH, theA); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeConeR1R2H diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh index a47518821..56c1cbc7b 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -75,6 +75,16 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : GEOM::GEOM_Object_ptr theVec, CORBA::Double theR, CORBA::Double theH); + + GEOM::GEOM_Object_ptr MakeCylinderRHA (CORBA::Double theR, + CORBA::Double theH, + CORBA::Double theA); + + GEOM::GEOM_Object_ptr MakeCylinderPntVecRHA (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theR, + CORBA::Double theH, + CORBA::Double theA); GEOM::GEOM_Object_ptr MakeConeR1R2H (CORBA::Double theR1, CORBA::Double theR2, diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.cc b/src/GEOM_I/GEOM_ICurvesOperations_i.cc index f1d2469c0..06d9b66d3 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.cc +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.cc @@ -30,6 +30,9 @@ #include "GEOM_Engine.hxx" #include "GEOM_Object.hxx" +#include +#include + //============================================================================= /*! * constructor: @@ -667,3 +670,189 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher return GetObject(anObject); } + +//============================================================================= +/*! + * MakePolyline2D + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline2D + (const GEOM::ListOfListOfDouble &theCoordsList, + const GEOM::string_array &theNamesList, + const GEOM::short_array &theTypesList, + const GEOM::ListOfBool &theClosedList, + const GEOM::ListOfDouble &theWorkingPlane) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + // Convert input data + Handle(TColStd_HArray1OfExtendedString) aNames = + ConvertStringArray(theNamesList); + Handle(TColStd_HArray1OfByte) aTypes = + ConvertEnumArray(theTypesList); + Handle(TColStd_HArray1OfByte) aCloseds = + ConvertBoolArray(theClosedList); + std::list > aCoords; + + ConvertListListDouble(theCoordsList, aCoords); + + Handle(TColStd_HArray1OfReal) aWorkingPlane; + const int n = theWorkingPlane.length(); + int i; + + if (n > 0) { + aWorkingPlane = new TColStd_HArray1OfReal(1, n); + + for (i = 0; i < n; i++) { + aWorkingPlane->SetValue(i + 1, theWorkingPlane[i]); + } + } + + // Make Polyline + Handle(GEOM_Object) anObject = GetOperations()->MakePolyline2D + (aCoords, aNames, aTypes, aCloseds, aWorkingPlane); + + if (!GetOperations()->IsDone() || anObject.IsNull()) { + return GEOM::GEOM_Object::_nil(); + } + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePolylineOnPlane + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline2DOnPlane + (const GEOM::ListOfListOfDouble &theCoordsList, + const GEOM::string_array &theNamesList, + const GEOM::short_array &theTypesList, + const GEOM::ListOfBool &theClosedList, + GEOM::GEOM_Object_ptr theWorkingPlane) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + // Convert input data + Handle(TColStd_HArray1OfExtendedString) aNames = + ConvertStringArray(theNamesList); + Handle(TColStd_HArray1OfByte) aTypes = + ConvertEnumArray(theTypesList); + Handle(TColStd_HArray1OfByte) aCloseds = + ConvertBoolArray(theClosedList); + std::list > aCoords; + Handle(GEOM_Object) aWorkingPlane = + GetObjectImpl(theWorkingPlane); + + ConvertListListDouble(theCoordsList, aCoords); + + // Make Polyline + Handle(GEOM_Object) anObject = GetOperations()->MakePolyline2DOnPlane + (aCoords, aNames, aTypes, aCloseds, aWorkingPlane); + + if (!GetOperations()->IsDone() || anObject.IsNull()) { + return GEOM::GEOM_Object::_nil(); + } + + return GetObject(anObject); +} + +//============================================================================= +/*! + * ConvertEnumArray + */ +//============================================================================= +Handle(TColStd_HArray1OfByte) GEOM_ICurvesOperations_i::ConvertEnumArray + (const GEOM::short_array &theInArray) +{ + Handle(TColStd_HArray1OfByte) anOutArray; + const int n = theInArray.length(); + int i; + + if (n <= 0) { + return anOutArray; + } + + anOutArray = new TColStd_HArray1OfByte(1, n); + + for (i = 0; i < n; i++) { + bool isOK = true; + GEOMImpl_ICurvesOperations::CurveType aType; + + switch(theInArray[i]) { + case GEOM::Polyline: + aType = GEOMImpl_ICurvesOperations::Polyline; + break; + case GEOM::Bezier: + aType = GEOMImpl_ICurvesOperations::Bezier; + break; + case GEOM::Interpolation: + aType = GEOMImpl_ICurvesOperations::Interpolation; + break; + default: + isOK = false; + break; + } + + if (isOK) { + anOutArray->SetValue(i + 1, aType); + } else { + anOutArray.Nullify(); + break; + } + } + + return anOutArray; +} + +//============================================================================= +/*! + * ConvertBoolArray + */ +//============================================================================= +Handle(TColStd_HArray1OfByte) GEOM_ICurvesOperations_i::ConvertBoolArray + (const GEOM::ListOfBool &theInArray) +{ + Handle(TColStd_HArray1OfByte) anOutArray; + const int n = theInArray.length(); + int i; + + if (n <= 0) { + return anOutArray; + } + + anOutArray = new TColStd_HArray1OfByte(1, n); + + for (i = 0; i < n; i++) { + anOutArray->SetValue(i + 1, theInArray[i]); + } + + return anOutArray; +} + +//============================================================================= +/*! + * ConvertListListDouble + */ +//============================================================================= +void GEOM_ICurvesOperations_i::ConvertListListDouble + (const GEOM::ListOfListOfDouble &theInList, + std::list > &theOutList) +{ + const int n = theInList.length(); + int i; + std::list anEmptyList; + + for (i = 0; i < n; i++) { + theOutList.push_back(anEmptyList); + + const int m = theInList[i].length(); + int j; + + for (j = 0; j < m; j++) { + theOutList.back().push_back(theInList[i][j]); + } + } +} diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.hh b/src/GEOM_I/GEOM_ICurvesOperations_i.hh index c08cb0156..90cbb2114 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.hh +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.hh @@ -112,8 +112,35 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i : GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates); + GEOM::GEOM_Object_ptr MakePolyline2D + (const GEOM::ListOfListOfDouble &theCoordsList, + const GEOM::string_array &theNamesList, + const GEOM::short_array &theTypesList, + const GEOM::ListOfBool &theClosedList, + const GEOM::ListOfDouble &theWorkingPlane); + + GEOM::GEOM_Object_ptr MakePolyline2DOnPlane + (const GEOM::ListOfListOfDouble &theCoordsList, + const GEOM::string_array &theNamesList, + const GEOM::short_array &theTypesList, + const GEOM::ListOfBool &theClosedList, + GEOM::GEOM_Object_ptr theWorkingPlane); + ::GEOMImpl_ICurvesOperations* GetOperations() { return (::GEOMImpl_ICurvesOperations*)GetImpl(); } + +private: + + Handle(TColStd_HArray1OfByte) + ConvertEnumArray(const GEOM::short_array &theInArray); + + Handle(TColStd_HArray1OfByte) + ConvertBoolArray(const GEOM::ListOfBool &theInArray); + + void ConvertListListDouble + (const GEOM::ListOfListOfDouble &theCoordsList, + std::list > &theCoords); + }; #endif diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.cc b/src/GEOM_I/GEOM_IHealingOperations_i.cc index af7cb5cd4..51fe6c46e 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.cc +++ b/src/GEOM_I/GEOM_IHealingOperations_i.cc @@ -78,25 +78,6 @@ Handle(TColStd_HArray1OfInteger) GEOM_IHealingOperations_i::Convert return anOutArray; } -//============================================================================= -/*! - * Convert - */ -//============================================================================= -Handle(TColStd_HArray1OfExtendedString) GEOM_IHealingOperations_i::Convert - (const GEOM::string_array& theInArray) -{ - Handle(TColStd_HArray1OfExtendedString) anOutArray; - int n = theInArray.length(); - if ( n <= 0 ) - return anOutArray; - anOutArray = new TColStd_HArray1OfExtendedString( 1, n ); - for ( int i = 0; i < n; i++ ) - anOutArray->SetValue( i+1, TCollection_ExtendedString( theInArray[i].in() ) ); - - return anOutArray; -} - //============================================================================= /*! * ProcessShape @@ -125,7 +106,8 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::ProcessShape (GEOM::GEOM_Object // Perform Handle(GEOM_Object) aNewObject = GetOperations()->ShapeProcess( anObject, - Convert( theOperations ), Convert( theParams ), Convert( theValues ) ); + ConvertStringArray( theOperations ), ConvertStringArray( theParams ), + ConvertStringArray( theValues ) ); if ( !GetOperations()->IsDone() || aNewObject.IsNull() ) return aGEOMObject._retn(); diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.hh b/src/GEOM_I/GEOM_IHealingOperations_i.hh index 8b30c9530..091358771 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.hh +++ b/src/GEOM_I/GEOM_IHealingOperations_i.hh @@ -33,9 +33,6 @@ #include "GEOMImpl_IHealingOperations.hxx" -#include -#include - class GEOM_I_EXPORT GEOM_IHealingOperations_i : public virtual POA_GEOM::GEOM_IHealingOperations, public virtual GEOM_IOperations_i @@ -101,7 +98,6 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i : ::GEOMImpl_IHealingOperations* GetOperations() { return (::GEOMImpl_IHealingOperations*)GetImpl(); } private: - Handle(TColStd_HArray1OfExtendedString) Convert( const GEOM::string_array& ); Handle(TColStd_HArray1OfInteger) Convert( const GEOM::short_array& ); }; diff --git a/src/GEOM_I/GEOM_IInsertOperations_i.cc b/src/GEOM_I/GEOM_IInsertOperations_i.cc index 3d8f79751..ab79c87b6 100644 --- a/src/GEOM_I/GEOM_IInsertOperations_i.cc +++ b/src/GEOM_I/GEOM_IInsertOperations_i.cc @@ -33,17 +33,13 @@ #include "Utils_ExceptHandlers.hxx" #include "GEOM_Engine.hxx" -#include "GEOM_Object.hxx" +#include "GEOM_BaseObject.hxx" #include #include -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #include -#else -#include -#endif //============================================================================= /*! @@ -113,11 +109,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); } //============================================================================= @@ -125,28 +117,17 @@ void GEOM_IInsertOperations_i::Export * ImportFile */ //============================================================================= -GEOM::ListOfGO* GEOM_IInsertOperations_i::ImportFile +GEOM::ListOfGBO* GEOM_IInsertOperations_i::ImportFile (const char* theFileName, const char* theFormatName) { - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + GEOM::ListOfGBO_var aSeq = new GEOM::ListOfGBO; //Set a not done flag 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 +137,8 @@ GEOM::ListOfGO* GEOM_IInsertOperations_i::ImportFile 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))); - } + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetBaseObject(Handle(GEOM_BaseObject)::DownCast(aHSeq->Value(i))); return aSeq._retn(); } @@ -176,90 +155,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 @@ -306,18 +207,10 @@ CORBA::Long GEOM_IInsertOperations_i::AddTexture(CORBA::Long theWidth, CORBA::Lo { GetOperations()->SetNotDone(); -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) aTexture; -#else - Handle(TDataStd_HArray1OfByte) aTexture; -#endif if ( theTexture.length() > 0 ) { -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 aTexture = new TColStd_HArray1OfByte (1, theTexture.length()); -#else - aTexture = new TDataStd_HArray1OfByte (1, theTexture.length()); -#endif for ( int i = 0; i < theTexture.length(); i++ ) aTexture->SetValue( i+1, (Standard_Byte)theTexture[i] ); @@ -335,11 +228,7 @@ SALOMEDS::TMPFile* GEOM_IInsertOperations_i::GetTexture(CORBA::Long theID, CORBA::Long& theHeight) { int aWidth, aHeight; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 Handle(TColStd_HArray1OfByte) aTextureImpl = -#else - Handle(TDataStd_HArray1OfByte) aTextureImpl = -#endif GetOperations()->GetTexture(theID, aWidth, aHeight); theWidth = aWidth; theHeight = aHeight; @@ -370,121 +259,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..4a2b4f2cc 100644 --- a/src/GEOM_I/GEOM_IInsertOperations_i.hh +++ b/src/GEOM_I/GEOM_IInsertOperations_i.hh @@ -49,19 +49,13 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i : const char* theFileName, const char* theFormatName); - GEOM::ListOfGO* ImportFile (const char* theFileName, - const char* theFormatName); + GEOM::ListOfGBO* ImportFile (const char* theFileName, + const char* theFormatName); char* ReadValue (const char* theFileName, 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_IOperations_i.cc b/src/GEOM_I/GEOM_IOperations_i.cc index 12184fd17..9cb5b8469 100644 --- a/src/GEOM_I/GEOM_IOperations_i.cc +++ b/src/GEOM_I/GEOM_IOperations_i.cc @@ -237,3 +237,28 @@ void GEOM_IOperations_i::UpdateGUIForObject(GEOM::GEOM_Object_ptr theObj) } } } + +//============================================================================= +/*! + * ConvertStringArray + */ +//============================================================================= +Handle(TColStd_HArray1OfExtendedString) GEOM_IOperations_i::ConvertStringArray + (const GEOM::string_array &theInArray) +{ + Handle(TColStd_HArray1OfExtendedString) anOutArray; + const int n = theInArray.length(); + int i; + + if (n <= 0) { + return anOutArray; + } + + anOutArray = new TColStd_HArray1OfExtendedString( 1, n ); + + for (i = 0; i < n; i++) { + anOutArray->SetValue(i + 1, TCollection_ExtendedString(theInArray[i].in())); + } + + return anOutArray; +} diff --git a/src/GEOM_I/GEOM_IOperations_i.hh b/src/GEOM_I/GEOM_IOperations_i.hh index 1d5b7fd56..b82b36c68 100644 --- a/src/GEOM_I/GEOM_IOperations_i.hh +++ b/src/GEOM_I/GEOM_IOperations_i.hh @@ -52,9 +52,6 @@ class GEOM_I_EXPORT GEOM_IOperations_i : public virtual POA_GEOM::GEOM_IOperatio virtual GEOM::GEOM_Object_ptr GetObject(Handle(GEOM_Object) theObject); virtual Handle(GEOM_Object) GetObjectImpl(GEOM::GEOM_Object_ptr theObject); - virtual Handle(TColStd_HSequenceOfTransient) - GetListOfObjectsImpl(const GEOM::ListOfGO& theObjects); - virtual void StartOperation(); virtual void FinishOperation(); @@ -66,6 +63,14 @@ class GEOM_I_EXPORT GEOM_IOperations_i : public virtual POA_GEOM::GEOM_IOperatio virtual void UpdateGUIForObject(GEOM::GEOM_Object_ptr theObj); +protected: + + Handle(TColStd_HSequenceOfTransient) + GetListOfObjectsImpl(const GEOM::ListOfGO& theObjects); + + Handle(TColStd_HArray1OfExtendedString) + ConvertStringArray(const GEOM::string_array &theInArray); + private: ::GEOM_IOperations* _impl; 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 792cbe5ae..867a5c6f7 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")); } } @@ -1073,6 +1168,38 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderRH (CORBA::Double theR, return anObj; } +//============================================================================= +// MakeCylinderPntVecRHA: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderPntVecRHA (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theRadius, + CORBA::Double theHeight, + CORBA::Double theAngle) +{ + beginService( " GEOM_Superv_i::MakeCylinderPntVecRHA" ); + MESSAGE("GEOM_Superv_i::MakeCylinderPntVecRHA"); + get3DPrimOp(); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeCylinderPntVecRHA(thePnt, theAxis, theRadius, theHeight, theAngle); + endService( " GEOM_Superv_i::MakeCylinderPntVecRHA" ); + return anObj; +} + +//============================================================================= +// MakeCylinderRHA: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderRHA (CORBA::Double theR, + CORBA::Double theH, + CORBA::Double theA) +{ + beginService( " GEOM_Superv_i::MakeCylinderRHA" ); + MESSAGE("GEOM_Superv_i::MakeCylinderRHA"); + get3DPrimOp(); + GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeCylinderRHA(theR, theH, theA); + endService( " GEOM_Superv_i::MakeCylinderRHA" ); + return anObj; +} + //============================================================================= // MakeSphere: //============================================================================= @@ -1588,41 +1715,15 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::ImportFile (const char* theFileName, beginService( " GEOM_Superv_i::ImportFile" ); MESSAGE("GEOM_Superv_i::ImportFile"); getInsOp(); - GEOM::ListOfGO* aSeq = myInsOp->ImportFile(theFileName, theFormatName); - GEOM::GEOM_Object_ptr anObj; + GEOM::ListOfGBO_var aSeq = myInsOp->ImportFile(theFileName, theFormatName); + GEOM::GEOM_Object_var anObj; if (aSeq->length() > 0) { - anObj = aSeq->operator[](0); + anObj = GEOM::GEOM_Object::_narrow(aSeq[0]); } endService( " GEOM_Superv_i::ImportFile" ); - 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" ); + return anObj._retn(); } //============================= TransformOperations =========================== @@ -3335,30 +3436,183 @@ GEOM::GEOM_List_ptr GEOM_Superv_i::GetObjects (GEOM::GEOM_Object_ptr theGroup) return aListPtr->_this(); } +//=============================== Import/Export Operations ============================= //============================================================================= -// ExportXAO +// Export STL //============================================================================= -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) +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" ); +} + +//============================================================================= +// Import IGES +//============================================================================= +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 8058cc132..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); @@ -246,6 +259,14 @@ public: CORBA::Double theHeight); GEOM::GEOM_Object_ptr MakeCylinderRH (CORBA::Double theR, CORBA::Double theH); + GEOM::GEOM_Object_ptr MakeCylinderPntVecRHA (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theRadius, + CORBA::Double theHeight, + CORBA::Double theAngle); + GEOM::GEOM_Object_ptr MakeCylinderRHA (CORBA::Double theR, + CORBA::Double theH, + CORBA::Double theA); GEOM::GEOM_Object_ptr MakeSphere (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ, @@ -361,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 // @@ -691,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 // @@ -746,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/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 28635865c..b644c196b 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -147,18 +147,20 @@ def TestAll (geompy, math): tan_on_face = geompy.MakeTangentPlaneOnFace(tan_extrusion, 0.7, 0.5, 150) #Create base geometry 3D - Box = geompy.MakeBoxTwoPnt(p0, p200) #(2 GEOM_Object)->GEOM_Object - Box1 = geompy.MakeBoxDXDYDZ(10, 20, 30) #(3 Doubles)->GEOM_Object - Box2 = geompy.MakeBox(10,20,30, 15,25,35) #(6 Doubles)->GEOM_Object - Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(2 GEOM_Object, 2 Doubles)->GEOM_Object - Cyl1 = geompy.MakeCylinderRH(radius2, height) #(2 Doubles)->GEOM_Object - Sphere = geompy.MakeSpherePntR(p0, radius1) #(GEOM_Object, Double)->GEOM_Object - Sphere1 = geompy.MakeSphereR(radius) #(Double)->GEOM_Object - Sphere2 = geompy.MakeSphere(50, 70, 30, radius) #(4 Doubles)->GEOM_Object - Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(2 GEOM_Object, 3 Doubles)->GEOM_Object - Cone1 = geompy.MakeConeR1R2H(radius1, radius, height) #(3 Doubles)->GEOM_Object - Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(2 GEOM_Object, 2 Doubles)->GEOM_Object - Torus1 = geompy.MakeTorusRR(radius2, radius1) #(2 Doubles)->GEOM_Object + Box = geompy.MakeBoxTwoPnt(p0, p200) #(2 GEOM_Object)->GEOM_Object + Box1 = geompy.MakeBoxDXDYDZ(10, 20, 30) #(3 Doubles)->GEOM_Object + Box2 = geompy.MakeBox(10,20,30, 15,25,35) #(6 Doubles)->GEOM_Object + Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(2 GEOM_Object, 2 Doubles)->GEOM_Object + Cyl1 = geompy.MakeCylinderRH(radius2, height) #(2 Doubles)->GEOM_Object + Cylinder1= geompy.MakeCylinderA(p0, vz, radius1, height, angle1) #(2 GEOM_Object, 3 Doubles)->GEOM_Object + Cyl2 = geompy.MakeCylinderRHA(radius2, height, angle2) #(3 Doubles)->GEOM_Object + Sphere = geompy.MakeSpherePntR(p0, radius1) #(GEOM_Object, Double)->GEOM_Object + Sphere1 = geompy.MakeSphereR(radius) #(Double)->GEOM_Object + Sphere2 = geompy.MakeSphere(50, 70, 30, radius) #(4 Doubles)->GEOM_Object + Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(2 GEOM_Object, 3 Doubles)->GEOM_Object + Cone1 = geompy.MakeConeR1R2H(radius1, radius, height) #(3 Doubles)->GEOM_Object + Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(2 GEOM_Object, 2 Doubles)->GEOM_Object + Torus1 = geompy.MakeTorusRR(radius2, radius1) #(2 Doubles)->GEOM_Object #Boolean (Common, Cut, Fuse, Section) Common = geompy.MakeBoolean(Box, Sphere, 1) #(2 GEOM_Object, Short)->GEOM_Object @@ -372,6 +374,8 @@ def TestAll (geompy, math): id_Box2 = geompy.addToStudy(Box2, "Box (10,20,30)-(15,25,35)") id_Cylinder = geompy.addToStudy(Cylinder, "Cylinder") id_Cyl1 = geompy.addToStudy(Cyl1, "Cylinder RH") + id_Cylinder1= geompy.addToStudy(Cylinder1,"CylinderA") + id_Cyl2 = geompy.addToStudy(Cyl2, "Cylinder RHA") id_Sphere = geompy.addToStudy(Sphere, "Sphere Pnt R") id_Sphere1 = geompy.addToStudy(Sphere1, "Sphere R") id_Sphere2 = geompy.addToStudy(Sphere2, "Sphere") diff --git a/src/GEOM_SWIG/GEOM_example3.py b/src/GEOM_SWIG/GEOM_example3.py index 5f79ccd14..b2432f339 100644 --- a/src/GEOM_SWIG/GEOM_example3.py +++ b/src/GEOM_SWIG/GEOM_example3.py @@ -113,6 +113,7 @@ if not isinstance(gg, type(salome_ComponentGUI)): gg.setDisplayMode(id_torus1,1) gg.setDisplayMode(id_torus2,1) gg.setVectorsMode(id_acyl,1,1) + gg.setVerticesMode(id_acyl,1,1) #gg.setDisplayMode(id_cage,1) gg.setColor(id_torus1,0,0,255) 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 38255ac1b..27b194dc2 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -39,16 +39,16 @@ ## by means of \ref geomBuilder.geomBuilder.addToStudy() "addToStudy()" ## or \ref geomBuilder.geomBuilder.addToStudyInFather() "addToStudyInFather()" ## functions. -## +## ## However, it is possible to publish result data in the study ## automatically. For this, almost each function of ## \ref geomBuilder.geomBuilder "geomBuilder" class has ## an additional @a theName parameter (@c None by default). ## As soon as non-empty string value is passed to this parameter, ## the result object is published in the study automatically. -## +## ## For example, consider the following Python script: -## +## ## @code ## import salome ## from salome.geom import geomBuilder @@ -56,15 +56,15 @@ ## box = geompy.MakeBoxDXDYDZ(100, 100, 100) # box is not published in the study yet ## geompy.addToStudy(box, "box") # explicit publishing ## @endcode -## +## ## Last two lines can be replaced by one-line instruction: -## +## ## @code ## box = geompy.MakeBoxDXDYDZ(100, 100, 100, theName="box") # box is published in the study with "box" name ## @endcode -## +## ## ... or simply -## +## ## @code ## box = geompy.MakeBoxDXDYDZ(100, 100, 100, "box") # box is published in the study with "box" name ## @endcode @@ -102,8 +102,8 @@ ## value passed as parameter has the same effect. ## - if @a maxNbSubShapes is any positive value, automatic publishing is enabled and ## maximum number of sub-shapes allowed for publishing is set to specified value. -## -## When automatic publishing is enabled, you even do not need to pass @a theName parameter +## +## When automatic publishing is enabled, you even do not need to pass @a theName parameter ## to the functions creating objects, instead default names will be used. However, you ## can always change the behavior, by passing explicit name to the @a theName parameter ## and it will be used instead default one. @@ -117,7 +117,7 @@ ## from salome.geom import geomBuilder ## geompy = geomBuilder.New(salome.myStudy) ## geompy.addToStudyAuto() # enable automatic publication -## box = geompy.MakeBoxDXDYDZ(100, 100, 100) +## box = geompy.MakeBoxDXDYDZ(100, 100, 100) ## # the box is created and published in the study with default name ## geompy.addToStudyAuto(5) # set max allowed number of sub-shapes to 5 ## vertices = geompy.SubShapeAll(box, geomBuilder.ShapeType['VERTEX']) @@ -146,44 +146,44 @@ ## ## It is possible to customize the representation of the geometrical ## data in the data tree; this can be done by using folders. A folder can -## be created in the study tree using function -## \ref geomBuilder.geomBuilder.NewFolder() "NewFolder()" -## (by default it is created under the "Geometry" root object). -## As soon as folder is created, any published geometry object +## be created in the study tree using function +## \ref geomBuilder.geomBuilder.NewFolder() "NewFolder()" +## (by default it is created under the "Geometry" root object). +## As soon as folder is created, any published geometry object ## can be moved into it. -## +## ## For example: -## +## ## @code ## import salome ## from salome.geom import geomBuilder ## geompy = geomBuilder.New(salome.myStudy) -## box = geompy.MakeBoxDXDYDZ(100, 100, 100, "Box") +## box = geompy.MakeBoxDXDYDZ(100, 100, 100, "Box") ## # the box was created and published in the study ## folder = geompy.NewFolder("Primitives") ## # an empty "Primitives" folder was created under default "Geometry" root object ## geompy.PutToFolder(box, folder) ## # the box was moved into "Primitives" folder ## @endcode -## +## ## Subfolders are also can be created by specifying another folder as a parent: -## +## ## @code ## subfolder = geompy.NewFolder("3D", folder) ## # "3D" folder was created under "Primitives" folder ## @endcode -## +## ## @note ## - Folder container is just a representation layer object that -## deals with already published objects only. So, any geometry object -## should be published in the study (for example, with +## deals with already published objects only. So, any geometry object +## should be published in the study (for example, with ## \ref geomBuilder.geomBuilder.PutToFolder() "addToStudy()" function) ## BEFORE moving it into any existing folder. ## - \ref geomBuilder.geomBuilder.PutToFolder() "PutToFolder()" function ## does not change physical position of geometry object in the study tree, ## it only affects on the representation of the data tree. ## - It is impossible to publish geometry object using any folder as father. -## +## ## \defgroup l1_publish_data ## \defgroup l1_geomBuilder_auxiliary ## \defgroup l1_geomBuilder_purpose @@ -254,8 +254,9 @@ from salome_notebook import * import GEOM import math import os +import functools -from salome.geom.gsketcher import Sketcher3D, Sketcher2D +from salome.geom.gsketcher import Sketcher3D, Sketcher2D, Polyline2D # service function def _toListOfNames(_names, _size=-1): @@ -269,15 +270,33 @@ def _toListOfNames(_names, _size=-1): for i in range(len(l), _size): l.append("%s_%d"%(l[0],i)) return l +# Decorator function to manage transactions for all geometric operations. +def ManageTransactions(theOpeName): + def MTDecorator(theFunction): + # To keep the original function name an documentation. + @functools.wraps(theFunction) + def OpenCallClose(self, *args, **kwargs): + # Open transaction + anOperation = getattr(self, theOpeName) + anOperation.StartOperation() + try: + # Call the function + res = theFunction(self, *args, **kwargs) + # Commit transaction + anOperation.FinishOperation() + return res + except: + # Abort transaction + anOperation.AbortOperation() + raise + return OpenCallClose + return MTDecorator + ## Raise an Error, containing the Method_name, if Operation is Failed ## @ingroup l1_geomBuilder_auxiliary def RaiseIfFailed (Method_name, Operation): if Operation.IsDone() == 0 and Operation.GetErrorCode() != "NOT_FOUND_ANY": - Operation.AbortOperation() raise RuntimeError, Method_name + " : " + Operation.GetErrorCode() - else: - Operation.FinishOperation() - pass ## Return list of variables value from salome notebook ## @ingroup l1_geomBuilder_auxiliary @@ -385,7 +404,7 @@ def PackData(data): Returns: data packed to the byte stream - + Example of usage: val = PackData("10001110") # val = 0xAE val = PackData("1") # val = 0x80 @@ -436,13 +455,13 @@ def ReadTexture(fname): texture bitmap itself. This function can be used to read the texture to the byte stream in order to pass it to the AddTexture() function of geomBuilder class. - + Parameters: fname texture file name Returns: sequence of tree values: texture's width, height in pixels and its byte stream - + Example of usage: from salome.geom import geomBuilder geompy = geomBuilder.New(salome.myStudy) @@ -515,6 +534,7 @@ class PluginOperation: self.function = function pass + @ManageTransactions("operation") def __call__(self, *args): res = self.function(self.operation, *args) RaiseIfFailed(self.function.__name__, self.operation) @@ -637,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 @@ -754,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() @@ -770,20 +781,10 @@ 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 - # + # # The automatic publishing is managed in the following way: # - if @a maxNbSubShapes = 0, automatic publishing is disabled. # - if @a maxNbSubShapes = -1 (default), automatic publishing is enabled and @@ -829,6 +830,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## Get name for sub-shape aSubObj of shape aMainObj # # @ref swig_SubShapeName "Example" + @ManageTransactions("ShapesOp") def SubShapeName(self,aSubObj, aMainObj): """ Get name for sub-shape aSubObj of shape aMainObj @@ -934,6 +936,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): genericAttribute = self.myBuilder.FindOrCreateAttribute(aSObject, "AttributeDrawable") drwAttribute = genericAttribute._narrow(SALOMEDS.AttributeDrawable) drwAttribute.SetDrawable(False) + # hide references if any + vso = self.myStudy.FindDependances(aSObject); + for refObj in vso : + genericAttribute = self.myBuilder.FindOrCreateAttribute(refObj, "AttributeDrawable") + drwAttribute = genericAttribute._narrow(SALOMEDS.AttributeDrawable) + drwAttribute.SetDrawable(False) + pass pass # end of l1_geomBuilder_auxiliary @@ -1038,7 +1047,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theAddPrefix add prefix "from_" to names of restored sub-shapes, and prefix "from_subshapes_of_" to names of partially restored sub-shapes. - Returns: + Returns: list of published sub-shapes """ # Example: see GEOM_TestAll.py @@ -1062,6 +1071,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" + @ManageTransactions("BasicOp") def MakeVertex(self, theX, theY, theZ, theName=None): """ Create point by three coordinates. @@ -1073,8 +1083,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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: + + Returns: New GEOM.GEOM_Object, containing the created point. """ # Example: see GEOM_TestAll.py @@ -1098,6 +1108,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" + @ManageTransactions("BasicOp") def MakeVertexWithRef(self, theReference, theX, theY, theZ, theName=None): """ Create a point, distant from the referenced point @@ -1133,6 +1144,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" + @ManageTransactions("BasicOp") def MakeVertexOnCurve(self, theRefCurve, theParameter, theName=None): """ Create a point, corresponding to the given parameter on the given curve. @@ -1170,10 +1182,11 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" + @ManageTransactions("BasicOp") def MakeVertexOnCurveByCoord(self, theRefCurve, theX, theY, theZ, theName=None): """ Create a point by projection give coordinates on the given curve - + Parameters: theRefCurve The referenced curve. theX X-coordinate in 3D space @@ -1209,6 +1222,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" + @ManageTransactions("BasicOp") def MakeVertexOnCurveByLength(self, theRefCurve, theLength, theStartPoint = None, theName=None): """ Create a point, corresponding to the given length on the given curve. @@ -1245,6 +1259,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created point. # # @ref swig_MakeVertexOnSurface "Example" + @ManageTransactions("BasicOp") def MakeVertexOnSurface(self, theRefSurf, theUParameter, theVParameter, theName=None): """ Create a point, corresponding to the given parameters on the @@ -1284,6 +1299,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created point. # # @ref swig_MakeVertexOnSurfaceByCoord "Example" + @ManageTransactions("BasicOp") def MakeVertexOnSurfaceByCoord(self, theRefSurf, theX, theY, theZ, theName=None): """ Create a point by projection give coordinates on the given surface @@ -1324,6 +1340,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created point. # # @ref swig_MakeVertexInsideFace "Example" + @ManageTransactions("BasicOp") def MakeVertexInsideFace (self, theFace, theName=None): """ Create a point, which lays on the given face. @@ -1359,6 +1376,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created point. # # @ref swig_MakeVertexOnLinesIntersection "Example" + @ManageTransactions("BasicOp") def MakeVertexOnLinesIntersection(self, theRefLine1, theRefLine2, theName=None): """ Create a point on intersection of two lines. @@ -1388,6 +1406,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created tangent. # # @ref swig_MakeTangentOnCurve "Example" + @ManageTransactions("BasicOp") def MakeTangentOnCurve(self, theRefCurve, theParameter, theName=None): """ Create a tangent, corresponding to the given parameter on the given curve. @@ -1422,6 +1441,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created tangent. # # @ref swig_MakeTangentPlaneOnFace "Example" + @ManageTransactions("BasicOp") def MakeTangentPlaneOnFace(self, theFace, theParameterU, theParameterV, theTrimSize, theName=None): """ Create a tangent plane, corresponding to the given parameter on the given face. @@ -1435,7 +1455,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created tangent. Example of usage: @@ -1457,6 +1477,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created vector. # # @ref tui_creation_vector "Example" + @ManageTransactions("BasicOp") def MakeVectorDXDYDZ(self, theDX, theDY, theDZ, theName=None): """ Create a vector with the given components. @@ -1469,7 +1490,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created vector. """ # Example: see GEOM_TestAll.py @@ -1490,6 +1511,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created vector. # # @ref tui_creation_vector "Example" + @ManageTransactions("BasicOp") def MakeVector(self, thePnt1, thePnt2, theName=None): """ Create a vector between two points. @@ -1501,7 +1523,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created vector. """ # Example: see GEOM_TestAll.py @@ -1521,6 +1543,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created line. # # @ref tui_creation_line "Example" + @ManageTransactions("BasicOp") def MakeLine(self, thePnt, theDir, theName=None): """ Create a line, passing through the given point @@ -1552,6 +1575,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created line. # # @ref tui_creation_line "Example" + @ManageTransactions("BasicOp") def MakeLineTwoPnt(self, thePnt1, thePnt2, theName=None): """ Create a line, passing through the given points @@ -1582,6 +1606,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created line. # # @ref swig_MakeLineTwoFaces "Example" + @ManageTransactions("BasicOp") def MakeLineTwoFaces(self, theFace1, theFace2, theName=None): """ Create a line on two faces intersection. @@ -1614,6 +1639,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" + @ManageTransactions("BasicOp") def MakePlane(self, thePnt, theVec, theTrimSize, theName=None): """ Create a plane, passing through the given point @@ -1627,7 +1653,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created plane. """ # Example: see GEOM_TestAll.py @@ -1650,6 +1676,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" + @ManageTransactions("BasicOp") def MakePlaneThreePnt(self, thePnt1, thePnt2, thePnt3, theTrimSize, theName=None): """ Create a plane, passing through the three given points @@ -1684,6 +1711,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" + @ManageTransactions("BasicOp") def MakePlaneFace(self, theFace, theTrimSize, theName=None): """ Create a plane, similar to the existing one, but with another size of representing face. @@ -1718,6 +1746,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" + @ManageTransactions("BasicOp") def MakePlane2Vec(self, theVec1, theVec2, theTrimSize, theName=None): """ Create a plane, passing through the 2 vectors @@ -1731,7 +1760,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created plane. """ # Example: see GEOM_TestAll.py @@ -1753,11 +1782,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" + @ManageTransactions("BasicOp") def MakePlaneLCS(self, theLCS, theTrimSize, theOrientation, theName=None): """ Create a plane, based on a Local coordinate system. - Parameters: + Parameters: theLCS coordinate system, defining plane. theTrimSize Half size of a side of quadrangle face, representing the plane. theOrientation OXY, OYZ or OZX orientation - (1, 2 or 3) @@ -1765,7 +1795,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created plane. """ # Example: see GEOM_TestAll.py @@ -1787,11 +1817,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created coordinate system. # # @ref swig_MakeMarker "Example" + @ManageTransactions("BasicOp") def MakeMarker(self, OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ, theName=None): """ Create a local coordinate system. - Parameters: + Parameters: OX,OY,OZ Three coordinates of coordinate system origin. XDX,XDY,XDZ Three components of OX direction YDX,YDY,YDZ Three components of OY direction @@ -1799,7 +1830,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created coordinate system. """ # Example: see GEOM_TestAll.py @@ -1819,6 +1850,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created coordinate system. # # @ref tui_creation_lcs "Example" + @ManageTransactions("BasicOp") def MakeMarkerFromShape(self, theShape, theName=None): """ Create a local coordinate system from shape. @@ -1828,8 +1860,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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: + + Returns: New GEOM.GEOM_Object, containing the created coordinate system. """ anObj = self.BasicOp.MakeMarkerFromShape(theShape) @@ -1848,6 +1880,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created coordinate system. # # @ref tui_creation_lcs "Example" + @ManageTransactions("BasicOp") def MakeMarkerPntTwoVec(self, theOrigin, theXVec, theYVec, theName=None): """ Create a local coordinate system from point and two vectors. @@ -1860,7 +1893,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created coordinate system. """ @@ -1886,6 +1919,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created arc. # # @ref swig_MakeArc "Example" + @ManageTransactions("CurvesOp") def MakeArc(self, thePnt1, thePnt2, thePnt3, theName=None): """ Create an arc of circle, passing through three given points. @@ -1898,7 +1932,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created arc. """ # Example: see GEOM_TestAll.py @@ -1919,6 +1953,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created arc. # # @ref swig_MakeArc "Example" + @ManageTransactions("CurvesOp") def MakeArcCenter(self, thePnt1, thePnt2, thePnt3, theSense=False, theName=None): """ Create an arc of circle from a center and 2 points. @@ -1952,6 +1987,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created arc. # # @ref swig_MakeArc "Example" + @ManageTransactions("CurvesOp") def MakeArcOfEllipse(self, theCenter, thePnt1, thePnt2, theName=None): """ Create an arc of ellipse, of center and two points. @@ -1984,6 +2020,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created circle. # # @ref tui_creation_circle "Example" + @ManageTransactions("CurvesOp") def MakeCircle(self, thePnt, theVec, theR, theName=None): """ Create a circle with given center, normal vector and radius. @@ -2016,6 +2053,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # publication is switched on, default value is used for result name. # # @return New GEOM.GEOM_Object, containing the created circle. + @ManageTransactions("CurvesOp") def MakeCircleR(self, theR, theName=None): """ Create a circle with given radius. @@ -2045,6 +2083,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created circle. # # @ref tui_creation_circle "Example" + @ManageTransactions("CurvesOp") def MakeCircleThreePnt(self, thePnt1, thePnt2, thePnt3, theName=None): """ Create a circle, passing through three given points @@ -2075,6 +2114,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created circle. # # @ref swig_MakeCircle "Example" + @ManageTransactions("CurvesOp") def MakeCircleCenter2Pnt(self, thePnt1, thePnt2, thePnt3, theName=None): """ Create a circle, with given point1 as center, @@ -2109,6 +2149,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created ellipse. # # @ref tui_creation_ellipse "Example" + @ManageTransactions("CurvesOp") def MakeEllipse(self, thePnt, theVec, theRMajor, theRMinor, theVecMaj=None, theName=None): """ Create an ellipse with given center, normal vector and radiuses. @@ -2123,7 +2164,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created ellipse. """ # Example: see GEOM_TestAll.py @@ -2148,6 +2189,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # publication is switched on, default value is used for result name. # # @return New GEOM.GEOM_Object, containing the created ellipse. + @ManageTransactions("CurvesOp") def MakeEllipseRR(self, theRMajor, theRMinor, theName=None): """ Create an ellipse with given radiuses. @@ -2179,6 +2221,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created polyline. # # @ref tui_creation_curve "Example" + @ManageTransactions("CurvesOp") def MakePolyline(self, thePoints, theIsClosed=False, theName=None): """ Create a polyline on the set of points. @@ -2209,6 +2252,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created bezier curve. # # @ref tui_creation_curve "Example" + @ManageTransactions("CurvesOp") def MakeBezier(self, thePoints, theIsClosed=False, theName=None): """ Create bezier curve on the set of points. @@ -2241,6 +2285,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created B-Spline curve. # # @ref tui_creation_curve "Example" + @ManageTransactions("CurvesOp") def MakeInterpol(self, thePoints, theIsClosed=False, theDoReordering=False, theName=None): """ Create B-Spline curve on the set of points. @@ -2254,7 +2299,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created B-Spline curve. """ # Example: see GEOM_TestAll.py @@ -2274,6 +2319,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created B-Spline curve. # # @ref tui_creation_curve "Example" + @ManageTransactions("CurvesOp") def MakeInterpolWithTangents(self, thePoints, theFirstVec, theLastVec, theName=None): """ Create B-Spline curve on the set of points. @@ -2286,7 +2332,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created B-Spline curve. """ # Example: see GEOM_TestAll.py @@ -2312,6 +2358,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created curve. # # @ref tui_creation_curve "Example" + @ManageTransactions("CurvesOp") def MakeCurveParametric(self, thexExpr, theyExpr, thezExpr, theParamMin, theParamMax, theParamStep, theCurveType, theNewMethod=False, theName=None ): """ @@ -2339,7 +2386,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): if theNewMethod: anObj = self.CurvesOp.MakeCurveParametricNew(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType) else: - anObj = self.CurvesOp.MakeCurveParametric(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType) + anObj = self.CurvesOp.MakeCurveParametric(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType) RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp) anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "curve") @@ -2359,6 +2406,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # a compound of edges. # # @ref tui_creation_curve "Example" + @ManageTransactions("CurvesOp") def MakeIsoline(self, theFace, IsUIsoline, theParameter, theName=None): """ Create an isoline curve on a face. @@ -2447,6 +2495,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created wire. # # @ref tui_sketcher_page "Example" + @ManageTransactions("CurvesOp") def MakeSketcher(self, theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0], theName=None): """ Create a sketcher (wire or face), following the textual description, passed @@ -2459,7 +2508,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): - CMD is one of - "R angle" : Set the direction by angle - "D dx dy" : Set the direction by DX & DY - + - "TT x y" : Create segment by point at X & Y - "T dx dy" : Create segment by point with DX & DY - "L length" : Create segment by direction & Length @@ -2476,11 +2525,11 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): - "WW" : Close Wire (to finish) - "WF" : Close Wire and build face (to finish) - + - Flag1 (= reverse) is 0 or 2 ... - if 0 the drawn arc is the one of lower angle (< Pi) - if 2 the drawn arc ius the one of greater angle (> Pi) - + - Flag2 (= control tolerance) is 0 or 1 ... - if 0 the specified end point can be at a distance of the arc greater than the tolerance (10^-7) - if 1 the wire is built only if the end point is on the arc @@ -2519,6 +2568,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created wire. # # @ref tui_sketcher_page "Example" + @ManageTransactions("CurvesOp") def MakeSketcherOnPlane(self, theCommand, theWorkingPlane, theName=None): """ Create a sketcher (wire or face), following the textual description, @@ -2544,7 +2594,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return anObj ## Obtain a 2D sketcher interface - # @return An instance of @ref gsketcher.Sketcher2D "Sketcher2D" interface + # @return An instance of @ref gsketcher.Sketcher2D "Sketcher2D" interface def Sketcher2D (self): """ Obtain a 2D sketcher interface. @@ -2562,7 +2612,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ sk = Sketcher2D (self) return sk - + ## Create a sketcher wire, following the numerical description, # passed through theCoordinates argument. \n # @param theCoordinates double values, defining points to create a wire, @@ -2574,6 +2624,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created wire. # # @ref tui_3dsketcher_page "Example" + @ManageTransactions("CurvesOp") def Make3DSketcher(self, theCoordinates, theName=None): """ Create a sketcher wire, following the numerical description, @@ -2616,6 +2667,25 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): sk = Sketcher3D (self) return sk + ## Obtain a 2D polyline creation interface + # @return An instance of @ref gsketcher.Polyline2D "Polyline2D" interface + # + # @ref tui_3dsketcher_page "Example" + def Polyline2D (self): + """ + Obtain a 2D polyline creation interface. + + Example of usage: + pl = geompy.Polyline2D() + pl.addSection("section 1", GEOM.Polyline, True) + pl.addPoints(0, 0, 10, 0, 10, 10) + pl.addSection("section 2", GEOM.Interpolation, False) + pl.addPoints(20, 0, 30, 0, 30, 10) + resultObj = pl.result(WorkingPlane) + """ + pl = Polyline2D (self) + return pl + # end of l3_sketcher ## @} @@ -2636,14 +2706,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): def MakeBox(self, x1, y1, z1, x2, y2, z2, theName=None): """ Create a box by coordinates of two opposite vertices. - + Parameters: x1,y1,z1 double values, defining first point. x2,y2,z2 double values, defining second point. 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 created box. """ @@ -2666,6 +2736,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created box. # # @ref tui_creation_box "Example" + @ManageTransactions("PrimOp") def MakeBoxDXDYDZ(self, theDX, theDY, theDZ, theName=None): """ Create a box with specified dimensions along the coordinate axes @@ -2680,7 +2751,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created box. """ # Example: see GEOM_TestAll.py @@ -2702,6 +2773,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created box. # # @ref tui_creation_box "Example" + @ManageTransactions("PrimOp") def MakeBoxTwoPnt(self, thePnt1, thePnt2, theName=None): """ Create a box with two specified opposite vertices, @@ -2734,6 +2806,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" + @ManageTransactions("PrimOp") def MakeFaceHW(self, theH, theW, theOrientation, theName=None): """ Create a face with specified dimensions with edges parallel to coordinate axes. @@ -2770,6 +2843,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" + @ManageTransactions("PrimOp") def MakeFaceObjHW(self, theObj, theH, theW, theName=None): """ Create a face from another plane and two sizes, @@ -2806,6 +2880,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created disk. # # @ref tui_creation_disk "Example" + @ManageTransactions("PrimOp") def MakeDiskPntVecR(self, thePnt, theVec, theR, theName=None): """ Create a disk with given center, normal vector and radius. @@ -2818,7 +2893,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created disk. """ # Example: see GEOM_TestAll.py @@ -2838,6 +2913,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created disk. # # @ref tui_creation_disk "Example" + @ManageTransactions("PrimOp") def MakeDiskThreePnt(self, thePnt1, thePnt2, thePnt3, theName=None): """ Create a disk, passing through three given points @@ -2848,7 +2924,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created disk. """ # Example: see GEOM_TestAll.py @@ -2867,6 +2943,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created disk. # # @ref tui_creation_face "Example" + @ManageTransactions("PrimOp") def MakeDiskR(self, theR, theOrientation, theName=None): """ Create a disk with specified dimensions along OX-OY coordinate axes. @@ -2878,7 +2955,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created disk. Example of usage: @@ -2904,6 +2981,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created cylinder. # # @ref tui_creation_cylinder "Example" + @ManageTransactions("PrimOp") def MakeCylinder(self, thePnt, theAxis, theR, theH, theName=None): """ Create a cylinder with given base point, axis, radius and height. @@ -2917,7 +2995,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created cylinder. """ # Example: see GEOM_TestAll.py @@ -2927,6 +3005,50 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "cylinder") return anObj + + ## Create a portion of cylinder with given base point, axis, radius, height and angle. + # @param thePnt Central point of cylinder base. + # @param theAxis Cylinder axis. + # @param theR Cylinder radius. + # @param theH Cylinder height. + # @param theA Cylinder angle in radians. + # @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 created cylinder. + # + # @ref tui_creation_cylinder "Example" + @ManageTransactions("PrimOp") + def MakeCylinderA(self, thePnt, theAxis, theR, theH, theA, theName=None): + """ + Create a a portion of cylinder with given base point, axis, radius, height and angle. + + Parameters: + thePnt Central point of cylinder base. + theAxis Cylinder axis. + theR Cylinder radius. + theH Cylinder height. + theA Cylinder angle in radians. + 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 created cylinder. + """ + # Example: see GEOM_TestAll.py + flag = False + if isinstance(theA,str): + flag = True + theR,theH,theA,Parameters = ParseParameters(theR, theH, theA) + if flag: + theA = theA*math.pi/180. + anObj = self.PrimOp.MakeCylinderPntVecRHA(thePnt, theAxis, theR, theH, theA) + RaiseIfFailed("MakeCylinderPntVecRHA", self.PrimOp) + anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "cylinder") + return anObj ## Create a cylinder with given radius and height at # the origin of coordinate system. Axis of the cylinder @@ -2940,6 +3062,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created cylinder. # # @ref tui_creation_cylinder "Example" + @ManageTransactions("PrimOp") def MakeCylinderRH(self, theR, theH, theName=None): """ Create a cylinder with given radius and height at @@ -2953,7 +3076,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created cylinder. """ # Example: see GEOM_TestAll.py @@ -2963,6 +3086,50 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "cylinder") return anObj + + ## Create a portion of cylinder with given radius, height and angle at + # the origin of coordinate system. Axis of the cylinder + # will be collinear to the OZ axis of the coordinate system. + # @param theR Cylinder radius. + # @param theH Cylinder height. + # @param theA Cylinder angle in radians. + # @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 created cylinder. + # + # @ref tui_creation_cylinder "Example" + @ManageTransactions("PrimOp") + def MakeCylinderRHA(self, theR, theH, theA, theName=None): + """ + Create a portion of cylinder with given radius, height and angle at + the origin of coordinate system. Axis of the cylinder + will be collinear to the OZ axis of the coordinate system. + + Parameters: + theR Cylinder radius. + theH Cylinder height. + theA Cylinder angle in radians. + 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 created cylinder. + """ + # Example: see GEOM_TestAll.py + flag = False + if isinstance(theA,str): + flag = True + theR,theH,theA,Parameters = ParseParameters(theR, theH, theA) + if flag: + theA = theA*math.pi/180. + anObj = self.PrimOp.MakeCylinderRHA(theR, theH, theA) + RaiseIfFailed("MakeCylinderRHA", self.PrimOp) + anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "cylinder") + return anObj ## Create a sphere with given center and radius. # @param thePnt Sphere center. @@ -2974,6 +3141,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created sphere. # # @ref tui_creation_sphere "Example" + @ManageTransactions("PrimOp") def MakeSpherePntR(self, thePnt, theR, theName=None): """ Create a sphere with given center and radius. @@ -2985,8 +3153,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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 created sphere. + Returns: + New GEOM.GEOM_Object, containing the created sphere. """ # Example: see GEOM_TestAll.py theR,Parameters = ParseParameters(theR) @@ -3010,7 +3178,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ Create a sphere with given center and radius. - Parameters: + Parameters: x,y,z Coordinates of sphere center. theR Sphere radius. theName Object name; when specified, this parameter is used @@ -3035,18 +3203,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created sphere. # # @ref tui_creation_sphere "Example" + @ManageTransactions("PrimOp") def MakeSphereR(self, theR, theName=None): """ Create a sphere with given radius at the origin of coordinate system. - Parameters: + Parameters: theR Sphere radius. 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 created sphere. + New GEOM.GEOM_Object, containing the created sphere. """ # Example: see GEOM_TestAll.py theR,Parameters = ParseParameters(theR) @@ -3071,11 +3240,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created cone. # # @ref tui_creation_cone "Example" + @ManageTransactions("PrimOp") def MakeCone(self, thePnt, theAxis, theR1, theR2, theH, theName=None): """ Create a cone with given base point, axis, height and radiuses. - Parameters: + Parameters: thePnt Central point of the first cone base. theAxis Cone axis. theR1 Radius of the first cone base. @@ -3115,13 +3285,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created cone. # # @ref tui_creation_cone "Example" + @ManageTransactions("PrimOp") def MakeConeR1R2H(self, theR1, theR2, theH, theName=None): """ Create a cone with given height and radiuses at the origin of coordinate system. Axis of the cone will be collinear to the OZ axis of the coordinate system. - Parameters: + Parameters: theR1 Radius of the first cone base. theR2 Radius of the second cone base. theH Cone height. @@ -3156,11 +3327,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created torus. # # @ref tui_creation_torus "Example" + @ManageTransactions("PrimOp") def MakeTorus(self, thePnt, theVec, theRMajor, theRMinor, theName=None): """ Create a torus with given center, normal vector and radiuses. - Parameters: + Parameters: thePnt Torus central point. theVec Torus axis of symmetry. theRMajor Torus major radius. @@ -3190,11 +3362,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created torus. # # @ref tui_creation_torus "Example" + @ManageTransactions("PrimOp") def MakeTorusRR(self, theRMajor, theRMinor, theName=None): """ Create a torus with given radiuses at the origin of coordinate system. - Parameters: + Parameters: theRMajor Torus major radius. theRMinor Torus minor radius. theName Object name; when specified, this parameter is used @@ -3202,7 +3375,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing the created torus. + New GEOM.GEOM_Object, containing the created torus. """ # Example: see GEOM_TestAll.py theRMajor,theRMinor,Parameters = ParseParameters(theRMajor,theRMinor) @@ -3231,11 +3404,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" + @ManageTransactions("PrimOp") def MakePrism(self, theBase, thePoint1, thePoint2, theScaleFactor = -1.0, theName=None): """ Create a shape by extrusion of the base shape along a vector, defined by two points. - Parameters: + Parameters: theBase Base shape to be extruded. thePoint1 First end of extrusion vector. thePoint2 Second end of extrusion vector. @@ -3273,12 +3447,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" + @ManageTransactions("PrimOp") def MakePrism2Ways(self, theBase, thePoint1, thePoint2, theName=None): """ Create a shape by extrusion of the base shape along a vector, defined by two points, in 2 Ways (forward/backward). - Parameters: + Parameters: theBase Base shape to be extruded. thePoint1 First end of extrusion vector. thePoint2 Second end of extrusion vector. @@ -3310,13 +3485,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" + @ManageTransactions("PrimOp") def MakePrismVecH(self, theBase, theVec, theH, theScaleFactor = -1.0, theName=None): """ Create a shape by extrusion of the base shape along the vector, i.e. all the space, transfixed by the base shape during its translation along the vector on the given distance. - Parameters: + Parameters: theBase Base shape to be extruded. theVec Direction of extrusion. theH Prism dimension along theVec. @@ -3356,6 +3532,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" + @ManageTransactions("PrimOp") def MakePrismVecH2Ways(self, theBase, theVec, theH, theName=None): """ Create a shape by extrusion of the base shape along the vector, @@ -3393,6 +3570,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" + @ManageTransactions("PrimOp") def MakePrismDXDYDZ(self, theBase, theDX, theDY, theDZ, theScaleFactor = -1.0, theName=None): """ Create a shape by extrusion of the base shape along the dx, dy, dz direction @@ -3406,7 +3584,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created prism. """ # Example: see GEOM_TestAll.py @@ -3435,6 +3613,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" + @ManageTransactions("PrimOp") def MakePrismDXDYDZ2Ways(self, theBase, theDX, theDY, theDZ, theName=None): """ Create a shape by extrusion of the base shape along the dx, dy, dz direction @@ -3472,6 +3651,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created revolution. # # @ref tui_creation_revolution "Example" + @ManageTransactions("PrimOp") def MakeRevolution(self, theBase, theAxis, theAngle, theName=None): """ Create a shape by revolution of the base shape around the axis @@ -3486,7 +3666,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created revolution. """ # Example: see GEOM_TestAll.py @@ -3511,6 +3691,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created revolution. # # @ref tui_creation_revolution "Example" + @ManageTransactions("PrimOp") def MakeRevolution2Ways(self, theBase, theAxis, theAngle, theName=None): """ Create a shape by revolution of the base shape around the axis @@ -3526,7 +3707,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created revolution. """ theAngle,Parameters = ParseParameters(theAngle) @@ -3556,6 +3737,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created filling surface. # # @ref tui_creation_filling "Example" + @ManageTransactions("PrimOp") def MakeFilling(self, theShape, theMinDeg=2, theMaxDeg=5, theTol2D=0.0001, theTol3D=0.0001, theNbIter=0, theMethod=GEOM.FOM_Default, isApprox=0, theName=None): """ @@ -3578,7 +3760,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created filling surface. Example of usage: @@ -3608,6 +3790,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created filling surface. # # @ref tui_creation_filling "Example" + @ManageTransactions("PrimOp") def MakeFillingNew(self, theShape, theMinDeg=2, theMaxDeg=5, theTol3D=0.0001, theName=None): """ Create a filling from the given compound of contours. @@ -3622,7 +3805,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created filling surface. Example of usage: @@ -3649,6 +3832,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created shell or solid. # # @ref swig_todo "Example" + @ManageTransactions("PrimOp") def MakeThruSections(self, theSeqSections, theModeSolid, thePreci, theRuled, theName=None): """ Create a shell or solid passing through set of sections.Sections should be wires,edges or vertices. @@ -3682,6 +3866,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created pipe. # # @ref tui_creation_pipe "Example" + @ManageTransactions("PrimOp") def MakePipe(self, theBase, thePath, theName=None): """ Create a shape by extrusion of the base shape along @@ -3722,6 +3907,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created pipe. # # @ref tui_creation_pipe_with_diff_sec "Example" + @ManageTransactions("PrimOp") def MakePipeWithDifferentSections(self, theSeqBases, theLocations, thePath, theWithContact, theWithCorrection, theName=None): @@ -3782,6 +3968,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created solids. # # @ref tui_creation_pipe_with_shell_sec "Example" + @ManageTransactions("PrimOp") def MakePipeWithShellSections(self, theSeqBases, theSeqSubBases, theLocations, thePath, theWithContact, theWithCorrection, theName=None): @@ -3813,7 +4000,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created solids. """ anObj = self.PrimOp.MakePipeWithShellSections(theSeqBases, theSeqSubBases, @@ -3828,6 +4015,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # functionality - it is a version of function MakePipeWithShellSections() # which give a possibility to recieve information about # creating pipe between each pair of sections step by step. + @ManageTransactions("PrimOp") def MakePipeWithShellSectionsBySteps(self, theSeqBases, theSeqSubBases, theLocations, thePath, theWithContact, theWithCorrection, theName=None): @@ -3878,6 +4066,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created solids. # # @ref tui_creation_pipe_without_path "Example" + @ManageTransactions("PrimOp") def MakePipeShellsWithoutPath(self, theSeqBases, theLocations, theName=None): """ Create solids between given sections @@ -3912,6 +4101,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created pipe. # # @ref tui_creation_pipe "Example" + @ManageTransactions("PrimOp") def MakePipeBiNormalAlongVector(self, theBase, thePath, theVec, theName=None): """ Create a shape by extrusion of the base shape along @@ -3928,7 +4118,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created pipe. """ # Example: see GEOM_TestAll.py @@ -3936,7 +4126,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): RaiseIfFailed("MakePipeBiNormalAlongVector", self.PrimOp) self._autoPublish(anObj, theName, "pipe") return anObj - + ## Makes a thick solid from a face or a shell # @param theShape Face or Shell to be thicken # @param theThickness Thickness of the resulting solid @@ -3946,6 +4136,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @return New GEOM.GEOM_Object, containing the created solid # + @ManageTransactions("PrimOp") def MakeThickSolid(self, theShape, theThickness, theName=None): """ Make a thick solid from a face or a shell @@ -3956,7 +4147,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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 created solid """ @@ -3965,7 +4156,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): RaiseIfFailed("MakeThickening", self.PrimOp) self._autoPublish(anObj, theName, "pipe") return anObj - + ## Modifies a face or a shell to make it a thick solid # @param theShape Face or Shell to be thicken @@ -3973,6 +4164,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @return The modified shape # + @ManageTransactions("PrimOp") def Thicken(self, theShape, theThickness): """ Modifies a face or a shell to make it a thick solid @@ -4013,6 +4205,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # source pipe's "path". # # @ref tui_creation_pipe_path "Example" + @ManageTransactions("PrimOp") def RestorePath (self, theShape, theBase1, theBase2, theName=None): """ Build a middle path of a pipe-like shape. @@ -4057,6 +4250,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # source pipe's "path". # # @ref tui_creation_pipe_path "Example" + @ManageTransactions("PrimOp") def RestorePathEdges (self, theShape, listEdges1, listEdges2, theName=None): """ Build a middle path of a pipe-like shape. @@ -4096,6 +4290,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created edge. # # @ref tui_creation_edge "Example" + @ManageTransactions("ShapesOp") def MakeEdge(self, thePnt1, thePnt2, theName=None): """ Create a linear edge with specified ends. @@ -4107,7 +4302,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created edge. """ # Example: see GEOM_TestAll.py @@ -4129,6 +4324,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created edge. # # @ref tui_creation_edge "Example" + @ManageTransactions("ShapesOp") def MakeEdgeOnCurveByLength(self, theRefCurve, theLength, theStartPoint = None, theName=None): """ Create a new edge, corresponding to the given length on the given curve. @@ -4143,7 +4339,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created edge. """ # Example: see GEOM_TestAll.py @@ -4165,6 +4361,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created edge. # # @ref tui_creation_edge "Example" + @ManageTransactions("ShapesOp") def MakeEdgeWire(self, theWire, theLinearTolerance = 1e-07, theAngularTolerance = 1e-12, theName=None): """ Create an edge from specified wire. @@ -4197,6 +4394,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created wire. # # @ref tui_creation_wire "Example" + @ManageTransactions("ShapesOp") def MakeWire(self, theEdgesAndWires, theTolerance = 1e-07, theName=None): """ Create a wire from the set of edges and wires. @@ -4209,7 +4407,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created wire. """ # Example: see GEOM_TestAll.py @@ -4232,6 +4430,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" + @ManageTransactions("ShapesOp") def MakeFace(self, theWire, isPlanarWanted, theName=None): """ Create a face on the given wire. @@ -4273,6 +4472,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" + @ManageTransactions("ShapesOp") def MakeFaceWires(self, theWires, isPlanarWanted, theName=None): """ Create a face on the given wires set. @@ -4288,7 +4488,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created face. """ # Example: see GEOM_TestAll.py @@ -4322,6 +4522,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created shell. # # @ref tui_creation_shell "Example" + @ManageTransactions("ShapesOp") def MakeShell(self, theFacesAndShells, theName=None): """ Create a shell from the set of faces and shells. @@ -4350,6 +4551,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created solid. # # @ref tui_creation_solid "Example" + @ManageTransactions("ShapesOp") def MakeSolid(self, theShells, theName=None): """ Create a solid, bounded by the given shells. @@ -4365,7 +4567,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ # Example: see GEOM_TestAll.py if len(theShells) == 1: - descr = self.MeasuOp.IsGoodForSolid(theShells[0]) + descr = self._IsGoodForSolid(theShells[0]) #if len(descr) > 0: # raise RuntimeError, "MakeSolidShells : " + descr if descr == "WRN_SHAPE_UNCLOSED": @@ -4384,6 +4586,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created compound. # # @ref tui_creation_compound "Example" + @ManageTransactions("ShapesOp") def MakeCompound(self, theShapes, theName=None): """ Create a compound of the given shapes. @@ -4398,7 +4601,6 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the created compound. """ # Example: see GEOM_TestAll.py - self.ShapesOp.StartOperation() anObj = self.ShapesOp.MakeCompound(theShapes) RaiseIfFailed("MakeCompound", self.ShapesOp) self._autoPublish(anObj, theName, "compound") @@ -4415,6 +4617,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Quantity of faces. # # @ref swig_NumberOf "Example" + @ManageTransactions("ShapesOp") def NumberOfFaces(self, theShape): """ Gives quantity of faces in the given shape. @@ -4422,7 +4625,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Parameters: theShape Shape to count faces of. - Returns: + Returns: Quantity of faces. """ # Example: see GEOM_TestOthers.py @@ -4435,6 +4638,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Quantity of edges. # # @ref swig_NumberOf "Example" + @ManageTransactions("ShapesOp") def NumberOfEdges(self, theShape): """ Gives quantity of edges in the given shape. @@ -4442,7 +4646,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Parameters: theShape Shape to count edges of. - Returns: + Returns: Quantity of edges. """ # Example: see GEOM_TestOthers.py @@ -4456,6 +4660,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Quantity of sub-shapes of given type. # # @ref swig_NumberOf "Example" + @ManageTransactions("ShapesOp") def NumberOfSubShapes(self, theShape, theShapeType): """ Gives quantity of sub-shapes of type theShapeType in the given shape. @@ -4477,6 +4682,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Quantity of solids. # # @ref swig_NumberOf "Example" + @ManageTransactions("ShapesOp") def NumberOfSolids(self, theShape): """ Gives quantity of solids in the given shape. @@ -4507,6 +4713,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return The reversed copy of theShape. # # @ref swig_ChangeOrientation "Example" + @ManageTransactions("ShapesOp") def ChangeOrientation(self, theShape, theName=None): """ Reverses an orientation the given shape. @@ -4517,7 +4724,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: The reversed copy of theShape. """ # Example: see GEOM_TestAll.py @@ -4550,6 +4757,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of IDs of all free faces, contained in theShape. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("ShapesOp") def GetFreeFacesIDs(self,theShape): """ Retrieve all free faces from the given shape. @@ -4577,6 +4785,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of sub-shapes of theShape1, shared with theShape2. # # @ref swig_GetSharedShapes "Example" + @ManageTransactions("ShapesOp") def GetSharedShapes(self, theShape1, theShape2, theShapeType, theName=None): """ Get all sub-shapes of theShape1 of the given type, shared with theShape2. @@ -4608,6 +4817,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of objects, that are sub-shapes of all given shapes. # # @ref swig_GetSharedShapes "Example" + @ManageTransactions("ShapesOp") def GetSharedShapesMulti(self, theShapes, theShapeType, theName=None): """ Get all sub-shapes, shared by all shapes in the list theShapes. @@ -4619,7 +4829,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: List of GEOM.GEOM_Object, that are sub-shapes of all given shapes. """ # Example: see GEOM_TestOthers.py @@ -4643,6 +4853,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes. # # @ref swig_GetShapesOnPlane "Example" + @ManageTransactions("ShapesOp") def GetShapesOnPlane(self, theShape, theShapeType, theAx1, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, @@ -4680,6 +4891,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnPlaneIDs "Example" + @ManageTransactions("ShapesOp") def GetShapesOnPlaneIDs(self, theShape, theShapeType, theAx1, theState): """ Find in theShape all sub-shapes of type theShapeType, @@ -4717,6 +4929,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes. # # @ref swig_GetShapesOnPlaneWithLocation "Example" + @ManageTransactions("ShapesOp") def GetShapesOnPlaneWithLocation(self, theShape, theShapeType, theAx1, thePnt, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, @@ -4757,6 +4970,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnPlaneWithLocationIDs "Example" + @ManageTransactions("ShapesOp") def GetShapesOnPlaneWithLocationIDs(self, theShape, theShapeType, theAx1, thePnt, theState): """ Find in theShape all sub-shapes of type theShapeType, @@ -4795,6 +5009,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes. # # @ref swig_GetShapesOnCylinder "Example" + @ManageTransactions("ShapesOp") def GetShapesOnCylinder(self, theShape, theShapeType, theAxis, theRadius, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively @@ -4832,6 +5047,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnCylinderIDs "Example" + @ManageTransactions("ShapesOp") def GetShapesOnCylinderIDs(self, theShape, theShapeType, theAxis, theRadius, theState): """ Find in theShape all sub-shapes of type theShapeType, situated relatively @@ -4869,6 +5085,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes. # # @ref swig_GetShapesOnCylinderWithLocation "Example" + @ManageTransactions("ShapesOp") def GetShapesOnCylinderWithLocation(self, theShape, theShapeType, theAxis, thePnt, theRadius, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively @@ -4907,6 +5124,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes indices # # @ref swig_GetShapesOnCylinderWithLocationIDs "Example" + @ManageTransactions("ShapesOp") def GetShapesOnCylinderWithLocationIDs(self, theShape, theShapeType, theAxis, thePnt, theRadius, theState): """ Find in theShape all sub-shapes of type theShapeType, situated relatively @@ -4921,7 +5139,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theState The state of the sub-shapes to find (see GEOM::shape_state) Returns: - List of all found sub-shapes indices. + List of all found sub-shapes indices. """ # Example: see GEOM_TestOthers.py aList = self.ShapesOp.GetShapesOnCylinderWithLocationIDs(theShape, theShapeType, theAxis, thePnt, theRadius, theState) @@ -4942,6 +5160,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes. # # @ref swig_GetShapesOnSphere "Example" + @ManageTransactions("ShapesOp") def GetShapesOnSphere(self, theShape, theShapeType, theCenter, theRadius, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively @@ -4977,6 +5196,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnSphereIDs "Example" + @ManageTransactions("ShapesOp") def GetShapesOnSphereIDs(self, theShape, theShapeType, theCenter, theRadius, theState): """ Find in theShape all sub-shapes of type theShapeType, situated relatively @@ -5013,6 +5233,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes. # # @ref swig_GetShapesOnQuadrangle "Example" + @ManageTransactions("ShapesOp") def GetShapesOnQuadrangle(self, theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState, theName=None): @@ -5056,6 +5277,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnQuadrangleIDs "Example" + @ManageTransactions("ShapesOp") def GetShapesOnQuadrangleIDs(self, theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState): @@ -5096,6 +5318,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes. # # @ref swig_GetShapesOnBox "Example" + @ManageTransactions("ShapesOp") def GetShapesOnBox(self, theBox, theShape, theShapeType, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively @@ -5129,6 +5352,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnBoxIDs "Example" + @ManageTransactions("ShapesOp") def GetShapesOnBoxIDs(self, theBox, theShape, theShapeType, theState): """ Find in theShape all sub-shapes of type theShapeType, situated relatively @@ -5153,7 +5377,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # certain way, defined through \a theState parameter. # @param theCheckShape Shape for relative comparing. It must be a solid. # @param theShape Shape to find sub-shapes of. - # @param theShapeType Type of sub-shapes to be retrieved (see ShapeType()) + # @param theShapeType Type of sub-shapes to be retrieved (see ShapeType()) # @param theState The state of the sub-shapes to find (see GEOM::shape_state) # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic @@ -5162,6 +5386,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes. # # @ref swig_GetShapesOnShape "Example" + @ManageTransactions("ShapesOp") def GetShapesOnShape(self, theCheckShape, theShape, theShapeType, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, @@ -5201,6 +5426,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return All found sub-shapes as compound. # # @ref swig_GetShapesOnShapeAsCompound "Example" + @ManageTransactions("ShapesOp") def GetShapesOnShapeAsCompound(self, theCheckShape, theShape, theShapeType, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, @@ -5237,6 +5463,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnShapeIDs "Example" + @ManageTransactions("ShapesOp") def GetShapesOnShapeIDs(self, theCheckShape, theShape, theShapeType, theState): """ Find in theShape all sub-shapes of type theShapeType, @@ -5277,6 +5504,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @image html get_in_place_lost_part.png # # @ref swig_GetInPlace "Example" + @ManageTransactions("ShapesOp") def GetInPlace(self, theShapeWhere, theShapeWhat, isNewImplementation = False, theName=None): """ Get sub-shape(s) of theShapeWhere, which are @@ -5294,7 +5522,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Returns: Group of all found sub-shapes or a single found sub-shape. - + Note: This function has a restriction on argument shapes. If theShapeWhere has curved parts with significantly @@ -5331,6 +5559,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Group of all found sub-shapes or a single found sub-shape. # # @ref swig_GetInPlace "Example" + @ManageTransactions("ShapesOp") def GetInPlaceByHistory(self, theShapeWhere, theShapeWhat, theName=None): """ Implementation of this method is based on a saved history of an operation, @@ -5367,6 +5596,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object for found sub-shape. # # @ref swig_GetSame "Example" + @ManageTransactions("ShapesOp") def GetSame(self, theShapeWhere, theShapeWhat, theName=None): """ Get sub-shape of theShapeWhere, which is @@ -5392,9 +5622,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # equal to \a theShapeWhat. # @param theShapeWhere Shape to find sub-shape of. # @param theShapeWhat Shape, specifying what to find. - # @return List of all found sub-shapes indices. + # @return List of all found sub-shapes indices. # # @ref swig_GetSame "Example" + @ManageTransactions("ShapesOp") def GetSameIDs(self, theShapeWhere, theShapeWhat): """ Get sub-shape indices of theShapeWhere, which is @@ -5456,6 +5687,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return ID of found sub-shape. # # @ref swig_all_decompose "Example" + @ManageTransactions("LocalOp") def GetSubShapeID(self, aShape, aSubShape): """ Obtain unique ID of sub-shape aSubShape inside aShape @@ -5472,7 +5704,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): anID = self.LocalOp.GetSubShapeIndex(aShape, aSubShape) RaiseIfFailed("GetSubShapeIndex", self.LocalOp) return anID - + ## Obtain unique IDs of sub-shapes aSubShapes inside aShape # This function is provided for performance purpose. The complexity is O(n) with n # the number of subobjects of aShape @@ -5481,6 +5713,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return list of IDs of found sub-shapes. # # @ref swig_all_decompose "Example" + @ManageTransactions("ShapesOp") def GetSubShapesIDs(self, aShape, aSubShapes): """ Obtain a list of IDs of sub-shapes aSubShapes inside aShape @@ -5513,6 +5746,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of existing sub-objects of \a theShape. # # @ref swig_all_decompose "Example" + @ManageTransactions("ShapesOp") def GetExistingSubObjects(self, theShape, theGroupsOnly = False): """ Get all sub-shapes and groups of theShape, @@ -5537,6 +5771,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of existing groups of \a theShape. # # @ref swig_all_decompose "Example" + @ManageTransactions("ShapesOp") def GetGroups(self, theShape): """ Get all groups of theShape, @@ -5556,7 +5791,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## Explode a shape on sub-shapes of a given type. # If the shape itself matches the type, it is also returned. # @param aShape Shape to be exploded. - # @param aType Type of sub-shapes to be retrieved (see ShapeType()) + # @param aType Type of sub-shapes to be retrieved (see ShapeType()) # @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. @@ -5564,6 +5799,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of sub-shapes of type theShapeType, contained in theShape. # # @ref swig_all_decompose "Example" + @ManageTransactions("ShapesOp") def SubShapeAll(self, aShape, aType, theName=None): """ Explode a shape on sub-shapes of a given type. @@ -5571,7 +5807,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Parameters: aShape Shape to be exploded. - aType Type of sub-shapes to be retrieved (see geompy.ShapeType) + aType Type of sub-shapes to be retrieved (see geompy.ShapeType) 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. @@ -5591,6 +5827,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of IDs of sub-shapes. # # @ref swig_all_decompose "Example" + @ManageTransactions("ShapesOp") def SubShapeAllIDs(self, aShape, aType): """ Explode a shape on sub-shapes of a given type. @@ -5624,7 +5861,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Obtain a compound of sub-shapes of aShape, selected by their indices in list of all sub-shapes of type aType. Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type] - + Parameters: aShape Shape to get sub-shape of. ListOfID List of sub-shapes indices. @@ -5646,7 +5883,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return anObj ## Explode a shape on sub-shapes of a given type. - # Sub-shapes will be sorted by coordinates of their gravity centers. + # Sub-shapes will be sorted taking into account their gravity centers, + # to provide stable order of sub-shapes. # If the shape itself matches the type, it is also returned. # @param aShape Shape to be exploded. # @param aType Type of sub-shapes to be retrieved (see ShapeType()) @@ -5657,20 +5895,22 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of sub-shapes of type theShapeType, contained in theShape. # # @ref swig_SubShapeAllSorted "Example" + @ManageTransactions("ShapesOp") def SubShapeAllSortedCentres(self, aShape, aType, theName=None): """ Explode a shape on sub-shapes of a given type. - Sub-shapes will be sorted by coordinates of their gravity centers. + Sub-shapes will be sorted taking into account their gravity centers, + to provide stable order of sub-shapes. If the shape itself matches the type, it is also returned. - Parameters: + Parameters: aShape Shape to be exploded. aType Type of sub-shapes to be retrieved (see geompy.ShapeType) 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: + Returns: List of sub-shapes of type theShapeType, contained in theShape. """ # Example: see GEOM_TestAll.py @@ -5680,22 +5920,25 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return ListObj ## Explode a shape on sub-shapes of a given type. - # Sub-shapes will be sorted by coordinates of their gravity centers. + # Sub-shapes will be sorted taking into account their gravity centers, + # to provide stable order of sub-shapes. # @param aShape Shape to be exploded. # @param aType Type of sub-shapes to be retrieved (see ShapeType()) # @return List of IDs of sub-shapes. # # @ref swig_all_decompose "Example" + @ManageTransactions("ShapesOp") def SubShapeAllSortedCentresIDs(self, aShape, aType): """ Explode a shape on sub-shapes of a given type. - Sub-shapes will be sorted by coordinates of their gravity centers. + Sub-shapes will be sorted taking into account their gravity centers, + to provide stable order of sub-shapes. - Parameters: + Parameters: aShape Shape to be exploded. aType Type of sub-shapes to be retrieved (see geompy.ShapeType) - Returns: + Returns: List of IDs of sub-shapes. """ ListIDs = self.ShapesOp.GetAllSubShapesIDs(aShape, EnumToLong( aType ), True) @@ -5752,6 +5995,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of sub-shapes of type aType, contained in aShape. # # @ref swig_FilletChamfer "Example" + @ManageTransactions("ShapesOp") def ExtractShapes(self, aShape, aType, isSorted = False, theName=None): """ Extract shapes (excluding the main shape) of given type. @@ -5764,7 +6008,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: List of sub-shapes of type aType, contained in aShape. """ # Example: see GEOM_TestAll.py @@ -5782,6 +6026,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of GEOM.GEOM_Object, corresponding to found sub-shapes. # # @ref swig_all_decompose "Example" + @ManageTransactions("ShapesOp") def SubShapes(self, aShape, anIDs, theName=None): """ Get a set of sub-shapes defined by their unique IDs inside theMainShape @@ -5793,7 +6038,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: List of GEOM.GEOM_Object, corresponding to found sub-shapes. """ # Example: see GEOM_TestAll.py @@ -5811,6 +6056,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## Deprecated method # It works like SubShapeAllSortedCentres(), but wrongly # defines centres of faces, shells and solids. + @ManageTransactions("ShapesOp") def SubShapeAllSorted(self, aShape, aType, theName=None): """ Deprecated method @@ -5825,6 +6071,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## Deprecated method # It works like SubShapeAllSortedCentresIDs(), but wrongly # defines centres of faces, shells and solids. + @ManageTransactions("ShapesOp") def SubShapeAllSortedIDs(self, aShape, aType): """ Deprecated method @@ -5900,7 +6147,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # are coincidental. The curves or surfaces may still meet at an angle, giving rise to a sharp corner or edge).\n # \b C1 (Tangential Continuity): first derivatives are equal (the end vectors of curves or surfaces are parallel, # ruling out sharp edges).\n - # \b C2 (Curvature Continuity): first and second derivatives are equal (the end vectors of curves or surfaces + # \b C2 (Curvature Continuity): first and second derivatives are equal (the end vectors of curves or surfaces # are of the same magnitude).\n # \b CN N-th derivatives are equal (both the direction and the magnitude of the Nth derivatives of curves # or surfaces (d/du C(u)) are the same at junction. \n @@ -5939,6 +6186,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # \n @ref tui_shape_processing "Example" + @ManageTransactions("HealOp") def ProcessShape(self, theShape, theOperators, theParameters, theValues, theName=None): """ Apply a sequence of Shape Healing operators to the given object. @@ -5976,7 +6224,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): * SplitContinuity.SurfaceContinuity - required continuity for surfaces. * SplitContinuity.CurveContinuity - required continuity for curves. This and the previous parameters can take the following values: - + Parametric Continuity: C0 (Positional Continuity): curves are joined (the end positions of curves or surfaces are coincidental. The curves or surfaces may still meet at an angle, @@ -5987,7 +6235,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): or surfaces are of the same magnitude). CN N-th derivatives are equal (both the direction and the magnitude of the Nth derivatives of curves or surfaces (d/du C(u)) are the same at junction. - + Geometric Continuity: G1: first derivatives are proportional at junction. The curve tangents thus have the same direction, but not necessarily the same magnitude. @@ -6047,6 +6295,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_suppress_faces "Example" + @ManageTransactions("HealOp") def SuppressFaces(self, theObject, theFaces, theName=None): """ Remove faces from the given object (shape). @@ -6109,6 +6358,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # publication is switched on, default value is used for result name. # # @return New GEOM.GEOM_Object, containing processed shape. + @ManageTransactions("HealOp") def Sew(self, theObject, theTolerance, AllowNonManifold=False, theName=None): """ Sewing of the given object. @@ -6148,6 +6398,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_remove_webs "Example" + @ManageTransactions("HealOp") def RemoveInternalFaces (self, theCompound, theName=None): """ Rebuild the topology of theCompound of solids by removing @@ -6179,6 +6430,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_suppress_internal_wires "Example" + @ManageTransactions("HealOp") def SuppressInternalWires(self, theObject, theWires, theName=None): """ Remove internal wires and edges from the given object (face). @@ -6191,7 +6443,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing processed shape. """ # Example: see GEOM_TestHealing.py @@ -6211,6 +6463,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_suppress_holes "Example" + @ManageTransactions("HealOp") def SuppressHoles(self, theObject, theWires, theName=None): """ Remove internal closed contours (holes) from the given object. @@ -6223,7 +6476,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing processed shape. """ # Example: see GEOM_TestHealing.py @@ -6245,11 +6498,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_close_contour "Example" + @ManageTransactions("HealOp") def CloseContour(self,theObject, theWires, isCommonVertex, theName=None): """ Close an open wire. - Parameters: + Parameters: theObject Shape to be processed. theWires Indexes of edge(s) and wire(s) to be closed within theObject's shape, if [ ], then theObject itself is a wire. @@ -6259,8 +6513,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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 processed shape. + Returns: + New GEOM.GEOM_Object, containing processed shape. """ # Example: see GEOM_TestHealing.py anObj = self.HealOp.CloseContour(theObject, theWires, isCommonVertex) @@ -6283,11 +6537,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_add_point_on_edge "Example" + @ManageTransactions("HealOp") def DivideEdge(self, theObject, theEdgeIndex, theValue, isByParameter, theName=None): """ Addition of a point to a given edge object. - Parameters: + Parameters: theObject Shape to be processed. theEdgeIndex Index of edge to be divided within theObject's shape, if -1, then theObject itself is the edge. @@ -6299,7 +6554,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing processed shape. """ # Example: see GEOM_TestHealing.py @@ -6321,11 +6576,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object with modified wire. # # @ref tui_fuse_collinear_edges "Example" + @ManageTransactions("HealOp") def FuseCollinearEdgesWithinWire(self, theWire, theVertices = [], theName=None): """ Suppress the vertices in the wire in case if adjacent edges are C1 continuous. - Parameters: + Parameters: theWire Wire to minimize the number of C1 continuous edges in. theVertices A list of vertices to suppress. If the list is empty, all vertices in a wire will be assumed. @@ -6333,7 +6589,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object with modified wire. """ anObj = self.HealOp.FuseCollinearEdgesWithinWire(theWire, theVertices) @@ -6346,14 +6602,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Updated theObject # # @ref swig_todo "Example" + @ManageTransactions("HealOp") def ChangeOrientationShell(self,theObject): """ Change orientation of the given object. Updates given shape. - Parameters: + Parameters: theObject Shape to be processed. - Returns: + Returns: Updated theObject """ theObject = self.HealOp.ChangeOrientation(theObject) @@ -6369,6 +6626,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # @ref swig_todo "Example" + @ManageTransactions("HealOp") def ChangeOrientationShellCopy(self, theObject, theName=None): """ Change orientation of the given object. @@ -6379,7 +6637,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing processed shape. """ anObj = self.HealOp.ChangeOrientationCopy(theObject) @@ -6397,6 +6655,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_limit_tolerance "Example" + @ManageTransactions("HealOp") def LimitTolerance(self, theObject, theTolerance = 1e-07, theName=None): """ Try to limit tolerance of the given object by value theTolerance. @@ -6408,7 +6667,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing processed shape. """ anObj = self.HealOp.LimitTolerance(theObject, theTolerance) @@ -6429,6 +6688,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # \n \a theOpenWires: Open wires on the free boundary of the given shape. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("HealOp") def GetFreeBoundary(self, theObject, theName=None): """ Get a list of wires (wrapped in GEOM.GEOM_Object-s), @@ -6440,7 +6700,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: [status, theClosedWires, theOpenWires] status: FALSE, if an error(s) occured during the method execution. theClosedWires: Closed wires on the free boundary of the given shape. @@ -6465,6 +6725,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing a copy of theShape without coincident faces. # # @ref tui_glue_faces "Example" + @ManageTransactions("ShapesOp") def MakeGlueFaces(self, theShape, theTolerance, doKeepNonSolids=True, theName=None): """ Replace coincident faces in theShape by one face. @@ -6501,6 +6762,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return GEOM.ListOfGO # # @ref tui_glue_faces "Example" + @ManageTransactions("ShapesOp") def GetGlueFaces(self, theShape, theTolerance, theName=None): """ Find coincident faces in theShape for possible gluing. @@ -6513,7 +6775,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: GEOM.ListOfGO """ anObj = self.ShapesOp.GetGlueFaces(theShape, theTolerance) @@ -6540,6 +6802,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # without some faces. # # @ref tui_glue_faces "Example" + @ManageTransactions("ShapesOp") def MakeGlueFacesByList(self, theShape, theTolerance, theFaces, doKeepNonSolids=True, doGlueAllEdges=True, theName=None): """ @@ -6581,6 +6844,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing a copy of theShape without coincident edges. # # @ref tui_glue_edges "Example" + @ManageTransactions("ShapesOp") def MakeGlueEdges(self, theShape, theTolerance, theName=None): """ Replace coincident edges in theShape by one edge. @@ -6592,7 +6856,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing a copy of theShape without coincident edges. """ theTolerance,Parameters = ParseParameters(theTolerance) @@ -6614,6 +6878,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return GEOM.ListOfGO # # @ref tui_glue_edges "Example" + @ManageTransactions("ShapesOp") def GetGlueEdges(self, theShape, theTolerance, theName=None): """ Find coincident edges in theShape for possible gluing. @@ -6626,7 +6891,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: GEOM.ListOfGO """ anObj = self.ShapesOp.GetGlueEdges(theShape, theTolerance) @@ -6648,6 +6913,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # without some edges. # # @ref tui_glue_edges "Example" + @ManageTransactions("ShapesOp") def MakeGlueEdgesByList(self, theShape, theTolerance, theEdges, theName=None): """ Replace coincident edges in theShape by one edge @@ -6662,7 +6928,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing a copy of theShape without some edges. """ @@ -6704,11 +6970,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_fuse "Example" + @ManageTransactions("BoolOp") def MakeBoolean(self, theShape1, theShape2, theOperation, checkSelfInte=False, theName=None): """ Perform one of boolean operations on two given shapes. - Parameters: + Parameters: theShape1 First argument for boolean operation. theShape2 Second argument for boolean operation. theOperation Indicates the operation to be done: @@ -6729,7 +6996,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): To find all self-intersections please use CheckSelfIntersections() method. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestAll.py @@ -6764,7 +7031,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ Perform Common boolean operation on two given shapes. - Parameters: + Parameters: theShape1 First argument for boolean operation. theShape2 Second argument for boolean operation. checkSelfInte The flag that tells if the arguments should @@ -6783,7 +7050,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): To find all self-intersections please use CheckSelfIntersections() method. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestOthers.py @@ -6815,7 +7082,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ Perform Cut boolean operation on two given shapes. - Parameters: + Parameters: theShape1 First argument for boolean operation. theShape2 Second argument for boolean operation. checkSelfInte The flag that tells if the arguments should @@ -6834,9 +7101,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): To find all self-intersections please use CheckSelfIntersections() method. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. - + """ # Example: see GEOM_TestOthers.py # note: auto-publishing is done in self.MakeBoolean() @@ -6865,12 +7132,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_fuse "Example 1" # \n @ref swig_MakeCommon "Example 2" + @ManageTransactions("BoolOp") def MakeFuse(self, theShape1, theShape2, checkSelfInte=False, rmExtraEdges=False, theName=None): """ Perform Fuse boolean operation on two given shapes. - Parameters: + Parameters: theShape1 First argument for boolean operation. theShape2 Second argument for boolean operation. checkSelfInte The flag that tells if the arguments should @@ -6891,9 +7159,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): To find all self-intersections please use CheckSelfIntersections() method. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. - + """ # Example: see GEOM_TestOthers.py anObj = self.BoolOp.MakeFuse(theShape1, theShape2, @@ -6927,7 +7195,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ Perform Section boolean operation on two given shapes. - Parameters: + Parameters: theShape1 First argument for boolean operation. theShape2 Second argument for boolean operation. checkSelfInte The flag that tells if the arguments should @@ -6946,9 +7214,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): To find all self-intersections please use CheckSelfIntersections() method. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. - + """ # Example: see GEOM_TestOthers.py # note: auto-publishing is done in self.MakeBoolean() @@ -6976,12 +7244,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_fuse "Example 1" # \n @ref swig_MakeCommon "Example 2" + @ManageTransactions("BoolOp") def MakeFuseList(self, theShapesList, checkSelfInte=False, rmExtraEdges=False, theName=None): """ Perform Fuse boolean operation on the list of shapes. - Parameters: + Parameters: theShapesList Shapes to be fused. checkSelfInte The flag that tells if the arguments should be checked for self-intersection prior to @@ -7001,9 +7270,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): To find all self-intersections please use CheckSelfIntersections() method. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. - + """ # Example: see GEOM_TestOthers.py anObj = self.BoolOp.MakeFuseList(theShapesList, checkSelfInte, @@ -7032,11 +7301,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_common "Example 1" # \n @ref swig_MakeCommon "Example 2" + @ManageTransactions("BoolOp") def MakeCommonList(self, theShapesList, checkSelfInte=False, theName=None): """ Perform Common boolean operation on the list of shapes. - Parameters: + Parameters: theShapesList Shapes for Common operation. checkSelfInte The flag that tells if the arguments should be checked for self-intersection prior to @@ -7054,9 +7324,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): To find all self-intersections please use CheckSelfIntersections() method. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. - + """ # Example: see GEOM_TestOthers.py anObj = self.BoolOp.MakeCommonList(theShapesList, checkSelfInte) @@ -7085,11 +7355,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_cut "Example 1" # \n @ref swig_MakeCommon "Example 2" + @ManageTransactions("BoolOp") def MakeCutList(self, theMainShape, theShapesList, checkSelfInte=False, theName=None): """ Perform Cut boolean operation on one object and the list of tools. - Parameters: + Parameters: theMainShape The object of the operation. theShapesList The list of tools of the operation. checkSelfInte The flag that tells if the arguments should @@ -7108,9 +7379,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): To find all self-intersections please use CheckSelfIntersections() method. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. - + """ # Example: see GEOM_TestOthers.py anObj = self.BoolOp.MakeCutList(theMainShape, theShapesList, checkSelfInte) @@ -7156,13 +7427,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shapes. # # @ref tui_partition "Example" + @ManageTransactions("BoolOp") def MakePartition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[], KeepNonlimitShapes=0, theName=None): """ Perform partition operation. - Parameters: + Parameters: ListShapes Shapes to be intersected. ListTools Shapes to intersect theShapes. Limit Type of resulting shapes (see geompy.ShapeType) @@ -7180,11 +7452,11 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Each compound from ListShapes and ListTools will be exploded in order to avoid possible intersection between shapes from this compound. - + After implementation new version of PartitionAlgo (October 2006) other parameters are ignored by current functionality. They are kept in this function only for support old versions. - + Ignored parameters: ListKeepInside Shapes, outside which the results will be deleted. Each shape from theKeepInside must belong to theShapes also. @@ -7193,7 +7465,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): RemoveWebs If TRUE, perform Glue 3D algorithm. ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shapes. """ # Example: see GEOM_TestAll.py @@ -7235,6 +7507,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shapes. # # @ref swig_todo "Example" + @ManageTransactions("BoolOp") def MakePartitionNonSelfIntersectedShape(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["AUTO"], RemoveWebs=0, @@ -7246,7 +7519,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): compound contains nonintersected shapes. Performance will be better since intersection between shapes from compound is not performed. - Parameters: + Parameters: Description of all parameters as in method geompy.MakePartition. One additional parameter is provided: checkSelfInte The flag that tells if the arguments should @@ -7261,12 +7534,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): time-consuming operation that gives an impact on performance. To find all self-intersections please use CheckSelfIntersections() method. - + NOTE: Passed compounds (via ListShapes or via ListTools) have to consist of nonintersecting shapes. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shapes. """ if Limit == self.ShapeType["AUTO"]: @@ -7311,18 +7584,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_partition "Example" + @ManageTransactions("BoolOp") def MakeHalfPartition(self, theShape, thePlane, theName=None): """ Perform partition of the Shape with the Plane - Parameters: + Parameters: theShape Shape to be intersected. thePlane Tool shape, to intersect theShape. 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: + Returns: New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestAll.py @@ -7345,17 +7619,18 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theCopy Flag used to translate object itself or create a copy. # @return Translated @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or # new GEOM.GEOM_Object, containing the translated object if @a theCopy flag is @c True. + @ManageTransactions("TrsfOp") def TranslateTwoPoints(self, theObject, thePoint1, thePoint2, theCopy=False): """ Translate the given object along the vector, specified by its end points. - Parameters: + Parameters: theObject The object to be translated. thePoint1 Start point of translation vector. thePoint2 End point of translation vector. theCopy Flag used to translate object itself or create a copy. - Returns: + Returns: Translated theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or new GEOM.GEOM_Object, containing the translated object if theCopy flag is True. """ @@ -7379,12 +7654,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_translation "Example 1" # \n @ref swig_MakeTranslationTwoPoints "Example 2" + @ManageTransactions("TrsfOp") def MakeTranslationTwoPoints(self, theObject, thePoint1, thePoint2, theName=None): """ Translate the given object along the vector, specified by its end points, creating its copy before the translation. - Parameters: + Parameters: theObject The object to be translated. thePoint1 Start point of translation vector. thePoint2 End point of translation vector. @@ -7392,7 +7668,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the translated object. """ # Example: see GEOM_TestAll.py @@ -7409,16 +7685,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # new GEOM.GEOM_Object, containing the translated object if @a theCopy flag is @c True. # # @ref tui_translation "Example" + @ManageTransactions("TrsfOp") def TranslateDXDYDZ(self, theObject, theDX, theDY, theDZ, theCopy=False): """ Translate the given object along the vector, specified by its components. - Parameters: + Parameters: theObject The object to be translated. theDX,theDY,theDZ Components of translation vector. theCopy Flag used to translate object itself or create a copy. - Returns: + Returns: Translated theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or new GEOM.GEOM_Object, containing the translated object if theCopy flag is True. """ @@ -7443,19 +7720,20 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the translated object. # # @ref tui_translation "Example" + @ManageTransactions("TrsfOp") def MakeTranslation(self,theObject, theDX, theDY, theDZ, theName=None): """ Translate the given object along the vector, specified by its components, creating its copy before the translation. - Parameters: + Parameters: theObject The object to be translated. theDX,theDY,theDZ Components of translation vector. 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: + Returns: New GEOM.GEOM_Object, containing the translated object. """ # Example: see GEOM_TestAll.py @@ -7472,16 +7750,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theCopy Flag used to translate object itself or create a copy. # @return Translated @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or # new GEOM.GEOM_Object, containing the translated object if @a theCopy flag is @c True. + @ManageTransactions("TrsfOp") def TranslateVector(self, theObject, theVector, theCopy=False): """ Translate the given object along the given vector. - Parameters: + Parameters: theObject The object to be translated. theVector The translation vector. theCopy Flag used to translate object itself or create a copy. - Returns: + Returns: Translated theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or new GEOM.GEOM_Object, containing the translated object if theCopy flag is True. """ @@ -7503,19 +7782,20 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the translated object. # # @ref tui_translation "Example" + @ManageTransactions("TrsfOp") def MakeTranslationVector(self, theObject, theVector, theName=None): """ Translate the given object along the given vector, creating its copy before the translation. - Parameters: + Parameters: theObject The object to be translated. theVector The translation vector. 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: + Returns: New GEOM.GEOM_Object, containing the translated object. """ # Example: see GEOM_TestAll.py @@ -7533,17 +7813,18 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # new GEOM.GEOM_Object, containing the translated object if @a theCopy flag is @c True. # # @ref tui_translation "Example" + @ManageTransactions("TrsfOp") def TranslateVectorDistance(self, theObject, theVector, theDistance, theCopy=False): """ Translate the given object along the given vector on given distance. - Parameters: + Parameters: theObject The object to be translated. theVector The translation vector. theDistance The translation distance. theCopy Flag used to translate object itself or create a copy. - Returns: + Returns: Translated theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or new GEOM.GEOM_Object, containing the translated object if theCopy flag is True. """ @@ -7566,6 +7847,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the translated object. # # @ref tui_translation "Example" + @ManageTransactions("TrsfOp") def MakeTranslationVectorDistance(self, theObject, theVector, theDistance, theName=None): """ Translate the given object along the given vector on given distance, @@ -7579,7 +7861,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the translated object. """ # Example: see GEOM_TestAll.py @@ -7600,6 +7882,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # new GEOM.GEOM_Object, containing the rotated object if @a theCopy flag is @c True. # # @ref tui_rotation "Example" + @ManageTransactions("TrsfOp") def Rotate(self, theObject, theAxis, theAngle, theCopy=False): """ Rotate the given object around the given axis on the given angle. @@ -7630,7 +7913,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return anObj ## Rotate the given object around the given axis - # on the given angle, creating its copy before the rotatation. + # on the given angle, creating its copy before the rotation. # @param theObject The object to be rotated. # @param theAxis Rotation axis. # @param theAngle Rotation angle in radians. @@ -7641,6 +7924,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the rotated object. # # @ref tui_rotation "Example" + @ManageTransactions("TrsfOp") def MakeRotation(self, theObject, theAxis, theAngle, theName=None): """ Rotate the given object around the given axis @@ -7679,6 +7963,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theCopy Flag used to rotate object itself or create a copy. # @return Rotated @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or # new GEOM.GEOM_Object, containing the rotated object if @a theCopy flag is @c True. + @ManageTransactions("TrsfOp") def RotateThreePoints(self, theObject, theCentPoint, thePoint1, thePoint2, theCopy=False): """ Rotate given object around vector perpendicular to plane @@ -7715,6 +8000,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the rotated object. # # @ref tui_rotation "Example" + @ManageTransactions("TrsfOp") def MakeRotationThreePoints(self, theObject, theCentPoint, thePoint1, thePoint2, theName=None): """ Rotate given object around vector perpendicular to plane @@ -7746,6 +8032,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theCopy Flag used to scale object itself or create a copy. # @return Scaled @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or # new GEOM.GEOM_Object, containing the scaled object if @a theCopy flag is @c True. + @ManageTransactions("TrsfOp") def Scale(self, theObject, thePoint, theFactor, theCopy=False): """ Scale the given object by the specified factor. @@ -7757,7 +8044,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theFactor Scaling factor value. theCopy Flag used to scale object itself or create a copy. - Returns: + Returns: Scaled theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or new GEOM.GEOM_Object, containing the scaled object if theCopy flag is True. """ @@ -7783,6 +8070,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the scaled shape. # # @ref tui_scale "Example" + @ManageTransactions("TrsfOp") def MakeScaleTransform(self, theObject, thePoint, theFactor, theName=None): """ Scale the given object by the factor, creating its copy before the scaling. @@ -7796,7 +8084,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the scaled shape. """ # Example: see GEOM_TestAll.py @@ -7815,6 +8103,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theCopy Flag used to scale object itself or create a copy. # @return Scaled @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or # new GEOM.GEOM_Object, containing the scaled object if @a theCopy flag is @c True. + @ManageTransactions("TrsfOp") def ScaleAlongAxes(self, theObject, thePoint, theFactorX, theFactorY, theFactorZ, theCopy=False): """ Scale the given object by different factors along coordinate axes. @@ -7826,7 +8115,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theFactorX,theFactorY,theFactorZ Scaling factors along each axis. theCopy Flag used to scale object itself or create a copy. - Returns: + Returns: Scaled theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or new GEOM.GEOM_Object, containing the scaled object if theCopy flag is True. """ @@ -7855,6 +8144,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the scaled shape. # # @ref swig_scale "Example" + @ManageTransactions("TrsfOp") def MakeScaleAlongAxes(self, theObject, thePoint, theFactorX, theFactorY, theFactorZ, theName=None): """ Scale the given object by different factors along coordinate axes, @@ -7887,6 +8177,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theCopy Flag used to mirror object itself or create a copy. # @return Mirrored @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or # new GEOM.GEOM_Object, containing the mirrored object if @a theCopy flag is @c True. + @ManageTransactions("TrsfOp") def MirrorByPlane(self, theObject, thePlane, theCopy=False): """ Mirror an object relatively the given plane. @@ -7918,6 +8209,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the mirrored shape. # # @ref tui_mirror "Example" + @ManageTransactions("TrsfOp") def MakeMirrorByPlane(self, theObject, thePlane, theName=None): """ Create an object, symmetrical to the given one relatively the given plane. @@ -7944,6 +8236,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theCopy Flag used to mirror object itself or create a copy. # @return Mirrored @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or # new GEOM.GEOM_Object, containing the mirrored object if @a theCopy flag is @c True. + @ManageTransactions("TrsfOp") def MirrorByAxis(self, theObject, theAxis, theCopy=False): """ Mirror an object relatively the given axis. @@ -7975,6 +8268,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the mirrored shape. # # @ref tui_mirror "Example" + @ManageTransactions("TrsfOp") def MakeMirrorByAxis(self, theObject, theAxis, theName=None): """ Create an object, symmetrical to the given one relatively the given axis. @@ -7986,7 +8280,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the mirrored shape. """ # Example: see GEOM_TestAll.py @@ -8001,6 +8295,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theCopy Flag used to mirror object itself or create a copy. # @return Mirrored @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or # new GEOM.GEOM_Object, containing the mirrored object if @a theCopy flag is @c True. + @ManageTransactions("TrsfOp") def MirrorByPoint(self, theObject, thePoint, theCopy=False): """ Mirror an object relatively the given point. @@ -8033,6 +8328,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the mirrored shape. # # @ref tui_mirror "Example" + @ManageTransactions("TrsfOp") def MakeMirrorByPoint(self, theObject, thePoint, theName=None): """ Create an object, symmetrical @@ -8045,7 +8341,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the mirrored shape. """ # Example: see GEOM_TestAll.py @@ -8065,6 +8361,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theCopy Flag used to displace object itself or create a copy. # @return Displaced @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or # new GEOM.GEOM_Object, containing the displaced object if @a theCopy flag is @c True. + @ManageTransactions("TrsfOp") def Position(self, theObject, theStartLCS, theEndLCS, theCopy=False): """ Modify the Location of the given object by LCS, creating its copy before the setting. @@ -8107,6 +8404,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the displaced shape. # # @ref tui_modify_location "Example" + @ManageTransactions("TrsfOp") def MakePosition(self, theObject, theStartLCS, theEndLCS, theName=None): """ Modify the Location of the given object by LCS, creating its copy before the setting. @@ -8123,7 +8421,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the displaced shape. Example of usage: @@ -8149,6 +8447,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # new GEOM.GEOM_Object, containing the displaced shape if @a theCopy is @c True. # # @ref tui_modify_location "Example" + @ManageTransactions("TrsfOp") def PositionAlongPath(self,theObject, thePath, theDistance, theCopy, theReverse): """ Modify the Location of the given object by Path. @@ -8160,7 +8459,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theCopy is to create a copy objects if true. theReverse 0 - for usual direction, 1 - to reverse path direction. - Returns: + Returns: Displaced theObject (GEOM.GEOM_Object) if theCopy is False or new GEOM.GEOM_Object, containing the displaced shape if theCopy is True. @@ -8182,6 +8481,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # publication is switched on, default value is used for result name. # # @return New GEOM.GEOM_Object, containing the displaced shape. + @ManageTransactions("TrsfOp") def MakePositionAlongPath(self, theObject, thePath, theDistance, theReverse, theName=None): """ Modify the Location of the given object by Path, creating its copy before the operation. @@ -8195,7 +8495,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the displaced shape. """ # Example: see GEOM_TestAll.py @@ -8210,6 +8510,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theCopy Flag used to offset object itself or create a copy. # @return Modified @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or # new GEOM.GEOM_Object, containing the result of offset operation if @a theCopy flag is @c True. + @ManageTransactions("TrsfOp") def Offset(self, theObject, theOffset, theCopy=False): """ Offset given shape. @@ -8219,7 +8520,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theOffset Offset value. theCopy Flag used to offset object itself or create a copy. - Returns: + Returns: Modified theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or new GEOM.GEOM_Object, containing the result of offset operation if theCopy flag is True. """ @@ -8242,6 +8543,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the offset object. # # @ref tui_offset "Example" + @ManageTransactions("TrsfOp") def MakeOffset(self, theObject, theOffset, theName=None): """ Create new object as offset of the given one. @@ -8253,7 +8555,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the offset object. Example of usage: @@ -8279,6 +8581,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the projection. # # @ref tui_projection "Example" + @ManageTransactions("TrsfOp") def MakeProjection(self, theSource, theTarget, theName=None): """ Create new object as projection of the given one on a 2D surface. @@ -8290,7 +8593,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the projection. """ # Example: see GEOM_TestAll.py @@ -8298,7 +8601,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): RaiseIfFailed("ProjectShapeCopy", self.TrsfOp) self._autoPublish(anObj, theName, "projection") return anObj - + ## Create a projection projection of the given point on a wire or an edge. # If there are no solutions or there are 2 or more solutions It throws an # exception. @@ -8314,19 +8617,20 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # \n \a EdgeInWireIndex: The index of an edge in a wire. # # @ref tui_projection "Example" + @ManageTransactions("TrsfOp") def MakeProjectionOnWire(self, thePoint, theWire, theName=None): """ Create a projection projection of the given point on a wire or an edge. If there are no solutions or there are 2 or more solutions It throws an exception. - + Parameters: thePoint the point to be projected. theWire the wire. The edge is accepted as well. 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: [u, PointOnEdge, EdgeInWireIndex] u: The parameter of projection point on edge. @@ -8356,6 +8660,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # the shapes, obtained after each translation. # # @ref tui_multi_translation "Example" + @ManageTransactions("TrsfOp") def MakeMultiTranslation1D(self, theObject, theVector, theStep, theNbTimes, theName=None): """ Translate the given object along the given vector a given number times @@ -8369,7 +8674,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing compound of all the shapes, obtained after each translation. @@ -8400,6 +8705,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # the shapes, obtained after each translation. # # @ref tui_multi_translation "Example" + @ManageTransactions("TrsfOp") def MakeMultiTranslation2D(self, theObject, theVector1, theStep1, theNbTimes1, theVector2, theStep2, theNbTimes2, theName=None): """ @@ -8446,6 +8752,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # shapes, obtained after each rotation. # # @ref tui_multi_rotation "Example" + @ManageTransactions("TrsfOp") def MultiRotate1DNbTimes (self, theObject, theAxis, theNbTimes, theName=None): """ Rotate the given object around the given axis a given number times. @@ -8459,7 +8766,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing compound of all the shapes, obtained after each rotation. @@ -8488,6 +8795,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # shapes, obtained after each rotation. # # @ref tui_multi_rotation "Example" + @ManageTransactions("TrsfOp") def MultiRotate1DByStep(self, theObject, theAxis, theAngleStep, theNbTimes, theName=None): """ Rotate the given object around the given axis @@ -8502,7 +8810,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing compound of all the shapes, obtained after each rotation. @@ -8535,6 +8843,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # shapes, obtained after each transformation. # # @ref tui_multi_rotation "Example" + @ManageTransactions("TrsfOp") def MultiRotate2DNbTimes(self, theObject, theAxis, theNbTimes1, theRadialStep, theNbTimes2, theName=None): """ Rotate the given object around the @@ -8553,7 +8862,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing compound of all the shapes, obtained after each transformation. @@ -8587,6 +8896,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # shapes, obtained after each transformation. # # @ref tui_multi_rotation "Example" + @ManageTransactions("TrsfOp") def MultiRotate2DByStep (self, theObject, theAxis, theAngleStep, theNbTimes1, theRadialStep, theNbTimes2, theName=None): """ Rotate the given object around the @@ -8606,7 +8916,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing compound of all the shapes, obtained after each transformation. @@ -8663,7 +8973,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): def MakeMultiRotation2DNbTimes(self, aShape, aDir, aPoint, nbtimes1, aStep, nbtimes2, theName=None): """ The same, as MultiRotate2DNbTimes(), but axis is given by direction and point - + Example of usage: pz = geompy.MakeVertex(0, 0, 100) vy = geompy.MakeVectorDXDYDZ(0, 100, 0) @@ -8681,7 +8991,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): def MakeMultiRotation2DByStep(self, aShape, aDir, aPoint, anAngle, nbtimes1, aStep, nbtimes2, theName=None): """ The same, as MultiRotate2DByStep(), but axis is given by direction and point - + Example of usage: pz = geompy.MakeVertex(0, 0, 100) vy = geompy.MakeVectorDXDYDZ(0, 100, 0) @@ -8709,6 +9019,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## The same, as MultiRotate2DByStep(), but theAngle is in degrees. # This method is DEPRECATED. Use MultiRotate2DByStep() instead. + @ManageTransactions("TrsfOp") def MultiRotate2D(self, theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2, theName=None): """ The same, as MultiRotate2DByStep(), but theAngle is in degrees. @@ -8749,7 +9060,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ The same, as MultiRotate2D(), but axis is given by direction and point This method is DEPRECATED. Use MakeMultiRotation2DByStep instead. - + Example of usage: pz = geompy.MakeVertex(0, 0, 100) vy = geompy.MakeVectorDXDYDZ(0, 100, 0) @@ -8778,6 +9089,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_fillet "Example 1" # \n @ref swig_MakeFilletAll "Example 2" + @ManageTransactions("LocalOp") def MakeFilletAll(self, theShape, theR, theName=None): """ Perform a fillet on all edges of the given shape. @@ -8789,10 +9101,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. - Example of usage: + Example of usage: filletall = geompy.MakeFilletAll(prism, 10.) """ # Example: see GEOM_TestOthers.py @@ -8817,6 +9129,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_fillet "Example" + @ManageTransactions("LocalOp") def MakeFillet(self, theShape, theR, theShapeType, theListShapes, theName=None): """ Perform a fillet on the specified edges/faces of the given shape @@ -8833,7 +9146,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. Example of usage: @@ -8860,6 +9173,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return anObj ## The same that MakeFillet() but with two Fillet Radius R1 and R2 + @ManageTransactions("LocalOp") def MakeFilletR1R2(self, theShape, theR1, theR2, theShapeType, theListShapes, theName=None): """ The same that geompy.MakeFillet but with two Fillet Radius R1 and R2 @@ -8906,6 +9220,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_fillet2d "Example" + @ManageTransactions("LocalOp") def MakeFillet1D(self, theShape, theR, theListOfVertexes, doIgnoreSecantVertices = True, theName=None): """ Perform a fillet on the specified edges of the given shape @@ -8928,10 +9243,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): The list of vertices could be empty,in this case fillet will done done at all vertices in wire - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. - Example of usage: + Example of usage: # create wire Wire_1 = geompy.MakeWire([Edge_12, Edge_7, Edge_11, Edge_6, Edge_1,Edge_4]) # make fillet at given wire vertices with giver radius @@ -8958,6 +9273,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_fillet2d "Example" + @ManageTransactions("LocalOp") def MakeFillet2D(self, theShape, theR, theListOfVertexes, theName=None): """ Perform a fillet at the specified vertices of the given face/shell. @@ -8972,7 +9288,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. Example of usage: @@ -8998,6 +9314,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_chamfer "Example 1" # \n @ref swig_MakeChamferAll "Example 2" + @ManageTransactions("LocalOp") def MakeChamferAll(self, theShape, theD, theName=None): """ Perform a symmetric chamfer on all edges of the given shape. @@ -9009,7 +9326,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. Example of usage: @@ -9038,6 +9355,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_chamfer "Example" + @ManageTransactions("LocalOp") def MakeChamferEdge(self, theShape, theD1, theD2, theFace1, theFace2, theName=None): """ Perform a chamfer on edges, common to the specified faces, @@ -9055,7 +9373,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. Example of usage: @@ -9084,6 +9402,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @note Global index of sub-shape can be obtained, using method GetSubShapeID(). # # @return New GEOM.GEOM_Object, containing the result shape. + @ManageTransactions("LocalOp") def MakeChamferEdgeAD(self, theShape, theD, theAngle, theFace1, theFace2, theName=None): """ Perform a chamfer on edges @@ -9100,7 +9419,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. Example of usage: @@ -9139,6 +9458,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_chamfer "Example" + @ManageTransactions("LocalOp") def MakeChamferFaces(self, theShape, theD1, theD2, theFaces, theName=None): """ Perform a chamfer on all edges of the specified faces, @@ -9154,10 +9474,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): 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. - + Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID(). - Returns: + Returns: New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestAll.py @@ -9172,6 +9492,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # theAngle is Angle of chamfer (angle in radians or a name of variable which defines angle in degrees) # # @ref swig_FilletChamfer "Example" + @ManageTransactions("LocalOp") def MakeChamferFacesAD(self, theShape, theD, theAngle, theFaces, theName=None): """ The Same that geompy.MakeChamferFaces but with params theD is chamfer lenght and @@ -9201,11 +9522,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref swig_FilletChamfer "Example" + @ManageTransactions("LocalOp") def MakeChamferEdges(self, theShape, theD1, theD2, theEdges, theName=None): """ Perform a chamfer on edges, with distance D1 on the first specified face (if several for one edge) - + Parameters: theShape Shape, to perform chamfer on. theD1,theD2 Chamfer size @@ -9226,6 +9548,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## The Same that MakeChamferEdges() but with params theD is chamfer lenght and # theAngle is Angle of chamfer (angle in radians or a name of variable which defines angle in degrees) + @ManageTransactions("LocalOp") def MakeChamferEdgesAD(self, theShape, theD, theAngle, theEdges, theName=None): """ The Same that geompy.MakeChamferEdges but with params theD is chamfer lenght and @@ -9258,9 +9581,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): else: anObj = self.MakeChamferFaces(aShape,d1,d2,ListShape,theName) return anObj - + ## Remove material from a solid by extrusion of the base shape on the given distance. - # @param theInit Shape to remove material from. It must be a solid or + # @param theInit Shape to remove material from. It must be a solid or # a compound made of a single solid. # @param theBase Closed edge or wire defining the base shape to be extruded. # @param theH Prism dimension along the normal to theBase @@ -9269,9 +9592,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # 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 initial shape with removed material + # @return New GEOM.GEOM_Object, containing the initial shape with removed material # # @ref tui_creation_prism "Example" + @ManageTransactions("PrimOp") def MakeExtrudedCut(self, theInit, theBase, theH, theAngle, theName=None): """ Add material to a solid by extrusion of the base shape on the given distance. @@ -9294,10 +9618,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): RaiseIfFailed("MakeExtrudedBoss", self.PrimOp) #anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "extrudedCut") - return anObj - + return anObj + ## Add material to a solid by extrusion of the base shape on the given distance. - # @param theInit Shape to add material to. It must be a solid or + # @param theInit Shape to add material to. It must be a solid or # a compound made of a single solid. # @param theBase Closed edge or wire defining the base shape to be extruded. # @param theH Prism dimension along the normal to theBase @@ -9306,9 +9630,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # 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 initial shape with added material + # @return New GEOM.GEOM_Object, containing the initial shape with added material # # @ref tui_creation_prism "Example" + @ManageTransactions("PrimOp") def MakeExtrudedBoss(self, theInit, theBase, theH, theAngle, theName=None): """ Add material to a solid by extrusion of the base shape on the given distance. @@ -9331,7 +9656,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): RaiseIfFailed("MakeExtrudedBoss", self.PrimOp) #anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "extrudedBoss") - return anObj + return anObj # end of l3_local ## @} @@ -9353,12 +9678,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # by a plane, corresponding to water level. # # @ref tui_archimede "Example" + @ManageTransactions("LocalOp") def Archimede(self, theShape, theWeight, theWaterDensity, theMeshDeflection, theName=None): """ Perform an Archimde operation on the given shape with given parameters. The object presenting the resulting face is returned. - Parameters: + Parameters: theShape Shape to be put in water. theWeight Weight og the shape. theWaterDensity Density of the water. @@ -9367,7 +9693,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing a section of theShape by a plane, corresponding to water level. """ @@ -9390,6 +9716,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return [x, y, z] # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def PointCoordinates(self,Point): """ Get point coordinates @@ -9400,8 +9727,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # Example: see GEOM_TestMeasures.py aTuple = self.MeasuOp.PointCoordinates(Point) RaiseIfFailed("PointCoordinates", self.MeasuOp) - return aTuple - + return aTuple + ## Get vector coordinates # @return [x, y, z] # @@ -9416,7 +9743,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): p1=self.GetFirstVertex(Vector) p2=self.GetLastVertex(Vector) - + X1=self.PointCoordinates(p1) X2=self.PointCoordinates(p2) @@ -9428,31 +9755,31 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_measurement_tools_page "Example" def CrossProduct(self, Vector1, Vector2): - """ + """ Compute cross product - + Returns: vector w=u^v """ u=self.VectorCoordinates(Vector1) v=self.VectorCoordinates(Vector2) w=self.MakeVectorDXDYDZ(u[1]*v[2]-u[2]*v[1], u[2]*v[0]-u[0]*v[2], u[0]*v[1]-u[1]*v[0]) - + return w - + ## Compute cross product # @return dot product p=u.v # # @ref tui_measurement_tools_page "Example" def DotProduct(self, Vector1, Vector2): - """ + """ Compute cross product - + Returns: dot product p=u.v """ u=self.VectorCoordinates(Vector1) v=self.VectorCoordinates(Vector2) p=u[0]*v[0]+u[1]*v[1]+u[2]*v[2] - + return p @@ -9465,12 +9792,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # theVolume: Volume of the given shape. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def BasicProperties(self,theShape): """ Get summarized length of all wires, area of surface and volume of the given shape. - Parameters: + Parameters: theShape Shape to define properties of. Returns: @@ -9493,11 +9821,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # Zmin,Zmax: Limits of shape along OZ axis. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def BoundingBox (self, theShape, precise=False): """ Get parameters of bounding box of the given shape - Parameters: + Parameters: theShape Shape to obtain bounding box of. precise TRUE for precise computation; FALSE for fast one. @@ -9522,11 +9851,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created box. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def MakeBoundingBox (self, theShape, precise=False, theName=None): """ Get bounding box of the given shape - Parameters: + Parameters: theShape Shape to obtain bounding box of. precise TRUE for precise computation; FALSE for fast one. theName Object name; when specified, this parameter is used @@ -9549,11 +9879,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # Ix,Iy,Iz: Moments of inertia of the given shape. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def Inertia(self,theShape): """ Get inertia matrix and moments of inertia of theShape. - Parameters: + Parameters: theShape Shape to calculate inertia of. Returns: @@ -9571,11 +9902,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param coords list of points coordinates [x1, y1, z1, x2, y2, z2, ...] # @param tolerance to be used (default is 1.0e-7) # @return list_of_boolean = [res1, res2, ...] + @ManageTransactions("MeasuOp") def AreCoordsInside(self, theShape, coords, tolerance=1.e-7): """ Get if coords are included in the shape (ST_IN or ST_ON) - - Parameters: + + Parameters: theShape Shape coords list of points coordinates [x1, y1, z1, x2, y2, z2, ...] tolerance to be used (default is 1.0e-7) @@ -9590,14 +9922,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Value of the minimal distance between the given shapes. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def MinDistance(self, theShape1, theShape2): """ Get minimal distance between the given shapes. - - Parameters: + + Parameters: theShape1,theShape2 Shapes to find minimal distance between. - Returns: + Returns: Value of the minimal distance between the given shapes. """ # Example: see GEOM_TestMeasures.py @@ -9611,14 +9944,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # [Distance, DX, DY, DZ]. # # @ref swig_all_measure "Example" + @ManageTransactions("MeasuOp") def MinDistanceComponents(self, theShape1, theShape2): """ Get minimal distance between the given shapes. - Parameters: + Parameters: theShape1,theShape2 Shapes to find minimal distance between. - Returns: + Returns: Value of the minimal distance between the given shapes, in form of list [Distance, DX, DY, DZ] """ @@ -9634,14 +9968,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # solutions) and a list of (X, Y, Z) coordinates for all couples of points. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def ClosestPoints (self, theShape1, theShape2): """ Get closest points of the given shapes. - Parameters: + Parameters: theShape1,theShape2 Shapes to find closest points of. - Returns: + Returns: The number of found solutions (-1 in case of infinite number of solutions) and a list of (X, Y, Z) coordinates for all couples of points. """ @@ -9657,18 +9992,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Value of the angle between the given shapes in degrees. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def GetAngle(self, theShape1, theShape2): """ Get angle between the given shapes in degrees. - Parameters: + Parameters: theShape1,theShape2 Lines or linear edges to find angle between. Note: If both arguments are vectors, the angle is computed in accordance with their orientations, otherwise the minimum angle is computed. - Returns: + Returns: Value of the angle between the given shapes in degrees. """ # Example: see GEOM_TestMeasures.py @@ -9683,19 +10019,20 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Value of the angle between the given shapes in radians. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def GetAngleRadians(self, theShape1, theShape2): """ Get angle between the given shapes in radians. - Parameters: + Parameters: theShape1,theShape2 Lines or linear edges to find angle between. - + Note: If both arguments are vectors, the angle is computed in accordance with their orientations, otherwise the minimum angle is computed. - Returns: + Returns: Value of the angle between the given shapes in radians. """ # Example: see GEOM_TestMeasures.py @@ -9710,16 +10047,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Value of the angle between the given vectors in degrees. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def GetAngleVectors(self, theShape1, theShape2, theFlag = True): """ Get angle between the given vectors in degrees. - Parameters: + Parameters: theShape1,theShape2 Vectors to find angle between. theFlag If True, the normal vector is defined by the two vectors cross, if False, the opposite vector to the normal vector is used. - Returns: + Returns: Value of the angle between the given vectors in degrees. """ anAngle = self.MeasuOp.GetAngleBtwVectors(theShape1, theShape2) @@ -9733,12 +10071,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ Get angle between the given vectors in radians. - Parameters: + Parameters: theShape1,theShape2 Vectors to find angle between. theFlag If True, the normal vector is defined by the two vectors cross, if False, the opposite vector to the normal vector is used. - Returns: + Returns: Value of the angle between the given vectors in radians. """ anAngle = self.GetAngleVectors(theShape1, theShape2, theFlag)*math.pi/180. @@ -9755,15 +10093,16 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return radius of curvature of \a theCurve. # # @ref swig_todo "Example" + @ManageTransactions("MeasuOp") def CurveCurvatureByParam(self, theCurve, theParam): """ Measure curvature of a curve at a point, set by parameter. - Parameters: + Parameters: theCurve a curve. theParam parameter. - Returns: + Returns: radius of curvature of theCurve. """ # Example: see GEOM_TestMeasures.py @@ -9777,16 +10116,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return radius of curvature of \a theCurve. # # @ref swig_todo "Example" + @ManageTransactions("MeasuOp") def CurveCurvatureByPoint(self, theCurve, thePoint): """ Measure curvature of a curve at a point. - Parameters: + Parameters: theCurve a curve. thePoint given point. - Returns: - radius of curvature of theCurve. + Returns: + radius of curvature of theCurve. """ aCurv = self.MeasuOp.CurveCurvatureByPoint(theCurve,thePoint) RaiseIfFailed("CurveCurvatureByPoint", self.MeasuOp) @@ -9805,16 +10145,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return max radius of curvature of theSurf. # ## @ref swig_todo "Example" + @ManageTransactions("MeasuOp") def MaxSurfaceCurvatureByParam(self, theSurf, theUParam, theVParam): """ Measure max radius of curvature of surface. - Parameters: + Parameters: theSurf the given surface. theUParam Value of U-parameter on the referenced surface. theVParam Value of V-parameter on the referenced surface. - - Returns: + + Returns: max radius of curvature of theSurf. """ # Example: see GEOM_TestMeasures.py @@ -9828,16 +10169,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return max radius of curvature of theSurf. # ## @ref swig_todo "Example" + @ManageTransactions("MeasuOp") def MaxSurfaceCurvatureByPoint(self, theSurf, thePoint): """ Measure max radius of curvature of surface in the given point. - Parameters: + Parameters: theSurf the given surface. thePoint given point. - - Returns: - max radius of curvature of theSurf. + + Returns: + max radius of curvature of theSurf. """ aSurf = self.MeasuOp.MaxSurfaceCurvatureByPoint(theSurf,thePoint) RaiseIfFailed("MaxSurfaceCurvatureByPoint", self.MeasuOp) @@ -9848,18 +10190,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theUParam Value of U-parameter on the referenced surface. # @param theVParam Value of V-parameter on the referenced surface. # @return min radius of curvature of theSurf. - # + # ## @ref swig_todo "Example" + @ManageTransactions("MeasuOp") def MinSurfaceCurvatureByParam(self, theSurf, theUParam, theVParam): """ Measure min radius of curvature of surface. - Parameters: + Parameters: theSurf the given surface. theUParam Value of U-parameter on the referenced surface. theVParam Value of V-parameter on the referenced surface. - - Returns: + + Returns: Min radius of curvature of theSurf. """ aSurf = self.MeasuOp.MinSurfaceCurvatureByParam(theSurf,theUParam,theVParam) @@ -9872,16 +10215,17 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return min radius of curvature of theSurf. # ## @ref swig_todo "Example" + @ManageTransactions("MeasuOp") def MinSurfaceCurvatureByPoint(self, theSurf, thePoint): """ Measure min radius of curvature of surface in the given point. - Parameters: + Parameters: theSurf the given surface. thePoint given point. - - Returns: - Min radius of curvature of theSurf. + + Returns: + Min radius of curvature of theSurf. """ aSurf = self.MeasuOp.MinSurfaceCurvatureByPoint(theSurf,thePoint) RaiseIfFailed("MinSurfaceCurvatureByPoint", self.MeasuOp) @@ -9896,14 +10240,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # VertMin,VertMax: Min and max tolerances of the vertices. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def Tolerance(self,theShape): """ Get min and max tolerances of sub-shapes of theShape - Parameters: + Parameters: theShape Shape, to get tolerances of. - Returns: + Returns: [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax] FaceMin,FaceMax: Min and max tolerances of the faces. EdgeMin,EdgeMax: Min and max tolerances of the edges. @@ -9919,6 +10264,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Description of the given shape. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def WhatIs(self,theShape): """ Obtain description of the given shape (number of sub-shapes of each type) @@ -10005,6 +10351,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def MakeCDG(self, theShape, theName=None): """ Get a point, situated at the centre of mass of theShape. @@ -10034,6 +10381,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created vertex. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def GetVertexByIndex(self, theShape, theIndex, theName=None): """ Get a vertex sub-shape by index depended with orientation. @@ -10073,14 +10421,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the created vertex. """ # Example: see GEOM_TestMeasures.py # note: auto-publishing is done in self.GetVertexByIndex() - anObj = self.GetVertexByIndex(theShape, 0, theName) - RaiseIfFailed("GetFirstVertex", self.MeasuOp) - return anObj + return self.GetVertexByIndex(theShape, 0, theName) ## Get the last vertex of wire/edge depended orientation. # @param theShape Shape to find last vertex. @@ -10095,21 +10441,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ Get the last vertex of wire/edge depended orientation. - Parameters: + Parameters: theShape Shape to find last vertex. 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: + Returns: New GEOM.GEOM_Object, containing the created vertex. """ # Example: see GEOM_TestMeasures.py - nb_vert = self.ShapesOp.NumberOfSubShapes(theShape, self.ShapeType["VERTEX"]) + nb_vert = self.NumberOfSubShapes(theShape, self.ShapeType["VERTEX"]) # note: auto-publishing is done in self.GetVertexByIndex() - anObj = self.GetVertexByIndex(theShape, (nb_vert-1), theName) - RaiseIfFailed("GetLastVertex", self.MeasuOp) - return anObj + return self.GetVertexByIndex(theShape, (nb_vert-1), theName) ## Get a normale to the given face. If the point is not given, # the normale is calculated at the center of mass. @@ -10122,19 +10466,20 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created vector. # # @ref swig_todo "Example" + @ManageTransactions("MeasuOp") def GetNormal(self, theFace, theOptionalPoint = None, theName=None): """ Get a normale to the given face. If the point is not given, the normale is calculated at the center of mass. - - Parameters: + + Parameters: theFace Face to define normale of. theOptionalPoint Point to compute the normale at. 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: + Returns: New GEOM.GEOM_Object, containing the created vector. """ # Example: see GEOM_TestMeasures.py @@ -10152,6 +10497,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # Otherwise doesn't return anything. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def PrintShapeErrors(self, theShape, theShapeErrors, theReturnStatus = 0): """ Print shape errors obtained from CheckShape. @@ -10191,11 +10537,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # returned along with IsValid flag. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def CheckShape(self,theShape, theIsCheckGeom = 0, theReturnStatus = 0): """ Check a topology of the given shape. - Parameters: + Parameters: theShape Shape to check validity of. theIsCheckGeom If FALSE, only the shape's topology will be checked, if TRUE, the shape's geometry will be checked also. @@ -10206,7 +10553,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): If 2 IsValid flag and the list of error data is returned. - Returns: + Returns: TRUE, if the shape "seems to be valid". If theShape is invalid, prints a description of problem. If theReturnStatus is equal to 1 the description is returned @@ -10237,14 +10584,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return TRUE, if the shape contains no self-intersections. # # @ref tui_measurement_tools_page "Example" + @ManageTransactions("MeasuOp") def CheckSelfIntersections(self, theShape): """ Detect self-intersections in the given shape. - Parameters: + Parameters: theShape Shape to check. - Returns: + Returns: TRUE, if the shape contains no self-intersections. """ # Example: see GEOM_TestMeasures.py @@ -10265,6 +10613,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # Xx,Xy,Xz: Coordinates of shape's LCS X direction. # # @ref swig_todo "Example" + @ManageTransactions("MeasuOp") def GetPosition(self,theShape): """ Get position (LCS) of theShape. @@ -10272,10 +10621,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Axes of the LCS are obtained from shape's location or, if the shape is a planar face, from position of its plane. - Parameters: + Parameters: theShape Shape to calculate position of. - Returns: + Returns: [Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz]. Ox,Oy,Oz: Coordinates of shape's LCS origin. Zx,Zy,Zz: Coordinates of shape's LCS normal(main) direction. @@ -10295,11 +10644,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # or \a theDoubles list depends on the kind() of the shape. # # @ref swig_todo "Example" + @ManageTransactions("MeasuOp") def KindOfShape(self,theShape): """ Get kind of theShape. - - Parameters: + + Parameters: theShape Shape to get a kind of. Returns: @@ -10328,14 +10678,40 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return aKindTuple + ## Returns the string that describes if the shell is good for solid. + # This is a support method for MakeSolid. + # + # @param theShell the shell to be checked. + # @return Returns a string that describes the shell validity for + # solid construction. + @ManageTransactions("MeasuOp") + def _IsGoodForSolid(self, theShell): + """ + Returns the string that describes if the shell is good for solid. + This is a support method for MakeSolid. + + Parameter: + theShell the shell to be checked. + + Returns: + Returns a string that describes the shell validity for + solid construction. + """ + aDescr = self.MeasuOp.IsGoodForSolid(theShell) + return aDescr + # end of l2_measure ## @} ## @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. @@ -10354,11 +10730,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # material groups are not automatically published. # # @ref swig_Import_Export "Example" + @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. + 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. @@ -10380,6 +10760,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) @@ -10394,157 +10778,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" - 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" - 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. @@ -10556,6 +10792,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing the shape, read from theStream. # # @ref swig_Import_Export "Example" + @ManageTransactions("InsertOp") def RestoreShape (self, theStream, theName=None): """ Read a shape from the binary stream, containing its bounding representation (BRep). @@ -10563,7 +10800,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Note: shape.GetShapeStream() method can be used to obtain the shape's BRep stream. - Parameters: + Parameters: theStream The BRep binary stream. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic @@ -10579,6 +10816,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. @@ -10586,10 +10827,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # geompy.InsertOp.ExportTranslators()[0] method. # # @ref swig_Import_Export "Example" + @ManageTransactions("InsertOp") def Export(self, theObject, theFileName, theFormatName): """ 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. + Parameters: theObject Shape to be stored in the file. theFileName Name of the file to store the given shape in. @@ -10598,42 +10843,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 ## @} @@ -10650,21 +10869,22 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_building_by_blocks_page "Example" + @ManageTransactions("BlocksOp") def MakeQuad(self, E1, E2, E3, E4, theName=None): """ Create a quadrangle face from four edges. Order of Edges is not important. It is not necessary that edges share the same vertex. - Parameters: + Parameters: E1,E2,E3,E4 Edges for the face bound. 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: + Returns: New GEOM.GEOM_Object, containing the created face. - Example of usage: + Example of usage: qface1 = geompy.MakeQuad(edge1, edge2, edge3, edge4) """ # Example: see GEOM_Spanner.py @@ -10683,20 +10903,21 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_building_by_blocks_page "Example" + @ManageTransactions("BlocksOp") def MakeQuad2Edges(self, E1, E2, theName=None): """ Create a quadrangle face on two edges. The missing edges will be built by creating the shortest ones. - Parameters: + Parameters: E1,E2 Two opposite edges for the face. 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: + Returns: New GEOM.GEOM_Object, containing the created face. - + Example of usage: # create vertices p1 = geompy.MakeVertex( 0., 0., 0.) @@ -10726,18 +10947,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_building_by_blocks_page "Example 1" # \n @ref swig_MakeQuad4Vertices "Example 2" + @ManageTransactions("BlocksOp") def MakeQuad4Vertices(self, V1, V2, V3, V4, theName=None): """ Create a quadrangle face with specified corners. The missing edges will be built by creating the shortest ones. - Parameters: + Parameters: V1,V2,V3,V4 Corner vertices for the face. 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: + Returns: New GEOM.GEOM_Object, containing the created face. Example of usage: @@ -10766,18 +10988,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_building_by_blocks_page "Example 1" # \n @ref swig_MakeHexa "Example 2" + @ManageTransactions("BlocksOp") def MakeHexa(self, F1, F2, F3, F4, F5, F6, theName=None): """ Create a hexahedral solid, bounded by the six given faces. Order of faces is not important. It is not necessary that Faces share the same edge. - Parameters: + Parameters: F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid. 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: + Returns: New GEOM.GEOM_Object, containing the created solid. Example of usage: @@ -10800,12 +11023,13 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_building_by_blocks_page "Example 1" # \n @ref swig_MakeHexa2Faces "Example 2" + @ManageTransactions("BlocksOp") def MakeHexa2Faces(self, F1, F2, theName=None): """ Create a hexahedral solid between two given faces. The missing faces will be built by creating the smallest ones. - Parameters: + Parameters: F1,F2 Two opposite faces for the hexahedral solid. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic @@ -10841,11 +11065,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found vertex. # # @ref swig_GetPoint "Example" + @ManageTransactions("BlocksOp") def GetPoint(self, theShape, theX, theY, theZ, theEpsilon, theName=None): """ Get a vertex, found in the given shape by its coordinates. - Parameters: + Parameters: theShape Block or a compound of blocks. theX,theY,theZ Coordinates of the sought vertex. theEpsilon Maximum allowed distance between the resulting @@ -10854,7 +11079,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the found vertex. Example of usage: @@ -10876,11 +11101,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found vertex. # # @ref swig_GetVertexNearPoint "Example" + @ManageTransactions("BlocksOp") def GetVertexNearPoint(self, theShape, thePoint, theName=None): """ Find a vertex of the given shape, which has minimal distance to the given point. - Parameters: + Parameters: theShape Any shape. thePoint Point, close to the desired vertex. theName Object name; when specified, this parameter is used @@ -10910,11 +11136,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found edge. # # @ref swig_GetEdge "Example" + @ManageTransactions("BlocksOp") def GetEdge(self, theShape, thePoint1, thePoint2, theName=None): """ Get an edge, found in the given shape by two given vertices. - Parameters: + Parameters: theShape Block or a compound of blocks. thePoint1,thePoint2 Points, close to the ends of the desired edge. theName Object name; when specified, this parameter is used @@ -10940,11 +11167,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found edge. # # @ref swig_GetEdgeNearPoint "Example" + @ManageTransactions("BlocksOp") def GetEdgeNearPoint(self, theShape, thePoint, theName=None): """ Find an edge of the given shape, which has minimal distance to the given point. - Parameters: + Parameters: theShape Block or a compound of blocks. thePoint Point, close to the desired edge. theName Object name; when specified, this parameter is used @@ -10970,6 +11198,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found face. # # @ref swig_todo "Example" + @ManageTransactions("BlocksOp") def GetFaceByPoints(self, theShape, thePoint1, thePoint2, thePoint3, thePoint4, theName=None): """ Returns a face, found in the given shape by four given corner vertices. @@ -11000,6 +11229,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found face. # # @ref swig_todo "Example" + @ManageTransactions("BlocksOp") def GetFaceByEdges(self, theShape, theEdge1, theEdge2, theName=None): """ Get a face of block, found in the given shape by two given edges. @@ -11030,6 +11260,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found face. # # @ref swig_GetOppositeFace "Example" + @ManageTransactions("BlocksOp") def GetOppositeFace(self, theBlock, theFace, theName=None): """ Find a face, opposite to the given one in the given block. @@ -11041,7 +11272,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM.GEOM_Object, containing the found face. """ # Example: see GEOM_Spanner.py @@ -11060,6 +11291,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found face. # # @ref swig_GetFaceNearPoint "Example" + @ManageTransactions("BlocksOp") def GetFaceNearPoint(self, theShape, thePoint, theName=None): """ Find a face of the given shape, which has minimal distance to the given point. @@ -11090,6 +11322,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found face. # # @ref swig_todo "Example" + @ManageTransactions("BlocksOp") def GetFaceByNormale(self, theBlock, theVector, theName=None): """ Find a face of block, whose outside normale has minimal angle with the given vector. @@ -11125,6 +11358,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM_Object, containing a group of all found shapes. # # @ref swig_GetShapesNearPoint "Example" + @ManageTransactions("BlocksOp") def GetShapesNearPoint(self, theShape, thePoint, theShapeType, theTolerance = 1e-07, theName=None): """ Find all sub-shapes of type theShapeType of the given shape, @@ -11169,6 +11403,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_measurement_tools_page "Example 1" # \n @ref swig_CheckCompoundOfBlocks "Example 2" + @ManageTransactions("BlocksOp") def CheckCompoundOfBlocks(self,theCompound): """ Check, if the compound of blocks is given. @@ -11184,7 +11419,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Returns: TRUE, if the given shape is a compound of blocks. - If theCompound is not valid, prints all discovered errors. + If theCompound is not valid, prints all discovered errors. """ # Example: see GEOM_Spanner.py (IsValid, BCErrors) = self.BlocksOp.CheckCompoundOfBlocks(theCompound) @@ -11207,6 +11442,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_measurement_tools_page "Example 1" # \n @ref swig_GetNonBlocks "Example 2" + @ManageTransactions("BlocksOp") def GetNonBlocks (self, theShape, theName=None): """ Retrieve all non blocks solids and faces from theShape. @@ -11245,6 +11481,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Improved shape. # # @ref swig_RemoveExtraEdges "Example" + @ManageTransactions("BlocksOp") def RemoveExtraEdges(self, theShape, doUnionFaces=False, theName=None): """ Remove all seam and degenerated edges from theShape. @@ -11259,7 +11496,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: Improved shape. """ # Example: see GEOM_TestOthers.py @@ -11282,6 +11519,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Improved shape. # # @ref swig_UnionFaces "Example" + @ManageTransactions("BlocksOp") def UnionFaces(self, theShape, theName=None): """ Performs union faces of theShape. @@ -11295,7 +11533,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: Improved shape. """ # Example: see GEOM_TestOthers.py @@ -11315,6 +11553,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return Improved compound. # # @ref swig_CheckAndImprove "Example" + @ManageTransactions("BlocksOp") def CheckAndImprove(self, theShape, theName=None): """ Check, if the given shape is a blocks compound. @@ -11329,7 +11568,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: Improved compound. """ # Example: see GEOM_TestOthers.py @@ -11358,6 +11597,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_explode_on_blocks "Example 1" # \n @ref swig_MakeBlockExplode "Example 2" + @ManageTransactions("BlocksOp") def MakeBlockExplode(self, theCompound, theMinNbFaces, theMaxNbFaces, theName=None): """ Get all the blocks, contained in the given compound. @@ -11373,7 +11613,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Note: If theMaxNbFaces = 0, the maximum number of faces is not restricted. - Returns: + Returns: List of GEOM.GEOM_Object, containing the retrieved blocks. """ # Example: see GEOM_TestOthers.py @@ -11397,6 +11637,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found block. # # @ref swig_todo "Example" + @ManageTransactions("BlocksOp") def GetBlockNearPoint(self, theCompound, thePoint, theName=None): """ Find block, containing the given point inside its volume or on boundary. @@ -11428,6 +11669,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the found block. # # @ref swig_GetBlockByParts "Example" + @ManageTransactions("BlocksOp") def GetBlockByParts(self, theCompound, theParts, theName=None): """ Find block, containing all the elements, passed as the parts, or maximum quantity of them. @@ -11439,7 +11681,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. - Returns: + Returns: New GEOM_Object, containing the found block. """ # Example: see GEOM_TestOthers.py @@ -11458,6 +11700,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of GEOM.GEOM_Object, containing the found blocks. # # @ref swig_todo "Example" + @ManageTransactions("BlocksOp") def GetBlocksByParts(self, theCompound, theParts, theName=None): """ Return all blocks, containing all the elements, passed as the parts. @@ -11493,6 +11736,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_multi_transformation "Example" + @ManageTransactions("BlocksOp") def MakeMultiTransformation1D(self, Block, DirFace1, DirFace2, NbTimes, theName=None): """ Multi-transformate block and glue the result. @@ -11533,6 +11777,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_multi_transformation "Example" + @ManageTransactions("BlocksOp") def MakeMultiTransformation2D(self, Block, DirFace1U, DirFace2U, NbTimesU, DirFace1V, DirFace2V, NbTimesV, theName=None): """ @@ -11572,6 +11817,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return List of GEOM.GEOM_Object, each of them is a propagation group. # # @ref swig_Propagate "Example" + @ManageTransactions("BlocksOp") def Propagate(self, theShape, theName=None): """ Build all possible propagation groups. @@ -11611,6 +11857,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ref tui_working_with_groups_page "Example 1" # \n @ref swig_CreateGroup "Example 2" + @ManageTransactions("GroupOp") def CreateGroup(self, theMainShape, theShapeType, theName=None): """ Creates a new group which will store sub-shapes of theMainShape @@ -11628,7 +11875,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Example of usage: group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) - + """ # Example: see GEOM_TestOthers.py anObj = self.GroupOp.CreateGroup(theMainShape, theShapeType) @@ -11642,6 +11889,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # \note Use method GetSubShapeID() to get an unique ID of the sub-shape # # @ref tui_working_with_groups_page "Example" + @ManageTransactions("GroupOp") def AddObject(self,theGroup, theSubShapeID): """ Adds a sub-object with ID theSubShapeId to the group @@ -11651,7 +11899,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theSubShapeID is a sub-shape ID in the main object. Note: - Use method GetSubShapeID() to get an unique ID of the sub-shape + Use method GetSubShapeID() to get an unique ID of the sub-shape """ # Example: see GEOM_TestOthers.py self.GroupOp.AddObject(theGroup, theSubShapeID) @@ -11666,6 +11914,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # \note Use method GetSubShapeID() to get an unique ID of the sub-shape # # @ref tui_working_with_groups_page "Example" + @ManageTransactions("GroupOp") def RemoveObject(self,theGroup, theSubShapeID): """ Removes a sub-object with ID theSubShapeId from the group @@ -11687,6 +11936,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theSubShapes is a list of sub-shapes to be added. # # @ref tui_working_with_groups_page "Example" + @ManageTransactions("GroupOp") def UnionList (self,theGroup, theSubShapes): """ Adds to the group all the given shapes. No errors, if some shapes are alredy included. @@ -11705,6 +11955,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theSubShapes is a list of indices of sub-shapes to be added. # # @ref swig_UnionIDs "Example" + @ManageTransactions("GroupOp") def UnionIDs(self,theGroup, theSubShapes): """ Adds to the group all the given shapes. No errors, if some shapes are alredy included. @@ -11723,6 +11974,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theSubShapes is a list of sub-shapes to be removed. # # @ref tui_working_with_groups_page "Example" + @ManageTransactions("GroupOp") def DifferenceList (self,theGroup, theSubShapes): """ Removes from the group all the given shapes. No errors, if some shapes are not included. @@ -11741,6 +11993,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theSubShapes is a list of indices of sub-shapes to be removed. # # @ref swig_DifferenceIDs "Example" + @ManageTransactions("GroupOp") def DifferenceIDs(self,theGroup, theSubShapes): """ Removes from the group all the given shapes. No errors, if some shapes are not included. @@ -11748,7 +12001,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Parameters: theGroup is a GEOM group from which the sub-shapes are removed. theSubShapes is a list of indices of sub-shapes to be removed. - """ + """ # Example: see GEOM_TestOthers.py self.GroupOp.DifferenceIDs(theGroup, theSubShapes) RaiseIfFailed("DifferenceIDs", self.GroupOp) @@ -11766,6 +12019,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return a newly created GEOM group. # # @ref tui_union_groups_anchor "Example" + @ManageTransactions("GroupOp") def UnionGroups (self, theGroup1, theGroup2, theName=None): """ Union of two groups. @@ -11799,6 +12053,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return a newly created GEOM group. # # @ref tui_intersect_groups_anchor "Example" + @ManageTransactions("GroupOp") def IntersectGroups (self, theGroup1, theGroup2, theName=None): """ Intersection of two groups. @@ -11832,6 +12087,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return a newly created GEOM group. # # @ref tui_cut_groups_anchor "Example" + @ManageTransactions("GroupOp") def CutGroups (self, theGroup1, theGroup2, theName=None): """ Cut of two groups. @@ -11865,6 +12121,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return a newly created GEOM group. # # @ref tui_union_groups_anchor "Example" + @ManageTransactions("GroupOp") def UnionListOfGroups (self, theGList, theName=None): """ Union of list of groups. @@ -11897,6 +12154,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return a newly created GEOM group. # # @ref tui_intersect_groups_anchor "Example" + @ManageTransactions("GroupOp") def IntersectListOfGroups (self, theGList, theName=None): """ Cut of lists of groups. @@ -11920,7 +12178,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## Cut of lists of groups. # New group is created. It will contain only entities - # which are present in groups listed in theGList1 but + # which are present in groups listed in theGList1 but # are not present in groups from theGList2. # @param theGList1 is a list of GEOM groups to include elements of. # @param theGList2 is a list of GEOM groups to exclude elements of. @@ -11931,11 +12189,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return a newly created GEOM group. # # @ref tui_cut_groups_anchor "Example" + @ManageTransactions("GroupOp") def CutListOfGroups (self, theGList1, theGList2, theName=None): """ Cut of lists of groups. New group is created. It will contain only entities - which are present in groups listed in theGList1 but + which are present in groups listed in theGList1 but are not present in groups from theGList2. Parameters: @@ -11958,6 +12217,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theGroup is a GEOM group for which a list of IDs is requested # # @ref swig_GetObjectIDs "Example" + @ManageTransactions("GroupOp") def GetObjectIDs(self,theGroup): """ Returns a list of sub-objects ID stored in the group @@ -11974,6 +12234,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param theGroup is a GEOM group which type is returned. # # @ref swig_GetType "Example" + @ManageTransactions("GroupOp") def GetType(self,theGroup): """ Returns a type of sub-objects stored in the group @@ -11996,7 +12257,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): Parameters: theId is a GEOM obect type id. - + Returns: type of geom object (POINT, VECTOR, PLANE, LINE, TORUS, ... ) """ @@ -12103,6 +12364,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @return a GEOM object which is a main shape for theGroup # # @ref swig_GetMainShape "Example" + @ManageTransactions("GroupOp") def GetMainShape(self,theGroup): """ Returns a main shape associated with the group @@ -12225,557 +12487,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" - 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" - 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" - 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" - 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" - 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" - 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" - 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" - 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" - 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 @@ -12787,6 +12500,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # # @ingroup l1_geomBuilder_auxiliary # @ref swig_MakeCopy "Example" + @ManageTransactions("InsertOp") def MakeCopy(self, theOriginal, theName=None): """ Create a copy of the given object @@ -12827,13 +12541,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param Path a path to the texture file # @return unique texture identifier # @ingroup l1_geomBuilder_auxiliary + @ManageTransactions("InsertOp") def LoadTexture(self, Path): """ Load marker texture from the file - + Parameters: Path a path to the texture file - + Returns: unique texture identifier """ @@ -12844,7 +12559,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## Get internal name of the object based on its study entry # @note This method does not provide an unique identifier of the geometry object. - # @note This is internal function of GEOM component, though it can be used outside it for + # @note This is internal function of GEOM component, though it can be used outside it for # appropriate reason (e.g. for identification of geometry object). # @param obj geometry object # @return unique object identifier @@ -12853,7 +12568,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): """ Get internal name of the object based on its study entry. Note: this method does not provide an unique identifier of the geometry object. - It is an internal function of GEOM component, though it can be used outside GEOM for + It is an internal function of GEOM component, though it can be used outside GEOM for appropriate reason (e.g. for identification of geometry object). Parameters: @@ -12867,11 +12582,11 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): if entry is not None: lst = entry.split(":") if len(lst) > 0: - ID = lst[-1] # -1 means last item in the list + ID = lst[-1] # -1 means last item in the list return "GEOM_" + ID return ID - - + + ## Add marker texture. @a Width and @a Height parameters # specify width and height of the texture in pixels. @@ -12886,6 +12601,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # @param RowData if @c True, @a Texture data are packed in the byte stream # @return unique texture identifier # @ingroup l1_geomBuilder_auxiliary + @ManageTransactions("InsertOp") def AddTexture(self, Width, Height, Texture, RowData=False): """ Add marker texture. Width and Height parameters @@ -12911,19 +12627,19 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): ## Creates a new folder object. It is a container for any GEOM objects. # @param Name name of the container - # @param Father parent object. If None, + # @param Father parent object. If None, # folder under 'Geometry' root object will be created. # @return a new created folder # @ingroup l1_publish_data def NewFolder(self, Name, Father=None): """ Create a new folder object. It is an auxiliary container for any GEOM objects. - + Parameters: Name name of the container - Father parent object. If None, + Father parent object. If None, folder under 'Geometry' root object will be created. - + Returns: a new created folder """ @@ -12937,7 +12653,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): def PutToFolder(self, Object, Folder): """ Move object to the specified folder - + Parameters: Object object to move Folder target folder @@ -12952,7 +12668,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): def PutListToFolder(self, ListOfSO, Folder): """ Move list of objects to the specified folder - + Parameters: ListOfSO list of objects to move Folder target folder @@ -12971,6 +12687,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # 0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape # @param componentNames names of components # @return a created field + @ManageTransactions("FieldOp") def CreateField(self, shape, name, type, dimension, componentNames): """ Creates a field @@ -12982,7 +12699,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): dimension dimension of the shape the field lies on 0 - VERTEX, 1 - EDGE, 2 - FACE, 3 - SOLID, -1 - whole shape componentNames names of components - + Returns: a created field """ @@ -13011,6 +12728,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return ## Returns number of fields on a shape + @ManageTransactions("FieldOp") def CountFields(self, shape): "Returns number of fields on a shape" nb = self.FieldOp.CountFields( shape ) @@ -13018,6 +12736,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return nb ## Returns all fields on a shape + @ManageTransactions("FieldOp") def GetFields(self, shape): "Returns all fields on a shape" ff = self.FieldOp.GetFields( shape ) @@ -13025,6 +12744,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return ff ## Returns a field on a shape by its name + @ManageTransactions("FieldOp") def GetField(self, shape, name): "Returns a field on a shape by its name" f = self.FieldOp.GetField( shape, name ) @@ -13216,3 +12936,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/GEOM_SWIG/gsketcher.py b/src/GEOM_SWIG/gsketcher.py index 783bfffca..004e8e63e 100644 --- a/src/GEOM_SWIG/gsketcher.py +++ b/src/GEOM_SWIG/gsketcher.py @@ -1211,3 +1211,145 @@ class Sketcher2D: self.myCommand = "Sketcher" self.geompyD._autoPublish(face, theName, "face") return face + +## An interface to build a 2D polyline step-by-step. The polyline can contain +# several sections. Each section represents a list of 2d points. As well it +# has a name, curve type, either polyline or interpolation (BSpline curve) and +# Closed flag. +# Use geompy.Polyline2D() method to obtain an instance of this class. +# @ingroup sketcher +class Polyline2D: + """ + An interface to build a 2D polyline step-by-step. The polyline can contain + several sections. Each section represents a list of 2d points. As well it + has a name, curve type, either polyline or interpolation (BSpline curve) and + Closed flag. + Use geompy.Polyline2D() method to obtain an instance of this class. + + Example of usage: + pl = geompy.Polyline2D() + pl.addSection("section 1", GEOM.Polyline, True, [0, 0, 10, 0, 10, 10]) + pl.addSection("section 2", GEOM.Interpolation, False) + pl.addPoints([20, 0, 30, 0, 30, 10]) + resultObj = pl.result(WorkingPlane) + """ + + def __init__(self, geompyD): + self.geompyD = geompyD + self.myNameList = [] + self.myTypeList = [] + self.myClosedList = [] + self.myCoordsList = [] + pass + + ## Add a new section to the polyline. + # + # @param theName the name + # @param theType the type. It can have either CORBA enumeration type + # GEOM.curve_type or a value of type long. Possible input values + # are: GEOM.Polyline(0) and GEOM.Interpolation(2). + # @param theClosed True for closed section; False otherwise + # @param thePoints the list of 2D points coordinates in the form: + # [x1, y1, x2, y2, ..., xN, yN] for N points. + def addSection(self, theName, theType, theClosed, thePoints = None): + """ + Add a new section to the polyline. + + Parameters: + theName the name + theType the type. It can have either CORBA enumeration type + GEOM.curve_type or a value of type long. Possible input + values are: GEOM.Polyline(0) and GEOM.Interpolation(2). + theClosed True for closed section; False otherwise + thePoints the list of 2D points coordinates in the form: + [x1, y1, x2, y2, ..., xN, yN] for N points. + + Example of usage: + pl = geompy.Polyline2D() + pl.addSection("section 1", GEOM.Polyline, True, [0, 0, 10, 0, 10, 10]) + resultObj = pl.result(WorkingPlane) + """ + from salome.geom.geomBuilder import EnumToLong + self.myNameList.append(theName) + self.myTypeList.append(EnumToLong(theType)) + self.myClosedList.append(theClosed) + if thePoints is None: + self.myCoordsList.append([]) + else: + self.myCoordsList.append(thePoints) + pass + + ## Add a points to the last added section of the polyline. If there are + # no sections in the polyline it does nothing. + # + # @param thePoints the list of 2D points coordinates in the form: + # [x1, y1, x2, y2, ..., xN, yN] for N points. + def addPoints(self, thePoints): + """ + Add a points to the last added section of the polyline. If there are + no sections in the polyline it does nothing. + + Parameters: + thePoints the list of 2D points coordinates in the form: + [x1, y1, x2, y2, ..., xN, yN] for N points. + + Example of usage: + pl = geompy.Polyline2D() + pl.addSection("section 1", GEOM.Polyline, True) + pl.addPoints([0, 0, 10, 0, 10, 10]) + pl.addPoints([20, 0, 30, 0, 30, 10]) + resultObj = pl.result(WorkingPlane) + """ + if self.myNameList: + self.myCoordsList[-1].extend(thePoints) + pass + + ## Obtain the 2D polyline result as a wire or a compound of wires in case + # of several sections defined. + # + # @param theWorkingPlane - current Working Plane used for this 2D polyline + # @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. + def result(self, theWorkingPlane=[0, 0, 0, 0, 0, 1, 1, 0, 0], theName=None): + """ + Obtain the 2D polyline result as a wire or a compound of wires in case + of several sections defined. + + Parameters: + theWorkingPlane current Working Plane used for this 2D polyline + 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. + + Example of usage: + pl = geompy.Polyline2D() + pl.addSection("section 1", GEOM.Polyline, True, [0, 0, 10, 0, 10, 10]) + pl.addSection("section 2", GEOM.Interpolation, False) + pl.addPoints([20, 0, 30, 0, 30, 10]) + resultObj = pl.result(WorkingPlane) + """ + from salome.geom.geomBuilder import RaiseIfFailed + import GEOM + if isinstance(theWorkingPlane, list): + aResult = self.geompyD.CurvesOp.MakePolyline2D( + self.myCoordsList, self.myNameList, self.myTypeList, + self.myClosedList, theWorkingPlane) + if isinstance(theWorkingPlane, GEOM._objref_GEOM_Object): + aResult = self.geompyD.CurvesOp.MakePolyline2DOnPlane( + self.myCoordsList, self.myNameList, self.myTypeList, + self.myClosedList, theWorkingPlane) + + self.myNameList = [] + self.myTypeList = [] + self.myClosedList = [] + self.myCoordsList = [] + RaiseIfFailed("Polyline2D.result", self.geompyD.CurvesOp) + self.geompyD._autoPublish(aResult, theName, "polyline") + + return aResult diff --git a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx index 1fa77355d..2b918cc12 100644 --- a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx +++ b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx @@ -391,6 +391,18 @@ void GEOM_Swig::setVectorsMode( const char* theEntry, bool theOn, bool theUpdate theOn, theUpdateViewer ) ); } +/*! + \brief Show / hide vertices for the presentation + \param theEntry geometry object's entry + \param theOn \c true to show vertices or \c false otherwise + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::setVerticesMode( const char* theEntry, bool theOn, bool theUpdateViewer ) +{ + ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::Vertices ), + theOn, theUpdateViewer ) ); +} + /*! \brief Change color of the presentation \param theEntry geometry object's entry diff --git a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.h b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.h index 60cb10cfa..1fd1d864e 100644 --- a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.h +++ b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.h @@ -41,6 +41,7 @@ public: void setDisplayMode( const char* theEntry, int theMode, bool theUpdateViewer = true ); void setVectorsMode( const char* theEntry, bool theOn, bool theUpdateViewer = true ); + void setVerticesMode( const char* theEntry, bool theOn, bool theUpdateViewer = true ); void setColor( const char* theEntry, int theRed, int theGreen, int theBlue, bool theUpdateViewer = true ); void setTransparency( const char* theEntry, float theTransparency, bool theUpdateViewer = true ); void setIsos( const char* theEntry, int theNbU, int theNbV, bool theUpdateViewer = true ); diff --git a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.i b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.i index 6d1050a98..30f6065c7 100644 --- a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.i +++ b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.i @@ -63,6 +63,7 @@ class GEOM_Swig void setDisplayMode( const char* theEntry, int theMode, bool theUpdateViewer = true ); void setVectorsMode( const char* theEntry, bool theOn, bool theUpdateViewer = true ); + void setVerticesMode( const char* theEntry, bool theOn, bool theUpdateViewer = true ); void setColor( const char* theEntry, int theRed, int theGreen, int theBlue, bool theUpdateViewer = true ); void setTransparency( const char* theEntry, float theTransparency, bool theUpdateViewer = true ); void setIsos( const char* theEntry, int theNbU, int theNbV, bool theUpdateViewer = true ); diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx index e9ead7a40..2068d5fda 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -165,6 +164,8 @@ void GenerationGUI_PipeDlg::Init() connect(GroupMakePoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupMakePoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupMakePoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupMakePoints->CheckBox1, SIGNAL(clicked()), this, SLOT(processPreview())); + connect(GroupMakePoints->CheckBox2, SIGNAL(clicked()), this, SLOT(processPreview())); initName(tr("GEOM_PIPE")); resize(100,100); @@ -264,10 +265,7 @@ bool GenerationGUI_PipeDlg::ClickOnApply() return false; initName(); - if ( getConstructorId() != 1 ) - ConstructorsClicked( getConstructorId() ); - // activate selection and connect selection manager - // GroupPoints->PushButton1->click(); + return true; } @@ -321,7 +319,6 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument() } } else if ( myEditCurrentArgument == GroupMakePoints->LineEdit1 ) { - myBaseObjects.clear(); QList types; types << TopAbs_EDGE << TopAbs_WIRE << TopAbs_FACE << TopAbs_SHELL; QList objects = getSelected( types, -1 ); @@ -332,7 +329,6 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument() } } else if ( myEditCurrentArgument == GroupMakePoints->LineEdit2 ) { - myLocations.clear(); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); QList objects = getSelected( TopAbs_VERTEX, -1 ); GEOMBase::Synchronize( myLocations, objects ); diff --git a/src/GroupGUI/GroupGUI_GroupDlg.cxx b/src/GroupGUI/GroupGUI_GroupDlg.cxx index fa50a5357..a34a137d4 100644 --- a/src/GroupGUI/GroupGUI_GroupDlg.cxx +++ b/src/GroupGUI/GroupGUI_GroupDlg.cxx @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include 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..ee240841d --- /dev/null +++ b/src/IGESPlugin/CMakeLists.txt @@ -0,0 +1,154 @@ +# 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} + ${OMNIORB_DEFINITIONS} + ) + +IF(WIN32) + ADD_DEFINITIONS(-DNOGDI) +ENDIF(WIN32) + +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..cb20e5463 --- /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 + #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..53d9be6c5 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_ExportDriver.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_ExportDriver_HXX +#define _IGESPlugin_ExportDriver_HXX + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( IGESPlugin_ExportDriver, GEOM_BaseDriver ); + +class 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..d6c3feb39 --- /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..7547da3a0 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_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 "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 { + OCC_CATCH_SIGNALS; + 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 { + OCC_CATCH_SIGNALS; + 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..0b12fa814 --- /dev/null +++ b/src/IGESPlugin/IGESPlugin_ImportDriver.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 _IGESPlugin_ImportDriver_HXX +#define _IGESPlugin_ImportDriver_HXX + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( IGESPlugin_ImportDriver, GEOM_BaseDriver ); + +class 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/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/MeasureGUI/MeasureGUI_1Sel12LineEdit_QTD.ui b/src/MeasureGUI/MeasureGUI_1Sel12LineEdit_QTD.ui index 30b225aad..2f0e56b0e 100644 --- a/src/MeasureGUI/MeasureGUI_1Sel12LineEdit_QTD.ui +++ b/src/MeasureGUI/MeasureGUI_1Sel12LineEdit_QTD.ui @@ -1,63 +1,48 @@ - + + MeasureGUI_1Sel12LineEdit_QTD - - + + 0 0 - 196 - 162 + 501 + 171 - + - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - 6 - - - - + + + + - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - 6 - - - - + + + + + TL1 + + + + + + + + 0 + 0 + + + + + + + + + + 300 0 @@ -65,109 +50,207 @@ - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - 6 - - - - - - - - - - - TL2 - - - - - - - - - - TL4 - - - - - - - - - - - - - - - - - - - - - - - - - TL5 - - - - - - - - - - - - - - - - TL3 - - - - - - - - - TL1 + + + + TL2_1 - - - - - 0 - 0 - + + + + + 100 + 0 + - - + + + + + + TL2_2 + + + + + + + + 100 + 0 + + + + + + + + TL2_3 + + + + + + + + 100 + 0 + + + + + + + + TL3_1 + + + + + + + + 100 + 0 + + + + + + + + TL3_2 + + + + + + + + 100 + 0 + + + + + + + + TL3_3 + + + + + + + + 100 + 0 + + + + + + + + TL4_1 + + + + + + + + 100 + 0 + + + + + + + + TL4_2 + + + + + + + + 100 + 0 + + + + + + + + TL4_3 + + + + + + + + 100 + 0 + + + + + + + + TL5_1 + + + + + + + + 100 + 0 + + + + + + + + TL5_2 + + + + + + + + 100 + 0 + + + + + + + + TL5_3 + + + + + + + + 100 + 0 + diff --git a/src/MeasureGUI/MeasureGUI_AngleDlg.cxx b/src/MeasureGUI/MeasureGUI_AngleDlg.cxx index ccce76eb6..2f8f47bbd 100644 --- a/src/MeasureGUI/MeasureGUI_AngleDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_AngleDlg.cxx @@ -113,7 +113,7 @@ MeasureGUI_AngleDlg::MeasureGUI_AngleDlg (GeometryGUI* GUI, QWidget* parent) /***************************************************************/ // Help page reference - myHelpFileName = "using_measurement_tools_page.html#angle_anchor"; + myHelpFileName = "angle_page.html"; // Initialisation Init(); @@ -313,9 +313,7 @@ SALOME_Prs* MeasureGUI_AngleDlg::buildPrs() if (anAngle > Precision::Angular()) { try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif TopoDS_Shape S1, S2; if (GEOMBase::GetShape(myObj , S1, TopAbs_EDGE) && GEOMBase::GetShape(myObj2, S2, TopAbs_EDGE)) { diff --git a/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx b/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx index 26763b814..8d7961412 100644 --- a/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx @@ -96,7 +96,7 @@ MeasureGUI_CheckCompoundOfBlocksDlg::MeasureGUI_CheckCompoundOfBlocksDlg( Geomet /***************************************************************/ - myHelpFileName = "using_measurement_tools_page.html#check_compound_anchor"; + myHelpFileName = "check_compound_of_blocks_page.html"; /* Initialisation */ Init(); diff --git a/src/MeasureGUI/MeasureGUI_CheckSelfIntersectionsDlg.cxx b/src/MeasureGUI/MeasureGUI_CheckSelfIntersectionsDlg.cxx index 8debf294c..de712233d 100644 --- a/src/MeasureGUI/MeasureGUI_CheckSelfIntersectionsDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_CheckSelfIntersectionsDlg.cxx @@ -87,7 +87,7 @@ MeasureGUI_CheckSelfIntersectionsDlg::MeasureGUI_CheckSelfIntersectionsDlg (Geom /***************************************************************/ - myHelpFileName = "using_measurement_tools_page.html#check_self_intersections_anchor"; + myHelpFileName = "check_self_intersections_page.html"; /* Initialisation */ Init(); diff --git a/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx b/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx index 42b9e3abd..3a4394d63 100644 --- a/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx @@ -97,7 +97,7 @@ MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( GeometryGUI* GUI, QWidget* p /***************************************************************/ - myHelpFileName = "using_measurement_tools_page.html#check_anchor"; + myHelpFileName = "check_shape_page.html"; /* Initialisation */ Init(); diff --git a/src/MeasureGUI/MeasureGUI_DimensionCreateTool.cxx b/src/MeasureGUI/MeasureGUI_DimensionCreateTool.cxx index 9ae10135a..b571b61c7 100644 --- a/src/MeasureGUI/MeasureGUI_DimensionCreateTool.cxx +++ b/src/MeasureGUI/MeasureGUI_DimensionCreateTool.cxx @@ -407,6 +407,9 @@ Handle(AIS_LengthDimension) MeasureGUI_DimensionCreateTool::LengthByParallelEdge return NULL; } + if( aFirstSh == aSecondSh ) + return NULL; + TopoDS_Edge aFirstEdge = TopoDS::Edge( aFirstSh ); TopoDS_Edge aSecondEdge = TopoDS::Edge( aSecondSh ); diff --git a/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx b/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx index 47a240e48..3a011a5fe 100644 --- a/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx @@ -62,10 +62,18 @@ MeasureGUI_InertiaDlg::MeasureGUI_InertiaDlg( GeometryGUI* GUI, QWidget* parent myGrp = new MeasureGUI_1Sel12LineEdit( centralWidget() ); myGrp->GroupBox1->setTitle( tr( "GEOM_MATRIX" ) ); myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); - myGrp->TextLabel2->setText( tr( "GEOM_INERTIA_I" ).arg( "1" ) ); - myGrp->TextLabel3->setText( tr( "GEOM_INERTIA_I" ).arg( "2" ) ); - myGrp->TextLabel4->setText( tr( "GEOM_INERTIA_I" ).arg( "3" ) ); - myGrp->TextLabel5->setText( tr( "GEOM_INERTIA_IXYZ" ) ); + myGrp->TextLabel2_1->setText( "1:1" ); + myGrp->TextLabel2_2->setText( "1:2" ); + myGrp->TextLabel2_3->setText( "1:3" ); + myGrp->TextLabel3_1->setText( "2:1" ); + myGrp->TextLabel3_2->setText( "2:2" ); + myGrp->TextLabel3_3->setText( "2:3" ); + myGrp->TextLabel4_1->setText( "3:1" ); + myGrp->TextLabel4_2->setText( "3:2" ); + myGrp->TextLabel4_3->setText( "3:3" ); + myGrp->TextLabel5_1->setText( "IX" ); + myGrp->TextLabel5_2->setText( "IY" ); + myGrp->TextLabel5_3->setText( "IZ" ); myGrp->LineEdit11->setReadOnly( true ); myGrp->LineEdit12->setReadOnly( true ); myGrp->LineEdit13->setReadOnly( true ); @@ -87,7 +95,7 @@ MeasureGUI_InertiaDlg::MeasureGUI_InertiaDlg( GeometryGUI* GUI, QWidget* parent /***************************************************************/ - myHelpFileName = "using_measurement_tools_page.html#inertia_anchor"; + myHelpFileName = "inertia_page.html"; /* Initialisation */ Init(); diff --git a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx index 0e34b7650..74ca035f5 100644 --- a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx @@ -77,7 +77,7 @@ MeasureGUI_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg( GeometryGUI* GUI, QWidge /***************************************************************/ - myHelpFileName = "using_measurement_tools_page.html#tolerance_anchor"; + myHelpFileName = "tolerance_page.html"; /* Initialisation */ Init(); diff --git a/src/MeasureGUI/MeasureGUI_NormaleDlg.cxx b/src/MeasureGUI/MeasureGUI_NormaleDlg.cxx index 457714ee8..53a5c3199 100644 --- a/src/MeasureGUI/MeasureGUI_NormaleDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_NormaleDlg.cxx @@ -80,7 +80,7 @@ MeasureGUI_NormaleDlg::MeasureGUI_NormaleDlg (GeometryGUI* theGeometryGUI, QWidg layout->addWidget(GroupArgs); /***************************************************************/ - setHelpFileName("using_measurement_tools_page.html#normale_anchor"); + setHelpFileName("normal_page.html"); Init(); } diff --git a/src/MeasureGUI/MeasureGUI_PointDlg.cxx b/src/MeasureGUI/MeasureGUI_PointDlg.cxx index e21d5252f..245bc0a13 100644 --- a/src/MeasureGUI/MeasureGUI_PointDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_PointDlg.cxx @@ -80,7 +80,7 @@ MeasureGUI_PointDlg::MeasureGUI_PointDlg( GeometryGUI* GUI, QWidget* parent ) layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( myGrp ); - myHelpFileName = "using_measurement_tools_page.html#point_coord_anchor"; + myHelpFileName = "point_coordinates_page.html"; Init(); } diff --git a/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx b/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx index 9e434c969..9b850db97 100644 --- a/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx @@ -77,7 +77,7 @@ MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* p /***************************************************************/ - myHelpFileName = "using_measurement_tools_page.html#basic_prop_anchor"; + myHelpFileName = "basic_prop_page.html"; /* Initialisation */ Init(); diff --git a/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx b/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx index 5789419de..7d7fc2baa 100644 --- a/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx @@ -145,7 +145,7 @@ MeasureGUI_WhatisDlg::MeasureGUI_WhatisDlg( GeometryGUI* GUI, QWidget* parent ) /***************************************************************/ - myHelpFileName = "using_measurement_tools_page.html#whatis_anchor"; + myHelpFileName = "whatis_page.html"; /* Initialisation */ Init(); diff --git a/src/OBJECT/CMakeLists.txt b/src/OBJECT/CMakeLists.txt index e98b2d7cf..1fba59a07 100755 --- a/src/OBJECT/CMakeLists.txt +++ b/src/OBJECT/CMakeLists.txt @@ -65,17 +65,8 @@ SET(_link_LIBRARIES SET(OBJECT_HEADERS GEOM_Actor.h GEOM_AISShape.hxx - GEOM_AISShape.ixx - GEOM_AISShape.jxx - Handle_GEOM_AISShape.hxx GEOM_TopWireframeShape.hxx - GEOM_TopWireframeShape.ixx - GEOM_TopWireframeShape.jxx - Handle_GEOM_TopWireframeShape.hxx GEOM_InteractiveObject.hxx - GEOM_InteractiveObject.ixx - GEOM_InteractiveObject.jxx - Handle_GEOM_InteractiveObject.hxx GEOM_AISTrihedron.hxx GEOM_VTKTrihedron.hxx GEOM_VTKPropertyMaterial.hxx diff --git a/src/OBJECT/GEOM_AISShape.cxx b/src/OBJECT/GEOM_AISShape.cxx index e790b8072..a41490235 100644 --- a/src/OBJECT/GEOM_AISShape.cxx +++ b/src/OBJECT/GEOM_AISShape.cxx @@ -20,26 +20,20 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// GEOM OBJECT : interactive object for Geometry entities visualization -// File : GEOM_AISShape.cxx -// Author : Nicolas REJNERI -// Module : GEOM - /*! \class GEOM_AISShape GEOM_AISShape.hxx \brief .... */ -#include "GEOM_AISShape.ixx" -#include "SALOME_InteractiveObject.hxx" +#include "GEOM_AISShape.hxx" #include "GEOM_AISVector.hxx" +#include + // Open CASCADE Includes #include #include - #include - #include #include #include @@ -53,6 +47,9 @@ #include #include #include +#if OCC_VERSION_LARGE > 0x06070200 +#include +#endif #include #include @@ -81,10 +78,12 @@ #include #include - #include #include +IMPLEMENT_STANDARD_HANDLE (GEOM_AISShape, SALOME_AISShape) +IMPLEMENT_STANDARD_RTTIEXT(GEOM_AISShape, SALOME_AISShape) + GEOM_AISShape::TopLevelDispMode GEOM_AISShape::myTopLevelDm = GEOM_AISShape::TopKeepCurrent; Quantity_Color GEOM_AISShape::myTopLevelColor; @@ -148,6 +147,7 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape, : SALOME_AISShape(shape), myName(aName), myDisplayVectors(false), + myDisplayVertices(false), myFieldDataType(GEOM::FDT_Double), myFieldDimension(0), myFieldStepRangeMin(0), @@ -158,14 +158,9 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape, myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD ); myPrevDisplayMode = 0; - storeBoundaryColors(); - myEdgesInShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD ); - myUIsoNumber = -1; - myVIsoNumber = -1; - myTopLevel = Standard_False; Graphic3d_MaterialAspect aMatAspect; if ( !HasMaterial() ) { @@ -180,6 +175,10 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape, } } +GEOM_AISShape::~GEOM_AISShape() +{ +} + void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){ SetOwner( io ); } @@ -215,20 +214,26 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL Handle(AIS_InteractiveContext) anIC = GetContext(); + // AKL: use old behavior to avoid keeping object's wireframe + // if to change shape properties (for example: 'Clear Top Level State','Color', 'Isos') + // calling popup menu over(!) the shape in OCC viewer. + anIC->SetToHilightSelected( false ); bool anIsField = !myFieldStepData.isEmpty(); bool anIsColorField = anIsField && myFieldDataType != GEOM::FDT_String; bool anIsTextField = anIsField && myFieldDataType == GEOM::FDT_String; +#if OCC_VERSION_LARGE > 0x06070200 + if (isShowVertices()) + myDrawer->SetVertexDrawMode(Prs3d_VDM_All); +#endif + // StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode; bool isTopLev = isTopLevel() && switchTopLevel(); switch (aMode) { - case 0://StdSelect_DM_Wireframe: + case Wireframe: case CustomHighlight: { - restoreIsoNumbers(); - // Restore wireframe edges colors - restoreBoundaryColors(); if(isTopLev) { SetColor(topLevelColor()); Handle(Prs3d_LineAspect) anAspect = Attributes()->WireAspect(); @@ -241,55 +246,33 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); break; } - case 1://StdSelect_DM_Shading: + case Shading: { - restoreIsoNumbers(); shadingMode(aPresentationManager, aPrs, aMode); - // Store wireframe edges colors - storeBoundaryColors(); break; } - case 3: //StdSelect_DM_HLR: + case ShadingWithEdges: + { + shadingMode(aPresentationManager, aPrs, Shading); + myDrawer->SetFaceBoundaryDraw( Standard_True ); + Handle(Prs3d_LineAspect) aBoundaryAspect = + new Prs3d_LineAspect ( myEdgesInShadingColor, Aspect_TOL_SOLID, myOwnWidth ); + myDrawer->SetFaceBoundaryAspect (aBoundaryAspect); + break; + } + case TexturedShape: { if(!isTopLev) - AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode); +#ifdef USE_TEXTURED_SHAPE + AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode); +#else + AIS_Shape::Compute(aPresentationManager, aPrs, aMode); +#endif else - shadingMode(aPresentationManager, aPrs, AIS_Shaded); + shadingMode(aPresentationManager, aPrs, Shading); break; } } - - if ( aMode == ShadingWithEdges ) { - // Temporary store number of iso lines in order to recover its later - // when display mode is achnged to 'Wirefame' or 'Shading'. - // Iso lines are not displayed in 'Shading with edges' mode. - storeIsoNumbers(); - - // Reset number of iso lines to 0 - resetIsoNumbers(); - - //Shaded faces - shadingMode(aPresentationManager, aPrs, AIS_Shaded); - - // Store wireframe edges colors - storeBoundaryColors(); - - // Coloring edges - Handle(Prs3d_LineAspect) anAspect = myDrawer->UnFreeBoundaryAspect(); - anAspect->SetColor( myEdgesInShadingColor ); - myDrawer->SetUnFreeBoundaryAspect( anAspect ); - - anAspect = myDrawer->FreeBoundaryAspect(); - anAspect->SetColor( myEdgesInShadingColor ); - myDrawer->SetFreeBoundaryAspect( anAspect ); - - // Add edges to presentation - if( anIsColorField && myFieldDimension == 1 ) - drawField( aPrs ); - else - StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); - } - if (isShowVectors()) { const bool isVector = IsKind(STANDARD_TYPE(GEOM_AISVector)); @@ -393,6 +376,11 @@ void GEOM_AISShape::SetDisplayVectors(bool isDisplayed) myDisplayVectors = isDisplayed; } +void GEOM_AISShape::SetDisplayVertices(bool isDisplayed) +{ + myDisplayVertices = isDisplayed; +} + void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPrs, const Standard_Integer aMode) @@ -424,65 +412,14 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre { // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer); +#ifdef USE_TEXTURED_SHAPE + AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode); +#else AIS_Shape::Compute(aPresentationManager, aPrs, aMode); +#endif } } -void GEOM_AISShape::storeIsoNumbers() -{ - myUIsoNumber = myDrawer->UIsoAspect()->Number(); - myVIsoNumber = myDrawer->VIsoAspect()->Number(); -} - -void GEOM_AISShape::restoreIsoNumbers() -{ - if ( myUIsoNumber > 0 ) { - // Restore number of U iso lines - Handle(Prs3d_IsoAspect) anAspect = myDrawer->UIsoAspect(); - anAspect->SetNumber( myUIsoNumber ); - myDrawer->SetUIsoAspect( anAspect ); - } - - if ( myVIsoNumber > 0 ) { - // Restore number of V iso lines - Handle(Prs3d_IsoAspect) anAspect = myDrawer->VIsoAspect(); - anAspect->SetNumber( myVIsoNumber ); - myDrawer->SetVIsoAspect( anAspect ); - } -} - -void GEOM_AISShape::resetIsoNumbers() -{ - Handle(Prs3d_IsoAspect) anAspect = myDrawer->UIsoAspect(); - anAspect->SetNumber( 0 ); - myDrawer->SetUIsoAspect( anAspect ); - - anAspect = myDrawer->VIsoAspect(); - anAspect->SetNumber( 0 ); - myDrawer->SetVIsoAspect( anAspect ); -} - -void GEOM_AISShape::storeBoundaryColors() -{ - Aspect_TypeOfLine aLT; - Standard_Real aW; - - myDrawer->FreeBoundaryAspect()->Aspect()->Values( myFreeBoundaryColor, aLT, aW); - myDrawer->UnFreeBoundaryAspect()->Aspect()->Values( myUnFreeBoundaryColor, aLT, aW); -} - -void GEOM_AISShape::restoreBoundaryColors() -{ - Handle(Prs3d_LineAspect) anAspect = myDrawer->FreeBoundaryAspect(); - anAspect->SetColor( myFreeBoundaryColor ); - myDrawer->SetFreeBoundaryAspect( anAspect ); - - anAspect = myDrawer->UnFreeBoundaryAspect(); - anAspect->SetColor( myUnFreeBoundaryColor ); - myDrawer->SetUnFreeBoundaryAspect( anAspect ); -} - - Standard_Boolean GEOM_AISShape::isTopLevel() { return myTopLevel; } @@ -493,10 +430,10 @@ void GEOM_AISShape::setTopLevel(Standard_Boolean f) { myPrevDisplayMode = DisplayMode(); Standard_Integer dm; switch(topLevelDisplayMode()) { - case TopKeepCurrent : dm = myPrevDisplayMode; break; - case TopWireFrame : dm = AIS_WireFrame; break; - case TopShadingWithEdges : dm = ShadingWithEdges; break; - default : dm = AIS_Shaded; break; + case TopKeepCurrent : dm = myPrevDisplayMode; break; + case TopWireFrame : dm = Wireframe; break; + case TopShadingWithEdges : dm = ShadingWithEdges; break; + default : dm = Shading; break; } SetDisplayMode(dm); } else { @@ -526,11 +463,11 @@ void GEOM_AISShape::setTopLevelDisplayMode(const GEOM_AISShape::TopLevelDispMode } Standard_Boolean GEOM_AISShape::switchTopLevel() { - return myTopLevelDm != TopShowAdditionalWActor; + return myTopLevelDm != TopShowAdditionalWActor; } Standard_Boolean GEOM_AISShape::toActivate() { - return Standard_True; + return ( myTopLevel && myTopLevelDm == TopShowAdditionalWActor ) ? false : true; } void GEOM_AISShape::setFieldStepInfo( const GEOM::field_data_type theFieldDataType, diff --git a/src/OBJECT/GEOM_AISShape.hxx b/src/OBJECT/GEOM_AISShape.hxx index b2881d2c6..e6f185c8b 100644 --- a/src/OBJECT/GEOM_AISShape.hxx +++ b/src/OBJECT/GEOM_AISShape.hxx @@ -20,183 +20,122 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// GEOM OBJECT : interactive object for Geometry entities visualization -// File : GEOM_AISShape.hxx -// Module : GEOM -// #ifndef _GEOM_AISShape_HeaderFile #define _GEOM_AISShape_HeaderFile -#include "GEOM_OBJECT_defs.hxx" +#include +#include -#include - -#ifndef _Standard_HeaderFile #include -#endif -#ifndef _Handle_GEOM_AISShape_HeaderFile -#include "Handle_GEOM_AISShape.hxx" -#endif - -#ifndef _Handle_SALOME_InteractiveObject_HeaderFile -#include "Handle_SALOME_InteractiveObject.hxx" -#endif -#ifndef _Standard_CString_HeaderFile -#include -#endif -#ifndef _SALOME_AISShape_HeaderFile -#include "SALOME_AISShape.hxx" -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _PrsMgr_PresentationManager_HeaderFile +#include #include -#endif -#ifndef _Handle_Prs3d_Presentation_HeaderFile #include -#endif - #include - #include -#include #include #include -class Prs3d_Presentation; -class SALOME_InteractiveObject; +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) + class TopoDS_Shape; -class GEOM_OBJECT_EXPORT GEOM_AISShape : public SALOME_AISShape { - +class GEOM_AISShape : public SALOME_AISShape +{ public: + //! Enumeration of display modes + typedef enum { + Wireframe = AIS_WireFrame, //!< wireframe + Shading = AIS_Shaded, //!< shadin + ShadingWithEdges, //!< shading with edges + TexturedShape, //!< texture + CustomHighlight //!< fields + } DispMode; - //! Enumeration of display modes - typedef enum { - //WireFrame, //!< the same as AIS_WireFrame - //Shading, //!< the same as AIS_Shaded - ShadingWithEdges = AIS_Shaded+1, //!< shading with edges - TexturedShape = ShadingWithEdges+1, //!< the same as AIS_ExactHLR - CustomHighlight = TexturedShape+1 - } DispMode; + //! Enumeration of top level display modes + typedef enum { + TopShowAdditionalWActor = 0, + TopKeepCurrent, //!< Keep current display mode + TopWireFrame, + TopShading, + TopShadingWithEdges, + } TopLevelDispMode; + + Standard_EXPORT GEOM_AISShape(const TopoDS_Shape& shape, const Standard_CString aName); + Standard_EXPORT ~GEOM_AISShape(); - //! Enumeration of top level display modes - typedef enum { - TopShowAdditionalWActor = 0, - TopKeepCurrent, //!< Keep current display mode - TopWireFrame, - TopShading, - TopShadingWithEdges, - } TopLevelDispMode; + Standard_EXPORT Standard_Boolean hasIO(); + Standard_EXPORT void setIO(const Handle(SALOME_InteractiveObject)& name); + Standard_EXPORT Handle(SALOME_InteractiveObject) getIO(); + Standard_EXPORT void setName(const Standard_CString aName); + Standard_EXPORT Standard_CString getName(); - 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); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // - GEOM_AISShape(const TopoDS_Shape& shape, const Standard_CString aName); - Standard_Boolean hasIO() ; - void setIO(const Handle(SALOME_InteractiveObject)& name) ; - void setName(const Standard_CString aName) ; - Standard_CString getName() ; - Standard_Boolean isTopLevel(); - void setTopLevel(Standard_Boolean); - Handle_SALOME_InteractiveObject getIO() ; - void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight ); - ~GEOM_AISShape(); + Standard_EXPORT Standard_Boolean isTopLevel(); + Standard_EXPORT void setTopLevel(Standard_Boolean); - void SetShadingColor(const Quantity_Color &aCol); - void SetEdgesInShadingColor(const Quantity_Color &aCol); - void SetDisplayVectors(bool isShow); + Standard_EXPORT void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight ); + + Standard_EXPORT void SetShadingColor(const Quantity_Color &aCol); + Standard_EXPORT void SetEdgesInShadingColor(const Quantity_Color &aCol); + Standard_EXPORT void SetDisplayVectors(bool isShow); + Standard_EXPORT void SetDisplayVertices(bool isShow); - virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, - const Handle(Prs3d_Presentation)& aPresentation, - const Standard_Integer aMode = 0) ; + Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, + const Handle(Prs3d_Presentation)& aPresentation, + const Standard_Integer aMode = 0); + + Standard_EXPORT virtual bool isShowVectors() { return myDisplayVectors; } + Standard_EXPORT virtual bool isShowVertices() { return myDisplayVertices; } - virtual bool isShowVectors () { return myDisplayVectors; } - virtual Standard_Boolean switchTopLevel(); - virtual Standard_Boolean toActivate(); + Standard_EXPORT virtual Standard_Boolean switchTopLevel(); + Standard_EXPORT virtual Standard_Boolean toActivate(); - // Type management - // - friend Handle_Standard_Type& GEOM_AISShape_Type_(); - const Handle(Standard_Type)& DynamicType() const; - Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + Standard_EXPORT static Quantity_Color topLevelColor(); + Standard_EXPORT static void setTopLevelColor(const Quantity_Color c); - void storeIsoNumbers(); - void restoreIsoNumbers(); - void resetIsoNumbers(); + Standard_EXPORT static TopLevelDispMode topLevelDisplayMode(); + Standard_EXPORT static void setTopLevelDisplayMode(const TopLevelDispMode dm); - void storeBoundaryColors(); - - static Quantity_Color topLevelColor(); - static void setTopLevelColor(const Quantity_Color c); - - static TopLevelDispMode topLevelDisplayMode(); - static void setTopLevelDisplayMode(const TopLevelDispMode dm); - - void setPrevDisplayMode(const Standard_Integer mode); - Standard_Integer prevDisplayMode() const {return myPrevDisplayMode;} + Standard_EXPORT void setPrevDisplayMode(const Standard_Integer mode); + Standard_EXPORT Standard_Integer prevDisplayMode() const {return myPrevDisplayMode;} // Field step information - void setFieldStepInfo( const GEOM::field_data_type theFieldDataType, - const int theFieldDimension, - const QList& theFieldStepData, - const TCollection_AsciiString& theFieldStepName, - const double theFieldStepRangeMin, - const double theFieldStepRangeMax ); - void getFieldStepInfo( GEOM::field_data_type& theFieldDataType, - int& theFieldDimension, - QList& theFieldStepData, - TCollection_AsciiString& theFieldStepName, - double& theFieldStepRangeMin, - double& theFieldStepRangeMax ) const; + Standard_EXPORT void setFieldStepInfo( const GEOM::field_data_type theFieldDataType, + const int theFieldDimension, + const QList& theFieldStepData, + const TCollection_AsciiString& theFieldStepName, + const double theFieldStepRangeMin, + const double theFieldStepRangeMax ); + Standard_EXPORT void getFieldStepInfo( GEOM::field_data_type& theFieldDataType, + int& theFieldDimension, + QList& theFieldStepData, + TCollection_AsciiString& theFieldStepName, + double& theFieldStepRangeMin, + double& theFieldStepRangeMax ) const; protected: - void shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, - const Handle(Prs3d_Presentation)& aPrs, - const Standard_Integer aMode); - - void restoreBoundaryColors(); - + Standard_EXPORT void shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, + const Handle(Prs3d_Presentation)& aPrs, + const Standard_Integer aMode); + // Displaying the field data - void drawField( const Handle(Prs3d_Presentation)& thePrs, - const bool theIsText = false, - const bool theIsHighlight = false ); - + Standard_EXPORT void drawField( const Handle(Prs3d_Presentation)& thePrs, + const bool theIsText = false, + const bool theIsHighlight = false ); + // Auxiliary method to compute a center of mass for the specified shape - static Standard_Boolean computeMassCenter( const TopoDS_Shape& theShape, - gp_Pnt& theCenter ); - - Quantity_Color myShadingColor; - - Quantity_Color myFreeBoundaryColor; - Quantity_Color myUnFreeBoundaryColor; - - Quantity_Color myEdgesInShadingColor; - - int myUIsoNumber; - int myVIsoNumber; - + Standard_EXPORT static Standard_Boolean computeMassCenter( const TopoDS_Shape& theShape, + gp_Pnt& theCenter ); + private: + Quantity_Color myShadingColor; + Quantity_Color myEdgesInShadingColor; + TCollection_AsciiString myName; bool myDisplayVectors; + bool myDisplayVertices; Standard_Boolean myTopLevel; Standard_Integer myPrevDisplayMode; @@ -207,13 +146,13 @@ private: double myFieldStepRangeMin; double myFieldStepRangeMax; - static TopLevelDispMode myTopLevelDm; - static Quantity_Color myTopLevelColor; + static TopLevelDispMode myTopLevelDm; + static Quantity_Color myTopLevelColor; + +public: + DEFINE_STANDARD_RTTI(GEOM_AISShape); }; - -// other inline functions and methods (like "C++: function call" methods) -// - +DEFINE_STANDARD_HANDLE(GEOM_AISShape, SALOME_AISShape) #endif diff --git a/src/OBJECT/GEOM_AISShape.ixx b/src/OBJECT/GEOM_AISShape.ixx deleted file mode 100644 index 292f586af..000000000 --- a/src/OBJECT/GEOM_AISShape.ixx +++ /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 -// - -// GEOM OBJECT : interactive object for Geometry entities visualization -// File : GEOM_AISShape.ixx -// Module : GEOM -// -#include "GEOM_AISShape.jxx" - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -GEOM_AISShape::~GEOM_AISShape() {} - - - -Standard_EXPORT Handle_Standard_Type& GEOM_AISShape_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_AISShape); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_AISShape); - static Handle_Standard_Type aType2 = STANDARD_TYPE(AIS_Shape); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(AIS_Shape); - static Handle_Standard_Type aType3 = STANDARD_TYPE(AIS_InteractiveObject); - if ( aType3.IsNull()) aType3 = STANDARD_TYPE(AIS_InteractiveObject); - static Handle_Standard_Type aType4 = STANDARD_TYPE(SelectMgr_SelectableObject); - if ( aType4.IsNull()) aType4 = STANDARD_TYPE(SelectMgr_SelectableObject); - static Handle_Standard_Type aType5 = STANDARD_TYPE(PrsMgr_PresentableObject); - if ( aType5.IsNull()) aType5 = STANDARD_TYPE(PrsMgr_PresentableObject); - static Handle_Standard_Type aType6 = STANDARD_TYPE(MMgt_TShared); - if ( aType6.IsNull()) aType6 = STANDARD_TYPE(MMgt_TShared); - static Handle_Standard_Type aType7 = STANDARD_TYPE(Standard_Transient); - if ( aType7.IsNull()) aType7 = STANDARD_TYPE(Standard_Transient); - - - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,aType5,aType6,aType7,NULL}; - static Handle_Standard_Type _aType = new Standard_Type("GEOM_AISShape", - sizeof(GEOM_AISShape), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(GEOM_AISShape) Handle(GEOM_AISShape)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(GEOM_AISShape) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(GEOM_AISShape))) { - _anOtherObject = Handle(GEOM_AISShape)((Handle(GEOM_AISShape)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& GEOM_AISShape::DynamicType() const -{ - return STANDARD_TYPE(GEOM_AISShape) ; -} -Standard_Boolean GEOM_AISShape::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(GEOM_AISShape) == AType || SALOME_AISShape::IsKind(AType)); -} -Handle_GEOM_AISShape::~Handle_GEOM_AISShape() {} - diff --git a/src/OBJECT/GEOM_Actor.cxx b/src/OBJECT/GEOM_Actor.cxx index 92860af3e..1b15c5640 100644 --- a/src/OBJECT/GEOM_Actor.cxx +++ b/src/OBJECT/GEOM_Actor.cxx @@ -82,10 +82,14 @@ GEOM_Actor::GEOM_Actor(): // myDisplayMode(eWireframe), myIsSelected(false), myVectorMode(false), + myVerticesMode(false), myVertexActor(GEOM_DeviceActor::New(),true), myVertexSource(GEOM_VertexSource::New(),true), + myStandaloneVertexActor(GEOM_DeviceActor::New(),true), + myStandaloneVertexSource(GEOM_VertexSource::New(),true), + myIsolatedEdgeActor(GEOM_DeviceActor::New(),true), myIsolatedEdgeSource(GEOM_EdgeSource::New(),true), @@ -129,13 +133,13 @@ GEOM_Actor::GEOM_Actor(): myHighlightProp->SetAmbientColor(1, 1, 1); myHighlightProp->SetDiffuseColor(1, 1, 1); myHighlightProp->SetSpecularColor(0.5, 0.5, 0.5); - myHighlightProp->SetPointSize(SALOME_POINT_SIZE); + myHighlightProp->SetPointSize(SALOME_POINT_SIZE+2); myHighlightActor->SetProperty(myHighlightProp.GetPointer()); this->myHighlightActor->SetInput(myAppendFilter->GetOutputPort(),false); myPreHighlightProp->SetColor(0,1,1); - myPreHighlightProp->SetPointSize(SALOME_POINT_SIZE+2); + myPreHighlightProp->SetPointSize(SALOME_POINT_SIZE); myPreHighlightProp->SetLineWidth(SALOME_LINE_WIDTH+1); myPreHighlightProp->SetRepresentationToWireframe(); @@ -146,6 +150,13 @@ GEOM_Actor::GEOM_Actor(): aProperty->SetPointSize(3); aProperty->SetColor(1, 1, 0); + myAppendFilter->AddInputConnection(myStandaloneVertexSource->GetOutputPort()); + myStandaloneVertexActor->SetInput(myStandaloneVertexSource->GetOutputPort(),false); + aProperty = myStandaloneVertexActor->GetProperty(); + aProperty->SetRepresentation(VTK_POINTS); + aProperty->SetPointSize(3); + aProperty->SetColor(1, 1, 0); + myAppendFilter->AddInputConnection(myIsolatedEdgeSource->GetOutputPort()); myIsolatedEdgeActor->SetInput(myIsolatedEdgeSource->GetOutputPort(),false); aProperty = myIsolatedEdgeActor->GetProperty(); @@ -186,12 +197,10 @@ GEOM_Actor::GEOM_Actor(): myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer()); - myNbIsos[0] = -1; - myNbIsos[1] = -1; - // Toggle display mode setDisplayMode(0); // WIRE FRAME SetVectorMode(0); // + SetVerticesMode(0); // } @@ -230,6 +239,7 @@ GEOM_Actor:: SetModified() { this->myVertexSource->Modified(); + this->myStandaloneVertexSource->Modified(); this->myIsolatedEdgeSource->Modified(); this->myOneFaceEdgeSource->Modified(); this->mySharedEdgeSource->Modified(); @@ -263,6 +273,7 @@ AddToRender(vtkRenderer* theRenderer) myIsolatedEdgeActor->AddToRender(theRenderer); myVertexActor->AddToRender(theRenderer); + myStandaloneVertexActor->AddToRender(theRenderer); } void @@ -283,6 +294,7 @@ RemoveFromRender(vtkRenderer* theRenderer) myIsolatedEdgeActor->RemoveFromRender(theRenderer); myVertexActor->RemoveFromRender(theRenderer); + myStandaloneVertexActor->RemoveFromRender(theRenderer); SetSelected(false); @@ -296,16 +308,6 @@ setDisplayMode(int theMode) #ifdef MYDEBUG MESSAGE ( "GEOM_Actor::setDisplayMode = "<GetProperty()->SetColor(myIsolatedEdgeColor[0], myIsolatedEdgeColor[1], @@ -371,7 +370,9 @@ SetVisibility(int theVisibility) myOneFaceEdgeActor->SetVisibility(theVisibility && (myDisplayMode == (int)eWireframe || myDisplayMode == (int)eShadingWithEdges) && !myIsSelected); myIsolatedEdgeActor->SetVisibility(theVisibility && !myIsSelected); - myVertexActor->SetVisibility(theVisibility && myDisplayMode == (int)eWireframe && !myIsSelected);// must be added new mode points + myVertexActor->SetVisibility(theVisibility && (isOnlyVertex || (myVerticesMode && (!myIsSelected && !myIsPreselected))));// must be added new mode points + + myStandaloneVertexActor->SetVisibility(theVisibility); } @@ -407,6 +408,26 @@ GEOM_Actor return myVectorMode; } +void +GEOM_Actor +::SetVerticesMode(bool theMode) +{ + myVerticesMode = theMode; + if ( theMode || isOnlyVertex ) { + myAppendFilter->AddInputConnection(myVertexSource->GetOutputPort()); + } else { + myAppendFilter->RemoveInputConnection(0, myVertexSource->GetOutputPort()); + } + SetModified(); +} + +bool +GEOM_Actor +::GetVerticesMode() +{ + return myVerticesMode; +} + void GEOM_Actor:: SetDeflection(float theDeflection) @@ -428,6 +449,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape, myShape = theShape; myVertexSource->Clear(); + myStandaloneVertexSource->Clear(); myIsolatedEdgeSource->Clear(); myOneFaceEdgeSource->Clear(); mySharedEdgeSource->Clear(); @@ -448,6 +470,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape, TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap); GEOM::SetShape(theShape,anEdgeMap,theIsVector, + myStandaloneVertexSource.Get(), myIsolatedEdgeSource.Get(), myOneFaceEdgeSource.Get(), mySharedEdgeSource.Get(), @@ -463,6 +486,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape, if((bool)myShape.Infinite() || isOnlyVertex ){ myVertexActor->GetDeviceActor()->SetInfinitive(true); + myStandaloneVertexActor->GetDeviceActor()->SetInfinitive(true); myHighlightActor->GetDeviceActor()->SetInfinitive(true); } @@ -518,6 +542,11 @@ vtkProperty* GEOM_Actor::GetVertexProperty() return myVertexActor->GetProperty(); } +vtkProperty* GEOM_Actor::GetStandaloneVertexProperty() +{ + return myStandaloneVertexActor->GetProperty(); +} + vtkProperty* GEOM_Actor::GetSharedEdgeProperty() { return mySharedEdgeActor->GetProperty(); @@ -707,6 +736,7 @@ void GEOM_Actor::SetOpacity(double opa) myHighlightProp->SetOpacity(opa); myPreHighlightProp->SetOpacity(opa); myVertexActor->GetProperty()->SetOpacity(opa); + myStandaloneVertexActor->GetProperty()->SetOpacity(opa); } double GEOM_Actor::GetOpacity() @@ -747,6 +777,7 @@ void GEOM_Actor::GetColor(double& r,double& g,double& b) void GEOM_Actor::SetPointColor(double r, double g, double b) { myVertexActor->GetProperty()->SetColor(r, g, b); + myStandaloneVertexActor->GetProperty()->SetColor(r, g, b); } /*! @@ -810,6 +841,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aCoefnt = theProps[0]->GetAmbient(); myShadingFaceProp->SetAmbient(aCoefnt); myVertexActor->GetProperty()->SetAmbient(aCoefnt); + myStandaloneVertexActor->GetProperty()->SetAmbient(aCoefnt); if ( aSize == 2 ) aCoefnt = theProps[1]->GetAmbient(); myShadingBackFaceProp->SetAmbient(aCoefnt); @@ -818,6 +850,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aCoefnt = theProps[0]->GetDiffuse(); myShadingFaceProp->SetDiffuse(aCoefnt); myVertexActor->GetProperty()->SetDiffuse(aCoefnt); + myStandaloneVertexActor->GetProperty()->SetDiffuse(aCoefnt); if ( aSize == 2 ) aCoefnt = theProps[1]->GetDiffuse(); myShadingBackFaceProp->SetDiffuse(aCoefnt); @@ -826,6 +859,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aCoefnt = theProps[0]->GetSpecular(); myShadingFaceProp->SetSpecular(aCoefnt); myVertexActor->GetProperty()->SetSpecular(aCoefnt); + myStandaloneVertexActor->GetProperty()->SetSpecular(aCoefnt); if ( aSize == 2 ) aCoefnt = theProps[1]->GetSpecular(); myShadingBackFaceProp->SetSpecular(aCoefnt); @@ -837,6 +871,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aColor = theProps[0]->GetAmbientColor(); myShadingFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]); + myStandaloneVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]); if ( aSize == 2 ) aColor = theProps[1]->GetAmbientColor(); myShadingBackFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]); @@ -845,6 +880,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aColor = theProps[0]->GetDiffuseColor(); myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); + myStandaloneVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); if ( aSize == 2 ) aColor = theProps[1]->GetDiffuseColor(); myShadingBackFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); @@ -853,6 +889,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aColor = theProps[0]->GetSpecularColor(); myShadingFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]); + myStandaloneVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]); if ( aSize == 2 ) aColor = theProps[1]->GetSpecularColor(); myShadingBackFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]); @@ -861,6 +898,7 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aCoefnt = theProps[0]->GetSpecularPower(); myShadingFaceProp->SetSpecularPower(aCoefnt); myVertexActor->GetProperty()->SetSpecularPower(aCoefnt); + myStandaloneVertexActor->GetProperty()->SetSpecularPower(aCoefnt); if ( aSize == 2 ) aCoefnt = theProps[1]->GetSpecularPower(); myShadingBackFaceProp->SetSpecularPower(aCoefnt); @@ -896,14 +934,6 @@ GEOM_Actor MESSAGE ( this << " GEOM_Actor::Highlight myIsSelected="<SetVisibility( false ); bool anIsPreselected = myIsPreselected; @@ -1081,11 +1103,6 @@ void GEOM_Actor::SetEdgesInShadingColor(double r,double g,double b) myEdgesInShadingColor[2] = b; } -void GEOM_Actor::StoreIsoNumbers() -{ - myWireframeFaceSource->GetNbIso(myNbIsos[0], myNbIsos[1]); -} - void GEOM_Actor::SetIsosWidth(const int width) { myWireframeFaceActor->GetProperty()->SetLineWidth(width); } @@ -1106,16 +1123,3 @@ void GEOM_Actor::SetWidth(const int width) { int GEOM_Actor::GetWidth() const { return (int)myIsolatedEdgeActor->GetProperty()->GetLineWidth(); } - -void GEOM_Actor::RestoreIsoNumbers() -{ - if ( myNbIsos[0] > 0 || myNbIsos[1] > 0 ) - // Restore number of U and (or) V iso lines - myWireframeFaceSource->SetNbIso(myNbIsos); -} - -void GEOM_Actor::ResetIsoNumbers() -{ - int aNb[2] = {0, 0}; - myWireframeFaceSource->SetNbIso(aNb); -} diff --git a/src/OBJECT/GEOM_Actor.h b/src/OBJECT/GEOM_Actor.h index 687663932..117f1afcb 100644 --- a/src/OBJECT/GEOM_Actor.h +++ b/src/OBJECT/GEOM_Actor.h @@ -89,6 +89,7 @@ public: vtkProperty* GetShadingProperty(); vtkProperty* GetIsolatedEdgeProperty(); vtkProperty* GetVertexProperty(); + vtkProperty* GetStandaloneVertexProperty(); vtkProperty* GetSharedEdgeProperty(); vtkProperty* GetFaceEdgeProperty(); @@ -201,15 +202,15 @@ public: virtual bool GetVectorMode(); - - void - StoreIsoNumbers(); + //! Vertices mode management + virtual void - RestoreIsoNumbers(); - - void - ResetIsoNumbers(); + SetVerticesMode(const bool theMode); + + virtual + bool + GetVerticesMode(); protected: void SetModified(); @@ -221,7 +222,6 @@ protected: private: TopoDS_Shape myShape; - int myNbIsos[2]; bool isOnlyVertex; float myDeflection; @@ -230,10 +230,14 @@ private: // EDisplayMode myDisplayMode; bool myIsSelected; bool myVectorMode; + bool myVerticesMode; PDeviceActor myVertexActor; PVertexSource myVertexSource; + PDeviceActor myStandaloneVertexActor; + PVertexSource myStandaloneVertexSource; + PDeviceActor myIsolatedEdgeActor; PEdgeSource myIsolatedEdgeSource; diff --git a/src/OBJECT/GEOM_Constants.cxx b/src/OBJECT/GEOM_Constants.cxx index 7790adcba..0ccf2ed1c 100644 --- a/src/OBJECT/GEOM_Constants.cxx +++ b/src/OBJECT/GEOM_Constants.cxx @@ -69,6 +69,8 @@ namespace GEOM "Color", // COLOR_PROP // "show edges direction" flag "VectorMode", // VECTOR_MODE_PROP + // "show vertices" flag + "VerticesMode", // VERTICES_MODE_PROP // deflection coefficient "DeflectionCoeff", // DEFLECTION_COEFF_PROP // point marker data diff --git a/src/OBJECT/GEOM_Constants.h b/src/OBJECT/GEOM_Constants.h index 17f65eb36..e314735f8 100644 --- a/src/OBJECT/GEOM_Constants.h +++ b/src/OBJECT/GEOM_Constants.h @@ -39,6 +39,7 @@ namespace GEOM NbIsos, Color, EdgesDirection, + Vertices, Deflection, PointMarker, Material, diff --git a/src/OBJECT/GEOM_InteractiveObject.cxx b/src/OBJECT/GEOM_InteractiveObject.cxx index 3416b6cd7..ed6306e67 100644 --- a/src/OBJECT/GEOM_InteractiveObject.cxx +++ b/src/OBJECT/GEOM_InteractiveObject.cxx @@ -20,17 +20,15 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// GEOM OBJECT : interactive object for Geometry entities visualization -// File : GEOM_InteractiveObject.cxx -// Author : Christophe ATTANASIO -// Module : GEOM -// /*! \class GEOM_InteractiveObject GEOM_InteractiveObject.hxx \brief .... */ -#include "GEOM_InteractiveObject.ixx" +#include "GEOM_InteractiveObject.hxx" + +IMPLEMENT_STANDARD_HANDLE (GEOM_InteractiveObject, SALOME_InteractiveObject) +IMPLEMENT_STANDARD_RTTIEXT(GEOM_InteractiveObject, SALOME_InteractiveObject) GEOM_InteractiveObject::GEOM_InteractiveObject() : SALOME_InteractiveObject() @@ -49,15 +47,22 @@ GEOM_InteractiveObject::GEOM_InteractiveObject(const char* anIOR, myFatherIOR = aFatherIOR; } -const char* GEOM_InteractiveObject::getIOR(){ +GEOM_InteractiveObject::~GEOM_InteractiveObject() +{ +} + +const char* GEOM_InteractiveObject::getIOR() +{ return myIOR.c_str(); } -const char* GEOM_InteractiveObject::getFatherIOR(){ +const char* GEOM_InteractiveObject::getFatherIOR() +{ return myFatherIOR.c_str(); } -Standard_Boolean GEOM_InteractiveObject::isSame(const Handle(SALOME_InteractiveObject)& anIO ){ +Standard_Boolean GEOM_InteractiveObject::isSame(const Handle(SALOME_InteractiveObject)& anIO ) +{ if ( anIO->hasEntry() && this->hasEntry() ) { if ( myEntry == anIO->getEntry() ) return Standard_True; diff --git a/src/OBJECT/GEOM_InteractiveObject.hxx b/src/OBJECT/GEOM_InteractiveObject.hxx index 27f24e4d7..2800e8fa8 100644 --- a/src/OBJECT/GEOM_InteractiveObject.hxx +++ b/src/OBJECT/GEOM_InteractiveObject.hxx @@ -20,106 +20,40 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// GEOM OBJECT : interactive object for Geometry entities visualization -// File : GEOM_InteractiveObject.hxx -// Module : GEOM -// #ifndef _GEOM_InteractiveObject_HeaderFile #define _GEOM_InteractiveObject_HeaderFile -#ifndef _Standard_HeaderFile +#include + #include -#endif -#ifndef _Handle_GEOM_InteractiveObject_HeaderFile -#include "Handle_GEOM_InteractiveObject.hxx" -#endif - -#ifndef _Standard_CString_HeaderFile -#include -#endif -#ifndef _SALOME_InteractiveObject_HeaderFile -#include "SALOME_InteractiveObject.hxx" -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Handle_SALOME_InteractiveObject_HeaderFile -#include "Handle_SALOME_InteractiveObject.hxx" -#endif - -class GEOM_InteractiveObject : public SALOME_InteractiveObject { +#include +class GEOM_InteractiveObject : public SALOME_InteractiveObject +{ public: + Standard_EXPORT GEOM_InteractiveObject(); + Standard_EXPORT GEOM_InteractiveObject(const char* anIOR, + const char* aFatherIOR, + const char* aComponentDataType, + const char* anEntry = ""); + Standard_EXPORT ~GEOM_InteractiveObject(); - 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); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT GEOM_InteractiveObject(); -Standard_EXPORT GEOM_InteractiveObject(const char* anIOR, - const char* aFatherIOR, - const char* aComponentDataType, - const char* anEntry = ""); -Standard_EXPORT void setIOR(const char* anEntry) ; -Standard_EXPORT const char* getIOR() ; -Standard_EXPORT void setFatherIOR(const char* anEntry) ; -Standard_EXPORT const char* getFatherIOR() ; -Standard_EXPORT virtual Standard_Boolean isSame(const Handle(SALOME_InteractiveObject)& anIO) ; -Standard_EXPORT ~GEOM_InteractiveObject(); + Standard_EXPORT void setIOR(const char* anEntry); + Standard_EXPORT const char* getIOR(); + Standard_EXPORT void setFatherIOR(const char* anEntry); + Standard_EXPORT const char* getFatherIOR(); - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& GEOM_InteractiveObject_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - + Standard_EXPORT virtual Standard_Boolean isSame(const Handle(SALOME_InteractiveObject)& anIO); private: + std::string myIOR; + std::string myFatherIOR; - // Methods PRIVATE - // - - - // Fields PRIVATE - // -std::string myIOR; -std::string myFatherIOR; - - +public: + DEFINE_STANDARD_RTTI(GEOM_InteractiveObject); }; - - - - -// other inline functions and methods (like "C++: function call" methods) -// - +DEFINE_STANDARD_HANDLE(GEOM_InteractiveObject, SALOME_InteractiveObject) #endif diff --git a/src/OBJECT/GEOM_InteractiveObject.ixx b/src/OBJECT/GEOM_InteractiveObject.ixx deleted file mode 100644 index 1bb456136..000000000 --- a/src/OBJECT/GEOM_InteractiveObject.ixx +++ /dev/null @@ -1,83 +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 OBJECT : interactive object for Geometry entities visualization -// File : GEOM_InteractiveObject.ixx -// Module : GEOM -// -#include "GEOM_InteractiveObject.jxx" - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -GEOM_InteractiveObject::~GEOM_InteractiveObject() {} - - - -Standard_EXPORT Handle_Standard_Type& GEOM_InteractiveObject_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_InteractiveObject); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_InteractiveObject); - 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("GEOM_InteractiveObject", - sizeof(GEOM_InteractiveObject), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(GEOM_InteractiveObject) Handle(GEOM_InteractiveObject)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(GEOM_InteractiveObject) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) { - _anOtherObject = Handle(GEOM_InteractiveObject)((Handle(GEOM_InteractiveObject)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& GEOM_InteractiveObject::DynamicType() const -{ - return STANDARD_TYPE(GEOM_InteractiveObject) ; -} -Standard_Boolean GEOM_InteractiveObject::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(GEOM_InteractiveObject) == AType || SALOME_InteractiveObject::IsKind(AType)); -} -Handle_GEOM_InteractiveObject::~Handle_GEOM_InteractiveObject() {} - 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/OBJECT/GEOM_TopWireframeShape.cxx b/src/OBJECT/GEOM_TopWireframeShape.cxx index 0cec60e0d..4defd1989 100755 --- a/src/OBJECT/GEOM_TopWireframeShape.cxx +++ b/src/OBJECT/GEOM_TopWireframeShape.cxx @@ -32,7 +32,7 @@ */ //Local includes -#include "GEOM_TopWireframeShape.ixx" +#include "GEOM_TopWireframeShape.hxx" #include "GEOM_AISShape.hxx" //GUI includes @@ -43,64 +43,74 @@ #include #include -GEOM_TopWireframeShape::GEOM_TopWireframeShape(const TopoDS_Shape& shape) - : SALOME_AISShape(shape) +IMPLEMENT_STANDARD_HANDLE(GEOM_TopWireframeShape, SALOME_AISShape) +IMPLEMENT_STANDARD_RTTIEXT(GEOM_TopWireframeShape, SALOME_AISShape) + +GEOM_TopWireframeShape::GEOM_TopWireframeShape( const TopoDS_Shape& shape ) + :SALOME_AISShape(shape) { - SetDisplayMode(AIS_WireFrame); - Handle(Prs3d_IsoAspect) anAspect = Attributes()->UIsoAspect(); - anAspect->SetNumber( 0 ); - Attributes()->SetUIsoAspect( anAspect ); - anAspect = Attributes()->VIsoAspect(); - anAspect->SetNumber( 0 ); - Attributes()->SetVIsoAspect( anAspect ); - SetColor(GEOM_AISShape::topLevelColor()); + SetDisplayMode( AIS_WireFrame ); + Handle(Prs3d_IsoAspect) anAspect = Attributes()->UIsoAspect(); + anAspect->SetNumber( 0 ); + Attributes()->SetUIsoAspect( anAspect ); + anAspect = Attributes()->VIsoAspect(); + anAspect->SetNumber( 0 ); + Attributes()->SetVIsoAspect( anAspect ); + SetColor( GEOM_AISShape::topLevelColor() ); } GEOM_TopWireframeShape::~GEOM_TopWireframeShape() { } -Handle(SALOME_InteractiveObject) GEOM_TopWireframeShape::getIO(){ +Handle(SALOME_InteractiveObject) GEOM_TopWireframeShape::getIO() +{ Handle(SALOME_InteractiveObject) IO; if ( !GetOwner().IsNull() ) IO = Handle(SALOME_InteractiveObject)::DownCast( GetOwner() ); return IO; } -Standard_Boolean GEOM_TopWireframeShape::hasIO(){ +Standard_Boolean GEOM_TopWireframeShape::hasIO() +{ return !getIO().IsNull(); } -void GEOM_TopWireframeShape::setName(const Standard_CString /*aName*/) +void GEOM_TopWireframeShape::setName( const Standard_CString /*aName*/ ) { } -Standard_CString GEOM_TopWireframeShape::getName(){ +Standard_CString GEOM_TopWireframeShape::getName() +{ return ""; } -void GEOM_TopWireframeShape::highlightSubShapes(const TColStd_IndexedMapOfInteger& /*aIndexMap*/, - const Standard_Boolean /*aHighlight*/ ) +void GEOM_TopWireframeShape::highlightSubShapes( const TColStd_IndexedMapOfInteger& /*aIndexMap*/, + const Standard_Boolean /*aHighlight*/ ) { } -Standard_Boolean GEOM_TopWireframeShape::isTopLevel() { +Standard_Boolean GEOM_TopWireframeShape::isTopLevel() +{ return Standard_True; } -void GEOM_TopWireframeShape::setTopLevel(Standard_Boolean /*f*/) { - +void GEOM_TopWireframeShape::setTopLevel( Standard_Boolean /*f*/ ) +{ } -Standard_Boolean GEOM_TopWireframeShape::toActivate() { - return Standard_False; +Standard_Boolean GEOM_TopWireframeShape::toActivate() +{ + return Standard_True; } -Standard_Boolean GEOM_TopWireframeShape::switchTopLevel() { - return Standard_True; +Standard_Boolean GEOM_TopWireframeShape::switchTopLevel() +{ + return Standard_True; } -void GEOM_TopWireframeShape::setIO(const Handle(SALOME_InteractiveObject)& io){ +void GEOM_TopWireframeShape::setIO( const Handle(SALOME_InteractiveObject)& io ) +{ SetOwner( io ); } diff --git a/src/OBJECT/GEOM_TopWireframeShape.hxx b/src/OBJECT/GEOM_TopWireframeShape.hxx index 97d7bf9c1..1a35990b1 100755 --- a/src/OBJECT/GEOM_TopWireframeShape.hxx +++ b/src/OBJECT/GEOM_TopWireframeShape.hxx @@ -20,91 +20,39 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// GEOM OBJECT : interactive object for Geometry entities visualization -// File : GEOM_TopWireframeShape.hxx -// Module : GEOM -// #ifndef _GEOM_TopWireframeShape_HeaderFile #define _GEOM_TopWireframeShape_HeaderFile -#include "GEOM_OBJECT_defs.hxx" +#include -#ifndef _Standard_HeaderFile #include -#endif -#ifndef _Handle_GEOM_TopWireframeShape_HeaderFile -#include "Handle_GEOM_TopWireframeShape.hxx" -#endif +#include -#ifndef _SALOME_AISShape_HeaderFile -#include "SALOME_AISShape.hxx" -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif +class GEOM_TopWireframeShape : public SALOME_AISShape +{ +public: + Standard_EXPORT GEOM_TopWireframeShape(const TopoDS_Shape& shape); + Standard_EXPORT ~GEOM_TopWireframeShape(); -class GEOM_OBJECT_EXPORT GEOM_TopWireframeShape : public SALOME_AISShape { + Standard_EXPORT virtual Standard_Boolean hasIO(); + Standard_EXPORT void setIO(const Handle(SALOME_InteractiveObject)& io); + Standard_EXPORT virtual Handle(SALOME_InteractiveObject) getIO(); + + Standard_EXPORT virtual void setName(const Standard_CString aName); + Standard_EXPORT virtual Standard_CString getName(); + + Standard_EXPORT virtual Standard_Boolean isTopLevel(); + Standard_EXPORT virtual void setTopLevel(Standard_Boolean); + Standard_EXPORT virtual Standard_Boolean switchTopLevel(); + + Standard_EXPORT virtual Standard_Boolean toActivate(); + + Standard_EXPORT virtual void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight ); 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); - } - // inline void operator delete(void *anAddress, size_t size) - // { - // if (anAddress) Standard::Free((Standard_Address&)anAddress,size); - // } - - // Methods PUBLIC - // - GEOM_TopWireframeShape(const TopoDS_Shape& shape); - virtual Handle_SALOME_InteractiveObject getIO(); - virtual Standard_Boolean hasIO(); - virtual Standard_Boolean isTopLevel(); - virtual Standard_Boolean switchTopLevel(); - virtual Standard_Boolean toActivate(); - virtual void setTopLevel(Standard_Boolean); - virtual Standard_CString getName(); - virtual void setName(const Standard_CString aName); - virtual void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight ); - ~GEOM_TopWireframeShape(); - - // Type management - // - friend Handle_Standard_Type& GEOM_TopWireframeShape_Type_(); - const Handle(Standard_Type)& DynamicType() const; - Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - - - void setIO(const Handle(SALOME_InteractiveObject)& io); - -protected: - - // Methods PROTECTED - // - - // Fields PROTECTED - // - -private: - - // Methods PRIVATE - // - - // Fields PRIVATE - // + DEFINE_STANDARD_RTTI(GEOM_TopWireframeShape); }; -// other inline functions and methods (like "C++: function call" methods) -// +DEFINE_STANDARD_HANDLE(GEOM_TopWireframeShape, SALOME_AISShape) #endif diff --git a/src/OBJECT/GEOM_TopWireframeShape.ixx b/src/OBJECT/GEOM_TopWireframeShape.ixx deleted file mode 100755 index e57a7a8dd..000000000 --- a/src/OBJECT/GEOM_TopWireframeShape.ixx +++ /dev/null @@ -1,87 +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 OBJECT : interactive object for Geometry entities visualization -// File : GEOM_AISShape.ixx -// Module : GEOM -// -#include "GEOM_TopWireframeShape.jxx" - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -Standard_EXPORT Handle_Standard_Type& GEOM_TopWireframeShape_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_AISShape); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_AISShape); - static Handle_Standard_Type aType2 = STANDARD_TYPE(AIS_Shape); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(AIS_Shape); - static Handle_Standard_Type aType3 = STANDARD_TYPE(AIS_InteractiveObject); - if ( aType3.IsNull()) aType3 = STANDARD_TYPE(AIS_InteractiveObject); - static Handle_Standard_Type aType4 = STANDARD_TYPE(SelectMgr_SelectableObject); - if ( aType4.IsNull()) aType4 = STANDARD_TYPE(SelectMgr_SelectableObject); - static Handle_Standard_Type aType5 = STANDARD_TYPE(PrsMgr_PresentableObject); - if ( aType5.IsNull()) aType5 = STANDARD_TYPE(PrsMgr_PresentableObject); - static Handle_Standard_Type aType6 = STANDARD_TYPE(MMgt_TShared); - if ( aType6.IsNull()) aType6 = STANDARD_TYPE(MMgt_TShared); - static Handle_Standard_Type aType7 = STANDARD_TYPE(Standard_Transient); - if ( aType7.IsNull()) aType7 = STANDARD_TYPE(Standard_Transient); - - - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,aType5,aType6,aType7,NULL}; - static Handle_Standard_Type _aType = new Standard_Type("GEOM_TopWireframeShape", - sizeof(GEOM_TopWireframeShape), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(GEOM_TopWireframeShape) Handle(GEOM_TopWireframeShape)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(GEOM_TopWireframeShape) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(GEOM_TopWireframeShape))) { - _anOtherObject = Handle(GEOM_TopWireframeShape)((Handle(GEOM_TopWireframeShape)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& GEOM_TopWireframeShape::DynamicType() const -{ - return STANDARD_TYPE(GEOM_TopWireframeShape) ; -} -Standard_Boolean GEOM_TopWireframeShape::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(GEOM_TopWireframeShape) == AType || SALOME_AISShape::IsKind(AType)); -} -Handle_GEOM_TopWireframeShape::~Handle_GEOM_TopWireframeShape() {} - diff --git a/src/OBJECT/Handle_GEOM_AISShape.hxx b/src/OBJECT/Handle_GEOM_AISShape.hxx deleted file mode 100644 index 0193845f4..000000000 --- a/src/OBJECT/Handle_GEOM_AISShape.hxx +++ /dev/null @@ -1,100 +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 OBJECT : interactive object for Geometry entities visualization -// File : Handle_GEOM_AISShape.hxx -// Module : GEOM -// -#ifndef _Handle_GEOM_AISShape_HeaderFile -#define _Handle_GEOM_AISShape_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_SALOME_AISShape_HeaderFile -#include "Handle_SALOME_AISShape.hxx" -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(SALOME_AISShape); -class GEOM_AISShape; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_AISShape); - -class Handle(GEOM_AISShape) : public Handle(SALOME_AISShape) { - 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); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - Handle(GEOM_AISShape)():Handle(SALOME_AISShape)() {} - Handle(GEOM_AISShape)(const Handle(GEOM_AISShape)& aHandle) : Handle(SALOME_AISShape)(aHandle) - { - } - - Handle(GEOM_AISShape)(const GEOM_AISShape* anItem) : Handle(SALOME_AISShape)((SALOME_AISShape *)anItem) - { - } - - Handle(GEOM_AISShape)& operator=(const Handle(GEOM_AISShape)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(GEOM_AISShape)& operator=(const GEOM_AISShape* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - GEOM_AISShape* operator->() - { - return (GEOM_AISShape *)ControlAccess(); - } - - GEOM_AISShape* operator->() const - { - return (GEOM_AISShape *)ControlAccess(); - } - - Standard_EXPORT ~Handle(GEOM_AISShape)(); - - Standard_EXPORT static const Handle(GEOM_AISShape) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/OBJECT/Handle_GEOM_InteractiveObject.hxx b/src/OBJECT/Handle_GEOM_InteractiveObject.hxx deleted file mode 100644 index f487f2b79..000000000 --- a/src/OBJECT/Handle_GEOM_InteractiveObject.hxx +++ /dev/null @@ -1,100 +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 OBJECT : interactive object for Geometry entities visualization -// File : Handle_GEOM_InteractiveObject.hxx -// Module : GEOM -// -#ifndef _Handle_GEOM_InteractiveObject_HeaderFile -#define _Handle_GEOM_InteractiveObject_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_SALOME_InteractiveObject_HeaderFile -#include "Handle_SALOME_InteractiveObject.hxx" -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(SALOME_InteractiveObject); -class GEOM_InteractiveObject; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_InteractiveObject); - -class Handle(GEOM_InteractiveObject) : public Handle(SALOME_InteractiveObject) { - 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); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - Handle(GEOM_InteractiveObject)():Handle(SALOME_InteractiveObject)() {} - Handle(GEOM_InteractiveObject)(const Handle(GEOM_InteractiveObject)& aHandle) : Handle(SALOME_InteractiveObject)(aHandle) - { - } - - Handle(GEOM_InteractiveObject)(const GEOM_InteractiveObject* anItem) : Handle(SALOME_InteractiveObject)((SALOME_InteractiveObject *)anItem) - { - } - - Handle(GEOM_InteractiveObject)& operator=(const Handle(GEOM_InteractiveObject)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(GEOM_InteractiveObject)& operator=(const GEOM_InteractiveObject* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - GEOM_InteractiveObject* operator->() - { - return (GEOM_InteractiveObject *)ControlAccess(); - } - - GEOM_InteractiveObject* operator->() const - { - return (GEOM_InteractiveObject *)ControlAccess(); - } - - Standard_EXPORT ~Handle(GEOM_InteractiveObject)(); - - Standard_EXPORT static const Handle(GEOM_InteractiveObject) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/OBJECT/Handle_GEOM_TopWireframeShape.hxx b/src/OBJECT/Handle_GEOM_TopWireframeShape.hxx deleted file mode 100755 index f2b0a2cbd..000000000 --- a/src/OBJECT/Handle_GEOM_TopWireframeShape.hxx +++ /dev/null @@ -1,100 +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 OBJECT : interactive object for Geometry entities visualization -// File : Handle_GEOM_TopWireframeShape.hxx -// Module : GEOM -// -#ifndef _Handle_GEOM_TopWireframeShape_HeaderFile -#define _Handle_GEOM_TopWireframeShape_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_SALOME_AISShape_HeaderFile -#include "Handle_SALOME_AISShape.hxx" -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(SALOME_AISShape); -class GEOM_TopWireframeShape; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_TopWireframeShape); - -class Handle(GEOM_TopWireframeShape) : public Handle(SALOME_AISShape) { - 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); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - Handle(GEOM_TopWireframeShape)():Handle(SALOME_AISShape)() {} - Handle(GEOM_TopWireframeShape)(const Handle(GEOM_TopWireframeShape)& aHandle) : Handle(SALOME_AISShape)(aHandle) - { - } - - Handle(GEOM_TopWireframeShape)(const GEOM_TopWireframeShape* anItem) : Handle(SALOME_AISShape)((SALOME_AISShape *)anItem) - { - } - - Handle(GEOM_TopWireframeShape)& operator=(const Handle(GEOM_TopWireframeShape)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(GEOM_TopWireframeShape)& operator=(const GEOM_TopWireframeShape* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - GEOM_TopWireframeShape* operator->() - { - return (GEOM_TopWireframeShape *)ControlAccess(); - } - - GEOM_TopWireframeShape* operator->() const - { - return (GEOM_TopWireframeShape *)ControlAccess(); - } - - Standard_EXPORT ~Handle(GEOM_TopWireframeShape)(); - - Standard_EXPORT static const Handle(GEOM_TopWireframeShape) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/OCC2VTK/GEOM_EdgeSource.cxx b/src/OCC2VTK/GEOM_EdgeSource.cxx index 0a3a41a0d..2ff7b91c7 100755 --- a/src/OCC2VTK/GEOM_EdgeSource.cxx +++ b/src/OCC2VTK/GEOM_EdgeSource.cxx @@ -18,7 +18,6 @@ // #include "GEOM_EdgeSource.h" -#include "OCC2VTK_internal.h" #include @@ -43,32 +42,20 @@ vtkStandardNewMacro(GEOM_EdgeSource); GEOM_EdgeSource::GEOM_EdgeSource() : myIsVector(false) { - myData = new EdgeSourceInternal; this->SetNumberOfInputPorts(0); } GEOM_EdgeSource::~GEOM_EdgeSource() -{ - delete myData; +{ } void GEOM_EdgeSource::AddEdge (const TopoDS_Edge& theEdge, bool theIsVector) { - myData->myEdgeSet.Add(theEdge); + myEdgeSet.Add(theEdge); myIsVector = theIsVector; } -void GEOM_EdgeSource::Clear() -{ - myData->myEdgeSet.Clear(); -} - -bool GEOM_EdgeSource::IsEmpty() -{ - return myData->myEdgeSet.IsEmpty(); -} - int GEOM_EdgeSource::RequestData(vtkInformation *vtkNotUsed(request), vtkInformationVector **vtkNotUsed(inputVector), vtkInformationVector *outputVector) @@ -82,7 +69,7 @@ int GEOM_EdgeSource::RequestData(vtkInformation *vtkNotUsed(request), aPolyData->SetPoints(aPts); aPts->Delete(); - TEdgeSet::Iterator anIter (myData->myEdgeSet); + TEdgeSet::Iterator anIter (myEdgeSet); for (; anIter.More(); anIter.Next()) { TopoDS_Edge anEdge = anIter.Value(); if ( !myIsVector ) diff --git a/src/OCC2VTK/GEOM_EdgeSource.h b/src/OCC2VTK/GEOM_EdgeSource.h index da64b0a52..0c2dbb67a 100755 --- a/src/OCC2VTK/GEOM_EdgeSource.h +++ b/src/OCC2VTK/GEOM_EdgeSource.h @@ -23,26 +23,26 @@ #include "OCC2VTK.h" #include +#include +#include + +typedef NCollection_Map TEdgeSet; #include #include class vtkPolyData; -class EdgeSourceInternal; class OCC2VTK_EXPORT GEOM_EdgeSource: public vtkPolyDataAlgorithm { public: - vtkTypeMacro(GEOM_EdgeSource, vtkPolyDataAlgorithm); - + vtkTypeMacro(GEOM_EdgeSource,vtkPolyDataAlgorithm); static GEOM_EdgeSource* New(); void AddEdge (const TopoDS_Edge& theEdge, bool theIsVector = false); - void Clear(); + void Clear(){ myEdgeSet.Clear();} - bool IsEmpty(); - void SetVectorMode(bool); bool GetVectorMode(); @@ -52,14 +52,17 @@ public: vtkPolyData* thePolyData, vtkPoints* thePts, bool theIsVector = false); + + bool IsEmpty(){return myEdgeSet.IsEmpty();} + protected: - EdgeSourceInternal* myData; + TEdgeSet myEdgeSet; // The flag is common for all edges, because the shape, // representing a vector, can have only one edge. bool myIsVector, myIsVectorMode; - virtual int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*); + virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); GEOM_EdgeSource(); ~GEOM_EdgeSource(); @@ -70,4 +73,5 @@ private: void operator=(const GEOM_EdgeSource&); }; + #endif //GEOM_EDGESOURCE_H diff --git a/src/OCC2VTK/GEOM_FaceSource.cxx b/src/OCC2VTK/GEOM_FaceSource.cxx index 41c4bf547..7067a7282 100755 --- a/src/OCC2VTK/GEOM_FaceSource.cxx +++ b/src/OCC2VTK/GEOM_FaceSource.cxx @@ -18,7 +18,6 @@ // #include "GEOM_FaceSource.h" -#include "OCC2VTK_internal.h" #include @@ -30,35 +29,19 @@ GEOM_FaceSource::GEOM_FaceSource() { - myData = new FaceSourceInternal; this->SetNumberOfInputPorts(0); -} +} GEOM_FaceSource::~GEOM_FaceSource() { - delete myData; -} +} void GEOM_FaceSource:: AddFace(const TopoDS_Face& theFace) { - myData->myFaceSet.Add(theFace); + myFaceSet.Add(theFace); } - -void -GEOM_FaceSource:: -Clear() -{ - myData->myFaceSet.Clear(); -} - -bool -GEOM_FaceSource:: -IsEmpty() -{ - return myData->myFaceSet.IsEmpty(); -} void GEOM_FaceSource:: diff --git a/src/OCC2VTK/GEOM_FaceSource.h b/src/OCC2VTK/GEOM_FaceSource.h index 8a824f8e0..68d507657 100755 --- a/src/OCC2VTK/GEOM_FaceSource.h +++ b/src/OCC2VTK/GEOM_FaceSource.h @@ -24,12 +24,15 @@ #include #include +#include +#include + +typedef NCollection_Map TFaceSet; #include #include class vtkPolyData; -class FaceSourceInternal; class OCC2VTK_EXPORT GEOM_FaceSource: public vtkPolyDataAlgorithm { @@ -37,11 +40,11 @@ public: vtkTypeMacro(GEOM_FaceSource,vtkPolyDataAlgorithm); void AddFace(const TopoDS_Face& theFace); - void Clear(); - bool IsEmpty(); + void Clear(){ myFaceSet.Clear();} + bool IsEmpty(){return myFaceSet.IsEmpty();} protected: - FaceSourceInternal* myData; + TFaceSet myFaceSet; static void MoveTo(gp_Pnt thePnt, diff --git a/src/OCC2VTK/GEOM_ShadingFace.cxx b/src/OCC2VTK/GEOM_ShadingFace.cxx index a802cbce3..9b56761ee 100755 --- a/src/OCC2VTK/GEOM_ShadingFace.cxx +++ b/src/OCC2VTK/GEOM_ShadingFace.cxx @@ -18,7 +18,6 @@ // #include "GEOM_ShadingFace.h" -#include "OCC2VTK_internal.h" #include @@ -58,7 +57,7 @@ int GEOM_ShadingFace::RequestData(vtkInformation *vtkNotUsed(request), aPolyData->SetPoints(aPts); aPts->Delete(); - TFaceSet::Iterator anIter(myData->myFaceSet); + TFaceSet::Iterator anIter(myFaceSet); for(; anIter.More(); anIter.Next()){ const TopoDS_Face& aFace = anIter.Value(); OCC2VTK(aFace,aPolyData,aPts); diff --git a/src/OCC2VTK/GEOM_VertexSource.cxx b/src/OCC2VTK/GEOM_VertexSource.cxx index 9df081137..e313ff865 100755 --- a/src/OCC2VTK/GEOM_VertexSource.cxx +++ b/src/OCC2VTK/GEOM_VertexSource.cxx @@ -18,7 +18,6 @@ // #include "GEOM_VertexSource.h" -#include "OCC2VTK_internal.h" #include @@ -35,29 +34,20 @@ vtkStandardNewMacro(GEOM_VertexSource); GEOM_VertexSource::GEOM_VertexSource() -{ - myData = new VertexSourceInternal; +{ this->SetNumberOfInputPorts(0); -} +} GEOM_VertexSource::~GEOM_VertexSource() -{ - delete myData; -} +{ +} void GEOM_VertexSource:: AddVertex(const TopoDS_Vertex& theVertex) -{ - myData->myVertexSet.Add(theVertex); -} - -void -GEOM_VertexSource:: -Clear() -{ - myData->myVertexSet.Clear(); -} +{ + myVertexSet.Add(theVertex); +} int GEOM_VertexSource::RequestData(vtkInformation *vtkNotUsed(request), vtkInformationVector **vtkNotUsed(inputVector), @@ -72,7 +62,7 @@ int GEOM_VertexSource::RequestData(vtkInformation *vtkNotUsed(request), aPolyData->SetPoints(aPts); aPts->Delete(); - TVertexSet::Iterator anIter(myData->myVertexSet); + TVertexSet::Iterator anIter(myVertexSet); for(; anIter.More(); anIter.Next()){ const TopoDS_Vertex& aVertex = anIter.Value(); OCC2VTK(aVertex,aPolyData,aPts); diff --git a/src/OCC2VTK/GEOM_VertexSource.h b/src/OCC2VTK/GEOM_VertexSource.h index d3e64c1c8..d0ca91e35 100755 --- a/src/OCC2VTK/GEOM_VertexSource.h +++ b/src/OCC2VTK/GEOM_VertexSource.h @@ -23,12 +23,15 @@ #include "OCC2VTK.h" #include +#include +#include + +typedef NCollection_Map TVertexSet; #include #include class vtkPolyData; -class VertexSourceInternal; class OCC2VTK_EXPORT GEOM_VertexSource: public vtkPolyDataAlgorithm { @@ -37,7 +40,7 @@ public: static GEOM_VertexSource* New(); void AddVertex(const TopoDS_Vertex& theVertex); - void Clear(); + void Clear(){ myVertexSet.Clear();} static void OCC2VTK(const TopoDS_Vertex& theVertex, @@ -45,7 +48,7 @@ public: vtkPoints* thePts); protected: - VertexSourceInternal* myData; + TVertexSet myVertexSet; virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); diff --git a/src/OCC2VTK/GEOM_WireframeFace.cxx b/src/OCC2VTK/GEOM_WireframeFace.cxx index cf91f71e6..f9d31608e 100755 --- a/src/OCC2VTK/GEOM_WireframeFace.cxx +++ b/src/OCC2VTK/GEOM_WireframeFace.cxx @@ -18,7 +18,6 @@ // #include "GEOM_WireframeFace.h" -#include "OCC2VTK_internal.h" #include @@ -64,7 +63,7 @@ int GEOM_WireframeFace::RequestData(vtkInformation *vtkNotUsed(request), aPolyData->SetPoints(aPts); aPts->Delete(); - TFaceSet::Iterator anIter(myData->myFaceSet); + TFaceSet::Iterator anIter(myFaceSet); for(; anIter.More(); anIter.Next()){ const TopoDS_Face& aFace = anIter.Value(); OCC2VTK(aFace,aPolyData,aPts,NbIso,Discret); @@ -110,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(); @@ -126,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/OCC2VTK/OCC2VTK_Tools.cxx b/src/OCC2VTK/OCC2VTK_Tools.cxx index 8e325c887..e9b592035 100755 --- a/src/OCC2VTK/OCC2VTK_Tools.cxx +++ b/src/OCC2VTK/OCC2VTK_Tools.cxx @@ -88,6 +88,7 @@ namespace GEOM void SetShape(const TopoDS_Shape& theShape, const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap, bool theIsVector, + GEOM_VertexSource* theStandaloneVertexSource, GEOM_EdgeSource* theIsolatedEdgeSource, GEOM_EdgeSource* theOneFaceEdgeSource, GEOM_EdgeSource* theSharedEdgeSource, @@ -98,6 +99,7 @@ namespace GEOM TopoDS_Iterator anItr(theShape); for (; anItr.More(); anItr.Next()) { SetShape(anItr.Value(),theEdgeMap,theIsVector, + theStandaloneVertexSource, theIsolatedEdgeSource, theOneFaceEdgeSource, theSharedEdgeSource, @@ -123,6 +125,10 @@ namespace GEOM break; } case TopAbs_VERTEX: { + if ( theStandaloneVertexSource ) { + const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape); + theStandaloneVertexSource->AddVertex(aVertex); + } break; } default: { diff --git a/src/OCC2VTK/OCC2VTK_Tools.h b/src/OCC2VTK/OCC2VTK_Tools.h index c4fb478c6..523ca14b9 100755 --- a/src/OCC2VTK/OCC2VTK_Tools.h +++ b/src/OCC2VTK/OCC2VTK_Tools.h @@ -25,6 +25,7 @@ #include #include +class GEOM_VertexSource; class GEOM_EdgeSource; class GEOM_WireframeFace; class GEOM_ShadingFace; @@ -40,6 +41,7 @@ namespace GEOM OCC2VTK_EXPORT void SetShape(const TopoDS_Shape& theShape, const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap, bool theIsVector, + GEOM_VertexSource* theStandaloneVertexSource, GEOM_EdgeSource* theIsolatedEdgeSource, GEOM_EdgeSource* theOneFaceEdgeSource, GEOM_EdgeSource* theSharedEdgeSource, diff --git a/src/OCC2VTK/OCC2VTK_internal.h b/src/OCC2VTK/OCC2VTK_internal.h deleted file mode 100644 index 32e2869e2..000000000 --- a/src/OCC2VTK/OCC2VTK_internal.h +++ /dev/null @@ -1,228 +0,0 @@ -#ifndef OCC2VTK_INTERNAL_H -#define OCC2VTK_INTERNAL_H - -#include -#include -#include -#include - -#include -#include -#include - -template class GEOM_Set - : public NCollection_BaseCollection, - public NCollection_BaseList -{ -public: - typedef NCollection_TListNode SetNode; - typedef NCollection_TListIterator Iterator; - -public: - //! Constructor - GEOM_Set(const Handle(NCollection_BaseAllocator)& theAllocator=0L) : - NCollection_BaseCollection(theAllocator), - NCollection_BaseList() {} - - //! Copy constructor - GEOM_Set (const GEOM_Set& theOther) : - NCollection_BaseCollection(theOther.myAllocator), - NCollection_BaseList() - { *this = theOther; } - - //! Size - Number of items - virtual Standard_Integer Size (void) const - { return Extent(); } - - //! Replace this list by the items of theOther collection - virtual void Assign (const NCollection_BaseCollection& theOther) - { - if (this == &theOther) - return; - Clear(); - TYPENAME NCollection_BaseCollection::Iterator& anIter = - theOther.CreateIterator(); - for (; anIter.More(); anIter.Next()) - { - SetNode* pNew = new (this->myAllocator) SetNode(anIter.Value()); - PAppend (pNew); - } - } - - //! Replace this list by the items of theOther Set - GEOM_Set& operator= (const GEOM_Set& theOther) - { - if (this == &theOther) - return *this; - Clear (); - SetNode * pCur = (SetNode *) theOther.PFirst(); - while (pCur) - { - SetNode* pNew = new (this->myAllocator) SetNode(pCur->Value()); - PAppend (pNew); - pCur = (SetNode *) pCur->Next(); - } - return *this; - } - - //! Clear this set - void Clear (void) - { PClear (SetNode::delNode, this->myAllocator); } - - //! Add item - Standard_Boolean Add (const TheItemType& theItem) - { - Iterator anIter(*this); - while (anIter.More()) - { - if (anIter.Value() == theItem) - return Standard_False; - anIter.Next(); - } - SetNode * pNew = new (this->myAllocator) SetNode(theItem); - PPrepend (pNew); - return Standard_True; - } - - //! Remove item - Standard_Boolean Remove (const TheItemType& theItem) - { - Iterator anIter(*this); - while (anIter.More()) - { - if (anIter.Value() == theItem) - { - PRemove (anIter, SetNode::delNode, this->myAllocator); - return Standard_True; - } - anIter.Next(); - } - return Standard_False; - } - - //! Remove - wrapper against 'hiding' warnings - void Remove (Iterator& theIter) - { NCollection_BaseList::PRemove (theIter, - SetNode::delNode, - this->myAllocator); } - - //! Contains - item inclusion query - Standard_Boolean Contains (const TheItemType& theItem) const - { - Iterator anIter(*this); - for (; anIter.More(); anIter.Next()) - if (anIter.Value() == theItem) - return Standard_True; - return Standard_False; - } - - //! IsASubset - Standard_Boolean IsASubset (const GEOM_Set& theOther) - { - if (this == &theOther) - return Standard_True; - Iterator anIter(theOther); - for (; anIter.More(); anIter.Next()) - if (!Contains(anIter.Value())) - return Standard_False; - return Standard_True; - } - - //! IsAProperSubset - Standard_Boolean IsAProperSubset (const GEOM_Set& theOther) - { - if (myLength <= theOther.Extent()) - return Standard_False; - Iterator anIter(theOther); - for (; anIter.More(); anIter.Next()) - if (!Contains(anIter.Value())) - return Standard_False; - return Standard_True; - } - - //! Union - void Union (const GEOM_Set& theOther) - { - if (this == &theOther) - return; - Iterator anIter(theOther); - Iterator aMyIter; - Standard_Integer i, iLength=myLength; - for (; anIter.More(); anIter.Next()) - { - Standard_Boolean isIn=Standard_False; - const TheItemType& theItem = anIter.Value(); - for (aMyIter.Init(*this), i=1; - i<=iLength; - aMyIter.Next(), i++) - if (theItem == aMyIter.Value()) - isIn = Standard_True; - if (!isIn) - { - SetNode * pNew = new (this->myAllocator) SetNode(theItem); - PAppend (pNew); - } - } - } - - //! Intersection - void Intersection (const GEOM_Set& theOther) - { - if (this == &theOther) - return; - Iterator anIter(*this); - while (anIter.More()) - if (theOther.Contains(anIter.Value())) - anIter.Next(); - else - NCollection_BaseList::PRemove (anIter, SetNode::delNode, this->myAllocator); - } - - //! Difference (Subtraction) - void Difference (const GEOM_Set& theOther) - { - if (this == &theOther) - return; - Iterator anIter(*this); - while (anIter.More()) - if (theOther.Contains(anIter.Value())) - NCollection_BaseList::PRemove (anIter, SetNode::delNode, this->myAllocator); - else - anIter.Next(); - } - - //! Destructor - clears the List - ~GEOM_Set (void) - { Clear(); } - -private: - //! Creates Iterator for use on BaseCollection - virtual TYPENAME NCollection_BaseCollection::Iterator& - CreateIterator(void) const - { return *(new (this->IterAllocator()) Iterator(*this)); } - -}; - -typedef GEOM_Set TVertexSet; -typedef GEOM_Set TEdgeSet; -typedef GEOM_Set TFaceSet; - -class VertexSourceInternal -{ -public: - TVertexSet myVertexSet; -}; - -class EdgeSourceInternal -{ -public: - TEdgeSet myEdgeSet; -}; - -class FaceSourceInternal -{ -public: - TFaceSet myFaceSet; -}; - -#endif // OCC2VTK_INTERNAL_H diff --git a/src/OperationGUI/CMakeLists.txt b/src/OperationGUI/CMakeLists.txt index f176f9d0b..0f8ae114e 100755 --- a/src/OperationGUI/CMakeLists.txt +++ b/src/OperationGUI/CMakeLists.txt @@ -45,11 +45,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) -IF(SALOME_GEOM_DEBUG_CC) - # for debug purposes, to be removed - INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/CurveCreator) -ENDIF() - # additional preprocessor / compiler flags ADD_DEFINITIONS( ${CAS_DEFINITIONS} @@ -61,10 +56,6 @@ ADD_DEFINITIONS( SET(_link_LIBRARIES GEOMBase ) -IF(SALOME_GEOM_DEBUG_CC) - # for debug purposes, to be removed - LIST(APPEND _link_LIBRARIES CurveCreator) -ENDIF() # --- resources --- diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx index c84dc1cf3..a705e0ae2 100644 --- a/src/OperationGUI/OperationGUI.cxx +++ b/src/OperationGUI/OperationGUI.cxx @@ -27,15 +27,8 @@ #include #include "GeometryGUI_Operations.h" -#include #include -#include #include -#include - -#include -#include -#include #include "OperationGUI_PartitionDlg.h" // Method PARTITION #include "OperationGUI_ArchimedeDlg.h" // Method ARCHIMEDE @@ -47,13 +40,6 @@ #include "OperationGUI_GetSharedShapesDlg.h" #include "OperationGUI_ExtrudedFeatureDlg.h" // Methods EXTRUDED BOSS / CUT -#ifdef DEBUG_CURVE_CREATOR -// for debug purposes, to be removed -#include "CurveCreator_Widget.h" -#include -#include -#endif - //======================================================================= // function : OperationGUI() // purpose : Constructor @@ -95,36 +81,6 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent) case GEOMOp::OpExtrudedCut: (new OperationGUI_ExtrudedFeatureDlg (CUT, getGeometryGUI(), parent))->show(); break; case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break; case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break; -#ifdef DEBUG_CURVE_CREATOR - // for debug purposes, to be removed - case GEOMOp::OpCurveCreator: - { - static CurveCreator_Curve *aStaticCurve = NULL; - - if (aStaticCurve == NULL) { - aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim2d); - } - if (CurveCreator::Dim2d == aStaticCurve->getDimension()) { - OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)getGeometryGUI()->getApp()->activeViewManager()->getActiveView(); - vw->onTopView(); - } - - QDialog *aDialog = new QDialog(parent); - QVBoxLayout *aMainLO = new QVBoxLayout; - QPushButton *aQuitButton = new QPushButton(tr("Close")); - CurveCreator_Widget *aWidget = - new CurveCreator_Widget (aDialog, aStaticCurve); - - connect(aQuitButton, SIGNAL(clicked()), aDialog, SLOT(close())); - aMainLO->addWidget(aWidget); - aMainLO->addWidget(aQuitButton); - - aDialog->setLayout(aMainLO); - aDialog->setAttribute(Qt::WA_DeleteOnClose); - aDialog->show(); - } - break; -#endif default: app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); } diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index e27701c60..66333aa24 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -70,19 +70,25 @@ PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg (GeometryGUI* theGeometryGUI, mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton3->close(); - GroupPoints = new DlgRef_2Sel2Spin(centralWidget()); + GroupPoints = new DlgRef_2Sel3Spin1Check(centralWidget()); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); GroupPoints->TextLabel1->setText(tr("GEOM_BASE_POINT")); GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS")); GroupPoints->TextLabel4->setText(tr("GEOM_HEIGHT")); + GroupPoints->TextLabel5->setText(tr("GEOM_ANGLE")); + GroupPoints->checkBox->setText(tr("")); GroupPoints->PushButton1->setIcon(image2); GroupPoints->PushButton2->setIcon(image2); + GroupPoints->SpinBox_DZ->setDisabled(true); - GroupDimensions = new DlgRef_2Spin(centralWidget()); + GroupDimensions = new DlgRef_3Spin1CheckCyl(centralWidget()); GroupDimensions->GroupBox1->setTitle(tr("GEOM_BOX_OBJ")); GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS")); GroupDimensions->TextLabel2->setText(tr("GEOM_HEIGHT")); + GroupDimensions->TextLabel3->setText(tr("GEOM_ANGLE")); + GroupDimensions->checkBox->setText(tr("")); + GroupDimensions->SpinBox_DZ->setDisabled(true); QVBoxLayout* layout = new QVBoxLayout(centralWidget()); layout->setMargin(0); layout->setSpacing(6); @@ -115,10 +121,14 @@ void PrimitiveGUI_CylinderDlg::Init() double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); // min, max, step and decimals for spin boxes & initial values + double SpecificStep = 5; initSpinBox(GroupPoints->SpinBox_DX, 0.00001, COORD_MAX, step, "length_precision" ); initSpinBox(GroupPoints->SpinBox_DY, 0.00001, COORD_MAX, step, "length_precision" ); + initSpinBox(GroupPoints->SpinBox_DZ, 0., 360., SpecificStep, "angle_precision" ); + initSpinBox(GroupDimensions->SpinBox_DX, 0.00001, COORD_MAX, step, "length_precision" ); initSpinBox(GroupDimensions->SpinBox_DY, 0.00001, COORD_MAX, step, "length_precision" ); + initSpinBox(GroupDimensions->SpinBox_DZ, 0., 360., SpecificStep, "angle_precision" ); // init variables myEditCurrentArgument = GroupPoints->LineEdit1; @@ -130,11 +140,13 @@ void PrimitiveGUI_CylinderDlg::Init() myPoint.nullify(); myDir.nullify(); - double aRadius(100.0), aHeight(300.0); + double aRadius(100.0), aHeight(300.0), aAngle(270.); GroupPoints->SpinBox_DX->setValue(aRadius); GroupPoints->SpinBox_DY->setValue(aHeight); + GroupPoints->SpinBox_DZ->setValue(aAngle); GroupDimensions->SpinBox_DX->setValue(aRadius); GroupDimensions->SpinBox_DY->setValue(aHeight); + GroupDimensions->SpinBox_DZ->setValue(aAngle); // signals and slots connections connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -147,11 +159,16 @@ void PrimitiveGUI_CylinderDlg::Init() connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); - + + connect(GroupPoints->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle())); + connect(GroupDimensions->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle())); + initName(tr("GEOM_CYLINDER")); setConstructorId(1); // simplest constructor @@ -201,7 +218,7 @@ void PrimitiveGUI_CylinderDlg::ConstructorsClicked (int constructorId) updateGeometry(); resize(minimumSizeHint()); SelectionIntoArgument(); - + displayPreview(true); } @@ -281,7 +298,6 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument() this, SLOT(SelectionIntoArgument())); } } - displayPreview(true); } @@ -355,6 +371,11 @@ void PrimitiveGUI_CylinderDlg::enterEvent (QEvent*) //================================================================================= void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox() { + QString msg; + if (!isValid(msg)) { + erasePreview(); + return; + } displayPreview(true); } @@ -378,14 +399,27 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg) { ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && + ( !GroupPoints->checkBox->isChecked() || GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) ) && myPoint && myDir; + if ( GroupPoints->checkBox->isChecked() && + ( GroupPoints->SpinBox_DZ->value() <= 0. || GroupPoints->SpinBox_DZ->value() >= 360. ) ) { + msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n"; + ok = false; + } } else if( getConstructorId() == 1 ) { ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && - GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ); + GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && + ( GroupDimensions->checkBox->isChecked() || GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) ); + if ( GroupDimensions->checkBox->isChecked() && + ( GroupDimensions->SpinBox_DZ->value() <= 0. || GroupDimensions->SpinBox_DZ->value() >= 360. ) ) { + msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n"; + ok = false; + } } ok = qAbs( getHeight() ) > Precision::Confusion() && ok; + ok = qAbs( getRadius() ) > Precision::Confusion() && ok; return ok; } @@ -396,7 +430,7 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg) bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects) { bool res = false; - + GEOM::GEOM_Object_var anObj; GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); @@ -404,27 +438,55 @@ bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects) switch (getConstructorId()) { case 0: if ( myPoint && myDir ) { - anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight()); - if (!anObj->_is_nil() && !IsPreview()) - { - QStringList aParameters; - aParameters << GroupPoints->SpinBox_DX->text(); - aParameters << GroupPoints->SpinBox_DY->text(); - anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + if ( GroupPoints->checkBox->isChecked() ) { + anObj = anOper->MakeCylinderPntVecRHA(myPoint.get(), myDir.get(), getRadius(), getHeight(), getAngle()*M_PI/180.); + if (!anObj->_is_nil() && !IsPreview()) + { + QStringList aParameters; + aParameters << GroupPoints->SpinBox_DX->text(); + aParameters << GroupPoints->SpinBox_DY->text(); + aParameters << GroupPoints->SpinBox_DZ->text(); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + } + res = true; + } + else { + anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight()); + if (!anObj->_is_nil() && !IsPreview()) + { + QStringList aParameters; + aParameters << GroupPoints->SpinBox_DX->text(); + aParameters << GroupPoints->SpinBox_DY->text(); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + } + res = true; } - res = true; } break; case 1: - anObj = anOper->MakeCylinderRH(getRadius(), getHeight()); - if (!anObj->_is_nil() && !IsPreview()) - { - QStringList aParameters; - aParameters << GroupDimensions->SpinBox_DX->text(); - aParameters << GroupDimensions->SpinBox_DY->text(); - anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + if ( GroupDimensions->checkBox->isChecked() ) { + anObj = anOper->MakeCylinderRHA(getRadius(), getHeight(), getAngle()*M_PI/180.); + if (!anObj->_is_nil() && !IsPreview()) + { + QStringList aParameters; + aParameters << GroupDimensions->SpinBox_DX->text(); + aParameters << GroupDimensions->SpinBox_DY->text(); + aParameters << GroupDimensions->SpinBox_DZ->text(); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + } + res = true; + } + else { + anObj = anOper->MakeCylinderRH(getRadius(), getHeight()); + if (!anObj->_is_nil() && !IsPreview()) + { + QStringList aParameters; + aParameters << GroupDimensions->SpinBox_DX->text(); + aParameters << GroupDimensions->SpinBox_DY->text(); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + } + res = true; } - res = true; break; } @@ -462,6 +524,20 @@ double PrimitiveGUI_CylinderDlg::getHeight() const return 0; } +//================================================================================= +// function : getAngle() +// purpose : +//================================================================================= +double PrimitiveGUI_CylinderDlg::getAngle() const +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0) + return GroupPoints->SpinBox_DZ->value(); + else if (aConstructorId == 1) + return GroupDimensions->SpinBox_DZ->value(); + return 0; +} + //================================================================================= // function : addSubshapeToStudy // purpose : virtual method to add new SubObjects if local selection @@ -473,3 +549,20 @@ void PrimitiveGUI_CylinderDlg::addSubshapesToStudy() GEOMBase::PublishSubObject( myDir.get() ); } } + +//================================================================================= +// function : ActivateAngle() +// purpose : enable the +//================================================================================= +void PrimitiveGUI_CylinderDlg::ActivateAngle() +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0){ + GroupPoints->SpinBox_DZ->setEnabled( GroupPoints->checkBox->isChecked() ); + processPreview(); + } + else if (aConstructorId == 1){ + GroupDimensions->SpinBox_DZ->setEnabled( GroupDimensions->checkBox->isChecked() ); + processPreview(); + } +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h index 6514d87a8..1a5ccc46b 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h @@ -30,8 +30,8 @@ #include "GEOMBase_Skeleton.h" #include "GEOM_GenericObjPtr.h" -class DlgRef_2Sel2Spin; -class DlgRef_2Spin; +class DlgRef_2Sel3Spin1Check; +class DlgRef_3Spin1CheckCyl; //================================================================================= // class : PrimitiveGUI_CylinderDlg @@ -57,6 +57,7 @@ private: void enterEvent( QEvent* ); double getRadius() const; double getHeight() const; + double getAngle() const; private: GEOM::GeomObjPtr myPoint, myDir; @@ -64,8 +65,8 @@ private: // to initialize the first selection field with a selected object on the dialog creation bool myInitial; - DlgRef_2Sel2Spin* GroupPoints; - DlgRef_2Spin* GroupDimensions; + DlgRef_2Sel3Spin1Check* GroupPoints; + DlgRef_3Spin1CheckCyl* GroupDimensions; private slots: void ClickOnOk(); @@ -76,6 +77,7 @@ private slots: void ConstructorsClicked( int ); void ValueChangedInSpinBox(); void SetDoubleSpinBoxStep( double ); + void ActivateAngle(); }; #endif // PRIMITIVEGUI_CYLINDERDLG_H diff --git a/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx b/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx index ae77997a0..8fe66a4bd 100644 --- a/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx +++ b/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx @@ -124,7 +124,7 @@ RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg( GeometryGUI* GUI, QWidget* paren aLay->addStretch(); aLay->addWidget( aFrame ); - myHelpFileName = "using_measurement_tools_page.html#faces_anchor"; + myHelpFileName = "free_faces_page.html"; connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ); connect( aHelpBtn, SIGNAL( clicked() ), SLOT( onHelp() ) ); diff --git a/src/RepairGUI/RepairGUI_GlueDlg.cxx b/src/RepairGUI/RepairGUI_GlueDlg.cxx index 0e8b07e22..55a1bb27a 100644 --- a/src/RepairGUI/RepairGUI_GlueDlg.cxx +++ b/src/RepairGUI/RepairGUI_GlueDlg.cxx @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include diff --git a/src/RepairGUI/RepairGUI_LimitToleranceDlg.cxx b/src/RepairGUI/RepairGUI_LimitToleranceDlg.cxx index 5f0e140f3..69b37b9f6 100644 --- a/src/RepairGUI/RepairGUI_LimitToleranceDlg.cxx +++ b/src/RepairGUI/RepairGUI_LimitToleranceDlg.cxx @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include diff --git a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx index 66c02302f..926f1eb80 100755 --- a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx +++ b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx @@ -38,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx b/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx index 5358f2565..43a0f629e 100644 --- a/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx +++ b/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include // OCCT Includes #include diff --git a/src/SKETCHER/CMakeLists.txt b/src/SKETCHER/CMakeLists.txt index 257c2dd1e..ef7e87480 100755 --- a/src/SKETCHER/CMakeLists.txt +++ b/src/SKETCHER/CMakeLists.txt @@ -43,13 +43,16 @@ SET(_link_LIBRARIES # --- headers --- SET(SKETCHER_HEADERS + Sketcher.hxx Sketcher_Profile.hxx + Sketcher_Utils.hxx ) # --- sources --- SET(SKETCHER_SOURCES Sketcher_Profile.cxx + Sketcher_Utils.cxx ) # --- rules --- diff --git a/src/OBJECT/GEOM_TopWireframeShape.jxx b/src/SKETCHER/Sketcher.hxx old mode 100755 new mode 100644 similarity index 69% rename from src/OBJECT/GEOM_TopWireframeShape.jxx rename to src/SKETCHER/Sketcher.hxx index 84d248da9..09602cee5 --- a/src/OBJECT/GEOM_TopWireframeShape.jxx +++ b/src/SKETCHER/Sketcher.hxx @@ -20,14 +20,20 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// GEOM OBJECT : interactive object for Geometry entities visualization -// File : GEOM_AISShape.jxx -// Module : GEOM -// -#ifndef _TopoDS_Shape_HeaderFile -#include +// File : Sketcher.hxx +// Author : Sergey KHROMOV + +#ifndef _SKETCHER_HXX_ +#define _SKETCHER_HXX_ + +#if defined WIN32 +# if defined SKETCHER_SALOME_EXPORTS || defined SKETCHER_EXPORTS || defined GEOMSketcher_EXPORTS || defined GEOMSKETCHER_EXPORTS +# define SKETCHER_SALOME_EXPORT _declspec( dllexport ) +# else +# define SKETCHER_SALOME_EXPORT _declspec( dllimport ) +# endif +#else +# define SKETCHER_SALOME_EXPORT #endif -#ifndef _GEOM_TopWireframeShape_HeaderFile -#include "GEOM_TopWireframeShape.hxx" -#endif +#endif // SKETCHER_HXX \ No newline at end of file diff --git a/src/SKETCHER/Sketcher_Profile.hxx b/src/SKETCHER/Sketcher_Profile.hxx index ed792f83b..8d36b639b 100644 --- a/src/SKETCHER/Sketcher_Profile.hxx +++ b/src/SKETCHER/Sketcher_Profile.hxx @@ -23,16 +23,12 @@ // File : Sketcher_Profile.h // Author : Damien COQUERET -#if defined WIN32 -# if defined SKETCHER_SALOME_EXPORTS || defined SKETCHER_EXPORTS || defined GEOMSketcher_EXPORTS || defined GEOMSKETCHER_EXPORTS -# define SKETCHER_SALOME_EXPORT _declspec( dllexport ) -# else -# define SKETCHER_SALOME_EXPORT _declspec( dllimport ) -# endif -#else -# define SKETCHER_SALOME_EXPORT -#endif +#ifndef _Sketcher_Profile_HXX_ +#define _Sketcher_Profile_HXX_ + + +#include "Sketcher.hxx" #include #include #include @@ -63,3 +59,5 @@ private: private: TCollection_AsciiString myCommand; }; + +#endif diff --git a/src/SKETCHER/Sketcher_Utils.cxx b/src/SKETCHER/Sketcher_Utils.cxx new file mode 100644 index 000000000..725a985cf --- /dev/null +++ b/src/SKETCHER/Sketcher_Utils.cxx @@ -0,0 +1,187 @@ +// 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 : Sketcher_Utils.cxx +// Author : Sergey KHROMOV +// Module : GEOM + + +#include "Sketcher_Utils.hxx" + +#include +#include +#include +#include +#include +#include +#include + +const double POINT_CONFUSION_TOLERANCE = 0.0001; + + +//======================================================================= +// function : MakePolyline +// purpose : +//======================================================================= +TopoDS_Shape Sketcher_Utils::MakePolyline + (const std::list &theCoords2D, + const Standard_Boolean IsClosed, + const gp_Ax3 &thePlane) +{ + std::list aPoints; + TopoDS_Shape aResult; + + To3D(theCoords2D, thePlane, aPoints); + + Standard_Integer aNbPnts = aPoints.size(); + + if (aNbPnts > 1) { + if (IsClosed && + aPoints.front().IsEqual(aPoints.back(), POINT_CONFUSION_TOLERANCE)) { + // The polyline should be closed, first and last points are confused. + // Remove the last point. + aPoints.pop_back(); + --aNbPnts; + } + } + + if (aNbPnts == 1) { + // The result is vertex. + aResult = BRepBuilderAPI_MakeVertex(aPoints.front()).Vertex(); + } else if (aNbPnts > 1) { + // There are several points. Make a polyline. + std::list ::const_iterator anIter = aPoints.begin(); + TopoDS_Vertex aVtxFirst = + BRepBuilderAPI_MakeVertex(*anIter).Vertex(); + TopoDS_Vertex aVtx[2]; + TopoDS_Edge aSegment; + BRepBuilderAPI_MakeWire aMkWire; + + aVtx[0] = aVtxFirst; + + for (++anIter; anIter != aPoints.end(); ++anIter) { + aVtx[1] = BRepBuilderAPI_MakeVertex(*anIter).Vertex(); + aSegment = BRepBuilderAPI_MakeEdge(aVtx[0], aVtx[1]).Edge(); + aMkWire.Add(aSegment); + aVtx[0] = aVtx[1]; + } + + if (IsClosed) { + // Create a closing segment. + aSegment = BRepBuilderAPI_MakeEdge(aVtx[0], aVtxFirst).Edge(); + aMkWire.Add(aSegment); + } + + aResult = aMkWire.Wire(); + } + + return aResult; +} + +//======================================================================= +// function : MakeInterpolation +// purpose : +//======================================================================= +TopoDS_Shape Sketcher_Utils::MakeInterpolation + (const std::list &theCoords2D, + const Standard_Boolean IsClosed, + const gp_Ax3 &thePlane) +{ + std::list aPoints; + TopoDS_Shape aResult; + + To3D(theCoords2D, thePlane, aPoints); + + Standard_Integer aNbPnts = aPoints.size(); + + if (aNbPnts > 1) { + if (IsClosed && + aPoints.front().IsEqual(aPoints.back(), POINT_CONFUSION_TOLERANCE)) { + // The polyline should be closed, first and last points are confused. + // Remove the last point. + aPoints.pop_back(); + --aNbPnts; + } + } + + if (aNbPnts == 1) { + // The result is vertex. + aResult = BRepBuilderAPI_MakeVertex(aPoints.front()).Vertex(); + } else if (aNbPnts > 1) { + std::list ::const_iterator anIter = aPoints.begin(); + Handle(TColgp_HArray1OfPnt) aHCurvePoints = + new TColgp_HArray1OfPnt(1, aNbPnts); + Standard_Integer i; + + for (i = 1; anIter != aPoints.end(); ++anIter, ++i) { + aHCurvePoints->SetValue(i, *anIter); + } + + // Compute BSpline + Standard_Real aTol = Precision::Confusion(); + GeomAPI_Interpolate aGBC(aHCurvePoints, IsClosed, aTol); + + aGBC.Perform(); + + if (aGBC.IsDone()) { + TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(aGBC.Curve()).Edge(); + aResult = BRepBuilderAPI_MakeWire(anEdge).Wire(); + } + } + + return aResult; +} + +//======================================================================= +// function : To3D +// purpose : +//======================================================================= +void Sketcher_Utils::To3D(const std::list &theCoords2D, + const gp_Ax3 &thePlane, + std::list &thePoints) +{ + thePoints.clear(); + + if (theCoords2D.empty() || theCoords2D.size() % 2 == 1) { + // Odd number of coordinates or empty list. Invalid case. + return; + } + + std::list ::const_iterator anIter = theCoords2D.begin(); + Standard_Real aX = *anIter; + Standard_Real aY = *(++anIter); + gp_Pnt aPLast = ElSLib::PlaneValue (aX, aY, thePlane); + gp_Pnt aPnt; + + thePoints.push_back(aPLast); + + for (++anIter; anIter != theCoords2D.end(); ++anIter) { + aX = *anIter; + aY = *(++anIter); + aPnt = ElSLib::PlaneValue (aX, aY, thePlane); + + if (!aPLast.IsEqual(aPnt, POINT_CONFUSION_TOLERANCE)) { + thePoints.push_back(aPnt); + aPLast = aPnt; + } + } +} diff --git a/src/SKETCHER/Sketcher_Utils.hxx b/src/SKETCHER/Sketcher_Utils.hxx new file mode 100644 index 000000000..75360111d --- /dev/null +++ b/src/SKETCHER/Sketcher_Utils.hxx @@ -0,0 +1,103 @@ +// 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 : Sketcher_Utils.h +// Author : Sergey KHROMOV + + +#ifndef _Sketcher_Utils_HXX_ +#define _Sketcher_Utils_HXX_ + + +#include "Sketcher.hxx" + +#include +#include + +#include + + +class gp_Ax3; + + +/** + * This class represents a set of utils needed to compute sketcher geometry. + */ +class SKETCHER_SALOME_EXPORT Sketcher_Utils +{ + +public: + + /** + * This method makes a shape from the list of 2D coordinates on the working + * plane. The result represents a vertex if there is only one point + * in the contour. If there are more then one points the result is a wire + * consisting of linear segments between points. It is either closed or not + * depending on the flag IsClosed. In case of failure the result is a null + * shape. + * + * \param theCoords2D is the list of coordinates in the form x1, y1, x2, y2, + * ..., xN, yN for N 2D points. + * \param IsClosed if Standard_True the first and last points are connected + * to form the closed contour. + * \param thePlane the working plane coordinate system. + * \return the result polyline. + */ + static TopoDS_Shape MakePolyline(const std::list &theCoords2D, + const Standard_Boolean IsClosed, + const gp_Ax3 &thePlane); + + /** + * This method makes a shape from the list of 2D coordinates on the working + * plane. The result represents a vertex if there is only one point + * in the contour. If there are more then one points the result is a wire + * consisting of a points interpolation BSpline curve. It is either closed + * or not depending on the flag IsClosed. In case of failure the result is + * a null shape. + * + * \param theCoords2D is the list of coordinates in the form x1, y1, x2, y2, + * ..., xN, yN for N 2D points. + * \param IsClosed if Standard_True the first and last points are connected + * to form the closed contour. + * \param thePlane the working plane coordinate system. + * \return the result interpolation wire. + */ + static TopoDS_Shape MakeInterpolation(const std::list &theCoords2D, + const Standard_Boolean IsClosed, + const gp_Ax3 &thePlane); + + /** + * This method converts the list of 2D point coordinates into 3D points + * basing on the working plane. The result list contains not confused points. + * + * \param theCoords2D is the list of coordinates in the form x1, y1, x2, y2, + * ..., xN, yN for N 2D points. + * \param thePlane the working plane coordinate system. + * \param thePoints the list of 3D points. + */ + static void To3D(const std::list &theCoords2D, + const gp_Ax3 &thePlane, + std::list &thePoints); + +}; + +#endif 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..4d4db727c --- /dev/null +++ b/src/STEPPlugin/CMakeLists.txt @@ -0,0 +1,153 @@ +# 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} + ${OMNIORB_DEFINITIONS} + ) + +IF(WIN32) + ADD_DEFINITIONS(-DNOGDI) +ENDIF(WIN32) + +IF(SALOME_BUILD_GUI) +ADD_DEFINITIONS( + ${QT_DEFINITIONS} + ) +ENDIF() + +# libraries to link to +SET(_link_engine_LIBRARIES + ${CAS_TKSTEP} + ${CAS_TKSTEPBase} + ${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..bf2acb873 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_ExportDriver.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_ExportDriver_HXX +#define _STEPPlugin_ExportDriver_HXX + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( STEPPlugin_ExportDriver, GEOM_BaseDriver ); + +class 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..66ebd4cc3 --- /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..e2fa9fad2 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_IOperations.cxx @@ -0,0 +1,202 @@ +// 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 { + OCC_CATCH_SIGNALS; + 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 { + OCC_CATCH_SIGNALS; + 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/CurveCreator/CurveCreator_Listener.hxx b/src/STEPPlugin/STEPPlugin_IOperations.hxx old mode 100755 new mode 100644 similarity index 52% rename from src/CurveCreator/CurveCreator_Listener.hxx rename to src/STEPPlugin/STEPPlugin_IOperations.hxx index 4fd4a29fa..6d4999815 --- a/src/CurveCreator/CurveCreator_Listener.hxx +++ b/src/STEPPlugin/STEPPlugin_IOperations.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -16,26 +16,31 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : STEPPlugin_IOperations.hxx -#ifndef CURVE_CREATOR_LISTENER_HXX -#define CURVE_CREATOR_LISTENER_HXX +#ifndef _STEPPlugin_IOperations_HXX_ +#define _STEPPlugin_IOperations_HXX_ -class CurveCreator_Listener +// internal includes +#include "STEPPlugin_Engine.hxx" + +// GEOM includes +#include "GEOMImpl_IBaseIEOperations.hxx" + +class STEPPLUGINENGINE_EXPORT STEPPlugin_IOperations: public GEOMImpl_IBaseIEOperations { public: - CurveCreator_Listener(void){}; - virtual ~CurveCreator_Listener(void){}; + STEPPlugin_IOperations( GEOM_Engine*, int ); + ~STEPPlugin_IOperations(); - virtual void pointChanged( int theSection, int thePoint ){} - virtual void pointRemoved( int theSection, int theFirstPoint, int thePointCnt ){} - virtual void pointInserted( int theSection, int theIndx ){} - - virtual void sectionClosed( int theSection, bool isClosed ){} - virtual void sectionAdded( int theSection ){} - virtual void sectionRemoved( int theSection ){} - virtual void sectionTypeChanged( int theSection ){} - - virtual void curveChanged(){} + 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 \ No newline at end of file +#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..dc26023bd --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_ImportDriver.cxx @@ -0,0 +1,612 @@ +// 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 { + OCC_CATCH_SIGNALS; + 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..40bb7b1be --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_ImportDriver.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 _STEPPlugin_ImportDriver_HXX +#define _STEPPlugin_ImportDriver_HXX + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( STEPPlugin_ImportDriver, GEOM_BaseDriver ); + +class 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..b4688f6b1 --- /dev/null +++ b/src/STLPlugin/CMakeLists.txt @@ -0,0 +1,154 @@ +# 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} + ${OMNIORB_DEFINITIONS} + ) + +IF(WIN32) + ADD_DEFINITIONS(-DNOGDI) +ENDIF(WIN32) + +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/GEOM/GEOM_Application.jxx b/src/STLPlugin/STLPlugin_Engine.cxx similarity index 69% rename from src/GEOM/GEOM_Application.jxx rename to src/STLPlugin/STLPlugin_Engine.cxx index 77a83467a..49fb94c80 100644 --- a/src/GEOM/GEOM_Application.jxx +++ b/src/STLPlugin/STLPlugin_Engine.cxx @@ -1,7 +1,4 @@ -// 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 +// 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 @@ -20,12 +17,15 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : GEOM_Application.jxx -// Module : GEOM -// -#ifndef _TColStd_SequenceOfExtendedString_HeaderFile -#include -#endif -#ifndef _GEOM_Application_HeaderFile -#include "GEOM_Application.hxx" -#endif +// 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..90eef7fb4 --- /dev/null +++ b/src/STLPlugin/STLPlugin_ExportDriver.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 _STLPlugin_ExportDriver_HXX +#define _STLPlugin_ExportDriver_HXX + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( STLPlugin_ExportDriver, GEOM_BaseDriver ); + +class 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..1c9749992 --- /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..512b9251b --- /dev/null +++ b/src/STLPlugin/STLPlugin_IOperations.cxx @@ -0,0 +1,177 @@ +// 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 { + OCC_CATCH_SIGNALS; + 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 { + OCC_CATCH_SIGNALS; + 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..fb695b844 --- /dev/null +++ b/src/STLPlugin/STLPlugin_ImportDriver.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 _STLPlugin_ImportDriver_HXX +#define _STLPlugin_ImportDriver_HXX + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( STLPlugin_ImportDriver, GEOM_BaseDriver ); + +class 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/ShHealOper/ShHealOper_FillHoles.cxx b/src/ShHealOper/ShHealOper_FillHoles.cxx index 8e8eb61c0..114326a8b 100644 --- a/src/ShHealOper/ShHealOper_FillHoles.cxx +++ b/src/ShHealOper/ShHealOper_FillHoles.cxx @@ -336,11 +336,7 @@ Standard_Boolean ShHealOper_FillHoles::addFace(const Handle(Geom_Surface)& theSu const Handle(TColStd_HArray1OfInteger)& theOrders, const Handle(TColStd_HArray1OfInteger)& theSenses) { -#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version BRepBuilderAPI_MakeFace aMakeFace (theSurf, Precision::Confusion()); -#else - BRepBuilderAPI_MakeFace aMakeFace (theSurf); -#endif TopoDS_Face aFace = aMakeFace.Face(); aFace.EmptyCopy(); diff --git a/src/ShapeRecognition/ShapeRec_FeatureDetector.hxx b/src/ShapeRecognition/ShapeRec_FeatureDetector.hxx index b683c7c69..bb0a44ddb 100644 --- a/src/ShapeRecognition/ShapeRec_FeatureDetector.hxx +++ b/src/ShapeRecognition/ShapeRec_FeatureDetector.hxx @@ -32,7 +32,17 @@ // Qt #include -class ShapeRec_Parameters +#ifdef WIN32 + #if defined GEOM_SHAPEREC_EXPORTS || defined GEOMShapeRec_EXPORTS + #define GEOM_SHAPEREC_EXPORT __declspec( dllexport ) + #else + #define GEOM_SHAPEREC_EXPORT __declspec( dllimport ) + #endif +#else + #define GEOM_SHAPEREC_EXPORT +#endif + +class GEOM_SHAPEREC_EXPORT ShapeRec_Parameters { public: ShapeRec_Parameters(); @@ -42,7 +52,7 @@ public: int findContoursMethod; }; -class ShapeRec_CornersParameters : public ShapeRec_Parameters +class GEOM_SHAPEREC_EXPORT ShapeRec_CornersParameters : public ShapeRec_Parameters { public: ShapeRec_CornersParameters(); @@ -55,7 +65,7 @@ public: double epsilon; }; -class ShapeRec_CannyParameters : public ShapeRec_Parameters +class GEOM_SHAPEREC_EXPORT ShapeRec_CannyParameters : public ShapeRec_Parameters { public: ShapeRec_CannyParameters(); @@ -66,7 +76,7 @@ public: bool L2gradient; }; -class ShapeRec_ColorFilterParameters : public ShapeRec_Parameters +class GEOM_SHAPEREC_EXPORT ShapeRec_ColorFilterParameters : public ShapeRec_Parameters { public: ShapeRec_ColorFilterParameters(); @@ -79,7 +89,7 @@ public: double maxThreshold; }; -class ShapeRec_FeatureDetector +class GEOM_SHAPEREC_EXPORT ShapeRec_FeatureDetector { public: diff --git a/src/TransformationGUI/TransformationGUI.cxx b/src/TransformationGUI/TransformationGUI.cxx index 4a6fe2fbc..eb62c1f18 100644 --- a/src/TransformationGUI/TransformationGUI.cxx +++ b/src/TransformationGUI/TransformationGUI.cxx @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION #include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION 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 bc342d396..000000000 --- a/src/VTKExport/VTKExport.cxx +++ /dev/null @@ -1,159 +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, - 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..d14424afe --- /dev/null +++ b/src/VTKPlugin/CMakeLists.txt @@ -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 +# + +IF(SALOME_BUILD_GUI) + INCLUDE(UseQt4Ext) + INCLUDE(${QT_USE_FILE}) +ENDIF() + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} + ${VTK_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} + ${OMNIORB_DEFINITIONS} + ) + +IF(WIN32) + ADD_DEFINITIONS(-DNOGDI) +ENDIF(WIN32) + +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/CurveCreator/CurveCreator_UndoOptsDlg.h b/src/VTKPlugin/VTKPlugin_ExportDlg.h similarity index 51% rename from src/CurveCreator/CurveCreator_UndoOptsDlg.h rename to src/VTKPlugin/VTKPlugin_ExportDlg.h index 86aa87aa3..d8e4095d4 100644 --- a/src/CurveCreator/CurveCreator_UndoOptsDlg.h +++ b/src/VTKPlugin/VTKPlugin_ExportDlg.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -17,57 +17,34 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: CurveCreator_UndoOptsDlg.h -// Author: Sergey KHROMOV +#ifndef VTKPlugin_ExportDlg_H +#define VTKPlugin_ExportDlg_H -#ifndef _CurveCreator_UndoOptsDlg_HeaderFile -#define _CurveCreator_UndoOptsDlg_HeaderFile +// GUI includes +#include +#include -#include +class SalomeApp_DoubleSpinBox; -class QButtonGroup; -class QLineEdit; -class QPushButton; - - -class CurveCreator_UndoOptsDlg : public QDialog +class VTKPlugin_ExportDlg: public SUIT_FileDlg { Q_OBJECT public: + VTKPlugin_ExportDlg( const Handle(SALOME_InteractiveObject)&, QWidget* parent ); + ~VTKPlugin_ExportDlg(); - CurveCreator_UndoOptsDlg(QWidget* parent); + double getDeflection() const; - ~CurveCreator_UndoOptsDlg(); - - void setUndoDepth(const int theDepth); - - int getUndoDepth() const; - - bool isEnabled() const; - - bool isUnlimited() const; + static QString getFileName( const Handle(SALOME_InteractiveObject)& io, + const QString& filters, + const QString& caption, + QWidget* parent, + double& deflection ); private: - - void init(); - - void setTabOrder(); - -private slots: - - void optionChanged(int theId); - - void accept(); - -protected: - - int myUndoDepth; - QButtonGroup *myOptsBtnGrp; - QLineEdit *myBufferSizeEdit; - QPushButton *myOkBtn; - QPushButton *myCancelBtn; - + SalomeApp_DoubleSpinBox* myDeflectionSB; + Handle(SALOME_InteractiveObject) myObject; }; -#endif +#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..b147c97d0 --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_ExportDriver.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 _VTKPlugin_ExportDriver_HXX +#define _VTKPlugin_ExportDriver_HXX + +// GEOM includes +#include "GEOM_BaseDriver.hxx" + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE( VTKPlugin_ExportDriver, GEOM_BaseDriver ); + +class 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..aa2200b11 --- /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..cdb6fc8cf --- /dev/null +++ b/src/VTKPlugin/VTKPlugin_IOperations.cxx @@ -0,0 +1,109 @@ +// 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 { + OCC_CATCH_SIGNALS; + 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/XAO/XAO_XaoExporter.cxx b/src/XAO/XAO_XaoExporter.cxx index 9bd59eafb..c3114ff67 100644 --- a/src/XAO/XAO_XaoExporter.cxx +++ b/src/XAO/XAO_XaoExporter.cxx @@ -310,14 +310,14 @@ namespace { parseXaoNode(doc, root, xaoObject); xmlFreeDoc(doc); // free document - xmlCleanupParser(); // free globals + //xmlCleanupParser(); // free globals //vsr: xmlCleanupParser should not be called from the application } void parseXaoNode(xmlDocPtr doc, xmlNodePtr xaoNode, Xao* xaoObject) { std::string version = readStringProp(xaoNode, C_ATTR_XAO_VERSION, false, ""); if (version != "") - xaoObject->setAuthor(version); + xaoObject->setVersion(version); std::string author = readStringProp(xaoNode, C_ATTR_XAO_AUTHOR, false, ""); xaoObject->setAuthor(author); @@ -592,7 +592,7 @@ namespace { int component = readIntegerProp(valNode, C_ATTR_VALUE_COMPONENT, true, -1); xmlChar* data = xmlNodeGetContent(valNode->children); - std::string value = (char*)data; + std::string value; if (data != NULL) { value = (char*)data; diff --git a/src/XAOPlugin/CMakeLists.txt b/src/XAOPlugin/CMakeLists.txt new file mode 100644 index 000000000..910c45b9c --- /dev/null +++ b/src/XAOPlugin/CMakeLists.txt @@ -0,0 +1,156 @@ +# 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} + ${OMNIORB_DEFINITIONS} + ) + +IF(WIN32) + ADD_DEFINITIONS(-DNOGDI) +ENDIF(WIN32) + +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/OBJECT/GEOM_AISShape.jxx b/src/XAOPlugin/XAOPlugin_Driver.hxx similarity index 60% rename from src/OBJECT/GEOM_AISShape.jxx rename to src/XAOPlugin/XAOPlugin_Driver.hxx index 4aed3f223..ea821cf3b 100644 --- a/src/OBJECT/GEOM_AISShape.jxx +++ b/src/XAOPlugin/XAOPlugin_Driver.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// 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 @@ -20,22 +20,26 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// GEOM OBJECT : interactive object for Geometry entities visualization -// File : GEOM_AISShape.jxx -// Module : GEOM -// -#ifndef _GEOM_InteractiveObject_HeaderFile -#include "GEOM_InteractiveObject.hxx" -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _GEOM_AISShape_HeaderFile -#include "GEOM_AISShape.hxx" -#endif -#ifndef _PrsMgr_PresentationManager3d_HeaderFile -#include -#endif -#ifndef _Prs3d_Presentation_HeaderFile -#include -#endif +#ifndef _XAOPlugin_Driver_HXX +#define _XAOPlugin_Driver_HXX + +// OCCT includes +#include + +DEFINE_STANDARD_HANDLE(XAOPlugin_Driver, TFunction_Driver); + +class 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/ImportExportGUI/ImportExportGUI_ImportXAODlg.h b/src/XAOPlugin/XAOPlugin_ExportDlg.h similarity index 52% rename from src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h rename to src/XAOPlugin/XAOPlugin_ExportDlg.h index d241ace6b..a2338e2e5 100644 --- a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h +++ b/src/XAOPlugin/XAOPlugin_ExportDlg.h @@ -17,52 +17,59 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef IMPORTEXPORTGUI_IMPORTXAODLG_H -#define IMPORTEXPORTGUI_IMPORTXAODLG_H +#ifndef XAOPlugin_ExportDlg_H +#define XAOPlugin_ExportDlg_H -#include -#include +// GEOM includes +#include "GEOMBase_Skeleton.h" class QLineEdit; class QButtonGroup; class QListWidget; +class QPushButton; //================================================================================= -// class : ImportExportGUI_ImportXAODlg +// class : XAOPlugin_ExportDlg // purpose : //================================================================================= -class ImportExportGUI_ImportXAODlg: public GEOMBase_Skeleton +class XAOPlugin_ExportDlg: public GEOMBase_Skeleton { - Q_OBJECT + Q_OBJECT public: - ImportExportGUI_ImportXAODlg(GeometryGUI*, QWidget* = 0); - ~ImportExportGUI_ImportXAODlg(); + 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(); - 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 ); + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid(QString&); + virtual bool execute(); private: - void Init(); - void enterEvent(QEvent*); + void Init(); + void enterEvent(QEvent*); + void processObject(); private: - QLineEdit* ledFileName; - QPushButton* btnFileSelect; - GEOM::GEOM_Object_var m_mainShape; + 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 LineEditReturnPressed(); - void btnFileSelectClicked(); + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void btnFileSelectClicked(); }; -#endif // IMPORTEXPORTGUI_EXPORTXAODLG_H +#endif // XAOPlugin_ExportDlg_H diff --git a/src/ImportExportGUI/ImportExportGUI.cxx b/src/XAOPlugin/XAOPlugin_GUI.cxx similarity index 53% rename from src/ImportExportGUI/ImportExportGUI.cxx rename to src/XAOPlugin/XAOPlugin_GUI.cxx index 27de1ef59..6bb816445 100644 --- a/src/ImportExportGUI/ImportExportGUI.cxx +++ b/src/XAOPlugin/XAOPlugin_GUI.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -17,38 +17,31 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include -#include +// internal includes +#include "XAOPlugin_GUI.h" +#include "XAOPlugin_ExportDlg.h" +#include "XAOPlugin_ImportDlg.h" -#include "GeometryGUI.h" -#include "GeometryGUI_Operations.h" - -#include +// GUI includes #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 @@// - +// GEOM includes +#include "GeometryGUI.h" //======================================================================= -// function : ImportExportGUI() +// function : XAOPlugin_GUI() // purpose : Constructor //======================================================================= -ImportExportGUI::ImportExportGUI(GeometryGUI* parent) : - GEOMGUI(parent) +XAOPlugin_GUI::XAOPlugin_GUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) { } //======================================================================= -// function : ~ImportExportGUI +// function : ~XAOPlugin_GUI // purpose : Destructor //======================================================================= -ImportExportGUI::~ImportExportGUI() +XAOPlugin_GUI::~XAOPlugin_GUI() { } @@ -56,32 +49,42 @@ ImportExportGUI::~ImportExportGUI() // function : OnGUIEvent() // purpose : //======================================================================= -bool ImportExportGUI::OnGUIEvent(int commandId, SUIT_Desktop* parent) +bool XAOPlugin_GUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) { - SalomeApp_Application* app = getGeometryGUI()->getApp(); - if (!app) return false; + switch ( theCommandID ) { + case 1: + return OnGUIEvent("Export_XAO", parent); + case 2: + return OnGUIEvent("Import_XAO", parent); + default: + return OnGUIEvent("", parent); + } + return false; +} - getGeometryGUI()->EmitSignalDeactivateDialog(); +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool XAOPlugin_GUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) +{ + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if (!app) return false; - 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; - } + getGeometryGUI()->EmitSignalDeactivateDialog(); - if (dialog != NULL) - dialog->show(); + 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 ) ); - return true; + if (dialog != NULL) + dialog->show(); + + return true; } //===================================================================================== @@ -92,8 +95,8 @@ extern "C" #ifdef WIN32 __declspec( dllexport ) #endif - GEOMGUI* GetLibGUI(GeometryGUI* parent) - { - return new ImportExportGUI(parent); - } + GEOMGUI* GetLibGUI(GeometryGUI* parent) + { + return new XAOPlugin_GUI(parent); + } } diff --git a/src/ImportExportGUI/ImportExportGUI.h b/src/XAOPlugin/XAOPlugin_GUI.h similarity index 68% rename from src/ImportExportGUI/ImportExportGUI.h rename to src/XAOPlugin/XAOPlugin_GUI.h index 1c3864a27..bbd83db36 100644 --- a/src/ImportExportGUI/ImportExportGUI.h +++ b/src/XAOPlugin/XAOPlugin_GUI.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -17,25 +17,23 @@ // 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 +#ifndef XAOPlugin_GUI_H +#define XAOPlugin_GUI_H -#include "GEOMGUI.h" +#include "GEOMPluginGUI.h" //================================================================================= -// class : ImportExportGUI +// class : XAOPlugin_GUI // purpose : //================================================================================= -class ImportExportGUI: public GEOMGUI +class XAOPlugin_GUI: public GEOMPluginGUI { public: - ImportExportGUI(GeometryGUI* parent); - ~ImportExportGUI(); + XAOPlugin_GUI(GeometryGUI* parent); + ~XAOPlugin_GUI(); - bool OnGUIEvent(int commandId, SUIT_Desktop* parent); + bool OnGUIEvent( int commandId, SUIT_Desktop* ); + bool OnGUIEvent( const QString&, SUIT_Desktop* ); }; -#endif // IMPORTEXPORTGUI_H +#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/GEOMImpl/GEOMImpl_IImportExportXAO.hxx b/src/XAOPlugin/XAOPlugin_IImportExport.hxx similarity index 83% rename from src/GEOMImpl/GEOMImpl_IImportExportXAO.hxx rename to src/XAOPlugin/XAOPlugin_IImportExport.hxx index bcbd4de28..4f5727536 100644 --- a/src/GEOMImpl/GEOMImpl_IImportExportXAO.hxx +++ b/src/XAOPlugin/XAOPlugin_IImportExport.hxx @@ -17,17 +17,17 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef _GEOMImpl_IImportExportXAO_HXX_ -#define _GEOMImpl_IImportExportXAO_HXX_ +#ifndef _XAOPlugin_IImportExport_HXX_ +#define _XAOPlugin_IImportExport_HXX_ #include "GEOM_Function.hxx" #define IMPORTEXPORTXAO_ARG_DATA 1 -class GEOMImpl_IImportExportXAO +class XAOPlugin_IImportExport { public: - GEOMImpl_IImportExportXAO(Handle(GEOM_Function) theFunction): _func(theFunction) {} + 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); } @@ -36,4 +36,4 @@ private: Handle(GEOM_Function) _func; }; -#endif // _GEOMImpl_IExportXAO_HXX_ +#endif // _XAOPlugin_IImportExport_HXX_ diff --git a/src/XAOPlugin/XAOPlugin_IOperations.cxx b/src/XAOPlugin/XAOPlugin_IOperations.cxx new file mode 100644 index 000000000..2e0f4d153 --- /dev/null +++ b/src/XAOPlugin/XAOPlugin_IOperations.cxx @@ -0,0 +1,666 @@ +// 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 +#include +#include +#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/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx b/src/XAOPlugin/XAOPlugin_ImportDlg.cxx similarity index 67% rename from src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx rename to src/XAOPlugin/XAOPlugin_ImportDlg.cxx index 5272fa788..6acce2f5e 100644 --- a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx +++ b/src/XAOPlugin/XAOPlugin_ImportDlg.cxx @@ -17,26 +17,29 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include -#include -#include -#include +// internal includes +#include "XAOPlugin_ImportDlg.h" +#include "XAOPlugin_IOperations_i.hh" +// KERNEL includes +#include + +// GUI includes #include #include #include #include + #include #include #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 @@ -45,26 +48,33 @@ #include #include -#include -#include "ImportExportGUI_ImportXAODlg.h" - -#include +// QT includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include //================================================================================= // Constructor //================================================================================= -ImportExportGUI_ImportXAODlg::ImportExportGUI_ImportXAODlg(GeometryGUI* geometryGUI, QWidget* parent) +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("ICON_DLG_IMPORTXAO"))); + QPixmap imageOp(resMgr->loadPixmap("GEOM", tr("XAOPLUGIN_IMPORT_ICON"))); QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); - setWindowTitle(tr("GEOM_IMPORTXAO_TITLE")); + setWindowTitle(tr("XAOPLUGIN_IMPORT_TITLE")); /***************************************************************/ - mainFrame()->GroupConstructors->setTitle(tr("GEOM_IMPORTXAO_TITLE")); + mainFrame()->GroupConstructors->setTitle(tr("XAOPLUGIN_IMPORT_TITLE")); mainFrame()->RadioButton1->setIcon(imageOp); mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton2->close(); @@ -86,7 +96,7 @@ ImportExportGUI_ImportXAODlg::ImportExportGUI_ImportXAODlg(GeometryGUI* geometry gridLayoutExport->setObjectName(QString::fromUtf8("gridLayoutExport")); int line = 0, col = 0; - QLabel* lblFileName = new QLabel(tr("GEOM_IMPORTXAO_FILENAME"), gbxExport); + QLabel* lblFileName = new QLabel(tr("XAOPLUGIN_IMPORT_FILENAME"), gbxExport); btnFileSelect = new QPushButton(gbxExport); ledFileName = new QLineEdit(gbxExport); btnFileSelect->setText("..."); @@ -111,7 +121,7 @@ ImportExportGUI_ImportXAODlg::ImportExportGUI_ImportXAODlg(GeometryGUI* geometry //================================================================================= // Destructor //================================================================================= -ImportExportGUI_ImportXAODlg::~ImportExportGUI_ImportXAODlg() +XAOPlugin_ImportDlg::~XAOPlugin_ImportDlg() { // no need to delete child widgets, Qt does it all for us } @@ -120,7 +130,7 @@ ImportExportGUI_ImportXAODlg::~ImportExportGUI_ImportXAODlg() // function : Init() // purpose : //================================================================================= -void ImportExportGUI_ImportXAODlg::Init() +void XAOPlugin_ImportDlg::Init() { // Signal/slot connections connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -128,7 +138,7 @@ void ImportExportGUI_ImportXAODlg::Init() connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked())); - initName(tr("GEOM_IMPORTXAO")); + initName(tr("XAOPLUGIN_IMPORTXAO")); //SelectionIntoArgument(); } @@ -136,7 +146,7 @@ void ImportExportGUI_ImportXAODlg::Init() // function : ClickOnOk() // purpose : //================================================================================= -void ImportExportGUI_ImportXAODlg::ClickOnOk() +void XAOPlugin_ImportDlg::ClickOnOk() { setIsApplyAndClose(true); if (ClickOnApply()) @@ -148,7 +158,7 @@ void ImportExportGUI_ImportXAODlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -bool ImportExportGUI_ImportXAODlg::ClickOnApply() +bool XAOPlugin_ImportDlg::ClickOnApply() { if(!isApplyAndClose()) { setIsDisableBrowsing( true ); @@ -191,11 +201,11 @@ bool ImportExportGUI_ImportXAODlg::ClickOnApply() // function : btnFileSelectClicked() // purpose : //================================================================================= -void ImportExportGUI_ImportXAODlg::btnFileSelectClicked() +void XAOPlugin_ImportDlg::btnFileSelectClicked() { QString file = SUIT_FileDlg::getFileName(this, ledFileName->text(), - tr("XAO_FILES"), - tr("GEOM_SELECT_IMPORT_XAO")); + tr("XAOPLUGIN_FILES"), + tr("XAOPLUGIN_IMPORT_SELECT")); if ( !file.isEmpty() ) ledFileName->setText( file ); } @@ -204,97 +214,96 @@ void ImportExportGUI_ImportXAODlg::btnFileSelectClicked() // function : ActivateThisDialog() // purpose : //================================================================================= -void ImportExportGUI_ImportXAODlg::ActivateThisDialog() +void XAOPlugin_ImportDlg::ActivateThisDialog() { - GEOMBase_Skeleton::ActivateThisDialog(); + GEOMBase_Skeleton::ActivateThisDialog(); } //================================================================================= // function : enterEvent [REDEFINED] // purpose : //================================================================================= -void ImportExportGUI_ImportXAODlg::enterEvent(QEvent*) +void XAOPlugin_ImportDlg::enterEvent(QEvent*) { - if (!mainFrame()->GroupConstructors->isEnabled()) - ActivateThisDialog(); + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); } //================================================================================= // function : createOperation // purpose : //================================================================================= -GEOM::GEOM_IOperations_ptr ImportExportGUI_ImportXAODlg::createOperation() +GEOM::GEOM_IOperations_ptr XAOPlugin_ImportDlg::createOperation() { - return getGeomEngine()->GetIInsertOperations(getStudyId()); + return getGeomEngine()->GetPluginOperations( getStudyId(), "XAOPluginEngine" ); } //================================================================================= // function : isValid // purpose : //================================================================================= -bool ImportExportGUI_ImportXAODlg::isValid(QString& msg) +bool XAOPlugin_ImportDlg::isValid(QString& msg) { - // check file name - if (ledFileName->text().isEmpty()) - return false; + // check file name + if (ledFileName->text().isEmpty()) + return false; - return true; + return true; } //================================================================================= // function : execute // purpose : //================================================================================= -bool ImportExportGUI_ImportXAODlg::execute() +bool XAOPlugin_ImportDlg::execute() { - bool res = false; + bool res = false; - QString fileName = ledFileName->text(); - GEOM::GEOM_Object_var shape; - GEOM::ListOfGO_var groups, subShapes; - GEOM::ListOfFields_var fields; + 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); + GEOM::IXAOOperations_var ieOp = GEOM::IXAOOperations::_narrow(getOperation()); + res = ieOp->ImportXAO(fileName.toUtf8().constData(), shape, subShapes, groups, fields); - if (!shape->_is_nil()) + 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++) { - m_mainShape = shape; + addInStudy(subShapes[i].in(), subShapes[i]->GetName()); } - else + for (int i = 0; i < groups->length(); i++) { - m_mainShape = NULL; + addInStudy(groups[i].in(), groups[i]->GetName()); + } + for (int i = 0; i < fields->length(); i++) + { + addFieldInStudy(fields[i].in(), m_mainShape); } - 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 ); - } + updateObjBrowser(); + if( SUIT_Application* anApp = SUIT_Session::session()->activeApplication() ) { + LightApp_Application* aLightApp = dynamic_cast( anApp ); + aLightApp->browseObjects( anEntryList ); } + } - return res; + return res; } -QString ImportExportGUI_ImportXAODlg::addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEOM::GEOM_Object_ptr theFather) +QString XAOPlugin_ImportDlg::addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEOM::GEOM_Object_ptr theFather) { if ( !hasCommand() ) return QString(); @@ -319,7 +328,7 @@ QString ImportExportGUI_ImportXAODlg::addFieldInStudy( GEOM::GEOM_Field_ptr theF 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() ); + 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 ); } @@ -329,22 +338,22 @@ QString ImportExportGUI_ImportXAODlg::addFieldInStudy( GEOM::GEOM_Field_ptr theF return anEntry; } -GEOM::GEOM_Object_ptr ImportExportGUI_ImportXAODlg::getFather(GEOM::GEOM_Object_ptr object) +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(); + 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 +QString XAOPlugin_ImportDlg::getObjectName(GEOM::GEOM_Object_ptr object) const { - if (object->_is_nil()) - return QString::null; - return object->GetName(); + if (object->_is_nil()) + return QString::null; + return object->GetName(); } diff --git a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h b/src/XAOPlugin/XAOPlugin_ImportDlg.h similarity index 50% rename from src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h rename to src/XAOPlugin/XAOPlugin_ImportDlg.h index 61ceffda1..2f32db08a 100644 --- a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h +++ b/src/XAOPlugin/XAOPlugin_ImportDlg.h @@ -17,60 +17,52 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef IMPORTEXPORTGUI_EXPORTXAODLG_H -#define IMPORTEXPORTGUI_EXPORTXAODLG_H +#ifndef XAOPlugin_ImportDlg_H +#define XAOPlugin_ImportDlg_H -#include -#include +// GEOM includes +#include "GEOMBase_Skeleton.h" class QLineEdit; class QButtonGroup; class QListWidget; -//class ImportExportGUI_1Sel1LineEdit2ListWidget; - //================================================================================= -// class : ImportExportGUI_ExportXAODlg +// class : XAOPlugin_ImportDlg // purpose : //================================================================================= -class ImportExportGUI_ExportXAODlg: public GEOMBase_Skeleton +class XAOPlugin_ImportDlg: public GEOMBase_Skeleton { - Q_OBJECT + Q_OBJECT public: - ImportExportGUI_ExportXAODlg(GeometryGUI*, QWidget* = 0); - ~ImportExportGUI_ExportXAODlg(); + 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(); + // 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*); - void processObject(); + void Init(); + void enterEvent(QEvent*); 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; + QLineEdit* ledFileName; + QPushButton* btnFileSelect; + GEOM::GEOM_Object_var m_mainShape; private slots: - void ClickOnOk(); - bool ClickOnApply(); - void ActivateThisDialog(); - void SelectionIntoArgument(); - void SetEditCurrentArgument(); - void btnFileSelectClicked(); + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void btnFileSelectClicked(); }; -#endif // IMPORTEXPORTGUI_EXPORTXAODLG_H +#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