Salome HOME
Merge branch 'master' into gni/adaptation
authorGérald NICOLAS <gerald.nicolas@edf.fr>
Mon, 15 Feb 2021 13:36:21 +0000 (14:36 +0100)
committerGérald NICOLAS <gerald.nicolas@edf.fr>
Mon, 15 Feb 2021 13:36:21 +0000 (14:36 +0100)
34 files changed:
CMakeLists.txt
doc/salome/examples/adaptation_ex01.py [new file with mode: 0644]
doc/salome/gui/SMESH/images/adaptation_01.png [new file with mode: 0644]
doc/salome/gui/SMESH/images/adaptation_02.png [new file with mode: 0644]
doc/salome/gui/SMESH/input/adaptation.rst [new file with mode: 0644]
doc/salome/gui/SMESH/input/index.rst
doc/salome/gui/SMESH/input/smeshpy_interface.rst
doc/salome/gui/SMESH/input/tui_adaptation.rst [new file with mode: 0644]
idl/CMakeLists.txt
idl/MG_ADAPT.idl [new file with mode: 0644]
idl/SMESH_Gen.idl
resources/CMakeLists.txt
resources/SalomeApp.xml.in
resources/adapt_mg_adapt.png [new file with mode: 0755]
src/CMakeLists.txt
src/SMESH/CMakeLists.txt
src/SMESH/MG_ADAPT.cxx [new file with mode: 0644]
src/SMESH/MG_ADAPT.hxx [new file with mode: 0644]
src/SMESHGUI/CMakeLists.txt
src/SMESHGUI/MG_ADAPTGUI.cxx [new file with mode: 0644]
src/SMESHGUI/MG_ADAPTGUI.hxx [new file with mode: 0644]
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_AdaptDlg.cxx [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_AdaptDlg.h [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_Operations.h
src/SMESHGUI/SMESH_images.ts
src/SMESHGUI/SMESH_msg_en.ts
src/SMESHGUI/SMESH_msg_fr.ts
src/SMESH_I/CMakeLists.txt
src/SMESH_I/MG_ADAPT_i.cxx [new file with mode: 0644]
src/SMESH_I/MG_ADAPT_i.hxx [new file with mode: 0644]
src/SMESH_I/SMESH_Gen_i.hxx

index 6796fcfe9254599b1154d524b9f4ad4187fcf3e0..651fbb877756f3cbcce0fe4437cc7bfbb0de06e1 100644 (file)
@@ -65,7 +65,7 @@ SET(BUILD_SHARED_LIBS TRUE)
 # ============
 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
 OPTION(SALOME_BUILD_DOC "Generate SALOME SMESH documentation" ON)
-  
+
 # Advanced options:
 OPTION(SALOME_BUILD_GUI           "Enable GUI" ON)
 OPTION(SALOME_SMESH_USE_CGNS      "Enable import/export to CGNS format" OFF)
@@ -142,7 +142,7 @@ IF(SALOME_BUILD_GUI)
   IF(EXISTS ${GUI_ROOT_DIR})
     FIND_PACKAGE(SalomeGUI)
     SALOME_GUI_WITH_CORBA() #check whether GUI built with CORBA
-    SALOME_GUI_MODE(SALOME_USE_VTKVIEWER SALOME_USE_SALOMEOBJECT 
+    SALOME_GUI_MODE(SALOME_USE_VTKVIEWER SALOME_USE_SALOMEOBJECT
                     OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_PYCONSOLE)
     ##
     ## Prerequisites From GUI:
@@ -191,6 +191,15 @@ IF(NOT WITH_SHAPER_STUDY AND SALOME_BUILD_TESTS)
   MESSAGE(WARNING "SHAPERSTUDY is not found; the corresponding tests will be omitted")
 ENDIF()
 
+# Find MEDCoupling
+# ================
+SET(MEDCOUPLING_ROOT_DIR $ENV{MEDCOUPLING_ROOT_DIR} CACHE PATH "Path to the MEDCoupling tool")
+IF(EXISTS ${MEDCOUPLING_ROOT_DIR})
+  FIND_PACKAGE(SalomeMEDCoupling REQUIRED)   # will reload HDF5, MEDFile, XDR, etc ...
+ELSE(EXISTS ${MEDCOUPLING_ROOT_DIR})
+  MESSAGE(FATAL_ERROR "We absolutely need the MEDCoupling tool, please define MEDCOUPLING_ROOT_DIR !")
+ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR})
+
 ##
 ## SMESH specifics
 ##
@@ -198,7 +207,7 @@ ENDIF()
 # VTK is obligatiry for the SMESH
 FIND_PACKAGE(SalomeVTK REQUIRED)
 
-FIND_PACKAGE(SalomeOpenCASCADE REQUIRED) 
+FIND_PACKAGE(SalomeOpenCASCADE REQUIRED)
 
 IF(SALOME_SMESH_USE_CGNS)
   FIND_PACKAGE(SalomeCGNS)
@@ -224,7 +233,7 @@ IF(WIN32)
     MESSAGE(STATUS "Build MEFISTO2D mesher using Fortran to C generator")
   ELSE(${F2C_FOUND})
     MESSAGE(FATAL "Fortran to C generator is not found: MEFISTO2D mesher cannot be compiled! Please define F2C_ROOT_DIR !")
-  ENDIF(${F2C_FOUND})  
+  ENDIF(${F2C_FOUND})
 ENDIF(WIN32)
 
 IF(SALOME_SMESH_ENABLE_MEFISTO)
@@ -243,32 +252,32 @@ SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOM
 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
-SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH 
+SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
    "Install path: SALOME scripts")
-SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH 
+SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
    "Install path: SALOME script data")
-SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH 
+SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
    "Install path: SALOME Python scripts")
-SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH 
+SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH
    "Install path: SALOME application skeleton - scripts")
-SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH 
+SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH
    "Install path: SALOME application skeleton - Python")
 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
-SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH 
+SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
    "Install path: SALOME Python shared modules")
-SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH 
-    "Install path: local SALOME CMake files") 
+SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH
+    "Install path: local SALOME CMake files")
 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
   "Install path: local SALOME config files (obsolete, to be removed)")
 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
 
 # Specific to SMESH:
