Salome HOME
Update copyrights 2014.
[plugins/blsurfplugin.git] / src / GUI / BLSURFPluginGUI_HypothesisCreator.cxx
index 3c6fd0384fffecc81d1b2c6793d2e4a36ac45212..886b17408f1021b9143532267dbf17708038df9a 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,7 +25,7 @@
 // ---
 //
 #include "BLSURFPluginGUI_HypothesisCreator.h"
-// #include <DlgBlSurfHyp_Enforced.h>
+#include "BLSURFPluginGUI_Dlg.h"
 
 #include "GeometryGUI.h"
 
 #include <SUIT_ResourceMgr.h>
 #include <SalomeApp_Tools.h>
 
-#include <QObject>
+#include <QApplication>
+#include <QCheckBox>
 #include <QComboBox>
-#include <QLabel>
-#include <QGroupBox>
 #include <QFrame>
-#include <QVBoxLayout>
 #include <QHBoxLayout>
+#include <QHeaderView>
 #include <QGridLayout>
+#include <QGroupBox>
+#include <QLabel>
 #include <QLineEdit>
-#include <QCheckBox>
-#include <QTabWidget>
-#include <QSpinBox>
-#include <QPushButton>
 #include <QMenu>
-#include <QTableWidget>
-#include <QHeaderView>
-#include <QApplication>
+#include <QObject>
+#include <QPushButton>
 #include <QRadioButton>
-#include <QFileDialog>
+#include <QSpinBox>
+#include <QTableWidget>
+#include <QTabWidget>
+#include <QVBoxLayout>
+#include <QSplitter>
 
 #include <QStandardItemModel>
 #include <QStandardItem>
 #include <stdexcept>
 #include <algorithm>
 
