]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
SALOME PAL V1_4_1
authorsmh <smh@opencascade.com>
Fri, 2 Apr 2004 13:33:18 +0000 (13:33 +0000)
committersmh <smh@opencascade.com>
Fri, 2 Apr 2004 13:33:18 +0000 (13:33 +0000)
158 files changed:
INSTALL
Makefile.in
adm_local/unix/config_files/check_Geom.m4
adm_local/unix/config_files/check_Med.m4
adm_local/unix/make_commence.in
bin/VERSION
configure.in.base
doc/Makefile.in
idl/Makefile.in
idl/SMESH_BasicHypothesis.idl
idl/SMESH_Gen.idl
idl/SMESH_Hypothesis.idl
idl/SMESH_Mesh.idl
resources/SMESH_en.xml
resources/SMESH_fr.xml
src/Driver/Makefile.in
src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx
src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.cxx
src/DriverDAT/Makefile.in
src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx
src/DriverMED/DriverMED_R_SMESHDS_Mesh.h
src/DriverMED/DriverMED_W_SMDS_Mesh.cxx
src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx
src/DriverMED/DriverMED_W_SMESHDS_Mesh.h
src/DriverMED/Makefile.in
src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx
src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.cxx
src/DriverUNV/Makefile.in
src/Makefile.in
src/OBJECT/Makefile.in
src/OBJECT/SMESH_Actor.cxx
src/OBJECT/SMESH_Actor.h
src/SMDS/Makefile.in
src/SMDS/SMDS_EdgePosition.hxx
src/SMDS/SMDS_FaceOfEdges.cxx
src/SMDS/SMDS_FaceOfEdges.hxx
src/SMDS/SMDS_FaceOfNodes.cxx
src/SMDS/SMDS_FaceOfNodes.hxx
src/SMDS/SMDS_HexahedronOfNodes.cxx
src/SMDS/SMDS_HexahedronOfNodes.hxx
src/SMDS/SMDS_Iterator.hxx
src/SMDS/SMDS_IteratorOfElements.cxx
src/SMDS/SMDS_IteratorOfElements.hxx
src/SMDS/SMDS_Mesh.cxx
src/SMDS/SMDS_Mesh.hxx
src/SMDS/SMDS_MeshEdge.cxx
src/SMDS/SMDS_MeshEdge.hxx
src/SMDS/SMDS_MeshElement.cxx
src/SMDS/SMDS_MeshElement.hxx
src/SMDS/SMDS_MeshElementIDFactory.cxx
src/SMDS/SMDS_MeshElementIDFactory.hxx
src/SMDS/SMDS_MeshGroup.cxx
src/SMDS/SMDS_MeshGroup.hxx
src/SMDS/SMDS_MeshIDFactory.cxx
src/SMDS/SMDS_MeshNode.cxx
src/SMDS/SMDS_MeshNode.hxx
src/SMDS/SMDS_MeshObject.hxx
src/SMDS/SMDS_Position.hxx
src/SMDS/SMDS_SpacePosition.cxx
src/SMDS/SMDS_SpacePosition.hxx
src/SMDS/SMDS_Tria3OfNodes.cxx
src/SMDS/SMDS_Tria3OfNodes.hxx
src/SMDS/SMDS_VertexPosition.hxx
src/SMDS/SMDS_VolumeOfFaces.cxx
src/SMDS/SMDS_VolumeOfFaces.hxx
src/SMDS/SMDS_VolumeOfNodes.cxx
src/SMDS/SMDS_VolumeOfNodes.hxx
src/SMESH/Makefile.in
src/SMESH/SMESH_1D_Algo.cxx
src/SMESH/SMESH_1D_Algo.hxx
src/SMESH/SMESH_2D_Algo.cxx
src/SMESH/SMESH_2D_Algo.hxx
src/SMESH/SMESH_3D_Algo.cxx
src/SMESH/SMESH_3D_Algo.hxx
src/SMESH/SMESH_Algo.cxx
src/SMESH/SMESH_Algo.hxx
src/SMESH/SMESH_Gen.cxx
src/SMESH/SMESH_Gen.hxx
src/SMESH/SMESH_Hypothesis.cxx
src/SMESH/SMESH_Hypothesis.hxx
src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx
src/SMESH/SMESH_subMesh.cxx
src/SMESH/SMESH_subMesh.hxx
src/SMESHDS/Makefile.in
src/SMESHDS/SMESHDS_Mesh.cxx
src/SMESHDS/SMESHDS_Mesh.hxx
src/SMESHDS/SMESHDS_SubMesh.cxx
src/SMESHDS/SMESHDS_SubMesh.hxx
src/SMESHFiltersSelection/SMESH_Type.h
src/SMESHFiltersSelection/SMESH_TypeFilter.cxx
src/SMESHGUI/Makefile.in
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI.h
src/SMESHGUI/SMESHGUI_AddEdgeDlg.cxx
src/SMESHGUI/SMESHGUI_AddFaceDlg.cxx
src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx
src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h
src/SMESHGUI/SMESHGUI_AddVolumeDlg.cxx
src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.cxx
src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx
src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h
src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx
src/SMESHGUI/SMESHGUI_InitMeshDlg.h
src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx
src/SMESHGUI/SMESHGUI_MeshInfosDlg.h
src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx
src/SMESHGUI/SMESHGUI_NodesDlg.cxx
src/SMESHGUI/SMESHGUI_OrientationElementsDlg.cxx
src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx
src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h
src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx
src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx
src/SMESHGUI/SMESHGUI_StudyAPI.cxx
src/SMESHGUI/SMESHGUI_StudyAPI.h
src/SMESHGUI/SMESHGUI_Swig.cxx
src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx
src/SMESHGUI/SMESHGUI_TransparencyDlg.h
src/SMESHGUI/SMESH_icons.po
src/SMESHGUI/SMESH_msg_en.po
src/SMESH_I/Makefile.in
src/SMESH_I/SMESH_1D_Algo_i.cxx
src/SMESH_I/SMESH_1D_Algo_i.hxx
src/SMESH_I/SMESH_2D_Algo_i.cxx
src/SMESH_I/SMESH_2D_Algo_i.hxx
src/SMESH_I/SMESH_3D_Algo_i.cxx
src/SMESH_I/SMESH_3D_Algo_i.hxx
src/SMESH_I/SMESH_Algo_i.cxx
src/SMESH_I/SMESH_Algo_i.hxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_I/SMESH_Hypothesis_i.cxx
src/SMESH_I/SMESH_Hypothesis_i.hxx
src/SMESH_I/SMESH_MEDMesh_i.cxx
src/SMESH_I/SMESH_MEDSupport_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx
src/SMESH_I/SMESH_subMesh_i.cxx
src/SMESH_I/SMESH_subMesh_i.hxx
src/SMESH_I/SMESH_test.py
src/SMESH_I/smeshpy.py
src/SMESH_SWIG/Makefile.in
src/SMESH_SWIG/SMESH_Partition1_tetra.py
src/SMESH_SWIG/SMESH_box2_tetra.py
src/SMESH_SWIG/SMESH_box3_tetra.py
src/SMESH_SWIG/SMESH_box_tetra.py
src/SMESH_SWIG/SMESH_fixation.py
src/SMESH_SWIG/SMESH_fixation_hexa.py
src/SMESH_SWIG/SMESH_fixation_tetra.py
src/SMESH_SWIG/SMESH_flight_skin.py
src/SMESH_SWIG/SMESH_mechanic.py
src/SMESH_SWIG/SMESH_mechanic_tetra.py
src/SMESH_SWIG/SMESH_test0.py
src/SMESH_SWIG/SMESH_test1.py
src/SMESH_SWIG/SMESH_test2.py
src/SMESH_SWIG/SMESH_test3.py
src/SMESH_SWIG/batchmode_smesh.py

diff --git a/INSTALL b/INSTALL
index c090b5ab4af169321b7d1afc122bef8c3915691c..b6c40125f9dd9539e39d3bcb53ab9a570ae30f9d 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,6 +1,6 @@
-This is SMESH V1_4_0
+This is SMESH V1_4_1
 
 Compatible with :
-       GEOM    V1_4_0
-       KERNEL  V1_4_0
-       MED     V1_4_0
+       GEOM    V1_4_1
+       KERNEL  V1_4_1
+       MED     V1_4_1
index ac708eff5f24c4b6c11264a2108d5ef85169d219..a79be56d3204f8d313e30768b281c975f24acfe1 100644 (file)
@@ -14,7 +14,7 @@ VPATH=.:@srcdir@:@top_srcdir@/bin:@top_srcdir@/resources:./bin:@top_srcdir@/idl
 
 @COMMENCE@
 
-SUBDIRS = idl src
+SUBDIRS = idl src doc
 
 RESOURCES_FILES = \
 delete.png  \
@@ -40,6 +40,8 @@ mesh_hypo_volume.png \
 mesh_info.png \
 mesh_init.png \
 mesh_length.png \
+mesh_free_edges.png \
+mesh_multi_edges.png \
 mesh_line_n.png \
 mesh_line.png \
 mesh_move_node.png \
@@ -71,6 +73,7 @@ mesh_tree_hypo.png \
 mesh_tree_hypo_segment.png \
 mesh_tree_hypo_volume.png \
 mesh_tree_mesh.png \
+mesh_tree_importedmesh.png \
 mesh_tree_mesh_warn.png \
 mesh_triangle_n.png \
 mesh_triangle.png \
@@ -78,10 +81,16 @@ mesh_update.png \
 mesh_vertex_n.png \
 mesh_vertex.png \
 mesh_wireframe.png \
+mesh_points.png \
 mesh_wrap.png \
+mesh_tree_group.png \
+mesh_edit_group.png \
+mesh_make_group.png \
 ModuleMesh.png \
 select1.png \
 SMESH_en.xml \
+SMESH.config \
+StdMeshers.xml \
 SMESHCatalog.xml \
 flight_solid.brep
 
@@ -104,10 +113,10 @@ include/salome/SALOMEconfig.h: salome_adm/unix/SALOMEconfig.ref
 # test if SALOMEconfig.h has changed (contents)
 salome_adm/unix/SALOMEconfig.ref: salome_adm/unix/SALOMEconfig.h
        @if ! [ -a $@ ]; then \
-         cp -p $< $@;        \
+         cp -p -f $< $@;        \
        fi;                   \
        if ! cmp $< $@; then  \
-         cp -p $< $@;        \
+         cp -p -f $< $@;        \
        fi;                   \
 
 include/salome/sstream: salome_adm/unix/sstream
@@ -131,7 +140,7 @@ install-include: $(include_list)
        $(INSTALL) -d  $(includedir)
        @for f in X $(include_list); do                         \
           if test $$f != X; then                               \
-            ($(INSTALL_DATA) $$f $(includedir)/. || exit 1);   \
+            ($(INSTALL_DATA) -p $$f $(includedir)/. || exit 1);        \
           fi;                                                  \
        done
 
index 947c44a12d7f44383cc93e52e3c65a05db3c41fa..803ca754b425e7fc7e2d5dec5377312a14191bf2 100644 (file)
@@ -47,7 +47,7 @@ if test -f ${GEOM_DIR}/bin/salome/libGEOM_Swig.py ; then
 else
    AC_MSG_WARN("Cannot find compiled Geom module distribution")
 fi
-  
+
 AC_MSG_RESULT(for Geom: $Geom_ok)
  
 ])dnl
index 839a3d7beb7e748e8eca8474df5c4f539b0e7342..49272705302c59cc4c61a4feee2de1ccb57092d9 100644 (file)
@@ -45,7 +45,7 @@ if test -f ${MED_DIR}/bin/salome/libMEDMEM_Swig.py ; then
    AC_SUBST(MED_ROOT_DIR)
 
 else
-   AC_MSG_WARN("Cannot find compiled Med module distribution")
+   AC_MSG_WARN("Cannot find Med module sources")
 fi
   
 AC_MSG_RESULT(for Med: $Med_ok)
index a42b18798bd1fb758c9e8f7f9f58348557943334..ad1a9a52f2bbaa81caf17c81941ede0974e50805 100644 (file)
@@ -34,6 +34,10 @@ CXX = @CXX@
 CXXFLAGS = @CXXFLAGS@ 
 CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@
 
+# BOOST Library
+
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+
 # JAVA
 
 JAVA_INCLUDES = @JAVA_INCLUDES@
@@ -127,7 +131,8 @@ OMNIORB_CXXFLAGS    = @OMNIORB_CXXFLAGS@
 
 OMNIORB_IDL         = @OMNIORB_IDL@
 OMNIORB_IDLCXXFLAGS = @OMNIORB_IDLCXXFLAGS@
-OMNIORB_IDLPYFLAGS  = @OMNIORB_IDLPYFLAGS@ -I$(top_srcdir)/idl -I$(top_builddir)/idl -I$(KERNEL_ROOT_DIR)/idl/salome -I$(GEOM_ROOT_DIR)/idl/salome -I$(MED_ROOT_DIR)/idl/salome
+OMNIORB_IDLPYFLAGS  = @OMNIORB_IDLPYFLAGS@ -I$(top_srcdir)/idl -I$(top_builddir)/idl/salome \
+       -I$(KERNEL_ROOT_DIR)/idl/salome -I$(GEOM_ROOT_DIR)/idl/salome -I$(MED_ROOT_DIR)/idl/salome
 
 OMNIORB_IDL_CLN_H   = @OMNIORB_IDL_CLN_H@
 OMNIORB_IDL_CLN_CXX = @OMNIORB_IDL_CLN_CXX@
@@ -144,7 +149,8 @@ CORBA_INCLUDES    = @CORBA_INCLUDES@
 CORBA_LIBS        = @CORBA_LIBS@
 CORBA_CXXFLAGS    = @CORBA_CXXFLAGS@
 
-IDLCXXFLAGS = -bcxx @IDLCXXFLAGS@ -I$(top_srcdir)/idl -I$(top_builddir)/idl -I$(KERNEL_ROOT_DIR)/idl/salome -I$(GEOM_ROOT_DIR)/idl/salome -I$(MED_ROOT_DIR)/idl/salome
+IDLCXXFLAGS = -bcxx @IDLCXXFLAGS@ -I$(top_srcdir)/idl -I$(top_builddir)/idl/salome \
+       -I$(KERNEL_ROOT_DIR)/idl/salome -I$(GEOM_ROOT_DIR)/idl/salome -I$(MED_ROOT_DIR)/idl/salome
 IDLPYFLAGS  = @IDLPYFLAGS@
 
 IDL = @IDL@
@@ -195,13 +201,13 @@ datadir=@datadir@/salome
 idldir=$(prefix)/idl/salome
 sharedpydir=@libdir@/python$(PYTHON_VERSION)/site-packages/salome/shared_modules
 
-docdir=$(datadir)/doc
+docdir=${prefix}/doc/salome
 
 #
 # begin of package rules
 #
 
-.PHONY: all lib bin inc resources tests install uninstall dep depend depend_idl cleandep mostlyclean clean distclean
+.PHONY: all lib bin inc resources docs tests install uninstall dep depend depend_idl cleandep mostlyclean clean distclean
 
 .SUFFIXES: .cxx .cc .c .f .o .lo .idl .py .i .ui .po .qm
 
@@ -243,11 +249,7 @@ ac_cxx_namespaces.m4              check_omniorb.m4   pyembed.m4            \
 ac_cxx_partial_specialization.m4  check_opengl.m4    python.m4         \
 ac_cxx_typename.m4                check_pthreads.m4  check_cas.m4      \
 ac_cc_warnings.m4                 check_qt.m4        check_med2.m4      \
-check_swig.m4 
-
-#ifeq (@WITHNETGEN@,yes)
-#  ACLOCAL_SRC += check_Netgen.m4
-#endif
+check_swig.m4                     check_boost.m4 
 
 $(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%)
        cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files
index 37cafc3cc63dab1a8963b4c9dcfcb9ffd00fab93..6d0bea42a5f5ea7fafd727c0f05a46c002ac6e43 100755 (executable)
@@ -1,2 +1,2 @@
-THIS IS SALOME - SMESH VERSION: 1.4.0
+THIS IS SALOME - SMESH VERSION: 1.4.1
 
index f2e7919b0a04d144fbd055840747a56cca86501f..5573498cadef60fe3aa7c45a7571288f6aba93e6 100644 (file)
@@ -113,6 +113,14 @@ dnl
 
 AC_CXX_HAVE_SSTREAM
 
+echo
+echo ---------------------------------------------
+echo BOOST Library
+echo ---------------------------------------------
+echo
+
+CHECK_BOOST
+
 dnl
 dnl ---------------------------------------------
 dnl testing MPICH
@@ -273,14 +281,6 @@ echo
 
 CHECK_MED
 
-echo
-echo ---------------------------------------------
-echo Testing Netgen
-echo ---------------------------------------------
-echo
-
-CHECK_NETGEN
-
 echo
 echo ---------------------------------------------
 echo Summary
@@ -288,7 +288,7 @@ echo ---------------------------------------------
 echo
 
 echo Configure
-variables="cc_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok Med_ok Netgen_ok"
+variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok Med_ok"
 
 for var in $variables
 do
@@ -318,7 +318,7 @@ else
 fi
 
 # make other build directories
-for rep in salome_adm adm_local doc bin/salome include/salome lib/salome share/salome/resources share/salome/doc idl
+for rep in salome_adm adm_local doc bin/salome include/salome lib/salome share/salome/resources idl
 do
 #   if test ! -d $rep ; then
 #      eval mkdir $rep
@@ -351,14 +351,15 @@ dnl copy shells and utilities contained in the bin directory
 dnl excluding .in files (treated in AC-OUTPUT below) and CVS 
 dnl directory
 
-cd bin
+mkdir -p bin/salome
+cd bin/salome
 for i in $ROOT_SRCDIR/bin/*
 do
   local_bin=`echo $i | sed -e "s,$ROOT_SRCDIR,.,"`
   case "$local_bin" in
         *.in | *~)                    ;;
-        ./bin/CVS)                    ;;
-        *) ln -fs $i; echo $local_bin ;;
+        ./bin/CVS | ./bin/salome)                    ;;
+        *) /usr/bin/install -C $i .; echo $local_bin ;;
   esac
 done
 cd $ROOT_BUILDDIR
index 01901597158e9cc36fca315a781abd5d150fc032..7295ede75128e9e51b474f63ed9f8d7a128bb3df 100644 (file)
@@ -11,9 +11,11 @@ top_builddir=..
 srcdir=@srcdir@
 VPATH=.:@srcdir@
 
-SUBDIRS=html 
+SUBDIRS= salome
 
-doc:
+@COMMENCE@
+
+docs:
        @@SETX@; for d in $(SUBDIRS); do        \
           (cd $$d && $(MAKE) $@) || exit 1;    \
        done
@@ -31,3 +33,8 @@ install:
        @@SETX@; for d in $(SUBDIRS); do        \
           (cd $$d && $(MAKE) $@) || exit 1;    \
        done
+
+uninstall:
+       @@SETX@; for d in $(SUBDIRS); do        \
+          (cd $$d && $(MAKE) $@) || exit 1;    \
+       done
index c53a0789573de711f647749a277a124f4d45a841..40a4c84f286e0e935b10f0469e88dd58879d30ce 100644 (file)
@@ -6,7 +6,7 @@
 top_srcdir=@top_srcdir@
 top_builddir=..
 srcdir=@srcdir@
-VPATH=.:$(srcdir):${KERNEL_ROOT_DIR}/idl/salome:${GEOM_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
+VPATH=.:${KERNEL_ROOT_DIR}/idl/salome:${GEOM_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
 
 @COMMENCE@
 
@@ -14,16 +14,21 @@ IDL_FILES = \
   SMESH_Gen.idl \
   SMESH_Mesh.idl \
   SMESH_Hypothesis.idl \
-  SMESH_BasicHypothesis.idl
+  SMESH_BasicHypothesis.idl \
+  SMESH_Filter.idl \
+  SMESH_Group.idl
 
 PY_CLIENT_IDL = $(IDL_FILES)
 
 # we copy all idl file in $(top_builddir)/idl
-inc: $(IDL_FILES:%=$(top_builddir)/idl/%)
+inc: $(top_builddir)/idl/salome $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
 
-$(IDL_FILES:%=$(top_builddir)/idl/%):$(top_builddir)/idl/%:%
+$(top_builddir)/idl/salome:
+       mkdir $@
+
+$(IDL_FILES:%=$(top_builddir)/idl/salome/%):$(IDL_FILES:%=$(top_srcdir)/idl/%)
 #      $(CP) $< $@
-       cp -f $< $@
+       cp -f $^ $(top_builddir)/idl/salome
 
 
 lib: pyidl
@@ -35,7 +40,7 @@ pyidl: $(PYTHON_BUILD_SITE) $(IDL_FILES:%.idl=$(PYTHON_BUILD_SITE)/%_idl.py)
 $(PYTHON_BUILD_SITE):
        $(INSTALL) -d  $@
 
-$(PYTHON_BUILD_SITE)/%_idl.py: %.idl
+$(PYTHON_BUILD_SITE)/%_idl.py: $(top_builddir)/idl/salome/%.idl
        $(OMNIORB_IDL) $(OMNIORB_IDLPYFLAGS) -C$(PYTHON_BUILD_SITE) $<
 
 
@@ -43,12 +48,12 @@ $(PYTHON_BUILD_SITE)/%_idl.py: %.idl
 install: install-pyidl install-idl
 
 # create directory $(idldir) and copy idl files into it
-install-idl: $(IDL_FILES)
+install-idl: $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
        $(INSTALL) -d  $(idldir)
        $(INSTALL_DATA) $^ $(idldir)
 
 
-install-pyidl: $(IDL_FILES)
+install-pyidl: $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
        $(INSTALL) -d  $(PYTHON_SITE_INSTALL)
        @for file in $^ dummy; do \
          if [ $$file != "dummy" ]; then \
@@ -63,6 +68,6 @@ cleandep:
 
 distclean:
        -$(RM) *.py
-       -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/%)
+       -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
        -$(RM) Makefile
 
index f6a37655c57a34bcea18493134e2aeecc3a63e5f..9987c2c4439c86e01fdec15f7444ca030648341c 100644 (file)
 #include "SMESH_Hypothesis.idl"
 
 
-module SMESH
+/*!
+ * StdMeshers: interfaces to standard hypotheses and algorithms
+ */
+module StdMeshers
 {
-  interface SMESH_LocalLength : SMESH_Hypothesis
+  /*!
+   * StdMeshers_LocalLength: interface of "Average length" hypothesis
+   */
+  interface StdMeshers_LocalLength : SMESH::SMESH_Hypothesis
   {
+    /*!
+     * Sets <length> parameter value
+     */
     void SetLength(in double length) 
       raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Returns <length> parameter value
+     */
     double GetLength();
   };
 
-  interface SMESH_NumberOfSegments : SMESH_Hypothesis
+  /*!
+   * StdMeshers_NumberOfSegments: interface of "Nb. Segments" hypothesis
+   */
+  interface StdMeshers_NumberOfSegments : SMESH::SMESH_Hypothesis
   {
+    /*!
+     * Sets <number of segments> parameter value
+     */
     void SetNumberOfSegments(in long segmentsNumber) 
       raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Returns <number of segments> parameter value
+     */
     long GetNumberOfSegments();
+
+    /*!
+     * Sets <scale factor> parameter value
+     */
     void SetScaleFactor(in double scaleFactor)
       raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Returns <scale factor> parameter value
+     */
     double GetScaleFactor();
   };
 
-  interface SMESH_MaxElementArea : SMESH_Hypothesis
+  /*!
+   * StdMeshers_MaxElementArea: interface of "Max. Triangle Area" hypothesis
+   */
+  interface StdMeshers_MaxElementArea : SMESH::SMESH_Hypothesis
   {
+    /*!
+     * Sets <maximum element area> parameter value
+     */
     void SetMaxElementArea(in double area) 
       raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Returns <maximum element area> parameter value
+     */
     double GetMaxElementArea();
   };
 
-  interface SMESH_LengthFromEdges : SMESH_Hypothesis
+  /*!
+   * StdMeshers_LengthFromEdges: interface of "Length From Edges (2D Hyp. for Triangulator)" hypothesis
+   */
+  interface StdMeshers_LengthFromEdges : SMESH::SMESH_Hypothesis
   {
+    /*!
+     * Sets <mode> parameter value
+     */
     void SetMode(in long mode) 
       raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Returns <mode> parameter value
+     */
     long GetMode();
   };
 
-  interface SMESH_MaxElementVolume : SMESH_Hypothesis
+  /*!
+   * StdMeshers_MaxElementVolume: interface of "Max. Hexahedron or Tetrahedron Volume" hypothesis
+   */
+  interface StdMeshers_MaxElementVolume : SMESH::SMESH_Hypothesis
   {
+    /*!
+     * Sets <maximum element volume> parameter value
+     */
     void SetMaxElementVolume(in double volume) 
       raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Returns <maximum element volume> parameter value
+     */
     double GetMaxElementVolume();
   };
 
-  interface SMESH_Regular_1D : SMESH_1D_Algo
+  /*!
+   * StdMeshers_NotConformAllowed: interface of "Not Conform Mesh Allowed" hypothesis.
+   * Presence of this hypothesis permits to algorithm generation of not conform mesh.
+   */
+  interface StdMeshers_NotConformAllowed : SMESH::SMESH_Hypothesis
   {
   };
 
-  interface SMESH_MEFISTO_2D : SMESH_2D_Algo
+  /*!
+   * StdMeshers_Regular_1D: interface of "Wire discretisation" algorithm
+   */
+  interface StdMeshers_Regular_1D : SMESH::SMESH_1D_Algo
   {
   };
 
-  interface SMESH_Quadrangle_2D : SMESH_2D_Algo
+  /*!
+   * StdMeshers_MEFISTO_2D: interface of "Triangle (Mefisto)" algorithm
+   */
+  interface StdMeshers_MEFISTO_2D : SMESH::SMESH_2D_Algo
   {
   };
 
-  interface SMESH_Hexa_3D : SMESH_3D_Algo
+  /*!
+   * StdMeshers_Quadrangle_2D: interface of "Quadrangle (Mapping)" algorithm
+   */
+  interface StdMeshers_Quadrangle_2D : SMESH::SMESH_2D_Algo
   {
   };
 
-#ifdef HAVE_NETGEN
-  interface SMESH_NETGEN_3D : SMESH_3D_Algo
+  /*!
+   * StdMeshers_Hexa_3D: interface of "Hexahedron (i,j,k)" algorithm
+   */
+  interface StdMeshers_Hexa_3D : SMESH::SMESH_3D_Algo
   {
   };
-#endif
 
 };
 
index c30750bf071b43be534679ac9e32ce4605abe203..390813d48a0292d1ec3eb4ef09a7fbcfd6f81ec5 100644 (file)
 module SMESH
 {
   typedef sequence<GEOM::GEOM_Shape> shape_array;
+  typedef sequence<SMESH_Mesh> mesh_array;
+
+  interface FilterManager;
 
   interface SMESH_Gen : Engines::Component, SALOMEDS::Driver
   {
+
+    FilterManager CreateFilterManager();
+
+    /*!
+      Set the current study
+     */
+    void SetCurrentStudy( in SALOMEDS::Study theStudy );
+
     /*!
-     * Create an hypothesis that can be shared by differents parts of the mesh.
+      Get the current study
+     */
+    SALOMEDS::Study GetCurrentStudy();
+
+    /*!
+     * Create a hypothesis that can be shared by differents parts of the mesh.
      * An hypothesis is either:
      * - a method used to generate or modify a part of the mesh (algorithm).
      * - a parameter or a law used by an algorithm.
      * Algorithms are 1D, 2D or 3D.
      */
-    SMESH_Hypothesis CreateHypothesis( in string anHyp,
-                                      in long studyId)
-      raises (SALOME::SALOME_Exception);
+    SMESH_Hypothesis CreateHypothesis( in string theHypName,
+                                      in string theLibName )
+      raises ( SALOME::SALOME_Exception );
 
     /*!
      * Create a Mesh object, given a geometry shape.
@@ -60,49 +76,51 @@ module SMESH
      * of TopoDS_Shapes and bind CORBA references of shape & subshapes
      * with TopoDS_Shapes
      */
-     SMESH_Mesh Init(in GEOM::GEOM_Gen geomEngine,
-                    in long studyId,
-                    in GEOM::GEOM_Shape aShape)
-       raises (SALOME::SALOME_Exception);
+    SMESH_Mesh CreateMesh( in GEOM::GEOM_Shape theShape )
+      raises ( SALOME::SALOME_Exception );
+    
+    /*!
+     * Create Mesh object(s) importing data from given MED file
+     */
+     mesh_array CreateMeshesFromMED( in string theFileName,
+                                    out SMESH::DriverMED_ReadStatus theStatus )
+       raises ( SALOME::SALOME_Exception );
 
     /*!
      * Create a Mesh object, without a geometry shape reference
      */
-//      SMESH_Mesh NewEmpty(in GEOM::GEOM_Gen geomEngine,
-//                      in long studyId)
-//        raises (SALOME::SALOME_Exception);
+//      SMESH_Mesh NewEmpty()
+//        raises ( SALOME::SALOME_Exception );
 
     /*!
      * Mesh a subShape. 
      * First, verify list of hypothesis associated with the subShape,
      * return NOK if hypothesis are not sufficient
      */
-    boolean Compute(in SMESH_Mesh aMesh, in GEOM::GEOM_Shape aSubShape)
-      raises (SALOME::SALOME_Exception);
+    boolean Compute( in SMESH_Mesh       theMesh, 
+                    in GEOM::GEOM_Shape theSubShape )
+      raises ( SALOME::SALOME_Exception );
 
     /*!
      * 
      */
 
-    boolean IsReadyToCompute(in SMESH_Mesh aMesh, in GEOM::GEOM_Shape aSubShape)
-      raises (SALOME::SALOME_Exception);
+    boolean IsReadyToCompute( in SMESH_Mesh       theMesh, 
+                             in GEOM::GEOM_Shape theSubShape )
+      raises ( SALOME::SALOME_Exception );
 
     /*!
      * 
      */
-    long_array GetSubShapesId(in GEOM::GEOM_Gen geomEngine,
-                            in long studyId,
-                            in GEOM::GEOM_Shape mainShape,
-                            in shape_array listOfSubShape)
-       raises (SALOME::SALOME_Exception);
+    long_array GetSubShapesId( in GEOM::GEOM_Shape theMainShape,
+                              in shape_array      theListOfSubShape )
+       raises ( SALOME::SALOME_Exception );
     
     /*!
      * 
      */
-    //    long_array GetSubMeshesState(in GEOM::GEOM_Gen geomEngine,
-    //                          in long studyId,
-    //                          in shape_array listOfSubShape)
-    //  raises (SALOME::SALOME_Exception);
+    //    long_array GetSubMeshesState( in shape_array theListOfSubShape )
+    //  raises ( SALOME::SALOME_Exception );
     
 
   };
index e3e82b80c3dd610030801bca0fa19c8368ad4bc9..6389d724f811644b8a132379295e39f9e92dcea9 100644 (file)
 #define _SMESH_HYPOTHESIS_IDL_
 
 #include "SALOME_Exception.idl"
+#include "SALOME_GenericObj.idl"
 
 module SMESH
 {
-  interface SMESH_Hypothesis;
-
-  typedef sequence<SMESH_Hypothesis> ListOfHypothesis;
-  typedef sequence<string> ListOfHypothesisName;
-
-  interface SMESH_Hypothesis
+  interface SMESH_Hypothesis : SALOME::GenericObj
   {
     /*!
      * Get the Hypothesis typeName 
      */
     string GetName();
 
+    /*!
+     * Get the Hypothesis plugin library Name 
+     */
+    string GetLibName();
+
     /*!
      * Get the internal Id 
      */
     long GetId();
- };
+  };
+
+  typedef sequence<string> ListOfHypothesisName;
 
   interface SMESH_Algo : SMESH_Hypothesis
   {
index a051ada9db0fb40b4af08f40f0a37708e08041a2..b81acf6a06e1dfc2d6bb751b97480affa4547a75 100644 (file)
 #define _SMESH_MESH_IDL_
 
 #include "SALOME_Exception.idl"
-#include "SMESH_Hypothesis.idl"
+//#include "SMESH_Hypothesis.idl"
+
+#include "SALOME_GenericObj.idl"
+//#include "GEOM_Shape.idl"
+//#include "MED.idl"
+
+module GEOM
+{
+  interface GEOM_Shape;
+};
+
+
+module SALOME_MED
+{
+  interface MESH;
+  interface FAMILY;
+};
 
-#include "GEOM_Shape.idl"
-#include "MED.idl"
 
 module SMESH
 {
+  interface SMESH_Hypothesis;
+  typedef sequence<SMESH_Hypothesis> ListOfHypothesis;
+
   typedef sequence<double> double_array ;
   typedef sequence<long> long_array ;
   typedef sequence<string> string_array ;
@@ -59,12 +76,56 @@ module SMESH
     double_array coords;
     long_array indexes;
   };
+
+  
+  /*!
+   * Enumeration for element type, like in SMDS
+   */
+  enum ElementType
+  {
+    ALL,
+    NODE,
+    EDGE,
+    FACE,
+    VOLUME
+  };
+  
+  /*!
+   * Enumeration for hypothesis status (used by AddHypothesis() and RemoveHypothesis() methods) 
+   */  
+  enum Hypothesis_Status // in the order of severity
+  {
+    HYP_OK,
+    HYP_MISSING,      // algo misses a hypothesis
+    HYP_CONCURENT,    // several applicable hypotheses
+    HYP_BAD_PARAMETER,// hypothesis has a bad parameter value
+    HYP_UNKNOWN_FATAL,//  --- all statuses below should be considered as fatal
+                      //      for Add/RemoveHypothesis operations
+    HYP_INCOMPATIBLE, // hypothesis does not fit algo
+    HYP_NOTCONFORM,   // not conform mesh is produced appling a hypothesis
+    HYP_ALREADY_EXIST,// such hypothesis already exist
+    HYP_BAD_DIM       // bad dimension
+  }; 
   
+  /*!
+   * Enumeration for DriverMED read status (used by ImportMEDFile() method)
+   */  
+  enum DriverMED_ReadStatus // in the order of severity
+  {
+    DRS_OK,
+    DRS_EMPTY,          // a MED 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
+    DRS_FAIL            // general failure (exception etc.)
+  }; 
+
   typedef sequence<log_block> log_array;
 
+  interface SMESH_Group;
   interface SMESH_subMesh;
   interface SMESH_MeshEditor;
-  interface SMESH_Mesh
+  interface SMESH_Mesh : SALOME::GenericObj
   {
     /*!
      * Associate a Shape to a Mesh created with NewEmpty
@@ -79,7 +140,7 @@ module SMESH
      * SubMesh will be used instead of SubShape in a next idl version to 
      * adress a specific subMesh...
      */
-    SMESH_subMesh GetElementsOnShape(in GEOM::GEOM_Shape aSubShape)
+    SMESH_subMesh GetSubMesh(in GEOM::GEOM_Shape aSubShape, in string name)
       raises (SALOME::SALOME_Exception);
 
     /*!
@@ -88,6 +149,25 @@ module SMESH
 //     SMESH_subMesh NewEmpty()
 //       raises (SALOME::SALOME_Exception);
 
+    /*!
+     * Remove a submesh
+     */
+    void RemoveSubMesh(in SMESH_subMesh aSubMesh)
+      raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Create a group
+     */
+    SMESH_Group CreateGroup( in ElementType elem_type,
+                            in string name )
+      raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Remove a group
+     */
+    void RemoveGroup(in SMESH_Group aGroup)
+      raises (SALOME::SALOME_Exception);
+
     /*!
      * Add hypothesis to the mesh, under a particular subShape
      * (or the main shape itself)
@@ -105,7 +185,8 @@ module SMESH
      *   (or one previous hypothesis on the subShape)
      * raises exception if hypothesis has not been created
      */
-    boolean AddHypothesis(in GEOM::GEOM_Shape aSubShape, in SMESH_Hypothesis anHyp)
+    Hypothesis_Status AddHypothesis(in GEOM::GEOM_Shape aSubShape,
+                                   in SMESH_Hypothesis anHyp)
       raises (SALOME::SALOME_Exception);
 //     boolean AddHypothesis(in SMESH_subMesh aSubMesh, in SMESH_Hypothesis anHyp)
 //       raises (SALOME::SALOME_Exception);
@@ -114,8 +195,8 @@ module SMESH
     /*!
      * Remove an hypothesis previouly added with AddHypothesis.
      */
-    boolean RemoveHypothesis(in GEOM::GEOM_Shape aSubShape,
-                            in SMESH_Hypothesis anHyp)
+    Hypothesis_Status RemoveHypothesis(in GEOM::GEOM_Shape aSubShape,
+                                      in SMESH_Hypothesis anHyp)
       raises (SALOME::SALOME_Exception);
 //     boolean RemoveHypothesis(in SMESH_subMesh aSubMesh,
 //                          in SMESH_Hypothesis anHyp)
@@ -165,7 +246,7 @@ module SMESH
      */
     void ExportDAT( in string file )
       raises (SALOME::SALOME_Exception);
-    void ExportMED( in string file )
+    void ExportMED( in string file, in boolean auto_groups )
       raises (SALOME::SALOME_Exception);
     void ExportUNV( in string file )
       raises (SALOME::SALOME_Exception);
@@ -200,11 +281,19 @@ module SMESH
     long NbHexas()
       raises (SALOME::SALOME_Exception);
 
+    long NbPyramids()
+      raises (SALOME::SALOME_Exception);
+
+    long NbPrisms()
+      raises (SALOME::SALOME_Exception);
+
     long NbSubMesh()
       raises (SALOME::SALOME_Exception);
+
+    string Dump();
   };
 
-  interface SMESH_subMesh
+  interface SMESH_subMesh : SALOME::GenericObj
   {
     /*!
      * 
@@ -224,6 +313,12 @@ module SMESH
     long_array GetElementsId()
       raises (SALOME::SALOME_Exception);
 
+    /*!
+     * 
+     */
+    long_array GetElementsByType( in ElementType theType )
+      raises (SALOME::SALOME_Exception);
+
     /*!
      * 
      */
index e1bb694bfce924db3f11d6357f0d902a98fe535e..449962659d2c99c627e30fb5376434ea9338d96c 100644 (file)
@@ -17,7 +17,7 @@
      <submenu label-id="Import" item-id="11" pos-id="8">
        <popup-item item-id="111" pos-id="" label-id="DAT file" icon-id="" tooltip-id="" accel-id="Ctrl+B" toggle-id="" execute-action=""/>
                <popup-item item-id="112" pos-id="" label-id="UNV File" icon-id="" tooltip-id="" accel-id="Ctrl+I" toggle-id="" execute-action=""/> 
-               <popup-item item-id="113" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id=""       toggle-id="" execute-action=""/> 
+               <popup-item item-id="113" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="Ctrl+M" toggle-id="" execute-action=""/> 
       </submenu>
       <endsubmenu />
       <submenu label-id="Export" item-id="12" pos-id="9">
 
 <!-- ************************** Hypothesis  (menubar)  ************************************ -->
 <menu-item label-id="Hypotheses" item-id="50" pos-id="3">
-       <popup-item item-id="5030" pos-id="" label-id="Average length" icon-id="mesh_hypo_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5031" pos-id="" label-id="Nb. Segments" icon-id="mesh_hypo_segment.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5032" pos-id="" label-id="Max. Triangle Area" icon-id="mesh_hypo_area.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5033" pos-id="" label-id="Max. Hexahedron or Tetrahedron Volume" icon-id="mesh_hypo_volume.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5034" pos-id="" label-id="Length From Edges (2D Hyp. for Triangulator)" icon-id="mesh_hypo_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-    <separator pos-id=""/>
-       <popup-item item-id="5000" pos-id="" label-id="Wire discretisation" icon-id="mesh_algo_regular.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5010" pos-id="" label-id="Triangle (Mefisto)" icon-id="mesh_algo_mefisto.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5011" pos-id="" label-id="Quadrangle (Mapping)" icon-id="mesh_algo_quad.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5020" pos-id="" label-id="Hexahedron (i,j,k)" icon-id="mesh_algo_hexa.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5021" pos-id="" label-id="Tetrahedron (Netgen)" icon-id="mesh_algo_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="5000" pos-id="" label-id="Create Hypotheses" icon-id="mesh_hypo_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="5010" pos-id="" label-id="Create Algorithms" icon-id="mesh_algo_mefisto.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </menu-item>
 
 <!-- ************************** Mesh  (menubar)  ************************************ -->
 <menu-item label-id="Mesh" item-id="70" pos-id="4">
-     <popup-item item-id="703" pos-id="" label-id="Global Hyp." icon-id="mesh_init.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-     <popup-item item-id="702" pos-id="" label-id="Local Hyp." icon-id="mesh_add_sub.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-     <popup-item item-id="704" pos-id="" label-id="Edit Hyp." icon-id="mesh_edit.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="703" pos-id="" label-id="Global Hypothesis" icon-id="mesh_init.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="702" pos-id="" label-id="Local Hypothesis" icon-id="mesh_add_sub.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="704" pos-id="" label-id="Edit Hypothesis" icon-id="mesh_edit.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
      <separator pos-id=""/>
      <popup-item item-id="701" pos-id="" label-id="Compute" icon-id="mesh_compute.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
      <separator pos-id=""/>
+     <popup-item item-id="801" pos-id="" label-id="Create Group" icon-id="mesh_tree_group.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="802" pos-id="" label-id="Construct Group" icon-id="mesh_make_group.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="803" pos-id="" label-id="Edit Group" icon-id="mesh_edit_group.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <separator pos-id=""/>
      <popup-item item-id="900" pos-id="" label-id="Mesh Infos" icon-id="mesh_info.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </menu-item>
 
 <!-- ************************** Control  (menubar)  ************************************ -->
 <menu-item label-id="Controls" item-id="60" pos-id="5">
        <popup-item item-id="6001" pos-id="" label-id="Length" icon-id="mesh_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="6002" pos-id="" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6003" pos-id="" label-id="Free borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6004" pos-id="" label-id="Borders at multi-connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <!-- popup-item item-id="6002" pos-id="" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/ -->
        <popup-item item-id="6011" pos-id="" label-id="Area" icon-id="mesh_area.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="6012" pos-id="" label-id="Taper" icon-id="mesh_taper.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="6013" pos-id="" label-id="Aspect Ratio" icon-id="mesh_aspect.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <popup-item item-id="6012" pos-id="" label-id="Taper" icon-id="mesh_taper.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <popup-item item-id="6013" pos-id="" label-id="Aspect Ratio" icon-id="mesh_aspect.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
        <popup-item item-id="6014" pos-id="" label-id="Minimum angle" icon-id="mesh_angle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
        <popup-item item-id="6015" pos-id="" label-id="Warp" icon-id="mesh_wrap.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
        <popup-item item-id="6016" pos-id="" label-id="Skew" icon-id="mesh_skew.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>  
      </submenu>
      <endsubmenu />
      <popup-item item-id="405" pos-id="" label-id="Move Node" icon-id="mesh_move_node.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-     <popup-item item-id="806" pos-id="" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-     <popup-item item-id="807" pos-id="" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-</menu-item>
-
-<!-- ************************** Numbering  (menubar)  ************************************ -->
-<menu-item label-id="Numbering" item-id="80" pos-id="7">
-     <popup-item item-id="9010" pos-id="" label-id="Display Nodes #" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
-     <popup-item item-id="9011" pos-id="" label-id="Display Elements #" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+     <popup-item item-id="406" pos-id="" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="407" pos-id="" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </menu-item>
 
 <!-- ********************************* Settings  (menubar) ********************************* -->
 <menu-item label-id="Preferences" item-id="4" pos-id="">
    <submenu label-id="Mesh" item-id="100" pos-id="-1">
     <submenu label-id="Display Mode" item-id="1000" pos-id="">
-       <popup-item item-id="10001" pos-id="" label-id="Wireframe" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
-       <popup-item item-id="10002" pos-id="" label-id="Shading" icon-id="" tooltip-id=""accel-id="" toggle-id="true" execute-action=""/>
-       <popup-item item-id="10003" pos-id="" label-id="Shrink" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+       <popup-item item-id="10001" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+       <popup-item item-id="10002" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id=""accel-id="" toggle-id="true" execute-action=""/>
+       <popup-item item-id="10004" pos-id="" label-id="Nodes" icon-id="mesh_points.png" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+        <separator pos-id=""/>
+       <popup-item item-id="10003" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
     </submenu>
     <endsubmenu /> 
     <popup-item item-id="1001" pos-id="" label-id="Automatic Update" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
     <separator pos-id=""/>
-    <popup-item item-id="1003" pos-id="" label-id="Colors - Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+    <popup-item item-id="1003" pos-id="" label-id="Colors / Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
     <separator pos-id=""/>
-    <popup-item item-id="1005" pos-id="" label-id="Scalars Bar" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+    <popup-item item-id="1005" pos-id="" label-id="Scalar Bar" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+    <separator pos-id=""/>
+    <popup-item item-id="1006" pos-id="" label-id="Selection" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    </submenu>
    <endsubmenu />
    <separator pos-id="-1"/>
 
 <!-- ********************************* View  (menubar) ********************************* -->
 <menu-item label-id="View" item-id="2" pos-id="">
-    <submenu label-id="Display Mode" item-id="21" pos-id="">
-       <popup-item item-id="211" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="212" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id=""accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-    </submenu>
-    <endsubmenu />
     <separator pos-id=""/>
     <popup-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </menu-item>
 <!-- ################################# POPUP MENU #################################  -->
 
 <popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Mesh">
-   <popup-item item-id="705" pos-id="" label-id="Edit Global Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <popup-item item-id="705" pos-id="" label-id="Edit Global Hypothesis" icon-id="mesh_edit.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <separator pos-id=""/>
+   <popup-item item-id="701" pos-id="" label-id="Compute" icon-id="mesh_compute.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <popup-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <popup-item item-id="900" pos-id="" label-id="Show Info" icon-id="mesh_info.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
    <separator pos-id=""/>
-   <popup-item item-id="701" pos-id="" label-id="Compute" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
-   <popup-item item-id="214" pos-id="" label-id="Update" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <popup-item item-id="801" pos-id="" label-id="Create Group" icon-id="mesh_tree_group.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
    <separator pos-id=""/>
    <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <separator pos-id=""/>
+   <popup-item item-id="122" pos-id="" label-id="Export to MED" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
 </popupmenu>
 
 <popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="SubMesh">
-   <popup-item item-id="706" pos-id="" label-id="Edit Local Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <popup-item item-id="706" pos-id="" label-id="Edit Local Hypothesis" icon-id="mesh_edit.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <separator pos-id=""/>
+   <popup-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <popup-item item-id="900" pos-id="" label-id="Show Info" icon-id="mesh_info.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <separator pos-id=""/>
+   <popup-item item-id="802" pos-id="" label-id="Construct Group" icon-id="mesh_make_group.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <separator pos-id=""/>
+   <popup-item item-id="33" pos-id="" label-id="Delete" icon-id="delete.png" tooltip-id="" accel-id="" toggle-id="" execute-action="" />
+</popupmenu>
+
+<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Group">
+   <popup-item item-id="803" pos-id="" label-id="Edit" icon-id="mesh_edit_group.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <separator pos-id=""/>
+   <popup-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <popup-item item-id="900" pos-id="" label-id="Show Info" icon-id="mesh_info.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <separator pos-id=""/>
+   <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <separator pos-id=""/>
+   <popup-item item-id="33" pos-id="" label-id="Delete" icon-id="delete.png" tooltip-id="" accel-id="" toggle-id="" execute-action="" />
 </popupmenu>
 
 <popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Hypothesis">
    <popup-item item-id="1100" pos-id="" label-id="Edit" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-   <popup-item item-id="1102" pos-id="" label-id="Unassign Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <popup-item item-id="1102" pos-id="" label-id="Unassign Hypothesis" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </popupmenu>
+
 <popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Algorithm">
-   <popup-item item-id="1102" pos-id="" label-id="Unassign Algo." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <popup-item item-id="1102" pos-id="" label-id="Unassign Algorithm" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </popupmenu>
 
 
-
 <popupmenu label-id="Popup for Viewer" context-id="" parent-id="Viewer" object-id="Mesh">
-   <popup-item item-id="214" pos-id="" label-id="Update" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> 
+   <popup-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> 
+   <popup-item item-id="900" pos-id="" label-id="Show Info" icon-id="mesh_info.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <separator pos-id=""/>   
+   <submenu label-id="Numbering" item-id="114" pos-id="">
+     <popup-item item-id="9010" pos-id="" label-id="Display Nodes #" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="9011" pos-id="" label-id="Display Elements #" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
+   <separator pos-id=""/>   
+   <submenu label-id="Display Mode" item-id="1131" pos-id="">
+        <popup-item item-id="211" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="212" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id=""accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="215" pos-id="" label-id="Nodes" icon-id="mesh_points.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <separator pos-id=""/>
+       <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
+   <popup-item item-id="1132" pos-id="" label-id="Colors / Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <popup-item item-id="1133" pos-id="" label-id="Transparency" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <separator pos-id=""/>
+   <submenu label-id="Control" item-id="2000" pos-id="">
+       <popup-item item-id="6001" pos-id="" label-id="Length" icon-id="mesh_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6003" pos-id="" label-id="Free borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6004" pos-id="" label-id="Borders at multi-connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <!-- popup-item item-id="6002" pos-id="" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/ -->
+       <popup-item item-id="6011" pos-id="" label-id="Area" icon-id="mesh_area.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <popup-item item-id="6012" pos-id="" label-id="Taper" icon-id="mesh_taper.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <popup-item item-id="6013" pos-id="" label-id="Aspect Ratio" icon-id="mesh_aspect.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6014" pos-id="" label-id="Minimum angle" icon-id="mesh_angle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6015" pos-id="" label-id="Warp" icon-id="mesh_wrap.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6016" pos-id="" label-id="Skew" icon-id="mesh_skew.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>  
+        <separator pos-id=""/>
+        <popup-item item-id="200" pos-id="" label-id="Reset" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <separator pos-id=""/>
+        <popup-item item-id="201" pos-id="" label-id="Scalar Bar Properties" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
+   <separator pos-id=""/>
+</popupmenu>
+
+<popupmenu label-id="Popup for Viewer" context-id="" parent-id="Viewer" object-id="SubMesh">
+   <popup-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> 
+   <popup-item item-id="900" pos-id="" label-id="Show Info" icon-id="mesh_info.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
    <separator pos-id=""/>   
-   <submenu label-id="Properties" item-id="113" pos-id="">
-        <submenu label-id="Display Mode" item-id="1131" pos-id="">
-               <popup-item item-id="211" pos-id="" label-id="Wireframe" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-               <popup-item item-id="212" pos-id="" label-id="Shading" icon-id="" tooltip-id=""accel-id="" toggle-id="" execute-action=""/>
-               <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       </submenu>
-       <endsubmenu />
+   <submenu label-id="Numbering" item-id="114" pos-id="">
+     <popup-item item-id="9010" pos-id="" label-id="Display Nodes #" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="9011" pos-id="" label-id="Display Elements #" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
+   <separator pos-id=""/>   
+   <submenu label-id="Display Mode" item-id="1131" pos-id="">
+        <popup-item item-id="211" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="212" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id=""accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="215" pos-id="" label-id="Nodes" icon-id="mesh_points.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <separator pos-id=""/>
+       <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
+   <popup-item item-id="1132" pos-id="" label-id="Colors / Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <popup-item item-id="1133" pos-id="" label-id="Transparency" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <separator pos-id=""/>
+   <submenu label-id="Control" item-id="2000" pos-id="">
+       <popup-item item-id="6001" pos-id="" label-id="Length" icon-id="mesh_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6003" pos-id="" label-id="Free borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6004" pos-id="" label-id="Borders at multi-connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <!-- popup-item item-id="6002" pos-id="" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/ -->
+       <popup-item item-id="6011" pos-id="" label-id="Area" icon-id="mesh_area.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <popup-item item-id="6012" pos-id="" label-id="Taper" icon-id="mesh_taper.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <popup-item item-id="6013" pos-id="" label-id="Aspect Ratio" icon-id="mesh_aspect.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6014" pos-id="" label-id="Minimum angle" icon-id="mesh_angle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6015" pos-id="" label-id="Warp" icon-id="mesh_wrap.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6016" pos-id="" label-id="Skew" icon-id="mesh_skew.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>  
         <separator pos-id=""/>
-        <popup-item item-id="1132" pos-id="" label-id="Colors - Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-        <popup-item item-id="1133" pos-id="" label-id="Transparency" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <popup-item item-id="200" pos-id="" label-id="Reset" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <separator pos-id=""/>
+        <popup-item item-id="201" pos-id="" label-id="Scalar Bar Properties" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    </submenu>
    <endsubmenu />
+   <separator pos-id=""/>
 </popupmenu>
 
-<popupmenu label-id="ScalarBar" context-id="" parent-id="Viewer" object-id="ScalarBar">
-   <popup-item item-id="200" pos-id="" label-id="Erase" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-   <popup-item item-id="201" pos-id="" label-id="Edit" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-   <popup-item item-id="202" pos-id="" label-id="Update View" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>  
+<popupmenu label-id="Popup for Viewer" context-id="" parent-id="Viewer" object-id="Group">
+   <popup-item item-id="803" pos-id="" label-id="Edit" icon-id="mesh_edit_group.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <separator pos-id=""/>
+   <popup-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> 
+   <popup-item item-id="900" pos-id="" label-id="Show Info" icon-id="mesh_info.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <separator pos-id=""/>   
+   <submenu label-id="Numbering" item-id="114" pos-id="">
+     <popup-item item-id="9010" pos-id="" label-id="Display Nodes #" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="9011" pos-id="" label-id="Display Elements #" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
+   <separator pos-id=""/>   
+   <submenu label-id="Display Mode" item-id="1131" pos-id="">
+        <popup-item item-id="211" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="212" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id=""accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="215" pos-id="" label-id="Nodes" icon-id="mesh_points.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <separator pos-id=""/>
+       <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
+   <popup-item item-id="1132" pos-id="" label-id="Colors / Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <popup-item item-id="1133" pos-id="" label-id="Transparency" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <separator pos-id=""/>
+   <submenu label-id="Control" item-id="2000" pos-id="">
+       <popup-item item-id="6001" pos-id="" label-id="Length" icon-id="mesh_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6003" pos-id="" label-id="Free borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6004" pos-id="" label-id="Borders at multi-connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <!-- popup-item item-id="6002" pos-id="" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/ -->
+       <popup-item item-id="6011" pos-id="" label-id="Area" icon-id="mesh_area.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <popup-item item-id="6012" pos-id="" label-id="Taper" icon-id="mesh_taper.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <popup-item item-id="6013" pos-id="" label-id="Aspect Ratio" icon-id="mesh_aspect.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6014" pos-id="" label-id="Minimum angle" icon-id="mesh_angle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6015" pos-id="" label-id="Warp" icon-id="mesh_wrap.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="6016" pos-id="" label-id="Skew" icon-id="mesh_skew.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>  
+        <separator pos-id=""/>
+        <popup-item item-id="200" pos-id="" label-id="Reset" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+        <separator pos-id=""/>
+        <popup-item item-id="201" pos-id="" label-id="Scalar Bar Properties" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   </submenu>
+   <endsubmenu />
+   <separator pos-id=""/>
+</popupmenu>
+
+<popupmenu label-id="Elements" context-id="" parent-id="Viewer" object-id="Elements">
+   <popup-item item-id="804" pos-id="" label-id="Add" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <popup-item item-id="805" pos-id="" label-id="Remove" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </popupmenu>
 
 </menubar>
 
 <!-- ///////////////////////////////////// TOOLBARS ////////////////////////////////////// -->
 <toolbar label-id="Mesh Toolbar">
-   <toolbutton-item item-id="703" pos-id="" label-id="Init" icon-id="mesh_init.png" tooltip-id="Global Hyp." accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="702" pos-id="" label-id="Add SubMesh" icon-id="mesh_add_sub.png" tooltip-id="Local Hyp." accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="704" pos-id="" label-id="Edit" icon-id="mesh_edit.png" tooltip-id="Edit Hyp." accel-id="" toggle-id="" execute-action=""/>
+   <toolbutton-item item-id="703" pos-id="" label-id="Init" icon-id="mesh_init.png" tooltip-id="Global Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+   <toolbutton-item item-id="702" pos-id="" label-id="Add SubMesh" icon-id="mesh_add_sub.png" tooltip-id="Local Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+   <toolbutton-item item-id="704" pos-id="" label-id="Edit" icon-id="mesh_edit.png" tooltip-id="Edit Hypothesis" accel-id="" toggle-id="" execute-action=""/>
    <separatorTB/>
    <toolbutton-item item-id="701" pos-id="" label-id="Compute" icon-id="mesh_compute.png" tooltip-id="Compute" accel-id="" toggle-id="" execute-action=""/>
    <separatorTB/>
+   <toolbutton-item item-id="801" pos-id="" label-id="Create Group" icon-id="mesh_tree_group.png" tooltip-id="Create Group" accel-id="" toggle-id="" execute-action=""/>
+   <toolbutton-item item-id="802" pos-id="" label-id="Construct Group" icon-id="mesh_make_group.png" tooltip-id="Construct Group" accel-id="" toggle-id="" execute-action=""/>
+   <toolbutton-item item-id="803" pos-id="" label-id="Edit Group" icon-id="mesh_edit_group.png" tooltip-id="Edit Group" accel-id="" toggle-id="" execute-action=""/>
+   <separatorTB/>
    <toolbutton-item item-id="900" pos-id="" label-id="Mesh Infos" icon-id="mesh_info.png" tooltip-id="Mesh Infos" accel-id="" toggle-id="" execute-action=""/>
 </toolbar>
 
 <toolbar label-id="Hypotheses Toolbar">
-   <toolbutton-item item-id="5030" label-id="Average length" icon-id="mesh_hypo_length.png" tooltip-id="Avreage length Hypothesis" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5031" label-id="Segments" icon-id="mesh_hypo_segment.png" tooltip-id="Nb. Segments Hypothesis" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5032" label-id="Max. Triangle Area" icon-id="mesh_hypo_area.png" tooltip-id="Max. Triangle Area Hypothesis" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5033" label-id="Max. Hexahedron or Tetrahedron Volume" icon-id="mesh_hypo_volume.png" tooltip-id="Max. Hexahedron or Tetrahedron Volume Hypothesis" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5034" label-id="Length From Edges (2D Hyp. for Triangulator)" icon-id="mesh_hypo_length.png" tooltip-id="Length From Edges Hypothesis" accel-id="" toggle-id="" execute-action=""/>
-   <separatorTB/>
-   <toolbutton-item item-id="5000" label-id="Wire Discretisation" icon-id="mesh_algo_regular.png" tooltip-id="Wire Discratisation Algorithm" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5010" label-id="Triangle (Mefisto)" icon-id="mesh_algo_mefisto.png" tooltip-id="Triangle (Mefisto) Algorithm" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5011" label-id="Quadrangle (Mapping)" icon-id="mesh_algo_quad.png" tooltip-id="Quadrangle (Mapping) Algorithm" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5020" label-id="Hexahedron (i,j,k)" icon-id="mesh_algo_hexa.png" tooltip-id="Hexahedron (i,j,k) Algorithm" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5021" label-id="Tetrahedron (Netgen)" icon-id="mesh_algo_hexa.png" tooltip-id="Tetrahedron (Netgen) Delaunay Algorithm" accel-id="" toggle-id="" execute-action=""/>
+   <toolbutton-item item-id="5000" label-id="Create Hypotheses" icon-id="mesh_hypo_length.png" tooltip-id="Create Hypotheses" accel-id="" toggle-id="" execute-action=""/>
+   <toolbutton-item item-id="5010" label-id="Create Algorithms" icon-id="mesh_algo_mefisto.png" tooltip-id="Create Algorithms" accel-id="" toggle-id="" execute-action=""/>
 </toolbar>
 
 <toolbar label-id="Controls toolbar">
        <toolbutton-item item-id="6001" label-id="Length" icon-id="mesh_length.png" tooltip-id="Length" accel-id="" toggle-id="" execute-action=""/>
-       <toolbutton-item item-id="6002" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="Connectivity" accel-id="" toggle-id="" execute-action=""/>
+       <toolbutton-item item-id="6003" label-id="Free borders" icon-id="mesh_free_edges.png" tooltip-id="Free borders" accel-id="" toggle-id="" execute-action=""/>
+  <toolbutton-item item-id="6004" label-id="Borders at multi-connection" icon-id="mesh_multi_edges.png" tooltip-id="Borders at multi-connection" accel-id="" toggle-id="" execute-action=""/>
+<!--<toolbutton-item item-id="6002" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="Connectivity" accel-id="" toggle-id="" execute-action=""/>-->
        <toolbutton-item item-id="6011" label-id="Area" icon-id="mesh_area.png" tooltip-id="Area" accel-id="" toggle-id="" execute-action=""/>
        <toolbutton-item item-id="6012" label-id="Taper" icon-id="mesh_taper.png" tooltip-id="Taper" accel-id="" toggle-id="" execute-action=""/>
        <toolbutton-item item-id="6013" label-id="Aspect Ratio" icon-id="mesh_aspect.png" tooltip-id="Aspect Ratio" accel-id="" toggle-id="" execute-action=""/>
 
 <toolbar label-id="Modification toolbar">
      <toolbutton-item item-id="405" label-id="Move Node" icon-id="mesh_move_node.png" tooltip-id="Move Node" accel-id="" toggle-id="" execute-action=""/>
-     <toolbutton-item item-id="806" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="Orientation" accel-id="" toggle-id="" execute-action=""/>
-     <toolbutton-item item-id="807" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="Diagonal Inversion" accel-id="" toggle-id="" execute-action=""/>
+     <toolbutton-item item-id="406" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="Orientation" accel-id="" toggle-id="" execute-action=""/>
+     <toolbutton-item item-id="407" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="Diagonal Inversion" accel-id="" toggle-id="" execute-action=""/>
 </toolbar>
 
 <toolbar label-id="Display Mode Toolbar">
    <toolbutton-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="Update View" accel-id="" toggle-id="" execute-action=""/>
-   <separatorTB/>
-   <toolbutton-item item-id="211" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="Wireframe" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="212" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id="shading" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="shrink" accel-id="" toggle-id="" execute-action=""/>
 </toolbar>
 
 </desktop>     
index 5c29ab6eca6f8fed2c197e82a30a666b2ee39a90..bef8ea89fb57b944eb4fc29f601670b53cfe4f1c 100644 (file)
@@ -17,7 +17,7 @@
      <submenu label-id="Import" item-id="11" pos-id="8">
        <popup-item item-id="111" pos-id="" label-id="DAT file" icon-id="" tooltip-id="" accel-id="Ctrl+B" toggle-id="" execute-action=""/>
                <popup-item item-id="112" pos-id="" label-id="UNV File" icon-id="" tooltip-id="" accel-id="Ctrl+I" toggle-id="" execute-action=""/> 
-               <popup-item item-id="113" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> 
+               <popup-item item-id="113" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="Ctrl+M" toggle-id="" execute-action=""/> 
       </submenu>
       <endsubmenu />
       <submenu label-id="Export" item-id="12" pos-id="9">
 
 <!-- ************************** Hypothesis  (menubar)  ************************************ -->
 <menu-item label-id="Hypotheses" item-id="50" pos-id="3">
-       <popup-item item-id="5030" pos-id="" label-id="Average length" icon-id="mesh_hypo_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5031" pos-id="" label-id="Nb. Segments" icon-id="mesh_hypo_segment.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5032" pos-id="" label-id="Max. Triangle Area" icon-id="mesh_hypo_area.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5033" pos-id="" label-id="Max. Hexahedron or Tetrahedron Volume" icon-id="mesh_hypo_volume.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5034" pos-id="" label-id="Length From Edges (2D Hyp. for Triangulator)" icon-id="mesh_hypo_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-    <separator pos-id=""/>
-       <popup-item item-id="5000" pos-id="" label-id="Wire discretisation" icon-id="mesh_algo_regular.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5010" pos-id="" label-id="Triangle (Mefisto)" icon-id="mesh_algo_mefisto.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5011" pos-id="" label-id="Quadrangle (Mapping)" icon-id="mesh_algo_quad.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5020" pos-id="" label-id="Hexahedron (i,j,k)" icon-id="mesh_algo_hexa.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-       <popup-item item-id="5021" pos-id="" label-id="Tetrahedron (Netgen)" icon-id="mesh_algo_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="5000" pos-id="" label-id="Create Hypothesis" icon-id="mesh_hypo_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+       <popup-item item-id="5010" pos-id="" label-id="Create Algorithm" icon-id="mesh_algo_mefisto.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </menu-item>
 
 <!-- ************************** Mesh  (menubar)  ************************************ -->
@@ -58,6 +49,8 @@
      <separator pos-id=""/>
      <popup-item item-id="701" pos-id="" label-id="Compute" icon-id="mesh_compute.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
      <separator pos-id=""/>
+     <popup-item item-id="801" pos-id="" label-id="Create Group" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <separator pos-id=""/>
      <popup-item item-id="900" pos-id="" label-id="Mesh Infos" icon-id="mesh_info.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </menu-item>
 
@@ -90,8 +83,8 @@
      </submenu>
      <endsubmenu />
      <popup-item item-id="405" pos-id="" label-id="Move Node" icon-id="mesh_move_node.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-     <popup-item item-id="806" pos-id="" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
-     <popup-item item-id="807" pos-id="" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="406" pos-id="" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+     <popup-item item-id="407" pos-id="" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </menu-item>
 
 <!-- ************************** Numbering  (menubar)  ************************************ -->
     <endsubmenu /> 
     <popup-item item-id="1001" pos-id="" label-id="Automatic Update" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
     <separator pos-id=""/>
-      <popup-item item-id="1003" pos-id="" label-id="Colors - Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+    <popup-item item-id="1003" pos-id="" label-id="Colors - Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
     <separator pos-id=""/>
     <popup-item item-id="1005" pos-id="" label-id="Scalars Bar" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    </submenu>
    <popup-item item-id="701" pos-id="" label-id="Compute" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
    <popup-item item-id="214" pos-id="" label-id="Update" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
    <separator pos-id=""/>
+   <popup-item item-id="801" pos-id="" label-id="Create Group" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
+   <separator pos-id=""/>
    <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </popupmenu>
 
 <popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="SubMesh">
    <popup-item item-id="706" pos-id="" label-id="Edit Local Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+   <separator pos-id=""/>
+   <popup-item item-id="802" pos-id="" label-id="Construct Group" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>   
 </popupmenu>
 
 <popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Hypothesis">
    <popup-item item-id="1102" pos-id="" label-id="Unassign Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </popupmenu>
+
 <popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Algorithm">
    <popup-item item-id="1102" pos-id="" label-id="Unassign Algo." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
 </popupmenu>
 
 
-
 <popupmenu label-id="Popup for Viewer" context-id="" parent-id="Viewer" object-id="Mesh">
    <popup-item item-id="214" pos-id="" label-id="Update" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> 
    <separator pos-id=""/>   
 </toolbar>
 
 <toolbar label-id="Hypotheses Toolbar">
-   <toolbutton-item item-id="5030" label-id="Average length" icon-id="mesh_hypo_length.png" tooltip-id="Avreage length Hypothesis" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5031" label-id="Segments" icon-id="mesh_hypo_segment.png" tooltip-id="Nb. Segments Hypothesis" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5032" label-id="Max. Triangle Area" icon-id="mesh_hypo_area.png" tooltip-id="Max. Triangle Area Hypothesis" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5033" label-id="Max. Hexahedron or Tetrahedron Volume" icon-id="mesh_hypo_volume.png" tooltip-id="Max. Hexahedron or Tetrahedron Volume Hypothesis" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5034" label-id="Length From Edges (2D Hyp. for Triangulator)" icon-id="mesh_hypo_length.png" tooltip-id="Length From Edges Hypothesis" accel-id="" toggle-id="" execute-action=""/>
-   <separatorTB/>
-   <toolbutton-item item-id="5000" label-id="Wire Discretisation" icon-id="mesh_algo_regular.png" tooltip-id="Wire Discratisation Algorithm" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5010" label-id="Triangle (Mefisto)" icon-id="mesh_algo_mefisto.png" tooltip-id="Triangle (Mefisto) Algorithm" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5011" label-id="Quadrangle (Mapping)" icon-id="mesh_algo_quad.png" tooltip-id="Quadrangle (Mapping) Algorithm" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5020" label-id="Hexahedron (i,j,k)" icon-id="mesh_algo_hexa.png" tooltip-id="Hexahedron (i,j,k) Algorithm" accel-id="" toggle-id="" execute-action=""/>
-   <toolbutton-item item-id="5021" label-id="Tetrahedron (Netgen)" icon-id="mesh_algo_hexa.png" tooltip-id="Tetrahedron (Netgen) Delaunay Algorithm" accel-id="" toggle-id="" execute-action=""/>
+   <toolbutton-item item-id="5000" label-id="Create Hypothesis" icon-id="mesh_hypo_length.png" tooltip-id="Create Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+   <toolbutton-item item-id="5010" label-id="Create Algorithm" icon-id="mesh_algo_mefisto.png" tooltip-id="Create Algorithm" accel-id="" toggle-id="" execute-action=""/>
 </toolbar>
 
 <toolbar label-id="Controls toolbar">
 
 <toolbar label-id="Modification toolbar">
      <toolbutton-item item-id="405" label-id="Move Node" icon-id="mesh_move_node.png" tooltip-id="Move Node" accel-id="" toggle-id="" execute-action=""/>
-     <toolbutton-item item-id="806" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="Orientation" accel-id="" toggle-id="" execute-action=""/>
-     <toolbutton-item item-id="807" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="Diagonal Inversion" accel-id="" toggle-id="" execute-action=""/>
+     <toolbutton-item item-id="406" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="Orientation" accel-id="" toggle-id="" execute-action=""/>
+     <toolbutton-item item-id="407" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="Diagonal Inversion" accel-id="" toggle-id="" execute-action=""/>
 </toolbar>
 
 <toolbar label-id="Display Mode Toolbar">
index 6016ac85fb6f19f806ec3a41ef09003386325508..252d53062f40e49e29f5549befcc2e4b649f5099 100644 (file)
@@ -46,7 +46,7 @@ LIB_CLIENT_IDL =
 LIB_SERVER_IDL =
 
 # additionnal information to compil and link file
-CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
 CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -rdynamic -ldl -I${KERNEL_ROOT_DIR}/include/salome
 
 LDFLAGS  += $(MED2_LIBS) -lSMESHDS -lSMDS
index 9ebe754b3ddb52ff9586b2b4c74cbc337cacde8a..8f6a7068d6ea865289302b3bb8f95635c5c44e4a 100644 (file)
@@ -111,7 +111,7 @@ void DriverDAT_W_SMDS_Mesh::Write()
        fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
        fprintf(stdout, "(************************)\n");
 
-       SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
+       SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator();
        while(itNodes->more())
        {               
                const SMDS_MeshNode * node = itNodes->next();
@@ -127,7 +127,7 @@ void DriverDAT_W_SMDS_Mesh::Write()
        fprintf(stdout, "(**************************)");
        /* Ecriture des connectivites, noms, numeros des mailles */
 
-       SMDS_Iterator<const SMDS_MeshEdge *> * itEdges=myMesh->edgesIterator();
+       SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator();
        while(itEdges->more())
        {
                const SMDS_MeshElement * elem = itEdges->next();
@@ -146,13 +146,13 @@ void DriverDAT_W_SMDS_Mesh::Write()
                }
                }
 
-               SMDS_Iterator<const SMDS_MeshElement *> * it=elem->nodesIterator();
+               SMDS_ElemIteratorPtr it=elem->nodesIterator();
                while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
 
                fprintf(myFileId, "\n");
        }
 
-       SMDS_Iterator<const SMDS_MeshFace *> * itFaces=myMesh->facesIterator();
+       SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator();
        while(itFaces->more())
        {
                const SMDS_MeshElement * elem = itFaces->next();
@@ -176,13 +176,13 @@ void DriverDAT_W_SMDS_Mesh::Write()
                }
                }
 
-               SMDS_Iterator<const SMDS_MeshElement *> * it=elem->nodesIterator();
+               SMDS_ElemIteratorPtr it=elem->nodesIterator();
                while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
 
                fprintf(myFileId, "\n");
        }
 
-       SMDS_Iterator<const SMDS_MeshVolume *> * itVolumes=myMesh->volumesIterator();
+       SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
        while(itVolumes->more())
        {
                const SMDS_MeshElement * elem = itVolumes->next();
@@ -196,7 +196,7 @@ void DriverDAT_W_SMDS_Mesh::Write()
                }
                }
 
-               SMDS_Iterator<const SMDS_MeshElement *> * it=elem->nodesIterator();
+               SMDS_ElemIteratorPtr it=elem->nodesIterator();
                while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
 
                fprintf(myFileId, "\n");
index 0c988c3d8bb85fcbc888e0e6148bf579deb99248..9518e2f784579878735693671ce085040a05b2e5 100644 (file)
@@ -125,14 +125,13 @@ void DriverDAT_W_SMESHDS_Mesh::Add()
        fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
        fprintf(stdout, "(************************)\n");
 
-       SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
+       SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator();
        while(itNodes->more())
        {               
                const SMDS_MeshNode * node = itNodes->next();
                fprintf(myFileId, "%d %e %e %e\n", node->GetID(), node->X(),
                        node->Y(), node->Z());
        }
-       delete itNodes;
 
   /****************************************************************************
   *                       ECRITURE DES ELEMENTS                                *
@@ -142,7 +141,7 @@ void DriverDAT_W_SMESHDS_Mesh::Add()
        fprintf(stdout, "(**************************)");
        /* Ecriture des connectivites, noms, numeros des mailles */
 
-       SMDS_Iterator<const SMDS_MeshEdge*> * itEdges=myMesh->edgesIterator();
+       SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator();
        while(itEdges->more())
        {
                const SMDS_MeshEdge * elem = itEdges->next();
@@ -161,15 +160,14 @@ void DriverDAT_W_SMESHDS_Mesh::Add()
                }
                }
 
-               SMDS_Iterator<const SMDS_MeshElement *> * itNodes=elem->nodesIterator();
+               SMDS_ElemIteratorPtr itNodes=elem->nodesIterator();
                while(itNodes->more())
                        fprintf(myFileId, "%d ", itNodes->next()->GetID());
                
                fprintf(myFileId, "\n");
        }
-       delete itEdges;
 
-       SMDS_Iterator<const SMDS_MeshFace *> * itFaces=myMesh->facesIterator();
+       SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator();
        while(itFaces->more())
        {
                const SMDS_MeshElement * elem = itFaces->next();
@@ -193,16 +191,14 @@ void DriverDAT_W_SMESHDS_Mesh::Add()
                }
                }
 
-               SMDS_Iterator<const SMDS_MeshElement *> * itNodes=elem->nodesIterator();
+               SMDS_ElemIteratorPtr itNodes=elem->nodesIterator();
                while(itNodes->more())
                        fprintf(myFileId, "%d ", itNodes->next()->GetID());
-               delete itNodes;
        
                fprintf(myFileId, "\n");
        }
-       delete itFaces;
 
-       SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=myMesh->volumesIterator();
+       SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
        while(itVolumes->more())
        {
                const SMDS_MeshElement * elem = itVolumes->next();
@@ -216,14 +212,12 @@ void DriverDAT_W_SMESHDS_Mesh::Add()
                }
                }
 
-               SMDS_Iterator<const SMDS_MeshElement *> * itNodes=elem->nodesIterator();
+               SMDS_ElemIteratorPtr itNodes=elem->nodesIterator();
                while(itNodes->more())
                        fprintf(myFileId, "%d ", itNodes->next()->GetID());
-               delete itNodes; 
 
                fprintf(myFileId, "\n");
        }
-       delete itVolumes;
 
        fclose(myFileId);
 }
index cf3dba921988323a61f555b5e520c6cb0cbbaf77..12dd8b7ca5dd153cf696cfbc07ca0f3ce2b07ac5 100644 (file)
@@ -46,7 +46,7 @@ LIB_CLIENT_IDL =
 LIB_SERVER_IDL =
 
 # additionnal information to compil and link file
-CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
 CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
 LDFLAGS  += $(MED2_LIBS) -lMeshDriver
 
index 1652a55a7e0ffc9b09309172b203d3ca5fd98e50..99da911a2b60a3d97aeca63b4ddd66887624e205 100644 (file)
 //  File   : DriverMED_R_SMESHDS_Mesh.cxx
 //  Module : SMESH
 
-using namespace std;
 #include "DriverMED_R_SMESHDS_Mesh.h"
 #include "DriverMED_R_SMDS_Mesh.h"
 #include "utilities.h"
 
+#include "DriverMED_Family.h"
+
+#include "SMESHDS_Group.hxx"
+
+#include "MEDA_Wrapper.hxx"
+#include "MED_Utilities.hxx"
+
 #include <stdlib.h>
 
 DriverMED_R_SMESHDS_Mesh::DriverMED_R_SMESHDS_Mesh()
+     :
+       myMesh (NULL),
+       myFile (""),
+       myFileId (-1),
+       myMeshId (-1)
 {
-       myFileId = -1;
 }
 
 DriverMED_R_SMESHDS_Mesh::~DriverMED_R_SMESHDS_Mesh()
 {
-       ;
+//  map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
+//  for (; aFamsIter != myFamilies.end(); aFamsIter++)
+//  {
+//    delete (*aFamsIter).second;
+//  }
 }
 
 void DriverMED_R_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
 {
-       //myMesh = SMESHDS_Mesh *::DownCast(aMesh);
-       myMesh = aMesh;
+  myMesh = aMesh;
 }
 
 void DriverMED_R_SMESHDS_Mesh::SetFile(string aFile)
 {
-       myFile = aFile;
+  myFile = aFile;
 }
 
 void DriverMED_R_SMESHDS_Mesh::SetFileId(med_idt aFileId)
 {
-       myFileId = aFileId;
+  myFileId = aFileId;
 }
 
 void DriverMED_R_SMESHDS_Mesh::SetMeshId(int aMeshId)
 {
-       myMeshId = aMeshId;
+  myMeshId = aMeshId;
 }
 
-void DriverMED_R_SMESHDS_Mesh::Read()
+void DriverMED_R_SMESHDS_Mesh::SetMeshName(string theMeshName)
 {
+  myMeshName = theMeshName;
+}
 
-       string myClass = string("SMDS_Mesh");
-       string myExtension = string("MED");
+void DriverMED_R_SMESHDS_Mesh::Read()
+{
 
-       DriverMED_R_SMDS_Mesh *myReader = new DriverMED_R_SMDS_Mesh;
+  string myClass = string("SMDS_Mesh");
+  string myExtension = string("MED");
 
-       myReader->SetMesh(myMesh);
-       myReader->SetMeshId(myMeshId);
-       myReader->SetFile(myFile);
-       myReader->SetFileId(-1);
+  DriverMED_R_SMDS_Mesh *myReader = new DriverMED_R_SMDS_Mesh;
 
-       myReader->Read();
+  myReader->SetMesh(myMesh);
+  myReader->SetMeshId(myMeshId);
+  myReader->SetFile(myFile);
+  myReader->SetFileId(-1);
 
+  myReader->Read();
 }
 
 void DriverMED_R_SMESHDS_Mesh::Add()
 {
+  string myClass = string("SMDS_Mesh");
+  string myExtension = string("MED");
 
-       string myClass = string("SMDS_Mesh");
-       string myExtension = string("MED");
-
-       DriverMED_R_SMDS_Mesh *myReader = new DriverMED_R_SMDS_Mesh;
-
-       myReader->SetMesh(myMesh);
-       myReader->SetMeshId(myMeshId);
+  DriverMED_R_SMDS_Mesh *myReader = new DriverMED_R_SMDS_Mesh;
 
-       SCRUTE(myFileId);
-       myReader->SetFileId(myFileId);
+  myReader->SetMesh(myMesh);
+  myReader->SetMeshId(myMeshId);
 
-       myReader->Read();
+  SCRUTE(myFileId);
+  myReader->SetFileId(myFileId);
 
+  myReader->Read();
 }
 
-void DriverMED_R_SMESHDS_Mesh::ReadMySelf()
-{
-
-       med_err ret = 0;
-       int i, j, k, l;
-       int numero;
-       char message[200];
-       bool ok;
-       /* nombre d'objets MED */
-       char nom_universel[MED_TAILLE_LNOM + 1];
-       med_int long_fichier_en_tete;
-       char *fichier_en_tete;
-       char version_hdf[10];
-       char version_med[10];
-       med_int nmaa, mdim, nnoe;
-       med_int nmai[MED_NBR_GEOMETRIE_MAILLE], nfac[MED_NBR_GEOMETRIE_FACE];
-       med_int nare[MED_NBR_GEOMETRIE_ARETE];
-       /* nom du maillage */
-       char nommaa[MED_TAILLE_NOM + 1];
-       /* noeuds */
-       med_float *coo;
-       char nomcoo[3 * MED_TAILLE_PNOM + 1];
-       char unicoo[3 * MED_TAILLE_PNOM + 1];
-       char *nomnoe;
-       med_int *numnoe;
-       med_int *nufano;
-       med_repere rep;
-       med_booleen inonoe, inunoe;
-       med_mode_switch mode_coo;
-       char str[MED_TAILLE_PNOM + 1];
-       /* elements */
-       med_int nsup;
-       med_int edim;
-       med_int taille;
-       med_int elem_id;
-       med_int cmpt = 0;
-       med_int *connectivite;
-       char *nomele;
-       med_int *numele;
-       med_int *nufael;
-       med_booleen inoele, inuele;
-       med_connectivite typ_con;
-       med_geometrie_element typgeo;
-       med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] =
-               { MED_POINT1, MED_SEG2,
-               MED_SEG3, MED_TRIA3,
-               MED_TRIA6, MED_QUAD4,
-               MED_QUAD8, MED_TETRA4,
-               MED_TETRA10, MED_HEXA8,
-               MED_HEXA20, MED_PENTA6,
-               MED_PENTA15, MED_PYRA5,
-               MED_PYRA13
-       };
-       med_int desmai[MED_NBR_GEOMETRIE_MAILLE] =
-               { 0, 2, 3, 3, 3, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5 };
-       med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
-       char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1",
-               "MED_SEG2",
-               "MED_SEG3",
-               "MED_TRIA3",
-               "MED_TRIA6",
-               "MED_QUAD4",
-               "MED_QUAD8",
-               "MED_TETRA4",
-               "MED_TETRA10",
-               "MED_HEXA8",
-               "MED_HEXA20",
-               "MED_PENTA6",
-               "MED_PENTA15",
-               "MED_PYRA5",
-               "MED_PYRA13"
-       };
-       med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] =
-               { MED_TRIA3, MED_TRIA6,
-               MED_QUAD4, MED_QUAD8
-       };
-       med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 };
-       med_int nfaces[MED_NBR_GEOMETRIE_FACE];
-       char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM + 1] =
-               { "MED_TRIA3", "MED_TRIA6",
-               "MED_QUAD4", "MED_QUAD8"
-       };
-       med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] =
-               { MED_SEG2, MED_SEG3 };
-       med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 };
-       med_int naretes[MED_NBR_GEOMETRIE_ARETE];
-       char nomare[MED_NBR_GEOMETRIE_ARETE][MED_TAILLE_NOM + 1] =
-               { "MED_SEG2", "MED_SEG3" };
-       /* familles */
-       med_int nfam;
-       med_int natt, ngro;
-       char *attdes, *gro;
-       med_int *attval, *attide;
-       char nomfam[MED_TAILLE_NOM + 1];
-       med_int numfam;
-       char str1[MED_TAILLE_DESC + 1];
-       char str2[MED_TAILLE_LNOM + 1];
-       string fam;
-       string fam_type;
-       string fam_id;
-
-       char *file2Read;
-       bool locally_managed;
-
-       if (myFileId == -1)
-               locally_managed = true;
-       else
-               locally_managed = false;
-
-       if (locally_managed)
-       {
-               file2Read = (char *)myFile.c_str();
-               myFileId = MEDouvrir(file2Read, MED_LECT);
-               if (myFileId < 0)
-               {
-                       fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n",
-                               file2Read);
-                       exit(EXIT_FAILURE);
-               }
-               numero = 1;
-       }
-       else
-               numero = myMeshId;
-       sprintf(nommaa, "Mesh %d", myMeshId);   //pour load
-       SCRUTE(nommaa);
-
-       typ_con = MED_NOD;
-       mode_coo = MED_FULL_INTERLACE;
-       mdim = 3;
-
-       SMESHDS_Mesh * mySMESHDSMesh = dynamic_cast<SMESHDS_Mesh *>(myMesh);
-
-       //TopoDS_Shape myShape = mySMESHDSMesh->ShapeToMesh();
-
-  /****************************************************************************
-  *                       NOMBRES D'OBJETS MED                                *
-  ****************************************************************************/
-       fprintf(stdout, "\n(****************************)\n");
-       fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n");
-       fprintf(stdout, "(****************************)\n");
-
-       /* lecture du nom et de la dimension du maillage */
-       /*!  fprintf(stdout,"%d %d\n",myFileId,numero);
-        * ret = MEDmaaInfo(myFileId,numero,nommaa,&mdim);
-        * fprintf(stdout,"%d\n",ret);
-        * if (ret < 0)
-        * {
-        * fprintf(stderr,">> ERREUR : lecture du nom du maillage \n");
-        * exit(EXIT_FAILURE);
-        * }
-        * fprintf(stdout,"- Nom du maillage : <<%s>>\n",nommaa);
-        * fprintf(stdout,"- Dimension du maillage : %d\n",mdim);
-        */
-       /* Combien de noeuds ? */
-       nnoe =
-               MEDnEntMaa(myFileId, nommaa, MED_COOR, MED_NOEUD, MED_POINT1, typ_con);
-       if (nnoe < 0)
-       {
-               fprintf(stderr, ">> ERREUR : lecture du nombre de noeuds \n");
-               exit(EXIT_FAILURE);
-       }
-       fprintf(stdout, "- Nombre de noeuds : %d \n", nnoe);
-
-       /* Combien de mailles, faces ou aretes ? */
-       for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
-       {
-               nmailles[i] =
-                       MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_MAILLE, typmai[i],
-                       typ_con);
-               if (nmailles[i] < 0)
-               {
-                       fprintf(stderr, ">> ERREUR : lecture du nombre de mailles \n");
-                       exit(EXIT_FAILURE);
-               }
-               fprintf(stdout, "- Nombre de mailles de type %s : %d \n", nommai[i],
-                       nmailles[i]);
-       }
 
-       for (i = 0; i < MED_NBR_GEOMETRIE_FACE; i++)
-       {
-               nfaces[i] = MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_FACE, typfac[i],
-                       typ_con);
-               if (nfaces[i] < 0)
-               {
-                       fprintf(stderr, ">> ERREUR : lecture du nombre de faces \n");
-                       exit(EXIT_FAILURE);
-               }
-               fprintf(stdout, "- Nombre de faces de type %s : %d \n", nomfac[i],
-                       nfaces[i]);
-       }
+static const SMDS_MeshNode* 
+FindNode(const SMDS_Mesh* theMesh, med_int theId){
+  const SMDS_MeshNode* aNode = theMesh->FindNode(theId);
+  if(aNode) return aNode;
+  EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
+}
 
-       for (i = 0; i < MED_NBR_GEOMETRIE_ARETE; i++)
-       {
-               naretes[i] =
-                       MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_ARETE, typare[i],
-                       typ_con);
-               if (naretes[i] < 0)
-               {
-                       fprintf(stderr, ">> ERREUR : lecture du nombre d'aretes \n");
-                       exit(EXIT_FAILURE);
-               }
-               fprintf(stdout, "- Nombre d'aretes de type %s : %d \n", nomare[i],
-                       naretes[i]);
-       }
 
-       /* nombre de familles */
-       nfam = MEDnFam(myFileId, nommaa, 0, MED_FAMILLE);
-       if (nfam < 0)
-       {
-               fprintf(stderr, ">> ERREUR : lecture du nombre de familles \n");
-               exit(EXIT_FAILURE);
-       }
-       fprintf(stdout, "- Nombre de familles : %d \n", nfam);
-
-       vector < int >family[nfam];
-
-  /****************************************************************************
-  *                       LECTURE DES NOEUDS                                  *
-  ****************************************************************************/
-       fprintf(stdout, "\n(************************)\n");
-       fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
-       fprintf(stdout, "(************************)\n");
-
-       /* Allocations memoires */
-       /* table des coordonnees 
-        * profil : (dimension * nombre de noeuds ) */
-       coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim);
-       /* table  des numeros, des numeros de familles des noeuds
-        * profil : (nombre de noeuds) */
-       numnoe = (med_int *) malloc(sizeof(med_int) * nnoe);
-       nufano = (med_int *) malloc(sizeof(med_int) * nnoe);
-       /* table des noms des noeuds 
-        * profil : (nnoe*MED_TAILLE_PNOM+1) */
-       nomnoe = (char *)malloc(MED_TAILLE_PNOM * nnoe + 1);
-
-       /* lecture des noeuds : 
-        * - coordonnees
-        * - noms (optionnel dans un fichier MED) 
-        * - numeros (optionnel dans un fichier MED) 
-        * - numeros des familles */
-       ret = MEDnoeudsLire(myFileId, nommaa, mdim, coo, mode_coo, &rep,
-               nomcoo, unicoo, nomnoe, &inonoe, numnoe, &inunoe, nufano, nnoe);
-       if (ret < 0)
-               strcpy(message, ">> ERREUR : lecture des noeuds \n");
-
-       if (inunoe)
-       {
-               for (int i = 0; i < nnoe; i++)
-               {
-                       ok = mySMESHDSMesh->AddNodeWithID(coo[i * 3], coo[i * 3 + 1],
-                               coo[i * 3 + 2], numnoe[i]);
-                       //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]);
-               }
-       }
-       else
-       {
-               for (int i = 0; i < nnoe; i++)
-               {
-                       ok = mySMESHDSMesh->AddNodeWithID(coo[i * 3], coo[i * 3 + 1],
-                               coo[i * 3 + 2], i + 1);
-                       //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i);
-                       family[*(nufano + i)].push_back(numnoe[i]);
+DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
+{
+  ReadStatus result = DRS_FAIL;
+  try{
+    using namespace MEDA;
+
+    myFamilies.clear();
+    MESSAGE("ReadMySelf - myFile : "<<myFile);
+    TWrapper aMed(myFile);
+
+    result = DRS_EMPTY;
+    if(med_int aNbMeshes = aMed.GetNbMeshes()){
+      for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){
+       // Reading the MED mesh
+       //---------------------
+       PMeshInfo aMeshInfo = aMed.GetMeshInfo(iMesh);
+        string aMeshName;
+        if (myMeshId != -1) {
+          ostringstream aMeshNameStr;
+          aMeshNameStr<<myMeshId;
+          aMeshName = aMeshNameStr.str();
+        } else {
+          aMeshName = myMeshName;
+        }
+       MESSAGE("ReadMySelf - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
+       if(aMeshName != aMeshInfo->GetName()) continue;
+        result = DRS_OK;
+       med_int aMeshDim = aMeshInfo->GetDim();
+       
+        // Reading MED families to the temporary structure
+       //------------------------------------------------
+        med_int aNbFams = aMed.GetNbFamilies(aMeshInfo);
+        MESSAGE("Read " << aNbFams << " families");
+        for (med_int iFam = 0; iFam < aNbFams; iFam++) {
+          PFamilyInfo aFamilyInfo = aMed.GetFamilyInfo(aMeshInfo, iFam);
+          med_int aFamId = aFamilyInfo->GetId();
+          MESSAGE("Family " << aFamId << " :");
+
+//if (aFamId >= FIRST_VALID_FAMILY) {
+            DriverMED_FamilyPtr aFamily (new DriverMED_Family);
+
+            med_int aNbGrp = aFamilyInfo->GetNbGroup();
+            MESSAGE("belong to " << aNbGrp << " groups");
+            for (med_int iGr = 0; iGr < aNbGrp; iGr++) {
+              string aGroupName = aFamilyInfo->GetGroupName(iGr);
+              MESSAGE(aGroupName);
+              aFamily->AddGroupName(aGroupName);
+            }
+//        aFamily->SetId(aFamId);
+            myFamilies[aFamId] = aFamily;
+//          }
+        }
+
+        // Reading MED nodes to the corresponding SMDS structure
+       //------------------------------------------------------
+       PNodeInfo aNodeInfo = aMed.GetNodeInfo(aMeshInfo);
+       med_booleen anIsNodeNum = aNodeInfo->IsElemNum();
+       med_int aNbElems = aNodeInfo->GetNbElem();
+       MESSAGE("ReadMySelf - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
+        for(med_int iElem = 0; iElem < aNbElems; iElem++){
+          double aCoords[3] = {0.0, 0.0, 0.0};
+          for(med_int iDim = 0; iDim < aMeshDim; iDim++)
+            aCoords[iDim] = aNodeInfo->GetNodeCoord(iElem,iDim);
+          const SMDS_MeshNode* aNode;
+          if(anIsNodeNum) {
+           aNode = myMesh->AddNodeWithID
+              (aCoords[0],aCoords[1],aCoords[2],aNodeInfo->GetElemNum(iElem));
+          } else {
+           aNode = myMesh->AddNode
+              (aCoords[0],aCoords[1],aCoords[2]);
+          }
+          //cout<<aNode->GetID()<<": "<<aNode->X()<<", "<<aNode->Y()<<", "<<aNode->Z()<<endl;
+
+          // Save reference to this node from its family
+          med_int aFamNum = aNodeInfo->GetFamNum(iElem);
+          if (myFamilies.find(aFamNum) != myFamilies.end())
+          {
+            myFamilies[aFamNum]->AddElement(aNode);
+            myFamilies[aFamNum]->SetType(SMDSAbs_Node);
+          }
+        }
+
+       // Reading pre information about all MED cells
+       //--------------------------------------------
+        bool takeNumbers = true;  // initially we trust the numbers from file
+       MED::TEntityInfo aEntityInfo = aMed.GetEntityInfo(aMeshInfo);
+       MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin();
+       for(; anEntityIter != aEntityInfo.end(); anEntityIter++){
+         const med_entite_maillage& anEntity = anEntityIter->first;
+         if(anEntity == MED_NOEUD) continue;
+         // Reading MED cells to the corresponding SMDS structure
+         //------------------------------------------------------
+         const MED::TGeom& aTGeom = anEntityIter->second;
+         MED::TGeom::const_iterator anTGeomIter = aTGeom.begin();
+         for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
+           const med_geometrie_element& aGeom = anTGeomIter->first;
+           if(aGeom == MED_POINT1) continue;
+           PCellInfo aCellInfo = aMed.GetCellInfo(aMeshInfo,anEntity,aGeom);
+           med_booleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : MED_FAUX;
+           med_int aNbElems = aCellInfo->GetNbElem();
+           MESSAGE("ReadMySelf - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
+           MESSAGE("ReadMySelf - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
+
+           for(int iElem = 0; iElem < aNbElems; iElem++){
+             med_int aNbNodes = -1;
+             switch(aGeom){
+             case MED_SEG2:
+             case MED_SEG3:
+               aNbNodes = 2;
+               break;
+             case MED_TRIA3:
+             case MED_TRIA6:
+               aNbNodes = 3;
+               break;
+               break;
+             case MED_QUAD4:
+             case MED_QUAD8:
+               aNbNodes = 4;
+                break;
+              case MED_TETRA4:
+             case MED_TETRA10:
+               aNbNodes = 4;
+               break;
+             case MED_PYRA5:
+             case MED_PYRA13:
+               aNbNodes = 5;
+               break;
+             case MED_PENTA6:
+             case MED_PENTA15:
+               aNbNodes = 6;
+               break;
+             case MED_HEXA8:
+             case MED_HEXA20:
+               aNbNodes = 8;
+               break;
+             }
+//           if(anIsElemNum)
+//             cout<<aCellInfo->GetElemNum(iElem)<<": ";
+//           else
+//             cout<<iElem<<": ";
+             vector<med_int> aNodeIds(aNbNodes);
+             for(int i = 0; i < aNbNodes; i++){
+               aNodeIds.at(i) = aCellInfo->GetConn(iElem,i);
+               //cout<<aNodeIds.at(i)<<", ";
+             }
+             //cout<<endl;
+
+             bool isRenum = false;
+             SMDS_MeshElement* anElement = NULL;
+             med_int aFamNum = aCellInfo->GetFamNum(iElem);
+             try{
+               switch(aGeom){
+               case MED_SEG2:
+               case MED_SEG3:
+                 if(anIsElemNum)
+                   anElement = myMesh->AddEdgeWithID(aNodeIds.at(0),
+                                                     aNodeIds.at(1),
+                                                     aCellInfo->GetElemNum(iElem));
+                 if (!anElement) {
+                   anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds.at(0)),
+                                               FindNode(myMesh,aNodeIds.at(1)));
+                   isRenum = anIsElemNum;
+                 }
+                 break;
+               case MED_TRIA3:
+               case MED_TRIA6:
+                 aNbNodes = 3;
+                 if(anIsElemNum)
+                   anElement = myMesh->AddFaceWithID(aNodeIds.at(0),
+                                                     aNodeIds.at(1),
+                                                     aNodeIds.at(2),
+                                                     aCellInfo->GetElemNum(iElem));
+                 if (!anElement) {
+                   anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds.at(0)),
+                                               FindNode(myMesh,aNodeIds.at(1)),
+                                               FindNode(myMesh,aNodeIds.at(2)));
+                   isRenum = anIsElemNum;
+                 }
+                 break;
+               case MED_QUAD4:
+               case MED_QUAD8:
+                 aNbNodes = 4;
+                 // There is some differnce between SMDS and MED
+                 if(anIsElemNum)
+                   anElement = myMesh->AddFaceWithID(aNodeIds.at(0),
+                                                     aNodeIds.at(1),
+                                                     aNodeIds.at(2),
+                                                     aNodeIds.at(3),
+                                                     aCellInfo->GetElemNum(iElem));
+                 if (!anElement) {
+                   anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds.at(0)),
+                                               FindNode(myMesh,aNodeIds.at(1)),
+                                               FindNode(myMesh,aNodeIds.at(2)),
+                                               FindNode(myMesh,aNodeIds.at(3)));
+                   isRenum = anIsElemNum;
+                 }
+                 break;
+               case MED_TETRA4:
+               case MED_TETRA10:
+                 aNbNodes = 4;
+                 if(anIsElemNum)
+                   anElement = myMesh->AddVolumeWithID(aNodeIds.at(0),
+                                                       aNodeIds.at(1),
+                                                       aNodeIds.at(2),
+                                                       aNodeIds.at(3),
+                                                       aCellInfo->GetElemNum(iElem));
+                 if (!anElement) {
+                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds.at(0)),
+                                                 FindNode(myMesh,aNodeIds.at(1)),
+                                                 FindNode(myMesh,aNodeIds.at(2)),
+                                                 FindNode(myMesh,aNodeIds.at(3)));
+                   isRenum = anIsElemNum;
+                 }
+                 break;
+               case MED_PYRA5:
+               case MED_PYRA13:
+                 aNbNodes = 5;
+                 // There is some differnce between SMDS and MED
+                 if(anIsElemNum)
+                   anElement = myMesh->AddVolumeWithID(aNodeIds.at(0),
+                                                       aNodeIds.at(1),
+                                                       aNodeIds.at(2),
+                                                       aNodeIds.at(3),
+                                                       aNodeIds.at(4),
+                                                       aCellInfo->GetElemNum(iElem));
+                 if (!anElement) {
+                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds.at(0)),
+                                                 FindNode(myMesh,aNodeIds.at(1)),
+                                                 FindNode(myMesh,aNodeIds.at(2)),
+                                                 FindNode(myMesh,aNodeIds.at(3)),
+                                                 FindNode(myMesh,aNodeIds.at(4)));
+                   isRenum = anIsElemNum;
+                 }
+                 break;
+               case MED_PENTA6:
+               case MED_PENTA15:
+                 aNbNodes = 6;
+                 if(anIsElemNum)
+                   anElement = myMesh->AddVolumeWithID(aNodeIds.at(0),
+                                                       aNodeIds.at(1),
+                                                       aNodeIds.at(2),
+                                                       aNodeIds.at(3),
+                                                       aNodeIds.at(4),
+                                                       aNodeIds.at(5),
+                                                       aCellInfo->GetElemNum(iElem));
+                 if (!anElement) {
+                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds.at(0)),
+                                                 FindNode(myMesh,aNodeIds.at(1)),
+                                                 FindNode(myMesh,aNodeIds.at(2)),
+                                                 FindNode(myMesh,aNodeIds.at(3)),
+                                                 FindNode(myMesh,aNodeIds.at(4)),
+                                                 FindNode(myMesh,aNodeIds.at(5)));
+                   isRenum = anIsElemNum;
+                 }
+                 break;
+               case MED_HEXA8:
+               case MED_HEXA20:
+                 aNbNodes = 8;
+                 if(anIsElemNum)
+                   anElement = myMesh->AddVolumeWithID(aNodeIds.at(0),
+                                                       aNodeIds.at(1),
+                                                       aNodeIds.at(2),
+                                                       aNodeIds.at(3),
+                                                       aNodeIds.at(4),
+                                                       aNodeIds.at(5),
+                                                       aNodeIds.at(6),
+                                                       aNodeIds.at(7),
+                                                       aCellInfo->GetElemNum(iElem));
+                 if (!anElement) {
+                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds.at(0)),
+                                                 FindNode(myMesh,aNodeIds.at(1)),
+                                                 FindNode(myMesh,aNodeIds.at(2)),
+                                                 FindNode(myMesh,aNodeIds.at(3)),
+                                                 FindNode(myMesh,aNodeIds.at(4)),
+                                                 FindNode(myMesh,aNodeIds.at(5)),
+                                                 FindNode(myMesh,aNodeIds.at(6)),
+                                                 FindNode(myMesh,aNodeIds.at(7)));
+                   isRenum = anIsElemNum;
+                 }
+                 break;
                }
+             }catch(const std::exception& exc){
+               //INFOS("Follow exception was cought:\n\t"<<exc.what());
+               result = DRS_FAIL;
+             }catch(...){
+               //INFOS("Unknown exception was cought !!!");
+               result = DRS_FAIL;
+             }
+               
+              if (!anElement) {
+                result = DRS_WARN_SKIP_ELEM;
+              }
+              else {
+                if (isRenum) {
+                  anIsElemNum = MED_FAUX;
+                  takeNumbers = false;
+                  if (result < DRS_WARN_RENUMBER)
+                    result = DRS_WARN_RENUMBER;
+                }
+                if (myFamilies.find(aFamNum) != myFamilies.end()) {
+                  // Save reference to this element from its family
+                  myFamilies[aFamNum]->AddElement(anElement);
+                  myFamilies[aFamNum]->SetType(anElement->GetType());
+                }
+              }
+            }
+         }
        }
+       break;
+      }
+    }
+  }catch(const std::exception& exc){
+    INFOS("Follow exception was cought:\n\t"<<exc.what());
+    result = DRS_FAIL;
+  }catch(...){
+    INFOS("Unknown exception was cought !!!");
+    result = DRS_FAIL;
+  }
+  MESSAGE("ReadMySelf - result status = "<<result);
+  return result;
+}
 
-       fprintf(stdout, "\n- Numeros des familles des noeuds : \n");
-       for (i = 0; i < nnoe; i++)
-               fprintf(stdout, " %d ", *(nufano + i));
-       fprintf(stdout, "\n");
-
-       /* liberation memoire */
-       free(coo);
-       free(nomnoe);
-       free(numnoe);
-       free(nufano);
-
-  /****************************************************************************
-  *                       LECTURE DES ELEMENTS                                *
-  ****************************************************************************/
-       fprintf(stdout, "\n(**************************)\n");
-       fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
-       fprintf(stdout, "(**************************)");
-       //fprintf(Out,"CELLS\n");
-       /* Lecture des connectivites, noms, numeros des mailles */
-       //printf("%d %d %d %d\n",nmailles[3],nmailles[4],nmailles[5],nmailles[9]);
-
-       if (ret == 0)
-               for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
-               {
-                       if (nmailles[i] > 0 && ret == 0)
-                       {
-                               /* dimension de la maille */
-                               edim = typmai[i] / 100;
-                               nsup = 0;
-                               if (mdim == 2 || mdim == 3)
-                                       if (edim == 1)
-                                               nsup = 1;
-                               if (mdim == 3)
-                                       if (edim == 2)
-                                               nsup = 1;
-
-                               taille = nsup + typmai[i] % 100;
-                               //taille = typmai[i]%100;
-
-                               /* allocation memoire */
-                               connectivite = (med_int *) malloc(sizeof(med_int) *
-                                       taille * nmailles[i]);
-                               nomele = (char *)malloc(sizeof(char) * MED_TAILLE_PNOM *
-                                       nmailles[i] + 1);
-                               numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
-                               nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
-
-                               /* lecture des données */
-                               ret =
-                                       MEDelementsLire(myFileId, nommaa, mdim, connectivite,
-                                       mode_coo, nomele, &inoele, numele, &inuele, nufael,
-                                       nmailles[i], MED_MAILLE, typmai[i], typ_con);
-
-                               switch (typmai[i])
-                               {
-                               case MED_TRIA3:
-                               {
-                                       if (inuele)
-                                       {
-                                               for (j = 0; j < nmailles[i]; j++)
-                                               {
-                                                       elem_id = *(numele + j);
-                                                       ok = mySMESHDSMesh->AddFaceWithID(*(connectivite +
-                                                                       j * (taille - nsup)),
-                                                               *(connectivite + j * (taille - nsup) + 1),
-                                                               *(connectivite + j * (taille - nsup) + 2),
-                                                               elem_id);
-                                                       //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2));
-                                               }
-                                       }
-                                       else
-                                       {
-                                               for (j = 0; j < nmailles[i]; j++)
-                                               {
-                                                       cmpt++;
-                                                       ok = mySMESHDSMesh->AddFaceWithID(*(connectivite +
-                                                                       j * (taille)),
-                                                               *(connectivite + j * (taille) + 1),
-                                                               *(connectivite + j * (taille) + 2), cmpt);
-                                                       //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2));
-                                               }
-                                       }
-
-                                       break;
-                               }
-                               case MED_QUAD4:
-                               {
-                                       if (inuele)
-                                       {
-                                               for (j = 0; j < nmailles[i]; j++)
-                                               {
-                                                       elem_id = *(numele + j);
-                                                       ok = mySMESHDSMesh->AddFaceWithID(*(connectivite +
-                                                                       j * (taille - nsup)),
-                                                               *(connectivite + j * (taille - nsup) + 1),
-                                                               *(connectivite + j * (taille - nsup) + 2),
-                                                               *(connectivite + j * (taille - nsup) + 3),
-                                                               elem_id);
-                                                       //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3));
-                                               }
-                                       }
-                                       else
-                                       {
-                                               for (j = 0; j < nmailles[i]; j++)
-                                               {
-                                                       cmpt++;
-                                                       ok = myMesh->AddFaceWithID(*(connectivite +
-                                                                       j * (taille)),
-                                                               *(connectivite + j * (taille) + 1),
-                                                               *(connectivite + j * (taille) + 2),
-                                                               *(connectivite + j * (taille) + 3), cmpt);
-                                                       //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3));
-                                               }
-                                       }
-                                       break;
-                               }
-                               case MED_TETRA4:
-                               {
-                                       if (inuele)
-                                       {
-                                               for (j = 0; j < nmailles[i]; j++)
-                                               {
-                                                       elem_id = *(numele + j);
-                                                       ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite +
-                                                                       j * (taille - nsup)),
-                                                               *(connectivite + j * (taille - nsup) + 1),
-                                                               *(connectivite + j * (taille - nsup) + 2),
-                                                               *(connectivite + j * (taille - nsup) + 3),
-                                                               elem_id);
-                                                       //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3));
-                                               }
-                                       }
-                                       else
-                                       {
-                                               for (j = 0; j < nmailles[i]; j++)
-                                               {
-                                                       cmpt++;
-                                                       ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite +
-                                                                       j * (taille)),
-                                                               *(connectivite + j * (taille) + 1),
-                                                               *(connectivite + j * (taille) + 2),
-                                                               *(connectivite + j * (taille) + 3), cmpt);
-                                                       //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3));
-                                               }
-                                       }
-                                       break;
-                               }
-                               case MED_HEXA8:
-                               {
-                                       if (inuele)
-                                       {
-                                               for (j = 0; j < nmailles[i]; j++)
-                                               {
-                                                       elem_id = *(numele + j);
-                                                       ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite +
-                                                                       j * (taille - nsup)),
-                                                               *(connectivite + j * (taille - nsup) + 1),
-                                                               *(connectivite + j * (taille - nsup) + 2),
-                                                               *(connectivite + j * (taille - nsup) + 3),
-                                                               *(connectivite + j * (taille - nsup) + 4),
-                                                               *(connectivite + j * (taille - nsup) + 5),
-                                                               *(connectivite + j * (taille - nsup) + 6),
-                                                               *(connectivite + j * (taille - nsup) + 7),
-                                                               elem_id);
-                                                       //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7));
-                                               }
-                                       }
-                                       else
-                                       {
-                                               for (j = 0; j < nmailles[i]; j++)
-                                               {
-                                                       cmpt++;
-                                                       ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite +
-                                                                       j * (taille)),
-                                                               *(connectivite + j * (taille) + 1),
-                                                               *(connectivite + j * (taille) + 2),
-                                                               *(connectivite + j * (taille) + 3),
-                                                               *(connectivite + j * (taille) + 4),
-                                                               *(connectivite + j * (taille) + 5),
-                                                               *(connectivite + j * (taille) + 6),
-                                                               *(connectivite + j * (taille) + 7), cmpt);
-                                                       //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7));
-                                               }
-                                       }
-                                       break;
-                               }
-                               default:
-                               {
-                                       break;
-                               }
-                               }
-
-                               fprintf(stdout, "\n  - Numéros de familles : \n");
-                               for (j = 0; j < nmailles[i]; j++)
-                                       fprintf(stdout, " %d ", *(nufael + j));
-
-                               /* liberation memoire */
-                               free(connectivite);
-                               free(nomele);
-                               free(numele);
-                               free(nufael);
-                       }
-               }
-
-  /****************************************************************************
-   *                       LECTURE DES FAMILLES                                *
-   ****************************************************************************/
-       printf("\n(*************************)\n");
-       printf("(* FAMILLES DU MAILLAGE : *)\n");
-       printf("(*************************)\n");
-       if (ret == 0)
-               for (i = 0; i < nfam; i++)
-               {
-
-                       /* nombre de groupes */
-                       ngro = MEDnFam(myFileId, nommaa, i + 1, MED_GROUPE);
-                       if (ngro < 0)
-                       {
-                               ret = -1;
-                               strcpy(message,
-                                       ">> ERREUR : lecture du nombre de groupes d'une famille \n");
-                       }
-
-                       /* nombre d'attributs */
-                       if (ret == 0)
-                       {
-                               natt = MEDnFam(myFileId, nommaa, i + 1, MED_ATTR);
-                               if (natt < 0)
-                               {
-                                       ret = -1;
-                                       strcpy(message,
-                                               ">> ERREUR : lecture du nombre d'attributs d'une famille\n");
-                               }
-                       }
-
-                       if (ret == 0)
-                               fprintf(stdout, "- Famille %d a %d attributs et %d groupes \n",
-                                       i + 1, natt, ngro);
-
-                       /* nom,numero,attributs,groupes */
-                       if (ret == 0)
-                       {
-                               attide = (med_int *) malloc(sizeof(med_int) * natt);
-                               attval = (med_int *) malloc(sizeof(med_int) * natt);
-                               attdes = (char *)malloc(MED_TAILLE_DESC * natt + 1);
-                               gro = (char *)malloc(MED_TAILLE_LNOM * ngro + 1);
-                               ret =
-                                       MEDfamInfo(myFileId, nommaa, i + 1, nomfam, &numfam, attide,
-                                       attval, attdes, &natt, gro, &ngro);
-
-                               fam = string(nomfam);
-                               fam_type = fam.substr(1, 1);
-                               fam_id = fam.substr(2, 1);
-                               if ((fam_type == string("V")) || (fam_type == string("A")) ||
-                                       (fam_type == string("F")))
-                                       LinkMeshToShape(fam_type, fam_id, family[i]);
-
-                               fprintf(stdout, "  - Famille de nom %s et de numero %d : \n",
-                                       nomfam, numfam);
-                               fprintf(stdout, "  - Attributs : \n");
-                               for (j = 0; j < natt; j++)
-                               {
-                                       strncpy(str1, attdes + j * MED_TAILLE_DESC,
-                                               MED_TAILLE_DESC);
-                                       str1[MED_TAILLE_DESC] = '\0';
-                                       fprintf(stdout, "   ide = %d - val = %d - des = %s\n",
-                                               *(attide + j), *(attval + j), str1);
-                               }
-                               free(attide);
-                               free(attval);
-                               free(attdes);
-                               fprintf(stdout, "  - Groupes :\n");
-                               for (j = 0; j < ngro; j++)
-                               {
-                                       strncpy(str2, gro + j * MED_TAILLE_LNOM, MED_TAILLE_LNOM);
-                                       str2[MED_TAILLE_LNOM] = '\0';
-                                       fprintf(stdout, "   gro = %s\n", str2);
-                               }
-                               free(gro);
-                       }
-               }
-
-       if (locally_managed)
-               ret = MEDfermer(myFileId);
-
+list<string> DriverMED_R_SMESHDS_Mesh::GetMeshNames()
+{
+  list<string> aMeshNames;
+
+  try {
+    using namespace MEDA;
+
+    MESSAGE("GetMeshNames - myFile : " << myFile);
+    TWrapper aMed (myFile);
+
+    if (med_int aNbMeshes = aMed.GetNbMeshes()) {
+      for (int iMesh = 0; iMesh < aNbMeshes; iMesh++) {
+       // Reading the MED mesh
+       //---------------------
+       PMeshInfo aMeshInfo = aMed.GetMeshInfo(iMesh);
+       aMeshNames.push_back(aMeshInfo->GetName());
+      }
+    }
+  }catch(const std::exception& exc){
+    INFOS("Follow exception was cought:\n\t"<<exc.what());
+  }catch(...){
+    INFOS("Unknown exception was cought !!!");
+  }
+
+  return aMeshNames;
 }
 
-void DriverMED_R_SMESHDS_Mesh::LinkMeshToShape(string fam_type, string fam_id,
-       vector < int >myNodes)
+list<string> DriverMED_R_SMESHDS_Mesh::GetGroupNames()
 {
+  list<string> aResult;
+  set<string> aResGroupNames;
+
+  map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
+  for (; aFamsIter != myFamilies.end(); aFamsIter++)
+  {
+    DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
+    const MED::TStringSet& aGroupNames = aFamily->GetGroupNames();
+    set<string>::iterator aGrNamesIter = aGroupNames.begin();
+    for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
+    {
+      string aName = *aGrNamesIter;
+      // Check, if this is a Group or SubMesh name
+//if (aName.substr(0, 5) == string("Group")) {
+        if (aResGroupNames.find(aName) == aResGroupNames.end()) {
+          aResGroupNames.insert(aName);
+          aResult.push_back(aName);
+        }
+//    }
+    }
+  }
+
+  return aResult;
+}
 
-       SMESHDS_Mesh * mySMESHDSMesh = dynamic_cast<SMESHDS_Mesh *>(myMesh);
+void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup)
+{
+  string aGroupName (theGroup->GetStoreName());
+  MESSAGE("Get Group " << aGroupName);
+
+  map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
+  for (; aFamsIter != myFamilies.end(); aFamsIter++)
+  {
+    DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
+    if (aFamily->MemberOf(aGroupName))
+    {
+      const set<const SMDS_MeshElement *>& anElements = aFamily->GetElements();
+      set<const SMDS_MeshElement *>::iterator anElemsIter = anElements.begin();
+      for (; anElemsIter != anElements.end(); anElemsIter++)
+      {
+        theGroup->SMDS_MeshGroup::Add(*anElemsIter);
+      }
+    }
+  }
+}
 
-       int id = atoi(fam_id.c_str());
-       if (fam_type == string("V"))
-       {                                                       //Linked to a vertex
-               for (int i = 0; i < myNodes.size(); i++)
-               {
-                       const SMDS_MeshNode * node = mySMESHDSMesh->FindNode(myNodes[i]);
-                       //const TopoDS_Vertex& S;//le recuperer !!!
-                       //mySMESHDSMesh->SetNodeOnVertex (node,S);
-               }
-       }
-       else if (fam_type == string("E"))
-       {                                                       //Linked to an edge
-               for (int i = 0; i < myNodes.size(); i++)
-               {
-                       const SMDS_MeshNode * node = mySMESHDSMesh->FindNode(myNodes[i]);
-                       //const TopoDS_Edge& S;//le recuperer !!!
-                       //mySMESHDSMesh->SetNodeOnEdge (node,S);
-               }
-       }
-       else if (fam_type == string("F"))
-       {                                                       //Linked to a face
-               for (int i = 0; i < myNodes.size(); i++)
-               {
-                       const SMDS_MeshNode * node = mySMESHDSMesh->FindNode(myNodes[i]);
-                       //const TopoDS_Face& S;//le recuperer !!!
-                       //mySMESHDSMesh->SetNodeOnFace (node,S);
-               }
-       }
+void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh,
+                                           const int theId)
+{
+  char submeshGrpName[ 30 ];
+  sprintf( submeshGrpName, "SubMesh %d", theId );
+  string aName (submeshGrpName);
+  map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
+  for (; aFamsIter != myFamilies.end(); aFamsIter++)
+  {
+    DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
+    if (aFamily->MemberOf(aName))
+    {
+      const set<const SMDS_MeshElement *>& anElements = aFamily->GetElements();
+      set<const SMDS_MeshElement *>::iterator anElemsIter = anElements.begin();
+      if (aFamily->GetType() == SMDSAbs_Node)
+      {
+        for (; anElemsIter != anElements.end(); anElemsIter++)
+        {
+          const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>(*anElemsIter);
+          theSubMesh->AddNode(node);
+        }
+      }
+      else
+      {
+        for (; anElemsIter != anElements.end(); anElemsIter++)
+        {
+          theSubMesh->AddElement(*anElemsIter);
+        }
+      }
+    }
+  }
+}
 
+void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes ()
+{
+  SMESHDS_Mesh* aSMESHDSMesh = dynamic_cast<SMESHDS_Mesh*>(myMesh);
+  if (!aSMESHDSMesh) {
+    EXCEPTION(runtime_error,"Can not cast SMDS_Mesh to SMESHDS_Mesh");
+  }
+  map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
+  for (; aFamsIter != myFamilies.end(); aFamsIter++)
+  {
+    DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
+    MED::TStringSet aGroupNames = aFamily->GetGroupNames();
+    set<string>::iterator aGrNamesIter = aGroupNames.begin();
+    for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
+    {
+      string aName = *aGrNamesIter;
+      // Check, if this is a Group or SubMesh name
+      if (aName.substr(0, 7) == string("SubMesh"))
+      {
+        int Id = atoi(string(aName).substr(7).c_str());
+        set<const SMDS_MeshElement *> anElements = aFamily->GetElements();
+        set<const SMDS_MeshElement *>::iterator anElemsIter = anElements.begin();
+        if (aFamily->GetType() == SMDSAbs_Node)
+        {
+          for (; anElemsIter != anElements.end(); anElemsIter++)
+          {
+            const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>(*anElemsIter);
+            aSMESHDSMesh->SetNodeInVolume(node, Id);
+//            aSMESHDSMesh->SetNodeOnFace(node, Id);
+//            aSMESHDSMesh->SetNodeOnEdge(node, Id);
+//            aSMESHDSMesh->SetNodeOnVertex(node, Id);
+          }
+        }
+        else
+        {
+          for (; anElemsIter != anElements.end(); anElemsIter++)
+          {
+            aSMESHDSMesh->SetMeshElementOnShape(*anElemsIter, Id);
+          }
+        }
+      }
+    }
+  }
 }
index 88ae5037c38682b51d8baa0a99296ab99ab65b5d..c592c30344b14a225795a7da96db379242dee7e9 100644 (file)
 
 #include "SMESHDS_Mesh.hxx"
 #include "Mesh_Reader.h"
+#include "DriverMED_Family.h"
 
-#include <vector>
+#include <list>
 extern "C"
 {
 #include <med.h>
 }
 
+using namespace std;
+
+class SMESHDS_Group;
+class SMESHDS_SubMesh;
+
 class DriverMED_R_SMESHDS_Mesh:public Mesh_Reader
 {
+ public:
+
+  DriverMED_R_SMESHDS_Mesh();
+  ~DriverMED_R_SMESHDS_Mesh();
+
+  enum ReadStatus {
+    DRS_OK,
+    DRS_EMPTY,          // a MED 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
+    DRS_FAIL            // general failure (exception etc.)
+  };
+
+  void Read();
+  ReadStatus ReadMySelf();
+  void Add();
 
-  public:DriverMED_R_SMESHDS_Mesh();
-       ~DriverMED_R_SMESHDS_Mesh();
+  list<string> GetGroupNames();
+  void GetGroup(SMESHDS_Group* theGroup);
+  void CreateAllSubMeshes();
+  void GetSubMesh(SMESHDS_SubMesh* theSubMesh, const int theId);
 
-       void Read();
-       void ReadMySelf();
-       void Add();
+  list<string> GetMeshNames();
 
-       void SetMesh(SMDS_Mesh * aMesh);
-       void SetFile(string);
-       void SetFileId(med_idt);
-       void SetMeshId(int);
+  void SetMesh(SMDS_Mesh * aMesh);
+  void SetFile(string);
+  void SetFileId(med_idt);
+  void SetMeshId(int);
+  void SetMeshName(string theMeshName);
 
-       void LinkMeshToShape(string, string, vector < int >);
+ private:
 
-  private:  SMDS_Mesh * myMesh;
-       string myFile;
-       med_idt myFileId;
-       int myMeshId;
+  SMDS_Mesh * myMesh;
+  string myFile;
+  med_idt myFileId;
+  int myMeshId;
+  string myMeshName;
+  map<int, DriverMED_FamilyPtr> myFamilies;
 
 };
 #endif
index fd6f3db753c5d320db6b7ad390e74dfc1353966c..eaa287e3b7cbd8a934dde1e10c5fc202c022f388 100644 (file)
@@ -207,7 +207,7 @@ void DriverMED_W_SMDS_Mesh::Write()
        for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
                nmailles[i] = 0;
 
-       SMDS_Iterator<const SMDS_MeshFace *> * itFaces=myMesh->facesIterator();
+       SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator();
        int nb_of_nodes, nb_of_faces;
        nb_of_faces = myMesh->NbFaces();
        //SCRUTE(nb_of_faces);
@@ -251,7 +251,7 @@ void DriverMED_W_SMDS_Mesh::Write()
 
        }
 
-       SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=myMesh->volumesIterator();
+       SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
        while(itVolumes->more())
        {
                const SMDS_MeshVolume * elem = itVolumes->next();
@@ -295,7 +295,7 @@ void DriverMED_W_SMDS_Mesh::Write()
        nomnoe = "";
 
        i = 0;
-       SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
+       SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator();
        while(itNodes->more())
        {               
                const SMDS_MeshNode * node = itNodes->next();
@@ -370,8 +370,7 @@ void DriverMED_W_SMDS_Mesh::Write()
                                        //elem_id=*(numele+j);
                                        //fprintf(stdout,"%d \n",myId);
 
-                                       SMDS_Iterator<const SMDS_MeshElement *> * itNode=
-                                               elem->nodesIterator();
+                                       SMDS_ElemIteratorPtr itNode= elem->nodesIterator();
 
                                        while(itNode->more())
                                        {
index 8459854360677b869d95fb1416372f2de5478849..eb6dd43a300b5f77b98da67206853422c7ea5897 100644 (file)
 //  File   : DriverMED_W_SMESHDS_Mesh.cxx
 //  Module : SMESH
 
-using namespace std;
 #include "DriverMED_W_SMESHDS_Mesh.h"
 #include "DriverMED_W_SMDS_Mesh.h"
+#include "DriverMED_Family.h"
+
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
-#include <TopExp.hxx>
-#include <vector>
 #include "utilities.h"
 
+#include "MEDA_Wrapper.hxx"
+#include <sstream>     
+
+#include "MED_Utilities.hxx"
+
 DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh()
+     :
+       myMesh (NULL),
+       myFile (""),
+       myFileId (-1),
+       myMeshId (-1),
+       myAllSubMeshes (false),
+       myDoGroupOfNodes (false),
+       myDoGroupOfEdges (false),
+       myDoGroupOfFaces (false),
+       myDoGroupOfVolumes (false)
 {
-       ;
 }
 
 DriverMED_W_SMESHDS_Mesh::~DriverMED_W_SMESHDS_Mesh()
 {
-       ;
 }
 
 void DriverMED_W_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
 {
-       myMesh = aMesh;
+  myMesh = aMesh;
 }
 
 void DriverMED_W_SMESHDS_Mesh::SetFile(string aFile)
 {
-       myFile = aFile;
+  myFile = aFile;
 }
 
 void DriverMED_W_SMESHDS_Mesh::SetFileId(med_idt aFileId)
 {
-       myFileId = aFileId;
+  myFileId = aFileId;
 }
 
 void DriverMED_W_SMESHDS_Mesh::SetMeshId(int aMeshId)
 {
-       myMeshId = aMeshId;
+  myMeshId = aMeshId;
 }
 
-void DriverMED_W_SMESHDS_Mesh::Write()
+void DriverMED_W_SMESHDS_Mesh::SetMeshName(string theMeshName)
 {
+  myMeshName = theMeshName;
+}
 
-       string myClass = string("SMDS_Mesh");
-       string myExtension = string("MED");
+void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_Group* theGroup)
+{
+  myGroups.push_back(theGroup);
+}
 
-       DriverMED_W_SMDS_Mesh *myWriter = new DriverMED_W_SMDS_Mesh;
+void DriverMED_W_SMESHDS_Mesh::AddAllSubMeshes()
+{
+  myAllSubMeshes = true;
+}
 
-       myWriter->SetMesh(myMesh);
-       //  myWriter->SetFile(myFile);
-       myWriter->SetMeshId(myMeshId);
-       myWriter->SetFileId(myFileId);
+void DriverMED_W_SMESHDS_Mesh::AddSubMesh(SMESHDS_SubMesh* theSubMesh, int theID)
+{
+  mySubMeshes[theID] = theSubMesh;
+}
 
-       myWriter->Write();
+void DriverMED_W_SMESHDS_Mesh::AddGroupOfNodes()
+{
+  myDoGroupOfNodes = true;
+}
 
+void DriverMED_W_SMESHDS_Mesh::AddGroupOfEdges()
+{
+  myDoGroupOfEdges = true;
 }
 
-void DriverMED_W_SMESHDS_Mesh::Add()
+void DriverMED_W_SMESHDS_Mesh::AddGroupOfFaces()
 {
+  myDoGroupOfFaces = true;
+}
 
-       med_err ret = 0;
-       int i, j, k, l;
-       int numero;
-       char message[200];
-       bool ok;
-       /* nombre d'objets MED */
-       char nom_universel[MED_TAILLE_LNOM + 1];
-       med_int long_fichier_en_tete;
-       char *fichier_en_tete;
-       char version_hdf[10];
-       char version_med[10];
-       med_int nmaa, mdim, nnoe;
-       med_int nmai[MED_NBR_GEOMETRIE_MAILLE], nfac[MED_NBR_GEOMETRIE_FACE];
-       med_int nare[MED_NBR_GEOMETRIE_ARETE];
-       /* nom du maillage */
-       char nommaa[MED_TAILLE_NOM + 1];
-       /* noeuds */
-       med_float *coo;
-       // PN : Initilialisation de nomcoo et unicoo pour lisibilite du maillage
-       char nomcoo[3 * MED_TAILLE_PNOM + 1] = "x       y        z      ";
-       char unicoo[3 * MED_TAILLE_PNOM + 1] = "m       m        m     ";
-       char *nomnoe;
-       med_int *numnoe;
-       med_int *nufano;
-       med_repere rep;
-       med_booleen inonoe, inunoe;
-       med_mode_switch mode_coo;
-       char str[MED_TAILLE_PNOM + 1];
-       med_int nbNodes;
-       /* elements */
-       med_int nsup;
-       med_int edim;
-       med_int taille;
-       med_int elem_id, myId;
-       med_int *connectivite;
-       char *nomele;
-       med_int *numele;
-       med_int *nufael;
-       med_booleen inoele, inuele;
-       med_connectivite typ_con;
-       med_geometrie_element typgeo;
-       med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] =
-               { MED_POINT1, MED_SEG2,
-               MED_SEG3, MED_TRIA3,
-               MED_TRIA6, MED_QUAD4,
-               MED_QUAD8, MED_TETRA4,
-               MED_TETRA10, MED_HEXA8,
-               MED_HEXA20, MED_PENTA6,
-               MED_PENTA15, MED_PYRA5,
-               MED_PYRA13
-       };
-       med_int desmai[MED_NBR_GEOMETRIE_MAILLE] =
-               { 0, 2, 3, 3, 3, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5 };
-       med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
-       char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1",
-               "MED_SEG2",
-               "MED_SEG3",
-               "MED_TRIA3",
-               "MED_TRIA6",
-               "MED_QUAD4",
-               "MED_QUAD8",
-               "MED_TETRA4",
-               "MED_TETRA10",
-               "MED_HEXA8",
-               "MED_HEXA20",
-               "MED_PENTA6",
-               "MED_PENTA15",
-               "MED_PYRA5",
-               "MED_PYRA13"
-       };
-       med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] =
-               { MED_TRIA3, MED_TRIA6,
-               MED_QUAD4, MED_QUAD8
-       };
-       med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 };
-       med_int nfaces[MED_NBR_GEOMETRIE_FACE];
-       char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM + 1] =
-               { "MED_TRIA3", "MED_TRIA6",
-               "MED_QUAD4", "MED_QUAD8"
-       };
-       med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] =
-               { MED_SEG2, MED_SEG3 };
-       med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 };
-       med_int naretes[MED_NBR_GEOMETRIE_ARETE];
-       char nomare[MED_NBR_GEOMETRIE_ARETE][MED_TAILLE_NOM + 1] =
-               { "MED_SEG2", "MED_SEG3" };
-
-       typ_con = MED_NOD;
-       mode_coo = MED_FULL_INTERLACE;
-       numero = myMeshId;
-
-       //---- provisoire : switch pour ecrire les familles de mailles
-       int besoinfamilledemaille = 1;
-       //---- provisoire : switch pour ecrire les familles de mailles
-
-  /****************************************************************************
-   *                      OUVERTURE DU FICHIER EN ECRITURE                    *
-   ****************************************************************************/
-       char *file2Read = (char *)myFile.c_str();
-
-       MESSAGE(" file2Read " << file2Read)
-               myFileId = MEDouvrir(file2Read, MED_REMP);
-       if (myFileId < 0)
-       {
-               fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
-               exit(EXIT_FAILURE);
-       }
+void DriverMED_W_SMESHDS_Mesh::AddGroupOfVolumes()
+{
+  myDoGroupOfVolumes = true;
+}
 
-  /****************************************************************************
-   *                       NOMBRES D'OBJETS MED                               *
-   ****************************************************************************/
-       MESSAGE("(****************************)");
-       MESSAGE("(* INFORMATIONS GENERALES : *)");
-       MESSAGE("(****************************)");
-
-       /* calcul de la dimension */
-       mdim = 2;
-       double epsilon = 0.00001;
-       double nodeRefX;
-       double nodeRefY;
-       double nodeRefZ;
-
-       bool dimX = true;
-       bool dimY = true;
-       bool dimZ = true;
-
-       int inode = 0;
-       SMDS_Iterator<const SMDS_MeshNode *> * myItNodes=myMesh->nodesIterator();
-       while(myItNodes->more())
-       {
-               const SMDS_MeshNode * node = myItNodes->next();
-               if (inode == 0)
-               {
-                       nodeRefX = fabs(node->X());
-                       nodeRefY = fabs(node->Y());
-                       nodeRefZ = fabs(node->Z());
-               }
-               SCRUTE(inode);
-               SCRUTE(nodeRefX);
-               SCRUTE(nodeRefY);
-               SCRUTE(nodeRefZ);
-
-               if (inode != 0)
-               {
-                       if ((fabs(fabs(node->X()) - nodeRefX) > epsilon) && dimX)
-                               dimX = false;
-                       if ((fabs(fabs(node->Y()) - nodeRefY) > epsilon) && dimY)
-                               dimY = false;
-                       if ((fabs(fabs(node->Z()) - nodeRefZ) > epsilon) && dimZ)
-                               dimZ = false;
-               }
-               if (!dimX && !dimY && !dimZ)
-               {
-                       mdim = 3;
-                       break;
-               }
-               inode++;
-       }
+void DriverMED_W_SMESHDS_Mesh::Write()
+{
+  string myClass = string("SMDS_Mesh");
+  string myExtension = string("MED");
 
-       if (mdim != 3)
-       {
-               if (dimX && dimY && dimZ)
-                       mdim = 0;
-               else if (!dimX)
-               {
-                       if (dimY && dimZ)
-                               mdim = 1;
-                       else if ((dimY && !dimZ) || (!dimY && dimZ))
-                               mdim = 2;
-               }
-               else if (!dimY)
-               {
-                       if (dimX && dimZ)
-                               mdim = 1;
-                       else if ((dimX && !dimZ) || (!dimX && dimZ))
-                               mdim = 2;
-               }
-               else if (!dimZ)
-               {
-                       if (dimY && dimX)
-                               mdim = 1;
-                       else if ((dimY && !dimX) || (!dimY && dimX))
-                               mdim = 2;
-               }
-       }
+  DriverMED_W_SMDS_Mesh *myWriter = new DriverMED_W_SMDS_Mesh;
 
-       MESSAGE(" mdim " << mdim);
-
-       /* creation du maillage */
-       //mdim=3;
-       sprintf(nommaa, "Mesh %d", numero);
-       SCRUTE(nommaa);
-       ret = MEDmaaCr(myFileId, nommaa, mdim);
-
-       ASSERT(ret == 0);
-       SCRUTE(ret);
-
-       /* Combien de noeuds ? */
-       nnoe = myMesh->NbNodes();
-       //SCRUTE(nnoe);
-       /* Combien de mailles, faces ou aretes ? */
-       for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
-               nmailles[i] = 0;
-
-       int nb_of_nodes, nb_of_faces, nb_of_edges;
-       vector < int >elem_Id[MED_NBR_GEOMETRIE_MAILLE];
-
-       nb_of_edges = myMesh->NbEdges();
-       SMDS_Iterator<const SMDS_MeshEdge *> * itEdges=myMesh->edgesIterator();
-       while(itEdges->more())
-       {
-               const SMDS_MeshEdge * elem = itEdges->next();
-
-               nb_of_nodes = elem->NbNodes();
-
-               switch (nb_of_nodes)
-               {
-               case 2:
-               {
-                       elem_Id[1].push_back(elem->GetID());
-                       nmailles[1]++;
-                       break;
-               }
-               case 3:
-               {
-                       elem_Id[2].push_back(elem->GetID());
-                       nmailles[2]++;
-                       break;
-               }
-               }
-       }
+  myWriter->SetMesh(myMesh);
+  //  myWriter->SetFile(myFile);
+  myWriter->SetMeshId(myMeshId);
+  myWriter->SetFileId(myFileId);
 
-       nb_of_faces = myMesh->NbFaces();
-       SMDS_Iterator<const SMDS_MeshFace *> * itFaces=myMesh->facesIterator();
-       while(itFaces->more())
-       {
-               const SMDS_MeshElement * elem = itFaces->next();
-
-               nb_of_nodes = elem->NbNodes();
-
-               switch (nb_of_nodes)
-               {
-               case 3:
-               {
-                       elem_Id[3].push_back(elem->GetID());
-                       nmailles[3]++;
-                       break;
-               }
-               case 4:
-               {
-                       elem_Id[5].push_back(elem->GetID());
-                       nmailles[5]++;
-                       break;
-               }
-               case 6:
-               {
-                       elem_Id[4].push_back(elem->GetID());
-                       nmailles[4]++;
-                       break;
-               }
-               }
+  myWriter->Write();
+}
 
+void DriverMED_W_SMESHDS_Mesh::Add()
+{
+  if (myMesh->hasConstructionEdges() || myMesh->hasConstructionFaces()) {
+    INFOS("SMDS_MESH with hasConstructionEdges() or hasConstructionFaces() do not supports!!!");
+    return;
+  }
+  try{
+    using namespace MEDA;
+    using namespace boost;
+
+    MESSAGE("Add - myFile : "<<myFile);
+    TWrapper aMed(myFile);
+
+    // Creating the MED mesh for corresponding SMDS structure
+    //-------------------------------------------------------
+    string aMeshName;
+    if (myMeshId != -1) {
+      ostringstream aMeshNameStr;
+      aMeshNameStr<<myMeshId;
+      aMeshName = aMeshNameStr.str();
+    } else {
+      aMeshName = myMeshName;
+    }
+    const int SMDS_MESH_DIM = 3;
+    PMeshInfo aMeshInfo = TWrapper::CrMeshInfo(SMDS_MESH_DIM,aMeshName);
+    MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
+    aMed.SetMeshInfo(aMeshInfo);
+
+    // Storing SMDS groups and sub-meshes
+    //-----------------------------------
+    int myNodesDefaultFamilyId = 0;
+    int myEdgesDefaultFamilyId = 0;
+    int myFacesDefaultFamilyId = 0;
+    int myVolumesDefaultFamilyId = 0;
+    if (myDoGroupOfNodes)
+      myNodesDefaultFamilyId = REST_NODES_FAMILY;
+    if (myDoGroupOfEdges)
+      myEdgesDefaultFamilyId = REST_EDGES_FAMILY;
+    if (myDoGroupOfFaces)
+      myFacesDefaultFamilyId = REST_FACES_FAMILY;
+    if (myDoGroupOfVolumes)
+      myVolumesDefaultFamilyId = REST_VOLUMES_FAMILY;
+
+    MESSAGE("Add - aFamilyInfo");
+    map<const SMDS_MeshElement *, int> anElemFamMap;
+    list<DriverMED_FamilyPtr> aFamilies;
+    if (myAllSubMeshes) {
+      SMESHDS_Mesh* aSMESHDSMesh = dynamic_cast<SMESHDS_Mesh*>(myMesh);
+      if (!aSMESHDSMesh) {
+        EXCEPTION(runtime_error,"Can not cast SMDS_Mesh to SMESHDS_Mesh");
+      }
+      aFamilies = DriverMED_Family::MakeFamilies
+        (aSMESHDSMesh->SubMeshes(), myGroups,
+         myDoGroupOfNodes, myDoGroupOfEdges, myDoGroupOfFaces, myDoGroupOfVolumes);
+    } else {
+      aFamilies = DriverMED_Family::MakeFamilies
+        (mySubMeshes, myGroups,
+         myDoGroupOfNodes, myDoGroupOfEdges, myDoGroupOfFaces, myDoGroupOfVolumes);
+    }
+    list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
+
+    for (; aFamsIter != aFamilies.end(); aFamsIter++)
+    {
+      PFamilyInfo aFamilyInfo = (*aFamsIter)->GetFamilyInfo(aMeshInfo);
+      aMed.SetFamilyInfo(aFamilyInfo);
+      int aFamId = (*aFamsIter)->GetId();
+
+      const set<const SMDS_MeshElement *>& anElems = (*aFamsIter)->GetElements();
+      set<const SMDS_MeshElement *>::iterator anElemsIter = anElems.begin();
+      for (; anElemsIter != anElems.end(); anElemsIter++)
+      {
+        anElemFamMap[*anElemsIter] = aFamId;
+      }
+//      delete (*aFamsIter);
+    }
+
+    // Storing SMDS nodes to the MED file for the MED mesh
+    //----------------------------------------------------
+    med_int aNbElems = myMesh->NbNodes();
+    MED::TIntVector anElemNums(aNbElems);
+    MED::TIntVector aFamilyNums(aNbElems);
+    MED::TFloatVector aCoordinates(aNbElems*SMDS_MESH_DIM);
+    SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator();
+    for(med_int iNode = 0, iCoord = 0; aNodesIter->more(); iNode++, iCoord+=SMDS_MESH_DIM){
+      const SMDS_MeshNode* aNode = aNodesIter->next();
+      aCoordinates[iCoord] = aNode->X();
+      aCoordinates[iCoord+1] = aNode->Y();
+      aCoordinates[iCoord+2] = aNode->Z();
+      anElemNums[iNode] = aNode->GetID();
+      //cout<<aNode->GetID()<<": "<<aNode->X()<<", "<<aNode->Y()<<", "<<aNode->Z()<<endl;
+
+      if (anElemFamMap.find(aNode) != anElemFamMap.end())
+        aFamilyNums[iNode] = anElemFamMap[aNode];
+      else
+        aFamilyNums[iNode] = myNodesDefaultFamilyId;
+    }
+
+    MED::TStringVector aCoordNames(3);
+    aCoordNames[0] = "x";  aCoordNames[1] = "y";  aCoordNames[2] = "z";
+
+    MED::TStringVector aCoordUnits(3);
+    aCoordUnits[0] = "m";  aCoordUnits[1] = "m";  aCoordUnits[2] = "m";
+
+    const med_repere SMDS_COORDINATE_SYSTEM = MED_CART;
+
+    PNodeInfo aNodeInfo = TWrapper::CrNodeInfo(aMeshInfo,
+                                              SMDS_COORDINATE_SYSTEM,
+                                              aCoordinates,
+                                              aCoordNames,
+                                              aCoordUnits,
+                                              aFamilyNums,
+                                              anElemNums);
+    MESSAGE("Add - aNodeInfo->GetNbElem() = "<<aNbElems);
+    aMed.SetNodeInfo(aNodeInfo);
+
+
+    // Storing others SMDS elements to the MED file for the MED mesh
+    //--------------------------------------------------------------
+    const med_entite_maillage SMDS_MED_ENTITY = MED_MAILLE;
+    const med_connectivite SMDS_MED_CONNECTIVITY = MED_NOD;
+
+    // Storing SMDS Edges
+    if(med_int aNbElems = myMesh->NbEdges()){
+      SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
+      med_int aNbConnectivity = MED::GetNbConn(SMDS_MED_ENTITY,MED_SEG2,SMDS_MESH_DIM);
+      MED::TIntVector anElemNums(aNbElems);
+      MED::TIntVector aFamilyNums(aNbElems);
+      MED::TIntVector aConnectivity(aNbElems*aNbConnectivity);
+
+      for(med_int iElem = 0, iConn = 0; anIter->more(); iElem++, iConn+=aNbConnectivity){
+       const SMDS_MeshEdge* anElem = anIter->next();
+       SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
+       for(med_int iNode = 0; iNode < aNbConnectivity && aNodesIter->more(); iNode++){
+         const SMDS_MeshElement* aNode = aNodesIter->next();
+         aConnectivity[iConn+iNode] = aNode->GetID();
        }
-
-       SMDS_Iterator<const SMDS_MeshVolume *> * itVolumes=myMesh->volumesIterator();
-       while(itVolumes->more())
-       {
-               const SMDS_MeshElement * elem = itVolumes->next();
-
-               nb_of_nodes = elem->NbNodes();
-               switch (nb_of_nodes)
-               {
-               case 8:
-               {
-                       elem_Id[9].push_back(elem->GetID());
-                       nmailles[9]++;
-                       break;
-               }
-               case 4 :
-               {
-                       elem_Id[7].push_back(elem->GetID());
-                       nmailles[7]++;
-                       break;
-               }
-               }
+       anElemNums[iElem] = anElem->GetID();
+       //cout<<anElem->GetID()<<": ";
+       //for(med_int iNode = 0; iNode < aNbNodes; iNode++) 
+       //  cout<<(*aConnectivity)[iConn+iNode]<<", ";
+       //cout<<endl;
+
+        if (anElemFamMap.find(anElem) != anElemFamMap.end())
+          aFamilyNums[iElem] = anElemFamMap[anElem];
+        else
+          aFamilyNums[iElem] = myEdgesDefaultFamilyId;
+      }
+      
+      PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
+                                                SMDS_MED_ENTITY,
+                                                MED_SEG2,
+                                                SMDS_MED_CONNECTIVITY,
+                                                aConnectivity,
+                                                aFamilyNums,
+                                                anElemNums);
+      aMed.SetCellInfo(aCellInfo);
+    }
+
+    // Storing SMDS Faces
+    if(med_int aNbElems = myMesh->NbFaces()){
+      SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
+
+      med_int aNbTriaConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_TRIA3,SMDS_MESH_DIM);
+      MED::TIntVector anTriaElemNums; 
+      anTriaElemNums.reserve(aNbElems);
+      MED::TIntVector aTriaFamilyNums;
+      aTriaFamilyNums.reserve(aNbElems);
+      MED::TIntVector aTriaConn;
+      aTriaConn.reserve(aNbElems*aNbTriaConn);
+
+      med_int aNbQuadConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_QUAD4,SMDS_MESH_DIM);
+      MED::TIntVector aQuadElemNums;
+      aQuadElemNums.reserve(aNbElems);
+      MED::TIntVector aQuadFamilyNums;
+      aQuadFamilyNums.reserve(aNbElems);
+      MED::TIntVector aQuadConn;
+      aQuadConn.reserve(aNbElems*aNbQuadConn);
+
+      for(med_int iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
+       const SMDS_MeshFace* anElem = anIter->next();
+       med_int aNbNodes = anElem->NbNodes();
+       SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
+       med_int aNbConnectivity;
+       MED::TIntVector* anElemNums;
+        MED::TIntVector* aFamilyNums;
+       MED::TIntVector* aConnectivity;
+       switch(aNbNodes){
+       case 3:
+         aNbConnectivity = aNbTriaConn;
+         anElemNums = &anTriaElemNums;
+         aFamilyNums = &aTriaFamilyNums;
+         aConnectivity = &aTriaConn;
+         break;
+       case 4:
+         aNbConnectivity = aNbQuadConn;
+         anElemNums = &aQuadElemNums;
+         aFamilyNums = &aQuadFamilyNums;
+         aConnectivity = &aQuadConn;
+         break;
        }
-
-  /****************************************************************************
-   *                       ECRITURE DES NOEUDS                                *
-   ****************************************************************************/
-       MESSAGE("(************************)");
-       MESSAGE("(* NOEUDS DU MAILLAGE : *)");
-       MESSAGE("(************************)");
-
-       /* Allocations memoires */
-       /* table des coordonnees
-        * profil : (dimension * nombre de noeuds ) */
-       coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim);
-       /* table  des numeros, des numeros de familles des noeuds
-        * profil : (nombre de noeuds) */
-       numnoe = (med_int *) malloc(sizeof(med_int) * nnoe);
-       nufano = (med_int *) malloc(sizeof(med_int) * nnoe);
-       /* table des noms des noeuds
-        * profil : (nnoe*MED_TAILLE_PNOM+1) */
-       nomnoe = "";
-
-       /* PN  pour aster, il faut une famille 0 pour les noeuds et une autre pour les elements */
-       /* PN : Creation de la famille 0 */
-       char *nomfam = "FAMILLE_0";
-       char *attdes = "";
-       char *gro = 0;
-       med_int ngro = 0;
-       med_int natt = 1;
-       med_int attide = 0;
-       med_int attval = 0;
-       med_int numfam = 0;
-       med_int attvalabs = 1;
-       ret =
-               MEDfamCr(myFileId, nommaa, nomfam, numfam, &attide, &attval, attdes,
-               natt, gro, ngro);
-       ASSERT(ret == 0);
-
-       /* PN : FIN Creation de la famille 0 */
-
-       map < int, int >mapNoeud;
-       typedef pair < set < int >::iterator, bool > IsFamily;
-       int nbFamillesNoeud;
-
-       i = 0;
-       set < int >FamilySet;
-       nbFamillesNoeud = 0;
-       int verifienbnoeuds = 0;
-       med_int *rien = 0;
-
-       SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
-       while(itNodes->more())
-       {
-               const SMDS_MeshNode * node = itNodes->next();
-
-               if (mdim == 3)
-               {
-                       coo[i * 3] = node->X();
-                       coo[i * 3 + 1] = node->Y();
-                       coo[i * 3 + 2] = node->Z();
-               }
-               else if (mdim == 2)
-               {
-                       if (dimX)
-                       {
-                               coo[i * 2] = node->Y();
-                               coo[i * 2 + 1] = node->Z();
-                       }
-                       if (dimY)
-                       {
-                               coo[i * 2] = node->X();
-                               coo[i * 2 + 1] = node->Z();
-                       }
-                       if (dimZ)
-                       {
-                               coo[i * 2] = node->X();
-                               coo[i * 2 + 1] = node->Y();
-                       }
-               }
-               else
-               {
-                       if (dimX)
-                       {
-                               coo[i * 2] = node->Y();
-                               coo[i * 2 + 1] = node->Z();
-                       }
-                       if (dimY)
-                       {
-                               coo[i * 2] = node->X();
-                               coo[i * 2 + 1] = node->Z();
-                       }
-                       if (dimZ)
-                       {
-                               coo[i * 2] = node->X();
-                               coo[i * 2 + 1] = node->Y();
-                       }
-               }
-               mapNoeud[node->GetID()] = i + 1;
-
-               // renvoie 0 pour les noeuds internes du volume
-               int numfamille = node->GetPosition()->GetShapeId();
-               nufano[i] = numfamille;
-
-               //SCRUTE(i);
-               //SCRUTE(nufano[i]);
-               //SCRUTE(coo[i*3]);
-               //SCRUTE(coo[i*3+1]);
-               //SCRUTE(coo[i*3+2]);
-               if (nufano[i] != 0)
-               {
-                       IsFamily deja = FamilySet.insert(nufano[i]);    // insert if new, or gives existant
-                       if (deja.second)        // actually inserted
-                       {
-                               char famille[MED_TAILLE_NOM + 1];
-                               sprintf(famille, "F%d", nufano[i]);
-                               //          CreateFamily(strdup(nommaa),strdup(famille),nufano[i],attvalabs++);
-                               attvalabs++;
-                               CreateFamily(strdup(nommaa), strdup(famille), nufano[i],
-                                       numfamille);
-                               //MESSAGE("---famille-noeud--- "<<nbFamillesNoeud<<" "<<nufano[i]);
-                               nbFamillesNoeud++;
-                       }
-               }
-
-               i++;
-               verifienbnoeuds++;
+       MED::TIntVector aVector(aNbNodes);
+       for(med_int iNode = 0; aNodesIter->more(); iNode++){
+         const SMDS_MeshElement* aNode = aNodesIter->next();
+         aVector[iNode] = aNode->GetID();
        }
-       ret = MEDnoeudsEcr(myFileId, nommaa, mdim, coo, mode_coo, MED_CART,
-               nomcoo, unicoo, nomnoe, MED_FAUX, rien, MED_FAUX,
-               nufano, nnoe, MED_REMP);
-       ASSERT(ret == 0);
-       MESSAGE("--- Creation de " << verifienbnoeuds << " noeuds");
-       ASSERT(verifienbnoeuds == nnoe);
-       MESSAGE("--- Creation de " << nbFamillesNoeud << " familles de noeuds");
-
-       /* liberation memoire */
-       free(coo);
-       free(numnoe);
-       free(nufano);
-
-  /****************************************************************************
-   *                       ECRITURE DES ELEMENTS                              *
-   ****************************************************************************/
-       MESSAGE("(**************************)");
-       MESSAGE("(* ELEMENTS DU MAILLAGE : *)");
-       MESSAGE("(**************************)");
-
-       /* Ecriture des connectivites, noms, numeros des mailles */
-
-       if (ret == 0)
-       {
-               int nbFamillesElts = 0;
-               SMESHDS_Mesh * mySMESHDSMesh = dynamic_cast<SMESHDS_Mesh *>(myMesh);
-               TopTools_IndexedMapOfShape myIndexToShape;
-               TopExp::MapShapes(mySMESHDSMesh->ShapeToMesh(), myIndexToShape);
-
-               map<int,int> mapFamille;
-
-               if (besoinfamilledemaille == 1)
-               {
-                       int t;
-                       for (t = 1; t <= myIndexToShape.Extent(); t++)
-                       {
-                               const TopoDS_Shape S = myIndexToShape(t);
-                               if (mySMESHDSMesh->HasMeshElements(S))
-                               {
-                                       //MESSAGE ("********* Traitement de la Famille "<<-t);
-
-                                       SMESHDS_SubMesh * SM = mySMESHDSMesh->MeshElements(S);
-                                       SMDS_Iterator<const SMDS_MeshElement*> * ite=SM->GetElements();
-                                       bool plein = false;
-                                       while(ite->more())
-                                       {
-                                               mapFamille[ite->next()->GetID()] = -t;
-                                               plein = true;
-                                       }
-                                       if (plein)
-                                       {
-                                               nbFamillesElts++;
-                                               char famille[MED_TAILLE_NOM + 1];
-                                               sprintf(famille, "E%d", t);
-                                               CreateFamily(strdup(nommaa), strdup(famille), -t,
-                                                       attvalabs++);
-                                       }
-                               }
-                       }
-               }
-
-               int indice = 1;
-               for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
-               {
-                       if (nmailles[i] > 0 && ret == 0)
-                       {
-                               MESSAGE(" Start " << typmai[i]);
-
-                               /* dimension de la maille */
-                               edim = typmai[i] / 100;
-                               nsup = 0;
-                               if (mdim == 2 || mdim == 3)
-                                       if (edim == 1)
-                                               nsup = 1;
-                               if (mdim == 3)
-                                       if (edim == 2)
-                                               nsup = 1;
-                               //SCRUTE(nsup);
-
-                               taille = nsup + typmai[i] % 100;
-                               //SCRUTE(taille);
-
-                               /* allocation memoire */
-                               connectivite =
-                                       (med_int *) malloc(sizeof(med_int) * taille * nmailles[i]);
-                               /* nomele =
-                                       (char *)malloc(sizeof(char) * MED_TAILLE_PNOM *
-                                       nmailles[i] + 1);*/
-                               nomele = "";
-                               numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
-                               nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
-                               nbNodes = typmai[i] % 100;
-
-                               for (j = 0; j < nmailles[i]; j++)
-                               {
-                                       myId = elem_Id[i][j];
-                                       const SMDS_MeshElement * elem =
-                                               myMesh->FindElement(myId);
-                                       //*(numele+j) = myId;
-                                       *(numele + j) = indice++;
-
-                                       SMDS_Iterator<const SMDS_MeshElement *> * itk=elem->nodesIterator();
-                                       for (k = 0; itk->more(); k++)
-                                       {
-                                               *(connectivite + j * taille + k) =
-                                                       mapNoeud[itk->next()->GetID()];
-                                       }
-                                       delete itk;
-
-                                       if (nsup)
-                                               *(connectivite + j * taille + nbNodes) = 0;
-
-                                       if (besoinfamilledemaille == 1)
-                                       {
-                                               if (mapFamille.find(myId) != mapFamille.end())
-                                               {
-                                                       nufael[j] = mapFamille[myId];
-                                               }
-                                               else
-                                               {
-                                                       nufael[j] = 0;
-                                               }
-                                       }
-                                       else
-                                       {
-                                               nufael[j] = 0;
-                                       }
-
-                                       //SCRUTE(myId);
-                                       //SCRUTE(j);
-                                       //SCRUTE(nufael[j]);
-                               }
-
-                               /* ecriture des données */
-
-                               med_int *rien = 0;
-                               ret =
-                                       MEDelementsEcr(myFileId, nommaa, mdim, connectivite,
-                                       mode_coo, nomele, MED_FAUX, numele, MED_VRAI, nufael,
-                                       nmailles[i], MED_MAILLE, typmai[i], typ_con, MED_REMP);
-                               ASSERT(ret == 0);
-                               //SCRUTE(ret);
-
-                               if (ret < 0)
-                                       MESSAGE(">> ERREUR : ecriture des mailles \n");
-
-                               /* liberation memoire */
-                               free(connectivite);
-                               free(numele);
-                               free(nufael);
-                               MESSAGE(" End " << typmai[i]);
-                       }
-               };
-               MESSAGE("--- Creation de " << nbFamillesElts << " familles d elements");
 
+       med_int aSize = aConnectivity->size();
+       aConnectivity->resize(aSize+aNbConnectivity);
+       // There is some differnce between SMDS and MED in cells mapping
+       switch(aNbNodes){
+       case 4:
+         (*aConnectivity)[aSize+0] = aVector[0];
+         (*aConnectivity)[aSize+1] = aVector[1];
+         (*aConnectivity)[aSize+2] = aVector[3];  
+         (*aConnectivity)[aSize+3] = aVector[2];  
+       default:
+         for(med_int iNode = 0; iNode < aNbNodes; iNode++) 
+           (*aConnectivity)[aSize+iNode] = aVector[iNode];
+       }
+       anElemNums->push_back(anElem->GetID());
+       //cout<<anElem->GetID()<<": ";
+       //for(med_int iNode = 0; iNode < aNbNodes; iNode++) 
+       //  cout<<(*aConnectivity)[aSize+iNode]<<", ";
+       //cout<<endl;
+
+        if (anElemFamMap.find(anElem) != anElemFamMap.end())
+          aFamilyNums->push_back(anElemFamMap[anElem]);
+        else
+          aFamilyNums->push_back(myFacesDefaultFamilyId);
+      }
+      if(med_int aNbElems = anTriaElemNums.size()){
+       PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
+                                                  SMDS_MED_ENTITY,
+                                                  MED_TRIA3,
+                                                  SMDS_MED_CONNECTIVITY,
+                                                  aTriaConn,
+                                                  aTriaFamilyNums,
+                                                  anTriaElemNums);
+       MESSAGE("Add - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_TRIA3<<"; aNbElems = "<<aNbElems);
+       aMed.SetCellInfo(aCellInfo);
+      }
+      if(med_int aNbElems = aQuadElemNums.size()){
+       PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
+                                                  SMDS_MED_ENTITY,
+                                                  MED_QUAD4,
+                                                  SMDS_MED_CONNECTIVITY,
+                                                  aQuadConn,
+                                                  aQuadFamilyNums,
+                                                  aQuadElemNums);
+       MESSAGE("Add - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_QUAD4<<"; aNbElems = "<<aNbElems);
+       aMed.SetCellInfo(aCellInfo);
+      }
+    }
+
+    // Storing SMDS Volumes
+    if(med_int aNbElems = myMesh->NbVolumes()){
+      SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
+
+      med_int aNbTetraConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_TETRA4,SMDS_MESH_DIM);
+      MED::TIntVector anTetraElemNums; 
+      anTetraElemNums.reserve(aNbElems);
+      MED::TIntVector aTetraFamilyNums;
+      aTetraFamilyNums.reserve(aNbElems);
+      MED::TIntVector aTetraConn;
+      aTetraConn.reserve(aNbElems*aNbTetraConn);
+
+      med_int aNbPyraConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_PYRA5,SMDS_MESH_DIM);
+      MED::TIntVector anPyraElemNums; 
+      anPyraElemNums.reserve(aNbElems);
+      MED::TIntVector aPyraFamilyNums;
+      aPyraFamilyNums.reserve(aNbElems);
+      MED::TIntVector aPyraConn;
+      aPyraConn.reserve(aNbElems*aNbPyraConn);
+
+      med_int aNbPentaConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_PENTA6,SMDS_MESH_DIM);
+      MED::TIntVector anPentaElemNums; 
+      anPentaElemNums.reserve(aNbElems);
+      MED::TIntVector aPentaFamilyNums;
+      aPentaFamilyNums.reserve(aNbElems);
+      MED::TIntVector aPentaConn;
+      aPentaConn.reserve(aNbElems*aNbPentaConn);
+
+      med_int aNbHexaConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_HEXA8,SMDS_MESH_DIM);
+      MED::TIntVector aHexaElemNums;
+      aHexaElemNums.reserve(aNbElems);
+      MED::TIntVector aHexaFamilyNums;
+      aHexaFamilyNums.reserve(aNbElems);
+      MED::TIntVector aHexaConn;
+      aHexaConn.reserve(aNbElems*aNbHexaConn);
+
+      for(med_int iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
+       const SMDS_MeshVolume* anElem = anIter->next();
+       med_int aNbNodes = anElem->NbNodes();
+       SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
+       med_int aNbConnectivity;
+       MED::TIntVector* anElemNums;
+       MED::TIntVector* aFamilyNums;
+       MED::TIntVector* aConnectivity;
+       switch(aNbNodes){
+       case 4:
+         aNbConnectivity = aNbTetraConn;
+         anElemNums = &anTetraElemNums;
+         aFamilyNums = &aTetraFamilyNums;
+         aConnectivity = &aTetraConn;
+         break;
+       case 5:
+         aNbConnectivity = aNbPyraConn;
+         anElemNums = &anPyraElemNums;
+         aFamilyNums = &aPyraFamilyNums;
+         aConnectivity = &aPyraConn;
+         break;
+       case 6:
+         aNbConnectivity = aNbPentaConn;
+         anElemNums = &anPentaElemNums;
+         aFamilyNums = &aPentaFamilyNums;
+         aConnectivity = &aPentaConn;
+         break;
+       case 8:
+         aNbConnectivity = aNbHexaConn;
+         anElemNums = &aHexaElemNums;
+         aFamilyNums = &aHexaFamilyNums;
+         aConnectivity = &aHexaConn;
        }
 
-         /****************************************************************************
-      *                      FERMETURE DU FICHIER                                *
-      ****************************************************************************/
-
-       ret = MEDfermer(myFileId);
-
-       if (ret != 0)
-               fprintf(stderr, ">> ERREUR : erreur a la fermeture du fichier %s\n",
-                       file2Read);
-       MESSAGE("fichier ferme");
-
-}
-
-void DriverMED_W_SMESHDS_Mesh::CreateFamily(char *nommaa, char *famille, int i,
-       med_int k)
-{
-
-       med_int ngro = 0;
-       med_int natt;
-
-       natt = 1;
-       char attdes[MED_TAILLE_DESC + 1];
-       char gro[MED_TAILLE_LNOM + 1];
-       char fam2[MED_TAILLE_LNOM + 1];
-
-       strcpy(attdes, "");
-       strcpy(gro, "");
-       strcpy(fam2, famille);
-
-       med_int *attide = new med_int[1];
-       med_int *attval = new med_int[1];
-       attide[0] = k;
-       attval[0] = k;
-
-       //MESSAGE("-------- Creation de la Famille : "<< famille << "numero " << i << " --------------");
-       med_int ret =
-               MEDfamCr(myFileId, nommaa, fam2, i, attide, attval, attdes, natt, gro,
-               ngro);
-       ASSERT(ret == 0);
-       delete[]attide;
-       delete[]attval;
-
+       MED::TIntVector aVector(aNbNodes);
+       for(med_int iNode = 0; aNodesIter->more(); iNode++){
+         const SMDS_MeshElement* aNode = aNodesIter->next();
+         aVector[iNode] = aNode->GetID();
+       }
+       med_int aSize = aConnectivity->size();
+       aConnectivity->resize(aSize+aNbConnectivity);
+       // There is some difference between SMDS and MED in cells mapping
+       switch(aNbNodes){
+       case 5:
+         (*aConnectivity)[aSize+0] = aVector[0];
+         (*aConnectivity)[aSize+1] = aVector[3];
+         (*aConnectivity)[aSize+2] = aVector[2];  
+         (*aConnectivity)[aSize+3] = aVector[1];  
+         (*aConnectivity)[aSize+4] = aVector[4];  
+       default:
+         for(med_int iNode = 0; iNode < aNbNodes; iNode++) 
+           (*aConnectivity)[aSize+iNode] = aVector[iNode];
+       }
+       anElemNums->push_back(anElem->GetID());
+
+        if (anElemFamMap.find(anElem) != anElemFamMap.end())
+          aFamilyNums->push_back(anElemFamMap[anElem]);
+        else
+          aFamilyNums->push_back(myVolumesDefaultFamilyId);
+      }
+
+      if(med_int aNbElems = anTetraElemNums.size()){
+       PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
+                                                  SMDS_MED_ENTITY,
+                                                  MED_TETRA4,
+                                                  SMDS_MED_CONNECTIVITY,
+                                                  aTetraConn,
+                                                  aTetraFamilyNums,
+                                                  anTetraElemNums);
+       MESSAGE("Add - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_TETRA4<<"; aNbElems = "<<aNbElems);
+       aMed.SetCellInfo(aCellInfo);
+      }
+      if(med_int aNbElems = anPyraElemNums.size()){
+       PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
+                                                  SMDS_MED_ENTITY,
+                                                  MED_PYRA5,
+                                                  SMDS_MED_CONNECTIVITY,
+                                                  aPyraConn,
+                                                  aPyraFamilyNums,
+                                                  anPyraElemNums);
+       MESSAGE("Add - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_PYRA5<<"; aNbElems = "<<aNbElems);
+       aMed.SetCellInfo(aCellInfo);
+      }
+      if(med_int aNbElems = anPentaElemNums.size()){
+       PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
+                                                  SMDS_MED_ENTITY,
+                                                  MED_PENTA6,
+                                                  SMDS_MED_CONNECTIVITY,
+                                                  aPentaConn,
+                                                  aPentaFamilyNums,
+                                                  anPentaElemNums);
+       MESSAGE("Add - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_PENTA6<<"; aNbElems = "<<aNbElems);
+       aMed.SetCellInfo(aCellInfo);
+      }
+      if(med_int aNbElems = aHexaElemNums.size()){
+       PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
+                                                  SMDS_MED_ENTITY,
+                                                  MED_HEXA8,
+                                                  SMDS_MED_CONNECTIVITY,
+                                                  aHexaConn,
+                                                  aHexaFamilyNums,
+                                                  aHexaElemNums);
+       MESSAGE("Add - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_HEXA8<<"; aNbElems = "<<aNbElems);
+       aMed.SetCellInfo(aCellInfo);
+      }
+    }
+  }catch(const std::exception& exc){
+    INFOS("Follow exception was cought:\n\t"<<exc.what());
+  }catch(...){
+    INFOS("Unknown exception was cought !!!");
+  }
+
+  myMeshId = -1;
+  myGroups.clear();
+  mySubMeshes.clear();
 }
index 6ce4b2afa4e67eaaabae45c7e9c0b30a39714bf3..df91d0d4955b046fe08e29962b46d6cba4be7bca 100644 (file)
 #include "Mesh_Writer.h"
 
 #include <string>
+#include <list>
+#include <map>
 
 extern "C"
 {
 #include <med.h>
 }
 
+using namespace std;
+
+class SMESHDS_Group;
+class SMESHDS_SubMesh;
+
 class DriverMED_W_SMESHDS_Mesh:public Mesh_Writer
 {
+  public:
 
-  public:DriverMED_W_SMESHDS_Mesh();
-       ~DriverMED_W_SMESHDS_Mesh();
+  DriverMED_W_SMESHDS_Mesh();
+  ~DriverMED_W_SMESHDS_Mesh();
 
-       void Add();
-       void Write();
-       void SetMesh(SMDS_Mesh * aMesh);
-       void SetFile(string);
+  /*! sets file name; only for usage with Add(), not Write()
+   */
+  void SetFile(string);
+  void AddGroupOfNodes();
+  void AddGroupOfEdges();
+  void AddGroupOfFaces();
+  void AddGroupOfVolumes();
 
-       void SetFileId(med_idt);
-       void SetMeshId(int);
+  /*! functions to prepare adding one mesh
+   */
+  void SetMesh(SMDS_Mesh * aMesh);
+  void SetMeshId(int);
+  void SetMeshName(string theMeshName);
+  void AddGroup(SMESHDS_Group* theGroup);
+  void AddAllSubMeshes();
+  void AddSubMesh(SMESHDS_SubMesh* theSubMesh, int theID);
 
-       void CreateFamily(char *, char *, int, med_int);
+  /*! add one mesh
+   */
+  void Add();
 
-  private:  SMDS_Mesh * myMesh;
-       string myFile;
-       med_idt myFileId;
-       int myMeshId;
+  /*! functions to write via DriverMED_W_SMDS_Mesh (no groups)
+   */
+  void SetFileId(med_idt);
+  void Write();
 
+ private:
+
+  SMDS_Mesh * myMesh;
+  string myFile;
+  med_idt myFileId;
+  int myMeshId;
+  string myMeshName;
+  list<SMESHDS_Group*> myGroups;
+  bool myAllSubMeshes;
+  map<int,SMESHDS_SubMesh*> mySubMeshes;
+  bool myDoGroupOfNodes;
+  bool myDoGroupOfEdges;
+  bool myDoGroupOfFaces;
+  bool myDoGroupOfVolumes;
 };
 #endif
+
index 4217426f55b76b664899c84a793badc04e3caf3a..18d72045c440fd9676e0bb7b704b47302ee6c2a0 100644 (file)
@@ -35,7 +35,10 @@ VPATH=.:@srcdir@
 @COMMENCE@
 
 # header files 
-EXPORT_HEADERS= DriverMED_R_SMDS_Mesh.h DriverMED_R_SMESHDS_Mesh.h DriverMED_R_SMESHDS_Document.h DriverMED_W_SMDS_Mesh.h DriverMED_W_SMESHDS_Mesh.h DriverMED_W_SMESHDS_Document.h 
+EXPORT_HEADERS = \
+       DriverMED_R_SMDS_Mesh.h DriverMED_R_SMESHDS_Mesh.h DriverMED_R_SMESHDS_Document.h \
+       DriverMED_W_SMDS_Mesh.h DriverMED_W_SMESHDS_Mesh.h DriverMED_W_SMESHDS_Document.h \
+       DriverMED_Family.h
 
 # Libraries targets
 LIB = libMeshDriverMED.la
@@ -45,15 +48,16 @@ LIB_SRC = \
        DriverMED_R_SMESHDS_Document.cxx \
        DriverMED_W_SMDS_Mesh.cxx \
        DriverMED_W_SMESHDS_Document.cxx \
-       DriverMED_W_SMESHDS_Mesh.cxx
+       DriverMED_W_SMESHDS_Mesh.cxx \
+       DriverMED_Family.cxx
 
 LIB_CLIENT_IDL =
 LIB_SERVER_IDL =
 
 # additionnal information to compil and link file
-CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
 CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
-LDFLAGS  += $(MED2_LIBS) -lMeshDriver -lmed
+LDFLAGS  += $(MED2_LIBS) -lMeshDriver -L${KERNEL_ROOT_DIR}/lib/salome -lMEDWrapper
 
 %_moc.cxx: %.h
        $(MOC) $< -o $@
index 01b112baa9058f229e1371eecd8ba304920722b8..80c02b4614bb247213309b0a6a30562de271f4d2 100644 (file)
@@ -101,7 +101,7 @@ void DriverUNV_W_SMDS_Mesh::Write()
        fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
        fprintf(myFileId, "%s\n", sNODE_UNV_ID);
 
-       SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
+       SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator();
        while(itNodes->more())
        {
                const SMDS_MeshNode * node = itNodes->next();
@@ -110,7 +110,6 @@ void DriverUNV_W_SMDS_Mesh::Write()
                fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(),
                        node->Z());
        }
-       delete itNodes;
        fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
 
   /****************************************************************************
@@ -124,11 +123,11 @@ void DriverUNV_W_SMDS_Mesh::Write()
        fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
        fprintf(myFileId, "%s\n", sELT_UNV_ID);
 
-       SMDS_Iterator<const SMDS_MeshEdge *> * itEdges=myMesh->edgesIterator();
+       SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator();
        while(itEdges->more())
        {
                const SMDS_MeshElement * elem = itEdges->next();
-               SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
+               SMDS_ElemIteratorPtr itn=elem->nodesIterator();
 
                switch (elem->NbNodes())
                {
@@ -149,11 +148,9 @@ void DriverUNV_W_SMDS_Mesh::Write()
 
                        break;
                }
-               delete itn;
        }
-       delete itEdges;
 
-       SMDS_Iterator<const SMDS_MeshFace*> * itFaces=myMesh->facesIterator();
+       SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator();
        while(itFaces->more())
        {
                const SMDS_MeshElement * elem = itFaces->next();
@@ -184,15 +181,13 @@ void DriverUNV_W_SMDS_Mesh::Write()
                        fprintf(myFileId, "element not registered\n");
                }
 
-               SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
+               SMDS_ElemIteratorPtr itn=elem->nodesIterator();
                while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID());
-               delete itn;
 
                fprintf(myFileId, "\n");
        }
-       delete itFaces;
 
-       SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=myMesh->volumesIterator();
+       SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
        while(itVolumes->more())
        {
                const SMDS_MeshElement * elem = itVolumes->next();
@@ -216,13 +211,11 @@ void DriverUNV_W_SMDS_Mesh::Write()
                        break;
                }
 
-               SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
+               SMDS_ElemIteratorPtr itn=elem->nodesIterator();
                while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID());
-               delete itn;
 
                fprintf(myFileId, "\n");
        }
-       delete itVolumes;
 
        fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
 
index 2923f9fa561780af10d8eccb9a076f8c2c0d09df..905eed9ca1acfea533183380609c7dacfd3376f0 100644 (file)
@@ -112,7 +112,7 @@ void DriverUNV_W_SMESHDS_Mesh::Add()
        fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
        fprintf(myFileId, "%s\n", sNODE_UNV_ID);
 
-       SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
+       SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator();
        while(itNodes->more())
        {
                const SMDS_MeshNode * node = itNodes->next(); 
@@ -121,7 +121,6 @@ void DriverUNV_W_SMESHDS_Mesh::Add()
                fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(),
                        node->Z());
        }
-       delete itNodes;
        fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
 
   /****************************************************************************
@@ -135,11 +134,11 @@ void DriverUNV_W_SMESHDS_Mesh::Add()
        fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
        fprintf(myFileId, "%s\n", sELT_UNV_ID);
 
-       SMDS_Iterator<const SMDS_MeshEdge *> * itEdges=myMesh->edgesIterator();
+       SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator();
        while(itEdges->more())
        {
                const SMDS_MeshEdge * elem = itEdges->next();
-               SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
+               SMDS_ElemIteratorPtr itn=elem->nodesIterator();
 
                switch (elem->NbNodes())
                {
@@ -159,11 +158,9 @@ void DriverUNV_W_SMESHDS_Mesh::Add()
                                itn->next()->GetID(), itn->next()->GetID());
                        break;
                }
-               delete itn;
        }
-       delete itEdges;
 
-       SMDS_Iterator<const SMDS_MeshFace*> * itFaces=myMesh->facesIterator();
+       SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator();
        while(itFaces->more())
        {
                const SMDS_MeshElement * elem = itFaces->next();
@@ -194,15 +191,13 @@ void DriverUNV_W_SMESHDS_Mesh::Add()
                        fprintf(myFileId, "element not registered\n");
                }
 
-               SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
+               SMDS_ElemIteratorPtr itn=elem->nodesIterator();
                while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID());
-               delete itn;
 
                fprintf(myFileId, "\n");
        }
-       delete itFaces;
 
-       SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=myMesh->volumesIterator();
+       SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
        while(itVolumes->more())
        {
                const SMDS_MeshElement * elem = itVolumes->next();
@@ -226,13 +221,11 @@ void DriverUNV_W_SMESHDS_Mesh::Add()
                        break;
                }
 
-               SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
+               SMDS_ElemIteratorPtr itn=elem->nodesIterator();
                while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID());
-               delete itn;
 
                fprintf(myFileId, "\n");
        }
-       delete itVolumes;
        fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
 
        fclose(myFileId);
index cfb048787a595a60312f5cc88faefb6cf178b010..038ab87f186e8e55e774e709d3480fcf95610597 100644 (file)
@@ -53,7 +53,7 @@ LIB_CLIENT_IDL =
 LIB_SERVER_IDL =
 
 # additionnal information to compil and link file
-CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
 CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
 LDFLAGS  += $(MED2_LIBS) -lMeshDriver
 
index c3dd0dc5efbc6aa71beb0196b807a28b8688d969..0527a7abef6fc47729b63cccb21342d468a9047d 100644 (file)
@@ -31,14 +31,9 @@ VPATH=.:@srcdir@
 
 @COMMENCE@
 
-SUBDIRS = OBJECT SMDS SMESHDS Driver DriverMED DriverDAT DriverUNV MEFISTO2 \
-       SMESH SMESH_I SMESHFiltersSelection SMESHGUI \
-       SMESH_SWIG
-
-ifeq (@WITHNETGEN@,yes)
-SUBDIRS = OBJECT SMDS SMESHDS Driver DriverMED DriverDAT DriverUNV MEFISTO2 \
-       NETGEN SMESH SMESH_I SMESHFiltersSelection SMESHGUI \
-       SMESH_SWIG
-endif
+SUBDIRS = \
+       SMDS SMESHDS Driver DriverMED DriverDAT DriverUNV \
+       SMESH SMESH_I OBJECT SMESHFiltersSelection SMESHGUI SMESH_SWIG \
+       MEFISTO2 StdMeshers StdMeshers_I StdMeshersGUI
 
 @MODULE@
index fbce0dc257f3c1b43ac1474c13deaf70d8458482..ac9be864c82ec1db1666a7103952c3b243696721 100644 (file)
 top_srcdir=@top_srcdir@
 top_builddir=../..
 srcdir=@srcdir@
-VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
+VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl
 
 @COMMENCE@
 
-EXPORT_HEADERS = SMESH_Actor.h \
-                SMESH_Grid.h
+EXPORT_HEADERS = SMESH_Actor.h SMESH_Object.h
 
 
 # Libraries targets
 
 LIB = libSMESHObject.la
-LIB_SRC = SMESH_Actor.cxx \
-         SMESH_Grid.cxx
+LIB_SRC = SMESH_Object.cxx SMESH_DeviceActor.cxx SMESH_Actor.cxx
+
+LIB_CLIENT_IDL = SALOME_Exception.idl \
+                SALOME_GenericObj.idl \
+                SMESH_Mesh.idl \
+                SMESH_Filter.idl \
+                SMESH_Group.idl
 
-LIB_CLIENT_IDL = 
 
 # Executables targets
 BIN = 
 BIN_SRC        =
 
-CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
-LDFLAGS+=$(QT_MT_LIBS) $(OCC_KERNEL_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) -lSalomeObject -L${KERNEL_ROOT_DIR}/lib/salome
-
-%_moc.cxx: %.h
-       $(MOC) $< -o $@
-
+CPPFLAGS+=$(OCC_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
+         $(BOOST_CPPFLAGS) $(QT_INCLUDES)
+LDFLAGS+=$(OCC_KERNEL_LIBS) $(VTK_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -lSMDS \
+         -lSalomeGUI -lSalomeObject -lOpUtil
 
 @CONCLUDE@
index a48f011be9d0d3c9bc622faf5d5070b078314898..29a1f094bd6a1af283abcd59800a555786fa3fc0 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
-/*!
-  \class SMESH_Actor SMESH_Actor.h
-  \brief ...
-*/
 
 #include "SMESH_Actor.h"
-#include "SMESH_Grid.h"
+#include "SMESH_DeviceActor.h"
+#include "SALOME_ExtractUnstructuredGrid.h"
+
+#include "QAD_Config.h"
 #include "utilities.h"
+#include <qstringlist.h>
 
-// VTK Includes
 #include <vtkObjectFactory.h>
-#include <vtkMergePoints.h>
-#include <vtkDataSetMapper.h>
-#include <vtkFeatureEdges.h>
-#include <vtkGeometryFilter.h>
+#include <vtkShrinkPolyData.h>
+#include <vtkMergeFilter.h>
+
+#include <vtkActor2D.h>
+#include <vtkPolyData.h>
+#include <vtkMaskPoints.h>
+#include <vtkCellCenters.h>
+#include <vtkTextProperty.h>
+#include <vtkLabeledDataMapper.h>
+#include <vtkSelectVisiblePoints.h>
+
+#include <vtkScalarBarActor.h>
+#include <vtkLookupTable.h>
+#include <vtkDoubleArray.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+static int MYDEBUGWITHFILES = 0;
+#else
+static int MYDEBUG = 0;
+static int MYDEBUGWITHFILES = 0;
+#endif
 
-//-------------------------------------------------------------
-// Main methods
-//-------------------------------------------------------------
+using namespace std;
 
-SMESH_Actor* SMESH_Actor::New()
-{
-  // First try to create the object from the vtkObjectFactory
-  vtkObject* ret = vtkObjectFactory::CreateInstance("SMESH_Actor");
-  if(ret)
-    {
-      return (SMESH_Actor*)ret;
-    }
-  // If the factory was unable to create the object, then create it here.
-  return new SMESH_Actor;
+
+inline float GetFloat(const QString& theValue, float theDefault = 0){
+  if(theValue.isEmpty()) return theDefault;
+  QString aValue = QAD_CONFIG->getSetting(theValue);
+  if(aValue.isEmpty()) return theDefault;
+  return aValue.toFloat();
 }
 
 
-SMESH_Actor::SMESH_Actor()
-{
-  this->Device = vtkActor::New();
+SMESH_Actor* SMESH_Actor::New(){
+  return new SMESH_Actor();
+}
 
-  this->EdgeDevice = vtkActor::New();
-  EdgeDevice->VisibilityOff();
-  EdgeDevice->PickableOff();
 
-  this->EdgeShrinkDevice = vtkActor::New();
-  EdgeShrinkDevice->VisibilityOff();
-  EdgeShrinkDevice->PickableOff();
+SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj, 
+                             SMESH::FilterManager_ptr theFilterMgr,
+                             const char* theEntry, 
+                             const char* theName,
+                             int theIsClear)
+{
+  SMESH_Actor* anActor = SMESH_Actor::New();
+  anActor->Init(theVisualObj,theFilterMgr,theEntry,theName,theIsClear);
+  return anActor;
+}
 
-  DataSource = NULL;
 
-  myIO = NULL;
+SMESH_Actor::SMESH_Actor(){
+  if(MYDEBUG) MESSAGE("SMESH_Actor");
+
+  myIsPointsVisible = false;
+
+  myIsShrinkable = false;
+  myIsShrunk = false;
+
+  float aPointSize = GetFloat("SMESH:SettingsNodesSize",3);
+  float aLineWidth = GetFloat("SMESH:SettingsWidth",1);
+
+  vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
+  SALOME_ExtractUnstructuredGrid* aFilter = NULL;
+
+  //Definition 2D and 3D divices of the actor
+  //-----------------------------------------
+  float anRGB[3] = {1,1,1};
+  mySurfaceProp = vtkProperty::New();
+  anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.;
+  anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.;
+  anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.;
+  mySurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+
+  myBackSurfaceProp = vtkProperty::New();
+  anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.;
+  anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.;
+  anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.;
+  myBackSurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+
+  my2DActor = SMESH_DeviceActor::New();
+  my2DActor->SetUserMatrix(aMatrix);
+  my2DActor->SetStoreMapping(true);
+  my2DActor->PickableOff();
+  my2DActor->SetProperty(mySurfaceProp);
+  my2DActor->SetBackfaceProperty(myBackSurfaceProp);
+  my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
+  aFilter = my2DActor->GetExtractUnstructuredGrid();
+  aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
+  aFilter->RegisterCellsWithType(VTK_TRIANGLE);
+  aFilter->RegisterCellsWithType(VTK_POLYGON);
+  aFilter->RegisterCellsWithType(VTK_QUAD);
+
+  my3DActor = SMESH_DeviceActor::New();
+  my3DActor->SetUserMatrix(aMatrix);
+  my3DActor->SetStoreMapping(true);
+  my3DActor->PickableOff();
+  my3DActor->SetProperty(mySurfaceProp);
+  my3DActor->SetBackfaceProperty(myBackSurfaceProp);
+  my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
+  aFilter = my3DActor->GetExtractUnstructuredGrid();
+  aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
+  aFilter->RegisterCellsWithType(VTK_TETRA);
+  aFilter->RegisterCellsWithType(VTK_VOXEL);
+  aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
+  aFilter->RegisterCellsWithType(VTK_WEDGE);
+  aFilter->RegisterCellsWithType(VTK_PYRAMID);
+
+
+  //Definition 1D divice of the actor
+  //---------------------------------
+  myEdgeProp = vtkProperty::New();
+  myEdgeProp->SetAmbient(1.0);
+  myEdgeProp->SetDiffuse(0.0);
+  myEdgeProp->SetSpecular(0.0);
+  anRGB[0] = GetFloat("SMESH:SettingsOutlineColorRed", 0)/255.;
+  anRGB[1] = GetFloat("SMESH:SettingsOutlineColorGreen", 170)/255.;
+  anRGB[2] = GetFloat("SMESH:SettingsOutlineColorBlue", 255)/255.;
+  myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+  myEdgeProp->SetLineWidth(aLineWidth);
+
+  my1DActor = SMESH_DeviceActor::New();
+  my1DActor->SetUserMatrix(aMatrix);
+  my1DActor->SetStoreMapping(true);
+  my1DActor->PickableOff();
+  my1DActor->SetProperty(myEdgeProp);
+  my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
+  aFilter = my1DActor->GetExtractUnstructuredGrid();
+  aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
+  aFilter->RegisterCellsWithType(VTK_LINE);
+
+  my1DProp = vtkProperty::New();
+  my1DProp->DeepCopy(myEdgeProp);
+  static int aCotnrolLineWidth = 3;
+  my1DProp->SetLineWidth(aCotnrolLineWidth);
+  my1DProp->SetPointSize(aPointSize);
+
+  my1DExtProp = vtkProperty::New();
+  my1DExtProp->DeepCopy(myEdgeProp);
+  anRGB[0] = 1 - anRGB[0];
+  anRGB[1] = 1 - anRGB[1];
+  anRGB[2] = 1 - anRGB[2];
+  my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+  my1DExtProp->SetLineWidth(aCotnrolLineWidth);
+
+  my1DExtActor = SMESH_DeviceActor::New();
+  my1DExtActor->SetUserMatrix(aMatrix);
+  my1DExtActor->SetStoreMapping(true);
+  my1DExtActor->PickableOff();
+  my1DExtActor->SetVisibility(false);
+  my1DExtActor->SetProperty(my1DExtProp);
+  my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
+  aFilter = my1DExtActor->GetExtractUnstructuredGrid();
+  aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
+  aFilter->RegisterCellsWithType(VTK_LINE);
+
+
+  //Definition 0D divice of the actor
+  //---------------------------------
+  myNodeProp = vtkProperty::New();
+  anRGB[0] = GetFloat("SMESH:SettingsNodeColorRed",255)/255.;
+  anRGB[1] = GetFloat("SMESH:SettingsNodeColorGreen",0)/255.;
+  anRGB[2] = GetFloat("SMESH:SettingsNodeColorBlue",0)/255.;
+  myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+  myNodeProp->SetPointSize(aPointSize);
+
+  myNodeActor = SMESH_DeviceActor::New();
+  myNodeActor->SetUserMatrix(aMatrix);
+  myNodeActor->SetStoreMapping(true);
+  myNodeActor->PickableOff();
+  myNodeActor->SetVisibility(false);
+  myNodeActor->SetProperty(myNodeProp);
+  myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
+  aFilter = myNodeActor->GetExtractUnstructuredGrid();
+  aFilter->SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints);
+
+
+  //Definition of Pickable and Highlitable engines
+  //----------------------------------------------
+
+  myBaseActor = SMESH_DeviceActor::New();
+  myBaseActor->SetUserMatrix(aMatrix);
+  myBaseActor->SetStoreMapping(true);
+  myBaseActor->GetProperty()->SetOpacity(0.0);
+
+  myPickableActor = myBaseActor;
+
+  myHighlightProp = vtkProperty::New();
+  myHighlightProp->SetAmbient(1.0);
+  myHighlightProp->SetDiffuse(0.0);
+  myHighlightProp->SetSpecular(0.0);
+  anRGB[0] = GetFloat("SMESH:SettingsSelectColorRed", 255)/255.;   // 1;
+  anRGB[1] = GetFloat("SMESH:SettingsSelectColorGreen", 255)/255.; // 1;
+  anRGB[2] = GetFloat("SMESH:SettingsSelectColorBlue", 255)/255.;  // 1;
+  myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+  myHighlightProp->SetPointSize(aPointSize);
+  myHighlightProp->SetRepresentation(1);
+  myPreselectProp = vtkProperty::New();
+  myPreselectProp->SetAmbient(1.0);
+  myPreselectProp->SetDiffuse(0.0);
+  myPreselectProp->SetSpecular(0.0);
+  anRGB[0] = GetFloat("SMESH:SettingsPreSelectColorRed", 0)/255.;     // 0;
+  anRGB[1] = GetFloat("SMESH:SettingsPreSelectColorGreen", 255)/255.; // 1;
+  anRGB[2] = GetFloat("SMESH:SettingsPreSelectColorBlue", 255)/255.;  // 1;
+  myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+  myPreselectProp->SetPointSize(aPointSize);
+  myPreselectProp->SetRepresentation(1);
+
+  myHighlitableActor = SMESH_DeviceActor::New();
+  myHighlitableActor->SetUserMatrix(aMatrix);
+  myHighlitableActor->SetStoreMapping(false);
+  myHighlitableActor->PickableOff();
+  myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
+
+
+  SetShrinkFactor(GetFloat("SMESH:SettingsShrinkCoeff", 75)/100.);
+
   myName = "";
+  myIO = NULL;
   myDisplayMode = 0;
 
   ishighlighted = false;
   ispreselected = false;
 
-  edgeColor.r = 0.;
-  edgeColor.g = 0.;
-  edgeColor.b = 0.;
-  
-  edgeHighlightColor.r = 1.;
-  edgeHighlightColor.g = 1.;
-  edgeHighlightColor.b = 1.;
+  myColorMode = eNone;
+  my1DColorMode = e1DNone;
+  myControlActor = my2DActor;
 
-  edgePreselectedColor.r = 0.;
-  edgePreselectedColor.g = 1.;
-  edgePreselectedColor.b = 1.;
+  //Definition of myScalarBarActor
+  //------------------------------
+  myLookupTable = vtkLookupTable::New();
+  //Fix for Bug PAL5195 - SMESH764: 
+  //Controls - Aspect Ratio: incorrect colors of the best and worst values
+  myLookupTable->SetHueRange(0.667,0.0);
 
-  actorColor.r = 1.;
-  actorColor.g = 1.;
-  actorColor.b = 0.;
+  myScalarBarActor = vtkScalarBarActor::New();
+  myScalarBarActor->SetVisibility(false);
+  myScalarBarActor->SetLookupTable(myLookupTable);
 
-  actorHighlightColor.r = 1.;
-  actorHighlightColor.g = 1.;
-  actorHighlightColor.b = 1.;
+  vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
 
-  actorPreselectedColor.r = 0.;
-  actorPreselectedColor.g = 1.;
-  actorPreselectedColor.b = 1.;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) {
+    QStringList aTColor = QStringList::split(  ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false );
+    aScalarBarTitleProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ),
+                                  ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), 
+                                  ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) );
+  }
+  else
+    aScalarBarTitleProp->SetColor( 1.0, 1.0, 1.0 );
+
+  aScalarBarTitleProp->SetFontFamilyToArial();
+  if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ){
+    if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" )
+      aScalarBarTitleProp->SetFontFamilyToArial();
+    else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" )
+      aScalarBarTitleProp->SetFontFamilyToCourier();
+    else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" )
+      aScalarBarTitleProp->SetFontFamilyToTimes();
+  }
 
-  actorNodeColor.r = 1.;
-  actorNodeColor.g = 1.;
-  actorNodeColor.b = 0.;
+  if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" )
+    aScalarBarTitleProp->BoldOn();
+  else
+    aScalarBarTitleProp->BoldOff();
 
-  actorNodeSize = 2 ;
-  
-}
+  if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" )
+    aScalarBarTitleProp->ItalicOn();
+  else
+    aScalarBarTitleProp->ItalicOff();
 
-SMESH_Actor::~SMESH_Actor()
-{
-  this->EdgeDevice->Delete();
-  this->EdgeShrinkDevice->Delete();
-}
+  if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" )
+    aScalarBarTitleProp->ShadowOn();
+  else
+    aScalarBarTitleProp->ShadowOff();
 
-void SMESH_Actor::setReader(vtkUnstructuredGridReader* r) {
-  myReader=r;
-}
+  myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
+  aScalarBarTitleProp->Delete();
+
+  vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
+
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) {
+    QStringList aTColor = QStringList::split(  ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false );
+    aScalarBarLabelProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ),
+                                  ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), 
+                                  ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) );
+  }
+  else
+    aScalarBarLabelProp->SetColor( 1.0, 1.0, 1.0 );
+
+  aScalarBarLabelProp->SetFontFamilyToArial();
+  if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ){
+    if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" )
+      aScalarBarLabelProp->SetFontFamilyToArial();
+    else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" )
+      aScalarBarLabelProp->SetFontFamilyToCourier();
+    else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" )
+      aScalarBarLabelProp->SetFontFamilyToTimes();
+  }
+
+  if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" )
+    aScalarBarLabelProp->BoldOn();
+  else
+    aScalarBarLabelProp->BoldOff();
+
+  if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" )
+    aScalarBarLabelProp->ItalicOn();
+  else
+    aScalarBarLabelProp->ItalicOff();
+
+  if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" )
+    aScalarBarLabelProp->ShadowOn();
+  else
+    aScalarBarLabelProp->ShadowOff();
+
+  myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
+  aScalarBarLabelProp->Delete();
+
+  if ( QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" )
+    myScalarBarActor->SetOrientationToHorizontal();
+  else
+    myScalarBarActor->SetOrientationToVertical();
+
+  float aXVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.20 : 0.01;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) )
+    aXVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toFloat();
+  float aYVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.01 : 0.1;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) )
+    aYVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toFloat();
+  myScalarBarActor->SetPosition( aXVal, aYVal );
+
+  float aWVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.60 : 0.10;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) )
+    aWVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toFloat();
+  myScalarBarActor->SetWidth( aWVal );
+
+  float aHVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.12 : 0.80;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) )
+    aHVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toFloat();
+  myScalarBarActor->SetHeight( aHVal );
+
+  int anIntVal = 5;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) )
+    anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfLabels").toInt();
+  myScalarBarActor->SetNumberOfLabels(anIntVal == 0? 5: anIntVal);
+
+  anIntVal = 64;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) )
+    anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfColors").toInt();
+  myScalarBarActor->SetMaximumNumberOfColors(anIntVal == 0? 64: anIntVal);
+
+
+  //Definition of points numbering pipeline
+  //---------------------------------------
+  myPointsNumDataSet = vtkUnstructuredGrid::New();
+
+  myPtsMaskPoints = vtkMaskPoints::New();
+  myPtsMaskPoints->SetInput(myPointsNumDataSet);
+  myPtsMaskPoints->SetOnRatio(1);
+    
+  myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
+  myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
+  myPtsSelectVisiblePoints->SelectInvisibleOff();
+  myPtsSelectVisiblePoints->SetTolerance(0.1);
+    
+  myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
+  myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
+  myPtsLabeledDataMapper->SetLabelFormat("%g");
+  myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
+    
+  vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
+  aPtsTextProp->SetFontFamilyToTimes();
+  static int aPointsFontSize = 10;
+  aPtsTextProp->SetFontSize(aPointsFontSize);
+  aPtsTextProp->SetBold(1);
+  aPtsTextProp->SetItalic(0);
+  aPtsTextProp->SetShadow(0);
+  myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
+  aPtsTextProp->Delete();
+    
+  myIsPointsLabeled = false;
+
+  myPointLabels = vtkActor2D::New();
+  myPointLabels->SetMapper(myPtsLabeledDataMapper);
+  myPointLabels->GetProperty()->SetColor(1,1,1);
+  myPointLabels->SetVisibility(myIsPointsLabeled);
+
+
+  //Definition of cells numbering pipeline
+  //---------------------------------------
+  myCellsNumDataSet = vtkUnstructuredGrid::New();
+
+  myCellCenters = vtkCellCenters::New();
+  myCellCenters->SetInput(myCellsNumDataSet);
 
-vtkUnstructuredGridReader* SMESH_Actor::getReader() {
-  return (myReader);
+  myClsMaskPoints = vtkMaskPoints::New();
+  myClsMaskPoints->SetInput(myCellCenters->GetOutput());
+  myClsMaskPoints->SetOnRatio(1);
+    
+  myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
+  myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
+  myClsSelectVisiblePoints->SelectInvisibleOff();
+  myClsSelectVisiblePoints->SetTolerance(0.1);
+    
+  myClsLabeledDataMapper = vtkLabeledDataMapper::New();
+  myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
+  myClsLabeledDataMapper->SetLabelFormat("%g");
+  myClsLabeledDataMapper->SetLabelModeToLabelScalars();
+    
+  vtkTextProperty* aClsTextProp = vtkTextProperty::New();
+  aClsTextProp->SetFontFamilyToTimes();
+  static int aCellsFontSize = 12;
+  aClsTextProp->SetFontSize(aCellsFontSize);
+  aClsTextProp->SetBold(1);
+  aClsTextProp->SetItalic(0);
+  aClsTextProp->SetShadow(0);
+  myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
+  aClsTextProp->Delete();
+    
+  myIsCellsLabeled = false;
+
+  myCellsLabels = vtkActor2D::New();
+  myCellsLabels->SetMapper(myClsLabeledDataMapper);
+  myCellsLabels->GetProperty()->SetColor(0,1,0);
+  myCellsLabels->SetVisibility(myIsCellsLabeled);
 }
 
-vtkMapper* SMESH_Actor::getMapper() {
-  return (this->Mapper);
+
+SMESH_Actor::~SMESH_Actor(){
+  if(MYDEBUG) MESSAGE("~SMESH_Actor");
+
+  myScalarBarActor->Delete();
+  myLookupTable->Delete();
+
+  mySurfaceProp->Delete();
+  myBackSurfaceProp->Delete();
+
+  myEdgeProp->Delete();
+  myHighlightProp->Delete();
+  myPreselectProp->Delete();
+
+  myNodeProp->Delete();
+
+  my1DProp->Delete();
+  my1DActor->Delete();
+
+  my1DExtProp->Delete();
+  my1DExtActor->Delete();
+
+  my2DActor->Delete();
+  my3DActor->Delete();
+
+  myNodeActor->Delete();
+  myBaseActor->Delete();
+  myHighlitableActor->Delete();
+
+
+  //Deleting of pints numbering pipeline
+  //---------------------------------------
+  myPointsNumDataSet->Delete();
+
+  myPtsLabeledDataMapper->RemoveAllInputs();
+  myPtsLabeledDataMapper->Delete();
+
+  myPtsSelectVisiblePoints->UnRegisterAllOutputs();
+  myPtsSelectVisiblePoints->Delete();
+
+  myPtsMaskPoints->UnRegisterAllOutputs();
+  myPtsMaskPoints->Delete();
+
+  myPointLabels->Delete();
+
+
+  //Deleting of cells numbering pipeline
+  //---------------------------------------
+  myCellsNumDataSet->Delete();
+
+  myClsLabeledDataMapper->RemoveAllInputs();
+  myClsLabeledDataMapper->Delete();
+
+  myClsSelectVisiblePoints->UnRegisterAllOutputs();
+  myClsSelectVisiblePoints->Delete();
+
+  myClsMaskPoints->UnRegisterAllOutputs();
+  myClsMaskPoints->Delete();
+
+  myCellCenters->UnRegisterAllOutputs();
+  myCellCenters->Delete();
+
+  myCellsLabels->Delete();
 }
 
-void SMESH_Actor::ShallowCopy(vtkProp *prop)
+
+void SMESH_Actor::SetPointsLabeled( bool theIsPointsLabeled )
 {
-  SMESH_Actor *f = SMESH_Actor::SafeDownCast(prop);
-  if ( f != NULL )
+  myIsPointsLabeled = theIsPointsLabeled;
+
+  if ( myIsPointsLabeled )
+  {
+    myPointsNumDataSet->ShallowCopy( GetUnstructuredGrid() );
+    vtkDataSet *aDataSet = myPointsNumDataSet;
+    
+    int aNbElem = aDataSet->GetNumberOfPoints();
+    
+    vtkIntArray *anArray = vtkIntArray::New();
+    anArray->SetNumberOfValues( aNbElem );
+    
+    for ( int anId = 0; anId < aNbElem; anId++ )
     {
-      this->setName( f->getName() );
-      if ( f->hasIO() )
-       this->setIO( f->getIO() );
-      this->setDisplayMode( f->getDisplayMode() );
-
-      // Copy devices
-      vtkActor* tempDev = vtkActor::New();
-      tempDev->ShallowCopy(f->Device);
-      vtkProperty* prp = vtkProperty::New();
-      prp->DeepCopy(f->Device->GetProperty());
-      tempDev->SetProperty(prp);
-      prp = vtkProperty::New();
-      prp->DeepCopy(f->Device->GetBackfaceProperty());
-      tempDev->SetBackfaceProperty(prp);
-      this->Device = tempDev;
-      
-      tempDev = vtkActor::New();
-      tempDev->ShallowCopy(f->EdgeDevice);
-      prp = vtkProperty::New();
-      prp->DeepCopy(f->EdgeDevice->GetProperty());
-      tempDev->SetProperty(prp);
-      prp = vtkProperty::New();
-      prp->DeepCopy(f->EdgeDevice->GetBackfaceProperty());
-      tempDev->SetBackfaceProperty(prp);
-      this->EdgeDevice = tempDev;
-
-      tempDev = vtkActor::New();
-      tempDev->ShallowCopy(f->EdgeShrinkDevice);
-      prp = vtkProperty::New();
-      prp->DeepCopy(f->EdgeShrinkDevice->GetProperty());
-      tempDev->SetProperty(prp);
-      prp = vtkProperty::New();
-      prp->DeepCopy(f->EdgeShrinkDevice->GetBackfaceProperty());
-      tempDev->SetBackfaceProperty(prp);
-      this->EdgeShrinkDevice = tempDev;
-
-      // Copy data source
-      this->DataSource = f->DataSource;
-
-      this->myReader   = f->myReader;
+      int aSMDSId = myVisualObj->GetNodeObjId( anId );
+      anArray->SetValue( anId, aSMDSId );
     }
-
-  // Now do superclass
-  this->SALOME_Actor::ShallowCopy(prop);
-
-  // Here we need to modify default ShallowCopy() results
-  // Create copies of properties
-  if ( f != NULL ) {
-    vtkProperty* prp = vtkProperty::New();
-    prp->DeepCopy(f->GetProperty());
-    this->SetProperty(prp);
-
-    prp = vtkProperty::New();
-    prp->DeepCopy(f->GetBackfaceProperty());
-    this->SetBackfaceProperty(prp);
-
-    // Copy the mapper
-    vtkDataSetMapper* mpr = vtkDataSetMapper::New();
-    mpr->ShallowCopy(f->GetMapper());
-    mpr->SetInput(f->DataSource);
-    this->SetMapper(mpr);
+    
+    aDataSet->GetPointData()->SetScalars( anArray );
+    anArray->Delete();
+    myPtsMaskPoints->SetInput( aDataSet );
+    myPointLabels->SetVisibility( GetVisibility() );
   }
-}
-
-void SMESH_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper )
-{
-   if (this->Mapper == NULL) {
-    MESSAGE ("No mapper for actor.")
-    return;
+  else
+  {
+    myPointLabels->SetVisibility( false );
   }
+  
+  SetRepresentation( GetRepresentation() );
+}
 
-   if ( myDisplayMode == 1 ) {
-     EdgeDevice->VisibilityOn();
-     EdgeShrinkDevice->VisibilityOff();
-   } else if ( myDisplayMode == 2 ) {
-     EdgeShrinkDevice->VisibilityOn();
-     EdgeDevice->VisibilityOff();
-   } else {
-     EdgeShrinkDevice->VisibilityOff();
-     EdgeDevice->VisibilityOff();
-   }
-     
-
-  vtkMapper *bestMapper;
-  bestMapper = this->Mapper;
-
-  /* render the property */
-  if (!this->Property) {
-    // force creation of a property
-    this->GetProperty();
-  }
 
-  if ( ishighlighted ) {
-   if ( myDisplayMode == 1 ) {
-     EdgeDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b);
-     this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b);
-   } else if ( myDisplayMode == 2 ) {
-     EdgeShrinkDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b);
-   } else {
-     this->GetProperty()->SetColor(actorHighlightColor.r,actorHighlightColor.g,actorHighlightColor.b);
-   }
-  } else if (! ispreselected ) {
-    if ( myDisplayMode == 1 ) {
-      EdgeDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b);
-      this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b);
+void SMESH_Actor::SetCellsLabeled(bool theIsCellsLabeled){
+  myIsCellsLabeled = theIsCellsLabeled;
+  if(myIsCellsLabeled){
+    myCellsNumDataSet->ShallowCopy(GetUnstructuredGrid());
+    vtkDataSet *aDataSet = myCellsNumDataSet;
+    int aNbElem = aDataSet->GetNumberOfCells();
+    vtkIntArray *anArray = vtkIntArray::New();
+    anArray->SetNumberOfValues(aNbElem);
+    for(int anId = 0; anId < aNbElem; anId++){
+      int aSMDSId = myVisualObj->GetElemObjId(anId);
+      anArray->SetValue(anId,aSMDSId);
     }
-    else if ( myDisplayMode == 2 ) 
-      EdgeShrinkDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b);
-    else
-      this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b);
-  }
-  else {
-    if ( myDisplayMode == 1 )
-      EdgeDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b);
-    else if ( myDisplayMode == 2 ) 
-      EdgeShrinkDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b);
-    else
-      this->GetProperty()->SetColor(actorPreselectedColor.r,actorPreselectedColor.g,actorPreselectedColor.b);
+    aDataSet->GetCellData()->SetScalars(anArray);
+    myCellCenters->SetInput(aDataSet);
+    myCellsLabels->SetVisibility(GetVisibility());
+  }else{
+    myCellsLabels->SetVisibility(false);
   }
+}
 
-  this->Property->Render(this, ren);
-  if (this->BackfaceProperty) {
-    this->BackfaceProperty->BackfaceRender(this, ren);
-    this->Device->SetBackfaceProperty(this->BackfaceProperty);
-  }
-  this->Device->SetProperty(this->Property);
-  
-  /* render the texture */
-  if (this->Texture) {
-    this->Texture->Render(ren);
+
+void SMESH_Actor::SetControlMode(eControl theMode){
+  myColorMode = eNone;
+  my1DColorMode = e1DNone;
+
+  my1DActor->GetMapper()->SetScalarVisibility(false);
+  my2DActor->GetMapper()->SetScalarVisibility(false);
+  my3DActor->GetMapper()->SetScalarVisibility(false);
+  myScalarBarActor->SetVisibility(false);
+
+  bool anIsScalarVisible = theMode > eNone;
+
+  if(anIsScalarVisible){
+    SMESH::NumericalFunctor_var aFunctor;
+    SMESH::Predicate_var aPredicate;
+      
+    switch(theMode){
+    case eLengthEdges:
+      aFunctor = myFilterMgr->CreateLength();
+      myControlActor = my1DActor;
+      break;
+    case eFreeBorders:
+      aPredicate = myFilterMgr->CreateFreeBorders();
+      myControlActor = my1DActor;
+      break;
+    case eMultiConnection:
+      aFunctor = myFilterMgr->CreateMultiConnection();
+      myControlActor = my1DActor;
+      break;
+    case eArea:
+      aFunctor = myFilterMgr->CreateArea();
+      myControlActor = my2DActor;
+      break;
+    case eTaper:
+      aFunctor = myFilterMgr->CreateTaper();
+      myControlActor = my2DActor;
+      break;
+    case eAspectRatio:
+      aFunctor = myFilterMgr->CreateAspectRatio();
+      myControlActor = my2DActor;
+      break;
+    case eMinimumAngle:
+      aFunctor = myFilterMgr->CreateMinimumAngle();
+      myControlActor = my2DActor;
+      break;
+    case eWarping:
+      aFunctor = myFilterMgr->CreateWarping();
+      myControlActor = my2DActor;
+      break;
+    case eSkew:
+      aFunctor = myFilterMgr->CreateSkew();
+      myControlActor = my2DActor;
+      break;
+    default:
+      return;
+    }
+    
+    vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
+    vtkIdType aNbCells = aGrid->GetNumberOfCells();
+    if(aNbCells){
+      if(theMode == eFreeBorders){
+       if(!aPredicate->_is_nil()){
+         myVisualObj->UpdateFunctor(aPredicate);
+         SALOME_ExtractUnstructuredGrid* aFilter = 
+           my1DExtActor->GetExtractUnstructuredGrid();
+         aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
+         aFilter->ClearRegisteredCells();
+         for( vtkIdType i = 0; i < aNbCells; i++ ){
+           vtkIdType anObjId = myControlActor->GetElemObjId( i );
+           CORBA::Boolean aValue = aPredicate->IsSatisfy(anObjId);
+           if(aValue)
+             aFilter->RegisterCell(i);
+         }
+         if(!aFilter->IsCellsRegistered())
+           aFilter->RegisterCell(-1);
+         aPredicate->Destroy();
+       }
+       myColorMode = theMode;
+       my1DColorMode = e1DHighlited;
+      }else{
+       myColorMode = theMode;
+       if(myControlActor == my1DActor)
+         my1DColorMode = e1DColored;
+       
+       vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+       aDataSet->ShallowCopy(aGrid);
+       myScalarBarActor->SetVisibility(true);
+       myControlActor->GetMapper()->SetScalarVisibility(true);
+       
+       vtkDoubleArray *aScalars = vtkDoubleArray::New();
+       aScalars->SetNumberOfComponents( 1 );
+       aScalars->SetNumberOfTuples(aNbCells);
+       
+       if(!aFunctor->_is_nil()){
+         myVisualObj->UpdateFunctor(aFunctor);
+         for( vtkIdType i = 0; i < aNbCells; i++ ){
+           vtkIdType anObjId = myControlActor->GetElemObjId( i );
+           CORBA::Double aValue = aFunctor->GetValue(anObjId);
+           aScalars->SetValue( i, aValue );
+         }
+         aFunctor->Destroy();
+       }else if(!aPredicate->_is_nil()){
+         myVisualObj->UpdateFunctor(aPredicate);
+         for( vtkIdType i = 0; i < aNbCells; i++ ){
+           vtkIdType anObjId = myControlActor->GetElemObjId( i );
+           CORBA::Boolean aValue = aPredicate->IsSatisfy(anObjId);
+           aScalars->SetValue( i, aValue );
+         }
+         aPredicate->Destroy();
+       }
+       aDataSet->GetCellData()->SetScalars(aScalars);
+       aScalars->Delete();
+       
+       float aRange[2];
+       aScalars->GetRange(aRange);
+       myLookupTable->SetRange(aRange);
+       myLookupTable->Build();
+       
+       myControlActor->GetMergeFilter()->SetScalars(aDataSet);
+       aDataSet->Delete();
+       if(MYDEBUGWITHFILES) 
+         WriteUnstructuredGrid(aDataSet,"/tmp/SetControlMode.vtk");
+      }
+    }
   }
+  SetRepresentation(GetRepresentation());
   
-  
-  // Store information on time it takes to render.
-  // We might want to estimate time from the number of polygons in mapper.
-  this->Device->Render(ren,bestMapper);
-  this->EstimatedRenderTime = bestMapper->GetTimeToDraw();
+  Modified();
 }
 
-int SMESH_Actor::RenderOpaqueGeometry(vtkViewport *vp)
+
+void SMESH_Actor::AddToRender(vtkRenderer* theRenderer){
+  SALOME_Actor::AddToRender(theRenderer);
+
+  theRenderer->AddActor(myNodeActor);
+  theRenderer->AddActor(myBaseActor);
+
+  theRenderer->AddActor(my3DActor);
+  theRenderer->AddActor(my2DActor);
+
+  theRenderer->AddActor(my1DActor);
+  theRenderer->AddActor(my1DExtActor);
+
+  theRenderer->AddActor(myHighlitableActor);
+
+  theRenderer->AddActor2D(myScalarBarActor);
+
+  myPtsSelectVisiblePoints->SetRenderer(theRenderer);
+  myClsSelectVisiblePoints->SetRenderer(theRenderer);
+
+  theRenderer->AddActor2D(myPointLabels);
+  theRenderer->AddActor2D(myCellsLabels);
+}
+
+void SMESH_Actor::RemoveFromRender(vtkRenderer* theRenderer){
+  SALOME_Actor::RemoveFromRender(theRenderer);
+
+  theRenderer->RemoveActor(myNodeActor);
+  theRenderer->RemoveActor(myBaseActor);
+  theRenderer->RemoveActor(myHighlitableActor);
+
+  theRenderer->RemoveActor(my1DActor);
+  theRenderer->RemoveActor(my1DExtActor);
+
+  theRenderer->RemoveActor(my2DActor);
+  theRenderer->RemoveActor(my3DActor);
+
+  theRenderer->RemoveActor(myScalarBarActor);
+  theRenderer->RemoveActor(myPointLabels);
+  theRenderer->RemoveActor(myCellsLabels);
+}
+
+
+void SMESH_Actor::Init(TVisualObjPtr theVisualObj, 
+                      SMESH::FilterManager_ptr theFilterMgr,
+                      const char* theEntry, 
+                      const char* theName,
+                      int theIsClear)
 {
-  int          renderedSomething = 0; 
-  vtkRenderer  *ren = (vtkRenderer *)vp;
-  
-  if ( ! this->Mapper ) {
-    return 0;
-  }
-  
-  // make sure we have a property
-  if (!this->Property) {
-    // force creation of a property
-    this->GetProperty();
-  }
+  Handle(SALOME_InteractiveObject) anIO =
+    new SALOME_InteractiveObject(strdup(theEntry),strdup("MESH"),strdup(theName));
+  setIO(anIO);
+  setName(strdup(theName));
+
+  myVisualObj = theVisualObj;
+  myNodeActor->myVisualObj = myVisualObj;
+  myBaseActor->myVisualObj = myVisualObj;
+  myHighlitableActor->myVisualObj = myVisualObj;
+
+  my1DActor->myVisualObj = myVisualObj;
+  my1DExtActor->myVisualObj = myVisualObj;
+
+  my2DActor->myVisualObj = myVisualObj;
+  my3DActor->myVisualObj = myVisualObj;
+
+  myVisualObj->Update(theIsClear);
+  SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
   
-  if ( ishighlighted ) {
-   if ( myDisplayMode == 1 ) {
-     EdgeDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b);
-   } else if ( myDisplayMode == 2 ) {
-     EdgeShrinkDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b);
-   } else {
-     this->GetProperty()->SetColor(actorHighlightColor.r,actorHighlightColor.g,actorHighlightColor.b);
-   }
-  } else if (! ispreselected ) {
-    if ( myDisplayMode == 1 )
-      EdgeDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b);
-    else if ( myDisplayMode == 2 ) 
-      EdgeShrinkDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b);
-    else
-      this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b);
+  myFilterMgr = SMESH::FilterManager::_duplicate(theFilterMgr);
+
+  QString aMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
+  SetRepresentation(-1);
+  if(aMode.compare("Wireframe") == 0){
+    SetRepresentation(eEdge);
+  }else if(aMode.compare("Shading") == 0){
+    SetRepresentation(eSurface);
+  }else if(aMode.compare("Nodes") == 0){
+    SetRepresentation(ePoint);
   }
-  else {
-    if ( myDisplayMode == 1 )
-      EdgeDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b);
-    else if ( myDisplayMode == 2 ) 
-      EdgeShrinkDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b);
-    else
-      this->GetProperty()->SetColor(actorPreselectedColor.r,actorPreselectedColor.g,actorPreselectedColor.b);    
+
+  aMode = QAD_CONFIG->getSetting("SMESH:Shrink");
+  if(aMode == "yes"){
+    SetShrink();
   }
 
-  // is this actor opaque ?
-  if (this->GetIsOpaque()) {
-    this->Property->Render(this, ren);
-    
-    // render the backface property
-    if (this->BackfaceProperty) {
-      this->BackfaceProperty->BackfaceRender(this, ren);
-    }
-    
-    // render the texture 
-    if (this->Texture) {
-      this->Texture->Render(ren);
-    }
-    this->Render(ren,this->Mapper);
+  Modified();
+}
+
+
+vtkPolyData* SMESH_Actor::GetPolyDataInput(){
+  return myPickableActor->GetPolyDataInput();
+}
+
+
+void SMESH_Actor::SetTransform(SALOME_Transform* theTransform){
+  myNodeActor->SetTransform(theTransform);
+  myBaseActor->SetTransform(theTransform);
+  myHighlitableActor->SetTransform(theTransform);
+
+  my1DActor->SetTransform(theTransform);
+  my1DExtActor->SetTransform(theTransform);
+
+  my2DActor->SetTransform(theTransform);
+  my3DActor->SetTransform(theTransform);
+
+  Modified();
+}
+
+
+void SMESH_Actor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
+  if(theGrid){
+    myNodeActor->SetUnstructuredGrid(theGrid);
+    myBaseActor->SetUnstructuredGrid(theGrid);
+    myHighlitableActor->SetUnstructuredGrid(theGrid);
+
+    my1DActor->SetUnstructuredGrid(theGrid);
+    my1DExtActor->SetUnstructuredGrid(theGrid);
+
+    my2DActor->SetUnstructuredGrid(theGrid);
+    my3DActor->SetUnstructuredGrid(theGrid);
+
+    my1DActor->GetMapper()->SetLookupTable(myLookupTable);
+    my2DActor->GetMapper()->SetLookupTable(myLookupTable);
+    my3DActor->GetMapper()->SetLookupTable(myLookupTable);
     
-    renderedSomething = 1;
+    float aFactor, aUnits;
+    my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
+    my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
+
+    //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
+    SetIsShrunkable(true);
+
+    Modified();
   }
-  
-  return renderedSomething; 
 }
 
 
-void SMESH_Actor::SetColor(float r,float g,float b)
-{
-  actorColor.r = r;
-  actorColor.g = g;
-  actorColor.b = b;
+void SMESH_Actor::SetMapper(vtkMapper* theMapper){
+  vtkLODActor::SetMapper(theMapper);
 }
 
-void SMESH_Actor::GetColor(float& r,float& g,float& b)
-{
-  r = actorColor.r;
-  g = actorColor.g;
-  b = actorColor.b;
+
+void SMESH_Actor::ShallowCopy(vtkProp *prop){
+  SALOME_Actor::ShallowCopy(prop);
 }
 
-void SMESH_Actor::SetPreselectedColor(float r,float g,float b)
-{
-  actorPreselectedColor.r = r;
-  actorPreselectedColor.g = g;
-  actorPreselectedColor.b = b;
+
+vtkMapper* SMESH_Actor::GetMapper(){
+  return myPickableActor->GetMapper();
 }
 
-void SMESH_Actor::GetPreselectedColor(float& r,float& g,float& b)
-{
-  r = actorPreselectedColor.r;
-  g = actorPreselectedColor.g;
-  b = actorPreselectedColor.b;
+
+vtkUnstructuredGrid* SMESH_Actor::GetUnstructuredGrid(){ 
+  return myVisualObj->GetUnstructuredGrid();
 }
 
-void SMESH_Actor::SetHighlightColor(float r,float g,float b)
-{
-  actorHighlightColor.r = r;
-  actorHighlightColor.g = g;
-  actorHighlightColor.b = b;
+
+bool SMESH_Actor::IsInfinitive(){
+  vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
+  aDataSet->Update();
+  myIsInfinite = aDataSet->GetNumberOfCells() == 0;
+  return SALOME_Actor::IsInfinitive();
 }
 
-void SMESH_Actor::GetHighlightColor(float& r,float& g,float& b)
-{
-  r = actorHighlightColor.r;
-  g = actorHighlightColor.g;
-  b = actorHighlightColor.b;
+
+void SMESH_Actor::SetIsShrunkable(bool theShrunkable){
+  myIsShrinkable = theShrunkable;
+  Modified();
 }
 
-void SMESH_Actor::SetEdgeColor(float r,float g,float b)
-{
-  edgeColor.r = r;
-  edgeColor.g = g;
-  edgeColor.b = b;
+float SMESH_Actor::GetShrinkFactor(){
+  return myBaseActor->GetShrinkFactor();
 }
 
-void SMESH_Actor::GetEdgeColor(float& r,float& g,float& b)
-{
-  r = edgeColor.r;
-  g = edgeColor.g;
-  b = edgeColor.b;
+void SMESH_Actor::SetShrinkFactor(float theValue){
+  myBaseActor->SetShrinkFactor(theValue);
+
+  my1DActor->SetShrinkFactor(theValue);
+  my1DExtActor->SetShrinkFactor(theValue);
+
+  my2DActor->SetShrinkFactor(theValue);
+  my3DActor->SetShrinkFactor(theValue);
+
+  Modified();
 }
 
-void SMESH_Actor::SetEdgeHighlightColor(float r,float g,float b)
-{
-  edgeHighlightColor.r = r;
-  edgeHighlightColor.g = g;
-  edgeHighlightColor.b = b;
+void SMESH_Actor::SetShrink(){
+  if(!myIsShrinkable) return;
+
+  myBaseActor->SetShrink();
+
+  my1DActor->SetShrink();
+  my1DExtActor->SetShrink();
+
+  my2DActor->SetShrink();
+  my3DActor->SetShrink();
+
+  myIsShrunk = true;
+  Modified();
 }
 
-void SMESH_Actor::GetEdgeHighlightColor(float& r,float& g,float& b)
-{
-  r = edgeHighlightColor.r;
-  g = edgeHighlightColor.g;
-  b = edgeHighlightColor.b;
+void SMESH_Actor::UnShrink(){
+  if(!myIsShrunk) return;
+
+  myBaseActor->UnShrink();
+
+  my1DActor->UnShrink();
+  my1DExtActor->UnShrink();
+
+  my2DActor->UnShrink();
+  my3DActor->UnShrink();
+
+  myIsShrunk = false;
+  Modified();
 }
 
-void SMESH_Actor::SetEdgePreselectedColor(float r,float g,float b)
-{
-  edgePreselectedColor.r = r;
-  edgePreselectedColor.g = g;
-  edgePreselectedColor.b = b;
+
+int SMESH_Actor::GetObjId(int theVtkID){
+  if (GetRepresentation() == 0){
+    return GetNodeObjId(theVtkID);
+  }else{
+    return GetElemObjId(theVtkID);
+  }
 }
 
-void SMESH_Actor::GetEdgePreselectedColor(float& r,float& g,float& b)
-{
-  r = edgePreselectedColor.r;
-  g = edgePreselectedColor.g;
-  b = edgePreselectedColor.b;
+SALOME_Actor::TVectorId SMESH_Actor::GetVtkId(int theObjID){
+  if (GetRepresentation() == 0){
+    return GetNodeVtkId(theObjID);
+  }else{
+    return GetElemVtkId(theObjID);
+  }
 }
 
 
-void SMESH_Actor::SetNodeColor(float r,float g,float b)
-{ 
-  actorNodeColor.r = r ;
-  actorNodeColor.g = g ;
-  actorNodeColor.b = b ;
+int SMESH_Actor::GetNodeObjId(int theVtkID){
+  return myPickableActor->GetNodeObjId(theVtkID);
 }
 
-void SMESH_Actor::GetNodeColor(float& r,float& g,float& b)
-{ 
-  r = actorNodeColor.r ;
-  g = actorNodeColor.g ;
-  b = actorNodeColor.b ;
+SALOME_Actor::TVectorId SMESH_Actor::GetNodeVtkId(int theObjID){
+  return myPickableActor->GetNodeVtkId(theObjID);
 }
 
-void SMESH_Actor::SetNodeSize(int size)
-{
-  actorNodeSize = size ;
+
+int SMESH_Actor::GetElemObjId(int theVtkID){
+  return myPickableActor->GetElemObjId(theVtkID);
 }
 
-int SMESH_Actor::GetNodeSize()
-{
-  return actorNodeSize ;
+SALOME_Actor::TVectorId SMESH_Actor::GetElemVtkId(int theObjID){
+  return myPickableActor->GetElemVtkId(theObjID);
 }
 
 
-void SMESH_Actor::AddNode(int idSMESHDSnode,int idVTKnode)
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    ((SMESH_Grid*)DataSource)->AddNode(idSMESHDSnode, idVTKnode);
-  } else 
-    MESSAGE("AddNode() method has been moved to SMESH_Grid class");
+void SMESH_Actor::SetVisibility(int theMode){
+  SALOME_Actor::SetVisibility(theMode);
+  if(GetVisibility()){
+    SetRepresentation(GetRepresentation());
+
+    if(myColorMode != eNone){
+      if(my1DColorMode == e1DHighlited)
+       my1DExtActor->VisibilityOn();
+      else if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
+       myScalarBarActor->VisibilityOn();
+    }
+
+    if(myRepresentation != ePoint)
+      myPickableActor->VisibilityOn();
+
+    my1DActor->VisibilityOn();
+
+    my2DActor->VisibilityOn();
+    my3DActor->VisibilityOn();
+
+    if(myIsPointsLabeled) myPointLabels->VisibilityOn();
+    if(myIsCellsLabeled) myCellsLabels->VisibilityOn();
+  }else{
+    myNodeActor->VisibilityOff();
+    myBaseActor->VisibilityOff();
+
+    my1DActor->VisibilityOff();
+    my1DExtActor->VisibilityOff();
+
+    my2DActor->VisibilityOff();
+    my3DActor->VisibilityOff();
+
+    myScalarBarActor->VisibilityOff();
+    myPointLabels->VisibilityOff();
+    myCellsLabels->VisibilityOff();
+  }
+  Modified();
 }
-void SMESH_Actor::AddElement(int idSMESHDSelement, int idVTKelement)
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    ((SMESH_Grid*)DataSource)->AddElement(idSMESHDSelement, idVTKelement);
-  } else 
-    MESSAGE("AddElement() method has been moved to SMESH_Grid class");
+
+
+void SMESH_Actor::SetRepresentation(int theMode){ 
+  int aNbEdges = myVisualObj->GetNbEntities(SMESH::EDGE);
+  int aNbFaces = myVisualObj->GetNbEntities(SMESH::FACE);
+  int aNbVolumes = myVisualObj->GetNbEntities(SMESH::VOLUME);
+  if(theMode < 0){
+    myRepresentation = eSurface;
+    if(!aNbFaces && !aNbVolumes && aNbEdges){
+      myRepresentation = eEdge;
+    }else if(!aNbFaces && !aNbVolumes && !aNbEdges){
+      myRepresentation = ePoint;
+    }
+  }else{
+    switch(theMode){
+    case eEdge:
+      if(!aNbFaces && !aNbVolumes && !aNbEdges) return;
+      break;
+    case eSurface:
+      if(!aNbFaces && !aNbVolumes) return;
+      break;
+    }    
+    myRepresentation = theMode;
+  }
+
+  if(!GetUnstructuredGrid()->GetNumberOfCells())
+    myRepresentation = ePoint;
+
+  if(myIsShrunk){
+    if(myRepresentation == ePoint){
+      UnShrink();
+      myIsShrunk = true;
+    }else{
+      SetShrink();
+    }      
+  }
+
+  myPickableActor = myBaseActor;
+  myNodeActor->SetVisibility(false);
+  vtkProperty *aProp = NULL, *aBackProp = NULL;
+  SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
+  switch(myRepresentation){
+  case ePoint: 
+    myPickableActor = myNodeActor;
+    aProp = aBackProp = myNodeProp;
+    aReperesent = SMESH_DeviceActor::ePoint;
+    break;
+  case eEdge:
+    aProp = aBackProp = myEdgeProp;
+    aReperesent = SMESH_DeviceActor::eInsideframe;
+    break;
+  case eSurface:
+    aProp = mySurfaceProp;
+    aBackProp = myBackSurfaceProp;
+    aReperesent = SMESH_DeviceActor::eSurface;
+    break;
+  }    
+
+  my2DActor->SetProperty(aProp);
+  my2DActor->SetBackfaceProperty(aBackProp);
+  my2DActor->SetRepresentation(aReperesent);
+  
+  my3DActor->SetProperty(aProp);
+  my3DActor->SetBackfaceProperty(aBackProp);
+  my3DActor->SetRepresentation(aReperesent);
+
+  my1DExtActor->SetVisibility(false);
+  switch(my1DColorMode){
+  case e1DColored: 
+    aProp = aBackProp = my1DProp;
+    if(myRepresentation != ePoint)
+      aReperesent = SMESH_DeviceActor::eInsideframe;
+    break;
+  case e1DHighlited: 
+    my1DExtActor->SetVisibility(true);
+    break;
+  }
+  
+  my1DActor->SetProperty(aProp);
+  my1DActor->SetBackfaceProperty(aBackProp);
+  my1DActor->SetRepresentation(aReperesent);
+  
+  if ( GetPointRepresentation() || !GetUnstructuredGrid()->GetNumberOfCells() || myIsPointsLabeled )
+  {
+    myPickableActor = myNodeActor;
+    myNodeActor->SetVisibility(true);
+  }
+
+  SetMapper(myPickableActor->GetMapper());
+
+  Modified();
 }
 
-void SMESH_Actor::SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK)
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    ((SMESH_Grid*)DataSource)->SetIdsVTKNode(mapVTK);
-  } else 
-    MESSAGE("SetIdsVTKNode() method has been moved to SMESH_Grid class");
+
+void SMESH_Actor::SetPointRepresentation(int theIsPointsVisible){
+  myIsPointsVisible = theIsPointsVisible;
+  SetRepresentation(GetRepresentation());
 }
-void SMESH_Actor::SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS)
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    ((SMESH_Grid*)DataSource)->SetIdsSMESHDSNode(mapSMESHDS);
-  } else 
-    MESSAGE("SetIdsSMESHDSNode() method has been moved to SMESH_Grid class");
+
+
+void SMESH_Actor::UpdateHighlight(){
+  myHighlitableActor->SetVisibility(false);
+  myNodeActor->SetProperty(myNodeProp);
+  if(myPickableActor != myNodeActor)
+    myNodeActor->SetVisibility(false);
+
+  if(ishighlighted){
+    myHighlitableActor->SetProperty(myHighlightProp);
+  }else if(ispreselected){
+    myHighlitableActor->SetProperty(myPreselectProp);
+  }
+
+  if(ishighlighted || ispreselected){
+    if(!GetUnstructuredGrid()->GetNumberOfCells()){
+      myNodeActor->SetProperty(myHighlitableActor->GetProperty());
+      myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
+      myNodeActor->SetVisibility(GetVisibility());
+    }else{
+      myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
+      myHighlitableActor->SetVisibility(GetVisibility());
+    }
+  }
 }
 
-void SMESH_Actor::SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK)
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    ((SMESH_Grid*)DataSource)->SetIdsVTKElement(mapVTK);
-  } else 
-    MESSAGE("SetIdsVTKElement() method has been moved to SMESH_Grid class");
+
+void SMESH_Actor::highlight(Standard_Boolean highlight){
+  ishighlighted = highlight;
+  UpdateHighlight();
 }
-void SMESH_Actor::SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS)
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    ((SMESH_Grid*)DataSource)->SetIdsSMESHDSElement(mapSMESHDS);
-  } else 
-    MESSAGE("SetIdsSMESHDSElement() method has been moved to SMESH_Grid class");
+
+
+void SMESH_Actor::SetPreSelected(Standard_Boolean presel){ 
+  ispreselected = presel; 
+  UpdateHighlight();
 }
 
-int SMESH_Actor::GetIdVTKNode(int idSMESHDSnode)
+
+// From vtkFollower
+int SMESH_Actor::RenderOpaqueGeometry(vtkViewport *vp)
 {
-  if (DataSource->IsA("SMESH_Grid")) {
-    return ((SMESH_Grid*)DataSource)->GetIdVTKNode(idSMESHDSnode);
-  } else {
-    MESSAGE("GetIdVTKNode() method has been moved to SMESH_Grid class");
-    return -1;
-  }
+  if (myPickableActor->GetIsOpaque())
+    {
+    vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
+    this->Render(ren);
+    return 1;
+    }
+  return 0;
 }
-int SMESH_Actor::GetIdVTKElement(int idSMESHDSelement)
+
+
+int SMESH_Actor::RenderTranslucentGeometry(vtkViewport *vp)
 {
-  if (DataSource->IsA("SMESH_Grid")) {
-    return ((SMESH_Grid*)DataSource)->GetIdVTKElement(idSMESHDSelement);
-  } else {
-    MESSAGE("GetIdVTKElement() method has been moved to SMESH_Grid class");
-    return -1;
-  }
+  if (!myPickableActor->GetIsOpaque())
+    {
+    vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
+    this->Render(ren);
+    return 1;
+    }
+  return 0;
+}
+
+
+void SMESH_Actor::Render(vtkRenderer *ren){}
+
 
+void SMESH_Actor::ReleaseGraphicsResources(vtkWindow *renWin){
+  SALOME_Actor::ReleaseGraphicsResources(renWin);
+
+  myPickableActor->ReleaseGraphicsResources(renWin);
 }
 
-int SMESH_Actor::GetIdSMESHDSNode(int idVTKnode)
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    return ((SMESH_Grid*)DataSource)->GetIdSMESHDSNode(idVTKnode);
-  } else {
-    MESSAGE("GetIdSMESHDSNode() method has been moved to SMESH_Grid class");
-    return -1;
-  }
+
+static void GetColor(vtkProperty *theProperty, float& r,float& g,float& b){
+  float* aColor = theProperty->GetColor();
+  r = aColor[0];
+  g = aColor[1];
+  b = aColor[2];
 }
 
-int SMESH_Actor::GetIdSMESHDSElement(int idVTKelement)
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    return ((SMESH_Grid*)DataSource)->GetIdSMESHDSElement(idVTKelement);
-  } else {
-    MESSAGE("AddNode() method has been moved to SMESH_Grid class");
-    return -1;
-  }
+
+void SMESH_Actor::SetOpacity(float theValue){
+  mySurfaceProp->SetOpacity(theValue);
+  myBackSurfaceProp->SetOpacity(theValue);
+  myEdgeProp->SetOpacity(theValue);
+  myNodeProp->SetOpacity(theValue);
+
+  my1DProp->SetOpacity(theValue);
 }
 
-void SMESH_Actor::ClearNode()
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    ((SMESH_Grid*)DataSource)->ClearNode();
-  } else 
-    MESSAGE("ClearNode() method has been moved to SMESH_Grid class");
+
+float SMESH_Actor::GetOpacity(){
+  return mySurfaceProp->GetOpacity();
 }
 
-void SMESH_Actor::ClearElement()
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    ((SMESH_Grid*)DataSource)->ClearElement();
-  } else 
-    MESSAGE("ClearElement() method has been moved to SMESH_Grid class");
+
+void SMESH_Actor::SetSufaceColor(float r,float g,float b){
+  mySurfaceProp->SetColor(r,g,b);
+  Modified();
 }
 
-void SMESH_Actor::RemoveNode(int id)
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    ((SMESH_Grid*)DataSource)->RemoveNode(id);
-  } else 
-    MESSAGE("RemoveNode() method has been moved to SMESH_Grid class");
+void SMESH_Actor::GetSufaceColor(float& r,float& g,float& b){
+  ::GetColor(mySurfaceProp,r,g,b);
 }
-void SMESH_Actor::RemoveElement(int id)
-{
-  if (DataSource->IsA("SMESH_Grid")) {
-    ((SMESH_Grid*)DataSource)->RemoveElement(id);
-  } else 
-    MESSAGE("RemoveElement() method has been moved to SMESH_Grid class");
-}
-
-void SMESH_Actor::setDisplayMode(int thenewmode) {
-  myDisplayMode = thenewmode;
-  if ( myDisplayMode == 1 ) {
-    EdgeDevice->VisibilityOn();
-    EdgeShrinkDevice->VisibilityOff();
-  } else if ( myDisplayMode == 2 ) {
-    EdgeDevice->VisibilityOff();
-    EdgeShrinkDevice->VisibilityOn();
-  } else {
-    EdgeDevice->VisibilityOff();
-    EdgeShrinkDevice->VisibilityOff();
-  }
+
+void SMESH_Actor::SetBackSufaceColor(float r,float g,float b){
+  myBackSurfaceProp->SetColor(r,g,b);
+  Modified();
 }
 
-float SMESH_Actor::GetShrinkFactor()
-{
-  return myShrinkFactor;
+void SMESH_Actor::GetBackSufaceColor(float& r,float& g,float& b){
+  ::GetColor(myBackSurfaceProp,r,g,b);
 }
 
-void SMESH_Actor::SetShrinkFactor(float value )
-{
-  if ( value <= 0.1 ) 
-    value = 0.8;
+void SMESH_Actor::SetEdgeColor(float r,float g,float b){
+  myEdgeProp->SetColor(r,g,b);
+  my1DProp->SetColor(r,g,b);
+  my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
+  Modified();
+}
 
-  myShrinkFactor = value;
+void SMESH_Actor::GetEdgeColor(float& r,float& g,float& b){
+  ::GetColor(myEdgeProp,r,g,b);
 }
 
-void SMESH_Actor::GetChildActors(vtkActorCollection* actors)
-{
-  actors->AddItem(EdgeDevice);
-  actors->AddItem(EdgeShrinkDevice);
+void SMESH_Actor::SetNodeColor(float r,float g,float b){ 
+  myNodeProp->SetColor(r,g,b);
+  Modified();
 }
 
-void SMESH_Actor::SetVisibility(bool visibility) 
-{
-  if ( visibility ) {
-    this->VisibilityOn();
-    if ( myDisplayMode == 1 ) {
-      EdgeDevice->VisibilityOn();
-      EdgeShrinkDevice->VisibilityOff();
-    } else if ( myDisplayMode == 2 ) {
-      EdgeDevice->VisibilityOff();
-      EdgeShrinkDevice->VisibilityOn();
-    } else {
-      EdgeDevice->VisibilityOff();
-      EdgeShrinkDevice->VisibilityOff();
-    }
-  } else {
-    this->VisibilityOff();
-    EdgeDevice->VisibilityOff();
-    EdgeShrinkDevice->VisibilityOff();    
-  }
+void SMESH_Actor::GetNodeColor(float& r,float& g,float& b){ 
+  ::GetColor(myNodeProp,r,g,b);
+}
+
+void SMESH_Actor::SetHighlightColor(float r,float g,float b){ 
+  myHighlightProp->SetColor(r,g,b);
+  Modified();
+}
+
+void SMESH_Actor::GetHighlightColor(float& r,float& g,float& b){ 
+  ::GetColor(myHighlightProp,r,g,b);
+}
+
+void SMESH_Actor::SetPreHighlightColor(float r,float g,float b){ 
+  myPreselectProp->SetColor(r,g,b);
+  Modified();
 }
 
+void SMESH_Actor::GetPreHighlightColor(float& r,float& g,float& b){ 
+  ::GetColor(myPreselectProp,r,g,b);
+}
+
+
+float SMESH_Actor::GetLineWidth(){
+  return myEdgeProp->GetLineWidth();
+}
+
+
+void SMESH_Actor::SetLineWidth(float theVal){
+  myEdgeProp->SetLineWidth(theVal);
+  Modified();
+}
+
+
+void SMESH_Actor::SetNodeSize(float theSize){
+  myNodeProp->SetPointSize(theSize);
+  myHighlightProp->SetPointSize(theSize);
+  myPreselectProp->SetPointSize(theSize);
+
+  my1DExtProp->SetPointSize(theSize);
+  my1DProp->SetPointSize(theSize);
+
+  Modified();
+}
+
+float SMESH_Actor::GetNodeSize(){
+  return myNodeProp->GetPointSize();
+}
+
+int SMESH_Actor::GetObjDimension( const int theObjId )
+{
+  return myVisualObj->GetElemDimension( theObjId );
+}
index ced5ade247e311327a836fa2d81f31dc26cb488e..2cb9628a8d81d2097db2f3f6d30d139f4a5e7e4e 100644 (file)
 #define SMESH_ACTOR_H
 
 #include "SALOME_Actor.h"
+#include "SMESH_Object.h"
 
-// VTK Includes
-#include <vtkActor.h>
-#include <vtkDataSetMapper.h>
-#include <vtkUnstructuredGridReader.h>
+class vtkProperty;
+class vtkShrinkFilter;
+class vtkPolyDataMapper;
+class vtkUnstructuredGrid;
+class vtkMergeFilter;
+class vtkPolyData;
 
-// Open CASCADE Includes
-#include <TColStd_IndexedMapOfInteger.hxx>
-#include <TColStd_DataMapOfIntegerInteger.hxx>
+class vtkMapper;
+class vtkActor2D;
+class vtkMaskPoints;
+class vtkLabeledDataMapper;
+class vtkSelectVisiblePoints;
 
-typedef struct rgbStruct
-{
-  float r;
-  float g;
-  float b;
-} RGBStruct;
+class vtkScalarBarActor;
+class vtkLookupTable;
 
-class SMESH_Actor : public SALOME_Actor {
+class SMESH_DeviceActor;
+class SALOME_ExtractUnstructuredGrid;
 
- public:
-  vtkTypeMacro(SMESH_Actor,SALOME_Actor);
-
-  static SMESH_Actor* New();
 
-  // Description:
-  // This causes the actor to be rendered. It, in turn, will render the actor`s
-  // property and then mapper.
-  virtual void Render(vtkRenderer *, vtkMapper *);
+class SMESH_Actor : public SALOME_Actor{
+  friend class SMESH_VisualObj;
 
-  // Description:
-  // This method is used internally by the rendering process.
-  // We overide the superclass method to properly set the estimated render time.
-  int RenderOpaqueGeometry(vtkViewport *viewport);
-
-  void ShallowCopy(vtkProp *prop);
-
-  void setReader(vtkUnstructuredGridReader* r) ;
-  vtkUnstructuredGridReader* getReader();
+ public:
+  vtkTypeMacro(SMESH_Actor,SALOME_Actor);
+  static SMESH_Actor* New(TVisualObjPtr theVisualObj, 
+                         SMESH::FilterManager_ptr theFilterMgr,
+                         const char* theEntry, 
+                         const char* theName,
+                         int theIsClear);
+  
+  virtual void ReleaseGraphicsResources(vtkWindow *renWin);
+  virtual int RenderOpaqueGeometry(vtkViewport *viewport);
+  virtual int RenderTranslucentGeometry(vtkViewport *viewport);
+  virtual void Render(vtkRenderer *ren);
+
+  virtual void AddToRender(vtkRenderer* theRenderer); 
+  virtual void RemoveFromRender(vtkRenderer* theRenderer);
 
-  // Highlight
   virtual bool hasHighlight() { return true; }  
+  virtual void highlight(Standard_Boolean highlight);  
+  virtual void SetPreSelected(Standard_Boolean presel = Standard_False);
 
-  vtkMapper* getMapper();
+  virtual bool IsInfinitive();  
 
-  void setDisplayMode(int);
+  virtual void SetOpacity(float theValue);
+  virtual float GetOpacity();
 
-  void SetColor(float r,float g,float b);
-  void GetColor(float& r,float& g,float& b);
-  void SetHighlightColor(float r,float g,float b);
-  void GetHighlightColor(float& r,float& g,float& b);
-  void SetPreselectedColor(float r,float g,float b);
-  void GetPreselectedColor(float& r,float& g,float& b);
+  void SetSufaceColor(float r,float g,float b);
+  void GetSufaceColor(float& r,float& g,float& b);
+
+  void SetBackSufaceColor(float r,float g,float b);
+  void GetBackSufaceColor(float& r,float& g,float& b);
 
   void SetEdgeColor(float r,float g,float b);
   void GetEdgeColor(float& r,float& g,float& b);
-  void SetEdgeHighlightColor(float r,float g,float b);
-  void GetEdgeHighlightColor(float& r,float& g,float& b);
-  void SetEdgePreselectedColor(float r,float g,float b);
-  void GetEdgePreselectedColor(float& r,float& g,float& b);
 
   void SetNodeColor(float r,float g,float b);
   void GetNodeColor(float& r,float& g,float& b);
+
+  void SetHighlightColor(float r,float g,float b);
+  void GetHighlightColor(float& r,float& g,float& b);
+
+  void SetPreHighlightColor(float r,float g,float b);
+  void GetPreHighlightColor(float& r,float& g,float& b);
  
-  void SetNodeSize(int size) ;
-  int  GetNodeSize() ;
+  float GetLineWidth();
+  void SetLineWidth(float theVal);
 
+  void SetNodeSize(float size) ;
+  float GetNodeSize() ;
 
-  void ClearNode();
-  void ClearElement();
+  virtual int GetObjId(int theVtkID);
+  virtual TVectorId GetVtkId(int theObjID);
 
-  void RemoveNode(int idSMESHDSnode);
-  void RemoveElement(int idSMESHDSelement);
+  virtual int GetNodeObjId(int theVtkID);
+  virtual TVectorId GetNodeVtkId(int theObjID);
 
-  void AddNode(int idSMESHDSnode, int idVTKnode);
-  void AddElement(int idSMESHDSelement, int idVTKelement);
+  virtual int GetElemObjId(int theVtkID);
+  virtual TVectorId GetElemVtkId(int theObjID);
 
-  int GetIdVTKNode(int idSMESHDSnode);
-  int GetIdVTKElement(int idSMESHDSelement);
+  virtual int GetObjDimension( const int theObjId );
 
-  int GetIdSMESHDSNode(int idVTKnode);
-  int GetIdSMESHDSElement(int idVTKelement);
+  virtual void SetVisibility(int theMode);
 
-  void SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK);
-  void SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS);
+  enum EReperesent { ePoint, eEdge, eSurface};
+  virtual void SetRepresentation(int theMode);
+  void SetPointRepresentation(int theIsPointsVisible);
+  bool GetPointRepresentation(){ return myIsPointsVisible;}
 
-  void SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK);
-  void SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS);
+  virtual vtkPolyData* GetPolyDataInput(); 
+  virtual void SetTransform(SALOME_Transform* theTransform); 
 
-  vtkDataSet* DataSource;
-  vtkActor*   EdgeDevice;
-  vtkActor*   EdgeShrinkDevice;
+  vtkUnstructuredGrid* GetUnstructuredGrid();
+  virtual vtkMapper* GetMapper();
 
   float GetShrinkFactor();
   void  SetShrinkFactor(float value );
 
-  void GetChildActors(vtkActorCollection*);
+  bool IsShrunkable() { return myIsShrinkable;}
+  bool IsShrunk() { return myIsShrunk;}
+  void SetShrink(); 
+  void UnShrink(); 
 
-  void SetVisibility(bool visibility);
+  void SetPointsLabeled(bool theIsPointsLabeled);
+  bool GetPointsLabeled(){ return myIsPointsLabeled;}
 
- protected:
+  void SetCellsLabeled(bool theIsCellsLabeled);
+  bool GetCellsLabeled(){ return myIsCellsLabeled;}
 
-  SMESH_Actor();
-  ~SMESH_Actor();
-  SMESH_Actor(const SMESH_Actor&) {};
-  void operator=(const SMESH_Actor&) {};
+  enum eControl{eNone, eLengthEdges, eFreeBorders, eMultiConnection, 
+               eArea, eTaper, eAspectRatio, eMinimumAngle, eWarping, eSkew};
+  void SetControlMode(eControl theMode);
+  eControl GetControlMode(){ return myColorMode;}
+
+  enum e1DControl{e1DNone, e1DColored, e1DHighlited};
+  e1DControl Get1DControlMode(){ return my1DColorMode;}
 
-  vtkUnstructuredGridReader* myReader;
+  vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
 
-  float myShrinkFactor;
+  TVisualObjPtr GetObject() { return myVisualObj;}
 
-  RGBStruct edgeColor;
-  RGBStruct edgeHighlightColor;
-  RGBStruct edgePreselectedColor;
+ protected:
+  TVisualObjPtr myVisualObj;
+
+  SMESH::FilterManager_var myFilterMgr;
+  vtkScalarBarActor* myScalarBarActor;
+  vtkLookupTable* myLookupTable;
+
+  vtkProperty* mySurfaceProp;
+  vtkProperty* myBackSurfaceProp;
+  vtkProperty* myEdgeProp;
+  vtkProperty* myNodeProp;
+
+  SMESH_DeviceActor* myBaseActor;
+  SMESH_DeviceActor* myNodeActor;
+  SMESH_DeviceActor* myPickableActor;
+
+  vtkProperty* myHighlightProp;
+  vtkProperty* myPreselectProp;
+  SMESH_DeviceActor* myHighlitableActor;
+
+  eControl myColorMode;
+  SMESH_DeviceActor* my2DActor;
+  SMESH_DeviceActor* my3DActor;
+  SMESH_DeviceActor* myControlActor;
+
+  e1DControl my1DColorMode;
+  vtkProperty* my1DProp;
+  SMESH_DeviceActor* my1DActor;
+  vtkProperty* my1DExtProp;
+  SMESH_DeviceActor* my1DExtActor;
+
+  bool myIsPointsVisible;
+
+  bool myIsShrinkable;
+  bool myIsShrunk;
+  
+  bool myIsPointsLabeled;
+  vtkUnstructuredGrid* myPointsNumDataSet;
+  vtkActor2D *myPointLabels;
+  vtkMaskPoints* myPtsMaskPoints;
+  vtkLabeledDataMapper* myPtsLabeledDataMapper;
+  vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
+
+  bool myIsCellsLabeled;
+  vtkUnstructuredGrid* myCellsNumDataSet;
+  vtkActor2D *myCellsLabels;
+  vtkMaskPoints* myClsMaskPoints;
+  vtkCellCenters* myCellCenters;
+  vtkLabeledDataMapper* myClsLabeledDataMapper;
+  vtkSelectVisiblePoints* myClsSelectVisiblePoints;
 
-  RGBStruct actorColor;
-  RGBStruct actorHighlightColor;
-  RGBStruct actorPreselectedColor;
+  SMESH_Actor();
+  ~SMESH_Actor();
 
-  RGBStruct actorNodeColor; // LPN
-  int       actorNodeSize;  // LPN
+  void Init(TVisualObjPtr theVisualObj, 
+           SMESH::FilterManager_ptr theFilterMgr,
+           const char* theEntry, 
+           const char* theName,
+           int theIsClear);
+
+  void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid);
+  void SetIsShrunkable(bool theShrunkable);
+  void UpdateHighlight();
+
+ private:
+  // hide the two parameter Render() method from the user and the compiler.
+  virtual void Render(vtkRenderer *, vtkMapper *) {};
+  virtual void ShallowCopy(vtkProp *prop);
+  virtual void SetMapper(vtkMapper *);
+  static SMESH_Actor* New();
 
+  // Not implemented.
+  SMESH_Actor(const SMESH_Actor&);  
+  void operator=(const SMESH_Actor&);
 };
+
+
 #endif //SMESH_ACTOR_H
index 5c3e9abd99e88dcbc3f7451c80aa0836b6caa951..20bf98ce4c94defa2c1271012c1e32febd5d0568 100644 (file)
@@ -123,7 +123,7 @@ EXPORT_HEADERS= \
 #SMDS_MeshNodeIDFactory.hxx
 
 # additionnal information to compil and link file
-CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
 CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome
 LDFLAGS  += -L${KERNEL_ROOT_DIR}/lib/salome
 
index 868310b51967d338060b24aaae358a0ff2d1799d..84916246b8c302dee16fa30b73ae0b8fd9bc5845 100644 (file)
@@ -38,7 +38,6 @@ class SMDS_EdgePosition:public SMDS_Position
        SMDS_TypeOfPosition GetTypeOfPosition() const;
        void SetUParameter(double aUparam);
        double GetUParameter() const;
-        ~SMDS_EdgePosition();
 
   private:
 
index 0e9243d3f4cb5faceb595027bca872aed447bbe2..0a53bba6e1a2bec73c6a4c7f0af1e537169d2ef5 100644 (file)
@@ -55,39 +55,44 @@ SMDSAbs_ElementType SMDS_FaceOfEdges::GetType() const
        return SMDSAbs_Face;
 }
 
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_FaceOfEdges::
+class SMDS_FaceOfEdges_MyIterator:public SMDS_ElemIterator
+{
+  const vector<const SMDS_MeshEdge*>& mySet;
+  int index;
+ public:
+  SMDS_FaceOfEdges_MyIterator(const vector<const SMDS_MeshEdge*>& s):
+    mySet(s),index(0) {}
+
+  bool more()
+  {
+    return index<mySet.size();
+  }
+
+  const SMDS_MeshElement* next()
+  {
+    index++;
+    return mySet[index-1];
+  }    
+};
+SMDS_ElemIteratorPtr SMDS_FaceOfEdges::
        elementsIterator(SMDSAbs_ElementType type) const
 {
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
-       {
-               const vector<const SMDS_MeshEdge*>& mySet;
-               int index;
-         public:
-               MyIterator(const vector<const SMDS_MeshEdge*>& s):mySet(s),index(0)
-               {}
-
-               bool more()
-               {
-                       return index<mySet.size();
-               }
-
-               const SMDS_MeshElement* next()
-               {
-                       index++;
-                       return mySet[index-1];
-               }       
-       };
-
        switch(type)
        {
-       case SMDSAbs_Face:return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
-       case SMDSAbs_Edge:return new MyIterator(myEdges);
-       default:return new SMDS_IteratorOfElements(this,type,new MyIterator(myEdges));
+       case SMDSAbs_Face:
+          return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
+       case SMDSAbs_Edge:
+          return SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges));
+       default:
+          return SMDS_ElemIteratorPtr
+            (new SMDS_IteratorOfElements
+             (this,type, SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges))));
        }
 }
 
-SMDS_FaceOfEdges::SMDS_FaceOfEdges(SMDS_MeshEdge* edge1, SMDS_MeshEdge* edge2,
-       SMDS_MeshEdge* edge3)
+SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
+                                   const SMDS_MeshEdge* edge2,
+                                   const SMDS_MeshEdge* edge3)
 {
        myEdges.resize(3);
        myEdges[0]=edge1;
@@ -95,8 +100,10 @@ SMDS_FaceOfEdges::SMDS_FaceOfEdges(SMDS_MeshEdge* edge1, SMDS_MeshEdge* edge2,
        myEdges[2]=edge3;
 }
 
-SMDS_FaceOfEdges::SMDS_FaceOfEdges(SMDS_MeshEdge* edge1, SMDS_MeshEdge* edge2,
-       SMDS_MeshEdge* edge3, SMDS_MeshEdge* edge4)
+SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
+                                   const SMDS_MeshEdge* edge2,
+                                   const SMDS_MeshEdge* edge3,
+                                   const SMDS_MeshEdge* edge4)
 {
        myEdges.resize(4);
        myEdges[0]=edge1;
@@ -108,7 +115,7 @@ SMDS_FaceOfEdges::SMDS_FaceOfEdges(SMDS_MeshEdge* edge1, SMDS_MeshEdge* edge2,
 /*bool operator<(const SMDS_FaceOfEdges& f1, const SMDS_FaceOfEdges& f2)
 {
        set<SMDS_MeshNode> set1,set2;
-       SMDS_Iterator<const SMDS_MeshElement*> * it;
+       SMDS_ElemIteratorPtr it;
        const SMDS_MeshNode * n;
 
        it=f1.nodesIterator();
index 978ad5df60aa55a0d9660f181acba45136e17ae0..4140207558988b6fdeba3bcd2b648592c4957f55 100644 (file)
@@ -31,10 +31,13 @@ class SMDS_FaceOfEdges:public SMDS_MeshFace
 {
   public:
        void Print(ostream & OS) const;
-       SMDS_FaceOfEdges(SMDS_MeshEdge* edge1, SMDS_MeshEdge* edge2,
-               SMDS_MeshEdge* edge3);
-       SMDS_FaceOfEdges(SMDS_MeshEdge* edge1, SMDS_MeshEdge* edge2,
-               SMDS_MeshEdge* edge3, SMDS_MeshEdge* edge4);
+       SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
+                         const SMDS_MeshEdge* edge2,
+                         const SMDS_MeshEdge* edge3);
+       SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
+                         const SMDS_MeshEdge* edge2,
+                         const SMDS_MeshEdge* edge3,
+                         const SMDS_MeshEdge* edge4);
                
        SMDSAbs_ElementType GetType() const;
        int NbEdges() const;
@@ -42,7 +45,7 @@ class SMDS_FaceOfEdges:public SMDS_MeshFace
 //     friend bool operator<(const SMDS_FaceOfEdges& e1, const SMDS_FaceOfEdges& e2);
 
   protected:
-       SMDS_Iterator<const SMDS_MeshElement *> *
+       SMDS_ElemIteratorPtr
                elementsIterator(SMDSAbs_ElementType type) const;
 
   private:
index 9a9a945f9e4409e4708d66a4dda9de3fa6c38803..abc9c9d60b853ce6a801740552b44561db678889 100644 (file)
@@ -56,42 +56,47 @@ void SMDS_FaceOfNodes::Print(ostream & OS) const
        OS << myNodes[i] << ") " << endl;
 }
 
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_FaceOfNodes::
+class SMDS_FaceOfNodes_MyIterator:public SMDS_ElemIterator
+{
+  const vector<const SMDS_MeshNode*>& mySet;
+  int index;
+ public:
+  SMDS_FaceOfNodes_MyIterator(const vector<const SMDS_MeshNode*>& s):
+    mySet(s),index(0) {}
+
+  bool more()
+  {
+    return index<mySet.size();
+  }
+
+  const SMDS_MeshElement* next()
+  {
+    index++;
+    return mySet[index-1];
+  }    
+};
+SMDS_ElemIteratorPtr SMDS_FaceOfNodes::
        elementsIterator(SMDSAbs_ElementType type) const
 {
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
-       {
-               const vector<const SMDS_MeshNode*>& mySet;
-               int index;
-         public:
-               MyIterator(const vector<const SMDS_MeshNode*>& s):mySet(s),index(0)
-               {}
-
-               bool more()
-               {
-                       return index<mySet.size();
-               }
-
-               const SMDS_MeshElement* next()
-               {
-                       index++;
-                       return mySet[index-1];
-               }       
-       };
-
-       switch(type)
-       {
-       case SMDSAbs_Face:return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
-       case SMDSAbs_Node:return new MyIterator(myNodes);
-       case SMDSAbs_Edge:
-               MESSAGE("Error : edge iterator for SMDS_FaceOfNodes not implemented");
-               break;
-       default:return new SMDS_IteratorOfElements(this,type,new MyIterator(myNodes));
-       }
+  switch(type)
+  {
+  case SMDSAbs_Face:
+    return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
+  case SMDSAbs_Node:
+    return SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes));
+  case SMDSAbs_Edge:
+    MESSAGE("Error : edge iterator for SMDS_FaceOfNodes not implemented");
+    break;
+  default:
+    return SMDS_ElemIteratorPtr
+      (new SMDS_IteratorOfElements
+       (this,type,SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes))));
+  }
 }
 
-SMDS_FaceOfNodes::SMDS_FaceOfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2,
-       SMDS_MeshNode* node3)
+SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
+                                   const SMDS_MeshNode* node2,
+                                   const SMDS_MeshNode* node3)
 {
        myNodes.resize(3);
        myNodes[0]=node1;
@@ -99,8 +104,10 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2,
        myNodes[2]=node3;
 }
 
-SMDS_FaceOfNodes::SMDS_FaceOfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2,
-       SMDS_MeshNode* node3, SMDS_MeshNode* node4)
+SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
+                                   const SMDS_MeshNode* node2,
+                                   const SMDS_MeshNode* node3,
+                                   const SMDS_MeshNode* node4)
 {
        myNodes.resize(4);
        myNodes[0]=node1;
@@ -112,7 +119,7 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2,
 /*bool operator<(const SMDS_FaceOfNodes& f1, const SMDS_FaceOfNodes& f2)
 {
        set<SMDS_MeshNode> set1,set2;
-       SMDS_Iterator<const SMDS_MeshElement*> * it;
+       SMDS_ElemIteratorPtr it;
        const SMDS_MeshNode * n;
 
        it=f1.nodesIterator();
index 809ee5f1c1710e8f9051f662a23e39a615216c4e..9a2adad0b80f29320b41f7830f5419f169a7aceb 100644 (file)
@@ -31,16 +31,19 @@ class SMDS_FaceOfNodes:public SMDS_MeshFace
 {
   public:
        void Print(ostream & OS) const;
-       SMDS_FaceOfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2,
-               SMDS_MeshNode* node3);
-       SMDS_FaceOfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2,
-               SMDS_MeshNode* node3, SMDS_MeshNode* node4);
+       SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
+                         const SMDS_MeshNode* node2,
+                         const SMDS_MeshNode* node3);
+       SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
+                         const SMDS_MeshNode* node2,
+                         const SMDS_MeshNode* node3,
+                         const SMDS_MeshNode* node4);
                
        int NbEdges() const;
        int NbFaces() const;
        int NbNodes() const;
   protected:
-       SMDS_Iterator<const SMDS_MeshElement *> *
+       SMDS_ElemIteratorPtr
                elementsIterator(SMDSAbs_ElementType type) const;
 
   private:
index cebd29a119ddb59df55f096684da7b670a867d21..8682ad7708ad3e9f9d2b38af143559fcf6e8b438 100644 (file)
 /// 5,1 and 7,3 are an edges.
 ///////////////////////////////////////////////////////////////////////////////
 SMDS_HexahedronOfNodes::SMDS_HexahedronOfNodes(
-               SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2,
-               SMDS_MeshNode * node3,
-               SMDS_MeshNode * node4,
-               SMDS_MeshNode * node5,
-               SMDS_MeshNode * node6,
-               SMDS_MeshNode * node7,
-               SMDS_MeshNode * node8)
+               const SMDS_MeshNode * node1,
+               const SMDS_MeshNode * node2,
+               const SMDS_MeshNode * node3,
+               const SMDS_MeshNode * node4,
+               const SMDS_MeshNode * node5,
+               const SMDS_MeshNode * node6,
+               const SMDS_MeshNode * node7,
+               const SMDS_MeshNode * node8)
 {
        myNodes[0]=node1;
        myNodes[1]=node2;
@@ -75,18 +75,18 @@ int SMDS_HexahedronOfNodes::NbEdges() const
        return 12;
 }
 
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_HexahedronOfNodes::
+SMDS_ElemIteratorPtr SMDS_HexahedronOfNodes::
        elementsIterator(SMDSAbs_ElementType type) const
 {
-       switch(type)
-       {
-       case SMDSAbs_Volume:
-               return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
-       case SMDSAbs_Node:
-               return new SMDS_IteratorOfArray<const SMDS_MeshElement *, 8,
-                       const SMDS_MeshNode*>(myNodes);
-       default: MESSAGE("ERROR : Iterator not implemented");
-       }
+  switch(type)
+  {
+  case SMDSAbs_Volume:
+    return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
+  case SMDSAbs_Node:
+    return SMDS_ElemIteratorPtr (new SMDS_IteratorOfArray<const SMDS_MeshElement *, 8,
+                                 const SMDS_MeshNode*>(myNodes));
+  default: MESSAGE("ERROR : Iterator not implemented");
+  }
 }
 
 SMDSAbs_ElementType SMDS_HexahedronOfNodes::GetType() const
index 2e3f22f4a7f1a397cd040e9f990a4d24d4ae4f6e..03cb242e283a064675999365e28693c9d217d877 100644 (file)
@@ -36,14 +36,14 @@ class SMDS_HexahedronOfNodes:public SMDS_MeshVolume
        
   public:
        SMDS_HexahedronOfNodes(
-               SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2,
-               SMDS_MeshNode * node3,
-               SMDS_MeshNode * node4,
-               SMDS_MeshNode * node5,
-               SMDS_MeshNode * node6,
-               SMDS_MeshNode * node7,
-               SMDS_MeshNode * node8);
+               const SMDS_MeshNode * node1,
+               const SMDS_MeshNode * node2,
+               const SMDS_MeshNode * node3,
+               const SMDS_MeshNode * node4,
+               const SMDS_MeshNode * node5,
+               const SMDS_MeshNode * node6,
+               const SMDS_MeshNode * node7,
+               const SMDS_MeshNode * node8);
 
        void Print(ostream & OS) const;
        int NbFaces() const;
@@ -51,7 +51,7 @@ class SMDS_HexahedronOfNodes:public SMDS_MeshVolume
        int NbEdges() const;
        SMDSAbs_ElementType GetType() const;    
   protected:
-       SMDS_Iterator<const SMDS_MeshElement *> *
+       SMDS_ElemIteratorPtr
                elementsIterator(SMDSAbs_ElementType type) const;
        const SMDS_MeshNode * myNodes[8];
 };
index 144f075d13fbd1f3bc130cc245ed71abab4ad277..264438c7dd42fe8793bf424a5d35df14a2a6a25c 100644 (file)
@@ -36,7 +36,11 @@ template<typename VALUE> class SMDS_Iterator
        virtual VALUE next()=0;
        
        /// Delete the current element and step to the next one
-       virtual void remove(){};
+       virtual void remove(){}
+       
+       /// Provide virtual destructor just for case if some derived iterator
+        /// must have a destructor
+       virtual ~SMDS_Iterator(){}
 };
 
 #endif
index 3f1a392fd231843b441e1695ceb4b6aedb2d7292..c18f24d25a837a44bdd34cafc0472119cf03d63a 100644 (file)
@@ -27,7 +27,6 @@ bool SMDS_IteratorOfElements::subMore()
        {
                if(t1Iterator->more())
                {
-                       if(t2Iterator!=NULL) delete t2Iterator;
                        t2Iterator=t1Iterator->next()->elementsIterator(myType);
                        return subMore();
                }
@@ -39,13 +38,8 @@ bool SMDS_IteratorOfElements::subMore()
 const SMDS_MeshElement * SMDS_IteratorOfElements::subNext()
 {
        if((t2Iterator==NULL)||(!t2Iterator->more()))
-       {
                if(t1Iterator->more())
-               {
-                       if(t2Iterator!=NULL) delete t2Iterator;
                        t2Iterator=t1Iterator->next()->elementsIterator(myType);
-               }
-       }
        return t2Iterator->next();
 }
 
@@ -54,9 +48,12 @@ const SMDS_MeshElement * SMDS_IteratorOfElements::subNext()
 /// to the element element. it is the iterator to get connectivity of element
 //////////////////////////////////////////////////////////////////////////////
 SMDS_IteratorOfElements::SMDS_IteratorOfElements(const SMDS_MeshElement * element,
-       SMDSAbs_ElementType type, SMDS_Iterator<const SMDS_MeshElement *>* it)
-       :t1Iterator(it), t2Iterator(NULL), myType(type), myElement(element),
-       myProxyElement(NULL)
+                                                 SMDSAbs_ElementType type,
+                                                 const SMDS_ElemIteratorPtr& it)
+     : t1Iterator(it),
+       t2Iterator(SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL)),
+       myType(type), myElement(element),
+       myProxyElement(NULL)
 {
        while(subMore())
                alreadyReturnedElements.insert(subNext());
@@ -81,7 +78,7 @@ bool SMDS_IteratorOfElements::more()
 
                        if(myReverseIteration)
                        {
-                               SMDS_Iterator<const SMDS_MeshElement*> * it=
+                               SMDS_ElemIteratorPtr it=
                                        myProxyElement->elementsIterator(myElement->GetType());
                                while(it->more())
                                {                               
@@ -103,9 +100,3 @@ const SMDS_MeshElement * SMDS_IteratorOfElements::next()
        myProxyElement=NULL;
        return e;
 }
-
-SMDS_IteratorOfElements::~SMDS_IteratorOfElements()
-{
-       delete t1Iterator;
-       if(t2Iterator!=NULL) delete t2Iterator;
-}
index 5d2d3700c0e4c52c986e4a4477e310c233e6e3e7..bb4d94ebe416d48f2d0dd568caeab06e19e921f6 100644 (file)
@@ -25,7 +25,7 @@
 
 using namespace std;
 
-class SMDS_IteratorOfElements:public SMDS_Iterator<const SMDS_MeshElement *>
+class SMDS_IteratorOfElements:public SMDS_ElemIterator
 {
   public:
 /////////////////////////////////////////////////////////////////////////////
@@ -33,14 +33,14 @@ class SMDS_IteratorOfElements:public SMDS_Iterator<const SMDS_MeshElement *>
 /// to the element element. it is the iterator to get connectivity of element
 //////////////////////////////////////////////////////////////////////////////
        SMDS_IteratorOfElements(const SMDS_MeshElement * element,
-               SMDSAbs_ElementType type, SMDS_Iterator<const SMDS_MeshElement *>* it);
+                                SMDSAbs_ElementType type,
+                                const SMDS_ElemIteratorPtr& it);
        bool more();
        const SMDS_MeshElement * next();
-       ~SMDS_IteratorOfElements();
 
   private:
-       SMDS_Iterator<const SMDS_MeshElement *> * t2Iterator;
-       SMDS_Iterator<const SMDS_MeshElement *> * t1Iterator;
+       SMDS_ElemIteratorPtr t2Iterator;
+       SMDS_ElemIteratorPtr t1Iterator;
        SMDSAbs_ElementType myType;     
        const SMDS_MeshElement * myProxyElement;
        const SMDS_MeshElement * myElement;             
index ca5172d4ea189edb913ac332e424e4c78f930e2c..93c4cf56832050cd9ba9b2691bd81d08dc316a69 100644 (file)
@@ -74,7 +74,7 @@ SMDS_Mesh *SMDS_Mesh::AddSubMesh()
 
 SMDS_MeshNode * SMDS_Mesh::AddNode(double x, double y, double z)
 {
-       return AddNodeWithID(x,y,z,myNodeIDFactory->GetFreeID());
+  return SMDS_Mesh::AddNodeWithID(x,y,z,myNodeIDFactory->GetFreeID());
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -84,18 +84,15 @@ SMDS_MeshNode * SMDS_Mesh::AddNode(double x, double y, double z)
 ///////////////////////////////////////////////////////////////////////////////
 SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID)
 {
-       // find the MeshNode corresponding to ID
-       const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID);
-
-       if (node == NULL)
-       {
-               SMDS_MeshNode * node=new SMDS_MeshNode(x, y, z);
-               myNodes.insert(node);
-               myNodeIDFactory->BindID(ID,node);
-               return node;
-       }
-       else
-               return NULL;
+  // find the MeshNode corresponding to ID
+  const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID);
+  if(!node){
+    SMDS_MeshNode * node=new SMDS_MeshNode(x, y, z);
+    myNodes.insert(node);
+    myNodeIDFactory->BindID(ID,node);
+    return node;
+  }else
+    return NULL;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -105,10 +102,10 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID)
 
 SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(int idnode1, int idnode2, int ID) 
 {
-       SMDS_MeshNode * node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
-       SMDS_MeshNode * node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
-       if((node1==NULL)||(node2==NULL)) return NULL;
-       return AddEdgeWithID(node1, node2, ID);
+  SMDS_MeshNode * node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+  SMDS_MeshNode * node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+  if(!node1 || !node2) return NULL;
+  return SMDS_Mesh::AddEdgeWithID(node1, node2, ID);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -117,9 +114,9 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(int idnode1, int idnode2, int ID)
 ///////////////////////////////////////////////////////////////////////////////
 
 SMDS_MeshEdge* SMDS_Mesh::AddEdge(const SMDS_MeshNode * node1,
-       const SMDS_MeshNode * node2)
+                                 const SMDS_MeshNode * node2)
 {
-       return AddEdgeWithID(node1, node2, myElementIDFactory->GetFreeID());
+  return SMDS_Mesh::AddEdgeWithID(node1, node2, myElementIDFactory->GetFreeID());
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -127,30 +124,28 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdge(const SMDS_MeshNode * node1,
 /// @param idnode1 ID of the first node
 /// @param idnode2 ID of the second node
 /// @param ID ID of the edge to create
-/// @return The created edge or NULL if an edge with this ID already exists or
+/// @return The created edge or NULL if an element with this ID already exists or
 /// if input nodes are not found.
 ///////////////////////////////////////////////////////////////////////////////
 
 SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2, int ID)
-{
-       SMDS_MeshNode *node1,*node2;
-       node1=const_cast<SMDS_MeshNode*>(n1);
-       node2=const_cast<SMDS_MeshNode*>(n2);
-
-       SMDS_MeshEdge * edge=new SMDS_MeshEdge(node1,node2);
-       if(myElementIDFactory->BindID(ID, edge))
-       {
-               node1->AddInverseElement(edge);
-               node2->AddInverseElement(edge);         
-               myEdges.insert(edge);
-               return edge;
-       } 
-       else
-       {
-               delete edge;
-               return NULL;
-       }
+                                       const SMDS_MeshNode * n2, 
+                                       int ID)
+{
+  SMDS_MeshEdge * edge=new SMDS_MeshEdge(n1,n2);
+  if(myElementIDFactory->BindID(ID, edge)) {
+    SMDS_MeshNode *node1,*node2;
+    node1=const_cast<SMDS_MeshNode*>(n1);
+    node2=const_cast<SMDS_MeshNode*>(n2);
+    node1->AddInverseElement(edge);
+    node2->AddInverseElement(edge);            
+    myEdges.insert(edge);
+    return edge;
+  } 
+  else {
+    delete edge;
+    return NULL;
+  }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -159,81 +154,73 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
 ///////////////////////////////////////////////////////////////////////////////
 
 SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshNode * n1,
-       const SMDS_MeshNode * n2,
-       const SMDS_MeshNode * n3)
+                                 const SMDS_MeshNode * n2,
+                                 const SMDS_MeshNode * n3)
 {
-       return AddFaceWithID(n1,n2,n3, myElementIDFactory->GetFreeID());
+  return SMDS_Mesh::AddFaceWithID(n1,n2,n3, myElementIDFactory->GetFreeID());
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-/// Add a quadrangle defined by its nodes IDs
+/// Add a triangle defined by its nodes IDs
 ///////////////////////////////////////////////////////////////////////////////
 
 SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(int idnode1, int idnode2, int idnode3, int ID)
 {
-       SMDS_MeshNode * node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
-       SMDS_MeshNode * node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
-       SMDS_MeshNode * node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
-       if((node1==NULL)||(node2==NULL)||(node3==NULL)) return NULL;
-       return AddFaceWithID(node1, node2, node3, ID);  
+  SMDS_MeshNode * node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+  SMDS_MeshNode * node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+  SMDS_MeshNode * node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
+  if(!node1 || !node2 || !node3) return NULL;
+  return SMDS_Mesh::AddFaceWithID(node1, node2, node3, ID);    
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-/// Add a quadrangle defined by its nodes
+/// Add a triangle defined by its nodes
 ///////////////////////////////////////////////////////////////////////////////
 
-SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(
-       const SMDS_MeshNode * n1,
-       const SMDS_MeshNode * n2,
-       const SMDS_MeshNode * n3, int ID)
+SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
+                                        const SMDS_MeshNode * n2,
+                                        const SMDS_MeshNode * n3,
+                                        int ID)
 {
-       SMDS_MeshNode *node1, *node2, *node3;
-       node1=const_cast<SMDS_MeshNode*>(n1),
-       node2=const_cast<SMDS_MeshNode*>(n2),
-       node3=const_cast<SMDS_MeshNode*>(n3);
-       SMDS_MeshFace * face=createTriangle(node1, node2, node3);
+  SMDS_MeshFace * face=createTriangle(n1, n2, n3);
 
-       if(myElementIDFactory->BindID(ID, face))
-       {
-               node1->AddInverseElement(face);
-               node2->AddInverseElement(face);
-        node3->AddInverseElement(face);
-               return face;
-       }       
-       else
-       {
-               RemoveFace(face);
-               return NULL;
-       }
+  if (!registerElement(ID, face)) {
+    RemoveElement(face, false);
+    face = NULL;
+  }
+  return face;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-/// Add a triangle defined by its nodes. An ID is automatically affected to the
+/// Add a quadrangle defined by its nodes. An ID is automatically affected to the
 /// created face
 ///////////////////////////////////////////////////////////////////////////////
 
 SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshNode * n1,
-       const SMDS_MeshNode * n2,
-       const SMDS_MeshNode * n3,
-       const SMDS_MeshNode * n4)
+                                 const SMDS_MeshNode * n2,
+                                 const SMDS_MeshNode * n3,
+                                 const SMDS_MeshNode * n4)
 {
-       return AddFaceWithID(n1,n2,n3, n4, myElementIDFactory->GetFreeID());
+  return SMDS_Mesh::AddFaceWithID(n1,n2,n3, n4, myElementIDFactory->GetFreeID());
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 /// Add a quadrangle defined by its nodes IDs
 ///////////////////////////////////////////////////////////////////////////////
 
-SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(int idnode1, int idnode2, int idnode3,
-       int idnode4, int ID)
+SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(int idnode1, 
+                                       int idnode2, 
+                                       int idnode3,
+                                       int idnode4, 
+                                       int ID)
 {
-       SMDS_MeshNode *node1, *node2, *node3, *node4;
-       node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
-       node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
-       node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
-       node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
-       if((node1==NULL)||(node2==NULL)||(node3==NULL)) return NULL;
-       return AddFaceWithID(node1, node2, node3, node4, ID);   
+  SMDS_MeshNode *node1, *node2, *node3, *node4;
+  node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+  node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+  node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
+  node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
+  if(!node1 || !node2 || !node3 || !node4) return NULL;
+  return SMDS_Mesh::AddFaceWithID(node1, node2, node3, node4, ID);     
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -241,29 +228,91 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(int idnode1, int idnode2, int idnode3,
 ///////////////////////////////////////////////////////////////////////////////
 
 SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
-       const SMDS_MeshNode * n2, const SMDS_MeshNode * n3,
-       const SMDS_MeshNode * n4, int ID)
+                                        const SMDS_MeshNode * n2,
+                                        const SMDS_MeshNode * n3,
+                                        const SMDS_MeshNode * n4,
+                                        int ID)
 {
-       SMDS_MeshNode *node1, *node2, *node3, *node4;
-       node1=const_cast<SMDS_MeshNode*>(n1),
-       node2=const_cast<SMDS_MeshNode*>(n2),
-       node3=const_cast<SMDS_MeshNode*>(n3);
-       node4=const_cast<SMDS_MeshNode*>(n4);
-       SMDS_MeshFace * face=createQuadrangle(node1, node2, node3, node4);
+  SMDS_MeshFace * face=createQuadrangle(n1, n2, n3, n4);
 
-       if(myElementIDFactory->BindID(ID, face))
-       {
-               node1->AddInverseElement(face);
-               node2->AddInverseElement(face);
-        node3->AddInverseElement(face);
-        node4->AddInverseElement(face);
-               return face;
-       }       
-       else
-       {
-               RemoveFace(face);
-               return NULL;
-       }
+  if (!registerElement(ID, face)) {
+    RemoveElement(face, false);
+    face = NULL;
+  }
+  return face;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a triangle defined by its edges. An ID is automatically assigned to the
+/// Created face
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshEdge * e1,
+                                  const SMDS_MeshEdge * e2,
+                                  const SMDS_MeshEdge * e3)
+{
+  if (!hasConstructionEdges())
+    return NULL;
+  return AddFaceWithID(e1,e2,e3, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a triangle defined by its edges
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1,
+                                        const SMDS_MeshEdge * e2,
+                                        const SMDS_MeshEdge * e3,
+                                        int ID)
+{
+  if (!hasConstructionEdges())
+    return NULL;
+  SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3);
+  myFaces.insert(face);
+
+  if (!registerElement(ID, face)) {
+    RemoveElement(face, false);
+    face = NULL;
+  }
+  return face;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a quadrangle defined by its edges. An ID is automatically assigned to the
+/// Created face
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshEdge * e1,
+                                  const SMDS_MeshEdge * e2,
+                                  const SMDS_MeshEdge * e3,
+                                  const SMDS_MeshEdge * e4)
+{
+  if (!hasConstructionEdges())
+    return NULL;
+  return AddFaceWithID(e1,e2,e3,e4, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a quadrangle defined by its edges
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1,
+                                        const SMDS_MeshEdge * e2,
+                                        const SMDS_MeshEdge * e3,
+                                        const SMDS_MeshEdge * e4,
+                                        int ID)
+{
+  if (!hasConstructionEdges())
+    return NULL;
+  SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3,e4);
+  myFaces.insert(face);
+
+  if (!registerElement(ID, face))
+  {
+    RemoveElement(face, false);
+    face = NULL;
+  }
+  return face;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -272,32 +321,36 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
 ///////////////////////////////////////////////////////////////////////////////
 
 SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
-       const SMDS_MeshNode * n2, const SMDS_MeshNode * n3,
-       const SMDS_MeshNode * n4)
+                                     const SMDS_MeshNode * n2, 
+                                     const SMDS_MeshNode * n3,
+                                     const SMDS_MeshNode * n4)
 {
-       int ID = myElementIDFactory->GetFreeID();
-       SMDS_MeshVolume * v = AddVolumeWithID(n1, n2, n3, n4, ID);
-       if(v==NULL) myElementIDFactory->ReleaseID(ID);
-       return v;
+  int ID = myElementIDFactory->GetFreeID();
+  SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
+  if(v==NULL) myElementIDFactory->ReleaseID(ID);
+  return v;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 ///Create a new tetrahedron and add it to the mesh. 
 ///@param ID The ID of the new volume
-///@return The created tetrahedron or NULL if an edge with this ID already exists
+///@return The created tetrahedron or NULL if an element with this ID already exists
 ///or if input nodes are not found.
 ///////////////////////////////////////////////////////////////////////////////
 
-SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, int idnode2,
-       int idnode3, int idnode4, int ID)
+SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, 
+                                            int idnode2,
+                                            int idnode3, 
+                                            int idnode4, 
+                                            int ID)
 {
-       SMDS_MeshNode *node1, *node2, *node3, *node4;
-       node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
-       node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
-       node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
-       node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
-       if((node1==NULL)||(node2==NULL)||(node3==NULL)||(node4=NULL)) return NULL;
-       return AddVolumeWithID(node1, node2, node3, node4, ID);
+  SMDS_MeshNode *node1, *node2, *node3, *node4;
+  node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+  node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+  node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
+  node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
+  if(!node1 || !node2 || !node3 || !node4) return NULL;
+  return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, ID);
 }
        
 ///////////////////////////////////////////////////////////////////////////////
@@ -306,51 +359,35 @@ SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, int idnode2,
 ///@return The created tetrahedron 
 ///////////////////////////////////////////////////////////////////////////////
 
-SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4, int ID)
-{
-       SMDS_MeshNode *node1, *node2, *node3, *node4;
-       node1=const_cast<SMDS_MeshNode*>(n1),
-       node2=const_cast<SMDS_MeshNode*>(n2),
-       node3=const_cast<SMDS_MeshNode*>(n3);
-       node4=const_cast<SMDS_MeshNode*>(n4);
-       SMDS_MeshVolume* volume;
-       if(hasConstructionFaces())
-       {
-               SMDS_MeshFace * f1=createTriangle(node1,node2,node3);
-               SMDS_MeshFace * f2=createTriangle(node1,node2,node4);
-               SMDS_MeshFace * f3=createTriangle(node1,node3,node4);
-               SMDS_MeshFace * f4=createTriangle(node2,node3,node4);
-               volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4);
-               myVolumes.insert(volume);
-       }
-       else if(hasConstructionEdges())
-       {
-               MESSAGE("Error : Not implemented");
-               return NULL;
-       }
-       else
-       {
-               volume=new SMDS_VolumeOfNodes(node1,node2,node3,node4);
-               myVolumes.insert(volume);
-       }
-
-       if(myElementIDFactory->BindID(ID, volume))
-       {
-               node1->AddInverseElement(volume);
-               node2->AddInverseElement(volume);
-        node3->AddInverseElement(volume);
-               node4->AddInverseElement(volume);
-               return volume;
-       }       
-       else
-       {
-               RemoveVolume(volume);
-               return NULL;
-       }
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+                                            const SMDS_MeshNode * n2,
+                                            const SMDS_MeshNode * n3,
+                                            const SMDS_MeshNode * n4,
+                                            int ID)
+{
+  SMDS_MeshVolume* volume;
+  if(hasConstructionFaces()) {
+    SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3);
+    SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n4);
+    SMDS_MeshFace * f3=FindFaceOrCreate(n1,n3,n4);
+    SMDS_MeshFace * f4=FindFaceOrCreate(n2,n3,n4);
+    volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4);
+    myVolumes.insert(volume);
+  }
+  else if(hasConstructionEdges()) {
+    MESSAGE("Error : Not implemented");
+    return NULL;
+  }
+  else {
+    volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4);
+    myVolumes.insert(volume);
+  }
+
+  if (!registerElement(ID, volume)) {
+    RemoveElement(volume, false);
+    volume = NULL;
+  }
+  return volume;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -360,36 +397,40 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(
 ///////////////////////////////////////////////////////////////////////////////
 
 SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
-       const SMDS_MeshNode * n2, const SMDS_MeshNode * n3,
-       const SMDS_MeshNode * n4, const SMDS_MeshNode * n5)
+                                     const SMDS_MeshNode * n2, 
+                                     const SMDS_MeshNode * n3,
+                                     const SMDS_MeshNode * n4, 
+                                     const SMDS_MeshNode * n5)
 {
-       int ID = myElementIDFactory->GetFreeID();
-       SMDS_MeshVolume * v = AddVolumeWithID(n1, n2, n3, n4, n5, ID);
-       if(v==NULL) myElementIDFactory->ReleaseID(ID);
-       return v;
+  int ID = myElementIDFactory->GetFreeID();
+  SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
+  if(v==NULL) myElementIDFactory->ReleaseID(ID);
+  return v;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 ///Create a new pyramid and add it to the mesh. 
 ///Nodes 1,2,3 and 4 define the base of the pyramid
 ///@param ID The ID of the new volume
-///@return The created pyramid or NULL if a pyramid with this ID already exists
+///@return The created pyramid or NULL if an element with this ID already exists
 ///or if input nodes are not found.
 ///////////////////////////////////////////////////////////////////////////////
 
-SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, int idnode2,
-       int idnode3, int idnode4, int idnode5, int ID)
+SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, 
+                                            int idnode2,
+                                            int idnode3, 
+                                            int idnode4, 
+                                            int idnode5, 
+                                            int ID)
 {
-       SMDS_MeshNode *node1, *node2, *node3, *node4, *node5;
-       node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
-       node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
-       node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
-       node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
-       node5 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode5);
-       if((node1==NULL)||(node2==NULL)||(node3==NULL)||(node4=NULL)||
-               (node5=NULL))
-               return NULL;
-       return AddVolumeWithID(node1, node2, node3, node4, node5, ID);
+  SMDS_MeshNode *node1, *node2, *node3, *node4, *node5;
+  node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+  node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+  node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
+  node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
+  node5 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode5);
+  if(!node1 || !node2 || !node3 || !node4 || !node5) return NULL;
+  return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, node5, ID);
 }
        
 ///////////////////////////////////////////////////////////////////////////////
@@ -399,54 +440,36 @@ SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, int idnode2,
 ///@return The created pyramid
 ///////////////////////////////////////////////////////////////////////////////
 
-SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5, int ID)
-{
-       SMDS_MeshNode *node1, *node2, *node3, *node4, *node5;
-       node1=const_cast<SMDS_MeshNode*>(n1),
-       node2=const_cast<SMDS_MeshNode*>(n2),
-       node3=const_cast<SMDS_MeshNode*>(n3);
-       node4=const_cast<SMDS_MeshNode*>(n4);
-       node5=const_cast<SMDS_MeshNode*>(n5);
-       SMDS_MeshVolume* volume;
-       if(hasConstructionFaces())
-       {
-               SMDS_MeshFace * f1=createQuadrangle(node1,node2,node3,node4);
-               SMDS_MeshFace * f2=createTriangle(node1,node2,node5);
-               SMDS_MeshFace * f3=createTriangle(node2,node3,node5);
-               SMDS_MeshFace * f4=createTriangle(node3,node4,node5);
-               volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4);
-               myVolumes.insert(volume);
-       }
-       else if(hasConstructionEdges())
-       {
-               MESSAGE("Error : Not implemented");
-               return NULL;
-       }
-       else
-       {
-               volume=new SMDS_VolumeOfNodes(node1,node2,node3,node4,node5);
-               myVolumes.insert(volume);
-       }
-
-       if(myElementIDFactory->BindID(ID, volume))
-       {
-               node1->AddInverseElement(volume);
-               node2->AddInverseElement(volume);
-        node3->AddInverseElement(volume);
-               node4->AddInverseElement(volume);
-               node5->AddInverseElement(volume);
-               return volume;
-       }       
-       else
-       {
-               RemoveVolume(volume);
-               return NULL;
-       }
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+                                            const SMDS_MeshNode * n2,
+                                            const SMDS_MeshNode * n3,
+                                            const SMDS_MeshNode * n4,
+                                            const SMDS_MeshNode * n5,
+                                            int ID)
+{
+  SMDS_MeshVolume* volume;
+  if(hasConstructionFaces()) {
+    SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4);
+    SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n5);
+    SMDS_MeshFace * f3=FindFaceOrCreate(n2,n3,n5);
+    SMDS_MeshFace * f4=FindFaceOrCreate(n3,n4,n5);
+    volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4);
+    myVolumes.insert(volume);
+  }
+  else if(hasConstructionEdges()) {
+    MESSAGE("Error : Not implemented");
+    return NULL;
+  }
+  else {
+    volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5);
+    myVolumes.insert(volume);
+  }
+
+  if (!registerElement(ID, volume)) {
+    RemoveElement(volume, false);
+    volume = NULL;
+  }
+  return volume;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -456,38 +479,43 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(
 ///////////////////////////////////////////////////////////////////////////////
 
 SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
-       const SMDS_MeshNode * n2, const SMDS_MeshNode * n3,
-       const SMDS_MeshNode * n4, const SMDS_MeshNode * n5,
-       const SMDS_MeshNode * n6)
+                                     const SMDS_MeshNode * n2, 
+                                     const SMDS_MeshNode * n3,
+                                     const SMDS_MeshNode * n4, 
+                                     const SMDS_MeshNode * n5,
+                                     const SMDS_MeshNode * n6)
 {
-       int ID = myElementIDFactory->GetFreeID();
-       SMDS_MeshVolume * v = AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
-       if(v==NULL) myElementIDFactory->ReleaseID(ID);
-       return v;
+  int ID = myElementIDFactory->GetFreeID();
+  SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
+  if(v==NULL) myElementIDFactory->ReleaseID(ID);
+  return v;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 ///Create a new prism and add it to the mesh. 
 ///Nodes 1,2,3 is a triangle and 1,2,5,4 a quadrangle.
 ///@param ID The ID of the new volume
-///@return The created prism or NULL if a prism with this ID already exists
+///@return The created prism or NULL if an element with this ID already exists
 ///or if input nodes are not found.
 ///////////////////////////////////////////////////////////////////////////////
 
-SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, int idnode2,
-       int idnode3, int idnode4, int idnode5, int idnode6, int ID)
-{
-       SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6;
-       node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
-       node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
-       node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
-       node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
-       node5 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode5);
-       node6 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode6);
-       if((node1==NULL)||(node2==NULL)||(node3==NULL)||(node4=NULL)||
-               (node5==NULL)||(node6=NULL))
-               return NULL;
-       return AddVolumeWithID(node1, node2, node3, node4, node5, node6, ID);
+SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, 
+                                            int idnode2,
+                                            int idnode3, 
+                                            int idnode4, 
+                                            int idnode5, 
+                                            int idnode6, 
+                                            int ID)
+{
+  SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6;
+  node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+  node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+  node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
+  node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
+  node5 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode5);
+  node6 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode6);
+  if(!node1 || !node2 || !node3 || !node4 || !node5 || !node6) return NULL;
+  return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, node5, node6, ID);
 }
        
 ///////////////////////////////////////////////////////////////////////////////
@@ -497,58 +525,38 @@ SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, int idnode2,
 ///@return The created prism
 ///////////////////////////////////////////////////////////////////////////////
 
-SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5,
-               const SMDS_MeshNode * n6, int ID)
-{
-       SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6;
-       node1=const_cast<SMDS_MeshNode*>(n1),
-       node2=const_cast<SMDS_MeshNode*>(n2),
-       node3=const_cast<SMDS_MeshNode*>(n3);
-       node4=const_cast<SMDS_MeshNode*>(n4);
-       node5=const_cast<SMDS_MeshNode*>(n5);
-       node6=const_cast<SMDS_MeshNode*>(n6);
-       SMDS_MeshVolume* volume;
-       if(hasConstructionFaces())
-       {
-               SMDS_MeshFace * f1=createTriangle(node1,node2,node3);
-               SMDS_MeshFace * f2=createTriangle(node4,node5,node6);
-               SMDS_MeshFace * f3=createQuadrangle(node1,node4,node5,node2);
-               SMDS_MeshFace * f4=createQuadrangle(node2,node5,node6,node3);
-               SMDS_MeshFace * f5=createQuadrangle(node3,node6,node4,node1);
-               volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5);
-               myVolumes.insert(volume);
-       }
-       else if(hasConstructionEdges())
-       {
-               MESSAGE("Error : Not implemented");
-               return NULL;
-       }
-       else
-       {
-               volume=new SMDS_VolumeOfNodes(node1,node2,node3,node4,node5,node6);
-               myVolumes.insert(volume);
-       }
-
-       if(myElementIDFactory->BindID(ID, volume))
-       {
-               node1->AddInverseElement(volume);
-               node2->AddInverseElement(volume);
-        node3->AddInverseElement(volume);
-               node4->AddInverseElement(volume);
-               node5->AddInverseElement(volume);
-               node6->AddInverseElement(volume);
-               return volume;
-       }       
-       else
-       {
-               RemoveVolume(volume);
-               return NULL;
-       }
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+                                            const SMDS_MeshNode * n2,
+                                            const SMDS_MeshNode * n3,
+                                            const SMDS_MeshNode * n4,
+                                            const SMDS_MeshNode * n5,
+                                            const SMDS_MeshNode * n6,
+                                            int ID)
+{
+  SMDS_MeshVolume* volume;
+  if(hasConstructionFaces()) {
+    SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3);
+    SMDS_MeshFace * f2=FindFaceOrCreate(n4,n5,n6);
+    SMDS_MeshFace * f3=FindFaceOrCreate(n1,n4,n5,n2);
+    SMDS_MeshFace * f4=FindFaceOrCreate(n2,n5,n6,n3);
+    SMDS_MeshFace * f5=FindFaceOrCreate(n3,n6,n4,n1);
+    volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5);
+    myVolumes.insert(volume);
+  }
+  else if(hasConstructionEdges()) {
+    MESSAGE("Error : Not implemented");
+    return NULL;
+  }
+  else {
+    volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5,n6);
+    myVolumes.insert(volume);
+  }
+
+  if (!registerElement(ID, volume)) {
+    RemoveElement(volume, false);
+    volume = NULL;
+  }
+  return volume;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -558,113 +566,236 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(
 ///////////////////////////////////////////////////////////////////////////////
 
 SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
-       const SMDS_MeshNode * n2, const SMDS_MeshNode * n3,
-       const SMDS_MeshNode * n4, const SMDS_MeshNode * n5,
-       const SMDS_MeshNode * n6, const SMDS_MeshNode * n7,
-       const SMDS_MeshNode * n8)
+                                     const SMDS_MeshNode * n2, 
+                                     const SMDS_MeshNode * n3,
+                                     const SMDS_MeshNode * n4, 
+                                     const SMDS_MeshNode * n5,
+                                     const SMDS_MeshNode * n6, 
+                                     const SMDS_MeshNode * n7,
+                                     const SMDS_MeshNode * n8)
 {
-       int ID = myElementIDFactory->GetFreeID();
-       SMDS_MeshVolume * v = AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
-       if(v==NULL) myElementIDFactory->ReleaseID(ID);
-       return v;
+  int ID = myElementIDFactory->GetFreeID();
+  SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
+  if(v==NULL) myElementIDFactory->ReleaseID(ID);
+  return v;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 ///Create a new hexahedron and add it to the mesh. 
 ///Nodes 1,2,3,4 and 5,6,7,8 are quadrangle and 5,1 and 7,3 are an edges.
 ///@param ID The ID of the new volume
-///@return The created hexahedron or NULL if an hexahedron with this ID already
+///@return The created hexahedron or NULL if an element with this ID already
 ///exists or if input nodes are not found.
 ///////////////////////////////////////////////////////////////////////////////
 
-SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, int idnode2,
-       int idnode3, int idnode4, int idnode5, int idnode6, int idnode7,
-       int idnode8, int ID)
-{
-       SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6, *node7, *node8;
-       node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
-       node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
-       node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
-       node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
-       node5 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode5);
-       node6 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode6);
-       node7 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode7);
-       node8 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode8);
-       if((node1==NULL)||(node2==NULL)||(node3==NULL)||(node4=NULL)||
-               (node5==NULL)||(node6=NULL)||(node7==NULL)||(node8=NULL))
-               return NULL;
-       return AddVolumeWithID(node1, node2, node3, node4, node5, node6, node7,
-               node8, ID);
+SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, 
+                                            int idnode2,
+                                            int idnode3, 
+                                            int idnode4, 
+                                            int idnode5, 
+                                            int idnode6, 
+                                            int idnode7,
+                                            int idnode8, 
+                                            int ID)
+{
+  SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6, *node7, *node8;
+  node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+  node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+  node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
+  node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
+  node5 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode5);
+  node6 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode6);
+  node7 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode7);
+  node8 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode8);
+  if(!node1 || !node2 || !node3 || !node4 || !node5 || !node6 || !node7 || !node8)
+    return NULL;
+  return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, node5, node6,
+                                    node7, node8, ID);
 }
        
 ///////////////////////////////////////////////////////////////////////////////
 ///Create a new hexahedron and add it to the mesh.
 ///Nodes 1,2,3,4 and 5,6,7,8 are quadrangle and 5,1 and 7,3 are an edges.
 ///@param ID The ID of the new volume
-///@return The created prism or NULL if an hexadron with this ID already exists
+///@return The created prism or NULL if an element with this ID already exists
 ///or if input nodes are not found.
 ///////////////////////////////////////////////////////////////////////////////
 
-SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5,
-               const SMDS_MeshNode * n6,
-               const SMDS_MeshNode * n7,
-               const SMDS_MeshNode * n8, int ID)
-{
-       SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6, *node7, *node8;
-       node1=const_cast<SMDS_MeshNode*>(n1),
-       node2=const_cast<SMDS_MeshNode*>(n2),
-       node3=const_cast<SMDS_MeshNode*>(n3);
-       node4=const_cast<SMDS_MeshNode*>(n4);
-       node5=const_cast<SMDS_MeshNode*>(n5);
-       node6=const_cast<SMDS_MeshNode*>(n6);
-       node7=const_cast<SMDS_MeshNode*>(n7);
-       node8=const_cast<SMDS_MeshNode*>(n8);
-       SMDS_MeshVolume* volume;
-       if(hasConstructionFaces())
-       {
-               SMDS_MeshFace * f1=FindFaceOrCreate(node1,node2,node3,node4);
-               SMDS_MeshFace * f2=FindFaceOrCreate(node5,node6,node7,node8);
-               SMDS_MeshFace * f3=FindFaceOrCreate(node1,node4,node8,node5);
-               SMDS_MeshFace * f4=FindFaceOrCreate(node1,node2,node6,node5);
-               SMDS_MeshFace * f5=FindFaceOrCreate(node2,node3,node7,node6);
-               SMDS_MeshFace * f6=FindFaceOrCreate(node3,node4,node8,node7);
-               volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6);
-               myVolumes.insert(volume);
-       }
-       else if(hasConstructionEdges())
-       {
-               MESSAGE("Error : Not implemented");
-               return NULL;
-       }
-       else
-       {
-               volume=new SMDS_HexahedronOfNodes(node1,node2,node3,node4,node5,node6,
-                       node7,node8);
-               myVolumes.insert(volume);
-       }
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+                                            const SMDS_MeshNode * n2,
+                                            const SMDS_MeshNode * n3,
+                                            const SMDS_MeshNode * n4,
+                                            const SMDS_MeshNode * n5,
+                                            const SMDS_MeshNode * n6,
+                                            const SMDS_MeshNode * n7,
+                                            const SMDS_MeshNode * n8,
+                                            int ID)
+{
+  SMDS_MeshVolume* volume;
+  if(hasConstructionFaces()) {
+    SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4);
+    SMDS_MeshFace * f2=FindFaceOrCreate(n5,n6,n7,n8);
+    SMDS_MeshFace * f3=FindFaceOrCreate(n1,n4,n8,n5);
+    SMDS_MeshFace * f4=FindFaceOrCreate(n1,n2,n6,n5);
+    SMDS_MeshFace * f5=FindFaceOrCreate(n2,n3,n7,n6);
+    SMDS_MeshFace * f6=FindFaceOrCreate(n3,n4,n8,n7);
+    volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6);
+    myVolumes.insert(volume);
+  }
+  else if(hasConstructionEdges()) {
+    MESSAGE("Error : Not implemented");
+    return NULL;
+  }
+  else {
+    volume=new SMDS_HexahedronOfNodes(n1,n2,n3,n4,n5,n6,n7,n8);
+    myVolumes.insert(volume);
+  }
+
+  if (!registerElement(ID, volume)) {
+    RemoveElement(volume, false);
+    volume = NULL;
+  }
+  return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new tetrahedron defined by its faces and add it to the mesh.
+///@return The created tetrahedron
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1,
+                                      const SMDS_MeshFace * f2,
+                                      const SMDS_MeshFace * f3,
+                                      const SMDS_MeshFace * f4)
+{
+  if (!hasConstructionFaces())
+    return NULL;
+  return AddVolumeWithID(f1,f2,f3,f4, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new tetrahedron defined by its faces and add it to the mesh.
+///@param ID The ID of the new volume
+///@return The created tetrahedron 
+///////////////////////////////////////////////////////////////////////////////
 
-       if(myElementIDFactory->BindID(ID, volume))
-       {
-               node1->AddInverseElement(volume);
-               node2->AddInverseElement(volume);
-        node3->AddInverseElement(volume);
-               node4->AddInverseElement(volume);
-               node5->AddInverseElement(volume);
-               node6->AddInverseElement(volume);
-               node7->AddInverseElement(volume);
-               node8->AddInverseElement(volume);
-               return volume;
-       }       
-       else
-       {
-               RemoveVolume(volume);
-               return NULL;
-       }
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
+                                            const SMDS_MeshFace * f2,
+                                            const SMDS_MeshFace * f3,
+                                            const SMDS_MeshFace * f4,
+                                            int ID)
+{
+  if (!hasConstructionFaces())
+    return NULL;
+  SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4);
+  myVolumes.insert(volume);
+
+  if (!registerElement(ID, volume)) {
+    RemoveElement(volume, false);
+    volume = NULL;
+  }
+  return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new pyramid defined by its faces and add it to the mesh.
+///@return The created pyramid
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1,
+                                      const SMDS_MeshFace * f2,
+                                      const SMDS_MeshFace * f3,
+                                      const SMDS_MeshFace * f4,
+                                      const SMDS_MeshFace * f5)
+{
+  if (!hasConstructionFaces())
+    return NULL;
+  return AddVolumeWithID(f1,f2,f3,f4,f5, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new pyramid defined by its faces and add it to the mesh.
+///@param ID The ID of the new volume
+///@return The created pyramid 
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
+                                            const SMDS_MeshFace * f2,
+                                            const SMDS_MeshFace * f3,
+                                            const SMDS_MeshFace * f4,
+                                            const SMDS_MeshFace * f5,
+                                            int ID)
+{
+  if (!hasConstructionFaces())
+    return NULL;
+  SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5);
+  myVolumes.insert(volume);
+
+  if (!registerElement(ID, volume)) {
+    RemoveElement(volume, false);
+    volume = NULL;
+  }
+  return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new prism defined by its faces and add it to the mesh.
+///@return The created prism
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1,
+                                      const SMDS_MeshFace * f2,
+                                      const SMDS_MeshFace * f3,
+                                      const SMDS_MeshFace * f4,
+                                      const SMDS_MeshFace * f5,
+                                      const SMDS_MeshFace * f6)
+{
+  if (!hasConstructionFaces())
+    return NULL;
+  return AddVolumeWithID(f1,f2,f3,f4,f5,f6, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new prism defined by its faces and add it to the mesh.
+///@param ID The ID of the new volume
+///@return The created prism 
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
+                                            const SMDS_MeshFace * f2,
+                                            const SMDS_MeshFace * f3,
+                                            const SMDS_MeshFace * f4,
+                                            const SMDS_MeshFace * f5,
+                                            const SMDS_MeshFace * f6,
+                                            int ID)
+{
+  if (!hasConstructionFaces())
+    return NULL;
+  SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6);
+  myVolumes.insert(volume);
+
+  if (!registerElement(ID, volume)) {
+    RemoveElement(volume, false);
+    volume = NULL;
+  }
+  return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Registers element with the given ID, maintains inverse connections
+///////////////////////////////////////////////////////////////////////////////
+bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement * element)
+{
+  if (myElementIDFactory->BindID(ID, element)) {
+    SMDS_ElemIteratorPtr it = element->nodesIterator();
+    while (it->more()) {
+      SMDS_MeshNode *node = static_cast<SMDS_MeshNode*>
+        (const_cast<SMDS_MeshElement*>(it->next()));
+      node->AddInverseElement(element);
+    }
+    return true;
+  }
+  return false;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -672,15 +803,16 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(
 ///////////////////////////////////////////////////////////////////////////////
 const SMDS_MeshNode * SMDS_Mesh::FindNode(int ID) const
 {
-       return (const SMDS_MeshNode *)myNodeIDFactory->MeshElement(ID);
+  return (const SMDS_MeshNode *)myNodeIDFactory->MeshElement(ID);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 ///Create a triangle and add it to the current mesh. This methode do not bind a
 ///ID to the create triangle.
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_MeshFace * SMDS_Mesh::createTriangle(SMDS_MeshNode * node1,
-       SMDS_MeshNode * node2, SMDS_MeshNode * node3)
+SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1,
+                                          const SMDS_MeshNode * node2,
+                                          const SMDS_MeshNode * node3)
 {
        if(hasConstructionEdges())
        {
@@ -705,8 +837,10 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(SMDS_MeshNode * node1,
 ///Create a quadrangle and add it to the current mesh. This methode do not bind
 ///a ID to the create triangle.
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_MeshFace * SMDS_Mesh::createQuadrangle(SMDS_MeshNode * node1,
-       SMDS_MeshNode * node2, SMDS_MeshNode * node3, SMDS_MeshNode * node4)
+SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1,
+                                           const SMDS_MeshNode * node2,
+                                           const SMDS_MeshNode * node3,
+                                           const SMDS_MeshNode * node4)
 {
        if(hasConstructionEdges())
        {
@@ -812,9 +946,6 @@ const SMDS_MeshEdge* SMDS_Mesh::FindEdge(int idnode1, int idnode2) const
        return FindEdge(node1,node2);
 }
 
-///////////////////////////////////////////////////////////////////////////////
-///
-///////////////////////////////////////////////////////////////////////////////
 //#include "Profiler.h"
 const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1,
        const SMDS_MeshNode * node2) const
@@ -822,14 +953,14 @@ const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1,
        const SMDS_MeshEdge * toReturn=NULL;
        //PROFILER_Init();
        //PROFILER_Set();
-       SMDS_Iterator<const SMDS_MeshElement *>*  it1=node1->edgesIterator();
+       SMDS_ElemIteratorPtr it1=node1->edgesIterator();
        //PROFILER_Get(0);
        //PROFILER_Set();
        while(it1->more())
        {
                const SMDS_MeshEdge * e=static_cast<const SMDS_MeshEdge *>
                        (it1->next());
-               SMDS_Iterator<const SMDS_MeshElement *>* it2=e->nodesIterator();
+               SMDS_ElemIteratorPtr it2=e->nodesIterator();
                while(it2->more())
                {
                        if(it2->next()->GetID()==node2->GetID())
@@ -838,10 +969,8 @@ const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1,
                                break;
                        }
                }
-               delete it2;
        }
        //PROFILER_Get(1);
-       delete it1;
        return toReturn;
 }
 
@@ -853,9 +982,8 @@ SMDS_MeshEdge* SMDS_Mesh::FindEdgeOrCreate(const SMDS_MeshNode * node1,
        toReturn=const_cast<SMDS_MeshEdge*>(FindEdge(node1,node2));
        if(toReturn==NULL)      
        {
-               toReturn=new SMDS_MeshEdge(const_cast<SMDS_MeshNode*>(node1),
-                       const_cast<SMDS_MeshNode*>(node2));
-               myEdges.insert(toReturn);
+          toReturn=new SMDS_MeshEdge(node1,node2);
+          myEdges.insert(toReturn);
        } 
        return toReturn;
 }
@@ -871,36 +999,53 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(int idnode1, int idnode2,
        const SMDS_MeshNode * node1=FindNode(idnode1);
        const SMDS_MeshNode * node2=FindNode(idnode2);
        const SMDS_MeshNode * node3=FindNode(idnode3);
+       if((node1==NULL)||(node2==NULL)||(node3==NULL)) return NULL;
+       return FindFace(node1, node2, node3);
+}
+
+const SMDS_MeshFace* SMDS_Mesh::FindFace(
+               const SMDS_MeshNode *node1,
+               const SMDS_MeshNode *node2,
+               const SMDS_MeshNode *node3) const
+{
        const SMDS_MeshFace * face;
        const SMDS_MeshElement * node;
        bool node2found, node3found;
-       if((node1==NULL)||(node2==NULL)||(node3==NULL)) return NULL;
 
-       SMDS_Iterator<const SMDS_MeshElement *>*  it1=node1->facesIterator();
+       SMDS_ElemIteratorPtr it1=node1->facesIterator();
        while(it1->more())
        {
                face=static_cast<const SMDS_MeshFace*>(it1->next());
                if(face->NbNodes()!=3) continue;
-               SMDS_Iterator<const SMDS_MeshElement *>* it2=face->nodesIterator();
+               SMDS_ElemIteratorPtr it2=face->nodesIterator();
                node2found=false;
                node3found=false;
                while(it2->more())
                {
                        node=it2->next();
-                       if(node->GetID()==idnode2) node2found=true;
-                       if(node->GetID()==idnode3) node3found=true;
+                       if(node->GetID()==node2->GetID()) node2found=true;
+                       if(node->GetID()==node3->GetID()) node3found=true;
                }
-               delete it2;
                if(node2found&&node3found)
-               {
-                       delete it1;
                        return face;
-               }
        }
-       delete it1;
        return NULL;
 }
 
+SMDS_MeshFace* SMDS_Mesh::FindFaceOrCreate(
+               const SMDS_MeshNode *node1,
+               const SMDS_MeshNode *node2,
+               const SMDS_MeshNode *node3)
+{
+       SMDS_MeshFace * toReturn=NULL;
+       toReturn=const_cast<SMDS_MeshFace*>(FindFace(node1,node2,node3));
+       if(toReturn==NULL)
+       {
+         toReturn=createTriangle(node1,node2,node3);
+       }
+       return toReturn;
+}
+
 //=======================================================================
 //function : FindFace
 //purpose  :
@@ -926,12 +1071,12 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(
        const SMDS_MeshFace * face;
        const SMDS_MeshElement * node;
        bool node2found, node3found, node4found;
-       SMDS_Iterator<const SMDS_MeshElement *>*  it1=node1->facesIterator();
+       SMDS_ElemIteratorPtr it1=node1->facesIterator();
        while(it1->more())
        {
                face=static_cast<const SMDS_MeshFace *>(it1->next());
                if(face->NbNodes()!=4) continue;
-               SMDS_Iterator<const SMDS_MeshElement *>* it2=face->nodesIterator();
+               SMDS_ElemIteratorPtr it2=face->nodesIterator();
                node2found=false;
                node3found=false;
                node4found=false;
@@ -942,14 +1087,9 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(
                        if(node->GetID()==node3->GetID()) node3found=true;
                        if(node->GetID()==node4->GetID()) node4found=true;
                }
-               delete it2;
                if(node2found&&node3found&&node4found)
-               {
-                       delete it1;
                        return face;
-               }
        }
-       delete it1;
        return NULL;
 }
 
@@ -961,15 +1101,10 @@ SMDS_MeshFace* SMDS_Mesh::FindFaceOrCreate(
 {
        SMDS_MeshFace * toReturn=NULL;
        toReturn=const_cast<SMDS_MeshFace*>(FindFace(node1,node2,node3,node4));
-       if(toReturn==NULL)      
+       if(toReturn==NULL)
        {
-               toReturn=createQuadrangle(
-                       const_cast<SMDS_MeshNode *>(node1),
-                       const_cast<SMDS_MeshNode *>(node2),
-                       const_cast<SMDS_MeshNode *>(node3),
-                       const_cast<SMDS_MeshNode *>(node4)
-               );
-       } 
+         toReturn=createQuadrangle(node1,node2,node3,node4);
+       }
        return toReturn;
 }
 
@@ -991,9 +1126,8 @@ const SMDS_MeshElement* SMDS_Mesh::FindElement(int IDelem) const
 void SMDS_Mesh::DumpNodes() const
 {
        MESSAGE("dump nodes of mesh : ");
-       SMDS_Iterator<const SMDS_MeshNode *> * itnode=nodesIterator();
+       SMDS_NodeIteratorPtr itnode=nodesIterator();
        while(itnode->more()) MESSAGE(itnode->next());
-       delete itnode;
 }
 
 //=======================================================================
@@ -1004,9 +1138,8 @@ void SMDS_Mesh::DumpNodes() const
 void SMDS_Mesh::DumpEdges() const
 {
        MESSAGE("dump edges of mesh : ");
-       SMDS_Iterator<const SMDS_MeshEdge *> * itedge=edgesIterator();
+       SMDS_EdgeIteratorPtr itedge=edgesIterator();
        while(itedge->more()) MESSAGE(itedge->next());
-       delete itedge;
 }
 
 //=======================================================================
@@ -1017,9 +1150,8 @@ void SMDS_Mesh::DumpEdges() const
 void SMDS_Mesh::DumpFaces() const
 {
        MESSAGE("dump faces of mesh : ");
-       SMDS_Iterator<const SMDS_MeshFace *> * itface=facesIterator();
+       SMDS_FaceIteratorPtr itface=facesIterator();
        while(itface->more()) MESSAGE(itface->next());
-       delete itface;
 }
 
 //=======================================================================
@@ -1030,9 +1162,8 @@ void SMDS_Mesh::DumpFaces() const
 void SMDS_Mesh::DumpVolumes() const
 {
        MESSAGE("dump volumes of mesh : ");
-       SMDS_Iterator<const SMDS_MeshVolume *> * itvol=volumesIterator();
+       SMDS_VolumeIteratorPtr itvol=volumesIterator();
        while(itvol->more()) MESSAGE(itvol->next());
-       delete itvol;
 }
 
 //=======================================================================
@@ -1053,7 +1184,7 @@ void SMDS_Mesh::DebugStats() const
 
        //#ifdef DEB
        
-       SMDS_Iterator<const SMDS_MeshNode *> * itnode=nodesIterator();
+       SMDS_NodeIteratorPtr itnode=nodesIterator();
        int sizeofnodes = 0;
        int sizeoffaces = 0;
 
@@ -1063,19 +1194,16 @@ void SMDS_Mesh::DebugStats() const
 
                sizeofnodes += sizeof(*node);
                
-               SMDS_Iterator<const SMDS_MeshElement *> * it=
-                       node->GetInverseElementIterator();
+               SMDS_ElemIteratorPtr it = node->GetInverseElementIterator();
                while(it->more())
                {
                        const SMDS_MeshElement *me = it->next();
                        sizeofnodes += sizeof(me);
                }
-               delete it;
 
        }
-       delete itnode;
-       SMDS_Iterator<const SMDS_MeshFace*>* itface=facesIterator();
-       
+
+       SMDS_FaceIteratorPtr itface=facesIterator();
        while(itface->more())
        {
                const SMDS_MeshElement *face = itface->next();          
@@ -1086,7 +1214,6 @@ void SMDS_Mesh::DebugStats() const
        MESSAGE("total size of face elements = " << sizeoffaces);;
 
        //#endif
-
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -1150,12 +1277,11 @@ SMDS_Mesh::~SMDS_Mesh()
                itc++;
        }
        
-       SMDS_Iterator<const SMDS_MeshNode*> * itn=nodesIterator();
+       SMDS_NodeIteratorPtr itn=nodesIterator();
        while(itn->more())
        {
                delete itn->next();
        }
-       delete itn;
 
        set<SMDS_MeshEdge*>::iterator ite=myEdges.begin();
        while(ite!=myEdges.end())
@@ -1177,7 +1303,6 @@ SMDS_Mesh::~SMDS_Mesh()
                delete *itv;
                itv++;
        }
-
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -1243,143 +1368,151 @@ void SMDS_Mesh::setInverseElements(bool b)
 /// Return an iterator on nodes of the current mesh. Once used this iterator
 /// must be free by the caller
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshNode *> * SMDS_Mesh::nodesIterator() const
+class SMDS_Mesh_MyNodeIterator:public SMDS_NodeIterator
 {
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshNode*>
-       {
-               const SetOfNodes& mySet;
-               SetOfNodes::iterator myIterator;
-         public:
-               MyIterator(const SetOfNodes& s):mySet(s)
-               {
-                       myIterator=mySet.begin();
-               }
+  typedef SMDS_Mesh::SetOfNodes SetOfNodes;
+  const SetOfNodes& mySet;
+  SetOfNodes::iterator myIterator;
+ public:
+  SMDS_Mesh_MyNodeIterator(const SetOfNodes& s):mySet(s)
+  {
+    myIterator=mySet.begin();
+  }
 
-               bool more()
-               {
-                       return myIterator!=mySet.end();
-               }
+  bool more()
+  {
+    return myIterator!=mySet.end();
+  }
 
-               const SMDS_MeshNode* next()
-               {
-                       const SMDS_MeshNode* current=*myIterator;
-                       myIterator++;
-                       return current; 
-               }       
-       };
-       return new MyIterator(myNodes);
+  const SMDS_MeshNode* next()
+  {
+    const SMDS_MeshNode* current=*myIterator;
+    myIterator++;
+    return current;    
+  }    
+};
+
+SMDS_NodeIteratorPtr SMDS_Mesh::nodesIterator() const
+{
+  return SMDS_NodeIteratorPtr(new SMDS_Mesh_MyNodeIterator(myNodes));
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 ///Return an iterator on volumes of the current mesh. Once used this iterator
 ///must be free by the caller
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshEdge *> * SMDS_Mesh::edgesIterator() const
+class SMDS_Mesh_MyEdgeIterator:public SMDS_EdgeIterator
 {
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshEdge*>
-       {
-               const SetOfEdges& mySet;
-               const SMDS_MeshEdge * myEdge;
-               SetOfEdges::iterator myIterator;
-         public:
-               MyIterator(const SetOfEdges& s):mySet(s)
-               {
-                       myIterator=mySet.begin();
-               }
+  typedef SMDS_Mesh::SetOfEdges SetOfEdges;
+  const SetOfEdges& mySet;
+  const SMDS_MeshEdge * myEdge;
+  SetOfEdges::iterator myIterator;
+ public:
+  SMDS_Mesh_MyEdgeIterator(const SetOfEdges& s):mySet(s)
+  {
+    myIterator=mySet.begin();
+  }
 
-               bool more()
-               {
-                       while((myIterator!=mySet.end()))
-                       {
-                               if((*myIterator)->GetID()!=-1)
-                                       return true;
-                               myIterator++;
-                       }
-                       return false;
-               }
+  bool more()
+  {
+    while((myIterator!=mySet.end()))
+    {
+      if((*myIterator)->GetID()!=-1)
+        return true;
+      myIterator++;
+    }
+    return false;
+  }
 
-               const SMDS_MeshEdge* next()
-               {
-                       const SMDS_MeshEdge* current=*myIterator;
-                       myIterator++;
-                       return current; 
-               }       
-       };
-       return new MyIterator(myEdges);
+  const SMDS_MeshEdge* next()
+  {
+    const SMDS_MeshEdge* current=*myIterator;
+    myIterator++;
+    return current;    
+  }    
+};
+
+SMDS_EdgeIteratorPtr SMDS_Mesh::edgesIterator() const
+{
+  return SMDS_EdgeIteratorPtr(new SMDS_Mesh_MyEdgeIterator(myEdges));
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 ///Return an iterator on faces of the current mesh. Once used this iterator
 ///must be free by the caller
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshFace *> * SMDS_Mesh::facesIterator() const
+class SMDS_Mesh_MyFaceIterator:public SMDS_FaceIterator
 {
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshFace*>
-       {
-               const SetOfFaces& mySet;
-               set<SMDS_MeshFace*>::iterator myIterator;
-         public:
-               MyIterator(const SetOfFaces& s):mySet(s)
-               {
-                       myIterator=mySet.begin();
-               }
+  typedef SMDS_Mesh::SetOfFaces SetOfFaces;
+  const SetOfFaces& mySet;
+  SetOfFaces::iterator myIterator;
+ public:
+  SMDS_Mesh_MyFaceIterator(const SetOfFaces& s):mySet(s)
+  {
+    myIterator=mySet.begin();
+  }
 
-               bool more()
-               {
-                       while((myIterator!=mySet.end()))
-                       {
-                               if((*myIterator)->GetID()!=-1)
-                                       return true;
-                               myIterator++;
-                       }
-                       return false;
-               }
+  bool more()
+  {
+    while((myIterator!=mySet.end()))
+    {
+      if((*myIterator)->GetID()!=-1)
+        return true;
+      myIterator++;
+    }
+    return false;
+  }
 
-               const SMDS_MeshFace* next()
-               {
-                       const SMDS_MeshFace* current=*myIterator;
-                       myIterator++;
-                       return current; 
-               }       
-       };
-       return new MyIterator(myFaces);
+  const SMDS_MeshFace* next()
+  {
+    const SMDS_MeshFace* current=*myIterator;
+    myIterator++;
+    return current;    
+  }    
+};
+
+SMDS_FaceIteratorPtr SMDS_Mesh::facesIterator() const
+{
+  return SMDS_FaceIteratorPtr(new SMDS_Mesh_MyFaceIterator(myFaces));
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 ///Return an iterator on volumes of the current mesh. Once used this iterator
 ///must be free by the caller
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshVolume *> * SMDS_Mesh::volumesIterator() const
+class SMDS_Mesh_MyVolumeIterator:public SMDS_VolumeIterator
 {
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshVolume*>
-       {
-               const SetOfVolumes& mySet;
-               SetOfVolumes::iterator myIterator;
-         public:
-               MyIterator(const SetOfVolumes& s):mySet(s)
-               {
-                       myIterator=mySet.begin();
-               }
+  typedef SMDS_Mesh::SetOfVolumes SetOfVolumes;
+  const SetOfVolumes& mySet;
+  SetOfVolumes::iterator myIterator;
+ public:
+  SMDS_Mesh_MyVolumeIterator(const SetOfVolumes& s):mySet(s)
+  {
+    myIterator=mySet.begin();
+  }
 
-               bool more()
-               {
-                       return myIterator!=mySet.end();
-               }
+  bool more()
+  {
+    return myIterator!=mySet.end();
+  }
 
-               const SMDS_MeshVolume* next()
-               {
-                       const SMDS_MeshVolume* current=*myIterator;
-                       myIterator++;
-                       return current; 
-               }       
-       };
-       return new MyIterator(myVolumes);
+  const SMDS_MeshVolume* next()
+  {
+    const SMDS_MeshVolume* current=*myIterator;
+    myIterator++;
+    return current;    
+  }    
+};
+
+SMDS_VolumeIteratorPtr SMDS_Mesh::volumesIterator() const
+{
+  return SMDS_VolumeIteratorPtr(new SMDS_Mesh_MyVolumeIterator(myVolumes));
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 /// Do intersection of sets (more than 2)
 ///////////////////////////////////////////////////////////////////////////////
-set<const SMDS_MeshElement*> * intersectionOfSets(
+static set<const SMDS_MeshElement*> * intersectionOfSets(
        set<const SMDS_MeshElement*> vs[], int numberOfSets)
 {
        set<const SMDS_MeshElement*>* rsetA=new set<const SMDS_MeshElement*>(vs[0]);
@@ -1401,26 +1534,25 @@ set<const SMDS_MeshElement*> * intersectionOfSets(
 ///////////////////////////////////////////////////////////////////////////////
 /// Return the list of finit elements owning the given element
 ///////////////////////////////////////////////////////////////////////////////
-set<const SMDS_MeshElement*> * getFinitElements(const SMDS_MeshElement * element)
+static set<const SMDS_MeshElement*> * getFinitElements(const SMDS_MeshElement * element)
 {
        int numberOfSets=element->NbNodes();
        set<const SMDS_MeshElement*> initSet[numberOfSets];
 
-       SMDS_Iterator<const SMDS_MeshElement*> * itNodes=element->nodesIterator();
+       SMDS_ElemIteratorPtr itNodes=element->nodesIterator();
 
        int i=0;
        while(itNodes->more())
        {
                const SMDS_MeshNode * n=static_cast<const SMDS_MeshNode*>(itNodes->next());
-               SMDS_Iterator<const SMDS_MeshElement*> * itFe = n->GetInverseElementIterator();
+               SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator();
 
                //initSet[i]=set<const SMDS_MeshElement*>();
-               while(itFe->more()) initSet[i].insert(itFe->next());
+               while(itFe->more())
+                  initSet[i].insert(itFe->next());
 
                i++;
-               delete itFe;
        }
-       delete itNodes;
        
        return intersectionOfSets(initSet, numberOfSets);
 }
@@ -1428,7 +1560,7 @@ set<const SMDS_MeshElement*> * getFinitElements(const SMDS_MeshElement * element
 ///////////////////////////////////////////////////////////////////////////////
 /// Return the list of nodes used only by the given elements
 ///////////////////////////////////////////////////////////////////////////////
-set<const SMDS_MeshElement*> * getExclusiveNodes(
+static set<const SMDS_MeshElement*> * getExclusiveNodes(
        set<const SMDS_MeshElement*>& elements)
 {
        set<const SMDS_MeshElement*> * toReturn=new set<const SMDS_MeshElement*>();
@@ -1436,20 +1568,18 @@ set<const SMDS_MeshElement*> * getExclusiveNodes(
 
        while(itElements!=elements.end())
        {
-               SMDS_Iterator<const SMDS_MeshElement*> * itNodes=
-                       (*itElements)->nodesIterator();
+               SMDS_ElemIteratorPtr itNodes = (*itElements)->nodesIterator();
                itElements++;
        
                while(itNodes->more())
                {
                        const SMDS_MeshNode * n=static_cast<const SMDS_MeshNode*>(itNodes->next());
-                       SMDS_Iterator<const SMDS_MeshElement*> * itFe = n->GetInverseElementIterator();
+                       SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator();
                        set<const SMDS_MeshElement*> s;
-                       while(itFe->more()) s.insert(itFe->next());
-                       delete itFe;
+                       while(itFe->more())
+                          s.insert(itFe->next());
                        if(s==elements) toReturn->insert(n);
                }
-               delete itNodes;
        }
        return toReturn;        
 }
@@ -1471,46 +1601,49 @@ void SMDS_Mesh::addChildrenWithNodes(set<const SMDS_MeshElement*>&      setOfChildren
                break;
        case SMDSAbs_Edge:
        {
-               SMDS_Iterator<const SMDS_MeshElement*> * itn=element->nodesIterator();
+               SMDS_ElemIteratorPtr itn=element->nodesIterator();
                while(itn->more())
                {
                        const SMDS_MeshElement * e=itn->next();
-                       if(nodes.find(e)!=nodes.end()) setOfChildren.insert(element);
+                       if(nodes.find(e)!=nodes.end())
+                        {
+                          setOfChildren.insert(element);
+                          break;
+                        }
                }
-               delete itn;
-       } break;        
+       } break;
        case SMDSAbs_Face:
        {
-               SMDS_Iterator<const SMDS_MeshElement*> * itn=element->nodesIterator();
+               SMDS_ElemIteratorPtr itn=element->nodesIterator();
                while(itn->more())
                {
                        const SMDS_MeshElement * e=itn->next();
-                       if(nodes.find(e)!=nodes.end()) setOfChildren.insert(element);
+                       if(nodes.find(e)!=nodes.end())
+                        {
+                          setOfChildren.insert(element);
+                          break;
+                        }
                }
-               delete itn;
                if(hasConstructionEdges())
                {
-                       SMDS_Iterator<const SMDS_MeshElement*>* ite=element->edgesIterator();
+                       SMDS_ElemIteratorPtr ite=element->edgesIterator();
                        while(ite->more())
                                addChildrenWithNodes(setOfChildren, ite->next(), nodes);
-                       delete ite;
                }
        } break;        
        case SMDSAbs_Volume:
        {
                if(hasConstructionFaces())
                {
-                       SMDS_Iterator<const SMDS_MeshElement*> * ite=element->facesIterator();
+                       SMDS_ElemIteratorPtr ite=element->facesIterator();
                        while(ite->more())
                                addChildrenWithNodes(setOfChildren, ite->next(), nodes);
-                       delete ite;
                }
                else if(hasConstructionEdges())
                {
-                       SMDS_Iterator<const SMDS_MeshElement*> * ite=element->edgesIterator();
+                       SMDS_ElemIteratorPtr ite=element->edgesIterator();
                        while(ite->more())
                                addChildrenWithNodes(setOfChildren, ite->next(), nodes);
-                       delete ite;
                }
        }
        }
@@ -1523,54 +1656,135 @@ void SMDS_Mesh::addChildrenWithNodes(set<const SMDS_MeshElement*>&     setOfChildren
 void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
        const bool removenodes)
 {
-       set<const SMDS_MeshElement*> * s1=getFinitElements(elem);
-       
-       set<const SMDS_MeshElement*> * s2=getExclusiveNodes(*s1);
-       set<const SMDS_MeshElement*> s3;
-       set<const SMDS_MeshElement*>::iterator it=s1->begin();
-       while(it!=s1->end())
-       {
-               addChildrenWithNodes(s3, *it ,*s2);
-               s3.insert(*it);
-               it++;
-       }
-       if(elem->GetType()!=SMDSAbs_Node) s3.insert(elem);      
-       it=s3.begin();
-       while(it!=s3.end())
-       {
-               switch((*it)->GetType())
-               {
-               case SMDSAbs_Node:
-                       MESSAGE("Internal Error: This should not happen");
-                       break;
-               case SMDSAbs_Edge:
-                       myEdges.erase(static_cast<SMDS_MeshEdge*>(
-                               const_cast<SMDS_MeshElement*>(*it)));   
-                       break;
-               case SMDSAbs_Face:
-                       myFaces.erase(static_cast<SMDS_MeshFace*>(
-                               const_cast<SMDS_MeshElement*>(*it)));
-                       break;
-               case SMDSAbs_Volume:
-                       myVolumes.erase(static_cast<SMDS_MeshVolume*>(
-                               const_cast<SMDS_MeshElement*>(*it)));   
-                       break;
-               }
-               delete (*it);
-               it++;
-       }       
-       if(removenodes)
-       {
-               it=s2->begin();
-               while(it!=s2->end())
-               {
-                       myNodes.erase(static_cast<SMDS_MeshNode*>(
-                               const_cast<SMDS_MeshElement*>(*it)));
-                       delete *it;
-                       it++;
-               }
-       }
-               
-       delete s2;
-       delete s1;
+  list<const SMDS_MeshElement *> removedElems;
+  list<const SMDS_MeshElement *> removedNodes;
+  RemoveElement( elem, removedElems, removedNodes, removenodes );
+}
+  
+///////////////////////////////////////////////////////////////////////////////
+///@param elem The element to delete
+///@param removedElems contains all removed elements
+///@param removedNodes contains all removed nodes
+///@param removenodes if true remaining nodes will be removed
+///////////////////////////////////////////////////////////////////////////////
+void SMDS_Mesh::RemoveElement(const SMDS_MeshElement *        elem,
+                              list<const SMDS_MeshElement *>& removedElems,
+                              list<const SMDS_MeshElement *>& removedNodes,
+                              const bool                      removenodes)
+{
+  // get finite elements built on elem
+  set<const SMDS_MeshElement*> * s1;
+  if (!hasConstructionEdges() && elem->GetType() == SMDSAbs_Edge ||
+      !hasConstructionFaces() && elem->GetType() == SMDSAbs_Face)
+  {
+    s1 = new set<const SMDS_MeshElement*>();
+    s1->insert(elem);
+  }
+  else
+    s1 = getFinitElements(elem);
+
+  // get exclusive nodes (which would become free afterwards)
+  set<const SMDS_MeshElement*> * s2;
+  if (s1->empty() && elem->GetType() == SMDSAbs_Node)
+  {
+    s2 = new set<const SMDS_MeshElement*>();
+    s2->insert(elem);
+  }
+  else
+    s2 = getExclusiveNodes(*s1);
+
+  // form the set of finite and construction elements to remove
+  set<const SMDS_MeshElement*> s3;
+  set<const SMDS_MeshElement*>::iterator it=s1->begin();
+  while(it!=s1->end())
+  {
+    addChildrenWithNodes(s3, *it ,*s2);
+    s3.insert(*it);
+    it++;
+  }
+  if(elem->GetType()!=SMDSAbs_Node) s3.insert(elem);
+
+  // remove finite and construction elements
+  it=s3.begin();
+  while(it!=s3.end())
+  {
+    // Remove element from <InverseElements> of its nodes
+    SMDS_ElemIteratorPtr itn=(*it)->nodesIterator();
+    while(itn->more())
+    {
+      SMDS_MeshNode * n = static_cast<SMDS_MeshNode *>
+        (const_cast<SMDS_MeshElement *>(itn->next()));
+      n->RemoveInverseElement( (*it) );
+    }
+
+    switch((*it)->GetType())
+    {
+    case SMDSAbs_Node:
+      MESSAGE("Internal Error: This should not happen");
+      break;
+    case SMDSAbs_Edge:
+      myEdges.erase(static_cast<SMDS_MeshEdge*>
+                    (const_cast<SMDS_MeshElement*>(*it)));
+      break;
+    case SMDSAbs_Face:
+      myFaces.erase(static_cast<SMDS_MeshFace*>
+                    (const_cast<SMDS_MeshElement*>(*it)));
+      break;
+    case SMDSAbs_Volume:
+      myVolumes.erase(static_cast<SMDS_MeshVolume*>
+                      (const_cast<SMDS_MeshElement*>(*it)));
+      break;
+    }
+    //MESSAGE( "SMDS: RM elem " << (*it)->GetID() );
+    removedElems.push_back( (*it) );
+    myElementIDFactory->ReleaseID((*it)->GetID());
+    delete (*it);
+    it++;
+  }
+
+  // remove exclusive (free) nodes
+  if(removenodes)
+  {
+    it=s2->begin();
+    while(it!=s2->end())
+    {
+      //MESSAGE( "SMDS: RM node " << (*it)->GetID() );
+      myNodes.erase(static_cast<SMDS_MeshNode*>
+                    (const_cast<SMDS_MeshElement*>(*it)));
+      myNodeIDFactory->ReleaseID((*it)->GetID());
+      removedNodes.push_back( (*it) );
+      delete *it;
+      it++;
+    }
+  }
+
+  delete s2;
+  delete s1;
+}
+
+/*!
+ * Checks if the element is present in mesh.
+ * Useful to determine dead pointers.
+ */
+bool SMDS_Mesh::Contains (const SMDS_MeshElement* elem) const
+{
+  // we should not imply on validity of *elem, so iterate on containers
+  // of all types in the hope of finding <elem> somewhere there
+  SMDS_NodeIteratorPtr itn = nodesIterator();
+  while (itn->more())
+    if (elem == itn->next())
+      return true;
+  SMDS_EdgeIteratorPtr ite = edgesIterator();
+  while (ite->more())
+    if (elem == ite->next())
+      return true;
+  SMDS_FaceIteratorPtr itf = facesIterator();
+  while (itf->more())
+    if (elem == itf->next())
+      return true;
+  SMDS_VolumeIteratorPtr itv = volumesIterator();
+  while (itv->more())
+    if (elem == itv->next())
+      return true;
+  return false;
 }
index f869cd705aa4795248af9ae2e83bbaa0fb004748..61507199171cdc53354388d9a399670cac269fc8 100644 (file)
 #include "SMDS_MeshElementIDFactory.hxx"
 #include "SMDS_Iterator.hxx"
 
+#include <boost/shared_ptr.hpp>
 #include <set>
 #include <list>
 
 class SMDSControl_BoundaryEdges;
 
-class SMDS_Mesh:public SMDS_MeshObject
-{
-
-  public:
-
-       SMDS_Mesh();
-
-       SMDS_Iterator<const SMDS_MeshNode *> * nodesIterator() const;
-       SMDS_Iterator<const SMDS_MeshEdge *> * edgesIterator() const;
-       SMDS_Iterator<const SMDS_MeshFace *> * facesIterator() const;
-       SMDS_Iterator<const SMDS_MeshVolume *> * volumesIterator() const;
-
-       SMDS_Mesh *AddSubMesh();
-       virtual SMDS_MeshNode* AddNode(double x, double y, double z);
-       virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
-
-       virtual SMDS_MeshEdge* AddEdge(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2);
-       virtual SMDS_MeshFace* AddFace(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3);
-       virtual SMDS_MeshFace* AddFace(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4);
-       virtual SMDS_MeshVolume* AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4);
-       virtual SMDS_MeshVolume* AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5);
-       virtual SMDS_MeshVolume* AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5,
-               const SMDS_MeshNode * n6);
-       virtual SMDS_MeshVolume* AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5,
-               const SMDS_MeshNode * n6,
-               const SMDS_MeshNode * n7,
-               const SMDS_MeshNode * n8);
-
-       SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
-       SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
-       SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
-               int ID);
-       SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
-               int ID);
-       SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
-               int n5, int ID);
-       SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
-               int n5, int n6, int ID);
-       SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
-               int n5, int n6, int n7, int n8, int ID);
-
-       SMDS_MeshEdge* AddEdgeWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2, int ID);
-       SMDS_MeshFace* AddFaceWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3, int ID);
-       SMDS_MeshFace* AddFaceWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4, int ID);
-       SMDS_MeshVolume* AddVolumeWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4, int ID);
-       SMDS_MeshVolume* AddVolumeWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5, int ID);
-       SMDS_MeshVolume* AddVolumeWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5,
-               const SMDS_MeshNode * n6, int ID);
-       SMDS_MeshVolume* AddVolumeWithID(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5,
-               const SMDS_MeshNode * n6,
-               const SMDS_MeshNode * n7,
-               const SMDS_MeshNode * n8, int ID);
-
-       virtual void RemoveElement(const SMDS_MeshElement * elem, const bool removenodes =
-               false);
-       virtual void RemoveNode(const SMDS_MeshNode * node);
-       virtual void RemoveEdge(const SMDS_MeshEdge * edge);
-       virtual void RemoveFace(const SMDS_MeshFace * face);
-       virtual void RemoveVolume(const SMDS_MeshVolume * volume);
-
-       virtual bool RemoveFromParent();
-       virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh);
-       
-       const SMDS_MeshNode *FindNode(int idnode) const;
-       const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const;
-       const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const;
-       const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4) const;
-       const SMDS_MeshElement *FindElement(int IDelem) const;
+typedef SMDS_Iterator<const SMDS_MeshNode *> SMDS_NodeIterator;
+typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshNode *> > SMDS_NodeIteratorPtr;
+typedef SMDS_Iterator<const SMDS_MeshEdge *> SMDS_EdgeIterator;
+typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshEdge *> > SMDS_EdgeIteratorPtr;
+typedef SMDS_Iterator<const SMDS_MeshFace *> SMDS_FaceIterator;
+typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshFace *> > SMDS_FaceIteratorPtr;
+typedef SMDS_Iterator<const SMDS_MeshVolume *> SMDS_VolumeIterator;
+typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshVolume *> > SMDS_VolumeIteratorPtr;
+
+class SMDS_Mesh:public SMDS_MeshObject{
+public:
+  
+  SMDS_Mesh();
+  
+  SMDS_NodeIteratorPtr nodesIterator() const;
+  SMDS_EdgeIteratorPtr edgesIterator() const;
+  SMDS_FaceIteratorPtr facesIterator() const;
+  SMDS_VolumeIteratorPtr volumesIterator() const;
+  
+  SMDS_Mesh *AddSubMesh();
+  
+  virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
+  virtual SMDS_MeshNode* AddNode(double x, double y, double z);
+  
+  virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
+  virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
+                                      const SMDS_MeshNode * n2, 
+                                      int ID);
+  virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
+                                const SMDS_MeshNode * n2);
+  
+  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
+  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
+                                      const SMDS_MeshNode * n2,
+                                      const SMDS_MeshNode * n3, 
+                                      int ID);
+  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
+                                const SMDS_MeshNode * n2,
+                                const SMDS_MeshNode * n3);
+  
+  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4, int ID);
+  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
+                                      const SMDS_MeshNode * n2,
+                                      const SMDS_MeshNode * n3,
+                                      const SMDS_MeshNode * n4, 
+                                      int ID);
+  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
+                                const SMDS_MeshNode * n2,
+                                const SMDS_MeshNode * n3,
+                                const SMDS_MeshNode * n4);
+  
+  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
+                                       const SMDS_MeshEdge * e2,
+                                       const SMDS_MeshEdge * e3, int ID);
+  virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
+                                 const SMDS_MeshEdge * e2,
+                                 const SMDS_MeshEdge * e3);
+
+  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
+                                       const SMDS_MeshEdge * e2,
+                                       const SMDS_MeshEdge * e3,
+                                       const SMDS_MeshEdge * e4, int ID);
+  virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
+                                 const SMDS_MeshEdge * e2,
+                                 const SMDS_MeshEdge * e3,
+                                 const SMDS_MeshEdge * e4);
+
+  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID);
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2,
+                                          const SMDS_MeshNode * n3,
+                                          const SMDS_MeshNode * n4, 
+                                          int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
+                                    const SMDS_MeshNode * n2,
+                                    const SMDS_MeshNode * n3,
+                                    const SMDS_MeshNode * n4);
+  
+  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
+                                           int n5, int ID);
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2,
+                                          const SMDS_MeshNode * n3,
+                                          const SMDS_MeshNode * n4,
+                                          const SMDS_MeshNode * n5, 
+                                          int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
+                                    const SMDS_MeshNode * n2,
+                                    const SMDS_MeshNode * n3,
+                                    const SMDS_MeshNode * n4,
+                                    const SMDS_MeshNode * n5);
+  
+  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
+                                           int n5, int n6, int ID);
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2,
+                                          const SMDS_MeshNode * n3,
+                                          const SMDS_MeshNode * n4,
+                                          const SMDS_MeshNode * n5,
+                                          const SMDS_MeshNode * n6, 
+                                          int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
+                                    const SMDS_MeshNode * n2,
+                                    const SMDS_MeshNode * n3,
+                                    const SMDS_MeshNode * n4,
+                                    const SMDS_MeshNode * n5,
+                                    const SMDS_MeshNode * n6);
+  
+  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
+                                           int n5, int n6, int n7, int n8, int ID);
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2,
+                                          const SMDS_MeshNode * n3,
+                                          const SMDS_MeshNode * n4,
+                                          const SMDS_MeshNode * n5,
+                                          const SMDS_MeshNode * n6,
+                                          const SMDS_MeshNode * n7,
+                                          const SMDS_MeshNode * n8, 
+                                          int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
+                                    const SMDS_MeshNode * n2,
+                                    const SMDS_MeshNode * n3,
+                                    const SMDS_MeshNode * n4,
+                                    const SMDS_MeshNode * n5,
+                                    const SMDS_MeshNode * n6,
+                                    const SMDS_MeshNode * n7,
+                                    const SMDS_MeshNode * n8);
+
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
+                                           const SMDS_MeshFace * f2,
+                                           const SMDS_MeshFace * f3,
+                                           const SMDS_MeshFace * f4, int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
+                                     const SMDS_MeshFace * f2,
+                                     const SMDS_MeshFace * f3,
+                                     const SMDS_MeshFace * f4);
+
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
+                                           const SMDS_MeshFace * f2,
+                                           const SMDS_MeshFace * f3,
+                                           const SMDS_MeshFace * f4,
+                                           const SMDS_MeshFace * f5, int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
+                                     const SMDS_MeshFace * f2,
+                                     const SMDS_MeshFace * f3,
+                                     const SMDS_MeshFace * f4,
+                                     const SMDS_MeshFace * f5);
+
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
+                                           const SMDS_MeshFace * f2,
+                                           const SMDS_MeshFace * f3,
+                                           const SMDS_MeshFace * f4,
+                                           const SMDS_MeshFace * f5,
+                                           const SMDS_MeshFace * f6, int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
+                                     const SMDS_MeshFace * f2,
+                                     const SMDS_MeshFace * f3,
+                                     const SMDS_MeshFace * f4,
+                                     const SMDS_MeshFace * f5,
+                                     const SMDS_MeshFace * f6);
+
+  virtual void RemoveElement(const SMDS_MeshElement *        elem,
+                             list<const SMDS_MeshElement *>& removedElems,
+                             list<const SMDS_MeshElement *>& removedNodes,
+                             const bool                      removenodes = false);
+  virtual void RemoveElement(const SMDS_MeshElement * elem, const bool removenodes = false);
+  virtual void RemoveNode(const SMDS_MeshNode * node);
+  virtual void RemoveEdge(const SMDS_MeshEdge * edge);
+  virtual void RemoveFace(const SMDS_MeshFace * face);
+  virtual void RemoveVolume(const SMDS_MeshVolume * volume);
+  
+  virtual bool RemoveFromParent();
+  virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh);
+  
+  const SMDS_MeshNode *FindNode(int idnode) const;
+  const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const;
+  const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const;
+  const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4) const;
+  const SMDS_MeshElement *FindElement(int IDelem) const;
        
-       int NbNodes() const;
-       int NbEdges() const;
-       int NbFaces() const;
-       int NbVolumes() const;
-       int NbSubMesh() const;
-       void DumpNodes() const;
-       void DumpEdges() const;
-       void DumpFaces() const;
-       void DumpVolumes() const;
-       void DebugStats() const;
-       SMDS_Mesh *boundaryFaces();
-       SMDS_Mesh *boundaryEdges();
-       virtual ~SMDS_Mesh();
-    bool hasConstructionEdges();
-    bool hasConstructionFaces();
-       bool hasInverseElements();
-    void setConstructionEdges(bool);
-    void setConstructionFaces(bool);
-       void setInverseElements(bool);
-
-  private:
-    SMDS_Mesh(SMDS_Mesh * parent);
-    SMDS_MeshFace * createTriangle(SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2, SMDS_MeshNode * node3);
-       SMDS_MeshFace * createQuadrangle(SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2, SMDS_MeshNode * node3, SMDS_MeshNode * node4);
-       const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2) const;
-       SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2);
-       SMDS_MeshFace* FindFaceOrCreate(
-               const SMDS_MeshNode *n1,
-               const SMDS_MeshNode *n2,
-               const SMDS_MeshNode *n3);
-       const SMDS_MeshFace* FindFace(
-               const SMDS_MeshNode *n1,
-               const SMDS_MeshNode *n2,
-               const SMDS_MeshNode *n3,
-               const SMDS_MeshNode *n4) const;
-       SMDS_MeshFace* FindFaceOrCreate(
-               const SMDS_MeshNode *n1,
-               const SMDS_MeshNode *n2,
-               const SMDS_MeshNode *n3,
-               const SMDS_MeshNode *n4);
-       void addChildrenWithNodes(set<const SMDS_MeshElement*>& setOfChildren, 
-               const SMDS_MeshElement * element, set<const SMDS_MeshElement*>& nodes);
-
-       // Fields PRIVATE
-       typedef set<SMDS_MeshNode *> SetOfNodes;
-       typedef set<SMDS_MeshEdge *> SetOfEdges;
-       typedef set<SMDS_MeshFace *> SetOfFaces;
-       typedef set<SMDS_MeshVolume *> SetOfVolumes;
-
-       SetOfNodes myNodes;
-       SetOfEdges myEdges;
-       SetOfFaces myFaces;
-       SetOfVolumes myVolumes;
-       SMDS_Mesh *myParent;
-       list<SMDS_Mesh *> myChildren;
-       SMDS_MeshElementIDFactory *myNodeIDFactory;
-       SMDS_MeshElementIDFactory *myElementIDFactory;
-
-    bool myHasConstructionEdges;
-    bool myHasConstructionFaces;
-       bool myHasInverseElements;
+  int NbNodes() const;
+  int NbEdges() const;
+  int NbFaces() const;
+  int NbVolumes() const;
+  int NbSubMesh() const;
+  void DumpNodes() const;
+  void DumpEdges() const;
+  void DumpFaces() const;
+  void DumpVolumes() const;
+  void DebugStats() const;
+  SMDS_Mesh *boundaryFaces();
+  SMDS_Mesh *boundaryEdges();
+  virtual ~SMDS_Mesh();
+  bool hasConstructionEdges();
+  bool hasConstructionFaces();
+  bool hasInverseElements();
+  void setConstructionEdges(bool);
+  void setConstructionFaces(bool);
+  void setInverseElements(bool);
+
+  /*!
+   * Checks if the element is present in mesh.
+   * Useful to determine dead pointers.
+   * Use this function for debug purpose only! Do not check in the code
+   * using it even in _DEBUG_ mode
+   */
+  bool Contains (const SMDS_MeshElement* elem) const;
+
+  typedef set<SMDS_MeshNode *> SetOfNodes;
+  typedef set<SMDS_MeshEdge *> SetOfEdges;
+  typedef set<SMDS_MeshFace *> SetOfFaces;
+  typedef set<SMDS_MeshVolume *> SetOfVolumes;
+
+private:
+  SMDS_Mesh(SMDS_Mesh * parent);
+
+  SMDS_MeshFace * createTriangle(const SMDS_MeshNode * node1, 
+                                const SMDS_MeshNode * node2, 
+                                const SMDS_MeshNode * node3);
+
+  SMDS_MeshFace * createQuadrangle(const SMDS_MeshNode * node1,
+                                  const SMDS_MeshNode * node2, 
+                                  const SMDS_MeshNode * node3, 
+                                  const SMDS_MeshNode * node4);
+
+  bool registerElement(int ID, SMDS_MeshElement * element);
+
+  const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
+                               const SMDS_MeshNode * n2) const;
+
+  SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1,
+                                 const SMDS_MeshNode * n2);
+
+  const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
+                                const SMDS_MeshNode *n2,
+                                const SMDS_MeshNode *n3) const;
+
+  SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
+                                 const SMDS_MeshNode *n2,
+                                 const SMDS_MeshNode *n3);
+
+  const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
+                               const SMDS_MeshNode *n2,
+                               const SMDS_MeshNode *n3,
+                               const SMDS_MeshNode *n4) const;
+
+  SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
+                                 const SMDS_MeshNode *n2,
+                                 const SMDS_MeshNode *n3,
+                                 const SMDS_MeshNode *n4);
+
+  void addChildrenWithNodes(set<const SMDS_MeshElement*>& setOfChildren, 
+                           const SMDS_MeshElement * element, 
+                           set<const SMDS_MeshElement*>& nodes);
+
+  // Fields PRIVATE
+  
+  SetOfNodes myNodes;
+  SetOfEdges myEdges;
+  SetOfFaces myFaces;
+  SetOfVolumes myVolumes;
+  SMDS_Mesh *myParent;
+  list<SMDS_Mesh *> myChildren;
+  SMDS_MeshElementIDFactory *myNodeIDFactory;
+  SMDS_MeshElementIDFactory *myElementIDFactory;
+  
+  bool myHasConstructionEdges;
+  bool myHasConstructionFaces;
+  bool myHasInverseElements;
 };
 
 #endif
index 3f7994c1ffd9ca18a8c26de8b69fab0235fa8461..484207ba08c6b7a3b1e4c50657c9c6d0c8a35143 100644 (file)
@@ -36,7 +36,8 @@
 //purpose  : 
 //=======================================================================
 
-SMDS_MeshEdge::SMDS_MeshEdge(SMDS_MeshNode * node1, SMDS_MeshNode * node2)
+SMDS_MeshEdge::SMDS_MeshEdge(const SMDS_MeshNode * node1,
+                             const SMDS_MeshNode * node2)
 {      
        myNodes[0]=node1;
        myNodes[1]=node2;
@@ -68,36 +69,40 @@ SMDSAbs_ElementType SMDS_MeshEdge::GetType() const
        return SMDSAbs_Edge;
 }
 
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshEdge::
+class SMDS_MeshEdge_MyNodeIterator:public SMDS_ElemIterator
+{
+  const SMDS_MeshNode *const* myNodes;
+  int myIndex;
+ public:
+  SMDS_MeshEdge_MyNodeIterator(const SMDS_MeshNode * const* nodes):
+    myNodes(nodes),myIndex(0) {}
+
+  bool more()
+  {
+    return myIndex<2;
+  }
+
+  const SMDS_MeshElement* next()
+  {
+    myIndex++;
+    return myNodes[myIndex-1];
+  }
+};
+
+SMDS_ElemIteratorPtr SMDS_MeshEdge::
        elementsIterator(SMDSAbs_ElementType type) const
 {
-       class MyNodeIterator:public SMDS_Iterator<const SMDS_MeshElement *>
-       {
-               SMDS_MeshNode *const* myNodes;
-               int myIndex;
-         public:
-               MyNodeIterator(SMDS_MeshNode * const* nodes):myNodes(nodes),myIndex(0)
-               {}      
-
-               bool more()
-               {
-                       return myIndex<2;
-               }
-
-               const SMDS_MeshElement* next()
-               {
-                       myIndex++;
-                       return myNodes[myIndex-1];
-               }       
-       };
-
-       switch(type)
-       {
-       case SMDSAbs_Edge:return SMDS_MeshElement::elementsIterator(SMDSAbs_Edge); 
-       case SMDSAbs_Node:return new MyNodeIterator(myNodes);
-       default: return new SMDS_IteratorOfElements(this,type, nodesIterator());
-       }
-
+  switch(type)
+  {
+  case SMDSAbs_Edge:
+    return SMDS_MeshElement::elementsIterator(SMDSAbs_Edge); 
+  case SMDSAbs_Node:
+    return SMDS_ElemIteratorPtr(new SMDS_MeshEdge_MyNodeIterator(myNodes));
+  default:
+    return SMDS_ElemIteratorPtr
+      (new SMDS_IteratorOfElements
+       (this,type, SMDS_ElemIteratorPtr(new SMDS_MeshEdge_MyNodeIterator(myNodes))));
+  }
 }
 
 bool operator<(const SMDS_MeshEdge & e1, const SMDS_MeshEdge & e2)
index cfef08ed7eac938d9bb90b3a4271e1bcb8fe75fe..28621d8e912867fabbb163dbd8cec5c117cacc3e 100644 (file)
@@ -34,7 +34,8 @@ class SMDS_MeshEdge:public SMDS_MeshElement
 {
 
   public:
-       SMDS_MeshEdge(SMDS_MeshNode * node1, SMDS_MeshNode * node2);
+       SMDS_MeshEdge(const SMDS_MeshNode * node1,
+                      const SMDS_MeshNode * node2);
        void Print(ostream & OS) const;
 
        SMDSAbs_ElementType GetType() const;
@@ -42,11 +43,11 @@ class SMDS_MeshEdge:public SMDS_MeshElement
        int NbEdges() const;
        friend bool operator<(const SMDS_MeshEdge& e1, const SMDS_MeshEdge& e2);
   protected:
-       SMDS_Iterator<const SMDS_MeshElement *> *
+       SMDS_ElemIteratorPtr
                elementsIterator(SMDSAbs_ElementType type) const;
 
   private:
-       SMDS_MeshNode* myNodes[2];
+       const SMDS_MeshNode* myNodes[2];
 
 };
 #endif
index 701e6fe97ce20051f79820ed74110609341e86a1..14c0af4b54667b048204f24d98da91b257a9b157 100644 (file)
@@ -45,7 +45,7 @@ ostream & operator <<(ostream & OS, const SMDS_MeshElement * ME)
 /// Create an iterator which iterate on nodes owned by the element.
 /// This method call elementsIterator().
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::nodesIterator() const
+SMDS_ElemIteratorPtr SMDS_MeshElement::nodesIterator() const
 {
        return elementsIterator(SMDSAbs_Node);
 }
@@ -54,7 +54,7 @@ SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::nodesIterator() cons
 /// Create an iterator which iterate on edges linked with or owned by the element.
 /// This method call elementsIterator().
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::edgesIterator() const
+SMDS_ElemIteratorPtr SMDS_MeshElement::edgesIterator() const
 {
        return elementsIterator(SMDSAbs_Edge);
 }
@@ -63,7 +63,7 @@ SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::edgesIterator() cons
 /// Create an iterator which iterate on faces linked with or owned by the element.
 /// This method call elementsIterator().
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::facesIterator() const
+SMDS_ElemIteratorPtr SMDS_MeshElement::facesIterator() const
 {
        return elementsIterator(SMDSAbs_Face);
 }
@@ -74,13 +74,12 @@ SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::facesIterator() cons
 int SMDS_MeshElement::NbNodes() const
 {
        int nbnodes=0;
-       SMDS_Iterator<const SMDS_MeshElement *> * it=nodesIterator();
+       SMDS_ElemIteratorPtr it=nodesIterator();
        while(it->more())
        {
                it->next();
                nbnodes++;
        }
-       delete it;
        return nbnodes;
 }
 
@@ -90,13 +89,12 @@ int SMDS_MeshElement::NbNodes() const
 int SMDS_MeshElement::NbEdges() const
 {
        int nbedges=0;
-       SMDS_Iterator<const SMDS_MeshElement *> * it=edgesIterator();
+       SMDS_ElemIteratorPtr it=edgesIterator();
        while(it->more())
        {
                it->next();
                nbedges++;
        }
-       delete it;
        return nbedges;
 }
 
@@ -106,55 +104,52 @@ int SMDS_MeshElement::NbEdges() const
 int SMDS_MeshElement::NbFaces() const
 {
        int nbfaces=0;
-       SMDS_Iterator<const SMDS_MeshElement *> * it=facesIterator();
+       SMDS_ElemIteratorPtr it=facesIterator();
        while(it->more())
        {
                it->next();
                nbfaces++;
        }
-       delete it;
        return nbfaces;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-///Create and iterator which iterate on elements linked with the current element.
-///The iterator must be free by the caller (call delete myIterator).
+///Create an iterator which iterate on elements linked with the current element.
 ///@param type The of elements on which you want to iterate
-///@return An iterator, that you must free when you no longer need it
+///@return A smart pointer to iterator, you are not to take care of freeing memory
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshElement::
+class SMDS_MeshElement_MyIterator:public SMDS_ElemIterator
+{
+  const SMDS_MeshElement * myElement;
+  bool myMore;
+ public:
+  SMDS_MeshElement_MyIterator(const SMDS_MeshElement * element):
+    myElement(element),myMore(true) {}
+
+  bool more()
+  {
+    return myMore;
+  }
+
+  const SMDS_MeshElement* next()
+  {
+    myMore=false;
+    return myElement;  
+  }    
+};
+SMDS_ElemIteratorPtr SMDS_MeshElement::
        elementsIterator(SMDSAbs_ElementType type) const
 {
        /** @todo Check that iterator in the child classes return elements
        in the same order for each different implementation (i.e: SMDS_VolumeOfNodes
        and SMDS_VolumeOfFaces */
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
-       {
-               const SMDS_MeshElement * myElement;
-               bool myMore;
-         public:
-               MyIterator(const SMDS_MeshElement * element):
-                       myElement(element),myMore(true)
-               {
-               }
-
-               bool more()
-               {
-                       return myMore;
-               }
-
-               const SMDS_MeshElement* next()
-               {
-                       myMore=false;
-                       return myElement;       
-               }       
-       };
        
-       if(type==GetType()) return new MyIterator(this);
+       if(type==GetType())
+          return SMDS_ElemIteratorPtr(new SMDS_MeshElement_MyIterator(this));
        else 
        {
-               MESSAGE("Iterator not implemented");            
-               return NULL;
+          MESSAGE("Iterator not implemented");
+          return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
        }
 }
 
index 86bc6ddb5109df689494b1f5bea20ec160b21d0b..5ae8bc1a02181df68a1eab7363c9549b28381f9c 100644 (file)
@@ -32,6 +32,7 @@
 #include "SMDS_Iterator.hxx"
 #include "SMDS_MeshElementIDFactory.hxx"
 
+#include <boost/shared_ptr.hpp>
 #include <vector>
 #include <iostream>
 
@@ -39,6 +40,10 @@ using namespace std;
 class SMDS_MeshNode;
 class SMDS_MeshEdge;
 class SMDS_MeshFace;   
+class SMDS_MeshElement;
+
+typedef SMDS_Iterator<const SMDS_MeshElement *> SMDS_ElemIterator;
+typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshElement *> > SMDS_ElemIteratorPtr;
 
 ///////////////////////////////////////////////////////////////////////////////
 /// Base class for elements
@@ -47,10 +52,10 @@ class SMDS_MeshElement:public SMDS_MeshObject
 {
 
   public:
-       SMDS_Iterator<const SMDS_MeshElement *> * nodesIterator() const;
-       SMDS_Iterator<const SMDS_MeshElement *> * edgesIterator() const;
-       SMDS_Iterator<const SMDS_MeshElement *> * facesIterator() const;
-       virtual SMDS_Iterator<const SMDS_MeshElement *> *
+       SMDS_ElemIteratorPtr nodesIterator() const;
+       SMDS_ElemIteratorPtr edgesIterator() const;
+       SMDS_ElemIteratorPtr facesIterator() const;
+       virtual SMDS_ElemIteratorPtr
                elementsIterator(SMDSAbs_ElementType type) const;
 
        virtual int NbNodes() const;
index d635b0110c15ea89c0360c75d87946aaa202f336..43f12c7771912daa708edc644b22104f7da9b0de 100644 (file)
@@ -58,3 +58,27 @@ SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
     map<int, SMDS_MeshElement*>::iterator it=myIDElements.find(ID);
     if(it==myIDElements.end()) return NULL; else return (*it).second;
 }
+
+
+//=======================================================================
+//function : GetFreeID
+//purpose  : 
+//=======================================================================
+int SMDS_MeshElementIDFactory::GetFreeID()
+{
+  int ID;
+  do {
+    ID = SMDS_MeshIDFactory::GetFreeID();
+  } while (myIDElements.find(ID) != myIDElements.end());
+  return ID;
+}
+
+//=======================================================================
+//function : ReleaseID
+//purpose  : 
+//=======================================================================
+void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
+{
+  myIDElements.erase(ID);
+  SMDS_MeshIDFactory::ReleaseID(ID);
+}
index 8814676335d34505bea659a419044d47232ecfe0..f987eaed2d4c7bb67ec51b69441dbe03f3779425 100644 (file)
@@ -28,7 +28,6 @@
 #define _SMDS_MeshElementIDFactory_HeaderFile
 
 #include "SMDS_MeshIDFactory.hxx"
-#include <SMDS_Iterator.hxx>
 
 #include <map>
 using namespace std;
@@ -41,6 +40,8 @@ class SMDS_MeshElementIDFactory:public SMDS_MeshIDFactory
        SMDS_MeshElementIDFactory();
        bool BindID(int ID, SMDS_MeshElement * elem);
        SMDS_MeshElement * MeshElement(int ID);
+       virtual int GetFreeID();
+       virtual void ReleaseID(int ID);
   private:
        map<int, SMDS_MeshElement *> myIDElements;
 
index 25e942abb32b7e0bc075d64988a6811a68034e3c..25ae25b73b774c32c378805fe36a143c6b015c26 100644 (file)
@@ -32,8 +32,9 @@ using namespace std;
 //purpose  : 
 //=======================================================================
 
-SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * aMesh)
-       :myMesh(aMesh),myType(SMDSAbs_All), myParent(NULL)
+SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh,
+                               const SMDSAbs_ElementType theType)
+       :myMesh(theMesh),myType(theType), myParent(NULL)
 {
 }
 
@@ -42,8 +43,9 @@ SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * aMesh)
 //purpose  : 
 //=======================================================================
 
-SMDS_MeshGroup::SMDS_MeshGroup(SMDS_MeshGroup * parent)
-       :myMesh(parent->myMesh),myType(SMDSAbs_All), myParent(parent)
+SMDS_MeshGroup::SMDS_MeshGroup(SMDS_MeshGroup * theParent,
+                               const SMDSAbs_ElementType theType)
+       :myMesh(theParent->myMesh),myType(theType), myParent(theParent)
 {
 }
 
@@ -52,9 +54,10 @@ SMDS_MeshGroup::SMDS_MeshGroup(SMDS_MeshGroup * parent)
 //purpose  : 
 //=======================================================================
 
-const SMDS_MeshGroup *SMDS_MeshGroup::AddSubGroup()
+const SMDS_MeshGroup *SMDS_MeshGroup::AddSubGroup
+                (const SMDSAbs_ElementType theType)
 {
-       const SMDS_MeshGroup * subgroup = new SMDS_MeshGroup(this);
+       const SMDS_MeshGroup * subgroup = new SMDS_MeshGroup(this,theType);
        myChildren.insert(myChildren.end(),subgroup);
        return subgroup;
 }
@@ -64,14 +67,14 @@ const SMDS_MeshGroup *SMDS_MeshGroup::AddSubGroup()
 //purpose  : 
 //=======================================================================
 
-bool SMDS_MeshGroup::RemoveSubGroup(const SMDS_MeshGroup * aGroup)
+bool SMDS_MeshGroup::RemoveSubGroup(const SMDS_MeshGroup * theGroup)
 {
        bool found = false;     
        list<const SMDS_MeshGroup*>::iterator itgroup;
        for(itgroup=myChildren.begin(); itgroup!=myChildren.end(); itgroup++)
        {
                const SMDS_MeshGroup* subgroup=*itgroup;
-               if (subgroup == aGroup)
+               if (subgroup == theGroup)
                {
                        found = true;
                        myChildren.erase(itgroup);
@@ -106,39 +109,19 @@ void SMDS_MeshGroup::Clear()
        myType = SMDSAbs_All;
 }
 
-//=======================================================================
-//function : IsEmpty
-//purpose  : 
-//=======================================================================
-
-bool SMDS_MeshGroup::IsEmpty() const
-{
-       return myElements.empty();
-}
-
-//=======================================================================
-//function : Extent
-//purpose  : 
-//=======================================================================
-
-int SMDS_MeshGroup::Extent() const
-{
-       return myElements.size();
-}
-
 //=======================================================================
 //function : Add
 //purpose  : 
 //=======================================================================
 
-void SMDS_MeshGroup::Add(const SMDS_MeshElement * ME)
+void SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
 {
        // the type of the group is determined by the first element added
-       if (myElements.empty()) myType = ME->GetType();
-       else if (ME->GetType() != myType)
+       if (myElements.empty()) myType = theElem->GetType();
+       else if (theElem->GetType() != myType)
                MESSAGE("SMDS_MeshGroup::Add : Type Mismatch");
        
-       myElements.insert(ME);
+       myElements.insert(theElem);
 }
 
 //=======================================================================
@@ -146,28 +129,29 @@ void SMDS_MeshGroup::Add(const SMDS_MeshElement * ME)
 //purpose  : 
 //=======================================================================
 
-void SMDS_MeshGroup::Remove(const SMDS_MeshElement * ME)
+void SMDS_MeshGroup::Remove(const SMDS_MeshElement * theElem)
 {
-       myElements.erase(ME);
+       myElements.erase(theElem);
        if (myElements.empty()) myType = SMDSAbs_All;
 }
 
 //=======================================================================
-//function : Type
+//function : Contains
 //purpose  : 
 //=======================================================================
 
-SMDSAbs_ElementType SMDS_MeshGroup::Type() const
+bool SMDS_MeshGroup::Contains(const SMDS_MeshElement * theElem) const
 {
-       return myType;
+       return myElements.find(theElem)!=myElements.end();
 }
 
 //=======================================================================
-//function : Contains
+//function : SetType
 //purpose  : 
 //=======================================================================
 
-bool SMDS_MeshGroup::Contains(const SMDS_MeshElement * ME) const
+void SMDS_MeshGroup::SetType(const SMDSAbs_ElementType theType)
 {
-       return myElements.find(ME)!=myElements.end();
+  if (IsEmpty())
+    myType = theType;
 }
index f73c1dd1f4a79bc51ab36f6b070e0c755940ec38..c5bfcb43216dcdf8dfbd8a5e10a11381224831a6 100644 (file)
@@ -33,25 +33,44 @@ using namespace std;
 class SMDS_MeshGroup:public SMDS_MeshObject
 {
   public:
-       SMDS_MeshGroup(const SMDS_Mesh * aMesh);
-       const SMDS_MeshGroup * AddSubGroup();
-       virtual bool RemoveSubGroup(const SMDS_MeshGroup* aGroup);
+       SMDS_MeshGroup(const SMDS_Mesh * theMesh,
+                       const SMDSAbs_ElementType theType = SMDSAbs_All);
+       const SMDS_MeshGroup * AddSubGroup
+                      (const SMDSAbs_ElementType theType = SMDSAbs_All);
+       virtual bool RemoveSubGroup(const SMDS_MeshGroup* theGroup);
        virtual bool RemoveFromParent();
-       void Clear();
-       void Add(const SMDS_MeshElement * ME);
-       void Remove(const SMDS_MeshElement * ME);
-       bool IsEmpty() const;
-       int Extent() const;
-       SMDSAbs_ElementType Type() const;
-       bool Contains(const SMDS_MeshElement * ME) const;
-       
-        ~SMDS_MeshGroup();
+
+        const SMDS_Mesh* GetMesh() const { return myMesh; }
+
+        void SetType (const SMDSAbs_ElementType theType);
+        void Clear();
+       void Add(const SMDS_MeshElement * theElem);
+       void Remove(const SMDS_MeshElement * theElem);
+       bool IsEmpty() const { return myElements.empty(); }
+       int Extent() const { return myElements.size(); }
+
+        SMDSAbs_ElementType GetType() const { return myType; }
+
+       bool Contains(const SMDS_MeshElement * theElem) const;
+
+        void InitIterator() const
+        { const_cast<iterator&>(myIterator) = myElements.begin(); }
+
+        bool More() const { return myIterator != myElements.end(); }
+
+        const SMDS_MeshElement* Next() const
+        { return *(const_cast<iterator&>(myIterator))++; }
+
   private:
-       SMDS_MeshGroup(SMDS_MeshGroup* parent);
-       const SMDS_Mesh *myMesh;
-       SMDSAbs_ElementType myType;
-       set<const SMDS_MeshElement *> myElements;
-       SMDS_MeshGroup * myParent;
-       list<const SMDS_MeshGroup*> myChildren;
+       SMDS_MeshGroup(SMDS_MeshGroup* theParent,
+                       const SMDSAbs_ElementType theType = SMDSAbs_All);
+
+        typedef set<const SMDS_MeshElement *>::iterator iterator;
+       const SMDS_Mesh *                       myMesh;
+       SMDSAbs_ElementType                     myType;
+       set<const SMDS_MeshElement *>           myElements;
+       SMDS_MeshGroup *                        myParent;
+       list<const SMDS_MeshGroup*>             myChildren;
+        iterator                                myIterator;
 };
 #endif
index a68ae5ad0325a37bfe530818c2349cf123f77c17..db5df4222ce3d2f3fd5661f4ee9b5d621b8e0d6b 100644 (file)
@@ -54,5 +54,5 @@ int SMDS_MeshIDFactory::GetFreeID()
 //=======================================================================
 void SMDS_MeshIDFactory::ReleaseID(const int ID)
 {
-       if (ID < myMaxID) myPoolOfID.push(ID);
+  if (ID > 0 && ID < myMaxID) myPoolOfID.push(ID);
 }
index 20bce63695892d324ac8962a3daa3706a4ffa370..cba7920fa32232349423fd2ca7d7ddcb6643e0ce 100644 (file)
@@ -61,7 +61,7 @@ void SMDS_MeshNode::Print(ostream & OS) const
 //purpose  : 
 //=======================================================================
 
-void SMDS_MeshNode::SetPosition(SMDS_Position * aPos)
+void SMDS_MeshNode::SetPosition(const SMDS_PositionPtr& aPos)
 {
        myPosition = aPos;
 }
@@ -71,94 +71,92 @@ void SMDS_MeshNode::SetPosition(SMDS_Position * aPos)
 //purpose  : 
 //=======================================================================
 
-SMDS_Position *SMDS_MeshNode::GetPosition()
+const SMDS_PositionPtr& SMDS_MeshNode::GetPosition() const
 {
        return myPosition;
 }
 
-const SMDS_Position *SMDS_MeshNode::GetPosition() const
+class SMDS_MeshNode_MyInvIterator:public SMDS_ElemIterator
 {
-       return myPosition;
-}
-/**
-*/
-SMDS_Iterator<const SMDS_MeshElement*> * SMDS_MeshNode::
+  const set<const SMDS_MeshElement*>& mySet;
+  set<const SMDS_MeshElement*>::iterator myIterator;
+ public:
+  SMDS_MeshNode_MyInvIterator(const set<const SMDS_MeshElement*>& s):
+    mySet(s)
+  {
+    myIterator=mySet.begin();
+  }
+
+  bool more()
+  {
+    return myIterator!=mySet.end();
+  }
+
+  const SMDS_MeshElement* next()
+  {
+    const SMDS_MeshElement* current=*myIterator;
+    myIterator++;
+    return current;    
+  }    
+};
+
+SMDS_ElemIteratorPtr SMDS_MeshNode::
        GetInverseElementIterator() const
 {
-       class SMDS_InverseElementIterator:public SMDS_Iterator<const SMDS_MeshElement*>
-       {
-               const set<const SMDS_MeshElement*>& mySet;
-               set<const SMDS_MeshElement*>::iterator myIterator;
-         public:
-               SMDS_InverseElementIterator(const set<const SMDS_MeshElement*>& s):mySet(s)
-               {
-                       myIterator=mySet.begin();
-               }
-
-               bool more()
-               {
-                       return myIterator!=mySet.end();
-               }
-
-               const SMDS_MeshElement* next()
-               {
-                       const SMDS_MeshElement* current=*myIterator;
-                       myIterator++;
-                       return current; 
-               }       
-       };
-       return new SMDS_InverseElementIterator(myInverseElements);
-}
-
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_MeshNode::
+  return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(myInverseElements));
+}
+
+// Same as GetInverseElementIterator but the create iterator only return
+// wanted type elements.
+class SMDS_MeshNode_MyIterator:public SMDS_ElemIterator
+{
+  set<const SMDS_MeshElement*> mySet;
+  set<const SMDS_MeshElement*>::iterator myIterator;
+ public:
+  SMDS_MeshNode_MyIterator(SMDSAbs_ElementType type,
+                           const set<const SMDS_MeshElement*>& s)
+  {
+    const SMDS_MeshElement * e;
+    bool toInsert;
+    set<const SMDS_MeshElement*>::iterator it=s.begin();
+    while(it!=s.end())
+    {
+      e=*it;
+      switch(type)
+      {
+      case SMDSAbs_Edge: toInsert=true; break;
+      case SMDSAbs_Face: toInsert=(e->GetType()!=SMDSAbs_Edge); break;
+      case SMDSAbs_Volume: toInsert=(e->GetType()==SMDSAbs_Volume); break;
+      }
+      if(toInsert) mySet.insert(e);
+      it++;
+    }
+    myIterator=mySet.begin();
+  }
+
+  bool more()
+  {
+    return myIterator!=mySet.end();
+  }
+
+  const SMDS_MeshElement* next()
+  {
+    const SMDS_MeshElement* current=*myIterator;
+    myIterator++;
+    return current;
+  }
+};
+
+SMDS_ElemIteratorPtr SMDS_MeshNode::
        elementsIterator(SMDSAbs_ElementType type) const
 {
-       // Same as GetInverseElementIterator but the create iterator only return
-       // wanted type elements.
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
-       {
-               set<const SMDS_MeshElement*> mySet;
-               set<const SMDS_MeshElement*>::iterator myIterator;
-         public:
-               MyIterator(SMDSAbs_ElementType type,
-                       const set<const SMDS_MeshElement*>& s) 
-               {
-                       const SMDS_MeshElement * e;
-                       bool toInsert;
-                       set<const SMDS_MeshElement*>::iterator it=s.begin();
-                       while(it!=s.end())
-                       {
-                               e=*it;
-                               switch(type)
-                               {
-                               case SMDSAbs_Edge: toInsert=true; break;
-                               case SMDSAbs_Face: toInsert=(e->GetType()!=SMDSAbs_Edge); break;
-                               case SMDSAbs_Volume: toInsert=(e->GetType()==SMDSAbs_Volume); break;
-                               }
-                               if(toInsert) mySet.insert(e);
-                               it++;
-                       }       
-                       myIterator=mySet.begin();
-               }
-
-               bool more()
-               {
-                       return myIterator!=mySet.end();
-               }
-
-               const SMDS_MeshElement* next()
-               {
-                       const SMDS_MeshElement* current=*myIterator;
-                       myIterator++;
-                       return current; 
-               }       
-       };
-
-       if(type==SMDSAbs_Node)
-               return SMDS_MeshElement::elementsIterator(SMDSAbs_Node); 
-       else
-               return new SMDS_IteratorOfElements(this,type,
-                       new MyIterator(type, myInverseElements));
+  if(type==SMDSAbs_Node)
+    return SMDS_MeshElement::elementsIterator(SMDSAbs_Node); 
+  else
+    return SMDS_ElemIteratorPtr
+      (new SMDS_IteratorOfElements
+       (this,type,
+        SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(type, myInverseElements))));
 }
 
 int SMDS_MeshNode::NbNodes() const
index f53630705b57fff437725290405a7d9307216d49..01482f9226c7a86d52037dc4deec9161f04f5051 100644 (file)
@@ -46,22 +46,21 @@ class SMDS_MeshNode:public SMDS_MeshElement
        void RemoveInverseElement(const SMDS_MeshElement * parent);
        void ClearInverseElements();
        bool emptyInverseElements();
-       SMDS_Iterator<const SMDS_MeshElement*> * GetInverseElementIterator() const;     
-       void SetPosition(SMDS_Position * aPos);
-       SMDS_Position *GetPosition();
-       const SMDS_Position *GetPosition() const;
+       SMDS_ElemIteratorPtr GetInverseElementIterator() const; 
+       void SetPosition(const SMDS_PositionPtr& aPos);
+       const SMDS_PositionPtr& GetPosition() const;
        SMDSAbs_ElementType GetType() const;
        int NbNodes() const;
        void setXYZ(double x, double y, double z);
        friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2);
 
   protected:
-       SMDS_Iterator<const SMDS_MeshElement *> *
+       SMDS_ElemIteratorPtr
                elementsIterator(SMDSAbs_ElementType type) const;
 
   private:
        double myX, myY, myZ;
-       SMDS_Position *myPosition;
+       SMDS_PositionPtr myPosition;
        set<const SMDS_MeshElement*> myInverseElements;
 };
 
index 7e4bcd464717bbfa976bf1b3a228fea3f1ea84ea..8386f211566afd77415ac71ef8d4314383ac5108 100644 (file)
@@ -29,6 +29,7 @@
 
 class SMDS_MeshObject
 {
-  public:
+ public:
+  virtual ~SMDS_MeshObject() {}
 };
 #endif
index 29a54d82b624235c606e335eba4ec3c45553048a..6047c30c397612442670926a7b91339a9a7b9153 100644 (file)
 #define _SMDS_Position_HeaderFile
 
 #include "SMDS_TypeOfPosition.hxx"
+#include <boost/shared_ptr.hpp>
+
+class SMDS_Position;
+typedef boost::shared_ptr<SMDS_Position> SMDS_PositionPtr;
 
 class SMDS_Position
 {
@@ -37,7 +41,7 @@ class SMDS_Position
        virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const = 0;
        void SetShapeId(int aShapeId);
        int GetShapeId() const;
-        ~SMDS_Position();
+       virtual ~SMDS_Position() {}
 
   protected:
          SMDS_Position(int aShapeId);
index 82ef3d54f78f7a042036b3a3461e9352a407a2fe..7ce582f915ab4f75fe315c00460c46d8868cd56b 100644 (file)
@@ -52,8 +52,8 @@ const double * SMDS_SpacePosition::Coords() const
        return myCoords;
 }
 
-SMDS_SpacePosition * SMDS_SpacePosition::originSpacePosition()
+SMDS_PositionPtr SMDS_SpacePosition::originSpacePosition()
 {
-       static SMDS_SpacePosition * staticpos=new SMDS_SpacePosition();
-       return staticpos;
+  static SMDS_PositionPtr staticpos (new SMDS_SpacePosition());
+  return staticpos;
 }
index af995f175f8ed9c71812fb5c9dc188a4b7368397..e4fadd6b1837cf79ac9aafac5aff6bcc2511e94c 100644 (file)
@@ -37,8 +37,7 @@ class SMDS_SpacePosition:public SMDS_Position
        const virtual double * Coords() const;
        virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const;
        inline void SetCoords(const double x, const double y, const double z);
-        ~SMDS_SpacePosition();
-        static SMDS_SpacePosition * originSpacePosition();
+        static SMDS_PositionPtr originSpacePosition();
   private:
        double myCoords[3];     
 };
index c3a96337dc1c69b160a6889865cfa6ee57a87ed7..686e34e24b9a9663a72ad50ad5d28b74c4bc771f 100644 (file)
@@ -56,42 +56,48 @@ void SMDS_Tria3OfNodes::Print(ostream & OS) const
        OS << myNodes[i] << ") " << endl;
 }
 
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_Tria3OfNodes::
-       elementsIterator(SMDSAbs_ElementType type) const
+class SMDS_Tria3OfNodes_MyIterator:public SMDS_ElemIterator
 {
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
-       {
-               const SMDS_MeshNode * const* mySet;
-               int index;
-         public:
-               MyIterator(const SMDS_MeshNode * const* s):mySet(s),index(0)
-               {}
+  const SMDS_MeshNode * const* mySet;
+  int index;
+ public:
+  SMDS_Tria3OfNodes_MyIterator(const SMDS_MeshNode * const* s):
+    mySet(s),index(0) {}
 
-               bool more()
-               {
-                       return index<3;
-               }
+  bool more()
+  {
+    return index<3;
+  }
 
-               const SMDS_MeshElement* next()
-               {
-                       index++;
-                       return mySet[index-1];
-               }       
-       };
+  const SMDS_MeshElement* next()
+  {
+    index++;
+    return mySet[index-1];
+  }
+};
 
-       switch(type)
-       {
-       case SMDSAbs_Face:return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
-       case SMDSAbs_Node:return new MyIterator(myNodes);
-       case SMDSAbs_Edge:
-               MESSAGE("Error : edge iterator for SMDS_FaceOfNodes not implemented");
-               break;
-       default:return new SMDS_IteratorOfElements(this,type,new MyIterator(myNodes));
-       }
+SMDS_ElemIteratorPtr SMDS_Tria3OfNodes::
+       elementsIterator(SMDSAbs_ElementType type) const
+{
+  switch(type)
+  {
+  case SMDSAbs_Face:
+    return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
+  case SMDSAbs_Node:
+    return SMDS_ElemIteratorPtr(new SMDS_Tria3OfNodes_MyIterator(myNodes));
+  case SMDSAbs_Edge:
+    MESSAGE("Error : edge iterator for SMDS_FaceOfNodes not implemented");
+    break;
+  default:
+    return SMDS_ElemIteratorPtr
+      (new SMDS_IteratorOfElements
+       (this,type,SMDS_ElemIteratorPtr(new SMDS_Tria3OfNodes_MyIterator(myNodes))));
+  }
 }
 
-SMDS_Tria3OfNodes::SMDS_Tria3OfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2,
-       SMDS_MeshNode* node3)
+SMDS_Tria3OfNodes::SMDS_Tria3OfNodes(const SMDS_MeshNode* node1,
+                                     const SMDS_MeshNode* node2,
+                                     const SMDS_MeshNode* node3)
 {
        myNodes[0]=node1;
        myNodes[1]=node2;
index ee4c330da567e0ec22cda3bc597994a564dec269..63552a03d1735e93cb9f56b542374838af335fe3 100644 (file)
@@ -31,14 +31,15 @@ class SMDS_Tria3OfNodes:public SMDS_MeshFace
 {
   public:
        void Print(ostream & OS) const;
-       SMDS_Tria3OfNodes(SMDS_MeshNode* node1, SMDS_MeshNode* node2,
-               SMDS_MeshNode* node3);
+       SMDS_Tria3OfNodes(const SMDS_MeshNode* node1,
+                          const SMDS_MeshNode* node2,
+                          const SMDS_MeshNode* node3);
                
        int NbEdges() const;
        int NbFaces() const;
        int NbNodes() const;
   protected:
-       SMDS_Iterator<const SMDS_MeshElement *> *
+       SMDS_ElemIteratorPtr
                elementsIterator(SMDSAbs_ElementType type) const;
 
   private:
index 6fc5a3c61132aa174af54f2f61fca2d2308a5afa..52ef0591804abad199259494ec2ce8d00a7c024f 100644 (file)
@@ -36,7 +36,6 @@ class SMDS_VertexPosition:public SMDS_Position
        SMDS_TypeOfPosition GetTypeOfPosition() const;
        SMDS_VertexPosition(int aVertexId=0);
        const double *Coords() const;
-       ~SMDS_VertexPosition();
 };
 
 #endif
index c221452ba711c42c8ab15a756d3feb81b296f841..435107fe7ca2203dc9450e061254e919e0c3daba 100644 (file)
@@ -21,7 +21,7 @@
 //
 //
 //
-//  File   : SMDS_MeshVolume.cxx
+//  File   : SMDS_VolumeOfFaces.cxx
 //  Author : Jean-Michel BOULCOURT
 //  Module : SMESH
 
@@ -46,39 +46,46 @@ int SMDS_VolumeOfFaces::NbFaces() const
        return myFaces.size();
 }
 
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_VolumeOfFaces::
-       elementsIterator(SMDSAbs_ElementType type) const
+class SMDS_VolumeOfFaces_MyIterator:public SMDS_ElemIterator
 {
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
-       {
-               const vector<SMDS_MeshFace*>& mySet;
-               int index;
-         public:
-               MyIterator(const vector<SMDS_MeshFace*>& s):mySet(s),index(0)
-               {}
+  const vector<const SMDS_MeshFace*>& mySet;
+  int index;
+ public:
+  SMDS_VolumeOfFaces_MyIterator(const vector<const SMDS_MeshFace*>& s):
+    mySet(s),index(0) {}
 
-               bool more()
-               {
-                       return index<mySet.size();
-               }
+  bool more()
+  {
+    return index<mySet.size();
+  }
 
-               const SMDS_MeshElement* next()
-               {
-                       index++;
-                       return mySet[index-1];
-               }       
-       };
+  const SMDS_MeshElement* next()
+  {
+    index++;
+    return mySet[index-1];
+  }
+};
 
-       switch(type)
-       {
-       case SMDSAbs_Volume:return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
-       case SMDSAbs_Face:return new MyIterator(myFaces);
-       default:return new SMDS_IteratorOfElements(this,type,new MyIterator(myFaces));
-       }
+SMDS_ElemIteratorPtr SMDS_VolumeOfFaces::
+       elementsIterator(SMDSAbs_ElementType type) const
+{
+  switch(type)
+  {
+  case SMDSAbs_Volume:
+    return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
+  case SMDSAbs_Face:
+    return SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces));
+  default:
+    return SMDS_ElemIteratorPtr
+      (new SMDS_IteratorOfElements
+       (this,type,SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces))));
+  }
 }
 
-SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2,
-       SMDS_MeshFace * face3, SMDS_MeshFace * face4)
+SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
+                                       const SMDS_MeshFace * face2,
+                                       const SMDS_MeshFace * face3,
+                                       const SMDS_MeshFace * face4)
 {
        myFaces.resize(4);
        myFaces[0]=face1;
@@ -87,9 +94,11 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * fa
        myFaces[3]=face4;
 }
 
-SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2,
-               SMDS_MeshFace * face3, SMDS_MeshFace * face4,
-               SMDS_MeshFace * face5)
+SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
+                                       const SMDS_MeshFace * face2,
+                                       const SMDS_MeshFace * face3,
+                                       const SMDS_MeshFace * face4,
+                                       const SMDS_MeshFace * face5)
 {
        myFaces.resize(5);
        myFaces[0]=face1;
@@ -99,9 +108,12 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * fa
        myFaces[4]=face5;
 }
 
-SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2,
-               SMDS_MeshFace * face3, SMDS_MeshFace * face4,
-               SMDS_MeshFace * face5,SMDS_MeshFace * face6)
+SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
+                                       const SMDS_MeshFace * face2,
+                                       const SMDS_MeshFace * face3,
+                                       const SMDS_MeshFace * face4,
+                                       const SMDS_MeshFace * face5,
+                                       const SMDS_MeshFace * face6)
 {
        myFaces.resize(6);
        myFaces[0]=face1;
index 05480f3df0ea075ee98627bd000a7b24f5f1e6e7..7ea45b37caf3d15b72c85a7baf629fadbc1700e3 100644 (file)
@@ -21,7 +21,7 @@
 //
 //
 //
-//  File   : SMDS_MeshVolume.hxx
+//  File   : SMDS_VolumeOfFaces.hxx
 //  Module : SMESH
 
 #ifndef _SMDS_VolumeOfFaces_HeaderFile
@@ -38,22 +38,29 @@ class SMDS_VolumeOfFaces:public SMDS_MeshVolume
 {
        
   public:
-       SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2,
-               SMDS_MeshFace * face3, SMDS_MeshFace * face4);
-       SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2,
-               SMDS_MeshFace * face3, SMDS_MeshFace * face4,
-               SMDS_MeshFace * face5);
-       SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2,
-               SMDS_MeshFace * face3, SMDS_MeshFace * face4,
-               SMDS_MeshFace * face5,SMDS_MeshFace * face6);
+       SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
+                           const SMDS_MeshFace * face2,
+                           const SMDS_MeshFace * face3,
+                           const SMDS_MeshFace * face4);
+       SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
+                           const SMDS_MeshFace * face2,
+                           const SMDS_MeshFace * face3,
+                           const SMDS_MeshFace * face4,
+                           const SMDS_MeshFace * face5);
+       SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
+                           const SMDS_MeshFace * face2,
+                           const SMDS_MeshFace * face3,
+                           const SMDS_MeshFace * face4,
+                           const SMDS_MeshFace * face5,
+                           const SMDS_MeshFace * face6);
 
        void Print(ostream & OS) const;
        
        int NbFaces() const;
 
   protected:
-       SMDS_Iterator<const SMDS_MeshElement *> *
+       SMDS_ElemIteratorPtr
                elementsIterator(SMDSAbs_ElementType type) const;
-       vector<SMDS_MeshFace *> myFaces;
+       vector<const SMDS_MeshFace *> myFaces;
 };
 #endif
index b2a7a547d16c27d8661691337256f4cee7294d0b..3f4d6a2458504f08aff7938b0b1bd17b779d8d9c 100644 (file)
 /// 5,1 and 7,3 are an edges.
 ///////////////////////////////////////////////////////////////////////////////
 SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
-               SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2,
-               SMDS_MeshNode * node3,
-               SMDS_MeshNode * node4,
-               SMDS_MeshNode * node5,
-               SMDS_MeshNode * node6,
-               SMDS_MeshNode * node7,
-               SMDS_MeshNode * node8)
+               const SMDS_MeshNode * node1,
+               const SMDS_MeshNode * node2,
+               const SMDS_MeshNode * node3,
+               const SMDS_MeshNode * node4,
+               const SMDS_MeshNode * node5,
+               const SMDS_MeshNode * node6,
+               const SMDS_MeshNode * node7,
+               const SMDS_MeshNode * node8)
 {
        myNodes.resize(8);
        myNodes[0]=node1;
@@ -49,10 +49,10 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
 }
 
 SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
-               SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2,
-               SMDS_MeshNode * node3,
-               SMDS_MeshNode * node4)
+               const SMDS_MeshNode * node1,
+               const SMDS_MeshNode * node2,
+               const SMDS_MeshNode * node3,
+               const SMDS_MeshNode * node4)
 {
        myNodes.resize(4);
        myNodes[0]=node1;
@@ -62,11 +62,11 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
 }
 
 SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
-               SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2,
-               SMDS_MeshNode * node3,
-               SMDS_MeshNode * node4,
-               SMDS_MeshNode * node5)
+               const SMDS_MeshNode * node1,
+               const SMDS_MeshNode * node2,
+               const SMDS_MeshNode * node3,
+               const SMDS_MeshNode * node4,
+               const SMDS_MeshNode * node5)
 {
        myNodes.resize(5);
        myNodes[0]=node1;
@@ -77,12 +77,12 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
 }
 
 SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
-               SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2,
-               SMDS_MeshNode * node3,
-               SMDS_MeshNode * node4,
-               SMDS_MeshNode * node5,
-               SMDS_MeshNode * node6)
+               const SMDS_MeshNode * node1,
+               const SMDS_MeshNode * node2,
+               const SMDS_MeshNode * node3,
+               const SMDS_MeshNode * node4,
+               const SMDS_MeshNode * node5,
+               const SMDS_MeshNode * node6)
 {
        myNodes.resize(6);
        myNodes[0]=node1;
@@ -134,34 +134,39 @@ int SMDS_VolumeOfNodes::NbEdges() const
        }
 }
 
-SMDS_Iterator<const SMDS_MeshElement *> * SMDS_VolumeOfNodes::
-       elementsIterator(SMDSAbs_ElementType type) const
+class SMDS_VolumeOfNodes_MyIterator:public SMDS_ElemIterator
 {
-       class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
-       {
-               const vector<const SMDS_MeshNode*>& mySet;
-               int index;
-         public:
-               MyIterator(const vector<const SMDS_MeshNode*>& s):mySet(s),index(0)
-               {}
+  const vector<const SMDS_MeshNode*>& mySet;
+  int index;
+ public:
+  SMDS_VolumeOfNodes_MyIterator(const vector<const SMDS_MeshNode*>& s):
+    mySet(s),index(0) {}
 
-               bool more()
-               {
-                       return index<mySet.size();
-               }
+  bool more()
+  {
+    return index<mySet.size();
+  }
 
-               const SMDS_MeshElement* next()
-               {
-                       index++;
-                       return mySet[index-1];
-               }       
-       };
-       switch(type)
-       {
-       case SMDSAbs_Volume:return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
-       case SMDSAbs_Node:return new MyIterator(myNodes);
-       default: MESSAGE("ERROR : Iterator not implemented");
-       }
+  const SMDS_MeshElement* next()
+  {
+    index++;
+    return mySet[index-1];
+  }
+};
+
+SMDS_ElemIteratorPtr SMDS_VolumeOfNodes::
+       elementsIterator(SMDSAbs_ElementType type) const
+{
+  switch(type)
+  {
+  case SMDSAbs_Volume:
+    return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
+  case SMDSAbs_Node:
+    return SMDS_ElemIteratorPtr(new SMDS_VolumeOfNodes_MyIterator(myNodes));
+  default:
+    MESSAGE("ERROR : Iterator not implemented");
+    return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
+  }
 }
 
 SMDSAbs_ElementType SMDS_VolumeOfNodes::GetType() const
index c7c3529c3b841e1aafd2828373c10f64c448665d..7d4aa27dea733aab73aae92eeeeebe9d4058dfae 100644 (file)
@@ -36,32 +36,32 @@ class SMDS_VolumeOfNodes:public SMDS_MeshVolume
        
   public:
        SMDS_VolumeOfNodes(
-               SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2,
-               SMDS_MeshNode * node3,
-               SMDS_MeshNode * node4);
+               const SMDS_MeshNode * node1,
+               const SMDS_MeshNode * node2,
+               const SMDS_MeshNode * node3,
+               const SMDS_MeshNode * node4);
        SMDS_VolumeOfNodes(
-               SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2,
-               SMDS_MeshNode * node3,
-               SMDS_MeshNode * node4,
-               SMDS_MeshNode * node5);
+               const SMDS_MeshNode * node1,
+               const SMDS_MeshNode * node2,
+               const SMDS_MeshNode * node3,
+               const SMDS_MeshNode * node4,
+               const SMDS_MeshNode * node5);
        SMDS_VolumeOfNodes(
-               SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2,
-               SMDS_MeshNode * node3,
-               SMDS_MeshNode * node4,
-               SMDS_MeshNode * node5,
-               SMDS_MeshNode * node6);
+               const SMDS_MeshNode * node1,
+               const SMDS_MeshNode * node2,
+               const SMDS_MeshNode * node3,
+               const SMDS_MeshNode * node4,
+               const SMDS_MeshNode * node5,
+               const SMDS_MeshNode * node6);
        SMDS_VolumeOfNodes(
-               SMDS_MeshNode * node1,
-               SMDS_MeshNode * node2,
-               SMDS_MeshNode * node3,
-               SMDS_MeshNode * node4,
-               SMDS_MeshNode * node5,
-               SMDS_MeshNode * node6,
-               SMDS_MeshNode * node7,
-               SMDS_MeshNode * node8);
+               const SMDS_MeshNode * node1,
+               const SMDS_MeshNode * node2,
+               const SMDS_MeshNode * node3,
+               const SMDS_MeshNode * node4,
+               const SMDS_MeshNode * node5,
+               const SMDS_MeshNode * node6,
+               const SMDS_MeshNode * node7,
+               const SMDS_MeshNode * node8);
 
        void Print(ostream & OS) const;
        int NbFaces() const;
@@ -69,7 +69,7 @@ class SMDS_VolumeOfNodes:public SMDS_MeshVolume
        int NbEdges() const;
        SMDSAbs_ElementType GetType() const;    
   protected:
-       SMDS_Iterator<const SMDS_MeshElement *> *
+       SMDS_ElemIteratorPtr
                elementsIterator(SMDSAbs_ElementType type) const;
        vector<const SMDS_MeshNode *> myNodes;
 };
index ef442ef40ece61a948208134811f878f32b4f4c8..f8fe6b7fa1048179b370b9f85d700f359bcfdaa7 100644 (file)
@@ -29,7 +29,7 @@
 top_srcdir=@top_srcdir@
 top_builddir=../..
 srcdir=@srcdir@
-VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
+VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl
 
 
 @COMMENCE@
@@ -40,22 +40,11 @@ EXPORT_HEADERS= \
        SMESH_Mesh.hxx \
        SMESH_subMesh.hxx \
        SMESH_Hypothesis.hxx \
-       SMESH_HypothesisFactory.hxx \
        SMESH_Algo.hxx \
        SMESH_1D_Algo.hxx \
        SMESH_2D_Algo.hxx \
        SMESH_3D_Algo.hxx \
-       SMESH_NumberOfSegments.hxx \
-       SMESH_LocalLength.hxx \
-       SMESH_LengthFromEdges.hxx \
-       SMESH_MaxElementArea.hxx \
-       SMESH_MaxElementVolume.hxx \
-       SMESH_Regular_1D.hxx \
-       SMESH_Quadrangle_2D.hxx \
-       SMESH_MEFISTO_2D.hxx \
-       SMESH_Hexa_3D.hxx \
-       SMESH_NETGEN_3D.hxx \
-       SMESH_HypothesisCreator.hxx
+       SMESH_Group.hxx
 
 EXPORT_PYSCRIPTS =
 
@@ -65,20 +54,11 @@ LIB= libSMESHimpl.la
 
 LIB_SRC = SMESH_Gen.cxx SMESH_Mesh.cxx SMESH_subMesh.cxx \
          SMESH_Hypothesis.cxx \
-          SMESH_HypothesisFactory.cxx \
          SMESH_Algo.cxx \
          SMESH_1D_Algo.cxx \
          SMESH_2D_Algo.cxx \
          SMESH_3D_Algo.cxx \
-         SMESH_NumberOfSegments.cxx \
-         SMESH_LocalLength.cxx \
-         SMESH_LengthFromEdges.cxx \
-         SMESH_MaxElementArea.cxx \
-         SMESH_MaxElementVolume.cxx \
-         SMESH_Regular_1D.cxx \
-         SMESH_Quadrangle_2D.cxx \
-         SMESH_MEFISTO_2D.cxx \
-         SMESH_Hexa_3D.cxx
+         SMESH_Group.cxx
 
 LIB_SERVER_IDL = 
 
@@ -89,20 +69,13 @@ BIN =
 BIN_SRC = 
 
 # additionnal information to compil and link file
-CPPFLAGS+= $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS+= $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
+           $(BOOST_CPPFLAGS)
 CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
 
 #IDLCXXFLAGS+= -Wbtp
 
-LDFLAGS+= $(HDF5_LIBS) $(MED2_LIBS) -lOpUtil -lSMESHDS -lSMDS -lMEFISTO2D -lMeshDriverDAT -lMeshDriverMED -lMeshDriverUNV -L${KERNEL_ROOT_DIR}/lib/salome
-
-ifeq (@WITHNETGEN@,yes)
-  LIB_SRC+= SMESH_NETGEN_3D.cxx
-  NETGEN_INCLUDES=@NETGEN_INCLUDES@
-  CPPFLAGS+= $(NETGEN_INCLUDES)
-  CXXFLAGS+= $(NETGEN_INCLUDES)
-  LDFLAGS+=  -lNETGEN
-endif
+LDFLAGS+= $(HDF5_LIBS) $(MED2_LIBS) -lOpUtil -lSMESHDS -lSMDS -lMeshDriverDAT -lMeshDriverMED -lMeshDriverUNV -L${KERNEL_ROOT_DIR}/lib/salome
 
 @CONCLUDE@
 
index caa3978e95b25a049f47424f4a49f6a3989e987b..846f28fb00e6248744ad9faec7e0da97532aed97 100644 (file)
@@ -26,7 +26,6 @@
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 using namespace std;
 #include "SMESH_1D_Algo.hxx"
 #include "SMESH_Gen.hxx"
@@ -55,47 +54,3 @@ SMESH_1D_Algo::~SMESH_1D_Algo()
 {
 }
 
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream & SMESH_1D_Algo::SaveTo(ostream & save)
-{
-  return save << this;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & SMESH_1D_Algo::LoadFrom(istream & load)
-{
-  return load >> (*this);
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream& operator << (ostream & save, SMESH_1D_Algo & hyp)
-{
-  return save;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream& operator >> (istream & load, SMESH_1D_Algo & hyp)
-{
-  return load;
-}
-
index cdacad4acf7729732662b1102661a22b95dec8b3..378ed7545263959294ac38a4fdb6b59d0a43c7e3 100644 (file)
@@ -37,13 +37,6 @@ class SMESH_1D_Algo:
 public:
   SMESH_1D_Algo(int hypId, int studyId,  SMESH_Gen* gen);
   virtual ~SMESH_1D_Algo();
-
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream& operator << (ostream & save, SMESH_1D_Algo & hyp);
-  friend istream& operator >> (istream & load, SMESH_1D_Algo & hyp);
-
-protected:
 };
 
 #endif
index 90102e5edd6e4cf2de794c0194b855dd0e3b7d2d..c84a353983c0ac5da9aabf5c5cb5fb6a45a5d539 100644 (file)
@@ -26,7 +26,6 @@
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 using namespace std;
 #include "SMESH_2D_Algo.hxx"
 #include "SMESH_Gen.hxx"
@@ -63,50 +62,6 @@ SMESH_2D_Algo::~SMESH_2D_Algo()
  */
 //=============================================================================
 
-ostream & SMESH_2D_Algo::SaveTo(ostream & save)
-{
-  return save << this;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & SMESH_2D_Algo::LoadFrom(istream & load)
-{
-  return load >> (*this);
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream& operator << (ostream & save, SMESH_2D_Algo & hyp)
-{
-  return save;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream& operator >> (istream & load, SMESH_2D_Algo & hyp)
-{
-  return load;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
 int SMESH_2D_Algo::NumberOfWires(const TopoDS_Shape& S)
 {
   int i = 0;
index fbf99f60bfcb6c1891d38a2c944b3b0c338c115e..5c904e22ef89ea1366a1c566a2f58c2ec647246e 100644 (file)
@@ -41,13 +41,6 @@ public:
 
   int NumberOfWires(const TopoDS_Shape& S);
   int NumberOfPoints(SMESH_Mesh& aMesh,const TopoDS_Wire& W);
-
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream& operator << (ostream & save, SMESH_2D_Algo & hyp);
-  friend istream& operator >> (istream & load, SMESH_2D_Algo & hyp);
-
-protected:
 };
 
 #endif
index 603d80ee60c2f8eb44b6d7759bda7d562555288d..ce35f66d40dd6f739cb631e71891712f9d0e940a 100644 (file)
@@ -26,7 +26,6 @@
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 using namespace std;
 #include "SMESH_3D_Algo.hxx"
 #include "SMESH_Gen.hxx"
@@ -56,47 +55,3 @@ SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen)
 SMESH_3D_Algo::~SMESH_3D_Algo()
 {
 }
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream & SMESH_3D_Algo::SaveTo(ostream & save)
-{
-  return save << this;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & SMESH_3D_Algo::LoadFrom(istream & load)
-{
-  return load >> (*this);
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream& operator << (ostream & save, SMESH_3D_Algo & hyp)
-{
-  return save;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream& operator >> (istream & load, SMESH_3D_Algo & hyp)
-{
-  return load;
-}
index 330624693600384abc93f53ba2230f02d4e00ebb..62621ce3cf532645b7efa60e9a9279206790451a 100644 (file)
@@ -37,13 +37,6 @@ class SMESH_3D_Algo:
 public:
   SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen);
   virtual ~SMESH_3D_Algo();
-
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream& operator << (ostream & save, SMESH_3D_Algo & hyp);
-  friend istream& operator >> (istream & load, SMESH_3D_Algo & hyp);
-
-protected:
 };
 
 #endif
index 234b7ecce8e0a661b71e2f94d35c738fea1574ad..cef1ea89c70ad30bd520ac6fefa25a5cc81cf69a 100644 (file)
@@ -26,7 +26,6 @@
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 using namespace std;
 #include "SMESH_Algo.hxx"
 #include "SMESH_Gen.hxx"
@@ -39,6 +38,8 @@ using namespace std;
 #include "utilities.h"
 
 #include <algorithm>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
 
 //=============================================================================
 /*!
@@ -52,6 +53,8 @@ SMESH_Algo::SMESH_Algo(int hypId, int studyId,
 //   _compatibleHypothesis.push_back("hypothese_bidon");
        _type = ALGO;
        gen->_mapAlgo[hypId] = this;
+
+        _onlyUnaryInput = _requireDescretBoundary = true;
 }
 
 //=============================================================================
@@ -75,77 +78,6 @@ const vector < string > &SMESH_Algo::GetCompatibleHypothesis()
        return _compatibleHypothesis;
 }
 
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream & SMESH_Algo::SaveTo(ostream & save)
-{
-       return save << this;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & SMESH_Algo::LoadFrom(istream & load)
-{
-       return load >> (*this);
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream & operator <<(ostream & save, SMESH_Algo & hyp)
-{
-       return save;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & operator >>(istream & load, SMESH_Algo & hyp)
-{
-       return load;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-bool SMESH_Algo::CheckHypothesis(SMESH_Mesh & aMesh,
-       const TopoDS_Shape & aShape)
-{
-       MESSAGE("SMESH_Algo::CheckHypothesis");
-       ASSERT(0);                                      // use method from derived classes
-       return false;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-bool SMESH_Algo::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
-{
-       MESSAGE("SMESH_Algo::Compute");
-       ASSERT(0);                                      // use method from derived classes
-       return false;
-}
-
 //=============================================================================
 /*!
  *  List the hypothesis used by the algorithm associated to the shape.
@@ -164,12 +96,21 @@ const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis(
        int nbHyp = _usedHypList.size();
        if (nbHyp == 0)
        {
-               TopoDS_Shape mainShape = aMesh.GetMeshDS()->ShapeToMesh();
-               if (!mainShape.IsSame(aShape))
-               {
-                       _usedHypList = GetAppliedHypothesis(aMesh, mainShape);  // copy
-                       nbHyp = _usedHypList.size();
-               }
+          TopTools_ListIteratorOfListOfShape ancIt( aMesh.GetAncestors( aShape ));
+          for (; ancIt.More(); ancIt.Next())
+          {
+            const TopoDS_Shape& ancestor = ancIt.Value();
+            _usedHypList = GetAppliedHypothesis(aMesh, ancestor);      // copy
+            nbHyp = _usedHypList.size();
+            if (nbHyp == 1)
+              break;
+          }
+//             TopoDS_Shape mainShape = aMesh.GetMeshDS()->ShapeToMesh();
+//             if (!mainShape.IsSame(aShape))
+//             {
+//                     _usedHypList = GetAppliedHypothesis(aMesh, mainShape);  // copy
+//                     nbHyp = _usedHypList.size();
+//             }
        }
        if (nbHyp > 1)
                _usedHypList.clear();   //only one compatible hypothesis allowed
index 53a0fbdde814bbf241e65fd8cd22e7d767a7d65e..d19bd94f32a3ff6bef508b8d3c0880c041db7780 100644 (file)
@@ -39,7 +39,7 @@
 #include <list>
 using namespace std;
 
-class SMESH_gen;
+class SMESH_Gen;
 class SMESH_Mesh;
 
 class SMESH_Algo:public SMESH_Hypothesis
@@ -49,10 +49,11 @@ class SMESH_Algo:public SMESH_Hypothesis
          virtual ~ SMESH_Algo();
 
        const vector < string > &GetCompatibleHypothesis();
-       virtual bool CheckHypothesis(SMESH_Mesh & aMesh,
-               const TopoDS_Shape & aShape);
+       virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+                                     const TopoDS_Shape& aShape,
+                                     SMESH_Hypothesis::Hypothesis_Status& aStatus) = 0;
 
-       virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
+       virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0;
 
        virtual const list <const SMESHDS_Hypothesis *> &
                GetUsedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
@@ -62,15 +63,29 @@ class SMESH_Algo:public SMESH_Hypothesis
 
        static double EdgeLength(const TopoDS_Edge & E);
 
-       virtual ostream & SaveTo(ostream & save);
-       virtual istream & LoadFrom(istream & load);
-       friend ostream & operator <<(ostream & save, SMESH_Algo & hyp);
-       friend istream & operator >>(istream & load, SMESH_Algo & hyp);
+ public:
+        // algo features
 
-  protected:
-         vector<string> _compatibleHypothesis;
-         list<const SMESHDS_Hypothesis *> _appliedHypList;
-         list<const SMESHDS_Hypothesis *> _usedHypList;
+        // SMESH_Hypothesis::GetDim();
+        // 1 - dimention of target mesh
+
+        bool OnlyUnaryInput() const { return _onlyUnaryInput; }
+        // 2 - is collection of tesselatable shapes inacceptable as input;
+        // "collection" means a shape containing shapes of dim equal
+        // to GetDim().
+        // Algo which can process a collection shape should expect
+        // an input temporary shape that is neither MainShape nor
+        // its child.
+        
+        bool NeedDescretBoundary() const { return _requireDescretBoundary; }
+        // 3 - is a Dim-1 mesh prerequisite
+
+ protected:
+        bool _onlyUnaryInput;
+        bool _requireDescretBoundary;
+        vector<string> _compatibleHypothesis;
+        list<const SMESHDS_Hypothesis *> _appliedHypList;
+        list<const SMESHDS_Hypothesis *> _usedHypList;
 };
 
 #endif
index ec40c71ff9a7d3335fdee3cb5a09e6687dd55897..44000dfac64f0a05e6128c064f375586c69e0151 100644 (file)
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
 
+#include "utilities.h"
+#include "OpUtil.hxx"
+
 #include <gp_Pnt.hxx>
 #include <BRep_Tool.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include "Utils_ExceptHandlers.hxx"
 
-#include "utilities.h"
-#include "OpUtil.hxx"
 
 //=============================================================================
 /*!
@@ -47,7 +51,7 @@ SMESH_Gen::SMESH_Gen()
 {
        MESSAGE("SMESH_Gen::SMESH_Gen");
        _localId = 0;
-       _hypothesisFactory.SetGen(this);
+       _hypId = 0;
 }
 
 //=============================================================================
@@ -67,7 +71,7 @@ SMESH_Gen::~SMESH_Gen()
  */
 //=============================================================================
 
-SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
+/*SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
        throw(SALOME_Exception)
 {
 
@@ -88,7 +92,7 @@ SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
 
        myStudyContext->myDocument->AddHypothesis(myHypothesis);
        return myHypothesis;
-}
+}*/
 
 //=============================================================================
 /*!
@@ -96,10 +100,11 @@ SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
  */
 //=============================================================================
 
-SMESH_Mesh *SMESH_Gen::Init(int studyId, const TopoDS_Shape & aShape)
+SMESH_Mesh* SMESH_Gen::CreateMesh(int studyId)
 throw(SALOME_Exception)
 {
-       MESSAGE("SMESH_Gen::Init");
+        Unexpect aCatch(SalomeException);
+       MESSAGE("SMESH_Gen::CreateMesh");
 //   if (aShape.ShapeType() == TopAbs_COMPOUND)
 //     {
 //       INFOS("Mesh Compound not yet implemented!");
@@ -120,7 +125,7 @@ throw(SALOME_Exception)
 
        // associate a TopoDS_Shape to the mesh
 
-       mesh->ShapeToMesh(aShape);
+//mesh->ShapeToMesh(aShape);
        return mesh;
 }
 
@@ -131,151 +136,604 @@ throw(SALOME_Exception)
 //=============================================================================
 
 bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
-throw(SALOME_Exception)
 {
-       MESSAGE("SMESH_Gen::Compute");
-//   bool isDone = false;
-/* 
-Algo : s'appuie ou non sur une geometrie
-Si geometrie:
-Vertex : rien à faire (range le point)
-Edge, Wire, collection d'edge et wire : 1D
-Face, Shell, collection de Face et Shells : 2D
-Solid, Collection de Solid : 3D
-*/
-// *** corriger commentaires
-       // check hypothesis associated to the mesh :
-       // - only one algo : type compatible with the type of the shape
-       // - hypothesis = compatible with algo
-       //    - check if hypothesis are applicable to this algo
-       //    - check contradictions within hypothesis
-       //    (test if enough hypothesis is done further)
-
-       bool ret = true;
-
-       SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
-//   SCRUTE(sm);
-       SMESH_subMesh *smToCompute = sm->GetFirstToCompute();
-       while (smToCompute)
-       {
-               TopoDS_Shape subShape = smToCompute->GetSubShape();
-               int dim = GetShapeDim(subShape);
-               //SCRUTE(dim);
-               if (dim > 0)
-               {
-                       bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
-                       ret = ret && ret1;
-               }
-               else
-               {
-                       ASSERT(dim == 0);
-                       ASSERT(smToCompute->_vertexSet == false);
-                       TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
-                       gp_Pnt P1 = BRep_Tool::Pnt(V1);
-                       SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
-                       //MESSAGE("point "<<nodeId<<" "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z());
-                       SMDS_MeshNode * node = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
-                       meshDS->SetNodeOnVertex(node, V1);
-                       smToCompute->GetSubMeshDS();
-                       smToCompute->_vertexSet = true;
-                       smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
-               }
-               smToCompute = sm->GetFirstToCompute();
-       }
-
-       return ret;
+  MESSAGE("SMESH_Gen::Compute");
+  //   bool isDone = false;
+  /* 
+     Algo : s'appuie ou non sur une geometrie
+     Si geometrie:
+     Vertex : rien à faire (range le point)
+     Edge, Wire, collection d'edge et wire : 1D
+     Face, Shell, collection de Face et Shells : 2D
+     Solid, Collection de Solid : 3D
+     */
+  // *** corriger commentaires
+  // check hypothesis associated to the mesh :
+  // - only one algo : type compatible with the type of the shape
+  // - hypothesis = compatible with algo
+  //    - check if hypothesis are applicable to this algo
+  //    - check contradictions within hypothesis
+  //    (test if enough hypothesis is done further)
+
+  bool ret = true;
+
+  if ( !CheckAlgoState( aMesh, aShape ))
+  {
+    INFOS( "ABORT MESHING: some algos or hypothesis are missing");
+    return false;
+  }
+
+  SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
+
+  // -----------------------------------------------------------------
+  // apply algos that do not require descretized boundaries, starting
+  // from the most complex shapes
+  // -----------------------------------------------------------------
+  
+  // map containing all subshapes in the order: vertices, edges, faces...
+  const map<int, SMESH_subMesh*>& smMap = sm->DependsOn();
+  map<int, SMESH_subMesh*>::const_reverse_iterator revItSub = smMap.rbegin();
+
+  SMESH_subMesh* smToCompute = sm;
+  while ( smToCompute )
+  {
+    const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
+    if ( GetShapeDim( aSubShape ) < 1 ) break;
+
+    SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
+    if (algo &&
+        !algo->NeedDescretBoundary() &&
+        smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE )
+    {
+      ret = smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
+    }
+    if (!ret)
+      return false;
+
+    // next subMesh
+    if (revItSub != smMap.rend())
+    {
+      smToCompute = (*revItSub).second;
+      revItSub++;
+    }
+    else
+      smToCompute = 0;
+  }
+    
+  // -----------------------------------------------
+  // mesh the rest subshapes starting from vertices
+  // -----------------------------------------------
+  
+  smToCompute = sm->GetFirstToCompute();
+  while (smToCompute)
+  {
+    TopoDS_Shape subShape = smToCompute->GetSubShape();
+    int dim = GetShapeDim(subShape);
+    if (dim > 0)
+    {
+      //MESSAGE ( "MESH shape id=" << smToCompute->GetId() <<
+        //       " type=" << smToCompute->GetSubShape().ShapeType());
+      bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
+      ret = ret && ret1;
+    }
+    else
+    {
+      ASSERT(dim == 0);
+      ASSERT(smToCompute->_vertexSet == false);
+      TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
+      gp_Pnt P1 = BRep_Tool::Pnt(V1);
+      SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+      //MESSAGE("point "<<nodeId<<" "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z());
+      SMDS_MeshNode * node = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
+      if ( node ) {  // san - increase robustness
+        meshDS->SetNodeOnVertex(node, V1);
+        smToCompute->GetSubMeshDS();
+        smToCompute->_vertexSet = true;
+        smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
+      }
+    }
+    smToCompute = sm->GetFirstToCompute();
+  }
+
+  MESSAGE( "VSR - SMESH_Gen::Compute() finished" );
+  return ret;
 }
 
-//=============================================================================
-/*!
- * 
- */
-//=============================================================================
 
-SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
+//=======================================================================
+//function : checkConformIgnoredAlgos
+//purpose  : 
+//=======================================================================
+
+static bool checkConformIgnoredAlgos(SMESH_Mesh&               aMesh,
+                                     SMESH_subMesh*            aSubMesh,
+                                     const SMESH_Algo*         aGlobIgnoAlgo,
+                                     const SMESH_Algo*         aLocIgnoAlgo,
+                                     bool &                    checkConform,
+                                     map<int, SMESH_subMesh*>& aCheckedMap)
 {
-       //MESSAGE("SMESH_Gen::GetAlgo");
+  ASSERT( aSubMesh );
+  if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
+    return true;
+
+
+  bool ret = true;
+
+  const list<const SMESHDS_Hypothesis*>& listHyp =
+    aMesh.GetMeshDS()->GetHypothesis( aSubMesh->GetSubShape() );
+  list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+  for ( ; it != listHyp.end(); it++)
+  {
+    const SMESHDS_Hypothesis * aHyp = *it;
+    if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+      continue;
+
+    const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
+    ASSERT ( algo );
+    
+    if ( aLocIgnoAlgo ) // algo is hidden by a local algo of upper dim
+    {
+      INFOS( "Local <" << algo->GetName() << "> is hidden by local <"
+            << aLocIgnoAlgo->GetName() << ">");
+    }
+    else
+    {
+      bool isGlobal = (aMesh.IsMainShape( aSubMesh->GetSubShape() ));
+      int dim = algo->GetDim();
+      int aMaxGlobIgnoDim = ( aGlobIgnoAlgo ? aGlobIgnoAlgo->GetDim() : -1 );
+
+      if ( dim < aMaxGlobIgnoDim )
+      {
+        // algo is hidden by a global algo
+        INFOS( ( isGlobal ? "Global" : "Local" ) 
+              << " <" << algo->GetName() << "> is hidden by global <"
+              << aGlobIgnoAlgo->GetName() << ">");
+      }
+      else if ( !algo->NeedDescretBoundary() && !isGlobal)
+      {
+        // local algo is not hidden and hides algos on sub-shapes
+        if (checkConform && !aSubMesh->IsConform( algo ))
+        {
+          ret = false;
+          checkConform = false; // no more check conformity
+          INFOS( "ERROR: Local <" << algo->GetName() <<
+                "> would produce not conform mesh: "
+                "<Not Conform Mesh Allowed> hypotesis is missing");
+        }
+
+        // sub-algos will be hidden by a local <algo>
+        const map<int, SMESH_subMesh*>& smMap = aSubMesh->DependsOn();
+        map<int, SMESH_subMesh*>::const_reverse_iterator revItSub;
+        bool checkConform2 = false;
+          for ( revItSub = smMap.rbegin(); revItSub != smMap.rend(); revItSub++)
+        {
+          checkConformIgnoredAlgos (aMesh, (*revItSub).second, aGlobIgnoAlgo,
+                                    algo, checkConform2, aCheckedMap);
+          int key = (*revItSub).first;
+         SMESH_subMesh* sm = (*revItSub).second;
+          if ( aCheckedMap.find( key ) == aCheckedMap.end() )
+          {
+            aCheckedMap[ key ] = sm;
+          }
+        }
+      }
+    }
+  }
+  
+  return ret;
+}
 
-       const SMESHDS_Hypothesis *theHyp = NULL;
-       SMESH_Algo *algo = NULL;
-       const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
-       int hypType;
-       int hypId;
-       int algoDim;
+//=======================================================================
+//function : checkMissing
+//purpose  : notify on missing hypothesis
+//           Return false if algo or hipothesis is missing
+//=======================================================================
+
+static bool checkMissing(SMESH_Gen*                aGen,
+                         SMESH_Mesh&               aMesh,
+                         SMESH_subMesh*            aSubMesh,
+                         const int                 aTopAlgoDim,
+                         bool*                     globalChecked,
+                         const bool                checkNoAlgo,
+                         map<int, SMESH_subMesh*>& aCheckedMap)
+{
+  if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
+    return true;
+  
+  //MESSAGE("=====checkMissing");
+
+  int ret = true;
+  SMESH_Algo* algo = 0;
+
+  switch (aSubMesh->GetAlgoState())
+  {
+  case SMESH_subMesh::NO_ALGO: {
+    if (checkNoAlgo)
+    {
+      // should there be any algo?
+      int shapeDim = SMESH_Gen::GetShapeDim( aSubMesh->GetSubShape() );
+      if (aTopAlgoDim > shapeDim)
+      {
+        INFOS( "ERROR: " << shapeDim << "D algorithm is missing" );
+        ret = false;
+      }
+    }
+    return ret;
+  }
+  case SMESH_subMesh::MISSING_HYP: {
+    // notify if an algo missing hyp is attached to aSubMesh
+    algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
+    ASSERT( algo );
+    bool isGlobalAlgo = aGen->IsGlobalAlgo( algo, aMesh );
+    if (!isGlobalAlgo || !globalChecked[ algo->GetDim() ])
+    {
+      INFOS( "ERROR: " << (isGlobalAlgo ? "Global " : "Local ")
+            << "<" << algo->GetName() << "> misses some hypothesis");
+      if (isGlobalAlgo)
+        globalChecked[ algo->GetDim() ] = true;
+    }
+    ret = false;
+    break;
+  }
+  case SMESH_subMesh::HYP_OK:
+    algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
+    ret = true;
+    break;
+  default: ASSERT(0);
+  }
+
+  // do not check under algo that hides sub-algos or
+  // re-start checking NO_ALGO state
+  ASSERT (algo);
+  bool isTopLocalAlgo =
+    ( aTopAlgoDim <= algo->GetDim() && !aGen->IsGlobalAlgo( algo, aMesh ));
+  if (!algo->NeedDescretBoundary() || isTopLocalAlgo)
+  {
+    bool checkNoAlgo2 = ( algo->NeedDescretBoundary() );
+    const map<int, SMESH_subMesh*>& subMeshes = aSubMesh->DependsOn();
+    map<int, SMESH_subMesh*>::const_iterator itsub;
+    for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
+    {
+      // sub-meshes should not be checked further more
+      int key = (*itsub).first;
+      SMESH_subMesh* sm = (*itsub).second;
+      if ( aCheckedMap.find( key ) == aCheckedMap.end() )
+        aCheckedMap[ key ] = sm;
+
+      if (isTopLocalAlgo)
+      {
+        //check algo on sub-meshes
+        int aTopAlgoDim2 = algo->GetDim();
+        if (!checkMissing (aGen, aMesh, sm, aTopAlgoDim2,
+                           globalChecked, checkNoAlgo2, aCheckedMap))
+        {
+          ret = false;
+          if (sm->GetAlgoState() == SMESH_subMesh::NO_ALGO )
+            checkNoAlgo2 = false;
+        }
+      }
+    }
+  }
+  return ret;
+}
 
-       // try shape first, then main shape
+//=======================================================================
+//function : CheckAlgoState
+//purpose  : notify on bad state of attached algos, return false
+//           if Compute() would fail because of some algo bad state
+//=======================================================================
 
-       TopoDS_Shape mainShape = meshDS->ShapeToMesh();
-       const TopoDS_Shape *shapeToTry[2] = { &aShape, &mainShape };
+bool SMESH_Gen::CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
+{
+  //MESSAGE("SMESH_Gen::CheckAlgoState");
+
+  bool ret = true;
+  bool hasAlgo = false;
+
+  SMESH_subMesh* sm = aMesh.GetSubMesh(aShape);
+  const SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
+  TopoDS_Shape mainShape = meshDS->ShapeToMesh();
+  
+  // -----------------
+  // get global algos
+  // -----------------
+  
+  const SMESH_Algo* aGlobAlgoArr[] = {0,0,0,0};
+
+  const list<const SMESHDS_Hypothesis*>& listHyp = meshDS->GetHypothesis( mainShape );
+  list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+  for ( ; it != listHyp.end(); it++)
+  {
+    const SMESHDS_Hypothesis * aHyp = *it;
+    if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+      continue;
+
+    const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
+    ASSERT ( algo );
+    
+    int dim = algo->GetDim();
+    aGlobAlgoArr[ dim ] = algo;
+
+    hasAlgo = true;
+  }
+  
+  // --------------------------------------------------------
+  // info on algos that will be ignored because of ones that
+  // don't NeedDescretBoundary() attached to super-shapes,
+  // check that a conform mesh will be produced
+  // --------------------------------------------------------
+
+
+  // find a global algo possibly hidding sub-algos
+  int dim;
+  const SMESH_Algo* aGlobIgnoAlgo = 0;
+  for (dim = 3; dim > 0; dim--)
+  {
+    if (aGlobAlgoArr[ dim ] &&
+        !aGlobAlgoArr[ dim ]->NeedDescretBoundary())
+    {
+      aGlobIgnoAlgo = aGlobAlgoArr[ dim ];
+      break;
+    }
+  }
+
+  const map<int, SMESH_subMesh*>& smMap = sm->DependsOn();
+  map<int, SMESH_subMesh*>::const_reverse_iterator revItSub = smMap.rbegin();
+  map<int, SMESH_subMesh*> aCheckedMap;
+  bool checkConform = ( !aMesh.IsNotConformAllowed() );
+  int aKey = 1;
+  SMESH_subMesh* smToCheck = sm;
+
+  // loop on aShape and its sub-shapes
+  while ( smToCheck )
+  {
+    if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
+      break;
+
+    if ( aCheckedMap.find( aKey ) == aCheckedMap.end() )
+      if (!checkConformIgnoredAlgos (aMesh, smToCheck, aGlobIgnoAlgo,
+                                     0, checkConform, aCheckedMap))
+        ret = false;
+
+    if ( smToCheck->GetAlgoState() != SMESH_subMesh::NO_ALGO )
+      hasAlgo = true;
+
+    // next subMesh
+    if (revItSub != smMap.rend())
+    {
+      aKey = (*revItSub).first;
+      smToCheck = (*revItSub).second;
+      revItSub++;
+    }
+    else
+    {
+      smToCheck = 0;
+    }
+
+  }
+
+  // ----------------------------------------------------------------
+  // info on missing hypothesis and find out if all needed algos are
+  // well defined
+  // ----------------------------------------------------------------
+
+  //MESSAGE( "---info on missing hypothesis and find out if all needed algos are");
+  
+  // find max dim of global algo
+  int aTopAlgoDim = 0;
+  for (dim = 3; dim > 0; dim--)
+  {
+    if (aGlobAlgoArr[ dim ])
+    {
+      aTopAlgoDim = dim;
+      break;
+    }
+  }
+  aCheckedMap.clear();
+  smToCheck = sm;
+  revItSub = smMap.rbegin();
+  bool checkNoAlgo = (bool) aTopAlgoDim;
+  bool globalChecked[] = { false, false, false, false };
+
+  // loop on aShape and its sub-shapes
+  while ( smToCheck )
+  {
+    if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
+      break;
+
+    if ( aCheckedMap.find( aKey ) == aCheckedMap.end() )
+      if (!checkMissing (this, aMesh, smToCheck, aTopAlgoDim,
+                         globalChecked, checkNoAlgo, aCheckedMap))
+      {
+        ret = false;
+        if (smToCheck->GetAlgoState() == SMESH_subMesh::NO_ALGO )
+          checkNoAlgo = false;
+      }
+
+    // next subMesh
+    if (revItSub != smMap.rend())
+    {
+      aKey = (*revItSub).first;
+      smToCheck = (*revItSub).second;
+      revItSub++;
+    }
+    else
+      smToCheck = 0;
+  }
+
+  if ( !hasAlgo )
+    INFOS( "None algorithm attached" );
+
+  return ( ret && hasAlgo );
+}
 
-       for (int iShape = 0; iShape < 2; iShape++)
-       {
-               TopoDS_Shape tryShape = (*shapeToTry[iShape]);
+//=======================================================================
+//function : IsGlobalAlgo
+//purpose  : check if theAlgo is attached to the main shape
+//=======================================================================
 
-               const list<const SMESHDS_Hypothesis*>& listHyp =
-                       meshDS->GetHypothesis(tryShape);
-               list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
-               
-               int nb_algo = 0;
-               int shapeDim = GetShapeDim(aShape);
-               int typeOfShape = aShape.ShapeType();
-
-               while (it!=listHyp.end())
-               {
-                       const SMESHDS_Hypothesis *anHyp = *it;
-                       hypType = anHyp->GetType();
-                       //SCRUTE(hypType);
-                       if (hypType > SMESHDS_Hypothesis::PARAM_ALGO)
-                       {
-                               switch (hypType)
-                               {
-                               case SMESHDS_Hypothesis::ALGO_1D:
-                                       algoDim = 1;
-                                       break;
-                               case SMESHDS_Hypothesis::ALGO_2D:
-                                       algoDim = 2;
-                                       break;
-                               case SMESHDS_Hypothesis::ALGO_3D:
-                                       algoDim = 3;
-                                       break;
-                               default:
-                                       algoDim = 0;
-                                       break;
-                               }
-                               //SCRUTE(algoDim);
-                               //SCRUTE(shapeDim);
-                               //SCRUTE(typeOfShape);
-                               if (shapeDim == algoDim)        // count only algos of shape dim.
-                               {                               // discard algos for subshapes
-                                       hypId = anHyp->GetID(); // (of lower dim.)
-                                       ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
-                                       SMESH_Algo *anAlgo = _mapAlgo[hypId];
-                                       //SCRUTE(anAlgo->GetShapeType());
-                                       //if (anAlgo->GetShapeType() == typeOfShape)
-                                       if ((anAlgo->GetShapeType()) & (1 << typeOfShape))
-                                       {                       // only specific TopoDS_Shape
-                                               nb_algo++;
-                                               theHyp = anHyp;
-                                       }
-                               }
-                       }
-                       if (nb_algo > 1) return NULL;   // more than one algo
-                       it++;
-               }
-               if (nb_algo == 1)               // one algo found : OK
-                       break;                          // do not try a parent shape
-       }
+bool SMESH_Gen::IsGlobalAlgo(const SMESH_Algo* theAlgo, SMESH_Mesh& aMesh)
+{
+  const SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
+  TopoDS_Shape mainShape = meshDS->ShapeToMesh();
+  const list<const SMESHDS_Hypothesis*>& listHyp = meshDS->GetHypothesis( mainShape );
+  list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+  for ( ; it != listHyp.end(); it++)
+    if ( *it == theAlgo )
+      return true;
+
+  return false;
+}
 
-       if (!theHyp)
-               return NULL;                    // no algo found
 
-       hypType = theHyp->GetType();
-       hypId = theHyp->GetID();
+//=======================================================================
+//function : getAlgoId
+//purpose  : return algo ID or -1 if not found
+//=======================================================================
 
-       ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
-       algo = _mapAlgo[hypId];
-       //MESSAGE("Algo found " << algo->GetName() << " Id " << hypId);
-       return algo;
+static int getAlgo(const list<const SMESHDS_Hypothesis*>& theHypList,
+                   const int                              theAlgoDim,
+                   const int                              theAlgoShapeType)
+{
+  list<const SMESHDS_Hypothesis*>::const_iterator it = theHypList.begin();
+  
+  int nb_algo = 0;
+  int algo_id = -1;
+  
+  while (it!=theHypList.end())
+  {
+    const SMESH_Hypothesis *anHyp = static_cast< const SMESH_Hypothesis *>( *it );
+    if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO &&
+        anHyp->GetDim() == theAlgoDim &&
+        ((anHyp->GetShapeType()) & (1 << theAlgoShapeType)))
+    {
+      nb_algo++;
+      algo_id = anHyp->GetID();
+      break;
+    }
+    
+    //if (nb_algo > 1) return -1;      // more than one algo
+    it++;
+  }
+
+  return algo_id;
+}
+
+//=============================================================================
+/*!
+ * 
+ */
+//=============================================================================
+
+SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
+{
+//  MESSAGE("SMESH_Gen::GetAlgo");
+
+  const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+  int dim = GetShapeDim( aShape );
+  int shape_type = aShape.ShapeType();
+  int algo_id = -1;
+
+  algo_id = getAlgo( meshDS->GetHypothesis( aShape ), dim, shape_type );
+
+  if (algo_id < 0)
+  {
+    // try ansestors
+    TopTools_ListIteratorOfListOfShape ancIt( aMesh.GetAncestors( aShape ));
+    for (; ancIt.More(); ancIt.Next())
+    {
+      const TopoDS_Shape& ancestor = ancIt.Value();
+      algo_id = getAlgo( meshDS->GetHypothesis( ancestor ), dim, shape_type );
+      if ( algo_id >= 0 )
+        break;
+    }
+    if (algo_id < 0) return NULL;
+  }
+
+  ASSERT(_mapAlgo.find(algo_id) != _mapAlgo.end());
+
+  return _mapAlgo[algo_id];
+  
+//     const SMESHDS_Hypothesis *theHyp = NULL;
+//     SMESH_Algo *algo = NULL;
+//     const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+//     int hypType;
+//     int hypId;
+//     int algoDim;
+
+//     // try shape first, then main shape
+
+//     TopoDS_Shape mainShape = meshDS->ShapeToMesh();
+//     const TopoDS_Shape *shapeToTry[2] = { &aShape, &mainShape };
+
+//     for (int iShape = 0; iShape < 2; iShape++)
+//     {
+//             TopoDS_Shape tryShape = (*shapeToTry[iShape]);
+
+//             const list<const SMESHDS_Hypothesis*>& listHyp =
+//                     meshDS->GetHypothesis(tryShape);
+//             list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+               
+//             int nb_algo = 0;
+//             int shapeDim = GetShapeDim(aShape);
+//             int typeOfShape = aShape.ShapeType();
+
+//             while (it!=listHyp.end())
+//             {
+//                     const SMESHDS_Hypothesis *anHyp = *it;
+//                     hypType = anHyp->GetType();
+//                     //SCRUTE(hypType);
+//                     if (hypType > SMESHDS_Hypothesis::PARAM_ALGO)
+//                     {
+//                             switch (hypType)
+//                             {
+//                             case SMESHDS_Hypothesis::ALGO_1D:
+//                                     algoDim = 1;
+//                                     break;
+//                             case SMESHDS_Hypothesis::ALGO_2D:
+//                                     algoDim = 2;
+//                                     break;
+//                             case SMESHDS_Hypothesis::ALGO_3D:
+//                                     algoDim = 3;
+//                                     break;
+//                             default:
+//                                     algoDim = 0;
+//                                     break;
+//                             }
+//                             //SCRUTE(algoDim);
+//                             //SCRUTE(shapeDim);
+//                             //SCRUTE(typeOfShape);
+//                             if (shapeDim == algoDim)        // count only algos of shape dim.
+//                             {                               // discard algos for subshapes
+//                                     hypId = anHyp->GetID(); // (of lower dim.)
+//                                     ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
+//                                     SMESH_Algo *anAlgo = _mapAlgo[hypId];
+//                                     //SCRUTE(anAlgo->GetShapeType());
+//                                     //if (anAlgo->GetShapeType() == typeOfShape)
+//                                     if ((anAlgo->GetShapeType()) & (1 << typeOfShape))
+//                                     {                       // only specific TopoDS_Shape
+//                                             nb_algo++;
+//                                             theHyp = anHyp;
+//                                     }
+//                             }
+//                     }
+//                     if (nb_algo > 1) return NULL;   // more than one algo
+//                     it++;
+//             }
+//             if (nb_algo == 1)               // one algo found : OK
+//                     break;                          // do not try a parent shape
+//     }
+
+//     if (!theHyp)
+//             return NULL;                    // no algo found
+
+//     hypType = theHyp->GetType();
+//     hypId = theHyp->GetID();
+
+//     ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
+//     algo = _mapAlgo[hypId];
+//     //MESSAGE("Algo found " << algo->GetName() << " Id " << hypId);
+//     return algo;
 }
 
 //=============================================================================
@@ -365,16 +823,12 @@ const char *SMESH_Gen::LocalPersistentIDToIOR(const char *aLocalPersistentID)
  */
 //=============================================================================
 
-int SMESH_Gen::GetShapeDim(const TopoDS_Shape & aShape)
+int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType)
 {
        int shapeDim = -1;                      // Shape dimension: 0D, 1D, 2D, 3D
-       int type = aShape.ShapeType();
+       int type = aShapeType;//.ShapeType();
        switch (type)
        {
-//     case TopAbs_COMPOUND:
-//       {
-//  break;
-//       }
        case TopAbs_COMPOUND:
        case TopAbs_COMPSOLID:
        case TopAbs_SOLID:
@@ -401,6 +855,17 @@ int SMESH_Gen::GetShapeDim(const TopoDS_Shape & aShape)
                break;
        }
        }
-//   SCRUTE(shapeDim);
        return shapeDim;
 }
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_Gen::GetANewId()
+{
+       //MESSAGE("SMESH_Gen::GetANewId");
+       return _hypId++;
+}
index 5443c0e4c9f3870df9ef0c2b021a573e2405e15f..3a01de04c4386bbb5d4436f6318d313d3b0e238a 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "Utils_SALOME_Exception.hxx"
 
-#include "SMESH_HypothesisFactory.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "SMESH_Algo.hxx"
 #include "SMESH_1D_Algo.hxx"
@@ -55,42 +54,53 @@ typedef struct studyContextStruct
 
 class SMESH_Gen
 {
-  public:
-       SMESH_Gen();
-       ~SMESH_Gen();
-
-       SMESH_Hypothesis *CreateHypothesis(const char *anHyp, int studyId)
-               throw(SALOME_Exception);
-       SMESH_Mesh *Init(int studyId, const TopoDS_Shape & aShape)
-               throw(SALOME_Exception);
-       bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
-               throw(SALOME_Exception);
-       StudyContextStruct *GetStudyContext(int studyId);
-
-       static int GetShapeDim(const TopoDS_Shape & aShape);
-       SMESH_Algo *GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
-
-       // inherited methods from SALOMEDS::Driver
-
-       void Save(int studyId, const char *aUrlOfFile);
-       void Load(int studyId, const char *aUrlOfFile);
-       void Close(int studyId);
-       const char *ComponentDataType();
-
-       const char *IORToLocalPersistentID(const char *IORString, bool & IsAFile);
-       const char *LocalPersistentIDToIOR(const char *aLocalPersistentID);
-
-       SMESH_HypothesisFactory _hypothesisFactory;
-
-         map < int, SMESH_Algo * >_mapAlgo;
-         map < int, SMESH_1D_Algo * >_map1D_Algo;
-         map < int, SMESH_2D_Algo * >_map2D_Algo;
-         map < int, SMESH_3D_Algo * >_map3D_Algo;
-
-  private:
-       int _localId;                           // unique Id of created objects, within SMESH_Gen entity
-         map < int, StudyContextStruct * >_mapStudyContext;
-         map < int, SMESH_Hypothesis * >_mapHypothesis;
+ public:
+  SMESH_Gen();
+  ~SMESH_Gen();
+
+//  SMESH_Hypothesis *CreateHypothesis(const char *anHyp, int studyId)
+//    throw(SALOME_Exception);
+  SMESH_Mesh* CreateMesh(int studyId)
+    throw(SALOME_Exception);
+  bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
+
+  bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
+  // notify on bad state of attached algos, return false
+  // if Compute() would fail because of some algo bad state
+
+
+  StudyContextStruct *GetStudyContext(int studyId);
+
+  static int GetShapeDim(const TopAbs_ShapeEnum & aShapeType);
+  static int GetShapeDim(const TopoDS_Shape & aShape)
+  { return GetShapeDim( aShape.ShapeType() ); }
+  SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
+  static bool IsGlobalAlgo(const SMESH_Algo* theAlgo, SMESH_Mesh& aMesh);
+
+  // inherited methods from SALOMEDS::Driver
+
+  void Save(int studyId, const char *aUrlOfFile);
+  void Load(int studyId, const char *aUrlOfFile);
+  void Close(int studyId);
+  const char *ComponentDataType();
+
+  const char *IORToLocalPersistentID(const char *IORString, bool & IsAFile);
+  const char *LocalPersistentIDToIOR(const char *aLocalPersistentID);
+
+  int GetANewId();
+
+  map < int, SMESH_Algo * >_mapAlgo;
+  map < int, SMESH_1D_Algo * >_map1D_Algo;
+  map < int, SMESH_2D_Algo * >_map2D_Algo;
+  map < int, SMESH_3D_Algo * >_map3D_Algo;
+
+ private:
+
+  int _localId;                                // unique Id of created objects, within SMESH_Gen entity
+  map < int, StudyContextStruct * >_mapStudyContext;
+
+  // hypotheses managing
+  int _hypId;
 };
 
 #endif
index 0d61a5f52eefc1db745c75da57e40b73786ec04c..dac1ee3257cf680cbc9e4fe2878022d99001dd89 100644 (file)
@@ -48,8 +48,8 @@ SMESH_Hypothesis::SMESH_Hypothesis(int hypId,
   StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
   myStudyContext->mapHypothesis[_hypId] = this;
   _type = PARAM_ALGO;
-//   _shapeType = -1; // to be set by algo with TopAbs_Enum
   _shapeType = 0; // to be set by algo with TopAbs_Enum
+  _param_algo_dim = -1; // to be set by algo parameter
 }
 
 //=============================================================================
@@ -69,7 +69,7 @@ SMESH_Hypothesis::~SMESH_Hypothesis()
  */
 //=============================================================================
 
-int SMESH_Hypothesis::GetDim()
+int SMESH_Hypothesis::GetDim() const
 {
   int dim = -1;
   switch (_type)
@@ -77,6 +77,7 @@ int SMESH_Hypothesis::GetDim()
     case ALGO_1D: dim = 1; break;
     case ALGO_2D: dim = 2; break;
     case ALGO_3D: dim = 3; break;
+    case PARAM_ALGO: dim = _param_algo_dim; break;
     }
   return dim;
 }
@@ -87,7 +88,7 @@ int SMESH_Hypothesis::GetDim()
  */
 //=============================================================================
 
-int SMESH_Hypothesis::GetShapeType()
+int SMESH_Hypothesis::GetShapeType() const
 {
   return _shapeType;
 }
@@ -98,7 +99,7 @@ int SMESH_Hypothesis::GetShapeType()
  */
 //=============================================================================
 
-int SMESH_Hypothesis::GetStudyId()
+int SMESH_Hypothesis::GetStudyId() const
 {
   return _studyId;
 }
@@ -133,3 +134,28 @@ void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
     }
 }
 
+//=============================================================================
+/*!
+ * 
+ */
+//=============================================================================
+
+const char* SMESH_Hypothesis::GetLibName() const
+{
+//   MESSAGE("SMESHDS_Hypothesis::GetLibName");
+//   SCRUTE(_LibName);
+//   SCRUTE(&_LibName);
+  return _libName.c_str();
+}
+
+//=============================================================================
+/*!
+ * 
+ */
+//=============================================================================
+
+void SMESH_Hypothesis::SetLibName(const char* theLibName)
+{
+//   MESSAGE("SMESHDS_Hypothesis::SetLibName");
+  _libName = string(theLibName);
+}
index edcfeba065f686df9f07cdf206e56787c1724d7b..9fcea7b251bda25357683ae1d1568483db93ec58 100644 (file)
@@ -36,17 +36,39 @@ class SMESH_Gen;
 class SMESH_Hypothesis: public SMESHDS_Hypothesis
 {
 public:
+  enum Hypothesis_Status // in the order of severity
+  {
+    HYP_OK,
+    HYP_MISSING,      // algo misses a hypothesis
+    HYP_CONCURENT,    // several applicable hypotheses
+    HYP_BAD_PARAMETER,// hypothesis has a bad parameter value
+    HYP_UNKNOWN_FATAL,//  --- all statuses below should be considered as fatal
+                      //      for Add/RemoveHypothesis operations
+    HYP_INCOMPATIBLE, // hypothesis does not fit algo
+    HYP_NOTCONFORM,   // not conform mesh is produced appling a hypothesis
+    HYP_ALREADY_EXIST,// such hypothesis already exist
+    HYP_BAD_DIM       // bad dimension
+  };
+  static bool IsStatusFatal(Hypothesis_Status theStatus)
+  { return theStatus >= HYP_UNKNOWN_FATAL; }
+
   SMESH_Hypothesis(int hypId, int studyId, SMESH_Gen* gen);
   virtual ~SMESH_Hypothesis();
-  int GetDim();
-  int GetStudyId();
+  int GetDim() const;
+  int GetStudyId() const;
   void NotifySubMeshesHypothesisModification();
-  int GetShapeType();
+  int GetShapeType() const;
+  const char* GetLibName() const;
+  void  SetLibName(const char* theLibName);
 
 protected:
   SMESH_Gen* _gen;
   int _studyId;
   int _shapeType;
+  int _param_algo_dim;
+
+private:
+  string _libName;
 };
 
 #endif
index 82f24dddf92121d8ec04e2c8c063d03a218c2737..6d03700c7ea0d1e6bf190fe378dd2a169c2d2c52 100644 (file)
@@ -30,6 +30,8 @@
 #include "SMESH_subMesh.hxx"
 #include "SMESH_Gen.hxx"
 #include "SMESH_Hypothesis.hxx"
+#include "SMESH_Group.hxx"
+#include "SMESHDS_Group.hxx"
 #include "SMESHDS_Script.hxx"
 #include "SMDS_MeshVolume.hxx"
 
 #include "DriverDAT_W_SMESHDS_Mesh.h"
 #include "DriverUNV_W_SMESHDS_Mesh.h"
 
+#include "DriverMED_R_SMESHDS_Mesh.h"
+
 #include <TCollection_AsciiString.hxx>
+#include <memory>
+#include <TopTools_ListOfShape.hxx>
+#include <TopExp.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include "Utils_ExceptHandlers.hxx"
+
 
 //=============================================================================
 /*!
@@ -61,8 +71,8 @@ SMESH_Mesh::SMESH_Mesh()
  */
 //=============================================================================
 
-SMESH_Mesh::SMESH_Mesh(int localId,
-       int studyId, SMESH_Gen * gen, SMESHDS_Document * myDocument)
+SMESH_Mesh::SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESHDS_Document * myDocument)
+: _groupId( 0 )
 {
        MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
        _id = localId;
@@ -82,7 +92,14 @@ SMESH_Mesh::SMESH_Mesh(int localId,
 
 SMESH_Mesh::~SMESH_Mesh()
 {
-       MESSAGE("SMESH_Mesh::~SMESH_Mesh");
+  MESSAGE("SMESH_Mesh::~SMESH_Mesh");
+
+  // delete groups
+  map < int, SMESH_Group * >::iterator itg;
+  for (itg = _mapGroup.begin(); itg != _mapGroup.end(); itg++) {
+    SMESH_Group *aGroup = (*itg).second;
+    delete aGroup;
+  }
 }
 
 //=============================================================================
@@ -91,9 +108,7 @@ SMESH_Mesh::~SMESH_Mesh()
  */
 //=============================================================================
 
-void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape)
-throw(SALOME_Exception)
-{
+void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape){
        MESSAGE("SMESH_Mesh::ShapeToMesh");
        if (_isShapeToMesh)
                throw
@@ -106,52 +121,109 @@ throw(SALOME_Exception)
        TopExp::MapShapes(aShape, _subShapes);
 }
 
+//=======================================================================
+//function : MEDToMesh
+//purpose  : 
+//=======================================================================
+
+int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName)
+{
+  MESSAGE("MEDToMesh - theFileName = "<<theFileName<<", mesh name = "<<theMeshName);
+  if(_isShapeToMesh)
+    throw SALOME_Exception(LOCALIZED("a shape to mesh as already been defined"));
+  _isShapeToMesh = true;
+  std::auto_ptr<DriverMED_R_SMESHDS_Mesh> myReader(new DriverMED_R_SMESHDS_Mesh);
+  myReader->SetMesh(_myMeshDS);
+  myReader->SetMeshId(-1);
+  myReader->SetFile(theFileName);
+  myReader->SetMeshName(theMeshName);
+  DriverMED_R_SMESHDS_Mesh::ReadStatus status = myReader->ReadMySelf();
+  MESSAGE("MEDToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
+  MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
+  MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
+  MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
+
+  // Reading groups (sub-meshes are out of scope of MED import functionality)
+  list<string> aGroupNames = myReader->GetGroupNames();
+  MESSAGE("MEDToMesh - Nb groups = "<<aGroupNames.size()); 
+  int anId;
+  for ( list<string>::iterator it = aGroupNames.begin(); it != aGroupNames.end(); it++ ) {
+    SMESH_Group* aGroup = AddGroup( SMDSAbs_All, it->c_str(), anId );
+    if ( aGroup ) {
+      MESSAGE("MEDToMesh - group added: "<<it->c_str());      
+      SMESHDS_Group* aGroupDS = aGroup->GetGroupDS();
+      aGroupDS->SetStoreName( it->c_str() );
+      myReader->GetGroup( aGroupDS );
+    }
+  }
+  return (int) status;
+}
+
 //=============================================================================
 /*!
  * 
  */
 //=============================================================================
 
-bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
-       int anHypId) throw(SALOME_Exception)
+SMESH_Hypothesis::Hypothesis_Status
+  SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
+                            int anHypId) throw(SALOME_Exception)
 {
-       MESSAGE("SMESH_Mesh::AddHypothesis");
-
-       StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
-       if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
-       {
-               MESSAGE("Hypothesis ID does not give an hypothesis");
-               SCRUTE(_studyId);
-               SCRUTE(anHypId);
-               throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
-       }
-
-       SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
-       SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
-       int event;
-
-       // shape 
-
-       if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
-               event = SMESH_subMesh::ADD_HYP;
-       else
-               event = SMESH_subMesh::ADD_ALGO;
-       int ret = subMesh->AlgoStateEngine(event, anHyp);
-
-       // subShapes (only when shape is mainShape)
-       TopoDS_Shape mainShape = _myMeshDS->ShapeToMesh();
-       if (aSubShape.IsSame(mainShape))
-       {
-               if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
-                       event = SMESH_subMesh::ADD_FATHER_HYP;
-               else
-                       event = SMESH_subMesh::ADD_FATHER_ALGO;
-               subMesh->SubMeshesAlgoStateEngine(event, anHyp);
-       }
-
-       subMesh->DumpAlgoState(true);
-       //SCRUTE(ret);
-       return ret;
+  Unexpect aCatch(SalomeException);
+  MESSAGE("SMESH_Mesh::AddHypothesis");
+
+  StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
+  if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
+  {
+    MESSAGE("Hypothesis ID does not give an hypothesis");
+    SCRUTE(_studyId);
+    SCRUTE(anHypId);
+    throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
+  }
+
+  SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
+  SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
+  SCRUTE( anHyp->GetName() );
+  int event;
+
+  bool isGlobalHyp = IsMainShape( aSubShape );
+
+  // NotConformAllowed can be only global
+  if ( !isGlobalHyp )
+  {
+    string hypName = anHyp->GetName();
+    if ( hypName == "NotConformAllowed" )
+    {
+      MESSAGE( "Hypotesis <NotConformAllowed> can be only global" );
+      return SMESH_Hypothesis::HYP_INCOMPATIBLE;
+    }
+  }
+
+  // shape 
+
+  if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+    event = SMESH_subMesh::ADD_HYP;
+  else
+    event = SMESH_subMesh::ADD_ALGO;
+  SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
+
+  // subShapes
+  if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
+      !subMesh->IsApplicableHypotesis( anHyp )) // is added on father
+  {
+    if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+      event = SMESH_subMesh::ADD_FATHER_HYP;
+    else
+      event = SMESH_subMesh::ADD_FATHER_ALGO;
+    SMESH_Hypothesis::Hypothesis_Status ret2 =
+      subMesh->SubMeshesAlgoStateEngine(event, anHyp);
+    if (ret2 > ret)
+      ret = ret2;
+  }
+
+  subMesh->DumpAlgoState(true);
+  SCRUTE(ret);
+  return ret;
 }
 
 //=============================================================================
@@ -160,9 +232,11 @@ bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
  */
 //=============================================================================
 
-bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
-       int anHypId)throw(SALOME_Exception)
+SMESH_Hypothesis::Hypothesis_Status
+  SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
+                               int anHypId)throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        MESSAGE("SMESH_Mesh::RemoveHypothesis");
 
        StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
@@ -181,18 +255,20 @@ bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
                event = SMESH_subMesh::REMOVE_HYP;
        else
                event = SMESH_subMesh::REMOVE_ALGO;
-       int ret = subMesh->AlgoStateEngine(event, anHyp);
+       SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
 
-       // subShapes (only when shape is mainShape)
-
-       TopoDS_Shape mainShape = _myMeshDS->ShapeToMesh();
-       if (aSubShape.IsSame(mainShape))
+       // subShapes
+        if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
+            !subMesh->IsApplicableHypotesis( anHyp )) // is removed from father
        {
                if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
                        event = SMESH_subMesh::REMOVE_FATHER_HYP;
                else
                        event = SMESH_subMesh::REMOVE_FATHER_ALGO;
-               subMesh->SubMeshesAlgoStateEngine(event, anHyp);
+                SMESH_Hypothesis::Hypothesis_Status ret2 =
+                  subMesh->SubMeshesAlgoStateEngine(event, anHyp);
+                if (ret2 > ret) // more severe
+                  ret = ret2;
        }
 
        subMesh->DumpAlgoState(true);
@@ -218,22 +294,24 @@ SMESHDS_Mesh * SMESH_Mesh::GetMeshDS()
 //=============================================================================
 
 const list<const SMESHDS_Hypothesis*>&
-       SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape)
+       SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const
        throw(SALOME_Exception)
 {
-       MESSAGE("SMESH_Mesh::GetHypothesisList");
-       _subShapeHypothesisList.clear();
-       const list<const SMESHDS_Hypothesis*>& listHyp =
-               _myMeshDS->GetHypothesis(aSubShape);
-
-       list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
-       while (it!=listHyp.end())
-       {
-               const SMESHDS_Hypothesis *anHyp = *it;
-               _subShapeHypothesisList.push_back(anHyp);
-               it++;
-       }
-       return _subShapeHypothesisList;
+  Unexpect aCatch(SalomeException);
+//     MESSAGE("SMESH_Mesh::GetHypothesisList");
+//     _subShapeHypothesisList.clear();
+//     const list<const SMESHDS_Hypothesis*>& listHyp =
+//             _myMeshDS->GetHypothesis(aSubShape);
+
+//     list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+//     while (it!=listHyp.end())
+//     {
+//             const SMESHDS_Hypothesis *anHyp = *it;
+//             _subShapeHypothesisList.push_back(anHyp);
+//             it++;
+//     }
+//     return _subShapeHypothesisList;
+  return _myMeshDS->GetHypothesis(aSubShape);
 }
 
 //=============================================================================
@@ -244,6 +322,7 @@ const list<const SMESHDS_Hypothesis*>&
 
 const list<SMESHDS_Command*> & SMESH_Mesh::GetLog() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        MESSAGE("SMESH_Mesh::GetLog");
        return _myMeshDS->GetScript()->GetCommands();
 }
@@ -255,6 +334,7 @@ const list<SMESHDS_Command*> & SMESH_Mesh::GetLog() throw(SALOME_Exception)
 //=============================================================================
 void SMESH_Mesh::ClearLog() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        MESSAGE("SMESH_Mesh::ClearLog");
        _myMeshDS->GetScript()->Clear();
 }
@@ -291,9 +371,11 @@ SMESH_Gen *SMESH_Mesh::GetGen()
 SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
 throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        //MESSAGE("SMESH_Mesh::GetSubMesh");
        SMESH_subMesh *aSubMesh;
        int index = _subShapes.FindIndex(aSubShape);
+
        if (_mapSubMesh.find(index) != _mapSubMesh.end())
        {
                aSubMesh = _mapSubMesh[index];
@@ -343,6 +425,7 @@ throw(SALOME_Exception)
 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
 throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        //MESSAGE("SMESH_Mesh::GetSubMeshContaining");
        bool isFound = false;
        SMESH_subMesh *aSubMesh = NULL;
@@ -379,6 +462,68 @@ throw(SALOME_Exception)
        return aSubMesh;
 }
 
+//=======================================================================
+//function : IsUsedHypothesis
+//purpose  : Return True if anHyp is used to mesh aSubShape
+//=======================================================================
+
+bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
+                                  const TopoDS_Shape & aSubShape)
+{
+  //MESSAGE( "SMESH_Mesh::IsUsedHypothesis" );
+
+  // check if anHyp is applicable to aSubShape
+  SMESH_subMesh * subMesh = GetSubMeshContaining( aSubShape );
+  if (!subMesh ||
+      !subMesh->IsApplicableHypotesis(static_cast<SMESH_Hypothesis*>(anHyp)))
+    return false;
+
+  SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape);
+
+  // algorithm
+  if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
+    return ( anHyp == algo );
+
+  // algorithm parameter
+  if (algo)
+  {
+    // look trough hypotheses used by algo
+    const list <const SMESHDS_Hypothesis * >&usedHyps =
+      algo->GetUsedHypothesis(*this, aSubShape);
+    list <const SMESHDS_Hypothesis * >::const_iterator itl;
+    for (itl = usedHyps.begin(); itl != usedHyps.end(); itl++)
+      if (anHyp == (*itl))
+        return true;
+  }
+  else
+  {
+    // look through all assigned hypotheses
+    {
+      const list <const SMESHDS_Hypothesis * >&usedHyps =
+        _myMeshDS->GetHypothesis( aSubShape );
+      list <const SMESHDS_Hypothesis * >::const_iterator itl;
+      for (itl = usedHyps.begin(); itl != usedHyps.end(); itl++)
+        if (anHyp == (*itl))
+          return true;
+    }
+
+    // on ancestors
+    TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
+    for (; it.More(); it.Next())
+    {
+      const list <const SMESHDS_Hypothesis * >&usedHyps =
+        _myMeshDS->GetHypothesis( aSubShape );
+      list <const SMESHDS_Hypothesis * >::const_iterator itl;
+      for (itl = usedHyps.begin(); itl != usedHyps.end(); itl++)
+        if (anHyp == (*itl))
+          return true;
+    }
+  }
+    
+  return false;
+}
+
+
 //=============================================================================
 /*!
  *
@@ -389,27 +534,14 @@ const list < SMESH_subMesh * >&
        SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
 throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
        map < int, SMESH_subMesh * >::iterator itsm;
        _subMeshesUsingHypothesisList.clear();
        for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
        {
                SMESH_subMesh *aSubMesh = (*itsm).second;
-               bool usesHyp = false;
-               SMESH_Algo *algo = _gen->GetAlgo(*this, aSubMesh->GetSubShape());
-               if (algo != NULL)
-               {
-                       const list <const SMESHDS_Hypothesis * >&usedHyps
-                               = algo->GetUsedHypothesis(*this, aSubMesh->GetSubShape());
-                       list <const SMESHDS_Hypothesis * >::const_iterator itl;
-                       for (itl = usedHyps.begin(); itl != usedHyps.end(); itl++)
-                               if (anHyp == (*itl))
-                               {
-                                       usesHyp = true;
-                                       break;
-                               }
-               }
-               if (usesHyp)
+               if ( IsUsedHypothesis ( anHyp, aSubMesh->GetSubShape() ))
                        _subMeshesUsingHypothesisList.push_back(aSubMesh);
        }
        return _subMeshesUsingHypothesisList;
@@ -421,17 +553,39 @@ throw(SALOME_Exception)
  */
 //=============================================================================
 
-void SMESH_Mesh::ExportMED(const char *file) throw(SALOME_Exception)
+void SMESH_Mesh::ExportMED(const char *file, const char* theMeshName, bool theAutoGroups) throw(SALOME_Exception)
 {
-       Mesh_Writer *myWriter = new DriverMED_W_SMESHDS_Mesh;
-       myWriter->SetFile(string(file));
-       myWriter->SetMesh(_myMeshDS);
-       MESSAGE(" _idDoc " << _idDoc) myWriter->SetMeshId(_idDoc);
-       myWriter->Add();
+  Unexpect aCatch(SalomeException);
+  std::auto_ptr<DriverMED_W_SMESHDS_Mesh> myWriter(new DriverMED_W_SMESHDS_Mesh);
+  myWriter  ->SetFile    ( file        );
+  myWriter  ->SetMesh    ( _myMeshDS   );
+  if ( !theMeshName ) 
+    myWriter->SetMeshId  ( _idDoc      );
+  else {
+    myWriter->SetMeshId  ( -1          );
+    myWriter->SetMeshName( theMeshName );
+  }
+
+  if ( theAutoGroups ) {
+    myWriter->AddGroupOfNodes();
+    myWriter->AddGroupOfEdges();
+    myWriter->AddGroupOfFaces();
+    myWriter->AddGroupOfVolumes();
+  }
+
+  for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
+    SMESH_Group*     aGroup = it->second;
+    SMESHDS_Group* aGroupDS = aGroup->GetGroupDS();
+    aGroupDS->SetStoreName( aGroup->GetName() );
+    myWriter->AddGroup( aGroupDS );
+  }
+
+  myWriter->Add();
 }
 
 void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        Mesh_Writer *myWriter = new DriverDAT_W_SMESHDS_Mesh;
        myWriter->SetFile(string(file));
        myWriter->SetMesh(_myMeshDS);
@@ -441,6 +595,7 @@ void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
 
 void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        Mesh_Writer *myWriter = new DriverUNV_W_SMESHDS_Mesh;
        myWriter->SetFile(string(file));
        myWriter->SetMesh(_myMeshDS);
@@ -455,6 +610,7 @@ void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception)
 //=============================================================================
 int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        return _myMeshDS->NbNodes();
 }
 
@@ -465,6 +621,7 @@ int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
 //=============================================================================
 int SMESH_Mesh::NbEdges() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        return _myMeshDS->NbEdges();
 }
 
@@ -475,6 +632,7 @@ int SMESH_Mesh::NbEdges() throw(SALOME_Exception)
 //=============================================================================
 int SMESH_Mesh::NbFaces() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        return _myMeshDS->NbFaces();
 }
 
@@ -483,11 +641,11 @@ int SMESH_Mesh::NbFaces() throw(SALOME_Exception)
 ///////////////////////////////////////////////////////////////////////////////
 int SMESH_Mesh::NbTriangles() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        int Nb = 0;
 
-       SMDS_Iterator<const SMDS_MeshFace*> * itFaces=_myMeshDS->facesIterator();
+       SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
        while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++;
-       delete itFaces;
        return Nb;
 }
 
@@ -496,11 +654,11 @@ int SMESH_Mesh::NbTriangles() throw(SALOME_Exception)
 ///////////////////////////////////////////////////////////////////////////////
 int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        int Nb = 0;
 
-       SMDS_Iterator<const SMDS_MeshFace*> * itFaces=_myMeshDS->facesIterator();
+       SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
        while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++;
-       delete itFaces;
        return Nb;
 }
 
@@ -511,24 +669,43 @@ int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
 //=============================================================================
 int SMESH_Mesh::NbVolumes() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        return _myMeshDS->NbVolumes();
 }
 
 int SMESH_Mesh::NbTetras() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        int Nb = 0;
-       SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=_myMeshDS->volumesIterator();
+       SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
        while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++;
-       delete itVolumes;
        return Nb;
 }
 
 int SMESH_Mesh::NbHexas() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        int Nb = 0;
-       SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=_myMeshDS->volumesIterator();
+       SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
        while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++;
-       delete itVolumes;
+       return Nb;
+}
+
+int SMESH_Mesh::NbPyramids() throw(SALOME_Exception)
+{
+  Unexpect aCatch(SalomeException);
+       int Nb = 0;
+       SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
+       while(itVolumes->more()) if(itVolumes->next()->NbNodes()==5) Nb++;
+       return Nb;
+}
+
+int SMESH_Mesh::NbPrisms() throw(SALOME_Exception)
+{
+  Unexpect aCatch(SalomeException);
+       int Nb = 0;
+       SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
+       while(itVolumes->more()) if(itVolumes->next()->NbNodes()==6) Nb++;
        return Nb;
 }
 
@@ -539,5 +716,187 @@ int SMESH_Mesh::NbHexas() throw(SALOME_Exception)
 //=============================================================================
 int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception)
 {
+  Unexpect aCatch(SalomeException);
        return _myMeshDS->NbSubMesh();
 }
+
+//=======================================================================
+//function : IsNotConformAllowed
+//purpose  : check if a hypothesis alowing notconform mesh is present
+//=======================================================================
+
+bool SMESH_Mesh::IsNotConformAllowed() const
+{
+  MESSAGE("SMESH_Mesh::IsNotConformAllowed");
+
+  const list<const SMESHDS_Hypothesis*>& listHyp =
+    _myMeshDS->GetHypothesis( _myMeshDS->ShapeToMesh() );
+  list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+  while (it!=listHyp.end())
+  {
+    const SMESHDS_Hypothesis *aHyp = *it;
+    string hypName = aHyp->GetName();
+    if ( hypName == "NotConformAllowed" )
+      return true;
+    it++;
+  }
+  return false;
+}
+
+//=======================================================================
+//function : IsMainShape
+//purpose  : 
+//=======================================================================
+
+bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const
+{
+  return theShape.IsSame(_myMeshDS->ShapeToMesh() );
+}
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType,
+                                   const char*               theName,
+                                  int&                      theId)
+{
+  if (_mapGroup.find(_groupId) != _mapGroup.end())
+    return NULL;
+  SMESH_Group* aGroup = new SMESH_Group (this, theType, theName);
+  theId = _groupId;
+  _mapGroup[_groupId++] = aGroup;
+  return aGroup;
+}
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+SMESH_Group* SMESH_Mesh::GetGroup (const int theGroupID)
+{
+  if (_mapGroup.find(theGroupID) == _mapGroup.end())
+    return NULL;
+  return _mapGroup[theGroupID];
+}
+
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+list<int> SMESH_Mesh::GetGroupIds()
+{
+  list<int> anIds;
+  for ( map<int, SMESH_Group*>::const_iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ )
+    anIds.push_back( it->first );
+  
+  return anIds;
+}
+
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+void SMESH_Mesh::RemoveGroup (const int theGroupID)
+{
+  if (_mapGroup.find(theGroupID) == _mapGroup.end())
+    return;
+  delete _mapGroup[theGroupID];
+  _mapGroup.erase (theGroupID);
+}
+
+//=======================================================================
+//function : GetAncestors
+//purpose  : return list of ancestors of theSubShape in the order
+//           that lower dimention shapes come first.
+//=======================================================================
+
+const TopTools_ListOfShape& SMESH_Mesh::GetAncestors(const TopoDS_Shape& theS)
+{
+  if ( _mapAncestors.IsEmpty() )
+  {
+    // fill _mapAncestors
+    int desType, ancType;
+    for ( desType = TopAbs_EDGE; desType > TopAbs_COMPOUND; desType-- )
+      for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
+        TopExp::MapShapesAndAncestors (_myMeshDS->ShapeToMesh(),
+                                       (TopAbs_ShapeEnum) desType,
+                                       (TopAbs_ShapeEnum) ancType,
+                                       _mapAncestors );
+  }
+
+  if ( _mapAncestors.Contains( theS ) )
+    return _mapAncestors.FindFromKey( theS );
+
+  static TopTools_ListOfShape emptyList;
+  return emptyList;
+}
+
+//=======================================================================
+//function : Dump
+//purpose  : dumps contents of mesh to stream [ debug purposes ]
+//=======================================================================
+ostream& SMESH_Mesh::Dump(ostream& save)
+{
+  save << "========================== Dump contents of mesh ==========================" << endl;
+  save << "1) Total number of nodes:     " << NbNodes() << endl;
+  save << "2) Total number of edges:     " << NbEdges() << endl;
+  save << "3) Total number of faces:     " << NbFaces() << endl;
+  if ( NbFaces() > 0 ) {
+    int nb3 = NbTriangles();
+    int nb4 = NbQuadrangles();
+    save << "3.1.) Number of triangles:    " << nb3 << endl;
+    save << "3.2.) Number of quadrangles:  " << nb4 << endl;
+    if ( nb3 + nb4 !=  NbFaces() ) {
+      map<int,int> myFaceMap;
+      SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
+      while( itFaces->more( ) ) {
+       int nbNodes = itFaces->next()->NbNodes();
+       if ( myFaceMap.find( nbNodes ) == myFaceMap.end() )
+         myFaceMap[ nbNodes ] = 0;
+       myFaceMap[ nbNodes ] = myFaceMap[ nbNodes ] + 1;
+      }
+      save << "3.3.) Faces in detail: " << endl;
+      map <int,int>::iterator itF;
+      for (itF = myFaceMap.begin(); itF != myFaceMap.end(); itF++)
+       save << "--> nb nodes: " << itF->first << " - nb elemens: " << itF->second << endl;
+    }
+  }
+  save << "4) Total number of volumes:   " << NbVolumes() << endl;
+  if ( NbVolumes() > 0 ) {
+    int nb8 = NbHexas();
+    int nb4 = NbTetras();
+    int nb5 = NbPyramids();
+    int nb6 = NbPrisms();
+    save << "4.1.) Number of hexahedrons:  " << nb8 << endl;
+    save << "4.2.) Number of tetrahedrons: " << nb4 << endl;
+    save << "4.3.) Number of prisms:       " << nb6 << endl;
+    save << "4.4.) Number of pyramides:    " << nb5 << endl;
+    if ( nb8 + nb4 + nb5 + nb6 != NbVolumes() ) {
+      map<int,int> myVolumesMap;
+      SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
+      while( itVolumes->more( ) ) {
+       int nbNodes = itVolumes->next()->NbNodes();
+       if ( myVolumesMap.find( nbNodes ) == myVolumesMap.end() )
+         myVolumesMap[ nbNodes ] = 0;
+       myVolumesMap[ nbNodes ] = myVolumesMap[ nbNodes ] + 1;
+      }
+      save << "4.5.) Volumes in detail: " << endl;
+      map <int,int>::iterator itV;
+      for (itV = myVolumesMap.begin(); itV != myVolumesMap.end(); itV++)
+       save << "--> nb nodes: " << itV->first << " - nb elemens: " << itV->second << endl;
+    }
+  }
+  save << "===========================================================================" << endl;
+  return save;
+}
index f179f68dc10f9e56b760dc1f389f7784322ff2c1..2f77fa2e5050b9ea7e7755189fa6703bc95016b0 100644 (file)
@@ -34,6 +34,7 @@
 #include "SMESHDS_Command.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "SMESH_subMesh.hxx"
+#include <SMDSAbs_ElementType.hxx>
 #include "Utils_SALOME_Exception.hxx"
 
 #include <TopExp.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 
 #include <vector>
 #include <list>
 #include <map>
 
+#if (__GNUC__>2)
+#include <string>
+#include <istream>
+#include <ostream>
+#else 
+#include <string>
+#include <istream.h>
+#include <ostream.h>
+#endif
+
 class SMESH_Gen;
+class SMESH_Group;
+class TopTools_ListOfShape;
 
 class SMESH_Mesh
 {
@@ -64,18 +78,24 @@ class SMESH_Mesh
        SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen,
                SMESHDS_Document * myDocument);
 
-       virtual ~ SMESH_Mesh();
+       virtual ~SMESH_Mesh();
 
-       void ShapeToMesh(const TopoDS_Shape & aShape) throw(SALOME_Exception);
+        void ShapeToMesh(const TopoDS_Shape & aShape);
+        /*!
+         * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
+         */
+        int MEDToMesh(const char* theFileName, const char* theMeshName);
 
-       bool AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
+       SMESH_Hypothesis::Hypothesis_Status
+                AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
                throw(SALOME_Exception);
 
-       bool RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
+       SMESH_Hypothesis::Hypothesis_Status
+                RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
                throw(SALOME_Exception);
 
        const list <const SMESHDS_Hypothesis * >&
-               GetHypothesisList(const TopoDS_Shape & aSubShape)
+               GetHypothesisList(const TopoDS_Shape & aSubShape) const
                throw(SALOME_Exception);
 
        const list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
@@ -101,8 +121,21 @@ class SMESH_Mesh
                GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
                throw(SALOME_Exception);
 
+        bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
+                              const TopoDS_Shape & aSubShape);
+        // Return True if anHyp is used to mesh aSubShape
+
+        bool IsNotConformAllowed() const;
+        // check if a hypothesis alowing notconform mesh is present
+
+        bool IsMainShape(const TopoDS_Shape& theShape) const;
+
+        const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape);
+        // return list of ancestors of theSubShape in the order
+        // that lower dimention shapes come first.
+        
        void ExportDAT(const char *file) throw(SALOME_Exception);
-       void ExportMED(const char *file) throw(SALOME_Exception);
+       void ExportMED(const char *file, const char* theMeshName = NULL, bool theAutoGroups = true) throw(SALOME_Exception);
        void ExportUNV(const char *file) throw(SALOME_Exception);
 
        int NbNodes() throw(SALOME_Exception);
@@ -121,21 +154,43 @@ class SMESH_Mesh
 
        int NbHexas() throw(SALOME_Exception);
 
+       int NbPyramids() throw(SALOME_Exception);
+
+       int NbPrisms() throw(SALOME_Exception);
+
        int NbSubMesh() throw(SALOME_Exception);
 
+        int NbGroup() const { return _mapGroup.size(); }
+  
+        SMESH_Group* AddGroup (const SMDSAbs_ElementType theType,
+                               const char*               theName,
+                               int&                      theId);
+  
+        SMESH_Group* GetGroup (const int theGroupID);
+
+        list<int> GetGroupIds();
+  
+        void RemoveGroup (const int theGroupID);
+
+        ostream& Dump(ostream & save);
+
   private:
 
        int _id;                                        // id given by creator (unique within the creator instance)
        int _studyId;
        int _idDoc;                                     // id given by SMESHDS_Document
-       bool _isShapeToMesh;            // set to true when a shape is given (only once)
+        int _groupId;                                   // id generator for group objects
+       bool _isShapeToMesh;                            // set to true when a shape is given (only once)
        list<const SMESHDS_Hypothesis *> _subShapeHypothesisList;
        list <SMESH_subMesh *> _subMeshesUsingHypothesisList;
        SMESHDS_Document * _myDocument;
        SMESHDS_Mesh * _myMeshDS;
        TopTools_IndexedMapOfShape _subShapes;
-       map <int, SMESH_subMesh *>_mapSubMesh;
+       map <int, SMESH_subMesh *> _mapSubMesh;
+       map <int, SMESH_Group *>   _mapGroup;
        SMESH_Gen *_gen;
+
+        TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors;
 };
 
 #endif
index 2e6799ed22b80a7348e8c5f73bfc0dde843632ae..2b78950b92e092d929ce7fe13efe4dde4c516758 100644 (file)
@@ -40,6 +40,8 @@ using namespace std;
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TopoDS_Compound.hxx>
+#include <BRep_Builder.hxx>
 
 //=============================================================================
 /*!
@@ -50,7 +52,6 @@ using namespace std;
 SMESH_subMesh::SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
        const TopoDS_Shape & aSubShape)
 {
-       //MESSAGE("SMESH_subMesh::SMESH_subMesh");
        _subShape = aSubShape;
        _meshDS = meshDS;
        _subMeshDS = meshDS->MeshElements(_subShape);   // may be null ...
@@ -58,7 +59,6 @@ SMESH_subMesh::SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
        _Id = Id;
        _vertexSet = false;                     // only for Vertex subMesh
        _dependenceAnalysed = false;
-       _dependantsFound = false;
 
        if (_subShape.ShapeType() == TopAbs_VERTEX)
        {
@@ -90,93 +90,19 @@ SMESH_subMesh::~SMESH_subMesh()
  */
 //=============================================================================
 
-int SMESH_subMesh::GetId()
+int SMESH_subMesh::GetId() const
 {
        //MESSAGE("SMESH_subMesh::GetId");
        return _Id;
 }
 
-//=============================================================================
-/*!
- * Given a subShape, find the subMesh is associated to this subShape or
- * to a collection of shapes containing this subShape. Collection = compsolid,
- * shell, wire
- */
-//=============================================================================
-
-// bool SMESH_subMesh::Contains(const TopoDS_Shape & aSubShape)
-//   throw (SALOME_Exception)
-// {
-//   //MESSAGE("SMESH_subMesh::Contains");
-//   bool contains = false;
-//   int type = _subShape.ShapeType();
-//   int typesub = aSubShape.ShapeType();
-//   //SCRUTE(type)
-//   //SCRUTE(typesub)
-//   switch (type)
-//     {
-// //     case TopAbs_COMPOUND:
-// //       {
-// //   //MESSAGE("---");
-// //   throw SALOME_Exception(LOCALIZED("Compound not yet treated"));
-// //   break;
-// //       }
-//     case TopAbs_COMPSOLID:
-//       {
-//  //MESSAGE("---");
-//  for (TopExp_Explorer exp(aSubShape,TopAbs_SOLID);exp.More();exp.Next())
-//    {
-//      contains = _subShape.IsSame(exp.Current());
-//      if (contains) break;
-//    }
-//  break;
-//       }
-//     case TopAbs_SHELL:
-//       {
-//  //MESSAGE("---");
-//  for (TopExp_Explorer exp(aSubShape,TopAbs_FACE);exp.More();exp.Next())
-//    {
-//      contains = _subShape.IsSame(exp.Current());
-//      if (contains) break;
-//    }
-//  break;
-//       }
-//     case TopAbs_WIRE:
-//       {
-//  //MESSAGE("---");
-//  for (TopExp_Explorer exp(aSubShape,TopAbs_EDGE);exp.More();exp.Next())
-//    {
-//      contains = _subShape.IsSame(exp.Current());
-//      if (contains) break;
-//    }
-//  break;
-//       }
-//     case TopAbs_COMPOUND:
-//     case TopAbs_SOLID:
-//     case TopAbs_FACE:
-//     case TopAbs_EDGE:
-//     case TopAbs_VERTEX:
-//       {
-//  //MESSAGE("---");
-//  contains = _subShape.IsSame(aSubShape);
-//  break;
-//       }
-//     default:
-//       {
-//  break;
-//       }
-//     }
-//   //SCRUTE(contains);
-//   return contains;
-// }
-
 //=============================================================================
 /*!
  * 
  */
 //=============================================================================
 
-SMESHDS_SubMesh * SMESH_subMesh::GetSubMeshDS() throw(SALOME_Exception)
+SMESHDS_SubMesh * SMESH_subMesh::GetSubMeshDS()
 {
        //MESSAGE("SMESH_subMesh::GetSubMeshDS");
        if (_subMeshDS==NULL)
@@ -199,7 +125,21 @@ SMESHDS_SubMesh * SMESH_subMesh::GetSubMeshDS() throw(SALOME_Exception)
  */
 //=============================================================================
 
-SMESH_subMesh *SMESH_subMesh::GetFirstToCompute() throw(SALOME_Exception)
+SMESHDS_SubMesh* SMESH_subMesh::CreateSubMeshDS()
+{
+  if ( !GetSubMeshDS() )
+    _meshDS->NewSubMesh( _meshDS->ShapeToIndex( _subShape ) );
+
+  return GetSubMeshDS();
+}
+
+//=============================================================================
+/*!
+ * 
+ */
+//=============================================================================
+
+SMESH_subMesh *SMESH_subMesh::GetFirstToCompute()
 {
        //MESSAGE("SMESH_subMesh::GetFirstToCompute");
        const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
@@ -239,7 +179,7 @@ SMESH_subMesh *SMESH_subMesh::GetFirstToCompute() throw(SALOME_Exception)
  */
 //=============================================================================
 
-bool SMESH_subMesh::SubMeshesComputed() throw(SALOME_Exception)
+bool SMESH_subMesh::SubMeshesComputed()
 {
        //MESSAGE("SMESH_subMesh::SubMeshesComputed");
        const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
@@ -526,10 +466,6 @@ const map < int, SMESH_subMesh * >&SMESH_subMesh::DependsOn()
 void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
 {
        //MESSAGE("SMESH_subMesh::InsertDependence");
-       //SMESH_subMesh* aSubMesh = _father->GetSubMeshContaining(aSubShape);
-       //SCRUTE(aSubMesh);
-       //if (! aSubMesh) aSubMesh = _father->GetSubMesh(aSubShape);
-
        SMESH_subMesh *aSubMesh = _father->GetSubMesh(aSubShape);
        int type = aSubShape.ShapeType();
        int ordType = 9 - type;         // 2 = Vertex, 8 = CompSolid
@@ -551,31 +487,6 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
 
 }
 
-//=============================================================================
-/*!
- * For collection shapes (compsolid, shell, wire).
- * Add only subMesh figuring only once in multiset to dependence list 
- */
-//=============================================================================
-
-// void SMESH_subMesh::FinalizeDependence(list<TopoDS_Shape>& shapeList)
-// {
-//   //MESSAGE("SMESH_subMesh::FinalizeDependence");
-//   list<TopoDS_Shape>::iterator it1, it2;
-//   for(it1 = shapeList.begin(); it1 != shapeList.end(); it1++)
-//     {
-//       TopoDS_Shape aSubShape = (*it1);
-//       int count = 0;
-//       for(it2 = shapeList.begin(); it2 != shapeList.end(); it2++)
-//  {
-//    TopoDS_Shape other = (*it2);
-//    if (other.IsSame(aSubShape)) count++;
-//  }
-//       if (count == 1) InsertDependence(aSubShape);
-//       SCRUTE(count);
-//     }
-// }
-
 //=============================================================================
 /*!
  * 
@@ -588,420 +499,467 @@ const TopoDS_Shape & SMESH_subMesh::GetSubShape()
        return _subShape;
 }
 
+
+//=======================================================================
+//function : CanAddHypothesis
+//purpose  : return true if theHypothesis can be attached to me:
+//           its dimention is checked
+//=======================================================================
+
+bool SMESH_subMesh::CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) const
+{
+  int aHypDim   = theHypothesis->GetDim();
+  int aShapeDim = SMESH_Gen::GetShapeDim(_subShape);
+  if ( aHypDim <= aShapeDim )
+    return true;
+//   if ( aHypDim < aShapeDim )
+//     return ( _father->IsMainShape( _subShape ));
+    
+  return false;
+}
+
+//=======================================================================
+//function : IsApplicableHypotesis
+//purpose  : return true if theHypothesis can be used to mesh me:
+//           its shape type is checked
+//=======================================================================
+
+bool SMESH_subMesh::IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis) const
+{
+  if ( theHypothesis->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
+    // algorithm
+    return ( theHypothesis->GetShapeType() & (1<< _subShape.ShapeType()));
+
+  // hypothesis
+  switch ( _subShape.ShapeType() ) {
+  case TopAbs_EDGE:
+  case TopAbs_FACE:
+  case TopAbs_SHELL:
+  case TopAbs_SOLID: {
+    int aHypDim   = theHypothesis->GetDim();
+    int aShapeDim = SMESH_Gen::GetShapeDim(_subShape);
+    return ( aHypDim == aShapeDim );
+  }
+//   case TopAbs_VERTEX:
+//   case TopAbs_WIRE:
+//   case TopAbs_COMPSOLID:
+//   case TopAbs_COMPOUND:
+  default:;
+  }
+
+  return false;
+}
+
 //=============================================================================
 /*!
  * 
  */
 //=============================================================================
 
-bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis * anHyp)
-throw(SALOME_Exception)
+SMESH_Hypothesis::Hypothesis_Status
+  SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis * anHyp)
 {
-       //  MESSAGE("SMESH_subMesh::AlgoStateEngine");
-       //SCRUTE(_algoState);
-       //SCRUTE(event);
-
-       // **** les retour des evenement shape sont significatifs
-       // (add ou remove fait ou non)
-       // le retour des evenement father n'indiquent pas que add ou remove fait
-       int dim = SMESH_Gen::GetShapeDim(_subShape);
-
-       if (dim < 1)
-       {
-               _algoState = HYP_OK;
-               //SCRUTE(_algoState);
-               return true;
-       }
-
-       SMESH_Gen *gen = _father->GetGen();
-       bool ret;
-       _oldAlgoState = _algoState;
-       bool modifiedHyp = false;       // if set to true, force event MODIF_ALGO_STATE
-       // in ComputeStateEngine
-
-       switch (_algoState)
-       {
-
-               // ----------------------------------------------------------------------
-
-       case NO_ALGO:
-               switch (event)
-               {
-               case ADD_HYP:
-                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-                       ret = _meshDS->AddHypothesis(_subShape, anHyp);
-                       break;
-               case ADD_ALGO:
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-                       if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
-                       {
-                               ret = _meshDS->AddHypothesis(_subShape, anHyp);
-//        if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
-//        if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
-                               if (ret &&
-                                       (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
-                               {
-                                       SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                                       ASSERT(algo);
-                                       ret = algo->CheckHypothesis((*_father), _subShape);
-                                       if (ret)
-                                               SetAlgoState(HYP_OK);
-                                       else
-                                               SetAlgoState(MISSING_HYP);
-                               }
-                       }
-                       break;
-               case REMOVE_HYP:
-                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-                       break;
-               case REMOVE_ALGO:
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-                       break;
-               case ADD_FATHER_HYP:    // nothing to do
-                       break;
-               case ADD_FATHER_ALGO:   // Algo just added in father
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-//    if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
-//    if (anHyp->GetShapeType() == _subShape.ShapeType())
-                       if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               ASSERT(algo);
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (ret)
-                                       SetAlgoState(HYP_OK);
-                               else
-                                       SetAlgoState(MISSING_HYP);
-                       }
-                       break;
-               case REMOVE_FATHER_HYP: // nothing to do
-                       break;
-               case REMOVE_FATHER_ALGO:        // nothing to do
-                       break;
-               default:
-                       ASSERT(0);
-                       break;
-               }
-               break;
-
-               // ----------------------------------------------------------------------
-
-       case MISSING_HYP:
-               switch (event)
-               {
-               case ADD_HYP:
-                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-                       ret = _meshDS->AddHypothesis(_subShape, anHyp);
-                       if (ret)
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               ASSERT(algo);
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (ret)
-                                       SetAlgoState(HYP_OK);
-                               else
-                                       SetAlgoState(MISSING_HYP);
-                       }
-                       break;
-               case ADD_ALGO:                  //already existing algo : on father ?
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-                       if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
-                       {
-                               ret = _meshDS->AddHypothesis(_subShape, anHyp);
-//        if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
-//        if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
-                               if (ret &&
-                                       (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
-                               {
-                                       SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                                       if (algo == NULL)       // two algo on the same subShape...
-                                       {
-                                               MESSAGE("two algo on the same subshape not allowed");
-                                               ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-                                               ret = false;
-                                       }
-                                       else
-                                       {
-                                               ret = algo->CheckHypothesis((*_father), _subShape);
-                                               if (ret)
-                                                       SetAlgoState(HYP_OK);
-                                               else
-                                                       SetAlgoState(MISSING_HYP);
-                                       }
-                               }
-                       }
-                       break;
-               case REMOVE_HYP:
-                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-                       break;
-               case REMOVE_ALGO:               // perhaps a father algo applies ?
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-//    if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
-//    if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
-                       if (ret && (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               if (algo == NULL)       // no more algo applying on subShape...
-                               {
-                                       SetAlgoState(NO_ALGO);
-                               }
-                               else
-                               {
-                                       ret = algo->CheckHypothesis((*_father), _subShape);
-                                       if (ret)
-                                               SetAlgoState(HYP_OK);
-                                       else
-                                               SetAlgoState(MISSING_HYP);
-                               }
-                       }
-                       break;
-               case ADD_FATHER_HYP:
-                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               ASSERT(algo);
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (ret)
-                                       SetAlgoState(HYP_OK);
-                               else
-                                       SetAlgoState(MISSING_HYP);
-                       }
-                       break;
-               case ADD_FATHER_ALGO:   // detect if two algo of same dim on father
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-//    if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
-//    if (anHyp->GetShapeType() == _subShape.ShapeType())
-                       if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               if (algo == NULL)       // two applying algo on father
-                               {
-                                       MESSAGE("two applying algo on fatherShape...");
-                                       SetAlgoState(NO_ALGO);
-                               }
-                               else
-                               {
-                                       ret = algo->CheckHypothesis((*_father), _subShape);
-                                       if (ret)
-                                               SetAlgoState(HYP_OK);
-                                       else
-                                               SetAlgoState(MISSING_HYP);
-                               }
-                       }
-                       break;
-               case REMOVE_FATHER_HYP: // nothing to do
-                       break;
-               case REMOVE_FATHER_ALGO:
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-//    if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
-//    if (anHyp->GetShapeType() == _subShape.ShapeType())
-                       if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               if (algo == NULL)       // no more applying algo on father
-                               {
-                                       SetAlgoState(NO_ALGO);
-                               }
-                               else
-                               {
-                                       ret = algo->CheckHypothesis((*_father), _subShape);
-                                       if (ret)
-                                               SetAlgoState(HYP_OK);
-                                       else
-                                               SetAlgoState(MISSING_HYP);
-                               }
-                       }
-                       break;
-               default:
-                       ASSERT(0);
-                       break;
-               }
-               break;
+  //  MESSAGE("SMESH_subMesh::AlgoStateEngine");
+  //SCRUTE(_algoState);
+  //SCRUTE(event);
+
+  // **** les retour des evenement shape sont significatifs
+  // (add ou remove fait ou non)
+  // le retour des evenement father n'indiquent pas que add ou remove fait
+  int dim = SMESH_Gen::GetShapeDim(_subShape);
+
+  SMESH_Hypothesis::Hypothesis_Status aux_ret, ret = SMESH_Hypothesis::HYP_OK;
+  if (dim < 1)
+    {
+      _algoState = HYP_OK;
+      return ret;
+    }
+
+  SMESH_Gen* gen =_father->GetGen();
+//  bool ret = false;
+  int oldAlgoState = _algoState;
+  bool modifiedHyp = false;  // if set to true, force event MODIF_ALGO_STATE
+                             // in ComputeStateEngine
+
+  // ----------------------
+  // check mesh conformity
+  // ----------------------
+  if (event == ADD_ALGO)
+  {
+    if (IsApplicableHypotesis( anHyp ) &&
+        !_father->IsNotConformAllowed() &&
+        !IsConform( static_cast< SMESH_Algo* >( anHyp )))
+      return SMESH_Hypothesis::HYP_NOTCONFORM;
+  }
+  
+  // ----------------------------------
+  // add a hypothesis to DS if possible
+  // ----------------------------------
+  if (event == ADD_HYP || event == ADD_ALGO)
+  {
+    if ( ! CanAddHypothesis( anHyp ))
+      return SMESH_Hypothesis::HYP_BAD_DIM;
+
+    if ( GetNbAttached( _subShape, anHyp ) > 0 )
+      return SMESH_Hypothesis::HYP_ALREADY_EXIST;
+
+    if ( !_meshDS->AddHypothesis(_subShape, anHyp))
+      return SMESH_Hypothesis::HYP_ALREADY_EXIST;
+  }
+
+  // --------------------------
+  // remove a hypothesis from DS
+  // --------------------------
+  if (event == REMOVE_HYP || event == REMOVE_ALGO)
+  {
+    if (!_meshDS->RemoveHypothesis(_subShape, anHyp))
+      return SMESH_Hypothesis::HYP_OK; // nothing changes
+  }
+
+  // ------------------
+  // analyse algo state
+  // ------------------
+  if (!IsApplicableHypotesis( anHyp ))
+    return ret; // not applicable hypotheses do not change algo state
+
+  switch (_algoState)
+  {
+
+    // ----------------------------------------------------------------------
+
+  case NO_ALGO:
+    switch (event) {
+    case ADD_HYP:
+      break;
+    case ADD_ALGO: {
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      ASSERT(algo);
+      if (algo->CheckHypothesis((*_father),_subShape, ret))
+        SetAlgoState(HYP_OK);
+      else
+        SetAlgoState(MISSING_HYP);
+      break;
+    }
+    case REMOVE_HYP:
+      break;
+    case REMOVE_ALGO:
+      break;
+    case ADD_FATHER_HYP:
+      break;
+    case ADD_FATHER_ALGO: {    // Algo just added in father
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      ASSERT(algo);
+      if ( algo == anHyp ) {
+        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret))
+          SetAlgoState(HYP_OK);
+        else
+          SetAlgoState(MISSING_HYP);
+      }
+      break;
+    }
+    case REMOVE_FATHER_HYP:
+      break;
+    case REMOVE_FATHER_ALGO: {
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      if (algo)
+      {
+        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+            SetAlgoState(HYP_OK);
+        else
+          SetAlgoState(MISSING_HYP);
+      }
+      break;
+    }
+    default:
+      ASSERT(0);
+      break;
+    }
+    break;
+
+    // ----------------------------------------------------------------------
+
+  case MISSING_HYP:
+    switch (event)
+    {
+    case ADD_HYP: {
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      ASSERT(algo);
+      if ( algo->CheckHypothesis((*_father),_subShape, ret ))
+        SetAlgoState(HYP_OK);
+      if (SMESH_Hypothesis::IsStatusFatal( ret ))
+        _meshDS->RemoveHypothesis(_subShape, anHyp);
+      else if (!_father->IsUsedHypothesis(  anHyp, _subShape ))
+      {
+        _meshDS->RemoveHypothesis(_subShape, anHyp);
+        ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
+      }
+      break;
+    }
+    case ADD_ALGO: {           //already existing algo : on father ?
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      ASSERT(algo);
+      if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))// ignore hyp status
+        SetAlgoState(HYP_OK);
+      else
+        SetAlgoState(MISSING_HYP);
+      break;
+    }
+    case REMOVE_HYP:
+      break;
+    case REMOVE_ALGO: {        // perhaps a father algo applies ?
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      if (algo == NULL)  // no more algo applying on subShape...
+      {
+        SetAlgoState(NO_ALGO);
+      }
+      else
+      {
+        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+          SetAlgoState(HYP_OK);
+        else
+          SetAlgoState(MISSING_HYP);
+      }
+      break;
+    }
+    case ADD_FATHER_HYP: {
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      ASSERT(algo);
+      if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+        SetAlgoState(HYP_OK);
+      else
+        SetAlgoState(MISSING_HYP);
+    }
+      break;
+    case ADD_FATHER_ALGO: { // new father algo
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      ASSERT( algo );
+      if ( algo == anHyp ) {
+        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+          SetAlgoState(HYP_OK);
+        else
+          SetAlgoState(MISSING_HYP);
+      }
+      break;
+    }
+    case REMOVE_FATHER_HYP:    // nothing to do
+      break;
+    case REMOVE_FATHER_ALGO: {
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      if (algo == NULL)  // no more applying algo on father
+      {
+        SetAlgoState(NO_ALGO);
+      }
+      else
+      {
+        if ( algo->CheckHypothesis((*_father),_subShape , aux_ret ))
+          SetAlgoState(HYP_OK);
+        else
+          SetAlgoState(MISSING_HYP);
+      }
+      break;
+    }
+    default:
+      ASSERT(0);
+      break;
+    }
+    break;
+
+    // ----------------------------------------------------------------------
+    
+  case HYP_OK:
+    switch (event)
+    {
+    case ADD_HYP: {
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      ASSERT(algo);
+      if (!algo->CheckHypothesis((*_father),_subShape, ret ))
+      {
+        MESSAGE("two applying algo on the same shape not allowed");
+        _meshDS->RemoveHypothesis(_subShape, anHyp);
+        //ret = SMESH_Hypothesis::HYP_ALREADY_EXIST;
+      }
+      else if (SMESH_Hypothesis::IsStatusFatal( ret ))
+        _meshDS->RemoveHypothesis(_subShape, anHyp);
+      else if (!_father->IsUsedHypothesis(  anHyp, _subShape ))
+      {
+        _meshDS->RemoveHypothesis(_subShape, anHyp);
+        ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
+      }
+      modifiedHyp = _father->IsUsedHypothesis( anHyp, _subShape ); // new Hyp?
+      break;
+    }
+    case ADD_ALGO: {           //already existing algo : on father ?
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+        SetAlgoState(HYP_OK);
+      else
+        SetAlgoState(MISSING_HYP);
+      modifiedHyp = true;
+      break;
+    }
+    case REMOVE_HYP: {
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      ASSERT(algo);
+      if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+        SetAlgoState(HYP_OK);
+      else
+        SetAlgoState(MISSING_HYP);
+      modifiedHyp = true;
+      // report only severe errors
+      if ( SMESH_Hypothesis::IsStatusFatal( aux_ret ))
+        ret = aux_ret;
+      break;
+    }
+    case REMOVE_ALGO: {         // perhaps a father algo applies ?
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      if (algo == NULL)   // no more algo applying on subShape...
+      {
+        SetAlgoState(NO_ALGO);
+      }
+      else
+      {
+        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+          SetAlgoState(HYP_OK);
+        else
+          SetAlgoState(MISSING_HYP);
+        modifiedHyp = true;
+        // report only severe errors
+        if ( SMESH_Hypothesis::IsStatusFatal( aux_ret ))
+          ret = aux_ret;
+      }
+      break;
+    }
+    case ADD_FATHER_HYP: {  // new father hypothesis ?
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      ASSERT(algo);
+      if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+      {
+        SetAlgoState(HYP_OK);
+        if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp
+          modifiedHyp = true;
+      }
+      else
+        SetAlgoState(MISSING_HYP);
+      break;
+    }
+    case ADD_FATHER_ALGO: {    // a new algo on father
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      if ( algo == anHyp ) {
+        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+          SetAlgoState(HYP_OK);
+        else
+          SetAlgoState(MISSING_HYP);
+        modifiedHyp = true;
+      }
+      break;
+    }
+    case REMOVE_FATHER_HYP: {
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      ASSERT(algo);
+      if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+        SetAlgoState(HYP_OK);
+      else
+        SetAlgoState(MISSING_HYP);
+      modifiedHyp = true;
+      break;
+    }
+    case REMOVE_FATHER_ALGO: {
+      SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+      if (algo == NULL)  // no more applying algo on father
+      {
+        SetAlgoState(NO_ALGO);
+      }
+      else
+      {
+        if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
+          SetAlgoState(HYP_OK);
+        else
+          SetAlgoState(MISSING_HYP);
+        modifiedHyp = true;
+      }
+      break;
+    }
+    default:
+      ASSERT(0);
+      break;
+    }
+    break;
+    
+    // ----------------------------------------------------------------------
+    
+  default:
+    ASSERT(0);
+    break;
+  }
+  // ----------------------------------------
+  // check concurent hypotheses on ansestors
+  // ----------------------------------------
+  if (ret < SMESH_Hypothesis::HYP_CONCURENT &&
+      (event == ADD_FATHER_HYP ||
+       event == ADD_FATHER_ALGO ||
+       event == REMOVE_FATHER_HYP ||
+       event == REMOVE_FATHER_ALGO ||
+       event == REMOVE_ALGO ||
+       event == REMOVE_HYP))
+  {
+    ret = CheckConcurentHypothesis( anHyp->GetType() );
+  }
+
+  if ((_algoState != oldAlgoState) || modifiedHyp)
+    int retc = ComputeStateEngine(MODIF_ALGO_STATE);
+
+  return ret;
+}
 
-               // ----------------------------------------------------------------------
 
-       case HYP_OK:
-               switch (event)
-               {
-               case ADD_HYP:
-               {
-                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-                       SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                       ASSERT(algo);
-                       list<const SMESHDS_Hypothesis *> originalUsedHyps = algo->GetUsedHypothesis((*_father), _subShape);     // copy
+//=======================================================================
+//function : IsConform
+//purpose  : check if a conform mesh will be produced by the Algo
+//=======================================================================
 
-                       ret = _meshDS->AddHypothesis(_subShape, anHyp);
-                       if (ret)
-                       {
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (!ret)
-                               {
-                                       INFOS("two applying algo on the same shape not allowed");
-                                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-                                       ret = false;
-                               }
-                               else                    // compare SMESHDS_Hypothesis* lists (order important)
-                               {
-                                       MESSAGE("---");
-                                       const list <const SMESHDS_Hypothesis *> & newUsedHyps
-                                               = algo->GetUsedHypothesis((*_father), _subShape);
-                                       modifiedHyp = (originalUsedHyps != newUsedHyps);
-                               }
-                       }
-               }
-                       break;
-               case ADD_ALGO:                  //already existing algo : on father ?
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-                       if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
-                       {
-                               ret = _meshDS->AddHypothesis(_subShape, anHyp);
-//        if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
-//        if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
-                               if (ret &&
-                                       (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
-                               {
-                                       SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                                       if (algo == NULL)       // two algo on the same subShape...
-                                       {
-                                               INFOS("two algo on the same subshape not allowed");
-                                               ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-                                               ret = false;
-                                       }
-                                       else
-                                       {
-                                               ret = algo->CheckHypothesis((*_father), _subShape);
-                                               if (ret)
-                                                       SetAlgoState(HYP_OK);
-                                               else
-                                                       SetAlgoState(MISSING_HYP);
-                                       }
-                               }
-                       }
-                       break;
-               case REMOVE_HYP:
-                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-                       if (ret)
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               ASSERT(algo);
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (ret)
-                                       SetAlgoState(HYP_OK);
-                               else
-                                       SetAlgoState(MISSING_HYP);
-                               modifiedHyp = true;
-                       }
-                       break;
-               case REMOVE_ALGO:               // perhaps a father algo applies ?
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-//    if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
-//    if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
-                       if (ret && (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               if (algo == NULL)       // no more algo applying on subShape...
-                               {
-                                       SetAlgoState(NO_ALGO);
-                               }
-                               else
-                               {
-                                       ret = algo->CheckHypothesis((*_father), _subShape);
-                                       if (ret)
-                                               SetAlgoState(HYP_OK);
-                                       else
-                                               SetAlgoState(MISSING_HYP);
-                               }
-                       }
-                       break;
-               case ADD_FATHER_HYP:
-                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               ASSERT(algo);
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (ret)
-                                       SetAlgoState(HYP_OK);
-                               else
-                                       SetAlgoState(MISSING_HYP);
-                       }
-                       break;
-               case ADD_FATHER_ALGO:   // detect if two algo of same dim on father
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-//    if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
-//    if (anHyp->GetShapeType() == _subShape.ShapeType())
-                       if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               if (algo == NULL)       // two applying algo on father
-                               {
-                                       MESSAGE("two applying algo on fatherShape...");
-                                       SetAlgoState(NO_ALGO);
-                               }
-                               else
-                               {
-                                       ret = algo->CheckHypothesis((*_father), _subShape);
-                                       if (ret)
-                                               SetAlgoState(HYP_OK);
-                                       else
-                                               SetAlgoState(MISSING_HYP);
-                               }
-                       }
-                       break;
-               case REMOVE_FATHER_HYP:
-                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               ASSERT(algo);
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (ret)
-                                       SetAlgoState(HYP_OK);
-                               else
-                                       SetAlgoState(MISSING_HYP);
-                       }
-                       break;
-               case REMOVE_FATHER_ALGO:
-                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-//    if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
-//    if (anHyp->GetShapeType() == _subShape.ShapeType())
-                       if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
-                       {
-                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
-                               if (algo == NULL)       // no more applying algo on father
-                               {
-                                       SetAlgoState(NO_ALGO);
-                               }
-                               else
-                               {
-                                       ret = algo->CheckHypothesis((*_father), _subShape);
-                                       if (ret)
-                                               SetAlgoState(HYP_OK);
-                                       else
-                                               SetAlgoState(MISSING_HYP);
-                               }
-                       }
-                       break;
-               default:
-                       ASSERT(0);
-                       break;
-               }
-               break;
-
-               // ----------------------------------------------------------------------
-
-       default:
-               ASSERT(0);
-               break;
-       }
-       //SCRUTE(_algoState);
-       if ((_algoState != _oldAlgoState) || modifiedHyp)
-               int retc = ComputeStateEngine(MODIF_ALGO_STATE);
-       return ret;
+bool SMESH_subMesh::IsConform(const SMESH_Algo* theAlgo)
+{
+  MESSAGE( "SMESH_subMesh::IsConform" );
+
+  if ( !theAlgo ) return false;
+
+  // check only algo that doesn't NeedDescretBoundary(): because mesh made
+  // on a sub-shape will be ignored by theAlgo
+  if ( theAlgo->NeedDescretBoundary() )
+    return true;
+
+  SMESH_Gen* gen =_father->GetGen();
+  
+  // only local algo is to be checked
+  if ( gen->IsGlobalAlgo( theAlgo, *_father ))
+    return true;
+
+  // check algo attached to adjacent shapes
+
+  // loop on one level down sub-meshes
+  TopoDS_Iterator itsub( _subShape );
+  for (; itsub.More(); itsub.Next())
+  {
+    // loop on adjacent subShapes
+    TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( itsub.Value() ));
+    for (; it.More(); it.Next())
+    {
+      const TopoDS_Shape& adjacent = it.Value();
+      if ( _subShape.IsSame( adjacent )) continue;
+      if ( adjacent.ShapeType() != _subShape.ShapeType())
+        break;
+
+      // check algo attached to smAdjacent
+      SMESH_Algo * algo = gen->GetAlgo((*_father), adjacent);
+      if (algo &&
+          //algo != theAlgo &&
+          !algo->NeedDescretBoundary() /*&&
+          !gen->IsGlobalAlgo( algo, *_father )*/)
+        return false; // NOT CONFORM MESH WILL BE PRODUCED
+    }
+  }
+
+  return true;
 }
 
 //=============================================================================
@@ -1012,7 +970,7 @@ throw(SALOME_Exception)
 
 void SMESH_subMesh::SetAlgoState(int state)
 {
-       if (state != _oldAlgoState)
+//     if (state != _oldAlgoState)
 //     int retc = ComputeStateEngine(MODIF_ALGO_STATE);
                _algoState = state;
 }
@@ -1022,13 +980,15 @@ void SMESH_subMesh::SetAlgoState(int state)
  * 
  */
 //=============================================================================
-
-void SMESH_subMesh::SubMeshesAlgoStateEngine(int event,
-       SMESH_Hypothesis * anHyp) throw(SALOME_Exception)
+SMESH_Hypothesis::Hypothesis_Status 
+ SMESH_subMesh::SubMeshesAlgoStateEngine(int event,
+       SMESH_Hypothesis * anHyp)
 {
        //MESSAGE("SMESH_subMesh::SubMeshesAlgoStateEngine");
-       int dim = SMESH_Gen::GetShapeDim(_subShape);
-       if (dim > 1)
+  SMESH_Hypothesis::Hypothesis_Status ret = SMESH_Hypothesis::HYP_OK;
+       //EAP: a wire (dim==1) should notify edges (dim==1)
+       //EAP: int dim = SMESH_Gen::GetShapeDim(_subShape);
+       if (/*EAP:dim > 1*/ _subShape.ShapeType() < TopAbs_EDGE )
        {
                const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
 
@@ -1036,9 +996,36 @@ void SMESH_subMesh::SubMeshesAlgoStateEngine(int event,
                for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
                {
                        SMESH_subMesh *sm = (*itsub).second;
-                       sm->AlgoStateEngine(event, anHyp);
+                        SMESH_Hypothesis::Hypothesis_Status ret2 =
+                          sm->AlgoStateEngine(event, anHyp);
+                        if ( ret2 > ret )
+                          ret = ret2;
                }
        }
+  return ret;
+}
+
+//=============================================================================
+/*!
+ * 
+ */
+//=============================================================================
+
+void SMESH_subMesh::CleanDependsOn()
+{
+       MESSAGE("SMESH_subMesh::CleanDependsOn");
+       // **** parcourir les ancetres dans l'ordre de dépendance
+
+       ComputeStateEngine(CLEAN);
+
+       const map < int, SMESH_subMesh * >&dependson = DependsOn();
+       map < int, SMESH_subMesh * >::const_iterator its;
+       for (its = dependson.begin(); its != dependson.end(); its++)
+       {
+               SMESH_subMesh *sm = (*its).second;
+               SCRUTE((*its).first);
+               sm->ComputeStateEngine(CLEAN);
+       }
 }
 
 //=============================================================================
@@ -1099,217 +1086,340 @@ void SMESH_subMesh::DumpAlgoState(bool isMain)
  */
 //=============================================================================
 
-bool SMESH_subMesh::ComputeStateEngine(int event) throw(SALOME_Exception)
+bool SMESH_subMesh::ComputeStateEngine(int event)
 {
-       //MESSAGE("SMESH_subMesh::ComputeStateEngine");
-       //SCRUTE(_computeState);
-       //SCRUTE(event);
-
-       int dim = SMESH_Gen::GetShapeDim(_subShape);
+  //MESSAGE("SMESH_subMesh::ComputeStateEngine");
+  //SCRUTE(_computeState);
+  //SCRUTE(event);
+
+  int dim = SMESH_Gen::GetShapeDim(_subShape);
+
+  if (dim < 1)
+  {
+    if (_vertexSet)
+      _computeState = COMPUTE_OK;
+    else
+      _computeState = READY_TO_COMPUTE;
+    //SCRUTE(_computeState);
+    return true;
+  }
+  SMESH_Gen *gen = _father->GetGen();
+  SMESH_Algo *algo = 0;
+  bool ret;
+  SMESH_Hypothesis::Hypothesis_Status hyp_status;
+
+  switch (_computeState)
+  {
+
+    // ----------------------------------------------------------------------
+
+  case NOT_READY:
+    switch (event)
+    {
+    case MODIF_HYP:            // nothing to do
+      break;
+    case MODIF_ALGO_STATE:
+      if (_algoState == HYP_OK)
+      {
+        _computeState = READY_TO_COMPUTE;
+      }
+      break;
+    case COMPUTE:                      // nothing to do
+      break;
+    case CLEAN:
+      RemoveSubMeshElementsAndNodes();
+      break;
+    case CLEANDEP:
+      CleanDependants();
+      break;
+    case SUBMESH_COMPUTED:     // nothing to do
+      break;
+    case SUBMESH_RESTORED:
+      ComputeSubMeshStateEngine( SUBMESH_RESTORED );
+      break;
+    default:
+      ASSERT(0);
+      break;
+    }
+    break;
+
+    // ----------------------------------------------------------------------
+
+  case READY_TO_COMPUTE:
+    switch (event)
+    {
+    case MODIF_HYP:            // nothing to do
+      break;
+    case MODIF_ALGO_STATE:
+      _computeState = NOT_READY;
+      algo = gen->GetAlgo((*_father), _subShape);
+      if (algo)
+      {
+        ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
+        if (ret)
+          _computeState = READY_TO_COMPUTE;
+      }
+      break;
+    case COMPUTE:
+      {
+        algo = gen->GetAlgo((*_father), _subShape);
+        ASSERT(algo);
+        ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
+        if (!ret)
+        {
+          MESSAGE("***** verify compute state *****");
+          _computeState = NOT_READY;
+          break;
+        }
+        // check submeshes needed
+        if (algo->NeedDescretBoundary())
+          ret = SubMeshesComputed();
+        if (!ret)
+        {
+          MESSAGE("Some SubMeshes not computed");
+          _computeState = FAILED_TO_COMPUTE;
+          break;
+        }
+        // compute
+        if (!algo->NeedDescretBoundary() && !algo->OnlyUnaryInput())
+          ret = ApplyToCollection( algo, GetCollection( gen, algo ) );
+        else
+          ret = algo->Compute((*_father), _subShape);
+        
+        if (!ret)
+        {
+          MESSAGE("problem in algo execution: failed to compute");
+          _computeState = FAILED_TO_COMPUTE;
+          if (!algo->NeedDescretBoundary())
+            UpdateSubMeshState( FAILED_TO_COMPUTE );
+          break;
+        }
+        else
+        {
+          _computeState = COMPUTE_OK;
+          UpdateDependantsState( SUBMESH_COMPUTED ); // send event SUBMESH_COMPUTED
+          if (!algo->NeedDescretBoundary())
+            UpdateSubMeshState( COMPUTE_OK );
+        }
+      }
+      break;
+    case CLEAN:
+      RemoveSubMeshElementsAndNodes();
+      _computeState = NOT_READY;
+      algo = gen->GetAlgo((*_father), _subShape);
+      if (algo)
+      {
+        ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
+        if (ret)
+          _computeState = READY_TO_COMPUTE;
+      }
+      break;
+    case CLEANDEP:
+      CleanDependants();
+      break;
+    case SUBMESH_COMPUTED:      // nothing to do
+      break;
+    case SUBMESH_RESTORED:
+      // check if a mesh is already computed that may
+      // happen after retrieval from a file
+      if ( IsMeshComputed() ) {
+        _computeState = COMPUTE_OK;
+      }
+      ComputeSubMeshStateEngine( SUBMESH_RESTORED );
+      break;
+    default:
+      ASSERT(0);
+      break;
+    }
+    break;
+
+    // ----------------------------------------------------------------------
+
+  case COMPUTE_OK:
+    switch (event)
+    {
+    case MODIF_HYP:
+      CleanDependants();        // recursive recall with event CLEANDEP
+      algo = gen->GetAlgo((*_father), _subShape);
+      if (algo && !algo->NeedDescretBoundary())
+        CleanDependsOn(); // remove sub-mesh with event CLEANDEP
+      break;
+    case MODIF_ALGO_STATE:
+      CleanDependants();        // recursive recall with event CLEANDEP
+      algo = gen->GetAlgo((*_father), _subShape);
+      if (algo && !algo->NeedDescretBoundary())
+        CleanDependsOn(); // remove sub-mesh with event CLEANDEP
+      break;
+    case COMPUTE:                       // nothing to do
+      break;
+    case CLEAN:
+      RemoveSubMeshElementsAndNodes();
+      _computeState = NOT_READY;
+      algo = gen->GetAlgo((*_father), _subShape);
+      if (algo)
+      {
+        ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
+        if (ret)
+          _computeState = READY_TO_COMPUTE;
+      }
+      break;
+    case CLEANDEP:
+      CleanDependants();        // recursive recall with event CLEANDEP
+      break;
+    case SUBMESH_COMPUTED:      // nothing to do
+      break;
+    case SUBMESH_RESTORED:
+      ComputeSubMeshStateEngine( SUBMESH_RESTORED );
+      break;
+    default:
+      ASSERT(0);
+      break;
+    }
+    break;
+
+    // ----------------------------------------------------------------------
+
+  case FAILED_TO_COMPUTE:
+    switch (event)
+    {
+    case MODIF_HYP:
+      if (_algoState == HYP_OK)
+        _computeState = READY_TO_COMPUTE;
+      else
+        _computeState = NOT_READY;
+      break;
+    case MODIF_ALGO_STATE:
+      if (_algoState == HYP_OK)
+        _computeState = READY_TO_COMPUTE;
+      else
+        _computeState = NOT_READY;
+      break;
+    case COMPUTE:                       // nothing to do
+      break;
+    case CLEAN:
+      RemoveSubMeshElementsAndNodes();
+      if (_algoState == HYP_OK)
+        _computeState = READY_TO_COMPUTE;
+      else
+        _computeState = NOT_READY;
+      break;
+    case CLEANDEP:
+      CleanDependants();
+      break;
+    case SUBMESH_COMPUTED:      // allow retry compute
+      if (_algoState == HYP_OK)
+        _computeState = READY_TO_COMPUTE;
+      else
+        _computeState = NOT_READY;
+      break;
+    case SUBMESH_RESTORED:
+      ComputeSubMeshStateEngine( SUBMESH_RESTORED );
+      break;
+    default:
+      ASSERT(0);
+      break;
+    }
+    break;
+
+    // ----------------------------------------------------------------------
+  default:
+    ASSERT(0);
+    break;
+  }
+
+  //SCRUTE(_computeState);
+  return ret;
+}
 
-       if (dim < 1)
-       {
-               if (_vertexSet)
-                       _computeState = COMPUTE_OK;
-               else
-                       _computeState = READY_TO_COMPUTE;
-               //SCRUTE(_computeState);
-               return true;
-       }
-       SMESH_Gen *gen = _father->GetGen();
-       SMESH_Algo *algo = 0;
-       bool ret;
+//=======================================================================
+//function : ApplyToCollection
+//purpose  : Apply theAlgo to all subshapes in theCollection
+//=======================================================================
 
-       switch (_computeState)
-       {
-
-               // ----------------------------------------------------------------------
+bool SMESH_subMesh::ApplyToCollection (SMESH_Algo*         theAlgo,
+                                       const TopoDS_Shape& theCollection)
+{
+  MESSAGE("SMESH_subMesh::ApplyToCollection");
+  ASSERT ( !theAlgo->NeedDescretBoundary() );
+
+  bool ret = false;
+
+
+  ret = theAlgo->Compute( *_father, theCollection );
+
+  // set _computeState of subshapes
+  TopExp_Explorer anExplorer( theCollection, _subShape.ShapeType() );
+  for ( ; anExplorer.More(); anExplorer.Next() )
+  {
+    const TopoDS_Shape& aSubShape = anExplorer.Current();
+    SMESH_subMesh* subMesh = _father->GetSubMeshContaining( aSubShape );
+    if ( subMesh )
+    {
+      if (ret)
+      {
+        subMesh->_computeState = COMPUTE_OK;
+        subMesh->UpdateDependantsState( SUBMESH_COMPUTED );
+        subMesh->UpdateSubMeshState( COMPUTE_OK );
+      }
+      else
+      {
+        subMesh->_computeState = FAILED_TO_COMPUTE;
+      }
+    }
+  }
+  return ret;
+}
 
-       case NOT_READY:
-               switch (event)
-               {
-               case MODIF_HYP:         // nothing to do
-                       break;
-               case MODIF_ALGO_STATE:
-                       if (_algoState == HYP_OK)
-                               _computeState = READY_TO_COMPUTE;
-                       break;
-               case COMPUTE:                   // nothing to do
-                       break;
-               case CLEAN:                     // nothing to do
-                       break;
-               case CLEANDEP:                  // nothing to do
-                       RemoveSubMeshElementsAndNodes();        // recursive call...
-                       break;
-               case SUBMESH_COMPUTED:  // nothing to do
-                       break;
-               default:
-                       ASSERT(0);
-                       break;
-               }
-               break;
 
-               // ----------------------------------------------------------------------
+//=======================================================================
+//function : UpdateSubMeshState
+//purpose  : 
+//=======================================================================
 
-       case READY_TO_COMPUTE:
-               switch (event)
-               {
-               case MODIF_HYP:         // nothing to do
-                       break;
-               case MODIF_ALGO_STATE:
-                       _computeState = NOT_READY;
-                       algo = gen->GetAlgo((*_father), _subShape);
-                       if (algo)
-                       {
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (ret)
-                                       _computeState = READY_TO_COMPUTE;
-                       }
-                       break;
-               case COMPUTE:
-               {
-                       algo = gen->GetAlgo((*_father), _subShape);
-                       ASSERT(algo);
-                       ret = algo->CheckHypothesis((*_father), _subShape);
-                       if (!ret)
-                       {
-                               MESSAGE("***** verify compute state *****");
-                               _computeState = NOT_READY;
-                               break;
-                       }
-                       ret = SubMeshesComputed();
-                       if (!ret)
-                       {
-                               MESSAGE("Some SubMeshes not computed");
-                               _computeState = FAILED_TO_COMPUTE;
-                               break;
-                       }
-                       ret = algo->Compute((*_father), _subShape);
-                       if (!ret)
-                       {
-                               MESSAGE("problem in algo execution: failed to compute");
-                               _computeState = FAILED_TO_COMPUTE;
-                               break;
-                       }
-                       else
-                       {
-                               _computeState = COMPUTE_OK;
-                               UpdateDependantsState();        // send event SUBMESH_COMPUTED
-                       }
-               }
-                       break;
-               case CLEAN:
-                       _computeState = NOT_READY;
-                       algo = gen->GetAlgo((*_father), _subShape);
-                       if (algo)
-                       {
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (ret)
-                                       _computeState = READY_TO_COMPUTE;
-                       }
-                       break;
-               case CLEANDEP:
-                       RemoveSubMeshElementsAndNodes();
-                       _computeState = NOT_READY;
-                       algo = gen->GetAlgo((*_father), _subShape);
-                       if (algo)
-                       {
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (ret)
-                                       _computeState = READY_TO_COMPUTE;
-                       }
-                       break;
-               case SUBMESH_COMPUTED:  // nothing to do
-                       break;
-               default:
-                       ASSERT(0);
-                       break;
-               }
-               break;
-
-               // ----------------------------------------------------------------------
-
-       case COMPUTE_OK:
-               switch (event)
-               {
-               case MODIF_HYP:
-                       CleanDependants();      // recursive recall with event CLEANDEP
-                       break;
-               case MODIF_ALGO_STATE:
-                       CleanDependants();      // recursive recall with event CLEANDEP
-                       break;
-               case COMPUTE:                   // nothing to do
-                       break;
-               case CLEAN:
-                       CleanDependants();      // recursive recall with event CLEANDEP
-                       break;
-               case CLEANDEP:
-                       RemoveSubMeshElementsAndNodes();
-                       _computeState = NOT_READY;
-                       algo = gen->GetAlgo((*_father), _subShape);
-                       if (algo)
-                       {
-                               ret = algo->CheckHypothesis((*_father), _subShape);
-                               if (ret)
-                                       _computeState = READY_TO_COMPUTE;
-                       }
-                       break;
-               case SUBMESH_COMPUTED:  // nothing to do
-                       break;
-               default:
-                       ASSERT(0);
-                       break;
-               }
-               break;
+void SMESH_subMesh::UpdateSubMeshState(const compute_state theState)
+{
+  const map<int, SMESH_subMesh*>& smMap = DependsOn();
+  map<int, SMESH_subMesh*>::const_iterator itsub;
+  for (itsub = smMap.begin(); itsub != smMap.end(); itsub++)
+  {
+    SMESH_subMesh* sm = (*itsub).second;
+    sm->_computeState = theState;
+  }
+}
 
-               // ----------------------------------------------------------------------
+//=======================================================================
+//function : ComputeSubMeshStateEngine
+//purpose  : 
+//=======================================================================
 
-       case FAILED_TO_COMPUTE:
-               switch (event)
-               {
-               case MODIF_HYP:
-                       if (_algoState == HYP_OK)
-                               _computeState = READY_TO_COMPUTE;
-                       else
-                               _computeState = NOT_READY;
-                       break;
-               case MODIF_ALGO_STATE:
-                       if (_algoState == HYP_OK)
-                               _computeState = READY_TO_COMPUTE;
-                       else
-                               _computeState = NOT_READY;
-                       break;
-               case COMPUTE:                   // nothing to do
-                       break;
-               case CLEAN:
-                       break;
-               case CLEANDEP:
-                       RemoveSubMeshElementsAndNodes();
-                       if (_algoState == HYP_OK)
-                               _computeState = READY_TO_COMPUTE;
-                       else
-                               _computeState = NOT_READY;
-                       break;
-               case SUBMESH_COMPUTED:  // allow retry compute
-                       if (_algoState == HYP_OK)
-                               _computeState = READY_TO_COMPUTE;
-                       else
-                               _computeState = NOT_READY;
-                       break;
-               default:
-                       ASSERT(0);
-                       break;
-               }
-               break;
+void SMESH_subMesh::ComputeSubMeshStateEngine(int event)
+{
+  const map<int, SMESH_subMesh*>& smMap = DependsOn();
+  map<int, SMESH_subMesh*>::const_iterator itsub;
+  for (itsub = smMap.begin(); itsub != smMap.end(); itsub++)
+  {
+    SMESH_subMesh* sm = (*itsub).second;
+    sm->ComputeStateEngine(event);
+  }
+}
 
-               // ----------------------------------------------------------------------
-       default:
-               ASSERT(0);
-               break;
-       }
+//=======================================================================
+//function : UpdateDependantsState
+//purpose  : 
+//=======================================================================
 
-       //SCRUTE(_computeState);
-       return ret;
+void SMESH_subMesh::UpdateDependantsState(const compute_event theEvent)
+{
+  //MESSAGE("SMESH_subMesh::UpdateDependantsState");
+  TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
+  for (; it.More(); it.Next())
+  {
+    const TopoDS_Shape& ancestor = it.Value();
+    SMESH_subMesh *aSubMesh =
+      _father->GetSubMeshContaining(ancestor);
+    if (aSubMesh)
+      aSubMesh->ComputeStateEngine( theEvent );
+  }
 }
 
 //=============================================================================
@@ -1318,40 +1428,49 @@ bool SMESH_subMesh::ComputeStateEngine(int event) throw(SALOME_Exception)
  */
 //=============================================================================
 
-void SMESH_subMesh::UpdateDependantsState()
+void SMESH_subMesh::CleanDependants()
 {
-       //MESSAGE("SMESH_subMesh::UpdateDependantsState");
-
-       const map < int, SMESH_subMesh * >&dependants = Dependants();
-       map < int, SMESH_subMesh * >::const_iterator its;
-       for (its = dependants.begin(); its != dependants.end(); its++)
-       {
-               SMESH_subMesh *sm = (*its).second;
-               //SCRUTE((*its).first);
-               sm->ComputeStateEngine(SUBMESH_COMPUTED);
-       }
+  //MESSAGE("SMESH_subMesh::CleanDependants: shape type " << _subShape.ShapeType() );
+
+  TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
+  for (; it.More(); it.Next())
+  {
+    const TopoDS_Shape& ancestor = it.Value();
+    //MESSAGE("ancestor shape type " << ancestor.ShapeType() );
+    SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor);
+    if (aSubMesh)
+      aSubMesh->ComputeStateEngine(CLEANDEP);
+  }
+  ComputeStateEngine(CLEAN);
 }
 
+
 //=============================================================================
 /*!
  * 
  */
 //=============================================================================
 
-void SMESH_subMesh::CleanDependants()
+static void removeSubMesh( SMESHDS_Mesh * meshDS, const TopoDS_Shape& subShape)
 {
-       MESSAGE("SMESH_subMesh::CleanDependants");
-       // **** parcourir les ancetres dans l'ordre de dépendance
-
-       const map < int, SMESH_subMesh * >&dependants = Dependants();
-       map < int, SMESH_subMesh * >::const_iterator its;
-       for (its = dependants.begin(); its != dependants.end(); its++)
-       {
-               SMESH_subMesh *sm = (*its).second;
-               SCRUTE((*its).first);
-               sm->ComputeStateEngine(CLEANDEP);
-       }
-       ComputeStateEngine(CLEANDEP);
+  SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(subShape);
+  if (subMeshDS!=NULL)
+  {
+    SMDS_ElemIteratorPtr ite=subMeshDS->GetElements();
+    while(ite->more())
+    {
+      const SMDS_MeshElement * elt = ite->next();
+      //MESSAGE( " RM elt: "<<elt->GetID()<<" ( "<<elt->NbNodes()<<" )" );
+      meshDS->RemoveElement(elt);
+    }
+
+    SMDS_NodeIteratorPtr itn=subMeshDS->GetNodes();
+    while(itn->more())
+    {
+      const SMDS_MeshNode * node = itn->next();
+      meshDS->RemoveNode(node);
+    }
+  }
 }
 
 //=============================================================================
@@ -1362,161 +1481,173 @@ void SMESH_subMesh::CleanDependants()
 
 void SMESH_subMesh::RemoveSubMeshElementsAndNodes()
 {
-       MESSAGE("SMESH_subMesh::RemoveSubMeshElementsAndNodes");
-       SCRUTE(_subShape.ShapeType());
-       SCRUTE(_Id);
-
-       _subMeshDS = _meshDS->MeshElements(_subShape);
-       if (_subMeshDS!=NULL)
-       {
-               SMDS_Iterator<const SMDS_MeshElement *> * ite=_subMeshDS->GetElements();
-               while(ite->more())
-               {
-                       const SMDS_MeshElement * elt = ite->next();
-                       _subMeshDS->RemoveElement(elt);
-                       _meshDS->RemoveElement(elt);
-               }
-               delete ite;
-               
-               SMDS_Iterator<const SMDS_MeshNode *> * itn=_subMeshDS->GetNodes();
-               while(itn->more())
-               {
-                       const SMDS_MeshNode * node = itn->next();
-                       _subMeshDS->RemoveNode(node);
-                       _meshDS->RemoveNode(node);
-               }
-               delete itn;
-       }
+  SCRUTE(_subShape.ShapeType());
+
+  removeSubMesh( _meshDS, _subShape );
+
+  // algo may bind a submesh not to _subShape, eg 3D algo
+  // sets nodes on SHELL while _subShape may be SOLID
+
+  int dim = SMESH_Gen::GetShapeDim( _subShape );
+  int type = _subShape.ShapeType() + 1;
+  for ( ; type <= TopAbs_EDGE; type++)
+    if ( dim == SMESH_Gen::GetShapeDim( (TopAbs_ShapeEnum) type ))
+    {
+      TopExp_Explorer exp( _subShape, (TopAbs_ShapeEnum) type );
+      for ( ; exp.More(); exp.Next() )
+        removeSubMesh( _meshDS, exp.Current() );
+    }
+    else
+      break;
 }
 
-//=============================================================================
-/*!
- * 
- */
-//=============================================================================
+//=======================================================================
+//function : IsMeshComputed
+//purpose  : check if _subMeshDS contains mesh elements
+//=======================================================================
 
-const map < int, SMESH_subMesh * >&SMESH_subMesh::Dependants()
+bool SMESH_subMesh::IsMeshComputed() const
 {
-       if (_dependantsFound)
-               return _mapDependants;
+  // algo may bind a submesh not to _subShape, eg 3D algo
+  // sets nodes on SHELL while _subShape may be SOLID
+
+  int dim = SMESH_Gen::GetShapeDim( _subShape );
+  int type = _subShape.ShapeType();
+  for ( ; type <= TopAbs_VERTEX; type++) {
+    if ( dim == SMESH_Gen::GetShapeDim( (TopAbs_ShapeEnum) type ))
+    {
+      TopExp_Explorer exp( _subShape, (TopAbs_ShapeEnum) type );
+      for ( ; exp.More(); exp.Next() )
+      {
+        SMESHDS_SubMesh * subMeshDS = _meshDS->MeshElements( exp.Current() );
+        if ( subMeshDS != NULL &&
+            (subMeshDS->GetElements()->more() || subMeshDS->GetNodes()->more())) {
+          return true;
+        }
+      }
+    }
+    else
+      break;
+  }
+
+  return false;
+}
 
-       //MESSAGE("SMESH_subMesh::Dependants");
 
-       int shapeType = _subShape.ShapeType();
-       //SCRUTE(shapeType);
-       TopTools_IndexedDataMapOfShapeListOfShape M;
-       TopoDS_Shape mainShape = _meshDS->ShapeToMesh();
+//=======================================================================
+//function : GetCollection
+//purpose  : return a shape containing all sub-shapes of the MainShape that can be
+//           meshed at once along with _subShape
+//=======================================================================
 
-       switch (shapeType)
-       {
-       case TopAbs_VERTEX:
-               break;
-       case TopAbs_EDGE:
-       case TopAbs_WIRE:
-               TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_WIRE, M);
-               TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_FACE, M);
-               TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_SHELL, M);
-               TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_SOLID, M);
-               TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_COMPSOLID,
-                       M);
-               ExtractDependants(M, TopAbs_EDGE);
-               break;
-       case TopAbs_FACE:
-       case TopAbs_SHELL:
-               TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_SHELL, M);
-               TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_SOLID, M);
-               TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_COMPSOLID,
-                       M);
-               ExtractDependants(M, TopAbs_FACE);
-               break;
-       case TopAbs_SOLID:
-       case TopAbs_COMPSOLID:
-               TopExp::MapShapesAndAncestors(mainShape, TopAbs_SOLID, TopAbs_COMPSOLID,
-                       M);
-               ExtractDependants(M, TopAbs_SOLID);
-               break;
-       case TopAbs_COMPOUND:
-               break;
-       }
-
-       _dependantsFound = true;
-       return _mapDependants;
+TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlgo)
+{
+  MESSAGE("SMESH_subMesh::GetCollection");
+  ASSERT (!theAlgo->NeedDescretBoundary());
+  
+  TopoDS_Shape mainShape = _father->GetMeshDS()->ShapeToMesh();
+
+  if ( mainShape.IsSame( _subShape ))
+    return _subShape;
+
+  list<const SMESHDS_Hypothesis*> aUsedHyp =
+    theAlgo->GetUsedHypothesis( *_father, _subShape ); // copy
+  
+  // put in a compound all shapes with the same hypothesis assigned
+  // and a good ComputState
+
+  TopoDS_Compound aCompound;
+  BRep_Builder aBuilder;
+  aBuilder.MakeCompound( aCompound );
+
+  TopExp_Explorer anExplorer( mainShape, _subShape.ShapeType() );
+  for ( ; anExplorer.More(); anExplorer.Next() )
+  {
+    const TopoDS_Shape& S = anExplorer.Current();
+    SMESH_subMesh* subMesh = _father->GetSubMesh( S );
+    SMESH_Algo* anAlgo = theGen->GetAlgo( *_father, S );
+
+    if (subMesh->GetComputeState() == READY_TO_COMPUTE &&
+        anAlgo == theAlgo &&
+        anAlgo->GetUsedHypothesis( *_father, S ) == aUsedHyp)
+    {
+      aBuilder.Add( aCompound, S );
+    }
+  }
+
+  return aCompound;
 }
 
-//=============================================================================
-/*!
- * 
- */
-//=============================================================================
-
-void SMESH_subMesh::
-ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape & M,
-       const TopAbs_ShapeEnum etype)
+//=======================================================================
+//function : GetNbAttached
+//purpose  : return nb of hypotheses attached to theShape.
+//           If theHyp is provided, similar but not same hypotheses
+//           are countered; else only applicable ones are countered
+//           depending on theAlgos flag
+//=======================================================================
+
+int SMESH_subMesh::GetNbAttached(const TopoDS_Shape&      theShape,
+                                 const SMESH_Hypothesis * theHyp,
+                                 const bool               theAlgos)
 {
-       //MESSAGE("SMESH_subMesh::ExtractDependants");
+  int nb = 0;
+
+  const list<const SMESHDS_Hypothesis*>& aHypList =
+    _father->GetHypothesisList( theShape );
+  list<const SMESHDS_Hypothesis*>::const_iterator it = aHypList.begin();
+  while (it!=aHypList.end())
+  {
+    const SMESH_Hypothesis* hyp = static_cast< const SMESH_Hypothesis *>( *it );
+    it++;
+
+    if ( theHyp )
+    {
+      // count similar
+      if (hyp != theHyp &&
+          hyp->GetType() == theHyp->GetType() &&
+          hyp->GetDim()  == theHyp->GetDim())
+        nb++;
+    }
+    else
+    {
+      bool isAlgo = ( hyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO );
+      if ( theAlgos == isAlgo && IsApplicableHypotesis( hyp ))
+        nb++;
+    }
+  }
+
+  return nb;
+}
 
-       TopoDS_Shape mainShape = _meshDS->ShapeToMesh();
-       int lg = M.Extent();
-       //SCRUTE(lg);
+//=======================================================================
+//function : CheckConcurentHypothesis
+//purpose  : check if there are several applicable hypothesis on fathers
+//=======================================================================
 
-       int shapeType = _subShape.ShapeType();
-       switch (shapeType)
-       {
-       case TopAbs_VERTEX:
-               break;
-       case TopAbs_EDGE:
-       case TopAbs_FACE:
-       case TopAbs_SOLID:
-       {
-               const TopTools_ListOfShape & ancestors = M.FindFromKey(_subShape);
-               TopTools_ListIteratorOfListOfShape it(ancestors);
-               for (; it.More(); it.Next())
-               {
-                       TopoDS_Shape ancestor = it.Value();
-                       SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor);
-                       //      if (! aSubMesh) aSubMesh = _father->GetSubMesh(ancestor);
-                       if (aSubMesh)
-                       {
-                               int type = aSubMesh->_subShape.ShapeType();
-                               int cle = aSubMesh->GetId();
-                               cle += 10000000 * type; // sort map by ordType then index
-                               if (_mapDependants.find(cle) == _mapDependants.end())
-                               {
-                                       _mapDependants[cle] = aSubMesh;
-                                       //SCRUTE(cle);
-                               }
-                       }
-               }
-       }
-               break;
-       case TopAbs_WIRE:
-       case TopAbs_SHELL:
-       case TopAbs_COMPSOLID:
-               for (TopExp_Explorer expE(_subShape, etype); expE.More(); expE.Next())
-               {
-                       TopoDS_Shape aShape = expE.Current();
-                       const TopTools_ListOfShape & ancestors = M.FindFromKey(aShape);
-                       TopTools_ListIteratorOfListOfShape it(ancestors);
-                       for (; it.More(); it.Next())
-                       {
-                               MESSAGE("---");
-                               TopoDS_Shape ancestor = it.Value();
-                               SMESH_subMesh *aSubMesh =
-                                       _father->GetSubMeshContaining(ancestor);
-                               if (!aSubMesh)
-                                       aSubMesh = _father->GetSubMesh(ancestor);
-                               int type = aSubMesh->_subShape.ShapeType();
-                               int cle = aSubMesh->GetId();
-                               cle += 10000000 * type; // sort map by ordType then index
-                               if (_mapDependants.find(cle) == _mapDependants.end())
-                               {
-                                       _mapDependants[cle] = aSubMesh;
-                                       SCRUTE(cle);
-                               }
-                       }
-               }
-               break;
-       case TopAbs_COMPOUND:
-               break;
-       }
+SMESH_Hypothesis::Hypothesis_Status
+  SMESH_subMesh::CheckConcurentHypothesis (const int theHypType)
+{
+  MESSAGE ("SMESH_subMesh::CheckConcurentHypothesis");
+
+  // is there local hypothesis on me?
+  if ( GetNbAttached( _subShape, 0, theHypType > SMESHDS_Hypothesis::PARAM_ALGO ) > 0 )
+    return SMESH_Hypothesis::HYP_OK;
+
+    
+  TopoDS_Shape aPrevWithHyp;
+  TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
+  for (; it.More(); it.Next())
+  {
+    const TopoDS_Shape& ancestor = it.Value();
+    if ( GetNbAttached( ancestor, 0, theHypType > SMESHDS_Hypothesis::PARAM_ALGO ) > 0 )
+    {
+      if ( aPrevWithHyp.IsNull() || aPrevWithHyp.IsSame( ancestor ))
+        aPrevWithHyp = ancestor;
+      else if ( aPrevWithHyp.ShapeType() == ancestor.ShapeType() )
+        return SMESH_Hypothesis::HYP_CONCURENT;
+      else
+        return SMESH_Hypothesis::HYP_OK;
+    }
+  }
+  return SMESH_Hypothesis::HYP_OK;
 }
index f72e4f65b32c09951c1d1d5bd32836b87f69d96f..937479da749c4e9d40dbdc1eea690cdfdb7a580c 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "SMESHDS_Mesh.hxx"
 #include "SMESHDS_SubMesh.hxx"
+#include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
 #include <TopoDS_Shape.hxx>
 #include <TColStd_IndexedMapOfTransient.hxx>
 
 class SMESH_Mesh;
 class SMESH_Hypothesis;
+class SMESH_Algo;
+class SMESH_Gen;
 
 class SMESH_subMesh
 {
 public:
-       SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
+ public:
+  SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
                const TopoDS_Shape & aSubShape);
-       virtual ~ SMESH_subMesh();
+  virtual ~ SMESH_subMesh();
 
-       int GetId();
+  int GetId() const;
 
-//   bool Contains(const TopoDS_Shape & aSubShape)
-//     throw (SALOME_Exception);
+  //   bool Contains(const TopoDS_Shape & aSubShape)
+  //     throw (SALOME_Exception);
 
-       SMESHDS_SubMesh * GetSubMeshDS() throw(SALOME_Exception);
+  SMESHDS_SubMesh * GetSubMeshDS();
 
-       SMESH_subMesh *GetFirstToCompute() throw(SALOME_Exception);
-
-       const map < int, SMESH_subMesh * >&DependsOn();
-       const map < int, SMESH_subMesh * >&Dependants();
-
-       const TopoDS_Shape & GetSubShape();
-
-       bool _vertexSet;                        // only for vertex subMesh, set to false for dim > 0
-
-       enum compute_state
-       { NOT_READY, READY_TO_COMPUTE,
-               COMPUTE_OK, FAILED_TO_COMPUTE
-       };
-       enum algo_state
-       { NO_ALGO, MISSING_HYP, HYP_OK };
-       enum algo_event
-       { ADD_HYP, ADD_ALGO,
-               REMOVE_HYP, REMOVE_ALGO,
-               ADD_FATHER_HYP, ADD_FATHER_ALGO,
-               REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO
-       };
-       enum compute_event
-       { MODIF_HYP, MODIF_ALGO_STATE, COMPUTE,
-               CLEAN, CLEANDEP, SUBMESH_COMPUTED
-       };
-
-       bool AlgoStateEngine(int event, SMESH_Hypothesis * anHyp)
-               throw(SALOME_Exception);
-
-       void SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp)
-               throw(SALOME_Exception);
-
-       void DumpAlgoState(bool isMain);
-
-       bool ComputeStateEngine(int event) throw(SALOME_Exception);
-
-       int GetComputeState()
-       {
-               return _computeState;
-       };
-
-  protected:
-       void InsertDependence(const TopoDS_Shape aSubShape);
-//   void FinalizeDependence(list<TopoDS_Shape>& shapeList);
-
-       bool SubMeshesComputed() throw(SALOME_Exception);
-
-       bool SubMeshesReady();
-
-       void RemoveSubMeshElementsAndNodes();
-       void UpdateDependantsState();
-       void CleanDependants();
-       void ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape & M,
-               const TopAbs_ShapeEnum etype);
-       void SetAlgoState(int state);
-
-       TopoDS_Shape _subShape;
-       SMESHDS_Mesh * _meshDS;
-       SMESHDS_SubMesh * _subMeshDS;
-       int _Id;
-       SMESH_Mesh *_father;
-       map < int, SMESH_subMesh * >_mapDepend;
-       map < int, SMESH_subMesh * >_mapDependants;
-       bool _dependenceAnalysed;
-       bool _dependantsFound;
-
-       int _algoState;
-       int _oldAlgoState;
-       int _computeState;
+  SMESHDS_SubMesh* CreateSubMeshDS();
+  // Explicit SMESHDS_SubMesh creation method, required for persistence mechanism
+
+  SMESH_subMesh *GetFirstToCompute();
+
+  const map < int, SMESH_subMesh * >&DependsOn();
+  //const map < int, SMESH_subMesh * >&Dependants();
+
+  const TopoDS_Shape & GetSubShape();
+
+  bool _vertexSet;                     // only for vertex subMesh, set to false for dim > 0
+
+  enum compute_state
+  {
+    NOT_READY, READY_TO_COMPUTE,
+    COMPUTE_OK, FAILED_TO_COMPUTE
+    };
+  enum algo_state
+  {
+    NO_ALGO, MISSING_HYP, HYP_OK
+    };
+  enum algo_event
+  {
+    ADD_HYP, ADD_ALGO,
+    REMOVE_HYP, REMOVE_ALGO,
+    ADD_FATHER_HYP, ADD_FATHER_ALGO,
+    REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO
+    };
+  enum compute_event
+  {
+    MODIF_HYP, MODIF_ALGO_STATE, COMPUTE,
+    CLEAN, CLEANDEP, SUBMESH_COMPUTED, SUBMESH_RESTORED
+    };
+
+  SMESH_Hypothesis::Hypothesis_Status
+    AlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
+
+  SMESH_Hypothesis::Hypothesis_Status
+    SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
+
+  int GetAlgoState() { return _algoState; }
+
+  void DumpAlgoState(bool isMain);
+
+  bool ComputeStateEngine(int event);
+
+  int GetComputeState()
+  {
+    return _computeState;
+  };
+
+  bool IsConform(const SMESH_Algo* theAlgo);
+  // check if a conform mesh will be produced by the Algo
+
+  bool CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) const;
+  // return true if theHypothesis can be attached to me:
+  // its dimention is checked
+
+  bool IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis) const;
+  // return true if theHypothesis can be used to mesh me:
+  // its shape type is checked
+  
+
+ protected:
+  void InsertDependence(const TopoDS_Shape aSubShape);
+
+  bool SubMeshesComputed();
+
+  bool SubMeshesReady();
+
+  void RemoveSubMeshElementsAndNodes();
+  void UpdateDependantsState(const compute_event theEvent);
+  void UpdateSubMeshState(const compute_state theState);
+  void ComputeSubMeshStateEngine(int event);
+  void CleanDependants();
+  void CleanDependsOn();
+  void SetAlgoState(int state);
+
+  bool IsMeshComputed() const;
+  // check if _subMeshDS contains mesh elements
+
+  TopoDS_Shape GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlgo);
+  // return a shape containing all sub-shapes of the MainShape that can be
+  // meshed at once along with _subShape
+
+  bool ApplyToCollection (SMESH_Algo*         theAlgo,
+                          const TopoDS_Shape& theCollection);
+  // Apply theAlgo to all subshapes in theCollection
+
+  SMESH_Hypothesis::Hypothesis_Status CheckConcurentHypothesis (const int theHypType);
+  // check if there are several applicable hypothesis on fathers
+
+  int GetNbAttached(const TopoDS_Shape&      theShape,
+                    const SMESH_Hypothesis * theHyp,
+                    const bool               theAlgos = false);
+  // return nb of hypotheses attached to theShape.
+  // If theHyp is provided, similar but not same hypotheses
+  // are countered; else only applicable ones are countered
+  // depending on theAlgos flag
+  
+  TopoDS_Shape _subShape;
+  SMESHDS_Mesh * _meshDS;
+  SMESHDS_SubMesh * _subMeshDS;
+  int _Id;
+  SMESH_Mesh *_father;
+  map < int, SMESH_subMesh * >_mapDepend;
+  //map < int, SMESH_subMesh * >_mapDependants;
+  bool _dependenceAnalysed;
+  //bool _dependantsFound;
+
+  int _algoState;
+  //int _oldAlgoState;
+  int _computeState;
 
 };
 
index bc62fc4ca839456559b3f935f78228090702fa8c..2b4d5391e4224328536051b5795253a1ebb156ff 100644 (file)
@@ -42,7 +42,8 @@ LIB_SRC = \
        SMESHDS_Script.cxx \
        SMESHDS_Command.cxx \
        SMESHDS_SubMesh.cxx \
-       SMESHDS_Mesh.cxx
+       SMESHDS_Mesh.cxx \
+       SMESHDS_Group.cxx
 
 LIB_CLIENT_IDL = 
 LIB_SERVER_IDL = 
@@ -61,10 +62,11 @@ EXPORT_HEADERS= \
        SMESHDS_Script.hxx \
        SMESHDS_Command.hxx \
        SMESHDS_CommandType.hxx \
-       SMESHDS_SubMesh.hxx 
+       SMESHDS_SubMesh.hxx \
+       SMESHDS_Group.hxx
 
 # additionnal information to compil and link file
-CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
 CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome
 LDFLAGS  += $(OCC_KERNEL_LIBS)
 
index 0396c6ba75cff834279258f1c7fcc6a7e63c07f0..a6cae5391c7d9287a4e4f1708c32e2976d9fbeba 100644 (file)
@@ -100,11 +100,16 @@ bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
 //function : AddNode
 //purpose  : 
 //=======================================================================
-SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z)
-{
-       SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
-       if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
-       return node;
+SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
+  SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
+  if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
+  return node;
+}
+
+SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
+  SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
+  if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
+  return node;
 }
 
 //=======================================================================
@@ -113,137 +118,345 @@ SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z)
 //=======================================================================
 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
 {
-       SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
-       node->setXYZ(x,y,z);
-       myScript->MoveNode(n->GetID(), x, y, z);
+  SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
+  node->setXYZ(x,y,z);
+  myScript->MoveNode(n->GetID(), x, y, z);
 }
 
 //=======================================================================
 //function : AddEdge
 //purpose  : 
 //=======================================================================
+SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
+{
+  SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
+  if(anElem) myScript->AddEdge(ID,n1,n2);
+  return anElem;
+}
+
+SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2, 
+                                          int ID)
+{
+  return AddEdgeWithID(n1->GetID(),
+                      n2->GetID(),
+                      ID);
+}
+
 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2)
+                                    const SMDS_MeshNode * n2)
 {
-       SMDS_MeshEdge* e = SMDS_Mesh::AddEdge(n1,n2);
-       if(e!=NULL) myScript->AddEdge(e->GetID(), n1->GetID(), n2->GetID());
-       return e;
+  SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
+  if(anElem) myScript->AddEdge(anElem->GetID(), 
+                              n1->GetID(), 
+                              n2->GetID());
+  return anElem;
 }
 
 //=======================================================================
 //function :AddFace
 //purpose  : 
 //=======================================================================
+SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
+{
+  SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
+  if(anElem) myScript->AddFace(ID,n1,n2,n3);
+  return anElem;
+}
+
+SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2,
+                                          const SMDS_MeshNode * n3, 
+                                          int ID)
+{
+  return AddFaceWithID(n1->GetID(),
+                      n2->GetID(),
+                      n3->GetID(),
+                      ID);
+}
+
 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3)
+                                     const SMDS_MeshNode * n2,
+                                     const SMDS_MeshNode * n3)
 {
-       SMDS_MeshFace *f = SMDS_Mesh::AddFace(n1, n2, n3);
-       if(f!=NULL) myScript->AddFace(f->GetID(), n1->GetID(), n2->GetID(),
-               n3->GetID());
-       return f;
+  SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
+  if(anElem) myScript->AddFace(anElem->GetID(), 
+                              n1->GetID(), 
+                              n2->GetID(),
+                              n3->GetID());
+  return anElem;
 }
 
 //=======================================================================
 //function :AddFace
 //purpose  : 
 //=======================================================================
+SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
+{
+  SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
+  if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
+  return anElem;
+}
+
+SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2,
+                                          const SMDS_MeshNode * n3,
+                                          const SMDS_MeshNode * n4, 
+                                          int ID)
+{
+  return AddFaceWithID(n1->GetID(),
+                      n2->GetID(),
+                      n3->GetID(),
+                      n4->GetID(),
+                      ID);
+}
+
 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4)
+                                    const SMDS_MeshNode * n2,
+                                    const SMDS_MeshNode * n3,
+                                    const SMDS_MeshNode * n4)
 {
-       SMDS_MeshFace *f = SMDS_Mesh::AddFace(n1, n2, n3, n4);
-       if(f!=NULL)
-               myScript->AddFace(f->GetID(), n1->GetID(), n2->GetID(), n3->GetID(),
-                       n4->GetID());
-       return f;
+  SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
+  if(anElem) myScript->AddFace(anElem->GetID(), 
+                              n1->GetID(), 
+                              n2->GetID(), 
+                              n3->GetID(),
+                              n4->GetID());
+  return anElem;
 }
 
 //=======================================================================
 //function :AddVolume
 //purpose  : 
 //=======================================================================
-SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4)
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
+{
+  SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
+  if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
+  return anElem;
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+                                              const SMDS_MeshNode * n2,
+                                              const SMDS_MeshNode * n3,
+                                              const SMDS_MeshNode * n4, 
+                                              int ID)
 {
-       SMDS_MeshVolume *f = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
-       if(f!=NULL)
-               myScript->AddVolume(f->GetID(), n1->GetID(), n2->GetID(), n3->GetID(),
-                       n4->GetID());
-       return f;
+  return AddVolumeWithID(n1->GetID(), 
+                        n2->GetID(), 
+                        n3->GetID(),
+                        n4->GetID(),
+                        ID);
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
+                                        const SMDS_MeshNode * n2,
+                                        const SMDS_MeshNode * n3,
+                                        const SMDS_MeshNode * n4)
+{
+  SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
+  if(anElem) myScript->AddVolume(anElem->GetID(), 
+                                n1->GetID(), 
+                                n2->GetID(), 
+                                n3->GetID(),
+                                n4->GetID());
+  return anElem;
 }
 
 //=======================================================================
 //function :AddVolume
 //purpose  : 
 //=======================================================================
-SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5)
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
+{
+  SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
+  if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
+  return anElem;
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+                                              const SMDS_MeshNode * n2,
+                                              const SMDS_MeshNode * n3,
+                                              const SMDS_MeshNode * n4,
+                                              const SMDS_MeshNode * n5, 
+                                              int ID)
+{
+  return AddVolumeWithID(n1->GetID(), 
+                        n2->GetID(), 
+                        n3->GetID(),
+                        n4->GetID(), 
+                        n5->GetID(),
+                        ID);
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
+                                        const SMDS_MeshNode * n2,
+                                        const SMDS_MeshNode * n3,
+                                        const SMDS_MeshNode * n4,
+                                        const SMDS_MeshNode * n5)
 {
-       SMDS_MeshVolume *v = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
-       if(v!=NULL)
-               myScript->AddVolume(v->GetID(), n1->GetID(), n2->GetID(), n3->GetID(),
-                       n4->GetID(), n5->GetID());
-       return v;
+  SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
+  if(anElem) myScript->AddVolume(anElem->GetID(), 
+                                n1->GetID(), 
+                                n2->GetID(), 
+                                n3->GetID(),
+                                n4->GetID(), 
+                                n5->GetID());
+  return anElem;
 }
 
 //=======================================================================
 //function :AddVolume
 //purpose  : 
 //=======================================================================
-SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5,
-               const SMDS_MeshNode * n6)
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
+{
+  SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
+  if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
+  return anElem;
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+                                              const SMDS_MeshNode * n2,
+                                              const SMDS_MeshNode * n3,
+                                              const SMDS_MeshNode * n4,
+                                              const SMDS_MeshNode * n5,
+                                              const SMDS_MeshNode * n6, 
+                                              int ID)
+{
+  return AddVolumeWithID(n1->GetID(), 
+                        n2->GetID(), 
+                        n3->GetID(),
+                        n4->GetID(), 
+                        n5->GetID(), 
+                        n6->GetID(),
+                        ID);
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
+                                        const SMDS_MeshNode * n2,
+                                        const SMDS_MeshNode * n3,
+                                        const SMDS_MeshNode * n4,
+                                        const SMDS_MeshNode * n5,
+                                        const SMDS_MeshNode * n6)
 {
-       SMDS_MeshVolume *v= SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
-       if(v!=NULL) 
-               myScript->AddVolume(v->GetID(), n1->GetID(), n2->GetID(), n3->GetID(),
-                       n4->GetID(), n5->GetID(), n6->GetID());
-       return v;
+  SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
+  if(anElem) myScript->AddVolume(anElem->GetID(), 
+                                n1->GetID(), 
+                                n2->GetID(), 
+                                n3->GetID(),
+                                n4->GetID(), 
+                                n5->GetID(), 
+                                n6->GetID());
+  return anElem;
 }
 
 //=======================================================================
 //function :AddVolume
 //purpose  : 
 //=======================================================================
-SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5,
-               const SMDS_MeshNode * n6,
-               const SMDS_MeshNode * n7,
-               const SMDS_MeshNode * n8)
-{
-       SMDS_MeshVolume *v=
-               SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
-       if(v!=NULL)
-               myScript->AddVolume(v->GetID(), n1->GetID(), n2->GetID(), n3->GetID(),
-                       n4->GetID(), n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID());
-       return v;
-}
-
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
+{
+  SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
+  if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
+  return anElem;
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+                                              const SMDS_MeshNode * n2,
+                                              const SMDS_MeshNode * n3,
+                                              const SMDS_MeshNode * n4,
+                                              const SMDS_MeshNode * n5,
+                                              const SMDS_MeshNode * n6,
+                                              const SMDS_MeshNode * n7,
+                                              const SMDS_MeshNode * n8, 
+                                              int ID)
+{
+  return AddVolumeWithID(n1->GetID(), 
+                        n2->GetID(), 
+                        n3->GetID(),
+                        n4->GetID(), 
+                        n5->GetID(), 
+                        n6->GetID(), 
+                        n7->GetID(), 
+                        n8->GetID(),
+                        ID);
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
+                                        const SMDS_MeshNode * n2,
+                                        const SMDS_MeshNode * n3,
+                                        const SMDS_MeshNode * n4,
+                                        const SMDS_MeshNode * n5,
+                                        const SMDS_MeshNode * n6,
+                                        const SMDS_MeshNode * n7,
+                                        const SMDS_MeshNode * n8)
+{
+  SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
+  if(anElem) myScript->AddVolume(anElem->GetID(), 
+                                n1->GetID(), 
+                                n2->GetID(), 
+                                n3->GetID(),
+                                n4->GetID(), 
+                                n5->GetID(), 
+                                n6->GetID(), 
+                                n7->GetID(), 
+                                n8->GetID());
+  return anElem;
+}
+//=======================================================================
+//function : removeFromSubMeshes
+//purpose  : 
+//=======================================================================
+
+static void removeFromSubMeshes (map<int,SMESHDS_SubMesh*> &      theSubMeshes,
+                                 list<const SMDS_MeshElement *> & theElems,
+                                 const bool                       isNode)
+{
+  if ( theElems.empty() )
+    return;
+    
+  map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
+  for ( ; SubIt != theSubMeshes.end(); SubIt++ )
+  {
+    list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
+    while ( elIt != theElems.end() )
+    {
+      bool removed = false;
+      if ( isNode )
+        removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt) );
+      else
+        removed = (*SubIt).second->RemoveElement( *elIt );
+
+      if (removed)
+      {
+        elIt = theElems.erase( elIt );
+        if ( theElems.empty() )
+          return; // all elements are found and removed
+      }
+      else
+      {
+        elIt++ ;
+      }
+    }
+  }
+}
+  
 //=======================================================================
 //function : RemoveNode
 //purpose  : 
 //=======================================================================
 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
 {
-       SMDS_Mesh::RemoveNode(n);
-       myScript->RemoveNode(n->GetID());
+  myScript->RemoveNode(n->GetID());
+  
+  list<const SMDS_MeshElement *> removedElems;
+  list<const SMDS_MeshElement *> removedNodes;
+
+  SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
+
+  removeFromSubMeshes( myShapeIndexToSubMesh, removedElems, false );
+  removeFromSubMeshes( myShapeIndexToSubMesh, removedNodes, true );
 }
 
 //=======================================================================
@@ -252,8 +465,20 @@ void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
 //========================================================================
 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
 {
-       SMDS_Mesh::RemoveElement(elt);
-       myScript->RemoveElement(elt->GetID());
+  if (elt->GetType() == SMDSAbs_Node)
+  {
+    RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
+    return;
+  }
+
+  myScript->RemoveElement(elt->GetID());
+
+  list<const SMDS_MeshElement *> removedElems;
+  list<const SMDS_MeshElement *> removedNodes;
+
+  SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
+  
+  removeFromSubMeshes( myShapeIndexToSubMesh, removedElems, false );
 }
 
 //=======================================================================
@@ -291,7 +516,7 @@ void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
        int Index = myIndexToShape.FindIndex(S);
 
        //Set Position on Node
-       aNode->SetPosition(new SMDS_FacePosition(Index, 0., 0.));
+       aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, 0., 0.)));
 
        //Update or build submesh
        map<int,SMESHDS_SubMesh*>::iterator it=myShapeIndexToSubMesh.find(Index);
@@ -313,7 +538,7 @@ void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
        int Index = myIndexToShape.FindIndex(S);
 
        //Set Position on Node
-       aNode->SetPosition(new SMDS_EdgePosition(Index, 0.));
+       aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, 0.)));
 
        //Update or build submesh
        map<int,SMESHDS_SubMesh*>::iterator it=myShapeIndexToSubMesh.find(Index);
@@ -335,7 +560,7 @@ void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
        int Index = myIndexToShape.FindIndex(S);
 
        //Set Position on Node
-       aNode->SetPosition(new SMDS_VertexPosition(Index));
+       aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
 
        //Update or build submesh
        map<int,SMESHDS_SubMesh*>::iterator it=myShapeIndexToSubMesh.find(Index);
@@ -402,13 +627,40 @@ TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
 ///////////////////////////////////////////////////////////////////////////////
 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S)
 {
-       if (myShape.IsNull()) MESSAGE("myShape is NULL");
+  if (myShape.IsNull()) MESSAGE("myShape is NULL");
 
-       int Index = myIndexToShape.FindIndex(S);
-       if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end())
-               return myShapeIndexToSubMesh[Index];
-       else
-               return NULL;
+  int Index = myIndexToShape.FindIndex(S);
+  if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end())
+    return myShapeIndexToSubMesh[Index];
+  else
+    return NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Return the sub mesh by Id of shape it is linked to
+///////////////////////////////////////////////////////////////////////////////
+SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
+{
+  if (myShape.IsNull()) MESSAGE("myShape is NULL");
+
+  if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end())
+    return myShapeIndexToSubMesh[Index];
+  else
+    return NULL;
+}
+
+//=======================================================================
+//function : SubMeshIndices
+//purpose  : 
+//=======================================================================
+list<int> SMESHDS_Mesh::SubMeshIndices()
+{
+  list<int> anIndices;
+  std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
+  for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
+    anIndices.push_back((*anIter).first);
+  }
+  return anIndices;
 }
 
 //=======================================================================
@@ -520,7 +772,7 @@ void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index)
 {
        //Set Position on Node
-       aNode->SetPosition(new SMDS_FacePosition(Index, 0., 0.));
+       aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, 0., 0.)));
 
        //Update or build submesh
        if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
@@ -536,7 +788,7 @@ void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index)
 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode, int Index)
 {
        //Set Position on Node
-       aNode->SetPosition(new SMDS_EdgePosition(Index, 0.));
+       aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, 0.)));
 
        //Update or build submesh
        if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
@@ -552,7 +804,7 @@ void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode, int Index)
 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
 {
        //Set Position on Node
-       aNode->SetPosition(new SMDS_VertexPosition(Index));
+       aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
 
        //Update or build submesh
        if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
index 6159a4fca69bb143cdc7bd1520d4894cee54436b..7d26b22664c44455178b6ee84e7b2bdc450cc685 100644 (file)
        #include <hash_map.h>
 #else
        #include <ext/hash_map>
-       using namespace __gnu_cxx;
+       namespace gstd = __gnu_cxx;
 #endif
 #endif
 
-using namespace std;
-
-class SMESHDS_Mesh:public SMDS_Mesh
-{
-
-  public:
-
-       SMESHDS_Mesh(int MeshID);
-       void ShapeToMesh(const TopoDS_Shape & S);
-       bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H);
-       bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H);
-       SMDS_MeshNode * AddNode(double x, double y, double z);
-       void RemoveNode(const SMDS_MeshNode *);
-       void MoveNode(const SMDS_MeshNode *, double x, double y, double z);
-       SMDS_MeshEdge* AddEdge(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2);
-       SMDS_MeshFace* AddFace(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3);
-       SMDS_MeshFace* AddFace(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4);
-       SMDS_MeshVolume* AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4);
-       SMDS_MeshVolume* AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5);
-       SMDS_MeshVolume* AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5,
-               const SMDS_MeshNode * n6);
-       SMDS_MeshVolume* AddVolume(
-               const SMDS_MeshNode * n1,
-               const SMDS_MeshNode * n2,
-               const SMDS_MeshNode * n3,
-               const SMDS_MeshNode * n4,
-               const SMDS_MeshNode * n5,
-               const SMDS_MeshNode * n6,
-               const SMDS_MeshNode * n7,
-               const SMDS_MeshNode * n8);
-       
-       void RemoveElement(const SMDS_MeshElement *);
-       void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S);
-       void SetNodeOnFace(SMDS_MeshNode * aNode, const TopoDS_Face & S);
-       void SetNodeOnEdge(SMDS_MeshNode * aNode, const TopoDS_Edge & S);
-       void SetNodeOnVertex(SMDS_MeshNode * aNode, const TopoDS_Vertex & S);
-       void UnSetNodeOnShape(const SMDS_MeshNode * aNode);
-       void SetMeshElementOnShape(const SMDS_MeshElement * anElt,
-               const TopoDS_Shape & S);
-       void UnSetMeshElementOnShape(const SMDS_MeshElement * anElt,
-               const TopoDS_Shape & S);
-       TopoDS_Shape ShapeToMesh() const;
-       bool HasMeshElements(const TopoDS_Shape & S);
-       SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S);
-       bool HasHypothesis(const TopoDS_Shape & S);
-       const list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
-       SMESHDS_Script * GetScript();
-       void ClearScript();
-       int ShapeToIndex(const TopoDS_Shape & aShape);
-       TopoDS_Shape IndexToShape(int ShapeIndex);
-       void NewSubMesh(int Index);
-       void SetNodeInVolume(const SMDS_MeshNode * aNode, int Index);
-       void SetNodeOnFace(SMDS_MeshNode * aNode, int Index);
-       void SetNodeOnEdge(SMDS_MeshNode * aNode, int Index);
-       void SetNodeOnVertex(SMDS_MeshNode * aNode, int Index);
-       void SetMeshElementOnShape(const SMDS_MeshElement * anElt, int Index);
-        ~SMESHDS_Mesh();
-
-  private:
-       struct HashTopoDS_Shape
-    {
-               size_t operator()(const TopoDS_Shape& S) const {return S.HashCode(2147483647);}
-    };
-       typedef hash_map<TopoDS_Shape, list<const SMESHDS_Hypothesis*>,HashTopoDS_Shape > ShapeToHypothesis;
-       int myMeshID;
-       TopoDS_Shape myShape;
-       TopTools_IndexedMapOfShape myIndexToShape;
-       map<int,SMESHDS_SubMesh*> myShapeIndexToSubMesh;
-       ShapeToHypothesis myShapeToHypothesis;
-       SMESHDS_Script * myScript;
+class SMESHDS_Mesh:public SMDS_Mesh{
+public:
+  SMESHDS_Mesh(int MeshID);
+  void ShapeToMesh(const TopoDS_Shape & S);
+  bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H);
+  bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H);
+  
+  virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
+  virtual SMDS_MeshNode * AddNode(double x, double y, double z);
+  
+  virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
+  virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
+                                      const SMDS_MeshNode * n2, 
+                                      int ID);
+  virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
+                                const SMDS_MeshNode * n2);
+  
+  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
+  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
+                                      const SMDS_MeshNode * n2,
+                                      const SMDS_MeshNode * n3, 
+                                      int ID);
+  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
+                                const SMDS_MeshNode * n2,
+                                const SMDS_MeshNode * n3);
+
+  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4, int ID);
+  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
+                                      const SMDS_MeshNode * n2,
+                                      const SMDS_MeshNode * n3,
+                                      const SMDS_MeshNode * n4, 
+                                      int ID);
+  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
+                                const SMDS_MeshNode * n2,
+                                const SMDS_MeshNode * n3,
+                                const SMDS_MeshNode * n4);
+
+  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID);
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2,
+                                          const SMDS_MeshNode * n3,
+                                          const SMDS_MeshNode * n4, 
+                                          int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
+                                    const SMDS_MeshNode * n2,
+                                    const SMDS_MeshNode * n3,
+                                    const SMDS_MeshNode * n4);
+
+  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID);
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2,
+                                          const SMDS_MeshNode * n3,
+                                          const SMDS_MeshNode * n4,
+                                          const SMDS_MeshNode * n5, 
+                                          int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
+                                    const SMDS_MeshNode * n2,
+                                    const SMDS_MeshNode * n3,
+                                    const SMDS_MeshNode * n4,
+                                    const SMDS_MeshNode * n5);
+
+  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID);
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2,
+                                          const SMDS_MeshNode * n3,
+                                          const SMDS_MeshNode * n4,
+                                          const SMDS_MeshNode * n5,
+                                          const SMDS_MeshNode * n6, 
+                                          int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
+                                    const SMDS_MeshNode * n2,
+                                    const SMDS_MeshNode * n3,
+                                    const SMDS_MeshNode * n4,
+                                    const SMDS_MeshNode * n5,
+                                    const SMDS_MeshNode * n6);
+
+  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID);
+  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
+                                          const SMDS_MeshNode * n2,
+                                          const SMDS_MeshNode * n3,
+                                          const SMDS_MeshNode * n4,
+                                          const SMDS_MeshNode * n5,
+                                          const SMDS_MeshNode * n6,
+                                          const SMDS_MeshNode * n7,
+                                          const SMDS_MeshNode * n8, 
+                                          int ID);
+  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
+                                    const SMDS_MeshNode * n2,
+                                    const SMDS_MeshNode * n3,
+                                    const SMDS_MeshNode * n4,
+                                    const SMDS_MeshNode * n5,
+                                    const SMDS_MeshNode * n6,
+                                    const SMDS_MeshNode * n7,
+                                    const SMDS_MeshNode * n8);
+  
+  void MoveNode(const SMDS_MeshNode *, double x, double y, double z);
+  virtual void RemoveNode(const SMDS_MeshNode *);
+  void RemoveElement(const SMDS_MeshElement *);
+
+  void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S);
+  void SetNodeOnFace(SMDS_MeshNode * aNode, const TopoDS_Face & S);
+  void SetNodeOnEdge(SMDS_MeshNode * aNode, const TopoDS_Edge & S);
+  void SetNodeOnVertex(SMDS_MeshNode * aNode, const TopoDS_Vertex & S);
+  void UnSetNodeOnShape(const SMDS_MeshNode * aNode);
+  void SetMeshElementOnShape(const SMDS_MeshElement * anElt,
+                            const TopoDS_Shape & S);
+  void UnSetMeshElementOnShape(const SMDS_MeshElement * anElt,
+                              const TopoDS_Shape & S);
+  TopoDS_Shape ShapeToMesh() const;
+  bool HasMeshElements(const TopoDS_Shape & S);
+  SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S);
+  SMESHDS_SubMesh * MeshElements(const int Index);
+  list<int> SubMeshIndices();
+  const std::map<int,SMESHDS_SubMesh*>& SubMeshes()
+  { return myShapeIndexToSubMesh; }
+
+  bool HasHypothesis(const TopoDS_Shape & S);
+  const list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
+  SMESHDS_Script * GetScript();
+  void ClearScript();
+  int ShapeToIndex(const TopoDS_Shape & aShape);
+  TopoDS_Shape IndexToShape(int ShapeIndex);
+
+  void NewSubMesh(int Index);
+  void SetNodeInVolume(const SMDS_MeshNode * aNode, int Index);
+  void SetNodeOnFace(SMDS_MeshNode * aNode, int Index);
+  void SetNodeOnEdge(SMDS_MeshNode * aNode, int Index);
+  void SetNodeOnVertex(SMDS_MeshNode * aNode, int Index);
+  void SetMeshElementOnShape(const SMDS_MeshElement * anElt, int Index);
+
+  ~SMESHDS_Mesh();
+  
+private:
+  struct HashTopoDS_Shape{
+    size_t operator()(const TopoDS_Shape& S) const {
+      return S.HashCode(2147483647);
+    }
+  };
+  typedef std::list<const SMESHDS_Hypothesis*> THypList;
+  typedef gstd::hash_map<TopoDS_Shape,THypList,HashTopoDS_Shape> ShapeToHypothesis;
+  ShapeToHypothesis myShapeToHypothesis;
+
+  int myMeshID;
+  TopoDS_Shape myShape;
+  TopTools_IndexedMapOfShape myIndexToShape;
+  std::map<int,SMESHDS_SubMesh*> myShapeIndexToSubMesh;
+  SMESHDS_Script* myScript;
 };
+
+
 #endif
index 31710630d79ec3e4d2b0fd6a698598e03d43656e..c7ad4c2108231107cbf318c28e282879433f7c03 100644 (file)
@@ -42,9 +42,12 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
 //function : RemoveElement
 //purpose  : 
 //=======================================================================
-void SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME)
+bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME)
 {
-       myElements.erase(ME);
+  if ( NbElements() )
+    return myElements.erase(ME);
+  
+  return false;
 }
 
 //=======================================================================
@@ -60,9 +63,12 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
 //function : RemoveNode
 //purpose  : 
 //=======================================================================
-void SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N)
+bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N)
 {
-       myNodes.erase(N);
+  if ( NbNodes() )
+    return myNodes.erase(N);
+
+  return false;
 }
 
 //=======================================================================
@@ -85,8 +91,9 @@ int SMESHDS_SubMesh::NbNodes() const
 
 template<typename T> class MySetIterator:public SMDS_Iterator<const T*>
 {
-       const set<const T*>& mySet;
-       set<const T*>::const_iterator myIt;
+  typedef const set<const T*> TSet;
+  typename TSet::const_iterator myIt;
+  TSet& mySet;
 
   public:
        MySetIterator(const set<const T*>& s):mySet(s), myIt(s.begin())
@@ -108,17 +115,17 @@ template<typename T> class MySetIterator:public SMDS_Iterator<const T*>
 ///Return an iterator on the elements of submesh
 ///The created iterator must be free by the caller
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshElement*> * SMESHDS_SubMesh::GetElements() const
+SMDS_ElemIteratorPtr SMESHDS_SubMesh::GetElements() const
 {
-       return new MySetIterator<SMDS_MeshElement>(myElements);
+  return SMDS_ElemIteratorPtr(new MySetIterator<SMDS_MeshElement>(myElements));
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 ///Return an iterator on the nodes of submesh
 ///The created iterator must be free by the caller
 ///////////////////////////////////////////////////////////////////////////////
-SMDS_Iterator<const SMDS_MeshNode*> * SMESHDS_SubMesh::GetNodes() const
+SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes() const
 {
-       return new MySetIterator<SMDS_MeshNode>(myNodes);
+  return SMDS_NodeIteratorPtr(new MySetIterator<SMDS_MeshNode>(myNodes));
 }
 
index bda8f04bb48c4a53e78ec0d0c31a52d8d7472228..be7e7462a4cc67ef4a970fc955b9117be3f99a98 100644 (file)
@@ -36,13 +36,13 @@ class SMESHDS_SubMesh
 {
   public:
        void AddElement(const SMDS_MeshElement * ME);
-       void RemoveElement(const SMDS_MeshElement * ME);
+       bool RemoveElement(const SMDS_MeshElement * ME); // ret true if ME was in
        void AddNode(const SMDS_MeshNode * ME);
-       void RemoveNode(const SMDS_MeshNode * ME);
+       bool RemoveNode(const SMDS_MeshNode * ME); // ret true if ME was in
        int NbElements() const;
-       SMDS_Iterator<const SMDS_MeshElement*> * GetElements() const;
+       SMDS_ElemIteratorPtr GetElements() const;
        int NbNodes() const;
-       SMDS_Iterator<const SMDS_MeshNode*> * GetNodes() const;
+       SMDS_NodeIteratorPtr GetNodes() const;
 
   private:
        const SMDS_Mesh * myMesh;
index 7bf427270e1bb6bfeafcdd1d7c56d08abdf8a388..a3ba79fa06320a7e1ef7a2d5a967057c21cee1dc 100644 (file)
@@ -17,5 +17,6 @@ enum MeshObjectType {
   SUBMESH_EDGE,
   SUBMESH_FACE,
   SUBMESH_SOLID,
-  SUBMESH_COMPOUND
+  SUBMESH_COMPOUND,
+  GROUP
 };
index 3a14178e53c688edff7154bab06f937e2be8034f..6514bfd8002788c23112550cd07c8ee9191e8348 100644 (file)
@@ -29,111 +29,92 @@ Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)&
   if ( !meshFilter->IsOk(anObj) ) 
     return false;
 
+  bool Ok = false;
+
   if ( anObj->hasEntry() ) {
     QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
     SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument();
     SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() );
 
-    bool Ok = false;
+    SALOMEDS::SObject_var objFather = obj->GetFather();
+    SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
+    
+    if ( strlen( obj->GetID() ) <= strlen( objComponent->GetID() ) )
+      return false;
 
     switch ( myKind )
       {
       case HYPOTHESIS:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
          if (( objFather->Tag() == 1 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
            Ok = true;
          break;
        }
       case ALGORITHM:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
          if (( objFather->Tag() == 2 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
            Ok = true;
          break;
        }
       case MESH:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) )
            Ok = true;
          break;
        }
       case SUBMESH:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
-         if (( objFather->Tag() >= 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
+         if (( objFather->Tag() >= 4 && objFather->Tag() < 9 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
            Ok = true;
          break;
        }
       case MESHorSUBMESH:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) )
            Ok = true;
 
-          if (( objFather->Tag() >= 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
+         if (( objFather->Tag() >= 4 && objFather->Tag() < 9 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
            Ok = true;
 
          break;
        }
-      case SUBMESH_VERTEX:
+      case SUBMESH_VERTEX:  // Label "SubMeshes on vertexes"
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() == 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
            Ok = true;
          break;
        }
       case SUBMESH_EDGE:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() == 5 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
            Ok = true;
          break;
        }
       case SUBMESH_FACE:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() == 6 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
            Ok = true;
          break;
        }
       case SUBMESH_SOLID:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() == 7 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
            Ok = true;
          break;
        }
       case SUBMESH_COMPOUND:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() == 8 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
            Ok = true;
          break;
        }
+      case GROUP:
+       {
+         if (( objFather->Tag() >= 9 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
+           Ok = true;
+         break;
+       }
       }
-
-    if ( Ok )
-      return true;
   }
-  return false;
+  return Ok;
 }
index 660789e06801ff16c85a25284911f2e33cd98d93..a183879daa7c118aadf450b490a10cc8a52216b6 100644 (file)
 top_srcdir=@top_srcdir@
 top_builddir=../..
 srcdir=@srcdir@
-VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
+VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl
 
 
 @COMMENCE@
 
 # header files 
 EXPORT_HEADERS= SMESHGUI_Swig.hxx \
-               SMESHGUI_Swig.i
+               SMESHGUI_Swig.i \
+               SMESHGUI.h \
+               SMESHGUI_Hypotheses.h \
+               SMESHGUI_SpinBox.h \
+               SMESHGUI_StudyAPI.h
 
 # .po files to transform in .qm
 PO_FILES = \
@@ -53,28 +57,28 @@ LIB_SRC =   SMESHGUI.cxx \
                SMESHGUI_AddAlgorithmDlg.cxx \
                SMESHGUI_InitMeshDlg.cxx \
                SMESHGUI_AddSubMeshDlg.cxx \
-               SMESHGUI_LocalLengthDlg.cxx \
-               SMESHGUI_NbSegmentsDlg.cxx \
                SMESHGUI_TransparencyDlg.cxx \
+               SMESHGUI_GroupDlg.cxx \
                SMESHGUI_RemoveNodesDlg.cxx \
                SMESHGUI_RemoveElementsDlg.cxx \
                SMESHGUI_MeshInfosDlg.cxx \
                SMESHGUI_Preferences_ColorDlg.cxx \
-               SMESHGUI_MaxElementAreaDlg.cxx \
                SMESHGUI_Preferences_ScalarBarDlg.cxx \
-               SMESHGUI_EditScalarBarDlg.cxx \
+               SMESHGUI_Preferences_SelectionDlg.cxx \
                SMESHGUI_aParameterDlg.cxx \
-               SMESHGUI_MaxElementVolumeDlg.cxx \
                SMESHGUI_Swig.cxx \
                SMESHGUI_ComputeScalarValue.cxx \
                SMESHGUI_MoveNodesDlg.cxx \
                SMESHGUI_OrientationElementsDlg.cxx \
                SMESHGUI_DiagonalInversionDlg.cxx \
-               SMESHGUI_EdgesConnectivityDlg.cxx \
                SMESHGUI_AddFaceDlg.cxx \
                SMESHGUI_AddVolumeDlg.cxx \
                SMESHGUI_AddEdgeDlg.cxx \
-               SMESHGUI_EditHypothesesDlg.cxx
+               SMESHGUI_EditHypothesesDlg.cxx \
+               SMESHGUI_CreateHypothesesDlg.cxx \
+               SMESHGUI_XmlHandler.cxx \
+               SMESHGUI_Filter.cxx \
+               SMESHGUI_FilterDlg.cxx
 
 LIB_MOC = \
                SMESHGUI.h \
@@ -84,26 +88,24 @@ LIB_MOC = \
                SMESHGUI_AddAlgorithmDlg.h \
                SMESHGUI_InitMeshDlg.h \
                SMESHGUI_AddSubMeshDlg.h \
-               SMESHGUI_LocalLengthDlg.h \
-               SMESHGUI_NbSegmentsDlg.h \
                SMESHGUI_TransparencyDlg.h \
+               SMESHGUI_GroupDlg.h \
                SMESHGUI_RemoveNodesDlg.h \
                SMESHGUI_RemoveElementsDlg.h \
                SMESHGUI_MeshInfosDlg.h \
                SMESHGUI_Preferences_ColorDlg.h \
-               SMESHGUI_MaxElementAreaDlg.h \
                SMESHGUI_Preferences_ScalarBarDlg.h \
-               SMESHGUI_EditScalarBarDlg.h \
+               SMESHGUI_Preferences_SelectionDlg.h \
                SMESHGUI_aParameterDlg.h \
-               SMESHGUI_MaxElementVolumeDlg.h \
                SMESHGUI_MoveNodesDlg.h \
                SMESHGUI_OrientationElementsDlg.h \
                SMESHGUI_DiagonalInversionDlg.h \
-               SMESHGUI_EdgesConnectivityDlg.h \
                SMESHGUI_AddEdgeDlg.h \
                SMESHGUI_AddVolumeDlg.h \
                SMESHGUI_AddFaceDlg.h \
-               SMESHGUI_EditHypothesesDlg.h
+               SMESHGUI_EditHypothesesDlg.h \
+               SMESHGUI_CreateHypothesesDlg.h \
+               SMESHGUI_FilterDlg.h
 
 LIB_CLIENT_IDL = SALOME_Exception.idl \
                 GEOM_Gen.idl \
@@ -111,21 +113,25 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \
                 SMESH_Gen.idl \
                 SMESH_Mesh.idl \
                 SMESH_Hypothesis.idl \
-                SMESH_BasicHypothesis.idl \
+                SMESH_Group.idl \
                 SALOMEDS.idl \
                 SALOMEDS_Attributes.idl \
                 SALOME_ModuleCatalog.idl \
                 SALOME_Component.idl \
-                MED.idl
+                MED.idl \
+                SMESH_Filter.idl \
+                SALOME_GenericObj.idl
 
 LIB_SERVER_IDL = 
 
 # additionnal information to compil and link file
 
-CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome
+CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \
+            $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \
+            $(BOOST_CPPFLAGS)
 CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome
 #$(OCC_CXXFLAGS)
 
-LDFLAGS += -lOCCViewer -lVTKViewer -lSalomeObject -lSalomeGUI -lSMESHObject -lSMDS -lSMESHDS -lSMESHFiltersSelection -lGEOMClient -lMeshDriverDAT -lMeshDriverMED -lMeshDriverUNV $(OCC_KERNEL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome
+LDFLAGS += -lOCCViewer -lVTKViewer -lSalomeObject -lSalomeGUI -lSMESHObject -lSMDS -lSMESHDS -lSMESHFiltersSelection -lGEOMClient -lMeshDriverDAT -lMeshDriverMED -lMeshDriverUNV $(OCC_KERNEL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeGenericObj
 
 @CONCLUDE@
index 5f56add8f6b6f36327723b5e0dcd1a479b0c7679..089f08e06b758c0fb8fd079ce718323c87a7da7c 100644 (file)
 //  License along with this library; if not, write to the Free Software 
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 // 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
 //
 //  File   : SMESHGUI.cxx
 //  Author : Nicolas REJNERI
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 #include "SMESHGUI.h"
 #include "SMESHGUI_AddHypothesisDlg.h"
 #include "SMESHGUI_AddAlgorithmDlg.h"
 #include "SMESHGUI_InitMeshDlg.h"
-#include "SMESHGUI_LocalLengthDlg.h"
-#include "SMESHGUI_NbSegmentsDlg.h"
 #include "SMESHGUI_AddSubMeshDlg.h"
 #include "SMESHGUI_NodesDlg.h"
 #include "SMESHGUI_TransparencyDlg.h"
+#include "SMESHGUI_GroupDlg.h"
 #include "SMESHGUI_RemoveNodesDlg.h"
 #include "SMESHGUI_RemoveElementsDlg.h"
 #include "SMESHGUI_MeshInfosDlg.h"
 #include "SMESHGUI_Preferences_ColorDlg.h"
-#include "SMESHGUI_MaxElementAreaDlg.h"
-#include "SMESHGUI_MaxElementVolumeDlg.h"
 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
-#include "SMESHGUI_EditScalarBarDlg.h"
+#include "SMESHGUI_Preferences_SelectionDlg.h"
 #include "SMESHGUI_aParameterDlg.h"
 #include "SMESHGUI_ComputeScalarValue.h"
 #include "SMESHGUI_MoveNodesDlg.h"
 #include "SMESHGUI_OrientationElementsDlg.h"
 #include "SMESHGUI_DiagonalInversionDlg.h"
-#include "SMESHGUI_EdgesConnectivityDlg.h"
 #include "SMESHGUI_AddFaceDlg.h"
 #include "SMESHGUI_AddEdgeDlg.h"
 #include "SMESHGUI_AddVolumeDlg.h"
 #include "SMESHGUI_EditHypothesesDlg.h"
+#include "SMESHGUI_CreateHypothesesDlg.h"
+#include "SMESHGUI_FilterDlg.h"
+#include "SMESHGUI_XmlHandler.h"
 
-#include "SMESH_Grid.h"
+#include "SMESH_Actor.h"
+#include "SMESH_Object.h"
 
 // SALOME Includes
 #include "Utils_ORB_INIT.hxx"
@@ -69,23 +66,27 @@ using namespace std;
 #include "QAD_MessageBox.h"
 #include "QAD_Resource.h"
 #include "QAD_FileDlg.h"
-#include "SALOMEGUI_Desktop.h"
-#include "SALOMEGUI_NameDlg.h"
+#include "QAD_Desktop.h"
+#include "QAD_ResourceMgr.h"
+#include "QAD_WaitCursor.h"
 
 #include "OCCViewer_ViewPort.h"
 #include "OCCViewer_ViewPort3d.h"
 #include "OCCViewer_Viewer3d.h"
 
-#include "GEOM_Client.hxx"
 #include "GEOM_InteractiveObject.hxx"
 
 #include "SALOME_NamingService.hxx"
 #include "SALOME_ListIteratorOfListIO.hxx"
 #include "SALOME_InteractiveObject.hxx"
 
+#include "SALOMEGUI_Desktop.h"
+#include "SALOMEGUI_NameDlg.h"
 #include "SALOMEGUI_ImportOperation.h"
 #include "SALOMEGUI_QtCatchCorbaException.hxx"
+
 #include "utilities.h"
+#include <dlfcn.h>
 
 #include "SMDS_Mesh.hxx"
 #include "SMESHDS_Document.hxx"
@@ -118,7 +119,6 @@ using namespace std;
 #include <qstring.h>
 #include <qcheckbox.h>
 #include <qcolordialog.h>
-#include <qmessagebox.h>
 #include <qspinbox.h>
 #include <qlist.h>
 #include <qwidget.h>
@@ -128,18 +128,367 @@ using namespace std;
 // VTK Includes
 #include "VTKViewer_Common.h"
 #include "VTKViewer_ViewFrame.h"
+#include "VTKViewer_InteractorStyleSALOME.h"
+
+#include <vtkScalarBarActor.h>
 #include <vtkLegendBoxActor.h>
 #include <vtkFeatureEdges.h>
 #include <vtkDoubleArray.h>
+#include <vtkTextProperty.h>
 
 // Open CASCADE Includes
 #include <gp_Pnt.hxx>
 #include <gp_Vec.hxx>
 
-static GEOM_Client ShapeReader;
+#include <boost/shared_ptr.hpp>
+
 static SMESHGUI *smeshGUI = 0;
 static CORBA::ORB_var _orb;
 
+using namespace std;
+
+typedef pair<int,string> TKeyOfVisualObj;
+typedef boost::shared_ptr<SMESH_VisualObj> TVisualObjPtr;
+typedef map<TKeyOfVisualObj,TVisualObjPtr> TVisualObjCont;
+static TVisualObjCont VISUALOBJCONT;
+
+
+TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry){
+  TVisualObjPtr aVisualObj;
+  try{
+    TVisualObjCont::key_type aKey(theStudyId,theEntry);
+    TVisualObjCont::iterator anIter = VISUALOBJCONT.find(aKey);
+    if(anIter != VISUALOBJCONT.end()){
+      aVisualObj = anIter->second;
+    }else{
+      SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
+      SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theEntry);
+      if(!CORBA::is_nil(aSObj)){
+       SALOMEDS::GenericAttribute_var anAttr;
+       if(aSObj->FindAttribute(anAttr,"AttributeIOR")){
+         SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+         CORBA::String_var aVal = anIOR->Value();
+         CORBA::Object_var anObj =_orb->string_to_object(aVal.in());
+         if(!CORBA::is_nil(anObj)){
+           //Try narrow to SMESH_Mesh interafce
+           SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj);
+           if(!aMesh->_is_nil()){
+             aVisualObj.reset(new SMESH_MeshObj(aMesh));
+             aVisualObj->Update();
+             TVisualObjCont::value_type aValue(aKey,aVisualObj); 
+             VISUALOBJCONT.insert(aValue);
+             return aVisualObj;
+           }
+           //Try narrow to SMESH_Group interafce
+           SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow(anObj);
+           if(!aGroup->_is_nil()){
+             SALOMEDS::SObject_var aFatherSObj = aSObj->GetFather();
+             if(aFatherSObj->_is_nil()) return aVisualObj;
+             aFatherSObj = aFatherSObj->GetFather();
+             if(aFatherSObj->_is_nil()) return aVisualObj;
+             CORBA::String_var anEntry = aFatherSObj->GetID();
+             TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in());
+             if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
+               aVisualObj.reset(new SMESH_GroupObj(aGroup,aMeshObj));
+               aVisualObj->Update();
+               TVisualObjCont::value_type aValue(aKey,aVisualObj); 
+               VISUALOBJCONT.insert(aValue);
+               return aVisualObj;
+             }
+           }
+           //Try narrow to SMESH_subMesh interafce
+           SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj);
+           if(!aSubMesh->_is_nil()){
+             SALOMEDS::SObject_var aFatherSObj = aSObj->GetFather();
+             if(aFatherSObj->_is_nil()) return aVisualObj;
+             aFatherSObj = aFatherSObj->GetFather();
+             if(aFatherSObj->_is_nil()) return aVisualObj;
+             CORBA::String_var anEntry = aFatherSObj->GetID();
+             TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in());
+             if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
+               aVisualObj.reset(new SMESH_subMeshObj(aSubMesh,aMeshObj));
+               aVisualObj->Update();
+               TVisualObjCont::value_type aValue(aKey,aVisualObj); 
+               VISUALOBJCONT.insert(aValue);
+               return aVisualObj;
+             }
+           }
+         }
+       }
+      }
+    }
+  }catch(...){
+    INFOS("GetMeshObj - There is no SMESH_Mesh object for the SALOMEDS::Strudy and Entry!!!");
+  }
+  return aVisualObj;
+}
+
+
+VTKViewer_ViewFrame* GetVtkViewFrame(QAD_StudyFrame* theStudyFrame){
+  QAD_ViewFrame* aViewFrame = theStudyFrame->getRightFrame()->getViewFrame();
+  return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
+}
+
+void UpdateSelectionProp() {
+  QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
+  QList<QAD_StudyFrame> aFrameList = aStudy->getStudyFrames();
+
+  QString SCr, SCg, SCb;
+  SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed");
+  SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen");
+  SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue");
+  QColor aHiColor = Qt::white;
+  if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
+    aHiColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
+
+  SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed");
+  SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen");
+  SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue");
+  QColor aSelColor = Qt::yellow;
+  if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
+    aSelColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
+  QString SW = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth");
+  if (SW.isEmpty()) SW = "5";
+
+  SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed");
+  SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen");
+  SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue");
+  QColor aPreColor = Qt::cyan;
+  if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
+    aPreColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
+  QString PW = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth");
+  if (PW.isEmpty()) PW = "5";
+
+  QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol");
+  if (SP1.isEmpty()) SP1 = "0.025";
+  QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol");
+  if (SP2.isEmpty()) SP2 = "0.001";
+
+  for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) {
+    if (aStudyFrame->getTypeView() == VIEW_VTK) {
+      VTKViewer_ViewFrame* aVtkViewFrame = GetVtkViewFrame(aStudyFrame);
+      if (!aVtkViewFrame) continue;
+      // update VTK viewer properties
+      VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor();
+      if (anInteractor) {
+       // mesh element selection
+       anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255., 
+                                      aSelColor.blue()/255., SW.toInt());
+         
+       // tolerances
+       anInteractor->SetSelectionTolerance(SP1.toDouble(), SP2.toDouble());
+         
+       // pre-selection
+       VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
+       if (aStyle) {
+         aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255., 
+                                     aPreColor.blue()/255., PW.toInt());
+       }
+      }
+      // update actors
+      vtkRenderer* aRenderer = aVtkViewFrame->getRenderer();
+      vtkActorCollection *aCollection = aRenderer->GetActors();
+      aCollection->InitTraversal();
+      while(vtkActor *anAct = aCollection->GetNextActor()){
+       if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
+         anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255., 
+                                    aHiColor.blue()/255.);
+         anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255., 
+                                       aPreColor.blue()/255.);
+       }
+      }
+    }
+  }
+}
+
+VTKViewer_ViewFrame* GetCurrentVtkView(){
+  QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
+  QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
+  return GetVtkViewFrame(aStudyFrame);
+}
+
+
+SMESH_Actor* FindActorByEntry(QAD_StudyFrame *theStudyFrame, 
+                             const char* theEntry)
+{
+  if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){
+    vtkRenderer *aRenderer = aViewFrame->getRenderer();
+    vtkActorCollection *aCollection = aRenderer->GetActors();
+    aCollection->InitTraversal();
+    while(vtkActor *anAct = aCollection->GetNextActor()){
+      if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
+       if(anActor->hasIO()){
+         Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
+         if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){
+           return anActor;
+         }
+       }
+      }
+    }
+  }
+  return NULL;
+}
+
+
+SMESH_Actor* FindActorByEntry(const char* theEntry){
+  QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
+  QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
+  return FindActorByEntry(aStudyFrame,theEntry);
+}
+
+
+SMESH_Actor* CreateActor(SALOMEDS::Study_ptr theStudy,
+                        const char* theEntry,
+                        int theIsClear = false)
+{
+  SMESH_Actor *anActor = NULL;
+  CORBA::Long anId = theStudy->StudyId();
+  if(TVisualObjPtr aVisualObj = GetVisualObj(anId,theEntry)){
+    SALOMEDS::SObject_var aSObj = theStudy->FindObjectID(theEntry);
+    if(!aSObj->_is_nil()){
+      SALOMEDS::GenericAttribute_var anAttr;
+      if(aSObj->FindAttribute(anAttr,"AttributeName")){
+       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+       CORBA::String_var aVal = aName->Value();
+       string aNameVal = aVal.in();
+       SMESH::FilterManager_ptr aFilterMgr = smeshGUI->GetFilterMgr();
+       anActor = SMESH_Actor::New(aVisualObj,aFilterMgr,theEntry,aNameVal.c_str(),theIsClear);
+      }
+    }
+  }
+  return anActor;
+}
+
+
+void DisplayActor(QAD_StudyFrame *theStudyFrame, SMESH_Actor* theActor){
+  if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){
+    aViewFrame->AddActor(theActor);
+    aViewFrame->Repaint();
+  }
+}
+
+
+void RemoveActor(QAD_StudyFrame *theStudyFrame, SMESH_Actor* theActor){
+  if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){
+    aViewFrame->RemoveActor(theActor);
+    aViewFrame->Repaint();
+  }
+}
+
+
+void FitAll(){
+  if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){
+    aViewFrame->onViewFitAll();
+    aViewFrame->Repaint();
+  }
+}
+
+vtkRenderer* GetCurrentRenderer(){
+  if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView())
+    return aViewFrame->getRenderer();
+  return NULL;
+}
+
+void RepaintCurrentView(){
+  if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView())
+    aViewFrame->Repaint();
+}
+
+
+enum EDisplaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll};
+void UpdateView(QAD_StudyFrame *theStudyFrame, EDisplaing theAction,
+               const char* theEntry = "")
+{
+  if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){
+    vtkRenderer *aRenderer = aViewFrame->getRenderer();
+    vtkActorCollection *aCollection = aRenderer->GetActors();
+    aCollection->InitTraversal();
+    switch(theAction){
+      case eDisplayAll: {
+       while(vtkActor *anAct = aCollection->GetNextActor()){
+         if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
+           anActor->SetVisibility(true);
+         }
+       }
+       break;
+      }
+      case eDisplayOnly:
+      case eEraseAll: {
+       while(vtkActor *anAct = aCollection->GetNextActor()){
+         if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
+           anActor->SetVisibility(false);
+         }
+       }
+      }
+      default: {
+       if(SMESH_Actor *anActor = FindActorByEntry(theStudyFrame,theEntry)){
+         switch(theAction) {
+           case eDisplay:
+           case eDisplayOnly:
+             anActor->SetVisibility(true);
+             break;
+           case eErase:
+             anActor->SetVisibility(false);
+             break;
+           }
+       } else {
+         switch(theAction){
+           case eDisplay:
+           case eDisplayOnly:{
+             QAD_Study* aStudy = theStudyFrame->getStudy();
+             SALOMEDS::Study_var aDocument = aStudy->getStudyDocument();
+             if(anActor = CreateActor(aDocument,theEntry,true)) {
+               DisplayActor(theStudyFrame,anActor);
+               FitAll();
+             }
+             break;
+           }
+         }
+       }
+      }
+    }
+  }
+}
+
+
+void UpdateView(EDisplaing theAction, const char* theEntry = ""){
+  QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
+  QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
+  UpdateView(aStudyFrame,theAction,theEntry);
+}
+
+static bool IsReferencedObject( SALOMEDS::SObject_ptr SO ) 
+{
+  if ( !SO->_is_nil() ) {
+    SALOMEDS::GenericAttribute_var anAttr;
+    if ( SO->FindAttribute( anAttr, "AttributeTarget" ) ) {
+      SALOMEDS::AttributeTarget_var aTarget = SALOMEDS::AttributeTarget::_narrow( anAttr );
+      SALOMEDS::Study::ListOfSObject_var aList = aTarget->Get();
+      if ( aList->length() > 0 ) {
+       return true;
+      }
+    }
+  }
+  return false;
+}
+
+void SetPointRepresentation(bool theIsVisible){
+  if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){
+    vtkRenderer *aRenderer = aViewFrame->getRenderer();
+    vtkActorCollection *aCollection = aRenderer->GetActors();
+    aCollection->InitTraversal();
+    while(vtkActor *anAct = aCollection->GetNextActor()){
+      if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
+       if(anActor->GetVisibility()){
+         anActor->SetPointRepresentation(theIsVisible);
+       }
+      }
+    }
+    RepaintCurrentView();
+  }
+}
+
+
 //=============================================================================
 /*!
  *
@@ -147,30 +496,30 @@ static CORBA::ORB_var _orb;
 //=============================================================================
 class CustomItem:public QCustomMenuItem
 {
 public:
-       CustomItem(const QString & s, const QFont & f):string(s), font(f)
-       {
-       };
-       ~CustomItem()
-       {
-       }
-
-       void paint(QPainter * p, const QColorGroup & /*cg */ , bool /*act */ ,
-               bool /*enabled */ , int x, int y, int w, int h)
-       {
-               p->setFont(font);
-               p->drawText(x, y, w, h,
-                       AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string);
-       }
-
-       QSize sizeHint()
-       {
-               return QFontMetrics(font).
-                       size(AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string);
-       }
 private:
-       QString string;
-       QFont font;
+ public:
+  CustomItem(const QString & s, const QFont & f):string(s), font(f)
+  {
+  };
+  ~CustomItem()
+  {
+  }
+
+  void paint(QPainter * p, const QColorGroup & /*cg */ , bool /*act */ ,
+             bool /*enabled */ , int x, int y, int w, int h)
+  {
+    p->setFont(font);
+    p->drawText(x, y, w, h,
+                AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string);
+  }
+
+  QSize sizeHint()
+  {
+    return QFontMetrics(font).
+      size(AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string);
+  }
+ private:
+  QString string;
+  QFont font;
 };
 
 //=============================================================================
@@ -197,9 +546,11 @@ SMESHGUI::~SMESHGUI()
  *
  */
 //=============================================================================
-SMESHGUI *SMESHGUI::GetSMESHGUI()
+SMESHGUISMESHGUI::GetSMESHGUI()
 {
-       return smeshGUI;
+  if ( !smeshGUI )
+    GetOrCreateSMESHGUI( QAD_Application::getDesktop() );
+  return smeshGUI;
 }
 
 //=============================================================================
@@ -207,55 +558,60 @@ SMESHGUI *SMESHGUI::GetSMESHGUI()
  *
  */
 //=============================================================================
-SMESHGUI *SMESHGUI::GetOrCreateSMESHGUI(QAD_Desktop * desktop)
+SMESHGUI* SMESHGUI::GetOrCreateSMESHGUI( QAD_Desktop* desktop )
 {
-       if (smeshGUI == 0)
-       {
-               setOrb();
-               smeshGUI = new SMESHGUI;
-               smeshGUI->myActiveDialogBox = 0;
-               smeshGUI->myState = -1;
-               smeshGUI->myDesktop = desktop;
-               smeshGUI->myActiveStudy = desktop->getActiveStudy();
-
-               Engines::Component_var comp =
-                       desktop->getEngine("FactoryServer", "SMESH");
-               smeshGUI->myComponentMesh = SMESH::SMESH_Gen::_narrow(comp);
-
-               Engines::Component_var comp1 =
-                       desktop->getEngine("FactoryServer", "GEOM");
-               smeshGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp1);
-
-               /* GetCurrentStudy */
-               smeshGUI->myStudyId = smeshGUI->myActiveStudy->getStudyId();
-
-               smeshGUI->myComponentGeom->GetCurrentStudy(smeshGUI->myStudyId);
-               //    smeshGUI->myComponentGeom->NbLabels();
-
-               smeshGUI->myStudy = smeshGUI->myActiveStudy->getStudyDocument();
-
-               smeshGUI->myStudyAPI =
-                       SMESHGUI_StudyAPI(smeshGUI->myStudy, smeshGUI->myComponentMesh);
-
-               smeshGUI->myDocument = new SMESHDS_Document(1); //NBU
-
-               smeshGUI->mySimulationActors = vtkActorCollection::New();
-               smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
-       }
-       else
-       {
-               /* study may have changed */
-               smeshGUI->myActiveStudy = desktop->getActiveStudy();
-               smeshGUI->myStudyAPI.Update(smeshGUI->myComponentMesh);
-       }
-
-       /* Automatic Update */
-       if (desktop->menuBar()->isItemChecked(1001))
-               smeshGUI->myAutomaticUpdate = true;
-       else
-               smeshGUI->myAutomaticUpdate = false;
-
-       return smeshGUI;
+  if( !smeshGUI ) {
+    setOrb();
+    smeshGUI = new SMESHGUI;
+    smeshGUI->myActiveDialogBox = 0 ;
+    smeshGUI->myState = -1 ;
+    smeshGUI->myDesktop = desktop ; 
+
+    /* get smesh engine */
+    Engines::Component_var comp = desktop->getEngine("FactoryServer", "SMESH");
+    smeshGUI->myComponentMesh = SMESH::SMESH_Gen::_narrow(comp);
+    
+    /* get geom engine */
+    Engines::Component_var comp1 = desktop->getEngine("FactoryServer", "GEOM");    
+    smeshGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp1);
+      
+    /* set current study */
+    smeshGUI->myActiveStudy = desktop->getActiveStudy();
+    smeshGUI->myStudyId     = smeshGUI->myActiveStudy->getStudyId();
+    smeshGUI->myStudy       = smeshGUI->myActiveStudy->getStudyDocument();
+    smeshGUI->myComponentGeom->GetCurrentStudy( smeshGUI->myStudyId );
+    smeshGUI->myComponentMesh->SetCurrentStudy( smeshGUI->myStudy );
+    //    smeshGUI->myComponentGeom->NbLabels();
+    
+    /* create service object */
+    smeshGUI->myStudyAPI = SMESHGUI_StudyAPI(smeshGUI->myStudy, smeshGUI->myComponentMesh);
+
+    smeshGUI->myDocument = new SMESHDS_Document(1);//NBU
+
+    smeshGUI->mySimulationActors = vtkActorCollection::New();
+    smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
+
+    /*filter manager*/
+    smeshGUI->myFilterMgr = smeshGUI->myComponentMesh->CreateFilterManager();
+
+    /* load resources for all available meshers */
+    smeshGUI->InitAvailableHypotheses();
+  } else {
+    /* study may have changed - set current study */
+    smeshGUI->myActiveStudy = desktop->getActiveStudy();
+    smeshGUI->myStudyId     = smeshGUI->myActiveStudy->getStudyId();
+    smeshGUI->myStudy       = smeshGUI->myActiveStudy->getStudyDocument();
+    smeshGUI->myComponentGeom->GetCurrentStudy( smeshGUI->myStudyId );
+    smeshGUI->myComponentMesh->SetCurrentStudy( smeshGUI->myStudy );
+    
+    // Set active study to Study API
+    smeshGUI->myStudyAPI.Update( smeshGUI->myStudy );
+  }
+  
+  /* Automatic Update flag */
+  smeshGUI->myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 );
+
+  return smeshGUI;
 }
 
 //=============================================================================
@@ -265,8 +621,8 @@ SMESHGUI *SMESHGUI::GetOrCreateSMESHGUI(QAD_Desktop * desktop)
 //=============================================================================
 void SMESHGUI::SetState(int aState)
 {
-       this->myState = aState;
-       return;
+  this->myState = aState;
+  return;
 }
 
 //=============================================================================
@@ -276,8 +632,8 @@ void SMESHGUI::SetState(int aState)
 //=============================================================================
 void SMESHGUI::ResetState()
 {
-       this->myState = -1;
-       return;
+  this->myState = -1;
+  return;
 }
 
 //=============================================================================
@@ -287,8 +643,8 @@ void SMESHGUI::ResetState()
 //=============================================================================
 void SMESHGUI::EmitSignalDeactivateDialog()
 {
-       emit this->SignalDeactivateActiveDialog();
-       return;
+  emit this->SignalDeactivateActiveDialog();
+  return;
 }
 
 //=============================================================================
@@ -298,8 +654,8 @@ void SMESHGUI::EmitSignalDeactivateDialog()
 //=============================================================================
 void SMESHGUI::EmitSignalCloseAllDialogs()
 {
-       emit this->SignalCloseAllDialogs();
-       return;
+  emit SignalCloseAllDialogs();
+  return;
 }
 
 //=============================================================================
@@ -309,7 +665,7 @@ void SMESHGUI::EmitSignalCloseAllDialogs()
 //=============================================================================
 QDialog *SMESHGUI::GetActiveDialogBox()
 {
-       return this->myActiveDialogBox;
+  return this->myActiveDialogBox;
 }
 
 //=============================================================================
@@ -319,8 +675,8 @@ QDialog *SMESHGUI::GetActiveDialogBox()
 //=============================================================================
 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
 {
-       this->myActiveDialogBox = (QDialog *) aDlg;
-       return;
+  this->myActiveDialogBox = (QDialog *) aDlg;
+  return;
 }
 
 //=============================================================================
@@ -330,7 +686,7 @@ void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
 //=============================================================================
 QAD_Study *SMESHGUI::GetActiveStudy()
 {
-       return this->myActiveStudy;
+  return this->myActiveStudy;
 }
 
 //=============================================================================
@@ -340,7 +696,7 @@ QAD_Study *SMESHGUI::GetActiveStudy()
 //=============================================================================
 SALOMEDS::Study_ptr SMESHGUI::GetStudy()
 {
-       return SALOMEDS::Study::_narrow(myStudy);
+  return SALOMEDS::Study::_narrow(myStudy);
 }
 
 //=============================================================================
@@ -350,7 +706,7 @@ SALOMEDS::Study_ptr SMESHGUI::GetStudy()
 //=============================================================================
 SMESHGUI_StudyAPI SMESHGUI::GetStudyAPI()
 {
-       return myStudyAPI;
+  return myStudyAPI;
 }
 
 //=============================================================================
@@ -360,7 +716,7 @@ SMESHGUI_StudyAPI SMESHGUI::GetStudyAPI()
 //=============================================================================
 QAD_Desktop *SMESHGUI::GetDesktop()
 {
-       return this->myDesktop;
+  return this->myDesktop;
 }
 
 //=============================================================================
@@ -368,21 +724,23 @@ QAD_Desktop *SMESHGUI::GetDesktop()
  *
  */
 //=============================================================================
-vtkScalarBarActor *SMESHGUI::GetScalarBar()
+void SMESHGUI::activeStudyChanged(QAD_Desktop* parent)
 {
-       vtkRenderer *aRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-       vtkActor2DCollection *actor2DList = aRenderer->GetActors2D();
-       actor2DList->InitTraversal();
-       vtkActor2D *aActor2d = actor2DList->GetNextActor2D();
-       while (aActor2d != NULL)
-       {
-               if (aActor2d->IsA("vtkScalarBarActor"))
-                       return vtkScalarBarActor::SafeDownCast(aActor2d);
-               actor2DList->GetNextActor2D();
-       }
-       return NULL;
+  MESSAGE("SMESHGUI::activeStudyChanged init.");
+  QAD_Study* prevStudy = 0;
+  if ( smeshGUI )
+    prevStudy = smeshGUI->myActiveStudy;
+  /* Create or retrieve an object SMESHGUI */
+  MESSAGE("Active study changed : prev study =" << prevStudy);
+  SMESHGUI::GetOrCreateSMESHGUI( parent );
+  MESSAGE("Active study changed : active study =" << smeshGUI->myActiveStudy);
+  if ( prevStudy != smeshGUI->myActiveStudy ) {
+    smeshGUI->EmitSignalCloseAllDialogs();
+    MESSAGE("Active study changed : SMESHGUI nullified" << endl);
+    //smeshGUI = 0;
+    ::UpdateSelectionProp();
+  }
+  MESSAGE("SMESHGUI::activeStudyChanged done.") return;
 }
 
 //=============================================================================
@@ -390,20 +748,15 @@ vtkScalarBarActor *SMESHGUI::GetScalarBar()
  *
  */
 //=============================================================================
-void SMESHGUI::activeStudyChanged(QAD_Desktop * parent)
+bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
 {
-       MESSAGE("SMESHGUI::activeStudyChanged init.")
-               /* Create or retrieve an object SMESHGUI */
-               SMESHGUI::GetOrCreateSMESHGUI(parent);
-       if (smeshGUI != 0)
-       {
-               smeshGUI->EmitSignalCloseAllDialogs();
-               MESSAGE("Active study changed : SMESHGUI nullified" << endl);
-               smeshGUI = 0;
-       }
-
-       //smeshGUI->SetSettings( parent ); //DCQ : Pb. Multi-Etudes
-       MESSAGE("SMESHGUI::activeStudyChanged done.") return;
+  /* Here the position is on the bottom right corner - 10 */
+  // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
+  aDlg->adjustSize();
+  QAD_Desktop *PP = QAD_Application::getDesktop();
+  x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
+  y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
+  return true;
 }
 
 //=============================================================================
@@ -411,14 +764,39 @@ void SMESHGUI::activeStudyChanged(QAD_Desktop * parent)
  *
  */
 //=============================================================================
-bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
+void SMESHGUI::EraseSimulationActors()
 {
-       /* Here the position is on the bottom right corner - 10 */
-       aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
-       QAD_Desktop *PP = QAD_Application::getDesktop();
-       x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
-       y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
-       return true;
+  if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
+  {                                                    //VTK
+    vtkRenderer *theRenderer =
+      ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
+       getRightFrame()->getViewFrame())->getRenderer();
+    vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
+
+    if (mySimulationActors != NULL)
+    {
+      mySimulationActors->InitTraversal();
+      vtkActor *ac = mySimulationActors->GetNextActor();
+      while (!(ac == NULL))
+      {
+        theRenderer->RemoveActor(ac);
+        ac = mySimulationActors->GetNextActor();
+      }
+      mySimulationActors->RemoveAllItems();
+    }
+    if (mySimulationActors2D != NULL)
+    {
+      mySimulationActors2D->InitTraversal();
+      vtkActor2D *ac = mySimulationActors2D->GetNextActor2D();
+      while (!(ac == NULL))
+      {
+        theRenderer->RemoveActor2D(ac);
+        ac = mySimulationActors2D->GetNextActor2D();
+      }
+      mySimulationActors2D->RemoveAllItems();
+    }
+    SetPointRepresentation(false);
+  }
 }
 
 //=============================================================================
@@ -426,40 +804,23 @@ bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
  *
  */
 //=============================================================================
-void SMESHGUI::EraseSimulationActors()
+SMESH::SMESH_Mesh_ptr SMESHGUI::InitMesh( GEOM::GEOM_Shape_ptr aShape,
+                                         QString              NameMesh )
 {
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
-       {                                                       //VTK
-               vtkRenderer *theRenderer =
-                       ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-                       getRightFrame()->getViewFrame())->getRenderer();
-               vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
-
-               if (mySimulationActors != NULL)
-               {
-
-                       mySimulationActors->InitTraversal();
-                       vtkActor *ac = mySimulationActors->GetNextActor();
-                       while (!(ac == NULL))
-                       {
-                               theRenderer->RemoveActor(ac);
-                               ac = mySimulationActors->GetNextActor();
-                       }
-                       mySimulationActors->RemoveAllItems();
-               }
-               if (mySimulationActors2D != NULL)
-               {
-                       mySimulationActors2D->InitTraversal();
-                       vtkActor2D *ac = mySimulationActors2D->GetNextActor2D();
-                       while (!(ac == NULL))
-                       {
-                               theRenderer->RemoveActor2D(ac);
-                               ac = mySimulationActors2D->GetNextActor2D();
-                       }
-                       mySimulationActors2D->RemoveAllItems();
-               }
-               renWin->Render();
-       }
+  try {
+    if ( !myComponentMesh->_is_nil() && !aShape->_is_nil() ) {
+      SMESH::SMESH_Mesh_var aMesh = myComponentMesh->CreateMesh( aShape );
+      if ( !aMesh->_is_nil() ) {
+       SALOMEDS::SObject_var SM = smeshGUI->myStudy->FindObjectIOR( _orb->object_to_string( aMesh ) );
+       myStudyAPI.SetName( SM, NameMesh );
+       return SMESH::SMESH_Mesh::_narrow(aMesh);
+      }
+    }
+  }
+  catch( const SALOME::SALOME_Exception& S_ex ) {
+    QtCatchCorbaException( S_ex );
+  }
+  return SMESH::SMESH_Mesh::_nil();
 }
 
 //=============================================================================
@@ -467,40 +828,21 @@ void SMESHGUI::EraseSimulationActors()
  *
  */
 //=============================================================================
-SMESH::SMESH_Mesh_ptr SMESHGUI::InitMesh(GEOM::GEOM_Shape_ptr aShape,
-       QString NameMesh)
+SMESH::SMESH_subMesh_ptr SMESHGUI::AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh,
+                                              GEOM::GEOM_Shape_ptr  aShape,
+                                              QString               NameMesh )
 {
-       try
-       {
-               if (!myComponentMesh->_is_nil() && !aShape->_is_nil())
-               {
-                       SMESH::SMESH_Mesh_var aMesh =
-                               myComponentMesh->Init(myComponentGeom, myStudyId, aShape);
-
-                       if (!aMesh->_is_nil())
-                       {
-                               SALOMEDS::SObject_var SM = myStudyAPI.AddNewMesh(aMesh);
-                               myStudyAPI.SetName(SM, NameMesh);
-
-                               // GEOM::GEOM_Shape has non-empty StudyShapeId only after AddInStudy operation,
-                               // not after loading from file, so let's use more reliable way to retrieve SObject
-                               Standard_CString ShapeIOR = _orb->object_to_string(aShape);
-                               SALOMEDS::SObject_var SObject =
-                                       myStudy->FindObjectIOR(ShapeIOR);
-                               if (!SObject->_is_nil() && !SM->_is_nil())
-                               {
-                                       myStudyAPI.SetShape(SM, SObject);
-                               }
-                               return SMESH::SMESH_Mesh::_narrow(aMesh);
-                       }
-               }
-       }
-       catch(const SALOME::SALOME_Exception & S_ex)
-       {
-               QtCatchCorbaException(S_ex);
-       }
-       myActiveStudy->updateObjBrowser(true);
-       return SMESH::SMESH_Mesh::_nil();
+  SMESH::SMESH_subMesh_var aSubMesh;
+  try {
+    if ( !aMesh->_is_nil() && !aShape->_is_nil() )
+      // create sub mesh
+      aSubMesh = SMESH::SMESH_subMesh::_duplicate( aMesh->GetSubMesh( aShape, NameMesh.latin1() ) ); //VSR: published automatically
+  }
+  catch( const SALOME::SALOME_Exception& S_ex ) {
+    QtCatchCorbaException( S_ex );
+    aSubMesh = SMESH::SMESH_subMesh::_nil();
+  }
+  return aSubMesh._retn();
 }
 
 //=============================================================================
@@ -508,40 +850,22 @@ SMESH::SMESH_Mesh_ptr SMESHGUI::InitMesh(GEOM::GEOM_Shape_ptr aShape,
  *
  */
 //=============================================================================
-SMESH::SMESH_subMesh_ptr SMESHGUI::AddSubMesh(SMESH::SMESH_Mesh_ptr aMesh,
-       GEOM::GEOM_Shape_ptr aShape, QString NameMesh)
+SMESH::SMESH_Group_ptr SMESHGUI::AddGroup( SMESH::SMESH_Mesh_ptr    aMesh,
+                                          SMESH::ElementType       aType,
+                                          QString                  aName )
 {
-       try
-       {
-               SMESH::SMESH_subMesh_var aSubMesh = aMesh->GetElementsOnShape(aShape);
-               SALOMEDS::SObject_var SO_Mesh = myStudyAPI.FindMesh(aMesh);
-               Standard_CString ShapeIOR = _orb->object_to_string(aShape);
-               SALOMEDS::SObject_var SO_GeomShape = myStudy->FindObjectIOR(ShapeIOR);
-
-               if (!SO_GeomShape->_is_nil() && !SO_Mesh->_is_nil() &&
-                       !aSubMesh->_is_nil() && !aMesh->_is_nil())
-               {
-                       SALOMEDS::SObject_var SO =
-                               myStudyAPI.AddSubMeshOnShape(SO_Mesh, SO_GeomShape, aSubMesh,
-                               aShape->ShapeType());
-                       myStudyAPI.SetName(SO, NameMesh);
-
-                       SMESH_Actor *amesh = SMESH_Actor::New();
-                       Handle(SALOME_InteractiveObject) IO =
-                               new SALOME_InteractiveObject(SO->GetID(), "MESH",
-                               strdup(NameMesh));
-                       amesh->setIO(IO);
-                       amesh->setName(strdup(NameMesh));
-                       DisplayActor(amesh, false);
-                       return SMESH::SMESH_subMesh::_narrow(aSubMesh);
-               }
-       }
-       catch(const SALOME::SALOME_Exception & S_ex)
-       {
-               QtCatchCorbaException(S_ex);
-       }
-       myActiveStudy->updateObjBrowser(true);
-       return SMESH::SMESH_subMesh::_nil();
+  SMESH::SMESH_Group_var aGroup;
+  try {
+    if ( !aMesh->_is_nil() )
+      // create group
+      aGroup = SMESH::SMESH_Group::_duplicate( aMesh->CreateGroup( aType, strdup(aName) ) ); //VSR: published automatically
+  }
+  catch( const SALOME::SALOME_Exception& S_ex ) {
+    QtCatchCorbaException( S_ex );
+    aGroup = SMESH::SMESH_Group::_nil();
+  }
+  myActiveStudy->updateObjBrowser( true );
+  return aGroup._retn();
 }
 
 //=============================================================================
@@ -549,342 +873,247 @@ SMESH::SMESH_subMesh_ptr SMESHGUI::AddSubMesh(SMESH::SMESH_Mesh_ptr aMesh,
  *
  */
 //=============================================================================
-SMESH::SMESH_Hypothesis_ptr SMESHGUI::CreateHypothesis(QString TypeHypothesis,
-       QString NameHypothesis)
-{
-       SMESH::SMESH_Hypothesis_var Hyp;
-       try
-       {
-               Hyp = myComponentMesh->CreateHypothesis(TypeHypothesis, myStudyId);
-               if (!Hyp->_is_nil())
-               {
-                       SALOMEDS::SObject_var SHyp = myStudyAPI.AddNewHypothesis(Hyp);
-                       myStudyAPI.SetName(SHyp, NameHypothesis);
-               }
-       }
-       catch(const SALOME::SALOME_Exception & S_ex)
-       {
-               QtCatchCorbaException(S_ex);
-       }
 
-       return SMESH::SMESH_Hypothesis::_narrow(Hyp);
+static void addMap( const map<string, HypothesisData*>& theMap,
+                   map<string, HypothesisData*>&       toMap)
+{
+  map<string, HypothesisData*>::const_iterator it;
+  for ( it = theMap.begin(); it != theMap.end(); it++ )
+    toMap.insert( *it );
 }
 
+    
 //=============================================================================
 /*!
- *
+ *  InitAvailableHypotheses (read from resource XML file)
  */
 //=============================================================================
-void SMESHGUI::AddHypothesisOnMesh(SMESH::SMESH_Mesh_ptr aMesh,
-       SMESH::SMESH_Hypothesis_ptr aHyp)
+void SMESHGUI::InitAvailableHypotheses ()
 {
-       if (!aMesh->_is_nil())
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               SALOMEDS::SObject_var SM = myStudyAPI.FindMesh(aMesh);
-               GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh(SM);
-               try
-               {
-                       bool res = aMesh->AddHypothesis(aShape, aHyp);
-                       if (res)
-                       {
-                               SALOMEDS::SObject_var SH =
-                                       myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
-                               if (!SM->_is_nil() && !SH->_is_nil())
-                               {
-                                       myStudyAPI.SetHypothesis(SM, SH);
-                                       myStudyAPI.ModifiedMesh(SM, false);
-                               }
-                               QApplication::restoreOverrideCursor();
-                       }
-                       else
-                       {
-                               QApplication::restoreOverrideCursor();
-                               QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                                       tr("SMESH_WRN_WARNING"),
-                                       tr("SMESH_WRN_HYPOTHESIS_ALREADYEXIST"),
-                                       tr("SMESH_BUT_YES"));
-                       }
-               }
-               catch(const SALOME::SALOME_Exception & S_ex)
-               {
-                       QtCatchCorbaException(S_ex);
-               }
-       }
-       myActiveStudy->updateObjBrowser(true);
-       QApplication::restoreOverrideCursor();
+  QAD_WaitCursor wc;
+  if ((myHypothesesMap.begin() == myHypothesesMap.end()) &&
+      (myAlgorithmsMap.begin() == myAlgorithmsMap.end()))
+  {
+    // Resource manager
+    QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
+    if (!resMgr) return;
+
+    // Find name of a resource XML file ("SMESH_Meshers.xml");
+    QString HypsXml;
+    char* cenv = getenv("SMESH_MeshersList");
+    if (cenv)
+      HypsXml.sprintf("%s", cenv);
+
+    QStringList HypsXmlList = QStringList::split( ":", HypsXml, false );
+    if (HypsXmlList.count() == 0)
+    {
+      QAD_MessageBox::error1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"),
+                             tr("MESHERS_FILE_NO_VARIABLE"),
+                             tr("SMESH_BUT_OK"));
+      return;
+    }
+
+    // loop on files in HypsXml
+    QString aNoAccessFiles;
+    for ( int i = 0; i < HypsXmlList.count(); i++ ) {
+      QString HypsXml = HypsXmlList[ i ];
+
+      // Find full path to the resource XML file
+      QString xmlFile = HypsXml + ".xml";
+      xmlFile = QAD_Tools::addSlash(resMgr->findFile(xmlFile, HypsXml)) + xmlFile;
+
+      QFile file (QAD_Tools::unix2win(xmlFile));
+      if (file.exists() && file.open(IO_ReadOnly))
+      {
+        file.close();
+
+        SMESHGUI_XmlHandler* myXmlHandler = new SMESHGUI_XmlHandler();
+        ASSERT(myXmlHandler);
+
+        QXmlInputSource source (file);
+        QXmlSimpleReader reader;
+        reader.setContentHandler(myXmlHandler);
+        reader.setErrorHandler(myXmlHandler);
+        bool ok = reader.parse(source);
+        file.close();
+        if (ok)
+        {
+          addMap( myXmlHandler->myHypothesesMap, myHypothesesMap );
+          addMap( myXmlHandler->myAlgorithmsMap, myAlgorithmsMap );
+        }
+        else
+        {
+          QAD_MessageBox::error1(myDesktop, 
+                                tr("INF_PARSE_ERROR"),
+                                tr(myXmlHandler->errorProtocol()),
+                                tr("SMESH_BUT_OK"));
+        }
+      }
+      else
+      {
+        if (aNoAccessFiles.isEmpty())
+          aNoAccessFiles = xmlFile;
+        else
+          aNoAccessFiles += ", " + xmlFile;
+      }
+    } // end loop
+
+
+    if (!aNoAccessFiles.isEmpty())
+    {
+      QString aMess = tr("MESHERS_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n";
+      aMess += tr("MESHERS_FILE_CHECK_VARIABLE");
+      wc.stop();
+      QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                            tr("SMESH_WRN_WARNING"),
+                            aMess,
+                            tr("SMESH_BUT_OK"));
+      wc.start();
+    }
+  }
 }
 
 //=============================================================================
 /*!
- *
+ *  GetAvailableHypotheses (read from resource XML file)
  */
 //=============================================================================
-void SMESHGUI::
-RemoveHypothesisOrAlgorithmOnMesh(const Handle(SALOME_InteractiveObject) &
-       IObject)
+QStringList SMESHGUI::GetAvailableHypotheses (const bool isAlgo)
 {
-       if (IObject->hasReference())
-       {
-               SMESH::SMESH_Hypothesis_var anHyp;
-               SALOMEDS::SObject_var SO_Hypothesis =
-                       smeshGUI->myStudy->FindObjectID(IObject->getEntry());
-               SALOMEDS::GenericAttribute_var anAttr;
-               SALOMEDS::AttributeIOR_var anIOR;
-
-               if (!SO_Hypothesis->_is_nil())
-               {
-                       QApplication::setOverrideCursor(Qt::waitCursor);
-                       if (SO_Hypothesis->FindAttribute(anAttr, "AttributeIOR"))
-                       {
-                               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                               anHyp =
-                                       SMESH::SMESH_Hypothesis::_narrow(_orb->
-                                       string_to_object(anIOR->Value()));
-                       }
-
-                       SALOMEDS::SObject_var SO_Applied_Hypothesis =
-                               smeshGUI->myStudy->FindObjectID(IObject->getReference());
-                       if (!SO_Applied_Hypothesis->_is_nil())
-                       {
-                               SALOMEDS::SObject_var MorSM =
-                                       smeshGUI->myStudyAPI.
-                                       GetMeshOrSubmesh(SO_Applied_Hypothesis);
-                               if (!MorSM->_is_nil())
-                               {
-                                       smeshGUI->myStudyAPI.ModifiedMesh(MorSM, false);
-
-                                       GEOM::GEOM_Shape_var aShape =
-                                               smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(MorSM);
-                                       if (!aShape->_is_nil())
-                                       {
-                                               if (MorSM->FindAttribute(anAttr, "AttributeIOR"))
-                                               {
-                                                       anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                                                       SMESH::SMESH_Mesh_var aMesh =
-                                                               SMESH::SMESH_Mesh::_narrow(_orb->
-                                                               string_to_object(anIOR->Value()));
-                                                       SMESH::SMESH_subMesh_var aSubMesh =
-                                                               SMESH::SMESH_subMesh::_narrow(_orb->
-                                                               string_to_object(anIOR->Value()));
-                                                       if (!aMesh->_is_nil())
-                                                       {
-                                                               bool res =
-                                                                       aMesh->RemoveHypothesis(aShape, anHyp);
-                                                               if (!res)
-                                                               {
-                                                                       QApplication::restoreOverrideCursor();
-                                                                       QAD_MessageBox::warn1(QAD_Application::
-                                                                               getDesktop(), tr("SMESH_WRN_WARNING"),
-                                                                               tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
-                                                                               tr("SMESH_BUT_YES"));
-                                                               }
-                                                       }
-                                                       else if (!aSubMesh->_is_nil())
-                                                       {
-                                                               aMesh = aSubMesh->GetFather();
-                                                               if (!aMesh->_is_nil())
-                                                               {
-                                                                       bool res =
-                                                                               aMesh->RemoveHypothesis(aShape, anHyp);
-                                                                       if (!res)
-                                                                       {
-                                                                               QApplication::restoreOverrideCursor();
-                                                                               QAD_MessageBox::warn1(QAD_Application::
-                                                                                       getDesktop(),
-                                                                                       tr("SMESH_WRN_WARNING"),
-                                                                                       tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
-                                                                                       tr("SMESH_BUT_YES"));
-                                                                       }
-                                                               }
-                                                       }
-                                                       if (myAutomaticUpdate)
-                                                       {
-                                                               SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
-                                                               if (Mesh != NULL)
-                                                               {
-#ifdef TRACE
-                                                                       Dump(Mesh);
-#endif
-                                                                       DisplayActor(Mesh);
-                                                                       DisplayEdges(Mesh);
-                                                                       smeshGUI->ChangeRepresentation(Mesh,
-                                                                               Mesh->getDisplayMode());
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                               smeshGUI->myStudyAPI.UnSetHypothesis(SO_Applied_Hypothesis);
-                       }
-               }
-       }
-       else if (IObject->hasEntry())
-       {
-       MESSAGE("IObject entry " << IObject->getEntry())}
-       QApplication::restoreOverrideCursor();
+  QStringList aHypList;
+
+  // Init list of available hypotheses, if needed
+  InitAvailableHypotheses();
+
+  // fill list of hypotheses/algorithms
+  map<string, HypothesisData*>::iterator anIter;
+  if (isAlgo)
+  {
+    anIter = myAlgorithmsMap.begin();
+    for (; anIter != myAlgorithmsMap.end(); anIter++)
+    {
+      aHypList.append(((*anIter).first).c_str());
+    }
+  }
+  else
+  {
+    anIter = myHypothesesMap.begin();
+    for (; anIter != myHypothesesMap.end(); anIter++)
+    {
+      aHypList.append(((*anIter).first).c_str());
+    }
+  }
+
+  return aHypList;
 }
 
 //=============================================================================
 /*!
- *
+ *  GetHypothesisData
  */
 //=============================================================================
-void SMESHGUI::RemoveHypothesisOrAlgorithmOnMesh(SALOMEDS::SObject_ptr MorSM,
-       SMESH::SMESH_Hypothesis_ptr anHyp)
+HypothesisData* SMESHGUI::GetHypothesisData (const char* aHypType)
 {
-       SALOMEDS::SObject_var AHR, aRef;
-       SALOMEDS::GenericAttribute_var anAttr;
-       SALOMEDS::AttributeIOR_var anIOR;
-
-       if (!MorSM->_is_nil())
-       {
-               GEOM::GEOM_Shape_var aShape =
-                       smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(MorSM);
-               if (!aShape->_is_nil())
-               {
-                       if (MorSM->FindAttribute(anAttr, "AttributeIOR"))
-                       {
-                               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                               SMESH::SMESH_Mesh_var aMesh =
-                                       SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->
-                                               Value()));
-                               SMESH::SMESH_subMesh_var aSubMesh =
-                                       SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->
-                                               Value()));
-                               if (!aMesh->_is_nil())
-                               {
-                                       bool res = aMesh->RemoveHypothesis(aShape, anHyp);
-                                       if (!res)
-                                       {
-                                               QApplication::restoreOverrideCursor();
-                                               QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                                                       tr("SMESH_WRN_WARNING"),
-                                                       tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
-                                                       tr("SMESH_BUT_YES"));
-                                       }
-                               }
-                               else if (!aSubMesh->_is_nil())
-                               {
-                                       aMesh = aSubMesh->GetFather();
-                                       if (!aMesh->_is_nil())
-                                       {
-                                               bool res = aMesh->RemoveHypothesis(aShape, anHyp);
-                                               if (!res)
-                                               {
-                                                       QApplication::restoreOverrideCursor();
-                                                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                                                               tr("SMESH_WRN_WARNING"),
-                                                               tr("SMESH_WRN_HYPOTHESIS_NOTEXIST"),
-                                                               tr("SMESH_BUT_YES"));
-                                               }
-                                       }
-                               }
-                               if (myAutomaticUpdate)
-                               {
-                                       SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
-                                       if (Mesh != NULL)
-                                       {
-#ifdef TRACE
-                                               Dump(Mesh);
-#endif
-                                               DisplayActor(Mesh);
-                                               DisplayEdges(Mesh);
-                                               // smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() );
-                                       }
-                               }
-                       }
-               }
-
-               if (MorSM->FindSubObject(2, AHR))
-               {
-                       SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(AHR);
-                       for (; it->More(); it->Next())
-                       {
-                               SALOMEDS::SObject_var Obj = it->Value();
-                               if (Obj->ReferencedObject(aRef))
-                               {
-                                       if (aRef->FindAttribute(anAttr, "AttributeIOR"))
-                                       {
-                                               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                                               if (strcmp(anIOR->Value(),
-                                                               _orb->object_to_string(anHyp)) == 0)
-                                               {
-                                                       smeshGUI->myStudyAPI.UnSetHypothesis(Obj);
-                                                       break;
-                                               }
-                                       }
-                               }
-                       }
-               }
-               if (MorSM->FindSubObject(3, AHR))
-               {
-                       SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(AHR);
-                       for (; it->More(); it->Next())
-                       {
-                               SALOMEDS::SObject_var Obj = it->Value();
-                               if (Obj->ReferencedObject(aRef))
-                               {
-                                       if (aRef->FindAttribute(anAttr, "AttributeIOR"))
-                                       {
-                                               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                                               if (strcmp(anIOR->Value(),
-                                                               _orb->object_to_string(anHyp)) == 0)
-                                               {
-                                                       smeshGUI->myStudyAPI.UnSetAlgorithm(Obj);
-                                                       break;
-                                               }
-                                       }
-                               }
-                       }
-               }
-               smeshGUI->myStudyAPI.ModifiedMesh(MorSM, false);
-       }
-       QApplication::restoreOverrideCursor();
+  HypothesisData* aHypData = 0;
+
+  // Init list of available hypotheses, if needed
+  InitAvailableHypotheses();
+
+  if (myHypothesesMap.find(aHypType) == myHypothesesMap.end())
+  {
+    if (myAlgorithmsMap.find(aHypType) != myAlgorithmsMap.end())
+    {
+      aHypData = myAlgorithmsMap[aHypType];
+    }
+  }
+  else
+  {
+    aHypData = myHypothesesMap[aHypType];
+  }
+  return aHypData;
 }
 
 //=============================================================================
-/*!
- *
+/*! 
+ *  Get a Hypothesis Creator from a Plugin Library
  */
 //=============================================================================
-void SMESHGUI::AddAlgorithmOnMesh(SMESH::SMESH_Mesh_ptr aMesh,
-       SMESH::SMESH_Hypothesis_ptr aHyp)
+SMESHGUI_GenericHypothesisCreator* SMESHGUI::GetHypothesisCreator(const QString& aHypType)
 {
-       if (!aMesh->_is_nil())
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               SALOMEDS::SObject_var SM = myStudyAPI.FindMesh(aMesh);
-               GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh(SM);
-               try
-               {
-                       bool res = aMesh->AddHypothesis(aShape, aHyp);
-                       if (res)
-                       {
-                               SALOMEDS::SObject_var SH =
-                                       myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
-                               if (!SM->_is_nil() && !SH->_is_nil())
-                               {
-                                       myStudyAPI.SetAlgorithms(SM, SH);
-                                       myStudyAPI.ModifiedMesh(SM, false);
-                               }
-                       }
-                       else
-                       {
-                               QApplication::restoreOverrideCursor();
-                               QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                                       tr("SMESH_WRN_WARNING"),
-                                       tr("SMESH_WRN_ALGORITHM_ALREADYEXIST"),
-                                       tr("SMESH_BUT_YES"));
-                       }
-               }
-               catch(const SALOME::SALOME_Exception & S_ex)
-               {
-                       QtCatchCorbaException(S_ex);
-               }
-       }
-       myActiveStudy->updateObjBrowser(true);
-       QApplication::restoreOverrideCursor();
+  char* sHypType = (char*)aHypType.latin1();
+  MESSAGE("Get HypothesisCreator for " << sHypType);
+
+  SMESHGUI_GenericHypothesisCreator* aCreator = 0;
+
+  // check, if creator for this hypothesis type already exists
+  if (myHypCreatorMap.find(sHypType) != myHypCreatorMap.end())
+  {
+    aCreator = myHypCreatorMap[sHypType];
+  }
+  else
+  {
+    // 1. Init list of available hypotheses, if needed
+    InitAvailableHypotheses();
+
+    // 2. Get names of plugin libraries
+    HypothesisData* aHypData = GetHypothesisData(sHypType);
+    if (!aHypData)
+    {
+      return aCreator;
+    }
+    QString aClientLibName = aHypData->ClientLibName;
+    QString aServerLibName = aHypData->ServerLibName;
+
+    // 3. Load Client Plugin Library
+    try
+    {
+      // load plugin library
+      MESSAGE("Loading client meshers plugin library ...");
+      void* libHandle = dlopen (aClientLibName, RTLD_LAZY);
+      if (!libHandle)
+      {
+        // report any error, if occured
+        const char* anError = dlerror();
+        MESSAGE(anError);
+      }
+      else
+      {
+        // get method, returning hypothesis creator
+        MESSAGE("Find GetHypothesisCreator() method ...");
+        typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \
+          (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI);
+        GetHypothesisCreator procHandle =
+          (GetHypothesisCreator)dlsym( libHandle, "GetHypothesisCreator" );
+        if (!procHandle)
+        {
+          MESSAGE("bad hypothesis client plugin library");
+          dlclose(libHandle);
+        }
+        else
+        {
+          // get hypothesis creator
+          MESSAGE("Get Hypothesis Creator for " << aHypType);
+          aCreator = procHandle(aHypType, aServerLibName, smeshGUI);
+          if (!aCreator)
+          {
+            MESSAGE("no such a hypothesis in this plugin");
+          }
+          else
+          {
+            // map hypothesis creator to a hypothesis name
+            myHypCreatorMap[sHypType] = aCreator;
+          }
+        }
+      }
+    }
+    catch (const SALOME::SALOME_Exception& S_ex)
+    {
+      QtCatchCorbaException(S_ex);
+    }
+  }
+
+  return aCreator;
 }
 
 //=============================================================================
@@ -892,48 +1121,39 @@ void SMESHGUI::AddAlgorithmOnMesh(SMESH::SMESH_Mesh_ptr aMesh,
  *
  */
 //=============================================================================
-void SMESHGUI::AddHypothesisOnSubMesh(SMESH::SMESH_subMesh_ptr aSubMesh,
-       SMESH::SMESH_Hypothesis_ptr aHyp)
+SMESH::SMESH_Hypothesis_ptr SMESHGUI::CreateHypothesis (const QString& aHypType,
+                                                       const QString& aHypName,
+                                                        const bool     isAlgo)
 {
-       if (!aSubMesh->_is_nil())
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               try
-               {
-                       SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
-                       SALOMEDS::SObject_var SsubM = myStudyAPI.FindSubMesh(aSubMesh);
-                       GEOM::GEOM_Shape_var aShape =
-                               myStudyAPI.GetShapeOnMeshOrSubMesh(SsubM);
-                       if (!aMesh->_is_nil())
-                       {
-                               bool res = aMesh->AddHypothesis(aShape, aHyp);
-                               if (res)
-                               {
-                                       SALOMEDS::SObject_var SH =
-                                               myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
-                                       if (!SsubM->_is_nil() && !SH->_is_nil())
-                                       {
-                                               myStudyAPI.SetHypothesis(SsubM, SH);
-                                               myStudyAPI.ModifiedMesh(SsubM, false);
-                                       }
-                               }
-                               else
-                               {
-                                       QApplication::restoreOverrideCursor();
-                                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                                               tr("SMESH_WRN_WARNING"),
-                                               tr("SMESH_WRN_HYPOTHESIS_ALREADYEXIST"),
-                                               tr("SMESH_BUT_YES"));
-                               }
-                       }
-               }
-               catch(const SALOME::SALOME_Exception & S_ex)
-               {
-                       QtCatchCorbaException(S_ex);
-               }
-       }
-       myActiveStudy->updateObjBrowser(true);
-       QApplication::restoreOverrideCursor();
+  MESSAGE("Create " << aHypType << " with name " << aHypName);
+
+  SMESH::SMESH_Hypothesis_var Hyp;
+
+  HypothesisData* aHypData = GetHypothesisData((char*)aHypType.latin1());
+  QString aServLib = aHypData->ServerLibName;
+
+  try
+  {
+    Hyp = myComponentMesh->CreateHypothesis(aHypType, aServLib);
+    if (!Hyp->_is_nil())
+    {
+      SALOMEDS::SObject_var SHyp =
+        smeshGUI->myStudy->FindObjectIOR( _orb->object_to_string( Hyp ) );
+      if (!SHyp->_is_nil())
+      {
+       if ( !aHypName.isEmpty() )
+         myStudyAPI.SetName( SHyp, aHypName );
+        myActiveStudy->updateObjBrowser(true);
+       return Hyp._retn();
+      }
+    }
+  }
+  catch (const SALOME::SALOME_Exception & S_ex)
+  {
+    QtCatchCorbaException(S_ex);
+  }
+
+  return SMESH::SMESH_Hypothesis::_nil();
 }
 
 //=============================================================================
@@ -941,48 +1161,48 @@ void SMESHGUI::AddHypothesisOnSubMesh(SMESH::SMESH_subMesh_ptr aSubMesh,
  *
  */
 //=============================================================================
-void SMESHGUI::AddAlgorithmOnSubMesh(SMESH::SMESH_subMesh_ptr aSubMesh,
-       SMESH::SMESH_Hypothesis_ptr aHyp)
+bool SMESHGUI::AddHypothesisOnMesh(SMESH::SMESH_Mesh_ptr aMesh,
+                                  SMESH::SMESH_Hypothesis_ptr aHyp)
 {
-       if (!aSubMesh->_is_nil())
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               try
-               {
-                       SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
-                       SALOMEDS::SObject_var SsubM = myStudyAPI.FindSubMesh(aSubMesh);
-                       GEOM::GEOM_Shape_var aShape =
-                               myStudyAPI.GetShapeOnMeshOrSubMesh(SsubM);
-                       if (!aMesh->_is_nil())
-                       {
-                               bool res = aMesh->AddHypothesis(aShape, aHyp);
-                               if (res)
-                               {
-                                       SALOMEDS::SObject_var SH =
-                                               myStudyAPI.FindHypothesisOrAlgorithms(aHyp);
-                                       if (!SsubM->_is_nil() && !SH->_is_nil())
-                                       {
-                                               myStudyAPI.SetAlgorithms(SsubM, SH);
-                                               myStudyAPI.ModifiedMesh(SsubM, false);
-                                       }
-                               }
-                               else
-                               {
-                                       QApplication::restoreOverrideCursor();
-                                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                                               tr("SMESH_WRN_WARNING"),
-                                               tr("SMESH_WRN_ALGORITHM_ALREADYEXIST"),
-                                               tr("SMESH_BUT_YES"));
-                               }
-                       }
-               }
-               catch(const SALOME::SALOME_Exception & S_ex)
-               {
-                       QtCatchCorbaException(S_ex);
-               }
-       }
-       myActiveStudy->updateObjBrowser(true);
-       QApplication::restoreOverrideCursor();
+  int res = SMESH::HYP_UNKNOWN_FATAL; 
+  QAD_WaitCursor wc;
+
+  if ( !aMesh->_is_nil() ) {
+    SALOMEDS::SObject_var SM = myStudyAPI.FindObject( aMesh );
+    GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh(SM);
+    try {
+      res = aMesh->AddHypothesis( aShape, aHyp );
+      if ( res < SMESH::HYP_UNKNOWN_FATAL ) {
+       SALOMEDS::SObject_var SH = myStudyAPI.FindObject(aHyp);
+       if ( !SM->_is_nil() && !SH->_is_nil() ) {
+         //myStudyAPI.SetHypothesis(SM, SH); // VSR: published automatically by engine
+         myStudyAPI.ModifiedMesh(SM, false);
+       }
+      }
+      if ( res >= SMESH::HYP_UNKNOWN_FATAL ) {
+       wc.stop();
+       QAD_MessageBox::error1(QAD_Application::getDesktop(),
+                             tr("SMESH_ERROR"),
+                             tr(QString("SMESH_HYP_%1").arg(res)),
+                             tr("SMESH_BUT_OK"));
+       wc.start();
+      }
+      else if ( res > SMESH::HYP_OK ) {
+       wc.stop();
+       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"),
+                             tr(QString("SMESH_HYP_%1").arg(res)),
+                             tr("SMESH_BUT_OK"));
+       wc.start();
+      }
+    }
+    catch( const SALOME::SALOME_Exception& S_ex ) {
+      wc.stop();
+      QtCatchCorbaException( S_ex );
+      res = SMESH::HYP_UNKNOWN_FATAL;
+    }
+  }
+  return res < SMESH::HYP_UNKNOWN_FATAL;
 }
 
 //=============================================================================
@@ -990,33 +1210,76 @@ void SMESHGUI::AddAlgorithmOnSubMesh(SMESH::SMESH_subMesh_ptr aSubMesh,
  *
  */
 //=============================================================================
-void SMESHGUI::CreateAlgorithm(QString TypeAlgo, QString NameAlgo)
+bool SMESHGUI::RemoveHypothesisOrAlgorithmOnMesh
+               (const Handle(SALOME_InteractiveObject)& IObject)
 {
-       SMESH::SMESH_Hypothesis_var Hyp;
-       try
-       {
-               if (TypeAlgo.compare("Regular_1D") == 0)
-                       Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
-               else if (TypeAlgo.compare("MEFISTO_2D") == 0)
-                       Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
-               else if (TypeAlgo.compare("Quadrangle_2D") == 0)
-                       Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
-               else if (TypeAlgo.compare("Hexa_3D") == 0)
-                       Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
-               else if (TypeAlgo.compare("NETGEN_3D") == 0)
-                       Hyp = myComponentMesh->CreateHypothesis(TypeAlgo, myStudyId);
-
-               if (!Hyp->_is_nil())
-               {
-                       SALOMEDS::SObject_var SHyp = myStudyAPI.AddNewAlgorithms(Hyp);
-                       myStudyAPI.SetName(SHyp, NameAlgo);
-               }
-       }
-       catch(const SALOME::SALOME_Exception & S_ex)
-       {
-               QtCatchCorbaException(S_ex);
-       }
-       myActiveStudy->updateObjBrowser(true);
+  int res = SMESH::HYP_UNKNOWN_FATAL;
+  QAD_WaitCursor wc;
+
+  if (IObject->hasReference())
+  {
+    try {
+      SMESH::SMESH_Hypothesis_var anHyp;
+      SALOMEDS::SObject_var SO_Hypothesis =
+       smeshGUI->myStudy->FindObjectID(IObject->getEntry());
+      SALOMEDS::GenericAttribute_var anAttr;
+      SALOMEDS::AttributeIOR_var anIOR;
+
+      if (!SO_Hypothesis->_is_nil()) {
+       if (SO_Hypothesis->FindAttribute(anAttr, "AttributeIOR")) {
+         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+         anHyp = SMESH::SMESH_Hypothesis::_narrow
+           (_orb->string_to_object(anIOR->Value()));
+       }
+
+       SALOMEDS::SObject_var SO_Applied_Hypothesis =
+         smeshGUI->myStudy->FindObjectID(IObject->getReference());
+       if (!SO_Applied_Hypothesis->_is_nil()) {
+         SALOMEDS::SObject_var MorSM =
+           smeshGUI->myStudyAPI.GetMeshOrSubmesh(SO_Applied_Hypothesis);
+         if (!MorSM->_is_nil()) {
+           GEOM::GEOM_Shape_var aShape =
+             smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(MorSM);
+           if (!aShape->_is_nil() && MorSM->FindAttribute(anAttr, "AttributeIOR")) {
+              anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+              SMESH::SMESH_Mesh_var aMesh =
+                SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value()));
+              SMESH::SMESH_subMesh_var aSubMesh =
+                SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->Value()));
+
+             if (!aSubMesh->_is_nil())
+                aMesh = aSubMesh->GetFather();
+
+              if (!aMesh->_is_nil())
+              {
+                res = aMesh->RemoveHypothesis(aShape, anHyp);
+               if ( res < SMESH::HYP_UNKNOWN_FATAL )
+                 smeshGUI->myStudyAPI.ModifiedMesh(MorSM, false);
+                if ( res > SMESH::HYP_OK ) {
+                 wc.stop();
+                  QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                                        tr("SMESH_WRN_WARNING"),
+                                        tr(QString("SMESH_HYP_%1").arg(res)),
+                                        tr("SMESH_BUT_OK"));
+                 wc.start();
+               }
+              }
+            }
+          }
+        }
+      }
+    }
+    catch( const SALOME::SALOME_Exception& S_ex ) {
+      wc.stop();
+      QtCatchCorbaException( S_ex );
+      res = SMESH::HYP_UNKNOWN_FATAL;
+    }
+  }
+  else if (IObject->hasEntry())
+  {
+    MESSAGE("IObject entry " << IObject->getEntry());
+  }
+  return res < SMESH::HYP_UNKNOWN_FATAL;
 }
 
 //=============================================================================
@@ -1024,26 +1287,52 @@ void SMESHGUI::CreateAlgorithm(QString TypeAlgo, QString NameAlgo)
  *
  */
 //=============================================================================
-void SMESHGUI::CreateLocalLength(QString TypeHypothesis, QString NameHypothesis,
-       double Length)
+bool SMESHGUI::RemoveHypothesisOrAlgorithmOnMesh(SALOMEDS::SObject_ptr MorSM,
+       SMESH::SMESH_Hypothesis_ptr anHyp)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       try
-       {
-               SMESH::SMESH_Hypothesis_var Hyp =
-                       SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
-                               NameHypothesis));
-               SMESH::SMESH_LocalLength_var LL =
-                       SMESH::SMESH_LocalLength::_narrow(Hyp);
-               if (!LL->_is_nil())
-                       LL->SetLength(Length);
-       }
-       catch(const SALOME::SALOME_Exception & S_ex)
-       {
-               QtCatchCorbaException(S_ex);
-       }
-       myActiveStudy->updateObjBrowser(true);
-       QApplication::restoreOverrideCursor();
+  SALOMEDS::SObject_var AHR, aRef;
+  SALOMEDS::GenericAttribute_var anAttr;
+  SALOMEDS::AttributeIOR_var anIOR;
+  int res = SMESH::HYP_UNKNOWN_FATAL;
+  QAD_WaitCursor wc;
+
+  if (!MorSM->_is_nil()) {
+    try {
+      GEOM::GEOM_Shape_var aShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(MorSM);
+      if (!aShape->_is_nil()) {
+       if (MorSM->FindAttribute(anAttr, "AttributeIOR")) {
+         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+         SMESH::SMESH_Mesh_var aMesh =
+           SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value()));
+         SMESH::SMESH_subMesh_var aSubMesh =
+           SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->Value()));
+         
+         if ( !aSubMesh->_is_nil() )
+           aMesh = aSubMesh->GetFather();
+         
+         if (!aMesh->_is_nil()) {
+           res = aMesh->RemoveHypothesis(aShape, anHyp);
+           if ( res < SMESH::HYP_UNKNOWN_FATAL )
+             smeshGUI->myStudyAPI.ModifiedMesh(MorSM, false);
+           if ( res > SMESH::HYP_OK ) {
+             wc.stop();
+             QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                                   tr("SMESH_WRN_WARNING"),
+                                   tr(QString("SMESH_HYP_%1").arg(res)),
+                                   tr("SMESH_BUT_OK"));
+             wc.start();
+           }
+         }
+       }
+      }
+    }
+    catch( const SALOME::SALOME_Exception& S_ex ) {
+      wc.stop();
+      QtCatchCorbaException( S_ex );
+      res = SMESH::HYP_UNKNOWN_FATAL;
+    }
+  }
+  return res < SMESH::HYP_UNKNOWN_FATAL;
 }
 
 //=============================================================================
@@ -1051,27 +1340,48 @@ void SMESHGUI::CreateLocalLength(QString TypeHypothesis, QString NameHypothesis,
  *
  */
 //=============================================================================
-void SMESHGUI::CreateMaxElementArea(QString TypeHypothesis,
-       QString NameHypothesis, double MaxArea)
+bool SMESHGUI::AddAlgorithmOnMesh( SMESH::SMESH_Mesh_ptr       aMesh,
+                                  SMESH::SMESH_Hypothesis_ptr aHyp )
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       try
-       {
-               SMESH::SMESH_Hypothesis_var Hyp =
-                       SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
-                               NameHypothesis));
-               SMESH::SMESH_MaxElementArea_var MaxElArea =
-                       SMESH::SMESH_MaxElementArea::_narrow(Hyp);
-               if (!MaxElArea->_is_nil())
-                       MaxElArea->SetMaxElementArea(MaxArea);
-       }
-       catch(SALOME::SALOME_Exception & S_ex)
-       {
-               QtCatchCorbaException(S_ex);
-       }
-
-       myActiveStudy->updateObjBrowser(true);
-       QApplication::restoreOverrideCursor();
+  int res = SMESH::HYP_UNKNOWN_FATAL;
+  QAD_WaitCursor wc;
+
+  if ( !aMesh->_is_nil() ) {
+    SALOMEDS::SObject_var SM = myStudyAPI.FindObject( aMesh );
+    GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh( SM );
+    try {
+      res = aMesh->AddHypothesis( aShape, aHyp );
+      if ( res < SMESH::HYP_UNKNOWN_FATAL ) {
+       //SALOMEDS::SObject_var SH = myStudyAPI.FindObject( aHyp );
+       //if ( !SM->_is_nil() && !SH->_is_nil() ) {
+         //myStudyAPI.SetAlgorithms(SM, SH);
+       myStudyAPI.ModifiedMesh( SM, false );
+       //}
+      }
+      if ( res >= SMESH::HYP_UNKNOWN_FATAL ) {
+       wc.stop();
+       QAD_MessageBox::error1(QAD_Application::getDesktop(),
+                             tr("SMESH_ERROR"),
+                             tr(QString("SMESH_HYP_%1").arg(res)),
+                             tr("SMESH_BUT_OK"));
+       wc.start();
+      }
+      else if ( res > SMESH::HYP_OK ) {
+       wc.stop();
+       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
+                              tr( "SMESH_WRN_WARNING" ),
+                              tr(QString("SMESH_HYP_%1").arg(res)),
+                              tr( "SMESH_BUT_OK" ) );
+       wc.start();
+      }
+    }
+    catch( const SALOME::SALOME_Exception& S_ex ) {
+      wc.stop();
+      QtCatchCorbaException( S_ex );
+      res = SMESH::HYP_UNKNOWN_FATAL;
+    }
+  }
+  return res < SMESH::HYP_UNKNOWN_FATAL;
 }
 
 //=============================================================================
@@ -1079,26 +1389,52 @@ void SMESHGUI::CreateMaxElementArea(QString TypeHypothesis,
  *
  */
 //=============================================================================
-void SMESHGUI::CreateMaxElementVolume(QString TypeHypothesis,
-       QString NameHypothesis, double MaxVolume)
+bool SMESHGUI::AddHypothesisOnSubMesh( SMESH::SMESH_subMesh_ptr    aSubMesh,
+                                      SMESH::SMESH_Hypothesis_ptr aHyp )
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       try
-       {
-               SMESH::SMESH_Hypothesis_var Hyp =
-                       SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
-                               NameHypothesis));
-               SMESH::SMESH_MaxElementVolume_var MaxElVolume =
-                       SMESH::SMESH_MaxElementVolume::_narrow(Hyp);
-               if (!MaxElVolume->_is_nil())
-                       MaxElVolume->SetMaxElementVolume(MaxVolume);
-       }
-       catch(const SALOME::SALOME_Exception & S_ex)
-       {
-               QtCatchCorbaException(S_ex);
-       }
-       myActiveStudy->updateObjBrowser(true);
-       QApplication::restoreOverrideCursor();
+  int res = SMESH::HYP_UNKNOWN_FATAL;
+  QAD_WaitCursor wc;
+
+  if ( !aSubMesh->_is_nil() ) {
+    try {
+      SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
+      SALOMEDS::SObject_var SsubM = myStudyAPI.FindObject( aSubMesh );
+      GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh( SsubM );
+      if ( !aMesh->_is_nil() && !SsubM->_is_nil() && !aShape->_is_nil() ) {
+       res = aMesh->AddHypothesis( aShape, aHyp );
+       if ( res < SMESH::HYP_UNKNOWN_FATAL )  {
+         //SALOMEDS::SObject_var SH = myStudyAPI.FindObject(aHyp);
+         //                    if (!SsubM->_is_nil() && !SH->_is_nil())
+         //                    {
+         //                            myStudyAPI.SetHypothesis(SsubM, SH);
+         myStudyAPI.ModifiedMesh( SsubM, false );
+         //                    }
+       }
+       if ( res >= SMESH::HYP_UNKNOWN_FATAL ) {
+         wc.stop();
+         QAD_MessageBox::error1(QAD_Application::getDesktop(),
+                                tr("SMESH_ERROR"),
+                                tr(QString("SMESH_HYP_%1").arg(res)),
+                                tr("SMESH_BUT_OK"));
+         wc.start();
+       }
+       else if ( res > SMESH::HYP_OK ) {
+         wc.stop();
+         QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                               tr( "SMESH_WRN_WARNING" ),
+                               tr(QString("SMESH_HYP_%1").arg(res)),
+                               tr( "SMESH_BUT_OK" ) );
+         wc.start();
+       }
+      }
+    }
+    catch( const SALOME::SALOME_Exception& S_ex ) {
+      wc.stop();
+      QtCatchCorbaException( S_ex );
+      res = SMESH::HYP_UNKNOWN_FATAL;
+    }
+  }
+  return res < SMESH::HYP_UNKNOWN_FATAL;
 }
 
 //=============================================================================
@@ -1106,26 +1442,51 @@ void SMESHGUI::CreateMaxElementVolume(QString TypeHypothesis,
  *
  */
 //=============================================================================
-void SMESHGUI::CreateNbSegments(QString TypeHypothesis, QString NameHypothesis,
-       int nbSegments)
+bool SMESHGUI::AddAlgorithmOnSubMesh( SMESH::SMESH_subMesh_ptr    aSubMesh,
+                                     SMESH::SMESH_Hypothesis_ptr aHyp )
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       try
-       {
-               SMESH::SMESH_Hypothesis_var Hyp =
-                       SMESH::SMESH_Hypothesis::_narrow(CreateHypothesis(TypeHypothesis,
-                               NameHypothesis));
-               SMESH::SMESH_NumberOfSegments_var NbS =
-                       SMESH::SMESH_NumberOfSegments::_narrow(Hyp);
-               if (!NbS->_is_nil())
-                       NbS->SetNumberOfSegments(nbSegments);
-       }
-       catch(const SALOME::SALOME_Exception & S_ex)
-       {
-               QtCatchCorbaException(S_ex);
-       }
-       myActiveStudy->updateObjBrowser(true);
-       QApplication::restoreOverrideCursor();
+  int res = SMESH::HYP_UNKNOWN_FATAL;
+  QAD_WaitCursor wc;
+
+  if ( !aSubMesh->_is_nil() ) {
+    try {
+      SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
+      SALOMEDS::SObject_var SsubM = myStudyAPI.FindObject(aSubMesh);
+      GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh(SsubM);
+      if ( !aMesh->_is_nil() && !SsubM->_is_nil() && !aShape->_is_nil() ) {
+       res = aMesh->AddHypothesis( aShape, aHyp );
+       if ( res < SMESH::HYP_UNKNOWN_FATAL )  {
+         //SALOMEDS::SObject_var SH = myStudyAPI.FindObject(aHyp);
+         //if (!SsubM->_is_nil() && !SH->_is_nil()) {
+         //myStudyAPI.SetAlgorithms(SsubM, SH);
+         myStudyAPI.ModifiedMesh( SsubM, false );
+         //}
+       }
+       if ( res >= SMESH::HYP_UNKNOWN_FATAL ) {
+         wc.stop();
+         QAD_MessageBox::error1(QAD_Application::getDesktop(),
+                                tr("SMESH_ERROR"),
+                                tr(QString("SMESH_HYP_%1").arg(res)),
+                                tr("SMESH_BUT_OK"));
+         wc.start();
+       }
+       else if ( res > SMESH::HYP_OK ) {
+         wc.stop();
+         QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                               tr( "SMESH_WRN_WARNING" ),
+                               tr(QString("SMESH_HYP_%1").arg(res)),
+                               tr( "SMESH_BUT_OK" ) );
+         wc.start();
+       }
+      }
+    }
+    catch( const SALOME::SALOME_Exception& S_ex ) {
+      wc.stop();
+      QtCatchCorbaException( S_ex );
+      res = SMESH::HYP_UNKNOWN_FATAL;
+    }
+  }
+  return res < SMESH::HYP_UNKNOWN_FATAL;
 }
 
 //=============================================================================
@@ -1153,38 +1514,23 @@ int SMESHGUI::GetNameOfSelectedIObjects(SALOME_Selection * Sel, QString & aName)
  *
  */
 //=============================================================================
-int SMESHGUI::GetNameOfSelectedNodes(SALOME_Selection * Sel, QString & aName)
-{
-       int nbNodes = 0;
-       int nbSel = Sel->IObjectCount();
-       if (nbSel == 1)
-       {
-               Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
-               if (!IObject->hasEntry())
-                       return -1;
-
-               Standard_Boolean res;
-               SMESH_Actor *ac = FindActorByEntry(IObject->getEntry(), res, true);
-               if (!res)
-                       return -1;
-
-               TColStd_MapOfInteger MapIndex;
-               Sel->GetIndex(IObject, MapIndex);
-               TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
-               aName = " ";
-               nbNodes = MapIndex.Extent();
-               for (; ite.More(); ite.Next())
-               {
-                       aName =
-                               aName + QString("%1").arg(ac->GetIdSMESHDSNode(ite.Key())) +
-                               " ";
-               }
-       }
-       else
-       {
-               aName = "";
-       }
-       return nbNodes;
+int SMESHGUI::GetNameOfSelectedNodes(SALOME_Selection * Sel, QString & aName){
+  aName = "";
+  if(Sel->IObjectCount() == 1){
+    Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+    if(IObject->hasEntry()){
+      if(SMESH_Actor *anActor = ::FindActorByEntry(IObject->getEntry())){
+       TColStd_MapOfInteger MapIndex;
+       Sel->GetIndex(IObject, MapIndex);
+       TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
+       for(; ite.More(); ite.Next()){
+         aName += QString(" %1").arg(anActor->GetNodeObjId(ite.Key()));
+       }
+       return MapIndex.Extent();
+      }
+    }
+  }
+  return -1;
 }
 
 //=============================================================================
@@ -1192,77 +1538,78 @@ int SMESHGUI::GetNameOfSelectedNodes(SALOME_Selection * Sel, QString & aName)
  *
  */
 //=============================================================================
-int SMESHGUI::GetNameOfSelectedElements(SALOME_Selection * Sel, QString & aName)
-{
-       int nbElements = 0;
-       int nbSel = Sel->IObjectCount();
-       if (nbSel == 1)
-       {
-               Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
-               if (!IObject->hasEntry())
-                       return -1;
+int SMESHGUI::GetNameOfSelectedElements(SALOME_Selection * Sel, QString & aName){
+  aName = "";
+  if(Sel->IObjectCount() == 1){
+    Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+    if(IObject->hasEntry()){
+      if(SMESH_Actor *anActor = ::FindActorByEntry(IObject->getEntry())){
+       TColStd_MapOfInteger MapIndex;
+       Sel->GetIndex(IObject, MapIndex);
+       TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
+       std::vector<int> aList;
+       for(; ite.More(); ite.Next()){
+         int aVtkId = ite.Key();
+         int anObjId = anActor->GetElemObjId(aVtkId);
+         std::vector<int>::iterator found = find(aList.begin(), aList.end(), anObjId);
+         //      MESSAGE("GetNameOfSelectedElements(): VTK Id = " << aVtkId << ", OBJECT Id = " << anObjId);
+         if (found == aList.end()) {
+           aList.push_back(anObjId);
+           aName += QString(" %1").arg(anObjId);
+         }
+       }
+       return aList.size();
+      }
+    }
+  }
+  return -1;
+}
 
-               Standard_Boolean res;
-               SMESH_Actor *ac = FindActorByEntry(IObject->getEntry(), res, true);
-               if (!res)
-                       return -1;
 
-               TColStd_MapOfInteger MapIndex;
-               Sel->GetIndex(IObject, MapIndex);
-               TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
-               aName = " ";
-               nbElements = MapIndex.Extent();
-               MESSAGE("GetNameOfSelectedElements(): number = " << nbElements);
-               for (; ite.More(); ite.Next())
-               {
-                       int idVTK = ite.Key();
-                       MESSAGE("GetNameOfSelectedElements(): VTK Id = " << idVTK);
-                       aName =
-                               aName + QString("%1").arg(ac->GetIdSMESHDSElement(idVTK)) + " ";
-               }
-       }
-       else
-       {
-               aName = "";
-       }
-       return nbElements;
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+int SMESHGUI::GetNameOfSelectedEdges(SALOME_Selection * Sel, QString & aName){
+  aName = "";
+  if(Sel->IObjectCount() == 1){
+    Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+    if(IObject->hasEntry()){
+      if(SMESH_Actor *anActor = ::FindActorByEntry(IObject->getEntry())){
+       TColStd_MapOfInteger MapIndex;
+       Sel->GetIndex(IObject, MapIndex);
+       TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
+       for(; ite.More(); ite.Next()){
+         aName += QString(" %1").arg(ite.Key());
+       }
+       return MapIndex.Extent();
+      }
+    }
+  }
+  return -1;
 }
 
+
 //=============================================================================
 /*!
  *
  */
 //=============================================================================
-int SMESHGUI::GetNameOfSelectedEdges(SALOME_Selection * Sel, QString & aName)
+SMESH_Actor *SMESHGUI::FindActorByEntry(QString theEntry,
+                                       Standard_Boolean & theResult, 
+                                       bool onlyInActiveView)
 {
-       int nbElements = 0;
-       int nbSel = Sel->IObjectCount();
-       if (nbSel == 1)
-       {
-               Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
-               if (!IObject->hasEntry())
-                       return -1;
-
-               Standard_Boolean res;
-               SMESH_Actor *ac = FindActorByEntry(IObject->getEntry(), res, true);
-               if (!res)
-                       return -1;
-
-               TColStd_MapOfInteger MapIndex;
-               Sel->GetIndex(IObject, MapIndex);
-               TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
-               aName = " ";
-               nbElements = MapIndex.Extent();
-               for (; ite.More(); ite.Next())
-               {
-                       aName = aName + QString("%1").arg(ite.Key()) + " ";
-               }
-       }
-       else
-       {
-               aName = "";
-       }
-       return nbElements;
+  theResult = false;
+  int aNbStudyFrames = myActiveStudy->getStudyFramesCount();
+  for (int i = 0; i < aNbStudyFrames; i++){
+    QAD_StudyFrame *aStudyFrame = myActiveStudy->getStudyFrame(i);
+    if(SMESH_Actor *anActor = ::FindActorByEntry(aStudyFrame,theEntry.latin1())){
+      theResult = true;
+      return anActor;
+    }
+  }
+  return NULL;
 }
 
 //=============================================================================
@@ -1270,54 +1617,20 @@ int SMESHGUI::GetNameOfSelectedEdges(SALOME_Selection * Sel, QString & aName)
  *
  */
 //=============================================================================
-SMESH_Actor *SMESHGUI::FindActorByEntry(QString entry,
-       Standard_Boolean & testResult, bool onlyInActiveView)
+SMESH_Actor* SMESHGUI::FindActor(CORBA::Object_ptr theObj,
+                                Standard_Boolean & theResult, 
+                                bool theOnlyInActiveView)
 {
-       int nbSf = myActiveStudy->getStudyFramesCount();
-       for (int i = 0; i < nbSf; i++)
-       {
-               QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i);
-               if (sf->getTypeView() == VIEW_VTK)
-               {
-                       vtkRenderer *Renderer =
-                               ((VTKViewer_ViewFrame *) sf->getRightFrame()->getViewFrame())->
-                               getRenderer();
-                       vtkActorCollection *theActors = Renderer->GetActors();
-                       theActors->InitTraversal();
-                       vtkActor *ac = theActors->GetNextActor();
-                       while (!(ac == NULL))
-                       {
-                               if (ac->IsA("SMESH_Actor"))
-                               {
-                                       SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
-                                       if (anActor->hasIO())
-                                       {
-                                               Handle(SALOME_InteractiveObject) IO = anActor->getIO();
-                                               if (strcmp(IO->getEntry(), entry) == 0)
-                                               {
-                                                       if (onlyInActiveView)
-                                                       {
-                                                               if (sf == myActiveStudy->getActiveStudyFrame())
-                                                               {
-                                                                       testResult = true;
-                                                                       return anActor;
-                                                               }
-                                                       }
-                                                       else
-                                                       {
-                                                               testResult = true;
-                                                               return anActor;
-                                                       }
-                                               }
-                                       }
-                               }
-                               ac = theActors->GetNextActor();
-                       }
-               }
-       }
-
-       MESSAGE(" Actor Not Found ") testResult = false;
-       return SMESH_Actor::New();
+  theResult = false;
+  SMESH_Actor* aRes = NULL;
+  if ( !CORBA::is_nil( theObj ) ) {
+    SALOMEDS::SObject_var aSObject = SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR( _orb->object_to_string( theObj ) ) );
+    if( !aSObject->_is_nil()) {
+      CORBA::String_var anEntry = aSObject->GetID();
+      aRes = FindActorByEntry( anEntry.in(), theResult, theOnlyInActiveView );
+    }
+  }
+  return aRes;
 }
 
 //=============================================================================
@@ -1325,17 +1638,34 @@ SMESH_Actor *SMESHGUI::FindActorByEntry(QString entry,
  *
  */
 //=============================================================================
-SMESH_Actor *SMESHGUI::FindActor(SMESH::SMESH_Mesh_ptr aMesh,
-       Standard_Boolean & testResult, bool onlyInActiveView)
+SMESH::SMESH_Mesh_ptr SMESHGUI::ConvertIOinMesh(const Handle(SALOME_InteractiveObject) & IO,
+                                               Standard_Boolean & testResult)
 {
-       SALOMEDS::SObject_var SM = myStudyAPI.FindMesh(aMesh);
-       if (SM->_is_nil())
-       {
-               MESSAGE(" Actor Not Found ") testResult = false;
-               return SMESH_Actor::New();
-       }
-
-       return FindActorByEntry(SM->GetID(), testResult, onlyInActiveView);
+  SMESH::SMESH_Mesh_var aMesh;
+  testResult = false;
+
+  /* case SObject */
+  if (IO->hasEntry())
+  {
+    SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::AttributeIOR_var anIOR;
+    if (!obj->_is_nil())
+    {
+      if (obj->FindAttribute(anAttr, "AttributeIOR"))
+      {
+        anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+        aMesh =
+          SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value()));
+        if (!aMesh->_is_nil())
+        {
+          testResult = true;
+          return SMESH::SMESH_Mesh::_duplicate(aMesh);
+        }
+      }
+    }
+  }
+  return SMESH::SMESH_Mesh::_nil();
 }
 
 //=============================================================================
@@ -1343,36 +1673,33 @@ SMESH_Actor *SMESHGUI::FindActor(SMESH::SMESH_Mesh_ptr aMesh,
  *
  */
 //=============================================================================
-SMESH::SMESH_Mesh_ptr SMESHGUI::
-ConvertIOinMesh(const Handle(SALOME_InteractiveObject) & IO,
-       Standard_Boolean & testResult)
+SMESH::SMESH_subMesh_ptr SMESHGUI::ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject) & IO,
+                                                     Standard_Boolean & testResult)
 {
-       SMESH::SMESH_Mesh_var aMesh;
-       testResult = false;
-
-       /* case SObject */
-       if (IO->hasEntry())
-       {
-               SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
-               SALOMEDS::GenericAttribute_var anAttr;
-               SALOMEDS::AttributeIOR_var anIOR;
-               if (!obj->_is_nil())
-               {
-                       if (obj->FindAttribute(anAttr, "AttributeIOR"))
-                       {
-                               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                               aMesh =
-                                       SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->
-                                               Value()));
-                               if (!aMesh->_is_nil())
-                               {
-                                       testResult = true;
-                                       return SMESH::SMESH_Mesh::_duplicate(aMesh);
-                               }
-                       }
-               }
-       }
-       return SMESH::SMESH_Mesh::_nil();
+  SMESH::SMESH_subMesh_var aSubMesh;
+  testResult = false;
+
+  /* case SObject */
+  if (IO->hasEntry())
+  {
+    SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::AttributeIOR_var anIOR;
+    if (!obj->_is_nil())
+    {
+      if (obj->FindAttribute(anAttr, "AttributeIOR"))
+      {
+        anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+        aSubMesh = SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->Value()));
+        if (!aSubMesh->_is_nil())
+        {
+          testResult = true;
+          return SMESH::SMESH_subMesh::_duplicate(aSubMesh);
+        }
+      }
+    }
+  }
+  return SMESH::SMESH_subMesh::_nil();
 }
 
 //=============================================================================
@@ -1380,36 +1707,33 @@ ConvertIOinMesh(const Handle(SALOME_InteractiveObject) & IO,
  *
  */
 //=============================================================================
-SMESH::SMESH_subMesh_ptr SMESHGUI::
-ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject) & IO,
-       Standard_Boolean & testResult)
+SMESH::SMESH_Hypothesis_ptr SMESHGUI::ConvertIOinSMESHHypothesis(const Handle(SALOME_InteractiveObject) & IO,
+                                                                Standard_Boolean & testResult)
 {
-       SMESH::SMESH_subMesh_var aSubMesh;
-       testResult = false;
-
-       /* case SObject */
-       if (IO->hasEntry())
-       {
-               SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
-               SALOMEDS::GenericAttribute_var anAttr;
-               SALOMEDS::AttributeIOR_var anIOR;
-               if (!obj->_is_nil())
-               {
-                       if (obj->FindAttribute(anAttr, "AttributeIOR"))
-                       {
-                               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                               aSubMesh =
-                                       SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->
-                                               Value()));
-                               if (!aSubMesh->_is_nil())
-                               {
-                                       testResult = true;
-                                       return SMESH::SMESH_subMesh::_duplicate(aSubMesh);
-                               }
-                       }
-               }
-       }
-       return SMESH::SMESH_subMesh::_nil();
+  SMESH::SMESH_Hypothesis_var aHyp;
+  testResult = false;
+
+  /* case SObject */
+  if (IO->hasEntry())
+  {
+    SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::AttributeIOR_var anIOR;
+    if (!obj->_is_nil())
+    {
+      if (obj->FindAttribute(anAttr, "AttributeIOR"))
+      {
+        anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+        aHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(anIOR->Value()));
+        if (!aHyp->_is_nil())
+        {
+          testResult = true;
+          return SMESH::SMESH_Hypothesis::_duplicate(aHyp);
+        }
+      }
+    }
+  }
+  return SMESH::SMESH_Hypothesis::_nil();
 }
 
 //=============================================================================
@@ -1417,36 +1741,29 @@ ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject) & IO,
  *
  */
 //=============================================================================
-SMESH::SMESH_Hypothesis_ptr SMESHGUI::
-ConvertIOinSMESHHypothesis(const Handle(SALOME_InteractiveObject) & IO,
-       Standard_Boolean & testResult)
+SMESH::SMESH_Group_ptr SMESHGUI::ConvertIOinSMESHGroup(const Handle(SALOME_InteractiveObject) & IO,
+                                                      Standard_Boolean & testResult)
 {
-       SMESH::SMESH_Hypothesis_var aHyp;
-       testResult = false;
-
-       /* case SObject */
-       if (IO->hasEntry())
-       {
-               SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
-               SALOMEDS::GenericAttribute_var anAttr;
-               SALOMEDS::AttributeIOR_var anIOR;
-               if (!obj->_is_nil())
-               {
-                       if (obj->FindAttribute(anAttr, "AttributeIOR"))
-                       {
-                               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                               aHyp =
-                                       SMESH::SMESH_Hypothesis::_narrow(_orb->
-                                       string_to_object(anIOR->Value()));
-                               if (!aHyp->_is_nil())
-                               {
-                                       testResult = true;
-                                       return SMESH::SMESH_Hypothesis::_duplicate(aHyp);
-                               }
-                       }
-               }
-       }
-       return SMESH::SMESH_Hypothesis::_nil();
+  SMESH::SMESH_Group_var aGroup;
+  testResult = false;
+
+  /* case SObject */
+  if (IO->hasEntry()) {
+    SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::AttributeIOR_var anIOR;
+    if (!obj->_is_nil()) {
+      if (obj->FindAttribute(anAttr, "AttributeIOR")) {
+        anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+        aGroup = SMESH::SMESH_Group::_narrow(_orb->string_to_object(anIOR->Value()));
+        if (!aGroup->_is_nil()) {
+          testResult = true;
+          return SMESH::SMESH_Group::_duplicate(aGroup);
+        }
+      }
+    }
+  }
+  return SMESH::SMESH_Group::_nil();
 }
 
 //=============================================================================
@@ -1454,34 +1771,29 @@ ConvertIOinSMESHHypothesis(const Handle(SALOME_InteractiveObject) & IO,
  *
  */
 //=============================================================================
-GEOM::GEOM_Shape_ptr SMESHGUI::
-ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject) & IO,
-       Standard_Boolean & testResult)
+GEOM::GEOM_Shape_ptr SMESHGUI::ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject) & IO,
+                                                   Standard_Boolean & testResult)
 {
-       GEOM::GEOM_Shape_var aShape;
-       testResult = false;
-
-       /* case SObject */
-       if (IO->hasEntry())
-       {
-               SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
-               SALOMEDS::GenericAttribute_var anAttr;
-               SALOMEDS::AttributeIOR_var anIOR;
-               if (!obj->_is_nil())
-               {
-                       if (obj->FindAttribute(anAttr, "AttributeIOR"))
-                       {
-                               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                               aShape = myComponentGeom->GetIORFromString(anIOR->Value());
-                               if (!aShape->_is_nil())
-                               {
-                                       testResult = true;
-                                       return GEOM::GEOM_Shape::_duplicate(aShape);
-                               }
-                       }
-               }
-       }
-       return GEOM::GEOM_Shape::_nil();
+  GEOM::GEOM_Shape_var aShape;
+  testResult = false;
+
+  /* case SObject */
+  if (IO->hasEntry()) {
+    SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry());
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::AttributeIOR_var anIOR;
+    if (!obj->_is_nil()) {
+      if (obj->FindAttribute(anAttr, "AttributeIOR")) {
+       anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+       aShape = myComponentGeom->GetIORFromString(anIOR->Value());
+       if (!aShape->_is_nil()) {
+         testResult = true;
+         return GEOM::GEOM_Shape::_duplicate(aShape);
+       }
+      }
+    }
+  }
+  return GEOM::GEOM_Shape::_nil();
 }
 
 //=============================================================================
@@ -1489,55 +1801,37 @@ ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject) & IO,
  *
  */
 //=============================================================================
-void SMESHGUI::SetViewMode(int commandId)
-{
-       SALOME_Selection *Sel =
-               SALOME_Selection::Selection(myActiveStudy->getSelection());
-       int nbSel = Sel->IObjectCount();
-       if (nbSel >= 1)
-       {
-               SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-               for (; It.More(); It.Next())
-               {
-                       Handle(SALOME_InteractiveObject) IObject = It.Value();
-                       if (IObject->hasEntry())
-                       {
-                               Standard_Boolean res;
-                               SMESH_Actor *ac =
-                                       FindActorByEntry(IObject->getEntry(), res, true);
-                               if (res)
-                               {
-                                       switch (commandId)
-                                       {
-                                       case 211:
-                                       {
-                                               ChangeRepresentation(ac, 0);
-                                               break;
-                                       }
-                                       case 212:
-                                       {
-                                               ChangeRepresentation(ac, 1);
-                                               break;
-                                       }
-                                       case 213:
-                                       {
-                                               ChangeRepresentation(ac, 2);
-                                               break;
-                                       }
-                                       case 1132:
-                                       {
-                                               ChangeRepresentation(ac, 3);
-                                               break;
-                                       }
-                                       }
-                               }
-                       }
-               }
-               if (commandId == 1133)
-               {
-                       ChangeRepresentation(SMESH_Actor::New(), 4);
-               }
-       }
+void SMESHGUI::SetViewMode(int commandId){
+  SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
+  if(Sel->IObjectCount() >= 1){
+    SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+    for(; It.More(); It.Next()){
+      Handle(SALOME_InteractiveObject) IObject = It.Value();
+      if(IObject->hasEntry()){
+       if(SMESH_Actor *anActor = ::FindActorByEntry(IObject->getEntry())){
+         switch(commandId){
+         case 211:
+           ChangeRepresentation(anActor,0);
+           break;
+         case 212:
+           ChangeRepresentation(anActor,1);
+           break;
+         case 213:
+           ChangeRepresentation(anActor,2);
+           break;
+         case 215:
+           ChangeRepresentation(anActor,5);
+           break;
+         case 1132:
+           ChangeRepresentation(anActor,3);
+           break;
+         }
+       }
+      }
+    }
+    if(commandId == 1133)
+      ChangeRepresentation(NULL,4);
+  }
 }
 
 //=============================================================================
@@ -1545,207 +1839,110 @@ void SMESHGUI::SetViewMode(int commandId)
  *
  */
 //=============================================================================
-void SMESHGUI::ChangeRepresentation(SMESH_Actor * ac, int type)
-{
-       if (ac->DataSource == NULL && type != 4)
-               return;
-
-       if (type != 4)
-       {
-               if (ac->getMapper() == NULL)
-               {
-                       return;
-               }
-       }
-       switch (type)
-       {
-       case 0:
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               if (ac->getDisplayMode() == 2)
-               {
-                       bool isColored = ac->getMapper()->GetScalarVisibility();        //SAL3899
-                       vtkDataSetMapper *meshMapper =
-                               (vtkDataSetMapper *) (ac->getMapper());
-                       meshMapper->SetInput(ac->DataSource);
-                       meshMapper->SetScalarVisibility(isColored);     //SAL3899
-               }
-               ac->setDisplayMode(0);
-               ac->GetProperty()->SetRepresentationToWireframe();
-               //    ac->SetActorProperty( ac->GetProperty() );
-               QApplication::restoreOverrideCursor();
-               break;
-       }
-       case 1:
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               if (ac->getDisplayMode() == 2)
-               {
-                       bool isColored = ac->getMapper()->GetScalarVisibility();        //SAL3899
-                       vtkDataSetMapper *meshMapper =
-                               (vtkDataSetMapper *) (ac->getMapper());
-                       meshMapper->SetInput(ac->DataSource);
-                       meshMapper->SetScalarVisibility(isColored);     //SAL3899
-               }
-               ac->setDisplayMode(1);
-               ac->GetProperty()->SetRepresentationToSurface();
-               QApplication::restoreOverrideCursor();
-               //    ac->SetActorProperty( ac->GetProperty() );
-               break;
-       }
-       case 2:
-       {
-               //    if (!(ac->getDisplayMode()==2)) {
-               //    ChangeRepresentation(ac, 1);
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               ac->setDisplayMode(2);
-               bool isColored = ac->getMapper()->GetScalarVisibility();        //SAL3899
-               vtkDataSetMapper *meshMapper = (vtkDataSetMapper *) (ac->getMapper());
-               vtkShrinkFilter *shrink = vtkShrinkFilter::New();
-               shrink->SetInput(ac->DataSource);
-               shrink->SetShrinkFactor(ac->GetShrinkFactor());
-
-               meshMapper->SetInput(shrink->GetOutput());
-               meshMapper->SetScalarVisibility(isColored);     //SAL3899
-               ac->SetMapper(meshMapper);
-               QApplication::restoreOverrideCursor();
-               //    }
-               break;
-       }
-       case 3:
-       {
-               float color[3];
-               float edgecolor[3];
-               float backfacecolor[3];
-               float nodecolor[3];
-               ac->GetColor(color[0], color[1], color[2]);
-//       QColor c(color[0]*255,color[1]*255,color[2]*255);
-               int c0 = int (color[0] * 255);
-               int c1 = int (color[1] * 255);
-               int c2 = int (color[2] * 255);
-               QColor c(c0, c1, c2);
-               ac->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
-//       QColor e(edgecolor[0]*255,edgecolor[1]*255,edgecolor[2]*255);
-               c0 = int (edgecolor[0] * 255);
-               c1 = int (edgecolor[1] * 255);
-               c2 = int (edgecolor[2] * 255);
-               QColor e(c0, c1, c2);
-               ac->GetBackfaceProperty()->GetColor(backfacecolor);
-//       QColor b(backfacecolor[0]*255,backfacecolor[1]*255,backfacecolor[2]*255);
-               c0 = int (backfacecolor[0] * 255);
-               c1 = int (backfacecolor[1] * 255);
-               c2 = int (backfacecolor[2] * 255);
-               QColor b(c0, c1, c2);
-               ac->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
-//       QColor n(nodecolor[0]*255, nodecolor[1]*255, nodecolor[2]*255 ) ;
-               c0 = int (nodecolor[0] * 255);
-               c1 = int (nodecolor[1] * 255);
-               c2 = int (nodecolor[2] * 255);
-               QColor n(c0, c1, c2);
-
-               int Edgewidth = (int)ac->EdgeDevice->GetProperty()->GetLineWidth();
-               if (Edgewidth == 0)
-                       Edgewidth = 1;
-               int intValue = ac->GetNodeSize();
-               float Shrink = ac->GetShrinkFactor();
-
-               SMESHGUI_Preferences_ColorDlg *aDlg =
-                       new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),
-                       "");
-               aDlg->SetColor(1, c);
-               aDlg->SetColor(2, e);
-               aDlg->SetColor(3, n);
-               aDlg->SetColor(4, b);
-               aDlg->SetIntValue(1, Edgewidth);
-               aDlg->SetIntValue(2, intValue);
-               aDlg->SetIntValue(3, int (Shrink * 100.));
-
-               if (aDlg->exec())
-               {
-                       QApplication::setOverrideCursor(Qt::waitCursor);
-                       QColor color = aDlg->GetColor(1);
-                       QColor edgecolor = aDlg->GetColor(2);
-                       QColor nodecolor = aDlg->GetColor(3);
-                       QColor backfacecolor = aDlg->GetColor(4);
-                       /* actor color and backface color */
-                       ac->GetProperty()->SetColor(float (color.red()) / 255.,
-                               float (color.green()) / 255., float (color.blue()) / 255.);
-                       ac->SetColor(float (color.red()) / 255.,
-                               float (color.green()) / 255., float (color.blue()) / 255.);
-                       ac->GetBackfaceProperty()->SetColor(float (backfacecolor.red()) /
-                               255., float (backfacecolor.green()) / 255.,
-                               float (backfacecolor.blue()) / 255.);
-
-                       /* edge color */
-                       ac->EdgeDevice->GetProperty()->SetColor(float (edgecolor.red()) /
-                               255., float (edgecolor.green()) / 255.,
-                               float (edgecolor.blue()) / 255.);
-                       ac->EdgeShrinkDevice->GetProperty()->SetColor(float (edgecolor.
-                                       red()) / 255., float (edgecolor.green()) / 255.,
-                               float (edgecolor.blue()) / 255.);
-                       ac->SetEdgeColor(float (edgecolor.red()) / 255.,
-                               float (edgecolor.green()) / 255.,
-                               float (edgecolor.blue()) / 255.);
-
-                       /* Shrink factor and size edges */
-                       ac->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
-                       ac->EdgeDevice->GetProperty()->SetLineWidth(aDlg->GetIntValue(1));
-                       ac->EdgeShrinkDevice->GetProperty()->SetLineWidth(aDlg->
-                               GetIntValue(1));
-
-                       /* Nodes color and size */
-                       ac->SetNodeColor(float (nodecolor.red()) / 255.,
-                               float (nodecolor.green()) / 255.,
-                               float (nodecolor.blue()) / 255.);
-                       ac->SetNodeSize(aDlg->GetIntValue(2));
-
-                       if (ac->getDisplayMode() == 2)
-                       {
-                               bool isColored = ac->getMapper()->GetScalarVisibility();        //SAL3899
-                               vtkDataSetMapper *meshMapper =
-                                       (vtkDataSetMapper *) (ac->getMapper());
-                               meshMapper->SetInput(ac->DataSource);
-                               vtkShrinkFilter *shrink = vtkShrinkFilter::New();
-                               shrink->SetInput(meshMapper->GetInput());
-                               shrink->SetShrinkFactor(ac->GetShrinkFactor());
-
-                               meshMapper->SetInput(shrink->GetOutput());
-                               meshMapper->SetScalarVisibility(isColored);     //SAL3899
-                               ac->SetMapper(meshMapper);
-                       }
-               }
-               delete aDlg;
-               QApplication::restoreOverrideCursor();
-               break;
-       }
-       case 4:
-       {
-               EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(myActiveStudy->getSelection());
-               SMESHGUI_TransparencyDlg *aDlg =
-                       new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(), "",
-                       Sel);
-               break;
-       }
-       case 5:
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               ac->GetProperty()->SetRepresentationToPoints();
-               QApplication::restoreOverrideCursor();
-               break;
-       }
-       }
-
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
-       {                                                       //VTK
-               vtkRenderer *theRenderer =
-                       ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-                       getRightFrame()->getViewFrame())->getRenderer();
-               theRenderer->Render();
-       }
-       QApplication::restoreOverrideCursor();
+void SMESHGUI::ChangeRepresentation(SMESH_Actor * theActor, int type){
+  switch (type){
+  case 0:{
+    //theActor->UnShrink();
+    theActor->SetRepresentation(SMESH_Actor::eEdge);
+    break;
+  }
+  case 1:{
+    //theActor->UnShrink();
+    theActor->SetRepresentation(SMESH_Actor::eSurface);
+    break;
+  }
+  case 2:{
+    theActor->IsShrunk() ? theActor->UnShrink() : theActor->SetShrink();
+    //theActor->SetRepresentation(SMESH_Actor::eSurface);
+    break;
+  }
+  case 5:{
+    //theActor->UnShrink();
+    theActor->SetRepresentation(SMESH_Actor::ePoint);
+    break;
+  }
+  case 3:{
+    float color[3];
+    theActor->GetSufaceColor(color[0], color[1], color[2]);
+    int c0 = int (color[0] * 255);
+    int c1 = int (color[1] * 255);
+    int c2 = int (color[2] * 255);
+    QColor c(c0, c1, c2);
+
+    float edgecolor[3];
+    theActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
+    c0 = int (edgecolor[0] * 255);
+    c1 = int (edgecolor[1] * 255);
+    c2 = int (edgecolor[2] * 255);
+    QColor e(c0, c1, c2);
+
+    float backfacecolor[3];
+    theActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
+    c0 = int (backfacecolor[0] * 255);
+    c1 = int (backfacecolor[1] * 255);
+    c2 = int (backfacecolor[2] * 255);
+    QColor b(c0, c1, c2);
+
+    float nodecolor[3];
+    theActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
+    c0 = int (nodecolor[0] * 255);
+    c1 = int (nodecolor[1] * 255);
+    c2 = int (nodecolor[2] * 255);
+    QColor n(c0, c1, c2);
+
+    int Edgewidth = (int)theActor->GetLineWidth();
+    if(Edgewidth == 0)
+      Edgewidth = 1;
+    int intValue = int(theActor->GetNodeSize());
+    float Shrink = theActor->GetShrinkFactor();
+
+    SMESHGUI_Preferences_ColorDlg *aDlg = new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),"");
+    aDlg->SetColor(1, c);
+    aDlg->SetColor(2, e);
+    aDlg->SetColor(3, n);
+    aDlg->SetColor(4, b);
+    aDlg->SetIntValue(1, Edgewidth);
+    aDlg->SetIntValue(2, intValue);
+    aDlg->SetIntValue(3, int(Shrink*100.));
+    if(aDlg->exec()){
+      QColor color = aDlg->GetColor(1);
+      QColor edgecolor = aDlg->GetColor(2);
+      QColor nodecolor = aDlg->GetColor(3);
+      QColor backfacecolor = aDlg->GetColor(4);
+      /* actor color and backface color */
+      theActor->SetSufaceColor(float (color.red()) / 255.,
+                              float (color.green()) / 255., 
+                              float (color.blue()) / 255.);
+      theActor->SetBackSufaceColor(float (backfacecolor.red()) / 255., 
+                                  float (backfacecolor.green()) / 255.,
+                                  float (backfacecolor.blue()) / 255.);
+
+      /* edge color */
+      theActor->SetEdgeColor(float (edgecolor.red()) / 255.,
+                            float (edgecolor.green()) / 255.,
+                            float (edgecolor.blue()) / 255.);
+      
+      /* Shrink factor and size edges */
+      theActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
+      theActor->SetLineWidth(aDlg->GetIntValue(1));
+      
+      /* Nodes color and size */
+      theActor->SetNodeColor(float (nodecolor.red()) / 255.,
+                            float (nodecolor.green()) / 255.,
+                            float (nodecolor.blue()) / 255.);
+      theActor->SetNodeSize(aDlg->GetIntValue(2));
+
+      delete aDlg;
+    }
+    break;
+  }
+  case 4:{
+    EmitSignalDeactivateDialog();
+    SMESHGUI_TransparencyDlg *aDlg = new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
+    break;
+  }
+  }
+  UpdateView();
 }
 
 //=============================================================================
@@ -1753,15 +1950,8 @@ void SMESHGUI::ChangeRepresentation(SMESH_Actor * ac, int type)
  *
  */
 //=============================================================================
-void SMESHGUI::UpdateView()
-{
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-
-       vtkRenderer *theRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-       theRenderer->Render();
+void SMESHGUI::UpdateView(){
+  ::RepaintCurrentView();
 }
 
 //=============================================================================
@@ -1769,91 +1959,9 @@ void SMESHGUI::UpdateView()
  *
  */
 //=============================================================================
-void SMESHGUI::DisplayActor(SMESH_Actor * ac, bool visibility)
-{
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-
-       MESSAGE("DisplayActor(): DataSource = " << ac->DataSource);
-
-       vtkRenderer *theRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-       vtkActorCollection *theActors = theRenderer->GetActors();
-       theActors->InitTraversal();
-       if (theActors->IsItemPresent(ac) == 0)
-       {
-               vtkProperty *prop = vtkProperty::New();
-               prop->SetColor(QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed").
-                       toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen").toFloat() /
-                       255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue").toFloat() /
-                       255.);
-
-               prop->SetPointSize(QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").
-                       toInt());
-               prop->SetLineWidth(QAD_CONFIG->getSetting("SMESH:SettingsWidth").
-                       toInt());
-               ac->SetProperty(prop);
-               ac->SetColor(QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed").
-                       toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen").toFloat() /
-                       255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue").toFloat() /
-                       255.);
-
-               //    prop->BackfaceCullingOn();
-               vtkProperty *backprop = vtkProperty::New();
-               backprop->SetColor(QAD_CONFIG->
-                       getSetting("SMESH:SettingsBackFaceColorRed").toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen").
-                       toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue").
-                       toFloat() / 255.);
-               ac->SetBackfaceProperty(backprop);
-
-               int intValue =
-                       QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff").toInt();
-               if (intValue == 0)
-                       intValue = 80;
-               ac->SetShrinkFactor(intValue / 100.);
-
-               ac->GetMapper()->SetResolveCoincidentTopologyToShiftZBuffer();
-               ac->GetMapper()->SetResolveCoincidentTopologyZShift(0.02);
-
-               QString DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
-               if (DisplayMode.compare("Wireframe") == 0)
-               {
-                       ac->setDisplayMode(0);
-                       ChangeRepresentation(ac, 0);
-               }
-               else if (DisplayMode.compare("Shading") == 0)
-               {
-                       ac->setDisplayMode(1);
-                       ChangeRepresentation(ac, 1);
-               }
-               else if (DisplayMode.compare("Shrink") == 0)
-               {
-                       ac->setDisplayMode(2);
-                       ChangeRepresentation(ac, 2);
-               }
-               theRenderer->AddActor(ac);
-       }
-       else
-       {
-               if (ac->GetMapper())
-                       ac->GetMapper()->Update();
-       }
-
-//  if ( visibility )
-       ac->SetVisibility(visibility);
-//    ac->VisibilityOn();
-//  else
-//    ac->VisibilityOff();
-
-       vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
-       renWin->Render();
+void SMESHGUI::DisplayActor(SMESH_Actor * theActor, bool theVisibility){
+  theActor->SetVisibility(theVisibility);
+  ::DisplayActor(myActiveStudy->getActiveStudyFrame(),theActor);
 }
 
 //=============================================================================
@@ -1861,22 +1969,8 @@ void SMESHGUI::DisplayActor(SMESH_Actor * ac, bool visibility)
  *
  */
 //=============================================================================
-void SMESHGUI::EraseActor(SMESH_Actor * ac)
-{
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-
-       vtkRenderer *theRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-
-       //NRI- : 02/12/2002 : Fixed bugId 882
-       //  ac->EdgeDevice->VisibilityOff();
-       //  ac->EdgeShrinkDevice->VisibilityOff();
-       //  ac->VisibilityOff();
-       ac->SetVisibility(false);
-
-       theRenderer->Render();
+void SMESHGUI::EraseActor(SMESH_Actor * theActor){
+  theActor->SetVisibility(false);
 }
 
 //=============================================================================
@@ -1942,113 +2036,118 @@ QString SMESHGUI::CheckHomogeneousSelection()
 //=============================================================================
 QString SMESHGUI::CheckTypeObject(const Handle(SALOME_InteractiveObject) & IO)
 {
-       SALOMEDS::SObject_var sobj =
-               smeshGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->
-               getEntry());
-       if (!sobj->_is_nil())
-       {
-               SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
-               if (strcmp(scomp->GetID(), IO->getEntry()) == 0)
-               {                                               // component is selected
-                       return "Component";
-               }
-       }
-
-       SALOME_Selection *Sel =
-               SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
-       Sel->ClearIObjects();
-
-       Handle(SMESH_TypeFilter) aHypFilter = new SMESH_TypeFilter(HYPOTHESIS);
-       Handle(SMESH_TypeFilter) anAlgoFilter = new SMESH_TypeFilter(ALGORITHM);
-       Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter(MESH);
-       Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter(SUBMESH);
-       Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter =
-               new SMESH_TypeFilter(MESHorSUBMESH);
-       Handle(SMESH_TypeFilter) aSubMeshVextexFilter =
-               new SMESH_TypeFilter(SUBMESH_VERTEX);
-       Handle(SMESH_TypeFilter) aSubMeshEdgeFilter =
-               new SMESH_TypeFilter(SUBMESH_EDGE);
-       Handle(SMESH_TypeFilter) aSubMeshFaceFilter =
-               new SMESH_TypeFilter(SUBMESH_FACE);
-       Handle(SMESH_TypeFilter) aSubMeshSolidFilter =
-               new SMESH_TypeFilter(SUBMESH_SOLID);
-       Handle(SMESH_TypeFilter) aSubMeshCompoundFilter =
-               new SMESH_TypeFilter(SUBMESH_COMPOUND);
-
-       Sel->AddFilter(aHypFilter);
-       if (Sel->AddIObject(IO) != -1)
-       {
-               Sel->ClearFilters();
-               return "Hypothesis";
-       }
-
-       Sel->ClearFilters();
-       Sel->AddFilter(anAlgoFilter);
-       if (Sel->AddIObject(IO) != -1)
-       {
-               Sel->ClearFilters();
-               return "Algorithm";
-       }
-
-       Sel->ClearFilters();
-       Sel->AddFilter(aMeshFilter);
-       if (Sel->AddIObject(IO) != -1)
-       {
-               Sel->ClearFilters();
-               return "Mesh";
-       }
-
-       Sel->ClearFilters();
-       Sel->AddFilter(aSubMeshFilter);
-       if (Sel->AddIObject(IO) != -1)
-       {
-               Sel->ClearFilters();
-               return "SubMesh";
-       }
-
-       Sel->ClearFilters();
-       Sel->AddFilter(aSubMeshVextexFilter);
-       if (Sel->AddIObject(IO) != -1)
-       {
-               Sel->ClearFilters();
-               return "SubMeshVertex";
-       }
-
-       Sel->ClearFilters();
-       Sel->AddFilter(aSubMeshEdgeFilter);
-       if (Sel->AddIObject(IO) != -1)
-       {
-               Sel->ClearFilters();
-               return "SubMeshEdge";
-       }
-
-       Sel->ClearFilters();
-       Sel->AddFilter(aSubMeshFaceFilter);
-       if (Sel->AddIObject(IO) != -1)
-       {
-               Sel->ClearFilters();
-               return "SubMeshFace";
-       }
+  SALOMEDS::SObject_var sobj = smeshGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry());
+  if (!sobj->_is_nil())        {
+    SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
+    if (strcmp(scomp->GetID(), IO->getEntry()) == 0)
+      {                                                // component is selected
+       return "Component";
+      }
+  }
+
+  SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+  Sel->ClearIObjects();
+
+  Handle(SMESH_TypeFilter) aHypFilter = new SMESH_TypeFilter(HYPOTHESIS);
+  Handle(SMESH_TypeFilter) anAlgoFilter = new SMESH_TypeFilter(ALGORITHM);
+  Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter(MESH);
+  Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter(SUBMESH);
+  Handle(SMESH_TypeFilter) aGroupFilter = new SMESH_TypeFilter(GROUP);
+  Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH);
+  Handle(SMESH_TypeFilter) aSubMeshVextexFilter = new SMESH_TypeFilter(SUBMESH_VERTEX);
+  Handle(SMESH_TypeFilter) aSubMeshEdgeFilter = new SMESH_TypeFilter(SUBMESH_EDGE);
+  Handle(SMESH_TypeFilter) aSubMeshFaceFilter =        new SMESH_TypeFilter(SUBMESH_FACE);
+  Handle(SMESH_TypeFilter) aSubMeshSolidFilter = new SMESH_TypeFilter(SUBMESH_SOLID);
+  Handle(SMESH_TypeFilter) aSubMeshCompoundFilter = new SMESH_TypeFilter(SUBMESH_COMPOUND);
+
+  Sel->AddFilter(aHypFilter);
+  if (Sel->AddIObject(IO) != -1) {
+    Sel->ClearFilters();
+    return "Hypothesis";
+  }
+
+  Sel->ClearFilters();
+  Sel->AddFilter(anAlgoFilter);
+  if (Sel->AddIObject(IO) != -1) {
+    Sel->ClearFilters();
+    return "Algorithm";
+  }
+
+  Sel->ClearFilters();
+  Sel->AddFilter(aMeshFilter);
+  if (Sel->AddIObject(IO) != -1) {
+    Sel->ClearFilters();
+    return "Mesh";
+  }
+
+  Sel->ClearFilters();
+  Sel->AddFilter(aSubMeshFilter);
+  if (Sel->AddIObject(IO) != -1) {
+    Sel->ClearFilters();
+    return "SubMesh";
+  }
+
+  Sel->ClearFilters();
+  Sel->AddFilter(aGroupFilter);
+  if (Sel->AddIObject(IO) != -1) {
+    Sel->ClearFilters();
+    return "Group";
+  }
+
+  Sel->ClearFilters();
+  Sel->AddFilter(aSubMeshVextexFilter);
+  if (Sel->AddIObject(IO) != -1) {
+    Sel->ClearFilters();
+    return "SubMeshVertex";
+  }
+
+  Sel->ClearFilters();
+  Sel->AddFilter(aSubMeshEdgeFilter);
+  if (Sel->AddIObject(IO) != -1) {
+    Sel->ClearFilters();
+    return "SubMeshEdge";
+  }
+
+  Sel->ClearFilters();
+  Sel->AddFilter(aSubMeshFaceFilter);
+  if (Sel->AddIObject(IO) != -1) {
+    Sel->ClearFilters();
+    return "SubMeshFace";
+  }
+
+  Sel->ClearFilters();
+  Sel->AddFilter(aSubMeshSolidFilter);
+  if (Sel->AddIObject(IO) != -1) {
+    Sel->ClearFilters();
+    return "SubMeshSolid";
+  }
+
+  Sel->ClearFilters();
+  Sel->AddFilter(aSubMeshCompoundFilter);
+  if (Sel->AddIObject(IO) != -1) {
+    Sel->ClearFilters();
+    return "SubMeshCompound";
+  }
+
+  Sel->ClearFilters();
+  Sel->AddIObject(IO);
+  return "NoType";
+}
 
-       Sel->ClearFilters();
-       Sel->AddFilter(aSubMeshSolidFilter);
-       if (Sel->AddIObject(IO) != -1)
-       {
-               Sel->ClearFilters();
-               return "SubMeshSolid";
-       }
 
-       Sel->ClearFilters();
-       Sel->AddFilter(aSubMeshCompoundFilter);
-       if (Sel->AddIObject(IO) != -1)
-       {
-               Sel->ClearFilters();
-               return "SubMeshCompound";
-       }
+static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
+  return theStudy->GetProperties()->IsLocked();
+}
 
-       Sel->ClearFilters();
-       Sel->AddIObject(IO);
-       return "NoType";
+static int checkLock(const SALOMEDS::Study_var& theStudy) {
+  if (isStudyLocked(theStudy)) {
+    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
+                          QObject::tr("WRN_WARNING"), 
+                          QObject::tr("WRN_STUDY_LOCKED"),
+                          QObject::tr("BUT_OK") );
+    return true;
+  }
+  return false;
 }
 
 //=============================================================================
@@ -2058,2437 +2157,948 @@ QString SMESHGUI::CheckTypeObject(const Handle(SALOME_InteractiveObject) & IO)
 //=============================================================================
 bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
 {
-       /* Create or retrieve an object SMESHGUI */
-       SMESHGUI::GetOrCreateSMESHGUI(parent);
-
-       // NRI : Temporary added
-       if (smeshGUI->myStudy->GetProperties()->IsLocked())
-       {
-               return false;
+  SALOMEDS::Study_var aStudy = smeshGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active
+  //  QAD_Viewer3d* v3d;
+  OCCViewer_Viewer3d *v3d;
+
+  Handle(AIS_InteractiveContext) ic;
+  vtkRenderer *Renderer;
+  vtkRenderWindow *RenWin;
+
+  if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
+    v3d = ((OCCViewer_ViewFrame *) smeshGUI->myActiveStudy->
+          getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+    ic = v3d->getAISContext();
+  }
+  else if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+    Renderer = ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
+               getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+    RenWin = Renderer->GetRenderWindow();
+  }
+
+  switch (theCommandID)        {
+  case 33:                                     // DELETE
+    if(checkLock(aStudy)) break;
+    smeshGUI->OnEditDelete();
+    break;
+    
+  case 113:                                    // IMPORT
+  case 112:
+  case 111:
+    {
+      if(checkLock(aStudy)) break;
+      //Import_Document(parent, theCommandID); //NBU
+      Import_Mesh(parent,theCommandID);
+      break;
+    }
+
+  case 122:                                    // EXPORT MED
+  case 121:
+  case 123:
+    {
+      Export_Mesh(parent, theCommandID);
+      break;
+    }
+
+  case 200:                                    // SCALAR BAR
+    {
+      SALOME_Selection *Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() );
+      if( Sel && Sel->IObjectCount() ) {
+       Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
+       if( anIO->hasEntry() ) {
+         if( SMESH_Actor* anActor = ::FindActorByEntry( anIO->getEntry() ) ) {
+           anActor->SetControlMode( SMESH_Actor::eNone );
+         }
+       }
+      }
+      break;
+    }
+  case 201:
+    {
+      SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() );
+      SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel );
+      break;
+    }
+
+  case 1133:                                   // DISPLAY MODE : WireFrame, Surface, Shrink
+  case 1132:
+  case 215:
+  case 213:
+  case 212:
+  case 211:
+    {
+      smeshGUI->SetViewMode(theCommandID);
+      break;
+    }
+
+  case 214:                                    // UPDATE
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->Update();
+      break;
+    }
+
+  case 300:                                    // ERASE
+  case 301:                                    // DISPLAY
+  case 302:                                    // DISPLAY ONLY
+    {
+      EDisplaing anAction;
+      switch(theCommandID){
+      case 300:        anAction = eErase; break;
+      case 301:        anAction = eDisplay; break;
+      case 302:        anAction = eDisplayOnly; break;
+      }
+      
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+       for (; It.More(); It.Next()) {
+         Handle(SALOME_InteractiveObject) IOS = It.Value();
+         if (IOS->hasEntry()) {
+           ::UpdateView(anAction,IOS->getEntry());
+         }
+       }
+      }
+      Sel->ClearIObjects();
+      break;
+    }
+
+  case 400:                                    // NODES
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       smeshGUI->EmitSignalDeactivateDialog();
+       SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+       Sel->ClearIObjects();
+       smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true);
+       smeshGUI->ViewNodes();
+       SMESHGUI_NodesDlg *aDlg = new SMESHGUI_NodesDlg(parent, "", Sel);
+      }
+      else {
+       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"), 
+                             tr("SMESH_WRN_VIEWER_VTK"),
+                             tr("SMESH_BUT_OK"));
+      }
+      break;
+    }
+
+  case 2151:  // FILTER
+  {
+    if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
+    {
+      smeshGUI->EmitSignalDeactivateDialog();
+      SMESHGUI_FilterDlg *aDlg = new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
+    }
+    break;
+  }
+    
+  case 405:                                    // MOVE NODE
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true);
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      SMESHGUI_MoveNodesDlg *aDlg = new SMESHGUI_MoveNodesDlg(parent, "", Sel);
+      break;
+    }
+    
+  case 701:                                    // COMPUTE MESH 
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+       int nbSel = Sel->IObjectCount();
+       if (nbSel != 1){
+         break;
        }
-       //NRI
-
-       //  QAD_Viewer3d* v3d;
-       OCCViewer_Viewer3d *v3d;
-
-       Handle(AIS_InteractiveContext) ic;
-       vtkRenderer *Renderer;
-       vtkRenderWindow *RenWin;
 
-       if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-               VIEW_OCC)
+       SMESH::SMESH_Mesh_var aMesh;
+       SMESH::SMESH_subMesh_var aSubMesh;
+       Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+       if (IObject->hasEntry()){
+         SALOMEDS::SObject_var aMeshSObj = smeshGUI->myStudy->FindObjectID(IObject->getEntry());
+         GEOM::GEOM_Shape_var aShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh( aMeshSObj );
+         if ( aShape->_is_nil() ) {
+           // imported mesh
+           break;
+         }
+         SALOMEDS::GenericAttribute_var anAttr;
+         if(!aMeshSObj->_is_nil() && aMeshSObj->FindAttribute(anAttr, "AttributeIOR")){
+           SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+           MESSAGE("SMESHGUI::OnGUIEvent - Compute mesh : IOR = "<< anIOR->Value());
+           CORBA::Object_var anObj;
+           try{
+             anObj = _orb->string_to_object(anIOR->Value());
+             if (CORBA::is_nil(anObj)){
+               MESSAGE("SMESHGUI::OnGUIEvent - Compute mesh : nil object");
+             }
+           }catch(CORBA::COMM_FAILURE & ex){
+             INFOS("SMESHGUI::OnGUIEvent - Compute mesh : exception (1)");
+           }
+           aMesh = SMESH::SMESH_Mesh::_narrow(anObj);
+           aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj);
+           if (!aMesh->_is_nil()){
+             GEOM::GEOM_Shape_var refShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(aMeshSObj);
+             if (!refShape->_is_nil()) {
+               if(!smeshGUI->myComponentMesh->IsReadyToCompute(aMesh,refShape)){
+                 QAD_MessageBox::warn1(QAD_Application::getDesktop(), 
+                                       tr("SMESH_WRN_WARNING"),
+                                       tr("SMESH_WRN_MISSING_PARAMETERS"),
+                                       tr("SMESH_BUT_OK"));
+                 break;
+               }
+               try{
+                 if (smeshGUI->myComponentMesh->Compute(aMesh,refShape))
+                    smeshGUI->myStudyAPI.ModifiedMesh(aMeshSObj,true);
+                 // TO Do : change icon of all submeshes
+               }
+               catch(const SALOME::SALOME_Exception & S_ex){
+                 QtCatchCorbaException(S_ex);
+               }
+             }
+           }else if(!aSubMesh->_is_nil()){
+             aMesh = aSubMesh->GetFather();
+             GEOM::GEOM_Shape_var refShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(aMeshSObj);
+             if(!refShape->_is_nil()){
+               bool compute = smeshGUI->myComponentMesh->IsReadyToCompute(aMesh,refShape);
+               if(!compute){
+                 QAD_MessageBox::warn1(QAD_Application::getDesktop(), 
+                                       tr("SMESH_WRN_WARNING"),
+                                       tr("SMESH_WRN_MISSING_PARAMETERS"),
+                                       tr("SMESH_BUT_OK"));
+                 break;
+               }
+               try{
+                 if ( smeshGUI->myComponentMesh->Compute(aMesh,refShape) )
+                    smeshGUI->myStudyAPI.ModifiedMesh(aMeshSObj,true);
+                 // TO Do : change icon of all submeshes
+               }catch(const SALOME::SALOME_Exception & S_ex){
+                 QtCatchCorbaException(S_ex);
+               }
+             }
+           }
+         }
+       }
+       CORBA::Long anId = smeshGUI->myStudy->StudyId();
+       TVisualObjPtr aVisualObj = GetVisualObj(anId,IObject->getEntry());
+       if(smeshGUI->myAutomaticUpdate && aVisualObj){
+         aVisualObj->Update();
+         SMESH_Actor* anActor = ::FindActorByEntry(IObject->getEntry());
+         if(!anActor){
+           anActor = ::CreateActor(smeshGUI->myStudy,IObject->getEntry());
+           if(anActor){
+             ::DisplayActor(smeshGUI->myActiveStudy->getActiveStudyFrame(),anActor); //apo
+             ::FitAll();
+           }
+         }
+       }
+      }else{
+       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"), 
+                             tr("SMESH_WRN_VIEWER_VTK"),
+                             tr("SMESH_BUT_OK"));
+      }
+      break;
+    }
+
+  case 702:                                    // ADD SUB MESH 
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       smeshGUI->EmitSignalDeactivateDialog();
+       SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+       SMESHGUI_AddSubMeshDlg *aDlg = new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
+      }
+      else {
+       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
+                             tr("SMESH_BUT_OK"));
+      }
+      break;
+    }
+    
+  case 703:                                    // INIT MESH 
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg(parent, "", Sel);
+      break;
+    }
+
+  case 704:                                    // EDIT Hypothesis 
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
+      break;
+    }
+
+  case 705:                                    //  EDIT Global Hypothesis
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
+      break;
+    }
+
+  case 706:                                    //  EDIT Local Hypothesis
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
+      break;
+    }
+
+  case 406:                                    // ORIENTATION ELEMENTS
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      smeshGUI->myDesktop->SetSelectionMode(FaceSelection, true);
+      SMESHGUI_OrientationElementsDlg *aDlg = new SMESHGUI_OrientationElementsDlg(parent, "", Sel);
+      break;
+    }
+
+  case 407:                                    // DIAGONAL INVERSION
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      Sel->ClearIObjects();
+      smeshGUI->myDesktop->SetSelectionMode(EdgeOfCellSelection, true);
+      SMESHGUI_DiagonalInversionDlg *aDlg = new SMESHGUI_DiagonalInversionDlg(parent, "", Sel);
+      break;
+    }
+
+  case 801:                                     // CREATE GROUP
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      int nbSel = Sel->IObjectCount();
+      if (nbSel == 1) {
+       // check if mesh is selected
+       Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+       if (IObject->hasEntry()) {
+         SALOMEDS::SObject_var aMeshSObj = smeshGUI->myStudy->FindObjectID(IObject->getEntry());
+         if (!aMeshSObj->_is_nil()) {
+           CORBA::Object_var anObj = aMeshSObj->GetObject();
+           SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj);
+           SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj);
+           if (aMesh->_is_nil() && !aSubMesh->_is_nil()) {
+             aMesh = aSubMesh->GetFather();
+           }
+           if (!aMesh->_is_nil()) {
+             SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh);
+             aDlg->show();
+           }
+         }
+       }
+      }
+      break;
+    }
+
+  case 802:                                     // CONSTRUCT GROUP
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      int nbSel = Sel->IObjectCount();
+      if (nbSel == 1) {
+       // check if submesh is selected
+       Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+       if (IObject->hasEntry()) {
+         SALOMEDS::SObject_var aSObj = smeshGUI->myStudy->FindObjectID(IObject->getEntry());
+         if(!aSObj->_is_nil()) {
+           SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject());
+           if (!aSubMesh->_is_nil()) {
+             try {
+               SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
+               // get submesh elements list by types
+               SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
+               SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
+               SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
+               SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
+               // create group for each type o elements
+               QString aName = IObject->getName();
+               MESSAGE("SMESHGUI::OnGUIEvent - Construct group on submesh : "<<aName);
+               MESSAGE(" Number of elements : nodes "<<aNodes->length() << ", edges " << aEdges->length()
+                       << ", faces " << aFaces->length() << ", volumes " << aVolumes->length());
+               if (aNodes->length() > 0) {
+                 SMESH::SMESH_Group_var aGroup = smeshGUI->AddGroup(aMesh, SMESH::NODE, aName);
+                 aGroup->Add(aNodes);
+               }
+               if (aEdges->length() > 0) {
+                 SMESH::SMESH_Group_var aGroup = smeshGUI->AddGroup(aMesh, SMESH::EDGE, aName);
+                 aGroup->Add(aEdges);
+               }
+               if (aFaces->length() > 0) {
+                 SMESH::SMESH_Group_var aGroup = smeshGUI->AddGroup(aMesh, SMESH::FACE, aName);
+                 aGroup->Add(aFaces);
+               }
+               if (aVolumes->length() > 0) {
+                 SMESH::SMESH_Group_var aGroup = smeshGUI->AddGroup(aMesh, SMESH::VOLUME, aName);
+                 aGroup->Add(aVolumes);
+               }
+               smeshGUI->myActiveStudy->updateObjBrowser(true);
+             }catch(const SALOME::SALOME_Exception & S_ex){
+               QtCatchCorbaException(S_ex);
+             }
+           }
+         }
+       }
+      }
+      break;
+    }
+
+  case 803:                                     // EDIT GROUP
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      int nbSel = Sel->IObjectCount();
+      if (nbSel == 1) {
+       // check if group is selected
+       Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+       if (IObject->hasEntry()) {
+         SALOMEDS::SObject_var aSObj = smeshGUI->myStudy->FindObjectID(IObject->getEntry());
+         if(!aSObj->_is_nil()) {
+           SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow(aSObj->GetObject());
+           if (!aGroup->_is_nil()) {
+             SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup);
+             aDlg->show();
+           }
+         }
+       }
+      }
+      break;
+    }
+
+  case 804:                                     // Add elements to group
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myState == 800) {
+       SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) smeshGUI->myActiveDialogBox;
+       if (aDlg) aDlg->onAdd();
+      }
+      break;
+    }
+
+  case 805:                                     // Remove elements from group
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myState == 800) {
+       SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) smeshGUI->myActiveDialogBox;
+       if (aDlg) aDlg->onRemove();
+      }
+      break;
+    }
+
+  case 900:                                    // MESH INFOS
+    {
+      smeshGUI->EmitSignalDeactivateDialog();
+      SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg(parent, "", false);
+      break;
+    }
+
+  case 1001:                                   // AUTOMATIC UPDATE PREFERENCES
+    {
+      parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001));
+      if (parent->menuBar()->isItemChecked(1001)) {
+       QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
+       smeshGUI->myAutomaticUpdate = true;
+      }
+      else {
+       QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
+       smeshGUI->myAutomaticUpdate = false;
+      }
+      break;
+    }
+
+  case 1003:                                   // MESH PREFERENCES
+    {
+      smeshGUI->SetDisplaySettings();
+      break;
+    }
+
+  case 1005:
+    {
+      SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent );
+      break;
+    }
+
+  case 1006: 
+    {
+      SMESHGUI_Preferences_SelectionDlg* aDlg = 
+       new SMESHGUI_Preferences_SelectionDlg(parent);
+
+      QColor aColor;
+      QString SCr, SCg, SCb;
+      SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed");
+      SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen");
+      SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue");
+      if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
+       aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
+      else aColor = Qt::cyan;
+      aDlg->SetColor(1, aColor);
+
+      SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed");
+      SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen");
+      SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue");
+      if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
+       aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
+      else aColor = Qt::yellow;
+      aDlg->SetColor(2, aColor);
+
+      SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed");
+      SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen");
+      SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue");
+      if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
+       aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
+      else aColor = Qt::white;
+      aDlg->SetColor(3, aColor);
+
+      QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth");
+      if (SW1.isEmpty()) SW1 = "5";
+      aDlg->SetWidth(1, SW1.toInt());
+
+      QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth");
+      if (SW2.isEmpty()) SW2 = "5";
+      aDlg->SetWidth(2, SW2.toInt());
+
+      QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol");
+      if (SP1.isEmpty()) SP1 = "0.025";
+      aDlg->SetPrecision(1, SP1.toDouble());
+
+      QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol");
+      if (SP2.isEmpty()) SP2 = "0.001";
+      aDlg->SetPrecision(2, SP2.toDouble());
+
+      if (aDlg->exec()) {
+       QColor aPreColor = aDlg->GetColor(1);
+       QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red());
+       QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green());
+       QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue());
+
+       QColor aSelColor = aDlg->GetColor(2);
+       QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red());
+       QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green());
+       QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue());
+
+       QColor aHiColor = aDlg->GetColor(3);
+       QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red());
+       QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green());
+       QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue());
+
+       int aPreWidth = aDlg->GetWidth(1);
+       QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth);
+       int aSelWidth = aDlg->GetWidth(2);
+       QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth);
+
+       double aTolNodes = aDlg->GetPrecision(1);
+       QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes);
+       double aTolItems = aDlg->GetPrecision(2);
+       QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems);
+
+       // update current study settings
+       ::UpdateSelectionProp();
+
+       QAD_StudyFrame* studyFrame = smeshGUI->myActiveStudy->getActiveStudyFrame();
+       if (studyFrame->getTypeView() == VIEW_VTK) {
+         VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(studyFrame);
+         // update VTK viewer properties
+         VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor();
+         if (anInteractor) {
+           anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255., 
+                                          aSelColor.blue()/255., aSelWidth);
+           anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
+           VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
+           if (aStyle)
+             aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255., 
+                                         aPreColor.blue()/255., aPreWidth);
+         }
+         // update actors
+         vtkRenderer* aRenderer = aViewFrame->getRenderer();
+         vtkActorCollection *aCollection = aRenderer->GetActors();
+         aCollection->InitTraversal();
+         while(vtkActor *anAct = aCollection->GetNextActor()){
+           if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
+             anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255., 
+                                        aHiColor.blue()/255.);
+             anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255., 
+                                           aPreColor.blue()/255.);
+           }
+         }
+       }
+      }
+
+      break;
+    }
+
+  case 1100:                                   // EDIT HYPOTHESIS
+    {
+      if(checkLock(aStudy)) break;
+      SALOME_Selection *Sel =
+        SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      int nbSel = Sel->IObjectCount();
+
+      if (nbSel == 1) {
+        Standard_Boolean res;
+        SMESH::SMESH_Hypothesis_var Hyp =
+          smeshGUI->ConvertIOinSMESHHypothesis(Sel->firstIObject(), res);
+
+        /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
+        /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects                   */
+        /* Warning : however by internal mechanism all subMeshes icons are changed !                     */
+        if ( res )
+        {
+          char* sName = Hyp->GetName();
+          SMESHGUI_GenericHypothesisCreator* aCreator = smeshGUI->GetHypothesisCreator(sName);
+          if (aCreator)
+          {
+            aCreator->EditHypothesis(Hyp);
+          }
+          else
+          {
+            // report error
+          }
+        }
+      }
+      break;
+    }
+
+  case 1101:                                   // RENAME
+    {
+      if(checkLock(aStudy)) break;
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+      for (; It.More(); It.Next()) {
+       Handle(SALOME_InteractiveObject) IObject = It.Value();
+
+       SALOMEDS::SObject_var obj = smeshGUI->myStudy->FindObjectID(IObject->getEntry());
+       SALOMEDS::GenericAttribute_var anAttr;
+       SALOMEDS::AttributeName_var aName;
+       if (!obj->_is_nil()) {
+         if (obj->FindAttribute(anAttr, "AttributeName")) {
+           aName = SALOMEDS::AttributeName::_narrow(anAttr);
+           QString newName = QString(aName->Value());
+           newName = SALOMEGUI_NameDlg::getName(QAD_Application::getDesktop(), newName);
+           if (!newName.isEmpty()) {
+             smeshGUI->myActiveStudy->renameIObject(IObject, newName);
+           }
+         }
+       }
+      }
+      break;
+    }
+    
+  case 1102:                                   // REMOVE HYPOTHESIS / ALGORITHMS
+    {
+      if(checkLock(aStudy)) break;
+      QAD_WaitCursor wc;
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+      for (int i = 0; It.More(); It.Next(), i++) {
+       Handle(SALOME_InteractiveObject) IObject = It.Value();
+       smeshGUI->RemoveHypothesisOrAlgorithmOnMesh(IObject);
+      }
+      Sel->ClearIObjects();
+      smeshGUI->myActiveStudy->updateObjBrowser(true);
+      break;
+    }
+
+  case 401:                                    // GEOM::EDGE
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       smeshGUI->EmitSignalDeactivateDialog();
+       SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+       Sel->ClearIObjects();
+       smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true);
+       smeshGUI->ViewNodes();
+       SMESHGUI_AddEdgeDlg *aDlg = new SMESHGUI_AddEdgeDlg(parent, "", Sel);
+      }
+      else {
+       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
+                             tr("SMESH_BUT_OK"));
+      }
+      break;
+    }
+  case 4021:                                   // TRIANGLE
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       smeshGUI->EmitSignalDeactivateDialog();
+       SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+       Sel->ClearIObjects();
+       smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true);
+       smeshGUI->ViewNodes();
+       SMESHGUI_AddFaceDlg *aDlg = new SMESHGUI_AddFaceDlg(parent, "", Sel, 3);
+      }
+      else {
+       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
+                             tr("SMESH_BUT_OK"));
+      }
+      break;
+    }
+  case 4022:                                   // QUAD
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       smeshGUI->EmitSignalDeactivateDialog();
+       SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+       Sel->ClearIObjects();
+       smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true);
+       smeshGUI->ViewNodes();
+       SMESHGUI_AddFaceDlg *aDlg = new SMESHGUI_AddFaceDlg(parent, "", Sel, 4);
+      }
+      else
        {
-               v3d =
-                       ((OCCViewer_ViewFrame *) smeshGUI->myActiveStudy->
-                       getActiveStudyFrame()->getRightFrame()->getViewFrame())->
-                       getViewer();
-               ic = v3d->getAISContext();
-       }
-       else if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-               VIEW_VTK)
+         QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
+                               tr("SMESH_BUT_OK"));
+       }
+      break;
+    }
+  case 4031:                                   // TETRA
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       smeshGUI->EmitSignalDeactivateDialog();
+       SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+       Sel->ClearIObjects();
+       smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true);
+       smeshGUI->ViewNodes();
+       SMESHGUI_AddVolumeDlg *aDlg = new SMESHGUI_AddVolumeDlg(parent, "", Sel, 4);
+      }
+      else {
+       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
+                             tr("SMESH_BUT_OK"));
+      }
+      break;
+    }
+  case 4032:                                   // HEXA
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       smeshGUI->EmitSignalDeactivateDialog();
+       SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+       Sel->ClearIObjects();
+       smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true);
+       smeshGUI->ViewNodes();
+       SMESHGUI_AddVolumeDlg *aDlg = new SMESHGUI_AddVolumeDlg(parent, "", Sel, 8);
+      }
+      else {
+       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
+                             tr("SMESH_BUT_OK"));
+      }
+      break;
+    }
+
+  case 4041:                                   // REMOVES NODES
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       smeshGUI->EmitSignalDeactivateDialog();
+       SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+       Sel->ClearIObjects();
+       smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true);
+       smeshGUI->ViewNodes();
+       SMESHGUI_RemoveNodesDlg *aDlg = new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
+      }
+      else {
+       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
+                             tr("SMESH_BUT_OK"));
+      }
+      break;
+    }
+  case 4042:                                   // REMOVES ELEMENTS
+    {
+      if(checkLock(aStudy)) break;
+      if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+       smeshGUI->EmitSignalDeactivateDialog();
+       SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+       Sel->ClearIObjects();
+       smeshGUI->myDesktop->SetSelectionMode(CellSelection, true);
+       SMESHGUI_RemoveElementsDlg *aDlg = new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
+      }
+      else
        {
-               Renderer =
-                       ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
-                       getActiveStudyFrame()->getRightFrame()->getViewFrame())->
-                       getRenderer();
-               RenWin = Renderer->GetRenderWindow();
-       }
+         QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
+                               tr("SMESH_BUT_OK"));
+       }
+      break;
+    }
+
+  case 5000: // HYPOTHESIS
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SMESHGUI_CreateHypothesesDlg *aDlg =
+        new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
+      break;
+    }
+  case 5010: // ALGO
+    {
+      if(checkLock(aStudy)) break;
+      smeshGUI->EmitSignalDeactivateDialog();
+      SMESHGUI_CreateHypothesesDlg *aDlg =
+        new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
+      break;
+    }
+
+  case 6016:                                   // CONTROLS 
+  case 6015:
+  case 6014:
+  case 6013:
+  case 6012:
+  case 6011:
+  case 6001:
+  case 6003:
+  case 6004:    
+    if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) {
+       SALOMEDS::SObject_var SO = smeshGUI->myStudy->FindObjectID( Sel->firstIObject()->getEntry() );
+       if ( !SO->_is_nil() ) {
+         CORBA::Object_var aObject = SO->GetObject();
+         SMESH::SMESH_Mesh_var    aMesh    = SMESH::SMESH_Mesh::_narrow( aObject );
+         SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
+         SMESH::SMESH_Group_var   aGroup   = SMESH::SMESH_Group::_narrow( aObject );
+         if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
+           smeshGUI->Control( theCommandID );
+           break;
+         }
+       }
+      }
+      QAD_MessageBox::warn1(smeshGUI->GetDesktop(), 
+                           tr( "SMESH_WRN_WARNING" ),
+                           tr( "SMESH_BAD_SELECTION" ), 
+                           tr( "SMESH_BUT_OK" ) );
+      break;
+    }
+    else {
+      QAD_MessageBox::warn1(smeshGUI->GetDesktop(), 
+                           tr( "SMESH_WRN_WARNING" ),
+                           tr( "NOT_A_VTK_VIEWER" ), 
+                           tr( "SMESH_BUT_OK" ) );
+    }
+    break;
+  case 9010:
+    {
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      if (Sel->IObjectCount() == 1)    {
+       Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
+       if(anIObject->hasEntry())
+         if(SMESH_Actor *anActor = ::FindActorByEntry(anIObject->getEntry())){
+           anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
+         }
+      }
+      break;
+    }
+  case 9011:
+    {
+      SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+      if (Sel->IObjectCount() == 1)    {
+       Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
+       if(anIObject->hasEntry())
+         if(SMESH_Actor *anActor = ::FindActorByEntry(anIObject->getEntry())){
+           anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
+         }
+      }
+      break;
+    }
+  case 10001:                          // DISPLAY MODE PREFERENCE
+    {
+      // Wireframe
+      parent->menuBar()->setItemChecked(10001, true);
+      parent->menuBar()->setItemChecked(10002, false);
+      parent->menuBar()->setItemChecked(10004, false);
+      parent->menuBar()->setItemEnabled(10003, true);
+      QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
+      break;
+    }
+  case 10002:
+    {
+      parent->menuBar()->setItemChecked(10002, true);
+      parent->menuBar()->setItemChecked(10001, false);
+      parent->menuBar()->setItemChecked(10004, false);
+      parent->menuBar()->setItemEnabled(10003, true);
+      QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
+      break;
+    }
+  case 10003:
+    {
+      parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003));
+      QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no");
+      break;
+    }
+  case 10004:
+    {
+      parent->menuBar()->setItemChecked(10001, false);
+      parent->menuBar()->setItemChecked(10004, true);
+      parent->menuBar()->setItemChecked(10002, false);
+      parent->menuBar()->setItemEnabled(10003, false);
+      QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes");
+      break;
+    }
+    
+  }
+
+  smeshGUI->myActiveStudy->updateObjBrowser(true);
+  return true;
+}
 
-       switch (theCommandID)
-       {
-       case 33:                                        // DELETE
-               smeshGUI->OnEditDelete();
-               break;
-
-       case 113:                                       // IMPORT
-       case 112:
-       case 111:
-       {
-               Import_Document(parent, theCommandID);  //NBU
-               //Import_Mesh(parent,theCommandID);
-               break;
-       }
-
-       case 122:                                       // EXPORT MED
-       case 121:
-       case 123:
-       {
-               Export_Mesh(parent, theCommandID);
-               break;
-       }
-
-       case 200:                                       // SCALAR BAR
-       {
-               smeshGUI->DisplayScalarBar(false);
-               break;
-       }
-       case 201:
-       {
-               SMESHGUI_EditScalarBarDlg *aDlg =
-                       new SMESHGUI_EditScalarBarDlg(parent, "", false);
-               aDlg->show();
-               break;
-       }
-       case 202:
-       {
-               smeshGUI->DisplayScalarBar(true);
-               break;
-       }
-
-       case 1133:                                      // DISPLAY MODE : WireFrame, Surface, Shrink
-       case 1132:
-       case 213:
-       case 212:
-       case 211:
-       {
-               smeshGUI->SetViewMode(theCommandID);
-               break;
-       }
-
-       case 214:                                       // UPDATE
-       {
-               smeshGUI->Update();
-               break;
-       }
-
-       case 300:                                       // ERASE
-       {
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {
-                       // VTK
-                       SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-                       for (; It.More(); It.Next())
-                       {
-                               Handle(SALOME_InteractiveObject) IOS = It.Value();
-                               if (IOS->hasEntry())
-                               {
-                                       Standard_Boolean res;
-                                       SMESH_Actor *ac =
-                                               smeshGUI->FindActorByEntry(IOS->getEntry(), res, true);
-                                       if (res)
-                                               smeshGUI->EraseActor(ac);
-                               }
-                       }
-               }
-               Sel->ClearIObjects();
-               smeshGUI->myActiveStudy->updateObjBrowser(true);
-       }
-
-       case 301:                                       // DISPLAY
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {
-                       // VTK
-                       QApplication::setOverrideCursor(Qt::waitCursor);
-                       SALOMEDS::SObject_var fatherSF =
-                               smeshGUI->myStudy->FindObjectID(smeshGUI->myActiveStudy->
-                               getActiveStudyFrame()->entry());
-
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-
-                       for (; It.More(); It.Next())
-                       {
-                               Handle(SALOME_InteractiveObject) IObject = It.Value();
-                               if (IObject->hasEntry())
-                               {
-                                       Standard_Boolean res;
-                                       SMESH_Actor *ac =
-                                               smeshGUI->FindActorByEntry(IObject->getEntry(), res,
-                                               false);
-                                       if (res)
-                                       {
-                                               smeshGUI->DisplayActor(ac, true);
-                                               smeshGUI->DisplayEdges(ac);
-                                               smeshGUI->ChangeRepresentation(ac,
-                                                       ac->getDisplayMode());
-                                       }
-                               }
-                       }
-                       QApplication::restoreOverrideCursor();
-               }
-               break;
-       }
-
-       case 302:                                       // DISPLAY ONLY
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {
-                       QApplication::setOverrideCursor(Qt::waitCursor);
-                       vtkActorCollection *theActors = Renderer->GetActors();
-                       theActors->InitTraversal();
-                       vtkActor *ac = theActors->GetNextActor();
-                       while (!(ac == NULL))
-                       {
-                               if (ac->IsA("SMESH_Actor"))
-                               {
-                                       SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
-                                       if (!anActor->isHighlighted())
-                                       {
-                                               //anActor->VisibilityOff();
-                                               //NRI- : 02/12/2002 : Fixed bugId 882
-                                               //      anActor->EdgeDevice->VisibilityOff();
-                                               //      anActor->EdgeShrinkDevice->VisibilityOff();
-                                               anActor->SetVisibility(false);
-                                       }
-                               }
-                               ac = theActors->GetNextActor();
-                       }
-
-                       // Display selection
-                       SALOMEDS::SObject_var fatherSF =
-                               smeshGUI->myStudy->FindObjectID(smeshGUI->myActiveStudy->
-                               getActiveStudyFrame()->entry());
-
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-
-                       for (; It.More(); It.Next())
-                       {
-                               Handle(SALOME_InteractiveObject) IObject = It.Value();
-                               SALOMEDS::SObject_var obj =
-                                       smeshGUI->myStudy->FindObjectID(IObject->getEntry());
-
-                               VTKViewer_RenderWindowInteractor *myRenderInter =
-                                       ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
-                                       getActiveStudyFrame()->getRightFrame()->getViewFrame())->
-                                       getRWInteractor();
-                               //      vtkQGLRenderWindowInteractor* myRenderInter= smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor();
-
-                               if (myRenderInter->isInViewer(IObject))
-                               {
-                                       if (IObject->hasEntry())
-                                       {
-                                               Standard_Boolean res;
-                                               SMESH_Actor *ac =
-                                                       smeshGUI->FindActorByEntry(IObject->getEntry(), res,
-                                                       true);
-                                               if (res)
-                                               {
-                                                       smeshGUI->DisplayActor(ac, true);
-                                                       smeshGUI->DisplayEdges(ac);
-                                                       smeshGUI->ChangeRepresentation(ac,
-                                                               ac->getDisplayMode());
-                                               }
-                                       }
-                               }
-                       }
-                       smeshGUI->myActiveStudy->updateObjBrowser(true);
-                       QApplication::restoreOverrideCursor();
-               }
-               break;
-       }
-
-       case 400:                                       // NODES
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       smeshGUI->EmitSignalDeactivateDialog();
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       Sel->ClearIObjects();
-                       smeshGUI->myDesktop->SetSelectionMode(1, true);
-                       parent->menuBar()->setItemChecked(9010, false);
-                       parent->menuBar()->setItemChecked(9011, false);
-                       smeshGUI->ViewNodes();
-                       SMESHGUI_NodesDlg *aDlg = new SMESHGUI_NodesDlg(parent, "", Sel);
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               break;
-       }
-
-       case 405:                                       // MOVE NODE
-       {
-               smeshGUI->myDesktop->SetSelectionMode(1, true);
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SMESHGUI_MoveNodesDlg *aDlg =
-                       new SMESHGUI_MoveNodesDlg(parent, "", Sel);
-               break;
-       }
-
-       case 701:                                       // COMPUTE MESH 
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       int nbSel = Sel->IObjectCount();
-                       if (nbSel != 1)
-                       {
-                               QApplication::restoreOverrideCursor();
-                               break;
-                       }
-
-                       SMESH::SMESH_Mesh_var aM;
-                       SMESH::SMESH_subMesh_var aSubM;
-                       Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
-                       if (IObject->hasEntry())
-                       {
-                               SALOMEDS::SObject_var aMorSM =
-                                       smeshGUI->myStudy->FindObjectID(IObject->getEntry());
-                               SALOMEDS::GenericAttribute_var anAttr;
-                               SALOMEDS::AttributeIOR_var anIOR;
-                               if (!aMorSM->_is_nil())
-                               {
-                                       if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
-                                       {
-                                               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                                               MESSAGE("SMESHGUI::OnGUIEvent - Compute mesh : IOR = "
-                                                       << anIOR->Value())CORBA::Object_var cobj;
-                                               try
-                                               {
-                                                       cobj = _orb->string_to_object(anIOR->Value());
-                                                       if (CORBA::is_nil(cobj))
-                                                       {
-                                                       MESSAGE
-                                                                       ("SMESHGUI::OnGUIEvent - Compute mesh : nil object")}
-                                               }
-                                               catch(CORBA::COMM_FAILURE & ex)
-                                               {
-                                               MESSAGE
-                                                               ("SMESHGUI::OnGUIEvent - Compute mesh : exception (1)")}
-                                               aM = SMESH::SMESH_Mesh::_narrow(cobj);
-                                               //aM = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) );
-                                               aSubM =
-                                                       SMESH::SMESH_subMesh::_narrow(_orb->
-                                                       string_to_object(anIOR->Value()));
-                                               if (!aM->_is_nil())
-                                               {
-                                                       GEOM::GEOM_Shape_var refShape =
-                                                               smeshGUI->myStudyAPI.
-                                                               GetShapeOnMeshOrSubMesh(aMorSM);
-                                                       if (!refShape->_is_nil())
-                                                       {
-                                                               bool compute =
-                                                                       smeshGUI->myComponentMesh->
-                                                                       IsReadyToCompute(aM, refShape);
-                                                               if (!compute)
-                                                               {
-                                                                       QApplication::restoreOverrideCursor();
-                                                                       QAD_MessageBox::warn1(QAD_Application::
-                                                                               getDesktop(), tr("SMESH_WRN_WARNING"),
-                                                                               tr("SMESH_WRN_MISSING_PARAMETERS"),
-                                                                               tr("SMESH_BUT_YES"));
-                                                                       break;
-                                                               }
-                                                               try
-                                                               {
-                                                                       smeshGUI->myComponentMesh->Compute(aM,
-                                                                               refShape);
-                                                                       smeshGUI->myStudyAPI.ModifiedMesh(aMorSM,
-                                                                               true);
-                                                                       // TO Do : change icon of all submeshes
-                                                               }
-                                                               catch(const SALOME::SALOME_Exception & S_ex)
-                                                               {
-                                                                       QtCatchCorbaException(S_ex);
-                                                               }
-                                                       }
-                                               }
-                                               else if (!aSubM->_is_nil())
-                                               {
-                                                       aM = aSubM->GetFather();
-                                                       GEOM::GEOM_Shape_var refShape =
-                                                               smeshGUI->myStudyAPI.
-                                                               GetShapeOnMeshOrSubMesh(aMorSM);
-                                                       if (!refShape->_is_nil())
-                                                       {
-                                                               bool compute =
-                                                                       smeshGUI->myComponentMesh->
-                                                                       IsReadyToCompute(aM, refShape);
-                                                               if (!compute)
-                                                               {
-                                                                       QApplication::restoreOverrideCursor();
-                                                                       QAD_MessageBox::warn1(QAD_Application::
-                                                                               getDesktop(), tr("SMESH_WRN_WARNING"),
-                                                                               tr("SMESH_WRN_MISSING_PARAMETERS"),
-                                                                               tr("SMESH_BUT_YES"));
-                                                                       break;
-                                                               }
-                                                               try
-                                                               {
-                                                                       smeshGUI->myComponentMesh->Compute(aM,
-                                                                               refShape);
-                                                                       smeshGUI->myStudyAPI.ModifiedMesh(aMorSM,
-                                                                               true);
-                                                                       // TO Do : change icon of all submeshes
-                                                               }
-                                                               catch(const SALOME::SALOME_Exception & S_ex)
-                                                               {
-                                                                       QtCatchCorbaException(S_ex);
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-
-                       // Check whether the actor for the mesh exists at least in one view
-                       Standard_Boolean res;
-                       SMESH_Actor *ac =
-                               smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
-                       if (!res)
-                               smeshGUI->InitActor(aM);
-                       else
-                       {
-                               // Check whether the actor belongs to the active view
-                               VTKViewer_RenderWindowInteractor *rwInter =
-                                       ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
-                                       getActiveStudyFrame()->getRightFrame()->getViewFrame())->
-                                       getRWInteractor();
-
-                               // The actor belongs to inactive view -> create a copy and add it in the active view
-                               if (!rwInter->isInViewer(IObject))
-                               {
-                                       SMESH_Actor *acCopy = SMESH_Actor::New();
-                                       acCopy->ShallowCopy(ac);
-
-                                       smeshGUI->DisplayActor(acCopy, false);
-                               }
-                       }
-
-                       if (smeshGUI->myAutomaticUpdate)
-                       {
-                               SMESH_Actor *Mesh = smeshGUI->ReadScript(aM);
-                               if (Mesh != NULL)
-                               {
-#ifdef TRACE
-                                       Dump(Mesh);
-#endif
-                                       smeshGUI->DisplayActor(Mesh, true);
-                                       smeshGUI->DisplayEdges(Mesh, true);
-                                       smeshGUI->ChangeRepresentation(Mesh,
-                                               Mesh->getDisplayMode());
-                               }
-                       }
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               QApplication::restoreOverrideCursor();
-               break;
-       }
-
-       case 702:                                       // ADD SUB MESH 
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       smeshGUI->EmitSignalDeactivateDialog();
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       SMESHGUI_AddSubMeshDlg *aDlg =
-                               new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               break;
-       }
-
-       case 703:                                       // INIT MESH 
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg(parent, "", Sel);
-               break;
-       }
-
-       case 704:                                       // EDIT Hypothesis 
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SMESHGUI_EditHypothesesDlg *aDlg =
-                       new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
-               break;
-       }
-
-       case 705:                                       //  EDIT Global Hypothesis
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SMESHGUI_EditHypothesesDlg *aDlg =
-                       new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
-               break;
-       }
-
-       case 706:                                       //  EDIT Local Hypothesis
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SMESHGUI_EditHypothesesDlg *aDlg =
-                       new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
-               break;
-       }
-
-       case 806:                                       // ORIENTATION ELEMENTS
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               smeshGUI->myDesktop->SetSelectionMode(3, true);
-               SMESHGUI_OrientationElementsDlg *aDlg =
-                       new SMESHGUI_OrientationElementsDlg(parent, "", Sel);
-               break;
-       }
-
-       case 807:                                       // DIAGONAL INVERSION
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               Sel->ClearIObjects();
-               smeshGUI->myDesktop->SetSelectionMode(2, true);
-               SMESHGUI_DiagonalInversionDlg *aDlg =
-                       new SMESHGUI_DiagonalInversionDlg(parent, "", Sel);
-               break;
-       }
-
-       case 900:                                       // MESH INFOS
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SMESHGUI_MeshInfosDlg *aDlg =
-                       new SMESHGUI_MeshInfosDlg(parent, "", Sel);
-               break;
-       }
-
-       case 1001:                                      // AUTOMATIC UPDATE PREFERENCES
-       {
-               parent->menuBar()->setItemChecked(1001,
-                       !parent->menuBar()->isItemChecked(1001));
-               if (parent->menuBar()->isItemChecked(1001))
-               {
-                       QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
-                       smeshGUI->myAutomaticUpdate = true;
-               }
-               else
-               {
-                       QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
-                       smeshGUI->myAutomaticUpdate = false;
-               }
-               break;
-       }
-
-       case 1003:                                      // MESH PREFERENCES
-       {
-               smeshGUI->SetDisplaySettings();
-               break;
-       }
-
-       case 1005:
-       {
-               QString Bold = QAD_CONFIG->getSetting("ScalarBar:Bold");
-               QString Italic = QAD_CONFIG->getSetting("ScalarBar:Italic");
-               QString Shadow = QAD_CONFIG->getSetting("ScalarBar:Shadow");
-               QString FontFamily = QAD_CONFIG->getSetting("ScalarBar:FontFamily");
-               QString Orientation = QAD_CONFIG->getSetting("ScalarBar:Orientation");
-               float Width = QAD_CONFIG->getSetting("ScalarBar:Width").toFloat();
-               float Height = QAD_CONFIG->getSetting("ScalarBar:Height").toFloat();
-               int NumberOfLabels =
-                       QAD_CONFIG->getSetting("ScalarBar:NumberOfLabels").toInt();
-               int NumberOfColors =
-                       QAD_CONFIG->getSetting("ScalarBar:NumberOfColors").toInt();
-
-               if (Width == 0)
-                       Width = 0.17;
-               if (Height == 0)
-                       Height = 0.8;
-               if (NumberOfLabels == 0)
-                       NumberOfLabels = 5;
-               if (NumberOfColors == 0)
-                       NumberOfColors = 64;
-
-               SMESHGUI_Preferences_ScalarBarDlg *aDlg =
-                       new SMESHGUI_Preferences_ScalarBarDlg(parent, "", true);
-
-               if (Bold.compare("true") == 0)
-                       aDlg->Bold->setChecked(true);
-               else
-                       aDlg->Bold->setChecked(false);
-               if (Italic.compare("true") == 0)
-                       aDlg->Italic->setChecked(true);
-               else
-                       aDlg->Italic->setChecked(false);
-               if (Shadow.compare("true") == 0)
-                       aDlg->Shadow->setChecked(true);
-               else
-                       aDlg->Shadow->setChecked(false);
-
-               if (Orientation.compare("Horizontal") == 0)
-                       aDlg->RadioHoriz->setChecked(true);
-               else
-                       aDlg->RadioVert->setChecked(true);
-
-               int NbItems = aDlg->ComboBox1->count();
-               int i = 0;
-               aDlg->ComboBox1->setCurrentItem(i);
-               while (i < NbItems)
-               {
-                       if (FontFamily.compare(aDlg->ComboBox1->text(i)) == 0)
-                               aDlg->ComboBox1->setCurrentItem(i);
-                       i++;
-               }
-
-               aDlg->LineEditWidth->setText(QString("%1").arg(Width));
-               aDlg->LineEditHeight->setText(QString("%1").arg(Height));
-
-               aDlg->SpinBoxLabels->setValue(NumberOfLabels);
-               aDlg->SpinBoxColors->setValue(NumberOfColors);
-
-               aDlg->show();
-               if (aDlg->result())
-               {
-                       if (aDlg->RadioHoriz->isChecked())
-                               Orientation = "Horizontal";
-                       else
-                               Orientation = "Vertical";
-                       if (aDlg->Bold->isChecked())
-                               Bold = "true";
-                       else
-                               Bold = "false";
-                       if (aDlg->Italic->isChecked())
-                               Italic = "true";
-                       else
-                               Italic = "false";
-                       if (aDlg->Shadow->isChecked())
-                               Shadow = "true";
-                       else
-                               Shadow = "false";
-
-                       FontFamily = aDlg->ComboBox1->currentText();
-                       Width = aDlg->LineEditWidth->text().toFloat();
-                       Height = aDlg->LineEditHeight->text().toFloat();
-                       NumberOfColors = aDlg->SpinBoxColors->text().toInt();
-                       NumberOfLabels = aDlg->SpinBoxLabels->text().toInt();
-
-                       vtkScalarBarActor *aScalarBar = smeshGUI->GetScalarBar();
-                       if (aScalarBar != NULL)
-                       {
-                               smeshGUI->SetSettingsScalarBar(aScalarBar, Bold, Italic, Shadow,
-                                       FontFamily, Orientation,
-                                       Width, Height, NumberOfColors, NumberOfLabels);
-                       }
-
-                       QAD_CONFIG->addSetting("ScalarBar:Bold", Bold);
-                       QAD_CONFIG->addSetting("ScalarBar:Italic", Italic);
-                       QAD_CONFIG->addSetting("ScalarBar:Shadow", Shadow);
-                       QAD_CONFIG->addSetting("ScalarBar:FontFamily", FontFamily);
-                       QAD_CONFIG->addSetting("ScalarBar:Orientation", Orientation);
-                       QAD_CONFIG->addSetting("ScalarBar:Width", Width);
-                       QAD_CONFIG->addSetting("ScalarBar:Height", Height);
-                       QAD_CONFIG->addSetting("ScalarBar:NumberOfLabels", NumberOfLabels);
-                       QAD_CONFIG->addSetting("ScalarBar:NumberOfColors", NumberOfColors);
-               }
-               break;
-       }
-
-       case 1100:                                      // EDIT HYPOTHESIS
-       {
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               int nbSel = Sel->IObjectCount();
-
-               if (nbSel == 1)
-               {
-                       Standard_Boolean res;
-                       SMESH::SMESH_Hypothesis_var Hyp =
-                               smeshGUI->ConvertIOinSMESHHypothesis(Sel->firstIObject(), res);
-
-                       /* Look for all mesh objects that have this hupothesis affected in order to flag as ModifiedMesh */
-                       /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects                   */
-                       /* Warning : however by internal mechanism all subMeshes icons are changed !                     */
-                       SALOMEDS::Study::ListOfSObject_var listSOmesh =
-                               smeshGUI->GetMeshesUsingAlgoOrHypothesis(Hyp);
-
-                       if (res)
-                       {
-                               QString Name = Hyp->GetName();
-
-                               if (Name.compare("LocalLength") == 0)
-                               {
-                                       SMESH::SMESH_LocalLength_var LL =
-                                               SMESH::SMESH_LocalLength::_narrow(Hyp);
-                                       double beforeLength = LL->GetLength();
-                                       double Length = smeshGUI->Parameter(res,
-                                               beforeLength,
-                                               tr("SMESH_LOCAL_LENGTH_HYPOTHESIS"),
-                                               tr("SMESH_VALUE"),
-                                               1.0E-5, 1E6, 6);
-                                       if (res && Length != beforeLength)
-                                       {
-                                               LL->SetLength(Length);
-                                               for (int i = 0; i < listSOmesh->length(); i++)
-                                               {
-                                                       smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
-                                                               false);
-                                               }
-                                               break;
-                                       }
-
-                               }
-                               else if (Name.compare("NumberOfSegments") == 0)
-                               {
-                                       SMESH::SMESH_NumberOfSegments_var NOS =
-                                               SMESH::SMESH_NumberOfSegments::_narrow(Hyp);
-                                       int beforeNbSeg = NOS->GetNumberOfSegments();
-                                       int NbSeg = smeshGUI->Parameter(res,
-                                               beforeNbSeg,
-                                               tr("SMESH_NB_SEGMENTS_HYPOTHESIS"),
-                                               tr("SMESH_VALUE"),
-                                               1, 1000000);
-
-                                       if (res && NbSeg != beforeNbSeg)
-                                       {
-                                               NOS->SetNumberOfSegments(NbSeg);
-                                               for (int i = 0; i < listSOmesh->length(); i++)
-                                               {
-                                                       SALOMEDS::SObject_var SO = listSOmesh[i];
-                                                       smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
-                                                               false);
-                                               }
-                                               break;
-                                       }
-
-                               }
-                               else if (Name.compare("MaxElementArea") == 0)
-                               {
-                                       SMESH::SMESH_MaxElementArea_var MEA =
-                                               SMESH::SMESH_MaxElementArea::_narrow(Hyp);
-                                       double beforeMaxArea = MEA->GetMaxElementArea();
-                                       double MaxArea = smeshGUI->Parameter(res,
-                                               beforeMaxArea,
-                                               tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"),
-                                               tr("SMESH_VALUE"),
-                                               1.0E-5, 1E6, 6);
-                                       if (res && MaxArea != beforeMaxArea)
-                                       {
-                                               MEA->SetMaxElementArea(MaxArea);
-                                               for (int i = 0; i < listSOmesh->length(); i++)
-                                               {
-                                                       smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
-                                                               false);
-                                               }
-                                               break;
-                                       }
-
-                               }
-                               else if (Name.compare("MaxElementVolume") == 0)
-                               {
-                                       SMESH::SMESH_MaxElementVolume_var MEV =
-                                               SMESH::SMESH_MaxElementVolume::_narrow(Hyp);
-                                       double beforeMaxVolume = MEV->GetMaxElementVolume();
-                                       double MaxVolume = smeshGUI->Parameter(res,
-                                               beforeMaxVolume,
-                                               tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"),
-                                               tr("SMESH_VALUE"),
-                                               1.0E-5, 1E6, 6);
-                                       if (res && MaxVolume != beforeMaxVolume)
-                                       {
-                                               MEV->SetMaxElementVolume(MaxVolume);
-                                               for (int i = 0; i < listSOmesh->length(); i++)
-                                               {
-                                                       smeshGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i],
-                                                               false);
-                                               }
-                                               break;
-                                       }
-
-                               }
-                               else if (Name.compare("Regular_1D") == 0)
-                               {
-                               }
-                               else if (Name.compare("MEFISTO_2D") == 0)
-                               {
-                               }
-                               else
-                               {
-                               }
-
-                       }
-               }
-               break;
-       }
-
-       case 1101:                                      // RENAME
-       {
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-               for (; It.More(); It.Next())
-               {
-                       Handle(SALOME_InteractiveObject) IObject = It.Value();
-
-                       SALOMEDS::SObject_var obj =
-                               smeshGUI->myStudy->FindObjectID(IObject->getEntry());
-                       SALOMEDS::GenericAttribute_var anAttr;
-                       SALOMEDS::AttributeName_var aName;
-                       if (!obj->_is_nil())
-                       {
-                               if (obj->FindAttribute(anAttr, "AttributeName"))
-                               {
-                                       aName = SALOMEDS::AttributeName::_narrow(anAttr);
-                                       QString newName = QString(aName->Value());
-                                       newName =
-                                               SALOMEGUI_NameDlg::getName(QAD_Application::
-                                               getDesktop(), newName);
-                                       if (!newName.isEmpty())
-                                       {
-                                               QApplication::setOverrideCursor(Qt::waitCursor);
-                                               smeshGUI->myActiveStudy->renameIObject(IObject,
-                                                       newName);
-                                       }
-                                       QApplication::restoreOverrideCursor();
-                               }
-                       }
-               }
-               break;
-       }
-
-       case 1102:                                      // REMOVE HYPOTHESIS / ALGORITHMS
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-               for (int i = 0; It.More(); It.Next(), i++)
-               {
-                       Handle(SALOME_InteractiveObject) IObject = It.Value();
-                       smeshGUI->RemoveHypothesisOrAlgorithmOnMesh(IObject);
-               }
-               Sel->ClearIObjects();
-               smeshGUI->myActiveStudy->updateObjBrowser(true);
-               QApplication::restoreOverrideCursor();
-               break;
-       }
-
-       case 401:                                       // GEOM::EDGE
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       smeshGUI->EmitSignalDeactivateDialog();
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       Sel->ClearIObjects();
-                       smeshGUI->myDesktop->SetSelectionMode(1, true);
-                       parent->menuBar()->setItemChecked(9010, false);
-                       parent->menuBar()->setItemChecked(9011, false);
-                       smeshGUI->ViewNodes();
-                       SMESHGUI_AddEdgeDlg *aDlg =
-                               new SMESHGUI_AddEdgeDlg(parent, "", Sel);
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               break;
-       }
-       case 4021:                                      // TRIANGLE
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       smeshGUI->EmitSignalDeactivateDialog();
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       Sel->ClearIObjects();
-                       smeshGUI->myDesktop->SetSelectionMode(1, true);
-                       parent->menuBar()->setItemChecked(9010, false);
-                       parent->menuBar()->setItemChecked(9011, false);
-                       smeshGUI->ViewNodes();
-                       SMESHGUI_AddFaceDlg *aDlg =
-                               new SMESHGUI_AddFaceDlg(parent, "", Sel, 3);
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               break;
-       }
-       case 4022:                                      // QUAD
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       smeshGUI->EmitSignalDeactivateDialog();
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       Sel->ClearIObjects();
-                       smeshGUI->myDesktop->SetSelectionMode(1, true);
-                       parent->menuBar()->setItemChecked(9010, false);
-                       parent->menuBar()->setItemChecked(9011, false);
-                       smeshGUI->ViewNodes();
-                       SMESHGUI_AddFaceDlg *aDlg =
-                               new SMESHGUI_AddFaceDlg(parent, "", Sel, 4);
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               break;
-       }
-       case 4031:                                      // TETRA
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       smeshGUI->EmitSignalDeactivateDialog();
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       Sel->ClearIObjects();
-                       smeshGUI->myDesktop->SetSelectionMode(1, true);
-                       parent->menuBar()->setItemChecked(9010, false);
-                       parent->menuBar()->setItemChecked(9011, false);
-                       smeshGUI->ViewNodes();
-                       SMESHGUI_AddVolumeDlg *aDlg =
-                               new SMESHGUI_AddVolumeDlg(parent, "", Sel, 4);
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               break;
-       }
-       case 4032:                                      // HEXA
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       smeshGUI->EmitSignalDeactivateDialog();
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       Sel->ClearIObjects();
-                       smeshGUI->myDesktop->SetSelectionMode(1, true);
-                       parent->menuBar()->setItemChecked(9010, false);
-                       parent->menuBar()->setItemChecked(9011, false);
-                       smeshGUI->ViewNodes();
-                       SMESHGUI_AddVolumeDlg *aDlg =
-                               new SMESHGUI_AddVolumeDlg(parent, "", Sel, 8);
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               break;
-       }
-
-       case 4041:                                      // REMOVES NODES
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       smeshGUI->EmitSignalDeactivateDialog();
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       Sel->ClearIObjects();
-                       smeshGUI->myDesktop->SetSelectionMode(1, true);
-                       parent->menuBar()->setItemChecked(9010, false);
-                       parent->menuBar()->setItemChecked(9011, false);
-                       smeshGUI->ViewNodes();
-                       SMESHGUI_RemoveNodesDlg *aDlg =
-                               new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               break;
-       }
-       case 4042:                                      // REMOVES ELEMENTS
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       smeshGUI->EmitSignalDeactivateDialog();
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       Sel->ClearIObjects();
-                       smeshGUI->myDesktop->SetSelectionMode(3, true);
-                       SMESHGUI_RemoveElementsDlg *aDlg =
-                               new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               break;
-       }
-
-       case 5000:                                      // HYPOTHESIS - ALGO
-       {
-               smeshGUI->CreateAlgorithm("Regular_1D", "Wire Discretisation");
-               break;
-       }
-       case 5010:
-       {
-               smeshGUI->CreateAlgorithm("MEFISTO_2D", "Triangle (Mefisto)");
-               break;
-       }
-       case 5011:
-       {
-               smeshGUI->CreateAlgorithm("Quadrangle_2D", "Quadrangle (Mapping)");
-               break;
-       }
-       case 5020:
-       {
-               smeshGUI->CreateAlgorithm("Hexa_3D", "Hexahedron (i,j,k)");
-               break;
-       }
-       case 5021:
-       {
-               smeshGUI->CreateAlgorithm("NETGEN_3D", "Tetrahedron (Netgen)");
-               break;
-       }
-
-       case 5030:                                      // HYPOTHESIS - LOCAL LENGTH
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SMESHGUI_LocalLengthDlg *aDlg = new SMESHGUI_LocalLengthDlg(parent, "");
-               break;
-       }
-       case 5031:                                      // HYPOTHESIS - NB SEGMENTS
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SMESHGUI_NbSegmentsDlg *aDlg = new SMESHGUI_NbSegmentsDlg(parent, "");
-               break;
-       }
-
-       case 5032:                                      // HYPOTHESIS - MAX ELEMENT AREA
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SMESHGUI_MaxElementAreaDlg *aDlg =
-                       new SMESHGUI_MaxElementAreaDlg(parent, "");
-               break;
-       }
-
-       case 5033:                                      // HYPOTHESIS - MAX ELEMENT VOLUME
-       {
-               smeshGUI->EmitSignalDeactivateDialog();
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SMESHGUI_MaxElementVolumeDlg *aDlg =
-                       new SMESHGUI_MaxElementVolumeDlg(parent, "");
-               break;
-       }
-
-       case 5034:                                     // HYPOTHESIS - LENGTH FROM EDGES
-       {
-         SMESH::SMESH_Hypothesis_var Hyp;
-         try
-           {
-             Hyp = smeshGUI->myComponentMesh->CreateHypothesis("LengthFromEdges", smeshGUI->myStudyId);
-
-             if (!Hyp->_is_nil())
-               {
-                 SALOMEDS::SObject_var SHyp = smeshGUI->myStudyAPI.AddNewHypothesis(Hyp);
-                 smeshGUI->myStudyAPI.SetName(SHyp, "LengthFromEdges");
-               }
-           }
-         catch(const SALOME::SALOME_Exception & S_ex)
-           {
-             QtCatchCorbaException(S_ex);
-           }
-         smeshGUI->myActiveStudy->updateObjBrowser(true);
-
-         break;
-       }
-
-       case 6016:                                      // CONTROLS 
-       case 6015:
-       case 6014:
-       case 6013:
-       case 6012:
-       case 6011:
-       case 6001:
-       {
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               int nbSel = Sel->IObjectCount();
-               if (nbSel != 1)
-                       break;
-               smeshGUI->Control(theCommandID);
-               break;
-       }
-
-       case 6002:
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {                                               //VTK
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       SMESHGUI_EdgesConnectivityDlg *Dlg =
-                               new SMESHGUI_EdgesConnectivityDlg(parent, "", Sel);
-               }
-               else
-               {
-                       QApplication::restoreOverrideCursor();
-                       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
-                               tr("SMESH_BUT_YES"));
-               }
-               break;
-       }
-
-       case 9010:
-       {
-               if (!parent->menuBar()->isItemChecked(9010))
-               {
-                       QApplication::setOverrideCursor(Qt::waitCursor);
-                       parent->menuBar()->setItemChecked(9011, false);
-
-                       smeshGUI->EraseSimulationActors();
-                       smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
-
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       int nbSel = Sel->IObjectCount();
-                       if (nbSel == 1)
-                       {
-                               Standard_Boolean res;
-                               SMESH_Actor *MeshActor =
-                                       smeshGUI->FindActorByEntry(Sel->firstIObject()->getEntry(),
-                                       res, true);
-                               if (res)
-                               {
-                                       parent->menuBar()->setItemChecked(9010,
-                                               !parent->menuBar()->isItemChecked(9010));
-
-                                       // It's necessary to display SMDS IDs instead of VTK ones, so 
-                                       // vtkIdFilter is unacceptable here. We have to do it manually :(
-                                       vtkUnstructuredGrid *ptGrid = vtkUnstructuredGrid::New();
-                                       ptGrid->CopyStructure(MeshActor->DataSource);
-
-                                       int numPts = MeshActor->DataSource->GetNumberOfPoints();
-
-                                       // Loop over points and generate ids
-                                       vtkIntArray *ptIds = vtkIntArray::New();
-                                       ptIds->SetNumberOfValues(numPts);
-
-                                       for (int id = 0; id < numPts; id++)
-                                       {
-                                               int idSMDS = MeshActor->GetIdSMESHDSNode(id);
-                                               ptIds->SetValue(id, idSMDS);
-                                       }
-
-// mpv porting vtk4.2.2
-                                       //          vtkScalars* newScalars = vtkScalars::New();
-                                       //          newScalars->SetData(ptIds);
-                                       //          ptGrid->GetPointData()->SetScalars(newScalars);
-                                       ptGrid->GetPointData()->SetScalars(ptIds);
-                                       //          newScalars->Delete();
-// mpv
-                                       ptIds->Delete();
-
-                                       vtkMaskPoints *mask = vtkMaskPoints::New();
-                                       mask->SetInput(ptGrid);
-                                       mask->SetOnRatio(1);
-                                       //        mask->SetMaximumNumberOfPoints( 50 );
-                                       //        mask->RandomModeOn();
-
-                                       vtkSelectVisiblePoints *visPts =
-                                               vtkSelectVisiblePoints::New();
-                                       visPts->SetInput(mask->GetOutput());
-                                       visPts->SetRenderer(((VTKViewer_ViewFrame *) smeshGUI->
-                                                       myActiveStudy->getActiveStudyFrame()->
-                                                       getRightFrame()->getViewFrame())->getRenderer());
-                                       //visPts->SetSelectInvisible(1);
-                                       visPts->SelectInvisibleOff();
-                                       visPts->SetTolerance(0.1);
-
-                                       vtkLabeledDataMapper *ldm = vtkLabeledDataMapper::New();
-                                       ldm->SetInput(visPts->GetOutput());
-                                       ldm->SetLabelFormat("%g");
-                                       ldm->SetLabelModeToLabelScalars();
-                                       //ldm->SetLabelModeToLabelFieldData();
-
-                                       ldm->SetFontFamilyToTimes();
-                                       ldm->SetFontSize(6 * parent->font().pointSize() / 5);
-                                       ldm->SetBold(1);
-                                       ldm->SetItalic(0);
-                                       ldm->SetShadow(0);
-
-                                       vtkActor2D *pointLabels = vtkActor2D::New();
-                                       pointLabels->SetMapper(ldm);
-                                       pointLabels->GetProperty()->SetColor(0, 1, 0);
-
-                                       visPts->Delete();
-                                       ldm->Delete();
-                                       smeshGUI->mySimulationActors2D->AddItem(pointLabels);
-                                       ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
-                                               getActiveStudyFrame()->getRightFrame()->
-                                               getViewFrame())->getRenderer()->AddActor2D(pointLabels);
-                               }
-                       }
-               }
-               else
-               {
-                       QApplication::setOverrideCursor(Qt::waitCursor);
-                       parent->menuBar()->setItemChecked(9010,
-                               !parent->menuBar()->isItemChecked(9010));
-                       smeshGUI->EraseSimulationActors();
-                       smeshGUI->ScalarVisibilityOff();
-               }
-               QApplication::restoreOverrideCursor();
-               break;
-       }
-       case 9011:
-       {
-               if (!parent->menuBar()->isItemChecked(9011))
-               {
-                       QApplication::setOverrideCursor(Qt::waitCursor);
-                       parent->menuBar()->setItemChecked(9010, false);
-
-                       smeshGUI->EraseSimulationActors();
-                       smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
-
-                       SALOME_Selection *Sel =
-                               SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                               getSelection());
-                       int nbSel = Sel->IObjectCount();
-                       if (nbSel == 1)
-                       {
-                               Standard_Boolean res;
-                               SMESH_Actor *MeshActor =
-                                       smeshGUI->FindActorByEntry(Sel->firstIObject()->getEntry(),
-                                       res, true);
-                               if (res)
-                               {
-                                       parent->menuBar()->setItemChecked(9011,
-                                               !parent->menuBar()->isItemChecked(9011));
-
-                                       // It's necessary to display SMDS IDs instead of VTK ones, so 
-                                       // vtkIdFilter is unacceptable here. We have to do it manually :(
-                                       vtkUnstructuredGrid *elGrid = vtkUnstructuredGrid::New();
-                                       elGrid->CopyStructure(MeshActor->DataSource);
-
-                                       int numCells = MeshActor->DataSource->GetNumberOfCells();
-
-                                       // Loop over points and generate ids
-                                       vtkIntArray *cellIds = vtkIntArray::New();
-                                       cellIds->SetNumberOfValues(numCells);
-
-                                       for (int id = 0; id < numCells; id++)
-                                       {
-                                               int idSMDS = MeshActor->GetIdSMESHDSElement(id);
-                                               cellIds->SetValue(id, idSMDS);
-                                       }
-
-// mpv porting vk4.2.2
-                                       //          vtkScalars* newScalars = vtkScalars::New();
-                                       //          newScalars->SetData(cellIds);
-                                       elGrid->GetCellData()->SetScalars(cellIds);
-                                       //          elGrid->GetCellData()->SetScalars(newScalars);
-                                       //          newScalars->Delete();
-//mpv
-
-                                       cellIds->Delete();
-
-                                       vtkCellCenters *cc = vtkCellCenters::New();
-                                       cc->SetInput(elGrid);
-
-                                       vtkSelectVisiblePoints *visCells =
-                                               vtkSelectVisiblePoints::New();
-                                       visCells->SetInput(cc->GetOutput());
-                                       visCells->SetRenderer(((VTKViewer_ViewFrame *) smeshGUI->
-                                                       myActiveStudy->getActiveStudyFrame()->
-                                                       getRightFrame()->getViewFrame())->getRenderer());
-                                       visCells->SelectInvisibleOff();
-                                       visCells->SetTolerance(0.1);
-                                       //        visCells->SetSelectInvisible(1);
-
-                                       vtkLabeledDataMapper *ldm = vtkLabeledDataMapper::New();
-                                       ldm->SetInput(visCells->GetOutput());
-                                       ldm->SetLabelFormat("%g");
-                                       ldm->SetLabelModeToLabelScalars();
-
-                                       ldm->SetFontFamilyToTimes();
-                                       ldm->SetFontSize(6 * parent->font().pointSize() / 5);
-                                       ldm->SetBold(1);
-                                       ldm->SetItalic(0);
-                                       ldm->SetShadow(0);
-
-                                       vtkActor2D *cellLabels = vtkActor2D::New();
-                                       cellLabels->SetMapper(ldm);
-                                       cellLabels->GetProperty()->SetColor(1, 0, 0);
-
-                                       cc->Delete();
-                                       visCells->Delete();
-                                       ldm->Delete();
-                                       smeshGUI->mySimulationActors2D->AddItem(cellLabels);
-                                       ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
-                                               getActiveStudyFrame()->getRightFrame()->
-                                               getViewFrame())->getRenderer()->AddActor2D(cellLabels);
-                               }
-                       }
-               }
-               else
-               {
-                       QApplication::setOverrideCursor(Qt::waitCursor);
-                       parent->menuBar()->setItemChecked(9011,
-                               !parent->menuBar()->isItemChecked(9011));
-                       smeshGUI->EraseSimulationActors();
-                       smeshGUI->ScalarVisibilityOff();
-               }
-               QApplication::restoreOverrideCursor();
-               break;
-       }
-
-       case 10001:                             // DISPLAY MODE PREFERENCE
-       {
-               parent->menuBar()->setItemChecked(10001,
-                       !parent->menuBar()->isItemChecked(10001));
-               parent->menuBar()->setItemChecked(10002, false);
-               parent->menuBar()->setItemChecked(10003, false);
-               QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
-               break;
-       }
-       case 10002:
-       {
-               parent->menuBar()->setItemChecked(10002,
-                       !parent->menuBar()->isItemChecked(10002));
-               parent->menuBar()->setItemChecked(10001, false);
-               parent->menuBar()->setItemChecked(10003, false);
-               QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
-               break;
-       }
-       case 10003:
-       {
-               parent->menuBar()->setItemChecked(10003,
-                       !parent->menuBar()->isItemChecked(10003));
-               parent->menuBar()->setItemChecked(10002, false);
-               parent->menuBar()->setItemChecked(10001, false);
-               QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shrink");
-               break;
-       }
-
-       }
-
-       smeshGUI->myActiveStudy->updateObjBrowser(true);
-       return true;
-}
-
-//=============================================================================
-/*! function : GetMeshesUsingAlgoOrHypothesis()
- *  purpose  : return a list of Study objects (mesh kind) that have 'AlgoOrHyp' affected.
- *           : However is supposed here that father of father of an hypothesis is a Mesh Object.
- */
-//=============================================================================      
-SALOMEDS::Study::ListOfSObject *
-       SMESHGUI::GetMeshesUsingAlgoOrHypothesis(SMESH::
-       SMESH_Hypothesis_ptr AlgoOrHyp)
-{
-       SALOMEDS::Study::ListOfSObject_var listSOmesh =
-               new SALOMEDS::Study::ListOfSObject;
-       listSOmesh->length(0);
-       unsigned int index = 0;
-       if (!AlgoOrHyp->_is_nil())
-       {
-               SALOMEDS::SObject_var SO_Hypothesis =
-                       smeshGUI->GetStudyAPI().FindHypothesisOrAlgorithms(AlgoOrHyp);
-               if (!SO_Hypothesis->_is_nil())
-               {
-                       SALOMEDS::Study::ListOfSObject_var listSO =
-                               smeshGUI->myStudy->FindDependances(SO_Hypothesis);
-                       for (unsigned int i = 0; i < listSO->length(); i++)
-                       {
-                               SALOMEDS::SObject_var SO = listSO[i];
-                               if (!SO->_is_nil())
-                               {
-                                       SALOMEDS::SObject_var SOfatherFather =
-                                               SO->GetFather()->GetFather();
-                                       if (!SOfatherFather->_is_nil())
-                                       {
-                                               index++;
-                                               listSOmesh->length(index);
-                                               listSOmesh[index - 1] = SOfatherFather;
-                                       }
-                               }
-                       }
-               }
-       }
-       return listSOmesh._retn();
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Import_Mesh(QAD_Desktop * parent, int theCommandID)
-{
-       QString filter;
-       string myExtension;
-       Mesh_Reader *myReader;
-
-       if (theCommandID == 113)
-       {
-               filter = tr("MED files (*.med)");
-               myExtension = string("MED");
-               myReader = new DriverMED_R_SMESHDS_Mesh;
-       }
-       else if (theCommandID == 112)
-       {
-               filter = tr("IDEAS files (*.unv)");
-               myExtension = string("UNV");
-       }
-       else if (theCommandID == 111)
-       {
-               filter = tr("DAT files (*.dat)");
-               myExtension = string("MED");
-               myReader = new DriverDAT_R_SMESHDS_Mesh;
-       }
-
-       QString filename = QAD_FileDlg::getFileName(parent,
-               "",
-               filter,
-               tr("Import mesh"),
-               true);
-       if (!filename.isEmpty())
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               string myClass = string("SMESHDS_Mesh");
-//    Mesh_Reader* myReader = SMESHDriver::GetMeshReader(myExtension, myClass);
-
-               int myMeshId = (smeshGUI->myDocument)->NewMesh();
-               SMDS_Mesh *myMesh = (smeshGUI->myDocument)->GetMesh(myMeshId);
-
-               myReader->SetFile(string(filename.latin1()));
-               myReader->SetMesh(myMesh);
-               myReader->SetMeshId(myMeshId);
-               myReader->Read();
-
-               QApplication::restoreOverrideCursor();
-       }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Export_Mesh(QAD_Desktop * parent, int theCommandID)
-{
-       SALOME_Selection *Sel =
-               SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
-       int nbSel = Sel->IObjectCount();
-       if (nbSel == 1)
-       {
-               Standard_Boolean res;
-               Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
-               SMESH::SMESH_Mesh_var aMesh = smeshGUI->ConvertIOinMesh(IObject, res);
-               if (res)
-               {
-                       if (theCommandID == 122)
-                       {                                       // EXPORT MED
-                               QString filename = QAD_FileDlg::getFileName(parent,
-                                       "",
-                                       tr("MED files (*.med)"),
-                                       tr("Export mesh"),
-                                       false);
-                               if (!filename.isEmpty())
-                               {
-                                       QApplication::setOverrideCursor(Qt::waitCursor);
-                                       aMesh->ExportMED(filename.latin1());
-                                       QApplication::restoreOverrideCursor();
-                               }
-                       }
-                       else if (theCommandID == 121)
-                       {                                       // EXPORT DAT
-                               QString filename = QAD_FileDlg::getFileName(parent,
-                                       "",
-                                       tr("DAT files (*.dat)"),
-                                       tr("Export mesh"),
-                                       false);
-                               if (!filename.isEmpty())
-                               {
-                                       QApplication::setOverrideCursor(Qt::waitCursor);
-                                       aMesh->ExportDAT(filename.latin1());
-                                       QApplication::restoreOverrideCursor();
-                               }
-                       }
-                       else if (theCommandID == 123)
-                       {                                       // EXPORT UNV
-                               QString filename = QAD_FileDlg::getFileName(parent,
-                                       "",
-                                       tr("IDEAS files (*.unv)"),
-                                       tr("Export mesh"),
-                                       false);
-                               if (!filename.isEmpty())
-                               {
-                                       QApplication::setOverrideCursor(Qt::waitCursor);
-                                       aMesh->ExportUNV(filename.latin1());
-                                       QApplication::restoreOverrideCursor();
-                               }
-                               else
-                                       aMesh->ExportDAT(filename.latin1());
-
-                               QApplication::restoreOverrideCursor();
-
-                               if (IObject->hasEntry())
-                               {
-                                       MESSAGE("---");
-                                       SALOMEDS::SObject_var SO =
-                                               smeshGUI->myStudy->FindObjectID(IObject->getEntry());
-                                       SALOMEDS::GenericAttribute_var anAttr;
-                                       SALOMEDS::AttributeComment_var aFileName;
-                                       SALOMEDS::StudyBuilder_var aStudyBuilder =
-                                               smeshGUI->myStudy->NewBuilder();
-                                       anAttr =
-                                               aStudyBuilder->FindOrCreateAttribute(SO,
-                                               "AttributeComment");
-                                       aFileName = SALOMEDS::AttributeComment::_narrow(anAttr);
-                                       aFileName->SetValue(filename.latin1());
-                               }
-                       }
-               }
-       }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Import_Document(QAD_Desktop * parent, int theCommandID)
-{
-       QString filter;
-       string myExtension;
-       Document_Reader *myReader;
-
-       if (theCommandID == 113)
-       {
-               filter = tr("MED files (*.med)");
-               myExtension = string("MED");
-               myReader = new DriverMED_R_SMESHDS_Document;
-       }
-       else if (theCommandID == 112)
-       {
-               filter = tr("IDEAS files (*.unv)");
-               myExtension = string("UNV");
-               myReader = new DriverUNV_R_SMESHDS_Document;
-       }
-       else if (theCommandID == 111)
-       {
-               filter = tr("DAT files (*.dat)");
-               myExtension = string("DAT");
-               myReader = new DriverDAT_R_SMESHDS_Document;
-       }
-
-       QString filename = QAD_FileDlg::getFileName(parent,
-               "",
-               filter,
-               tr("Import document"),
-               true);
-       if (!filename.isEmpty())
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               string myClass = string("SMESHDS_Document");
-//    Document_Reader* myReader = SMESHDriver::GetDocumentReader(myExtension, myClass);
-               SMESHDS_Document *newDocument = new SMESHDS_Document(1);
-
-               myReader->SetFile(string(filename.latin1()));
-               myReader->SetDocument(smeshGUI->myDocument);
-               myReader->Read();
-               QApplication::restoreOverrideCursor();
-       }
-}
-
-void SMESHGUI::Export_Document(QAD_Desktop * parent, int theCommandID)
-{
-       QString filter;
-       Document_Writer *myWriter;
-       string myExtension;
-
-       if (theCommandID == 122)
-       {
-               filter = tr("MED files (*.med)");
-               myExtension = string("MED");
-               myWriter = new DriverMED_W_SMESHDS_Document;
-       }
-       else if (theCommandID == 121)
-       {
-               filter = tr("DAT files (*.dat)");
-               myExtension = string("DAT");
-               myWriter = new DriverDAT_W_SMESHDS_Document;
-       }
-       else if (theCommandID == 123)
-       {
-               filter = tr("IDEAS files (*.unv)");
-               myExtension = string("UNV");
-               myWriter = new DriverUNV_W_SMESHDS_Document;
-       }
-
-       QString filename = QAD_FileDlg::getFileName(parent,
-               "",
-               filter,
-               tr("Export document"),
-               false);
-       if (!filename.isEmpty())
-       {
-               QApplication::setOverrideCursor(Qt::waitCursor);
-               string myClass = string("SMESHDS_Document");
-               //Document_Writer* myWriter = SMESHDriver::GetDocumentWriter(myExtension, myClass);
-
-               myWriter->SetFile(string(filename.latin1()));
-               myWriter->SetDocument(smeshGUI->myDocument);
-
-               //StudyContextStruct* myStudyContext = _impl.GetStudyContext(myStudyId);
-               //Handle(SMESHDS_Document) myDocument = myStudyContext->myDocument;
-               //myWriter->SetDocument(myDocument);
-
-               myWriter->Write();
-               QApplication::restoreOverrideCursor();
-       }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
-       QAD_StudyFrame * studyFrame)
-{
-       SMESHGUI::GetOrCreateSMESHGUI(parent);
-       return false;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
-       QAD_StudyFrame * studyFrame)
-{
-       SMESHGUI::GetOrCreateSMESHGUI(parent);
-
-       return true;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
-       QAD_StudyFrame * studyFrame)
-{
-       SMESHGUI::GetOrCreateSMESHGUI(parent);
-
-       return true;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::SetSettings(QAD_Desktop * parent)
-{
-       SMESHGUI::GetOrCreateSMESHGUI(parent);
-
-       /* Display mode */
-       QString DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
-       if (DisplayMode.compare("") == 0)
-       {
-               DisplayMode = "Shading";
-               QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
-       }
-
-       if (DisplayMode.compare("Wireframe") == 0)
-       {
-               parent->menuBar()->setItemChecked(10003, false);
-               parent->menuBar()->setItemChecked(10002, false);
-               parent->menuBar()->setItemChecked(10001, true);
-       }
-       else if (DisplayMode.compare("Shading") == 0)
-       {
-               parent->menuBar()->setItemChecked(10003, false);
-               parent->menuBar()->setItemChecked(10002, true);
-               parent->menuBar()->setItemChecked(10001, false);
-       }
-       else if (DisplayMode.compare("Shrink") == 0)
-       {
-               parent->menuBar()->setItemChecked(10003, true);
-               parent->menuBar()->setItemChecked(10002, false);
-               parent->menuBar()->setItemChecked(10001, false);
-       }
-
-       /* Automatic Update */
-       QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
-       if (AutoUpdate.compare("true") == 0)
-       {
-               parent->menuBar()->setItemChecked(1001, true);
-               smeshGUI->myAutomaticUpdate = true;
-       }
-       else
-       {
-               parent->menuBar()->setItemChecked(1001, false);
-               smeshGUI->myAutomaticUpdate = false;
-       }
-
-       /* menus disable */
-       parent->menuBar()->setItemEnabled(11, false);   // IMPORT
-
-       return true;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::DefinePopup(QString & theContext, QString & theParent,
-       QString & theObject)
-{
-       /* Create or retrieve an object SMESHGUI */
-       SMESHGUI::GetOrCreateSMESHGUI(QAD_Application::getDesktop());
-
-       // NRI : Temporary added
-       //  if ( smeshGUI->myStudy->GetProperties()->IsLocked() ) {
-       //    theObject = "NothingSelected";
-       //    theContext = "NothingSelected";
-       //  }
-       // NRI
-
-       SALOME_Selection *Sel =
-               SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
-       int nbSel = Sel->IObjectCount();
-       if (nbSel == 0)
-       {
-               if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() ==
-                       VIEW_VTK)
-               {
-                       vtkScalarBarActor *aScalarBar = smeshGUI->GetScalarBar();
-                       if ((aScalarBar != NULL) && (aScalarBar->GetVisibility() == 1))
-                       {
-                               theObject = "ScalarBar";
-                               theContext = "";
-                       }
-                       else
-                       {
-                               theObject = "NothingSelected";
-                               theContext = "NothingSelected";
-                       }
-               }
-               else
-               {
-                       theObject = "NothingSelected";
-                       theContext = "NothingSelected";
-               }
-       }
-       else if (nbSel == 1)
-       {
-               theObject = smeshGUI->CheckTypeObject(Sel->firstIObject());
-               theContext = "";
-       }
-       else
-       {
-               theObject = smeshGUI->CheckHomogeneousSelection();
-               theContext = "";
-       }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-bool SMESHGUI::CustomPopup(QAD_Desktop * parent,
-       QPopupMenu * popup,
-       const QString & theContext,
-       const QString & theParent, const QString & theObject)
-{
-       // Popup should be customized for any viewer since some meaningless commands may be present in the popup
-       //if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) //Test du type de viewer true=OCC false=VTK
-       //  return false;
-       /* Create or retrieve an object SMESHGUI */
-       SMESHGUI::GetOrCreateSMESHGUI(parent);
-
-       // NRI : Temporary added
-       //  if ( smeshGUI->myStudy->GetProperties()->IsLocked() ) {
-       //    return false;
-       //  }
-       // NRI
-
-       SALOME_Selection *Sel =
-               SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
-       QAD_StudyFrame *studyFrame = smeshGUI->myActiveStudy->getActiveStudyFrame();
-       int nbSel = Sel->IObjectCount();
-
-       if (nbSel == 0)
-       {
-               if (studyFrame->getTypeView() != VIEW_VTK)
-                       popup->clear();
-               return false;
-       }
-       else if (nbSel == 1)
-       {
-               QString parentComp =
-                       ((SALOMEGUI_Desktop *) parent)->getComponentFromSelection();
-               // First check type of active viewer (VTK required)
-               if ( /*studyFrame->getTypeView() != VIEW_VTK || */ parentComp !=
-                       parent->getActiveComponent())
-               {
-                       //MESSAGE("CustomPopup(): VTK viewer required, removing all SMESH-specific popup menu items")
-                       while (1)
-                       {
-                               int id = popup->idAt(0);
-                               if (id <= QAD_TopLabel_Popup_ID)
-                                       popup->removeItemAt(0);
-                               else
-                                       break;
-                       }
-                       if (theObject.compare("Component") == 0)
-                       {
-                               popup->removeItem(QAD_DisplayOnly_Popup_ID);
-                       }
-                       return false;
-               }
-
-               // Remove common popup items for Submesh, Hypothesis and Algorithm
-               if (theObject.compare("SubMesh") == 0 ||
-                       theObject.compare("Hypothesis") == 0 ||
-                       theObject.compare("Algorithm") == 0)
-               {
-                       popup->removeItem(QAD_Display_Popup_ID);
-                       popup->removeItem(QAD_DisplayOnly_Popup_ID);
-                       popup->removeItem(QAD_Erase_Popup_ID);
-                       int id = popup->idAt(popup->count() - 1);       // last item
-                       if (id < 0 && id != -1)
-                               popup->removeItem(id);  // separator
-               }
-
-               if (theObject.compare("Component") == 0)
-               {
-                       popup->removeItem(QAD_DisplayOnly_Popup_ID);
-                       return true;
-               }
-
-               int id = QAD_TopLabel_Popup_ID; //popup->idAt(0);
-               QFont f = QApplication::font();
-               f.setBold(TRUE);
-
-               Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
-
-               if (theParent.compare("Viewer") == 0)
-               {
-                       if (popup->idAt(0) == id)
-                       {
-                               popup->removeItem(id);
-                               popup->insertItem(new CustomItem(QString(IObject->getName()),
-                                               f), id, 0);
-                       }
-
-                       Standard_Boolean res;
-                       SMESH_Actor *ac =
-                               smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
-                       if (res && studyFrame->getTypeView() == VIEW_VTK)
-                       {
-                               VTKViewer_RenderWindowInteractor *myRenderInter =
-                                       ((VTKViewer_ViewFrame *) studyFrame->getRightFrame()->
-                                       getViewFrame())->getRWInteractor();
-                               if (myRenderInter->isVisible(IObject))
-                               {
-                                       popup->removeItem(QAD_Display_Popup_ID);
-                               }
-                               else
-                               {
-                                       popup->removeItem(QAD_Erase_Popup_ID);
-                               }
-                       }
-                       else
-                       {
-                               popup->removeItem(QAD_Erase_Popup_ID);
-                               if (!res)
-                               {                               // mesh not computed -> can't display it
-                                       popup->removeItem(QAD_Display_Popup_ID);
-                                       popup->removeItem(QAD_DisplayOnly_Popup_ID);
-                                       popup->removeItemAt(popup->count() - 1);        //separator
-                               }
-                       }
-               }
-               else if (theParent.compare("ObjectBrowser") == 0)
-               {
-                       if (theObject.compare("Mesh") == 0 ||
-                               theObject.compare("SubMesh") == 0 ||
-                               theObject.compare("Hypothesis") == 0 ||
-                               theObject.compare("Algorithm") == 0)
-                       {
-                               popup->removeItemAt(0);
-                       }
-                       else
-                       {
-                               if (popup->idAt(0) == id)
-                               {
-                                       popup->removeItem(id);
-                                       popup->removeItemAt(0); //separator
-                               }
-                       }
-
-                       Standard_Boolean res;
-                       SMESH_Actor *ac =
-                               smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
-                       if (res && studyFrame->getTypeView() == VIEW_VTK)
-                       {
-                               VTKViewer_RenderWindowInteractor *myRenderInter =
-                                       ((VTKViewer_ViewFrame *) studyFrame->getRightFrame()->
-                                       getViewFrame())->getRWInteractor();
-                               if (myRenderInter->isVisible(IObject))
-                               {
-                                       popup->removeItem(QAD_Display_Popup_ID);
-                               }
-                               else
-                               {
-                                       popup->removeItem(QAD_Erase_Popup_ID);
-                               }
-                       }
-                       else
-                       {
-                               if (theObject.compare("Mesh") == 0 ||
-                                       theObject.compare("SubMesh") == 0 ||
-                                       theObject.compare("Hypothesis") == 0 ||
-                                       theObject.compare("Algorithm") == 0)
-                               {
-                               }
-                               else
-                               {
-                                       popup->removeItem(QAD_Erase_Popup_ID);
-                                       if (!res)
-                                       {                       // mesh not computed -> can't display it
-                                               popup->removeItem(QAD_Display_Popup_ID);
-                                               popup->removeItem(QAD_DisplayOnly_Popup_ID);
-                                               popup->removeItemAt(popup->count() - 1);        //separator
-                                       }
-                               }
-                       }
-               }
-       }
-       else
-       {
-               QString parentComp =
-                       ((SALOMEGUI_Desktop *) parent)->getComponentFromSelection();
-               QAD_StudyFrame *studyFrame =
-                       smeshGUI->myActiveStudy->getActiveStudyFrame();
-               if ( /*studyFrame->getTypeView() != VIEW_VTK || */ parentComp !=
-                       parent->getActiveComponent())
-               {
-                       //MESSAGE("CustomPopup(): VTK viewer required, removing all SMESH-specific popup menu items")
-                       while (1)
-                       {
-                               int id = popup->idAt(0);
-                               if (id <= QAD_TopLabel_Popup_ID && id != -1)
-                                       popup->removeItemAt(0);
-                               else
-                                       break;
-                       }
-                       if (parentComp.isNull())
-                       {                                       // objects from several components are selected
-                               popup->removeItem(QAD_DisplayOnly_Popup_ID);
-                               popup->removeItem(QAD_Display_Popup_ID);
-                               popup->removeItem(QAD_Erase_Popup_ID);
-                               int id = popup->idAt(popup->count() - 1);       // last item
-                               if (id < 0 && id != -1)
-                                       popup->removeItem(id);  // separator
-                       }
-                       return false;
-               }
-
-               QString type = smeshGUI->CheckHomogeneousSelection();
-               if (type.compare("Heterogeneous Selection") != 0)
-               {
-                       int id = QAD_TopLabel_Popup_ID; //popup->idAt(0);
-                       QFont f = QApplication::font();
-                       f.setBold(TRUE);
-                       popup->removeItem(id);
-                       popup->insertItem(new CustomItem(QString("%1 ").arg(nbSel) + type +
-                                       " (s) ", f), id, 0);
-               }
-       }
-       return false;
-}
-
-//=============================================================================
-/*! Method:  BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
- *  Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
- */
-//=============================================================================
-void SMESHGUI::BuildPresentation(const Handle(SALOME_InteractiveObject) & theIO)
-{
-       /* Create or retrieve an object SMESHGUI */
-       SMESHGUI::GetOrCreateSMESHGUI(QAD_Application::getDesktop());
-
-       QAD_StudyFrame *activeFrame =
-               smeshGUI->myActiveStudy->getActiveStudyFrame();
-       if (activeFrame->getTypeView() == VIEW_VTK)
-       {
-               // VTK
-               SALOMEDS::SObject_var fatherSF =
-                       smeshGUI->myStudy->FindObjectID(activeFrame->entry());
-
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(smeshGUI->myActiveStudy->
-                       getSelection());
-               SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-
-//    for(;It.More();It.Next()) {
-//      Handle(SALOME_InteractiveObject) IObject = It.Value();
-               Handle(SALOME_InteractiveObject) IObject = theIO;
-               if (IObject->hasEntry())
-               {
-                       // Look for the actor in all views
-                       Standard_Boolean res;
-                       SMESH_Actor *ac =
-                               smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
-
-                       // Actor not found at all -> mesh is not computed -> do nothing!!!
-                       if (!res)
-                       {
-                               /*SMESH::SMESH_Mesh_var aM;
-                                * SALOMEDS::SObject_var aMorSM = smeshGUI->myStudy->FindObjectID( IObject->getEntry() );
-                                * SALOMEDS::SObject_var father = aMorSM->GetFather();
-                                * SALOMEDS::SObject_var fatherComp = aMorSM->GetFatherComponent();
-                                * 
-                                * // Non-displayable objects (Hypo, Algo) have tags < 3 or have a father different from component
-                                * if (aMorSM->Tag() < 3 || strcmp(father->GetID(), fatherComp->GetID()) != 0)
-                                * continue;
-                                * 
-                                * SALOMEDS::GenericAttribute_var anAttr;
-                                * SALOMEDS::AttributeIOR_var     anIOR;
-                                * if ( !aMorSM->_is_nil() ) {
-                                * if (aMorSM->FindAttribute(anAttr, "AttributeIOR") ) {
-                                * anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                                * aM = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) );
-                                * }
-                                * }
-                                * 
-                                * if (!aM->_is_nil()) {
-                                * smeshGUI->InitActor(aM);
-                                * ac = smeshGUI->ReadScript(aM);
-                                * }
-                                * 
-                                * if (ac) {
-                                * smeshGUI->DisplayActor( ac, true );
-                                * smeshGUI->DisplayEdges( ac ); 
-                                * smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() );
-                                * } */
-//    continue;
-                       }
-                       else
-                       {                                       // The actor exists in some view
-                               // Check whether the actor belongs to the active view
-                               VTKViewer_RenderWindowInteractor *rwInter =
-                                       ((VTKViewer_ViewFrame *) activeFrame->getRightFrame()->
-                                       getViewFrame())->getRWInteractor();
-
-                               // The actor belongs to inactive view -> create a copy and display it in the active view
-                               if (!rwInter->isInViewer(IObject))
-                               {
-                                       if(ac->GetMapper()==NULL)
-                                       {
-                                               SMESH::SMESH_Mesh_var aMesh = smeshGUI->ConvertIOinMesh(theIO, res);
-                                               ac=smeshGUI->ReadScript(aMesh);
-                                       }
-                                       SMESH_Actor *acCopy = SMESH_Actor::New();
-                                       acCopy->ShallowCopy(ac);
-                                       ac = acCopy;
-                               }
-                               smeshGUI->DisplayActor(ac, false);
-                               smeshGUI->DisplayEdges(ac);
-                               smeshGUI->ChangeRepresentation(ac, ac->getDisplayMode());
-                       }
-               }
-//    }
-       }
-       else
-       {
-       MESSAGE
-                       ("BuildPresentation() must not be called while non-VTK view is active")}
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::setOrb()
-{
-       try
-       {
-               ORB_INIT & init = *SINGLETON_ < ORB_INIT >::Instance();
-               ASSERT(SINGLETON_ < ORB_INIT >::IsAlreadyExisting());
-               _orb = init(0, 0);
-       } catch(...)
-       {
-               INFOS("internal error : orb not found");
-               _orb = 0;
-       }
-       ASSERT(!CORBA::is_nil(_orb));
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-SMESH_Actor *SMESHGUI::ReadScript(SMESH::SMESH_Mesh_ptr aMesh)
-{
-       SMESH_Actor *MeshActor;
-       if (!aMesh->_is_nil())
-       {
-               Standard_Boolean result;
-               MeshActor = FindActor(aMesh, result, false);
-               if (result)
-               {
-                       SMESH::log_array_var aSeq = aMesh->GetLog(true);
-
-                       if (aSeq->length() == 0)
-                       {
-                               MESSAGE("ReadScript(): log is empty") return MeshActor;
-                       }
-
-                       for (unsigned int ind = 0; ind < aSeq->length(); ind++)
-                       {
-                               switch (aSeq[ind].commandType)
-                               {
-                               case SMESH::ADD_NODE:
-                               {
-                                       AddNodes(MeshActor, aSeq[ind].number, aSeq[ind].coords,
-                                               aSeq[ind].indexes);
-                                       break;
-                               }
-                               case SMESH::ADD_EDGE:
-                               {
-                                       //          AddEdges( MeshActor, aSeq[ind].number, aSeq[ind].coords, aSeq[ind].indexes );
-                                       break;
-                               }
-                               case SMESH::ADD_TRIANGLE:
-                               {
-                                       AddTriangles(MeshActor, aSeq[ind].number, aSeq[ind].coords,
-                                               aSeq[ind].indexes);
-                                       break;
-                               }
-                               case SMESH::ADD_QUADRANGLE:
-                               {
-                                       AddQuadrangles(MeshActor, aSeq[ind].number,
-                                               aSeq[ind].coords, aSeq[ind].indexes);
-                                       break;
-                               }
-                               case SMESH::ADD_TETRAHEDRON:
-                               {
-                                       AddTetras(MeshActor, aSeq[ind].number, aSeq[ind].coords,
-                                               aSeq[ind].indexes);
-                                       break;
-                               }
-                               case SMESH::ADD_PYRAMID:
-                               {
-                                       break;
-                               }
-                               case SMESH::ADD_PRISM:
-                               {
-                                       break;
-                               }
-                               case SMESH::ADD_HEXAHEDRON:
-                               {
-                                       AddHexaedres(MeshActor, aSeq[ind].number, aSeq[ind].coords,
-                                               aSeq[ind].indexes);
-                                       break;
-                               }
-                               case SMESH::REMOVE_NODE:
-                               {
-                                       RemoveNodes(MeshActor, aSeq[ind].number, aSeq[ind].coords,
-                                               aSeq[ind].indexes);
-                                       break;
-                               }
-                               case SMESH::REMOVE_ELEMENT:
-                               {
-                                       RemoveElements(MeshActor, aSeq[ind].number,
-                                               aSeq[ind].coords, aSeq[ind].indexes);
-                                       break;
-                               }
-                               }
-                       }
-                       return MeshActor;
-               }
-       }
-       return NULL;
-}
-
-//=============================================================================
-/*!
- *
- */
 //=============================================================================
-void SMESHGUI::Dump(SMESH_Actor * Mactor)
-{
-       vtkUnstructuredGrid *ugrid =
-               vtkUnstructuredGrid::SafeDownCast(Mactor->DataSource);
-       vtkPoints *Pts = ugrid->GetPoints();
-       int nbPts = Pts->GetNumberOfPoints();
-       int nbCells = ugrid->GetNumberOfCells();
-
-       FILE *In;
-       int i, j;
-       In = fopen("/tmp/dumpMesh", "w+");
-       fprintf(In, "%d %d\n", nbPts, nbCells);
-       for (int i = 0; i < nbPts; i++)
-       {
-               float *p = ugrid->GetPoint(i);
-               fprintf(In, "%d %e %e %e\n", i, p[0], p[1], p[2]);
-       }
-
-       for (int i = 0; i < nbCells; i++)
-       {
-               fprintf(In, "%d %d", i, ugrid->GetCell(i)->GetCellType());
-               vtkIdList *Id = ugrid->GetCell(i)->GetPointIds();
-               for (j = 0; j < Id->GetNumberOfIds(); j++)
-               {
-                       fprintf(In, " %d", Id->GetId(j));
-               }
-               fprintf(In, "\n");
-       }
-       fclose(In);
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::AddNodes(SMESH_Actor * Mactor, int number,
-       const SMESH::double_array & coords, const SMESH::long_array & indexes)
-{
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       if (Mactor->GetMapper() == NULL)
-       {
-               vtkPoints *Pts = vtkPoints::New();
-               SMESH_Grid *ugrid = SMESH_Grid::New();
-               ugrid->Allocate();
-
-               int i = 1;
-               int j = 1;
-               while (i <= number)
-               {
-                       int idVTK =
-                               Pts->InsertNextPoint(coords[j - 1], coords[j], coords[j + 1]);
-                       //Mactor->AddNode( indexes[i-1], idVTK );
-                       ugrid->AddNode(indexes[i - 1], idVTK);
-                       i++;
-                       j = j + 3;
-               }
-               //vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New();
-               ugrid->SetPoints(Pts);
-               vtkDataSetMapper *PtsMapper = vtkDataSetMapper::New();
-               PtsMapper->SetInput(ugrid);
-               Mactor->DataSource = PtsMapper->GetInput();
-               Mactor->SetMapper(PtsMapper);
-       }
-       else
-       {
-               //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-               SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-               int i = 1;
-               int j = 1;
-               while (i <= number)
-               {
-                       int idVTK =
-                               ugrid->GetPoints()->InsertNextPoint(coords[j - 1], coords[j],
-                               coords[j + 1]);
-                       ugrid->AddNode(indexes[i - 1], idVTK);
-                       i++;
-                       j = j + 3;
-               }
-               vtkDataSetMapper *PtsMapper = vtkDataSetMapper::New();
-               PtsMapper->SetInput(ugrid);
-               Mactor->DataSource = PtsMapper->GetInput();
-               Mactor->SetMapper(PtsMapper);
-       }
-       QApplication::restoreOverrideCursor();
-}
-
-//=============================================================================
-/*!
- *
+/*! function : GetMeshesUsingAlgoOrHypothesis()
+ *  purpose  : return a list of Study objects (mesh kind) that have 'AlgoOrHyp' affected.
+ *           : However is supposed here that father of father of an hypothesis is a Mesh Object.
  */
-//=============================================================================
-void SMESHGUI::AddNode(SMESH_Actor * Mactor, int idnode, float x, float y,
-       float z)
+//=============================================================================      
+SALOMEDS::Study::ListOfSObject *
+       SMESHGUI::GetMeshesUsingAlgoOrHypothesis(SMESH::
+       SMESH_Hypothesis_ptr AlgoOrHyp)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       MESSAGE("SMESHGUI::AddNode " << idnode << " : " << x << ";" << y << ";" <<
-               z) if (Mactor->GetMapper() == NULL)
-       {
-               vtkPoints *Pts = vtkPoints::New();
-               int idVTK = Pts->InsertNextPoint(x, y, z);
-               //Mactor->AddNode( idnode, idVTK );
-               //vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New();
-               SMESH_Grid *ugrid = SMESH_Grid::New();
-               ugrid->Allocate();
-               ugrid->AddNode(idnode, idVTK);
-               ugrid->SetPoints(Pts);
-               vtkDataSetMapper *PtsMapper = vtkDataSetMapper::New();
-               PtsMapper->SetInput(ugrid);
-               Mactor->DataSource = PtsMapper->GetInput();
-               Mactor->SetMapper(PtsMapper);
-       }
-       else
-       {
-               //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-               SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-               int idVTK = ugrid->GetPoints()->InsertNextPoint(x, y, z);
-               //Mactor->AddNode( idnode, idVTK );
-               ugrid->AddNode(idnode, idVTK);
-               vtkDataSetMapper *PtsMapper = vtkDataSetMapper::New();
-               PtsMapper->SetInput(ugrid);
-               Mactor->DataSource = PtsMapper->GetInput();
-               Mactor->SetMapper(PtsMapper);
+  SALOMEDS::Study::ListOfSObject_var listSOmesh =
+    new SALOMEDS::Study::ListOfSObject;
+  listSOmesh->length(0);
+  unsigned int index = 0;
+  if (!AlgoOrHyp->_is_nil()) {
+    SALOMEDS::SObject_var SO_Hypothesis =
+      smeshGUI->GetStudyAPI().FindObject(AlgoOrHyp);
+    if (!SO_Hypothesis->_is_nil()) {
+      SALOMEDS::Study::ListOfSObject_var listSO =
+       smeshGUI->myStudy->FindDependances(SO_Hypothesis);
+      MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<<listSO->length());
+      for (unsigned int i = 0; i < listSO->length(); i++) {
+       SALOMEDS::SObject_ptr SO = listSO[i];
+       if (!SO->_is_nil()) { 
+         SALOMEDS::SObject_var aFather = SO->GetFather();
+         if (!aFather->_is_nil()) {
+           SALOMEDS::SObject_var SOfatherFather = aFather->GetFather();
+           if (!SOfatherFather->_is_nil()) {
+             MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list");
+             index++;
+             listSOmesh->length(index);
+             listSOmesh[index - 1] = SOfatherFather;
+           }
+         }
        }
-       QApplication::restoreOverrideCursor();
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::RemoveNode(SMESH_Actor * Mactor, int idnode)
-{
-       MESSAGE(" OLD RemoveNode method ")
-//   int id = Mactor->GetIdVTKNode( idnode );
-//    MESSAGE ( " RemoveNode id VTK " << id )
-//    if ( Mactor->GetMapper() != NULL ) {
-//      vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-//      vtkUnstructuredGrid* newUgrid = vtkUnstructuredGrid::New();
-//      vtkPoints *Pts = ugrid->GetPoints();
-//      vtkPoints *newPts = vtkPoints::New();
-//      int nbPts = Pts->GetNumberOfPoints();
-//      bool findPt = false;
-//      for ( int i = 0; i < nbPts; i++ ) {
-//        if ( id != i ) {
-//      if ( !findPt)
-//        newPts->InsertPoint(i, Pts->GetPoint(i) );
-//      else
-//        newPts->InsertPoint(i-1, Pts->GetPoint(i) );
-//        } else {
-//      findPt = true;
-//      Mactor->RemoveNode( idnode );
-//        }
-//      }
-//      newUgrid->SetPoints(newPts);
-//      int nbCells = ugrid->GetNumberOfCells();
-//      for ( int i = 0; i < nbCells; i++ ) {
-//        vtkIdList *Ids = ugrid->GetCell(i)->GetPointIds();
-//        vtkIdList *newIds = vtkIdList::New();
-//        int nbIds = Ids->GetNumberOfIds();
-//        newIds->SetNumberOfIds(nbIds);
-//        for ( int j = 0; j < nbIds; j++ ) {
-//      int theid = Ids->GetId(j);
-//      if ( theid > id ) {
-//        newIds->SetId( j, theid-1 );
-//      } else
-//        newIds->SetId( j, theid );
-//        }
-//        int idSMDSel = Mactor->GetIdSMESHDSElement( i );
-//        Mactor->RemoveElement( idSMDSel, false );
-//        int idVTKel = newUgrid->InsertNextCell( ugrid->GetCell(i)->GetCellType(), newIds );
-//        Mactor->AddElement( idSMDSel, idVTKel );
-//      }
-//      vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
-//      Mapper->SetInput( newUgrid );
-//      Mactor->DataSource = Mapper->GetInput();
-//      Mactor->SetMapper(Mapper);
-//      UpdateView();
-//    }
+      }
+    }
+  }
+  MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed");
+  return listSOmesh._retn();
 }
 
 //=============================================================================
@@ -4496,103 +3106,54 @@ void SMESHGUI::RemoveNode(SMESH_Actor * Mactor, int idnode)
  *
  */
 //=============================================================================
-void SMESHGUI::RemoveNodes(SMESH_Actor * Mactor, int number,
-       const SMESH::double_array & coords, const SMESH::long_array & indexes)
-{
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       int i = 1;
-       while (i <= number)
-       {
-               Mactor->RemoveNode(indexes[i - 1]);
-               i++;
-       }
-
-       TColStd_DataMapOfIntegerInteger newMapVTKNodes;
-       TColStd_DataMapOfIntegerInteger newMapSMESHDSNodes;
-       TColStd_DataMapOfIntegerInteger MapOldNodesToNewNodes;
-
-       if (Mactor->GetMapper() != NULL)
-       {
-               SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-               SMESH_Grid *newUgrid = SMESH_Grid::New();
-               newUgrid->CopyMaps(ugrid);
-
-               vtkPoints *Pts = ugrid->GetPoints();
-               vtkPoints *newPts = vtkPoints::New();
-               int nbPts = Pts->GetNumberOfPoints();
-               int j = 0;
-               for (int i = 0; i < nbPts; i++)
-               {
-                       int idSMESHDSNode = Mactor->GetIdSMESHDSNode(i);
-                       if (idSMESHDSNode != -1)
-                       {
-                               newPts->InsertPoint(j, Pts->GetPoint(i));
-
-                               newMapVTKNodes.Bind(j, idSMESHDSNode);
-                               newMapSMESHDSNodes.Bind(idSMESHDSNode, j);
-
-                               MapOldNodesToNewNodes.Bind(i, j);
-                               j++;
-                       }
-               }
-
-               newUgrid->SetIdsVTKNode(newMapVTKNodes);
-               newUgrid->SetIdsSMESHDSNode(newMapSMESHDSNodes);
-               newUgrid->SetPoints(newPts);
-
-               TColStd_DataMapOfIntegerInteger newMapElementSMDStoVTK;
-               TColStd_DataMapOfIntegerInteger newMapElementVTKtoSMDS;
-
-               int nbCells = ugrid->GetNumberOfCells();
-               for (int i = 0; i < nbCells; i++)
-               {
-                       vtkIdList *Ids = ugrid->GetCell(i)->GetPointIds();
-                       vtkIdList *newIds = vtkIdList::New();
-                       int nbIds = Ids->GetNumberOfIds();
-                       newIds->SetNumberOfIds(nbIds);
-                       bool isGood = true;
-                       for (int j = 0; j < nbIds; j++)
-                       {
-                               int theid = Ids->GetId(j);
-                               if (MapOldNodesToNewNodes.IsBound(theid))
-                               {
-                                       newIds->SetId(j, MapOldNodesToNewNodes.Find(theid));
-                               }
-                               else
-                               {
-                                       isGood = false;
-                                       break;
-                               }
-                       }
-
-                       // Filtering out cells based on non-existing nodes
-                       if (isGood)
-                       {
-                               int idSMDSel = Mactor->GetIdSMESHDSElement(i);
-                               int idVTKel =
-                                       newUgrid->InsertNextCell(ugrid->GetCell(i)->GetCellType(),
-                                       newIds);
-
-                               newMapElementSMDStoVTK.Bind(idSMDSel, idVTKel);
-                               newMapElementVTKtoSMDS.Bind(idVTKel, idSMDSel);
-                       }
-               }
-
-               newUgrid->SetIdsVTKElement(newMapElementVTKtoSMDS);
-               newUgrid->SetIdsSMESHDSElement(newMapElementSMDStoVTK);
-
-               // Copy new data to the old DatSource: keep the single DataSource for all actors
-               ugrid->DeepCopy(newUgrid);
-
-               vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
-               Mapper->SetInput(ugrid);
-               Mactor->SetMapper(Mapper);
-
-               // Commented to avoid multiple viewer updates when called by ReadScript()
-               //UpdateView();
-
-       }
-       QApplication::restoreOverrideCursor();
+void SMESHGUI::Import_Mesh(QAD_Desktop * parent, int theCommandID){
+  QString filter;
+  string myExtension;
+  
+  if(theCommandID == 113){
+    filter = tr("MED files (*.med)");
+  }else if (theCommandID == 112){
+    filter = tr("IDEAS files (*.unv)");
+  }else if (theCommandID == 111){
+    filter = tr("DAT files (*.dat)");
+  }
+  QString filename = QAD_FileDlg::getFileName(parent,
+                                             "",
+                                             filter,
+                                             tr("Import mesh"),
+                                             true);
+  if(!filename.isEmpty()){
+    QAD_WaitCursor wc;
+    SMESH::mesh_array_var aMeshes;
+    try {
+      SMESH::DriverMED_ReadStatus res;
+      aMeshes = smeshGUI->myComponentMesh->CreateMeshesFromMED(filename.latin1(),
+                                                               res);
+      if ( res > SMESH::DRS_OK ) {
+       wc.stop();
+       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+                             tr("SMESH_WRN_WARNING"),
+                             tr(QString("SMESH_DRS_%1").arg(res)),
+                             tr("SMESH_BUT_OK"));
+       wc.start();
+
+      }
+    }
+    catch (const SALOME::SALOME_Exception& S_ex)
+    {
+      wc.stop();
+      QtCatchCorbaException(S_ex);
+      wc.start();
+    }
+    for ( int i = 0, n = aMeshes->length(); i < n; i++ ) {
+      SALOMEDS::SObject_var aMeshSO = smeshGUI->myStudyAPI.FindObject( aMeshes[i] );
+      if ( !aMeshSO->_is_nil() ) {
+       SALOMEDS::StudyBuilder_var aBuilder = smeshGUI->myStudy->NewBuilder();
+       SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) );
+       aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
+      }
+    }
+  }
 }
 
 //=============================================================================
@@ -4600,40 +3161,61 @@ void SMESHGUI::RemoveNodes(SMESH_Actor * Mactor, int number,
  *
  */
 //=============================================================================
-void SMESHGUI::RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh,
-       const TColStd_MapOfInteger & MapIndex)
-{
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       Standard_Boolean result;
-       SMESH_Actor *ac = FindActor(aMesh, result, true);
-       if (result)
-       {
-               SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
-               anArrayOfIdeces->length(MapIndex.Extent());
-               TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
-               int i = 0;
-               for (; ite.More(); ite.Next())
-               {
-                       //      MESSAGE ( " RemoveNode : id " << ac->GetIdSMESHDSNode(ite.Key()) )
-                       anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key());
-                       i++;
-               }
-               SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
-               aMeshEditor->RemoveNodes(anArrayOfIdeces);
-
-       }
-       if (myAutomaticUpdate)
-       {
-               SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
-               if (Mesh != NULL)
-               {
-                       smeshGUI->DisplayActor(Mesh);
-                       smeshGUI->DisplayEdges(Mesh);
-                       smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
-                       AddActorInSelection(Mesh);
-               }
-       }
-       QApplication::restoreOverrideCursor();
+void SMESHGUI::Export_Mesh(QAD_Desktop * parent, int theCommandID)
+{
+  SALOME_Selection *Sel =
+    SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection());
+  int nbSel = Sel->IObjectCount();
+  if ( !nbSel )
+    return;
+  Standard_Boolean res;
+  Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+  SMESH::SMESH_Mesh_var aMesh = smeshGUI->ConvertIOinMesh(IObject, res);
+  if ( res && ( nbSel == 1 || theCommandID == 122 ) ) {// MED export supports multiple meshes
+    QString aFilter, aTitle = tr("Export mesh");
+    switch ( theCommandID ) {
+    case 122:
+      aFilter = tr("MED files (*.med)");
+      break;
+    case 121:
+      aFilter = tr("DAT files (*.dat)");
+      break;
+    case 123:
+      aFilter = tr("IDEAS files (*.unv)");
+      break;
+    default:
+      break;
+    }
+    
+    QString filename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
+    
+    if ( !filename.isEmpty() ) {
+      // Check whether the file already exists and delete it if yes
+      QFile aFile( filename );
+      if ( aFile.exists() )
+       aFile.remove();
+      
+      QAD_WaitCursor wc;
+      for ( SALOME_ListIteratorOfListIO it( Sel->StoredIObjects() ); it.More(); it.Next() ) {
+       aMesh = smeshGUI->ConvertIOinMesh( it.Value(), res );
+       if ( res ) {
+         switch ( theCommandID ) {
+         case 122:
+           aMesh->ExportMED( filename.latin1(), true ); // currently, automatic groups are always created
+           break;
+         case 121:
+           aMesh->ExportDAT( filename.latin1() );
+           break;
+         case 123:
+           aMesh->ExportUNV( filename.latin1() );
+           break;
+         default:
+           break;
+         }
+       }
+      }
+    }
+  }
 }
 
 //=============================================================================
@@ -4641,29 +3223,10 @@ void SMESHGUI::RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh,
  *
  */
 //=============================================================================
-void SMESHGUI::RemoveElement(SMESH_Actor * Mactor, int idelement)
+bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
+                           QAD_StudyFrame * studyFrame)
 {
-       MESSAGE(" OLD RemoveElement method ")
-//    int id = Mactor->GetIdVTKElement( idelement );
-//    MESSAGE ( " RemoveElement id VTK : " << id )
-//    if ( Mactor->GetMapper() != NULL ) {
-//      vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-//      vtkUnstructuredGrid* newUgrid = vtkUnstructuredGrid::New();
-//      int nbCells = ugrid->GetNumberOfCells();
-//      for ( int i = 0; i < nbCells; i++ ) {
-//        if ( id != i ) {
-//      newUgrid->InsertNextCell( ugrid->GetCell(i)->GetCellType(), 
-//                    ugrid->GetCell(i)->GetPointIds() );
-//        } else
-//      Mactor->RemoveElement( idelement );
-//      }
-//      newUgrid->SetPoints(ugrid->GetPoints());
-//      vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
-//      Mapper->SetInput( newUgrid );
-//      Mactor->DataSource = Mapper->GetInput();
-//      Mactor->SetMapper(Mapper);
-//      UpdateView();
-//    }
+  return false;
 }
 
 //=============================================================================
@@ -4671,55 +3234,10 @@ void SMESHGUI::RemoveElement(SMESH_Actor * Mactor, int idelement)
  *
  */
 //=============================================================================
-void SMESHGUI::RemoveElements(SMESH_Actor * Mactor, int number,
-       const SMESH::double_array & coords, const SMESH::long_array & indexes)
+bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
+                          QAD_StudyFrame * studyFrame)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       int i = 1;
-       while (i <= number)
-       {
-               Mactor->RemoveElement(indexes[i - 1]);
-               i++;
-       }
-       TColStd_DataMapOfIntegerInteger newMapElementSMDStoVTK;
-       TColStd_DataMapOfIntegerInteger newMapElementVTKtoSMDS;
-
-       if (Mactor->GetMapper() != NULL)
-       {
-               SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-               SMESH_Grid *newUgrid = SMESH_Grid::New();
-               newUgrid->CopyMaps(ugrid);
-
-               int nbCells = ugrid->GetNumberOfCells();
-               for (int i = 0; i < nbCells; i++)
-               {
-                       int idSMESHDSElement = Mactor->GetIdSMESHDSElement(i);
-                       if (idSMESHDSElement != -1)
-                       {
-                               int newId =
-                                       newUgrid->InsertNextCell(ugrid->GetCell(i)->GetCellType(),
-                                       ugrid->GetCell(i)->GetPointIds());
-                               newMapElementSMDStoVTK.Bind(idSMESHDSElement, newId);
-                               newMapElementVTKtoSMDS.Bind(newId, idSMESHDSElement);
-                       }
-               }
-
-               newUgrid->SetIdsVTKElement(newMapElementVTKtoSMDS);
-               newUgrid->SetIdsSMESHDSElement(newMapElementSMDStoVTK);
-
-               newUgrid->SetPoints(ugrid->GetPoints());
-
-               // Copy new data to the old DatSource: keep the single DataSource for all actors
-               ugrid->DeepCopy(newUgrid);
-
-               vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
-               Mapper->SetInput(ugrid);
-               Mactor->SetMapper(Mapper);
-
-               // Commented to avoid multiple viewer updates when called by ReadScript()
-               //UpdateView();
-       }
-       QApplication::restoreOverrideCursor();
+  return true;
 }
 
 //=============================================================================
@@ -4727,44 +3245,10 @@ void SMESHGUI::RemoveElements(SMESH_Actor * Mactor, int number,
  *
  */
 //=============================================================================
-void SMESHGUI::RemoveElements(SMESH::SMESH_Mesh_ptr aMesh,
-       const TColStd_MapOfInteger & MapIndex)
+bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
+                         QAD_StudyFrame * studyFrame)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       Standard_Boolean result;
-       SMESH_Actor *ac = FindActor(aMesh, result, true);
-       if (result)
-       {
-               SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
-               anArrayOfIdeces->length(MapIndex.Extent());
-               TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
-               int i = 0;
-               for (; ite.More(); ite.Next())
-               {
-                       //      MESSAGE ( " RemoveElement : id " << ite.Key() << "," << ac->GetIdSMESHDSElement(ite.Key()) )
-                       anArrayOfIdeces[i] = ac->GetIdSMESHDSElement(ite.Key());
-                       i++;
-               }
-
-               SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
-               aMeshEditor->RemoveElements(anArrayOfIdeces);
-       }
-
-       if (myAutomaticUpdate)
-       {
-               SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
-               if (Mesh != NULL)
-               {
-                       smeshGUI->DisplayActor(Mesh);
-                       smeshGUI->DisplayEdges(Mesh);
-                       smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
-                       AddActorInSelection(Mesh);
-#ifdef TRACE
-                       Dump(Mesh);
-#endif
-               }
-       }
-       QApplication::restoreOverrideCursor();
+  return true;
 }
 
 //=============================================================================
@@ -4772,59 +3256,64 @@ void SMESHGUI::RemoveElements(SMESH::SMESH_Mesh_ptr aMesh,
  *
  */
 //=============================================================================
-void SMESHGUI::OrientationElements(SMESH::SMESH_Mesh_ptr aMesh,
-       const TColStd_MapOfInteger & MapIndex)
+bool SMESHGUI::SetSettings(QAD_Desktop * parent)
 {
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-
-       vtkRenderer *theRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-       Standard_Boolean result;
-       SMESH_Actor *ac = FindActor(aMesh, result, true);
-       if (result)
-       {
-               //vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::New();
-               SMESH_Grid *UGrid = SMESH_Grid::New();
-               SMESH_Grid *oldGrid = SMESH_Grid::SafeDownCast(ac->DataSource);
-               UGrid->CopyMaps(oldGrid);
-
-               vtkGeometryFilter *gf = vtkGeometryFilter::New();
-               gf->SetInput(ac->DataSource);
-
-               vtkPolyDataMapper *Mapper = vtkPolyDataMapper::New();
-               Mapper->SetInput(gf->GetOutput());
-               Mapper->Update();
-
-               TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
-               for (; ite.More(); ite.Next())
-               {
-                       Mapper->GetInput()->ReverseCell(ite.Key());
-               }
-
-               UGrid->SetPoints(Mapper->GetInput()->GetPoints());
-               int nbCells = Mapper->GetInput()->GetNumberOfCells();
-               for (int i = 0; i < nbCells; i++)
-               {
-                       UGrid->InsertNextCell(Mapper->GetInput()->GetCellType(i),
-                               Mapper->GetInput()->GetCell(i)->GetPointIds());
-               }
-
-               // Copy new data to the old DatSource: keep the single DataSource for all actors
-               oldGrid->DeepCopy(UGrid);
-
-               vtkDataSetMapper *NewMapper = vtkDataSetMapper::New();
-               //NewMapper->SetInput( UGrid );
-               NewMapper->SetInput(oldGrid);
-               NewMapper->Update();
-
-               //ac->DataSource = NewMapper->GetInput();
-               ac->SetMapper(NewMapper);
-       }
-       vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
-       renWin->Render();
-       QApplication::restoreOverrideCursor();
+  MESSAGE("SMESHGUI::SetSettings.");
+  SMESHGUI::GetOrCreateSMESHGUI(parent);
+
+  /* Display mode */
+  QString DisplayMode = "Shading";
+  if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") )
+    DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
+  else
+    QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
+
+  bool Shrink = false;
+  if ( QAD_CONFIG->hasSetting("SMESH:Shrink") )
+    Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes";
+
+  if (DisplayMode == "Wireframe") {
+    // wireframe
+    parent->menuBar()->setItemChecked(10004, false);
+    parent->menuBar()->setItemChecked(10002, false);
+    parent->menuBar()->setItemChecked(10001, true);
+    parent->menuBar()->setItemEnabled(10003, true);
+  }
+  else if (DisplayMode == "Nodes") {
+    // poins
+    parent->menuBar()->setItemChecked(10004, true);
+    parent->menuBar()->setItemChecked(10002, false);
+    parent->menuBar()->setItemChecked(10001, false);
+    parent->menuBar()->setItemEnabled(10003, false);
+  }
+  else {
+    // default is shading
+    parent->menuBar()->setItemChecked(10004, false);
+    parent->menuBar()->setItemChecked(10002, true);
+    parent->menuBar()->setItemChecked(10001, false);
+    parent->menuBar()->setItemEnabled(10003, true);
+  }
+  parent->menuBar()->setItemChecked(10003, Shrink);
+
+  /* Automatic Update */
+  QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
+  if (AutoUpdate.compare("true") == 0) {
+    parent->menuBar()->setItemChecked(1001, true);
+    smeshGUI->myAutomaticUpdate = true;
+  }
+  else {
+    parent->menuBar()->setItemChecked(1001, false);
+    smeshGUI->myAutomaticUpdate = false;
+  }
+
+  /* Selection */
+  ::UpdateSelectionProp();
+
+  /* menus disable */
+  parent->menuBar()->setItemEnabled(111, false);       // IMPORT DAT
+  parent->menuBar()->setItemEnabled(112, false);       // IMPORT UNV
+
+  return true;
 }
 
 //=============================================================================
@@ -4832,174 +3321,33 @@ void SMESHGUI::OrientationElements(SMESH::SMESH_Mesh_ptr aMesh,
  *
  */
 //=============================================================================
-void SMESHGUI::DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh,
-       const TColStd_MapOfInteger & MapIndex)
+void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject)
 {
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       vtkRenderer *theRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-       Standard_Boolean result;
-
-       SMESH_Actor *ac = FindActor(aMesh, result, true);
-       if (result)
-       {
-               //vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::New();
-               SMESH_Grid *UGrid = SMESH_Grid::New();
-               vtkGeometryFilter *gf = vtkGeometryFilter::New();
-               gf->SetInput(ac->DataSource);
-
-               vtkExtractEdges *edges = vtkExtractEdges::New();
-               edges->SetInput(ac->DataSource);
-
-               vtkPolyDataMapper *Mapper = vtkPolyDataMapper::New();
-               Mapper->SetInput(edges->GetOutput());
-               Mapper->Update();
-
-               int nb = Mapper->GetInput()->GetNumberOfCells();
-               //MESSAGE ( "nb : " << nb )
-
-               TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
-               for (; ite.More(); ite.Next())
-               {
-                       vtkCell *StartEdge = Mapper->GetInput()->GetCell(ite.Key());
-                       //MESSAGE( "DCQ : Edge Id = " << ite.Key())
-                       int CellType = StartEdge->GetCellType();
-                       //MESSAGE( "DCQ : Cell Type = " << CellType)
-                       int nbPoints = StartEdge->GetNumberOfPoints();
-
-                       //MESSAGE( "DCQ : Nb Point = " << nbPoints)
-                       if (nbPoints == 2)
-                       {
-                               vtkUnstructuredGrid *StartUGrid =
-                                       vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
-
-                               vtkIdList *IdCells = vtkIdList::New();
-                               vtkIdList *IdPoints = StartEdge->GetPointIds();
-                               float p1[3];
-                               float p2[3];
-
-                               Mapper->GetInput()->GetPoints()->GetPoint(IdPoints->GetId(0),
-                                       p1);
-                               Mapper->GetInput()->GetPoints()->GetPoint(IdPoints->GetId(1),
-                                       p2);
-
-                               int idp1 = StartUGrid->FindPoint(p1);
-                               int idp2 = StartUGrid->FindPoint(p2);
-
-                               StartUGrid->GetPointCells(idp1, IdCells);
-
-                               //MESSAGE ( " pt 0 : " << IdPoints->GetId(0) )
-                               //MESSAGE ( " pt 1 : " << IdPoints->GetId(1) )
-
-                               //MESSAGE ( " pt 0 : " << idp1 )
-                               //MESSAGE ( " pt 1 : " << idp2 )
-
-                               vtkIdList *IdPts = vtkIdList::New();
-                               if (IdCells->GetNumberOfIds() >= 2)
-                               {
-                                       int nbCells = IdCells->GetNumberOfIds();
-                                       //MESSAGE ( " nbCells : " << nbCells )
-                                       for (int j = 0; j < nbCells; j++)
-                                       {
-                                               StartUGrid->GetCellPoints(IdCells->GetId(j), IdPts);
-                                               if (IdPts->IsId(idp2) == -1)
-                                               {
-                                                       IdCells->DeleteId(IdCells->GetId(j));
-                                               }
-                                       }
-
-                                       //MESSAGE ( " IdCells " << IdCells->GetNumberOfIds() )
-
-                                       vtkIdList *IdPts0 = vtkIdList::New();
-                                       vtkIdList *IdPts1 = vtkIdList::New();
-
-                                       if (IdCells->GetNumberOfIds() == 2)
-                                       {
-                                               StartUGrid->GetCellPoints(IdCells->GetId(0), IdPts0);
-                                               StartUGrid->GetCellPoints(IdCells->GetId(1), IdPts1);
-
-                                               //Create new faces
-                                               TColStd_MapOfInteger EndMapIndex;
-                                               for (int j = 0; j < 3; j++)
-                                               {
-                                                       if (IdPts0->GetId(j) != idp1 &&
-                                                               IdPts0->GetId(j) != idp2)
-                                                       {
-                                                               EndMapIndex.Add(IdPts0->GetId(j));
-                                                       }
-                                                       if (IdPts1->GetId(j) != idp1 &&
-                                                               IdPts1->GetId(j) != idp2)
-                                                       {
-                                                               EndMapIndex.Add(IdPts1->GetId(j));
-                                                       }
-                                               }
-
-                                               bool MyAU = myAutomaticUpdate;
-                                               myAutomaticUpdate = false;
-
-                                               EndMapIndex.Add(idp1);
-                                               TColStd_MapIteratorOfMapOfInteger ite1(EndMapIndex);
-                                               int i = 1;
-                                               while (ite1.More())
-                                               {
-                                                       if (ite1.Key() == idp1)
-                                                               break;
-                                                       i++;
-                                                       ite1.Next();
-                                               }
-                                               bool reverse1 = (i == 2);
-                                               this->AddFace(aMesh, EndMapIndex, reverse1);
-
-                                               EndMapIndex.Remove(idp1);
-                                               EndMapIndex.Add(idp2);
-                                               TColStd_MapIteratorOfMapOfInteger ite2(EndMapIndex);
-                                               i = 1;
-                                               while (ite2.More())
-                                               {
-                                                       if (ite2.Key() == idp2)
-                                                               break;
-                                                       i++;
-                                                       ite2.Next();
-                                               }
-                                               bool reverse2 = (i == 2);
-                                               this->AddFace(aMesh, EndMapIndex,
-                                                       !(reverse1 == reverse2));
-
-                                               myAutomaticUpdate = MyAU;
-                                               //MESSAGE ( " myAutomaticUpdate = " << MyAU )
-                                               Mapper->Update();
-                                               //Remove old faces
-                                               TColStd_MapOfInteger StartMapIndex;
-                                               StartMapIndex.Add(IdCells->GetId(0));
-                                               StartMapIndex.Add(IdCells->GetId(1));
-                                               this->RemoveElements(aMesh, StartMapIndex);
-
-                                               Mapper->Update();
-                                       }
-                               }
-                       }
-               }
-
-               //      UGrid->SetPoints( Mapper->GetInput()->GetPoints() );
-               //      int nbCells = Mapper->GetInput()->GetNumberOfCells();
-               //      for ( int i = 0; i < nbCells; i++ ) {
-               //        UGrid->InsertNextCell( Mapper->GetInput()->GetCellType(i), Mapper->GetInput()->GetCell(i)->GetPointIds() );
-               //      }
-
-               //      vtkDataSetMapper *NewMapper = vtkDataSetMapper::New();
-               //      NewMapper->SetInput( UGrid );
-               //      NewMapper->Update();
-
-               //      ac->DataSource = NewMapper->GetInput();
-               //      ac->SetMapper( NewMapper );
-       }
-       vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
-       renWin->Render();
-       QApplication::restoreOverrideCursor();
+  // NRI : Temporary added
+  //  if ( smeshGUI->myStudy->GetProperties()->IsLocked() ) {
+  //    theObject = "NothingSelected";
+  //    theContext = "NothingSelected";
+  //  }
+  // NRI
+
+  SALOME_Selection *Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() );
+  int nbSel = Sel->IObjectCount();
+  switch ( nbSel ) {
+  case 0:
+    theObject = "NothingSelected";
+    theContext = "NothingSelected";
+    break;
+  case 1:
+    if ( smeshGUI->myState == 800 && Sel->HasIndex( Sel->firstIObject() ) )
+      theObject = "Elements";
+    else
+      theObject = smeshGUI->CheckTypeObject( Sel->firstIObject() );
+    theContext = "";
+    break;
+  default:
+    theObject = smeshGUI->CheckHomogeneousSelection();
+    theContext = "";
+  }
 }
 
 //=============================================================================
@@ -5007,56 +3355,250 @@ void SMESHGUI::DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh,
  *
  */
 //=============================================================================
-void SMESHGUI::AddEdges(SMESH_Actor * Mactor, int number,
-       const SMESH::double_array & coords, const SMESH::long_array & indexes)
+bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
+                          const QString& theParent, const QString& theObject)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-       SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-       int i = 1;
-       int j = 1;
-       while (i <= number)
-       {
-               vtkIdList *Ids = vtkIdList::New();
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 1]));
-               int id = ugrid->InsertNextCell(VTK_LINE, Ids);
-               Mactor->AddElement(indexes[j - 1], id);
-               i++;
-               j = j + 3;
-       }
-       vtkDataSetMapper *EdgeMapper = vtkDataSetMapper::New();
-       EdgeMapper->SetInput(ugrid);
-       Mactor->DataSource = EdgeMapper->GetInput();
-       Mactor->SetMapper(EdgeMapper);
-       QApplication::restoreOverrideCursor();
+  // get active study frame
+  QAD_StudyFrame* studyFrame = smeshGUI->myActiveStudy->getActiveStudyFrame();
+  
+  // get parent component which selected object(s) belongs to
+  QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection();
+
+  // get selection
+  SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() );
+  int nbSel = Sel->IObjectCount();
+
+  if ( nbSel == 0 ) {
+    popup->clear();
+  }
+  else if ( nbSel == 1 ) {
+    if ( parentComp != parent->getActiveComponent() ) {
+      // object not belongs to SMESH module - remove all commands except common Display/Erase...
+      while ( 1 ) {
+       int id = popup->idAt( 0 );
+       if ( id <= QAD_TopLabel_Popup_ID )
+         popup->removeItemAt( 0 );
+       else
+         break;
+      }
+    }
+    else {
+      // get selected interactive object 
+      Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+      SALOMEDS::SObject_var SO = smeshGUI->myStudy->FindObjectID( IObject->getEntry() );
+      // find popup menu's TopLabel item
+      int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
+      if ( topItem >= 0 ) {
+       if ( theParent == "Viewer" ) {
+         // set bold font for popup menu's TopLabel item (Viewer popup)
+         QFont fnt = QApplication::font(); fnt.setBold( TRUE );
+         popup->removeItem( QAD_TopLabel_Popup_ID );
+         popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem );
+       }
+       else if ( theParent == "ObjectBrowser" ) {
+         // remove popup menu's TopLabel item (Object Browser popup)
+         popup->removeItem( QAD_TopLabel_Popup_ID );
+       }
+      }
+
+      // remove "Display only" command for component object
+      if ( theObject.compare( "Component" ) == 0 ) {
+       popup->removeItem( QAD_DisplayOnly_Popup_ID );
+      }
+      else if ( theObject == "Hypothesis" || theObject == "Algorithm" ) {
+       // remove Display/Erase commands
+       popup->removeItem( QAD_Display_Popup_ID );
+       popup->removeItem( QAD_DisplayOnly_Popup_ID );
+       popup->removeItem( QAD_Erase_Popup_ID );
+       // remove "Unassign ..." command if hyp/algo is not assigned
+       if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */)
+         popup->removeItem( 1102 );
+      }
+      else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) {
+       // get actor
+       GEOM::GEOM_Shape_var aShape = GetSMESHGUI()->GetStudyAPI().GetShapeOnMeshOrSubMesh( SO );
+       if ( aShape->_is_nil() ) {
+         // imported mesh
+         popup->removeItem( 701 ); // Compute
+         popup->removeItem( 705 ); // Edit hypothesis
+         popup->removeItem( 706 ); // ...
+       }
+       SMESH_Actor* ac = ::FindActorByEntry(IObject->getEntry());
+       // if object has actor
+       if ( ac && studyFrame->getTypeView() == VIEW_VTK ) {
+         VTKViewer_RenderWindowInteractor* myRenderInter =
+           ( ( VTKViewer_ViewFrame* ) studyFrame->getRightFrame()->getViewFrame() )->getRWInteractor();
+         if ( myRenderInter->isVisible( IObject ) ) {
+           popup->removeItem( QAD_Display_Popup_ID );
+           popup->setItemChecked( 9010, ac->GetPointsLabeled() ); // Numbering / Display Nodes #
+           popup->setItemChecked( 9011, ac->GetCellsLabeled() );  // Numbering / Display Elements #
+           TVisualObjPtr aVisualObj = ac->GetObject();
+           int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE);
+           int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE);
+           int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME);
+           QMenuItem* mi = popup->findItem( 1131 );
+           if ( mi && mi->popup() ) {
+             int  prType = ac->GetRepresentation();
+             // Display Mode / Wireframe
+             if(!aNbFaces && !aNbVolumes && !aNbEdges){
+               mi->popup()->removeItem( 211 );
+             }else{
+               mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
+             }
+             // Display Mode / Shading
+             if(!aNbFaces && !aNbVolumes){
+               mi->popup()->removeItem( 212 );
+             }else{
+               mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface );
+             }
+             // Display Mode / Points
+             mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );  
+             // Display Mode / Shrink
+             bool isShrunk = ac->IsShrunk();
+             bool isShrunkable = ac->IsShrunkable();
+             mi->popup()->setItemChecked( 213, isShrunk );   
+             mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
+           }
+           // Scalar Bar
+           mi = popup->findItem( 2000 );
+           if ( mi && mi->popup() ) {
+             SMESH_Actor::eControl cMode = ac->GetControlMode();
+             switch ( cMode ) {
+             case SMESH_Actor::eLengthEdges:
+               mi->popup()->setItemChecked( 6001, true ); break;
+             case SMESH_Actor::eFreeBorders:
+               mi->popup()->setItemChecked( 6003, true );
+               mi->popup()->removeItem( 201 );
+               break;
+             case SMESH_Actor::eMultiConnection:
+               mi->popup()->setItemChecked( 6004, true ); break;
+             case SMESH_Actor::eArea:
+               mi->popup()->setItemChecked( 6011, true ); break;
+             case SMESH_Actor::eTaper:
+               mi->popup()->setItemChecked( 6012, true ); break;
+             case SMESH_Actor::eAspectRatio:
+               mi->popup()->setItemChecked( 6013, true ); break;
+             case SMESH_Actor::eMinimumAngle:
+               mi->popup()->setItemChecked( 6014, true ); break;
+             case SMESH_Actor::eWarping:
+               mi->popup()->setItemChecked( 6015, true ); break;
+             case SMESH_Actor::eSkew:
+               mi->popup()->setItemChecked( 6016, true ); break;
+             case SMESH_Actor::eNone:
+             default:
+               mi->popup()->removeItem( 200 );
+               mi->popup()->removeItem( 201 );
+               break;
+             }
+             TVisualObjPtr aVisualObj = ac->GetObject();
+             SMESH::ElementType aType;
+             if(!aNbEdges){
+               mi->popup()->removeItem( 6001 );
+               mi->popup()->removeItem( 6003 );
+               mi->popup()->removeItem( 6004 );
+             }
+             if(!aNbFaces){
+               mi->popup()->removeItem( 6011 );
+               mi->popup()->removeItem( 6012 );
+               mi->popup()->removeItem( 6013 );
+               mi->popup()->removeItem( 6014 );
+               mi->popup()->removeItem( 6015 );
+               mi->popup()->removeItem( 6016 );
+             }
+             if(!aNbFaces && !aNbEdges)
+               popup->removeItem( 2000 );                         // Scalar Bar
+           }
+         }
+         else {
+           popup->removeItem( QAD_Erase_Popup_ID );
+           popup->removeItem( 114 );                              // Numbering popup menu
+           popup->removeItem( 1131 );                             // Display mode
+           popup->removeItem( 1132 );                             // Color / size
+           popup->removeItem( 1133 );                             // Transparency
+           popup->removeItem( 2000 );                             // Scalar Bar
+         }
+       }
+       else {
+         // object doesn't have actor
+         CORBA::Object_var anObject = SO->GetObject();
+         bool bDisplay = false;
+         if ( !CORBA::is_nil( anObject ) ) {
+           SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject );
+           if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0  || aMeshObj->NbVolumes() > 0 ) )
+             bDisplay = true;
+           SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject );
+           if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes() > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) )
+             bDisplay = true;
+           SMESH::SMESH_Group_var aGroupObj = SMESH::SMESH_Group::_narrow( anObject );
+           if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 )
+             bDisplay = true;
+         }
+         if ( !bDisplay ) {
+           popup->removeItem( QAD_Display_Popup_ID );
+           popup->removeItem( QAD_DisplayOnly_Popup_ID );
+         }
+         popup->removeItem( QAD_Erase_Popup_ID );
+         popup->removeItem( 114 );                              // Numbering popup menu
+         popup->removeItem( 1131 );                             // Display mode
+         popup->removeItem( 1132 );                             // Color / size
+         popup->removeItem( 1133 );                             // Transparency
+         popup->removeItem( 2000 );                             // Scalar Bar
+       }
+      }
+      else {
+       // another SMESH object
+       popup->removeItem( QAD_Display_Popup_ID );
+       popup->removeItem( QAD_DisplayOnly_Popup_ID );
+       popup->removeItem( QAD_Erase_Popup_ID );
+      }
+    }
+  }
+  else {
+    // multiple selection
+    if ( parentComp != parent->getActiveComponent() ) {
+      // object not belongs to SMESH module - remove all commands except common Display/Erase...
+      while ( 1 )      {
+       int id = popup->idAt( 0 );
+       if ( id <= QAD_TopLabel_Popup_ID )
+         popup->removeItemAt( 0 );
+       else
+         break;
+      }
+      if ( parentComp.isNull() ) {
+       // objects from different components are selected
+       popup->removeItem( QAD_DisplayOnly_Popup_ID );
+       popup->removeItem( QAD_Display_Popup_ID );
+       popup->removeItem( QAD_Erase_Popup_ID );
+      }
+    }
+    else {
+      QString type = smeshGUI->CheckHomogeneousSelection();
+      if ( type != "Heterogeneous Selection" ) {
+       int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
+       if ( topItem >= 0 ) {
+         // set bold font for popup menu's TopLabel item
+         QFont fnt = QApplication::font(); fnt.setBold( TRUE );
+         popup->removeItem( QAD_TopLabel_Popup_ID );
+         popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem );
+       }
+      }
+    }
+  }
+  return false;
 }
 
 //=============================================================================
-/*!
- *
+/*! Method:  BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
+ *  Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
  */
 //=============================================================================
-void SMESHGUI::AddEdge(SMESH_Actor * Mactor, int idedge, int idnode1,
-       int idnode2)
+void SMESHGUI::BuildPresentation(const Handle(SALOME_InteractiveObject) & theIO)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       MESSAGE("SMESHGUI::AddEdge " << idedge << " : " << idnode1 << ";" <<
-               idnode2) vtkIdList *Ids = vtkIdList::New();
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode1));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode2));
-
-       //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-       SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-       int id = ugrid->InsertNextCell(VTK_LINE, Ids);
-       Mactor->AddElement(idedge, id);
-
-       MESSAGE(" Edge VTK id " << id)
-               vtkDataSetMapper *EdgeMapper = vtkDataSetMapper::New();
-       EdgeMapper->SetInput(ugrid);
-       Mactor->DataSource = EdgeMapper->GetInput();
-       Mactor->SetMapper(EdgeMapper);
-       QApplication::restoreOverrideCursor();
+  if(theIO->hasEntry()){
+    QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
+    QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
+    ::UpdateView(aStudyFrame,eDisplay,theIO->getEntry());
+  }
 }
 
 //=============================================================================
@@ -5064,50 +3606,19 @@ void SMESHGUI::AddEdge(SMESH_Actor * Mactor, int idedge, int idnode1,
  *
  */
 //=============================================================================
-void SMESHGUI::AddTriangles(SMESH_Actor * Mactor, int number,
-       const SMESH::double_array & coords, const SMESH::long_array & indexes)
+void SMESHGUI::setOrb()
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-       SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-       int i = 1;
-       int j = 1;
-       while (i <= number)
+       try
        {
-               vtkIdList *Ids = vtkIdList::New();
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 1]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 2]));
-               int id = ugrid->InsertNextCell(VTK_TRIANGLE, Ids);
-               Mactor->AddElement(indexes[j - 1], id);
-               i++;
-               j = j + 4;
+               ORB_INIT & init = *SINGLETON_ < ORB_INIT >::Instance();
+               ASSERT(SINGLETON_ < ORB_INIT >::IsAlreadyExisting());
+               _orb = init(0, 0);
+       } catch(...)
+       {
+               INFOS("internal error : orb not found");
+               _orb = 0;
        }
-       vtkDataSetMapper *TriMapper = vtkDataSetMapper::New();
-       TriMapper->SetInput(ugrid);
-       Mactor->DataSource = TriMapper->GetInput();
-       Mactor->SetMapper(TriMapper);
-       QApplication::restoreOverrideCursor();
-}
-void SMESHGUI::AddTriangle(SMESH_Actor * Mactor, int idtri, int idnode1,
-       int idnode2, int idnode3)
-{
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       vtkIdList *Ids = vtkIdList::New();
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode1));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode2));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode3));
-
-       //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-       SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-       int id = ugrid->InsertNextCell(VTK_TRIANGLE, Ids);
-       Mactor->AddElement(idtri, id);
-
-       vtkDataSetMapper *TriMapper = vtkDataSetMapper::New();
-       TriMapper->SetInput(ugrid);
-       Mactor->DataSource = TriMapper->GetInput();
-       Mactor->SetMapper(TriMapper);
-       QApplication::restoreOverrideCursor();
+       ASSERT(!CORBA::is_nil(_orb));
 }
 
 //=============================================================================
@@ -5115,58 +3626,41 @@ void SMESHGUI::AddTriangle(SMESH_Actor * Mactor, int idtri, int idnode1,
  *
  */
 //=============================================================================
-void SMESHGUI::AddQuadrangles(SMESH_Actor * Mactor, int number,
-       const SMESH::double_array & coords, const SMESH::long_array & indexes)
-{
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-       SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-       int i = 1;
-       int j = 1;
-       while (i <= number)
-       {
-               vtkIdList *Ids = vtkIdList::New();
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 1]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 2]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 3]));
-               int id = ugrid->InsertNextCell(VTK_QUAD, Ids);
-               Mactor->AddElement(indexes[j - 1], id);
-               i++;
-               j = j + 5;
-       }
-       vtkDataSetMapper *QuadMapper = vtkDataSetMapper::New();
-       QuadMapper->SetInput(ugrid);
-       Mactor->DataSource = QuadMapper->GetInput();
-       Mactor->SetMapper(QuadMapper);
-       QApplication::restoreOverrideCursor();
-}
+SMESH_Actor *SMESHGUI::ReadScript(SMESH::SMESH_Mesh_ptr theMesh){}
 
 //=============================================================================
 /*!
  *
  */
 //=============================================================================
-void SMESHGUI::AddQuadrangle(SMESH_Actor * Mactor, int idquad, int idnode1,
-       int idnode2, int idnode3, int idnode4)
+void SMESHGUI::Dump(SMESH_Actor * Mactor)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       vtkIdList *Ids = vtkIdList::New();
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode1));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode2));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode3));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode4));
-
-       //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-       SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-       int id = ugrid->InsertNextCell(VTK_QUAD, Ids);
-       Mactor->AddElement(idquad, id);
-
-       vtkDataSetMapper *QuadMapper = vtkDataSetMapper::New();
-       QuadMapper->SetInput(ugrid);
-       Mactor->DataSource = QuadMapper->GetInput();
-       Mactor->SetMapper(QuadMapper);
-       QApplication::restoreOverrideCursor();
+       vtkUnstructuredGrid *ugrid = Mactor->GetUnstructuredGrid();
+       vtkPoints *Pts = ugrid->GetPoints();
+       int nbPts = Pts->GetNumberOfPoints();
+       int nbCells = ugrid->GetNumberOfCells();
+
+       FILE *In;
+       int i, j;
+       In = fopen("/tmp/dumpMesh", "w+");
+       fprintf(In, "%d %d\n", nbPts, nbCells);
+       for (int i = 0; i < nbPts; i++)
+       {
+               float *p = ugrid->GetPoint(i);
+               fprintf(In, "%d %e %e %e\n", i, p[0], p[1], p[2]);
+       }
+
+       for (int i = 0; i < nbCells; i++)
+       {
+               fprintf(In, "%d %d", i, ugrid->GetCell(i)->GetCellType());
+               vtkIdList *Id = ugrid->GetCell(i)->GetPointIds();
+               for (j = 0; j < Id->GetNumberOfIds(); j++)
+               {
+                       fprintf(In, " %d", Id->GetId(j));
+               }
+               fprintf(In, "\n");
+       }
+       fclose(In);
 }
 
 //=============================================================================
@@ -5174,31 +3668,36 @@ void SMESHGUI::AddQuadrangle(SMESH_Actor * Mactor, int idquad, int idnode1,
  *
  */
 //=============================================================================
-void SMESHGUI::AddTetras(SMESH_Actor * Mactor, int number,
-       const SMESH::double_array & coords, const SMESH::long_array & indexes)
+void SMESHGUI::RemoveNodes(SMESH::SMESH_Mesh_ptr theMesh,
+                          const TColStd_MapOfInteger & MapIndex)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-       SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-       int i = 1;
-       int j = 1;
-       while (i <= number)
-       {
-               vtkIdList *Ids = vtkIdList::New();
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 1]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 2]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 3]));
-               int id = ugrid->InsertNextCell(VTK_TETRA, Ids);
-               Mactor->AddElement(indexes[j - 1], id);
-               i++;
-               j = j + 5;
-       }
-       vtkDataSetMapper *TetraMapper = vtkDataSetMapper::New();
-       TetraMapper->SetInput(ugrid);
-       Mactor->DataSource = TetraMapper->GetInput();
-       Mactor->SetMapper(TetraMapper);
-       QApplication::restoreOverrideCursor();
+  QAD_WaitCursor wc;
+  try{
+    SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh);
+    CORBA::String_var anEntry = aSobj->GetID();
+    if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){
+      SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
+      anArrayOfIdeces->length(MapIndex.Extent());
+      TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
+      for(int i = 0; ite.More(); ite.Next(), i++){
+       anArrayOfIdeces[i] = anActor->GetNodeObjId(ite.Key());
+      }
+      SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
+      aMeshEditor->RemoveNodes(anArrayOfIdeces);
+      if(myAutomaticUpdate){
+       CORBA::Long anId = smeshGUI->myStudy->StudyId();
+       if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){
+         aVisualObj->Update(true);
+       }
+      }
+    }
+  }catch(SALOME::SALOME_Exception& exc) {
+    INFOS("Follow exception was cought:\n\t"<<exc.details.text);
+  }catch(const std::exception& exc){
+    INFOS("Follow exception was cought:\n\t"<<exc.what());
+  }catch(...){
+    INFOS("Unknown exception was cought !!!");
+  }
 }
 
 //=============================================================================
@@ -5206,29 +3705,36 @@ void SMESHGUI::AddTetras(SMESH_Actor * Mactor, int number,
  *
  */
 //=============================================================================
-void SMESHGUI::AddTetra(SMESH_Actor * Mactor, int idtetra, int idnode1,
-       int idnode2, int idnode3, int idnode4)
+void SMESHGUI::RemoveElements(SMESH::SMESH_Mesh_ptr theMesh,
+                             const TColStd_MapOfInteger & MapIndex)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       MESSAGE("SMESHGUI::AddTetra " << idtetra << " : " << idnode1 << ";" <<
-               idnode2 << ";" << idnode3 << ";" << idnode4) vtkIdList *Ids =
-               vtkIdList::New();
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode1));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode2));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode3));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode4));
-
-       //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-       SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-       int id = ugrid->InsertNextCell(VTK_TETRA, Ids);
-       Mactor->AddElement(idtetra, id);
-
-       MESSAGE(" Tetra VTK id " << id)
-               vtkDataSetMapper *TetraMapper = vtkDataSetMapper::New();
-       TetraMapper->SetInput(ugrid);
-       Mactor->DataSource = TetraMapper->GetInput();
-       Mactor->SetMapper(TetraMapper);
-       QApplication::restoreOverrideCursor();
+  QAD_WaitCursor wc;
+  try{
+    SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh);
+    CORBA::String_var anEntry = aSobj->GetID();
+    if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){
+      SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
+      anArrayOfIdeces->length(MapIndex.Extent());
+      TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
+      for(int i = 0; ite.More(); ite.Next(), i++){
+       anArrayOfIdeces[i] = anActor->GetElemObjId(ite.Key());
+      }
+      SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
+      aMeshEditor->RemoveElements(anArrayOfIdeces);
+      if(myAutomaticUpdate){
+       CORBA::Long anId = smeshGUI->myStudy->StudyId();
+       if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){
+         aVisualObj->Update(true);
+       }
+      }
+    }
+  }catch(SALOME::SALOME_Exception& exc) {
+    INFOS("Follow exception was cought:\n\t"<<exc.details.text);
+  }catch(const std::exception& exc){
+    INFOS("Follow exception was cought:\n\t"<<exc.what());
+  }catch(...){
+    INFOS("Unknown exception was cought !!!");
+  }
 }
 
 //=============================================================================
@@ -5236,35 +3742,10 @@ void SMESHGUI::AddTetra(SMESH_Actor * Mactor, int idtetra, int idnode1,
  *
  */
 //=============================================================================
-void SMESHGUI::AddHexaedres(SMESH_Actor * Mactor, int number,
-       const SMESH::double_array & coords, const SMESH::long_array & indexes)
+void SMESHGUI::OrientationElements(SMESH::SMESH_Mesh_ptr aMesh,
+       const TColStd_MapOfInteger & MapIndex)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-       SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-       int i = 1;
-       int j = 1;
-       while (i <= number)
-       {
-               vtkIdList *Ids = vtkIdList::New();
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 1]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 2]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 3]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 4]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 5]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 6]));
-               Ids->InsertNextId(Mactor->GetIdVTKNode(indexes[j + 7]));
-               int id = ugrid->InsertNextCell(VTK_HEXAHEDRON, Ids);
-               Mactor->AddElement(indexes[j - 1], id);
-               i++;
-               j = j + 9;
-       }
-       vtkDataSetMapper *HexaMapper = vtkDataSetMapper::New();
-       HexaMapper->SetInput(ugrid);
-       Mactor->DataSource = HexaMapper->GetInput();
-       Mactor->SetMapper(HexaMapper);
-       QApplication::restoreOverrideCursor();
+  MESSAGE("OrientationElements - not implemeted yet!");
 }
 
 //=============================================================================
@@ -5272,35 +3753,10 @@ void SMESHGUI::AddHexaedres(SMESH_Actor * Mactor, int number,
  *
  */
 //=============================================================================
-void SMESHGUI::AddHexaedre(SMESH_Actor * Mactor, int idhexa, int idnode1,
-       int idnode2, int idnode3, int idnode4, int idnode5, int idnode6,
-       int idnode7, int idnode8)
+void SMESHGUI::DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh,
+       const TColStd_MapOfInteger & MapIndex)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       MESSAGE("SMESHGUI::AddHexaedre " << idhexa << " : " << idnode1 << ";" <<
-               idnode2 << ";" << idnode3 << ";" << idnode4 << ";" << idnode5 << ";" <<
-               idnode6 << ";" << idnode7 << ";" << idnode8) vtkIdList *Ids =
-               vtkIdList::New();
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode1));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode2));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode3));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode4));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode5));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode6));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode7));
-       Ids->InsertNextId(Mactor->GetIdVTKNode(idnode8));
-
-       //vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
-       SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
-       int id = ugrid->InsertNextCell(VTK_HEXAHEDRON, Ids);
-       Mactor->AddElement(idhexa, id);
-
-       MESSAGE(" Hexa VTK id " << id)
-               vtkDataSetMapper *HexaMapper = vtkDataSetMapper::New();
-       HexaMapper->SetInput(ugrid);
-       Mactor->DataSource = HexaMapper->GetInput();
-       Mactor->SetMapper(HexaMapper);
-       QApplication::restoreOverrideCursor();
+  MESSAGE("OrientationElements - not implemeted yet!");
 }
 
 //=====================================================================================
@@ -5360,218 +3816,20 @@ extern "C"
                SMESHGUI::BuildPresentation(theIO);
        }
 
-       void supportedViewType(int *buffer, int bufferSize)
-       {
-               if (!buffer || !bufferSize)
-                       return;
-               buffer[0] = (int)VIEW_VTK;
-       }
-
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::ViewNodes()
-{
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-
-       EraseSimulationActors();
-       mySimulationActors = vtkActorCollection::New();
-       vtkRenderer *theRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-       vtkActorCollection *theActors = theRenderer->GetActors();
-       theActors->InitTraversal();
-       vtkActor *ac = theActors->GetNextActor();
-       while (!(ac == NULL))
-       {
-               if (ac->IsA("SMESH_Actor"))
-               {
-                       SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
-                       if (anActor->GetVisibility() == 1)
-                       {
-                               vtkGeometryFilter *gf = vtkGeometryFilter::New();
-                               gf->SetInput(anActor->DataSource);
-                               vtkMaskPoints *verts = vtkMaskPoints::New();
-                               verts->SetInput(gf->GetOutput());
-                               verts->GenerateVerticesOn();
-                               verts->SetOnRatio(1);
-
-                               vtkPolyDataMapper *vertMapper = vtkPolyDataMapper::New();
-                               vertMapper->SetInput(verts->GetOutput());
-                               vertMapper->ScalarVisibilityOff();
-
-                               vtkActor *vertActor = vtkActor::New();
-                               vertActor->SetMapper(vertMapper);
-
-                               float r, g, b;
-                               anActor->GetNodeColor(r, g, b);
-                               vertActor->GetProperty()->SetColor(r, g, b);
-
-                               vertActor->GetProperty()->SetPointSize(anActor->GetNodeSize());
-
-                               vertActor->PickableOff();
-
-                               mySimulationActors->AddItem(vertActor);
-                               theRenderer->AddActor(vertActor);
-                       }
-               }
-               ac = theActors->GetNextActor();
-       }
-
-       vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
-       renWin->Render();
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Control(int theCommandID)
-{
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       DisplayScalarBar(false);
-
-       vtkDoubleArray *scalars = vtkDoubleArray::New();
-       scalars->SetNumberOfComponents(1);
-
-       vtkDataSetMapper *meshMapper = 0;
-       SALOME_Selection *Sel =
-               SALOME_Selection::Selection(myActiveStudy->getSelection());
-       int nbSel = Sel->IObjectCount();
-       Standard_Boolean result;
-       Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
-       SMESH_Actor *MeshActor =
-               FindActorByEntry(IObject->getEntry(), result, true);
-
-       // Mesh may be not updated after Compute
-       if (!MeshActor->DataSource || !MeshActor->GetMapper())
-       {
-               QApplication::restoreOverrideCursor();
-               return;
-       }
-
-       vtkDataSet *aDataSet = MeshActor->DataSource;
-       typedef double (*TScalarFun) (vtkCell * theCell);
-       TScalarFun aScalarFun;
-       if (result)
-       {
-               QString type;
-               switch (theCommandID)
-               {
-               case 6001:
-               {
-                       type = tr("SMESH_CONTROL_LENGTH_EDGES");
-                       aDataSet = MeshActor->EdgeDevice->GetMapper()->GetInput();
-                       aScalarFun = &(SMESHGUI_ComputeScalarValue::LengthEdges);
-                       MESSAGE(" init minimum length " << aDataSet->GetNumberOfCells());
-                       if (MeshActor->getDisplayMode() != 0)
-                               ChangeRepresentation(MeshActor, 1);     // limitation; in Wireframe, colored edges are not visible
-                       break;
-               }
-               case 6011:
-               {
-                       type = tr("SMESH_CONTROL_AREA_ELEMENTS");
-                       aScalarFun = &(SMESHGUI_ComputeScalarValue::AreaElements);
-                       if (MeshActor->getDisplayMode() != 1)
-                               ChangeRepresentation(MeshActor, 1);
-                       break;
-               }
-               case 6012:
-               {
-                       type = tr("SMESH_CONTROL_TAPER_ELEMENTS");
-                       aScalarFun = &(SMESHGUI_ComputeScalarValue::Taper);
-                       break;
-               }
-               case 6013:
-               {
-                       type = tr("SMESH_CONTROL_ASPECTRATIO_ELEMENTS");
-                       aScalarFun = &(SMESHGUI_ComputeScalarValue::AspectRatio);
-                       if (MeshActor->getDisplayMode() != 1)
-                               ChangeRepresentation(MeshActor, 1);
-                       break;
-               }
-               case 6014:
-               {
-                       type = tr("SMESH_CONTROL_MINIMUMANGLE_ELEMENTS");
-                       aScalarFun = &(SMESHGUI_ComputeScalarValue::MinimumAngle);
-                       if (MeshActor->getDisplayMode() != 1)
-                               ChangeRepresentation(MeshActor, 1);
-                       break;
-               }
-               case 6015:
-               {
-                       type = tr("SMESH_CONTROL_WARP_ELEMENTS");
-                       aScalarFun = &(SMESHGUI_ComputeScalarValue::Warp);
-                       break;
-               }
-               case 6016:
-               {
-                       type = tr("SMESH_CONTROL_SKEW_ELEMENTS");
-                       aScalarFun = &(SMESHGUI_ComputeScalarValue::Skew);
-                       break;
-               }
-               }
-
-               for (int i = 0, iEnd = aDataSet->GetNumberOfCells(); i < iEnd; i++)
-                       scalars->InsertTuple1(i, aScalarFun(aDataSet->GetCell(i)));
-
-               float range[2];
-               scalars->GetRange(range);
-
-               vtkLookupTable *wat = vtkLookupTable::New();
-               wat->SetRange(range);
-               wat->Build();
-
-               scalars->SetLookupTable(wat);
-
-               if (!meshMapper)
-                       meshMapper = (vtkDataSetMapper *) (MeshActor->getMapper());
-               meshMapper->SetScalarModeToUseCellData();
-               MeshActor->DataSource->GetCellData()->SetScalars(scalars);
-               meshMapper->SetScalarRange(range);
-               meshMapper->ScalarVisibilityOn();
-
-               vtkScalarBarActor *aScalarBar = GetScalarBar();
-               if (aScalarBar == NULL)
-               {
-                       aScalarBar = vtkScalarBarActor::New();
-                       QString Bold = QAD_CONFIG->getSetting("ScalarBar:Bold");
-                       QString Italic = QAD_CONFIG->getSetting("ScalarBar:Italic");
-                       QString Shadow = QAD_CONFIG->getSetting("ScalarBar:Shadow");
-                       QString FontFamily = QAD_CONFIG->getSetting("ScalarBar:FontFamily");
-                       QString Orientation =
-                               QAD_CONFIG->getSetting("ScalarBar:Orientation");
-                       float Width = QAD_CONFIG->getSetting("ScalarBar:Width").toFloat();
-                       float Height = QAD_CONFIG->getSetting("ScalarBar:Height").toFloat();
-                       int NumberOfLabels =
-                               QAD_CONFIG->getSetting("ScalarBar:NumberOfLabels").toInt();
-                       int NumberOfColors =
-                               QAD_CONFIG->getSetting("ScalarBar:NumberOfColors").toInt();
-
-                       SetSettingsScalarBar(aScalarBar, Bold, Italic, Shadow, FontFamily,
-                               Orientation, Width, Height, NumberOfColors, NumberOfLabels);
-                       vtkRenderer *theRenderer =
-                               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-                               getRightFrame()->getViewFrame())->getRenderer();
-                       theRenderer->AddActor2D(aScalarBar);
-               }
-               aScalarBar->SetLookupTable(wat);
-               aScalarBar->SetTitle(type.latin1());
-
-               scalars->Delete();
-               //    wat->Delete();
-               DisplayScalarBar(true);
+       void supportedViewType(int *buffer, int bufferSize)
+       {
+               if (!buffer || !bufferSize)
+                       return;
+               buffer[0] = (int)VIEW_VTK;
+       }
+
+       void deactivate()
+       {
+         if ( SMESHGUI::GetSMESHGUI() ) {
+           SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs();
+         }
        }
-       QApplication::restoreOverrideCursor();
+
 }
 
 //=============================================================================
@@ -5579,46 +3837,29 @@ void SMESHGUI::Control(int theCommandID)
  *
  */
 //=============================================================================
-void SMESHGUI::SetSettingsScalarBar(vtkScalarBarActor * theScalarBar,
-       QString Bold, QString Italic,
-       QString Shadow, QString FontFamily,
-       QString Orientation, float Width, float Height, int NbColors, int NbLabels)
-{
-       if (Bold.isNull() || Bold.isEmpty() || (Bold.compare("true") == 0))
-               theScalarBar->BoldOn();
-       else
-               theScalarBar->BoldOff();
-
-       if (Italic.isNull() || Italic.isEmpty() || (Italic.compare("true") == 0))
-               theScalarBar->ItalicOn();
-       else
-               theScalarBar->ItalicOff();
-
-       if (Shadow.isNull() || Shadow.isEmpty() || (Shadow.compare("true") == 0))
-               theScalarBar->ShadowOn();
-       else
-               theScalarBar->ShadowOff();
-
-       if (FontFamily.compare("Arial") == 0)
-               theScalarBar->SetFontFamilyToArial();
-       else if (FontFamily.compare("Courier") == 0)
-               theScalarBar->SetFontFamilyToCourier();
-       else if (FontFamily.compare("Times") == 0)
-               theScalarBar->SetFontFamilyToTimes();
-       else
-               theScalarBar->SetFontFamilyToArial();
-
-       if (Orientation.isNull() || Orientation.isEmpty() ||
-               (Orientation.compare("Vertical") == 0))
-               theScalarBar->SetOrientationToVertical();
-       else
-               theScalarBar->SetOrientationToHorizontal();
+void SMESHGUI::SetPickable(SMESH_Actor* theActor){
+  if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){
+    int anIsAllPickable = (theActor == NULL);
+    vtkRenderer *aRenderer = aViewFrame->getRenderer();
+    vtkActorCollection *aCollection = aRenderer->GetActors();
+    aCollection->InitTraversal();
+    while(vtkActor *anAct = aCollection->GetNextActor()){
+      if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){
+       if(anActor->GetVisibility()){
+         anActor->SetPickable(anIsAllPickable);
+       }
+      }
+    }
+    if(theActor)
+      theActor->SetPickable(!anIsAllPickable);
+    RepaintCurrentView();
+  }
+}
 
-       theScalarBar->SetWidth((Width == 0) ? 0.17 : Width);
-       theScalarBar->SetHeight((Height == 0) ? 0.8 : Height);
 
-       theScalarBar->SetNumberOfLabels((NbLabels == 0) ? 5 : NbLabels);
-       theScalarBar->SetMaximumNumberOfColors((NbColors == 0) ? 64 : NbColors);
+void SMESHGUI::ViewNodes(){
+  EraseSimulationActors();
+  ::SetPointRepresentation(true);
 }
 
 //=============================================================================
@@ -5626,58 +3867,57 @@ void SMESHGUI::SetSettingsScalarBar(vtkScalarBarActor * theScalarBar,
  *
  */
 //=============================================================================
-void SMESHGUI::DisplayScalarBar(bool visibility)
-{
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-
-       vtkRenderer *theRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-       vtkScalarBarActor *aScalarBar = GetScalarBar();
-
-       if (aScalarBar == NULL)
-       {
-               MESSAGE("myScalarBar is NULL");
-               return;
-       }
-
-       if (visibility)
-               aScalarBar->VisibilityOn();
-       else
-       {
-               aScalarBar->VisibilityOff();
-               //Turn off mesh coloring (influences on all views)
-               vtkActorCollection *actorList = theRenderer->GetActors();
-               actorList->InitTraversal();
-               vtkActor *ac = actorList->GetNextActor();
-               while (ac != NULL)
-               {
-                       if (ac->GetMapper() != NULL)
-                       {
-                               ac->GetMapper()->ScalarVisibilityOff();
-                       }
-                       ac = actorList->GetNextActor();
-               }
-               // Turn off ScalarBar in all views
-               /*QList<QAD_StudyFrame> aFrames = myActiveStudy->getStudyFrames();
-                * for ( QAD_StudyFrame* aFrame = aFrames.first(); aFrame; aFrame = aFrames.next() ) {
-                * if (aFrame->getTypeView() == VIEW_VTK) {
-                * vtkRenderer *aRenderer = ((VTKViewer_ViewFrame*) aFrame->getRightFrame()->getViewFrame())->getRenderer();
-                * vtkActor2DCollection* actor2DList = aRenderer->GetActors2D();
-                * actor2DList->InitTraversal();
-                * vtkActor2D* aActor2d =  actor2DList->GetNextActor2D();
-                * while (aActor2d != NULL) {
-                * if (aActor2d->IsA("vtkScalarBarActor")) {
-                * aActor2d->VisibilityOff();
-                * break;
-                * }
-                * actor2DList->GetNextActor2D();
-                * }
-                * }
-                * } */
+void SMESHGUI::Control( int theCommandID ){
+  SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+  if(Sel){
+    Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
+    if(!anIO.IsNull()){
+      QString aTitle;
+      SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
+      if(SMESH_Actor *anActor = ::FindActorByEntry(anIO->getEntry())){
+       switch ( theCommandID ){
+       case 6001:
+         aTitle = tr( "LENGTH_EDGES" );
+         aControl = SMESH_Actor::eLengthEdges;
+         break;
+       case 6003:
+         aTitle = tr( "FREE_BORDERS" );
+         aControl = SMESH_Actor::eFreeBorders;
+         break;
+       case 6004:
+         aTitle = tr( "MULTI_BORDERS" );
+         aControl = SMESH_Actor::eMultiConnection;
+         break;
+       case 6011:
+         aTitle = tr( "AREA_ELEMENTS" );
+         aControl = SMESH_Actor::eArea;
+         break;
+       case 6012:
+         aTitle = tr( "TAPER_ELEMENTS" );
+         aControl = SMESH_Actor::eTaper;
+         break;
+       case 6013:
+         aTitle = tr( "ASPECTRATIO_ELEMENTS" );
+         aControl = SMESH_Actor::eAspectRatio;
+         break;
+       case 6014:
+         aTitle = tr( "MINIMUMANGLE_ELEMENTS" );
+         aControl = SMESH_Actor::eMinimumAngle;
+         break;
+       case 6015:
+         aTitle = tr( "WARP_ELEMENTS" );
+         aControl = SMESH_Actor::eWarping;
+         break;
+       case 6016:
+         aTitle = tr( "SKEW_ELEMENTS" );
+         aControl = SMESH_Actor::eSkew;
+         break;
        }
-       myActiveStudy->update3dViewers();
+       anActor->SetControlMode(aControl);
+       anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
+      }
+    }
+  }
 }
 
 //=============================================================================
@@ -5685,39 +3925,52 @@ void SMESHGUI::DisplayScalarBar(bool visibility)
  *
  */
 //=============================================================================
-void SMESHGUI::UpdateScalarBar(float MinRange, float MaxRange)
+void SMESHGUI::SetSettingsScalarBar(vtkScalarBarActor * theScalarBar,
+                                   QString Bold, 
+                                   QString Italic,
+                                   QString Shadow, 
+                                   QString FontFamily,
+                                   QString Orientation, 
+                                   float Width, 
+                                   float Height, 
+                                   int NbColors, 
+                                   int NbLabels)
 {
-       vtkScalarBarActor *aScalarBar = GetScalarBar();
-       if (aScalarBar == NULL)
-       {
-               MESSAGE("myScalarBar is NULL");
-               return;
-       }
-       DisplayScalarBar(false);
-
-       aScalarBar->GetLookupTable()->SetRange(MinRange, MaxRange);
-       vtkRenderer *aRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-       vtkActorCollection *aActorList = aRenderer->GetActors();
-       aActorList->InitTraversal();
-       vtkActor *aActor = aActorList->GetNextActor();
-       while (aActor != NULL)
-       {
-               if (aActor->IsA("SMESH_Actor"))
-               {
-                       SMESH_Actor *aMeshActor = SMESH_Actor::SafeDownCast(aActor);
-                       vtkDataSetMapper *aMeshMapper =
-                               (vtkDataSetMapper *) (aMeshActor->getMapper());
-                       if ((aMeshMapper != NULL))
-                       {
-                               aMeshMapper->SetScalarRange(MinRange, MaxRange);
-                               aMeshMapper->ScalarVisibilityOn();
-                       }
-               }
-               aActor = aActorList->GetNextActor();
-       }
-       DisplayScalarBar(true);
+  if (Bold.isNull() || Bold.isEmpty() || (Bold.compare("true") == 0))
+    theScalarBar->BoldOn();
+  else
+    theScalarBar->BoldOff();
+  
+  if (Italic.isNull() || Italic.isEmpty() || (Italic.compare("true") == 0))
+    theScalarBar->ItalicOn();
+  else
+    theScalarBar->ItalicOff();
+  
+  if (Shadow.isNull() || Shadow.isEmpty() || (Shadow.compare("true") == 0))
+    theScalarBar->ShadowOn();
+  else
+    theScalarBar->ShadowOff();
+  
+  if (FontFamily.compare("Arial") == 0)
+    theScalarBar->SetFontFamilyToArial();
+  else if (FontFamily.compare("Courier") == 0)
+    theScalarBar->SetFontFamilyToCourier();
+  else if (FontFamily.compare("Times") == 0)
+    theScalarBar->SetFontFamilyToTimes();
+  else
+    theScalarBar->SetFontFamilyToArial();
+  
+  if (Orientation.isNull() || Orientation.isEmpty() ||
+      (Orientation.compare("Vertical") == 0))
+    theScalarBar->SetOrientationToVertical();
+  else
+    theScalarBar->SetOrientationToHorizontal();
+  
+  theScalarBar->SetWidth((Width == 0) ? 0.17 : Width);
+  theScalarBar->SetHeight((Height == 0) ? 0.8 : Height);
+  
+  theScalarBar->SetNumberOfLabels((NbLabels == 0) ? 5 : NbLabels);
+  theScalarBar->SetMaximumNumberOfColors((NbColors == 0) ? 64 : NbColors);
 }
 
 //=============================================================================
@@ -5727,82 +3980,86 @@ void SMESHGUI::UpdateScalarBar(float MinRange, float MaxRange)
 //=============================================================================
 void SMESHGUI::SetDisplaySettings()
 {
-       EmitSignalDeactivateDialog();
-       SMESHGUI_Preferences_ColorDlg *aDlg =
-               new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
-
-       QString SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
-       QString SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
-       QString SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
-       QColor color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
-       aDlg->SetColor(1, color);
-
-       SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
-       SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
-       SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
-       color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
-       aDlg->SetColor(2, color);
-
-       SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
-       SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
-       SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
-       color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
-       aDlg->SetColor(3, color);
-
-       QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
-       QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
-       QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
-       color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
-       aDlg->SetColor(4, color);
-
-       QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
-       aDlg->SetIntValue(1, intValue.toInt());
-       intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
-       aDlg->SetIntValue(2, intValue.toInt());
-       intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
-       aDlg->SetIntValue(3, intValue.toInt());
-
-       if (aDlg->exec())
-       {
-               QColor colorFill = aDlg->GetColor(1);
-               QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
-               QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen",
-                       colorFill.green());
-               QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
-
-               QColor colorOutline = aDlg->GetColor(2);
-               QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed",
-                       colorOutline.red());
-               QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen",
-                       colorOutline.green());
-               QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue",
-                       colorOutline.blue());
-
-               QColor colorNode = aDlg->GetColor(3);
-               QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
-               QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen",
-                       colorNode.green());
-               QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
-
-               QColor colorBackFace = aDlg->GetColor(4);
-               QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed",
-                       colorBackFace.red());
-               QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen",
-                       colorBackFace.green());
-               QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue",
-                       colorBackFace.blue());
-
-               int width = aDlg->GetIntValue(1);
-               QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
-
-               int nodes_size = aDlg->GetIntValue(2);
-               QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
-
-               int shrink_coeff = aDlg->GetIntValue(3);
-               QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
-       }
-
-       delete aDlg;
+  EmitSignalDeactivateDialog();
+  SMESHGUI_Preferences_ColorDlg *aDlg =
+    new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
+
+  QColor color;
+  QString SCr, SCg, SCb;
+  SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
+  SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
+  SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
+  if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
+    color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
+  else color = QColor(0, 170, 255);
+  aDlg->SetColor(1, color);
+
+  SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
+  SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
+  SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
+  if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
+    color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
+  else color = QColor(0, 170, 255);
+  aDlg->SetColor(2, color);
+
+  SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
+  SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
+  SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
+  if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
+    color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
+  else color = Qt::red;
+  aDlg->SetColor(3, color);
+
+  QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
+  QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
+  QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
+  if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
+    color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
+  else color = Qt::blue;
+  aDlg->SetColor(4, color);
+
+  QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
+  if (intValue.isEmpty()) intValue = "1";
+  aDlg->SetIntValue(1, intValue.toInt());
+  intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
+  if (intValue.isEmpty()) intValue = "3";
+  aDlg->SetIntValue(2, intValue.toInt());
+  intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
+  if (intValue.isEmpty()) intValue = "75";
+  aDlg->SetIntValue(3, intValue.toInt());
+
+  if (aDlg->exec()) {
+    QColor colorFill = aDlg->GetColor(1);
+    QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
+    QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green());
+    QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
+
+    QColor colorOutline = aDlg->GetColor(2);
+    QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red());
+    QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green());
+    QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue());
+
+    QColor colorNode = aDlg->GetColor(3);
+    QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
+    QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green());
+    QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
+
+    QColor colorBackFace = aDlg->GetColor(4);
+    QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red());
+    QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green());
+    QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue());
+
+    int width = aDlg->GetIntValue(1);
+    QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
+
+    int nodes_size = aDlg->GetIntValue(2);
+    QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
+
+    int shrink_coeff = aDlg->GetIntValue(3);
+    QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
+  }
+
+  delete aDlg;
 }
 
 //=======================================================================
@@ -5869,189 +4126,43 @@ int SMESHGUI::Parameter(Standard_Boolean & res,
  *
  */
 //=============================================================================
-void SMESHGUI::DisplayEdges(SMESH_Actor * ac, bool visibility)
-{
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-       if (ac->DataSource == NULL || ac->GetMapper() == NULL)
-               return;
-
-       vtkGeometryFilter *gf = vtkGeometryFilter::New();
-       gf->SetInput(ac->DataSource);
-       vtkFeatureEdges *edges = vtkFeatureEdges::New();
-       edges->SetInput(gf->GetOutput());
-       edges->BoundaryEdgesOn();
-       edges->ManifoldEdgesOn();
-
-       vtkPolyDataMapper *edgeMapper = vtkPolyDataMapper::New();
-       edgeMapper->SetInput(edges->GetOutput());
-       edgeMapper->ScalarVisibilityOff();
-
-       vtkRenderer *theRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-       vtkActorCollection *actorList = theRenderer->GetActors();
-
-       int test = actorList->IsItemPresent(ac->EdgeDevice);
-       if (test == 0)
-       {
-               vtkProperty *prop = vtkProperty::New();
-               prop->SetColor(QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed").
-                       toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").
-                       toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat() /
-                       255.);
-               prop->SetPointSize(QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").
-                       toInt());
-               prop->SetLineWidth(QAD_CONFIG->getSetting("SMESH:SettingsWidth").
-                       toInt());
-               ac->EdgeDevice->SetProperty(prop);
-               ac->SetEdgeColor(QAD_CONFIG->
-                       getSetting("SMESH:SettingsOutlineColorRed").toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").
-                       toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat() /
-                       255.);
-               ac->EdgeDevice->SetMapper(edgeMapper);
-
-               theRenderer->AddActor(ac->EdgeDevice);
-       }
-       else
-       {
-               ac->EdgeDevice->SetMapper(edgeMapper);
-               edgeMapper->Update();
-       }
-
-       vtkShrinkFilter *shrink = vtkShrinkFilter::New();
-       shrink->SetInput(ac->DataSource);
-       shrink->SetShrinkFactor(ac->GetShrinkFactor());
-       vtkGeometryFilter *Shrinkgf = vtkGeometryFilter::New();
-       Shrinkgf->SetInput(shrink->GetOutput());
-       vtkFeatureEdges *ShrinkEdges = vtkFeatureEdges::New();
-       ShrinkEdges->SetInput(Shrinkgf->GetOutput());
-       ShrinkEdges->BoundaryEdgesOn();
-       ShrinkEdges->ManifoldEdgesOn();
-
-       vtkPolyDataMapper *ShrinkEdgeMapper = vtkPolyDataMapper::New();
-       ShrinkEdgeMapper->SetInput(ShrinkEdges->GetOutput());
-       ShrinkEdgeMapper->ScalarVisibilityOff();
-
-       test = actorList->IsItemPresent(ac->EdgeShrinkDevice);
-       if (test == 0)
-       {
-               vtkProperty *prop = vtkProperty::New();
-               prop->SetColor(QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed").
-                       toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").
-                       toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat() /
-                       255.);
-               prop->SetPointSize(QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").
-                       toInt());
-               prop->SetLineWidth(QAD_CONFIG->getSetting("SMESH:SettingsWidth").
-                       toInt());
-               ac->EdgeShrinkDevice->SetProperty(prop);
-               ac->SetEdgeColor(QAD_CONFIG->
-                       getSetting("SMESH:SettingsOutlineColorRed").toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").
-                       toFloat() / 255.,
-                       QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat() /
-                       255.);
-               ac->EdgeShrinkDevice->SetMapper(ShrinkEdgeMapper);
-
-               theRenderer->AddActor(ac->EdgeShrinkDevice);
-       }
-       else
-       {
-               ac->EdgeShrinkDevice->SetMapper(ShrinkEdgeMapper);
-               ShrinkEdgeMapper->Update();
-       }
-
-       vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
-       renWin->Render();
-}
+void SMESHGUI::DisplayEdges(SMESH_Actor * ac, bool visibility){}
 
 //=============================================================================
 /*!
  *
  */
 //=============================================================================
-void SMESHGUI::InitActor(SMESH::SMESH_Mesh_ptr aMesh)
-{
-       SALOMEDS::SObject_var aSO_M = myStudyAPI.FindMesh(aMesh);
-       SALOMEDS::GenericAttribute_var anAttr;
-       SALOMEDS::AttributeName_var aName;
-       if (!aSO_M->_is_nil())
-       {
-               if (aSO_M->FindAttribute(anAttr, "AttributeName"))
-               {
-                       aName = SALOMEDS::AttributeName::_narrow(anAttr);
-                       Standard_Boolean result;
-                       SMESH_Actor *MeshActor =
-                               smeshGUI->FindActorByEntry(aSO_M->GetID(), result, true);
-                       if (!result)
-                       {
-                               SMESH_Actor *amesh = SMESH_Actor::New();
-                               Handle(SALOME_InteractiveObject) IO =
-                                       new SALOME_InteractiveObject(aSO_M->GetID(), "MESH",
-                                       aName->Value());
-                               amesh->setIO(IO);
-                               amesh->setName(aName->Value());
-                               DisplayActor(amesh, false);
-                       }
-               }
-       }
-}
+void SMESHGUI::InitActor(SMESH::SMESH_Mesh_ptr aMesh){}
 
 //=============================================================================
 /*!
  *
  */
 //=============================================================================
-void SMESHGUI::Update()
-{
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
-       {                                                       //VTK
-               vtkRenderer *theRenderer =
-                       ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-                       getRightFrame()->getViewFrame())->getRenderer();
-
-               SALOME_Selection *Sel =
-                       SALOME_Selection::Selection(myActiveStudy->getSelection());
-               int nbSel = Sel->IObjectCount();
-               if (nbSel == 0)
-               {
-                       vtkActorCollection *actorList = theRenderer->GetActors();
-                       actorList->InitTraversal();
-                       vtkActor *ac = actorList->GetNextActor();
-                       while (!(ac == NULL))
-                       {
-                               if (ac->IsA("SMESH_Actor"))
-                               {
-                                       SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
-                                       if (anActor->hasIO())
-                                       {
-                                               Handle(SALOME_InteractiveObject) IO = anActor->getIO();
-                                               Update(IO);
-                                       }
-                               }
-                               ac = actorList->GetNextActor();
-                       }
-               }
-               else
-               {
-                       SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-                       for (; It.More(); It.Next())
-                       {
-                               Handle(SALOME_InteractiveObject) IO = It.Value();
-                               Update(IO);
-                       }
-               }
-               vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
-               renWin->Render();
-       }
-       QApplication::restoreOverrideCursor();
+void SMESHGUI::Update(){
+  if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){
+    SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
+    if(Sel->IObjectCount() == 0){
+      vtkRenderer* aRenderer = aViewFrame->getRenderer();
+      vtkActorCollection *aCollection = aRenderer->GetActors();
+      aCollection->InitTraversal();
+      while(vtkActor *anAct = aCollection->GetNextActor()){
+       if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
+         if(anActor->hasIO()){
+           Update(anActor->getIO());
+         }
+       }
+      }
+    }else{
+      SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+      for(; It.More(); It.Next()){
+       Handle(SALOME_InteractiveObject) IO = It.Value();
+       Update(IO);
+      }
+    }
+    ::RepaintCurrentView();
+  }
 }
 
 //=============================================================================
@@ -6059,47 +4170,11 @@ void SMESHGUI::Update()
  *
  */
 //=============================================================================
-void SMESHGUI::Update(const Handle(SALOME_InteractiveObject) & IO)
-{
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-
-       if (IO->hasEntry())
-       {
-               Standard_Boolean res;
-               SMESH::SMESH_Mesh_var aMesh = ConvertIOinMesh(IO, res);
-               if (res)
-               {
-                       SMESH_Actor *ac = FindActorByEntry(IO->getEntry(), res, false);
-                       if (res)
-                       {
-                               // Check whether the actor belongs to the active view
-                               VTKViewer_RenderWindowInteractor *rwInter =
-                                       ((VTKViewer_ViewFrame *) myActiveStudy->
-                                       getActiveStudyFrame()->getRightFrame()->getViewFrame())->
-                                       getRWInteractor();
-
-                               ac = ReadScript(aMesh);
-                               // The actor belongs to inactive view -> create a copy and display it in the active view
-                               if (!rwInter->isInViewer(IO))
-                               {
-                                       SMESH_Actor *acCopy = SMESH_Actor::New();
-                                       acCopy->ShallowCopy(ac);
-                                       ac=acCopy;
-                               }
-
-                               if (ac != NULL)
-                               {
-#ifdef TRACE
-                                       Dump(ac);
-#endif
-                                       DisplayActor(ac);
-                                       DisplayEdges(ac);
-                                       smeshGUI->ChangeRepresentation(ac, ac->getDisplayMode());
-                               }
-                       }
-               }
-       }
+void SMESHGUI::Update(const Handle(SALOME_InteractiveObject) & theIO){
+  CORBA::Long anId = smeshGUI->myStudy->StudyId();
+  TVisualObjPtr aVisualObj = ::GetVisualObj(anId,theIO->getEntry());
+  aVisualObj->Update();
+  ::UpdateView(eDisplay,theIO->getEntry());
 }
 
 //=============================================================================
@@ -6118,7 +4193,7 @@ vtkActor *SMESHGUI::SimulationMoveNode(SMESH_Actor * Mactor, int idnode)
                getRightFrame()->getViewFrame())->getRenderer();
 
        vtkUnstructuredGrid *ugrid =
-               vtkUnstructuredGrid::SafeDownCast(Mactor->DataSource);
+               vtkUnstructuredGrid::SafeDownCast(Mactor->GetUnstructuredGrid());
        vtkIdList *IdCells = vtkIdList::New();
        ugrid->GetPointCells(idnode, IdCells);
 
@@ -6139,7 +4214,7 @@ vtkActor *SMESHGUI::SimulationMoveNode(SMESH_Actor * Mactor, int idnode)
        prop->SetColor(1., 0., 0.);
        prop->SetRepresentationToWireframe();
 
-       int Edgewidth = (int)Mactor->EdgeDevice->GetProperty()->GetLineWidth();
+       int Edgewidth = (int)Mactor->GetLineWidth();
        if (Edgewidth == 0)
                Edgewidth = 1;
        prop->SetLineWidth(Edgewidth + 1);
@@ -6184,7 +4259,7 @@ void SMESHGUI::DisplaySimulationNode(SMESH::SMESH_Mesh_ptr aMesh, float x,
        if (result)
        {
                vtkUnstructuredGrid *ugrid =
-                       vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
+                       vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid());
                vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
 
                vtkPoints *Pts = ugrid->GetPoints();
@@ -6286,36 +4361,17 @@ void SMESHGUI::MoveNode(SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x,
  *
  */
 //=============================================================================
-void SMESHGUI::ScalarVisibilityOff()
-{
-       if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK)
-               return;
-
-       vtkRenderer *theRenderer =
-               ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()->
-               getRightFrame()->getViewFrame())->getRenderer();
-       vtkActorCollection *actorList = theRenderer->GetActors();
-
-       actorList->InitTraversal();
-       vtkActor *ac = actorList->GetNextActor();
-       while (!(ac == NULL))
-       {
-               if (ac->IsA("SMESH_Actor"))
-               {
-                       SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac);
-                       if (anActor->GetVisibility() == 1)
-                       {
-                               vtkDataSetMapper *meshMapper =
-                                       (vtkDataSetMapper *) (anActor->getMapper());
-                               meshMapper->ScalarVisibilityOff();
-                               meshMapper->SetInput(anActor->DataSource);
-                               ChangeRepresentation(anActor, anActor->getDisplayMode());
-                       }
-               }
-               ac = actorList->GetNextActor();
-       }
-
-       theRenderer->Render();
+void SMESHGUI::ScalarVisibilityOff(){
+  if(vtkRenderer *aRenderer = ::GetCurrentRenderer()){
+    vtkActorCollection *actorList = aRenderer->GetActors();
+    actorList->InitTraversal();
+    while(vtkActor *ac = actorList->GetNextActor()){
+      if(SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac)){
+       anActor->GetMapper()->ScalarVisibilityOff();
+      }
+    }
+    ::RepaintCurrentView();
+  }
 }
 
 //=============================================================================
@@ -6355,7 +4411,7 @@ void SMESHGUI::DisplaySimulationEdge(SMESH::SMESH_Mesh_ptr aMesh,
                pts[1] = idNodes[1];
 
                vtkUnstructuredGrid *ugrid =
-                       vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
+                       vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid());
                vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
                newugrid->SetPoints(ugrid->GetPoints());
                newugrid->InsertNextCell(VTK_LINE, 2, pts);
@@ -6427,7 +4483,7 @@ void SMESHGUI::DisplaySimulationTriangle(SMESH::SMESH_Mesh_ptr aMesh,
                        pts[2] = idNodes[2];
                }
                vtkUnstructuredGrid *ugrid =
-                       vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
+                       vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid());
                vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
                newugrid->SetPoints(ugrid->GetPoints());
                newugrid->InsertNextCell(VTK_TRIANGLE, 3, pts);
@@ -6469,7 +4525,7 @@ void SMESHGUI::DisplaySimulationQuadrangle(SMESH::SMESH_Mesh_ptr aMesh,
        SMESH_Actor *ac = FindActor(aMesh, result, true);
 
        vtkUnstructuredGrid *ugrid =
-               vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
+               vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid());
 
        if (result)
        {
@@ -6534,7 +4590,7 @@ void SMESHGUI::DisplaySimulationQuadrangle(SMESH::SMESH_Mesh_ptr aMesh,
                        Ids->InsertId(3, idNodes[3]);
                }
 
-               //    vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource );
+               //    vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->GetUnstructuredGrid() );
                vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
                newugrid->SetPoints(ugrid->GetPoints());
                newugrid->InsertNextCell(VTK_QUAD, Ids);
@@ -6591,7 +4647,7 @@ void SMESHGUI::DisplaySimulationTetra(SMESH::SMESH_Mesh_ptr aMesh,
                Ids->InsertId(3, idNodes[3]);
 
                vtkUnstructuredGrid *ugrid =
-                       vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
+                       vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid());
                vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
                newugrid->SetPoints(ugrid->GetPoints());
                newugrid->InsertNextCell(VTK_TETRA, Ids);
@@ -6652,7 +4708,7 @@ void SMESHGUI::DisplaySimulationHexa(SMESH::SMESH_Mesh_ptr aMesh,
                Ids->InsertId(7, idNodes[7]);
 
                vtkUnstructuredGrid *ugrid =
-                       vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
+                       vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid());
                vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New();
                newugrid->SetPoints(ugrid->GetPoints());
                newugrid->InsertNextCell(VTK_HEXAHEDRON, Ids);
@@ -6678,101 +4734,84 @@ void SMESHGUI::DisplaySimulationHexa(SMESH::SMESH_Mesh_ptr aMesh,
  *
  */
 //=============================================================================
-void SMESHGUI::AddFace(SMESH::SMESH_Mesh_ptr aMesh,
-       const TColStd_MapOfInteger & MapIndex, bool reverse)
+void SMESHGUI::AddFace(SMESH::SMESH_Mesh_ptr theMesh,
+                      const TColStd_MapOfInteger & MapIndex, 
+                      bool reverse)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       Standard_Boolean result;
-       SMESH_Actor *ac = FindActor(aMesh, result, true);
-       if (result)
-       {
-               TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
-               SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
-               anArrayOfIdeces->length(MapIndex.Extent());
-
-               int i = 0;
-               for (; ite.More(); ite.Next())
-               {
-                       anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key());
-                       i++;
-               }
-
-               int tmp;
-               if (MapIndex.Extent() == 4)
-               {
-                       int idNodes[4];
-                       int i = 0;
-                       TColStd_MapIteratorOfMapOfInteger ite1(MapIndex);
-                       for (; ite1.More(); ite1.Next())
-                       {
-                               idNodes[i] = ite1.Key();
-                               i++;
-                       }
-
-                       vtkUnstructuredGrid *ugrid =
-                               vtkUnstructuredGrid::SafeDownCast(ac->DataSource);
-                       float *p0 = ugrid->GetPoint(idNodes[0]);
-                       float *p1 = ugrid->GetPoint(idNodes[1]);
-                       float *p2 = ugrid->GetPoint(idNodes[2]);
-                       float *p3 = ugrid->GetPoint(idNodes[3]);
-
-                       gp_Pnt P0(p0[0], p0[1], p0[2]);
-
-                       gp_Vec V1(P0, gp_Pnt(p1[0], p1[1], p1[2]));
-                       gp_Vec V2(P0, gp_Pnt(p2[0], p2[1], p2[2]));
-                       gp_Vec V3(P0, gp_Pnt(p3[0], p3[1], p3[2]));
-
-                       gp_Vec Cross1 = V1 ^ V2;
-                       gp_Vec Cross2 = V2 ^ V3;
-
-                       if (Cross1.Dot(Cross2) < 0)
-                       {
-
-                               V1 = gp_Vec(P0, gp_Pnt(p2[0], p2[1], p2[2]));
-                               V2 = gp_Vec(P0, gp_Pnt(p1[0], p1[1], p1[2]));
-                               Cross1 = V1 ^ V2;
-                               Cross2 = V2 ^ V3;
-
-                               if (Cross1.Dot(Cross2) < 0)
-                               {
-                                       tmp = anArrayOfIdeces[2];
-                                       anArrayOfIdeces[2] = anArrayOfIdeces[3];
-                                       anArrayOfIdeces[3] = tmp;
-                               }
-                               else
-                               {
-                                       tmp = anArrayOfIdeces[1];
-                                       anArrayOfIdeces[1] = anArrayOfIdeces[2];
-                                       anArrayOfIdeces[2] = tmp;
-                               }
-                       }
-               }
-
-               //    int tmp;
-               if (reverse)
-               {
-                       for (i = 0; i < (MapIndex.Extent() / 2); i++)
-                       {
-                               tmp = anArrayOfIdeces[i];
-                               anArrayOfIdeces[i] = anArrayOfIdeces[MapIndex.Extent() - i - 1];
-                               anArrayOfIdeces[MapIndex.Extent() - i - 1] = tmp;
-                       }
-               }
-               SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
-               aMeshEditor->AddFace(anArrayOfIdeces);
-       }
-       if (myAutomaticUpdate)
-       {
-               SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
-               if (Mesh != NULL)
-               {
-                       smeshGUI->DisplayActor(Mesh);
-                       smeshGUI->DisplayEdges(Mesh);
-                       smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
-                       AddActorInSelection(Mesh);
-               }
-       }
-       QApplication::restoreOverrideCursor();
+  QAD_WaitCursor wc;
+  try{
+    SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh);
+    CORBA::String_var anEntry = aSobj->GetID();
+    if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){
+      SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
+      anArrayOfIdeces->length(MapIndex.Extent());
+      TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
+      for(int i = 0; ite.More(); ite.Next(), i++){
+       anArrayOfIdeces[i] = anActor->GetNodeObjId(ite.Key());
+      }
+      int tmp;
+      if(MapIndex.Extent() == 4){
+       int idNodes[4];
+       TColStd_MapIteratorOfMapOfInteger ite1(MapIndex);
+       for(int i = 0; ite1.More(); ite1.Next(), i++){
+         idNodes[i] = ite1.Key();
+       }
+       vtkUnstructuredGrid *ugrid = anActor->GetUnstructuredGrid();
+       float *p0 = ugrid->GetPoint(idNodes[0]);
+       float *p1 = ugrid->GetPoint(idNodes[1]);
+       float *p2 = ugrid->GetPoint(idNodes[2]);
+       float *p3 = ugrid->GetPoint(idNodes[3]);
+       
+       gp_Pnt P0(p0[0], p0[1], p0[2]);
+       
+       gp_Vec V1(P0, gp_Pnt(p1[0], p1[1], p1[2]));
+       gp_Vec V2(P0, gp_Pnt(p2[0], p2[1], p2[2]));
+       gp_Vec V3(P0, gp_Pnt(p3[0], p3[1], p3[2]));
+       
+       gp_Vec Cross1 = V1 ^ V2;
+       gp_Vec Cross2 = V2 ^ V3;
+       
+       if(Cross1.Dot(Cross2) < 0){
+         V1 = gp_Vec(P0, gp_Pnt(p2[0], p2[1], p2[2]));
+         V2 = gp_Vec(P0, gp_Pnt(p1[0], p1[1], p1[2]));
+         Cross1 = V1 ^ V2;
+         Cross2 = V2 ^ V3;
+         
+         if(Cross1.Dot(Cross2) < 0){
+           tmp = anArrayOfIdeces[2];
+           anArrayOfIdeces[2] = anArrayOfIdeces[3];
+           anArrayOfIdeces[3] = tmp;
+         }else{
+           tmp = anArrayOfIdeces[1];
+           anArrayOfIdeces[1] = anArrayOfIdeces[2];
+           anArrayOfIdeces[2] = tmp;
+         }
+       }
+      }
+      if(reverse){
+       for(int i = 0; i < (MapIndex.Extent() / 2); i++){
+         tmp = anArrayOfIdeces[i];
+         anArrayOfIdeces[i] = anArrayOfIdeces[MapIndex.Extent() - i - 1];
+         anArrayOfIdeces[MapIndex.Extent() - i - 1] = tmp;
+       }
+      }
+      SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
+      aMeshEditor->AddFace(anArrayOfIdeces);
+      if(myAutomaticUpdate){
+       CORBA::Long anId = smeshGUI->myStudy->StudyId();
+       if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){
+         aVisualObj->Update(true);
+       }
+       AddActorInSelection(anActor);
+      }
+    }
+  }catch(SALOME::SALOME_Exception& exc) {
+    INFOS("Follow exception was cought:\n\t"<<exc.details.text);
+  }catch(const std::exception& exc){
+    INFOS("Follow exception was cought:\n\t"<<exc.what());
+  }catch(...){
+    INFOS("Unknown exception was cought !!!");
+  }
 }
 
 //=============================================================================
@@ -6780,113 +4819,103 @@ void SMESHGUI::AddFace(SMESH::SMESH_Mesh_ptr aMesh,
  *
  */
 //=============================================================================
-void SMESHGUI::AddVolume(SMESH::SMESH_Mesh_ptr aMesh,
-       const TColStd_MapOfInteger & MapIndex)
+void SMESHGUI::AddVolume(SMESH::SMESH_Mesh_ptr theMesh,
+                        const TColStd_MapOfInteger & MapIndex)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       Standard_Boolean result;
-       SMESH_Actor *ac = FindActor(aMesh, result, true);
-       if (result)
-       {
-               TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
-               SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
-               anArrayOfIdeces->length(MapIndex.Extent());
-
-               int i = 0;
-               for (; ite.More(); ite.Next())
-               {
-                       anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key());
-                       i++;
-               }
-
-               SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
-               aMeshEditor->AddVolume(anArrayOfIdeces);
-       }
-       if (myAutomaticUpdate)
-       {
-               SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
-               if (Mesh != NULL)
-               {
-                       smeshGUI->DisplayActor(Mesh);
-                       smeshGUI->DisplayEdges(Mesh);
-                       smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
-                       AddActorInSelection(Mesh);
-               }
-       }
-       QApplication::restoreOverrideCursor();
+  QAD_WaitCursor wc;
+  try{
+    SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh);
+    CORBA::String_var anEntry = aSobj->GetID();
+    if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){
+      SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
+      anArrayOfIdeces->length(MapIndex.Extent());
+      TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
+      for(int i = 0; ite.More(); ite.Next(), i++){
+       anArrayOfIdeces[i] = anActor->GetNodeObjId(ite.Key());
+      }
+      SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
+      aMeshEditor->AddVolume(anArrayOfIdeces);
+      if(myAutomaticUpdate){
+       CORBA::Long anId = smeshGUI->myStudy->StudyId();
+       if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){
+         aVisualObj->Update(true);
+       }
+      }
+    }
+  }catch(SALOME::SALOME_Exception& exc) {
+    INFOS("Follow exception was cought:\n\t"<<exc.details.text);
+  }catch(const std::exception& exc){
+    INFOS("Follow exception was cought:\n\t"<<exc.what());
+  }catch(...){
+    INFOS("Unknown exception was cought !!!");
+  }
 }
-
 //=============================================================================
 /*!
  *
  */
 //=============================================================================
-void SMESHGUI::AddEdge(SMESH::SMESH_Mesh_ptr aMesh,
-       const TColStd_MapOfInteger & MapIndex)
+void SMESHGUI::AddEdge(SMESH::SMESH_Mesh_ptr theMesh,
+                      const TColStd_MapOfInteger & MapIndex)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       Standard_Boolean result;
-       SMESH_Actor *ac = FindActor(aMesh, result, true);
-       if (result)
-       {
-               TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
-               SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
-               anArrayOfIdeces->length(MapIndex.Extent());
-
-               int i = 0;
-               for (; ite.More(); ite.Next())
-               {
-                       anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key());
-                       i++;
-               }
-
-               SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
-               aMeshEditor->AddEdge(anArrayOfIdeces);
-       }
-       if (myAutomaticUpdate)
-       {
-               SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
-               if (Mesh != NULL)
-               {
-                       smeshGUI->DisplayActor(Mesh);
-                       smeshGUI->DisplayEdges(Mesh);
-                       smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
-                       AddActorInSelection(Mesh);
-               }
-       }
-       QApplication::restoreOverrideCursor();
+  QAD_WaitCursor wc;
+  try{
+    SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh);
+    CORBA::String_var anEntry = aSobj->GetID();
+    if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){
+      SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
+      anArrayOfIdeces->length(MapIndex.Extent());
+      TColStd_MapIteratorOfMapOfInteger ite(MapIndex);
+      for(int i = 0; ite.More(); ite.Next(), i++){
+       anArrayOfIdeces[i] = anActor->GetNodeObjId(ite.Key());
+      }
+      SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
+      aMeshEditor->AddEdge(anArrayOfIdeces);
+      if(myAutomaticUpdate){
+       CORBA::Long anId = smeshGUI->myStudy->StudyId();
+       if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){
+         aVisualObj->Update(true);
+       }
+      }
+    }
+  }catch(SALOME::SALOME_Exception& exc) {
+    INFOS("Follow exception was cought:\n\t"<<exc.details.text);
+  }catch(const std::exception& exc){
+    INFOS("Follow exception was cought:\n\t"<<exc.what());
+  }catch(...){
+    INFOS("Unknown exception was cought !!!");
+  }
 }
-
 //=============================================================================
 /*!
  *
  */
 //=============================================================================
-void SMESHGUI::AddNode(SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z)
+void SMESHGUI::AddNode(SMESH::SMESH_Mesh_ptr theMesh, 
+                      float x, float y, float z)
 {
-       QApplication::setOverrideCursor(Qt::waitCursor);
-       Standard_Boolean result;
-       SMESH_Actor *ac = FindActor(aMesh, result, true);
-       if (result)
-       {
-               SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
-               aMeshEditor->AddNode(x, y, z);
-
-               if (myAutomaticUpdate)
-               {
-                       SMESH_Actor *Mesh = smeshGUI->ReadScript(aMesh);
-                       if (Mesh != NULL)
-                       {
-                               smeshGUI->DisplayActor(Mesh);
-                               smeshGUI->DisplayEdges(Mesh);
-                               smeshGUI->ChangeRepresentation(Mesh, Mesh->getDisplayMode());
-                               AddActorInSelection(Mesh);
-                       }
-               }
-       }
-       QApplication::restoreOverrideCursor();
+  QAD_WaitCursor wc;
+  try{
+    SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh);
+    CORBA::String_var anEntry = aSobj->GetID();
+    if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){
+      SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
+      aMeshEditor->AddNode(x, y, z);
+      if(myAutomaticUpdate){
+       CORBA::Long anId = smeshGUI->myStudy->StudyId();
+       if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){
+         aVisualObj->Update(true);
+       }
+      }
+    }
+  }catch(SALOME::SALOME_Exception& exc) {
+    INFOS("Follow exception was cought:\n\t"<<exc.details.text);
+  }catch(const std::exception& exc){
+    INFOS("Follow exception was cought:\n\t"<<exc.what());
+  }catch(...){
+    INFOS("Unknown exception was cought !!!");
+  }
 }
-
 //=============================================================================
 /*!
  *
@@ -6945,105 +4974,89 @@ void SMESHGUI::DisplayEdgesConnectivityLegendBox(vtkActor * ac)
 //===============================================================================
 void SMESHGUI::OnEditDelete()
 {
-       if (QAD_MessageBox::warn2
-               (QAD_Application::getDesktop(),
-                       tr("SMESH_WRN_WARNING"),
-                       tr("SMESH_REALLY_DELETE"),
-                       tr("SMESH_BUT_YES"), tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
-               return;
-
-       int nbSf = myActiveStudy->getStudyFramesCount();
-
-       Standard_Boolean found;
-       SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
-       SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
-       SALOMEDS::GenericAttribute_var anAttr;
-       SALOMEDS::AttributeIOR_var anIOR;
-
-       SALOME_Selection *Sel =
-               SALOME_Selection::Selection(myActiveStudy->getSelection());
-       SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-       for (; It.More(); It.Next())
-       {
-               Handle(SALOME_InteractiveObject) IObject = It.Value();
-               if (IObject->hasEntry())
-               {
-                       SALOMEDS::SObject_var SO =
-                               myStudy->FindObjectID(IObject->getEntry());
-
-                       /* Erase child graphical objects */
-                       SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
-                       for (; it->More(); it->Next())
-                       {
-                               SALOMEDS::SObject_var CSO = it->Value();
-                               if (CSO->FindAttribute(anAttr, "AttributeIOR"))
-                               {
-                                       anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-
-                                       for (int i = 0; i < nbSf; i++)
-                                       {
-                                               QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i);
-                                               if (sf->getTypeView() == VIEW_VTK)
-                                               {
-                                                       vtkRenderer *Renderer =
-                                                               ((VTKViewer_ViewFrame *) smeshGUI->
-                                                               myActiveStudy->getActiveStudyFrame()->
-                                                               getRightFrame()->getViewFrame())->getRenderer();
-                                                       SMESH_Actor *ac =
-                                                               smeshGUI->FindActorByEntry(CSO->GetID(), found,
-                                                               false);
-                                                       if (found)
-                                                       {
-                                                               Renderer->RemoveActor(ac->EdgeDevice);
-                                                               Renderer->RemoveActor(ac->EdgeShrinkDevice);
-                                                               Renderer->RemoveActor(ac);
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-
-                       /* Erase main graphical object */
-                       for (int i = 0; i < nbSf; i++)
-                       {
-                               QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i);
-                               if (sf->getTypeView() == VIEW_VTK)
-                               {
-                                       vtkRenderer *Renderer =
-                                               ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy->
-                                               getActiveStudyFrame()->getRightFrame()->
-                                               getViewFrame())->getRenderer();
-                                       VTKViewer_RenderWindowInteractor *myRenderInter =
-                                               ((VTKViewer_ViewFrame *) sf->getRightFrame()->
-                                               getViewFrame())->getRWInteractor();
-                                       SMESH_Actor *ac =
-                                               smeshGUI->FindActorByEntry(IObject->getEntry(), found,
-                                               false);
-                                       if (found)
-                                       {
-                                               Renderer->RemoveActor(ac->EdgeDevice);
-                                               Renderer->RemoveActor(ac->EdgeShrinkDevice);
-                                       }
-                                       myRenderInter->Remove(IObject);
-                               }
-                       }
-
-                       /* Erase objects in Study */
-                       SALOMEDS::SObject_var obj =
-                               myStudy->FindObjectID(IObject->getEntry());
-                       if (!obj->_is_nil())
-                       {
-                               QAD_Operation *op =
-                                       new SALOMEGUI_ImportOperation(myActiveStudy);
-                               op->start();
-                               aStudyBuilder->RemoveObject(obj);
-                               op->finish();
-                       }
-
-               }                                               /* IObject->hasEntry() */
-       }                                                       /* more/next           */
+  if (QAD_MessageBox::warn2
+      (QAD_Application::getDesktop(),
+       tr("SMESH_WRN_WARNING"),
+       tr("SMESH_REALLY_DELETE"),
+       tr("SMESH_BUT_YES"), tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
+    return;
+
+  int nbSf = myActiveStudy->getStudyFramesCount();
+
+  Standard_Boolean found;
+  SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+  SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
+  SALOMEDS::GenericAttribute_var anAttr;
+  SALOMEDS::AttributeIOR_var anIOR;
+
+  SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
+  SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+  for(; It.More(); It.Next()){
+    Handle(SALOME_InteractiveObject) IObject = It.Value();
+    if(IObject->hasEntry()){
+      SALOMEDS::SObject_var SO = myStudy->FindObjectID(IObject->getEntry());
+
+      /* Erase child graphical objects */
+      SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
+      for(; it->More(); it->Next()){
+        SALOMEDS::SObject_var CSO = it->Value();
+        if(CSO->FindAttribute(anAttr, "AttributeIOR")){
+          anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+         
+          for(int i = 0; i < nbSf; i++){
+            QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i);
+           CORBA::String_var anEntry = CSO->GetID();
+           if(SMESH_Actor* anActor = ::FindActorByEntry(sf,anEntry.in())){
+             RemoveActor(sf,anActor);
+           }
+          }
+        }
+      }
+
+      /* Erase main graphical object */
+      for(int i = 0; i < nbSf; i++){
+       QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i);
+       if(SMESH_Actor* anActor = ::FindActorByEntry(sf,IObject->getEntry())){
+         RemoveActor(sf,anActor);
+       }
+      }
+
+      // Remove object(s) from data structures
+      SALOMEDS::SObject_var obj = myStudy->FindObjectID(IObject->getEntry());
+      if(!obj->_is_nil()){
+       SMESH::SMESH_Group_var     aGroup = SMESH::SMESH_Group  ::_narrow(obj->GetObject());
+       SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject());
+
+       if ( !aGroup->_is_nil() ) {                          // DELETE GROUP
+         SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
+         aMesh->RemoveGroup( aGroup );
+       }
+       else if ( !aSubMesh->_is_nil() ) {                   // DELETE SUBMESH
+         SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
+         aMesh->RemoveSubMesh( aSubMesh );
+       }
+       else {// default action: remove SObject from the study
+         // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
+         //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
+         //op->start();
+         aStudyBuilder->RemoveObjectWithChildren( obj );
+         //op->finish();
+       }
+      }
+
+    } /* IObject->hasEntry() */
+  } /* more/next */
+
+  /* Clear any previous selection */
+  Sel->ClearIObjects();
+  myActiveStudy->updateObjBrowser();
+}
 
-       /* Clear any previous selection */
-       Sel->ClearIObjects();
-       myActiveStudy->updateObjBrowser();
+//=======================================================================
+// name    : SMESHGUI::GetFilterMgr
+// Purpose : Get filter manager
+//=======================================================================
+SMESH::FilterManager_ptr SMESHGUI::GetFilterMgr()
+{
+   return myFilterMgr;
 }
index ee29287bfb2c54b9e87e3d2cce9a4a9e4cdcc10e..da6cb22bbbc0ad896f924754a9a37dbe78d54806 100644 (file)
@@ -30,6 +30,7 @@
 #define SMESHGUI_HeaderFile
 
 #include "TColStd_MapOfInteger.hxx"
+#include <map>
 
 #include "SMESHDS_Document.hxx"
 
 #include "SALOME_Selection.h"
 #include "SALOME_InteractiveObject.hxx"
 
-#include "SMESH_Actor.h"
-
 #include "SMESHGUI_StudyAPI.h"
+#include "SMESHGUI_Hypotheses.h"
 
 // IDL Headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_Gen)
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Group)
 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
-#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 #include CORBA_SERVER_HEADER(GEOM_Gen)
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+#include CORBA_SERVER_HEADER(SMESH_Filter)
 
 // QT Includes
 #include <qstringlist.h>
 
-// VTK Inlcudes
-#include <vtkScalarBarActor.h>
+// VTK Inlcludes
+
+class vtkActorCollection;
+class vtkActor2DCollection;
+class vtkScalarBarActor;
+class vtkActor;
+
+class SMESH_Actor;
 
 //=================================================================================
 // class    : SMESHGUI
@@ -92,6 +99,13 @@ private :
 
   bool                      myAutomaticUpdate;
 
+  SMESH::FilterManager_var  myFilterMgr;
+
+  // Hypotheses/algorithms from plugin libraries
+  map<string, HypothesisData*>                    myHypothesesMap;
+  map<string, HypothesisData*>                    myAlgorithmsMap;
+  map<string, SMESHGUI_GenericHypothesisCreator*> myHypCreatorMap;
+
 public :
 
   SMESHGUI();
@@ -105,8 +119,6 @@ public :
   SALOMEDS::Study_ptr GetStudy();
   SMESHGUI_StudyAPI   GetStudyAPI();
 
-  vtkScalarBarActor*  GetScalarBar();
-
   QDialog*            GetActiveDialogBox() ;               
   void                SetActiveDialogBox(QDialog* aDlg) ;  
 
@@ -140,79 +152,57 @@ public :
   /* Mesh Management */
   SMESH::SMESH_Mesh_ptr       InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
   SMESH::SMESH_subMesh_ptr    AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
+  SMESH::SMESH_Group_ptr      AddGroup( SMESH::SMESH_Mesh_ptr aMesh, SMESH::ElementType aType, QString aName );
+
+  /* Hypotheses and Algorithms Management */
+  void InitAvailableHypotheses ();
+  QStringList GetAvailableHypotheses (const bool isAlgo);
+  HypothesisData* GetHypothesisData (const char* aHypType);
+  SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator (const QString& aHypType);
+
+  SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const QString& aHypType,
+                                               const QString& aHypName,
+                                               const bool     isAlgo = false);
 
-  /* Hypothesis Management */
-  SMESH::SMESH_Hypothesis_ptr CreateHypothesis( QString TypeHypothesis, QString NameHypothesis );
-  void AddHypothesisOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ;
-  void AddHypothesisOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ;
+  bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
+  bool AddAlgorithmOnMesh  (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
 
-  void RemoveHypothesisOrAlgorithmOnMesh( const Handle(SALOME_InteractiveObject)& IObject ) ;
-  void RemoveHypothesisOrAlgorithmOnMesh( SALOMEDS::SObject_ptr MorSM, SMESH::SMESH_Hypothesis_ptr anHyp ) ;
+  bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
+  bool AddAlgorithmOnSubMesh  (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
 
-  void CreateLocalLength( QString TypeHypothesis, QString NameHypothesis, double Length );
-  void CreateNbSegments( QString TypeHypothesis, QString NameHypothesis, int nbSegments );
-  void CreateMaxElementArea( QString TypeHypothesis, QString NameHypothesis, double MaxArea );
-  void CreateMaxElementVolume( QString TypeHypothesis, QString NameHypothesis, double MaxVolume );
+  bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject);
+  bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM,
+                                         SMESH::SMESH_Hypothesis_ptr anHyp);
 
-  /* Algorithms Management */
-  void AddAlgorithmOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp );
-  void AddAlgorithmOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp );
-  void CreateAlgorithm( QString TypeAlgo, QString NameAlgo );
+  void SetPickable(SMESH_Actor* theActor = NULL);
 
   /* NODES */
   void ViewNodes();
   vtkActor* SimulationMoveNode(SMESH_Actor* Mactor, int idnode);
   void MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z);
-  void AddNode(SMESH_Actor*, int idnode, float x, float y, float z) ; 
-  void AddNodes( SMESH_Actor* Mactor, int number, 
-                const SMESH::double_array& coords, const SMESH::long_array& indexes);
 
   void DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
   void DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z);
 
-  void RemoveNode(SMESH_Actor*, int idnode) ;
   void RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
-  void RemoveNodes(SMESH_Actor* Mactor, int number, 
-                  const SMESH::double_array& coords, const SMESH::long_array& indexes);
 
   /* EDGES */
-  void AddEdge(SMESH_Actor*, int idedge, int idnode1, int idnode2) ;
-  void AddEdges( SMESH_Actor* Mactor, int number, 
-                const SMESH::double_array& coords, const SMESH::long_array& indexes);
   void DisplayEdges(SMESH_Actor* ac, bool visibility = true);
   void DisplayEdgesConnectivityLegendBox(vtkActor *ac);
   void DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
 
   /* TRIANGLES */
-  void AddTriangle(SMESH_Actor*, int idtri, int idnode1, int idnode2, int idnode3) ;
-  void AddTriangles( SMESH_Actor* Mactor, int number, 
-                    const SMESH::double_array& coords, const SMESH::long_array& indexes);
   void DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
 
   /* QUADRANGLES */
-  void AddQuadrangle(SMESH_Actor*, int idquad, int idnode1, int idnode2, 
-                     int idnode3, int idnode4) ;
-  void AddQuadrangles( SMESH_Actor* Mactor, int number, 
-                      const SMESH::double_array& coords, const SMESH::long_array& indexes);
   void DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
 
   /* VOLUMES */
-  void AddTetra(SMESH_Actor*, int idtetra, int idnode1, int idnode2, 
-                int idnode3, int idnode4) ;
-  void AddHexaedre(SMESH_Actor*, int idhexa, int idnode1, int idnode2, 
-                   int idnode3, int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) ;
-  void AddTetras( SMESH_Actor* Mactor, int number, 
-                      const SMESH::double_array& coords, const SMESH::long_array& indexes);
-  void AddHexaedres( SMESH_Actor* Mactor, int number, 
-                      const SMESH::double_array& coords, const SMESH::long_array& indexes);
   void DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
   void DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
 
   /* ELEMENTS */
-  void RemoveElement(SMESH_Actor*, int idnode);
   void RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
-  void RemoveElements(SMESH_Actor* Mactor, int number, 
-                     const SMESH::double_array& coords, const SMESH::long_array& indexes);
   void OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
   void DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
 
@@ -239,6 +229,7 @@ public :
 
   SMESH::SMESH_Mesh_ptr       ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
   SMESH::SMESH_subMesh_ptr    ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
+  SMESH::SMESH_Group_ptr      ConvertIOinSMESHGroup(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
 
   /* Geometry Client */
   GEOM::GEOM_Shape_ptr        ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO, 
@@ -257,7 +248,7 @@ public :
   void SetViewMode(int commandId);
   void ChangeRepresentation( SMESH_Actor* ac, int type );
 
-  SMESH_Actor* FindActor(SMESH::SMESH_Mesh_ptr aMesh
+  SMESH_Actor* FindActor(CORBA::Object_ptr theObj
                         Standard_Boolean& testResult,
                         bool onlyInActiveView);
   SMESH_Actor* FindActorByEntry(QString entry, 
@@ -282,10 +273,7 @@ public :
                            QString Bold, QString Italic, QString Shadow, QString Font, 
                            QString Orientation, float Width, float Height, 
                            int NbColors, int NbLabels);
-  void DisplayScalarBar(bool visibility);
-  void UpdateScalarBar(float MinRange, float MaxRange);
-
-  void SetDisplaySettings(); 
+  void SetDisplaySettings();    
 
   SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ;
 
@@ -303,11 +291,12 @@ public :
   static void setOrb();
 
   /* Import/Export */ //NBU
-  static void Import_Document(QAD_Desktop* parent, int theCommandID);
-  static void Export_Document(QAD_Desktop* parent, int theCommandID);
   static void Import_Mesh(QAD_Desktop* parent, int theCommandID);
   static void Export_Mesh(QAD_Desktop* parent, int theCommandID);
 
+  /* Filter manager */
+  SMESH::FilterManager_ptr GetFilterMgr();
+
 signals:
   void SignalDeactivateActiveDialog() ;
   void SignalCloseAllDialogs() ;
index 8fe1cc2010ae46223d8c5e96a7fe3b988d849dd4..2b40287d0c928248a2fa7c8dc5a6767edcd6f279 100644 (file)
@@ -255,7 +255,7 @@ void SMESHGUI_AddEdgeDlg::ClickOnOk()
 //=================================================================================
 void SMESHGUI_AddEdgeDlg::ClickOnCancel()
 {
-  QAD_Application::getDesktop()->SetSelectionMode( 4 );
+  QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
   disconnect( mySelection, 0, this, 0 );
   mySMESHGUI->ResetState() ;
   mySMESHGUI->EraseSimulationActors();
@@ -282,9 +282,9 @@ void SMESHGUI_AddEdgeDlg::SelectionIntoArgument()
   if(nbNodes < 1)
     return ;
   
-  if ( mySelection->SelectionMode() != 1 ) {
+  if ( mySelection->SelectionMode() != NodeSelection ) {
     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
-                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
+                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") );
     return;
   }
 
index 168dc13508ddf7644d9270e24e0fdc5c85234a4c..b294f936896f43041ca67097e6540f59551cca53 100644 (file)
@@ -278,7 +278,7 @@ void SMESHGUI_AddFaceDlg::ClickOnOk()
 //=================================================================================
 void SMESHGUI_AddFaceDlg::ClickOnCancel()
 {
-  QAD_Application::getDesktop()->SetSelectionMode( 4 );
+  QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
   disconnect( mySelection, 0, this, 0 );
   mySMESHGUI->ResetState() ;
   mySMESHGUI->EraseSimulationActors();
@@ -305,9 +305,9 @@ void SMESHGUI_AddFaceDlg::SelectionIntoArgument()
   if(nbNodes < 1)
     return ;
   
-  if ( mySelection->SelectionMode() != 1 ) {
+  if ( mySelection->SelectionMode() != NodeSelection ) {
     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
-                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
+                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") );
     return;
   }
 
index 91ec96dee25c6e9bd37d33bfb684bb46559e42b2..b3ab63dfcfe96f5bde121e04aeed8662d1786e66 100644 (file)
@@ -33,23 +33,20 @@ using namespace std;
 
 #include "QAD_Application.h"
 #include "QAD_Desktop.h"
+#include "QAD_MessageBox.h"
+#include "QAD_WaitCursor.h"
+#include "QAD_Operation.h"
+
 #include "utilities.h"
 
 // QT Includes
-#include <qbuttongroup.h>
 #include <qgroupbox.h>
 #include <qlabel.h>
 #include <qlineedit.h>
 #include <qpushbutton.h>
-#include <qradiobutton.h>
 #include <qlayout.h>
-#include <qvariant.h>
-#include <qtooltip.h>
-#include <qwhatsthis.h>
-#include <qimage.h>
 #include <qpixmap.h>
 
-
 //=================================================================================
 // class    : SMESHGUI_AddSubMeshDlg()
 // purpose  : Constructs a SMESHGUI_AddSubMeshDlg which is a child of 'parent', with the 
@@ -58,149 +55,97 @@ using namespace std;
 //            TRUE to construct a modal dialog.
 //=================================================================================
 SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
-    : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+    : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
 {
-    QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_ADD_SUBMESH")));
     QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
     if ( !name )
        setName( "SMESHGUI_AddSubMeshDlg" );
-    resize( 303, 175 ); 
     setCaption( tr( "SMESH_ADD_SUBMESH"  ) );
     setSizeGripEnabled( TRUE );
-    SMESHGUI_AddSubMeshDlgLayout = new QGridLayout( this ); 
+    QGridLayout* SMESHGUI_AddSubMeshDlgLayout = new QGridLayout( this ); 
     SMESHGUI_AddSubMeshDlgLayout->setSpacing( 6 );
     SMESHGUI_AddSubMeshDlgLayout->setMargin( 11 );
     
     /***************************************************************/
-    GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
-    GroupConstructors->setTitle( tr( "SMESH_SUBMESH"  ) );
-    GroupConstructors->setExclusive( TRUE );
-    GroupConstructors->setColumnLayout(0, Qt::Vertical );
-    GroupConstructors->layout()->setSpacing( 0 );
-    GroupConstructors->layout()->setMargin( 0 );
-    GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
-    GroupConstructorsLayout->setAlignment( Qt::AlignTop );
-    GroupConstructorsLayout->setSpacing( 6 );
-    GroupConstructorsLayout->setMargin( 11 );
-    Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
-    Constructor1->setText( tr( ""  ) );
-    Constructor1->setPixmap( image1 );
-    Constructor1->setChecked( TRUE );
-    Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
-    Constructor1->setMinimumSize( QSize( 50, 0 ) );
-    GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
-    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
-    GroupConstructorsLayout->addItem( spacer, 0, 1 );
-    SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupConstructors, 0, 0 );
-    
-    /***************************************************************/
-    GroupButtons = new QGroupBox( this, "GroupButtons" );
-    GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
-    GroupButtons->setTitle( tr( ""  ) );
-    GroupButtons->setColumnLayout(0, Qt::Vertical );
-    GroupButtons->layout()->setSpacing( 0 );
-    GroupButtons->layout()->setMargin( 0 );
-    GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
-    GroupButtonsLayout->setAlignment( Qt::AlignTop );
-    GroupButtonsLayout->setSpacing( 6 );
-    GroupButtonsLayout->setMargin( 11 );
-    buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
-    buttonCancel->setText( tr( "SMESH_BUT_CLOSE"  ) );
-    buttonCancel->setAutoDefault( TRUE );
-    GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
-    buttonApply = new QPushButton( GroupButtons, "buttonApply" );
-    buttonApply->setText( tr( "SMESH_BUT_APPLY"  ) );
-    buttonApply->setAutoDefault( TRUE );
-    GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
-    QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
-    GroupButtonsLayout->addItem( spacer_9, 0, 2 );
-    buttonOk = new QPushButton( GroupButtons, "buttonOk" );
-    buttonOk->setText( tr( "SMESH_BUT_OK"  ) );
-    buttonOk->setAutoDefault( TRUE );
-    buttonOk->setDefault( TRUE );
-    GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
-    SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupButtons, 2, 0 );
-
-    /***************************************************************/
-    GroupC1 = new QGroupBox( this, "GroupC1" );
-    GroupC1->setTitle( tr( "SMESH_ARGUMENTS"  ) );
-    GroupC1->setMinimumSize( QSize( 0, 0 ) );
-    GroupC1->setFrameShape( QGroupBox::Box );
-    GroupC1->setFrameShadow( QGroupBox::Sunken );
+    GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), this, "GroupC1" );
     GroupC1->setColumnLayout(0, Qt::Vertical );
     GroupC1->layout()->setSpacing( 0 );
     GroupC1->layout()->setMargin( 0 );
-    GroupC1Layout = new QGridLayout( GroupC1->layout() );
+    QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
     GroupC1Layout->setAlignment( Qt::AlignTop );
     GroupC1Layout->setSpacing( 6 );
     GroupC1Layout->setMargin( 11 );
 
-    TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
-    TextLabelC1A1->setText( tr( "SMESH_OBJECT_MESH"  ) );
-    TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
-    TextLabelC1A1->setFrameShape( QLabel::NoFrame );
-    TextLabelC1A1->setFrameShadow( QLabel::Plain );
-    GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
+    TextLabel_NameMesh = new QLabel(  tr( "SMESH_NAME" ), GroupC1, "TextLabel_NameMesh" );
+    GroupC1Layout->addWidget( TextLabel_NameMesh, 0, 0 );
+    LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" );
+    GroupC1Layout->addWidget( LineEdit_NameMesh, 0, 2 );
+
+    TextLabelC1A1 = new QLabel( tr( "SMESH_OBJECT_MESH" ), GroupC1, "TextLabelC1A1" );
+    GroupC1Layout->addWidget( TextLabelC1A1, 1, 0 );
     SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
-    SelectButtonC1A1->setText( tr( ""  ) );
     SelectButtonC1A1->setPixmap( image0 );
     SelectButtonC1A1->setToggleButton( FALSE );
-    GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
+    GroupC1Layout->addWidget( SelectButtonC1A1, 1, 1 );
     LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
-    GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
-
-    TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
-    TextLabelC1A2->setText( tr( "SMESH_OBJECT_GEOM"  ) );
-    TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
-    TextLabelC1A2->setFrameShape( QLabel::NoFrame );
-    TextLabelC1A2->setFrameShadow( QLabel::Plain );
-    GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
+    GroupC1Layout->addWidget( LineEditC1A1, 1, 2 );
+
+    TextLabelC1A2 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A2" );
+    GroupC1Layout->addWidget( TextLabelC1A2, 2, 0 );
     SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
-    SelectButtonC1A2->setText( tr( ""  ) );
     SelectButtonC1A2->setPixmap( image0 );
     SelectButtonC1A2->setToggleButton( FALSE );
-    GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
+    GroupC1Layout->addWidget( SelectButtonC1A2, 2, 1 );
     LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
-    GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
-
-    TextLabel_NameMesh = new QLabel( GroupC1, "TextLabel_NameMesh" );
-    TextLabel_NameMesh->setText( tr( "SMESH_NAME"  ) );
-    GroupC1Layout->addWidget( TextLabel_NameMesh, 2, 0 );
-    LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" );
-    GroupC1Layout->addWidget( LineEdit_NameMesh, 2, 2 );
+    GroupC1Layout->addWidget( LineEditC1A2, 2, 2 );
 
-    TextLabelC1A1Hyp = new QLabel( GroupC1, "TextLabelC1A1Hyp" );
-    TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_HYPOTHESIS" ) );
-    TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) );
-    TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame );
-    TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain );
+    TextLabelC1A1Hyp = new QLabel( tr( "SMESH_OBJECT_HYPOTHESIS" ), GroupC1, "TextLabelC1A1Hyp" );
     GroupC1Layout->addWidget( TextLabelC1A1Hyp, 3, 0 );
     SelectButtonC1A1Hyp = new QPushButton( GroupC1, "SelectButtonC1A1Hyp" );
-    SelectButtonC1A1Hyp->setText( tr( ""  ) );
     SelectButtonC1A1Hyp->setPixmap( image0 );
     GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 3, 1 );
     LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" );
-    LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) );
     GroupC1Layout->addWidget( LineEditC1A1Hyp, 3, 2 );
 
-    TextLabelC1A1Algo = new QLabel( GroupC1, "TextLabelC1A1Algo" );
-    TextLabelC1A1Algo->setText( tr( "SMESH_OBJECT_ALGORITHM" ) );
-    TextLabelC1A1Algo->setMinimumSize( QSize( 50, 0 ) );
-    TextLabelC1A1Algo->setFrameShape( QLabel::NoFrame );
-    TextLabelC1A1Algo->setFrameShadow( QLabel::Plain );
+    TextLabelC1A1Algo = new QLabel( tr( "SMESH_OBJECT_ALGORITHM" ), GroupC1, "TextLabelC1A1Algo" );
     GroupC1Layout->addWidget( TextLabelC1A1Algo, 4, 0 );
     SelectButtonC1A1Algo = new QPushButton( GroupC1, "SelectButtonC1A1Algo" );
-    SelectButtonC1A1Algo->setText( tr( ""  ) );
     SelectButtonC1A1Algo->setPixmap( image0 );
     GroupC1Layout->addWidget( SelectButtonC1A1Algo, 4, 1 );
     LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" );
-    LineEditC1A1Algo->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Algo->sizePolicy().hasHeightForWidth() ) );
     GroupC1Layout->addWidget( LineEditC1A1Algo, 4, 2 );
 
     SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupC1, 1, 0 );
+
     /***************************************************************/
+    GroupButtons = new QGroupBox( this, "GroupButtons" );
+    GroupButtons->setColumnLayout(0, Qt::Vertical );
+    GroupButtons->layout()->setSpacing( 0 );
+    GroupButtons->layout()->setMargin( 0 );
+    QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+    GroupButtonsLayout->setAlignment( Qt::AlignTop );
+    GroupButtonsLayout->setSpacing( 6 );
+    GroupButtonsLayout->setMargin( 11 );
 
-    Init(Sel) ;
+    buttonOk = new QPushButton( tr( "SMESH_BUT_OK" ), GroupButtons, "buttonOk" );
+    buttonOk->setAutoDefault( TRUE );
+    buttonOk->setDefault( TRUE );
+    GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+
+    buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons, "buttonApply" );
+    buttonApply->setAutoDefault( TRUE );
+    GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
+
+    GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 );
+
+    buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons, "buttonCancel" );
+    buttonCancel->setAutoDefault( TRUE );
+    GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
+
+    SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+    /***************************************************************/
+    Init( Sel ) ;
 }
 
 
@@ -220,60 +165,41 @@ SMESHGUI_AddSubMeshDlg::~SMESHGUI_AddSubMeshDlg()
 //=================================================================================
 void SMESHGUI_AddSubMeshDlg::Init( SALOME_Selection* Sel )
 {
-  GroupC1->show();
-  myConstructorId = 0 ;
-  Constructor1->setChecked( TRUE );
-  myEditCurrentArgument = LineEditC1A1 ;       
   mySelection = Sel;
   mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
   mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
 
-  myGeomFilter = new SALOME_TypeFilter( "GEOM" );
-  myMeshFilter = new SMESH_TypeFilter( MESH );
-
-  myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM );
+  myGeomFilter       = new SALOME_TypeFilter( "GEOM" );
+  myMeshFilter       = new SMESH_TypeFilter( MESH );
+  myAlgorithmFilter  = new SMESH_TypeFilter( ALGORITHM );
   myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS );
 
-  myNameSubMesh = "SubMesh";
-
-  myGeomShape = GEOM::GEOM_Shape::_nil();
-  myMesh = SMESH::SMESH_Mesh::_nil();
-
   /* signals and slots connections */
-  connect( buttonOk, SIGNAL( clicked() ),     this, SLOT( ClickOnOk() ) );
-  connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
+  connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+  connect( buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
-  connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
-
-  connect( SelectButtonC1A1, SIGNAL (clicked() ),   this, SLOT( SetEditCurrentArgument() ) ) ;
-  connect( SelectButtonC1A2, SIGNAL (clicked() ),   this, SLOT( SetEditCurrentArgument() ) ) ;
-  connect( LineEdit_NameMesh, SIGNAL (textChanged(const QString&)  ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
 
-  connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ),  this, SLOT( SetEditCurrentArgument() ) ) ;
+  connect( SelectButtonC1A1,     SIGNAL (clicked() ),  this, SLOT( SetEditCurrentArgument() ) ) ;
+  connect( SelectButtonC1A2,     SIGNAL (clicked() ),  this, SLOT( SetEditCurrentArgument() ) ) ;
+  connect( SelectButtonC1A1Hyp,  SIGNAL (clicked() ),  this, SLOT( SetEditCurrentArgument() ) ) ;
   connect( SelectButtonC1A1Algo, SIGNAL (clicked() ),  this, SLOT( SetEditCurrentArgument() ) ) ;
 
-  connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
-  connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
-  connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
+  connect( mySelection, SIGNAL( currentSelectionChanged() ),      this, SLOT( SelectionIntoArgument() ) );
+  connect( mySMESHGUI,  SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
+  connect( mySMESHGUI,  SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) ) ;
   
   int x, y ;
   mySMESHGUI->DefineDlgPosition( this, x, y ) ;
   this->move( x, y ) ;
   this->show() ; 
 
-  SelectionIntoArgument();
-
-  return ;
-}
-
+  LineEdit_NameMesh->setText( tr( "SMESH_SUBMESH" ) );
+  LineEdit_NameMesh->setFocus() ;
+  myEditCurrentArgument = LineEditC1A1 ;       
+  mySelection->ClearFilters() ;   
+  mySelection->AddFilter( myMeshFilter ) ;
 
-//=================================================================================
-// function : ConstructorsClicked()
-// purpose  : Radio button management
-//=================================================================================
-void SMESHGUI_AddSubMeshDlg::ConstructorsClicked(int constructorId)
-{
-  return ;
+  SelectionIntoArgument();
 }
 
 //=================================================================================
@@ -282,50 +208,77 @@ void SMESHGUI_AddSubMeshDlg::ConstructorsClicked(int constructorId)
 //=================================================================================
 void SMESHGUI_AddSubMeshDlg::ClickOnOk()
 {
-  this->ClickOnApply() ;
-  this->ClickOnCancel() ;
+  if ( this->ClickOnApply() )
+    this->ClickOnCancel() ;
 }
 
 //=================================================================================
 // function : ClickOnApply()
 // purpose  :
 //=================================================================================
-void SMESHGUI_AddSubMeshDlg::ClickOnApply()
+bool SMESHGUI_AddSubMeshDlg::ClickOnApply()
 {
-  switch(myConstructorId)
-    { 
-    case 0 :
-      { 
-       if ( !myNameSubMesh.isEmpty() && !myNameSubMesh.isNull() && 
-            !myGeomShape->_is_nil() && !myMesh->_is_nil()) {
-         mySubMesh = mySMESHGUI->AddSubMesh( myMesh, myGeomShape, myNameSubMesh ) ;
-       }
-       
-       if( myOkHypothesis && !mySubMesh->_is_nil() ) {
-         SALOME_ListIteratorOfListIO It( HypoList );
-         for(;It.More();It.Next()) {
-           Handle(SALOME_InteractiveObject) IObject = It.Value();
-           Standard_Boolean testResult;
-           myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
-           if( testResult )
-             mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, myHypothesis) ;
+  QString myNameSubMesh = LineEdit_NameMesh->text().stripWhiteSpace();
+  if ( myNameSubMesh.isEmpty() ) {
+    QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) );
+    return false;
+  }
+  
+  if ( myMesh->_is_nil() || myGeomShape->_is_nil() || ( !HypoList.count() && !AlgoList.count() ) )
+    return false;
+
+  SALOMEDS::SObject_var aMeshSO = mySMESHGUI->GetStudyAPI().FindObject( myMesh );
+  GEOM::GEOM_Shape_var myMainShape = mySMESHGUI->GetStudyAPI().GetShapeOnMeshOrSubMesh( aMeshSO );
+  if ( myMainShape->_is_nil() )
+    return false;
+
+  QAD_WaitCursor wc;
+
+  QAD_Operation* op = new QAD_Operation( mySMESHGUI->GetActiveStudy() );
+
+  // start transaction
+  op->start();
+  
+  // create submesh
+  SMESH::SMESH_subMesh_var aSubMesh = mySMESHGUI->AddSubMesh( myMesh, myGeomShape, myNameSubMesh ) ;
+  
+  if ( !aSubMesh->_is_nil() ) {
+    // assign hypotheses
+    for( int i = 0; i < HypoList.count(); i++ ) {
+      SALOMEDS::SObject_var aHypSO = mySMESHGUI->GetStudy()->FindObjectID( HypoList[i] );
+      if ( !aHypSO->_is_nil() ) {
+       CORBA::Object_var anObject = aHypSO->GetObject();
+       if ( !CORBA::is_nil( anObject ) ) {
+         SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+         if ( !aHyp->_is_nil() )
+           if ( !mySMESHGUI->AddHypothesisOnSubMesh( aSubMesh, aHyp ) ) {
+             // abort transaction
+             op->abort();
+             return false;
          }
        }
-
-       if( myOkAlgorithm && !mySubMesh->_is_nil() ) {
-         SALOME_ListIteratorOfListIO It( AlgoList );
-         for(;It.More();It.Next()) {
-           Handle(SALOME_InteractiveObject) IObject = It.Value();
-           Standard_Boolean testResult;
-           myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
-           if( testResult )
-             mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, myAlgorithm) ;
+      }
+    }
+    // assign algorithms
+    for( int i = 0; i < AlgoList.count(); i++ ) {
+      SALOMEDS::SObject_var aHypSO = mySMESHGUI->GetStudy()->FindObjectID( AlgoList[i] );
+      if ( !aHypSO->_is_nil() ) {
+       CORBA::Object_var anObject = aHypSO->GetObject();
+       if ( !CORBA::is_nil( anObject ) ) {
+         SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+         if ( !aHyp->_is_nil() )
+           if ( !mySMESHGUI->AddAlgorithmOnSubMesh( aSubMesh, aHyp ) ) {
+             // abort transaction
+             op->abort();
+             return false;
          }
        }
-       
-       break ;
       }
     }
+  }
+  // commit transaction
+  op->finish();
+  return true;
 }
 
 
@@ -335,13 +288,20 @@ void SMESHGUI_AddSubMeshDlg::ClickOnApply()
 //=================================================================================
 void SMESHGUI_AddSubMeshDlg::ClickOnCancel()
 {
-  disconnect( mySelection, 0, this, 0 );
-  mySMESHGUI->ResetState() ;
-  mySelection->ClearFilters() ;
-  reject() ;
-  return ;
+  close();
 }
 
+static bool IsFatherOf( SALOMEDS::SObject_ptr SO, SALOMEDS::SObject_ptr fatherSO ) {
+  if ( !SO->_is_nil() && !fatherSO->_is_nil() ) {
+    SALOMEDS::SObject_var aSO = SO->GetFather();
+    while( strlen( aSO->GetID() ) >= strlen( fatherSO->GetID() ) ) {
+      if ( QString( aSO->GetID() ) == QString( fatherSO->GetID() ) )
+       return true;
+      aSO = aSO->GetFather();
+    }
+  }
+  return false;
+}
 
 //=================================================================================
 // function : SelectionIntoArgument()
@@ -349,81 +309,88 @@ void SMESHGUI_AddSubMeshDlg::ClickOnCancel()
 //=================================================================================
 void SMESHGUI_AddSubMeshDlg::SelectionIntoArgument()
 {
-  myEditCurrentArgument->setText("") ;
+  SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
   QString aString = ""; 
 
   int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
 
-  switch (myConstructorId) 
-    {
-    case 0:
-      {
-       if ( myEditCurrentArgument == LineEditC1A1 ) {
-         if ( nbSel != 1 ) {
-           myOkHypothesis = false;
-           myOkAlgorithm = false;
-           return ;
-         } else {
-           Standard_Boolean testResult ;
-           Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
-           myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ;
-           if( !testResult ) {
-             myMesh = SMESH::SMESH_Mesh::_nil();
-             return ;
-           }
-         }
-       } else if ( myEditCurrentArgument == LineEditC1A2 ) {
-         if ( nbSel != 1 ) {
-           myOkHypothesis = false;
-           myOkAlgorithm = false;
-           return ;
-         } else {
-           Standard_Boolean testResult ;
-           Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
-           myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
-           if( !testResult ) {
-             myGeomShape = GEOM::GEOM_Shape::_nil();
-             return ;
-           }
-         }
-       } else if ( myEditCurrentArgument == LineEditC1A1Hyp ) {
-         if ( nbSel >= 1 ) {
-           HypoList.Clear();
-           SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
-           for (; Itinit.More(); Itinit.Next()) {
-             HypoList.Append(Itinit.Value());
-           }
-           myOkHypothesis = true ;
-           if (nbSel > 1)
-             aString = tr("%1 Hypothesis").arg(nbSel) ;
-           LineEditC1A1Hyp->setText(aString) ;
-         }
-         else {
-           myOkHypothesis = false ;
-           return ;
-         }
-       } else if ( myEditCurrentArgument == LineEditC1A1Algo ) {
-         if ( nbSel >= 1 ) {
-           AlgoList.Clear(); 
-           SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
-           for (; Itinit.More(); Itinit.Next()) {
-             AlgoList.Append(Itinit.Value());
-           }
-           myOkAlgorithm = true ;
-           if (nbSel > 1)
-             aString = tr("%1 Algorithms").arg(nbSel) ;
-           LineEditC1A1Algo->setText(aString) ;
-         }
-         else {
-           myOkAlgorithm = false ;
-           return ;
-         }
-       }
-       break;
+  if ( myEditCurrentArgument == LineEditC1A1 ) {
+    // mesh
+    if ( nbSel != 1 ) {
+      myMesh = SMESH::SMESH_Mesh::_nil();
+      aString = "";
+    } 
+    else {
+      Standard_Boolean testResult ;
+      Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+      myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ;
+      if( !testResult ) {
+       myMesh = SMESH::SMESH_Mesh::_nil();
+       aString = "";
+      }
+    }
+    myGeomShape = GEOM::GEOM_Shape::_nil();
+    LineEditC1A2->setText( "" );
+  }
+  else if ( myEditCurrentArgument == LineEditC1A2 ) {
+    // geom shape
+    if ( nbSel != 1 ) {
+      myGeomShape = GEOM::GEOM_Shape::_nil();
+      aString = "";
+    } 
+    else {
+      Standard_Boolean testResult ;
+      Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+      myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
+      if( !testResult ) {
+       myGeomShape = GEOM::GEOM_Shape::_nil();
+       aString = "";
       }
+      if ( !myMesh->_is_nil() ) {
+       SALOMEDS::SObject_var aMeshSO = myStudyAPI.FindObject( myMesh );
+       GEOM::GEOM_Shape_var aMainGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh( aMeshSO );
+       SALOMEDS::SObject_var aMainGeomShapeSO = myStudyAPI.FindObject( aMainGeomShape );
+       if ( aMainGeomShapeSO->_is_nil() || !IsFatherOf(  mySMESHGUI->GetStudy()->FindObjectID( IO->getEntry() ), aMainGeomShapeSO ) ) {
+         myGeomShape = GEOM::GEOM_Shape::_nil();
+         aString = "";
+       }         
+      }
+    }
+  } 
+  else if ( myEditCurrentArgument == LineEditC1A1Hyp ) {
+    // hypotheses
+    HypoList.clear();
+    if ( nbSel >= 1 ) {
+      SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
+      for ( ; Itinit.More(); Itinit.Next() ) {
+       HypoList.append( Itinit.Value()->getEntry() );
+      }
+      if ( nbSel > 1 )
+       aString = tr( "%1 Hypothesis" ).arg( nbSel ) ;
+    }
+    else {
+      aString = "";
     }
+  }
+  else if ( myEditCurrentArgument == LineEditC1A1Algo ) {
+    // algorithms
+    AlgoList.clear(); 
+    if ( nbSel >= 1 ) {
+      SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
+      for ( ; Itinit.More(); Itinit.Next() ) {
+       AlgoList.append( Itinit.Value()->getEntry() );
+      }
+      if ( nbSel > 1 )
+       aString = tr( "%1 Algorithms" ).arg( nbSel ) ;
+    }
+    else {
+      aString = "";
+    }
+  }
   
   myEditCurrentArgument->setText(aString) ;
+
+  UpdateControlState();
 }
 
 
@@ -434,36 +401,28 @@ void SMESHGUI_AddSubMeshDlg::SelectionIntoArgument()
 void SMESHGUI_AddSubMeshDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
-  switch (myConstructorId)
-    {
-    case 0: /* default constructor */
-      {        
-       if(send == SelectButtonC1A1) {
-         LineEditC1A1->setFocus() ;
-         myEditCurrentArgument = LineEditC1A1;
-         mySelection->ClearFilters() ;   
-         mySelection->AddFilter(myMeshFilter) ;
-       } else if (send == SelectButtonC1A2) {
-         LineEditC1A2->setFocus() ;
-         myEditCurrentArgument = LineEditC1A2;
-         mySelection->ClearFilters() ;
-         mySelection->AddFilter(myGeomFilter) ;
-       } else if( send == SelectButtonC1A1Hyp ) {
-         LineEditC1A1Hyp->setFocus() ;
-         myEditCurrentArgument = LineEditC1A1Hyp ;
-         mySelection->ClearFilters() ;   
-         mySelection->AddFilter(myHypothesisFilter) ;
-       } else if( send == SelectButtonC1A1Algo ) {
-         LineEditC1A1Algo->setFocus() ;
-         myEditCurrentArgument = LineEditC1A1Algo ;
-         mySelection->ClearFilters() ;   
-         mySelection->AddFilter(myAlgorithmFilter) ;
-       }
-       SelectionIntoArgument() ;
-       break;
-      }
-    }
-  return ;
+  if(send == SelectButtonC1A1) {
+    LineEditC1A1->setFocus() ;
+    myEditCurrentArgument = LineEditC1A1;
+    mySelection->ClearFilters() ;        
+    mySelection->AddFilter(myMeshFilter) ;
+  } else if (send == SelectButtonC1A2) {
+    LineEditC1A2->setFocus() ;
+    myEditCurrentArgument = LineEditC1A2;
+    mySelection->ClearFilters() ;
+    mySelection->AddFilter(myGeomFilter) ;
+  } else if( send == SelectButtonC1A1Hyp ) {
+    LineEditC1A1Hyp->setFocus() ;
+    myEditCurrentArgument = LineEditC1A1Hyp ;
+    mySelection->ClearFilters() ;        
+    mySelection->AddFilter(myHypothesisFilter) ;
+  } else if( send == SelectButtonC1A1Algo ) {
+    LineEditC1A1Algo->setFocus() ;
+    myEditCurrentArgument = LineEditC1A1Algo ;
+    mySelection->ClearFilters() ;        
+    mySelection->AddFilter(myAlgorithmFilter) ;
+  }
+  SelectionIntoArgument() ;
 }
 
 //=================================================================================
@@ -472,9 +431,8 @@ void SMESHGUI_AddSubMeshDlg::SetEditCurrentArgument()
 //=================================================================================
 void SMESHGUI_AddSubMeshDlg::DeactivateActiveDialog()
 {
-  if ( GroupConstructors->isEnabled() ) {
+  if ( GroupC1->isEnabled() ) {
     disconnect( mySelection, 0, this, 0 );
-    GroupConstructors->setEnabled(false) ;
     GroupC1->setEnabled(false) ;
     GroupButtons->setEnabled(false) ;
   }
@@ -488,11 +446,9 @@ void SMESHGUI_AddSubMeshDlg::DeactivateActiveDialog()
 void SMESHGUI_AddSubMeshDlg::ActivateThisDialog()
 {
   mySMESHGUI->EmitSignalDeactivateDialog() ;   
-  GroupConstructors->setEnabled(true) ;
   GroupC1->setEnabled(true) ;
   GroupButtons->setEnabled(true) ;
   connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-  return ;
 }
 
 
@@ -502,10 +458,8 @@ void SMESHGUI_AddSubMeshDlg::ActivateThisDialog()
 //=================================================================================
 void SMESHGUI_AddSubMeshDlg::enterEvent(QEvent* e)
 {
-  if ( GroupConstructors->isEnabled() )
-    return ;  
-  ActivateThisDialog() ;
-  return ;
+  if ( !GroupC1->isEnabled() )
+    ActivateThisDialog() ;
 }
 
 
@@ -515,21 +469,31 @@ void SMESHGUI_AddSubMeshDlg::enterEvent(QEvent* e)
 //=================================================================================
 void SMESHGUI_AddSubMeshDlg::closeEvent( QCloseEvent* e )
 {
-  this->ClickOnCancel() ;
-  return ;
+  disconnect( mySelection, 0, this, 0 );
+  mySMESHGUI->ResetState() ;
+  mySelection->ClearFilters() ;
+  QDialog::closeEvent( e );
 }
 
 //=================================================================================
-// function : TextChangedInLineEdit()
+// function : UpdateControlState()
 // purpose  :
 //=================================================================================
-void SMESHGUI_AddSubMeshDlg::TextChangedInLineEdit(const QString& newText)
-{  
-  QLineEdit* send = (QLineEdit*)sender();
-  QString newT = strdup(newText) ;
-  
-  if (send == LineEdit_NameMesh) {
-    myNameSubMesh = newText;
+void SMESHGUI_AddSubMeshDlg::UpdateControlState()
+{
+  bool isEnabled = ( !myMesh->_is_nil() && !myGeomShape->_is_nil() && ( HypoList.count() || AlgoList.count() ) );
+  bool isImportedMesh = false;
+  if ( !myMesh->_is_nil() ) {
+    SALOMEDS::SObject_var aMeshSO = mySMESHGUI->GetStudyAPI().FindObject( myMesh );
+    GEOM::GEOM_Shape_var myGeomShape = mySMESHGUI->GetStudyAPI().GetShapeOnMeshOrSubMesh( aMeshSO );
+    isImportedMesh = myGeomShape->_is_nil();
   }
-  return ;
+
+  buttonOk   ->setEnabled( isEnabled && !isImportedMesh );
+  buttonApply->setEnabled( isEnabled && !isImportedMesh );
 }
+
+
+
+
+
index 4d26275e03956424c8717559f5ee47235110de73..a9e8d3efa7e65b9fca09432cfddde0bcb076901b 100644 (file)
@@ -34,8 +34,8 @@
 #include "SMESH_TypeFilter.hxx"
 
 // QT Includes
-#include <qvariant.h>
 #include <qdialog.h>
+#include <qstringlist.h>
 
 // IDL Headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(GEOM_Shape)
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
 
-class QVBoxLayout; 
-class QHBoxLayout; 
-class QGridLayout; 
-class QButtonGroup;
 class QGroupBox;
 class QLabel;
 class QLineEdit;
 class QPushButton;
-class QRadioButton;
 class SMESHGUI;
 
-
 //=================================================================================
 // class    : SMESHGUI_AddSubMeshDlg
 // purpose  :
@@ -67,44 +61,36 @@ public:
     SMESHGUI_AddSubMeshDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
     ~SMESHGUI_AddSubMeshDlg();
 
-private:
-
-    void Init( SALOME_Selection* Sel ) ;
+protected:
     void closeEvent( QCloseEvent* e ) ;
     void enterEvent ( QEvent * ) ;
 
+private:
+    void Init( SALOME_Selection* Sel ) ;
+
+    void UpdateControlState();
+
+private:
     SMESHGUI*                     mySMESHGUI ;
     SALOME_Selection*             mySelection ;
              
-    GEOM::GEOM_Shape_var                myGeomShape ;
-    int                           myConstructorId ; 
-    QLineEdit*                    myEditCurrentArgument; 
-
     SMESH::SMESH_Mesh_var         myMesh;
-    SMESH::SMESH_subMesh_var      mySubMesh;
-
-    QString                       myNameSubMesh ;
+    GEOM::GEOM_Shape_var          myGeomShape ;
+    QLineEdit*                    myEditCurrentArgument; 
 
     Handle(SALOME_TypeFilter)     myGeomFilter;
     Handle(SMESH_TypeFilter)      myMeshFilter;
     Handle(SMESH_TypeFilter)      myHypothesisFilter;
     Handle(SMESH_TypeFilter)      myAlgorithmFilter;
 
-    SALOME_ListIO                 HypoList;
-    SALOME_ListIO                 AlgoList;
+    QStringList                   HypoList;
+    QStringList                   AlgoList;
 
-    bool                          myOkHypothesis;
-    bool                          myOkAlgorithm;
-
-    SMESH::SMESH_Hypothesis_var   myHypothesis;
-    SMESH::SMESH_Hypothesis_var   myAlgorithm;
-
-    QButtonGroup* GroupConstructors;
-    QRadioButton* Constructor1;
     QGroupBox*    GroupButtons;
     QPushButton*  buttonOk;
-    QPushButton*  buttonCancel;
     QPushButton*  buttonApply;
+    QPushButton*  buttonCancel;
+
     QGroupBox*    GroupC1;
     QLabel*       TextLabel_NameMesh ;
     QLineEdit*    LineEdit_NameMesh ;
@@ -124,22 +110,13 @@ private:
     QLineEdit*    LineEditC1A1Algo;
 
 private slots:
-
-    void ConstructorsClicked(int constructorId);
     void ClickOnOk();
+    bool ClickOnApply();
     void ClickOnCancel();
-    void ClickOnApply();
     void SetEditCurrentArgument() ;
     void SelectionIntoArgument() ;
     void DeactivateActiveDialog() ;
     void ActivateThisDialog() ;
-    void TextChangedInLineEdit(const QString& newText) ;
-
-protected:
-    QGridLayout* SMESHGUI_AddSubMeshDlgLayout;
-    QGridLayout* GroupConstructorsLayout;
-    QGridLayout* GroupButtonsLayout;
-    QGridLayout* GroupC1Layout;
 };
 
 #endif // DIALOGBOX_ADD_SUBMESH_H
index 0ef1e42b0ef8f429d9a0f2a0fd1184bc3892d9ab..8953903d55e1ea7b2edad1a3dea7f632315f7fef 100644 (file)
@@ -270,7 +270,7 @@ void SMESHGUI_AddVolumeDlg::ClickOnOk()
 //=================================================================================
 void SMESHGUI_AddVolumeDlg::ClickOnCancel()
 {
-  QAD_Application::getDesktop()->SetSelectionMode( 4 );
+  QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
   disconnect( mySelection, 0, this, 0 );
   mySMESHGUI->ResetState() ;
   mySMESHGUI->EraseSimulationActors();
@@ -297,9 +297,9 @@ void SMESHGUI_AddVolumeDlg::SelectionIntoArgument()
   if(nbNodes < 1)
     return ;
   
-  if ( mySelection->SelectionMode() != 1 ) {
+  if ( mySelection->SelectionMode() != NodeSelection ) {
     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
-                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
+                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") );
     return;
   }
 
index ad086e43e8a17d7b2a730526685c5199e1dcac08..bc76e32fb5f897fc253c0a6a0f01116f09c34761 100644 (file)
@@ -247,7 +247,7 @@ void SMESHGUI_DiagonalInversionDlg::ClickOnOk()
 //=================================================================================
 void SMESHGUI_DiagonalInversionDlg::ClickOnCancel()
 {
-  QAD_Application::getDesktop()->SetSelectionMode( 4 );
+  QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
   disconnect( mySelection, 0, this, 0 );
   mySMESHGUI->ResetState() ;
   reject() ;
@@ -265,7 +265,7 @@ void SMESHGUI_DiagonalInversionDlg::SelectionIntoArgument()
   myOkElements = false;
   QString aString = "";
 
-  if ( mySelection->SelectionMode() != 2 ) {
+  if ( mySelection->SelectionMode() != EdgeSelection ) {
     return;
   }
 
index 13f8197c47ea6170393765bd1b8c53e3855c5c99..7f8c9925087d53f5a69683d638611a264ab77563 100644 (file)
@@ -33,20 +33,17 @@ using namespace std;
 
 #include "QAD_Application.h"
 #include "QAD_Desktop.h"
+#include "QAD_WaitCursor.h"
+#include "QAD_Operation.h"
+
 #include "utilities.h"
 
 // QT Includes
-#include <qbuttongroup.h>
 #include <qgroupbox.h>
 #include <qlabel.h>
 #include <qlineedit.h>
 #include <qpushbutton.h>
-#include <qradiobutton.h>
 #include <qlayout.h>
-#include <qvariant.h>
-#include <qtooltip.h>
-#include <qwhatsthis.h>
-#include <qimage.h>
 #include <qpixmap.h>
 
 //VRV: porting on Qt 3.0.5
@@ -55,6 +52,38 @@ using namespace std;
 #endif
 //VRV: porting on Qt 3.0.5
 
+class ListBoxIOR : public QListBoxText
+{
+public:
+  enum { RTTI_IOR = 1000 };
+
+public:
+  ListBoxIOR( QListBox* listbox, 
+              const char* ior,
+              const QString& text = QString::null)
+  : QListBoxText( listbox, text ), myIOR( ior ) {}
+  virtual ~ListBoxIOR() {};
+  virtual int rtti() const { return RTTI_IOR; }
+  const char* GetIOR() { return myIOR.c_str(); }
+
+private:
+  string myIOR;
+};
+
+#define ALLOW_CHANGE_SHAPE 0
+
+int findItem( QListBox* listBox, const string& ior )
+{
+  for ( int i = 0; i < listBox->count(); i++ ) {
+    if ( listBox->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) {
+      ListBoxIOR* anItem = ( ListBoxIOR* )( listBox->item( i ) );
+      if ( anItem && ior == string( anItem->GetIOR() ) )
+       return i;
+    }
+  }
+  return -1;
+}
+
 //=================================================================================
 // class    : SMESHGUI_EditHypothesesDlg()
 // purpose  : Constructs a SMESHGUI_EditHypothesesDlg which is a child of 'parent', with the 
@@ -63,238 +92,131 @@ using namespace std;
 //            TRUE to construct a modal dialog.
 //=================================================================================
 SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
-    : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+  : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
+    myImportedMesh( false )
 {
-    QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDIT_MESH")));
     QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
     if ( !name )
-       setName( "SMESHGUI_EditHypothesesDlg" );
-    resize( 417, 573 ); 
+        setName( "SMESHGUI_EditHypothesesDlg" );
     setCaption( tr( "SMESH_EDIT_HYPOTHESES"  ) );
     setSizeGripEnabled( TRUE );
-    SMESHGUI_EditHypothesesDlgLayout = new QGridLayout( this ); 
+    QGridLayout* SMESHGUI_EditHypothesesDlgLayout = new QGridLayout( this ); 
     SMESHGUI_EditHypothesesDlgLayout->setSpacing( 6 );
     SMESHGUI_EditHypothesesDlgLayout->setMargin( 11 );
 
     /***************************************************************/
-    GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
-    GroupConstructors->setTitle( tr( "SMESH_HYPOTHESES"  ) );
-    GroupConstructors->setExclusive( TRUE );
-    GroupConstructors->setColumnLayout(0, Qt::Vertical );
-    GroupConstructors->layout()->setSpacing( 0 );
-    GroupConstructors->layout()->setMargin( 0 );
-    GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
-    GroupConstructorsLayout->setAlignment( Qt::AlignTop );
-    GroupConstructorsLayout->setSpacing( 6 );
-    GroupConstructorsLayout->setMargin( 11 );
-    Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
-    Constructor1->setText( tr( ""  ) );
-    Constructor1->setPixmap( image1 );
-    Constructor1->setChecked( TRUE );
-    Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
-    Constructor1->setMinimumSize( QSize( 50, 0 ) );
-    GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
-    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
-    GroupConstructorsLayout->addItem( spacer, 0, 1 );
-    SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupConstructors, 0, 0 );
-    
-    /***************************************************************/
-    GroupButtons = new QGroupBox( this, "GroupButtons" );
-    GroupButtons->setGeometry( QRect( 10, 10, 281, 96 ) ); 
-    GroupButtons->setTitle( tr( ""  ) );
-    GroupButtons->setColumnLayout(0, Qt::Vertical );
-    GroupButtons->layout()->setSpacing( 0 );
-    GroupButtons->layout()->setMargin( 0 );
-    GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
-    GroupButtonsLayout->setAlignment( Qt::AlignTop );
-    GroupButtonsLayout->setSpacing( 6 );
-    GroupButtonsLayout->setMargin( 11 );
-    buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
-    buttonCancel->setText( tr( "SMESH_BUT_CLOSE"  ) );
-    buttonCancel->setAutoDefault( TRUE );
-    buttonCancel->setDefault( TRUE );
-    buttonCancel->setEnabled( TRUE ) ;
-    
-    GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
-    buttonApply = new QPushButton( GroupButtons, "buttonApply" );
-    buttonApply->setText( tr( "SMESH_BUT_APPLY"  ) );
-    buttonApply->setAutoDefault( TRUE );
-    buttonApply->setDefault( FALSE );
-    buttonApply->setEnabled( FALSE ) ;
-    
-    GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
-    QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
-    GroupButtonsLayout->addItem( spacer_9, 0, 2 );
-    buttonOk = new QPushButton( GroupButtons, "buttonOk" );
-    buttonOk->setText( tr( "SMESH_BUT_OK"  ) );
-    
-    buttonOk->setAutoDefault( TRUE );
-    buttonOk->setDefault( FALSE );
-    buttonOk->setEnabled( FALSE ) ;
-    
-    GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
-    SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupButtons, 5, 0 );
-
-    /***************************************************************/
-    GroupC1 = new QGroupBox( this, "GroupC1" );
-    GroupC1->setTitle( tr( "SMESH_ARGUMENTS"  ) );
-    GroupC1->setMinimumSize( QSize( 0, 0 ) );
-    GroupC1->setFrameShape( QGroupBox::Box );
-    GroupC1->setFrameShadow( QGroupBox::Sunken );
+    GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), this, "GroupC1" );
     GroupC1->setColumnLayout(0, Qt::Vertical );
     GroupC1->layout()->setSpacing( 0 );
     GroupC1->layout()->setMargin( 0 );
-    GroupC1Layout = new QGridLayout( GroupC1->layout() );
+    QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
     GroupC1Layout->setAlignment( Qt::AlignTop );
     GroupC1Layout->setSpacing( 6 );
     GroupC1Layout->setMargin( 11 );
 
-    TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
-    TextLabelC1A1->setText( tr( "SMESH_OBJECT_MESHorSUBMESH"  ) );
-    TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
-    TextLabelC1A1->setFrameShape( QLabel::NoFrame );
-    TextLabelC1A1->setFrameShadow( QLabel::Plain );
+    TextLabelC1A1 = new QLabel( tr( "SMESH_OBJECT_MESHorSUBMESH" ), GroupC1, "TextLabelC1A1" );
     GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
     SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
-    SelectButtonC1A1->setText( tr( ""  ) );
     SelectButtonC1A1->setPixmap( image0 );
-    SelectButtonC1A1->setToggleButton( FALSE );
     GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
     LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
     GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
 
-    TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
-    TextLabelC1A2->setText( tr( "SMESH_OBJECT_GEOM"  ) );
-    TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
-    TextLabelC1A2->setFrameShape( QLabel::NoFrame );
-    TextLabelC1A2->setFrameShadow( QLabel::Plain );
+    TextLabelC1A2 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A2" );
     GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
     SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
-    SelectButtonC1A2->setText( tr( ""  ) );
     SelectButtonC1A2->setPixmap( image0 );
     SelectButtonC1A2->setToggleButton( FALSE );
     GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
     LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
     GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
 
-    GroupHypotheses = new QGroupBox( this, "GroupHypotheses" );
-    GroupHypotheses->setTitle( tr( "SMESH_HYPOTHESES"  ) );
+    SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupC1, 0, 0 );
+
+    /***************************************************************/
+    GroupHypotheses = new QGroupBox( tr( "SMESH_HYPOTHESES" ), this, "GroupHypotheses" );
     GroupHypotheses->setColumnLayout(0, Qt::Vertical );
     GroupHypotheses->layout()->setSpacing( 0 );
     GroupHypotheses->layout()->setMargin( 0 );
-    grid_3 = new QGridLayout( GroupHypotheses->layout() );
-    grid_3->setGeometry( QRect( 12, 18, 139, 110 ) ); 
+    QGridLayout* grid_3 = new QGridLayout( GroupHypotheses->layout() );
     grid_3->setAlignment( Qt::AlignTop );
     grid_3->setSpacing( 6 );
     grid_3->setMargin( 11 );
 
-    hbox_2 = new QHBoxLayout; 
-    hbox_2->setSpacing( 6 );
-    hbox_2->setMargin( 0 );
-
-    vbox = new QVBoxLayout; 
-    vbox->setSpacing( 6 );
-    vbox->setMargin( 0 );
-
-    TextHypDefinition = new QLabel( GroupHypotheses, "TextHypDefinition" );
-    TextHypDefinition->setText( tr( "SMESH_AVAILABLE"  ) );
-    vbox->addWidget( TextHypDefinition );
+    TextHypDefinition = new QLabel( tr( "SMESH_AVAILABLE" ), GroupHypotheses, "TextHypDefinition" );
+    grid_3->addWidget( TextHypDefinition, 0, 0 );
 
     ListHypDefinition = new QListBox( GroupHypotheses, "ListHypDefinition" );
-    ListHypDefinition->setMinimumSize( 100, 50);
-//      ListHypDefinition->setRowMode(4);
-//      ListHypDefinition->setRowMode( QListBox::FixedNumber );
-//    ListHypDefinition->setLineWidth( 4 );
-//      ListHypDefinition->setColumnMode( QListBox::Variable );
-//      ListHypDefinition->setVariableHeight( FALSE );
-//      ListHypDefinition->insertItem( tr( "New Item" ) );
-    vbox->addWidget( ListHypDefinition );
-    hbox_2->addLayout( vbox );
-
-    vbox_2 = new QVBoxLayout; 
-    vbox_2->setSpacing( 6 );
-    vbox_2->setMargin( 0 );
-
-    TextHypAssignation = new QLabel( GroupHypotheses, "TextHypAssignation" );
-    TextHypAssignation->setText( tr( "SMESH_EDIT_USED"  ) );
-    vbox_2->addWidget( TextHypAssignation );
+    ListHypDefinition->setMinimumSize( 100, 100 );
+    grid_3->addWidget( ListHypDefinition, 1, 0 );
+
+    TextHypAssignation = new QLabel( tr( "SMESH_EDIT_USED" ), GroupHypotheses, "TextHypAssignation" );
+    grid_3->addWidget( TextHypAssignation, 0, 1 );
 
     ListHypAssignation = new QListBox( GroupHypotheses, "ListHypAssignation" );
-    ListHypAssignation->setMinimumSize( 100, 50);
-//      ListHypAssignation->setRowMode(4); 
-//      ListHypAssignation->setRowMode( QListBox::FixedNumber );
-//    ListHypAssignation->setLineWidth( 4 );
-//      ListHypAssignation->setColumnMode( QListBox::Variable );
-//      ListHypAssignation->setVariableHeight( FALSE );
-//      ListHypAssignation->insertItem( tr( "New Item" ) );
-    vbox_2->addWidget( ListHypAssignation );
-    hbox_2->addLayout( vbox_2 );
-
-    grid_3->addLayout( hbox_2, 0, 0 );
-
-    SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupHypotheses, 2, 0 );
-
-    GroupAlgorithms = new QGroupBox( this, "GroupAlgorithms" );
-    GroupAlgorithms->setTitle( tr( "SMESH_ADD_ALGORITHM"  ) );
+    ListHypAssignation->setMinimumSize( 100, 100 );
+    grid_3->addWidget( ListHypAssignation, 1, 1 );
+
+    SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupHypotheses, 1, 0 );
+
+    /***************************************************************/
+    GroupAlgorithms = new QGroupBox( tr( "SMESH_ADD_ALGORITHM" ), this, "GroupAlgorithms" );
     GroupAlgorithms->setColumnLayout(0, Qt::Vertical );
     GroupAlgorithms->layout()->setSpacing( 0 );
     GroupAlgorithms->layout()->setMargin( 0 );
-    grid_4 = new QGridLayout( GroupAlgorithms->layout() );
-    grid_4->setGeometry( QRect( 12, 18, 139, 110 ) ); 
+    QGridLayout* grid_4 = new QGridLayout( GroupAlgorithms->layout() );
     grid_4->setAlignment( Qt::AlignTop );
     grid_4->setSpacing( 6 );
     grid_4->setMargin( 11 );
 
-    hbox_3 = new QHBoxLayout; 
-    hbox_3->setSpacing( 6 );
-    hbox_3->setMargin( 0 );
-
-    vbox_3 = new QVBoxLayout; 
-    vbox_3->setSpacing( 6 );
-    vbox_3->setMargin( 0 );
-
-    TextAlgoDefinition = new QLabel( GroupAlgorithms, "TextAlgoDefinition" );
-    TextAlgoDefinition->setText( tr( "SMESH_AVAILABLE"  ) );
-    vbox_3->addWidget( TextAlgoDefinition );
+    TextAlgoDefinition = new QLabel( tr( "SMESH_AVAILABLE" ), GroupAlgorithms, "TextAlgoDefinition" );
+    grid_4->addWidget( TextAlgoDefinition, 0, 0 );
 
     ListAlgoDefinition = new QListBox( GroupAlgorithms, "ListAlgoDefinition" );
-    ListAlgoDefinition->setMinimumSize( 100, 50);
-//      ListAlgoDefinition->setRowMode(4);
-//      ListAlgoDefinition->setRowMode( QListBox::FixedNumber );
-//    ListAlgoDefinition->setLineWidth( 4 );
-//      ListAlgoDefinition->setColumnMode( QListBox::Variable );
-//      ListAlgoDefinition->setVariableHeight( FALSE );
-//      ListAlgoDefinition->insertItem( tr( "New Item" ) );
-    vbox_3->addWidget( ListAlgoDefinition );
-    hbox_3->addLayout( vbox_3 );
-
-    vbox_4 = new QVBoxLayout; 
-    vbox_4->setSpacing( 6 );
-    vbox_4->setMargin( 0 );
-
-    TextAlgoAssignation = new QLabel( GroupAlgorithms, "TextAlgoAssignation" );
-    TextAlgoAssignation->setText( tr( "SMESH_EDIT_USED"  ) );
-    vbox_4->addWidget( TextAlgoAssignation );
+    ListAlgoDefinition->setMinimumSize( 100, 100 );
+    grid_4->addWidget( ListAlgoDefinition, 1, 0 );
+
+    TextAlgoAssignation = new QLabel( tr( "SMESH_EDIT_USED" ), GroupAlgorithms, "TextAlgoAssignation" );
+    grid_4->addWidget( TextAlgoAssignation, 0, 1 );
 
     ListAlgoAssignation = new QListBox( GroupAlgorithms, "ListAlgoAssignation" );
-    ListAlgoAssignation ->setMinimumSize( 100, 50);
-//      ListAlgoAssignation->setRowMode(4);
-//      ListAlgoAssignation->setRowMode( QListBox::FixedNumber );
-//    ListAlgoAssignation->setLineWidth( 4 );
-//      ListAlgoAssignation->setColumnMode( QListBox::Variable );
-//      ListAlgoAssignation->setVariableHeight( FALSE );
-//      ListAlgoAssignation->insertItem( tr( "New Item" ) );
-    vbox_4->addWidget( ListAlgoAssignation );
-    hbox_3->addLayout( vbox_4 );
-
-    grid_4->addLayout( hbox_3, 0, 0 );
-    SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupAlgorithms, 3, 0 );
-
-    SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupC1, 1, 0 );
+    ListAlgoAssignation ->setMinimumSize( 100, 100 );
+    grid_4->addWidget( ListAlgoAssignation, 1, 1 );
+
+    SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupAlgorithms, 2, 0 );
+
     /***************************************************************/
+    GroupButtons = new QGroupBox( this, "GroupButtons" );
+    GroupButtons->setColumnLayout(0, Qt::Vertical );
+    GroupButtons->layout()->setSpacing( 0 );
+    GroupButtons->layout()->setMargin( 0 );
+    QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+    GroupButtonsLayout->setAlignment( Qt::AlignTop );
+    GroupButtonsLayout->setSpacing( 6 );
+    GroupButtonsLayout->setMargin( 11 );
 
-    Init(Sel) ;
+    buttonOk = new QPushButton( tr( "SMESH_BUT_OK" ), GroupButtons, "buttonOk" );
+    buttonOk->setAutoDefault( TRUE );
+    buttonOk->setDefault( FALSE );
+    GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+
+    buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons, "buttonApply" );
+    buttonApply->setAutoDefault( TRUE );
+    buttonApply->setDefault( FALSE );
+    GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
+
+    GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 );
+
+    buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons, "buttonCancel" );
+    buttonCancel->setAutoDefault( TRUE );
+    buttonCancel->setDefault( TRUE );
+    buttonCancel->setEnabled( TRUE ) ;
+    GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
+
+    SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupButtons, 4, 0 );
 
+    /***************************************************************/
+    Init(Sel) ;
 }
 
 
@@ -314,10 +236,6 @@ SMESHGUI_EditHypothesesDlg::~SMESHGUI_EditHypothesesDlg()
 //=================================================================================
 void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel )
 {
-  GroupC1->show();
-  myConstructorId = 0 ;
-  Constructor1->setChecked( TRUE );
-  myEditCurrentArgument = LineEditC1A1 ;       
   mySelection = Sel;
   mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
   mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
@@ -325,9 +243,6 @@ void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel )
   InitHypDefinition();
   InitAlgoDefinition();
 
-  InitHypAssignation();
-  InitAlgoAssignation();
-
   myGeomFilter = new SALOME_TypeFilter( "GEOM" );
   myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
 
@@ -336,52 +251,87 @@ void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel )
   mySubMesh = SMESH::SMESH_subMesh::_nil();
 
   /* signals and slots connections */
-  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
-  connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
+  connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+  connect( buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
 
-  connect( SelectButtonC1A1, SIGNAL (clicked() ),   this, SLOT( SetEditCurrentArgument() ) ) ;
-  connect( SelectButtonC1A2, SIGNAL (clicked() ),   this, SLOT( SetEditCurrentArgument() ) ) ;
+  connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+  connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
 
-  connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
-  connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
-  connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
+  connect( mySelection, SIGNAL( currentSelectionChanged() ),      this, SLOT( SelectionIntoArgument() ) );
+  connect( mySMESHGUI,  SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
+  connect( mySMESHGUI,  SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) ) ;
  
-  connect( ListHypAssignation, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) );
-  connect( ListAlgoAssignation, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) );
+  connect( ListHypAssignation,  SIGNAL( doubleClicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) );
+  connect( ListAlgoAssignation, SIGNAL( doubleClicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) );
  
-  connect( ListHypDefinition, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) );
-  connect( ListAlgoDefinition, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) );
+  connect( ListHypDefinition,  SIGNAL( doubleClicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) );
+  connect( ListAlgoDefinition, SIGNAL( doubleClicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) );
 
   int x, y ;
   mySMESHGUI->DefineDlgPosition( this, x, y ) ;
   this->move( x, y ) ;
   this->show() ; 
+
+  LineEditC1A1->setFocus() ;
+  myEditCurrentArgument = LineEditC1A1;
+  mySelection->ClearFilters() ;   
+  mySelection->AddFilter(myMeshOrSubMeshFilter) ;
+
   SelectionIntoArgument();
 
-  return ;
+  UpdateControlState();
 }
 
 
 //=================================================================================
-// function : ConstructorsClicked()
-// purpose  : Radio button management
+// function : ClickOnOk()
+// purpose  :
 //=================================================================================
-void SMESHGUI_EditHypothesesDlg::ConstructorsClicked(int constructorId)
+void SMESHGUI_EditHypothesesDlg::ClickOnOk()
 {
-  return ;
+  if ( ClickOnApply() )
+    ClickOnCancel() ;
 }
 
+//=================================================================================
+// function : ClickOnApply()
+// purpose  :
+//=================================================================================
+bool SMESHGUI_EditHypothesesDlg::ClickOnApply()
+{
+  bool aRes = false;
+
+  QAD_WaitCursor wc;
+
+  QAD_Operation* op = new QAD_Operation( mySMESHGUI->GetActiveStudy() );
+
+  // start transaction
+  op->start();
+  
+  if ( !myMesh->_is_nil() )
+    aRes = StoreMesh();
+  else if ( !mySubMesh->_is_nil() )
+    aRes = StoreSubMesh();
+
+  if ( aRes )
+    // commit transaction
+    op->finish();
+  else
+    // abort transaction
+    op->abort();
+
+  return aRes;
+}
+
+
 //=================================================================================
 // function : ClickOnCancel()
 // purpose  :
 //=================================================================================
 void SMESHGUI_EditHypothesesDlg::ClickOnCancel()
 {
-  disconnect( mySelection, 0, this, 0 );
-  mySMESHGUI->ResetState() ;
-  mySelection->ClearFilters() ;
-  reject() ;
-  return ;
+  close();
 }
 
 
@@ -391,75 +341,52 @@ void SMESHGUI_EditHypothesesDlg::ClickOnCancel()
 //=================================================================================
 void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument()
 {
-  myEditCurrentArgument->setText("") ;
   QString aString = ""; 
 
   int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
-
-  switch (myConstructorId) 
-    {
-    case 0:
-      {
-       if ( myEditCurrentArgument == LineEditC1A1 ) {
-         if ( nbSel != 1 ) {
-           myOkHypothesis = false;
-           myOkAlgorithm = false;
-           myMesh = SMESH::SMESH_Mesh::_nil();
-           mySubMesh = SMESH::SMESH_subMesh::_nil();
-           InitHypAssignation();
-           InitAlgoAssignation();
-           InitGeom();
-           return ;
-         } else {
-           Standard_Boolean testResult ;
-           Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
-           myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ;
-           if( !testResult ) {
-             myMesh = SMESH::SMESH_Mesh::_nil();
-
-             mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IO, testResult) ;
-             if( !testResult ) {
-               mySubMesh = SMESH::SMESH_subMesh::_nil();
-               InitHypAssignation();
-               InitAlgoAssignation();
-               InitGeom();
-               return ;
-             }
-           }
-           InitHypAssignation();
-           InitAlgoAssignation();
-           InitGeom();
-         }
-       } else if ( myEditCurrentArgument == LineEditC1A2 ) {
-         if ( nbSel != 1 ) {
-           myOkHypothesis = false;
-           myOkAlgorithm = false;
-           myGeomShape = GEOM::GEOM_Shape::_nil();
-           InitHypAssignation();
-           InitAlgoAssignation();
-           InitGeom();
-           return ;
-         } else {
-           Standard_Boolean testResult ;
-           Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
-           myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
-           if( !testResult ) {
-             myGeomShape = GEOM::GEOM_Shape::_nil();
-             InitHypAssignation();
-             InitAlgoAssignation();
-             InitGeom();
-             return ;
-           }
-           InitHypAssignation();
-           InitAlgoAssignation();
-           InitGeom();     
-         }
-       } 
-       break;
+  
+  if ( myEditCurrentArgument == LineEditC1A1 ) {
+    if ( nbSel != 1 ) {
+      myMesh      = SMESH::SMESH_Mesh::_nil();
+      mySubMesh   = SMESH::SMESH_subMesh::_nil();
+      aString     = "";
+    } else {
+      Standard_Boolean testResult ;
+      Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+      myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ;
+      if( !testResult ) {
+       myMesh = SMESH::SMESH_Mesh::_nil();
+       mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IO, testResult) ;
+       if( !testResult ) {
+         mySubMesh = SMESH::SMESH_subMesh::_nil();
+         aString = "";
+       }
       }
     }
-  
-  myEditCurrentArgument->setText(aString) ;
+    myEditCurrentArgument->setText( aString );
+    
+    myGeomShape = GEOM::GEOM_Shape::_nil(); // InitGeom() will try to retrieve a shape from myMesh or mySubMesh
+    InitGeom();
+    
+    myImportedMesh = myGeomShape->_is_nil();
+    
+    InitHypAssignation();
+    InitAlgoAssignation();
+  } 
+  else if ( myEditCurrentArgument == LineEditC1A2 ) {
+    if ( nbSel != 1 )
+      myGeomShape = GEOM::GEOM_Shape::_nil();
+    else {
+      Standard_Boolean testResult ;
+      Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+      myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
+      if( !testResult )
+       myGeomShape = GEOM::GEOM_Shape::_nil();
+    }
+    InitGeom();
+  } 
+
+  UpdateControlState();
 }
 
 
@@ -470,26 +397,18 @@ void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument()
 void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
-  switch (myConstructorId)
-    {
-    case 0: /* default constructor */
-      {        
-       if(send == SelectButtonC1A1) {
-         LineEditC1A1->setFocus() ;
-         myEditCurrentArgument = LineEditC1A1;
-         mySelection->ClearFilters() ;   
-         mySelection->AddFilter(myMeshOrSubMeshFilter) ;
-       } else if (send == SelectButtonC1A2) {
-         LineEditC1A2->setFocus() ;
-         myEditCurrentArgument = LineEditC1A2;
-         mySelection->ClearFilters() ;
-         mySelection->AddFilter(myGeomFilter) ;
-       } 
-       SelectionIntoArgument() ;
-       break;
-      }
-    }
-  return ;
+  if(send == SelectButtonC1A1) {
+    LineEditC1A1->setFocus() ;
+    myEditCurrentArgument = LineEditC1A1;
+    mySelection->ClearFilters() ;   
+    mySelection->AddFilter(myMeshOrSubMeshFilter) ;
+  } else if (send == SelectButtonC1A2) {
+    LineEditC1A2->setFocus() ;
+    myEditCurrentArgument = LineEditC1A2;
+    mySelection->ClearFilters() ;
+    mySelection->AddFilter(myGeomFilter) ;
+  } 
+  SelectionIntoArgument() ;
 }
 
 //=================================================================================
@@ -498,9 +417,8 @@ void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument()
 //=================================================================================
 void SMESHGUI_EditHypothesesDlg::DeactivateActiveDialog()
 {
-  if ( GroupConstructors->isEnabled() ) {
+  if ( GroupC1->isEnabled() ) {
     disconnect( mySelection, 0, this, 0 );
-    GroupConstructors->setEnabled(false) ;
     GroupC1->setEnabled(false) ;
     GroupButtons->setEnabled(false) ;
   }
@@ -514,11 +432,9 @@ void SMESHGUI_EditHypothesesDlg::DeactivateActiveDialog()
 void SMESHGUI_EditHypothesesDlg::ActivateThisDialog()
 {
   mySMESHGUI->EmitSignalDeactivateDialog() ;   
-  GroupConstructors->setEnabled(true) ;
   GroupC1->setEnabled(true) ;
   GroupButtons->setEnabled(true) ;
   connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-  return ;
 }
 
 
@@ -528,10 +444,8 @@ void SMESHGUI_EditHypothesesDlg::ActivateThisDialog()
 //=================================================================================
 void SMESHGUI_EditHypothesesDlg::enterEvent(QEvent* e)
 {
-  if ( GroupConstructors->isEnabled() )
-    return ;  
-  ActivateThisDialog() ;
-  return ;
+  if ( !GroupC1->isEnabled() )
+    ActivateThisDialog();
 }
 
 
@@ -541,72 +455,31 @@ void SMESHGUI_EditHypothesesDlg::enterEvent(QEvent* e)
 //=================================================================================
 void SMESHGUI_EditHypothesesDlg::closeEvent( QCloseEvent* e )
 {
-  this->ClickOnCancel() ;
-  return ;
+  disconnect( mySelection, 0, this, 0 );
+  mySMESHGUI->ResetState() ;
+  mySelection->ClearFilters() ;
+  QDialog::closeEvent( e );
 }
 
+
 //=================================================================================
-// function : TextChangedInLineEdit()
+// function : removeItem()
 // purpose  :
 //=================================================================================
-void SMESHGUI_EditHypothesesDlg::TextChangedInLineEdit(const QString& newText)
-{  
-  QLineEdit* send = (QLineEdit*)sender();
-  QString newT = strdup(newText) ;
-  
-  return ;
-}
-
-void SMESHGUI_EditHypothesesDlg::removeItem(QListBoxItem* i)
+void SMESHGUI_EditHypothesesDlg::removeItem(QListBoxItem* item)
 {
-  if (!i) return;
+  const QObject* aSender = sender();
 
-  SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
-  int index = ListHypAssignation->index( i );
-  if ( index != -1 ) {
-    if (mapNameIOR.find( string((const char*)(i->text())) ) != mapNameIOR.end()) {
-      SMESH::SMESH_Hypothesis_var Hyp = 
-       SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR( mapNameIOR[ string((const char*)(i->text())) ].c_str() ) );
-  
-      if ( !myMesh->_is_nil() ) {
-       SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh(myMesh);
-       mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aMesh, Hyp);
-       //      mySMESHGUI->GetStudyAPI().ModifiedMesh( aMesh, false );
-       mySMESHGUI->GetActiveStudy()->updateObjBrowser();
-      }
-      if ( !mySubMesh->_is_nil() ) {
-       SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh(mySubMesh);
-       mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aSubMesh, Hyp);
-       //      mySMESHGUI->GetStudyAPI().ModifiedMesh( aSubMesh, false );
-       mySMESHGUI->GetActiveStudy()->updateObjBrowser();
-      }
-      
-      ListHypAssignation->removeItem( index );
-    }
-    return;
-  } 
-  index = ListAlgoAssignation->index( i );
-  if ( index != -1 ) {
-    if (mapNameIOR.find( string((const char*)(i->text())) ) != mapNameIOR.end()) {
-      SMESH::SMESH_Hypothesis_var Hyp = 
-       SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string((const char*)(i->text())) ].c_str()) );
-      
-      if ( !myMesh->_is_nil() ) {
-       SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh(myMesh);
-       mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aMesh, Hyp);
-       //      mySMESHGUI->GetStudyAPI().ModifiedMesh( aMesh, false );
-       mySMESHGUI->GetActiveStudy()->updateObjBrowser();
-      }
-      if ( !mySubMesh->_is_nil() ) {
-       SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh(mySubMesh);
-       mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aSubMesh, Hyp);
-       //      mySMESHGUI->GetStudyAPI().ModifiedMesh( aSubMesh, false );
-       mySMESHGUI->GetActiveStudy()->updateObjBrowser();
-      }
+  if (!item) return;
 
-      ListAlgoAssignation->removeItem( index );
-    } 
+  if ( aSender == ListHypAssignation ) {
+    ListHypAssignation->removeItem( ListHypAssignation->index( item ) );
+  } 
+  else if ( aSender == ListAlgoAssignation ) {
+    ListAlgoAssignation->removeItem( ListAlgoAssignation->index( item ) );
   }
+
+  UpdateControlState();
 }
 
 
@@ -614,43 +487,45 @@ void SMESHGUI_EditHypothesesDlg::removeItem(QListBoxItem* i)
 // function : addItem()
 // purpose  :
 //=================================================================================
-void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* i)
+void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* item)
 {
+  const QObject* aSender = sender();
+
+  if (!item) return;
+
+  ListBoxIOR* i = 0;
+  if ( item->rtti() == ListBoxIOR::RTTI_IOR )
+    i = (ListBoxIOR*)item;
   if (!i) return;
+  
+  bool isFound = false;
 
-  SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
-  if ( ListHypDefinition->findItem( i->text() ) ) {
-    if ( !ListHypAssignation->findItem( i->text() ) ) {
-      ListHypAssignation->insertItem( i->text() );
-      
-      if (mapNameIOR.find( string((const char*)(i->text())) ) != mapNameIOR.end()) {
-       SMESH::SMESH_Hypothesis_var Hyp = 
-         SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string((const char*)(i->text())) ].c_str()) );
-      
-       if ( !myMesh->_is_nil() )
-         mySMESHGUI->AddHypothesisOnMesh(myMesh, Hyp);
-       if ( !mySubMesh->_is_nil() )
-         mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, Hyp);
+  if ( aSender == ListHypDefinition ) {
+    for ( int j = 0, n = ListHypAssignation->count(); !isFound && j < n; j++ ) {
+      if ( ListHypAssignation->item( j )->rtti() == ListBoxIOR::RTTI_IOR ) {
+       ListBoxIOR* anItem = (ListBoxIOR*)ListHypAssignation->item( j );
+       isFound = !strcmp( anItem->GetIOR(), i->GetIOR() );
       }
     }
-    return;
+    if ( !isFound )
+      ListBoxIOR* anItem = new ListBoxIOR( ListHypAssignation, 
+                                          strdup( i->GetIOR() ), 
+                                          strdup( i->text().latin1() ) );
   }
-  if ( ListAlgoDefinition->findItem( i->text() ) ) {
-    if ( !ListAlgoAssignation->findItem( i->text() ) ) {
-      ListAlgoAssignation->insertItem( i->text() );
-      
-      if (mapNameIOR.find( string((const char*)(i->text())) ) != mapNameIOR.end()) {
-       SMESH::SMESH_Hypothesis_var Hyp = 
-         SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string((const char*)(i->text())) ].c_str()) );
-      
-       if ( !myMesh->_is_nil() )
-         mySMESHGUI->AddAlgorithmOnMesh(myMesh, Hyp);
-       if ( !mySubMesh->_is_nil() )
-         mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, Hyp);
+  else if ( aSender == ListAlgoDefinition ) {
+    for ( int j = 0, n = ListAlgoAssignation->count(); !isFound && j < n; j++ ) {
+      if ( ListAlgoAssignation->item( j )->rtti() == ListBoxIOR::RTTI_IOR ) {
+       ListBoxIOR* anItem = (ListBoxIOR*)ListAlgoAssignation->item( j );
+       isFound = !strcmp( anItem->GetIOR(), i->GetIOR() );
       }
     }
+    if ( !isFound )
+      ListBoxIOR* anItem = new ListBoxIOR( ListAlgoAssignation, 
+                                          strdup( i->GetIOR() ), 
+                                          strdup( i->text().latin1() ) );
   }
-  mySMESHGUI->GetActiveStudy()->updateObjBrowser();
+
+  UpdateControlState();
 }
 
 
@@ -660,7 +535,12 @@ void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* i)
 //=================================================================================
 void SMESHGUI_EditHypothesesDlg::InitHypDefinition()
 {
+  ListHypDefinition->clear();
+
   SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH");
+  if ( father->_is_nil() )
+    return;
+
   SALOMEDS::SObject_var           HypothesisRoot;
   SALOMEDS::GenericAttribute_var  anAttr;
   SALOMEDS::AttributeName_var     aName;
@@ -672,13 +552,13 @@ void SMESHGUI_EditHypothesesDlg::InitHypDefinition()
     for (; it->More();it->Next()) {
       SALOMEDS::SObject_var Obj = it->Value();
       if (Obj->FindAttribute(anAttr, "AttributeName") ) {
-       aName = SALOMEDS::AttributeName::_narrow(anAttr);
-       ListHypDefinition->insertItem(aName->Value());
-       
-       if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
-         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-         mapNameIOR[ aName->Value() ] = anIOR->Value();
-       }
+        aName = SALOMEDS::AttributeName::_narrow(anAttr);
+        if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
+          anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+          ListBoxIOR* anItem = new ListBoxIOR( ListHypDefinition, 
+                                               anIOR->Value(), 
+                                               aName->Value() );
+        }
       }
     }
   }
@@ -692,43 +572,41 @@ void SMESHGUI_EditHypothesesDlg::InitHypAssignation()
 {
   MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() )
   MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() )
+
+  myMapOldHypos.clear();
   ListHypAssignation->clear();
-  SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
-  int Tag_RefOnAppliedHypothesis = 2;
-  SALOMEDS::SObject_var             AHR, aRef;
+  if ( myImportedMesh )
+    return;
+
+  SALOMEDS::SObject_var             aMorSM, AHR, aRef;
   SALOMEDS::GenericAttribute_var    anAttr;
   SALOMEDS::AttributeName_var       aName;
+  SALOMEDS::AttributeIOR_var        anIOR;
+  SMESHGUI_StudyAPI                 myStudyAPI = mySMESHGUI->GetStudyAPI();
 
-  if ( !myMesh->_is_nil() ) {
-    SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
-    if ( aMesh->FindSubObject (2, AHR)) {
-      SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
-      for (; it->More();it->Next()) {
-       SALOMEDS::SObject_var Obj = it->Value();
-       if ( Obj->ReferencedObject(aRef) ) {
-         if (aRef->FindAttribute(anAttr, "AttributeName") ) {
-             aName = SALOMEDS::AttributeName::_narrow(anAttr);
-           ListHypAssignation->insertItem(aName->Value());
+  if ( !myMesh->_is_nil() )
+    aMorSM = myStudyAPI.FindObject( myMesh );
+  else if ( !mySubMesh->_is_nil() )
+    aMorSM = myStudyAPI.FindObject( mySubMesh );
+
+  if ( !aMorSM->_is_nil() && aMorSM->FindSubObject (2, AHR)) {
+    SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
+    for (; it->More();it->Next()) {
+      SALOMEDS::SObject_var Obj = it->Value();
+      if ( Obj->ReferencedObject(aRef) ) {
+        if (aRef->FindAttribute(anAttr, "AttributeName") ) {
+         aName = SALOMEDS::AttributeName::_narrow(anAttr);
+         if (aRef->FindAttribute(anAttr, "AttributeIOR")) {
+           anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+           ListBoxIOR* anItem = new ListBoxIOR( ListHypAssignation, 
+                                                anIOR->Value(), 
+                                                aName->Value() );
+           myMapOldHypos[ anIOR->Value() ] = ListHypAssignation->index( anItem );
          }
        }
       }
     }
   }
-  if ( !mySubMesh->_is_nil() ) {
-    SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
-    if ( aSubMesh->FindSubObject (2, AHR)) {
-      SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
-      for (; it->More();it->Next()) {
-       SALOMEDS::SObject_var Obj = it->Value();
-       if ( Obj->ReferencedObject(aRef) ) {
-         if (aRef->FindAttribute(anAttr, "AttributeName") ) {
-           aName = SALOMEDS::AttributeName::_narrow(anAttr);
-           ListHypAssignation->insertItem(aName->Value());
-         }
-       }
-      }
-    }    
-  }
 }
 
 //=================================================================================
@@ -737,25 +615,29 @@ void SMESHGUI_EditHypothesesDlg::InitHypAssignation()
 //=================================================================================
 void SMESHGUI_EditHypothesesDlg::InitAlgoDefinition()
 {
+  ListAlgoDefinition->clear();
+
   SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH");
+  if ( father->_is_nil() )
+    return;
+
   SALOMEDS::SObject_var          AlgorithmsRoot;
   SALOMEDS::GenericAttribute_var anAttr;
   SALOMEDS::AttributeName_var    aName;
   SALOMEDS::AttributeIOR_var     anIOR;
 
-  int Tag_AlgorithmsRoot = 2;
   if (father->FindSubObject (2, AlgorithmsRoot)) {
     SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AlgorithmsRoot);
     for (; it->More();it->Next()) {
       SALOMEDS::SObject_var Obj = it->Value();
       if (Obj->FindAttribute(anAttr, "AttributeName") ) {
-       aName = SALOMEDS::AttributeName::_narrow(anAttr);
-       ListAlgoDefinition->insertItem(aName->Value());
-
-       if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
-         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-         mapNameIOR[ aName->Value() ] = anIOR->Value();
-       }
+        aName = SALOMEDS::AttributeName::_narrow(anAttr);
+        if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
+          anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+          ListBoxIOR* anItem = new ListBoxIOR( ListAlgoDefinition, 
+                                               anIOR->Value(), 
+                                               aName->Value() );
+        }
       }
     }
   }
@@ -770,38 +652,36 @@ void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation()
 {
   MESSAGE ( " InitAlgoAssignation " << myMesh->_is_nil() )
   MESSAGE ( " InitAlgoAssignation " << mySubMesh->_is_nil() )
+
+  myMapOldAlgos.clear();
   ListAlgoAssignation->clear();
-  SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
-  int Tag_RefOnAppliedAlgorithms = 3;
-  SALOMEDS::SObject_var             AHR, aRef;
+  if ( myImportedMesh )
+    return;
+
+  SALOMEDS::SObject_var             aMorSM, AHR, aRef;
   SALOMEDS::GenericAttribute_var    anAttr;
   SALOMEDS::AttributeName_var       aName;
-  
-  if ( !myMesh->_is_nil() ) {
-    SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
-    if ( aMesh->FindSubObject (3, AHR) ) {
-      SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
-      for (; it->More();it->Next()) {
-       SALOMEDS::SObject_var Obj = it->Value();
-       if ( Obj->ReferencedObject(aRef) ) {
-         if (aRef->FindAttribute(anAttr, "AttributeName") ) {
-           aName = SALOMEDS::AttributeName::_narrow(anAttr);
-           ListAlgoAssignation->insertItem(aName->Value());
-         }
-       }
-      }
-    }
-  }
-  if ( !mySubMesh->_is_nil() ) {
-    SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
-    if ( aSubMesh->FindSubObject (3, AHR) ) {
-      SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
-      for (; it->More();it->Next()) {
-       SALOMEDS::SObject_var Obj = it->Value();
-       if ( Obj->ReferencedObject(aRef) ) {
-         if (aRef->FindAttribute(anAttr, "AttributeName") ) {
-           aName = SALOMEDS::AttributeName::_narrow(anAttr);
-           ListAlgoAssignation->insertItem(aName->Value());
+  SALOMEDS::AttributeIOR_var        anIOR;
+  SMESHGUI_StudyAPI                 myStudyAPI = mySMESHGUI->GetStudyAPI();  
+
+  if ( !myMesh->_is_nil() )
+    aMorSM = myStudyAPI.FindObject( myMesh );
+  else if ( !mySubMesh->_is_nil() )
+    aMorSM = myStudyAPI.FindObject( mySubMesh );
+
+  if ( !aMorSM->_is_nil() && aMorSM->FindSubObject (3, AHR)) {
+    SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
+    for (; it->More();it->Next()) {
+      SALOMEDS::SObject_var Obj = it->Value();
+      if ( Obj->ReferencedObject(aRef) ) {
+        if (aRef->FindAttribute(anAttr, "AttributeName") ) {
+         aName = SALOMEDS::AttributeName::_narrow(anAttr);
+         if (aRef->FindAttribute(anAttr, "AttributeIOR")) {
+           anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+           ListBoxIOR* anItem = new ListBoxIOR( ListAlgoAssignation, 
+                                                anIOR->Value(), 
+                                                aName->Value() );
+           myMapOldAlgos[ anIOR->Value() ] = ListAlgoAssignation->index( anItem );
          }
        }
       }
@@ -818,13 +698,13 @@ void SMESHGUI_EditHypothesesDlg::InitGeom()
   LineEditC1A2->setText("") ;
   SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
 
-  if ( !myMesh->_is_nil() ) {
-    SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
+  if ( myGeomShape->_is_nil() && !myMesh->_is_nil() ) {
+    SALOMEDS::SObject_var aMesh = myStudyAPI.FindObject( myMesh );
     if ( !aMesh->_is_nil() )
       myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aMesh);
   }
-  if ( !mySubMesh->_is_nil() ) {
-    SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
+  if ( myGeomShape->_is_nil() && !mySubMesh->_is_nil() ) {
+    SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindObject( mySubMesh );
     if ( !aSubMesh->_is_nil() )
       myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aSubMesh);
   }
@@ -835,9 +715,203 @@ void SMESHGUI_EditHypothesesDlg::InitGeom()
     SALOMEDS::SObject_var aSO = mySMESHGUI->GetStudy()->FindObjectIOR( myGeomShape->Name() );
     if ( !aSO->_is_nil() ) {
       if (aSO->FindAttribute(anAttr, "AttributeName") ) {
-       aName = SALOMEDS::AttributeName::_narrow(anAttr);
-       LineEditC1A2->setText( QString(aName->Value()) ) ;
+        aName = SALOMEDS::AttributeName::_narrow(anAttr);
+        LineEditC1A2->setText( QString(aName->Value()) ) ;
+      }
+    }
+  }
+}
+
+//=================================================================================
+// function : UpdateControlState()
+// purpose  :
+//=================================================================================
+void SMESHGUI_EditHypothesesDlg::UpdateControlState()
+{
+  bool isEnabled = ( !myMesh   ->_is_nil() && !myGeomShape->_is_nil() &&   ListHypAssignation->count() && ListAlgoAssignation->count() ) ||
+                   ( !mySubMesh->_is_nil() && !myGeomShape->_is_nil() && ( ListHypAssignation->count() || ListAlgoAssignation->count() ) );
+
+  buttonOk   ->setEnabled( isEnabled && !myImportedMesh );
+  buttonApply->setEnabled( isEnabled && !myImportedMesh );
+
+  SelectButtonC1A2   ->setEnabled( ALLOW_CHANGE_SHAPE && !myImportedMesh );
+  LineEditC1A2       ->setEnabled( ALLOW_CHANGE_SHAPE && !myImportedMesh );
+  ListHypDefinition  ->setEnabled( !myImportedMesh );
+  ListHypAssignation ->setEnabled( !myImportedMesh );
+  ListAlgoDefinition ->setEnabled( !myImportedMesh );
+  ListAlgoAssignation->setEnabled( !myImportedMesh );
+}
+
+//=================================================================================
+// function : StoreMesh()
+// purpose  :
+//=================================================================================
+bool SMESHGUI_EditHypothesesDlg::StoreMesh()
+{
+  SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
+  MapIOR anOldHypos, aNewHypos;
+  if ( myGeomShape->_is_nil() )
+    return false;
+  // 1. Check whether the geometric shape has changed
+  SALOMEDS::SObject_var aMeshSO = myStudyAPI.FindObject( myMesh );
+  GEOM::GEOM_Shape_var aIniGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh( aMeshSO );
+  bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent( myGeomShape );
+  if ( bShapeChanged ) {
+    // VSR : TODO : Set new shape - not supported yet by SMESH engine
+    // 1) remove all old hypotheses and algorithms and also submeshes
+    // 2) set new shape
+  }
+  MapIOR::iterator it;
+  // 2. remove not used hypotheses from the mesh
+  for ( it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it ) {
+    string ior = it->first;
+    int index = findItem( ListHypAssignation, ior );
+    if ( index < 0 ) {
+      CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+      if ( !CORBA::is_nil( anObject ) ) {
+       SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+       if ( !aHyp->_is_nil() )
+         if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp ) )
+           return false;
+      }
+    }
+  }
+  // 3. remove not used algorithms from the mesh
+  for ( it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it ) {
+    string ior = it->first;
+    int index = findItem( ListAlgoAssignation, ior );
+    if ( index < 0 ) {
+      CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+      if ( !CORBA::is_nil( anObject ) ) {
+       SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+       if ( !aHyp->_is_nil() )
+         if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp ) )
+           return false;
+      }
+    }
+  }
+  // 4. Add new hypotheses
+  for ( int i = 0; i < ListHypAssignation->count(); i++ ) {
+    if ( ListHypAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) {
+      ListBoxIOR* anItem = ( ListBoxIOR* )( ListHypAssignation->item( i ) );
+      if ( anItem ) {
+       string ior = anItem->GetIOR();
+       if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) {
+         CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+         if ( !CORBA::is_nil( anObject ) ) {
+           SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+           if ( !aHyp->_is_nil() )
+             if ( !mySMESHGUI->AddHypothesisOnMesh( myMesh, aHyp ) )
+               return false;
+         }
+       }
+      }
+    }
+  }
+  // 4. Add new algorithms
+  for ( int i = 0; i < ListAlgoAssignation->count(); i++ ) {
+    if ( ListAlgoAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) {
+      ListBoxIOR* anItem = ( ListBoxIOR* )( ListAlgoAssignation->item( i ) );
+      if ( anItem ) {
+       string ior = anItem->GetIOR();
+       if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) {
+         CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+         if ( !CORBA::is_nil( anObject ) ) {
+           SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+           if ( !aHyp->_is_nil() )
+             if ( !mySMESHGUI->AddAlgorithmOnMesh( myMesh, aHyp ) )
+               return false;
+         }
+       }
+      }
+    }
+  }
+  return true;
+}
+
+//=================================================================================
+// function : StoreSubMesh()
+// purpose  :
+//=================================================================================
+bool SMESHGUI_EditHypothesesDlg::StoreSubMesh()
+{
+  SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
+  MapIOR anOldHypos, aNewHypos;
+  if ( myGeomShape->_is_nil() )
+    return false;
+  // 1. Check whether the geometric shape has changed
+  SALOMEDS::SObject_var aSubMeshSO = myStudyAPI.FindObject( mySubMesh );
+  GEOM::GEOM_Shape_var aIniGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh( aSubMeshSO );
+  bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent( myGeomShape );
+  if ( bShapeChanged ) {
+    // VSR : TODO : Set new shape - not supported yet by engine
+    // 1) remove all old hypotheses and algorithms
+    // 2) set new shape
+  }
+  MapIOR::iterator it;
+  // 2. remove not used hypotheses from the submesh
+  for ( it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it ) {
+    string ior = it->first;
+    int index = findItem( ListHypAssignation, ior );
+    if ( index < 0 ) {
+      CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+      if ( !CORBA::is_nil( anObject ) ) {
+       SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+       if ( !aHyp->_is_nil() )
+         if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp ) )
+           return false;
+      }
+    }
+  }
+  // 3. remove not used algorithms from the submesh
+  for ( it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it ) {
+    string ior = it->first;
+    int index = findItem( ListAlgoAssignation, ior );
+    if ( index < 0 ) {
+      CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+      if ( !CORBA::is_nil( anObject ) ) {
+       SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+       if ( !aHyp->_is_nil() )
+         if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp ) )
+           return false;
+      }
+    }
+  }
+  // 4. Add new hypotheses
+  for ( int i = 0; i < ListHypAssignation->count(); i++ ) {
+    if ( ListHypAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) {
+      ListBoxIOR* anItem = ( ListBoxIOR* )( ListHypAssignation->item( i ) );
+      if ( anItem ) {
+       string ior = anItem->GetIOR();
+       if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) {
+         CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+         if ( !CORBA::is_nil( anObject ) ) {
+           SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+           if ( !aHyp->_is_nil() )
+             if ( !mySMESHGUI->AddHypothesisOnSubMesh( mySubMesh, aHyp ) )
+               return false;
+         }
+       }
+      }
+    }
+  }
+  // 4. Add new algorithms
+  for ( int i = 0; i < ListAlgoAssignation->count(); i++ ) {
+    if ( ListAlgoAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) {
+      ListBoxIOR* anItem = ( ListBoxIOR* )( ListAlgoAssignation->item( i ) );
+      if ( anItem ) {
+       string ior = anItem->GetIOR();
+       if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) {
+         CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() );
+         if ( !CORBA::is_nil( anObject ) ) {
+           SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+           if ( !aHyp->_is_nil() )
+             if ( !mySMESHGUI->AddAlgorithmOnSubMesh( mySubMesh, aHyp ) )
+               return false;
+         }
+       }
       }
     }
   }
+  return true;
 }
index 45bf2c4bad98cd65f88531ca00cb198b90a822ff..2e707dd49f99e56a5dd29db3dbf58d2e54c1a03a 100644 (file)
@@ -34,7 +34,6 @@
 #include "SMESH_TypeFilter.hxx"
 
 // QT Includes
-#include <qvariant.h>
 #include <qdialog.h>
 
 // IDL Headers
 #include <map>
 #include <string>
 
-using namespace std;
-
-class QVBoxLayout; 
-class QHBoxLayout; 
-class QGridLayout; 
-class QButtonGroup;
 class QGroupBox;
 class QLabel;
 class QLineEdit;
 class QPushButton;
-class QRadioButton;
 class QListBox;
 class QListBoxItem;
 class SMESHGUI;
 
+typedef map<string, int> MapIOR;
 
 //=================================================================================
 // class    : SMESHGUI_EditHypothesesDlg
@@ -74,11 +67,12 @@ public:
     SMESHGUI_EditHypothesesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
     ~SMESHGUI_EditHypothesesDlg();
 
-private:
+protected:
+    virtual void closeEvent( QCloseEvent* e ); 
+    virtual void enterEvent ( QEvent* );
 
+private:
     void Init( SALOME_Selection* Sel ) ;
-    void closeEvent( QCloseEvent* e ) ;
-    void enterEvent ( QEvent * ) ;
 
     void InitHypDefinition();
     void InitAlgoDefinition();
@@ -87,11 +81,16 @@ private:
 
     void InitGeom();
 
+    void UpdateControlState();
+
+    bool StoreMesh();
+    bool StoreSubMesh();
+
+private:
     SMESHGUI*                     mySMESHGUI ;
     SALOME_Selection*             mySelection ;
              
     GEOM::GEOM_Shape_var          myGeomShape ;
-    int                           myConstructorId ; 
     QLineEdit*                    myEditCurrentArgument; 
 
     SMESH::SMESH_Mesh_var         myMesh;
@@ -100,78 +99,46 @@ private:
     Handle(SALOME_TypeFilter)     myGeomFilter;
     Handle(SMESH_TypeFilter)      myMeshOrSubMeshFilter;
 
-    map<string,string>            mapNameIOR;
-
-    SALOME_ListIO                 HypoList;
-    SALOME_ListIO                 AlgoList;
-
-    bool                          myOkHypothesis;
-    bool                          myOkAlgorithm;
+    MapIOR                        myMapOldHypos, myMapOldAlgos;
 
-    SMESH::SMESH_Hypothesis_var   myHypothesis;
-    SMESH::SMESH_Hypothesis_var   myAlgorithm;
-
-    SMESH::ListOfHypothesis_var   myLHypothesis;
-    SMESH::ListOfHypothesis_var   myLAlgorithm;
+    bool                          myImportedMesh;
  
-    QButtonGroup* GroupConstructors;
-    QRadioButton* Constructor1;
     QGroupBox*    GroupButtons;
     QPushButton*  buttonOk;
-    QPushButton*  buttonCancel;
     QPushButton*  buttonApply;
-    QGroupBox*    GroupC1;
+    QPushButton*  buttonCancel;
 
+    QGroupBox*    GroupC1;
     QLabel*       TextLabelC1A1;
     QPushButton*  SelectButtonC1A1;
     QLineEdit*    LineEditC1A1;
-
     QLabel*       TextLabelC1A2;
     QPushButton*  SelectButtonC1A2;
     QLineEdit*    LineEditC1A2;
 
-    QGroupBox* GroupHypotheses;
-    QLabel* TextHypDefinition;
-    QListBox* ListHypDefinition;
-    QLabel* TextHypAssignation;
-    QListBox* ListHypAssignation;
+    QGroupBox*    GroupHypotheses;
+    QLabel*       TextHypDefinition;
+    QListBox*     ListHypDefinition;
+    QLabel*       TextHypAssignation;
+    QListBox*     ListHypAssignation;
 
-    QGroupBox* GroupAlgorithms;
-    QLabel* TextAlgoDefinition;
-    QListBox* ListAlgoDefinition;
-    QLabel* TextAlgoAssignation;
-    QListBox* ListAlgoAssignation;
+    QGroupBox*    GroupAlgorithms;
+    QLabel*       TextAlgoDefinition;
+    QListBox*     ListAlgoDefinition;
+    QLabel*       TextAlgoAssignation;
+    QListBox*     ListAlgoAssignation;
 
 private slots:
-
-    void ConstructorsClicked(int constructorId);
+    void ClickOnOk();
+    bool ClickOnApply();
     void ClickOnCancel();
     void SetEditCurrentArgument() ;
     void SelectionIntoArgument() ;
     void DeactivateActiveDialog() ;
     void ActivateThisDialog() ;
-    void TextChangedInLineEdit(const QString& newText) ;
 
     void removeItem(QListBoxItem*);
     void addItem(QListBoxItem*);
-
-protected:
-    QGridLayout* SMESHGUI_EditHypothesesDlgLayout;
-    QGridLayout* GroupConstructorsLayout;
-    QGridLayout* GroupButtonsLayout;
-    QGridLayout* GroupC1Layout;
-
-    QGridLayout* grid_3;
-    QGridLayout* grid_4;
-
-    QHBoxLayout* hbox_2;
-    QHBoxLayout* hbox_3;
-
-    QVBoxLayout* vbox;
-    QVBoxLayout* vbox_2;
-    QVBoxLayout* vbox_3;
-    QVBoxLayout* vbox_4;
-
 };
 
 #endif // DIALOGBOX_EDIT_HYPOTHESES_H
index 4261740b39a2c4756c854ce2a7b547a0f385ba00..ac34a76c77560ac3b9c5eb2b27bb3be0ed21d621 100644 (file)
@@ -33,23 +33,20 @@ using namespace std;
 
 #include "QAD_Application.h"
 #include "QAD_Desktop.h"
+#include "QAD_MessageBox.h"
+#include "QAD_WaitCursor.h"
+#include "QAD_Operation.h"
+
 #include "utilities.h"
 
 // QT Includes
-#include <qbuttongroup.h>
 #include <qgroupbox.h>
 #include <qlabel.h>
 #include <qlineedit.h>
 #include <qpushbutton.h>
-#include <qradiobutton.h>
 #include <qlayout.h>
-#include <qvariant.h>
-#include <qtooltip.h>
-#include <qwhatsthis.h>
-#include <qimage.h>
 #include <qpixmap.h>
 
-
 //=================================================================================
 // class    : SMESHGUI_InitMeshDlg()
 // purpose  : Constructs a SMESHGUI_InitMeshDlg which is a child of 'parent', with the 
@@ -58,135 +55,88 @@ using namespace std;
 //            TRUE to construct a modal dialog.
 //=================================================================================
 SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
-    : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu  )
+    : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
 {
-    QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_INIT_MESH")));
     QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
     if ( !name )
        setName( "SMESHGUI_InitMeshDlg" );
-    resize( 303, 175 ); 
     setCaption( tr( "SMESH_INIT_MESH"  ) );
     setSizeGripEnabled( TRUE );
-    SMESHGUI_InitMeshDlgLayout = new QGridLayout( this ); 
+    QGridLayout* SMESHGUI_InitMeshDlgLayout = new QGridLayout( this ); 
     SMESHGUI_InitMeshDlgLayout->setSpacing( 6 );
     SMESHGUI_InitMeshDlgLayout->setMargin( 11 );
     
     /***************************************************************/
-    GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
-    GroupConstructors->setTitle( tr( "SMESH_INIT"  ) );
-    GroupConstructors->setExclusive( TRUE );
-    GroupConstructors->setColumnLayout(0, Qt::Vertical );
-    GroupConstructors->layout()->setSpacing( 0 );
-    GroupConstructors->layout()->setMargin( 0 );
-    GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
-    GroupConstructorsLayout->setAlignment( Qt::AlignTop );
-    GroupConstructorsLayout->setSpacing( 6 );
-    GroupConstructorsLayout->setMargin( 11 );
-    Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
-    Constructor1->setText( tr( ""  ) );
-    Constructor1->setPixmap( image1 );
-    Constructor1->setChecked( TRUE );
-    Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
-    Constructor1->setMinimumSize( QSize( 50, 0 ) );
-    GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
-    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
-    GroupConstructorsLayout->addItem( spacer, 0, 1 );
-    SMESHGUI_InitMeshDlgLayout->addWidget( GroupConstructors, 0, 0 );
-    
-    /***************************************************************/
-    GroupButtons = new QGroupBox( this, "GroupButtons" );
-    GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
-    GroupButtons->setTitle( tr( ""  ) );
-    GroupButtons->setColumnLayout(0, Qt::Vertical );
-    GroupButtons->layout()->setSpacing( 0 );
-    GroupButtons->layout()->setMargin( 0 );
-    GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
-    GroupButtonsLayout->setAlignment( Qt::AlignTop );
-    GroupButtonsLayout->setSpacing( 6 );
-    GroupButtonsLayout->setMargin( 11 );
-    buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
-    buttonCancel->setText( tr( "SMESH_BUT_CLOSE"  ) );
-    buttonCancel->setAutoDefault( TRUE );
-    GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
-    buttonApply = new QPushButton( GroupButtons, "buttonApply" );
-    buttonApply->setText( tr( "SMESH_BUT_APPLY"  ) );
-    buttonApply->setAutoDefault( TRUE );
-    GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
-    QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
-    GroupButtonsLayout->addItem( spacer_9, 0, 2 );
-    buttonOk = new QPushButton( GroupButtons, "buttonOk" );
-    buttonOk->setText( tr( "SMESH_BUT_OK"  ) );
-    buttonOk->setAutoDefault( TRUE );
-    buttonOk->setDefault( TRUE );
-    GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
-    SMESHGUI_InitMeshDlgLayout->addWidget( GroupButtons, 2, 0 );
-
-    /***************************************************************/
-    GroupC1 = new QGroupBox( this, "GroupC1" );
-    GroupC1->setTitle( tr( "SMESH_ARGUMENTS"  ) );
-    GroupC1->setMinimumSize( QSize( 0, 0 ) );
-    GroupC1->setFrameShape( QGroupBox::Box );
-    GroupC1->setFrameShadow( QGroupBox::Sunken );
+    GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), this, "GroupC1" );
     GroupC1->setColumnLayout(0, Qt::Vertical );
     GroupC1->layout()->setSpacing( 0 );
     GroupC1->layout()->setMargin( 0 );
-    GroupC1Layout = new QGridLayout( GroupC1->layout() );
+    QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
     GroupC1Layout->setAlignment( Qt::AlignTop );
     GroupC1Layout->setSpacing( 6 );
     GroupC1Layout->setMargin( 11 );
 
-    TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
-    TextLabelC1A1->setText( tr( "SMESH_OBJECT_GEOM"  ) );
-    TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
-    TextLabelC1A1->setFrameShape( QLabel::NoFrame );
-    TextLabelC1A1->setFrameShadow( QLabel::Plain );
-    GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
+    TextLabel_NameMesh = new QLabel( tr( "SMESH_NAME" ), GroupC1, "TextLabel_NameMesh" );
+    GroupC1Layout->addWidget( TextLabel_NameMesh, 0, 0 );
+    LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" );
+    GroupC1Layout->addWidget( LineEdit_NameMesh, 0, 2 );
+
+    TextLabelC1A1 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A1" );
+    GroupC1Layout->addWidget( TextLabelC1A1, 1, 0 );
     SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
-    SelectButtonC1A1->setText( tr( ""  ) );
     SelectButtonC1A1->setPixmap( image0 );
     SelectButtonC1A1->setToggleButton( FALSE );
-    GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
+    GroupC1Layout->addWidget( SelectButtonC1A1, 1, 1 );
     LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
-    GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
+    GroupC1Layout->addWidget( LineEditC1A1, 1, 2 );
 
-    TextLabel_NameMesh = new QLabel( GroupC1, "TextLabel_NameMesh" );
-    TextLabel_NameMesh->setText( tr( "SMESH_NAME"  ) );
-    GroupC1Layout->addWidget( TextLabel_NameMesh, 1, 0 );
-    LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" );
-    GroupC1Layout->addWidget( LineEdit_NameMesh, 1, 2 );
-
-    TextLabelC1A1Hyp = new QLabel( GroupC1, "TextLabelC1A1Hyp" );
-    TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_HYPOTHESIS" ) );
-    TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) );
-    TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame );
-    TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain );
+    TextLabelC1A1Hyp = new QLabel( tr( "SMESH_OBJECT_HYPOTHESIS" ), GroupC1, "TextLabelC1A1Hyp" );
     GroupC1Layout->addWidget( TextLabelC1A1Hyp, 2, 0 );
     SelectButtonC1A1Hyp = new QPushButton( GroupC1, "SelectButtonC1A1Hyp" );
-    SelectButtonC1A1Hyp->setText( tr( ""  ) );
     SelectButtonC1A1Hyp->setPixmap( image0 );
     GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 2, 1 );
     LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" );
-    LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) );
     GroupC1Layout->addWidget( LineEditC1A1Hyp, 2, 2 );
 
-    TextLabelC1A1Algo = new QLabel( GroupC1, "TextLabelC1A1Algo" );
-    TextLabelC1A1Algo->setText( tr( "SMESH_OBJECT_ALGORITHM" ) );
-    TextLabelC1A1Algo->setMinimumSize( QSize( 50, 0 ) );
-    TextLabelC1A1Algo->setFrameShape( QLabel::NoFrame );
-    TextLabelC1A1Algo->setFrameShadow( QLabel::Plain );
+    TextLabelC1A1Algo = new QLabel( tr( "SMESH_OBJECT_ALGORITHM" ), GroupC1, "TextLabelC1A1Algo" );
     GroupC1Layout->addWidget( TextLabelC1A1Algo, 3, 0 );
     SelectButtonC1A1Algo = new QPushButton( GroupC1, "SelectButtonC1A1Algo" );
-    SelectButtonC1A1Algo->setText( tr( ""  ) );
     SelectButtonC1A1Algo->setPixmap( image0 );
     GroupC1Layout->addWidget( SelectButtonC1A1Algo, 3, 1 );
     LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" );
-    LineEditC1A1Algo->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Algo->sizePolicy().hasHeightForWidth() ) );
     GroupC1Layout->addWidget( LineEditC1A1Algo, 3, 2 );
 
     SMESHGUI_InitMeshDlgLayout->addWidget( GroupC1, 1, 0 );
+
     /***************************************************************/
+    GroupButtons = new QGroupBox( this, "GroupButtons" );
+    GroupButtons->setColumnLayout(0, Qt::Vertical );
+    GroupButtons->layout()->setSpacing( 0 );
+    GroupButtons->layout()->setMargin( 0 );
+    QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+    GroupButtonsLayout->setAlignment( Qt::AlignTop );
+    GroupButtonsLayout->setSpacing( 6 );
+    GroupButtonsLayout->setMargin( 11 );
+
+    buttonOk = new QPushButton( tr( "SMESH_BUT_OK" ), GroupButtons, "buttonOk" );
+    buttonOk->setAutoDefault( TRUE );
+    buttonOk->setDefault( TRUE );
+    GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+
+    buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons, "buttonApply" );
+    buttonApply->setAutoDefault( TRUE );
+    GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
+
+    GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 );
+
+    buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons, "buttonCancel" );
+    buttonCancel->setAutoDefault( TRUE );
+    GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
+
+    SMESHGUI_InitMeshDlgLayout->addWidget( GroupButtons, 2, 0 );
 
-    Init(Sel) ;
+    /***************************************************************/
+    Init( Sel ) ;
 }
 
 
@@ -206,108 +156,118 @@ SMESHGUI_InitMeshDlg::~SMESHGUI_InitMeshDlg()
 //=================================================================================
 void SMESHGUI_InitMeshDlg::Init( SALOME_Selection* Sel )
 {
-  GroupC1->show();
-  myConstructorId = 0 ;
-  Constructor1->setChecked( TRUE );
-  myEditCurrentArgument = LineEditC1A1 ;       
   mySelection = Sel;
   mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
   mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
 
-  myGeomFilter = new SALOME_TypeFilter( "GEOM" );
-  myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM );
+  myGeomFilter       = new SALOME_TypeFilter( "GEOM" );
+  myAlgorithmFilter  = new SMESH_TypeFilter( ALGORITHM );
   myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS );
 
-  myNameMesh = "Mesh";
-
   /* signals and slots connections */
-  connect( buttonOk, SIGNAL( clicked() ),     this, SLOT( ClickOnOk() ) );
-  connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
+  connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+  connect( buttonApply,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
-  connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
 
-  connect( SelectButtonC1A1, SIGNAL (clicked() ),   this, SLOT( SetEditCurrentArgument() ) ) ;
-  connect( LineEdit_NameMesh, SIGNAL (textChanged(const QString&)  ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
-
-  connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ),  this, SLOT( SetEditCurrentArgument() ) ) ;
+  connect( SelectButtonC1A1,     SIGNAL (clicked() ),  this, SLOT( SetEditCurrentArgument() ) ) ;
+  connect( SelectButtonC1A1Hyp,  SIGNAL (clicked() ),  this, SLOT( SetEditCurrentArgument() ) ) ;
   connect( SelectButtonC1A1Algo, SIGNAL (clicked() ),  this, SLOT( SetEditCurrentArgument() ) ) ;
 
-  connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
-  connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
-  connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
+  connect( mySelection, SIGNAL( currentSelectionChanged() ),      this, SLOT( SelectionIntoArgument() ) );
+  connect( mySMESHGUI,  SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
+  connect( mySMESHGUI,  SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) ) ;
   
   int x, y ;
   mySMESHGUI->DefineDlgPosition( this, x, y ) ;
   this->move( x, y ) ;
   this->show() ; 
 
-  return ;
-}
+  LineEdit_NameMesh->setText( tr( "SMESH_OBJECT_MESH" ) );
+  LineEdit_NameMesh->setFocus() ;
+  myEditCurrentArgument = LineEditC1A1 ;       
+  mySelection->ClearFilters() ;   
+  mySelection->AddFilter( myGeomFilter ) ;
 
+  SelectionIntoArgument();
 
-//=================================================================================
-// function : ConstructorsClicked()
-// purpose  : Radio button management
-//=================================================================================
-void SMESHGUI_InitMeshDlg::ConstructorsClicked(int constructorId)
-{
-  return ;
+  UpdateControlState();
 }
 
+
 //=================================================================================
 // function : ClickOnOk()
 // purpose  :
 //=================================================================================
 void SMESHGUI_InitMeshDlg::ClickOnOk()
 {
-  this->ClickOnApply() ;
-  this->ClickOnCancel() ;
-
-  return ;
+  if ( this->ClickOnApply() )
+    this->ClickOnCancel() ;
 }
 
 //=================================================================================
 // function : ClickOnApply()
 // purpose  :
 //=================================================================================
-void SMESHGUI_InitMeshDlg::ClickOnApply()
+bool SMESHGUI_InitMeshDlg::ClickOnApply()
 {
-  switch(myConstructorId)
-    { 
-    case 0 :
-      { 
-       MESSAGE ( " myNameMesh " << myNameMesh.isEmpty() )
-       MESSAGE ( " myGeomShape " << myGeomShape->_is_nil() )
-       if ( !myNameMesh.isEmpty() && !myNameMesh.isNull() && !myGeomShape->_is_nil() )
-         myMesh = mySMESHGUI->InitMesh( myGeomShape, myNameMesh ) ;
-       
-       MESSAGE ( " myMesh " << myMesh->_is_nil() ) 
-       MESSAGE ( " myOkHypothesis " )
-       MESSAGE ( " myOkAlgorithm " )
-       if( myOkHypothesis && !myMesh->_is_nil() ) {
-         SALOME_ListIteratorOfListIO It( HypoList );
-         for(;It.More();It.Next()) {
-           Handle(SALOME_InteractiveObject) IObject = It.Value();
-           Standard_Boolean testResult;
-           myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
-           if( testResult )
-             mySMESHGUI->AddHypothesisOnMesh(myMesh, myHypothesis) ;
+  QString myNameMesh = LineEdit_NameMesh->text().stripWhiteSpace();
+  if ( myNameMesh.isEmpty() ) {
+    QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) );
+    return false;
+  }
+  
+  if ( myGeomShape->_is_nil() || !HypoList.count() || !AlgoList.count() )
+    return false;
+
+  QAD_WaitCursor wc;
+
+  QAD_Operation* op = new QAD_Operation( mySMESHGUI->GetActiveStudy() );
+
+  // start transaction
+  op->start();
+  
+  // create mesh
+  SMESH::SMESH_Mesh_var aMesh = mySMESHGUI->InitMesh( myGeomShape, myNameMesh ) ;
+  
+  if ( !aMesh->_is_nil() ) {
+    // assign hypotheses
+    for( int i = 0; i < HypoList.count(); i++ ) {
+      SALOMEDS::SObject_var aHypSO = mySMESHGUI->GetStudy()->FindObjectID( HypoList[i] );
+      if ( !aHypSO->_is_nil() ) {
+       CORBA::Object_var anObject = aHypSO->GetObject();
+       if ( !CORBA::is_nil( anObject ) ) {
+         SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+         if ( !aHyp->_is_nil() ) {
+           if ( !mySMESHGUI->AddHypothesisOnMesh( aMesh, aHyp ) ) {
+             // abort transaction
+             op->abort();
+             return false;
+           }
          }
        }
-
-       if( myOkAlgorithm && !myMesh->_is_nil() ) {
-         SALOME_ListIteratorOfListIO It( AlgoList );
-         for(;It.More();It.Next()) {
-           Handle(SALOME_InteractiveObject) IObject = It.Value();
-           Standard_Boolean testResult;
-           myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
-           if( testResult )
-             mySMESHGUI->AddAlgorithmOnMesh(myMesh, myAlgorithm) ;
+      }
+    }
+    // assign algorithms
+    for( int i = 0; i < AlgoList.count(); i++ ) {
+      SALOMEDS::SObject_var aHypSO = mySMESHGUI->GetStudy()->FindObjectID( AlgoList[i] );
+      if ( !aHypSO->_is_nil() ) {
+       CORBA::Object_var anObject = aHypSO->GetObject();
+       if ( !CORBA::is_nil( anObject ) ) {
+         SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+         if ( !aHyp->_is_nil() ) {
+           if ( !mySMESHGUI->AddAlgorithmOnMesh( aMesh, aHyp ) ) {
+             // abort transaction
+             op->abort();
+             return false;
+           }
          }
        }
-       break ;
       }
     }
+  }
+  // commit transaction
+  op->finish();
+  return true;
 }
 
 
@@ -317,11 +277,7 @@ void SMESHGUI_InitMeshDlg::ClickOnApply()
 //=================================================================================
 void SMESHGUI_InitMeshDlg::ClickOnCancel()
 {
-  mySelection->ClearFilters() ;
-  disconnect( mySelection, 0, this, 0 );
-  mySMESHGUI->ResetState() ;
-  reject() ;
-  return ;
+  close();
 }
 
 
@@ -331,61 +287,60 @@ void SMESHGUI_InitMeshDlg::ClickOnCancel()
 //=================================================================================
 void SMESHGUI_InitMeshDlg::SelectionIntoArgument()
 {
-  myEditCurrentArgument->setText("") ;
   QString aString = ""; 
+
   int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+
   if ( myEditCurrentArgument == LineEditC1A1 ) {
+    // geom shape
     if ( nbSel != 1 ) {
-      myOkHypothesis = false;
-      myOkAlgorithm = false;
       myGeomShape = GEOM::GEOM_Shape::_nil();
-      return ;
-    } else {
+      aString = "";
+    } 
+    else {
       Standard_Boolean testResult ;
       Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
       myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
       if( !testResult )  {
-       myOkHypothesis = false;
-       myOkAlgorithm = false;
-       return ;
+       myGeomShape = GEOM::GEOM_Shape::_nil();
+       aString = "";
       }
     }
   }
   else if ( myEditCurrentArgument == LineEditC1A1Hyp ) {
+    // hypotheses
+    HypoList.clear();
     if ( nbSel >= 1 ) {
-      HypoList.Clear();
       SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
-      for (; Itinit.More(); Itinit.Next()) {
-       HypoList.Append(Itinit.Value());
+      for ( ; Itinit.More(); Itinit.Next() ) {
+       HypoList.append( Itinit.Value()->getEntry() );
       }
-      myOkHypothesis = true ;
-      if (nbSel > 1)
-       aString = tr("%1 Hypothesis").arg(nbSel) ;
-      LineEditC1A1Hyp->setText(aString) ;
+      if ( nbSel > 1 )
+       aString = tr( "%1 Hypothesis" ).arg( nbSel ) ;
     }
     else {
-      myOkHypothesis = false ;
-      return ;
+      aString = "";
     }
-  } else if ( myEditCurrentArgument == LineEditC1A1Algo ) {
+  }
+  else if ( myEditCurrentArgument == LineEditC1A1Algo ) {
+    // algorithms
+    AlgoList.clear(); 
     if ( nbSel >= 1 ) {
-      AlgoList.Clear(); 
       SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
-      for (; Itinit.More(); Itinit.Next()) {
-       AlgoList.Append(Itinit.Value());
+      for ( ; Itinit.More(); Itinit.Next() ) {
+       AlgoList.append( Itinit.Value()->getEntry() );
       }
-      myOkAlgorithm = true ;
-      if (nbSel > 1)
-       aString = tr("%1 Algorithms").arg(nbSel) ;
-      LineEditC1A1Algo->setText(aString) ;
+      if ( nbSel > 1 )
+       aString = tr( "%1 Algorithms" ).arg( nbSel ) ;
     }
     else {
-      myOkAlgorithm = false ;
-      return ;
+      aString = "";
     }
   }
 
   myEditCurrentArgument->setText(aString) ;
+
+  UpdateControlState();
 }
 
 
@@ -396,31 +351,23 @@ void SMESHGUI_InitMeshDlg::SelectionIntoArgument()
 void SMESHGUI_InitMeshDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
-  switch (myConstructorId)
-    {
-    case 0: /* default constructor */
-      {        
-       if(send == SelectButtonC1A1) {
-         LineEditC1A1->setFocus() ;
-         myEditCurrentArgument = LineEditC1A1;
-         mySelection->ClearFilters() ;   
-         mySelection->AddFilter(myGeomFilter) ;
-       } else if( send == SelectButtonC1A1Hyp ) {
-         LineEditC1A1Hyp->setFocus() ;
-         myEditCurrentArgument = LineEditC1A1Hyp ;
-         mySelection->ClearFilters() ;   
-         mySelection->AddFilter(myHypothesisFilter) ;
-       } else if( send == SelectButtonC1A1Algo ) {
-         LineEditC1A1Algo->setFocus() ;
-         myEditCurrentArgument = LineEditC1A1Algo ;
-         mySelection->ClearFilters() ;   
-         mySelection->AddFilter(myAlgorithmFilter) ;
-       }
-       SelectionIntoArgument() ;
-       break;
-      }
-    }
-  return ;
+  if(send == SelectButtonC1A1) {
+    LineEditC1A1->setFocus() ;
+    myEditCurrentArgument = LineEditC1A1;
+    mySelection->ClearFilters() ;        
+    mySelection->AddFilter(myGeomFilter) ;
+  } else if( send == SelectButtonC1A1Hyp ) {
+    LineEditC1A1Hyp->setFocus() ;
+    myEditCurrentArgument = LineEditC1A1Hyp ;
+    mySelection->ClearFilters() ;        
+    mySelection->AddFilter(myHypothesisFilter) ;
+  } else if( send == SelectButtonC1A1Algo ) {
+    LineEditC1A1Algo->setFocus() ;
+    myEditCurrentArgument = LineEditC1A1Algo ;
+    mySelection->ClearFilters() ;        
+    mySelection->AddFilter(myAlgorithmFilter) ;
+  }
+  SelectionIntoArgument() ;
 }
 
 //=================================================================================
@@ -429,9 +376,8 @@ void SMESHGUI_InitMeshDlg::SetEditCurrentArgument()
 //=================================================================================
 void SMESHGUI_InitMeshDlg::DeactivateActiveDialog()
 {
-  if ( GroupConstructors->isEnabled() ) {
+  if ( GroupC1->isEnabled() ) {
     disconnect( mySelection, 0, this, 0 );
-    GroupConstructors->setEnabled(false) ;
     GroupC1->setEnabled(false) ;
     GroupButtons->setEnabled(false) ;
   }
@@ -445,11 +391,9 @@ void SMESHGUI_InitMeshDlg::DeactivateActiveDialog()
 void SMESHGUI_InitMeshDlg::ActivateThisDialog()
 {
   mySMESHGUI->EmitSignalDeactivateDialog() ;   
-  GroupConstructors->setEnabled(true) ;
   GroupC1->setEnabled(true) ;
   GroupButtons->setEnabled(true) ;
   connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-  return ;
 }
 
 
@@ -459,10 +403,8 @@ void SMESHGUI_InitMeshDlg::ActivateThisDialog()
 //=================================================================================
 void SMESHGUI_InitMeshDlg::enterEvent(QEvent* e)
 {
-  if ( GroupConstructors->isEnabled() )
-    return ;  
-  ActivateThisDialog() ;
-  return ;
+  if ( !GroupC1->isEnabled() )
+    ActivateThisDialog() ;
 }
 
 
@@ -472,21 +414,25 @@ void SMESHGUI_InitMeshDlg::enterEvent(QEvent* e)
 //=================================================================================
 void SMESHGUI_InitMeshDlg::closeEvent( QCloseEvent* e )
 {
-  this->ClickOnCancel() ;
-  return ;
+  disconnect( mySelection, 0, this, 0 );
+  mySMESHGUI->ResetState() ;
+  mySelection->ClearFilters() ;
+  QDialog::closeEvent( e );
 }
 
 //=================================================================================
-// function : TextChangedInLineEdit()
+// function : UpdateControlState()
 // purpose  :
 //=================================================================================
-void SMESHGUI_InitMeshDlg::TextChangedInLineEdit(const QString& newText)
-{  
-  QLineEdit* send = (QLineEdit*)sender();
-  QString newT = strdup(newText) ;
-  
-  if (send == LineEdit_NameMesh) {
-    myNameMesh = newText;
-  }
-  return ;
+void SMESHGUI_InitMeshDlg::UpdateControlState()
+{
+  bool isEnabled = ( !myGeomShape->_is_nil() && HypoList.count() && AlgoList.count() );
+
+  buttonOk   ->setEnabled( isEnabled );
+  buttonApply->setEnabled( isEnabled );
 }
+
+
+
+
+
index 9d934183a79717365810c74d6f2ed9287c31c689..ec04b794246eb7bef7f13b7659c51423e3e36051 100644 (file)
@@ -34,8 +34,8 @@
 #include "SMESH_TypeFilter.hxx"
 
 // QT Includes
-#include <qvariant.h>
 #include <qdialog.h>
+#include <qstringlist.h>
 
 // IDL Headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(GEOM_Shape)
 #include CORBA_SERVER_HEADER(SMESH_Gen)
 
-class QVBoxLayout; 
-class QHBoxLayout; 
-class QGridLayout; 
-class QButtonGroup;
 class QGroupBox;
 class QLabel;
 class QLineEdit;
 class QPushButton;
-class QRadioButton;
 class SMESHGUI;
 
-
 //=================================================================================
 // class    : SMESHGUI_InitMeshDlg
 // purpose  :
@@ -67,42 +61,34 @@ public:
     SMESHGUI_InitMeshDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
     ~SMESHGUI_InitMeshDlg();
 
-private:
-
-    void Init( SALOME_Selection* Sel ) ;
+protected:
     void closeEvent( QCloseEvent* e ) ;
     void enterEvent ( QEvent * ) ;
 
+private:
+    void Init( SALOME_Selection* Sel ) ;
+
+    void UpdateControlState();
+
+private:
     SMESHGUI*                     mySMESHGUI ;
     SALOME_Selection*             mySelection ;
              
-    GEOM::GEOM_Shape_var                myGeomShape ;
-    int                           myConstructorId ; 
+    GEOM::GEOM_Shape_var          myGeomShape ;
     QLineEdit*                    myEditCurrentArgument; 
 
-    QString                       myNameMesh ;
-
     Handle(SALOME_TypeFilter)     myGeomFilter;
     Handle(SMESH_TypeFilter)      myHypothesisFilter;
     Handle(SMESH_TypeFilter)      myAlgorithmFilter;
 
-    SALOME_ListIO                 HypoList;
-    SALOME_ListIO                 AlgoList;
-
-    bool                          myOkHypothesis;
-    bool                          myOkAlgorithm;
-
-    SMESH::SMESH_Hypothesis_var   myHypothesis;
-    SMESH::SMESH_Hypothesis_var   myAlgorithm;
-
-    SMESH::SMESH_Mesh_var         myMesh;
+    QStringList                   HypoList;
+    QStringList                   AlgoList;
 
-    QButtonGroup* GroupConstructors;
-    QRadioButton* Constructor1;
     QGroupBox*    GroupButtons;
     QPushButton*  buttonOk;
     QPushButton*  buttonCancel;
     QPushButton*  buttonApply;
+
     QGroupBox*    GroupC1;
     QLabel*       TextLabel_NameMesh ;
     QLineEdit*    LineEdit_NameMesh ;
@@ -119,22 +105,13 @@ private:
     QLineEdit*    LineEditC1A1Algo;
 
 private slots:
-
-    void ConstructorsClicked(int constructorId);
     void ClickOnOk();
+    bool ClickOnApply();
     void ClickOnCancel();
-    void ClickOnApply();
     void SetEditCurrentArgument() ;
     void SelectionIntoArgument() ;
     void DeactivateActiveDialog() ;
     void ActivateThisDialog() ;
-    void TextChangedInLineEdit(const QString& newText) ;
-
-protected:
-    QGridLayout* SMESHGUI_InitMeshDlgLayout;
-    QGridLayout* GroupConstructorsLayout;
-    QGridLayout* GroupButtonsLayout;
-    QGridLayout* GroupC1Layout;
 };
 
 #endif // DIALOGBOX_INIT_MESH_H
index 473d2ab4555197d7cb26e3b0658a9406c081a22d..c85e86c50d4f11fb0e2991b70fb25d6865c64799 100644 (file)
@@ -32,369 +32,412 @@ using namespace std;
 #include "SMESHGUI.h"
 #include "QAD_Application.h"
 #include "QAD_Desktop.h"
+#include "QAD_WaitCursor.h"
 #include "utilities.h"
 
 // QT Includes
 #include <qgroupbox.h>
 #include <qlabel.h>
+#include <qframe.h>
+#include <qwidgetstack.h>
 #include <qlayout.h>
-#include <qvariant.h>
-#include <qtooltip.h>
-#include <qwhatsthis.h>
 #include <qmap.h>
 
-/* 
- *  Constructs a SMESHGUI_MeshInfosDlg which is a child of 'parent', with the 
- *  name 'name' and widget flags set to 'f' 
- *
- *  The dialog will by default be modeless, unless you set 'modal' to
- *  TRUE to construct a modal dialog.
- */
-SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg( QWidget* parent,  const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
-    : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
-    if ( !name )
-       setName( "SMESHGUI_MeshInfosDlg" );
-    setCaption( tr( "SMESH_MESHINFO_TITLE"  ) );
-    setSizeGripEnabled( TRUE );
-
-    SMESHGUI_MeshInfosDlgLayout = new QVBoxLayout( this ); 
-    SMESHGUI_MeshInfosDlgLayout->setSpacing( 6 );
-    SMESHGUI_MeshInfosDlgLayout->setMargin( 11 );
-
-    /****************************************************************/
-    GroupBox1 = new QGroupBox( this, "GroupBox1" );
-    GroupBox1->setTitle( tr( "SMESH_MESHINFO_NB1D"  ) );
-    GroupBox1->setColumnLayout(0, Qt::Vertical );
-    GroupBox1->layout()->setSpacing( 0 );
-    GroupBox1->layout()->setMargin( 0 );
-    QGridLayout* GroupBox1Layout = new QGridLayout( GroupBox1->layout() );
-    GroupBox1Layout->setAlignment( Qt::AlignTop );
-    GroupBox1Layout->setSpacing( 6 );
-    GroupBox1Layout->setMargin( 11 );
-
-    TextLabel11 = new QLabel( GroupBox1, "TextLabel11" );
-    TextLabel11->setMinimumWidth( 100 );
-    TextLabel11->setText( tr( "SMESH_MESHINFO_NODES"  ) );
-    GroupBox1Layout->addWidget( TextLabel11, 0, 0 );
-
-    TextLabel12 = new QLabel( GroupBox1, "TextLabel12" );
-    TextLabel12->setMinimumWidth( 100 );
-    TextLabel12->setText( tr( "SMESH_MESHINFO_EDGES"  ) );
-    GroupBox1Layout->addWidget( TextLabel12, 1, 0 );
-
-    TextLabel13 = new QLabel( GroupBox1, "TextLabel13" );
-    TextLabel13->setMinimumWidth( 100 );
-    GroupBox1Layout->addWidget( TextLabel13, 0, 1 );
-
-    TextLabel14 = new QLabel( GroupBox1, "TextLabel14" );
-    TextLabel14->setMinimumWidth( 100 );
-    GroupBox1Layout->addWidget( TextLabel14, 1, 1 );
-    SMESHGUI_MeshInfosDlgLayout->addWidget( GroupBox1 );
-
-    /****************************************************************/
-    GroupBox2 = new QGroupBox( this, "GroupBox2" );
-    GroupBox2->setTitle( tr( "SMESH_MESHINFO_NB2D"  ) );
-    GroupBox2->setColumnLayout(0, Qt::Vertical );
-    GroupBox2->layout()->setSpacing( 0 );
-    GroupBox2->layout()->setMargin( 0 );
-    QGridLayout* GroupBox2Layout = new QGridLayout( GroupBox2->layout() );
-    GroupBox2Layout->setAlignment( Qt::AlignTop );
-    GroupBox2Layout->setSpacing( 6 );
-    GroupBox2Layout->setMargin( 11 );
-
-    TextLabel21 = new QLabel( GroupBox2, "TextLabel21" );
-    TextLabel21->setMinimumWidth( 100 );
-    TextLabel21->setText( tr( "SMESH_MESHINFO_TRIANGLES"  ) );
-    GroupBox2Layout->addWidget( TextLabel21, 0, 0 );
-
-    TextLabel22 = new QLabel( GroupBox2, "TextLabel22" );
-    TextLabel22->setMinimumWidth( 100 );
-    TextLabel22->setText( tr( "SMESH_MESHINFO_QUADRANGLES"  ) );
-    GroupBox2Layout->addWidget( TextLabel22, 1, 0 );
-
-    TextLabel23 = new QLabel( GroupBox2, "TextLabel23" );
-    TextLabel23->setMinimumWidth( 100 );
-    GroupBox2Layout->addWidget( TextLabel23, 0, 1 );
-    
-    TextLabel24 = new QLabel( GroupBox2, "TextLabel24" );
-    TextLabel24->setMinimumWidth( 100 );
-    GroupBox2Layout->addWidget( TextLabel24, 1, 1 );
-    SMESHGUI_MeshInfosDlgLayout->addWidget( GroupBox2 );
-
-    /****************************************************************/
-    GroupBox3 = new QGroupBox( this, "GroupBox3" );
-    GroupBox3->setTitle( tr( "SMESH_MESHINFO_NB3D"  ) );
-    GroupBox3->setColumnLayout(0, Qt::Vertical );
-    GroupBox3->layout()->setSpacing( 0 );
-    GroupBox3->layout()->setMargin( 0 );
-    QGridLayout* GroupBox3Layout = new QGridLayout( GroupBox3->layout() );
-    GroupBox3Layout->setAlignment( Qt::AlignTop );
-    GroupBox3Layout->setSpacing( 6 );
-    GroupBox3Layout->setMargin( 11 );
-
-    TextLabel31 = new QLabel( GroupBox3, "TextLabel31" );
-    TextLabel31->setMinimumWidth( 100 );
-    TextLabel31->setText( tr( "SMESH_MESHINFO_TETRAS"  ) );
-    GroupBox3Layout->addWidget( TextLabel31, 0, 0 );
-
-    TextLabel32 = new QLabel( GroupBox3, "TextLabel32" );
-    TextLabel32->setMinimumWidth( 100 );
-    TextLabel32->setText( tr( "SMESH_MESHINFO_HEXAS"  ) );
-    GroupBox3Layout->addWidget( TextLabel32, 1, 0 );
-
-    TextLabel33 = new QLabel( GroupBox3, "TextLabel33" );
-    TextLabel33->setMinimumWidth( 100 );
-    GroupBox3Layout->addWidget( TextLabel33, 0, 1 );
-
-    TextLabel34 = new QLabel( GroupBox3, "TextLabel34" );
-    TextLabel34->setMinimumWidth( 100 );
-    GroupBox3Layout->addWidget( TextLabel34, 1, 1 );
-    SMESHGUI_MeshInfosDlgLayout->addWidget( GroupBox3 );
-
-    /****************************************************************/
-    QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
-    GroupButtons->setColumnLayout(0, Qt::Vertical );
-    GroupButtons->layout()->setSpacing( 0 );
-    GroupButtons->layout()->setMargin( 0 );
-    QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
-    GroupButtonsLayout->setAlignment( Qt::AlignTop );
-    GroupButtonsLayout->setSpacing( 6 );
-    GroupButtonsLayout->setMargin( 11 );
-
-    GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 0 );
-    buttonOk = new QPushButton( GroupButtons, "buttonOk" );
-    buttonOk->setText( tr( "SMESH_BUT_OK"  ) );
-    buttonOk->setAutoDefault( TRUE );
-    buttonOk->setDefault( TRUE );
-    GroupButtonsLayout->addWidget( buttonOk, 0, 1 );
-    GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 );
-    SMESHGUI_MeshInfosDlgLayout->addWidget( GroupButtons );
-    /****************************************************************/
-
-    Init( Sel ) ; 
-}
-
-/*  
- *  Destroys the object and frees any allocated resources
- */
-SMESHGUI_MeshInfosDlg::~SMESHGUI_MeshInfosDlg()
-{
-    // no need to delete child widgets, Qt does it all for us
-}
+#define COLONIZE( str )   ( QString( str ).contains( ":" ) > 0 ? QString( str ) : QString( str ) + " :"  )
 
 //=================================================================================
-// function : Init()
-// purpose  :
+/*!
+ *  SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg
+ * 
+ *  Constructor
+ */
 //=================================================================================
-void SMESHGUI_MeshInfosDlg::Init( SALOME_Selection* Sel )
-{  
-  mySelection = Sel ;
-
-  mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
-  myStudy = mySMESHGUI->GetActiveStudy()->getStudyDocument();
-
-  Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "SMESH");
-  myCompMesh = SMESH::SMESH_Gen::_narrow(comp);
-
-  int nbSel = mySelection->IObjectCount();
-
-  TextLabel13->setText( "0" );
-  TextLabel14->setText( "0" );
-  TextLabel23->setText( "0" );
-  TextLabel24->setText( "0" );
-  TextLabel33->setText( "0" );
-  TextLabel34->setText( "0" );
-
-  //gets the selected mesh
-  if ( nbSel == 1 ) {
-    Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject();
-    Standard_Boolean res;
-    myMesh = mySMESHGUI->ConvertIOinMesh( IObject, res );
-    if ( res )
-      DumpMeshInfos();
-  }
-
-  mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
-
-  /* signals and slots connections */
-  connect( buttonOk,    SIGNAL( clicked() ),                      this, SLOT( ClickOnOk() ) );
-  connect( mySMESHGUI,  SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
-  connect( mySelection, SIGNAL( currentSelectionChanged() ),      this, SLOT( SelectionIntoArgument() ) );
-  /* to close dialog if study change */
-  connect( mySMESHGUI,  SIGNAL ( SignalCloseAllDialogs() ),       this, SLOT( ClickOnOk() ) ) ;
-  /* Move widget on the botton right corner of main widget */
-  int x, y ;
-  mySMESHGUI->DefineDlgPosition( this, x, y ) ;
-  this->move( x, y ) ;
-  this->show() ; /* Displays Dialog */ 
-
-  return ;
+SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
+     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
+{
+  if ( !name )
+      setName( "SMESHGUI_MeshInfosDlg" );
+  setCaption( tr( "SMESH_MESHINFO_TITLE"  ) );
+  setSizeGripEnabled( TRUE );
+
+  myStartSelection = true;
+  myIsActiveWindow = true;
+
+  QVBoxLayout* aTopLayout = new QVBoxLayout( this ); 
+  aTopLayout->setSpacing( 6 );  aTopLayout->setMargin( 11 );
+
+  // select button & label
+  QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) );
+  mySelectBtn = new QPushButton( this, "mySelectBtn" );
+  mySelectBtn->setPixmap( image0 );
+  mySelectBtn->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
+
+  mySelectLab = new QLabel( this, "mySelectLab" );
+  mySelectLab->setAlignment( AlignCenter );
+  QFont fnt = mySelectLab->font(); fnt.setBold( true );
+  mySelectLab->setFont( fnt );
+
+  QHBoxLayout* aSelectLayout = new QHBoxLayout; 
+  aSelectLayout->setMargin( 0 ); aSelectLayout->setSpacing( 0 );
+  aSelectLayout->addWidget( mySelectBtn ); 
+  aSelectLayout->addWidget( mySelectLab );
+
+  // top widget stack
+  myWGStack = new QWidgetStack( this );
+
+  // no valid selection
+  QWidget* myBadWidget = new QWidget( myWGStack );
+  QVBoxLayout* aBadLayout = new QVBoxLayout( myBadWidget ); 
+  QLabel* myBadLab = new QLabel( tr( "SMESH_BAD_SELECTION" ), myBadWidget, "myBadLab" );
+  myBadLab->setAlignment( Qt::AlignCenter ); 
+  myBadLab->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+  aBadLayout->addWidget( myBadLab );
+  myWGStack->addWidget( myBadWidget, 0 );
+  
+  // mesh
+  myMeshWidget = new QWidget( myWGStack );
+  QGridLayout* aMeshLayout = new QGridLayout( myMeshWidget ); 
+  aMeshLayout->setSpacing( 6 );  aMeshLayout->setMargin( 0 );
+  myWGStack->addWidget( myMeshWidget );
+  
+  // --> name
+  QLabel* myMeshNameLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_NAME" ) ), myMeshWidget, "myMeshNameLab" );
+  myMeshName    = new QLabel( myMeshWidget, "myMeshName" );
+  myMeshName->setMinimumWidth( 100 );
+  QFrame* line1 = new QFrame( myMeshWidget );
+  line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+  
+  // --> nodes
+  QLabel* myMeshNbNodesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_NODES" ) ), myMeshWidget, "myMeshNbNodesLab" );
+  myMeshNbNodes    = new QLabel( myMeshWidget, "myMeshNbNodes" );
+  myMeshNbNodes->setMinimumWidth( 100 );
+  
+  // --> edges
+  QLabel* myMeshNbEdgesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_EDGES" ) ), myMeshWidget, "myMeshNbEdgesLab" );
+  myMeshNbEdges    = new QLabel( myMeshWidget, "myMeshNbEdges" );
+  myMeshNbEdges->setMinimumWidth( 100 );
+  
+  // --> faces
+  myMeshFacesGroup = new QGroupBox( tr( "SMESH_MESHINFO_FACES" ), myMeshWidget, "myMeshFacesGroup" );
+  myMeshFacesGroup->setColumnLayout(0, Qt::Vertical );
+  myMeshFacesGroup->layout()->setSpacing( 0 );  myMeshFacesGroup->layout()->setMargin( 0 );
+  QGridLayout* myMeshFacesGroupLayout = new QGridLayout( myMeshFacesGroup->layout() );
+  myMeshFacesGroupLayout->setAlignment( Qt::AlignTop );
+  myMeshFacesGroupLayout->setSpacing( 6 );  myMeshFacesGroupLayout->setMargin( 11 );
+
+  // --> faces --> total
+  QLabel* myMeshNbFacesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TOTAL" ) ), myMeshFacesGroup, "myMeshNbFacesLab" );
+  myMeshNbFacesLab->setFont( fnt );
+  myMeshNbFaces    = new QLabel( myMeshFacesGroup, "myMeshNbFaces" );
+  myMeshNbFaces->setMinimumWidth( 100 );
+  myMeshNbFaces->setFont( fnt );
+  
+  // --> faces --> triangles
+  QLabel* myMeshNbTrianglesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TRIANGLES" ) ), myMeshFacesGroup, "myMeshNbTrianglesLab" );
+  myMeshNbTriangles    = new QLabel( myMeshFacesGroup, "myMeshNbTriangles" );
+  myMeshNbTriangles->setMinimumWidth( 100 );
+  
+  // --> faces --> quadrangles
+  QLabel* myMeshNbQuadranglesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_QUADRANGLES" ) ), myMeshFacesGroup, "myMeshNbQuadranglesLab" );
+  myMeshNbQuadrangles    = new QLabel( myMeshFacesGroup, "myMeshNbQuadrangles" );
+  myMeshNbQuadrangles->setMinimumWidth( 100 );
+  
+  myMeshFacesGroupLayout->addWidget( myMeshNbFacesLab,       0, 0 );
+  myMeshFacesGroupLayout->addWidget( myMeshNbFaces,          0, 1 );
+  myMeshFacesGroupLayout->addWidget( myMeshNbTrianglesLab,   1, 0 );
+  myMeshFacesGroupLayout->addWidget( myMeshNbTriangles,      1, 1 );
+  myMeshFacesGroupLayout->addWidget( myMeshNbQuadranglesLab, 2, 0 );
+  myMeshFacesGroupLayout->addWidget( myMeshNbQuadrangles,    2, 1 );
+  
+  // --> volumes
+  myMeshVolumesGroup = new QGroupBox( tr( "SMESH_MESHINFO_VOLUMES" ), myMeshWidget, "myMeshVolumesGroup" );
+  myMeshVolumesGroup->setColumnLayout(0, Qt::Vertical );
+  myMeshVolumesGroup->layout()->setSpacing( 0 );  myMeshVolumesGroup->layout()->setMargin( 0 );
+  QGridLayout* myMeshVolumesGroupLayout = new QGridLayout( myMeshVolumesGroup->layout() );
+  myMeshVolumesGroupLayout->setAlignment( Qt::AlignTop );
+  myMeshVolumesGroupLayout->setSpacing( 6 );  myMeshVolumesGroupLayout->setMargin( 11 );
+  
+  // --> volumes --> total
+  QLabel* myMeshNbVolumesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TOTAL" ) ), myMeshVolumesGroup, "myMeshNbVolumesLab" );
+  myMeshNbVolumesLab->setFont( fnt );
+  myMeshNbVolumes    = new QLabel( myMeshVolumesGroup, "myMeshNbVolumes" );
+  myMeshNbVolumes->setMinimumWidth( 100 );
+  myMeshNbVolumes->setFont( fnt );
+  
+  // --> volumes --> tetrahedrons
+  QLabel* myMeshNbTetraLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TETRAS" ) ), myMeshVolumesGroup, "myMeshNbTetraLab" );
+  myMeshNbTetra    = new QLabel( myMeshVolumesGroup, "myMeshNbTetra" );
+  myMeshNbTetra->setMinimumWidth( 100 );
+  
+  // --> volumes --> hexahedrons
+  QLabel* myMeshNbHexaLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_HEXAS" ) ), myMeshVolumesGroup, "myMeshNbHexaLab" );
+  myMeshNbHexa    = new QLabel( myMeshVolumesGroup, "myMeshNbHexa" );
+  myMeshNbHexaLab->setMinimumWidth( 100 );
+  
+  // --> volumes --> prisms
+  QLabel* myMeshNbPrismLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_PRISMS" ) ), myMeshVolumesGroup, "myMeshNbPrismLab" );
+  myMeshNbPrism    = new QLabel( myMeshVolumesGroup, "myMeshNbPrism" );
+  myMeshNbPrism->setMinimumWidth( 100 );
+  
+  // --> volumes --> pyramids
+  QLabel* myMeshNbPyraLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_PYRAS" ) ), myMeshVolumesGroup, "myMeshNbPyraLab" );
+  myMeshNbPyra    = new QLabel( myMeshVolumesGroup, "myMeshNbPyra" );
+  myMeshNbPyra->setMinimumWidth( 100 );
+  
+  myMeshVolumesGroupLayout->addWidget( myMeshNbVolumesLab, 0, 0 );
+  myMeshVolumesGroupLayout->addWidget( myMeshNbVolumes,    0, 1 );
+  myMeshVolumesGroupLayout->addWidget( myMeshNbTetraLab,   1, 0 );
+  myMeshVolumesGroupLayout->addWidget( myMeshNbTetra,      1, 1 );
+  myMeshVolumesGroupLayout->addWidget( myMeshNbHexaLab,    2, 0 );
+  myMeshVolumesGroupLayout->addWidget( myMeshNbHexa,       2, 1 );
+  myMeshVolumesGroupLayout->addWidget( myMeshNbPrismLab,   3, 0 );
+  myMeshVolumesGroupLayout->addWidget( myMeshNbPrism,      3, 1 );
+  myMeshVolumesGroupLayout->addWidget( myMeshNbPyraLab,    4, 0 );
+  myMeshVolumesGroupLayout->addWidget( myMeshNbPyra,       4, 1 );
+  
+  aMeshLayout->addWidget( myMeshNameLab,          0, 0 );
+  aMeshLayout->addWidget( myMeshName,             0, 1 );
+  aMeshLayout->addMultiCellWidget( line1,   1, 1, 0, 1 );
+  aMeshLayout->addWidget( myMeshNbNodesLab,       2, 0 );
+  aMeshLayout->addWidget( myMeshNbNodes,          2, 1 );
+  aMeshLayout->addWidget( myMeshNbEdgesLab,       3, 0 );
+  aMeshLayout->addWidget( myMeshNbEdges,          3, 1 );
+  aMeshLayout->addMultiCellWidget( myMeshFacesGroup,   4, 4, 0, 1 );
+  aMeshLayout->addMultiCellWidget( myMeshVolumesGroup, 5, 5, 0, 1 );
+  aMeshLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ), 6, 0 );
+
+  // submesh
+  mySubMeshWidget = new QWidget( myWGStack );
+  QGridLayout* aSubMeshLayout = new QGridLayout( mySubMeshWidget ); 
+  aSubMeshLayout->setSpacing( 6 );  aSubMeshLayout->setMargin( 0 );
+  myWGStack->addWidget( mySubMeshWidget );
+  
+  // --> name
+  QLabel* mySubMeshNameLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_NAME" ) ), mySubMeshWidget, "mySubMeshNameLab" );
+  mySubMeshName    = new QLabel( mySubMeshWidget, "mySubMeshName" );
+  mySubMeshName->setMinimumWidth( 100 );
+  QFrame* line2 = new QFrame( mySubMeshWidget );
+  line2->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+  
+  // --> nodes
+  QLabel* mySubMeshNbNodesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_NODES" ) ), mySubMeshWidget, "mySubMeshNbNodesLab" );
+  mySubMeshNbNodes    = new QLabel( mySubMeshWidget, "mySubMeshNbNodes" );
+  mySubMeshNbNodes->setMinimumWidth( 100 );
+  
+  // --> elements
+  mySubMeshElementsGroup = new QGroupBox( tr( "SMESH_MESHINFO_ELEMENTS" ), mySubMeshWidget, "mySubMeshElementsGroup" );
+  mySubMeshElementsGroup->setColumnLayout(0, Qt::Vertical );
+  mySubMeshElementsGroup->layout()->setSpacing( 0 );  mySubMeshElementsGroup->layout()->setMargin( 0 );
+  QGridLayout* mySubMeshElementsGroupLayout = new QGridLayout( mySubMeshElementsGroup->layout() );
+  mySubMeshElementsGroupLayout->setAlignment( Qt::AlignTop );
+  mySubMeshElementsGroupLayout->setSpacing( 6 );  mySubMeshElementsGroupLayout->setMargin( 11 );
+
+  // --> elements --> total
+  QLabel* mySubMeshNbElementsLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TOTAL" ) ), mySubMeshElementsGroup, "mySubMeshNbElementsLab" );
+  mySubMeshNbElementsLab->setFont( fnt );
+  mySubMeshNbElements    = new QLabel( mySubMeshElementsGroup, "mySubMeshNbElements" );
+  mySubMeshNbElements->setMinimumWidth( 100 );
+  mySubMeshNbElements->setFont( fnt );
+  
+  // --> elements --> edges
+  QLabel* mySubMeshNbEdgesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_EDGES" ) ), mySubMeshElementsGroup, "mySubMeshNbEdgesLab" );
+  mySubMeshNbEdges    = new QLabel( mySubMeshElementsGroup, "mySubMeshNbEdges" );
+  mySubMeshNbEdges->setMinimumWidth( 100 );
+  
+  // --> elements --> faces
+  QLabel* mySubMeshNbFacesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_FACES" ) ), mySubMeshElementsGroup, "mySubMeshNbFacesLab" );
+  mySubMeshNbFaces    = new QLabel( mySubMeshElementsGroup, "mySubMeshNbFaces" );
+  mySubMeshNbFaces->setMinimumWidth( 100 );
+  
+  // --> elements --> volumes
+  QLabel* mySubMeshNbVolumesLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_VOLUMES" ) ), mySubMeshElementsGroup, "mySubMeshNbVolumesLab" );
+  mySubMeshNbVolumes    = new QLabel( mySubMeshElementsGroup, "mySubMeshNbVolumes" );
+  mySubMeshNbVolumes->setMinimumWidth( 100 );
+  
+  mySubMeshElementsGroupLayout->addWidget( mySubMeshNbElementsLab, 0, 0 );
+  mySubMeshElementsGroupLayout->addWidget( mySubMeshNbElements,    0, 1 );
+  mySubMeshElementsGroupLayout->addWidget( mySubMeshNbEdgesLab,    1, 0 );
+  mySubMeshElementsGroupLayout->addWidget( mySubMeshNbEdges,       1, 1 );
+  mySubMeshElementsGroupLayout->addWidget( mySubMeshNbFacesLab,    2, 0 );
+  mySubMeshElementsGroupLayout->addWidget( mySubMeshNbFaces,       2, 1 );
+  mySubMeshElementsGroupLayout->addWidget( mySubMeshNbVolumesLab,  3, 0 );
+  mySubMeshElementsGroupLayout->addWidget( mySubMeshNbVolumes,     3, 1 );
+
+  aSubMeshLayout->addWidget( mySubMeshNameLab,          0, 0 );
+  aSubMeshLayout->addWidget( mySubMeshName,             0, 1 );
+  aSubMeshLayout->addMultiCellWidget( line2,      1, 1, 0, 1 );
+  aSubMeshLayout->addWidget( mySubMeshNbNodesLab,       2, 0 );
+  aSubMeshLayout->addWidget( mySubMeshNbNodes,          2, 1 );
+  aSubMeshLayout->addMultiCellWidget( mySubMeshElementsGroup, 3, 3, 0, 1 );
+  aSubMeshLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 );
+
+  // group
+  myGroupWidget = new QWidget( myWGStack );
+  QGridLayout* myGroupWidgetLayout = new QGridLayout( myGroupWidget ); 
+  myGroupWidgetLayout->setSpacing( 6 );  myGroupWidgetLayout->setMargin( 0 );
+  myWGStack->addWidget( myGroupWidget );
+  
+  // --> name
+  QLabel* myGroupNameLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_NAME" ) ), myGroupWidget, "myGroupNameLab" );
+  myGroupName = new QLabel( myGroupWidget, "myGroupName" );
+  myGroupName->setMinimumWidth( 100 );
+  QFrame* line3 = new QFrame( myGroupWidget );
+  line3->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+  
+  // --> type
+  QLabel* myGroupTypeLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_TYPE" ) ), myGroupWidget, "myGroupTypeLab" );
+  myGroupType = new QLabel( myGroupWidget, "myGroupType" );
+  myGroupType->setMinimumWidth( 100 );
+
+  // --> number of entities
+  QLabel* myGroupNbLab = new QLabel( COLONIZE( tr( "SMESH_MESHINFO_ENTITIES" ) ), myGroupWidget, "myGroupNbLab" );
+  myGroupNb = new QLabel( myGroupWidget, "myGroupNb" );
+  myGroupNb->setMinimumWidth( 100 );
+  
+  myGroupWidgetLayout->addWidget( myGroupNameLab,       0, 0 );
+  myGroupWidgetLayout->addWidget( myGroupName,          0, 1 );
+  myGroupWidgetLayout->addMultiCellWidget( line3, 1, 1, 0, 1 );
+  myGroupWidgetLayout->addWidget( myGroupTypeLab,       2, 0 );
+  myGroupWidgetLayout->addWidget( myGroupType,          2, 1 );
+  myGroupWidgetLayout->addWidget( myGroupNbLab,         3, 0 );
+  myGroupWidgetLayout->addWidget( myGroupNb,            3, 1 );
+  myGroupWidgetLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 );
+
+  // buttons
+  myButtonsGroup = new QGroupBox( this, "myButtonsGroup" );
+  myButtonsGroup->setColumnLayout(0, Qt::Vertical );
+  myButtonsGroup->layout()->setSpacing( 0 );  myButtonsGroup->layout()->setMargin( 0 );
+  QHBoxLayout* myButtonsGroupLayout = new QHBoxLayout( myButtonsGroup->layout() );
+  myButtonsGroupLayout->setAlignment( Qt::AlignTop );
+  myButtonsGroupLayout->setSpacing( 6 ); myButtonsGroupLayout->setMargin( 11 );
+  
+  // buttons --> OK button
+  myOkBtn = new QPushButton( tr( "SMESH_BUT_OK"  ), myButtonsGroup, "myOkBtn" );
+  myOkBtn->setAutoDefault( TRUE ); myOkBtn->setDefault( TRUE );
+  myButtonsGroupLayout->addStretch();
+  myButtonsGroupLayout->addWidget( myOkBtn );
+  myButtonsGroupLayout->addStretch();
+
+  aTopLayout->addLayout( aSelectLayout );
+  aTopLayout->addWidget( myWGStack );
+  aTopLayout->addWidget( myButtonsGroup );
+  
+  mySelection = SALOME_Selection::Selection( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getSelection() );
+  SMESHGUI::GetSMESHGUI()->SetActiveDialogBox( this ) ;
+
+  // connect signals
+  connect( myOkBtn,                  SIGNAL( clicked() ),                      this, SLOT( close() ) );
+  connect( mySelectBtn,              SIGNAL( clicked() ),                      this, SLOT( onStartSelection() ) );
+  connect( SMESHGUI::GetSMESHGUI(),  SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( close() ) ) ;
+  connect( SMESHGUI::GetSMESHGUI(),  SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
+  connect( mySelection,              SIGNAL( currentSelectionChanged() ),      this, SLOT( onSelectionChanged() ) );
+
+  // resize and move dialog, then show
+  int x, y;
+  SMESHGUI::GetSMESHGUI()->DefineDlgPosition( this, x, y );
+  this->move( x, y );
+  this->show();
+
+  // init dialog with current selection
+  onSelectionChanged();
 }
 
 //=================================================================================
-// function : genEdgeKey
-// purpose  : edge counting helper;
-//            packs two long integers into one 8-byte value (treated as double by the caller);
-//            the order of arguments is insignificant
+/*!
+ *  SMESHGUI_MeshInfosDlg::~SMESHGUI_MeshInfosDlg
+ * 
+ *  Destructor
+ */
 //=================================================================================
-void genEdgeKey(long a, long b, void* key)
+SMESHGUI_MeshInfosDlg::~SMESHGUI_MeshInfosDlg()
 {
-  long* lKey = (long*)key;
-  *lKey     = (a < b) ? a : b;
-  *(++lKey) = (a < b) ? b : a;
 }
 
 //=================================================================================
-// function : DumpMeshInfos()
-// purpose  :
+/*!
+ *  SMESHGUI_MeshInfosDlg::DumpMeshInfos
+ */
 //=================================================================================
 void SMESHGUI_MeshInfosDlg::DumpMeshInfos()
 {
-  int nbOfNodes = myMesh->NbNodes();
-  int nbOfEdges = myMesh->NbEdges();
-  int nbOfTriangles = myMesh->NbTriangles();
-  int nbOfQuadrangles = myMesh->NbQuadrangles();
-  int nbOfTetras = myMesh->NbTetras();
-  int nbOfHexas = myMesh->NbHexas();
-
-  /*
-  int nbOfNodes = 0 ;
-  int nbOfEdges = 0 ;
-  int nbOfTriangles = 0 ;
-  int nbOfQuadrangles = 0 ;
-  int nbOfTetras = 0 ;
-  int nbOfHexas = 0 ;
-  int nbCells = 0 ;
-  int CellType = 0 ;
-  QMap<double, char> aMapOfEdges;
-
-  Standard_Boolean result;
-  SMESH_Actor* MeshActor = mySMESHGUI->FindActor(myMesh, result, true);
-
-  if ( result ) {
-    vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( MeshActor->DataSource );
-    vtkPoints *Pts = ugrid->GetPoints();
-    nbOfNodes = Pts->GetNumberOfPoints();
-    int nbCells = ugrid->GetNumberOfCells();
-
-    for ( int i = 0; i < nbCells; i++ ) {
-      vtkCell* cellPtr = ugrid->GetCell(i);
-      CellType = cellPtr->GetCellType();
-      switch (CellType)
-       {
-       case 3: //Edges
-         {
-           nbOfEdges++;
-           break;
-         }
-       case 5: //Triangles
-         {
-           nbOfTriangles++;
-           
-           for (int edgeNum = 0; edgeNum < 3; edgeNum++) {
-             vtkCell* edgePtr = cellPtr->GetEdge(edgeNum);
-             double anEdgeKey;
-             genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey);
-             if (!aMapOfEdges.contains(anEdgeKey)) {
-               nbOfEdges++;
-               aMapOfEdges.insert(anEdgeKey, 0);
-             }
-           }
-           break;
-         }
-       case 9: //Quadrangles
-         {
-           nbOfQuadrangles++;
-           
-           for (int edgeNum = 0; edgeNum < 4; edgeNum++) {
-             vtkCell* edgePtr = cellPtr->GetEdge(edgeNum);
-             double anEdgeKey;
-             genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey);
-             if (!aMapOfEdges.contains(anEdgeKey)) {
-               nbOfEdges++;
-               aMapOfEdges.insert(anEdgeKey, 0);
-             }
-           }
-           break;
-         }
-       case 10: //Tetraedras
-         {
-           nbOfTetras++;
-
-           for (int edgeNum = 0; edgeNum < 6; edgeNum++) {
-             vtkCell* edgePtr = cellPtr->GetEdge(edgeNum);
-             double anEdgeKey;
-             genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey);
-             if (!aMapOfEdges.contains(anEdgeKey)) {
-               nbOfEdges++;
-               aMapOfEdges.insert(anEdgeKey, 0);
-             }
-           }
-           break;
-         }
-       case 12: //Hexahedras
-         {
-           nbOfHexas++;
-
-           for (int edgeNum = 0; edgeNum < 12; edgeNum++) {
-             vtkCell* edgePtr = cellPtr->GetEdge(edgeNum);
-             double anEdgeKey;
-             genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey);
-             if (!aMapOfEdges.contains(anEdgeKey)) {
-               nbOfEdges++;
-               aMapOfEdges.insert(anEdgeKey, 0);
-             }
-           }
-           break;
+  QAD_WaitCursor wc;
+  int nbSel = mySelection->IObjectCount();
+  if ( nbSel == 1 ) {
+    myStartSelection = false;
+    mySelectLab->setText( "" );
+    Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject();
+    SALOMEDS::SObject_var aSO = SMESHGUI::GetSMESHGUI()->GetStudy()->FindObjectID( IObject->getEntry() );
+    if ( !aSO->_is_nil() ) {
+      CORBA::Object_var anObject = aSO->GetObject();
+      if ( !CORBA::is_nil( anObject ) ) {
+       SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( anObject );
+       if ( !aMesh->_is_nil() ) {
+         myWGStack->raiseWidget( myMeshWidget );
+         setCaption( tr( "SMESH_MESHINFO_TITLE" ) + " [" + tr("SMESH_OBJECT_MESH") +"]" );
+         myMeshName->setText( aSO->GetName() );
+         myMeshNbNodes->setNum( (int)aMesh->NbNodes() );
+         myMeshNbEdges->setNum( (int)aMesh->NbEdges() );
+         myMeshNbFaces->setNum( (int)aMesh->NbFaces() );
+         myMeshNbTriangles->setNum( (int)aMesh->NbTriangles() );
+         myMeshNbQuadrangles->setNum( (int)aMesh->NbQuadrangles() );
+         myMeshNbVolumes->setNum( (int)aMesh->NbVolumes() );
+         myMeshNbTetra->setNum( (int)aMesh->NbTetras() );
+         myMeshNbHexa->setNum( (int)aMesh->NbHexas() );
+         myMeshNbPrism->setNum( (int)aMesh->NbPrisms() );
+         myMeshNbPyra->setNum( (int)aMesh->NbPyramids() );
+         return;
+       }
+       SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( anObject );
+       if ( !aSubMesh->_is_nil() ) {
+         myWGStack->raiseWidget( mySubMeshWidget );
+         setCaption( tr( "SMESH_MESHINFO_TITLE" ) + " [" + tr("SMESH_SUBMESH") +"]" );
+         mySubMeshName->setText( aSO->GetName() );
+         mySubMeshNbNodes->setNum( (int)aSubMesh->GetNumberOfNodes() );
+         mySubMeshNbElements->setNum( (int)aSubMesh->GetNumberOfElements() );
+         mySubMeshNbEdges->setNum( (int)( aSubMesh->GetElementsByType( SMESH::EDGE )->length() ) );
+         mySubMeshNbFaces->setNum( (int)( aSubMesh->GetElementsByType( SMESH::FACE )->length() ) );
+         mySubMeshNbVolumes->setNum( (int)( aSubMesh->GetElementsByType( SMESH::VOLUME )->length() ) );
+         return;
+       }
+       SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( anObject );
+       if ( !aGroup->_is_nil() ) {
+         myWGStack->raiseWidget( myGroupWidget );
+         setCaption( tr( "SMESH_MESHINFO_TITLE" ) + " [" + tr("SMESH_GROUP") +"]" );
+         myGroupName->setText( aSO->GetName() );
+         int aType = aGroup->GetType();
+         QString strType;
+         switch ( aType ) {
+         case SMESH::NODE:
+           strType = "SMESH_MESHINFO_NODES"; break;
+         case SMESH::EDGE:
+           strType = "SMESH_MESHINFO_EDGES"; break;
+         case SMESH::FACE:
+           strType = "SMESH_MESHINFO_FACES"; break;
+         case SMESH::VOLUME:
+           strType = "SMESH_MESHINFO_VOLUMES"; break;
+         default:
+           strType = "SMESH_MESHINFO_ALL_TYPES"; break;
          }
+         
+         myGroupType->setText( tr( strType ) );
+         myGroupNb->setNum( (int)aGroup->Size() );
+         return;
        }
+      }
     }
   }
-  */
-  TextLabel13->setText( tr( "%1" ).arg(nbOfNodes) );
-  TextLabel14->setText( tr( "%1" ).arg(nbOfEdges) );
-  TextLabel23->setText( tr( "%1" ).arg(nbOfTriangles) );
-  TextLabel24->setText( tr( "%1" ).arg(nbOfQuadrangles) );
-  TextLabel33->setText( tr( "%1" ).arg(nbOfTetras) );
-  TextLabel34->setText( tr( "%1" ).arg(nbOfHexas) );
-}
-
-//=================================================================================
-// function : ClickOnOk()
-// purpose  :
-//=================================================================================
-void SMESHGUI_MeshInfosDlg::ClickOnOk()
-{
-  disconnect( mySelection, 0, this, 0 );
-  mySMESHGUI->ResetState() ;
-  reject() ;
-  return ;
+  myWGStack->raiseWidget( 0 );
+  setCaption( tr( "SMESH_MESHINFO_TITLE" ) );
 }
 
 //=================================================================================
 // function : SelectionIntoArgument()
 // purpose  : Called when selection has changed
 //=================================================================================
-void SMESHGUI_MeshInfosDlg::SelectionIntoArgument()
+void SMESHGUI_MeshInfosDlg::onSelectionChanged()
 {
-  TextLabel13->setText( "0" );
-  TextLabel14->setText( "0" );
-  TextLabel23->setText( "0" );
-  TextLabel24->setText( "0" );
-  TextLabel33->setText( "0" );
-  TextLabel34->setText( "0" );
-
-  int nbSel = mySelection->IObjectCount();
-  if ( nbSel == 1 ) {
-    Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject();
-    Standard_Boolean res;
-    myMesh = mySMESHGUI->ConvertIOinMesh( IObject, res );
-    if ( res ) 
-      DumpMeshInfos();
-  }
-  return ; 
+  if ( myStartSelection )
+    DumpMeshInfos();
 }
 
 
@@ -404,20 +447,21 @@ void SMESHGUI_MeshInfosDlg::SelectionIntoArgument()
 //=================================================================================
 void SMESHGUI_MeshInfosDlg::closeEvent( QCloseEvent* e )
 {
-  disconnect( mySelection, 0, this, 0 );
-  mySMESHGUI->ResetState() ;
-  reject() ;
-  return ;
+  SMESHGUI::GetSMESHGUI()->ResetState();
+  QDialog::closeEvent( e );
 }
 
 
 //=================================================================================
-// function : enterEvent()
-// purpose  : when mouse enter onto the QWidget
+// function : windowActivationChange()
+// purpose  : called when window is activated/deactivated
 //=================================================================================
-void SMESHGUI_MeshInfosDlg::enterEvent( QEvent *  )
+void SMESHGUI_MeshInfosDlg::windowActivationChange( bool oldActive )
 {
-  ActivateThisDialog() ;
+  QDialog::windowActivationChange( oldActive );
+  if ( isActiveWindow() && myIsActiveWindow != isActiveWindow() )
+    ActivateThisDialog() ;
+  myIsActiveWindow = isActiveWindow();
 }
 
 
@@ -428,8 +472,6 @@ void SMESHGUI_MeshInfosDlg::enterEvent( QEvent *  )
 void SMESHGUI_MeshInfosDlg::DeactivateActiveDialog()
 {
   disconnect( mySelection, 0, this, 0 );
-
-  return ;
 }
 
 
@@ -440,8 +482,18 @@ void SMESHGUI_MeshInfosDlg::DeactivateActiveDialog()
 void SMESHGUI_MeshInfosDlg::ActivateThisDialog()
 {
   /* Emit a signal to deactivate any active dialog */
-  mySMESHGUI->EmitSignalDeactivateDialog() ;
-
-  return ;
+  SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ;
+  connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
 }
 
+//=================================================================================
+// function : onStartSelection()
+// purpose  : starts selection
+//=================================================================================
+void SMESHGUI_MeshInfosDlg::onStartSelection()
+{
+  myStartSelection = true;
+  onSelectionChanged();
+  myStartSelection = true;
+  mySelectLab->setText( tr( "INF_SELECT_OBJECT" ) );
+}
index bef45b9b2d2ca006097251a24ab6491c8e5be374..c5f65073d3321e8c5fc368d90631f3e9f2f6973a 100644 (file)
 #ifndef SMESHGUI_MESHINFOSDLG_H
 #define SMESHGUI_MESHINFOSDLG_H
 
-#include "SALOME_Selection.h"
-#include "QAD_Study.h"
-
 // IDL Headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_Gen)
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
 
 // QT Includes
-#include <qvariant.h>
 #include <qdialog.h>
-class QVBoxLayout; 
-class QHBoxLayout; 
-class QGridLayout; 
+
 class QGroupBox;
 class QLabel;
 class QPushButton;
-class SMESHGUI;
+class SALOME_Selection;
+class QWidgetStack;
 
 class SMESHGUI_MeshInfosDlg : public QDialog
 { 
     Q_OBJECT
 
 public:
-    SMESHGUI_MeshInfosDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+    SMESHGUI_MeshInfosDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
     ~SMESHGUI_MeshInfosDlg();
 
-private:
-
-    void Init( SALOME_Selection* Sel ) ;
-    void closeEvent( QCloseEvent* e ) ;
-    void enterEvent ( QEvent * ) ;                /* mouse enter the QWidget */
+protected:
+    void closeEvent( QCloseEvent* e );
+    void windowActivationChange( bool oldActive );
     void DumpMeshInfos();
 
-    SMESH::SMESH_Gen_var  myCompMesh ;                
-    SMESHGUI*             mySMESHGUI ;            
-    SMESH::SMESH_Mesh_var myMesh ;            
-    SALOME_Selection*     mySelection ; 
-    SALOMEDS::Study_var   myStudy;
+private slots:
+    void onSelectionChanged();
+    void DeactivateActiveDialog() ;
+    void ActivateThisDialog();
+    void onStartSelection();
 
-    QGroupBox* GroupBox1;
-    QLabel* TextLabel12;
-    QLabel* TextLabel11;
-    QLabel* TextLabel13;
-    QLabel* TextLabel14;
-    QGroupBox* GroupBox2;
-    QLabel* TextLabel21;
-    QLabel* TextLabel22;
-    QLabel* TextLabel23;
-    QLabel* TextLabel24;
-    QGroupBox* GroupBox3;
-    QLabel* TextLabel31;
-    QLabel* TextLabel32;
-    QLabel* TextLabel33;
-    QLabel* TextLabel34;
-    QPushButton* buttonOk;
+private:
+    SALOME_Selection*     mySelection; 
+    bool                  myStartSelection;
+    bool                  myIsActiveWindow;
+    
+    QPushButton*  mySelectBtn;
+    QLabel*       mySelectLab;
 
-private slots:
+    QWidgetStack* myWGStack;
 
-    void ClickOnOk();
-    void SelectionIntoArgument() ;
-    void DeactivateActiveDialog() ;
-    void ActivateThisDialog() ;
+    QWidget*      myMeshWidget;
+    QLabel*       myMeshName;
+    QLabel*       myMeshNbNodes;
+    QLabel*       myMeshNbEdges;
+    QGroupBox*    myMeshFacesGroup;
+    QLabel*       myMeshNbFaces;
+    QLabel*       myMeshNbTriangles;
+    QLabel*       myMeshNbQuadrangles;
+    QGroupBox*    myMeshVolumesGroup;
+    QLabel*       myMeshNbVolumes;
+    QLabel*       myMeshNbTetra;
+    QLabel*       myMeshNbHexa;
+    QLabel*       myMeshNbPyra;
+    QLabel*       myMeshNbPrism;
+    
+    QWidget*      mySubMeshWidget;
+    QLabel*       mySubMeshName;
+    QLabel*       mySubMeshNbNodes;
+    QGroupBox*    mySubMeshElementsGroup;
+    QLabel*       mySubMeshNbElements;
+    QLabel*       mySubMeshNbEdges;
+    QLabel*       mySubMeshNbFaces;
+    QLabel*       mySubMeshNbVolumes;
 
-protected:
-    QVBoxLayout* SMESHGUI_MeshInfosDlgLayout;
-    QHBoxLayout* Layout1;
+    QWidget*      myGroupWidget;
+    QLabel*       myGroupName;
+    QLabel*       myGroupType;
+    QLabel*       myGroupNb;
 
+    QGroupBox*   myButtonsGroup;
+    QPushButton* myOkBtn;
 };
 
 #endif // SMESHGUI_MESHINFOSDLG_H
index 72c2f95e7c4e7fcef0c5df8a72e2276a13d212bc..f44ffac11611e6240a16c751fd26bf1906829851 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 #include "SMESHGUI_MoveNodesDlg.h"
-#include "SMESHGUI.h"
 #include "SMESHGUI_SpinBox.h"
+#include "SMESH_Actor.h"
+#include "SMESHGUI.h"
 
 #include "QAD_Application.h"
 #include "QAD_Desktop.h"
@@ -53,8 +53,7 @@ using namespace std;
 // Open CASCADE Include
 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
 
-// VTK Include
-#include <vtkActor.h>
+using namespace std;
 
 //=================================================================================
 // class    : SMESHGUI_MoveNodesDlg()
@@ -309,7 +308,7 @@ void SMESHGUI_MoveNodesDlg::ClickOnOk()
 //=================================================================================
 void SMESHGUI_MoveNodesDlg::ClickOnCancel()
 {
-  QAD_Application::getDesktop()->SetSelectionMode( 4 );
+  QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
   disconnect( mySelection, 0, this, 0 );
   mySMESHGUI->ResetState() ;
   mySMESHGUI->EraseSimulationActors();
@@ -347,9 +346,9 @@ void SMESHGUI_MoveNodesDlg::SelectionIntoArgument()
     return ;
   }
   
-  if ( mySelection->SelectionMode() != 1 ){
+  if ( mySelection->SelectionMode() != NodeSelection ){
     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
-                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
+                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") );
     return;
   }
 
index 8a757402ee2b76fea0fe9031806fb78318689e3e..5ae62afc1e539a30836af819824cf36706336dc5 100644 (file)
@@ -284,7 +284,7 @@ void SMESHGUI_NodesDlg::ClickOnApply()
 //=======================================================================
 void SMESHGUI_NodesDlg::ClickOnCancel()
 {
-  QAD_Application::getDesktop()->SetSelectionMode( 4 );
+  QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
   disconnect( mySelection, 0, this, 0 );
   myMeshGUI->ResetState() ;
   myMeshGUI->EraseSimulationActors() ;
@@ -316,12 +316,12 @@ void SMESHGUI_NodesDlg::SelectionIntoArgument()
     return ;
   }
   
-  if ( mySelection->SelectionMode() != 1 ) {
+  if ( mySelection->SelectionMode() != NodeSelection ) {
     SpinBox_X->SetValue(0.0) ;
     SpinBox_Y->SetValue(0.0) ;
     SpinBox_Z->SetValue(0.0) ;
     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
-                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
+                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") );
     return;
   }
 
@@ -345,7 +345,7 @@ void SMESHGUI_NodesDlg::SelectionIntoArgument()
 
     Standard_Boolean result;
     SMESH_Actor* ac = myMeshGUI->FindActor( myMesh, result, true );
-    vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource );
+    vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->GetUnstructuredGrid() );
     float *p0 = ugrid->GetPoint(idNodes[0]);
 
     SpinBox_X->SetValue( p0[0] ) ;
index dbcc09c751de7814bd938c3e2518f5850cb3a42e..92b7101a50806da001a2e4708dc64c33b557a746 100644 (file)
@@ -249,7 +249,7 @@ void SMESHGUI_OrientationElementsDlg::ClickOnOk()
 //=================================================================================
 void SMESHGUI_OrientationElementsDlg::ClickOnCancel()
 {
-  QAD_Application::getDesktop()->SetSelectionMode( 4 );
+  QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
   disconnect( mySelection, 0, this, 0 );
   mySMESHGUI->ResetState() ;
   reject() ;
@@ -275,9 +275,9 @@ void SMESHGUI_OrientationElementsDlg::SelectionIntoArgument()
   if(nbElements < 1)
     return ;
   
-  if ( mySelection->SelectionMode() != 3 ) {
+  if ( mySelection->SelectionMode() != FaceSelection ) {
     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
-                           tr ("SMESH_WRN_SELECTIONMODE_ELEMENTS"), tr ("SMESH_BUT_YES") );
+                           tr ("SMESH_WRN_SELECTIONMODE_ELEMENTS"), tr ("SMESH_BUT_OK") );
     return;
   }
 
index 0608341655aaa5af3f43bba08179ba432e9248e8..1989d2c146f01c5ddd767198391d8c4939d7f7af 100644 (file)
@@ -28,6 +28,7 @@
 
 using namespace std;
 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
+#include "SMESHGUI.h"
 
 #include <qbuttongroup.h>
 #include <qcheckbox.h>
@@ -36,171 +37,695 @@ using namespace std;
 #include <qlabel.h>
 #include <qlineedit.h>
 #include <qpushbutton.h>
+#include <qtoolbutton.h>
 #include <qradiobutton.h>
 #include <qspinbox.h>
 #include <qlayout.h>
-#include <qvariant.h>
-#include <qtooltip.h>
-#include <qwhatsthis.h>
+#include <qvalidator.h>
+#include <qcolordialog.h>
 
-/* 
- *  Constructs a SMESHGUI_Preferences_ScalarBarDlg which is a child of 'parent', with the 
- *  name 'name' and widget flags set to 'f' 
+#include <vtkTextProperty.h>
+#include <vtkScalarBarActor.h>
+
+#include "QAD_SpinBoxDbl.h"
+#include "QAD_Config.h"
+#include "SALOME_Selection.h"
+#include "SMESHGUI.h"
+#include "SMESH_Actor.h"
+
+#define MINIMUM_WIDTH 70
+#define MARGIN_SIZE   11
+#define SPACING_SIZE   6
+
+#define DEF_VER_X  0.01
+#define DEF_VER_Y  0.10
+#define DEF_VER_H  0.80
+#define DEF_VER_W  0.10
+#define DEF_HOR_X  0.20
+#define DEF_HOR_Y  0.01
+#define DEF_HOR_H  0.12
+#define DEF_HOR_W  0.60
+
+// Only one instance is allowed
+SMESHGUI_Preferences_ScalarBarDlg* SMESHGUI_Preferences_ScalarBarDlg::myDlg = 0;
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties
+ *
+ *  Gets the only instance of "Scalar Bar Properties" dialog box
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties(QWidget* parent, 
+                                                           SALOME_Selection* Sel)
+{
+  if ( !myDlg ) {
+    myDlg = new SMESHGUI_Preferences_ScalarBarDlg( parent, Sel, false );
+    myDlg->show();
+  }
+  else {
+    myDlg->show();
+    myDlg->setActiveWindow();
+    myDlg->raise();
+    myDlg->setFocus();
+  }
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences
+ *
+ *  Opens "Scalar Bar Preferences" dialog box
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( QWidget* parent )
+{
+  SMESHGUI_Preferences_ScalarBarDlg* aDlg = new SMESHGUI_Preferences_ScalarBarDlg( parent, 0, true );
+  aDlg->exec();
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg
  *
- *  The dialog will by default be modeless, unless you set 'modal' to
- *  TRUE to construct a modal dialog.
+ *  Constructor
  */
-SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
-    : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+//=================================================================================================
+SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg(QWidget* parent, 
+                                                                    SALOME_Selection* Sel, 
+                                                                    bool modal)
+     : QDialog( parent, 0, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
 {
-    if ( !name )
-       setName( "SMESHGUI_Preferences_ScalarBarDlg" );
-    setCaption( tr( "SMESH_PREFERENCES_SCALARBAR"  ) );
-    setSizeGripEnabled( TRUE );
-
-    grid = new QGridLayout( this ); 
-    grid->setSpacing( 6 );
-    grid->setMargin( 11 );
-
-    /******************************************************************************/
-    Properties = new QGroupBox( this, "Properties" );
-    Properties->setTitle( tr( "SMESH_PROPERTIES"  ) );
-    Properties->setColumnLayout(0, Qt::Vertical );
-    Properties->layout()->setSpacing( 0 );
-    Properties->layout()->setMargin( 0 );
-    grid_4 = new QGridLayout( Properties->layout() );
-    grid_4->setAlignment( Qt::AlignTop );
-    grid_4->setSpacing( 6 );
-    grid_4->setMargin( 11 );
-
-    /* Font */
-    grid_5 = new QGridLayout; 
-    grid_5->setSpacing( 6 );
-    grid_5->setMargin( 0 );
-    TextLabel2 = new QLabel( Properties, "TextLabel2" );
-    TextLabel2->setText( tr( "SMESH_FONT"  ) );
-    grid_5->addWidget( TextLabel2, 0, 0 );
-    ComboBox1 = new QComboBox( FALSE, Properties, "ComboBox1" );
-    ComboBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-    ComboBox1->insertItem( tr( "SMESH_FONT_ARIAL" ) );
-    ComboBox1->insertItem( tr( "SMESH_FONT_COURIER" ) );
-    ComboBox1->insertItem( tr( "SMESH_FONT_TIMES" ) );
-    grid_5->addWidget( ComboBox1, 0, 1 );
-    grid_4->addLayout( grid_5, 0, 0 );
+  setName( "SMESHGUI_Preferences_ScalarBarDlg" );
+  setCaption( Sel ? tr( "SMESH_PROPERTIES_SCALARBAR" ) : tr( "SMESH_PREFERENCES_SCALARBAR" ) );
+  setSizeGripEnabled( TRUE );
+
+  mySelection = Sel;
+  myActor = 0;
+
+  /******************************************************************************/
+  // Top layout
+  QGridLayout* aTopLayout = new QGridLayout( this );
+  aTopLayout->setSpacing( SPACING_SIZE ); aTopLayout->setMargin( MARGIN_SIZE );
+  int aRow = 0;
+
+  /******************************************************************************/
+  // Scalar range
+  if ( mySelection ) {
+    myRangeGrp = new QGroupBox ( tr( "SMESH_RANGE_SCALARBAR" ), this, "myRangeGrp" );
+    myRangeGrp->setColumnLayout( 0, Qt::Vertical );
+    myRangeGrp->layout()->setSpacing( 0 ); myRangeGrp->layout()->setMargin( 0 );
+    QGridLayout* myRangeGrpLayout = new QGridLayout( myRangeGrp->layout() );
+    myRangeGrpLayout->setAlignment( Qt::AlignTop );
+    myRangeGrpLayout->setSpacing( SPACING_SIZE ); myRangeGrpLayout->setMargin( MARGIN_SIZE );
+    
+    myMinEdit = new QLineEdit( myRangeGrp, "myMinEdit" );
+    myMinEdit->setMinimumWidth( MINIMUM_WIDTH );
+    myMinEdit->setValidator( new QDoubleValidator( this ) );
+
+    myMaxEdit = new QLineEdit( myRangeGrp, "myMaxEdit" );
+    myMaxEdit->setMinimumWidth( MINIMUM_WIDTH );
+    myMaxEdit->setValidator( new QDoubleValidator( this ) );
+
+    myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MIN" ), myRangeGrp, "myMinLab" ), 0, 0 );
+    myRangeGrpLayout->addWidget( myMinEdit, 0, 1 );
+    myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MAX" ), myRangeGrp, "myMaxLab" ), 0, 2 );
+    myRangeGrpLayout->addWidget( myMaxEdit, 0, 3 );
+
+    aTopLayout->addWidget( myRangeGrp, aRow, 0 );
+    aRow++;
+  }
+
+  /******************************************************************************/
+  // Text properties
+  myFontGrp = new QGroupBox ( tr( "SMESH_FONT_SCALARBAR" ), this, "myFontGrp" );
+  myFontGrp->setColumnLayout( 0, Qt::Vertical );
+  myFontGrp->layout()->setSpacing( 0 ); myFontGrp->layout()->setMargin( 0 );
+  QGridLayout* myFontGrpLayout = new QGridLayout( myFontGrp->layout() );
+  myFontGrpLayout->setAlignment( Qt::AlignTop );
+  myFontGrpLayout->setSpacing( SPACING_SIZE ); myFontGrpLayout->setMargin( MARGIN_SIZE );
+    
+  myTitleColorBtn = new QToolButton( myFontGrp, "myTitleColorBtn" );
+  
+  myTitleFontCombo = new QComboBox( false, myFontGrp, "myTitleFontCombo" );
+  myTitleFontCombo->setMinimumWidth( MINIMUM_WIDTH );
+  myTitleFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myTitleFontCombo->insertItem( tr( "SMESH_FONT_ARIAL" ) );
+  myTitleFontCombo->insertItem( tr( "SMESH_FONT_COURIER" ) );
+  myTitleFontCombo->insertItem( tr( "SMESH_FONT_TIMES" ) );
+  
+  myTitleBoldCheck   = new QCheckBox( tr( "SMESH_FONT_BOLD" ),   myFontGrp, "myTitleBoldCheck" );
+  myTitleItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp, "myTitleItalicCheck" );
+  myTitleShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp, "myTitleShadowCheck" );
+
+  myLabelsColorBtn = new QToolButton( myFontGrp, "myLabelsColorBtn" );
+  
+  myLabelsFontCombo = new QComboBox( false, myFontGrp, "myLabelsFontCombo" );
+  myLabelsFontCombo->setMinimumWidth( MINIMUM_WIDTH );
+  myLabelsFontCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myLabelsFontCombo->insertItem( tr( "SMESH_FONT_ARIAL" ) );
+  myLabelsFontCombo->insertItem( tr( "SMESH_FONT_COURIER" ) );
+  myLabelsFontCombo->insertItem( tr( "SMESH_FONT_TIMES" ) );
+  
+  myLabelsBoldCheck   = new QCheckBox( tr( "SMESH_FONT_BOLD" ),   myFontGrp, "myLabelsBoldCheck" );
+  myLabelsItalicCheck = new QCheckBox( tr( "SMESH_FONT_ITALIC" ), myFontGrp, "myLabelsItalicCheck" );
+  myLabelsShadowCheck = new QCheckBox( tr( "SMESH_FONT_SHADOW" ), myFontGrp, "myLabelsShadowCheck" );
+
+  myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_TITLE" ), myFontGrp, "myFontTitleLab" ), 0, 0 );
+  myFontGrpLayout->addWidget( myTitleColorBtn,    0, 1 );
+  myFontGrpLayout->addWidget( myTitleFontCombo,   0, 2 );
+  myFontGrpLayout->addWidget( myTitleBoldCheck,   0, 3 );
+  myFontGrpLayout->addWidget( myTitleItalicCheck, 0, 4 );
+  myFontGrpLayout->addWidget( myTitleShadowCheck, 0, 5 );
+  
+  myFontGrpLayout->addWidget( new QLabel( tr( "SMESH_LABELS" ), myFontGrp, "myFontLabelsLab" ), 1, 0 );
+  myFontGrpLayout->addWidget( myLabelsColorBtn,    1, 1 );
+  myFontGrpLayout->addWidget( myLabelsFontCombo,   1, 2 );
+  myFontGrpLayout->addWidget( myLabelsBoldCheck,   1, 3 );
+  myFontGrpLayout->addWidget( myLabelsItalicCheck, 1, 4 );
+  myFontGrpLayout->addWidget( myLabelsShadowCheck, 1, 5 );
+
+  aTopLayout->addWidget( myFontGrp, aRow, 0 );
+  aRow++;
+
+  /******************************************************************************/
+  // Labels & Colors
+  myLabColorGrp = new QGroupBox ( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), this, "myLabColorGrp" );
+  myLabColorGrp->setColumnLayout( 0, Qt::Vertical );
+  myLabColorGrp->layout()->setSpacing( 0 ); myLabColorGrp->layout()->setMargin( 0 );
+  QGridLayout* myLabColorGrpLayout = new QGridLayout( myLabColorGrp->layout() );
+  myLabColorGrpLayout->setAlignment( Qt::AlignTop );
+  myLabColorGrpLayout->setSpacing( SPACING_SIZE ); myLabColorGrpLayout->setMargin( MARGIN_SIZE );
+    
+  myColorsSpin = new QSpinBox( 2, 256, 1, myLabColorGrp, "myColorsSpin" );
+  myColorsSpin->setMinimumWidth( MINIMUM_WIDTH );
+  myColorsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  myLabelsSpin = new QSpinBox( 2, 65, 1, myLabColorGrp, "myLabelsSpin" );
+  myLabelsSpin->setMinimumWidth( MINIMUM_WIDTH );
+  myLabelsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFCOLORS" ), myLabColorGrp, "myNbColorLab" ), 0, 0 );
+  myLabColorGrpLayout->addWidget( myColorsSpin, 0, 1 );
+  myLabColorGrpLayout->addWidget( new QLabel( tr( "SMESH_NUMBEROFLABELS" ), myLabColorGrp, "myNbLabsLab" ), 0, 2 );
+  myLabColorGrpLayout->addWidget( myLabelsSpin, 0, 3 );
+
+  aTopLayout->addWidget( myLabColorGrp, aRow, 0 );
+  aRow++;
+
+  /******************************************************************************/
+  // Orientation
+  myOrientationGrp = new QButtonGroup ( tr( "SMESH_ORIENTATION" ), this, "myOrientationGrp" );
+  myOrientationGrp->setColumnLayout( 0, Qt::Vertical );
+  myOrientationGrp->layout()->setSpacing( 0 ); myOrientationGrp->layout()->setMargin( 0 );
+  QGridLayout* myOrientationGrpLayout = new QGridLayout( myOrientationGrp->layout() );
+  myOrientationGrpLayout->setAlignment( Qt::AlignTop );
+  myOrientationGrpLayout->setSpacing( SPACING_SIZE ); myOrientationGrpLayout->setMargin( MARGIN_SIZE );
+    
+  myVertRadioBtn  = new QRadioButton( tr( "SMESH_VERTICAL" ),   myOrientationGrp, "myVertRadioBtn" );
+  myHorizRadioBtn = new QRadioButton( tr( "SMESH_HORIZONTAL" ), myOrientationGrp, "myHorizRadioBtn" );
+  myVertRadioBtn->setChecked( true );
+
+  myOrientationGrpLayout->addWidget( myVertRadioBtn,  0, 0 );
+  myOrientationGrpLayout->addWidget( myHorizRadioBtn, 0, 1 );
+
+  aTopLayout->addWidget( myOrientationGrp, aRow, 0 );
+  aRow++;
+
+  /******************************************************************************/
+  // Position & Size
+  myOriginDimGrp = new QGroupBox ( tr( "SMESH_POSITION_SIZE_SCALARBAR" ), this, "myOriginDimGrp" );
+  myOriginDimGrp->setColumnLayout( 0, Qt::Vertical );
+  myOriginDimGrp->layout()->setSpacing( 0 ); myOriginDimGrp->layout()->setMargin( 0 );
+  QGridLayout* myOriginDimGrpLayout = new QGridLayout( myOriginDimGrp->layout() );
+  myOriginDimGrpLayout->setAlignment( Qt::AlignTop );
+  myOriginDimGrpLayout->setSpacing( SPACING_SIZE ); myOriginDimGrpLayout->setMargin( MARGIN_SIZE );
     
-    /* Font attributes */
-    grid_6 = new QGridLayout; 
-    grid_6->setSpacing( 6 );
-    grid_6->setMargin( 0 );
-    Bold = new QCheckBox( Properties, "Bold" );
-    Bold->setText( tr( "SMESH_FONT_BOLD"  ) );
-    grid_6->addWidget( Bold, 0, 0 );
-    Italic = new QCheckBox( Properties, "Italic" );
-    Italic->setText( tr( "SMESH_FONT_ITALIC"  ) );
-    grid_6->addWidget( Italic, 0, 1 );
-    Shadow = new QCheckBox( Properties, "Shadow" );
-    Shadow->setText( tr( "SMESH_FONT_SHADOW"  ) );
-    grid_6->addWidget( Shadow, 0, 2 );
-    grid_4->addLayout( grid_6, 1, 0 );
-
-    grid_7 = new QGridLayout; 
-    grid_7->setSpacing( 6 );
-    grid_7->setMargin( 0 );
-    NumberColors = new QLabel( Properties, "NumberColors" );
-    NumberColors->setText( tr( "SMESH_NUMBEROFCOLORS"  ) );
-    grid_7->addWidget( NumberColors, 0, 0 );
-    SpinBoxColors = new QSpinBox( Properties, "SpinBoxColors" );
-    SpinBoxColors->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-    SpinBoxColors->setMinValue( 1 );
-    grid_7->addWidget( SpinBoxColors, 0, 1 );
-    NumberLabels = new QLabel( Properties, "NumberLabels" );
-    NumberLabels->setText( tr( "SMESH_NUMBEROFLABELS"  ) );
-    grid_7->addWidget( NumberLabels, 1, 0 );
-    SpinBoxLabels = new QSpinBox( Properties, "SpinBoxLabels" );
-    SpinBoxLabels->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-    SpinBoxLabels->setMinValue( 1 );
-    grid_7->addWidget( SpinBoxLabels, 1, 1 );
-    grid_4->addLayout( grid_7, 2, 0 );
-
-    grid->addWidget( Properties, 0, 0 );
-
-    /******************************************************************************/
-    ButtonGroup_Orientation = new QButtonGroup( this, "ButtonGroup_Orientation" );
-    ButtonGroup_Orientation->setTitle( tr( "SMESH_ORIENTATION"  ) );
-    ButtonGroup_Orientation->setColumnLayout(0, Qt::Vertical );
-    ButtonGroup_Orientation->layout()->setSpacing( 0 );
-    ButtonGroup_Orientation->layout()->setMargin( 0 );
-    grid_2 = new QGridLayout( ButtonGroup_Orientation->layout() );
-    grid_2->setAlignment( Qt::AlignTop );
-    grid_2->setSpacing( 6 );
-    grid_2->setMargin( 11 );
-    RadioVert = new QRadioButton( ButtonGroup_Orientation, "RadioVert" );
-    RadioVert->setText( tr( "SMESH_VERTICAL"  ) );
-    RadioHoriz = new QRadioButton( ButtonGroup_Orientation, "RadioHoriz" );
-    RadioHoriz->setText( tr( "SMESH_HORIZONTAL"  ) );
-    grid_2->addWidget( RadioVert, 0, 0 );
-    grid_2->addWidget( RadioHoriz, 0, 1 );
-
-    grid->addWidget( ButtonGroup_Orientation, 1, 0 );
-
-    /******************************************************************************/
-    GroupBox5 = new QGroupBox( this, "GroupBox5" );
-    GroupBox5->setTitle( tr( "SMESH_DIMENSIONS"  ) );
-    GroupBox5->setColumnLayout(0, Qt::Vertical );
-    GroupBox5->layout()->setSpacing( 0 );
-    GroupBox5->layout()->setMargin( 0 );
-    grid_11 = new QGridLayout( GroupBox5->layout() );
-    grid_11->setAlignment( Qt::AlignTop );
-    grid_11->setSpacing( 6 );
-    grid_11->setMargin( 11 );
-
-    LineEditWidth = new QLineEdit( GroupBox5, "LineEditWidth" );
-    grid_11->addWidget( LineEditWidth, 0, 0 );
-    Width = new QLabel( GroupBox5, "Width" );
-    Width->setText( tr( "SMESH_WIDTH"  ) );
-    grid_11->addWidget( Width, 0, 1 );
-    LineEditHeight = new QLineEdit( GroupBox5, "LineEditHeight" );
-    grid_11->addWidget( LineEditHeight, 1, 0 );
-    Height = new QLabel( GroupBox5, "Height" );
-    Height->setText( tr( "SMESH_HEIGHT"  ) );
-    grid_11->addWidget( Height, 1, 1 );
-
-    grid->addWidget( GroupBox5, 2, 0 );
-
-    /***************************************************************/
-    QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
-    GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
-    GroupButtons->setTitle( tr( ""  ) );
-    GroupButtons->setColumnLayout(0, Qt::Vertical );
-    GroupButtons->layout()->setSpacing( 0 );
-    GroupButtons->layout()->setMargin( 0 );
-    grid_15 = new QGridLayout( GroupButtons->layout() );
-    grid_15->setAlignment( Qt::AlignTop );
-    grid_15->setSpacing( 6 );
-    grid_15->setMargin( 11 );
-    buttonOk = new QPushButton( GroupButtons, "buttonOk" );
-    buttonOk->setText( tr( "SMESH_BUT_OK"  ) );
-    buttonOk->setAutoDefault( TRUE );
-    buttonOk->setDefault( TRUE );
-    grid_15->addWidget( buttonOk, 0, 0 );
-    grid_15->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
-    buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
-    buttonCancel->setText( tr( "SMESH_BUT_CANCEL"  ) );
-    buttonCancel->setAutoDefault( TRUE );
-    grid_15->addWidget( buttonCancel, 0, 2 );
-
-    grid->addWidget( GroupButtons, 3, 0 );
-
-    // signals and slots connections
-    connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
-    connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+  myXSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 );
+  myXSpin->setMinimumWidth( MINIMUM_WIDTH );
+  myXSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  myYSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 );
+  myYSpin->setMinimumWidth( MINIMUM_WIDTH );
+  myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  myWidthSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 );
+  myWidthSpin->setMinimumWidth( MINIMUM_WIDTH );
+  myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  myHeightSpin = new QAD_SpinBoxDbl( myOriginDimGrp, 0.0, 1.0, 0.1 );
+  myHeightSpin->setMinimumWidth( MINIMUM_WIDTH );
+  myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_X_SCALARBAR" ), myOriginDimGrp, "myXLab" ), 0, 0 );
+  myOriginDimGrpLayout->addWidget( myXSpin, 0, 1 );
+  myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_Y_SCALARBAR" ), myOriginDimGrp, "myYLab" ), 0, 2 );
+  myOriginDimGrpLayout->addWidget( myYSpin, 0, 3 );
+  myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_WIDTH" ),  myOriginDimGrp, "myWidthLab" ),  1, 0 );
+  myOriginDimGrpLayout->addWidget( myWidthSpin, 1, 1 );
+  myOriginDimGrpLayout->addWidget( new QLabel( tr( "SMESH_HEIGHT" ), myOriginDimGrp, "myHeightLab" ), 1, 2 );
+  myOriginDimGrpLayout->addWidget( myHeightSpin, 1, 3 );
+
+  aTopLayout->addWidget( myOriginDimGrp, aRow, 0 );
+  aRow++;
+
+  /***************************************************************/
+  // Common buttons
+  myButtonGrp = new QGroupBox( this, "myButtonGrp" );
+  myButtonGrp->setColumnLayout(0, Qt::Vertical );
+  myButtonGrp->layout()->setSpacing( 0 ); myButtonGrp->layout()->setMargin( 0 );
+  QHBoxLayout* myButtonGrpLayout = new QHBoxLayout( myButtonGrp->layout() );
+  myButtonGrpLayout->setAlignment( Qt::AlignTop );
+  myButtonGrpLayout->setSpacing( SPACING_SIZE ); myButtonGrpLayout->setMargin( MARGIN_SIZE );
+
+  myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), myButtonGrp, "myOkBtn" );
+  myOkBtn->setAutoDefault( TRUE ); myOkBtn->setDefault( TRUE );
+  myButtonGrpLayout->addWidget( myOkBtn );
+  if ( mySelection ) {
+    myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), myButtonGrp, "myApplyBtn" );
+    myApplyBtn->setAutoDefault( TRUE );
+    myButtonGrpLayout->addWidget( myApplyBtn );
+  }
+  myButtonGrpLayout->addStretch();
+  myCancelBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), myButtonGrp, "myCancelBtn" );
+  if ( mySelection )
+    myCancelBtn->setText( tr( "SMESH_BUT_CLOSE" ) );
+  myCancelBtn->setAutoDefault( TRUE );
+  myButtonGrpLayout->addWidget( myCancelBtn );
+
+  aTopLayout->addWidget( myButtonGrp, aRow, 0 );
+
+  /***************************************************************/
+  // Init
+  // --> first init from preferences
+  QColor titleColor( 255, 255, 255 );
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) {
+    QStringList aTColor = QStringList::split(  ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false );
+    titleColor = QColor( ( aTColor.count() > 0 ? aTColor[0].toInt() : 255 ), 
+                        ( aTColor.count() > 1 ? aTColor[1].toInt() : 255 ), 
+                        ( aTColor.count() > 2 ? aTColor[2].toInt() : 255 ) );
+  }
+  myTitleColorBtn->setPaletteBackgroundColor( titleColor );
+  myTitleFontCombo->setCurrentItem( 0 );
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ) {
+    if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" )
+      myTitleFontCombo->setCurrentItem( 0 );
+    if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" )
+      myTitleFontCombo->setCurrentItem( 1 );
+    if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" )
+      myTitleFontCombo->setCurrentItem( 2 );
+  }
+  myTitleBoldCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" );
+  myTitleItalicCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" );
+  myTitleShadowCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" );
+
+  QColor labelColor( 255, 255, 255 );
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) {
+    QStringList aLColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false );
+    labelColor = QColor( ( aLColor.count() > 0 ? aLColor[0].toInt() : 255 ), 
+                        ( aLColor.count() > 1 ? aLColor[1].toInt() : 255 ), 
+                        ( aLColor.count() > 2 ? aLColor[2].toInt() : 255 ) );
+  }
+  myLabelsColorBtn->setPaletteBackgroundColor( labelColor );
+  myLabelsFontCombo->setCurrentItem( 0 );
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ) {
+    if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" )
+      myLabelsFontCombo->setCurrentItem( 0 );
+    if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" )
+      myLabelsFontCombo->setCurrentItem( 1 );
+    if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" )
+      myLabelsFontCombo->setCurrentItem( 2 );
+  }
+  myLabelsBoldCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" );
+  myLabelsItalicCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" );
+  myLabelsShadowCheck->setChecked( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" );
+
+  int aNbColors = 64;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) )
+    aNbColors = QAD_CONFIG->getSetting( "SMESH:ScalarBarNbOfColors" ).toInt();
+  myColorsSpin->setValue( aNbColors );
+  int aNbLabels = 5;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) )
+    aNbLabels = QAD_CONFIG->getSetting( "SMESH:ScalarBarNbOfLabels" ).toInt();
+  myLabelsSpin->setValue( aNbLabels );
+
+  QString aOrientation = QAD_CONFIG->getSetting( "SMESH:ScalarBarOrientation" );
+  if ( aOrientation == "Horizontal" )
+    myHorizRadioBtn->setChecked( true );
+  else
+    myVertRadioBtn->setChecked( true );
+  myIniOrientation = myVertRadioBtn->isChecked();
+
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) )
+    myIniX = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toDouble();
+  else
+    myIniX = myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) )
+    myIniY = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toDouble();
+  else
+    myIniY = myHorizRadioBtn->isChecked() ? DEF_HOR_Y : DEF_VER_Y;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) )
+    myIniW = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toDouble();
+  else
+    myIniW = myHorizRadioBtn->isChecked() ? DEF_HOR_W : DEF_VER_W;
+  if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) )
+    myIniH = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toDouble();
+  else
+    myIniH = myHorizRadioBtn->isChecked() ? DEF_HOR_H : DEF_VER_H;
+  setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
+
+  if ( mySelection ) {
+    // --> then init from selection if necessary
+    onSelectionChanged();
+  }
+  
+  /***************************************************************/
+  // Connect section
+  connect( myTitleColorBtn,     SIGNAL( clicked() ), this, SLOT( onTitleColor() ) );
+  connect( myLabelsColorBtn,    SIGNAL( clicked() ), this, SLOT( onLabelsColor() ) );
+  connect( myOkBtn,             SIGNAL( clicked() ), this, SLOT( onOk() ) );
+  connect( myCancelBtn,         SIGNAL( clicked() ), this, SLOT( onCancel() ) );
+  connect( myXSpin,             SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
+  connect( myYSpin,             SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
+  connect( myOrientationGrp,    SIGNAL( clicked( int ) ), this, SLOT( onOrientationChanged() ) );
+  if ( mySelection ) {
+    connect( myApplyBtn,        SIGNAL( clicked() ), this, SLOT( onApply() ) );
+    connect( mySelection,       SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
+  }
+  connect( SMESHGUI::GetSMESHGUI(),  SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) ) ;
 }
 
-/*  
- *  Destroys the object and frees any allocated resources
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg
+ *
+ *  Destructor
  */
+//=================================================================================================
 SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg()
 {
-    // no need to delete child widgets, Qt does it all for us
 }
 
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::onOk
+ *
+ *  OK button slot
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::onOk()
+{
+  if ( onApply() )
+    onCancel();
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::onApply
+ *
+ *  Apply button slot
+ */
+//=================================================================================================
+bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
+{
+  if ( mySelection ) {
+    // Scalar Bar properties
+    if ( !myActor )
+      return false;
+    vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
+
+    vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
+    QColor aTColor = myTitleColorBtn->paletteBackgroundColor();
+    aTitleTextPrp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
+    if ( myTitleFontCombo->currentItem() == 0 )
+      aTitleTextPrp->SetFontFamilyToArial();
+    else if ( myTitleFontCombo->currentItem() == 1 )
+      aTitleTextPrp->SetFontFamilyToCourier();
+    else
+      aTitleTextPrp->SetFontFamilyToTimes();
+    aTitleTextPrp->SetBold( myTitleBoldCheck->isChecked() );
+    aTitleTextPrp->SetItalic( myTitleItalicCheck->isChecked() );
+    aTitleTextPrp->SetShadow( myTitleShadowCheck->isChecked() );
+    myScalarBarActor->SetTitleTextProperty( aTitleTextPrp );
+
+    vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty();
+    QColor aLColor = myLabelsColorBtn->paletteBackgroundColor();
+    aLabelsTextPrp->SetColor( aLColor.red()/255., aLColor.green()/255., aLColor.blue()/255. );
+    if ( myLabelsFontCombo->currentItem() == 0 )
+      aLabelsTextPrp->SetFontFamilyToArial();
+    else if ( myLabelsFontCombo->currentItem() == 1 )
+      aLabelsTextPrp->SetFontFamilyToCourier();
+    else
+      aLabelsTextPrp->SetFontFamilyToTimes();
+    aLabelsTextPrp->SetBold( myLabelsBoldCheck->isChecked() );
+    aLabelsTextPrp->SetItalic( myLabelsItalicCheck->isChecked() );
+    aLabelsTextPrp->SetShadow( myLabelsShadowCheck->isChecked() );
+    myScalarBarActor->SetLabelTextProperty( aLabelsTextPrp );
+
+    myScalarBarActor->SetNumberOfLabels( myLabelsSpin->value() );
+    myScalarBarActor->SetMaximumNumberOfColors( myColorsSpin->value() );
+
+    if ( myHorizRadioBtn->isChecked() )
+      myScalarBarActor->SetOrientationToHorizontal();
+    else
+      myScalarBarActor->SetOrientationToVertical();
+
+    myScalarBarActor->SetPosition( myXSpin->value(), myYSpin->value() );
+    myScalarBarActor->SetWidth( myWidthSpin->value() );
+    myScalarBarActor->SetHeight( myHeightSpin->value() );
+
+    double aMin = myMinEdit->text().toDouble();
+    double aMax = myMaxEdit->text().toDouble();
+    myScalarBarActor->GetLookupTable()->SetRange( aMin, aMax );
+    SMESHGUI::GetSMESHGUI()->UpdateView();
+  }
+  else {
+    // Scalar Bar preferences
+    QColor titleColor = myTitleColorBtn->paletteBackgroundColor();
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleColor",  QString().sprintf( "%d:%d:%d", titleColor.red(), titleColor.green(), titleColor.blue() ) );
+    if ( myTitleFontCombo->currentItem() == 0 )
+      QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleFont", "Arial" );
+    else if ( myTitleFontCombo->currentItem() == 1 )
+      QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleFont", "Courier" );
+    else
+      QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleFont", "Times" );
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleBold",   myTitleBoldCheck->isChecked() ?   "true" : "false" );
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleItalic", myTitleItalicCheck->isChecked() ? "true" : "false" );
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarTitleShadow", myTitleShadowCheck->isChecked() ? "true" : "false" );
+
+    QColor labelColor = myLabelsColorBtn->paletteBackgroundColor();
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelColor",  QString().sprintf( "%d:%d:%d", labelColor.red(), labelColor.green(),labelColor. blue() ) );
+    if ( myLabelsFontCombo->currentItem() == 0 )
+      QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelFont", "Arial" );
+    else if ( myLabelsFontCombo->currentItem() == 1 )
+      QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelFont", "Courier" );
+    else
+      QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelFont", "Times" );
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelBold",   myLabelsBoldCheck->isChecked() ?   "true" : "false" );
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelItalic", myLabelsItalicCheck->isChecked() ? "true" : "false" );
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarLabelShadow", myLabelsShadowCheck->isChecked() ? "true" : "false" );
+
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarNbOfColors", myColorsSpin->value() );
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarNbOfLabels", myLabelsSpin->value() );
+
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarOrientation", myHorizRadioBtn->isChecked() ? "Horizontal" : "Vertical" );
+    
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarXPosition", myXSpin->value() );
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarYPosition", myYSpin->value() );
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarWidth",     myWidthSpin->value() );
+    QAD_CONFIG->addSetting( "SMESH:ScalarBarHeight",    myHeightSpin->value() );
+  }
+  return true;
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::onCancel
+ *
+ *  Cancel button slot
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::onCancel()
+{
+  close();
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::onTitleColor
+ *
+ *  Change Title color button slot
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::onTitleColor()
+{
+  QColor aColor = myTitleColorBtn->paletteBackgroundColor();
+  aColor = QColorDialog::getColor( aColor, this );
+  if ( aColor.isValid() ) 
+    myTitleColorBtn->setPaletteBackgroundColor( aColor );
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::onLabelsColor
+ *
+ *  Change Labels color button slot
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::onLabelsColor()
+{
+  QColor aColor = myLabelsColorBtn->paletteBackgroundColor();
+  aColor = QColorDialog::getColor( aColor, this );
+  if ( aColor.isValid() ) 
+    myLabelsColorBtn->setPaletteBackgroundColor( aColor );
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged
+ *
+ *  Called when selection changed
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
+{
+  if( mySelection ) {
+    if ( mySelection->IObjectCount() == 1 ) {
+      Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject();
+      if( anIO->hasEntry() ) {
+       Standard_Boolean isOk;
+       SMESH_Actor* anActor = SMESHGUI::GetSMESHGUI()->FindActorByEntry( anIO->getEntry(), isOk, true );
+       if ( isOk && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
+         myActor = anActor;
+         vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
+         
+         double aMin = 0.0, aMax = 0.0;
+         if ( myScalarBarActor->GetLookupTable() ) {
+           float *range = myScalarBarActor->GetLookupTable()->GetRange();
+           myMinEdit->setText( QString::number( range[0] ) );
+           myMaxEdit->setText( QString::number( range[1] ) );
+         }
+
+         vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
+         float aTColor[3];
+         aTitleTextPrp->GetColor( aTColor );
+         myTitleColorBtn->setPaletteBackgroundColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) );
+         myTitleFontCombo->setCurrentItem( aTitleTextPrp->GetFontFamily() );
+         myTitleBoldCheck->setChecked( aTitleTextPrp->GetBold() );
+         myTitleItalicCheck->setChecked( aTitleTextPrp->GetItalic() );
+         myTitleShadowCheck->setChecked( aTitleTextPrp->GetShadow() );
+
+         vtkTextProperty* aLabelsTextPrp = myScalarBarActor->GetLabelTextProperty();
+         float aLColor[3];
+         aLabelsTextPrp->GetColor( aLColor );
+         myLabelsColorBtn->setPaletteBackgroundColor( QColor( (int)( aLColor[0]*255 ), (int)( aLColor[1]*255 ), (int)( aLColor[2]*255 ) ) );
+         myLabelsFontCombo->setCurrentItem( aLabelsTextPrp->GetFontFamily() );
+         myLabelsBoldCheck->setChecked( aLabelsTextPrp->GetBold() );
+         myLabelsItalicCheck->setChecked( aLabelsTextPrp->GetItalic() );
+         myLabelsShadowCheck->setChecked( aLabelsTextPrp->GetShadow() );
+
+         myLabelsSpin->setValue( myScalarBarActor->GetNumberOfLabels() );
+         myColorsSpin->setValue( myScalarBarActor->GetMaximumNumberOfColors() );
+
+         if ( myScalarBarActor->GetOrientation() == VTK_ORIENT_VERTICAL )
+           myVertRadioBtn->setChecked( true );
+         else
+           myHorizRadioBtn->setChecked( true );
+         myIniOrientation = myVertRadioBtn->isChecked();
+         
+         myIniX = myScalarBarActor->GetPosition()[0];
+         myIniY = myScalarBarActor->GetPosition()[1];
+         myIniW = myScalarBarActor->GetWidth();
+         myIniH = myScalarBarActor->GetHeight();
+         setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
+
+         myRangeGrp->setEnabled( true );
+         myFontGrp->setEnabled( true );
+         myLabColorGrp->setEnabled( true );
+         myOrientationGrp->setEnabled( true );
+         myOriginDimGrp->setEnabled( true );
+         myOkBtn->setEnabled( true );
+         myApplyBtn->setEnabled( true );
+         return;
+       }
+      }
+    }
+    myActor = 0;
+    myRangeGrp->setEnabled( false );
+    myFontGrp->setEnabled( false );
+    myLabColorGrp->setEnabled( false );
+    myOrientationGrp->setEnabled( false );
+    myOriginDimGrp->setEnabled( false );
+    myOkBtn->setEnabled( false );
+    myApplyBtn->setEnabled( false );
+  }
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::closeEvent
+ *
+ *  Close event handler
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::closeEvent( QCloseEvent* e )
+{
+  if ( mySelection ) // "Properties" dialog box
+    myDlg = 0;
+  QDialog::closeEvent( e );
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::onXYChanged
+ *
+ *  Called when X, Y values are changed
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::onXYChanged()
+{
+  myWidthSpin->setMaxValue( 1.0 - myXSpin->value() );
+  myHeightSpin->setMaxValue( 1.0 - myYSpin->value() );
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize
+ *
+ *  Called when X, Y values are changed
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize( const double x,
+                                                         const double y,
+                                                         const double w,
+                                                         const double h )
+{
+  blockSignals( true );
+  myXSpin->setValue( x );
+  myYSpin->setValue( y );
+  myWidthSpin->setMaxValue( 1.0 );
+  myWidthSpin->setValue( w );
+  myHeightSpin->setMaxValue( 1.0 );
+  myHeightSpin->setValue( h );
+  blockSignals( false );
+  onXYChanged();
+}
+
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged
+ *
+ *  Called when orientation is changed
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged() 
+{
+  int aOrientation = myVertRadioBtn->isChecked();
+  if ( aOrientation == myIniOrientation )
+    setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
+  else
+    setOriginAndSize( aOrientation ? DEF_VER_X : DEF_HOR_X, 
+                     aOrientation ? DEF_VER_Y : DEF_HOR_Y, 
+                     aOrientation ? DEF_VER_W : DEF_HOR_W, 
+                     aOrientation ? DEF_VER_H : DEF_HOR_H );
+}
index 777d24aff5de867ef952d5cd3d6f98c373208d80..bde914a36757a143eca20a8c1d41e559c2fb66d3 100644 (file)
 #ifndef SMESHGUI_PREFERENCES_SCALARBARDLG_H
 #define SMESHGUI_PREFERENCES_SCALARBARDLG_H
 
-#include <qvariant.h>
 #include <qdialog.h>
-class QVBoxLayout; 
-class QHBoxLayout; 
-class QGridLayout; 
+
 class QButtonGroup;
 class QCheckBox;
 class QComboBox;
@@ -41,54 +38,78 @@ class QGroupBox;
 class QLabel;
 class QLineEdit;
 class QPushButton;
+class QToolButton;
 class QRadioButton;
 class QSpinBox;
+class QAD_SpinBoxDbl;
+class SALOME_Selection;
+class SMESH_Actor;
 
 class SMESHGUI_Preferences_ScalarBarDlg : public QDialog
 { 
-    Q_OBJECT
+  Q_OBJECT
 
 public:
-    SMESHGUI_Preferences_ScalarBarDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
-    ~SMESHGUI_Preferences_ScalarBarDlg();
-
-    QButtonGroup* ButtonGroup_Orientation;
-    QRadioButton* RadioHoriz;
-    QRadioButton* RadioVert;
-    QGroupBox* Properties;
-    QLabel* NumberLabels;
-    QLabel* NumberColors;
-    QSpinBox* SpinBoxLabels;
-    QSpinBox* SpinBoxColors;
-    QLabel* TextLabel2;
-    QComboBox* ComboBox1;
-    QCheckBox* Shadow;
-    QCheckBox* Italic;
-    QCheckBox* Bold;
-    QGroupBox* GroupBox5;
-    QLineEdit* LineEditWidth;
-    QLineEdit* LineEditHeight;
-    QLabel* Height;
-    QLabel* Width;
-    QPushButton* buttonCancel;
-    QPushButton* buttonOk;
+  ~SMESHGUI_Preferences_ScalarBarDlg();
+  static void ScalarBarPreferences( QWidget* parent );
+  static void ScalarBarProperties ( QWidget* parent, SALOME_Selection* Sel );
 
 protected:
-    QGridLayout* grid;
-    QGridLayout* grid_2;
-    QGridLayout* grid_3;
-    QGridLayout* grid_4;
-    QGridLayout* grid_5;
-    QGridLayout* grid_6;
-    QGridLayout* grid_7;
-    QGridLayout* grid_8;
-    QGridLayout* grid_9;
-    QGridLayout* grid_10;
-    QGridLayout* grid_11;
-    QGridLayout* grid_12;
-    QGridLayout* grid_13;
-    QGridLayout* grid_14;
-    QGridLayout* grid_15;
+  SMESHGUI_Preferences_ScalarBarDlg( QWidget* parent = 0, SALOME_Selection* Sel = 0, bool modal = FALSE );
+  static SMESHGUI_Preferences_ScalarBarDlg* myDlg;
+  void closeEvent( QCloseEvent* e );
+  void setOriginAndSize( const double x, const double y, const double w, const double h );
+
+protected slots:
+  void onOk();
+  bool onApply();
+  void onCancel();
+  void onTitleColor();
+  void onLabelsColor();
+  void onSelectionChanged();
+  void onXYChanged();
+  void onOrientationChanged();
+
+private:
+  SALOME_Selection*  mySelection;
+  SMESH_Actor*       myActor;
+  double             myIniX, myIniY, myIniW, myIniH;
+  int                myIniOrientation;
+
+  QGroupBox*         myRangeGrp;
+  QLineEdit*         myMinEdit;
+  QLineEdit*         myMaxEdit;
+
+  QGroupBox*         myFontGrp;
+  QToolButton*       myTitleColorBtn;
+  QComboBox*         myTitleFontCombo;
+  QCheckBox*         myTitleBoldCheck;
+  QCheckBox*         myTitleItalicCheck;
+  QCheckBox*         myTitleShadowCheck;
+  QToolButton*       myLabelsColorBtn;
+  QComboBox*         myLabelsFontCombo;
+  QCheckBox*         myLabelsBoldCheck;
+  QCheckBox*         myLabelsItalicCheck;
+  QCheckBox*         myLabelsShadowCheck;
+  
+  QGroupBox*         myLabColorGrp;
+  QSpinBox*          myColorsSpin;
+  QSpinBox*          myLabelsSpin;
+
+  QButtonGroup*      myOrientationGrp;
+  QRadioButton*      myVertRadioBtn;
+  QRadioButton*      myHorizRadioBtn;
+
+  QGroupBox*         myOriginDimGrp;
+  QAD_SpinBoxDbl*    myXSpin;
+  QAD_SpinBoxDbl*    myYSpin;
+  QAD_SpinBoxDbl*    myWidthSpin;
+  QAD_SpinBoxDbl*    myHeightSpin;
+
+  QGroupBox*         myButtonGrp;
+  QPushButton*       myOkBtn;
+  QPushButton*       myApplyBtn;
+  QPushButton*       myCancelBtn;
 };
 
 #endif // SMESHGUI_PREFERENCES_SCALARBARDLG_H
index b15ea1b807a3946f8558046f34f70ef8290b98cc..fd3e5e4270cedcd9312602c61b029bb6b2a73144 100644 (file)
@@ -247,7 +247,7 @@ void SMESHGUI_RemoveElementsDlg::ClickOnOk()
 //=================================================================================
 void SMESHGUI_RemoveElementsDlg::ClickOnCancel()
 {
-  QAD_Application::getDesktop()->SetSelectionMode( 4 );
+  QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
   disconnect( mySelection, 0, this, 0 );
   mySMESHGUI->ResetState() ;
   reject() ;
@@ -273,9 +273,9 @@ void SMESHGUI_RemoveElementsDlg::SelectionIntoArgument()
   if(nbElements < 1)
     return ;
   
-  if ( mySelection->SelectionMode() != 3 ) {
+  if ( mySelection->SelectionMode() != CellSelection ) {
     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
-                           tr ("SMESH_WRN_SELECTIONMODE_ELEMENTS"), tr ("SMESH_BUT_YES") );
+                           tr ("SMESH_WRN_SELECTIONMODE_ELEMENTS"), tr ("SMESH_BUT_OK") );
     return;
   }
 
index 373cfbc51d5a5e7d6804636603211a8650c4fb6b..68ba6b86315067755962a5aed2404ed8069bf2fd 100644 (file)
@@ -251,7 +251,7 @@ void SMESHGUI_RemoveNodesDlg::ClickOnOk()
 //=================================================================================
 void SMESHGUI_RemoveNodesDlg::ClickOnCancel()
 {
-  QAD_Application::getDesktop()->SetSelectionMode( 4 );
+  QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
   disconnect( mySelection, 0, this, 0 );
   mySMESHGUI->ResetState() ;
   mySMESHGUI->EraseSimulationActors();
@@ -278,9 +278,9 @@ void SMESHGUI_RemoveNodesDlg::SelectionIntoArgument()
   if(nbNodes < 1)
     return ;
   
-  if ( mySelection->SelectionMode() != 1 ){
+  if ( mySelection->SelectionMode() != NodeSelection ){
     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
-                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
+                           tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") );
     return;
   }
 
index 42e2724d937d2d3b41cb927201cb1a150f50d5b6..65605ad92e850508aebd22c9494669dc774d5f55 100644 (file)
@@ -82,40 +82,8 @@ SMESHGUI_StudyAPI::SMESHGUI_StudyAPI ()
 SMESHGUI_StudyAPI::SMESHGUI_StudyAPI ( SALOMEDS::Study_ptr aStudy,
                                       SMESH::SMESH_Gen_ptr CompMesh)
 {
-  myStudy = aStudy;
-  myStudyBuilder = aStudy->NewBuilder();
-
   setOrb();
-
-  // NRI : Temporary added
-  if ( myStudy->GetProperties()->IsLocked() ) {
-//    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
-//                         QObject::tr("WARNING"), 
-//                         QObject::tr("WRN_STUDY_LOCKED"),
-//                         QObject::tr("BUT_OK") );
-    
-    return;
-  }
-  // NRI
-
-  SALOMEDS::SComponent_var father = aStudy->FindComponent("MESH");
-  SALOMEDS::GenericAttribute_var anAttr;
-  SALOMEDS::AttributeName_var    aName;
-  SALOMEDS::AttributePixMap_var  aPixmap;
-  
-  if (father->_is_nil()) {
-    father = myStudyBuilder->NewComponent("MESH");
-  }
-  anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
-  aName = SALOMEDS::AttributeName::_narrow(anAttr);
-  //NRI    aName->SetValue(QObject::tr("SMESH_MEN_COMPONENT"));
-  aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SMESH" ) );
-  anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
-  aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
-  aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
-  
-  myStudyBuilder->DefineComponentInstance(father, CompMesh );
-  mySComponentMesh = SALOMEDS::SComponent::_narrow( father );
+  Update( aStudy );
 }
 
 //=======================================================================
@@ -130,93 +98,12 @@ SMESHGUI_StudyAPI::~SMESHGUI_StudyAPI ()
 // function :
 // purpose  : Update
 //=======================================================================
-void SMESHGUI_StudyAPI::Update(SMESH::SMESH_Gen_ptr CompMesh)
-{
-  // NRI : Temporary added
-  if ( myStudy->GetProperties()->IsLocked() ) {
-    return;
-  }
-  // NRI
-
-  SALOMEDS::SComponent_var father = myStudy->FindComponent("MESH");
-  SALOMEDS::GenericAttribute_var anAttr;
-  SALOMEDS::AttributeName_var    aName;
-  SALOMEDS::AttributePixMap_var  aPixmap;
-  
-  if (father->_is_nil()) {
-    father = myStudyBuilder->NewComponent("MESH");
-    anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
-    aName = SALOMEDS::AttributeName::_narrow(anAttr);
-    //NRI    aName->SetValue(QObject::tr("SMESH_MEN_COMPONENT"));
-    aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SMESH" ) );
-    anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
-    aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
-    aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
-  }
-  myStudyBuilder->DefineComponentInstance(father, CompMesh );
-  mySComponentMesh = SALOMEDS::SComponent::_narrow( father );  
-}
-
-//=======================================================================
-// function : AddNewMesh 
-// purpose  :
-//=======================================================================
-
-SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddNewMesh (SMESH::SMESH_Mesh_ptr M)
+void SMESHGUI_StudyAPI::Update(SALOMEDS::Study_ptr aStudy)
 {
-  // NRI : Temporary added
-  if ( myStudy->GetProperties()->IsLocked() ) {
-    return SALOMEDS::SObject::_nil();
-  }
-  // NRI
-
-  //Find or Create Hypothesis root
-  SALOMEDS::SObject_var             HypothesisRoot;
-  SALOMEDS::GenericAttribute_var    anAttr;
-  SALOMEDS::AttributeName_var       aName;
-  SALOMEDS::AttributeIOR_var        anIOR;
-  SALOMEDS::AttributeSelectable_var aSelAttr;
-  SALOMEDS::AttributePixMap_var     aPixmap;
-
-  if (!mySComponentMesh->FindSubObject (Tag_HypothesisRoot, HypothesisRoot)) {
-    HypothesisRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot);
-    anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeName");
-    aName = SALOMEDS::AttributeName::_narrow(anAttr);
-    aName->SetValue(QObject::tr("SMESH_MEN_HYPOTHESIS"));
-    anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributePixMap");
-    aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
-    aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
-    anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable");
-    aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
-    aSelAttr->SetSelectable(false);
-  }
-
-  SALOMEDS::SObject_var AlgorithmsRoot;
-  if (!mySComponentMesh->FindSubObject (Tag_AlgorithmsRoot, AlgorithmsRoot)) {
-    AlgorithmsRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot);
-    anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeName");
-    aName = SALOMEDS::AttributeName::_narrow(anAttr);
-    aName->SetValue(QObject::tr("SMESH_MEN_ALGORITHMS"));
-    anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap");
-    aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
-    aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" );
-    anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable");
-    aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
-    aSelAttr->SetSelectable(false);
-  }
-
-  // Add New Mesh
-  SALOMEDS::SObject_var newMesh = myStudyBuilder->NewObject(mySComponentMesh);
-  anAttr = myStudyBuilder->FindOrCreateAttribute(newMesh, "AttributePixMap");
-  aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
-  aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
-  anAttr = myStudyBuilder->FindOrCreateAttribute(newMesh, "AttributeIOR");
-  anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-  anIOR->SetValue(IORToString(M));
-  return SALOMEDS::SObject::_narrow( newMesh );
+  myStudy = SALOMEDS::Study::_duplicate( aStudy );
+  myStudyBuilder = aStudy->NewBuilder();
 }
 
-
 //=======================================================================
 // function : SetShape
 // purpose  :
@@ -245,6 +132,9 @@ GEOM::GEOM_Shape_ptr SMESHGUI_StudyAPI::GetShapeOnMeshOrSubMesh(SALOMEDS::SObjec
   }
   // NRI
 
+  if ( SO_Mesh_Or_SubMesh->_is_nil() )
+    return GEOM::GEOM_Shape::_nil();
+
   GEOM::GEOM_Shape_var Shape;
   SALOMEDS::SObject_var aSO, aGeom;
   SALOMEDS::GenericAttribute_var anAttr;
@@ -260,112 +150,6 @@ GEOM::GEOM_Shape_ptr SMESHGUI_StudyAPI::GetShapeOnMeshOrSubMesh(SALOMEDS::SObjec
   return GEOM::GEOM_Shape::_nil();
 }
 
-//=======================================================================
-// function : AddNewHypothesis 
-// purpose  :
-//=======================================================================
-SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddNewHypothesis  (SMESH::SMESH_Hypothesis_ptr H)
-{
-  // NRI : Temporary added
-  if ( myStudy->GetProperties()->IsLocked() ) {
-    return SALOMEDS::SObject::_nil();
-  }
-  // NRI
-
-  //Find or Create Hypothesis root
-  SALOMEDS::SObject_var             HypothesisRoot;
-  SALOMEDS::GenericAttribute_var    anAttr;
-  SALOMEDS::AttributeName_var       aName;
-  SALOMEDS::AttributeIOR_var        anIOR;
-  SALOMEDS::AttributeSelectable_var aSelAttr;
-  SALOMEDS::AttributePixMap_var     aPixmap;
-
-  if (!mySComponentMesh->FindSubObject (Tag_HypothesisRoot, HypothesisRoot)) {
-    HypothesisRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot);
-    anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeName");
-    aName = SALOMEDS::AttributeName::_narrow(anAttr);
-    aName->SetValue(QObject::tr("SMESH_MEN_HYPOTHESIS"));
-    anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable");
-    aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
-    aSelAttr->SetSelectable(false);
-    anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributePixMap");
-    aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
-    aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
-  }
-  // Add New Hypothesis
-  SALOMEDS::SObject_var newHypo = myStudyBuilder->NewObject(HypothesisRoot);
-  anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributePixMap");
-  aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
-  QString aType = H->GetName();
-  MESSAGE ( " aType " << aType )
-  aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_" + aType );
-  //    if ( aType.compare("LocalLength") == 0 )
-  //      aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_LENGTH" );
-  //    else if ( aType.compare("NumberOfSegments") == 0 )
-  //      aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_SEGMENT" );
-  //    else if ( aType.compare("MaxElementArea") == 0 )
-  //      aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_AREA" );
-  //    else if ( aType.compare("MaxElementVolume") == 0 )
-  //      aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_VOLUME" );
-  anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributeIOR");
-  anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-  anIOR->SetValue(IORToString(H));
-  return SALOMEDS::SObject::_narrow(newHypo);
-}  
-
-//=======================================================================
-// function : AddNewAlgorithms 
-// purpose  :
-//=======================================================================
-SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddNewAlgorithms  (SMESH::SMESH_Hypothesis_ptr H)
-{
-  // NRI : Temporary added
-  if ( myStudy->GetProperties()->IsLocked() ) {
-    return SALOMEDS::SObject::_nil();
-  }
-  // NRI
-
-  //Find or Create Algorithms root
-  SALOMEDS::SObject_var             AlgorithmsRoot;
-  SALOMEDS::GenericAttribute_var    anAttr;
-  SALOMEDS::AttributeName_var       aName;
-  SALOMEDS::AttributeIOR_var        anIOR;
-  SALOMEDS::AttributeSelectable_var aSelAttr;
-  SALOMEDS::AttributePixMap_var     aPixmap;
-
-  if (!mySComponentMesh->FindSubObject (Tag_AlgorithmsRoot, AlgorithmsRoot)) {
-    AlgorithmsRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot);
-    anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeName");
-    aName = SALOMEDS::AttributeName::_narrow(anAttr);
-    aName->SetValue(QObject::tr("SMESH_MEN_ALGORITHMS"));
-    anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable");
-    aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
-    aSelAttr->SetSelectable(false);
-    anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap");
-    aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
-    aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" );
-  }
-  // Add New Algorithms
-  SALOMEDS::SObject_var newHypo = myStudyBuilder->NewObject(AlgorithmsRoot);
-  anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributePixMap");
-  aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
-  QString aType = H->GetName();
-  //  if ( aType.compare("Regular_1D") == 0 )
-  aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_" + aType );
-  //      aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_REGULAR" );
-  //    else if ( aType.compare("MEFISTO_2D") == 0 )
-  //      aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_MEFISTO" );
-  //    else if ( aType.compare("Quadrangle_2D") == 0 )
-  //      aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_QUAD" );
-  //    else if ( aType.compare("Hexa_3D") == 0 )
-  //      aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_HEXA" );
-  anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributeIOR");
-  anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-  anIOR->SetValue(IORToString(H));
-  return SALOMEDS::SObject::_narrow(newHypo);
-}  
-
-
 //=======================================================================
 // function : AddSubMeshOnShape
 // purpose  :
@@ -512,46 +296,25 @@ void SMESHGUI_StudyAPI::SetAlgorithms     (SALOMEDS::SObject_ptr SO_MorSM,
 // function :
 // purpose  : 
 //=======================================================================
-SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindMesh       (SMESH::SMESH_Mesh_ptr M)
+SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindObject( CORBA::Object_ptr theObject )
 {
   // NRI : Temporary added
   if ( myStudy->GetProperties()->IsLocked() ) {
     return SALOMEDS::SObject::_nil();
   }
   // NRI
-  return SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR (IORToString(M)) );
-}   
-
-//=======================================================================
-// function :
-// purpose  : 
-//=======================================================================
-SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindHypothesisOrAlgorithms (SMESH::SMESH_Hypothesis_ptr H)
-{
-  // NRI : Temporary added
-  if ( myStudy->GetProperties()->IsLocked() ) {
-    return SALOMEDS::SObject::_nil();
+  if ( !CORBA::is_nil ( theObject ) ) {
+    string anIOR = IORToString( theObject );
+    if ( anIOR != "" )
+      return myStudy->FindObjectIOR( anIOR.c_str() );
   }
-  // NRI
-  return SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR (IORToString(H)) );
-} 
-  
+  return SALOMEDS::SObject::_nil();
+}   
 
 //=======================================================================
 // function :
 // purpose  : 
 //=======================================================================
-SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindSubMesh    (SMESH::SMESH_subMesh_ptr SM)
-{
-  // NRI : Temporary added
-  if ( myStudy->GetProperties()->IsLocked() ) {
-    return SALOMEDS::SObject::_nil();
-  }
-  // NRI
-  return SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR (IORToString(SM)) );
-}   
-
 void SMESHGUI_StudyAPI::setOrb()
 {
   try {
@@ -565,25 +328,6 @@ void SMESHGUI_StudyAPI::setOrb()
   ASSERT(! CORBA::is_nil(_orb));
 }
 
-//=======================================================================
-// function :
-// purpose  : 
-//=======================================================================
-void SMESHGUI_StudyAPI::SetTagHypothesisRoot()
-{
-  // NRI : Temporary added
-  if ( myStudy->GetProperties()->IsLocked() ) {
-    return;
-  }
-  // NRI
-  SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(mySComponentMesh);
-  int i = 0;
-  for (; it->More();it->Next()) {
-  i++;
-  }
-  Tag_HypothesisRoot = i++;
-}
-
 //=======================================================================
 // function :
 // purpose  : 
index 5224c22e05b5ad4841e64b39e7d2f73d0717a2eb..8cbb56f2bf22985fd6037a43fd81d54f9c82fd45 100644 (file)
@@ -37,6 +37,7 @@
 #include CORBA_SERVER_HEADER(GEOM_Shape)
 #include CORBA_SERVER_HEADER(SALOMEDS)
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+#include CORBA_SERVER_HEADER(SALOME_GenericObj)
        
 class SMESH_subMesh_ptr;
 
@@ -62,7 +63,7 @@ class SMESHGUI_StudyAPI {
 
   SALOMEDS::SObject_ptr AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, SALOMEDS::SObject_ptr SO_GeomShape, SMESH::SMESH_subMesh_ptr SM, GEOM::shape_type ST);
 
-  void Update(SMESH::SMESH_Gen_ptr Gen);
+  void Update(SALOMEDS::Study_ptr aStudy);
 
   void ModifiedMesh( SALOMEDS::SObject_ptr MorSM, bool right);
 
@@ -84,23 +85,14 @@ class SMESHGUI_StudyAPI {
   
   SALOMEDS::SObject_ptr GetMeshOrSubmesh  (SALOMEDS::SObject_ptr SO);
 
-  SALOMEDS::SObject_ptr FindMesh       (SMESH::SMESH_Mesh_ptr M);
+  SALOMEDS::SObject_ptr FindObject(CORBA::Object_ptr theObject);
 
-  SALOMEDS::SObject_ptr FindHypothesisOrAlgorithms (SMESH::SMESH_Hypothesis_ptr H);
-
-  SALOMEDS::SObject_ptr FindSubMesh    (SMESH::SMESH_subMesh_ptr SM);
-
-  //SALOMEDS::ListOfSObject_ptr FindMesh    (SALOMEDS_SObject_ptr SO_GeomShape);
-  //SALOMEDS_SObject_ptr        FindSubMesh (SALOMEDS_SObject_ptr SO_Mesh, SALOMEDS_SObject_ptr SO_GeomShape);
-    
   static void setOrb();
 
   private:
   //fields
   SALOMEDS::Study_var        myStudy;
   SALOMEDS::StudyBuilder_var myStudyBuilder;
-  SALOMEDS::SComponent_var   mySComponentMesh;
 };
 #endif
 
index 2eace0798fe7e606fb17d09624b7130345aeee14..1ab1cea6b7da1a3d5e0fdfbd5d3c26ee0d2fdcad 100644 (file)
@@ -73,6 +73,9 @@ void SMESH_Swig::Init(int studyID)
   Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "SMESH");
   SMESH::SMESH_Gen_var CompMesh = SMESH::SMESH_Gen::_narrow(comp);
 
+  Engines::Component_var comp1 = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
+  GEOM::GEOM_Gen_var CompGeom = GEOM::GEOM_Gen::_narrow(comp1);
+
   QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
   if ( resMgr ) {
     QString msg;
@@ -83,6 +86,9 @@ void SMESH_Swig::Init(int studyID)
   CORBA::Object_var obj = QAD_Application::getDesktop()->getNameService()->Resolve("/myStudyManager");
   SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
   myStudy = myStudyMgr->GetStudyByID(studyID);
+
+  CompMesh->SetCurrentStudy( myStudy.in() ); 
+
   myStudyBuilder = myStudy->NewBuilder();
   SALOMEDS::GenericAttribute_var anAttr;
   SALOMEDS::AttributeName_var    aName;
@@ -104,6 +110,8 @@ void SMESH_Swig::Init(int studyID)
     myStudyBuilder->DefineComponentInstance(father, CompMesh );
     if (aLocked) myStudy->GetProperties()->SetLocked(true);
   }
+  mySComponentMesh = SALOMEDS::SComponent::_narrow( father );
+
   // Tags definition 
   Tag_HypothesisRoot  = 1;
   Tag_AlgorithmsRoot  = 2;
@@ -128,6 +136,12 @@ SMESH_Swig::~SMESH_Swig()
 const char* SMESH_Swig::AddNewMesh(const char* IOR)
 {
   MESSAGE("AddNewMesh");
+
+  // VSR: added temporarily - to be removed - objects are published automatically by engine
+  SALOMEDS::SObject_var SO = myStudy->FindObjectIOR( IOR );
+  if ( !SO->_is_nil() )
+    return SO->GetID();
+
   //Find or Create Hypothesis root
   SALOMEDS::GenericAttribute_var    anAttr;
   SALOMEDS::AttributeName_var       aName;
@@ -177,6 +191,12 @@ const char* SMESH_Swig::AddNewMesh(const char* IOR)
 const char* SMESH_Swig::AddNewHypothesis(const char* IOR)
 {
   MESSAGE("AddNewHypothesis");
+
+  // VSR: added temporarily - to be removed - objects are published automatically by engine
+  SALOMEDS::SObject_var SO = myStudy->FindObjectIOR( IOR );
+  if ( !SO->_is_nil() )
+    return SO->GetID();
+
   //Find or Create Hypothesis root
   SALOMEDS::SObject_var             HypothesisRoot;
   SALOMEDS::GenericAttribute_var    anAttr;
@@ -221,6 +241,12 @@ const char* SMESH_Swig::AddNewHypothesis(const char* IOR)
 const char* SMESH_Swig::AddNewAlgorithms(const char* IOR)
 {
   MESSAGE("AddNewAlgorithms");
+
+  // VSR: added temporarily - to be removed - objects are published automatically by engine
+  SALOMEDS::SObject_var SO = myStudy->FindObjectIOR( IOR );
+  if ( !SO->_is_nil() )
+    return SO->GetID();
+
   //Find or Create Algorithms root
   SALOMEDS::SObject_var             AlgorithmsRoot;
   SALOMEDS::GenericAttribute_var    anAttr;
index 0ab482433cb853bab12709872ec6a7e9104417f5..f42405abccb624b0f5331847469ab6757782e19a 100644 (file)
@@ -31,21 +31,44 @@ using namespace std;
 #include "SMESHGUI.h"
 
 // QT Includes
-#include <qframe.h>
 #include <qlabel.h>
 #include <qpushbutton.h>
 #include <qslider.h>
 #include <qlayout.h>
-#include <qvariant.h>
-#include <qtooltip.h>
-#include <qwhatsthis.h>
-#include <qapplication.h>
 #include <qgroupbox.h>
 
 #include "VTKViewer_ViewFrame.h"
 #include "VTKViewer_RenderWindowInteractor.h"
 #include "QAD_RightFrame.h"
+#include "QAD_WaitCursor.h"
 #include "SALOME_ListIteratorOfListIO.hxx"
+#include "SMESH_Actor.h"
+#include "SALOME_Selection.h"
+#include "SALOME_InteractiveObject.hxx"
+
+static SMESH_Actor* FindActorByEntry(const char* theEntry)
+{
+  QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
+  QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
+  VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>( aStudyFrame->getRightFrame()->getViewFrame() );
+
+  if(aViewFrame){
+    vtkRenderer *aRenderer = aViewFrame->getRenderer();
+    vtkActorCollection *aCollection = aRenderer->GetActors();
+    aCollection->InitTraversal();
+    while(vtkActor *anAct = aCollection->GetNextActor()){
+      if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
+       if(anActor->hasIO()){
+         Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
+         if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){
+           return anActor;
+         }
+       }
+      }
+    }
+  }
+  return NULL;
+}
 
 //=================================================================================
 // class    : SMESHGUI_TransparencyDlg()
@@ -54,38 +77,18 @@ using namespace std;
 //=================================================================================
 SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg( QWidget* parent,
                                                    const char* name,
-                                                   SALOME_Selection* Sel,
                                                    bool modal,
                                                    WFlags fl )
-  : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+  : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
 {
   if ( !name )
     setName( "SMESHGUI_TransparencyDlg" );
-  resize( 152, 107 ); 
   setCaption( tr( "SMESH_TRANSPARENCY_TITLE"  ) );
   setSizeGripEnabled( TRUE );
-  SMESHGUI_TransparencyDlgLayout = new QGridLayout( this ); 
+  QGridLayout* SMESHGUI_TransparencyDlgLayout = new QGridLayout( this ); 
   SMESHGUI_TransparencyDlgLayout->setSpacing( 6 );
   SMESHGUI_TransparencyDlgLayout->setMargin( 11 );
 
-  /*************************************************************************/
-  QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
-  GroupButtons->setColumnLayout(0, Qt::Vertical );
-  GroupButtons->layout()->setSpacing( 0 );
-  GroupButtons->layout()->setMargin( 0 );
-  QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
-  GroupButtonsLayout->setAlignment( Qt::AlignTop );
-  GroupButtonsLayout->setSpacing( 6 );
-  GroupButtonsLayout->setMargin( 11 );
-
-  buttonOk = new QPushButton( GroupButtons, "buttonOk" );
-  buttonOk->setText( tr( "GEOM_BUT_OK" ) );
-  buttonOk->setAutoDefault( TRUE );
-  buttonOk->setDefault( TRUE );
-  GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0 );
-  GroupButtonsLayout->addWidget( buttonOk, 0, 1 );
-  GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2 );
-
   /*************************************************************************/
   QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
   GroupC1->setColumnLayout(0, Qt::Vertical );
@@ -96,59 +99,82 @@ SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg( QWidget* parent,
   GroupC1Layout->setSpacing( 6 );
   GroupC1Layout->setMargin( 11 );
   
-  TextLabelOpaque = new QLabel( GroupC1, "TextLabelOpaque" );
-  TextLabelOpaque->setText( tr( "SMESH_TRANSPARENCY_OPAQUE"  ) );
-  TextLabelOpaque->setAlignment( int( QLabel::AlignLeft ) );
-  GroupC1Layout->addWidget( TextLabelOpaque, 0, 0 );
-  GroupC1Layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
-  
   TextLabelTransparent = new QLabel( GroupC1, "TextLabelTransparent" );
   TextLabelTransparent->setText( tr( "SMESH_TRANSPARENCY_TRANSPARENT"  ) );
-  TextLabelTransparent->setAlignment( int( QLabel::AlignRight ) );
-  GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 );
+  TextLabelTransparent->setAlignment( AlignLeft );
+  GroupC1Layout->addWidget( TextLabelTransparent, 0, 0 );
+  
+  ValueLab = new QLabel( GroupC1, "ValueLab" );
+  ValueLab->setAlignment( AlignCenter );
+  ValueLab->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  QFont fnt = ValueLab->font(); fnt.setBold( true ); ValueLab->setFont( fnt );
+  GroupC1Layout->addWidget( ValueLab, 0, 1 );
+
+  TextLabelOpaque = new QLabel( GroupC1, "TextLabelOpaque" );
+  TextLabelOpaque->setText( tr( "SMESH_TRANSPARENCY_OPAQUE"  ) );
+  TextLabelOpaque->setAlignment( AlignRight );
+  GroupC1Layout->addWidget( TextLabelOpaque, 0, 2 );
   
   Slider1 = new QSlider( 0, 10, 1, 5, Horizontal, GroupC1, "Slider1" );
+  Slider1->setFocusPolicy( QWidget::NoFocus );
   Slider1->setMinimumSize( 300, 0 );
-  Slider1->setTickmarks( QSlider::Left );
+  Slider1->setTickmarks( QSlider::Above );
+  Slider1->setTickInterval( 10 );
+  Slider1->setTracking( true );
+  Slider1->setMinValue( 0 ) ;
+  Slider1->setMaxValue( 100 );
+  Slider1->setLineStep( 1 );
+  Slider1->setPageStep( 10 );
   GroupC1Layout->addMultiCellWidget( Slider1, 1, 1, 0, 2 );
 
+  /*************************************************************************/
+  QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+  GroupButtons->setColumnLayout(0, Qt::Vertical );
+  GroupButtons->layout()->setSpacing( 0 );
+  GroupButtons->layout()->setMargin( 0 );
+  QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+  GroupButtonsLayout->setAlignment( Qt::AlignTop );
+  GroupButtonsLayout->setSpacing( 6 );
+  GroupButtonsLayout->setMargin( 11 );
+
+  buttonOk = new QPushButton( GroupButtons, "buttonOk" );
+  buttonOk->setText( tr( "SMESH_BUT_CLOSE" ) );
+  buttonOk->setAutoDefault( TRUE );
+  buttonOk->setDefault( TRUE );
+  GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0 );
+  GroupButtonsLayout->addWidget( buttonOk, 0, 1 );
+  GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2 );
+
   SMESHGUI_TransparencyDlgLayout->addWidget( GroupC1,      0, 0 );
   SMESHGUI_TransparencyDlgLayout->addWidget( GroupButtons, 1, 0 );
   
-  /* Initialisations */
-  this->mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
-  this->mySel = Sel ;
-  
-  /* First call valueChanged() method for initialisation               */
-  /* The default value of transparency will change with the selection  */
-  this->myFirstInit = true ;
-//  Slider1->setMaxValue( 10 );
-//  Slider1->setValue( 5 ) ;
+  mySelection = SALOME_Selection::Selection( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getSelection());
 
-
-  this->ValueHasChanged( Slider1->value() ) ;
+  // Initial state
+  this->onSelectionChanged() ;
   
   // signals and slots connections : after ValueHasChanged()
   connect( buttonOk, SIGNAL( clicked() ),         this, SLOT( ClickOnOk() ) );
-  connect( Slider1,  SIGNAL( valueChanged(int) ), this, SLOT( ValueHasChanged(int) ) );
+  connect( Slider1,  SIGNAL( valueChanged(int) ), this, SLOT( SetTransparency() ) );
+  connect( Slider1,  SIGNAL( sliderMoved(int) ),  this, SLOT( ValueHasChanged() ) );
+  connect( SMESHGUI::GetSMESHGUI(), SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnOk() ) ) ;
+  connect( mySelection,  SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
   
   /* Move widget on the botton right corner of main widget */
   int x, y ;
-  mySMESHGUI->DefineDlgPosition( this, x, y ) ;
+  SMESHGUI::GetSMESHGUI()->DefineDlgPosition( this, x, y ) ;
   this->move( x, y ) ;
-  this->show() ; /* Displays this Dialog */
+  this->show();
 }
 
 
-
-
 //=================================================================================
 // function : ~SMESHGUI_TransparencyDlg()
 // purpose  :
 //=================================================================================
 SMESHGUI_TransparencyDlg::~SMESHGUI_TransparencyDlg()
 {
-    // no need to delete child widgets, Qt does it all for us
+  // no need to delete child widgets, Qt does it all for us
 }
 
 
@@ -158,51 +184,79 @@ SMESHGUI_TransparencyDlg::~SMESHGUI_TransparencyDlg()
 //=======================================================================
 void SMESHGUI_TransparencyDlg::ClickOnOk()
 {
-  accept() ;
-  return ;
+  close();
 }
 
 
-//=======================================================================
-// function : ClickOnClose()
-// purpose  :
-//=======================================================================
-void SMESHGUI_TransparencyDlg::ClickOnClose()
+//=================================================================================
+// function : SetTransparency()
+// purpose  : Called when value of slider change
+//          : or the first time as initilisation
+//=================================================================================
+void SMESHGUI_TransparencyDlg::SetTransparency()
 {
-  accept() ;
-  return ;
+  if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+    QAD_WaitCursor wc;
+    float opacity = this->Slider1->value() / 100. ;
+    SALOME_ListIteratorOfListIO It( mySelection->StoredIObjects() );
+    for( ;It.More(); It.Next() ) {
+      Handle(SALOME_InteractiveObject) IOS = It.Value();
+      SMESH_Actor* anActor = FindActorByEntry(IOS->getEntry());
+      if ( anActor )
+       anActor->SetOpacity( opacity );
+    }
+    SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint();
+  }
+  ValueHasChanged();
 }
 
-
 //=================================================================================
 // function : ValueHasChanged()
-// purpose  : Called when value of slider change
-//          : or the first time as initilisation
+// purpose  : Called when user moves a slider
 //=================================================================================
-void SMESHGUI_TransparencyDlg::ValueHasChanged( int newValue )
+void SMESHGUI_TransparencyDlg::ValueHasChanged()
 {
+  ValueLab->setText( QString::number( this->Slider1->value() ) + "%" );
+}
 
-  if ( mySMESHGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
-    VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)mySMESHGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
-    SALOME_ListIteratorOfListIO It( this->mySel->StoredIObjects() );
-    Handle(SALOME_InteractiveObject) FirstIOS =  mySel->firstIObject();
-    if( !FirstIOS.IsNull() ) {
-      /* The first time as initialisation */
-      if( this->myFirstInit ) {        
-       this->myFirstInit = false ;
-       float transp = ( myRenderInter->GetTransparency(FirstIOS))*10.0 ;
-        this->Slider1->setValue( int(transp) ) ;
-       return;
+//=================================================================================
+// function : onSelectionChanged()
+// purpose  : Called when selection is changed
+//=================================================================================
+void SMESHGUI_TransparencyDlg::onSelectionChanged()
+{
+  if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+    int opacity = 100;
+    if ( mySelection->IObjectCount() == 1 ) {
+      Handle(SALOME_InteractiveObject) FirstIOS = mySelection->firstIObject();
+      if( !FirstIOS.IsNull() ) {
+       SMESH_Actor* anActor = FindActorByEntry( FirstIOS->getEntry() );
+       if ( anActor )
+         opacity = int( anActor->GetOpacity() * 100. + 0.5 );
       }
     }
-    
-    QApplication::setOverrideCursor( Qt::waitCursor );
-    for( ;It.More(); It.Next() ) {
-      Handle(SALOME_InteractiveObject) IOS = It.Value();
-      myRenderInter->SetTransparency( IOS, newValue/10.0 );
+    else if ( mySelection->IObjectCount() > 1 ) {
+      SALOME_ListIteratorOfListIO It( mySelection->StoredIObjects() );
+      int setOp = -1;
+      for ( ; It.More(); It.Next() ) {
+       Handle(SALOME_InteractiveObject) IO = It.Value();
+       if( !IO.IsNull() ) {
+         SMESH_Actor* anActor = FindActorByEntry( IO->getEntry() );
+         if ( anActor ) {
+           int op = int( anActor->GetOpacity() * 100. + 0.5 );
+           if ( setOp < 0 )
+             setOp = op;
+           else if ( setOp != op ) {
+             setOp = 100;
+             break;
+           }
+         }
+       }
+      }
+      if ( setOp >= 0 )
+       opacity = setOp;
     }
-    QApplication::restoreOverrideCursor();
+    Slider1->setValue( opacity ) ;
   }
-  QApplication::restoreOverrideCursor();
-  return ;
+  ValueHasChanged();
 }
index 215abe83290df8ea50b81d4a59e56914a7e0a6e9..2bc7767fabaf62b3999c2806dc9bb031126440de 100644 (file)
 #ifndef DIALOGBOX_TRANSPARENCYDLG_H
 #define DIALOGBOX_TRANSPARENCYDLG_H
 
-#include "SALOME_Selection.h"
-#include "SALOME_InteractiveObject.hxx"
-
 // QT Includes
-#include <qvariant.h>
 #include <qdialog.h>
 
-class QVBoxLayout;
-class QHBoxLayout;
-class QGridLayout;
-class QFrame;
 class QLabel;
 class QPushButton;
 class QSlider;
-class SMESHGUI;
+class SALOME_Selection;
 
 //=================================================================================
 // class    : SMESHGUI_TransparencyDlg
@@ -55,34 +47,28 @@ class SMESHGUI_TransparencyDlg : public QDialog
 
 public:
     SMESHGUI_TransparencyDlg( QWidget* parent = 0,
-                                const char* name = 0,
-                                SALOME_Selection* Sel = 0,
-                                bool modal = TRUE,
-                                WFlags fl = 0 );
+                             const char* name = 0,
+                             bool modal = false,
+                             WFlags fl = 0 );
 
     ~SMESHGUI_TransparencyDlg();
 
 private :
 
-    SMESHGUI*                        mySMESHGUI ;     /* Current GeomGUI object     */
-    bool                             myFirstInit ;    /* Inform for the first init  */
-    SALOME_Selection*                mySel;           /* User selection             */
-    
-    QPushButton* buttonOk;
-    QLabel* TextLabelOpaque;
-    QLabel* TextLabelTransparent;
-    QSlider* Slider1;
+    SALOME_Selection* mySelection;
+
+    QPushButton*      buttonOk;
+    QLabel*           TextLabelOpaque;
+    QLabel*           ValueLab;
+    QLabel*           TextLabelTransparent;
+    QSlider*          Slider1;
 
 public slots:
       
     void ClickOnOk();
-    void ClickOnClose();
-    void ValueHasChanged( int newValue ) ;
-    
-protected:
-    QGridLayout* SMESHGUI_TransparencyDlgLayout;
-    QHBoxLayout* Layout1;
-    QHBoxLayout* Layout2;
+    void ValueHasChanged() ;
+    void SetTransparency();
+    void onSelectionChanged();
 };
 
 #endif // DIALOGBOX_TRANSPARENCYDLG_H
index 60f92f2d7bb92b80b6fa54d19c1adc714b2311eb..74147762034f1905cf180218bc92de90cca3193c 100644 (file)
@@ -59,22 +59,6 @@ msgstr "mesh_connectivity.png"
 # Hypothesis
 #-----------------------------------------------------------
 
-#Hypo Local Length
-msgid "ICON_DLG_LOCAL_LENGTH"
-msgstr "mesh_hypo_length.png"
-
-#Hypo Nb Segments
-msgid "ICON_DLG_NB_SEGMENTS"
-msgstr "mesh_hypo_segment.png"
-
-#Hypo Max Area
-msgid "ICON_DLG_MAX_ELEMENT_AREA"
-msgstr "mesh_hypo_area.png"
-
-#Hypo Max Volume
-msgid "ICON_DLG_MAX_ELEMENT_VOLUME"
-msgstr "mesh_hypo_volume.png"
-
 #Set Algo
 msgid "ICON_DLG_ADD_ALGORITHM"
 msgstr "mesh_set_algo.png"
@@ -118,53 +102,40 @@ msgstr "mesh_hexa.png"
 
 
 #-----------------------------------------------------------
-# ObjectBrother
+# ObjectBrowser
 #-----------------------------------------------------------
 
 #mesh_tree_mesh
 msgid "ICON_SMESH_TREE_MESH"
 msgstr "mesh_tree_mesh.png"    
 
+#mesh_tree_group
+msgid "ICON_SMESH_TREE_GROUP"
+msgstr "mesh_tree_group.png"   
+
 #mesh_tree_algo
 msgid "ICON_SMESH_TREE_ALGO"
 msgstr "mesh_tree_algo.png"
 
-#mesh_tree_algo_regular
-msgid "ICON_SMESH_TREE_ALGO_Regular_1D"
-msgstr "mesh_tree_algo_regular.png"
-
-#mesh_tree_algo_hexa
-msgid "ICON_SMESH_TREE_ALGO_Hexa_3D"
-msgstr "mesh_tree_algo_hexa.png"
-
-#mesh_tree_algo_mefisto
-msgid "ICON_SMESH_TREE_ALGO_MEFISTO_2D"
-msgstr "mesh_tree_algo_mefisto.png"
-
-#mesh_tree_algo_quad
-msgid "ICON_SMESH_TREE_ALGO_Quadrangle_2D"
-msgstr "mesh_tree_algo_quad.png"
-
 #mesh_tree_hypo
 msgid "ICON_SMESH_TREE_HYPO"
 msgstr "mesh_tree_hypo.png"
 
-#mesh_tree_hypo_area
-msgid "ICON_SMESH_TREE_HYPO_MaxElementArea"
-msgstr "mesh_tree_hypo_area.png"
+#mesh_tree_mesh_warn
+msgid "ICON_SMESH_TREE_MESH_WARN"
+msgstr "mesh_tree_mesh_warn.png"
 
-#mesh_tree_hypo_length
-msgid "ICON_SMESH_TREE_HYPO_LocalLength"
-msgstr "mesh_tree_hypo_length.png"
+#mesh_tree_mesh
+msgid "ICON_SMESH_TREE_MESH_IMPORTED"
+msgstr "mesh_tree_importedmesh.png"
 
-#mesh_tree_hypo_segment
-msgid "ICON_SMESH_TREE_HYPO_NumberOfSegments"
-msgstr "mesh_tree_hypo_segment.png"
 
-#mesh_tree_hypo_volume
-msgid "ICON_SMESH_TREE_HYPO_MaxElementVolume"
-msgstr "mesh_tree_hypo_volume.png"
+#-----------------------------------------------------------
+# Group
+#-----------------------------------------------------------
 
-#mesh_tree_mesh_warn
-msgid "ICON_SMESH_TREE_MESH_WARN"
-msgstr "mesh_tree_mesh_warn.png"
+msgid "ICON_EDIT_GROUP"
+msgstr "mesh_edit_group.png"
+
+msgid "ICON_CONSTRUCT_GROUP"
+msgstr "mesh_make_group.png"
index c593f9571663227632509ecd6597f29845e98dee..38d6f37ed96c6ac5011df30f8677902d161f89a1 100644 (file)
@@ -38,11 +38,34 @@ msgstr "&No"
 msgid "SMESH_BUT_CANCEL"
 msgstr "&Cancel"
 
+#Add
+msgid "SMESH_BUT_ADD"
+msgstr "A&dd"
+
+#Remove
+msgid "SMESH_BUT_REMOVE"
+msgstr "&Remove"
+
+#Set Filters
+msgid "SMESH_BUT_FILTER"
+msgstr "Set &Filters"
+
+#Sort
+msgid "SMESH_BUT_SORT"
+msgstr "&Sort List"
+
+#Create
+msgid "SMESH_BUT_CREATE"
+msgstr "Create"
 
 #-------------------------------------------------------------------------
 # WARNING
 #-------------------------------------------------------------------------
 
+#Error
+msgid "SMESH_ERROR"
+msgstr "Error"
+
 #Warning
 msgid "SMESH_WRN_WARNING"
 msgstr "Warning"
@@ -83,6 +106,9 @@ msgstr "Activate Nodes Selection Mode"
 msgid "SMESH_WRN_SELECTIONMODE_DIAGONAL"
 msgstr "Activate Link Selection Mode"
 
+#Empty name
+msgid "SMESH_WRN_EMPTY_NAME" 
+msgstr "Empty name is not valid"
 
 #-------------------------------------------------------------------------
 # MEN
@@ -114,19 +140,19 @@ msgstr "SubMeshes On Compound"
 
 #Applied Algorithm
 msgid "SMESH_MEN_APPLIED_ALGORIHTMS"
-msgstr "Applied Algorithm"
+msgstr "Applied Algorithms"
 
 #Applied Hypothesis
 msgid "SMESH_MEN_APPLIED_HYPOTHESIS"
-msgstr "Applied Hypothesis"
+msgstr "Applied Hypotheses"
 
 #Hypothesis Definition
 msgid "SMESH_MEN_HYPOTHESIS"
-msgstr "Hypothesis Definition"
+msgstr "Hypotheses"
 
 #Algorithms Definition
 msgid "SMESH_MEN_ALGORITHMS"
-msgstr "Algorithms Definition"
+msgstr "Algorithms"
 
 
 #-------------------------------------------------------------------------
@@ -207,6 +233,18 @@ msgstr "SubMesh"
 
 # -------------- Hypothesis / Algorithm --------------
 
+#Meshers file
+msgid "MESHERS_FILE_NO_VARIABLE"
+msgstr "Environment variable SMESH_MeshersList is not defined"
+
+#Meshers file
+msgid "MESHERS_FILE_CANT_OPEN"
+msgstr "Can not open resource file"
+
+#Meshers file
+msgid "MESHERS_FILE_CHECK_VARIABLE"
+msgstr "Check environment variable SMESH_MeshersList"
+
 #Hypothesis
 msgid "SMESH_ADD_HYPOTHESIS"
 msgstr "Hypothesis"
@@ -219,14 +257,6 @@ msgstr "Hypothesis Assignation"
 msgid "SMESH_OBJECT_HYPOTHESIS"
 msgstr "Hypothesis"
 
-#Local Length
-msgid "SMESH_LOCAL_LENGTH_HYPOTHESIS"
-msgstr "Local Length"
-
-#Hypothesis Construction
-msgid "SMESH_LOCAL_LENGTH_TITLE"
-msgstr "Hypothesis Construction"
-
 #Algorithms
 msgid "SMESH_ADD_ALGORITHM"
 msgstr "Algorithms"
@@ -239,38 +269,6 @@ msgstr "Algorithms Assignation"
 msgid "SMESH_OBJECT_ALGORITHM"
 msgstr "Algorithm"
 
-#Number of Segments
-msgid "SMESH_NB_SEGMENTS_HYPOTHESIS"
-msgstr "Number of Segments"
-
-#Hypothesis Construction
-msgid "SMESH_NB_SEGMENTS_TITLE"
-msgstr "Hypothesis Construction"
-
-#Max. Area
-msgid "SMESH_MAX_ELEMENT_AREA"
-msgstr "Max. Area"
-
-#Max. Element Area
-msgid "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"
-msgstr "Max. Element Area"
-
-#Hypothesis Construction
-msgid "SMESH_MAX_ELEMENT_AREA_TITLE"
-msgstr "Hypothesis Construction"
-
-#Max. Volume
-msgid "SMESH_MAX_ELEMENT_VOLUME"
-msgstr "Max. Volume"
-
-#Max. Element Volume
-msgid "SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"
-msgstr "Max. Element Volume"
-
-#Hypothesis Construction
-msgid "SMESH_MAX_ELEMENT_VOLUME_TITLE"
-msgstr "Hypothesis Construction"
-
 
 # -------------- Nodes / Segments / Elements --------------
 
@@ -391,87 +389,118 @@ msgstr "Add Hexahedron"
 
 #Opacity
 msgid "SMESH_TRANSPARENCY_OPAQUE"
-msgstr "Opacity"
+msgstr "---> Opaque"
 
 #Transparency
 msgid "SMESH_TRANSPARENCY_TITLE"
-msgstr "Transparency"
+msgstr "Change Transparency"
 
 #Fully Transparency
 msgid "SMESH_TRANSPARENCY_TRANSPARENT"
-msgstr "Fully Transparency"
+msgstr "Transparent <---"
 
 
 # -------------- Preferences -----------
 
+#Scalar Bar Preferences
+msgid "SMESH_PROPERTIES_SCALARBAR"
+msgstr "Scalar Bar Properties"
+
+#Scalar Bar Properties
+msgid "SMESH_PREFERENCES_SCALARBAR"
+msgstr "Scalar Bar Preferences"
+
+#Scalar Bar Range
+msgid "SMESH_RANGE_SCALARBAR"
+msgstr "Scalar Range"
+
+#Scalar Bar Range Min Value
+msgid "SMESH_RANGE_MIN"
+msgstr "Min value:"
+
+#Scalar Bar Range Max Value
+msgid "SMESH_RANGE_MAX"
+msgstr "Max value:"
+
+#Scalar Bar Font
+msgid "SMESH_FONT_SCALARBAR"
+msgstr "Font"
+
 #Arial
 msgid "SMESH_FONT_ARIAL"
 msgstr "Arial"
 
-#Bold
-msgid "SMESH_FONT_BOLD"
-msgstr "Bold"
-
 #Courier
 msgid "SMESH_FONT_COURIER"
 msgstr "Courier"
 
-#Dimensions
-msgid "SMESH_DIMENSIONS"
-msgstr "Dimensions"
-
-#Font
-msgid "SMESH_FONT"
-msgstr "Font"
-
-#Height
-msgid "SMESH_HEIGHT"
-msgstr "Height"
+#Times
+msgid "SMESH_FONT_TIMES"
+msgstr "Times"
 
-#Horizontal
-msgid "SMESH_HORIZONTAL"
-msgstr "Horizontal"
+#Bold
+msgid "SMESH_FONT_BOLD"
+msgstr "Bold"
 
 #Italic
 msgid "SMESH_FONT_ITALIC"
 msgstr "Italic"
 
-#Scalar Bar Preferences
-msgid "SMESH_PREFERENCES_SCALARBAR"
-msgstr "Scalar Bar Preferences"
+#Shadow
+msgid "SMESH_FONT_SHADOW"
+msgstr "Shadow"
+
+#Title
+msgid "SMESH_TITLE"
+msgstr "Title:"
+
+#Labels
+msgid "SMESH_LABELS"
+msgstr "Labels:"
+
+#Colors & Labels
+msgid "SMESH_LABELS_COLORS_SCALARBAR"
+msgstr "Colors && Labels"
 
 #Number Of Colors
 msgid "SMESH_NUMBEROFCOLORS"
-msgstr "Number Of Colors"
+msgstr "Nb of colors:"
 
 #Number Of Labels
 msgid "SMESH_NUMBEROFLABELS"
-msgstr "Number Of Labels"
+msgstr "Nb of labels:"
 
 #Orientation
 msgid "SMESH_ORIENTATION"
 msgstr "Orientation"
 
-#Properties
-msgid "SMESH_PROPERTIES"
-msgstr "Properties"
-
-#Shadow
-msgid "SMESH_FONT_SHADOW"
-msgstr "Shadow"
-
-#Times
-msgid "SMESH_FONT_TIMES"
-msgstr "Times"
-
 #Vertical
 msgid "SMESH_VERTICAL"
 msgstr "Vertical"
 
+#Horizontal
+msgid "SMESH_HORIZONTAL"
+msgstr "Horizontal"
+
+#Position & Size
+msgid "SMESH_POSITION_SIZE_SCALARBAR"
+msgstr "Origin && Size"
+
+#X
+msgid "SMESH_X_SCALARBAR"
+msgstr "X:"
+
+#Y
+msgid "SMESH_Y_SCALARBAR"
+msgstr "Y:"
+
 #Width
 msgid "SMESH_WIDTH"
-msgstr "Width"
+msgstr "Width:"
 
+#Height
+msgid "SMESH_HEIGHT"
+msgstr "Height:"
 
 # -------------- ScalarBar --------------
 
@@ -485,7 +514,7 @@ msgstr "Min"
 
 #ScalarBar
 msgid "SMESH_SCALARBAR"
-msgstr "ScalarBar"
+msgstr "Scalar Bar"
 
 #Update View
 msgid "SMESH_UPDATEVIEW"
@@ -510,10 +539,6 @@ msgstr "Manifold Edges"
 msgid "SMESH_NONMANIFOLDEDGES"
 msgstr "Non Manifold Edges"
 
-#Edges Connectivity
-msgid "SMESH_EDGES_CONNECTIVITY"
-msgstr "Edges Connectivity"
-
 #Edges Connectivity
 msgid "SMESH_EDGES_CONNECTIVITY_TITLE"
 msgstr "Edges Connectivity"
@@ -551,72 +576,87 @@ msgstr "Diagonal Inversion"
 msgid "SMESH_MESHINFO_TITLE"
 msgstr "Mesh Infos"
 
-#Number Of 1D Elements
-msgid "SMESH_MESHINFO_NB1D"
-msgstr "Number Of 1D Elements"
-
-#Number Of 2D Elements
-msgid "SMESH_MESHINFO_NB2D"
-msgstr "Number Of 2D Elements"
+#Mesh Infos
+msgid "SMESH_MESHINFO_NAME"
+msgstr "Name"
 
-#Number Of 3D Elements
-msgid "SMESH_MESHINFO_NB3D"
-msgstr "Number Of 3D Elements"
+#Faces :
+msgid "SMESH_MESHINFO_ELEMENTS"
+msgstr "Elements"
 
 #Edges :
 msgid "SMESH_MESHINFO_EDGES"
-msgstr "Edges :"
+msgstr "Edges"
 
 #Nodes :
 msgid "SMESH_MESHINFO_NODES"
-msgstr "Nodes :"
+msgstr "Nodes"
+
+#Faces :
+msgid "SMESH_MESHINFO_FACES"
+msgstr "Faces"
+
+#Total :
+msgid "SMESH_MESHINFO_TOTAL"
+msgstr "Total"
 
 #Triangles :
 msgid "SMESH_MESHINFO_TRIANGLES"
-msgstr "Triangles :"
+msgstr "Triangles"
 
 #Quadrangles :
 msgid "SMESH_MESHINFO_QUADRANGLES"
-msgstr "Quadrangles :"
+msgstr "Quadrangles"
+
+#Volumes :
+msgid "SMESH_MESHINFO_VOLUMES"
+msgstr "Volumes"
 
 #Tetrahedrons :
 msgid "SMESH_MESHINFO_TETRAS"
-msgstr "Tetrahedrons :"
+msgstr "Tetrahedrons"
 
 #Hexahedrons :
 msgid "SMESH_MESHINFO_HEXAS"
-msgstr "Hexahedrons :"
+msgstr "Hexahedrons"
 
+#Pyramids :
+msgid "SMESH_MESHINFO_PYRAS"
+msgstr "Pyramids"
 
-# -------------- Controls --------------
+#Prisms :
+msgid "SMESH_MESHINFO_PRISMS"
+msgstr "Prisms"
 
-#Length
-msgid "SMESH_CONTROL_LENGTH_EDGES"
-msgstr "Length"
+#Type :
+msgid "SMESH_MESHINFO_TYPE"
+msgstr "Type"
 
-#Area
-msgid "SMESH_CONTROL_AREA_ELEMENTS"
-msgstr "Area"
+#Entities :
+msgid "SMESH_MESHINFO_ENTITIES"
+msgstr "Entities"
 
-#Taper
-msgid "SMESH_CONTROL_TAPER_ELEMENTS"
-msgstr "Taper"
+#All types :
+msgid "SMESH_MESHINFO_ALL_TYPES"
+msgstr "Heterogenous"
 
-#Aspect Ratio
-msgid "SMESH_CONTROL_ASPECTRATIO_ELEMENTS"
-msgstr "Aspect Ratio"
+#No valid selection :
+msgid "SMESH_BAD_SELECTION"
+msgstr "No valid selection"
 
-#Minimum Angle
-msgid "SMESH_CONTROL_MINIMUMANGLE_ELEMENTS"
-msgstr "Minimum Angle"
+# --------- Create hypotheses/algorithms ---------
 
-#Warp
-msgid "SMESH_CONTROL_WARP_ELEMENTS"
-msgstr "Warp"
+msgid "SMESH_CREATE_HYPOTHESES"
+msgstr "Create hypotheses"
 
-#Skew
-msgid "SMESH_CONTROL_SKEW_ELEMENTS"
-msgstr "Skew"
+msgid "SMESH_CREATE_ALGORITHMS"
+msgstr "Create algorithms"
+
+msgid "SMESH_AVAILABLE_ALGORITHMS"
+msgstr "Available algorithms"
+
+msgid "SMESH_AVAILABLE_HYPOTHESES"
+msgstr "Available hypotheses"
 
 # -------------- Edit --------------
 
@@ -636,3 +676,247 @@ msgstr "Available"
 msgid "SMESH_EDIT_USED"
 msgstr "Used"
 
+# -------------- Group --------------
+
+#Create Group
+msgid "SMESH_CREATE_GROUP_TITLE"
+msgstr "Create Group"
+
+#Edit Group
+msgid "SMESH_EDIT_GROUP_TITLE"
+msgstr "Edit Group"
+
+#Elements Type
+msgid "SMESH_ELEMENTS_TYPE"
+msgstr "Elements Type"
+
+#Face
+msgid "SMESH_FACE"
+msgstr "Face"
+
+#Volume
+msgid "SMESH_VOLUME"
+msgstr "Volume"
+
+#Content
+msgid "SMESH_CONTENT"
+msgstr "Content"
+
+#Select rom
+msgid "SMESH_SELECT_FROM"
+msgstr "Select From"
+
+#Group
+msgid "SMESH_GROUP"
+msgstr "Group"
+
+#%1 SubMeshes
+msgid "SMESH_SUBMESH_SELECTED"
+msgstr "%1 SubMeshes"
+
+#%1 Groups
+msgid "SMESH_GROUP_SELECTED"
+msgstr "%1 Groups"
+
+
+# -------------- Preferences - Selection --------------
+msgid "SMESH_PREF_SELECTION"
+msgstr "Preferences - Selection"
+
+msgid "SMESH_SELECTION"
+msgstr "Selection"
+
+msgid "SMESH_PRESELECTION"
+msgstr "Preselection"
+
+msgid "SMESH_HILIGHT_COLOR"
+msgstr "Highlight Color"
+
+msgid "SMESH_ELEMENTS_COLOR"
+msgstr "Mesh Element Color"
+
+msgid "SMESH_PRECISION"
+msgstr "Precision"
+
+msgid "SMESH_OUTLINE_COLOR"
+msgstr "Mesh Object Color"
+
+
+# -------------- SMESHGUI_FilterDlg --------------
+msgid "SMESHGUI_FilterDlg::FACES_TLT"
+msgstr "Filter for Faces"
+
+msgid "SMESHGUI_FilterDlg::EDGES_TLT"
+msgstr "Filter for Edges"
+
+msgid "SMESHGUI_FilterDlg::ADD"
+msgstr "Add"
+
+msgid "SMESHGUI_FilterDlg::REMOVE"
+msgstr "Remove"
+
+msgid "SMESHGUI_FilterDlg::CRITERION"
+msgstr "Criterion"
+
+msgid "SMESHGUI_FilterDlg::COMPARE"
+msgstr "Compare"
+
+msgid "SMESHGUI_FilterDlg::THRESHOLD_VALUE"
+msgstr "Threshold value"
+
+msgid "SMESHGUI_FilterDlg::UNARY"
+msgstr "Unary"
+
+msgid "SMESHGUI_FilterDlg::BINARY"
+msgstr "Binary"
+
+msgid "SMESHGUI_FilterDlg::FREE_BORDERS"
+msgstr "Free borders"
+
+msgid "SMESHGUI_FilterDlg::MULTI_BORDERS"
+msgstr "Borders at multi-connections"
+
+msgid "SMESHGUI_FilterDlg::LENGTH"
+msgstr "Length"
+
+msgid "SMESHGUI_FilterDlg::ASPECT_RATIO"
+msgstr "Aspect ratio"
+
+msgid "SMESHGUI_FilterDlg::WARPING"
+msgstr "Warping"
+
+msgid "SMESHGUI_FilterDlg::MINIMUM_ANGLE"
+msgstr "Minimum angle"
+
+msgid "SMESHGUI_FilterDlg::TAPER"
+msgstr "Taper"
+
+msgid "SMESHGUI_FilterDlg::SKEW"
+msgstr "Skew"
+
+msgid "SMESHGUI_FilterDlg::AREA"
+msgstr "Area"
+
+msgid "SMESHGUI_FilterDlg::LESS_THAN"
+msgstr "Less than"
+
+msgid "SMESHGUI_FilterDlg::MORE_THAN"
+msgstr "More than"
+
+msgid "SMESHGUI_FilterDlg::EQUAL_TO"
+msgstr "Equal to"
+
+msgid "SMESHGUI_FilterDlg::NOT"
+msgstr "Not"
+
+msgid "SMESHGUI_FilterDlg::AND"
+msgstr "And"
+
+msgid "SMESHGUI_FilterDlg::OR"
+msgstr "Or"
+
+msgid "SMESHGUI_FilterDlg::ERROR"
+msgstr "Threshold value is not correctly specified\nPlease enter correct value and try again"
+
+msgid "SMESHGUI_FilterDlg::MULTIEDGES_ERROR"
+msgstr "Threshold value of borders at multi-connections can not be equal 1\nPlease enter correct value and try again"
+
+msgid "SMESHGUI_FilterDlg::SOURCE"
+msgstr "Source"
+
+msgid "SMESHGUI_FilterDlg::MESH"
+msgstr "Mesh"
+
+msgid "SMESHGUI_FilterDlg::SELECTION"
+msgstr "Current Selection"
+
+msgid "SMESHGUI_FilterDlg::CURRENT_GROUP"
+msgstr "Current Group"
+
+msgid "SMESHGUI_FilterDlg::NONE"
+msgstr "None"
+
+msgid "SMESHGUI_FilterDlg::SET_IN_VIEWER"
+msgstr "Insert filter in viewer"
+
+msgid "SMESHGUI_FilterDlg::CLEAR"
+msgstr "Clear"
+
+# -------------- SMESHGUI --------------
+msgid "SMESHGUI::MESH_IS_NOT_SELECTED"
+msgstr "There is no selected mesh\nPlease, select a mesh and try again"
+
+msgid "SMESHGUI::NOT_A_VTK_VIEWER"
+msgstr "This command is available in VTK viewer only\nPlease, create VTK viewer and try again"
+
+msgid "SMESHGUI::LENGTH_EDGES"
+msgstr "Length"
+
+msgid "SMESHGUI::FREE_BORDERS"
+msgstr "Free borders"
+
+msgid "SMESHGUI::MULTI_BORDERS"
+msgstr "Borders at multi-connections"
+
+msgid "SMESHGUI::AREA_ELEMENTS"
+msgstr "Area"
+
+msgid "SMESHGUI::TAPER_ELEMENTS"
+msgstr "Taper"
+
+msgid "SMESHGUI::ASPECTRATIO_ELEMENTS"
+msgstr "Aspect Ratio"
+
+msgid "SMESHGUI::MINIMUMANGLE_ELEMENTS"
+msgstr "Minimum Angle"
+
+msgid "SMESHGUI::WARP_ELEMENTS"
+msgstr "Warp"
+
+msgid "SMESHGUI::SKEW_ELEMENTS"
+msgstr "Skew"
+
+msgid "SMESH_INSUFFICIENT_DATA"
+msgstr "Insufficient input value"
+
+msgid "SMESH_HYP_1"
+msgstr "Algorithm misses a hypothesis"
+
+msgid "SMESH_HYP_2"
+msgstr "Concurrent hypotheses on a shape"
+
+msgid "SMESH_HYP_3"
+msgstr "Hypothesis has a bad parameter value"
+
+msgid "SMESH_HYP_4"
+msgstr "Unknown fatal error while assigning hypothesis"
+
+msgid "SMESH_HYP_5"
+msgstr "Hypothesis is not suitable in the current context"
+
+msgid "SMESH_HYP_6"
+msgstr "Non-conform mesh is produced using applied hypotheses"
+
+msgid "SMESH_HYP_7"
+msgstr "Such hypothesis is already assigned to the shape"
+
+msgid "SMESH_HYP_8"
+msgstr "Hypothesis and submesh dimensions mismatch"
+
+msgid "SMESH_DRS_1"
+msgstr "MED file contains no mesh with the given name"
+
+msgid "SMESH_DRS_2"
+msgstr ""
+"MED file has overlapped ranges of element numbers,\n"
+"     the numbers from the file are ignored"
+
+msgid "SMESH_DRS_3"
+msgstr "Some elements were skipped due to incorrect file data"
+
+msgid "SMESH_DRS_4"
+msgstr "    The file is incorrect,\n"
+       "some information will be missed"
+
+msgid "INF_SELECT_OBJECT"
+msgstr "Select an object"
\ No newline at end of file
index 44991ebdeec9bb8973eff68463628376962e85ba..2f38fc04e4792c8aaa0f02e6a3ce5f2043005881 100644 (file)
 top_srcdir=@top_srcdir@
 top_builddir=../..
 srcdir=@srcdir@
-VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
+VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:
 
 
 @COMMENCE@
 
+# header files  
+EXPORT_HEADERS= \
+       SMESH_Gen_i.hxx \
+       SMESH_Algo_i.hxx \
+       SMESH_1D_Algo_i.hxx \
+       SMESH_2D_Algo_i.hxx \
+       SMESH_3D_Algo_i.hxx \
+       SMESH_subMesh_i.hxx \
+       SMESH_topo.hxx \
+       SMESH_Mesh_i.hxx \
+       SMESH_Hypothesis_i.hxx
+
 EXPORT_PYSCRIPTS = smeshpy.py SMESH_test.py
 
 # Libraries targets
 
 LIB= libSMESHEngine.la
 
-LIB_SRC = SMESH_Gen_i.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 \
-          SMESH_topo.cxx SMESH_HypothesisFactory_i.cxx \
-          SMESH_Algo_i.cxx \
-          SMESH_1D_Algo_i.cxx \
-          SMESH_2D_Algo_i.cxx \
-          SMESH_3D_Algo_i.cxx \
-          SMESH_NumberOfSegments_i.cxx \
-          SMESH_LocalLength_i.cxx \
-          SMESH_MaxElementArea_i.cxx \
-         SMESH_LengthFromEdges_i.cxx \
-          SMESH_MaxElementVolume_i.cxx \
-          SMESH_Regular_1D_i.cxx \
-          SMESH_Quadrangle_2D_i.cxx \
-          SMESH_MEFISTO_2D_i.cxx \
-          SMESH_Hexa_3D_i.cxx
+LIB_SRC = \
+       SMESH_Gen_i.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 \
+        SMESH_topo.cxx \
+        SMESH_Algo_i.cxx \
+        SMESH_1D_Algo_i.cxx \
+        SMESH_2D_Algo_i.cxx \
+        SMESH_3D_Algo_i.cxx \
+       SMESH_Filter_i.cxx \
+       SMESH_Group_i.cxx
 
 LIB_SERVER_IDL = SMESH_Gen.idl SMESH_Hypothesis.idl SMESH_Mesh.idl \
                  SALOME_Component.idl SALOME_Exception.idl \
-                 SMESH_BasicHypothesis.idl
+                 SMESH_Filter.idl SMESH_Group.idl
 
-LIB_CLIENT_IDL = SALOMEDS.idl GEOM_Gen.idl GEOM_Shape.idl MED.idl SALOMEDS_Attributes.idl
+LIB_CLIENT_IDL = SALOMEDS.idl GEOM_Gen.idl GEOM_Shape.idl MED.idl SALOMEDS_Attributes.idl SALOME_GenericObj.idl
 
 # Executables targets
 BIN = 
 BIN_SRC = 
 
 # additionnal information to compil and link file
-CPPFLAGS+= $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome
-CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome
+CPPFLAGS+= $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
+           -I${GEOM_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
+CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
+           -I${GEOM_ROOT_DIR}/include/salome
 
 #IDLCXXFLAGS+= -Wbtp
 
-LDFLAGS+= $(HDF5_LIBS) $(MED2_LIBS) -lSMESHimpl -lSalomeContainer -lSalomeNS -lSalomeDS -lRegistry -lSalomeHDFPersist -lOpUtil -lGEOMClient -lSMESHDS -lSMDS -lMEFISTO2D -lMeshDriverMED -lSalomeLifeCycleCORBA -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome
-
-ifeq (@WITHNETGEN@,yes)
-  LIB_SRC += SMESH_NETGEN_3D_i.cxx
-  LDFLAGS += -lNETGEN
-endif
+LDFLAGS+= $(HDF5_LIBS) $(MED2_LIBS) -lSMESHimpl -lSalomeContainer -lSalomeNS -lSalomeDS -lRegistry -lSalomeHDFPersist -lOpUtil -lGEOMClient -lSMESHDS -lSMDS -lMeshDriverMED -lSalomeLifeCycleCORBA -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeGenericObj
 
 @CONCLUDE@
-
index ae37c94352482b9df143eccf651242068657d865..a792ec2872b382994286ed6e94bf4e0e64d78674 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 using namespace std;
 #include "SMESH_1D_Algo_i.hxx"
-#include "SMESH_Gen.hxx"
-#include "SMESH_HypothesisFactory.hxx"
 
-#include "Utils_CorbaException.hxx"
 #include "utilities.h"
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_1D_Algo_i::SMESH_1D_Algo_i
+ * 
+ *  Constructor
  */
 //=============================================================================
 
-SMESH_1D_Algo_i::SMESH_1D_Algo_i()
+SMESH_1D_Algo_i::SMESH_1D_Algo_i( PortableServer::POA_ptr thePOA )
+     : SALOME::GenericObj_i( thePOA ), 
+       SMESH_Hypothesis_i( thePOA ), 
+       SMESH_Algo_i( thePOA )
 {
-  MESSAGE("SMESH_1D_Algo_i::SMESH_1D_Algo_i");
+  MESSAGE( "SMESH_1D_Algo_i::SMESH_1D_Algo_i" );
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_1D_Algo_i::~SMESH_1D_Algo_i
+ * 
+ *  Destructor
  */
 //=============================================================================
 
 SMESH_1D_Algo_i::~SMESH_1D_Algo_i()
 {
-  MESSAGE("SMESH_1D_Algo_i::~SMESH_1D_Algo_i");
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-void SMESH_1D_Algo_i::SetImpl(::SMESH_1D_Algo* impl)
-{
-  MESSAGE("SMESH_1D_Algo_i::SetImpl");
-  SMESH_Algo_i::SetImpl(impl);
-  _impl = impl;
+  MESSAGE( "SMESH_1D_Algo_i::~SMESH_1D_Algo_i" );
 }
index 4f619ea998522d65089e66a1754deb242d3c3e30..16ab9b4410fb88bd63739657750a9febf0241747 100644 (file)
 
 #include "SMESH_Algo_i.hxx"
 
-#include "SMESH_1D_Algo.hxx"
-
+// ======================================================
+// Generic 1D algorithm
+// ======================================================
 class SMESH_1D_Algo_i:
-  public POA_SMESH::SMESH_1D_Algo,
-  public SMESH_Algo_i
+  public virtual POA_SMESH::SMESH_1D_Algo,
+  public virtual SMESH_Algo_i
 {
-public:
-  SMESH_1D_Algo_i();
-
-  virtual ~SMESH_1D_Algo_i();
-
 protected:
-  virtual void SetImpl(::SMESH_1D_Algo* impl);
+  // Constructor : placed in protected section to prohibit creation of generic class instance
+  SMESH_1D_Algo_i( PortableServer::POA_ptr thePOA );
 
-  ::SMESH_1D_Algo* _impl;
+public:
+  // Destructor
+  virtual ~SMESH_1D_Algo_i();
 };
 
 #endif
index 4114c0d779b750543c3464025eb71cbe3ddab340..833be2ac9451880abd7d1e3839831ddf3554e3f0 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 using namespace std;
 #include "SMESH_2D_Algo_i.hxx"
-#include "SMESH_Gen.hxx"
-#include "SMESH_HypothesisFactory.hxx"
 
-#include "Utils_CorbaException.hxx"
 #include "utilities.h"
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_2D_Algo_i::SMESH_2D_Algo_i
+ * 
+ *  Constructor
  */
 //=============================================================================
 
-SMESH_2D_Algo_i::SMESH_2D_Algo_i()
+SMESH_2D_Algo_i::SMESH_2D_Algo_i( PortableServer::POA_ptr thePOA )
+     : SALOME::GenericObj_i( thePOA ), 
+       SMESH_Hypothesis_i( thePOA ), 
+       SMESH_Algo_i( thePOA ) 
 {
-  MESSAGE("SMESH_2D_Algo_i::SMESH_2D_Algo_i");
+  MESSAGE( "SMESH_2D_Algo_i::SMESH_2D_Algo_i" );
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_2D_Algo_i::~SMESH_2D_Algo_i
+ * 
+ *  Destructor
  */
 //=============================================================================
 
 SMESH_2D_Algo_i::~SMESH_2D_Algo_i()
 {
-  MESSAGE("SMESH_2D_Algo_i::~SMESH_2D_Algo_i");
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-void SMESH_2D_Algo_i::SetImpl(::SMESH_2D_Algo* impl)
-{
-  MESSAGE("SMESH_2D_Algo_i::SetImpl");
-  SMESH_Algo_i::SetImpl(impl);
-  _impl = impl;
+  MESSAGE( "SMESH_2D_Algo_i::~SMESH_2D_Algo_i" );
 }
index 3143aa431d5b6a1b8495771629e0f2456f077595..cebda6197e1808561671e2749fa8640839f1f87c 100644 (file)
 
 #include "SMESH_Algo_i.hxx"
 
-#include "SMESH_2D_Algo.hxx"
-
+// ======================================================
+// Generic 2D algorithm
+// ======================================================
 class SMESH_2D_Algo_i:
-  public POA_SMESH::SMESH_2D_Algo,
-  public SMESH_Algo_i
+  public virtual POA_SMESH::SMESH_2D_Algo,
+  public virtual SMESH_Algo_i
 {
-public:
-  SMESH_2D_Algo_i();
-
-  virtual ~SMESH_2D_Algo_i();
-
 protected:
-  virtual void SetImpl(::SMESH_2D_Algo* impl);
+  // Constructor : placed in protected section to prohibit creation of generic class instance
+  SMESH_2D_Algo_i( PortableServer::POA_ptr thePOA );
 
-  ::SMESH_2D_Algo* _impl;
+public:
+  // Destructor
+  virtual ~SMESH_2D_Algo_i();
 };
 
 #endif
index e28872c7784d4ead1e06545f077be9298c5e2aea..197fc4448405d31ed509ae5180e7b5955e910e74 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 using namespace std;
 #include "SMESH_3D_Algo_i.hxx"
-#include "SMESH_Gen.hxx"
-#include "SMESH_HypothesisFactory.hxx"
 
-#include "Utils_CorbaException.hxx"
 #include "utilities.h"
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_3D_Algo_i::SMESH_3D_Algo_i
+ * 
+ *  Constructor
  */
 //=============================================================================
 
-SMESH_3D_Algo_i::SMESH_3D_Algo_i()
+SMESH_3D_Algo_i::SMESH_3D_Algo_i( PortableServer::POA_ptr thePOA )
+     : SALOME::GenericObj_i( thePOA ), 
+       SMESH_Hypothesis_i( thePOA ), 
+       SMESH_Algo_i( thePOA )
 {
-  MESSAGE("SMESH_3D_Algo_i::SMESH_3D_Algo_i");
+  MESSAGE( "SMESH_3D_Algo_i::SMESH_3D_Algo_i" );
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_3D_Algo_i::~SMESH_3D_Algo_i
+ * 
+ *  Destructor
  */
 //=============================================================================
 
 SMESH_3D_Algo_i::~SMESH_3D_Algo_i()
 {
-  MESSAGE("SMESH_3D_Algo_i::~SMESH_3D_Algo_i");
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-void SMESH_3D_Algo_i::SetImpl(::SMESH_3D_Algo* impl)
-{
-  MESSAGE("SMESH_3D_Algo_i::SetImpl");
-  SMESH_Algo_i::SetImpl(impl);
-  _impl = impl;
+  MESSAGE( "SMESH_3D_Algo_i::~SMESH_3D_Algo_i" );
 }
index aa75717a22491a85be12570a404074d187f23aa8..a45336a39b3ba7604ae3e03608a33a67b7d64330 100644 (file)
 
 #include "SMESH_Algo_i.hxx"
 
-class SMESH_3D_Algo;
-
+// ======================================================
+// Generic 3D algorithm
+// ======================================================
 class SMESH_3D_Algo_i:
-  public POA_SMESH::SMESH_3D_Algo,
-  public SMESH_Algo_i
+  public virtual POA_SMESH::SMESH_3D_Algo,
+  public virtual SMESH_Algo_i
 {
-public:
-  SMESH_3D_Algo_i();
-
-  virtual ~SMESH_3D_Algo_i();
-
 protected:
-  virtual void SetImpl(::SMESH_3D_Algo* impl);
+  // Constructor : placed in protected section to prohibit creation of generic class instance
+  SMESH_3D_Algo_i( PortableServer::POA_ptr thePOA );
 
-  ::SMESH_3D_Algo* _impl;
+public:
+  // Destructor
+  virtual ~SMESH_3D_Algo_i();
 };
 
 #endif
index d5f747bb2fee4fee37a307b06dcdb2d205d69823..17995f4b7ddd5a1090987e424e963551b2913aa9 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 using namespace std;
 #include "SMESH_Algo_i.hxx"
-#include "SMESH_Gen.hxx"
-#include "SMESH_HypothesisFactory.hxx"
+#include "SMESH_Algo.hxx"
 
-#include "Utils_CorbaException.hxx"
 #include "utilities.h"
 
 #include <string>
@@ -40,56 +37,49 @@ using namespace std;
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Algo_i::SMESH_Algo_i
+ * 
+ *  Constructor
  */
 //=============================================================================
 
-SMESH_Algo_i::SMESH_Algo_i()
+SMESH_Algo_i::SMESH_Algo_i( PortableServer::POA_ptr thePOA )
+     : SALOME::GenericObj_i( thePOA ), 
+       SMESH_Hypothesis_i( thePOA )
 {
-  MESSAGE("SMESH_Algo_i::SMESH_Algo_i");
+  MESSAGE( "SMESH_Algo_i::SMESH_Algo_i" );
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Algo_i::~SMESH_Algo_i
+ * 
+ *  Destructor
  */
 //=============================================================================
 
 SMESH_Algo_i::~SMESH_Algo_i()
 {
-  MESSAGE("SMESH_Algo_i::~SMESH_Algo_i");
+  MESSAGE( "SMESH_Algo_i::~SMESH_Algo_i" );
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Algo_i::GetCompatibleHypothesis
+ * 
+ *  Gets list of compatible hypotheses
  */
 //=============================================================================
 
 SMESH::ListOfHypothesisName* SMESH_Algo_i::GetCompatibleHypothesis()
 {
-  MESSAGE("SMESH_Algo_i::GetCompatibleHypothesis");
-  SMESH::ListOfHypothesisName_var listOfHypothesis 
-    = new SMESH::ListOfHypothesisName;
-  const vector<string> & hypList = _impl->GetCompatibleHypothesis();
+  MESSAGE( "SMESH_Algo_i::GetCompatibleHypothesis" );
+  SMESH::ListOfHypothesisName_var listOfHypothesis = new SMESH::ListOfHypothesisName;
+  const vector<string>& hypList = ( ( ::SMESH_Algo* )myBaseImpl )->GetCompatibleHypothesis();
   int nbHyp = hypList.size();
-  listOfHypothesis->length(nbHyp);
-  for (int i=0; i<nbHyp; i++)
-    {
-      listOfHypothesis[i] = hypList[i].c_str();
-    }
+  listOfHypothesis->length( nbHyp );
+  for ( int i = 0; i < nbHyp; i++ ) {
+    listOfHypothesis[ i ] = strdup( hypList[ i ].c_str() );
+  }
   return listOfHypothesis._retn();
 }
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-void SMESH_Algo_i::SetImpl(::SMESH_Algo* impl)
-{
-  MESSAGE("SMESH_Algo_i::SetImpl");
-  //SMESH_Algo_i::SetImpl(impl);
-  _impl = impl;
-}
index c5427f753989ecb6add4120e4417286b03519f5d..21630ec8adfb3c1961c98416d2d50564d9f7a150 100644 (file)
 
 #include "SMESH_Hypothesis_i.hxx"
 
-#include "SMESH_Algo.hxx"
-
+// ======================================================
+// Generic algorithm
+// ======================================================
 class SMESH_Algo_i:
-  public POA_SMESH::SMESH_Algo,
-  public SMESH_Hypothesis_i
+  public virtual POA_SMESH::SMESH_Algo,
+  public virtual SMESH_Hypothesis_i
 {
 public:
-  SMESH_Algo_i();
+  // Constructor : placed in protected section to prohibit creation of generic class instance
+  SMESH_Algo_i( PortableServer::POA_ptr thePOA );
 
+public:
+  // Destructor
   virtual ~SMESH_Algo_i();
-
+  
+  // Gets list of compatible hypotheses
   SMESH::ListOfHypothesisName* GetCompatibleHypothesis();
-
-protected:
-  virtual void SetImpl(::SMESH_Algo* impl);
-
-  ::SMESH_Algo* _impl;
 };
 
 #endif
index b55ed358bd435e495cc3ccc3d447b8254b031c0d..44cbd411e3010d3a8ffdf73f2c7ceaf843536402 100644 (file)
@@ -41,21 +41,34 @@ using namespace std;
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopTools_MapOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 #include <gp_Pnt.hxx>
 #include <BRep_Tool.hxx>
 #include <TCollection_AsciiString.hxx>
 
+#include "Utils_CorbaException.hxx"
+
+#include "utilities.h"
 #include <fstream>
 #include <stdio.h>
+#include <dlfcn.h>
+
+#include <HDFOI.hxx>
 
 #include "SMESH_Gen_i.hxx"
 #include "SMESH_Mesh_i.hxx"
-#include "SMESH_LocalLength_i.hxx"
-#include "SMESH_NumberOfSegments_i.hxx"
-#include "SMESH_MaxElementArea_i.hxx"
-#include "SMESH_MaxElementVolume_i.hxx"
+#include "SMESH_Hypothesis_i.hxx"
+#include "SMESH_Algo_i.hxx"
+#include "SMESH_Group_i.hxx"
 
 #include "SMESHDS_Document.hxx"
+#include "SMESHDS_Group.hxx"
+#include "SMESH_topo.hxx"
+#include "SMESH_Group.hxx"
+
+#include CORBA_SERVER_HEADER(SMESH_Group)
+#include CORBA_SERVER_HEADER(SMESH_Filter)
+#include "SMESH_Filter_i.hxx"
 
 #include "Document_Reader.h"
 #include "DriverMED_W_SMESHDS_Mesh.h"
@@ -64,246 +77,700 @@ using namespace std;
 #include "DriverUNV_R_SMESHDS_Document.h"
 #include "DriverDAT_R_SMESHDS_Document.h"
 
-#include "Utils_CorbaException.hxx"
-#include "utilities.h"
-
 #include "SALOMEDS_Tool.hxx"
 #include "SALOME_NamingService.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
 #include "Utils_SINGLETON.hxx"
 #include "OpUtil.hxx"
 
-//#include <TopAbs_ShapeEnum.hxx>
+#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
 
 #include "GEOM_Client.hxx"
+#include "Utils_ExceptHandlers.hxx"
 
 #include <map>
 
-#define NUM_TMP_FILES 4
+#define NUM_TMP_FILES 2
+
+// Tags definition ===========================================================
+// Top level
+long Tag_HypothesisRoot         = 1; // hypotheses root
+long Tag_AlgorithmsRoot         = 2; // algorithms root
+// Mesh/Submesh
+long Tag_RefOnShape             = 1; // references to shape
+long Tag_RefOnAppliedHypothesis = 2; // applied hypotheses root
+long Tag_RefOnAppliedAlgorithms = 3; // applied algorithms root
+// Mesh only
+long Tag_SubMeshOnVertex        = 4; // sub-meshes roots by type
+long Tag_SubMeshOnEdge          = 5; // ...
+long Tag_SubMeshOnFace          = 6; // ...
+long Tag_SubMeshOnSolid         = 7; // ...
+long Tag_SubMeshOnCompound      = 8; // ...
+long Tag_NodeGroups             = 9; // Group roots by type
+long Tag_EdgeGroups             = 10; // ...
+long Tag_FaceGroups             = 11; // ...
+long Tag_VolumeGroups           = 12; // ...
+// ===========================================================================
+
+// Static variables definition
+CORBA::ORB_var          SMESH_Gen_i::myOrb;
+PortableServer::POA_var SMESH_Gen_i::myPoa;
+SALOME_NamingService*   SMESH_Gen_i::myNS  = NULL;
+SALOME_LifeCycleCORBA*  SMESH_Gen_i::myLCC = NULL;
+
+//=============================================================================
+/*!
+ *  FindMaxChildTag [ static internal ]
+ *
+ *  Finds maximum child tag for the given object
+ */
+//=============================================================================
+
+static long FindMaxChildTag( SALOMEDS::SObject_ptr theSObject )
+{
+  long aTag = 0;
+  if ( !theSObject->_is_nil() ) {
+    SALOMEDS::Study_var aStudy = theSObject->GetStudy();
+    if ( !aStudy->_is_nil() ) {
+      SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( theSObject );
+      for ( ; anIter->More(); anIter->Next() ) {
+       long nTag = anIter->Value()->Tag();
+       if ( nTag > aTag )
+         aTag = nTag;
+      }
+    }
+  }
+  return aTag;
+}
+
+//=============================================================================
+/*!
+ *  Get...Tag [ static ]
+ *
+ *  Methods which determine SMESH data model structure
+ */
+//=============================================================================
+
+long SMESH_Gen_i::GetHypothesisRootTag()
+{
+  return Tag_HypothesisRoot;
+}
+
+long SMESH_Gen_i::GetAlgorithmsRootTag()
+{
+  return Tag_AlgorithmsRoot;
+}
+
+long SMESH_Gen_i::GetRefOnShapeTag()
+{
+  return Tag_RefOnShape;
+}
+
+long SMESH_Gen_i::GetRefOnAppliedHypothesisTag()
+{
+  return Tag_RefOnAppliedHypothesis;
+}
+
+long SMESH_Gen_i::GetRefOnAppliedAlgorithmsTag()
+{
+  return Tag_RefOnAppliedAlgorithms;
+}
+
+long SMESH_Gen_i::GetSubMeshOnVertexTag()
+{
+  return Tag_SubMeshOnVertex;
+}
+
+long SMESH_Gen_i::GetSubMeshOnEdgeTag()
+{
+  return Tag_SubMeshOnEdge;
+}
+
+long SMESH_Gen_i::GetSubMeshOnFaceTag()
+{
+  return Tag_SubMeshOnFace;
+}
+
+long SMESH_Gen_i::GetSubMeshOnSolidTag()
+{
+  return Tag_SubMeshOnSolid;
+}
+
+long SMESH_Gen_i::GetSubMeshOnCompoundTag()
+{
+  return Tag_SubMeshOnCompound;
+}
 
-// Tags definition 
-long Tag_HypothesisRoot  = 1;
-long Tag_AlgorithmsRoot  = 2;
+long SMESH_Gen_i::GetNodeGroupsTag()
+{
+  return Tag_NodeGroups;
+}
 
-long Tag_RefOnShape      = 1;
-long Tag_RefOnAppliedHypothesis = 2;
-long Tag_RefOnAppliedAlgorithms = 3;
+long SMESH_Gen_i::GetEdgeGroupsTag()
+{
+  return Tag_EdgeGroups;
+}
 
-long Tag_SubMeshOnVertex = 4;
-long Tag_SubMeshOnEdge = 5;
-long Tag_SubMeshOnFace = 6;
-long Tag_SubMeshOnSolid = 7;
-long Tag_SubMeshOnCompound = 8;
+long SMESH_Gen_i::GetFaceGroupsTag()
+{
+  return Tag_FaceGroups;
+}
 
+long SMESH_Gen_i::GetVolumeGroupsTag()
+{
+  return Tag_VolumeGroups;
+}
 
 //=============================================================================
 /*!
- *  default constructor: not for use
+ *  GetServant [ static ]
+ *
+ *  Get servant of the CORBA object
  */
 //=============================================================================
 
-SMESH_Gen_i::SMESH_Gen_i()
+PortableServer::ServantBase_var SMESH_Gen_i::GetServant( CORBA::Object_ptr theObject )
+{
+  if( CORBA::is_nil( theObject ) || CORBA::is_nil( GetPOA() ) )
+    return NULL;
+  try {
+    PortableServer::Servant aServant = GetPOA()->reference_to_servant( theObject );
+    return aServant;
+  } 
+  catch (...) {
+    MESSAGE( "GetServant - Unknown exception was caught!!!" ); 
+    return NULL;
+  }
+}
+
+//=============================================================================
+/*!
+ *  SObjectToObject [ static ]
+ *
+ *  Get CORBA object corresponding to the SALOMEDS::SObject
+ */
+//=============================================================================
+
+CORBA::Object_var SMESH_Gen_i::SObjectToObject( SALOMEDS::SObject_ptr theSObject )
 {
-  MESSAGE("SMESH_Gen_i default constructor");
-  // ****
+  SALOMEDS::GenericAttribute_var anAttr;
+  CORBA::Object_var anObj;
+  if ( !theSObject->_is_nil() ) {
+    try {
+      if( theSObject->FindAttribute( anAttr, "AttributeIOR" ) ) {
+       SALOMEDS::AttributeIOR_var anIOR  = SALOMEDS::AttributeIOR::_narrow( anAttr );
+       CORBA::String_var aValue = anIOR->Value();
+       if( strcmp( aValue, "" ) != 0 )
+         anObj = GetORB()->string_to_object( aValue );
+       }
+    }
+    catch( ... ) {
+      MESSAGE( "SObjectToObject - Unknown exception was caught!!!" );
+    }
+  }
+  return anObj;
 }
 
 //=============================================================================
 /*!
- *  Standard constructor, used with Container.
+ *  GetNS [ static ]
+ *
+ *  Get SALOME_NamingService object 
  */
 //=============================================================================
 
-SMESH_Gen_i::SMESH_Gen_i(CORBA::ORB_ptr orb,
-              PortableServer::POA_ptr poa,
-              PortableServer::ObjectId * contId, 
-              const char *instanceName, 
-                         const char *interfaceName) :
-  Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
+SALOME_NamingService* SMESH_Gen_i::GetNS()
 {
-  MESSAGE("activate object");
-  _thisObj = this ;
-  _id = _poa->activate_object(_thisObj);
+  if ( myNS == NULL ) {
+    myNS = SINGLETON_<SALOME_NamingService>::Instance();
+    ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
+    myNS->init_orb( GetORB() );
+  }
+  return myNS;
+}
+
+//=============================================================================
+/*!
+ *  GetLCC [ static ]
+ *
+ *  Get SALOME_LifeCycleCORBA object
+ */
+//=============================================================================     
+SALOME_LifeCycleCORBA*  SMESH_Gen_i::GetLCC() {
+  if ( myLCC == NULL ) {
+    myLCC = new SALOME_LifeCycleCORBA( GetNS() );
+  }
+  return myLCC;
+}
+
+
+//=============================================================================
+/*!
+ *  GetGeomEngine [ static ]
+ *
+ *  Get GEOM::GEOM_Gen reference
+ */
+//=============================================================================     
+GEOM::GEOM_Gen_ptr SMESH_Gen_i::GetGeomEngine() {
+  GEOM::GEOM_Gen_var aGeomEngine =
+    GEOM::GEOM_Gen::_narrow( GetLCC()->FindOrLoad_Component("FactoryServer","GEOM") );
+  return aGeomEngine._retn();
+}
+
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::SMESH_Gen_i
+ *
+ *  Default constructor: not for use
+ */
+//=============================================================================
+
+SMESH_Gen_i::SMESH_Gen_i()
+{
+  MESSAGE( "SMESH_Gen_i::SMESH_Gen_i : default constructor" );
+}
+
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::SMESH_Gen_i 
+ *
+ *  Standard constructor, used with Container
+ */
+//=============================================================================
 
-  _ShapeReader = NULL;
-  _localId = 0;  // number of created objects & local id 
+SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr            orb,
+                         PortableServer::POA_ptr   poa,
+                         PortableServer::ObjectId* contId, 
+                         const char*               instanceName, 
+                          const char*               interfaceName )
+     : Engines_Component_i( orb, poa, contId, instanceName, interfaceName )
+{
+  MESSAGE( "SMESH_Gen_i::SMESH_Gen_i : standard constructor" );
 
+  myOrb = CORBA::ORB::_duplicate(orb);
+  myPoa = PortableServer::POA::_duplicate(poa);
+  
+  _thisObj = this ;
+  _id = myPoa->activate_object( _thisObj );
+  
+  myShapeReader = NULL;  // shape reader
 }
 
 //=============================================================================
 /*!
- *  Standard destructor
+ *  SMESH_Gen_i::~SMESH_Gen_i
+ *
+ *  Destructor
  */
 //=============================================================================
 
 SMESH_Gen_i::~SMESH_Gen_i()
 {
-  MESSAGE("~SMESH_Gen_i");
-  // ****
+  MESSAGE( "SMESH_Gen_i::~SMESH_Gen_i" );
+
+  // delete hypothesis creators
+  map<string, GenericHypothesisCreator_i*>::iterator itHyp;
+  for (itHyp = myHypCreatorMap.begin(); itHyp != myHypCreatorMap.end(); itHyp++)
+  {
+    delete (*itHyp).second;
+  }
+  myHypCreatorMap.clear();
+
+  // Clear study contexts data
+  map<int, StudyContext*>::iterator it;
+  for ( it = myStudyContextMap.begin(); it != myStudyContextMap.end(); ++it ) {
+    delete it->second;
+  }
+  myStudyContextMap.clear();
+  // delete shape reader
+  if ( !myShapeReader ) 
+    delete myShapeReader;
 }
   
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::CreateFilterManager
+ *
+ *  Create filter manager
  */
 //=============================================================================
 
-SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis(const char* anHyp,
-                                                          CORBA::Long studyId)
-  throw (SALOME::SALOME_Exception)
+SMESH::FilterManager_ptr SMESH_Gen_i::CreateFilterManager()
 {
-  MESSAGE("CreateHypothesis");
+  SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
+  SMESH::FilterManager_var anObj = aFilter->_this();
+  return anObj._retn();
+}
 
-  // create a new hypothesis object servant
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::createHypothesis
+ *
+ *  Create hypothesis of given type
+ */
+//=============================================================================
+SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName,
+                                                          const char* theLibName)
+     throw (SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE( "Create Hypothesis <" << theHypName << "> from " << theLibName);
 
+  // get study context
+  StudyContext* myStudyContext = GetCurrentStudyContext();
+  
+  // create a new hypothesis object servant
   SMESH_Hypothesis_i* myHypothesis_i = 0;
+  SMESH::SMESH_Hypothesis_var hypothesis_i;
+
   try
+  {
+    // check, if creator for this hypothesis type already exists
+    if (myHypCreatorMap.find(string(theHypName)) == myHypCreatorMap.end())
     {
-      myHypothesis_i = _hypothesisFactory_i.Create(anHyp,
-                                                   studyId,
-                                                   &_impl);
+      // load plugin library
+      MESSAGE("Loading server meshers plugin library ...");
+      void* libHandle = dlopen (theLibName, RTLD_LAZY);
+      if (!libHandle)
+      {
+        // report any error, if occured
+        const char* anError = dlerror();
+        throw(SALOME_Exception(anError));
+      }
+
+      // get method, returning hypothesis creator
+      MESSAGE("Find GetHypothesisCreator() method ...");
+      typedef GenericHypothesisCreator_i* (*GetHypothesisCreator)(const char* theHypName);
+      GetHypothesisCreator procHandle =
+        (GetHypothesisCreator)dlsym( libHandle, "GetHypothesisCreator" );
+      if (!procHandle)
+      {
+        throw(SALOME_Exception(LOCALIZED("bad hypothesis plugin library")));
+        dlclose(libHandle);
+      }
+
+      // get hypothesis creator
+      MESSAGE("Get Hypothesis Creator for " << theHypName);
+      GenericHypothesisCreator_i* aCreator = procHandle(theHypName);
+      if (!aCreator)
+      {
+        throw(SALOME_Exception(LOCALIZED("no such a hypothesis in this plugin")));
+      }
+
+      // map hypothesis creator to a hypothesis name
+      myHypCreatorMap[string(theHypName)] = aCreator;
     }
+
+    // create a new hypothesis object, store its ref. in studyContext
+    MESSAGE("Create Hypothesis " << theHypName);
+    myHypothesis_i =
+      myHypCreatorMap[string(theHypName)]->Create
+        (myPoa, myCurrentStudy->StudyId(), &myGen);
+    myHypothesis_i->SetLibName(theLibName); // for persistency assurance
+  }
   catch (SALOME_Exception& S_ex)
-    {
-      THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
-    }
+  {
+    THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+  }
+
+  if (!myHypothesis_i)
+    return hypothesis_i._retn();
 
   // activate the CORBA servant of hypothesis
+  hypothesis_i = SMESH::SMESH_Hypothesis::_narrow( myHypothesis_i->_this() );
+  string iorString = GetORB()->object_to_string( hypothesis_i );
+  int nextId = myStudyContext->addObject( iorString );
+  MESSAGE( "Add hypo to map with id = "<< nextId << " and IOR = " << iorString.c_str() );
 
-  SMESH::SMESH_Hypothesis_var hypothesis_i
-    = SMESH::SMESH_Hypothesis::_narrow(myHypothesis_i->_this());
-  return SMESH::SMESH_Hypothesis::_duplicate(hypothesis_i);
+  return hypothesis_i._retn();
 }
   
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::createMesh
+ *
+ *  Create empty mesh on shape
  */
 //=============================================================================
-
-SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Init(GEOM::GEOM_Gen_ptr geomEngine,
-                                        CORBA::Long studyId,
-                                        GEOM::GEOM_Shape_ptr aShape)
-  throw (SALOME::SALOME_Exception)
+SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh()
+     throw ( SALOME::SALOME_Exception )
 {
-  MESSAGE("Init");
-  // _narrow() duplicates the reference and checks the type
-  GEOM::GEOM_Gen_var geom = GEOM::GEOM_Gen::_narrow(geomEngine);
-  GEOM::GEOM_Shape_var myShape = GEOM::GEOM_Shape::_narrow(aShape);
-
-  if (CORBA::is_nil(geom))
-    THROW_SALOME_CORBA_EXCEPTION("bad geom reference", \
-                                 SALOME::BAD_PARAM);
-  if (CORBA::is_nil(myShape))
-    THROW_SALOME_CORBA_EXCEPTION("bad shape reference", \
-                                 SALOME::BAD_PARAM);
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE( "SMESH_Gen_i::createMesh" );
+
+  // get current study
+  StudyContext* myStudyContext = GetCurrentStudyContext();
 
   // Get or create the GEOM_Client instance
+  try {
+    // create a new mesh object servant, store it in a map in study context
+    SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(),
+                                                 this,
+                                                 myCurrentStudy->StudyId() );
+    // create a new mesh object
+    meshServant->SetImpl( myGen.CreateMesh( myCurrentStudy->StudyId() ) );
+
+    // activate the CORBA servant of Mesh
+    SMESH::SMESH_Mesh_var mesh = meshServant->_this();
+    string iorString = GetORB()->object_to_string( mesh );
+    int nextId = myStudyContext->addObject( iorString );
+    MESSAGE( "Add mesh to map with id = "<< nextId << " and IOR = " << iorString.c_str() );
+    return mesh._retn();
+  }
+  catch (SALOME_Exception& S_ex) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
+  }
+  return SMESH::SMESH_Mesh::_nil();
+}
 
-  SMESH_Mesh_i* meshServant = 0;
-  try
-    {
-      if (! _ShapeReader) _ShapeReader = new GEOM_Client();
-      ASSERT(_ShapeReader);
-      
-      // explore main Shape, get local TopoDS_Shapes of all subShapes
-      //  SMESH_topo* myTopo = ExploreMainShape(geom, studyId, myShape);
-      
-      // Get studyContext_i, create it if it does'nt exist
-      
-      if (_mapStudyContext_i.find(studyId) == _mapStudyContext_i.end())
-        {
-          _mapStudyContext_i[studyId] = new StudyContext_iStruct;      
-        }
-      StudyContext_iStruct* myStudyContext = _mapStudyContext_i[studyId];
-      
-      // create a new mesh object servant, store it in a map in study context
-      
-      meshServant = new SMESH_Mesh_i(this,
-                                     geom,
-                                     studyId,
-                                     _localId);
-      myStudyContext->mapMesh_i[_localId] = meshServant;
-      _localId++;
-
-      // create a new mesh object
-      
-      TopoDS_Shape myLocShape  = _ShapeReader->GetShape(geom,myShape);
-      meshServant->SetImpl(_impl.Init(studyId, myLocShape));
-    }
-  catch (SALOME_Exception& S_ex)
-    {
-      THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
-    }
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::GetShapeReader
+ *
+ *  Get shape reader
+ */
+//=============================================================================
+GEOM_Client* SMESH_Gen_i::GetShapeReader()
+{
+  // create shape reader if necessary
+  if ( !myShapeReader ) 
+    myShapeReader = new GEOM_Client(GetContainerRef());
+  ASSERT( myShapeReader );
+  return myShapeReader;
+}
 
-  // activate the CORBA servant of Mesh
-  
-  SMESH::SMESH_Mesh_var mesh
-    = SMESH::SMESH_Mesh::_narrow(meshServant->_this());
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::SetCurrentStudy
+ *
+ *  Set current study
+ */
+//=============================================================================
+
+void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy )
+{
+  MESSAGE( "SMESH_Gen_i::SetCurrentStudy" );
+  myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy );
+  // create study context, if it doesn't exist and set current study
+  int studyId = myCurrentStudy->StudyId();
+  MESSAGE( "SMESH_Gen_i::SetCurrentStudy: study Id = " << studyId );
+  if ( myStudyContextMap.find( studyId ) == myStudyContextMap.end() ) {
+    myStudyContextMap[ studyId ] = new StudyContext;      
+  }
+  // set current study for geom engine
+  if ( !CORBA::is_nil( GetGeomEngine() ) )
+    GetGeomEngine()->GetCurrentStudy( myCurrentStudy->StudyId() );
+}
+
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::GetCurrentStudy
+ *
+ *  Get current study
+ */
+//=============================================================================
+
+SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy()
+{
+  MESSAGE( "SMESH_Gen_i::GetCurrentStudy: study Id = " << myCurrentStudy->StudyId() );
+  return SALOMEDS::Study::_duplicate( myCurrentStudy );
+}
+
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::GetCurrentStudyContext 
+ *
+ *  Get current study context
+ */
+//=============================================================================
+StudyContext* SMESH_Gen_i::GetCurrentStudyContext()
+{
+  ASSERT( !CORBA::is_nil( myCurrentStudy ) )
+  ASSERT( myStudyContextMap.find( myCurrentStudy->StudyId() ) != myStudyContextMap.end() );
+  return myStudyContextMap[ myCurrentStudy->StudyId() ];
+}
+
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::CreateHypothesis 
+ *
+ *  Create hypothesis/algorothm of given type and publish it in the study
+ */
+//=============================================================================
+
+SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypName,
+                                                           const char* theLibName )
+     throw ( SALOME::SALOME_Exception )
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  ASSERT( !CORBA::is_nil( myCurrentStudy ) );
+  // Create hypothesis/algorithm
+  SMESH::SMESH_Hypothesis_var hyp = this->createHypothesis( theHypName, theLibName );
+
+  // Publish hypothesis/algorithm in the study
+  if ( this->CanPublishInStudy( hyp ) ) {
+    this->PublishInStudy( myCurrentStudy, SALOMEDS::SObject::_nil(), hyp, "" );
+  }
+  return hyp._retn();
+}
   
-  meshServant->SetIor(mesh);
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::CreateMesh
+ *
+ *  Create empty mesh on a shape and publish it in the study
+ */
+//=============================================================================
 
-  return SMESH::SMESH_Mesh::_duplicate(mesh);
+SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Shape_ptr theShape )
+     throw ( SALOME::SALOME_Exception )
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE( "SMESH_Gen_i::CreateMesh" );
+  ASSERT( !CORBA::is_nil( myCurrentStudy ) );
+  // create mesh
+  SMESH::SMESH_Mesh_var mesh = this->createMesh();
+  // publish mesh in the study
+  if ( this->CanPublishInStudy( mesh ) ) {
+    this->PublishInStudy( myCurrentStudy, SALOMEDS::SObject::_nil(), mesh.in(), "" );
+  }
+  // set shape
+  SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( mesh ).in() );
+  ASSERT( meshServant );
+  meshServant->SetShape( theShape );
+  return mesh._retn();
 }
   
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::CreateMeshFromMED
+ *
+ *  Create mesh and import data from MED file
+ */
+//=============================================================================
+
+SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
+                                                     SMESH::DriverMED_ReadStatus& theStatus)
+     throw ( SALOME::SALOME_Exception )
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
+  ASSERT( !CORBA::is_nil( myCurrentStudy ) );
+
+  // Retrieve mesh names from the file
+  DriverMED_R_SMESHDS_Mesh myReader;
+  myReader.SetFile( theFileName );
+  myReader.SetMeshId( -1 );
+  list<string> aNames = myReader.GetMeshNames();
+
+  SMESH::mesh_array_var aResult = new SMESH::mesh_array();
+  aResult->length( aNames.size() );
+  int i = 0;
+
+  // Iterate through all meshes and create mesh objects
+  theStatus = SMESH::DRS_OK;
+  for ( list<string>::iterator it = aNames.begin(); it != aNames.end(); it++ ) {
+    // create mesh
+    SMESH::SMESH_Mesh_var mesh = createMesh();
+    
+    // publish mesh in the study
+    if ( CanPublishInStudy( mesh ) ) {
+      PublishInStudy( myCurrentStudy, SALOMEDS::SObject::_nil(), mesh.in(), (*it).c_str() );
+    }
+
+    // Read mesh data (groups are published automatically by ImportMEDFile())
+    SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( mesh ).in() );
+    ASSERT( meshServant );
+    SMESH::DriverMED_ReadStatus status1 =
+      meshServant->ImportMEDFile( theFileName, (*it).c_str() );
+    if (status1 > theStatus)
+      theStatus = status1;
+
+    aResult[i++] = SMESH::SMESH_Mesh::_duplicate( mesh );
+  }
+
+  return aResult._retn();
+}
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::IsReadyToCompute
+ *
+ *  Returns true if mesh contains enough data to be computed
  */
 //=============================================================================
 
-CORBA::Boolean SMESH_Gen_i::IsReadyToCompute(SMESH::SMESH_Mesh_ptr aMesh,
-                                             GEOM::GEOM_Shape_ptr aShape)
-  throw (SALOME::SALOME_Exception)
+CORBA::Boolean SMESH_Gen_i::IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh,
+                                              GEOM::GEOM_Shape_ptr  theShape )
+  throw ( SALOME::SALOME_Exception )
 {
-  MESSAGE("SMESH_Gen_i::IsReadyToCompute");
-  return true;
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE( "SMESH_Gen_i::IsReadyToCompute" );
+
+  if ( CORBA::is_nil( theShape ) )
+    THROW_SALOME_CORBA_EXCEPTION( "bad shape reference", 
+                                  SALOME::BAD_PARAM );
+
+  if ( CORBA::is_nil( theMesh ) )
+    THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference",
+                                  SALOME::BAD_PARAM );
+
+  try {
+    // get mesh servant
+    SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( theMesh ).in() );
+    ASSERT( meshServant );
+    if ( meshServant ) {
+      // get local TopoDS_Shape
+      TopoDS_Shape myLocShape = GetShapeReader()->GetShape( GetGeomEngine(), theShape );
+      // call implementation
+      ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
+      return myGen.CheckAlgoState( myLocMesh, myLocShape );
+    }
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    MESSAGE( "catch exception "<< S_ex.what() );
+  }
+  return false;
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::GetSubShapesId
+ *
+ *  Get sub-shapes unique ID's list
  */
 //=============================================================================
 
-  SMESH::long_array* 
-  SMESH_Gen_i::GetSubShapesId(GEOM::GEOM_Gen_ptr geomEngine,
-                              CORBA::Long studyId,
-                              GEOM::GEOM_Shape_ptr mainShape,
-                              const SMESH::shape_array& listOfSubShape)
-    throw (SALOME::SALOME_Exception)
+SMESH::long_array* SMESH_Gen_i::GetSubShapesId( GEOM::GEOM_Shape_ptr      theMainShape,
+                                               const SMESH::shape_array& theListOfSubShape )
+     throw ( SALOME::SALOME_Exception )
 {
-  MESSAGE("SMESH_Gen_i::GetSubShapesId");
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE( "SMESH_Gen_i::GetSubShapesId" );
+
   SMESH::long_array_var shapesId = new SMESH::long_array;
   set<int> setId;
 
-  GEOM::GEOM_Gen_var geom = GEOM::GEOM_Gen::_narrow(geomEngine);
-  GEOM::GEOM_Shape_var myShape = GEOM::GEOM_Shape::_narrow(mainShape);
-
-  if (CORBA::is_nil(geom))
-    THROW_SALOME_CORBA_EXCEPTION("bad geom reference", \
-                                 SALOME::BAD_PARAM);
-  if (CORBA::is_nil(myShape))
-    THROW_SALOME_CORBA_EXCEPTION("bad shape reference", \
-                                 SALOME::BAD_PARAM);
+  if ( CORBA::is_nil( theMainShape ) )
+    THROW_SALOME_CORBA_EXCEPTION( "bad shape reference",
+                                  SALOME::BAD_PARAM );
 
   try
     {
-      if (! _ShapeReader) _ShapeReader = new GEOM_Client();
-      ASSERT(_ShapeReader);
-      TopoDS_Shape myMainShape  = _ShapeReader->GetShape(geom,myShape);
+      if (! myShapeReader) myShapeReader = new GEOM_Client(GetContainerRef());
+      ASSERT(myShapeReader);
+      TopoDS_Shape myMainShape  = GetShapeReader()->GetShape(GetGeomEngine(),theMainShape);
       TopTools_IndexedMapOfShape myIndexToShape;      
       TopExp::MapShapes(myMainShape,myIndexToShape);
 
-      for (int i=0; i<listOfSubShape.length(); i++)
+      for (int i=0; i<theListOfSubShape.length(); i++)
        {
          GEOM::GEOM_Shape_var aShape
-           = GEOM::GEOM_Shape::_narrow(listOfSubShape[i]);
+           = GEOM::GEOM_Shape::_narrow(theListOfSubShape[i]);
          if (CORBA::is_nil(aShape))
            THROW_SALOME_CORBA_EXCEPTION("bad shape reference", \
                                         SALOME::BAD_PARAM);
-         TopoDS_Shape locShape  = _ShapeReader->GetShape(geom,aShape);
+         TopoDS_Shape locShape  = GetShapeReader()->GetShape(GetGeomEngine(),aShape);
          for (TopExp_Explorer exp(locShape,TopAbs_FACE); exp.More(); exp.Next())
            {
              const TopoDS_Face& F = TopoDS::Face(exp.Current());
@@ -344,1413 +811,1693 @@ CORBA::Boolean SMESH_Gen_i::IsReadyToCompute(SMESH::SMESH_Mesh_ptr aMesh,
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::Compute
+ *
+ *  Compute mesh on a shape
  */
 //=============================================================================
 
-CORBA::Boolean SMESH_Gen_i::Compute(SMESH::SMESH_Mesh_ptr aMesh,
-                                    GEOM::GEOM_Shape_ptr aShape)
-  throw (SALOME::SALOME_Exception)
+CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
+                                     GEOM::GEOM_Shape_ptr  theShape )
+     throw ( SALOME::SALOME_Exception )
 {
-  MESSAGE("SMESH_Gen_i::Compute");
-  GEOM::GEOM_Shape_var myShape = GEOM::GEOM_Shape::_narrow(aShape);
-  if (CORBA::is_nil(myShape))
-    THROW_SALOME_CORBA_EXCEPTION("bad shape reference", \
-                                 SALOME::BAD_PARAM);
-
-  SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow(aMesh);
-  if (CORBA::is_nil(myMesh))
-    THROW_SALOME_CORBA_EXCEPTION("bad Mesh reference", \
-                                 SALOME::BAD_PARAM);
-
-  bool ret = false;
-  try
-    {
-      
-      // get study context from studyId given by CORBA mesh object
-      
-      int studyId = myMesh->GetStudyId();
-      ASSERT(_mapStudyContext_i.find(studyId) != _mapStudyContext_i.end());
-      StudyContext_iStruct* myStudyContext = _mapStudyContext_i[studyId];
-      
-      // get local Mesh_i object with Id and study context 
-      
-      int meshId = myMesh->GetId();
-      ASSERT(myStudyContext->mapMesh_i.find(meshId) != myStudyContext->mapMesh_i.end());
-      SMESH_Mesh_i* meshServant = myStudyContext->mapMesh_i[meshId];
-      ASSERT(meshServant);
-      
-      // get local TopoDS_Shape
-      
-      GEOM::GEOM_Gen_var geom = meshServant->GetGeomEngine();
-      TopoDS_Shape myLocShape  = _ShapeReader->GetShape(geom,myShape);
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE( "SMESH_Gen_i::Compute" );
 
-      // implementation compute
-      
-      ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
-      ret = _impl.Compute(myLocMesh, myLocShape);
-    }
-  catch (SALOME_Exception& S_ex)
-    {
-      MESSAGE("catch exception "<< S_ex.what());
-      return false;
-//       THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
-    }
-
-  return ret;
-}
+  if ( CORBA::is_nil( theShape ) )
+    THROW_SALOME_CORBA_EXCEPTION( "bad shape reference", 
+                                  SALOME::BAD_PARAM );
 
+  if ( CORBA::is_nil( theMesh ) )
+    THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference",
+                                  SALOME::BAD_PARAM );
+
+  try {
+    // get mesh servant
+    SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( theMesh ).in() );
+    ASSERT( meshServant );
+    if ( meshServant ) {
+      // get local TopoDS_Shape
+      TopoDS_Shape myLocShape = GetShapeReader()->GetShape( GetGeomEngine(), theShape );
+      // call implementarion compute
+      ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
+      return myGen.Compute( myLocMesh, myLocShape);
+    }
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    MESSAGE( "Compute(): catch exception "<< S_ex.what() );
+  }
+  catch ( ... ) {
+    MESSAGE( "Compute(): unknown exception " );
+  }
+  return false;
+}
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::Save
+ *
+ *  Save SMESH module's data
  */
 //=============================================================================
-
-SALOMEDS::TMPFile* SMESH_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
-                                    const char* theURL,
-                                    bool isMultiFile)
+SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
+                                     const char*              theURL,
+                                     bool                     isMultiFile )
 {
-  MESSAGE("SMESH_Gen_i::SAVE");
-  SALOMEDS::Study_var Study = theComponent->GetStudy(); 
-  int studyId;
+  INFOS( "SMESH_Gen_i::Save" );
+
+  ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() )
+  StudyContext* myStudyContext = GetCurrentStudyContext();
   
   // Declare a byte stream
   SALOMEDS::TMPFile_var aStreamFile;
   
   // Obtain a temporary dir
-  TCollection_AsciiString tmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
+  TCollection_AsciiString tmpDir =
+    ( isMultiFile ) ? TCollection_AsciiString( ( char* )theURL ) : SALOMEDS_Tool::GetTmpDir();
 
   // Create a sequence of files processed
   SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
-  aFileSeq->length(NUM_TMP_FILES);
+  aFileSeq->length( NUM_TMP_FILES );
 
-  TCollection_AsciiString aStudyName("");
+  TCollection_AsciiString aStudyName( "" );
+  if ( isMultiFile ) 
+    aStudyName = ( SALOMEDS_Tool::GetNameFromPath( myCurrentStudy->URL() ) );
 
   // Set names of temporary files
-  TCollection_AsciiString filename = aStudyName + TCollection_AsciiString("_SMESH.hdf");
-  TCollection_AsciiString hypofile = aStudyName + TCollection_AsciiString("_SMESH_Hypo.txt");
-  TCollection_AsciiString algofile = aStudyName + TCollection_AsciiString("_SMESH_Algo.txt");
-  TCollection_AsciiString meshfile = aStudyName + TCollection_AsciiString("_SMESH_Mesh.med");
-  aFileSeq[0] = CORBA::string_dup(filename.ToCString());
-  aFileSeq[1] = CORBA::string_dup(hypofile.ToCString());
-  aFileSeq[2] = CORBA::string_dup(algofile.ToCString());
-  aFileSeq[3] = CORBA::string_dup(meshfile.ToCString());
+  TCollection_AsciiString filename =
+    aStudyName + TCollection_AsciiString( "_SMESH.hdf" );        // for SMESH data itself
+  TCollection_AsciiString meshfile =
+    aStudyName + TCollection_AsciiString( "_SMESH_Mesh.med" );   // for mesh data to be stored in MED file
+  aFileSeq[ 0 ] = CORBA::string_dup( filename.ToCString() );
+  aFileSeq[ 1 ] = CORBA::string_dup( meshfile.ToCString() );
   filename = tmpDir + filename;
-  hypofile = tmpDir + hypofile;
-  algofile = tmpDir + algofile;
   meshfile = tmpDir + meshfile;
 
-  HDFfile * hdf_file;
-  map <int,HDFgroup*> hdf_group, hdf_subgroup;
-  map <int,HDFdataset*> hdf_dataset;
-  FILE* destFile;
-
-  SALOMEDS::ChildIterator_var itBig,it,itSM;
-  SALOMEDS::SObject_var mySObject,myBranch,mySObjectChild;
-  hdf_size size[1];
-  int longueur,cmpt_ds = 0,cmpt_it;
-  char *name_group,name_dataset[30],name_meshgroup[30];
-  bool ok,_found;
-  int cmpt_sm = 0, myTag;
-
-//************* HDF file creation
-  hdf_file = new HDFfile(filename.ToCString());
-  hdf_file->CreateOnDisk();
-//****************************
-
-  itBig = Study->NewChildIterator(theComponent);
-  for (; itBig->More();itBig->Next()) {
-    SALOMEDS::SObject_var gotBranch = itBig->Value();
-
-//************branch 1 : hypothesis
-    if (gotBranch->Tag()==Tag_HypothesisRoot) { //hypothesis = tag 1
-
-      double length,maxElementsArea,maxElementsVolume;
-      int numberOfSegments;
-
-      destFile = fopen( hypofile.ToCString() ,"w");
-      it = Study->NewChildIterator(gotBranch);
-      for (; it->More();it->Next()) {
-        mySObject = it->Value();
-        SALOMEDS::GenericAttribute_var anAttr;
-        SALOMEDS::AttributeIOR_var anIOR;
-        if ( mySObject->FindAttribute(anAttr, "AttributeIOR")) {
-          anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-
-          SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(anIOR->Value()));
-          fprintf(destFile,"%s\n",myHyp->GetName());
-          
-          if (strcmp(myHyp->GetName(),"LocalLength")==0) {
-            SMESH::SMESH_LocalLength_var LL = SMESH::SMESH_LocalLength::_narrow( myHyp );
-            length = LL->GetLength();
-            fprintf(destFile,"%f\n",length);
-          }
-          else if (strcmp(myHyp->GetName(),"NumberOfSegments")==0) {
-            SMESH::SMESH_NumberOfSegments_var NOS = SMESH::SMESH_NumberOfSegments::_narrow( myHyp );
-            numberOfSegments = NOS->GetNumberOfSegments();
-            fprintf(destFile,"%d\n",numberOfSegments);
-          }
-          else if (strcmp(myHyp->GetName(),"MaxElementArea")==0) {
-            SMESH::SMESH_MaxElementArea_var MEA = SMESH::SMESH_MaxElementArea::_narrow( myHyp );
-            maxElementsArea = MEA->GetMaxElementArea();
-            fprintf(destFile,"%f\n",maxElementsArea);
-          }
-          else if (strcmp(myHyp->GetName(),"MaxElementVolume")==0) {
-            SMESH::SMESH_MaxElementVolume_var MEV = SMESH::SMESH_MaxElementVolume::_narrow( myHyp );
-            maxElementsVolume = MEV->GetMaxElementVolume();
-            fprintf(destFile,"%f\n",maxElementsVolume);
-          }
-        }
-      }
-      fclose(destFile);
-
-//writes the file name in the hdf file
-      longueur = hypofile.Length() +1;
-      name_group="Hypothesis";
-      //SCRUTE(name_group);
-      
-      size[0]=longueur;
-      hdf_group[1] = new HDFgroup(name_group,hdf_file);
-      hdf_group[1]->CreateOnDisk();
-      
-      hdf_dataset[cmpt_ds]=new HDFdataset(name_group,hdf_group[1],HDF_STRING,size,1);
-      hdf_dataset[cmpt_ds]->CreateOnDisk();
-      hdf_dataset[cmpt_ds]->WriteOnDisk(hypofile.ToCString());
-      hdf_dataset[cmpt_ds]->CloseOnDisk();
-      cmpt_ds++;
-      
-      hdf_group[1]->CloseOnDisk();
-      MESSAGE("End of Hypothesis Save");
-
-    }
-//************branch 2 : algorithms
-    else if (gotBranch->Tag()==Tag_AlgorithmsRoot) {//algos = tag 2
-      
-      destFile = fopen( algofile.ToCString() ,"w");
-      it = Study->NewChildIterator(gotBranch);
-      for (; it->More();it->Next()) {
-        mySObject = it->Value();
-        SALOMEDS::GenericAttribute_var anAttr;
-        SALOMEDS::AttributeIOR_var anIOR;
-        if (mySObject->FindAttribute(anAttr, "AttributeIOR")) {
-          anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-          SMESH::SMESH_Algo_var myAlgo = SMESH::SMESH_Algo::_narrow(_orb->string_to_object(anIOR->Value()));
-          fprintf(destFile,"%s\n",myAlgo->GetName());
-        }
-      }
-    
-      fclose(destFile);
+  HDFfile*    aFile;
+  HDFdataset* aDataset;
+  HDFgroup*   aTopGroup;
+  HDFgroup*   aGroup;
+  HDFgroup*   aSubGroup;
+  HDFgroup*   aSubSubGroup;
+  hdf_size    aSize[ 1 ];
+
+  // MED writer to be used by storage process
+  DriverMED_W_SMESHDS_Mesh myWriter;
+  myWriter.SetFile( meshfile.ToCString() );
+
+  // Write data
+  // ---> create HDF file
+  aFile = new HDFfile( filename.ToCString() );
+  aFile->CreateOnDisk();
   
-//writes the file name in the hdf file
-      longueur = algofile.Length() +1;
-      name_group="Algorithms";
-      //SCRUTE(name_group);
-      
-      size[0]=longueur;
-      hdf_group[2] = new HDFgroup(name_group,hdf_file);
-      hdf_group[2]->CreateOnDisk();
-      
-      hdf_dataset[cmpt_ds]=new HDFdataset(name_group,hdf_group[2],HDF_STRING,size,1);
-      hdf_dataset[cmpt_ds]->CreateOnDisk();
-      hdf_dataset[cmpt_ds]->WriteOnDisk(algofile.ToCString());
-      hdf_dataset[cmpt_ds]->CloseOnDisk();
-      cmpt_ds++;
-      
-      hdf_group[2]->CloseOnDisk();
-      MESSAGE("End of Algos Save");
-
-    }
-//************branch 3 : meshes
-    else if (gotBranch->Tag()>=3) {//meshes = tag > 3
+  // --> iterator for top-level objects
+  SALOMEDS::ChildIterator_var itBig = myCurrentStudy->NewChildIterator( theComponent );
+  for ( ; itBig->More(); itBig->Next() ) {
+    SALOMEDS::SObject_var gotBranch = itBig->Value();
 
-      SALOMEDS::GenericAttribute_var anAttr;
-      SALOMEDS::AttributeIOR_var anIOR;
-      if (gotBranch->FindAttribute(anAttr, "AttributeIOR")) {
-        anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-       
-       SMESH::SMESH_Mesh_var myMesh =  SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value())) ;
-       studyId = myMesh->GetStudyId();
-       SCRUTE(studyId);
-       
-       StudyContext_iStruct* myStudyContext = _mapStudyContext_i[studyId];
-       int meshId = myMesh->GetId();
-       SMESH_Mesh_i* meshServant = myStudyContext->mapMesh_i[meshId];
-       ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
-       SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS();
-       
-       SCRUTE(mySMESHDSMesh->NbNodes());
-       if (mySMESHDSMesh->NbNodes()>0) {//checks if the mesh is not empty
-         
-         DriverMED_W_SMESHDS_Mesh* myWriter = new DriverMED_W_SMESHDS_Mesh;
-         myWriter->SetFile(meshfile.ToCString());
-         
-         myWriter->SetMesh(mySMESHDSMesh);
-         myWriter->SetMeshId(gotBranch->Tag());
-         myWriter->Add();
-       }
-       else meshfile = "No data";
-       
-       //********** opening of the HDF group
-       sprintf(name_meshgroup,"Mesh %d",gotBranch->Tag());
-       SCRUTE(name_meshgroup);
-       hdf_group[gotBranch->Tag()] = new HDFgroup(name_meshgroup,hdf_file);
-       hdf_group[gotBranch->Tag()]->CreateOnDisk();
-       //********** 
-       
-       //********** file where the data are stored
-       longueur = strlen(meshfile.ToCString()) +1;
-       size[0]=longueur;
-       strcpy(name_dataset,"Mesh data");
-       hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_group[gotBranch->Tag()],HDF_STRING,size,1);
-       hdf_dataset[cmpt_ds]->CreateOnDisk();
-       hdf_dataset[cmpt_ds]->WriteOnDisk(meshfile.ToCString());
-       hdf_dataset[cmpt_ds]->CloseOnDisk();
-       cmpt_ds++;
-       //********** 
-       
-       //********** ref on shape
-       Standard_CString  myRefOnObject="" ;
-       SALOMEDS::SObject_var myRef,myShape;
-       _found = gotBranch->FindSubObject(Tag_RefOnShape,myRef);
-       if (_found) {
-         ok = myRef->ReferencedObject(myShape);
-         myRefOnObject = myShape->GetID();
-         SCRUTE(myRefOnObject);
-         
-         longueur = strlen(myRefOnObject) +1;
-         if (longueur>1) {
-           size[0]=longueur;
-           strcpy(name_dataset,"Ref on shape");
-           hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_group[gotBranch->Tag()],HDF_STRING,size,1);
-           hdf_dataset[cmpt_ds]->CreateOnDisk();
-           hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
-           hdf_dataset[cmpt_ds]->CloseOnDisk();
-           cmpt_ds++;
-           
-         }
-       }
-       //********** 
-       
-       //********** ref on applied hypothesis
-       _found = gotBranch->FindSubObject(Tag_RefOnAppliedHypothesis,myBranch);
-       if (_found) {
-         
-         strcpy(name_meshgroup,"Applied Hypothesis");
-         hdf_subgroup[Tag_RefOnAppliedHypothesis] = new HDFgroup(name_meshgroup,hdf_group[gotBranch->Tag()]);
-         hdf_subgroup[Tag_RefOnAppliedHypothesis]->CreateOnDisk();
-         
-         it = Study->NewChildIterator(myBranch);
-         cmpt_it = 0;
-         for (; it->More();it->Next()) {
-           mySObject = it->Value();
-           ok = mySObject->ReferencedObject(myRef);
-           myRefOnObject = myRef->GetID();
-           
-           longueur = strlen(myRefOnObject) +1;
-           if (longueur>1) {
-             size[0]=longueur;
-             sprintf(name_dataset,"Hyp %d",cmpt_it);
-             hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_subgroup[Tag_RefOnAppliedHypothesis],HDF_STRING,size,1);
-             hdf_dataset[cmpt_ds]->CreateOnDisk();
-             hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
-             hdf_dataset[cmpt_ds]->CloseOnDisk();
+    // --> hypotheses root branch (only one for the study)
+    if ( gotBranch->Tag() == GetHypothesisRootTag() ) {
+      // create hypotheses root HDF group
+      aTopGroup = new HDFgroup( "Hypotheses", aFile );
+      aTopGroup->CreateOnDisk();
+
+      // iterator for all hypotheses
+      SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( gotBranch );
+      for ( ; it->More(); it->Next() ) {
+        SALOMEDS::SObject_var mySObject = it->Value();
+       CORBA::Object_var anObject = SObjectToObject( mySObject );
+       if ( !CORBA::is_nil( anObject ) ) {
+          SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+          if ( !myHyp->_is_nil() ) {
+           SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
+           if ( myImpl ) {
+             string hypname = string( myHyp->GetName() );
+             string libname = string( myHyp->GetLibName() );
+             int    id      = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+             string hypdata = string( myImpl->SaveTo() );
+
+             // for each hypothesis create HDF group basing on its id
+             char hypGrpName[30];
+             sprintf( hypGrpName, "Hypothesis %d", id );
+             aGroup = new HDFgroup( hypGrpName, aTopGroup );
+             aGroup->CreateOnDisk();
+             // --> type name of hypothesis
+             aSize[ 0 ] = hypname.length() + 1;
+             aDataset = new HDFdataset( "Name", aGroup, HDF_STRING, aSize, 1 );
+             aDataset->CreateOnDisk();
+             aDataset->WriteOnDisk( ( char* )( hypname.c_str() ) );
+             aDataset->CloseOnDisk();
+             // --> server plugin library name of hypothesis
+             aSize[ 0 ] = libname.length() + 1;
+             aDataset = new HDFdataset( "LibName", aGroup, HDF_STRING, aSize, 1 );
+             aDataset->CreateOnDisk();
+             aDataset->WriteOnDisk( ( char* )( libname.c_str() ) );
+             aDataset->CloseOnDisk();
+             // --> persistent data of hypothesis
+             aSize[ 0 ] = hypdata.length() + 1;
+             aDataset = new HDFdataset( "Data", aGroup, HDF_STRING, aSize, 1 );
+             aDataset->CreateOnDisk();
+             aDataset->WriteOnDisk( ( char* )( hypdata.c_str() ) );
+             aDataset->CloseOnDisk();
+             // close hypothesis HDF group
+             aGroup->CloseOnDisk();
            }
-           cmpt_ds++;
-           cmpt_it++;
          }
-         hdf_subgroup[Tag_RefOnAppliedHypothesis]->CloseOnDisk();
        }
-       //********** 
-       
-       //********** ref on applied algorithms
-       _found = gotBranch->FindSubObject(Tag_RefOnAppliedAlgorithms,myBranch);
-       if (_found) {
-         
-         strcpy(name_meshgroup,"Applied Algorithms");
-         hdf_subgroup[Tag_RefOnAppliedAlgorithms] = new HDFgroup(name_meshgroup,hdf_group[gotBranch->Tag()]);
-         hdf_subgroup[Tag_RefOnAppliedAlgorithms]->CreateOnDisk();
-         
-         it = Study->NewChildIterator(myBranch);
-         cmpt_it = 0;
-         for (; it->More();it->Next()) {
-           mySObject = it->Value();
-           ok = mySObject->ReferencedObject(myRef);
-           myRefOnObject = myRef->GetID();
-           
-           longueur = strlen(myRefOnObject) +1;
-           if (longueur>1) {
-             size[0]=longueur;
-             sprintf(name_dataset,"Algo %d",cmpt_it);
-             hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_subgroup[Tag_RefOnAppliedAlgorithms],HDF_STRING,size,1);
-             hdf_dataset[cmpt_ds]->CreateOnDisk();
-             hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
-             hdf_dataset[cmpt_ds]->CloseOnDisk();
+      }
+      // close hypotheses root HDF group
+      aTopGroup->CloseOnDisk();
+    }
+    // --> algorithms root branch (only one for the study)
+    else if ( gotBranch->Tag() == GetAlgorithmsRootTag() ) {
+      // create algorithms root HDF group
+      aTopGroup = new HDFgroup( "Algorithms", aFile );
+      aTopGroup->CreateOnDisk();
+
+      // iterator for all algorithms
+      SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( gotBranch );
+      for ( ; it->More(); it->Next() ) {
+        SALOMEDS::SObject_var mySObject = it->Value();
+       CORBA::Object_var anObject = SObjectToObject( mySObject );
+       if ( !CORBA::is_nil( anObject ) ) {
+          SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
+          if ( !myHyp->_is_nil() ) {
+           SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
+           if ( myImpl ) {
+             string hypname = string( myHyp->GetName() );
+             string libname = string( myHyp->GetLibName() );
+             int    id      = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+             string hypdata = string( myImpl->SaveTo() );
+
+             // for each algorithm create HDF group basing on its id
+             char hypGrpName[30];
+             sprintf( hypGrpName, "Algorithm %d", id );
+             aGroup = new HDFgroup( hypGrpName, aTopGroup );
+             aGroup->CreateOnDisk();
+             // --> type name of algorithm
+             aSize[0] = hypname.length() + 1;
+             aDataset = new HDFdataset( "Name", aGroup, HDF_STRING, aSize, 1 );
+             aDataset->CreateOnDisk();
+             aDataset->WriteOnDisk( ( char* )( hypname.c_str() ) );
+             aDataset->CloseOnDisk();
+             // --> server plugin library name of hypothesis
+             aSize[0] = libname.length() + 1;
+             aDataset = new HDFdataset( "LibName", aGroup, HDF_STRING, aSize, 1 );
+             aDataset->CreateOnDisk();
+             aDataset->WriteOnDisk( ( char* )( libname.c_str() ) );
+             aDataset->CloseOnDisk();
+             // --> persistent data of algorithm
+             aSize[0] = hypdata.length() + 1;
+             aDataset = new HDFdataset( "Data", aGroup, HDF_STRING, aSize, 1 );
+             aDataset->CreateOnDisk();
+             aDataset->WriteOnDisk( ( char* )( hypdata.c_str() ) );
+             aDataset->CloseOnDisk();
+             // close algorithm HDF group
+             aGroup->CloseOnDisk();
            }
-           cmpt_ds++;
-           cmpt_it++;
          }
-         hdf_subgroup[Tag_RefOnAppliedAlgorithms]->CloseOnDisk();
        }
-       MESSAGE("end of algo applied");
-       //********** 
-       
-       //********** submeshes on subshapes
-       int myLevel1Tag;
-       for (int i=Tag_SubMeshOnVertex;i<=Tag_SubMeshOnCompound;i++) {
-         _found = gotBranch->FindSubObject(i,myBranch);
-         if (_found) {
-           if (i==Tag_SubMeshOnVertex)
-             strcpy(name_meshgroup,"SubMeshes On Vertex");
-           else if (i==Tag_SubMeshOnEdge)
-             strcpy(name_meshgroup,"SubMeshes On Edge");
-           else if (i==Tag_SubMeshOnFace)
-             strcpy(name_meshgroup,"SubMeshes On Face");
-           else if (i==Tag_SubMeshOnSolid)
-             strcpy(name_meshgroup,"SubMeshes On Solid");
-           else if (i==Tag_SubMeshOnCompound)
-             strcpy(name_meshgroup,"SubMeshes On Compound");
-
-           cmpt_sm++;
-           myLevel1Tag = 10+cmpt_sm;
-           hdf_subgroup[myLevel1Tag] = new HDFgroup(name_meshgroup,hdf_group[gotBranch->Tag()]);
-           hdf_subgroup[myLevel1Tag]->CreateOnDisk();
+      }
+      // close algorithms root HDF group
+      aTopGroup->CloseOnDisk();
+    }
+    // --> mesh objects roots branches
+    else if ( gotBranch->Tag() > GetAlgorithmsRootTag() ) {
+      CORBA::Object_var anObject = SObjectToObject( gotBranch );
+      if ( !CORBA::is_nil( anObject ) ) {
+       SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow( anObject ) ;
+        if ( !myMesh->_is_nil() ) {
+         SMESH_Mesh_i* myImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( myMesh ).in() );
+         if ( myImpl ) {
+           int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+           ::SMESH_Mesh& myLocMesh = myImpl->GetImpl();
+           SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS();
+
+           // for each mesh open the HDF group basing on its id
+           char meshGrpName[ 30 ];
+           sprintf( meshGrpName, "Mesh %d", id );
+           aTopGroup = new HDFgroup( meshGrpName, aFile );
+           aTopGroup->CreateOnDisk();
+
+           // --> put dataset to hdf file which is a flag that mesh has data
+           string strHasData = "0";
+           // check if the mesh is not empty
+           if ( mySMESHDSMesh->NbNodes() > 0 ) {
+             // write mesh data to med file
+             myWriter.SetMesh( mySMESHDSMesh );
+             myWriter.SetMeshId( id );
+             strHasData = "1";
+           }
+           aSize[ 0 ] = strHasData.length() + 1;
+           aDataset = new HDFdataset( "Has data", aTopGroup, HDF_STRING, aSize, 1 );
+           aDataset->CreateOnDisk();
+           aDataset->WriteOnDisk( ( char* )( strHasData.c_str() ) );
+           aDataset->CloseOnDisk();
            
-           itSM = Study->NewChildIterator(myBranch);
-           for (; itSM->More();itSM->Next()) {//Loop on all submeshes
-             mySObject = itSM->Value();
-             cmpt_sm++;
-             myTag = 10+cmpt_sm;
-             mySObject->FindAttribute(anAttr, "AttributeIOR");
-             anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-             SMESH::SMESH_subMesh_var mySubMesh =  SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->Value())) ;
-
-             //sprintf(name_meshgroup,"SubMesh %d",myTag);
-             sprintf(name_meshgroup,"SubMesh %d",mySubMesh->GetId());
-             SCRUTE(name_meshgroup);
-             
-             hdf_subgroup[myTag] = new HDFgroup(name_meshgroup,hdf_subgroup[myLevel1Tag]);
-             hdf_subgroup[myTag]->CreateOnDisk();
-             
-             //********** ref on shape
-             Standard_CString  myRefOnObject="" ;
-             SALOMEDS::SObject_var myRef,myShape;
-             bool _found2;
-             _found2 = mySObject->FindSubObject(Tag_RefOnShape,myRef);
-             if (_found2) {
-               ok = myRef->ReferencedObject(myShape);
-               myRefOnObject = myShape->GetID();
-               SCRUTE(myRefOnObject);
-               
-               longueur = strlen(myRefOnObject) +1;
-               if (longueur>1) {
-                 size[0]=longueur;
-                 strcpy(name_dataset,"Ref on shape");
-                 hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_subgroup[myTag],HDF_STRING,size,1);
-                 hdf_dataset[cmpt_ds]->CreateOnDisk();
-                 hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
-                 hdf_dataset[cmpt_ds]->CloseOnDisk();
-                 cmpt_ds++;
+           // write reference on a shape if exists
+           SALOMEDS::SObject_var myRef;
+           bool found = gotBranch->FindSubObject( GetRefOnShapeTag(), myRef );
+           if ( found ) {
+             SALOMEDS::SObject_var myShape;
+             bool ok = myRef->ReferencedObject( myShape );
+             if ( ok ) {
+               string myRefOnObject = myShape->GetID();
+               if ( myRefOnObject.length() > 0 ) {
+                 aSize[ 0 ] = myRefOnObject.length() + 1;
+                 aDataset = new HDFdataset( "Ref on shape", aTopGroup, HDF_STRING, aSize, 1 );
+                 aDataset->CreateOnDisk();
+                 aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
+                 aDataset->CloseOnDisk();
                }
              }
-             //********** 
-             
-             //********** ref on applied hypothesis
-             _found2 = mySObject->FindSubObject(Tag_RefOnAppliedHypothesis,myBranch);
-             if (_found2) {
-               
-               strcpy(name_meshgroup,"Applied Hypothesis");
-               cmpt_sm++;
-               hdf_subgroup[10+cmpt_sm] = new HDFgroup(name_meshgroup,hdf_subgroup[myTag]);
-               hdf_subgroup[10+cmpt_sm]->CreateOnDisk();
+           }
+
+           // write applied hypotheses if exist
+           SALOMEDS::SObject_var myHypBranch;
+           found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch );
+           if ( found ) {
+             aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup );
+             aGroup->CreateOnDisk();
+
+             SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myHypBranch );
+             int hypNb = 0;
+             for ( ; it->More(); it->Next() ) {
+               SALOMEDS::SObject_var mySObject = it->Value();
+               SALOMEDS::SObject_var myRefOnHyp;
+               bool ok = mySObject->ReferencedObject( myRefOnHyp );
+               if ( ok ) {
+                 // san - it is impossible to recover applied hypotheses
+                  //       using their entries within Load() method,
+                 // for there are no AttributeIORs in the study when Load() is working. 
+                 // Hence, it is better to store persistent IDs of hypotheses as references to them
+
+                 //string myRefOnObject = myRefOnHyp->GetID();
+                 CORBA::Object_var anObject = SObjectToObject( myRefOnHyp );
+                 int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+                 //if ( myRefOnObject.length() > 0 ) {
+                 //aSize[ 0 ] = myRefOnObject.length() + 1;
+                 char hypName[ 30 ], hypId[ 30 ];
+                 sprintf( hypName, "Hyp %d", ++hypNb );
+                 sprintf( hypId, "%d", id );
+                 aSize[ 0 ] = strlen( hypId ) + 1;
+                 aDataset = new HDFdataset( hypName, aGroup, HDF_STRING, aSize, 1 );
+                 aDataset->CreateOnDisk();
+                 //aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
+                 aDataset->WriteOnDisk( hypId );
+                 aDataset->CloseOnDisk();
+                 //}
+               }
+             }
+             aGroup->CloseOnDisk();
+           }
+
+           // write applied algorithms if exist
+           SALOMEDS::SObject_var myAlgoBranch;
+           found = gotBranch->FindSubObject( GetRefOnAppliedAlgorithmsTag(), myAlgoBranch );
+           if ( found ) {
+             aGroup = new HDFgroup( "Applied Algorithms", aTopGroup );
+             aGroup->CreateOnDisk();
+
+             SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myAlgoBranch );
+             int algoNb = 0;
+             for ( ; it->More(); it->Next() ) {
+               SALOMEDS::SObject_var mySObject = it->Value();
+               SALOMEDS::SObject_var myRefOnAlgo;
+               bool ok = mySObject->ReferencedObject( myRefOnAlgo );
+               if ( ok ) {
+                 // san - it is impossible to recover applied algorithms
+                  //       using their entries within Load() method,
+                 // for there are no AttributeIORs in the study when Load() is working. 
+                 // Hence, it is better to store persistent IDs of algorithms as references to them
+
+                 //string myRefOnObject = myRefOnAlgo->GetID();
+                 CORBA::Object_var anObject = SObjectToObject( myRefOnAlgo );
+                 int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+                 //if ( myRefOnObject.length() > 0 ) {
+                 //aSize[ 0 ] = myRefOnObject.length() + 1;
+                 char algoName[ 30 ], algoId[ 30 ];
+                 sprintf( algoName, "Algo %d", ++algoNb );
+                 sprintf( algoId, "%d", id );
+                 aSize[ 0 ] = strlen( algoId ) + 1;
+                 aDataset = new HDFdataset( algoName, aGroup, HDF_STRING, aSize, 1 );
+                 aDataset->CreateOnDisk();
+                 //aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
+                 aDataset->WriteOnDisk( algoId );
+                 aDataset->CloseOnDisk();
+                 //}
+               }
+             }
+             aGroup->CloseOnDisk();
+           }
+
+           // --> submesh objects sub-branches
+           for ( int i = GetSubMeshOnVertexTag(); i <= GetSubMeshOnCompoundTag(); i++ ) {
+             SALOMEDS::SObject_var mySubmeshBranch;
+             found = gotBranch->FindSubObject( i, mySubmeshBranch );
+             if ( found ) {
+               char name_meshgroup[ 30 ];
+               if ( i == GetSubMeshOnVertexTag() )
+                 strcpy( name_meshgroup, "SubMeshes On Vertex" );
+               else if ( i == GetSubMeshOnEdgeTag() )
+                 strcpy( name_meshgroup, "SubMeshes On Edge" );
+               else if ( i == GetSubMeshOnFaceTag() )
+                 strcpy( name_meshgroup, "SubMeshes On Face" );
+               else if ( i == GetSubMeshOnSolidTag() )
+                 strcpy( name_meshgroup, "SubMeshes On Solid" );
+               else if ( i == GetSubMeshOnCompoundTag() )
+                 strcpy( name_meshgroup, "SubMeshes On Compound" );
                
-               it = Study->NewChildIterator(myBranch);
-               cmpt_it = 0;
-               for (; it->More();it->Next()) {
-                 mySObjectChild = it->Value();
-                 ok = mySObjectChild->ReferencedObject(myRef);
-                 myRefOnObject = myRef->GetID();
-                 
-                 longueur = strlen(myRefOnObject) +1;
-                 if (longueur>1) {
-                   size[0]=longueur;
-                   sprintf(name_dataset,"Hyp %d",cmpt_it);
-                   SCRUTE(cmpt_it);
-                   hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_subgroup[10+cmpt_sm],HDF_STRING,size,1);
-                   hdf_dataset[cmpt_ds]->CreateOnDisk();
-                   hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
-                   hdf_dataset[cmpt_ds]->CloseOnDisk();
+               // for each type of submeshes create container HDF group
+               aGroup = new HDFgroup( name_meshgroup, aTopGroup );
+               aGroup->CreateOnDisk();
+           
+               // iterator for all submeshes of given type
+               SALOMEDS::ChildIterator_var itSM = myCurrentStudy->NewChildIterator( mySubmeshBranch );
+               for ( ; itSM->More(); itSM->Next() ) {
+                 SALOMEDS::SObject_var mySObject = itSM->Value();
+                 CORBA::Object_var anSubObject = SObjectToObject( mySObject );
+                 if ( !CORBA::is_nil( anSubObject ) ) {
+                   SMESH::SMESH_subMesh_var mySubMesh = SMESH::SMESH_subMesh::_narrow( anSubObject ) ;
+                   int subid = myStudyContext->findId( string( GetORB()->object_to_string( anSubObject ) ) );
+                     
+                   // for each mesh open the HDF group basing on its id
+                   char submeshGrpName[ 30 ];
+                   sprintf( submeshGrpName, "SubMesh %d", subid );
+                   aSubGroup = new HDFgroup( submeshGrpName, aGroup );
+                   aSubGroup->CreateOnDisk();
+
+//                 // Put submesh data to MED convertor
+//                 if ( myImpl->_mapSubMesh.find( mySubMesh->GetId() ) != myImpl->_mapSubMesh.end() ) {
+//                   MESSAGE( "VSR - SMESH_Gen_i::Save(): saving submesh with ID = "
+//                              << mySubMesh->GetId() << " to MED file" );
+//                   ::SMESH_subMesh* aLocalSubmesh = myImpl->_mapSubMesh[mySubMesh->GetId()];
+//                   myWriter.AddSubMesh( aLocalSubmesh->GetSubMeshDS(), subid );
+//                 }
+                   
+                   // write reference on a shape if exists
+                   SALOMEDS::SObject_var mySubRef;
+                   found = mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef );
+                   if ( found ) {
+                     SALOMEDS::SObject_var myShape;
+                     bool ok = mySubRef->ReferencedObject( myShape );
+                     if ( ok ) {
+                       string myRefOnObject = myShape->GetID();
+                       if ( myRefOnObject.length() > 0 ) {
+                         aSize[ 0 ] = myRefOnObject.length() + 1;
+                         aDataset = new HDFdataset( "Ref on shape", aSubGroup, HDF_STRING, aSize, 1 );
+                         aDataset->CreateOnDisk();
+                         aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
+                         aDataset->CloseOnDisk();
+                       }
+                     }
+                   }
+
+                   // write applied hypotheses if exist
+                   SALOMEDS::SObject_var mySubHypBranch;
+                   found = mySObject->FindSubObject( GetRefOnAppliedHypothesisTag(), mySubHypBranch );
+                   if ( found ) {
+                     aSubSubGroup = new HDFgroup( "Applied Hypotheses", aSubGroup );
+                     aSubSubGroup->CreateOnDisk();
+
+                     SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( mySubHypBranch );
+                     int hypNb = 0;
+                     for ( ; it->More(); it->Next() ) {
+                       SALOMEDS::SObject_var mySubSObject = it->Value();
+                       SALOMEDS::SObject_var myRefOnHyp;
+                       bool ok = mySubSObject->ReferencedObject( myRefOnHyp );
+                       if ( ok ) {
+                         //string myRefOnObject = myRefOnHyp->GetID();
+                         CORBA::Object_var anObject = SObjectToObject( myRefOnHyp );
+                         int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+                         //if ( myRefOnObject.length() > 0 ) {
+                         //aSize[ 0 ] = myRefOnObject.length() + 1;
+                         char hypName[ 30 ], hypId[ 30 ];
+                         sprintf( hypName, "Hyp %d", ++hypNb );
+                         sprintf( hypId, "%d", id );
+                         aSize[ 0 ] = strlen( hypId ) + 1;
+                         aDataset = new HDFdataset( hypName, aSubSubGroup, HDF_STRING, aSize, 1 );
+                         aDataset->CreateOnDisk();
+                         //aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
+                         aDataset->WriteOnDisk( hypId );
+                         aDataset->CloseOnDisk();
+                         //}
+                       }
+                     }
+                     aSubSubGroup->CloseOnDisk();
+                   }
+                   
+                   // write applied algorithms if exist
+                   SALOMEDS::SObject_var mySubAlgoBranch;
+                   found = mySObject->FindSubObject( GetRefOnAppliedAlgorithmsTag(), mySubAlgoBranch );
+                   if ( found ) {
+                     aSubSubGroup = new HDFgroup( "Applied Algorithms", aSubGroup );
+                     aSubSubGroup->CreateOnDisk();
+
+                     SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( mySubAlgoBranch );
+                     int algoNb = 0;
+                     for ( ; it->More(); it->Next() ) {
+                       SALOMEDS::SObject_var mySubSObject = it->Value();
+                       SALOMEDS::SObject_var myRefOnAlgo;
+                       bool ok = mySubSObject->ReferencedObject( myRefOnAlgo );
+                       if ( ok ) {
+                         //string myRefOnObject = myRefOnAlgo->GetID();
+                         CORBA::Object_var anObject = SObjectToObject( myRefOnAlgo );
+                         int id = myStudyContext->findId( string( GetORB()->object_to_string( anObject ) ) );
+                         //if ( myRefOnObject.length() > 0 ) {
+                         //aSize[ 0 ] = myRefOnObject.length() + 1;
+                         char algoName[ 30 ], algoId[ 30 ];
+                         sprintf( algoName, "Algo %d", ++algoNb );
+                         sprintf( algoId, "%d", id );
+                         aSize[ 0 ] = strlen( algoId ) + 1;
+                         aDataset = new HDFdataset( algoName, aSubSubGroup, HDF_STRING, aSize, 1 );
+                         aDataset->CreateOnDisk();
+                         //aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
+                         aDataset->WriteOnDisk( algoId );
+                         aDataset->CloseOnDisk();
+                         //}
+                       }
+                     }
+                     aSubSubGroup->CloseOnDisk();
+                   }
+                   // close submesh HDF group
+                   aSubGroup->CloseOnDisk();
                  }
-                 cmpt_ds++;
-                 cmpt_it++;
                }
-               hdf_subgroup[10+cmpt_sm]->CloseOnDisk();
+               // close container of submeshes by type HDF group
+               aGroup->CloseOnDisk();
              }
-             //********** 
-             
-             //********** ref on applied algorithms
-             _found2 = mySObject->FindSubObject(Tag_RefOnAppliedAlgorithms,myBranch);
-             SCRUTE(_found2);
-             if (_found2) {
-               
-               strcpy(name_meshgroup,"Applied Algorithms");
-               cmpt_sm++;
-               hdf_subgroup[10+cmpt_sm] = new HDFgroup(name_meshgroup,hdf_subgroup[myTag]);
-               hdf_subgroup[10+cmpt_sm]->CreateOnDisk();
-               
-               it = Study->NewChildIterator(myBranch);
-               cmpt_it = 0;
-               for (; it->More();it->Next()) {
-                 mySObjectChild = it->Value();
-                 ok = mySObjectChild->ReferencedObject(myRef);
-                 myRefOnObject = myRef->GetID();
-                 
-                 longueur = strlen(myRefOnObject) +1;
-                 if (longueur>1) {
-                   size[0]=longueur;
-                   sprintf(name_dataset,"Algo %d",cmpt_it);
-                   hdf_dataset[cmpt_ds]=new HDFdataset(name_dataset,hdf_subgroup[10+cmpt_sm],HDF_STRING,size,1);
-                   hdf_dataset[cmpt_ds]->CreateOnDisk();
-                   hdf_dataset[cmpt_ds]->WriteOnDisk(myRefOnObject);
-                   hdf_dataset[cmpt_ds]->CloseOnDisk();
+           }
+            // All sub-meshes will be stored in MED file
+            myWriter.AddAllSubMeshes();
+
+           // groups root sub-branch
+           SALOMEDS::SObject_var myGroupsBranch;
+           for ( int i = GetNodeGroupsTag(); i <= GetVolumeGroupsTag(); i++ ) {
+             found = gotBranch->FindSubObject( i, myGroupsBranch );
+             if ( found ) {
+               char name_group[ 30 ];
+               if ( i == GetNodeGroupsTag() )
+                 strcpy( name_group, "Groups of Nodes" );
+               else if ( i == GetEdgeGroupsTag() )
+                 strcpy( name_group, "Groups of Edges" );
+               else if ( i == GetFaceGroupsTag() )
+                 strcpy( name_group, "Groups of Faces" );
+               else if ( i == GetVolumeGroupsTag() )
+                 strcpy( name_group, "Groups of Volumes" );
+
+               aGroup = new HDFgroup( name_group, aTopGroup );
+               aGroup->CreateOnDisk();
+
+               SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myGroupsBranch );
+               int grpNb = 0;
+               for ( ; it->More(); it->Next() ) {
+                 SALOMEDS::SObject_var mySObject = it->Value();
+                 CORBA::Object_var aSubObject = SObjectToObject( mySObject );
+                 if ( !CORBA::is_nil( aSubObject ) ) {
+                   SMESH_Group_i* myGroupImpl = dynamic_cast<SMESH_Group_i*>( GetServant( aSubObject ).in() );
+                   if ( !myGroupImpl )
+                     continue;
+
+                   int anId = myStudyContext->findId( string( GetORB()->object_to_string( aSubObject ) ) );
+                   
+                   // For each group, create a dataset named "Group <group_persistent_id>"
+                    // and store the group's user name into it
+                   char grpName[ 30 ];
+                   sprintf( grpName, "Group %d", anId );
+                   char* aUserName = myGroupImpl->GetName();
+                   aSize[ 0 ] = strlen( aUserName ) + 1;
+
+                   aDataset = new HDFdataset( grpName, aGroup, HDF_STRING, aSize, 1 );
+                   aDataset->CreateOnDisk();
+                   aDataset->WriteOnDisk( aUserName );
+                   aDataset->CloseOnDisk();
+
+                   // Store the group contents into MED file
+                   if ( myLocMesh.GetGroup( myGroupImpl->GetLocalID() ) ) {
+                     MESSAGE( "VSR - SMESH_Gen_i::Save(): saving group with StoreName = "
+                              << grpName << " to MED file" );
+                     SMESHDS_Group* aGrpDS = myLocMesh.GetGroup( myGroupImpl->GetLocalID() )->GetGroupDS();
+                     aGrpDS->SetStoreName( grpName );
+
+                     // Pass SMESHDS_Group to MED writer 
+                     myWriter.AddGroup( aGrpDS );
+                   }
                  }
-                 cmpt_ds++;
-                 cmpt_it++;
                }
-               hdf_subgroup[10+cmpt_sm]->CloseOnDisk();
+               aGroup->CloseOnDisk();
              }
-             //MESSAGE("end of algo applied");
-             //********** 
-             
-             hdf_subgroup[myTag]->CloseOnDisk();
            }
-           
-           hdf_subgroup[myLevel1Tag]->CloseOnDisk();
+
+           // Flush current mesh information into MED file
+           if ( strcmp( strHasData.c_str(), "1" ) == 0 )             
+             myWriter.Add();
+
+           // close mesh HDF group
+           aTopGroup->CloseOnDisk();
          }
-         
        }
-       //********** 
-       
-       //********** closing of the HDF group
-       hdf_group[gotBranch->Tag()]->CloseOnDisk();
-       MESSAGE("End of Mesh Save");
-       //********** 
-      }                  
+      }
     }
-    MESSAGE("End of Meshes Save");
   }
 
-  hdf_file->CloseOnDisk();
-  delete hdf_file;
-  hdf_file = 0;
+  // close HDF file
+  aFile->CloseOnDisk();
+  delete aFile;
 
   // Convert temporary files to stream
-  aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.ToCString(), aFileSeq.in(), isMultiFile);
+  aStreamFile = SALOMEDS_Tool::PutFilesToStream( tmpDir.ToCString(), aFileSeq.in(), isMultiFile );
 
   // Remove temporary files and directory
-  if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.ToCString(), aFileSeq.in(), true);
-
-  MESSAGE("End SMESH_Gen_i::Save");
+  if ( !isMultiFile ) 
+    SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq.in(), true );
 
+  INFOS( "SMESH_Gen_i::Save() completed" );
   return aStreamFile._retn();
 }
 
-SALOMEDS::TMPFile* SMESH_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
-                                         const char* theURL,
-                                         bool isMultiFile) {
-  SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::SaveASCII
+ *
+ *  Save SMESH module's data in ASCII format (not implemented yet)
+ */
+//=============================================================================
+
+SALOMEDS::TMPFile* SMESH_Gen_i::SaveASCII( SALOMEDS::SComponent_ptr theComponent,
+                                          const char*              theURL,
+                                          bool                     isMultiFile ) {
+  MESSAGE( "SMESH_Gen_i::SaveASCII" );
+  SALOMEDS::TMPFile_var aStreamFile = Save( theComponent, theURL, isMultiFile );
   return aStreamFile._retn();
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::loadGeomData
+ *
+ *  Load GEOM module data
  */
 //=============================================================================
 
-bool SMESH_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
-                      const SALOMEDS::TMPFile& theStream,
-                      const char* theURL,
-                      bool isMultiFile)
+void SMESH_Gen_i::loadGeomData( SALOMEDS::SComponent_ptr theCompRoot )
 {
-  MESSAGE("SMESH_Gen_i::Load\n");
+  if ( theCompRoot->_is_nil() )
+    return;
 
-  // Get temporary files location
-  TCollection_AsciiString tmpDir = isMultiFile?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
+  SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( theCompRoot->GetStudy() );
+  if ( aStudy->_is_nil() )
+    return;
 
-  // Convert the stream into sequence of files to process
-  SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
-                                                                           tmpDir.ToCString(),
-                                                                          isMultiFile);
+  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); 
+  aStudyBuilder->LoadWith( theCompRoot, GetGeomEngine() );
+}
 
-  TCollection_AsciiString aStudyName("");
-  if (isMultiFile) aStudyName = (SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()));
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::Load
+ *
+ *  Load SMESH module's data
+ */
+//=============================================================================
 
-  // Set names of temporary files
-  TCollection_AsciiString filename = tmpDir + aStudyName + TCollection_AsciiString("_SMESH.hdf");
-  TCollection_AsciiString hypofile = tmpDir + aStudyName + TCollection_AsciiString("_SMESH_Hypo.txt");
-  TCollection_AsciiString algofile = tmpDir + aStudyName + TCollection_AsciiString("_SMESH_Algo.txt");
-  TCollection_AsciiString meshfile = tmpDir + aStudyName + TCollection_AsciiString("_SMESH_Mesh.med");
+bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
+                       const SALOMEDS::TMPFile& theStream,
+                       const char*              theURL,
+                       bool                     isMultiFile )
+{
+  INFOS( "SMESH_Gen_i::Load" );
 
-  SALOMEDS::Study_var Study = theComponent->GetStudy(); 
-  int studyId = Study->StudyId();
-  SCRUTE(studyId);
+  ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() )
+  StudyContext* myStudyContext = GetCurrentStudyContext();
+  
+  // Get temporary files location
+  TCollection_AsciiString tmpDir =
+    isMultiFile ? TCollection_AsciiString( ( char* )theURL ) : SALOMEDS_Tool::GetTmpDir();
 
-  SALOMEDS::GenericAttribute_var anAttr;
-  SALOMEDS::AttributeName_var    aName;
-  SALOMEDS::AttributeIOR_var    anIOR;
-
-  SALOMEDS::SComponent_var fathergeom = Study->FindComponent("GEOM");
-  SALOMEDS::SComponent_var myGeomSComp = SALOMEDS::SComponent::_narrow( fathergeom );
-  SCRUTE(fathergeom);
-
-  //to get the geom engine !!!
-  //useful to define our new mesh
-  SALOME_NamingService* _NS = SINGLETON_<SALOME_NamingService>::Instance() ;
-  ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
-  _NS->init_orb( _orb ) ;
-  SALOME_LifeCycleCORBA* myEnginesLifeCycle = new SALOME_LifeCycleCORBA(_NS);
-  Engines::Component_var geomEngine =
-    myEnginesLifeCycle->FindOrLoad_Component("FactoryServer","GEOM");
-  GEOM::GEOM_Gen_var myGeomEngine = GEOM::GEOM_Gen::_narrow(geomEngine);
-
-
-  char* aLine;
-  bool ok;
-  char objectId[10],name_dataset[10];
-  int nb_datasets,size,cmpt_ds=0;
-  int cmpt_sm = 0;
-
-  char name[HDF_NAME_MAX_LEN+1];
-  char sgname[HDF_NAME_MAX_LEN+1];
-  char msgname[HDF_NAME_MAX_LEN+1];
-  char name_of_group[HDF_NAME_MAX_LEN+1];
-  char *name_meshgroup;
-  map <int,HDFgroup*> hdf_group, hdf_subgroup;
-  map <int,HDFdataset*> hdf_dataset;
-  FILE *loadedFile;
-
-  //************* HDF file opening
-  HDFfile * hdf_file = new HDFfile(filename.ToCString());
+  // Convert the stream into sequence of files to process
+  SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles( theStream,
+                                                                            tmpDir.ToCString(),
+                                                                           isMultiFile );
+  TCollection_AsciiString aStudyName( "" );
+  if ( isMultiFile ) 
+    aStudyName = ( SALOMEDS_Tool::GetNameFromPath( myCurrentStudy->URL() ) );
+
+  // Set names of temporary files
+  TCollection_AsciiString filename = tmpDir + aStudyName + TCollection_AsciiString( "_SMESH.hdf" );
+  TCollection_AsciiString meshfile = tmpDir + aStudyName + TCollection_AsciiString( "_SMESH_Mesh.med" );
+
+  int size;
+  HDFfile*    aFile;
+  HDFdataset* aDataset;
+  HDFgroup*   aTopGroup;
+  HDFgroup*   aGroup;
+  HDFgroup*   aSubGroup;
+  HDFgroup*   aSubSubGroup;
+
+  // Read data
+  // ---> open HDF file
+  aFile = new HDFfile( filename.ToCString() );
   try {
-    hdf_file->OpenOnDisk(HDF_RDONLY);
+    aFile->OpenOnDisk( HDF_RDONLY );
   }
-  catch (HDFexception) {
-    MESSAGE("Load(): " << filename << " not found!");
+  catch ( HDFexception ) {
+    MESSAGE( "Load(): " << filename << " not found!" );
     return false;
   }
 
-  //****************************
+  DriverMED_R_SMESHDS_Mesh myReader;
+  myReader.SetFile( meshfile.ToCString() );
+
+  // get total number of top-level groups
+  int aNbGroups = aFile->nInternalObjects(); 
+  if ( aNbGroups > 0 ) {
+    // --> in first turn we should read&create hypotheses
+    if ( aFile->ExistInternalObject( "Hypotheses" ) ) {
+      // open hypotheses root HDF group
+      aTopGroup = new HDFgroup( "Hypotheses", aFile ); 
+      aTopGroup->OpenOnDisk();
+
+      // get number of hypotheses
+      int aNbObjects = aTopGroup->nInternalObjects(); 
+      for ( int j = 0; j < aNbObjects; j++ ) {
+       // try to identify hypothesis
+       char hypGrpName[ HDF_NAME_MAX_LEN+1 ];
+        aTopGroup->InternalObjectIndentify( j, hypGrpName );
+
+       if ( string( hypGrpName ).substr( 0, 10 ) == string( "Hypothesis" ) ) {
+         // open hypothesis group
+         aGroup = new HDFgroup( hypGrpName, aTopGroup ); 
+         aGroup->OpenOnDisk();
+
+         // --> get hypothesis id
+         int    id = atoi( string( hypGrpName ).substr( 10 ).c_str() );
+         string hypname;
+         string libname;
+         string hypdata;
+
+         // get number of datasets
+         int aNbSubObjects = aGroup->nInternalObjects();
+         for ( int k = 0; k < aNbSubObjects; k++ ) {
+           // identify dataset
+           char name_of_subgroup[ HDF_NAME_MAX_LEN+1 ];
+           aGroup->InternalObjectIndentify( k, name_of_subgroup );
+           // --> get hypothesis name
+           if ( strcmp( name_of_subgroup, "Name"  ) == 0 ) {
+             aDataset = new HDFdataset( name_of_subgroup, aGroup );
+             aDataset->OpenOnDisk();
+             size = aDataset->GetSize();
+             char* hypname_str = new char[ size ];
+             aDataset->ReadFromDisk( hypname_str );
+             hypname = string( hypname_str );
+             delete hypname_str;
+             aDataset->CloseOnDisk();
+           }
+           // --> get hypothesis plugin library name
+           if ( strcmp( name_of_subgroup, "LibName"  ) == 0 ) {
+             aDataset = new HDFdataset( name_of_subgroup, aGroup );
+             aDataset->OpenOnDisk();
+             size = aDataset->GetSize();
+             char* libname_str = new char[ size ];
+             aDataset->ReadFromDisk( libname_str );
+             SCRUTE( libname_str );
+             libname = string( libname_str );
+             delete libname_str;
+             aDataset->CloseOnDisk();
+           }
+           // --> get hypothesis data
+           if ( strcmp( name_of_subgroup, "Data"  ) == 0 ) {
+             aDataset = new HDFdataset( name_of_subgroup, aGroup );
+             aDataset->OpenOnDisk();
+             size = aDataset->GetSize();
+             char* hypdata_str = new char[ size ];
+             aDataset->ReadFromDisk( hypdata_str );
+             hypdata = string( hypdata_str );
+             delete hypdata_str;
+             aDataset->CloseOnDisk();
+           }
+         }
+         // close hypothesis HDF group
+         aGroup->CloseOnDisk();
+
+         // --> restore hypothesis from data
+         if ( id > 0 && !hypname.empty()/* && !hypdata.empty()*/ ) { // VSR : persistent data can be empty
+           MESSAGE("VSR - load hypothesis : id = " << id <<
+                    ", name = " << hypname.c_str() << ", persistent string = " << hypdata.c_str());
+            SMESH::SMESH_Hypothesis_var myHyp;
+           
+           try { // protect persistence mechanism against exceptions
+             myHyp = this->createHypothesis( hypname.c_str(), libname.c_str() );
+           }
+           catch (...) {
+             MESSAGE( "Exception during hypothesis creation" );
+           }
 
-  int nb_group = hdf_file->nInternalObjects(); 
-  SCRUTE(nb_group);
-  for (int i=0;i<nb_group;i++) 
-    {
-      hdf_file->InternalObjectIndentify(i,name);
-      //SCRUTE(name);
-      
-//***************
-// Loading of the Hypothesis Branch
-//***************
-      if (strcmp(name,"Hypothesis")==0) {
-        
-        double length,maxElementsArea,maxElementsVolume;
-        int numberOfSegments;
-
-        hdf_group[Tag_HypothesisRoot] = new HDFgroup(name,hdf_file); 
-        hdf_group[Tag_HypothesisRoot]->OpenOnDisk();
-        
-        hdf_group[Tag_HypothesisRoot]->InternalObjectIndentify(0,name_of_group);
-        hdf_dataset[cmpt_ds]=new HDFdataset(name_of_group,hdf_group[Tag_HypothesisRoot]);
-        hdf_dataset[cmpt_ds]->OpenOnDisk();
-        size=hdf_dataset[cmpt_ds]->GetSize();
-
-        char * name_of_file =new char[size];
-        hdf_dataset[cmpt_ds]->ReadFromDisk(name_of_file);
-        SCRUTE(name_of_file);
-        hdf_dataset[cmpt_ds]->CloseOnDisk();
-        hdf_group[Tag_HypothesisRoot]->CloseOnDisk();
-        cmpt_ds++;
-        delete[] name_of_file;
-        name_of_file = 0;
-
-        aLine = new char[100];
-        loadedFile = fopen( hypofile.ToCString() ,"r");
-        while (!feof(loadedFile)) {
-          fscanf(loadedFile,"%s",aLine);
-          //SCRUTE(aLine);
-          if (strcmp(aLine,"LocalLength")==0) {
-            SMESH::SMESH_Hypothesis_var myHyp  = this->CreateHypothesis(aLine,studyId);
-            SMESH::SMESH_LocalLength_var LL = SMESH::SMESH_LocalLength::_narrow( myHyp );
-            fscanf(loadedFile,"%s",aLine);
-            length = atof(aLine);
-            LL->SetLength(length);
-            string iorString = _orb->object_to_string(LL);
-            sprintf(objectId,"%d",LL->GetId());
-            _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString;
-          }
-          else if (strcmp(aLine,"NumberOfSegments")==0) {
-            SMESH::SMESH_Hypothesis_var myHyp  = this->CreateHypothesis(aLine,studyId);
-            SMESH::SMESH_NumberOfSegments_var NOS = SMESH::SMESH_NumberOfSegments::_narrow( myHyp );
-            fscanf(loadedFile,"%s",aLine);
-            numberOfSegments = atoi(aLine);
-            NOS->SetNumberOfSegments(numberOfSegments);
-            string iorString = _orb->object_to_string(NOS);
-            sprintf(objectId,"%d",NOS->GetId());
-            _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString;
-          }
-          else if (strcmp(aLine,"MaxElementArea")==0) {
-            SMESH::SMESH_Hypothesis_var myHyp  = this->CreateHypothesis(aLine,studyId);
-            SMESH::SMESH_MaxElementArea_var MEA = SMESH::SMESH_MaxElementArea::_narrow( myHyp );
-            fscanf(loadedFile,"%s",aLine);
-            maxElementsArea = atof(aLine);
-            MEA->SetMaxElementArea(maxElementsArea);
-            string iorString = _orb->object_to_string(MEA);
-            sprintf(objectId,"%d",MEA->GetId());
-            _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString;
-          }
-          else if (strcmp(aLine,"MaxElementVolume")==0) {
-            SMESH::SMESH_Hypothesis_var myHyp  = this->CreateHypothesis(aLine,studyId);
-            SMESH::SMESH_MaxElementVolume_var MEV = SMESH::SMESH_MaxElementVolume::_narrow( myHyp );
-            fscanf(loadedFile,"%s",aLine);
-            maxElementsVolume = atof(aLine);
-            MEV->SetMaxElementVolume(maxElementsVolume);
-            string iorString = _orb->object_to_string(MEV);
-            sprintf(objectId,"%d",MEV->GetId());
-            _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString;
+           SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
+           if ( myImpl ) {
+             myImpl->LoadFrom( hypdata.c_str() );
+             string iorString = GetORB()->object_to_string( myHyp );
+             int newId = myStudyContext->findId( iorString );
+             myStudyContext->mapOldToNew( id, newId );
+           }
+           else
+             MESSAGE( "VSR - SMESH_Gen::Load - can't get servant" );
           }
-          
-
         }
-        fclose(loadedFile);
-        delete[] aLine;
-        aLine = 0;
-        MESSAGE("End of Hypos Load");
-
       }
-//***************
-// Loading of the Algorithms Branch
-//***************
-      else if (strcmp(name,"Algorithms")==0) {
-
-        hdf_group[Tag_AlgorithmsRoot] = new HDFgroup(name,hdf_file); 
-        hdf_group[Tag_AlgorithmsRoot]->OpenOnDisk();
-        
-        hdf_group[Tag_AlgorithmsRoot]->InternalObjectIndentify(0,name_of_group);
-        hdf_dataset[cmpt_ds] = new HDFdataset(name_of_group,hdf_group[Tag_AlgorithmsRoot]);
-        hdf_dataset[cmpt_ds]->OpenOnDisk();
-        size=hdf_dataset[cmpt_ds]->GetSize();
-
-        char * name_of_file =new char[size];
-        hdf_dataset[cmpt_ds]->ReadFromDisk(name_of_file);
-        hdf_dataset[cmpt_ds]->CloseOnDisk();
-        hdf_group[Tag_AlgorithmsRoot]->CloseOnDisk();
-        cmpt_ds++;
-        delete[] name_of_file;
-        name_of_file = 0;
-        
-        aLine = new char[100];
-        loadedFile = fopen( algofile.ToCString(),"r");
-        while (!feof(loadedFile)) {
-          fscanf(loadedFile,"%s\n",aLine);
-          //SCRUTE(aLine);
-          if (strcmp(aLine,"")!=0) {
-            SMESH::SMESH_Hypothesis_var myHyp = this->CreateHypothesis(aLine,studyId);
-            SMESH::SMESH_Algo_var myAlgo = SMESH::SMESH_Algo::_narrow(myHyp);
-            string iorString = _orb->object_to_string(myAlgo);
-            sprintf(objectId,"%d",myAlgo->GetId());
-            _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString;
+      // close hypotheses root HDF group
+      aTopGroup->CloseOnDisk();
+    }
+
+    // --> then we should read&create algorithms
+    if ( aFile->ExistInternalObject( "Algorithms" ) ) {
+      // open algorithms root HDF group
+      aTopGroup = new HDFgroup( "Algorithms", aFile ); 
+      aTopGroup->OpenOnDisk();
+
+      // get number of algorithms
+      int aNbObjects = aTopGroup->nInternalObjects(); 
+      for ( int j = 0; j < aNbObjects; j++ ) {
+       // try to identify algorithm
+       char hypGrpName[ HDF_NAME_MAX_LEN+1 ];
+        aTopGroup->InternalObjectIndentify( j, hypGrpName );
+
+       if ( string( hypGrpName ).substr( 0, 9 ) == string( "Algorithm" ) ) {
+         // open algorithm group
+         aGroup = new HDFgroup( hypGrpName, aTopGroup ); 
+         aGroup->OpenOnDisk();
+
+         // --> get algorithm id
+         int    id = atoi( string( hypGrpName ).substr( 9 ).c_str() );
+         string hypname;
+         string libname;
+         string hypdata;
+
+         // get number of datasets
+         int aNbSubObjects = aGroup->nInternalObjects();
+         for ( int k = 0; k < aNbSubObjects; k++ ) {
+           // identify dataset
+           char name_of_subgroup[ HDF_NAME_MAX_LEN+1 ];
+           aGroup->InternalObjectIndentify( k, name_of_subgroup );
+           // --> get algorithm name
+           if ( strcmp( name_of_subgroup, "Name"  ) == 0 ) {
+             aDataset = new HDFdataset( name_of_subgroup, aGroup );
+             aDataset->OpenOnDisk();
+             size = aDataset->GetSize();
+             char* hypname_str = new char[ size ];
+             aDataset->ReadFromDisk( hypname_str );
+             hypname = string( hypname_str );
+             delete hypname_str;
+             aDataset->CloseOnDisk();
+           }
+           // --> get algorithm plugin library name
+           if ( strcmp( name_of_subgroup, "LibName"  ) == 0 ) {
+             aDataset = new HDFdataset( name_of_subgroup, aGroup );
+             aDataset->OpenOnDisk();
+             size = aDataset->GetSize();
+             char* libname_str = new char[ size ];
+             aDataset->ReadFromDisk( libname_str );
+             SCRUTE( libname_str );
+             libname = string( libname_str );
+             delete libname_str;
+             aDataset->CloseOnDisk();
+           }
+           // --> get algorithm data
+           if ( strcmp( name_of_subgroup, "Data"  ) == 0 ) {
+             aDataset = new HDFdataset( name_of_subgroup, aGroup );
+             aDataset->OpenOnDisk();
+             size = aDataset->GetSize();
+             char* hypdata_str = new char[ size ];
+             aDataset->ReadFromDisk( hypdata_str );
+             SCRUTE( hypdata_str );
+             hypdata = string( hypdata_str );
+             delete hypdata_str;
+             aDataset->CloseOnDisk();
+           }
+         }
+         // close algorithm HDF group
+         aGroup->CloseOnDisk();
+         
+         // --> restore algorithm from data
+         if ( id > 0 && !hypname.empty()/* && !hypdata.empty()*/ ) { // VSR : persistent data can be empty
+           MESSAGE("VSR - load algo : id = " << id <<
+                    ", name = " << hypname.c_str() << ", persistent string = " << hypdata.c_str());
+            SMESH::SMESH_Hypothesis_var myHyp;
+                   
+           try { // protect persistence mechanism against exceptions
+             myHyp = this->createHypothesis( hypname.c_str(), libname.c_str() );
+           }
+           catch (...) {
+             MESSAGE( "Exception during hypothesis creation" );
+           }
+           
+           SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
+           if ( myImpl ) {
+             myImpl->LoadFrom( hypdata.c_str() );
+             string iorString = GetORB()->object_to_string( myHyp );
+             int newId = myStudyContext->findId( iorString );
+             myStudyContext->mapOldToNew( id, newId );
+           }
+           else
+             MESSAGE( "VSR - SMESH_Gen::Load - can't get servant" );
           }
         }
-        fclose(loadedFile);
-        delete[] aLine;
-        aLine = 0;
-        MESSAGE("End of Algos Load");
-
       }
+      // close algorithms root HDF group
+      aTopGroup->CloseOnDisk();
+    }
 
-//***************
-// Loading of the Mesh Branch
-//***************
-      else if (string(name).substr(0,4)==string("Mesh")) {
-        MESSAGE("in mesh load");
-
-        Standard_Integer myMeshId = atoi((string(name).substr(5,5)).c_str());
-        SCRUTE(myMeshId);
+    // --> the rest groups should be meshes
+    for ( int i = 0; i < aNbGroups; i++ ) {
+      // identify next group
+      char meshName[ HDF_NAME_MAX_LEN+1 ];
+      aFile->InternalObjectIndentify( i, meshName );
+
+      if ( string( meshName ).substr( 0, 4 ) == string( "Mesh" ) ) {
+       // --> get mesh id
+       int id = atoi( string( meshName ).substr( 4 ).c_str() );
+       if ( id <= 0 )
+         continue;
+
+       bool hasData = false;
+
+       // open mesh HDF group
+       aTopGroup = new HDFgroup( meshName, aFile ); 
+       aTopGroup->OpenOnDisk();
+
+       // get number of child HDF objects
+       int aNbObjects = aTopGroup->nInternalObjects(); 
+       if ( aNbObjects > 0 ) {
+         // create mesh
+         MESSAGE( "VSR - load mesh : id = " << id );
+         SMESH::SMESH_Mesh_var myNewMesh = this->createMesh();
+         SMESH_Mesh_i* myNewMeshImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( myNewMesh ).in() );
+         if ( !myNewMeshImpl )
+           continue;
+         string iorString = GetORB()->object_to_string( myNewMesh );
+         int newId = myStudyContext->findId( iorString );
+         myStudyContext->mapOldToNew( id, newId );
+         
+         ::SMESH_Mesh& myLocMesh = myNewMeshImpl->GetImpl();
+         SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS();
+
+         // try to find mesh data dataset
+         if ( aTopGroup->ExistInternalObject( "Has data" ) ) {
+           // load mesh "has data" flag
+           aDataset = new HDFdataset( "Has data", aTopGroup );
+           aDataset->OpenOnDisk();
+           size = aDataset->GetSize();
+           char* strHasData = new char[ size ];
+           aDataset->ReadFromDisk( strHasData );
+           aDataset->CloseOnDisk();
+           if ( strcmp( strHasData, "1") == 0 ) {
+             // read mesh data from MED file
+             myReader.SetMesh( mySMESHDSMesh );
+             myReader.SetMeshId( id );
+             myReader.ReadMySelf();
+             hasData = true;
+           }
+         }
 
-       hdf_group[myMeshId] = new HDFgroup(name,hdf_file); 
-       hdf_group[myMeshId]->OpenOnDisk();
+         // try to read and set reference to shape
+         GEOM::GEOM_Shape_var aShape;
+         if ( aTopGroup->ExistInternalObject( "Ref on shape" ) ) {
+           // load mesh "Ref on shape" - it's an entry to SObject
+           aDataset = new HDFdataset( "Ref on shape", aTopGroup );
+           aDataset->OpenOnDisk();
+           size = aDataset->GetSize();
+           char* refFromFile = new char[ size ];
+           aDataset->ReadFromDisk( refFromFile );
+           aDataset->CloseOnDisk();
+           if ( strlen( refFromFile ) > 0 ) {
+             SALOMEDS::SObject_var shapeSO = myCurrentStudy->FindObjectID( refFromFile );
+
+             // Make sure GEOM data are loaded first
+             loadGeomData( shapeSO->GetFatherComponent() );
+
+             CORBA::Object_var shapeObject = SObjectToObject( shapeSO );
+             if ( !CORBA::is_nil( shapeObject ) ) {
+               aShape = GEOM::GEOM_Shape::_narrow( shapeObject );
+               if ( !aShape->_is_nil() )
+                 myNewMeshImpl->setShape( aShape );
+             }
+           }
+         }
 
-       int nb_meshsubgroup = hdf_group[myMeshId]->nInternalObjects(); 
-       SCRUTE(nb_meshsubgroup);
-             
-       //********** Loading of the file name where the data are stored
-       MESSAGE("Mesh data file");
-       strcpy(name_of_group,"Mesh data");
-       hdf_dataset[cmpt_ds]=new HDFdataset(name_of_group,hdf_group[myMeshId]);
-       hdf_dataset[cmpt_ds]->OpenOnDisk();
-       size=hdf_dataset[cmpt_ds]->GetSize();
-       
-       char * datafilename =new char[size];
-       hdf_dataset[cmpt_ds]->ReadFromDisk(datafilename);
-       hdf_dataset[cmpt_ds]->CloseOnDisk();
-       cmpt_ds++;
-             
-       //********** 
-       //}
-       //else if (strcmp(msgname,"Ref on shape")==0) {
-       //********** Loading of the reference on the shape
-       //********** and mesh initialization
-       MESSAGE("Ref on shape");
-       strcpy(name_of_group,"Ref on shape");
-       hdf_dataset[cmpt_ds] = new HDFdataset(name_of_group,hdf_group[myMeshId]);
-       hdf_dataset[cmpt_ds]->OpenOnDisk();
-       size=hdf_dataset[cmpt_ds]->GetSize();
-             
-       char * refFromFile =new char[size];
-       hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
-       hdf_dataset[cmpt_ds]->CloseOnDisk();
-       cmpt_ds++;
-             
-       Standard_CString  myRefOnShape="";   //look for ref on shape
-             
-       bool _found = false;
-       SALOMEDS::SObject_var CSO = Study->FindObjectID(refFromFile);
-       SMESH::SMESH_Mesh_var myNewMesh;
-       GEOM::GEOM_Shape_var aShape;
-             
-       if (!CORBA::is_nil(CSO)) {
-         _found = true;
-         CSO->FindAttribute(anAttr, "AttributeIOR");
-         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-         char* ShapeIOR = anIOR->Value();
-         aShape = GEOM::GEOM_Shape::_narrow(_orb->string_to_object(ShapeIOR));
+         // try to get applied hypotheses
+         if ( aTopGroup->ExistInternalObject( "Applied Hypotheses" ) ) {
+           aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup );
+           aGroup->OpenOnDisk();
+           // get number of applied hypotheses
+           int aNbSubObjects = aGroup->nInternalObjects(); 
+           MESSAGE( "VSR - number of applied hypotheses = " << aNbSubObjects );
+           for ( int j = 0; j < aNbSubObjects; j++ ) {
+             char name_dataset[ HDF_NAME_MAX_LEN+1 ];
+             aGroup->InternalObjectIndentify( j, name_dataset );
+             // check if it is a hypothesis
+             if ( string( name_dataset ).substr( 0, 3 ) == string( "Hyp" ) ) {
+               aDataset = new HDFdataset( name_dataset, aGroup );
+               aDataset->OpenOnDisk();
+               size = aDataset->GetSize();
+               char* refFromFile = new char[ size ];
+               aDataset->ReadFromDisk( refFromFile );
+               aDataset->CloseOnDisk();
+
+               // san - it is impossible to recover applied hypotheses using their entries within Load() method
                
-         myNewMesh = this->Init(myGeomEngine,studyId,aShape);
-         string iorString = _orb->object_to_string(myNewMesh);
-         sprintf(objectId,"%d",myNewMesh->GetId());
-         _SMESHCorbaObj[string("Mesh_")+string(objectId)] = iorString;
-                               
-         //********** 
-         //********** Loading of mesh data
-         if (strcmp(datafilename,"No data")!=0) {
-                 
-           med_idt fid;
-           int ret;
-           
-           //****************************************************************************
-           //*                      OUVERTURE DU FICHIER EN LECTURE                      *
-           //****************************************************************************
-                 
-           fid = MEDouvrir(datafilename,MED_LECT);
-           if (fid < 0)
-             {
-               printf(">> ERREUR : ouverture du fichier %s \n",datafilename);
-               exit(EXIT_FAILURE);
+               //SALOMEDS::SObject_var hypSO = myCurrentStudy->FindObjectID( refFromFile );
+               //CORBA::Object_var hypObject = SObjectToObject( hypSO );
+               int id = atoi( refFromFile );
+               string anIOR = myStudyContext->getIORbyOldId( id );
+               if ( !anIOR.empty() ) {
+                 CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() );
+                 if ( !CORBA::is_nil( hypObject ) ) {
+                   SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject );
+                   if ( !anHyp->_is_nil() && !aShape->_is_nil() )
+                     myNewMeshImpl->addHypothesis( aShape, anHyp );
+                 }
+               }
              }
-           else {
-                   
-             StudyContext_iStruct* myStudyContext = _mapStudyContext_i[studyId];
-             int meshId = myNewMesh->GetId();
-             SMESH_Mesh_i* meshServant = myStudyContext->mapMesh_i[meshId];
-             ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
-             SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS();
-                   
-             DriverMED_R_SMESHDS_Mesh* myReader = new DriverMED_R_SMESHDS_Mesh;
-                   
-             myReader->SetMesh(mySMESHDSMesh);
-             myReader->SetMeshId(myMeshId);
-             myReader->SetFileId(fid);
-             myReader->ReadMySelf();
-             //SCRUTE(mySMESHDSMesh->NbNodes());
-             //myNewMesh->ExportUNV("/tmp/test.unv");//only to check out
-                   
-             //****************************************************************************
-             //*                      FERMETURE DU FICHIER                                 *
-             //****************************************************************************
-             ret = MEDfermer(fid);
-                   
-             if (ret != 0)
-               printf(">> ERREUR : erreur a la fermeture du fichier %s\n",datafilename);
-                   
            }
+           aGroup->CloseOnDisk();
          }
-       }
-       //********** 
-       //}
-       //else if (strcmp(msgname,"Applied Hypothesis")==0) {
-       for (int ii=0;ii<nb_meshsubgroup;ii++) 
-         {
-           hdf_group[myMeshId]->InternalObjectIndentify(ii,msgname);
-           if (strcmp(msgname,"Mesh data")==0) {
-             //nothing
-           }
-           else if (strcmp(msgname,"Ref on shape")==0) {
-             //nothing
-           }
-           else if (strcmp(msgname,"Applied Hypothesis")==0) {
-             //********** Loading of the applied hypothesis
-             strcpy(name_of_group,"Applied Hypothesis");
-             hdf_subgroup[Tag_RefOnAppliedHypothesis] = new HDFgroup(name_of_group,hdf_group[myMeshId]);
-             hdf_subgroup[Tag_RefOnAppliedHypothesis]->OpenOnDisk();
-             
-             nb_datasets = hdf_subgroup[Tag_RefOnAppliedHypothesis]->nInternalObjects();  
-             SCRUTE(nb_datasets);
-             
-             for (int j=0;j<nb_datasets;j++) {
-               sprintf(name_dataset,"Hyp %d",j);
-               hdf_dataset[cmpt_ds] = new HDFdataset(name_dataset,hdf_subgroup[Tag_RefOnAppliedHypothesis]);
-               hdf_dataset[cmpt_ds]->OpenOnDisk();
-               size=hdf_dataset[cmpt_ds]->GetSize();
+       
+         // try to get applied algorithms
+         if ( aTopGroup->ExistInternalObject( "Applied Algorithms" ) ) {
+           aGroup = new HDFgroup( "Applied Algorithms", aTopGroup );
+           aGroup->OpenOnDisk();
+           // get number of applied algorithms
+           int aNbSubObjects = aGroup->nInternalObjects(); 
+           MESSAGE( "VSR - number of applied algos " << aNbSubObjects );
+           for ( int j = 0; j < aNbSubObjects; j++ ) {
+             char name_dataset[ HDF_NAME_MAX_LEN+1 ];
+             aGroup->InternalObjectIndentify( j, name_dataset );
+             // check if it is an algorithm
+             if ( string( name_dataset ).substr( 0, 4 ) == string( "Algo" ) ) {
+               aDataset = new HDFdataset( name_dataset, aGroup );
+               aDataset->OpenOnDisk();
+               size = aDataset->GetSize();
+               char* refFromFile = new char[ size ];
+               aDataset->ReadFromDisk( refFromFile );
+               aDataset->CloseOnDisk();
+
+               // san - it is impossible to recover applied algorithms using their entries within Load() method
                
-               char * refFromFile =new char[size];
-               hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
-               //SCRUTE(refFromFile);
-               hdf_dataset[cmpt_ds]->CloseOnDisk();
-               cmpt_ds++;
-               if (_found) {
-                 SALOMEDS::SObject_var HypSO = Study->FindObjectID(refFromFile);
-                 if (!CORBA::is_nil(HypSO)) {
-                   HypSO->FindAttribute(anAttr, "AttributeIOR");
-                   anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                   if (!CORBA::is_nil(anIOR)) {
-                     char* HypIOR = anIOR->Value();
-                     SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(HypIOR));
-                     if (!CORBA::is_nil(anHyp)) {
-                       myNewMesh->AddHypothesis(aShape,anHyp);
-                       MESSAGE("Hypothesis added ...");
-                     }
-                   }
+               //SALOMEDS::SObject_var hypSO = myCurrentStudy->FindObjectID( refFromFile );
+               //CORBA::Object_var hypObject = SObjectToObject( hypSO );
+               int id = atoi( refFromFile );
+               string anIOR = myStudyContext->getIORbyOldId( id );
+               if ( !anIOR.empty() ) {
+                 CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() );
+                 if ( !CORBA::is_nil( hypObject ) ) {
+                   SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject );
+                   if ( !anHyp->_is_nil() && !aShape->_is_nil() )
+                     myNewMeshImpl->addHypothesis( aShape, anHyp );
                  }
                }
-             } 
-             
-             hdf_subgroup[Tag_RefOnAppliedHypothesis]->CloseOnDisk();
-             //********** 
+             }
            }
-           else if (strcmp(msgname,"Applied Algorithms")==0) {
+           aGroup->CloseOnDisk();
+         }
 
-             //********** Loading of the applied algorithms 
-             strcpy(name_of_group,"Applied Algorithms");
-             hdf_subgroup[Tag_RefOnAppliedAlgorithms] = new HDFgroup(name_of_group,hdf_group[myMeshId]);
-             hdf_subgroup[Tag_RefOnAppliedAlgorithms]->OpenOnDisk();
-             
-             nb_datasets = hdf_subgroup[Tag_RefOnAppliedAlgorithms]->nInternalObjects();  
-             SCRUTE(nb_datasets);
+         // --> try to find submeshes containers for each type of submesh
+         for ( int j = GetSubMeshOnVertexTag(); j <= GetSubMeshOnCompoundTag(); j++ ) {
+           char name_meshgroup[ 30 ];
+           if ( j == GetSubMeshOnVertexTag() )
+             strcpy( name_meshgroup, "SubMeshes On Vertex" );
+           else if ( j == GetSubMeshOnEdgeTag() )
+             strcpy( name_meshgroup, "SubMeshes On Edge" );
+           else if ( j == GetSubMeshOnFaceTag() )
+             strcpy( name_meshgroup, "SubMeshes On Face" );
+           else if ( j == GetSubMeshOnSolidTag() )
+             strcpy( name_meshgroup, "SubMeshes On Solid" );
+           else if ( j == GetSubMeshOnCompoundTag() )
+             strcpy( name_meshgroup, "SubMeshes On Compound" );
+           
+           // try to get submeshes container HDF group
+           if ( aTopGroup->ExistInternalObject( name_meshgroup ) ) {
+             // open submeshes containers HDF group
+             aGroup = new HDFgroup( name_meshgroup, aTopGroup );
+             aGroup->OpenOnDisk();
              
-             for (int j=0;j<nb_datasets;j++) {
-               sprintf(name_dataset,"Algo %d",j);
-               hdf_dataset[cmpt_ds] = new HDFdataset(name_dataset,hdf_subgroup[Tag_RefOnAppliedAlgorithms]);
-               hdf_dataset[cmpt_ds]->OpenOnDisk();
-               size=hdf_dataset[cmpt_ds]->GetSize();
-               
-               char * refFromFile =new char[size];
-               hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
-               hdf_dataset[cmpt_ds]->CloseOnDisk();
-               cmpt_ds++;
-               
-               if (_found) {
-                 SALOMEDS::SObject_var AlgoSO = Study->FindObjectID(refFromFile);
-                 if (!CORBA::is_nil(AlgoSO)) {
-                   AlgoSO->FindAttribute(anAttr, "AttributeIOR");
-                   anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                   if (!CORBA::is_nil(anIOR)) {
-                     char* AlgoIOR = anIOR->Value();
-                     //SCRUTE(AlgoIOR);
-                     SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(AlgoIOR));
-                     SMESH::SMESH_Algo_var anAlgo = SMESH::SMESH_Algo::_narrow(myHyp);
-                     //SMESH::SMESH_Algo_var anAlgo = SMESH::SMESH_Algo::_narrow(_orb->string_to_object(AlgoIOR));
-                     if (!CORBA::is_nil(anAlgo)) {
-                       myNewMesh->AddHypothesis(aShape,anAlgo);//essayer avec _SMESHCorbaObj
-                       MESSAGE("Algorithms added ...");
+             // get number of submeshes
+             int aNbSubMeshes = aGroup->nInternalObjects(); 
+             for ( int k = 0; k < aNbSubMeshes; k++ ) {
+               // identify submesh
+               char name_submeshgroup[ HDF_NAME_MAX_LEN+1 ];
+               aGroup->InternalObjectIndentify( k, name_submeshgroup );
+               if ( string( name_submeshgroup ).substr( 0, 7 ) == string( "SubMesh" )  ) {
+                 // --> get submesh id
+                 int subid = atoi( string( name_submeshgroup ).substr( 7 ).c_str() );
+                 if ( subid <= 0 )
+                   continue;
+                 // open submesh HDF group
+                 aSubGroup = new HDFgroup( name_submeshgroup, aGroup );
+                 aSubGroup->OpenOnDisk();
+                 
+                 // try to read and set reference to subshape
+                 GEOM::GEOM_Shape_var     aSubShape;
+                 SMESH::SMESH_subMesh_var aSubMesh;
+                   
+                 if ( aSubGroup->ExistInternalObject( "Ref on shape" ) ) {
+                   // load submesh "Ref on shape" - it's an entry to SObject
+                   aDataset = new HDFdataset( "Ref on shape", aSubGroup );
+                   aDataset->OpenOnDisk();
+                   size = aDataset->GetSize();
+                   char* refFromFile = new char[ size ];
+                   aDataset->ReadFromDisk( refFromFile );
+                   aDataset->CloseOnDisk();
+                   if ( strlen( refFromFile ) > 0 ) {
+                     SALOMEDS::SObject_var subShapeSO = myCurrentStudy->FindObjectID( refFromFile );
+                     CORBA::Object_var subShapeObject = SObjectToObject( subShapeSO );
+                     if ( !CORBA::is_nil( subShapeObject ) ) {
+                       aSubShape = GEOM::GEOM_Shape::_narrow( subShapeObject );
+                       if ( !aSubShape->_is_nil() )
+                         aSubMesh = SMESH::SMESH_subMesh::_duplicate
+                            ( myNewMeshImpl->createSubMesh( aSubShape ) );
+                       if ( aSubMesh->_is_nil() )
+                         continue;
+                       string iorSubString = GetORB()->object_to_string( aSubMesh );
+                       int newSubId = myStudyContext->findId( iorSubString );
+                       myStudyContext->mapOldToNew( subid, newSubId );
                      }
                    }
                  }
-               }
-             } 
-             
-             hdf_subgroup[Tag_RefOnAppliedAlgorithms]->CloseOnDisk();
-             //********** 
-           }
-           else if (string(msgname).substr(0,9)==string("SubMeshes")) {
-             
-             
-             //********** Loading of the submeshes on subshapes
-             int myLevel1Tag, myTag;
-             SCRUTE(msgname);
-             cmpt_sm++;
-             myLevel1Tag = 10+cmpt_sm;
-             hdf_subgroup[myLevel1Tag] = new HDFgroup(name_of_group,hdf_group[myMeshId]);
-             hdf_subgroup[myLevel1Tag] = new HDFgroup(msgname,hdf_group[myMeshId]);
-             hdf_subgroup[myLevel1Tag]->OpenOnDisk();
-       
-             int nb_submeshes = hdf_subgroup[myLevel1Tag]->nInternalObjects();  
-             SCRUTE(nb_submeshes);
-
-             for (int j=0;j<nb_submeshes;j++) {
-               cmpt_sm++;
-               myTag = 10+cmpt_sm;
-               hdf_subgroup[myLevel1Tag]->InternalObjectIndentify(j,name_meshgroup);
-               SCRUTE(name_meshgroup);
-
-               hdf_subgroup[myTag] = new HDFgroup(name_meshgroup,hdf_subgroup[myLevel1Tag]);
-               hdf_subgroup[myTag]->OpenOnDisk();
-               int subMeshId = atoi((string(name_meshgroup).substr(8,18)).c_str());
-               
-               MESSAGE("Ref on shape");
-               //********** ref on shape
-               sprintf(name_dataset,"Ref on shape");
-               hdf_dataset[cmpt_ds] = new HDFdataset(name_dataset,hdf_subgroup[myTag]);
-               hdf_dataset[cmpt_ds]->OpenOnDisk();
-               size=hdf_dataset[cmpt_ds]->GetSize();
-               
-               char * refFromFile =new char[size];
-               hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
-               hdf_dataset[cmpt_ds]->CloseOnDisk();
-               cmpt_ds++;
-               
-               bool _found3 = false;
-               SALOMEDS::SObject_var GSO = Study->FindObjectID(refFromFile);
-               SMESH::SMESH_subMesh_var aSubMesh;
-               GEOM::GEOM_Shape_var aSubShape;
-               
-               if (!CORBA::is_nil(GSO)) {
-                 GSO->FindAttribute(anAttr, "AttributeIOR");
-                 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                 char* SubShapeIOR = anIOR->Value();
-                 aSubShape = GEOM::GEOM_Shape::_narrow(_orb->string_to_object(SubShapeIOR));
                  
-                 if (!CORBA::is_nil(aSubShape)) {
-                   aSubMesh = myNewMesh->GetElementsOnShape(aSubShape);
-                   string iorString = _orb->object_to_string(aSubMesh);
-                   sprintf(objectId,"%d",subMeshId);
-                   _SMESHCorbaObj[string("SubMesh_")+string(objectId)] = iorString;
-                   _found3 = true;
-                   //SCRUTE(aSubMesh->GetNumberOfNodes());
-                   //MESSAGE("yes");
-                   //SCRUTE(aSubMesh->GetNumberOfElements());
-                 }
-               }
+                 if ( aSubMesh->_is_nil() )
+                   continue;
+
+                 // VSR: Get submesh data from MED convertor
+//               int anInternalSubmeshId = aSubMesh->GetId(); // this is not a persistent ID, it's an internal one computed from sub-shape
+//               if (myNewMeshImpl->_mapSubMesh.find(anInternalSubmeshId) != myNewMeshImpl->_mapSubMesh.end()) {
+//                 MESSAGE("VSR - SMESH_Gen_i::Load(): loading from MED file submesh with ID = " <<
+//                            subid << " for subshape # " << anInternalSubmeshId);
+//                 SMESHDS_SubMesh* aSubMeshDS =
+//                      myNewMeshImpl->_mapSubMesh[anInternalSubmeshId]->CreateSubMeshDS();
+//                 if ( !aSubMeshDS ) {
+//                   MESSAGE("VSR - SMESH_Gen_i::Load(): FAILED to create a submesh for subshape # " <<
+//                              anInternalSubmeshId << " in current mesh!");
+//                 }
+//                 else
+//                   myReader.GetSubMesh( aSubMeshDS, subid );
+//               }
                    
-               int nb_subgroup = hdf_subgroup[myTag]->nInternalObjects(); 
-               SCRUTE(nb_subgroup);
-               for (int k=0;k<nb_subgroup;k++) 
-                 {
-                   hdf_subgroup[myTag]->InternalObjectIndentify(k,sgname);
-                   if (strcmp(sgname,"Ref on shape")==0) {
-                     //nothing
-                   }
-                   else if (strcmp(sgname,"Applied Hypothesis")==0) {
-                     //********** ref on applied hypothesis
-                     MESSAGE("Applied Hypothesis");
-                     strcpy(name_meshgroup,"Applied Hypothesis");
-                     cmpt_sm++;
-                     hdf_subgroup[10+cmpt_sm] = new HDFgroup(name_meshgroup,hdf_subgroup[myTag]);
-                     hdf_subgroup[10+cmpt_sm]->OpenOnDisk();
-                     nb_datasets = hdf_subgroup[10+cmpt_sm]->nInternalObjects();  
-                     SCRUTE(nb_datasets);
-                     
-                     for (int l=0;l<nb_datasets;l++) {
-                       sprintf(name_dataset,"Hyp %d",l);
-                       hdf_dataset[cmpt_ds] = new HDFdataset(name_dataset,hdf_subgroup[10+cmpt_sm]);
-                       hdf_dataset[cmpt_ds]->OpenOnDisk();
-                       size=hdf_dataset[cmpt_ds]->GetSize();
+                 // try to get applied hypotheses
+                 if ( aSubGroup->ExistInternalObject( "Applied Hypotheses" ) ) {
+                   // open "applied hypotheses" HDF group
+                   aSubSubGroup = new HDFgroup( "Applied Hypotheses", aSubGroup );
+                   aSubSubGroup->OpenOnDisk();
+                   // get number of applied hypotheses
+                   int aNbSubObjects = aSubSubGroup->nInternalObjects(); 
+                   for ( int l = 0; l < aNbSubObjects; l++ ) {
+                     char name_dataset[ HDF_NAME_MAX_LEN+1 ];
+                     aSubSubGroup->InternalObjectIndentify( l, name_dataset );
+                     // check if it is a hypothesis
+                     if ( string( name_dataset ).substr( 0, 3 ) == string( "Hyp" ) ) {
+                       aDataset = new HDFdataset( name_dataset, aSubSubGroup );
+                       aDataset->OpenOnDisk();
+                       size = aDataset->GetSize();
+                       char* refFromFile = new char[ size ];
+                       aDataset->ReadFromDisk( refFromFile );
+                       aDataset->CloseOnDisk();
                        
-                       char * refFromFile =new char[size];
-                       hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
-                       hdf_dataset[cmpt_ds]->CloseOnDisk();
-                       cmpt_ds++;
-                       
-                       if (_found3) {
-                         SALOMEDS::SObject_var HypSO = Study->FindObjectID(refFromFile);
-                         if (!CORBA::is_nil(HypSO)) {
-                           HypSO->FindAttribute(anAttr, "AttributeIOR");
-                           anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                           if (!CORBA::is_nil(anIOR)) {
-                             char* HypIOR = anIOR->Value();
-                             SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(HypIOR));
-                             if (!CORBA::is_nil(anHyp)) {
-                               SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
-                               aMesh->AddHypothesis(aSubShape,anHyp);//essayer avec _SMESHCorbaObj
-                               MESSAGE("Hypothesis added ...");
-                             }
-                           }
+                       //SALOMEDS::SObject_var hypSO = myCurrentStudy->FindObjectID( refFromFile );
+                       //CORBA::Object_var hypObject = SObjectToObject( hypSO );
+                       int id = atoi( refFromFile );
+                       string anIOR = myStudyContext->getIORbyOldId( id );
+                       if ( !anIOR.empty() ) {
+                         CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() );
+                         if ( !CORBA::is_nil( hypObject ) ) {
+                           SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject );
+                           if ( !anHyp->_is_nil() && !aShape->_is_nil() )
+                             myNewMeshImpl->addHypothesis( aSubShape, anHyp );
                          }
                        }
-                     } 
+                     }
                    }
-                   else if (strcmp(sgname,"Applied Algorithms")==0) {
-                     //********** ref on applied algorithms
-                     MESSAGE("Applied Algorithms");
-                     strcpy(name_meshgroup,"Applied Algorithms");
-                     cmpt_sm++;
-                     hdf_subgroup[10+cmpt_sm] = new HDFgroup(name_meshgroup,hdf_subgroup[myTag]);
-                     hdf_subgroup[10+cmpt_sm]->OpenOnDisk();
-                     nb_datasets = hdf_subgroup[10+cmpt_sm]->nInternalObjects();  
-                     SCRUTE(nb_datasets);
-                     
-                     for (int l=0;l<nb_datasets;l++) {
-                       sprintf(name_dataset,"Algo %d",l);
-                       hdf_dataset[cmpt_ds] = new HDFdataset(name_dataset,hdf_subgroup[10+cmpt_sm]);
-                       hdf_dataset[cmpt_ds]->OpenOnDisk();
-                       size=hdf_dataset[cmpt_ds]->GetSize();
-                       
-                       char * refFromFile =new char[size];
-                       hdf_dataset[cmpt_ds]->ReadFromDisk(refFromFile);
-                       hdf_dataset[cmpt_ds]->CloseOnDisk();
-                       cmpt_ds++;
-                       
-                       if (_found3) {
-                         SALOMEDS::SObject_var AlgoSO = Study->FindObjectID(refFromFile);
-                         if (!CORBA::is_nil(AlgoSO)) {
-                           AlgoSO->FindAttribute(anAttr, "AttributeIOR");
-                           anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-                           if (!CORBA::is_nil(anIOR)) {
-                             char* AlgoIOR = anIOR->Value();
-                             //SCRUTE(AlgoIOR);
-                             SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(AlgoIOR));
-                             SMESH::SMESH_Algo_var anAlgo = SMESH::SMESH_Algo::_narrow(myHyp);
-                             //SMESH::SMESH_Algo_var anAlgo = SMESH::SMESH_Algo::_narrow(_orb->string_to_object(AlgoIOR));
-                             if (!CORBA::is_nil(anAlgo)) {
-                               SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
-                               aMesh->AddHypothesis(aSubShape,anAlgo);//essayer avec _SMESHCorbaObj
-                               MESSAGE("Algorithms added ...");
-                             }
-                           }
+                   // close "applied hypotheses" HDF group
+                   aSubSubGroup->CloseOnDisk();
+                 }
+       
+                 // try to get applied algorithms
+                 if ( aSubGroup->ExistInternalObject( "Applied Algorithms" ) ) {
+                   // open "applied algorithms" HDF group
+                   aSubSubGroup = new HDFgroup( "Applied Algorithms", aSubGroup );
+                   aSubSubGroup->OpenOnDisk();
+                   // get number of applied algorithms
+                   int aNbSubObjects = aSubSubGroup->nInternalObjects(); 
+                   for ( int l = 0; l < aNbSubObjects; l++ ) {
+                     char name_dataset[ HDF_NAME_MAX_LEN+1 ];
+                     aSubSubGroup->InternalObjectIndentify( l, name_dataset );
+                     // check if it is an algorithm
+                     if ( string( name_dataset ).substr( 0, 4 ) == string( "Algo" ) ) {
+                       aDataset = new HDFdataset( name_dataset, aSubSubGroup );
+                       aDataset->OpenOnDisk();
+                       size = aDataset->GetSize();
+                       char* refFromFile = new char[ size ];
+                       aDataset->ReadFromDisk( refFromFile );
+                       aDataset->CloseOnDisk();
+
+                       //SALOMEDS::SObject_var hypSO = myCurrentStudy->FindObjectID( refFromFile );
+                       //CORBA::Object_var hypObject = SObjectToObject( hypSO );
+                       int id = atoi( refFromFile );
+                       string anIOR = myStudyContext->getIORbyOldId( id );
+                       if ( !anIOR.empty() ) {
+                         CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() );
+                         if ( !CORBA::is_nil( hypObject ) ) {
+                           SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject );
+                           if ( !anHyp->_is_nil() && !aShape->_is_nil() )
+                             myNewMeshImpl->addHypothesis( aSubShape, anHyp );
                          }
                        }
-                       
-                     } 
+                     }
                    }
+                   // close "applied algorithms" HDF group
+                   aSubSubGroup->CloseOnDisk();
                  }
-               hdf_subgroup[myTag]->CloseOnDisk();
+                 
+                 // close submesh HDF group
+                 aSubGroup->CloseOnDisk();
+               }
              }
-             hdf_subgroup[myLevel1Tag]->CloseOnDisk();
+             // close submeshes containers HDF group
+             aGroup->CloseOnDisk();
            }
          }
-       hdf_group[myMeshId]->CloseOnDisk();     
-       
-       MESSAGE("End of Meshes Load");
+
+         if(hasData){
+           // Read sub-meshes from MED
+           MESSAGE("JFA - Create all sub-meshes");
+           myReader.CreateAllSubMeshes();
+         }
+
+          // Recompute State (as computed sub-meshes are restored from MED)
+         if ( !aShape->_is_nil() ) {
+           MESSAGE("JFA - Compute State Engine ...");
+//          map<int, ::SMESH_subMesh*>::iterator anAllSubMeshes = myNewMeshImpl->_mapSubMesh.begin();
+//          for (; anAllSubMeshes != myNewMeshImpl->_mapSubMesh.end(); anAllSubMeshes++)
+//          {
+//            (*anAllSubMeshes).second->GetSubMeshDS(); // init SMESH_subMesh::_meshDS
+//            (*anAllSubMeshes).second->ComputeStateEngine(SMESH_subMesh::SUBMESH_RESTORED);
+//          }
+           TopoDS_Shape myLocShape = GetShapeReader()->GetShape( GetGeomEngine(), aShape );
+           myNewMeshImpl->GetImpl().GetSubMesh(myLocShape)->ComputeStateEngine(SMESH_subMesh::SUBMESH_RESTORED);
+           MESSAGE("JFA - Compute State Engine finished");
+         }
+
+         // try to get groups
+         for ( int ii = GetNodeGroupsTag(); ii <= GetVolumeGroupsTag(); ii++ ) {
+           char name_group[ 30 ];
+           if ( ii == GetNodeGroupsTag() )
+             strcpy( name_group, "Groups of Nodes" );
+           else if ( ii == GetEdgeGroupsTag() )
+             strcpy( name_group, "Groups of Edges" );
+           else if ( ii == GetFaceGroupsTag() )
+             strcpy( name_group, "Groups of Faces" );
+           else if ( ii == GetVolumeGroupsTag() )
+             strcpy( name_group, "Groups of Volumes" );
+
+           if ( aTopGroup->ExistInternalObject( name_group ) ) {
+             aGroup = new HDFgroup( name_group, aTopGroup );
+             aGroup->OpenOnDisk();
+             // get number of groups
+             int aNbSubObjects = aGroup->nInternalObjects(); 
+             for ( int j = 0; j < aNbSubObjects; j++ ) {
+               char name_dataset[ HDF_NAME_MAX_LEN+1 ];
+               aGroup->InternalObjectIndentify( j, name_dataset );
+               // check if it is an group
+               if ( string( name_dataset ).substr( 0, 5 ) == string( "Group" ) ) {
+                 // --> get group id
+                 int subid = atoi( string( name_dataset ).substr( 5 ).c_str() );
+                 if ( subid <= 0 )
+                   continue;
+                 aDataset = new HDFdataset( name_dataset, aGroup );
+                 aDataset->OpenOnDisk();
+
+                 // Retrieve actual group name
+                 size = aDataset->GetSize();
+                 char* nameFromFile = new char[ size ];
+                 aDataset->ReadFromDisk( nameFromFile );
+                 aDataset->CloseOnDisk();
+                 
+                 // Create group servant
+                 SMESH::SMESH_Group_var aNewGroup = SMESH::SMESH_Group::_duplicate
+                    ( myNewMeshImpl->createGroup( (SMESH::ElementType)(ii - GetNodeGroupsTag() + 1),
+                                                 nameFromFile ) );
+                 // Obtain a SMESHDS_Group object 
+                 if ( aNewGroup->_is_nil() )
+                   continue;
+
+                 string iorSubString = GetORB()->object_to_string( aNewGroup );
+                 int newSubId = myStudyContext->findId( iorSubString );
+                 myStudyContext->mapOldToNew( subid, newSubId );
+
+                 SMESH_Group_i* aGroupImpl = dynamic_cast<SMESH_Group_i*>( GetServant( aNewGroup ).in() );
+                 if ( !aGroupImpl )
+                   continue;
+
+                 SMESH_Group* aLocalGroup  = myLocMesh.GetGroup( aGroupImpl->GetLocalID() );
+                 if ( !aLocalGroup )
+                   continue;
+
+                 SMESHDS_Group* aGroupDS = aLocalGroup->GetGroupDS();
+                 aGroupDS->SetStoreName( name_dataset );
+
+                 // Fill group with contents from MED file
+                 myReader.GetGroup( aGroupDS );
+               }
+             }
+             aGroup->CloseOnDisk();
+           }
+         }
+       }
+       // close mesh group
+       aTopGroup->CloseOnDisk();       
       }
     }
-  
-  MESSAGE("End of SMESH_Gen::Load");
-  
-  hdf_file->CloseOnDisk();
-  delete  hdf_file;
-  hdf_file=0;
+  }
+  // close HDF file
+  aFile->CloseOnDisk();
+  delete aFile;
 
   // Remove temporary files created from the stream
-  if (isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.ToCString(), aFileSeq.in(), true);
+  if ( !isMultiFile ) 
+    SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq.in(), true );
 
+  INFOS( "SMESH_Gen_i::Load completed" );
   return true;
 }
 
-bool SMESH_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
-                           const SALOMEDS::TMPFile& theStream,
-                           const char* theURL,
-                           bool isMultiFile) {
-  return Load(theComponent, theStream, theURL, isMultiFile);
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::LoadASCII
+ *
+ *  Load SMESH module's data in ASCII format (not implemented yet)
+ */
+//=============================================================================
+
+bool SMESH_Gen_i::LoadASCII( SALOMEDS::SComponent_ptr theComponent,
+                            const SALOMEDS::TMPFile& theStream,
+                            const char*              theURL,
+                            bool                     isMultiFile ) {
+  MESSAGE( "SMESH_Gen_i::LoadASCII" );
+  return Load( theComponent, theStream, theURL, isMultiFile );
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::Close
+ *
+ *  Clears study-connected data when it is closed
  */
 //=============================================================================
 
-void SMESH_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
+void SMESH_Gen_i::Close( SALOMEDS::SComponent_ptr theComponent )
 {
-  MESSAGE("Close");
-  SALOMEDS::Study_var aStudy = theComponent->GetStudy();
-  SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
-  for (; itBig->More();itBig->Next()) {
-    SALOMEDS::SObject_var gotBranch = itBig->Value();
-    
-    // branch 1 : hypothesis
-    if (gotBranch->Tag()==Tag_HypothesisRoot || gotBranch->Tag()==Tag_AlgorithmsRoot) {
-      SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(gotBranch);
-      for (; it->More();it->Next()) {
-       SALOMEDS::SObject_var mySObject = it->Value();
-       SALOMEDS::GenericAttribute_var anAttr;
-       SALOMEDS::AttributeIOR_var anIOR;
-       if ( mySObject->FindAttribute(anAttr, "AttributeIOR")) {
-         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-         SMESH::SMESH_Hypothesis_var myHyp =
-           SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(anIOR->Value()));
-         char objectId[10];
-         sprintf(objectId,"%d",myHyp->GetId());
-//       cout<<"********** delete Hyp "<<objectId<<endl;
-         _SMESHCorbaObj.erase(string("Hypo_")+string(objectId));
-         myHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(anIOR->Value()));
-       }
-      }
-    }
-    // branch 2 : algorithms
-    else if (gotBranch->Tag()>=3) {
-      SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(gotBranch);
-      for (; it->More();it->Next()) {
-       SALOMEDS::SObject_var mySObject = it->Value();
-       SALOMEDS::GenericAttribute_var anAttr;
-       SALOMEDS::AttributeIOR_var anIOR;
-       if ( mySObject->FindAttribute(anAttr, "AttributeIOR")) {
-         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-         SMESH::SMESH_Mesh_var myMesh =
-           SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value()));
-         if (!myMesh->_is_nil()) {
-           char objectId[10];
-           sprintf(objectId,"%d",myMesh->GetId());
-//         cout<<"********** delete Mesh "<<objectId<<endl;
-           _SMESHCorbaObj.erase(string("Mesh_")+string(objectId));
-           CORBA::release(myMesh);
-         }
-         else {
-           SMESH::SMESH_subMesh_var mySubMesh =
-             SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->Value()));
-           if (!mySubMesh->_is_nil()) {
-             char objectId[10];
-             sprintf(objectId,"%d",mySubMesh->GetId());
-//           cout<<"********** delete SubMesh "<<objectId<<endl;
-             _SMESHCorbaObj.erase(string("SubMesh_")+string(objectId));
-             CORBA::release(mySubMesh);
-           }
-         }
-       }
-      }
-    }
+  MESSAGE( "SMESH_Gen_i::Close" );
+
+  // Clear study contexts data
+  int studyId = myCurrentStudy->StudyId();
+  if ( myStudyContextMap.find( studyId ) != myStudyContextMap.end() ) {
+    delete myStudyContextMap[ studyId ];
+    myStudyContextMap.erase( studyId );
   }
+  return;
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::ComponentDataType
+ * 
+ *  Get component data type
  */
 //=============================================================================
 
 char* SMESH_Gen_i::ComponentDataType()
 {
-  MESSAGE("SMESH_Gen_i::ComponentDataType");
-  return strdup("SMESH");
+  MESSAGE( "SMESH_Gen_i::ComponentDataType" );
+  return strdup( "SMESH" );
 }
 
     
 //=============================================================================
 /*!
+ *  SMESH_Gen_i::IORToLocalPersistentID
  *  
+ *  Transform data from transient form to persistent
  */
 //=============================================================================
 
-char* SMESH_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
-                                         const char* IORString,
-                                         CORBA::Boolean isMultiFile,
-                                         CORBA::Boolean isASCII)
+char* SMESH_Gen_i::IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject,
+                                          const char*           IORString,
+                                          CORBA::Boolean        isMultiFile,
+                                          CORBA::Boolean        isASCII )
 {
-  MESSAGE("SMESH_Gen_i::IORToLocalPersistentID");
+  MESSAGE( "SMESH_Gen_i::IORToLocalPersistentID" );
+  StudyContext* myStudyContext = GetCurrentStudyContext();
+  
+  if ( strcmp( IORString, "" ) != 0 ) {
+    int anId = myStudyContext->findId( IORString );
+    if ( anId ) {
+      MESSAGE( "VSR " << anId )
+      char strId[ 20 ];
+      sprintf( strId, "%d", anId );
+      return  CORBA::string_dup( strId );
+    }
+  }
+  return strdup( "" );
+}
 
-  char objectId[10];
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::LocalPersistentIDToIOR
+ *
+ *  Transform data from persistent form to transient
+ */
+//=============================================================================
 
-  SMESH::SMESH_Algo_var myAlgo = SMESH::SMESH_Algo::_narrow(_orb->string_to_object(IORString));
-  if (! CORBA::is_nil(myAlgo))
-    {
-      string prefix = "Hypo_";
-      sprintf(objectId,"%d",myAlgo->GetId());
-      string lpID = prefix + string(objectId);
-      return CORBA::string_dup(lpID.c_str());
-    }
-  else {
-    SMESH::SMESH_Hypothesis_var myHypo = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(IORString));
-    if (! CORBA::is_nil(myHypo))
-      {
-        string prefix = "Hypo_";
-        sprintf(objectId,"%d",myHypo->GetId());
-        string lpID = prefix + string(objectId);
-        return CORBA::string_dup(lpID.c_str());
-      }
-    else {
-      SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(IORString));
-      if (! CORBA::is_nil(myMesh))
-       {
-         string prefix = "Mesh_";
-         sprintf(objectId,"%d",myMesh->GetId());
-         string lpID = prefix + string(objectId);
-         return CORBA::string_dup(lpID.c_str());
-       }
-      else {
-       SMESH::SMESH_subMesh_var mySubMesh = SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(IORString));
-       if (! CORBA::is_nil(mySubMesh))
-         {
-           string prefix = "SubMesh_";
-           sprintf(objectId,"%d",mySubMesh->GetId());
-           string lpID = prefix + string(objectId);
-           return CORBA::string_dup(lpID.c_str());
-         }
-       else return (strdup("no object"));
-      }
-    }
+char* SMESH_Gen_i::LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject,
+                                          const char*           aLocalPersistentID,
+                                          CORBA::Boolean        isMultiFile,
+                                          CORBA::Boolean        isASCII )
+{
+  MESSAGE( "SMESH_Gen_i::LocalPersistentIDToIOR(): id = " << aLocalPersistentID );
+  StudyContext* myStudyContext = GetCurrentStudyContext();
+
+  if ( strcmp( aLocalPersistentID, "" ) != 0 ) {
+    int anId = atoi( aLocalPersistentID );
+    return CORBA::string_dup( myStudyContext->getIORbyOldId( anId ).c_str() );
   }
+  return strdup( "" );
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::CanPublishInStudy
+ *
+ *  Returns true if object can be published in the study
  */
 //=============================================================================
 
-char* SMESH_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
-                                         const char* aLocalPersistentID,
-                                         CORBA::Boolean isMultiFile,
-                                         CORBA::Boolean isASCII)
+bool SMESH_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
 {
-  MESSAGE("SMESH_Gen_i::LocalPersistentIDToIOR");
-  SCRUTE(aLocalPersistentID);
-  string clef = string(aLocalPersistentID);
-  SCRUTE(_SMESHCorbaObj[clef].c_str());
-  return CORBA::string_dup(_SMESHCorbaObj[clef].c_str());
+  SMESH::SMESH_Mesh_var aMesh       = SMESH::SMESH_Mesh::_narrow(theIOR);
+  if( !aMesh->_is_nil() )
+    return true;
+
+  SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(theIOR);
+  if( !aSubMesh->_is_nil() )
+    return true;
+
+  SMESH::SMESH_Hypothesis_var aHyp  = SMESH::SMESH_Hypothesis::_narrow(theIOR);
+  if( !aHyp->_is_nil() )
+    return true;
+
+  SMESH::SMESH_Group_var aGroup     = SMESH::SMESH_Group::_narrow(theIOR);
+  if( !aGroup->_is_nil() )
+    return true;
+
+  return false;
 }
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Gen_i::PublishInStudy
+ *
+ *  Publish object in the study
  */
 //=============================================================================
 
-SMESH_topo* SMESH_Gen_i::ExploreMainShape(GEOM::GEOM_Gen_ptr geomEngine,
-                                          CORBA::Long studyId,
-                                          GEOM::GEOM_Shape_ptr aShape)
+SALOMEDS::SObject_ptr SMESH_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
+                                                 SALOMEDS::SObject_ptr theSObject,
+                                                 CORBA::Object_ptr theIOR,
+                                                 const char* theName) 
+throw (SALOME::SALOME_Exception)
 {
-  MESSAGE("SMESH_Mesh_i::ExploreMainShape");
-  // _narrow() duplicates the reference and check the type
-  GEOM::GEOM_Gen_var geom = GEOM::GEOM_Gen::_narrow(geomEngine);
-  GEOM::GEOM_Shape_var myShape = GEOM::GEOM_Shape::_narrow(aShape);
-
-  if (CORBA::is_nil(geom))
-    THROW_SALOME_CORBA_EXCEPTION("bad geom reference", \
-                                 SALOME::BAD_PARAM);
-  if (CORBA::is_nil(myShape))
-    THROW_SALOME_CORBA_EXCEPTION("bad shape reference", \
-                                 SALOME::BAD_PARAM);
-  MESSAGE("---");
-  SCRUTE(myShape->Name());
-  geom->GetCurrentStudy(studyId);
-  SCRUTE(studyId);
-  TopoDS_Shape mainShape  = _ShapeReader->GetShape(geom,myShape);
-  MESSAGE("---");
-
-  // create an SMESH_topo object for the mainShape
-
-  SMESH_topo* myTopo = new SMESH_topo();
-  MESSAGE("---");
-
-  // explore local TopoDS_Shape, store reference of local TopoDS subShapes
-
-  for (TopExp_Explorer exp(mainShape,TopAbs_COMPOUND); exp.More(); exp.Next())
-    {
-      const TopoDS_Compound& E = TopoDS::Compound(exp.Current());
-      int i = myTopo->_myShapes[TopAbs_COMPOUND].Add(E);
-      SCRUTE(i);
-    }
-  for (TopExp_Explorer exp(mainShape,TopAbs_COMPSOLID); exp.More(); exp.Next())
-    {
-      const TopoDS_CompSolid& E = TopoDS::CompSolid(exp.Current());
-      int i = myTopo->_myShapes[TopAbs_COMPSOLID].Add(E);
-      SCRUTE(i);
-    }
-  for (TopExp_Explorer exp(mainShape,TopAbs_SOLID); exp.More(); exp.Next())
-    {
-      const TopoDS_Solid& E = TopoDS::Solid(exp.Current());
-      int i = myTopo->_myShapes[TopAbs_SOLID].Add(E);
-      SCRUTE(i);
-    }
-  for (TopExp_Explorer exp(mainShape,TopAbs_SHELL); exp.More(); exp.Next())
-    {
-      const TopoDS_Shell& E = TopoDS::Shell(exp.Current());
-      int i = myTopo->_myShapes[TopAbs_SHELL].Add(E);
-      SCRUTE(i);
-    }
-  for (TopExp_Explorer exp(mainShape,TopAbs_FACE); exp.More(); exp.Next())
-    {
-      const TopoDS_Face& E = TopoDS::Face(exp.Current());
-      int i = myTopo->_myShapes[TopAbs_FACE].Add(E);
-      SCRUTE(i);
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE( "********** SMESH_Gen_i::PublishInStudy()" );
+  SALOMEDS::SObject_var aSO;
+
+  // san - first try to find SObject corresponding to SMESH component in theStudy
+  // It is dangerous to use FindComponent("MESH") for this, as some other component
+  // of type "MESH" might be present in theStudy.
+  // So component's user name obtained from ModuleCatalog is passed to FindObject()...
+  SALOME_ModuleCatalog::ModuleCatalog_var aCat =
+    SALOME_ModuleCatalog::ModuleCatalog::_narrow( GetNS()->Resolve("/Kernel/ModulCatalog") );
+  if ( CORBA::is_nil( aCat ) )
+    return aSO._retn();
+
+  SALOME_ModuleCatalog::Acomponent_var   aComp = aCat->GetComponent( "SMESH" );
+  if ( CORBA::is_nil( aComp ) )
+    return aSO._retn();
+
+  SALOMEDS::SComponent_var father =
+    SALOMEDS::SComponent::_narrow( theStudy->FindObject( strdup( aComp->componentusername() ) ) );
+  SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); 
+
+  SALOMEDS::GenericAttribute_var anAttr;
+  SALOMEDS::AttributeName_var    aName;
+  SALOMEDS::AttributePixMap_var  aPixmap;
+  
+  if ( father->_is_nil() ) {
+    father  = aStudyBuilder->NewComponent( "MESH" );
+    anAttr  = aStudyBuilder->FindOrCreateAttribute( father, "AttributeName" );
+    aName   = SALOMEDS::AttributeName::_narrow( anAttr );
+    aName   ->SetValue( strdup( aComp->componentusername() ) );
+    anAttr  = aStudyBuilder->FindOrCreateAttribute( father, "AttributePixMap" );
+    aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
+    aPixmap ->SetPixMap( "ICON_OBJBROWSER_SMESH" );
+    aStudyBuilder->DefineComponentInstance( father, SMESH_Gen::_this() );
+  }
+
+  if ( father->_is_nil() )  
+    return aSO._retn();
+
+  SALOMEDS::AttributeIOR_var        anIOR;
+  SALOMEDS::AttributeSelectable_var aSelAttr;
+  TCollection_AsciiString anObjName("obj");
+
+  // Publishing a mesh
+  SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( theIOR );
+  if( !aMesh->_is_nil() ) {
+    // Find correct free tag
+    long aTag = FindMaxChildTag( father.in() );
+    if ( aTag <= GetAlgorithmsRootTag() )
+      aTag = GetAlgorithmsRootTag() + 1;
+    else
+      aTag++;
+    // Add New Mesh
+    SALOMEDS::SObject_var newMesh = aStudyBuilder->NewObjectToTag( father, aTag );
+    anAttr  = aStudyBuilder->FindOrCreateAttribute( newMesh, "AttributePixMap" );
+    aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
+    aPixmap ->SetPixMap( "ICON_SMESH_TREE_MESH" );
+    anAttr  = aStudyBuilder->FindOrCreateAttribute( newMesh, "AttributeIOR" );
+    anIOR   = SALOMEDS::AttributeIOR::_narrow(anAttr);
+    anIOR   ->SetValue( GetORB()->object_to_string( aMesh ) );
+    aSO     = SALOMEDS::SObject::_narrow( newMesh );
+    anObjName = TCollection_AsciiString( "Mesh" );
+  }
+
+  // Publishing a sub-mesh
+  SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( theIOR );
+  if( aSO->_is_nil() && !aSubMesh->_is_nil() ) {
+    // try to obtain a parent mesh's SObject
+    MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing submesh..." );
+    SALOMEDS::SObject_var aParentSO;
+    SMESH::SMESH_Mesh_var aParentMesh;
+    SMESH_subMesh_i* aServant = dynamic_cast<SMESH_subMesh_i*>( GetServant( aSubMesh ).in() );
+    if ( aServant != NULL ) {
+      aParentMesh = aServant->_mesh_i->_this();
+      if ( !aParentMesh->_is_nil() ) {
+       aParentSO = theStudy->FindObjectIOR( GetORB()->object_to_string( aParentMesh ) );
+      }
     }
-  for (TopExp_Explorer exp(mainShape,TopAbs_WIRE); exp.More(); exp.Next())
-    {
-      const TopoDS_Wire& E = TopoDS::Wire(exp.Current());
-      int i = myTopo->_myShapes[TopAbs_WIRE].Add(E);
-      SCRUTE(i);
+
+    // Find submesh sub-tree tag
+    if ( !aParentSO->_is_nil() ) {
+      long aRootTag = GetSubMeshOnVertexTag();
+      char* aRootName = "";
+
+      SMESH_Mesh_i* aMeshServant = aServant->_mesh_i;
+      if ( aMeshServant->_mapSubMesh.find( aServant->GetId() ) != aMeshServant->_mapSubMesh.end() ) {
+       MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): local submesh found" )
+       SMESH_subMesh* aLocalSubMesh = aMeshServant->_mapSubMesh[aServant->GetId()];
+       switch ( aLocalSubMesh->GetSubShape().ShapeType() ) {
+       case TopAbs_VERTEX:
+         aRootTag  = GetSubMeshOnVertexTag();
+         aRootName = "SubMeshes on Vertex";
+         break;
+       case TopAbs_EDGE:
+         aRootTag  = GetSubMeshOnEdgeTag();
+         aRootName = "SubMeshes on Edge";        
+         break;
+       case TopAbs_FACE:
+         aRootTag  = GetSubMeshOnFaceTag();
+         aRootName = "SubMeshes on Face";        
+         break;
+       case TopAbs_SOLID:
+         aRootTag  = GetSubMeshOnSolidTag();
+         aRootName = "SubMeshes on Solid";
+         break;
+       default:
+         aRootTag  = GetSubMeshOnCompoundTag();
+         aRootName = "SubMeshes on Compound";
+         break;
+       }
+      }
+
+      // Find or create submesh root
+      SALOMEDS::SObject_var aRootSO;
+      if ( !aParentSO->FindSubObject ( aRootTag, aRootSO ) ) {
+           MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): creating submesh root..." )
+       aRootSO  = aStudyBuilder->NewObjectToTag( aParentSO, aRootTag );
+       anAttr   = aStudyBuilder->FindOrCreateAttribute( aRootSO, "AttributeName" );
+       aName    = SALOMEDS::AttributeName::_narrow( anAttr );
+       aName    ->SetValue( aRootName );
+       anAttr   = aStudyBuilder->FindOrCreateAttribute( aRootSO, "AttributeSelectable" );
+       aSelAttr = SALOMEDS::AttributeSelectable::_narrow( anAttr );
+       aSelAttr ->SetSelectable( false );
+      }
+
+      // Add new submesh to corresponding sub-tree
+      MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): adding submesh to study..." )
+      SALOMEDS::SObject_var newMesh = aStudyBuilder->NewObject( aRootSO );
+      anAttr  = aStudyBuilder->FindOrCreateAttribute( newMesh, "AttributePixMap" );
+      aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
+      aPixmap ->SetPixMap( "ICON_SMESH_TREE_MESH" );
+      anAttr  = aStudyBuilder->FindOrCreateAttribute( newMesh, "AttributeIOR" );
+      anIOR   = SALOMEDS::AttributeIOR::_narrow(anAttr);
+      anIOR   ->SetValue( GetORB()->object_to_string( aSubMesh ) );
+      aSO     = SALOMEDS::SObject::_narrow( newMesh );
+      anObjName = TCollection_AsciiString( "SubMesh" );
     }
-  for (TopExp_Explorer exp(mainShape,TopAbs_EDGE); exp.More(); exp.Next())
-    {
-      const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
-      int i = myTopo->_myShapes[TopAbs_EDGE].Add(E);
-      SCRUTE(i);
+  }
+
+  // Publishing a hypothesis or algorithm
+  SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( theIOR );
+  if( aSO->_is_nil() && !aHyp->_is_nil() ) {
+    //Find or Create Hypothesis root
+    SALOMEDS::SObject_var  HypothesisRoot;
+    Standard_Integer aRootTag =
+      SMESH::SMESH_Algo::_narrow( theIOR )->_is_nil() ? GetHypothesisRootTag() : GetAlgorithmsRootTag();
+
+    if ( !father->FindSubObject ( aRootTag, HypothesisRoot ) ) {
+      HypothesisRoot = aStudyBuilder->NewObjectToTag( father, aRootTag );
+      anAttr   = aStudyBuilder->FindOrCreateAttribute( HypothesisRoot, "AttributeName" );
+      aName    = SALOMEDS::AttributeName::_narrow( anAttr );
+      aName    ->SetValue( aRootTag ==  GetHypothesisRootTag()  ? "Hypotheses" : "Algorithms" );
+      anAttr   = aStudyBuilder->FindOrCreateAttribute( HypothesisRoot, "AttributeSelectable" );
+      aSelAttr = SALOMEDS::AttributeSelectable::_narrow( anAttr );
+      aSelAttr ->SetSelectable( false );
+      anAttr   = aStudyBuilder->FindOrCreateAttribute( HypothesisRoot, "AttributePixMap" );
+      aPixmap  = SALOMEDS::AttributePixMap::_narrow( anAttr );
+      aPixmap  ->SetPixMap( aRootTag == GetHypothesisRootTag()  ? "ICON_SMESH_TREE_HYPO" : "ICON_SMESH_TREE_ALGO" );
     }
-  for (TopExp_Explorer exp(mainShape,TopAbs_VERTEX); exp.More(); exp.Next())
-    {
-      const TopoDS_Vertex& E = TopoDS::Vertex(exp.Current());
-      int i = myTopo->_myShapes[TopAbs_VERTEX].Add(E);
-      SCRUTE(i);
+
+    // Add New Hypothesis
+    string aPmName;
+    SALOMEDS::SObject_var newHypo = aStudyBuilder->NewObject( HypothesisRoot );
+    anAttr  = aStudyBuilder->FindOrCreateAttribute( newHypo, "AttributePixMap" );
+    aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
+    aPmName = ( aRootTag == GetHypothesisRootTag()  ? "ICON_SMESH_TREE_HYPO_" : "ICON_SMESH_TREE_ALGO_" );
+    aPmName += aHyp->GetName();
+    aPixmap ->SetPixMap( aPmName.c_str() );
+    anAttr  = aStudyBuilder->FindOrCreateAttribute( newHypo, "AttributeIOR" );
+    anIOR   = SALOMEDS::AttributeIOR::_narrow(anAttr);
+    anIOR   ->SetValue( GetORB()->object_to_string( aHyp ) );
+    aSO     = SALOMEDS::SObject::_narrow( newHypo );
+    anObjName = TCollection_AsciiString( aHyp->GetName() );
+  }
+
+  // Publishing a group
+  SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow(theIOR);
+  if( aSO->_is_nil() && !aGroup->_is_nil() ) {
+    // try to obtain a parent mesh's SObject
+    MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing group..." );
+    SALOMEDS::SObject_var aParentSO;
+    SMESH::SMESH_Mesh_var aParentMesh;
+    SMESH_Group_i* aServant = dynamic_cast<SMESH_Group_i*>( GetServant( aGroup ).in() );
+    if ( aServant != NULL ) {
+      aParentMesh = SMESH::SMESH_Mesh::_narrow( GetPOA()->servant_to_reference( aServant->GetMeshServant() ) );
+      if ( !aParentMesh->_is_nil() ) {
+       MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing group: refernce to mesh is OK" );
+       string anIOR = GetORB()->object_to_string( aParentMesh );
+       MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing group: mesh IOR = "<<anIOR.c_str() );
+       aParentSO = theStudy->FindObjectIOR( anIOR.c_str() );
+      }
     }
-  
-  // explore subShapes of distant CORBA object,
-  // associate distant CORBA subShape references
-  // with local reference to local TopoDS subShape
 
-  string filenode = "toposhape.txt";
-  ofstream fic(filenode.c_str());
+    // Find proper group sub-tree tag
+    if ( !aParentSO->_is_nil() ) {
+      MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing group: parent mesh found" );
+      int aType = (int)aGroup->GetType();
+      const char* aRootNames[] = { "Compound Groups", "Groups of Nodes", "Groups of Edges", "Groups of Faces", "Groups of Volumes" };
+
+      // Currently, groups with heterogenous content are not supported
+      if ( aType != SMESH::ALL ) {
+       MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing group: group type OK" );
+       long aRootTag = GetNodeGroupsTag() + aType - 1;
+
+       // Find or create groups root
+       SALOMEDS::SObject_var aRootSO;
+       if ( !aParentSO->FindSubObject ( aRootTag, aRootSO ) ) {
+         MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): creating groups root..." )
+         aRootSO  = aStudyBuilder->NewObjectToTag( aParentSO, aRootTag );
+         anAttr   = aStudyBuilder->FindOrCreateAttribute( aRootSO, "AttributeName" );
+         aName    = SALOMEDS::AttributeName::_narrow( anAttr );
+         aName    ->SetValue( aRootNames[aType] );
+         anAttr   = aStudyBuilder->FindOrCreateAttribute( aRootSO, "AttributeSelectable" );
+         aSelAttr = SALOMEDS::AttributeSelectable::_narrow( anAttr );
+         aSelAttr ->SetSelectable( false );
+       }
 
-  for (int shapeType = TopAbs_COMPOUND; shapeType < TopAbs_SHAPE; shapeType++)
-    {
-      fic << "shape type : " << SMESH_shapeTypeNames[shapeType];
-
-      GEOM::GEOM_Gen::ListOfGeomShapes_var subShapes
-        = geom->SubShapeAll(myShape,shapeType); 
-      int nbSubShapes = subShapes->length();
-      int nbLocal = myTopo->_myShapes[shapeType].Extent();
-      fic << " - number of elements: " << nbSubShapes << endl;
-      ASSERT(nbSubShapes == nbLocal);
-
-      for (int i=0; i< nbSubShapes; i++)
-        {
-          GEOM::GEOM_Shape_var aSubShape = subShapes[i];
-          string idShape = SMESH_topo::GetShapeLocalId(aSubShape);
-          fic << "  " <<  idShape;
-          SCRUTE(idShape);
-          TopoDS_Shape aLocShape  = _ShapeReader->GetShape(geom,aSubShape);
-          for (int j=1; j <= nbLocal; j++)
-            if (aLocShape.IsSame(myTopo->_myShapes[shapeType].FindKey(j)))
-              {
-                MESSAGE("  --- trouve = " << j);
-                myTopo->_mapIndShapes[shapeType][idShape] = j;
-                fic << "  --- trouve = " << j;
-                break;
-              }
-          fic << endl;
-        }
+       // Add new group to corresponding sub-tree
+       MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): adding group to study..." )
+       SALOMEDS::SObject_var aGroupSO = aStudyBuilder->NewObject( aRootSO );
+       anAttr  = aStudyBuilder->FindOrCreateAttribute( aGroupSO, "AttributePixMap" );
+       aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
+       aPixmap ->SetPixMap( "ICON_SMESH_TREE_GROUP" );
+       anAttr  = aStudyBuilder->FindOrCreateAttribute( aGroupSO, "AttributeIOR" );
+       anIOR   = SALOMEDS::AttributeIOR::_narrow( anAttr );
+       anIOR   ->SetValue( GetORB()->object_to_string( aGroup ) );
+       aSO     = SALOMEDS::SObject::_narrow( aGroupSO );
+       anObjName = TCollection_AsciiString( "Group" );
+      }
     }
-  fic.close();
+  }
+
+  // Setting SObject's name
+  if ( !aSO->_is_nil() ) {
+    if ( strlen( theName ) == 0 ) 
+      anObjName += TCollection_AsciiString( "_" ) + TCollection_AsciiString( aSO->Tag() );
+    else 
+      anObjName = TCollection_AsciiString( strdup( theName ) );
+    anAttr  = aStudyBuilder->FindOrCreateAttribute( aSO, "AttributeName" );
+    aName   = SALOMEDS::AttributeName::_narrow( anAttr );
+    aName   ->SetValue( anObjName.ToCString() );    
+  }
 
-  return myTopo;
+  MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): COMPLETED" )
+  return aSO._retn();
 }
       
 //=============================================================================
 /*! 
- * C factory, accessible with dlsym, after dlopen  
+ *  SMESHEngine_factory
+ *
+ *  C factory, accessible with dlsym, after dlopen  
  */
 //=============================================================================
 
 extern "C"
 {
-  PortableServer::ObjectId * SMESHEngine_factory(
-                               CORBA::ORB_ptr orb,
-                               PortableServer::POA_ptr poa, 
-                               PortableServer::ObjectId * contId,
-                               const char *instanceName, 
-                               const char *interfaceName)
+  PortableServer::ObjectId* SMESHEngine_factory( CORBA::ORB_ptr            orb,
+                                                PortableServer::POA_ptr   poa, 
+                                                PortableServer::ObjectId* contId,
+                                                const char*               instanceName, 
+                                                const char*               interfaceName )
   {
-    MESSAGE("PortableServer::ObjectId * SMESHEngine_factory()");
+    MESSAGE( "PortableServer::ObjectId* SMESHEngine_factory()" );
     SCRUTE(interfaceName);
     SMESH_Gen_i * mySMESH_Gen 
       = new SMESH_Gen_i(orb, poa, contId, instanceName, interfaceName);
index 1a045328542cbdf72919f7b0999aa9b0f35f7e8c..77e3adf43dd87d6c721b48507ffe3041212d2a28 100644 (file)
 #include CORBA_CLIENT_HEADER(SALOMEDS)
 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
 
-
-class SMESH_Mesh_i;
-
-#include "SMESH_HypothesisFactory_i.hxx"
 #include "SMESH_Mesh_i.hxx"
+#include "SMESH_Hypothesis_i.hxx"
 #include "SALOME_Component_i.hxx"
 #include "SALOME_NamingService.hxx"
 
@@ -50,115 +47,268 @@ class SMESH_Mesh_i;
 #include "SMESH_topo.hxx"
 #include "GEOM_Client.hxx"
 
-#include <HDFOI.hxx>
-
 #include <map>
 
-typedef struct studyContext_iStruct
+class SMESH_Mesh_i;
+class SALOME_LifeCycleCORBA;
+
+// ===========================================================
+// Study context - stores study-connected objects references
+// ==========================================================
+class StudyContext
 {
-  map<int,SMESH_Mesh_i*> mapMesh_i;
-} StudyContext_iStruct;
+public:
+  // constructor
+  StudyContext() {}
+  // destructor
+  ~StudyContext() 
+  { 
+    mapIdToIOR.clear();
+    mapIdToId.clear();
+  }
+  // register object in the internal map and return its id
+  int addObject( string theIOR )
+  {
+    int nextId = getNextId();
+    mapIdToIOR[ nextId ]  = theIOR;
+    return nextId;
+  }
+  // find the object id in the internal map by the IOR
+  int findId( string theIOR )
+  {
+    map<int, string>::iterator imap;
+    for ( imap = mapIdToIOR.begin(); imap != mapIdToIOR.end(); ++imap ) {
+      if ( imap->second == theIOR )
+        return imap->first;
+    }
+    return 0;
+  }
+  // get object's IOR by id
+  string getIORbyId( const int theId )
+  {
+    if ( mapIdToIOR.find( theId ) != mapIdToIOR.end() )
+      return mapIdToIOR[ theId ];
+    return string( "" );
+  }
+  // get object's IOR by old id
+  string getIORbyOldId( const int theOldId )
+  {
+    if ( mapIdToId.find( theOldId ) != mapIdToId.end() )
+      return getIORbyId( mapIdToId[ theOldId ] );
+    return string( "" );
+  }
+  // maps old object id to the new one (used when restoring data)
+  void mapOldToNew( const int oldId, const int newId ) {
+    mapIdToId[ oldId ] = newId;
+  }
+    
+private:
+  // get next free object identifier
+  int getNextId()
+  {
+    int id = 1;
+    while( mapIdToIOR.find( id ) != mapIdToIOR.end() )
+      id++;
+    return id;
+  }
+
+  map<int, string> mapIdToIOR;      // persistent-to-transient map
+  map<int, int>    mapIdToId;       // used to translate object from persistent to transient form
+};
 
+// ===========================================================
+// SMESH module's engine
+// ==========================================================
 class SMESH_Gen_i:
-  public POA_SMESH::SMESH_Gen,
-  public Engines_Component_i 
+  public virtual POA_SMESH::SMESH_Gen,
+  public virtual Engines_Component_i 
 {
 public:
+  // Get ORB object
+  static CORBA::ORB_var GetORB() { return myOrb;}
+  // Get SMESH module's POA object
+  static PortableServer::POA_var GetPOA() { return myPoa;}
+  // Get Naming Service object
+  static SALOME_NamingService* GetNS();
+  // Get SALOME_LifeCycleCORBA object
+  static SALOME_LifeCycleCORBA* GetLCC();
+  // Retrieve and get GEOM engine reference
+  static GEOM::GEOM_Gen_ptr GetGeomEngine();
+  // Get object of the CORBA reference
+  static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
+  // Get CORBA object corresponding to the SALOMEDS::SObject
+  static CORBA::Object_var SObjectToObject( SALOMEDS::SObject_ptr theSObject );
 
+  // Default constructor
   SMESH_Gen_i();
-  SMESH_Gen_i(CORBA::ORB_ptr orb,
-              PortableServer::POA_ptr poa,
-              PortableServer::ObjectId * contId, 
-              const char *instanceName, 
-              const char *interfaceName);
+  // Standard constructor
+  SMESH_Gen_i( CORBA::ORB_ptr            orb,
+               PortableServer::POA_ptr   poa,
+               PortableServer::ObjectId* contId, 
+               const char*               instanceName, 
+               const char*               interfaceName );
+  // Destructor
   virtual ~SMESH_Gen_i();
   
-  SMESH::SMESH_Hypothesis_ptr CreateHypothesis(const char* anHyp,
-                                               CORBA::Long studyId)
-    throw (SALOME::SALOME_Exception);
+  // *****************************************
+  // Interface methods
+  // *****************************************
+
+  // Set current study
+  void SetCurrentStudy( SALOMEDS::Study_ptr theStudy );
+  // Get current study
+  SALOMEDS::Study_ptr GetCurrentStudy();
+
+  // Create hypothesis/algorothm of given type
+  SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const char* theHypType,
+                                                const char* theLibName)
+    throw ( SALOME::SALOME_Exception );
   
-  SMESH::SMESH_Mesh_ptr Init(GEOM::GEOM_Gen_ptr geomEngine,
-                             CORBA::Long studyId,
-                             GEOM::GEOM_Shape_ptr aShape)
-    throw (SALOME::SALOME_Exception);
-
-  CORBA::Boolean Compute(SMESH::SMESH_Mesh_ptr aMesh,
-                         GEOM::GEOM_Shape_ptr aShape)
-    throw (SALOME::SALOME_Exception);
-
-  CORBA::Boolean IsReadyToCompute(SMESH::SMESH_Mesh_ptr aMesh,
-                                  GEOM::GEOM_Shape_ptr aShape)
-    throw (SALOME::SALOME_Exception);
-
-  SMESH::long_array* GetSubShapesId(GEOM::GEOM_Gen_ptr geomEngine,
-                                   CORBA::Long studyId,
-                                   GEOM::GEOM_Shape_ptr mainShape,
-                                   const SMESH::shape_array& listOfSubShape)
-    throw (SALOME::SALOME_Exception);
-
-
-  // inherited methods from SALOMEDS::Driver
-
-  SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
-                         const char* theURL,
-                         bool isMultiFile);
-  bool Load(SALOMEDS::SComponent_ptr theComponent,
-           const SALOMEDS::TMPFile& theStream,
-           const char* theURL,
-           bool isMultiFile);
-
-  SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
-                              const char* theURL,
-                              bool isMultiFile);
-  bool LoadASCII(SALOMEDS::SComponent_ptr theComponent,
-                const SALOMEDS::TMPFile& theStream,
-                const char* theURL,
-                bool isMultiFile);
-
-  void Close(SALOMEDS::SComponent_ptr theComponent);
+  // Create empty mesh on a shape
+  SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Shape_ptr theShape )
+    throw ( SALOME::SALOME_Exception );
+
+  //  Create mesh(es) and import data from MED file
+  SMESH::mesh_array* CreateMeshesFromMED( const char* theFileName,
+                                          SMESH::DriverMED_ReadStatus& theStatus )
+    throw ( SALOME::SALOME_Exception );
+
+  // Compute mesh on a shape
+  CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh,
+                          GEOM::GEOM_Shape_ptr  theShape )
+    throw ( SALOME::SALOME_Exception );
+
+  // Returns true if mesh contains enough data to be computed
+  CORBA::Boolean IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh,
+                                   GEOM::GEOM_Shape_ptr  theShape )
+    throw ( SALOME::SALOME_Exception );
+
+  // Get sub-shapes unique ID's list
+  SMESH::long_array* GetSubShapesId( GEOM::GEOM_Shape_ptr      theMainShape,
+                                     const SMESH::shape_array& theListOfSubShape )
+    throw ( SALOME::SALOME_Exception );
+
+
+  // ****************************************************
+  // Interface inherited methods (from SALOMEDS::Driver)
+  // ****************************************************
+
+  // Save SMESH data
+  SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent,
+                          const char*              theURL,
+                          bool                     isMultiFile );
+  // Load SMESH data
+  bool Load( SALOMEDS::SComponent_ptr theComponent,
+            const SALOMEDS::TMPFile& theStream,
+            const char*              theURL,
+            bool                     isMultiFile );
+  // Save SMESH data in ASCII format
+  SALOMEDS::TMPFile* SaveASCII( SALOMEDS::SComponent_ptr theComponent,
+                               const char*              theURL,
+                               bool                     isMultiFile );
+  // Load SMESH data in ASCII format
+  bool LoadASCII( SALOMEDS::SComponent_ptr theComponent,
+                 const SALOMEDS::TMPFile& theStream,
+                 const char*              theURL,
+                 bool                     isMultiFile );
+
+  // Create filter manager
+  SMESH::FilterManager_ptr CreateFilterManager();
+
+  // Clears study-connected data when it is closed
+  void Close( SALOMEDS::SComponent_ptr theComponent );
+  
+  // Get component data type
   char* ComponentDataType();
     
-  char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
-                              const char* IORString,
-                              CORBA::Boolean isMultiFile,
-                              CORBA::Boolean isASCII);
-  char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
-                              const char* aLocalPersistentID,
-                              CORBA::Boolean isMultiFile,
-                              CORBA::Boolean isASCII);
-
-  bool CanPublishInStudy(CORBA::Object_ptr theIOR) { return false; }
-  SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
-                                      SALOMEDS::SObject_ptr theSObject,
-                                      CORBA::Object_ptr theObject,
-                                      const char* theName) throw (SALOME::SALOME_Exception) {
-    SALOMEDS::SObject_var aResultSO;
-    return aResultSO._retn();
-  }
+  // Transform data from transient form to persistent
+  char* IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject,
+                               const char*           IORString,
+                               CORBA::Boolean        isMultiFile,
+                               CORBA::Boolean        isASCII );
+  // Transform data from persistent form to transient
+  char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject,
+                               const char*           aLocalPersistentID,
+                               CORBA::Boolean        isMultiFile,
+                               CORBA::Boolean        isASCII );
+
+  // Returns true if object can be published in the study
+  bool CanPublishInStudy( CORBA::Object_ptr theIOR );
+  // Publish object in the study
+  SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::Study_ptr   theStudy,
+                                       SALOMEDS::SObject_ptr theSObject,
+                                       CORBA::Object_ptr     theObject,
+                                       const char*           theName ) 
+    throw ( SALOME::SALOME_Exception );
 
-  CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject) {return false;}
-  SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {return false;}
-  CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID) {return false;}
-  SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
-                                 CORBA::Long theObjectID,
-                                 SALOMEDS::SObject_ptr theObject) {
+  // Copy-paste methods - returns true if object can be copied to the clipboard
+  CORBA::Boolean CanCopy( SALOMEDS::SObject_ptr theObject ) { return false; }
+  // Copy-paste methods - copy object to the clipboard
+  SALOMEDS::TMPFile* CopyFrom( SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID ) { return false; }
+  // Copy-paste methods - returns true if object can be pasted from the clipboard
+  CORBA::Boolean CanPaste( const char* theComponentName, CORBA::Long theObjectID ) { return false; }
+  // Copy-paste methods - paste object from the clipboard
+  SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile& theStream,
+                                  CORBA::Long              theObjectID,
+                                  SALOMEDS::SObject_ptr    theObject ) {
     SALOMEDS::SObject_var aResultSO;
     return aResultSO._retn();
   }
 
-  GEOM_Client* _ShapeReader;
-protected:
-  SMESH_topo* ExploreMainShape(GEOM::GEOM_Gen_ptr geomEngine,
-                               CORBA::Long studyId,
-                               GEOM::GEOM_Shape_ptr aShape);
+  // *****************************************
+  // Internal methods
+  // *****************************************
+public:
+  // Get shape reader
+  GEOM_Client* GetShapeReader();
+
+  // Tags definition 
+  static long GetHypothesisRootTag();
+  static long GetAlgorithmsRootTag();
+  static long GetRefOnShapeTag();
+  static long GetRefOnAppliedHypothesisTag();
+  static long GetRefOnAppliedAlgorithmsTag();
+  static long GetSubMeshOnVertexTag();
+  static long GetSubMeshOnEdgeTag();
+  static long GetSubMeshOnFaceTag();
+  static long GetSubMeshOnSolidTag();
+  static long GetSubMeshOnCompoundTag();
+  static long GetNodeGroupsTag();
+  static long GetEdgeGroupsTag();
+  static long GetFaceGroupsTag();
+  static long GetVolumeGroupsTag();
+
+  //  Get study context
+  StudyContext* GetCurrentStudyContext();
   
 private:
-  SMESH_HypothesisFactory_i _hypothesisFactory_i;
-  ::SMESH_Gen _impl;  // no namespace here
-  int _localId; // unique Id of created objects, within SMESH_Gen_i entity
+  // Create hypothesis of given type
+  SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName,
+                                                const char* theLibName)
+    throw ( SALOME::SALOME_Exception );
+  
+  // Create empty mesh on shape
+  SMESH::SMESH_Mesh_ptr createMesh()
+    throw ( SALOME::SALOME_Exception );
+
+  static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot );
+  
+private:
+
+  static CORBA::ORB_var          myOrb;         // ORB reference
+  static PortableServer::POA_var myPoa;         // POA reference
+  static SALOME_NamingService*   myNS;          // Naming Service
+  static SALOME_LifeCycleCORBA*  myLCC;         // Life Cycle CORBA
+
+  ::SMESH_Gen               myGen;              // SMESH_Gen local implementation
+
+  // hypotheses managing
+  map<string, GenericHypothesisCreator_i*> myHypCreatorMap;
+
+  map<int, StudyContext*>   myStudyContextMap;  // Map of study context objects
 
-  map<int, StudyContext_iStruct*> _mapStudyContext_i;
-  map <string, string> _SMESHCorbaObj;
+  GEOM_Client*              myShapeReader;      // Shape reader
+  SALOMEDS::Study_var       myCurrentStudy;     // Current study
 };
 
 #endif
index 2c86f6af0d2a3ce937a84ff990e37fa210185fcd..87c16ee4e12632f9d244c58df93a0ab917667a16 100644 (file)
 //  $Header$
 
 using namespace std;
-using namespace std;
+#include <iostream>
+#include <sstream>
 #include "SMESH_Hypothesis_i.hxx"
-#include "SMESH_Hypothesis.hxx"
-#include "SMESH_Gen.hxx"
 #include "utilities.h"
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Hypothesis_i::SMESH_Hypothesis_i
+ * 
+ *  Constructor
  */
 //=============================================================================
 
-SMESH_Hypothesis_i::SMESH_Hypothesis_i()
+SMESH_Hypothesis_i::SMESH_Hypothesis_i( PortableServer::POA_ptr thePOA )
+     : SALOME::GenericObj_i( thePOA )
 {
-  MESSAGE("SMESH_Hypothesis_i");
+  MESSAGE( "SMESH_Hypothesis_i::SMESH_Hypothesis_i" );
+  myBaseImpl = 0;
+  thePOA->activate_object( this );
 };
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Hypothesis_i::~SMESH_Hypothesis_i
+ *
+ *  Destructor
  */
 //=============================================================================
 
 SMESH_Hypothesis_i::~SMESH_Hypothesis_i()
 {
-  MESSAGE("~SMESH_Hypothesis_i");
+  MESSAGE( "SMESH_Hypothesis_i::~SMESH_Hypothesis_i" );
+  if ( myBaseImpl )
+    delete myBaseImpl;
 };
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Hypothesis_i::GetName
+ *
+ *  Get type name of hypothesis
  */
 //=============================================================================
 
 char* SMESH_Hypothesis_i::GetName()
 {
-  MESSAGE("GetName");
-  return CORBA::string_dup(_baseImpl->GetName());
-//   const char* name = _baseImpl->GetName();
-//   SCRUTE(name);
-//   return CORBA::string_dup(name);
+  MESSAGE( "SMESH_Hypothesis_i::GetName" );
+  return CORBA::string_dup( myBaseImpl->GetName() );
+};
+
+//=============================================================================
+/*!
+ *  SMESH_Hypothesis_i::GetLibName
+ *
+ *  Get plugin library name of hypothesis (required by persistency mechanism)
+ */
+//=============================================================================
+
+char* SMESH_Hypothesis_i::GetLibName()
+{
+  MESSAGE( "SMESH_Hypothesis_i::GetLibName" );
+  return CORBA::string_dup( myBaseImpl->GetLibName() );
+};
+
+//=============================================================================
+/*!
+ *  SMESH_Hypothesis_i::SetLibName
+ *
+ *  Set plugin library name of hypothesis (required by persistency mechanism)
+ */
+//=============================================================================
+
+void SMESH_Hypothesis_i::SetLibName(const char* theLibName)
+{
+  MESSAGE( "SMESH_Hypothesis_i::SetLibName" );
+  myBaseImpl->SetLibName( theLibName );
 };
 
 //=============================================================================
 /*!
- *  
+ *  SMESH_Hypothesis_i::GetId
+ *
+ *  Get unique id of hypothesis
  */
 //=============================================================================
 
 CORBA::Long SMESH_Hypothesis_i::GetId()
 {
-  MESSAGE("GetId");
-  return _baseImpl->GetID();
+  MESSAGE( "SMESH_Hypothesis_i::GetId" );
+  return myBaseImpl->GetID();
+}
+
+//=============================================================================
+/*!
+ *  SMESH_Hypothesis_i::GetImpl
+ *
+ *  Get implementation
+ */
+//=============================================================================
+
+::SMESH_Hypothesis* SMESH_Hypothesis_i::GetImpl()
+{
+  MESSAGE( "SMESH_Hypothesis_i::GetImpl" );
+  return myBaseImpl;
+}
+
+//=============================================================================
+/*!
+ *  SMESH_Hypothesis_i::SaveTo
+ *
+ *  Persistence: Dumps parameters to the string stream
+ */
+//=============================================================================
+
+char* SMESH_Hypothesis_i::SaveTo()
+{
+  MESSAGE( "SMESH_Hypothesis_i::SaveTo" );
+  std::ostringstream os;
+  myBaseImpl->SaveTo( os );
+  return CORBA::string_dup( os.str().c_str() );
+}
+
+//=============================================================================
+/*!
+*  SMESH_Hypothesis_i::LoadFrom
+*
+*  Persistence: Restores parameters from string
+*/
+//=============================================================================
+
+void SMESH_Hypothesis_i::LoadFrom( const char* theStream )
+{
+  MESSAGE( "SMESH_Hypothesis_i::LoadFrom" );
+  std::istringstream is( theStream );
+  myBaseImpl->LoadFrom( is );
 }
index 9277426d344c65fb3be440318dbbdb3ea99cace1..5a03bfa44785ccd1fb1b6b3eee923ccae39e584b 100644 (file)
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
 
-class SMESH_Gen;
-class SMESH_Hypothesis;
+#include "SMESH_Hypothesis.hxx"
+#include "SALOME_GenericObj_i.hh"
 
+#include "SMESH_Gen.hxx"
+
+// ======================================================
+// Generic hypothesis
+// ======================================================
 class SMESH_Hypothesis_i:
-  public POA_SMESH::SMESH_Hypothesis
+  public virtual POA_SMESH::SMESH_Hypothesis,
+  public virtual SALOME::GenericObj_i
 {
 public:
-  SMESH_Hypothesis_i();
+  // Constructor : placed in protected section to prohibit creation of generic class instance
+  SMESH_Hypothesis_i( PortableServer::POA_ptr thePOA );
+
+public:
+  // Destructor
   virtual ~SMESH_Hypothesis_i();
 
+  // Get type name of hypothesis
   char* GetName();
+
+  // Get plugin library name of hypothesis
+  char* GetLibName();
+
+  // Set plugin library name of hypothesis
+  void SetLibName( const char* theLibName );
+
+  // Get unique id of hypothesis
   CORBA::Long GetId();
 
+  // Get implementation
+  ::SMESH_Hypothesis* GetImpl();
+  
+  // Persistence
+  virtual char* SaveTo();
+  virtual void  LoadFrom( const char* theStream );
+  
 protected:
-  ::SMESH_Hypothesis* _baseImpl;
-  ::SMESH_Gen* _genImpl;
-  int _id;
+  ::SMESH_Hypothesis* myBaseImpl;    // base hypothesis implementation
+};
+
+// ======================================================
+// Generic hypothesis creator
+// ======================================================
+class GenericHypothesisCreator_i
+{
+public:
+  // Create a hypothesis
+  virtual SMESH_Hypothesis_i* Create(PortableServer::POA_ptr thePOA,
+                                     int                     theStudyId,
+                                     ::SMESH_Gen*            theGenImpl) = 0;
+};
+
+//=============================================================================
+//
+// Specific Hypothesis Creators are generated with a template which inherits a
+// generic hypothesis creator. Each creator returns an hypothesis of the type
+// given in the template. 
+//
+//=============================================================================
+template <class T> class HypothesisCreator_i: public GenericHypothesisCreator_i
+{
+public:
+  virtual SMESH_Hypothesis_i* Create (PortableServer::POA_ptr thePOA,
+                                      int                     theStudyId,
+                                      ::SMESH_Gen*            theGenImpl) 
+  {
+    return new T (thePOA, theStudyId, theGenImpl);
+  };
 };
 
 #endif
index 25ce55bfe3b3fedfa11e95fa5b322af840b2fb49..82917f4ad753f03e09406df08d3a9db955b7cbf1 100644 (file)
@@ -54,6 +54,8 @@ using namespace std;
 
 # include "Utils_ORB_INIT.hxx"
 # include "Utils_SINGLETON.hxx"
+# include "Utils_ExceptHandlers.hxx"
+
 extern "C"
 {
 #include <stdio.h>
@@ -254,7 +256,7 @@ SALOME_MED::double_array * SMESH_MEDMesh_i::getCoordinates(
                myseq->length(nbNodes * spaceDimension);
                int i = 0;
 
-               SMDS_Iterator<const SMDS_MeshNode *> * itNodes=_meshDS->nodesIterator();
+               SMDS_NodeIteratorPtr itNodes=_meshDS->nodesIterator();
                while(itNodes->more())
                {
                        const SMDS_MeshNode* node = itNodes->next();
@@ -280,7 +282,6 @@ SALOME_MED::double_array * SMESH_MEDMesh_i::getCoordinates(
                        }
                        i++;
                }
-               delete itNodes;
        }
        catch(...)
        {
@@ -949,7 +950,7 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
                int trouveSeg3 = 0;
                SALOME_MED::medGeometryElement medElement;
 
-               SMDS_Iterator<const SMDS_MeshEdge*> * itEdges=_meshDS->edgesIterator();
+               SMDS_EdgeIteratorPtr itEdges=_meshDS->edgesIterator();
                while(itEdges->more())
                {
                        const SMDS_MeshEdge* elem = itEdges->next();
@@ -987,13 +988,11 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
                        int longueur = _seq_elemId[index]->length();
                        _seq_elemId[index]->length(longueur + nb_of_nodes);
 
-                       SMDS_Iterator<const SMDS_MeshNode*> * itn=_meshDS->nodesIterator();
+                       SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator();
 
                        for(int k=0; itn->more(); k++)
                                _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
-                       delete itn;
                }
-               delete itEdges;
 
                _mapNbTypes[SALOME_MED::MED_EDGE] = trouveSeg2 + trouveSeg3;
 
@@ -1008,7 +1007,7 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
                _mapIndToSeqElts[SALOME_MED::MED_QUAD4] = _indexElts++;
                _mapIndToVectTypes[SALOME_MED::MED_FACE] = _indexEnts++;
 
-               SMDS_Iterator<const SMDS_MeshFace*> * itFaces=_meshDS->facesIterator();
+               SMDS_FaceIteratorPtr itFaces=_meshDS->facesIterator();
                while(itFaces->more())
                {
                        const SMDS_MeshFace * elem = itFaces->next();
@@ -1059,13 +1058,11 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
                        int longueur = _seq_elemId[index]->length();
                        _seq_elemId[index]->length(longueur + nb_of_nodes);
 
-                       SMDS_Iterator<const SMDS_MeshNode*> * itn=_meshDS->nodesIterator();
+                       SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator();
 
                        for(int k=0; itn->more(); k++)
                                _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
-                       delete itn;
                } //itFaces
-               delete itFaces;
 
                _mapNbTypes[SALOME_MED::MED_FACE] =
                        trouveTria3 + trouveTria6 + trouveQuad4;
@@ -1076,7 +1073,7 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
 
                int trouveHexa8 = 0;
 
-               SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=_meshDS->volumesIterator();
+               SMDS_VolumeIteratorPtr itVolumes=_meshDS->volumesIterator();
                while(itVolumes->more())
                {
                        const SMDS_MeshVolume * elem = itVolumes->next();
@@ -1094,12 +1091,10 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
                        int longueur = _seq_elemId[index]->length();
                        _seq_elemId[index]->length(longueur + nb_of_nodes);
 
-                       SMDS_Iterator<const SMDS_MeshNode*> * itn=_meshDS->nodesIterator();
+                       SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator();
                        for(int k=0; itn->more(); k++)
                                _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
-                       delete itn;
                }
-               delete itVolumes;
 
                _mapNbTypes[SALOME_MED::MED_CELL] = trouveHexa8;
                _mapNbTypes[SALOME_MED::MED_ALL_ENTITIES]
@@ -1116,6 +1111,7 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
 //=============================================================================
 void SMESH_MEDMesh_i::createFamilies() throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        string famDes = ("Je ne sais pas");
        string famName0 = "Famille_";
        string famName;
index ba72f1973327f0343c7b216bf55a2c404d4e4e59..7b5289ebb879212e6acc7a12e24b70b7bcb84f7c 100644 (file)
@@ -28,6 +28,7 @@ using namespace std;
 #include "SMESH_MEDSupport_i.hxx"
 #include "utilities.h"
 #include "Utils_CorbaException.hxx"
+#include "Utils_ExceptHandlers.hxx"
 
 #include <TopoDS_Iterator.hxx>
 #include "SMESHDS_Mesh.hxx"
@@ -36,6 +37,7 @@ using namespace std;
 #include "SMESH_Mesh_i.hxx"
 #include "SMESH_subMesh_i.hxx"
 
+
 //=============================================================================
 /*!
  * Default constructor
@@ -296,6 +298,7 @@ CORBA::Long SMESH_MEDSupport_i::getNumberOfElements(SALOME_MED::
 SALOME_MED::long_array * SMESH_MEDSupport_i::getNumber(
        SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        if (_subMeshDS==NULL)
                THROW_SALOME_CORBA_EXCEPTION("No associated Support",
                        SALOME::INTERNAL_ERROR);
@@ -309,13 +312,12 @@ SALOME_MED::long_array * SMESH_MEDSupport_i::getNumber(
        int i = 0;
        myseq->length(_subMeshDS->NbNodes());
 
-       SMDS_Iterator<const SMDS_MeshNode*> * it = _subMeshDS->GetNodes();
+       SMDS_NodeIteratorPtr it = _subMeshDS->GetNodes();
        while(it->more())
        {
                myseq[i] = it->next()->GetID();
                i++;
        };
-       delete it;
 
        SCRUTE(myseq->length());
        MESSAGE("End of SMESH_MEDSupport_i::getNumber");
index 89088d3f63bdd50595764759809d1471a265c9eb..99b27b0bb9f278c7ae4c7e9e0c4fb16d34fd553c 100644 (file)
@@ -61,8 +61,14 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveElements(const SMESH::
        for (int i = 0; i < IDsOfElements.length(); i++)
        {
                CORBA::Long index = IDsOfElements[i];
-               _myMeshDS->RemoveElement(_myMeshDS->FindElement(index));
-               MESSAGE("Element " << index << " was removed")
+                const SMDS_MeshElement * elem = _myMeshDS->FindElement(index);
+                // an element may be removed as a result of preceding
+                // loop removal
+                if ( elem )
+                {
+                  _myMeshDS->RemoveElement( elem );
+                  MESSAGE("Element " << index << " was removed");
+                }
        }
        return true;
 };
index 9dee0f5621005a8ca9ff9276bb9e6ebae73bcca1..9ca6f208aea314526c18e946b3b75b8ef51a40fa 100644 (file)
@@ -30,8 +30,10 @@ using namespace std;
 #include "SMESH_Mesh_i.hxx"
 #include "SMESH_subMesh_i.hxx"
 #include "SMESH_MEDMesh_i.hxx"
+#include "SMESH_Group_i.hxx"
 
 #include "Utils_CorbaException.hxx"
+#include "Utils_ExceptHandlers.hxx"
 #include "utilities.h"
 
 #include "SALOME_NamingService.hxx"
@@ -42,12 +44,17 @@ using namespace std;
 #include "SMESHDS_Command.hxx"
 #include "SMESHDS_CommandType.hxx"
 #include "SMESH_MeshEditor_i.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "DriverMED_R_SMESHDS_Mesh.h"
 
 #include <string>
 #include <iostream>
 
+
 //**** SMESHDS en champ
 
+int SMESH_Mesh_i::myIdGenerator = 0;
+
 //=============================================================================
 /*!
  *  
@@ -55,10 +62,11 @@ using namespace std;
 //=============================================================================
 
 SMESH_Mesh_i::SMESH_Mesh_i()
+     : SALOME::GenericObj_i( PortableServer::POA::_nil() )
 {
        MESSAGE("SMESH_Mesh_i: default constructor, not for use");
        ASSERT(0);
-};
+}
 
 //=============================================================================
 /*!
@@ -66,16 +74,28 @@ SMESH_Mesh_i::SMESH_Mesh_i()
  */
 //=============================================================================
 
-SMESH_Mesh_i::SMESH_Mesh_i(SMESH_Gen_i * gen_i,
-       GEOM::GEOM_Gen_ptr geomEngine, CORBA::Long studyId, int localId)
+SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
+                           SMESH_Gen_i*            gen_i,
+                           CORBA::Long studyId )
+: SALOME::GenericObj_i( thePOA )
 {
-       MESSAGE("SMESH_Mesh_i");
-       _gen_i = gen_i;
-       _id = localId;
-       _geom = GEOM::GEOM_Gen::_narrow(geomEngine);
-       _studyId = studyId;
+  MESSAGE("SMESH_Mesh_i");
+  _gen_i = gen_i;
+  _id = myIdGenerator++;
+  _studyId = studyId;
+  thePOA->activate_object( this );
 }
-
+/*
+SMESH_Mesh_i::SMESH_Mesh_i(SMESH_Gen_i* gen_i,
+                          CORBA::Long studyId, 
+                          int localId)
+{
+  MESSAGE("SMESH_Mesh_i");
+  _gen_i = gen_i;
+  _id = localId;
+  _studyId = studyId;
+}
+*/
 //=============================================================================
 /*!
  *  Destructor
@@ -84,9 +104,287 @@ SMESH_Mesh_i::SMESH_Mesh_i(SMESH_Gen_i * gen_i,
 
 SMESH_Mesh_i::~SMESH_Mesh_i()
 {
-       MESSAGE("~SMESH_Mesh_i");
-       // ****
-};
+  MESSAGE("~SMESH_Mesh_i");
+  map<int, SMESH::SMESH_Group_ptr>::iterator it;
+  for ( it = _mapGroups.begin(); it != _mapGroups.end(); it++ ) {
+    SMESH_Group_i* aGroup = dynamic_cast<SMESH_Group_i*>( SMESH_Gen_i::GetServant( it->second ).in() );
+    if ( aGroup ) {
+      _impl->RemoveGroup( aGroup->GetLocalID() );
+      aGroup->Destroy();
+    }
+  }
+  _mapGroups.clear();
+}
+
+//=============================================================================
+/*!
+ *  SetShape
+ *
+ *  Associates <this> mesh with <theShape> and puts a reference  
+ *  to <theShape> into the current study; 
+ *  the previous shape is substituted by the new one.
+ */
+//=============================================================================
+
+void SMESH_Mesh_i::SetShape( GEOM::GEOM_Shape_ptr theShape )
+    throw (SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  try {
+    setShape( theShape );
+  }
+  catch(SALOME_Exception & S_ex) {
+    THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+  }  
+
+  SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+  if ( aStudy->_is_nil() ) 
+    return;
+
+  // Create a reference to <theShape> 
+  SALOMEDS::SObject_var aMeshSO  = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) );
+  SALOMEDS::SObject_var aShapeSO = aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string( theShape ) );
+  
+  SALOMEDS::SObject_var          anObj, aRef;
+  SALOMEDS::GenericAttribute_var anAttr;
+  SALOMEDS::AttributeIOR_var     anIOR;
+  SALOMEDS::StudyBuilder_var     aBuilder = aStudy->NewBuilder();
+  long                           aTag = SMESH_Gen_i::GetRefOnShapeTag();      
+  
+  if ( aMeshSO->FindSubObject( aTag, anObj ) ) {
+    if ( anObj->ReferencedObject( aRef ) ) {
+      if ( strcmp( aRef->GetID(), aShapeSO->GetID() ) == 0 ) {
+       // Setting the same shape twice forbidden
+       return;
+      }
+    }
+  }
+  else {
+    anObj = aBuilder->NewObjectToTag( aMeshSO, aTag );
+  }
+  aBuilder->Addreference( anObj, aShapeSO );
+}
+
+//=============================================================================
+/*!
+ *  setShape
+ *
+ *  Sets shape to the mesh implementation
+ */
+//=============================================================================
+
+bool SMESH_Mesh_i::setShape( GEOM::GEOM_Shape_ptr theShape )
+{
+  TopoDS_Shape aLocShape  = _gen_i->GetShapeReader()->GetShape( SMESH_Gen_i::GetGeomEngine(), theShape );
+  _impl->ShapeToMesh( aLocShape );
+  return true;
+}
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+static SMESH::DriverMED_ReadStatus ConvertDriverMEDReadStatus (int theStatus)
+{
+  SMESH::DriverMED_ReadStatus res;
+  switch (theStatus)
+  {
+  case DriverMED_R_SMESHDS_Mesh::DRS_OK:
+    res = SMESH::DRS_OK; break;
+  case DriverMED_R_SMESHDS_Mesh::DRS_EMPTY:
+    res = SMESH::DRS_EMPTY; break;
+  case DriverMED_R_SMESHDS_Mesh::DRS_WARN_RENUMBER:
+    res = SMESH::DRS_WARN_RENUMBER; break;
+  case DriverMED_R_SMESHDS_Mesh::DRS_WARN_SKIP_ELEM:
+    res = SMESH::DRS_WARN_SKIP_ELEM; break;
+  case DriverMED_R_SMESHDS_Mesh::DRS_FAIL:
+  default:
+    res = SMESH::DRS_FAIL; break;
+  }
+  return res;
+}
+
+//=============================================================================
+/*!
+ *  ImportMEDFile
+ *
+ *  Imports mesh data from MED file
+ */
+//=============================================================================
+
+SMESH::DriverMED_ReadStatus
+  SMESH_Mesh_i::ImportMEDFile( const char* theFileName, const char* theMeshName )
+     throw ( SALOME::SALOME_Exception )
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  int status;
+  try {
+    status = importMEDFile( theFileName, theMeshName );
+  }
+  catch( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+  }  
+  catch ( ... ) {
+    THROW_SALOME_CORBA_EXCEPTION("ImportMEDFile(): unknown exception", SALOME::BAD_PARAM);
+  }
+
+  SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+  if ( aStudy->_is_nil() ) 
+    return ConvertDriverMEDReadStatus(status);
+  
+  // publishing of the groups in the study (sub-meshes are out of scope of MED import)
+  map<int, SMESH::SMESH_Group_ptr>::iterator it = _mapGroups.begin();
+  for (; it != _mapGroups.end(); it++ ) {
+    SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_duplicate( it->second );
+    if ( _gen_i->CanPublishInStudy( aGroup ) )
+      _gen_i->PublishInStudy( aStudy, 
+                             SALOMEDS::SObject::_nil(),
+                             aGroup,
+                             aGroup->GetName() );
+  }
+  return ConvertDriverMEDReadStatus(status);
+}
+
+//=============================================================================
+/*!
+ *  importMEDFile
+ *
+ *  Imports mesh data from MED file
+ */
+//=============================================================================
+
+int SMESH_Mesh_i::importMEDFile( const char* theFileName, const char* theMeshName )
+{
+  // Read mesh with name = <theMeshName> and all its groups into SMESH_Mesh
+  int status = _impl->MEDToMesh( theFileName, theMeshName );
+
+  // Create group servants, if any groups were imported
+  list<int> aGroupIds = _impl->GetGroupIds();
+  for ( list<int>::iterator it = aGroupIds.begin(); it != aGroupIds.end(); it++ ) {
+    SMESH_Group_i* aGroupImpl     = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, *it );
+    SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() );
+    _mapGroups[*it]               = SMESH::SMESH_Group::_duplicate( aGroup );
+
+    // register CORBA object for persistence
+    StudyContext* myStudyContext = _gen_i->GetCurrentStudyContext();
+    string iorString = SMESH_Gen_i::GetORB()->object_to_string( aGroup );
+    int nextId = myStudyContext->addObject( iorString );
+    MESSAGE( "Add group to map with id = "<< nextId << " and IOR = " << iorString.c_str() );
+  }
+
+  return status;
+}
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+static SMESH::Hypothesis_Status ConvertHypothesisStatus
+                         (SMESH_Hypothesis::Hypothesis_Status theStatus)
+{
+  SMESH::Hypothesis_Status res;
+  switch (theStatus)
+  {
+  case SMESH_Hypothesis::HYP_OK:
+    res = SMESH::HYP_OK; break;
+  case SMESH_Hypothesis::HYP_MISSING:
+    res = SMESH::HYP_MISSING; break;
+  case SMESH_Hypothesis::HYP_CONCURENT:
+    res = SMESH::HYP_CONCURENT; break;
+  case SMESH_Hypothesis::HYP_BAD_PARAMETER:
+    res = SMESH::HYP_BAD_PARAMETER; break;
+  case SMESH_Hypothesis::HYP_INCOMPATIBLE:
+    res = SMESH::HYP_INCOMPATIBLE; break;
+  case SMESH_Hypothesis::HYP_NOTCONFORM:
+    res = SMESH::HYP_NOTCONFORM; break;
+  case SMESH_Hypothesis::HYP_ALREADY_EXIST:
+    res = SMESH::HYP_ALREADY_EXIST; break;
+  case SMESH_Hypothesis::HYP_BAD_DIM:
+    res = SMESH::HYP_BAD_DIM; break;
+  default:
+    res = SMESH::HYP_UNKNOWN_FATAL;
+  }
+  return res;
+}
+
+//=============================================================================
+/*!
+ *  AddHypothesis
+ *
+ *  calls internal addHypothesis() and then adds a reference to <anHyp> under 
+ *  the SObject actually having a reference to <aSubShape>.
+ *  NB: For this method to work, it is necessary to add a reference to sub-shape first.
+ */
+//=============================================================================
+
+SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+                                                     SMESH::SMESH_Hypothesis_ptr anHyp)
+  throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  SMESH_Hypothesis::Hypothesis_Status status = addHypothesis( aSubShape, anHyp );
+
+  if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
+    SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+
+    if ( !aStudy->_is_nil() ) {
+      // Detect whether <aSubShape> refers to this mesh or its sub-mesh
+      SALOMEDS::GenericAttribute_var anAttr;
+      SALOMEDS::AttributeIOR_var     anIOR;
+      SALOMEDS::SObject_var aMeshSO  = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) );
+      SALOMEDS::SObject_var aMorSM, aRef;
+      CORBA::String_var aShapeIOR    = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( aSubShape ) );
+      SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( aMeshSO );
+
+      for ( it->InitEx( true ); it->More(); it->Next() ) {
+       SALOMEDS::SObject_var anObj = it->Value();
+       if ( anObj->ReferencedObject( aRef ) ) {
+         if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) {
+           anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
+           if ( strcmp( anIOR->Value(), aShapeIOR ) == 0 ) {
+             aMorSM = anObj->GetFather();
+             break;
+           }
+         }
+       }
+      }
+
+      bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( anHyp )->_is_nil();
+      SALOMEDS::SObject_var aHypSO  = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( anHyp   ) ) ) );
+      if ( !aMorSM->_is_nil() && !aHypSO->_is_nil() ) {
+       //Find or Create Applied Hypothesis root
+       SALOMEDS::SObject_var             AHR;
+       SALOMEDS::AttributeName_var       aName;
+       SALOMEDS::AttributeSelectable_var aSelAttr;
+       SALOMEDS::AttributePixMap_var     aPixmap;
+       SALOMEDS::StudyBuilder_var        aBuilder = aStudy->NewBuilder();
+       long                              aTag = aIsAlgo ? SMESH_Gen_i::GetRefOnAppliedAlgorithmsTag() : SMESH_Gen_i::GetRefOnAppliedHypothesisTag();
+
+       if ( !aMorSM->FindSubObject( aTag, AHR ) ) {
+         AHR      = aBuilder->NewObjectToTag( aMorSM, aTag );
+         anAttr   = aBuilder->FindOrCreateAttribute( AHR, "AttributeName" );
+         aName    = SALOMEDS::AttributeName::_narrow( anAttr );
+         aName    ->SetValue( aIsAlgo ? "Applied algorithms" : "Applied hypotheses" );
+         anAttr   = aBuilder->FindOrCreateAttribute( AHR, "AttributeSelectable" );
+         aSelAttr = SALOMEDS::AttributeSelectable::_narrow( anAttr );
+         aSelAttr ->SetSelectable( false );
+         anAttr   = aBuilder->FindOrCreateAttribute( AHR, "AttributePixMap" );
+         aPixmap  = SALOMEDS::AttributePixMap::_narrow( anAttr );
+         aPixmap  ->SetPixMap( aIsAlgo ? "ICON_SMESH_TREE_ALGO" : "ICON_SMESH_TREE_HYPO" );
+       }
+
+       SALOMEDS::SObject_var SO = aBuilder->NewObject( AHR );
+       aBuilder->Addreference( SO, aHypSO );
+      }
+    }
+  }
+
+  return ConvertHypothesisStatus(status);
+}
 
 //=============================================================================
 /*!
@@ -94,10 +392,11 @@ SMESH_Mesh_i::~SMESH_Mesh_i()
  */
 //=============================================================================
 
-CORBA::Boolean SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
-       SMESH::SMESH_Hypothesis_ptr anHyp) throw(SALOME::SALOME_Exception)
+SMESH_Hypothesis::Hypothesis_Status
+  SMESH_Mesh_i::addHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+                              SMESH::SMESH_Hypothesis_ptr anHyp)
 {
-       MESSAGE("AddHypothesis");
+       MESSAGE("addHypothesis");
        // **** proposer liste de subShape (selection multiple)
 
        GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape);
@@ -109,20 +408,99 @@ CORBA::Boolean SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
        if (CORBA::is_nil(myHyp))
                THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference",
                        SALOME::BAD_PARAM);
-       bool ret = false;
+
+       SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
        try
        {
                TopoDS_Shape myLocSubShape =
-                       _gen_i->_ShapeReader->GetShape(_geom, mySubShape);
+                       _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), mySubShape);
                int hypId = myHyp->GetId();
-               ret = _impl->AddHypothesis(myLocSubShape, hypId);
+               status = _impl->AddHypothesis(myLocSubShape, hypId);
+                if ( !SMESH_Hypothesis::IsStatusFatal(status) )
+                  _mapHypo[hypId] = myHyp;
        }
        catch(SALOME_Exception & S_ex)
        {
                THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
        }
-       return ret;
-};
+       return status;
+}
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+                                                        SMESH::SMESH_Hypothesis_ptr anHyp)
+     throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  SMESH_Hypothesis::Hypothesis_Status status = removeHypothesis( aSubShape, anHyp );
+
+  if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
+    SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+
+    if ( !aStudy->_is_nil() ) {
+      // Detect whether <aSubShape> refers to this mesh or its sub-mesh
+      SALOMEDS::GenericAttribute_var anAttr;
+      SALOMEDS::AttributeIOR_var     anIOR;
+      SALOMEDS::SObject_var aMeshSO  = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) );
+      if ( aMeshSO->_is_nil() )
+       return SMESH::HYP_UNKNOWN_FATAL;
+
+      SALOMEDS::SObject_var aMorSM, aRef;
+      CORBA::String_var aShapeIOR    = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( aSubShape ) );
+      SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( aMeshSO );
+
+      for ( it->InitEx( true ); it->More(); it->Next() ) {
+       SALOMEDS::SObject_var anObj = it->Value();
+       if ( anObj->ReferencedObject( aRef ) ) {
+         if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) {
+           anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
+           if ( strcmp( anIOR->Value(), aShapeIOR ) == 0 ) {
+             aMorSM = anObj->GetFather();
+             break;
+           }
+         }
+       }
+      }
+
+      bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( anHyp )->_is_nil();
+      SALOMEDS::SObject_var aHypSO  = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( anHyp ) ) ) );
+      if ( !aMorSM->_is_nil() && !aHypSO->_is_nil() ) {
+       // Remove a refernce to hypothesis or algorithm
+       SALOMEDS::SObject_var             AHR;
+       SALOMEDS::AttributeName_var       aName;
+       SALOMEDS::AttributeSelectable_var aSelAttr;
+       SALOMEDS::AttributePixMap_var     aPixmap;
+       SALOMEDS::StudyBuilder_var        aBuilder = aStudy->NewBuilder();
+       CORBA::String_var                 aHypIOR  = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( anHyp ) );
+       long                              aTag     = aIsAlgo ? SMESH_Gen_i::GetRefOnAppliedAlgorithmsTag() : SMESH_Gen_i::GetRefOnAppliedHypothesisTag();
+
+       if ( aMorSM->FindSubObject( aTag, AHR ) ) {
+         SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( AHR );
+         for ( ; it->More(); it->Next() ) {
+           SALOMEDS::SObject_var anObj = it->Value();
+           if ( anObj->ReferencedObject( aRef ) ) {
+             if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) {
+               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+               if ( strcmp( anIOR->Value(), aHypIOR ) == 0 ) {
+                 aBuilder->RemoveObject( anObj );
+                 break;
+               }
+             }
+           }
+         }
+       }
+      }
+    }
+  }
+
+  return ConvertHypothesisStatus(status);
+}
+
 
 //=============================================================================
 /*!
@@ -130,11 +508,11 @@ CORBA::Boolean SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
  */
 //=============================================================================
 
-CORBA::Boolean
-       SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
-       SMESH::SMESH_Hypothesis_ptr anHyp) throw(SALOME::SALOME_Exception)
+SMESH_Hypothesis::Hypothesis_Status
+  SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+                                 SMESH::SMESH_Hypothesis_ptr anHyp)
 {
-       MESSAGE("RemoveHypothesis");
+       MESSAGE("removeHypothesis()");
        // **** proposer liste de subShape (selection multiple)
 
        GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape);
@@ -144,23 +522,25 @@ CORBA::Boolean
 
        SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
        if (CORBA::is_nil(myHyp))
-               THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference",
+         THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference",
                        SALOME::BAD_PARAM);
 
-       bool ret = false;
+       SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
        try
        {
                TopoDS_Shape myLocSubShape =
-                       _gen_i->_ShapeReader->GetShape(_geom, mySubShape);
+                       _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), mySubShape);
                int hypId = myHyp->GetId();
-               ret = _impl->RemoveHypothesis(myLocSubShape, hypId);
+               status = _impl->RemoveHypothesis(myLocSubShape, hypId);
+                if ( !SMESH_Hypothesis::IsStatusFatal(status) )
+                  _mapHypo.erase( hypId );
        }
        catch(SALOME_Exception & S_ex)
        {
                THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
        }
-       return ret;
-};
+       return status;
+}
 
 //=============================================================================
 /*!
@@ -172,64 +552,286 @@ SMESH::ListOfHypothesis *
        SMESH_Mesh_i::GetHypothesisList(GEOM::GEOM_Shape_ptr aSubShape)
 throw(SALOME::SALOME_Exception)
 {
-       MESSAGE("GetHypothesisList");
-       // ****
-};
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE("GetHypothesisList");
+  GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape);
+  if (CORBA::is_nil(mySubShape))
+    THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
+                                SALOME::BAD_PARAM);
+  
+  SMESH::ListOfHypothesis_var aList = new SMESH::ListOfHypothesis();
+
+  try {
+    TopoDS_Shape myLocSubShape
+      = _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), mySubShape);
+    
+    const list<const SMESHDS_Hypothesis*>& aLocalList = _impl->GetHypothesisList( myLocSubShape );
+    int i = 0, n = aLocalList.size();
+    aList->length( n );
+
+    for ( list<const SMESHDS_Hypothesis*>::const_iterator anIt = aLocalList.begin(); i < n && anIt != aLocalList.end(); anIt++ ) {
+      SMESHDS_Hypothesis* aHyp = (SMESHDS_Hypothesis*)(*anIt);
+      if ( _mapHypo.find( aHyp->GetID() ) != _mapHypo.end() )
+       aList[i++] = SMESH::SMESH_Hypothesis::_narrow( _mapHypo[aHyp->GetID()] );
+    }
+
+    aList->length( i );
+  }
+  catch(SALOME_Exception & S_ex) {
+    THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+  }
+  
+  return aList._retn();
+}
 
 //=============================================================================
 /*!
  *  
  */
 //=============================================================================
-SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetElementsOnShape(GEOM::
-       GEOM_Shape_ptr aSubShape) throw(SALOME::SALOME_Exception)
+SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Shape_ptr aSubShape,
+                                                 const char*          theName ) 
+     throw(SALOME::SALOME_Exception)
 {
-       MESSAGE("SMESH_Mesh_i::GetElementsOnShape");
-       GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape);
-       if (CORBA::is_nil(mySubShape))
-               THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
-                       SALOME::BAD_PARAM);
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE("SMESH_Mesh_i::GetElementsOnShape");
+  GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape);
+  if (CORBA::is_nil(mySubShape))
+    THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
+                                SALOME::BAD_PARAM);
+  
+  int subMeshId = 0;
+  try {
+    TopoDS_Shape myLocSubShape
+      = _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), mySubShape);
+    
+    //Get or Create the SMESH_subMesh object implementation
+    
+    ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape);
+    subMeshId = mySubMesh->GetId();
+    
+    // create a new subMesh object servant if there is none for the shape
+    
+    if (_mapSubMesh.find(subMeshId) == _mapSubMesh.end()) {
+      SMESH::SMESH_subMesh_var subMesh = createSubMesh( aSubShape );
+      if ( _gen_i->CanPublishInStudy( subMesh ) ) {
+       SALOMEDS::SObject_var aSubmeshSO = _gen_i->PublishInStudy( _gen_i->GetCurrentStudy(), 
+                                                                  SALOMEDS::SObject::_nil(),
+                                                                  subMesh,
+                                                                  theName );
+         
+       // Add reference to <aSubShape> to the study
+       SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
+       SALOMEDS::SObject_var aShapeSO = aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string( aSubShape ) );
+       if ( !aSubmeshSO->_is_nil() && !aShapeSO->_is_nil() ) {
+         MESSAGE( "********** SMESH_Mesh_i::GetSubMesh(): adding shape reference..." )
+         SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
+         SALOMEDS::SObject_var SO = aBuilder->NewObjectToTag( aSubmeshSO, SMESH_Gen_i::GetRefOnShapeTag() );
+         aBuilder->Addreference( SO, aShapeSO );
+         MESSAGE( "********** SMESH_Mesh_i::GetSubMesh(): shape reference added" )
+       }
+      }
+    }
+  }
+  catch(SALOME_Exception & S_ex) {
+    THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+  }
+    
+  ASSERT(_mapSubMeshIor.find(subMeshId) != _mapSubMeshIor.end());
+  return SMESH::SMESH_subMesh::_duplicate(_mapSubMeshIor[subMeshId]);
+}
 
-       int subMeshId = 0;
-       try
-       {
-               SMESH_subMesh_i *subMeshServant;
-               TopoDS_Shape myLocSubShape
-                       = _gen_i->_ShapeReader->GetShape(_geom, mySubShape);
 
-               //Get or Create the SMESH_subMesh object implementation
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
 
-               ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape);
-               subMeshId = mySubMesh->GetId();
+void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
+     throw (SALOME::SALOME_Exception)
+{
+  MESSAGE("SMESH_Mesh_i::RemoveSubMesh");
+  if ( theSubMesh->_is_nil() )
+    return;
+
+  GEOM::GEOM_Shape_var aSubShape;
+  SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+  if ( !aStudy->_is_nil() )  {
+    // Remove submesh's SObject
+    SALOMEDS::SObject_var anSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( theSubMesh ) ) ) );
+    if ( !anSO->_is_nil() ) {
+      long aTag = SMESH_Gen_i::GetRefOnShapeTag(); 
+      SALOMEDS::SObject_var anObj, aRef;
+      if ( anSO->FindSubObject( aTag, anObj ) && anObj->ReferencedObject( aRef ) )
+       aSubShape = GEOM::GEOM_Shape::_narrow( aRef->GetObject() );
+
+      aStudy->NewBuilder()->RemoveObjectWithChildren( anSO );
+    }
+  }
+
+  removeSubMesh( theSubMesh, aSubShape.in() );
+}
 
-               // create a new subMesh object servant if there is none for the shape
 
-               if (_mapSubMesh.find(subMeshId) != _mapSubMesh.end())
-               {
-                       ASSERT(_mapSubMesh_i.find(subMeshId) != _mapSubMesh_i.end());
-                       subMeshServant = _mapSubMesh_i[subMeshId];
-               }
-               else
-               {
-                       // create and activate the CORBA servant of Mesh
-                       subMeshServant = new SMESH_subMesh_i(_gen_i, this, subMeshId);
-                       SMESH::SMESH_subMesh_var subMesh
-                               = SMESH::SMESH_subMesh::_narrow(subMeshServant->_this());
-                       _mapSubMesh[subMeshId] = mySubMesh;
-                       _mapSubMesh_i[subMeshId] = subMeshServant;
-                       _mapSubMeshIor[subMeshId]
-                               = SMESH::SMESH_subMesh::_duplicate(subMesh);
-               }
-       }
-       catch(SALOME_Exception & S_ex)
-       {
-               THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
-       }
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType,
+                                                 const char*        theName )
+     throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  SMESH::SMESH_Group_var aNewGroup = createGroup( theElemType, theName );
+
+  // Groups should be put under separate roots according to their type (nodes, edges, faces, volumes)
+  if ( _gen_i->CanPublishInStudy( aNewGroup ) ) {
+    SALOMEDS::SObject_var aGroupSO = _gen_i->PublishInStudy( _gen_i->GetCurrentStudy(), 
+                                                            SALOMEDS::SObject::_nil(),
+                                                            aNewGroup,
+                                                            theName );
+  }
+
+  return aNewGroup._retn();
+}
+
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_Group_ptr theGroup )
+    throw (SALOME::SALOME_Exception)
+{
+  if ( theGroup->_is_nil() )
+    return;
+
+  SMESH_Group_i* aGroup = dynamic_cast<SMESH_Group_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
+  if ( !aGroup )
+    return;
+
+  SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+  if ( !aStudy->_is_nil() )  {
+    // Remove group's SObject
+    SALOMEDS::SObject_var aGroupSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( theGroup ) ) ) );
+    if ( !aGroupSO->_is_nil() )
+      aStudy->NewBuilder()->RemoveObject( aGroupSO );
+  }
+
+  // Remove the group from SMESH data structures
+  removeGroup( aGroup->GetLocalID() );
+}
+
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Shape_ptr theSubShape ) {
+  TopoDS_Shape myLocSubShape = _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), theSubShape);
+
+  ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape);
+  int subMeshId = mySubMesh->GetId();
+  SMESH_subMesh_i *subMeshServant = new SMESH_subMesh_i(myPOA, _gen_i, this, subMeshId);
+  SMESH::SMESH_subMesh_var subMesh
+    = SMESH::SMESH_subMesh::_narrow(subMeshServant->_this());
+
+  _mapSubMesh[subMeshId] = mySubMesh;
+  _mapSubMesh_i[subMeshId] = subMeshServant;
+  _mapSubMeshIor[subMeshId]
+    = SMESH::SMESH_subMesh::_duplicate(subMesh);
 
-       ASSERT(_mapSubMeshIor.find(subMeshId) != _mapSubMeshIor.end());
-       return SMESH::SMESH_subMesh::_duplicate(_mapSubMeshIor[subMeshId]);
+  // register CORBA object for persistence
+  StudyContext* myStudyContext = _gen_i->GetCurrentStudyContext();
+  string iorString = SMESH_Gen_i::GetORB()->object_to_string( subMesh );
+  int nextId = myStudyContext->addObject( iorString );
+  MESSAGE( "Add submesh to map with id = "<< nextId << " and IOR = " << iorString.c_str() );
+
+  return subMesh._retn(); 
 }
 
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+void SMESH_Mesh_i::removeSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh, GEOM::GEOM_Shape_ptr theSubShape )
+{
+  MESSAGE("SMESH_Mesh_i::removeSubMesh()");
+  if ( theSubMesh->_is_nil() || theSubShape->_is_nil() )
+    return;
+
+  try {
+    SMESH::ListOfHypothesis_var aHypList = GetHypothesisList( theSubShape );
+    for ( int i = 0, n = aHypList->length(); i < n; i++ ) {
+      removeHypothesis( theSubShape, aHypList[i] );
+    }
+  }
+  catch( const SALOME::SALOME_Exception& ) {
+    MESSAGE("SMESH_Mesh_i::removeSubMesh(): exception caught!");
+  }
+
+  int subMeshId = theSubMesh->GetId();
+
+  _mapSubMesh.erase(subMeshId);
+  _mapSubMesh_i.erase(subMeshId);
+  _mapSubMeshIor.erase(subMeshId);
+  MESSAGE("SMESH_Mesh_i::removeSubMesh() completed");
+}
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+SMESH::SMESH_Group_ptr SMESH_Mesh_i::createGroup( SMESH::ElementType theElemType, const char* theName )
+{
+  int anId;
+  SMESH::SMESH_Group_var aGroup;
+  if ( _impl->AddGroup( (SMDSAbs_ElementType)theElemType, theName, anId ) ) {
+    SMESH_Group_i* aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId );
+    aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() );
+    _mapGroups[anId] = SMESH::SMESH_Group::_duplicate( aGroup );
+
+    // register CORBA object for persistence
+    StudyContext* myStudyContext = _gen_i->GetCurrentStudyContext();
+    string iorString = SMESH_Gen_i::GetORB()->object_to_string( aGroup );
+    int nextId = myStudyContext->addObject( iorString );
+    MESSAGE( "Add group to map with id = "<< nextId << " and IOR = " << iorString.c_str() );
+  }
+  return aGroup._retn();
+}
+
+
+//=============================================================================
+/*!
+ * SMESH_Mesh_i::removeGroup
+ *
+ * Should be called by ~SMESH_Group_i() 
+ */
+//=============================================================================
+
+void SMESH_Mesh_i::removeGroup( const int theId )
+{
+  MESSAGE("SMESH_Mesh_i::removeGroup()" );  
+  if ( _mapGroups.find( theId ) != _mapGroups.end() ) {
+    _mapGroups.erase( theId );
+    _impl->RemoveGroup( theId );
+  }
+}
+
+
 //=============================================================================
 /*!
  *  
@@ -472,43 +1074,6 @@ void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl)
        return *_impl;
 }
 
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-GEOM::GEOM_Gen_ptr SMESH_Mesh_i::GetGeomEngine()
-{
-       MESSAGE("SMESH_Mesh_i::GetGeomEngine");
-       return GEOM::GEOM_Gen::_duplicate(_geom);
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-void SMESH_Mesh_i::SetIor(SMESH::SMESH_Mesh_ptr myIor)
-{
-       MESSAGE("SMESH_Mesh_i::SetIor");
-       _myIor = SMESH::SMESH_Mesh::_duplicate(myIor);
-       ASSERT(!CORBA::is_nil(_myIor));
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-SMESH::SMESH_Mesh_ptr SMESH_Mesh_i::GetIor()
-{
-       MESSAGE("SMESH_Mesh_i::GetIor");
-       ASSERT(!CORBA::is_nil(_myIor));
-       return SMESH::SMESH_Mesh::_duplicate(_myIor);
-}
 
 //=============================================================================
 /*!
@@ -530,16 +1095,29 @@ SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor()
  */
 //=============================================================================
 
-void SMESH_Mesh_i::ExportMED(const char *file) throw(SALOME::SALOME_Exception)
+void SMESH_Mesh_i::ExportMED(const char *file, CORBA::Boolean auto_groups) throw(SALOME::SALOME_Exception)
 {
-       _impl->ExportMED(file);
+  Unexpect aCatch(SALOME_SalomeException);
+  SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+  if ( aStudy->_is_nil() ) 
+    return;
+
+  char* aMeshName = NULL;
+  SALOMEDS::SObject_var aMeshSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) );
+  if ( !aMeshSO->_is_nil() ) 
+    aMeshName = aMeshSO->GetName();
+
+  _impl->ExportMED( file, aMeshName, auto_groups );
 }
+
 void SMESH_Mesh_i::ExportDAT(const char *file) throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        _impl->ExportDAT(file);
 }
 void SMESH_Mesh_i::ExportUNV(const char *file) throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        _impl->ExportUNV(file);
 }
 
@@ -551,6 +1129,7 @@ void SMESH_Mesh_i::ExportUNV(const char *file) throw(SALOME::SALOME_Exception)
 
 SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        SMESH_MEDMesh_i *aMedMesh = new SMESH_MEDMesh_i(this);
        SALOME_MED::MESH_var aMesh = aMedMesh->_this();
        return aMesh._retn();
@@ -563,6 +1142,7 @@ SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()throw(SALOME::SALOME_Exception)
 //=============================================================================
 CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        return _impl->NbNodes();
 }
 
@@ -573,6 +1153,7 @@ CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception)
 //=============================================================================
 CORBA::Long SMESH_Mesh_i::NbEdges()throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        return _impl->NbEdges();
 }
 
@@ -583,16 +1164,19 @@ CORBA::Long SMESH_Mesh_i::NbEdges()throw(SALOME::SALOME_Exception)
 //=============================================================================
 CORBA::Long SMESH_Mesh_i::NbFaces()throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        return _impl->NbFaces();
 }
 
 CORBA::Long SMESH_Mesh_i::NbTriangles()throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        return _impl->NbTriangles();
 }
 
 CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        return _impl->NbQuadrangles();
 }
 
@@ -603,19 +1187,34 @@ CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception)
 //=============================================================================
 CORBA::Long SMESH_Mesh_i::NbVolumes()throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        return _impl->NbVolumes();
 }
 
 CORBA::Long SMESH_Mesh_i::NbTetras()throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        return _impl->NbTetras();
 }
 
 CORBA::Long SMESH_Mesh_i::NbHexas()throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        return _impl->NbHexas();
 }
 
+CORBA::Long SMESH_Mesh_i::NbPyramids()throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+       return _impl->NbPyramids();
+}
+
+CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+       return _impl->NbPrisms();
+}
+
 //=============================================================================
 /*!
  *  
@@ -623,5 +1222,18 @@ CORBA::Long SMESH_Mesh_i::NbHexas()throw(SALOME::SALOME_Exception)
 //=============================================================================
 CORBA::Long SMESH_Mesh_i::NbSubMesh()throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        return _impl->NbSubMesh();
 }
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+char* SMESH_Mesh_i::Dump()
+{
+  std::ostringstream os;
+  _impl->Dump( os );
+  return CORBA::string_dup( os.str().c_str() );
+}
index ca631431e5e2e249da5b2ef5efe15e1e6b8d09e9..48243c177fc1ed8c802f8cab4f8d3ef3350e7bf8 100644 (file)
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Group)
 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
 #include CORBA_CLIENT_HEADER(GEOM_Gen)
 #include CORBA_CLIENT_HEADER(GEOM_Shape)
 #include CORBA_CLIENT_HEADER(MED)
 
 class SMESH_Gen_i;
+class SMESH_Group_i;
 
+#include "SMESH_Hypothesis.hxx"
 #include "SMESH_Mesh.hxx"
-#include "SMESH_Gen_i.hxx"
 #include "SMESH_subMesh_i.hxx"
 #include "SMESH_subMesh.hxx"
 #include "SMESH_topo.hxx"
 
 #include <map>
 
+#include "SALOME_GenericObj_i.hh"
+
 class SMESH_Mesh_i:
-  public POA_SMESH::SMESH_Mesh
+  public virtual POA_SMESH::SMESH_Mesh,
+  public virtual SALOME::GenericObj_i
 {
 public:
   SMESH_Mesh_i();
-  SMESH_Mesh_i(SMESH_Gen_i* myGen_i,
-              GEOM::GEOM_Gen_ptr geomEngine,
-              CORBA::Long studyId,
-              int localId);
+  SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
+                SMESH_Gen_i*            myGen_i,
+               CORBA::Long             studyId );
 
   virtual ~SMESH_Mesh_i();
 
   // --- CORBA
+  void SetShape( GEOM::GEOM_Shape_ptr theShape )
+    throw (SALOME::SALOME_Exception);
 
-  CORBA::Boolean AddHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
-                              SMESH::SMESH_Hypothesis_ptr anHyp)
+  SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+                                         SMESH::SMESH_Hypothesis_ptr anHyp)
     throw (SALOME::SALOME_Exception);
 
-  CORBA::Boolean  RemoveHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
-                                  SMESH::SMESH_Hypothesis_ptr anHyp)
+  SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+                                            SMESH::SMESH_Hypothesis_ptr anHyp)
     throw (SALOME::SALOME_Exception);
 
   SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Shape_ptr aSubShape)
     throw (SALOME::SALOME_Exception);
 
-  SMESH::SMESH_subMesh_ptr GetElementsOnShape(GEOM::GEOM_Shape_ptr aSubShape)
+  SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Shape_ptr aSubShape, const char* theName)
+    throw (SALOME::SALOME_Exception);
+
+  void RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
+    throw (SALOME::SALOME_Exception);
+
+  SMESH::SMESH_Group_ptr CreateGroup( SMESH::ElementType theElemType, const char* theName )
+    throw (SALOME::SALOME_Exception);
+  
+  void RemoveGroup( SMESH::SMESH_Group_ptr theGroup )
     throw (SALOME::SALOME_Exception);
 
 //    SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
@@ -94,13 +109,17 @@ public:
   // --- C++ interface
 
   void SetImpl(::SMESH_Mesh* impl);
-
   ::SMESH_Mesh& GetImpl();         // :: force no namespace here
-  GEOM::GEOM_Gen_ptr GetGeomEngine();
-  void SetIor(SMESH::SMESH_Mesh_ptr myIor);
-  SMESH::SMESH_Mesh_ptr GetIor();
 
-  void ExportMED( const char* file )
+  SMESH_Gen_i* GetGen() { return _gen_i; }
+  
+  /*!
+   * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
+   */
+  SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
+    throw (SALOME::SALOME_Exception);
+
+  void ExportMED( const char* file, CORBA::Boolean auto_groups )
     throw (SALOME::SALOME_Exception);
   void ExportDAT( const char* file )
     throw (SALOME::SALOME_Exception);
@@ -134,25 +153,49 @@ public:
   CORBA::Long NbHexas()
     throw (SALOME::SALOME_Exception);
   
+  CORBA::Long NbPyramids()
+    throw (SALOME::SALOME_Exception);
+  
+  CORBA::Long NbPrisms()
+    throw (SALOME::SALOME_Exception);
+  
   CORBA::Long NbSubMesh()
     throw (SALOME::SALOME_Exception);
+
+  char* Dump();
+  
+  // Internal methods not available through CORBA
+  // They are called by corresponding interface methods
+  SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+                                                    SMESH::SMESH_Hypothesis_ptr anHyp);
+
+  SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+                                                       SMESH::SMESH_Hypothesis_ptr anHyp);
   
+  bool setShape( GEOM::GEOM_Shape_ptr theShape );
+
+  int importMEDFile( const char* theFileName, const char* theMeshName );
+
+  SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Shape_ptr theSubShape );
+
+  void removeSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh, GEOM::GEOM_Shape_ptr theSubShape );
+
+  SMESH::SMESH_Group_ptr createGroup( SMESH::ElementType theElemType, const char* theName );
+
+  void removeGroup( const int theId );
 
   map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
   map<int, ::SMESH_subMesh*> _mapSubMesh;   //NRI
 
 private:
-
+  static int myIdGenerator;
   ::SMESH_Mesh* _impl;  // :: force no namespace here
   SMESH_Gen_i* _gen_i;
-  //   CORBA::ORB_ptr _orb;
-//   SMESH_topo* _topo;   // all local TopoDS_Shape of subShapes
   int _id;          // id given by creator (unique within the creator instance)
-  GEOM::GEOM_Gen_var _geom;
   int _studyId;
-  //  int _localId; // id attributed to all objects created by Mesh_i
-  map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor;
-  SMESH::SMESH_Mesh_var _myIor;
+  map<int, SMESH::SMESH_subMesh_ptr>    _mapSubMeshIor;
+  map<int, SMESH::SMESH_Group_ptr>      _mapGroups;
+  map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;
 };
 
 #endif
index 3ed4d296571979c468fd50a90f71ca30a99b0ad5..8c6563ffd1cddda956e8058c88dc48584661d150 100644 (file)
@@ -35,6 +35,7 @@ using namespace std;
 #include "Utils_CorbaException.hxx"
 #include "utilities.h"
 #include "OpUtil.hxx"
+#include "Utils_ExceptHandlers.hxx"
 
 //=============================================================================
 /*!
@@ -43,6 +44,7 @@ using namespace std;
 //=============================================================================
 
 SMESH_subMesh_i::SMESH_subMesh_i()
+     : SALOME::GenericObj_i( PortableServer::POA::_nil() )
 {
   MESSAGE("SMESH_subMesh_i::SMESH_subMesh_i default, not for use");
     ASSERT(0);
@@ -54,14 +56,17 @@ SMESH_subMesh_i::SMESH_subMesh_i()
  */
 //=============================================================================
 
-SMESH_subMesh_i::SMESH_subMesh_i(SMESH_Gen_i* gen_i,
-                                SMESH_Mesh_i* mesh_i,
-                                int localId)
+SMESH_subMesh_i::SMESH_subMesh_i( PortableServer::POA_ptr thePOA,
+                                 SMESH_Gen_i*            gen_i,
+                                 SMESH_Mesh_i*           mesh_i,
+                                 int                     localId )
+     : SALOME::GenericObj_i( thePOA )
 {
   MESSAGE("SMESH_subMesh_i::SMESH_subMesh_i");
   _gen_i = gen_i;
   _mesh_i = mesh_i;
   _localId = localId;
+  thePOA->activate_object( this );
   // ****
 }
 //=============================================================================
@@ -85,8 +90,16 @@ SMESH_subMesh_i::~SMESH_subMesh_i()
 CORBA::Long SMESH_subMesh_i::GetNumberOfElements()
   throw (SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
   MESSAGE("SMESH_subMesh_i::GetNumberOfElements");
-  // ****
+  if ( _mesh_i->_mapSubMesh.find( _localId ) == _mesh_i->_mapSubMesh.end() )
+    return 0;
+
+  SMESHDS_SubMesh* aSubMeshDS = _mesh_i->_mapSubMesh[_localId]->GetSubMeshDS();
+  if ( aSubMeshDS == NULL )
+    return 0;
+
+  return aSubMeshDS->NbElements();
 }
 
 //=============================================================================
@@ -98,8 +111,16 @@ CORBA::Long SMESH_subMesh_i::GetNumberOfElements()
 CORBA::Long SMESH_subMesh_i::GetNumberOfNodes()
   throw (SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
   MESSAGE("SMESH_subMesh_i::GetNumberOfNodes");
-  // ****
+  if ( _mesh_i->_mapSubMesh.find( _localId ) == _mesh_i->_mapSubMesh.end() )
+    return 0;
+
+  SMESHDS_SubMesh* aSubMeshDS = _mesh_i->_mapSubMesh[_localId]->GetSubMeshDS();
+  if ( aSubMeshDS == NULL )
+    return 0;
+
+  return aSubMeshDS->NbNodes();
 }
 
 //=============================================================================
@@ -111,8 +132,74 @@ CORBA::Long SMESH_subMesh_i::GetNumberOfNodes()
 SMESH::long_array* SMESH_subMesh_i::GetElementsId()
   throw (SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
   MESSAGE("SMESH_subMesh_i::GetElementsId");
-  // ****
+  SMESH::long_array_var aResult = new SMESH::long_array();
+
+  if ( _mesh_i->_mapSubMesh.find( _localId ) == _mesh_i->_mapSubMesh.end() )
+    return aResult._retn();
+
+  SMESHDS_SubMesh* aSubMeshDS = _mesh_i->_mapSubMesh[_localId]->GetSubMeshDS();
+  if ( aSubMeshDS == NULL )
+    return aResult._retn();
+
+  aResult->length( aSubMeshDS->NbElements() );
+  SMDS_ElemIteratorPtr anIt = aSubMeshDS->GetElements();
+  for ( int i = 0, n = aSubMeshDS->NbElements(); i < n && anIt->more(); i++ )
+    aResult[i] = anIt->next()->GetID();
+
+  return aResult._retn();
+}
+
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+SMESH::long_array* SMESH_subMesh_i::GetElementsByType( SMESH::ElementType theElemType )
+    throw (SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE("SMESH_subMesh_i::GetElementsByType");
+  SMESH::long_array_var aResult = new SMESH::long_array();
+
+  if ( _mesh_i->_mapSubMesh.find( _localId ) == _mesh_i->_mapSubMesh.end() )
+    return aResult._retn();
+
+  SMESHDS_SubMesh* aSubMeshDS = _mesh_i->_mapSubMesh[_localId]->GetSubMeshDS();
+  if ( aSubMeshDS == NULL )
+    return aResult._retn();
+
+  int i = 0;
+  if ( theElemType == SMESH::ALL )
+    aResult->length( aSubMeshDS->NbElements() + aSubMeshDS->NbNodes() );
+  else if ( theElemType == SMESH::NODE )
+    aResult->length( aSubMeshDS->NbNodes() );
+  else
+    aResult->length( aSubMeshDS->NbElements() );
+
+  int n = aResult->length();
+
+  if ( theElemType == SMESH::ALL || theElemType == SMESH::NODE ) {
+    SMDS_NodeIteratorPtr anIt = aSubMeshDS->GetNodes();
+    while ( i < n && anIt->more() )
+      aResult[i++] = anIt->next()->GetID();
+  }
+
+  if ( theElemType == SMESH::ALL || theElemType != SMESH::NODE ) {
+    SMDS_ElemIteratorPtr anIt = aSubMeshDS->GetElements();
+    while ( i < n && anIt->more() ) {
+      const SMDS_MeshElement* anElem = anIt->next();
+      if ( theElemType == SMESH::ALL || anElem->GetType() == (SMDSAbs_ElementType)theElemType )
+       aResult[i++] = anElem->GetID();
+    }
+  }
+
+  aResult->length( i );
+
+  return aResult._retn();
 }
 
 //=============================================================================
@@ -124,8 +211,23 @@ SMESH::long_array* SMESH_subMesh_i::GetElementsId()
 SMESH::long_array* SMESH_subMesh_i::GetNodesId()
   throw (SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
   MESSAGE("SMESH_subMesh_i::GetNodesId");
-  // ****
+  SMESH::long_array_var aResult = new SMESH::long_array();
+
+  if ( _mesh_i->_mapSubMesh.find( _localId ) == _mesh_i->_mapSubMesh.end() )
+    return aResult._retn();
+
+  SMESHDS_SubMesh* aSubMeshDS = _mesh_i->_mapSubMesh[_localId]->GetSubMeshDS();
+  if ( aSubMeshDS == NULL )
+    return aResult._retn();
+
+  aResult->length( aSubMeshDS->NbNodes() );
+  SMDS_NodeIteratorPtr anIt = aSubMeshDS->GetNodes();
+  for ( int i = 0, n = aSubMeshDS->NbNodes(); i < n && anIt->more(); i++ )
+    aResult[i] = anIt->next()->GetID();
+
+  return aResult._retn();
 }
 
 //=============================================================================
@@ -137,9 +239,9 @@ SMESH::long_array* SMESH_subMesh_i::GetNodesId()
 SMESH::SMESH_Mesh_ptr SMESH_subMesh_i::GetFather()
   throw (SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
   MESSAGE("SMESH_subMesh_i::GetFather");
-  SMESH::SMESH_Mesh_var meshIor = _mesh_i->GetIor();
-  return SMESH::SMESH_Mesh::_duplicate(meshIor);
+  return _mesh_i->_this();
 }
 
 //=============================================================================
@@ -162,6 +264,7 @@ CORBA::Long SMESH_subMesh_i::GetId()
 SALOME_MED::FAMILY_ptr SMESH_subMesh_i::GetFamily()
   throw (SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
   SALOME_MED::MESH_var MEDMesh = GetFather()->GetMEDMesh();
 
   SALOME_MED::Family_array_var families = 
index 0708405e5f746ce661cc2b56e92967bb097c4fcf..9b456af4bb1b5d501373944c57d15317bd01d3fa 100644 (file)
 #include CORBA_CLIENT_HEADER(GEOM_Shape)
 #include CORBA_CLIENT_HEADER(MED)
 
+#include "SALOME_GenericObj_i.hh"
+
 class SMESH_Gen_i;
 class SMESH_Mesh_i;
 
 class SMESH_subMesh_i:
-  public POA_SMESH::SMESH_subMesh
+  public virtual POA_SMESH::SMESH_subMesh,
+  public virtual SALOME::GenericObj_i
 {
 public:
   SMESH_subMesh_i();
-  SMESH_subMesh_i(SMESH_Gen_i* gen_i,
-                 SMESH_Mesh_i* mesh_i,
-                 int localId);
+  SMESH_subMesh_i( PortableServer::POA_ptr thePOA,
+                   SMESH_Gen_i*            gen_i,
+                  SMESH_Mesh_i*           mesh_i,
+                  int                     localId );
   ~SMESH_subMesh_i();
 
   CORBA::Long GetNumberOfElements()
@@ -57,6 +61,9 @@ public:
   
   SMESH::long_array* GetElementsId()
     throw (SALOME::SALOME_Exception);
+
+  SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
+    throw (SALOME::SALOME_Exception);
   
   SMESH::long_array* GetNodesId()
     throw (SALOME::SALOME_Exception);
index 3023a28d01c5a529d91eb607f19ccce1f813c4cd..e823f9028009d33f84f2fe5493373065a8710c23 100644 (file)
@@ -25,6 +25,8 @@
 #  Module : SMESH
 
 import SMESH
+import StdMeshers
+
 import smeshpy
 import salome
 from salome import sg
@@ -76,41 +78,41 @@ ide=geompy.addToStudyInFather(face,edge,name)
 
 # ---- launch SMESH, init a Mesh with the box
 gen=smeshpy.smeshpy()
-mesh=gen.Init(idb)
+mesh=gen.CreateMesh(idb)
 
 # ---- create Hypothesis
 
 print "-------------------------- create Hypothesis"
 print "-------------------------- LocalLength"
-hyp1=gen.CreateHypothesis("LocalLength")
+hyp1=gen.CreateHypothesis("LocalLength","libStdMeshersEngine.so")
 print hyp1.GetName()
 print hyp1.GetId()
-hypo1 = hyp1._narrow(SMESH.SMESH_LocalLength)
+hypo1 = hyp1._narrow(StdMeshers.StdMeshers_LocalLength)
 print hypo1.GetLength()
 hypo1.SetLength(100)
 print hypo1.GetLength()
 
 print "-------------------------- bidon"
-hyp3=gen.CreateHypothesis("bidon")
+hyp3=gen.CreateHypothesis("bidon","")
 
 print "-------------------------- NumberOfSegments"
-hyp3=gen.CreateHypothesis("NumberOfSegments")
-hypo3=hyp3._narrow(SMESH.SMESH_NumberOfSegments)
+hyp3=gen.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
+hypo3=hyp3._narrow(StdMeshers.StdMeshers_NumberOfSegments)
 hypo3.SetNumberOfSegments(7)
 print hypo3.GetName()
 print hypo3.GetNumberOfSegments()
 print hypo3.GetId()
 
 print "-------------------------- MaxElementArea"
-hyp4=gen.CreateHypothesis("MaxElementArea")
-hypo4=hyp4._narrow(SMESH.SMESH_MaxElementArea)
+hyp4=gen.CreateHypothesis("MaxElementArea","libStdMeshersEngine.so")
+hypo4=hyp4._narrow(StdMeshers.StdMeshers_MaxElementArea)
 hypo4.SetMaxElementArea(5000)
 print hypo4.GetName()
 print hypo4.GetMaxElementArea()
 print hypo4.GetId()
 
 print "-------------------------- Regular_1D"
-alg1=gen.CreateHypothesis("Regular_1D")
+alg1=gen.CreateHypothesis("Regular_1D","libStdMeshersEngine.so")
 print alg1.GetName()
 print alg1.GetId()
 algo1=alg1._narrow(SMESH.SMESH_Algo)
@@ -118,18 +120,18 @@ listHyp=algo1.GetCompatibleHypothesis()
 for hyp in listHyp:
     print hyp
     
-algo_1=alg1._narrow(SMESH.SMESH_Regular_1D)
+algo_1=alg1._narrow(StdMeshers.StdMeshers_Regular_1D)
 print algo_1.GetId()
 
 print "-------------------------- MEFISTO_2D"
-alg2=gen.CreateHypothesis("MEFISTO_2D")
+alg2=gen.CreateHypothesis("MEFISTO_2D","libStdMeshersEngine.so")
 print alg2.GetName()
 print alg2.GetId()
 algo2=alg2._narrow(SMESH.SMESH_Algo)
 listHyp=algo2.GetCompatibleHypothesis()
 for hyp in listHyp:
     print hyp
-algo_2=alg2._narrow(SMESH.SMESH_MEFISTO_2D)
+algo_2=alg2._narrow(StdMeshers.StdMeshers_MEFISTO_2D)
 print algo_2.GetId()
 
 # ---- add hypothesis to edge
index ccc54cacf5bf48ea85b51c832ba0c6d853268bf8..9fb4709e7e31216ceb1a114de9172fe36295751c 100644 (file)
@@ -44,14 +44,15 @@ class smeshpy:
             self._smesh = salome.lcc.FindOrLoadComponent("FactoryServer","SMESH")
         except:
             MESSAGE( "exception in smeshpy:__init__" )
-        self._studyId = salome.myStudyId
+        self._study = salome.myStudy
+        self._smesh.SetCurrentStudy(self._study)
 
     #--------------------------------------------------------------------------
 
-    def Init(self, shapeId):
+    def CreateMesh(self, shapeId):
         try:
             shape = salome.IDToObject(shapeId)
-            aMesh = self._smesh.Init(self._geom, self._studyId, shape)
+            aMesh = self._smesh.CreateMesh(shape)
             return aMesh
         except:
             MESSAGE( "exception in smeshpy:Init" )
@@ -59,9 +60,9 @@ class smeshpy:
 
     #--------------------------------------------------------------------------
 
-    def CreateHypothesis(self, name):
+    def CreateHypothesis(self, name, libname):
         try:
-            hyp = self._smesh.CreateHypothesis(name,self._studyId)
+            hyp = self._smesh.CreateHypothesis(name, libname)
             return hyp
         except:
             MESSAGE( "exception in smeshpy:CreateHypothesis" )
index 2965e0403453bbbc80b6c4e643f18219546b82ae..343100a93658a5aa248d4ca7ffcd4d6bdad476a5 100644 (file)
@@ -43,6 +43,7 @@ EXPORT_PYSCRIPTS = libSMESH_Swig.py \
                   SMESH_test1.py \
                   SMESH_test2.py \
                   SMESH_test3.py \
+                  SMESH_test4.py \
                   SMESH_mechanic.py \
                   SMESH_mechanic_tetra.py \
                   SMESH_fixation.py \
@@ -53,7 +54,10 @@ EXPORT_PYSCRIPTS = libSMESH_Swig.py \
                   SMESH_box2_tetra.py \
                   SMESH_box3_tetra.py \
                   SMESH_flight_skin.py \
-                  SMESH_Partition1_tetra.py
+                  SMESH_Partition1_tetra.py\
+                  batchmode_mefisto.py \
+                  SMESH_controls.py \
+                  SMESH_freebord.py
 
 LIB_CLIENT_IDL = SALOMEDS.idl \
                 SALOME_Exception.idl \
@@ -63,14 +67,16 @@ LIB_CLIENT_IDL = SALOMEDS.idl \
                 SMESH_Mesh.idl \
                 SMESH_Hypothesis.idl \
                 SMESH_BasicHypothesis.idl \
+                SMESH_Group.idl \
                 SALOME_ModuleCatalog.idl \
                 SALOME_Component.idl \
+                SALOME_GenericObj.idl \
                 MED.idl
 
 EXPORT_SHAREDPYSCRIPTS=SMESH_shared_modules.py
 
 CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -DHAVE_CONFIG_H
 LIBS+= $(PYTHON_LIBS)
-LDFLAGS+= -lSMESHGUI
+LDFLAGS+= -lSMESHGUI -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeGenericObj
 
 @CONCLUDE@
index 1478f01b7996cd9eea4cd117c6f6dee2888a94e1..fd72c8e183dd03b997d2bf1dd525d30d8b26cc2d 100644 (file)
-#\r
-# Tetrahedrization of the geometry generated by the Python script GEOM_Partition1.py\r
-# Hypothesis and algorithms for the mesh generation are global\r
-#\r
-#%Make geometry (like CEA script (A1)) using Partition algorithm% from OCC\r
-# -- Rayon de la bariere\r
-\r
-barier_height = 7.0\r
-barier_radius = 5.6 / 2 # Rayon de la bariere\r
-colis_radius = 1.0 / 2  # Rayon du colis\r
-colis_step = 2.0        # Distance s\89parant deux colis\r
-cc_width = 0.11         # Epaisseur du complement de colisage\r
-\r
-# --\r
-\r
-cc_radius = colis_radius + cc_width\r
-from math import sqrt\r
-colis_center = sqrt(2.0)*colis_step/2\r
-\r
-# --\r
-\r
-import geompy\r
-geom = geompy.geom\r
-\r
-boolean_common  = 1\r
-boolean_cut     = 2\r
-boolean_fuse    = 3\r
-boolean_section = 4\r
-\r
-# --\r
-\r
-barier = geompy.MakeCylinder(\r
-    geom.MakePointStruct(0.,0.,0.),\r
-    geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),\r
-    barier_radius,\r
-    barier_height)\r
-\r
-# --\r
-\r
-colis = geompy.MakeCylinder(\r
-    geom.MakePointStruct(0.,0.,0.),\r
-    geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),\r
-    colis_radius,\r
-    barier_height)\r
-\r
-cc = geompy.MakeCylinder(\r
-    geom.MakePointStruct(0.,0.,0.),\r
-    geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),\r
-    cc_radius,\r
-    barier_height)\r
-\r
-colis_cc = geompy.MakeCompound(\r
-    [colis._get_Name(), cc._get_Name()])\r
-\r
-colis_cc = geompy.MakeTranslation(\r
-    colis_cc, colis_center, 0.0, 0.0)\r
-\r
-colis_cc_multi = geompy.MakeMultiRotation1D(\r
-    colis_cc,\r
-    geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),\r
-    geom.MakePointStruct(0.,0.,0.),\r
-    4)\r
-\r
-# --\r
-\r
-alveole = geompy.Partition(\r
-    [colis_cc_multi._get_Name(), barier._get_Name()])\r
-\r
-ShapeTypeShell     = 3\r
-ShapeTypeFace      = 4\r
-ShapeTypeEdge      = 6\r
-\r
-print "Analysis of the geometry to mesh (right after the Partition) :"\r
-\r
-subShellList=geompy.SubShapeAll(alveole,ShapeTypeShell)\r
-subFaceList=geompy.SubShapeAll(alveole,ShapeTypeFace)\r
-subEdgeList=geompy.SubShapeAll(alveole,ShapeTypeEdge)\r
-\r
-print "number of Shells in alveole : ",len(subShellList)\r
-print "number of Faces in alveole : ",len(subFaceList)\r
-print "number of Edges in alveole : ",len(subEdgeList)\r
-\r
-subshapes = geompy.SubShapeAll( alveole, geompy.ShapeType["SHAPE"] )\r
-\r
-## there are 9 subshapes\r
-\r
-comp1 = geompy.MakeCompound( [ subshapes[0]._get_Name(), subshapes[1]._get_Name() ] );\r
-comp2 = geompy.MakeCompound( [ subshapes[2]._get_Name(), subshapes[3]._get_Name() ] );\r
-comp3 = geompy.MakeCompound( [ subshapes[4]._get_Name(), subshapes[5]._get_Name() ] );\r
-comp4 = geompy.MakeCompound( [ subshapes[6]._get_Name(), subshapes[7]._get_Name() ] );\r
-\r
-compIORs = []\r
-compIORs.append( comp1._get_Name() );\r
-compIORs.append( comp2._get_Name() );\r
-compIORs.append( comp3._get_Name() );\r
-compIORs.append( comp4._get_Name() );\r
-comp = geompy.MakeCompound( compIORs );\r
-\r
-alveole = geompy.MakeCompound( [ comp._get_Name(), subshapes[8]._get_Name() ]);\r
-       \r
-idalveole= geompy.addToStudy(alveole, "alveole")\r
-\r
-print "Analysis of the geometry to mesh (right after the MakeCompound) :"\r
-\r
-subShellList=geompy.SubShapeAll(alveole,ShapeTypeShell)\r
-subFaceList=geompy.SubShapeAll(alveole,ShapeTypeFace)\r
-subEdgeList=geompy.SubShapeAll(alveole,ShapeTypeEdge)\r
-\r
-print "number of Shells in alveole : ",len(subShellList)\r
-print "number of Faces in alveole : ",len(subFaceList)\r
-print "number of Edges in alveole : ",len(subEdgeList)\r
-\r
-status=geompy.CheckShape(alveole)\r
-print " check status ", status\r
-\r
-# ---- launch SMESH\r
-\r
-import salome\r
-from salome import sg\r
-\r
-import SMESH\r
-import smeshpy\r
-\r
-smeshgui = salome.ImportComponentGUI("SMESH")\r
-smeshgui.Init(salome.myStudyId)\r
-\r
-gen=smeshpy.smeshpy()\r
-\r
-# ---- create Hypothesis\r
-\r
-print "-------------------------- create Hypothesis (In this case global hypothesis are used)"\r
-\r
-print "-------------------------- NumberOfSegments"\r
-\r
-numberOfSegments = 10\r
-\r
-hyp1=gen.CreateHypothesis("NumberOfSegments")\r
-hypNbSeg=hyp1._narrow(SMESH.SMESH_NumberOfSegments)\r
-hypNbSeg.SetNumberOfSegments(numberOfSegments)\r
-hypNbSegID = hypNbSeg.GetId()\r
-print hypNbSeg.GetName()\r
-print hypNbSegID\r
-print hypNbSeg.GetNumberOfSegments()\r
-\r
-idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )\r
-smeshgui.SetName(idseg, "NumberOfSegments")\r
-\r
-print "-------------------------- MaxElementArea"\r
-\r
-maxElementArea = 0.1\r
-\r
-hyp2=gen.CreateHypothesis("MaxElementArea")\r
-hypArea=hyp2._narrow(SMESH.SMESH_MaxElementArea)\r
-hypArea.SetMaxElementArea(maxElementArea)\r
-print hypArea.GetName()\r
-print hypArea.GetId()\r
-print hypArea.GetMaxElementArea()\r
-\r
-idarea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )\r
-smeshgui.SetName(idarea, "MaxElementArea")\r
-\r
-print "-------------------------- MaxElementVolume"\r
-\r
-maxElementVolume = 0.5\r
-\r
-hyp3=gen.CreateHypothesis("MaxElementVolume")\r
-hypVolume=hyp3._narrow(SMESH.SMESH_MaxElementVolume)\r
-hypVolume.SetMaxElementVolume(maxElementVolume)\r
-print hypVolume.GetName()\r
-print hypVolume.GetId()\r
-print hypVolume.GetMaxElementVolume()\r
-\r
-idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )\r
-smeshgui.SetName(idvolume, "MaxElementVolume")\r
-\r
-# ---- create Algorithms\r
-\r
-print "-------------------------- create Algorithms"\r
-\r
-print "-------------------------- Regular_1D"\r
-\r
-hypothesis=gen.CreateHypothesis("Regular_1D")\r
-regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)\r
-regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )\r
-smeshgui.SetName(regularID, "Wire Discretisation")\r
-\r
-print "-------------------------- MEFISTO_2D"\r
-\r
-hypothesis=gen.CreateHypothesis("MEFISTO_2D")\r
-mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)\r
-mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )\r
-smeshgui.SetName(mefistoID, "MEFISTO_2D")\r
-\r
-print "-------------------------- NETGEN_3D"\r
-\r
-hypothesis=gen.CreateHypothesis("NETGEN_3D")\r
-netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)\r
-netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )\r
-smeshgui.SetName(netgenID, "NETGEN_3D")\r
-\r
-# ---- init a Mesh with the alveole\r
-\r
-mesh=gen.Init(idalveole)\r
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )\r
-smeshgui.SetName(idmesh, "MeshAlveole")\r
-smeshgui.SetShape(idalveole, idmesh)\r
-\r
-# ---- add hypothesis to alveole\r
-\r
-print "-------------------------- add hypothesis to alveole"\r
-\r
-ret=mesh.AddHypothesis(alveole,regular1D)\r
-print ret\r
-ret=mesh.AddHypothesis(alveole,hypNbSeg)\r
-print ret\r
-ret=mesh.AddHypothesis(alveole,mefisto2D)\r
-print ret\r
-ret=mesh.AddHypothesis(alveole,hypArea)\r
-print ret\r
-ret=mesh.AddHypothesis(alveole,netgen3D)\r
-print ret\r
-ret=mesh.AddHypothesis(alveole,hypVolume)\r
-print ret\r
-\r
-smeshgui.SetAlgorithms( idmesh, regularID)\r
-smeshgui.SetHypothesis( idmesh, idseg )\r
-smeshgui.SetAlgorithms( idmesh, mefistoID )\r
-smeshgui.SetHypothesis( idmesh, idarea )\r
-smeshgui.SetAlgorithms( idmesh, netgenID )\r
-smeshgui.SetHypothesis( idmesh, idvolume )\r
-\r
-sg.updateObjBrowser(1)\r
-\r
-\r
-print "-------------------------- compute the mesh of alveole "\r
-ret=gen.Compute(mesh,idalveole)\r
-print ret\r
-if ret != 0:\r
-    log=mesh.GetLog(0) # no erase trace\r
-    for linelog in log:\r
-        print linelog\r
-else:\r
-    print "problem when computing the mesh"\r
-\r
-sg.updateObjBrowser(1)\r
+#
+# Tetrahedrization of the geometry generated by the Python script GEOM_Partition1.py
+# Hypothesis and algorithms for the mesh generation are global
+#
+#%Make geometry (like CEA script (A1)) using Partition algorithm% from OCC
+# -- Rayon de la bariere
+
+import salome
+import geompy
+
+import StdMeshers
+import NETGENPlugin
+
+geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
+
+geom.GetCurrentStudy(salome.myStudy._get_StudyId())
+smesh.SetCurrentStudy(salome.myStudy)
+
+smeshgui = salome.ImportComponentGUI("SMESH")
+smeshgui.Init(salome.myStudyId);
+
+#---------------------------------------------------------------
+
+barier_height = 7.0
+barier_radius = 5.6 / 2 # Rayon de la bariere
+colis_radius = 1.0 / 2  # Rayon du colis
+colis_step = 2.0        # Distance s\89parant deux colis
+cc_width = 0.11         # Epaisseur du complement de colisage
+
+# --
+
+cc_radius = colis_radius + cc_width
+from math import sqrt
+colis_center = sqrt(2.0)*colis_step/2
+
+# --
+
+boolean_common  = 1
+boolean_cut     = 2
+boolean_fuse    = 3
+boolean_section = 4
+
+# --
+
+barier = geompy.MakeCylinder(
+    geom.MakePointStruct(0.,0.,0.),
+    geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
+    barier_radius,
+    barier_height)
+
+# --
+
+colis = geompy.MakeCylinder(
+    geom.MakePointStruct(0.,0.,0.),
+    geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
+    colis_radius,
+    barier_height)
+
+cc = geompy.MakeCylinder(
+    geom.MakePointStruct(0.,0.,0.),
+    geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
+    cc_radius,
+    barier_height)
+
+colis_cc = geompy.MakeCompound(
+    [colis._get_Name(), cc._get_Name()])
+
+colis_cc = geompy.MakeTranslation(
+    colis_cc, colis_center, 0.0, 0.0)
+
+colis_cc_multi = geompy.MakeMultiRotation1D(
+    colis_cc,
+    geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
+    geom.MakePointStruct(0.,0.,0.),
+    4)
+
+# --
+
+alveole = geompy.Partition(
+    [colis_cc_multi._get_Name(), barier._get_Name()])
+
+ShapeTypeShell     = 3
+ShapeTypeFace      = 4
+ShapeTypeEdge      = 6
+
+print "Analysis of the geometry to mesh (right after the Partition) :"
+
+subShellList=geompy.SubShapeAll(alveole,ShapeTypeShell)
+subFaceList=geompy.SubShapeAll(alveole,ShapeTypeFace)
+subEdgeList=geompy.SubShapeAll(alveole,ShapeTypeEdge)
+
+print "number of Shells in alveole : ",len(subShellList)
+print "number of Faces in alveole : ",len(subFaceList)
+print "number of Edges in alveole : ",len(subEdgeList)
+
+subshapes = geompy.SubShapeAll( alveole, geompy.ShapeType["SHAPE"] )
+
+## there are 9 subshapes
+
+comp1 = geompy.MakeCompound( [ subshapes[0]._get_Name(), subshapes[1]._get_Name() ] );
+comp2 = geompy.MakeCompound( [ subshapes[2]._get_Name(), subshapes[3]._get_Name() ] );
+comp3 = geompy.MakeCompound( [ subshapes[4]._get_Name(), subshapes[5]._get_Name() ] );
+comp4 = geompy.MakeCompound( [ subshapes[6]._get_Name(), subshapes[7]._get_Name() ] );
+
+compIORs = []
+compIORs.append( comp1._get_Name() );
+compIORs.append( comp2._get_Name() );
+compIORs.append( comp3._get_Name() );
+compIORs.append( comp4._get_Name() );
+comp = geompy.MakeCompound( compIORs );
+
+alveole = geompy.MakeCompound( [ comp._get_Name(), subshapes[8]._get_Name() ]);
+       
+idalveole= geompy.addToStudy(alveole, "alveole")
+
+print "Analysis of the geometry to mesh (right after the MakeCompound) :"
+
+subShellList=geompy.SubShapeAll(alveole,ShapeTypeShell)
+subFaceList=geompy.SubShapeAll(alveole,ShapeTypeFace)
+subEdgeList=geompy.SubShapeAll(alveole,ShapeTypeEdge)
+
+print "number of Shells in alveole : ",len(subShellList)
+print "number of Faces in alveole : ",len(subFaceList)
+print "number of Edges in alveole : ",len(subEdgeList)
+
+status=geompy.CheckShape(alveole)
+print " check status ", status
+
+# ---- launch SMESH
+
+# ---- create Hypothesis
+
+print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
+
+print "-------------------------- NumberOfSegments"
+
+numberOfSegments = 10
+
+hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
+hypNbSeg.SetNumberOfSegments(numberOfSegments)
+print hypNbSeg.GetName()
+print hypNbSeg.GetId()
+print hypNbSeg.GetNumberOfSegments()
+
+smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
+
+print "-------------------------- MaxElementArea"
+
+maxElementArea = 0.1
+
+hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
+hypArea.SetMaxElementArea(maxElementArea)
+print hypArea.GetName()
+print hypArea.GetId()
+print hypArea.GetMaxElementArea()
+
+smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_0.1")
+
+print "-------------------------- MaxElementVolume"
+
+maxElementVolume = 0.5
+
+hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
+hypVolume.SetMaxElementVolume(maxElementVolume)
+print hypVolume.GetName()
+print hypVolume.GetId()
+print hypVolume.GetMaxElementVolume()
+
+smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_0.5")
+
+# ---- create Algorithms
+
+print "-------------------------- create Algorithms"
+
+print "-------------------------- Regular_1D"
+
+regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
+smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
+
+print "-------------------------- MEFISTO_2D"
+
+mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
+smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
+
+print "-------------------------- NETGEN_3D"
+
+netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
+smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
+
+# ---- init a Mesh with the alveole
+shape_mesh = salome.IDToObject( idalveole )
+
+mesh=smesh.CreateMesh(shape_mesh)
+smeshgui.SetName(salome.ObjectToID(mesh), "MeshAlveole")
+
+# ---- add hypothesis to alveole
+
+print "-------------------------- add hypothesis to alveole"
+
+mesh.AddHypothesis(shape_mesh,regular1D)
+mesh.AddHypothesis(shape_mesh,hypNbSeg)
+
+mesh.AddHypothesis(shape_mesh,mefisto2D)
+mesh.AddHypothesis(shape_mesh,hypArea)
+
+mesh.AddHypothesis(shape_mesh,netgen3D)
+mesh.AddHypothesis(shape_mesh,hypVolume)
+
+print "-------------------------- compute the mesh of alveole "
+ret=smesh.Compute(mesh,shape_mesh)
+
+if ret != 0:
+    log=mesh.GetLog(0) # no erase trace
+    for linelog in log:
+        print linelog
+    print "Information about the Mesh_mechanic:"
+    print "Number of nodes      : ", mesh.NbNodes()
+    print "Number of edges      : ", mesh.NbEdges()
+    print "Number of faces      : ", mesh.NbFaces()
+    print "Number of triangles  : ", mesh.NbTriangles()
+    print "Number of volumes: ", mesh.NbVolumes()
+    print "Number of tetrahedrons: ", mesh.NbTetras() 
+else:
+    print "problem when computing the mesh"
+    
+salome.sg.updateObjBrowser(1)
index 6db29ba29e7d68538722e3674267383bcf882756..d5e6979f6f4945bf14df324b8329a64a58b0153c 100644 (file)
@@ -4,15 +4,16 @@
 #
 
 import salome
-from salome import sg
-
 import geompy
 
-import SMESH
-import smeshpy
+import StdMeshers
+import NETGENPlugin
+
+geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
 
-geom = geompy.geom
-myBuilder = geompy.myBuilder
+smeshgui = salome.ImportComponentGUI("SMESH")
+smeshgui.Init(salome.myStudyId);
 
 ShapeTypeShell     = 3
 ShapeTypeFace      = 4
@@ -65,12 +66,8 @@ print "number of Shells in shell : ",len(subShellList)
 print "number of Faces in shell : ",len(subFaceList)
 print "number of Edges in shell : ",len(subEdgeList)
 
-# ---- launch SMESH
-
-smeshgui = salome.ImportComponentGUI("SMESH")
-smeshgui.Init(salome.myStudyId)
 
-gen=smeshpy.smeshpy()
+### ---------------------------- SMESH --------------------------------------
 
 # ---- create Hypothesis
 
@@ -80,44 +77,40 @@ print "-------------------------- NumberOfSegments"
 
 numberOfSegments = 10
 
-hyp1=gen.CreateHypothesis("NumberOfSegments")
-hypNbSeg=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
+hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
 hypNbSeg.SetNumberOfSegments(numberOfSegments)
-hypNbSegID = hypNbSeg.GetId()
+
 print hypNbSeg.GetName()
-print hypNbSegID
+print hypNbSeg.GetId()
 print hypNbSeg.GetNumberOfSegments()
 
-idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
-smeshgui.SetName(idseg, "NumberOfSegments")
+smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
 
 print "-------------------------- MaxElementArea"
 
 maxElementArea = 500
 
-hyp2=gen.CreateHypothesis("MaxElementArea")
-hypArea=hyp2._narrow(SMESH.SMESH_MaxElementArea)
+hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
 hypArea.SetMaxElementArea(maxElementArea)
+
 print hypArea.GetName()
 print hypArea.GetId()
 print hypArea.GetMaxElementArea()
 
-idarea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )
-smeshgui.SetName(idarea, "MaxElementArea")
+smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
 
 print "-------------------------- MaxElementVolume"
 
 maxElementVolume = 500
 
-hyp3=gen.CreateHypothesis("MaxElementVolume")
-hypVolume=hyp3._narrow(SMESH.SMESH_MaxElementVolume)
+hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
 hypVolume.SetMaxElementVolume(maxElementVolume)
+
 print hypVolume.GetName()
 print hypVolume.GetId()
 print hypVolume.GetMaxElementVolume()
 
-idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
-smeshgui.SetName(idvolume, "MaxElementVolume")
+smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
 
 # ---- create Algorithms
 
@@ -125,65 +118,52 @@ print "-------------------------- create Algorithms"
 
 print "-------------------------- Regular_1D"
 
-hypothesis=gen.CreateHypothesis("Regular_1D")
-regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
-regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
-smeshgui.SetName(regularID, "Wire Discretisation")
+regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
+smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
 
 print "-------------------------- MEFISTO_2D"
 
-hypothesis=gen.CreateHypothesis("MEFISTO_2D")
-mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
-mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
-smeshgui.SetName(mefistoID, "MEFISTO_2D")
+mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
+smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
 
 print "-------------------------- NETGEN_3D"
 
-hypothesis=gen.CreateHypothesis("NETGEN_3D")
-netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
-netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
-smeshgui.SetName(netgenID, "NETGEN_3D")
+netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
+smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
 
 # ---- init a Mesh with the shell
 
-mesh=gen.Init(idshell)
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
-smeshgui.SetName(idmesh, "MeshBox2")
-smeshgui.SetShape(idshell, idmesh)
+mesh = smesh.CreateMesh(shell)
+smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox2")
 
 # ---- add hypothesis to shell
 
 print "-------------------------- add hypothesis to shell"
 
-ret=mesh.AddHypothesis(shell,regular1D)
-print ret
-ret=mesh.AddHypothesis(shell,hypNbSeg)
-print ret
-ret=mesh.AddHypothesis(shell,mefisto2D)
-print ret
-ret=mesh.AddHypothesis(shell,hypArea)
-print ret
-ret=mesh.AddHypothesis(shell,netgen3D)
-print ret
-ret=mesh.AddHypothesis(shell,hypVolume)
-print ret
+mesh.AddHypothesis(shell,regular1D)
+mesh.AddHypothesis(shell,hypNbSeg)
 
-smeshgui.SetAlgorithms( idmesh, regularID)
-smeshgui.SetHypothesis( idmesh, idseg )
-smeshgui.SetAlgorithms( idmesh, mefistoID )
-smeshgui.SetHypothesis( idmesh, idarea )
-smeshgui.SetAlgorithms( idmesh, netgenID )
-smeshgui.SetHypothesis( idmesh, idvolume )
+mesh.AddHypothesis(shell,mefisto2D)
+mesh.AddHypothesis(shell,hypArea)
 
-sg.updateObjBrowser(1)
+mesh.AddHypothesis(shell,netgen3D)
+mesh.AddHypothesis(shell,hypVolume)
 
+salome.sg.updateObjBrowser(1)
 
 print "-------------------------- compute shell"
-ret=gen.Compute(mesh,idshell)
+ret= smesh.Compute(mesh,shell)
 print ret
-log=mesh.GetLog(0) # no erase trace
-for linelog in log:
-    print linelog
-
-
-sg.updateObjBrowser(1)
+if ret != 0:
+    log=mesh.GetLog(0) # no erase trace
+    for linelog in log:
+        print linelog
+    print "Information about the MeshBox2:"
+    print "Number of nodes       : ", mesh.NbNodes()
+    print "Number of edges       : ", mesh.NbEdges()
+    print "Number of faces       : ", mesh.NbFaces()
+    print "Number of triangles   : ", mesh.NbTriangles()
+    print "Number of volumes     : ", mesh.NbVolumes()
+    print "Number of tetrahedrons: ", mesh.NbTetras()
+else:
+    print "probleme when computing the mesh"
index 000a2611bb0bff35998ce9eff8bd507a64b1276d..adb7d4944730c27fbbcc8e5d4fc208451c9dcfd3 100644 (file)
@@ -5,15 +5,16 @@
 #
 
 import salome
-from salome import sg
-
 import geompy
 
-import SMESH
-import smeshpy
+import StdMeshers
+import NETGENPlugin
+
+geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
 
-geom = geompy.geom
-myBuilder = geompy.myBuilder
+smeshgui = salome.ImportComponentGUI("SMESH")
+smeshgui.Init(salome.myStudyId);
 
 ShapeTypeShell     = 3
 ShapeTypeFace      = 4
@@ -77,12 +78,8 @@ print "number of Shells in shell : ",len(subShellList)
 print "number of Faces in shell : ",len(subFaceList)
 print "number of Edges in shell : ",len(subEdgeList)
 
-# ---- launch SMESH
-
-smeshgui = salome.ImportComponentGUI("SMESH")
-smeshgui.Init(salome.myStudyId)
 
-gen=smeshpy.smeshpy()
+### ---------------------------- SMESH --------------------------------------
 
 # ---- create Hypothesis
 
@@ -92,44 +89,40 @@ print "-------------------------- NumberOfSegments"
 
 numberOfSegments = 10
 
-hyp1=gen.CreateHypothesis("NumberOfSegments")
-hypNbSeg=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
+hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
 hypNbSeg.SetNumberOfSegments(numberOfSegments)
-hypNbSegID = hypNbSeg.GetId()
+
 print hypNbSeg.GetName()
-print hypNbSegID
+print hypNbSeg.GetId()
 print hypNbSeg.GetNumberOfSegments()
 
-idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
-smeshgui.SetName(idseg, "NumberOfSegments")
+smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
 
 print "-------------------------- MaxElementArea"
 
 maxElementArea = 500
 
-hyp2=gen.CreateHypothesis("MaxElementArea")
-hypArea=hyp2._narrow(SMESH.SMESH_MaxElementArea)
+hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
 hypArea.SetMaxElementArea(maxElementArea)
+
 print hypArea.GetName()
 print hypArea.GetId()
 print hypArea.GetMaxElementArea()
 
-idarea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )
-smeshgui.SetName(idarea, "MaxElementArea")
+smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
 
 print "-------------------------- MaxElementVolume"
 
 maxElementVolume = 500
 
-hyp3=gen.CreateHypothesis("MaxElementVolume")
-hypVolume=hyp3._narrow(SMESH.SMESH_MaxElementVolume)
+hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
 hypVolume.SetMaxElementVolume(maxElementVolume)
+
 print hypVolume.GetName()
 print hypVolume.GetId()
 print hypVolume.GetMaxElementVolume()
 
-idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
-smeshgui.SetName(idvolume, "MaxElementVolume")
+smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
 
 # ---- create Algorithms
 
@@ -137,65 +130,52 @@ print "-------------------------- create Algorithms"
 
 print "-------------------------- Regular_1D"
 
-hypothesis=gen.CreateHypothesis("Regular_1D")
-regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
-regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
-smeshgui.SetName(regularID, "Wire Discretisation")
+regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
+smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
 
 print "-------------------------- MEFISTO_2D"
 
-hypothesis=gen.CreateHypothesis("MEFISTO_2D")
-mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
-mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
-smeshgui.SetName(mefistoID, "MEFISTO_2D")
+mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
+smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
 
 print "-------------------------- NETGEN_3D"
 
-hypothesis=gen.CreateHypothesis("NETGEN_3D")
-netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
-netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
-smeshgui.SetName(netgenID, "NETGEN_3D")
+netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
+smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
 
 # ---- init a Mesh with the shell
 
-mesh=gen.Init(idshell)
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
-smeshgui.SetName(idmesh, "MeshBox2")
-smeshgui.SetShape(idshell, idmesh)
+mesh = smesh.CreateMesh(shell)
+smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox3")
 
 # ---- add hypothesis to shell
 
 print "-------------------------- add hypothesis to shell"
 
-ret=mesh.AddHypothesis(shell,regular1D)
-print ret
-ret=mesh.AddHypothesis(shell,hypNbSeg)
-print ret
-ret=mesh.AddHypothesis(shell,mefisto2D)
-print ret
-ret=mesh.AddHypothesis(shell,hypArea)
-print ret
-ret=mesh.AddHypothesis(shell,netgen3D)
-print ret
-ret=mesh.AddHypothesis(shell,hypVolume)
-print ret
+mesh.AddHypothesis(shell,regular1D)
+mesh.AddHypothesis(shell,hypNbSeg)
 
-smeshgui.SetAlgorithms( idmesh, regularID)
-smeshgui.SetHypothesis( idmesh, idseg )
-smeshgui.SetAlgorithms( idmesh, mefistoID )
-smeshgui.SetHypothesis( idmesh, idarea )
-smeshgui.SetAlgorithms( idmesh, netgenID )
-smeshgui.SetHypothesis( idmesh, idvolume )
+mesh.AddHypothesis(shell,mefisto2D)
+mesh.AddHypothesis(shell,hypArea)
 
-sg.updateObjBrowser(1)
+mesh.AddHypothesis(shell,netgen3D)
+mesh.AddHypothesis(shell,hypVolume)
 
+salome.sg.updateObjBrowser(1)
 
 print "-------------------------- compute shell"
-ret=gen.Compute(mesh,idshell)
+ret= smesh.Compute(mesh,shell)
 print ret
-log=mesh.GetLog(0) # no erase trace
-for linelog in log:
-    print linelog
-
-
-sg.updateObjBrowser(1)
+if ret != 0:
+    log=mesh.GetLog(0) # no erase trace
+    for linelog in log:
+        print linelog
+    print "Information about the MeshBox3:"
+    print "Number of nodes       : ", mesh.NbNodes()
+    print "Number of edges       : ", mesh.NbEdges()
+    print "Number of faces       : ", mesh.NbFaces()
+    print "Number of triangles   : ", mesh.NbTriangles()
+    print "Number of volumes     : ", mesh.NbVolumes()
+    print "Number of tetrahedrons: ", mesh.NbTetras()
+else:
+    print "probleme when computing the mesh"
index 99744949ee72a8c8ae6e9b6bfa1b8ae9ed5429a6..38effb77780817ee11444fa589fef7677b32b242 100644 (file)
@@ -4,21 +4,18 @@
 #
 
 import salome
-from salome import sg
-
 import geompy
 
-import SMESH
-import smeshpy
-
-# -----------------------------------------------------------------------------
+import StdMeshers
+import NETGENPlugin
 
-##geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
-##myBuilder = salome.myStudy.NewBuilder()
+geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
 
-geom = geompy.geom
-myBuilder = geompy.myBuilder
+smeshgui = salome.ImportComponentGUI("SMESH")
+smeshgui.Init(salome.myStudyId);
 
+# -----------------------------------------------------------------------------
 ShapeTypeShell     = 3
 ShapeTypeFace      = 4
 ShapeTypeEdge      = 6
@@ -38,12 +35,8 @@ print "number of Shells in box : ",len(subShellList)
 print "number of Faces in box : ",len(subFaceList)
 print "number of Edges in box : ",len(subEdgeList)
 
-# ---- launch SMESH
 
-smeshgui = salome.ImportComponentGUI("SMESH")
-smeshgui.Init(salome.myStudyId)
-
-gen=smeshpy.smeshpy()
+### ---------------------------- SMESH --------------------------------------
 
 # ---- create Hypothesis
 
@@ -53,44 +46,40 @@ print "-------------------------- NumberOfSegments"
 
 numberOfSegments = 10
 
-hyp1=gen.CreateHypothesis("NumberOfSegments")
-hypNbSeg=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
+hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
 hypNbSeg.SetNumberOfSegments(numberOfSegments)
-hypNbSegID = hypNbSeg.GetId()
+
 print hypNbSeg.GetName()
-print hypNbSegID
+print hypNbSeg.GetId()
 print hypNbSeg.GetNumberOfSegments()
 
-idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
-smeshgui.SetName(idseg, "NumberOfSegments")
+smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
 
 print "-------------------------- MaxElementArea"
 
 maxElementArea = 500
 
-hyp2=gen.CreateHypothesis("MaxElementArea")
-hypArea=hyp2._narrow(SMESH.SMESH_MaxElementArea)
+hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
 hypArea.SetMaxElementArea(maxElementArea)
+
 print hypArea.GetName()
 print hypArea.GetId()
 print hypArea.GetMaxElementArea()
 
-idarea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )
-smeshgui.SetName(idarea, "MaxElementArea")
+smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
 
 print "-------------------------- MaxElementVolume"
 
 maxElementVolume = 500
 
-hyp3=gen.CreateHypothesis("MaxElementVolume")
-hypVolume=hyp3._narrow(SMESH.SMESH_MaxElementVolume)
+hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
 hypVolume.SetMaxElementVolume(maxElementVolume)
+
 print hypVolume.GetName()
 print hypVolume.GetId()
 print hypVolume.GetMaxElementVolume()
 
-idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
-smeshgui.SetName(idvolume, "MaxElementVolume")
+smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
 
 # ---- create Algorithms
 
@@ -98,65 +87,52 @@ print "-------------------------- create Algorithms"
 
 print "-------------------------- Regular_1D"
 
-hypothesis=gen.CreateHypothesis("Regular_1D")
-regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
-regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
-smeshgui.SetName(regularID, "Wire Discretisation")
+regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
+smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
 
 print "-------------------------- MEFISTO_2D"
 
-hypothesis=gen.CreateHypothesis("MEFISTO_2D")
-mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
-mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
-smeshgui.SetName(mefistoID, "MEFISTO_2D")
+mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
+smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
 
 print "-------------------------- NETGEN_3D"
 
-hypothesis=gen.CreateHypothesis("NETGEN_3D")
-netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
-netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
-smeshgui.SetName(netgenID, "NETGEN_3D")
+netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
+smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
 
 # ---- init a Mesh with the boxe
 
-mesh=gen.Init(idbox)
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
-smeshgui.SetName(idmesh, "MeshBox")
-smeshgui.SetShape(idbox, idmesh)
+mesh = smesh.CreateMesh(box)
+smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox")
 
 # ---- add hypothesis to the boxe
 
-print "-------------------------- add hypothesis to the boxe"
+print "-------------------------- add hypothesis to the box"
 
-ret=mesh.AddHypothesis(box,regular1D)
-print ret
-ret=mesh.AddHypothesis(box,hypNbSeg)
-print ret
-ret=mesh.AddHypothesis(box,mefisto2D)
-print ret
-ret=mesh.AddHypothesis(box,hypArea)
-print ret
-ret=mesh.AddHypothesis(box,netgen3D)
-print ret
-ret=mesh.AddHypothesis(box,hypVolume)
-print ret
+mesh.AddHypothesis(box,regular1D)
+mesh.AddHypothesis(box,hypNbSeg)
 
-smeshgui.SetAlgorithms( idmesh, regularID)
-smeshgui.SetHypothesis( idmesh, idseg )
-smeshgui.SetAlgorithms( idmesh, mefistoID )
-smeshgui.SetHypothesis( idmesh, idarea )
-smeshgui.SetAlgorithms( idmesh, netgenID )
-smeshgui.SetHypothesis( idmesh, idvolume )
+mesh.AddHypothesis(box,mefisto2D)
+mesh.AddHypothesis(box,hypArea)
 
-sg.updateObjBrowser(1)
+mesh.AddHypothesis(box,netgen3D)
+mesh.AddHypothesis(box,hypVolume)
 
+salome.sg.updateObjBrowser(1)
 
 print "-------------------------- compute the mesh of the boxe"
-ret=gen.Compute(mesh,idbox)
+ret=smesh.Compute(mesh,box)
 print ret
-log=mesh.GetLog(0) # no erase trace
-for linelog in log:
-    print linelog
-
-
-sg.updateObjBrowser(1)
+if ret != 0:
+    log=mesh.GetLog(0) # no erase trace
+    for linelog in log:
+        print linelog
+    print "Information about the MeshBox:"
+    print "Number of nodes       : ", mesh.NbNodes()
+    print "Number of edges       : ", mesh.NbEdges()
+    print "Number of faces       : ", mesh.NbFaces()
+    print "Number of triangles   : ", mesh.NbTriangles()
+    print "Number of volumes     : ", mesh.NbVolumes()
+    print "Number of tetrahedrons: ", mesh.NbTetras()
+else:
+    print "probleme when computing the mesh"
index 93accf52e48d03cf4d724e21bacb62107a23fada..9158ee567a384334160ec310a9d8399b27f9041f 100644 (file)
 #  $Header$
 
 import salome
-from salome import sg
-
 import geompy
-
 import math
 
 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
-myBuilder = salome.myStudy.NewBuilder()
 
 ShapeTypeCompSolid = 1
 ShapeTypeSolid     = 2
@@ -290,9 +286,10 @@ cylcongy0 = geom.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq +2*marge)
 bcong1=geom.MakeBoolean(bcong1,cylcongx0,2)
 bcong2=geom.MakeBoolean(bcong2,cylcongx0,2)
 bcong1=geom.MakeBoolean(bcong1,cylcongy0,2)
+#NRI : inverse order of BOP
+bcong3=geom.MakeBoolean(bcong3,cylcongy0,2)
 bcong3=geom.MakeBoolean(bcong3,cylcongx3,2)
 bcong4=geom.MakeBoolean(bcong4,cylcongx3,2)
-bcong3=geom.MakeBoolean(bcong3,cylcongy0,2)
 
 pf1 = geom.MakePointStruct(0., y0h, z3)
 pf2 = geom.MakePointStruct(0., y1, z3)
index 2916e6a09b098f0ee41824893768d5518967da41..2d12c7f47580f35f32afdfcd7cbc1f1a58b25b0d 100644 (file)
@@ -5,14 +5,13 @@
 #
 
 import SMESH_fixation
-import SMESH
-import smeshpy
+
+import StdMeshers
 
 compshell = SMESH_fixation.compshell
 idcomp = SMESH_fixation.idcomp
 geompy = SMESH_fixation.geompy
 salome = SMESH_fixation.salome
-sg = SMESH_fixation.sg
 
 ShapeTypeShell     = 3
 ShapeTypeFace      = 4
@@ -30,13 +29,12 @@ print "number of Edges in compshell : ",len(subEdgeList)
 status=geompy.CheckShape(compshell)
 print " check status ", status
 
-### ---- launch SMESH
+### ---------------------------- SMESH --------------------------------------
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
 
 smeshgui = salome.ImportComponentGUI("SMESH")
 smeshgui.Init(salome.myStudyId)
 
-gen=smeshpy.smeshpy()
-
 ### ---- create Hypothesis
 
 print "-------------------------- create Hypothesis"
@@ -45,16 +43,14 @@ print "-------------------------- NumberOfSegments"
 
 numberOfSegments = 5
 
-hyp1=gen.CreateHypothesis("NumberOfSegments")
-hypNbSeg=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
+hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
 hypNbSeg.SetNumberOfSegments(numberOfSegments)
-hypNbSegID = hypNbSeg.GetId()
+
 print hypNbSeg.GetName()
-print hypNbSegID
+print hypNbSeg.GetId()
 print hypNbSeg.GetNumberOfSegments()
 
-idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
-smeshgui.SetName(idseg, "NumberOfSegments")
+smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5")
 
 # ---- create Algorithms
 
@@ -62,61 +58,54 @@ print "-------------------------- create Algorithms"
 
 print "-------------------------- Regular_1D"
 
-hypothesis=gen.CreateHypothesis("Regular_1D")
-regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
-regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
-smeshgui.SetName(regularID, "Wire Discretisation")
+regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
+
+smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
 
 print "-------------------------- Quadrangle_2D"
 
-hypothesis=gen.CreateHypothesis("Quadrangle_2D")
-quad2D = hypothesis._narrow(SMESH.SMESH_Quadrangle_2D)
-quadID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(quad2D) )
-smeshgui.SetName(quadID, "Quadrangle_2D")
+quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
+
+smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
 
 print "-------------------------- Hexa_3D"
 
-hypothesis=gen.CreateHypothesis("Hexa_3D")
-hexa3D = hypothesis._narrow(SMESH.SMESH_Hexa_3D)
-hexaID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(hexa3D) )
-smeshgui.SetName(hexaID, "Hexa_3D")
+hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
+
+smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
 
 # ---- init a Mesh with the compshell
+shape_mesh = salome.IDToObject( idcomp  )
+
+mesh=smesh.CreateMesh(shape_mesh)
+smeshgui.SetName(salome.ObjectToID(mesh), "MeshCompShell")
 
-mesh=gen.Init(idcomp)
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
-smeshgui.SetName(idmesh, "MeshcompShel")
-smeshgui.SetShape(idcomp, idmesh)
 
 # ---- add hypothesis to compshell
 
 print "-------------------------- add hypothesis to compshell"
 
-ret=mesh.AddHypothesis(compshell,regular1D)
-print ret
-ret=mesh.AddHypothesis(compshell,hypNbSeg)
-print ret
-ret=mesh.AddHypothesis(compshell,quad2D)
-print ret
-ret=mesh.AddHypothesis(compshell,hexa3D)
-print ret
-
-smeshgui.SetAlgorithms( idmesh, regularID)
-smeshgui.SetHypothesis( idmesh, idseg )
-smeshgui.SetAlgorithms( idmesh, quadID )
-smeshgui.SetAlgorithms( idmesh, hexaID )
+mesh.AddHypothesis(shape_mesh,regular1D)
+mesh.AddHypothesis(shape_mesh,hypNbSeg)
 
-sg.updateObjBrowser(1)
+mesh.AddHypothesis(shape_mesh,quad2D)
+mesh.AddHypothesis(shape_mesh,hexa3D)
 
+salome.sg.updateObjBrowser(1)
 
 print "-------------------------- compute compshell"
-ret=gen.Compute(mesh,idcomp)
+ret=smesh.Compute(mesh, shape_mesh)
 print ret
 if ret != 0:
     log=mesh.GetLog(0) # no erase trace
     for linelog in log:
         print linelog
+    print "Information about the MeshcompShel:"
+    print "Number of nodes       : ", mesh.NbNodes()
+    print "Number of edges       : ", mesh.NbEdges()
+    print "Number of faces       : ", mesh.NbFaces()
+    print "Number of quadrangles : ", mesh.NbQuadrangles()
+    print "Number of volumes     : ", mesh.NbVolumes()
+    print "Number of hexahedrons : ", mesh.NbHexas()
 else:
     print "problem when Computing the mesh"
-
-sg.updateObjBrowser(1)
index 57e9c913dea88243945fc0fb1b1b849a87af8760..d429fe958b4c6c37351c6aa0f4e9fe81905d194b 100644 (file)
@@ -4,15 +4,14 @@
 # Hypothesis and algorithms for the mesh generation are global
 #
 
+import StdMeshers
+import NETGENPlugin
 import SMESH_fixation
-import SMESH
-import smeshpy
 
 compshell = SMESH_fixation.compshell
 idcomp = SMESH_fixation.idcomp
 geompy = SMESH_fixation.geompy
 salome = SMESH_fixation.salome
-sg = SMESH_fixation.sg
 
 ShapeTypeShell     = 3
 ShapeTypeFace      = 4
@@ -30,13 +29,12 @@ print "number of Edges in compshell : ",len(subEdgeList)
 status=geompy.CheckShape(compshell)
 print " check status ", status
 
-### ---- launch SMESH
+### ---------------------------- SMESH --------------------------------------
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
 
 smeshgui = salome.ImportComponentGUI("SMESH")
 smeshgui.Init(salome.myStudyId)
 
-gen=smeshpy.smeshpy()
-
 ### ---- create Hypothesis
 
 print "-------------------------- create Hypothesis"
@@ -45,44 +43,41 @@ print "-------------------------- NumberOfSegments"
 
 numberOfSegments = 5
 
-hypothesis=gen.CreateHypothesis("NumberOfSegments")
-hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
+hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
 hypNbSeg.SetNumberOfSegments(numberOfSegments)
-hypNbSegID = hypNbSeg.GetId()
+
 print hypNbSeg.GetName()
-print hypNbSegID
+print hypNbSeg.GetId()
 print hypNbSeg.GetNumberOfSegments()
 
-idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
-smeshgui.SetName(idseg, "NumberOfSegments")
+smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5")
 
 print "-------------------------- MaxElementArea"
 
-maxElementArea = 80
+## maxElementArea = 80
 
-hypothesis=gen.CreateHypothesis("MaxElementArea")
-hypArea=hypothesis._narrow(SMESH.SMESH_MaxElementArea)
-hypArea.SetMaxElementArea(maxElementArea)
-print hypArea.GetName()
-print hypArea.GetId()
-print hypArea.GetMaxElementArea()
+## hypArea=smesh.CreateHypothesis("MaxElementArea")
+## hypArea.SetMaxElementArea(maxElementArea)
+## print hypArea.GetName()
+## print hypArea.GetId()
+## print hypArea.GetMaxElementArea()
+## smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_160")
+hypLengthFromEdges=smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
+smeshgui.SetName(salome.ObjectToID(hypLengthFromEdges), "LengthFromEdges")
 
-idarea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )
-smeshgui.SetName(idarea, "MaxElementArea")
 
 print "-------------------------- MaxElementVolume"
 
-maxElementVolume = 150
+maxElementVolume = 1000
 
-hypothesis=gen.CreateHypothesis("MaxElementVolume")
-hypVolume=hypothesis._narrow(SMESH.SMESH_MaxElementVolume)
+hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
 hypVolume.SetMaxElementVolume(maxElementVolume)
+
 print hypVolume.GetName()
 print hypVolume.GetId()
 print hypVolume.GetMaxElementVolume()
 
-idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
-smeshgui.SetName(idvolume, "MaxElementVolume")
+smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_1000")
 
 # ---- create Algorithms
 
@@ -90,66 +85,56 @@ print "-------------------------- create Algorithms"
 
 print "-------------------------- Regular_1D"
 
-hypothesis=gen.CreateHypothesis("Regular_1D")
-regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
-regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
-smeshgui.SetName(regularID, "Wire Discretisation")
+regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
+
+smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
 
 print "-------------------------- MEFISTO_2D"
 
-hypothesis=gen.CreateHypothesis("MEFISTO_2D")
-mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
-mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
-smeshgui.SetName(mefistoID, "MEFISTO_2D")
+mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
+
+smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
 
 print "-------------------------- NETGEN_3D"
 
-hypothesis=gen.CreateHypothesis("NETGEN_3D")
-netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
-netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
-smeshgui.SetName(netgenID, "NETGEN_3D")
+netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
+
+smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
 
 # ---- init a Mesh with the compshell
 
-mesh=gen.Init(idcomp)
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
-smeshgui.SetName(idmesh, "MeshcompShell")
-smeshgui.SetShape(idcomp, idmesh)
+mesh=smesh.CreateMesh(compshell)
+smeshgui.SetName(salome.ObjectToID(mesh), "MeshcompShel")
 
 # ---- add hypothesis to compshell
 
 print "-------------------------- add hypothesis to compshell"
 
-ret=mesh.AddHypothesis(compshell,regular1D)
-print ret
-ret=mesh.AddHypothesis(compshell,hypNbSeg)
-print ret
-ret=mesh.AddHypothesis(compshell,mefisto2D)
-print ret
-ret=mesh.AddHypothesis(compshell,hypArea)
-print ret
-ret=mesh.AddHypothesis(compshell,netgen3D)
-print ret
-ret=mesh.AddHypothesis(compshell,hypVolume)
-print ret
+mesh.AddHypothesis(compshell,regular1D)
+mesh.AddHypothesis(compshell,hypNbSeg)
+
+mesh.AddHypothesis(compshell,mefisto2D)
+mesh.AddHypothesis(compshell,hypLengthFromEdges)
 
-smeshgui.SetAlgorithms( idmesh, regularID)
-smeshgui.SetHypothesis( idmesh, idseg )
-smeshgui.SetAlgorithms( idmesh, mefistoID )
-smeshgui.SetHypothesis( idmesh, idarea )
-smeshgui.SetAlgorithms( idmesh, netgenID )
-smeshgui.SetHypothesis( idmesh, idvolume )
+mesh.AddHypothesis(compshell,netgen3D)
+mesh.AddHypothesis(compshell,hypVolume)
 
-sg.updateObjBrowser(1)
+salome.sg.updateObjBrowser(1)
 
 print "-------------------------- compute compshell"
-ret=gen.Compute(mesh,idcomp)
+ret=smesh.Compute(mesh,compshell)
 print ret
 if ret != 0:
     log=mesh.GetLog(0) # no erase trace
     for linelog in log:
         print linelog
+    print "Information about the MeshcompShel:"
+    print "Number of nodes        : ", mesh.NbNodes()
+    print "Number of edges        : ", mesh.NbEdges()
+    print "Number of faces        : ", mesh.NbFaces()
+    print "Number of triangles    : ", mesh.NbTriangles()
+    print "Number of volumes      : ", mesh.NbVolumes()
+    print "Number of tetrahedrons : ", mesh.NbTetras()
+    
 else:
     print "problem when computing the mesh"
-
-sg.updateObjBrowser(1)
index b352355b8b37de1d4e2548964be2d52927084c84..6165621b9bb3b349751e15a0f2835393c8c4be2b 100644 (file)
@@ -4,23 +4,25 @@
 # Hypothesis and algorithms for the mesh generation are global
 #
 
+import os
 import salome
-from salome import sg
-
 import geompy
 
-import SMESH
-import smeshpy
+import StdMeshers
+
+geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
+
+smeshgui = salome.ImportComponentGUI("SMESH")
+smeshgui.Init(salome.myStudyId);
+
 
-geom = geompy.geom
-myBuilder = geompy.myBuilder
+# ---------------------------- GEOM --------------------------------------
 
 ShapeTypeShell     = 3
 ShapeTypeFace      = 4
 ShapeTypeEdge      = 6
 
-import os
-
 # import a BRep
 #before running this script, please be sure about
 #the path the file fileName
@@ -43,12 +45,8 @@ print "number of Shells in flight : ",len(subShellList)
 print "number of Faces in flight : ",len(subFaceList)
 print "number of Edges in flight : ",len(subEdgeList)
 
-# ---- launch SMESH
-
-smeshgui = salome.ImportComponentGUI("SMESH")
-smeshgui.Init(salome.myStudyId)
 
-gen=smeshpy.smeshpy()
+### ---------------------------- SMESH --------------------------------------
 
 # ---- create Hypothesis
 
@@ -58,27 +56,23 @@ print "-------------------------- LocalLength"
 
 lengthOfSegments = 0.3
 
-hypothesis=gen.CreateHypothesis("LocalLength")
-hypLength=hypothesis._narrow(SMESH.SMESH_LocalLength)
+hypLength=smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
 hypLength.SetLength(lengthOfSegments)
-hypLengthID = hypLength.GetId()
+
 print hypLength.GetName()
-print hypLengthID
+print  hypLength.GetId()
 print hypLength.GetLength()
 
-idlen = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLength) )
-smeshgui.SetName(idlen, "LocalLength")
+smeshgui.SetName(salome.ObjectToID(hypLength), "LocalLength_0.3")
 
 print "-------------------------- LengthFromEdges"
 
-hypothesis=gen.CreateHypothesis("LengthFromEdges")
-hypLengthFromEdge=hypothesis._narrow(SMESH.SMESH_LengthFromEdges)
-hypLengthFromEdgeID = hypLengthFromEdge.GetId()
+hypLengthFromEdge=smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
+
 print hypLengthFromEdge.GetName()
-print hypLengthFromEdgeID
+print hypLengthFromEdge.GetId()
 
-idlenfromedge = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLengthFromEdge) )
-smeshgui.SetName(idlenfromedge, "LengthFromEdge")
+smeshgui.SetName(salome.ObjectToID(hypLengthFromEdge), "LengthFromEdge")
 
 # ---- create Algorithms
 
@@ -86,54 +80,46 @@ print "-------------------------- create Algorithms"
 
 print "-------------------------- Regular_1D"
 
-hypothesis=gen.CreateHypothesis("Regular_1D")
-regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
-regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
-smeshgui.SetName(regularID, "Wire Discretisation")
+regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
+
+smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
 
 print "-------------------------- MEFISTO_2D"
 
-hypothesis=gen.CreateHypothesis("MEFISTO_2D")
-mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
-mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
-smeshgui.SetName(mefistoID, "MEFISTO_2D")
+mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
+
+smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
 
 # ---- init a Mesh with the shell
+shape_mesh = salome.IDToObject( idShape )
 
-mesh=gen.Init(idShape)
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
-smeshgui.SetName(idmesh, "MeshFlight")
-smeshgui.SetShape(idShape, idmesh)
+mesh=smesh.CreateMesh(shape_mesh)
+smeshgui.SetName(salome.ObjectToID(mesh), "MeshFlight")
 
 # ---- add hypothesis to flight
 
 print "-------------------------- add hypothesis to flight"
 
-ret=mesh.AddHypothesis(shape,regular1D)
-print ret
-ret=mesh.AddHypothesis(shape,hypLength)
-print ret
-ret=mesh.AddHypothesis(shape,mefisto2D)
-print ret
-ret=mesh.AddHypothesis(shape,hypLengthFromEdge)
-print ret
-
-smeshgui.SetAlgorithms( idmesh, regularID)
-smeshgui.SetHypothesis( idmesh, idlen )
-smeshgui.SetAlgorithms( idmesh, mefistoID )
-smeshgui.SetHypothesis( idmesh, idlenfromedge)
+mesh.AddHypothesis(shape_mesh,regular1D)
+mesh.AddHypothesis(shape_mesh,hypLength)
+mesh.AddHypothesis(shape_mesh,mefisto2D)
+mesh.AddHypothesis(shape_mesh,hypLengthFromEdge)
 
-sg.updateObjBrowser(1)
+salome.sg.updateObjBrowser(1)
 
 
 print "-------------------------- compute the skin flight"
-ret=gen.Compute(mesh,idShape)
+ret=smesh.Compute(mesh,shape_mesh)
 print ret
 if ret != 0:
     log=mesh.GetLog(0) # no erase trace
     for linelog in log:
         print linelog
+    print "Information about the Mesh_mechanic_tetra:"
+    print "Number of nodes      : ", mesh.NbNodes()
+    print "Number of edges      : ", mesh.NbEdges()
+    print "Number of faces      : ", mesh.NbFaces()
+    print "Number of triangles  : ", mesh.NbTriangles()
+    print "Number of volumes    : ", mesh.NbVolumes()
 else:
     print "probleme when computing the mesh"
-
-sg.updateObjBrowser(1)
index 8a0a3a339e360613d31dd0c7a382fa5490bcb1a7..3011c0c827b1cbee036c2e7012f997e7e81088d1 100644 (file)
 #  Module : SMESH
 #  $Header$
 
-import SMESH
-import smeshpy
 import salome
-from salome import sg
-import math
-#import SMESH_BasicHypothesis_idl
-
 import geompy
 
+geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
 
-
-# ---------------------------- GEOM --------------------------------------
-geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
-myBuilder = salome.myStudy.NewBuilder()
-#from geompy import gg
+geom.GetCurrentStudy(salome.myStudy._get_StudyId())
+smesh.SetCurrentStudy(salome.myStudy)
 
 smeshgui = salome.ImportComponentGUI("SMESH")
 smeshgui.Init(salome.myStudyId);
 
+import StdMeshers
+
+# ---------------------------- GEOM --------------------------------------
 ShapeTypeCompSolid = 1
 ShapeTypeSolid     = 2
 ShapeTypeShell     = 3
@@ -51,9 +47,7 @@ ShapeTypeWire      = 5
 ShapeTypeEdge      = 6
 ShapeTypeVertex    = 7
 
-
 # ---- define contigous arcs and segment to define a closed wire
-
 p1   = geom.MakePointStruct( 100.0,   0.0,  0.0 )
 p2   = geom.MakePointStruct(  50.0,  50.0,  0.0 )
 p3   = geom.MakePointStruct( 100.0, 100.0,  0.0 ) 
@@ -69,9 +63,7 @@ arc2 = geom.MakeArc( p4, p5, p6 )
 p7   = geom.MakePointStruct( 120.0, 30.0, 0.0 )
 arc3 = geom.MakeArc( p6, p7, p1 )
 
-
 # ---- define a closed wire with arcs and segment
-
 List1 = []
 List1.append( arc1 )
 List1.append( seg1 )
@@ -85,13 +77,11 @@ wire1 = geom.MakeWire( ListIOR1 )
 
 Id_wire1 = geompy.addToStudy( wire1, "wire1")
 
-
 # ---- define a planar face with wire
 WantPlanarFace = 1 #True
 face1 = geom.MakeFace( wire1, WantPlanarFace )
 Id_face1 = geompy.addToStudy( face1, "face1")
 
-
 # ---- create a shape by extrusion
 pO = geom.MakePointStruct( 0.0, 0.0,   0.0 )
 pz = geom.MakePointStruct( 0.0, 0.0, 100.0 )
@@ -99,8 +89,6 @@ pz = geom.MakePointStruct( 0.0, 0.0, 100.0 )
 prism1    = geom.MakePrism( face1, pO, pz )
 Id_prism1 = geompy.addToStudy( prism1, "prism1")
 
-
-
 # ---- create two cylinders
 
 pc1 = geom.MakePointStruct(  90.0, 50.0, -40.0 )
@@ -114,7 +102,6 @@ cyl2  = geom.MakeCylinder( pc2, vz, radius, height )
 Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" )
 Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" )
 
-
 # ---- cut with cyl1 
 shape  = geom.MakeBoolean( prism1, cyl1, 2 )
 
@@ -123,203 +110,185 @@ shape1 =  geom.MakeBoolean( shape, cyl2, 3 )
 
 Id_shape1 = geompy.addToStudy( shape1, "shape1")
 
-
+#faces = geompy.SubShapeAllSorted( shape1, ShapeTypeFace)
+#i = 0
+#for face in faces:
+#    geompy.addToStudy(face,"face_" + str(i))
+#    i = i+1
+    
 # ---- add a face sub shape in study to be meshed different
 IdSubFaceList = []
-IdSubFaceList.append(10)
+IdSubFaceList.append(1)
 sub_face = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceList )
 name     = geompy.SubShapeName( sub_face._get_Name(), shape1._get_Name() )
 
 Id_SubFace = geompy.addToStudyInFather( shape1, sub_face, name )
 
-
 # ---- add a face sub shape in study to be meshed different
 IdSubFaceL = []
-IdSubFaceL.append(7)
+IdSubFaceL.append(2)
 sub_face2 = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceL )
 name      = geompy.SubShapeName( sub_face2._get_Name(), shape1._get_Name() )
 
 Id_SubFace2 = geompy.addToStudyInFather( shape1, sub_face2, name )
 
+# ---- add a face sub shape in study to be meshed different
+IdSubFaceL = []
+IdSubFaceL.append(3)
+sub_face3 = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceL )
+name      = geompy.SubShapeName( sub_face3._get_Name(), shape1._get_Name() )
 
+Id_SubFace3 = geompy.addToStudyInFather( shape1, sub_face3, name )
 
+# ---- add a face sub shape in study to be meshed different
+IdSubFaceL = []
+IdSubFaceL.append(6)
+sub_face4 = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceL )
+name      = geompy.SubShapeName( sub_face4._get_Name(), shape1._get_Name() )
 
-# ---------------------------- SMESH --------------------------------------
-
-# ---- launch SMESH, init a Mesh with shape 'shape1'
-gen  = smeshpy.smeshpy()
-mesh = gen.Init( Id_shape1 )
+Id_SubFace4 = geompy.addToStudyInFather( shape1, sub_face4, name )
 
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
-smeshgui.SetName( idmesh, "Mesh_meca" );
-smeshgui.SetShape( Id_shape1, idmesh );
 
+# ---------------------------- SMESH --------------------------------------
 
 # ------------------------------ Length Hypothesis
 
 print "-------------------------- create Hypothesis"
 print "-------------------------- LocalLength"
-hyp1    = gen.CreateHypothesis( "LocalLength" )
-hypLen1 = hyp1._narrow( SMESH.SMESH_LocalLength )
-hypLen1.SetLength( 100.0 )
-print hypLen1.GetName()
-print hypLen1.GetId()
-print hypLen1.GetLength()
-
-idlength = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLen1) );
-smeshgui.SetName(idlength, "Local_Length_100");
+hyp1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
+hyp1.SetLength( 100.0 )
+print hyp1.GetName()
+print hyp1.GetId()
+print hyp1.GetLength()
 
+idlength = salome.ObjectToID(hyp1)
+smeshgui.SetName(idlength, "Local_Length_100");
 
 print "-------------------------- NumberOfSegments"
 
-hyp2      = gen.CreateHypothesis( "NumberOfSegments" )
-hypNbSeg1 = hyp2._narrow( SMESH.SMESH_NumberOfSegments )
-hypNbSeg1.SetNumberOfSegments( 10 )
-print hypNbSeg1.GetName()
-print hypNbSeg1.GetId()
-print hypNbSeg1.GetNumberOfSegments()
+hyp2 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
+hyp2.SetNumberOfSegments( 10 )
+print hyp2.GetName()
+print hyp2.GetId()
+print hyp2.GetNumberOfSegments()
 
-idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg1) );
+idseg = salome.ObjectToID(hyp2)
 smeshgui.SetName(idseg, "NumberOfSegments_12");
 
-
 print "-------------------------- MaxElementArea"
 
-hyp3     = gen.CreateHypothesis( "MaxElementArea" )
-hypArea1 = hyp3._narrow( SMESH.SMESH_MaxElementArea )
-hypArea1.SetMaxElementArea( 25 )
-print hypArea1.GetName()
-print hypArea1.GetId()
-print hypArea1.GetMaxElementArea()
+hyp3 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
+hyp3.SetMaxElementArea( 25 )
+print hyp3.GetName()
+print hyp3.GetId()
+print hyp3.GetMaxElementArea()
 
-idarea1 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea1) );
+idarea1 = salome.ObjectToID(hyp3)
 smeshgui.SetName(idarea1, "MaxElementArea_20");
 
-
-
 print "-------------------------- MaxElementArea"
 
-hyp4     = gen.CreateHypothesis( "MaxElementArea" )
-hypArea2 = hyp4._narrow( SMESH.SMESH_MaxElementArea )
-hypArea2.SetMaxElementArea( 35 )
-print hypArea2.        GetName()
-print hypArea2.GetId()
-print hypArea2.GetMaxElementArea()
+hyp4 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
+hyp4.SetMaxElementArea( 35 )
+print hyp4.GetName()
+print hyp4.GetId()
+print hyp4.GetMaxElementArea()
 
-idarea2 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea2) );
+idarea2 = salome.ObjectToID(hyp4)
 smeshgui.SetName(idarea2, "MaxElementArea_30");
 
 
 print "-------------------------- Regular_1D"
 
-alg1    = gen.CreateHypothesis( "Regular_1D" )
-algo1   = alg1._narrow( SMESH.SMESH_Algo )
-listHyp =algo1.GetCompatibleHypothesis()
+alg1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
+listHyp =alg1.GetCompatibleHypothesis()
 for hyp in listHyp:
     print hyp
-algoReg1d = alg1._narrow( SMESH.SMESH_Regular_1D )
-print algoReg1d.GetName()
-print algoReg1d.GetId()
+print alg1.GetName()
+print alg1.GetId()
 
-idreg1d = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoReg1d) );
+idreg1d = salome.ObjectToID(alg1)
 smeshgui.SetName( idreg1d, "Regular_1D" );
 
-
-
 print "-------------------------- MEFISTO_2D"
 
-alg2    = gen.CreateHypothesis( "MEFISTO_2D" )
-algo2   = alg2._narrow( SMESH.SMESH_Algo )
-listHyp = algo2.GetCompatibleHypothesis()
+alg2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
+listHyp = alg2.GetCompatibleHypothesis()
 for hyp in listHyp:
     print hyp
-algoMef = alg2._narrow( SMESH.SMESH_MEFISTO_2D )
-print algoMef.GetName()
-print algoMef.GetId()
+print alg2.GetName()
+print alg2.GetId()
 
-idmef = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoMef) );
+idmef = salome.ObjectToID(alg2)
 smeshgui.SetName( idmef, "MEFISTO_2D" );
 
-
-
 print "-------------------------- SMESH_Quadrangle_2D"
 
-alg3    = gen.CreateHypothesis( "Quadrangle_2D" )
-algo3   = alg3._narrow( SMESH.SMESH_2D_Algo )
-listHyp = algo3.GetCompatibleHypothesis()
+alg3 = smesh.CreateHypothesis( "Quadrangle_2D", "libStdMeshersEngine.so" )
+listHyp = alg3.GetCompatibleHypothesis()
 for hyp in listHyp:
     print hyp
-algoQad2 = alg3._narrow( SMESH.SMESH_Quadrangle_2D )
-print algoQad2.GetName()
-print algoQad2.GetId()
+print alg3.GetName()
+print alg3.GetId()
 
-idqad2 = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoQad2) );
+idqad2 =  salome.ObjectToID(alg3)
 smeshgui.SetName( idqad2, "SMESH_Quadrangle_2D" );
 
 
-
 print "-------------------------- add hypothesis to main shape1"
 
 shape_mesh = salome.IDToObject( Id_shape1  )
-submesh    = mesh.GetElementsOnShape( shape_mesh )
-
-ret = mesh.AddHypothesis( shape_mesh, algoReg1d )   # Regular 1D/wire discretisation
-print ret
-ret = mesh.AddHypothesis( shape_mesh, algoMef )     # MEFISTO 2D
-print ret
-ret = mesh.AddHypothesis( shape_mesh, hypNbSeg1 )   # nb segments
-print ret
-ret = mesh.AddHypothesis( shape_mesh, hypArea1 )    # max area
-print ret
 
-smeshgui.SetAlgorithms( idmesh, idreg1d );  # Regular 1D/wire discretisation
-smeshgui.SetAlgorithms( idmesh, idmef );    # MEFISTO 2D
-smeshgui.SetHypothesis( idmesh, idseg );    # nb segments
-smeshgui.SetHypothesis( idmesh, idarea1 );  # max area
+mesh = smesh.CreateMesh(shape_mesh)
 
+idmesh = salome.ObjectToID(mesh) 
+smeshgui.SetName( idmesh, "Mesh_mechanic" );
 
+mesh.AddHypothesis( shape_mesh, alg1 )   # Regular 1D/wire discretisation
+mesh.AddHypothesis( shape_mesh, alg2 )     # MEFISTO 2D
 
-print "-------------------------- add hypothesis and algorith to sub face"        
+ret = mesh.AddHypothesis( shape_mesh, hyp2 )   # nb segments
+ret = mesh.AddHypothesis( shape_mesh, hyp3 )    # max area
 
-sub_face  = salome.IDToObject( Id_SubFace )
-submesh   = mesh.GetElementsOnShape( sub_face )
+print "--------Add hypothesis and algorith to sub face"        
 
-ret = mesh.AddHypothesis( sub_face, algoQad2 )  # Quadrangle 2D
-print ret
-ret = mesh.AddHypothesis( sub_face, hypArea2 )  # max area
-print ret
+#sub_face  = salome.IDToObject( Id_SubFace )
+submesh   = mesh.GetSubMesh(sub_face, "SubMeshFace")
 
-idsm2 = smeshgui.AddSubMeshOnShape( idmesh,
-                                    Id_SubFace,
-                                    salome.orb.object_to_string(submesh),
-                                    ShapeTypeFace )
+mesh.AddHypothesis( sub_face, alg3 )  # Quadrangle 2D
+mesh.AddHypothesis( sub_face, hyp4 )  # max area
 
-smeshgui.SetName(idsm2, "SubMeshFace")
-smeshgui.SetAlgorithms( idsm2, idqad2 );  # Quadrangle 2D
-smeshgui.SetHypothesis( idsm2, idarea2 ); # max area
+print "--------Add hypothesis and algorith to sub face 2"        
 
+#sub_face2  = salome.IDToObject( Id_SubFace2 )
+submesh    = mesh.GetSubMesh(sub_face2, "SubMeshFace2")
 
+mesh.AddHypothesis( sub_face2, alg3 )  # Quadrangle 2D
+ret = mesh.AddHypothesis( sub_face2, hyp4 )  # max area
 
-print "-------------------------- add hypothesis and algorith to sub face"        
+print "--------Add hypothesis and algorith to sub face 3"        
 
-sub_face2  = salome.IDToObject( Id_SubFace2 )
-submesh    = mesh.GetElementsOnShape( sub_face2 )
+#sub_face3  = salome.IDToObject( Id_SubFace3 )
+submesh    = mesh.GetSubMesh(sub_face3, "SubMeshFace3")
 
-ret = mesh.AddHypothesis( sub_face2, algoQad2 )  # Quadrangle 2D
-print ret
-ret = mesh.AddHypothesis( sub_face2, hypArea2 )  # max area
-print ret
+mesh.AddHypothesis( sub_face3, alg3 )  # Quadrangle 2D
+ret = mesh.AddHypothesis( sub_face3, hyp4 )  # max area
 
-idsm3 = smeshgui.AddSubMeshOnShape( idmesh,
-                                    Id_SubFace2,
-                                    salome.orb.object_to_string(submesh),
-                                    ShapeTypeFace )
+print "--------Add hypothesis and algorith to sub face 4"        
 
-smeshgui.SetName(idsm3, "SubMeshFace2")
-smeshgui.SetAlgorithms( idsm3, idqad2 );  # Quadrangle 2D
-smeshgui.SetHypothesis( idsm3, idarea2 ); # max area
+#sub_face4  = salome.IDToObject( Id_SubFace4 )
+submesh    = mesh.GetSubMesh(sub_face4, "SubMeshFace4")
 
+mesh.AddHypothesis( sub_face4, alg3 )  # Quadrangle 2D
+ret = mesh.AddHypothesis( sub_face4, hyp4 )  # max area
 
+smesh.Compute(mesh,shape_mesh)
 
+print "Information about the Mesh_mechanic:"
+print "Number of nodes      : ", mesh.NbNodes()
+print "Number of edges      : ", mesh.NbEdges()
+print "Number of faces      : ", mesh.NbFaces()
+print "Number of triangles  : ", mesh.NbTriangles()
+print "Number of quadrangles: ", mesh.NbQuadrangles()
 
-sg.updateObjBrowser(1);
+salome.sg.updateObjBrowser(1);
index 2446828a94b16b86fe8fc4d9972a9d187bb98b7f..6896148913f320f5fb5b3d5946e1f2b05bb27f48 100644 (file)
 #  Module : SMESH
 #  $Header$
 
-import SMESH
-import smeshpy
 import salome
-from salome import sg
-import math
-
 import geompy
 
-# ---------------------------- GEOM --------------------------------------
-geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
-myBuilder = salome.myStudy.NewBuilder()
-#from geompy import gg
+import StdMeshers
+import NETGENPlugin
+
+geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
 
 smeshgui = salome.ImportComponentGUI("SMESH")
-smeshgui.Init(salome.myStudyId)
+smeshgui.Init(salome.myStudyId);
 
+# ---------------------------- GEOM --------------------------------------
 ShapeTypeCompSolid = 1
 ShapeTypeSolid     = 2
 ShapeTypeShell     = 3
@@ -124,131 +121,100 @@ print "number of Edges in mechanic : ",len(subEdgeList)
 
 ### ---------------------------- SMESH --------------------------------------
 
-# ---- launch SMESH, init a Mesh with shape 'mechanic'
-
-gen  = smeshpy.smeshpy()
-mesh = gen.Init( idMechanic )
-
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
-smeshgui.SetName( idmesh, "Mesh_mechanic" )
-smeshgui.SetShape( idMechanic, idmesh )
-
 print "-------------------------- NumberOfSegments"
 
 numberOfSegment = 10
 
-hypNumberOfSegment = gen.CreateHypothesis( "NumberOfSegments" )
-hypNbSeg = hypNumberOfSegment._narrow( SMESH.SMESH_NumberOfSegments )
+hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
 hypNbSeg.SetNumberOfSegments(numberOfSegment)
 print hypNbSeg.GetName()
 print hypNbSeg.GetId()
 print hypNbSeg.GetNumberOfSegments()
 
-idSeg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
-smeshgui.SetName(idSeg, "NumberOfSegments")
+smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
 
 print "-------------------------- MaxElementArea"
 
 maxElementArea = 20
 
-hypMaxElementArea = gen.CreateHypothesis( "MaxElementArea" )
-hypArea = hypMaxElementArea._narrow( SMESH.SMESH_MaxElementArea )
+hypArea = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
 hypArea.SetMaxElementArea(maxElementArea)
 print hypArea.GetName()
 print hypArea.GetId()
 print hypArea.GetMaxElementArea()
 
-idArea = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea) )
-smeshgui.SetName(idArea, "MaxElementArea")
+smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_20")
 
 print "-------------------------- MaxElementVolume"
 
 maxElementVolume = 20
 
-hypMaxElementVolume = gen.CreateHypothesis( "MaxElementVolume" )
-hypVolume = hypMaxElementVolume._narrow( SMESH.SMESH_MaxElementVolume )
+hypVolume = smesh.CreateHypothesis( "MaxElementVolume", "libStdMeshersEngine.so" )
 hypVolume.SetMaxElementVolume(maxElementVolume)
 print hypVolume.GetName()
 print hypVolume.GetId()
 print hypVolume.GetMaxElementVolume()
 
-idVolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
-smeshgui.SetName(idVolume, "MaxElementArea")
+smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_20")
 
 print "-------------------------- Regular_1D"
 
-alg1D = gen.CreateHypothesis( "Regular_1D" )
-algo1D   = alg1D._narrow( SMESH.SMESH_Algo )
-listHyp =algo1D.GetCompatibleHypothesis()
+algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
+listHyp =algoReg1D.GetCompatibleHypothesis()
 for hyp in listHyp:
     print hyp
-algoReg1D = alg1D._narrow( SMESH.SMESH_Regular_1D )
 print algoReg1D.GetName()
 print algoReg1D.GetId()
 
-idReg1D = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoReg1D) )
-smeshgui.SetName( idReg1D, "Regular_1D" )
+smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D" )
 
 print "-------------------------- MEFISTO_2D"
 
-alg2D = gen.CreateHypothesis( "MEFISTO_2D" )
-algo2D = alg2D._narrow( SMESH.SMESH_Algo )
-listHyp = algo2D.GetCompatibleHypothesis()
+algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
+listHyp = algoMef.GetCompatibleHypothesis()
 for hyp in listHyp:
     print hyp
-algoMef = alg2D._narrow( SMESH.SMESH_MEFISTO_2D )
 print algoMef.GetName()
 print algoMef.GetId()
 
-idMef = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoMef) )
-smeshgui.SetName( idMef, "MEFISTO_2D" )
+smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D" )
 
 print "-------------------------- NETGEN_3D"
 
-alg3D = gen.CreateHypothesis( "NETGEN_3D" )
-algo3D = alg3D._narrow( SMESH.SMESH_Algo )
-listHyp = algo3D.GetCompatibleHypothesis()
+algoNg = smesh.CreateHypothesis( "NETGEN_3D", "libNETGENEngine.so" )
+listHyp = algoNg.GetCompatibleHypothesis()
 for hyp in listHyp:
     print hyp
-algoNg = alg3D._narrow( SMESH.SMESH_NETGEN_3D )
 print algoNg.GetName()
 print algoNg.GetId()
 
-idNg = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoNg) )
-smeshgui.SetName( idNg, "NETGEN_2D" )
+smeshgui.SetName(salome.ObjectToID(algoNg), "NETGEN_3D" )
 
 print "-------------------------- add hypothesis to main mechanic"
 
 shape_mesh = salome.IDToObject( idMechanic  )
-submesh    = mesh.GetElementsOnShape( shape_mesh )
-
-ret = mesh.AddHypothesis( shape_mesh, algoReg1D )   # Regular 1D/wire discretisation
-print ret
-ret = mesh.AddHypothesis( shape_mesh, algoMef )     # MEFISTO 2D
-print ret
-ret = mesh.AddHypothesis( shape_mesh, algoNg )     # NETGEN 3D
-print ret
-ret = mesh.AddHypothesis( shape_mesh, hypNbSeg )   # nb segments
-print ret
-ret = mesh.AddHypothesis( shape_mesh, hypArea )    # max area
-print ret
-ret = mesh.AddHypothesis( shape_mesh, hypVolume )    # max volume
-print ret
-
-smeshgui.SetAlgorithms( idmesh, idReg1D );  # Regular 1D/wire discretisation
-smeshgui.SetAlgorithms( idmesh, idMef );    # MEFISTO 2D
-smeshgui.SetAlgorithms( idmesh, idNg );    # NETGEN 3D
-smeshgui.SetHypothesis( idmesh, idSeg );    # nb segments
-smeshgui.SetHypothesis( idmesh, idArea );  # max area
-smeshgui.SetHypothesis( idmesh, idVolume );  # max volume
-
-sg.updateObjBrowser(1);
+
+mesh = smesh.CreateMesh(shape_mesh)
+smeshgui.SetName(salome.ObjectToID(mesh), "Mesh_mechanic_tetra" );
+
+mesh.AddHypothesis( shape_mesh, algoReg1D )   # Regular 1D/wire discretisation
+mesh.AddHypothesis( shape_mesh, algoMef )     # MEFISTO 2D
+mesh.AddHypothesis( shape_mesh, algoNg )     # NETGEN 3D
+
+mesh.AddHypothesis( shape_mesh, hypNbSeg )   # nb segments
+mesh.AddHypothesis( shape_mesh, hypArea )    # max area
+mesh.AddHypothesis( shape_mesh, hypVolume )    # max volume
 
 print "-------------------------- compute the mesh of the mechanic piece"
-ret=gen.Compute(mesh,idMechanic)
-print ret
-log=mesh.GetLog(0) # no erase trace
-for linelog in log:
-    print linelog
+smesh.Compute(mesh,shape_mesh)
+
+print "Information about the Mesh_mechanic_tetra:"
+print "Number of nodes      : ", mesh.NbNodes()
+print "Number of edges      : ", mesh.NbEdges()
+print "Number of faces      : ", mesh.NbFaces()
+print "Number of triangles  : ", mesh.NbTriangles()
+print "Number of volumes: ", mesh.NbVolumes()
+print "Number of tetrahedrons: ", mesh.NbTetras()
+
+salome.sg.updateObjBrowser(1);
 
-sg.updateObjBrowser(1)
index bce99c6e9a3cf37e546fb250ca2ef1524d4e578a..ce717fdde9b4d35c9d3abef2c5c0c7b670b8d2f1 100644 (file)
@@ -35,9 +35,6 @@ geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
 myBuilder = salome.myStudy.NewBuilder()
 from geompy import gg
 
-smeshgui = salome.ImportComponentGUI("SMESH")
-smeshgui.Init(salome.myStudyId);
-
 ShapeTypeCompSolid = 1
 ShapeTypeSolid = 2
 ShapeTypeShell = 3
index 35a3ef00b0943a8831080bcd60da5b256579484e..a16b63d5a134b650d3947ae06737eaf6e6df90b3 100644 (file)
 #  File   : SMESH_test1.py
 #  Module : SMESH
 
-import SMESH
-import smeshpy
 import salome
-from salome import sg
-import math
-#import SMESH_BasicHypothesis_idl
-
 import geompy
 
-geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
-myBuilder = salome.myStudy.NewBuilder()
-from geompy import gg
+import StdMeshers
 
-smeshgui = salome.ImportComponentGUI("SMESH")
-smeshgui.Init(salome.myStudyId);
+geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
+
+geom.GetCurrentStudy(salome.myStudy._get_StudyId())
+smesh.SetCurrentStudy(salome.myStudy)
 
 ShapeTypeCompSolid = 1
 ShapeTypeSolid = 2
@@ -75,135 +70,102 @@ name = geompy.SubShapeName( edge._get_Name(), face._get_Name() )
 print name
 idedge=geompy.addToStudyInFather(face,edge,name)
 
-# ---- launch SMESH, init a Mesh with the box
-gen=smeshpy.smeshpy()
-mesh=gen.Init(idbox)
-
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
-smeshgui.SetName(idmesh, "Meshbox");
-smeshgui.SetShape(idbox, idmesh);
+# ---- launch SMESH
+smeshgui = salome.ImportComponentGUI("SMESH")
+smeshgui.Init(salome.myStudyId);
 
 # ---- create Hypothesis
 
 print "-------------------------- create Hypothesis"
 print "-------------------------- LocalLength"
-hyp1=gen.CreateHypothesis("LocalLength")
-hypLen1 = hyp1._narrow(SMESH.SMESH_LocalLength)
+
+hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
 hypLen1.SetLength(100)
 print hypLen1.GetName()
 print hypLen1.GetId()
 print hypLen1.GetLength()
 
-idlength = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLen1) );
+idlength = salome.ObjectToID(hypLen1) 
 smeshgui.SetName(idlength, "Local_Length_100");
 
 print "-------------------------- NumberOfSegments"
-hyp2=gen.CreateHypothesis("NumberOfSegments")
-hypNbSeg1=hyp2._narrow(SMESH.SMESH_NumberOfSegments)
+hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
 hypNbSeg1.SetNumberOfSegments(7)
 print hypNbSeg1.GetName()
 print hypNbSeg1.GetId()
 print hypNbSeg1.GetNumberOfSegments()
 
-idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg1) );
+idseg = salome.ObjectToID(hypNbSeg1) 
 smeshgui.SetName(idseg, "NumberOfSegments_7");
 
 print "-------------------------- MaxElementArea"
-hyp3=gen.CreateHypothesis("MaxElementArea")
-hypArea1=hyp3._narrow(SMESH.SMESH_MaxElementArea)
+hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
 hypArea1.SetMaxElementArea(2500)
 print hypArea1.GetName()
 print hypArea1.GetId()
 print hypArea1.GetMaxElementArea()
 
-idarea1 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea1) );
+idarea1 = salome.ObjectToID(hypArea1)
 smeshgui.SetName(idarea1, "MaxElementArea_2500");
 
 print "-------------------------- MaxElementArea"
-hyp3=gen.CreateHypothesis("MaxElementArea")
-hypArea2=hyp3._narrow(SMESH.SMESH_MaxElementArea)
+hypArea2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
 hypArea2.SetMaxElementArea(500)
 print hypArea2.GetName()
 print hypArea2.GetId()
 print hypArea2.GetMaxElementArea()
 
-idarea2 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea2) );
+idarea2 = salome.ObjectToID(hypArea2)
 smeshgui.SetName(idarea2, "MaxElementArea_500");
 
 print "-------------------------- Regular_1D"
-alg1=gen.CreateHypothesis("Regular_1D")
-algo1=alg1._narrow(SMESH.SMESH_Algo)
-listHyp=algo1.GetCompatibleHypothesis()
+algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
+listHyp=algoReg.GetCompatibleHypothesis()
 for hyp in listHyp:
     print hyp
-algoReg=alg1._narrow(SMESH.SMESH_Regular_1D)
 print algoReg.GetName()
 print algoReg.GetId()
 
-idreg = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoReg) );
+idreg = salome.ObjectToID(algoReg)
 smeshgui.SetName(idreg, "Regular_1D");
 
 print "-------------------------- MEFISTO_2D"
-alg2=gen.CreateHypothesis("MEFISTO_2D")
-algo2=alg2._narrow(SMESH.SMESH_Algo)
-listHyp=algo2.GetCompatibleHypothesis()
+algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
+listHyp=algoMef.GetCompatibleHypothesis()
 for hyp in listHyp:
     print hyp
-algoMef=alg2._narrow(SMESH.SMESH_MEFISTO_2D)
 print algoMef.GetName()
 print algoMef.GetId()
 
-idmef = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoMef) );
+idmef = salome.ObjectToID(algoMef)
 smeshgui.SetName(idmef, "MEFISTO_2D");
 
+# ---- Init a Mesh with the box
+
+box=salome.IDToObject(idbox)
+mesh=smesh.CreateMesh(box)
+
+idmesh = salome.ObjectToID(mesh)
+smeshgui.SetName(idmesh, "Meshbox");
+
+# ---- add hypothesis to box
+print "-------------------------- add hypothesis to box"
+mesh.AddHypothesis(box,algoReg)
+mesh.AddHypothesis(box,hypNbSeg1)
+mesh.AddHypothesis(box,algoMef)
+mesh.AddHypothesis(box,hypArea1)
+
 # ---- add hypothesis to edge
 
 print "-------------------------- add hypothesis to edge"
 edge=salome.IDToObject(idedge)
-submesh=mesh.GetElementsOnShape(edge)
-ret=mesh.AddHypothesis(edge,algoReg)
-print ret
-ret=mesh.AddHypothesis(edge,hypLen1)
-print ret
-
-idsm1 = smeshgui.AddSubMeshOnShape( idmesh,
-                                    idedge,
-                                    salome.orb.object_to_string(submesh),
-                                    ShapeTypeEdge )
-smeshgui.SetName(idsm1, "SubMeshEdge")
-smeshgui.SetAlgorithms( idsm1, idreg );
-smeshgui.SetHypothesis( idsm1, idlength );
+submesh = mesh.GetSubMesh(edge, "SubMeshEdge")
+mesh.AddHypothesis(edge , algoReg)
+mesh.AddHypothesis(edge, hypLen1)
 
 print "-------------------------- add hypothesis to face"
-face=salome.IDToObject(idface)
-submesh=mesh.GetElementsOnShape(face)
-ret=mesh.AddHypothesis(face,hypArea2)
-print ret
-
-idsm2 = smeshgui.AddSubMeshOnShape( idmesh,
-                                    idface,
-                                    salome.orb.object_to_string(submesh),
-                                    ShapeTypeFace )
-smeshgui.SetName(idsm2, "SubMeshFace")
-smeshgui.SetHypothesis( idsm2, idarea2 );
-
-# ---- add hypothesis to box
+face = salome.IDToObject(idface)
+submesh =mesh.GetSubMesh(face, "SubMeshFace")
+mesh.AddHypothesis(face,hypArea2)
 
-print "-------------------------- add hypothesis to box"
-box=salome.IDToObject(idbox)
-submesh=mesh.GetElementsOnShape(box)
-ret=mesh.AddHypothesis(box,algoReg)
-print ret
-ret=mesh.AddHypothesis(box,hypNbSeg1)
-print ret
-ret=mesh.AddHypothesis(box,algoMef)
-print ret
-ret=mesh.AddHypothesis(box,hypArea1)
-print ret
-
-smeshgui.SetAlgorithms( idmesh, idreg );
-smeshgui.SetHypothesis( idmesh, idseg );
-smeshgui.SetAlgorithms( idmesh, idmef );
-smeshgui.SetHypothesis( idmesh, idarea1 );
-
-sg.updateObjBrowser(1);
+salome.sg.updateObjBrowser(1);
index dd58a63aafe210c572323ee84fd63b8d35f0a3bf..1c58f73da46ce0a9da8ab67f17340fcad0a6208c 100644 (file)
@@ -27,14 +27,14 @@ from SMESH_test1 import *
 # ---- compute box
 
 print "-------------------------- compute box"
-ret=gen.Compute(mesh,idbox)
+ret=smesh.Compute(mesh,box)
 print ret
 log=mesh.GetLog(0); # no erase trace
 for linelog in log:
     print linelog
 
 
-sg.updateObjBrowser(1);
+salome.sg.updateObjBrowser(1);
 
 # ---- compute edge
 
index 4154040ce2a8447061e91527163555ccaecde628..65d7129e6d7441ddaab740601932d15f89b2c02b 100644 (file)
@@ -34,9 +34,6 @@ geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
 myBuilder = salome.myStudy.NewBuilder()
 from geompy import gg
 
-smeshgui = salome.ImportComponentGUI("SMESH")
-smeshgui.Init(salome.myStudyId);
-
 ShapeTypeCompSolid = 1
 ShapeTypeSolid = 2
 ShapeTypeShell = 3
index eef9e1d502f01c11be0cc697a9f3e78003d0d2d3..899dc59af0fe8498b01fd5af4797e3a45216ca40 100644 (file)
@@ -22,13 +22,10 @@ if myStudyBuilder is None:
 father = myStudy.FindComponent("MESH")
 if father is None:
         father = myStudyBuilder.NewComponent("MESH")
-        A1 = myStudyBuilder.FindOrCreateAttribute(father, "AttributeName");
-        FName = A1._narrow(SALOMEDS.AttributeName)
-        #FName.SetValue("Mesh")        
+        FName = myStudyBuilder.FindOrCreateAttribute(father, "AttributeName");
        Comp = modulecatalog.GetComponent( "SMESH" )
        FName.SetValue( Comp._get_componentusername() )
-       A2 = myStudyBuilder.FindOrCreateAttribute(father, "AttributePixMap");
-       aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
+       aPixmap = myStudyBuilder.FindOrCreateAttribute(father, "AttributePixMap");
        aPixmap.SetPixMap( "ICON_OBJBROWSER_Mesh" );
 
 myStudyBuilder.DefineComponentInstance(father,smesh)
@@ -67,113 +64,111 @@ def Init():
         pass
 #------------------------------------------------------------
 def AddNewMesh(IOR):
+       # VSR: added temporarily - objects are published automatically by the engine
+       aSO = myStudy.FindObjectIOR( IOR )
+       if aSO is not None:
+               return aSO.GetID()
+       # VSR ######################################################################
+       
        res,HypothesisRoot = mySComponentMesh.FindSubObject ( Tag_HypothesisRoot )
        if HypothesisRoot is None or res == 0:
                HypothesisRoot = myStudyBuilder.NewObjectToTag(mySComponentMesh, Tag_HypothesisRoot)
-               anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeName")
-               aName = anAttr._narrow(SALOMEDS.AttributeName)
-               aName.SetValue("Hypothesis Definition")
-               anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributePixMap")
-               aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap)
+               aName = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeName")
+               aName.SetValue("Hypotheses")
+               aPixmap = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributePixMap")
                aPixmap.SetPixMap( "mesh_tree_hypo.png" )
-               anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable")
-               aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable)
+               aSelAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable")
                aSelAttr.SetSelectable(0);
 
        res, AlgorithmsRoot = mySComponentMesh.FindSubObject (Tag_AlgorithmsRoot)
        if AlgorithmsRoot is None  or res == 0:
                AlgorithmsRoot = myStudyBuilder.NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot)
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeName")
-               aName = anAttr._narrow(SALOMEDS.AttributeName)
-               aName.SetValue("Algorithms Definition");
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap");
-               aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap);
+               aName = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeName")
+               aName.SetValue("Algorithms");
+               aPixmap = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap");
                aPixmap.SetPixMap( "mesh_tree_algo.png" );
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable");
-               aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable);
+               aSelAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable");
                aSelAttr.SetSelectable(0);
 
        HypothesisRoot = HypothesisRoot._narrow(SALOMEDS.SObject)
        newMesh = myStudyBuilder.NewObject(mySComponentMesh)
-       newMesh = newMesh._narrow(SALOMEDS.SObject)
-       anAttr = myStudyBuilder.FindOrCreateAttribute(newMesh, "AttributePixMap")
-       aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap)
+       aPixmap = myStudyBuilder.FindOrCreateAttribute(newMesh, "AttributePixMap")
        aPixmap.SetPixMap( "mesh_tree_mesh.png" )
-       anAttr = myStudyBuilder.FindOrCreateAttribute(newMesh, "AttributeIOR")
-       anIOR = anAttr._narrow(SALOMEDS.AttributeIOR)
+       anIOR = myStudyBuilder.FindOrCreateAttribute(newMesh, "AttributeIOR")
        anIOR.SetValue(IOR)
        return newMesh.GetID()
 
 #------------------------------------------------------------  
 def AddNewHypothesis(IOR):
+       # VSR: added temporarily - objects are published automatically by the engine
+       aSO = myStudy.FindObjectIOR( IOR )
+       if aSO is not None:
+               return aSO.GetID()
+       # VSR ######################################################################
+
        res, HypothesisRoot = mySComponentMesh.FindSubObject (Tag_HypothesisRoot)
        if HypothesisRoot is None or res == 0:
                HypothesisRoot = myStudyBuilder.NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot)
-               anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeName");
-               aName = anAttr._narrow(SALOMEDS.AttributeName);
-               aName.SetValue("Hypothesis Definition");
-               anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable");
-               aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable);
+               aName = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeName");
+               aName.SetValue("Hypotheses");
+               aSelAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable");
                aSelAttr.SetSelectable(0);
-               anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributePixMap");
-               aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap);
+               aPixmap = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributePixMap");
                aPixmap.SetPixMap( "mesh_tree_hypo.png" );
  
        # Add New Hypothesis
        newHypo = myStudyBuilder.NewObject(HypothesisRoot)
-       newHypo = newHypo._narrow(SALOMEDS.SObject)
-       anAttr  = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributePixMap")
-       aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap)
+       aPixmap = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributePixMap")
        H = orb.string_to_object(IOR)
-       H = H._narrow( SMESH.SMESH_Hypothesis );
        aType = H.GetName();
        aPixmap.SetPixMap( "mesh_tree_hypo.png_" + aType );
-       anAttr = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributeIOR");
-       anIOR = anAttr._narrow(SALOMEDS.AttributeIOR);
+       anIOR = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributeIOR");
        anIOR.SetValue(IOR);
        return newHypo.GetID();
 
 #------------------------------------------------------------
 def AddNewAlgorithms(IOR):
+       # VSR: added temporarily - objects are published automatically by the engine
+       aSO = myStudy.FindObjectIOR( IOR )
+       if aSO is not None:
+               return aSO.GetID()
+       # VSR ######################################################################
+
        res, AlgorithmsRoot = mySComponentMesh.FindSubObject (Tag_AlgorithmsRoot)
        if  AlgorithmsRoot is None or res == 0:
                AlgorithmsRoot = myStudyBuilde.NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot)
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeName")
-               aName = anAttr._narrow(SALOMEDS.AttributeName);
-               aName.SetValue("Algorithms Definition");
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable")
-               aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable);
+               aName = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeName")
+               aName.SetValue("Algorithms");
+               aSelAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable")
                aSelAttr.SetSelectable(0);
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap");
-               aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap);
+               aPixmap = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap");
                aPixmap.SetPixMap( "mesh_tree_algo.png" );
 
   # Add New Algorithms
        newHypo = myStudyBuilder.NewObject(AlgorithmsRoot)
-       newHypo = newHypo._narrow(SALOMEDS.SObject)
-       anAttr = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributePixMap");
+       aPixmap = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributePixMap");
        aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap);
        H = orb.string_to_object(IOR)
-       H = H._narrow( SMESH.SMESH_Hypothesis);
        aType = H.GetName();    #QString in fact
        aPixmap.SetPixMap( "mesh_tree_algo.png_" + aType );
-       anAttr = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributeIOR");
-       anIOR = anAttr._narrow(SALOMEDS.AttributeIOR);
+       anIOR = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributeIOR");
        anIOR.SetValue(IOR);
        return newHypo.GetID();
 
 
 #------------------------------------------------------------
 def SetShape(ShapeEntry, MeshEntry):
-
        SO_MorSM = myStudy.FindObjectID( MeshEntry )
-       SO_MorSM = SO_MorSM._narrow(SALOMEDS.SObject)
        SO_GeomShape = myStudy.FindObjectID( ShapeEntry );
-       SO_GeomShape = SO_GeomShape._narrow(SALOMEDS.SObject)
 
        if SO_MorSM is not None and SO_GeomShape is not None :
+               # VSR: added temporarily - shape reference is published automatically by the engine
+               res, Ref = SO_MorSM.FindSubObject( Tag_RefOnShape );
+               if res == 1 :
+                       return;
+               # VSR ######################################################################
+       
                SO = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnShape);
-               SO = SO._narrow(SALOMEDS.SObject)
                myStudyBuilder.Addreference (SO,SO_GeomShape);
   
 
@@ -188,19 +183,28 @@ def SetHypothesis(Mesh_Or_SubMesh_Entry, Hypothesis_Entry):
        res, AHR = SO_MorSM.FindSubObject (Tag_RefOnAppliedHypothesis)
        if  AHR is None or res == 0: 
                AHR = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnAppliedHypothesis);
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeName");
-               aName = anAttr._narrow(SALOMEDS.AttributeName);
-               aName.SetValue("Applied Hypothesis");
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeSelectable");
-               aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable);
+               aName = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeName");
+               
+               # The same name as in SMESH_Mesh_i::AddHypothesis() ##################
+               aName.SetValue("Applied hypotheses");
+               
+               aSelAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeSelectable");
                aSelAttr.SetSelectable(0);
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributePixMap");
-               aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap);
+               aPixmap = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributePixMap");
                aPixmap.SetPixMap( "mesh_tree_hypo.png" );
-               
-               SO = myStudyBuilder.NewObject(AHR);
-               SO = SO._narrow(SALOMEDS.SObject)
-               myStudyBuilder.Addreference (SO,SO_Hypothesis);
+               
+       # VSR: added temporarily - reference to applied hypothesis is published automatically by the engine
+       else :
+               it = myStudy.NewChildIterator(AHR);
+               while it.More() :
+                       res, Ref = it.Value().ReferencedObject();
+                       if res and Ref is not None and Ref.GetID() == Hypothesis_Entry :
+                               return;
+                       it.Next();
+       # VSR ######################################################################
+       
+       SO = myStudyBuilder.NewObject(AHR);
+       myStudyBuilder.Addreference (SO,SO_Hypothesis);
 
 #------------------------------------------------------------
 def SetAlgorithms(Mesh_Or_SubMesh_Entry, Algorithms_Entry):
@@ -211,16 +215,26 @@ def SetAlgorithms(Mesh_Or_SubMesh_Entry, Algorithms_Entry):
        res, AHR = SO_MorSM.FindSubObject (Tag_RefOnAppliedAlgorithms);
        if AHR is None or res == 0: 
                AHR = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnAppliedAlgorithms);
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeName");
-               aName = anAttr._narrow(SALOMEDS.AttributeName);
-               aName.SetValue("Applied Algorithm");
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeSelectable");
-               aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable);
+               aName = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeName");
+
+               # The same name as in SMESH_Mesh_i::AddHypothesis() ##################
+               aName.SetValue("Applied algorithms");
+               
+               aSelAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeSelectable");
                aSelAttr.SetSelectable(0);
-               anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributePixMap");
-               aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap);
+               aPixmap = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributePixMap");
                aPixmap.SetPixMap( "mesh_tree_algo.png" );
-    
+                       
+       # VSR: added temporarily - reference to applied hypothesis is published automatically by the engine
+       else :
+               it = myStudy.NewChildIterator(AHR);
+               while it.More() :
+                       res, Ref = it.Value().ReferencedObject();
+                       if res and Ref is not None and Ref.GetID() == Algorithms_Entry :
+                               return;
+                       it.Next();
+       # VSR ######################################################################
+       
        SO = myStudyBuilder.NewObject(AHR);
        myStudyBuilder.Addreference (SO,SO_Algorithms);
   
@@ -234,40 +248,41 @@ def UnSetHypothesis( Applied_Hypothesis_Entry ):
 
 #------------------------------------------------------------
 def AddSubMesh ( SO_Mesh_Entry, SM_IOR, ST):
+       # VSR: added temporarily - objects are published automatically by the engine
+       aSO = myStudy.FindObjectIOR( SM_IOR )
+       if aSO is not None:
+               return aSO.GetID()
+       # VSR ######################################################################
+       
        SO_Mesh = myStudy.FindObjectID( SO_Mesh_Entry )
        if ( SO_Mesh ) : 
     
                if  ST == ShapeTypeCompSolid : 
                        Tag_Shape = Tag_SubMeshOnSolid;    
-                       Name = "SubMeshes On Solid";
+                       Name = "SubMeshes on Solid";
                elif ST == ShapeTypeFace :
                        Tag_Shape = Tag_SubMeshOnFace;     
-                       Name = "SubMeshes On Face";
+                       Name = "SubMeshes on Face";
                elif ST == ShapeTypeEdge :
                        Tag_Shape = Tag_SubMeshOnEdge;     
-                       Name = "SubMeshes On Edge";
+                       Name = "SubMeshes on Edge";
                elif ST == ShapeTypeVertex :
                        Tag_Shape = Tag_SubMeshOnVertex;   
-                       Name = "SubMeshes On Vertex";
+                       Name = "SubMeshes on Vertex";
                else :
                        Tag_Shape = Tag_SubMeshOnCompound; 
-                       Name = "SubMeshes On Compound";
+                       Name = "SubMeshes on Compound";
                
                res, SubmeshesRoot = SO_Mesh.FindSubObject (Tag_Shape)
                if SubmeshesRoot is None or res == 0:
                        SubmeshesRoot = myStudyBuilder.NewObjectToTag (SO_Mesh, Tag_Shape);
-                       anAttr = myStudyBuilder.FindOrCreateAttribute(SubmeshesRoot, "AttributeName");
-                       
-                       aName = anAttr._narrow(SALOMEDS.AttributeName);
+                       aName = myStudyBuilder.FindOrCreateAttribute(SubmeshesRoot, "AttributeName");
                        aName.SetValue(Name);
-                       anAttr = myStudyBuilder.FindOrCreateAttribute(SubmeshesRoot, "AttributeSelectable");
-                       aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable);
+                       aSelAttr = myStudyBuilder.FindOrCreateAttribute(SubmeshesRoot, "AttributeSelectable");
                        aSelAttr.SetSelectable(0);
                
                SO = myStudyBuilder.NewObject (SubmeshesRoot); 
-               SO = SO._narrow(SALOMEDS.SObject)
-               anAttr = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeIOR");
-               anIOR = anAttr._narrow(SALOMEDS.AttributeIOR);
+               anIOR = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeIOR");
                anIOR.SetValue(SM_IOR);
                return  SO.GetID();
         
@@ -275,24 +290,28 @@ def AddSubMesh ( SO_Mesh_Entry, SM_IOR, ST):
 
 #------------------------------------------------------------
 def AddSubMeshOnShape (Mesh_Entry, GeomShape_Entry, SM_IOR, ST) :
-  SO_GeomShape = myStudy.FindObjectID( GeomShape_Entry );
-  if  SO_GeomShape != None : 
-       SM_Entry = AddSubMesh (Mesh_Entry,SM_IOR,ST);
-       SO_SM = myStudy.FindObjectID( SM_Entry );
-
-       if  SO_SM != None :
-               SetShape (GeomShape_Entry, SM_Entry);
-               return SO_SM.GetID();
+       # VSR: added temporarily - objects are published automatically by the engine
+       aSO = myStudy.FindObjectIOR( SM_IOR )
+       if aSO is not None:
+               return aSO.GetID()
+       # VSR ######################################################################
+       SO_GeomShape = myStudy.FindObjectID( GeomShape_Entry );
+       if  SO_GeomShape != None : 
+               SM_Entry = AddSubMesh (Mesh_Entry,SM_IOR,ST);
+               SO_SM = myStudy.FindObjectID( SM_Entry );
+
+               if  SO_SM != None :
+                       SetShape (GeomShape_Entry, SM_Entry);
+                       return SM_Entry;
     
-  return None;
+       return None;
 
 
 #------------------------------------------------------------
 def SetName(Entry, Name):
        SO = myStudy.FindObjectID( Entry );
        if SO != None : 
-               anAttr = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeName");
-               aName = anAttr._narrow(SALOMEDS.AttributeName);
+               aName = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeName");
                aName.SetValue(Name);