-SET(SALOME_SMESH_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/smesh" CACHE PATH 
+SET(SALOME_SMESH_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/smesh" CACHE PATH
     "Install path: SALOME SMESH specific data")
-SET(SALOME_SMESH_INSTALL_PLUGINS share/salome/plugins/smesh CACHE PATH 
+SET(SALOME_SMESH_INSTALL_PLUGINS share/salome/plugins/smesh CACHE PATH
     "Install path: SALOME SMESH plugins")
-    
+
 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
@@ -276,13 +285,23 @@ MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
 MARK_AS_ADVANCED(SALOME_SMESH_INSTALL_RES_DATA SALOME_SMESH_INSTALL_PLUGINS)
 
+# Specific to ADAPT:
+# SET(SALOME_ADAPT_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/adapt" CACHE PATH
+#   "Install path: SALOME ADAPT specific data")
+SET(SALOME_ADAPT_INSTALL_SAMPLES share/salome/adaptsamples CACHE PATH
+  "Install path: SALOME ADAPT samples")
+SET(SALOME_ADAPT_INSTALL_TEST ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test CACHE PATH
+    "Install path: SALOME ADAPT Test files")
+SET(SALOME_ADAPT_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/adapt" CACHE PATH
+    "Install path: SALOME ADAPT specific data")
+
 # Accumulate environment variables for SMESH module
 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
-SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) 
+SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
 
-# Sources 
+# Sources
 # ========
 
 ADD_SUBDIRECTORY(idl)
@@ -309,7 +328,7 @@ INCLUDE(CMakePackageConfigHelpers)
 
 # List of targets in this project we want to make visible to the rest of the world.
 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
-SET(_${PROJECT_NAME}_exposed_targets 
+SET(_${PROJECT_NAME}_exposed_targets
   SMESHControls MeshDriver MeshDriverDAT MeshDriverGMF MeshDriverMED
   MeshDriverSTL MeshDriverUNV MEDWrapper
   SMDS SMESHimpl SMESHEngine SMESHClient SMESHDS
@@ -319,7 +338,7 @@ SET(_${PROJECT_NAME}_exposed_targets
 
 IF(SALOME_SMESH_ENABLE_MEFISTO)
   LIST(APPEND _${PROJECT_NAME}_exposed_targets
-       MEFISTO2D) 
+       MEFISTO2D)
 ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
 
 IF(SALOME_BUILD_GUI)
@@ -329,7 +348,7 @@ IF(SALOME_BUILD_GUI)
 ENDIF(SALOME_BUILD_GUI)
 
 IF(SALOME_SMESH_USE_CGNS)
-  LIST(APPEND _${PROJECT_NAME}_exposed_targets 
+  LIST(APPEND _${PROJECT_NAME}_exposed_targets
     MeshDriverCGNS
   )
 ENDIF(SALOME_SMESH_USE_CGNS)
@@ -346,7 +365,7 @@ SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}")
 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
 SET(CGNS_ROOT_DIR "${CGNS_ROOT_DIR}")
 SET(TBB_ROOT_DIR  "${TBB_ROOT_DIR}")
+
 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
 
 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
@@ -369,5 +388,5 @@ INSTALL(FILES
   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
 
 # Install the export set for use with the install-tree
-INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" 
+INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
   FILE ${PROJECT_NAME}Targets.cmake)
diff --git a/doc/salome/examples/adaptation_ex01.py b/doc/salome/examples/adaptation_ex01.py
new file mode 100644 (file)
index 0000000..7956f95
--- /dev/null
@@ -0,0 +1,68 @@
+# Remeshing with MG-Adapt
+import os
+import salome
+salome.salome_init()
+
+import SMESH
+from salome.smesh import smeshBuilder
+smesh = smeshBuilder.New()
+
+# directory
+rootdir = ...
+
+# Test 1 : remeshing with a local size, surface
+#--- Creation of the object for the adaptation ---
+objet_adapt = smesh.Adaptation('MG_Adapt')
+
+#--- Initial mesh ---
+objet_adapt.setMEDFileIn(os.path.join(rootdir, "maill.01.med"))
+#--- Final mesh ---
+objet_adapt.setMEDFileOut(os.path.join(rootdir, "maill.01.adapt.med"))
+
+#--- Creation of the hypothesis ---
+hypo = smesh.CreateAdaptationHypothesis()
+#    Options
+hypo.setSizeMapType('Local')
+hypo.setSizeMapFieldName('TAILLE')
+hypo.setTimeStepRankLast()
+hypo.setOptionValue("adaptation", "surface")
+
+#--- Link between hypothesis and object ---
+objet_adapt.AddHypothesis(hypo)
+
+#--- Compute without publication
+err = objet_adapt.Compute(False)
+
+#--- Clean
+del objet_adapt
+
+
+
+# Test 2 : remeshing with a background size, volume
+#--- Creation of the object for the adaptation ---
+objet_adapt = smesh.Adaptation('MG_Adapt')
+
+#--- Initial mesh ---
+objet_adapt.setMEDFileIn(os.path.join(rootdir, "maill.02.med"))
+#--- Background mesh ---
+objet_adapt.setMEDFileBackground(rootdir, "maill.size.02.med"))
+#--- Final mesh ---
+objet_adapt.setMEDFileOut(os.path.join(rootdir, "maill.02.adapt.med"))
+
+#--- Creation of the hypothesis ---
+hypo = smesh.CreateAdaptationHypothesis()
+#    Options
+hypo.setSizeMapType('Background')
+hypo.setSizeMapFieldName('TAILLE')
+hypo.setTimeStepRank(1,1)
+hypo.setOptionValue("adaptation", "both")
+
+#--- Link between hypothesis and object ---
+objet_adapt.AddHypothesis(hypo)
+
+#--- Compute without publication
+err = objet_adapt.Compute(False)
+
+#--- Clean
+del objet_adapt
+
diff --git a/doc/salome/gui/SMESH/images/adaptation_01.png b/doc/salome/gui/SMESH/images/adaptation_01.png
new file mode 100644 (file)
index 0000000..67cb8b6
Binary files /dev/null and b/doc/salome/gui/SMESH/images/adaptation_01.png differ
diff --git a/doc/salome/gui/SMESH/images/adaptation_02.png b/doc/salome/gui/SMESH/images/adaptation_02.png
new file mode 100644 (file)
index 0000000..1f3f9ed
Binary files /dev/null and b/doc/salome/gui/SMESH/images/adaptation_02.png differ
diff --git a/doc/salome/gui/SMESH/input/adaptation.rst b/doc/salome/gui/SMESH/input/adaptation.rst
new file mode 100644 (file)
index 0000000..624851d
--- /dev/null
@@ -0,0 +1,38 @@
+.. _adaptation_page:
+
+**********
+Adaptation
+**********
+
+Mesh module provides the possibility to perform different adaptations of a mesh.
+
+.. note::
+  A mesh adaptation based on splitting is available by the HOMARD module.
+
+.. _mg_adapt_anchor:
+
+MG_Adapt
+########
+
+For meshes made of triangles and/or tetrahedra, remeshing operations are available with the MG-Adapt plugin. The remeshing is based on wanted mesh sizes defined over the mesh or as a constant. The boundaries are dedeuced from the initial mesh.
+
+To start **Remeshing** operation, select **MG Adapt** tab in **Adaptation** dialog.
+
+.. image:: ../images/adaptation_01.png
+  :align: center
+
+
+* **Mesh In** is the initial mesh to remesh.
+* **Mesh Out** is the resulting mesh after remeshing. By default, the name of the initial mesh is kept and the file name is based on the name of the initial mesh.
+* **Size map definition** is a choice between **Local**, **Background** and **Constant**.
+
+- If the choice is **Background**, the name of the MED file must be given.
+- If the choice is **Local** or **Background**, the name of the field must be selected from the list, together with time step.
+
+.. image:: ../images/adaptation_02.png
+  :align: center
+
+.. note::
+  The exhaustive description of MG-Adapt can be read into its documentation. It can be reached by the general help button.
+
+**See Also** a sample TUI Script of :ref:`tui_adaptation_page`.
index c6a2ade379f250957cb339f61afe82365cfb8fc0..fcd97b7b810a74fcfa9a4f2b982c9e915116f955 100644 (file)
@@ -14,15 +14,16 @@ Introduction to Mesh module
 
 * :ref:`creating meshes <about_meshes_page>` in different ways:
 
-  * by meshing geometrical models previously created or imported by the Geometry component; 
+  * by meshing geometrical models previously created or imported by the Geometry component;
   * bottom-up, using :ref:`mesh edition <modifying_meshes_page>`, especially :ref:`extrusion <extrusion_page>` and :ref:`revolution <revolution_page>`;
-  * by generation of the 3D mesh from the 2D mesh not based on the geometry (:ref:`imported <importing_exporting_meshes_page>` for example); 
+  * by generation of the 3D mesh from the 2D mesh not based on the geometry (:ref:`imported <importing_exporting_meshes_page>` for example);
+
 * :ref:`importing and exporting meshes <importing_exporting_meshes_page>` in various formats;
-* :ref:`modifying meshes <modifying_meshes_page>` with a vast array of dedicated operations; 
+* :ref:`modifying meshes <modifying_meshes_page>` with a vast array of dedicated operations;
 * :ref:`creating groups <grouping_elements_page>` of mesh elements;
 * filtering mesh entities (nodes or elements) using :ref:`Filters <filters_page>` functionality for :ref:`creating groups <grouping_elements_page>` and applying :ref:`mesh modifications <modifying_meshes_page>`;
 * :ref:`viewing meshes <viewing_meshes_overview_page>` in the VTK viewer and :ref:`getting info <mesh_infos_page>` on mesh and its sub-objects;
+* :ref:`remeshing meshes <adaptation_page>`;
 * applying to meshes :ref:`Quality Controls <quality_page>`, allowing to highlight important elements;
 * taking various :ref:`measurements <measurements_page>` of the mesh objects.
 
@@ -35,7 +36,7 @@ It is possible to use the variables predefined in :ref:`Salome notebook <using_n
 Mesh module preferences are described in the :ref:`mesh_preferences_page` section of SALOME Mesh Help.
 
 .. image:: ../images/image7.jpg
-       :align: center 
+       :align: center
 
 .. centered::
        Example of MESH module usage for engineering tasks
@@ -52,9 +53,10 @@ Mesh module preferences are described in the :ref:`mesh_preferences_page` sectio
    grouping_elements
    about_filters
    about_quality_controls
+   adaptation
    measurements
    viewing_meshes_overview
    smeshpy_interface
-   tools       
+   tools
    mesh_preferences
    using_notebook_smesh_page
index a08cb2d0ab0207d03c82a4f8898815bba22873b4..8fa865382b03539e7204d2a4681807d9b6ebe7c9 100644 (file)
@@ -23,7 +23,7 @@ meshes. It can be used to create an empty mesh or to import mesh from the data f
 As soon as a mesh is created, it is possible to manage it via its own
 methods, described in class :class:`smeshBuilder.Mesh` documentation.
 
-Class :class:`smeshstudytools.SMeshStudyTools` provides several methods to manipulate mesh objects in Salome study. 
+Class :class:`smeshstudytools.SMeshStudyTools` provides several methods to manipulate mesh objects in Salome study.
 
 A usual workflow to generate a mesh on geometry is following:
 
@@ -54,14 +54,14 @@ A usual workflow to generate a mesh on geometry is following:
                maxArea  = mefisto.LocalLength( 100. )
                netgen.SetMaxSize( 20. )
                netgen.SetFineness( smeshBuilder.VeryCoarse )
-  
+
 #. :ref:`Compute the mesh <compute_anchor>` (generate mesh nodes and elements):
        .. code-block:: python
 
                mesh.Compute()
 
 An easiest way to start with Python scripting is to do something in
-GUI and then to get a corresponding Python script via 
+GUI and then to get a corresponding Python script via
 **File > Dump Study** menu item. Don't forget that you can get
 all methods of any object in hand (e.g. a mesh group or a hypothesis)
 by calling *dir()* Python built-in function.
@@ -95,6 +95,7 @@ the following links:
    tui_transforming_meshes
    tui_viewing_meshes
    tui_quality_controls
+   tui_adaptation
    tui_measurements
    tui_work_on_objects_from_gui
    tui_notebook_smesh
diff --git a/doc/salome/gui/SMESH/input/tui_adaptation.rst b/doc/salome/gui/SMESH/input/tui_adaptation.rst
new file mode 100644 (file)
index 0000000..7db15c6
--- /dev/null
@@ -0,0 +1,18 @@
+.. _tui_adaptation_page:
+
+**********
+Adaptation
+**********
+
+.. _tui_mg_adapt:
+
+MG_Adapt
+========
+
+.. literalinclude:: ../../../examples/adaptation_ex01.py
+    :language: python
+
+:download:`Download this script <../../../examples/adaptation_ex01.py>`
+
+
+**See Also** the GUI :ref:`adaptation_page`.
index 7ab17aef9e3072621894161b00327c97cacf4eff..6387eb74135f8938024c242ace37e1faf5fbac69 100644 (file)
@@ -36,6 +36,7 @@ SET(SalomeIDLSMESH_IDLSOURCES
   SMESH_Pattern.idl
   SMESH_MeshEditor.idl
   SMESH_Measurements.idl
+  MG_ADAPT.idl
 )
 
 SET(_idl_include_dirs
diff --git a/idl/MG_ADAPT.idl b/idl/MG_ADAPT.idl
new file mode 100644 (file)
index 0000000..6a4c7c9
--- /dev/null
@@ -0,0 +1,153 @@
+// Copyright (C) 2011-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+// File   : MG_ADAPT.hxx
+//
+#ifndef MG_ADAPT_IDL
+#define MG_ADAPT_IDL
+
+#include "SALOME_Component.idl"
+#include "SALOME_Exception.idl"
+#include "SALOME_GenericObj.idl"
+#include "SALOMEDS.idl"
+#include "SMESH_Mesh.idl"
+
+module SMESH{
+
+  typedef sequence<string> str_array ;
+  struct MgAdaptHypothesisData
+  {
+    string  myFileInDir, myMeshFileIn, myInMeshName, myMeshFileBackground, myOutMeshName,
+            myMeshFileOut,  myFileOutDir, myFileSizeMapDir, myFieldName;
+    boolean fromMedFile;
+    boolean myPublish, myMeshOutMed;
+    boolean myUseLocalMap, myUseBackgroundMap, myUseConstantValue;
+    double  myConstantValue;
+    long    myRank, myTimeStep;
+    boolean myUseNoTimeStep, myUseLastTimeStep, myUseChosenTimeStep;
+    string  myWorkingDir, myLogFile;
+    boolean myPrintLogInFile, myKeepFiles, myRemoveLogOnSuccess;
+    long    myVerboseLevel;
+  };
+
+
+  interface MG_ADAPT : SALOME::GenericObj
+  {
+    //MG_ADAPT CreateMG_ADAPT(in PortableServer::POA_var poa);
+    void setData( inout MgAdaptHypothesisData data);
+
+    void setMedFileIn(in string MedFileIn );
+    string getMedFileIn();
+
+    void setMedFileOut(in string MedFileOut);
+    string getMedFileOut();
+
+    void setMeshName(in string s);
+    string getMeshName();
+
+    void setMeshNameOut(in string s);
+    string getMeshNameOut();
+
+    void setMeshOutMed(in boolean b);
+    boolean getMeshOutMed();
+
+    void setPublish(in boolean b);
+    boolean getPublish();
+
+    void setSizeMapFieldName(in string s);
+    string getSizeMapFieldName();
+
+    void setTimeStep(in long s);
+    long getTimeStep() ;
+
+    void setTimeStepRank(in long s, in long f);
+    long getRank();
+
+    void setTimeStepRankLast();
+    void setNoTimeStep();
+
+    void setLogFile(in string f);
+    string getLogFile();
+
+    void setVerbosityLevel(in long f);
+    long getVerbosityLevel();
+
+    void setRemoveOnSuccess(in boolean f);
+    boolean getRemoveOnSuccess();
+
+    MgAdaptHypothesisData getData();
+
+    void setUseLocalMap(in boolean f);
+    boolean getUseLocalMap();
+
+    void setUseBackgroundMap(in boolean f);
+    boolean getUseBackgroundMap();
+
+    void setUseConstantValue(in boolean f);
+    boolean getUseConstantValue();
+
+    void setConstantSize(in double f);
+    double getConstantSize() ;
+
+    void setSizeMapFile(in string f);
+    string getSizeMapFile();
+
+    void setFromMedFile(in boolean f);
+    boolean isFromMedFile();
+
+    void setKeepWorkingFiles(in boolean f);
+    boolean getKeepWorkingFiles();
+
+    void setPrintLogInFile(in boolean f);
+    boolean getPrintLogInFile();
+
+    void setWorkingDir(in string f);
+    string getWorkingDir() ;
+
+    void setSizeMapType(in string f);
+    boolean setAll();
+    string getCommandToRun() ;
+    //long compute(out string errStr);
+    long compute();
+    string getErrMsg();
+    string getFileName() ;
+    string getExeName();
+    void copyMgAdaptHypothesisData(in MgAdaptHypothesisData f ) ;
+
+    //void checkDirPath(inout string  f);
+
+    boolean hasOptionDefined( in string optionName ) ;
+    void setOptionValue(in string optionName, in string optionValue) raises (SALOME::SALOME_Exception);
+    string getOptionValue(in string optionName, inout boolean isDefault) raises (SALOME::SALOME_Exception);
+    str_array getCustomOptionValuesStrVec() ;
+    str_array getOptionValuesStrVec() ;
+  };
+
+  typedef MG_ADAPT MG_ADAPT_HYPOTHESIS;
+  interface MG_ADAPT_OBJECT : SALOME::GenericObj
+  {
+    void setMeshIn(in SMESH_Mesh theMesh )   raises (SALOME::SALOME_Exception);
+    void setMEDFileIn(in string f)           raises (SALOME::SALOME_Exception);
+    void setMEDFileOut(in string f)          raises (SALOME::SALOME_Exception);
+    void setMEDFileBackground(in string f)   raises (SALOME::SALOME_Exception);
+    void AddHypothesis(in MG_ADAPT mg)       raises (SALOME::SALOME_Exception);
+    long Compute(in boolean Publish)         raises (SALOME::SALOME_Exception);
+  };
+
+};
+#endif // MG_ADAPT_IDL
index a7e4c50940d535482525235f37ca4fb35c27e86c..52295a43b239f0c8046f541d732361fd3625fd08 100644 (file)
@@ -43,6 +43,8 @@ module SMESH
   interface FilterManager;
   interface SMESH_Pattern;
   interface Measurements;
+  interface MG_ADAPT;
+  interface MG_ADAPT_OBJECT;
 
   /*!
    * Tags definition
@@ -136,7 +138,6 @@ module SMESH
     SMESH_Pattern GetPattern();
 
     Measurements  CreateMeasurements();
-
     /*!
       Set the current mode
      */
@@ -584,7 +585,10 @@ module SMESH
                          in GEOM::GEOM_Object theGeom,
                          in double theTolerance );    
 
-
+   
+       MG_ADAPT CreateMG_ADAPT();
+       MG_ADAPT_OBJECT Adaptation(in string adaptType);
+       MG_ADAPT CreateAdaptationHypothesis();
   };
 
 };
index 1a5619a10d4baf262bff2e3f5fec2e8b53d7d632..1306b1319958edf6e2552732c42ffd708c01745e 100644 (file)
@@ -22,6 +22,7 @@
 
 SET(SMESH_RESOURCES_FILES
   ModuleMesh.png
+  adapt_mg_adapt.png
   advanced_mesh_info.png
   bare_border_face.png
   bare_border_volume.png
index c69c4b5782fdb4102e22be6873db430e3bee96ef..c11851f4fbe3f9121225030d43ce14bab4d2a30e 100644 (file)
     <parameter name="vol_precision"                value="-6"  />
     <parameter name="selection_increment"          value="0"  />
     <parameter name="controls_increment"           value="2"  />
+    <!-- Adaptation -->
+    <parameter name="mg_adapt_file_mesh_out"       value="true"  />
+    <parameter name="mg_adapt_publish_mesh_out"    value="false"  />
+    <parameter name="mg_adapt_size_map"            value="Local"  />
+    <parameter name="mg_adapt_time_step"           value="None"  />
   </section>
   <section name="smesh_help" >
     <parameter name="User's Guide/Mesh module/User's Guide"      value="%SMESH_ROOT_DIR%/share/doc/salome/gui/SMESH/index.html;;http://docs.salome-platform.org/latest/gui/SMESH/index.html"/>
     <parameter name="User's Guide/Mesh module/Plug-ins/MacMesh plugin" value="%SMESH_ROOT_DIR%/share/doc/salome/gui/SMESH/MacMesh/index.html;;http://docs.salome-platform.org/latest/gui/SMESH/MacMesh/index.html"/>
     <parameter name="User's Guide/Mesh module/Plug-ins/blocFissure plugin" value="%SMESH_ROOT_DIR%/share/doc/salome/gui/SMESH/blocFissure/index.html;;http://docs.salome-platform.org/latest/gui/SMESH/blocFissure/index.html"/>
     <parameter name="User's Guide/Mesh module/Plug-ins/SpherePadder plugin" value="%SMESH_ROOT_DIR%/share/doc/salome/gui/SMESH/padder/index.html;;http://docs.salome-platform.org/latest/gui/SMESH/padder/index.html"/>
+    <parameter name="User's Guide/Mesh module/MG-Adapt plugin/User's Guide" value="%SMESH_ROOT_DIR%/share/doc/salome/gui/SMESH/index.html#adaptation;;http://docs.salome-platform.org/latest/gui/SMESH/index.html#adaptation"/>
+    <parameter name="User's Guide/Mesh module/MG-Adapt plugin/Reference"    value="%MESHGEMS_ROOT_DIR%/Docs/mg-adapt_api_manual.pdf"/>
+    <parameter name="User's Guide/Mesh module/MG-Adapt plugin/Manual"       value="%MESHGEMS_ROOT_DIR%/Docs/mg-adapt_user_manual.pdf"/>
     <parameter name="User's Guide/Mesh module/MGCleaner plugin/User's Guide" value="%SMESH_ROOT_DIR%/share/doc/salome/gui/SMESH/MGCleaner/index.html;;http://docs.salome-platform.org/latest/gui/SMESH/MGCleaner/index.html"/>
     <parameter name="User's Guide/Mesh module/MGCleaner plugin/Reference"    value="%MESHGEMS_ROOT_DIR%/Docs/mg-cleaner_api_manual.pdf"/>
     <parameter name="User's Guide/Mesh module/MGCleaner plugin/Manual"       value="%MESHGEMS_ROOT_DIR%/Docs/mg-cleaner_user_manual.pdf"/>
diff --git a/resources/adapt_mg_adapt.png b/resources/adapt_mg_adapt.png
new file mode 100755 (executable)
index 0000000..f2c1a93
Binary files /dev/null and b/resources/adapt_mg_adapt.png differ
index 6e74f5b5654abae7c0c6904baa407caa4bda001a..69ec0d05168b1733564afc01accfd9c6cd05258e 100644 (file)
@@ -51,7 +51,7 @@ ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
 # CGNS
 ##
 IF(SALOME_SMESH_USE_CGNS)
-  SET(SUBDIRS_CGNS 
+  SET(SUBDIRS_CGNS
     DriverCGNS
   )
 ENDIF(SALOME_SMESH_USE_CGNS)
@@ -60,9 +60,9 @@ ENDIF(SALOME_SMESH_USE_CGNS)
 # GUI
 ##
 IF(SALOME_BUILD_GUI)
-  SET(SUBDIRS_GUI OBJECT 
-                  SMESHFiltersSelection 
-                  SMESHGUI 
+  SET(SUBDIRS_GUI OBJECT
+                  SMESHFiltersSelection
+                  SMESHGUI
                   PluginUtils
                  SMESH_SWIG_WITHIHM
                  StdMeshersGUI
index 129ec5c41f01d73813e0dca56ee8a5b20f5a3a7f..55b8da58434733ba6a1b3160d7358521f2eec9d6 100644 (file)
@@ -38,6 +38,7 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/SMDS
   ${PROJECT_SOURCE_DIR}/src/SMESHDS
   ${PROJECT_SOURCE_DIR}/src/SMESHUtils
+  ${MEDCOUPLING_INCLUDE_DIRS}
 )
 
 # additional preprocessor / compiler flags
@@ -67,6 +68,7 @@ SET(_link_LIBRARIES
   MeshDriverUNV
   MeshDriverGMF
   ${DriverCGNS_LIB}
+  ${MEDCoupling_medloader}
 )
 
 # --- headers ---
@@ -86,6 +88,7 @@ SET(SMESHimpl_HEADERS
   SMESH_MesherHelper.hxx
   SMESH_ProxyMesh.hxx
   SMESH_SMESH.hxx
+  MG_ADAPT.hxx
 )
 
 # --- sources ---
@@ -104,6 +107,7 @@ SET(SMESHimpl_SOURCES
   SMESH_HypoFilter.cxx
   SMESH_ProxyMesh.cxx
   SMESH_MesherHelper.cxx
+  MG_ADAPT.cxx
 )
 
 # --- rules ---
diff --git a/src/SMESH/MG_ADAPT.cxx b/src/SMESH/MG_ADAPT.cxx
new file mode 100644 (file)
index 0000000..c3e95da
--- /dev/null
@@ -0,0 +1,1577 @@
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// file : MG_ADAPT.cxx
+
+#include "MG_ADAPT.hxx"
+
+#include "MeshFormatReader.hxx"
+#include "MeshFormatWriter.hxx"
+#include "MEDFileMesh.hxx"
+#include "MCAuto.hxx"
+#include "MEDFileData.hxx"
+#include "MEDFileField.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+
+#include <SALOME_NamingService.hxx>
+#include <Utils_SALOME_Exception.hxx>
+#include "Utils_CorbaException.hxx"
+
+#include <utilities.h>
+#include <iostream>
+#include <unistd.h>
+#include <TCollection_AsciiString.hxx>
+#include <cstring>
+#include <cstdlib>
+#include <boost/filesystem.hpp>
+
+using namespace MG_ADAPT;
+static std::string removeFile(std::string fileName, int& notOk)
+{
+  std::string errStr;
+  notOk = std::remove(fileName.c_str());
+  if (notOk) errStr = ToComment("\n error while removing file : ") << fileName;
+        else errStr = ToComment("\n file : ") << fileName << " succesfully deleted! \n ";
+
+  return errStr;
+}
+std::string remove_extension(const std::string& filename) {
+  size_t lastdot = filename.find_last_of(".");
+  if (lastdot == std::string::npos) return filename;
+  return filename.substr(0, lastdot);
+}
+namespace
+{
+struct GET_DEFAULT // struct used to get default value from GetOptionValue()
+{
+  bool isDefault;
+  operator bool* () {
+      return &isDefault;
+  }
+};
+}
+
+//----------------------------------------------------------------------------------------
+MgAdapt::MgAdapt()
+{
+  data = new MgAdaptHypothesisData();
+  data->myInMeshName = "";
+  data->fromMedFile = defaultFromMedFile();
+  data->myFileInDir = defaultWorkingDirectory();
+  data->myMeshFileIn = "";
+  data->myFileOutDir = defaultWorkingDirectory();
+  data->myOutMeshName = "";
+  data->myMeshFileOut = "";
+  data->myMeshOutMed = defaultMeshOutMed();
+  data->myPublish = defaultPublish();
+  data->myUseLocalMap = defaultUseLocalMap();
+  data->myUseBackgroundMap = defaultUseBackgroundMap();
+  data->myFileSizeMapDir = defaultWorkingDirectory();
+  data->myMeshFileBackground = "";
+  data->myUseConstantValue = defaultUseConstantValue();
+  data->myConstantValue = 0.0;
+  data->myFieldName = "";
+  data->myUseNoTimeStep = defaultUseNoTimeStep();
+  data->myUseLastTimeStep = defaultUseLastTimeStep();
+  data->myUseChosenTimeStep = defaultUseChosenTimeStep();
+  data->myTimeStep = -2;
+  data->myRank =  -2;
+  data->myWorkingDir = defaultWorkingDirectory();
+  data->myLogFile = defaultLogFile();
+  data->myVerboseLevel = defaultVerboseLevel();
+  data->myPrintLogInFile = defaultPrintLogInFile();
+  data->myKeepFiles = defaultKeepFiles();
+  data->myRemoveLogOnSuccess = defaultRemoveLogOnSuccess();
+
+  buildModel();
+  setAll();
+}
+MgAdapt::MgAdapt(MgAdaptHypothesisData* myData)
+{
+  data = new MgAdaptHypothesisData();
+  setData(myData);
+  buildModel();
+}
+
+MgAdapt::MgAdapt( const MgAdapt& copy)
+{
+  data = new MgAdaptHypothesisData();
+  MgAdaptHypothesisData *copyData = copy.getData();
+  copyMgAdaptHypothesisData(copyData);
+  setAll();
+
+  this->_option2value = copy._option2value;
+  this->_customOption2value = copy._customOption2value;
+  this->_defaultOptionValues = copy._defaultOptionValues;
+  this->_doubleOptions = copy._doubleOptions;
+  this->_charOptions = copy._charOptions;
+  this->_boolOptions = copy._boolOptions;
+}
+
+//-----------------------------------------------------------------------------------------
+MgAdapt::~MgAdapt()
+{
+  delete data;
+}
+void MgAdapt::buildModel()
+{
+
+  const char* boolOptionNames[] = { "compute_ridges", // yes
+                                    "" // mark of end
+                                  };
+  // const char* intOptionNames[] = { "max_number_of_errors_printed", // 1
+  //                                  "max_number_of_threads",        // 4
+  //                                  "" // mark of end
+  // };
+  const char* doubleOptionNames[] = { "max_memory",  // 0
+                                      "" // mark of end
+                                    };
+  const char* charOptionNames[] = { "components",  // "yes"
+                                    "adaptation",  // both
+                                    "" // mark of end
+                                  };
+
+  int i = 0;
+  while (boolOptionNames[i][0])
+  {
+    _boolOptions.insert( boolOptionNames[i] );
+    _option2value[boolOptionNames[i++]].clear();
+  }
+  // i = 0;
+  // while (intOptionNames[i][0])
+  //   _option2value[intOptionNames[i++]].clear();
+
+  i = 0;
+  while (doubleOptionNames[i][0]) {
+    _doubleOptions.insert(doubleOptionNames[i]);
+    _option2value[doubleOptionNames[i++]].clear();
+  }
+  i = 0;
+  while (charOptionNames[i][0]) {
+    _charOptions.insert(charOptionNames[i]);
+    _option2value[charOptionNames[i++]].clear();
+  }
+
+  // default values to be used while MG-Adapt
+
+  _defaultOptionValues["adaptation"    ] = "both";
+  _defaultOptionValues["components"    ] = "outside components";
+  _defaultOptionValues["compute_ridges"] = "yes";
+  _defaultOptionValues["max_memory"    ] = ToComment(defaultMaximumMemory());
+}
+
+//=============================================================================
+TOptionValues MgAdapt::getOptionValues() const
+{
+  TOptionValues vals;
+  TOptionValues::const_iterator op_val = _option2value.begin();
+  for ( ; op_val != _option2value.end(); ++op_val )
+    vals.insert( make_pair( op_val->first, getOptionValue( op_val->first, GET_DEFAULT() )));
+
+  return vals;
+}
+
+std::vector <std::string> MgAdapt::getOptionValuesStrVec() const
+{
+  std::vector <std::string> vals;
+  TOptionValues::const_iterator op_val = _option2value.begin();
+  for ( ; op_val != _option2value.end(); ++op_val )
+    vals.push_back(op_val->first+":"+getOptionValue( op_val->first, GET_DEFAULT() ));
+
+  return vals;
+}
+
+std::vector <std::string> MgAdapt::getCustomOptionValuesStrVec() const
+{
+  std::vector <std::string> vals;
+  TOptionValues::const_iterator op_val;
+  for ( op_val = _customOption2value.begin(); op_val != _customOption2value.end(); ++op_val )
+  {
+    vals.push_back(op_val->first+":"+getOptionValue( op_val->first, GET_DEFAULT() ));
+  }
+  return vals;
+}
+const TOptionValues& MgAdapt::getCustomOptionValues() const
+{
+  return _customOption2value;
+}
+void MgAdapt::setData(MgAdaptHypothesisData* myData)
+{
+  copyMgAdaptHypothesisData(myData);
+  setAll();
+}
+MgAdaptHypothesisData* MgAdapt::getData() const
+{
+  return data;
+}
+void MgAdapt::setMedFileIn(std::string fileName)
+{
+  if ( isFileExist(fileName) )
+  {
+    medFileIn = fileName;
+
+    if (medFileOut == "") // default MED file Out
+      medFileOut = remove_extension( fileName )+ ".adapt.med";
+  }
+  else
+  {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::BAD_PARAM;
+    std::string text = "\nThe file " + fileName + " does not exist.\n" ;
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+  }
+}
+
+std::string MgAdapt::getMedFileIn()
+{
+  return medFileIn;
+}
+
+void MgAdapt::setMedFileOut(std::string fileOut)
+{
+  medFileOut = fileOut;
+}
+std::string MgAdapt::getMedFileOut()
+{
+  return medFileOut;
+}
+void MgAdapt::setMeshOutMed(bool mybool)
+{
+  meshOutMed = mybool;
+}
+bool MgAdapt::getMeshOutMed()
+{
+  return meshOutMed;
+}
+void MgAdapt::setPublish(bool mybool)
+{
+  publish = mybool;
+}
+bool MgAdapt::getPublish()
+{
+  return publish;
+}
+void MgAdapt::setFieldName(std::string myFieldName)
+{
+  fieldName = myFieldName;
+}
+std::string MgAdapt::getFieldName()
+{
+  return fieldName;
+}
+void MgAdapt::setTimeStep(int time)
+{
+  timeStep = time;
+}
+int MgAdapt::getTimeStep() const
+{
+  return timeStep;
+}
+
+void MgAdapt::setRankTimeStep(int time, int myRank)
+{
+  timeStep = time;
+  rank = myRank;
+}
+
+int MgAdapt::getRank()
+{
+  return rank;
+}
+void MgAdapt::setTimeStepRankLast()
+{
+  myUseLastTimeStep = true;
+  myUseChosenTimeStep = false;
+  myUseNoTimeStep = false;
+  //~med_int aRank, tmst;
+     //~std::string fieldFile = useBackgroundMap ? sizeMapFile : medFileIn;
+  //~getTimeStepInfos(fieldFile, tmst, aRank);
+  //~setRankTimeStep((int) tmst, (int) aRank);
+}
+void MgAdapt::setNoTimeStep()
+{
+  myUseLastTimeStep = false;
+  myUseChosenTimeStep = false;
+  myUseNoTimeStep = true;
+  //~int aRank = (int)MED_NO_IT;
+  //~int tmst  = (int)MED_NO_DT ;
+  //~setRankTimeStep(tmst, aRank);
+}
+void MgAdapt::setChosenTimeStepRank()
+{
+  myUseLastTimeStep = false;
+  myUseChosenTimeStep = true;
+  myUseNoTimeStep = false;
+  //~int aRank = (int)MED_NO_IT;
+  //~int tmst  = (int)MED_NO_DT ;
+  //~setRankTimeStep(tmst, aRank);
+}
+void MgAdapt::setUseLocalMap(bool myLocal)
+{
+  useLocalMap = myLocal;
+}
+
+bool MgAdapt::getUseLocalMap()
+{
+  return useLocalMap;
+}
+
+void MgAdapt::setUseBackgroundMap(bool bckg)
+{
+  useBackgroundMap = bckg;
+}
+
+bool MgAdapt::getUseBackgroundMap()
+{
+  return useBackgroundMap;
+}
+
+void MgAdapt::setUseConstantValue(bool cnst)
+{
+  useConstantValue = cnst;
+}
+bool MgAdapt::getUseConstantValue()
+{
+  return useConstantValue;
+}
+void MgAdapt::setLogFile(std::string myLogFile)
+{
+  logFile = myLogFile;
+}
+std::string MgAdapt::getLogFile()
+{
+  return logFile;
+}
+void MgAdapt::setVerbosityLevel(int verboLevel)
+{
+  verbosityLevel = verboLevel;
+}
+int MgAdapt::getVerbosityLevel()
+{
+  return verbosityLevel;
+}
+void MgAdapt::setRemoveOnSuccess(bool rmons)
+{
+  removeOnSuccess = rmons;
+}
+bool MgAdapt::getRemoveOnSuccess()
+{
+  return removeOnSuccess;
+}
+void MgAdapt::setSizeMapFile(std::string mapFile)
+{
+  if ( mapFile == "" || isFileExist(mapFile) )
+  {
+    sizeMapFile = mapFile;
+  }
+  else
+  {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::BAD_PARAM;
+    std::string text = "\nThe file " + mapFile + " does not exist.\n" ;
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+  }
+}
+std::string MgAdapt::getSizeMapFile()
+{
+  return sizeMapFile;
+}
+
+void MgAdapt::setMeshName(std::string name)
+{
+  meshName = name;
+}
+std::string MgAdapt::getMeshName()
+{
+  return meshName;
+}
+void MgAdapt::setMeshNameOut(std::string name)
+{
+  meshNameOut = name;
+}
+std::string MgAdapt::getMeshNameOut()
+{
+  return meshNameOut;
+}
+void MgAdapt::setFromMedFile(bool mybool)
+{
+  fromMedFile = mybool;
+}
+bool MgAdapt::isFromMedFile()
+{
+  return fromMedFile;
+}
+void MgAdapt::setConstantValue(double cnst)
+{
+  constantValue = cnst;
+}
+double MgAdapt::getConstantValue() const
+{
+  return constantValue;
+}
+
+void MgAdapt::setWorkingDir(std::string dir)
+{
+  workingDir = dir;
+}
+std::string MgAdapt::getWorkingDir() const
+{
+  return workingDir;
+}
+void MgAdapt::setKeepWorkingFiles(bool mybool)
+{
+  toKeepWorkingFiles = mybool;
+}
+bool MgAdapt::getKeepWorkingFiles()
+{
+  return toKeepWorkingFiles;
+}
+void MgAdapt::setPrintLogInFile(bool print)
+{
+  printLogInFile = print;
+}
+bool MgAdapt::getPrintLogInFile()
+{
+  return printLogInFile;
+}
+
+bool MgAdapt::setAll()
+{
+
+  setFromMedFile(data->fromMedFile);
+  std::string file;
+  checkDirPath(data->myFileInDir);
+  file = data->myFileInDir+data->myMeshFileIn;
+  setMedFileIn(file);
+  setMeshName(data->myInMeshName);
+  setMeshNameOut(data->myOutMeshName);
+  checkDirPath(data->myFileOutDir);
+  std::string out = data->myFileOutDir+data->myMeshFileOut;
+  setMedFileOut(out);
+  setPublish(data->myPublish);
+  setMeshOutMed(data->myMeshOutMed);
+  setUseLocalMap(data->myUseLocalMap);
+  setUseBackgroundMap(data->myUseBackgroundMap);
+  setUseConstantValue(data->myUseConstantValue);
+
+  std::string mapfile;
+  if (useBackgroundMap)
+  {
+    checkDirPath(data->myFileSizeMapDir);
+    mapfile = data->myFileSizeMapDir+data->myMeshFileBackground;
+    setFieldName(data->myFieldName);
+  }
+  else if (useConstantValue)
+  {
+    setConstantValue(data->myConstantValue);
+  }
+  else
+  {
+    mapfile ="";
+    setConstantValue(0.0);
+    setFieldName(data->myFieldName);
+  }
+
+  setSizeMapFile(mapfile);
+  if (data->myUseNoTimeStep)
+    setNoTimeStep();
+  else if (data->myUseLastTimeStep)
+    setTimeStepRankLast();
+  else
+  {
+    setChosenTimeStepRank();
+    setRankTimeStep(data->myTimeStep, data->myRank);
+  }
+  /* Advanced options */
+  setWorkingDir(data->myWorkingDir);
+  checkDirPath(data->myWorkingDir);
+  setLogFile(data->myWorkingDir+defaultLogFile());
+  setVerbosityLevel(data->myVerboseLevel);
+  setRemoveOnSuccess(data->myRemoveLogOnSuccess);
+  setPrintLogInFile(data->myPrintLogInFile);
+  setKeepWorkingFiles(data->myKeepFiles);
+
+  return true;
+}
+
+void MgAdapt::checkDirPath(std::string& dirPath)
+{
+  const char lastChar = *dirPath.rbegin();
+#ifdef WIN32
+  if(lastChar != '\\') dirPath+='\\';
+#else
+  if(lastChar != '/') dirPath+='/';
+#endif
+}
+//=============================================================================
+void MgAdapt::setOptionValue(const std::string& optionName,
+                             const std::string& optionValue)
+throw (std::invalid_argument)
+{
+//   INFOS("setOptionValue");
+//   std::cout << "optionName: " << optionName << ", optionValue: " << optionValue << std::endl;
+  TOptionValues::iterator op_val = _option2value.find(optionName);
+  if (op_val == _option2value.end())
+  {
+    op_val = _customOption2value.find( optionName );
+    _customOption2value[ optionName ] = optionValue;
+    return;
+  }
+
+  if (op_val->second != optionValue)
+  {
+    std::string lowerOptionValue = toLowerStr(optionValue);
+    const char* ptr = lowerOptionValue.c_str();
+    // strip white spaces
+    while (ptr[0] == ' ')
+      ptr++;
+    int i = strlen(ptr);
+    while (i != 0 && ptr[i - 1] == ' ')
+      i--;
+    // check value type
+    bool typeOk = true;
+    std::string typeName;
+    if (i == 0)
+    {
+      // empty string
+    }
+    else if (_charOptions.count(optionName))
+    {
+      // do not check strings
+    }
+    else if (_doubleOptions.count(optionName))
+    {
+      // check if value is double
+      toDbl(ptr, &typeOk);
+      typeName = "real";
+    }
+    else if (_boolOptions.count(optionName))
+    {
+      // check if value is bool
+      toBool(ptr, &typeOk);
+      typeName = "bool";
+    }
+    else
+    {
+      // check if value is int
+      toInt(ptr, &typeOk);
+      typeName = "integer";
+    }
+    if ( typeOk ) // check some specific values ?
+    {
+    }
+    if ( !typeOk )
+    {
+      std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
+      throw std::invalid_argument(msg);
+    }
+    std::string value( ptr, i );
+//     std::cout << "==> value: " << value << std::endl;
+    if ( _defaultOptionValues[ optionName ] == value ) value.clear();
+
+//     std::cout << "==> value: " << value << std::endl;
+    op_val->second = value;
+  }
+}
+//=============================================================================
+//! Return option value. If isDefault provided, it can be a default value,
+//  then *isDefault == true. If isDefault is not provided, the value will be
+//  empty if it equals a default one.
+std::string MgAdapt::getOptionValue(const std::string& optionName, bool* isDefault) const
+throw (std::invalid_argument)
+{
+//   INFOS("getOptionValue");
+//   std::cout << "optionName: " << optionName << ", isDefault: " << isDefault << std::endl;
+  TOptionValues::const_iterator op_val = _option2value.find(optionName);
+  if (op_val == _option2value.end())
+  {
+    op_val = _customOption2value.find(optionName);
+    if (op_val == _customOption2value.end())
+    {
+      std::string msg = "Unknown MG-Adapt option: <" + optionName + ">";
+      throw std::invalid_argument(msg);
+    }
+  }
+  std::string val = op_val->second;
+  if ( isDefault ) *isDefault = ( val.empty() );
+
+  if ( val.empty() && isDefault )
+  {
+    op_val = _defaultOptionValues.find( optionName );
+    if (op_val != _defaultOptionValues.end()) val = op_val->second;
+  }
+//   std::cout << "==> val: " << val << std::endl;
+
+  return val;
+}
+//================================================================================
+/*!
+ * \brief Converts a string to a real value
+ */
+//================================================================================
+
+double MgAdapt::toDbl(const std::string& str, bool* isOk )
+throw (std::invalid_argument)
+{
+  if ( str.empty() ) throw std::invalid_argument("Empty value provided");
+
+  char * endPtr;
+  double val = strtod(&str[0], &endPtr);
+  bool ok = (&str[0] != endPtr);
+
+  if ( isOk ) *isOk = ok;
+
+  if ( !ok )
+  {
+    std::string msg = "Not a real value:'" + str + "'";
+    throw std::invalid_argument(msg);
+  }
+  return val;
+}
+//================================================================================
+/*!
+ * \brief Converts a string to a lower
+ */
+//================================================================================
+std::string MgAdapt::toLowerStr(const std::string& str)
+{
+  std::string s = str;
+  for ( size_t i = 0; i <= s.size(); ++i )
+    s[i] = tolower( s[i] );
+  return s;
+}
+//================================================================================
+/*!
+ * \brief Converts a string to a bool
+ */
+//================================================================================
+
+bool MgAdapt::toBool(const std::string& str, bool* isOk )
+throw (std::invalid_argument)
+{
+  std::string s = str;
+  if ( isOk ) *isOk = true;
+
+  for ( size_t i = 0; i <= s.size(); ++i )
+    s[i] = tolower( s[i] );
+
+  if ( s == "1" || s == "true" || s == "active" || s == "yes" )
+    return true;
+
+  if ( s == "0" || s == "false" || s == "inactive" || s == "no" )
+    return false;
+
+  if ( isOk )
+    *isOk = false;
+  else
+  {
+    std::string msg = "Not a Boolean value:'" + str + "'";
+    throw std::invalid_argument(msg);
+  }
+  return false;
+}
+//================================================================================
+/*!
+ * \brief Converts a string to a integer value
+ */
+//================================================================================
+
+int MgAdapt::toInt(const std::string& str, bool* isOk )
+throw (std::invalid_argument)
+{
+  if ( str.empty() ) throw std::invalid_argument("Empty value provided");
+
+  char * endPtr;
+  int val = (int)strtol( &str[0], &endPtr, 10);
+  bool ok = (&str[0] != endPtr);
+
+  if ( isOk ) *isOk = ok;
+
+  if ( !ok )
+  {
+    std::string msg = "Not an integer value:'" + str + "'";
+    throw std::invalid_argument(msg);
+  }
+  return val;
+}
+//=============================================================================
+bool MgAdapt::hasOptionDefined( const std::string& optionName ) const
+{
+  bool isDefault = false;
+  try
+  {
+    getOptionValue( optionName, &isDefault );
+  }
+  catch ( std::invalid_argument )
+  {
+    return false;
+  }
+  return !isDefault;
+}
+//================================================================================
+/*!
+ * \brief Return command to run MG-Tetra mesher excluding file prefix (-f)
+ */
+//================================================================================
+
+std::string MgAdapt::getCommandToRun(MgAdapt* hyp)
+{
+  return hyp ? hyp->getCommandToRun() : ToComment("error with hypothesis!");
+}
+
+
+
+int MgAdapt::compute(std::string& errStr)
+{
+  std::string cmd = getCommandToRun();
+//   std::cout << cmd << std::endl;
+
+  int err = 0;
+  execCmd( cmd.c_str(), err ); // run
+
+  if ( err )
+  {
+    errStr = ToComment("system(mg-adapt.exe ...) command failed with error: ") << strerror( errno );
+  }
+  else
+  {
+    convertMeshFile(meshFormatOutputMesh, solFormatOutput);
+  }
+  if (!err) cleanUp();
+  return err;
+}
+
+void MgAdapt::execCmd( const char* cmd, int& err)
+{
+  err = 1;
+  std::array <char, 128> buffer;
+  std::streambuf* buf;
+outFileStream fileStream;
+  if (printLogInFile)
+  {
+  fileStream.open(logFile);
+  buf = fileStream.rdbuf();
+  }
+  else
+  {
+    buf = std::cout.rdbuf();
+  }
+  std::ostream logStream(buf);
+
+  std::unique_ptr <FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose );
+  if(!pipe)
+  {
+    throw std::runtime_error("popen() failed!");
+  }
+  while(fgets(buffer.data(), buffer.size(), pipe.get()) !=nullptr )
+  {
+    logStream<<buffer.data() ;
+  }
+  err = 0;
+}
+/*
+ * to delete tmp files .mesh, .sol and if needed
+ * the log file
+ *
+ */
+void MgAdapt::cleanUp()
+{
+  int notOk;
+  std::string errStr;
+  if(toKeepWorkingFiles)
+    return;
+  if(removeOnSuccess && printLogInFile)
+    tmpFilesToBeDeleted.push_back(logFile);
+
+  std::vector< std::string>::iterator it = tmpFilesToBeDeleted.begin();
+  for (; it!=tmpFilesToBeDeleted.end(); ++it)
+  {
+    errStr=removeFile(*it, notOk);
+    if (notOk)
+    {
+      appendMsgToLogFile(errStr);
+    }
+
+  }
+}
+
+void MgAdapt::appendMsgToLogFile(std::string& msg)
+{
+  std::ofstream logStream;
+  logStream.open(logFile, std::ofstream::out | std::ofstream::app);
+  logStream<< msg;
+  logStream.close();
+}
+//================================================================================
+/*!
+ * \brief Return command to run MG-Tetra mesher excluding file prefix (-f)
+ */
+//================================================================================
+
+std::string MgAdapt::getCommandToRun()
+{
+  /*
+  || return system command with args and options
+  ||
+  */
+  std::string errStr;
+  std::string cmd = getExeName();
+  std::string meshIn(""), sizeMapIn(""), solFileIn("");
+  updateTimeStepRank();
+  convertMedFile(meshIn, solFileIn, sizeMapIn);
+  if (!isFileExist(meshIn) || !isFileExist(solFileIn))
+  {
+    errStr = ToComment(" failed to find .mesh or .sol file from converter ")<< strerror( errno );
+    return errStr;
+  }
+  tmpFilesToBeDeleted.push_back(meshIn);
+  tmpFilesToBeDeleted.push_back(solFileIn);
+  if(useBackgroundMap && !isFileExist(sizeMapIn))
+  {
+    errStr = ToComment(" failed to find .mesh size map file from converter ")<< strerror( errno );
+    return errStr;
+  }
+
+  cmd+= " --in "+ meshIn;
+  meshFormatOutputMesh = getFileName()+".mesh";
+  tmpFilesToBeDeleted.push_back(meshFormatOutputMesh);
+  cmd+= " --out "+ meshFormatOutputMesh;
+  if (useLocalMap || useConstantValue) cmd+= " --sizemap "+ solFileIn;
+  else //  (useBackgroundMap)
+  {
+    cmd+= " --background_mesh "+ sizeMapIn ;
+    cmd+= " --background_sizemap "+ solFileIn;
+    tmpFilesToBeDeleted.push_back(sizeMapIn);
+  }
+  //~else
+  //~{
+      //~// constant value TODO
+  //~}
+  // Check coherence between mesh dimension and option fo adaptation
+  checkDimensionOptionAdaptation();
+
+//   sizemap file is written only if level is higher than 3
+  if ( verbosityLevel > 3)
+  {
+    std::string solFileOut = getFileName()+".sol";
+    cmd+= " --write_sizemap "+ solFileOut;
+    solFormatOutput.push_back(solFileOut);
+    tmpFilesToBeDeleted.push_back(solFileOut);
+  }
+
+  std::string option, value;
+  bool isDefault;
+  const TOptionValues* options[] = { &_option2value, &_customOption2value };
+  for ( int iOp = 0; iOp < 2; ++iOp )
+  {
+    TOptionValues::const_iterator o2v = options[iOp]->begin();
+    for ( ; o2v != options[iOp]->end(); ++o2v )
+    {
+      option = o2v->first;
+      value = getOptionValue( option, &isDefault );
+
+      if ( isDefault )
+        continue;
+      if ( value.empty() )//value == NoValue() )
+      {
+        if ( _defaultOptionValues.count( option ))
+          continue; // non-custom option with no value
+        //value.clear();
+      }
+      if ( strncmp( "no", option.c_str(), 2 ) == 0 ) // options w/o values: --no_*
+      {
+        if ( !value.empty() && toBool( value ) == false )
+          continue;
+        value.clear();
+      }
+      if ( option[0] != '-' )
+        cmd += " --";
+      else
+        cmd += " ";
+//       std::cout << "--- option: '" << option << ", value: '" << value <<"'"<< std::endl;
+      cmd += option + " " + value;
+    }
+  }
+
+  // Verbosity Level
+  if (verbosityLevel != defaultVerboseLevel())
+  {
+    cmd+= " --verbose "+ ToComment(verbosityLevel);
+  }
+    //~}
+//~cmd+= " >"
+#ifdef WIN32
+    cmd += " < NUL";
+#endif
+//   std::cout << "--- cmd :"<< std::endl;
+//   std::cout << cmd << std::endl;
+
+  return cmd;
+}
+
+bool MgAdapt::isFileExist(const std::string& fName)
+{
+
+  if ( fName.empty() ) return false;
+
+  boost::system::error_code err;
+  bool res = boost::filesystem::exists( fName, err );
+
+  return err ? false : res;
+}
+//=======================================================================
+//function : defaultMaximumMemory
+//=======================================================================
+
+#if defined(WIN32)
+#include <windows.h>
+#elif !defined(__APPLE__)
+#include <sys/sysinfo.h>
+#endif
+
+double MgAdapt::defaultMaximumMemory()
+{
+#if defined(WIN32)
+  // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
+  MEMORYSTATUSEX statex;
+  statex.dwLength = sizeof (statex);
+  long err = GlobalMemoryStatusEx (&statex);
+  if (err != 0)
+  {
+    double totMB = (double)statex.ullAvailPhys / 1024. / 1024.;
+    return (double)( 0.7 * totMB );
+  }
+#elif !defined(__APPLE__)
+  struct sysinfo si;
+  long err = sysinfo( &si );
+  if ( err == 0 )
+  {
+    long ramMB = si.totalram * si.mem_unit / 1024 / 1024;
+    return ( 0.7 * ramMB );
+  }
+#endif
+  return 1024;
+}
+
+//=======================================================================
+//function : defaultWorkingDirectory
+//=======================================================================
+
+std::string MgAdapt::defaultWorkingDirectory()
+{
+  TCollection_AsciiString aTmpDir;
+
+  char *Tmp_dir = getenv("SALOME_TMP_DIR");
+  if(Tmp_dir != NULL)
+  {
+    aTmpDir = Tmp_dir;
+  }
+  else {
+#ifdef WIN32
+    aTmpDir = TCollection_AsciiString("C:\\");
+#else
+    aTmpDir = TCollection_AsciiString("/tmp/");
+#endif
+  }
+  return aTmpDir.ToCString();
+}
+//================================================================================
+/*!
+ * \brief Return a unique file name
+ */
+//================================================================================
+
+std::string MgAdapt::getFileName() const
+{
+  std::string aTmpDir = workingDir;
+  const char lastChar = *aTmpDir.rbegin();
+#ifdef WIN32
+  if(lastChar != '\\') aTmpDir+='\\';
+#else
+  if(lastChar != '/') aTmpDir+='/';
+#endif
+
+  TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str();
+  aGenericName += "MgAdapt_";
+  aGenericName += getpid();
+  aGenericName += "_";
+  aGenericName += Abs((Standard_Integer)(long) aGenericName.ToCString());
+
+  return aGenericName.ToCString();
+}
+//=======================================================================
+//function : defaultLogFile
+//=======================================================================
+
+std::string MgAdapt::defaultLogFile()
+{
+  std::string alogFile("MG_ADAPT.log");
+  return alogFile;
+}
+//=======================================================================
+//function : defaultUseConstantValue
+//=======================================================================
+
+bool MgAdapt::defaultUseConstantValue()
+{
+  return false;
+}
+//=======================================================================
+//function : defaultUseNoTimeStep
+//=======================================================================
+
+bool MgAdapt::defaultUseNoTimeStep()
+{
+  return true;
+}
+//=======================================================================
+//function : defaultRemoveLogOnSuccess
+//=======================================================================
+
+bool MgAdapt::defaultRemoveLogOnSuccess()
+{
+  return true;
+}
+//=======================================================================
+//function : defaultPrintLogInFile
+//=======================================================================
+
+bool MgAdapt::defaultPrintLogInFile()
+{
+  return false;
+}
+//=======================================================================
+//function : defaultUseChosenTimeStep
+//=======================================================================
+
+bool MgAdapt::defaultUseChosenTimeStep()
+{
+  return false;
+}
+//=======================================================================
+//function : UseLastTimeStep
+//=======================================================================
+
+bool MgAdapt::defaultUseLastTimeStep()
+{
+  return false;
+}
+//=======================================================================
+//function : defaultUseBackgroundMap
+//=======================================================================
+
+bool MgAdapt::defaultUseBackgroundMap()
+{
+  return false;
+}
+//=======================================================================
+//function : defaultKeepFiles
+//=======================================================================
+
+bool MgAdapt::defaultKeepFiles()
+{
+  return false;
+}
+//=======================================================================
+//function : defaultUseLocalMap
+//=======================================================================
+
+bool MgAdapt::defaultUseLocalMap()
+{
+  return true;
+}
+//=======================================================================
+//function : defaultPublish
+//=======================================================================
+
+bool MgAdapt::defaultPublish()
+{
+  return false;
+}
+//=======================================================================
+//function : defaultMeshOutMed
+//=======================================================================
+
+bool MgAdapt::defaultMeshOutMed()
+{
+  return true;
+}
+//=======================================================================
+//function : defaultFromMedFile
+//=======================================================================
+
+bool MgAdapt::defaultFromMedFile()
+{
+  return true;
+}
+//=======================================================================
+//function : defaultVerboseLevel
+//=======================================================================
+
+int  MgAdapt::defaultVerboseLevel()
+{
+  return 3;
+}
+std::string MgAdapt::getExeName()
+{
+  return "mg-adapt.exe";
+}
+void MgAdapt::copyMgAdaptHypothesisData( const MgAdaptHypothesisData* from)
+{
+  data->myFileInDir = from->myFileInDir;
+  data->myMeshFileIn = from->myMeshFileIn;
+  data->myMeshFileBackground = from->myMeshFileBackground;
+  data->myOutMeshName = from->myOutMeshName;
+  data->myMeshFileOut = from->myMeshFileOut;
+  data->myFileOutDir = from->myFileOutDir;
+  data->myFileSizeMapDir = from->myFileSizeMapDir;
+  data->myFieldName = from->myFieldName;
+  data->fromMedFile = from->fromMedFile;
+  data->myPublish = from->myPublish;
+  data->myMeshOutMed = from->myMeshOutMed;
+  data->myUseLocalMap = from->myUseLocalMap;
+  data->myUseBackgroundMap = from->myUseBackgroundMap;
+  data->myUseConstantValue = from->myUseConstantValue;
+  data->myConstantValue = from->myConstantValue;
+  data->myTimeStep = from->myTimeStep;
+  data->myRank = from->myRank;
+  data->myUseNoTimeStep = from->myUseNoTimeStep;
+  data->myUseLastTimeStep = from->myUseLastTimeStep;
+  data->myUseChosenTimeStep = from->myUseChosenTimeStep;
+  data->myWorkingDir = from->myWorkingDir;
+  data->myLogFile = from->myLogFile;
+  data->myPrintLogInFile = from->myPrintLogInFile;
+  data->myKeepFiles = from->myKeepFiles;
+  data->myRemoveLogOnSuccess = from->myRemoveLogOnSuccess;
+  data->myVerboseLevel = from->myVerboseLevel;
+}
+
+std::vector<std::string> MgAdapt::getListFieldsNames(std::string fileIn)
+{
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(fileIn);
+  std::vector<std::string> listFieldsNames(mfd->getFields()->getFieldsNames());
+  return listFieldsNames ;
+}
+
+void MgAdapt::checkDimensionOptionAdaptation()
+{
+  // Quand le maillage est 3D, tout est possible
+  // Quand le maillage est 2D, il faut 'surface' sauf si carte de fonds 3D
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(medFileIn);
+  int meshdim = mfd->getMeshes()->getMeshAtPos(0)->getMeshDimension() ;
+//   std::cout << "meshdim = " << meshdim << std::endl;
+
+  if ( meshdim == 2 )
+  {
+    std::string optionName   = "adaptation";
+    std::string optionValue = getOptionValue(optionName);
+//     std::cout << "optionValue = '" << optionValue <<"'"<< std::endl;
+    bool a_tester = false ;
+    // carte locale ou constante : impératif d'avoir "surface"
+    if ( useLocalMap || useConstantValue) a_tester = true ;
+    // carte de fond : impératif d'avoir "surface" si le fonds est aussi 2D
+    else
+    {
+      MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfdbg = MEDCoupling::MEDFileData::New(sizeMapFile);
+      int meshdimbg = mfdbg->getMeshes()->getMeshAtPos(0)->getMeshDimension() ;
+//       std::cout << "meshdimbg = " << meshdimbg << std::endl;
+      if ( meshdimbg == 2 ) a_tester = true ;
+    }
+    if ( a_tester )
+    {
+      if ( optionValue == "" ) setOptionValue (optionName, "surface");
+      else
+      {
+        if ( optionValue != "surface" )
+        {
+          SALOME::ExceptionStruct es;
+          es.type = SALOME::BAD_PARAM;
+          std::string text = "Mesh dimension is 2; the option should be 'surface' instead of '" + optionValue + "'." ;
+          es.text = CORBA::string_dup(text.c_str());
+          throw SALOME::SALOME_Exception(es);
+        }
+      }
+    }
+  }
+}
+
+void MgAdapt::checkFieldName(std::string fileIn)
+{
+  bool ret = false ;
+  std::vector<std::string> listFieldsNames = getListFieldsNames(fileIn);
+  std::size_t jaux(listFieldsNames.size());
+  for(std::size_t j=0;j<jaux;j++)
+  {
+    if ( fieldName == listFieldsNames[j] )
+    {
+      ret = true ;
+      break ;
+    }
+  }
+  if ( ! ret )
+  {
+    std::cout << "Available field names:" << std::endl;
+    for(std::size_t j=0;j<jaux;j++)
+    { std::cout << listFieldsNames[j] << std::endl;}
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::BAD_PARAM;
+    std::string text = "Field " + fieldName + " is not found." ;
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+  }
+}
+
+void MgAdapt::checkTimeStepRank(std::string fileIn)
+{
+  bool ret = false ;
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(fileIn);
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts = dynamic_cast<MEDCoupling::MEDFileFieldMultiTS *>( mfd->getFields()->getFieldWithName(fieldName) );
+//   std::cout << "--- timeStep " << timeStep << std::endl;
+//   std::cout << "--- rank " << rank << std::endl;
+  std::vector<double> timevalue;
+  std::vector< std::pair<int,int> > timesteprank = fts->getTimeSteps(timevalue);
+  std::size_t jaux(timesteprank.size());
+  for(std::size_t j=0;j<jaux;j++)
+  {
+    if ( ( timeStep == timesteprank[j].first ) & ( rank == timesteprank[j].second ) )
+    {
+      ret = true ;
+      break ;
+    }
+  }
+  if ( ! ret )
+  {
+    std::cout << "Available (Time step, Rank):" << std::endl;
+    for(std::size_t j=0;j<jaux;j++)
+    { std::cout << "(Time step = " << timesteprank[j].first << ", Rank = " << timesteprank[j].second << ")" << std::endl;}
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::BAD_PARAM;
+    std::string text = "(Time step = " + std::to_string(timeStep) + ", Rank = " + std::to_string(rank) + ") is not found." ;
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+  }
+}
+
+void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& solFormatFieldFileName, std::string& meshFormatsizeMapFile)
+{
+  std::vector<std::string> fieldFileNames;
+  MEDCoupling::MeshFormatWriter writer;
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(medFileIn);
+  MEDCoupling::MEDFileMeshes* meshes = mfd->getMeshes();
+  MEDCoupling::MEDFileMesh* fileMesh = meshes->getMeshAtPos(0); // ok only one mesh in file!
+  if (meshNameOut =="")
+      meshNameOut = fileMesh->getName();
+  storeGroupsAndFams(fileMesh);
+
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileFields> fields = MEDCoupling::MEDFileFields::New();
+  solFormatFieldFileName = getFileName();
+  solFormatFieldFileName+=".sol";
+  fieldFileNames.push_back(solFormatFieldFileName);
+
+  if (useBackgroundMap)
+  {
+    checkFieldName(sizeMapFile) ;
+    checkTimeStepRank(sizeMapFile) ;
+    meshFormatsizeMapFile = getFileName();
+    meshFormatsizeMapFile += ".mesh";
+    buildBackGroundMeshAndSolFiles(fieldFileNames, meshFormatsizeMapFile);
+  }
+  else if(useLocalMap)
+  {
+    checkFieldName(medFileIn) ;
+    checkTimeStepRank(medFileIn) ;
+    MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts = dynamic_cast<MEDCoupling::MEDFileFieldMultiTS *>( mfd->getFields()->getFieldWithName(fieldName) );
+    MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeField1TS> f = fts->getTimeStep(timeStep, rank);
+    MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::MEDFileFieldMultiTS::New();
+    tmFts->pushBackTimeStep(f);
+
+    fields->pushField(tmFts);
+
+    writer.setFieldFileNames( fieldFileNames);
+  }
+  else
+  {
+    MEDCoupling::MCAuto<MEDCoupling::MEDCouplingMesh> mesh = fileMesh->getMeshAtLevel(1); // nodes mesh
+    MEDCoupling::MCAuto<MEDCoupling::MEDCouplingUMesh> umesh = mesh->buildUnstructured(); // nodes mesh
+    int dim  =  umesh->getSpaceDimension();
+    int version =  sizeof(double) < 8 ? 1 : 2;
+    mcIdType nbNodes =  umesh->getNumberOfNodes();
+    buildConstantSizeMapSolFile(solFormatFieldFileName, dim, version, nbNodes);
+  }
+
+  mfd->setFields( fields );
+  meshFormatMeshFileName = getFileName();
+  meshFormatMeshFileName+=".mesh";
+  writer.setMeshFileName(meshFormatMeshFileName);
+  writer.setMEDFileDS( mfd);
+  writer.write();
+
+}
+
+void MgAdapt::convertMeshFile(std::string& meshFormatIn, std::vector< std::string>& solFieldFileNames) const
+{
+  MEDCoupling::MeshFormatReader reader(meshFormatIn, solFieldFileNames);
+
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = reader.loadInMedFileDS();
+  // write MED
+  MEDCoupling::MEDFileMeshes* meshes = mfd->getMeshes();
+  MEDCoupling::MEDFileMesh* fileMesh = meshes->getMeshAtPos(0); // ok only one mesh in file!
+  fileMesh->setName(meshNameOut);
+  restoreGroupsAndFams(fileMesh);
+  mfd->write(medFileOut, 2);
+}
+
+void MgAdapt::storeGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh)
+{
+  storefams(fileMesh);
+  storeGroups(fileMesh);
+}
+
+void MgAdapt::restoreGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh) const
+{
+  restorefams(fileMesh);
+  restoreGroups(fileMesh);
+}
+void MgAdapt::storeGroups(MEDCoupling::MEDFileMesh* fileMesh)
+{
+  std::map<std::string, std::vector<std::string> > grpFams = fileMesh->getGroupInfo();
+  std::map<std::string, std::vector<std::string> >::iterator g2ff = grpFams.begin();
+
+  for ( ; g2ff != grpFams.end(); ++g2ff )
+  {
+    std::string        groupName = g2ff->first;
+    std::vector<std::string> famNames = g2ff->second;
+
+    if ( famNames.empty() ) continue;
+    std::size_t k = 0;
+    std::vector< mcIdType> famListId;
+    for ( size_t i = 0; i < famNames.size(); ++i )
+    {
+      famListId.push_back( fileMesh->getFamilyId( famNames[i].c_str() ) );
+    }
+    group grp(groupName, famListId, famNames);
+    groupVec.push_back(grp);
+  }
+}
+
+void MgAdapt::storefams(MEDCoupling::MEDFileMesh* fileMesh)
+{
+  std::map<std::string, mcIdType> grpFams = fileMesh->getFamilyInfo();
+  std::map<std::string, mcIdType >::iterator f = grpFams.begin();
+
+  for ( ; f != grpFams.end(); ++f )
+  {
+    if(!f->second) continue;  // FAMILLE_ZERO
+    family fs(f->first, f->second);
+    famVec.push_back(fs);
+  }
+
+}
+
+void MgAdapt::restorefams(MEDCoupling::MEDFileMesh* fileMesh) const
+{
+  std::vector<family>::const_iterator fIt = famVec.begin();
+
+  for (; fIt!=famVec.end(); ++fIt)
+  {
+    try  //
+    {
+      std::string givenFamNameFromMeshGemConverter = fileMesh->getFamilyNameGivenId( std::abs(fIt->_famId) );
+      fileMesh->changeFamilyId(std::abs(fIt->_famId), fIt->_famId);
+      fileMesh->changeFamilyName(givenFamNameFromMeshGemConverter, fIt->_famName);
+    }
+    catch (const std::exception& e)
+    {
+      std::cerr<<e.what();
+    }
+  }
+}
+
+void MgAdapt::restoreGroups(MEDCoupling::MEDFileMesh* fileMesh) const
+{
+  std::map<std::string, std::vector<std::string> > info;
+  std::vector <group>::const_iterator grpFams = groupVec.begin();
+
+  for (; grpFams!=groupVec.end(); ++grpFams)
+  {
+    info.insert(std::pair <std::string, std::vector<std::string> > (grpFams->_name, grpFams->_famNames) );
+  }
+
+  fileMesh->setGroupInfo(info);
+}
+
+void MgAdapt::buildConstantSizeMapSolFile(const std::string& solFormatFieldFileName, const int dim, const int version, const mcIdType nbNodes) const
+{
+  MeshFormat::Localizer loc;
+  MeshFormat::MeshFormatParser writer;
+  int fileId = writer.GmfOpenMesh( solFormatFieldFileName.c_str(), GmfWrite, version, dim);
+  int typTab[] = {GmfSca};
+  writer.GmfSetKwd(fileId, MeshFormat::GmfSolAtVertices, (int)nbNodes, 1, typTab);
+  for (mcIdType i = 0; i<nbNodes; i++)
+  {
+    double valTab[1] = {constantValue};
+    writer.GmfSetLin( fileId, MeshFormat::GmfSolAtVertices, valTab);
+  }
+  writer.GmfCloseMesh(fileId);
+}
+
+void MgAdapt::buildBackGroundMeshAndSolFiles(const std::vector<std::string>& fieldFileNames, const std::string& meshFormatsizeMapFile) const
+{
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileData> tmpMfd = MEDCoupling::MEDFileData::New(sizeMapFile);
+  MEDCoupling::MEDFileFields* tmpFields = tmpMfd->getFields();
+  MEDCoupling::MEDFileAnyTypeFieldMultiTS* fts = tmpFields->getFieldWithName(fieldName);
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS>  fts1 = dynamic_cast<MEDCoupling::MEDFileFieldMultiTS *>(fts);
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeField1TS> f = fts1->getTimeStep(timeStep, rank);
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::MEDFileFieldMultiTS::New();
+  tmFts->pushBackTimeStep(f);
+
+  MEDCoupling::MCAuto<MEDCoupling::MEDFileFields> tmp_fields = MEDCoupling::MEDFileFields::New();
+  tmp_fields->pushField(tmFts);
+
+  tmpMfd->setFields( tmp_fields );
+  MEDCoupling::MeshFormatWriter tmpWriter;
+  tmpWriter.setMeshFileName(meshFormatsizeMapFile);
+  tmpWriter.setFieldFileNames( fieldFileNames);
+  tmpWriter.setMEDFileDS(tmpMfd);
+  tmpWriter.write();
+}
+// =======================================================================
+med_idt MgAdapt::openMedFile(const std::string aFile)
+// =======================================================================
+// renvoie le medId associe au fichier Med apres ouverture
+{
+  med_idt medIdt = MEDfileOpen(aFile.c_str(),MED_ACC_RDONLY);
+  if (medIdt <0)
+  {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::BAD_PARAM;
+    std::string text = "\nThe med file " + aFile + " cannot be opened.\n" ;
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+  }
+  return medIdt;
+}
+
+MgAdapt::Status MgAdapt::addMessage(const std::string& msg,
+                                  const bool         isFatal/*=false*/)
+{
+  if ( isFatal )
+    _myErrorMessages.clear(); // warnings are useless if a fatal error encounters
+
+  _myErrorMessages.push_back( msg );
+
+//~MESSAGE(msg);
+#ifdef _DEBUG_
+  std::cout << msg << std::endl;
+#endif
+  return ( _myStatus = isFatal ? MgAdapt::DRS_FAIL : MgAdapt::DRS_WARN_SKIP_ELEM );
+}
+
+// =======================================================================
+void MgAdapt::getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit)
+// =======================================================================
+{
+// Il faut voir si plusieurs maillages
+
+  herr_t erreur = 0 ;
+  med_idt medIdt ;
+
+
+  // Ouverture du fichier
+  //~SCRUTE(aFile.toStdString());
+  medIdt = openMedFile(aFile);
+  if ( medIdt < 0 ) return ;
+  // Lecture du nombre de champs
+  med_int ncha = MEDnField(medIdt) ;
+  if (ncha < 1 )
+  {
+    //~addMessage( ToComment(" error: there is no field in  ") << aFile, /*fatal=*/true );
+    return;
+  }
+  // Lecture des caracteristiques du champs
+
+  //       Lecture du type du champ, des noms des composantes et du nom de l'unite
+  char nomcha  [MED_NAME_SIZE+1];
+  strcpy(nomcha, fieldName.c_str());
+//       Lecture du nombre de composantes
+  med_int ncomp = MEDfieldnComponentByName(medIdt, nomcha);
+  char meshname[MED_NAME_SIZE+1];
+  char * comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
+  char * unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
+  char dtunit[MED_SNAME_SIZE+1];
+  med_bool local;
+  med_field_type typcha;
+  med_int nbofcstp;
+  erreur =  MEDfieldInfoByName (medIdt, nomcha, meshname,&local,&typcha,comp,unit,dtunit, &nbofcstp);
+  free(comp);
+  free(unit);
+  if ( erreur < 0 )
+  {
+      //~addMessage( ToComment(" error: error while reading field  ") << nomcha << " in file " << aFile , /*fatal=*/true );
+    return;
+  }
+
+  med_float dt;
+  med_int tmp_numdt, tmp_numit;
+
+  //~med_int step = data->myUseLastTimeStep ? nbofcstp : data->myTimeStep+1;
+  //~myPrint("step ", step);
+  erreur = MEDfieldComputingStepInfo ( medIdt, nomcha, 1, &numdt, &numit, &dt );
+  for(med_int step = 1; step <= nbofcstp; step++ )
+  {
+    erreur = MEDfieldComputingStepInfo ( medIdt, nomcha, step, &tmp_numdt, &tmp_numit, &dt );
+    if(tmp_numdt > numdt)
+    {
+      numdt = tmp_numdt;
+      numit = tmp_numit;
+    }
+  }
+  if ( erreur < 0 )
+  {
+    //~addMessage( ToComment(" error: error while reading field ") << nomcha << "step (numdt, numit) = " <<"("<< numdt<< ", " \
+    numit<< ")" <<" in file " << aFile , /*fatal=*/true );
+    return;
+  }
+
+  // Fermeture du fichier
+  if ( medIdt > 0 ) MEDfileClose(medIdt);
+
+}
+
+void MgAdapt::updateTimeStepRank()
+{
+
+  med_int arank;
+  med_int tmst;
+  if (myUseNoTimeStep)
+  {
+    arank = MED_NO_IT;
+    tmst  = MED_NO_DT ;
+    setRankTimeStep((int)tmst, (int)arank);
+  }
+  else if (myUseLastTimeStep)
+  {
+    std::string fieldFile = useBackgroundMap ? sizeMapFile : medFileIn;
+    getTimeStepInfos(fieldFile, tmst, arank);
+    setRankTimeStep((int)tmst, (int)arank);
+  }
+}
diff --git a/src/SMESH/MG_ADAPT.hxx b/src/SMESH/MG_ADAPT.hxx
new file mode 100644 (file)
index 0000000..ba12831
--- /dev/null
@@ -0,0 +1,340 @@
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : MG_ADAPT.hxx
+//
+#ifndef MG_ADAPT_HXX
+#define MG_ADAPT_HXX
+#include <string>
+# include <sstream>
+#include <map>
+#include <vector>
+#include <set>
+#include <fstream>
+
+#include "MCAuto.hxx"
+#include "MCType.hxx"
+#include "MEDFileMesh.hxx"
+
+#include <med.h>
+// SMESH includes
+
+//~#include <med.h>
+std::string remove_extension(const std::string& filename);
+namespace MG_ADAPT{
+class MgAdapt;
+
+typedef std::map< std::string, std::string > TOptionValues;
+typedef std::set< std::string > TOptionNames;
+
+struct MgAdaptHypothesisData
+{
+  std::string myFileInDir, myMeshFileIn, myInMeshName, myMeshFileBackground, myOutMeshName,
+              myMeshFileOut, myFileOutDir, myFileSizeMapDir, myFieldName;
+  bool fromMedFile;
+  bool myPublish, myMeshOutMed;
+  bool myUseLocalMap, myUseBackgroundMap, myUseConstantValue;
+  double myConstantValue;
+  int  myRank, myTimeStep;
+  bool myUseNoTimeStep, myUseLastTimeStep, myUseChosenTimeStep;
+  std::string myWorkingDir, myLogFile;
+  bool myPrintLogInFile, myKeepFiles, myRemoveLogOnSuccess;
+  int myVerboseLevel;
+};
+
+class outFileStream : public std::ofstream{
+public:
+    ~outFileStream(){close();} //to close file at dtor
+};
+
+/*!
+ * \brief Class to generate string from any type
+ */
+class ToComment : public std::string
+{
+  std::ostringstream _s ;
+
+public :
+
+  ToComment():std::string("") {}
+
+  ToComment(const ToComment& c):std::string() {
+    _s << c.c_str() ;
+    this->std::string::operator=( _s.str() );
+  }
+
+  ToComment & operator=(const ToComment& c) {
+    _s << c.c_str() ;
+    this->std::string::operator=( _s.str() );
+    return *this;
+  }
+
+  template <class T>
+  ToComment( const T &anything ) {
+    _s << anything ;
+    this->std::string::operator=( _s.str() );
+  }
+
+  template <class T>
+  ToComment & operator<<( const T &anything ) {
+    _s << anything ;
+    this->std::string::operator=( _s.str() );
+    return *this ;
+  }
+
+  operator char*() const {
+    return (char*)c_str();
+  }
+
+  std::ostream& Stream() {
+    return _s;
+  }
+};
+
+
+class MgAdapt
+{
+
+public:
+
+  MgAdapt();
+  MgAdapt(MgAdaptHypothesisData*);
+  MgAdapt(const MgAdapt&);
+  ~MgAdapt();
+  void buildModel();
+  void setData( MgAdaptHypothesisData* data);
+
+  void setMedFileIn(std::string fileName);
+  std::string getMedFileIn();
+
+  void setMedFileOut(std::string fileOut);
+  std::string getMedFileOut();
+
+  void setMeshName(std::string name);
+  std::string getMeshName();
+
+  void setMeshNameOut(std::string  name);
+  std::string getMeshNameOut();
+
+  void setMeshOutMed(bool mybool);
+  bool getMeshOutMed();
+
+  void setPublish(bool mybool);
+  bool getPublish();
+
+  void setFieldName(std::string myFieldName);
+  std::string getFieldName();
+
+  void setTimeStep(int time);
+  int getTimeStep() const;
+
+  void setRankTimeStep(int time, int myRank);
+  int getRank();
+
+  void setTimeStepRankLast();
+  void setNoTimeStep();
+  void setChosenTimeStepRank();
+  void updateTimeStepRank();
+
+  void setLogFile(std::string);
+  std::string getLogFile();
+
+  void setVerbosityLevel(int verbosity);
+  int getVerbosityLevel();
+
+  void setRemoveOnSuccess(bool mybool);
+  bool getRemoveOnSuccess();
+
+  MgAdaptHypothesisData* getData() const;
+
+  void setUseLocalMap(bool mybool);
+  bool getUseLocalMap();
+
+  void setUseBackgroundMap(bool mybool);
+  bool getUseBackgroundMap();
+
+  void setUseConstantValue(bool mybool);
+  bool getUseConstantValue();
+
+  void setConstantValue(double cnst);
+  double getConstantValue() const;
+
+  void setSizeMapFile(std::string mapFile);
+  std::string getSizeMapFile();
+
+  void setFromMedFile(bool mybool);
+  bool isFromMedFile();
+
+  void setKeepWorkingFiles(bool mybool);
+  bool getKeepWorkingFiles();
+
+  void setPrintLogInFile(bool mybool);
+  bool getPrintLogInFile();
+
+  void setWorkingDir(std::string dir);
+  std::string getWorkingDir() const;
+
+
+  bool setAll();
+  static std::string getCommandToRun(MgAdapt* );
+  std::string getCommandToRun() ;
+  int compute(std::string& errStr);
+  std::string getFileName() const;
+  static std::string getExeName();
+  void copyMgAdaptHypothesisData( const MgAdaptHypothesisData* from) ;
+
+  void checkDirPath(std::string& dirPath);
+
+  bool hasOptionDefined( const std::string& optionName ) const;
+  void setOptionValue(const std::string& optionName,
+                      const std::string& optionValue) throw (std::invalid_argument);
+  std::string getOptionValue(const std::string& optionName,
+                              bool*              isDefault=0) const throw (std::invalid_argument);
+  std::vector <std::string> getCustomOptionValuesStrVec() const;
+  std::vector <std::string> getOptionValuesStrVec() const;
+
+
+  TOptionValues        getOptionValues()       const;
+  const TOptionValues& getCustomOptionValues() const ;
+  static double toDbl(const std::string&, bool* isOk = 0) throw (std::invalid_argument);
+  static bool toBool(const std::string&, bool* isOk = 0) throw (std::invalid_argument);
+  static int toInt(const std::string&, bool* isOk = 0 ) throw (std::invalid_argument);
+  static std::string toLowerStr(const std::string& str);
+
+  /*  default values */
+  static std::string defaultWorkingDirectory();
+  static std::string defaultLogFile();
+  static bool  defaultKeepFiles();
+  static bool  defaultRemoveLogOnSuccess();
+  static int   defaultVerboseLevel();
+  static bool  defaultPrintLogInFile();
+  static bool  defaultFromMedFile();
+  static bool  defaultMeshOutMed();
+  static bool  defaultPublish();
+  static bool  defaultUseLocalMap();
+  static bool  defaultUseBackgroundMap();
+  static bool  defaultUseConstantValue();
+  static bool  defaultUseNoTimeStep();
+  static bool  defaultUseLastTimeStep();
+  static bool  defaultUseChosenTimeStep();
+  static double  defaultMaximumMemory();
+  static bool isFileExist(const std::string& fName);
+
+  enum Status {
+    DRS_OK,
+    DRS_EMPTY,          // a file contains no mesh with the given name
+    DRS_WARN_RENUMBER,  // a 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_WARN_DESCENDING, // some elements were skipped due to descending connectivity
+    DRS_FAIL,            // general failure (exception etc.)
+    DRS_NO_TIME_STEP            // general failure (exception etc.)
+  };
+
+  struct group {
+
+    std::string _name;
+    std::vector<MEDCoupling::mcIdType> _famListId;
+    std::vector<std::string> _famNames;
+    group(std::string name, std::vector<MEDCoupling::mcIdType> famListId, std::vector<std::string> famNames):_name(name)
+    {
+      std::vector<MEDCoupling::mcIdType>::iterator it = famListId.begin();
+      for (; it!=famListId.end(); ++it)
+          _famListId.push_back(*it);
+
+      std::vector<std::string>::iterator itt = famNames.begin();
+      for (; itt!=famNames.end(); ++itt)
+          _famNames.push_back(*itt);
+    }
+  };
+
+  struct family {
+    std::string _famName;
+    mcIdType _famId;
+    family(std::string famName, MEDCoupling::mcIdType famId):_famName(famName), _famId(famId) {}
+  };
+
+
+private :
+  bool fromMedFile;
+  std::string medFileIn;
+  std::string medFileOut;
+  std::string meshName;
+  std::string meshNameOut;
+  bool publish, meshOutMed;
+  bool useLocalMap, useBackgroundMap, useConstantValue;
+  bool myUseLastTimeStep, myUseNoTimeStep, myUseChosenTimeStep;
+  std::string sizeMapFile;
+  std::string fieldName;
+  double constantValue;
+  int rank,  timeStep;
+
+  /* advanced options */
+
+
+  std::string logFile;
+  std::string workingDir;
+  int verbosityLevel;
+  bool removeOnSuccess;
+  bool toKeepWorkingFiles;
+  bool printLogInFile;
+
+  /* Model DATA */
+  MgAdaptHypothesisData* data;
+
+  /*            */
+
+  TOptionValues _option2value, _customOption2value;         // user defined values
+  TOptionValues _defaultOptionValues;                       // default values
+  TOptionNames  _doubleOptions, _charOptions, _boolOptions; // to find a type of option
+
+  std::vector <std::string> _myErrorMessages;
+  Status _myStatus;
+  std::string meshFormatOutputMesh;
+  std::vector< std::string> solFormatOutput;
+  std::vector <group> groupVec;
+  std::vector <family> famVec;
+  std::vector< std::string> tmpFilesToBeDeleted;
+
+  /* convert MED-->.mesh format */
+  void convertMedFile(std::string& meshIn,std::string& solFileIn,  std::string& sizeMapIn)  ;
+  void storeGroups(MEDCoupling::MEDFileMesh* fileMesh);
+  void restoreGroups(MEDCoupling::MEDFileMesh* fileMesh) const;
+  void storefams(MEDCoupling::MEDFileMesh* fileMesh);
+  void restorefams(MEDCoupling::MEDFileMesh* fileMesh) const;
+  void storeGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh);
+  void restoreGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh) const;
+  void convertMeshFile(std::string& meshFormatIn, std::vector< std::string>& solFieldFileNames) const ;
+  void buildConstantSizeMapSolFile(const std::string& solFormatFieldFileName, const int dim, const int version, const mcIdType nbNodes) const;
+  void buildBackGroundMeshAndSolFiles(const std::vector<std::string>& fieldFileNames, const std::string& meshFormatsizeMapFile) const;
+  void getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit);
+  Status addMessage(const std::string& msg, const bool isFatal = false);
+  med_idt openMedFile(const std::string aFile) ;
+  void execCmd( const char* cmd, int& err);
+  void cleanUp();
+  void appendMsgToLogFile(std::string& msg);
+  std::vector<std::string> getListFieldsNames(std::string fileIn) ;
+  void checkDimensionOptionAdaptation() ;
+  void checkFieldName(std::string fileIn) ;
+  void checkTimeStepRank(std::string fileIn) ;
+
+};
+
+}
+
+#endif // MG_ADAPT_HXX
index 5bd61d945362367770305fa6fa2d4c41b73a3d97..237f63801af93a9f2685296bf3e33412b340e579 100644 (file)
@@ -44,6 +44,7 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/MEDWrapper
   ${PROJECT_BINARY_DIR}
   ${PROJECT_BINARY_DIR}/idl
+  ${MEDCOUPLING_INCLUDE_DIRS}
 )
 
 # additional preprocessor / compiler flags
@@ -73,6 +74,7 @@ SET(_link_LIBRARIES
   SMDS
   SMESHControls
   SMESHObject
+  ${MEDCoupling_medloader}
 )
 
 # --- headers ---
@@ -145,6 +147,9 @@ SET(_moc_HEADERS
   SMESHGUI_SplitBiQuad.h
   SMESHGUI_IdPreview.h
   SMESHGUI_PreVisualObj.h
+  SMESHGUI_AdaptDlg.h
+  SMESHGUI_MG_ADAPTDRIVER.h
+  MG_ADAPTGUI.hxx # to replace in ../ADAPTGUI/
 )
 
 # header files / no moc processing
@@ -167,6 +172,7 @@ SET(_other_HEADERS
   SMESHGUI_FileValidator.h
   SMESHGUI_SelectionProxy.h
   SMESH_SMESHGUI.hxx
+  #~MG_ADAPT.hxx # to replace in ../ADAPT/
 )
 
 # header files / to install
@@ -260,6 +266,10 @@ SET(_other_SOURCES
   SMESHGUI_SplitBiQuad.cxx
   SMESHGUI_PreVisualObj.cxx
   SMESHGUI_IdPreview.cxx
+  SMESHGUI_AdaptDlg.cxx
+  SMESHGUI_MG_ADAPTDRIVER.cxx
+  MG_ADAPTGUI.cxx # to replace in ../ADAPTGUI/
+  #MG_ADAPT.cxx
 )
 
 # sources / to compile
@@ -273,7 +283,7 @@ SET(_ts_RESOURCES
   SMESH_msg_en.ts
   SMESH_msg_fr.ts
   SMESH_msg_ja.ts
-) 
+)
 
 # --- rules ---
 
diff --git a/src/SMESHGUI/MG_ADAPTGUI.cxx b/src/SMESHGUI/MG_ADAPTGUI.cxx
new file mode 100644 (file)
index 0000000..a449cdd
--- /dev/null
@@ -0,0 +1,1364 @@
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  file : MG_ADAPTGUI.cxx
+
+#include "MG_ADAPTGUI.hxx"
+
+#include "MEDFileData.hxx"
+#include "MEDLoader.hxx"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_Application.h"
+#include "SUIT_Session.h"
+
+#include "SalomeApp_Application.h"
+#include "SalomeApp_Module.h"
+#include "SalomeApp_Study.h"
+#include <SUIT_MessageBox.h>
+#include <LightApp_SelectionMgr.h>
+#include <SUIT_OverrideCursor.h>
+#include <SUIT_ResourceMgr.h>
+#include <SVTK_ViewWindow.h>
+#include <SALOME_ListIO.hxx>
+#include <SUIT_FileDlg.h>
+#include <QApplication>
+#include <QButtonGroup>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QLineEdit>
+#include <QCheckBox>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QTabWidget>
+#include <QVBoxLayout>
+#include <QDoubleSpinBox>
+#include <QSpinBox>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
+#include <QSpacerItem>
+#include <QString>
+#include <QHeaderView>
+#include <QItemDelegate>
+#include <QFileDialog>
+#include <QMessageBox>
+#include <QComboBox>
+
+#include <vtkPoints.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkIdList.h>
+#include <vtkCellArray.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkDataSetMapper.h>
+#include <VTKViewer_CellLocationsArray.h>
+#include <vtkProperty.h>
+
+#include <ElCLib.hxx>
+// SALOME KERNEL includes
+#include <SALOMEDS_SComponent.hxx>
+#include <SALOMEDS_SObject.hxx>
+#include <SALOMEDS_Study.hxx>
+#include <SALOMEDS_wrap.hxx>
+#include "SalomeApp_Tools.h"
+#include <SALOMEconfig.h>
+#include <med.h>
+#include <utilities.h>
+
+#include <TCollection_AsciiString.hxx>
+
+const int SPACING = 6;            // layout spacing
+const int MARGIN  = 9;            // layout margin
+
+//=================================================================================
+// function : SMESHGUI_MgAdaptDlg()
+// purpose  :
+//=================================================================================
+SMESHGUI_MgAdaptDlg::SMESHGUI_MgAdaptDlg( SalomeApp_Module* theModule, SMESH::MG_ADAPT_ptr myModel, QWidget* parent, bool isCreation )
+    : mySMESHGUI( theModule ), QDialog(parent)
+{
+  //~model = new MgAdapt(*myModel);
+  model = SMESH::MG_ADAPT::_duplicate(myModel);
+  myData = model->getData();
+  buildDlg();
+  if (!isCreation) readParamsFromHypo();
+}
+
+void SMESHGUI_MgAdaptDlg::buildDlg()
+{
+  setModal( false );
+  setAttribute( Qt::WA_DeleteOnClose, true );
+  setWindowTitle( tr( "ADAPT_PREF_MG_ADAPT" ) );
+  setSizeGripEnabled( true );
+
+  myTabWidget = new QTabWidget( this );
+
+  // Arguments
+
+  myArgs = new SMESHGUI_MgAdaptArguments( myTabWidget );
+  SMESH::str_array* str = model->getOptionValuesStrVec();
+  SMESH::str_array* str2 = model->getCustomOptionValuesStrVec();
+  std::vector<std::string> s;
+  for (int i = 0; i< str->length(); i++) s.push_back( (*str)[i].in());
+  for (int j = str->length(); j< str2->length(); j++) s.push_back((*str2)[ j - str->length() ].in() );
+  //~str.insert( str.end(), str2.begin(), str2.end() );
+
+  myAdvOpt = new MgAdaptAdvWidget(myTabWidget, &s);
+
+  int argsTab = myTabWidget->addTab( myArgs, tr( "Args" ) );
+  int advTab = myTabWidget->addTab( myAdvOpt, tr( "ADVOP" ) );
+
+  myAdvOpt->workingDirectoryLabel         ->setText (tr( "WORKING_DIR" ));
+  myAdvOpt->workingDirectoryPushButton    ->setText (tr( "SELECT_DIR" ));
+  myAdvOpt->keepWorkingFilesCheck         ->setText (tr( "KEEP_WORKING_FILES" ));
+  myAdvOpt->verboseLevelLabel             ->setText (tr( "VERBOSE_LEVEL" ));
+  myAdvOpt->removeLogOnSuccessCheck       ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
+  myAdvOpt->logInFileCheck                ->setText (tr( "LOG_IN_FILE" ));
+  myAdvOpt->logGroupBox                   ->setTitle(tr( "LOG_GROUP_TITLE" ));
+
+  // buttons
+  QPushButton* buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), this);
+  buttonOk->setAutoDefault(false);
+  QPushButton* buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), this);
+  buttonApply->setAutoDefault(false);
+  QPushButton* buttonCancel = new QPushButton( tr( "SMESH_BUT_CANCEL" ), this );
+  buttonCancel->setAutoDefault( false );
+  QPushButton* buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
+  buttonHelp->setAutoDefault( false );
+
+  QHBoxLayout* btnLayout = new QHBoxLayout;
+  btnLayout->setSpacing( SPACING );
+  btnLayout->setMargin( 0 );
+  btnLayout->addWidget( buttonOk );
+  btnLayout->addStretch( 10 );
+  btnLayout->addWidget( buttonApply );
+  btnLayout->addStretch( 10 );
+  btnLayout->addWidget( buttonCancel );
+  btnLayout->addStretch( 10 );
+  btnLayout->addWidget( buttonHelp );
+
+  QVBoxLayout* l = new QVBoxLayout ( this );
+  l->setMargin( MARGIN );
+  l->setSpacing( SPACING );
+  l->addWidget( myTabWidget );
+  l->addStretch();
+  l->addLayout( btnLayout );
+
+  connect( buttonOk,       SIGNAL(pressed()), this, SLOT(PushOnOK()));
+  connect( buttonApply,    SIGNAL(pressed()), this, SLOT(PushOnApply()));
+  connect( buttonCancel,   SIGNAL(pressed()), this, SLOT(close()));
+  connect( buttonHelp,     SIGNAL(pressed()), this, SLOT(PushOnHelp()));
+
+  connect( myArgs, SIGNAL(meshDimSignal(ADAPTATION_MODE)), myAdvOpt, SLOT( onMeshDimChanged(ADAPTATION_MODE))  );
+}
+
+
+//=================================================================================
+// function : ~SMESHGUI_MgAdaptDlg()
+// purpose  : Destroys the object and frees any allocated resources
+//=================================================================================
+SMESHGUI_MgAdaptDlg::~SMESHGUI_MgAdaptDlg()
+{
+    //~delete model;
+}
+
+//~void SMESHGUI_MgAdaptDlg::setModel(MgAdapt* mg)
+//~{
+    //~model = mg;
+//~}
+SMESH::MG_ADAPT_ptr SMESHGUI_MgAdaptDlg::getModel() const
+{
+  return model;
+}
+/*!
+\brief Perform clean-up actions on the dialog box closing.
+*/
+bool SMESHGUI_MgAdaptDlg::PushOnApply()
+{
+  bool ret = readParamsFromWidgets();
+  return ret;
+}
+void SMESHGUI_MgAdaptDlg::PushOnOK()
+{
+  bool ret = PushOnApply();
+  if ( ret ) reject();
+}
+void SMESHGUI_MgAdaptDlg::reject()
+{
+  QDialog::reject();
+}
+bool SMESHGUI_MgAdaptDlg::readParamsFromHypo( ) const
+{
+  bool ret = true;
+  myArgs->aMedfile->setChecked(myData->fromMedFile) ;
+  if (myData->fromMedFile)
+  {
+
+    *(myArgs->myFileInDir) = QString(myData->myFileInDir) ;
+    myArgs->selectMedFileLineEdit->setText(QString(myData->myMeshFileIn)) ;
+    // myData->myInMeshName = // TODO
+
+  }
+  else
+  {
+    myArgs->aBrowserObject->setText(QString(myData->myInMeshName));
+    //~ myArgs->myFileInDir =""; // TODO
+    //~ myArgs->selectMedFileLineEdit->setText(); // TODO
+  }
+  myArgs->meshNameLineEdit->setText(QString(myData->myOutMeshName));
+  myArgs->medFileCheckBox->setChecked(myData->myMeshOutMed);
+
+  if(myData->myMeshOutMed)
+  {
+    *(myArgs->myFileOutDir) = QString(myData->myFileOutDir);
+    myArgs->selectOutMedFileLineEdit->setText(QString(myData->myMeshFileOut));
+  }
+  else
+  {
+    *(myArgs->myFileOutDir) = QString(""); //TODO
+  }
+
+  myArgs->publishOut->setChecked(myData->myPublish);
+
+  myArgs->localButton->setChecked(myData->myUseLocalMap);
+  myArgs->backgroundButton->setChecked(myData->myUseBackgroundMap);
+  myArgs->constantButton->setChecked(myData->myUseConstantValue);
+
+  if (myData->myUseConstantValue)
+  {
+    myArgs->dvalue->setValue(myData->myConstantValue);
+  }
+  else
+  {
+    myArgs->dvalue->setValue(0.0);
+  }
+
+  if (myData->myUseBackgroundMap)
+  {
+
+    *(myArgs->myFileSizeMapDir) = QString(myData->myFileSizeMapDir) ;
+    myArgs->selectMedFileBackgroundLineEdit->setText(QString(myData->myMeshFileBackground));
+  }
+  else
+  {
+    *(myArgs->myFileSizeMapDir) = QString("") ;  //TODO
+    myArgs->selectMedFileBackgroundLineEdit->setText(""); //TODO
+  }
+
+  myArgs->fieldNameCmb->setCurrentText(QString(myData->myFieldName));
+  myArgs->noTimeStep->setChecked(myData->myUseNoTimeStep);
+  myArgs->lastTimeStep->setChecked( myData->myUseLastTimeStep);
+  myArgs->chosenTimeStep->setChecked(myData->myUseChosenTimeStep);
+  if (myData->myUseChosenTimeStep)
+  {
+    myArgs->rankSpinBox->setValue(myData->myRank);
+    myArgs->timeStep->setValue(myData->myTimeStep);
+  }
+
+  myAdvOpt->workingDirectoryLineEdit->setText(QString(myData->myWorkingDir));
+  myAdvOpt->logInFileCheck->setChecked(myData->myPrintLogInFile);
+
+  myAdvOpt->verboseLevelSpin->setValue(myData->myVerboseLevel);
+  myAdvOpt->removeLogOnSuccessCheck->setChecked(myData->myRemoveLogOnSuccess);
+  myAdvOpt->keepWorkingFilesCheck->setChecked(myData->myKeepFiles);
+
+  return ret;
+
+}
+
+bool SMESHGUI_MgAdaptDlg::readParamsFromWidgets()
+{
+  MESSAGE ("readParamsFromWidgets") ;
+  bool ret = true ;
+  SMESH::MgAdaptHypothesisData* aData = new SMESH::MgAdaptHypothesisData();
+  while ( ret )
+  {
+    // 1. Fichier du maillage de départ
+    aData->fromMedFile = myArgs->aMedfile->isChecked();
+    if (aData->fromMedFile)
+    {
+      aData->myFileInDir = CORBA::string_dup(myArgs->myFileInDir->toStdString().c_str());
+      aData->myMeshFileIn = CORBA::string_dup(myArgs->selectMedFileLineEdit->text().toStdString().c_str());
+        // aData->myInMeshName = // TODO
+    }
+    else // TODO browser
+    {
+      QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
+                                QObject::tr("MG_ADAPT_MED_FILE_4") );
+      ret = false ;
+      break ;
+  //     aData->myInMeshName = CORBA::string_dup(myArgs->aBrowserObject->text().toStdString().c_str());
+  //     aData->myFileInDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str());
+  //
+  //     TCollection_AsciiString aGenericName = (char*)aData->myFileInDir;
+  //     TCollection_AsciiString aGenericName2 = "MgAdapt_";
+  //     aGenericName2 += getpid();
+  //     aGenericName2 += "_";
+  //     aGenericName2 += Abs((Standard_Integer)(long) aGenericName.ToCString());
+  //     aGenericName2 += ".med";
+  //     aGenericName+=aGenericName2;
+  //     emit myArgs->toExportMED(aGenericName.ToCString());
+  //     aData->myMeshFileIn = aGenericName2.ToCString();
+    }
+    // 2. Fichier du maillage de sortie
+    aData->myOutMeshName = CORBA::string_dup(myArgs->meshNameLineEdit->text().toStdString().c_str());
+    aData->myMeshOutMed = myArgs->medFileCheckBox->isChecked();
+    if(aData->myMeshOutMed)
+    {
+      aData->myFileOutDir = CORBA::string_dup(myArgs->myFileOutDir->toStdString().c_str());
+      aData->myMeshFileOut = CORBA::string_dup(myArgs->selectOutMedFileLineEdit->text().toStdString().c_str());
+    }
+    else
+    {
+      aData->myMeshFileOut = "";
+    }
+    aData->myPublish = myArgs->publishOut->isChecked();
+
+    // 3. Type de carte de tailles
+    aData->myUseLocalMap = myArgs->localButton->isChecked();
+    aData->myUseBackgroundMap = myArgs->backgroundButton->isChecked();
+    aData->myUseConstantValue = myArgs->constantButton->isChecked();
+    // 3.1. Constante
+    if (aData->myUseConstantValue)
+    {
+      aData->myConstantValue = myArgs->dvalue->value();
+    }
+    else
+    {
+      aData->myConstantValue = 0.0;
+    }
+    // 3.2. Arrière-plan
+    if (aData->myUseBackgroundMap)
+    {
+      aData->myFileSizeMapDir = CORBA::string_dup(myArgs->myFileSizeMapDir->toStdString().c_str());
+      aData->myMeshFileBackground = CORBA::string_dup(myArgs->selectMedFileBackgroundLineEdit->text().toStdString().c_str());
+    }
+    else
+    {
+      aData->myMeshFileBackground = "";
+    }
+
+  // 4. Le champ
+    if ( ! aData->myUseConstantValue )
+    {
+      if ( strlen(myArgs->fieldNameCmb->currentText().toStdString().c_str()) == 0 )
+      {
+        QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
+                                  QObject::tr("MG_ADAPT_MED_FILE_5") );
+        ret = false ;
+        break ;
+      }
+      {
+        aData->myFieldName = CORBA::string_dup(myArgs->fieldNameCmb->currentText().toStdString().c_str());
+        aData->myUseNoTimeStep = myArgs->noTimeStep->isChecked();
+        aData->myUseLastTimeStep = myArgs->lastTimeStep->isChecked();
+        aData->myUseChosenTimeStep = myArgs->chosenTimeStep->isChecked();
+        if (aData->myUseChosenTimeStep)
+        {
+          aData->myRank = myArgs->rankSpinBox->value();
+          aData->myTimeStep = myArgs->timeStep->value();
+        }
+      }
+    }
+
+    // 5. Options avancées
+    aData->myWorkingDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str());
+    aData->myPrintLogInFile = myAdvOpt->logInFileCheck->isChecked();
+    aData->myVerboseLevel = myAdvOpt->verboseLevelSpin->value();
+    aData->myRemoveLogOnSuccess = myAdvOpt->removeLogOnSuccessCheck->isChecked();
+    aData->myKeepFiles = myAdvOpt->keepWorkingFilesCheck->isChecked();
+    model->setData(*aData);
+
+    QString msg;
+    checkParams(msg);
+    break ;
+  }
+
+  delete aData;
+
+  return ret;
+}
+bool SMESHGUI_MgAdaptDlg::storeParamsToHypo( const SMESH::MgAdaptHypothesisData& ) const
+{
+}
+/*!
+  \brief Show help page
+*/
+void SMESHGUI_MgAdaptDlg::PushOnHelp()
+{
+//   QString aHelpFile;
+  // if ( myTabWidget->currentIndex() == MinDistance ) {
+  //   aHelpFile = "measurements.html#min-distance-anchor";
+  // } else if ( myTabWidget->currentIndex() == BoundingBox ) {
+  //   aHelpFile = "measurements.html#bounding-box-anchor";
+  // } else if ( myTabWidget->currentWidget() == myAngle ) {
+  //   aHelpFile = "measurements.html#angle-anchor";
+  // } else {
+  //   aHelpFile = "measurements.html#basic-properties-anchor";
+  // }
+
+//   SMESH::ShowHelpFile( aHelpFile );
+}
+bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg)
+{
+  if ( !QFileInfo( myAdvOpt->workingDirectoryLineEdit->text().trimmed() ).isWritable() )
+  {
+    SUIT_MessageBox::warning( this,
+                              tr( "SMESH_WRN_WARNING" ),
+                              tr( "NO_PERMISSION" ) );
+    return false;
+  }
+
+
+  myAdvOpt->myOptionTable->setFocus();
+  QApplication::instance()->processEvents();
+
+  QString name, value;
+  bool isDefault, ok = true;
+  int iRow = 0, nbRows = myAdvOpt->myOptionTable->topLevelItemCount();
+  for ( ; iRow < nbRows; ++iRow )
+  {
+    QTreeWidgetItem* row = myAdvOpt->myOptionTable->topLevelItem( iRow );
+    myAdvOpt->GetOptionAndValue( row, name, value, isDefault );
+
+    if ( name.simplified().isEmpty() )
+        continue; // invalid custom option
+
+    if ( isDefault ) // not selected option
+        value.clear();
+
+    try
+    {
+      model->setOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
+    }
+    catch ( const SALOME::SALOME_Exception& ex )
+    {
+      msg = ex.details.text.in();
+      ok = false;
+      break;
+    }
+  }
+
+  return ok;
+}
+
+//=================================================================================
+// function : SMESHGUI_MgAdaptArguments()
+// purpose  :
+//=================================================================================
+SMESHGUI_MgAdaptArguments::SMESHGUI_MgAdaptArguments( QWidget* parent )
+    :QWidget(parent)
+{
+
+  myFileInDir = new QString("");
+  myFileOutDir = new QString("");
+  myFileSizeMapDir = new QString("");
+  if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
+  {
+    *myFileInDir = QDir::currentPath();
+    *myFileOutDir = QDir::currentPath();
+    *myFileSizeMapDir = QDir::currentPath();
+  }
+  else
+  {
+    *myFileInDir = SUIT_FileDlg::getLastVisitedPath();
+    *myFileOutDir = SUIT_FileDlg::getLastVisitedPath();
+    *myFileSizeMapDir = SUIT_FileDlg::getLastVisitedPath();
+  }
+
+  meshDim = 0;
+  meshDimBG = 0;
+  // Mesh in
+  aMeshIn = new QGroupBox( tr( "MeshIn" ), this );
+  aMedfile       = new QRadioButton( tr( "MEDFile" ),    aMeshIn );
+  aBrowser       = new QRadioButton( tr( "Browser" ), aMeshIn );
+  aBrowserObject = new QLineEdit(  aMeshIn );
+  selectMedFilebutton = new QPushButton("", aMeshIn);
+  selectMedFileLineEdit      = new QLineEdit(  aMeshIn );
+
+  meshIn = new QGridLayout( aMeshIn );
+
+  meshIn->setMargin( MARGIN );
+  meshIn->setSpacing( SPACING );
+  meshIn->addWidget( aMedfile,     0, 0, 1,1 );
+  meshIn->addWidget( aBrowser,     0, 1,1,1);
+  meshIn->addWidget( aBrowserObject,     0, 2, 1, 1 );
+  meshIn->addWidget( selectMedFilebutton,  1, 0,1, 1);
+  meshIn->addWidget( selectMedFileLineEdit,  1, 1, 1, 1 );
+  hspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+
+  meshInGroup = new QButtonGroup( this );
+  meshInGroup->addButton( aMedfile,   0 );
+  meshInGroup->addButton( aBrowser,   1 );
+
+  //Mesh out
+
+  aMeshOut = new QGroupBox( tr( "MeshOut" ), this );
+  meshName = new QLabel(tr("MeshName"), aMeshOut);
+  secondHspacer = new QSpacerItem(100, 30);
+  meshNameLineEdit = new QLineEdit(aMeshOut) ;
+  medFileCheckBox = new QCheckBox(tr("MEDFile"), aMeshOut);
+  selectOutMedFilebutton = new QPushButton("", aMeshOut);
+  thirdHspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+  selectOutMedFileLineEdit = new QLineEdit(aMeshOut) ;
+  publishOut = new  QCheckBox(tr("Publish_MG_ADAPT"), aMeshOut);
+
+  meshOut = new QGridLayout( aMeshOut );
+
+  meshOut->setMargin( MARGIN );
+  meshOut->setSpacing( SPACING );
+  meshOut->addWidget( meshName,  0, 0, 1,1 );
+  meshOut->addItem( secondHspacer,  0, 1, 1, 1 );
+  meshOut->addWidget( meshNameLineEdit, 0, 2,1,1);
+  meshOut->addWidget( medFileCheckBox,  1, 0,1,1 );
+  meshOut->addWidget( selectOutMedFilebutton,  1, 1,1,1 );
+  meshOut->addWidget( selectOutMedFileLineEdit,  1, 2,1,1);
+  meshOut->addWidget( publishOut,  2, 0,1,1 );
+
+  //size map definition
+
+  sizeMapDefinition  = new QGroupBox(tr("SIZE_MAP_DEF"), this);
+  localButton = new QRadioButton(tr("LOCAL_MG_ADAPT"), sizeMapDefinition);
+  backgroundButton = new QRadioButton(tr("BACKGRND_MG_ADAPT"), sizeMapDefinition);
+  constantButton = new QRadioButton(tr("CNST_MG_ADAPT"), sizeMapDefinition);
+  medFileBackground = new QLabel(tr("MED_FILE_BCKG"), sizeMapDefinition);
+  selectMedFileBackgroundbutton = new QPushButton(tr(""), sizeMapDefinition);
+  selectMedFileBackgroundLineEdit = new QLineEdit(sizeMapDefinition);
+  valueLabel = new QLabel(tr("VALUE_MG_ADAPT"), sizeMapDefinition);
+  dvalue = new QDoubleSpinBox(sizeMapDefinition);
+  sizeMapDefGroup = new QButtonGroup( this );
+  sizeMapDefGroup->addButton( localButton,   0 );
+  sizeMapDefGroup->addButton( backgroundButton,   1 );
+  sizeMapDefGroup->addButton( constantButton,   2 );
+
+  sizeMapDefGroupLayout = new QGridLayout(sizeMapDefinition);
+  sizeMapDefGroupLayout->addWidget(localButton, 0,0);
+  sizeMapDefGroupLayout->addWidget(backgroundButton, 0,1);
+  sizeMapDefGroupLayout->addWidget(constantButton, 0,2);
+  sizeMapDefGroupLayout->addWidget(medFileBackground, 1,0);
+  sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundbutton, 1,1);
+  sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundLineEdit, 1,2);
+  sizeMapDefGroupLayout->addWidget(valueLabel, 2,0);
+  sizeMapDefGroupLayout->addWidget(dvalue, 2,1);
+
+  // size Map field
+  sizeMapField = new QGroupBox(tr("SIZE_MAP_FIELD"), this);
+  fieldName = new QLabel(tr("MG_ADAPT_FIELD_NAME"), sizeMapField);
+  fieldNameCmb = new QComboBox(sizeMapField);
+  noTimeStep = new QRadioButton(tr("MG_ADAPT_NO_T_ST"), sizeMapField);
+  lastTimeStep = new QRadioButton(tr("MG_ADAPT_L_ST"), sizeMapField);
+  chosenTimeStep = new QRadioButton(tr("MG_ADAPT_CH_ST"), sizeMapField);
+  timeStepLabel = new QLabel(tr("MG_ADAPT_TSTP"), sizeMapField);
+  timeStep = new QSpinBox(sizeMapField);
+  timeStep->setMinimum(-1);
+  rankLabel = new QLabel(tr("MG_ADAPT_RANK"), sizeMapField);
+  rankSpinBox = new QSpinBox(sizeMapField);
+  rankSpinBox->setMinimum(-1);
+
+  timeStepGroup = new QButtonGroup(this);
+  timeStepGroup->addButton(noTimeStep, 0);
+  timeStepGroup->addButton(lastTimeStep, 1);
+  timeStepGroup->addButton(chosenTimeStep, 2);
+
+  sizeMapFieldGroupLayout = new QGridLayout(sizeMapField);
+
+  sizeMapFieldGroupLayout->addWidget(fieldName, 0,0);
+  sizeMapFieldGroupLayout->addWidget(fieldNameCmb, 0,1);
+  sizeMapFieldGroupLayout->addWidget(noTimeStep, 1,0);
+  sizeMapFieldGroupLayout->addWidget(lastTimeStep, 1,1);
+  sizeMapFieldGroupLayout->addWidget(chosenTimeStep, 1,2);
+  sizeMapFieldGroupLayout->addWidget(timeStepLabel, 2,0);
+  sizeMapFieldGroupLayout->addWidget(timeStep, 2,1);
+  sizeMapFieldGroupLayout->addWidget(rankLabel, 2,2);
+  sizeMapFieldGroupLayout->addWidget(rankSpinBox, 2,3);
+
+  QGridLayout* argumentsLayout = new QGridLayout( this );
+  argumentsLayout->setMargin( MARGIN );
+  argumentsLayout->setSpacing( SPACING );
+
+  argumentsLayout->addWidget( aMeshIn,  0, 0, 1, 3 );
+  argumentsLayout->addWidget( aMeshOut, 1, 0, 1, 3 );
+  argumentsLayout->addWidget( sizeMapDefinition, 2, 0, 1, 3 );
+  argumentsLayout->addWidget( sizeMapField, 3, 0, 1, 3 );
+  argumentsLayout->setColumnStretch( 1, 5 );
+  argumentsLayout->setRowStretch( 4, 5 );
+
+  // Initial state
+  setMode( Mesh, Local);
+  medFileCheckBox->setChecked(true);
+  visibleTimeStepRankLabel (false);
+
+  // Connections
+  connect( meshInGroup,            SIGNAL( buttonClicked( int ) ),  this, SLOT( modeChanged( int ) ) );
+  connect( sizeMapDefGroup,        SIGNAL( buttonClicked( int ) ),  this, SLOT( sizeMapDefChanged( int ) ) );
+  connect( selectMedFilebutton,    SIGNAL( pressed(  ) ),           this, SLOT( onSelectMedFilebuttonClicked(  ) ) );
+  connect( medFileCheckBox,        SIGNAL (stateChanged(int)),      this, SLOT(onMedFileCheckBox(int) ) );
+  connect( publishOut,             SIGNAL (stateChanged(int)),      this, SLOT(onPublishOut(int) ) );
+  connect( selectOutMedFilebutton, SIGNAL( pressed()),              this, SLOT(onSelectOutMedFilebutton()));
+  connect( selectMedFileBackgroundbutton, SIGNAL(pressed()),        this, SLOT(onSelectMedFileBackgroundbutton()) );
+  connect( timeStepGroup,          SIGNAL( buttonClicked( int ) ),  this, SLOT( timeStepGroupChanged( int ) ) );
+  emit updateSelection();
+}
+
+//=================================================================================
+// function : ~SMESHGUI_MgAdaptArguments()
+// purpose  : Destroys the object and frees any allocated resources
+//=================================================================================
+SMESHGUI_MgAdaptArguments::~SMESHGUI_MgAdaptArguments()
+{
+}
+
+void SMESHGUI_MgAdaptArguments::onNoTimeStep(bool disableOther)
+{
+  noTimeStep->setChecked(true);
+
+  visibleTimeStepRankLabel (false);
+  rankSpinBox->setValue(-2);
+  timeStep->setValue(-2);
+
+  lastTimeStep->setDisabled(disableOther);
+  chosenTimeStep->setDisabled(disableOther);
+}
+void SMESHGUI_MgAdaptArguments::onLastTimeStep(bool disableOther)
+{
+  lastTimeStep->setChecked(true);
+
+  visibleTimeStepRankLabel (false);
+  rankSpinBox->setValue(-1);
+  timeStep->setValue(-1);
+  noTimeStep->setDisabled(disableOther);
+}
+void SMESHGUI_MgAdaptArguments::onChosenTimeStep(bool disableOther, int vmax)
+{
+  chosenTimeStep->setChecked(true);
+
+  visibleTimeStepRankLabel (true);
+  rankSpinBox->setValue(-1);
+  timeStep->setValue(-1);
+  if (vmax) timeStep->setMaximum(vmax);
+}
+
+void SMESHGUI_MgAdaptArguments::visibleTimeStepRankLabel(bool visible)
+{
+  rankLabel->setVisible(visible);
+  rankSpinBox->setVisible(visible);
+
+  timeStepLabel->setVisible(visible);
+  timeStep->setVisible(visible);
+}
+
+void SMESHGUI_MgAdaptArguments::onSelectOutMedFilebutton()
+{
+
+  QString filtre = QString("Med") ;
+  filtre += QString(" files (*.") + QString("med") + QString(");;");
+  QString fileName = QFileDialog::getSaveFileName(this, tr("SAVE_MED"), QString(""), filtre);
+  QFileInfo myFileInfo(fileName);
+  selectOutMedFileLineEdit->setText(myFileInfo.fileName());
+  *myFileOutDir = myFileInfo.path();
+
+}
+void SMESHGUI_MgAdaptArguments::onSelectMedFileBackgroundbutton()
+{
+  QString fileName0 = selectMedFileBackgroundbutton->text().trimmed();
+
+  QString fileName = getMedFileName(false);
+  if (fileName != QString::null)
+  {
+    myFieldList = GetListeChamps(fileName);
+    if (myFieldList.empty())
+    {
+      fileName = fileName0;
+      fieldNameCmb->clear();
+    }
+    else
+    {
+      // fill field name Combobox
+      fieldNameCmb->clear();
+      std::map<QString, int>::const_iterator it;
+      for ( it=myFieldList.begin() ; it != myFieldList.end(); it++)
+      {
+        fieldNameCmb->insertItem(0,QString(it->first));
+        int typeStepInField = it->second > 2 ?  2 : it->second ;
+        timeStepGroupChanged(typeStepInField, false);
+      }
+      // Dimension du maillage de fonds
+      MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(fileName.toStdString());
+      meshDimBG = mfd->getMeshes()->getMeshAtPos(0)->getMeshDimension() ;
+      valueAdaptation ();
+    }
+  }
+  else
+  {
+    fileName = fileName0;
+    fieldNameCmb->clear();
+  }
+
+  QFileInfo myFileInfo(fileName);
+  *myFileSizeMapDir = myFileInfo.path();
+  selectMedFileBackgroundLineEdit->setText(myFileInfo.fileName());
+
+}
+void SMESHGUI_MgAdaptArguments::onMedFileCheckBox(int state)
+{
+  if (state == Qt::Checked)
+  {
+    selectOutMedFilebutton->show();
+    selectOutMedFileLineEdit->show();
+    selectOutMedFilebutton->setEnabled(true);
+    selectOutMedFileLineEdit->setEnabled(true);
+  }
+  else
+  {
+    selectOutMedFilebutton->setEnabled(false);
+    selectOutMedFileLineEdit->setEnabled(false);
+    publishOut->setChecked(true);
+  }
+}
+void SMESHGUI_MgAdaptArguments::onPublishOut(int state)
+{
+  if (state == Qt::Unchecked)
+  {
+    medFileCheckBox->setChecked(true);
+  }
+}
+
+void SMESHGUI_MgAdaptArguments::onSelectMedFilebuttonClicked()
+{
+  // bool keep = false;
+  QString fileName0 = selectMedFileLineEdit->text().trimmed();
+
+  QString fileName = getMedFileName(false);
+  if(fileName != QString::null)
+  {
+    QString aMeshName = lireNomMaillage(fileName.trimmed(), meshDim);
+    if (aMeshName == QString::null )
+    {
+      QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
+                                QObject::tr("MG_ADAPT_MED_FILE_2") );
+      fileName = fileName0;
+    }
+    else
+    {
+      meshNameLineEdit->setText(aMeshName);
+      valueAdaptation ();
+//       ADAPTATION_MODE aMode = meshDim == 3 ? ADAPTATION_MODE::BOTH : ADAPTATION_MODE::SURFACE; // and when dimesh 3 without 2D mesh?
+//       emit meshDimSignal(aMode);
+    }
+  }
+  else
+  {
+      return;
+  }
+
+  QFileInfo myFileInfo(fileName);
+  *myFileInDir = myFileInfo.path();
+  *myFileOutDir = myFileInfo.path();
+  selectMedFileLineEdit->setText(myFileInfo.fileName());
+  QString outF = fileName == QString::null ? myFileInfo.fileName() :
+  QString( remove_extension(myFileInfo.fileName().toStdString() ).c_str() )+ QString(".adapt.med");
+  selectOutMedFileLineEdit->setText(outF);
+  onLocalSelected(myFileInfo.filePath());
+
+}
+
+void SMESHGUI_MgAdaptArguments::valueAdaptation()
+{
+  ADAPTATION_MODE aMode ;
+  if ( meshDimBG < 3 )
+  {
+    aMode = meshDim == 3 ? ADAPTATION_MODE::BOTH : ADAPTATION_MODE::SURFACE;
+  }
+  else
+  {
+    aMode = ADAPTATION_MODE::BOTH;
+  }
+  emit meshDimSignal(aMode);
+}
+
+void SMESHGUI_MgAdaptArguments::onLocalSelected(QString filePath)
+{
+  myFieldList = GetListeChamps(filePath, false);
+  if (myFieldList.empty())
+  {
+    if (localButton->isChecked())
+    {
+      fieldNameCmb->clear();
+    }
+  }
+  else
+  {
+    // fill field name Combobox
+    fieldNameCmb->clear();
+    std::map<QString, int>::const_iterator it;
+    for ( it = myFieldList.begin() ; it != myFieldList.end(); it++)
+    {
+      fieldNameCmb->insertItem(0,QString(it->first));
+      // Je ne comprends pas le rapport entre pas de temps et apparition d'un nouveau champ... GN
+      int typeStepInField = it->second > 2 ?  2 : it->second ;
+//             std::cout << "SMESHGUI_MgAdaptArguments::onLocalSelected typeStepInField : " << typeStepInField << std::endl;
+      timeStepGroupChanged(typeStepInField, false);
+    }
+  }
+}
+// =======================================================================
+// Gestion les boutons qui permettent  de
+// 1) retourne le nom d'un fichier par une fenetre de dialogue si aucun
+//    objet est selectionne dans l arbre d etude
+// 2) retourne le nom du fichier asocie a l objet
+//    selectionne dans l arbre d etude
+// =======================================================================
+QString SMESHGUI_MgAdaptArguments::getMedFileName(bool avertir)
+{
+
+  QString aFile = QString::null;
+  QString filtre = QString("Med") ;
+  filtre += QString(" files (*.") + QString("med") + QString(");;");
+  aFile = SUIT_FileDlg::getOpenFileName(0, QObject::tr("MG_ADAPT_SELECT_FILE_0"), QString(""), filtre );
+
+  return aFile;
+
+}
+void SMESHGUI_MgAdaptArguments::setMode(const Mode theMode, const SIZEMAP theSizeMap )
+{
+  QRadioButton* aButton = qobject_cast<QRadioButton*>( meshInGroup->button( theMode ) );
+  QRadioButton* bButton = qobject_cast<QRadioButton*>( sizeMapDefGroup->button( theSizeMap ) );
+  if ( aButton )
+  {
+    aButton->setChecked( true );
+    modeChanged( theMode );
+  }
+  if ( bButton )
+  {
+    bButton->setChecked( true );
+    sizeMapDefChanged( theSizeMap );
+  }
+}
+
+void SMESHGUI_MgAdaptArguments::modeChanged( int theMode )
+{
+  clear();
+  if(theMode == Mesh)
+  {
+    aBrowserObject->hide();
+    selectMedFileLineEdit->show();
+    selectMedFilebutton->show();
+    localButton->setEnabled(true);
+  }
+  else
+  {
+    selectMedFileLineEdit->hide();
+    selectMedFilebutton->hide();
+    localButton->setEnabled(false);
+    aBrowserObject->show();
+    sizeMapDefChanged(Background);
+    emit updateSelection();
+  }
+}
+
+void SMESHGUI_MgAdaptArguments::sizeMapDefChanged( int  theSizeMap )
+{
+  fieldNameCmb->clear();
+  if(theSizeMap == Local)
+  {
+    localButton->setEnabled(true);
+    localButton->setChecked(true);
+    medFileBackground->hide();
+    selectMedFileBackgroundbutton->hide();
+    selectMedFileBackgroundLineEdit->hide();
+    selectMedFileBackgroundLineEdit->clear();
+    valueLabel->hide();
+    dvalue->hide();
+
+    sizeMapField->setEnabled(true);
+    if (!selectMedFileLineEdit->text().isEmpty())
+    {
+      QFileInfo myFileInfo(QDir(*myFileInDir), selectMedFileLineEdit->text());
+      onLocalSelected(myFileInfo.filePath());
+    }
+  }
+  else if (theSizeMap == Background)
+  {
+    medFileBackground->show();
+    backgroundButton->setChecked(true);
+    selectMedFileBackgroundbutton->show();
+    selectMedFileBackgroundLineEdit->show();
+    valueLabel->hide();
+    dvalue->hide();
+    sizeMapField->setEnabled(true);
+  }
+  else
+  {
+    medFileBackground->hide();
+    constantButton->setChecked(true);
+    selectMedFileBackgroundbutton->hide();
+    selectMedFileBackgroundLineEdit->clear();
+    selectMedFileBackgroundLineEdit->hide();
+    valueLabel->show();
+    dvalue->show();
+    sizeMapField->setEnabled(false);
+  }
+  meshDimBG = 0;
+  valueAdaptation();
+}
+void SMESHGUI_MgAdaptArguments::timeStepGroupChanged(int timeStepType, bool disableOther, int vmax)
+{
+  switch (timeStepType)
+  {
+  case 0 :
+    onNoTimeStep(disableOther);
+    break;
+  case 1 :
+    onLastTimeStep(disableOther);
+    break;
+  case 2 :
+    onChosenTimeStep(disableOther, vmax);
+  default:
+    break;
+  }
+}
+
+void SMESHGUI_MgAdaptArguments::clear()
+{
+  selectMedFileLineEdit->clear();
+  aBrowserObject->clear();
+
+  meshNameLineEdit->clear();
+  selectOutMedFileLineEdit->clear();
+}
+// med_int SMESHGUI_MgAdaptArguments::getMeshDim() const
+// {
+//   return meshDim;
+// }
+QWidget* ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const
+{
+  bool editable = index.data( EDITABLE_ROLE ).toInt();
+  return editable ? QItemDelegate::createEditor( parent, o, index ) : 0;
+}
+
+//////////////////////////////////////////
+// MgAdaptAdvWidget
+//////////////////////////////////////////
+
+MgAdaptAdvWidget::MgAdaptAdvWidget( QWidget* parent, std::vector <std::string>* options, Qt::WindowFlags f )
+  : QWidget( parent, f ), myOptions(options)
+{
+  setupWidget();
+  myOptionTable->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
+  myOptionTable->setItemDelegate( new ItemDelegate( myOptionTable ) );
+
+  for ( int i = 0, nb = myOptions->size(); i < nb; ++i )
+  {
+    AddOption( (*myOptions)[i].c_str() );
+  }
+
+  connect( myOptionTable, SIGNAL( itemChanged(QTreeWidgetItem *, int)), SLOT( itemChanged(QTreeWidgetItem *, int )));
+  connect( addBtn,        SIGNAL(clicked()),       this, SLOT( onAddOption() ) );
+  connect(workingDirectoryPushButton, SIGNAL(pressed()),  this, SLOT(_onWorkingDirectoryPushButton()));
+}
+
+MgAdaptAdvWidget::~MgAdaptAdvWidget()
+{
+}
+
+void MgAdaptAdvWidget::AddOption( const char* option, bool isCustom )
+{
+  QString name, value;
+  bool isDefault = false;
+  if ( option )
+  {
+    QStringList name_value_type = QString(option).split( ":", QString::KeepEmptyParts );
+    if ( name_value_type.size() > 0 )
+        name = name_value_type[0];
+    if ( name_value_type.size() > 1 )
+        value = name_value_type[1];
+    if ( name_value_type.size() > 2 )
+        isDefault = !name_value_type[2].toInt();
+  }
+  QTreeWidget* table = myOptionTable;
+  //table->setExpanded( true );
+
+  QTreeWidgetItem* row;
+  if (optionTreeWidgetItem.size())
+  {
+    std::map<QString, QTreeWidgetItem *>::iterator it = optionTreeWidgetItem.find(name);
+    if(it != optionTreeWidgetItem.end()) return; // option exist
+    else
+    {
+      row = getNewQTreeWidgetItem(table, option, name, isCustom);
+    }
+  }
+  else
+  {
+    row = getNewQTreeWidgetItem(table, option, name, isCustom);
+  }
+  row->setText( 0, tr( name.toLatin1().constData() ));
+  row->setText( 1, tr( value.toLatin1().constData() ));
+  row->setCheckState( 0, isDefault ? Qt::Unchecked : Qt::Checked);
+  row->setData( NAME_COL, PARAM_NAME, name );
+
+  if ( isCustom )
+  {
+    myOptionTable->scrollToItem( row );
+    myOptionTable->setCurrentItem( row );
+    myOptionTable->editItem( row, NAME_COL );
+  }
+}
+
+QTreeWidgetItem* MgAdaptAdvWidget::getNewQTreeWidgetItem(QTreeWidget* table, const char* option, QString& name, bool isCustom)
+{
+  QTreeWidgetItem* row = new QTreeWidgetItem( table );
+  row->setData( NAME_COL, EDITABLE_ROLE, int( isCustom && !option ));
+  row->setFlags( row->flags() | Qt::ItemIsEditable );
+  optionTreeWidgetItem.insert(std::pair <QString, QTreeWidgetItem*> (name, row));
+
+  return row;
+}
+
+void MgAdaptAdvWidget::onAddOption()
+{
+  AddOption( NULL, true );
+}
+void MgAdaptAdvWidget::GetOptionAndValue( QTreeWidgetItem * tblRow,
+        QString&          option,
+        QString&          value,
+        bool&             isDefault)
+{
+  option    = tblRow->data( NAME_COL, PARAM_NAME ).toString();
+  value     = tblRow->text( VALUE_COL );
+  isDefault = ! tblRow->checkState( NAME_COL );
+
+}
+
+void MgAdaptAdvWidget::itemChanged(QTreeWidgetItem* tblRow, int column)
+{
+  if ( tblRow )
+  {
+    myOptionTable->blockSignals( true );
+
+    tblRow->setData( VALUE_COL, EDITABLE_ROLE, int( tblRow->checkState( NAME_COL )));
+
+    int c = tblRow->checkState( NAME_COL ) ? 0 : 150;
+    tblRow->setForeground( VALUE_COL, QBrush( QColor( c, c, c )));
+
+    if ( column == NAME_COL && tblRow->data( NAME_COL, EDITABLE_ROLE ).toInt() ) // custom table
+    {
+      tblRow->setData( NAME_COL, PARAM_NAME, tblRow->text( NAME_COL ));
+    }
+
+    myOptionTable->blockSignals( false );
+  }
+}
+void MgAdaptAdvWidget::setupWidget()
+{
+  if (this->objectName().isEmpty())
+      this->setObjectName(QString(tr("MG-ADAPT-ADV")));
+  this->resize(337, 369);
+  gridLayout_4 = new QGridLayout(this);
+  gridLayout_4->setObjectName(QString("gridLayout_4"));
+  myOptionTable = new MgAdaptAdvWidgetTreeWidget(this);
+  QFont font;
+  font.setBold(false);
+  font.setWeight(50);
+  QTreeWidgetItem *__qtreewidgetitem = new QTreeWidgetItem();
+  __qtreewidgetitem->setFont(1, font);
+  __qtreewidgetitem->setFont(0, font);
+  __qtreewidgetitem->setText(1, tr("OPTION_VALUE_COLUMN"));
+  __qtreewidgetitem->setText(0, tr("OPTION_NAME_COLUMN"));
+  myOptionTable->setHeaderItem(__qtreewidgetitem);
+  myOptionTable->setObjectName(QString("myOptionTable"));
+  myOptionTable->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
+  myOptionTable->setTabKeyNavigation(true);
+
+  gridLayout_4->addWidget(myOptionTable, 0, 0, 1, 2);
+
+  addBtn = new QPushButton(this);
+  addBtn->setObjectName(QString("addBtn"));
+
+  gridLayout_4->addWidget(addBtn, 1, 0, 1, 1);
+
+  horizontalSpacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+
+  gridLayout_4->addItem(horizontalSpacer, 1, 1, 1, 1);
+
+  logGroupBox = new QGroupBox(this);
+  logGroupBox->setObjectName(QString("logGroupBox"));
+  gridLayout_2 = new QGridLayout(logGroupBox);
+  gridLayout_2->setObjectName(QString("gridLayout_2"));
+  gridLayout = new QGridLayout();
+  gridLayout->setObjectName(QString("gridLayout"));
+  workingDirectoryLabel = new QLabel(logGroupBox);
+  workingDirectoryLabel->setObjectName(QString("workingDirectoryLabel"));
+
+  gridLayout->addWidget(workingDirectoryLabel, 0, 0, 1, 1);
+
+  workingDirectoryLineEdit = new QLineEdit(logGroupBox);
+  workingDirectoryLineEdit->setObjectName(QString("workingDirectoryLineEdit"));
+
+  gridLayout->addWidget(workingDirectoryLineEdit, 0, 1, 1, 1);
+
+  workingDirectoryPushButton = new QPushButton(logGroupBox);
+  workingDirectoryPushButton->setObjectName(QString("workingDirectoryPushButton"));
+
+  gridLayout->addWidget(workingDirectoryPushButton, 0, 2, 1, 1);
+
+  verboseLevelLabel = new QLabel(logGroupBox);
+  verboseLevelLabel->setObjectName(QString("verboseLevelLabel"));
+
+  gridLayout->addWidget(verboseLevelLabel, 1, 0, 1, 1);
+
+  verboseLevelSpin = new QSpinBox(logGroupBox);
+  verboseLevelSpin->setObjectName(QString("verboseLevelSpin"));
+
+  gridLayout->addWidget(verboseLevelSpin, 1, 1, 1, 1);
+
+
+  gridLayout_2->addLayout(gridLayout, 0, 0, 1, 1);
+
+  horizontalLayout = new QHBoxLayout();
+  horizontalLayout->setObjectName(QString("horizontalLayout"));
+  logInFileCheck = new QCheckBox(logGroupBox);
+  logInFileCheck->setObjectName(QString("logInFileCheck"));
+  logInFileCheck->setChecked(true);
+
+  horizontalLayout->addWidget(logInFileCheck);
+
+  removeLogOnSuccessCheck = new QCheckBox(logGroupBox);
+  removeLogOnSuccessCheck->setObjectName(QString("removeLogOnSuccessCheck"));
+  removeLogOnSuccessCheck->setChecked(true);
+
+  horizontalLayout->addWidget(removeLogOnSuccessCheck);
+
+
+  gridLayout_2->addLayout(horizontalLayout, 1, 0, 1, 1);
+
+  keepWorkingFilesCheck = new QCheckBox(logGroupBox);
+  keepWorkingFilesCheck->setObjectName(QString("keepWorkingFilesCheck"));
+  keepWorkingFilesCheck->setAutoExclusive(false);
+
+  gridLayout_2->addWidget(keepWorkingFilesCheck, 2, 0, 1, 1);
+
+
+  gridLayout_4->addWidget(logGroupBox, 3, 0, 1, 2);
+
+}
+void MgAdaptAdvWidget::_onWorkingDirectoryPushButton()
+{
+  QString aDirName=QFileDialog::getExistingDirectory ();
+  if (!(aDirName.isEmpty()))workingDirectoryLineEdit->setText(aDirName);
+}
+void MgAdaptAdvWidget::onMeshDimChanged(ADAPTATION_MODE aMode)
+{
+/* default adaptation mode
+  * assume that if meshDim == 2 and no 3D backgrounmesh-->adaptation surface
+  * if meshDim == 3 and  if there is not 2D mesh -->VOLUME
+  * else BOTH
+  */
+
+  QString adaptation("adaptation"), value;
+  switch(aMode)
+  {
+    case ADAPTATION_MODE::SURFACE:
+    {
+      value ="surface";
+      setOptionValue(adaptation, value);
+      break;
+    }
+    case ADAPTATION_MODE::BOTH :
+    {
+      value = "both";
+      setOptionValue(adaptation, value);
+      break;
+    }
+    case ADAPTATION_MODE::VOLUME :
+    {
+      value = "volume";
+      setOptionValue(adaptation, value);
+      break;
+    }
+  }
+}
+void MgAdaptAdvWidget::setOptionValue(QString& option, QString& value)
+{
+  std::map<QString, QTreeWidgetItem *>::iterator it = optionTreeWidgetItem.find(option);
+  if (it != optionTreeWidgetItem.end())
+  {
+    it->second->setText( 0, tr( option.toLatin1().constData() ));
+    it->second->setText( 1, tr( value.toLatin1().constData() ));
+    it->second->setCheckState( 0,  Qt::Checked );
+    it->second->setData( NAME_COL, PARAM_NAME, option );
+    myOptionTable->editItem( it->second, NAME_COL );
+  }
+}
+namespace
+{
+bool isEditable( const QModelIndex& index )
+{
+  return index.isValid() &&
+          index.flags() & Qt::ItemIsEditable &&
+          index.flags() & Qt::ItemIsEnabled &&
+          ( !index.data( Qt::UserRole + 1 ).isValid() || index.data( Qt::UserRole + 1 ).toInt() != 0 );
+}
+}
+
+MgAdaptAdvWidgetTreeWidget::MgAdaptAdvWidgetTreeWidget( QWidget* parent )
+    : QTreeWidget( parent )
+{
+}
+
+QModelIndex MgAdaptAdvWidgetTreeWidget::moveCursor( CursorAction action, Qt::KeyboardModifiers modifiers )
+{
+  QModelIndex current = currentIndex();
+  int column = current.column();
+  if ( action == MoveNext )
+  {
+    if ( column < columnCount()-1 )
+    {
+      QModelIndex next = current.sibling( current.row(), column+1 );
+      if ( isEditable( next ) ) return next;
+    }
+    else
+    {
+      QModelIndex next = current.sibling( current.row()+1, 0 );
+      if ( isEditable( next ) ) return next;
+    }
+  }
+  else if ( action == MovePrevious )
+  {
+    if ( column == 0 ) {
+      QModelIndex next = current.sibling( current.row()-1, columnCount()-1 );
+      if ( isEditable( next ) ) return next;
+    }
+    else {
+      QModelIndex next = current.sibling( current.row(), column-1 );
+       if ( isEditable( next ) ) return next;
+    }
+  }
+  return QTreeWidget::moveCursor( action, modifiers );
+}
+
+void MgAdaptAdvWidgetTreeWidget::keyPressEvent( QKeyEvent* e )
+{
+  switch ( e->key() )
+  {
+    case Qt::Key_F2:
+    {
+      QModelIndex index = currentIndex();
+      if ( !isEditable( index ) ) {
+        for ( int i = 0; i < columnCount(); i++ ) {
+          QModelIndex sibling = index.sibling( index.row(), i );
+          if ( isEditable( sibling ) ) {
+            if ( !edit( sibling, EditKeyPressed, e ) ) e->ignore();
+          }
+        }
+      }
+    }
+    break;
+    default:
+      break;
+  }
+  QTreeWidget::keyPressEvent( e );
+}
+
+// ======================================================
+// ========================================================
+QString lireNomMaillage(QString aFile, med_int& meshdim)
+{
+  QString nomMaillage = QString::null ;
+
+  while ( true )
+  {
+    std::vector<std::string> listMeshesNames = MEDCoupling::GetMeshNames(aFile.toStdString());
+
+    std::size_t numberOfMeshes(listMeshesNames.size());
+  //   std::cout << "numberOfMeshes:" << numberOfMeshes << std::endl;
+    if (numberOfMeshes == 0 )
+    {
+      QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
+                                QObject::tr("MG_ADAPT_MED_FILE_2") );
+      break ;
+    }
+    if (numberOfMeshes > 1 )
+    {
+      QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
+                                QObject::tr("MG_ADAPT_MED_FILE_3") );
+      break ;
+    }
+
+//     std::cout << "nomMaillage:" << listMeshesNames[0] << std::endl;
+    nomMaillage = QString(listMeshesNames[0].c_str());
+
+    // Dimension du maillage
+    MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(aFile.toStdString());
+    meshdim = mfd->getMeshes()->getMeshAtPos(0)->getMeshDimension() ;
+//     std::cout << "meshdim:" << meshdim << std::endl;
+
+    break ;
+  }
+
+  return nomMaillage;
+}
+
+// =======================================================================
+std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage)
+// =======================================================================
+{
+// Il faut voir si plusieurs maillages
+
+  std::map<QString, int> ListeChamp ;
+
+  while ( true )
+  {
+    MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(aFile.toStdString());
+    std::vector<std::string> listFieldsNames(mfd->getFields()->getFieldsNames());
+    std::size_t jaux(listFieldsNames.size());
+    if (jaux < 1 )
+    {
+      if(errorMessage)
+      {
+        QMessageBox::critical( 0, QObject::tr("_ERROR"),
+                                  QObject::tr("HOM_MED_FILE_5") );
+      }
+      break ;
+    }
+    // nbofcstp inutile pour le moment
+    med_int nbofcstp = 1;
+    for(std::size_t j=0;j<jaux;j++)
+    {
+//       std::cout << listFieldsNames[j] << std::endl;
+      ListeChamp.insert(std::pair<QString, int> (QString(listFieldsNames[j].c_str()), nbofcstp));
+    }
+    break ;
+  }
+
+  return ListeChamp;
+}
+
+// =======================================================================
+std::string remove_extension(const std::string& filename)
+// =======================================================================
+{
+  size_t lastdot = filename.find_last_of(".");
+  if (lastdot == std::string::npos) return filename;
+  return filename.substr(0, lastdot);
+}
diff --git a/src/SMESHGUI/MG_ADAPTGUI.hxx b/src/SMESHGUI/MG_ADAPTGUI.hxx
new file mode 100644 (file)
index 0000000..5121d11
--- /dev/null
@@ -0,0 +1,329 @@
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// SMESH SMESHGUI : GUI for the adaptation in the SMESH component\r
+// File : MG_ADAPTGUI.hxx\r
+//\r
+#ifndef MG_ADAPTGUI_HXX\r
+#define MG_ADAPTGUI_HXX\r
+\r
+#include <set>\r
+// SMESH includes\r
+\r
+// Qt includes\r
+#include <QDialog>\r
+#include <QTreeWidget>\r
+#include<QItemDelegate>\r
+\r
+#include "LightApp_DataOwner.h"\r
+#include "SalomeApp_Application.h"\r
+#include <SALOMEconfig.h>\r
+#include <SALOME_ListIO.hxx>\r
+#include "SalomeApp_Module.h"\r
+#include "SalomeApp_Study.h"\r
+#include <med.h>\r
+#include <map>\r
+\r
+\r
+// model\r
+\r
+\r
+//~#include "MG_ADAPT.hxx"\r
+\r
+#include CORBA_SERVER_HEADER(MG_ADAPT)\r
+\r
+class SUIT_ViewWindow;\r
+class SUIT_Desktop;\r
+class SUIT_Study;\r
+class SUIT_ResourceMgr;\r
+\r
+class CAM_Module;\r
+\r
+class SALOMEDSClient_Study;\r
+class SALOMEDSClient_SObject;\r
+\r
+class SalomeApp_Study;\r
+class SalomeApp_Module;\r
+class LightApp_SelectionMgr;\r
+\r
+\r
+class QButtonGroup;\r
+class QLineEdit;\r
+class QGroupBox;\r
+class QRadioButton;\r
+class QLabel;\r
+class QCheckBox;\r
+class QGridLayout;\r
+class QTabWidget;\r
+class QDoubleSpinBox;\r
+class QSpinBox;\r
+class QTreeWidget;\r
+class QTreeWidgetItem;\r
+class QSpacerItem;\r
+class QHBoxLayout;\r
+class QItemDelegate;\r
+class QComboBox;\r
+\r
+// IDL includes\r
+#include <SALOMEconfig.h>\r
+\r
+class SVTK_ViewWindow;\r
+class SVTK_Selector;\r
+class SMESHGUI_MgAdaptDlg;\r
+class SMESHGUI_MgAdaptArguments;\r
+class SMESHGUI_SpinBox;\r
+class MgAdaptAdvWidgetTreeWidget;\r
+class MgAdaptAdvWidget;\r
+//~class MgAdapt;\r
+class QHeaderView;\r
+class QFileDialog;\r
+\r
+\r
+std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage = true);\r
+QString lireNomMaillage(QString aFile, med_int& meshDim);\r
+\r
+std::string remove_extension(const std::string& filename);\r
+\r
+enum ADAPTATION_MODE{\r
+  SURFACE,\r
+  VOLUME,\r
+  BOTH\r
+};\r
+//=================================================================================\r
+// class    : SMESHGUI_MgAdaptDlg\r
+// purpose  :\r
+//=================================================================================\r
+class  SMESHGUI_MgAdaptDlg : public QDialog\r
+{\r
+  Q_OBJECT;\r
+public:\r
+  //! Property type\r
+  enum Mode { Arguments, AdvancedOptions};\r
+  SMESHGUI_MgAdaptDlg( SalomeApp_Module*, SMESH::MG_ADAPT_ptr, QWidget* parent= 0,bool isCreation = true );\r
+  ~SMESHGUI_MgAdaptDlg();\r
+\r
+  void buildDlg();\r
+  void reject();\r
+  bool checkParams(QString& msg) ;\r
+  //~void setModel(MgAdapt*);\r
+  SMESH::MG_ADAPT_ptr getModel() const;\r
+\r
+public slots:\r
+\r
+protected slots:\r
+  virtual bool PushOnApply();\r
+\r
+private slots:\r
+  virtual void PushOnHelp();\r
+  virtual void PushOnOK();\r
+\r
+protected :\r
+\r
+  SMESHGUI_MgAdaptArguments* myArgs;\r
+  MgAdaptAdvWidget* myAdvOpt;\r
+  bool readParamsFromHypo( ) const ;\r
+  bool readParamsFromWidgets( ) ;\r
+  bool storeParamsToHypo( const SMESH::MgAdaptHypothesisData & ) const;\r
+\r
+private:\r
+\r
+  SalomeApp_Module*              mySMESHGUI;              /* Current SMESHGUI object */\r
+  QTabWidget*           myTabWidget;\r
+\r
+\r
+  SMESH::MgAdaptHypothesisData* myData;\r
+  SMESH::MG_ADAPT_ptr model;\r
+\r
+};\r
+\r
+class  SMESHGUI_MgAdaptArguments : public QWidget\r
+{\r
+  Q_OBJECT;\r
+public:\r
+  //! Property type\r
+  enum Mode { Mesh, Browser};\r
+  enum SIZEMAP { Local, Background, Constant};\r
+  SMESHGUI_MgAdaptArguments( QWidget* parent);\r
+  ~SMESHGUI_MgAdaptArguments();\r
+  void setMode( const Mode, const SIZEMAP );\r
+\r
+  QString* myFileInDir;\r
+  QString* myFileOutDir;\r
+  QString* myFileSizeMapDir;\r
+  QGroupBox*    aMeshIn ;\r
+  QRadioButton* aMedfile;\r
+  QRadioButton* aBrowser ;\r
+  QLineEdit* aBrowserObject;\r
+  QPushButton* selectMedFilebutton ;\r
+  QSpacerItem* hspacer;\r
+  QLineEdit* selectMedFileLineEdit ;\r
+  QButtonGroup* meshInGroup ;\r
+  QGridLayout* meshIn ;\r
+\r
+  QGroupBox*    aMeshOut ;\r
+  QLabel* meshName;\r
+  QLineEdit* meshNameLineEdit;\r
+  QSpacerItem* secondHspacer;\r
+  QCheckBox* medFileCheckBox;\r
+  QPushButton* selectOutMedFilebutton;\r
+  QLineEdit* selectOutMedFileLineEdit;\r
+  QSpacerItem* thirdHspacer;\r
+  QCheckBox* publishOut;\r
+  QGridLayout* meshOut ;\r
+\r
+  QGroupBox*    sizeMapDefinition ;\r
+  QRadioButton* localButton;\r
+  QRadioButton* backgroundButton ;\r
+  QRadioButton* constantButton ;\r
+  QLabel* medFileBackground;\r
+  QPushButton* selectMedFileBackgroundbutton;\r
+  QLineEdit* selectMedFileBackgroundLineEdit;\r
+  QLabel* valueLabel;\r
+  QDoubleSpinBox* dvalue;\r
+  QButtonGroup* sizeMapDefGroup ;\r
+  QGridLayout* sizeMapDefGroupLayout;\r
+\r
+\r
+  QGroupBox* sizeMapField;\r
+  QLabel* fieldName;\r
+  QComboBox* fieldNameCmb;\r
+  QRadioButton* noTimeStep;\r
+  QRadioButton* lastTimeStep ;\r
+  QRadioButton* chosenTimeStep;\r
+  QLabel* timeStepLabel;\r
+  QSpinBox* timeStep;\r
+  QLabel* rankLabel;\r
+  QSpinBox* rankSpinBox;\r
+  QButtonGroup* timeStepGroup;\r
+  QGridLayout* sizeMapFieldGroupLayout;\r
+\r
+signals:\r
+  void updateSelection();\r
+  void toExportMED(const char *);\r
+  void meshDimSignal(ADAPTATION_MODE aMode);\r
+public slots:\r
+\r
+protected slots:\r
+\r
+private slots:\r
+  void modeChanged( int);\r
+  void sizeMapDefChanged(int);\r
+  void timeStepGroupChanged(int timeStepType, bool disableOther = false, int vmax = 0);\r
+  void onSelectMedFilebuttonClicked();\r
+  void clear();\r
+  void onMedFileCheckBox(int);\r
+  void onPublishOut(int);\r
+  void onSelectOutMedFilebutton();\r
+  void onSelectMedFileBackgroundbutton();\r
+  void onLocalSelected(QString);\r
+  void onNoTimeStep(bool disableOther = false);\r
+  void onLastTimeStep(bool disableOther = false);\r
+  void onChosenTimeStep(bool disableOther = false, int vmax = 0);\r
+  void visibleTimeStepRankLabel(bool visible);\r
+  void valueAdaptation ();\r
+\r
+private:\r
+\r
+  QString getMedFileName(bool avertir);\r
+  LightApp_SelectionMgr* selMgr ;\r
+  med_int meshDim;\r
+  med_int meshDimBG;\r
+  std::map<QString, int> myFieldList;\r
+\r
+};\r
+enum {\r
+  OPTION_ID_COLUMN = 0,\r
+  OPTION_TYPE_COLUMN,\r
+  OPTION_NAME_COLUMN = 0,\r
+  OPTION_VALUE_COLUMN,\r
+  NB_COLUMNS,\r
+};\r
+\r
+//////////////////////////////////////////\r
+// MgAdaptAdvWidget\r
+//////////////////////////////////////////\r
+class  MgAdaptAdvWidget : public QWidget\r
+{\r
+  Q_OBJECT\r
+\r
+public:\r
+  MgAdaptAdvWidget( QWidget* = 0, std::vector <std::string> * = nullptr, Qt::WindowFlags = 0 );\r
+  ~MgAdaptAdvWidget();\r
+  std::vector < std::string > * myOptions;\r
+  QGridLayout *gridLayout_4;\r
+  MgAdaptAdvWidgetTreeWidget *myOptionTable;\r
+  QPushButton *addBtn;\r
+  QSpacerItem *horizontalSpacer;\r
+  QGroupBox *logGroupBox;\r
+  QGridLayout *gridLayout_2;\r
+  QGridLayout *gridLayout;\r
+  QLabel *workingDirectoryLabel;\r
+  QLineEdit *workingDirectoryLineEdit;\r
+  QPushButton *workingDirectoryPushButton;\r
+  QLabel *verboseLevelLabel;\r
+  QSpinBox *verboseLevelSpin;\r
+  QHBoxLayout *horizontalLayout;\r
+  QCheckBox *logInFileCheck;\r
+  QCheckBox *removeLogOnSuccessCheck;\r
+  QCheckBox *keepWorkingFilesCheck;\r
+\r
+  void AddOption( const char* name_value_type, bool isCustom = false );\r
+  void GetOptionAndValue( QTreeWidgetItem * tblRow, QString& option, QString& value, bool& dflt );\r
+  void setupWidget();\r
+\r
+public slots:\r
+  void                onAddOption();\r
+  void itemChanged(QTreeWidgetItem * tblRow, int column);\r
+  void onMeshDimChanged(ADAPTATION_MODE aMode);\r
+private slots:\r
+  void _onWorkingDirectoryPushButton();\r
+private:\r
+  void setOptionValue(QString& option, QString& value);\r
+  std::map<QString, QTreeWidgetItem *> optionTreeWidgetItem;\r
+\r
+  QTreeWidgetItem* getNewQTreeWidgetItem(QTreeWidget* table, const char* option, QString& name, bool isCustom);\r
+\r
+};\r
+\r
+enum { EDITABLE_ROLE = Qt::UserRole + 1, PARAM_NAME,\r
+       NAME_COL = 0, VALUE_COL\r
+     };\r
+\r
+class  ItemDelegate: public QItemDelegate\r
+{\r
+public:\r
+\r
+  ItemDelegate(QObject* parent=0): QItemDelegate(parent) {}\r
+  QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const;\r
+};\r
+\r
+class  MgAdaptAdvWidgetTreeWidget : public QTreeWidget\r
+{\r
+  Q_OBJECT\r
+public:\r
+  MgAdaptAdvWidgetTreeWidget( QWidget* );\r
+\r
+protected:\r
+  QModelIndex moveCursor( CursorAction, Qt::KeyboardModifiers );\r
+  void keyPressEvent( QKeyEvent* );\r
+};\r
+\r
+#endif // MG_ADAPTGUI_HXX\r
index ff88035b1238d665f0230d67d0da51ea0eed8203..a16812234d7f1d945935710d26415e73b295ddfb 100644 (file)
@@ -30,6 +30,7 @@
 
 //  SMESH includes
 #include "SMESHGUI.h"
+#include "SMESHGUI_AdaptDlg.h"
 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
 #include "SMESHGUI_AddMeshElementDlg.h"
 #include "SMESHGUI_AddQuadraticElementDlg.h"
@@ -1970,12 +1971,12 @@ void SMESHGUI::OnEditDelete()
   int objectCount = 0;
   QString aNameList;
   QString aParentComponent = QString::null;
-  
+
   for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
   {
     Handle(SALOME_InteractiveObject) anIO = anIt.Value();
     if ( anIO.IsNull() ) continue;
-    
+
     QString father = "unknown", name;
 
     _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() );
@@ -3034,6 +3035,13 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       }
       break;
     }
+  // Adaptation - begin
+  case SMESHOp::OpMGAdapt:
+    {
+      SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
+      SMESHGUI_AdaptDlg *objet = new SMESHGUI_AdaptDlg( this, theCommandID, aMesh);
+    }
+  // Adaptation - end
   case SMESHOp::OpSplitBiQuadratic:
   case SMESHOp::OpConvertMeshToQuadratic:
   case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
@@ -4271,6 +4279,10 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction( SMESHOp::OpAutoColor,        "AUTO_COLOR" );
   createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
 
+  // Adaptation - begin
+  createSMESHAction( SMESHOp::OpMGAdapt,              "MG_ADAPT",                "ICON_MG_ADAPT" );
+  // Adaptation - end
+
   createSMESHAction( SMESHOp::OpMinimumDistance,  "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
   createSMESHAction( SMESHOp::OpBoundingBox,      "MEASURE_BND_BOX",  "ICON_MEASURE_BND_BOX" );
   createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH",   "ICON_MEASURE_LENGTH" );
@@ -4312,6 +4324,7 @@ void SMESHGUI::initialize( CAM_Application* app )
       meshId    = createMenu( tr( "MEN_MESH" ),    -1, 70, 10 ),
       ctrlId    = createMenu( tr( "MEN_CTRL" ),    -1, 60, 10 ),
       modifyId  = createMenu( tr( "MEN_MODIFY" ),  -1, 40, 10 ),
+      adaptId   = createMenu( tr( "MEN_ADAPT" ),   -1, 80, 10 ),
       measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
       viewId    = createMenu( tr( "MEN_VIEW" ),    -1,  2 );
 
@@ -4484,6 +4497,10 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( SMESHOp::OpSmoothing,              modifyId, -1 );
   createMenu( SMESHOp::OpPatternMapping,         modifyId, -1 );
 
+  // Adaptation - begin
+  createMenu( SMESHOp::OpMGAdapt,              adaptId, -1 );
+  // Adaptation - end
+
   createMenu( SMESHOp::OpMinimumDistance,  measureId,   -1 );
   createMenu( SMESHOp::OpBoundingBox,      measureId,   -1 );
   createMenu( SMESHOp::OpAngle,            measureId,   -1 );
@@ -4498,22 +4515,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
 
   // ----- create toolbars --------------
-  int meshTb       = createTool( tr( "TB_MESH" ),      QString( "SMESHMeshToolbar" ) ),
-      info         = createTool( tr( "TB_INFO" ),      QString( "SMESHInformationToolbar" ) ),
-      groupTb      = createTool( tr( "TB_GROUP" ),     QString( "SMESHGroupToolbar" ) ),
-      ctrl0dTb     = createTool( tr( "TB_CTRL0D" ),    QString( "SMESHNodeControlsToolbar" ) ),
-      ctrl1dTb     = createTool( tr( "TB_CTRL1D" ),    QString( "SMESHEdgeControlsToolbar" ) ),
-      ctrl2dTb     = createTool( tr( "TB_CTRL2D" ),    QString( "SMESHFaceControlsToolbar" ) ),
-      ctrl3dTb     = createTool( tr( "TB_CTRL3D" ),    QString( "SMESHVolumeControlsToolbar" ) ),
-      addElemTb    = createTool( tr( "TB_ADD" ),       QString( "SMESHAddElementToolbar" ) ),
-      addNonElemTb = createTool( tr( "TB_ADDNON" ),    QString( "SMESHAddElementToolbar" ) ),
-      remTb        = createTool( tr( "TB_REM" ),       QString( "SMESHRemoveToolbar" ) ),
-    //renumbTb     = createTool( tr( "TB_RENUMBER" ),  QString( "SMESHRenumberingToolbar" ) ),
-      transformTb  = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ),
-      modifyTb     = createTool( tr( "TB_MODIFY" ),    QString( "SMESHModificationToolbar" ) ),
-      measuremTb   = createTool( tr( "TB_MEASUREM" ),  QString( "SMESHMeasurementsToolbar" ) ),
-      dispModeTb   = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
-
+  int meshTb       = createTool( tr( "TB_MESH" ),      QString( "SMESHMeshToolbar" ) ) ;
   createTool( SMESHOp::OpCreateMesh,        meshTb );
   createTool( SMESHOp::OpCreateSubMesh,     meshTb );
   createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
@@ -4525,25 +4527,30 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpEvaluate,          meshTb );
   createTool( SMESHOp::OpMeshOrder,         meshTb );
 
+  int infoTb       = createTool( tr( "TB_INFO" ),      QString( "SMESHInformationToolbar" ) ) ;
+  createTool( SMESHOp::OpMeshInformation,    infoTb );
+  //createTool( SMESHOp::OpStdInfo, meshTb );
+  //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
+  createTool( SMESHOp::OpFindElementByPoint, infoTb );
+
+  int groupTb      = createTool( tr( "TB_GROUP" ),     QString( "SMESHGroupToolbar" ) ) ;
   createTool( SMESHOp::OpCreateGroup,         groupTb );
   createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
   createTool( SMESHOp::OpConstructGroup,      groupTb );
   createTool( SMESHOp::OpEditGroup,           groupTb );
 
-  createTool( SMESHOp::OpMeshInformation,    info );
-  //createTool( SMESHOp::OpStdInfo, meshTb );
-  //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
-  createTool( SMESHOp::OpFindElementByPoint, info );
-
+  int ctrl0dTb     = createTool( tr( "TB_CTRL0D" ),    QString( "SMESHNodeControlsToolbar" ) ) ;
   createTool( SMESHOp::OpFreeNode,  ctrl0dTb );
   createTool( SMESHOp::OpEqualNode, ctrl0dTb );
   //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
 
+  int ctrl1dTb     = createTool( tr( "TB_CTRL1D" ),    QString( "SMESHEdgeControlsToolbar" ) ) ;
   createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
   createTool( SMESHOp::OpLength,     ctrl1dTb );
   createTool( SMESHOp::OpConnection, ctrl1dTb );
   createTool( SMESHOp::OpEqualEdge,  ctrl1dTb );
 
+  int ctrl2dTb     = createTool( tr( "TB_CTRL2D" ),    QString( "SMESHFaceControlsToolbar" ) ) ;
   createTool( SMESHOp::OpFreeEdge,            ctrl2dTb );
   createTool( SMESHOp::OpFreeFace,            ctrl2dTb );
   createTool( SMESHOp::OpBareBorderFace,      ctrl2dTb );
@@ -4560,6 +4567,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpEqualFace,           ctrl2dTb );
   createTool( SMESHOp::OpDeflection2D,        ctrl2dTb );
 
+  int ctrl3dTb     = createTool( tr( "TB_CTRL3D" ),    QString( "SMESHVolumeControlsToolbar" ) ) ;
   createTool( SMESHOp::OpAspectRatio3D,         ctrl3dTb );
   createTool( SMESHOp::OpVolume,                ctrl3dTb );
   createTool( SMESHOp::OpMaxElementLength3D,    ctrl3dTb );
@@ -4567,6 +4575,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
   createTool( SMESHOp::OpEqualVolume,           ctrl3dTb );
 
+  int addElemTb    = createTool( tr( "TB_ADD" ),       QString( "SMESHAddElementToolbar" ) ) ;
   createTool( SMESHOp::OpNode,              addElemTb );
   createTool( SMESHOp::OpElem0D,            addElemTb );
   createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
@@ -4582,6 +4591,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpHexagonalPrism,    addElemTb );
   createTool( SMESHOp::OpPolyhedron,        addElemTb );
 
+  int addNonElemTb = createTool( tr( "TB_ADDNON" ),    QString( "SMESHAddElementToolbar" ) ) ;
   createTool( SMESHOp::OpQuadraticEdge,          addNonElemTb );
   createTool( SMESHOp::OpQuadraticTriangle,      addNonElemTb );
   createTool( SMESHOp::OpBiQuadraticTriangle,    addNonElemTb );
@@ -4595,14 +4605,17 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpQuadraticHexahedron,    addNonElemTb );
   createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
 
+  int remTb        = createTool( tr( "TB_REM" ),       QString( "SMESHRemoveToolbar" ) ) ;
   createTool( SMESHOp::OpRemoveNodes,       remTb );
   createTool( SMESHOp::OpRemoveElements,    remTb );
   createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
   createTool( SMESHOp::OpClearMesh,         remTb );
 
+//   int renumbTb     = createTool( tr( "TB_RENUMBER" ),  QString( "SMESHRenumberingToolbar" ) ) ;
   //createTool( SMESHOp::OpRenumberingNodes,    renumbTb );
   //createTool( SMESHOp::OpRenumberingElements, renumbTb );
 
+  int transformTb  = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
   createTool( SMESHOp::OpMergeNodes,     transformTb );
   createTool( SMESHOp::OpMergeElements,  transformTb );
   createTool( SMESHOp::OpTranslation,    transformTb );
@@ -4613,6 +4626,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpSewing,         transformTb );
   createTool( SMESHOp::OpDuplicateNodes, transformTb );
 
+  int modifyTb     = createTool( tr( "TB_MODIFY" ),    QString( "SMESHModificationToolbar" ) ) ;
   createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
   createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
   createTool( SMESHOp::OpExtrusion,              modifyTb );
@@ -4630,8 +4644,15 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( SMESHOp::OpSmoothing,              modifyTb );
   createTool( SMESHOp::OpPatternMapping,         modifyTb );
 
+  // Adaptation - begin
+  int adaptTb      = createTool( tr( "TB_ADAPTATION" ),QString( "SMESHAdaptationToolbar" ) ) ;
+  createTool( SMESHOp::OpMGAdapt,              adaptTb );
+  // Adaptation - end
+
+  int measuremTb   = createTool( tr( "TB_MEASUREM" ),  QString( "SMESHMeasurementsToolbar" ) ) ;
   createTool( SMESHOp::OpMinimumDistance, measuremTb );
 
+  int dispModeTb   = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
   createTool( SMESHOp::OpUpdate, dispModeTb );
 
   QString lc = "$";        // VSR : instead of QtxPopupSelection::defEquality();
@@ -4707,9 +4728,11 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->insert( separator(), -1, 0 );
   createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
   createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
-  //popupMgr()->insert( separator(), -1, 0 );
+  popupMgr()->insert( separator(), -1, 0 );
 
-  //popupMgr()->insert( separator(), -1, 0 );
+  // Adaptation - begin
+  createPopupItem( SMESHOp::OpMGAdapt,              OB, mesh );
+  // Adaptation - end
 
   QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
   QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
@@ -5131,7 +5154,7 @@ bool SMESHGUI::activateModule( SUIT_Study* study )
   lab = lab + tr("INFO_COMPUTE") + "<br/>";
   lab = lab + tr("INFO_REFINE") + ":";
   items << wrap(tr("INFO_REFINE_LOCAL_SIZE"), "li")
-       << wrap(tr("INFO_REFINE_SUBMESH"), "li");
+        << wrap(tr("INFO_REFINE_SUBMESH"), "li");
   lab = lab + wrap(items.join(""), "ul");
   items.clear();
 
@@ -5139,26 +5162,26 @@ bool SMESHGUI::activateModule( SUIT_Study* study )
 
   gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MESH"));
   items << wrap("UNV", "li")
-       << wrap("MED", "li")
-       << wrap("STL", "li")
-       << wrap("CGNS", "li")
-       << wrap("SAUV", "li")
-       << wrap("GMF", "li");
+        << wrap("MED", "li")
+        << wrap("STL", "li")
+        << wrap("CGNS", "li")
+        << wrap("SAUV", "li")
+        << wrap("GMF", "li");
   lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
   items.clear();
-  
+
   app->infoPanel()->addLabel(lab, gb);
-    
+
   gb = app->infoPanel()->addGroup(tr("INFO_GRP_CHECK_MESH"));
   lab = tr("INFO_DISPLAY") + "<br/>";
   items << wrap(tr("INFO_QUALITY_AREA"), "li")
-       << wrap(tr("INFO_QUALITY_VOLUME"), "li")
-       << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
-       << wrap("...", "li");
+        << wrap(tr("INFO_QUALITY_VOLUME"), "li")
+        << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
+        << wrap("...", "li");
   lab = lab + tr("INFO_QUALITY_INFO") + ":" + wrap(items.join(""), "ul");
   items.clear();
   lab = lab + tr("INFO_CLIPPING");
-  
+
   app->infoPanel()->addLabel(lab, gb);
   // << Help Panel
 
@@ -5366,7 +5389,7 @@ void SMESHGUI::createPreferences()
   setPreferenceProperty( dispgroup, "columns", 2 );
 
   addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
-  
+
   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
   QStringList modes;
   modes.append( tr("MEN_WIRE") );
@@ -5743,6 +5766,29 @@ void SMESHGUI::createPreferences()
   setPreferenceProperty( coloringType, "indexes", indices );
   addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
 
+  // Adaptation - begin
+  // Adaptation tab ------------------------------------------------------------------------
+  int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
+  int bloc, pref ;
+  // MG-Adapt
+  bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab );
+  setPreferenceProperty( bloc, "columns", 1 );
+  pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" );
+  pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" );
+  pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" );
+  QStringList aListOfSizeMap;
+  aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" );
+  aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" );
+  aListOfSizeMap << tr( "ADAPT_PREF_NONE" );;
+  setPreferenceProperty( pref, "strings", aListOfSizeMap );
+  pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" );
+  QStringList aListOfTimeStep;
+  aListOfTimeStep << tr( "ADAPT_PREF_NONE" );
+  aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
+  aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
+  setPreferenceProperty( pref, "strings", aListOfTimeStep );
+  // Adaptation - end
+
 }
 
 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
@@ -5956,6 +6002,10 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
   case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
     op = new SMESHGUI_Add0DElemsOnAllNodesOp();
     break;
+  // Adaptation - begin
+  case SMESHOp::OpMGAdapt:
+    break;
+  // Adaptation - end
   default:
     break;
   }
diff --git a/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx b/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx
new file mode 100644 (file)
index 0000000..a37c196
--- /dev/null
@@ -0,0 +1,162 @@
+// Copyright (C) 2011-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  SMESH SMESHGUI : GUI for the adaptation in the SMESH component
+//  File   : SMESHGUI_AdaptDlg.cxx
+//  Author : Gerald NICOLAS, EDF
+
+//  SMESH includes
+#include "SMESHGUI.h"
+#include "SMESHGUI_AdaptDlg.h"
+#include "SMESHGUI_MG_ADAPTDRIVER.h"
+//~#include "MG_ADAPT_i.hxx"
+//~#include "MG_ADAPT.hxx"
+
+// SALOME GUI includes
+#include <SUIT_Desktop.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+
+// SALOME KERNEL includes
+#include "utilities.h"
+#include <SALOME_LifeCycleCORBA.hxx>
+
+//=================================================================================
+// function : SMESHGUI_AdaptDlg()
+// purpose  :
+//=================================================================================
+SMESHGUI_AdaptDlg::SMESHGUI_AdaptDlg( SMESHGUI* theModule,
+                                      int theCommandID,
+                                      SMESH::SMESH_Mesh_ptr theMesh )
+  : mySMESHGUI( theModule )
+{
+  action( theCommandID ) ;
+}
+
+//=================================================================================
+// function : ~SMESHGUI_AdaptDlg()
+// purpose  : Destroys the object and frees any allocated resources
+//=================================================================================
+SMESHGUI_AdaptDlg::~SMESHGUI_AdaptDlg()
+{
+}
+
+/*!
+  * \brief Pilote les actions d'adaption de maillage
+  * \param
+  * \return bool OK/notOK
+*/
+void SMESHGUI_AdaptDlg::action (int theCommandID)
+//=======================================================================
+{
+//   std::cout  << "SMESHGUI_AdaptDlg::action avec theCommandID : " << theCommandID << std::endl;
+
+// Preferences
+//   recupPreferences();
+
+// Menus and actions
+  bool ok =  OnGUIEvent (theCommandID) ;
+  if ( ! ok ) INFOS("Erreur");
+
+  return ;
+}
+
+// /*!
+//   * \brief Gets the preferences for the adaptation
+//   * \param
+//   * \return
+//   *
+//   * Pour chaque valeur, le defaut est la valeur definie dans ADAPT_Gen
+//   * . Si la recuperation dans config/salome s'est bien passee a la creation de ADAPT_Gen
+//   *   ces valeurs sont les valeurs definies.
+//   * . Si cela ne s'est pas bien passe, ce sont les valeurs par defaut de ADAPT_Gen
+// */
+// void SMESHGUI_AdaptDlg::recupPreferences()
+// {
+//   INFOS("Début de recupPreferences")
+// //
+// // A. Declarations
+// //
+//   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+//   SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
+//   Engines::EngineComponent_var comp = ls->FindOrLoad_Component("FactoryServer", "SMESH");
+//   ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp);
+//   if (!CORBA::is_nil(adaptGen))
+//     adaptGen->UpdateStudy();
+//
+//   SUIT_ResourceMgr* resMgr = mySMESHGUI->getApp()->resourceMgr();
+//
+// }
+
+/*!
+  * \brief Launches the GUI for the adaptation
+  * \param theCommandID - the integer that references the operation
+  * \return bool OK/notOK
+*/
+bool SMESHGUI_AdaptDlg::OnGUIEvent (int theCommandID)
+{
+//   std::cout  << "SMESHGUI_AdaptDlg:OnGUIEvent avec theCommandID : " << theCommandID << std::endl;
+// A. Controles
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if ( !app ) return false;
+
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*> ( app->activeStudy() );
+  if ( !aStudy )
+  {
+    INFOS ( "FAILED to cast active study to SalomeApp_Study" );
+    return false;
+  }
+
+  SUIT_Desktop* parent = SUIT_Session::session()->activeApplication()->desktop();
+
+  SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
+  Engines::EngineComponent_var comp = ls->FindOrLoad_Component("FactoryServer", "SMESH");
+//   ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp);
+//   if (!CORBA::is_nil(adaptGen))
+//     adaptGen->UpdateStudy();
+
+  mySMESHGUI->getApp()->updateObjectBrowser();
+//
+// B. Choix selon les commandes
+  bool ok = true ;
+  SCRUTE(theCommandID);
+  switch (theCommandID)
+  {
+    case 8020: // Adaptation avec MG-Adpat
+    {
+//       INFOS("Interface avec MG-Adapt" );
+
+      SMESH::MG_ADAPT_ptr model = SMESHGUI::GetSMESHGen()->CreateMG_ADAPT();
+      bool isCreation = false;
+      if (mySMESHGUI->isStudyLocked()) break;
+      mySMESHGUI->EmitSignalDeactivateDialog();
+      SMESHGUI_MG_ADAPTDRIVER *mgAdapt = new SMESHGUI_MG_ADAPTDRIVER(mySMESHGUI, model, isCreation);
+      mgAdapt->show();
+      break;
+    }
+
+  }
+  mySMESHGUI->getApp()->updateObjectBrowser();
+  return ok;
+}
+
+
+
diff --git a/src/SMESHGUI/SMESHGUI_AdaptDlg.h b/src/SMESHGUI/SMESHGUI_AdaptDlg.h
new file mode 100644 (file)
index 0000000..1231b06
--- /dev/null
@@ -0,0 +1,77 @@
+// Copyright (C) 2011-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SMESH SMESHGUI : GUI for the adaptation in the SMESH component
+// File   : SMESHGUI_AdaptDlg.h
+// Author : Gérald NICOLAS, EDF
+//
+#ifndef SMESHGUI_ADAPTDLG_H
+#define SMESHGUI_ADAPTDLG_H
+
+// SMESH includes
+#include "SMESH_SMESHGUI.hxx"
+
+// Qt includes
+#include <QDialog>
+
+// IDL includes
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+class SMESHGUI;
+
+//=================================================================================
+// class    : SMESHGUI_AdaptDlg
+// purpose  :
+//=================================================================================
+class SMESHGUI_EXPORT SMESHGUI_AdaptDlg : public QWidget
+{
+public:
+  SMESHGUI_AdaptDlg( SMESHGUI*,
+                     int theCommandID,
+                     SMESH::SMESH_Mesh_ptr = SMESH::SMESH_Mesh::_nil() );
+  ~SMESHGUI_AdaptDlg();
+
+  void action (int theCommandID);
+  virtual bool OnGUIEvent (int theCommandID);
+
+//   static ADAPT::ADAPT_Gen_var InitAdaptGen(SalomeApp_Application*);
+
+public slots:
+
+protected slots:
+
+private slots:
+
+private:
+
+//   void recupPreferences();
+  SMESHGUI*                     mySMESHGUI;              /* Current SMESHGUI object */
+
+  QString _ObjectName;
+  QString _LanguageShort ;
+  int _PublisMeshIN ;
+  int _PublisMeshOUT ;
+  int _YACSMaxIter ;
+  int _YACSMaxNode ;
+  int _YACSMaxElem ;
+  int _YACSTypeTest ;
+};
+
+#endif // SMESHGUI_ADAPTDLG_H
diff --git a/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx b/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx
new file mode 100644 (file)
index 0000000..fc14963
--- /dev/null
@@ -0,0 +1,758 @@
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : SMESHGUI_MG_ADAPTDRIVER.cxx
+
+#include "SMESHGUI_MG_ADAPTDRIVER.h"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_Application.h"
+#include "SUIT_Session.h"
+
+#include "SalomeApp_Application.h"
+#include "SalomeApp_Module.h"
+#include "SalomeApp_Study.h"
+
+#include "SMESH_Comment.hxx"
+#include "SMESH_Actor.h"
+#include "SMESHGUI.h"
+#include "SMESHGUI_FilterDlg.h"
+#include "SMESHGUI_Selection.h"
+#include <SUIT_MessageBox.h>
+#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_MeshEditPreview.h"
+#include "SMESHGUI_VTKUtils.h"
+#include <SMESH_TypeFilter.hxx>
+#include <SMESH_MeshAlgos.hxx>
+#include <SMESH_LogicalFilter.hxx>
+#include <SMDS_Mesh.hxx>
+#include <SMDS_MeshNode.hxx>
+#include "SMESHGUI_SpinBox.h"
+
+#include <LightApp_SelectionMgr.h>
+#include <SUIT_OverrideCursor.h>
+#include <SUIT_ResourceMgr.h>
+#include <SVTK_ViewWindow.h>
+#include <SALOME_ListIO.hxx>
+#include <SUIT_FileDlg.h>
+#include "SMESHGUI_MeshUtils.h"
+
+
+#include <QApplication>
+#include <QButtonGroup>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QLineEdit>
+#include <QCheckBox>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QTabWidget>
+#include <QVBoxLayout>
+#include <QDoubleSpinBox>
+#include <QSpinBox>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
+#include <QSpacerItem>
+#include <QString>
+#include <QHeaderView>
+#include <QItemDelegate>
+#include <QFileDialog>
+#include <QMessageBox>
+#include <QComboBox>
+
+#include <vtkPoints.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkIdList.h>
+#include <vtkCellArray.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkDataSetMapper.h>
+#include <VTKViewer_CellLocationsArray.h>
+#include <vtkProperty.h>
+
+#include <ElCLib.hxx>
+// SALOME KERNEL includes
+#include <SALOMEDS_SComponent.hxx>
+#include <SALOMEDS_SObject.hxx>
+#include <SALOMEDS_Study.hxx>
+#include <SALOMEDS_wrap.hxx>
+#include "SalomeApp_Tools.h"
+#include <SALOMEconfig.h>
+#include <med.h>
+#include <utilities.h>
+
+#include <TCollection_AsciiString.hxx>
+
+const int SPACING = 6; // layout spacing
+const int MARGIN  = 9; // layout margin
+
+SALOME_ListIO mySelected;
+
+
+//================================================================
+// Function : firstIObject
+// Purpose  :  Return the first selected object in the selected object list
+//================================================================
+Handle(SALOME_InteractiveObject) firstIObject()
+{
+  const SALOME_ListIO& aList = selectedIO();
+  return aList.Extent() > 0 ? aList.First() : Handle(SALOME_InteractiveObject)();
+}
+//================================================================
+// Function : selectedIO
+// Return the list of selected SALOME_InteractiveObject's
+//================================================================
+const SALOME_ListIO& selectedIO()
+{
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* > ( SUIT_Session::session()->activeApplication() );
+  LightApp_SelectionMgr* aSelectionMgr = app->selectionMgr();
+  if( aSelectionMgr )
+  {
+    aSelectionMgr->selectedObjects( mySelected );
+    for (SALOME_ListIteratorOfListIO it (mySelected); it.More(); it.Next())
+      SCRUTE(it.Value()->getEntry());
+  };
+  return mySelected;
+}
+//================================================================
+// Function : getStudy
+// Returne un pointeur sur l'etude active
+//================================================================
+_PTR(Study) getStudy()
+{
+  static _PTR(Study) _study;
+  if(!_study)
+      _study = SalomeApp_Application::getStudy();
+  return _study;
+}
+
+bool createAndPublishMed(QString fileName)
+{
+
+  SMESH::DriverMED_ReadStatus res;
+  SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
+  // SMESHGUI aGui;
+
+  aMeshes = SMESHGUI::GetSMESHGen()->CreateMeshesFromMED( fileName.toUtf8().constData(), res );
+  _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[0] );
+  _PTR(Study) aStudy = SMESH::getStudy();
+  QStringList anEntryList;
+  // bool isEmpty;
+  if ( aMeshSO )
+  {
+    _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+    _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
+    aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
+    anEntryList.append( aMeshSO->GetID().c_str() );
+  }
+  else
+  {
+      // isEmpty = true;
+      return false;
+  }
+  SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+
+  // browse to the published meshes
+  if( LightApp_Application* anApp =
+              dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+      anApp->browseObjects( anEntryList );
+  return true;
+}
+bool createMgAdaptObject(MgAdapt *myMgAdapt )
+{
+  // SMESH::SMESH_Mesh_var newMesh = SMESHGUI::GetSMESHGen()->CreateEmptyMesh();
+
+  // _PTR(SObject) aHypothesis;
+  _PTR(Study) aStudy = SMESH::getStudy();
+  QStringList anEntryList;
+  _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+  _PTR(SComponent) mgadapt = aStudy->FindComponent("MG-ADAPT");
+  _PTR(GenericAttribute) ga;
+  if (!aBuilder->FindAttribute(mgadapt, ga, "AttributeName") )
+  {
+    mgadapt = aBuilder->NewComponent("MG-ADAPT");
+    _PTR(AttributeName) Name = aBuilder->FindOrCreateAttribute(mgadapt, "AttributeName");
+    Name->SetValue("MG-ADAPT");
+    _PTR(AttributePixMap) myPixmap = aBuilder->FindOrCreateAttribute( mgadapt, "AttributePixMap" );
+    myPixmap->SetPixMap( "ICON_MG_ADAPT" );
+    anEntryList.append( mgadapt->GetID().c_str() );
+  }
+
+  _PTR(SObject) obj = aBuilder->NewObject(mgadapt);
+  _PTR(AttributeName) myName = aBuilder->FindOrCreateAttribute(obj, "AttributeName");
+  myName->SetValue("hypo");
+  _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( obj, "AttributePixMap" );
+  aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
+  anEntryList.append( obj->GetID().c_str() );
+
+  SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+
+  // // browse to the published meshes
+  if( LightApp_Application* anApp =
+              dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+      anApp->browseObjects( anEntryList );
+  return true;
+}
+
+
+// MG ADAPT UTILS
+//================================================================
+// Function : IObjectCount
+// Return the number of selected objects
+//================================================================
+int IObjectCount()
+{
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  LightApp_SelectionMgr* aSelectionMgr = app->selectionMgr();
+  if( aSelectionMgr )
+  {
+      aSelectionMgr->selectedObjects( mySelected );
+      SCRUTE(mySelected.Extent());
+      return mySelected.Extent();
+  }
+  return 0;
+}
+
+
+
+SMESHGUI_MG_ADAPTDRIVER::SMESHGUI_MG_ADAPTDRIVER( SMESHGUI* theModule, SMESH::MG_ADAPT_ptr myModel, bool isCreation )
+  : mySMESHGUI( theModule ),
+    myFilterDlg(0),
+    myIsApplyAndClose( false ),
+    SMESHGUI_MgAdaptDlg((SalomeApp_Module*)theModule, myModel, SMESHGUI::desktop(), isCreation)
+{
+
+  resMgr = resourceMgr();
+
+  selMgr = selectionMgr();
+
+  // connections
+  connect(myArgs, SIGNAL(updateSelection()), this, SLOT(updateSelection()));
+  connect(myArgs, SIGNAL(toExportMED(const char*)), this, SLOT(exportMED(const char*)));
+}
+
+SUIT_ResourceMgr* SMESHGUI_MG_ADAPTDRIVER::resourceMgr()
+{
+  return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
+}
+
+LightApp_SelectionMgr* SMESHGUI_MG_ADAPTDRIVER::selectionMgr()
+{
+  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+  if( anApp )
+    return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
+  else
+    return 0;
+}
+
+void SMESHGUI_MG_ADAPTDRIVER::updateSelection()
+{
+  disconnect( selMgr, 0, this, 0 );
+  selMgr->clearFilters();
+
+  SMESH::SetPointRepresentation( true );
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
+      aViewWindow->SetSelectionMode( ActorSelection );
+  if (myArgs->aBrowser->isChecked())
+  {
+    connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ));
+    selectionChanged();
+  }
+
+}
+void SMESHGUI_MG_ADAPTDRIVER::selectionChanged()
+{
+  //~ get selected mesh
+  SALOME_ListIO aList;
+  selMgr->selectedObjects(aList);
+  QString aString = "";
+  int nbSel = aList.Extent();
+  if (nbSel != 1)
+    return;
+
+  Handle(SALOME_InteractiveObject) IO = aList.First();
+  SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(IO);
+  if ( !mesh->_is_nil() )
+  {
+    myMesh = mesh;
+
+    mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
+    if ( mySelectedObject->_is_nil() )
+        return;
+  }
+  else
+      return;
+
+  SMESH::GetNameOfSelectedIObjects( selMgr, aString );
+  if ( aString.isEmpty() ) aString = " ";
+  else                     aString = aString.trimmed();
+
+
+  bool ok = !aString.isEmpty();
+  if ( !mesh->_is_nil() )
+  {
+    myArgs->aBrowserObject->setText( aString );
+    myArgs->meshNameLineEdit->setText( aString );
+    myArgs->selectOutMedFileLineEdit->setText(aString+QString(".med"));
+    ADAPTATION_MODE aMode;
+    int nbVolumes = myMesh->NbVolumes();
+    int nbFaces = myMesh->NbFaces();
+    if(nbFaces > 0 && nbVolumes > 0) aMode = ADAPTATION_MODE::BOTH;
+    else if(nbFaces > 0) aMode = ADAPTATION_MODE::SURFACE;
+    else aMode = ADAPTATION_MODE::VOLUME;
+    emit myArgs->meshDimSignal(aMode);
+  }
+
+}
+void SMESHGUI_MG_ADAPTDRIVER::exportMED(const char* tmp_file)
+{
+  bool toOverwrite = true;
+  bool toFindOutDim = true;
+  myMesh->ExportMED(tmp_file, false, -1, toOverwrite, toFindOutDim);
+}
+void SMESHGUI_MG_ADAPTDRIVER::setMyMesh(SMESH::SMESH_Mesh_var mesh)
+{
+  myMesh = mesh;
+}
+SMESH::SMESH_Mesh_var SMESHGUI_MG_ADAPTDRIVER::getMyMesh()
+{
+  return myMesh;
+}
+
+//=================================================================================
+// function : PushOnOk()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MG_ADAPTDRIVER::PushOnOK()
+{
+  setIsApplyAndClose( true );
+  bool ret = PushOnApply();
+//   std::cout  << "SMESHGUI_MG_ADAPTDRIVER::PushOnOK ret : " <<ret<<std::endl;
+  if ( ret ) reject();
+}
+bool SMESHGUI_MG_ADAPTDRIVER::PushOnApply()
+{
+  MESSAGE("PushOnApply");
+
+  if ( SMESHGUI::isStudyLocked() )
+    return false;
+  if( !isValid() )
+    return false;
+
+  bool ok = SMESHGUI_MgAdaptDlg::PushOnApply();
+//   std::cout  << "SMESHGUI_MG_ADAPTDRIVER::PushOnApply ok 1 : " <<ok<<std::endl;
+
+  if ( ok )
+  {
+    ok = execute();
+    if (getModel()->getPublish()) this->createMeshInObjectBrowser();
+//     std::cout  << "SMESHGUI_MG_ADAPTDRIVER::PushOnApply ok 2 : " <<ok<<std::endl;
+    if ( ok )
+    {
+      QMessageBox::information( 0, QObject::tr(""),
+                                   QObject::tr("MG_ADAPT_DIAG_1") );
+    }
+    else
+    {
+      QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
+                                QObject::tr("MG_ADAPT_DIAG_2") );
+    }
+  }
+
+  return ok;
+}
+
+bool SMESHGUI_MG_ADAPTDRIVER::execute()
+{
+  int err;
+  //~std::string errStr;
+  char* errStr;
+  try
+  {
+    err = getModel()->compute();
+    errStr = getModel()->getErrMsg();
+    std::string msg = err == 0 ? " ok" : std::string("Not ok \n")+CORBA::string_dup(errStr) ;
+  }
+  catch (const std::exception& e)
+  {
+    std::cerr<<e.what();
+  }
+  return err == 0? true: false;
+}
+
+//=================================================================================
+// function : Init()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MG_ADAPTDRIVER::Init (bool ResetControls)
+{
+  myBusy = false;
+
+  if ( ResetControls )
+  {
+    myLineEditElements->clear();
+    myNbOkElements = 0;
+
+    buttonOk->setEnabled(false);
+    buttonApply->setEnabled(false);
+
+    //~myActor = 0;
+    myMesh = SMESH::SMESH_Mesh::_nil();
+
+    myIdSourceCheck->setChecked(true);
+
+    onConstructor( 0 );
+  }
+
+}
+
+//=======================================================================
+//function : onConstructor
+//purpose  : switch operation mode
+//=======================================================================
+
+void SMESHGUI_MG_ADAPTDRIVER::onConstructor( int withGeom )
+{
+
+  myGeomLabel        ->setVisible( withGeom );
+  myGeomNameEdit     ->setVisible( withGeom );
+  myReuseHypCheck    ->setVisible( withGeom );
+  myCopyElementsCheck->setVisible( withGeom );
+  myFilterBtn        ->setVisible( !withGeom );
+  myIdSourceCheck    ->setVisible( !withGeom );
+
+  if ( !withGeom )
+      myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
+
+}
+
+//~void SMESHGUI_MG_ADAPTDRIVER::onSelectIdSource( bool )
+//~{}
+
+//=================================================================================
+// function : enterEvent()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MG_ADAPTDRIVER::enterEvent (QEvent*)
+{
+
+  // if ( !ConstructorsBox->isEnabled() ) {
+  //   SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+  //   if ( aViewWindow && !mySelector ) {
+  //     mySelector = aViewWindow->GetSelector();
+  //   }
+  //   activateThisDialog();
+  // }
+
+}
+
+//=================================================================================
+// function : keyPressEvent()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MG_ADAPTDRIVER::keyPressEvent( QKeyEvent* e )
+{
+
+  QDialog::keyPressEvent( e );
+  if ( e->isAccepted() )
+      return;
+
+  if ( e->key() == Qt::Key_F1 )
+  {
+    e->accept();
+    PushOnHelp();
+  }
+
+}
+
+//=================================================================================
+// function : PushOnHelp()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MG_ADAPTDRIVER::PushOnHelp()
+{
+
+  QString aHelpFile = "adaptation.html#_mg_adapt_anchor";
+
+  SMESH::ShowHelpFile( aHelpFile );
+
+}
+
+//=======================================================================
+//function : getErrorMsg
+//purpose  : Return an error message and entries of invalid smesh object
+//=======================================================================
+
+QString SMESHGUI_MG_ADAPTDRIVER::getErrorMsg( SMESH::string_array_var theInvalidEntries,
+        QStringList & theEntriesToBrowse )
+{
+
+  if ( theInvalidEntries->length() == 0 )
+      return tr("OPERATION_FAILED");
+
+  // theInvalidEntries - SObject's that hold geometry objects whose
+  // counterparts are not found in the newGeometry, followed by SObject's
+  // holding mesh sub-objects that are invalid because they depend on a not found
+  // preceding sub-shape
+
+  QString msg = tr("SUBSHAPES_NOT_FOUND_MSG") + "\n";
+
+  QString objString;
+  for ( CORBA::ULong i = 0; i < theInvalidEntries->length(); ++i )
+  {
+    _PTR(SObject) so = SMESH::getStudy()->FindObjectID( theInvalidEntries[i].in() );
+
+    int objType = SMESHGUI_Selection::type( theInvalidEntries[i].in() );
+    if ( objType < 0 ) // geom object
+    {
+      objString += "\n";
+      if ( so )
+          objString += so->GetName().c_str();
+      else
+          objString += theInvalidEntries[i].in(); // it's something like "FACE #2"
+    }
+    else // smesh object
+    {
+      theEntriesToBrowse.push_back( theInvalidEntries[i].in() );
+
+      objString += "\n ";
+      switch ( objType ) {
+      case SMESH::MESH:
+          objString += tr("SMESH_MESH");
+          break;
+      case SMESH::HYPOTHESIS:
+          objString += tr("SMESH_HYPOTHESIS");
+          break;
+      case SMESH::ALGORITHM:
+          objString += tr("SMESH_ALGORITHM");
+          break;
+      case SMESH::SUBMESH_VERTEX:
+      case SMESH::SUBMESH_EDGE:
+      case SMESH::SUBMESH_FACE:
+      case SMESH::SUBMESH_SOLID:
+      case SMESH::SUBMESH_COMPOUND:
+      case SMESH::SUBMESH:
+          objString += tr("SMESH_SUBMESH");
+          break;
+      case SMESH::GROUP:
+          objString += tr("SMESH_GROUP");
+          break;
+      default:
+          ;
+      }
+      objString += " \"";
+      if ( so )
+          objString += so->GetName().c_str();
+      objString += "\" (";
+      objString += theInvalidEntries[i].in();
+      objString += ")";
+    }
+  }
+  if ( !objString.isEmpty() )
+      msg += objString;
+
+  return msg;
+}
+
+//=================================================================================
+// function : isValid
+// purpose  :
+//=================================================================================
+
+bool SMESHGUI_MG_ADAPTDRIVER::isValid()
+{
+  bool ok = true;
+  return ok;
+}
+
+bool SMESHGUI_MG_ADAPTDRIVER::createMeshInObjectBrowser()
+{
+  QString filename(getModel()->getMedFileOut());
+  QStringList errors;
+  QStringList anEntryList;
+  bool isEmpty = false;
+  bool ok = false;
+  SMESH::SMESH_Gen_var SMESH_Gen_ptr = SMESHGUI::GetSMESHGen();
+  if (!SMESH_Gen_ptr) {
+    std::cerr << "Could not retrieve SMESH_Gen_ptr" << std::endl;
+    throw SALOME_Exception(LOCALIZED("Could not retrieve SMESH::GetSMESHGen()"));
+  }
+  SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
+  aMeshes->length( 1 ); // one mesh only
+  SMESH::DriverMED_ReadStatus res;
+  aMeshes = SMESH_Gen_ptr->CreateMeshesFromMED( filename.toUtf8().constData(), res );
+  if ( res != SMESH::DRS_OK ) {
+    errors.append( QString( "%1 :\n\t%2" ).arg( filename ).arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
+  }
+  _PTR(Study) aStudy = SMESH::getStudy();
+  for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
+  {
+    _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
+    if ( aMeshSO )
+    {
+      _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+      _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
+      aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" ); // put REFINED mesh ico
+      anEntryList.append( aMeshSO->GetID().c_str() );
+    }
+    else
+    {
+      isEmpty = true;
+    }
+  }
+  // update Object browser
+  SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+  // browse to the published meshes
+  if( LightApp_Application* anApp =
+              dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+      anApp->browseObjects( anEntryList );
+
+  // show Error message box if there were errors
+  if ( errors.count() > 0 ) {
+    SUIT_MessageBox::critical( SMESHGUI::desktop(),
+                                QObject::tr( "SMESH_ERROR" ),
+                                QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
+  }
+
+  // show warning message box, if some imported mesh is empty
+  if ( isEmpty ) {
+    SUIT_MessageBox::warning( SMESHGUI::desktop(),
+                                QObject::tr( "SMESH_WRN_WARNING" ),
+                                QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
+  }
+  return true;
+}
+
+//================================================================
+// function : setIsApplyAndClose
+// Purpose  : Set value of the flag indicating that the dialog is
+//            accepted by Apply & Close button
+//================================================================
+void SMESHGUI_MG_ADAPTDRIVER::setIsApplyAndClose( const bool theFlag )
+{
+  myIsApplyAndClose = theFlag;
+}//================================================================
+// function : isApplyAndClose
+// Purpose  : Get value of the flag indicating that the dialog is
+//            accepted by Apply & Close button
+//================================================================
+bool SMESHGUI_MG_ADAPTDRIVER::isApplyAndClose() const
+{
+  return myIsApplyAndClose;
+}
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MG_ADAPTDRIVER::deactivateActiveDialog()
+{
+  if (ConstructorsBox->isEnabled())
+  {
+    ConstructorsBox->setEnabled(false);
+    GroupArguments->setEnabled(false);
+    GroupButtons->setEnabled(false);
+    mySMESHGUI->ResetState();
+    mySMESHGUI->SetActiveDialogBox(0);
+    if ( selMgr )
+        selMgr->removeFilter( myIdSourceFilter );
+  }
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MG_ADAPTDRIVER::activateThisDialog()
+{
+
+  /* Emit a signal to deactivate the active dialog */
+  // mySMESHGUI->EmitSignalDeactivateDialog();
+  // ConstructorsBox->setEnabled(true);
+  // GroupArguments->setEnabled(true);
+  // GroupButtons->setEnabled(true);
+
+  // mySMESHGUI->SetActiveDialogBox((QDialog*)this);
+
+  // onSelectIdSource( myIdSourceCheck->isChecked() );
+
+  // SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : setFilters()
+// purpose  : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_MG_ADAPTDRIVER::setFilters()
+{
+  if(myMesh->_is_nil())
+  {
+    SUIT_MessageBox::critical(this,
+                                tr("SMESH_ERROR"),
+                                tr("NO_MESH_SELECTED"));
+    return;
+  }
+  if ( !myFilterDlg )
+      myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
+
+  QList<int> types;
+  if ( myMesh->NbEdges()     ) types << SMESH::EDGE;
+  if ( myMesh->NbFaces()     ) types << SMESH::FACE;
+  if ( myMesh->NbVolumes()   ) types << SMESH::VOLUME;
+  if ( myMesh->NbBalls()     ) types << SMESH::BALL;
+  if ( myMesh->Nb0DElements()) types << SMESH::ELEM0D;
+  if ( types.count() > 1 )     types << SMESH::ALL;
+
+  myFilterDlg->Init( types );
+  myFilterDlg->SetSelection();
+  myFilterDlg->SetMesh( myMesh );
+  myFilterDlg->SetSourceWg( myLineEditElements );
+
+  myFilterDlg->show();
+}
+
+//=================================================================================
+// function : onOpenView()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MG_ADAPTDRIVER::onOpenView()
+{
+  if ( mySelector ) {
+    SMESH::SetPointRepresentation(false);
+  }
+  else {
+    mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
+    activateThisDialog();
+  }
+}
+
+//=================================================================================
+// function : onCloseView()
+// purpose  :
+//=================================================================================
+void SMESHGUI_MG_ADAPTDRIVER::onCloseView()
+{
+  deactivateActiveDialog();
+  mySelector = 0;
+}
diff --git a/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h b/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h
new file mode 100644 (file)
index 0000000..20e09dd
--- /dev/null
@@ -0,0 +1,210 @@
+// Copyright (C) 2011-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SMESH SMESHGUI : GUI for the adaptation in the SMESH component
+// File : SMESHGUI_MG_ADAPTDRIVER.h
+//
+#ifndef SMESHGUI_MG_ADAPTDRIVER_H
+#define SMESHGUI_MG_ADAPTDRIVER_H
+
+#include <set>
+// SMESH includes
+#include "SMESH_SMESHGUI.hxx"
+
+// Qt includes
+#include <QDialog>
+#include <QTreeWidget>
+#include<QItemDelegate>
+
+#include <QThread>
+
+#include "LightApp_DataOwner.h"
+#include "SalomeApp_Application.h"
+#include <SALOMEconfig.h>
+#include <SALOME_ListIO.hxx>
+#include "SalomeApp_Module.h"
+#include "SalomeApp_Study.h"
+#include <med.h>
+#include <QObject>
+// model
+#include "MG_ADAPTGUI.hxx"
+
+#include CORBA_SERVER_HEADER(MG_ADAPT)
+
+class SUIT_ViewWindow;
+class SUIT_Desktop;
+class SUIT_Study;
+class SUIT_ResourceMgr;
+
+class CAM_Module;
+
+class SALOMEDSClient_Study;
+class SALOMEDSClient_SObject;
+
+class SalomeApp_Study;
+class SalomeApp_Module;
+class LightApp_SelectionMgr;
+class SUIT_SelectionFilter;
+
+
+class QButtonGroup;
+class QLineEdit;
+class QGroupBox;
+class QRadioButton;
+class QLabel;
+class QCheckBox;
+class QGridLayout;
+class QTabWidget;
+class QDoubleSpinBox;
+class QSpinBox;
+class QTreeWidget;
+class QTreeWidgetItem;
+class QSpacerItem;
+class QHBoxLayout;
+class QItemDelegate;
+class QComboBox;
+class QObject;
+
+
+// IDL includes
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Gen)
+class SMESHGUI;
+class SMESHGUI_MgAdaptDlg;
+class SMESHGUI_IdValidator;
+class SMESHGUI_FilterDlg;
+class MgAdapt;
+class QHeaderView;
+class QFileDialog;
+
+
+int IObjectCount();
+const SALOME_ListIO& selectedIO();
+_PTR(Study) getStudy();
+Handle(SALOME_InteractiveObject) firstIObject();
+bool createAndPublishMed(QString fileName);
+bool createMgAdaptObject(MgAdapt* myMgAdapt = 0);
+
+
+class  SMESHGUI_MG_ADAPTDRIVER : public SMESHGUI_MgAdaptDlg
+{
+    Q_OBJECT;
+
+public :
+    SMESHGUI_MG_ADAPTDRIVER( SMESHGUI*, SMESH::MG_ADAPT_ptr, bool isCreation = true );
+    void setMyMesh(SMESH::SMESH_Mesh_var);
+    SMESH::SMESH_Mesh_var getMyMesh() ;
+
+private :
+
+    SMESHGUI*                     mySMESHGUI;              /* Current SMESHGUI object */
+    LightApp_SelectionMgr* selMgr ;
+    SUIT_ResourceMgr* resMgr;
+    SUIT_ResourceMgr* resourceMgr();
+    LightApp_SelectionMgr* selectionMgr();
+    SMESH::SMESH_Mesh_var myMesh ;
+
+
+
+    void                   Init( bool = true );
+    void                   enterEvent( QEvent* );           /* mouse enter the QWidget */
+    void                   keyPressEvent( QKeyEvent* );
+    QString                getErrorMsg( SMESH::string_array_var invalidEntries,
+                                        QStringList &           entriesToBrowse );
+
+    bool                   isValid();
+    bool                   createMeshInObjectBrowser();
+    void                   setIsApplyAndClose( const bool theFlag );
+    bool                   isApplyAndClose() const;
+    bool                   execute();
+    SMESHGUI_IdValidator*  myIdValidator;
+    int                    myNbOkElements;          /* to check when elements are defined */
+
+    SVTK_Selector*         mySelector;
+
+    bool                   myBusy;
+    GEOM::GEOM_Object_var  myNewGeometry;
+    //~SMESH_Actor*           myActor;  //
+    SUIT_SelectionFilter*  myIdSourceFilter;
+
+    SMESH::SMESH_IDSource_var mySelectedObject;
+
+    QTabWidget*           myTabWidget;
+    QButtonGroup*          GroupConstructors;
+
+    QGroupBox*             ConstructorsBox;
+    QGroupBox*             GroupArguments;
+    QGroupBox*             GroupButtons;
+
+    QPushButton*           buttonOk;
+    QPushButton*           buttonCancel;
+    QPushButton*           buttonApply;
+    QPushButton*           buttonHelp;
+
+    QLabel*                myTextLabelElements;
+    QLabel*                myGeomLabel;
+    QLineEdit*             myLineEditElements;
+    QLineEdit*             myMeshNameEdit;
+    QLineEdit*             myGeomNameEdit;
+    QCheckBox*             myIdSourceCheck;
+    QCheckBox*             myCopyGroupsCheck;
+    QCheckBox*             myReuseHypCheck;
+    QCheckBox*             myCopyElementsCheck;
+    QCheckBox*             myKeepIdsCheck;
+
+    QPushButton*           myFilterBtn;
+    SMESHGUI_FilterDlg*    myFilterDlg;
+
+    QString                myHelpFileName;
+
+    bool                   myIsApplyAndClose;
+
+    QString             inputMeshName;
+    QString           outputMeshName;
+private slots:
+    void selectionChanged();
+    void updateSelection();
+
+protected slots :
+
+private slots:
+
+    void exportMED(const char* );
+
+    virtual bool PushOnApply();
+    virtual void PushOnOK();
+    virtual void PushOnHelp();
+
+    void                   deactivateActiveDialog();
+    void                   activateThisDialog();
+    void                   onConstructor( int );
+    //~void                   onTextChange( const QString& );
+    //~void                   onSelectIdSource( bool );
+    void                   setFilters();
+    void                   onOpenView();
+    void                   onCloseView();
+
+
+};
+
+
+
+
+#endif // SMESHGUI_MG_ADAPTDRIVER_H
index 2782458aa29a4ba138e613e0f2f6e7dbbc9651e5..d63c592c0aeb96586e1b237f143406694239a4bd 100644 (file)
@@ -186,6 +186,8 @@ namespace SMESHOp {
     OpConvertMeshToQuadratic = 4513,   // MENU MODIFICATION - CONVERT TO/FROM QUADRATIC
     OpCreateBoundaryElements = 4514,   // MENU MODIFICATION - CREATE BOUNDARY ELEMENTS
     OpSplitBiQuadratic       = 4515,   // MENU MODIFICATION - SPLIT BI-QUADRATIC TO LINEAR
+    // Adaptation ---------------------//--------------------------------
+    OpMGAdapt                = 8020,   // MENU ADAPTATION - MG-ADAPT
     // Measurements -------------------//--------------------------------
     OpPropertiesLength       = 5000,   // MENU MEASUREMENTS - BASIC PROPERTIES - LENGTH
     OpPropertiesArea         = 5001,   // MENU MEASUREMENTS - BASIC PROPERTIES - AREA
index 932d60f07320568287b663ffda635aa94b9fc6e4..317a769cb4d70f8611b1ad10856535ddca63b81d 100644 (file)
             <source>ICON_CREATE_GEO_GROUP</source>
             <translation>mesh_groups_from_gemetry.png</translation>
         </message>
+        <message>
+            <source>ICON_MG_ADAPT</source>
+            <translation>adapt_mg_adapt.png</translation>
+        </message>
         <message>
             <source>ICON_CONV_TO_QUAD</source>
             <translation>mesh_conv_to_quad.png</translation>
         <message>
             <source>ICON_MEASURE_AREA</source>
             <translation>mesh_measure_area.png</translation>
-        </message>     
+        </message>
         <message>
             <source>ICON_MEASURE_VOLUME</source>
             <translation>mesh_measure_volume.png</translation>
index cdbcfc114831ebd04ae8867dfd6cc02bc9e6f11d..32fb70b88b8f712f5f78be845bc2c94a35b623c2 100644 (file)
         <source>MEN_CONSTRUCT_GROUP</source>
         <translation>Construct Group</translation>
     </message>
+    <message>
+        <source>MEN_MG_ADAPT</source>
+        <translation>Remesh with MG_Adapt</translation>
+    </message>
+    <message>
+        <source>Args</source>
+        <translation>Arguments</translation>
+    </message>
+    <message>
+        <source>MeshOut</source>
+        <translation>Mesh Out</translation>
+    </message>
+    <message>
+        <source>MeshIn</source>
+        <translation>Mesh In</translation>
+    </message>
+    <message>
+        <source>MEDFile</source>
+        <translation>MED file</translation>
+    </message>
+    <message>
+        <source>Browser</source>
+        <translation>Browser</translation>
+    </message>
+    <message>
+        <source>Publish_MG_ADAPT</source>
+        <translation>Publish</translation>
+    </message>
+    <message>
+        <source>SIZE_MAP_FIELD</source>
+        <translation>Size map field</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_FIELD_NAME</source>
+        <translation>Field Name</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_MED_FILE_1</source>
+        <translation>This MED file cannot be read.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_MED_FILE_2</source>
+        <translation>No mesh in this MED file.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_MED_FILE_3</source>
+        <translation>More than one mesh in this MED file.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_MED_FILE_4</source>
+        <translation>The mesh in this MED file cannot be read.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_MED_FILE_5</source>
+        <translation>No field in this MED file.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_ERROR</source>
+        <translation>Error</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_CH_ST</source>
+        <translation>Chosen time step</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_RANK</source>
+        <translation>Rank</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_TSTP</source>
+        <translation>Time step </translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_NO_T_ST</source>
+        <translation>No time step</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_L_ST</source>
+        <translation>Last time step</translation>
+    </message>
+    <message>
+        <source>MeshName</source>
+        <translation>Mesh name</translation>
+    </message>
+    <message>
+        <source>LOCAL_MG_ADAPT</source>
+        <translation>Local</translation>
+    </message>
+    <message>
+        <source>BACKGRND_MG_ADAPT</source>
+        <translation>Background</translation>
+    </message>
+    <message>
+        <source>CNST_MG_ADAPT</source>
+        <translation>Constant</translation>
+    </message>
+    <message>
+        <source>MED_FILE_BCKG</source>
+        <translation>MED file background size map</translation>
+    </message>
+    <message>
+        <source>VALUE_MG_ADAPT</source>
+        <translation>Value</translation>
+    </message>
+    <message>
+        <source>SIZE_MAP_DEF</source>
+        <translation>Size map definition</translation>
+    </message>
+    <message>
+        <source>ADVOP</source>
+        <translation>Advanced Options</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_DIAG_1</source>
+        <translation>Adaptation succeeded.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_DIAG_2</source>
+        <translation>Adaptation failed.</translation>
+    </message>
     <message>
         <source>MEN_CONV_TO_QUAD</source>
         <translation>Convert to/from quadratic</translation>
         <source>MEN_MODIFY</source>
         <translation>Modification</translation>
     </message>
+    <message>
+        <source>MEN_ADAPT</source>
+        <translation>Adaptation</translation>
+    </message>
     <message>
         <source>MEN_MEASURE</source>
         <translation>Measurements</translation>
@@ -1502,6 +1626,10 @@ Please enter correct values and try again</translation>
         <source>SMESH_AVAILABLE</source>
         <translation>Available</translation>
     </message>
+    <message>
+        <source>SMESH_NOT_AVAILABLE</source>
+        <translation>Not available</translation>
+    </message>
     <message>
         <source>SMESH_AVAILABLE_ALGORITHMS</source>
         <translation>Available algorithms</translation>
@@ -2897,6 +3025,82 @@ Check algorithm documentation for supported geometry</translation>
         <source>SMESH_MULTICOLOR</source>
         <translation>Multicolor</translation>
     </message>
+    <message>
+        <source>ADAPT_PREF_TAB_GENERAL</source>
+        <translation>Adaptation</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_NONE</source>
+        <translation>None</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT</source>
+        <translation>Adaptation with MG-Adapt</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT</source>
+        <translation>Write the OUT mesh</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT</source>
+        <translation>Publication of the OUT mesh</translation>
+    </message>
+    <message>
+        <source>OPTION_VALUE_COLUMN</source>
+        <translation>Option</translation>
+    </message>
+    <message>
+        <source>OPTION_NAME_COLUMN</source>
+        <translation>Value</translation>
+    </message>
+    <message>
+        <source>compute_ridges</source>
+        <translation>Compute ridges</translation>
+    </message>
+    <message>
+        <source>max_memory</source>
+        <translation>Maximum memory (Mb)</translation>
+    </message>
+    <message>
+        <source>Adaption</source>
+        <translation>adaptation</translation>
+    </message>
+    <message>
+        <source>components</source>
+        <translation>Components</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_SIZE_MAP</source>
+        <translation>Size map</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL</source>
+        <translation>Local</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND</source>
+        <translation>Background</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST</source>
+        <translation>Last</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_TIME_STEP</source>
+        <translation>Choosen time step</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_TIME_STEP_C</source>
+        <translation>Value</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_SELECT_FILE_0</source>
+        <translation>MG-ADAPT select file</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_ADVOP</source>
+        <translation>Advanced Options</translation>
+    </message>
     <message>
         <source>SMESH_VISU_PROBLEM</source>
         <translation>Mesh visualization failed</translation>
@@ -3112,6 +3316,10 @@ Use Display Entity menu command to show them.
         <source>STB_CONSTRUCT_GROUP</source>
         <translation>Construct Group</translation>
     </message>
+    <message>
+        <source>STB_MG_ADAPT</source>
+        <translation>Remesh with MG_Adapt</translation>
+    </message>
     <message>
         <source>STB_CONV_TO_QUAD</source>
         <translation>Convert to/from quadratic</translation>
@@ -3708,6 +3916,10 @@ Use Display Entity menu command to show them.
         <source>TB_CTRL3D</source>
         <translation>Volume Controls Toolbar</translation>
     </message>
+    <message>
+        <source>TB_ADAPTATION</source>
+        <translation>Adaptation Toolbar</translation>
+    </message>
     <message>
         <source>TB_MEASUREM</source>
         <translation>Measurements Toolbar</translation>
@@ -3812,6 +4024,10 @@ Use Display Entity menu command to show them.
         <source>TOP_CONSTRUCT_GROUP</source>
         <translation>Construct Group</translation>
     </message>
+    <message>
+        <source>TOP_MG_ADAPT</source>
+        <translation>Remesh with MG_Adapt</translation>
+    </message>
     <message>
         <source>TOP_CONV_TO_QUAD</source>
         <translation>Convert to/from quadratic</translation>
@@ -4443,8 +4659,8 @@ Use Display Entity menu command to show them.
     <message>
         <source>FULL_RECOMPUTE_QUESTION</source>
         <translation>
-The mesh has been edited since a last total re-compute 
-that may prevent successful computation. 
+The mesh has been edited since a last total re-compute
+that may prevent successful computation.
 Do you wish to re-compute the mesh totally to discard the modifications?
 </translation>
     </message>
@@ -6637,7 +6853,7 @@ Please specify them and try again</translation>
     <message>
         <source>GEOMETRY_OBJECT_IS_NOT_DEFINED_MESH</source>
         <translation>Geometry object is not defined.
-Do you want to create an empty mesh 
+Do you want to create an empty mesh
 without algorithms and hypotheses? </translation>
     </message>
     <message>
@@ -6712,7 +6928,7 @@ select mesh or sub-mesh and try again</translation>
     <message>
         <source>CONCURRENT_SUBMESH_APPEARS</source>
         <translation>
-The assigned algorithm has the same priority as one assigned to an 
+The assigned algorithm has the same priority as one assigned to an
 adjacent sub-mesh, hence it&apos;s undefined which algorithm to use for
 meshing boundary shared by two sub-meshes. Would you like to set
 the order of sub-mesh computation? </translation>
@@ -8322,7 +8538,7 @@ as they are of improper type:
     <message>
         <source>SUBSHAPES_NOT_FOUND_MSG</source>
         <translation>
-Some sub-shapes not found in the new geometry. They are listed 
+Some sub-shapes not found in the new geometry. They are listed
 below along with dependent mesh objects that are marked with
 red in the Object Browser.</translation>
     </message>
index 318c6294700d659cb8d02ed5c2f7b8b6a9fd3a64..b69f4650ab6a44b36979beaa6673c6d185ba452e 100644 (file)
         <source>MEN_CONSTRUCT_GROUP</source>
         <translation>Construire un groupe</translation>
     </message>
+    <message>
+        <source>MEN_MG_ADAPT</source>
+        <translation>Remaillage avec MG_Adapt</translation>
+    </message>
+    <message>
+        <source>Args</source>
+        <translation>Arguments</translation>
+    </message>
+    <message>
+        <source>MeshOut</source>
+        <translation>Maillage en sortie</translation>
+    </message>
+    <message>
+        <source>MeshIn</source>
+        <translation>Maillage en entrée</translation>
+    </message>
+    <message>
+        <source>MEDFile</source>
+        <translation>Fichier MED</translation>
+    </message>
+    <message>
+        <source>Browser</source>
+        <translation>Arbre d'études</translation>
+    </message>
+    <message>
+        <source>Publish_MG_ADAPT</source>
+        <translation>Publication</translation>
+    </message>
+    <message>
+        <source>SIZE_MAP_FIELD</source>
+        <translation>Champ de la carte de taille</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_FIELD_NAME</source>
+        <translation>Nom du champ</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_MED_FILE_1</source>
+        <translation>Ce fichier MED est illisible.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_MED_FILE_2</source>
+        <translation>Ce fichier MED ne contient aucun maillage.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_MED_FILE_3</source>
+        <translation>Ce fichier MED contient plus d'un maillage.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_MED_FILE_4</source>
+        <translation>Impossible de lire le maillage de ce fichier MED.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_MED_FILE_5</source>
+        <translation>Ce fichier MED ne contient aucun champ.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_ERROR</source>
+        <translation>Erreur</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_CH_ST</source>
+        <translation>Pas de temps choisi</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_RANK</source>
+        <translation>Numéro d'ordre</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_TSTP</source>
+        <translation>Pas de temps </translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_NO_T_ST</source>
+        <translation>Sans pas de temps</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_L_ST</source>
+        <translation>Dernier pas de temps</translation>
+    </message>
+    <message>
+        <source>MeshName</source>
+        <translation>Nom du maillage</translation>
+    </message>
+    <message>
+        <source>LOCAL_MG_ADAPT</source>
+        <translation>Locale</translation>
+    </message>
+    <message>
+        <source>BACKGRND_MG_ADAPT</source>
+        <translation>Arrière-plan</translation>
+    </message>
+    <message>
+        <source>CNST_MG_ADAPT</source>
+        <translation>Constante</translation>
+    </message>
+    <message>
+        <source>MED_FILE_BCKG</source>
+        <translation>Fichier MED de la carte en arrière-plan</translation>
+    </message>
+    <message>
+        <source>VALUE_MG_ADAPT</source>
+        <translation>Valeur</translation>
+    </message>
+    <message>
+        <source>SIZE_MAP_DEF</source>
+        <translation>Définition de la carte de taille</translation>
+    </message>
+    <message>
+        <source>ADVOP</source>
+        <translation>Options avancées</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_DIAG_1</source>
+        <translation>Adaptation réussie.</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_DIAG_2</source>
+        <translation>Echec de l'adaptation.</translation>
+    </message>
     <message>
         <source>MEN_CONV_TO_QUAD</source>
         <translation>Convertir vers/depuis quadratique</translation>
     </message>
     <message>
         <source>MEN_EDIT</source>
-        <translation>Edition</translation>
+        <translation>Editer</translation>
     </message>
     <message>
         <source>MEN_EDIT_GROUP</source>
         <source>MEN_MODIFY</source>
         <translation>Modification</translation>
     </message>
+    <message>
+        <source>MEN_ADAPT</source>
+        <translation>Adaptation</translation>
+    </message>
     <message>
         <source>MEN_MEASURE</source>
         <translation>Outils de mesure</translation>
@@ -2895,6 +3019,82 @@ Référez-vous à la documentation sur l'algorithme et la géométrie supportée
         <source>SMESH_MULTICOLOR</source>
         <translation>Multicouleur</translation>
     </message>
+    <message>
+        <source>ADAPT_PREF_TAB_GENERAL</source>
+        <translation>Adaptation</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_NONE</source>
+        <translation>Sans</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT</source>
+        <translation>Adaptation avec MG-Adapt</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT</source>
+        <translation>Ecriture du maillage de sortie</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT</source>
+        <translation>Publication du maillage de sortie</translation>
+    </message>
+    <message>
+        <source>OPTION_VALUE_COLUMN</source>
+        <translation>Option</translation>
+    </message>
+    <message>
+        <source>OPTION_NAME_COLUMN</source>
+        <translation>Valeur</translation>
+    </message>
+    <message>
+        <source>compute_ridges</source>
+        <translation>Calcul des crêtes</translation>
+    </message>
+    <message>
+        <source>max_memory</source>
+        <translation>Maximum mémoire (Mb)</translation>
+    </message>
+    <message>
+        <source>Adaption</source>
+        <translation>Adaptation</translation>
+    </message>
+    <message>
+        <source>components</source>
+        <translation>Composantes</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_SIZE_MAP</source>
+        <translation>Carte de tailles</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL</source>
+        <translation>Locale</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND</source>
+        <translation>Arrière-plan</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST</source>
+        <translation>Dernier</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_TIME_STEP</source>
+        <translation>Choix du pas de temps</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_TIME_STEP_C</source>
+        <translation>Valeur</translation>
+    </message>
+    <message>
+        <source>MG_ADAPT_SELECT_FILE_0</source>
+        <translation>MG-ADAPT selection fichier MED</translation>
+    </message>
+    <message>
+        <source>ADAPT_PREF_MG_ADAPT_ADVOP</source>
+        <translation>Options avancées</translation>
+    </message>
     <message>
         <source>SMESH_VISU_PROBLEM</source>
         <translation>Impossible de visualiser le maillage, probablement à cause d'un manque de mémoire</translation>
@@ -3111,6 +3311,10 @@ Utilisez le menu &quot;Visualiser une entité&quot; pour les afficher.
         <source>STB_CONSTRUCT_GROUP</source>
         <translation>Construire un groupe</translation>
     </message>
+    <message>
+        <source>STB_MG_ADAPT</source>
+        <translation>Remaillage avec MG_Adapt</translation>
+    </message>
     <message>
         <source>STB_CONV_TO_QUAD</source>
         <translation>Convertir vers/depuis quadratique</translation>
@@ -3707,6 +3911,10 @@ Utilisez le menu &quot;Visualiser une entité&quot; pour les afficher.
         <source>TB_CTRL3D</source>
         <translation>Barre des contrôles des volumes</translation>
     </message>
+    <message>
+        <source>TB_ADAPTATION</source>
+        <translation>Barre de l'adaptation</translation>
+    </message>
     <message>
         <source>TB_MEASUREM</source>
         <translation>Barre des mesures</translation>
@@ -3811,6 +4019,10 @@ Utilisez le menu &quot;Visualiser une entité&quot; pour les afficher.
         <source>TOP_CONSTRUCT_GROUP</source>
         <translation>Construire un groupe</translation>
     </message>
+    <message>
+        <source>TOP_MG_ADAPT</source>
+        <translation>Remaillage avec MG_Adapt</translation>
+    </message>
     <message>
         <source>TOP_CONV_TO_QUAD</source>
         <translation>Convertir vers/de quadratique</translation>
index cd73e1f09c84a9e76584884edcc32a45db545995..9b2d937ffa304b216248e76c408e8238d0847abe 100644 (file)
@@ -37,8 +37,11 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/DriverCGNS
   ${PROJECT_SOURCE_DIR}/src/SMESH
   ${PROJECT_SOURCE_DIR}/src/SMESHUtils
+  #~${PROJECT_SOURCE_DIR}/src/ADAPT
   ${PROJECT_BINARY_DIR}
   ${PROJECT_BINARY_DIR}/idl
+  #~${PROJECT_BINARY_DIR}/ADAPT
+  ${MEDCOUPLING_INCLUDE_DIRS}
 )
 
 # additional preprocessor / compiler flags
@@ -83,6 +86,7 @@ SET(_link_LIBRARIES
   SMESHDS
   SMESHControls
   MeshDriverMED
+  ${MEDCoupling_medloader}
 )
 
 # --- headers ---
@@ -111,6 +115,7 @@ SET(SMESHEngine_HEADERS
   SMESH_PreMeshInfo.hxx
   SMESH_MeshPartDS.hxx
   SMESH.hxx
+  MG_ADAPT_i.hxx
 )
 
 # --- sources ---
@@ -138,6 +143,7 @@ SET(SMESHEngine_SOURCES
   SMESH_NoteBook.cxx
   SMESH_Measurements_i.cxx
   SMESH_PreMeshInfo.cxx
+  MG_ADAPT_i.cxx
 )
 
 # --- rules ---
diff --git a/src/SMESH_I/MG_ADAPT_i.cxx b/src/SMESH_I/MG_ADAPT_i.cxx
new file mode 100644 (file)
index 0000000..fbe27fd
--- /dev/null
@@ -0,0 +1,536 @@
+// Copyright (C) 2011-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MG_ADAPT_i.hxx"
+
+#include "string.h"
+#include "SMESH_Gen_i.hxx"
+#include <SMESH_Gen.hxx>
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOMEDS)
+
+
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::CreateMG_ADAPT
+ *
+ *  Create measurement instance
+ */
+//=============================================================================
+
+
+using namespace SMESH;
+void MG_ADAPT_i::copyHypothesisDataToImpl(const SMESH::MgAdaptHypothesisData& from, ::MG_ADAPT::MgAdaptHypothesisData* to) const
+{
+  to->myFileInDir = from.myFileInDir;
+  to->myMeshFileIn = from.myMeshFileIn;
+  to->myMeshFileBackground = from.myMeshFileBackground;
+  to->myOutMeshName = from.myOutMeshName;
+  to->myMeshFileOut = from.myMeshFileOut;
+  to->myFileOutDir = from.myFileOutDir;
+  to->myFileSizeMapDir = from.myFileSizeMapDir;
+  to->myFieldName = from.myFieldName;
+  to->fromMedFile = from.fromMedFile;
+  to->myPublish = from.myPublish;
+  to->myMeshOutMed = from.myMeshOutMed;
+  to->myUseLocalMap = from.myUseLocalMap;
+  to->myUseBackgroundMap = from.myUseBackgroundMap;
+  to->myUseConstantValue = from.myUseConstantValue;
+  to->myConstantValue = from.myConstantValue;
+  to->myTimeStep = from.myTimeStep;
+  to->myRank = from.myRank;
+  to->myUseNoTimeStep = from.myUseNoTimeStep;
+  to->myUseLastTimeStep = from.myUseLastTimeStep;
+  to->myUseChosenTimeStep = from.myUseChosenTimeStep;
+  to->myWorkingDir = from.myWorkingDir;
+  to->myLogFile = from.myLogFile;
+  to->myPrintLogInFile = from.myPrintLogInFile;
+  to->myKeepFiles = from.myKeepFiles;
+  to->myRemoveLogOnSuccess = from.myRemoveLogOnSuccess;
+  to->myVerboseLevel = from.myVerboseLevel;
+}
+void MG_ADAPT_i::copyHypothesisDataFromImpl(const ::MG_ADAPT::MgAdaptHypothesisData* from, SMESH::MgAdaptHypothesisData* to) const
+{
+  to->myFileInDir = CORBA::string_dup(from->myFileInDir.c_str());
+  to->myMeshFileIn = CORBA::string_dup(from->myMeshFileIn.c_str());
+  to->myMeshFileBackground = CORBA::string_dup(from->myMeshFileBackground.c_str());
+  to->myOutMeshName = CORBA::string_dup(from->myOutMeshName.c_str());
+  to->myMeshFileOut = CORBA::string_dup(from->myMeshFileOut.c_str());
+  to->myFileOutDir = CORBA::string_dup(from->myFileOutDir.c_str());
+  to->myFileSizeMapDir = CORBA::string_dup(from->myFileSizeMapDir.c_str());
+  to->myFieldName = CORBA::string_dup(from->myFieldName.c_str());
+  to->fromMedFile = from->fromMedFile;
+  to->myPublish = from->myPublish;
+  to->myMeshOutMed = from->myMeshOutMed;
+  to->myUseLocalMap = from->myUseLocalMap;
+  to->myUseBackgroundMap = from->myUseBackgroundMap;
+  to->myUseConstantValue = from->myUseConstantValue;
+  to->myConstantValue = from->myConstantValue;
+  to->myTimeStep = from->myTimeStep;
+  to->myRank = from->myRank;
+  to->myUseNoTimeStep = from->myUseNoTimeStep;
+  to->myUseLastTimeStep = from->myUseLastTimeStep;
+  to->myUseChosenTimeStep = from->myUseChosenTimeStep;
+  to->myWorkingDir = CORBA::string_dup(from->myWorkingDir.c_str());
+  to->myLogFile = CORBA::string_dup(from->myLogFile.c_str());
+  to->myPrintLogInFile = from->myPrintLogInFile;
+  to->myKeepFiles = from->myKeepFiles;
+  to->myRemoveLogOnSuccess = from->myRemoveLogOnSuccess;
+  to->myVerboseLevel = from->myVerboseLevel;
+}
+SMESH::MG_ADAPT_ptr SMESH_Gen_i::CreateMG_ADAPT()
+{
+  SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i();
+  SMESH::MG_ADAPT_var anObj = aMGadapt->_this();
+  return anObj._retn();
+}
+SMESH::MG_ADAPT_ptr SMESH_Gen_i::CreateAdaptationHypothesis()
+{
+  SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i();
+  SMESH::MG_ADAPT_var anObj = aMGadapt->_this();
+  return anObj._retn();
+}
+SMESH::MG_ADAPT_OBJECT_ptr SMESH_Gen_i::Adaptation( const char* adaptationType)
+{
+
+  if (!strcmp(adaptationType, "MG_Adapt"))
+  {
+    SMESH::MG_ADAPT_OBJECT_i* mg_adapt_object = new SMESH::MG_ADAPT_OBJECT_i();
+    SMESH::MG_ADAPT_OBJECT_var anObj = mg_adapt_object->_this();
+    return anObj._retn();
+  }
+
+}
+//~SMESH::MG_ADAPT_ptr MG_ADAPT_i::CreateMG_ADAPT()
+//~{
+
+  //~SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
+  //~SMESH::MG_ADAPT_i* aMGadapt = new SMESH::MG_ADAPT_i(smeshGen_i->GetPOA());
+  //~SMESH::MG_ADAPT_var anObj = aMGadapt->_this();
+  //~return anObj._retn();
+//~}
+//=============================================================================
+/*!
+ *  standard constructor
+ */
+//=============================================================================
+MG_ADAPT_i::MG_ADAPT_i(): SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
+{
+  myMgAdapt = new ::MG_ADAPT::MgAdapt();
+}
+//~MG_ADAPT_i::MG_ADAPT_i(PortableServer::POA_var myPoa): SALOME::GenericObj_i( myPoa )
+//~{
+  //~myMgAdapt = new ::MG_ADAPT::MgAdapt();
+//~}
+
+//=============================================================================
+/*!
+ *  standard constructor
+ */
+//=============================================================================
+//~MG_ADAPT_i::MG_ADAPT_i( CORBA::ORB_ptr orb,
+                            //~ADAPT::ADAPT_Gen_var engine )
+//~{
+
+  //~_gen_i = engine;
+  //~_orb = orb;
+  //~myMgAdapt = new MgAdapt();
+//~}
+
+//=============================================================================
+/*!
+ *  standard destructor
+ */
+//=============================================================================
+MG_ADAPT_i::~MG_ADAPT_i()
+{
+}
+void MG_ADAPT_i::setData( SMESH::MgAdaptHypothesisData& data)
+{
+  ::MG_ADAPT::MgAdaptHypothesisData* baseData = new ::MG_ADAPT::MgAdaptHypothesisData();
+  copyHypothesisDataToImpl(data, baseData);
+  myMgAdapt->setData(baseData);
+  delete baseData;
+}
+void MG_ADAPT_i::setMedFileIn(const char* str)
+{
+  myMgAdapt->setMedFileIn(str);
+}
+char* MG_ADAPT_i::getMedFileIn()
+{
+  return CORBA::string_dup(myMgAdapt->getMedFileIn().c_str());
+}
+void MG_ADAPT_i::setMedFileOut(const char* str)
+{
+  myMgAdapt->setMedFileOut(str);
+}
+char* MG_ADAPT_i::getMedFileOut()
+{
+  return CORBA::string_dup(myMgAdapt->getMedFileOut().c_str());
+}
+void MG_ADAPT_i::setMeshName(const char* str)
+{
+  myMgAdapt->setMeshName(str);
+}
+char* MG_ADAPT_i::getMeshName()
+{
+  return CORBA::string_dup(myMgAdapt->getMeshName().c_str());
+}
+void MG_ADAPT_i::setMeshNameOut(const char* str)
+{
+  myMgAdapt->setMeshNameOut(str);
+}
+char* MG_ADAPT_i::getMeshNameOut()
+{
+  return CORBA::string_dup(myMgAdapt->getMeshNameOut().c_str());
+}
+void MG_ADAPT_i::setMeshOutMed(bool mybool)
+{
+  myMgAdapt->setMeshOutMed(mybool);
+}
+bool MG_ADAPT_i::getMeshOutMed()
+{
+  return myMgAdapt->getMeshOutMed();
+}
+void MG_ADAPT_i::setPublish(bool mybool)
+{
+  myMgAdapt->setPublish(mybool);
+}
+bool MG_ADAPT_i::getPublish()
+{
+  return myMgAdapt->getPublish();
+}
+void MG_ADAPT_i::setSizeMapFieldName(const char* str)
+{
+  myMgAdapt->setFieldName(str);
+}
+char* MG_ADAPT_i::getSizeMapFieldName()
+{
+  return CORBA::string_dup(myMgAdapt->getFieldName().c_str());
+}
+void MG_ADAPT_i::setTimeStep(CORBA::Long t)
+{
+  myMgAdapt->setTimeStep(t);
+}
+CORBA::Long MG_ADAPT_i::getTimeStep()
+{
+  return myMgAdapt->getTimeStep();
+}
+void MG_ADAPT_i::setTimeStepRank(CORBA::Long t, CORBA::Long r)
+{
+  myMgAdapt->setChosenTimeStepRank();
+  myMgAdapt->setRankTimeStep(t, r);
+}
+CORBA::Long MG_ADAPT_i::getRank()
+{
+  return myMgAdapt->getRank();
+}
+void MG_ADAPT_i::setTimeStepRankLast()
+{
+  myMgAdapt->setTimeStepRankLast();
+}
+void MG_ADAPT_i::setNoTimeStep()
+{
+  myMgAdapt->setNoTimeStep();
+}
+void MG_ADAPT_i::setLogFile(const char* str)
+{
+  myMgAdapt->setLogFile(str);
+}
+char* MG_ADAPT_i::getLogFile()
+{
+  return CORBA::string_dup(myMgAdapt->getLogFile().c_str());
+}
+
+void MG_ADAPT_i::setVerbosityLevel(CORBA::Long v)
+{
+  myMgAdapt->setVerbosityLevel(v);
+}
+CORBA::Long MG_ADAPT_i::getVerbosityLevel()
+{
+  return myMgAdapt->getVerbosityLevel();
+}
+void MG_ADAPT_i::setRemoveOnSuccess(bool mybool)
+{
+  myMgAdapt->setRemoveOnSuccess(mybool);
+}
+bool MG_ADAPT_i::getRemoveOnSuccess()
+{
+  myMgAdapt->getRemoveOnSuccess();
+}
+SMESH::MgAdaptHypothesisData* MG_ADAPT_i::getData()
+{
+  SMESH::MgAdaptHypothesisData* result = new SMESH::MgAdaptHypothesisData();
+  ::MG_ADAPT::MgAdaptHypothesisData* from =  myMgAdapt->getData();
+  copyHypothesisDataFromImpl(from, result);
+  return result;
+}
+void MG_ADAPT_i::setUseLocalMap(bool mybool)
+{
+  myMgAdapt->setUseLocalMap(mybool);
+}
+bool MG_ADAPT_i::getUseLocalMap()
+{
+  return myMgAdapt->getUseLocalMap();
+}
+void MG_ADAPT_i::setUseBackgroundMap(bool mybool)
+{
+  myMgAdapt->setUseBackgroundMap(mybool);
+}
+bool MG_ADAPT_i::getUseBackgroundMap()
+{
+  return myMgAdapt->getUseBackgroundMap();
+}
+void MG_ADAPT_i::setUseConstantValue(bool mybool)
+{
+  myMgAdapt->setUseConstantValue(mybool);
+}
+bool MG_ADAPT_i::getUseConstantValue()
+{
+  return myMgAdapt->getUseConstantValue();
+}
+void MG_ADAPT_i::setConstantSize(double value)
+{
+  myMgAdapt->setConstantValue(value);
+}
+double MG_ADAPT_i::getConstantSize()
+{
+  return myMgAdapt->getConstantValue();
+}
+void MG_ADAPT_i::setSizeMapFile(const char* str)
+{
+  myMgAdapt->setSizeMapFile(str);
+}
+char* MG_ADAPT_i::getSizeMapFile()
+{
+  return CORBA::string_dup(myMgAdapt->getSizeMapFile().c_str());
+}
+void MG_ADAPT_i::setFromMedFile(bool mybool)
+{
+  myMgAdapt->setFromMedFile(mybool);
+}
+bool MG_ADAPT_i::isFromMedFile()
+{
+  return myMgAdapt->isFromMedFile();
+}
+
+void MG_ADAPT_i::setKeepWorkingFiles(bool mybool)
+{
+  myMgAdapt->setKeepWorkingFiles(mybool);
+}
+bool MG_ADAPT_i::getKeepWorkingFiles()
+{
+  return myMgAdapt->getKeepWorkingFiles();
+}
+
+//~void MG_ADAPT_i::setPrCORBA::LongLogInFile(bool);
+//~bool MG_ADAPT_i::getPrCORBA::LongLogInFile();
+
+void MG_ADAPT_i::setSizeMapType(const char* type)
+{
+  setUseLocalMap(false);
+  setUseBackgroundMap(false);
+  setUseConstantValue(false);
+
+  if (!strcmp("Local", type))
+    setUseLocalMap(true);
+  else if (!strcmp("Background", type))
+    setUseBackgroundMap(true);
+  else
+    setUseConstantValue(true);
+}
+void MG_ADAPT_i::setWorkingDir(const char* dir)
+{
+  myMgAdapt->setWorkingDir(dir);
+}
+char* MG_ADAPT_i::getWorkingDir()
+{
+  return CORBA::string_dup(myMgAdapt->getWorkingDir().c_str());
+}
+bool MG_ADAPT_i::setAll()
+{
+  return myMgAdapt->setAll();
+}
+char* MG_ADAPT_i::getCommandToRun()
+{
+  return CORBA::string_dup(myMgAdapt->getCommandToRun().c_str());
+}
+
+//~CORBA::Long MG_ADAPT_i::compute(::CORBA::String_out errStr)
+//~{
+  //~std::string err("");
+  //~CORBA::Long ret = myMgAdapt->compute(err);
+  //~errStr =  err.c_str();
+  //~return ret;
+//~}
+CORBA::Long MG_ADAPT_i::compute()
+{
+  errStr = "";
+  CORBA::Long ret;
+  try
+  {
+    ret = myMgAdapt->compute(errStr);
+  }
+  catch (const std::exception& e)
+  {
+    std::cerr<<e.what();
+    ret = -1;
+  }
+  if(ret!=-1 && myMgAdapt->getPublish())
+  {
+    SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
+    SMESH::DriverMED_ReadStatus theStatus;
+    smeshGen_i->CreateMeshesFromMED(myMgAdapt->getMedFileOut().c_str(), theStatus);
+  }
+  //~errStr =  err.c_str();
+  return ret;
+}
+char* MG_ADAPT_i::getErrMsg()
+{
+  return CORBA::string_dup(errStr.c_str());
+}
+char* MG_ADAPT_i::getFileName()
+{
+  return CORBA::string_dup(myMgAdapt->getFileName().c_str());
+}
+char* MG_ADAPT_i::getExeName()
+{
+  return CORBA::string_dup(myMgAdapt->getExeName().c_str());
+}
+void MG_ADAPT_i::copyMgAdaptHypothesisData( const SMESH::MgAdaptHypothesisData& data)
+{
+  ::MG_ADAPT::MgAdaptHypothesisData* baseData = new ::MG_ADAPT::MgAdaptHypothesisData();
+  copyHypothesisDataToImpl(data, baseData);
+  myMgAdapt->copyMgAdaptHypothesisData(baseData);
+  delete baseData;
+}
+
+//~void MG_ADAPT_i::checkDirPath(char*& str)
+//~{
+  //~myMgAdapt->checkDirPath(str);
+//~}
+
+bool MG_ADAPT_i::hasOptionDefined( const char* optionName )
+{
+  return myMgAdapt->hasOptionDefined(optionName);
+}
+void MG_ADAPT_i::setOptionValue(const char* optionName,
+          const char* optionValue) throw (std::invalid_argument)
+{
+  myMgAdapt->setOptionValue(optionName, optionValue);
+}
+
+char* MG_ADAPT_i::getOptionValue(const char* optionName,
+               bool&              isDefault)  throw (std::invalid_argument)
+{
+  return CORBA::string_dup(myMgAdapt->getOptionValue(optionName, &isDefault).c_str());
+}
+str_array* MG_ADAPT_i::getCustomOptionValuesStrVec()
+{
+  SMESH::str_array_var result = new SMESH::str_array();
+  std::vector <std::string> vals = myMgAdapt->getCustomOptionValuesStrVec();
+  result->length(vals.size());
+  for (int i = 0; i<vals.size(); i++) result[i] = CORBA::string_dup(vals[i].c_str());
+  return result._retn();
+}
+str_array*  MG_ADAPT_i::getOptionValuesStrVec()
+{
+
+  SMESH::str_array_var result = new SMESH::str_array();
+  std::vector <std::string> vals = myMgAdapt->getOptionValuesStrVec();
+  result->length(vals.size());
+  for (int i = 0; i<vals.size(); i++) result[i] = CORBA::string_dup(vals[i].c_str());
+  return result._retn();
+}
+
+void MG_ADAPT_i::setPrintLogInFile(bool mybool)
+{
+  myMgAdapt->setPrintLogInFile(mybool);
+}
+bool MG_ADAPT_i::getPrintLogInFile()
+{
+  return myMgAdapt->getPrintLogInFile();
+}
+//~TOptionValues        MG_ADAPT_i::getOptionValues()       const;
+//~const TOptionValues& MG_ADAPT_i::getCustomOptionValues() const ;
+
+MG_ADAPT_OBJECT_i::MG_ADAPT_OBJECT_i(): SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
+{
+  medFileIn="";
+  medFileOut="";
+  medFileBackground="";
+  publish = false;
+  //~myMesh = CORBA::nil;
+}
+
+void MG_ADAPT_OBJECT_i::setMeshIn(SMESH::SMESH_Mesh_ptr theMesh )
+{
+  myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
+}
+void MG_ADAPT_OBJECT_i::setMEDFileIn(const char* f)
+{
+  medFileIn =  f;
+}
+void MG_ADAPT_OBJECT_i::setMEDFileOut(const char* f)
+{
+  medFileOut = f;
+}
+void MG_ADAPT_OBJECT_i::setMEDFileBackground(const char* f)
+{
+  medFileBackground = f;
+}
+void MG_ADAPT_OBJECT_i::AddHypothesis(SMESH::MG_ADAPT_ptr mg)
+{
+
+  mg->setMedFileIn(medFileIn.c_str());
+  mg->setMedFileOut(medFileOut.c_str());
+  mg->setSizeMapFile(medFileBackground.c_str());
+  hypothesis = SMESH::MG_ADAPT::_duplicate(mg);
+}
+CORBA::Long MG_ADAPT_OBJECT_i::Compute(bool publish)
+{
+  if(!checkMeshFileIn()){
+    std::cerr<< "\n Error : Please check the MED file input or mesh input. \n";
+    return -1;
+  }
+  hypothesis->setPublish(publish);
+  return hypothesis->compute();
+}
+
+bool MG_ADAPT_OBJECT_i::checkMeshFileIn()
+{
+  bool ret = false; // 1 ok , 0 nook
+  if(!::MG_ADAPT::MgAdapt::isFileExist(medFileIn))
+  {
+    if(!myMesh->_is_nil())
+    {
+      bool toOverwrite  = true;
+      bool toFindOutDim = true;
+      medFileIn = hypothesis->getFileName();
+      medFileIn+= ".med";
+      myMesh->ExportMED(medFileIn.c_str(), false, -1, toOverwrite, toFindOutDim);
+      hypothesis->setMedFileIn(medFileIn.c_str());
+      ret = true;
+    }
+  }
+  else
+    ret = true;
+
+  return ret;
+}
diff --git a/src/SMESH_I/MG_ADAPT_i.hxx b/src/SMESH_I/MG_ADAPT_i.hxx
new file mode 100644 (file)
index 0000000..b259531
--- /dev/null
@@ -0,0 +1,163 @@
+#ifndef MG_ADAPT_I_HXX
+#define MG_ADAPT_I_HXX
+
+#include "MG_ADAPT.hxx"
+#include "SMESH.hxx"
+#include <SALOMEconfig.h>
+//~#include CORBA_SERVER_HEADER(ADAPT_Gen)
+#include CORBA_SERVER_HEADER(MG_ADAPT)
+
+#include "SALOME_GenericObj_i.hh"
+#include "SALOME_Component_i.hxx"
+#include "SALOME_NamingService.hxx"
+#include "Utils_CorbaException.hxx"
+#include <vector>
+#include <algorithm>
+#include <iterator>
+#include <string>
+
+//~struct MgAdaptHypothesisData;
+//~static void copyHypothesisDataToImpl(SMESH::MgAdaptHypothesisData& from, MG_ADAPT::MgAdaptHypothesisData* to);
+//~static void copyHypothesisDataFromImpl(MG_ADAPT::MgAdaptHypothesisData* from, SMESH::MgAdaptHypothesisData& to);
+//~class MgAdapt;
+namespace SMESH
+{
+
+class SMESH_I_EXPORT MG_ADAPT_i :
+    public virtual SALOME::GenericObj_i,
+    public virtual POA_SMESH::MG_ADAPT
+{
+public:
+  //~MG_ADAPT_i( CORBA::ORB_ptr orb, ADAPT::ADAPT_Gen_var gen_i );
+  //~static SMESH::MG_ADAPT_ptr CreateMG_ADAPT();
+  //~MG_ADAPT_i(PortableServer::POA_var poa);
+  MG_ADAPT_i();
+  virtual ~MG_ADAPT_i();
+  //~void setData( SMESH::MgAdaptHypothesisData* data);
+  void setData( SMESH::MgAdaptHypothesisData& data);
+
+  void setMedFileIn(const char* str);
+  char* getMedFileIn();
+
+  void setMedFileOut(const char* str);
+  char* getMedFileOut();
+
+  void setMeshName(const char* str);
+  char* getMeshName();
+
+  void setMeshNameOut(const char* str);
+  char* getMeshNameOut();
+
+  void setMeshOutMed(bool mybool);
+  bool getMeshOutMed();
+
+  void setPublish(bool mybool);
+  bool getPublish();
+
+  void setSizeMapFieldName(const char* str);
+  char* getSizeMapFieldName();
+
+  void setTimeStep(CORBA::Long t);
+  CORBA::Long getTimeStep() ;
+
+  void setTimeStepRank(CORBA::Long t, CORBA::Long r );
+  CORBA::Long getRank();
+
+  void setTimeStepRankLast();
+  void setNoTimeStep();
+
+  void setLogFile(const char* str);
+  char* getLogFile();
+
+  void setVerbosityLevel(CORBA::Long v);
+  CORBA::Long getVerbosityLevel();
+
+  void setRemoveOnSuccess(bool mybool);
+  bool getRemoveOnSuccess();
+
+  SMESH::MgAdaptHypothesisData* getData() ;
+  void setSizeMapType(const char* type);
+  void setUseLocalMap(bool mybool);
+  bool getUseLocalMap();
+
+  void setUseBackgroundMap(bool mybool);
+  bool getUseBackgroundMap();
+
+  void setUseConstantValue(bool mybool);
+  bool getUseConstantValue();
+
+  void setConstantSize(double value);
+  double getConstantSize();
+
+  void setSizeMapFile(const char* str);
+  char* getSizeMapFile();
+
+  void setFromMedFile(bool mybool);
+  bool isFromMedFile();
+
+  void setKeepWorkingFiles(bool mybool);
+  bool getKeepWorkingFiles();
+
+  //~void setPrCORBA::LongLogInFile(bool);
+  //~bool getPrCORBA::LongLogInFile();
+
+  void setWorkingDir(const char* str);
+  char* getWorkingDir() ;
+
+  void setPrintLogInFile(bool mybool);
+  bool getPrintLogInFile();
+
+  bool setAll();
+  char* getCommandToRun() ;
+  //~CORBA::Long compute(::CORBA::String_out errStr);
+  CORBA::Long compute();
+  char* getFileName();
+  char* getExeName();
+  void copyMgAdaptHypothesisData( const SMESH::MgAdaptHypothesisData& data ) ;
+  //~void copyMgAdaptHypothesisData( const SMESH::MgAdaptHypothesisData& data ) {
+          //~copyMgAdaptHypothesisData(&data);
+  //~}
+
+  //~void checkDirPath(char*& str);
+
+  bool hasOptionDefined( const char* optionName ) ;
+  void setOptionValue(const char* optionName,
+                                          const char* optionValue) throw (std::invalid_argument);
+  char* getOptionValue(const char* optionName,
+                      bool&              isDefault)  throw (std::invalid_argument);
+  str_array* getCustomOptionValuesStrVec() ;
+  str_array* getOptionValuesStrVec() ;
+  void copyHypothesisDataFromImpl(const ::MG_ADAPT::MgAdaptHypothesisData* from, SMESH::MgAdaptHypothesisData* to) const;
+  void copyHypothesisDataToImpl(const SMESH::MgAdaptHypothesisData& from, ::MG_ADAPT::MgAdaptHypothesisData* to) const;
+  //~TOptionValues        getOptionValues()       const;
+  //~const TOptionValues& getCustomOptionValues() const ;
+  char* getErrMsg();
+private:
+  ::MG_ADAPT::MgAdapt*          myMgAdapt;
+  std::string errStr;
+  //~CORBA::ORB_ptr         _orb;
+  //~ADAPT::ADAPT_Gen_var _gen_i;
+
+};
+
+class SMESH_I_EXPORT MG_ADAPT_OBJECT_i:
+  public virtual SALOME::GenericObj_i,
+  public virtual POA_SMESH::MG_ADAPT_OBJECT {
+public :
+  MG_ADAPT_OBJECT_i();
+  void setMeshIn( SMESH::SMESH_Mesh_ptr theMesh );
+  void setMEDFileIn(const char* f);
+  void setMEDFileOut(const char* f);
+  void setMEDFileBackground(const char* f);
+  void AddHypothesis(SMESH::MG_ADAPT_ptr);
+      CORBA::Long Compute(bool Publish);
+private:
+std::string medFileIn, medFileOut, medFileBackground;
+bool checkMeshFileIn();
+bool publish;
+SMESH::SMESH_Mesh_ptr myMesh;
+SMESH::MG_ADAPT_ptr hypothesis;
+};
+
+}
+#endif // MG_ADAPT_I_HXX
index c78d57bfd9b8f99c9e9b05bfcf5a06851e78fc4e..817abd07c790003944d31648f1abe2a9d151e496 100644 (file)
@@ -477,6 +477,10 @@ public:
 
   int CountInPyDump(const TCollection_AsciiString& text);
 
+  SMESH::MG_ADAPT_ptr CreateMG_ADAPT();
+  SMESH::MG_ADAPT_ptr CreateAdaptationHypothesis();
+  SMESH::MG_ADAPT_OBJECT_ptr Adaptation( const char* adaptationType);
+
   // *****************************************
   // Internal methods
   // *****************************************