-#define WITH_SIZE_BOUNDARIES
-
-enum Topology {
-    FromCAD,
-    Process,
-    Process2,
-    PreCAD
-  } ;
-
-enum PhysicalMesh
-  {
-    DefaultSize = 0,
-    PhysicalUserDefined,
-    SizeMap
-  };
-
-enum GeometricMesh
-  {
-    DefaultGeom = 0,
-    UserDefined
-  };
 
 enum {
   STD_TAB = 0,
   ADV_TAB,
   SMP_TAB,
   ENF_TAB,
-  OPTION_ID_COLUMN = 0,
-  OPTION_TYPE_COLUMN,
-  OPTION_NAME_COLUMN,
-  OPTION_VALUE_COLUMN,
-  NB_COLUMNS,
+  PERIODICITY_TAB,
   SMP_NAME_COLUMN =0,
   SMP_SIZEMAP_COLUMN,
   SMP_ENTRY_COLUMN,
@@ -126,7 +101,36 @@ enum {
   ENF_VER_Z_COLUMN,
   ENF_VER_ENTRY_COLUMN,
   ENF_VER_GROUP_COLUMN,
-  ENF_VER_NB_COLUMNS
+  ENF_VER_NB_COLUMNS,
+// Periodicity
+  PERIODICITY_OBJ_SOURCE_COLUMN = 0,
+  PERIODICITY_OBJ_TARGET_COLUMN,
+  PERIODICITY_P1_SOURCE_COLUMN,
+  PERIODICITY_P2_SOURCE_COLUMN,
+  PERIODICITY_P3_SOURCE_COLUMN,
+  PERIODICITY_P1_TARGET_COLUMN,
+  PERIODICITY_P2_TARGET_COLUMN,
+  PERIODICITY_P3_TARGET_COLUMN,
+  PERIODICITY_SHAPE_TYPE,
+
+//  PERIODICITY_OBJ_SOURCE_COLUMN = 0,
+//  PERIODICITY_ENTRY_SOURCE_COLUMN,
+//  PERIODICITY_OBJ_TARGET_COLUMN,
+//  PERIODICITY_ENTRY_TARGET_COLUMN,
+//  PERIODICITY_P1_SOURCE_COLUMN,
+//  PERIODICITY_P1_ENTRY_SOURCE_COLUMN,
+//  PERIODICITY_P2_SOURCE_COLUMN,
+//  PERIODICITY_P2_ENTRY_SOURCE_COLUMN,
+//  PERIODICITY_P3_SOURCE_COLUMN,
+//  PERIODICITY_P3_ENTRY_SOURCE_COLUMN,
+//  PERIODICITY_P1_TARGET_COLUMN,
+//  PERIODICITY_P1_ENTRY_TARGET_COLUMN,
+//  PERIODICITY_P2_TARGET_COLUMN,
+//  PERIODICITY_P2_ENTRY_TARGET_COLUMN,
+//  PERIODICITY_P3_TARGET_COLUMN,
+//  PERIODICITY_P3_ENTRY_TARGET_COLUMN,
+
+  PERIODICITY_NB_COLUMN
 };
 
 enum {
@@ -352,7 +356,7 @@ void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemMode
   } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
     QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
     QString value = lineEdit->text();
-    if (! vertexExists(model, index, value))
+    if (!vertexExists(model, index, value))
       model->setData(index, value, Qt::EditRole);
   } else if (index.column() == ENF_VER_GROUP_COLUMN) {
     QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
@@ -426,75 +430,6 @@ bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
 // END EnforcedTreeWidgetDelegate
 //
 
-//
-// BEGIN BLSURFPluginGUI_ObjectReferenceParamWdg
-//
-//================================================================================
-
-// BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
-// ( SUIT_SelectionFilter* f, QWidget* parent, bool multiSelection)
-//   : StdMeshersGUI_ObjectReferenceParamWdg(f, parent, multiSelection)
-// {
-//   init();
-// }
-// 
-// 
-// BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
-// ( MeshObjectType objType, QWidget* parent, bool multiSelection )
-//   : StdMeshersGUI_ObjectReferenceParamWdg( objType, parent, multiSelection )
-// {
-//   init();
-// }
-// 
-// BLSURFPluginGUI_ObjectReferenceParamWdg::~BLSURFPluginGUI_ObjectReferenceParamWdg()
-// {
-//   if ( myFilter )
-//   {
-//     mySelectionMgr->removeFilter( myFilter );
-//     delete myFilter;
-//   }
-// }
-// 
-// void BLSURFPluginGUI_ObjectReferenceParamWdg::init()
-// {
-//   StdMeshersGUI_ObjectReferenceParamWdg::init();
-//   disconnect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection()));
-//   connect( mySelButton, SIGNAL(toggled(bool)), SLOT(setActivationStatus(bool)));
-// }
-// 
-// void BLSURFPluginGUI_ObjectReferenceParamWdg::setActivationStatus(bool status)
-// {
-//   if (status)
-//     activateSelection();
-//   else
-//     deactivateSelection();
-// }
-// 
-// void BLSURFPluginGUI_ObjectReferenceParamWdg::activateSelectionOnly()
-// {
-//   if ( !mySelectionActivated && mySelectionMgr )
-//   {
-//     mySelectionActivated = true;
-//     mySelectionMgr->clearFilters();
-//     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-//       aViewWindow->SetSelectionMode(ActorSelection);
-//     if ( myFilter )
-//       mySelectionMgr->installFilter( myFilter );
-//     connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
-//   }
-//   emit selectionActivated();
-// }
-// 
-// void BLSURFPluginGUI_ObjectReferenceParamWdg::deactivateSelectionOnly()
-// {
-//   mySelectionActivated = false;
-//   disconnect(mySelectionMgr, 0, this, 0 );
-//   mySelectionMgr->removeFilter( myFilter );
-// }
-// 
-//
-// END BLSURFPluginGUI_ObjectReferenceParamWdg
-//
 
 /**
  * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
@@ -551,6 +486,31 @@ GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
   return GeometryGUI::GetGeomGen();
 }
 
+void BLSURFPluginGUI_HypothesisCreator::avoidSimultaneousSelection(ListOfWidgets &selectionWidgets) const
+{
+  StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
+  ListOfWidgets::const_iterator anIt = selectionWidgets.begin();
+  for ( ; anIt != selectionWidgets.end(); anIt++)
+    {
+      if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
+        {
+          StdMeshersGUI_ObjectReferenceParamWdg * w1 =
+              ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+          ListOfWidgets::const_iterator anIt2 = anIt;
+          for ( ++anIt2; anIt2 != selectionWidgets.end(); anIt2++)
+            if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
+              {
+                StdMeshersGUI_ObjectReferenceParamWdg * w2 =
+                    ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
+                w1->AvoidSimultaneousSelection( w2 );
+              }
+          if ( !widgetToActivate )
+            widgetToActivate = w1;
+        }
+    }
+  if ( widgetToActivate )
+    widgetToActivate->activateSelection();
+}
 
 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
 {
@@ -562,17 +522,17 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
 
   if ( ok )
   {
-    myOptionTable->setFocus();
+    myAdvWidget->myOptionTable->setFocus();
     QApplication::instance()->processEvents();
 
-    int row = 0, nbRows = myOptionTable->rowCount();
+    int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
     for ( ; row < nbRows; ++row )
     {
-      QString name  = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
-      QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
+      QString name  = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
+      QString value = myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
       if ( !value.isEmpty() ) {
         try {
-          QString optionType = myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().trimmed();
+          QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().trimmed();
           if (optionType == "PRECAD")
             h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
           else if (optionType == "BLSURF")
@@ -633,6 +593,38 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
     }
   }
 
+  // 22207: BLSURFPLUGIN: The user is allowed to enter 0 as a global or local size.
+  if ( ok )
+  {
+    // In case if not STD_TAB is current tab, then text() of empty spinboxes returns "0" value.
+    // So STD_TAB must be current tab to get correct value of it's spinbox.
+    myTabWidget->setCurrentIndex( STD_TAB );
+  }
+  if ( ok )
+  {
+    if ( !( ok = ( myStdWidget->myPhySize->text().isEmpty() ||
+                   myStdWidget->myPhySize->text().toDouble() > 0.0 )))
+      msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_HPHYDEF"));
+  }
+  if ( ok )
+  {
+    if ( !( ok = ( myStdWidget->myMaxSize->text().isEmpty() ||
+                   myStdWidget->myMaxSize->text().toDouble() > 0.0 )))
+      msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_MAXSIZE"));
+  }
+  if ( ok )
+  {
+    if ( !( ok = ( myStdWidget->myAngleMesh->text().isEmpty() ||
+                   myStdWidget->myAngleMesh->text().toDouble() > 0.0 )))
+      msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_ANGLE_MESH"));
+  }
+  if ( ok )
+  {
+    if ( !( ok = ( myStdWidget->myChordalError->text().isEmpty() ||
+                   myStdWidget->myChordalError->text().toDouble() > 0.0 )))
+      msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_CHORDAL_ERROR"));
+  }
+
   // Enforced vertices
   // TODO
 
@@ -650,175 +642,49 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   lay->setMargin( 5 );
   lay->setSpacing( 0 );
 
-  // tab
-  QTabWidget* tab = new QTabWidget( fr );
-  tab->setTabShape( QTabWidget::Rounded );
-  tab->setTabPosition( QTabWidget::North );
-  lay->addWidget( tab );
+  // main TabWidget of the dialog
+  myTabWidget = new QTabWidget( fr );
+  myTabWidget->setTabShape( QTabWidget::Rounded );
+  myTabWidget->setTabPosition( QTabWidget::North );
+  lay->addWidget( myTabWidget );
 
+  myName = 0;
+  
   // basic parameters
   myStdGroup = new QWidget();
   QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
   aStdLayout->setSpacing( 6 );
   aStdLayout->setMargin( 11 );
-
-  myName = 0;
+  
   if( isCreation() )
     myName = new QLineEdit( myStdGroup );
-
-  myGradation = new SMESHGUI_SpinBox( myStdGroup );
-  myGradation->RangeStepAndValidator(1.1, 2.5, 0.1, "length_precision");
-
-  myPhysicalMesh = new QComboBox( myStdGroup );
-  QStringList physicalTypes;
-  physicalTypes << tr( "BLSURF_DEFAULT_USER" ) << tr( "BLSURF_CUSTOM_USER" ) << tr( "BLSURF_SIZE_MAP");
-  myPhysicalMesh->addItems( physicalTypes );
-
-  myPhySize = new SMESHGUI_SpinBox( myStdGroup );
-  myPhySize->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
-
-#ifdef WITH_SIZE_BOUNDARIES
-  myPhyMin = new SMESHGUI_SpinBox( myStdGroup );
-  myPhyMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
-  myPhyMin->setText("");
-  myPhyMax = new SMESHGUI_SpinBox( myStdGroup );
-  myPhyMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
-  myPhyMax->setText("");
-#endif
-
-  myGeometricMesh = new QComboBox( myStdGroup );
-  QStringList types;
-  types << tr( "BLSURF_DEFAULT_GEOM" ) << tr( "BLSURF_CUSTOM_GEOM" );
-  myGeometricMesh->addItems( types );
-
-  myAngleMeshS = new SMESHGUI_SpinBox( myStdGroup );
-  myAngleMeshS->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
-
-  myAngleMeshC = new SMESHGUI_SpinBox( myStdGroup );
-  myAngleMeshC->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
-
-#ifdef WITH_SIZE_BOUNDARIES
-  myGeoMin = new SMESHGUI_SpinBox( myStdGroup );
-  myGeoMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
-  myGeoMin->setText("");
-  myGeoMax = new SMESHGUI_SpinBox( myStdGroup );
-  myGeoMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
-  myGeoMax->setText("");
-#endif
-  myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup );
-  myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup );
-
-  // ADD WIDGETS (STANDARD TAB)
+  myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
+  
   int row = 0;
   if( isCreation() ) {
-    aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ),        row, 0, 1, 1 );
-    aStdLayout->addWidget( myName,                                              row++, 1, 1, 3 );
-  }
-  aStdLayout->addWidget( new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup ),     row, 0, 1, 1 );
-  aStdLayout->addWidget( myPhysicalMesh,                                        row++, 1, 1, 1 );
-  aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup),       row, 0, 1, 1 );
-  aStdLayout->addWidget( myPhySize,                                             row++, 1, 1, 1 );
-  aStdLayout->addWidget( new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ),    row, 0, 1, 1 );
-  aStdLayout->addWidget( myGradation,                                           row++, 1, 1, 1 );
-#ifdef WITH_SIZE_BOUNDARIES
-  aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup ),      row, 0, 1, 1 );
-  aStdLayout->addWidget( myPhyMin,                                              row++, 1, 1, 1 );
-  aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup ),      row, 0, 1, 1 );
-  aStdLayout->addWidget( myPhyMax,                                              row++, 1, 1, 1 );
-#endif
+    aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ),    0, 0, 1, 1 );
+    aStdLayout->addWidget( myName,                                      row++, 1, 1, 3 );
+  }
+  aStdLayout->addWidget( myStdWidget,                                   row++, 0, 1, 4 );
+  
   int maxrow = row;
+  row = 0;
   if( isCreation() )
     row = 1;
-  else
-    row = 0;
-  aStdLayout->addWidget( new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup ),    row, 2, 1, 1 );
-  aStdLayout->addWidget( myGeometricMesh,                                       row++, 3, 1, 1 );
-  aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup ), row, 2, 1, 1 );
-  aStdLayout->addWidget( myAngleMeshS,                                          row++, 3, 1, 1 );
-  aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ), row, 2, 1, 1 );
-  aStdLayout->addWidget( myAngleMeshC,                                          row++, 3, 1, 1 );
-#ifdef WITH_SIZE_BOUNDARIES
-  aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup ),      row, 2, 1, 1 );
-  aStdLayout->addWidget( myGeoMin,                                              row++, 3, 1, 1 );
-  aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup ),      row, 2, 1, 1 );
-  aStdLayout->addWidget( myGeoMax,                                              row++, 3, 1, 1 );
-#endif
-  row = max(row,maxrow)+1;
-  aStdLayout->addWidget( myAllowQuadrangles,                                    row, 0, 1, 2 );
-  aStdLayout->addWidget( myDecimesh,                                            row++, 2, 1, 2 );
+//   row = max(row,maxrow)+1;
   aStdLayout->setRowStretch(row,1);
+  aStdLayout->setColumnStretch(1,1);
   maxrow = row;
 
+  
   // advanced parameters
   myAdvGroup = new QWidget();
   QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
   anAdvLayout->setSpacing( 6 );
-  anAdvLayout->setMargin( 11 );
-  anAdvLayout->setRowStretch( 4, 5 );
-  anAdvLayout->setColumnStretch( 1, 5 );
-
-  myTopology = new QComboBox( myAdvGroup );
-  QStringList topologyTypes;
-  topologyTypes << tr( "BLSURF_TOPOLOGY_CAD" ) 
-                << tr( "BLSURF_TOPOLOGY_PROCESS" ) 
-                << tr( "BLSURF_TOPOLOGY_PROCESS2" ) 
-                << tr( "BLSURF_TOPOLOGY_PRECAD" );
-  myTopology->addItems( topologyTypes );
-
-  myVerbosity = new QSpinBox( myAdvGroup );
-  myVerbosity->setMinimum( 0 );
-  myVerbosity->setMaximum( 100 );
-  myVerbosity->setSingleStep( 5 );
-
-  myOptionTable = new QTableWidget( 0, NB_COLUMNS, myAdvGroup );
-  QStringList headers;
-  headers << tr( "OPTION_ID_COLUMN" )<< tr( "OPTION_TYPE_COLUMN" )  << tr( "OPTION_NAME_COLUMN" ) << tr( "OPTION_VALUE_COLUMN" );
-  myOptionTable->setHorizontalHeaderLabels( headers );
-  myOptionTable->horizontalHeader()->hideSection( OPTION_ID_COLUMN );
-//   myOptionTable->horizontalHeader()->hideSection( OPTION_TYPE_COLUMN );
-  myOptionTable->horizontalHeader()->setStretchLastSection(true);
-  myOptionTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
-  //myOptionTable->setColumnReadOnly( OPTION_NAME_COLUMN, TRUE );//////
-  //myOptionTable->setColumnReadOnly( OPTION_VALUE_COLUMN, FALSE );/////
-  myOptionTable->verticalHeader()->hide();
-  //myOptionTable->setSelectionBehavior( QAbstractItemView::SelectRows );
-
-  QPushButton* addBtn = new QPushButton( tr( "ADD_OPTION"),  myAdvGroup );
-  addBtn->setMenu( new QMenu() );
-  QPushButton* rmBtn = new QPushButton( tr( "REMOVE_OPTION"), myAdvGroup );
-
-  myPreCADGroupBox = new QGroupBox(tr("BLSURF_PRECAD_GROUP"),  myAdvGroup );
-  myPreCADGroupBox->setEnabled(false);
-  QGridLayout* aPreCADGroupLayout = new QGridLayout(myPreCADGroupBox);
-  myPreCADMergeEdges = new QCheckBox(tr("BLSURF_PRECAD_MERGE_EDGES"),myPreCADGroupBox);
-  aPreCADGroupLayout->addWidget(myPreCADMergeEdges,0,0,1,2);
-  myPreCADRemoveNanoEdges = new QCheckBox(tr("BLSURF_PRECAD_REMOVE_NANO_EDGES"),myPreCADGroupBox);
-  aPreCADGroupLayout->addWidget(myPreCADRemoveNanoEdges,1,0,1,2);
-  myPreCADEpsNano = new SMESHGUI_SpinBox(myPreCADGroupBox);
-  myPreCADEpsNano->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
-  myPreCADEpsNano->setText("");
-  aPreCADGroupLayout->addWidget( new QLabel( tr( "BLSURF_PRECAD_EPS_NANO" ), myPreCADGroupBox ), 2, 0, 1, 1 );
-  aPreCADGroupLayout->addWidget(myPreCADEpsNano, 2, 1, 1, 1 );
-  myPreCADDiscardInput = new QCheckBox(tr("BLSURF_PRECAD_DISCARD_INPUT"),myPreCADGroupBox);
-  aPreCADGroupLayout->addWidget(myPreCADDiscardInput, 3, 0, 1, 2);
-  
-  QPushButton* chooseGMFBtn = new QPushButton( tr( "BLSURF_GMF_FILE" ),  myAdvGroup );
-  myGMFFileName = new QLineEdit(myAdvGroup);
-//   myGMFFileMode = new QCheckBox(tr("BLSURF_GMF_MODE"),myAdvGroup);
-
-  // ADD WIDGETS (ADVANCED TAB)
-  anAdvLayout->addWidget( new QLabel( tr( "BLSURF_VERBOSITY" ), myAdvGroup ), 0, 0, 1, 1 );
-  anAdvLayout->addWidget( myVerbosity,                                        0, 1, 1, 1 );
-  anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ),  1, 0, 1, 1 );
-  anAdvLayout->addWidget( myTopology,                                         1, 1, 1, 1 );
-  anAdvLayout->addWidget( myPreCADGroupBox ,                                  2, 0, 1, 2 );
-  anAdvLayout->addWidget( addBtn,                                             0, 2, 1, 1 );
-  anAdvLayout->addWidget( rmBtn,                                              0, 3, 1, 1 );
-  anAdvLayout->addWidget( myOptionTable,                                      1, 2, 3, 2 );
-  anAdvLayout->addWidget( chooseGMFBtn,                                       3, 0, 1, 1 );
-  anAdvLayout->addWidget( myGMFFileName,                                      3, 1, 1, 1 );
-//   anAdvLayout->addWidget( myGMFFileMode,                                      4, 0, 1, 2 );
-  anAdvLayout->setRowStretch(4,1);
+  anAdvLayout->setMargin( 11 );  
+  myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
+  myAdvWidget->addBtn->setMenu( new QMenu() );
+  anAdvLayout->addWidget( myAdvWidget);
 
 
   // Size Maps parameters
@@ -1055,21 +921,204 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
 //   anEnfLayout->setRowStretch(1, 1);
 
   // ---
-  tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
-  tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
-  tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) );
-  tab->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
+  // Periodicity parameters
+  myPeriodicityGroup = new QWidget();
+  aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
+
+  myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
+  myPeriodicitySplitter->setOrientation(Qt::Horizontal);
+  aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
+
+  myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
+
+  QStringList myPeriodicityTreeHeaders;
+  myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
+                           << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
+                           << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
+                           << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
+  myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
+
+  // Hide the vertex name to make the widget more readable
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
+  myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
+
+
+  myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
+  myPeriodicityTreeWidget->setSortingEnabled(true);
+
+  myPeriodicityTreeWidget->setAlternatingRowColors(true);
+  myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+  myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
+  
+  int periodicityVisibleColumns = 2;
+  for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
+      myPeriodicityTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
+      myPeriodicityTreeWidget->resizeColumnToContents(column);
+  }
+  myPeriodicityTreeWidget->header()->setStretchLastSection(true);
+
+  myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
+
+  myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
+
+  myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
+  myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
+  myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
+
+  myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
+
+  myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
+
+  myPeriodicityOnFaceRadioButton->setChecked(true);
+
+  myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
+
+
+  // FACE, EDGE AND VERTEX SELECTION
+  TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
+  shapeTypesFace.Add( TopAbs_FACE );
+  shapeTypesFace.Add( TopAbs_EDGE );
+  shapeTypesFace.Add( TopAbs_COMPOUND );
+  shapeTypesEdge.Add( TopAbs_EDGE );
+  shapeTypesEdge.Add( TopAbs_COMPOUND );
+
+//  myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
+
+  myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
+  myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+//  myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
+
+//  myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+//  myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
+//  myPeriodicitySourceEdgeWdg->hide();
+//  myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
+
+  myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
+  myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+//  myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
+  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
+
+//  myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+//  myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
+//  myPeriodicityTargetEdgeWdg->hide();
+//  myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
+
+  myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
+  myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
+  myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
+
+  myPeriodicityGroupBox2->setCheckable(true);
+  myPeriodicityGroupBox2->setChecked(false);
+
+  myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
+
+  myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
+
+  // P1
+  myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
+
+
+  SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
+
+  // P2
+  myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
+
+  // P3
+  myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
+
+  // P1
+  myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
+
+  // P2
+  myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
 
-  tab->setCurrentIndex( STD_TAB );
+  // P3
+  myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
+
+  SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
+  myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
+  myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
+
+  myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
+  myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
+
+
+  myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
+  myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
+
+  myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
+  myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
+
+  myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
+
+  myPeriodicitySelectionWidgets.clear();
+  myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
+  myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
+  avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
 
   // ---
-  connect( myGeometricMesh,     SIGNAL( activated( int ) ),            this,         SLOT( onGeometricMeshChanged() ) );
-  connect( myPhysicalMesh,      SIGNAL( activated( int ) ),            this,         SLOT( onPhysicalMeshChanged() ) );
-  connect( myTopology,          SIGNAL( activated( int ) ),            this,         SLOT( onTopologyChanged( int ) ) );
-  connect( addBtn->menu(),      SIGNAL( aboutToShow() ),               this,         SLOT( onAddOption() ) );
-  connect( addBtn->menu(),      SIGNAL( triggered( QAction* ) ),       this,         SLOT( onOptionChosenInPopup( QAction* ) ) );
-  connect( rmBtn,               SIGNAL( clicked()),                    this,         SLOT( onDeleteOption() ) );
-  connect( chooseGMFBtn,        SIGNAL( clicked()),                    this,         SLOT( onChooseGMFFile() ) );
+  myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
+  myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
+  myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
+  myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
+  myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
+
+  myTabWidget->setCurrentIndex( STD_TAB );
+
+  connect( myAdvWidget->addBtn->menu(), SIGNAL( aboutToShow() ),         this, SLOT( onAddOption() ) );
+  connect( myAdvWidget->addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
+  connect( myAdvWidget->rmBtn,          SIGNAL( clicked()),              this, SLOT( onDeleteOption() ) );
 
   // Size Maps
   connect( addMapButton,        SIGNAL( clicked()),                    this,         SLOT( onAddMap() ) );
@@ -1097,6 +1146,20 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
 //   connect( myEnfVertexWdg,     SIGNAL( selectionActivated()),         this,         SLOT( onVertexSelectionActivated() ) );
 //   connect( myEnfFaceWdg,       SIGNAL( selectionActivated()),         this,         SLOT( onFaceSelectionActivated() ) );
 
+  // Periodicity
+  connect( myPeriodicityAddButton,     SIGNAL( clicked()),                    this,   SLOT( onAddPeriodicity() ) );
+  connect( myPeriodicityRemoveButton,  SIGNAL( clicked()),                    this,   SLOT( onRemovePeriodicity() ) );
+  connect( myPeriodicityTreeWidget,    SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
+  connect( myPeriodicityGroupBox2,     SIGNAL(toggled(bool)),                 this,   SLOT(onPeriodicityByVerticesChecked(bool)));
+
+  ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
+  for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
+    {
+      StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+      connect( w1,     SIGNAL(contentModified ()),                 this,   SLOT(onPeriodicityContentModified()));
+
+    }
+//  connect( myPeriodicitySourceFaceWdg,     SIGNAL(contentModified()),    this,   SLOT(onPeriodicityContentModified()));
   return fr;
 }
 
@@ -1386,7 +1449,7 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
     if (boost::trim_copy(groupName).empty())
       groupName = "";
 
-    if (selEnfVertex == 1)
+    if (selEnfVertex <= 1)
     {
       double x,y,z;
       x = myXCoord->GetValue();
@@ -1430,9 +1493,9 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
   for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
     myEnforcedTreeWidget->resizeColumnToContents(column);
 
-  if ( myPhysicalMesh->currentIndex() != SizeMap ) {
-    myPhysicalMesh->setCurrentIndex( SizeMap );
-    onPhysicalMeshChanged();
+  if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
+    myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
+    myStdWidget->onPhysicalMeshChanged();
   }
 }
 
@@ -1482,14 +1545,207 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
 
 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
 {
-  if (state == Qt::Checked) {
-    myInternalEnforcedVerticesAllFacesGroup->setEnabled(true);
-  }
-  if (state == Qt::Unchecked) {
-    myInternalEnforcedVerticesAllFacesGroup->setEnabled(false);
+  myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
+This method is called when a item is added into the periodicity table widget
+*/
+void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
+//   MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
+
+  BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+
+  that->getGeomSelectionTool()->selectionMgr()->clearFilters();
+  ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
+  for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
+    {
+          StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+          w1->deactivateSelection();
+    }
+
+
+  // Source-Target selection
+  int selSource = myPeriodicitySourceFaceWdg->NbObjects();
+  int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
+
+  if (selSource == 0 || selTarget == 0)
+    return;
+
+  // Vertices selection
+  if (myPeriodicityGroupBox2->isChecked())
+    {
+      int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
+      int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
+      int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
+      int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
+      int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
+      int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
+
+      if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
+        {
+          QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
+          SUIT_MessageBox::critical( dlg(),"Error" , msg );
+          return;
+        }
+    }
+
+  // Add Source-Target in table
+  string shapeEntry, sourceEntry, targetEntry;
+  string shapeName, sourceName, targetName;
+  GEOM::GEOM_Object_var shape;
+
+  QTreeWidgetItem* item = new QTreeWidgetItem();
+  myPeriodicityTreeWidget->addTopLevelItem(item);
+
+  item->setFlags( Qt::ItemIsSelectable   |Qt::ItemIsEnabled );
+
+
+  size_t k=0;
+  for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
+    {
+      StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+      shape = w1->GetObject< GEOM::GEOM_Object >(0);
+      shapeName = shape->GetName();
+      shapeEntry = shape->GetStudyEntry();
+      item->setData(k, Qt::EditRole, shapeName.c_str() );
+      item->setData(k, Qt::UserRole, shapeEntry.c_str() );
+      if (! myPeriodicityGroupBox2->isChecked() && k==1)
+        break;
+    }
+
+  // Add shape type in tree
+  string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
+  item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
+
+  // Blank input fields
+  for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
+    {
+      StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+      w1->SetObject(GEOM::GEOM_Object::_nil());
+    }
+
+//  for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
+//    myPeriodicityTreeWidget->resizeColumnToContents(column);
+
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
+This method is called when a item is removed from the periodicity tree widget
+*/
+void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
+//   MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
+  QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
+  QTreeWidgetItem* item;
+
+  foreach(item,selectedItems) {
+     MESSAGE("Remove " << item->text(0).toStdString());
+    delete item;
   }
+
+  myEnforcedTreeWidget->selectionModel()->clearSelection();
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
+This method enable clears the field for periodicity by vertices
+*/
+void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
+{
+  if (! checked)
+    {
+      for (size_t k=2; k<myPeriodicitySelectionWidgets.size(); k++)
+        {
+          StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
+          w1->deactivateSelection();
+          w1->SetObject(CORBA::Object::_nil());
+        }
+    }
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
+This method enable the proper shape selection widget to Face or Edge shapes
+*/
+//void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
+//{
+//  if (myPeriodicityOnFaceRadioButton->isChecked())
+//    {
+//      MESSAGE("Show Face");
+//      myPeriodicitySourceEdgeWdg->hide();
+//      myPeriodicityTargetEdgeWdg->hide();
+//      myPeriodicitySourceFaceWdg->show();
+//      myPeriodicityTargetFaceWdg->show();
+//    }
+//  else
+//    {
+//      MESSAGE("Show Edge");
+//      myPeriodicitySourceFaceWdg->hide();
+//      myPeriodicityTargetFaceWdg->hide();
+//      myPeriodicitySourceEdgeWdg->show();
+//      myPeriodicityTargetEdgeWdg->show();
+//    }
+//}
+
+void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
+{
+  QString shapeName, shapeEntry;
+  CORBA::Object_var shape;
+  size_t k=0;
+  ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
+  for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
+    {
+      StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+
+      shapeName = item->data(k, Qt::EditRole).toString();
+      shapeEntry = item->data(k, Qt::UserRole).toString();
+      if (! shapeEntry.isEmpty())
+        {
+          shape = entryToObject(shapeEntry);
+          w1->SetObject(shape);
+          w1->deactivateSelection();
+          if (k==2)
+            myPeriodicityGroupBox2->setChecked(1);
+        }
+      else if(k==2)
+        myPeriodicityGroupBox2->setChecked(0);
+    }
+
+  if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
+    myPeriodicityOnFaceRadioButton->setChecked(true);
+  else
+    myPeriodicityOnEdgeRadioButton->setChecked(true);
+
+
 }
 
+/** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
+This method gives the focus to the next selection widget when a content is modified in a selection widget.
+*/
+void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
+{
+  BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+
+  ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
+  size_t k=0;
+  // find wich selection widget is activated
+  for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
+    {
+      StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
+      if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
+        {
+          // don't activate vertex selection if the group box is not checked
+          if (k==1 && !myPeriodicityGroupBox2->isChecked())
+            break;
+          // clear the selection, to avoid to put the same object in the other widget
+          that->getGeomSelectionTool()->selectionMgr()->clearSelected();
+          // activate the next widget
+          StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
+          w2->activateSelection();
+          break;
+        }
+    }
+}
+
+
 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
 This method updates the GUI widgets with the hypothesis data
 */
@@ -1506,47 +1762,62 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
     QFontMetrics metrics( myName->font() );
     myName->setMinimumWidth( metrics.width( data.myName )+5 );
   }
-  myTopology->setCurrentIndex( data.myTopology );
-  myPreCADGroupBox->setEnabled(data.myTopology == PreCAD);
-  myPreCADMergeEdges->setChecked( data.myPreCADMergeEdges );
-  myPreCADRemoveNanoEdges->setChecked( data.myPreCADRemoveNanoEdges );
-  myPreCADDiscardInput->setChecked( data.myPreCADDiscardInput );
-  MESSAGE("data.myPreCADEpsNano: "<<data.myPreCADEpsNano)
-  if (data.myPreCADEpsNano < 0)
-    myPreCADEpsNano->setText("");
+  myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
+  myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
+  if (data.myPhySize <= 0)
+    myStdWidget->myPhySize->setText("");
+  else
+    myStdWidget->myPhySize->SetValue( data.myPhySize );
+  myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
+  if (data.myMinSize < 0)
+    myStdWidget->myMinSize->setText("");
+  else
+    myStdWidget->myMinSize->SetValue( data.myMinSize );
+  myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
+  if (data.myMaxSize < 0)
+    myStdWidget->myMaxSize->setText("");
+  else
+    myStdWidget->myMaxSize->SetValue( data.myMaxSize );
+  myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
+  if (data.myGradation <= 0)
+    myStdWidget->myGradation->setText("");
   else
-    myPreCADEpsNano->SetValue( data.myPreCADEpsNano );
-  myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
-  myPhySize->SetValue( data.myPhySize );
-#ifdef WITH_SIZE_BOUNDARIES
-  MESSAGE("data.myPhyMin: "<<data.myPhyMin)
-  if (data.myPhyMin < 0)
-    myPhyMin->setText("");
+    myStdWidget->myGradation->SetValue( data.myGradation );
+  myStdWidget->myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
+  
+  if (data.myAngleMesh < 0)
+    myStdWidget->myAngleMesh->setText("");
+  else
+    myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
+  if (data.myChordalError <= 0)
+    myStdWidget->myChordalError->setText("");
   else
-    myPhyMin->SetValue( data.myPhyMin );
-  MESSAGE("data.myPhyMax: "<<data.myPhyMax)
-  if (data.myPhyMax < 0)
-    myPhyMax->setText("");
+    myStdWidget->myChordalError->SetValue( data.myChordalError );
+  myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
+  if (data.myAnisotropicRatio <= 0)
+    myStdWidget->myAnisotropicRatio->setText("");
   else
-    myPhyMax->SetValue( data.myPhyMax );
-  MESSAGE("data.myGeoMin: "<<data.myGeoMin)
-  if (data.myGeoMin < 0)
-    myGeoMin->setText("");
+    myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
+  myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
+  if (data.myTinyEdgeLength <= 0)
+    myStdWidget->myTinyEdgeLength->setText("");
   else
-    myGeoMin->SetValue( data.myGeoMin );
-  MESSAGE("data.myGeoMax: "<<data.myGeoMax)
-  if (data.myGeoMax < 0)
-    myGeoMax->setText("");
+    myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
+  myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
+  if (data.myBadElementAspectRatio <= 0)
+    myStdWidget->myBadElementAspectRatio->setText("");
   else
-    myGeoMax->SetValue( data.myGeoMax );
-#endif
-  myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
-  myAngleMeshS->SetValue( data.myAngleMeshS );
-  myAngleMeshC->SetValue( data.myAngleMeshC );
-  myGradation->SetValue( data.myGradation );
-  myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
-  myDecimesh->setChecked( data.myDecimesh );
-  myVerbosity->setValue( data.myVerbosity );
+    myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
+  myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
+  myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
+  
+  myStdWidget->resizeWidgets();  
+  
+  myAdvWidget->myVerbosity->setValue( data.myVerbosity );
+  myAdvWidget->myPreCADGroupBox->setChecked(data.myTopology == PreCAD);
+  myAdvWidget->myPreCADMergeEdges->setChecked( data.myPreCADMergeEdges );
+  myAdvWidget->myPreCADProcess3DTopology->setChecked( data.myPreCADProcess3DTopology );
+  myAdvWidget->myPreCADDiscardInput->setChecked( data.myPreCADDiscardInput );
 
   if ( myOptions.operator->() ) {
 //     MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
@@ -1555,18 +1826,18 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
       QStringList name_value = option.split( ":", QString::KeepEmptyParts );
       if ( name_value.count() > 1 ) {
         QString idStr = QString("%1").arg( i );
-        int row = myOptionTable->rowCount();
-        myOptionTable->setRowCount( row+1 );
-        myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
-        myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
-        myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "BLSURF" ) );
-        myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
-        myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
-        myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
-        myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
-        myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
-                                      Qt::ItemIsEditable   |
-                                      Qt::ItemIsEnabled );
+        int row = myAdvWidget->myOptionTable->rowCount();
+        myAdvWidget->myOptionTable->setRowCount( row+1 );
+        myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
+        myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
+        myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "BLSURF" ) );
+        myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
+        myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
+        myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
+        myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
+        myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
+                                                                                Qt::ItemIsEditable   |
+                                                                                Qt::ItemIsEnabled );
       }
     }
   }
