Salome HOME
updated copyright message
[plugins/blsurfplugin.git] / src / GUI / BLSURFPluginGUI_HypothesisCreator.cxx
index c064e484a021a7b08f1a0d28372d125e88518831..79c1060dbcb8f29e03d2aa5e4d2da3bcc6556994 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2023  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
@@ -83,7 +83,8 @@ enum {
   STD_TAB = 0,
   ADV_TAB,
   SMP_TAB,
-  ENF_TAB,
+  ENF_V_TAB,
+  ENF_M_TAB,
   PERIODICITY_TAB,
   HYPERPATCH_TAB,
   SMP_NAME_COLUMN =0,
@@ -104,7 +105,11 @@ enum {
   ENF_VER_ENTRY_COLUMN,
   ENF_VER_GROUP_COLUMN,
   ENF_VER_NB_COLUMNS,
-// Periodicity
+
+  // Enforced 1D meshes
+  ENF_MESH_NB_COLUMNS = 2,
+
+  // Periodicity
   PERIODICITY_OBJ_SOURCE_COLUMN = 0,
   PERIODICITY_OBJ_TARGET_COLUMN,
   PERIODICITY_P1_SOURCE_COLUMN,
@@ -713,39 +718,39 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   lay->addWidget( myTabWidget );
 
   myName = 0;
-  
+
   // basic parameters
   myStdGroup = new QWidget();
   QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
   aStdLayout->setSpacing( 6 );
   aStdLayout->setMargin( 11 );
-  
+
   if( isCreation() )
     myName = new QLineEdit( myStdGroup );
   myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
   if ( !hasGeom() ) {
     myStdWidget->myPhysicalMesh->removeItem( PhysicalLocalSize );
   }
-  
+
   int row = 0;
   if( isCreation() ) {
     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 );
-  
+
   row = 0;
   if( isCreation() )
     row = 1;
   aStdLayout->setRowStretch(row,1);
   aStdLayout->setColumnStretch(1,1);
 
-  
+
   // advanced parameters
   myAdvGroup = new QWidget();
   QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
   anAdvLayout->setSpacing( 6 );
-  anAdvLayout->setMargin( 11 );  
+  anAdvLayout->setMargin( 11 );
   myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
   anAdvLayout->addWidget( myAdvWidget );
 
@@ -756,7 +761,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
 
   //Layout
   QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
-  
+
   // Table
   mySizeMapTable = new QTreeWidget( mySmpGroup );
   mySizeMapTable ->setMinimumWidth(200);
@@ -951,7 +956,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
 
   anEnfLayout->addWidget(myEnforcedTreeWidget,     0, 0, ENF_VER_NB_LINES, 1);
   QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
-//  FACE AND VERTEX SELECTION
+  //  FACE AND VERTEX SELECTION
   //anEnfLayout2->addWidget(myEnfFaceWdg,             ENF_VER_FACE, 0, 1, 2);
   anEnfLayout2->addWidget(myEnfVertexWdg,           ENF_VER_VERTEX, 0, 1, 2);
   anEnfLayout2->addWidget(myXCoordLabel,            ENF_VER_X_COORD, 0, 1, 1);
@@ -970,6 +975,56 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
   anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
 
+  // ---------------------------
+  // Enforced meshes parameters
+  // ---------------------------
+
+  myEnfMeshGroup = new QWidget();
+  QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
+
+  myEnfMeshTableWdg = new QTableWidget(myEnfGroup);
+  //myEnfMeshTableWdg->setRowCount( 0 );
+  myEnfMeshTableWdg->setColumnCount( ENF_MESH_NB_COLUMNS );
+  myEnfMeshTableWdg->setSortingEnabled(true);
+  myEnfMeshTableWdg->verticalHeader()->hide();
+  myEnfMeshTableWdg->setHorizontalHeaderLabels( QStringList()
+                                                << tr( "ENF_NAME_COLUMN" )
+                                                << tr( "ENF_GROUP_COLUMN" ));
+  myEnfMeshTableWdg->horizontalHeader()->setStretchLastSection(true);
+  myEnfMeshTableWdg->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+  myEnfMeshTableWdg->setAlternatingRowColors(true);
+  myEnfMeshTableWdg->setSelectionMode(QAbstractItemView::ExtendedSelection);
+  myEnfMeshTableWdg->setSelectionBehavior(QAbstractItemView::SelectItems);
+  myEnfMeshTableWdg->resizeColumnsToContents();
+  //myEnfMeshTableWdg->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
+
+  myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE_EDGE, myEnfMeshGroup, /*multiSel=*/false);
+  myEnfMeshWdg->SetDefaultText(tr("ENF_SELECT_MESH"), "QLineEdit { color: grey }");
+
+  myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
+  myEnfMeshWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
+  myEnfMeshWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
+  myEnfMeshWdg->AvoidSimultaneousSelection(myAttSelWdg);
+
+  QLabel* enforcedGroupNameLabel = new QLabel( tr( "ENF_GROUP_LABEL" ), myEnfMeshGroup );
+  myEnforcedGroupName = new QLineEdit(myEnfMeshGroup);
+
+  myAddEnfMeshButton    = new QPushButton(tr("ENF_ADD"),myEnfMeshGroup);
+  myRemoveEnfMeshButton = new QPushButton(tr("ENF_REMOVE"),myEnfMeshGroup);
+
+  QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
+  anEnfMeshLayout2->addWidget(myEnfMeshWdg,             0, 0, 1, 2);
+  anEnfMeshLayout2->addWidget(enforcedGroupNameLabel,   1, 0, 1, 1);
+  anEnfMeshLayout2->addWidget(myEnforcedGroupName,      1, 1, 1, 1);
+  anEnfMeshLayout2->addWidget(myAddEnfMeshButton,       2, 0, 1, 2);
+  anEnfMeshLayout2->addWidget(myRemoveEnfMeshButton,    3, 0, 1, 2);
+  anEnfMeshLayout2->setRowStretch( 4, 1 );
+
+  anEnfMeshLayout->addWidget(myEnfMeshTableWdg, 0, 0, 5, 1);
+  anEnfMeshLayout->addLayout(anEnfMeshLayout2,  0, 1, 1, 1);
+  anEnfMeshLayout->setRowStretch( 2, 1 );
+
+
   // ---
   // Periodicity parameters
   myPeriodicityGroup = new QWidget( dlg() );
@@ -1010,8 +1065,8 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
   myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
   
-  size_t periodicityVisibleColumns = 2;
-  for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
+  int periodicityVisibleColumns = 2;
+  for (int column = 0; column < periodicityVisibleColumns; ++column) {
       myPeriodicityTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
       myPeriodicityTreeWidget->resizeColumnToContents(column);
   }
@@ -1200,7 +1255,8 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
   if ( hasGeom() ) {
     myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
-    myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
+    myTabWidget->insertTab( ENF_V_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
+    myTabWidget->insertTab( ENF_M_TAB, myEnfMeshGroup, tr( "ENF_MESH" ) );
     myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
     myTabWidget->insertTab( HYPERPATCH_TAB, hpGroup, tr( "BLSURF_HYPERPATCH_TAB" ));
   }
@@ -1208,47 +1264,55 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   {
     mySmpGroup->hide();
     myEnfGroup->hide();
+    myEnfMeshGroup->hide();
     myPeriodicityGroup->hide();
     hpGroup->hide();
   }
   myTabWidget->setCurrentIndex( STD_TAB );
 
-  connect( myAdvWidget->addBtn, SIGNAL( clicked() ),           this, SLOT( onAddOption() ) );
+  connect( myAdvWidget->addBtn, SIGNAL( clicked() ),                           SLOT( onAddOption() ) );
 
   // Size Maps
-  connect( addMapButton,        SIGNAL( clicked()),                    this,         SLOT( onAddMap() ) );
-  connect( removeMapButton,     SIGNAL( clicked()),                    this,         SLOT( onRemoveMap() ) );
-  connect( modifyMapButton,     SIGNAL( clicked()),                    this,         SLOT( onModifyMap() ) );
-  connect( mySizeMapTable,      SIGNAL( itemClicked (QTreeWidgetItem *, int)),this,  SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
-  connect( myGeomSelWdg2,       SIGNAL( contentModified() ),           this,         SLOT( onMapGeomContentModified() ) );
-  connect( myGeomSelWdg1,       SIGNAL( contentModified() ),           this,         SLOT( onMapGeomContentModified() ) );
-  connect( myAttSelWdg,         SIGNAL( contentModified() ),           this,         SLOT( onMapGeomContentModified() ) );
-  connect( mySizeMapTable,      SIGNAL( itemChanged (QTreeWidgetItem *, int)),this,  SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
-  connect( myAttractorCheck,    SIGNAL( stateChanged ( int )),         this,         SLOT( onAttractorClicked( int ) ) );
-  connect( myConstSizeCheck,    SIGNAL( stateChanged ( int )),         this,         SLOT( onConstSizeClicked( int ) ) );
-  connect( smpTab,              SIGNAL( currentChanged ( int )),       this,         SLOT( onTabChanged( int ) ) );
-  connect( myTabWidget,         SIGNAL( currentChanged ( int )),       this,         SLOT( onTabChanged( int ) ) );
+  connect( addMapButton,        SIGNAL( clicked()),                            SLOT( onAddMap() ) );
+  connect( removeMapButton,     SIGNAL( clicked()),                            SLOT( onRemoveMap() ) );
+  connect( modifyMapButton,     SIGNAL( clicked()),                            SLOT( onModifyMap() ) );
+  connect( mySizeMapTable,      SIGNAL( itemClicked (QTreeWidgetItem *, int)), SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
+  connect( myGeomSelWdg2,       SIGNAL( contentModified() ),                   SLOT( onMapGeomContentModified() ) );
+  connect( myGeomSelWdg1,       SIGNAL( contentModified() ),                   SLOT( onMapGeomContentModified() ) );
+  connect( myAttSelWdg,         SIGNAL( contentModified() ),                   SLOT( onMapGeomContentModified() ) );
+  connect( mySizeMapTable,      SIGNAL( itemChanged (QTreeWidgetItem *, int)), SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
+  connect( myAttractorCheck,    SIGNAL( stateChanged ( int )),                 SLOT( onAttractorClicked( int ) ) );
+  connect( myConstSizeCheck,    SIGNAL( stateChanged ( int )),                 SLOT( onConstSizeClicked( int ) ) );
+  connect( smpTab,              SIGNAL( currentChanged ( int )),               SLOT( onTabChanged( int ) ) );
+  connect( myTabWidget,         SIGNAL( currentChanged ( int )),               SLOT( onTabChanged( int ) ) );
 
   // Enforced vertices
-  connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this,  SLOT( synchronizeCoords() ) );
-  connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this,  SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
-  connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ),      this,         SLOT( synchronizeCoords() ) );
-  connect( addVertexButton,     SIGNAL( clicked()),                    this,         SLOT( onAddEnforcedVertices() ) );
-  connect( removeVertexButton,  SIGNAL( clicked()),                    this,         SLOT( onRemoveEnforcedVertex() ) );
-  connect( myEnfVertexWdg,      SIGNAL( contentModified()),            this,         SLOT( onSelectEnforcedVertex() ) );
-  connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this,  SLOT( onInternalVerticesClicked( int ) ) );
+  connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)),  SLOT( synchronizeCoords() ) );
+  connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)),  SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
+  connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ),              SLOT( synchronizeCoords() ) );
+  connect( addVertexButton,     SIGNAL( clicked()),                            SLOT( onAddEnforcedVertices() ) );
+  connect( removeVertexButton,  SIGNAL( clicked()),                            SLOT( onRemoveEnforcedVertex() ) );
+  connect( myEnfVertexWdg,      SIGNAL( contentModified()),                    SLOT( onSelectEnforcedVertex() ) );
+  connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )),  SLOT( onInternalVerticesClicked( int ) ) );
+
+  // Enforced mesh
+  connect( myAddEnfMeshButton,    SIGNAL( clicked()),              SLOT( onAddEnforcedMesh()));
+  connect( myRemoveEnfMeshButton, SIGNAL( clicked()),              SLOT( onRemoveEnforcedMesh()));
+  connect( myEnfMeshWdg,          SIGNAL( contentModified()),      SLOT( onEnforcedMeshSelected()));
+  connect( myEnfMeshTableWdg,     SIGNAL( itemSelectionChanged()), SLOT( onEnfMeshTableSelected()));
+
 
   // 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)));
