diff --git a/Makefile.am b/Makefile.am index 9893076e7..2244fdc0e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,12 +28,10 @@ if SMESH_ENABLE_GUI ACLOCAL_AMFLAGS = -I adm_local/unix/config_files \ -I ${GUI_ROOT_DIR}/adm_local/unix/config_files \ -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \ - -I ${MED_ROOT_DIR}/adm_local/unix/config_files \ -I ${GEOM_ROOT_DIR}/adm_local/unix/config_files else !SMESH_ENABLE_GUI ACLOCAL_AMFLAGS = -I adm_local/unix/config_files \ -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \ - -I ${MED_ROOT_DIR}/adm_local/unix/config_files \ -I ${GEOM_ROOT_DIR}/adm_local/unix/config_files endif diff --git a/build_configure b/build_configure index 6c9778d7c..a8500b6e8 100755 --- a/build_configure +++ b/build_configure @@ -46,14 +46,6 @@ fi # exit #fi -######################################################################## -# Test if the MED_ROOT_DIR is set correctly - -if test ! -d "${MED_ROOT_DIR}"; then - echo "failed : MED_ROOT_DIR variable is not correct !" - exit -fi - ######################################################################## # Test if the GEOM_ROOT_DIR is set correctly @@ -82,12 +74,10 @@ if test -d "${GUI_ROOT_DIR}"; then aclocal -I adm_local/unix/config_files \ -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \ -I ${GUI_ROOT_DIR}/adm_local/unix/config_files \ - -I ${MED_ROOT_DIR}/adm_local/unix/config_files \ -I ${GEOM_ROOT_DIR}/adm_local/unix/config_files || exit 1 else aclocal -I adm_local/unix/config_files \ -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \ - -I ${MED_ROOT_DIR}/adm_local/unix/config_files \ -I ${GEOM_ROOT_DIR}/adm_local/unix/config_files || exit 1 fi diff --git a/configure.ac b/configure.ac index 83aaf3685..e97b1b891 100644 --- a/configure.ac +++ b/configure.ac @@ -408,14 +408,6 @@ echo CHECK_GEOM -echo -echo --------------------------------------------- -echo Testing Med -echo --------------------------------------------- -echo - -CHECK_MED - CHECK_PLATFORM echo @@ -452,11 +444,11 @@ echo echo Configure if test "${gui_ok}" = "yes"; then - variables="cc_ok fortran_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok cgns_ok tbb_ok omniORB_ok occ_ok doxygen_ok graphviz_ok sphinx_ok qwt_ok Kernel_ok Geom_ok Med_ok gui_ok" + variables="cc_ok fortran_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok cgns_ok tbb_ok med3_ok omniORB_ok occ_ok doxygen_ok graphviz_ok sphinx_ok qwt_ok Kernel_ok Geom_ok gui_ok" elif test "${SalomeGUI_need}" != "no"; then - variables="cc_ok fortran_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok vtk_ok hdf5_ok cgns_ok tbb_ok med3_ok omniORB_ok occ_ok doxygen_ok graphviz_ok sphinx_ok Kernel_ok Geom_ok Med_ok gui_ok" + variables="cc_ok fortran_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok vtk_ok hdf5_ok cgns_ok tbb_ok med3_ok omniORB_ok occ_ok doxygen_ok graphviz_ok sphinx_ok Kernel_ok Geom_ok gui_ok" else - variables="cc_ok fortran_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok vtk_ok hdf5_ok cgns_ok tbb_ok med3_ok omniORB_ok occ_ok doxygen_ok graphviz_ok sphinx_ok Kernel_ok Geom_ok Med_ok" + variables="cc_ok fortran_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok vtk_ok hdf5_ok cgns_ok tbb_ok med3_ok omniORB_ok occ_ok doxygen_ok graphviz_ok sphinx_ok Kernel_ok Geom_ok" fi for var in $variables @@ -549,6 +541,10 @@ AC_OUTPUT([ \ doc/salome/tui/static/header.html \ src/Makefile \ src/Controls/Makefile \ + src/MEDWrapper/Makefile \ + src/MEDWrapper/Base/Makefile \ + src/MEDWrapper/Factory/Makefile \ + src/MEDWrapper/V2_2/Makefile \ src/Driver/Makefile \ src/DriverDAT/Makefile \ src/DriverMED/Makefile \ @@ -578,6 +574,9 @@ AC_OUTPUT([ \ src/Tools/YamsPlug/Makefile \ src/Tools/YamsPlug/doc/Makefile \ src/Tools/YamsPlug/doc/conf.py \ + src/Tools/MGCleanerPlug/Makefile \ + src/Tools/MGCleanerPlug/doc/Makefile \ + src/Tools/MGCleanerPlug/doc/conf.py \ src/Tools/padder/Makefile \ src/Tools/padder/meshjob/Makefile \ src/Tools/padder/meshjob/idl/Makefile \ diff --git a/doc/salome/examples/creating_meshes_ex05.py b/doc/salome/examples/creating_meshes_ex05.py index 98e921a06..ae1d073b4 100644 --- a/doc/salome/examples/creating_meshes_ex05.py +++ b/doc/salome/examples/creating_meshes_ex05.py @@ -16,23 +16,43 @@ idbox = geompy.addToStudy(box, "box") # create a mesh tetra = smesh.Mesh(box, "MeshBox") - -algo1D = tetra.Segment() -algo1D.NumberOfSegments(7) - -algo2D = tetra.Triangle() -algo2D.MaxElementArea(800.) - -algo3D = tetra.Tetrahedron() -algo3D.MaxElementVolume(900.) +tetra.Segment().NumberOfSegments(7) +tetra.Triangle() +tetra.Tetrahedron() # compute the mesh tetra.Compute() # export the mesh in a MED file -tetra.ExportMED("/tmp/meshMED.med", 0) +import tempfile +medFile = tempfile.NamedTemporaryFile(suffix=".med").name +tetra.ExportMED( medFile, 0 ) # export a group in a MED file face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] # a box side group = tetra.GroupOnGeom( face, "face group" ) # group of 2D elements on the -tetra.ExportMED("/tmp/groupMED.med", meshPart=group) +tetra.ExportMED( medFile, meshPart=group ) + +# ======================== +# autoDimension parameter +# ======================== + +face = geompy.MakeFaceHW( 10, 10, 1, "rectangle" ) +mesh2D = smesh.Mesh( face, "mesh2D" ) +mesh2D.AutomaticHexahedralization(0) + +import MEDLoader, os + +# exported mesh is in 2D space because it is a planar mesh lying +# on XOY plane, and autoDimension=True by default +mesh2D.ExportMED( medFile ) +medMesh = MEDLoader.MEDLoader.ReadUMeshFromFile(medFile,mesh2D.GetName(),0) +print "autoDimension==True, exported mesh is in %sD"%medMesh.getSpaceDimension() + +# exported mesh is in 3D space, same as in Mesh module, +# thanks to autoDimension=False +mesh2D.ExportMED( medFile, autoDimension=False ) +medMesh = MEDLoader.MEDLoader.ReadUMeshFromFile(medFile,mesh2D.GetName(),0) +print "autoDimension==False, exported mesh is in %sD"%medMesh.getSpaceDimension() + +os.remove( medFile ) diff --git a/doc/salome/examples/defining_hypotheses_ex17.py b/doc/salome/examples/defining_hypotheses_ex17.py index d21638fcc..36d8f6c1f 100644 --- a/doc/salome/examples/defining_hypotheses_ex17.py +++ b/doc/salome/examples/defining_hypotheses_ex17.py @@ -25,6 +25,7 @@ ignoreFaces = [ faces[0], faces[-1]] geompy.addToStudy( shape, "shape" ) geompy.addToStudyInFather( shape, face1, "face1") +# 3D Viscous layers mesh = smesh.Mesh(shape, "CFD") @@ -45,3 +46,21 @@ mesh.Compute() mesh.MakeGroup("Tetras",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_TETRA) mesh.MakeGroup("Pyras",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PYRAMID) mesh.MakeGroup("Prims",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PENTA) + +# 2D Viscous layers + +# 3 edges of the 4 edges of face1 +edgeIds = geompy.SubShapeAllIDs( face1, geompy.ShapeType["EDGE"])[:-1] + +mesh = smesh.Mesh(face1,"VicsousLayers2D") +mesh.Segment().NumberOfSegments( 5 ) + +# viscous layers should be created on 1 edge, as we set 3 edges to ignore +vlHyp = mesh.Triangle().ViscousLayers2D( 2, 3, 1.5, edgeIds, isEdgesToIgnore=True ) + +mesh.Compute() + +# viscous layers should be created on 3 edges, as we pass isEdgesToIgnore=False +vlHyp.SetEdges( edgeIds, False ) + +mesh.Compute() diff --git a/doc/salome/examples/transforming_meshes_ex11.py b/doc/salome/examples/transforming_meshes_ex11.py index 0c3bee898..de98b27bb 100644 --- a/doc/salome/examples/transforming_meshes_ex11.py +++ b/doc/salome/examples/transforming_meshes_ex11.py @@ -1,13 +1,14 @@ -# Duplicate nodes +# Duplicate nodes or/and elements import salome salome.salome_init() + import GEOM from salome.geom import geomBuilder geompy = geomBuilder.New(salome.myStudy) -import SMESH, SALOMEDS +import SMESH from salome.smesh import smeshBuilder smesh = smeshBuilder.New(salome.myStudy) @@ -24,7 +25,7 @@ mesh.Hexahedron() # Compute mesh mesh.Compute() -# Without the duplication of border elements +# Duplicate nodes only # Nodes to duplicate nodes1 = mesh.CreateEmptyGroup( SMESH.NODE, 'nodes1' ) @@ -48,7 +49,7 @@ print "Nodes : ", mesh.NbNodes() print "Edges : ", mesh.NbEdges() print "Quadrangles : ", mesh.NbQuadrangles() -# With the duplication of border elements +# Duplicate nodes and border elements # Edges to duplicate edges = mesh.CreateEmptyGroup( SMESH.EDGE, 'edges' ) @@ -76,6 +77,19 @@ print "Nodes : ", mesh.NbNodes() print "Edges : ", mesh.NbEdges() print "Quadrangles : ", mesh.NbQuadrangles() + +# Duplicate elements only + +# Duplicate all faces and make a group of new faces. +# If a mesh is given to DoubleElements(), all elements of the greatest dimension are duplicated +newFacesGroup = mesh.DoubleElements( mesh, "newFacesGroup" ) + +# Duplicate edges contained in the group "edges" and add new edges to this group +mesh.DoubleElements( edges, edges.GetName() ) + +# Duplicate two first edges of the mesh +mesh.DoubleElements([ 1, 2 ]) + # Update object browser if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0) diff --git a/doc/salome/gui/SMESH/CMakeLists.txt b/doc/salome/gui/SMESH/CMakeLists.txt index 326133c7e..a0c5fe79a 100644 --- a/doc/salome/gui/SMESH/CMakeLists.txt +++ b/doc/salome/gui/SMESH/CMakeLists.txt @@ -46,8 +46,6 @@ IF(WINDOWS) @SET PATH=$ENV{KERNEL_ROOT_DIR}/lib/salome\;%PATH% @SET PYTHONPATH=$ENV{KERNEL_ROOT_DIR}/bin/salome\;%PYTHONPATH% @SET PYTHONPATH=$ENV{KERNEL_ROOT_DIR}/lib/python${PYTHON_VERSION}/site-packages/salome\;%PYTHONPATH% - @SET PYTHONPATH=$ENV{MED_ROOT_DIR}/lib/python${PYTHON_VERSION}/site-packages/salome\;%PYTHONPATH% - @SET PYTHONPATH=$ENV{MED_ROOT_DIR}/bin/salome\;%PYTHONPATH% @SET PYTHONPATH=$ENV{GEOM_ROOT_DIR}/lib/python${PYTHON_VERSION}/site-packages/salome\;%PYTHONPATH% @SET PYTHONPATH=$ENV{GEOM_ROOT_DIR}/bin/salome\;%PYTHONPATH% @SET PYTHONPATH=${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/salome\;%PYTHONPATH% @@ -57,8 +55,8 @@ IF(WINDOWS) SET(EXT "bat") SET(CALL_STR "call") ELSE(WINDOWS) - SET(DOC_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/bin/salome:${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/salome:${MED_ROOT_DIR}/lib/python${PYTHON_VERSION}/site-packages/salome:${GEOM_ROOT_DIR}/bin/salome:${GEOM_ROOT_DIR}/lib/python${PYTHON_VERSION}/site-packages/salome:${KERNEL_ROOT_DIR}/bin/salome:${KERNEL_ROOT_DIR}/lib/python${PYTHON_VERSION}/site-packages/salome:${OMNIORB_ROOT_USER}/lib/python${PYTHON_VERSION}/site-packages:${OMNIORB_ROOT_USER}/lib64/python${PYTHON_VERSION}/site-packages") - SET(DOC_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/lib/salome:${MED_ROOT_DIR}/lib/salome:${GEOM_ROOT_DIR}/lib/salome:${KERNEL_ROOT_DIR}/lib/salome") + SET(DOC_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/bin/salome:${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/salome:${GEOM_ROOT_DIR}/bin/salome:${GEOM_ROOT_DIR}/lib/python${PYTHON_VERSION}/site-packages/salome:${KERNEL_ROOT_DIR}/bin/salome:${KERNEL_ROOT_DIR}/lib/python${PYTHON_VERSION}/site-packages/salome:${OMNIORB_ROOT_USER}/lib/python${PYTHON_VERSION}/site-packages:${OMNIORB_ROOT_USER}/lib64/python${PYTHON_VERSION}/site-packages") + SET(DOC_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/lib/salome:${GEOM_ROOT_DIR}/lib/salome:${KERNEL_ROOT_DIR}/lib/salome") SET(SCR "export PYTHONPATH=${DOC_PYTHONPATH}:\${PYTHONPATH} export LD_LIBRARY_PATH=${DOC_LD_LIBRARY_PATH}:\${LD_LIBRARY_PATH} export SMESH_MeshersList=${DOC_SMESH_MeshersList} diff --git a/doc/salome/gui/SMESH/Makefile.am b/doc/salome/gui/SMESH/Makefile.am index 351520331..aad285f22 100755 --- a/doc/salome/gui/SMESH/Makefile.am +++ b/doc/salome/gui/SMESH/Makefile.am @@ -31,8 +31,8 @@ dist_salomescript_PYTHON = collect_mesh_methods.py guidocdir = $(docdir)/gui/SMESH guidoc_DATA = images/head.png -DOC_PYTHONPATH=$(prefix)/bin/salome:$(prefix)/lib/python$(PYTHON_VERSION)/site-packages/salome:$(MED_ROOT_DIR)/lib/python$(PYTHON_VERSION)/site-packages/salome:$(GEOM_ROOT_DIR)/bin/salome:$(GEOM_ROOT_DIR)/lib/python$(PYTHON_VERSION)/site-packages/salome:$(KERNEL_ROOT_DIR)/bin/salome:$(KERNEL_ROOT_DIR)/lib/python$(PYTHON_VERSION)/site-packages/salome:$(OMNIORB_ROOT)/lib/python$(PYTHON_VERSION)/site-packages:$(OMNIORB_ROOT)/lib64/python$(PYTHON_VERSION)/site-packages -DOC_LD_LIBRARY_PATH=$(prefix)/lib/salome:$(MED_ROOT_DIR)/lib/salome:$(GEOM_ROOT_DIR)/lib/salome:$(KERNEL_ROOT_DIR)/lib/salome +DOC_PYTHONPATH=$(prefix)/bin/salome:$(prefix)/lib/python$(PYTHON_VERSION)/site-packages/salome:$(GEOM_ROOT_DIR)/bin/salome:$(GEOM_ROOT_DIR)/lib/python$(PYTHON_VERSION)/site-packages/salome:$(KERNEL_ROOT_DIR)/bin/salome:$(KERNEL_ROOT_DIR)/lib/python$(PYTHON_VERSION)/site-packages/salome:$(OMNIORB_ROOT)/lib/python$(PYTHON_VERSION)/site-packages:$(OMNIORB_ROOT)/lib64/python$(PYTHON_VERSION)/site-packages +DOC_LD_LIBRARY_PATH=$(prefix)/lib/salome:$(GEOM_ROOT_DIR)/lib/salome:$(KERNEL_ROOT_DIR)/lib/salome DOC_SMESH_MeshersList=StdMeshers tmp1/smeshBuilder.py: $(top_srcdir)/src/SMESH_SWIG/StdMeshersBuilder.py $(srcdir)/collect_mesh_methods.py @@ -80,6 +80,7 @@ uninstall-local: case $${filen} in \ dummy ) ;; \ $(DESTDIR)$(guidocdir)/yams ) ;; \ + $(DESTDIR)$(guidocdir)/MGCleaner ) ;; \ $(DESTDIR)$(guidocdir)/head.png ) ;; \ * ) echo "removing $${filen}" && rm -rf $${filen} ;; \ esac ; \ diff --git a/doc/salome/gui/SMESH/images/addinfo_group.png b/doc/salome/gui/SMESH/images/addinfo_group.png index c9ac74a06..7dfcdf074 100644 Binary files a/doc/salome/gui/SMESH/images/addinfo_group.png and b/doc/salome/gui/SMESH/images/addinfo_group.png differ diff --git a/doc/salome/gui/SMESH/images/addinfo_mesh.png b/doc/salome/gui/SMESH/images/addinfo_mesh.png index 42d88c638..75215b304 100644 Binary files a/doc/salome/gui/SMESH/images/addinfo_mesh.png and b/doc/salome/gui/SMESH/images/addinfo_mesh.png differ diff --git a/doc/salome/gui/SMESH/images/addinfo_submesh.png b/doc/salome/gui/SMESH/images/addinfo_submesh.png index f41ba2904..44b1ddad0 100644 Binary files a/doc/salome/gui/SMESH/images/addinfo_submesh.png and b/doc/salome/gui/SMESH/images/addinfo_submesh.png differ diff --git a/doc/salome/gui/SMESH/images/advanced_mesh_infos.png b/doc/salome/gui/SMESH/images/advanced_mesh_infos.png index 3471144a1..c3585eaaf 100755 Binary files a/doc/salome/gui/SMESH/images/advanced_mesh_infos.png and b/doc/salome/gui/SMESH/images/advanced_mesh_infos.png differ diff --git a/doc/salome/gui/SMESH/images/crack_emulation_double_nodes.png b/doc/salome/gui/SMESH/images/crack_emulation_double_nodes.png new file mode 100644 index 000000000..032d9d6df Binary files /dev/null and b/doc/salome/gui/SMESH/images/crack_emulation_double_nodes.png differ diff --git a/doc/salome/gui/SMESH/images/crack_emulation_double_nodes_with_elems.png b/doc/salome/gui/SMESH/images/crack_emulation_double_nodes_with_elems.png new file mode 100644 index 000000000..9a0fd5e25 Binary files /dev/null and b/doc/salome/gui/SMESH/images/crack_emulation_double_nodes_with_elems.png differ diff --git a/doc/salome/gui/SMESH/images/ctrlinfo.png b/doc/salome/gui/SMESH/images/ctrlinfo.png new file mode 100644 index 000000000..9cdad0ac8 Binary files /dev/null and b/doc/salome/gui/SMESH/images/ctrlinfo.png differ diff --git a/doc/salome/gui/SMESH/images/duplicate01.png b/doc/salome/gui/SMESH/images/duplicate01.png index 80a4a2ba9..02938fa41 100644 Binary files a/doc/salome/gui/SMESH/images/duplicate01.png and b/doc/salome/gui/SMESH/images/duplicate01.png differ diff --git a/doc/salome/gui/SMESH/images/duplicate02.png b/doc/salome/gui/SMESH/images/duplicate02.png index 0e5014125..9653a3ea0 100644 Binary files a/doc/salome/gui/SMESH/images/duplicate02.png and b/doc/salome/gui/SMESH/images/duplicate02.png differ diff --git a/doc/salome/gui/SMESH/images/duplicate03.png b/doc/salome/gui/SMESH/images/duplicate03.png new file mode 100644 index 000000000..72b2a7a80 Binary files /dev/null and b/doc/salome/gui/SMESH/images/duplicate03.png differ diff --git a/doc/salome/gui/SMESH/images/eleminfo1.png b/doc/salome/gui/SMESH/images/eleminfo1.png index 3e1888ff2..74c76db63 100755 Binary files a/doc/salome/gui/SMESH/images/eleminfo1.png and b/doc/salome/gui/SMESH/images/eleminfo1.png differ diff --git a/doc/salome/gui/SMESH/images/eleminfo2.png b/doc/salome/gui/SMESH/images/eleminfo2.png index ea73500bd..b7a785bc9 100755 Binary files a/doc/salome/gui/SMESH/images/eleminfo2.png and b/doc/salome/gui/SMESH/images/eleminfo2.png differ diff --git a/doc/salome/gui/SMESH/images/meshexportmesh.png b/doc/salome/gui/SMESH/images/meshexportmesh.png index 57d0a8021..d2997a47d 100755 Binary files a/doc/salome/gui/SMESH/images/meshexportmesh.png and b/doc/salome/gui/SMESH/images/meshexportmesh.png differ diff --git a/doc/salome/gui/SMESH/images/pref21.png b/doc/salome/gui/SMESH/images/pref21.png index d39efb580..ddacc6332 100755 Binary files a/doc/salome/gui/SMESH/images/pref21.png and b/doc/salome/gui/SMESH/images/pref21.png differ diff --git a/doc/salome/gui/SMESH/images/pref22.png b/doc/salome/gui/SMESH/images/pref22.png index b56c4e540..ff13403fb 100755 Binary files a/doc/salome/gui/SMESH/images/pref22.png and b/doc/salome/gui/SMESH/images/pref22.png differ diff --git a/doc/salome/gui/SMESH/images/pref23.png b/doc/salome/gui/SMESH/images/pref23.png index 07858d726..c715ee482 100755 Binary files a/doc/salome/gui/SMESH/images/pref23.png and b/doc/salome/gui/SMESH/images/pref23.png differ diff --git a/doc/salome/gui/SMESH/images/pref24.png b/doc/salome/gui/SMESH/images/pref24.png index f1cdcf8fc..167cc0bf0 100755 Binary files a/doc/salome/gui/SMESH/images/pref24.png and b/doc/salome/gui/SMESH/images/pref24.png differ diff --git a/doc/salome/gui/SMESH/images/reduce_three_to_one.png b/doc/salome/gui/SMESH/images/reduce_three_to_one.png new file mode 100644 index 000000000..d5f4a382e Binary files /dev/null and b/doc/salome/gui/SMESH/images/reduce_three_to_one.png differ diff --git a/doc/salome/gui/SMESH/images/smesh_sort.png b/doc/salome/gui/SMESH/images/smesh_sort.png new file mode 100644 index 000000000..0b00568c3 Binary files /dev/null and b/doc/salome/gui/SMESH/images/smesh_sort.png differ diff --git a/doc/salome/gui/SMESH/images/viscous_layers_hyp.png b/doc/salome/gui/SMESH/images/viscous_layers_hyp.png index 843ff5d09..9c9930317 100644 Binary files a/doc/salome/gui/SMESH/images/viscous_layers_hyp.png and b/doc/salome/gui/SMESH/images/viscous_layers_hyp.png differ diff --git a/doc/salome/gui/SMESH/images/viscous_layers_on_submesh.png b/doc/salome/gui/SMESH/images/viscous_layers_on_submesh.png new file mode 100644 index 000000000..3897baadc Binary files /dev/null and b/doc/salome/gui/SMESH/images/viscous_layers_on_submesh.png differ diff --git a/doc/salome/gui/SMESH/input/2d_meshing_hypo.doc b/doc/salome/gui/SMESH/input/2d_meshing_hypo.doc index d72e4d504..c5095b1bf 100644 --- a/doc/salome/gui/SMESH/input/2d_meshing_hypo.doc +++ b/doc/salome/gui/SMESH/input/2d_meshing_hypo.doc @@ -13,11 +13,10 @@ \anchor max_element_area_anchor

Max Element Area

-Max Element Area hypothesis is applied for meshing of 2D faces +Max Element Area hypothesis is applied for meshing of faces composing your geometrical object. Definition of this hypothesis -consists of setting the maximum area of meshing elements (depending on -the chosen meshing algorithm it can be triangles or quadrangles), -which will compose the mesh of these 2D faces. +consists of setting the maximum area of mesh elements, +which will compose the mesh of these faces. \image html a-maxelarea.png @@ -33,8 +32,9 @@ operation. \anchor length_from_edges_anchor

Length from Edges

-Length from edges hypothesis builds 2D mesh segments having a -length calculated as an average edge length for a given wire. +Length from edges hypothesis builds 2D mesh elements having a +maximum linear size calculated as an average segment length for a wire +of a given face. See Also a sample TUI Script of a \ref tui_length_from_edges "Length from Edges" hypothesis operation. @@ -48,7 +48,7 @@ length calculated as an average edge length for a given wire. Quadrangle parameters is a hypothesis for Quadrangle (Mapping). Base vertex parameter allows using Quadrangle (Mapping) -algorithm for meshing of triangular faces. In this case it is +algorithm for meshing of trilateral faces. In this case it is necessary to select the vertex, which will be used as the fourth edge (degenerated). @@ -86,13 +86,22 @@ between them. The following types are available: This type corresponds to Quadrangle Preference additional hypothesis, which is obsolete now.
  • Quadrangle preference (reversed) works in the same way and -with the same restriction as Quadrangle preference, but - the transition area is located along the coarser meshed sides.
  • + with the same restriction as Quadrangle preference, but + the transition area is located along the coarser meshed sides.
  • Reduced type forces building only quadrangles and the transition between the sides is made gradually, layer by layer. This type has a limitation on the number of segments: one pair of opposite sides must have the same number of segments, the other pair must have an even difference - between the numbers of segments on the sides.
  • + between the numbers of segments on the sides. In addition, number + of rows of faces between sides with different discretization + should be enough for the transition. At the fastest transition + pattern, three segments become one (see the image below), hence + the least number of face rows needed to reduce from Nmax segments + to Nmin segments is log3( Nmax / Nmin ). The number of + face rows is equal to number of segments on each of equally + discretized sides. +\image html reduce_three_to_one.png "The fastest transition pattern: 3 to 1" + See Also a sample TUI Script of a diff --git a/doc/salome/gui/SMESH/input/about_hypo.doc b/doc/salome/gui/SMESH/input/about_hypo.doc index 4453a7b8d..e4bf36ca0 100644 --- a/doc/salome/gui/SMESH/input/about_hypo.doc +++ b/doc/salome/gui/SMESH/input/about_hypo.doc @@ -5,13 +5,12 @@ \b Hypotheses represent boundary conditions which will be taken into account at calculations of meshes or sub-meshes basing on geometrical objects. These hypotheses allow you to manage the level of detail of -the resulting meshes or submeshes: when applying different hypotheses -with different parameters you can preset the quantity of meshing +the resulting meshes or sub-meshes: when applying different hypotheses +with different parameters you can preset the quantity or size of elements which will compose your mesh. So, it will be possible to generate a coarse or a more refined mesh or sub-mesh. -In \b MESH there are the following Basic Hypotheses (to introduce -them, you operate numerical values): +In \b MESH there are the following Basic Hypotheses: diff --git a/doc/salome/gui/SMESH/input/arranging_study_objects_page.doc b/doc/salome/gui/SMESH/input/arranging_study_objects_page.doc new file mode 100644 index 000000000..ea655d5f4 --- /dev/null +++ b/doc/salome/gui/SMESH/input/arranging_study_objects_page.doc @@ -0,0 +1,11 @@ +/*! + +\page arranging_study_objects_page Arranging objects in study + +If sub-meshes or groups container item has more than one child sub-object, then there is a possibility to sort these children in ascending order. + +To use sort functionality select "Sort children" popup menu item for the parent object. + +\image html smesh_sort.png "Sorting of sub-objects" + +*/ diff --git a/doc/salome/gui/SMESH/input/basic_meshing_algos.doc b/doc/salome/gui/SMESH/input/basic_meshing_algos.doc index 5aed468f1..142ca62f4 100644 --- a/doc/salome/gui/SMESH/input/basic_meshing_algos.doc +++ b/doc/salome/gui/SMESH/input/basic_meshing_algos.doc @@ -30,13 +30,13 @@ quadrangular elements. \image html image124.gif "Example of a quadrangular 2D mesh" -
  • For meshing of 3D entities (volume objects):
  • +
  • For meshing of 3D entities (solid objects):
  • diff --git a/doc/salome/gui/SMESH/input/constructing_meshes.doc b/doc/salome/gui/SMESH/input/constructing_meshes.doc index 126dcfbd9..2255641b3 100644 --- a/doc/salome/gui/SMESH/input/constructing_meshes.doc +++ b/doc/salome/gui/SMESH/input/constructing_meshes.doc @@ -251,7 +251,7 @@ And the last mesh computation is made with: "Result mesh with order SubMesh_3, SubMesh_2, SubMesh_1 " As we can see, each mesh computation has a different number of result -elements and a different mesh discretisation on the shared edges (the edges +elements and a different mesh discretization on the shared edges (the edges that are shared between Face_1, Face_2 and Face_3) Additionally, submesh priority (the order of applied algorithms) can diff --git a/doc/salome/gui/SMESH/input/double_nodes_page.doc b/doc/salome/gui/SMESH/input/double_nodes_page.doc index a8a93d1f9..0c4c1eb2c 100644 --- a/doc/salome/gui/SMESH/input/double_nodes_page.doc +++ b/doc/salome/gui/SMESH/input/double_nodes_page.doc @@ -1,36 +1,37 @@ /*! -\page double_nodes_page Duplicate Nodes +\page double_nodes_page Duplicate Nodes or/and Elements -\n This operation allows to duplicate nodes of your mesh, which can be -useful to emulate a crack in the model. -Duplication consists in replacement of an existing mesh element by another one. -Lower level elements of the duplicated ones are cloned automatically. +\n This operation allows to duplicate nodes or/and elements of your mesh. +Duplication of nodes can be useful to emulate a crack in the model. +Duplication consists in creation of mesh element "equal" to existing ones. -To duplicate nodes: +To duplicate nodes or/and elements:
      -
    1. From the \b Modification menu choose \b Transformation -> \b Duplicate -\b Nodes item or click "Duplicate Nodes" button in the toolbar. +
    2. From the \b Modification menu choose \b Transformation -> Duplicate + Nodes or/and Elements item or click "Duplicate Nodes or/and + Elements" button in the toolbar.
      -\image html duplicate_nodes.png "Duplicate Nodes button" +\image html duplicate_nodes.png "Duplicate Nodes or/and Elements button"
    3. -
    4. Check in the dialog box one of two radio buttons corresponding to -the type of nodes duplication operation you would like to perform.
    5. -
    6. Fill the other fields available in the dialog box (depends on the chosen - operation mode).
    7. -
    8. Click the \b Apply or Apply and Close button to perform the operation of nodes - duplication.
    9. +
    10. Check in the dialog box one of three radio buttons corresponding to + the type of duplication operation you would like to perform.
    11. +
    12. Fill the other fields available in the dialog box (depending on + the chosen operation mode).
    13. +
    14. Click the \b Apply or Apply and Close button to perform the + operation of duplication.
    -\n "Duplicate Nodes" dialog has two working modes: +\n "Duplicate Nodes or/and Elements" dialog has three working modes:
    \anchor mode_without_elem_anchor -

    Without duplication of border elements

    +

    Duplicate nodes only

    In this mode the dialog looks like: @@ -38,16 +39,29 @@ In this mode the dialog looks like: Parameters to be defined in this mode: +A schema below explains the crack emulation using the node duplication. +\image html crack_emulation_double_nodes.png "Crack emulation" +This schema shows a virtual crack in a 2D mesh created using this duplication +mode. In this schema: +- Black balls are nodes to duplicate. +- Red balls are new nodes. +- Elements to replace nodes with new ones are marked with green. + +Note that in reality nodes to duplicate coincide with new nodes. +
    \anchor mode_with_elem_anchor -

    With duplication of border elements

    +

    Duplicate nodes and border elements

    In this mode the dialog looks like: @@ -55,18 +69,62 @@ In this mode the dialog looks like: Parameters to be defined in this mode: + +A schema below explains the crack emulation using the node duplication +with border elements. +\image html crack_emulation_double_nodes_with_elems.png "Crack emulation" +This schema shows a virtual crack in a 2D mesh created using this duplication +mode. In this schema: +- Black segments are elements to duplicate (edges in 2D case). +- Black balls (except the lowest one) are nodes of elements to + duplicate that are duplicated. +- The lowest black ball is a node not to duplicate. +- Red balls are creates nodes. +- Red segments are created elements (edges). +- Elements to replace nodes with new ones are marked with green. + +Note that in reality nodes to duplicate coincide with new nodes. +
    +In a 3D case, where elements to duplicate are faces, the edges +located at the "crack" (if any) are cloned automatically. + +
    +\anchor mode_elem_only_anchor +

    Duplicate elements only

    + +This mode just duplicates given elements, i.e. creates new elements on +the same nodes as the given elements. +
    +In this mode the dialog looks like: + +\image html duplicate03.png + +Parameters to be defined in this mode: + -
    See Also a sample TUI Script of a \ref tui_duplicate_nodes "Duplicate nodes" operation. +
    See Also a sample TUI Script of a + \ref tui_duplicate_nodes "Duplicate nodes or/and elements" operation. */ diff --git a/doc/salome/gui/SMESH/input/importing_exporting_meshes.doc b/doc/salome/gui/SMESH/input/importing_exporting_meshes.doc index 9b0d032fa..6519aa16d 100644 --- a/doc/salome/gui/SMESH/input/importing_exporting_meshes.doc +++ b/doc/salome/gui/SMESH/input/importing_exporting_meshes.doc @@ -2,19 +2,22 @@ \page importing_exporting_meshes_page Importing and exporting meshes -\n In MESH there is a functionality allowing importation/exportation +\n In MESH there is a functionality allowing import/export of meshes from/to \b MED, \b UNV (I-DEAS 10), \b DAT (simple ascii format), \b STL, -\b GMF (internal format of DISTENE products, namely BLSurf, GHS3D and Hexotic algorithms) and \b CGNS format files. You can also export a group as a whole mesh. +\b GMF (internal format of DISTENE products, namely BLSurf, GHS3D and +Hexotic algorithms) and \b CGNS format files. You can also export a +group as a whole mesh. To import a mesh:
    1. From the \b File menu choose the \b Import item, from its sub-menu -select the corresponding format (MED, UNV, STL, GMF and CGNS) of the file containing -your mesh.
    2. + select the corresponding format (MED, UNV, STL, GMF and CGNS) of the + file containing your mesh.
    3. In the standard Search File dialog box find the file for -importation. It is possible to select multiple files to be imported all at once.
    4. + import. It is possible to select multiple files to be imported all at + once.
    5. Click the \b OK button.
    @@ -24,17 +27,35 @@ importation. It is possible to select multiple files to be imported all at once. To export a mesh or a group:
      -
    1. Select the object you wish to export.
    2. -
    3. From the \b File menu choose the \b Export item, from its sub-menu -select the format (MED, UNV, DAT, STL, GMF and CGNS) of the file which will -contain your exported mesh.
    4. -
    5. In the standard Search File select a location for the -exported file and enter its name.
    6. -
    7. Click the \b OK button.
    8. +
    9. Select the object you wish to export.
    10. +
    11. From the \b File menu choose the \b Export item, from its sub-menu + select the format (MED, UNV, DAT, STL, GMF and CGNS) of the file which will + contain your exported mesh.
    12. +
    13. In the standard Search File select a location for the + exported file and enter its name.
    14. +
    15. Click the \b OK button.
    \image html meshexportmesh.png +At export to MED and SAUV format files additional parameters are available. +
    See Also a sample TUI Script of an \ref tui_export_mesh "Export Mesh" operation. */ diff --git a/doc/salome/gui/SMESH/input/index.doc b/doc/salome/gui/SMESH/input/index.doc index 798237b4b..917e540bd 100644 --- a/doc/salome/gui/SMESH/input/index.doc +++ b/doc/salome/gui/SMESH/input/index.doc @@ -23,6 +23,9 @@ array of dedicated operations; \subpage using_notebook_mesh_page "Salome notebook". +The possibility to sort the created sub-meshes or groups is detailed on +\subpage arranging_study_objects_page section. + Mesh module preferences are described in the \subpage mesh_preferences_page section of SALOME Mesh Help. Almost all mesh module functionalities are accessible via diff --git a/doc/salome/gui/SMESH/input/mesh_infos.doc b/doc/salome/gui/SMESH/input/mesh_infos.doc index 95897e0f0..d446d2e9d 100644 --- a/doc/salome/gui/SMESH/input/mesh_infos.doc +++ b/doc/salome/gui/SMESH/input/mesh_infos.doc @@ -15,11 +15,13 @@ in the toolbar. The Mesh Information dialog box provides three tab pages: - \ref advanced_mesh_infos_anchor "Base Info" - to show base -information about the selected mesh object +information about the selected mesh object. - \ref mesh_element_info_anchor "Element Info" - to show detailed information about the selected mesh node or element. - \ref mesh_addition_info_anchor "Additional Info" - to show additional information available for the selected mesh, sub-mesh or group object. +- \ref mesh_quality_info_anchor "Quality Info" - to show +overall quality information about the selected mesh, sub-mesh or group object. \anchor advanced_mesh_infos_anchor

    Base Information

    @@ -119,6 +121,39 @@ automatically calculated if the size of the group does not exceed the "Automatic nodes compute limit" set via the "Mesh information" preferences (zero value means no limit). +\anchor mesh_quality_info_anchor +

    Quality Information

    + +The Quality Info tab page of the dialog box provides overal +mesh quality controls information on the selected object - mesh, +sub-mesh or mesh group: +- Name; +- Nodes information: + - Number of the free nodes; + - Number of double nodes; +- Edges information: + - Number of double edges; +- Faces information: + - Number of double faces; + - Number of over-constrained faces; + - Aspect Ratio histogram; +- Volume information: + - Number of double volumes; + - Number of over-constrained volumes; + - Aspect Ratio 3D histogram. + +
    \image html ctrlinfo.png +"Quality Info" page
    + +\note User can set "Double nodes tolerance" in the dialog for local change + or via the "Quality controls" in Mesh preferences. + +\note For the perfomance reason, all quality control values for the big meshes are +computed only by demand. For this, the user should press the "compute" +button (see picture). Also, values are automatically computed if the number of the +nodes / elements does not exceed the "Automatic controls compute limit" set +via the "Mesh information" preferences (zero value means no limit). + The button \b "Dump" allows printing the information displayed in the dialog box to a .txt file. diff --git a/doc/salome/gui/SMESH/input/mesh_preferences.doc b/doc/salome/gui/SMESH/input/mesh_preferences.doc index 1ce536a16..80d751d6f 100644 --- a/doc/salome/gui/SMESH/input/mesh_preferences.doc +++ b/doc/salome/gui/SMESH/input/mesh_preferences.doc @@ -9,213 +9,227 @@ later sessions with this module. \image html pref21.png - +- Automatic Update + - If you toggle Automatic Update checkbox, the model in your + viewer automatically updated when you make changes in it, depending on + values of additional preferences specified below. + - Size limit (elements) - allows to specify the maximum + number of elements in the resulting mesh for which the automatic updating + of the presentation is performed. This option affects only + Compute operation. Zero value means "no limit". Default value + is 500 000 mesh elements. + - Incremental limit check - when this control is switched on, + check for mesh size limit will be applied not to total number of + elements in resulting mesh, but iteratively to each entity types + in the following order: 0D elements, edges, faces, volumes, balls; + at each step number of entities of given type will be added to the + total number of elements computed at previous step - if resulting + number of elements does not exceed size limit, the entities of + this type will be shown, otherwise user will be warned that some + entities are not shown. + +- Quality Controls + - If you toggle Display entity, both faces and edges of an + object will be displayed in the viewer by default. + - If you toggle Use precision checkbox, you can display numbers in + Quality Control diagrams at the necessary level of precision. + - Number of digits after point - defines precision for + Quality Controls. By default, numbers in Quality Control + diagrams are presented as integers. + - Double nodes tolerance defines the maximal distance between two + mesh nodes, at which they are considered coincident by Double nodes + quality control. + +- Display mode - allows to set Wireframe, Shading, Nodes or Shrink + presentation mode as default. + +- Representation of the 2D quadratic elements + - Representation of the 2D quadratic elements combobox - allows + to select lines or arcs for representation of quadratic elements. + - Maximum Angle - maximum deviation angle used by the + application to build arcs. + +- Mesh export + - If you toggle Automatically create groups for MED export checkbox, + this operation will be carried out automatically. + +- Mesh computation + - Show a computation result notification combobox allows to + select the notification mode about a mesh computation result. + There are 3 possible modes: + - Never - do not show the result dialog at all; + - Errors only - the result dialog will be shown if there were + some errors during a mesh computation; + - Always - show the result dialog after each mesh + computation. This is a default mode. + +- Mesh information + - Mesh element information - change the way mesh element + information is shown: + - Simple - as a plain text + - Tree - in a tree-like form + - Automatic nodes compute limit - allows to define the size limit for the + mesh groups for which the number of underlying nodes is calculated + automatically. If the group size exceeds the value set in the preferences, + the user will have to press \em Compute button explicitly. Zero value + means "no limit". By default the value is set to 100 000 mesh elements. + - Automatic controls compute limit - allows to define the size limit for the + mesh elements for which the Aspect Ratio histogram is calculated + automatically. If the mesh elements size exceeds the value set in the preferences, + the user will have to press \em Compute button explicitly. Zero value + means "no limit". By default the value is set to 3 000 mesh elements. + - Show details on groups in element information tab - when + this option is switched off (default), only the names of groups, to which the node + or element belongs, are shown in the \ref mesh_element_info_anchor "Info Tab" + tab of "Mesh Information" dialog box. If this option is + switched on, the detailed information on groups is shown. + - Dump base information - allows to dump base mesh information to the + file, see \ref mesh_infos_page. + - Dump element information - allows to dump element information to the + file, see \ref mesh_infos_page. + - Dump additional information - allows to dump additional mesh + information to the file, see \ref mesh_infos_page. + - Dump controls information - allows to dump quality mesh + information to the file, see \ref mesh_infos_page. + +- Automatic Parameters + - Ratio Bounding Box Diagonal / Max Size - this parameter is + used for automatic meshing: ratio between the bounding box of the + meshed object and the Max Size of segments. + - Default Number of Segments - allows defining the default + number of segments on each edge. + +- Mesh loading + - If No mesh loading from study file at hypothesis modification + checkbox is on, the mesh data will not be loaded from the study file + when a hypothesis is modified. This allows saving time by omitting + loading data of a large mesh that is planned to be recomputed with other parameters. + +- Input fields precision + - Length precision - allows to adjust input precision of coordinates and dimensions. + - Angular precision - allows to adjust input precision of angles. + - Length tolerance precision - allows to adjust input precision of tolerance of coordinates and dimensions. + - Parametric precision - allows to adjust input precision of parametric values. + - Area precision - allows to adjust input precision of mesh element area. + - Volume precision - allows to adjust input precision of mesh element volume. + +- Preview + - Sub-shapes preview chunk size - allows to limit the number + of previewed sub-shapes shown in the hypotheses creation dialog boxes, + for example "Reverse Edges" parameter of \ref number_of_segments_anchor "Number of segments" hypothesis. + +- Python Dump + - Historical python dump checkbox allows switching between + \a Historical and \a Snapshot dump mode: + - In \a Historical mode, Python Dump script includes all commands + performed by SMESH engine. + - In \a Snapshot mode, the commands relating to objects removed + from the Study as well as the commands not influencing the + current state of meshes are excluded from the script.

    Mesh Preferences

    \image html pref22.png - +- Nodes + - Color - allows to select the color of nodes. Click on the + colored line to access to the Select Color dialog box. + - Type of marker - allows to define the shape of nodes. + - Scale of marker - allows to define the size of nodes. + +- Elements + - Surface color - allows to select the surface color of 2D elements + (seen in Shading mode). Click on the colored line to access to the + Select Color dialog box. + - Back surface color - allows to select the back surface color + of 2D elements. This is useful to differ 2d elements with + reversed orientation. Use the slider to select the color generated basing on + the Surface color by changing its brightness and saturation. + - Volume color - allows to select the surface color of 3D elements + (seen in Shading mode). + - Reversed volume color - allows to select the surface color + of reversed 3D elements. Use the slider to select the color generated basing on + the Volume color by changing its brightness and saturation. + - 0D elements - allows to choose color of 0D mesh elements. + - Balls - allows to choose color of discrete mesh elements (balls). + - Outline color - allows to select the color of element + borders. + - Wireframe color - allows to select the color of borders of + elements in the wireframe mode. + - Size of 0D elements - specifies default size of 0D elements. + - Size of ball elements - specifies default size of discrete + elements (balls). + - Line width - allows to define the width of 1D elements (edges). + - Outline width - allows to define the width of borders of + 2D and 3D elements (shown in the Shading mode). + - Shrink coef. - allows to define relative space of elements + compared to gaps between them in shrink mode. + +- Groups allows to define groups default properties: + - Names color - specifies color of group names to be used in + 3D viewer. + - Default color - specifies default group color. + +- Numbering allows to define properties of numbering functionality: + - Nodes - specifies text properties of nodes numbering + (font family, size, attributes, color). + - Elements - same for elements. + +- Orientation of Faces - allows to define the behavior of + Orientation of faces functionality: + - \b Color - allows to define the color of orientation vertors; + - \b Scale - allows to define the size of orientation vectors; + - 3D Vector checkbox allows to choose between 2D planar + and 3D vectors.

    Selection Preferences

    \image html pref23.png - +- Selection - performed with mouse-indexing (preselection) + and left-clicking on an object, whose appearance changes as defined in + the Preferences. + - Object Color - allows to select the color of mesh (edges and + borders of meshes) of the selected entity. Click on the colored line + to access to the Select Color dialog box. + - Element color - allows to select the color of surface of selected + elements (seen in Shading mode). Click on the colored line to access + to the Select Color dialog box. + +- Preselection - performed with mouse-indexing on an object, + whose appearance changes as defined in the Preferences. + - Highlight Color - allows to select the color of mesh (edges and + borders of meshes) of the entity . Click on the colored line to access + to the Select Color dialog box. + +- Precision - in this menu you can set the value of precision + used for Nodes, Elements and Objects.

    Scalar Bar Preferences

    \image html pref24.png - +- Font - in this menu you can set type, face and color for + the font of Title and Labels. + +- Colors & Labels - in this menu you can set the number of + colors and the number of labels in use. + +- Orientation - here you can choose between vertical and + horizontal orientation of the Scalar Bar + +- Origin & Size Vertical & Horizontal - allows to define + placement (X and Y) and lookout (Width and + Height) of Scalar Bars. + - X: abscissa of the point of origin (from the left + side) + - Y: ordinate of the origin of the bar (from the bottom) + +- Distribution in this menu you can Show/Hide distribution + histogram of the values of the Scalar Bar and specify the + Coloring Type of the histogram: + - Multicolor the histogram is colored as Scalar Bar + - Monocolor the histogram is colored as selected with + Distribution color selector */ diff --git a/doc/salome/gui/SMESH/input/modifying_meshes.doc b/doc/salome/gui/SMESH/input/modifying_meshes.doc index 36c4e0abb..b7b7e2e64 100644 --- a/doc/salome/gui/SMESH/input/modifying_meshes.doc +++ b/doc/salome/gui/SMESH/input/modifying_meshes.doc @@ -22,7 +22,8 @@ the mesh or some of its elements. elements.
  • \subpage symmetry_page "Mirror" the mesh through a point or a vector of symmetry.
  • -
  • \subpage double_nodes_page "Duplicate nodes" to emulate a crack in the model.
  • +
  • \subpage double_nodes_page "Duplicate nodes or/and + Elements". Duplication of nodes can be useful to emulate a crack in the model.
  • Unite meshes by \subpage sewing_meshes_page "sewing" free borders, conform free borders, border to side or side elements.
  • \subpage merging_nodes_page "Merge Nodes", considered coincident diff --git a/doc/salome/gui/SMESH/input/tui_creating_meshes.doc b/doc/salome/gui/SMESH/input/tui_creating_meshes.doc index d7edad332..f1b12e4c4 100644 --- a/doc/salome/gui/SMESH/input/tui_creating_meshes.doc +++ b/doc/salome/gui/SMESH/input/tui_creating_meshes.doc @@ -20,7 +20,7 @@
    \anchor tui_editing_mesh -

    Editing of a mesh

    +

    Editing a mesh

    \tui_script{creating_meshes_ex04.py}
    diff --git a/doc/salome/gui/SMESH/input/tui_generate_flat_elements.doc b/doc/salome/gui/SMESH/input/tui_generate_flat_elements.doc index 42f061b39..03f0141ed 100644 --- a/doc/salome/gui/SMESH/input/tui_generate_flat_elements.doc +++ b/doc/salome/gui/SMESH/input/tui_generate_flat_elements.doc @@ -13,8 +13,8 @@ by flat elements. \n Triangles are transformed into prisms, and quadrangles into hexahedrons. \n The flat elements are stored in groups of volumes. These groups are named according to the position of the group in the list: -the group j_n_p is the group of the flat elements that are built between the group #n and the group #p in the list. -If there is no shared faces between the group #n and the group #p in the list, the group j_n_p is not created. +the group j_n_p is the group of the flat elements that are built between the group \#n and the group \#p in the list. +If there is no shared faces between the group \#n and the group \#p in the list, the group j_n_p is not created. All the flat elements are gathered into the group named "joints3D" (or "joints2D" in 2D situation). The flat element of the multiple junctions between the simple junction are stored in a group named "jointsMultiples". diff --git a/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc b/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc index 303b7cec4..d3ad4de47 100644 --- a/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc +++ b/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc @@ -58,7 +58,7 @@
    \anchor tui_duplicate_nodes -

    Duplicate nodes

    +

    Duplicate nodes or/and elements

    \tui_script{transforming_meshes_ex11.py}
    diff --git a/idl/Makefile.am b/idl/Makefile.am index c43c430ee..887895f9a 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -64,12 +64,10 @@ nodist_salomeinclude_HEADERS = $(BASEIDL_FILES:%.idl=%.hh) libSalomeIDLSMESH_la_CPPFLAGS = \ -I$(top_builddir)/idl \ $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) \ - $(KERNEL_CXXFLAGS) $(MED_CXXFLAGS) \ - $(GEOM_CXXFLAGS) + $(KERNEL_CXXFLAGS) $(GEOM_CXXFLAGS) libSalomeIDLSMESH_la_LDFLAGS = -no-undefined -version-info=0:0:0 libSalomeIDLSMESH_la_LIBADD = \ @CORBA_LIBS@ \ - $(MED_LDFLAGS) -lSalomeIDLMED \ $(GEOM_LDFLAGS) -lSalomeIDLGEOM \ $(KERNEL_LDFLAGS) -lSalomeIDLKernel @@ -80,7 +78,6 @@ OMNIORB_IDLPYFLAGS = \ @OMNIORB_IDLPYFLAGS@ \ -I$(top_builddir)/idl/salome \ -I$(KERNEL_ROOT_DIR)/idl/salome \ - -I$(MED_ROOT_DIR)/idl/salome \ -I$(GEOM_ROOT_DIR)/idl/salome IDLCXXFLAGS = \ @@ -88,13 +85,11 @@ IDLCXXFLAGS = \ @IDLCXXFLAGS@ \ -I$(top_builddir)/idl/salome \ -I$(KERNEL_ROOT_DIR)/idl/salome \ - -I$(MED_ROOT_DIR)/idl/salome \ -I$(GEOM_ROOT_DIR)/idl/salome IDLPYFLAGS = \ @IDLPYFLAGS@ \ -I$(KERNEL_ROOT_DIR)/idl/salome \ - -I$(MED_ROOT_DIR)/idl/salome \ -I$(GEOM_ROOT_DIR)/idl/salome # potential problem on parallel make on the following - multiple outputs @@ -132,7 +127,7 @@ mostlyclean-local: @for dep in $^ dummy; do \ if [ $$dep != "dummy" ]; then \ echo Building dependencies for $$dep; \ - $(CPP) $(C_DEPEND_FLAG) -x c -I$(srcdir) -I$(KERNEL_ROOT_DIR)/idl/salome -I$(MED_ROOT_DIR)/idl/salome -I$(GEOM_ROOT_DIR)/idl/salome $$dep 2>/dev/null | \ + $(CPP) $(C_DEPEND_FLAG) -x c -I$(srcdir) -I$(KERNEL_ROOT_DIR)/idl/salome -I$(GEOM_ROOT_DIR)/idl/salome $$dep 2>/dev/null | \ sed 's/\.o/\SK.cc/' >>$@; \ fi; \ done ; diff --git a/idl/SMESH_BasicHypothesis.idl b/idl/SMESH_BasicHypothesis.idl index 312f17372..b2bca113c 100644 --- a/idl/SMESH_BasicHypothesis.idl +++ b/idl/SMESH_BasicHypothesis.idl @@ -875,6 +875,14 @@ module StdMeshers void SetIgnoreEdges(in SMESH::long_array edgeIDs) raises (SALOME::SALOME_Exception); SMESH::long_array GetIgnoreEdges(); + /*! + * Set edges either to exclude from treatment or to make the Viscous Layers on. + */ + void SetEdges(in SMESH::long_array edgeIDs, + in boolean toIgnore) raises (SALOME::SALOME_Exception); + SMESH::long_array GetEdges(); + boolean GetIsToIgnoreEdges(); + /*! * Set total thickness of layers of prisms */ @@ -918,7 +926,7 @@ module StdMeshers boolean IsGridBySpacing(in short axis); /*! - * Set coordinates of nodes along an axis (counterd from zero) + * Set coordinates of nodes along an axis (countered from zero) */ void SetGrid(in SMESH::double_array coords, in short axis) raises (SALOME::SALOME_Exception); diff --git a/idl/SMESH_Filter.idl b/idl/SMESH_Filter.idl index 305a27f25..4522b2205 100644 --- a/idl/SMESH_Filter.idl +++ b/idl/SMESH_Filter.idl @@ -117,8 +117,9 @@ module SMESH { double GetValue( in long theElementId ); - Histogram GetHistogram( in short nbIntervals, in boolean isLogarithmic ); - + Histogram GetHistogram ( in short nbIntervals, in boolean isLogarithmic ); + Histogram GetLocalHistogram( in short nbIntervals, in boolean isLogarithmic, + in SMESH::SMESH_IDSource obj ); /*! * Set precision for calculation. It is a position after point which is * used to functor value after calculation. @@ -164,11 +165,12 @@ module SMESH /*! * Predicates are intended for verification of criteria, - * must return bool value by mesh id + * they return bool value by mesh id */ interface Predicate: Functor { boolean IsSatisfy( in long thEntityId ); + long NbSatisfying( in SMESH::SMESH_IDSource obj ); }; /*! diff --git a/idl/SMESH_Gen.idl b/idl/SMESH_Gen.idl index fbe8a35d6..aadfb1e33 100644 --- a/idl/SMESH_Gen.idl +++ b/idl/SMESH_Gen.idl @@ -36,6 +36,7 @@ module SMESH { + typedef sequence sobject_list; typedef sequence object_array; typedef sequence mesh_array; @@ -402,6 +403,19 @@ module SMESH * \brief Get names of meshes defined in file with the specified name. */ string_array GetMeshNames(in string theFileName); + + /*! + * \brief Moves objects to the specified position + * + * This function is used in the drag-n-drop functionality. + * + * \param what objects being moved + * \param where parent object where objects are moved to + * \param row position in the parent object's children list at which objects are moved + */ + void Move( in sobject_list what, + in SALOMEDS::SObject where, + in long row ); }; }; diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index 96e926990..4796428fd 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -29,7 +29,6 @@ #include "SALOME_Exception.idl" #include "SALOME_GenericObj.idl" #include "GEOM_Gen.idl" -#include "MED.idl" module SMESH { @@ -86,6 +85,7 @@ module SMESH double_array coords; long_array indexes; }; + typedef sequence log_array; struct PointStruct { double x; double y; @@ -93,7 +93,7 @@ module SMESH typedef sequence nodes_array; - struct DirStruct { PointStruct PS ; } ; // analog to Occ Direction + struct DirStruct { PointStruct PS ; } ; // analog to OCCT gp_Vec struct AxisStruct { double x; double y; @@ -101,7 +101,6 @@ module SMESH double vx; double vy; double vz; } ; - /*! * Node location on a shape */ @@ -130,12 +129,13 @@ module SMESH FACE, VOLUME, ELEM0D, - BALL + BALL, + NB_ELEMENT_TYPES }; typedef sequence array_of_ElementType ; /*! - * Enumeration for element geometry type, like in SMDS + * Enumeration for element geometry type, like SMDSAbs_GeometryType in SMDSAbs_ElementType.hxx */ enum GeometryType { @@ -162,7 +162,6 @@ module SMESH ORDER_QUADRATIC /*! entities of 2nd order */ }; - /*! * Enumeration of entity type used in mesh info array, * it should be synchronised with enum SMDSAbs_EntityType @@ -197,7 +196,6 @@ module SMESH Entity_Last }; - /*! * Enumeration for hypothesis status (used by AddHypothesis() and RemoveHypothesis() methods) */ @@ -221,12 +219,12 @@ module SMESH }; /*! - * Enumeration for DriverMED read status (used by ImportMEDFile() method) + * Enumeration for mesh read status (used by SMESH_Gen::CreateMeshesFrom*() methods) */ enum DriverMED_ReadStatus // in the order of severity { DRS_OK, - DRS_EMPTY, // a MED file contains no mesh with the given name + DRS_EMPTY, // a file contains no mesh with the given name DRS_WARN_RENUMBER, // a MED file has overlapped ranges of element numbers, // so the numbers from the file are ignored DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data @@ -235,16 +233,23 @@ module SMESH }; /*! - * Enumeration for DriverMED (used by Perform() method) + * Enumeration for ExportToMED*() */ - enum MED_VERSION // in the order of severity + enum MED_VERSION { MED_V2_1, MED_V2_2 }; - typedef sequence log_array; - + /*! + * \brief A structure containing information about MED file + */ + struct MedFileInfo + { + string fileName; //!< name of file + long fileSize; //!< size of file + long major, minor, release; //!< MED file version + }; /*! * Auxilary flags for advanced extrusion. @@ -280,11 +285,17 @@ module SMESH long_array GetIDs(); /*! - * Returns statistic of mesh elements - * @return array of number enityties by index of EntityType + * Returns number of mesh elements of each \a EntityType + * @return array of number of elements per \a EntityType */ long_array GetMeshInfo(); + /*! + * Returns number of mesh elements of each \a ElementType + * @return array of number of elements per \a ElementType + */ + long_array GetNbElementsByType(); + /*! * Returns types of elements it contains. * It's empty if the SMESH_IDSource contains no IDs @@ -596,19 +607,26 @@ module SMESH boolean HasDuplicatedGroupNamesMED(); /*! - * Export Mesh to different MED Formats + * Export Mesh to a MED Format file * @params * - file : name of the MED file * - auto_groups : boolean parameter for creating/not creating - * the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; - * the typical use is auto_groups=false. + * the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; + * the typical use is auto_groups=false. * - version : define the version of format of MED file, that will be created * - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists + * - autoDimension: if @c True (default), a space dimension of a MED mesh can be either + * - 1D if all mesh nodes lie on OX coordinate axis, or + * - 2D if all mesh nodes lie on XOY coordinate plane, or + * - 3D in the rest cases. + * + * If @a autoDimension is @c False, the space dimension is always 3. */ void ExportToMEDX( in string file, in boolean auto_groups, in MED_VERSION version, - in boolean overwrite ) raises (SALOME::SALOME_Exception); + in boolean overwrite, + in boolean autoDimension ) raises (SALOME::SALOME_Exception); /*! * Export a part of Mesh into a MED file @@ -617,15 +635,20 @@ module SMESH * - file : name of the MED file * - version : define the version of format of MED file, that will be created * - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists + * - autoDimension: if @c True, a space dimension for export is defined by mesh + * configuration; for example a planar mesh lying on XOY plane + * will be exported as a mesh in 2D space. + * If @a autoDimension == @c False, the space dimension is 3. */ void ExportPartToMED( in SMESH_IDSource meshPart, in string file, in boolean auto_groups, in MED_VERSION version, - in boolean overwrite ) raises (SALOME::SALOME_Exception); + in boolean overwrite, + in boolean autoDimension ) raises (SALOME::SALOME_Exception); /*! - * Export Mesh to different MED Formats + * Export Mesh to a MED Format file * Works, just the same as ExportToMEDX, with overwrite parameter equal to true. * The method is kept in order to support old functionality */ @@ -674,12 +697,10 @@ module SMESH void ExportPartToSTL( in SMESH_IDSource meshPart, in string file, in boolean isascii ) raises (SALOME::SALOME_Exception); - /*! - * Get MED Mesh + * Return computation progress [0.,1] */ - SALOME_MED::MESH GetMEDMesh() - raises (SALOME::SALOME_Exception); + double GetComputeProgress(); /*! * Get informations about mesh contents @@ -932,7 +953,7 @@ module SMESH double_array BaryCenter(in long id); /*! Gets information about imported MED file */ - SALOME_MED::MedFileInfo GetMEDFileInfo(); + MedFileInfo GetMEDFileInfo(); /*! * Sets list of notebook variables used for Mesh operations separated by ":" symbol @@ -1005,12 +1026,6 @@ module SMESH * Get the internal Id */ long GetId(); - - /*! - * Get MED subMesh - */ - SALOME_MED::FAMILY GetFamily() - raises (SALOME::SALOME_Exception); }; }; diff --git a/idl/SMESH_MeshEditor.idl b/idl/SMESH_MeshEditor.idl index 752d68930..43d7eac35 100644 --- a/idl/SMESH_MeshEditor.idl +++ b/idl/SMESH_MeshEditor.idl @@ -927,13 +927,29 @@ module SMESH boolean ChangeElemNodes(in long ide, in long_array newIDs) raises (SALOME::SALOME_Exception); + /*! + * \brief Duplicates given elements, i.e. creates new elements based on the + * same nodes as the given ones. + * \param theElements - container of elements to duplicate. + * \param theGroupName - a name of group to contain the generated elements. + * If a group with such a name already exists, the new elements + * are added to the existng group, else a new group is created. + * If \a theGroupName is empty, new elements are not added + * in any group. + * \return a group where the new elements are added. NULL if theGroupName == "". + * \sa DoubleNode() + */ + SMESH_Group DoubleElements( in SMESH_IDSource theElements, + in string theGroupName ) + raises (SALOME::SALOME_Exception); + /*! * \brief Creates a hole in a mesh by doubling the nodes of some particular elements * \param theNodes - identifiers of nodes to be doubled * \param theModifiedElems - identifiers of elements to be updated by the new (doubled) * nodes. If list of element identifiers is empty then nodes are doubled but * they not assigned to elements - * \return TRUE if operation has been completed successfully, FALSE otherwise + * \return TRUE if operation has been completed successfully, FALSE otherwise * \sa DoubleNode(), DoubleNodeGroup(), DoubleNodeGroups() */ boolean DoubleNodes( in long_array theNodes, in long_array theModifiedElems ) diff --git a/resources/Makefile.am b/resources/Makefile.am index 62cb2827e..7a057d202 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -156,7 +156,8 @@ dist_salomeres_DATA = \ mesh_sew_sideelements.png \ mesh_merge_nodes.png \ mesh_merge_elements.png \ - select1.png \ + select1.png \ + open.png \ StdMeshers.xml \ mesh_pattern.png \ mesh_pentahedron.png \ @@ -193,13 +194,14 @@ dist_salomeres_DATA = \ mesh_tree_mesh_partial.png \ mesh_extractGroup.png \ mesh_precompute.png \ - mesh_2d_from_3d.png \ - mesh_free_faces.png \ - scale.png \ - scale_along_axes.png \ + mesh_2d_from_3d.png \ + mesh_free_faces.png \ + scale.png \ + scale_along_axes.png \ split_into_tetra.png \ mesh_duplicate_nodes.png \ mesh_duplicate_nodes_with_elem.png \ + mesh_duplicate_elem_only.png \ mesh_bounding_box.png \ mesh_hypo_viscous_layers.png \ mesh_tree_hypo_viscous_layers.png \ diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index 72f293f20..7f3e3c14e 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -77,6 +77,7 @@ + @@ -85,9 +86,11 @@ + + @@ -113,6 +116,7 @@ +
    diff --git a/resources/StdMeshers.xml b/resources/StdMeshers.xml index 81c8ba228..3deebff7c 100644 --- a/resources/StdMeshers.xml +++ b/resources/StdMeshers.xml @@ -261,7 +261,7 @@ MEFISTO_2D=Triangle(algo=smeshBuilder.MEFISTO) LengthFromEdges=LengthFromEdges() MaxElementArea=MaxElementArea(SetMaxElementArea()) - ViscousLayers2D=ViscousLayers2D(SetTotalThickness(),SetNumberLayers(),SetStretchFactor(),SetIgnoreEdges()) + ViscousLayers2D=ViscousLayers2D(SetTotalThickness(),SetNumberLayers(),SetStretchFactor(),SetEdges(1),SetEdges(2)) diff --git a/resources/mesh_duplicate_elem_only.png b/resources/mesh_duplicate_elem_only.png new file mode 100644 index 000000000..c34edc39d Binary files /dev/null and b/resources/mesh_duplicate_elem_only.png differ diff --git a/resources/open.png b/resources/open.png new file mode 100644 index 000000000..8ed143ebd Binary files /dev/null and b/resources/open.png differ diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index b78c2f0f7..7686e655d 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -2768,10 +2768,11 @@ void ElemEntityType::SetMesh( const SMDS_Mesh* theMesh ) bool ElemEntityType::IsSatisfy( long theId ) { if ( !myMesh ) return false; + if ( myType == SMDSAbs_Node ) + return myMesh->FindNode( theId ); const SMDS_MeshElement* anElem = myMesh->FindElement( theId ); return ( anElem && - myEntityType == anElem->GetEntityType() && - ( myType == SMDSAbs_Edge || myType == SMDSAbs_Face || myType == SMDSAbs_Volume )); + myEntityType == anElem->GetEntityType() ); } void ElemEntityType::SetType( SMDSAbs_ElementType theType ) diff --git a/src/Driver/Driver_Mesh.h b/src/Driver/Driver_Mesh.h index 21170efca..64a1eb739 100644 --- a/src/Driver/Driver_Mesh.h +++ b/src/Driver/Driver_Mesh.h @@ -59,7 +59,7 @@ class MESHDRIVER_EXPORT Driver_Mesh }; void SetMeshId(int theMeshId); - void SetFile(const std::string& theFileName); + virtual void SetFile(const std::string& theFileName); virtual void SetMeshName(const std::string& theMeshName); virtual std::string GetMeshName() const; diff --git a/src/DriverMED/DriverMED.hxx b/src/DriverMED/DriverMED.hxx new file mode 100644 index 000000000..c2bee4b5f --- /dev/null +++ b/src/DriverMED/DriverMED.hxx @@ -0,0 +1,28 @@ +// 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 +// + +// Declarations needed for usage of DriverMED + +#include + +class DriverMED_Family; +typedef boost::shared_ptr DriverMED_FamilyPtr; diff --git a/src/DriverMED/DriverMED_Family.cxx b/src/DriverMED/DriverMED_Family.cxx index 0644c1728..55a857f61 100644 --- a/src/DriverMED/DriverMED_Family.cxx +++ b/src/DriverMED/DriverMED_Family.cxx @@ -24,7 +24,6 @@ // File : DriverMED_Family.cxx // Author : Julia DOROVSKIKH // Module : SMESH -// $Header$ // #include "DriverMED_Family.h" #include "MED_Factory.hxx" diff --git a/src/DriverMED/DriverMED_Family.h b/src/DriverMED/DriverMED_Family.h index 1cd35e271..c64c17f7c 100644 --- a/src/DriverMED/DriverMED_Family.h +++ b/src/DriverMED/DriverMED_Family.h @@ -24,12 +24,12 @@ // File : DriverMED_Family.hxx // Author : Julia DOROVSKIKH // Module : SMESH -// $Header$ // #ifndef _INCLUDE_DRIVERMED_FAMILY #define _INCLUDE_DRIVERMED_FAMILY #include "SMESH_DriverMED.hxx" +#include "DriverMED.hxx" #include "SMDS_Mesh.hxx" #include "SMESHDS_GroupBase.hxx" @@ -49,8 +49,6 @@ #define REST_BALL_FAMILY -5 #define FIRST_ELEM_FAMILY -6 -class DriverMED_Family; -typedef boost::shared_ptr DriverMED_FamilyPtr; typedef std::list DriverMED_FamilyPtrList; typedef std::map SMESHDS_SubMeshPtrMap; typedef std::list SMESHDS_GroupBasePtrList; diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index cd6243d16..b4ca1a08f 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -52,6 +52,26 @@ static int MYDEBUG = 0; using namespace MED; using namespace std; +typedef std::map TID2FamilyMap; + +namespace DriverMED +{ + bool buildMeshGrille(const MED::PWrapper& theWrapper, + const MED::PMeshInfo& theMeshInfo, + SMESHDS_Mesh* theMesh, + const TID2FamilyMap& myFamilies); + /*! + * \brief Ensure aFamily has a required ID + * \param aFamily - a family to check + * \param anID - an ID aFamily should have + * \param myFamilies - a map of the family ID to the Family + * \retval bool - true if successful + */ + bool checkFamilyID(DriverMED_FamilyPtr & aFamily, + int anID, + const TID2FamilyMap& myFamilies); +} + void DriverMED_R_SMESHDS_Mesh ::SetMeshName(string theMeshName) @@ -135,7 +155,7 @@ DriverMED_R_SMESHDS_Mesh } if (aMeshInfo->GetType() == MED::eSTRUCTURE){ - /*bool aRes = */buildMeshGrille(aMed,aMeshInfo); + /*bool aRes = */DriverMED::buildMeshGrille(aMed,aMeshInfo,myMesh,myFamilies); continue; } @@ -169,7 +189,7 @@ DriverMED_R_SMESHDS_Mesh // Save reference to this node from its family TInt aFamNum = aNodeInfo->GetFamNum(iElem); - if ( checkFamilyID ( aFamily, aFamNum )) + if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )) { aFamily->AddElement(aNode); aFamily->SetType(SMDSAbs_Node); @@ -257,7 +277,7 @@ DriverMED_R_SMESHDS_Mesh // Save reference to this element from its family TInt aFamNum = aBallInfo->GetFamNum(iBall); - if ( checkFamilyID ( aFamily, aFamNum )) + if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )) { aFamily->AddElement(anElement); aFamily->SetType( SMDSAbs_Ball ); @@ -329,7 +349,7 @@ DriverMED_R_SMESHDS_Mesh if(aResult < DRS_WARN_RENUMBER) aResult = DRS_WARN_RENUMBER; } - if ( checkFamilyID ( aFamily, aFamNum )) + if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )) { // Save reference to this element from its family aFamily->AddElement(anElement); @@ -409,7 +429,7 @@ DriverMED_R_SMESHDS_Mesh if (aResult < DRS_WARN_RENUMBER) aResult = DRS_WARN_RENUMBER; } - if ( checkFamilyID ( aFamily, aFamNum )) { + if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )) { // Save reference to this element from its family aFamily->AddElement(anElement); aFamily->SetType(anElement->GetType()); @@ -920,7 +940,7 @@ DriverMED_R_SMESHDS_Mesh if (aResult < DRS_WARN_RENUMBER) aResult = DRS_WARN_RENUMBER; } - if ( checkFamilyID ( aFamily, aFamNum )) { + if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )) { // Save reference to this element from its family myFamilies[aFamNum]->AddElement(anElement); myFamilies[aFamNum]->SetType(anElement->GetType()); @@ -1127,7 +1147,9 @@ void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes () * \param anID - an ID aFamily should have * \retval bool - true if successful */ -bool DriverMED_R_SMESHDS_Mesh::checkFamilyID(DriverMED_FamilyPtr & aFamily, int anID) const +bool DriverMED::checkFamilyID(DriverMED_FamilyPtr & aFamily, + int anID, + const TID2FamilyMap& myFamilies) { if ( !aFamily || aFamily->GetId() != anID ) { map::const_iterator i_fam = myFamilies.find(anID); @@ -1138,14 +1160,18 @@ bool DriverMED_R_SMESHDS_Mesh::checkFamilyID(DriverMED_FamilyPtr & aFamily, int return ( aFamily->GetId() == anID ); } - -/*! \brief Reading the structured mesh and convert to non structured (by filling of smesh structure for non structured mesh) +/*! + * \brief Reading the structured mesh and convert to non structured + * (by filling of smesh structure for non structured mesh) * \param theWrapper - PWrapper const pointer * \param theMeshInfo - PMeshInfo const pointer + * \param myFamilies - a map of the family ID to the Family * \return TRUE, if successfully. Else FALSE */ -bool DriverMED_R_SMESHDS_Mesh::buildMeshGrille(const MED::PWrapper& theWrapper, - const MED::PMeshInfo& theMeshInfo) +bool DriverMED::buildMeshGrille(const MED::PWrapper& theWrapper, + const MED::PMeshInfo& theMeshInfo, + SMESHDS_Mesh* myMesh, + const TID2FamilyMap& myFamilies) { bool res = true; @@ -1167,7 +1193,7 @@ bool DriverMED_R_SMESHDS_Mesh::buildMeshGrille(const MED::PWrapper& theWrapper, if((aGrilleInfo->myFamNumNode).size() > 0){ TInt aFamNum = aGrilleInfo->GetFamNumNode(iNode); - if ( checkFamilyID ( aFamily, aFamNum )) + if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )) { aFamily->AddElement(aNode); aFamily->SetType(SMDSAbs_Node); @@ -1224,7 +1250,7 @@ bool DriverMED_R_SMESHDS_Mesh::buildMeshGrille(const MED::PWrapper& theWrapper, } if((aGrilleInfo->myFamNum).size() > 0){ TInt aFamNum = aGrilleInfo->GetFamNum(iCell); - if ( checkFamilyID ( aFamily, aFamNum )){ + if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )){ aFamily->AddElement(anElement); aFamily->SetType(anElement->GetType()); } diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.h b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.h index 5e4459a32..71d38ef78 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.h +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.h @@ -29,10 +29,12 @@ #include "SMESH_DriverMED.hxx" +#include "DriverMED.hxx" #include "Driver_SMESHDS_Mesh.h" -#include "DriverMED_Family.h" +#include "SMDSAbs_ElementType.hxx" #include +#include class SMESHDS_Mesh; class SMESHDS_Group; @@ -53,18 +55,6 @@ class MESHDRIVERMED_EXPORT DriverMED_R_SMESHDS_Mesh: public Driver_SMESHDS_Mesh std::list GetMeshNames(Status& theStatus); void SetMeshName(std::string theMeshName); - private: - /*! - * \brief Ensure aFamily has required ID - * \param aFamily - a family to check - * \param anID - an ID aFamily should have - * \retval bool - true if successful - */ - bool checkFamilyID(DriverMED_FamilyPtr & aFamily, int anID) const; - - bool buildMeshGrille(const MED::PWrapper& theWrapper, - const MED::PMeshInfo& theMeshInfo); - private: std::string myMeshName; std::map myFamilies; diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index a3d934c84..aa89eea40 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -24,19 +24,19 @@ // File : DriverMED_W_SMESHDS_Mesh.cxx // Module : SMESH // -#include #include "DriverMED_W_SMESHDS_Mesh.h" -#include "DriverMED_Family.h" -#include "SMESHDS_Mesh.hxx" +#include "DriverMED_Family.h" +#include "MED_Factory.hxx" +#include "MED_Utilities.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" #include "SMDS_PolyhedralVolumeOfNodes.hxx" +#include "SMESHDS_Mesh.hxx" -#include "utilities.h" +#include -#include "MED_Utilities.hxx" #define _EDF_NODE_IDS_ //#define _ELEMENTS_BY_DIM_ @@ -46,25 +46,27 @@ using namespace MED; DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh(): + myMedVersion(MED::eV2_2), myAllSubMeshes (false), myDoGroupOfNodes (false), myDoGroupOfEdges (false), myDoGroupOfFaces (false), myDoGroupOfVolumes (false), myDoGroupOf0DElems(false), - myDoGroupOfBalls(false) + myDoGroupOfBalls(false), + myAutoDimension(true) {} void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName, - MED::EVersion theId) + MED::EVersion theId) { - myMed = CrWrapper(theFileName,theId); Driver_SMESHDS_Mesh::SetFile(theFileName); + myMedVersion = theId; } void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName) { - return SetFile(theFileName,MED::eV2_2); + Driver_SMESHDS_Mesh::SetFile(theFileName); } string DriverMED_W_SMESHDS_Mesh::GetVersionString(const MED::EVersion theVersion, int theNbDigits) @@ -120,7 +122,8 @@ void DriverMED_W_SMESHDS_Mesh::AddGroupOfVolumes() myDoGroupOfVolumes = true; } -namespace{ +namespace +{ typedef double (SMDS_MeshNode::* TGetCoord)() const; typedef const char* TName; typedef const char* TUnit; @@ -311,12 +314,13 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() } // Mesh dimension definition - TInt aSpaceDimension; + TInt aSpaceDimension = 3; TCoordHelperPtr aCoordHelperPtr; { bool anIsXDimension = false; bool anIsYDimension = false; bool anIsZDimension = false; + if ( myAutoDimension ) { SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator(); double aBounds[6]; @@ -390,6 +394,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() if ( myMesh->NbVolumes() > 0 ) aMeshDimension = 3; + MED::PWrapper myMed = CrWrapper(myFile,myMedVersion); PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName); MESSAGE("Add - aMeshName : "<GetName()); myMed->SetMeshInfo(aMeshInfo); diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.h b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.h index 7c02b40f0..30d1f475f 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.h +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.h @@ -30,7 +30,7 @@ #include "SMESH_DriverMED.hxx" #include "Driver_SMESHDS_Mesh.h" -#include "MED_Factory.hxx" +#include "MED_Common.hxx" #include #include @@ -48,6 +48,7 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh virtual void SetFile(const std::string& theFileName); void SetFile(const std::string& theFileName, MED::EVersion theId); + void SetAutoDimension(bool toFindOutDimension) { myAutoDimension = toFindOutDimension; } static std::string GetVersionString(const MED::EVersion theVersion, int theNbDigits=2); /*! sets file name; only for usage with Add(), not Write() @@ -71,7 +72,7 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh private: - MED::PWrapper myMed; + MED::EVersion myMedVersion; std::list myGroups; bool myAllSubMeshes; std::map mySubMeshes; @@ -81,8 +82,7 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh bool myDoGroupOfVolumes; bool myDoGroupOf0DElems; bool myDoGroupOfBalls; + bool myAutoDimension; }; - #endif - diff --git a/src/DriverMED/Makefile.am b/src/DriverMED/Makefile.am index 13ac7d451..dc58802a1 100644 --- a/src/DriverMED/Makefile.am +++ b/src/DriverMED/Makefile.am @@ -26,6 +26,7 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am # header files salomeinclude_HEADERS = \ + DriverMED.hxx \ DriverMED_R_SMESHDS_Mesh.h \ DriverMED_W_SMESHDS_Mesh.h \ DriverMED_Family.h \ @@ -47,12 +48,13 @@ dist_MED_Test_SOURCES = \ # additionnal information to compil and link file libMeshDriverMED_la_CPPFLAGS = \ - $(MED_CXXFLAGS) \ @HDF5_INCLUDES@ \ $(KERNEL_CXXFLAGS) \ $(CAS_CPPFLAGS) \ $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) \ + -I$(srcdir)/../MEDWrapper/Base \ + -I$(srcdir)/../MEDWrapper/Factory \ -I$(srcdir)/../Driver \ -I$(srcdir)/../SMDS \ -I$(srcdir)/../SMESHUtils \ @@ -61,7 +63,9 @@ libMeshDriverMED_la_CPPFLAGS = \ libMeshDriverMED_la_LDFLAGS = \ $(BOOST_LIBS) \ ../Driver/libMeshDriver.la \ - $(MED_LDFLAGS) -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_2 + ../MEDWrapper/Factory/libMEDWrapper.la \ + ../MEDWrapper/Base/libMEDWrapperBase.la \ + ../MEDWrapper/V2_2/libMEDWrapper_V2_2.la \ $(BOOST_LIB_SYSTEM) MED_Test_CPPFLAGS = \ @@ -77,8 +81,7 @@ MED_Test_LDADD = \ -lOpUtil \ -lSALOMELocalTrace \ -lSALOMEBasics \ - $(MED_LDFLAGS) \ - -lMEDWrapper \ - -lMEDWrapperBase \ - -lMEDWrapper_V2_2 + ../MEDWrapper/Factory/libMEDWrapper.la \ + ../MEDWrapper/Base/libMEDWrapperBase.la \ + ../MEDWrapper/V2_2/libMEDWrapper_V2_2.la \ $(BOOST_LIB_SYSTEM) diff --git a/src/MEDWrapper/Base/CMakeLists.txt b/src/MEDWrapper/Base/CMakeLists.txt new file mode 100644 index 000000000..2d7fe409d --- /dev/null +++ b/src/MEDWrapper/Base/CMakeLists.txt @@ -0,0 +1,47 @@ +# Copyright (C) 2012-2013 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 +# 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_DIRECTORIES( + ${HDF5_INCLUDE_DIRS} + ${BOOST_INCLUDE_DIRS} +) + +IF(MED_ENABLE_KERNEL) + INCLUDE_DIRECTORIES(${KERNEL_ROOT_DIR}/include/salome) +ELSE(MED_ENABLE_KERNEL) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/adm_local_without_kernel) +ENDIF(MED_ENABLE_KERNEL) + +SET(MEDWrapperBase_SOURCES + MED_Structures.cxx + MED_Wrapper.cxx + MED_Algorithm.cxx + MED_GaussUtils.cxx + MED_CoordUtils.cxx + MED_Utilities.cxx + MED_GaussDef.cxx + ) + +ADD_LIBRARY(MEDWrapperBase SHARED ${MEDWrapperBase_SOURCES}) +SET_TARGET_PROPERTIES(MEDWrapperBase PROPERTIES COMPILE_FLAGS "-D${MACHINE} ${HDF5_DEFINITIONS} ${BOOST_DEFINITIONS} ${PLATFORM_DEFINITIONS}") +TARGET_LINK_LIBRARIES(MEDWrapperBase ${BOOST_LIB_THREAD} ${BOOST_LIB_DATE_TIME}) +INSTALL(TARGETS MEDWrapperBase DESTINATION ${MED_salomelib_LIBS}) + +FILE(GLOB MEDWrapperBase_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") +INSTALL(FILES ${MEDWrapperBase_HEADERS_HXX} DESTINATION ${MED_salomeinclude_HEADERS}) diff --git a/src/MEDWrapper/Base/MED_Algorithm.cxx b/src/MEDWrapper/Base/MED_Algorithm.cxx new file mode 100644 index 000000000..afe4ab7de --- /dev/null +++ b/src/MEDWrapper/Base/MED_Algorithm.cxx @@ -0,0 +1,375 @@ +// 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 "MED_Algorithm.hxx" +#include "MED_Wrapper.hxx" + +#include "MED_Utilities.hxx" + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +static int MYVALUEDEBUG = 0; +#else +// static int MYDEBUG = 0; +// static int MYVALUEDEBUG = 0; +#endif + +namespace MED +{ + //--------------------------------------------------------------- + TEntity2TGeom2ElemInfo + GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper, + const PMeshInfo& theMeshInfo, + const MED::TEntityInfo& theEntityInfo) + { + MSG(MYDEBUG,"GetElemsByEntity(...)"); + TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo; + MED::TEntityInfo::const_iterator anIter = theEntityInfo.begin(); + PElemInfo anElemInfo; + TErr anErr; + for(; anIter != theEntityInfo.end(); anIter++){ + const EEntiteMaillage& anEntity = anIter->first; + const TGeom2Size& aGeom2Size = anIter->second; + TGeom2ElemInfo& aGeom2ElemInfo = anEntity2TGeom2ElemInfo[anEntity]; + + if(anEntity == eNOEUD){ + aGeom2ElemInfo[ePOINT1] = theWrapper->GetPElemInfo(theMeshInfo); + continue; + } + + TGeom2Size::const_iterator anIter2 = aGeom2Size.begin(); + for(; anIter2 != aGeom2Size.end(); anIter2++){ + const EGeometrieElement& aGeom = anIter2->first; + aGeom2ElemInfo[aGeom] = theWrapper->GetPElemInfo(theMeshInfo,anEntity,aGeom,MED::eNOD,&anErr); + } + } + ADDMSG(MYDEBUG,"\n"); + return anEntity2TGeom2ElemInfo; + } + + + //--------------------------------------------------------------- + TFamilyInfoSet + GetFamilyInfoSet(const PWrapper& theWrapper, + const PMeshInfo& theMeshInfo) + { + MSG(MYDEBUG,"GetFamilies(...)"); + TErr anErr; + TFamilyInfoSet aFamilyInfoSet; + TInt aNbFam = theWrapper->GetNbFamilies(*theMeshInfo); + INITMSG(MYDEBUG,"GetNbFamilies() = "<GetPFamilyInfo(theMeshInfo,iFam,&anErr); + if(anErr >= 0) + aFamilyInfoSet.insert(aFamilyInfo); + } + ADDMSG(MYDEBUG,"\n"); + return aFamilyInfoSet; + } + + + //--------------------------------------------------------------- + TGroupInfo + GetGroupInfo(const TFamilyInfoSet& theFamilyInfoSet) + { + MSG(MYDEBUG,"GetFamiliesByGroup(...)"); + TGroupInfo aGroup; + TFamilyInfoSet::const_iterator anIter = theFamilyInfoSet.begin(); + for(; anIter != theFamilyInfoSet.end(); anIter++){ + const PFamilyInfo& aFamilyInfo = *anIter; + TInt aNbGroup = aFamilyInfo->GetNbGroup(); + for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){ + aGroup[aFamilyInfo->GetGroupName(iGroup)].insert(aFamilyInfo); + } + } + +#ifdef _DEBUG_ + if(MYDEBUG){ + TGroupInfo::const_iterator anIter = aGroup.begin(); + for(; anIter != aGroup.end(); anIter++){ + const std::string& aName = anIter->first; + INITMSG(MYDEBUG,"aGroupName = '"<second; + TFamilyInfoSet::const_iterator anFamIter = aFamilyInfoSet.begin(); + for(; anFamIter != aFamilyInfoSet.end(); anFamIter++){ + const PFamilyInfo& aFamilyInfo = *anFamIter; + INITMSG(MYDEBUG,"aFamilyName = '"<GetName()<<"'\n"); + } + } + ADDMSG(MYDEBUG,"\n"); + } +#endif + + return aGroup; + } + + + //--------------------------------------------------------------- + TFieldInfo2TimeStampInfoSet + GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper, + const PMeshInfo& theMeshInfo, + const MED::TEntityInfo& theEntityInfo) + { + MSG(MYDEBUG,"GetFieldsByEntity(...)"); + TFieldInfo2TimeStampInfoSet aFieldInfo2TimeStampInfoSet; + TInt aNbFields = theWrapper->GetNbFields(); + INITMSG(MYDEBUG,"GetNbFields() = "<GetPFieldInfo(theMeshInfo,iField); + INITMSG(MYDEBUG,"aFieldName = '"<GetName()<< + "'; aNbComp = "<GetNbComp()<<"; "); + TGeom2Size aGeom2Size; + EEntiteMaillage anEntity = EEntiteMaillage(-1); + TInt aNbTimeStamps = theWrapper->GetNbTimeStamps(aFieldInfo,theEntityInfo,anEntity,aGeom2Size); + ADDMSG(MYDEBUG,"anEntity = "<GetPTimeStampInfo(aFieldInfo,anEntity,aGeom2Size,iTimeStamp); + aFieldInfo2TimeStampInfoSet[aFieldInfo].insert(aTimeStamp); + INITMSG(MYDEBUG, + "aDt = "<GetDt()<< + ", Unit = \'"<GetUnitDt()<<"\n"); + } + } + ADDMSG(MYDEBUG,"\n"); + return aFieldInfo2TimeStampInfoSet; + } + + + //--------------------------------------------------------------- + TEntite2TFieldInfo2TimeStampInfoSet + GetEntite2TFieldInfo2TimeStampInfoSet(const TFieldInfo2TimeStampInfoSet& theFieldInfo2TimeStampInfoSet) + { + TEntite2TFieldInfo2TimeStampInfoSet anEntite2TFieldInfo2TimeStampInfoSet; + TFieldInfo2TimeStampInfoSet::const_iterator anIter = theFieldInfo2TimeStampInfoSet.begin(); + for(; anIter != theFieldInfo2TimeStampInfoSet.end(); anIter++){ + const TTimeStampInfoSet& aTimeStampInfoSet = anIter->second; + //const PFieldInfo& aFieldInfo = anIter->first; + if(aTimeStampInfoSet.empty()) + continue; + const PTimeStampInfo& aTimeStampInfo = *aTimeStampInfoSet.begin(); + anEntite2TFieldInfo2TimeStampInfoSet[ConvertEntity(aTimeStampInfo->GetEntity())].insert(*anIter); + } + return anEntite2TFieldInfo2TimeStampInfoSet; + } + + + //--------------------------------------------------------------- + bool + operator<(const TFamilyTSize& theLeft, const TFamilyTSize& theRight) + { + const MED::PFamilyInfo& aLeftInfo = boost::get<0>(theLeft); + const MED::PFamilyInfo& aRightInfo = boost::get<0>(theRight); + return aLeftInfo->GetId() < aRightInfo->GetId(); + } + + + //--------------------------------------------------------------- + TEntity2FamilySet + GetEntity2FamilySet(const PWrapper& theWrapper, + const TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo, + const TFamilyInfoSet& theFamilyInfoSet) + { + MSG(MYDEBUG,"GetFamiliesByEntity(...)"); + TEntity2FamilySet anEntity2FamilySet; + + typedef std::map TId2Family; + TId2Family anId2Family; + TFamilyInfoSet::const_iterator anIter = theFamilyInfoSet.begin(); + for(; anIter != theFamilyInfoSet.end(); anIter++){ + const PFamilyInfo& aFamilyInfo = *anIter; + anId2Family.insert(TId2Family::value_type(aFamilyInfo->GetId(),aFamilyInfo)); + } + + if(!anId2Family.empty()){ + typedef std::map TFamilyID2Size; + typedef std::map TEntity2FamilyID; + TEntity2FamilyID anEntity2FamilyID; + + if(!theEntity2TGeom2ElemInfo.empty()){ + TEntity2TGeom2ElemInfo::const_iterator anIter = theEntity2TGeom2ElemInfo.begin(); + for(; anIter != theEntity2TGeom2ElemInfo.end(); anIter++){ + const EEntiteMaillage& anEntity = anIter->first; + TFamilyID2Size& aFamilyID2Size = anEntity2FamilyID[anEntity]; + const TGeom2ElemInfo& aGeom2ElemInfo = anIter->second; + TGeom2ElemInfo::const_iterator aGeom2ElemInfoIter = aGeom2ElemInfo.begin(); + for(; aGeom2ElemInfoIter != aGeom2ElemInfo.end(); aGeom2ElemInfoIter++){ + const PElemInfo& aElemInfo = aGeom2ElemInfoIter->second; + if(TInt aNbElem = aElemInfo->GetNbElem()){ + for(TInt i = 0; i < aNbElem; i++){ + aFamilyID2Size[aElemInfo->GetFamNum(i)] += 1; + } + } + } + } + } + + if(!anEntity2FamilyID.empty()){ + TEntity2FamilyID::const_iterator anIter = anEntity2FamilyID.begin(); + for(; anIter != anEntity2FamilyID.end(); anIter++){ + const EEntiteMaillage& anEntity = anIter->first; + INITMSG(MYDEBUG,"anEntity = "<second; + TFamilyID2Size::const_iterator anIter2 = aFamilyID2Size.begin(); + for(; anIter2 != aFamilyID2Size.end(); anIter2++){ + TInt anId = anIter2->first; + TInt aSize = anIter2->second; + TId2Family::const_iterator anIter3 = anId2Family.find(anId); + if(anIter3 != anId2Family.end()){ + const PFamilyInfo& aFamilyInfo = anIter3->second; + anEntity2FamilySet[anEntity].insert(TFamilyTSize(aFamilyInfo,aSize)); + INITMSG(MYDEBUG, + "aFamilyName = '"<GetName()<< + "' anId = "<GetId()<<"\n"); + } + } + } + } + } + ADDMSG(MYDEBUG,"\n"); + return anEntity2FamilySet; + } + + + //--------------------------------------------------------------- + TKey2Gauss + GetKey2Gauss(const PWrapper& theWrapper, + TErr* theErr, + EModeSwitch theMode) + { + INITMSG(MYDEBUG,"GetKey2Gauss - theMode = "<GetNbGauss(theErr); + for(TInt anId = 1; anId <= aNbGauss; anId++){ + TGaussInfo::TInfo aPreInfo = theWrapper->GetGaussPreInfo(anId); + PGaussInfo anInfo = theWrapper->CrGaussInfo(aPreInfo,theMode); + theWrapper->GetGaussInfo(anId,anInfo,theErr); + TGaussInfo::TKey aKey = boost::get<0>(aPreInfo); + aKey2Gauss[aKey] = anInfo; + +#ifdef _DEBUG_ + const EGeometrieElement& aGeom = boost::get<0>(aKey); + const std::string& aName = boost::get<1>(aKey); + INITMSG(MYDEBUG, + "- aGeom = "<GetNbProfiles(theErr); + for(TInt anId = 1; anId <= aNbProfiles; anId++){ + TProfileInfo::TInfo aPreInfo = theWrapper->GetProfilePreInfo(anId); + const std::string& aName = boost::get<0>(aPreInfo); + if(aName == theProfileName) + return theWrapper->GetPProfileInfo(anId,theMode,theErr); + } + return anInfo; + } + + + //--------------------------------------------------------------- + TMKey2Profile + GetMKey2Profile(const PWrapper& theWrapper, + TErr* theErr, + EModeProfil theMode) + { + INITMSG(MYDEBUG,"GetMKey2Profile - theMode = "<GetNbProfiles(theErr); + for(TInt anId = 1; anId <= aNbProfiles; anId++){ + TProfileInfo::TInfo aPreInfo = theWrapper->GetProfilePreInfo(anId); + PProfileInfo anInfo = theWrapper->GetPProfileInfo(anId,theMode,theErr); + const std::string& aName = boost::get<0>(aPreInfo); + aKey2Profile[aName] = anInfo; + +#ifdef _DEBUG_ + INITMSG(MYDEBUG, + "- aName = '"<GetSize(); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", "); + } + ADDMSG(MYVALUEDEBUG, std::endl); +#endif + + } + return TMKey2Profile(theMode,aKey2Profile); + } + + //--------------------------------------------------------------- + EEntiteMaillage + GetEntityByFamilyId(PGrilleInfo& theInfo,TInt theId){ + TElemNum::iterator aNodeFamIter = (theInfo->myFamNumNode).begin(); + for(;aNodeFamIter != (theInfo->myFamNumNode).end(); aNodeFamIter++){ + if(theId == *aNodeFamIter) + return eNOEUD; + } + TElemNum::iterator aCellFamIter = (theInfo->myFamNum).begin(); + for(;aCellFamIter != (theInfo->myFamNum).end(); aCellFamIter++){ + if(theId == *aCellFamIter) + return eMAILLE; + } + EXCEPTION(std::runtime_error, "GetEntityByFamilyId - fails"); + return EEntiteMaillage(-1); + } + + TFamilyID2NbCells + GetFamilyID2NbCells(PGrilleInfo& theInfo){ + TFamilyID2NbCells aFamily2NbCells; + TInt aNbNodes = theInfo->myFamNumNode.size(); + TInt aNbCells = theInfo->myFamNum.size(); + for(TInt i=0; iGetFamNumNode(i)] = 0; + for(TInt i=0; iGetFamNum(i)] = 0; + for(TInt i=0; iGetFamNumNode(i)] += 1; + for(TInt i=0; iGetFamNum(i)] += 1; + return aFamily2NbCells; + } + + EEntiteMaillage ConvertEntity(const EEntiteMaillage& aEntity){ + switch( aEntity ){ + + case eNOEUD_ELEMENT: + case eMAILLE: return eMAILLE; //eNOEUD_ELEMENT it is eMAILLE + + case eFACE: + case eARETE: + case eNOEUD: return aEntity; break; + default: return EEntiteMaillage(-1); + + } + } +} diff --git a/src/MEDWrapper/Base/MED_Algorithm.hxx b/src/MEDWrapper/Base/MED_Algorithm.hxx new file mode 100644 index 000000000..ee7ac3780 --- /dev/null +++ b/src/MEDWrapper/Base/MED_Algorithm.hxx @@ -0,0 +1,157 @@ +// 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 MED_Algorithm_HeaderFile +#define MED_Algorithm_HeaderFile + +#include "MED_WrapperBase.hxx" +#include "MED_Structures.hxx" + +#include + +namespace MED +{ + //--------------------------------------------------------------- + typedef std::map TGeom2ElemInfo; + typedef std::map TEntity2TGeom2ElemInfo; + + //! Get set of TElemInfo by its geometrical type and corresponding MED ENTITY + MEDWRAPPER_EXPORT + TEntity2TGeom2ElemInfo + GetEntity2TGeom2ElemInfo(const PWrapper& theWrapper, + const PMeshInfo& theMeshInfo, + const MED::TEntityInfo& theEntityInfo); + + + //--------------------------------------------------------------- + typedef std::set TFamilyInfoSet; + + //! Read set of MED FAMILIES for defined MED file + MEDWRAPPER_EXPORT + TFamilyInfoSet + GetFamilyInfoSet(const PWrapper& theWrapper, + const PMeshInfo& theMeshInfo); + + + //--------------------------------------------------------------- + typedef boost::tuple TFamilyTSize; + + bool + operator<(const TFamilyTSize& theLeft, const TFamilyTSize& theRight); + typedef std::set TFamilyTSizeSet; + + + //--------------------------------------------------------------- + typedef std::map TEntity2FamilySet; + + //! Split set of MED FAMILIES by corresponding MED ENTITY + MEDWRAPPER_EXPORT + TEntity2FamilySet + GetEntity2FamilySet(const PWrapper& theWrapper, + const TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo, + const TFamilyInfoSet& theFamilyInfoSet); + + + //--------------------------------------------------------------- + typedef std::map TGroupInfo; + + //! Split the input set of MED FAMILIES by corresponding MED GROUPS + MEDWRAPPER_EXPORT + TGroupInfo + GetGroupInfo(const TFamilyInfoSet& theFamilyInfoSet); + + + //--------------------------------------------------------------- + typedef std::set TTimeStampInfoSet; + typedef std::map TFieldInfo2TimeStampInfoSet; + + //! Read set of MED TIMESTAMPS groupped by corresponding MED FIELDS + MEDWRAPPER_EXPORT + TFieldInfo2TimeStampInfoSet + GetFieldInfo2TimeStampInfoSet(const PWrapper& theWrapper, + const PMeshInfo& theMeshInfo, + const MED::TEntityInfo& theEntityInfo); + + + //--------------------------------------------------------------- + typedef std::map TEntite2TFieldInfo2TimeStampInfoSet; + + //! Split the input set of MED TIMESTAMPS by corresponding MED FIELDS and MED ENTITIES + MEDWRAPPER_EXPORT + TEntite2TFieldInfo2TimeStampInfoSet + GetEntite2TFieldInfo2TimeStampInfoSet(const TFieldInfo2TimeStampInfoSet& theFieldInfo2TimeStampInfoSet); + + + //--------------------------------------------------------------- + typedef std::map TKey2Gauss; + + //! Read set of MED GAUSS + MEDWRAPPER_EXPORT + TKey2Gauss + GetKey2Gauss(const PWrapper& theWrapper, + TErr* theErr = NULL, + EModeSwitch theMode = eFULL_INTERLACE); + + + //--------------------------------------------------------------- + //! Get MED PROFILE by its name + MEDWRAPPER_EXPORT + PProfileInfo + GetProfileInfo(const PWrapper& theWrapper, + const std::string& theProfileName, + TErr* theErr = NULL, + EModeProfil theMode = eCOMPACT); + + + //--------------------------------------------------------------- + typedef std::map TKey2Profile; + typedef boost::tuple TMKey2Profile; + + //! Read set of MED PROFILES + MEDWRAPPER_EXPORT + TMKey2Profile + GetMKey2Profile(const PWrapper& theWrapper, + TErr* theErr = NULL, + EModeProfil theMode = eCOMPACT); + + //--------------------------------------------------------------- + //! Get Entity for Grille by family id. + MEDWRAPPER_EXPORT + EEntiteMaillage + GetEntityByFamilyId(PGrilleInfo& theInfo, + TInt theId); + + typedef std::map TFamilyID2NbCells; + + //! Get Number of cells for theId family, for Grille + MEDWRAPPER_EXPORT + TFamilyID2NbCells + GetFamilyID2NbCells(PGrilleInfo& theInfo); + + //! Convert eNOEUD_ELEMENT to eMAILLE + MEDWRAPPER_EXPORT + EEntiteMaillage + ConvertEntity(const EEntiteMaillage& aEntity); + +} + +#endif diff --git a/src/MEDWrapper/Base/MED_Common.hxx b/src/MEDWrapper/Base/MED_Common.hxx new file mode 100644 index 000000000..4715f6c85 --- /dev/null +++ b/src/MEDWrapper/Base/MED_Common.hxx @@ -0,0 +1,186 @@ +// 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 MED_Common_HeaderFile +#define MED_Common_HeaderFile + +#include "MED_WrapperBase.hxx" + +#include +#include +#include + +#include + +#include + +#include "SALOMEconfig.h" + +#include "MED_Vector.hxx" +#include "MED_SharedPtr.hxx" +#include "MED_SliceArray.hxx" + +#ifdef WIN32 +#pragma warning(disable:4099) +#endif + +namespace MED{ + + enum EVersion {eVUnknown = -1, eV2_1, eV2_2}; + + typedef enum {eFAUX, eVRAI} EBooleen ; + typedef double TFloat; +#if defined(HAVE_F77INT64) + typedef long TInt; +#else + typedef int TInt; +#endif + typedef hid_t TIdt; + typedef herr_t TErr; + + typedef enum {eFULL_INTERLACE, eNO_INTERLACE} EModeSwitch; + + typedef enum {eFLOAT64=6, eINT=26} ETypeChamp; + + typedef enum {eNON_STRUCTURE, eSTRUCTURE} EMaillage; + + typedef enum {eCART, eCYL, eSPHER} ERepere; + + typedef enum {eNOD, eDESC} EConnectivite ; + + typedef enum {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203, + eQUAD4=204, eTRIA6=206, eTRIA7=207, eQUAD8=208, eQUAD9=209,eTETRA4=304, + ePYRA5=305, ePENTA6=306, eHEXA8=308, eOCTA12=312, eTETRA10=310, + ePYRA13=313, ePENTA15=315, eHEXA20=320, eHEXA27=327, + ePOLYGONE=400, ePOLYEDRE=500, eNONE=0, + eBALL=1101 /*no such a type in med.h, it's just a trick*/, + eAllGeoType=-1 } EGeometrieElement; + + typedef enum {eMAILLE, eFACE, eARETE, eNOEUD, eNOEUD_ELEMENT, eSTRUCT_ELEMENT} EEntiteMaillage; + + typedef enum {eNO_PFLMOD, eGLOBAL, eCOMPACT} EModeProfil; + + typedef enum {eGRILLE_CARTESIENNE, eGRILLE_POLAIRE, eGRILLE_STANDARD} EGrilleType; + + typedef enum {eCOOR, eCONN, eNOM, eNUM, eFAM, eCOOR_IND1, eCOOR_IND2, eCOOR_IND3} ETable; + + typedef TVector TFloatVector; + typedef TVector TStringVector; + typedef TVector TIntVector; + typedef std::set TStringSet; + + typedef std::map TGeom2Size; + typedef std::map TEntityInfo; + + typedef std::set TGeomSet; + typedef std::map TEntity2GeomSet; + + MEDWRAPPER_EXPORT + const TEntity2GeomSet& + GetEntity2GeomSet(); + + template + TInt MEDWRAPPER_EXPORT + GetDESCLength(); + + template + TInt MEDWRAPPER_EXPORT + GetIDENTLength(); + + template + TInt MEDWRAPPER_EXPORT + GetNOMLength(); + + template + TInt MEDWRAPPER_EXPORT + GetLNOMLength(); + + template + TInt MEDWRAPPER_EXPORT + GetPNOMLength(); + + template + void MEDWRAPPER_EXPORT + GetVersionRelease(TInt& majeur, TInt& mineur, TInt& release); + + template + MEDWRAPPER_EXPORT + TInt + GetNbConn(EGeometrieElement typmai, + EEntiteMaillage typent, + TInt mdim); + + MEDWRAPPER_EXPORT + TInt + GetNbNodes(EGeometrieElement typmai); + + struct TNameInfo; + typedef SharedPtr PNameInfo; + + struct TMeshInfo; + typedef SharedPtr PMeshInfo; + + struct TFamilyInfo; + typedef SharedPtr PFamilyInfo; + + struct TElemInfo; + typedef SharedPtr PElemInfo; + + struct TNodeInfo; + typedef SharedPtr PNodeInfo; + + struct TPolygoneInfo; + typedef SharedPtr PPolygoneInfo; + + struct TPolyedreInfo; + typedef SharedPtr PPolyedreInfo; + + struct TCellInfo; + typedef SharedPtr PCellInfo; + + struct TBallInfo; + typedef SharedPtr PBallInfo; + + struct TFieldInfo; + typedef SharedPtr PFieldInfo; + + struct TTimeStampInfo; + typedef SharedPtr PTimeStampInfo; + + struct TProfileInfo; + typedef SharedPtr PProfileInfo; + + struct TGaussInfo; + typedef SharedPtr PGaussInfo; + + class TGrilleInfo; + typedef SharedPtr PGrilleInfo; + + struct TTimeStampValueBase; + typedef SharedPtr PTimeStampValueBase; + + struct TWrapper; + typedef SharedPtr PWrapper; +} + + +#endif diff --git a/src/MEDWrapper/Base/MED_CoordUtils.cxx b/src/MEDWrapper/Base/MED_CoordUtils.cxx new file mode 100644 index 000000000..21f9162b0 --- /dev/null +++ b/src/MEDWrapper/Base/MED_CoordUtils.cxx @@ -0,0 +1,160 @@ +// 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 "MED_CoordUtils.hxx" +#include "MED_Utilities.hxx" + +namespace MED +{ + + enum ECoordName{eX, eY, eZ, eNone}; + + template + TFloat + GetCoord(const TCCoordSlice& theCoordSlice) + { + return theCoordSlice[TCoordId]; + } + + template<> + TFloat + GetCoord(const TCCoordSlice& theCoordSlice) + { + return 0.0; + } + + TGetCoord + aXYZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord + aXYGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord + aYZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord + aXZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + + TGetCoord + aXGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord + aYGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord + aZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + + //--------------------------------------------------------------- + TCoordHelper + ::TCoordHelper(TGetCoord* theGetCoord): + myGetCoord(theGetCoord) + {} + + TFloat + TCoordHelper + ::GetCoord(TCCoordSlice& theCoordSlice, + TInt theCoordId) + { + return (*myGetCoord[theCoordId])(theCoordSlice); + } + + + //--------------------------------------------------------------- + PCoordHelper + GetCoordHelper(PNodeInfo theNodeInfo) + { + PCoordHelper aCoordHelper; + { + PMeshInfo aMeshInfo = theNodeInfo->GetMeshInfo(); + TInt aMeshDimension = aMeshInfo->GetDim(); + bool anIsDimPresent[3] = {false, false, false}; + for(int iDim = 0; iDim < aMeshDimension; iDim++){ + // PAL16857(SMESH not conform to the MED convention) -> + // 1D - always along X + // 2D - always in XOY plane + anIsDimPresent[iDim] = iDim < aMeshDimension; +// std::string aName = theNodeInfo->GetCoordName(iDim); +// if ( aName.size() > 1 ) // PAL12148, aName has size 8 or 16 +// aName = aName.substr(0,1); +// if(aName == "x" || aName == "X") +// anIsDimPresent[eX] = true; +// else if(aName == "y" || aName == "Y") +// anIsDimPresent[eY] = true; +// else if(aName == "z" || aName == "Z") +// anIsDimPresent[eZ] = true; + } + + switch(aMeshDimension){ + case 3: + aCoordHelper.reset(new TCoordHelper(aXYZGetCoord)); + break; + case 2: + if(anIsDimPresent[eY] && anIsDimPresent[eZ]) + aCoordHelper.reset(new TCoordHelper(aYZGetCoord)); + else if(anIsDimPresent[eX] && anIsDimPresent[eZ]) + aCoordHelper.reset(new TCoordHelper(aXZGetCoord)); + else + aCoordHelper.reset(new TCoordHelper(aXYGetCoord)); + break; + case 1: + if(anIsDimPresent[eY]) + aCoordHelper.reset(new TCoordHelper(aYGetCoord)); + else if(anIsDimPresent[eZ]) + aCoordHelper.reset(new TCoordHelper(aZGetCoord)); + else + aCoordHelper.reset(new TCoordHelper(aXGetCoord)); + break; + } + } + return aCoordHelper; + } +} diff --git a/src/MEDWrapper/Base/MED_CoordUtils.hxx b/src/MEDWrapper/Base/MED_CoordUtils.hxx new file mode 100644 index 000000000..17b09d761 --- /dev/null +++ b/src/MEDWrapper/Base/MED_CoordUtils.hxx @@ -0,0 +1,57 @@ +// 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 MED_CoordUtils_HeaderFile +#define MED_CoordUtils_HeaderFile + +#include "MED_WrapperBase.hxx" + +#include "MED_Structures.hxx" + +namespace MED +{ + typedef TFloat (*TGetCoord)(const TCCoordSlice& theCoordSlice); + + + //--------------------------------------------------------------- + class MEDWRAPPER_EXPORT TCoordHelper + { + TGetCoord* myGetCoord; + + public: + TCoordHelper(TGetCoord* theGetCoord); + + TFloat + GetCoord(TCCoordSlice& theCoordSlice, + TInt theCoordId); + }; + typedef SharedPtr PCoordHelper; + + + //--------------------------------------------------------------- + MEDWRAPPER_EXPORT + PCoordHelper + GetCoordHelper(PNodeInfo theNodeInfo); + +} + +#endif diff --git a/src/MEDWrapper/Base/MED_GaussDef.cxx b/src/MEDWrapper/Base/MED_GaussDef.cxx new file mode 100644 index 000000000..f89042e58 --- /dev/null +++ b/src/MEDWrapper/Base/MED_GaussDef.cxx @@ -0,0 +1,570 @@ +// Copyright (C) 2007-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 : MED_GaussDef.hxx +// Author : Edward AGAPOV (eap) +// +#include "MED_GaussDef.hxx" +#include "MED_Utilities.hxx" +#include "MED_GaussUtils.hxx" + +namespace MED +{ + using namespace std; + using namespace MED; + //--------------------------------------------------------------- + + void TGaussDef::add(const double x, const double weight) + { + if ( dim() != 1 ) + EXCEPTION( logic_error,"dim() != 1"); + if ( myWeights.capacity() == myWeights.size() ) + EXCEPTION( logic_error,"Extra gauss point"); + myCoords.push_back( x ); + myWeights.push_back( weight ); + } + void TGaussDef::add(const double x, const double y, const double weight) + { + if ( dim() != 2 ) + EXCEPTION( logic_error,"dim() != 2"); + if ( myWeights.capacity() == myWeights.size() ) + EXCEPTION( logic_error,"Extra gauss point"); + myCoords.push_back( x ); + myCoords.push_back( y ); + myWeights.push_back( weight ); + } + void TGaussDef::add(const double x, const double y, const double z, const double weight) + { + if ( dim() != 3 ) + EXCEPTION( logic_error,"dim() != 3"); + if ( myWeights.capacity() == myWeights.size() ) + EXCEPTION( logic_error,"Extra gauss point"); + myCoords.push_back( x ); + myCoords.push_back( y ); + myCoords.push_back( z ); + myWeights.push_back( weight ); + } + void TGaussDef::setRefCoords(const TShapeFun& aShapeFun) + { + myRefCoords.reserve( aShapeFun.myRefCoord.size() ); + myRefCoords.assign( aShapeFun.myRefCoord.begin(), + aShapeFun.myRefCoord.end() ); + } + + + //--------------------------------------------------------------- + /*! + * \brief Fill definition of gauss points family + */ + //--------------------------------------------------------------- + + TGaussDef::TGaussDef(const int geom, const int nbGauss, const int variant) + { + myType = geom; + myCoords .reserve( nbGauss * dim() ); + myWeights.reserve( nbGauss ); + + switch ( geom ) { + + case eSEG2: + case eSEG3: + if (geom == eSEG2) setRefCoords( TSeg2a() ); + else setRefCoords( TSeg3a() ); + switch ( nbGauss ) { + case 1: { + add( 0.0, 2.0 ); break; + } + case 2: { + const double a = 0.577350269189626; + add( a, 1.0 ); + add( -a, 1.0 ); break; + } + case 3: { + const double a = 0.774596669241; + const double P1 = 1./1.8; + const double P2 = 1./1.125; + add( -a, P1 ); + add( 0, P2 ); + add( a, P1 ); break; + } + case 4: { + const double a = 0.339981043584856, b = 0.861136311594053; + const double P1 = 0.652145154862546, P2 = 0.347854845137454 ; + add( a, P1 ); + add( -a, P1 ); + add( b, P2 ); + add( -b, P2 ); break; + } + default: + EXCEPTION( logic_error,"Invalid nb of gauss points for SEG"< alfa + const double a = (6 + sqrt(15.))/21.; + const double b = (6 - sqrt(15.))/21.; + const double P1 = (155 + sqrt(15.))/2400.; + const double P2 = (155 - sqrt(15.))/2400.; //___ + add( -d, 1/3., 1/3., c1*9/80. );//___ + add( -d, a, a, c1*P1 ); + add( -d, 1-2*a, a, c1*P1 ); + add( -d, a, 1-2*a, c1*P1 );//___ + add( -d, b, b, c1*P2 ); + add( -d, 1-2*b, b, c1*P2 ); + add( -d, b, 1-2*b, c1*P2 );//___ + add( 0., 1/3., 1/3., c2*9/80. );//___ + add( 0., a, a, c2*P1 ); + add( 0., 1-2*a, a, c2*P1 ); + add( 0., a, 1-2*a, c2*P1 );//___ + add( 0., b, b, c2*P2 ); + add( 0., 1-2*b, b, c2*P2 ); + add( 0., b, 1-2*b, c2*P2 );//___ + add( d, 1/3., 1/3., c1*9/80. );//___ + add( d, a, a, c1*P1 ); + add( d, 1-2*a, a, c1*P1 ); + add( d, a, 1-2*a, c1*P1 );//___ + add( d, b, b, c1*P2 ); + add( d, 1-2*b, b, c1*P2 ); + add( d, b, 1-2*b, c1*P2 );//___ + break; + } + default: + EXCEPTION( logic_error,"Invalid nb of gauss points for PENTA: " < + +namespace MED +{ + class TShapeFun; + typedef std::vector TDoubleVector; + /*! + * \brief Description of family of integration points + */ + struct TGaussDef + { + int myType; //!< element geometry (EGeometrieElement or med_geometrie_element) + TDoubleVector myRefCoords; //!< description of reference points + TDoubleVector myCoords; //!< coordinates of Gauss points + TDoubleVector myWeights; //!< weights, len(weights)== + + /*! + * \brief Creates definition of gauss points family + * \param geomType - element geometry (EGeometrieElement or med_geometrie_element) + * \param nbPoints - nb gauss point + * \param variant - [1-3] to choose the variant of definition + * + * Throws in case of invalid parameters + * variant == 1 refers to "Fonctions de forme et points d'integration + * des elements finis" v7.4 by J. PELLET, X. DESROCHES, 15/09/05 + * variant == 2 refers to the same doc v6.4 by J.P. LEFEBVRE, X. DESROCHES, 03/07/03 + * variant == 3 refers to the same doc v6.4, second variant for 2D elements + */ + MEDWRAPPER_EXPORT TGaussDef(const int geomType, const int nbPoints, const int variant=1); + + MEDWRAPPER_EXPORT int dim() const { return myType/100; } + MEDWRAPPER_EXPORT int nbPoints() const { return myWeights.capacity(); } + + private: + void add(const double x, const double weight); + void add(const double x, const double y, const double weight); + void add(const double x, const double y, const double z, const double weight); + void setRefCoords(const TShapeFun& aShapeFun); + }; +} + +#endif diff --git a/src/MEDWrapper/Base/MED_GaussUtils.cxx b/src/MEDWrapper/Base/MED_GaussUtils.cxx new file mode 100644 index 000000000..9ae82dfb3 --- /dev/null +++ b/src/MEDWrapper/Base/MED_GaussUtils.cxx @@ -0,0 +1,2173 @@ +// 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 "MED_GaussUtils.hxx" +#include "MED_Utilities.hxx" + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +static int MYVALUEDEBUG = 0; +#else +// static int MYDEBUG = 0; +// static int MYVALUEDEBUG = 0; +#endif + +//#define _DEBUG_REF_COORDS_ + +namespace MED +{ + //--------------------------------------------------------------- + TGaussCoord + ::TGaussCoord(): + TModeSwitchInfo(eFULL_INTERLACE), + myNbElem(0), + myNbGauss(0), + myDim(0), + myGaussStep(0) + { + } + + void + TGaussCoord + ::Init(TInt theNbElem, + TInt theNbGauss, + TInt theDim, + EModeSwitch theMode) + { + myModeSwitch = theMode; + + myNbElem = theNbElem; + myNbGauss = theNbGauss; + myDim = theDim; + + myGaussStep = myNbGauss*myDim; + + myGaussCoord.resize(theNbElem*myGaussStep); + } + + + TInt + TGaussCoord + ::GetNbElem() const + { + return myNbElem; + } + + TInt + TGaussCoord + ::GetNbGauss() const + { + return myNbGauss; + } + + TInt + TGaussCoord + ::GetDim() const + { + return myDim; + } + + unsigned char* + TGaussCoord + ::GetValuePtr() + { + return (unsigned char*)&(myGaussCoord[0]); + } + + + TCCoordSliceArr + TGaussCoord + ::GetCoordSliceArr(TInt theElemId) const + { + TCCoordSliceArr aCoordSliceArr(myNbGauss); + if(GetModeSwitch() == eFULL_INTERLACE){ + TInt anId = theElemId*myGaussStep; + for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){ + aCoordSliceArr[anGaussId] = + TCCoordSlice(myGaussCoord,std::slice(anId,myDim,1)); + anId += myDim; + } + } + else{ + for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){ + aCoordSliceArr[anGaussId] = + TCCoordSlice(myGaussCoord,std::slice(theElemId,myDim,myGaussStep)); + } + } + return aCoordSliceArr; + } + + + TCoordSliceArr + TGaussCoord + ::GetCoordSliceArr(TInt theElemId) + { + TCoordSliceArr aCoordSliceArr(myNbGauss); + if(GetModeSwitch() == eFULL_INTERLACE){ + TInt anId = theElemId*myGaussStep; + for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){ + aCoordSliceArr[anGaussId] = + TCoordSlice(myGaussCoord,std::slice(anId,myDim,1)); + anId += myDim; + } + } + else{ + for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){ + aCoordSliceArr[anGaussId] = + TCoordSlice(myGaussCoord,std::slice(theElemId,myDim,myGaussStep)); + } + } + return aCoordSliceArr; + } + + + //--------------------------------------------------------------- + inline + bool + IsEqual(TFloat theLeft, TFloat theRight) + { + static TFloat EPS = 1.0E-3; + if(fabs(theLeft) + fabs(theRight) > EPS) + return fabs(theLeft-theRight)/(fabs(theLeft)+fabs(theRight)) < EPS; + return true; + } + + + //--------------------------------------------------------------- + class TShapeFun::TFun + { + TFloatVector myFun; + TInt myNbRef; + + public: + + void + Init(TInt theNbGauss, + TInt theNbRef) + { + myFun.resize(theNbGauss*theNbRef); + myNbRef = theNbRef; + } + + TCFloatVecSlice + GetFunSlice(TInt theGaussId) const + { + return TCFloatVecSlice(myFun,std::slice(theGaussId*myNbRef,myNbRef,1)); + } + + TFloatVecSlice + GetFunSlice(TInt theGaussId) + { + return TFloatVecSlice(myFun,std::slice(theGaussId*myNbRef,myNbRef,1)); + } + }; + + //--------------------------------------------------------------- + + TShapeFun::TShapeFun(TInt theDim, TInt theNbRef): + myRefCoord(theNbRef*theDim), + myDim(theDim), + myNbRef(theNbRef) + {} + + TCCoordSlice + TShapeFun::GetCoord(TInt theRefId) const + { + return TCCoordSlice(myRefCoord,std::slice(theRefId*myDim,myDim,1)); + } + + TCoordSlice + TShapeFun::GetCoord(TInt theRefId) + { + return TCoordSlice(myRefCoord,std::slice(theRefId*myDim,myDim,1)); + } + + void + TShapeFun::GetFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const + { + TInt aNbRef = theRef.size(); + TInt aNbGauss = theGauss.size(); + theFun.Init(aNbGauss,aNbRef); + } + + bool + TShapeFun::IsSatisfy(const TCCoordSliceArr& theRefCoord) const + { + TInt aNbRef = theRefCoord.size(); + TInt aNbRef2 = GetNbRef(); + INITMSG(MYDEBUG,"TShapeFun::IsSatisfy "<< + "- aNbRef("<GetDim(); + TInt aNbGauss = theGauss.size(); + + bool anIsSubMesh = !theElemNum.empty(); + TInt aNbElem; + if(anIsSubMesh) + aNbElem = theElemNum.size(); + else + aNbElem = theCellInfo.GetNbElem(); + + theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode); + + TFun aFun; + InitFun(theRef,theGauss,aFun); + TInt aConnDim = theCellInfo.GetConnDim(); + + INITMSG(MYDEBUG,"aDim = "<GetDim(); + static TInt aNbGauss = 1; + + bool anIsSubMesh = !theElemNum.empty(); + TInt aNbElem; + if(anIsSubMesh) + aNbElem = theElemNum.size(); + else + aNbElem = theCellInfo.GetNbElem(); + + theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode); + + TInt aConnDim = theCellInfo.GetConnDim(); + + INITMSGA(MYDEBUG,0, + "- aDim = "<GetDim(); + static TInt aNbGauss = 1; + + bool anIsSubMesh = !theElemNum.empty(); + TInt aNbElem; + if(anIsSubMesh) + aNbElem = theElemNum.size(); + else + aNbElem = thePolygoneInfo.GetNbElem(); + + theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode); + + INITMSGA(MYDEBUG,0, + "- aDim = "<GetDim(); + static TInt aNbGauss = 1; + + bool anIsSubMesh = !theElemNum.empty(); + TInt aNbElem; + if(anIsSubMesh) + aNbElem = theElemNum.size(); + else + aNbElem = thePolyedreInfo.GetNbElem(); + + theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode); + + INITMSGA(MYDEBUG,0, + "- aDim = "< TCCoordSliceArr; + typedef TVector TCoordSliceArr; + + //! Define a helper class to handle Gauss Points coordinates + class MEDWRAPPER_EXPORT TGaussCoord: + virtual TModeSwitchInfo + { + TInt myNbElem; + TInt myNbGauss; + TInt myDim; + + TInt myGaussStep; + + TNodeCoord myGaussCoord; + + public: + + TGaussCoord(); + + //! To init the class + void + Init(TInt theNbElem, + TInt theNbGauss, + TInt theDim, + EModeSwitch theMode = eFULL_INTERLACE); + + TInt + GetNbElem() const; + + TInt + GetNbGauss() const; + + TInt + GetDim() const; + + unsigned char* + GetValuePtr(); + + //! Get slice of the coordinate that corresponds to defined cell (const version) + TCCoordSliceArr + GetCoordSliceArr(TInt theElemId) const; + + //! Get slice of the coordinate that corresponds to defined cell + TCoordSliceArr + GetCoordSliceArr(TInt theElemId); + }; + typedef SharedPtr PGaussCoord; + + + //--------------------------------------------------------------- + //! To calculate Gauss Points coordinates + MEDWRAPPER_EXPORT + bool + GetGaussCoord3D(const TGaussInfo& theGaussInfo, + const TCellInfo& theCellInfo, + const TNodeInfo& theNodeInfo, + TGaussCoord& theGaussCoord, + const TElemNum& theElemNum = TElemNum(), + EModeSwitch theMode = eFULL_INTERLACE); + + + //--------------------------------------------------------------- + //! To calculate Gauss Points coordinates for defined TCellInfo as its bary center + MEDWRAPPER_EXPORT + bool + GetBaryCenter(const TCellInfo& theCellInfo, + const TNodeInfo& theNodeInfo, + TGaussCoord& theGaussCoord, + const TElemNum& theElemNum = TElemNum(), + EModeSwitch theMode = eFULL_INTERLACE); + + //! To calculate Gauss Points coordinates for defined TPolygoneInfo as its bary center + MEDWRAPPER_EXPORT + bool + GetBaryCenter(const TPolygoneInfo& thePolygoneInfo, + const TNodeInfo& theNodeInfo, + TGaussCoord& theGaussCoord, + const TElemNum& theElemNum = TElemNum(), + EModeSwitch theMode = eFULL_INTERLACE); + + //! To calculate Gauss Points coordinates for defined TPolyedreInfo as its bary center + MEDWRAPPER_EXPORT + bool + GetBaryCenter(const TPolyedreInfo& thePolyedreInfo, + const TNodeInfo& theNodeInfo, + TGaussCoord& theGaussCoord, + const TElemNum& theElemNum = TElemNum(), + EModeSwitch theMode = eFULL_INTERLACE); + + //--------------------------------------------------------------- + //! Shape function definitions + //--------------------------------------------------------------- + struct MEDWRAPPER_EXPORT TShapeFun + { + class TFun; + + TFloatVector myRefCoord; + TInt myDim; + TInt myNbRef; + + TShapeFun(TInt theDim = 0, TInt theNbRef = 0); + + TInt GetNbRef() const { return myNbRef; } + + TCCoordSlice GetCoord(TInt theRefId) const; + + TCoordSlice GetCoord(TInt theRefId); + + void GetFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + virtual + void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const = 0; + virtual + bool IsSatisfy(const TCCoordSliceArr& theRefCoord) const; + + bool Eval(const TCellInfo& theCellInfo, + const TNodeInfo& theNodeInfo, + const TElemNum& theElemNum, + const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TGaussCoord& theGaussCoord, + EModeSwitch theMode); + }; + //--------------------------------------------------------------- + struct TSeg2a: TShapeFun { + TSeg2a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TSeg3a: TShapeFun { + TSeg3a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TTria3a: TShapeFun { + TTria3a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TTria6a: TShapeFun { + TTria6a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TTria3b: TShapeFun { + TTria3b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TTria6b: TShapeFun { + TTria6b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TQuad4a: TShapeFun { + TQuad4a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TQuad8a: TShapeFun { + TQuad8a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TQuad9a: TShapeFun { + TQuad9a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TQuad4b: TShapeFun { + TQuad4b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TQuad8b: TShapeFun { + TQuad8b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TQuad9b: TShapeFun { + TQuad9b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TTetra4a: TShapeFun { + TTetra4a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TTetra10a: TShapeFun { + TTetra10a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TTetra4b: TShapeFun { + TTetra4b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TTetra10b: TShapeFun { + TTetra10b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct THexa8a: TShapeFun { + THexa8a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct THexa20a: TShapeFun { + THexa20a(TInt theDim = 3, TInt theNbRef = 20); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct THexa27a: THexa20a { + THexa27a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct THexa8b: TShapeFun { + THexa8b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct THexa20b: TShapeFun { + THexa20b(TInt theDim = 3, TInt theNbRef = 20); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TPenta6a: TShapeFun { + TPenta6a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TPenta6b: TShapeFun { + TPenta6b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TPenta15a: TShapeFun { + TPenta15a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TPenta15b: TShapeFun { + TPenta15b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TPyra5a: TShapeFun { + TPyra5a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TPyra5b: TShapeFun { + TPyra5b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TPyra13a: TShapeFun { + TPyra13a(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + struct TPyra13b: TShapeFun { + TPyra13b(); + virtual void InitFun(const TCCoordSliceArr& theRef, + const TCCoordSliceArr& theGauss, + TFun& theFun) const; + }; + //--------------------------------------------------------------- + +} + +#endif diff --git a/src/MEDWrapper/Base/MED_SharedPtr.hxx b/src/MEDWrapper/Base/MED_SharedPtr.hxx new file mode 100644 index 000000000..d0f4746c6 --- /dev/null +++ b/src/MEDWrapper/Base/MED_SharedPtr.hxx @@ -0,0 +1,96 @@ +// 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 MED_SharedPtr_HeaderFile +#define MED_SharedPtr_HeaderFile + +#include + +namespace MED +{ + + //! To extend the boost::shared_ptr to support such features automatic dynamic cast + /*! + All entities of the MEDWrapper package are handled as pointer. + This class was introduced to provide correct and flexible memory management + for all of the MEDWrapper objects. + */ + template class SharedPtr: public boost::shared_ptr + { + public: + //! Default constructor + SharedPtr() {} + + //! Construct the class by any type of a pointer + template + explicit SharedPtr(Y * p): + boost::shared_ptr(p) + {} + + //! Construct the class by any specialisation of the class + template + SharedPtr(SharedPtr const & r): + boost::shared_ptr(r,boost::detail::dynamic_cast_tag()) + {} + + //! Copy-constructor + template + SharedPtr& + operator=(SharedPtr const & r) + { + boost::shared_ptr(r,boost::detail::dynamic_cast_tag()).swap(*this); + return *this; + } + + //! Introduce a flexible way to reset the wrapped pointer + template + SharedPtr& + operator()(Y * p) // Y must be complete + { + return operator=(SharedPtr(p)); + } + + //! Introduce a flexible way to reset the wrapped pointer + template + SharedPtr& + operator()(SharedPtr const & r) // Y must be complete + { + return operator=(SharedPtr(r)); + } + + //! To provide a flexible way to use reference to the wrapped pointer (const version) + operator const T& () const + { + return *(this->get()); + } + + //! To provide a flexible way to use reference to the wrapped pointer + operator T& () + { + return *(this->get()); + } + }; + +} + + +#endif diff --git a/src/MEDWrapper/Base/MED_SliceArray.hxx b/src/MEDWrapper/Base/MED_SliceArray.hxx new file mode 100644 index 000000000..c41951c75 --- /dev/null +++ b/src/MEDWrapper/Base/MED_SliceArray.hxx @@ -0,0 +1,186 @@ +// 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 MED_SliceArray_HeaderFile +#define MED_SliceArray_HeaderFile + +#ifdef WIN32 // for correctly compiling "valarray" in modules, which are includes this file + #undef max + #undef min +#endif + +#include +#include + +//#if defined(_DEBUG_) +# define MED_TCSLICE_CHECK_RANGE +//#endif + +namespace MED +{ + //--------------------------------------------------------------- + //! This class intends to provide an uniform way to handle multy-dimention data (const version) + /*! + It just contains pointer to real sequence and implement proper calcultion of its indexes. + This class deal with constant pointer to the sources data and provide const method to + read the them (data). + */ + template + class TCSlice + { + const TValueType* myCValuePtr; //!< Reference to source multy-dimension data + size_t mySourceSize; //!< Size of the source multy-dimension data + std::slice mySlice; //!< Defines algorithm of index calculation + + protected: + void + check_id(size_t theId) const + { + long int anId = -1; + if(theId < mySlice.size()){ + anId = mySlice.start() + theId*mySlice.stride(); + if(anId < (long int)mySourceSize) + return; + } + throw std::out_of_range("TCSlice::check_id"); + } + + //! Calculate internal index to get proper element from the source multy-dimension data + size_t + calculate_id(size_t theId) const + { + return mySlice.start() + theId*mySlice.stride(); + } + + size_t + get_id(size_t theId) const + { +#ifdef MED_TCSLICE_CHECK_RANGE + check_id(theId); +#endif + return calculate_id(theId); + } + + size_t + get_id_at(size_t theId) const + { + check_id(theId); + return calculate_id(theId); + } + + public: + typedef TValueType value_type; + + //! Construct the class from bare pointer + TCSlice(const value_type* theValuePtr, + size_t theSourceSize, + const std::slice& theSlice): + myCValuePtr(theValuePtr), + mySourceSize(theSourceSize), + mySlice(theSlice) + {} + + //! Construct the class from corresponding container + TCSlice(const TVector& theContainer, + const std::slice& theSlice): + myCValuePtr(&theContainer[0]), + mySourceSize(theContainer.size()), + mySlice(theSlice) + {} + + //! Default constructor (dangerous) + TCSlice(): + myCValuePtr(NULL) + {} + + //! Get element by its number (const version) + const value_type& + operator[](size_t theId) const + { + return *(myCValuePtr + get_id(theId)); + } + + const value_type& + at(size_t theId) const + { + return *(myCValuePtr + get_id_at(theId)); + } + + //! Get range of the order numbers + size_t + size() const + { + return mySlice.size(); + } + }; + + + //--------------------------------------------------------------- + //! This class extend TCSlice functionality for non-constant case + template + class TSlice: public TCSlice + { + TValueType* myValuePtr; + + public: + typedef TValueType value_type; + typedef TCSlice TSupperClass; + + //! Construct the class from bare pointer + TSlice(value_type* theValuePtr, + size_t theSourceSize, + const std::slice& theSlice): + TSupperClass(theValuePtr, theSourceSize, theSlice), + myValuePtr(theValuePtr) + {} + + //! Construct the class from corresponding container + TSlice(TVector& theContainer, + const std::slice& theSlice): + TSupperClass(theContainer, theSlice), + myValuePtr(&theContainer[0]) + {} + + //! Default constructor (dangerous) + TSlice(): + myValuePtr(NULL) + {} + + //! Get element by its number + value_type& + operator[](size_t theId) + { + return *(myValuePtr + this->get_id(theId)); + } + + value_type& + at(size_t theId) + { + return *(myValuePtr + this->get_id_at(theId)); + } + }; + +} + +#undef MED_TCSLICE_CHECK_RANGE + +#endif diff --git a/src/MEDWrapper/Base/MED_Structures.cxx b/src/MEDWrapper/Base/MED_Structures.cxx new file mode 100644 index 000000000..e9059ad93 --- /dev/null +++ b/src/MEDWrapper/Base/MED_Structures.cxx @@ -0,0 +1,865 @@ +// 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 +// +// File : MED_Structure.cxx +// Author : Eugeny NIKOLAEV +// +#include "MED_Structures.hxx" +#include "MED_Utilities.hxx" + +#include + +using namespace MED; + +namespace MED +{ + TInt + GetNbNodes(EGeometrieElement typmai) + { + return typmai%100; + } + + std::string + GetString(TInt theId, + TInt theStep, + const TString& theString) + { + const char* aPos = &theString[theId*theStep]; + TInt aSize = std::min(TInt(strlen(aPos)),theStep); + return std::string(aPos,aSize); + } + + void + SetString(TInt theId, + TInt theStep, + TString& theString, + const std::string& theValue) + { + TInt aSize = std::min(TInt(theValue.size()+1),theStep); + char* aPos = &theString[theId*theStep]; + strncpy(aPos,theValue.c_str(),aSize); + } + + void + SetString(TInt theId, + TInt theStep, + TString& theString, + const TString& theValue) + { + TInt aSize = std::min(TInt(theValue.size()+1),theStep); + char* aPos = &theString[theId*theStep]; + const char* aValue = &theValue[0]; + strncpy(aPos,aValue,aSize); + } + + TInt + GetDimGaussCoord(EGeometrieElement theGeom) + { + return theGeom/100; + } + + TInt + GetNbRefCoord(EGeometrieElement theGeom) + { + return (theGeom%100); + } + + //--------------------------------------------------------------- + PFloatTimeStampValue + CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue) + { + return theTimeStampValue; + } + + PIntTimeStampValue + CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue) + { + return theTimeStampValue; + } +} + +//--------------------------------------------------------------- +TInt +TFamilyInfo +::GetAttrId(TInt theId) const +{ + return myAttrId[theId]; +} + +TInt +TFamilyInfo +::GetAttrVal(TInt theId) const +{ + return myAttrVal[theId]; +} + +void +TFamilyInfo +::SetAttrId(TInt theId,TInt theVal) +{ + myAttrId[theId] = theVal; +} + +void +TFamilyInfo +::SetAttrVal(TInt theId,TInt theVal) +{ + myAttrVal[theId] = theVal; +} + +//--------------------------------------------------------------- +TInt +TElemInfo +::GetFamNum(TInt theId) const +{ + return (*myFamNum)[theId]; +} + +void +TElemInfo +::SetFamNum(TInt theId, TInt theVal) +{ + (*myFamNum)[theId] = theVal; + myIsFamNum = eVRAI; +} + +TInt +TElemInfo +::GetElemNum(TInt theId) const +{ + return (*myElemNum)[theId]; +} + +void +TElemInfo +::SetElemNum(TInt theId, TInt theVal) +{ + (*myElemNum)[theId] = theVal; +} + +//--------------------------------------------------------------- +TCCoordSlice +TNodeInfo +::GetCoordSlice(TInt theId) const +{ + TInt aDim = myMeshInfo->GetSpaceDim(); + if(GetModeSwitch() == eFULL_INTERLACE) + return TCCoordSlice(*myCoord, std::slice(theId*aDim, aDim, 1)); + else + return TCCoordSlice(*myCoord, std::slice(theId, aDim, aDim)); +} + +TCoordSlice +TNodeInfo +::GetCoordSlice(TInt theId) +{ + TInt aDim = myMeshInfo->GetSpaceDim(); + if(GetModeSwitch() == eFULL_INTERLACE) + return TCoordSlice(*myCoord, std::slice(theId*aDim,aDim,1)); + else + return TCoordSlice(*myCoord, std::slice(theId,aDim,aDim)); +} + +//--------------------------------------------------------------- +TCConnSlice +TCellInfo +::GetConnSlice(TInt theElemId) const +{ + if(GetModeSwitch() == eFULL_INTERLACE) + return TCConnSlice(*myConn, std::slice(GetConnDim()*theElemId, GetNbNodes(myGeom), 1)); + else + return TCConnSlice(*myConn, std::slice(theElemId, GetNbNodes(myGeom), GetConnDim())); +} + +TConnSlice +TCellInfo +::GetConnSlice(TInt theElemId) +{ + if(GetModeSwitch() == eFULL_INTERLACE) + return TConnSlice(*myConn, std::slice(GetConnDim()*theElemId, GetNbNodes(myGeom), 1)); + else + return TConnSlice(*myConn, std::slice(theElemId, GetNbNodes(myGeom), GetConnDim())); +} + + +//--------------------------------------------------------------- +TInt +TPolygoneInfo +::GetNbConn(TInt theElemId) const +{ + return (*myIndex)[theElemId + 1] - (*myIndex)[theElemId]; +} + +TCConnSlice +TPolygoneInfo +::GetConnSlice(TInt theElemId) const +{ + return TCConnSlice(*myConn, std::slice((*myIndex)[theElemId] - 1, GetNbConn(theElemId), 1)); +} + +TConnSlice +TPolygoneInfo +::GetConnSlice(TInt theElemId) +{ + return TConnSlice(*myConn, std::slice((*myIndex)[theElemId] - 1, GetNbConn(theElemId), 1)); +} + + +//--------------------------------------------------------------- +TInt +TPolyedreInfo +::GetNbFaces(TInt theElemId) const +{ + return (*myIndex)[theElemId+1] - (*myIndex)[theElemId]; +} + +TInt +TPolyedreInfo +::GetNbNodes(TInt theElemId) const +{ + TInt aNbNodes = 0; + TInt aNbFaces = GetNbFaces(theElemId); + TInt aStartFaceId = (*myIndex)[theElemId] - 1; + for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){ + TInt aCurrentId = (*myFaces)[aStartFaceId]; + TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId; + aNbNodes += aDiff; + } + return aNbNodes; +} + +TCConnSliceArr +TPolyedreInfo +::GetConnSliceArr(TInt theElemId) const +{ + TInt aNbFaces = GetNbFaces(theElemId); + TCConnSliceArr aConnSliceArr(aNbFaces); + TInt aStartFaceId = (*myIndex)[theElemId] - 1; + for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){ + TInt aCurrentId = (*myFaces)[aStartFaceId]; + TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId; + aConnSliceArr[aFaceId] = + TCConnSlice(*myConn, std::slice(aCurrentId - 1, aDiff, 1)); + } + return aConnSliceArr; +} + +TConnSliceArr +TPolyedreInfo +::GetConnSliceArr(TInt theElemId) +{ + TInt aNbFaces = GetNbFaces(theElemId); + TConnSliceArr aConnSliceArr(aNbFaces); + TInt aStartFaceId = (*myIndex)[theElemId] - 1; + for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){ + TInt aCurrentId = (*myFaces)[aStartFaceId]; + TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId; + aConnSliceArr[aFaceId] = + TConnSlice(*myConn, std::slice(aCurrentId - 1, aDiff, 1)); + } + return aConnSliceArr; +} + + +//--------------------------------------------------------------- +TMeshValueBase +::TMeshValueBase(): + myNbElem(0), + myNbComp(0), + myNbGauss(0), + myStep(0) +{} + +void +TMeshValueBase +::Allocate(TInt theNbElem, + TInt theNbGauss, + TInt theNbComp, + EModeSwitch theMode) +{ + myModeSwitch = theMode; + + myNbElem = theNbElem; + myNbGauss = theNbGauss; + myNbComp = theNbComp; + + myStep = theNbComp*theNbGauss; +} + +size_t +TMeshValueBase +::GetSize() const +{ + return myNbElem * myStep; +} + +size_t +TMeshValueBase +::GetNbVal() const +{ + return myNbElem * myNbGauss; +} + +size_t +TMeshValueBase +::GetNbGauss() const +{ + return myNbGauss; +} + +size_t +TMeshValueBase +::GetStep() const +{ + return myStep; +} + + +//--------------------------------------------------------------- +TInt +TProfileInfo +::GetElemNum(TInt theId) const +{ + return (*myElemNum)[theId]; +} + +void +TProfileInfo +::SetElemNum(TInt theId,TInt theVal) +{ + (*myElemNum)[theId] = theVal; +} + +//--------------------------------------------------------------- +bool +TGaussInfo::TLess +::operator()(const TKey& theLeft, const TKey& theRight) const +{ + EGeometrieElement aLGeom = boost::get<0>(theLeft); + EGeometrieElement aRGeom = boost::get<0>(theRight); + if(aLGeom != aRGeom) + return aLGeom < aRGeom; + + const std::string& aLStr = boost::get<1>(theLeft); + const std::string& aRStr = boost::get<1>(theRight); + return aLStr < aRStr; +} + +bool +TGaussInfo::TLess +::operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const +{ + if(!&theLeft) + return true; + + if(!&theRight) + return false; + + if(theLeft.myGeom != theRight.myGeom) + return theLeft.myGeom < theRight.myGeom; + + if(theLeft.myRefCoord != theRight.myRefCoord) + return theLeft.myRefCoord < theRight.myRefCoord; + + return theLeft.myGaussCoord < theRight.myGaussCoord; +} + +TCCoordSlice +TGaussInfo +::GetRefCoordSlice(TInt theId) const +{ + if(GetModeSwitch() == eFULL_INTERLACE) + return TCCoordSlice(myRefCoord,std::slice(theId*GetDim(),GetDim(),1)); + else + return TCCoordSlice(myRefCoord,std::slice(theId,GetDim(),GetDim())); +} + +TCoordSlice +TGaussInfo +::GetRefCoordSlice(TInt theId) +{ + if(GetModeSwitch() == eFULL_INTERLACE) + return TCoordSlice(myRefCoord,std::slice(theId*GetDim(),GetDim(),1)); + else + return TCoordSlice(myRefCoord,std::slice(theId,GetDim(),GetDim())); +} + +TCCoordSlice +TGaussInfo +::GetGaussCoordSlice(TInt theId) const +{ + if(GetModeSwitch() == eFULL_INTERLACE) + return TCCoordSlice(myGaussCoord,std::slice(theId*GetDim(),GetDim(),1)); + else + return TCCoordSlice(myGaussCoord,std::slice(theId,GetDim(),GetDim())); +} + +TCoordSlice +TGaussInfo +::GetGaussCoordSlice(TInt theId) +{ + if(GetModeSwitch() == eFULL_INTERLACE) + return TCoordSlice(myGaussCoord,std::slice(theId*GetDim(),GetNbGauss(),1)); + else + return TCoordSlice(myGaussCoord,std::slice(theId,GetNbGauss(),GetDim())); +} + + +//--------------------------------------------------------------- +TInt +TTimeStampInfo +::GetNbGauss(EGeometrieElement theGeom) const +{ + TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom); + if(anIter == myGeom2NbGauss.end()) + return 1;//EXCEPTION(runtime_error,"TTimeStampInfo::GetNbGauss - myGeom2NbGauss.find(theGeom) fails"); + + return anIter->second; +} + + +//--------------------------------------------------------------- +// TGrilleInfo structure methods +//--------------------------------------------------------------- +const EGrilleType& +TGrilleInfo +::GetGrilleType() const +{ + return myGrilleType; +} + +EGrilleType +TGrilleInfo +::GetGrilleType() +{ + return myGrilleType; +} + +void +TGrilleInfo +::SetGrilleType(EGrilleType theGrilleType) +{ + myGrilleType = theGrilleType; +} + +const +TIndexes& +TGrilleInfo +::GetMapOfIndexes() const +{ + return myIndixes; +} + +TIndexes& +TGrilleInfo +::GetMapOfIndexes() +{ + return myIndixes; +} + +const +TFloatVector& +TGrilleInfo +::GetIndexes(TInt theAxisNumber) const +{ + TIndexes::const_iterator aIter=myIndixes.find(theAxisNumber); + if(aIter==myIndixes.end()) + EXCEPTION(std::runtime_error, "const TGrilleInfo::GetIndexes - myIndixes.find(theAxisNumber); fails"); + return aIter->second; +} + +TFloatVector& +TGrilleInfo +::GetIndexes(TInt theAxisNumber) +{ + TIndexes::iterator aIter=myIndixes.find(theAxisNumber); + if(aIter==myIndixes.end()) + EXCEPTION(std::runtime_error, "TGrilleInfo::GetIndexes - myIndixes.find(theAxisNumber="<second; +} + +TInt +TGrilleInfo +::GetNbIndexes(TInt theAxisNumber) +{ + const TFloatVector& aVector=GetIndexes(theAxisNumber); + return aVector.size(); +} + +TInt +TGrilleInfo +::GetNbNodes() +{ + TInt nbNodes=0; + TInt aDim = myMeshInfo->GetDim(); + for(int i=0;iGetGrilleStructure()[i]; + else + nbNodes = nbNodes*this->GetGrilleStructure()[i]; + + return nbNodes; +} + +TInt +TGrilleInfo +::GetNbCells() +{ + TInt nbCells=0; + TInt aDim = myMeshInfo->GetDim(); + for(int i=0;iGetGrilleStructure()[i]-1; + else + nbCells = nbCells*(this->GetGrilleStructure()[i]-1); + return nbCells; +} + +TInt +TGrilleInfo +::GetNbSubCells() +{ + TInt nb=0; + TInt aDim = myMeshInfo->GetDim(); + switch (aDim) { + case 3: + nb = + (myGrilleStructure[0] ) * (myGrilleStructure[1]-1) * (myGrilleStructure[2]-1) + + (myGrilleStructure[0]-1) * (myGrilleStructure[1] ) * (myGrilleStructure[2]-1) + + (myGrilleStructure[0]-1) * (myGrilleStructure[1]-1) * (myGrilleStructure[2] ); + break; + case 2: + nb = + (myGrilleStructure[0] ) * (myGrilleStructure[1]-1) + + (myGrilleStructure[0]-1) * (myGrilleStructure[1] ); + break; + } + return nb; +} + +EGeometrieElement +TGrilleInfo +::GetGeom() +{ + TInt aDim = myMeshInfo->GetDim(); + switch(aDim){ + case 1: + return eSEG2; + case 2: + return eQUAD4; + case 3: + return eHEXA8; + default: + return eNONE; + } +} + +EGeometrieElement +TGrilleInfo +::GetSubGeom() +{ + TInt aDim = myMeshInfo->GetDim(); + switch(aDim){ + case 2: + return eSEG2; + case 3: + return eQUAD4; + } + return eNONE; +} + +EEntiteMaillage +TGrilleInfo +::GetEntity() +{ + return eMAILLE; +} + +EEntiteMaillage +TGrilleInfo +::GetSubEntity() +{ + TInt aDim = myMeshInfo->GetDim(); + switch(aDim){ + case 2: + return eARETE; + case 3: + return eFACE; + } + return EEntiteMaillage(-1); +} + +const +TIntVector& +TGrilleInfo +::GetGrilleStructure() const +{ + return myGrilleStructure; +} + +TIntVector +TGrilleInfo +::GetGrilleStructure() +{ + return myGrilleStructure; +} + +void +TGrilleInfo +::SetGrilleStructure(TInt theAxis,TInt theNb) +{ + if(theAxis >= 0 && theAxis <=2 && theNb >= 0) + myGrilleStructure[theAxis]=theNb; +} + +const +TNodeCoord& +TGrilleInfo +::GetNodeCoord() const +{ + return myCoord; +} + +TNodeCoord& +TGrilleInfo +::GetNodeCoord() +{ + return myCoord; +} + +TNodeCoord +TGrilleInfo +::GetCoord(TInt theId) +{ + TNodeCoord aCoord; + TInt aDim = myMeshInfo->GetDim(); + TInt aNbNodes = this->GetNbNodes(); + aCoord.resize(aDim); + + if(theId >= aNbNodes) + EXCEPTION(std::runtime_error, "TGrilleInfo::GetCoord - theId out of range"); + + if(myGrilleType == eGRILLE_STANDARD){ + switch(aDim){ + case 3: + aCoord[2] = myCoord[aDim*theId+2]; + case 2: + aCoord[1] = myCoord[aDim*theId+1]; + case 1:{ + aCoord[0] = myCoord[aDim*theId]; + break; + } + } + } else { + + TFloatVector aVecX = this->GetIndexes(0); + TInt nbIndxX = this->GetNbIndexes(0); + + switch(aDim){ + case 1:{ + aCoord[0] = aVecX[theId]; + break; + } + case 2:{ + TFloatVector aVecY = this->GetIndexes(1); + TInt i,j,k; + i = j = k = 0; + i = theId % nbIndxX; + j = theId / nbIndxX; + if(myGrilleType == eGRILLE_CARTESIENNE){ + aCoord[0] = aVecX[i]; + aCoord[1] = aVecY[j]; + } else { // eGRILLE_POLAIRE (cylindrical) + aCoord[0] = aVecX[i] * cos(aVecY[j]); + aCoord[1] = aVecX[i] * sin(aVecY[j]); + } + break; + } + case 3:{ + TFloatVector aVecY = this->GetIndexes(1); + TInt nbIndxY = this->GetNbIndexes(1); + TFloatVector aVecZ = this->GetIndexes(2); + TInt i,j,k; + i = j = k = 0; + + i = theId % nbIndxX; + j = (theId / nbIndxX) % nbIndxY; + k = theId / (nbIndxX*nbIndxY); + + if(myGrilleType == eGRILLE_CARTESIENNE){ + aCoord[0] = aVecX[i]; + aCoord[1] = aVecY[j]; + aCoord[2] = aVecZ[k]; + } else { // eGRILLE_POLAIRE (cylindrical) + aCoord[0] = aVecX[i] * cos(aVecY[j]); + aCoord[1] = aVecX[i] * sin(aVecY[j]); + aCoord[2] = aVecZ[k]; + } + + break; + } + } + } + + return aCoord; +} + +TIntVector +TGrilleInfo +::GetConn(TInt theId, const bool isSub) +{ + TIntVector anIndexes; + TInt aDim = myMeshInfo->GetDim(); + + TInt idx; + TInt iMin, jMin, kMin, iMax, jMax, kMax; + TInt loc[3]; + + loc[0] = loc[1] = loc[2] = 0; + iMin = iMax = jMin = jMax = kMin = kMax = 0; + + switch(aDim) { + case 3: + { + TInt nbX = this->GetGrilleStructure()[0]; + TInt nbY = this->GetGrilleStructure()[1]; + TInt nbZ = this->GetGrilleStructure()[2]; + TInt d01 = nbX*nbY, dX = 1, dY = 1, dZ = 1; + if ( isSub ) + { + if ( theId < nbX * (nbY-1) * (nbZ-1)) + { // face is normal to X axis + dX = 0; + } + else if ( theId < nbX * (nbY-1) * (nbZ-1) + (nbX-1) * nbY * (nbZ-1)) + { // face is normal to Y axis + theId -= nbX * (nbY-1) * (nbZ-1); + dY = 0; + } + else + { + theId -= nbX * (nbY-1) * (nbZ-1) + (nbX-1) * nbY * (nbZ-1); + dZ = 0; + } + } + //else + { + iMin = theId % (nbX - dX); + jMin = (theId / (nbX - dX)) % (nbY - dY); + kMin = theId / ((nbX - dX) * (nbY - dY)); + iMax = iMin+dX; + jMax = jMin+dY; + kMax = kMin+dZ; + } + for (loc[2]=kMin; loc[2]<=kMax; loc[2]++) + for (loc[1]=jMin; loc[1]<=jMax; loc[1]++) + for (loc[0]=iMin; loc[0]<=iMax; loc[0]++) + { + idx = loc[0] + loc[1]*nbX + loc[2]*d01; + anIndexes.push_back(idx); + } + break; + } + case 2: + { + TInt nbX = this->GetGrilleStructure()[0]; + TInt nbY = this->GetGrilleStructure()[1]; + TInt dX = 1, dY = 1; + if ( isSub ) + { + if ( theId < nbX * (nbY-1)) + { // edge is normal to X axis + dX = 0; + } + else + { + theId -= nbX * (nbY-1); + dY = 0; + } + } + iMin = theId % (nbX-dX); + jMin = theId / (nbX-dX); + iMax = iMin+dX; + jMax = jMin+dY; + for (loc[1]=jMin; loc[1]<=jMax; loc[1]++) + for (loc[0]=iMin; loc[0]<=iMax; loc[0]++) + { + idx = loc[0] + loc[1]*nbX; + anIndexes.push_back(idx); + } + break; + } + case 1: + { + iMin = theId; + for (loc[0]=iMin; loc[0]<=iMin+1; loc[0]++) + { + idx = loc[0]; + anIndexes.push_back(idx); + } + break; + } + } + + return anIndexes; +} + +TInt +TGrilleInfo +::GetFamNumNode(TInt theId) const +{ + return myFamNumNode[theId]; +} + +void +TGrilleInfo +::SetFamNumNode(TInt theId,TInt theVal) +{ + myFamNumNode[theId] = theVal; +} + +TInt +TGrilleInfo +::GetFamNum(TInt theId) const +{ + return myFamNum[theId]; +} + +void +TGrilleInfo +::SetFamNum(TInt theId,TInt theVal) +{ + myFamNum[theId] = theVal; +} + +TInt +TGrilleInfo +::GetFamSubNum(TInt theId) const +{ + return myFamSubNum[theId]; +} + +void +TGrilleInfo +::SetFamSubNum(TInt theId,TInt theVal) +{ + myFamSubNum[theId] = theVal; +} diff --git a/src/MEDWrapper/Base/MED_Structures.hxx b/src/MEDWrapper/Base/MED_Structures.hxx new file mode 100644 index 000000000..bcd361a67 --- /dev/null +++ b/src/MEDWrapper/Base/MED_Structures.hxx @@ -0,0 +1,1081 @@ +// 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 MED_Structures_HeaderFile +#define MED_Structures_HeaderFile + +#include "MED_Common.hxx" +#include "MED_Utilities.hxx" + +#ifdef WIN32 +#pragma warning(disable:4251) +#endif + +namespace MED +{ + + //--------------------------------------------------------------- + //! Defines a type for managing sequence of strings + typedef TVector TString; + typedef SharedPtr PString; + + //! Extract a substring from the sequence of the strings + MEDWRAPPER_EXPORT + std::string + GetString(TInt theId, TInt theStep, + const TString& theString); + + //! Set a substring in the sequence of the strings + MEDWRAPPER_EXPORT + void + SetString(TInt theId, TInt theStep, + TString& theString, + const std::string& theValue); + + //! Set a substring in the sequence of the strings + MEDWRAPPER_EXPORT + void + SetString(TInt theId, TInt theStep, + TString& theString, + const TString& theValue); + + //--------------------------------------------------------------- + //! Define a parent class for all MEDWrapper classes + struct MEDWRAPPER_EXPORT TBase + { + virtual ~TBase() {} + }; + + + //--------------------------------------------------------------- + //! Define a parent class for all named MED entities + struct MEDWRAPPER_EXPORT TNameInfo: virtual TBase + { + TString myName; //!< Keeps its name + virtual std::string GetName() const = 0; //!< Gets its name + virtual void SetName(const std::string& theValue) = 0; //!< Set a new name + virtual void SetName(const TString& theValue) = 0; //!< Set a new name + }; + + + //--------------------------------------------------------------- + //! Define a parent class for all MED entities that contains a sequence of numbers + /*! + It defines through corresponding enumeration (EModeSwitch) how the sequence + should be interpreted in C or Fortran mode (eFULL_INTERLACE or eNON_INTERLACE). + */ + struct MEDWRAPPER_EXPORT TModeSwitchInfo: virtual TBase + { + //! To construct instance of the class by default + TModeSwitchInfo(): + myModeSwitch(eFULL_INTERLACE) + {} + + //! To construct instance of the class + TModeSwitchInfo(EModeSwitch theModeSwitch): + myModeSwitch(theModeSwitch) + {} + + EModeSwitch myModeSwitch; //!< Keeps the + EModeSwitch GetModeSwitch() const { return myModeSwitch;} + }; + + + //--------------------------------------------------------------- + //! Define a base class which represents MED Mesh entity + struct MEDWRAPPER_EXPORT TMeshInfo: virtual TNameInfo + { + TInt myDim; //!< Dimension of the mesh (0, 1, 2 or 3) + TInt GetDim() const { return myDim;} //!< Gets dimension of the mesh + + TInt mySpaceDim; + TInt GetSpaceDim() const { return mySpaceDim; } + + EMaillage myType; //!< Type of the mesh + EMaillage GetType() const { return myType;} //!< Gets type of the mesh + + TString myDesc; //!< Description of the mesh + virtual std::string GetDesc() const = 0; //!< Get description for the mesh + virtual void SetDesc(const std::string& theValue) = 0; //!< Sets description for the mesh + + + }; + + + //--------------------------------------------------------------- + typedef TVector TIntVector; + typedef TSlice TIntVecSlice; + typedef TCSlice TCIntVecSlice; + + typedef TIntVector TFamAttr; + + //! Define a base class which represents MED Family entity + struct MEDWRAPPER_EXPORT TFamilyInfo: virtual TNameInfo + { + PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh + //! Get a reference to corresponding MED Mesh + const PMeshInfo& GetMeshInfo() const { return myMeshInfo;} + + TInt myId; //!< An unique index of the MED FAMILY + TInt GetId() const { return myId;} //!< Gets number of the MED FAMILY + void SetId(TInt theId) { myId = theId;} //! Define number of the MED FAMILY + + TInt myNbGroup; //!< Defines number MED Groups connected to + //! Gets number of MED GROUPS the MED FAMILY is bound to + TInt GetNbGroup() const { return myNbGroup;} + + //! Contains sequence of the names for the MED Groups connected to + TString myGroupNames; + //! Gets name of a bound MED GROUP by its number + virtual std::string GetGroupName(TInt theId) const = 0; + //! Sets name of the defined MED GROUP by its number + virtual void SetGroupName(TInt theId, const std::string& theValue) = 0; + + TInt myNbAttr; //!< Defines number of the MED Family attributes + //! Gets number of attached attributes for the MED FAMILY + TInt GetNbAttr() const { return myNbAttr;} + + //! Defines sequence of the indexes of the MED Family attributes + TFamAttr myAttrId; + //! Get MED FAMILY attribute by its number + TInt GetAttrId(TInt theId) const; + //! Set MED FAMILY attribute by its number + void SetAttrId(TInt theId, TInt theVal); + + //! Defines sequence of the values of the MED Family attributes + TFamAttr myAttrVal; + //! Get MED FAMILY attribute by its number + TInt GetAttrVal(TInt theId) const; + //! Set MED FAMILY attribute by its number + void SetAttrVal(TInt theId, TInt theVal); + + //! Defines sequence of the names of the MED Family attributes + TString myAttrDesc; + //! Get value of the MED FAMILY attribute by its number + virtual std::string GetAttrDesc(TInt theId) const = 0; + //! Set value of the MED FAMILY attribute by its number + virtual void SetAttrDesc(TInt theId, const std::string& theValue) = 0; + }; + + + //--------------------------------------------------------------- + typedef TIntVector TElemNum; + typedef SharedPtr PElemNum; + + //! Define a parent class for all MED entities that describes mesh entites such as nodes and cells. + struct MEDWRAPPER_EXPORT TElemInfo: virtual TBase + { + PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh + //! Get a reference to corresponding MED Mesh + const PMeshInfo& GetMeshInfo() const { return myMeshInfo;} + + TInt myNbElem; // TFloatVector; + typedef TSlice TFloatVecSlice; + typedef TCSlice TCFloatVecSlice; + + typedef TFloatVector TNodeCoord; + typedef SharedPtr PNodeCoord; + + typedef TFloatVecSlice TCoordSlice; + typedef TCFloatVecSlice TCCoordSlice; + + //! Define a base class which represents MED Nodes entity + struct MEDWRAPPER_EXPORT TNodeInfo: + virtual TElemInfo, + virtual TModeSwitchInfo + { + PNodeCoord myCoord; //!< Contains all nodal coordinates + + //! Gives coordinates for mesh node by its number (const version) + TCCoordSlice GetCoordSlice(TInt theId) const; + //! Gives coordinates for mesh node by its number + TCoordSlice GetCoordSlice(TInt theId); + + ERepere mySystem; //!< Defines, which coordinate system is used + //! Get which coordinate system is used for the node describing + ERepere GetSystem() const { return mySystem;} + //! Set coordinate system to be used for the node describing + void SetSystem(ERepere theSystem) { mySystem = theSystem;} + + TString myCoordNames; //!< Contains names for the coordinate dimensions + //! Get name of the coordinate dimension by its order number + virtual std::string GetCoordName(TInt theId) const = 0; + //! Set name of the coordinate dimension by its order number + virtual void SetCoordName(TInt theId, const std::string& theValue) = 0; + + TString myCoordUnits; //!< Contains units for the coordinate dimensions + //! Get name of unit for the coordinate dimension by its order number + virtual std::string GetCoordUnit(TInt theId) const = 0; + //! Set name of unit for the coordinate dimension by its order number + virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0; + }; + + + //--------------------------------------------------------------- + typedef TIntVecSlice TConnSlice; + typedef TCIntVecSlice TCConnSlice; + + //! Define a base class which represents MED Cells entity + struct MEDWRAPPER_EXPORT TCellInfo: + virtual TElemInfo, + virtual TModeSwitchInfo + { + EEntiteMaillage myEntity; //!< Defines the MED Entity where the mesh cells belongs to + //! Let known what MED ENTITY the cells belong to + EEntiteMaillage GetEntity() const { return myEntity;} + + EGeometrieElement myGeom; //!< Defines the MED Geometric type of the instance + //! Let known what MED geometrical type the cells belong to + EGeometrieElement GetGeom() const { return myGeom;} + + EConnectivite myConnMode; //!< Defines connectivity mode + //! Let known in what connectivity the cells are writen + EConnectivite GetConnMode() const { return myConnMode;} + + virtual TInt GetConnDim() const = 0; //!< Gives step in the connectivity sequence + + PElemNum myConn; //!< Defines sequence which describe connectivity for each of mesh cell + + //! Gives connectivities for mesh cell by its number (const version) + TCConnSlice GetConnSlice(TInt theElemId) const; + //! Gives connectivities for mesh cell by its number + TConnSlice GetConnSlice(TInt theElemId); + }; + + //--------------------------------------------------------------- + //! Define a base class which represents MED Polygon entity + struct MEDWRAPPER_EXPORT TPolygoneInfo: + virtual TElemInfo + { + //! Defines the MED Entity where the polygons belongs to + EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE + //! Let known what MED ENTITY the MED Polygons belong to + EEntiteMaillage GetEntity() const { return myEntity;} + + //! Defines the MED Geometric type of the instance + EGeometrieElement myGeom; // ePOLYGONE + //! Let known what MED geometrical type the MED Polygons belong to + EGeometrieElement GetGeom() const { return ePOLYGONE;} + + //! Defines connectivity mode + EConnectivite myConnMode; // eNOD|eDESC(eDESC not used) + //! Let known in what connectivity the cells are writen + EConnectivite GetConnMode() const { return myConnMode;} + + PElemNum myConn; //!< Table de connectivities + PElemNum myIndex; //!< Table de indexes + + //! Gives number of the connectivities for the defined polygon + TInt GetNbConn(TInt theElemId) const; + + //! Gives connectivities for polygon by its number (const version) + TCConnSlice GetConnSlice(TInt theElemId) const; + //! Gives connectivities for polygon by its number + TConnSlice GetConnSlice(TInt theElemId); + }; + + //--------------------------------------------------------------- + //! Define a class representing MED_BALL structure element. + // + // This could be a generic class for any structure element + // holding any number of contant and variable attributes + // but it's too hard to implement + // + struct MEDWRAPPER_EXPORT TBallInfo: + virtual TCellInfo + { + TFloatVector myDiameters; + }; + + //--------------------------------------------------------------- + typedef TVector TCConnSliceArr; + typedef TVector TConnSliceArr; + + //! Define a base class which represents MED Polyedre entity + struct MEDWRAPPER_EXPORT TPolyedreInfo: + virtual TElemInfo + { + //! Defines the MED Entity where the polyedres belongs to + EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE + //! Let known what MED ENTITY the MED Polyedres belong to + EEntiteMaillage GetEntity() const { return myEntity;} + + //! Defines the MED Geometric type of the instance + EGeometrieElement myGeom; // ePOLYEDRE + //! Let known what MED geometrical type the MED Polyedres belong to + EGeometrieElement GetGeom() const { return ePOLYEDRE;} + + //! Defines connectivity mode + EConnectivite myConnMode; // eNOD|eDESC(eDESC not used) + //! Let known in what connectivity the cells are writen + EConnectivite GetConnMode() const { return myConnMode;} + + PElemNum myConn; //!< Table de connectivities + PElemNum myFaces; //!< Table de faces indexes + PElemNum myIndex; //!< Table de indexes + + //! Gives number of the faces for the defined polyedre (const version) + TInt GetNbFaces(TInt theElemId) const; + //! Gives number of the nodes for the defined polyedre + TInt GetNbNodes(TInt theElemId) const; + + //! Gives sequence of the face connectivities for polyedre by its number (const version) + TCConnSliceArr GetConnSliceArr(TInt theElemId) const; + //! Gives sequence of the face connectivities for polyedre by its number + TConnSliceArr GetConnSliceArr(TInt theElemId); + }; + + //--------------------------------------------------------------- + //! Define a base class which represents MED Field entity + struct MEDWRAPPER_EXPORT TFieldInfo: + virtual TNameInfo + { + PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh + //! Get a reference to corresponding MED Mesh + const PMeshInfo& GetMeshInfo() const { return myMeshInfo;} + + ETypeChamp myType; //!< Defines type of the MED Field + //! Let known what type of the MED FIELD is used + ETypeChamp GetType() const { return myType;} + + TInt myNbComp; //!< Defines number of components stored in the field + //! Get number of components for the MED FIELD + TInt GetNbComp() const { return myNbComp;} + + EBooleen myIsLocal; //!< Defines if the MED Field is local + //! Let known is the MED FIELD is local or not + EBooleen GetIsLocal() const { return myIsLocal;} + + TInt myNbRef; //!< Defines number of refereces of the field + //! Let known number of references for the MED FIELD + TInt GetNbRef() const { return myNbRef;} + + TString myCompNames; //!< Contains names for each of MED Field components + //! Get name of the component by its order number + virtual std::string GetCompName(TInt theId) const = 0; + //! Set name for the component by its order number + virtual void SetCompName(TInt theId, const std::string& theValue) = 0; + + TString myUnitNames; //!< Contains units for each of MED Field components + //! Get unit of the component by its order number + virtual std::string GetUnitName(TInt theId) const = 0; + //! Set unit for the component by its order number + virtual void SetUnitName(TInt theId, const std::string& theValue) = 0; + + }; + + + //--------------------------------------------------------------- + //! Get dimension of the Gauss coordinates for the defined type of mesh cell + MEDWRAPPER_EXPORT + TInt + GetDimGaussCoord(EGeometrieElement theGeom); + + //! Get number of referenced nodes for the defined type of mesh cell + MEDWRAPPER_EXPORT + TInt + GetNbRefCoord(EGeometrieElement theGeom); + + typedef TFloatVector TWeight; + + //! The class represents MED Gauss entity + struct MEDWRAPPER_EXPORT TGaussInfo: + virtual TNameInfo, + virtual TModeSwitchInfo + { + typedef boost::tuple TKey; + typedef boost::tuple TInfo; + struct MEDWRAPPER_EXPORT TLess + { + bool + operator()(const TKey& theLeft, const TKey& theRight) const; + + bool + operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const; + }; + + //! Defines, which geometrical type the MED Gauss entity belongs to + EGeometrieElement myGeom; + //! Let known what MED geometrical type the MED GAUSS entity belong to + EGeometrieElement GetGeom() const { return myGeom;} + + //! Contains coordinates for the refereced nodes + TNodeCoord myRefCoord; + + //! Gives coordinates for the referenced node by its number + TCCoordSlice GetRefCoordSlice(TInt theId) const; + //! Gives coordinates for the referenced node by its number + TCoordSlice GetRefCoordSlice(TInt theId); + + //! Contains coordinates for the Gauss points + TNodeCoord myGaussCoord; + + //! Gives coordinates for the Gauss points by its number + TCCoordSlice GetGaussCoordSlice(TInt theId) const; + //! Gives coordinates for the Gauss points by its number + TCoordSlice GetGaussCoordSlice(TInt theId); + + //! Contains wheights for the Gauss points + TWeight myWeight; + + //! Gives number of the referenced nodes + TInt GetNbRef() const { return GetNbRefCoord(GetGeom());} + + //! Gives dimension of the referenced nodes + TInt GetDim() const { return GetDimGaussCoord(GetGeom());} + + //! Gives number of the Gauss Points + TInt GetNbGauss() const { return (TInt)(myGaussCoord.size()/GetDim());} + }; + + + //--------------------------------------------------------------- + typedef std::map TGeom2Gauss; + typedef std::map TGeom2NbGauss; + + //! Define a base class which represents MED TimeStamp + struct MEDWRAPPER_EXPORT TTimeStampInfo: + virtual TBase + { + PFieldInfo myFieldInfo; //!< A reference to correspondig MED Field + //! Get a reference to corresponding MED Field + const PFieldInfo& GetFieldInfo() const { return myFieldInfo;} + + //! Defines the MED Entity where the MED TimeStamp belongs to + EEntiteMaillage myEntity; + //! Let known to what MED Entity the MED TimeStamp belong to + EEntiteMaillage GetEntity() const { return myEntity;} + + //! Keeps map of number of cells per geometric type where the MED TimeStamp belongs to + TGeom2Size myGeom2Size; + //! Get map of number of cells per geometric type where the MED TimeStamp belongs to + const TGeom2Size& GetGeom2Size() const { return myGeom2Size;} + + TGeom2NbGauss myGeom2NbGauss; //!< Keeps number of the Gauss Points for the MED TimeStamp + TInt GetNbGauss(EGeometrieElement theGeom) const; //!< Gives number of the Gauss Points for the MED TimeStamp + + TInt myNumDt; //!< Keeps number in time for the MED TimeStamp + TInt GetNumDt() const { return myNumDt;} //!< Defines number in time for the MED TimeStamp + + TInt myNumOrd; //!< Keeps number for the MED TimeStamp + TInt GetNumOrd() const { return myNumOrd;} //!< Defines number for the MED TimeStamp + + TFloat myDt; //!< Keeps time for the MED TimeStamp + TFloat GetDt() const { return myDt;} //!< Defines time for the MED TimeStamp + + //! Keeps map of MED Gauss entityes per geometric type + TGeom2Gauss myGeom2Gauss; + //! Gets a map of MED Gauss entityes per geometric type + const TGeom2Gauss& GetGeom2Gauss() const { return myGeom2Gauss;} + + TString myUnitDt; //!< Defines unit for the time for the MED TimeStamp + //! Get unit of time for the MED TimeStamp + virtual std::string GetUnitDt() const = 0; + //! Set unit of time for the MED TimeStamp + virtual void SetUnitDt(const std::string& theValue) = 0; + }; + + + //--------------------------------------------------------------- + //! The class represents MED Profile entity + struct MEDWRAPPER_EXPORT TProfileInfo: + virtual TNameInfo + { + typedef std::string TKey; + typedef boost::tuple TInfo; + + EModeProfil myMode; //!< Keeps mode for the MED Profile + //! Let known what mode of MED Profile is used + EModeProfil GetMode() const { return myMode;} + //! Set mode for the MED Profile + void SetMode(EModeProfil theMode) { myMode = theMode;} + + PElemNum myElemNum; //!< Keeps sequence of cell by its number which belong to the profile + //! Get number of mesh elelemts by its order number + TInt GetElemNum(TInt theId) const; + //! Set number of mesh elelemts by its order number + void SetElemNum(TInt theId, TInt theVal); + + //! Let known is the MED Profile defined + bool IsPresent() const { return GetName() != "";} + + //! Let known size of the MED Profile + TInt GetSize() const { return (TInt)myElemNum->size();} + }; + + + //--------------------------------------------------------------- + //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp + struct MEDWRAPPER_EXPORT TMeshValueBase: + virtual TModeSwitchInfo + { + TInt myNbElem; + TInt myNbComp; + TInt myNbGauss; + TInt myStep; + + TMeshValueBase(); + + //! Initialize the class + void + Allocate(TInt theNbElem, + TInt theNbGauss, + TInt theNbComp, + EModeSwitch theMode = eFULL_INTERLACE); + + //! Returns size of the value container + size_t + GetSize() const; + + //! Returns MED interpetation of the value size + size_t + GetNbVal() const; + + //! Returns number of Gauss Points bounded with the value + size_t + GetNbGauss() const; + + //! Returns step inside of the data array + size_t + GetStep() const; + + //! Returns bare pointer on the internal value representation + virtual + unsigned char* + GetValuePtr() = 0; + }; + + //--------------------------------------------------------------- + //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp + template + struct TTMeshValue: + virtual TMeshValueBase + { + typedef TValueType TValue; + typedef typename TValueType::value_type TElement; + + typedef TSlice TValueSlice; + typedef TCSlice TCValueSlice; + + typedef TVector TCValueSliceArr; + typedef TVector TValueSliceArr; + + TValue myValue; + + //! Initialize the class + void + Allocate(TInt theNbElem, + TInt theNbGauss, + TInt theNbComp, + EModeSwitch theMode = eFULL_INTERLACE) + { + TMeshValueBase::Allocate(theNbElem, theNbGauss, theNbComp, theMode); + myValue.resize(theNbElem * this->GetStep()); + } + + //! Returns bare pointer on the internal value representation + virtual + unsigned char* + GetValuePtr() + { + return (unsigned char*)&myValue[0]; + } + + //! Returns bare pointer on the internal value representation + virtual + TElement* + GetPointer() + { + return &myValue[0]; + } + + //! Returns bare pointer on the internal value representation + virtual + const TElement* + GetPointer() const + { + return &myValue[0]; + } + + //! Iteration through Gauss Points by their components + TCValueSliceArr + GetGaussValueSliceArr(TInt theElemId) const + { + TCValueSliceArr aValueSliceArr(myNbGauss); + if(GetModeSwitch() == eFULL_INTERLACE){ + TInt anId = theElemId * myStep; + for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){ + aValueSliceArr[aGaussId] = + TCValueSlice(myValue, std::slice(anId, myNbComp, 1)); + anId += myNbComp; + } + } + else{ + for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){ + aValueSliceArr[aGaussId] = + TCValueSlice(myValue, std::slice(theElemId, myNbComp, myStep)); + } + } + return aValueSliceArr; + } + + //! Iteration through Gauss Points by their components + TValueSliceArr + GetGaussValueSliceArr(TInt theElemId) + { + TValueSliceArr aValueSliceArr(myNbGauss); + if(GetModeSwitch() == eFULL_INTERLACE){ + TInt anId = theElemId*myStep; + for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){ + aValueSliceArr[aGaussId] = + TValueSlice(myValue, std::slice(anId, myNbComp, 1)); + anId += myNbComp; + } + } + else{ + for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){ + aValueSliceArr[aGaussId] = + TValueSlice(myValue, std::slice(theElemId, myNbComp, myStep)); + } + } + return aValueSliceArr; + } + + //! Iteration through components by corresponding Gauss Points + TCValueSliceArr + GetCompValueSliceArr(TInt theElemId) const + { + TCValueSliceArr aValueSliceArr(myNbComp); + if(GetModeSwitch() == eFULL_INTERLACE){ + TInt anId = theElemId*myStep; + for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){ + aValueSliceArr[aCompId] = + TCValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp)); + anId += 1; + } + } + else{ + for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){ + aValueSliceArr[aCompId] = + TCValueSlice(myValue, std::slice(theElemId, myNbGauss, myStep)); + } + } + return aValueSliceArr; + } + + //! Iteration through components by corresponding Gauss Points + TValueSliceArr + GetCompValueSliceArr(TInt theElemId) + { + if(GetModeSwitch() == eFULL_INTERLACE){ + TValueSliceArr aValueSliceArr(myNbComp); + TInt anId = theElemId*myStep; + for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){ + aValueSliceArr[aCompId] = + TValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp)); + anId += 1; + } + return aValueSliceArr; + } + else{ + TValueSliceArr aValueSliceArr(myNbGauss); + for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){ + aValueSliceArr[aGaussId] = + TValueSlice(myValue,std::slice(theElemId, myNbComp, myStep)); + } + return aValueSliceArr; + } + } + }; + + typedef TTMeshValue TFloatMeshValue; + typedef TTMeshValue TIntMeshValue; + + //--------------------------------------------------------------- + // Backward compatibility declarations + typedef TFloatVector TValue; + typedef TSlice TValueSlice; + typedef TCSlice TCValueSlice; + + typedef TVector TCValueSliceArr; + typedef TVector TValueSliceArr; + + typedef TFloatMeshValue TMeshValue; + typedef std::map TGeom2Value; + + //--------------------------------------------------------------- + typedef std::map TGeom2Profile; + typedef std::set TGeom; + + //! The class is a base class for MED TimeStamp values holder + struct MEDWRAPPER_EXPORT TTimeStampValueBase: + virtual TModeSwitchInfo + { + //! A reference to correspondig MED TimeStamp + PTimeStampInfo myTimeStampInfo; + //!< Get a reference to correspondig MED TimeStamp + const PTimeStampInfo& GetTimeStampInfo() const { return myTimeStampInfo;} + + //! Keeps set of MED EGeometrieElement which contains values for the timestamp + TGeomSet myGeomSet; + const TGeomSet& GetGeomSet() const { return myGeomSet;} + + //! Keeps map of MED Profiles per geometric type + TGeom2Profile myGeom2Profile; + //! Gets a map of MED Profiles per geometric type + const TGeom2Profile& GetGeom2Profile() const { return myGeom2Profile;} + + //! Gets type of the champ + virtual + ETypeChamp + GetTypeChamp() const = 0; + + //! Allocates values for the given geometry + virtual + void + AllocateValue(EGeometrieElement theGeom, + TInt theNbElem, + TInt theNbGauss, + TInt theNbComp, + EModeSwitch theMode = eFULL_INTERLACE) = 0; + + virtual + size_t + GetValueSize(EGeometrieElement theGeom) const = 0; + + virtual + size_t + GetNbVal(EGeometrieElement theGeom) const = 0; + + virtual + size_t + GetNbGauss(EGeometrieElement theGeom) const = 0; + + virtual + unsigned char* + GetValuePtr(EGeometrieElement theGeom) = 0; + }; + + + //--------------------------------------------------------------- + //! The class implements a container for MED TimeStamp values + template + struct TTimeStampValue: + virtual TTimeStampValueBase + { + typedef TMeshValueType TTMeshValue; + typedef SharedPtr PTMeshValue; + typedef typename TMeshValueType::TElement TElement; + typedef std::map TTGeom2Value; + + ETypeChamp myTypeChamp; //second; + } + + //! Gets MED TimeStamp values for the given geometric type + PTMeshValue& + GetMeshValuePtr(EGeometrieElement theGeom) + { + myGeomSet.insert(theGeom); + if(myGeom2Value.find(theGeom) == myGeom2Value.end()){ + myGeom2Value[theGeom] = PTMeshValue(new TTMeshValue()); + return myGeom2Value[theGeom]; + } + return myGeom2Value[theGeom]; + } + + //! Gets MED TimeStamp values for the given geometric type (const version) + const TTMeshValue& + GetMeshValue(EGeometrieElement theGeom) const + { + return *(this->GetMeshValuePtr(theGeom)); + } + + //! Gets MED TimeStamp values for the given geometric type + TTMeshValue& + GetMeshValue(EGeometrieElement theGeom) + { + return *(this->GetMeshValuePtr(theGeom)); + } + }; + + + //--------------------------------------------------------------- + typedef TTimeStampValue TFloatTimeStampValue; + typedef SharedPtr PFloatTimeStampValue; + + PFloatTimeStampValue MEDWRAPPER_EXPORT + CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue); + + typedef TTimeStampValue TIntTimeStampValue; + typedef SharedPtr PIntTimeStampValue; + + PIntTimeStampValue MEDWRAPPER_EXPORT + CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue); + + + //--------------------------------------------------------------- + template + void + CopyTimeStampValue(SharedPtr > theTimeStampValueFrom, + SharedPtr > theTimeStampValueTo) + { + typedef TTimeStampValue TimeStampValueTypeFrom; + typedef TTimeStampValue TimeStampValueTypeTo; + typedef typename TMeshValueTypeTo::TElement TElementTo; + + typename TimeStampValueTypeFrom::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value; + typename TimeStampValueTypeFrom::TTGeom2Value::const_iterator anIter = aGeom2Value.begin(); + for(; anIter != aGeom2Value.end(); anIter++){ + const EGeometrieElement& aGeom = anIter->first; + const typename TimeStampValueTypeFrom::TTMeshValue& aMeshValue = *anIter->second; + typename TimeStampValueTypeTo::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom); + aMeshValue2.Allocate(aMeshValue.myNbElem, + aMeshValue.myNbGauss, + aMeshValue.myNbComp, + aMeshValue.myModeSwitch); + const typename TimeStampValueTypeFrom::TTMeshValue::TValue& aValue = aMeshValue.myValue; + typename TimeStampValueTypeTo::TTMeshValue::TValue& aValue2 = aMeshValue2.myValue; + TInt aSize = aValue.size(); + for(TInt anId = 0; anId < aSize; anId++) + aValue2[anId] = TElementTo(aValue[anId]); + } + } + + template + void + CopyTimeStampValue(SharedPtr > theTimeStampValueFrom, + SharedPtr > theTimeStampValueTo) + { + typedef TTimeStampValue TimeStampValueType; + typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value; + typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin(); + for(; anIter != aGeom2Value.end(); anIter++){ + const EGeometrieElement& aGeom = anIter->first; + const typename TimeStampValueType::TTMeshValue& aMeshValue = *anIter->second; + typename TimeStampValueType::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom); + aMeshValue2 = aMeshValue; + } + } + + //--------------------------------------------------------------- + inline + void + CopyTimeStampValueBase(const PTimeStampValueBase& theValueFrom, + const PTimeStampValueBase& theValueTo) + { + if(theValueFrom->GetTypeChamp() == theValueTo->GetTypeChamp()){ + if(theValueFrom->GetTypeChamp() == eFLOAT64) + CopyTimeStampValue(theValueFrom, theValueTo); + else if(theValueFrom->GetTypeChamp() == eINT) + CopyTimeStampValue(theValueFrom, theValueTo); + }else{ + if(theValueFrom->GetTypeChamp() == eFLOAT64 && theValueTo->GetTypeChamp() == eINT) + CopyTimeStampValue(theValueFrom, theValueTo); + else if(theValueFrom->GetTypeChamp() == eINT && theValueTo->GetTypeChamp() == eFLOAT64) + CopyTimeStampValue(theValueFrom, theValueTo); + } + } + + + //--------------------------------------------------------------- + // Backward compatibility declarations + typedef TFloatTimeStampValue TTimeStampVal; + typedef PFloatTimeStampValue PTimeStampVal; + + //--------------------------------------------------------------- + typedef std::map TIndexes; + typedef std::map TNames; + + //! Define a base class which represents MED Grille (structured mesh) + struct MEDWRAPPER_EXPORT TGrilleInfo: + virtual TModeSwitchInfo + { + + PMeshInfo myMeshInfo; + const PMeshInfo& GetMeshInfo() const { return myMeshInfo;} + + TNodeCoord myCoord; //!< Contains all nodal coordinates, now used only for eGRILLE_STANDARD + //! Gives coordinates for mesh nodes (const version) + const TNodeCoord& GetNodeCoord() const; + TNodeCoord& GetNodeCoord(); + //! Gives coordinates for mesh node by its number, array index from 0 + TNodeCoord GetCoord(TInt theId); + //! Gives ids of nodes for mesh cell or sub-cell by its number, array index from 0 + TIntVector GetConn(TInt theId, const bool isSub=false); + + EGrilleType myGrilleType; //!< Defines grille type (eGRILLE_CARTESIENNE,eGRILLE_POLAIRE,eGRILLE_STANDARD) + //!Gets grille type (const version) + const EGrilleType& GetGrilleType() const; + //!Gets grille type + EGrilleType GetGrilleType(); + //!Sets grille type + void SetGrilleType(EGrilleType theGrilleType); + + + + TString myCoordNames; //!< Contains names for the coordinate dimensions + //! Get name of the coordinate dimension by its order number + virtual std::string GetCoordName(TInt theId) const = 0 ; + //! Set name of the coordinate dimension by its order number + virtual void SetCoordName(TInt theId, const std::string& theValue) = 0; + + TString myCoordUnits; //!< Contains units for the coordinate dimensions + //! Get name of unit for the coordinate dimension by its order number + virtual std::string GetCoordUnit(TInt theId) const = 0; + //! Set name of unit for the coordinate dimension by its order number + virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0; + + + //! Map of index of axes and Table of indexes for certain axe, now used for eGRILLE_CARTESIENNE and eGRILLE_POLAIRE + TIndexes myIndixes; + //!Gets a map of Tables (const version) + const TIndexes& GetMapOfIndexes() const ; + //!Gets a map of Tables + TIndexes& GetMapOfIndexes(); + //!Gets a Table of indexes for certain axe(const version) + const TFloatVector& GetIndexes(TInt theAxisNumber) const; + //!Gets a Table of indexes for certain axe + TFloatVector& GetIndexes(TInt theAxisNumber); + //!Gets a number of indices per axe + TInt GetNbIndexes(TInt theAxisNumber); + + TInt GetNbNodes();//! Return count of all points + TInt GetNbCells();//! Return count of all cells + TInt GetNbSubCells();//! Return count of all entities of + EGeometrieElement GetGeom();//! Return geometry of cells (calculated from mesh dimension) + EGeometrieElement GetSubGeom();//! Return geometry of subcells (calculated from mesh dimension) + EEntiteMaillage GetEntity();//! Return entity (eMAILLE) + EEntiteMaillage GetSubEntity();//! Return sub entity + + /*! + *Vector of grille structure (Example: {3,4,5}, 3 nodes in X axe, 4 nodes in Y axe, ...) + */ + TIntVector myGrilleStructure; + //!Gets grille structure(const version) + const TIntVector& GetGrilleStructure() const; + //!Gets grille structure + TIntVector GetGrilleStructure(); + //!Sets the grille structure of theAxis axe to theNb. + void SetGrilleStructure(TInt theAxis,TInt theNb); + + /*! + *Defines sequence MED Family indexes for corresponding mesh entites + */ + TElemNum myFamNum; + //! Get number of a MED FAMILY by order number of the mesh element + TInt GetFamNum(TInt theId) const; + //! Set number of a MED FAMILY for the mesh element with the order number + void SetFamNum(TInt theId, TInt theVal); + + /*! + *Defines sequence MED Family indexes for sub entites + */ + TElemNum myFamSubNum; + //! Get number of a MED FAMILY by order number of sub element + TInt GetFamSubNum(TInt theId) const; + //! Set number of a MED FAMILY for theId-th sub element + void SetFamSubNum(TInt theId, TInt theVal); + + /*! + *Defines sequence MED Family indexes for corresponding mesh nodes + */ + TElemNum myFamNumNode; + //! Get number of a MED FAMILY by order number of the mesh node + TInt GetFamNumNode(TInt theId) const; + //! Set number of a MED FAMILY for the mesh node with the order number + void SetFamNumNode(TInt theId, TInt theVal); + + }; + + +} + +#endif diff --git a/src/MEDWrapper/Base/MED_TStructures.hxx b/src/MEDWrapper/Base/MED_TStructures.hxx new file mode 100644 index 000000000..dfbca909a --- /dev/null +++ b/src/MEDWrapper/Base/MED_TStructures.hxx @@ -0,0 +1,1216 @@ +// 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 MED_TStructures_HeaderFile +#define MED_TStructures_HeaderFile + +#include "MED_Structures.hxx" + +#ifdef WIN32 +#pragma warning(disable:4250) +#endif + +namespace MED +{ + //--------------------------------------------------------------- + //! To provide a common way to handle values of MEDWrapper types as native MED types + template + struct TValueHolder + { + TValue& myValue; + TRepresentation myRepresentation; + + TValueHolder(TValue& theValue): + myValue(theValue), + myRepresentation(TRepresentation(theValue)) + {} + + ~TValueHolder() + { + myValue = TValue(myRepresentation); + } + + TRepresentation* + operator& () + { + return &myRepresentation; + } + + operator TRepresentation () const + { + return myRepresentation; + } + + const TValue& + operator() () const + { + return myValue; + } + }; + + //! To customize TValueHolder common template definition for TVector + template + struct TValueHolder, TRepresentation> + { + typedef TVector TValue; + TValue& myValue; + TRepresentation* myRepresentation; + + TValueHolder(TValue& theValue): + myValue(theValue) + { + if(theValue.empty()) + myRepresentation = (TRepresentation*)NULL; + else + myRepresentation = (TRepresentation*)&theValue[0]; + } + + TRepresentation* + operator& () + { + return myRepresentation; + } + }; + + //--------------------------------------------------------------- + template + struct TTNameInfo: virtual TNameInfo + { + TTNameInfo(const std::string& theValue) + { + myName.resize(GetNOMLength()+1); + SetName(theValue); + } + + virtual + std::string + GetName() const + { + return GetString(0, GetNOMLength(), myName); + } + + virtual + void + SetName(const std::string& theValue) + { + SetString(0, GetNOMLength(), myName, theValue); + } + + virtual + void + SetName(const TString& theValue) + { + SetString(0, GetNOMLength(), myName, theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTMeshInfo: + virtual TMeshInfo, + virtual TTNameInfo + { + typedef TTNameInfo TNameInfoBase; + + TTMeshInfo(const PMeshInfo& theInfo): + TNameInfoBase(theInfo->GetName()) + { + myDim = theInfo->GetDim(); + mySpaceDim = theInfo->GetSpaceDim(); + myType = theInfo->GetType(); + + myDesc.resize(GetDESCLength()+1); + SetDesc(theInfo->GetDesc()); + } + + TTMeshInfo(TInt theDim, TInt theSpaceDim, + const std::string& theValue, + EMaillage theType, + const std::string& theDesc): + TNameInfoBase(theValue) + { + myDim = theDim; + mySpaceDim = theSpaceDim; + myType = theType; + + myDesc.resize(GetDESCLength()+1); + SetDesc(theDesc); + } + + virtual + std::string + GetDesc() const + { + return GetString(0, GetDESCLength(), myDesc); + } + + virtual + void + SetDesc(const std::string& theValue) + { + SetString(0, GetDESCLength(), myDesc, theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTFamilyInfo: + virtual TFamilyInfo, + virtual TTNameInfo + { + typedef TTNameInfo TNameInfoBase; + + TTFamilyInfo(const PMeshInfo& theMeshInfo, const PFamilyInfo& theInfo): + TNameInfoBase(theInfo->GetName()) + { + myMeshInfo = theMeshInfo; + + myId = theInfo->GetId(); + + myNbGroup = theInfo->GetNbGroup(); + myGroupNames.resize(myNbGroup*GetLNOMLength()+1); + if(myNbGroup){ + for(TInt anId = 0; anId < myNbGroup; anId++){ + SetGroupName(anId,theInfo->GetGroupName(anId)); + } + } + + myNbAttr = theInfo->GetNbAttr(); + myAttrId.resize(myNbAttr); + myAttrVal.resize(myNbAttr); + myAttrDesc.resize(myNbAttr*GetDESCLength()+1); + if(myNbAttr){ + for(TInt anId = 0; anId < myNbAttr; anId++){ + SetAttrDesc(anId,theInfo->GetAttrDesc(anId)); + myAttrVal[anId] = theInfo->GetAttrVal(anId); + myAttrId[anId] = theInfo->GetAttrId(anId); + } + } + } + + TTFamilyInfo(const PMeshInfo& theMeshInfo, + TInt theNbGroup, + TInt theNbAttr, + TInt theId, + const std::string& theValue): + TNameInfoBase(theValue) + { + myMeshInfo = theMeshInfo; + + myId = theId; + + myNbGroup = theNbGroup; + myGroupNames.resize(theNbGroup*GetLNOMLength()+1); + + myNbAttr = theNbAttr; + myAttrId.resize(theNbAttr); + myAttrVal.resize(theNbAttr); + myAttrDesc.resize(theNbAttr*GetDESCLength()+1); + } + + TTFamilyInfo(const PMeshInfo& theMeshInfo, + const std::string& theValue, + TInt theId, + const TStringSet& theGroupNames, + const TStringVector& theAttrDescs, + const TIntVector& theAttrIds, + const TIntVector& theAttrVals): + TNameInfoBase(theValue) + { + myMeshInfo = theMeshInfo; + + myId = theId; + + myNbGroup = (TInt)theGroupNames.size(); + myGroupNames.resize(myNbGroup*GetLNOMLength()+1); + if(myNbGroup){ + TStringSet::const_iterator anIter = theGroupNames.begin(); + for(TInt anId = 0; anIter != theGroupNames.end(); anIter++, anId++){ + const std::string& aVal = *anIter; + SetGroupName(anId,aVal); + } + } + + myNbAttr = (TInt)theAttrDescs.size(); + myAttrId.resize(myNbAttr); + myAttrVal.resize(myNbAttr); + myAttrDesc.resize(myNbAttr*GetDESCLength()+1); + if(myNbAttr){ + for(TInt anId = 0, anEnd = (TInt)theAttrDescs.size(); anId < anEnd; anId++){ + SetAttrDesc(anId,theAttrDescs[anId]); + myAttrVal[anId] = theAttrVals[anId]; + myAttrId[anId] = theAttrIds[anId]; + } + } + } + + virtual + std::string + GetGroupName(TInt theId) const + { + return GetString(theId, GetLNOMLength(), myGroupNames); + } + + virtual + void + SetGroupName(TInt theId, const std::string& theValue) + { + SetString(theId, GetLNOMLength(), myGroupNames, theValue); + } + + virtual + std::string + GetAttrDesc(TInt theId) const + { + return GetString(theId, GetDESCLength(), myAttrDesc); + } + + virtual + void + SetAttrDesc(TInt theId, const std::string& theValue) + { + SetString(theId, GetDESCLength(), myAttrDesc, theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTElemInfo: virtual TElemInfo + { + TTElemInfo(const PMeshInfo& theMeshInfo, const PElemInfo& theInfo) + { + myMeshInfo = theMeshInfo; + + myNbElem = theInfo->GetNbElem(); + myFamNum.reset(new TElemNum(myNbElem)); + myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum() + + myIsElemNum = theInfo->IsElemNum(); + if(theInfo->IsElemNum()) + myElemNum.reset(new TElemNum(myNbElem)); + else + myElemNum.reset(new TElemNum()); + + myIsElemNames = theInfo->IsElemNames(); + if(theInfo->IsElemNames()) + myElemNames.reset(new TString(myNbElem*GetPNOMLength() + 1)); + else + myElemNames.reset(new TString()); + + if(theInfo->GetNbElem()){ + for(TInt anId = 0; anId < myNbElem; anId++){ + SetFamNum(anId, theInfo->GetFamNum(anId)); + } + if(theInfo->IsElemNum() == eVRAI){ + for(TInt anId = 0; anId < myNbElem; anId++){ + SetElemNum(anId, theInfo->GetElemNum(anId)); + } + } + if(theInfo->IsElemNames() == eVRAI){ + for(TInt anId = 0; anId < myNbElem; anId++){ + SetElemName(anId,theInfo->GetElemName(anId)); + } + } + } + } + + TTElemInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EBooleen theIsElemNum, + EBooleen theIsElemNames) + { + myMeshInfo = theMeshInfo; + + myNbElem = theNbElem; + myFamNum.reset(new TElemNum(theNbElem)); + myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum() + + myIsElemNum = theIsElemNum; + if(theIsElemNum) + myElemNum.reset(new TElemNum(theNbElem)); + else + myElemNum.reset(new TElemNum()); + + myIsElemNames = theIsElemNames; + if(theIsElemNames) + myElemNames.reset(new TString(theNbElem*GetPNOMLength() + 1)); + else + myElemNames.reset(new TString()); + } + + TTElemInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames) + { + myMeshInfo = theMeshInfo; + + myNbElem = theNbElem; + myFamNum.reset(new TElemNum(theNbElem)); + myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum() + + myIsElemNum = theElemNums.size()? eVRAI: eFAUX; + if(myIsElemNum) + myElemNum.reset(new TElemNum(theNbElem)); + else + myElemNum.reset(new TElemNum()); + + myIsElemNames = theElemNames.size()? eVRAI: eFAUX; + if(myIsElemNames) + myElemNames.reset(new TString(theNbElem*GetPNOMLength() + 1)); + else + myElemNames.reset(new TString()); + + if(theNbElem){ + + if(theFamilyNums.size()) + *myFamNum = theFamilyNums; + + if(myIsElemNum) + *myElemNum = theElemNums; + + if(myIsElemNames){ + for(TInt anId = 0; anId < theNbElem; anId++){ + const std::string& aVal = theElemNames[anId]; + SetElemName(anId,aVal); + } + } + } + } + + virtual + std::string + GetElemName(TInt theId) const + { + return GetString(theId,GetPNOMLength(), *myElemNames); + } + + virtual + void + SetElemName(TInt theId, const std::string& theValue) + { + SetString(theId,GetPNOMLength(), *myElemNames, theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTNodeInfo: + virtual TNodeInfo, + virtual TTElemInfo + { + typedef TTElemInfo TElemInfoBase; + + TTNodeInfo(const PMeshInfo& theMeshInfo, const PNodeInfo& theInfo): + TNodeInfo(theInfo), + TElemInfoBase(theMeshInfo, theInfo) + { + myModeSwitch = theInfo->GetModeSwitch(); + + mySystem = theInfo->GetSystem(); + + myCoord.reset(new TNodeCoord(*theInfo->myCoord)); + + TInt aSpaceDim = theMeshInfo->GetSpaceDim(); + + myCoordNames.resize(aSpaceDim*GetPNOMLength()+1); + for(TInt anId = 0; anId < aSpaceDim; anId++) + SetCoordName(anId,theInfo->GetCoordName(anId)); + + myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1); + for(TInt anId = 0; anId < aSpaceDim; anId++) + SetCoordUnit(anId,theInfo->GetCoordUnit(anId)); + } + + TTNodeInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EModeSwitch theMode, + ERepere theSystem, + EBooleen theIsElemNum, + EBooleen theIsElemNames): + TModeSwitchInfo(theMode), + TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames) + { + mySystem = theSystem; + + myCoord.reset(new TNodeCoord(theNbElem * theMeshInfo->mySpaceDim)); + + myCoordUnits.resize(theMeshInfo->mySpaceDim*GetPNOMLength()+1); + + myCoordNames.resize(theMeshInfo->mySpaceDim*GetPNOMLength()+1); + } + + + TTNodeInfo(const PMeshInfo& theMeshInfo, + const TFloatVector& theNodeCoords, + EModeSwitch theMode, + ERepere theSystem, + const TStringVector& theCoordNames, + const TStringVector& theCoordUnits, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames): + TModeSwitchInfo(theMode), + TElemInfoBase(theMeshInfo, + (TInt)theNodeCoords.size()/theMeshInfo->GetDim(), + theFamilyNums, + theElemNums, + theElemNames) + { + mySystem = theSystem; + + myCoord.reset(new TNodeCoord(theNodeCoords)); + + TInt aSpaceDim = theMeshInfo->GetSpaceDim(); + + myCoordNames.resize(aSpaceDim*GetPNOMLength()+1); + if(!theCoordNames.empty()) + for(TInt anId = 0; anId < aSpaceDim; anId++) + SetCoordName(anId,theCoordNames[anId]); + + myCoordUnits.resize(aSpaceDim*GetPNOMLength() + 1); + if(!theCoordUnits.empty()) + for(TInt anId = 0; anId < aSpaceDim; anId++) + SetCoordUnit(anId, theCoordUnits[anId]); + } + + virtual + std::string + GetCoordName(TInt theId) const + { + return GetString(theId,GetPNOMLength(),myCoordNames); + } + + virtual + void + SetCoordName(TInt theId, const std::string& theValue) + { + SetString(theId,GetPNOMLength(),myCoordNames,theValue); + } + + virtual + std::string + GetCoordUnit(TInt theId) const + { + return GetString(theId,GetPNOMLength(),myCoordUnits); + } + + virtual + void + SetCoordUnit(TInt theId, const std::string& theValue) + { + SetString(theId,GetPNOMLength(),myCoordUnits,theValue); + } + }; + + //--------------------------------------------------------------- + template + struct TTPolygoneInfo: + virtual TPolygoneInfo, + virtual TTElemInfo + { + typedef TTElemInfo TElemInfoBase; + + TTPolygoneInfo(const PMeshInfo& theMeshInfo, const PPolygoneInfo& theInfo): + TElemInfoBase(theMeshInfo,theInfo) + { + myEntity = theInfo->GetEntity(); + myGeom = theInfo->GetGeom(); + + myIndex.reset(new TElemNum(*theInfo->myIndex)); + myConn.reset(new TElemNum(*theInfo->myConn)); + + myConnMode = theInfo->GetConnMode(); + } + + TTPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TInt theNbElem, + TInt theConnSize, + EConnectivite theConnMode, + EBooleen theIsElemNum, + EBooleen theIsElemNames): + TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames) + { + myEntity = theEntity; + myGeom = theGeom; + + myIndex.reset(new TElemNum(theNbElem + 1)); + myConn.reset(new TElemNum(theConnSize)); + + myConnMode = theConnMode; + } + + TTPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + const TIntVector& theIndexes, + const TIntVector& theConnectivities, + EConnectivite theConnMode, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames): + TElemInfoBase(theMeshInfo, + (TInt)theIndexes.size() - 1, + theFamilyNums, + theElemNums, + theElemNames) + { + myEntity = theEntity; + myGeom = theGeom; + + myIndex.reset(new TElemNum(theIndexes)); + myConn.reset(new TElemNum(theConnectivities)); + + myConnMode = theConnMode; + } + }; + + //--------------------------------------------------------------- + template + struct TTPolyedreInfo: + virtual TPolyedreInfo, + virtual TTElemInfo + { + typedef TTElemInfo TElemInfoBase; + + TTPolyedreInfo(const PMeshInfo& theMeshInfo, const PPolyedreInfo& theInfo): + TElemInfoBase(theMeshInfo,theInfo) + { + myEntity = theInfo->GetEntity(); + myGeom = theInfo->GetGeom(); + + myIndex.reset(new TElemNum(*theInfo->myIndex)); + myFaces.reset(new TElemNum(*theInfo->myFaces)); + myConn.reset(new TElemNum(*theInfo->myConn)); + + myConnMode = theInfo->GetConnMode(); + } + + TTPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TInt theNbElem, + TInt theNbFaces, + TInt theConnSize, + EConnectivite theConnMode, + EBooleen theIsElemNum, + EBooleen theIsElemNames): + TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames) + { + myEntity = theEntity; + myGeom = theGeom; + + myIndex.reset(new TElemNum(theNbElem + 1)); + myFaces.reset(new TElemNum(theNbFaces)); + myConn.reset(new TElemNum(theConnSize)); + + myConnMode = theConnMode; + } + + TTPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + const TIntVector& theIndexes, + const TIntVector& theFaces, + const TIntVector& theConnectivities, + EConnectivite theConnMode, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames): + TElemInfoBase(theMeshInfo, + (TInt)theIndexes.size()-1, + theFamilyNums, + theElemNums, + theElemNames) + { + myEntity = theEntity; + myGeom = theGeom; + + myIndex.reset(new TElemNum(theIndexes)); + myFaces.reset(new TElemNum(theFaces)); + myConn.reset(new TElemNum(theConnectivities)); + + myConnMode = theConnMode; + } + }; + + //--------------------------------------------------------------- + template + struct TTCellInfo: + virtual TCellInfo, + virtual TTElemInfo + { + typedef TTElemInfo TElemInfoBase; + + TTCellInfo(const PMeshInfo& theMeshInfo, const PCellInfo& theInfo): + TElemInfoBase(theMeshInfo,theInfo) + { + myEntity = theInfo->GetEntity(); + myGeom = theInfo->GetGeom(); + myConnMode = theInfo->GetConnMode(); + + TInt aConnDim = GetNbNodes(myGeom); + TInt aNbConn = GetNbConn(myGeom, myEntity, myMeshInfo->myDim); + myConn.reset(new TElemNum(myNbElem * aNbConn)); + for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){ + TConnSlice aConnSlice = GetConnSlice(anElemId); + TCConnSlice aConnSlice2 = theInfo->GetConnSlice(anElemId); + for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){ + aConnSlice[anConnId] = aConnSlice2[anConnId]; + } + } + } + + TTCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TInt theNbElem, + EConnectivite theConnMode, + EBooleen theIsElemNum, + EBooleen theIsElemNames, + EModeSwitch theMode): + TModeSwitchInfo(theMode), + TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames) + { + myEntity = theEntity; + myGeom = theGeom; + + myConnMode = theConnMode; + TInt aNbConn = GetNbConn(theGeom, myEntity, theMeshInfo->myDim); + myConn.reset(new TElemNum(theNbElem * aNbConn)); + } + + TTCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + const TIntVector& theConnectivities, + EConnectivite theConnMode, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames, + EModeSwitch theMode): + TModeSwitchInfo(theMode), + TElemInfoBase(theMeshInfo, + (TInt)theConnectivities.size() / GetNbNodes(theGeom), + theFamilyNums, + theElemNums, + theElemNames) + { + myEntity = theEntity; + myGeom = theGeom; + + myConnMode = theConnMode; + TInt aConnDim = GetNbNodes(myGeom); + TInt aNbConn = GetNbConn(myGeom, myEntity, myMeshInfo->myDim); + myConn.reset(new TElemNum(myNbElem * aNbConn)); + for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){ + TConnSlice aConnSlice = GetConnSlice(anElemId); + for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){ + aConnSlice[anConnId] = theConnectivities[anElemId*aConnDim + anConnId]; + } + } + } + + virtual + TInt + GetConnDim() const + { + return GetNbConn(myGeom, myEntity, myMeshInfo->myDim); + } + + }; + + //--------------------------------------------------------------- + template + struct TTBallInfo: + virtual TBallInfo, + virtual TTCellInfo + { + typedef TTCellInfo TCellInfoBase; + + TTBallInfo(const PMeshInfo& theMeshInfo, const PBallInfo& theInfo): + TCellInfoBase::TElemInfoBase(theMeshInfo, theInfo), + TCellInfoBase(theMeshInfo,theInfo) + { + myDiameters = theInfo->myDiameters; + } + + TTBallInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EBooleen theIsElemNum ): + TCellInfoBase::TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + /*theIsElemNames=*/eFAUX), + TCellInfoBase(theMeshInfo, + eSTRUCT_ELEMENT, + eBALL, + theNbElem, + /*EConnectivite=*/eNOD, + theIsElemNum, + /*theIsElemNames=*/eFAUX, + eFULL_INTERLACE) + { + myDiameters.resize( theNbElem ); + } + + TTBallInfo(const PMeshInfo& theMeshInfo, + const TIntVector& theNodes, + TFloatVector& theDiameters, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums): + TCellInfoBase::TElemInfoBase(theMeshInfo, + (TInt)std::max(theNodes.size(),theDiameters.size() ), + theFamilyNums, + theElemNums, + TStringVector()), + TCellInfoBase(theMeshInfo, + eSTRUCT_ELEMENT, + eBALL, + theNodes, + /*EConnectivite=*/eNOD, + theFamilyNums, + theElemNums, + TStringVector(), + eFULL_INTERLACE) + { + myDiameters.swap( theDiameters ); + } + }; + + //--------------------------------------------------------------- + template + struct TTFieldInfo: + virtual TFieldInfo, + virtual TTNameInfo + { + typedef TTNameInfo TNameInfoBase; + + TTFieldInfo(const PMeshInfo& theMeshInfo, const PFieldInfo& theInfo): + TNameInfoBase(theInfo->GetName()) + { + myMeshInfo = theMeshInfo; + + myNbComp = theInfo->GetNbComp(); + myCompNames.resize(myNbComp*GetPNOMLength()+1); + for(TInt anId = 0; anId < myNbComp; anId++){ + SetCompName(anId,theInfo->GetCompName(anId)); + } + + myUnitNames.resize(myNbComp*GetPNOMLength()+1); + for(TInt anId = 0; anId < myNbComp; anId++){ + SetUnitName(anId,theInfo->GetUnitName(anId)); + } + + myType = theInfo->GetType(); + + myIsLocal = theInfo->GetIsLocal(); + myNbRef = theInfo->GetNbRef(); + } + + TTFieldInfo(const PMeshInfo& theMeshInfo, + TInt theNbComp, + ETypeChamp theType, + const std::string& theValue, + EBooleen theIsLocal, + TInt theNbRef): + TNameInfoBase(theValue) + { + myMeshInfo = theMeshInfo; + + myNbComp = theNbComp; + myCompNames.resize(theNbComp*GetPNOMLength()+1); + myUnitNames.resize(theNbComp*GetPNOMLength()+1); + + myType = theType; + + myIsLocal = theIsLocal; + myNbRef = theNbRef; + } + + virtual + std::string + GetCompName(TInt theId) const + { + return GetString(theId,GetPNOMLength(),myCompNames); + } + + virtual + void + SetCompName(TInt theId, const std::string& theValue) + { + SetString(theId,GetPNOMLength(),myCompNames,theValue); + } + + virtual + std::string + GetUnitName(TInt theId) const + { + return GetString(theId,GetPNOMLength(),myUnitNames); + } + + virtual + void + SetUnitName(TInt theId, const std::string& theValue) + { + SetString(theId,GetPNOMLength(),myUnitNames,theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTGaussInfo: + virtual TGaussInfo, + virtual TTNameInfo + { + typedef TTNameInfo TNameInfoBase; + + TTGaussInfo(const TGaussInfo::TInfo& theInfo, + EModeSwitch theMode): + TModeSwitchInfo(theMode), + TNameInfoBase(boost::get<1>(boost::get<0>(theInfo))) + { + const TGaussInfo::TKey& aKey = boost::get<0>(theInfo); + + myGeom = boost::get<0>(aKey); + myRefCoord.resize(GetNbRef()*GetDim()); + + TInt aNbGauss = boost::get<1>(theInfo); + myGaussCoord.resize(aNbGauss*GetDim()); + myWeight.resize(aNbGauss); + } + }; + + + //--------------------------------------------------------------- + template + struct TTTimeStampInfo: virtual TTimeStampInfo + { + TTTimeStampInfo(const PFieldInfo& theFieldInfo, const PTimeStampInfo& theInfo) + { + myFieldInfo = theFieldInfo; + + myEntity = theInfo->GetEntity(); + myGeom2Size = theInfo->GetGeom2Size(); + + myNumDt = theInfo->GetNumDt(); + myNumOrd = theInfo->GetNumOrd(); + myDt = theInfo->GetDt(); + + myUnitDt.resize(GetPNOMLength()+1); + SetUnitDt(theInfo->GetUnitDt()); + + myGeom2NbGauss = theInfo->myGeom2NbGauss; + myGeom2Gauss = theInfo->GetGeom2Gauss(); + } + + TTTimeStampInfo(const PFieldInfo& theFieldInfo, + EEntiteMaillage theEntity, + const TGeom2Size& theGeom2Size, + const TGeom2NbGauss& theGeom2NbGauss, + TInt theNumDt, + TInt theNumOrd, + TFloat theDt, + const std::string& theUnitDt, + const TGeom2Gauss& theGeom2Gauss) + { + myFieldInfo = theFieldInfo; + + myEntity = theEntity; + myGeom2Size = theGeom2Size; + + myNumDt = theNumDt; + myNumOrd = theNumDt; + myDt = theDt; + + myUnitDt.resize(GetPNOMLength()+1); + SetUnitDt(theUnitDt); + + myGeom2NbGauss = theGeom2NbGauss; + myGeom2Gauss = theGeom2Gauss; + } + + virtual + std::string + GetUnitDt() const + { + return GetString(0,GetPNOMLength(),myUnitDt); + } + + virtual + void + SetUnitDt(const std::string& theValue) + { + SetString(0,GetPNOMLength(),myUnitDt,theValue); + } + }; + + + //--------------------------------------------------------------- + template + struct TTProfileInfo: + virtual TProfileInfo, + virtual TTNameInfo + { + typedef TTNameInfo TNameInfoBase; + + TTProfileInfo(const TProfileInfo::TInfo& theInfo, + EModeProfil theMode): + TNameInfoBase(boost::get<0>(theInfo)) + { + TInt aSize = boost::get<1>(theInfo); + myElemNum.reset(new TElemNum(aSize)); + myMode = aSize > 0? theMode: eNO_PFLMOD; + } + }; + + + //--------------------------------------------------------------- + template + struct TTTimeStampValue: virtual TTimeStampValue + { + TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + const PTimeStampValueBase& theInfo, + ETypeChamp theTypeChamp) + { + typedef TTimeStampValue TCompatible; + if(TCompatible* aCompatible = dynamic_cast(theInfo.get())){ + this->myTimeStampInfo = theTimeStampInfo; + this->myTypeChamp = theTypeChamp; + this->myGeom2Profile = aCompatible->GetGeom2Profile(); + this->myGeom2Value = aCompatible->myGeom2Value; + this->myGeomSet = aCompatible->GetGeomSet(); + }else + EXCEPTION(std::runtime_error,"TTTimeStampValue::TTTimeStampValue - use incompatible arguments!"); + } + + TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + ETypeChamp theTypeChamp, + const TGeom2Profile& theGeom2Profile, + EModeSwitch theMode): + TModeSwitchInfo(theMode) + { + this->myTimeStampInfo = theTimeStampInfo; + + this->myTypeChamp = theTypeChamp; + + this->myGeom2Profile = theGeom2Profile; + + TInt aNbComp = theTimeStampInfo->myFieldInfo->myNbComp; + + const TGeom2Size& aGeom2Size = theTimeStampInfo->GetGeom2Size(); + TGeom2Size::const_iterator anIter = aGeom2Size.begin(); + for(; anIter != aGeom2Size.end(); anIter++){ + const EGeometrieElement& aGeom = anIter->first; + TInt aNbElem = anIter->second; + + MED::PProfileInfo aProfileInfo; + MED::TGeom2Profile::const_iterator anIter = theGeom2Profile.find(aGeom); + if(anIter != theGeom2Profile.end()) + aProfileInfo = anIter->second; + + if(aProfileInfo && aProfileInfo->IsPresent()) + aNbElem = aProfileInfo->GetSize(); + + TInt aNbGauss = theTimeStampInfo->GetNbGauss(aGeom); + + this->GetMeshValue(aGeom).Allocate(aNbElem,aNbGauss,aNbComp); + } + } + + virtual + size_t + GetValueSize(EGeometrieElement theGeom) const + { + return this->GetMeshValue(theGeom).GetSize(); + } + + virtual + size_t + GetNbVal(EGeometrieElement theGeom) const + { + return this->GetMeshValue(theGeom).GetNbVal(); + } + + virtual + size_t + GetNbGauss(EGeometrieElement theGeom) const + { + return this->GetMeshValue(theGeom).GetNbGauss(); + } + + virtual + void + AllocateValue(EGeometrieElement theGeom, + TInt theNbElem, + TInt theNbGauss, + TInt theNbComp, + EModeSwitch theMode = eFULL_INTERLACE) + { + this->GetMeshValue(theGeom).Allocate(theNbElem,theNbGauss,theNbComp,theMode); + } + + virtual + unsigned char* + GetValuePtr(EGeometrieElement theGeom) + { + return this->GetMeshValue(theGeom).GetValuePtr(); + } + }; + + //--------------------------------------------------------------- + template + struct TTGrilleInfo: + virtual TGrilleInfo + { + TTGrilleInfo(const PMeshInfo& theMeshInfo, + const PGrilleInfo& theInfo) + { + myMeshInfo = theMeshInfo; + + myCoord = theInfo->GetNodeCoord(); + + myGrilleType = theInfo->GetGrilleType(); + + myCoordNames = theInfo->myCoordNames; + + myCoordUnits = theInfo->myCoordUnits; + + myIndixes = theInfo->GetMapOfIndexes(); + + myGrilleStructure = theInfo->GetGrilleStructure(); + + myGrilleType = theInfo->GetGrilleType(); + + myFamNumNode.resize(theInfo->GetNbNodes()); + myFamNumNode = theInfo->myFamNumNode; + + myFamNum = theInfo->myFamNum; + } + + TTGrilleInfo(const PMeshInfo& theMeshInfo, + const EGrilleType& type, + const TInt nnoeuds) + { + myMeshInfo = theMeshInfo; + TInt aSpaceDim = theMeshInfo->GetSpaceDim(); + if(type == eGRILLE_STANDARD){ + myCoord.resize(aSpaceDim*nnoeuds); + myCoordNames.resize(aSpaceDim*GetPNOMLength()+1); + myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1); + } else { //if(type == eGRILLE_CARTESIENNE){ + myCoordNames.resize(aSpaceDim*GetPNOMLength()+aSpaceDim); + myCoordUnits.resize(aSpaceDim*GetPNOMLength()+aSpaceDim); + } + myGrilleStructure.resize(aSpaceDim); + myFamNumNode.resize(nnoeuds); + } + + TTGrilleInfo(const PMeshInfo& theMeshInfo, + const EGrilleType& type) + { + myMeshInfo = theMeshInfo; + TInt aSpaceDim = theMeshInfo->GetSpaceDim(); + if(type == eGRILLE_STANDARD){ + myCoordNames.resize(aSpaceDim*GetPNOMLength()+1); + myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1); + } else {// if(type == eGRILLE_CARTESIENNE){ + myCoordNames.resize(aSpaceDim*GetPNOMLength()+aSpaceDim); + myCoordUnits.resize(aSpaceDim*GetPNOMLength()+aSpaceDim); + } + myGrilleStructure.resize(aSpaceDim); + } + + TTGrilleInfo(const PMeshInfo& theMeshInfo, + const EGrilleType& type, + const MED::TIntVector& nbNodeVec) + { + myMeshInfo = theMeshInfo; + + TInt aSpaceDim = theMeshInfo->GetSpaceDim(); + if(type == eGRILLE_STANDARD){ + myCoordNames.resize(aSpaceDim*GetPNOMLength()+1); + myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1); + } else {// if(type == eGRILLE_CARTESIENNE){ + myCoordNames.resize(aSpaceDim*GetPNOMLength()+aSpaceDim); + myCoordUnits.resize(aSpaceDim*GetPNOMLength()+aSpaceDim); + } + + if(type != eGRILLE_STANDARD) + for(unsigned int aAxe=0;aAxe(),myCoordNames); + } + + virtual + void + SetCoordName(TInt theId, const std::string& theValue) + { + SetString(theId,GetPNOMLength(),myCoordNames,theValue); + } + + virtual + std::string + GetCoordUnit(TInt theId) const + { + return GetString(theId,GetPNOMLength(),myCoordUnits); + } + + virtual + void + SetCoordUnit(TInt theId, const std::string& theValue) + { + SetString(theId,GetPNOMLength(),myCoordUnits,theValue); + } + + }; +} + +#endif diff --git a/src/MEDWrapper/Base/MED_TWrapper.hxx b/src/MEDWrapper/Base/MED_TWrapper.hxx new file mode 100644 index 000000000..4acda13b4 --- /dev/null +++ b/src/MEDWrapper/Base/MED_TWrapper.hxx @@ -0,0 +1,578 @@ +// 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 MED_TWrapper_HeaderFile +#define MED_TWrapper_HeaderFile + +#include "MED_TStructures.hxx" +#include "MED_Wrapper.hxx" + +namespace MED +{ + + template + class TTWrapper: public TWrapper + { + public: + //---------------------------------------------------------------------------- + //! Gets version of the MED library used for the MED file + virtual + EVersion + GetVersion() + { + return eVersion; + } + + //---------------------------------------------------------------------------- + virtual + PMeshInfo + CrMeshInfo(TInt theDim = 0, TInt theSpaceDim = 0, + const std::string& theValue = "", + EMaillage theType = eNON_STRUCTURE, + const std::string& theDesc = "") + { + return PMeshInfo(new TTMeshInfo + (theDim, + theSpaceDim, + theValue, + theType, + theDesc)); + } + + virtual + PMeshInfo + CrMeshInfo(const PMeshInfo& theInfo) + { + return PMeshInfo(new TTMeshInfo(theInfo)); + } + + + //---------------------------------------------------------------------------- + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + TInt theNbGroup = 0, + TInt theNbAttr = 0, + TInt theId = 0, + const std::string& theValue = "") + { + return PFamilyInfo(new TTFamilyInfo + (theMeshInfo, + theNbGroup, + theNbAttr, + theId, + theValue)); + } + + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + const std::string& theValue, + TInt theId, + const MED::TStringSet& theGroupNames, + const MED::TStringVector& theAttrDescs = MED::TStringVector(), + const MED::TIntVector& theAttrIds = MED::TIntVector(), + const MED::TIntVector& theAttrVals = MED::TIntVector()) + { + return PFamilyInfo(new TTFamilyInfo + (theMeshInfo, + theValue, + theId, + theGroupNames, + theAttrDescs, + theAttrIds, + theAttrVals)); + } + + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + const PFamilyInfo& theInfo) + { + return PFamilyInfo(new TTFamilyInfo + (theMeshInfo, + theInfo)); + } + + //---------------------------------------------------------------------------- + virtual + PElemInfo + CrElemInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PElemInfo(new TTElemInfo + (theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames)); + } + + virtual + PElemInfo + CrElemInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + const TIntVector& theFamNum, + const TIntVector& aElemNum, + const TStringVector& aElemNames) + { + return PElemInfo(new TTElemInfo + (theMeshInfo, + theNbElem, + theFamNum, + aElemNum, + aElemNames)); + } + + //---------------------------------------------------------------------------- + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EModeSwitch theMode = eFULL_INTERLACE, + ERepere theSystem = eCART, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PNodeInfo(new TTNodeInfo + (theMeshInfo, + theNbElem, + theMode, + theSystem, + theIsElemNum, + theIsElemNames)); + } + + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + const TFloatVector& theNodeCoords, + EModeSwitch theMode = eFULL_INTERLACE, + ERepere theSystem = eCART, + const TStringVector& theCoordNames = TStringVector(), + const TStringVector& theCoordUnits = TStringVector(), + const TIntVector& theFamilyNums = TIntVector(), + const TIntVector& theElemNums = TIntVector(), + const TStringVector& theElemNames = TStringVector()) + { + return PNodeInfo(new TTNodeInfo + (theMeshInfo, + theNodeCoords, + theMode, + theSystem, + theCoordNames, + theCoordUnits, + theFamilyNums, + theElemNums, + theElemNames)); + } + + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + const PNodeInfo& theInfo) + { + return PNodeInfo(new TTNodeInfo + (theMeshInfo, + theInfo)); + } + + //---------------------------------------------------------------------------- + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TInt theNbElem, + TInt theConnSize, + EConnectivite theConnMode = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PPolygoneInfo(new TTPolygoneInfo + (theMeshInfo, + theEntity, + theGeom, + theNbElem, + theConnSize, + theConnMode, + theIsElemNum, + theIsElemNames)); + } + + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + const TIntVector& theIndexes, + const TIntVector& theConnectivities, + EConnectivite theConnMode = eNOD, + const TIntVector& theFamilyNums = TIntVector(), + const TIntVector& theElemNums = TIntVector(), + const TStringVector& theElemNames = TStringVector()) + { + return PPolygoneInfo(new TTPolygoneInfo + (theMeshInfo, + theEntity, + theGeom, + theIndexes, + theConnectivities, + theConnMode, + theFamilyNums, + theElemNums, + theElemNames)); + } + + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + const PPolygoneInfo& theInfo) + { + return PPolygoneInfo(new TTPolygoneInfo + (theMeshInfo, + theInfo)); + } + + //---------------------------------------------------------------------------- + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TInt theNbElem, + TInt theNbFaces, + TInt theConnSize, + EConnectivite theConnMode = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PPolyedreInfo(new TTPolyedreInfo + (theMeshInfo, + theEntity, + theGeom, + theNbElem, + theNbFaces, + theConnSize, + theConnMode, + theIsElemNum, + theIsElemNames)); + } + + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + const TIntVector& theIndexes, + const TIntVector& theFaces, + const TIntVector& theConnectivities, + EConnectivite theConnMode = eNOD, + const TIntVector& theFamilyNums = TIntVector(), + const TIntVector& theElemNums = TIntVector(), + const TStringVector& theElemNames = TStringVector()) + { + return PPolyedreInfo(new TTPolyedreInfo + (theMeshInfo, + theEntity, + theGeom, + theIndexes, + theFaces, + theConnectivities, + theConnMode, + theFamilyNums, + theElemNums, + theElemNames)); + } + + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + const PPolyedreInfo& theInfo) + { + return PPolyedreInfo(new TTPolyedreInfo + (theMeshInfo, + theInfo)); + } + + //---------------------------------------------------------------------------- + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TInt theNbElem, + EConnectivite theConnMode = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI, + EModeSwitch theMode = eFULL_INTERLACE) + { + return PCellInfo(new TTCellInfo + (theMeshInfo, + theEntity, + theGeom, + theNbElem, + theConnMode, + theIsElemNum, + theIsElemNames, + theMode)); + } + + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + const TIntVector& theConnectivities, + EConnectivite theConnMode = eNOD, + const TIntVector& theFamilyNums = TIntVector(), + const TIntVector& theElemNums = TIntVector(), + const TStringVector& theElemNames = TStringVector(), + EModeSwitch theMode = eFULL_INTERLACE) + { + return PCellInfo(new TTCellInfo + (theMeshInfo, + theEntity, + theGeom, + theConnectivities, + theConnMode, + theFamilyNums, + theElemNums, + theElemNames, + theMode)); + } + + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + const PCellInfo& theInfo) + { + return PCellInfo(new TTCellInfo + (theMeshInfo, + theInfo)); + } + + //---------------------------------------------------------------------------- + //! Creates a MEDWrapper MED Balls representation + virtual PBallInfo CrBallInfo(const PMeshInfo& theMeshInfo, + TInt theNbBalls, + EBooleen theIsElemNum = eVRAI) + { + return PBallInfo( new TTBallInfo( theMeshInfo, theNbBalls, theIsElemNum )); + } + + //! Creates a MEDWrapper MED Balls representation + virtual PBallInfo CrBallInfo(const PMeshInfo& theMeshInfo, + const TIntVector& theNodes, + TFloatVector& theDiameters, + const TIntVector& theFamilyNums = TIntVector(), + const TIntVector& theElemNums = TIntVector()) + { + return PBallInfo( new TTBallInfo( theMeshInfo, theNodes, theDiameters, + theFamilyNums, theElemNums)); + } + + //! A copy-constructor for the MEDWrapper MED Balls representation + virtual PBallInfo CrBallInfo(const PMeshInfo& theMeshInfo, + const PBallInfo& theInfo) + { + return PBallInfo( new TTBallInfo( theMeshInfo, theInfo )); + } + + //---------------------------------------------------------------------------- + virtual + PFieldInfo + CrFieldInfo(const PMeshInfo& theMeshInfo, + TInt theNbComp = 0, + ETypeChamp theType = eFLOAT64, + const std::string& theValue = "", + EBooleen theIsLocal = eVRAI, + TInt theNbRef = 1) + { + return PFieldInfo(new TTFieldInfo + (theMeshInfo, + theNbComp, + theType, + theValue, + theIsLocal, + theNbRef)); + } + + virtual + PFieldInfo + CrFieldInfo(const PMeshInfo& theMeshInfo, + const PFieldInfo& theInfo) + { + return PFieldInfo(new TTFieldInfo + (theMeshInfo, + theInfo)); + } + + + //---------------------------------------------------------------------------- + virtual + PTimeStampInfo + CrTimeStampInfo(const PFieldInfo& theFieldInfo, + EEntiteMaillage theEntity, + const TGeom2Size& theGeom2Size, + const TGeom2NbGauss& theGeom2NbGauss = TGeom2NbGauss(), + TInt theNumDt = 0, + TInt theNumOrd = 0, + TFloat theDt = 0, + const std::string& theUnitDt = "", + const TGeom2Gauss& theGeom2Gauss = TGeom2Gauss()) + { + return PTimeStampInfo(new TTTimeStampInfo + (theFieldInfo, + theEntity, + theGeom2Size, + theGeom2NbGauss, + theNumDt, + theNumOrd, + theDt, + theUnitDt, + theGeom2Gauss)); + } + + virtual + PTimeStampInfo + CrTimeStampInfo(const PFieldInfo& theFieldInfo, + const PTimeStampInfo& theInfo) + { + return PTimeStampInfo(new TTTimeStampInfo + (theFieldInfo, + theInfo)); + } + + + //---------------------------------------------------------------------------- + virtual + PGaussInfo + CrGaussInfo(const TGaussInfo::TInfo& theInfo, + EModeSwitch theMode = eFULL_INTERLACE) + { + return PGaussInfo(new TTGaussInfo + (theInfo, + theMode)); + } + + + //---------------------------------------------------------------------------- + virtual + PProfileInfo + CrProfileInfo(const TProfileInfo::TInfo& theInfo, + EModeProfil theMode = eCOMPACT) + { + return PProfileInfo(new TTProfileInfo + (theInfo, + theMode)); + } + + + //---------------------------------------------------------------------------- + virtual + PTimeStampValueBase + CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + ETypeChamp theTypeChamp, + const TGeom2Profile& theGeom2Profile = TGeom2Profile(), + EModeSwitch theMode = eFULL_INTERLACE) + { + if(theTypeChamp == eFLOAT64) + return PTimeStampValueBase(new TTTimeStampValue + (theTimeStampInfo, + theTypeChamp, + theGeom2Profile, + theMode)); + return PTimeStampValueBase(new TTTimeStampValue + (theTimeStampInfo, + theTypeChamp, + theGeom2Profile, + theMode)); + } + + virtual + PTimeStampValueBase + CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + const PTimeStampValueBase& theInfo, + ETypeChamp theTypeChamp) + { + if(theTypeChamp == eFLOAT64) + return PTimeStampValueBase(new TTTimeStampValue + (theTimeStampInfo, + theInfo, + theTypeChamp)); + return PTimeStampValueBase(new TTTimeStampValue + (theTimeStampInfo, + theInfo, + theTypeChamp)); + } + + //---------------------------------------------------------------------------- + virtual + PGrilleInfo + CrGrilleInfo(const PMeshInfo& theMeshInfo, + const PGrilleInfo& theInfo) + { + return PGrilleInfo(new TTGrilleInfo + (theMeshInfo, + theInfo)); + } + virtual + PGrilleInfo + CrGrilleInfo(const PMeshInfo& theMeshInfo, + const EGrilleType& type) + { + return PGrilleInfo(new TTGrilleInfo + (theMeshInfo, + type)); + } + + virtual + PGrilleInfo + CrGrilleInfo(const PMeshInfo& theMeshInfo, + const EGrilleType& type, + const TInt& nbNodes) + { + return PGrilleInfo(new TTGrilleInfo + (theMeshInfo, + type, + nbNodes)); + } + + virtual + PGrilleInfo + CrGrilleInfo(const PMeshInfo& theMeshInfo, + const EGrilleType& type, + const MED::TIntVector& nbNodeVec) + { + return PGrilleInfo(new TTGrilleInfo + (theMeshInfo, + type, + nbNodeVec)); + } + //---------------------------------------------------------------------------- + }; + +} + + +#endif diff --git a/src/MEDWrapper/Base/MED_Utilities.cxx b/src/MEDWrapper/Base/MED_Utilities.cxx new file mode 100644 index 000000000..49cd74aac --- /dev/null +++ b/src/MEDWrapper/Base/MED_Utilities.cxx @@ -0,0 +1,113 @@ +// 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 "MED_Utilities.hxx" +#include "MED_Common.hxx" + +using namespace std; + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +// static int MYDEBUG = 0; +#endif + + +int MED::PrefixPrinter::myCounter = 0; + +MED::PrefixPrinter::PrefixPrinter(bool theIsActive): + myIsActive(theIsActive) +{ + if(myIsActive) + myCounter++; + MSG(MYDEBUG,"MED::PrefixPrinter::PrefixPrinter(...)- "< +#include +#include +#include +#include + + +namespace MED +{ + class MEDWRAPPER_EXPORT PrefixPrinter + { + static int myCounter; + bool myIsActive; + public: + PrefixPrinter(bool theIsActive = true); + ~PrefixPrinter(); + + static std::string GetPrefix(); + }; +} + +#ifdef _DEBUG_ + #define MSG(deb,msg) if(deb) std::cout< +#include + +//#if defined(_DEBUG_) +# define MED_TVECTOR_CHECK_RANGE +//#endif + +namespace MED +{ + + //! Main purpose to introduce the class was to customize operator [] + template > + class TVector : public std::vector<_Tp, _Alloc> + { + public: + typedef size_t size_type; + + typedef std::vector<_Tp, _Alloc> superclass; + typedef typename superclass::allocator_type allocator_type; + + typedef _Tp value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + + protected: + void + check_range(size_type __n) const + { + if (__n >= this->size()) + throw std::out_of_range("TVector [] access out of range"); + } + + const_reference + get_value(size_type __n) const + { + return superclass::operator[](__n); + } + + reference + get_value(size_type __n) + { + return superclass::operator[](__n); + } + + public: + explicit + TVector(const allocator_type& __a = allocator_type()): + superclass(__a) + {} + + TVector(size_type __n, const value_type& __val, + const allocator_type& __a = allocator_type()): + superclass(__n, __val, __a) + {} + + explicit + TVector(size_type __n): + superclass(__n) + {} + + TVector(const TVector& __x): + superclass(__x) + {} + + template + TVector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()): + superclass(__first, __last, __a) + {} + + template + TVector(TVector<_Yp, _Al> __y): + superclass(__y.begin(), __y.end()) + {} + + TVector& + operator=(const TVector& __x) + { + superclass::operator=(__x); + return *this; + } + + template + TVector& + operator=(TVector<_Yp, _Al> __y) + { + this->assign(__y.begin(), __y.end()); + return *this; + } + + reference + operator[](size_type __n) + { +#if defined(MED_TVECTOR_CHECK_RANGE) + check_range(__n); +#endif + return get_value(__n); + } + + const_reference + operator[](size_type __n) const + { +#if defined(MED_TVECTOR_CHECK_RANGE) + check_range(__n); +#endif + return get_value(__n); + } + + reference + at(size_type __n) + { + check_range(__n); + return get_value(__n); + } + + const_reference + at(size_type __n) const + { + check_range(__n); + return get_value(__n); + } + }; + +} + +#undef MED_TVECTOR_CHECK_RANGE + +#endif diff --git a/src/MEDWrapper/Base/MED_Wrapper.cxx b/src/MEDWrapper/Base/MED_Wrapper.cxx new file mode 100644 index 000000000..d04c28423 --- /dev/null +++ b/src/MEDWrapper/Base/MED_Wrapper.cxx @@ -0,0 +1,707 @@ +// 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 +// +// File : MED_Wrapper.cxx +// Author : Alexey PETROV +// +#include "MED_Wrapper.hxx" +#include "MED_Utilities.hxx" + +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +static int MYVALUEDEBUG = 0; +#else +// static int MYDEBUG = 0; +// static int MYVALUEDEBUG = 0; +#endif + +namespace MED +{ + TLockProxy + ::TLockProxy(TWrapper* theWrapper): + myWrapper(theWrapper) + { +#if BOOST_VERSION >= 103500 + myWrapper->myMutex.lock(); +#else + boost::detail::thread::lock_ops::lock(myWrapper->myMutex); +#endif + INITMSG(MYDEBUG,"TLockProxy() - this -"<GetGroupName(iGroup); + INITMSG(MYDEBUG,"aGroupName = '"<myDim; + TInt aNbElem = anInfo->GetNbElem(); + INITMSG(MYDEBUG,"GetPNodeInfo: "); + { + INITMSG(MYDEBUG,"aCoords: "<myCoord; + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + for(TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++){ + ADDMSG(MYVALUEDEBUG,aCoord[anId]<<","); + } + ADDMSG(MYVALUEDEBUG," "); + } + ADDMSG(MYDEBUG, std::endl); + + BEGMSG(MYVALUEDEBUG, "GetFamNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", "); + } + ADDMSG(MYVALUEDEBUG, std::endl); + + if(anInfo->IsElemNum()){ + BEGMSG(MYVALUEDEBUG,"GetElemNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", "); + } + ADDMSG(MYVALUEDEBUG, std::endl); + } + } + ADDMSG(MYDEBUG, std::endl); +#endif + + return anInfo; + } + + //---------------------------------------------------------------------------- + PPolygoneInfo + TWrapper + ::GetPPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode) + { + if(theMeshInfo->GetType() != eNON_STRUCTURE) + return PPolygoneInfo(); + + TInt aNbElem = GetNbPolygones(theMeshInfo,theEntity,theGeom,theConnMode); + TInt aConnSize = GetPolygoneConnSize(theMeshInfo,theEntity,theGeom,theConnMode); + PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo,theEntity,theGeom,aNbElem,aConnSize,theConnMode); + GetPolygoneInfo(anInfo); + +#ifdef _DEBUG_ + INITMSG(MYDEBUG,"GetPPolygoneInfo"<< + " - theGeom = "<GetConnSlice(iElem); + TInt aConnDim = aConnSlice.size(); + for(TInt iConn = 0; iConn < aConnDim; iConn++){ + ADDMSG(MYVALUEDEBUG,aConnSlice[iConn]<<","); + } + ADDMSG(MYDEBUG," "); + } + ADDMSG(MYDEBUG, std::endl); +#endif + + return anInfo; + } + + //---------------------------------------------------------------------------- + PPolyedreInfo + TWrapper + ::GetPPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode) + { + if(theMeshInfo->GetType() != eNON_STRUCTURE) + return PPolyedreInfo(); + TInt aNbElem = GetNbPolyedres(theMeshInfo,theEntity,theGeom,theConnMode); + TInt aNbFaces, aConnSize; + GetPolyedreConnSize(theMeshInfo,aNbFaces,aConnSize,theConnMode); + PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo,theEntity,theGeom,aNbElem,aNbFaces,aConnSize,theConnMode); + GetPolyedreInfo(anInfo); + +#ifdef _DEBUG_ + INITMSG(MYDEBUG,"GetPPolyedreInfo"<< + " - theGeom = "<GetConnSliceArr(iElem); + TInt aNbFaces = aConnSliceArr.size(); + ADDMSG(MYDEBUG,"{"); + for(TInt iFace = 0; iFace < aNbFaces; iFace++){ + TCConnSlice aConnSlice = aConnSliceArr[iFace]; + TInt aNbConn = aConnSlice.size(); + ADDMSG(MYDEBUG,"["); + for(TInt iConn = 0; iConn < aNbConn; iConn++){ + ADDMSG(MYVALUEDEBUG,aConnSlice[iConn]<<","); + } + ADDMSG(MYDEBUG,"] "); + } + ADDMSG(MYDEBUG,"} "); + } + ADDMSG(MYDEBUG, std::endl); +#endif + + return anInfo; + } + + //---------------------------------------------------------------------------- + PElemInfo + TWrapper + ::GetPElemInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode, + TErr* theErr) + { + EMaillage aType = theMeshInfo->GetType(); + if(aType == eNON_STRUCTURE){ + switch(theGeom){ + case ePOINT1: + if(theEntity == eNOEUD) + return GetPNodeInfo(theMeshInfo,theErr); + return GetPCellInfo(theMeshInfo,theEntity,theGeom,theConnMode,theErr); + break; + case ePOLYGONE: + return GetPPolygoneInfo(theMeshInfo,theEntity,theGeom,theConnMode); + break; + case ePOLYEDRE: + return GetPPolyedreInfo(theMeshInfo,theEntity,theGeom,theConnMode); + break; + default: + return GetPCellInfo(theMeshInfo,theEntity,theGeom,theConnMode,theErr); + } + } else { + PGrilleInfo aGrille = GetPGrilleInfo(theMeshInfo); + + TInt nbElems; + EBooleen theIsElemNum = eFAUX; + // nodes + switch(theGeom){ + case ePOINT1: + nbElems = aGrille->GetNbNodes(); + theIsElemNum = eVRAI; + break; + case eSEG2: + case eQUAD4: + case eHEXA8: + nbElems = aGrille->GetNbCells(); + break; + default: + nbElems = 0; + } + + TIntVector aFamNum; + TIntVector aElemNum; + TStringVector aElemNames; + + PElemInfo aElemInfo; + + if(theGeom == ePOINT1){ + aElemInfo = CrElemInfo(theMeshInfo, + nbElems, + theIsElemNum); + MED::TElemInfo &aTElemInfo = *aElemInfo; + + // must be reimplemente in connection with mesh type eSTRUCTURE +// GetNumeration(aTElemInfo, +// nbElems, +// theEntity, +// theGeom, +// theErr); + + GetFamilies(aTElemInfo, + nbElems, + theEntity, + theGeom, + theErr); + + // must be reimplemente in connection with mesh type eSTRUCTURE +// GetNames(aTElemInfo, +// nbElems, +// theEntity, +// theGeom, +// theErr); + } else { + aElemInfo = CrElemInfo(theMeshInfo, + nbElems, + aFamNum, + aElemNum, + aElemNames); + } + + return aElemInfo; + } + return PElemInfo(); + } + + + //---------------------------------------------------------------------------- + PCellInfo + TWrapper + ::GetPCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode, + TErr* theErr) + { + if(theMeshInfo->GetType() != eNON_STRUCTURE) + return PCellInfo(); + TInt aNbElem = GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode); + PCellInfo anInfo = CrCellInfo(theMeshInfo,theEntity,theGeom,aNbElem,theConnMode); + GetCellInfo(anInfo,theErr); + +#ifdef _DEBUG_ + TInt aConnDim = anInfo->GetConnDim(); + INITMSG(MYDEBUG,"GetPCellInfo - theEntity = "<GetConnSlice(iElem); + for(TInt iConn = 0; iConn < aConnDim; iConn++){ + ADDMSG(MYVALUEDEBUG,aConnSlice[iConn]<<","); + } + ADDMSG(MYVALUEDEBUG," "); + } + ADDMSG(MYDEBUG, std::endl); + + BEGMSG(MYVALUEDEBUG,"GetPCellInfo - GetFamNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", "); + } + ADDMSG(MYVALUEDEBUG, std::endl); + + if(anInfo->IsElemNum()){ + BEGMSG(MYVALUEDEBUG,"GetPCellInfo - GetElemNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", "); + } + ADDMSG(MYVALUEDEBUG, std::endl); + } + ADDMSG(MYDEBUG, std::endl); +#endif + + return anInfo; + } + + //---------------------------------------------------------------------------- + //! Read a MEDWrapped representation of MED Balls from the MED file + PBallInfo + TWrapper + ::GetPBallInfo(const PMeshInfo& theMeshInfo) + { + TInt nbBalls = GetNbBalls(theMeshInfo); + if ( nbBalls < 1 ) return PBallInfo(); + + PBallInfo anInfo = CrBallInfo( theMeshInfo, nbBalls ); + GetBallInfo(anInfo); + + return anInfo; + } + //---------------------------------------------------------------------------- + PFieldInfo + TWrapper + ::GetPFieldInfo(const PMeshInfo& theMeshInfo, + TInt theId, + TErr* theErr) + { + TInt aNbComp = GetNbComp(theId); + PFieldInfo anInfo = CrFieldInfo(theMeshInfo,aNbComp); + GetFieldInfo(theId,*anInfo,theErr); + +#ifdef _DEBUG_ + INITMSG(MYDEBUG, + "GetPFieldInfo "<< + "- aName = '"<GetName()<<"'"<< + "; aType = "<GetType()<< + "; aNbComp = "<myGeom2NbGauss; + TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin(); + for(; anIter != aGeom2NbGauss.end(); anIter++){ + const EGeometrieElement& aGeom = anIter->first; + INITMSG(MYDEBUG,"aGeom = "<GetFieldInfo(); + return CrTimeStampValue(theTimeStampInfo, + aFieldInfo->GetType(), + theGeom2Profile, + theMode); + } + + //---------------------------------------------------------------------------- + PTimeStampValueBase + TWrapper + ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + const PTimeStampValueBase& theInfo) + { + PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo(); + return CrTimeStampValue(theTimeStampInfo, + theInfo, + aFieldInfo->GetType()); + } + + //---------------------------------------------------------------------------- + template + void + Print(SharedPtr theTimeStampValue) + { + INITMSG(MYDEBUG,"Print - TimeStampValue\n"); + typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value; + typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin(); + for(; anIter != aGeom2Value.end(); anIter++){ + const EGeometrieElement& aGeom = anIter->first; + const typename TimeStampValueType::TTMeshValue& aMeshValue = anIter->second; + TInt aNbElem = aMeshValue.myNbElem; + TInt aNbGauss = aMeshValue.myNbGauss; + TInt aNbComp = aMeshValue.myNbComp; + INITMSG(MYDEBUG,"aGeom = "<GetFieldInfo(); + PTimeStampValueBase anInfo = CrTimeStampValue(theTimeStampInfo, + aFieldInfo->GetType()); + GetTimeStampValue(anInfo, + theMKey2Profile, + theKey2Gauss, + theErr); +#ifdef _DEBUG_ + if(aFieldInfo->GetType() == eFLOAT64) + Print(anInfo); + else + Print(anInfo); +#endif + return anInfo; + } + + //---------------------------------------------------------------------------- + void + TWrapper + ::GetTimeStampVal(const PTimeStampVal& theVal, + const TMKey2Profile& theMKey2Profile, + const TKey2Gauss& theKey2Gauss, + TErr* theErr) + { + PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo(); + PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo(); + if(aFieldInfo->GetType() == eFLOAT64) + GetTimeStampValue(theVal, + theMKey2Profile, + theKey2Gauss, + theErr); + else{ + PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo, + theVal, + eINT); + GetTimeStampValue(aVal, + theMKey2Profile, + theKey2Gauss, + theErr); + CopyTimeStampValueBase(aVal, theVal); + } + } + + //---------------------------------------------------------------------------- + void + TWrapper + ::SetTimeStamp(const PTimeStampVal& theVal, + TErr* theErr) + { + PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo(); + PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo(); + if(aFieldInfo->GetType() == eFLOAT64) + SetTimeStampValue(theVal, theErr); + else{ + PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo, + eINT, + theVal->GetGeom2Profile(), + theVal->GetModeSwitch()); + CopyTimeStampValueBase(theVal, aVal); + SetTimeStampValue(aVal, theErr); + } + } + + //---------------------------------------------------------------------------- + PTimeStampVal + TWrapper + ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const TGeom2Profile& theGeom2Profile, + EModeSwitch theMode) + { + return CrTimeStampValue(theTimeStampInfo, + eFLOAT64, + theGeom2Profile, + theMode); + } + + //---------------------------------------------------------------------------- + PTimeStampVal + TWrapper + ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const PTimeStampVal& theInfo) + { + return CrTimeStampValue(theTimeStampInfo, + theInfo, + eFLOAT64); + } + + //---------------------------------------------------------------------------- + PTimeStampVal + TWrapper + ::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const TMKey2Profile& theMKey2Profile, + const TKey2Gauss& theKey2Gauss, + TErr* theErr) + { + PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo); + GetTimeStampVal(anInfo, + theMKey2Profile, + theKey2Gauss, + theErr); + return anInfo; + } + + //---------------------------------------------------------------------------- + PGrilleInfo + TWrapper + ::GetPGrilleInfo(const PMeshInfo& theMeshInfo) + { + if(theMeshInfo->GetType() != eSTRUCTURE) + return PGrilleInfo(); + + EGrilleType type; + GetGrilleType(*theMeshInfo,type); + PGrilleInfo anInfo; + if(type == eGRILLE_STANDARD){ + const TInt nnoeuds = GetNbNodes(*theMeshInfo); + anInfo = CrGrilleInfo(theMeshInfo,type,nnoeuds); + } + else { + TIntVector aVec; + aVec.resize(theMeshInfo->GetDim()); + for(int aAxe=0;aAxeGetDim();aAxe++){ + ETable aATable; + switch(aAxe){ + case 0: + aATable = eCOOR_IND1; + break; + case 1: + aATable = eCOOR_IND2; + break; + case 2: + aATable = eCOOR_IND3; + break; + } + aVec[aAxe] = GetNbNodes(*theMeshInfo,aATable); + } + anInfo = CrGrilleInfo(theMeshInfo,type,aVec); + } + + GetGrilleInfo(anInfo); + anInfo->SetGrilleType(type); + +#ifdef _DEBUG_ + INITMSG(MYDEBUG,"GetPGrilleInfo: "); + { + TInt aNbElem = anInfo->GetNbNodes(); + BEGMSG(MYVALUEDEBUG,"GetFamNumNode: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetFamNumNode(iElem)<<", "); + } + TInt aNbCells = anInfo->GetNbCells(); + BEGMSG(MYVALUEDEBUG,"GetFamNum: "); + for(TInt iElem = 0; iElem < aNbCells; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", "); + } + ADDMSG(MYVALUEDEBUG, std::endl); + BEGMSG(MYVALUEDEBUG,"GetCoordName: "); + for(TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetCoordName(iElem)<<", "); + } + ADDMSG(MYVALUEDEBUG, std::endl); + BEGMSG(MYVALUEDEBUG,"GetCoordUnit: "); + for(TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetCoordUnit(iElem)<<", "); + } + ADDMSG(MYVALUEDEBUG, std::endl); + + } +#endif + + return anInfo; + } + + //---------------------------------------------------------------------------- + PGrilleInfo + TWrapper + ::GetPGrilleInfo(const PMeshInfo& theMeshInfo, + const PGrilleInfo& theInfo) + { + PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo,theInfo); + return anInfo; + } +} diff --git a/src/MEDWrapper/Base/MED_Wrapper.hxx b/src/MEDWrapper/Base/MED_Wrapper.hxx new file mode 100644 index 000000000..027c9a545 --- /dev/null +++ b/src/MEDWrapper/Base/MED_Wrapper.hxx @@ -0,0 +1,1052 @@ +// 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 MED_Wrapper_HeaderFile +#define MED_Wrapper_HeaderFile + +#include "MED_WrapperBase.hxx" + +#include "MED_Structures.hxx" +#include "MED_Algorithm.hxx" + +#include + +namespace MED +{ + + //---------------------------------------------------------------------------- + //! Define a base class that wraps the MED API + struct MEDWRAPPER_EXPORT TWrapper + { + typedef boost::mutex TMutex; + //! This is a syncronization primitive which allow to support thread safety for the MED access + TMutex myMutex; + + virtual + ~TWrapper(); + + //---------------------------------------------------------------------------- + //! Gets version of the MED library used for the MED file + virtual + EVersion + GetVersion() = 0; + + //---------------------------------------------------------------------------- + //! Creates a MEDWrapper MED Mesh representation + virtual + PMeshInfo + CrMeshInfo(TInt theDim = 0, TInt theSpaceDim = 0, + const std::string& theValue = "", + EMaillage theType = eNON_STRUCTURE, + const std::string& theDesc = "") = 0; + + //! A copy-constructor for the MEDWrapper MED Mesh representation + virtual + PMeshInfo + CrMeshInfo(const PMeshInfo& theInfo) = 0; + + //! Read number of MED Mesh entities in the defined MED file + virtual + TInt + GetNbMeshes(TErr* theErr = NULL) = 0; + + //! Read a MEDWrapper MED Mesh representation by its number + virtual + void + GetMeshInfo(TInt theMeshId, + TMeshInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Write the MEDWrapper MED Mesh representation in the defined MED file + virtual + void + SetMeshInfo(const TMeshInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Read a MEDWrapper MED Mesh representation by its number + virtual + PMeshInfo + GetPMeshInfo(TInt theId, + TErr* theErr = NULL); + + + //---------------------------------------------------------------------------- + //! Read number of MED Family entities in the defined MED file + virtual + TInt + GetNbFamilies(const TMeshInfo& theMeshInfo, + TErr* theErr = NULL) = 0; + + //! Read number of attributes for defined MED Family + virtual + TInt + GetNbFamAttr(TInt theFamId, + const TMeshInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Read number of MED Groups where MED Family with the number belong to + virtual + TInt + GetNbFamGroup(TInt theFamId, + const TMeshInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Read a MEDWrapper MED Family representation by its number + virtual + void + GetFamilyInfo(TInt theFamId, + TFamilyInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Write a MEDWrapper MED Family representation by its number + virtual + void + SetFamilyInfo(const TFamilyInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Creates a MEDWrapper MED Family representation + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + TInt theNbGroup = 0, + TInt theNbAttr = 0, + TInt theId = 0, + const std::string& theValue = "") = 0; + + //! Creates a MEDWrapper MED Family representation + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + const std::string& theValue, + TInt theId, + const TStringSet& theGroupNames, + const TStringVector& theAttrDescs = TStringVector(), + const TIntVector& theAttrIds = TIntVector(), + const TIntVector& theAttrVals = TIntVector()) = 0; + + //! A copy-constructor for the MEDWrapper MED Family representation + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + const PFamilyInfo& theInfo) = 0; + + //! Write a MEDWrapper MED Family representation by its number + PFamilyInfo + GetPFamilyInfo(const PMeshInfo& theMeshInfo, + TInt theId, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + //! Read sequence of names for any descendant of TElemInfo + virtual + void + GetNames(TElemInfo& theInfo, + TInt theNb, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL) + {} + + //! Read sequence of numerous for any descendant of TElemInfo + virtual + void + GetNumeration(TElemInfo& theInfo, + TInt theNb, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL) + {} + + //! Read sequence MED Family indexes for any descendant of TElemInfo + virtual + void + GetFamilies(TElemInfo& theInfo, + TInt theNb, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL) + {} + + //! Write sequence of names for any descendant of TElemInfo + virtual + void + SetNames(const TElemInfo& theInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL) + {} + + //! Write sequence of numerous for any descendant of TElemInfo + virtual + void + SetNumeration(const TElemInfo& theInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL) + {} + + //! Write sequence MED Family indexes for any descendant of TElemInfo + virtual + void + SetFamilies(const TElemInfo& theInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL) + {} + + //! Read a MEDWrapper MED Element representation from defined MED file + PElemInfo + GetPElemInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity = eNOEUD, + EGeometrieElement theGeom = ePOINT1, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + //! Read number of nodes in defined MED Mesh + virtual + TInt + GetNbNodes(const TMeshInfo& theMeshInfo, + TErr* theErr = NULL) = 0; + + virtual + TInt + GetNbNodes(const TMeshInfo& theMeshInfo, + ETable theTable, + TErr* theErr = NULL) + { + return 0; + } + + //! Read a MEDWrapper MED Nodes representation from defined MED file + virtual + void + GetNodeInfo(TNodeInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Write the MEDWrapper MED Nodes representation into defined MED file + virtual + void + SetNodeInfo(const TNodeInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Creates a MEDWrapper MED Nodes representation + virtual + PElemInfo + CrElemInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PElemInfo(); + } + + //! Creates a MEDWrapper MED Nodes representation + virtual + PElemInfo + CrElemInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + const TIntVector& theFamNum, + const TIntVector& aElemNum, + const TStringVector& aElemNames) + { + return PElemInfo(); + } + + //! Creates a MEDWrapper MED Nodes representation + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EModeSwitch theMode = eFULL_INTERLACE, + ERepere theSystem = eCART, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) = 0; + + //! Creates a MEDWrapper MED Nodes representation + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + const TFloatVector& theNodeCoords, + EModeSwitch theMode = eFULL_INTERLACE, + ERepere theSystem = eCART, + const TStringVector& theCoordNames = TStringVector(), + const TStringVector& theCoordUnits = TStringVector(), + const TIntVector& theFamilyNums = TIntVector(), + const TIntVector& theElemNums = TIntVector(), + const TStringVector& theElemNames = TStringVector()) = 0; + + //! A copy-constructor for the MEDWrapper MED Nodes representation + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + const PNodeInfo& theInfo) = 0; + + //! Read a MEDWrapper MED Nodes representation from defined MED file + PNodeInfo + GetPNodeInfo(const PMeshInfo& theMeshInfo, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + //! Read a MEDWrapper MED Polygones representation from defined MED file + /*! This feature is supported only for version of 2.2 and higher */ + virtual + void + GetPolygoneInfo(TPolygoneInfo& theInfo, + TErr* theErr = NULL) + {} + + //! Write a MEDWrapper MED Polygones representation from defined MED file + /*! This feature is supported only for version of 2.2 and higher */ + virtual + void + SetPolygoneInfo(const TPolygoneInfo& theInfo, + TErr* theErr = NULL) + {} + + //! Read number of MED Polygones in defined MED Mesh + /*! This feature is supported only for version of 2.2 and higher */ + virtual + TInt + GetNbPolygones(const TMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL) + { + return 0; + } + + //! Read connectivity infroamtion for the MED Polygones in defined MED Mesh + /*! This feature is supported only for version of 2.2 and higher */ + virtual + TInt + GetPolygoneConnSize(const TMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL) + { + return 0; + } + + //! Creates a MEDWrapper MED Polygones representation + /*! This feature is supported only for version of 2.2 and higher */ + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TInt theNbElem, + TInt theConnSize, + EConnectivite theConnMode = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PPolygoneInfo(); + } + + //! Creates a MEDWrapper MED Polygones representation + /*! This feature is supported only for version of 2.2 and higher */ + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + const TIntVector& theIndexes, + const TIntVector& theConnectivities, + EConnectivite theConnMode = eNOD, + const TIntVector& theFamilyNums = TIntVector(), + const TIntVector& theElemNums = TIntVector(), + const TStringVector& theElemNames = TStringVector()) + { + return PPolygoneInfo(); + } + + //! A copy-constructor for the MEDWrapper MED Polygones representation + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + const PPolygoneInfo& theInfo) + { + return PPolygoneInfo(); + } + + //! Read a MEDWrapper MED Polygones representation from defined MED file + /*! This feature is support only for version of 2.2 and higher */ + PPolygoneInfo + GetPPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode = eNOD); + + //---------------------------------------------------------------------------- + //! Read a MEDWrapper MED Polyedres representation from defined MED file + /*! This feature is support only for version of 2.2 and higher */ + virtual + void + GetPolyedreInfo(TPolyedreInfo& theInfo, + TErr* theErr = NULL) + {} + + //! Write a MEDWrapper MED Polyedres representation from defined MED file + /*! This feature is support only for version of 2.2 and higher */ + virtual + void + SetPolyedreInfo(const TPolyedreInfo& theInfo, + TErr* theErr = NULL) + {} + + //! Read number of MED Polyedres in defined MED Mesh + /*! This feature is support only for version of 2.2 and higher */ + virtual + TInt + GetNbPolyedres(const TMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL) + { + return 0; + } + + //! Read connectivity infroamtion for the MED Polyedres in defined MED Mesh + /*! This feature is support only for version of 2.2 and higher */ + virtual + void + GetPolyedreConnSize(const TMeshInfo& theMeshInfo, + TInt& theNbFaces, + TInt& theConnSize, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL) + { + theNbFaces = theConnSize = 0; + } + + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TInt theNbElem, + TInt theNbFaces, + TInt theConnSize, + EConnectivite theConnMode = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PPolyedreInfo(); + } + + //! Creates a MEDWrapper MED Polyedres representation + /*! This feature is support only for version of 2.2 and higher */ + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + const TIntVector& theIndexes, + const TIntVector& theFaces, + const TIntVector& theConnectivities, + EConnectivite theConnMode = eNOD, + const TIntVector& theFamilyNums = TIntVector(), + const TIntVector& theElemNums = TIntVector(), + const TStringVector& theElemNames = TStringVector()) + { + return PPolyedreInfo(); + } + + //! A copy-constructor for the MEDWrapper MED Polyedres representation + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + const PPolyedreInfo& theInfo) + { + return PPolyedreInfo(); + } + + //! Read a MEDWrapper MED Polyedres representation from defined MED file + /*! This feature is support only for version of 2.2 and higher */ + PPolyedreInfo + GetPPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode = eNOD); + + //---------------------------------------------------------------------------- + //! Get TEntityInfo which contains brief information about existing cells and their destribution among MED ENTITIES + virtual + TEntityInfo + GetEntityInfo(const TMeshInfo& theMeshInfo, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL) = 0; + + //! Read number of cells for defined MED Mesh, ENTITY and geometrical type with define mode of connectivity + virtual + TInt + GetNbCells(const TMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL) = 0; + + //! Read a MEDWrapper MED Cells representation from defined MED file + virtual + void + GetCellInfo(TCellInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Write the MEDWrapper MED Cells representation into defined MED file + virtual + void + SetCellInfo(const TCellInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Creates a MEDWrapper MED Cells representation + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TInt theNbElem, + EConnectivite theConnMode = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI, + EModeSwitch theMode = eFULL_INTERLACE) = 0; + + //! Creates a MEDWrapper MED Cells representation + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + const TIntVector& theConnectivities, + EConnectivite theConnMode = eNOD, + const TIntVector& theFamilyNums = TIntVector(), + const TIntVector& theElemNums = TIntVector(), + const TStringVector& theElemNames = TStringVector(), + EModeSwitch theMode = eFULL_INTERLACE) = 0; + + //! A copy-constructor for the MEDWrapper MED Cells representation + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + const PCellInfo& theInfo) = 0; + + //! Read a MEDWrapper MED Cells representation from defined MED file + PCellInfo + GetPCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + //! Read number of balls in the Mesh + /*! This feature is supported since version 3.0 */ + virtual + TInt + GetNbBalls(const TMeshInfo& theMeshInfo) + { + return 0; + } + + //! Read a MEDWrapped representation of MED_BALL from the MED file + /*! This feature is supported since version 3.0 */ + virtual + void + GetBallInfo(TBallInfo& theInfo, + TErr* theErr = NULL) + {} + + //! Write a MEDWrapped representation of MED_BALL to the MED file + /*! This feature is supported since version 3.0 */ + virtual + void + SetBallInfo(const TBallInfo& theInfo, + TErr* theErr = NULL) + {} + + //! Creates a MEDWrapper MED Balls representation + /*! This feature is supported since version 3.0 */ + virtual + PBallInfo + CrBallInfo(const PMeshInfo& theMeshInfo, + TInt theNbBalls, + EBooleen theIsElemNum = eVRAI) + { + return PBallInfo(); + } + + //! Creates a MEDWrapper MED Balls representation + /*! This feature is supported since version 3.0 */ + virtual + PBallInfo + CrBallInfo(const PMeshInfo& theMeshInfo, + const TIntVector& theNodes, + TFloatVector& theDiameters, + const TIntVector& theFamilyNums = TIntVector(), + const TIntVector& theElemNums = TIntVector()) + { + return PBallInfo(); + } + + //! A copy-constructor for the MEDWrapped MED Balls representation + virtual + PBallInfo + CrBallInfo(const PMeshInfo& theMeshInfo, + const PBallInfo& theInfo) + { + return PBallInfo(); + } + + //! Read a MEDWrapped MED Balls representation from defined MED file + /*! This feature is supported since version 3.0 */ + virtual + PBallInfo + GetPBallInfo(const PMeshInfo& theMeshInfo); + + //---------------------------------------------------------------------------- + //! Read number of MED FIELDS in defined MED Mesh + virtual + TInt + GetNbFields(TErr* theErr = NULL) = 0; + + //! Read number of components for the defined MED FIELD by its order number + virtual + TInt + GetNbComp(TInt theFieldId, + TErr* theErr = NULL) = 0; + + //! Read MEDWrapper MED FIELD representation by its order number + virtual + void + GetFieldInfo(TInt theFieldId, + TFieldInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Write MEDWrapper MED FIELD representation into defined MED file + virtual + void + SetFieldInfo(const TFieldInfo& theInfo, + TErr* theErr = NULL) = 0; + + + //! Creates a MEDWrapper MED FIELD representation + virtual + PFieldInfo + CrFieldInfo(const PMeshInfo& theMeshInfo, + TInt theNbComp = 0, + ETypeChamp theType = eFLOAT64, + const std::string& theValue = "", + EBooleen theIsLocal = eVRAI, + TInt theNbRef = 1) = 0; + + //! A copy-constructor for the MEDWrapper MED FIELD representation + virtual + PFieldInfo + CrFieldInfo(const PMeshInfo& theMeshInfo, + const PFieldInfo& theInfo) = 0; + + //! Read a MEDWrapper MED FIELD representation from defined MED file + PFieldInfo + GetPFieldInfo(const PMeshInfo& theMeshInfo, + TInt theId, + TErr* theErr = NULL); + + + //---------------------------------------------------------------------------- + //! Read number of MED GAUSS in defined MED Mesh + /*! This feature is support only for version of 2.2 and higher */ + virtual + TInt + GetNbGauss(TErr* theErr = NULL) + { + return TInt(); + } + + //! Read brief MED GAUSS information by its order number from defined MED Mesh + /*! This feature is support only for version of 2.2 and higher */ + virtual + TGaussInfo::TInfo + GetGaussPreInfo(TInt theId, + TErr* theErr = NULL) + { + return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 ); + } + + //! Read a MEDWrapper MED GAUSS representation by its order number from defined MED file + /*! This feature is support only for version of 2.2 and higher */ + virtual + void + GetGaussInfo(TInt theId, + TGaussInfo& theInfo, + TErr* theErr = NULL) + {} + + //! Creates a MEDWrapper MED GAUSS representation + /*! This feature is support only for version of 2.2 and higher */ + virtual + PGaussInfo + CrGaussInfo(const TGaussInfo::TInfo& theInfo, + EModeSwitch theMode = eFULL_INTERLACE) = 0; + + + //---------------------------------------------------------------------------- + //! Read number of MED TIMESTAMPS in defined MED Mesh + /*! + By the way some additional information can be obtained: + - to what MED ENTITY the MED TIMESTAMP conntected to; + - on what geometrical types the MED TIMESTAMP defined to. + */ + virtual + TInt + GetNbTimeStamps(const TFieldInfo& theInfo, + const TEntityInfo& theEntityInfo, + EEntiteMaillage& theEntity, + TGeom2Size& theGeom2Size, + TErr* theErr = NULL) = 0; + + //! Read MEDWrapper MED TIMESTAMP representation by its order number + virtual + void + GetTimeStampInfo(TInt theTimeStampId, + TTimeStampInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Creates a MEDWrapper MED TIMESTAMP representation + virtual + PTimeStampInfo + CrTimeStampInfo(const PFieldInfo& theFieldInfo, + EEntiteMaillage theEntity, + const TGeom2Size& theGeom2Size, + const TGeom2NbGauss& theGeom2NbGauss = TGeom2NbGauss(), + TInt theNumDt = 0, + TInt theNumOrd = 0, + TFloat theDt = 0, + const std::string& theUnitDt = "", + const TGeom2Gauss& theGeom2Gauss = TGeom2Gauss()) = 0; + + //! A copy-constructor for the MEDWrapper MED TIMESTAMP representation + virtual + PTimeStampInfo + CrTimeStampInfo(const PFieldInfo& theFieldInfo, + const PTimeStampInfo& theInfo) = 0; + + //! Read MEDWrapper MED TIMESTAMP representation by its order number + PTimeStampInfo + GetPTimeStampInfo(const PFieldInfo& theFieldInfo, + EEntiteMaillage theEntity, + const TGeom2Size& theGeom2Size, + TInt theId, + TErr* theErr = NULL); + + + //---------------------------------------------------------------------------- + //! Read number of MED PROFILES in defined MED Mesh + virtual + TInt + GetNbProfiles(TErr* theErr = NULL) = 0; + + //! Read brief MED PROFILE information by its order number from defined MED Mesh + virtual + TProfileInfo::TInfo + GetProfilePreInfo(TInt theId, + TErr* theErr = NULL) = 0; + + //! Read a MEDWrapper MED PROFILE representation by its order number from defined MED file + virtual + void + GetProfileInfo(TInt theId, + TProfileInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Creates a MEDWrapper MED PROFILE representation + virtual + PProfileInfo + CrProfileInfo(const TProfileInfo::TInfo& theInfo, + EModeProfil theMode = eCOMPACT) = 0; + + //! Write a MEDWrapper MED PROFILE representation + virtual + void + SetProfileInfo(const TProfileInfo& theInfo, + TErr* theErr = NULL) = 0; + + //! Read a MEDWrapper MED PROFILE representation by its order number from defined MED file + PProfileInfo + GetPProfileInfo(TInt theId, + EModeProfil theMode = eCOMPACT, + TErr* theErr = NULL); + + + //---------------------------------------------------------------------------- + //! Read the values for MEDWrapper MED TIEMSTAMP from defined MED file + virtual + void + GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue, + const TMKey2Profile& theMKey2Profile, + const TKey2Gauss& theKey2Gauss, + TErr* theErr = NULL) = 0; + + //! Write the values for MEDWrapper MED TIEMSTAMP to defined MED file + virtual + void + SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue, + TErr* theErr = NULL) = 0; + + //! Creates the values for MEDWrapper MED TIEMSTAMP representation + virtual + PTimeStampValueBase + CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + ETypeChamp theTypeChamp, + const TGeom2Profile& theGeom2Profile = TGeom2Profile(), + EModeSwitch theMode = eFULL_INTERLACE) = 0; + + //! Creates the values for MEDWrapper MED TIEMSTAMP representation + virtual + PTimeStampValueBase + CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + const TGeom2Profile& theGeom2Profile = TGeom2Profile(), + EModeSwitch theMode = eFULL_INTERLACE); + + //! A copy-constructor for the values for MEDWrapper MED TIEMSTAMP representation + virtual + PTimeStampValueBase + CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + const PTimeStampValueBase& theInfo, + ETypeChamp theTypeChamp) = 0; + + //! A copy-constructor for the values for MEDWrapper MED TIEMSTAMP representation + virtual + PTimeStampValueBase + CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + const PTimeStampValueBase& theInfo); + + //! Read the values for MEDWrapper MED TIEMSTAMP from defined MED file + PTimeStampValueBase + GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo, + const TMKey2Profile& theMKey2Profile, + const TKey2Gauss& theKey2Gauss, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + // Backward compatibility declarations + //! Read the values for MEDWrapper MED TIEMSTAMP from defined MED file + virtual + void + GetTimeStampVal(const PTimeStampVal& theVal, + const TMKey2Profile& theMKey2Profile, + const TKey2Gauss& theKey2Gauss, + TErr* theErr = NULL); + + //! Write the values for MEDWrapper MED TIEMSTAMP to defined MED file + virtual + void + SetTimeStamp(const PTimeStampVal& theVal, + TErr* theErr = NULL); + + //! Creates the values for MEDWrapper MED TIEMSTAMP representation + virtual + PTimeStampVal + CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const TGeom2Profile& theGeom2Profile = TGeom2Profile(), + EModeSwitch theMode = eFULL_INTERLACE); + + //! A copy-constructor for the values for MEDWrapper MED TIEMSTAMP representation + virtual + PTimeStampVal + CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const PTimeStampVal& theInfo); + + //! Read the values for MEDWrapper MED TIEMSTAMP from defined MED file + PTimeStampVal + GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const TMKey2Profile& theMKey2Profile, + const TKey2Gauss& theKey2Gauss, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + //! Read a MEDWrapper MED Grille representation from defined MED file + /*! This feature is support only for version of 2.2 and higher */ + PGrilleInfo + GetPGrilleInfo(const PMeshInfo& theMeshInfo); + + //! Read a MEDWrapper MED Grille representation from defined MED file + /*! This feature is support only for version of 2.2 and higher */ + PGrilleInfo + GetPGrilleInfo(const PMeshInfo& theMeshInfo, + const PGrilleInfo& theInfo); + + //! Read a MEDWrapper MED Grille representation from defined MED file + /*! This feature is support only for version of 2.2 and higher */ + virtual + void + GetGrilleInfo(TGrilleInfo& theInfo, + TErr* theErr = NULL) + {} + + //! Write the MEDWrapper MED Grille representation into defined MED file + /*! This feature is support only for version of 2.2 and higher */ + virtual + void + SetGrilleInfo(const TGrilleInfo& theInfo, + TErr* theErr = NULL) + {} + + /*! This feature is support only for version of 2.2 and higher */ + virtual + PGrilleInfo + CrGrilleInfo(const PMeshInfo& theMeshInfo, + const PGrilleInfo& theGrilleInfo) + { + return PGrilleInfo(); + } + + /*! This feature is support only for version of 2.2 and higher */ + virtual + PGrilleInfo + CrGrilleInfo(const PMeshInfo& theMeshInfo) + { + return PGrilleInfo(); + } + + /*! This feature is support only for version of 2.2 and higher */ + virtual + PGrilleInfo + CrGrilleInfo(const PMeshInfo& theMeshInfo, + const EGrilleType& type) + { + return PGrilleInfo(); + } + + /*! This feature is support only for version of 2.2 and higher */ + virtual + PGrilleInfo + CrGrilleInfo(const PMeshInfo& theMeshInfo, + const EGrilleType& type, + const TInt& nbNodes) + { + return PGrilleInfo(); + } + + /*! This feature is support only for version of 2.2 and higher */ + virtual + PGrilleInfo + CrGrilleInfo(const PMeshInfo& theMeshInfo, + const EGrilleType& type, + const MED::TIntVector& nbNodeVec) + { + return PGrilleInfo(); + } + + /*! This feature is support only for version of 2.2 and higher */ + virtual + void + GetGrilleType(const TMeshInfo& theMeshInfo, + EGrilleType& type, + TErr* theErr = NULL) + { + } + + }; + + + //---------------------------------------------------------------------------- + //! This class provide thread-safety for MEDWrapper interaction + class MEDWRAPPER_EXPORT TLockProxy + { + TLockProxy& operator=(const TLockProxy& ); + TWrapper* myWrapper; + + public: + TLockProxy(TWrapper* theWrapper); + + ~TLockProxy(); + + TWrapper * operator-> () const; + }; + + + //---------------------------------------------------------------------------- + //! To specialize the SharedPtr for TWrapper + template<> + class MEDWRAPPER_EXPORT SharedPtr: public boost::shared_ptr + { + public: + SharedPtr() {} + + template + explicit SharedPtr(Y * p): + boost::shared_ptr(p) + {} + + template + SharedPtr(SharedPtr const & r): + boost::shared_ptr(r,boost::detail::dynamic_cast_tag()) + {} + + template + SharedPtr& + operator=(SharedPtr const & r) + { + boost::shared_ptr(r,boost::detail::dynamic_cast_tag()).swap(*this); + return *this; + } + + template + SharedPtr& + operator()(Y * p) // Y must be complete + { + return operator=(SharedPtr(p)); + } + + template + SharedPtr& + operator()(SharedPtr const & r) // Y must be complete + { + return operator=(SharedPtr(r)); + } + + TLockProxy operator-> () const // never throws + { + return TLockProxy(this->get()); + } + + protected: + operator const TWrapper& () const; + + operator TWrapper& (); + + TWrapper& operator* () const; + + TWrapper * get() const // never throws + { + return boost::shared_ptr::get(); + } + }; + + //---------------------------------------------------------------------------- + typedef SharedPtr PWrapper; +} + +#endif diff --git a/src/MEDWrapper/Base/MED_WrapperBase.hxx b/src/MEDWrapper/Base/MED_WrapperBase.hxx new file mode 100755 index 000000000..128e4e89b --- /dev/null +++ b/src/MEDWrapper/Base/MED_WrapperBase.hxx @@ -0,0 +1,46 @@ +// 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 +// +// File : MED_WrapperBase.hxx +// Author : Alexander A. BORODIN +// +#ifndef _MED_WrapperBase_HXX_ +#define _MED_WrapperBase_HXX_ + +#ifdef WIN32 + #if defined MEDWRAPPER_BASE_EXPORTS || defined MEDWrapperBase_EXPORTS + #if defined WIN32 + #define MEDWRAPPER_EXPORT __declspec( dllexport ) + #else + #define MEDWRAPPER_EXPORT + #endif + #else + #if defined WIN32 + #define MEDWRAPPER_EXPORT __declspec( dllimport ) + #else + #define MEDWRAPPER_EXPORT + #endif + #endif +#else + #define MEDWRAPPER_EXPORT +#endif + +#endif diff --git a/src/MEDWrapper/Base/Makefile.am b/src/MEDWrapper/Base/Makefile.am new file mode 100644 index 000000000..8594ce7fc --- /dev/null +++ b/src/MEDWrapper/Base/Makefile.am @@ -0,0 +1,52 @@ +# Copyright (C) 2007-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 $(top_srcdir)/adm_local/unix/make_common_starter.am + +lib_LTLIBRARIES= libMEDWrapperBase.la + +salomeinclude_HEADERS= \ + MED_Common.hxx \ + MED_Vector.hxx \ + MED_SharedPtr.hxx \ + MED_SliceArray.hxx \ + MED_Wrapper.hxx \ + MED_TWrapper.hxx \ + MED_Structures.hxx \ + MED_TStructures.hxx \ + MED_Algorithm.hxx \ + MED_GaussUtils.hxx \ + MED_CoordUtils.hxx \ + MED_Utilities.hxx \ + MED_GaussDef.hxx \ + MED_WrapperBase.hxx + +dist_libMEDWrapperBase_la_SOURCES= \ + MED_Structures.cxx \ + MED_Wrapper.cxx \ + MED_Algorithm.cxx \ + MED_GaussUtils.cxx \ + MED_CoordUtils.cxx \ + MED_Utilities.cxx \ + MED_GaussDef.cxx + +libMEDWrapperBase_la_CPPFLAGS= $(BOOST_CPPFLAGS) $(HDF5_INCLUDES) -D@MACHINE@ +libMEDWrapperBase_la_CPPFLAGS+= -I$(KERNEL_ROOT_DIR)/include/salome +libMEDWrapperBase_la_CPPFLAGS+= $(MED_CPPFLAGS) +libMEDWrapperBase_la_LDFLAGS= $(BOOST_LIB_THREAD) $(BOOST_LIB_SYSTEM) $(BOOST_LIB_DATE_TIME) diff --git a/src/MEDWrapper/CMakeLists.txt b/src/MEDWrapper/CMakeLists.txt new file mode 100644 index 000000000..90ed5a20a --- /dev/null +++ b/src/MEDWrapper/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (C) 2012-2013 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 +# 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 +# + +ADD_SUBDIRECTORY(Base) +ADD_SUBDIRECTORY(V2_2) +ADD_SUBDIRECTORY(Factory) diff --git a/src/MEDWrapper/Factory/CMakeLists.txt b/src/MEDWrapper/Factory/CMakeLists.txt new file mode 100644 index 000000000..08cd75cef --- /dev/null +++ b/src/MEDWrapper/Factory/CMakeLists.txt @@ -0,0 +1,57 @@ +# Copyright (C) 2012-2013 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 +# 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_DIRECTORIES( + ${HDF5_INCLUDE_DIRS} + ${BOOST_INCLUDE_DIRS} + ${MED3_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR}/../Base + ${CMAKE_CURRENT_SOURCE_DIR}/../V2_2 + ) + +IF(MED_ENABLE_KERNEL) + INCLUDE_DIRECTORIES(${KERNEL_ROOT_DIR}/include/salome) +ELSE(MED_ENABLE_KERNEL) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/adm_local_without_kernel) +ENDIF(MED_ENABLE_KERNEL) + +SET(MEDWrapper_SOURCES + MED_Factory.cxx +) + +SET(mprint_version_SOURCES + mprint_version.cxx + ) + +ADD_LIBRARY(MEDWrapper SHARED ${MEDWrapper_SOURCES}) +SET_TARGET_PROPERTIES(MEDWrapper PROPERTIES COMPILE_FLAGS "${BOOST_DEFINITIONS} ${MED3_DEFINITIONS} ${PLATFORM_DEFINITIONS}") +TARGET_LINK_LIBRARIES(MEDWrapper MEDWrapper_V2_2) +INSTALL(TARGETS MEDWrapper DESTINATION ${MED_salomelib_LIBS}) + +ADD_EXECUTABLE(mprint_version ${mprint_version_SOURCES}) +SET_TARGET_PROPERTIES(mprint_version PROPERTIES COMPILE_FLAGS "${BOOST_DEFINITIONS} ${MED3_DEFINITIONS} ${PLATFORM_DEFINITIONS}") +TARGET_LINK_LIBRARIES(mprint_version MEDWrapper MEDWrapper_V2_2 MEDWrapperBase ${BOOST_LIBS} ${MED3_LIBS_C_ONLY}) + +ADD_EXECUTABLE(MED_Test ${mprint_version_SOURCES}) +SET_TARGET_PROPERTIES(MED_Test PROPERTIES COMPILE_FLAGS "${BOOST_DEFINITIONS} ${MED3_DEFINITIONS} ${PLATFORM_DEFINITIONS}") +TARGET_LINK_LIBRARIES(MED_Test MEDWrapper MEDWrapper_V2_2 MEDWrapperBase ${BOOST_LIBS}) + +FILE(GLOB MEDWrapper_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") +INSTALL(FILES ${MEDWrapper_HEADERS_HXX} DESTINATION ${MED_salomeinclude_HEADERS}) +INSTALL(TARGETS mprint_version MED_Test DESTINATION ${MED_salomebin_BINS}) diff --git a/src/MEDWrapper/Factory/MED_Factory.cxx b/src/MEDWrapper/Factory/MED_Factory.cxx new file mode 100644 index 000000000..7232ee08d --- /dev/null +++ b/src/MEDWrapper/Factory/MED_Factory.cxx @@ -0,0 +1,164 @@ +// 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 "MED_Factory.hxx" +#include "MED_Utilities.hxx" +#include "MED_V2_2_Wrapper.hxx" + +#include +#include + +extern "C" +{ +#include +#ifndef WIN32 + #include +#endif +} + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +namespace MED +{ + + EVersion GetVersionId(const std::string& theFileName, + bool theDoPreCheckInSeparateProcess) + { + INITMSG(MYDEBUG,"GetVersionId - theFileName = '"<&1 > /dev/null"; + + std::string aCommand = aStr.str(); + int aStatus = system(aCommand.c_str()); + + BEGMSG(MYDEBUG,"aCommand = '"<GetNbProfiles() = "<GetNbProfiles()<GetNbMeshes(); + BEGMSG(MYDEBUG,"GetNbMeshes() = "<GetPMeshInfo(iMesh); + INITMSG(MYDEBUG,"aMeshInfo->GetName() = '"<GetName()<<"'"<GetEntityInfo(aMeshInfo); + + TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo = + GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,aEntityInfo); + + TFieldInfo2TimeStampInfoSet aFieldInfo2TimeStampInfoSet = + GetFieldInfo2TimeStampInfoSet(aMed,aMeshInfo,aEntityInfo); + + TEntite2TFieldInfo2TimeStampInfoSet anEntite2TFieldInfo2TimeStampInfoSet = + GetEntite2TFieldInfo2TimeStampInfoSet(aFieldInfo2TimeStampInfoSet); + + TEntite2TFieldInfo2TimeStampInfoSet::const_iterator anEntite2TFieldInfo2TimeStampInfoSetIter = + anEntite2TFieldInfo2TimeStampInfoSet.begin(); + for(; anEntite2TFieldInfo2TimeStampInfoSetIter != anEntite2TFieldInfo2TimeStampInfoSet.end(); anEntite2TFieldInfo2TimeStampInfoSetIter++){ + const TFieldInfo2TimeStampInfoSet& aFieldInfo2TimeStampInfoSet = anEntite2TFieldInfo2TimeStampInfoSetIter->second; + TFieldInfo2TimeStampInfoSet::const_iterator aFieldInfo2TimeStampInfoSetIter = aFieldInfo2TimeStampInfoSet.begin(); + for(; aFieldInfo2TimeStampInfoSetIter != aFieldInfo2TimeStampInfoSet.end(); aFieldInfo2TimeStampInfoSetIter++){ + PFieldInfo aFieldInfo = aFieldInfo2TimeStampInfoSetIter->first; + INITMSG(MYDEBUG, + "GetPFieldInfo "<< + "- aName = '"<GetName()<<"'"<< + "; aType = "<GetType()<< + "; aNbComp = "<GetNbComp()<< + std::endl); + const TTimeStampInfoSet& aTimeStampInfoSet = aFieldInfo2TimeStampInfoSetIter->second; + TTimeStampInfoSet::const_iterator aTimeStampInfoSettIter = aTimeStampInfoSet.begin(); + for(; aTimeStampInfoSettIter != aTimeStampInfoSet.end(); aTimeStampInfoSettIter++){ + PTimeStampInfo aTimeStampInfo = *aTimeStampInfoSettIter; + INITMSG(MYDEBUG, + "GetPTimeStampInfo "<< + "- anEntity = "<GetEntity()<< + "; aNumDt = "<GetNumDt()<< + std::endl); + PTimeStampValueBase aTimeStampValue = + aMed->GetPTimeStampValue(aTimeStampInfo, + aMKey2Profile, + aKey2Gauss); + } + } + } + + continue; + + TFamilyInfoSet aFamilyInfoSet = GetFamilyInfoSet(aMed,aMeshInfo); + + TEntity2FamilySet aEntity2FamilySet = + GetEntity2FamilySet(aMed,anEntity2TGeom2ElemInfo,aFamilyInfoSet); + + TGroupInfo aGroupInfo = GetGroupInfo(aFamilyInfoSet); + + PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo); + TEntity2TGeom2ElemInfo::const_iterator anIter = anEntity2TGeom2ElemInfo.begin(); + for(; anIter != anEntity2TGeom2ElemInfo.end(); anIter++){ + const EEntiteMaillage& anEntity = anIter->first; + if(anEntity != eNOEUD){ + const TGeom2ElemInfo& aGeom2ElemInfo = anIter->second; + TKey2Gauss::const_iterator anIter2 = aKey2Gauss.begin(); + for(; anIter2 != aKey2Gauss.end(); anIter2++){ + const TGaussInfo::TKey& aKey = anIter2->first; + EGeometrieElement aGeom = boost::get<0>(aKey); + TGeom2ElemInfo::const_iterator anIter3 = aGeom2ElemInfo.find(aGeom); + if(anIter3 != aGeom2ElemInfo.end()){ + if(PCellInfo aCellInfo = anIter3->second){ + PGaussInfo aGaussInfo = anIter2->second; + TGaussCoord aGaussCoord; + GetGaussCoord3D(aGaussInfo,aCellInfo,aNodeInfo,aGaussCoord); + } + } + } + } + } + + } + } + MSG(MYDEBUG,"OK"); +} + + +void CopyMed(const PWrapper& theMed, + const PWrapper& theMed2, + int theIncr) +{ + TKey2Gauss aKey2Gauss = GetKey2Gauss(theMed); + TMKey2Profile aMKey2Profile = GetMKey2Profile(theMed); + + TInt aNbMeshes = theMed->GetNbMeshes(); + MSG(MYDEBUG,"aNbMeshes = "<GetPMeshInfo(iMesh+1); +#ifdef _DEBUG_ + TInt aDim = aMeshInfo->myDim; + aName = aMeshInfo->GetName(); + INITMSG(MYDEBUG,"GetMeshInfo - aName = '"<CrMeshInfo(aMeshInfo); + if(MYWRITEDEBUG){ + aName = aMeshInfo2->GetName(); + + aName[0] += theIncr; + aMeshInfo2->SetName(aName); + theMed2->SetMeshInfo(aMeshInfo2); + BEGMSG(MYDEBUG,"aNbMeshes2 = "<GetNbMeshes()<<"\n"); + } + + TEntityInfo aEntityInfo = theMed->GetEntityInfo(aMeshInfo); + + //continue; + + TInt aNbFields = theMed->GetNbFields(); + MSG(MYDEBUG,"GetNbFields() = "<GetPFieldInfo(aMeshInfo,iField+1); +#ifdef _DEBUG_ + TInt aNbComp = aFieldInfo->GetNbComp(); + INITMSG(MYDEBUG,"aName = '"<GetName()<<"'; aNbComp = "<CrFieldInfo(aMeshInfo2,aFieldInfo); + + if(MYWRITEDEBUG){ + aName = aFieldInfo->GetName(); + aName[0] += theIncr; + aFieldInfo2->SetName(aName); + theMed2->SetFieldInfo(aFieldInfo2); + } + + EEntiteMaillage anEntity; + TGeom2Size aGeom2Size; + TInt aNbTimeStamps = + theMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,anEntity,aGeom2Size); + { + INITMSG(MYDEBUG,"GetNbTimeStamps = "<GetPTimeStampInfo(aFieldInfo,anEntity,aGeom2Size,iTimeStamp+1); +#ifdef _DEBUG_ + TInt aNumDt = aTimeStampInfo->GetNumDt(); + INITMSG(MYDEBUG,"aNumDt = "<CrTimeStampInfo(aFieldInfo2,aTimeStampInfo); + + PTimeStampValueBase aTimeStampValue = + theMed->GetPTimeStampValue(aTimeStampInfo, + aMKey2Profile, + aKey2Gauss); + + PTimeStampValueBase aTimeStampValue2 = + theMed->CrTimeStampValue(aTimeStampInfo2, + aTimeStampValue); + + if(MYWRITEDEBUG) theMed2->SetTimeStamp(aTimeStampValue2); + } + } + } + + TInt aNbFam = theMed->GetNbFamilies(aMeshInfo); + MSG(MYDEBUG,"GetNbFamilies() = "<GetPFamilyInfo(aMeshInfo,iFam+1); + TInt aNbGroup = aFamilyInfo->GetNbGroup(); +#ifdef _DEBUG_ + TInt aNbAttr = aFamilyInfo->GetNbAttr(); +#endif + TInt anId = aFamilyInfo->GetId(); + if(anId == 0) + continue; + + aName = aFamilyInfo->GetName(); +#ifdef _DEBUG_ + INITMSG(MYDEBUG,"aName = '"<CrFamilyInfo(aMeshInfo2,aFamilyInfo); + for(TInt iGroup = 0; iGroup < aNbGroup; iGroup++){ + aName = aFamilyInfo->GetGroupName(iGroup); + INITMSG(MYDEBUG,"aGroupName = '"<SetGroupName(iGroup,aName); + } + + if(MYWRITEDEBUG){ + aName = aFamilyInfo->GetName(); + aName[0] += theIncr; + aFamilyInfo2->SetName(aName); + theMed2->SetFamilyInfo(aFamilyInfo2); + INITMSG(MYDEBUG,"GetNbFamilies = "<GetNbFamilies(aMeshInfo2)<GetPNodeInfo(aMeshInfo); + PNodeInfo aNodeInfo2 = theMed->CrNodeInfo(aMeshInfo2,aNodeInfo); + if(MYWRITEDEBUG) theMed2->SetNodeInfo(aNodeInfo2); + continue; + } + TGeom2Size& aGeom2Size = anEntityInfoIter->second; + TGeom2Size::iterator aGeomIter = aGeom2Size.begin(); + for(; aGeomIter != aGeom2Size.end(); aGeomIter++){ + const EGeometrieElement& aGeom = aGeomIter->first; +#ifdef _DEBUG_ + const TInt& aNbElem = aGeomIter->second; + INITMSG(MYDEBUG,"aGeom = "<GetPPolygoneInfo(aMeshInfo,anEntity,aGeom); + PPolygoneInfo aPolygoneInfo2 = theMed->CrPolygoneInfo(aMeshInfo2,aPolygoneInfo); + if(MYWRITEDEBUG) theMed2->SetPolygoneInfo(aPolygoneInfo2); + break; + } + case ePOLYEDRE: { + PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom); + PPolyedreInfo aPolyedreInfo2 = theMed->CrPolyedreInfo(aMeshInfo2,aPolyedreInfo); + if(MYWRITEDEBUG) theMed2->SetPolyedreInfo(aPolyedreInfo2); + break; + } + default: + PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,anEntity,aGeom); + PCellInfo aCellInfo2 = theMed2->CrCellInfo(aMeshInfo2,aCellInfo); + if(MYWRITEDEBUG) theMed2->SetCellInfo(aCellInfo2); + } + } + } + + } + MSG(MYDEBUG,"OK"); +} + + +void CopyMed(const std::string& theFileName, + const std::string& theFileName2, + MED::EVersion theVersion, + int theNbCopy) +{ + MSG(MYDEBUG,"CopyMed - theFileName = '"< + +#include +#include + +int main (int argc, char **argv) +{ + med_idt aFid = MEDfileOpen(argv[1],MED_ACC_RDONLY); + if(aFid < 0) + exit(1); + + med_int aMajor, aMinor, aRelease; + med_err aRet = MEDfileNumVersionRd(aFid,&aMajor,&aMinor,&aRelease); + MEDfileClose(aFid); + if(aRet < 0) { + // VSR: simulate med 2.3.6 behavior, med file version is assumed to 2.1 + aMajor=2; + aMinor=aRelease=-1; + } + + printf("%d.%d.%d\n",aMajor,aMinor,aRelease); +} diff --git a/src/MEDWrapper/Makefile.am b/src/MEDWrapper/Makefile.am new file mode 100644 index 000000000..8ebdfd64a --- /dev/null +++ b/src/MEDWrapper/Makefile.am @@ -0,0 +1,23 @@ +# Copyright (C) 2007-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 $(top_srcdir)/adm_local/unix/make_common_starter.am + +SUBDIRS = Base V2_2 Factory + +DIST_SUBDIRS = Base V2_2 Factory diff --git a/src/MEDWrapper/V2_2/CMakeLists.txt b/src/MEDWrapper/V2_2/CMakeLists.txt new file mode 100644 index 000000000..7bbe89e65 --- /dev/null +++ b/src/MEDWrapper/V2_2/CMakeLists.txt @@ -0,0 +1,43 @@ +# Copyright (C) 2012-2013 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 +# 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_DIRECTORIES( + ${MED3_INCLUDE_DIRS} + ${HDF5_INCLUDE_DIRS} + ${BOOST_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR}/../Base + ) + +SET(MEDWrapper_V2_2_SOURCES + MED_V2_2_Wrapper.cxx + ) + +IF(MED_ENABLE_KERNEL) + INCLUDE_DIRECTORIES(${KERNEL_ROOT_DIR}/include/salome) +ELSE(MED_ENABLE_KERNEL) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/adm_local_without_kernel) +ENDIF(MED_ENABLE_KERNEL) + +ADD_LIBRARY(MEDWrapper_V2_2 SHARED ${MEDWrapper_V2_2_SOURCES}) +SET_TARGET_PROPERTIES(MEDWrapper_V2_2 PROPERTIES COMPILE_FLAGS "${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${BOOST_DEFINITIONS} ${PLATFORM_DEFINITIONS}") +TARGET_LINK_LIBRARIES(MEDWrapper_V2_2 MEDWrapperBase ${MED3_LIBS_C_ONLY} ${HDF5_LIBS}) +INSTALL(TARGETS MEDWrapper_V2_2 DESTINATION ${MED_salomelib_LIBS}) + +FILE(GLOB MEDWrapper_V2_2_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") +INSTALL(FILES ${MEDWrapper_V2_2_HEADERS_HXX} DESTINATION ${MED_salomeinclude_HEADERS}) diff --git a/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx new file mode 100644 index 000000000..a7dc74a85 --- /dev/null +++ b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx @@ -0,0 +1,2878 @@ +// 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 "MED_V2_2_Wrapper.hxx" +#include "MED_Algorithm.hxx" +#include "MED_Utilities.hxx" + +extern "C" +{ +#include +#include +} + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +// #else +// static int MYDEBUG = 0; +#endif + + + +namespace MED +{ + template<> + TInt + GetDESCLength() + { + return 200; + } + + template<> + TInt + GetIDENTLength() + { + return 8; + } + + template<> + TInt + GetNOMLength() + { + return 64; + } + + template<> + TInt + GetLNOMLength() + { + return 80; + } + + template<> + TInt + GetPNOMLength() + { + return 16; + } + + template<> + void + GetVersionRelease(TInt& majeur, TInt& mineur, TInt& release) + { + majeur=MED_MAJOR_NUM; + mineur=MED_MINOR_NUM; + release=MED_RELEASE_NUM; + } + + template<> + TInt + GetNbConn(EGeometrieElement typmai, + EEntiteMaillage typent, + TInt mdim) + { + return typmai%100; + } + + namespace V2_2 + { + + //--------------------------------------------------------------- + class TFile{ + TFile(); + TFile(const TFile&); + + public: + TFile(const std::string& theFileName): + myCount(0), + myFid(0), + myFileName(theFileName) + {} + + ~TFile() + { + Close(); + } + + void + Open(EModeAcces theMode, TErr* theErr = NULL) + { + if(myCount++ == 0){ + const char* aFileName = myFileName.c_str(); + myFid = MEDfileOpen(aFileName,med_access_mode(theMode)); + } + if(theErr) + *theErr = TErr(myFid); + else if(myFid < 0) + EXCEPTION(std::runtime_error,"TFile - MEDfileOpen('"<Open(theMode,theErr); + } + + ~TFileWrapper() + { + myFile->Close(); + } + }; + + + //--------------------------------------------------------------- + TVWrapper::TVWrapper(const std::string& theFileName): + myFile(new TFile(theFileName)) + {} + + + //---------------------------------------------------------------------------- + TInt + TVWrapper + ::GetNbMeshes(TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return -1; + + return MEDnMesh(myFile->Id()); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetMeshInfo(TInt theMeshId, + MED::TMeshInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + TValueHolder aMeshName(theInfo.myName); + TValueHolder aDim(theInfo.myDim); + TValueHolder aSpaceDim(theInfo.mySpaceDim); + TValueHolder aType(theInfo.myType); + char dtunit[MED_SNAME_SIZE+1]; + med_sorting_type sorttype; + med_int nstep; + med_axis_type at; + int naxis=MEDmeshnAxis(myFile->Id(),theMeshId); + char *axisname=new char[naxis*MED_SNAME_SIZE+1]; + char *axisunit=new char[naxis*MED_SNAME_SIZE+1]; + TErr aRet = MEDmeshInfo(myFile->Id(), + theMeshId, + &aMeshName, + &aSpaceDim, + &aDim, + &aType, + &theInfo.myDesc[0], + dtunit, + &sorttype, + &nstep, + &at, + axisname, + axisunit); + delete [] axisname; + delete [] axisunit; + if(aRet < 0) + EXCEPTION(std::runtime_error,"GetMeshInfo - MEDmeshInfo(...)"); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetMeshInfo(const MED::TMeshInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TMeshInfo& anInfo = const_cast(theInfo); + + TValueHolder aMeshName(anInfo.myName); + TValueHolder aDim(anInfo.myDim); + TValueHolder aSpaceDim(anInfo.mySpaceDim); + TValueHolder aType(anInfo.myType); + TValueHolder aDesc(anInfo.myDesc); + + char *nam=new char[aSpaceDim*MED_SNAME_SIZE+1]; + std::fill(nam,nam+aSpaceDim*MED_SNAME_SIZE+1,'\0'); + char *unit=new char[aSpaceDim*MED_SNAME_SIZE+1]; + std::fill(unit,unit+aSpaceDim*MED_SNAME_SIZE+1,'\0'); + TErr aRet = MEDmeshCr(myFile->Id(), + &aMeshName, + aSpaceDim, + aDim, + aType, + &aDesc, + "", + MED_SORT_DTIT, + MED_CARTESIAN, + nam, + unit); + delete [] nam; + delete [] unit; + + //if(aRet == 0) + // aRet = MEDunvCr(myFile->Id(),&aMeshName); + + INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<(theInfo); + TValueHolder aName(anInfo.myName); + return MEDnFamily(myFile->Id(),&aName); + } + + + //---------------------------------------------------------------------------- + TInt + TVWrapper + ::GetNbFamAttr(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return -1; + + MED::TMeshInfo& anInfo = const_cast(theInfo); + + TValueHolder aName(anInfo.myName); + + return MEDnFamily23Attribute(myFile->Id(),&aName,theFamId); + } + + + //---------------------------------------------------------------------------- + TInt + TVWrapper + ::GetNbFamGroup(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return -1; + + MED::TMeshInfo& anInfo = const_cast(theInfo); + + TValueHolder aName(anInfo.myName); + + return MEDnFamilyGroup(myFile->Id(),&aName,theFamId); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetFamilyInfo(TInt theFamId, + MED::TFamilyInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder aFamilyName(theInfo.myName); + TValueHolder aFamilyId(theInfo.myId); + TValueHolder anAttrId(theInfo.myAttrId); + TValueHolder anAttrVal(theInfo.myAttrVal); + TValueHolder anAttrDesc(theInfo.myAttrDesc); + TValueHolder aGroupNames(theInfo.myGroupNames); + + TErr aRet = MEDfamily23Info(myFile->Id(), + &aMeshName, + theFamId, + &aFamilyName, + &anAttrId, + &anAttrVal, + &anAttrDesc, + &aFamilyId, + &aGroupNames); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetFamilyInfo - MEDfamily23Info(...) - "<< + " aMeshInfo.myName = '"<<&aMeshName<< + "'; theFamId = "< aMeshName (aMeshInfo.myName); + TValueHolder anElemNames(theInfo.myElemNames); + TValueHolder anEntity (theEntity); + TValueHolder aGeom (theGeom); + + TErr aRet = MEDmeshEntityNameRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aGeom, + &anElemNames); + + theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ; + + if(theErr) + *theErr = aRet; + } + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetNumeration(TElemInfo& theInfo, + TInt theNb, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + if ( theGeom == eBALL ) + theGeom = GetBallGeom( theInfo.myMeshInfo ); + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder anElemNum(theInfo.myElemNum); + TValueHolder anEntity (theEntity); + TValueHolder aGeom (theGeom); + + TErr aRet = MEDmeshEntityNumberRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aGeom, + &anElemNum); + + theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI; + + if(theErr) + *theErr = aRet; + } + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetFamilies(TElemInfo& theInfo, + TInt theNb, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + if ( theGeom == eBALL ) + theGeom = GetBallGeom( theInfo.myMeshInfo ); + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder aFamNum (theInfo.myFamNum); + TValueHolder anEntity (theEntity); + TValueHolder aGeom (theGeom); + + TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aGeom, + &aFamNum); + + if(aRet < 0) + { +// if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files + { + int aSize = (int)theInfo.myFamNum->size(); + theInfo.myFamNum->clear(); + theInfo.myFamNum->resize(aSize,0); + aRet = 0; + } +// else +// EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS"); + } + if(theErr) + *theErr = aRet; + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetNames(const TElemInfo& theInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr) + { + SetNames(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetNames(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + if ( theGeom == eBALL ) + theGeom = GetBallGeom( theInfo.myMeshInfo ); + + MED::TElemInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + TErr aRet = 0; + if(theInfo.myIsElemNames) + { + TValueHolder aMeshName (aMeshInfo.myName); + TValueHolder anElemNames(anInfo.myElemNames); + TValueHolder anEntity (theEntity); + TValueHolder aGeom (theGeom); + + aRet = MEDmeshEntityNameWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aGeom, + (TInt)anInfo.myElemNames->size(), + &anElemNames); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetNames - MEDmeshEntityNameWr(...)"); + } + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetNumeration(const TElemInfo& theInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr) + { + SetNumeration(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetNumeration(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + if ( theGeom == eBALL ) + theGeom = GetBallGeom( theInfo.myMeshInfo ); + + MED::TElemInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + TErr aRet = 0; + if(theInfo.myIsElemNum) + { + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder anElemNum(anInfo.myElemNum); + TValueHolder anEntity (theEntity); + TValueHolder aGeom (theGeom); + + aRet = MEDmeshEntityNumberWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aGeom, + (TInt)anInfo.myElemNum->size(), + &anElemNum); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetNumeration - MEDmeshEntityNumberWr(...)"); + } + } + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetFamilies(const TElemInfo& theInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr) + { + SetFamilies(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr); + } + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetFamilies(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + if ( theGeom == eBALL ) + theGeom = GetBallGeom( theInfo.myMeshInfo ); + + MED::TElemInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder aFamNum (anInfo.myFamNum); + TValueHolder anEntity (theEntity); + TValueHolder aGeom (theGeom); + + TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aGeom, + (TInt)anInfo.myFamNum->size(), + &aFamNum); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetFamilies - MEDmeshEntityFamilyNumberWr(...)"); + } + + //---------------------------------------------------------------------------- + TInt + TVWrapper + ::GetNbNodes(const MED::TMeshInfo& theMeshInfo, + ETable theTable, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return -1; + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder aTable(theTable); + med_bool chgt,trsf; + return MEDmeshnEntity(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_NODE, + MED_NO_GEOTYPE, + aTable, + MED_NO_CMODE, + &chgt, + &trsf); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetNodeInfo(MED::TNodeInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder aDim(aMeshInfo.myDim); + TValueHolder aCoord(theInfo.myCoord); + TValueHolder aModeSwitch(theInfo.myModeSwitch); + TValueHolder aSystem(theInfo.mySystem); + TValueHolder aCoordNames(theInfo.myCoordNames); + TValueHolder aCoordUnits(theInfo.myCoordUnits); + TValueHolder anElemNames(theInfo.myElemNames); + //TValueHolder anIsElemNames(theInfo.myIsElemNames); + TValueHolder anElemNum(theInfo.myElemNum); + //TValueHolder anIsElemNum(theInfo.myIsElemNum); + TValueHolder aFamNum(theInfo.myFamNum); + TValueHolder aNbElem(theInfo.myNbElem); + + TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + aModeSwitch, + &aCoord); + + TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_NODE, + MED_NO_GEOTYPE , + &aFamNum); + if (aRet2 < 0) + { +// if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files + { + int mySize = (int)theInfo.myFamNum->size(); + theInfo.myFamNum->clear(); + theInfo.myFamNum->resize(mySize,0); + } +// else +// EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)"); + } + + if ( MEDmeshEntityNameRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_NODE, + MED_NO_GEOTYPE , + &anElemNames) < 0) theInfo.myIsElemNames=eFAUX; + + if ( MEDmeshEntityNumberRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_NODE, + MED_NO_GEOTYPE , + &anElemNum) < 0 ) theInfo.myIsElemNum=eFAUX; + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshNodeCoordinateRd(...)"); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetNodeInfo(const MED::TNodeInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TNodeInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + TValueHolder aMeshName (aMeshInfo.myName); + TValueHolder aCoord (anInfo.myCoord); + TValueHolder aModeSwitch (anInfo.myModeSwitch); + TValueHolder aSystem (anInfo.mySystem); + TValueHolder aCoordNames (anInfo.myCoordNames); + TValueHolder aCoordUnits (anInfo.myCoordUnits); + TValueHolder anElemNames (anInfo.myElemNames); + TValueHolder anIsElemNames(anInfo.myIsElemNames); + TValueHolder anElemNum (anInfo.myElemNum); + TValueHolder anIsElemNum (anInfo.myIsElemNum); + TValueHolder aFamNum (anInfo.myFamNum); + TValueHolder aNbElem (anInfo.myNbElem); + + TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_NO_DT, + aModeSwitch, + aNbElem, + &aCoord); + + MEDmeshEntityFamilyNumberWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_NODE, + MED_NO_GEOTYPE, + aNbElem, + &aFamNum); + if(anIsElemNames) + MEDmeshEntityNameWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_NODE, + MED_NO_GEOTYPE, + aNbElem, + &anElemNames); + if(anIsElemNum) + MEDmeshEntityNumberWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_NODE, + MED_NO_GEOTYPE, + aNbElem, + &anElemNum); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetNodeInfo - MEDmeshNodeCoordinateWr(...)"); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetNodeInfo(const MED::TNodeInfo& theInfo, + TErr* theErr) + { + TErr aRet; + SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet); + + if(aRet < 0) + SetNodeInfo(theInfo,eLECTURE_AJOUT,&aRet); + + if(theErr) + *theErr = aRet; + } + + + //----------------------------------------------------------------- + void + TVWrapper + ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder anIndex(theInfo.myIndex); + TInt aNbElem = (TInt)theInfo.myElemNum->size(); + TValueHolder aConn(theInfo.myConn); + TValueHolder anEntity(theInfo.myEntity); + TValueHolder aConnMode(theInfo.myConnMode); + + TErr aRet; + aRet = MEDmeshPolygonRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aConnMode, + &anIndex, + &aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolygonRd(...)"); + + if(theInfo.myIsElemNames){ + GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + } + + if(theInfo.myIsElemNum){ + GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + } + + GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + } + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, + TErr* theErr) + { + SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr); + } + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TPolygoneInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder anIndex(anInfo.myIndex); + TValueHolder aConn(anInfo.myConn); + TValueHolder anEntity(anInfo.myEntity); + TValueHolder aConnMode(anInfo.myConnMode); + + TErr aRet = MEDmeshPolygonWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_UNDEF_DT, + anEntity, + aConnMode, + anInfo.myNbElem + 1, + &anIndex, + &aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetPolygoneInfo - MEDmeshPolygonWr(...)"); + + SetNames(anInfo,theInfo.myEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + + SetNumeration(anInfo,theInfo.myEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + + SetFamilies(anInfo,theInfo.myEntity,ePOLYGONE,&aRet); + if(theErr) + *theErr = aRet; + } + + //---------------------------------------------------------------------------- + TInt + TVWrapper + ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode, + TErr* theErr) + { + return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr); + } + + //---------------------------------------------------------------------------- + TInt + TVWrapper + ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return 0; + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + + TValueHolder aMeshName(aMeshInfo.myName); + med_int aTaille = 0; + med_bool chgt,trsf; + aTaille=MEDmeshnEntity(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + med_entity_type(theEntity), + MED_POLYGON, + MED_CONNECTIVITY, + med_connectivity_mode(theConnMode), + &chgt, + &trsf); + + + if(aTaille < 0) + EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)"); + + return TInt(aTaille); + } + + //----------------------------------------------------------------- + void + TVWrapper + ::GetPolyedreInfo(TPolyedreInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + TValueHolder aMeshName(aMeshInfo.myName); + TInt aNbElem = (TInt)theInfo.myElemNum->size(); + TValueHolder anIndex(theInfo.myIndex); + TValueHolder aFaces(theInfo.myFaces); + TValueHolder aConn(theInfo.myConn); + TValueHolder aConnMode(theInfo.myConnMode); + + TErr aRet; + aRet = MEDmeshPolyhedronRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_CELL, + aConnMode, + &anIndex, + &aFaces, + &aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolyhedronRd(...)"); + + if(theInfo.myIsElemNames){ + GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet); + if(theErr) + *theErr = aRet; + } + + if(theInfo.myIsElemNum){ + GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet); + if(theErr) + *theErr = aRet; + } + + GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet); + if(theErr) + *theErr = aRet; + } + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetPolyedreInfo(const TPolyedreInfo& theInfo, + TErr* theErr) + { + SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr); + } + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TPolyedreInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder anIndex(anInfo.myIndex); + TValueHolder aFaces(anInfo.myFaces); + TValueHolder aConn(anInfo.myConn); + TValueHolder aConnMode(anInfo.myConnMode); + + TErr aRet; + aRet = MEDmeshPolyhedronWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_UNDEF_DT, + MED_CELL, + aConnMode, + anInfo.myNbElem+1, + &anIndex, + (TInt)anInfo.myFaces->size(), + &aFaces, + &aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshPolyhedronWr(...)"); + + TValueHolder anEntity(anInfo.myEntity); + + if(theInfo.myIsElemNames){ + TValueHolder anElemNames(anInfo.myElemNames); + aRet = MEDmeshEntityNameWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + MED_POLYHEDRON, + (TInt)anInfo.myElemNames->size(), + &anElemNames); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNameWr(...)"); + } + + if(theInfo.myIsElemNum){ + TValueHolder anElemNum(anInfo.myElemNum); + aRet = MEDmeshEntityNumberWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + MED_POLYHEDRON, + (TInt)anInfo.myElemNum->size(), + &anElemNum); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNumberWr(...)"); + } + + + TValueHolder aFamNum(anInfo.myFamNum); + aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + MED_POLYHEDRON, + (TInt)anInfo.myFamNum->size(), + &aFamNum); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)"); + } + + //---------------------------------------------------------------------------- + TInt + TVWrapper + ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode, + TErr* theErr) + { + return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr); + } + + //---------------------------------------------------------------------------- + void + TVWrapper ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo, + TInt& theNbFaces, + TInt& theConnSize, + EConnectivite theConnMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + EXCEPTION(std::runtime_error,"GetPolyedreConnSize - (...)"); + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder aConnMode(theConnMode); + //TValueHolder aNbFaces(theNbFaces); + //TValueHolder aConnSize(theConnSize); + + med_bool chgt,trsf; + theNbFaces = MEDmeshnEntity(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_CELL, + MED_POLYHEDRON, + MED_INDEX_NODE, + aConnMode, + &chgt, + &trsf); + + theConnSize = MEDmeshnEntity(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_CELL, + MED_POLYHEDRON, + MED_CONNECTIVITY, + aConnMode, + &chgt, + &trsf); + + if(theNbFaces < 0 || theConnSize<0) + EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)"); + + } + + //----------------------------------------------------------------- + TEntityInfo + TVWrapper + ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo, + EConnectivite theConnMode, + TErr* theErr) + { + TEntityInfo anInfo; + + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return anInfo; + + if(theMeshInfo.GetType() == eNON_STRUCTURE) { + TInt aNbElem = GetNbNodes(theMeshInfo); + if(aNbElem > 0){ + anInfo[eNOEUD][ePOINT1] = aNbElem; + const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet(); + TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin(); + TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end(); + for(; anIter != anIterEnd; anIter++){ + const EEntiteMaillage& anEntity = anIter->first; + const TGeomSet& aGeomSet = anIter->second; + TGeomSet::const_iterator anIter2 = aGeomSet.begin(); + TGeomSet::const_iterator anIterEnd2 = aGeomSet.end(); + for(; anIter2 != anIterEnd2; anIter2++){ + const EGeometrieElement& aGeom = *anIter2; + aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr); + if(aNbElem > 0) { + if ( anEntity == eSTRUCT_ELEMENT ) { + const TInt nbStructTypes = aNbElem; + for ( TInt structType = 0; structType < nbStructTypes; ++structType ) { + // check type name to keep only "MED_BALL" structured element + TValueHolder aMeshName((TString&) theMeshInfo.myName ); + char geotypename[ MED_NAME_SIZE + 1] = ""; + med_geometry_type geotype; + MEDmeshEntityInfo( myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, + med_entity_type(anEntity), structType+1, + geotypename, &geotype); + if ( strcmp( geotypename, MED_BALL_NAME ) == 0 ) { + aNbElem = GetNbCells( theMeshInfo, anEntity, EGeometrieElement(geotype), + theConnMode, theErr); + if ( aNbElem > 0 ) + anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem; + } + } + } + else { + anInfo[anEntity][aGeom] = aNbElem; + } + } + } + } + } + } else { // eSTRUCTURE + EGrilleType aGrilleType; + TInt aNbNodes = 1; + TInt aNbElem = 1; + TInt aNbSub = 0; + TInt aDim = theMeshInfo.GetDim(); + EGeometrieElement aGeom, aSubGeom; + EEntiteMaillage aSubEntity = eMAILLE; + + GetGrilleType(theMeshInfo, aGrilleType); + + TIntVector aStruct(aDim); + if(aGrilleType == eGRILLE_STANDARD) + { + GetGrilleStruct(theMeshInfo, aStruct, theErr); + } + else + { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE + ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 }; + for(med_int anAxis = 0; anAxis < aDim; anAxis++) + aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]); + } + for(med_int i = 0; i < aDim; i++){ + aNbNodes = aNbNodes * aStruct[i]; + aNbElem = aNbElem * (aStruct[i] - 1); + } + switch(aDim){ + case 1: + aGeom = eSEG2; + break; + case 2: + aGeom = eQUAD4; + aSubGeom = eSEG2; + aSubEntity = eARETE; + aNbSub = + (aStruct[0] ) * (aStruct[1]-1) + + (aStruct[0]-1) * (aStruct[1] ); + break; + case 3: + aGeom = eHEXA8; + aSubGeom = eQUAD4; + aSubEntity = eFACE; + aNbSub = + (aStruct[0] ) * (aStruct[1]-1) * (aStruct[2]-1) + + (aStruct[0]-1) * (aStruct[1] ) * (aStruct[2]-1) + + (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2] ); + break; + } + anInfo[eNOEUD][ePOINT1] = aNbNodes; + anInfo[eMAILLE][aGeom] = aNbElem; + if ( aDim > 1 ) + anInfo[aSubEntity][aSubGeom] = aNbSub; + } + return anInfo; + } + + + //----------------------------------------------------------------- + TInt + TVWrapper + ::GetNbCells(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return -1; + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + TValueHolder aMeshName(aMeshInfo.myName); + med_bool chgt,trsf; + if(theGeom!=MED::ePOLYGONE && theGeom!=MED::ePOLYEDRE && theGeom != MED::eBALL) + { + return MEDmeshnEntity(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + med_entity_type(theEntity), + med_geometry_type(theGeom), + MED_CONNECTIVITY, + med_connectivity_mode(theConnMode), + &chgt, + &trsf); + } + else if(theGeom==MED::ePOLYGONE) + { + return MEDmeshnEntity(myFile->Id(),&aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(theEntity), + MED_POLYGON,MED_INDEX_NODE,med_connectivity_mode(theConnMode),&chgt,&trsf)-1; + } + else if ( theGeom==MED::ePOLYEDRE ) + { + return MEDmeshnEntity(myFile->Id(),&aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(theEntity), + MED_POLYHEDRON,MED_INDEX_FACE,med_connectivity_mode(theConnMode),&chgt,&trsf)-1; + } + else if ( theGeom==MED::eBALL ) + { + return GetNbBalls( theMeshInfo ); + } + return 0; + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetCellInfo(MED::TCellInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + + TValueHolder aMeshName (aMeshInfo.myName); + TValueHolder aConn (theInfo.myConn); + TValueHolder aModeSwitch (theInfo.myModeSwitch); + TValueHolder anElemNames (theInfo.myElemNames); + TValueHolder anIsElemNames(theInfo.myIsElemNames); + TValueHolder anElemNum (theInfo.myElemNum); + TValueHolder anIsElemNum (theInfo.myIsElemNum); + TValueHolder aFamNum (theInfo.myFamNum); + TValueHolder anIsFamNum (theInfo.myIsFamNum); + TValueHolder anEntity (theInfo.myEntity); + TValueHolder aGeom (theInfo.myGeom); + TValueHolder aConnMode (theInfo.myConnMode); + + TErr aRet; + aRet = MEDmeshElementRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aGeom, + aConnMode, + aModeSwitch, + &aConn, + &anIsElemNames, + &anElemNames, + &anIsElemNum, + &anElemNum, + &anIsFamNum, + &aFamNum); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetCellInfo - MEDmeshElementRd(...)"); + + if (anIsFamNum == MED_FALSE) + { + int mySize = (int) theInfo.myFamNum->size(); + theInfo.myFamNum->clear(); + theInfo.myFamNum->resize(mySize, 0); + } + + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetCellInfo(const MED::TCellInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TCellInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + TValueHolder aMeshName (aMeshInfo.myName); + TValueHolder aConn (anInfo.myConn); + TValueHolder aModeSwitch (anInfo.myModeSwitch); + TValueHolder anElemNames (anInfo.myElemNames); + TValueHolder anIsElemNames(anInfo.myIsElemNames); + TValueHolder anElemNum (anInfo.myElemNum); + TValueHolder anIsElemNum (anInfo.myIsElemNum); + TValueHolder aFamNum (anInfo.myFamNum); + TValueHolder anIsFamNum (anInfo.myIsFamNum); + TValueHolder anEntity (anInfo.myEntity); + TValueHolder aGeom (anInfo.myGeom); + TValueHolder aConnMode (anInfo.myConnMode); + TValueHolder aNbElem (anInfo.myNbElem); + + TErr aRet; + aRet = MEDmeshElementConnectivityWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_UNDEF_DT, + anEntity, + aGeom, + aConnMode, + aModeSwitch, + aNbElem, + &aConn); + + MEDmeshEntityFamilyNumberWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aGeom, + aNbElem, + &aFamNum); + if(anIsElemNames) + MEDmeshEntityNameWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aGeom, + aNbElem, + &anElemNames); + if(anIsElemNum) + MEDmeshEntityNumberWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + anEntity, + aGeom, + aNbElem, + &anElemNum); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetCellInfo - MEDmeshElementWr(...)"); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetCellInfo(const MED::TCellInfo& theInfo, + TErr* theErr) + { + SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr); + } + + //---------------------------------------------------------------------------- + //! Read geom type of MED_BALL structural element + EGeometrieElement TVWrapper::GetBallGeom(const TMeshInfo& theMeshInfo) + { + TFileWrapper aFileWrapper(myFile,eLECTURE); + + // read med_geometry_type of "MED_BALL" element + char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME; + return EGeometrieElement( MEDstructElementGeotype( myFile->Id(), geotypename ) ); + } + + //---------------------------------------------------------------------------- + //! Read number of balls in the Mesh + TInt TVWrapper::GetNbBalls(const TMeshInfo& theMeshInfo) + { + TFileWrapper aFileWrapper(myFile,eLECTURE); + + EGeometrieElement ballType = GetBallGeom( theMeshInfo ); + if ( ballType < 0 ) + return 0; + + return GetNbCells( theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD ); + } + + //---------------------------------------------------------------------------- + //! Read a MEDWrapped representation of MED_BALL from the MED file + void TVWrapper::GetBallInfo(TBallInfo& theInfo, TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + // check geometry of MED_BALL + if ( theInfo.myGeom == eBALL ) + { + theInfo.myGeom = GetBallGeom( *theInfo.myMeshInfo ); + if ( theInfo.myGeom < 0 ) { + if ( !theErr ) + EXCEPTION(std::runtime_error,"GetBallInfo - no balls in the mesh"); + *theErr = theInfo.myGeom; + return; + } + } + + // read nodes ids + GetCellInfo( theInfo ); + + // read diameters + TValueHolder aMeshName (theInfo.myMeshInfo->myName); + TValueHolder aGeom (theInfo.myGeom); + TValueHolder aDiam (theInfo.myDiameters); + char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER; + + TErr aRet = MEDmeshStructElementVarAttRd( myFile->Id(), &aMeshName, + MED_NO_DT, MED_NO_IT, + aGeom, + varattname, + &aDiam); + if ( theErr ) + *theErr = aRet; + else if ( aRet < 0 ) + EXCEPTION(std::runtime_error,"GetBallInfo - pb at reading diameters"); + } + + + //---------------------------------------------------------------------------- + //! Write a MEDWrapped representation of MED_BALL to the MED file + void TVWrapper::SetBallInfo(const TBallInfo& theInfo, EModeAcces theMode, TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + TErr ret; + char ballsupportname[MED_NAME_SIZE+1]="BALL_SUPPORT_MESH"; + EGeometrieElement ballGeom = GetBallGeom( *theInfo.myMeshInfo ); + if ( ballGeom < 0 ) + { + // no ball model in the file, create support mesh for it + char dummyname [MED_NAME_SIZE*3+1]=""; + if (( ret = MEDsupportMeshCr( myFile->Id(), + ballsupportname, + theInfo.myMeshInfo->GetSpaceDim(), + theInfo.myMeshInfo->GetDim(), + "Support mesh for a ball model", + MED_CARTESIAN, + /*axisname=*/dummyname, /*unitname=*/dummyname)) < 0) { + if ( !theErr ) + EXCEPTION(std::runtime_error,"SetBallInfo - MEDsupportMeshCr"); + *theErr = ret; + return; + } + // write coordinates of 1 node + med_float coord[3] = {0,0,0}; + if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(), + ballsupportname, MED_NO_DT, MED_NO_IT, 0.0, + MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) { + if ( !theErr ) + EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshNodeCoordinateWr"); + *theErr = ret; + return; + } + // ball model creation + char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME; + if (( ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(), + geotypename, + theInfo.myMeshInfo->GetSpaceDim(), + ballsupportname, + MED_NODE,MED_NONE)) < 0 ) { + if ( !theErr ) + EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementCr"); + *theErr = ret; + return; + } + // create diameter attribute + if (( ret = MEDstructElementVarAttCr(myFile->Id(), + geotypename, MED_BALL_DIAMETER, + MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) { + if ( !theErr ) + EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementVarAttCr"); + *theErr = ret; + return; + } + } // ballGeom < 0 + + TBallInfo& aBallInfo = ((TBallInfo&) theInfo ); + aBallInfo.myGeom = ballGeom; + + // write node ids + SetCellInfo(theInfo,theMode,theErr); + if ( theErr && theErr < 0 ) + return; + + // write diameter + TValueHolder aMeshName (aBallInfo.myMeshInfo->myName); + TValueHolder aGeom (aBallInfo.myGeom); + TValueHolder aDiam (aBallInfo.myDiameters); + ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName, + MED_NO_DT, MED_NO_IT, + aGeom, MED_BALL_DIAMETER, + theInfo.myNbElem, &aDiam); + if ( theErr ) + *theErr = ret; + else if ( ret < 0 ) + EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshStructElementVarAttWr"); + } + + //---------------------------------------------------------------------------- + //! Write a MEDWrapped representation of MED_BALL to the MED file + void TVWrapper::SetBallInfo(const TBallInfo& theInfo, TErr* theErr) + { + SetBallInfo( theInfo, eLECTURE_ECRITURE, theErr ); + } + + //----------------------------------------------------------------- + TInt + TVWrapper + ::GetNbFields(TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return -1; + + return MEDnField(myFile->Id()); + } + + + //---------------------------------------------------------------------------- + TInt + TVWrapper + ::GetNbComp(TInt theFieldId, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return -1; + + return MEDfieldnComponent(myFile->Id(),theFieldId); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetFieldInfo(TInt theFieldId, + MED::TFieldInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + TString aFieldName(256); // Protect from memory problems with too long names + TValueHolder aType(theInfo.myType); + TValueHolder aCompNames(theInfo.myCompNames); + TValueHolder anUnitNames(theInfo.myUnitNames); + MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo; + + TErr aRet; + med_bool local; + char dtunit[MED_SNAME_SIZE+1]; + char local_mesh_name[MED_NAME_SIZE+1]=""; + med_int nbofstp; + theInfo.myNbComp = MEDfieldnComponent(myFile->Id(),theFieldId); + aRet = MEDfieldInfo(myFile->Id(), + theFieldId, + &aFieldName[0], + local_mesh_name, + &local, + &aType, + &aCompNames, + &anUnitNames, + dtunit, + &nbofstp); + + if(strcmp(&aMeshInfo.myName[0],local_mesh_name) != 0 ) { + if(theErr) + *theErr = -1; + return; + } + + theInfo.SetName(aFieldName); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetFieldInfo - MEDfieldInfo(...)"); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetFieldInfo(const MED::TFieldInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TFieldInfo& anInfo = const_cast(theInfo); + + TValueHolder aFieldName(anInfo.myName); + TValueHolder aType(anInfo.myType); + TValueHolder aCompNames(anInfo.myCompNames); + TValueHolder anUnitNames(anInfo.myUnitNames); + MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo; + TErr aRet; + char dtunit[MED_SNAME_SIZE+1]; + std::fill(dtunit,dtunit+MED_SNAME_SIZE+1,'\0'); + aRet = MEDfieldCr(myFile->Id(), + &aFieldName, + aType, + anInfo.myNbComp, + &aCompNames, + &anUnitNames, + dtunit, + &aMeshInfo.myName[0]); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetFieldInfo - MEDfieldCr(...)"); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::SetFieldInfo(const MED::TFieldInfo& theInfo, + TErr* theErr) + { + TErr aRet; + SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet); + + if(aRet < 0) + SetFieldInfo(theInfo,eLECTURE_AJOUT,&aRet); + + if(theErr) + *theErr = aRet; + } + + + //---------------------------------------------------------------------------- + TInt + TVWrapper + ::GetNbGauss(TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return -1; + + return MEDnLocalization(myFile->Id()); + } + + + //---------------------------------------------------------------------------- + TGaussInfo::TInfo + TVWrapper + ::GetGaussPreInfo(TInt theId, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 ); + + med_int aNbGaussPoints = med_int(); + TVector aName(GetNOMLength()+1); + med_geometry_type aGeom = MED_NONE; + + TErr aRet; + med_int dim; + char geointerpname[MED_NAME_SIZE+1]=""; + char ipointstructmeshname[MED_NAME_SIZE+1]=""; + med_int nsectionmeshcell; + med_geometry_type sectiongeotype; + aRet = MEDlocalizationInfo (myFile->Id(), + theId, + &aName[0], + &aGeom, + &dim, + &aNbGaussPoints, + geointerpname, + ipointstructmeshname, + &nsectionmeshcell, + §iongeotype); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetGaussPreInfo - MEDlocalizationInfo(...)"); + return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]), + TInt(aNbGaussPoints)); + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetGaussInfo(TInt theId, + TGaussInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + TValueHolder aRefCoord(theInfo.myRefCoord); + TValueHolder aGaussCoord(theInfo.myGaussCoord); + TValueHolder aWeight(theInfo.myWeight); + TValueHolder aModeSwitch(theInfo.myModeSwitch); + TValueHolder aGaussName(theInfo.myName); + + TErr aRet; + aRet = MEDlocalizationRd(myFile->Id(), + &aGaussName, + aModeSwitch, + &aRefCoord, + &aGaussCoord, + &aWeight); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetGaussInfo - MEDlocalizationRd(...)"); + } + + + //---------------------------------------------------------------------------- + TInt + TVWrapper + ::GetNbProfiles(TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return -1; + + return MEDnProfile(myFile->Id()); + } + + TProfileInfo::TInfo + TVWrapper + ::GetProfilePreInfo(TInt theId, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return TProfileInfo::TInfo(); + + med_int aSize = -1; + TVector aName(GetNOMLength()+1); + + TErr aRet; + aRet = MEDprofileInfo(myFile->Id(), + theId, + &aName[0], + &aSize); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofileInfo(...)"); + + return TProfileInfo::TInfo(&aName[0],aSize); + } + + void + TVWrapper + ::GetProfileInfo(TInt theId, + TProfileInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + TProfileInfo& anInfo = const_cast(theInfo); + TValueHolder anElemNum(anInfo.myElemNum); + TValueHolder aProfileName(anInfo.myName); + + TErr aRet; + aRet = MEDprofileRd(myFile->Id(), + &aProfileName, + &anElemNum); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofileRd(...)"); + } + + void + TVWrapper + ::SetProfileInfo(const TProfileInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && *theErr < 0) + return; + + TProfileInfo& anInfo = const_cast(theInfo); + TValueHolder anElemNum(anInfo.myElemNum); + TValueHolder aProfileName(anInfo.myName); + + TErr aRet; + aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier. + &aProfileName, // tableau de valeurs du profil. + theInfo.GetSize(), // taille du profil. + &anElemNum); // nom profil. + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofileWr(...)"); + } + + void + TVWrapper + ::SetProfileInfo(const TProfileInfo& theInfo, + TErr* theErr) + { + TErr aRet; + SetProfileInfo(theInfo,eLECTURE_ECRITURE,&aRet); + + if(aRet < 0) + SetProfileInfo(theInfo,eLECTURE_AJOUT,&aRet); + + if(aRet < 0) + SetProfileInfo(theInfo,eCREATION,&aRet); + + if(theErr) + *theErr = aRet; + } + + //----------------------------------------------------------------- + TInt + TVWrapper + ::GetNbTimeStamps(const MED::TFieldInfo& theInfo, + const MED::TEntityInfo& theEntityInfo, + EEntiteMaillage& theEntity, + TGeom2Size& theGeom2Size, + TErr* theErr) + { + theEntity = EEntiteMaillage(-1); + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr){ + if(theEntityInfo.empty()) + *theErr = -1; + if(*theErr < 0) + return -1; + }else if(theEntityInfo.empty()) + EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh"); + + bool anIsPerformAdditionalCheck = GetNbMeshes() > 1; + + theGeom2Size.clear(); + TInt aNbTimeStamps = 0; + TIdt anId = myFile->Id(); + + MED::TFieldInfo& anInfo = const_cast(theInfo); + TValueHolder aFieldName(anInfo.myName); + MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo; + + // workaround for IPAL13676 + MED::TEntityInfo localEntityInfo = theEntityInfo; + TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE); + if(anLocalIter != localEntityInfo.end()){ + localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second; + } + + TEntityInfo::const_iterator anIter = localEntityInfo.begin(); + for(; anIter != localEntityInfo.end(); anIter++){ + med_entity_type anEntity = med_entity_type(anIter->first); + const TGeom2Size& aGeom2Size = anIter->second; + TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin(); + for(; anGeomIter != aGeom2Size.end(); anGeomIter++){ + med_geometry_type aGeom = med_geometry_type(anGeomIter->first); + char aMeshName[MED_NAME_SIZE+1]; + med_bool islocal; + med_field_type ft; + char dtunit[MED_SNAME_SIZE+1]; + med_int myNbComp = MEDfieldnComponentByName(anId,&aFieldName); + char *cname=new char[myNbComp*MED_SNAME_SIZE+1]; + char *unitname=new char[myNbComp*MED_SNAME_SIZE+1]; + TInt aNbStamps; + MEDfieldInfoByName(anId, + &aFieldName, + aMeshName, + &islocal, + &ft, + cname, + unitname, + dtunit, + &aNbStamps); + delete [] cname; + delete [] unitname; + med_int nval = 0; + med_int aNumDt; + med_int aNumOrd; + med_float aDt; + if (aNbStamps > 0) + { + MEDfieldComputingStepInfo(anId, + &aFieldName, + 1, + &aNumDt, + &aNumOrd, + &aDt); + char profilename[MED_NAME_SIZE+1]; + char locname[MED_NAME_SIZE+1]; + med_int profilsize; + med_int aNbGauss; + + // protection from crash (division by zero) + // inside MEDfieldnValueWithProfile function + // caused by the workaround for IPAL13676 (see above) + if( anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0 ) + continue; + + nval = MEDfieldnValueWithProfile(anId, + &aFieldName, + aNumDt, + aNumOrd, + anEntity, + med_geometry_type(aGeom), + 1, + MED_COMPACT_STMODE, + profilename, + &profilsize, + locname, + &aNbGauss); + } + bool anIsSatisfied =(nval > 0); + if(anIsSatisfied){ + INITMSG(MYDEBUG, + "GetNbTimeStamps aNbTimeStamps = "<second; + theEntity = EEntiteMaillage(anEntity); + aNbTimeStamps = aNbStamps; + } + } + if(!theGeom2Size.empty()) + break; + } + return aNbTimeStamps; + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetTimeStampInfo(TInt theTimeStampId, + MED::TTimeStampInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + const TGeom2Size& aGeom2Size = theInfo.myGeom2Size; + + if(theErr){ + if(aGeom2Size.empty()) + *theErr = -1; + if(*theErr < 0) + return; + }else if(aGeom2Size.empty()) + EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell"); + + MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo; + MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; + + TValueHolder aFieldName(aFieldInfo.myName); + TValueHolder anEntity(theInfo.myEntity); + TValueHolder aNumDt(theInfo.myNumDt); + TValueHolder aNumOrd(theInfo.myNumOrd); + TValueHolder anUnitDt(theInfo.myUnitDt); + TValueHolder aDt(theInfo.myDt); + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder anIsLocal(aFieldInfo.myIsLocal); + TValueHolder aNbRef(aFieldInfo.myNbRef); + + TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss; + + // just to get a time stamp unit (anUnitDt) + med_field_type aFieldType; + med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName); + char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1]; + char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1]; + TInt aNbStamps; + MEDfieldInfoByName(myFile->Id(), + &aFieldName, + &aMeshName, + &anIsLocal, + &aFieldType, + aCompName, + aCompUnit, + &anUnitDt, + &aNbStamps); + delete [] aCompName; + delete [] aCompUnit; + + TGeom2Size::const_iterator anIter = aGeom2Size.begin(); + for(; anIter != aGeom2Size.end(); anIter++){ + const EGeometrieElement& aGeom = anIter->first; + med_int aNbGauss = -1; + + TErr aRet; + aRet = MEDfieldComputingStepInfo(myFile->Id(), + &aFieldName, + theTimeStampId, + &aNumDt, + &aNumOrd, + &aDt); + char profilename[MED_NAME_SIZE+1]; + med_int profilsize; + char locname[MED_NAME_SIZE+1]; + MEDfieldnValueWithProfile(myFile->Id(), + &aFieldName, + aNumDt, + aNumOrd, + anEntity, + med_geometry_type(aGeom), + 1, + MED_COMPACT_STMODE, + profilename, + &profilsize, + locname, + &aNbGauss); + + static TInt MAX_NB_GAUSS_POINTS = 32; + if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS) + aNbGauss = 1; + + aGeom2NbGauss[aGeom] = aNbGauss; + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDfieldnValueWithProfile(...)"); + } + } + + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue, + const TMKey2Profile& theMKey2Profile, + const TKey2Gauss& theKey2Gauss, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + TIdt anId = myFile->Id(); + + TValueHolder aModeSwitch(theTimeStampValue->myModeSwitch); + MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile; + + MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo; + TValueHolder anEntity(aTimeStampInfo->myEntity); + TValueHolder aNumDt(aTimeStampInfo->myNumDt); + TValueHolder aNumOrd(aTimeStampInfo->myNumOrd); + + MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo; + TValueHolder aFieldName(aFieldInfo->myName); + TValueHolder anIsLocal(aFieldInfo->myIsLocal); + + MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo; + TValueHolder aMeshName(aMeshInfo->myName); + + TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss; + TVector aGaussName(GetNOMLength()+1); + + med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile)); + MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile); + TVector aProfileName(GetNOMLength()+1); + + TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size; + TGeom2Size::iterator anIter = aGeom2Size.begin(); + for(; anIter != aGeom2Size.end(); anIter++){ + EGeometrieElement aGeom = anIter->first; + TInt aNbElem = anIter->second; + med_int profilesize,aNbGauss; + + TInt aNbVal = MEDfieldnValueWithProfile(anId, + &aFieldName, + aNumDt, + aNumOrd, + anEntity, + med_geometry_type(aGeom), + 1, + aProfileMode, + &aProfileName[0], + &profilesize, + &aGaussName[0], + &aNbGauss); + + if(aNbVal <= 0){ + if(theErr){ + *theErr = -1; + return; + } + EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<myNbComp; + TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed + theTimeStampValue->AllocateValue(aGeom, + aNbValue, + aNbGauss, + aNbComp); + TInt aValueSize = theTimeStampValue->GetValueSize(aGeom); + + INITMSG(MYDEBUG, + "TVWrapper::GetTimeStampValue - aGeom = "<second; + aGeom2Gauss[aGeom] = aGaussInfo; + } + } + + MED::PProfileInfo aProfileInfo; + if(strcmp(&aProfileName[0],MED_NO_PROFILE) != 0){ + MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]); + if(anIter != aKey2Profile.end()){ + aProfileInfo = anIter->second; + aGeom2Profile[aGeom] = aProfileInfo; + } + } + + if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){ + if(theErr){ + *theErr = MED_FALSE; + return; + } + EXCEPTION(std::runtime_error,"GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()"); + } + + if(aProfileInfo && aProfileInfo->IsPresent()){ + TInt aNbSubElem = aProfileInfo->GetSize(); + TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss; + if(aProfileSize != aValueSize){ + if(theErr){ + *theErr = -1; + return; + } + EXCEPTION(std::runtime_error, + "GetTimeStampValue - aProfileSize("<Id(); + + TValueHolder aModeSwitch(theTimeStampValue->myModeSwitch); + MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile; + + MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo; + TValueHolder anEntity(aTimeStampInfo->myEntity); + TValueHolder aNumDt(aTimeStampInfo->myNumDt); + TValueHolder aNumOrd(aTimeStampInfo->myNumOrd); + TValueHolder anUnitDt(aTimeStampInfo->myUnitDt); + TValueHolder aDt(aTimeStampInfo->myDt); + MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss; + + MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo; + TValueHolder aFieldName(aFieldInfo->myName); + + MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo; + TValueHolder aMeshName(aMeshInfo->myName); + + const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet; + TGeomSet::const_iterator anIter = aGeomSet.begin(); + for(; anIter != aGeomSet.end(); anIter++){ + EGeometrieElement aGeom = *anIter; + + TVector aGaussName(GetNOMLength()+1); + MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom); + if(aGaussIter != aGeom2Gauss.end()){ + MED::PGaussInfo aGaussInfo = aGaussIter->second; + strcpy(&aGaussName[0],&aGaussInfo->myName[0]); + } + + TVector aProfileName(GetNOMLength()+1); + med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD); + MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom); + if(aProfileIter != aGeom2Profile.end()){ + MED::PProfileInfo aProfileInfo = aProfileIter->second; + aProfileMode = med_storage_mode(aProfileInfo->myMode); + strcpy(&aProfileName[0],&aProfileInfo->myName[0]); + } + + med_int aNbVal = theTimeStampValue->GetNbVal(aGeom); + + aRet = MEDfieldValueWithProfileWr(anId, + &aFieldName, + aNumDt, + aNumOrd, + aDt, + anEntity, + med_geometry_type(aGeom), + aProfileMode, + &aProfileName[0], + &aGaussName[0], + aModeSwitch, + MED_ALL_CONSTITUENT, + aNbVal, + theTimeStampValue->GetValuePtr(aGeom)); + if(aRet < 0){ + if(theErr){ + *theErr = MED_FALSE; + break; + } + EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDfieldValueWithProfileWr(...)"); + } + + } + + INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "< aCoord(anInfo.myCoord); + TValueHolder aModeSwitch(anInfo.myModeSwitch); + TValueHolder aCoordNames(anInfo.myCoordNames); + TValueHolder aCoordUnits(anInfo.myCoordUnits); + med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim); + //med_axis_type aRepere = MED_CARTESIAN; + + aRet = MEDmeshNodeCoordinateWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_UNDEF_DT, + aModeSwitch, + aNbNoeuds, + &aCoord); + + if(aRet < 0) + EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshNodeCoordinateWr(...)"); + + TValueHolder aGrilleStructure(anInfo.myGrilleStructure); + aRet = MEDmeshGridStructWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_UNDEF_DT, + &aGrilleStructure); + if(aRet < 0) + EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridStructWr(...)"); + + } else { + for(med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++){ + aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_UNDEF_DT, + aAxis+1, + anInfo.GetIndexes(aAxis).size(), + &anInfo.GetIndexes(aAxis)[0]); + + if(aRet < 0) + EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)"); + } + + } + + return; + } + + //---------------------------------------------------------------------------- + void + TVWrapper + ::GetGrilleInfo(TGrilleInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + TValueHolder aMeshName(aMeshInfo.myName); + EMaillage aMaillageType = aMeshInfo.myType; + + GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr); + EGrilleType aGrilleType = theInfo.myGrilleType; + + TErr aRet = 0; + if(aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) { + GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr); + + TValueHolder aCoord(theInfo.myCoord); + TValueHolder aModeSwitch(theInfo.myModeSwitch); + TValueHolder aCoordNames(theInfo.myCoordNames); + TValueHolder aCoordUnits(theInfo.myCoordUnits); + //med_axis_type aRepere; + + aRet = MEDmeshNodeCoordinateRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + aModeSwitch, + &aCoord); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshNodeCoordinateRd(...)"); + + //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo); + TValueHolder aFamNumNode(theInfo.myFamNumNode); + + aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + MED_NODE, + MED_NO_GEOTYPE, + &aFamNumNode); + + if(aRet < 0) + { +// if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files + { + int mySize = (int)theInfo.myFamNumNode.size(); + theInfo.myFamNumNode.clear(); + theInfo.myFamNumNode.resize(mySize,0); + aRet = 0; + } +// else +// EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)"); + } + if(theErr) + *theErr = aRet; + + //============================ + } + + if(aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD){ + ETable aTable; + for(med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++){ + switch(anAxis){ + case 1 : + aTable = eCOOR_IND1; + break; + case 2 : + aTable = eCOOR_IND2; + break; + case 3 : + aTable = eCOOR_IND3; + break; + default : + aRet = -1; + } + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetGrilleInfo - anAxis number out of range(...)"); + + TInt aNbIndexes = GetNbNodes(aMeshInfo,aTable); + if(aNbIndexes < 0) + EXCEPTION(std::runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice"); + + TValueHolder anIndexes(theInfo.GetIndexes(anAxis-1)); + //TValueHolder table(aTable); + //char aCompNames[MED_SNAME_SIZE+1]; + //char anUnitNames[MED_SNAME_SIZE+1]; + aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),&aMeshName, + MED_NO_DT,MED_NO_IT, + anAxis, + &anIndexes); + + //theInfo.SetCoordName(anAxis-1, aCompNames); + //theInfo.SetCoordUnit(anAxis-1, anUnitNames); + theInfo.SetGrilleStructure(anAxis-1, aNbIndexes); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)"); + } + } + + EGeometrieElement aGeom = theInfo.GetGeom(); + EEntiteMaillage aEntity = theInfo.GetEntity(); + TInt aNbCells = theInfo.GetNbCells(); + + theInfo.myFamNum.resize(aNbCells); + TValueHolder aFamNum(theInfo.myFamNum); + + aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(), + &aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(aEntity), + med_geometry_type(aGeom),&aFamNum); + + if ( aMeshInfo.myDim == 3 ) + { + aGeom = theInfo.GetSubGeom(); + aEntity = theInfo.GetSubEntity(); + aNbCells = theInfo.GetNbSubCells(); + + theInfo.myFamSubNum.resize(aNbCells,0); + TValueHolder aFamNum(theInfo.myFamSubNum); + + aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(), + &aMeshName,MED_NO_DT,MED_NO_IT, + med_entity_type(aEntity), + med_geometry_type(aGeom),&aFamNum); + } + if(aRet < 0) + { +// if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files + { + int mySize = (int)theInfo.myFamNumNode.size(); + theInfo.myFamNumNode.clear(); + theInfo.myFamNumNode.resize(mySize,0); + aRet = 0; + } +// else +// EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)"); + } + if(theErr) + *theErr = aRet; + } + + void + TVWrapper + ::GetGrilleType(const MED::TMeshInfo& theMeshInfo, + EGrilleType& theGridType, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + EXCEPTION(std::runtime_error," GetGrilleType - aFileWrapper (...)"); + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + + if(aMeshInfo.myType == eSTRUCTURE){ + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder aGridType(theGridType); + TErr aRet = MEDmeshGridTypeRd(myFile->Id(), + &aMeshName, + &aGridType); + + if(aRet < 0) + EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridTypeRd(...)"); + } + } + + void + TVWrapper + ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo, + TIntVector& theStruct, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && *theErr < 0) + return; + + TErr aRet; + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + + TValueHolder aMeshName(aMeshInfo.myName); + TValueHolder aGridStructure(theStruct); + + aRet = MEDmeshGridStructRd(myFile->Id(), + &aMeshName, + MED_NO_DT, + MED_NO_IT, + &aGridStructure); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridStructRd(...)"); + } + + } +} diff --git a/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.hxx b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.hxx new file mode 100644 index 000000000..9d5a74ca7 --- /dev/null +++ b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.hxx @@ -0,0 +1,490 @@ +// 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 MED_V2_2_Wrapper_HeaderFile +#define MED_V2_2_Wrapper_HeaderFile + +#ifdef WIN32 + #if defined MEDWRAPPER_V2_2_EXPORTS || defined MEDWrapper_V2_2_EXPORTS + #if defined WIN32 + #define MED_V22_WRAPPER_EXPORT __declspec( dllexport ) + #else + #define MED_V22_WRAPPER_EXPORT + #endif + #else + #if defined WIN32 + #define MED_V22_WRAPPER_EXPORT __declspec( dllimport ) + #else + #define MED_V22_WRAPPER_EXPORT + #endif + #endif +#else + #define MED_V22_WRAPPER_EXPORT +#endif + +#include "MED_Structures.hxx" +#include "MED_TWrapper.hxx" + +namespace MED +{ + template<> + TInt MED_V22_WRAPPER_EXPORT + GetDESCLength(); + + template<> + TInt MED_V22_WRAPPER_EXPORT + GetIDENTLength(); + + template<> + TInt MED_V22_WRAPPER_EXPORT + GetNOMLength(); + + template<> + TInt MED_V22_WRAPPER_EXPORT + GetLNOMLength(); + + template<> + TInt MED_V22_WRAPPER_EXPORT + GetPNOMLength(); + + template<> + void MED_V22_WRAPPER_EXPORT + GetVersionRelease(TInt& majeur, TInt& mineur, TInt& release); + + template<> + TInt MED_V22_WRAPPER_EXPORT + GetNbConn(EGeometrieElement typmai, + EEntiteMaillage typent, + TInt mdim); + + namespace V2_2 + { + //---------------------------------------------------------------------------- + class TFile; + typedef boost::shared_ptr PFile; + + typedef enum {eLECTURE, eLECTURE_ECRITURE, eLECTURE_AJOUT, eCREATION} EModeAcces; + + //---------------------------------------------------------------------------- + class MED_V22_WRAPPER_EXPORT TVWrapper: public MED::TTWrapper + { + TVWrapper(); + TVWrapper(const TVWrapper&); + TVWrapper& operator=(const TVWrapper&); + + public: + TVWrapper(const std::string& theFileName); + + //---------------------------------------------------------------------------- + virtual + TInt + GetNbMeshes(TErr* theErr = NULL); + + virtual + void + GetMeshInfo(TInt theMeshId, MED::TMeshInfo&, + TErr* theErr = NULL); + + virtual + void + SetMeshInfo(const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); + + void SetMeshInfo(const MED::TMeshInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //---------------------------------------------------------------------------- + virtual + TInt + GetNbFamilies(const MED::TMeshInfo& theMeshInfo, + TErr* theErr = NULL); + + virtual + TInt + GetNbFamAttr(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); + + virtual + TInt + GetNbFamGroup(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + GetFamilyInfo(TInt theFamId, + MED::TFamilyInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetFamilyInfo(const MED::TFamilyInfo& theInfo, + TErr* theErr = NULL); + + void + SetFamilyInfo(const MED::TFamilyInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //---------------------------------------------------------------------------- + virtual + void + GetNames(TElemInfo& theInfo, + TInt nb, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL); + + virtual + void + GetNumeration(TElemInfo& theInfo, + TInt nb, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL); + + virtual + void + GetFamilies(TElemInfo& theInfo, + TInt nb, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL); + + virtual + void + SetNames(const TElemInfo& theInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL); + + void + SetNames(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL); + + virtual + void + SetNumeration(const TElemInfo& theInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL); + void + SetNumeration(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL); + + virtual + void + SetFamilies(const TElemInfo& theInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL); + void + SetFamilies(const TElemInfo& theInfo, + EModeAcces theMode, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + virtual + TInt + GetNbNodes(const MED::TMeshInfo& theMeshInfo, + TErr* theErr = NULL) + { + return GetNbNodes(theMeshInfo,eCOOR,theErr); + } + + TInt + GetNbNodes(const MED::TMeshInfo& theMeshInfo, + ETable theTable, + TErr* theErr = NULL); + + virtual + void + GetNodeInfo(MED::TNodeInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetNodeInfo(const MED::TNodeInfo& theInfo, + TErr* theErr = NULL); + + void + SetNodeInfo(const MED::TNodeInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + virtual + void + GetPolygoneInfo(TPolygoneInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetPolygoneInfo(const TPolygoneInfo& theInfo, + TErr* theErr = NULL); + + void + SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + virtual + TInt + GetNbPolygones(const TMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL); + + virtual + TInt + GetPolygoneConnSize(const TMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + virtual + void + GetPolyedreInfo(TPolyedreInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetPolyedreInfo(const TPolyedreInfo& theInfo, + TErr* theErr = NULL); + + void + SetPolyedreInfo(const MED::TPolyedreInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + virtual + TInt + GetNbPolyedres(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite, + TErr* theErr = NULL); + + virtual + void + GetPolyedreConnSize(const TMeshInfo& theMeshInfo, + TInt& theNbFaces, + TInt& theConnSize, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + virtual + TEntityInfo + GetEntityInfo(const MED::TMeshInfo& theMeshInfo, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL); + + virtual + TInt + GetNbCells(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite theConnMode = eNOD, + TErr* theErr = NULL); + + virtual + void + GetCellInfo(MED::TCellInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetCellInfo(const MED::TCellInfo& theInfo, + TErr* theErr = NULL); + + void + SetCellInfo(const MED::TCellInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + //! Read geom type of MED_BALL structural element + EGeometrieElement GetBallGeom(const TMeshInfo& theMeshInfo); + + //! Read number of balls in the Mesh + virtual TInt GetNbBalls(const TMeshInfo& theMeshInfo); + + //! Read a MEDWrapped representation of MED_BALL from the MED file + virtual void GetBallInfo(TBallInfo& theInfo, TErr* theErr = NULL); + + //! Write a MEDWrapped representation of MED_BALL to the MED file + virtual void SetBallInfo(const TBallInfo& theInfo, TErr* theErr); + + //! Write a MEDWrapped representation of MED_BALL to the MED file + void SetBallInfo(const TBallInfo& theInfo, EModeAcces theMode, TErr* theErr); + + //---------------------------------------------------------------------------- + virtual + TInt + GetNbFields(TErr* theErr = NULL); + + virtual + TInt + GetNbComp(TInt theFieldId, + TErr* theErr = NULL); + + virtual + void + GetFieldInfo(TInt theFieldId, + MED::TFieldInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetFieldInfo(const MED::TFieldInfo& theInfo, + TErr* theErr = NULL); + + void + SetFieldInfo(const MED::TFieldInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + virtual + TInt + GetNbGauss(TErr* theErr = NULL); + + virtual + TGaussInfo::TInfo + GetGaussPreInfo(TInt theId, + TErr* theErr = NULL); + + virtual + void + GetGaussInfo(TInt theId, + TGaussInfo& theInfo, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + virtual + TInt + GetNbProfiles(TErr* theErr = NULL); + + virtual + TProfileInfo::TInfo + GetProfilePreInfo(TInt theId, + TErr* theErr = NULL); + + virtual + void + GetProfileInfo(TInt theId, + TProfileInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetProfileInfo(const TProfileInfo& theInfo, + TErr* theErr = NULL); + + void + SetProfileInfo(const TProfileInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + //---------------------------------------------------------------------------- + virtual + TInt + GetNbTimeStamps(const MED::TFieldInfo& theInfo, + const MED::TEntityInfo& theEntityInfo, + EEntiteMaillage& theEntity, + TGeom2Size& theGeom2Size, + TErr* theErr = NULL); + + virtual + void + GetTimeStampInfo(TInt theTimeStampId, + MED::TTimeStampInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue, + const TMKey2Profile& theMKey2Profile, + const TKey2Gauss& theKey2Gauss, + TErr* theErr = NULL); + + virtual + void + SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue, + TErr* theErr = NULL); + + void + SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue, + EModeAcces theMode, + TErr* theErr = NULL); + + + //---------------------------------------------------------------------------- + virtual + void + GetGrilleInfo(TGrilleInfo& theGrilleInfo, + TErr* theErr = NULL); + + virtual + void + SetGrilleInfo(const MED::TGrilleInfo& theGrilleInfo, + TErr* theErr = NULL); + + void + SetGrilleInfo(const MED::TGrilleInfo& theGrilleInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + virtual + void + GetGrilleType(const MED::TMeshInfo& theMeshInfo, + EGrilleType& type, + TErr* theErr = NULL); + + void + GetGrilleStruct(const MED::TMeshInfo& theMeshInfo, + TIntVector& theStruct, + TErr* theErr = NULL); + + protected: + PFile myFile; + }; + } +} + +#endif diff --git a/src/MEDWrapper/V2_2/Makefile.am b/src/MEDWrapper/V2_2/Makefile.am new file mode 100644 index 000000000..d744452a7 --- /dev/null +++ b/src/MEDWrapper/V2_2/Makefile.am @@ -0,0 +1,32 @@ +# Copyright (C) 2007-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 $(top_srcdir)/adm_local/unix/make_common_starter.am + +lib_LTLIBRARIES= libMEDWrapper_V2_2.la + +salomeinclude_HEADERS = \ + MED_V2_2_Wrapper.hxx + +dist_libMEDWrapper_V2_2_la_SOURCES = \ + MED_V2_2_Wrapper.cxx + +libMEDWrapper_V2_2_la_CPPFLAGS= $(BOOST_CPPFLAGS) $(MED3_INCLUDES) $(HDF5_INCLUDES) -I$(srcdir)/../Base +libMEDWrapper_V2_2_la_CPPFLAGS+= -I$(KERNEL_ROOT_DIR)/include/salome +libMEDWrapper_V2_2_la_LDFLAGS= $(MED3_LIBS_C_ONLY) $(HDF5_LIBS) +libMEDWrapper_V2_2_la_LIBADD= ../Base/libMEDWrapperBase.la diff --git a/src/Makefile.am b/src/Makefile.am index 3f6ab8b3e..246391150 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,6 +34,7 @@ SUBDIRS = \ SMESHUtils \ Controls \ Driver \ + MEDWrapper \ DriverMED \ DriverDAT \ DriverUNV \ @@ -60,7 +61,7 @@ if SMESH_ENABLE_GUI StdMeshersGUI endif -DIST_SUBDIRS = SMDS SMESHDS Controls Driver DriverMED DriverDAT DriverUNV DriverSTL DriverCGNS \ +DIST_SUBDIRS = SMDS SMESHDS Controls Driver MEDWrapper DriverMED DriverDAT DriverUNV DriverSTL DriverCGNS \ DriverGMF \ SMESHUtils SMESH SMESH_I SMESHClient SMESH_SWIG MEFISTO2 StdMeshers StdMeshers_I OBJECT \ SMESHFiltersSelection SMESHGUI PluginUtils SMESH_SWIG_WITHIHM StdMeshersGUI SMESH_PY Tools diff --git a/src/SMDS/SMDS_MeshElement.hxx b/src/SMDS/SMDS_MeshElement.hxx index a8a3ad422..78238dcea 100644 --- a/src/SMDS/SMDS_MeshElement.hxx +++ b/src/SMDS/SMDS_MeshElement.hxx @@ -151,19 +151,28 @@ public: /*! * \brief Filters of elements, to be used with SMDS_SetIterator */ - struct TypeFilter + struct Filter + { + virtual bool operator()(const SMDS_MeshElement* e) const = 0; + ~Filter() {} + }; + struct NonNullFilter: public Filter + { + bool operator()(const SMDS_MeshElement* e) const { return e; } + }; + struct TypeFilter : public Filter { SMDSAbs_ElementType _type; TypeFilter( SMDSAbs_ElementType t = SMDSAbs_NbElementTypes ):_type(t) {} bool operator()(const SMDS_MeshElement* e) const { return e && e->GetType() == _type; } }; - struct EntityFilter + struct EntityFilter : public Filter { SMDSAbs_EntityType _type; EntityFilter( SMDSAbs_EntityType t = SMDSEntity_Last ):_type(t) {} bool operator()(const SMDS_MeshElement* e) const { return e && e->GetEntityType() == _type; } }; - struct GeomFilter + struct GeomFilter : public Filter { SMDSAbs_GeometryType _type; GeomFilter( SMDSAbs_GeometryType t = SMDSGeom_NONE ):_type(t) {} diff --git a/src/SMDS/SMDS_VtkVolume.cxx b/src/SMDS/SMDS_VtkVolume.cxx index 7e66a83c8..3db0ba03b 100644 --- a/src/SMDS/SMDS_VtkVolume.cxx +++ b/src/SMDS/SMDS_VtkVolume.cxx @@ -366,7 +366,6 @@ const SMDS_MeshNode* SMDS_VtkVolume::GetFaceNode(const int face_ind, const int n std::vector SMDS_VtkVolume::GetQuantities() const { vector quantities; - quantities.clear(); SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId]; vtkUnstructuredGrid* grid = mesh->getGrid(); vtkIdType aVtkType = grid->GetCellType(this->myVtkID); @@ -428,6 +427,22 @@ const SMDS_MeshNode* SMDS_VtkVolume::GetNode(const int ind) const { vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); vtkIdType aVtkType = grid->GetCellType(this->myVtkID); + if ( aVtkType == VTK_POLYHEDRON) + { + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + grid->GetFaceStream(this->myVtkID, nFaces, ptIds); + int id = 0, nbPoints = 0; + for (int i = 0; i < nFaces; i++) + { + int nodesInFace = ptIds[id]; + if ( ind < nbPoints + nodesInFace ) + return SMDS_Mesh::_meshList[myMeshId]->FindNodeVtk( ptIds[ ind + i ]); + nbPoints += nodesInFace; + id += (nodesInFace + 1); + } + return 0; + } vtkIdType npts, *pts; grid->GetCellPoints( this->myVtkID, npts, pts ); const std::vector& interlace = SMDS_MeshCell::fromVtkOrder( VTKCellType( aVtkType )); diff --git a/src/SMESH/Makefile.am b/src/SMESH/Makefile.am index 32ad95643..d92df0a09 100644 --- a/src/SMESH/Makefile.am +++ b/src/SMESH/Makefile.am @@ -63,12 +63,12 @@ dist_libSMESHimpl_la_SOURCES = \ libSMESHimpl_la_CPPFLAGS = \ $(KERNEL_CXXFLAGS) \ $(CAS_CPPFLAGS) \ - $(MED_CXXFLAGS) \ $(GEOM_CXX_FLAGS) \ $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) \ @HDF5_INCLUDES@ \ -I$(srcdir)/../Controls \ + -I$(srcdir)/../MEDWrapper/Base \ -I$(srcdir)/../Driver \ -I$(srcdir)/../DriverDAT \ -I$(srcdir)/../DriverMED \ diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index 63d232027..263a1e673 100644 --- a/src/SMESH/SMESH_Algo.cxx +++ b/src/SMESH/SMESH_Algo.cxx @@ -175,7 +175,7 @@ const SMESH_Algo::Features& SMESH_Algo::GetFeatures( const std::string& algoType SMESH_Algo::SMESH_Algo (int hypId, int studyId, SMESH_Gen * gen) : SMESH_Hypothesis(hypId, studyId, gen) { - gen->_mapAlgo[hypId] = this; + //gen->_mapAlgo[hypId] = this; _onlyUnaryInput = _requireDiscreteBoundary = _requireShape = true; _quadraticMesh = _supportSubmeshes = false; @@ -205,28 +205,28 @@ SMESH_0D_Algo::SMESH_0D_Algo(int hypId, int studyId, SMESH_Gen* gen) { _shapeType = (1 << TopAbs_VERTEX); _type = ALGO_0D; - gen->_map0D_Algo[hypId] = this; + //gen->_map0D_Algo[hypId] = this; } SMESH_1D_Algo::SMESH_1D_Algo(int hypId, int studyId, SMESH_Gen* gen) : SMESH_Algo(hypId, studyId, gen) { _shapeType = (1 << TopAbs_EDGE); _type = ALGO_1D; - gen->_map1D_Algo[hypId] = this; + //gen->_map1D_Algo[hypId] = this; } SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen) : SMESH_Algo(hypId, studyId, gen) { _shapeType = (1 << TopAbs_FACE); _type = ALGO_2D; - gen->_map2D_Algo[hypId] = this; + //gen->_map2D_Algo[hypId] = this; } SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen) : SMESH_Algo(hypId, studyId, gen) { _shapeType = (1 << TopAbs_SOLID); _type = ALGO_3D; - gen->_map3D_Algo[hypId] = this; + //gen->_map3D_Algo[hypId] = this; } //============================================================================= @@ -681,6 +681,17 @@ void SMESH_Algo::CancelCompute() _error = COMPERR_CANCELED; } +//================================================================================ +/* + * If possible, returns progress of computation [0.,1.] + */ +//================================================================================ + +double SMESH_Algo::GetProgress() const +{ + return _progress; +} + //================================================================================ /*! * \brief store error and comment and then return ( error == COMPERR_OK ) @@ -728,7 +739,7 @@ SMESH_ComputeErrorPtr SMESH_Algo::GetComputeError() const //================================================================================ /*! - * \brief initialize compute error + * \brief initialize compute error before call of Compute() */ //================================================================================ @@ -743,6 +754,27 @@ void SMESH_Algo::InitComputeError() _badInputElements.clear(); _computeCanceled = false; + _progressTic = 0; + _progress = 0.; +} + +//================================================================================ +/*! + * \brief Return compute progress by nb of calls of this method + */ +//================================================================================ + +double SMESH_Algo::GetProgressByTic() const +{ + int computeCost = 0; + for ( size_t i = 0; i < _smToCompute.size(); ++i ) + computeCost += _smToCompute[i]->GetComputeCost(); + + const_cast( this )->_progressTic++; + + double x = 5 * _progressTic; + x = ( x < computeCost ) ? ( x / computeCost ) : 1.; + return 0.9 * sin( x * M_PI / 2 ); } //================================================================================ diff --git a/src/SMESH/SMESH_Algo.hxx b/src/SMESH/SMESH_Algo.hxx index 25224689a..acb852b72 100644 --- a/src/SMESH/SMESH_Algo.hxx +++ b/src/SMESH/SMESH_Algo.hxx @@ -169,6 +169,11 @@ class SMESH_EXPORT SMESH_Algo : public SMESH_Hypothesis */ virtual void CancelCompute(); + /*! + * \brief If possible, returns progress of computation [0.,1.] + */ + virtual double GetProgress() const; + /*! * \brief evaluates size of prospective mesh on a shape * \param aMesh - the mesh @@ -224,14 +229,23 @@ class SMESH_EXPORT SMESH_Algo : public SMESH_Hypothesis */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); + /*! * \brief return compute error */ SMESH_ComputeErrorPtr GetComputeError() const; /*! - * \brief initialize compute error + * \brief initialize compute error etc. before call of Compute() */ void InitComputeError(); + /*! + * \brief Return compute progress by nb of calls of this method + */ + double GetProgressByTic() const; + /*! + * Return a vector of sub-meshes to Compute() + */ + std::vector& SubMeshesToCompute() { return _smToCompute; } public: // ================================================================== @@ -407,8 +421,14 @@ protected: std::list _badInputElements; //!< to explain COMPERR_BAD_INPUT_MESH volatile bool _computeCanceled; //!< is set to True while computing to stop it + + double _progress; /* progress of Compute() [0.,1.], + to be set by an algo really tracking the progress */ + int _progressTic; // counter of calls from SMESH_Mesh::GetComputeProgress() + std::vector _smToCompute; // sub-meshes to Compute() }; + class SMESH_EXPORT SMESH_0D_Algo: public SMESH_Algo { public: diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index fa720985a..d51535139 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -120,16 +120,17 @@ SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode) } //============================================================================= -/*! +/* * Compute a mesh */ //============================================================================= bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, - const bool anUpward, - const ::MeshDimension aDim, - TSetOfInt* aShapesId) + const bool aShapeOnly /*=false*/, + const bool anUpward /*=false*/, + const ::MeshDimension aDim /*=::MeshDim_3D*/, + TSetOfInt* aShapesId /*=0*/) { MESSAGE("SMESH_Gen::Compute"); MEMOSTAT; @@ -143,11 +144,12 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const int globalAlgoDim = 100; SMESH_subMeshIteratorPtr smIt; - SMESH_subMesh::compute_event computeEvent; - if ( !anUpward && aShape.IsSame( aMesh.GetShapeToMesh() )) - computeEvent = SMESH_subMesh::COMPUTE; - else - computeEvent = SMESH_subMesh::COMPUTE_SUBMESH; + + // Fix of Issue 22150. Due to !BLSURF->OnlyUnaryInput(), BLSURF computes edges + // that must be computed by Projection 1D-2D when Projection asks to compute + // one face only. + SMESH_subMesh::compute_event computeEvent = + aShapeOnly ? SMESH_subMesh::COMPUTE_SUBMESH : SMESH_subMesh::COMPUTE; if ( anUpward ) // is called from the below code in this method { @@ -331,7 +333,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, SMESH_Hypothesis::Hypothesis_Status status; if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status )) // mesh a lower smToCompute starting from vertices - Compute( aMesh, aSubShape, /*anUpward=*/true, aDim, aShapesId ); + Compute( aMesh, aSubShape, aShapeOnly, /*anUpward=*/true, aDim, aShapesId ); } } } @@ -363,7 +365,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, // ----------------------------------------------- // mesh the rest sub-shapes starting from vertices // ----------------------------------------------- - ret = Compute( aMesh, aShape, /*anUpward=*/true, aDim, aShapesId ); + ret = Compute( aMesh, aShape, aShapeOnly, /*anUpward=*/true, aDim, aShapesId ); } MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret); diff --git a/src/SMESH/SMESH_Gen.hxx b/src/SMESH/SMESH_Gen.hxx index 496ca9b69..53610552b 100644 --- a/src/SMESH/SMESH_Gen.hxx +++ b/src/SMESH/SMESH_Gen.hxx @@ -70,6 +70,8 @@ public: /*! * \brief Computes aMesh on aShape + * \param aShapeOnly - if true, algo->OnlyUnaryInput() feature is ignored and + * only \a aShape is computed. * \param anUpward - compute from vertices up to more complex shape (internal usage) * \param aDim - upper level dimension of the mesh computation * \param aShapesId - list of shapes with computed mesh entities (elements or nodes) @@ -77,16 +79,17 @@ public: */ bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, + const bool aShapeOnly=false, const bool anUpward=false, const ::MeshDimension aDim=::MeshDim_3D, TSetOfInt* aShapesId=0); -#ifdef WITH_SMESH_CANCEL_COMPUTE void PrepareCompute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); void CancelCompute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); -#endif + + const SMESH_subMesh* GetCurrentSubMesh() const { return _sm_current; } /*! * \brief evaluates size of prospective mesh on a shape @@ -151,11 +154,11 @@ public: int GetANewId(); - std::map < int, SMESH_Algo * >_mapAlgo; - std::map < int, SMESH_0D_Algo * >_map0D_Algo; - std::map < int, SMESH_1D_Algo * >_map1D_Algo; - std::map < int, SMESH_2D_Algo * >_map2D_Algo; - std::map < int, SMESH_3D_Algo * >_map3D_Algo; + // std::map < int, SMESH_Algo * >_mapAlgo; + // std::map < int, SMESH_0D_Algo * >_map0D_Algo; + // std::map < int, SMESH_1D_Algo * >_map1D_Algo; + // std::map < int, SMESH_2D_Algo * >_map2D_Algo; + // std::map < int, SMESH_3D_Algo * >_map3D_Algo; private: @@ -168,14 +171,13 @@ private: // number of segments per diagonal of boundary box of geometry by which // default segment length of appropriate 1D hypotheses is defined int _segmentation; - // default of segments + // default number of segments int _nbSegments; + counters *_counters; -#ifdef WITH_SMESH_CANCEL_COMPUTE - volatile bool _compute_canceled; + volatile bool _compute_canceled; SMESH_subMesh* _sm_current; -#endif }; #endif diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 9bf36fb1f..bcddd46d5 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -592,19 +593,9 @@ SMESH_Hypothesis::Hypothesis_Status if ( !subMesh || !subMesh->GetId()) return SMESH_Hypothesis::HYP_BAD_SUBSHAPE; - StudyContextStruct *sc = _gen->GetStudyContext(_studyId); - if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end()) - { - if(MYDEBUG) MESSAGE("Hypothesis ID does not give an hypothesis"); - if(MYDEBUG) { - SCRUTE(_studyId); - SCRUTE(anHypId); - } + SMESH_Hypothesis *anHyp = GetHypothesis( anHypId ); + if ( !anHyp ) throw SALOME_Exception(LOCALIZED("hypothesis does not exist")); - } - - SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId]; - MESSAGE( "SMESH_Mesh::AddHypothesis " << anHyp->GetName() ); bool isGlobalHyp = IsMainShape( aSubShape ); @@ -682,8 +673,7 @@ SMESH_Hypothesis::Hypothesis_Status SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId]; if(MYDEBUG) { - int hypType = anHyp->GetType(); - SCRUTE(hypType); + SCRUTE(anHyp->GetType()); } // shape @@ -877,6 +867,22 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape, return nbHyps; } +//================================================================================ +/*! + * \brief Return a hypothesis by its ID + */ +//================================================================================ + +SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const int anHypId) const +{ + StudyContextStruct *sc = _gen->GetStudyContext(_studyId); + if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end()) + return false; + + SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId]; + return anHyp; +} + //============================================================================= /*! * @@ -1249,19 +1255,21 @@ void SMESH_Mesh::ExportMED(const char * file, const char* theMeshName, bool theAutoGroups, int theVersion, - const SMESHDS_Mesh* meshPart) + const SMESHDS_Mesh* meshPart, + bool theAutoDimension) throw(SALOME_Exception) { Unexpect aCatch(SalomeException); DriverMED_W_SMESHDS_Mesh myWriter; - myWriter.SetFile ( file, MED::EVersion(theVersion) ); - myWriter.SetMesh ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS ); + myWriter.SetFile ( file, MED::EVersion(theVersion) ); + myWriter.SetMesh ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS ); + myWriter.SetAutoDimension( theAutoDimension ); if ( !theMeshName ) - myWriter.SetMeshId ( _id ); + myWriter.SetMeshId ( _id ); else { - myWriter.SetMeshId ( -1 ); - myWriter.SetMeshName( theMeshName ); + myWriter.SetMeshId ( -1 ); + myWriter.SetMeshName ( theMeshName ); } if ( theAutoGroups ) { @@ -1300,6 +1308,12 @@ void SMESH_Mesh::ExportMED(const char * file, myWriter.Perform(); } +//================================================================================ +/*! + * \brief Export the mesh to a SAUV file + */ +//================================================================================ + void SMESH_Mesh::ExportSAUV(const char *file, const char* theMeshName, bool theAutoGroups) @@ -1444,6 +1458,66 @@ void SMESH_Mesh::ExportGMF(const char * file, myWriter.Perform(); } +//================================================================================ +/*! + * \brief Return a ratio of "compute cost" of computed sub-meshes to the whole + * "compute cost". + */ +//================================================================================ + +double SMESH_Mesh::GetComputeProgress() const +{ + double totalCost = 1e-100, computedCost = 0; + const SMESH_subMesh* curSM = _gen->GetCurrentSubMesh(); + + // get progress of a current algo + TColStd_MapOfInteger currentSubIds; + if ( curSM ) + if ( SMESH_Algo* algo = curSM->GetAlgo() ) + { + int algoNotDoneCost = 0, algoDoneCost = 0; + const std::vector& smToCompute = algo->SubMeshesToCompute(); + for ( size_t i = 0; i < smToCompute.size(); ++i ) + { + if ( smToCompute[i]->IsEmpty() ) + algoNotDoneCost += smToCompute[i]->GetComputeCost(); + else + algoDoneCost += smToCompute[i]->GetComputeCost(); + currentSubIds.Add( smToCompute[i]->GetId() ); + } + double rate = algo->GetProgress(); + if ( !( 0. < rate && rate < 1.001 )) + { + rate = algo->GetProgressByTic(); + } + // cout << "rate: "<getDependsOnIterator(/*includeSelf=*/true); + while ( smIt->more() ) + { + const SMESH_subMesh* sm = smIt->next(); + const int smCost = sm->GetComputeCost(); + totalCost += smCost; + if ( !currentSubIds.Contains( sm->GetId() ) ) + { + if (( !sm->IsEmpty() ) || + ( sm->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE && + !sm->DependsOn( curSM ) )) + computedCost += smCost; + } + } + } + // cout << "Total: " << totalCost + // << " computed: " << computedCost << " progress: " << computedCost / totalCost + // << " nbElems: " << GetMeshDS()->GetMeshInfo().NbElements() << endl; + return computedCost / totalCost; +} + //================================================================================ /*! * \brief Return number of nodes in the mesh diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index e329e0313..fa6abc0bb 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -148,6 +148,8 @@ public: const bool andAncestors, std::list< TopoDS_Shape > * assignedTo=0) const; + SMESH_Hypothesis * GetHypothesis(const int aHypID) const; + const std::list & GetLog() throw(SALOME_Exception); void ClearLog() throw(SALOME_Exception); @@ -229,11 +231,12 @@ public: */ bool HasDuplicatedGroupNamesMED(); - void ExportMED(const char *file, - const char* theMeshName = NULL, - bool theAutoGroups = true, - int theVersion = 0, - const SMESHDS_Mesh* meshPart = 0) + void ExportMED(const char * theFile, + const char* theMeshName = NULL, + bool theAutoGroups = true, + int theVersion = 0, + const SMESHDS_Mesh* theMeshPart = 0, + bool theAutoDimension = false) throw(SALOME_Exception); void ExportDAT(const char * file, @@ -251,6 +254,8 @@ public: void ExportSAUV(const char *file, const char* theMeshName = NULL, bool theAutoGroups = true) throw(SALOME_Exception); + + double GetComputeProgress() const; int NbNodes() const throw(SALOME_Exception); int Nb0DElements() const throw(SALOME_Exception); diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 4e9a0f48d..16ed768ec 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -105,9 +105,11 @@ using namespace SMESH::Controls; namespace { - SMDS_ElemIteratorPtr elemSetIterator( const TIDSortedElemSet& elements ) + template < class ELEM_SET > + SMDS_ElemIteratorPtr elemSetIterator( const ELEM_SET& elements ) { - typedef SMDS_SetIterator< SMDS_pElement, TIDSortedElemSet::const_iterator> TSetIterator; + typedef SMDS_SetIterator + < SMDS_pElement, typename ELEM_SET::const_iterator> TSetIterator; return SMDS_ElemIteratorPtr( new TSetIterator( elements.begin(), elements.end() )); } } @@ -424,10 +426,20 @@ void SMESH_MeshEditor::Create0DElementsOnAllNodes( const TIDSortedElemSet& eleme TIDSortedElemSet& all0DElems ) { SMDS_ElemIteratorPtr elemIt; + vector< const SMDS_MeshElement* > allNodes; if ( elements.empty() ) + { + allNodes.reserve( GetMeshDS()->NbNodes() ); elemIt = GetMeshDS()->elementsIterator( SMDSAbs_Node ); + while ( elemIt->more() ) + allNodes.push_back( elemIt->next() ); + + elemIt = elemSetIterator( allNodes ); + } else + { elemIt = elemSetIterator( elements ); + } while ( elemIt->more() ) { @@ -9586,6 +9598,95 @@ SMESH_MeshEditor::FindMatchingNodes(set& theSide1, return SEW_OK; } +//================================================================================ +/*! + * \brief Create elements equal (on same nodes) to given ones + * \param [in] theElements - a set of elems to duplicate. If it is empty, all + * elements of the uppest dimension are duplicated. + */ +//================================================================================ + +void SMESH_MeshEditor::DoubleElements( const TIDSortedElemSet& theElements ) +{ + CrearLastCreated(); + SMESHDS_Mesh* mesh = GetMeshDS(); + + // get an element type and an iterator over elements + + SMDSAbs_ElementType type; + SMDS_ElemIteratorPtr elemIt; + vector< const SMDS_MeshElement* > allElems; + if ( theElements.empty() ) + { + if ( mesh->NbNodes() == 0 ) + return; + // get most complex type + SMDSAbs_ElementType types[SMDSAbs_NbElementTypes] = { + SMDSAbs_Volume, SMDSAbs_Face, SMDSAbs_Edge, + SMDSAbs_0DElement, SMDSAbs_Ball, SMDSAbs_Node + }; + for ( int i = 0; i < SMDSAbs_NbElementTypes; ++i ) + if ( mesh->GetMeshInfo().NbElements( types[i] )) + { + type = types[i]; + break; + } + // put all elements in the vector + allElems.reserve( mesh->GetMeshInfo().NbElements( type )); + elemIt = mesh->elementsIterator( type ); + while ( elemIt->more() ) + allElems.push_back( elemIt->next()); + elemIt = elemSetIterator( allElems ); + } + else + { + type = (*theElements.begin())->GetType(); + elemIt = elemSetIterator( theElements ); + } + + // duplicate elements + + if ( type == SMDSAbs_Ball ) + { + SMDS_UnstructuredGrid* vtkGrid = mesh->getGrid(); + while ( elemIt->more() ) + { + const SMDS_MeshElement* elem = elemIt->next(); + if ( elem->GetType() != SMDSAbs_Ball ) + continue; + if (( elem = mesh->AddBall( elem->GetNode(0), + vtkGrid->GetBallDiameter( elem->getVtkId() )))) + myLastCreatedElems.Append( elem ); + } + } + else + { + vector< const SMDS_MeshNode* > nodes; + while ( elemIt->more() ) + { + const SMDS_MeshElement* elem = elemIt->next(); + if ( elem->GetType() != type ) + continue; + + nodes.assign( elem->begin_nodes(), elem->end_nodes() ); + + if ( type == SMDSAbs_Volume && elem->GetVtkType() == VTK_POLYHEDRON ) + { + std::vector quantities = + static_cast< const SMDS_VtkVolume* >( elem )->GetQuantities(); + elem = mesh->AddPolyhedralVolume( nodes, quantities ); + } + else + { + AddElement( nodes, type, elem->IsPoly() ); + elem = 0; // myLastCreatedElems is already filled + } + if ( elem ) + myLastCreatedElems.Append( elem ); + } + } +} + //================================================================================ /*! \brief Creates a hole in a mesh by doubling the nodes of some particular elements @@ -10890,7 +10991,8 @@ void SMESH_MeshEditor::CreateHoleSkin(double radius, double z = nodesCoords[i++]; gp_Pnt p = gp_Pnt(x, y ,z); gpnts.push_back(p); - MESSAGE("TopoDS_Vertex " << k++ << " " << p.X() << " " << p.Y() << " " << p.Z()); + MESSAGE("TopoDS_Vertex " << k << " " << p.X() << " " << p.Y() << " " << p.Z()); + k++; } } else // --- no group, no coordinates : use the vertices of the geom shape provided, and radius diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx index 7796b7cbc..e8b403e6e 100644 --- a/src/SMESH/SMESH_MeshEditor.hxx +++ b/src/SMESH/SMESH_MeshEditor.hxx @@ -504,6 +504,8 @@ public: // Return an index of the shape theElem is on // or zero if a shape not found + void DoubleElements( const TIDSortedElemSet& theElements ); + bool DoubleNodes( const std::list< int >& theListOfNodes, const std::list< int >& theListOfModifiedElems ); diff --git a/src/SMESH/SMESH_MesherHelper.cxx b/src/SMESH/SMESH_MesherHelper.cxx index 314a0f5c7..316bcea62 100644 --- a/src/SMESH/SMESH_MesherHelper.cxx +++ b/src/SMESH/SMESH_MesherHelper.cxx @@ -845,7 +845,7 @@ gp_XY SMESH_MesherHelper::GetCenterUV(const gp_XY& uv1, double SMESH_MesherHelper::GetNodeU(const TopoDS_Edge& E, const SMDS_MeshNode* n, const SMDS_MeshNode* inEdgeNode, - bool* check) + bool* check) const { double param = Precision::Infinite(); @@ -2489,9 +2489,16 @@ bool SMESH_MesherHelper::IsReversedSubMesh (const TopoDS_Face& theFace) { SMESH_TNodeXYZ nPnt[3]; SMDS_ElemIteratorPtr nodesIt = elem->nodesIterator(); + int iNodeOnFace = 0, iPosDim = SMDS_TOP_VERTEX; for ( int iN = 0; nodesIt->more() && iN < 3; ++iN) // loop on nodes + { nPnt[ iN ] = nodesIt->next(); - + if ( nPnt[ iN ]._node->GetPosition()->GetTypeOfPosition() > iPosDim ) + { + iNodeOnFace = iN; + iPosDim = nPnt[ iN ]._node->GetPosition()->GetTypeOfPosition(); + } + } // compute normal gp_Vec v01( nPnt[0], nPnt[1] ), v02( nPnt[0], nPnt[2] ); if ( v01.SquareMagnitude() > RealSmall() && @@ -2499,7 +2506,7 @@ bool SMESH_MesherHelper::IsReversedSubMesh (const TopoDS_Face& theFace) { Ne = v01 ^ v02; if (( normalOK = ( Ne.SquareMagnitude() > RealSmall() ))) - uv = GetNodeUV( theFace, nPnt[0]._node, nPnt[2]._node, &normalOK ); + uv = GetNodeUV( theFace, nPnt[iNodeOnFace]._node, 0, &normalOK ); } } } diff --git a/src/SMESH/SMESH_MesherHelper.hxx b/src/SMESH/SMESH_MesherHelper.hxx index e6f5bb239..f2b4d9ffc 100644 --- a/src/SMESH/SMESH_MesherHelper.hxx +++ b/src/SMESH/SMESH_MesherHelper.hxx @@ -420,7 +420,7 @@ public: double GetNodeU(const TopoDS_Edge& theEdge, const SMDS_MeshNode* theNode, const SMDS_MeshNode* inEdgeNode=0, - bool* check=0); + bool* check=0) const; /*! * \brief Return node UV on face * \param inFaceNode - a node of element being created located inside a face diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index 9d0c236e0..483495be5 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -104,6 +104,8 @@ SMESH_subMesh::SMESH_subMesh(int Id, _algoState = NO_ALGO; _computeState = NOT_READY; } + _computeCost = 0; // how costly is to compute this sub-mesh + _realComputeCost = 0; } //============================================================================= @@ -355,6 +357,48 @@ bool SMESH_subMesh::SubMeshesComputed(bool * isFailedToCompute/*=0*/) const return subMeshesComputed; } +//================================================================================ +/*! + * \brief Return cost of computing this sub-mesh. If hypotheses are not well defined, + * zero is returned + * \return int - the computation cost in abstract units. + */ +//================================================================================ + +int SMESH_subMesh::GetComputeCost() const +{ + return _realComputeCost; +} + +//================================================================================ +/*! + * \brief Return cost of computing this sub-mesh. The cost depends on the shape type + * and number of sub-meshes this one DependsOn(). + * \return int - the computation cost in abstract units. + */ +//================================================================================ + +int SMESH_subMesh::computeCost() const +{ + if ( !_computeCost ) + { + int computeCost; + switch ( _subShape.ShapeType() ) { + case TopAbs_SOLID: + case TopAbs_SHELL: computeCost = 1000; break; + case TopAbs_FACE: computeCost = 100; break; + case TopAbs_EDGE: computeCost = 10; break; + default: computeCost = 1; + } + SMESH_subMeshIteratorPtr childIt = getDependsOnIterator(/*includeSelf=*/false); + while ( childIt->more() ) + computeCost += childIt->next()->computeCost(); + + ((SMESH_subMesh*)this)->_computeCost = computeCost; + } + return _computeCost; +} + //============================================================================= /*! * @@ -501,6 +545,23 @@ const map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn() return _mapDepend; } +//================================================================================ +/*! + * \brief Return a key for SMESH_subMesh::_mapDepend map + */ +//================================================================================ + +namespace { + int dependsOnMapKey( const SMESH_subMesh* sm ) + { + int type = sm->GetSubShape().ShapeType(); + int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid + int cle = sm->GetId(); + cle += 10000000 * ordType; // sort map by ordType then index + return cle; + } +} + //============================================================================= /*! * For simple Shapes (solid, face, edge): add subMesh into dependence list. @@ -510,10 +571,7 @@ const map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn() void SMESH_subMesh::insertDependence(const TopoDS_Shape aSubShape) { SMESH_subMesh *aSubMesh = _father->GetSubMesh(aSubShape); - int type = aSubShape.ShapeType(); - int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid - int cle = aSubMesh->GetId(); - cle += 10000000 * ordType; // sort map by ordType then index + int cle = dependsOnMapKey( aSubMesh ); if ( _mapDepend.find( cle ) == _mapDepend.end()) { _mapDepend[cle] = aSubMesh; @@ -522,19 +580,28 @@ void SMESH_subMesh::insertDependence(const TopoDS_Shape aSubShape) } } +//================================================================================ +/*! + * \brief Return \c true if \a this sub-mesh depends on \a other + */ +//================================================================================ + +bool SMESH_subMesh::DependsOn( const SMESH_subMesh* other ) const +{ + return other ? _mapDepend.count( dependsOnMapKey( other )) : false; +} + //============================================================================= /*! - * + * Return a shape of \a this sub-mesh */ //============================================================================= const TopoDS_Shape & SMESH_subMesh::GetSubShape() const { - //MESSAGE("SMESH_subMesh::GetSubShape"); - return _subShape; + return _subShape; } - //======================================================================= //function : CanAddHypothesis //purpose : return true if theHypothesis can be attached to me: @@ -1074,6 +1141,8 @@ SMESH_Hypothesis::Hypothesis_Status if (stateChange || modifiedHyp) ComputeStateEngine(MODIF_ALGO_STATE); + _realComputeCost = ( _algoState == HYP_OK ) ? computeCost() : 0; + return ret; } @@ -1251,8 +1320,7 @@ void SMESH_subMesh::cleanDependsOn( SMESH_Algo* algoRequiringCleaning/*=0*/ ) void SMESH_subMesh::DumpAlgoState(bool isMain) { - int dim = SMESH_Gen::GetShapeDim(_subShape); -// if (dim < 1) return; + // if (dim < 1) return; if (isMain) { const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); @@ -1264,8 +1332,9 @@ void SMESH_subMesh::DumpAlgoState(bool isMain) sm->DumpAlgoState(false); } } - int type = _subShape.ShapeType(); - MESSAGE("dim = " << dim << " type of shape " << type); + //int type = _subShape.ShapeType(); + MESSAGE("dim = " << SMESH_Gen::GetShapeDim(_subShape) << + " type of shape " << _subShape.ShapeType()); switch (_algoState) { case NO_ALGO: @@ -1462,13 +1531,14 @@ bool SMESH_subMesh::ComputeStateEngine(int event) break; } TopoDS_Shape shape = _subShape; + algo->SubMeshesToCompute().assign( 1, this ); // check submeshes needed if (_father->HasShapeToMesh() ) { bool subComputed = false, subFailed = false; if (!algo->OnlyUnaryInput()) { if ( event == COMPUTE /*&& ( algo->NeedDiscreteBoundary() || algo->SupportSubmeshes() )*/) - shape = getCollection( gen, algo, subComputed, subFailed ); + shape = getCollection( gen, algo, subComputed, subFailed, algo->SubMeshesToCompute()); else subComputed = SubMeshesComputed( & subFailed ); } @@ -1501,6 +1571,7 @@ bool SMESH_subMesh::ComputeStateEngine(int event) OCC_CATCH_SIGNALS; #endif algo->InitComputeError(); + MemoryReserve aMemoryReserve; SMDS_Mesh::CheckMemory(); Kernel_Utils::Localizer loc; @@ -2028,7 +2099,8 @@ void SMESH_subMesh::removeSubMeshElementsAndNodes() TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * theGen, SMESH_Algo* theAlgo, bool & theSubComputed, - bool & theSubFailed) + bool & theSubFailed, + std::vector& theSubs) { theSubComputed = SubMeshesComputed( & theSubFailed ); @@ -2048,11 +2120,14 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * theGen, BRep_Builder aBuilder; aBuilder.MakeCompound( aCompound ); + theSubs.clear(); + TopExp_Explorer anExplorer( mainShape, _subShape.ShapeType() ); for ( ; anExplorer.More(); anExplorer.Next() ) { const TopoDS_Shape& S = anExplorer.Current(); SMESH_subMesh* subMesh = _father->GetSubMesh( S ); + theSubs.push_back( subMesh ); if ( subMesh == this ) { aBuilder.Add( aCompound, S ); diff --git a/src/SMESH/SMESH_subMesh.hxx b/src/SMESH/SMESH_subMesh.hxx index 48ed2be01..63ff08d3f 100644 --- a/src/SMESH/SMESH_subMesh.hxx +++ b/src/SMESH/SMESH_subMesh.hxx @@ -80,11 +80,13 @@ class SMESH_EXPORT SMESH_subMesh SMESH_Algo* GetAlgo() const; const std::map < int, SMESH_subMesh * >& DependsOn(); + bool DependsOn( const SMESH_subMesh* other ) const; /*! - * \brief Return iterator on the submeshes this one depends on + * \brief Return iterator on the sub-meshes this one depends on. By default + * most simple sub-meshes go first. */ SMESH_subMeshIteratorPtr getDependsOnIterator(const bool includeSelf, - const bool complexShapeFirst) const; + const bool complexShapeFirst=false) const; const TopoDS_Shape & GetSubShape() const; @@ -244,7 +246,7 @@ public: bool IsEmpty() const; bool IsMeshComputed() const; - // check if _subMeshDS contains mesh elements + // check if _subMeshDS contains mesh elements unless _alwaysComputed==true /*! * \brief Allow algo->Compute() if a subshape of lower dim is meshed but @@ -255,6 +257,8 @@ public: bool SubMeshesComputed(bool * isFailedToCompute=0) const; + int GetComputeCost() const; + // how costly is to compute this sub-mesh /*! * \brief Find common submeshes (based on shared subshapes with other @@ -283,7 +287,8 @@ protected: TopoDS_Shape getCollection(SMESH_Gen * theGen, SMESH_Algo* theAlgo, bool & theSubComputed, - bool & theSubFailed); + bool & theSubFailed, + std::vector& theSubs); /*! * \brief Update compute_state by _computeError * \retval bool - false if there are errors @@ -303,6 +308,7 @@ protected: const SMESH_Hypothesis * theHyp, const int theHypType = 0); // + int computeCost() const; protected: @@ -318,6 +324,8 @@ protected: algo_state _algoState; compute_state _computeState; SMESH_ComputeErrorPtr _computeError; + int _computeCost; // how costly is to compute this sub-mesh + int _realComputeCost; // _computeCost depending on presence of needed hypotheses // allow algo->Compute() if a sub-shape of lower dim is meshed but // none mesh entity is bound to it. Eg StdMeshers_CompositeSegment_1D can diff --git a/src/SMESHClient/Makefile.am b/src/SMESHClient/Makefile.am index a696d59df..e8e42e9fb 100644 --- a/src/SMESHClient/Makefile.am +++ b/src/SMESHClient/Makefile.am @@ -66,10 +66,12 @@ libSMESHClient_la_LDFLAGS = \ ../SMESH/libSMESHimpl.la \ ../SMESHDS/libSMESHDS.la \ ../Controls/libSMESHControls.la \ + ../MEDWrapper/Factory/libMEDWrapper.la \ + ../MEDWrapper/Base/libMEDWrapperBase.la \ + ../MEDWrapper/V2_2/libMEDWrapper_V2_2.la \ $(KERNEL_LDFLAGS) -lSalomeLifeCycleCORBA -lSalomeNS -lOpUtil -lSALOMEBasics \ -lSalomeIDLKernel -lSALOMELocalTrace \ $(GEOM_LDFLAGS) -lNMTDS -lSalomeIDLGEOM \ - $(MED_LDFLAGS) -lMEDWrapper_V2_2 -lSalomeIDLMED -lMEDWrapper \ $(CAS_KERNEL) SMESHClientBin_CPPFLAGS = \ diff --git a/src/SMESHGUI/Makefile.am b/src/SMESHGUI/Makefile.am index f2c9b5190..446bf6eec 100644 --- a/src/SMESHGUI/Makefile.am +++ b/src/SMESHGUI/Makefile.am @@ -267,6 +267,7 @@ libSMESH_la_CPPFLAGS = \ -I$(srcdir)/../SMESH_I \ -I$(srcdir)/../Controls \ -I$(srcdir)/../SMESHClient \ + -I$(srcdir)/../MEDWrapper/Base \ -I$(top_builddir) \ -I$(top_builddir)/idl diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 0bbbf9bda..33de52b4d 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -162,6 +162,7 @@ #include #include #include +#include // OCCT includes #include @@ -591,6 +592,7 @@ if ( resMgr ) toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false ); bool toOverwrite = true; + bool toFindOutDim = true; QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH"); QString anInitialPath = ""; @@ -612,32 +614,6 @@ anInitialPath + QString("/") + aMeshName, aFilter, aTitle, false); } - // else if ( isGMF )// Export to GMF - // { - // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg - // ( SMESHGUI::desktop(), false, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true ); - // QStringList filters; - // filters << QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" - // << QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)"; - // fd->setWindowTitle( aTitle ); - // fd->setNameFilters( filters ); - - // if ( !aMeshOrGroup->_is_equivalent( aMesh )) - // toCreateGroups = false; - // else - // toCreateGroups = ( aMesh->NbGroups() > 0 ); - - // fd->SetChecked( true ); - // if ( !anInitialPath.isEmpty() ) - // fd->setDirectory( anInitialPath ); - // fd->selectFile(aMeshName); - - // if ( fd->exec() ) - // aFilename = fd->selectedFile(); - // toCreateGroups = fd->IsChecked(); - - // delete fd; - // } else if ( isCGNS )// Export to CGNS { SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true ); @@ -705,13 +681,16 @@ if (it.value() == SMESH::MED_V2_2) aDefaultFilter = it.key(); } + QStringList checkBoxes; + checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM"); - SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg - ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true ); + SalomeApp_CheckFileDlg* fd = + new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true ); fd->setWindowTitle( aTitle ); fd->setNameFilters( filters ); fd->selectNameFilter(aDefaultFilter); - fd->SetChecked(toCreateGroups); + fd->SetChecked(0,toCreateGroups); + fd->SetChecked(1,toFindOutDim); if ( !anInitialPath.isEmpty() ) fd->setDirectory( anInitialPath ); fd->selectFile(aMeshName); @@ -794,7 +773,8 @@ } } } - toCreateGroups = fd->IsChecked(); + toCreateGroups = fd->IsChecked(0); + toFindOutDim = fd->IsChecked(1); delete fd; } else @@ -833,10 +813,10 @@ SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh(); if ( aMeshOrGroup->_is_equivalent( aMeshItem )) aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups, - aFormat, toOverwrite && aMeshIndex == 0 ); + aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim ); else aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups, - aFormat, toOverwrite && aMeshIndex == 0 ); + aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim ); } } else if ( isSAUV ) @@ -1017,6 +997,22 @@ SMESH::RepaintCurrentView(); } + void OverallMeshQuality() { + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + if ( selected.IsEmpty() ) return; + SALOME_ListIteratorOfListIO It( selected ); + for ( ; It.More(); It.Next() ) { + SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() ); + ctrlDlg->showInfo( It.Value() ); + ctrlDlg->show(); + } + } + QString functorToString( SMESH::Controls::FunctorPtr f ) { QString type = QObject::tr( "UNKNOWN_CONTROL" ); @@ -1226,6 +1222,25 @@ } } + void sortChildren(){ + LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + SALOME_ListIO selected; + if( aSel ) { + aSel->selectedObjects( selected ); + + if(selected.Extent()){ + Handle(SALOME_InteractiveObject) anIObject = selected.First(); + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry()); + if (aSObj) { + if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) { + SMESHGUI::GetSMESHGUI()->updateObjBrowser(); + } + } + } + } + } + void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap) { SALOME_ListIO selected; @@ -1981,6 +1996,82 @@ bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded) return autoUpdate && !exceeded; } +//============================================================================= +/*! + * + */ +//============================================================================= +bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh, + int* entities, bool* limitExceeded ) +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + if ( !resMgr ) + return false; + + bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false ); + long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 ); + bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false ); + + long requestedSize = theMesh->NbElements(); + + *entities = SMESH_Actor::eAllEntity; + + bool exceeded = updateLimit > 0 && requestedSize > updateLimit; + + if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded; + + if ( incrementalLimit ) { + long nbOdElems = theMesh->Nb0DElements(); + long nbEdges = theMesh->NbEdges(); + long nbFaces = theMesh->NbFaces(); + long nbVolumes = theMesh->NbVolumes(); + long nbBalls = theMesh->NbBalls(); + long total = 0; + + if ( nbOdElems > 0 ) { + if ( total + nbOdElems > updateLimit ) + *entities = *entities & ~SMESH_Actor::e0DElements; + else + exceeded = false; + } + total += nbOdElems; + + if ( nbEdges > 0 ) { + if ( total + nbEdges > updateLimit ) + *entities = *entities & ~SMESH_Actor::eEdges; + else + exceeded = false; + } + total += nbEdges; + + if ( nbFaces > 0 ) { + if ( total + nbFaces > updateLimit ) + *entities = *entities & ~SMESH_Actor::eFaces; + else + exceeded = false; + } + total += nbFaces; + + if ( nbVolumes > 0 ) { + if ( total + nbVolumes > updateLimit ) + *entities = *entities & ~SMESH_Actor::eVolumes; + else + exceeded = false; + } + total += nbVolumes; + + if ( nbBalls > 0 ) { + if ( total + nbBalls > updateLimit ) + *entities = *entities & ~SMESH_Actor::eBallElem; + else + exceeded = false; + } + total += nbBalls; + } + + return autoUpdate && !exceeded; +} + //============================================================================= /*! * @@ -2386,6 +2477,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 214: // UPDATE { if(checkLock(aStudy)) break; + SUIT_OverrideCursor wc; try { #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 OCC_CATCH_SIGNALS; @@ -3073,26 +3165,16 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) SMDSAbs_EntityType type = SMDSEntity_Last; switch (theCommandID) { - case 4034: - type = SMDSEntity_Quad_Edge; break; - case 4035: - type = SMDSEntity_Quad_Triangle; break; - case 4036: - type = SMDSEntity_Quad_Quadrangle; break; - case 4136: - type = SMDSEntity_BiQuad_Quadrangle; break; - case 4137: - type = SMDSEntity_BiQuad_Triangle; break; - case 4037: - type = SMDSEntity_Quad_Tetra; break; - case 4038: - type = SMDSEntity_Quad_Pyramid; break; - case 4039: - type = SMDSEntity_Quad_Penta; break; - case 4040: - type = SMDSEntity_Quad_Hexa; break; - case 4140: - type = SMDSEntity_TriQuad_Hexa; break; + case 4034: type = SMDSEntity_Quad_Edge; break; + case 4035: type = SMDSEntity_Quad_Triangle; break; + case 4036: type = SMDSEntity_Quad_Quadrangle; break; + case 4136: type = SMDSEntity_BiQuad_Quadrangle; break; + case 4137: type = SMDSEntity_BiQuad_Triangle; break; + case 4037: type = SMDSEntity_Quad_Tetra; break; + case 4038: type = SMDSEntity_Quad_Pyramid; break; + case 4039: type = SMDSEntity_Quad_Penta; break; + case 4040: type = SMDSEntity_Quad_Hexa; break; + case 4140: type = SMDSEntity_TriQuad_Hexa; break; default: break; } if ( type != SMDSEntity_Last ) @@ -3189,6 +3271,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) SUIT_MessageBox::No ) == SUIT_MessageBox::Yes; if( confirm ) { try { + SUIT_OverrideCursor wc; SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); int removed = aMeshEditor->RemoveOrphanNodes(); SUIT_MessageBox::information(SMESHGUI::desktop(), @@ -3408,6 +3491,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject ); SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject ); if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) { + SUIT_OverrideCursor wc; ::Control( theCommandID ); break; } @@ -3424,8 +3508,12 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) tr( "NOT_A_VTK_VIEWER" ) ); } break; + case 6032: + OverallMeshQuality(); + break; case 9010: { + SUIT_OverrideCursor wc; LightApp_SelectionMgr* mgr = selectionMgr(); SALOME_ListIO selected; mgr->selectedObjects( selected ); @@ -3442,6 +3530,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } case 9011: { + SUIT_OverrideCursor wc; LightApp_SelectionMgr* mgr = selectionMgr(); SALOME_ListIO selected; mgr->selectedObjects( selected ); @@ -3464,6 +3553,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) dlg->show(); break; } + case 41: + ::sortChildren(); + break; + } anApp->updateActions(); //SRN: To update a Save button in the toolbar @@ -3651,6 +3744,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true ); createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true ); createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true ); + createSMESHAction( 6032, "OVERALL_MESH_QUALITY" ); createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true ); createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true ); createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true ); @@ -3760,6 +3854,8 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( 301, "SHOW" ); createSMESHAction( 302, "DISPLAY_ONLY" ); + createSMESHAction( 41, "SORT_CHILD_ITEMS" ); + // ----- create menu -------------- int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ), editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ), @@ -3862,6 +3958,8 @@ void SMESHGUI::initialize( CAM_Application* app ) createMenu( 6024, volumeId, -1 ); createMenu( 6026, volumeId, -1 ); createMenu( 6031, volumeId, -1 ); + createMenu( separator(), ctrlId, -1 ); + createMenu( 6032, ctrlId, -1 ); createMenu( 4000, addId, -1 ); createMenu( 4009, addId, -1 ); @@ -4106,6 +4204,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createPopupItem( 214, OB, mesh_part ); // UPDATE createPopupItem( 900, OB, mesh_part ); // ADV_INFO createPopupItem( 904, OB, mesh_group ); // FIND_ELEM + createPopupItem( 6032, OB, mesh_part ); // CTRL_INFO popupMgr()->insert( separator(), -1, 0 ); createPopupItem( 801, OB, mesh ); // CREATE_GROUP createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP @@ -4147,6 +4246,7 @@ void SMESHGUI::initialize( CAM_Application* app ) popupMgr()->insert( separator(), -1, 0 ); createPopupItem( 214, View, mesh_part ); // UPDATE createPopupItem( 900, View, mesh_part ); // ADV_INFO + createPopupItem( 6032,View, mesh_part ); // CTRL_INFO createPopupItem( 904, View, mesh ); // FIND_ELEM popupMgr()->insert( separator(), -1, 0 ); @@ -4391,7 +4491,7 @@ void SMESHGUI::initialize( CAM_Application* app ) popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule ); - + popupMgr()->insert( separator(), anId, -1 ); popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP @@ -4438,6 +4538,10 @@ void SMESHGUI::initialize( CAM_Application* app ) popupMgr()->insert( separator(), -1, -1 ); + popupMgr()->insert( action( 41 ), -1, -1 ); + popupMgr()->setRule( action( 41 ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule ); + popupMgr()->insert( separator(), -1, -1 ); + connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ), this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) ); @@ -4678,11 +4782,13 @@ void SMESHGUI::createPreferences() int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) ); int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" ); + setPreferenceProperty( autoUpdate, "columns", 2 ); int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" ); setPreferenceProperty( lim, "min", 0 ); setPreferenceProperty( lim, "max", 100000000 ); setPreferenceProperty( lim, "step", 1000 ); setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) ); + addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" ); int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab ); setPreferenceProperty( qaGroup, "columns", 2 ); @@ -4767,10 +4873,16 @@ void SMESHGUI::createPreferences() setPreferenceProperty( nodesLim, "max", 10000000 ); setPreferenceProperty( nodesLim, "step", 10000 ); setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) ); + int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" ); + setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) ); + setPreferenceProperty( ctrlLim, "min", 0 ); + setPreferenceProperty( ctrlLim, "max", 10000000 ); + setPreferenceProperty( ctrlLim, "step", 1000 ); addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" ); addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" ); addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" ); addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" ); + addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" ); int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab ); setPreferenceProperty( segGroup, "columns", 2 ); diff --git a/src/SMESHGUI/SMESHGUI.h b/src/SMESHGUI/SMESHGUI.h index 1b990f099..8a38ec5ec 100644 --- a/src/SMESHGUI/SMESHGUI.h +++ b/src/SMESHGUI/SMESHGUI.h @@ -100,6 +100,7 @@ public : bool isActiveStudyLocked(); static bool automaticUpdate(unsigned int requestedSize = 0, bool* limitExceeded = 0); + static bool automaticUpdate( SMESH::SMESH_Mesh_ptr, int*, bool* ); static void Modified( bool = true ); diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx index be3fc2f18..ec8dd9523 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx @@ -33,6 +33,7 @@ #include "SMESHGUI_MeshOrderOp.h" #include "SMESHGUI_MeshOrderDlg.h" +#include "SMESH_Actor.h" #include "SMESH_ActorUtils.h" #include @@ -91,6 +92,7 @@ #include #include #include +#include // VTK includes #include @@ -99,25 +101,15 @@ #include #include +#ifndef WIN32 +#include +#endif + #define SPACING 6 #define MARGIN 11 #define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" ) -/* OBSOLETE -static void addSeparator( QWidget* parent ) -{ - QGridLayout* l = qobject_cast( parent->layout() ); - int row = l->rowCount(); - int cols = l->columnCount(); - for ( int i = 0; i < cols; i++ ) { - QFrame* hline = new QFrame( parent ); - hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - l->addWidget( hline, row, i ); - } -} -*/ - enum TCol { COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS }; @@ -740,25 +732,37 @@ SMESHGUI_ComputeDlg_QThreadQDialog::SMESHGUI_ComputeDlg_QThreadQDialog(QWidget qthread(gen, mesh, mainShape) { // -- - setWindowTitle(tr("Compute")); + setWindowTitle(tr("TITLE")); setMinimumWidth( 200 ); - cancelButton = new QPushButton(tr("Cancel")); + cancelButton = new QPushButton(tr("CANCEL")); cancelButton->setDefault(true); + cancelButton->setCheckable(true); QLabel * nbNodesName = new QLabel(tr("SMESH_MESHINFO_NODES"), this ); QLabel * nbElemsName = new QLabel(tr("SMESH_MESHINFO_ELEMENTS"), this ); + QLabel * freeRAMName = new QLabel(tr("SMESH_FREERAM"), this ); nbNodesLabel = new QLabel("0", this ); nbElemsLabel = new QLabel("0", this ); + freeRAMLabel = new QLabel("", this ); + progressBar = new QProgressBar(this); + progressBar->setMinimum( 0 ); + progressBar->setMaximum( 1000 ); QGridLayout* layout = new QGridLayout(this); layout->setMargin( MARGIN ); layout->setSpacing( SPACING ); - layout->addWidget(nbNodesName, 0, 0); - layout->addWidget(nbNodesLabel, 0, 1); - layout->addWidget(nbElemsName, 1, 0); - layout->addWidget(nbElemsLabel, 1, 1); - layout->addWidget(cancelButton, 2, 0, 1, 2); + int row = 0; + layout->addWidget(nbNodesName, row, 0); + layout->addWidget(nbNodesLabel, row++, 1); + layout->addWidget(nbElemsName, row, 0); + layout->addWidget(nbElemsLabel, row++, 1); +#ifndef WNT + layout->addWidget(freeRAMName, row, 0); + layout->addWidget(freeRAMLabel, row++, 1); +#endif + layout->addWidget(progressBar, row++, 0, 1, 2); + layout->addWidget(cancelButton, row++, 0, 1, 2); adjustSize(); update(); @@ -776,23 +780,40 @@ bool SMESHGUI_ComputeDlg_QThreadQDialog::result() void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel() { qthread.cancel(); -} + cancelButton->setText( tr("CANCELING")); + cancelButton->setEnabled(false); +} void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event) { + if ( !cancelButton->isChecked() ) // not yet cancelled + progressBar->setValue( progressBar->maximum() * qthread.getMesh()->GetComputeProgress() ); + if(qthread.isFinished()) - { - close(); - } - nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() )); - nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() )); + { + close(); + } + else + { + nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() )); + nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() )); +#ifndef WNT + struct sysinfo si; + const int err = sysinfo( &si ); + if ( err ) + freeRAMLabel->setText(""); + else + freeRAMLabel->setText( tr("SMESH_GIGABYTE").arg + ( si.freeram * si.mem_unit /1024./1024./1024., 0, 'f', 2 )); +#endif + } event->accept(); } void SMESHGUI_ComputeDlg_QThreadQDialog::closeEvent(QCloseEvent *event) { if(qthread.isRunning()) - { + { event->ignore(); return; } @@ -839,13 +860,9 @@ void SMESHGUI_BaseComputeOp::computeMesh() #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 OCC_CATCH_SIGNALS; #endif - bool res; SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myMainShape); qthreaddialog.exec(); - res = qthreaddialog.result(); - res = gen->Compute(myMesh, myMainShape); - if (res) - computeFailed = false; + computeFailed = !qthreaddialog.result(); } catch(const SALOME::SALOME_Exception & S_ex) { memoryLack = true; @@ -875,17 +892,31 @@ void SMESHGUI_BaseComputeOp::computeMesh() // SHOW MESH // NPAL16631: if ( getSMESHGUI()->automaticUpdate() ) SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() ); - long newSize = myMesh->NbElements(); bool limitExceeded; + long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 ); + int entities = SMESH_Actor::eAllEntity; if ( !memoryLack ) { - if ( getSMESHGUI()->automaticUpdate( newSize, &limitExceeded ) ) + if ( getSMESHGUI()->automaticUpdate( myMesh, &entities, &limitExceeded ) ) { try { #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 OCC_CATCH_SIGNALS; #endif + SMESH_Actor *anActor = SMESH::FindActorByObject( myMesh ); + if ( !anActor ) anActor = SMESH::CreateActor( aMeshSObj->GetStudy(), aMeshSObj->GetID().c_str(), true ); + + anActor->SetEntityMode( entities ); + SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor ); + SMESH::Update(myIObject, true); + + if ( limitExceeded ) + { + SUIT_MessageBox::warning( desktop(), + tr( "SMESH_WRN_WARNING" ), + tr( "SMESH_WRN_SIZE_INC_LIMIT_EXCEEDED" ).arg( myMesh->NbElements() ).arg( limitSize ) ); + } } catch (...) { #ifdef _DEBUG_ @@ -901,10 +932,9 @@ void SMESHGUI_BaseComputeOp::computeMesh() } else if ( limitExceeded ) { - long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 ); SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), - tr( "SMESH_WRN_SIZE_LIMIT_EXCEEDED" ).arg( newSize ).arg( limitSize ) ); + tr( "SMESH_WRN_SIZE_LIMIT_EXCEEDED" ).arg( myMesh->NbElements() ).arg( limitSize ) ); } } LightApp_SelectionMgr *Sel = selectionMgr(); diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.h b/src/SMESHGUI/SMESHGUI_ComputeDlg.h index 81a09f857..d67709d37 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.h +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.h @@ -49,6 +49,7 @@ class QPushButton; class QTableWidget; class QLabel; class QtxComboBox; +class QProgressBar; class SMESHGUI_ComputeDlg; class SMESHGUI_MeshInfosBox; class SMESHGUI_PrecomputeDlg; @@ -317,6 +318,8 @@ private: QPushButton * cancelButton; QLabel * nbNodesLabel; QLabel * nbElemsLabel; + QLabel * freeRAMLabel; + QProgressBar* progressBar; }; #endif // SMESHGUI_COMPUTEDLG_H diff --git a/src/SMESHGUI/SMESHGUI_DuplicateNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_DuplicateNodesDlg.cxx index 27c1c9d66..24d4a37cb 100644 --- a/src/SMESHGUI/SMESHGUI_DuplicateNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_DuplicateNodesDlg.cxx @@ -29,6 +29,7 @@ #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" +#include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_VTKUtils.h" #include @@ -63,6 +64,7 @@ #include #include +#include // IDL includes #include @@ -107,6 +109,7 @@ SMESHGUI_DuplicateNodesDlg::SMESHGUI_DuplicateNodesDlg( SMESHGUI* theModule ) SUIT_ResourceMgr* aResMgr = SMESH::GetResourceMgr( mySMESHGUI ); QPixmap iconWithoutElem (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_NODES"))); QPixmap iconWithElem (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_NODES_WITH_ELEM"))); + QPixmap iconElemOnly (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_ELEM_ONLY"))); QPixmap iconSelect (aResMgr->loadPixmap("SMESH", tr("ICON_SELECT"))); // Main layout @@ -125,11 +128,15 @@ SMESHGUI_DuplicateNodesDlg::SMESHGUI_DuplicateNodesDlg( SMESHGUI* theModule ) aRadioButton1->setIcon(iconWithoutElem); QRadioButton* aRadioButton2 = new QRadioButton(aConstructorsBox); aRadioButton2->setIcon(iconWithElem); + QRadioButton* aRadioButton3 = new QRadioButton(aConstructorsBox); + aRadioButton3->setIcon(iconElemOnly); aConstructorsBoxLayout->addWidget(aRadioButton1); aConstructorsBoxLayout->addWidget(aRadioButton2); + aConstructorsBoxLayout->addWidget(aRadioButton3); myGroupConstructors->addButton(aRadioButton1, 0); myGroupConstructors->addButton(aRadioButton2, 1); + myGroupConstructors->addButton(aRadioButton3, 2); // Arguments myGroupArguments = new QGroupBox(this); @@ -200,6 +207,9 @@ SMESHGUI_DuplicateNodesDlg::SMESHGUI_DuplicateNodesDlg( SMESHGUI* theModule ) aMainLayout->addWidget(myGroupArguments); aMainLayout->addWidget(aGroupButtons); + myCheckBoxNewElemGroup->setChecked(true); + myCheckBoxNewNodeGroup->setChecked(true); + // Initialize the dialog Init(); @@ -237,8 +247,6 @@ SMESHGUI_DuplicateNodesDlg::~SMESHGUI_DuplicateNodesDlg() void SMESHGUI_DuplicateNodesDlg::Init() { mySMESHGUI->SetActiveDialogBox((QDialog*)this); - myCheckBoxNewElemGroup->setChecked(true); - myCheckBoxNewNodeGroup->setChecked(true); // Set initial parameters myBusy = false; @@ -294,6 +302,9 @@ void SMESHGUI_DuplicateNodesDlg::onConstructorsClicked (int constructorId) myCheckBoxNewNodeGroup->show(); // Hide the third field + myTextLabel2->show(); + mySelectButton2->show(); + myLineEdit2->show(); myTextLabel3->hide(); mySelectButton3->hide(); myLineEdit3->hide(); @@ -312,10 +323,32 @@ void SMESHGUI_DuplicateNodesDlg::onConstructorsClicked (int constructorId) myCheckBoxNewNodeGroup->show(); // Show the third field + myTextLabel2->show(); + mySelectButton2->show(); + myLineEdit2->show(); myTextLabel3->show(); mySelectButton3->show(); myLineEdit3->show(); + break; + } + case 2: + { + // Set text to the group of arguments and to all the labels + myGroupArguments->setTitle(tr("DUPLICATION_ONLY_ELEMS")); + myTextLabel1->setText(tr("GROUP_ELEMS_TO_DUPLICATE")); + + myCheckBoxNewElemGroup->show(); + myCheckBoxNewNodeGroup->hide(); + + // Hide the second and the third field + myTextLabel2->hide(); + mySelectButton2->hide(); + myLineEdit2->hide(); + myTextLabel3->hide(); + mySelectButton3->hide(); + myLineEdit3->hide(); + break; } } @@ -336,17 +369,20 @@ bool SMESHGUI_DuplicateNodesDlg::onApply() bool toCreateElemGroup = myCheckBoxNewElemGroup->isChecked(); bool toCreateNodeGroup = myCheckBoxNewNodeGroup->isChecked(); - int operationMode = myGroupConstructors->checkedId(); + int operationMode = myGroupConstructors->checkedId(); // Apply changes bool result = false; SUIT_OverrideCursor aWaitCursor; + QStringList anEntryList; try { SMESH::SMESH_Mesh_var aMesh = myGroups1[0]->GetMesh(); SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); - if ( operationMode == 0 ) { + switch ( operationMode ) { + case 0: + { SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups(); g1->length( myGroups1.count() ); for ( int i = 0; i < myGroups1.count(); i++ ) @@ -364,8 +400,10 @@ bool SMESHGUI_DuplicateNodesDlg::onApply() else { result = aMeshEditor->DoubleNodeGroups( g1.in(), g2.in() ); } + break; } - else { + case 1: + { SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups(); g1->length( myGroups1.count() ); for ( int i = 0; i < myGroups1.count(); i++ ) @@ -388,6 +426,31 @@ bool SMESHGUI_DuplicateNodesDlg::onApply() else { result = aMeshEditor->DoubleNodeElemGroups( g1.in(), g2.in(), g3.in() ); } + break; + } + case 2: + { + result = true; + QString groupName; + if ( toCreateElemGroup ) + groupName = SMESH::UniqueName("DoubleElements"); + for ( int i = 0; i < myGroups1.count(); i++ ) + { + SMESH::SMESH_Group_var group = + aMeshEditor->DoubleElements( myGroups1[i], groupName.toLatin1().data() ); + if ( group->_is_nil() ) + { + if ( toCreateElemGroup ) + result = false; + } + else + { + if ( _PTR(SObject) so = SMESH::FindSObject( group )) + anEntryList.append( so->GetID().c_str() ); + } + } + break; + } } } catch (const SALOME::SALOME_Exception& S_ex) { @@ -396,7 +459,7 @@ bool SMESHGUI_DuplicateNodesDlg::onApply() catch ( const std::exception& exc ) { INFOS( "Follow exception was cought:\n\t" << exc.what() ); } - catch (...){ + catch (...) { INFOS( "Unknown exception was cought !!!" ); } @@ -413,9 +476,14 @@ bool SMESHGUI_DuplicateNodesDlg::onApply() SMESHGUI::Modified(); mySMESHGUI->updateObjBrowser(true); + if ( !anEntryList.isEmpty()) + if( LightApp_Application* anApp = + dynamic_cast( SUIT_Session::session()->activeApplication() )) + anApp->browseObjects( anEntryList, true, false ); + // Reinitialize the dialog Init(); - + return true; } @@ -471,15 +539,20 @@ void SMESHGUI_DuplicateNodesDlg::onSelectionChanged() // check group of proper type is selected if ( ok ) { SMESH::ElementType aGroupType = aGroup->GetType(); - if ( operationMode == 0 ) { + switch ( operationMode ) { + case 0: ok = ( myCurrentLineEdit == myLineEdit1 && aGroupType == SMESH::NODE ) || ( myCurrentLineEdit == myLineEdit2 && aGroupType != SMESH::NODE ); - } - else { + break; + case 1: ok = ( myCurrentLineEdit == myLineEdit1 && ( aGroupType == SMESH::EDGE || aGroupType == SMESH::FACE ) ) || ( myCurrentLineEdit == myLineEdit2 && aGroupType == SMESH::NODE ) || ( myCurrentLineEdit == myLineEdit3 && aGroupType != SMESH::NODE ); + break; + case 2: + ok = ( aGroupType != SMESH::NODE ); + break; } } if ( ok ) aGroups << aGroup; @@ -533,7 +606,7 @@ void SMESHGUI_DuplicateNodesDlg::onEditCurrentArgument() /*! \brief Check if the input data is valid. - \return \c true id the data is valid + \return \c true if the data is valid */ bool SMESHGUI_DuplicateNodesDlg::isValid() { diff --git a/src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx b/src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx index d850c3071..498a72dad 100644 --- a/src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx @@ -23,13 +23,13 @@ // #include "SMESHGUI_FileInfoDlg.h" -#include +#include "MED_Common.hxx" #include #include #include -SMESHGUI_FileInfoDlg::SMESHGUI_FileInfoDlg( QWidget* parent, SALOME_MED::MedFileInfo* inf ) +SMESHGUI_FileInfoDlg::SMESHGUI_FileInfoDlg( QWidget* parent, SMESH::MedFileInfo* inf ) : QtxDialog( parent, true, true, QtxDialog::OK ) { setWindowTitle( tr( "CAPTION" ) ); diff --git a/src/SMESHGUI/SMESHGUI_FileInfoDlg.h b/src/SMESHGUI/SMESHGUI_FileInfoDlg.h index a1264d9a2..2cab5a95b 100644 --- a/src/SMESHGUI/SMESHGUI_FileInfoDlg.h +++ b/src/SMESHGUI/SMESHGUI_FileInfoDlg.h @@ -27,14 +27,14 @@ #include #include -#include CORBA_CLIENT_HEADER(MED) +#include CORBA_CLIENT_HEADER(SMESH_Mesh) class SMESHGUI_FileInfoDlg : public QtxDialog { Q_OBJECT public: - SMESHGUI_FileInfoDlg( QWidget*, SALOME_MED::MedFileInfo* ); + SMESHGUI_FileInfoDlg( QWidget*, SMESH::MedFileInfo* ); virtual ~SMESHGUI_FileInfoDlg(); }; diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index 07f8a30a5..df5618fc2 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -1765,185 +1765,216 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con Table* aTable = myTables[ aType ]; ComboItem* aCompareItem = (ComboItem*)aTable->item(row, 1); - int aCriterionType = GetCriterionType(row); + // find out type of a existing threshould table item QtxColorButton* clrBtn = qobject_cast(aTable->cellWidget(row, 2)); - int aComboType = ComboItem::Type(); - int aIntSpinType = IntSpinItem::Type(); - int aDoubleSpinType = DoubleSpinItem::Type(); - QTableWidgetItem* aTableItem = aTable->item(row, 2); - bool isComboItem = false; - bool isIntSpinItem = false; - bool isDoubleSpinItem = false; - if (aTableItem) { - int aTableType = aTable->item(row, 2)->type(); - isComboItem = ( aTableType == aComboType ); - isIntSpinItem = ( aTableType == aIntSpinType ); - isDoubleSpinItem = ( aTableType == aDoubleSpinType ); + bool isComboItem = false; + bool isIntSpinItem = false; + bool isDoubleSpinItem = false; + if ( QTableWidgetItem* aTableItem = aTable->item(row, 2) ) + { + int aTableType = aTableItem->type(); + isComboItem = ( aTableType == ComboItem::Type() ); + isIntSpinItem = ( aTableType == IntSpinItem::Type() ); + isDoubleSpinItem = ( aTableType == DoubleSpinItem::Type() ); } - - bool anIsDoubleCriterion = - aCriterionType == SMESH::FT_AspectRatio || - aCriterionType == SMESH::FT_AspectRatio3D || - aCriterionType == SMESH::FT_Taper || - aCriterionType == SMESH::FT_Warping || - aCriterionType == SMESH::FT_MinimumAngle || - aCriterionType == SMESH::FT_Skew || - aCriterionType == SMESH::FT_Area || - aCriterionType == SMESH::FT_Length || - aCriterionType == SMESH::FT_Length2D || - aCriterionType == SMESH::FT_MaxElementLength2D || - aCriterionType == SMESH::FT_MaxElementLength3D || - aCriterionType == SMESH::FT_Volume3D || - aCriterionType == SMESH::FT_EntityType; + + // find out a type of item required by a new criterion and other table features + int aCriterionType = GetCriterionType(row); + bool anIsDoubleCriterion = false; + bool anIsIntCriterion = false; + bool anIsComboCriterion = false; + // other features: + QList comboIDs; // values to show in a combo item + int nbCompareSigns = 0; // possible values are 0,1,3 + bool isThresholdEditable = false; // actual for "simple" item types + switch ( aCriterionType ) + { + case SMESH::FT_AspectRatio: + case SMESH::FT_AspectRatio3D: + case SMESH::FT_Warping: + case SMESH::FT_MinimumAngle: + case SMESH::FT_Taper: + case SMESH::FT_Skew: + case SMESH::FT_Area: + case SMESH::FT_Volume3D: + case SMESH::FT_MaxElementLength2D: + case SMESH::FT_MaxElementLength3D: + anIsDoubleCriterion = true; nbCompareSigns = 3; break; + + case SMESH::FT_FreeBorders: + case SMESH::FT_FreeEdges: + case SMESH::FT_FreeNodes: + case SMESH::FT_FreeFaces: + case SMESH::FT_EqualNodes: + case SMESH::FT_EqualEdges: + case SMESH::FT_EqualFaces: + case SMESH::FT_EqualVolumes: break; + + case SMESH::FT_MultiConnection: + case SMESH::FT_MultiConnection2D: anIsIntCriterion = true; break; + + case SMESH::FT_Length: + case SMESH::FT_Length2D: anIsDoubleCriterion = true; break; + + case SMESH::FT_BelongToGeom: + case SMESH::FT_BelongToPlane: + case SMESH::FT_BelongToCylinder: + case SMESH::FT_BelongToGenSurface: + case SMESH::FT_LyingOnGeom: nbCompareSigns = 1; isThresholdEditable = true; break; + + case SMESH::FT_RangeOfIds: nbCompareSigns = 1; isThresholdEditable = true; break; + + case SMESH::FT_BadOrientedVolume: + case SMESH::FT_BareBorderVolume: + case SMESH::FT_BareBorderFace: + case SMESH::FT_OverConstrainedVolume: + case SMESH::FT_OverConstrainedFace: + case SMESH::FT_LinearOrQuadratic: break; + + case SMESH::FT_GroupColor: nbCompareSigns = 1; isThresholdEditable = true; break; + + case SMESH::FT_ElemGeomType: + comboIDs = geomTypes( aType ); anIsComboCriterion = true; nbCompareSigns = 1; break; + + case SMESH::FT_EntityType: + comboIDs = entityTypes( aType ); anIsComboCriterion = true; nbCompareSigns = 1; break; + + case SMESH::FT_CoplanarFaces: isThresholdEditable = true; break; + + case SMESH::FT_BallDiameter: anIsDoubleCriterion = true; break; + + case SMESH::FT_ConnectedElements: isThresholdEditable = true; break; + + case SMESH::FT_LessThan: + case SMESH::FT_MoreThan: + case SMESH::FT_EqualTo: + case SMESH::FT_LogicalNOT: + case SMESH::FT_LogicalAND: + case SMESH::FT_LogicalOR: + case SMESH::FT_Undefined: + default: return; + } + + // get a precision of a double criterion int aPrecision = 0; if ( anIsDoubleCriterion ) { - const char* aPrecisionType = getPrecision( aCriterionType ); + const char* aPrecisionType = getPrecision( aCriterionType ); SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr( mySMESHGUI ); if( aPrecisionType && aResourceMgr ) aPrecision = aResourceMgr->integerValue( "SMESH", aPrecisionType, aPrecision ); } - // if the precision is to be changed we should remove the existing - // spin item and create another one with new precision - bool anIsPrecisionChanged = false; - if ( anIsDoubleCriterion && isDoubleSpinItem ) { - if ( DoubleSpinItem* aDoubleSpinItem = dynamic_cast( aTable->item( row, 2 ) ) ) { - anIsPrecisionChanged = aDoubleSpinItem->precision() != aPrecision; + // check if the current item type satisfies the criterion + bool itemTypeKO = + ( aCriterionType == SMESH::FT_GroupColor && !clrBtn) || + ( anIsComboCriterion && !isComboItem ) || + ( anIsIntCriterion && !isIntSpinItem ) || + ( anIsDoubleCriterion && !isDoubleSpinItem ); + + if ( !itemTypeKO ) + { + if ( anIsDoubleCriterion ) + { + // if the precision is to be changed we should remove the existing + // spin item and create another one with new precision + if ( DoubleSpinItem* aDoubleSpinItem = dynamic_cast( aTable->item( row, 2 ))) + itemTypeKO = ( aDoubleSpinItem->precision() != aPrecision ); + else + itemTypeKO = true; + } + else if ( anIsComboCriterion ) + { + if ( ComboItem* aComboItem = dynamic_cast( aTable->item( row, 2 ))) + itemTypeKO = ( aComboItem->count() != comboIDs.count() ); + else + itemTypeKO = true; + } + else if ( !anIsIntCriterion && aCriterionType != SMESH::FT_GroupColor ) + { + itemTypeKO = ( clrBtn || isComboItem || isIntSpinItem || isDoubleSpinItem ); } } - if ( (aCriterionType != SMESH::FT_GroupColor && clrBtn) || - (aCriterionType != SMESH::FT_ElemGeomType && isComboItem) || - (aCriterionType != SMESH::FT_EntityType && isComboItem) || - (aCriterionType != SMESH::FT_MultiConnection && isIntSpinItem) || - (!anIsDoubleCriterion && isDoubleSpinItem) || - anIsPrecisionChanged ) + // update the table row + + bool isSignalsBlocked = aTable->signalsBlocked(); + aTable->blockSignals( true ); + + // update threshold table item + if ( itemTypeKO ) { - bool isSignalsBlocked = aTable->signalsBlocked(); - aTable->blockSignals( true ); aTable->removeCellWidget( row, 2 ); - aTable->setItem( row, 2, new QTableWidgetItem() ); - aTable->blockSignals( isSignalsBlocked ); - } - if ( (aCriterionType == SMESH::FT_GroupColor && !clrBtn) || - (aCriterionType == SMESH::FT_ElemGeomType && !isComboItem) || - (aCriterionType == SMESH::FT_EntityType && !isComboItem) || - (aCriterionType == SMESH::FT_MultiConnection && !isIntSpinItem) || - (anIsDoubleCriterion && !isDoubleSpinItem) || - anIsPrecisionChanged ) - { - bool isSignalsBlocked = aTable->signalsBlocked(); - aTable->blockSignals( true ); - if ( aCriterionType == SMESH::FT_GroupColor ) + + if ( aCriterionType == SMESH::FT_GroupColor ) // ---------------------- QtxColorButton + { aTable->setCellWidget( row, 2, new QtxColorButton( aTable ) ); - else if ( aCriterionType == SMESH::FT_ElemGeomType ) { - QList typeIds = geomTypes( aType ); - QMap typeNames; - QList::const_iterator anIter = typeIds.begin(); - for ( int i = 0; anIter != typeIds.end(); ++anIter, ++i) - { - QString typeKey = QString( "GEOM_TYPE_%1" ).arg( *anIter ); - typeNames[ *anIter ] = tr( typeKey.toLatin1().data() ); - } - ComboItem* typeBox = new ComboItem( typeNames ); - aTable->setItem( row, 2, typeBox ); } - else if ( aCriterionType == SMESH::FT_EntityType ) { - QList typeIds = entityTypes( aType ); - QMap typeNames; - QList::const_iterator anIter = typeIds.begin(); - for ( int i = 0; anIter != typeIds.end(); ++anIter, ++i) + else if ( anIsComboCriterion ) // -------------------------------------------ComboItem + { + QString msgPrefix + ( aCriterionType == SMESH::FT_ElemGeomType ? "GEOM_TYPE_%1" : "ENTITY_TYPE_%1" ); + QMap names; + QList::const_iterator id = comboIDs.begin(); + for ( ; id != comboIDs.end(); ++id ) { - QString typeKey = QString( "ENTITY_TYPE_%1" ).arg( *anIter ); - typeNames[ *anIter ] = tr( typeKey.toLatin1().data() ); + QString name = msgPrefix.arg( *id ); + names[ *id ] = tr( name.toLatin1().data() ); } - ComboItem* typeBox = new ComboItem( typeNames ); - aTable->setItem( row, 2, typeBox ); + ComboItem* comboBox = new ComboItem( names ); + aTable->setItem( row, 2, comboBox ); } - else if ( aCriterionType == SMESH::FT_MultiConnection ) { + else if ( anIsIntCriterion ) // ------------------------------------------ IntSpinItem + { IntSpinItem* intSpin = new IntSpinItem( 0 ); aTable->setItem( row, 2, intSpin ); } - else if ( anIsDoubleCriterion ) { + else if ( anIsDoubleCriterion ) // -------------------------------------DoubleSpinItem + { DoubleSpinItem* dblSpin = new DoubleSpinItem( 0 ); dblSpin->setPrecision( aPrecision ); aTable->setItem( row, 2, dblSpin ); } - aTable->blockSignals( isSignalsBlocked ); - } - - // set Compare and enable/desable Threshold - if ((aType == SMESH::NODE && (aCriterionType == SMESH::FT_FreeNodes || - aCriterionType == SMESH::FT_EqualNodes )) || - (aType == SMESH::EDGE && (aCriterionType == SMESH::FT_FreeBorders || - aCriterionType == SMESH::FT_EqualEdges )) || - (aType == SMESH::FACE && (aCriterionType == SMESH::FT_BareBorderFace || - aCriterionType == SMESH::FT_OverConstrainedFace || - aCriterionType == SMESH::FT_FreeEdges || - aCriterionType == SMESH::FT_FreeFaces || - aCriterionType == SMESH::FT_EqualFaces)) || - (aType == SMESH::VOLUME && (aCriterionType == SMESH::FT_BadOrientedVolume || - aCriterionType == SMESH::FT_OverConstrainedVolume || - aCriterionType == SMESH::FT_BareBorderVolume || - aCriterionType == SMESH::FT_EqualVolumes )) || - aCriterionType == SMESH::FT_LinearOrQuadratic || - aCriterionType == SMESH::FT_CoplanarFaces || - aCriterionType == SMESH::FT_ConnectedElements - ) - { - // - No compare - bool isSignalsBlocked = aTable->signalsBlocked(); - aTable->blockSignals( true ); - - if (aCompareItem->count() > 0) - aCompareItem->clear(); - aTable->setEditable(false, row, 1); - // - Threshold is NOT editable for most of criteria - aTable->item(row, 2)->setText( QString("") ); - aTable->setEditable(( aCriterionType == SMESH::FT_ConnectedElements || - aCriterionType == SMESH::FT_CoplanarFaces ), row, 2); - aTable->blockSignals( isSignalsBlocked ); - } - else if (aCriterionType == SMESH::FT_RangeOfIds || - aCriterionType == SMESH::FT_GroupColor || - aCriterionType == SMESH::FT_ElemGeomType || - aCriterionType == SMESH::FT_EntityType || - aCriterionType == SMESH::FT_BelongToGeom || - aCriterionType == SMESH::FT_BelongToPlane || - aCriterionType == SMESH::FT_BelongToCylinder || - aCriterionType == SMESH::FT_BelongToGenSurface || - aCriterionType == SMESH::FT_LyingOnGeom) - { - // - EQUAL_TO compare ONLY - QMap aMap; - aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO"); - aCompareItem->setItems(aMap); - // if (!aTable->isEditable(row, 2)) - aTable->setEditable(false, row, 1); - // - Threshold is editable - if (!aTable->isEditable(row, 2)) - aTable->setEditable(true, row, 2); - } - else - { - // All compare signs - if (aCompareItem && aCompareItem->count() != 3) + else // --------------------------------------------------------------QTableWidgetItem { - aCompareItem->setItems(getCompare()); - } - // Threshold is editable - if (aTable->item( row, 2 )) { - QString aText = aTable->text(row, 2); - bool isOk = false; - aText.toDouble(&isOk); - aTable->item( row, 2 )->setText(isOk ? aText : QString("")); - if (!aTable->isEditable(row, 1)) - aTable->setEditable(true, row, 1); - if (!aTable->isEditable(row, 2)) - aTable->setEditable(true, row, 2); + aTable->setItem( row, 2, new QTableWidgetItem() ); } } + // set Compare + if ( aCompareItem->count() != nbCompareSigns ) + { + switch ( nbCompareSigns ) { + case 0: { + aCompareItem->clear(); + break; + } + case 1: { + QMap aMap; + aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO"); + aCompareItem->setItems(aMap); + break; + } + case 3: { + aCompareItem->setItems(getCompare()); + break; + } + } + } + aTable->setEditable( nbCompareSigns == 3, row, 1); + + // enable/desable Threshold + if ( aCriterionType == SMESH::FT_GroupColor || + anIsComboCriterion || + anIsIntCriterion || + anIsDoubleCriterion ) + { + isThresholdEditable = true; + } + aTable->setEditable( isThresholdEditable, row, 2); + + + aTable->blockSignals( isSignalsBlocked ); + updateAdditionalWidget(); emit CriterionChanged(row, entityType); diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.cxx b/src/SMESHGUI/SMESHGUI_Hypotheses.cxx index da396be6f..a6e19527b 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.cxx +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.cxx @@ -185,6 +185,7 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame() { QLabel* lab = new QLabel( (*anIt).myName, GroupC1 ); GroupC1Layout->addWidget( lab, i, 0 ); + myParamLabels << lab; QWidget* w = getCustomWidget( *anIt, GroupC1, i ); if ( !w ) @@ -466,6 +467,22 @@ SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCrea return myParamWidgets; } +//================================================================================ +/*! + * \brief Returns a QLabel of a spesified parameter. + * If isCreation(), the 1st label (supposed to be "Name") is not countered. + */ +//================================================================================ + +QLabel* SMESHGUI_GenericHypothesisCreator::getLabel(int i) const +{ + if ( isCreation() ) + i++; + if ( i < myParamLabels.size() ) + return (QLabel*) myParamLabels.at(i); + return NULL; +} + QtxDialog* SMESHGUI_GenericHypothesisCreator:: dlg() const { return myDlg; diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.h b/src/SMESHGUI/SMESHGUI_Hypotheses.h index 475763191..83da609d3 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.h +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.h @@ -99,6 +99,7 @@ protected: bool hasInitParamsHypothesis() const; const ListOfWidgets& widgets() const; ListOfWidgets& changeWidgets(); + QLabel* getLabel(int i) const; QtxDialog* dlg() const; QString getVariableName(const char* methodName) const; @@ -134,6 +135,7 @@ private: QString myHypName; QString myHypType; ListOfWidgets myParamWidgets; + ListOfWidgets myParamLabels; bool myIsCreate; QtxDialog* myDlg; QString myShapeEntry; diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx index aad40cdb2..786c72f9d 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx @@ -24,18 +24,19 @@ #include "SMESHGUI_MeshInfo.h" -#include "SMESH_Actor.h" -#include "SMESHGUI.h" -#include "SMESHGUI_IdValidator.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_VTKUtils.h" #include "SMDSAbs_ElementType.hxx" -#include "SMDS_Mesh.hxx" #include "SMDS_BallElement.hxx" #include "SMDS_EdgePosition.hxx" #include "SMDS_FacePosition.hxx" +#include "SMDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx" -#include "SMESH_ControlsDef.hxx" +#include "SMESHGUI.h" +#include "SMESHGUI_FilterUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESH_Actor.h" #include #include @@ -60,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +73,8 @@ #include #include CORBA_SERVER_HEADER(GEOM_Gen) +namespace { + const int SPACING = 6; const int MARGIN = 9; const int MAXITEMS = 10; @@ -87,12 +91,12 @@ enum InfoType { NodeConnectivity = 100, ElemConnectivity, }; +} // namesapce /*! \class ExtraWidget \internal */ - class ExtraWidget : public QWidget { public: @@ -150,6 +154,7 @@ public: QCheckBox* myBaseChk; QCheckBox* myElemChk; QCheckBox* myAddChk; + QCheckBox* myCtrlChk; }; /*! @@ -164,11 +169,13 @@ DumpFileDlg::DumpFileDlg( QWidget* parent ) : SUIT_FileDlg( parent, false, true, myBaseChk = new QCheckBox( SMESHGUI::tr( "PREF_DUMP_BASE_INFO" ), hB ); myElemChk = new QCheckBox( SMESHGUI::tr( "PREF_DUMP_ELEM_INFO" ), hB ); myAddChk = new QCheckBox( SMESHGUI::tr( "PREF_DUMP_ADD_INFO" ), hB ); + myCtrlChk = new QCheckBox( SMESHGUI::tr( "PREF_DUMP_CTRL_INFO" ), hB ); - QHBoxLayout* layout = new QHBoxLayout( hB ); - layout->addWidget( myBaseChk ); - layout->addWidget( myElemChk ); - layout->addWidget( myAddChk ); + QGridLayout* layout = new QGridLayout( hB ); + layout->addWidget( myBaseChk, 0, 0 ); + layout->addWidget( myElemChk, 0, 1 ); + layout->addWidget( myAddChk, 1, 0 ); + layout->addWidget( myCtrlChk, 1, 1 ); QPushButton* pb = new QPushButton( this ); @@ -418,13 +425,13 @@ SMESHGUI_MeshInfo::SMESHGUI_MeshInfo( QWidget* parent ) l->addWidget( a3DHexPriTotal, 25, 1 ); l->addWidget( a3DPolLab, 26, 0 ); l->addWidget( a3DPolTotal, 26, 1 ); - l->addWidget( myLoadBtn, 27, 1, 1, 3 ); + l->addWidget( myLoadBtn, 28, 1, 1, 3 ); l->setColumnStretch( 0, 0 ); l->setColumnStretch( 1, 5 ); l->setColumnStretch( 2, 5 ); l->setColumnStretch( 3, 5 ); - l->setRowStretch( 23, 5 ); + l->setRowStretch( 27, 5 ); clear(); } @@ -459,27 +466,13 @@ void SMESHGUI_MeshInfo::showInfo( SMESH::SMESH_IDSource_ptr obj ) else if ( !aGroup->_is_nil() ) { QString objType; switch( aGroup->GetType() ) { - case SMESH::NODE: - objType = tr( "OBJECT_GROUP_NODES" ); - break; - case SMESH::EDGE: - objType = tr( "OBJECT_GROUP_EDGES" ); - break; - case SMESH::FACE: - objType = tr( "OBJECT_GROUP_FACES" ); - break; - case SMESH::VOLUME: - objType = tr( "OBJECT_GROUP_VOLUMES" ); - break; - case SMESH::ELEM0D: - objType = tr( "OBJECT_GROUP_0DELEMS" ); - break; - case SMESH::BALL: - objType = tr( "OBJECT_GROUP_BALLS" ); - break; - default: - objType = tr( "OBJECT_GROUP" ); - break; + case SMESH::NODE: objType = tr( "OBJECT_GROUP_NODES" );break; + case SMESH::EDGE: objType = tr( "OBJECT_GROUP_EDGES" );break; + case SMESH::FACE: objType = tr( "OBJECT_GROUP_FACES" );break; + case SMESH::VOLUME:objType = tr( "OBJECT_GROUP_VOLUMES" );break; + case SMESH::ELEM0D:objType = tr( "OBJECT_GROUP_0DELEMS" );break; + case SMESH::BALL: objType = tr( "OBJECT_GROUP_BALLS" );break; + default: objType = tr( "OBJECT_GROUP" );break; } myWidgets[iObject][iSingle]->setProperty( "text", objType ); } @@ -495,7 +488,7 @@ void SMESHGUI_MeshInfo::showInfo( SMESH::SMESH_IDSource_ptr obj ) long nbQuadrangles = info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle]; long nb2DLinear = info[SMDSEntity_Triangle] + info[SMDSEntity_Quadrangle] + info[SMDSEntity_Polygon]; long nb2DQuadratic = info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle]; - myWidgets[i2D][iTotal] ->setProperty( "text", QString::number( nb2DLinear + nb2DQuadratic ) ); + myWidgets[i2D][iTotal] ->setProperty( "text", QString::number( nb2DLinear + nb2DQuadratic )); myWidgets[i2D][iLinear] ->setProperty( "text", QString::number( nb2DLinear ) ); myWidgets[i2D][iQuadratic] ->setProperty( "text", QString::number( nb2DQuadratic ) ); myWidgets[i2DTriangles][iTotal] ->setProperty( "text", QString::number( nbTriangles ) ); @@ -2242,7 +2235,7 @@ void SMESHGUI_AddInfo::meshInfo( SMESH::SMESH_Mesh_ptr mesh, QTreeWidgetItem* pa { // type GEOM::GEOM_Object_var shape = mesh->GetShapeToMesh(); - SALOME_MED::MedFileInfo* inf = mesh->GetMEDFileInfo(); + SMESH::MedFileInfo* inf = mesh->GetMEDFileInfo(); QTreeWidgetItem* typeItem = createItem( parent, Bold ); typeItem->setText( 0, tr( "TYPE" ) ); if ( !CORBA::is_nil( shape ) ) { @@ -2653,6 +2646,11 @@ SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page ) myAddInfo = new SMESHGUI_AddInfo( myTabWidget ); myTabWidget->addTab( myAddInfo, tr( "ADDITIONAL_INFO" ) ); + // controls info + + myCtrlInfo = new SMESHGUI_CtrlInfo( myTabWidget ); + myTabWidget->addTab( myCtrlInfo, tr( "CTRL_INFO" ) ); + // buttons QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this ); @@ -2712,6 +2710,7 @@ void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO if ( !CORBA::is_nil( obj ) ) { myBaseInfo->showInfo( obj ); myAddInfo->showInfo( obj ); + myCtrlInfo->showInfo( obj ); myActor = SMESH::FindActorByEntry( IO->getEntry() ); SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector(); @@ -2782,7 +2781,7 @@ void SMESHGUI_MeshInfoDlg::updateSelection() disconnect( selMgr, 0, this, 0 ); selMgr->clearFilters(); - if ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo ) { + if ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo || myTabWidget->currentIndex() == CtrlInfo ) { SMESH::SetPointRepresentation( false ); if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() ) aViewWindow->SetSelectionMode( ActorSelection ); @@ -2933,11 +2932,13 @@ void SMESHGUI_MeshInfoDlg::dump() bool anIsBase = true; bool anIsElem = true; bool anIsAdd = true; + bool anIsCtrl = true; if ( SUIT_ResourceMgr* aResourceMgr = SMESHGUI::resourceMgr() ) { anIsBase = aResourceMgr->booleanValue( "SMESH", "info_dump_base", anIsBase ); anIsElem = aResourceMgr->booleanValue( "SMESH", "info_dump_elem", anIsElem ); anIsAdd = aResourceMgr->booleanValue( "SMESH", "info_dump_add", anIsAdd ); + anIsCtrl = aResourceMgr->booleanValue( "SMESH", "info_dump_ctrl", anIsCtrl ); } DumpFileDlg fd( this ); @@ -2946,6 +2947,7 @@ void SMESHGUI_MeshInfoDlg::dump() fd.myBaseChk->setChecked( anIsBase ); fd.myElemChk->setChecked( anIsElem ); fd.myAddChk ->setChecked( anIsAdd ); + fd.myCtrlChk->setChecked( anIsCtrl ); if ( fd.exec() == QDialog::Accepted ) { QString aFileName = fd.selectedFile(); @@ -2953,6 +2955,7 @@ void SMESHGUI_MeshInfoDlg::dump() bool toBase = fd.myBaseChk->isChecked(); bool toElem = fd.myElemChk->isChecked(); bool toAdd = fd.myAddChk->isChecked(); + bool toCtrl = fd.myCtrlChk->isChecked(); if ( !aFileName.isEmpty() ) { QFileInfo aFileInfo( aFileName ); @@ -2968,6 +2971,639 @@ void SMESHGUI_MeshInfoDlg::dump() if ( toBase ) myBaseInfo->saveInfo( out ); if ( toElem ) myElemInfo->saveInfo( out ); if ( toAdd ) myAddInfo ->saveInfo( out ); + if ( toCtrl ) myCtrlInfo->saveInfo( out ); } } } + +/*! + \class SMESHGUI_CtrlInfo + \brief Class for the mesh controls information widget. +*/ + +/*! + \brief Constructor + \param parent parent widget +*/ +SMESHGUI_CtrlInfo::SMESHGUI_CtrlInfo( QWidget* parent ) + : QFrame( parent ), myPlot( 0 ), myPlot3D( 0 ) +{ + setFrameStyle( StyledPanel | Sunken ); + + myMainLayout = new QGridLayout( this ); + myMainLayout->setMargin( MARGIN ); + myMainLayout->setSpacing( SPACING ); + + // name + QLabel* aNameLab = new QLabel( tr( "NAME_LAB" ), this ); + QLabel* aName = createField(); + aName->setMinimumWidth( 150 ); + myWidgets << aName; + + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QIcon aComputeIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_COMPUTE" ) ) ); + + SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); + + // nodes info + QLabel* aNodesLab = new QLabel( tr( "NODES_INFO" ), this ); + QLabel* aNodesFreeLab = new QLabel( tr( "NUMBER_OF_THE_FREE_NODES" ), this ); + QLabel* aNodesFree = createField(); + myWidgets << aNodesFree; + myPredicates << aFilterMgr->CreateFreeNodes(); + // + QLabel* aNodesDoubleLab = new QLabel( tr( "NUMBER_OF_THE_DOUBLE_NODES" ), this ); + QLabel* aNodesDouble = createField(); + myWidgets << aNodesDouble; + myPredicates << aFilterMgr->CreateEqualNodes(); + QLabel* aToleranceLab = new QLabel( tr( "DOUBLE_NODES_TOLERANCE" ), this ); + myToleranceWidget = new SMESHGUI_SpinBox( this ); + myToleranceWidget->RangeStepAndValidator(0.0000000001, 1000000.0, 0.0000001, "length_precision" ); + myToleranceWidget->setAcceptNames( false ); + myToleranceWidget->SetValue( SMESHGUI::resourceMgr()->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 ) ); + + // edges info + QLabel* anEdgesLab = new QLabel( tr( "EDGES_INFO" ), this ); + QLabel* anEdgesDoubleLab = new QLabel( tr( "NUMBER_OF_THE_DOUBLE_EDGES" ), this ); + QLabel* anEdgesDouble = createField(); + myWidgets << anEdgesDouble; + myPredicates << aFilterMgr->CreateEqualEdges(); + + // faces info + QLabel* aFacesLab = new QLabel( tr( "FACES_INFO" ), this ); + QLabel* aFacesDoubleLab = new QLabel( tr( "NUMBER_OF_THE_DOUBLE_FACES" ), this ); + QLabel* aFacesDouble = createField(); + myWidgets << aFacesDouble; + myPredicates << aFilterMgr->CreateEqualFaces(); + QLabel* aFacesOverLab = new QLabel( tr( "NUMBER_OF_THE_OVER_CONSTRAINED" ), this ); + QLabel* aFacesOver = createField(); + myWidgets << aFacesOver; + myPredicates << aFilterMgr->CreateOverConstrainedFace(); + QLabel* anAspectRatioLab = new QLabel( tr( "ASPECT_RATIO_HISTOGRAM" ), this ); + myPlot = createPlot( this ); + myAspectRatio = aFilterMgr->CreateAspectRatio(); + + // volumes info + QLabel* aVolumesLab = new QLabel( tr( "VOLUMES_INFO" ), this ); + QLabel* aVolumesDoubleLab = new QLabel( tr( "NUMBER_OF_THE_DOUBLE_VOLUMES" ), this ); + QLabel* aVolumesDouble = createField(); + myWidgets << aVolumesDouble; + myPredicates << aFilterMgr->CreateEqualVolumes(); + QLabel* aVolumesOverLab = new QLabel( tr( "NUMBER_OF_THE_OVER_CONSTRAINED" ), this ); + QLabel* aVolumesOver = createField(); + myWidgets << aVolumesOver; + myPredicates << aFilterMgr->CreateOverConstrainedVolume(); + QLabel* anAspectRatio3DLab = new QLabel( tr( "ASPECT_RATIO_3D_HISTOGRAM" ), this ); + myPlot3D = createPlot( this ); + myAspectRatio3D = aFilterMgr->CreateAspectRatio3D(); + + QToolButton* aFreeNodesBtn = new QToolButton( this ); + aFreeNodesBtn->setIcon(aComputeIcon); + myButtons << aFreeNodesBtn; //0 + + QToolButton* aDoubleNodesBtn = new QToolButton( this ); + aDoubleNodesBtn->setIcon(aComputeIcon); + myButtons << aDoubleNodesBtn; //1 + + QToolButton* aDoubleEdgesBtn = new QToolButton( this ); + aDoubleEdgesBtn->setIcon(aComputeIcon); + myButtons << aDoubleEdgesBtn; //2 + + QToolButton* aDoubleFacesBtn = new QToolButton( this ); + aDoubleFacesBtn->setIcon(aComputeIcon); + myButtons << aDoubleFacesBtn; //3 + + QToolButton* aOverContFacesBtn = new QToolButton( this ); + aOverContFacesBtn->setIcon(aComputeIcon); + myButtons << aOverContFacesBtn; //4 + + QToolButton* aComputeFaceBtn = new QToolButton( this ); + aComputeFaceBtn->setIcon(aComputeIcon); + myButtons << aComputeFaceBtn; //5 + + QToolButton* aDoubleVolumesBtn = new QToolButton( this ); + aDoubleVolumesBtn->setIcon(aComputeIcon); + myButtons << aDoubleVolumesBtn; //6 + + QToolButton* aOverContVolumesBtn = new QToolButton( this ); + aOverContVolumesBtn->setIcon(aComputeIcon); + myButtons << aOverContVolumesBtn; //7 + + QToolButton* aComputeVolumeBtn = new QToolButton( this ); + aComputeVolumeBtn->setIcon(aComputeIcon); + myButtons << aComputeVolumeBtn; //8 + + connect( aComputeFaceBtn, SIGNAL( clicked() ), this, SLOT( computeAspectRatio() ) ); + connect( aComputeVolumeBtn, SIGNAL( clicked() ), this, SLOT( computeAspectRatio3D() ) ); + connect( aFreeNodesBtn, SIGNAL( clicked() ), this, SLOT( computeFreeNodesInfo() ) ); + connect( aDoubleNodesBtn, SIGNAL( clicked() ), this, SLOT( computeDoubleNodesInfo() ) ); + connect( aDoubleEdgesBtn, SIGNAL( clicked() ), this, SLOT( computeDoubleEdgesInfo() ) ); + connect( aDoubleFacesBtn, SIGNAL( clicked() ), this, SLOT( computeDoubleFacesInfo() ) ); + connect( aOverContFacesBtn, SIGNAL( clicked() ), this, SLOT( computeOverConstrainedFacesInfo() ) ); + connect( aDoubleVolumesBtn, SIGNAL( clicked() ), this, SLOT( computeDoubleVolumesInfo() ) ); + connect( aOverContVolumesBtn, SIGNAL( clicked() ), this, SLOT( computeOverConstrainedVolumesInfo() ) ); + connect( myToleranceWidget, SIGNAL(valueChanged(double)), this, SLOT( setTolerance( double ))); + + setFontAttributes( aNameLab ); + setFontAttributes( aNodesLab ); + setFontAttributes( anEdgesLab ); + setFontAttributes( aFacesLab ); + setFontAttributes( aVolumesLab ); + + myMainLayout->addWidget( aNameLab, 0, 0 ); //0 + myMainLayout->addWidget( aName, 0, 1, 1, 2 ); //1 + myMainLayout->addWidget( aNodesLab, 1, 0, 1, 3 ); //2 + myMainLayout->addWidget( aNodesFreeLab, 2, 0 ); //3 + myMainLayout->addWidget( aNodesFree, 2, 1 ); //4 + myMainLayout->addWidget( aFreeNodesBtn, 2, 2 ); //5 + myMainLayout->addWidget( aNodesDoubleLab, 3, 0 ); //6 + myMainLayout->addWidget( aNodesDouble, 3, 1 ); //7 + myMainLayout->addWidget( aDoubleNodesBtn, 3, 2 ); //8 + myMainLayout->addWidget( aToleranceLab, 4, 0 ); //9 + myMainLayout->addWidget( myToleranceWidget, 4, 1 ); //10 + myMainLayout->addWidget( anEdgesLab, 5, 0, 1, 3 ); //11 + myMainLayout->addWidget( anEdgesDoubleLab, 6, 0 ); //12 + myMainLayout->addWidget( anEdgesDouble, 6, 1 ); //13 + myMainLayout->addWidget( aDoubleEdgesBtn, 6, 2 ); //14 + myMainLayout->addWidget( aFacesLab, 7, 0, 1, 3 ); //15 + myMainLayout->addWidget( aFacesDoubleLab, 8, 0 ); //16 + myMainLayout->addWidget( aFacesDouble, 8, 1 ); //17 + myMainLayout->addWidget( aDoubleFacesBtn, 8, 2 ); //18 + myMainLayout->addWidget( aFacesOverLab, 9, 0 ); //19 + myMainLayout->addWidget( aFacesOver, 9, 1 ); //20 + myMainLayout->addWidget( aOverContFacesBtn, 9, 2 ); //21 + myMainLayout->addWidget( anAspectRatioLab, 10, 0 ); //22 + myMainLayout->addWidget( aComputeFaceBtn, 10, 2 ); //23 + myMainLayout->addWidget( myPlot, 11, 0, 1, 3 );//24 + myMainLayout->addWidget( aVolumesLab, 12, 0, 1, 3 );//25 + myMainLayout->addWidget( aVolumesDoubleLab, 13, 0 ); //26 + myMainLayout->addWidget( aVolumesDouble, 13, 1 ); //27 + myMainLayout->addWidget( aDoubleVolumesBtn, 13, 2 ); //28 + myMainLayout->addWidget( aVolumesOverLab, 14, 0 ); //28 + myMainLayout->addWidget( aVolumesOver, 14, 1 ); //30 + myMainLayout->addWidget( aOverContVolumesBtn,14, 2 ); //31 + myMainLayout->addWidget( anAspectRatio3DLab, 15, 0 ); //32 + myMainLayout->addWidget( aComputeVolumeBtn, 15, 2 ); //33 + myMainLayout->addWidget( myPlot3D, 16, 0, 1, 3 );//34 + + myMainLayout->setColumnStretch( 0, 0 ); + myMainLayout->setColumnStretch( 1, 5 ); + myMainLayout->setRowStretch ( 11, 5 ); + myMainLayout->setRowStretch ( 16, 5 ); + myMainLayout->setRowStretch ( 17, 1 ); + + clearInternal(); +} + +/*! + \brief Destructor +*/ +SMESHGUI_CtrlInfo::~SMESHGUI_CtrlInfo() +{} + +/*! + \brief Change widget font attributes (bold, ...). + \param w widget + \param attr font attributes (XORed flags) +*/ +void SMESHGUI_CtrlInfo::setFontAttributes( QWidget* w ) +{ + if ( w ) { + QFont f = w->font(); + f.setBold( true ); + w->setFont( f ); + } +} + +/*! + \brief Create info field + \return new info field +*/ +QLabel* SMESHGUI_CtrlInfo::createField() +{ + QLabel* lab = new QLabel( this ); + lab->setFrameStyle( StyledPanel | Sunken ); + lab->setAlignment( Qt::AlignCenter ); + lab->setAutoFillBackground( true ); + QPalette pal = lab->palette(); + pal.setColor( QPalette::Window, QApplication::palette().color( QPalette::Active, QPalette::Base ) ); + lab->setPalette( pal ); + lab->setMinimumWidth( 60 ); + return lab; +} + +/*! + \brief Create QwtPlot + \return new QwtPlot +*/ +QwtPlot* SMESHGUI_CtrlInfo::createPlot( QWidget* parent ) +{ + QwtPlot* aPlot = new QwtPlot( parent ); + aPlot->setMinimumSize( 100, 100 ); + QFont xFont = aPlot->axisFont( QwtPlot::xBottom ); + xFont.setPointSize( 5 ); + QFont yFont = aPlot->axisFont( QwtPlot::yLeft ); + yFont.setPointSize( 5 ); + aPlot->setAxisFont( QwtPlot::xBottom, xFont ); + aPlot->setAxisFont( QwtPlot::yLeft, yFont ); + aPlot->replot(); + return aPlot; +} + +/*! + \brief Show controls information on the selected object +*/ +void SMESHGUI_CtrlInfo::showInfo( SMESH::SMESH_IDSource_ptr obj ) +{ + clearInternal(); + + myObject = SMESH::SMESH_IDSource::_duplicate( obj ); + if ( myObject->_is_nil() ) return; + + if ( _PTR(SObject) aSO = SMESH::FindSObject( obj )) + myWidgets[0]->setText( aSO->GetName().c_str() ); + + SMESH::SMESH_Mesh_var mesh = obj->GetMesh(); + if ( mesh->_is_nil() ) return; + + const bool meshLoaded = mesh->IsLoaded(); + if ( !meshLoaded ) // mesh not yet loaded from the hdf file + // enable Compute buttons, just in case obj->GetNbElementsByType() fails + for ( int i = 0; i < myButtons.count(); ++i ) + myButtons[i]->setEnabled( true ); + + SMESH::long_array_var nbElemsByType = obj->GetNbElementsByType(); + if ( ! &nbElemsByType.in() ) return; + + const CORBA::Long ctrlLimit = + meshLoaded ? SMESHGUI::resourceMgr()->integerValue( "SMESH", "info_controls_limit", 3000 ) : -1; + + // nodes info + const CORBA::Long nbNodes = nbElemsByType[ SMESH::NODE ]; + const CORBA::Long nbElems = ( nbElemsByType[ SMESH::EDGE ] + + nbElemsByType[ SMESH::FACE ] + + nbElemsByType[ SMESH::VOLUME ] ); + if ( nbNodes + nbElems > 0 ) { + if ( Max( (int)nbNodes, (int)nbElems ) <= ctrlLimit ) { + // free nodes + computeFreeNodesInfo(); + // double nodes + computeDoubleNodesInfo(); + } + else { + myButtons[0]->setEnabled( true ); + myButtons[1]->setEnabled( true ); + } + } + else { + for( int i=2; i<=10; i++) + myMainLayout->itemAt(i)->widget()->setVisible( false ); + } + + // edges info + if ( nbElemsByType[ SMESH::EDGE ] > 0 ) { + // double edges + if( nbElemsByType[ SMESH::EDGE ] <= ctrlLimit ) + computeDoubleEdgesInfo(); + else + myButtons[2]->setEnabled( true ); + } + else { + for( int i=11; i<=14; i++) + myMainLayout->itemAt(i)->widget()->setVisible( false ); + } + + // faces info + if ( nbElemsByType[ SMESH::FACE ] > 0 ) { + if ( nbElemsByType[ SMESH::FACE ] <= ctrlLimit ) { + // double faces + computeDoubleFacesInfo(); + // over constrained faces + computeOverConstrainedFacesInfo(); + // aspect Ratio histogram + computeAspectRatio(); + } + else { + myButtons[3]->setEnabled( true ); + myButtons[4]->setEnabled( true ); + myButtons[5]->setEnabled( true ); + } + } + else { + myMainLayout->setRowStretch(11,0); + for( int i=15; i<=24; i++) + myMainLayout->itemAt(i)->widget()->setVisible( false ); + } + + // volumes info + if ( nbElemsByType[ SMESH::VOLUME ] > 0 ) { + if ( nbElemsByType[ SMESH::VOLUME ] <= ctrlLimit ) { + // double volumes + computeDoubleVolumesInfo(); + // over constrained volumes + computeOverConstrainedVolumesInfo(); + // aspect Ratio 3D histogram + computeAspectRatio3D(); + } + else { + myButtons[6]->setEnabled( true ); + myButtons[7]->setEnabled( true ); + myButtons[8]->setEnabled( true ); + } + } + else { + myMainLayout->setRowStretch(16,0); + for( int i=25; i<=34; i++) + myMainLayout->itemAt(i)->widget()->setVisible( false ); + } +} + +//================================================================================ +/*! + * \brief Computes and shows nb of elements satisfying a given predicate + * \param [in] ft - a predicate type (SMESH::FunctorType) + * \param [in] iBut - index of one of myButtons to disable + * \param [in] iWdg - index of one of myWidgets to show the computed number + */ +//================================================================================ + +void SMESHGUI_CtrlInfo::computeNb( int ft, int iBut, int iWdg ) +{ + myButtons[ iBut ]->setEnabled( false ); + myWidgets[ iWdg ]->setText( "" ); + if ( myObject->_is_nil() ) return; + + SUIT_OverrideCursor wc; + + SMESH::SMESH_Mesh_var mesh = myObject->GetMesh(); + if ( !mesh->_is_nil() && !mesh->IsLoaded() ) + { + mesh->Load(); + this->showInfo( myObject ); // try to show all values + if ( !myWidgets[ iWdg ]->text().isEmpty() ) + return; // predicate already computed + } + // look for a predicate of type + for ( int i = 0; i < myPredicates.count(); ++i ) + if ( myPredicates[i]->GetFunctorType() == ft ) + { + CORBA::Long nb = myPredicates[i]->NbSatisfying( myObject ); + myWidgets[ iWdg ]->setText( QString::number( nb )); + } +} + +void SMESHGUI_CtrlInfo::computeFreeNodesInfo() +{ + computeNb( SMESH::FT_FreeNodes, 0, 1 ); +} + +void SMESHGUI_CtrlInfo::computeDoubleNodesInfo() +{ + computeNb( SMESH::FT_EqualNodes, 1, 2 ); +} + +void SMESHGUI_CtrlInfo::computeDoubleEdgesInfo() +{ + computeNb( SMESH::FT_EqualEdges, 2, 3 ); +} + +void SMESHGUI_CtrlInfo::computeDoubleFacesInfo() +{ + computeNb( SMESH::FT_EqualFaces, 3, 4 ); +} + +void SMESHGUI_CtrlInfo::computeOverConstrainedFacesInfo() +{ + computeNb( SMESH::FT_OverConstrainedFace, 4, 5 ); +} + +void SMESHGUI_CtrlInfo::computeDoubleVolumesInfo() +{ + computeNb( SMESH::FT_EqualVolumes, 6, 6 ); +} + +void SMESHGUI_CtrlInfo::computeOverConstrainedVolumesInfo() +{ + computeNb( SMESH::FT_OverConstrainedVolume, 7, 7 ); +} + +void SMESHGUI_CtrlInfo::computeAspectRatio() +{ + myButtons[5]->setEnabled( false ); + + if ( myObject->_is_nil() ) return; + + SUIT_OverrideCursor wc; + + Plot2d_Histogram* aHistogram = getHistogram( myAspectRatio ); + if ( aHistogram && !aHistogram->isEmpty() ) { + QwtPlotItem* anItem = aHistogram->createPlotItem(); + anItem->attach( myPlot ); + myPlot->replot(); + } +} + +void SMESHGUI_CtrlInfo::computeAspectRatio3D() +{ + myButtons[8]->setEnabled( false ); + + if ( myObject->_is_nil() ) return; + + SUIT_OverrideCursor wc; + + Plot2d_Histogram* aHistogram = getHistogram( myAspectRatio3D ); + if ( aHistogram && !aHistogram->isEmpty() ) { + QwtPlotItem* anItem = aHistogram->createPlotItem(); + anItem->attach( myPlot3D ); + myPlot3D->replot(); + } +} + +/*! + \brief Internal clean-up (reset widget) +*/ +void SMESHGUI_CtrlInfo::clearInternal() +{ + for( int i=0; i<=34; i++) + myMainLayout->itemAt(i)->widget()->setVisible( true ); + for( int i=0; i<=8; i++) + myButtons[i]->setEnabled( false ); + myPlot->detachItems(); + myPlot3D->detachItems(); + myPlot->replot(); + myPlot3D->replot(); + myWidgets[0]->setText( QString() ); + for ( int i = 1; i < myWidgets.count(); i++ ) + myWidgets[i]->setText( "" ); + myMainLayout->setRowStretch(11,5); + myMainLayout->setRowStretch(16,5); +} + +void SMESHGUI_CtrlInfo::setTolerance( double theTolerance ) +{ + //SMESH::long_array_var anElems = getElementsByType( SMESH::NODE ); + myButtons[1]->setEnabled( true ); + myWidgets[2]->setText(""); +} + +Plot2d_Histogram* SMESHGUI_CtrlInfo::getHistogram( SMESH::NumericalFunctor_ptr aNumFun ) +{ + SMESH::SMESH_Mesh_var mesh = myObject->GetMesh(); + if ( mesh->_is_nil() ) return 0; + if ( !mesh->IsLoaded() ) + mesh->Load(); + aNumFun->SetMesh( mesh ); + + CORBA::Long cprecision = 6; + if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) ) + cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 ); + aNumFun->SetPrecision( cprecision ); + + int nbIntervals = SMESHGUI::resourceMgr()->integerValue( "SMESH", "scalar_bar_num_colors", false ); + + SMESH::Histogram_var histogramVar = aNumFun->GetLocalHistogram( nbIntervals, + /*isLogarithmic=*/false, + myObject ); + Plot2d_Histogram* aHistogram = new Plot2d_Histogram(); + aHistogram->setColor( palette().color( QPalette::Highlight ) ); + if ( &histogramVar.in() ) + { + for ( size_t i = 0, nb = histogramVar->length(); i < nb; i++ ) + aHistogram->addPoint( 0.5 * ( histogramVar[i].min + histogramVar[i].max ), histogramVar[i].nbEvents ); + if ( histogramVar->length() >= 2 ) + aHistogram->setWidth( ( histogramVar[0].max - histogramVar[0].min ) * 0.8 ); + } + return aHistogram; +} + +void SMESHGUI_CtrlInfo::saveInfo( QTextStream &out ) { + out << QString( 20, '-' ) << "\n"; + out << tr( "CTRL_INFO" ) << "\n"; + out << QString( 20, '-' ) << "\n"; + out << tr( "NAME_LAB" ) << " " << myWidgets[0]->text() << "\n"; + out << tr( "NODES_INFO" ) << "\n"; + out << QString( SPACING_INFO, ' ' ) << tr( "NUMBER_OF_THE_FREE_NODES" ) << ": " << myWidgets[1]->text() << "\n"; + out << QString( SPACING_INFO, ' ' ) << tr( "NUMBER_OF_THE_DOUBLE_NODES" ) << ": " << myWidgets[2]->text() << "\n"; + out << tr( "EDGES_INFO" ) << "\n"; + out << QString( SPACING_INFO, ' ' ) << tr( "NUMBER_OF_THE_DOUBLE_EDGES" ) << ": " << myWidgets[3]->text() << "\n"; + out << tr( "FACES_INFO" ) << "\n"; + out << QString( SPACING_INFO, ' ' ) << tr( "NUMBER_OF_THE_DOUBLE_FACES" ) << ": " << myWidgets[4]->text() << "\n"; + out << QString( SPACING_INFO, ' ' ) << tr( "NUMBER_OF_THE_OVER_CONSTRAINED" ) << ": " << myWidgets[5]->text() << "\n"; + out << tr( "VOLUMES_INFO" ) << "\n"; + out << QString( SPACING_INFO, ' ' ) << tr( "NUMBER_OF_THE_DOUBLE_VOLUMES" ) << ": " << myWidgets[6]->text() << "\n"; + out << QString( SPACING_INFO, ' ' ) << tr( "NUMBER_OF_THE_OVER_CONSTRAINED" ) << ": " << myWidgets[7]->text() << "\n"; +} + +/*! + \class SMESHGUI_CtrlInfoDlg + \brief Controls information dialog box +*/ + +/*! + \brief Constructor + \param parent parent widget + \param page specifies the dialog page to be shown at the start-up +*/ +SMESHGUI_CtrlInfoDlg::SMESHGUI_CtrlInfoDlg( QWidget* parent ) +: QDialog( parent ) +{ + setAttribute( Qt::WA_DeleteOnClose, true ); + setWindowTitle( tr( "CTRL_INFO" ) ); + setMinimumSize( 400, 600 ); + + myCtrlInfo = new SMESHGUI_CtrlInfo( this ); + + // buttons + QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this ); + okBtn->setAutoDefault( true ); + okBtn->setDefault( true ); + okBtn->setFocus(); + + QGridLayout* l = new QGridLayout ( this ); + l->setMargin( MARGIN ); + l->setSpacing( SPACING ); + l->addWidget( myCtrlInfo, 0, 0, 1, 3 ); + l->addWidget( okBtn, 1, 1 ); + l->setColumnStretch( 0, 5 ); + l->setColumnStretch( 2, 5 ); + + connect( okBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( deactivate() ) ); + connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) ); + + updateSelection(); +} + +/*! + \brief Destructor +*/ +SMESHGUI_CtrlInfoDlg::~SMESHGUI_CtrlInfoDlg() +{ +} + +/*! + \brief Show controls information + \param IO interactive object +*/ +void SMESHGUI_CtrlInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO ) +{ + if ( SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface( IO ) ) + myCtrlInfo->showInfo( obj ); +} + +/*! + \brief Perform clean-up actions on the dialog box closing. +*/ +void SMESHGUI_CtrlInfoDlg::reject() +{ + SMESH::SetPointRepresentation( false ); + QDialog::reject(); +} + +/*! + \brief Setup selection mode depending on the current dialog box state. +*/ +void SMESHGUI_CtrlInfoDlg::updateSelection() +{ + LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr(); + disconnect( selMgr, 0, this, 0 ); + SMESH::SetPointRepresentation( false ); + connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) ); + updateInfo(); +} + +/*! + \brief Show mesh information +*/ +void SMESHGUI_CtrlInfoDlg::updateInfo() +{ + SUIT_OverrideCursor wc; + + SALOME_ListIO selected; + SMESHGUI::selectionMgr()->selectedObjects( selected ); + + if ( selected.Extent() == 1 ) { + Handle(SALOME_InteractiveObject) IO = selected.First(); + showInfo( IO ); + } +} + +/*! + \brief Activate dialog box +*/ +void SMESHGUI_CtrlInfoDlg::activate() +{ + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + SMESHGUI::GetSMESHGUI()->SetActiveDialogBox( this ); + updateSelection(); +} + +/*! + \brief Deactivate dialog box +*/ +void SMESHGUI_CtrlInfoDlg::deactivate() +{ + disconnect( SMESHGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) ); +} + + diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.h b/src/SMESHGUI/SMESHGUI_MeshInfo.h index 111a73b5b..54c101324 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.h +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.h @@ -26,7 +26,9 @@ #define SMESHGUI_MESHINFO_H #include "SMESH_SMESHGUI.hxx" -#include +#include "SMESH_ControlsDef.hxx" + +#include #include #include @@ -39,7 +41,12 @@ #include #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Group) +#include CORBA_SERVER_HEADER(SMESH_Filter) +#include +#include + +class QAbstractButton; class QButtonGroup; class QContextMenuEvent; class QLabel; @@ -47,9 +54,11 @@ class QLineEdit; class QPushButton; class QTabWidget; class QTextBrowser; +class QGridLayout; class SMESH_Actor; class SMDS_MeshNode; class SMDS_MeshElement; +class SMESHGUI_SpinBox; class ExtraWidget; @@ -280,6 +289,54 @@ private: SMESH::submesh_array_var mySubMeshes; }; +class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame +{ + Q_OBJECT; + +public: + SMESHGUI_CtrlInfo( QWidget* = 0 ); + ~SMESHGUI_CtrlInfo(); + + void showInfo( SMESH::SMESH_IDSource_ptr ); + void saveInfo( QTextStream &out ); + +private: + enum ObjectType { Mesh, SubMesh, Group }; + QLabel* createField(); + QwtPlot* createPlot( QWidget* ); + void setFontAttributes( QWidget* ); + void clearInternal(); + Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr functor ); + void computeNb( int ft, int iBut, int iWdg ); + +private slots: + void computeAspectRatio(); + void computeAspectRatio3D(); + void computeFreeNodesInfo(); + void computeDoubleNodesInfo(); + void computeDoubleEdgesInfo(); + void computeDoubleFacesInfo(); + void computeOverConstrainedFacesInfo(); + void computeDoubleVolumesInfo(); + void computeOverConstrainedVolumesInfo(); + void setTolerance( const double theTolerance ); + + +private: + typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate; + typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor; + SMESH::SMESH_IDSource_var myObject; + ObjectType myObjectType; + SMESHGUI_SpinBox* myToleranceWidget; + QList myWidgets; + QGridLayout* myMainLayout; + QwtPlot* myPlot; + QwtPlot* myPlot3D; + QList myButtons; + QList myPredicates; + TNumFunctor myAspectRatio, myAspectRatio3D; +}; + class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog { Q_OBJECT; @@ -291,7 +348,8 @@ public: enum { BaseInfo, //!< base mesh information ElemInfo, //!< mesh element information - AddInfo //!< additional information + AddInfo, //!< additional information + CtrlInfo //!< controls information }; SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo ); @@ -323,7 +381,29 @@ private: QLineEdit* myID; SMESHGUI_ElemInfo* myElemInfo; SMESHGUI_AddInfo* myAddInfo; + SMESHGUI_CtrlInfo* myCtrlInfo; SMESH_Actor* myActor; }; +class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog +{ + Q_OBJECT; + +public: + SMESHGUI_CtrlInfoDlg( QWidget* = 0 ); + ~SMESHGUI_CtrlInfoDlg(); + + void showInfo( const Handle(SALOME_InteractiveObject)& ); + void reject(); + +private slots: + void updateInfo(); + void activate(); + void deactivate(); + void updateSelection(); + +private: + SMESHGUI_CtrlInfo* myCtrlInfo; +}; + #endif // SMESHGUI_MESHINFO_H diff --git a/src/SMESHGUI/SMESHGUI_MeshUtils.cxx b/src/SMESHGUI/SMESHGUI_MeshUtils.cxx index 110b80f0e..b6036d4de 100644 --- a/src/SMESHGUI/SMESHGUI_MeshUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshUtils.cxx @@ -95,6 +95,7 @@ namespace SMESH if ( !p ) p = aStudy->FindComponent( "SMESH" ); if ( p ) { _PTR(ChildIterator) iter = aStudy->NewChildIterator( p ); + iter->InitEx(/*allLevels=*/true); int idx = 0; while( true ) { bool found = false; diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 8c7ebc2c2..86a929214 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -127,6 +127,9 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const else if ( p=="groupType" ) val = QVariant( groupType( ind ) ); else if ( p=="quadratic2DMode") val = QVariant(quadratic2DMode(ind)); else if ( p=="isDistributionVisible") val = QVariant(isDistributionVisible(ind)); + else if ( p=="hasChildren") val = QVariant(hasChildren(ind)); + else if ( p=="nbChildren") val = QVariant(nbChildren(ind)); + else if ( p=="isContainer") val = QVariant(isContainer(ind)); if( val.isValid() ) return val; @@ -529,6 +532,50 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const return QVariant( false ); } +//======================================================================= +//function : hasChildren +//purpose : +//======================================================================= + +bool SMESHGUI_Selection::hasChildren( int ind ) const +{ + if ( ind >= 0 ) + { + _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() ); + return SMESH::GetActiveStudyDocument()->GetUseCaseBuilder()->HasChildren( sobj ); + } + return false; +} + +//======================================================================= +//function : hasChildren +//purpose : +//======================================================================= + +int SMESHGUI_Selection::nbChildren( int ind ) const +{ + int nb = 0; + if ( ind >= 0 ) + { + _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() ); + if ( sobj->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode( sobj ) ) { + _PTR(UseCaseIterator) it = sobj->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( sobj ); + for (it->Init(false); it->More(); it->Next()) nb++; + } + } + return nb; +} + +//======================================================================= +//function : isContainer +//purpose : +//======================================================================= + +bool SMESHGUI_Selection::isContainer( int ind ) const +{ + return ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Unknown"; +} + //======================================================================= //function : type //purpose : @@ -653,7 +700,7 @@ bool SMESHGUI_Selection::isImported( const int ind ) const SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( SO ) ); if( !aMesh->_is_nil() ) { - SALOME_MED::MedFileInfo_var inf = aMesh->GetMEDFileInfo(); + SMESH::MedFileInfo_var inf = aMesh->GetMEDFileInfo(); res = strlen( (char*)inf->fileName ) > 0; } } diff --git a/src/SMESHGUI/SMESHGUI_Selection.h b/src/SMESHGUI/SMESHGUI_Selection.h index 4358bab07..5f2a50bdb 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.h +++ b/src/SMESHGUI/SMESHGUI_Selection.h @@ -63,6 +63,9 @@ public: virtual QString quadratic2DMode(int ) const; virtual bool isDistributionVisible(int ) const; + virtual bool hasChildren( int ) const; + virtual int nbChildren( int ) const; + virtual bool isContainer( int ) const; // parameters got from actor return nothing if an actor is not visible virtual QList elemTypes( int ) const; diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx index 1abc292e4..29c51666c 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx @@ -103,9 +103,6 @@ private: #define SPACING 6 #define MARGIN 11 -//To disable automatic genericobj management, the following line should be commented. -//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx -#define WITHGENERICOBJ //================================================================================= // class : SMESHGUI_TranslationDlg() @@ -509,84 +506,80 @@ bool SMESHGUI_TranslationDlg::ClickOnApply() switch ( actionButton ) { case MOVE_ELEMS_BUTTON: if(CheckBoxMesh->isChecked()) - for ( int i = 0; i < myObjects.count(); i++ ) { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); - myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); - aMeshEditor->TranslateObject(myObjects[i], aVector, false); - } + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->TranslateObject(myObjects[i], aVector, false); + } else { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); - myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); aMeshEditor->Translate(anElementsId, aVector, false); - } + } break; case COPY_ELEMS_BUTTON: if ( makeGroups ) { SMESH::ListOfGroups_var groups; if(CheckBoxMesh->isChecked()) { - for ( int i = 0; i < myObjects.count(); i++ ) { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); - myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); - groups = aMeshEditor->TranslateObjectMakeGroups(myObjects[i],aVector); - } - } + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + groups = aMeshEditor->TranslateObjectMakeGroups(myObjects[i],aVector); + } + } else { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); - myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); groups = aMeshEditor->TranslateMakeGroups(anElementsId, aVector); - } + } } else { if(CheckBoxMesh->isChecked()) { - for ( int i = 0; i < myObjects.count(); i++ ) { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); - myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); - aMeshEditor->TranslateObject(myObjects[i], aVector, true); - } - } + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + aMeshEditor->TranslateObject(myObjects[i], aVector, true); + } + } else { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); - myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); aMeshEditor->Translate(anElementsId, aVector, true); - } + } } break; case MAKE_MESH_BUTTON: { SMESH::SMESH_Mesh_var mesh; if (CheckBoxMesh->isChecked()) { - for ( int i = 0; i < myObjects.count(); i++ ) { - QString aName = SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] ) ); - SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); - myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); - mesh = aMeshEditor->TranslateObjectMakeMesh(myObjects[i], aVector, makeGroups, - aName.toLatin1().data()); - if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) - anEntryList.append( aSObject->GetID().c_str() ); + for ( int i = 0; i < myObjects.count(); i++ ) { + QString aName = SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] ) ); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); + myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + mesh = aMeshEditor->TranslateObjectMakeMesh(myObjects[i], aVector, makeGroups, + aName.toLatin1().data()); + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) + anEntryList.append( aSObject->GetID().c_str() ); -#ifdef WITHGENERICOBJ - // obj has been published in study. Its refcount has been incremented. - // It is safe to decrement its refcount - // so that it will be destroyed when the entry in study will be removed - mesh->UnRegister(); -#endif - } - } - else { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); - myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); - mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups, + // obj has been published in study. Its refcount has been incremented. + // It is safe to decrement its refcount + // so that it will be destroyed when the entry in study will be removed + mesh->UnRegister(); + } + } + else { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); + myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); + mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups, LineEditNewMesh->text().toLatin1().data()); if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) anEntryList.append( aSObject->GetID().c_str() ); - -#ifdef WITHGENERICOBJ + // obj has been published in study. Its refcount has been incremented. // It is safe to decrement its refcount // so that it will be destroyed when the entry in study will be removed mesh->UnRegister(); -#endif - } - break; + } + break; } } } catch (...) { @@ -762,26 +755,26 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument() Handle(SALOME_InteractiveObject) IO = it.Value(); SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO ); if ( aMesh->_is_nil() ) - return; + return; SMESH_Actor* anActor = SMESH::FindActorByObject( aMesh ); if ( !anActor ) - anActor = SMESH::FindActorByEntry( IO->getEntry() ); + anActor = SMESH::FindActorByEntry( IO->getEntry() ); if ( !anActor && !CheckBoxMesh->isChecked() ) - return; + return; if ( !SMESH::IObjectToInterface( IO )->_is_nil() ) { - if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() ) { - _PTR(SObject) obj = aStudy->FindObjectID( qPrintable( QString( IO->getEntry() ) ) ); - _PTR(GenericAttribute) anAttr; - if ( obj && obj->FindAttribute( anAttr, "AttributeName" ) ) { - _PTR(AttributeName) aNameAttr( anAttr ); - myObjects << SMESH::IObjectToInterface( IO ); - myObjectsNames << aNameAttr->Value().c_str(); - myMeshes << aMesh; - } - } + if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() ) { + _PTR(SObject) obj = aStudy->FindObjectID( qPrintable( QString( IO->getEntry() ) ) ); + _PTR(GenericAttribute) anAttr; + if ( obj && obj->FindAttribute( anAttr, "AttributeName" ) ) { + _PTR(AttributeName) aNameAttr( anAttr ); + myObjects << SMESH::IObjectToInterface( IO ); + myObjectsNames << aNameAttr->Value().c_str(); + myMeshes << aMesh; + } + } } myActor = anActor; @@ -803,7 +796,7 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString ); if (myMeshes.isEmpty()) - return; + return; } else { aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aList.First(), aString); myElementsId = aString; @@ -1151,19 +1144,19 @@ void SMESHGUI_TranslationDlg::onDisplaySimulation( bool toDisplayPreview ) { bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON || ActionGroup->checkedId() == MAKE_MESH_BUTTON ); SUIT_OverrideCursor aWaitCursor; - QList aMeshPreviewStruct; + QList aMeshPreviewStruct; if(CheckBoxMesh->isChecked()) - for ( int i = 0; i < myObjects.count(); i++ ) { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer(); - aMeshEditor->TranslateObject(myObjects[i], aVector, copy); - aMeshPreviewStruct << aMeshEditor->GetPreviewData(); - } + for ( int i = 0; i < myObjects.count(); i++ ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer(); + aMeshEditor->TranslateObject(myObjects[i], aVector, copy); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } else { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer(); + SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer(); aMeshEditor->Translate(anElementsId, aVector, copy); - aMeshPreviewStruct << aMeshEditor->GetPreviewData(); - } - setSimulationPreview( aMeshPreviewStruct ); + aMeshPreviewStruct << aMeshEditor->GetPreviewData(); + } + setSimulationPreview( aMeshPreviewStruct ); } catch (...) { } diff --git a/src/SMESHGUI/SMESH_images.ts b/src/SMESHGUI/SMESH_images.ts index 17eafcde3..a8fa7fd73 100644 --- a/src/SMESHGUI/SMESH_images.ts +++ b/src/SMESHGUI/SMESH_images.ts @@ -51,7 +51,7 @@ ICON_CONNECTION_2D mesh_multi_edges_2d.png - + ICON_CREATE_GROUP mesh_group.png @@ -271,11 +271,11 @@ ICON_FREE_EDGE mesh_free_edges.png - + ICON_FREE_EDGE_2D mesh_free_edges_2d.png - + ICON_FREE_NODE mesh_free_nodes.png @@ -427,13 +427,17 @@ ICON_REORIENT_2D reorient_faces_face.png - + ICON_SMESH_DUPLICATE_NODES mesh_duplicate_nodes.png - + ICON_SMESH_DUPLICATE_NODES_WITH_ELEM mesh_duplicate_nodes_with_elem.png + + + ICON_SMESH_DUPLICATE_ELEM_ONLY + mesh_duplicate_elem_only.png ICON_SMESH_TREE_ALGO diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index c10c3bad0..6a8b6750f 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -828,6 +828,10 @@ MEN_RESET Reset + + MEN_OVERALL_MESH_QUALITY + Overall Mesh Quality + MEN_DISTRIBUTION_CTRL Distribution @@ -946,7 +950,7 @@ MEN_DUPLICATE_NODES - Duplicate Nodes + Duplicate Nodes or/and Elements MEN_TRANSF @@ -1269,6 +1273,10 @@ Please enter correct values and try again SMESH_AUTO_GROUPS Automatically create groups + + SMESH_AUTO_DIM + Automatically define space dimension + SMESH_REQUIRED_GROUPS Create groups of required entities @@ -2555,7 +2563,7 @@ Check algorithm documentation for supported geometry SMESH_DUPLICATE_TITLE - Duplicate Nodes + Duplicate Nodes and/or Elements SMESH_SCALE @@ -2711,6 +2719,12 @@ Consider saving your work before application crash SMESH_WRN_SIZE_LIMIT_EXCEEDED No automatic update of the presentation has been done: new mesh size (%1 elements) exceeds current size limit (%2 elements). Please check preferences of Mesh module. + + + + SMESH_WRN_SIZE_INC_LIMIT_EXCEEDED + New mesh sise (%1 elements) exceeds current size limit (%2 elements). +Not all mesh elements are shown. Please check preferences of Mesh module. @@ -3283,7 +3297,7 @@ Please check preferences of Mesh module. STB_DUPLICATE_NODES - Duplicate Nodes + Duplicate Nodes or/and Elements STB_TRANSP @@ -3891,7 +3905,7 @@ Please check preferences of Mesh module. TOP_DUPLICATE_NODES - Duplicate Nodes + Duplicate Nodes or/and Elements TOP_TRANSP @@ -4092,6 +4106,22 @@ Input value precision can be adjusted using Selected object has been used to create another one. It can't be deleted + + SMESH_FREERAM + Free RAM + + + SMESH_GIGABYTE + %1 GB + + + MEN_SORT_CHILD_ITEMS + Sort children + + + STB_SORT_CHILD_ITEMS + Sort child items + SMESHGUI_Dialog @@ -4151,6 +4181,10 @@ Please, create VTK viewer and try again PREF_UPDATE_LIMIT_NOLIMIT No limit + + PREF_INCREMENTAL_LIMIT + Incremental limit check + PREF_BACKFACE Back surface color @@ -4263,10 +4297,18 @@ Please, create VTK viewer and try again PREF_DUMP_ADD_INFO Dump additional information + + PREF_DUMP_CTRL_INFO + Dump controls information + PREF_GPP_NODES_LIMIT Automatic nodes compute limit + + PREF_CTRL_LIMIT + Automatic controls compute limit + SMESH_PREF_GROUP_PRECISION Input fields precision @@ -4617,6 +4659,21 @@ Please, create VTK viewer and try again Bad Mesh to Group + + SMESHGUI_ComputeDlg_QThreadQDialog + + CANCEL + Cancel + + + CANCELING + Canceling... + + + TITLE + Compute + + SMESHGUI_PrecomputeDlg @@ -6463,7 +6520,7 @@ It is impossible to read point coordinates from file DUPLICATION_WITHOUT_ELEMS - Without duplication of border elements + Duplicate nodes only GROUP_NODES_TO_DUPLICATE @@ -6475,7 +6532,11 @@ It is impossible to read point coordinates from file DUPLICATION_WITH_ELEMS - With duplication of border elements + Duplicate nodes and border elements + + + DUPLICATION_ONLY_ELEMS + Duplicate elements only GROUP_ELEMS_TO_DUPLICATE @@ -6739,6 +6800,10 @@ as they are of improper type: ADDITIONAL_INFO Additional Info + + CTRL_INFO + Quality Info + NODE_MODE Node @@ -7105,6 +7170,84 @@ as they are of improper type: Vertex + + SMESHGUI_CtrlInfo + + CTRL_INFO + Quality information + + + NAME_LAB + Name: + + + VALUE + Value + + + BUT_COMPUTE + Compute + + + NODES_INFO + Nodes Information: + + + NUMBER_OF_THE_FREE_NODES + Number of the free nodes + + + DOUBLE_NODES_TOLERANCE + Double nodes tolerance + + + NUMBER_OF_THE_DOUBLE_NODES + Number of the double nodes + + + EDGES_INFO + Edges Information: + + + NUMBER_OF_THE_DOUBLE_EDGES + Number of the double edges + + + FACES_INFO + Faces Information: + + + NUMBER_OF_THE_DOUBLE_FACES + Number of the double faces + + + ASPECT_RATIO_HISTOGRAM + Aspect Ratio histogram + + + VOLUMES_INFO + Volumes Information: + + + NUMBER_OF_THE_DOUBLE_VOLUMES + Number of the double volumes + + + NUMBER_OF_THE_OVER_CONSTRAINED + Number of the over-constrained + + + ASPECT_RATIO_3D_HISTOGRAM + Aspect Ratio 3D histogram + + + + SMESHGUI_CtrlInfoDlg + + CTRL_INFO + Quality Info + + SMESHGUI_MinDistance diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index 6aae4287a..7423e43ea 100755 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -3,6 +3,46 @@ @default + + SMESH_GIGABYTE + %1 GB + + + SMESH_FREERAM + Free RAM + + + STB_BIQUADRATIC_TRIANGLE + BiQuadratic Triangle + + + TOP_BIQUADRATIC_TRIANGLE + BiQuadratic Triangle + + + MEN_BIQUADRATIC_TRIANGLE + BiQuadratic Triangle + + + SMESH_BIQUADRATIC_TRIANGLES + BiQuadratic Triangles + + + SMESH_BIQUADRATIC_TRIANGLE + BiQuadratic Triangle + + + SMESH_AUTO_DIM + Automatically define space dimension + + + SMESH_ADD_BIQUADRATIC_TRIANGLE_TITLE + Add BiQuadratic Triangle + + + COMPERR_WARNING + Warning + SMESH_EXPORT_MESH Exporter le maillage @@ -824,6 +864,10 @@ MEN_RESET Restaurer + + MEN_OVERALL_MESH_QUALITY + Overall Mesh Quality + MEN_DISTRIBUTION_CTRL Distribution @@ -2683,6 +2727,12 @@ Enregistrez votre travail avant que l'application se plante SMESH_WRN_SIZE_LIMIT_EXCEEDED La présentation n'a pas été mise à jour automatiquement: la nouvelle taille du maillage (%1 éléments) dépasse la limite de taille actuelle (%2 éléments). Vérifiez la limite dans les préférences du module Mesh. + + + + SMESH_WRN_SIZE_INC_LIMIT_EXCEEDED + New mesh sise (%1 elements) exceeds current size limit (%2 elements). +Not all mesh elements are shown. Please check preferences of Mesh module. @@ -4064,6 +4114,14 @@ avec le paramètre '%1' des préférences du module Mesh.L'objet sélectionné a été utilisé pour en créer un autre. Il ne peut pas être supprimé. + + MEN_SORT_CHILD_ITEMS + Sort children + + + STB_SORT_CHILD_ITEMS + Sort child items + SMESHGUI_Dialog @@ -4123,6 +4181,10 @@ Ouvrez une fenêtre VTK et essayez de nouveau PREF_UPDATE_LIMIT_NOLIMIT Sans limite + + PREF_INCREMENTAL_LIMIT + Incremental limit check + PREF_BACKFACE Couleur de face arrière @@ -4235,10 +4297,18 @@ Ouvrez une fenêtre VTK et essayez de nouveau PREF_DUMP_ADD_INFO Copier les informations additionelles + + PREF_DUMP_CTRL_INFO + Dump controls information + PREF_GPP_NODES_LIMIT Calcul automatique du nombre de nÅ“uds: limite + + PREF_CTRL_LIMIT + Automatic controls compute limit + SMESH_PREF_GROUP_PRECISION Précision des champs d'entrée @@ -4435,6 +4505,10 @@ Ouvrez une fenêtre VTK et essayez de nouveau SMESHGUI_AddQuadraticElementDlg + + SMESH_ADD_BIQUADRATIC_TRIANGLE + Add BiQuadratic Triangle + SMESH_ADD_QUADRATIC_EDGE Ajouter une arête quadratique @@ -4544,6 +4618,10 @@ Ouvrez une fenêtre VTK et essayez de nouveau SMESHGUI_ComputeDlg + + GROUP_OF_BAD_MESH + Bad Mesh to Group + CAPTION Le calcul du maillage a échoué @@ -4763,6 +4841,10 @@ Vérifiez l'espace de disque disponible et vos droits d'écriture dans SMESHGUI_CuttingOfQuadsDlg + + TO_4_TRIA + Cut into 4 triangles + CAPTION Découpe des quadrangles @@ -5132,6 +5214,22 @@ Vérifiez la validité des informations données SMESHGUI_FilterTable + + ENTITY_TYPE_24 + BALL + + + ENTITY_TYPE_23 + QPOLYEDRE + + + ENTITY_TYPE_1 + POINT1 + + + CONNECTED_ELEMS + Elements of a domain + ADD Ajouter @@ -6401,6 +6499,10 @@ Il y a trop peu de points dans le fichier SMESHGUI_DuplicateNodesDlg + + DUPLICATION_ONLY_ELEMS + Duplicate elements only + DUPLICATION_MODE Mode de duplication @@ -6683,6 +6785,10 @@ en raison de leurs types incompatibles: ADDITIONAL_INFO Infos détaillées + + CTRL_INFO + Quality Info + NODE_MODE NÅ“ud @@ -7049,6 +7155,84 @@ en raison de leurs types incompatibles: Point + + SMESHGUI_CtrlInfo + + CTRL_INFO + Quality information + + + NAME_LAB + Name: + + + VALUE + Value + + + BUT_COMPUTE + Compute + + + NODES_INFO + Nodes Information: + + + NUMBER_OF_THE_FREE_NODES + Number of the free nodes + + + NUMBER_OF_THE_DOUBLE_NODES + Number of the double nodes + + + DOUBLE_NODES_TOLERANCE + Tolérance des nÅ“uds doubles + + + EDGES_INFO + Edges Information: + + + NUMBER_OF_THE_DOUBLE_EDGES + Number of the double edges + + + FACES_INFO + Faces Information: + + + NUMBER_OF_THE_DOUBLE_FACES + Number of the double faces + + + ASPECT_RATIO_HISTOGRAM + Aspect Ratio histogram + + + VOLUMES_INFO + Volumes Information: + + + NUMBER_OF_THE_DOUBLE_VOLUMES + Number of the double volumes + + + NUMBER_OF_THE_OVER_CONSTRAINED + Number of the over-constrained + + + ASPECT_RATIO_3D_HISTOGRAM + Aspect Ratio 3D histogram + + + + SMESHGUI_CtrlInfoDlg + + CTRL_INFO + Quality Info + + SMESHGUI_MinDistance @@ -7308,4 +7492,19 @@ en raison de leurs types incompatibles: Coef de réduction: + + SMESHGUI_ComputeDlg_QThreadQDialog + + TITLE + Compute + + + CANCELING + Canceling... + + + CANCEL + Cancel + + diff --git a/src/SMESHUtils/SMESH_Block.cxx b/src/SMESHUtils/SMESH_Block.cxx index 084c49146..f0838270e 100644 --- a/src/SMESHUtils/SMESH_Block.cxx +++ b/src/SMESHUtils/SMESH_Block.cxx @@ -694,12 +694,12 @@ bool SMESH_Block::ComputeParameters(const gp_Pnt& thePoint, start.SetCoord( iParam, sumParam / 4.); } if ( needGrid ) { - // compute nodes of 3 x 3 x 3 grid + // compute nodes of 10 x 10 x 10 grid int iNode = 0; Bnd_Box box; - for ( double x = 0.25; x < 0.9; x += 0.25 ) - for ( double y = 0.25; y < 0.9; y += 0.25 ) - for ( double z = 0.25; z < 0.9; z += 0.25 ) { + for ( double x = 0.05; x < 1.; x += 0.1 ) + for ( double y = 0.05; y < 1.; y += 0.1 ) + for ( double z = 0.05; z < 1.; z += 0.1 ) { TxyzPair & prmPtn = my3x3x3GridNodes[ iNode++ ]; prmPtn.first.SetCoord( x, y, z ); ShellPoint( prmPtn.first, prmPtn.second ); @@ -718,7 +718,7 @@ bool SMESH_Block::ComputeParameters(const gp_Pnt& thePoint, { double minDist = DBL_MAX; gp_XYZ* bestParam = 0; - for ( int iNode = 0; iNode < 27; iNode++ ) { + for ( int iNode = 0; iNode < 1000; iNode++ ) { TxyzPair & prmPtn = my3x3x3GridNodes[ iNode ]; double dist = ( thePoint.XYZ() - prmPtn.second ).SquareModulus(); if ( dist < minDist ) { @@ -819,6 +819,12 @@ bool SMESH_Block::ComputeParameters(const gp_Pnt& thePoint, << " ------ NB IT: " << myNbIterations << ", SUM DIST: " << mySumDist ); #endif + const double reachedDist = sqrt( sqDistance ); + if ( reachedDist > 1000 * myTolerance && + computeParameters( thePoint, theParams, solution ) && + reachedDist > distance() ) + return true; + theParams = solution; if ( myFaceIndex > 0 ) diff --git a/src/SMESHUtils/SMESH_Block.hxx b/src/SMESHUtils/SMESH_Block.hxx index 427cc94de..4f0a60db9 100644 --- a/src/SMESHUtils/SMESH_Block.hxx +++ b/src/SMESHUtils/SMESH_Block.hxx @@ -383,7 +383,7 @@ public: double myValues[ 4 ]; // values computed at myParam: square distance and 3 derivatives typedef std::pair TxyzPair; - TxyzPair my3x3x3GridNodes[ 27 ]; // to compute the first param guess + TxyzPair my3x3x3GridNodes[ 1000 ]; // to compute the first param guess bool myGridComputed; }; diff --git a/src/SMESH_I/Makefile.am b/src/SMESH_I/Makefile.am index 982b6c33b..d76a6c7dc 100644 --- a/src/SMESH_I/Makefile.am +++ b/src/SMESH_I/Makefile.am @@ -38,11 +38,8 @@ salomeinclude_HEADERS = \ SMESH_Hypothesis_i.hxx \ SMESH_PythonDump.hxx \ SMESH_Group_i.hxx \ - SMESH_MEDMesh_i.hxx \ SMESH_Filter_i.hxx \ SMESH_MeshEditor_i.hxx \ - SMESH_MEDFamily_i.hxx \ - SMESH_MEDSupport_i.hxx \ SMESH_Pattern_i.hxx \ SMESH_2smeshpy.hxx \ SMESH_NoteBook.hxx \ @@ -60,9 +57,6 @@ dist_libSMESHEngine_la_SOURCES = \ SMESH_Gen_i_1.cxx \ SMESH_DumpPython.cxx \ SMESH_Mesh_i.cxx \ - SMESH_MEDMesh_i.cxx \ - SMESH_MEDFamily_i.cxx \ - SMESH_MEDSupport_i.cxx \ SMESH_subMesh_i.cxx \ SMESH_MeshEditor_i.cxx \ SMESH_Hypothesis_i.cxx \ @@ -95,11 +89,12 @@ libSMESHEngine_la_CPPFLAGS = \ $(BOOST_CPPFLAGS) \ $(KERNEL_CXXFLAGS) \ $(GUI_CXXFLAGS) \ - $(MED_CXXFLAGS) \ $(GEOM_CXXFLAGS) \ -I$(srcdir)/../Controls \ -I$(srcdir)/../SMDS \ -I$(srcdir)/../SMESHDS \ + -I$(srcdir)/../MEDWrapper/Base \ + -I$(srcdir)/../MEDWrapper/Factory \ -I$(srcdir)/../Driver \ -I$(srcdir)/../DriverMED \ -I$(srcdir)/../DriverCGNS \ @@ -124,10 +119,6 @@ libSMESHEngine_la_LDFLAGS = \ -lSalomeGenericObj \ -lSalomeIDLKernel \ -lSALOMELocalTrace \ - $(MED_LDFLAGS) \ - -lMEDWrapper \ - -lMEDWrapper_V2_2 \ - -lSalomeIDLMED \ $(CAS_LDPATH) \ -lTKCDF \ -lTKBO \ diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 7ff09306b..b0a202b5e 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -196,8 +196,16 @@ namespace { cmd->Clear(); return; } - // comment a command having not created args - for ( int iArg = cmd->GetNbArgs(); iArg; --iArg ) + // check if an Object was created in the script + _AString comment; + const _pyID& obj = cmd->GetObject(); + if ( !obj.IsEmpty() && cmd->IsStudyEntry( obj ) && !presentObjects.count( obj )) + { + comment = "not created Object"; + theGen->ObjectCreationRemoved( obj ); + } + // check if a command has not created args + for ( int iArg = cmd->GetNbArgs(); iArg && comment.IsEmpty(); --iArg ) { const _pyID& arg = cmd->GetArg( iArg ); if ( arg.IsEmpty() || arg.Value( 1 ) == '"' || arg.Value( 1 ) == '\'' ) @@ -207,34 +215,29 @@ namespace { for ( ; id != idList.end(); ++id ) if ( !theGen->IsGeomObject( *id ) && !presentObjects.count( *id )) { - cmd->Comment(); - cmd->GetString() += " ### " ; - cmd->GetString() += *id + " has not been yet created"; - for ( int i = 0; i < cmd->GetNbResultValues(); i++ ) { - _pyID objID = cmd->GetResultValue( i+1 ); - theGen->ObjectCreationRemoved( objID ); // objID.SetName( name ) is not needed - } - return; + comment += *id + " has not been yet created"; + break; } } - // comment a command having not created Object - const _pyID& obj = cmd->GetObject(); - if ( !obj.IsEmpty() && cmd->IsStudyEntry( obj ) && !presentObjects.count( obj )) + // treat result objects + const _pyID& result = cmd->GetResultValue(); + if ( !result.IsEmpty() && result.Value( 1 ) != '"' && result.Value( 1 ) != '\'' ) + { + list< _pyID > idList = cmd->GetStudyEntries( result ); + list< _pyID >::iterator id = idList.begin(); + for ( ; id != idList.end(); ++id ) + if ( comment.IsEmpty() ) + presentObjects.insert( *id ); + else + theGen->ObjectCreationRemoved( *id ); // objID.SetName( name ) is not needed + } + // comment the command + if ( !comment.IsEmpty() ) { cmd->Comment(); - cmd->GetString() += " ### not created object" ; - for ( int i = 0; i < cmd->GetNbResultValues(); i++ ) { - _pyID objID = cmd->GetResultValue( i+1 ); - theGen->ObjectCreationRemoved( objID ); // objID.SetName( name ) is not needed - } + cmd->GetString() += " ### "; + cmd->GetString() += comment; } - const _pyID& result = cmd->GetResultValue(); - if ( result.IsEmpty() || result.Value( 1 ) == '"' || result.Value( 1 ) == '\'' ) - return; - list< _pyID > idList = cmd->GetStudyEntries( result ); - list< _pyID >::iterator id = idList.begin(); - for ( ; id != idList.end(); ++id ) - presentObjects.insert( *id ); } //================================================================================ @@ -307,6 +310,8 @@ namespace { undef2newItems[ 44 ].push_back( 37 ); undef2newItems[ 45 ].push_back( 36 ); undef2newItems[ 46 ].push_back( 39 ); + + ASSERT( undef2newItems.rbegin()->first == SMESH::FT_Undefined ); } int iType = Type.IntegerValue(); @@ -342,6 +347,90 @@ namespace { BinaryOp = TCollection_AsciiString( iBinaryOp ); } } + + //================================================================================ + /*! + * \brief Replaces "SMESH.PointStruct(x,y,z)" and "SMESH.DirStruct( SMESH.PointStruct(x,y,z))" + * arguments of a given command by a list "[x,y,z]" if the list is accesible + * type of argument. + */ + //================================================================================ + + void StructToList( Handle( _pyCommand)& theCommand ) + { + static TStringSet methodsAcceptingList; + if ( methodsAcceptingList.empty() ) { + const char * methodNames[] = { + "GetCriterion","Reorient2D","ExtrusionSweep","ExtrusionSweepMakeGroups0D", + "ExtrusionSweepMakeGroups","ExtrusionSweep0D", + "AdvancedExtrusion","AdvancedExtrusionMakeGroups", + "ExtrusionSweepObject","ExtrusionSweepObject0DMakeGroups", + "ExtrusionSweepObjectMakeGroups","ExtrusionSweepObject0D", + "ExtrusionSweepObject1D","ExtrusionSweepObject1DMakeGroups", + "ExtrusionSweepObject2D","ExtrusionSweepObject2DMakeGroups", + "Translate","TranslateMakeGroups","TranslateMakeMesh", + "TranslateObject","TranslateObjectMakeGroups", "TranslateObjectMakeMesh" + ,"" }; // <- mark of the end + methodsAcceptingList.Insert( methodNames ); + } + if ( methodsAcceptingList.Contains( theCommand->GetMethod() )) + { + for ( int i = theCommand->GetNbArgs(); i > 0; --i ) + { + const _AString & arg = theCommand->GetArg( i ); + if ( arg.Search( "SMESH.PointStruct" ) == 1 || + arg.Search( "SMESH.DirStruct" ) == 1 ) + { + Handle(_pyCommand) workCmd = new _pyCommand( arg ); + if ( workCmd->GetNbArgs() == 1 ) // SMESH.DirStruct( SMESH.PointStruct(x,y,z)) + { + workCmd = new _pyCommand( workCmd->GetArg( 1 ) ); + } + if ( workCmd->GetNbArgs() == 3 ) // SMESH.PointStruct(x,y,z) + { + _AString newArg = "[ "; + newArg += ( workCmd->GetArg( 1 ) + ", " + + workCmd->GetArg( 2 ) + ", " + + workCmd->GetArg( 3 ) + " ]"); + theCommand->SetArg( i, newArg ); + } + } + } + } + } + //================================================================================ + /*! + * \brief Replaces "mesh.GetIDSource([id1,id2])" argument of a given command by + * a list "[id1,id2]" if the list is an accesible type of argument. + */ + //================================================================================ + + void GetIDSourceToList( Handle( _pyCommand)& theCommand ) + { + static TStringSet methodsAcceptingList; + if ( methodsAcceptingList.empty() ) { + const char * methodNames[] = { + "ExportPartToMED","ExportPartToDAT","ExportPartToUNV","ExportPartToSTL", + "ExportCGNS","ExportGMF", + "Create0DElementsOnAllNodes","Reorient2D","QuadTo4Tri", + "ScaleMakeGroups","Scale","ScaleMakeMesh", + "FindCoincidentNodesOnPartBut","DoubleElements" + ,"" }; // <- mark of the end + methodsAcceptingList.Insert( methodNames ); + } + if ( methodsAcceptingList.Contains( theCommand->GetMethod() )) + { + for ( int i = theCommand->GetNbArgs(); i > 0; --i ) + { + _pyCommand argCmd( theCommand->GetArg( i )); + if ( argCmd.GetMethod() == "GetIDSource" && + argCmd.GetNbArgs() == 2 ) + { + theCommand->SetArg( i, argCmd.GetArg( 1 )); + } + } + } + } } //================================================================================ @@ -537,12 +626,16 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand PlaceSubmeshAfterItsCreation( aCommand ); } + // Method( SMESH.PointStruct(x,y,z) -> Method( [x,y,z] + StructToList( aCommand ); + // Find an object to process theCommand // SMESH_Gen method? if ( objID == this->GetID() || objID == SMESH_2smeshpy::GenName()) { this->Process( aCommand ); + addFilterUser( aCommand, theGen ); // protect filters from clearing return aCommand; } @@ -566,6 +659,11 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand myObjects.insert( make_pair( subMeshID, subMesh )); } + // Method( mesh.GetIDSource([id1,id2]) -> Method( [id1,id2] + GetIDSourceToList( aCommand ); + + addFilterUser( aCommand, theGen ); // protect filters from clearing + id_mesh->second->Process( aCommand ); id_mesh->second->AddProcessedCmd( aCommand ); return aCommand; @@ -575,6 +673,11 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand map< _pyID, Handle(_pyMeshEditor) >::iterator id_editor = myMeshEditors.find( objID ); if ( id_editor != myMeshEditors.end() ) { + // Method( mesh.GetIDSource([id1,id2]) -> Method( [id1,id2] + GetIDSourceToList( aCommand ); + + addFilterUser( aCommand, theGen ); // protect filters from clearing + const TCollection_AsciiString& method = aCommand->GetMethod(); // some commands of SMESH_MeshEditor create meshes and groups @@ -719,6 +822,9 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand UnaryOp = SMESH + SMESH::FunctorTypeToString( SMESH::FunctorType( UnaryOp.IntegerValue() )); BinaryOp = SMESH + SMESH::FunctorTypeToString( SMESH::FunctorType( BinaryOp.IntegerValue() )); + if ( Compare == "SMESH.FT_EqualTo" ) + Compare = "'='"; + aCommand->RemoveArgs(); aCommand->SetObject( SMESH_2smeshpy::GenName() ); aCommand->SetMethod( "GetCriterion" ); @@ -1250,6 +1356,35 @@ void _pyGen::setNeighbourCommand( Handle(_pyCommand)& theCmd, (*pos)->SetOrderNb( i++ ); } +//================================================================================ +/*! + * \brief Call _pyFilter.AddUser() if a filter is used as a command arg + */ +//================================================================================ + +void _pyGen::addFilterUser( Handle(_pyCommand)& theCommand, const Handle(_pyObject)& user ) +{ + const char filterPrefix[] = "aFilter0x"; + if ( theCommand->GetString().Search( filterPrefix ) < 1 ) + return; + + for ( int i = theCommand->GetNbArgs(); i > 0; --i ) + { + const _AString & arg = theCommand->GetArg( i ); + // NOT TREATED CASE: arg == "[something, aFilter0x36a2f60]" + if ( arg.Search( filterPrefix ) != 1 ) + continue; + + Handle(_pyFilter) filter = Handle(_pyFilter)::DownCast( FindObject( arg )); + if ( !filter.IsNull() ) + { + filter->AddUser( user ); + if ( !filter->GetNewID().IsEmpty() ) + theCommand->SetArg( i, filter->GetNewID() ); + } + } +} + //================================================================================ /*! * \brief Set command be last in list of commands @@ -1676,9 +1811,17 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand ) // ---------------------------------------------------------------------- else if ( theCommand->MethodStartsFrom( "Export" )) { - if ( method == "ExportToMED" || // ExportToMED() --> ExportMED() - method == "ExportToMEDX" ) { // ExportToMEDX() --> ExportMED() + if ( method == "ExportToMED" || // ExportToMED() --> ExportMED() + method == "ExportToMEDX" ) // ExportToMEDX() --> ExportMED() + { theCommand->SetMethod( "ExportMED" ); + if ( theCommand->GetNbArgs() == 5 ) + { + // ExportToMEDX(...,autoDimension) -> ExportToMEDX(...,meshPart=None,autoDimension) + _AString autoDimension = theCommand->GetArg( 5 ); + theCommand->SetArg( 5, "None" ); + theCommand->SetArg( 6, autoDimension ); + } } else if ( method == "ExportCGNS" ) { // ExportCGNS(part, ...) -> ExportCGNS(..., part) @@ -1703,9 +1846,9 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand ) TCollection_AsciiString newMethod = method; newMethod.Remove( 7, 6 ); theCommand->SetMethod( newMethod ); - // make the 1st arg be the last one + // make the 1st arg be the last one (or last but one for ExportMED()) _pyID partID = theCommand->GetArg( 1 ); - int nbArgs = theCommand->GetNbArgs(); + int nbArgs = theCommand->GetNbArgs() - (newMethod == "ExportMED"); for ( int i = 2; i <= nbArgs; ++i ) theCommand->SetArg( i-1, theCommand->GetArg( i )); theCommand->SetArg( nbArgs, partID ); @@ -2090,29 +2233,36 @@ _pyMeshEditor::_pyMeshEditor(const Handle(_pyCommand)& theCreationCmd): void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand) { - // names of SMESH_MeshEditor methods fully equal to methods of the python class Mesh, so - // commands calling this methods are converted to calls of Mesh methods + // Names of SMESH_MeshEditor methods fully equal to methods of the python class Mesh, so + // commands calling these methods are converted to calls of Mesh methods without + // additional modifs, only object is changed from MeshEditor to Mesh. static TStringSet sameMethods; if ( sameMethods.empty() ) { const char * names[] = { - "RemoveElements","RemoveNodes","RemoveOrphanNodes","AddNode","Add0DElement","AddEdge","AddFace","AddPolygonalFace","AddBall", - "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "MoveClosestNodeToPoint", + "RemoveElements","RemoveNodes","RemoveOrphanNodes", + "AddNode","Add0DElement","AddEdge","AddFace","AddPolygonalFace","AddBall", + "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces", + "MoveNode", "MoveClosestNodeToPoint", "InverseDiag","DeleteDiag","Reorient","ReorientObject", "TriToQuad","TriToQuadObject", "QuadTo4Tri", "SplitQuad","SplitQuadObject", "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject", "ConvertToQuadratic","ConvertFromQuadratic","RenumberNodes","RenumberElements", "RotationSweep","RotationSweepObject","RotationSweepObject1D","RotationSweepObject2D", - "ExtrusionSweep","AdvancedExtrusion","ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D", - "ExtrusionAlongPath","ExtrusionAlongPathObject","ExtrusionAlongPathX", - "ExtrusionAlongPathObject1D","ExtrusionAlongPathObject2D", + "ExtrusionSweep","AdvancedExtrusion","ExtrusionSweepObject","ExtrusionSweepObject1D", + "ExtrusionSweepObject2D","ExtrusionAlongPath","ExtrusionAlongPathObject", + "ExtrusionAlongPathX","ExtrusionAlongPathObject1D","ExtrusionAlongPathObject2D", "Mirror","MirrorObject","Translate","TranslateObject","Rotate","RotateObject", - "FindCoincidentNodes",/*"FindCoincidentNodesOnPart",*/"MergeNodes","FindEqualElements", + "FindCoincidentNodes","MergeNodes","FindEqualElements", "MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders", "SewBorderToSide","SewSideElements","ChangeElemNodes","GetLastCreatedNodes", "GetLastCreatedElems", "MirrorMakeMesh","MirrorObjectMakeMesh","TranslateMakeMesh","TranslateObjectMakeMesh", "Scale","ScaleMakeMesh","RotateMakeMesh","RotateObjectMakeMesh","MakeBoundaryMesh", - "MakeBoundaryElements", "SplitVolumesIntoTetra" + "MakeBoundaryElements", "SplitVolumesIntoTetra", + "DoubleElements","DoubleNodes","DoubleNode","DoubleNodeGroup","DoubleNodeGroups", + "DoubleNodeElem","DoubleNodeElemInRegion","DoubleNodeElemGroup", + "DoubleNodeElemGroupInRegion","DoubleNodeElemGroups","DoubleNodeElemGroupsInRegion", + "DoubleNodesOnGroupBoundaries","CreateFlatElementsOnFacesGroups","CreateHoleSkin" ,"" }; // <- mark of the end sameMethods.Insert( names ); } @@ -3202,6 +3352,7 @@ int _pyCommand::GetBegPos( int thePartIndex ) return EMPTY; if ( myBegPos.Length() < thePartIndex ) return UNKNOWN; + ASSERT( thePartIndex > 0 ); return myBegPos( thePartIndex ); } @@ -3217,6 +3368,7 @@ void _pyCommand::SetBegPos( int thePartIndex, int thePosition ) { while ( myBegPos.Length() < thePartIndex ) myBegPos.Append( UNKNOWN ); + ASSERT( thePartIndex > 0 ); myBegPos( thePartIndex ) = thePosition; } @@ -3747,7 +3899,7 @@ void _pyCommand::Comment() if ( i <= Length() ) { myString.Insert( i, "#" ); - for ( int iPart = 0; iPart < myBegPos.Length(); ++iPart ) + for ( int iPart = 1; iPart <= myBegPos.Length(); ++iPart ) { int begPos = GetBegPos( iPart + 1 ); if ( begPos != UNKNOWN ) diff --git a/src/SMESH_I/SMESH_2smeshpy.hxx b/src/SMESH_I/SMESH_2smeshpy.hxx index 86a087728..32ad5cd94 100644 --- a/src/SMESH_I/SMESH_2smeshpy.hxx +++ b/src/SMESH_I/SMESH_2smeshpy.hxx @@ -268,7 +268,8 @@ private: void setNeighbourCommand( Handle(_pyCommand)& theCmd, Handle(_pyCommand)& theOtherCmd, const bool theIsAfter ); - + void addFilterUser( Handle(_pyCommand)& theCmd, const Handle(_pyObject)& user ); + private: std::map< _pyID, Handle(_pyMesh) > myMeshes; std::map< _pyID, Handle(_pyMeshEditor) > myMeshEditors; diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx index 5840f0ab2..c9ca6c870 100644 --- a/src/SMESH_I/SMESH_DumpPython.cxx +++ b/src/SMESH_I/SMESH_DumpPython.cxx @@ -881,15 +881,16 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl aScript += helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()\n\t"; aScript += helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()\n\t"; + // This is not needed since entering a plug-in system to smesh.py // import python files corresponding to plugins - set moduleNameSet; - map::iterator hyp_creator = myHypCreatorMap.begin(); - for ( ; hyp_creator != myHypCreatorMap.end(); ++hyp_creator ) { - string moduleName = hyp_creator->second->GetModuleName(); - bool newModule = moduleNameSet.insert( moduleName ).second; - if ( newModule ) - aScript += helper + "\n\t" + "from salome." + (char*) moduleName.c_str() + " import " + (char*) moduleName.c_str() +"Builder"; - } + // set moduleNameSet; + // map::iterator hyp_creator = myHypCreatorMap.begin(); + // for ( ; hyp_creator != myHypCreatorMap.end(); ++hyp_creator ) { + // string moduleName = hyp_creator->second->GetModuleName(); + // bool newModule = moduleNameSet.insert( moduleName ).second; + // if ( newModule ) + // aScript += helper + "\n\t" + "from salome." + (char*) moduleName.c_str() + " import " + (char*) moduleName.c_str() +"Builder"; + // } // Dump trace of restored study if (theSavedTrace.Length() > 0) { @@ -993,7 +994,8 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl do { aName = aBaseName + (++objectCounter); } while (theObjectNames.IsBound(aName)); - seqRemoved.Append(aName); + if ( !aRemovedObjIDs.count( anEntry )) + seqRemoved.Append(aName); mapRemoved.Bind(anEntry, "1"); theObjectNames.Bind(anEntry, aName); } @@ -1032,7 +1034,6 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl anUpdatedScript += "\n\taStudyBuilder = theStudy.NewBuilder()"; } for (int ir = 1; ir <= seqRemoved.Length(); ir++) { - if ( aRemovedObjIDs.count( seqRemoved.Value(ir) )) continue; anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR("; anUpdatedScript += seqRemoved.Value(ir); // for object wrapped by class of smeshBuilder.py @@ -1043,12 +1044,8 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl } // Set object names - anUpdatedScript += "\n\t## set object names"; -// anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")"; -// anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())"; -// anUpdatedScript += "\n"; - TCollection_AsciiString aGUIName; + TCollection_AsciiString aGUIName, aSetNameScriptPart; Resource_DataMapOfAsciiStringAsciiString mapEntries; for (Standard_Integer i = 1; i <= aLen; i += 2) { @@ -1056,23 +1053,24 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl aName = geom->GetDumpName( anEntry.ToCString() ); if (aName.IsEmpty() && // Not a GEOM object theNames.IsBound(anEntry) && - !aRemovedObjIDs.count(anEntry) && // a command creating anEntry was erased + !aRemovedObjIDs.count(anEntry) && // A command creating anEntry was erased !mapEntries.IsBound(anEntry) && // Not yet processed !mapRemoved.IsBound(anEntry)) // Was not removed { aName = theObjectNames.Find(anEntry); aGUIName = theNames.Find(anEntry); mapEntries.Bind(anEntry, aName); - anUpdatedScript += helper + "\n\t" + aSMESHGen + ".SetName(" + aName; + aSetNameScriptPart += helper + "\n\t" + aSMESHGen + ".SetName(" + aName; if ( anEntry2AccessorMethod.IsBound( anEntry ) ) - anUpdatedScript += helper + "." + anEntry2AccessorMethod( anEntry ); - anUpdatedScript += helper + ", '" + aGUIName + "')"; + aSetNameScriptPart += helper + "." + anEntry2AccessorMethod( anEntry ); + aSetNameScriptPart += helper + ", '" + aGUIName + "')"; } } - - // Issue 0021249: removed (a similar block is dumped by SALOMEDSImpl_Study) - //anUpdatedScript += "\n\tif salome.sg.hasDesktop():"; - //anUpdatedScript += "\n\t\tsalome.sg.updateObjBrowser(0)"; + if ( !aSetNameScriptPart.IsEmpty() ) + { + anUpdatedScript += "\n\t## set object names"; + anUpdatedScript += aSetNameScriptPart; + } // ----------------------------------------------------------------- // store visual properties of displayed objects diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 6ab4d0850..b7b0e53e1 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -33,6 +33,7 @@ #include "SMDS_MeshNode.hxx" #include "SMESHDS_Mesh.hxx" #include "SMESH_Gen_i.hxx" +#include "SMESH_Group_i.hxx" #include "SMESH_PythonDump.hxx" #include @@ -588,12 +589,63 @@ SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals, COR std::vector elements; myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements,0,isLogarithmic); -#ifdef WIN32 - nbIntervals = CORBA::Short( min( nbEvents.size(), funValues.size() - 1)); -#else - nbIntervals = CORBA::Short( std::min( nbEvents.size(), funValues.size() - 1)); -#endif SMESH::Histogram_var histogram = new SMESH::Histogram; + + nbIntervals = CORBA::Short( Min( int( nbEvents.size()), + int( funValues.size() - 1 ))); + if ( nbIntervals > 0 ) + { + histogram->length( nbIntervals ); + for ( int i = 0; i < nbIntervals; ++i ) + { + HistogramRectangle& rect = histogram[i]; + rect.nbEvents = nbEvents[i]; + rect.min = funValues[i]; + rect.max = funValues[i+1]; + } + } + return histogram._retn(); +} + +SMESH::Histogram* NumericalFunctor_i::GetLocalHistogram(CORBA::Short nbIntervals, + CORBA::Boolean isLogarithmic, + SMESH::SMESH_IDSource_ptr object) +{ + SMESH::Histogram_var histogram = new SMESH::Histogram; + + std::vector nbEvents; + std::vector funValues; + std::vector elements; + + SMDS_ElemIteratorPtr elemIt; + if ( SMESH::DownCast< SMESH_GroupOnFilter_i* >( object ) || + SMESH::DownCast< SMESH::Filter_i* >( object )) + { + elemIt = SMESH_Mesh_i::GetElements( object, GetElementType() ); + } + else + { + SMESH::SMESH_Mesh_var mesh = object->GetMesh(); + SMESH::long_array_var objNbElems = object->GetNbElementsByType(); + SMESH::long_array_var meshNbElems = mesh-> GetNbElementsByType(); + if ( meshNbElems[ GetElementType() ] != + objNbElems [ GetElementType() ] ) + { + elements.reserve( objNbElems[ GetElementType() ]); + elemIt = SMESH_Mesh_i::GetElements( object, GetElementType() ); + } + } + if ( elemIt ) + { + while ( elemIt->more() ) + elements.push_back( elemIt->next()->GetID() ); + if ( elements.empty() ) return histogram._retn(); + } + + myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements,0,isLogarithmic); + + nbIntervals = CORBA::Short( Min( int( nbEvents.size()), + int( funValues.size() - 1 ))); if ( nbIntervals > 0 ) { histogram->length( nbIntervals ); @@ -920,6 +972,29 @@ CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId ) return myPredicatePtr->IsSatisfy( theId ); } +CORBA::Long Predicate_i::NbSatisfying( SMESH::SMESH_IDSource_ptr obj ) +{ + SMESH::SMESH_Mesh_var meshVar = obj->GetMesh(); + const SMDS_Mesh* meshDS = MeshPtr2SMDSMesh( meshVar ); + if ( !meshDS ) + return 0; + myPredicatePtr->SetMesh( meshDS ); + + SMDSAbs_ElementType elemType = SMDSAbs_ElementType( GetElementType() ); + + int nb = 0; + SMDS_ElemIteratorPtr elemIt = + SMESH::DownCast( meshVar )->GetElements( obj, GetElementType() ); + if ( elemIt ) + while ( elemIt->more() ) + { + const SMDS_MeshElement* e = elemIt->next(); + if ( e && e->GetType() == elemType ) + nb += myPredicatePtr->IsSatisfy( e->GetID() ); + } + return nb; +} + Controls::PredicatePtr Predicate_i::GetPredicate() { return myPredicatePtr; @@ -2702,59 +2777,63 @@ GetElementsId( SMESH_Mesh_ptr theMesh ) return anArray._retn(); } -template -static void collectMeshInfo(const TIterator& theItr, - TPredicate& thePred, - SMESH::long_array& theRes) -{ - if (!theItr) - return; - while (theItr->more()) { - const SMDS_MeshElement* anElem = theItr->next(); - if ( thePred->IsSatisfy( anElem->GetID() ) ) - theRes[ anElem->GetEntityType() ]++; - } -} - //============================================================================= /*! - * \brief Returns statistic of mesh elements + * \brief Returns number of mesh elements per each \a EntityType */ //============================================================================= + SMESH::long_array* ::Filter_i::GetMeshInfo() { SMESH::long_array_var aRes = new SMESH::long_array(); aRes->length(SMESH::Entity_Last); - for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++) + for (int i = 0; i < SMESH::Entity_Last; i++) aRes[i] = 0; - if(!CORBA::is_nil(myMesh) && myPredicate) { - const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); - SMDS_ElemIteratorPtr it; - switch( GetElementType() ) + if ( !CORBA::is_nil(myMesh) && myPredicate ) + { + const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); + SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() )); + while ( it->more() ) { - case SMDSAbs_Node: - collectMeshInfo(aMesh->nodesIterator(),myPredicate,aRes); - break; - case SMDSAbs_Edge: - collectMeshInfo(aMesh->edgesIterator(),myPredicate,aRes); - break; - case SMDSAbs_Face: - collectMeshInfo(aMesh->facesIterator(),myPredicate,aRes); - break; - case SMDSAbs_Volume: - collectMeshInfo(aMesh->volumesIterator(),myPredicate,aRes); - break; - case SMDSAbs_All: - default: - collectMeshInfo(aMesh->elementsIterator(),myPredicate,aRes); - break; + const SMDS_MeshElement* anElem = it->next(); + if ( myPredicate->IsSatisfy( anElem->GetID() ) ) + aRes[ anElem->GetEntityType() ]++; } } return aRes._retn(); } +//============================================================================= +/*! + * \brief Returns number of mesh elements of each \a ElementType + */ +//============================================================================= + +SMESH::long_array* ::Filter_i::GetNbElementsByType() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::NB_ELEMENT_TYPES); + for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++) + aRes[i] = 0; + + if ( !CORBA::is_nil(myMesh) && myPredicate ) { + const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); + SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() )); + CORBA::Long& nbElems = aRes[ GetElementType() ]; + while ( it->more() ) + { + const SMDS_MeshElement* anElem = it->next(); + if ( myPredicate->IsSatisfy( anElem->GetID() ) ) + nbElems++; + } + } + + return aRes._retn(); +} + + //================================================================================ /*! * \brief Return GetElementType() within an array diff --git a/src/SMESH_I/SMESH_Filter_i.hxx b/src/SMESH_I/SMESH_Filter_i.hxx index fa9436722..b6036a13d 100644 --- a/src/SMESH_I/SMESH_Filter_i.hxx +++ b/src/SMESH_I/SMESH_Filter_i.hxx @@ -162,7 +162,11 @@ namespace SMESH { public: CORBA::Double GetValue( CORBA::Long theElementId ); - SMESH::Histogram* GetHistogram(CORBA::Short nbIntervals, CORBA::Boolean isLogarithmic); + SMESH::Histogram* GetHistogram(CORBA::Short nbIntervals, + CORBA::Boolean isLogarithmic); + SMESH::Histogram* GetLocalHistogram(CORBA::Short nbIntervals, + CORBA::Boolean isLogarithmic, + SMESH::SMESH_IDSource_ptr object); void SetPrecision( CORBA::Long thePrecision ); CORBA::Long GetPrecision(); Controls::NumericalFunctorPtr GetNumericalFunctor(); @@ -383,6 +387,7 @@ namespace SMESH { public: CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); + CORBA::Long NbSatisfying( SMESH::SMESH_IDSource_ptr obj ); Controls::PredicatePtr GetPredicate(); protected: @@ -1029,6 +1034,7 @@ namespace SMESH // ========================= virtual SMESH::long_array* GetIDs(); virtual SMESH::long_array* GetMeshInfo(); + virtual SMESH::long_array* GetNbElementsByType(); virtual SMESH::array_of_ElementType* GetTypes(); virtual SMESH::SMESH_Mesh_ptr GetMesh(); virtual bool IsMeshInfoCorrect() { return true; } diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 82428ef94..f393b918c 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -67,6 +67,12 @@ #include "SMESH_Gen_i.hxx" #include "SMESH_version.h" +#include "DriverMED_W_SMESHDS_Mesh.h" +#include "DriverMED_R_SMESHDS_Mesh.h" +#ifdef WITH_CGNS +#include "DriverCGNS_Read.hxx" +#endif +#include "MED_Factory.hxx" #include "SMDS_EdgePosition.hxx" #include "SMDS_FacePosition.hxx" #include "SMDS_PolyhedralVolumeOfNodes.hxx" @@ -87,17 +93,12 @@ #include "SMESH_Mesh_i.hxx" #include "SMESH_PreMeshInfo.hxx" #include "SMESH_PythonDump.hxx" +#include "memoire.h" #include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(SMESH_Filter) #include CORBA_SERVER_HEADER(SMESH_MeshEditor) -#include "DriverMED_W_SMESHDS_Mesh.h" -#include "DriverMED_R_SMESHDS_Mesh.h" -#ifdef WITH_CGNS -#include "DriverCGNS_Read.hxx" -#endif -#include "memoire.h" #include @@ -473,7 +474,8 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName // activate the CORBA servant of hypothesis hypothesis_i = SMESH::SMESH_Hypothesis::_narrow( myHypothesis_i->_this() ); int nextId = RegisterObject( hypothesis_i ); - if(MYDEBUG) MESSAGE( "Add hypo to map with id = "<< nextId ); + if(MYDEBUG) { MESSAGE( "Add hypo to map with id = "<< nextId ); } + else { nextId = 0; } // avoid "unused variable" warning in release mode return hypothesis_i._retn(); } @@ -502,7 +504,8 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh() // activate the CORBA servant of Mesh SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() ); int nextId = RegisterObject( mesh ); - if(MYDEBUG) MESSAGE( "Add mesh to map with id = "<< nextId); + if(MYDEBUG) { MESSAGE( "Add mesh to map with id = "<< nextId); } + else { nextId = 0; } // avoid "unused variable" warning in release mode return mesh._retn(); } catch (SALOME_Exception& S_ex) { @@ -1830,7 +1833,7 @@ SMESH::MeshPreviewStruct* SMESH_Gen_i::Precompute( SMESH::SMESH_Mesh_ptr theMesh ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); TSetOfInt shapeIds; ::MeshDimension aDim = (MeshDimension)theDimension; - if ( myGen.Compute( myLocMesh, myLocShape, false, aDim, &shapeIds ) ) + if ( myGen.Compute( myLocMesh, myLocShape, false, false, aDim, &shapeIds ) ) { int nbShapeId = shapeIds.size(); theShapesId.length( nbShapeId ); @@ -4787,6 +4790,18 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, } pd << ""; // prevent optimizing pd out + // creation of tree nodes for all data objects in the study + // to support tree representation customization and drag-n-drop: + SALOMEDS::UseCaseBuilder_var useCaseBuilder = theComponent->GetStudy()->GetUseCaseBuilder(); + if ( !useCaseBuilder->IsUseCaseNode( theComponent ) ) { + useCaseBuilder->SetRootCurrent(); + useCaseBuilder->Append( theComponent ); // component object is added as the top level item + SALOMEDS::ChildIterator_var it = theComponent->GetStudy()->NewChildIterator( theComponent ); + for (it->InitEx(true); it->More(); it->Next()) { + useCaseBuilder->AppendTo( it->Value()->GetFather(), it->Value() ); + } + } + INFOS( "SMESH_Gen_i::Load completed" ); return true; } @@ -4994,6 +5009,46 @@ char* SMESH_Gen_i::getVersion() #endif } +//================================================================================= +// function : Move() +// purpose : Moves objects to the specified position. +// Is used in the drag-n-drop functionality. +//================================================================================= +void SMESH_Gen_i::Move( const SMESH::sobject_list& what, + SALOMEDS::SObject_ptr where, + CORBA::Long row ) +{ + if ( CORBA::is_nil( where ) ) return; + + SALOMEDS::Study_var study = where->GetStudy(); + SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder(); + SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder(); + SALOMEDS::SComponent_var father = where->GetFatherComponent(); + std::string dataType = father->ComponentDataType(); + if ( dataType != "SMESH" ) return; // not a SMESH component + + SALOMEDS::SObject_var objAfter; + if ( row >= 0 && useCaseBuilder->HasChildren( where ) ) { + // insert at given row -> find insertion position + SALOMEDS::UseCaseIterator_var useCaseIt = useCaseBuilder->GetUseCaseIterator( where ); + int i; + for ( i = 0; i < row && useCaseIt->More(); i++, useCaseIt->Next() ); + if ( i == row && useCaseIt->More() ) { + objAfter = useCaseIt->Value(); + } + } + + for ( int i = 0; i < what.length(); i++ ) { + SALOMEDS::SObject_var sobj = what[i]; + if ( CORBA::is_nil( sobj ) ) continue; // skip bad object + // insert the object to the use case tree + if ( !CORBA::is_nil( objAfter ) ) + useCaseBuilder->InsertBefore( sobj, objAfter ); // insert at given row + else + useCaseBuilder->AppendTo( where, sobj ); // append to the end of list + } +} + //============================================================================= /*! * SMESHEngine_factory diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index bbd544fab..403fb7ee5 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -585,6 +585,11 @@ public: const std::string & GetLastObjEntry() const { return myLastObj; } std::vector< std::string > GetAllParameters(const std::string& theObjectEntry) const; + // Move objects to the specified position + void Move( const SMESH::sobject_list& what, + SALOMEDS::SObject_ptr where, + CORBA::Long row ); + private: // Create hypothesis of given type SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName, diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index 4ac7ad8d3..fc50bc409 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -261,6 +261,7 @@ static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr theStudy, { SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( theStudy, theIOR ); SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + SALOMEDS::UseCaseBuilder_var useCaseBuilder = theStudy->GetUseCaseBuilder(); if ( SO->_is_nil() ) { if ( theTag == 0 ) SO = aStudyBuilder->NewObject( theFatherObject ); @@ -286,6 +287,10 @@ static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr theStudy, selAttr->SetSelectable( false ); } + // add object to the use case tree + // (to support tree representation customization and drag-n-drop) + useCaseBuilder->AppendTo( SO->GetFather(), SO ); + return SO._retn(); } @@ -377,6 +382,9 @@ static void addReference (SALOMEDS::Study_ptr theStudy, if ( !theSObject->FindSubObject( theTag, aReferenceSO.inout() )) aReferenceSO = aStudyBuilder->NewObjectToTag( theSObject, theTag ); aStudyBuilder->Addreference( aReferenceSO, aToObjSO ); + // add reference to the use case tree + // (to support tree representation customization and drag-n-drop) + theStudy->GetUseCaseBuilder()->AppendTo( aReferenceSO->GetFather(), aReferenceSO ); } } @@ -456,6 +464,7 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent(SALOMEDS::Study_ptr theSt return father._retn(); SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + SALOMEDS::UseCaseBuilder_var useCaseBuilder = theStudy->GetUseCaseBuilder(); SALOMEDS::GenericAttribute_wrap anAttr; SALOMEDS::AttributePixMap_wrap aPixmap; @@ -466,6 +475,10 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent(SALOMEDS::Study_ptr theSt aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" ); CORBA::String_var userName = aComp->componentusername(); SetName( father, userName.in(), "MESH" ); + // add component to the use case tree + // (to support tree representation customization and drag-n-drop) + useCaseBuilder->SetRootCurrent(); + useCaseBuilder->Append( father ); // component object is added as the top level item if(MYDEBUG) MESSAGE("PublishComponent--END"); return father._retn(); diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 20da6c040..d5c06b37c 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -677,9 +677,9 @@ void SMESH_GroupBase_i::SetColorNumber(CORBA::Long color) } //============================================================================= -/*! - * Returns statistic of mesh elements - * Result array of number enityties +/* + * Returns number of mesh elements of each \a SMESH::EntityType + * Result array of number of elements per \a SMESH::EntityType * Inherited from SMESH_IDSource */ //============================================================================= @@ -706,6 +706,27 @@ SMESH::long_array* SMESH_GroupBase_i::GetMeshInfo() return aRes._retn(); } +//============================================================================= +/* + * Returns number of mesh elements of each \a ElementType + */ +//============================================================================= + +SMESH::long_array* SMESH_GroupBase_i::GetNbElementsByType() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::NB_ELEMENT_TYPES); + for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++) + aRes[ i ] = 0; + + if ( myPreMeshInfo ) + aRes[ GetType() ] = myPreMeshInfo->NbElements( SMDSAbs_ElementType( GetType() )); + else + aRes[ GetType() ] = Size(); + + return aRes._retn(); +} + //======================================================================= //function : GetIDs //purpose : Returns ids of members diff --git a/src/SMESH_I/SMESH_Group_i.hxx b/src/SMESH_I/SMESH_Group_i.hxx index ad4522a0a..152abd53c 100644 --- a/src/SMESH_I/SMESH_Group_i.hxx +++ b/src/SMESH_I/SMESH_Group_i.hxx @@ -72,15 +72,19 @@ class SMESH_I_EXPORT SMESH_GroupBase_i: virtual SMESH::SMESH_Mesh_ptr GetMesh(); /*! - * Returns statistic of mesh elements - * Result array of number enityties + * Returns number of mesh elements of each \a EntityType + * Result array of number of elements per \a EntityType * Inherited from SMESH_IDSource */ virtual SMESH::long_array* GetMeshInfo(); - - // Inherited from SMESH_IDSource interface + /*! + * Returns number of mesh elements of each \a ElementType + */ + virtual SMESH::long_array* GetNbElementsByType(); + /*! + * Returns a sequence of all element IDs + */ virtual SMESH::long_array* GetIDs(); - /*! * Returns types of elements it contains * Inherited from SMESH_IDSource interface diff --git a/src/SMESH_I/SMESH_MEDFamily_i.cxx b/src/SMESH_I/SMESH_MEDFamily_i.cxx deleted file mode 100644 index ada90fd74..000000000 --- a/src/SMESH_I/SMESH_MEDFamily_i.cxx +++ /dev/null @@ -1,301 +0,0 @@ -// 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 -// - -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses -// File : SMESH_MEDFamily_i.cxx -// Module : SMESH -// -#include "SMESH_MEDFamily_i.hxx" -#include "utilities.h" -#include "Utils_CorbaException.hxx" - -using namespace std; - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -SMESH_MEDFamily_i::SMESH_MEDFamily_i() -{ - BEGIN_OF("Default Constructor SMESH_MEDFamily_i"); - END_OF("Default Constructor SMESH_MEDFamily_i"); -} -//============================================================================= -/*! - * constructor par recopie - */ -//============================================================================= -SMESH_MEDFamily_i::SMESH_MEDFamily_i(const SMESH_MEDFamily_i & f): - SMESH_MEDSupport_i(f._subMesh_i,f._name,f._description,f._entity), - _subMesh_i(f._subMesh_i), - _identifier(f._identifier), - _numberOfAttribute(f._numberOfAttribute), - _numberOfGroup(f._numberOfGroup), - _attributeValue(f._attributeValue) -{ - BEGIN_OF("Copy Constructor SMESH_MEDFamily_i"); - _attributeDescription=new string[_numberOfAttribute]; - for (int i=0;i<_numberOfAttribute;i++) { - _attributeDescription[i]=f._attributeDescription[i]; - }; - _groupName=new string[_numberOfGroup]; - for (int i=0;i<_numberOfAttribute;i++) { - _groupName[i]=f._groupName[i]; - }; - END_OF("Copy Constructor SMESH_MEDFamily_i"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -SMESH_MEDFamily_i::~SMESH_MEDFamily_i() -{ -} -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -SMESH_MEDFamily_i::SMESH_MEDFamily_i(int identifier, SMESH_subMesh_i* sm, - string name, string description, SALOME_MED::medEntityMesh entity): - SMESH_MEDSupport_i( sm, name, description, entity ), - - _subMesh_i(sm), - _identifier(identifier), - _numberOfAttribute(0), - _attributeIdentifier((int*)NULL), - _attributeValue((int*)NULL), - _attributeDescription((string*)NULL), - _numberOfGroup(0), - _groupName((string*)NULL) -{ - BEGIN_OF("Constructor SMESH_MEDFamily_i"); - END_OF("Constructor SMESH_MEDFamily_i"); -} -//============================================================================= -/*! - * CORBA: Accessor for Family's Identifier - */ -//============================================================================= - -CORBA::Long SMESH_MEDFamily_i::getIdentifier() -throw (SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - return _identifier; - -} -//============================================================================= -/*! - * CORBA: Accessor for number of attributes - */ -//============================================================================= -CORBA::Long SMESH_MEDFamily_i::getNumberOfAttributes() -throw (SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - return _numberOfAttribute; -} -//============================================================================= -/*! - * CORBA: Accessor for attributes identifiers - */ -//============================================================================= -SALOME_TYPES::ListOfLong* SMESH_MEDFamily_i::getAttributesIdentifiers() -throw (SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - if (_numberOfAttribute == 0) - { - MESSAGE("Les familles SMESH n ont pas d attribut"); - THROW_SALOME_CORBA_EXCEPTION("No attributes"\ - ,SALOME::BAD_PARAM); - }; - - SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong; - myseq->length(_numberOfAttribute); - for (int i=0;i<_numberOfAttribute;i++) - { - myseq[i]=_attributeIdentifier[i]; - }; - return myseq._retn(); - -} -//============================================================================= -/*! - * CORBA: Accessor for attribute identifier I - */ -//============================================================================= -CORBA::Long SMESH_MEDFamily_i::getAttributeIdentifier(CORBA::Long i) - throw (SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - MESSAGE("Les familles SMESH n ont pas d attribut"); - THROW_SALOME_CORBA_EXCEPTION("No attributes"\ - ,SALOME::BAD_PARAM); - if (_numberOfAttribute == 0) - { - MESSAGE("Les familles SMESH n ont pas d attribut"); - THROW_SALOME_CORBA_EXCEPTION("No attributes"\ - ,SALOME::BAD_PARAM); - }; - ASSERT (i <= _numberOfAttribute); - return _attributeIdentifier[i]; -} -//============================================================================= -/*! - * CORBA: Accessor for attributes values - */ -//============================================================================= -SALOME_TYPES::ListOfLong* SMESH_MEDFamily_i::getAttributesValues() - throw (SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - - if (_numberOfAttribute == 0) - { - MESSAGE("Les familles SMESH n ont pas d attribut"); - THROW_SALOME_CORBA_EXCEPTION("No attributes"\ - ,SALOME::BAD_PARAM); - }; - - SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong; - myseq->length(_numberOfAttribute); - for (int i=0;i<_numberOfAttribute;i++) - { - myseq[i]=_attributeValue[i]; - }; - return myseq._retn(); -} -//============================================================================= -/*! - * CORBA: Accessor for attribute value I - */ -//============================================================================= -CORBA::Long SMESH_MEDFamily_i::getAttributeValue(CORBA::Long i) - throw (SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - if (_numberOfAttribute == 0) - { - MESSAGE("Les familles SMESH n ont pas d attribut"); - THROW_SALOME_CORBA_EXCEPTION("No attributes"\ - ,SALOME::BAD_PARAM); - } - - ASSERT (i <= _numberOfAttribute); - return _attributeValue[i]; -} -//============================================================================= -/*! - * CORBA: Accessor for attributes desriptions - */ -//============================================================================= -SALOME_TYPES::ListOfString * SMESH_MEDFamily_i::getAttributesDescriptions() - throw (SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - if (_numberOfAttribute == 0) - { - MESSAGE("Les familles SMESH n ont pas d attribut"); - THROW_SALOME_CORBA_EXCEPTION("No attributes"\ - ,SALOME::BAD_PARAM); - } - SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString; - for (int i=0;i<_numberOfAttribute;i++) - { - myseq[i]=CORBA::string_dup(_attributeDescription[i].c_str()); - } - return myseq._retn(); -} -//============================================================================= -/*! - * CORBA: Accessor for attribute description i - */ -//============================================================================= -char * SMESH_MEDFamily_i::getAttributeDescription( CORBA::Long i) - throw (SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - if (_numberOfAttribute == 0) - { - MESSAGE("Les familles SMESH n ont pas d attribut"); - THROW_SALOME_CORBA_EXCEPTION("No attributes"\ - ,SALOME::BAD_PARAM); - } - ASSERT (i <= _numberOfAttribute); - return CORBA::string_dup(_attributeDescription[i].c_str()); -} -//============================================================================= -/*! - * CORBA: Accessor for the number of groups - */ -//============================================================================= -CORBA::Long SMESH_MEDFamily_i::getNumberOfGroups() - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!! NOT YET IMPLEMENTED !!!!"); - THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM); - return 0; -} -//============================================================================= -/*! - * CORBA: Accessor for the name of the group i - */ -//============================================================================= -char * SMESH_MEDFamily_i::getGroupName( CORBA::Long i) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!! NOT YET IMPLEMENTED !!!!"); - THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM); - return NULL; -} -//============================================================================= -/*! - * CORBA: Accessor for all the groups name - */ -//============================================================================= -SALOME_TYPES::ListOfString* SMESH_MEDFamily_i::getGroupsNames() - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!! NOT YET IMPLEMENTED !!!!"); - THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM); - return NULL; -} diff --git a/src/SMESH_I/SMESH_MEDFamily_i.hxx b/src/SMESH_I/SMESH_MEDFamily_i.hxx deleted file mode 100644 index f4ec0749f..000000000 --- a/src/SMESH_I/SMESH_MEDFamily_i.hxx +++ /dev/null @@ -1,92 +0,0 @@ -// 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 -// - -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses -// File : SMESH_MEDFamily_i.hxx -// Module : SMESH -// -#ifndef SMESH_MED_FAMILY_I_HXX_ -#define SMESH_MED_FAMILY_I_HXX_ - -#include "SMESH.hxx" - -#include "SMESH_MEDSupport_i.hxx" - -#include - -class SMESH_I_EXPORT SMESH_MEDFamily_i: - public virtual POA_SALOME_MED::FAMILY, - public virtual SMESH_MEDSupport_i -{ -protected : - SMESH_MEDFamily_i(); - ~SMESH_MEDFamily_i(); - - ::SMESH_subMesh_i* _subMesh_i; - - // Values - int _identifier; - int _numberOfAttribute; - int * _attributeIdentifier; - int * _attributeValue; - std::string * _attributeDescription; - int _numberOfGroup ; - std::string * _groupName ; - - -public : - - // Constructors and associated internal methods - SMESH_MEDFamily_i(int identifier, SMESH_subMesh_i* sm, - std::string name, std::string description, SALOME_MED::medEntityMesh entity ); - SMESH_MEDFamily_i(const SMESH_MEDFamily_i & f); - - // IDL Methods - void setProtocol(SALOME::TypeOfCommunication typ) {} - void release() {} - SALOME::SenderInt_ptr getSenderForNumber(SALOME_MED::medGeometryElement) {return SALOME::SenderInt::_nil();} - SALOME::SenderInt_ptr getSenderForNumberIndex() {return SALOME::SenderInt::_nil();} - - CORBA::Long getIdentifier() - throw (SALOME::SALOME_Exception); - CORBA::Long getNumberOfAttributes() - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfLong* getAttributesIdentifiers() - throw (SALOME::SALOME_Exception); - CORBA::Long getAttributeIdentifier(CORBA::Long i) - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfLong* getAttributesValues() - throw (SALOME::SALOME_Exception); - CORBA::Long getAttributeValue(CORBA::Long i) - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfString* getAttributesDescriptions() - throw (SALOME::SALOME_Exception); - char* getAttributeDescription( CORBA::Long i) - throw (SALOME::SALOME_Exception); - CORBA::Long getNumberOfGroups() - throw (SALOME::SALOME_Exception); - char * getGroupName( CORBA::Long i) - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfString* getGroupsNames() - throw (SALOME::SALOME_Exception); -}; -#endif /* MED_FAMILY_I_HXX_ */ diff --git a/src/SMESH_I/SMESH_MEDMesh_i.cxx b/src/SMESH_I/SMESH_MEDMesh_i.cxx deleted file mode 100644 index f338dfeac..000000000 --- a/src/SMESH_I/SMESH_MEDMesh_i.cxx +++ /dev/null @@ -1,1210 +0,0 @@ -// 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 -// - -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses -// File : SMESH_MEDMesh_i.cxx -// Module : SMESH -// -#include "SMESH_MEDMesh_i.hxx" -#include "SMESH_Gen_i.hxx" -#include "SMESH_Mesh_i.hxx" - -#include "SMESHDS_Mesh.hxx" -#include "SMESHDS_SubMesh.hxx" - -#include "SMESH_MEDSupport_i.hxx" -#include "SMESH_MEDFamily_i.hxx" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -extern "C" -{ -#include -} - -using namespace std; - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -// PN Est-ce un const ? -SMESH_MEDMesh_i::SMESH_MEDMesh_i() -{ - BEGIN_OF("Default Constructor SMESH_MEDMesh_i"); - END_OF("Default Constructor SMESH_MEDMesh_i"); -} - -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -SMESH_MEDMesh_i::~SMESH_MEDMesh_i() -{ -} - -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -SMESH_MEDMesh_i::SMESH_MEDMesh_i(::SMESH_Mesh_i * m_i):_meshId(""), - _compte(false), - _creeFamily(false), - _famIdent(0), - _indexElts(0), - _indexEnts(0) -{ - BEGIN_OF("Constructor SMESH_MEDMesh_i"); - - _mesh_i = m_i; - _meshDS = _mesh_i->GetImpl().GetMeshDS(); - - END_OF("Constructor SMESH_MEDMesh_i"); -} - -//============================================================================= -/*! - * CORBA: Accessor for Name - */ -//============================================================================= -char *SMESH_MEDMesh_i::getName() throw(SALOME::SALOME_Exception) -{ - if (_meshDS == NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - - try - { - SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen(); - SALOMEDS::Study_var study = gen->GetCurrentStudy(); - SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( study, _mesh_i->_this()); - if ( meshSO->_is_nil() ) - return CORBA::string_dup("toto"); - - CORBA::String_var name = meshSO->GetName(); - - return CORBA::string_dup( name.in() ); - } - catch(...) - { - MESSAGE("Exception en accedant au nom"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object", - SALOME::INTERNAL_ERROR); - } - return 0; -} - -//============================================================================= -/*! - * CORBA: Accessor for corbaindex cuisine interne - */ -//============================================================================= -CORBA::Long SMESH_MEDMesh_i::getCorbaIndex()throw(SALOME::SALOME_Exception) -{ - MESSAGE("Non Implemente"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); -} - -//============================================================================= -/*! - * CORBA: Accessor for Space Dimension - */ -//============================================================================= -CORBA::Long SMESH_MEDMesh_i::getSpaceDimension()throw(SALOME::SALOME_Exception) -{ - // PN : Il semblerait que la dimension soit fixee a 3 - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - return 3; -} - -//============================================================================= -/*! - * CORBA: Accessor for Mesh Dimension - */ -//============================================================================= -CORBA::Long SMESH_MEDMesh_i::getMeshDimension()throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - // PN : Il semblerait que la dimension soit fixee a 3 - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - return 3; -} -//============================================================================= -/*! - * CORBA: Accessor for the boolean _isAGrid - */ -//============================================================================= -CORBA::Boolean SMESH_MEDMesh_i::getIsAGrid() throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!!!! NOT YET IMPLEMENTED !!!!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return false; -} -//============================================================================= -/*! - * CORBA: Accessor for the connectivities, to see if they exist - */ -//============================================================================= -CORBA::Boolean -SMESH_MEDMesh_i::existConnectivity(SALOME_MED::medConnectivity connectivityType, - SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!!!! IMPLEMENTED BUT ONLY PARTIALLY !!!!!!"); - - - return false; - -} -//============================================================================= -/*! - * CORBA: Accessor for Coordinate - */ -//============================================================================= -CORBA::Double SMESH_MEDMesh_i::getCoordinate(CORBA::Long Number, CORBA::Long Axis) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!!!! NOT YET IMPLEMENTED !!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return 0.0; -} -//============================================================================= -/*! - * CORBA: Accessor for Coordinates System - */ -//============================================================================= -char *SMESH_MEDMesh_i::getCoordinatesSystem() throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - // PN : En dur. Non encore prevu - try - { - string systcoo = "CARTESIEN"; - return CORBA::string_dup(systcoo.c_str()); - } - catch(...) - { - MESSAGE("Exception en accedant au maillage"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object", - SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for Coordinates - */ -//============================================================================= -SALOME_TYPES::ListOfDouble * SMESH_MEDMesh_i::getCoordinates -(SALOME_MED::medModeSwitch typeSwitch) throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfDouble_var myseq = new SALOME_TYPES::ListOfDouble; - try - { - // PN : En dur - int spaceDimension = 3; - int nbNodes = _meshDS->NbNodes(); - SCRUTE(nbNodes); - myseq->length(nbNodes * spaceDimension); - int i = 0; - - SMDS_NodeIteratorPtr itNodes=_meshDS->nodesIterator(); - while(itNodes->more()) - { - const SMDS_MeshNode* node = itNodes->next(); - - if (typeSwitch == SALOME_MED::MED_FULL_INTERLACE) - { - myseq[i * 3] = node->X(); - myseq[i * 3 + 1] = node->Y(); - myseq[i * 3 + 2] = node->Z(); - SCRUTE(myseq[i * 3]); - SCRUTE(myseq[i * 3 + 1]); - SCRUTE(myseq[i * 3 + 2]); - } - else - { - ASSERT(typeSwitch == SALOME_MED::MED_NO_INTERLACE); - myseq[i] = node->X(); - myseq[i + nbNodes] = node->Y(); - myseq[i + (nbNodes * 2)] = node->Z(); - SCRUTE(myseq[i]); - SCRUTE(myseq[i + nbNodes]); - SCRUTE(myseq[i + (nbNodes * 2)]); - } - i++; - } - } - catch(...) - { - MESSAGE("Exception en accedant aux coordonnees"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object", - SALOME::INTERNAL_ERROR); - } - return myseq._retn(); -} - -//============================================================================= -/*! - * CORBA: Accessor for Coordinates Names - */ -//============================================================================= -SALOME_TYPES::ListOfString * -SMESH_MEDMesh_i::getCoordinatesNames()throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString; - try - { - // PN : en dur - int spaceDimension = 3; - myseq->length(spaceDimension); - myseq[0] = CORBA::string_dup("x"); - myseq[1] = CORBA::string_dup("y"); - myseq[2] = CORBA::string_dup("z"); - } - catch(...) - { - MESSAGE("Exception en accedant aux noms des coordonnees"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object", - SALOME::INTERNAL_ERROR); - } - return myseq._retn(); - -} - -//============================================================================= -/*! - * CORBA: Accessor for Coordinates Units - */ -//============================================================================= -SALOME_TYPES::ListOfString * -SMESH_MEDMesh_i::getCoordinatesUnits()throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString; - try - { - // PN : en dur - int spaceDimension = 3; - myseq->length(spaceDimension); - myseq[0] = CORBA::string_dup("m"); - myseq[1] = CORBA::string_dup("m"); - myseq[2] = CORBA::string_dup("m"); - } - catch(...) - { - MESSAGE("Exception en accedant aux unites des coordonnees"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object", - SALOME::INTERNAL_ERROR); - } - return myseq._retn(); -} - -//============================================================================= -/*! - * CORBA: Accessor for Number of Nodes - */ -//============================================================================= -CORBA::Long SMESH_MEDMesh_i::getNumberOfNodes()throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - try - { - return _meshDS->NbNodes(); - } - catch(...) - { - MESSAGE("Exception en accedant au nombre de noeuds"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object", - SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for number of Types - */ -//============================================================================= -CORBA::Long SMESH_MEDMesh_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity) - throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - try - { - if (!_compte) - calculeNbElts(); - int retour = 0; - if (_mapNbTypes.find(entity) != _mapNbTypes.end()) - retour = _mapNbTypes[entity]; - return retour; - } - catch(...) - { - MESSAGE("Exception en accedant au nombre de Types"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object", - SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for existing geometry element types - * Not implemented for MED_ALL_ENTITIES - */ -//============================================================================= -SALOME_MED::medGeometryElement_array * -SMESH_MEDMesh_i::getTypes(SALOME_MED::medEntityMesh entity) throw(SALOME:: - SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - if (entity == SALOME_MED::MED_ALL_ENTITIES) - THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES", - SALOME::BAD_PARAM); - if (!_compte) - calculeNbElts(); - SALOME_MED::medGeometryElement_array_var myseq = - new SALOME_MED::medGeometryElement_array; - try - { - if (_mapNbTypes.find(entity) == _mapNbTypes.end()) - THROW_SALOME_CORBA_EXCEPTION("No Such Entity in the mesh", - SALOME::BAD_PARAM); - int nbTypes = _mapNbTypes[entity]; - - myseq->length(nbTypes); - - if (_mapIndToVectTypes.find(entity) == _mapIndToVectTypes.end()) - THROW_SALOME_CORBA_EXCEPTION("No Such Entity in the mesh", - SALOME::INTERNAL_ERROR); - - int index = _mapIndToVectTypes[entity]; - ASSERT(_TypesId[index].size() != 0); - int i = 0; - vector < SALOME_MED::medGeometryElement >::iterator it; - for (it = _TypesId[index].begin(); it != _TypesId[index].end(); it++) - { - myseq[i++] = *it; - }; - } - catch(...) - { - MESSAGE("Exception en accedant aux differents types"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object", - SALOME::INTERNAL_ERROR); - } - return myseq._retn(); -} - -//============================================================================= -/*! - * CORBA: Returns number of elements of type medGeometryElement - * Not implemented for MED_ALL_ELEMENTS - * implemented for MED_ALL_ENTITIES - * - * Dans cette implementation, il n est pas prevu de tenir compte du entity - * qui ne doit pas pouvoir avoir deux valeurs differentes pour un geomElement - */ -//============================================================================= -CORBA::Long SMESH_MEDMesh_i::getNumberOfElements(SALOME_MED:: - medEntityMesh entity, - SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - if (geomElement == SALOME_MED::MED_ALL_ELEMENTS) - THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ELEMENTS", - SALOME::BAD_PARAM); - if (!_compte) - calculeNbElts(); - - try - { - int retour = 0; - if (_mapIndToSeqElts.find(geomElement) != _mapIndToSeqElts.end()) - { - int index = _mapIndToSeqElts[geomElement]; - - retour = _seq_elemId[index]->length(); - } - return retour; - } - catch(...) - { - MESSAGE("Exception en accedant au nombre d élements"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object", - SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for connectivities - */ -//============================================================================= -SALOME_TYPES::ListOfLong * -SMESH_MEDMesh_i::getConnectivity(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity, - SALOME_MED::medGeometryElement geomElement) - throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - if (mode != SALOME_MED::MED_NODAL) - THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM); - /*if (typeSwitch == SALOME_MED::MED_NO_INTERLACE) - THROW_SALOME_CORBA_EXCEPTION("Not Yet Implemented", SALOME::BAD_PARAM);*/ - if (!_compte) - calculeNbElts(); - - // Faut-il renvoyer un pointeur vide ??? - if (_mapIndToSeqElts.find(geomElement) != _mapIndToSeqElts.end()) - THROW_SALOME_CORBA_EXCEPTION("No Such Element in the mesh", - SALOME::BAD_PARAM); - - int index = _mapIndToSeqElts[geomElement]; - - return _seq_elemId[index]._retn(); -} - -//============================================================================= -/*! - * CORBA: Accessor for connectivities - */ -//============================================================================= -SALOME_TYPES::ListOfLong * -SMESH_MEDMesh_i::getConnectivityIndex(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity) - throw(SALOME::SALOME_Exception) -{ - MESSAGE("Pas Implemente dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return 0; -} - -//============================================================================= -/*! - * CORBA: Find an element corresponding to the given connectivity - */ -//============================================================================= -CORBA::Long -SMESH_MEDMesh_i::getElementNumber(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity, - SALOME_MED::medGeometryElement type, - const SALOME_TYPES::ListOfLong & connectivity) - throw(SALOME::SALOME_Exception) -{ - const char *LOC = "getElementNumber "; - MESSAGE(LOC << "Pas Implemente dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return -1; -} - -//============================================================================= -/*! - * CORBA: Accessor for Ascendant connectivities - * not implemented for MED_ALL_ENTITIES and MED_MAILLE - */ -//============================================================================= -SALOME_TYPES::ListOfLong * -SMESH_MEDMesh_i::getReverseConnectivity(SALOME_MED:: - medConnectivity mode) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Pas Implemente dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return 0; -} - -//============================================================================= -/*! - * CORBA: Accessor for connectivities - */ -//============================================================================= -SALOME_TYPES::ListOfLong * -SMESH_MEDMesh_i::getReverseConnectivityIndex(SALOME_MED:: - medConnectivity mode) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Pas Implemente dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return 0; -} - -//============================================================================= -/*! - * CORBA: Returns number of families within the mesh - */ -//============================================================================= -CORBA::Long SMESH_MEDMesh_i::getNumberOfFamilies(SALOME_MED:: - medEntityMesh entity) throw(SALOME::SALOME_Exception) -{ - if (_creeFamily == false) - createFamilies(); - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - return _families.size(); -} - -//============================================================================= -/*! - * CORBA: Returns number of groups within the mesh - */ -//============================================================================= -CORBA::Long SMESH_MEDMesh_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity) - throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - MESSAGE(" Pas d implementation des groupes dans SMESH"); - return 0; -} - -//============================================================================= -/*! - * CORBA: Returns references for families within the mesh - */ -//============================================================================= -SALOME_MED::Family_array * -SMESH_MEDMesh_i::getFamilies(SALOME_MED:: - medEntityMesh entity) throw(SALOME::SALOME_Exception) -{ - if (_creeFamily == false) - createFamilies(); - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array; - int nbfam = _families.size(); - myseq->length(nbfam); - int i = 0; - vector < SALOME_MED::FAMILY_ptr >::iterator it; - for (it = _families.begin(); it != _families.end(); it++) - { - myseq[i++] = *it; - }; - return myseq._retn(); -} - -//============================================================================= -/*! - * CORBA: Returns references for family i within the mesh - */ -//============================================================================= -SALOME_MED::FAMILY_ptr SMESH_MEDMesh_i::getFamily(SALOME_MED:: - medEntityMesh entity, CORBA::Long i) throw(SALOME::SALOME_Exception) -{ - if (_creeFamily == false) - createFamilies(); - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - - SCRUTE(_families[i]->getName()); - MESSAGE(" SMESH_MEDMesh_i::getFamily " << i) return _families[i]; -} - -//============================================================================= -/*! - * CORBA: Returns references for groups within the mesh - */ -//============================================================================= -SALOME_MED::Group_array * -SMESH_MEDMesh_i::getGroups(SALOME_MED::medEntityMesh entity) throw(SALOME:: - SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - MESSAGE(" Pas d implementation des groupes dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("No group implementation", SALOME::BAD_PARAM); -} - -//============================================================================= -/*! - * CORBA: Returns references for group i within the mesh - */ -//============================================================================= -SALOME_MED::GROUP_ptr SMESH_MEDMesh_i::getGroup(SALOME_MED:: - medEntityMesh entity, CORBA::Long i) throw(SALOME::SALOME_Exception) -{ - if (_mesh_i == 0) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - MESSAGE(" Pas d implementation des groupes dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("No group implementation", SALOME::BAD_PARAM); -} -//============================================================================= -/*! - * CORBA: Returns references for the global numbering index - */ -//============================================================================= -SALOME_TYPES::ListOfLong* -SMESH_MEDMesh_i::getGlobalNumberingIndex(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return NULL; -} -//============================================================================= -/*! - * CORBA: Returns references for the support of boundary elements of type - * entity - */ -//============================================================================= -SALOME_MED::SUPPORT_ptr -SMESH_MEDMesh_i::getBoundaryElements(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return NULL; -} -//============================================================================= -/*! - * CORBA: Method return a reference on a support define on all the element of - * an entity. - */ -//============================================================================= -SALOME_MED::SUPPORT_ptr -SMESH_MEDMesh_i::getSupportOnAll(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return NULL; -} -//============================================================================= -/*! - * CORBA: Returns references for the support of the skin of the support - * mySupport3D - */ -//============================================================================= -SALOME_MED::SUPPORT_ptr -SMESH_MEDMesh_i::getSkin(SALOME_MED::SUPPORT_ptr mySupport3D) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return NULL; -} -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getVolume(SALOME_MED:: - SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Pas Implemente dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return 0; -} - -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getArea(SALOME_MED:: - SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Pas Implemente dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return 0; -} - -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getLength(SALOME_MED:: - SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Pas Implemente dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return 0; -} - -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNormal(SALOME_MED:: - SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Pas Implemente dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return 0; -} - -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getBarycenter(SALOME_MED:: - SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Pas Implemente dans SMESH"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return 0; -} - -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNeighbourhood(SALOME_MED:: - SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Non Implemente"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return 0; -} - -//============================================================================= -/*! - * CORBA: add the Mesh in the StudyManager - * PN Pas Implemente - */ -//============================================================================= -void SMESH_MEDMesh_i::addInStudy(SALOMEDS::Study_ptr myStudy, - SALOME_MED::GMESH_ptr myIor) throw(SALOME::SALOME_Exception) -{ - BEGIN_OF("MED_Mesh_i::addInStudy"); - if (_meshId != "") - { - MESSAGE("Mesh already in Study"); - THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", SALOME::BAD_PARAM); - } - END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)"); -} - -//============================================================================= -/*! - * CORBA: write mesh in a med file - */ -//============================================================================= -void SMESH_MEDMesh_i::write(CORBA::Long i, const char *driverMeshName) - throw(SALOME::SALOME_Exception) -{ - MESSAGE("Non Implemente"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); -} - -//============================================================================= -/*! - * CORBA: read mesh in a med file - */ -//============================================================================= -void SMESH_MEDMesh_i::read(CORBA::Long i) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Non Implemente"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); -} - -//============================================================================= -/*! - * CORBA : release driver - */ -//============================================================================= -void SMESH_MEDMesh_i::rmDriver(CORBA::Long i) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Non Implemente"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); -} - -//============================================================================= -/*! - * CORBA : attach driver - */ -//============================================================================= -CORBA::Long SMESH_MEDMesh_i::addDriver(SALOME_MED::medDriverTypes driverType, - const char *fileName, const char *meshName) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Non Implemente"); - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - return 0; -} - -//============================================================================= -/*! - * Calcule le Nb d'elements par entite geometrique - */ -//============================================================================= -void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception) -{ - if (!_compte) - { - _compte = true; - - _mapNbTypes[SALOME_MED::MED_NODE] = 1; - // On compte les aretes MED_SEG2 ou MED_SEG3 - // On range les elements dans les vecteurs correspondants - - _mapIndToSeqElts[SALOME_MED::MED_SEG2] = _indexElts++; - _mapIndToSeqElts[SALOME_MED::MED_SEG3] = _indexElts++; - _mapIndToVectTypes[SALOME_MED::MED_EDGE] = _indexEnts++; - - int trouveSeg2 = 0; - int trouveSeg3 = 0; - SALOME_MED::medGeometryElement medElement; - - SMDS_EdgeIteratorPtr itEdges=_meshDS->edgesIterator(); - while(itEdges->more()) - { - const SMDS_MeshEdge* elem = itEdges->next(); - int nb_of_nodes = elem->NbNodes(); - - switch (nb_of_nodes) - { - case 2: - { - medElement = SALOME_MED::MED_SEG2; - if (trouveSeg2 == 0) - { - trouveSeg2 = 1; - _TypesId[SALOME_MED::MED_EDGE]. - push_back(SALOME_MED::MED_SEG2); - } - break; - } - case 3: - { - medElement = SALOME_MED::MED_SEG3; - if (trouveSeg3 == 0) - { - trouveSeg3 = 1; - _TypesId[SALOME_MED::MED_EDGE]. - push_back(SALOME_MED::MED_SEG3); - } - break; - } - } - int index = _mapIndToSeqElts[medElement]; - SCRUTE(index); - // Traitement de l arete - - int longueur = _seq_elemId[index]->length(); - _seq_elemId[index]->length(longueur + nb_of_nodes); - - SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator(); - - for(int k=0; itn->more(); k++) - _seq_elemId[index][longueur + k] = itn->next()->GetID()+1; - } - - _mapNbTypes[SALOME_MED::MED_EDGE] = trouveSeg2 + trouveSeg3; - - // On compte les faces MED_TRIA3, MED_HEXA8, MED_TRIA6 - // On range les elements dans les vecteurs correspondants - int trouveTria3 = 0; - int trouveTria6 = 0; - int trouveQuad4 = 0; - - _mapIndToSeqElts[SALOME_MED::MED_TRIA3] = _indexElts++; - _mapIndToSeqElts[SALOME_MED::MED_TRIA6] = _indexElts++; - _mapIndToSeqElts[SALOME_MED::MED_QUAD4] = _indexElts++; - _mapIndToVectTypes[SALOME_MED::MED_FACE] = _indexEnts++; - - SMDS_FaceIteratorPtr itFaces=_meshDS->facesIterator(); - while(itFaces->more()) - { - const SMDS_MeshFace * elem = itFaces->next(); - int nb_of_nodes = elem->NbNodes(); - - switch (nb_of_nodes) - { - case 3: - { - medElement = SALOME_MED::MED_TRIA3; - if (trouveTria3 == 0) - { - trouveTria3 = 1; - _TypesId[SALOME_MED::MED_FACE]. - push_back(SALOME_MED::MED_TRIA3); - } - break; - } - case 4: - { - medElement = SALOME_MED::MED_QUAD4; - if (trouveQuad4 == 0) - { - trouveQuad4 = 1; - _TypesId[SALOME_MED::MED_FACE]. - push_back(SALOME_MED::MED_QUAD4); - } - break; - } - case 6: - { - medElement = SALOME_MED::MED_TRIA6; - if (trouveTria6 == 0) - { - trouveTria6 = 1; - _TypesId[SALOME_MED::MED_FACE]. - push_back(SALOME_MED::MED_TRIA6); - } - break; - } - } - int index = _mapIndToSeqElts[medElement]; - SCRUTE(index); - - // Traitement de la face - // Attention La numérotation des noeuds Med commence a 1 - - int longueur = _seq_elemId[index]->length(); - _seq_elemId[index]->length(longueur + nb_of_nodes); - - SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator(); - - for(int k=0; itn->more(); k++) - _seq_elemId[index][longueur + k] = itn->next()->GetID()+1; - } //itFaces - - _mapNbTypes[SALOME_MED::MED_FACE] = - trouveTria3 + trouveTria6 + trouveQuad4; - - _mapIndToSeqElts[SALOME_MED::MED_HEXA8] = _indexElts++; - _mapIndToVectTypes[SALOME_MED::MED_CELL] = _indexEnts++; - int index = _mapIndToSeqElts[medElement]; - - int trouveHexa8 = 0; - - SMDS_VolumeIteratorPtr itVolumes=_meshDS->volumesIterator(); - while(itVolumes->more()) - { - const SMDS_MeshVolume * elem = itVolumes->next(); - - int nb_of_nodes = elem->NbNodes(); - medElement = SALOME_MED::MED_HEXA8; - ASSERT(nb_of_nodes == 8); - - if (trouveHexa8 == 0) - { - trouveHexa8 = 1; - _TypesId[SALOME_MED::MED_CELL].push_back(SALOME_MED::MED_HEXA8); - }; - // Traitement de la maille - int longueur = _seq_elemId[index]->length(); - _seq_elemId[index]->length(longueur + nb_of_nodes); - - SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator(); - for(int k=0; itn->more(); k++) - _seq_elemId[index][longueur + k] = itn->next()->GetID()+1; - } - - _mapNbTypes[SALOME_MED::MED_CELL] = trouveHexa8; - _mapNbTypes[SALOME_MED::MED_ALL_ENTITIES] - = - trouveHexa8 + trouveTria3 + trouveTria6 + trouveQuad4 + trouveSeg2 + - trouveSeg3; - }// fin du _compte -}; - -//============================================================================= -/*! - * Creation des familles - */ -//============================================================================= -void SMESH_MEDMesh_i::createFamilies() throw(SALOME::SALOME_Exception) -{ - Unexpect aCatch(SALOME_SalomeException); - string famDes = ("Je ne sais pas"); - string famName0 = "Famille_"; - string famName; - char numero[10]; - - if (_creeFamily == false) - { - _creeFamily = true; - //SMESH_subMesh_i *subMeshServant; - - map < int, SMESH_subMesh_i * >::iterator it; - for (it = _mesh_i->_mapSubMesh_i.begin(); - it != _mesh_i->_mapSubMesh_i.end(); it++) - { - SMESH_subMesh_i *submesh_i = (*it).second; - int famIdent = (*it).first; - - ASSERT(famIdent < 999999999); - sprintf(numero, "%d\n", famIdent); - famName = famName0 + numero; - - SMESH_MEDFamily_i *famservant = - new SMESH_MEDFamily_i(famIdent, submesh_i, - famName, famDes, SALOME_MED::MED_NODE); -#ifdef WNT - SALOME_MED::FAMILY_ptr famille = SALOME_MED::FAMILY::_nil(); - POA_SALOME_MED::FAMILY* servantbase = dynamic_cast(famservant); - if ( servantbase ) - famille = SALOME_MED::FAMILY::_narrow( servantbase->_this() ); -#else - SALOME_MED::FAMILY_ptr famille = - SALOME_MED::FAMILY::_narrow( famservant->POA_SALOME_MED::FAMILY::_this() ); -#endif - _families.push_back(famille); - } - } -}; -//============================================================================= -/*! - * Gives informations of the considered mesh. - */ -//============================================================================= -SALOME_MED::GMESH::meshInfos * SMESH_MEDMesh_i::getMeshGlobal() - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return NULL; -} - -//================================================================================ -/*! - * \brief Converts this GMESH into MESH - */ -//================================================================================ - -SALOME_MED::MESH_ptr SMESH_MEDMesh_i::convertInMESH() throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return NULL; -} - -//============================================================================= -/*! - * Gives informations on coordinates of the considered mesh. - */ -//============================================================================= -SALOME_MED::GMESH::coordinateInfos * SMESH_MEDMesh_i::getCoordGlobal() - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return NULL; -} -//============================================================================= -/*! - * Gives informations on connectivities of the considered mesh for the entity - * entity. - */ -//============================================================================= -SALOME_MED::MESH::connectivityInfos * -SMESH_MEDMesh_i::getConnectGlobal(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return NULL; -} -//============================================================================= -/*! - * Gives the type of the element number of entity entity - */ -//============================================================================= -SALOME_MED::medGeometryElement -SMESH_MEDMesh_i::getElementType(SALOME_MED::medEntityMesh entity, - CORBA::Long number) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!"); - - THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM); - - return (SALOME_MED::medGeometryElement) 0; -} diff --git a/src/SMESH_I/SMESH_MEDMesh_i.hxx b/src/SMESH_I/SMESH_MEDMesh_i.hxx deleted file mode 100644 index db415bcfe..000000000 --- a/src/SMESH_I/SMESH_MEDMesh_i.hxx +++ /dev/null @@ -1,262 +0,0 @@ -// 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 -// - -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses -// File : SMESH_MEDMesh_i.hxx -// Module : SMESH -// -#ifndef _MED_SMESH_MESH_I_HXX_ -#define _MED_SMESH_MESH_I_HXX_ - -#include "SMESH.hxx" - -#include -#include CORBA_SERVER_HEADER(MED) -#include -#include -#include - -#include "SMESHDS_Mesh.hxx" - -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" -#include "SALOME_GenericObj_i.hh" - -#define MED_NBR_GEOMETRIE_MAILLE 15 -#define MED_NBR_TYPE 5 - -class SMESH_Mesh_i; - -class SMESH_I_EXPORT SMESH_MEDMesh_i: - public virtual POA_SALOME_MED::MESH, - public virtual SALOME::GenericObj_i -{ -protected: - // C++ object containing values - ::SMESH_Mesh_i * _mesh_i; - SMESHDS_Mesh *_meshDS; - - std::string _meshId; - bool _compte; - bool _creeFamily; - int _indexElts; - int _indexEnts; - int _famIdent; - - std::map < SALOME_MED::medGeometryElement, int >_mapIndToSeqElts; - SALOME_TYPES::ListOfLong_var _seq_elemId[MED_NBR_GEOMETRIE_MAILLE]; - - std::map < SALOME_MED::medEntityMesh, int >_mapNbTypes; - std::map < SALOME_MED::medEntityMesh, int >_mapIndToVectTypes; - std::vector < SALOME_MED::medGeometryElement > - _TypesId[MED_NBR_GEOMETRIE_MAILLE]; - - std::vector < SALOME_MED::FAMILY_ptr > _families; -public: - - // Constructors and associated internal methods - SMESH_MEDMesh_i(); - SMESH_MEDMesh_i(SMESH_Mesh_i * m); - ~SMESH_MEDMesh_i(); - - // IDL Methods - void setProtocol(SALOME::TypeOfCommunication typ) {} - void release() {} - SALOME::SenderDouble_ptr getSenderForCoordinates(SALOME_MED::medModeSwitch) {return SALOME::SenderDouble::_nil();} - SALOME::SenderInt_ptr getSenderForConnectivity(SALOME_MED::medConnectivity, - SALOME_MED::medEntityMesh, - SALOME_MED::medGeometryElement) - { - return SALOME::SenderInt::_nil(); - } - SALOME::SenderInt_ptr getSenderForConnectivityIndex(SALOME_MED::medConnectivity, - SALOME_MED::medEntityMesh, - SALOME_MED::medGeometryElement) - { - return SALOME::SenderInt::_nil(); - } - SALOME::SenderInt_ptr getSenderForPolygonsConnectivity(SALOME_MED::medConnectivity, SALOME_MED::medEntityMesh) {return SALOME::SenderInt::_nil();} - SALOME::SenderInt_ptr getSenderForPolygonsConnectivityIndex(SALOME_MED::medConnectivity, SALOME_MED::medEntityMesh) {return SALOME::SenderInt::_nil();} - SALOME::SenderInt_ptr getSenderForPolyhedronConnectivity(SALOME_MED::medConnectivity) {return SALOME::SenderInt::_nil();} - SALOME::SenderInt_ptr getSenderForPolyhedronIndex(SALOME_MED::medConnectivity) {return SALOME::SenderInt::_nil();} - SALOME::SenderInt_ptr getSenderForPolyhedronFacesIndex() {return SALOME::SenderInt::_nil();} - - char *getName() throw(SALOME::SALOME_Exception); - CORBA::Long getSpaceDimension() throw(SALOME::SALOME_Exception); - - CORBA::Long getMeshDimension() throw(SALOME::SALOME_Exception); - - CORBA::Boolean getIsAGrid() throw (SALOME::SALOME_Exception); - - CORBA::Boolean - existConnectivity(SALOME_MED::medConnectivity connectivityType, - SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - - char *getCoordinatesSystem() throw(SALOME::SALOME_Exception); - - CORBA::Double getCoordinate(CORBA::Long Number, CORBA::Long Axis) - throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfDouble * getCoordinates(SALOME_MED::medModeSwitch typeSwitch) - throw(SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfString * getCoordinatesNames() - throw(SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfString * getCoordinatesUnits() - throw(SALOME::SALOME_Exception); - - CORBA::Long getNumberOfNodes() throw(SALOME::SALOME_Exception); - - CORBA::Long getNumberOfTypes(SALOME_MED::medEntityMesh entity) - throw(SALOME::SALOME_Exception); - - SALOME_MED::medGeometryElement_array * - getTypes(SALOME_MED::medEntityMesh entity) throw(SALOME:: - SALOME_Exception); - - SALOME_MED::medGeometryElement - getElementType(SALOME_MED::medEntityMesh entity, - CORBA::Long number) - throw (SALOME::SALOME_Exception); - - CORBA::Long getNumberOfElements(SALOME_MED::medEntityMesh entity, - SALOME_MED::medGeometryElement geomElement) - throw(SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong * - getConnectivity(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity, - SALOME_MED::medGeometryElement geomElement) - throw(SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong * - getConnectivityIndex(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity) - throw(SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong* - getGlobalNumberingIndex(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - - CORBA::Long getElementNumber(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity, - SALOME_MED::medGeometryElement type, - const SALOME_TYPES::ListOfLong & connectivity) - throw(SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong * - getReverseConnectivity(SALOME_MED::medConnectivity mode) - throw(SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong * - getReverseConnectivityIndex(SALOME_MED::medConnectivity mode) - throw(SALOME::SALOME_Exception); - - // Family and Group - CORBA::Long getNumberOfFamilies(SALOME_MED::medEntityMesh entity) - throw(SALOME::SALOME_Exception); - - CORBA::Long getNumberOfGroups(SALOME_MED::medEntityMesh entity) - throw(SALOME::SALOME_Exception); - - SALOME_MED::Family_array * - getFamilies(SALOME_MED::medEntityMesh entity) - throw(SALOME::SALOME_Exception); - - SALOME_MED::FAMILY_ptr getFamily(SALOME_MED::medEntityMesh entity, - CORBA::Long i) - throw(SALOME::SALOME_Exception); - - SALOME_MED::Group_array * getGroups(SALOME_MED::medEntityMesh entity) - throw(SALOME::SALOME_Exception); - - SALOME_MED::GROUP_ptr getGroup(SALOME_MED::medEntityMesh entity, - CORBA::Long i) - throw(SALOME::SALOME_Exception); - - SALOME_MED::SUPPORT_ptr - getBoundaryElements(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - - SALOME_MED::SUPPORT_ptr - getSupportOnAll(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - - SALOME_MED::SUPPORT_ptr getSkin(SALOME_MED::SUPPORT_ptr mySupport3D) - throw (SALOME::SALOME_Exception); - - SALOME_MED::FIELD_ptr getVolume(SALOME_MED::SUPPORT_ptr mySupport) - throw(SALOME::SALOME_Exception); - - SALOME_MED::FIELD_ptr getArea(SALOME_MED::SUPPORT_ptr mySupport) - throw(SALOME::SALOME_Exception); - - SALOME_MED::FIELD_ptr getLength(SALOME_MED::SUPPORT_ptr mySupport) - throw(SALOME::SALOME_Exception); - - SALOME_MED::FIELD_ptr getNormal(SALOME_MED::SUPPORT_ptr mySupport) - throw(SALOME::SALOME_Exception); - - SALOME_MED::FIELD_ptr getBarycenter(SALOME_MED::SUPPORT_ptr mySupport) - throw(SALOME::SALOME_Exception); - - SALOME_MED::FIELD_ptr getNeighbourhood(SALOME_MED::SUPPORT_ptr mySupport) - throw(SALOME::SALOME_Exception); - - // Others - void addInStudy(SALOMEDS::Study_ptr myStudy, - SALOME_MED::GMESH_ptr myIor) - throw(SALOME::SALOME_Exception); - CORBA::Long addDriver(SALOME_MED::medDriverTypes driverType, - const char *fileName, const char *meshName) - throw(SALOME::SALOME_Exception); - void rmDriver(CORBA::Long i) throw(SALOME::SALOME_Exception); - void read(CORBA::Long i) throw(SALOME::SALOME_Exception); - void write(CORBA::Long i, const char *driverMeshName) - throw(SALOME::SALOME_Exception); - - // Cuisine interne - CORBA::Long getCorbaIndex() - throw(SALOME::SALOME_Exception); - - SALOME_MED::GMESH::meshInfos * getMeshGlobal() - throw (SALOME::SALOME_Exception); - - bool areEquals(SALOME_MED::GMESH_ptr other) { return false;}; - - SALOME_MED::MESH_ptr convertInMESH() throw (SALOME::SALOME_Exception); - - SALOME_MED::GMESH::coordinateInfos * getCoordGlobal() - throw (SALOME::SALOME_Exception); - - SALOME_MED::MESH::connectivityInfos * - getConnectGlobal(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - - // - void calculeNbElts() throw(SALOME::SALOME_Exception); - void createFamilies() throw(SALOME::SALOME_Exception); -}; - -#endif /* _MED_MESH_I_HXX_ */ diff --git a/src/SMESH_I/SMESH_MEDSupport_i.cxx b/src/SMESH_I/SMESH_MEDSupport_i.cxx deleted file mode 100644 index 803ffa67f..000000000 --- a/src/SMESH_I/SMESH_MEDSupport_i.cxx +++ /dev/null @@ -1,403 +0,0 @@ -// 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 -// - -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses -// File : SMESH_MEDSupport_i.cxx -// Module : SMESH -// -#include "SMESH_MEDSupport_i.hxx" -#include "utilities.h" -#include "Utils_CorbaException.hxx" -#include "Utils_ExceptHandlers.hxx" - -#include "SMESHDS_Mesh.hxx" - -#include "SMESH_subMesh.hxx" -#include "SMESH_Mesh_i.hxx" -#include "SMESH_subMesh_i.hxx" -#include "SMESH_Gen_i.hxx" - -#include - -using namespace std; - - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -SMESH_MEDSupport_i::SMESH_MEDSupport_i() -{ - BEGIN_OF("Default Constructor SMESH_MEDSupport_i"); - END_OF("Default Constructor SMESH_MEDSupport_i"); -} - -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -SMESH_MEDSupport_i::SMESH_MEDSupport_i(SMESH_subMesh_i * sm, string name, - string description, SALOME_MED::medEntityMesh entity) - :_subMesh_i(sm), _name(name), _description(description), _entity(entity), - _seqNumber(false), _seqLength(0) -{ - BEGIN_OF("Constructor SMESH_MEDSupport_i"); - - int subMeshId = sm->GetId(); - - MESSAGE(" subMeshId " << subMeshId); - - SMESH_Mesh_i* mesh_i = SMESH::DownCast( sm->GetMesh() ); - _subMesh = mesh_i->GetImpl().GetSubMeshContaining( subMeshId ); - - if (_entity == SALOME_MED::MED_NODE) - { - _numberOfGeometricType = 1; - _geometricType = new SALOME_MED::medGeometryElement[1]; - _geometricType[0] = SALOME_MED::MED_NONE; - } - else - { - MESSAGE("Pas implemente dans cette version"); - THROW_SALOME_CORBA_EXCEPTION - ("Seules les familles de noeuds sont implementees ", - SALOME::BAD_PARAM); - } - - END_OF("Constructor SMESH_MEDSupport_i"); -} - -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -SMESH_MEDSupport_i:: -SMESH_MEDSupport_i(const SMESH_MEDSupport_i & s):_subMesh(s._subMesh), -_name(s._name), _description(s._description), _entity(s._entity), -_seqNumber(false), _seqLength(0) -{ - BEGIN_OF("Constructor SMESH_MEDSupport_i"); - - END_OF("Constructor SMESH_MEDSupport_i"); -} - -//============================================================================= -/*! - * Destructor - */ -//============================================================================= - -SMESH_MEDSupport_i::~SMESH_MEDSupport_i() -{ -} - -//============================================================================= -/*! - * CORBA: Accessor for Corba Index - */ -//============================================================================= - -CORBA::Long SMESH_MEDSupport_i::getCorbaIndex()throw(SALOME::SALOME_Exception) -{ - if (_subMesh == NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", - SALOME::INTERNAL_ERROR); - MESSAGE("Not implemented for SMESH_i"); - THROW_SALOME_CORBA_EXCEPTION("Not Implemented ", SALOME::BAD_PARAM); - -} - -//============================================================================= -/*! - * CORBA: Accessor for Name - */ -//============================================================================= - -char *SMESH_MEDSupport_i::getName() throw(SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", - SALOME::INTERNAL_ERROR); - return CORBA::string_dup(_name.c_str()); - -} - -//============================================================================= -/*! - * CORBA: Accessor for Description - */ -//============================================================================= - -char *SMESH_MEDSupport_i::getDescription() throw(SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", - SALOME::INTERNAL_ERROR); - return CORBA::string_dup(_description.c_str()); -} - -//============================================================================= -/*! - * CORBA: Accessor for Mesh - */ -//============================================================================= - -SALOME_MED::GMESH_ptr SMESH_MEDSupport_i::getMesh()throw(SALOME:: - SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", - SALOME::INTERNAL_ERROR); - - return _subMesh_i->GetMesh()->GetMEDMesh(); -} - -//============================================================================= -/*! - * CORBA: boolean indicating if support concerns all elements - */ -//============================================================================= - -CORBA::Boolean SMESH_MEDSupport_i::isOnAllElements()throw(SALOME:: - SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", - SALOME::INTERNAL_ERROR); - if (_seqNumber == false) - { - if (_entity != SALOME_MED::MED_NONE) - { - _seqLength = _subMesh_i->GetNumberOfNodes(/*all=*/false); - _seqNumber = true; - } - else - { - MESSAGE("Only Node Families are implemented "); - THROW_SALOME_CORBA_EXCEPTION("Not implemented Yet ", - SALOME::BAD_PARAM); - } - } - try - { - _isOnAllElements = (_seqLength == _subMesh->GetFather()->NbNodes()); - } - catch(...) - { - MESSAGE("unable to acces related Mesh"); - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", - SALOME::INTERNAL_ERROR); - }; - return _isOnAllElements; -} - -//============================================================================= -/*! - * CORBA: Accessor for type of support's entity - */ -//============================================================================= - -SALOME_MED::medEntityMesh SMESH_MEDSupport_i::getEntity()throw(SALOME:: - SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", - SALOME::INTERNAL_ERROR); - return _entity; -} - -//============================================================================= -/*! - * CORBA: Accessor for types of geometry elements - */ -//============================================================================= - -SALOME_MED::medGeometryElement_array * - SMESH_MEDSupport_i::getTypes()throw(SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", - SALOME::INTERNAL_ERROR); - SALOME_MED::medGeometryElement_array_var myseq = - new SALOME_MED::medGeometryElement_array; - try - { - int mySeqLength = _numberOfGeometricType; - myseq->length(mySeqLength); - for (int i = 0; i < mySeqLength; i++) - { - myseq[i] = _geometricType[i]; - } - } - catch(...) - { - MESSAGE("Exception lors de la recherche des differents types"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support Types", - SALOME::INTERNAL_ERROR); - } - return myseq._retn(); -} - -//============================================================================= -/*! - * CORBA: Number of different types of geometry elements - * existing in the support - */ -//============================================================================= -CORBA::Long SMESH_MEDSupport_i::getNumberOfElements(SALOME_MED:: - medGeometryElement geomElement) throw(SALOME::SALOME_Exception) -{ - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", - SALOME::INTERNAL_ERROR); - return _numberOfGeometricType; - -} - -//============================================================================= -/*! - * CORBA: get Nodes - */ -//============================================================================= - -SALOME_TYPES::ListOfLong * SMESH_MEDSupport_i::getNumber( - SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception) -{ - Unexpect aCatch(SALOME_SalomeException); - if (_subMesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", - SALOME::INTERNAL_ERROR); - - // A changer s'il ne s agit plus seulement de famille de noeuds - if (geomElement != SALOME_MED::MED_NONE) - THROW_SALOME_CORBA_EXCEPTION("Not implemented", SALOME::BAD_PARAM); - - SALOME_TYPES::ListOfLong_var myseq = new SALOME_TYPES::ListOfLong; - - int i = 0; - myseq->length(_subMesh_i->GetNumberOfNodes(/*all=*/false)); - - if ( _subMesh->GetSubMeshDS() ) - { - SMDS_NodeIteratorPtr it = _subMesh->GetSubMeshDS()->GetNodes(); - while(it->more()) - { - myseq[i] = it->next()->GetID(); - i++; - }; - } - - SCRUTE(myseq->length()); - MESSAGE("End of SMESH_MEDSupport_i::getNumber"); - return myseq._retn(); - -} - -//============================================================================= -/*! - * CORBA: get Nodes from file - */ -//============================================================================= - -SALOME_TYPES::ListOfLong * SMESH_MEDSupport_i::getNumberFromFile( - SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception) -{ - return getNumber(geomElement); -} - -//============================================================================= -/*! - * CORBA: Global Nodes Index (optionnaly designed by the user) - * CORBA: ?????????????????????????????? - */ -//============================================================================= - -SALOME_TYPES::ListOfLong * - SMESH_MEDSupport_i::getNumberIndex()throw(SALOME::SALOME_Exception) -{ - MESSAGE("Not implemented for SMESH_i"); - THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM); - return NULL; -} -//============================================================================= -/*! - * CORBA: Array containing indexes for elements included in the support - */ -//============================================================================= - -CORBA::Long SMESH_MEDSupport_i::getNumberOfGaussPoint(SALOME_MED:: - medGeometryElement geomElement) throw(SALOME::SALOME_Exception) -{ - MESSAGE("Not implemented for SMESH_i"); - return 0; -} -//============================================================================= -/*! - * Gives the number of types of elements included in the support - */ -//============================================================================= -CORBA::Long SMESH_MEDSupport_i::getNumberOfTypes() - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!! NOT YET IMPLEMENTED !!!!"); - THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM); - return 0; -} -//============================================================================= -/*! - * Gives CORBA: Array containing the numbers of Gauss point of elements - * included in the support - */ -//============================================================================= -SALOME_TYPES::ListOfLong* SMESH_MEDSupport_i::getNumbersOfGaussPoint() - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!! NOT YET IMPLEMENTED !!!!"); - THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM); - return NULL; -} -//============================================================================= -/*! - * build the object which will contain all the boundary elements of the mesh. - */ -//============================================================================= -void SMESH_MEDSupport_i::getBoundaryElements() - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!! NOT YET IMPLEMENTED !!!!"); - THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM); -} -//============================================================================= -/*! - * Gives information on the support - */ -//============================================================================= -SALOME_MED::SUPPORT::supportInfos * SMESH_MEDSupport_i::getSupportGlobal() - throw (SALOME::SALOME_Exception) -{ - MESSAGE("!!! NOT YET IMPLEMENTED !!!!"); - THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM); - return NULL; -} diff --git a/src/SMESH_I/SMESH_MEDSupport_i.hxx b/src/SMESH_I/SMESH_MEDSupport_i.hxx deleted file mode 100644 index d8c1c8349..000000000 --- a/src/SMESH_I/SMESH_MEDSupport_i.hxx +++ /dev/null @@ -1,120 +0,0 @@ -// 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 -// - -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses -// File : SMESH_MEDSupport_i.hxx -// Module : SMESH -// -#ifndef _MED_SMESH_MEDSUPPORT_I_HXX_ -#define _MED_SMESH_MEDSUPPORT_I_HXX_ - -#include "SMESH.hxx" - -#include -#include CORBA_SERVER_HEADER(MED) -#include - -#include "SMESHDS_Mesh.hxx" -#include "SMESHDS_SubMesh.hxx" -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" - -#include "SMESH_MEDSupport_i.hxx" -#include "SALOME_GenericObj_i.hh" -class SMESH_subMesh; -class SMESH_subMesh_i; - -class SMESH_I_EXPORT SMESH_MEDSupport_i: - public virtual POA_SALOME_MED::SUPPORT, public virtual SALOME::GenericObj_i -{ - public: - -// Constructors and associated internal methods - SMESH_MEDSupport_i(SMESH_subMesh_i * sm, - std::string name, std::string description, SALOME_MED::medEntityMesh entity); - SMESH_MEDSupport_i(const SMESH_MEDSupport_i & s); - -// IDL Methods - char *getName() throw(SALOME::SALOME_Exception); - char *getDescription() throw(SALOME::SALOME_Exception); - SALOME_MED::GMESH_ptr getMesh() throw(SALOME::SALOME_Exception); - CORBA::Boolean isOnAllElements() throw(SALOME::SALOME_Exception); - SALOME_MED::medEntityMesh getEntity() throw(SALOME::SALOME_Exception); - CORBA::Long - getNumberOfElements(SALOME_MED::medGeometryElement geomElement) - throw(SALOME::SALOME_Exception); - - CORBA::Long getNumberOfTypes() throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong * - getNumber(SALOME_MED::medGeometryElement geomElement) - throw(SALOME::SALOME_Exception); - - /*! - * Same function as getNumber. - */ - SALOME_TYPES::ListOfLong * - getNumberFromFile(SALOME_MED::medGeometryElement geomElement) - throw(SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong * getNumberIndex() - throw(SALOME::SALOME_Exception); - - CORBA::Long - getNumberOfGaussPoint(SALOME_MED::medGeometryElement geomElement) - throw(SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong* getNumbersOfGaussPoint() - throw (SALOME::SALOME_Exception); - - SALOME_MED::medGeometryElement_array *getTypes() - throw(SALOME::SALOME_Exception); - - void getBoundaryElements() throw (SALOME::SALOME_Exception); - - CORBA::Long getCorbaIndex() throw(SALOME::SALOME_Exception); - - SALOME_MED::SUPPORT::supportInfos * getSupportGlobal() - throw (SALOME::SALOME_Exception); - - void createSeq() throw(SALOME::SALOME_Exception); - - public: //public field - SMESH_subMesh_i * _subMesh_i; - ::SMESH_subMesh * _subMesh; - - std::string _name; - std::string _description; - bool _isOnAllElements; - bool _seqNumber; - int _seqLength; - - SALOME_MED::medEntityMesh _entity; - SALOME_MED::medGeometryElement * _geometricType; - int _numberOfGeometricType; - - protected: - SMESH_MEDSupport_i(); - ~SMESH_MEDSupport_i(); -}; - -#endif /* _MED_MEDSUPPORT_I_HXX_ */ diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 6cb26a80a..25750af0e 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -274,13 +274,23 @@ namespace MeshEditor_I { TIDSortedElemSet& aMap, const SMDSAbs_ElementType aType = SMDSAbs_All ) { - for (int i=0; iFindNode(ind) : aMesh->FindElement(ind)); - if ( elem && ( aType == SMDSAbs_All || elem->GetType() == aType )) - aMap.insert( aMap.end(), elem ); - } + SMDS_MeshElement::NonNullFilter filter1; + SMDS_MeshElement::TypeFilter filter2( aType ); + SMDS_MeshElement::Filter & filter = + ( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter&) filter1 : filter2; + + if ( aType == SMDSAbs_Node ) + for (int i=0; iFindNode( IDs[i] ); + if ( filter( elem )) + aMap.insert( aMap.end(), elem ); + } + else + for (int i=0; iFindElement( IDs[i] ); + if ( filter( elem )) + aMap.insert( aMap.end(), elem ); + } } //================================================================================ /*! @@ -711,6 +721,14 @@ struct SMESH_MeshEditor_i::_IDSource : public POA_SMESH::SMESH_IDSource SMESH::SMESH_Mesh_ptr _mesh; SMESH::long_array* GetIDs() { return new SMESH::long_array( _ids ); } SMESH::long_array* GetMeshInfo() { return 0; } + SMESH::long_array* GetNbElementsByType() + { + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::NB_ELEMENT_TYPES); + for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++) + aRes[ i ] = ( i == _type ) ? _ids.length() : 0; + return aRes._retn(); + } SMESH::SMESH_Mesh_ptr GetMesh() { return SMESH::SMESH_Mesh::_duplicate( _mesh ); } bool IsMeshInfoCorrect() { return true; } SMESH::array_of_ElementType* GetTypes() @@ -746,6 +764,18 @@ bool SMESH_MeshEditor_i::IsTemporaryIDSource( SMESH::SMESH_IDSource_ptr& idSourc return SMESH::DownCast( idSource ); } +CORBA::Long* SMESH_MeshEditor_i::GetTemporaryIDs( SMESH::SMESH_IDSource_ptr& idSource, + int& nbIds) +{ + if ( _IDSource* tmpIdSource = SMESH::DownCast( idSource )) + { + nbIds = (int) tmpIdSource->_ids.length(); + return & tmpIdSource->_ids[0]; + } + nbIds = 0; + return 0; +} + void SMESH_MeshEditor_i::deleteAuxIDSources() { std::list< _IDSource* >::iterator idSrcIt = myAuxIDSources.begin(); @@ -1211,6 +1241,7 @@ SMESH_MeshEditor_i::Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObje TPythonDump pyDump; TIDSortedElemSet elements, elems0D; + prepareIdSource( theObject ); if ( idSourceToSet( theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1)) getEditor().Create0DElementsOnAllNodes( elements, elems0D ); @@ -1559,6 +1590,8 @@ CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theO TPythonDump aTPythonDump; // suppress dump in Reorient() + prepareIdSource( theObject ); + SMESH::long_array_var anElementsId = theObject->GetIDs(); CORBA::Boolean isDone = Reorient(anElementsId); @@ -1593,6 +1626,7 @@ CORBA::Long SMESH_MeshEditor_i::Reorient2D(SMESH::SMESH_IDSource_ptr the2Dgroup, initData(/*deleteSearchers=*/false); TIDSortedElemSet elements; + prepareIdSource( the2Dgroup ); if ( !idSourceToSet( the2Dgroup, getMeshDS(), elements, SMDSAbs_Face, /*emptyIfIsMesh=*/1)) THROW_SALOME_CORBA_EXCEPTION("No faces in given group", SALOME::BAD_PARAM); @@ -1714,6 +1748,8 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr initData(); TPythonDump aTPythonDump; // suppress dump in TriToQuad() + + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle); @@ -1783,6 +1819,7 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr TPythonDump aTPythonDump; // suppress dump in QuadToTri() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion); @@ -1813,6 +1850,7 @@ void SMESH_MeshEditor_i::QuadTo4Tri (SMESH::SMESH_IDSource_ptr theObject) initData(); TIDSortedElemSet faces; + prepareIdSource( theObject ); if ( !idSourceToSet( theObject, getMeshDS(), faces, SMDSAbs_Face, /*emptyIfIsMesh=*/true ) && faces.empty() ) THROW_SALOME_CORBA_EXCEPTION("No faces given", SALOME::BAD_PARAM); @@ -1868,6 +1906,7 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr th TPythonDump aTPythonDump; // suppress dump in SplitQuad() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13); @@ -1932,6 +1971,7 @@ void SMESH_MeshEditor_i::SplitVolumesIntoTetra (SMESH::SMESH_IDSource_ptr elems, SMESH_TRY; initData(); + prepareIdSource( elems ); SMESH::long_array_var anElementsId = elems->GetIDs(); TIDSortedElemSet elemSet; arrayToSet( anElementsId, getMeshDS(), elemSet, SMDSAbs_Volume ); @@ -2091,6 +2131,7 @@ SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObjec TPythonDump aTPythonDump; // suppress dump in smooth() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method, IsParametric); @@ -2292,6 +2333,7 @@ void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject << theNbOfSteps << ", " << theTolerance << " )"; } + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); rotationSweep(anElementsId, theAxis, @@ -2321,6 +2363,7 @@ void SMESH_MeshEditor_i::RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObje << TVar( theNbOfSteps ) << ", " << TVar( theTolerance ) << " )"; } + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); rotationSweep(anElementsId, theAxis, @@ -2351,6 +2394,7 @@ void SMESH_MeshEditor_i::RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObje << TVar( theNbOfSteps ) << ", " << TVar( theTolerance ) << " )"; } + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); rotationSweep(anElementsId, theAxis, @@ -2376,6 +2420,7 @@ SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theO { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId, theAxis, @@ -2410,6 +2455,7 @@ SMESH_MeshEditor_i::RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr th { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId, theAxis, @@ -2445,6 +2491,7 @@ SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr th { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId, theAxis, @@ -2558,6 +2605,7 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObjec CORBA::Long theNbOfSteps) throw (SALOME::SALOME_Exception) { + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false ); if (!myIsPreviewMode) { @@ -2576,6 +2624,7 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject0D(SMESH::SMESH_IDSource_ptr theObj CORBA::Long theNbOfSteps) throw (SALOME::SALOME_Exception) { + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Node ); if ( !myIsPreviewMode ) { @@ -2594,6 +2643,7 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObj CORBA::Long theNbOfSteps) throw (SALOME::SALOME_Exception) { + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge ); if ( !myIsPreviewMode ) { @@ -2612,6 +2662,7 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObj CORBA::Long theNbOfSteps) throw (SALOME::SALOME_Exception) { + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face ); if ( !myIsPreviewMode ) { @@ -2679,6 +2730,7 @@ SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr the { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, theNbOfSteps, true); @@ -2703,6 +2755,7 @@ SMESH_MeshEditor_i::ExtrusionSweepObject0DMakeGroups(SMESH::SMESH_IDSource_ptr t { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Node); @@ -2727,6 +2780,7 @@ SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr t { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge); @@ -2751,6 +2805,7 @@ SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr t { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face); @@ -3149,6 +3204,7 @@ SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObje << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; } SMESH::SMESH_MeshEditor::Extrusion_Error anError; + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionAlongPath( anElementsId, thePathMesh, @@ -3194,6 +3250,7 @@ SMESH_MeshEditor_i::ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theOb << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; } SMESH::SMESH_MeshEditor::Extrusion_Error anError; + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionAlongPath( anElementsId, thePathMesh, @@ -3240,6 +3297,7 @@ SMESH_MeshEditor_i::ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theOb << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; } SMESH::SMESH_MeshEditor::Extrusion_Error anError; + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionAlongPath( anElementsId, thePathMesh, @@ -3327,6 +3385,7 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId, thePathMesh, @@ -3381,6 +3440,7 @@ ExtrusionAlongPathObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject, { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId, thePathMesh, @@ -3436,6 +3496,7 @@ ExtrusionAlongPathObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject, { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( theObject ); SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId, thePathMesh, @@ -3493,6 +3554,7 @@ ExtrusionAlongPathObjX(SMESH::SMESH_IDSource_ptr Object, { TPythonDump aPythonDump; // it is here to prevent dump of GetGroups() + prepareIdSource( Object ); SMESH::long_array_var anElementsId = Object->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionAlongPathX(anElementsId, Path, @@ -3781,6 +3843,7 @@ void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObj bool emptyIfIsMesh = myIsPreviewMode ? false : true; + prepareIdSource( theObject ); if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh)) mirror(elements, theAxis, theMirrorType, theCopy, false); } @@ -3830,6 +3893,7 @@ SMESH_MeshEditor_i::MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr t SMESH::ListOfGroups * aGroups = 0; TIDSortedElemSet elements; + prepareIdSource( theObject ); if ( idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1)) aGroups = mirror(elements, theMirror, theMirrorType, true, true); @@ -3915,6 +3979,7 @@ SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr the mesh = makeMesh( theMeshName ); mesh_i = SMESH::DownCast( mesh ); TIDSortedElemSet elements; + prepareIdSource( theObject ); if ( mesh_i && idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1)) { @@ -4043,6 +4108,7 @@ void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject, bool emptyIfIsMesh = myIsPreviewMode ? false : true; + prepareIdSource( theObject ); if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh)) translate(elements, theVector, theCopy, false); } @@ -4088,6 +4154,7 @@ SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObjec SMESH::ListOfGroups * aGroups = 0; TIDSortedElemSet elements; + prepareIdSource( theObject ); if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1)) aGroups = translate(elements, theVector, true, true); @@ -4170,6 +4237,7 @@ SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject, mesh_i = SMESH::DownCast( mesh ); TIDSortedElemSet elements; + prepareIdSource( theObject ); if ( mesh_i && idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1)) { @@ -4297,6 +4365,7 @@ void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject, } TIDSortedElemSet elements; bool emptyIfIsMesh = myIsPreviewMode ? false : true; + prepareIdSource( theObject ); if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh)) rotate(elements,theAxis,theAngle,theCopy,false); } @@ -4346,6 +4415,7 @@ SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, SMESH::ListOfGroups * aGroups = 0; TIDSortedElemSet elements; + prepareIdSource( theObject ); if (idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1)) aGroups = rotate(elements, theAxis, theAngle, true, true); @@ -4437,6 +4507,7 @@ SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject, mesh_i = SMESH::DownCast( mesh ); TIDSortedElemSet elements; + prepareIdSource( theObject ); if (mesh_i && idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1)) { @@ -4489,6 +4560,7 @@ SMESH_MeshEditor_i::scale(SMESH::SMESH_IDSource_ptr theObject, theCopy = false; TIDSortedElemSet elements; + prepareIdSource( theObject ); bool emptyIfIsMesh = myIsPreviewMode ? false : true; if ( !idSourceToSet(theObject, getMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh)) return 0; @@ -4672,6 +4744,7 @@ void SMESH_MeshEditor_i::FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr initData(); TIDSortedNodeSet nodes; + prepareIdSource( theObject ); idSourceToNodeSet( theObject, getMeshDS(), nodes ); ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes; @@ -4715,6 +4788,7 @@ FindCoincidentNodesOnPartBut(SMESH::SMESH_IDSource_ptr theObject, initData(); TIDSortedNodeSet nodes; + prepareIdSource( theObject ); idSourceToNodeSet( theObject, getMeshDS(), nodes ); for ( int i = 0; i < theExceptSubMeshOrGroups.length(); ++i ) @@ -4808,6 +4882,7 @@ void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr theObj if ( !(!group->_is_nil() && group->GetType() == SMESH::NODE) ) { TIDSortedElemSet elems; + prepareIdSource( theObject ); idSourceToSet( theObject, getMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true); ::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID; @@ -5515,8 +5590,11 @@ void SMESH_MeshEditor_i::convertToQuadratic(CORBA::Boolean theForce3d TIDSortedElemSet elems; bool elemsOK; if ( !( elemsOK = CORBA::is_nil( theObject ))) + { + prepareIdSource( theObject ); elemsOK = idSourceToSet( theObject, getMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true ); + } if ( elemsOK ) { if ( !elems.empty() && (*elems.begin())->GetType() == SMDSAbs_Node ) @@ -5595,8 +5673,11 @@ void SMESH_MeshEditor_i::ConvertFromQuadraticObject(SMESH::SMESH_IDSource_ptr th throw (SALOME::SALOME_Exception) { SMESH_TRY; - TPythonDump pyDump; + + TPythonDump pyDump; + TIDSortedElemSet elems; + prepareIdSource( theObject ); if ( idSourceToSet( theObject, getMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true )) { if ( elems.empty() ) @@ -5677,11 +5758,99 @@ string SMESH_MeshEditor_i::generateGroupName(const string& thePrefix) int index = 0; while (!groupNames.insert(name).second) - name = SMESH_Comment( thePrefix ) << "_" << index; + name = SMESH_Comment( thePrefix ) << "_" << index++; return name; } +//================================================================================ +/*! + * \brief Prepare SMESH_IDSource for work + */ +//================================================================================ + +void SMESH_MeshEditor_i::prepareIdSource(SMESH::SMESH_IDSource_ptr theObject) +{ + if ( SMESH::Filter_i* filter = SMESH::DownCast( theObject )) + { + SMESH::SMESH_Mesh_var mesh = myMesh_i->_this(); + filter->SetMesh( mesh ); + } +} + +//================================================================================ +/*! + * \brief Duplicates given elements, i.e. creates new elements based on the + * same nodes as the given ones. + * \param theElements - container of elements to duplicate. + * \param theGroupName - a name of group to contain the generated elements. + * If a group with such a name already exists, the new elements + * are added to the existng group, else a new group is created. + * If \a theGroupName is empty, new elements are not added + * in any group. + * \return a group where the new elements are added. NULL if theGroupName == "". + * \sa DoubleNode() + */ +//================================================================================ + +SMESH::SMESH_Group_ptr +SMESH_MeshEditor_i::DoubleElements(SMESH::SMESH_IDSource_ptr theElements, + const char* theGroupName) + throw (SALOME::SALOME_Exception) +{ + SMESH::SMESH_Group_var newGroup; + + SMESH_TRY; + initData(); + + TPythonDump pyDump; + + TIDSortedElemSet elems; + prepareIdSource( theElements ); + if ( idSourceToSet( theElements, getMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true)) + { + getEditor().DoubleElements( elems ); + + if ( strlen( theGroupName ) && !getEditor().GetLastCreatedElems().IsEmpty() ) + { + // group type + SMESH::ElementType type = + SMESH::ElementType( getEditor().GetLastCreatedElems().Value(1)->GetType() ); + // find existing group + SMESH::ListOfGroups_var groups = myMesh_i->GetGroups(); + for ( size_t i = 0; i < groups->length(); ++i ) + if ( groups[i]->GetType() == type ) + { + CORBA::String_var name = groups[i]->GetName(); + if ( strcmp( name, theGroupName ) == 0 ) { + newGroup = SMESH::SMESH_Group::_narrow( groups[i] ); + break; + } + } + // create a new group + if ( newGroup->_is_nil() ) + newGroup = myMesh_i->CreateGroup( type, theGroupName ); + // fill newGroup + if ( SMESH_Group_i* group_i = SMESH::DownCast< SMESH_Group_i* >( newGroup )) + { + SMESHDS_Group* groupDS = static_cast< SMESHDS_Group* >( group_i->GetGroupDS() ); + const SMESH_SequenceOfElemPtr& aSeq = getEditor().GetLastCreatedElems(); + for ( int i = 1; i <= aSeq.Length(); i++ ) + groupDS->SMDSGroup().Add( aSeq(i) ); + } + } + } + // python dump + if ( !newGroup->_is_nil() ) + pyDump << newGroup << " = "; + pyDump << this << ".DoubleElements( " + << theElements << ", " << "'" << theGroupName <<"')"; + + SMESH_CATCH( SMESH::throwCorbaException ); + + return newGroup._retn(); +} + //================================================================================ /*! \brief Creates a hole in a mesh by doubling the nodes of some particular elements @@ -6831,6 +7000,7 @@ SMESH_MeshEditor_i::MakeBoundaryMesh(SMESH::SMESH_IDSource_ptr idSource, TIDSortedElemSet elements; SMDSAbs_ElementType elemType = (dim == SMESH::BND_1DFROM2D) ? SMDSAbs_Face : SMDSAbs_Volume; + prepareIdSource( idSource ); if ( idSourceToSet( idSource, aMeshDS, elements, elemType,/*emptyIfIsMesh=*/true )) { // mesh to fill in diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx index 07435e3a6..ec6ae3b84 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.hxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx @@ -89,6 +89,7 @@ public: SMESH::SMESH_IDSource_ptr MakeIDSource(const SMESH::long_array& IDsOfElements, SMESH::ElementType type); static bool IsTemporaryIDSource( SMESH::SMESH_IDSource_ptr& idSource ); + static CORBA::Long* GetTemporaryIDs( SMESH::SMESH_IDSource_ptr& idSource, int& nbIds ); CORBA::Boolean RemoveElements(const SMESH::long_array & IDsOfElements) throw (SALOME::SALOME_Exception); @@ -723,6 +724,10 @@ public: CORBA::Boolean ChangeElemNodes(CORBA::Long ide, const SMESH::long_array& newIDs) throw (SALOME::SALOME_Exception); + SMESH::SMESH_Group_ptr DoubleElements(SMESH::SMESH_IDSource_ptr theElements, + const char* theGroupName) + throw (SALOME::SALOME_Exception); + CORBA::Boolean DoubleNodes( const SMESH::long_array& theNodes, const SMESH::long_array& theModifiedElems ) throw (SALOME::SALOME_Exception); @@ -1077,6 +1082,8 @@ private: //!< private methods string generateGroupName(const string& thePrefix); + void prepareIdSource(SMESH::SMESH_IDSource_ptr theObject); + private: //!< fields SMESH_Mesh_i* myMesh_i; diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 0e0e82a6b..41cfc153c 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -27,6 +27,7 @@ #include "DriverMED_R_SMESHDS_Mesh.h" #include "DriverMED_W_SMESHDS_Mesh.h" +#include "MED_Factory.hxx" #include "SMDS_EdgePosition.hxx" #include "SMDS_ElemIterator.hxx" #include "SMDS_FacePosition.hxx" @@ -38,11 +39,11 @@ #include "SMESHDS_CommandType.hxx" #include "SMESHDS_Group.hxx" #include "SMESHDS_GroupOnGeom.hxx" +#include "SMESH_Controls.hxx" #include "SMESH_Filter_i.hxx" #include "SMESH_Gen_i.hxx" #include "SMESH_Group.hxx" #include "SMESH_Group_i.hxx" -#include "SMESH_MEDMesh_i.hxx" #include "SMESH_MeshEditor.hxx" #include "SMESH_MeshEditor_i.hxx" #include "SMESH_MeshPartDS.hxx" @@ -382,7 +383,7 @@ SMESH_Mesh_i::ImportMEDFile( const char* theFileName, const char* theMeshName ) int major, minor, release; if( !MED::getMEDVersion( theFileName, major, minor, release ) ) major = minor = release = -1; - _medFileInfo = new SALOME_MED::MedFileInfo(); + _medFileInfo = new SMESH::MedFileInfo(); _medFileInfo->fileName = theFileName; _medFileInfo->fileSize = 0; #ifdef WIN32 @@ -2155,7 +2156,8 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theS // register CORBA object for persistence int nextId = _gen_i->RegisterObject( subMesh ); - if(MYDEBUG) MESSAGE( "Add submesh to map with id = "<< nextId); + if(MYDEBUG) { MESSAGE( "Add submesh to map with id = "<< nextId); } + else { nextId = 0; } // avoid "unused variable" warning in release mode // to track changes of GEOM groups addGeomGroupData( theSubShapeObject, subMesh ); @@ -2270,7 +2272,8 @@ SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType // register CORBA object for persistence int nextId = _gen_i->RegisterObject( aGroup ); - if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId); + if(MYDEBUG) { MESSAGE( "Add group to map with id = "<< nextId); } + else { nextId = 0; } // avoid "unused variable" warning in release mode // to track changes of GEOM groups if ( !theShape.IsNull() ) { @@ -2706,7 +2709,8 @@ string SMESH_Mesh_i::prepareMeshNameAndGroups(const char* file, void SMESH_Mesh_i::ExportToMEDX (const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion, - CORBA::Boolean overwrite) + CORBA::Boolean overwrite, + CORBA::Boolean autoDimension) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); @@ -2715,9 +2719,11 @@ void SMESH_Mesh_i::ExportToMEDX (const char* file, string aMeshName = prepareMeshNameAndGroups(file, overwrite); TPythonDump() << _this() << ".ExportToMEDX( r'" - << file << "', " << auto_groups << ", " << theVersion << ", " << overwrite << " )"; + << file << "', " << auto_groups << ", " + << theVersion << ", " << overwrite << ", " + << autoDimension << " )"; - _impl->ExportMED( file, aMeshName.c_str(), auto_groups, theVersion ); + _impl->ExportMED( file, aMeshName.c_str(), auto_groups, theVersion, 0, autoDimension ); } //================================================================================ @@ -2846,29 +2852,39 @@ void SMESH_Mesh_i::ExportPartToMED(::SMESH::SMESH_IDSource_ptr meshPart, const char* file, CORBA::Boolean auto_groups, ::SMESH::MED_VERSION version, - ::CORBA::Boolean overwrite) + ::CORBA::Boolean overwrite, + ::CORBA::Boolean autoDimension) throw (SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - if ( _preMeshInfo ) - _preMeshInfo->FullLoadFromFile(); + TPythonDump pyDump; - PrepareForWriting(file, overwrite); - - string aMeshName = "Mesh"; - SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy(); - if ( !aStudy->_is_nil() ) { - SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( aStudy, meshPart ); - if ( !SO->_is_nil() ) { - CORBA::String_var name = SO->GetName(); - aMeshName = name; - } + if ( SMESH_Mesh_i * mesh = SMESH::DownCast< SMESH_Mesh_i* >( meshPart )) + { + mesh->ExportToMEDX( file, auto_groups, version, autoDimension ); } - SMESH_MeshPartDS partDS( meshPart ); - _impl->ExportMED( file, aMeshName.c_str(), auto_groups, version, &partDS ); + else + { + if ( _preMeshInfo ) + _preMeshInfo->FullLoadFromFile(); - TPythonDump() << _this() << ".ExportPartToMED( " << meshPart << ", r'" << file << "', " - << auto_groups << ", " << version << ", " << overwrite << " )"; + PrepareForWriting(file, overwrite); + + string aMeshName = "Mesh"; + SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy(); + if ( !aStudy->_is_nil() ) { + SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( aStudy, meshPart ); + if ( !SO->_is_nil() ) { + CORBA::String_var name = SO->GetName(); + aMeshName = name; + } + } + SMESH_MeshPartDS partDS( meshPart ); + _impl->ExportMED( file, aMeshName.c_str(), auto_groups, version, &partDS, autoDimension ); + } + pyDump << _this() << ".ExportPartToMED( " << meshPart << ", r'" << file << "', " + << auto_groups << ", " << version << ", " << overwrite << ", " + << autoDimension << " )"; } //================================================================================ @@ -2993,23 +3009,20 @@ void SMESH_Mesh_i::ExportGMF(::SMESH::SMESH_IDSource_ptr meshPart, //============================================================================= /*! - * Return implementation of SALOME_MED::MESH interfaces + * Return computation progress [0.,1] */ //============================================================================= -SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()throw(SALOME::SALOME_Exception) +CORBA::Double SMESH_Mesh_i::GetComputeProgress() { - Unexpect aCatch(SALOME_SalomeException); - if ( _preMeshInfo ) - _preMeshInfo->FullLoadFromFile(); + SMESH_TRY; - SMESH_MEDMesh_i *aMedMesh = new SMESH_MEDMesh_i(this); - SALOME_MED::MESH_var aMesh = aMedMesh->_this(); - return aMesh._retn(); + return _impl->GetComputeProgress(); + + SMESH_CATCH( SMESH::doNothing ); + return 0.; } -//============================================================================= - CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); @@ -4273,7 +4286,8 @@ void SMESH_Mesh_i::CreateGroupServants() // register CORBA object for persistence int nextId = _gen_i->RegisterObject( groupVar ); - if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId); + if(MYDEBUG) { MESSAGE( "Add group to map with id = "<< nextId); } + else { nextId = 0; } // avoid "unused variable" warning in release mode // publishing the groups in the study if ( !aStudy->_is_nil() ) { @@ -4323,11 +4337,11 @@ SMESH::ListOfGroups* SMESH_Mesh_i::GetGroups(const list& groupIDs) const */ //============================================================================= -SALOME_MED::MedFileInfo* SMESH_Mesh_i::GetMEDFileInfo() +SMESH::MedFileInfo* SMESH_Mesh_i::GetMEDFileInfo() { - SALOME_MED::MedFileInfo_var res( _medFileInfo ); + SMESH::MedFileInfo_var res( _medFileInfo ); if ( !res.operator->() ) { - res = new SALOME_MED::MedFileInfo; + res = new SMESH::MedFileInfo; res->fileName = ""; res->fileSize = res->major = res->minor = res->release = -1; } @@ -4466,7 +4480,7 @@ bool SMESH_Mesh_i::IsMeshInfoCorrect() //============================================================================= /*! - * \brief Returns statistic of mesh elements + * \brief Returns number of mesh elements per each \a EntityType */ //============================================================================= @@ -4490,7 +4504,33 @@ SMESH::long_array* SMESH_Mesh_i::GetMeshInfo() //============================================================================= /*! - * \brief Collect statistic of mesh elements given by iterator + * \brief Returns number of mesh elements per each \a ElementType + */ +//============================================================================= + +SMESH::long_array* SMESH_Mesh_i::GetNbElementsByType() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::NB_ELEMENT_TYPES); + for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++) + aRes[ i ] = 0; + + const SMDS_MeshInfo* meshInfo = 0; + if ( _preMeshInfo ) + meshInfo = _preMeshInfo; + else if ( SMESHDS_Mesh* meshDS = _impl->GetMeshDS() ) + meshInfo = & meshDS->GetMeshInfo(); + + if (meshInfo) + for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++) + aRes[i] = meshInfo->NbElements((SMDSAbs_ElementType)i); + + return aRes._retn(); +} + +//============================================================================= +/* + * Collect statistic of mesh elements given by iterator */ //============================================================================= @@ -4502,6 +4542,232 @@ void SMESH_Mesh_i::CollectMeshInfo(const SMDS_ElemIteratorPtr theItr, theInfo[ theItr->next()->GetEntityType() ]++; } +//============================================================================= +namespace /* Iterators used in SMESH_Mesh_i::GetElements(SMESH::SMESH_IDSource_var obj, + * SMESH::ElementType type) */ +{ + using namespace SMESH::Controls; + //----------------------------------------------------------------------------- + struct PredicateIterator : public SMDS_ElemIterator + { + SMDS_ElemIteratorPtr _elemIter; + PredicatePtr _predicate; + const SMDS_MeshElement* _elem; + + PredicateIterator( SMDS_ElemIteratorPtr iterator, + PredicatePtr predicate): + _elemIter(iterator), _predicate(predicate) + { + next(); + } + virtual bool more() + { + return _elem; + } + virtual const SMDS_MeshElement* next() + { + const SMDS_MeshElement* res = _elem; + _elem = 0; + while ( _elemIter->more() && !_elem ) + { + _elem = _elemIter->next(); + if ( _elem && ( !_predicate->IsSatisfy( _elem->GetID() ))) + _elem = 0; + } + return res; + } + }; + + //----------------------------------------------------------------------------- + struct IDSourceIterator : public SMDS_ElemIterator + { + const CORBA::Long* _idPtr; + const CORBA::Long* _idEndPtr; + SMESH::long_array_var _idArray; + const SMDS_Mesh* _mesh; + const SMDSAbs_ElementType _type; + const SMDS_MeshElement* _elem; + + IDSourceIterator( const SMDS_Mesh* mesh, + const CORBA::Long* ids, + const int nbIds, + SMDSAbs_ElementType type): + _idPtr( ids ), _idEndPtr( ids + nbIds ), _mesh( mesh ), _type( type ), _elem( 0 ) + { + if ( _idPtr && nbIds && _mesh ) + next(); + } + IDSourceIterator( const SMDS_Mesh* mesh, + SMESH::long_array* idArray, + SMDSAbs_ElementType type): + _idPtr( 0 ), _idEndPtr( 0 ), _idArray( idArray), _mesh( mesh ), _type( type ), _elem( 0 ) + { + if ( idArray && _mesh ) + { + _idPtr = &_idArray[0]; + _idEndPtr = _idPtr + _idArray->length(); + next(); + } + } + virtual bool more() + { + return _elem; + } + virtual const SMDS_MeshElement* next() + { + const SMDS_MeshElement* res = _elem; + _elem = 0; + while ( _idPtr < _idEndPtr && !_elem ) + { + if ( _type == SMDSAbs_Node ) + { + _elem = _mesh->FindNode( *_idPtr++ ); + } + else if ((_elem = _mesh->FindElement( *_idPtr++ )) && + _elem->GetType() != _type ) + { + _elem = 0; + } + } + return res; + } + }; + //----------------------------------------------------------------------------- + + struct NodeOfElemIterator : public SMDS_ElemIterator + { + TColStd_MapOfInteger _checkedNodeIDs; + SMDS_ElemIteratorPtr _elemIter; + SMDS_ElemIteratorPtr _nodeIter; + const SMDS_MeshElement* _node; + + NodeOfElemIterator( SMDS_ElemIteratorPtr iter ): _elemIter( iter ), _node( 0 ) + { + if ( _elemIter && _elemIter->more() ) + { + _nodeIter = _elemIter->next()->nodesIterator(); + next(); + } + } + virtual bool more() + { + return _node; + } + virtual const SMDS_MeshElement* next() + { + const SMDS_MeshElement* res = _node; + _node = 0; + while (( _elemIter->more() || _nodeIter->more() ) && !_node ) + { + if ( _nodeIter->more() ) + { + _node = _nodeIter->next(); + if ( !_checkedNodeIDs.Add( _node->GetID() )) + _node = 0; + } + else + { + _nodeIter = _elemIter->next()->nodesIterator(); + } + } + return res; + } + }; +} + +//============================================================================= +/* + * Return iterator on elements of given type in given object + */ +//============================================================================= + +SMDS_ElemIteratorPtr SMESH_Mesh_i::GetElements(SMESH::SMESH_IDSource_ptr theObject, + SMESH::ElementType theType) +{ + SMDS_ElemIteratorPtr elemIt; + bool typeOK = false; + SMDSAbs_ElementType elemType = SMDSAbs_ElementType( theType ); + + SMESH::SMESH_Mesh_var meshVar = theObject->GetMesh(); + SMESH_Mesh_i* mesh_i = SMESH::DownCast( meshVar ); + if ( !mesh_i ) return elemIt; + SMESHDS_Mesh* meshDS = mesh_i->GetImpl().GetMeshDS(); + + if ( SMESH::DownCast( theObject )) + { + elemIt = meshDS->elementsIterator( elemType ); + typeOK = true; + } + else if ( SMESH_subMesh_i* submesh_i = SMESH::DownCast( theObject )) + { + SMESHDS_SubMesh* sm = ((SMESHDS_Mesh*) meshDS)->MeshElements( submesh_i->GetId() ); + if ( sm ) + { + elemIt = sm->GetElements(); + if ( elemType != SMDSAbs_Node ) + { + typeOK = ( elemIt && elemIt->more() && elemIt->next()->GetType() == elemType ); + elemIt = typeOK ? sm->GetElements() : SMDS_ElemIteratorPtr(); + } + } + } + else if ( SMESH_GroupBase_i* group_i = SMESH::DownCast( theObject )) + { + SMESHDS_GroupBase* groupDS = group_i->GetGroupDS(); + if ( groupDS && ( groupDS->GetType() == elemType || elemType == SMDSAbs_Node )) + { + elemIt = groupDS->GetElements(); + typeOK = ( groupDS->GetType() == elemType ); + } + } + else if ( SMESH::Filter_i* filter_i = SMESH::DownCast( theObject )) + { + if ( filter_i->GetElementType() == theType || elemType == SMDSAbs_Node ) + { + SMESH::Predicate_i* pred_i = filter_i->GetPredicate_i(); + if ( pred_i && pred_i->GetPredicate() ) + { + SMDSAbs_ElementType filterType = SMDSAbs_ElementType( filter_i->GetElementType() ); + SMDS_ElemIteratorPtr allElemIt = meshDS->elementsIterator( filterType ); + elemIt = SMDS_ElemIteratorPtr( new PredicateIterator( allElemIt, pred_i->GetPredicate() )); + typeOK = ( filterType == elemType ); + } + } + } + else + { + SMESH::array_of_ElementType_var types = theObject->GetTypes(); + const bool isNodes = ( types->length() == 1 && types[0] == SMESH::NODE ); + if ( isNodes && elemType != SMDSAbs_Node ) + return elemIt; + if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theObject )) + { + int nbIds; + if ( CORBA::Long* ids = SMESH_MeshEditor_i::GetTemporaryIDs( theObject, nbIds )) + elemIt = SMDS_ElemIteratorPtr( new IDSourceIterator( meshDS, ids, nbIds, elemType )); + } + else + { + SMESH::long_array_var ids = theObject->GetIDs(); + elemIt = SMDS_ElemIteratorPtr( new IDSourceIterator( meshDS, ids._retn(), elemType )); + } + typeOK = ( isNodes == ( elemType == SMDSAbs_Node )); + } + + if ( elemIt && elemIt->more() && !typeOK ) + { + if ( elemType == SMDSAbs_Node ) + { + elemIt = SMDS_ElemIteratorPtr( new NodeOfElemIterator( elemIt )); + } + else + { + elemIt = SMDS_ElemIteratorPtr(); + } + } + return elemIt; +} + //============================================================================= namespace // Finding concurrent hypotheses //============================================================================= @@ -4549,9 +4815,9 @@ class SMESH_DimHyp //----------------------------------------------------------------------------- //! Constructors - SMESH_DimHyp(const SMESH_subMesh* theSubMesh, - const int theDim, - const TopoDS_Shape& theShape) + SMESH_DimHyp(const SMESH_subMesh* theSubMesh, + const int theDim, + const TopoDS_Shape& theShape) { _subMesh = (SMESH_subMesh*)theSubMesh; SetShape( theDim, theShape ); @@ -4563,7 +4829,7 @@ class SMESH_DimHyp const TopoDS_Shape& theShape) { _dim = theDim; - _ownDim = (int)SMESH_Gen::GetShapeDim(theShape); + _ownDim = SMESH_Gen::GetShapeDim(theShape); if (_dim >= _ownDim) _shapeMap.Add( theShape ); else { diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index f9df1792b..cead1dc06 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -34,7 +34,6 @@ #include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(SMESH_Hypothesis) #include CORBA_CLIENT_HEADER(GEOM_Gen) -#include CORBA_CLIENT_HEADER(MED) #include "SMESH_Hypothesis.hxx" #include "SMESH_Mesh.hxx" @@ -231,7 +230,8 @@ public: void ExportToMEDX( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION version, - CORBA::Boolean overwrite ) throw (SALOME::SALOME_Exception); + CORBA::Boolean overwrite, + CORBA::Boolean autoDimension=true) throw (SALOME::SALOME_Exception); void ExportToMED ( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION version ) throw (SALOME::SALOME_Exception); @@ -254,7 +254,8 @@ public: const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION version, - CORBA::Boolean overwrite) throw (SALOME::SALOME_Exception); + CORBA::Boolean overwrite, + CORBA::Boolean autoDim=true) throw (SALOME::SALOME_Exception); void ExportPartToDAT(SMESH::SMESH_IDSource_ptr meshPart, const char* file) throw (SALOME::SALOME_Exception); void ExportPartToUNV(SMESH::SMESH_IDSource_ptr meshPart, @@ -263,8 +264,7 @@ public: const char* file, CORBA::Boolean isascii) throw (SALOME::SALOME_Exception); - SALOME_MED::MESH_ptr GetMEDMesh() - throw (SALOME::SALOME_Exception); + CORBA::Double GetComputeProgress(); CORBA::Long NbNodes() throw (SALOME::SALOME_Exception); @@ -560,7 +560,7 @@ public: /*! * Returns information about imported MED file */ - virtual SALOME_MED::MedFileInfo* GetMEDFileInfo(); + virtual SMESH::MedFileInfo* GetMEDFileInfo(); /*! * Sets list of notebook variables used for Mesh operations separated by ":" symbol @@ -577,12 +577,6 @@ public: */ SMESH::string_array* GetLastParameters(); - /*! - * Collect statistic of mesh elements given by iterator - */ - static void CollectMeshInfo(const SMDS_ElemIteratorPtr theItr, - SMESH::long_array& theInfo); - /*! * \brief Return submesh objects list in meshing order */ @@ -593,17 +587,32 @@ public: virtual ::CORBA::Boolean SetMeshOrder(const SMESH::submesh_array_array& theSubMeshArray); + /*! + * Collect statistic of mesh elements given by iterator + */ + static void CollectMeshInfo(const SMDS_ElemIteratorPtr theItr, + SMESH::long_array& theInfo); + /*! + * \brief Return iterator on elements of given type in given object + */ + static SMDS_ElemIteratorPtr GetElements(SMESH::SMESH_IDSource_ptr obj, + SMESH::ElementType type); + // ========================= // SMESH_IDSource interface // ========================= virtual SMESH::long_array* GetIDs(); /*! - * Returns statistic of mesh elements - * Result array of number enityties + * Returns number of mesh elements of each \a EntityType + * Result array of number of elements per \a EntityType * Inherited from SMESH_IDSource */ virtual SMESH::long_array* GetMeshInfo(); + /*! + * Returns number of mesh elements of each \a ElementType + */ + virtual SMESH::long_array* GetNbElementsByType(); /*! * Returns types of elements it contains */ @@ -646,8 +655,8 @@ private: std::map _mapSubMeshIor; std::map _mapGroups; std::map _mapHypo; - SALOME_MED::MedFileInfo_var _medFileInfo; - SMESH_PreMeshInfo* _preMeshInfo; // mesh info before full loading from study file + SMESH::MedFileInfo_var _medFileInfo; + SMESH_PreMeshInfo* _preMeshInfo; // mesh info before full loading from study file SMESH_PreMeshInfo* & changePreMeshInfo() { return _preMeshInfo; } friend class SMESH_PreMeshInfo; diff --git a/src/SMESH_I/SMESH_subMesh_i.cxx b/src/SMESH_I/SMESH_subMesh_i.cxx index 3dab3db5b..30c8cc52a 100644 --- a/src/SMESH_I/SMESH_subMesh_i.cxx +++ b/src/SMESH_I/SMESH_subMesh_i.cxx @@ -207,53 +207,29 @@ CORBA::Long SMESH_subMesh_i::GetNumberOfNodes(CORBA::Boolean all) ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId]; SMESHDS_SubMesh* aSubMeshDS = aSubMesh->GetSubMeshDS(); - set nodeIds; - - // nodes are bound to shell instead of solid - TListOfSubMeshes smList; - if ( all && getSubMeshes( aSubMesh, smList )) + if ( aSubMeshDS && aSubMeshDS->IsComplexSubmesh() ) { - TListOfSubMeshes::iterator sm = smList.begin(); - for ( ; sm != smList.end(); ++sm ) + // sub-mesh on a geom group, always return all nodes + return aSubMeshDS->NbNodes(); + } + if ( aSubMeshDS && !all ) + { + // return anything we have + return aSubMeshDS->NbNodes(); + } + if ( all ) // get nodes from aSubMesh and all child sub-meshes + { + int nbNodes = 0; + SMESH_subMeshIteratorPtr smIt = aSubMesh->getDependsOnIterator( /*includeSelf=*/true ); + while ( smIt->more() ) { - SMDS_ElemIteratorPtr eIt = (*sm)->GetElements(); - if ( eIt->more() ) { - while ( eIt->more() ) { - const SMDS_MeshElement* anElem = eIt->next(); - SMDS_ElemIteratorPtr nIt = anElem->nodesIterator(); - while ( nIt->more() ) - nodeIds.insert( nIt->next()->GetID() ); - } - } else { - SMDS_NodeIteratorPtr nIt = (*sm)->GetNodes(); - while ( nIt->more() ) - nodeIds.insert( nIt->next()->GetID() ); - } + aSubMesh = smIt->next(); + if (( aSubMeshDS = aSubMesh->GetSubMeshDS() )) + nbNodes += aSubMeshDS->NbNodes(); } - return nodeIds.size(); } - if ( aSubMeshDS == NULL ) - return 0; - - if ( all ) { // all nodes of submesh elements - SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements(); - if ( eIt->more() ) { - while ( eIt->more() ) { - const SMDS_MeshElement* anElem = eIt->next(); - SMDS_ElemIteratorPtr nIt = anElem->nodesIterator(); - while ( nIt->more() ) - nodeIds.insert( nIt->next()->GetID() ); - } - } else { - SMDS_NodeIteratorPtr nIt = aSubMeshDS->GetNodes(); - while ( nIt->more() ) - nodeIds.insert( nIt->next()->GetID() ); - } - return nodeIds.size(); - } - - return aSubMeshDS->NbNodes(); + return aSubMeshDS ? aSubMeshDS->NbNodes() : 0; } //============================================================================= @@ -485,30 +461,6 @@ GEOM::GEOM_Object_ptr SMESH_subMesh_i::GetSubShape() return aShapeObj._retn(); } -//============================================================================= -/*! - * - */ -//============================================================================= -SALOME_MED::FAMILY_ptr SMESH_subMesh_i::GetFamily() - throw (SALOME::SALOME_Exception) -{ - Unexpect aCatch(SALOME_SalomeException); - if ( _preMeshInfo ) - _preMeshInfo->FullLoadFromFile(); - SALOME_MED::MESH_var MEDMesh = GetFather()->GetMEDMesh(); - - SALOME_MED::Family_array_var families = - MEDMesh->getFamilies(SALOME_MED::MED_NODE); - - for ( int i = 0; i < families->length(); i++ ) { - if ( families[i]->getIdentifier() == ( _localId ) ) - return families[i]; - } - - return SALOME_MED::FAMILY::_nil(); -} - //============================================================================= /*! * @@ -532,14 +484,13 @@ SMESH::ElementType SMESH_subMesh_i::GetElementType( const CORBA::Long id, const return GetFather()->GetElementType( id, iselem ); } - //============================================================================= -/*! - * Returns statistic of mesh elements - * Result array of number enityties - * Inherited from SMESH_IDSource +/* + * Returns number of mesh elements of each \a EntityType + * @return array of number of elements per \a EntityType */ //============================================================================= + SMESH::long_array* SMESH_subMesh_i::GetMeshInfo() { if ( _preMeshInfo ) @@ -564,6 +515,37 @@ SMESH::long_array* SMESH_subMesh_i::GetMeshInfo() return aRes._retn(); } +//======================================================================= +/* + * Returns number of mesh elements of each \a ElementType + */ +//======================================================================= + +SMESH::long_array* SMESH_subMesh_i::GetNbElementsByType() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::NB_ELEMENT_TYPES); + for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++) + if ( _preMeshInfo ) + aRes[ i ] = _preMeshInfo->NbElements( SMDSAbs_ElementType( i )); + else + aRes[ i ] = 0; + + if ( !_preMeshInfo ) + { + aRes[ SMESH::NODE ] = GetNumberOfNodes(true); + + ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId]; + if ( SMESHDS_SubMesh* smDS = aSubMesh->GetSubMeshDS() ) + { + SMDS_ElemIteratorPtr eIt = smDS->GetElements(); + if ( eIt->more() ) + aRes[ eIt->next()->GetType() ] = smDS->NbElements(); + } + } + return aRes._retn(); +} + //======================================================================= //function : GetTypes diff --git a/src/SMESH_I/SMESH_subMesh_i.hxx b/src/SMESH_I/SMESH_subMesh_i.hxx index 39d6d2677..5282620dd 100644 --- a/src/SMESH_I/SMESH_subMesh_i.hxx +++ b/src/SMESH_I/SMESH_subMesh_i.hxx @@ -34,7 +34,6 @@ #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Hypothesis) #include CORBA_CLIENT_HEADER(GEOM_Gen) -#include CORBA_CLIENT_HEADER(MED) #include "SALOME_GenericObj_i.hh" #include "SMESH_Mesh_i.hxx" @@ -80,9 +79,6 @@ public: CORBA::Long GetId(); - SALOME_MED::FAMILY_ptr GetFamily() - throw (SALOME::SALOME_Exception); - // ========================= // interface SMESH_IDSource @@ -92,11 +88,15 @@ public: */ virtual SMESH::long_array* GetIDs(); /*! - * Returns statistic of mesh elements - * Result array of number enityties + * Returns number of mesh elements of each \a EntityType + * Result array of number of elements per \a EntityType * Inherited from SMESH_IDSource */ virtual SMESH::long_array* GetMeshInfo(); + /*! + * Returns number of mesh elements of each \a ElementType + */ + virtual SMESH::long_array* GetNbElementsByType(); /*! * Returns types of elements it contains */ diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index a7ddf4191..852b6ba50 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -1567,14 +1567,21 @@ class Mesh: # @param version MED format version(MED_V2_1 or MED_V2_2) # @param overwrite boolean parameter for overwriting/not overwriting the file # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh + # @param autoDimension: if @c True (default), a space dimension of a MED mesh can be either + # - 1D if all mesh nodes lie on OX coordinate axis, or + # - 2D if all mesh nodes lie on XOY coordinate plane, or + # - 3D in the rest cases. + # + # If @a autoDimension is @c False, the space dimension is always 3. # @ingroup l2_impexp - def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None): + def ExportMED(self, f, auto_groups=0, version=MED_V2_2, + overwrite=1, meshPart=None, autoDimension=True): if meshPart: if isinstance( meshPart, list ): meshPart = self.GetIDSource( meshPart, SMESH.ALL ) - self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite ) + self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite, autoDimension) else: - self.mesh.ExportToMEDX(f, auto_groups, version, overwrite) + self.mesh.ExportToMEDX(f, auto_groups, version, overwrite, autoDimension) ## Exports the mesh in a file in SAUV format # @param f is the file name @@ -1965,12 +1972,6 @@ class Mesh: def GetIDSource(self, ids, elemType): return self.editor.MakeIDSource(ids, elemType) - ## Gets MED Mesh - # @return an instance of SALOME_MED::MESH - # @ingroup l1_auxiliary - def GetMEDMesh(self): - return self.mesh.GetMEDMesh() - # Get informations about mesh contents: # ------------------------------------ @@ -4133,12 +4134,30 @@ class Mesh: def GetLastCreatedElems(self): return self.editor.GetLastCreatedElems() - ## Clear sequences of nodes and elements created by mesh edition oparations + ## Clears sequences of nodes and elements created by mesh edition oparations # @ingroup l1_auxiliary def ClearLastCreated(self): self.editor.ClearLastCreated() - ## Creates a hole in a mesh by doubling the nodes of some particular elements + ## Creates Duplicates given elements, i.e. creates new elements based on the + # same nodes as the given ones. + # @param theElements - container of elements to duplicate. It can be a Mesh, + # sub-mesh, group, filter or a list of element IDs. + # @param theGroupName - a name of group to contain the generated elements. + # If a group with such a name already exists, the new elements + # are added to the existng group, else a new group is created. + # If \a theGroupName is empty, new elements are not added + # in any group. + # @return a group where the new elements are added. None if theGroupName == "". + # @ingroup l2_modif_edit + def DoubleElements(self, theElements, theGroupName=""): + if isinstance( theElements, Mesh ): + theElements = theElements.mesh + elif isinstance( theElements, list ): + theElements = self.GetIDSource( theElements, SMESH.ALL ) + return self.editor.DoubleElements(theElements, theGroupName) + + ## Creates a hole in a mesh by doubling the nodes of some particular elements # @param theNodes identifiers of nodes to be doubled # @param theModifiedElems identifiers of elements to be updated by the new (doubled) # nodes. If list of element identifiers is empty then nodes are doubled but diff --git a/src/SMESH_SWIG/smesh_algorithm.py b/src/SMESH_SWIG/smesh_algorithm.py index 6dc35e6b2..a81f825a6 100644 --- a/src/SMESH_SWIG/smesh_algorithm.py +++ b/src/SMESH_SWIG/smesh_algorithm.py @@ -290,21 +290,27 @@ class Mesh_Algorithm: # @param thickness total thickness of layers of quadrilaterals # @param numberOfLayers number of layers # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh - # @param ignoreEdges list of geometrical edge (or their ids) not to generate layers on + # @param edges list of geometrical edge (or their ids). + # Viscous layers are either generated on these edges or not, depending on + # the values of \a isEdgesToIgnore parameter. + # @param isEdgesToIgnore if \c True, the Viscous layers are not generated on the + # edges specified by the previous parameter (\a edges). # @ingroup l3_hypos_additi - def ViscousLayers2D(self, thickness, numberOfLayers, stretchFactor, ignoreEdges=[]): + def ViscousLayers2D(self, thickness, numberOfLayers, stretchFactor, + edges=[], isEdgesToIgnore=True ): if not isinstance(self.algo, SMESH._objref_SMESH_2D_Algo): raise TypeError, "ViscousLayers2D are supported by 2D algorithms only" if not "ViscousLayers2D" in self.GetCompatibleHypothesis(): raise TypeError, "ViscousLayers2D are not supported by %s"%self.algo.GetName() - if ignoreEdges and isinstance( ignoreEdges[0], geomBuilder.GEOM._objref_GEOM_Object ): - ignoreEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreEdges ] + if edges and isinstance( edges[0], geomBuilder.GEOM._objref_GEOM_Object ): + edges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in edges ] hyp = self.Hypothesis("ViscousLayers2D", - [thickness, numberOfLayers, stretchFactor, ignoreEdges]) + [thickness, numberOfLayers, stretchFactor, + edges, isEdgesToIgnore]) hyp.SetTotalThickness(thickness) hyp.SetNumberLayers(numberOfLayers) hyp.SetStretchFactor(stretchFactor) - hyp.SetIgnoreEdges(ignoreEdges) + hyp.SetEdges(edges, isEdgesToIgnore) return hyp ## Transform a list of ether edges or tuples (edge, 1st_vertex_of_edge) diff --git a/src/StdMeshers/StdMeshers_FaceSide.cxx b/src/StdMeshers/StdMeshers_FaceSide.cxx index 4d72e2f68..a0e7f0034 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.cxx +++ b/src/StdMeshers/StdMeshers_FaceSide.cxx @@ -358,13 +358,22 @@ const vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, { const UVPtStructVec& edgeUVPtStruct = proxySubMesh[iE]->GetUVPtStructVec(); std::copy( edgeUVPtStruct.begin(), edgeUVPtStruct.end(), & points[iPt] ); + // check orientation + double du1 = edgeUVPtStruct.back().param - edgeUVPtStruct[0].param; + double du2 = myLast[iE] - myFirst[iE]; + if ( du1 * du2 < 0 ) + { + std::reverse( & points[iPt], & points[iPt + edgeUVPtStruct.size()]); + for ( size_t i = 0; i < edgeUVPtStruct.size(); ++i ) + points[iPt+i].normParam = 1. - points[iPt+i].normParam; + } // update normalized params if ( myEdge.size() > 1 ) { for ( size_t i = 0; i < edgeUVPtStruct.size(); ++i, ++iPt ) { UVPtStruct & uvPt = points[iPt]; - uvPt.normParam = prevNormPar + uvPt.normParam * paramSize; - uvPt.x = uvPt.y = uvPt.normParam; + uvPt.normParam = prevNormPar + uvPt.normParam * paramSize; + uvPt.x = uvPt.y = uvPt.normParam; } --iPt; // to point to the 1st VERTEX of the next EDGE } diff --git a/src/StdMeshers/StdMeshers_Prism_3D.cxx b/src/StdMeshers/StdMeshers_Prism_3D.cxx index 149e35a0e..33f261506 100644 --- a/src/StdMeshers/StdMeshers_Prism_3D.cxx +++ b/src/StdMeshers/StdMeshers_Prism_3D.cxx @@ -2118,15 +2118,17 @@ bool StdMeshers_Prism_3D::initPrism(Prism_3D::TPrismTopo& thePrism, bool StdMeshers_PrismAsBlock::Init(SMESH_MesherHelper* helper, const Prism_3D::TPrismTopo& thePrism) { + myHelper = helper; + SMESHDS_Mesh* meshDS = myHelper->GetMeshDS(); + SMESH_Mesh* mesh = myHelper->GetMesh(); + if ( mySide ) { delete mySide; mySide = 0; } vector< TSideFace* > sideFaces( NB_WALL_FACES, 0 ); vector< pair< double, double> > params( NB_WALL_FACES ); - mySide = new TSideFace( sideFaces, params ); + mySide = new TSideFace( *mesh, sideFaces, params ); - myHelper = helper; - SMESHDS_Mesh* meshDS = myHelper->GetMeshDS(); SMESH_Block::init(); myShapeIDMap.Clear(); @@ -2265,14 +2267,14 @@ bool StdMeshers_PrismAsBlock::Init(SMESH_MesherHelper* helper, for ( int i = 0; i < nbSplit; ++i ) { double f = ( isForward ? params[ i ] : params[ nbSplit - i-1 ]); double l = ( isForward ? params[ i+1 ] : params[ nbSplit - i ]); - TSideFace* comp = new TSideFace( myHelper, wallFaceIds[ iSide ], + TSideFace* comp = new TSideFace( *mesh, wallFaceIds[ iSide ], thePrism.myWallQuads[ iE ], *botE, &myParam2ColumnMaps[ iE ], f, l ); mySide->SetComponent( iSide++, comp ); } } else { - TSideFace* comp = new TSideFace( myHelper, wallFaceIds[ iSide ], + TSideFace* comp = new TSideFace( *mesh, wallFaceIds[ iSide ], thePrism.myWallQuads[ iE ], *botE, &myParam2ColumnMaps[ iE ]); mySide->SetComponent( iSide++, comp ); @@ -2293,19 +2295,19 @@ bool StdMeshers_PrismAsBlock::Init(SMESH_MesherHelper* helper, list< TopoDS_Edge >::const_iterator botE = thePrism.myBottomEdges.begin(); for ( iE = 0; iE < nbExraFaces; ++iE, ++botE ) { - components[ iE ] = new TSideFace( myHelper, wallFaceIds[ iSide ], + components[ iE ] = new TSideFace( *mesh, wallFaceIds[ iSide ], thePrism.myWallQuads[ iE ], *botE, &myParam2ColumnMaps[ iE ]); double u1 = u0 + edgeLength[ iE ] / sumLen; params[ iE ] = make_pair( u0 , u1 ); u0 = u1; } - mySide->SetComponent( iSide++, new TSideFace( components, params )); + mySide->SetComponent( iSide++, new TSideFace( *mesh, components, params )); // fill the rest faces for ( ; iE < nbEdges; ++iE, ++botE ) { - TSideFace* comp = new TSideFace( myHelper, wallFaceIds[ iSide ], + TSideFace* comp = new TSideFace( *mesh, wallFaceIds[ iSide ], thePrism.myWallQuads[ iE ], *botE, &myParam2ColumnMaps[ iE ]); mySide->SetComponent( iSide++, comp ); @@ -2583,7 +2585,7 @@ bool StdMeshers_PrismAsBlock::IsForwardEdge(SMESHDS_Mesh* meshDS, */ //================================================================================ -StdMeshers_PrismAsBlock::TSideFace::TSideFace(SMESH_MesherHelper* helper, +StdMeshers_PrismAsBlock::TSideFace::TSideFace(SMESH_Mesh& mesh, const int faceID, const Prism_3D::TQuadList& quadList, const TopoDS_Edge& baseEdge, @@ -2592,20 +2594,20 @@ StdMeshers_PrismAsBlock::TSideFace::TSideFace(SMESH_MesherHelper* helper, const double last): myID( faceID ), myParamToColumnMap( columnsMap ), - myHelper( helper ) + myHelper( mesh ) { myParams.resize( 1 ); myParams[ 0 ] = make_pair( first, last ); mySurface = PSurface( new BRepAdaptor_Surface( quadList.front()->face )); myBaseEdge = baseEdge; - myIsForward = StdMeshers_PrismAsBlock::IsForwardEdge( myHelper->GetMeshDS(), + myIsForward = StdMeshers_PrismAsBlock::IsForwardEdge( myHelper.GetMeshDS(), *myParamToColumnMap, myBaseEdge, myID ); if ( quadList.size() > 1 ) // side is vertically composite { // fill myShapeID2Surf map to enable finding a right surface by any sub-shape ID - SMESHDS_Mesh* meshDS = myHelper->GetMeshDS(); + SMESHDS_Mesh* meshDS = myHelper.GetMeshDS(); TopTools_IndexedDataMapOfShapeListOfShape subToFaces; Prism_3D::TQuadList::const_iterator quad = quadList.begin(); @@ -2630,19 +2632,20 @@ StdMeshers_PrismAsBlock::TSideFace::TSideFace(SMESH_MesherHelper* helper, //================================================================================ /*! - * \brief Constructor of complex side face + * \brief Constructor of a complex side face */ //================================================================================ StdMeshers_PrismAsBlock::TSideFace:: -TSideFace(const vector< TSideFace* >& components, +TSideFace(SMESH_Mesh& mesh, + const vector< TSideFace* >& components, const vector< pair< double, double> > & params) :myID( components[0] ? components[0]->myID : 0 ), myParamToColumnMap( 0 ), myParams( params ), myIsForward( true ), myComponents( components ), - myHelper( components[0] ? components[0]->myHelper : 0 ) + myHelper( mesh ) {} //================================================================================ /*! @@ -2651,17 +2654,17 @@ TSideFace(const vector< TSideFace* >& components, */ //================================================================================ -StdMeshers_PrismAsBlock::TSideFace::TSideFace( const TSideFace& other ) +StdMeshers_PrismAsBlock::TSideFace::TSideFace( const TSideFace& other ): + myID ( other.myID ), + myParamToColumnMap ( other.myParamToColumnMap ), + mySurface ( other.mySurface ), + myBaseEdge ( other.myBaseEdge ), + myShapeID2Surf ( other.myShapeID2Surf ), + myParams ( other.myParams ), + myIsForward ( other.myIsForward ), + myComponents ( other.myComponents.size() ), + myHelper ( *other.myHelper.GetMesh() ) { - myID = other.myID; - mySurface = other.mySurface; - myBaseEdge = other.myBaseEdge; - myParams = other.myParams; - myIsForward = other.myIsForward; - myHelper = other.myHelper; - myParamToColumnMap = other.myParamToColumnMap; - - myComponents.resize( other.myComponents.size()); for (int i = 0 ; i < myComponents.size(); ++i ) myComponents[ i ] = new TSideFace( *other.myComponents[ i ]); } @@ -2864,16 +2867,16 @@ gp_Pnt StdMeshers_PrismAsBlock::TSideFace::Value(const Standard_Real U, } else { - TopoDS_Shape s = myHelper->GetSubShapeByNode( nn[0], myHelper->GetMeshDS() ); + TopoDS_Shape s = myHelper.GetSubShapeByNode( nn[0], myHelper.GetMeshDS() ); if ( s.ShapeType() != TopAbs_EDGE ) - s = myHelper->GetSubShapeByNode( nn[2], myHelper->GetMeshDS() ); + s = myHelper.GetSubShapeByNode( nn[2], myHelper.GetMeshDS() ); if ( s.ShapeType() == TopAbs_EDGE ) edge = TopoDS::Edge( s ); } if ( !edge.IsNull() ) { - double u1 = myHelper->GetNodeU( edge, nn[0] ); - double u3 = myHelper->GetNodeU( edge, nn[2] ); + double u1 = myHelper.GetNodeU( edge, nn[0] ); + double u3 = myHelper.GetNodeU( edge, nn[2] ); double u = u1 * ( 1 - hR ) + u3 * hR; TopLoc_Location loc; double f,l; Handle(Geom_Curve) curve = BRep_Tool::Curve( edge,loc,f,l ); @@ -2909,10 +2912,10 @@ gp_Pnt StdMeshers_PrismAsBlock::TSideFace::Value(const Standard_Real U, } if ( notFaceID2 ) // no nodes of FACE and nodes are on different FACEs { - SMESHDS_Mesh* meshDS = myHelper->GetMeshDS(); - TopoDS_Shape face = myHelper->GetCommonAncestor( meshDS->IndexToShape( notFaceID1 ), + SMESHDS_Mesh* meshDS = myHelper.GetMeshDS(); + TopoDS_Shape face = myHelper.GetCommonAncestor( meshDS->IndexToShape( notFaceID1 ), meshDS->IndexToShape( notFaceID2 ), - *myHelper->GetMesh(), + *myHelper.GetMesh(), TopAbs_FACE ); if ( face.IsNull() ) throw SALOME_Exception("StdMeshers_PrismAsBlock::TSideFace::Value() face.IsNull()"); @@ -2923,12 +2926,12 @@ gp_Pnt StdMeshers_PrismAsBlock::TSideFace::Value(const Standard_Real U, } } - gp_XY uv1 = myHelper->GetNodeUV( mySurface->Face(), nn[0], nn[2]); - gp_XY uv2 = myHelper->GetNodeUV( mySurface->Face(), nn[1], nn[3]); + gp_XY uv1 = myHelper.GetNodeUV( mySurface->Face(), nn[0], nn[2]); + gp_XY uv2 = myHelper.GetNodeUV( mySurface->Face(), nn[1], nn[3]); gp_XY uv12 = uv1 * ( 1 - vR ) + uv2 * vR; - gp_XY uv3 = myHelper->GetNodeUV( mySurface->Face(), nn[2], nn[0]); - gp_XY uv4 = myHelper->GetNodeUV( mySurface->Face(), nn[3], nn[1]); + gp_XY uv3 = myHelper.GetNodeUV( mySurface->Face(), nn[2], nn[0]); + gp_XY uv4 = myHelper.GetNodeUV( mySurface->Face(), nn[3], nn[1]); gp_XY uv34 = uv3 * ( 1 - vR ) + uv4 * vR; gp_XY uv = uv12 * ( 1 - hR ) + uv34 * hR; @@ -2957,7 +2960,7 @@ TopoDS_Edge StdMeshers_PrismAsBlock::TSideFace::GetEdge(const int iEdge) const } TopoDS_Shape edge; const SMDS_MeshNode* node = 0; - SMESHDS_Mesh * meshDS = myHelper->GetMesh()->GetMeshDS(); + SMESHDS_Mesh * meshDS = myHelper.GetMesh()->GetMeshDS(); TNodeColumn* column; switch ( iEdge ) { @@ -2965,7 +2968,7 @@ TopoDS_Edge StdMeshers_PrismAsBlock::TSideFace::GetEdge(const int iEdge) const case BOTTOM_EDGE: column = & (( ++myParamToColumnMap->begin())->second ); node = ( iEdge == TOP_EDGE ) ? column->back() : column->front(); - edge = myHelper->GetSubShapeByNode ( node, meshDS ); + edge = myHelper.GetSubShapeByNode ( node, meshDS ); if ( edge.ShapeType() == TopAbs_VERTEX ) { column = & ( myParamToColumnMap->begin()->second ); node = ( iEdge == TOP_EDGE ) ? column->back() : column->front(); @@ -2980,7 +2983,7 @@ TopoDS_Edge StdMeshers_PrismAsBlock::TSideFace::GetEdge(const int iEdge) const else column = & ( myParamToColumnMap->begin()->second ); if ( column->size() > 0 ) - edge = myHelper->GetSubShapeByNode( (*column)[ 1 ], meshDS ); + edge = myHelper.GetSubShapeByNode( (*column)[ 1 ], meshDS ); if ( edge.IsNull() || edge.ShapeType() == TopAbs_VERTEX ) node = column->front(); break; @@ -2992,10 +2995,10 @@ TopoDS_Edge StdMeshers_PrismAsBlock::TSideFace::GetEdge(const int iEdge) const // find edge by 2 vertices TopoDS_Shape V1 = edge; - TopoDS_Shape V2 = myHelper->GetSubShapeByNode( node, meshDS ); + TopoDS_Shape V2 = myHelper.GetSubShapeByNode( node, meshDS ); if ( !V2.IsNull() && V2.ShapeType() == TopAbs_VERTEX && !V2.IsSame( V1 )) { - TopoDS_Shape ancestor = myHelper->GetCommonAncestor( V1, V2, *myHelper->GetMesh(), TopAbs_EDGE); + TopoDS_Shape ancestor = myHelper.GetCommonAncestor( V1, V2, *myHelper.GetMesh(), TopAbs_EDGE); if ( !ancestor.IsNull() ) return TopoDS::Edge( ancestor ); } @@ -3035,8 +3038,8 @@ int StdMeshers_PrismAsBlock::TSideFace::InsertSubShapes(TBlockShapes& shapeMap) GetColumns(0, col1, col2 ); const SMDS_MeshNode* node0 = col1->second.front(); const SMDS_MeshNode* node1 = col1->second.back(); - TopoDS_Shape v0 = myHelper->GetSubShapeByNode( node0, myHelper->GetMeshDS()); - TopoDS_Shape v1 = myHelper->GetSubShapeByNode( node1, myHelper->GetMeshDS()); + TopoDS_Shape v0 = myHelper.GetSubShapeByNode( node0, myHelper.GetMeshDS()); + TopoDS_Shape v1 = myHelper.GetSubShapeByNode( node1, myHelper.GetMeshDS()); if ( v0.ShapeType() == TopAbs_VERTEX ) { nbInserted += SMESH_Block::Insert( v0, vertIdVec[ 0 ], shapeMap); } @@ -3049,8 +3052,8 @@ int StdMeshers_PrismAsBlock::TSideFace::InsertSubShapes(TBlockShapes& shapeMap) GetColumns(1, col1, col2 ); node0 = col2->second.front(); node1 = col2->second.back(); - v0 = myHelper->GetSubShapeByNode( node0, myHelper->GetMeshDS()); - v1 = myHelper->GetSubShapeByNode( node1, myHelper->GetMeshDS()); + v0 = myHelper.GetSubShapeByNode( node0, myHelper.GetMeshDS()); + v1 = myHelper.GetSubShapeByNode( node1, myHelper.GetMeshDS()); if ( v0.ShapeType() == TopAbs_VERTEX ) { nbInserted += SMESH_Block::Insert( v0, vertIdVec[ 0 ], shapeMap); } @@ -3242,7 +3245,7 @@ gp_Pnt2d StdMeshers_PrismAsBlock::TPCurveOnHorFaceAdaptor::Value(const Standard_ { TParam2ColumnIt u_col1, u_col2; double r = mySide->GetColumns( U, u_col1, u_col2 ); - gp_XY uv1 = mySide->GetNodeUV( myFace, u_col1->second[ myZ ]); - gp_XY uv2 = mySide->GetNodeUV( myFace, u_col2->second[ myZ ]); + gp_XY uv1 = mySide->GetNodeUV( myFace, u_col1->second[ myZ ], u_col2->second[ myZ ]); + gp_XY uv2 = mySide->GetNodeUV( myFace, u_col2->second[ myZ ], u_col1->second[ myZ ]); return uv1 * ( 1 - r ) + uv2 * r; } diff --git a/src/StdMeshers/StdMeshers_Prism_3D.hxx b/src/StdMeshers/StdMeshers_Prism_3D.hxx index 226a5006b..2229c7b1e 100644 --- a/src/StdMeshers/StdMeshers_Prism_3D.hxx +++ b/src/StdMeshers/StdMeshers_Prism_3D.hxx @@ -270,16 +270,17 @@ private: std::vector< std::pair< double, double> > myParams; bool myIsForward; std::vector< TSideFace* > myComponents; - SMESH_MesherHelper * myHelper; + SMESH_MesherHelper myHelper; public: - TSideFace( SMESH_MesherHelper* helper, + TSideFace( SMESH_Mesh& mesh, const int faceID, const Prism_3D::TQuadList& quadList, const TopoDS_Edge& baseEdge, TParam2ColumnMap* columnsMap, const double first = 0.0, const double last = 1.0); - TSideFace( const std::vector< TSideFace* >& components, + TSideFace( SMESH_Mesh& mesh, + const std::vector< TSideFace* >& components, const std::vector< std::pair< double, double> > & params); TSideFace( const TSideFace& other ); ~TSideFace(); @@ -287,8 +288,8 @@ private: { return ( NbComponents() > 0 || myParams[0].first != 0. || myParams[0].second != 1. ); } int FaceID() const { return myID; } TParam2ColumnMap* GetColumns() const { return myParamToColumnMap; } - gp_XY GetNodeUV(const TopoDS_Face& F, const SMDS_MeshNode* n) const - { return myHelper->GetNodeUV( F, n ); } + gp_XY GetNodeUV(const TopoDS_Face& F, const SMDS_MeshNode* n, const SMDS_MeshNode* n2=0) const + { return ((SMESH_MesherHelper&) myHelper).SetSubShape(F), myHelper.GetNodeUV( F, n, n2 ); } const TopoDS_Edge & BaseEdge() const { return myBaseEdge; } int ColumnHeight() const { if ( NbComponents() ) return GetComponent(0)->GetColumns()->begin()->second.size(); diff --git a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx index 3e9f5c462..de59b2654 100644 --- a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx +++ b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx @@ -2100,7 +2100,7 @@ bool StdMeshers_ProjectionUtils::MakeComputed(SMESH_subMesh * sm, const int iter string algoType = algo->GetName(); if ( algoType.substr(0, 11) != "Projection_") - return gen->Compute( *mesh, shape ); + return gen->Compute( *mesh, shape, /*shapeOnly=*/true ); // try to compute source mesh @@ -2132,7 +2132,7 @@ bool StdMeshers_ProjectionUtils::MakeComputed(SMESH_subMesh * sm, const int iter } } if ( srcShape.IsNull() ) // no projection source defined - return gen->Compute( *mesh, shape ); + return gen->Compute( *mesh, shape, /*shapeOnly=*/true ); if ( srcShape.IsSame( shape )) RETURN_BAD_RESULT("Projection from self"); @@ -2141,7 +2141,7 @@ bool StdMeshers_ProjectionUtils::MakeComputed(SMESH_subMesh * sm, const int iter srcMesh = mesh; if ( MakeComputed( srcMesh->GetSubMesh( srcShape ), iterationNb + 1 ) && - gen->Compute( *mesh, shape )) + gen->Compute( *mesh, shape, /*shapeOnly=*/true )) return sm->IsMeshComputed(); return false; diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx index 23512af43..ef7e6100b 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -254,6 +254,17 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, Smooth( quad ); return ok; } + if ( n1 != n3 && n2 != n4 ) + error( COMPERR_WARNING, + "To use 'Reduced' transition, " + "two opposite sides should have same number of segments, " + "but actual number of segments is different on all sides. " + "'Standard' transion has been used."); + else + error( COMPERR_WARNING, + "To use 'Reduced' transition, " + "two opposite sides should have an even difference in number of segments. " + "'Standard' transion has been used."); } // set normalized grid on unit square in parametric domain @@ -2316,19 +2327,20 @@ namespace * Implementation of Reduced algorithm (meshing with quadrangles only) */ //======================================================================= + bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, const TopoDS_Shape& aShape, FaceQuadStruct::Ptr quad) { - SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); - const TopoDS_Face& F = TopoDS::Face(aShape); + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + const TopoDS_Face& F = TopoDS::Face(aShape); Handle(Geom_Surface) S = BRep_Tool::Surface(F); - int i,j,geomFaceID = meshDS->ShapeToIndex(F); + int i,j,geomFaceID = meshDS->ShapeToIndex(F); - int nb = quad->side[0]->NbPoints(); - int nr = quad->side[1]->NbPoints(); - int nt = quad->side[2]->NbPoints(); - int nl = quad->side[3]->NbPoints(); + int nb = quad->side[0]->NbPoints(); // bottom + int nr = quad->side[1]->NbPoints(); // right + int nt = quad->side[2]->NbPoints(); // top + int nl = quad->side[3]->NbPoints(); // left // Simple Reduce 10->8->6->4 (3 steps) Multiple Reduce 10->4 (1 step) // @@ -2374,13 +2386,21 @@ bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, } // number of rows and columns - int nrows = nr1 - 1; + int nrows = nr1 - 1; int ncol_top = nt1 - 1; int ncol_bot = nb1 - 1; // number of rows needed to reduce ncol_bot to ncol_top using simple 3->1 "tree" (see below) - int nrows_tree31 = int( log( (double)(ncol_bot / ncol_top) ) / log((double) 3 )); // = log x base 3 + int nrows_tree31 = + int( ceil( log( double(ncol_bot) / ncol_top) / log( 3.))); // = log x base 3 if ( nrows < nrows_tree31 ) + { MultipleReduce = true; + error( COMPERR_WARNING, + SMESH_Comment("To use 'Reduced' transition, " + "number of face rows should be at least ") + << nrows_tree31 << ". Actual number of face rows is " << nrows << ". " + "'Quadrangle preference (reversed)' transion has been used."); + } } if (MultipleReduce) { // == ComputeQuadPref QUAD_QUADRANGLE_PREF_REVERSED @@ -2624,7 +2644,7 @@ bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, // add bottom nodes (first columns) for (i=2; iAddFace(NodesC.Value(i,j), NodesC.Value(i+1,j), + SMDS_MeshFace* F = + myHelper->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j), NodesC.Value(i+1,j+1), NodesC.Value(i,j+1)); - if (F) meshDS->SetMeshElementOnShape(F, geomFaceID); + if (F) meshDS->SetMeshElementOnShape(F, geomFaceID); } } - // TODO ??? } // end Multiple Reduce implementation else { // Simple Reduce (!MultipleReduce) //========================================================= diff --git a/src/StdMeshers/StdMeshers_RadialPrism_3D.cxx b/src/StdMeshers/StdMeshers_RadialPrism_3D.cxx index 7b26457d1..450dbb3c7 100644 --- a/src/StdMeshers/StdMeshers_RadialPrism_3D.cxx +++ b/src/StdMeshers/StdMeshers_RadialPrism_3D.cxx @@ -316,11 +316,10 @@ public: static TNodeDistributor* GetDistributor(SMESH_Mesh& aMesh) { const int myID = -1000; - map < int, SMESH_1D_Algo * > & algoMap = aMesh.GetGen()->_map1D_Algo; - map < int, SMESH_1D_Algo * >::iterator id_algo = algoMap.find( myID ); - if ( id_algo == algoMap.end() ) - return new TNodeDistributor( myID, 0, aMesh.GetGen() ); - return static_cast< TNodeDistributor* >( id_algo->second ); + TNodeDistributor* myHyp = dynamic_cast( aMesh.GetHypothesis( myID )); + if ( !myHyp ) + myHyp = new TNodeDistributor( myID, 0, aMesh.GetGen() ); + return myHyp; } // ----------------------------------------------------------------------------- bool Compute( vector< double > & positions, diff --git a/src/StdMeshers/StdMeshers_RadialQuadrangle_1D2D.cxx b/src/StdMeshers/StdMeshers_RadialQuadrangle_1D2D.cxx index 838a8fbbc..fde94e9ae 100644 --- a/src/StdMeshers/StdMeshers_RadialQuadrangle_1D2D.cxx +++ b/src/StdMeshers/StdMeshers_RadialQuadrangle_1D2D.cxx @@ -295,12 +295,11 @@ public: // ----------------------------------------------------------------------------- static TNodeDistributor* GetDistributor(SMESH_Mesh& aMesh) { - const int myID = -1000; - map < int, SMESH_1D_Algo * > & algoMap = aMesh.GetGen()->_map1D_Algo; - map < int, SMESH_1D_Algo * >::iterator id_algo = algoMap.find( myID ); - if ( id_algo == algoMap.end() ) - return new TNodeDistributor( myID, 0, aMesh.GetGen() ); - return static_cast< TNodeDistributor* >( id_algo->second ); + const int myID = -1001; + TNodeDistributor* myHyp = dynamic_cast( aMesh.GetHypothesis( myID )); + if ( !myHyp ) + myHyp = new TNodeDistributor( myID, 0, aMesh.GetGen() ); + return myHyp; } // ----------------------------------------------------------------------------- //! Computes distribution of nodes on a straight line ending at pIn and pOut diff --git a/src/StdMeshers/StdMeshers_ViscousLayers.cxx b/src/StdMeshers/StdMeshers_ViscousLayers.cxx index 61365b4d6..d4a595ec5 100644 --- a/src/StdMeshers/StdMeshers_ViscousLayers.cxx +++ b/src/StdMeshers/StdMeshers_ViscousLayers.cxx @@ -567,20 +567,17 @@ virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const // StdMeshers_ViscousLayers::StdMeshers_ViscousLayers(int hypId, int studyId, SMESH_Gen* gen) :SMESH_Hypothesis(hypId, studyId, gen), - _nbLayers(1), _thickness(1), _stretchFactor(1) + _isToIgnoreShapes(18), _nbLayers(1), _thickness(1), _stretchFactor(1) { _name = StdMeshers_ViscousLayers::GetHypType(); _param_algo_dim = -3; // auxiliary hyp used by 3D algos } // -------------------------------------------------------------------------------- -void StdMeshers_ViscousLayers::SetBndShapesToIgnore(const std::vector& faceIds) +void StdMeshers_ViscousLayers::SetBndShapes(const std::vector& faceIds, bool toIgnore) { - if ( faceIds != _ignoreBndShapeIds ) - _ignoreBndShapeIds = faceIds, NotifySubMeshesHypothesisModification(); -} // -------------------------------------------------------------------------------- -bool StdMeshers_ViscousLayers::IsIgnoredShape(const int shapeID) const -{ - return ( find( _ignoreBndShapeIds.begin(), _ignoreBndShapeIds.end(), shapeID ) - != _ignoreBndShapeIds.end() ); + if ( faceIds != _shapeIds ) + _shapeIds = faceIds, NotifySubMeshesHypothesisModification(); + if ( _isToIgnoreShapes != toIgnore ) + _isToIgnoreShapes = toIgnore, NotifySubMeshesHypothesisModification(); } // -------------------------------------------------------------------------------- void StdMeshers_ViscousLayers::SetTotalThickness(double thickness) { @@ -638,17 +635,22 @@ std::ostream & StdMeshers_ViscousLayers::SaveTo(std::ostream & save) save << " " << _nbLayers << " " << _thickness << " " << _stretchFactor - << " " << _ignoreBndShapeIds.size(); - for ( unsigned i = 0; i < _ignoreBndShapeIds.size(); ++i ) - save << " " << _ignoreBndShapeIds[i]; + << " " << _shapeIds.size(); + for ( unsigned i = 0; i < _shapeIds.size(); ++i ) + save << " " << _shapeIds[i]; + save << " " << !_isToIgnoreShapes; // negate to keep the behavior in old studies. return save; } // -------------------------------------------------------------------------------- std::istream & StdMeshers_ViscousLayers::LoadFrom(std::istream & load) { - int nbFaces, faceID; + int nbFaces, faceID, shapeToTreat; load >> _nbLayers >> _thickness >> _stretchFactor >> nbFaces; - while ( _ignoreBndShapeIds.size() < nbFaces && load >> faceID ) - _ignoreBndShapeIds.push_back( faceID ); + while ( _shapeIds.size() < nbFaces && load >> faceID ) + _shapeIds.push_back( faceID ); + if ( load >> shapeToTreat ) + _isToIgnoreShapes = !shapeToTreat; + else + _isToIgnoreShapes = true; // old behavior return load; } // -------------------------------------------------------------------------------- bool StdMeshers_ViscousLayers::SetParametersByMesh(const SMESH_Mesh* theMesh, @@ -1072,7 +1074,7 @@ bool _ViscousBuilder::findFacesWithLayers() vector ignoreFaces; for ( unsigned i = 0; i < _sdVec.size(); ++i ) { - vector ids = _sdVec[i]._hyp->GetBndShapesToIgnore(); + vector ids = _sdVec[i]._hyp->GetBndShapes(); for ( unsigned i = 0; i < ids.size(); ++i ) { const TopoDS_Shape& s = getMeshDS()->IndexToShape( ids[i] ); diff --git a/src/StdMeshers/StdMeshers_ViscousLayers.hxx b/src/StdMeshers/StdMeshers_ViscousLayers.hxx index 9794ec54d..b62e165b0 100644 --- a/src/StdMeshers/StdMeshers_ViscousLayers.hxx +++ b/src/StdMeshers/StdMeshers_ViscousLayers.hxx @@ -39,10 +39,11 @@ class STDMESHERS_EXPORT StdMeshers_ViscousLayers : public SMESH_Hypothesis public: StdMeshers_ViscousLayers(int hypId, int studyId, SMESH_Gen* gen); - // Set boundary shapes to exclude from treatment, faces in 3D, edges in 2D - void SetBndShapesToIgnore(const std::vector& shapeIds); - std::vector GetBndShapesToIgnore() const { return _ignoreBndShapeIds; } - bool IsIgnoredShape(const int shapeID) const; + // Set boundary shapes, faces in 3D, edges in 2D, either to exclude from + // treatment or to make the Viscous Layers on + void SetBndShapes(const std::vector& shapeIds, bool toIgnore); + std::vector GetBndShapes() const { return _shapeIds; } + bool IsToIgnoreShapes() const { return _isToIgnoreShapes; } // Set total thickness of layers of prisms void SetTotalThickness(double thickness); @@ -86,7 +87,8 @@ public: private: - std::vector _ignoreBndShapeIds; + std::vector _shapeIds; + bool _isToIgnoreShapes; int _nbLayers; double _thickness; double _stretchFactor; diff --git a/src/StdMeshers/StdMeshers_ViscousLayers2D.cxx b/src/StdMeshers/StdMeshers_ViscousLayers2D.cxx index e2e26dd38..4edb0163b 100644 --- a/src/StdMeshers/StdMeshers_ViscousLayers2D.cxx +++ b/src/StdMeshers/StdMeshers_ViscousLayers2D.cxx @@ -69,7 +69,10 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -332,11 +335,11 @@ namespace VISCOUS_2D const StdMeshers_ViscousLayers2D* theHyp); SMESH_ComputeErrorPtr GetError() const { return _error; } // does it's job - SMESH_ProxyMesh::Ptr Compute(); + SMESH_ProxyMesh::Ptr Compute(const TopoDS_Shape& theShapeHypAssignedTo); private: - bool findEdgesWithLayers(); + bool findEdgesWithLayers(const TopoDS_Shape& theShapeHypAssignedTo); bool makePolyLines(); bool inflate(); bool fixCollisions(); @@ -398,15 +401,60 @@ namespace VISCOUS_2D * \brief Returns StdMeshers_ViscousLayers2D for the FACE */ const StdMeshers_ViscousLayers2D* findHyp(SMESH_Mesh& theMesh, - const TopoDS_Face& theFace) + const TopoDS_Face& theFace, + TopoDS_Shape* assignedTo=0) { SMESH_HypoFilter hypFilter ( SMESH_HypoFilter::HasName( StdMeshers_ViscousLayers2D::GetHypType() )); const SMESH_Hypothesis * hyp = - theMesh.GetHypothesis( theFace, hypFilter, /*ancestors=*/true ); + theMesh.GetHypothesis( theFace, hypFilter, /*ancestors=*/true, assignedTo ); return dynamic_cast< const StdMeshers_ViscousLayers2D* > ( hyp ); } + //================================================================================ + /*! + * \brief Returns ids of EDGEs not to create Viscous Layers on + * \param [in] theHyp - the hypothesis, holding edges either to ignore or not to. + * \param [in] theFace - the FACE whose EDGEs are checked. + * \param [in] theMesh - the mesh. + * \param [in,out] theEdgeIds - container returning EDGEs to ignore. + * \return int - number of found EDGEs of the FACE. + */ + //================================================================================ + + int getEdgesToIgnore( const StdMeshers_ViscousLayers2D* theHyp, + const TopoDS_Shape& theFace, + const SMESHDS_Mesh* theMesh, + set< int > & theEdgeIds) + { + int nbToEdgesIgnore = 0; + vector ids = theHyp->GetBndShapes(); + if ( theHyp->IsToIgnoreShapes() ) // EDGEs to ignore are given + { + for ( size_t i = 0; i < ids.size(); ++i ) + { + const TopoDS_Shape& E = theMesh->IndexToShape( ids[i] ); + if ( !E.IsNull() && + E.ShapeType() == TopAbs_EDGE && + SMESH_MesherHelper::IsSubShape( E, theFace )) + { + theEdgeIds.insert( ids[i] ); + ++nbToEdgesIgnore; + } + } + } + else // EDGEs to make the Viscous Layers on are given + { + TopExp_Explorer E( theFace, TopAbs_EDGE ); + for ( ; E.More(); E.Next(), ++nbToEdgesIgnore ) + theEdgeIds.insert( theMesh->ShapeToIndex( E.Current() )); + + for ( size_t i = 0; i < ids.size(); ++i ) + nbToEdgesIgnore -= theEdgeIds.erase( ids[i] ); + } + return nbToEdgesIgnore; + } + } // namespace VISCOUS_2D //================================================================================ @@ -432,11 +480,12 @@ StdMeshers_ViscousLayers2D::Compute(SMESH_Mesh& theMesh, { SMESH_ProxyMesh::Ptr pm; - const StdMeshers_ViscousLayers2D* vlHyp = VISCOUS_2D::findHyp( theMesh, theFace ); + TopoDS_Shape hypAssignedTo; + const StdMeshers_ViscousLayers2D* vlHyp = VISCOUS_2D::findHyp( theMesh, theFace, &hypAssignedTo ); if ( vlHyp ) { VISCOUS_2D::_ViscousBuilder2D builder( theMesh, theFace, vlHyp ); - pm = builder.Compute(); + pm = builder.Compute( hypAssignedTo ); SMESH_ComputeErrorPtr error = builder.GetError(); if ( error && !error->IsOK() ) theMesh.GetSubMesh( theFace )->GetComputeError() = error; @@ -495,9 +544,9 @@ _ViscousBuilder2D::_ViscousBuilder2D(SMESH_Mesh& theMesh, _mesh( &theMesh ), _face( theFace ), _hyp( theHyp ), _helper( theMesh ) { _helper.SetSubShape( _face ); - _helper.SetElementsOnShape(true); + _helper.SetElementsOnShape( true ); - //_face.Orientation( TopAbs_FORWARD ); + _face.Orientation( TopAbs_FORWARD ); // 2D logic works only in this case _surface = BRep_Tool::Surface( _face ); if ( _hyp ) @@ -512,7 +561,6 @@ _ViscousBuilder2D::_ViscousBuilder2D(SMESH_Mesh& theMesh, bool _ViscousBuilder2D::error(const string& text ) { - cout << "_ViscousBuilder2D::error " << text << endl; _error->myName = COMPERR_ALGO_FAILED; _error->myComment = string("Viscous layers builder 2D: ") + text; if ( SMESH_subMesh* sm = _mesh->GetSubMesh( _face ) ) @@ -522,8 +570,9 @@ bool _ViscousBuilder2D::error(const string& text ) _error->myAlgo = smError->myAlgo; smError = _error; } - //makeGroupOfLE(); // debug - +#ifdef _DEBUG_ + cout << "_ViscousBuilder2D::error " << text << endl; +#endif return false; } @@ -533,14 +582,14 @@ bool _ViscousBuilder2D::error(const string& text ) */ //================================================================================ -SMESH_ProxyMesh::Ptr _ViscousBuilder2D::Compute() +SMESH_ProxyMesh::Ptr _ViscousBuilder2D::Compute(const TopoDS_Shape& theShapeHypAssignedTo) { _error = SMESH_ComputeError::New(COMPERR_OK); _faceSideVec = StdMeshers_FaceSide::GetFaceWires( _face, *_mesh, true, _error ); if ( !_error->IsOK() ) return _proxyMesh; - if ( !findEdgesWithLayers() ) // analysis of a shape + if ( !findEdgesWithLayers(theShapeHypAssignedTo) ) // analysis of a shape return _proxyMesh; if ( ! makePolyLines() ) // creation of fronts @@ -569,53 +618,49 @@ SMESH_ProxyMesh::Ptr _ViscousBuilder2D::Compute() */ //================================================================================ -bool _ViscousBuilder2D::findEdgesWithLayers() +bool _ViscousBuilder2D::findEdgesWithLayers(const TopoDS_Shape& theShapeHypAssignedTo) { // collect all EDGEs to ignore defined by hyp - int nbMyEdgesIgnored = 0; - vector ids = _hyp->GetBndShapesToIgnore(); - for ( size_t i = 0; i < ids.size(); ++i ) - { - const TopoDS_Shape& s = getMeshDS()->IndexToShape( ids[i] ); - if ( !s.IsNull() && s.ShapeType() == TopAbs_EDGE ) { - _ignoreShapeIds.insert( ids[i] ); - nbMyEdgesIgnored += ( _helper.IsSubShape( s, _face )); - } - } + int nbMyEdgesIgnored = getEdgesToIgnore( _hyp, _face, getMeshDS(), _ignoreShapeIds ); // check all EDGEs of the _face int totalNbEdges = 0; + TopTools_IndexedDataMapOfShapeListOfShape facesOfEdgeMap; + TopExp::MapShapesAndAncestors( theShapeHypAssignedTo, + TopAbs_EDGE, TopAbs_FACE, facesOfEdgeMap); for ( size_t iWire = 0; iWire < _faceSideVec.size(); ++iWire ) { StdMeshers_FaceSidePtr wire = _faceSideVec[ iWire ]; totalNbEdges += wire->NbEdges(); for ( int iE = 0; iE < wire->NbEdges(); ++iE ) - if ( _helper.NbAncestors( wire->Edge( iE ), *_mesh, TopAbs_FACE ) > 1 ) + { + const TopTools_ListOfShape& faceList = facesOfEdgeMap.FindFromKey( wire->Edge( iE )); + if ( faceList.Extent() > 1 ) { // ignore internal EDGEs (shared by several FACEs) - TGeomID edgeID = getMeshDS()->ShapeToIndex( wire->Edge( iE )); + const TGeomID edgeID = wire->EdgeID( iE ); _ignoreShapeIds.insert( edgeID ); // check if ends of an EDGE are to be added to _noShrinkVert - PShapeIteratorPtr faceIt = _helper.GetAncestors( wire->Edge( iE ), *_mesh, TopAbs_FACE ); - while ( const TopoDS_Shape* neighbourFace = faceIt->next() ) + TopTools_ListIteratorOfListOfShape faceIt( faceList ); + for ( ; faceIt.More(); faceIt.Next() ) { - if ( neighbourFace->IsSame( _face )) continue; - SMESH_Algo* algo = _mesh->GetGen()->GetAlgo( *_mesh, *neighbourFace ); + const TopoDS_Shape& neighbourFace = faceIt.Value(); + if ( neighbourFace.IsSame( _face )) continue; + SMESH_Algo* algo = _mesh->GetGen()->GetAlgo( *_mesh, neighbourFace ); if ( !algo ) continue; const StdMeshers_ViscousLayers2D* viscHyp = 0; const list & allHyps = - algo->GetUsedHypothesis(*_mesh, *neighbourFace, /*noAuxiliary=*/false); + algo->GetUsedHypothesis(*_mesh, neighbourFace, /*noAuxiliary=*/false); list< const SMESHDS_Hypothesis *>::const_iterator hyp = allHyps.begin(); for ( ; hyp != allHyps.end() && !viscHyp; ++hyp ) viscHyp = dynamic_cast( *hyp ); set neighbourIgnoreEdges; - if (viscHyp) { - vector ids = _hyp->GetBndShapesToIgnore(); - neighbourIgnoreEdges.insert( ids.begin(), ids.end() ); - } + if (viscHyp) + getEdgesToIgnore( viscHyp, neighbourFace, getMeshDS(), neighbourIgnoreEdges ); + for ( int iV = 0; iV < 2; ++iV ) { TopoDS_Vertex vertex = iV ? wire->LastVertex(iE) : wire->FirstVertex(iE); @@ -626,13 +671,32 @@ bool _ViscousBuilder2D::findEdgesWithLayers() PShapeIteratorPtr edgeIt = _helper.GetAncestors( vertex, *_mesh, TopAbs_EDGE ); while ( const TopoDS_Shape* edge = edgeIt->next() ) if ( !edge->IsSame( wire->Edge( iE )) && + _helper.IsSubShape( *edge, neighbourFace ) && neighbourIgnoreEdges.count( getMeshDS()->ShapeToIndex( *edge ))) + { _noShrinkVert.insert( getMeshDS()->ShapeToIndex( vertex )); + break; + } } } } } + } } + + // add VERTEXes w/o layers to _ignoreShapeIds (this is used by toShrinkForAdjacent()) + for ( size_t iWire = 0; iWire < _faceSideVec.size(); ++iWire ) + { + StdMeshers_FaceSidePtr wire = _faceSideVec[ iWire ]; + for ( int iE = 0; iE < wire->NbEdges(); ++iE ) + { + TGeomID edge1 = wire->EdgeID( iE ); + TGeomID edge2 = wire->EdgeID( iE+1 ); + if ( _ignoreShapeIds.count( edge1 ) && _ignoreShapeIds.count( edge2 )) + _ignoreShapeIds.insert( getMeshDS()->ShapeToIndex( wire->LastVertex( iE ))); + } + } + return ( nbMyEdgesIgnored < totalNbEdges ); } @@ -773,7 +837,8 @@ bool _ViscousBuilder2D::makePolyLines() } } } - _thickness = Min( _hyp->GetTotalThickness(), maxPossibleThick ); + if ( maxPossibleThick > 0. ) + _thickness = Min( _hyp->GetTotalThickness(), maxPossibleThick ); } // Adjust _LayerEdge's at _PolyLine's extremities @@ -1713,11 +1778,12 @@ bool _ViscousBuilder2D::toShrinkForAdjacent( const TopoDS_Face& adjFace, const TopoDS_Edge& E, const TopoDS_Vertex& V) { - if ( const StdMeshers_ViscousLayers2D* vlHyp = findHyp( *_mesh, adjFace )) + TopoDS_Shape hypAssignedTo; + if ( const StdMeshers_ViscousLayers2D* vlHyp = findHyp( *_mesh, adjFace, &hypAssignedTo )) { VISCOUS_2D::_ViscousBuilder2D builder( *_mesh, adjFace, vlHyp ); builder._faceSideVec = StdMeshers_FaceSide::GetFaceWires( adjFace, *_mesh, true, _error ); - builder.findEdgesWithLayers(); + builder.findEdgesWithLayers( hypAssignedTo ); PShapeIteratorPtr edgeIt = _helper.GetAncestors( V, *_mesh, TopAbs_EDGE ); while ( const TopoDS_Shape* edgeAtV = edgeIt->next() ) @@ -1732,7 +1798,7 @@ bool _ViscousBuilder2D::toShrinkForAdjacent( const TopoDS_Face& adjFace, } return false; } - + //================================================================================ /*! * \brief Make faces @@ -1741,6 +1807,10 @@ bool _ViscousBuilder2D::toShrinkForAdjacent( const TopoDS_Face& adjFace, bool _ViscousBuilder2D::refine() { + // find out orientation of faces to create + bool isReverse = + ( _helper.GetSubShapeOri( _mesh->GetShapeToMesh(), _face ) == TopAbs_REVERSED ); + // store a proxyMesh in a sub-mesh // make faces on each _PolyLine vector< double > layersHeight; @@ -1845,6 +1915,8 @@ bool _ViscousBuilder2D::refine() nbN = innerNodes.size() - ( hasRightNode || hasOwnRightNode ); L._leftNodes .reserve( _hyp->GetNumberLayers() ); L._rightNodes.reserve( _hyp->GetNumberLayers() ); + int cur = 0, prev = -1; // to take into account orientation of _face + if ( isReverse ) std::swap( cur, prev ); for ( int iF = 0; iF < _hyp->GetNumberLayers(); ++iF ) // loop on layers of faces { // get accumulated length of intermediate segments @@ -1878,10 +1950,9 @@ bool _ViscousBuilder2D::refine() if ( !hasOwnRightNode ) L._rightNodes.push_back( innerNodes.back() ); // create faces - // TODO care of orientation for ( size_t i = 1; i < innerNodes.size(); ++i ) - if ( SMDS_MeshElement* f = _helper.AddFace( outerNodes[ i-1 ], outerNodes[ i ], - innerNodes[ i ], innerNodes[ i-1 ])) + if ( SMDS_MeshElement* f = _helper.AddFace( outerNodes[ i+prev ], outerNodes[ i+cur ], + innerNodes[ i+cur ], innerNodes[ i+prev ])) L._newFaces.insert( L._newFaces.end(), f ); outerNodes.swap( innerNodes ); @@ -1898,11 +1969,14 @@ bool _ViscousBuilder2D::refine() continue; for ( size_t i = 1; i < lNodes.size(); ++i ) - _helper.AddFace( lNodes[ i-1 ], rNodes[ i-1 ], - rNodes[ i ], lNodes[ i ]); + _helper.AddFace( lNodes[ i+prev ], rNodes[ i+prev ], + rNodes[ i+cur ], lNodes[ i+cur ]); const UVPtStruct& ptOnVertex = points[ isR ? L._lastPntInd : L._firstPntInd ]; - _helper.AddFace( ptOnVertex.node, rNodes[ 0 ], lNodes[ 0 ]); + if ( isReverse ) + _helper.AddFace( ptOnVertex.node, lNodes[ 0 ], rNodes[ 0 ]); + else + _helper.AddFace( ptOnVertex.node, rNodes[ 0 ], lNodes[ 0 ]); } // Fill the _ProxyMeshOfFace diff --git a/src/StdMeshersGUI/Makefile.am b/src/StdMeshersGUI/Makefile.am index 8fc16589c..da78f1cd9 100644 --- a/src/StdMeshersGUI/Makefile.am +++ b/src/StdMeshersGUI/Makefile.am @@ -35,7 +35,8 @@ salomeinclude_HEADERS = \ StdMeshersGUI_LayerDistributionParamWdg.h \ StdMeshersGUI_FixedPointsParamWdg.h \ StdMeshersGUI_SubShapeSelectorWdg.h \ - StdMeshersGUI_CartesianParamCreator.h + StdMeshersGUI_CartesianParamCreator.h \ + StdMeshersGUI_RadioButtonsGrpWdg.h # Libraries targets lib_LTLIBRARIES = libStdMeshersGUI.la @@ -51,7 +52,8 @@ dist_libStdMeshersGUI_la_SOURCES = \ StdMeshersGUI_LayerDistributionParamWdg.cxx \ StdMeshersGUI_FixedPointsParamWdg.cxx \ StdMeshersGUI_SubShapeSelectorWdg.cxx \ - StdMeshersGUI_CartesianParamCreator.cxx + StdMeshersGUI_CartesianParamCreator.cxx \ + StdMeshersGUI_RadioButtonsGrpWdg.cxx MOC_FILES = \ StdMeshersGUI_StdHypothesisCreator_moc.cxx \ @@ -63,7 +65,8 @@ MOC_FILES = \ StdMeshersGUI_LayerDistributionParamWdg_moc.cxx \ StdMeshersGUI_FixedPointsParamWdg_moc.cxx \ StdMeshersGUI_SubShapeSelectorWdg_moc.cxx \ - StdMeshersGUI_CartesianParamCreator_moc.cxx + StdMeshersGUI_CartesianParamCreator_moc.cxx \ + StdMeshersGUI_RadioButtonsGrpWdg_moc.cxx nodist_libStdMeshersGUI_la_SOURCES= \ $(MOC_FILES) diff --git a/src/StdMeshersGUI/StdMeshersGUI_RadioButtonsGrpWdg.cxx b/src/StdMeshersGUI/StdMeshersGUI_RadioButtonsGrpWdg.cxx new file mode 100644 index 000000000..cca80aa17 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_RadioButtonsGrpWdg.cxx @@ -0,0 +1,82 @@ +// Copyright (C) 2007-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 "StdMeshersGUI_RadioButtonsGrpWdg.h" + +#include +#include +#include +#include + +#define SPACING 6 +#define MARGIN 11 + +//================================================================================ +/*! + * \brief Creates a QGroupBox with a given title + */ +//================================================================================ + +StdMeshersGUI_RadioButtonsGrpWdg::StdMeshersGUI_RadioButtonsGrpWdg( const QString& title ) + : QGroupBox( title ) +{ + myButtonGrp = new QButtonGroup( this ); +} + +//================================================================================ +/*! + * \brief Creates a given nubmer of button labels with given labels (QString's) + */ +//================================================================================ + +void StdMeshersGUI_RadioButtonsGrpWdg::setButtonLabels( const QStringList& buttonLabels ) +{ + QVBoxLayout* layout = new QVBoxLayout( this ); + layout->setSpacing(SPACING); + layout->setMargin(MARGIN); + + for ( int id = 0; id < buttonLabels.size(); ++id ) + { + QRadioButton* button = new QRadioButton( buttonLabels.at(id), this ); + layout->addWidget( button ); + myButtonGrp->addButton( button, id ); + } +} + +//================================================================================ +/*! + * \brief Set checked a radio button with a give id. + */ +//================================================================================ + +void StdMeshersGUI_RadioButtonsGrpWdg::setChecked(int id) +{ + if ( QAbstractButton* but = myButtonGrp->button( id )) + but->setChecked( true ); +} + +//================================================================================ +/*! + * \brief Return id (zero based) of a checked radio button + */ +//================================================================================ + +int StdMeshersGUI_RadioButtonsGrpWdg::checkedId () const +{ + return myButtonGrp->checkedId(); +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_RadioButtonsGrpWdg.h b/src/StdMeshersGUI/StdMeshersGUI_RadioButtonsGrpWdg.h new file mode 100644 index 000000000..fd8be84a2 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_RadioButtonsGrpWdg.h @@ -0,0 +1,53 @@ +// Copyright (C) 2007-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 STDMESHERSGUI_RadioButtonsGrpWdg_H +#define STDMESHERSGUI_RadioButtonsGrpWdg_H + +// SMESH includes +#include "SMESH_StdMeshersGUI.hxx" + +// Qt includes +#include + +class QButtonGroup; +class QStringList; + +/*! + * \brief A QGroupBox holding several radio buttons + */ +class STDMESHERSGUI_EXPORT StdMeshersGUI_RadioButtonsGrpWdg : public QGroupBox +{ + Q_OBJECT + +public: + StdMeshersGUI_RadioButtonsGrpWdg (const QString& title); + + void setButtonLabels( const QStringList& buttonLabels ); + + void setChecked(int id); + + int checkedId() const; + + QButtonGroup* getButtonGroup() { return myButtonGrp; } + +private: + QButtonGroup* myButtonGrp; +}; + +#endif // STDMESHERSGUI_RadioButtonsGrpWdg_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index 1c6007296..493235b15 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -39,6 +39,7 @@ #include "StdMeshersGUI_ObjectReferenceParamWdg.h" #include "StdMeshersGUI_QuadrangleParamWdg.h" #include "StdMeshersGUI_SubShapeSelectorWdg.h" +#include "StdMeshersGUI_RadioButtonsGrpWdg.h" #include @@ -58,6 +59,7 @@ #include #include #include +#include const double VALUE_MAX = 1.0e+15, // COORD_MAX VALUE_MAX_2 = VALUE_MAX * VALUE_MAX, @@ -708,10 +710,10 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const h->SetVarParameter( params[2].text(), "SetStretchFactor" ); h->SetStretchFactor ( params[2].myValue.toDouble() ); - if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg = - widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 )) + if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg = + widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 )) { - h->SetIgnoreEdges( idsWg->GetListOfIDs() ); + h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() ); } } else if( hypType()=="QuadrangleParams" ) @@ -1198,7 +1200,19 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry(); if ( !aMainEntry.isEmpty() ) { - item.myName = tr( "SMESH_EDGES_WO_LAYERS" ); + item.myName = tr("TO_IGNORE_EDGES_OR_NOT"); + p.append( item ); + + StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg(""); + ignoreWdg->setButtonLabels ( QStringList() + << tr("NOT_TO_IGNORE_EDGES") + << tr("TO_IGNORE_EDGES") ); + ignoreWdg->setChecked( h->GetIsToIgnoreEdges() ); + connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged())); + customWidgets()->append( ignoreWdg ); + + item.myName = + tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ); p.append( item ); StdMeshersGUI_SubShapeSelectorWdg* idsWg = @@ -1206,7 +1220,7 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const idsWg->SetGeomShapeEntry( aMainEntry ); idsWg->SetMainShapeEntry( aMainEntry ); - idsWg->SetListOfIDs( h->GetIgnoreEdges() ); + idsWg->SetListOfIDs( h->GetEdges() ); idsWg->showPreview( true ); customWidgets()->append ( idsWg ); } @@ -1489,6 +1503,13 @@ bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & pa //param.myValue = w->isChecked(); return true; } + if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" )) + { + const StdMeshersGUI_RadioButtonsGrpWdg * w = + static_cast( widget ); + param.myValue = w->checkedId(); + return true; + } return false; } @@ -1539,6 +1560,14 @@ void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget) toCopyGroups->setEnabled( true ); } } + else if ( hypType() == "ViscousLayers2D" && paramWidget->inherits("QButtonGroup")) + { + if ( QLabel* label = getLabel(4) ) + { + bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( 3 )->checkedId(); + label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" )); + } + } } //================================================================================ diff --git a/src/StdMeshersGUI/StdMeshers_msg_en.ts b/src/StdMeshersGUI/StdMeshers_msg_en.ts index 2b506311f..cfc5d535d 100644 --- a/src/StdMeshersGUI/StdMeshers_msg_en.ts +++ b/src/StdMeshersGUI/StdMeshers_msg_en.ts @@ -1,6 +1,21 @@ + + StdMeshersGUI_StdHypothesisCreator + + TO_IGNORE_EDGES_OR_NOT + Specified edges are + + + NOT_TO_IGNORE_EDGES + Edges with layers (walls) + + + TO_IGNORE_EDGES + Edges without layers (inlets and oulets) + + @default @@ -170,8 +185,16 @@ SMESH_EDGES_WO_LAYERS - Edges without layers -(inlets and oulets) + Edges without layers + + + SMESH_FACES_WITH_LAYERS + Faces with layers +(walls) + + + SMESH_EDGES_WITH_LAYERS + Edges with layers SMESH_MAX_LENGTH_TITLE diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx index bd709e593..e26f4cae5 100644 --- a/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx @@ -77,15 +77,48 @@ StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i() */ //================================================================================ -void StdMeshers_ViscousLayers2D_i::SetIgnoreEdges(const ::SMESH::long_array& edgeIDs) -throw ( SALOME::SALOME_Exception ) +void StdMeshers_ViscousLayers2D_i::SetEdges(const ::SMESH::long_array& edgeIDs, + CORBA::Boolean toIgnore) + throw ( SALOME::SALOME_Exception ) { vector ids( edgeIDs.length() ); for ( unsigned i = 0; i < ids.size(); ++i ) if (( ids[i] = edgeIDs[i] ) < 1 ) THROW_SALOME_CORBA_EXCEPTION( "Invalid edge id", SALOME::BAD_PARAM ); - GetImpl()->SetBndShapesToIgnore( ids ); - SMESH::TPythonDump() << _this() << ".SetIgnoreEdges( " << edgeIDs << " )"; + + GetImpl()->SetBndShapes( ids, toIgnore ); + + SMESH::TPythonDump() << _this() << ".SetEdges( " << edgeIDs << ", " << toIgnore << " )"; +} + +//================================================================================ +/*! + * \brief + */ +//================================================================================ + +void StdMeshers_ViscousLayers2D_i::SetIgnoreEdges(const ::SMESH::long_array& edgeIDs) + throw ( SALOME::SALOME_Exception ) +{ + SMESH::TPythonDump pyDump; + this->SetEdges( edgeIDs, true ); + pyDump<< _this() << ".SetIgnoreEdges( " << edgeIDs << " )"; +} + +//================================================================================ +/*! + * \brief + */ +//================================================================================ + +SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetEdges() +{ + vector idsVec = GetImpl()->GetBndShapes(); + SMESH::long_array_var ids = new SMESH::long_array; + ids->length( idsVec.size() ); + for ( unsigned i = 0; i < idsVec.size(); ++i ) + ids[i] = idsVec[i]; + return ids._retn(); } //================================================================================ @@ -96,12 +129,20 @@ throw ( SALOME::SALOME_Exception ) SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetIgnoreEdges() { - vector idsVec = GetImpl()->GetBndShapesToIgnore(); - SMESH::long_array_var ids = new SMESH::long_array; - ids->length( idsVec.size() ); - for ( unsigned i = 0; i < idsVec.size(); ++i ) - ids[i] = idsVec[i]; - return ids._retn(); + if ( GetImpl()->IsToIgnoreShapes() ) + return this->GetEdges(); + return new SMESH::long_array; +} + +//================================================================================ +/*! + * \brief + */ +//================================================================================ + +CORBA::Boolean StdMeshers_ViscousLayers2D_i::GetIsToIgnoreEdges() +{ + return GetImpl()->IsToIgnoreShapes(); } //================================================================================ diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx index 68723365c..91b072146 100644 --- a/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx @@ -48,9 +48,14 @@ class STDMESHERS_I_EXPORT StdMeshers_ViscousLayers2D_i: // Destructor virtual ~StdMeshers_ViscousLayers2D_i(); - void SetIgnoreEdges(const ::SMESH::long_array& edgeIDs) throw ( SALOME::SALOME_Exception ); + void SetIgnoreEdges(const SMESH::long_array& edgeIDs) throw ( SALOME::SALOME_Exception ); SMESH::long_array* GetIgnoreEdges(); + void SetEdges(const SMESH::long_array& edgeIDs, + CORBA::Boolean toIgnore) throw (SALOME::SALOME_Exception); + SMESH::long_array* GetEdges(); + CORBA::Boolean GetIsToIgnoreEdges(); + void SetTotalThickness(::CORBA::Double thickness) throw ( SALOME::SALOME_Exception ); ::CORBA::Double GetTotalThickness(); diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx b/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx index 99f7f1d6b..5ad82c7ec 100644 --- a/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx @@ -85,7 +85,7 @@ throw ( SALOME::SALOME_Exception ) for ( unsigned i = 0; i < ids.size(); ++i ) if (( ids[i] = faceIDs[i] ) < 1 ) THROW_SALOME_CORBA_EXCEPTION( "Invalid face id", SALOME::BAD_PARAM ); - GetImpl()->SetBndShapesToIgnore( ids ); + GetImpl()->SetBndShapes( ids, /*toIgnore=*/true ); SMESH::TPythonDump() << _this() << ".SetIgnoreFaces( " << faceIDs << " )"; } @@ -97,11 +97,14 @@ throw ( SALOME::SALOME_Exception ) SMESH::long_array* StdMeshers_ViscousLayers_i::GetIgnoreFaces() { - vector idsVec = GetImpl()->GetBndShapesToIgnore(); SMESH::long_array_var ids = new SMESH::long_array; - ids->length( idsVec.size() ); - for ( unsigned i = 0; i < idsVec.size(); ++i ) - ids[i] = idsVec[i]; + if ( GetImpl()->IsToIgnoreShapes() ) + { + vector idsVec = GetImpl()->GetBndShapes(); + ids->length( idsVec.size() ); + for ( unsigned i = 0; i < idsVec.size(); ++i ) + ids[i] = idsVec[i]; + } return ids._retn(); } diff --git a/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py b/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py new file mode 100644 index 000000000..abff9ed9c --- /dev/null +++ b/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py @@ -0,0 +1,604 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 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 +# 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 +# + +# Modules Python +# Modules Eficas + +import os, subprocess +from MGCleanerPlugDialog import Ui_MGCleanerPlugDialog +from MGCleanerMonViewText import MGCleanerMonViewText +from PyQt4.QtGui import * +from PyQt4.QtCore import * + + +class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget): + """ + """ + def __init__(self): + QWidget.__init__(self) + self.setupUi(self) + self.connecterSignaux() + self.fichierIn="" + self.fichierOut="" + self.MeshIn="" + self.commande="" + self.num=1 + self.__selectedMesh=None + + # complex whith QResources: not used + # The icon are supposed to be located in the $SMESH_ROOT_DIR/share/salome/resources/smesh folder, + # other solution could be in the same folder than this python module file: + # iconfolder=os.path.dirname(os.path.abspath(__file__)) + + self.iconfolder=os.environ["SMESH_ROOT_DIR"]+"/share/salome/resources/smesh" + #print "MGCleanerMonPlugDialog iconfolder",iconfolder + icon = QIcon() + icon.addFile(os.path.join(self.iconfolder,"select1.png")) + self.PB_LoadHyp.setIcon(icon) + self.PB_LoadHyp.setToolTip("hypothesis from Salome Object Browser") + self.PB_SaveHyp.setIcon(icon) + self.PB_SaveHyp.setToolTip("hypothesis to Salome Object Browser") + self.PB_MeshSmesh.setIcon(icon) + self.PB_MeshSmesh.setToolTip("source mesh from Salome Object Browser") + icon = QIcon() + icon.addFile(os.path.join(self.iconfolder,"open.png")) + self.PB_ParamsFileExplorer.setIcon(icon) + self.PB_Load.setIcon(icon) + self.PB_Load.setToolTip("hypothesis from file") + self.PB_Save.setIcon(icon) + self.PB_Save.setToolTip("hypothesis to file") + self.PB_MeshFile.setIcon(icon) + self.PB_MeshFile.setToolTip("source mesh from a file in disk") + + #Ces parametres ne sont pas remis à rien par le clean + self.paramsFile= os.path.abspath(os.path.join(os.environ["HOME"],".MGCleaner.dat")) + self.LE_ParamsFile.setText(self.paramsFile) + self.LE_MeshFile.setText("") + self.LE_MeshSmesh.setText("") + + v1=QDoubleValidator(self) + v1.setBottom(0.) + #v1.setTop(10000.) + v1.setDecimals(4) + self.SP_MinHoleSize.setValidator(v1) + self.SP_MinHoleSize.titleForWarning="MinHoleSize" + + v2=QDoubleValidator(self) + v2.setBottom(0.) + #v2.setTop(10000.) + v2.setDecimals(4) + self.SP_ToleranceDisplacement.setValidator(v2) + self.SP_ToleranceDisplacement.titleForWarning="ToleranceDisplacement" + + v3=QDoubleValidator(self) + v3.setBottom(0.) + #v3.setTop(10000.) + v3.setDecimals(4) + self.SP_ResolutionLength.setValidator(v3) + self.SP_ResolutionLength.titleForWarning="ResolutionLength" + + v4=QDoubleValidator(self) + v4.setBottom(0.) + #v4.setTop(10000.) + v4.setDecimals(4) + self.SP_OverlapDistance.setValidator(v4) + self.SP_OverlapDistance.titleForWarning="OverlapDistance" + + self.resize(800, 500) + self.clean() + + def connecterSignaux(self) : + self.connect(self.PB_Cancel,SIGNAL("clicked()"),self.PBCancelPressed) + self.connect(self.PB_Default,SIGNAL("clicked()"),self.clean) + self.connect(self.PB_Help,SIGNAL("clicked()"),self.PBHelpPressed) + self.connect(self.PB_OK,SIGNAL("clicked()"),self.PBOKPressed) + + self.connect(self.PB_Load,SIGNAL("clicked()"),self.PBLoadPressed) + self.connect(self.PB_Save,SIGNAL("clicked()"),self.PBSavePressed) + self.connect(self.PB_LoadHyp,SIGNAL("clicked()"),self.PBLoadHypPressed) + self.connect(self.PB_SaveHyp,SIGNAL("clicked()"),self.PBSaveHypPressed) + + self.connect(self.PB_MeshFile,SIGNAL("clicked()"),self.PBMeshFilePressed) + self.connect(self.PB_MeshSmesh,SIGNAL("clicked()"),self.PBMeshSmeshPressed) + self.connect(self.LE_MeshSmesh,SIGNAL("returnPressed()"),self.meshSmeshNameChanged) + self.connect(self.PB_ParamsFileExplorer,SIGNAL("clicked()"),self.setParamsFileName) + self.connect(self.LE_MeshFile,SIGNAL("returnPressed()"),self.meshFileNameChanged) + self.connect(self.LE_ParamsFile,SIGNAL("returnPressed()"),self.paramsFileNameChanged) + + #QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL("stateChanged(int)"), self.change) + self.connect(self.CB_FillHoles,SIGNAL("stateChanged(int)"),self.SP_MinHoleSize.setEnabled) + self.connect(self.CB_ComputedToleranceDisplacement,SIGNAL("stateChanged(int)"),self.SP_ToleranceDisplacement.setDisabled) + self.connect(self.CB_ComputedResolutionLength,SIGNAL("stateChanged(int)"),self.SP_ResolutionLength.setDisabled) + self.connect(self.CB_ComputedOverlapDistance,SIGNAL("stateChanged(int)"),self.SP_OverlapDistance.setDisabled) + + def PBHelpPressed(self): + try: + mydir=os.environ["SMESH_ROOT_DIR"] + except Exception: + QMessageBox.warning( self, "Help", "Help unavailable $SMESH_ROOT_DIR not found") + return + maDoc=mydir+"/share/doc/salome/gui/SMESH/MGCleaner/_downloads/mg-cleaner_user_manual.pdf" + command="xdg-open "+maDoc+";" + subprocess.call(command, shell=True) + + def PBOKPressed(self): + if not(self.PrepareLigneCommande()): + #warning done yet + #QMessageBox.warning(self, "Compute", "Command not found") + return + maFenetre=MGCleanerMonViewText(self, self.commande) + + def enregistreResultat(self): + import salome + import SMESH + from salome.kernel import studyedit + from salome.smesh import smeshBuilder + smesh = smeshBuilder.New(salome.myStudy) + + if not os.path.isfile(self.fichierOut): + QMessageBox.warning(self, "Compute", "Result file "+self.fichierOut+" not found") + + maStudy=studyedit.getActiveStudy() + smesh.SetCurrentStudy(maStudy) + (outputMesh, status) = smesh.CreateMeshesFromGMF(self.fichierOut) + name=str(self.LE_MeshSmesh.text()) + initialMeshFile=None + initialMeshObject=None + if name=="": + a=str(self.fichierIn) + name=os.path.basename(os.path.splitext(a)[0]) + initialMeshFile=a + else: + initialMeshObject=maStudy.FindObjectByName(name ,"SMESH")[0] + + meshname = name+"_MGC_"+str(self.num) + smesh.SetName(outputMesh.GetMesh(), meshname) + outputMesh.Compute() #no algorithms message for "Mesh_x" has been computed with warnings: - global 1D algorithm is missing + + self.editor = studyedit.getStudyEditor() + moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH") + HypReMeshEntry = self.editor.findOrCreateItem( + moduleEntry, name = "Plugins Hypotheses", icon="mesh_tree_hypo.png") #, comment = "HypoForRemeshing" ) + + monStudyBuilder=maStudy.NewBuilder() + monStudyBuilder.NewCommand() + newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry) + self.editor.setAttributeValue(newStudyIter, "AttributeName", "MGCleaner Parameters_"+str(self.num)) + self.editor.setAttributeValue(newStudyIter, "AttributeComment", self.getResumeData(separator=" ; ")) + + SOMesh=maStudy.FindObjectByName(meshname ,"SMESH")[0] + + if initialMeshFile!=None: + newStudyFileName=monStudyBuilder.NewObject(SOMesh) + self.editor.setAttributeValue(newStudyFileName, "AttributeName", "meshFile") + self.editor.setAttributeValue(newStudyFileName, "AttributeExternalFileDef", initialMeshFile) + self.editor.setAttributeValue(newStudyFileName, "AttributeComment", initialMeshFile) + + if initialMeshObject!=None: + newLink=monStudyBuilder.NewObject(SOMesh) + monStudyBuilder.Addreference(newLink, initialMeshObject) + + newLink=monStudyBuilder.NewObject(SOMesh) + monStudyBuilder.Addreference(newLink, newStudyIter) + + if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0) + self.num+=1 + return True + + def PBSavePressed(self): + from datetime import datetime + if not(self.PrepareLigneCommande()): return + text = "# MGCleaner hypothesis parameters\n" + text += "# Params for mesh : " + self.LE_MeshSmesh.text() +"\n" + text += datetime.now().strftime("# Date : %d/%m/%y %H:%M:%S\n") + text += "# Command : "+self.commande+"\n" + text += self.getResumeData(separator="\n") + text += "\n\n" + + try: + f=open(self.paramsFile,"a") + except: + QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile) + return + try: + f.write(text) + except: + QMessageBox.warning(self, "File", "Unable to write "+self.paramsFile) + return + f.close() + + def PBSaveHypPressed(self): + """save hypothesis in Object Browser""" + import salome + import SMESH + from salome.kernel import studyedit + from salome.smesh import smeshBuilder + smesh = smeshBuilder.New(salome.myStudy) + + maStudy=studyedit.getActiveStudy() + smesh.SetCurrentStudy(maStudy) + + self.editor = studyedit.getStudyEditor() + moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH") + HypReMeshEntry = self.editor.findOrCreateItem( + moduleEntry, name = "Plugins Hypotheses", icon="mesh_tree_hypo.png") #, comment = "HypoForRemeshing" ) + + monStudyBuilder=maStudy.NewBuilder() + monStudyBuilder.NewCommand() + newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry) + self.editor.setAttributeValue(newStudyIter, "AttributeName", "MGCleaner Parameters_"+str(self.num)) + self.editor.setAttributeValue(newStudyIter, "AttributeComment", self.getResumeData(separator=" ; ")) + + if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0) + self.num+=1 + return True + + """ + import salome_pluginsmanager + print "salome_pluginsmanager.plugins",salome_pluginsmanager.plugins + print "salome_pluginsmanager.current_plugins_manager",salome_pluginsmanager.current_plugins_manager + """ + + def SP_toStr(self, widget): + """only for a QLineEdit widget""" + #cr, pos=widget.validator().validate(res, 0) #n.b. "1,3" is acceptable !locale! + try: + val=float(widget.text()) + except: + QMessageBox.warning(self, widget.titleForWarning, "float value is incorrect: '"+widget.text()+"'") + res=str(widget.validator().bottom()) + widget.setProperty("text", res) + return res + valtest=widget.validator().bottom() + if valtest!=None: + if valvaltest: + QMessageBox.warning(self, widget.titleForWarning, "float value is over maximum: "+str(val)+" > "+str(valtest)) + res=str(valtest) + widget.setProperty("text", res) + return res + return str(val) + + def getResumeData(self, separator="\n"): + text="" + if self.RB_Fix1.isChecked(): + CheckOrFix="fix1pass" + else: + if self.RB_Fix2.isChecked(): + CheckOrFix="fix2pass" + else: + CheckOrFix="check" + text+="CheckOrFix="+CheckOrFix+separator + text+="PreserveTopology="+str(self.CB_PreserveTopology.isChecked())+separator + text+="FillHoles="+str(self.CB_FillHoles.isChecked())+separator + v=self.SP_toStr(self.SP_MinHoleSize) + text+="MinHoleSize="+v+separator + text+="ComputedToleranceDisplacement="+str(self.CB_ComputedToleranceDisplacement.isChecked())+separator + v=self.SP_toStr(self.SP_ToleranceDisplacement) + text+="ToleranceDisplacement="+v+separator + text+="ComputedResolutionLength="+str(self.CB_ComputedResolutionLength.isChecked())+separator + v=self.SP_toStr(self.SP_ResolutionLength) + text+="ResolutionLength="+v+separator + text+="FoldingAngle="+str(self.SP_FoldingAngle.value())+separator + text+="RemeshPlanes="+str(self.CB_RemeshPlanes.isChecked())+separator + text+="ComputedOverlapDistance="+str(self.CB_ComputedOverlapDistance.isChecked())+separator + v=self.SP_toStr(self.SP_OverlapDistance) + text+="OverlapDistance="+v+separator + text+="OverlapAngle="+str(self.SP_OverlapAngle.value())+separator + text+="Verbosity="+str(self.SP_Verbosity.value())+separator + return str(text) + + def loadResumeData(self, hypothesis, separator="\n"): + text=str(hypothesis) + self.clean() + for slig in reversed(text.split(separator)): + lig=slig.strip() + #print "load ResumeData",lig + if lig=="": continue #skip blanck lines + if lig[0]=="#": break + try: + tit,value=lig.split("=") + if tit=="CheckOrFix": + self.RB_Fix1.setChecked(False) + self.RB_Fix2.setChecked(False) + self.RB_Check.setChecked(False) + if value=="fix1pass": self.RB_Fix1.setChecked(True) + if value=="fix2pass": self.RB_Fix2.setChecked(True) + if value=="check": self.RB_Check.setChecked(True) + if tit=="PreserveTopology": self.CB_PreserveTopology.setChecked(value=="True") + if tit=="FillHoles": self.CB_FillHoles.setChecked(value=="True") + if tit=="MinHoleSize": self.SP_MinHoleSize.setProperty("text", value) + if tit=="ComputedToleranceDisplacement": self.CB_ComputedToleranceDisplacement.setChecked(value=="True") + if tit=="ToleranceDisplacement": self.SP_ToleranceDisplacement.setProperty("text", value) + if tit=="ComputedResolutionLength": self.CB_ComputedResolutionLength.setChecked(value=="True") + if tit=="ResolutionLength": self.SP_ResolutionLength.setProperty("text", value) + if tit=="FoldingAngle": self.SP_FoldingAngle.setProperty("value", float(value)) + if tit=="RemeshPlanes": self.CB_RemeshPlanes.setChecked(value=="True") + if tit=="ComputedOverlapDistance": self.CB_ComputedOverlapDistance.setChecked(value=="True") + if tit=="OverlapDistance": self.SP_OverlapDistance.setProperty("text", value) + if tit=="OverlapAngle": self.SP_OverlapAngle.setProperty("value", float(value)) + if tit=="Verbosity": self.SP_Verbosity.setProperty("value", int(float(value))) + except: + QMessageBox.warning(self, "load MGCleaner Hypothesis", "Problem on '"+lig+"'") + + def PBLoadPressed(self): + """load last hypothesis saved in tail of file""" + try: + f=open(self.paramsFile,"r") + except: + QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile) + return + try: + text=f.read() + except: + QMessageBox.warning(self, "File", "Unable to read "+self.paramsFile) + return + f.close() + self.loadResumeData(text, separator="\n") + + def PBLoadHypPressed(self): + """load hypothesis saved in Object Browser""" + #QMessageBox.warning(self, "load Object Browser MGCleaner hypothesis", "TODO") + import salome + from salome.kernel import studyedit + from salome.smesh.smeshstudytools import SMeshStudyTools + from salome.gui import helper as guihelper + from omniORB import CORBA + + mySObject, myEntry = guihelper.getSObjectSelected() + if CORBA.is_nil(mySObject) or mySObject==None: + QMessageBox.critical(self, "Hypothese", "select an Object Browser MGCleaner hypothesis") + return + + #for i in dir(mySObject): print "dir mySObject",i + #print "GetAllAttributes",mySObject.GetAllAttributes() + #print "GetComment",mySObject.GetComment() + #print "GetName",mySObject.GetName() + + #could be renamed... + #if mySObject.GetFather().GetName()!="MGCleaner Hypotheses": + # QMessageBox.critical(self, "Hypothese", "not a child of MGCleaner Hypotheses") + # return + + text=mySObject.GetComment() + + #a verification + if "CheckOrFix=" not in text: + QMessageBox.critical(self, "Load Hypothese", "Object Browser selection not a MGCleaner Hypothesis") + return + self.loadResumeData(text, separator=" ; ") + return + + def PBCancelPressed(self): + self.close() + + def PBMeshFilePressed(self): + fd = QFileDialog(self, "select an existing Mesh file", self.LE_MeshFile.text(), "Mesh-Files (*.mesh);;All Files (*)") + if fd.exec_(): + infile = fd.selectedFiles()[0] + self.LE_MeshFile.setText(infile) + self.fichierIn=infile.toLatin1() + self.MeshIn="" + self.LE_MeshSmesh.setText("") + + def setParamsFileName(self): + fd = QFileDialog(self, "select a file", self.LE_ParamsFile.text(), "dat Files (*.dat);;All Files (*)") + if fd.exec_(): + infile = fd.selectedFiles()[0] + self.LE_ParamsFile.setText(infile) + self.paramsFile=infile.toLatin1() + + def meshFileNameChanged(self): + self.fichierIn=str(self.LE_MeshFile.text()) + #print "meshFileNameChanged", self.fichierIn + if os.path.exists(self.fichierIn): + self.__selectedMesh=None + self.MeshIn="" + self.LE_MeshSmesh.setText("") + return + QMessageBox.warning(self, "Mesh file", "File doesn't exist") + + def meshSmeshNameChanged(self): + """only change by GUI mouse selection, otherwise clear""" + #self.MeshIn=str(self.LE_MeshSmesh.text()) + #print "meshSmeshNameChanged", self.MeshIn + self.__selectedMesh = None + self.MeshIn="" + self.LE_MeshSmesh.setText("") + self.fichierIn="" + return + + def paramsFileNameChanged(self): + self.paramsFile=self.LE_ParamsFile.text() + + def PBMeshSmeshPressed(self): + from omniORB import CORBA + import salome + from salome.kernel import studyedit + from salome.smesh.smeshstudytools import SMeshStudyTools + from salome.gui import helper as guihelper + from salome.smesh import smeshBuilder + smesh = smeshBuilder.New(salome.myStudy) + + mySObject, myEntry = guihelper.getSObjectSelected() + if CORBA.is_nil(mySObject) or mySObject==None: + QMessageBox.critical(self, "Mesh", "select an input mesh") + return + self.smeshStudyTool = SMeshStudyTools() + try: + self.__selectedMesh = self.smeshStudyTool.getMeshObjectFromSObject(mySObject) + except: + QMessageBox.critical(self, "Mesh", "select an input mesh") + return + if CORBA.is_nil(self.__selectedMesh): + QMessageBox.critical(self, "Mesh", "select an input mesh") + return + myName = mySObject.GetName() + #print "MeshSmeshNameChanged", myName + self.MeshIn=myName + self.LE_MeshSmesh.setText(myName) + self.LE_MeshFile.setText("") + self.fichierIn="" + + def prepareFichier(self): + self.fichierIn="/tmp/ForMGCleaner_"+str(self.num)+".mesh" + self.__selectedMesh.ExportGMF(self.__selectedMesh, self.fichierIn, True) + + def PrepareLigneCommande(self): + """ + #use doc examples of mg-cleaner: + ls -al /data/tmplgls/salome/prerequis/install/COMMON_64/MeshGems-1.0/bin + source /data/tmplgls/salome/prerequis/install/LICENSE/dlim8.var.sh + export PATH=/data/tmplgls/salome/prerequis/install/COMMON_64/MeshGems-1.0/bin/Linux_64:$PATH + cp -r /data/tmplgls/salome/prerequis/install/COMMON_64/MeshGems-1.0/examples . + cd examples + mg-cleaner.exe --help + mg-cleaner.exe --in case7.mesh --out case7-test.mesh --check + mg-cleaner.exe case7.mesh case7-fix.mesh --fix + mg-cleaner.exe --in Porsche.mesh --out Porsche-test.mesh --check + mg-cleaner.exe --in Porsche.mesh --out Porschefix.mesh --fix + mg-cleaner.exe --in Porsche.mesh --out PorscheNewfix.mesh --fix --resolution_length 0.03 + """ + + #self.commande="mg-cleaner.exe --in " + self.fichierIn + " --out " + self.fichierOut + " --fix2pass" + #return True + #print "PrepareLigneCommande '"+self.fichierIn+"' '"+self.MeshIn+"'",self.__selectedMesh + if self.fichierIn=="" and self.MeshIn=="": + QMessageBox.critical(self, "Mesh", "select an input mesh") + return False + if self.__selectedMesh!=None: self.prepareFichier() + if not (os.path.isfile(self.fichierIn)): + QMessageBox.critical(self, "File", "unable to read GMF Mesh in "+str(self.fichierIn)) + return False + + self.commande="mg-cleaner.exe" + verbosity=str(self.SP_Verbosity.value()) + self.commande+=" --verbose " + verbosity + self.commande+=" --in " + self.fichierIn + #print "self.fichierIn",self.fichierIn,type(self.fichierIn) + deb=os.path.splitext(str(self.fichierIn)) + self.fichierOut=deb[0] + "_fix.mesh" + self.commande+=" --out "+self.fichierOut + if self.RB_Fix1.isChecked(): + self.commande+=" --fix1pass" + else: + if self.RB_Fix2.isChecked(): + self.commande+=" --fix2pass" + else: + self.commande+=" --check" + if self.CB_PreserveTopology.isChecked(): + self.commande+=" --topology respect" + else: + self.commande+=" --topology ignore" + if self.CB_FillHoles.isChecked(): #no fill holes default + self.commande+=" --min_hole_size " + self.SP_toStr(self.SP_MinHoleSize) + if not self.CB_ComputedToleranceDisplacement.isChecked(): #computed default + self.commande+=" --tolerance_displacement " + self.SP_toStr(self.SP_ToleranceDisplacement) + if not self.CB_ComputedResolutionLength.isChecked(): #computed default + self.commande+=" --resolution_length " + self.SP_toStr(self.SP_ResolutionLength) + self.commande+=" --folding_angle " + str(self.SP_FoldingAngle.value()) + if self.CB_RemeshPlanes.isChecked(): #no remesh default + self.commande+=" --remesh_planes" + if not self.CB_ComputedOverlapDistance.isChecked(): #computed default + self.commande+=" --overlap_distance " + self.SP_toStr(self.SP_OverlapDistance) + self.commande+=" --overlap_angle " + str(self.SP_OverlapAngle.value()) + return True + + def clean(self): + self.RB_Check.setChecked(False) + self.RB_Fix1.setChecked(False) + self.RB_Fix2.setChecked(True) + self.CB_PreserveTopology.setChecked(False) + self.CB_FillHoles.setChecked(False) + self.CB_RemeshPlanes.setChecked(False) + + self.SP_MinHoleSize.setProperty("text", 0) + self.SP_ToleranceDisplacement.setProperty("text", 0) + self.SP_ResolutionLength.setProperty("text", 0) + self.SP_FoldingAngle.setProperty("value", 15) + self.SP_OverlapDistance.setProperty("text", 0) + self.SP_OverlapAngle.setProperty("value", 15) + self.SP_Verbosity.setProperty("value", 3) + + self.CB_ComputedToleranceDisplacement.setChecked(True) + self.CB_ComputedResolutionLength.setChecked(True) + self.CB_ComputedOverlapDistance.setChecked(True) + +__dialog=None +def getDialog(): + """ + This function returns a singleton instance of the plugin dialog. + c est obligatoire pour faire un show sans parent... + """ + global __dialog + if __dialog is None: + __dialog = MGCleanerMonPlugDialog() + #else : + # __dialog.clean() + return __dialog + + +# +# ============================================================================== +# For memory +# ============================================================================== +# +def TEST_standalone(): + """ + works only if a salome is launched yet with a study loaded + to launch standalone python do: + ./APPLI/runSession + python + or (do not works) + python ./INSTALL/SMESH/share/salome/plugins/smesh/MGCleanerMonPlugDialog.py + """ + import salome + import SMESH + from salome.kernel import studyedit + salome.salome_init() + maStudy=studyedit.getActiveStudy() + #etc...a mano... + +# +# ============================================================================== +# Basic use cases and unit test functions +# ============================================================================== +# +def TEST_MGCleanerMonPlugDialog(): + import sys + from PyQt4.QtGui import QApplication + from PyQt4.QtCore import QObject, SIGNAL, SLOT + app = QApplication(sys.argv) + QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) + + dlg=MGCleanerMonPlugDialog() + dlg.show() + sys.exit(app.exec_()) + +if __name__ == "__main__": + TEST_MGCleanerMonPlugDialog() + #TEST_standalone() + pass diff --git a/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py b/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py new file mode 100644 index 000000000..698bb7ad2 --- /dev/null +++ b/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py @@ -0,0 +1,118 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 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 +# 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 +# + +# Modules Python +import string,types,os +import traceback + +from PyQt4 import * +from PyQt4.QtGui import * +from PyQt4.QtCore import * + +# Import des panels + +from MGCleanerViewText import Ui_ViewExe + +class MGCleanerMonViewText(Ui_ViewExe, QDialog): + """ + Classe permettant la visualisation de texte + """ + def __init__(self, parent, txt, ): + QDialog.__init__(self,parent) + self.setupUi(self) + self.resize( QSize(1000,600).expandedTo(self.minimumSizeHint()) ) + #self.connect( self.PB_Ok,SIGNAL("clicked()"), self, SLOT("close()") ) + self.connect( self.PB_Ok,SIGNAL("clicked()"), self.theClose ) + self.connect( self.PB_Save,SIGNAL("clicked()"), self.saveFile ) + self.PB_Save.setToolTip("Save trace in log file") + self.PB_Ok.setToolTip("Close view") + self.monExe=QProcess(self) + + self.connect(self.monExe, SIGNAL("readyReadStandardOutput()"), self.readFromStdOut ) + self.connect(self.monExe, SIGNAL("readyReadStandardError()"), self.readFromStdErr ) + + # Je n arrive pas a utiliser le setEnvironment du QProcess + # fonctionne hors Salome mais pas dans Salome ??? + cmds='' + try : + LICENCE_FILE=os.environ["DISTENE_LICENCE_FILE_FOR_MGCLEANER"] + except: + LICENCE_FILE='' + try : + PATH=os.environ["DISTENE_PATH_FOR_MGCLEANER"] + except: + PATH='' + if LICENCE_FILE != '': + cmds+='source '+LICENCE_FILE+'\n' + else: + cmds+="# $DISTENE_LICENCE_FILE_FOR_MGCLEANER NOT SET\n" + if PATH != '': + cmds+='export PATH='+PATH+':$PATH\n' + else: + cmds+="# $DISTENE_PATH_FOR_MGCLEANER NOT SET\n" + #cmds+='env\n' + cmds+='rm -f '+self.parent().fichierOut+'\n' + cmds+=txt+'\n' + cmds+='echo END_OF_MGCleaner\n' + pid=self.monExe.pid() + nomFichier='/tmp/MGCleaner_'+str(pid)+'.sh' + f=open(nomFichier,'w') + f.write(cmds) + f.close() + + maBidouille='sh ' + nomFichier + self.monExe.start(maBidouille) + self.monExe.closeWriteChannel() + self.enregistreResultatsDone=False + self.show() + + def saveFile(self): + #recuperation du nom du fichier + savedir=os.environ['HOME'] + fn = QFileDialog.getSaveFileName(None, self.trUtf8("Save File"),savedir) + if fn.isNull() : return + ulfile = os.path.abspath(unicode(fn)) + try: + f = open(fn, 'wb') + f.write(str(self.TB_Exe.toPlainText())) + f.close() + except IOError, why: + QMessageBox.critical(self, self.trUtf8('Save File'), + self.trUtf8('The file %1 could not be saved.
    Reason: %2') + .arg(unicode(fn)).arg(str(why))) + + def readFromStdErr(self): + a=self.monExe.readAllStandardError() + self.TB_Exe.append(QString.fromUtf8(a.data(),len(a))) + + def readFromStdOut(self) : + a=self.monExe.readAllStandardOutput() + aa=QString.fromUtf8(a.data(),len(a)) + self.TB_Exe.append(aa) + if "END_OF_MGCleaner" in aa: + self.parent().enregistreResultat() + self.enregistreResultatsDone=True + #self.theClose() + + def theClose(self): + if not self.enregistreResultatsDone: + self.parent().enregistreResultat() + self.enregistreResultatsDone=True + self.close() diff --git a/src/Tools/MGCleanerPlug/MGCleanerPlugDialog.ui b/src/Tools/MGCleanerPlug/MGCleanerPlugDialog.ui new file mode 100644 index 000000000..5e3ddbfba --- /dev/null +++ b/src/Tools/MGCleanerPlug/MGCleanerPlugDialog.ui @@ -0,0 +1,839 @@ + + + MGCleanerPlugDialog + + + + 0 + 0 + 800 + 500 + + + + MGCleaner : Remeshing tool + + + false + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 10 + 20 + + + + + + + + Compute + + + + + + + Close + + + + + + + Qt::Horizontal + + + + 30 + 20 + + + + + + + + Save + + + + 18 + 18 + + + + + + + + Load + + + + 18 + 18 + + + + + + + + Default + + + + + + + Qt::Horizontal + + + + 30 + 20 + + + + + + + + + 10 + + + + Help + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 10 + 20 + + + + + + + + + + + 10 + + + + 0 + + + + Simple Remeshing Options + + + + + 10 + 140 + 750 + 270 + + + + Options + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 30 + 20 + + + + + + + + + + + Performs checks only (no fixing). +Writes diagnostics into the output file. +Default is to fix with two passes. + + + Only checking + + + false + + + + + + + Analyses and fixes mesh with only the first stage of the cleaning procedure. +Does not write diagnostics into the output file. +Default is to fix with two passes. + + + Fix problems with one pass + + + false + + + + + + + Analyses and fixes mesh with the two stage cleaning procedure. +Does not write diagnostics into the output file. +Default is to fix with two passes. + + + Fix problems with two passes + + + true + + + + + + + + Disables fixing operations which induce topology modifications. +Default is enable topology modifications. +(argument --topology) + + + Preserve topology + + + false + + + + + + + Default is not to fill holes. +if set: see 'surface size threshold of holes' in 'Advanced remeshing options'. + + + Fill holes + + + false + + + + + + + + Inserts vertices on planes to improve mesh quality . +May be useful for poor quality triangulations (eg .STL or .DXF triangulations). +Default is not to mesh planes. + + + Remesh planes + + + false + + + + + + + + + + + + + + + 10 + 10 + 750 + 120 + + + + + 10 + + + + Original Mesh + + + + + 40 + 70 + 190 + 31 + + + + + 10 + + + + Mesh File GMF format + + + + 18 + 18 + + + + + + + 240 + 70 + 481 + 31 + + + + + 10 + + + + + + + 40 + 30 + 190 + 31 + + + + Mesh Object Browser + + + + 18 + 18 + + + + false + + + + + + 240 + 30 + 481 + 31 + + + + + 10 + + + + + + + 10 + 80 + 31 + 18 + + + + or + + + + groupBox + GBOptim + + + + Advanced Remeshing Options + + + + + 10 + 10 + 750 + 400 + + + + You can control + +#1 + + + + 20 + 30 + 100 + 25 + + + + false + + + + + + 130 + 30 + 600 + 30 + + + + sets the surface size threshold below which holes are filled. +Set 'Fill holes' in 'Simple Remeshing Options'. + + + Surface size threshold of holes to fill (--min_hole_size) + + +#2 + + + + 20 + 70 + 100 + 25 + + + + false + + + + + + 130 + 70 + 600 + 30 + + + + Sets the displacement threshold below which modification is allowed. +Unused in collision resolution . +'Tolerance displacement' is set to resolution_length if it is lower. + + + Tolerance displacement threshold of points for modification +(--tolerance_displacement) + + + + + + + 650 + 70 + 100 + 30 + + + + If set default value is computed from model. + + + Computed + + + true + + + +#3 + + + + 20 + 110 + 100 + 25 + + + + false + + + + + + 130 + 110 + 600 + 30 + + + + sets the distance threshold above which 2 points are considered distinct. +Sets the tolerance displacement to 1/5 of this size. +Default is computed from model. + + + Distance threshold for two points distinct (--resolution_length) + + + + + + 650 + 110 + 100 + 30 + + + + If set default value is computed from model. + + + Computed + + + true + + +#4 + + + + 20 + 150 + 100 + 25 + + + + 90 + + + 0 + + + 1 + + + 15 + + + + + + 130 + 150 + 600 + 30 + + + + Sets the threshold angle below which 2 connected triangles are considered overlapping . +Reduce this value if model contains sharp angles below this threshold that must be kept. +Overlap_angle is set to this angle if it is higher. +Default is 15 degrees. + + + Angle threshold for two connected triangles overlapping (--folding_angle) + + +#5 + + + + 20 + 190 + 100 + 25 + + + + false + + + + + + 130 + 190 + 600 + 30 + + + + sets the distance below which 2 unconnected triangles are considered overlapping. +Reduce this value if too many overlaps are detected. +Default is computed from model. + + + Distance threshold for two unconnected triangles overlapping +(--overlap_distance) + + + + + + 650 + 190 + 100 + 30 + + + + If set default value is computed from model. + + + Computed + + + true + + +#6 + + + + 20 + 230 + 100 + 25 + + + + 90 + + + 0 + + + 1 + + + 15 + + + + + + 130 + 230 + 600 + 30 + + + + Sets the angle below which 2 unconnected triangles are considered overlapping. +'Folding angle' is set to this angle if it is lower. +Default is 15 degrees. + + + Angle threshold for two unconnected triangles overlapping (--overlap_angle) + + + + + + + Generic Options + + + + + 10 + 10 + 750 + 130 + + + + MGCleaner Generic Options + + + + + + 20 + 30 + 100 + 25 + + + + 10 + + + 3 + + + + + + + 130 + 30 + 600 + 30 + + + + sets the verbosity level. +From 0 (no detail) to 10 (very detailed). +Default is 3. + + + Verbosity level + + + + + + + + + 10 + 150 + 750 + 170 + + + + Plug-in Generic Options + + + + + 20 + 40 + 391 + 18 + + + + File used to save MGCleaner hypothesis parameters : + + + + + + 20 + 70 + 30 + 31 + + + + + + + + + + 60 + 70 + 661 + 31 + + + + + + + + 20 + 110 + 70 + 31 + + + + Save + + + + 18 + 18 + + + + + + + + 120 + 110 + 70 + 31 + + + + Load + + + + 18 + 18 + + + + + + + + + + + + + diff --git a/src/Tools/MGCleanerPlug/MGCleanerViewText.ui b/src/Tools/MGCleanerPlug/MGCleanerViewText.ui new file mode 100644 index 000000000..8bec19a12 --- /dev/null +++ b/src/Tools/MGCleanerPlug/MGCleanerViewText.ui @@ -0,0 +1,38 @@ + + + ViewExe + + + + 0 + 0 + 469 + 489 + + + + Run MGCleaner + + + + + + + + + Ok + + + + + + + Save + + + + + + + + diff --git a/src/Tools/MGCleanerPlug/MGCleanerplug_plugin.py b/src/Tools/MGCleanerPlug/MGCleanerplug_plugin.py new file mode 100644 index 000000000..80eeae790 --- /dev/null +++ b/src/Tools/MGCleanerPlug/MGCleanerplug_plugin.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2006-2013 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 +# 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 +# + +# if you already have plugins defined in a salome_plugins.py file, add this file at the end. +# if not, copy this file as ${HOME}/Plugins/smesh_plugins.py or ${APPLI}/Plugins/smesh_plugins.py + +def MGCleanerLct(context): + # get context study, studyId, salomeGui + study = context.study + studyId = context.studyId + sg = context.sg + + import os + import subprocess + import tempfile + from PyQt4 import QtCore + from PyQt4 import QtGui + from PyQt4.QtGui import QFileDialog + from PyQt4.QtGui import QMessageBox + + #prior test to avoid unnecessary user GUI work with ending crash + try : + os.environ['DISTENE_LICENCE_FILE_FOR_MGCLEANER'] + except: + QMessageBox.warning(None,"Products","Distene's product MeshGem Cleaner is not installed.\nrequired environment variable:\nDISTENE_LICENCE_FILE_FOR_MGCLEANER='/.../dlim8.var.sh'") + return + import MGCleanerMonPlugDialog + window=MGCleanerMonPlugDialog.getDialog() + window.show() + diff --git a/src/Tools/MGCleanerPlug/Makefile.am b/src/Tools/MGCleanerPlug/Makefile.am new file mode 100644 index 000000000..efbc7859d --- /dev/null +++ b/src/Tools/MGCleanerPlug/Makefile.am @@ -0,0 +1,38 @@ +# Copyright (C) 2007-2013 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 +# 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 +# + +SUBDIRS = doc + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +UIPY_FILES = MGCleanerPlugDialog.py MGCleanerViewText.py + +salomeplugins_PYTHON = \ + MGCleanerMonPlugDialog.py\ + MGCleanerMonViewText.py\ + MGCleanerplug_plugin.py + +nodist_salomeplugins_PYTHON = $(UIPY_FILES) + +CLEANFILES = $(UIPY_FILES) + +EXTRA_DIST += $(UIPY_FILES:%.py=%.ui) + +%.py : %.ui + $(PYUIC) $< -o $@ diff --git a/src/Tools/MGCleanerPlug/Tolerance.png b/src/Tools/MGCleanerPlug/Tolerance.png new file mode 100644 index 000000000..d8fb16238 Binary files /dev/null and b/src/Tools/MGCleanerPlug/Tolerance.png differ diff --git a/src/Tools/MGCleanerPlug/doc/Advanced_params.rst b/src/Tools/MGCleanerPlug/doc/Advanced_params.rst new file mode 100644 index 000000000..34178cfd3 --- /dev/null +++ b/src/Tools/MGCleanerPlug/doc/Advanced_params.rst @@ -0,0 +1,11 @@ +Advanced Remeshing Options +========================== + +See tooltips comments for each parameter. +See also :download:`MG-cleaner user manual `. + +.. image:: images/Advanced.png + :align: center + + + diff --git a/src/Tools/MGCleanerPlug/doc/Generics_params.rst b/src/Tools/MGCleanerPlug/doc/Generics_params.rst new file mode 100644 index 000000000..45133412c --- /dev/null +++ b/src/Tools/MGCleanerPlug/doc/Generics_params.rst @@ -0,0 +1,18 @@ +Generic Options +================= + +These options are not meshing options but allow the user to configure control parameters for MG-Cleaner. + + +- **Verbosity Level** + +This parameter (between 0 and 10) indicates the amount of information that MG-Cleaner prints during the run. + + +- **File** + +You can change the file used to store your favorite remeshing hypothesis. see paragraph :ref:`hypothesis-label` for further informations. + +.. image:: images/Generic.png + :align: center + diff --git a/src/Tools/MGCleanerPlug/doc/Makefile.am b/src/Tools/MGCleanerPlug/doc/Makefile.am new file mode 100644 index 000000000..d122e7966 --- /dev/null +++ b/src/Tools/MGCleanerPlug/doc/Makefile.am @@ -0,0 +1,70 @@ +# Makefile for Sphinx documentation +# + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +MGCleanerdocdir=$(docdir)/gui/SMESH/MGCleaner + +RSTFILES = lct.rst \ + index.rst \ + editHypo.rst \ + Mandatory_params.rst \ + Generics_params.rst \ + Advanced_params.rst + +EXTRA_DIST += $(RSTFILES) images files + +# You can set these variables from the command line. +SPHINXOPTS = +SOURCEDIR = $(srcdir) +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build +CONF_FILE_DIR = $(top_builddir)/src/Tools/MGCleanerPlug/doc + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees -c $(CONF_FILE_DIR) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SOURCEDIR) + +.PHONY: help clean html latexpdf + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +install-data-local: $(BUILDDIR)/html/index.html + -test -z $(MGCleanerdocdir) || mkdir -p $(MGCleanerdocdir) && cp -rf $(BUILDDIR)/html/* $(MGCleanerdocdir) ; + +uninstall-local: + -test -d $(MGCleanerdocdir) && chmod -R +w $(MGCleanerdocdir) && rm -rf $(MGCleanerdocdir)/* + +clean-local: + -rm -rf $(BUILDDIR)/* + +$(BUILDDIR)/html/index.html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + diff --git a/src/Tools/MGCleanerPlug/doc/Mandatory_params.rst b/src/Tools/MGCleanerPlug/doc/Mandatory_params.rst new file mode 100644 index 000000000..541a3bdf7 --- /dev/null +++ b/src/Tools/MGCleanerPlug/doc/Mandatory_params.rst @@ -0,0 +1,27 @@ +Simple Remeshing Options +========================= + +simple case +----------- + + All options, but the input mesh, have default values. however, **you have to specified these + simple options in order to drive MG-Cleaner and control remeshing parameters**. + + You can access Distene documentation by clicking on Help button. + + +.. image:: images/Simple.png + :align: center + + +- **Original Mesh** + + You have to select a Mesh Object from Salome Object Browser or choose a .GMF file. + + +Options +------------ + +This is the main remeshing Option. + + diff --git a/src/Tools/MGCleanerPlug/doc/conf.py.in b/src/Tools/MGCleanerPlug/doc/conf.py.in new file mode 100644 index 000000000..b8f430700 --- /dev/null +++ b/src/Tools/MGCleanerPlug/doc/conf.py.in @@ -0,0 +1,179 @@ +# -*- coding: utf-8 -*- +# +# MGCleaner PlugIn documentation build configuration file, created by +# sphinx-quickstart on April 2013. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# The contents of this file are pickled, so don't put values in the namespace +# that aren't pickleable (module imports are okay, they're removed automatically). +# +# All configuration values have a default value; values that are commented out +# serve to show the default value. + +import sys, os + +# If your extensions are in another directory, add it here. If the directory +# is relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +#sys.path.append(os.path.abspath('some/directory')) + +# General configuration +# --------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['.templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General substitutions. +project = 'MGCleaner Plug-in' +copyright = '2013, CEA' + +# The default replacements for |version| and |release|, also used in various +# other places throughout the built documents. +# +# The short X.Y version. +version = '@VERSION@' +# The full version, including alpha/beta/rc tags. +release = '@VERSION@' + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directories, that shouldn't be searched +# for source files. +#exclude_dirs = [] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + + +# Options for HTML output +# ----------------------- + +# The style sheet to use for HTML and HTML Help pages. A file of that name +# must exist either in Sphinx' static/ path, or in one of the custom paths +# given in html_static_path. +html_style = 'default.css' + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (within the static path) to place at the top of +# the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +#html_static_path = ['.static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_use_modindex = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, the reST sources are included in the HTML build as _sources/. +#html_copy_source = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'MGCleanerPlug-in doc' + + +# Options for LaTeX output +# ------------------------ + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, document class [howto/manual]). +latex_documents = [ + ('index', 'MGCleanerPlugIn.tex', 'MGCleaner PlugIn Documentation', + 'CEA', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True diff --git a/src/Tools/MGCleanerPlug/doc/editHypo.rst b/src/Tools/MGCleanerPlug/doc/editHypo.rst new file mode 100644 index 000000000..5ab05f374 --- /dev/null +++ b/src/Tools/MGCleanerPlug/doc/editHypo.rst @@ -0,0 +1,50 @@ +.. _hypothesis-label: + +=========================== +How to save MG-Cleaner Parameters +=========================== + +MG-Cleaner hypothesis is not meshing hypothesis for Salome, but hypothesis for MG-Cleaner. +The current set of parameters is automatically written in the salome study object browser when you run computation. + +Theses parameters could also be stored in a special file. +Default file is $HOME/.MGCleaner.dat. +This ASCII file is appended, and never cleaned. + +In frame "Plug-in Generic Options": + +- To save the current setting in this file, click on "Save" pushbutton. +- To load the last set of parameters saved, click on "Load" pushbutton. + +At the bottom of the dialog window: + +- To save a current setting in the study object browser, click on "Save" pushbutton. +- To load a current setting from the study object browser, click on "Load" pushbutton. +- To load the default setting, click on "Default" pushbutton. . + + +**example of .MGCleaner.dat** + + +.. code-block:: python + + # MGCleaner hypothesis parameters + # Params for mesh : Mesh_1 + # Date : 21/05/13 10:44:05 + # Command : mg-cleaner.exe --verbose 2 --in /tmp/ForMGCleaner_2.mesh --out /tmp/ForMGCleaner_2_fix.mesh --check --topology ignore --tolerance_displacement 0.0 --folding_angle 15.0 --overlap_angle 15.0 + CheckOrFix=check + PreserveTopology=False + FillHoles=False + MinHoleSize=0.0 + ComputedToleranceDisplacement=True + ToleranceDisplacement=0.0 + ComputedResolutionLength=False + ResolutionLength=0.0 + FoldingAngle=15.0 + RemeshPlanes=False + ComputedOverlapDistance=True + OverlapDistance=0.0 + OverlapAngle=15.0 + Verbosity=2 + + diff --git a/src/Tools/MGCleanerPlug/doc/files/mg-cleaner_user_manual.pdf b/src/Tools/MGCleanerPlug/doc/files/mg-cleaner_user_manual.pdf new file mode 100644 index 000000000..a3907d243 Binary files /dev/null and b/src/Tools/MGCleanerPlug/doc/files/mg-cleaner_user_manual.pdf differ diff --git a/src/Tools/MGCleanerPlug/doc/images/Advanced.png b/src/Tools/MGCleanerPlug/doc/images/Advanced.png new file mode 100644 index 000000000..2e19ee577 Binary files /dev/null and b/src/Tools/MGCleanerPlug/doc/images/Advanced.png differ diff --git a/src/Tools/MGCleanerPlug/doc/images/AppelMGCleaner.png b/src/Tools/MGCleanerPlug/doc/images/AppelMGCleaner.png new file mode 100644 index 000000000..620e8f2e6 Binary files /dev/null and b/src/Tools/MGCleanerPlug/doc/images/AppelMGCleaner.png differ diff --git a/src/Tools/MGCleanerPlug/doc/images/Generic.png b/src/Tools/MGCleanerPlug/doc/images/Generic.png new file mode 100644 index 000000000..a6614bf49 Binary files /dev/null and b/src/Tools/MGCleanerPlug/doc/images/Generic.png differ diff --git a/src/Tools/MGCleanerPlug/doc/images/Simple.png b/src/Tools/MGCleanerPlug/doc/images/Simple.png new file mode 100644 index 000000000..52775723c Binary files /dev/null and b/src/Tools/MGCleanerPlug/doc/images/Simple.png differ diff --git a/src/Tools/MGCleanerPlug/doc/images/Tolerance.png b/src/Tools/MGCleanerPlug/doc/images/Tolerance.png new file mode 100644 index 000000000..6df0c80c7 Binary files /dev/null and b/src/Tools/MGCleanerPlug/doc/images/Tolerance.png differ diff --git a/src/Tools/MGCleanerPlug/doc/index.rst b/src/Tools/MGCleanerPlug/doc/index.rst new file mode 100644 index 000000000..533951573 --- /dev/null +++ b/src/Tools/MGCleanerPlug/doc/index.rst @@ -0,0 +1,30 @@ +.. MeshGems-Cleaner documentation master file, created by sphinx-quickstart on Wed Sep 14 11:40:32 2011. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +MeshGems-Cleaner plugin documentation +===================================== + +This documentation covers the usage of MeshGems-Cleaner, also named MG-Cleaner or MGCleaner as plug-in in Salome that can be used within the Salome +Mesh module for remeshing 2D Surface. + +MG-Cleaner plug-in uses Distene commercial software MeshGems-Cleaner, which is an **automatic surface remeshing tool**. +This plug_in offers only the most common functionnalities of the tool. + +.. note:: + for a complete documentation, see :download:`MG-cleaner user manual `. + +Contents: + +.. toctree:: + :maxdepth: 2 + + lct.rst + Mandatory_params.rst + Advanced_params.rst + Generics_params.rst + editHypo.rst + + + + diff --git a/src/Tools/MGCleanerPlug/doc/lct.rst b/src/Tools/MGCleanerPlug/doc/lct.rst new file mode 100644 index 000000000..c37726b9e --- /dev/null +++ b/src/Tools/MGCleanerPlug/doc/lct.rst @@ -0,0 +1,11 @@ +Running MGCleaner Plug-in +===================== + +MGCleaner plug-in can be invoked via SMESH Plugin item in Mesh menu bar + +.. image:: images/AppelMGCleaner.png + :align: center + + +This plug-in works only with the commercial software MeshGemsCleaner. To obtain a license, +visit www.distene.comm diff --git a/src/Tools/MGCleanerPlug/open.png b/src/Tools/MGCleanerPlug/open.png new file mode 100644 index 000000000..8ed143ebd Binary files /dev/null and b/src/Tools/MGCleanerPlug/open.png differ diff --git a/src/Tools/MGCleanerPlug/select1.png b/src/Tools/MGCleanerPlug/select1.png new file mode 100644 index 000000000..ecb252ab7 Binary files /dev/null and b/src/Tools/MGCleanerPlug/select1.png differ diff --git a/src/Tools/Makefile.am b/src/Tools/Makefile.am index ac2d64680..ad092da9f 100644 --- a/src/Tools/Makefile.am +++ b/src/Tools/Makefile.am @@ -28,10 +28,10 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am SUBDIRS = MeshCut padder if SMESH_ENABLE_GUI - SUBDIRS += YamsPlug + SUBDIRS += YamsPlug MGCleanerPlug endif salomeplugins_PYTHON = \ smesh_plugins.py -DIST_SUBDIRS = MeshCut padder YamsPlug +DIST_SUBDIRS = MeshCut padder YamsPlug MGCleanerPlug diff --git a/src/Tools/YamsPlug/YamsPlugDialog.ui b/src/Tools/YamsPlug/YamsPlugDialog.ui index 72ae1e07b..e34b7b7da 100644 --- a/src/Tools/YamsPlug/YamsPlugDialog.ui +++ b/src/Tools/YamsPlug/YamsPlugDialog.ui @@ -6,8 +6,8 @@ 0 0 - 927 - 700 + 800 + 500 @@ -19,6 +19,22 @@ + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 10 + 20 + + + + @@ -38,35 +54,44 @@ Qt::Horizontal - - QSizePolicy::Minimum - - 60 + 30 20 - + - Save Params + Save + + + 18 + 18 + + - + - Load Params + Load + + + 18 + 18 + + - Default Params + Default @@ -77,8 +102,8 @@ - 338 - 25 + 30 + 20 @@ -95,6 +120,22 @@ + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 10 + 20 + + + + @@ -114,212 +155,245 @@ - 20 - 190 - 871 - 311 + 10 + 140 + 750 + 270 Optimisation - - - - 20 - 30 - 611 - 261 - - - - - - 17 - 25 - 585 - 23 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<table style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Quality improvement</span> is done by point smoothing and edge swapping</p></td></tr></table></body></html> - - - Quality improvement Only (0) - - - true - - - - - - 17 - 54 - 585 - 23 - - - - the given surface triangulation is enriched (no coarsening at all) in such away that the distance + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 30 + 20 + + + + + + + + + + + Quality improvement is done by point smoothing and edge swapping. + + + Quality improvement Only (0) + + + true + + + + + + + The given surface triangulation is enriched (no coarsening at all) in such away that the distance between the elements in the final mesh and those of the initial one is bounded by auser specified tolerance value. One should use this option, to enrich the mesh where purely geometrical features may be insuficiently fine, i.e. the resulting mesh will be least as fine as the input. Mesh and the geometric features will be refined if needed as specified by the other program parameters. The meshes obtained with those settings may not be suitable for computation. - - - Pure Geometry Enrichment (G) - - - false - - - - - - 17 - 83 - 585 - 23 - - - - a uniform subdivision of the given surface triangulation is performed : + + + Pure Geometry Enrichment (G) + + + false + + + + + + + An uniform subdivision of the given surface triangulation is performed : each triangle of the given surface triangulation is considered at and is divided into identical triangles. - - - Uniform Subdivision(U) - - - false - - - - - - 17 - 112 - 585 - 23 - - - - a surface sandpapering without shrinkage of the given surface + + + Uniform Subdivision (U) + + + false + + + + + + + A surface sandpapering without shrinkage of the given surface triangulation is performed, i.e., the high curvature variations of the given surface will be smoothed out without shrinking the volume in doing so. If ridges are defined, they will be kept as they are in the resulting mesh. -This option modifies the goemetry. - - - Sand Papering (S) - - - false - - - - - - 17 - 141 - 585 - 23 - - - - The given surface triangulation is modified in such a way that the distance between +This option modifies the geometry. + + + Sandpapering (S) + + + false + + + + + + + The given surface triangulation is modified in such a way that the distance between the elements in the final mesh and those of the initial one is bounded by a user specfied tolerance value. One should use this option, to coarsen when a purely geometrical mesh is needed. (a mesh that keeps and obeys its geometric features only.) The meshes obtained with this option are usually not suitable for computation because anisotropic elements may be generated - - - Geometrical Mesh : Coarsening(-2) - - - - - - 17 - 170 - 585 - 23 - - - - The given surface triangulation is modified in such a way that the distance between + + + Geometrical Mesh : Coarsening (-2) + + + + + + + The given surface triangulation is modified in such a way that the distance between the elements in the final mesh and those of the initial one is bounded by a user specfied tolerance value. One should use this option, to coarsen and enrich when a purely geometrical mesh is needed. (a mesh that keeps and obeys its geometric features only.) The meshes obtained with this setting are usually not suitable for computation because anisotropic elements may be generated - - - Geometrical Mesh : Coarsening and Enrichment (2) - - - - - - 17 - 199 - 585 - 23 - - - - The given surface triangulation is modfied in accordance to a size map. + + + Geometrical Mesh : Coarsening and Enrichment (2) + + + + + + + The given surface triangulation is modified in accordance to a size map. The latter can be either the intrinsic size map (computed automatically and based on the surface properties, i.e. the local curvatures), or on a given size map (which is then combined to the intrinsic size map). One should use this option to coarsen the mesh, when a regular mesh for computation purposes is desired, i.e. a mesh with good aspect ratios or good quality elements. - - - Mesh for finite element computation : Coarsening (-1) - - - - - - 17 - 228 - 585 - 22 - - - - The given surface triangulation is modfied in accordance to a size map. + + + Mesh for finite element computation : Coarsening (-1) + + + + + + + The given surface triangulation is modified in accordance to a size map. The latter can be either the intrinsic size map (computed automatically and based on the surface properties, i.e. the local curvatures), or on a given size map (which is then combined to the intrinsic size map). -One should use this option to coarsen and enrich the mesh, when a regular mesh +One should use this option to coarse and enrich the mesh, when a regular mesh for computation purposes is desired, i.e. a mesh with good aspect ratios or good quality elements - - - Mesh for finite element computation : Coarsening and Enrichment (1) - - + + + Mesh for finite element computation : Coarsening and Enrichment (1) + + + + + + + + + + + + 10 + 420 + 750 + 70 + + + + This parameter enables the user to bound the maximal chordal deviation allowed, +that is the maximal distance allowed between the detected curve and the plane P +of the corresponding mesh face. +In other words, it avoids having faces too far away from the curve they should represent. + + + Chordal deviation Tolerance + + + + + 40 + 30 + 110 + 24 + + + + If the Units parameter is relative, epsilon max correspond to (per thousand) s*Tolerance/1000, where s is the size of the bounding box of the domain. +If the Units parameter is absolute, the tolerance parameter is expressed in model units: + if P=2 and point coordinates are given in millimeters, the maximal chordal deviation is 2 mm. + + + + + + 220 + 30 + 120 + 24 + + + + Values are expressed in the model units. + + + Absolute units + + + false + + + + + + 350 + 30 + 120 + 24 + + + + Values are relative (per thousand) to the bounding box size. + + + Relative units + + + true + 10 - 20 - 871 - 161 + 10 + 750 + 120 @@ -330,275 +404,128 @@ good quality elements
    Original Mesh - + + + + 40 + 70 + 190 + 31 + + + + + 10 + + + + Mesh File GMF format + + + + 18 + 18 + + + + + + + 240 + 70 + 481 + 31 + + + + + 10 + + + + + + + 40 + 30 + 190 + 31 + + + + Mesh Object Browser + + + + 18 + 18 + + + + false + + + + + + 240 + 30 + 481 + 31 + + + + + 10 + + + + 10 - 30 - 861 - 101 + 80 + 31 + 18 - - - - - - 10 - false - - - - QFrame::Box - - - Smesh mesh - - - false - - - 0 - - - - - - - - - - - ../../../../../../../../SalomeSrc/SMESH_V6_main/src/Tools/YamsPlug/open.png../../../../../../../../SalomeSrc/SMESH_V6_main/src/Tools/YamsPlug/open.png - - - - 18 - 18 - - - - false - - - - - - - - 10 - - - - - - - - or - - - - - - - - 10 - - - - Mesh File (GMF format) - - - - - - - - 10 - - - - - + + or + - - - - 430 - 540 - 81 - 31 - - - - - PreferDefault - - - - true - - - <html><head/><body><p>If the Units parameter is relative, epsilon max corresponds to 0.001x s x tolerance parameter where s is the size of the bounding box of the domain.</p><p>If the Units parameter (P) is absolute, the tolerance parameter is expressed in model units :</p><p>if P=2 and point coordinates are given in millimetre, it means that the maximal chordal deviation is 2 mm </p></body></html> - - - 0 - - - 1.000000000000000 - - - 1000.000000000000000 - - - 1.000000000000000 - - - 10.000000000000000 - - - - - - 30 - 500 - 801 - 37 - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></td></tr></table></body></html> - - - Units - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Set chordal deviation tolerance:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This parameter enables the user to bound the maximal chordal deviation allowed,</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">that is, the maximal distance allowed between the detected curve and the plane P</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">of the corresponding mesh face.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">In other words, it avoids having faces too far away from the curve </p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">they represent (or should represent).</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></td></tr></table></body></html> - - - Chordal deviation Tolerance - - - - - - - - - 60 - 540 - 230 - 31 - - - - - - - Values are expressed in the model units. - - - Absolute - - - false - - - - - - - Values are relative to the bounding box size. - - - Relative - - - true - - - - - - - - - 520 - 540 - 301 - 51 - - - - <html><head/><body><p><span style=" font-size:8pt;">0/00 if relative</span></p><p><span style=" font-size:8pt;">Mesh unit if absolute</span></p></body></html> - - - layoutWidget - layoutWidget groupBox GBOptim - SP_Tolerance - label_11 - Advanced Remeshing Options + Advanced Remeshing Options - + 10 10 - 761 - 71 + 750 + 120 - You can disable : + You can set/unset - 100 + 30 20 271 - 23 + 25 - if not set (ridge detection disabled), Yams will not try to detect any new ridge edge by its own mechanism : + If not set (ridge detection disabled), Yams will not try to detect any new ridge edge by its own mechanism : it will consider as ridge only the ridges given in the mesh. -All non-ridge edges that would have been detected as ridge by the Ridge angle paramaeter +All non-ridge edges that would have been detected as ridge by the ridge angle parameter (see below) will be considered as part of the same continuous patch. This option should not be checked when all the known ridges of the mesh are given and when all other possible ridges are not geometric ridges to take into account. @@ -613,10 +540,10 @@ when all other possible ridges are not geometric ridges to take into account. - 100 - 40 + 30 + 50 271 - 23 + 25 @@ -631,127 +558,159 @@ or add vertices (refines) to change the mesh. true + + + + + 30 + 80 + 271 + 25 + + + + If set, Yams creates new vertices placed on the curved surface and adds them to elements. +It means one extra vertex on edge (P2 or quadratic triangles). +New created vertices are saved in the .mesh file under keyword section 'Vertices' + + + split edge + + + false + + + + 10 - 90 - 841 - 391 + 140 + 750 + 270 - You can control + You can control +##1 - 10 + 30 30 - 91 - 23 + 100 + 25 - 0.890000000000000 + 0.89 - 0.010000000000000 + 0.01 - 0.040000000000000 + 0.04 - 120 - 20 - 731 - 61 + 140 + 30 + 630 + 30 This field (as well as tolerance) enables the user to control the accuracy of the piecewise linear approximation of the surface. This parameter enables the user to -control the maximal angle allowed between two adjacent faces. It can be used to +control the maximal angle allowed between two adjacent faces. It can be used to bound the maximal deviation of the mesh faces from the tangent planes at mesh vertices. In other words, it avoids having sharp angles between faces representing a smooth curve. This parameter enables the user to specify the maximal chordal deviation "max relatively to the curvature. Following that criterion: -- if the chordal deviation epsilon is smaller than epsilon max *r, it is acceptable to remove the considered point; +- if the chordal deviation epsilon is smaller than epsilon max*r, it is acceptable to remove the considered point; - if the chordal deviation epsilon is greater than epsiolon max*r, the considered mesh face should be redefined -by adding a point on the curve. + by adding a point on the curve. One can see that the smaller the radius r, the harder it is to satisfy this criterion: epsilon max is a real value corresponding to a percentage, the ratio between the chordal deviation to the local curvature. This field is used only for optimisation style -O values of -1, 0 and 1. The default value for "max is set to 0:04 which leads to angles of less than 33 degrees between two adjacent -faces . +faces.
    - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> -<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';">Geometrical approximation : Maximum angle (1-cos(angle)) allowed </span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';">between a face and a curve </span><span style=" font-family:'Sans Serif'; font-size:8pt;">(not separated by a ridge).</span><span style=" font-family:'Sans Serif';">)</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"><br /></p></td></tr></table></body></html> + Geometrical approximation: +Maximum angle allowed between a face and a curve (not separated by a ridge). + + +##2 + + + + 30 + 70 + 100 + 25 + + + + 90. + + + 45. - 120 - 80 - 691 - 71 + 140 + 70 + 630 + 30 - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> -<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';">Ridge angle:</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';">if the angle between the normal vectors of two adjacent faces</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';">exceeds this value, the edge common to the faces is a ridge</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"><br /></p></td></tr></table></body></html> + If the angle between the normal vectors of two adjacent faces exceeds this value, +the edge common to the faces is a ridge. - +##3 + - 10 - 100 - 91 - 23 + 30 + 110 + 100 + 25 + + 0.01 + - 90.000000000000000 + 100. + + + 0.1 - 45.000000000000000 + 100. - 120 - 160 - 681 - 61 + 140 + 110 + 630 + 30 - This parameter allows the user to prescribe a maximal size hmax + This parameter allows the user to prescribe a maximal size hmax for the mesh elements i.e., the lengths of the edges with respect to the specified size map. The corresponding values are either relative or absolute depending on the choosen parameter. The default values are automatically set based on the surface geometry (curvature dependent) and its @@ -760,24 +719,80 @@ Please note that, as it is not strictly possible to obey the given or computed s size may be slightly bigger than the prescribed ones. - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> -<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Maximal size allowed around vertices:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">the lengths of the edges with respect to the specified size map.</p></td></tr></table></body></html> + Maximal size allowed around vertices, +the lengths of the edges with respect to the specified size map. + + +##4 + + + + 30 + 150 + 100 + 25 + + + + 0. + + + 100. + + + 0.1 + + + 5. + + + + + + 140 + 150 + 630 + 30 + + + + This parameter allows the user to prescribe a maximal size hmax +for the mesh elements i.e., the lengths of the edges with respect to the specified + size map. The corresponding values are either relative or absolute depending on the choosen parameter. +The default values are automatically set based on the surface geometry (curvature dependent) and its +bounding box size. +Please note that, as it is not strictly possible to obey the given or computed size map, the actual maximal +size may be slightly bigger than the prescribed ones. + + + Minimal size allowed around vertices, +the lengths of the edges with respect to the specified size map. + + +##5 + + + + 30 + 190 + 100 + 25 + + + + 0.01 + + + 1.3 - 120 - 290 - 691 - 91 + 140 + 190 + 630 + 30 @@ -790,142 +805,10 @@ This procedure is de-activated if yams computes a mesh for finite element with o The default value is 1.3, which is the usual value set for computational meshes.
    - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> -<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Mesh Gradation ie the element size variation in the triangulation:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Yams will avoid having two adjacent edges which sizes </p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">vary more than the given gradation.</p></td></tr></table></body></html> + Mesh Gradation: the element size variation in the triangulation. +Yams will avoid having two adjacent edges which sizes vary more than the given gradation. - - - - 10 - 300 - 91 - 23 - - - - 0.010000000000000 - - - 1.300000000000000 - - - - - - 10 - 170 - 91 - 23 - - - - 0.010000000000000 - - - 100.000000000000000 - - - 0.100000000000000 - - - 100.000000000000000 - - - - - - 120 - 230 - 661 - 51 - - - - This parameter allows the user to prescribe a maximal size hmax -for the mesh elements i.e., the lengths of the edges with respect to the specified - size map. The corresponding values are either relative or absolute depending on the choosen parameter. -The default values are automatically set based on the surface geometry (curvature dependent) and its -bounding box size. -Please note that, as it is not strictly possible to obey the given or computed size map, the actual maximal -size may be slightly bigger than the prescribed ones. - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> -<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Minimal size allowed around vertices:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">the lengths of the edges with respect to the specified size map.</p></td></tr></table></body></html> - - - - - - 10 - 230 - 91 - 23 - - - - 0.000000000000000 - - - 100.000000000000000 - - - 0.100000000000000 - - - 5.000000000000000 - - - - - - - 20 - 490 - 751 - 31 - - - - You can enable : - - - - - - 70 - 530 - 271 - 23 - - - - if set, Yams creates new vertices placed on the curved surface and adds them to elements. -It means one extra vertex on edge (P2 or quadratic triangles). -New created vertices are saved in the .mesh file under keyword section Vertices - - - split edge - - - false - @@ -936,101 +819,80 @@ New created vertices are saved in the .mesh file under keyword section Vertices 10 - 30 - 741 - 131 + 10 + 750 + 130 Yams Generic Options - + + - 40 + 20 30 - 441 - 34 + 100 + 25 - - - - - Verbosity Level - - - - - - - Qt::Horizontal - - - - 28 - 20 - - - - - - 10 - 7 + 3 - - - - + + - 40 - 70 - 441 - 34 + 130 + 30 + 600 + 30 - - - - - - 225 - 25 - - + + sets the verbosity level. +From 0 (no detail) to 10 (very detailed). +Default is 3. + - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> -<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory size (in Mbytes)</p></td></tr></table></body></html> + Verbosity level - - - - - Qt::Horizontal - - - - 28 - 20 - - - - - + + + + 20 + 70 + 100 + 25 + + + + 100000 + + + 0 + + + + + + + 130 + 70 + 600 + 30 + + + + Memory size (in Mbytes) + The program requires roughly about 370 bytes per point. It is thus possible to estimate a priori the required memory size to complete a job. As an example of memory space needed, a mesh @@ -1041,33 +903,25 @@ The memory needed for mesh modification is allocated dynamically at the beginnin memory allowed, it will stop inserting points and, if possible, the current mesh will be saved as it is, valid and conformal, provided the input mesh was valid and conformal. Specify the memory if: -- the automatically allocated memory reveals insufficient when the user asked to enrich the given mesh; +- the automatically allocated memory reveals insufficient when the user asked to enrich the given mesh. - you want to limit the amount of memory used by the program. If the input mesh size requires more memory than requested or if the allocated memory (user defined or not) exceeds the machine capabilities, the tool will stop because of insufficient memory. - - 100000 - - - 0 - - - - + 10 - 230 - 741 - 141 + 150 + 750 + 170 - Plug-In Generic Options + Plug-in Generic Options @@ -1079,7 +933,7 @@ exceeds the machine capabilities, the tool will stop because of insufficient mem - File used to save Yams Params : + File used to save Yams hypothesis parameters : @@ -1094,10 +948,6 @@ exceeds the machine capabilities, the tool will stop because of insufficient mem - - - ../../../../../../../../SalomeSrc/SMESH_V6_main/src/Tools/YamsPlug/open.png../../../../../../../../SalomeSrc/SMESH_V6_main/src/Tools/YamsPlug/open.png - @@ -1109,6 +959,47 @@ exceeds the machine capabilities, the tool will stop because of insufficient mem + + + + + 20 + 110 + 70 + 31 + + + + Save + + + + 18 + 18 + + + + + + + + 120 + 110 + 70 + 31 + + + + Load + + + + 18 + 18 + + + + diff --git a/src/Tools/YamsPlug/doc/Generics_params.rst b/src/Tools/YamsPlug/doc/Generics_params.rst index 32b31b1ac..046e688c9 100644 --- a/src/Tools/YamsPlug/doc/Generics_params.rst +++ b/src/Tools/YamsPlug/doc/Generics_params.rst @@ -15,7 +15,7 @@ You usually don't have to set this parameter but you can choose to limit the amo - **File** -You can change the file used to store the remeshing hypothesis. see paragraph :ref:`hypothesis-label` for further informations. +You can change the file used to store remeshing hypotheses. see paragraph :ref:`hypothesis-label` for further informations. .. image:: images/Generic.png :align: center diff --git a/src/Tools/YamsPlug/doc/Makefile.am b/src/Tools/YamsPlug/doc/Makefile.am index d32f6589d..2841defc7 100644 --- a/src/Tools/YamsPlug/doc/Makefile.am +++ b/src/Tools/YamsPlug/doc/Makefile.am @@ -12,7 +12,7 @@ RSTFILES = lct.rst \ Generics_params.rst \ Advanced_params.rst -EXTRA_DIST += $(RSTFILES) images +EXTRA_DIST += $(RSTFILES) images files # You can set these variables from the command line. SPHINXOPTS = diff --git a/src/Tools/YamsPlug/doc/Mandatory_params.rst b/src/Tools/YamsPlug/doc/Mandatory_params.rst index c752c692b..f657c1d92 100644 --- a/src/Tools/YamsPlug/doc/Mandatory_params.rst +++ b/src/Tools/YamsPlug/doc/Mandatory_params.rst @@ -61,7 +61,7 @@ This is the main remeshing Option. Yams always does quality improvement. It is - **Mesh for finite element computation : Coarsening** - The given surface triangulation is modfied in accordance to a size map. The latter is the intrinsic size map (computed automatically and based on the surface properties, i.e. the local curvatures). One should use this option to coarsen the mesh, when a regular mesh for computation purposes is desired, i.e. a mesh with good aspect ratios or good quality elements. + The given surface triangulation is modified in accordance to a size map. The latter is the intrinsic size map (computed automatically and based on the surface properties, i.e. the local curvatures). One should use this option to coarsen the mesh, when a regular mesh for computation purposes is desired, i.e. a mesh with good aspect ratios or good quality elements. It is equivalent to Yams's batch option -1. diff --git a/src/Tools/YamsPlug/doc/editHypo.rst b/src/Tools/YamsPlug/doc/editHypo.rst index 414d8ad0d..75b8eb76a 100644 --- a/src/Tools/YamsPlug/doc/editHypo.rst +++ b/src/Tools/YamsPlug/doc/editHypo.rst @@ -4,17 +4,23 @@ How to save Yams Parameters =========================== -As Yams hypothesis are not meshing hypothesis for Salome (but hypothesis for yams), parameters -are stored in a special file. Default file is $HOME/.yams.dat. It is strongly recommended that you -change this name if you want to preserve the way you obtain a mesh : This file is never cleaned. -All sets of parameters are logged in it. +Yams hypothesis is not meshing hypothesis for Salome, but hypothesis for yams. +The current set of parameters is automatically written in the salome study object browser when you run computation. +Theses parameters could also be stored in a special file. +Default file is $HOME/.yams.dat. +This ASCII file is appended, and never cleaned. -- To save the current setting, click on "Save Params" pushbutton. -- A set of parameters is automatically written in the .yams.dat file when you run computation. -- Restoring the default settings can be done by pushing "Default Params". -- "Loading Params" will reload the last set of parameters +In frame "Plug-in Generic Options": +- To save the current setting in this file, click on "Save" pushbutton. +- To load the last set of parameters saved, click on "Load" pushbutton. + +At the bottom of the dialog window: + +- To save a current setting in the study object browser, click on "Save" pushbutton. +- To load a current setting from the study object browser, click on "Load" pushbutton. +- To load the default setting, click on "Default" pushbutton. . **example of .yams.dat** @@ -22,39 +28,25 @@ All sets of parameters are logged in it. .. code-block:: python - # Save intermediate params - # Params for mesh : - Optimisation ='Quality improvement Only (0)' - Units ='Relative' - Chordal_Tolerance_Deviation=1.0 - Ridge_Detection=True - Split_Edge=False - Point_Smoothing=True - Geometrical_Approximation=0.04 - Ridge_Angle=45.0 - Maximum_Size=-2.0 - Minimum_Size=-2.0 - Mesh_Gradation=1.3 - Verbosity=3 - Memory=0 - - - - # Params for Hypothese : monHypo_Yams_0 + # YAMS hypothesis parameters # Params for mesh : Mesh_1 - Optimisation ='Quality improvement Only (0)' - Units ='Relative' - Chordal_Tolerance_Deviation=1.0 - Ridge_Detection=True - Split_Edge=False - Point_Smoothing=True - Geometrical_Approximation=0.04 - Ridge_Angle=45.0 - Maximum_Size=-2.0 - Minimum_Size=-2.0 - Mesh_Gradation=1.3 + # Date : 23/05/13 14:23:18 + # Command : yams -v 3 -O 0 -Drelative,tolerance=0.100000,maxsize=0.010000,minsize=0.000000 /tmp/ForYams_1.mesh + Optimisation=Quality improvement Only (0) + Units=Relative + ChordalToleranceDeviation=0.1 + RidgeDetection=True + SplitEdge=False + PointSmoothing=True + GeometricalApproximation=0.04 + RidgeAngle=45.0 + MaximumSize=0.01 + MinimumSize=0.0 + MeshGradation=1.3 Verbosity=3 Memory=0 + + diff --git a/src/Tools/YamsPlug/doc/files/YamsWhitePaper_3.2.pdf b/src/Tools/YamsPlug/doc/files/YamsWhitePaper_3.2.pdf new file mode 100644 index 000000000..f445bba28 Binary files /dev/null and b/src/Tools/YamsPlug/doc/files/YamsWhitePaper_3.2.pdf differ diff --git a/src/Tools/YamsPlug/doc/images/Advanced.png b/src/Tools/YamsPlug/doc/images/Advanced.png index bd91a1733..eb8ee0fb0 100644 Binary files a/src/Tools/YamsPlug/doc/images/Advanced.png and b/src/Tools/YamsPlug/doc/images/Advanced.png differ diff --git a/src/Tools/YamsPlug/doc/images/AppelYams.png b/src/Tools/YamsPlug/doc/images/AppelYams.png index a18b9ef65..d3f6fddc6 100644 Binary files a/src/Tools/YamsPlug/doc/images/AppelYams.png and b/src/Tools/YamsPlug/doc/images/AppelYams.png differ diff --git a/src/Tools/YamsPlug/doc/images/Generic.png b/src/Tools/YamsPlug/doc/images/Generic.png index fb37ab42c..eaabb4c92 100644 Binary files a/src/Tools/YamsPlug/doc/images/Generic.png and b/src/Tools/YamsPlug/doc/images/Generic.png differ diff --git a/src/Tools/YamsPlug/doc/images/Simple.png b/src/Tools/YamsPlug/doc/images/Simple.png index 98cf1b9b9..63f61b421 100644 Binary files a/src/Tools/YamsPlug/doc/images/Simple.png and b/src/Tools/YamsPlug/doc/images/Simple.png differ diff --git a/src/Tools/YamsPlug/doc/index.rst b/src/Tools/YamsPlug/doc/index.rst index 864044638..45442f9ae 100644 --- a/src/Tools/YamsPlug/doc/index.rst +++ b/src/Tools/YamsPlug/doc/index.rst @@ -11,6 +11,8 @@ Mesh module for remeshing 2D Surface. Yams plug-in uses Distene commercial software Yams, which is an **automatic surface remeshing tool**. This plug_in offers only the most common functionnalities of the tool. +.. note:: + for a complete documentation, see :download:`Yams whitepaper `. Contents: @@ -19,8 +21,8 @@ Contents: lct.rst Mandatory_params.rst - Generics_params.rst Advanced_params.rst + Generics_params.rst editHypo.rst diff --git a/src/Tools/YamsPlug/doc/lct.rst b/src/Tools/YamsPlug/doc/lct.rst index 6f3bc515b..c26492602 100644 --- a/src/Tools/YamsPlug/doc/lct.rst +++ b/src/Tools/YamsPlug/doc/lct.rst @@ -1,7 +1,7 @@ Running Yams Plug-in ===================== -Yamms plug-in can be invoked via SMESH Plugin item in Mesh menu bar +Yams plug-in can be invoked via SMESH Plugin item in Mesh menu bar .. image:: images/AppelYams.png :align: center diff --git a/src/Tools/YamsPlug/monViewText.py b/src/Tools/YamsPlug/monViewText.py index a613f5d6b..ce291033b 100644 --- a/src/Tools/YamsPlug/monViewText.py +++ b/src/Tools/YamsPlug/monViewText.py @@ -1,4 +1,4 @@ -# -*- coding: iso-8859-1 -*- +# -*- coding: utf-8 -*- # Copyright (C) 2007-2013 EDF R&D # # This library is free software; you can redistribute it and/or @@ -28,45 +28,59 @@ from PyQt4.QtCore import * # Import des panels -# ------------------------------- # from ViewText import Ui_ViewExe -class MonViewText(Ui_ViewExe,QDialog): -# ------------------------------- # + +class MonViewText(Ui_ViewExe, QDialog): """ Classe permettant la visualisation de texte """ - def __init__(self,parent,txt): + def __init__(self, parent, txt): QDialog.__init__(self,parent) - self.pere=parent self.setupUi(self) - self.resize( QSize(600,600).expandedTo(self.minimumSizeHint()) ) - self.connect( self.PB_Ok,SIGNAL("clicked()"), self, SLOT("close()") ) + self.resize( QSize(1000,600).expandedTo(self.minimumSizeHint()) ) + #self.connect( self.PB_Ok,SIGNAL("clicked()"), self, SLOT("close()") ) + self.connect( self.PB_Ok,SIGNAL("clicked()"), self.theClose ) self.connect( self.PB_Save,SIGNAL("clicked()"), self.saveFile ) self.monExe=QProcess(self) - self.connect(self.monExe, SIGNAL("readyReadStandardOutput()"), self.readFromStdOut ) self.connect(self.monExe, SIGNAL("readyReadStandardError()"), self.readFromStdErr ) - self.connect(self.monExe, SIGNAL("finished(int )"), self.exeFinished ) # Je n arrive pas a utiliser le setEnvironment du QProcess # fonctionne hors Salome mais pas dans Salome ??? - LICENCE=os.environ['DISTENE_LICENCE_FILE_FOR_YAMS'] - txt='export DISTENE_LICENSE_FILE='+LICENCE+';'+ txt + cmds='' + try : + LICENCE_FILE=os.environ["DISTENE_LICENCE_FILE_FOR_YAMS"] + except: + LICENCE_FILE='' + try : + PATH=os.environ["DISTENE_PATH_FOR_YAMS"] + except: + PATH='' + if LICENCE_FILE != '': + cmds+='source '+LICENCE_FILE+'\n' + else: + cmds+="# $DISTENE_LICENCE_FILE_FOR_YAMS NOT SET\n" + if PATH != '': + cmds+='export PATH='+PATH+':$PATH\n' + else: + cmds+="# $DISTENE_PATH_FOR_YAMS NOT SET\n" + #cmds+='env\n' + cmds+='rm -f '+self.parent().fichierOut+'\n' + cmds+=txt+'\n' + cmds+='echo END_OF_Yams\n' pid=self.monExe.pid() - nomFichier='/tmp/yam_'+str(pid)+'.py' + nomFichier='/tmp/Yams_'+str(pid)+'.sh' f=open(nomFichier,'w') - f.write(txt) + f.write(cmds) f.close() maBidouille='sh ' + nomFichier self.monExe.start(maBidouille) self.monExe.closeWriteChannel() + self.enregistreResultatsDone=False self.show() - def exeFinished(self): - self.pere.enregistreResultat() - def saveFile(self): #recuperation du nom du fichier savedir=os.environ['HOME'] @@ -84,8 +98,19 @@ class MonViewText(Ui_ViewExe,QDialog): def readFromStdErr(self): a=self.monExe.readAllStandardError() - self.TB_Exe.append(QString.fromUtf8(a.data(),len(a))) ; + self.TB_Exe.append(QString.fromUtf8(a.data(),len(a))) def readFromStdOut(self) : a=self.monExe.readAllStandardOutput() - self.TB_Exe.append(QString.fromUtf8(a.data(),len(a))) ; + aa=QString.fromUtf8(a.data(),len(a)) + self.TB_Exe.append(aa) + if "END_OF_Yams" in aa: + self.parent().enregistreResultat() + self.enregistreResultatsDone=True + #self.theClose() + + def theClose(self): + if not self.enregistreResultatsDone: + self.parent().enregistreResultat() + self.enregistreResultatsDone=True + self.close() diff --git a/src/Tools/YamsPlug/monYamsPlugDialog.py b/src/Tools/YamsPlug/monYamsPlugDialog.py index 1e9c32fc9..d8ec10244 100644 --- a/src/Tools/YamsPlug/monYamsPlugDialog.py +++ b/src/Tools/YamsPlug/monYamsPlugDialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2007-2013 EDF R&D +# Copyright (C) 2007-2013 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 @@ -17,6 +17,7 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + # Modules Python # Modules Eficas @@ -31,286 +32,496 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget): """ """ def __init__(self): - QWidget.__init__(self) - self.setupUi(self) - self.connecterSignaux() - self.fichierIn="" - self.fichierOut="" - self.MeshIn="" - self.num=1 + QWidget.__init__(self) + self.setupUi(self) + self.connecterSignaux() + self.fichierIn="" + self.fichierOut="" + self.MeshIn="" + self.commande="" + self.num=1 + self.__selectedMesh=None -# Ces parametres ne sont pas remis à rien par le clean - self.paramsFile= os.path.abspath(os.path.join(os.environ['HOME'],'.yams.dat')) - self.LE_ParamsFile.setText(self.paramsFile) - self.LE_MeshFile.setText("") - self.LE_MeshSmesh.setText("") + # complex whith QResources: not used + # The icon are supposed to be located in the $SMESH_ROOT_DIR/share/salome/resources/smesh folder, + # other solution could be in the same folder than this python module file: + # iconfolder=os.path.dirname(os.path.abspath(__file__)) + + self.iconfolder=os.environ["SMESH_ROOT_DIR"]+"/share/salome/resources/smesh" + #print "monYamsPlugDialog iconfolder",iconfolder + icon = QIcon() + icon.addFile(os.path.join(self.iconfolder,"select1.png")) + self.PB_LoadHyp.setIcon(icon) + self.PB_LoadHyp.setToolTip("hypothesis from Salome Object Browser") + self.PB_SaveHyp.setIcon(icon) + self.PB_SaveHyp.setToolTip("hypothesis to Salome Object Browser") + self.PB_MeshSmesh.setIcon(icon) + self.PB_MeshSmesh.setToolTip("source mesh from Salome Object Browser") + icon = QIcon() + icon.addFile(os.path.join(self.iconfolder,"open.png")) + self.PB_ParamsFileExplorer.setIcon(icon) + self.PB_Load.setIcon(icon) + self.PB_Load.setToolTip("hypothesis from file") + self.PB_Save.setIcon(icon) + self.PB_Save.setToolTip("hypothesis to file") + self.PB_MeshFile.setIcon(icon) + self.PB_MeshFile.setToolTip("source mesh from a file in disk") + + #Ces parametres ne sont pas remis à rien par le clean + self.paramsFile= os.path.abspath(os.path.join(os.environ["HOME"],".yams.dat")) + self.LE_ParamsFile.setText(self.paramsFile) + self.LE_MeshFile.setText("") + self.LE_MeshSmesh.setText("") + + v1=QDoubleValidator(self) + v1.setBottom(0.) + #v1.setTop(1000.) #per thousand... only if relative + v1.setDecimals(2) + self.SP_Tolerance.setValidator(v1) + self.SP_Tolerance.titleForWarning="Chordal Tolerance" + + self.resize(800, 600) + self.clean() def connecterSignaux(self) : - self.connect(self.PB_Cancel,SIGNAL("clicked()"),self.PBCancelPressed) - self.connect(self.PB_Default,SIGNAL("clicked()"),self.clean) - self.connect(self.PB_Help,SIGNAL("clicked()"),self.PBHelpPressed) - self.connect(self.PB_Load,SIGNAL("clicked()"),self.PBLoadPressed) - self.connect(self.PB_OK,SIGNAL("clicked()"),self.PBOKPressed) - self.connect(self.PB_Save,SIGNAL("clicked()"),self.PBSavePressed) - self.connect(self.PB_MeshFile,SIGNAL("clicked()"),self.PBMeshFilePressed) - self.connect(self.PB_MeshSmesh,SIGNAL("clicked()"),self.PBMeshSmeshPressed) - self.connect(self.PB_ParamsFileExplorer,SIGNAL("clicked()"),self.setParamsFileName) - self.connect(self.LE_MeshFile,SIGNAL("returnPressed()"),self.meshFileNameChanged) - self.connect(self.LE_ParamsFile,SIGNAL("returnPressed()"),self.paramsFileNameChanged) - + self.connect(self.PB_Cancel,SIGNAL("clicked()"),self.PBCancelPressed) + self.connect(self.PB_Default,SIGNAL("clicked()"),self.clean) + self.connect(self.PB_Help,SIGNAL("clicked()"),self.PBHelpPressed) + self.connect(self.PB_OK,SIGNAL("clicked()"),self.PBOKPressed) + + self.connect(self.PB_Load,SIGNAL("clicked()"),self.PBLoadPressed) + self.connect(self.PB_Save,SIGNAL("clicked()"),self.PBSavePressed) + self.connect(self.PB_LoadHyp,SIGNAL("clicked()"),self.PBLoadHypPressed) + self.connect(self.PB_SaveHyp,SIGNAL("clicked()"),self.PBSaveHypPressed) + + self.connect(self.PB_MeshFile,SIGNAL("clicked()"),self.PBMeshFilePressed) + self.connect(self.PB_MeshSmesh,SIGNAL("clicked()"),self.PBMeshSmeshPressed) + self.connect(self.LE_MeshSmesh,SIGNAL("returnPressed()"),self.meshSmeshNameChanged) + self.connect(self.PB_ParamsFileExplorer,SIGNAL("clicked()"),self.setParamsFileName) + self.connect(self.LE_MeshFile,SIGNAL("returnPressed()"),self.meshFileNameChanged) + self.connect(self.LE_ParamsFile,SIGNAL("returnPressed()"),self.paramsFileNameChanged) def PBHelpPressed(self): - try : - maDoc=os.environ['DISTENE_YAMS_DOC_PDF'] - except Exception: - QMessageBox.warning( self, "Help unavailable", str(maDoc) + " not found") - command="xdg-open "+maDoc+";" - subprocess.call(command, shell=True) - + try : + mydir=os.environ["SMESH_ROOT_DIR"] + except Exception: + QMessageBox.warning(self, "Help", "Help unavailable $SMESH_ROOT_DIR not found") + return + maDoc=mydir+"/share/doc/salome/gui/SMESH/yams/_downloads/YamsWhitePaper_3.2.pdf" + command="xdg-open "+maDoc+";" + subprocess.call(command, shell=True) def PBOKPressed(self): - if not(self.PrepareLigneCommande()) : return - self.PBSavePressed(NomHypo=True) - maFenetre=MonViewText(self,self.commande) + if not(self.PrepareLigneCommande()): + #warning done yet + #QMessageBox.warning(self, "Compute", "Command not found") + return + maFenetre=MonViewText(self,self.commande) def enregistreResultat(self): - if not(os.path.isfile(self.fichierOut)) : return - import smesh - import SMESH - import salome - from salome.kernel import studyedit + import salome + import SMESH + from salome.kernel import studyedit + from salome.smesh import smeshBuilder + smesh = smeshBuilder.New(salome.myStudy) + + if not os.path.isfile(self.fichierOut): + QMessageBox.warning(self, "Compute", "Result file "+self.fichierOut+" not found") - maStudy=studyedit.getActiveStudy() - smesh.SetCurrentStudy(maStudy) - (outputMesh, status) = smesh.CreateMeshesFromGMF(self.fichierOut) - meshname = 'yams'+str(self.num) - smesh.SetName(outputMesh.GetMesh(), meshname) - outputMesh.Compute() + maStudy=studyedit.getActiveStudy() + smesh.SetCurrentStudy(maStudy) + (outputMesh, status) = smesh.CreateMeshesFromGMF(self.fichierOut) + name=str(self.LE_MeshSmesh.text()) + initialMeshFile=None + initialMeshObject=None + if name=="": + a=str(self.fichierIn) + name=os.path.basename(os.path.splitext(a)[0]) + initialMeshFile=a + else: + initialMeshObject=maStudy.FindObjectByName(name ,"SMESH")[0] + meshname = name+"_YAMS_"+str(self.num) + smesh.SetName(outputMesh.GetMesh(), meshname) + outputMesh.Compute() #no algorithms message for "Mesh_x" has been computed with warnings: - global 1D algorithm is missing - self.editor = studyedit.getStudyEditor() # - moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH") - HypReMeshEntry = self.editor.findOrCreateItem( moduleEntry, name = 'HypoForRemesh', - comment = 'HypoForRemshing') - monStudyBuilder=maStudy.NewBuilder(); - monStudyBuilder.NewCommand(); - newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry) - aNameAttrib=monStudyBuilder.FindOrCreateAttribute(newStudyIter,"AttributeName") - hypoName = 'monHypo_Yams_'+str(self.num) - aNameAttrib.SetValue(hypoName) - aCommentAttrib=monStudyBuilder.FindOrCreateAttribute(newStudyIter,"AttributeComment") - aCommentAttrib.SetValue(str(self.commande)) - - SOMesh=maStudy.FindObjectByName(meshname ,"SMESH")[0] - newLink=monStudyBuilder.NewObject(SOMesh) - monStudyBuilder.Addreference(newLink, newStudyIter); - if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0) - self.num+=1 - return True + self.editor = studyedit.getStudyEditor() + moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH") + HypReMeshEntry = self.editor.findOrCreateItem( + moduleEntry, name = "Plugins Hypotheses", icon="mesh_tree_hypo.png") #, comment = "HypoForRemeshing" ) + + monStudyBuilder=maStudy.NewBuilder() + monStudyBuilder.NewCommand() + newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry) + self.editor.setAttributeValue(newStudyIter, "AttributeName", "YAMS Parameters_"+str(self.num)) + self.editor.setAttributeValue(newStudyIter, "AttributeComment", self.getResumeData(separator=" ; ")) + + SOMesh=maStudy.FindObjectByName(meshname ,"SMESH")[0] + + if initialMeshFile!=None: + newStudyFileName=monStudyBuilder.NewObject(SOMesh) + self.editor.setAttributeValue(newStudyFileName, "AttributeName", "meshFile") + self.editor.setAttributeValue(newStudyFileName, "AttributeExternalFileDef", initialMeshFile) + self.editor.setAttributeValue(newStudyFileName, "AttributeComment", initialMeshFile) - def PBSavePressed(self,NomHypo=False): - if NomHypo : text = '# Params for Hypothese : monHypo_Yams_'+str(self.num - 1)+"\n" - else : text = '# Save intermediate params \n' - text += "# Params for mesh : " + self.LE_MeshSmesh.text() +'\n' - for RB in self.GBOptim.findChildren(QRadioButton,): - if RB.isChecked()==True: - text+="Optimisation ='"+RB.text()+"'\n" - break - for RB in self.GBUnit.findChildren(QRadioButton,): - if RB.isChecked()==True: - text+="Units ='"+RB.text()+"'\n" - text+='Chordal_Tolerance_Deviation='+str(self.SP_Tolerance.value())+'\n' + if initialMeshObject!=None: + newLink=monStudyBuilder.NewObject(SOMesh) + monStudyBuilder.Addreference(newLink, initialMeshObject) - text+='Ridge_Detection=' + str(self.CB_Ridge.isChecked())+'\n' - text+='Split_Edge=' + str(self.CB_SplitEdge.isChecked())+'\n' - text+='Point_Smoothing=' + str(self.CB_Point.isChecked())+'\n' - text+='Geometrical_Approximation='+ str(self.SP_Geomapp.value()) +'\n' - text+='Ridge_Angle=' + str(self.SP_Ridge.value()) +'\n' - text+='Maximum_Size=' + str(self.SP_MaxSize.value()) +'\n' - text+='Minimum_Size=' + str(self.SP_MaxSize.value()) +'\n' - text+='Mesh_Gradation=' + str(self.SP_Gradation.value())+'\n' + newLink=monStudyBuilder.NewObject(SOMesh) + monStudyBuilder.Addreference(newLink, newStudyIter) - text+='Verbosity=' + str(self.SP_Verbosity.value())+'\n' - text+='Memory=' + str(self.SP_Memory.value())+'\n' - text+='\n\n' + if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0) + self.num+=1 + return True - try : - f=open(self.paramsFile,'a') - except : - QMessageBox.warning( self, "File", "Unable to open "+self.paramsFile) - return - try : - f.write(text) - except : - QMessageBox.warning( self, "File", "Unable to write "+self.paramsFile) - return - f.close() + def PBSavePressed(self): + from datetime import datetime + if not(self.PrepareLigneCommande()): return + text = "# YAMS hypothesis parameters\n" + text += "# Params for mesh : " + self.LE_MeshSmesh.text() +"\n" + text += datetime.now().strftime("# Date : %d/%m/%y %H:%M:%S\n") + text += "# Command : "+self.commande+"\n" + text += self.getResumeData(separator="\n") + text += "\n\n" + + try: + f=open(self.paramsFile,"a") + except: + QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile) + return + try: + f.write(text) + except: + QMessageBox.warning(self, "File", "Unable to write "+self.paramsFile) + return + f.close() + + def PBSaveHypPressed(self): + """save hypothesis in Object Browser""" + import salome + import SMESH + from salome.kernel import studyedit + from salome.smesh import smeshBuilder + smesh = smeshBuilder.New(salome.myStudy) + + maStudy=studyedit.getActiveStudy() + smesh.SetCurrentStudy(maStudy) + + self.editor = studyedit.getStudyEditor() + moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH") + HypReMeshEntry = self.editor.findOrCreateItem( + moduleEntry, name = "Plugins Hypotheses", icon="mesh_tree_hypo.png") #, comment = "HypoForRemeshing" ) + + monStudyBuilder=maStudy.NewBuilder() + monStudyBuilder.NewCommand() + newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry) + self.editor.setAttributeValue(newStudyIter, "AttributeName", "YAMS Parameters_"+str(self.num)) + self.editor.setAttributeValue(newStudyIter, "AttributeComment", self.getResumeData(separator=" ; ")) + + if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(0) + self.num+=1 + return True + + def SP_toStr(self, widget): + """only for a QLineEdit widget""" + #cr, pos=widget.validator().validate(res, 0) #n.b. "1,3" is acceptable !locale! + try: + val=float(widget.text()) + except: + QMessageBox.warning(self, widget.titleForWarning, "float value is incorrect: '"+widget.text()+"'") + res=str(widget.validator().bottom()) + widget.setProperty("text", res) + return res + valtest=widget.validator().bottom() + if valtest!=None: + if valvaltest: + QMessageBox.warning(self, widget.titleForWarning, "float value is over maximum: "+str(val)+" > "+str(valtest)) + res=str(valtest) + widget.setProperty("text", res) + return res + return str(val) + + def getResumeData(self, separator="\n"): + text="" + for RB in self.GBOptim.findChildren(QRadioButton,): + if RB.isChecked()==True: + text+="Optimisation="+RB.text()+separator + break + if self.RB_Absolute.isChecked(): + text+="Units=absolute"+separator + else: + text+="Units=relative"+separator + v=self.SP_toStr(self.SP_Tolerance) + text+="ChordalToleranceDeviation="+v+separator + text+="RidgeDetection="+str(self.CB_Ridge.isChecked())+separator + text+="SplitEdge="+str(self.CB_SplitEdge.isChecked())+separator + text+="PointSmoothing="+str(self.CB_Point.isChecked())+separator + text+="GeometricalApproximation="+str(self.SP_Geomapp.value())+separator + text+="RidgeAngle="+str(self.SP_Ridge.value())+separator + text+="MaximumSize="+str(self.SP_MaxSize.value())+separator + text+="MinimumSize="+str(self.SP_MinSize.value())+separator + text+="MeshGradation="+str(self.SP_Gradation.value())+separator + text+="Verbosity="+str(self.SP_Verbosity.value())+separator + text+="Memory="+str(self.SP_Memory.value())+separator + return str(text) + + def loadResumeData(self, hypothesis, separator="\n"): + text=str(hypothesis) + self.clean() + for slig in reversed(text.split(separator)): + lig=slig.strip() + #print "load ResumeData",lig + if lig=="": continue #skip blanck lines + if lig[0]=="#": break + try: + tit,value=lig.split("=") + if tit=="Optimisation": + #no need: exlusives QRadioButton + #for RB in self.GBOptim.findChildren(QRadioButton,): + # RB.setChecked(False) + for RB in self.GBOptim.findChildren(QRadioButton,): + if RB.text()==value : + RB.setChecked(True) + break + if tit=="Units": + if value=="absolute": + self.RB_Absolute.setChecked(True) + self.RB_Relative.setChecked(False) + else: + self.RB_Absolute.setChecked(False) + self.RB_Relative.setChecked(True) + if tit=="ChordalToleranceDeviation": self.SP_Tolerance.setProperty("text", float(value)) + if tit=="RidgeDetection": self.CB_Ridge.setChecked(value=="True") + if tit=="SplitEdge": self.CB_SplitEdge.setChecked(value=="True") + if tit=="PointSmoothing": self.CB_Point.setChecked(value=="True") + if tit=="GeometricalApproximation": self.SP_Geomapp.setProperty("value", float(value)) + if tit=="RidgeAngle": self.SP_Ridge.setProperty("value", float(value)) + if tit=="MaximumSize": self.SP_MaxSize.setProperty("value", float(value)) + if tit=="MinimumSize": self.SP_MinSize.setProperty("value", float(value)) + if tit=="MeshGradation": self.SP_Gradation.setProperty("value", float(value)) + if tit=="Verbosity": self.SP_Verbosity.setProperty("value", int(float(value))) + if tit=="Memory": self.SP_Memory.setProperty("value", float(value)) + except: + QMessageBox.warning(self, "load YAMS Hypothesis", "Problem on '"+lig+"'") def PBLoadPressed(self): - try : - f=open(self.paramsFile,'r') - except : - QMessageBox.warning( self, "File", "Unable to open "+self.paramsFile) - return - try : - text=f.read() - except : - QMessageBox.warning( self, "File", "Unable to read "+self.paramsFile) - return - f.close() - d={} - exec text in d - for RB in self.GBOptim.findChildren(QRadioButton,): - if d['Optimisation']== RB.text(): - RB.setChecked(True) - break - for RB in self.GBUnit.findChildren(QRadioButton,): - if d['Units']== RB.text(): - RB.setChecked(True) - break - self.SP_Tolerance.setValue(d['Chordal_Tolerance_Deviation']) - - self.CB_Ridge.setChecked(d['Ridge_Detection']) - self.CB_Point.setChecked(d['Point_Smoothing']) - self.CB_SplitEdge.setChecked(d['Split_Edge']) - self.SP_Geomapp.setValue(d['Geometrical_Approximation']) - self.SP_Ridge.setValue(d['Ridge_Angle']) - self.SP_MaxSize.setValue(d['Maximum_Size']) - self.SP_MinSize.setValue(d['Minimum_Size']) - self.SP_Gradation.setValue(d['Mesh_Gradation']) - - self.SP_Verbosity.setValue(d['Verbosity']) - self.SP_Memory.setValue(d['Memory']) + """load last hypothesis saved in tail of file""" + try: + f=open(self.paramsFile,"r") + except: + QMessageBox.warning(self, "File", "Unable to open "+self.paramsFile) + return + try: + text=f.read() + except: + QMessageBox.warning(self, "File", "Unable to read "+self.paramsFile) + return + f.close() + self.loadResumeData(text, separator="\n") + def PBLoadHypPressed(self): + """load hypothesis saved in Object Browser""" + #QMessageBox.warning(self, "load Object Browser YAMS hypothesis", "TODO") + import salome + from salome.kernel import studyedit + from salome.smesh.smeshstudytools import SMeshStudyTools + from salome.gui import helper as guihelper + from omniORB import CORBA + mySObject, myEntry = guihelper.getSObjectSelected() + if CORBA.is_nil(mySObject) or mySObject==None: + QMessageBox.critical(self, "Hypothese", "select an Object Browser YAMS hypothesis") + return + + text=mySObject.GetComment() + + #a verification + if "Optimisation=" not in text: + QMessageBox.critical(self, "Load Hypothese", "Object Browser selection not a YAMS Hypothesis") + return + self.loadResumeData(text, separator=" ; ") + return + def PBCancelPressed(self): - self.close() + self.close() def PBMeshFilePressed(self): - fd = QFileDialog(self, "select an existing Mesh file", self.LE_MeshFile.text(), "Mesh-Files (*.mesh);;All Files (*)") - if fd.exec_(): - infile = fd.selectedFiles()[0] - self.LE_MeshFile.setText(infile) - self.fichierIn=infile.toLatin1() + fd = QFileDialog(self, "select an existing Mesh file", self.LE_MeshFile.text(), "Mesh-Files (*.mesh);;All Files (*)") + if fd.exec_(): + infile = fd.selectedFiles()[0] + self.LE_MeshFile.setText(infile) + self.fichierIn=infile.toLatin1() + self.MeshIn="" + self.LE_MeshSmesh.setText("") def setParamsFileName(self): - fd = QFileDialog(self, "select a file", self.LE_ParamsFile.text(), "dat Files (*.dat);;All Files (*)") - if fd.exec_(): - infile = fd.selectedFiles()[0] - self.LE_ParamsFile.setText(infile) - self.paramsFile=infile.toLatin1() - + fd = QFileDialog(self, "select a file", self.LE_ParamsFile.text(), "dat Files (*.dat);;All Files (*)") + if fd.exec_(): + infile = fd.selectedFiles()[0] + self.LE_ParamsFile.setText(infile) + self.paramsFile=infile.toLatin1() def meshFileNameChanged(self): - self.fichierIn=self.LE_MeshFile.text() - if os.path.exists(self.fichierIn): return - QMessageBox.warning( self, "Unknown File", "File doesn't exist") + self.fichierIn=str(self.LE_MeshFile.text()) + #print "meshFileNameChanged", self.fichierIn + if os.path.exists(self.fichierIn): + self.__selectedMesh=None + self.MeshIn="" + self.LE_MeshSmesh.setText("") + return + QMessageBox.warning(self, "Mesh file", "File doesn't exist") + + def meshSmeshNameChanged(self): + """only change by GUI mouse selection, otherwise clear""" + self.__selectedMesh = None + self.MeshIn="" + self.LE_MeshSmesh.setText("") + self.fichierIn="" + return def paramsFileNameChanged(self): - self.paramsFile=self.LE_ParamsFile.text() + self.paramsFile=self.LE_ParamsFile.text() def PBMeshSmeshPressed(self): - import salome - import smesh - from salome.kernel import studyedit - from salome.smesh.smeshstudytools import SMeshStudyTools - from salome.gui import helper as guihelper - from omniORB import CORBA + from omniORB import CORBA + import salome + from salome.kernel import studyedit + from salome.smesh.smeshstudytools import SMeshStudyTools + from salome.gui import helper as guihelper + from salome.smesh import smeshBuilder + smesh = smeshBuilder.New(salome.myStudy) - mySObject, myEntry = guihelper.getSObjectSelected() - if CORBA.is_nil(mySObject) or mySObject==None: - QMessageBox.critical(self, "Mesh", "select an input mesh") - return - self.smeshStudyTool = SMeshStudyTools() + mySObject, myEntry = guihelper.getSObjectSelected() + if CORBA.is_nil(mySObject) or mySObject==None: + QMessageBox.critical(self, "Mesh", "select an input mesh") + return + self.smeshStudyTool = SMeshStudyTools() + try: self.__selectedMesh = self.smeshStudyTool.getMeshObjectFromSObject(mySObject) - if CORBA.is_nil(self.__selectedMesh): - QMessageBox.critical(self, "Mesh", "select an input mesh") - return - myName = mySObject.GetName() - self.MeshIn=myName - self.LE_MeshSmesh.setText(myName) + except: + QMessageBox.critical(self, "Mesh", "select an input mesh") + return + if CORBA.is_nil(self.__selectedMesh): + QMessageBox.critical(self, "Mesh", "select an input mesh") + return + myName = mySObject.GetName() + #print "MeshSmeshNameChanged", myName + self.MeshIn=myName + self.LE_MeshSmesh.setText(myName) + self.LE_MeshFile.setText("") + self.fichierIn="" def prepareFichier(self): - self.fichierIn="/tmp/PourYam_"+str(self.num)+".mesh" - import SMESH - self.__selectedMesh.ExportGMF(self.__selectedMesh,self.fichierIn, True) + self.fichierIn="/tmp/ForYams_"+str(self.num)+".mesh" + self.__selectedMesh.ExportGMF(self.__selectedMesh, self.fichierIn, True) def PrepareLigneCommande(self): - self.commande="yams " - verbosity=str(self.SP_Verbosity.value()) - self.commande+="-v "+verbosity - for obj in self.mesRB.children(): - try : - if obj.isChecked(): - self.style=obj.objectName().remove(0,3) - self.style.replace("_","-") - break - except : - pass - self.commande+=" -O "+self.style.toLatin1() - if self.fichierIn=="" and self.MeshIn=="" : - QMessageBox.critical(self, "Mesh", "select an input mesh") - return False - if self.MeshIn!="" : self.prepareFichier() - if not (os.path.isfile(self.fichierIn)): - QMessageBox.critical(self, "File", "unable to read GMF Mesh in "+str(self.fichierIn)) - return False + if self.fichierIn=="" and self.MeshIn=="": + QMessageBox.critical(self, "Mesh", "select an input mesh") + return False + if self.__selectedMesh!=None: self.prepareFichier() + if not (os.path.isfile(self.fichierIn)): + QMessageBox.critical(self, "File", "unable to read GMF Mesh in "+str(self.fichierIn)) + return False + + self.commande="yams" + verbosity=str(self.SP_Verbosity.value()) + self.commande+=" -v "+verbosity + for obj in self.GBOptim.findChildren(QRadioButton,): + try: + if obj.isChecked(): + self.style=obj.objectName().remove(0,3) + self.style.replace("_","-") + break + except: + pass + self.commande+=" -O "+self.style.toLatin1() - deb=os.path.splitext(self.fichierIn) - self.fichierOut=deb[0]+'.d.meshb' + deb=os.path.splitext(self.fichierIn) + self.fichierOut=deb[0] + ".d.meshb" - if self.RB_Absolute.isChecked()==True : - self.commande+=' -Dabsolute' - else : - self.commande+=' -Drelative' - self.commande+=',tolerance=%f'%self.SP_Tolerance.value() - if self.CB_Ridge.isChecked()==False : self.commande+=',-nr' - if self.CB_Point.isChecked()==False : self.commande+=',-ns' - if self.SP_Geomapp.value()!=0.04 : self.commande+=',geomapp=%f'%self.SP_Geomapp.value() - if self.SP_Ridge.value()!=45.0 : self.commande+=',ridge=%f'%self.SP_Ridge.value() - if self.SP_MaxSize.value()!=100 : self.commande+=',maxsize=%f'%self.SP_MaxSize.value() - if self.SP_MinSize.value()!=5 : self.commande+=',minsize=%f'%self.SP_MinSize.value() - if self.SP_Gradation.value()!=1.3 : self.commande+=',gradation=%f'%self.SP_MaxSize.value() - if self.CB_SplitEdge.isChecked()==True : self.commande+=',splitedge=1' + if self.RB_Absolute.isChecked()==True : + self.commande+=" -Dabsolute" + else : + self.commande+=" -Drelative" + + v=self.SP_toStr(self.SP_Tolerance) + self.commande+=",tolerance="+v + if self.CB_Ridge.isChecked()==False : self.commande+=",-nr" + if self.CB_Point.isChecked()==False : self.commande+=",-ns" + if self.SP_Geomapp.value()!=0.04 : self.commande+=",geomapp=%f"%self.SP_Geomapp.value() + if self.SP_Ridge.value()!=45.0 : self.commande+=",ridge=%f"%self.SP_Ridge.value() + if self.SP_MaxSize.value()!=100 : self.commande+=",maxsize=%f"%self.SP_MaxSize.value() + if self.SP_MinSize.value()!=5 : self.commande+=",minsize=%f"%self.SP_MinSize.value() + if self.SP_Gradation.value()!=1.3 : self.commande+=",gradation=%f"%self.SP_MaxSize.value() + if self.CB_SplitEdge.isChecked()==True : self.commande+=",splitedge=1" - if self.SP_Verbosity.value()!=3 : self.commande+=' -v %d'%self.SP_Verbosity.value() - if self.SP_Memory.value()!=0 : self.commande+=' -m %d'%self.SP_Memory.value() + if self.SP_Verbosity.value()!=3 : self.commande+=" -v %d"%self.SP_Verbosity.value() + if self.SP_Memory.value()!=0 : self.commande+=" -m %d"%self.SP_Memory.value() - self.commande+=" "+self.fichierIn - return True + self.commande+=" "+self.fichierIn + return True def clean(self): - self.RB_0.setChecked(True) - self.RB_G.setChecked(False) - self.RB_U.setChecked(False) - self.RB_S.setChecked(False) - self.RB_2.setChecked(False) - self.RB_1.setChecked(False) - self.RB_Absolute.setChecked(False) - self.RB_Relative.setChecked(True) - self.SP_Tolerance.setProperty("value", 0.1) - self.SP_Geomapp.setProperty("value", 0.04) - self.SP_Ridge.setProperty("value", 45.0) - self.SP_Gradation.setProperty("value", 1.3) - self.CB_Ridge.setChecked(True) - self.CB_Point.setChecked(True) - self.CB_SplitEdge.setChecked(False) - self.SP_MaxSize.setProperty("value", -2.0) - self.SP_MinSize.setProperty("value", -2.0) - self.SP_Verbosity.setProperty("value", 3) - self.SP_Memory.setProperty("value", 0) - + self.RB_0.setChecked(True) + #no need: exlusives QRadioButton + #self.RB_G.setChecked(False) + #self.RB_U.setChecked(False) + #self.RB_S.setChecked(False) + #self.RB_2.setChecked(False) + #self.RB_1.setChecked(False) + self.RB_Relative.setChecked(True) + #no need: exlusives QRadioButton + #self.RB_Absolute.setChecked(False) + self.SP_Tolerance.setProperty("text", "10.") + self.SP_Geomapp.setProperty("value", 0.04) + self.SP_Ridge.setProperty("value", 45.0) + self.SP_Gradation.setProperty("value", 1.3) + self.CB_Ridge.setChecked(True) + self.CB_Point.setChecked(True) + self.CB_SplitEdge.setChecked(False) + self.SP_MaxSize.setProperty("value", -2.0) + self.SP_MinSize.setProperty("value", -2.0) + self.SP_Verbosity.setProperty("value", 3) + self.SP_Memory.setProperty("value", 0) __dialog=None def getDialog(): - """ - This function returns a singleton instance of the plugin dialog. - c est obligatoire pour faire un show sans parent... - """ - global __dialog - if __dialog is None: - __dialog = MonYamsPlugDialog() - #else : - # __dialog.clean() - return __dialog + """ + This function returns a singleton instance of the plugin dialog. + c est obligatoire pour faire un show sans parent... + """ + global __dialog + if __dialog is None: + __dialog = MonYamsPlugDialog() + #else : + # __dialog.clean() + return __dialog +# +# ============================================================================== +# Basic use cases and unit test functions +# ============================================================================== +# +def TEST_MonYamsPlugDialog(): + import sys + from PyQt4.QtGui import QApplication + from PyQt4.QtCore import QObject, SIGNAL, SLOT + app = QApplication(sys.argv) + QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) + + dlg=MonYamsPlugDialog() + dlg.show() + sys.exit(app.exec_()) + +if __name__ == "__main__": + TEST_MonYamsPlugDialog() + pass diff --git a/src/Tools/YamsPlug/open.png b/src/Tools/YamsPlug/open.png new file mode 100644 index 000000000..8ed143ebd Binary files /dev/null and b/src/Tools/YamsPlug/open.png differ diff --git a/src/Tools/YamsPlug/yamsplug_plugin.py b/src/Tools/YamsPlug/yamsplug_plugin.py index cc7a7c130..f61ed050f 100644 --- a/src/Tools/YamsPlug/yamsplug_plugin.py +++ b/src/Tools/YamsPlug/yamsplug_plugin.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (C) 2006-2013 EDF R&D # # This library is free software; you can redistribute it and/or @@ -34,11 +35,12 @@ def YamsLct(context): from PyQt4.QtGui import QFileDialog from PyQt4.QtGui import QMessageBox + #prior test to avoid unnecessary user GUI work with ending crash try : os.environ['DISTENE_LICENCE_FILE_FOR_YAMS'] except: - QMessageBox.warning(None,"Products","Distene's products are not installed") + QMessageBox.warning(None,"Products","Distene's product Yams is not installed.\nrequired environment variable:\nDISTENE_LICENCE_FILE_FOR_YAMS='/.../dlim8.var.sh'") return import monYamsPlugDialog - window=monYamsPlugDialog.getDialog() + window=monYamsPlugDialog.getDialog() window.show() diff --git a/src/Tools/padder/doc/input/padder_userguide.doc b/src/Tools/padder/doc/input/padder_userguide.doc index 9c41e101a..21a227997 100644 --- a/src/Tools/padder/doc/input/padder_userguide.doc +++ b/src/Tools/padder/doc/input/padder_userguide.doc @@ -156,7 +156,7 @@ installation process of the SALOME plateform, on the basis of the environment variable PADDERHOME that localizes the installation root of the SpherePadder external program. This installation process creates a configuration file padder.cfg located in the folder -/share/salome/plugins/smesh, where is +\/share/salome/plugins/smesh, where \ is the installation root directory of the SMESH module. In the case where you have to specify a different configuration than @@ -262,7 +262,7 @@ ssh-copy-id -i ~/.ssh/id_rsa.pub @ \endcode You can check the configuration by testing that you can connect to the -host with the login without being asked a +host \ with the login \ without being asked a password: \code diff --git a/src/Tools/padder/meshjob/impl/Makefile.am b/src/Tools/padder/meshjob/impl/Makefile.am index cd3e8b540..c72666449 100644 --- a/src/Tools/padder/meshjob/impl/Makefile.am +++ b/src/Tools/padder/meshjob/impl/Makefile.am @@ -71,7 +71,7 @@ libSPADDERPluginTesterEngine_la_LIBADD = \ # For testing SMESH # libSPADDERPluginTesterEngine_la_CXXFLAGS += \ - @GEOM_CXXFLAGS@ @MED_CXXFLAGS@ \ + @GEOM_CXXFLAGS@ \ -I$(top_builddir)/idl \ -I$(top_srcdir)/src/SMESH \ -I$(top_srcdir)/src/SMESH_I \ diff --git a/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.cxx b/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.cxx index 328c42022..83565540c 100644 --- a/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.cxx +++ b/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.cxx @@ -100,6 +100,7 @@ bool SPADDERPluginTester_i::testkernel() beginService("SPADDERPluginTester_i::testplugin"); Engines::SalomeLauncher_ptr salomeLauncher = KERNEL::getSalomeLauncher(); + salomeLauncher = NULL; endService("SPADDERPluginTester_i::testplugin"); return true; diff --git a/src/Tools/smesh_plugins.py b/src/Tools/smesh_plugins.py index 1702f09cd..e61dd16a7 100644 --- a/src/Tools/smesh_plugins.py +++ b/src/Tools/smesh_plugins.py @@ -24,6 +24,7 @@ import salome_pluginsmanager from spadderPlugin import runSpadderPlugin from meshcut_plugin import MeshCut from yamsplug_plugin import YamsLct +from MGCleanerplug_plugin import MGCleanerLct salome_pluginsmanager.AddFunction('PADDER mesher', 'Create a mesh with PADDER', @@ -36,3 +37,8 @@ salome_pluginsmanager.AddFunction('MeshCut', salome_pluginsmanager.AddFunction('ReMesh with Yams', 'Run Yams', YamsLct) + +salome_pluginsmanager.AddFunction('ReMesh with MGCleaner', + 'Run MGCleaner', + MGCleanerLct) +