@@ -1577,23 +1848,23 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
       QStringList name_value = option.split( ":", QString::KeepEmptyParts );
       if ( name_value.count() > 1 ) {
         QString idStr = QString("%1").arg( i );
-        int row = myOptionTable->rowCount();
-        myOptionTable->setRowCount( row+1 );
-        myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
-        myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
-        myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "PRECAD" ) );
-        myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
-        myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
-        myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
-        myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
-        myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
-                                      Qt::ItemIsEditable   |
-                                      Qt::ItemIsEnabled );
+        int row = myAdvWidget->myOptionTable->rowCount();
+        myAdvWidget->myOptionTable->setRowCount( row+1 );
+        myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
+        myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
+        myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "PRECAD" ) );
+        myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
+        myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
+        myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
+        myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
+        myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
+                                                                                Qt::ItemIsEditable   |
+                                                                                Qt::ItemIsEnabled );
       }
     }
   }
-  myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
-  myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
+  myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
+  myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
 //   myGMFFileMode->setChecked(data.myGMFFileMode);
   
   // Sizemaps
@@ -1673,9 +1944,29 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
   myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
   myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
 
+  // Periodicity
+  MESSAGE("retrieveParams(): periodicity ");
+
+
+  // Add an item in the tree widget for each association
+  for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
+    {
+      QTreeWidgetItem* item = new QTreeWidgetItem();
+      myPeriodicityTreeWidget->addTopLevelItem(item);
+      item->setFlags( Qt::ItemIsSelectable   |Qt::ItemIsEnabled );
+      TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
+      for (size_t k=0; k<periodicity_i.size(); k++)
+        {
+          string shapeEntry = periodicity_i[k];
+          string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
+          item->setData(k, Qt::EditRole, shapeName.c_str() );
+          item->setData(k, Qt::UserRole, shapeEntry.c_str() );
+        }
+    }
+
   // update widgets
