Salome HOME
0020746: EDF 1274 SMESH : MergeAllNodesButNodesFromGroup feature
authorvsr <vsr@opencascade.com>
Mon, 27 Sep 2010 06:17:50 +0000 (06:17 +0000)
committervsr <vsr@opencascade.com>
Mon, 27 Sep 2010 06:17:50 +0000 (06:17 +0000)
doc/salome/gui/SMESH/images/mergenodes.png
doc/salome/gui/SMESH/images/mergenodes_auto.png
doc/salome/gui/SMESH/input/merging_nodes.doc
src/SMESHGUI/SMESHGUI_MergeDlg.cxx
src/SMESHGUI/SMESHGUI_MergeDlg.h
src/SMESHGUI/SMESH_msg_en.ts

index 024bc22..54cb3d1 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/mergenodes.png and b/doc/salome/gui/SMESH/images/mergenodes.png differ
index b292086..71511d2 100644 (file)
Binary files a/doc/salome/gui/SMESH/images/mergenodes_auto.png and b/doc/salome/gui/SMESH/images/mergenodes_auto.png differ
index eb17e0a..3b1bbea 100644 (file)
@@ -2,17 +2,18 @@
 
 \page merging_nodes_page Merging nodes
 
-\n This functionality allows user to detect groups of coincident nodes
-with desirable tolerance, edit these groups and merge.
+This functionality allows user to detect groups of coincident nodes
+with specified tolerance; each group of the coincident nodes can be
+then converted to the single node.
 
 \image html mergenodes_ico.png "Merge nodes button"
 
 <em>To merge nodes of your mesh:</em>
 <ol>
-<li>From the \b Modification choose \b Transformation and  from its
+<li>From the \b Modification choose \b Transformation and from its
 sub-menu select the <b>Merge nodes</b> item. The following dialog box
 shall appear:</li>
-
+<br>
 \image html mergenodes_auto.png
 <br>
 <ul>
@@ -21,13 +22,16 @@ shall appear:</li>
 processed.
 <li>\b Tolerance is a maximum distance between nodes sufficient for
 merging.</li>
+<li><b>Exclude Groups</b> group box allows to ignore the nodes which
+belong to the specified mesh groups.
 </ul>
 
 <li><b>Automatic mode:</b>
 <br>
 <ul>
 <li>In the \b Automatic Mode all Nodes within the indicated tolerance
-will be merged.</li>
+will be merged. The nodes which belong to the groups specified in the
+<b>Exclude Groups</b> will be not taken into account.</li>
 </ul>
 </li><br>
 <li>If the \b Manual Mode is selected, additional controls are available:
@@ -44,8 +48,9 @@ viewer with pressed "Shift" key.</li>
 <li><b>Select all</b> checkbox selects all groups.</li>
 </ul>
 
+<br>
 \image html mergenodes.png
-
+<br>
 </li>
 <li><b>Edit selected group</b> list allows editing the selected
 group:
index ff37f9f..26922e9 100644 (file)
@@ -391,29 +391,43 @@ SMESHGUI_MergeDlg::SMESHGUI_MergeDlg (SMESHGUI* theModule, int theAction)
                                   this);
 
   QVBoxLayout* aCoincidentLayout = new QVBoxLayout(GroupCoincident);
+  aCoincidentLayout->setSpacing(SPACING);
+  aCoincidentLayout->setMargin(MARGIN);
 
-  GroupCoincident->setLayout(aCoincidentLayout);
-
-  QHBoxLayout* aSpinBoxLayout = new QHBoxLayout( GroupCoincident );
-  
   if (myAction == 0) { // case merge nodes
-    TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupCoincident);
-    SpinBoxTolerance = new SMESHGUI_SpinBox(GroupCoincident);
+    QWidget* foo = new QWidget(GroupCoincident);
+    TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), foo);
+    SpinBoxTolerance = new SMESHGUI_SpinBox(foo);
     SpinBoxTolerance->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
 