+  connect( myPeriodicityAddButton,     SIGNAL( clicked()),                     SLOT( onAddPeriodicity() ) );
+  connect( myPeriodicityRemoveButton,  SIGNAL( clicked()),                     SLOT( onRemovePeriodicity() ) );
+  connect( myPeriodicityTreeWidget,    SIGNAL( itemClicked(QTreeWidgetItem*, int)), SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
+  connect( myPeriodicityGroupBox2,     SIGNAL(toggled(bool)),                  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( w1, SIGNAL( contentModified ()), SLOT( onPeriodicityContentModified() ));
 
   }
 
@@ -1299,7 +1363,8 @@ void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
     This method updates the tooltip of a modified item. The QLineEdit widgets content
     is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
 */
-void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int /*column*/) {
+void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int /*column*/)
+{
   QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
   QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
   QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
@@ -1336,8 +1401,9 @@ void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetIt
   }
 }
 
-void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
-  int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
+void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex()
+{
+  size_t nbSelEnfVertex = myEnfVertexWdg->NbObjects();
   clearEnforcedVertexWidgets();
   if (nbSelEnfVertex == 1)
   {
@@ -1366,7 +1432,8 @@ void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
 of the enforced vertex clicked in the tree widget.
 */
-void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
+void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
+{
   clearEnforcedVertexWidgets();
   QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
   if (! items.isEmpty() && items.size() == 1) {
@@ -1393,7 +1460,8 @@ void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
 This method adds a face containing enforced vertices in the tree widget.
 */
-QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
+QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName)
+{
   // Find theFaceEntry item
   QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
   QTreeWidgetItem* theItem;
@@ -1503,7 +1571,7 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
     myEnforcedTreeWidget->resizeColumnToContents(column);
 
   // Vertex selection
-  int selEnfVertex = myEnfVertexWdg->NbObjects();
+  size_t selEnfVertex = myEnfVertexWdg->NbObjects();
   bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
 
   if ((selEnfVertex == 0) && coordsEmpty)
@@ -1537,7 +1605,7 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
 
       CORBA::Double x,y,z;
       x = y = z = 0.;
-      for (int j = 0 ; j < selEnfVertex ; j++)
+      for (size_t j = 0 ; j < selEnfVertex ; j++)
       {
         myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
         if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
@@ -1565,7 +1633,8 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
 This method is called when a item is removed from the enforced vertices tree widget
 */
-void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
+void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
+{
   QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
   QList<QTreeWidgetItem *> selectedVertices;
   QSet<QTreeWidgetItem *> selectedEntries;
@@ -1612,8 +1681,8 @@ void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
 This method is called when a item is added into the periodicity table widget
 */
-void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
-
+void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
+{
   BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
 
   that->getGeomSelectionTool()->selectionMgr()->clearFilters();
@@ -1626,8 +1695,8 @@ void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
 
 
   // Source-Target selection
-  int selSource = myPeriodicitySourceFaceWdg->NbObjects();
-  int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
+  size_t selSource = myPeriodicitySourceFaceWdg->NbObjects();
+  size_t selTarget = myPeriodicityTargetFaceWdg->NbObjects();
 
   if (selSource == 0 || selTarget == 0)
     return;
@@ -1635,12 +1704,12 @@ void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
   // 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();
+      size_t P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
+      size_t P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
+      size_t P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
+      size_t P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
+      //size_t P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
+      size_t P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
 
       if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
         {
@@ -1661,7 +1730,7 @@ void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
   item->setFlags( Qt::ItemIsSelectable   |Qt::ItemIsEnabled );
 
 
-  size_t k=0;
+  int k=0;
   for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
     {
       StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
@@ -1693,7 +1762,8 @@ void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
 This method is called when a item is removed from the periodicity tree widget
 */
-void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
+void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
+{
   QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
   QTreeWidgetItem* item;
 
@@ -1745,7 +1815,7 @@ void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem
 {
   QString shapeName, shapeEntry;
   CORBA::Object_var shape;
-  size_t k=0;
+  int k=0;
   ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
   for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
     {
@@ -2013,12 +2083,13 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
     {
       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() );
+      item->setData((int) k, Qt::EditRole, shapeName.c_str() );
+      item->setData((int) k, Qt::UserRole, shapeEntry.c_str() );
     }
   }
 
   // Hyper patches
+
   QString patchEntries;
   for ( int i = 0; i < data.hyperpatches.size(); ++i )
   {
@@ -2030,6 +2101,18 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
   that->myStdWidget->onPhysicalMeshChanged();
   that->myStdWidget->onGeometricMeshChanged();
   that->onStateChange();
+
+  // Enforced mesh
+
+  BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
+    BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
+
+  BLSURFPlugin::EnforcedMeshesList_var enfMeshes = h->GetEnforcedMeshes();
+  for ( CORBA::ULong i = 0; i < enfMeshes->length(); ++i )
+  {
+    BLSURFPlugin::MG_EnforcedMesh1D & enfMesh = enfMeshes[i];
+    that->addEnforcedMesh( enfMesh.mesh.in(), enfMesh.groupName.in() );
+  }
 }
 
 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
@@ -2128,7 +2211,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
     fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
     if ( fullSizeMapList.count() > 1 ) {
       string fullSizeMap = fullSizeMapList[1].toStdString();
-      int pos = fullSizeMap.find("return")+7;
+      size_t pos = fullSizeMap.find("return")+7;
       QString sizeMap;
       try {
         sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
@@ -2270,7 +2353,7 @@ void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothes
     BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
 {
 
-  for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
+  for (CORBA::ULong i=0; i<preCadFacePeriodicityVector->length(); i++ )
     {
       TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
       periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
@@ -2355,11 +2438,11 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
     if ( h->GetVolumeGradation() !=  h_data.myVolumeGradation )
       h->SetVolumeGradation( h_data.myVolumeGradation <= 0 ? -1 : h_data.myVolumeGradation );
 
-    h->SetSurfaceProximity        ( h_data.myUseSurfaceProximity      );
-    h->SetNbSurfaceProximityLayers( h_data.myNbSurfaceProximityLayers );
+    h->SetSurfaceProximity        ((CORBA::Short) h_data.myUseSurfaceProximity      );
+    h->SetNbSurfaceProximityLayers((CORBA::Short) h_data.myNbSurfaceProximityLayers );
     h->SetSurfaceProximityRatio   ( h_data.mySurfaceProximityRatio    );
-    h->SetVolumeProximity         ( h_data.myUseVolumeProximity       );
-    h->SetNbVolumeProximityLayers ( h_data.myNbVolumeProximityLayers  );
+    h->SetVolumeProximity         ((CORBA::Short) h_data.myUseVolumeProximity       );
+    h->SetNbVolumeProximityLayers ((CORBA::Short) h_data.myNbVolumeProximityLayers  );
     h->SetVolumeProximityRatio    ( h_data.myVolumeProximityRatio     );
 
     if ( h->GetElementType() != h_data.myElementType )
@@ -2403,7 +2486,7 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
       h->SetQuadraticMesh( h_data.myQuadraticMesh );
 
     if ( h->GetVerbosity() != h_data.myVerbosity )
-      h->SetVerbosity( h_data.myVerbosity );
+      h->SetVerbosity((CORBA::Short) h_data.myVerbosity );
     // if ( h->GetTopology() != h_data.myTopology )
     //   h->SetTopology( (int) h_data.myTopology );
     // if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
@@ -2583,6 +2666,31 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
       h->SetHyperPatches( hpl );
 
 
+    // Enforced meshes
+    BLSURFPlugin::EnforcedMeshesList_var enfMeshesList = new BLSURFPlugin::EnforcedMeshesList();
+    enfMeshesList->length( myEnfMeshTableWdg->rowCount() );
+
+    int nbMeshes = 0;
+    for ( int row = 0, nbRow = myEnfMeshTableWdg->rowCount(); row < nbRow; ++row )
+    {
+      QTableWidgetItem *  meshCell = myEnfMeshTableWdg->item( row, 0 );
+      QString                entry = meshCell->data( Qt::UserRole ).toString();
+      QTableWidgetItem * groupCell = myEnfMeshTableWdg->item( row, 1 );
+      QString            groupName = groupCell->text();
+
+      SMESH::SMESH_IDSource_var mesh = SMESH::EntryToInterface< SMESH::SMESH_IDSource >( entry );
+      if ( !mesh->_is_nil() )
+      {
+        enfMeshesList[ nbMeshes ].mesh = SMESH::SMESH_IDSource::_duplicate( mesh );
+        enfMeshesList[ nbMeshes ].groupName = CORBA::string_dup( groupName.toStdString().c_str() );
+        ++nbMeshes;
+      }
+    }
+    enfMeshesList->length( nbMeshes );
+
+    h->SetEnforcedMeshes( enfMeshesList );
+
+
   } // try
   catch(...) {
     ok = false;
@@ -2809,7 +2917,7 @@ void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
 }
 
 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
-{ 
+{
   BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
   if (col == SMP_SIZEMAP_COLUMN) {
     QString entry   = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
@@ -2833,7 +2941,7 @@ void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item,
       const TAttractorVec& attVec = myATTMap[entry];
       if ( !attVec.empty() )
       {
-        int iAtt = 0;
+        size_t iAtt = 0;
         if ( !childEntry.isEmpty() )
           for ( size_t i = 0; i < attVec.size(); ++i )
             if ( childEntry == attVec[i].attEntry.c_str() )
@@ -2892,6 +3000,7 @@ void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
     myPeriodicityP1TargetWdg  ->deactivateSelection();
     myPeriodicityP2TargetWdg  ->deactivateSelection();
     myPeriodicityP3TargetWdg  ->deactivateSelection();
+    myEnfMeshWdg              ->deactivateSelection();
     if ( myHyPatchFaceSelBtn->isChecked() )
       myHyPatchFaceSelBtn->toggle();
     if ( myHyPatchGroupSelBtn->isChecked() )
@@ -2928,6 +3037,15 @@ void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
     mySmpSizeSpin->RangeStepAndValidator(minSize, maxSize, 1.0, "length_precision");
     myAttSizeSpin->RangeStepAndValidator(minSize, maxSize, 1.0, "length_precision");
   }
+
+  if ( tab == ENF_M_TAB )
+  {
+    myEnfMeshWdg->activateSelection();
+    onEnforcedMeshSelected(); // update buttons
+    onEnfMeshTableSelected();
+    if ( myEnforcedGroupName->text().isEmpty() )
+      myEnforcedGroupName->setText("Group 1D");
+  }
 }
 
 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
@@ -3567,6 +3685,153 @@ void BLSURFPluginGUI_HypothesisCreator::onHyPatchRemove()
   }
 }
 
+//================================================================================
+/*!
+ * \brief Add a new row in Enforced mesh table
+ */
+//================================================================================
+
+void BLSURFPluginGUI_HypothesisCreator::addEnforcedMesh( SMESH::SMESH_IDSource_ptr mesh,
+                                                         const QString&            groupName  )
+{
+  _PTR(SObject) sobj = SMESH::FindSObject( mesh );
+  if ( !sobj )
+    return;
+
+  QString meshEntry = sobj->GetID().c_str();
+  QString meshName  = sobj->GetName().c_str();
+
+  QTableWidgetItem* meshCell = new QTableWidgetItem( meshName );
+  meshCell->setData( Qt::UserRole, meshEntry );
+  meshCell->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+
+  QTableWidgetItem* groupCell = new QTableWidgetItem( groupName );
+  groupCell->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable );
+
+  int row = myEnfMeshTableWdg->rowCount();
+  myEnfMeshTableWdg->insertRow( row );
+  myEnfMeshTableWdg->setItem( row, 0, meshCell );
+  myEnfMeshTableWdg->setItem( row, 1, groupCell );
+
+  myEnfMeshTableWdg->resizeColumnToContents( 0 );
+  myEnfMeshTableWdg->resizeColumnToContents( 1 );
+}
+
+//================================================================================
+/*!
+ * \brief SLOT called when [Add] is clicked in Enforced mesh tab.
+ *        Add an item to the enforced meshes table
+ */
+//================================================================================
+
+void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedMesh()
+{
+  if ( myEnfMeshWdg->NbObjects() != 1 )
+    return;
+
+  SMESH::SMESH_IDSource_var mesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
+  QString              groupName = myEnforcedGroupName->text().simplified();
+
+  addEnforcedMesh( mesh, groupName );
+
+  selectionMgr()->clearSelected();
+  myEnfMeshWdg->SetObject( SMESH::SMESH_IDSource::_nil() );
+}
+
+//================================================================================
+/*!
+ * \brief SLOT called when [Remove] is clicked in Enforced mesh tab.
+ *        Remove a selected mesh from the enforced meshes table
+ */
+//================================================================================
+
+void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
+{
+  QList<int> selectedRows;
+  QList<QTableWidgetItem *> selectedItems = myEnfMeshTableWdg->selectedItems();
+  QTableWidgetItem* item;
+  int row;
+  foreach( item, selectedItems )
+  {
+    row = item->row();
+    if (!selectedRows.contains( row ) )
+      selectedRows.append(row);
+  }
+
+  qSort( selectedRows );
+  QListIterator<int> it( selectedRows );
+  it.toBack();
+  while ( it.hasPrevious() ) {
+    row = it.previous();
+    myEnfMeshTableWdg->removeRow(row );
+  }
+
+  myEnfMeshTableWdg->selectionModel()->clearSelection();
+
+  onEnforcedMeshSelected(); // to activate [Add] if possible
+}
+
+//================================================================================
+/*!
+ * \brief SLOT called when mesh selection changes. Enable/disable [Add] button
+ */
+//================================================================================
+
+void BLSURFPluginGUI_HypothesisCreator::onEnforcedMeshSelected()
+{
+  bool enable = ( myEnfMeshWdg->NbObjects() == 1 );
+  if ( enable )
+  {
+    // check if a selected mesh contains segments
+    SMESH::SMESH_IDSource_var mesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
+    if (( enable = !mesh->_is_nil() ))
+    {
+      SMESH::array_of_ElementType_var types = mesh->GetTypes();
+      if (( enable = ( types->length() > 0 )))
+      {
+        enable = false;
+        for ( CORBA::ULong i = 0; i < types->length() &&  !enable; ++i )
+          enable = ( types[ i ] = SMESH::EDGE );
+      }
+    }
+
+    // check if this mesh is already in the table
+    if ( enable )
+    {
+      _PTR(SObject) sobj = SMESH::FindSObject( mesh );
+      if (( enable = bool( sobj )))
+      {
+        QString meshEntry = sobj->GetID().c_str();
+        for ( int row = 0, nbRow = myEnfMeshTableWdg->rowCount(); row < nbRow &&  enable; ++row )
+        {
+          QTableWidgetItem * cell = myEnfMeshTableWdg->item( row, 0 );
+          enable = ( meshEntry != cell->data( Qt::UserRole ).toString() );
+        }
+      }
+    }
+  }
+  myAddEnfMeshButton->setEnabled( enable );
+}
+
+//================================================================================
+/*!
+ * \brief SLOT called when selection changes in the table. Enable/disable [Remove] button
+ */
+//================================================================================
+
+void BLSURFPluginGUI_HypothesisCreator::onEnfMeshTableSelected()
+{
+  bool enable = !myEnfMeshTableWdg->selectedItems().empty();
+
+  myRemoveEnfMeshButton->setEnabled( enable );
+}
+
+//================================================================================
+/*!
+ * \brief Return false if algorithm is a re-mesher
+ */
+//================================================================================
+
 bool BLSURFPluginGUI_HypothesisCreator::hasGeom() const
 {
   return hypType() == BLSURFPlugin_Hypothesis::GetHypType(true);