-  that->onPhysicalMeshChanged();
-  that->onGeometricMeshChanged();
+  that->myStdWidget->onPhysicalMeshChanged();
+  that->myStdWidget->onGeometricMeshChanged();
 }
 
 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
@@ -1683,6 +1974,7 @@ This method updates the hypothesis data with the GUI widgets content.
 */
 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
 {
+  MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParams");
   BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
 
   BlsurfHypothesisData data;
@@ -1704,37 +1996,39 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
   HypothesisData* data = SMESH::GetHypothesisData( hypType() );
   h_data.myName = isCreation() && data ? hypName() : "";
 
-  h_data.myTopology           = (int) h->GetTopology();
-  h_data.myPhysicalMesh       = (int) h->GetPhysicalMesh();
-  h_data.myPhySize            = h->GetPhySize();
-  h_data.myGeometricMesh      = (int) h->GetGeometricMesh();
-  h_data.myAngleMeshS         = h->GetAngleMeshS();
-  h_data.myAngleMeshC         = h->GetAngleMeshC();
-  h_data.myGradation          = h->GetGradation();
-  h_data.myAllowQuadrangles   = h->GetQuadAllowed();
-  h_data.myDecimesh           = h->GetDecimesh();
-  h_data.myVerbosity          = h->GetVerbosity();
-  h_data.myPreCADMergeEdges   = h->GetPreCADMergeEdges();
-  h_data.myPreCADRemoveNanoEdges = h->GetPreCADRemoveNanoEdges();
-  h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
-  double EpsNano = h->GetPreCADEpsNano();
-  h_data.myPreCADEpsNano      = EpsNano > 0 ? EpsNano : -1.0;
-
-#ifdef WITH_SIZE_BOUNDARIES
-  double PhyMin = h->GetPhyMin();
-  double PhyMax = h->GetPhyMax();
-  double GeoMin = h->GetGeoMin();
-  double GeoMax = h->GetGeoMax();
-//   if ( PhyMin > 0 )
-//   h_data.myPhyMin = PhyMin > 0 ? QString::number( h->GetPhyMin() ) : QString("");
-//   h_data.myPhyMax = PhyMax > 0 ? QString::number( h->GetPhyMax() ) : QString("");
-//   h_data.myGeoMin = GeoMin > 0 ? QString::number( h->GetGeoMin() ) : QString("");
-//   h_data.myGeoMax = GeoMax > 0 ? QString::number( h->GetGeoMax() ) : QString("");
-  h_data.myPhyMin = PhyMin > 0 ? PhyMin : -1.0;
-  h_data.myPhyMax = PhyMax > 0 ? PhyMax : -1.0;
-  h_data.myGeoMin = GeoMin > 0 ? GeoMin : -1.0;
-  h_data.myGeoMax = GeoMax > 0 ? GeoMax : -1.0;
-#endif
+  h_data.myPhysicalMesh           = (int) h->GetPhysicalMesh();
+  h_data.myGeometricMesh          = (int) h->GetGeometricMesh();
+  h_data.myPhySize                = h->GetPhySize();
+  h_data.myPhySizeRel             = h->IsPhySizeRel();
+  double minSize                  = h->GetMinSize();
+  double maxSize                  = h->GetMaxSize();
+  h_data.myMinSize                = minSize > 0 ? minSize : -1.0;
+  h_data.myMinSizeRel             = h->IsMinSizeRel();
+  h_data.myMaxSize                = maxSize > 0 ? maxSize : -1.0;
+  h_data.myMaxSizeRel             = h->IsMaxSizeRel();
+  h_data.myGradation              = h->GetGradation();
+  h_data.myAllowQuadrangles       = h->GetQuadAllowed();
+  double angle                    = h->GetAngleMesh();
+  h_data.myAngleMesh              = angle > 0 ? angle : -1.0;
+  double chordalError             = h->GetChordalError();
+  h_data.myChordalError           = chordalError > 0 ? chordalError : -1.0;
+  h_data.myAnisotropic            = h->GetAnisotropic();
+  double myAnisotropicRatio       = h->GetAnisotropicRatio();
+  h_data.myAnisotropicRatio       = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
+  h_data.myRemoveTinyEdges        = h->GetRemoveTinyEdges();
+  double myTinyEdgeLength         = h->GetTinyEdgeLength();
+  h_data.myTinyEdgeLength         = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
+  h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
+  double myBadElementAspectRatio  = h->GetBadElementAspectRatio();
+  h_data.myBadElementAspectRatio  = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
+  h_data.myOptimizeMesh           = h->GetOptimizeMesh();
+  h_data.myQuadraticMesh          = h->GetQuadraticMesh();
+  h_data.myVerbosity              = h->GetVerbosity();
+  h_data.myTopology               = (int) h->GetTopology();
+  h_data.myPreCADMergeEdges       = h->GetPreCADMergeEdges();
+  h_data.myPreCADProcess3DTopology  = h->GetPreCADProcess3DTopology();
+  h_data.myPreCADDiscardInput     = h->GetPreCADDiscardInput();
+
 
   BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
   that->myOptions = h->GetOptionValues();
@@ -1808,7 +2102,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
   }
   
   // attractor new version