-    aSpinBoxLayout->addWidget(TextLabelTolerance);
-    aSpinBoxLayout->addWidget(SpinBoxTolerance);
-    aCoincidentLayout->addLayout(aSpinBoxLayout);
+    GroupExclude = new QGroupBox(tr("EXCLUDE_GROUPS"), foo);
+    GroupExclude->setCheckable( true );
+    GroupExclude->setChecked( false );
+    ListExclude = new QListWidget( GroupExclude );
+    QVBoxLayout* GroupExcludeLayout = new QVBoxLayout(GroupExclude);
+    GroupExcludeLayout->setSpacing(SPACING);
+    GroupExcludeLayout->setMargin(MARGIN);
+    GroupExcludeLayout->addWidget(ListExclude);
+
+    QGridLayout* fooLayout = new QGridLayout( foo );
+    fooLayout->setSpacing(SPACING);
+    fooLayout->setMargin(0);
+    fooLayout->addWidget(TextLabelTolerance, 0, 0 );
+    fooLayout->addWidget(SpinBoxTolerance,   0, 1 );
+    fooLayout->addWidget(GroupExclude,       1, 0, 1, 2 );
+    aCoincidentLayout->addWidget(foo);
   }
   else {
     TextLabelTolerance = 0;
     SpinBoxTolerance = 0;
+    GroupExclude = 0;
+    ListExclude = 0;
   }
 
   GroupCoincidentWidget = new QWidget(GroupCoincident);
   QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincidentWidget);
   GroupCoincidentLayout->setSpacing(SPACING);
-  GroupCoincidentLayout->setMargin(MARGIN);
+  GroupCoincidentLayout->setMargin(0);
 
   ListCoincident = new QListWidget(GroupCoincidentWidget);
   ListCoincident->setSelectionMode(QListWidget::ExtendedSelection);
@@ -424,11 +438,6 @@ SMESHGUI_MergeDlg::SMESHGUI_MergeDlg (SMESHGUI* theModule, int theAction)
 
   SelectAllCB = new QCheckBox(tr("SELECT_ALL"), GroupCoincidentWidget);
 
-  if (myAction == 0)
-    GroupCoincidentWidget->hide();
-  else
-    GroupCoincident->hide();
-
   GroupCoincidentLayout->addWidget(ListCoincident,    0,   0, 4, 2);
   GroupCoincidentLayout->addWidget(DetectButton,      0,   2);
   GroupCoincidentLayout->addWidget(AddGroupButton,    2, 2);
@@ -465,8 +474,6 @@ SMESHGUI_MergeDlg::SMESHGUI_MergeDlg (SMESHGUI* theModule, int theAction)
   GroupEditLayout->addWidget(RemoveElemButton, 0, 2);
   GroupEditLayout->addWidget(SetFirstButton,   1, 1, 1, 2);
 
-  GroupEdit->hide();
-
   /***************************************************************/
   GroupButtons = new QGroupBox(this);
   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
@@ -499,6 +506,11 @@ SMESHGUI_MergeDlg::SMESHGUI_MergeDlg (SMESHGUI* theModule, int theAction)
   DlgLayout->addWidget(GroupEdit);
   DlgLayout->addWidget(GroupButtons);
 
+  GroupCoincidentWidget->setVisible( myAction != 0 );
+  GroupCoincident->setVisible( myAction == 0 );
+  //if GroupExclude->setVisible( myAction == 0 );
+  GroupEdit->hide();
+
   this->resize(10,10);
 
   Init(); // Initialisations
@@ -783,19 +795,27 @@ void SMESHGUI_MergeDlg::onDetect()
     ListEdit->clear();
 
     SMESH::array_of_long_array_var aGroupsArray;