-  MESSAGE("retrieveParams, Attractors")
+  MESSAGE("readParamsFromHypo, Attractors")
   BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
   for ( int i = 0;i<allMyAttractorParams->length(); ++i ) {
     BLSURFPlugin::TAttractorParams myAttractorParams =  allMyAttractorParams[i];
@@ -1871,9 +2165,55 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
   h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
   h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
 
+  // Periodicity
+  MESSAGE("readParamsFromHypo, Periodicity")
+
+  h_data.preCadPeriodicityVector.clear();
+
+  BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
+  AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
+
+  BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
+  AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
   return true;
 }
 
+void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
+    BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
+{
+
+  for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
+    {
+      TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
+      periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
+      periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
+
+      BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
+      BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
+
+      if (sourceVertices.length()!=0)
+        {
+          periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
+          periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
+          periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
+        }
+
+      if (targetVertices.length()!=0)
+        {
+          periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
+          periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
+          periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
+        }
+
+      if (onFace)
+        periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
+      else
+        periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
+
+      h_data.preCadPeriodicityVector.push_back(periodicity_i);
+    }
+}
+
 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
 Saves the hypothesis data to hypothesis values.
 */
@@ -1886,52 +2226,80 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
   bool ok = true;
   try
   {
-    if( isCreation() )
+    if ( isCreation() )
       SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
 
-    if ( h->GetTopology() != h_data.myTopology ) // avoid duplication of DumpPython commands
-      h->SetTopology( (int) h_data.myTopology );
-    if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh )
+    if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
       h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
     if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
       h->SetGeometricMesh( (int) h_data.myGeometricMesh );
+
+    if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
+      if ( h->GetPhySize()   != h_data.myPhySize ||
+           h->IsPhySizeRel() != h_data.myPhySizeRel ) {
+        if ( h_data.myPhySizeRel )
+          h->SetPhySizeRel( h_data.myPhySize );
+        else
+          h->SetPhySize( h_data.myPhySize );
+      }
+    }
+    if (h->GetMinSize()   != h_data.myMinSize ||
+        h->IsMinSizeRel() != h_data.myMinSizeRel ) {
+      if ( h_data.myMinSizeRel )
+        h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
+      else
+        h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
+    }
+    if (h->GetMaxSize()   != h_data.myMaxSize ||
+        h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
+      if ( h_data.myMaxSizeRel )
+        h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
+      else
+        h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
+    }
     if ( h->GetGradation() !=  h_data.myGradation )
-      h->SetGradation( h_data.myGradation );
+      h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
     if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
       h->SetQuadAllowed( h_data.myAllowQuadrangles );
-    if ( h->GetDecimesh() != h_data.myDecimesh )
-      h->SetDecimesh( h_data.myDecimesh );
+    
+    if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
+      if ( h->GetAngleMesh() != h_data.myAngleMesh )
+        h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
+      if ( h->GetChordalError() != h_data.myChordalError )
+        h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
+    }
+    
+    if ( h->GetAnisotropic() != h_data.myAnisotropic )
+      h->SetAnisotropic( h_data.myAnisotropic );
+    if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
+      h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
+    
+    if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
+      h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
+    if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
+      h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
+    
+    if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
+      h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
+    if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
+      h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
+    
+    if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
+      h->SetOptimizeMesh( h_data.myOptimizeMesh );    
+    
+    if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
+      h->SetQuadraticMesh( h_data.myQuadraticMesh );    
+
     if ( h->GetVerbosity() != h_data.myVerbosity )
       h->SetVerbosity( h_data.myVerbosity );
+    if ( h->GetTopology() != h_data.myTopology )
+      h->SetTopology( (int) h_data.myTopology );
     if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
       h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
-    if ( h->GetPreCADRemoveNanoEdges() != h_data.myPreCADRemoveNanoEdges )
-      h->SetPreCADRemoveNanoEdges( h_data.myPreCADRemoveNanoEdges );
+    if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
+      h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
     if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
       h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
-    if ( h->GetPreCADEpsNano() != h_data.myPreCADEpsNano && h_data.myPreCADEpsNano > 0)
-      h->SetPreCADEpsNano( h_data.myPreCADEpsNano );
-
-    if( ((int) h_data.myPhysicalMesh == PhysicalUserDefined)||((int) h_data.myPhysicalMesh == SizeMap) ) {
-      if ( h->GetPhySize() != h_data.myPhySize )
-        h->SetPhySize( h_data.myPhySize );
-    }
-    if( (int) h_data.myGeometricMesh == UserDefined ) {
-      if ( h->GetAngleMeshS() != h_data.myAngleMeshS )
-        h->SetAngleMeshS( h_data.myAngleMeshS );
-      if ( h->GetAngleMeshC() != h_data.myAngleMeshC )
-        h->SetAngleMeshC( h_data.myAngleMeshC );
-    }
-#ifdef WITH_SIZE_BOUNDARIES
-    if (h->GetPhyMin() != h_data.myPhyMin && h_data.myPhyMin > 0)
-      h->SetPhyMin( h_data.myPhyMin );
-    if (h->GetPhyMax() != h_data.myPhyMax && h_data.myPhyMax > 0)
-      h->SetPhyMax( h_data.myPhyMax );
-    if (h->GetGeoMin() != h_data.myGeoMin && h_data.myGeoMin > 0)
-      h->SetGeoMin( h_data.myGeoMin );
-    if (h->GetGeoMax() != h_data.myGeoMax && h_data.myGeoMax > 0)
-      h->SetGeoMax( h_data.myGeoMax );
-#endif
 
     h->SetOptionValues( myOptions ); // is set in checkParams()
     h->SetPreCADOptionValues( myPreCADOptions ); // is set in checkParams()
@@ -2025,6 +2393,53 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
     if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
       h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
 