+    SMESH::ListOfIDSources_var aExcludeGroups = new SMESH::ListOfIDSources;
+
+    SMESH::SMESH_IDSource_var src;
+    if ( mySubMeshOrGroup->_is_nil() ) src = SMESH::SMESH_IDSource::_duplicate( myMesh );
+    else src = SMESH::SMESH_IDSource::_duplicate( mySubMeshOrGroup );
 
     switch (myAction) {
     case 0 :
-      if(!mySubMeshOrGroup->_is_nil())
-        aMeshEditor->FindCoincidentNodesOnPart(mySubMeshOrGroup, SpinBoxTolerance->GetValue(), aGroupsArray);
-      else
-        aMeshEditor->FindCoincidentNodes(SpinBoxTolerance->GetValue(), aGroupsArray);
+      for ( int i = 0; GroupExclude->isChecked() && i < ListExclude->count(); i++ ) {
+       if ( ListExclude->item( i )->checkState() == Qt::Checked ) {
+         aExcludeGroups->length( aExcludeGroups->length()+1 );
+         aExcludeGroups[ aExcludeGroups->length()-1 ] = SMESH::SMESH_IDSource::_duplicate( myGroups[i] );
+       }
+      }
+      aMeshEditor->FindCoincidentNodesOnPartBut(src.in(),
+                                               SpinBoxTolerance->GetValue(), 
+                                               aGroupsArray.out(),
+                                               aExcludeGroups.in());
       break;
     case 1 :
-      if(!mySubMeshOrGroup->_is_nil())
-        aMeshEditor->FindEqualElements(mySubMeshOrGroup, aGroupsArray);
-      else
-        aMeshEditor->FindEqualElements(myMesh, aGroupsArray);
+      aMeshEditor->FindEqualElements(src.in(), aGroupsArray.out());
       break;
     }
     
@@ -1082,6 +1102,7 @@ void SMESHGUI_MergeDlg::SelectionIntoArgument()
     ListCoincident->clear();
     ListEdit->clear();
     myActor = 0;
+    QString aCurrentEntry = myEntry;
     
     int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
     if (nbSel != 1) {
@@ -1097,6 +1118,7 @@ void SMESHGUI_MergeDlg::SelectionIntoArgument()
     mySelectionMgr->selectedObjects(aList);
     
     Handle(SALOME_InteractiveObject) IO = aList.First();
+    myEntry = IO->getEntry();
     myMesh = SMESH::GetMeshByIO(IO);
     
     if (myMesh->_is_nil())
@@ -1127,6 +1149,26 @@ void SMESHGUI_MergeDlg::SelectionIntoArgument()
           aViewWindow->SetSelectionMode(CellSelection);
     }
 
+    // process groups
+    if ( myAction == 0 && !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
+      myGroups.clear();
+      ListExclude->clear();
+      SMESH::ListOfGroups_var aListOfGroups = myMesh->GetGroups();
+      for( int i = 0, n = aListOfGroups->length(); i < n; i++ ) {
+       SMESH::SMESH_GroupBase_var aGroup = aListOfGroups[i];
+       if ( !aGroup->_is_nil() ) { // && aGroup->GetType() == SMESH::NODE
+         QString aGroupName( aGroup->GetName() );
+         if ( !aGroupName.isEmpty() ) {
+           myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup));
+           QListWidgetItem* item = new QListWidgetItem( aGroupName );
+           item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
+           item->setCheckState( Qt::Unchecked );
+           ListExclude->addItem( item );
+         }
+       }
+      }
+    }
+
     updateControls();
   }
 }
index 30f3237..73dce16 100644 (file)
@@ -89,6 +89,8 @@ private:
   // add the centers of gravity of ElemsIdMap elements to the GrCentersXYZ list
 
 private:
+  typedef QList<SMESH::SMESH_GroupBase_var> GrpList;
+
   SMESHGUI*                 mySMESHGUI;     /* Current SMESHGUI object */
   LightApp_SelectionMgr*    mySelectionMgr; /* User shape selection */
   SVTK_Selector*            mySelector;
@@ -137,11 +139,17 @@ private:
   QPushButton*              RemoveElemButton;
   QPushButton*              SetFirstButton;
 
+  QGroupBox*                GroupExclude;
+  QListWidget*              ListExclude;
+
   QGroupBox*                TypeBox;
   QButtonGroup*             GroupType;
     
   QString                   myHelpFileName;
 
+  QString                   myEntry;
+  GrpList                   myGroups;
+
  private slots:
   void                      ClickOnOk();
   void                      ClickOnCancel();
index 56554a3..b883c89 100644 (file)
@@ -3779,6 +3779,10 @@ Please select a groups and try again</translation>
         <source>SELECT_ALL</source>
         <translation>Select all</translation>
     </message>
+    <message>
+        <source>EXCLUDE_GROUPS</source>
+        <translation>Exclude Groups</translation>
+    </message>
 </context>
 <context>
     <name>SMESHGUI_ExtrusionAlongPathDlg</name>