+    // Periodicity
+    if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
+          h->ClearPreCadPeriodicityVectors();
+
+    MESSAGE("h_data.preCadPeriodicityVector.size(): " << h_data.preCadPeriodicityVector.size());
+    TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
+    for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
+      {
+        TPreCadPeriodicity periodicity_i = *pIt;
+        TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
+        TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
+        TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
+        TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
+        TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
+        TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
+        TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
+        TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
+        bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
+
+        BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
+        if (! p1Source.empty())
+          {
+            sourceVertices->length(3);
+            sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
+            sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
+            sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
+          }
+
+
+        BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
+        if (! p1Target.empty())
+          {
+            targetVertices->length(3);
+            targetVertices[0]=CORBA::string_dup(p1Target.c_str());
+            targetVertices[1]=CORBA::string_dup(p2Target.c_str());
+            targetVertices[2]=CORBA::string_dup(p3Target.c_str());
+          }
+
+        if (onFace)
+          h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
+        else
+          h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
+      }
+
+    MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end periodicity");
+
+
   } // try
   catch(const std::exception& ex) {
     std::cout << "Exception: " << ex.what() << std::endl;
@@ -2036,6 +2451,7 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
 // //     SalomeApp_Tools::QtCatchCorbaException(ex);
 // //     ok = false;
 //   }
+  MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end");
   return ok;
 }
 
@@ -2046,57 +2462,72 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes
 {
   MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
   h_data.myName                  = myName ? myName->text() : "";
-  h_data.myTopology              = myTopology->currentIndex();
-  h_data.myPhysicalMesh          = myPhysicalMesh->currentIndex();
-  h_data.myPhySize               = myPhySize->GetValue();
-#ifdef WITH_SIZE_BOUNDARIES
-  h_data.myPhyMin                = myPhyMin->GetValue();
-  h_data.myPhyMax                = myPhyMax->GetValue();
-  h_data.myGeoMin                = myGeoMin->GetValue();
-  h_data.myGeoMax                = myGeoMax->GetValue();
-#endif
-  h_data.myGeometricMesh         = myGeometricMesh->currentIndex();
-  h_data.myAngleMeshS            = myAngleMeshS->GetValue();
-  h_data.myAngleMeshC            = myAngleMeshC->GetValue();
-  h_data.myGradation             = myGradation->GetValue();
-  h_data.myAllowQuadrangles      = myAllowQuadrangles->isChecked();
-  h_data.myDecimesh              = myDecimesh->isChecked();
-  h_data.myVerbosity             = myVerbosity->value();
-  h_data.myPreCADMergeEdges      = myPreCADMergeEdges->isChecked();
-  h_data.myPreCADRemoveNanoEdges = myPreCADRemoveNanoEdges->isChecked();
-  h_data.myPreCADDiscardInput    = myPreCADDiscardInput->isChecked();
-  h_data.myPreCADEpsNano         = myPreCADEpsNano->GetValue();
+  h_data.myPhysicalMesh          = myStdWidget->myPhysicalMesh->currentIndex();
+  h_data.myGeometricMesh         = myStdWidget->myGeometricMesh->currentIndex();
+  h_data.myPhySize               = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
+  h_data.myPhySizeRel            = myStdWidget->myPhySizeRel->isChecked();
+  h_data.myMinSize               = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
+  h_data.myMinSizeRel            = myStdWidget->myMinSizeRel->isChecked();
+  h_data.myMaxSize               = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
+  h_data.myMaxSizeRel            = myStdWidget->myMaxSizeRel->isChecked();
+  h_data.myGradation             = myStdWidget->myGradation->text().isEmpty() ? -1.0 : myStdWidget->myGradation->GetValue();
+  h_data.myAllowQuadrangles      = myStdWidget->myAllowQuadrangles->isChecked();
+  h_data.myAngleMesh             = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
+  h_data.myChordalError          = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
+  h_data.myAnisotropic           = myStdWidget->myAnisotropic->isChecked();
+  h_data.myAnisotropicRatio      = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
+  h_data.myRemoveTinyEdges       = myStdWidget->myRemoveTinyEdges->isChecked();
+  h_data.myTinyEdgeLength        = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
+  h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
+  h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
+  h_data.myOptimizeMesh          = myStdWidget->myOptimizeMesh->isChecked();
+  h_data.myQuadraticMesh         = myStdWidget->myQuadraticMesh->isChecked();
+  h_data.myVerbosity             = myAdvWidget->myVerbosity->value();
+  h_data.myTopology              = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
+  h_data.myPreCADMergeEdges      = myAdvWidget->myPreCADMergeEdges->isChecked();
+  h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
+  h_data.myPreCADDiscardInput    = myAdvWidget->myPreCADDiscardInput->isChecked();
 
   QString guiHyp;
-  guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
   guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
-  guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
   guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
-  guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( h_data.myAngleMeshS ) + "; ";
+  guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
+  guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
+  guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
+  guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
+  guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
+  guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
   guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
   guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
-  guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(h_data.myDecimesh ? "yes" : "no") + "; ";
-#ifdef WITH_SIZE_BOUNDARIES
-  guiHyp += "hphymin = " + QString::number( h_data.myPhyMin ) + "; ";
-  guiHyp += "hphymax = " + QString::number( h_data.myPhyMax ) + "; ";
-  guiHyp += "hgeomin = " + QString::number( h_data.myGeoMin ) + "; ";
-  guiHyp += "hgeomax = " + QString::number( h_data.myGeoMax ) + "; ";
-#endif
+  guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
+  guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
+  guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
+  guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
+  
+  
+  guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
+  guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
+  guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
+  guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
+  guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
+  guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
+  
+  
+  guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
   guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
-  guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADRemoveNanoEdges ? "yes" : "no") + "; ";
+  guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
   guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
-  guiHyp += tr("BLSURF_PRECAD_EPS_NANO") + " = " + QString::number( h_data.myPreCADEpsNano ) + "; ";
 
   BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
-  int row = 0, nbRows = myOptionTable->rowCount();
+  int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
   for ( ; row < nbRows; ++row )
   {
-    int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
-    std::string optionType = myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString();
+    int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
+    std::string optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString();
     if ( id >= 0 && ( ( optionType == "BLSURF" && id < myOptions->length() ) || ( optionType == "PRECAD" && id < myPreCADOptions->length() ) ) )
     {
-      QString name  = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
-      QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
+      QString name  = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
+      QString value = myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
       if ( value.isNull() )
         value = "";
       if (optionType == "PRECAD")
@@ -2112,7 +2543,7 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes
     }
   }
   
-  h_data.myGMFFileName = myGMFFileName->text().toStdString();
+  h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
 //   h_data.myGMFFileMode = myGMFFileMode->isChecked();
 
   // SizeMap
@@ -2182,60 +2613,28 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes
   h_data.myInternalEnforcedVerticesAllFaces      = myInternalEnforcedVerticesAllFaces->isChecked();
   h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
 
-  MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
-  return guiHyp;
-}
-
-
-void BLSURFPluginGUI_HypothesisCreator::onTopologyChanged(int index) {
-  MESSAGE("BLSURFPluginGUI_HypothesisCreator::onTopologyChanged");
-  myPreCADGroupBox->setEnabled(index == PreCAD);
-}
-
-void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() {
-  MESSAGE("BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged");
-  bool isPhysicalUserDefined = (myPhysicalMesh->currentIndex() == PhysicalUserDefined);
-  bool isSizeMap = (myPhysicalMesh->currentIndex() == SizeMap);
-  bool isCustom = (isPhysicalUserDefined || isSizeMap) ;
-  bool geomIsCustom = (myGeometricMesh->currentIndex() == UserDefined);
-
-  myGradation->setEnabled(!isPhysicalUserDefined || geomIsCustom);
-  myPhySize->setEnabled(isCustom);
-  myPhyMax->setEnabled(isCustom);
-  myPhyMin->setEnabled(isCustom);
-
-  if ( !myGradation->isEnabled())
-    myGradation->SetValue( 1.1 );
-
-  if ( !isCustom ) {
-    if ( myGeometricMesh->currentIndex() == DefaultGeom ) {
-      myGeometricMesh->setCurrentIndex( UserDefined );
-      onGeometricMeshChanged();
+  // Periodicity
+  h_data.preCadPeriodicityVector.clear();
+  // For each tree item, store each value. Shapes are stored as entries.
+  int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
+  for (size_t i=0 ; i<nbPeriodicityDescriptions ; i++) {
+    QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
+    TPreCadPeriodicity periodicity_i;
+    if (item) {
+        for (size_t k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
+          {
+            MESSAGE(k);
+            std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
+            MESSAGE(entry);
+            periodicity_i.push_back(entry);
+          }
+        h_data.preCadPeriodicityVector.push_back(periodicity_i);
     }
+    guiHyp += "PERIODICITY = yes; ";
   }
-}
 
-void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() {
-  MESSAGE("BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged");
-  bool isCustom = (myGeometricMesh->currentIndex() == UserDefined);
-  bool phyIsSizemap = (myPhysicalMesh->currentIndex() == SizeMap);
-
-  myAngleMeshS->setEnabled(isCustom);
-  myAngleMeshC->setEnabled(isCustom);
-  myGradation->setEnabled(isCustom || phyIsSizemap);
-  myGeoMax->setEnabled(isCustom);
-  myGeoMin->setEnabled(isCustom);
-
-  if ( !myGradation->isEnabled())
-    myGradation->SetValue( 1.1 );
-
-  if ( ! isCustom ) {
-    //  hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
-    if ( myPhysicalMesh->currentIndex() == DefaultSize ) {
-      myPhysicalMesh->setCurrentIndex( PhysicalUserDefined );
-      onPhysicalMeshChanged();
-    }
-  }
+  MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
+  return guiHyp;
 }
 
 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
@@ -2264,7 +2663,7 @@ void BLSURFPluginGUI_HypothesisCreator::onAddOption()
 
 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
 {
-  myOptionTable->setFocus();
+  myAdvWidget->myOptionTable->setFocus();
   QMenu* menu = (QMenu*)( a->parent() );
 
   int idx = menu->actions().indexOf( a );
@@ -2281,69 +2680,59 @@ void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
   QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
 
   // look for a row with optionName
-  int row = 0, nbRows = myOptionTable->rowCount();
+  int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
   for ( ; row < nbRows; ++row )
-    if ( myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
-      if ( myOptionTable->item( row, OPTION_TYPE_COLUMN )->text() == optionType )
+    if ( myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
+      if ( myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text() == optionType )
         break;
   // add a row if not found
   if ( row == nbRows ) {
-    myOptionTable->setRowCount( row+1 );
-    myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
-    myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
-    myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( optionType ) );
-    myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
-    myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
-    myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
-    myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
-    myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
-                                                               Qt::ItemIsEditable   |
-                                                               Qt::ItemIsEnabled );
-    myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
-  }
-  myOptionTable->clearSelection();
-  myOptionTable->scrollToItem( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
-  //myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
-  myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
-  //myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
+    myAdvWidget->myOptionTable->setRowCount( row+1 );
+    myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
+    myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
+    myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( optionType ) );
+    myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
+    myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
+    myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
+    myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
+    myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
+                                                                            Qt::ItemIsEditable   |
+                                                                            Qt::ItemIsEnabled );
+    myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
+  }
+  myAdvWidget->myOptionTable->clearSelection();
+  myAdvWidget->myOptionTable->scrollToItem( myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
+  //myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
+  myAdvWidget->myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
+  //myAdvWidget->myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
 }
 
 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
 {
   // clear option values and remember selected row
   QList<int> selectedRows;
-  QList<QTableWidgetItem*> selected = myOptionTable->selectedItems();
+  QList<QTableWidgetItem*> selected = myAdvWidget->myOptionTable->selectedItems();
   QTableWidgetItem* item;
   foreach( item, selected ) {
     int row = item->row();
     if ( !selectedRows.contains( row ) ) {
       selectedRows.append( row );
-      int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
-      std::string optionType = myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString();
+      int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
+      QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text();
       if ( id >= 0 )
         if (optionType == "BLSURF" && id < myOptions->length() )
-          myOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
+          myOptions[ id ] = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
         else if (optionType == "PRECAD" && id < myPreCADOptions->length() )
-          myPreCADOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
+          myPreCADOptions[ id ] = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
     }
   }
   qSort( selectedRows );
   QListIterator<int> it( selectedRows );
   it.toBack();
   while ( it.hasPrevious() )
-    myOptionTable->removeRow( it.previous() );
-}
-
-void BLSURFPluginGUI_HypothesisCreator::onChooseGMFFile()
-{
-//   QFileDialog dlg(0);
-//   dlg.selectFile(myGMFFileName->text());
-//   dlg.setNameFilter(tr("BLSURF_GMF_FILE_FORMAT"));
-//   dlg.setDefaultSuffix(QString("mesh"));
-  myGMFFileName->setText(QFileDialog::getSaveFileName(0, tr("BLSURF_GMF_FILE_DIALOG"), myGMFFileName->text(), tr("BLSURF_GMF_FILE_FORMAT")));
+    myAdvWidget->myOptionTable->removeRow( it.previous() );
 }
 
-
 // **********************
 // *** BEGIN SIZE MAP ***
 // **********************
@@ -2553,19 +2942,26 @@ void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int
 
 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
 {
+  bool res = false;
   if ( smpTab->currentIndex() == ATT_TAB ){    
     if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){ 
       mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
       myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
-      insertAttractor(mySMapObject, myAttObject);
+      res = insertAttractor(mySMapObject, myAttObject);
     }
   }
   if (smpTab->currentIndex() == SMP_STD_TAB  ){
     if ( myGeomSelWdg1->IsObjectSelected() ){
       mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
-      insertElement(mySMapObject);  
+      res = insertElement(mySMapObject);  
     }  
   }
+  if ( !res ) {
+    // Local size should be more than 0
+    QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
+    SUIT_MessageBox::critical( dlg(),"Error" , msg );
+    return;
+  }
   BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;  
   that->getGeomSelectionTool()->selectionMgr()->clearFilters();
   myAttDistSpin->setValue(0.);
@@ -2585,19 +2981,26 @@ void BLSURFPluginGUI_HypothesisCreator::onAddMap()
 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
 {
   MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()");
+  bool res = false;
   if ( smpTab->currentIndex() == ATT_TAB ){    
     if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){ 
       mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
       myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
-      insertAttractor(mySMapObject, myAttObject, /*modify = */true);
+      res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
     }
   }
   if (smpTab->currentIndex() == SMP_STD_TAB  ){
     if ( myGeomSelWdg1->IsObjectSelected() ){
       mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
-      insertElement(mySMapObject, /*modify = */true);  
+      res = insertElement(mySMapObject, /*modify = */true);  
     }  
   }
+  if ( !res ) {
+    // Local size should be more than 0
+    QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
+    SUIT_MessageBox::critical( dlg(),"Error" , msg );
+    return;
+  }
   BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;  
   that->getGeomSelectionTool()->selectionMgr()->clearFilters();
   myAttDistSpin->setValue(0.);
@@ -2614,7 +3017,7 @@ void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
   myAttSelWdg->SetObject(CORBA::Object::_nil());
 }
 
-void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
+bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
 {
   MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
   BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
@@ -2647,6 +3050,10 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb
   QString shapeEntry;
   shapeEntry = QString::fromStdString(entry);
   double phySize = mySmpSizeSpin->value();
+
+  if ( phySize == 0 )
+    return false; // Local size should be more than 0
+
   std::ostringstream oss;
   oss << phySize;
   QString sizeMap;
@@ -2660,7 +3067,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb
     if (that->mySMPMap.contains(shapeEntry)) {  
       if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
   //             MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
-        return;
+        return false;
       }
     }
     mySizeMapTable->addTopLevelItem(item);
@@ -2677,13 +3084,14 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb
   mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
   mySizeMapTable->clearSelection();
 
-  if ( myPhysicalMesh->currentIndex() != SizeMap ) {
-    myPhysicalMesh->setCurrentIndex( SizeMap );
-    onPhysicalMeshChanged();
+  if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
+    myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
+    myStdWidget->onPhysicalMeshChanged();
   }
+  return true;
 }
 
-void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
+bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
 {
   MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
   BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
@@ -2706,6 +3114,10 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF
   double infDist = 0. ;
   double constDist = 0. ;
   phySize = myAttSizeSpin->value();
+
+  if ( phySize == 0 )
+    return false; // Local size should be more than 0
+
   if (myAttractorCheck->isChecked()){
     infDist = myAttDistSpin->value();
   }
@@ -2733,7 +3145,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF
     if (that->mySMPMap.contains(shapeEntry)) {  
       if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
     //             MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
-        return;
+        return false;
       }
     }
     item = new QTreeWidgetItem();
@@ -2765,11 +3177,12 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF
   mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
   mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
 
-  if ( myPhysicalMesh->currentIndex() != SizeMap ) {
-    myPhysicalMesh->setCurrentIndex( SizeMap );
-    onPhysicalMeshChanged();
+  if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
+    myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
+    myStdWidget->onPhysicalMeshChanged();
   }
   MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
+  return true;
 }
 
 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
@@ -2920,14 +3333,12 @@ LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
 {
   SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
-  SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
+  SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
   CORBA::Object_var obj;
-  SALOMEDS::GenericAttribute_var anAttr;
   SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
-  if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
-    SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-    CORBA::String_var aVal = anIOR->Value();
-    obj = myStudy->ConvertIORToObject(aVal);
+  if (!aSObj->_is_nil()) {
+    obj = aSObj->GetObject();
+    aSObj->UnRegister();
   }
   return obj;
 }