]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
0020742: EDF 1270 SMESH : Delete Group with contents and remove Orphan Nodes
authorvsr <vsr@opencascade.com>
Wed, 7 Jul 2010 05:32:15 +0000 (05:32 +0000)
committervsr <vsr@opencascade.com>
Wed, 7 Jul 2010 05:32:15 +0000 (05:32 +0000)
17 files changed:
doc/salome/gui/SMESH/images/remove_nodes_icon.png [new file with mode: 0644]
doc/salome/gui/SMESH/images/remove_orphan_nodes_icon.png [new file with mode: 0644]
doc/salome/gui/SMESH/images/removeorphannodes.png [new file with mode: 0644]
doc/salome/gui/SMESH/input/removing_nodes_and_elements.doc
doc/salome/gui/SMESH/input/tui_modifying_meshes.doc
idl/SMESH_MeshEditor.idl
resources/Makefile.am
resources/mesh_rem_orphan_nodes.png [new file with mode: 0644]
src/SMESH/SMESH_MeshEditor.cxx
src/SMESH/SMESH_MeshEditor.hxx
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESH_images.ts
src/SMESHGUI/SMESH_msg_en.ts
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.hxx
src/SMESH_SWIG/smeshDC.py

diff --git a/doc/salome/gui/SMESH/images/remove_nodes_icon.png b/doc/salome/gui/SMESH/images/remove_nodes_icon.png
new file mode 100644 (file)
index 0000000..0818837
Binary files /dev/null and b/doc/salome/gui/SMESH/images/remove_nodes_icon.png differ
diff --git a/doc/salome/gui/SMESH/images/remove_orphan_nodes_icon.png b/doc/salome/gui/SMESH/images/remove_orphan_nodes_icon.png
new file mode 100644 (file)
index 0000000..16df2e5
Binary files /dev/null and b/doc/salome/gui/SMESH/images/remove_orphan_nodes_icon.png differ
diff --git a/doc/salome/gui/SMESH/images/removeorphannodes.png b/doc/salome/gui/SMESH/images/removeorphannodes.png
new file mode 100644 (file)
index 0000000..fdf8395
Binary files /dev/null and b/doc/salome/gui/SMESH/images/removeorphannodes.png differ
index 6cd89157302553b8021384a5022ca7837bd47ae1..2ba731240e39c9b17e868eb7da77374d74f636ab 100644 (file)
@@ -6,6 +6,7 @@
 
 <ul>
 <li>\ref removing_nodes_anchor "Nodes"</li>
+<li>\ref removing_orphan_nodes_anchor "Orphan Nodes"</li>
 <li>\ref removing_elements_anchor "Elements"</li>
 <li>\ref clear_mesh_anchor "Clear Mesh Data"</li>
 </ul>
 <ol>
 <li>Select your mesh in the Object Browser or in the 3D viewer.</li>
 
-<li>From the Modification menu choose Remove and from the associated
-submenu select the Remove nodes, or just click <em>"Remove nodes"</em>
+<li>From the <em>Modification</em> menu choose <em>Remove</em> and from the associated
+submenu select the <em>Nodes</em>, or just click <em>"Remove nodes"</em>
 button in the toolbar.
 
-\image html image88.gif
+\image html remove_nodes_icon.png
 <center><em>"Remove nodes" button</em></center>
 
 The following dialog box will appear:
@@ -46,6 +47,29 @@ about filters in the \ref selection_filter_library_page "Selection filter librar
 \note Be careful while removing nodes because if you remove a definite
 node of your mesh all adjacent elements will be also deleted.
 
+<br>
+\anchor removing_orphan_nodes_anchor
+<h2>Removing orphan nodes</h2>
+
+There is a quick way to remove all the orphan (free) nodes.
+
+<em>To remove the orphan nodes:</em>
+<ol>
+<li>Select your mesh in the Object Browser or in the 3D viewer.</li>
+
+<li>From the <em>Modification</em> menu choose <em>Remove</em> and from the associated
+submenu select the <em>Orphan Nodes</em>, or just click <em>"Remove orphan nodes"</em>
+button in the toolbar.
+
+\image html remove_orphan_nodes_icon.png
+<center><em>"Remove orphan nodes" button</em></center>
+
+The following Warning message box will appear:
+
+\image html removeorphannodes.png
+
+Confirm removing nodes by pressing "Yes" button.
+
 <br>
 \anchor removing_elements_anchor
 <h2>Removing elements</h2>
@@ -54,8 +78,8 @@ node of your mesh all adjacent elements will be also deleted.
 <ol>
 <li>Select your mesh in the Object Browser or in the 3D viewer.</li>
 
-<li>From the \b Modification menu choose \b Remove and from the
-associated submenu select the Remove elements, or just click
+<li>From the <em>Modification</em> menu choose <em>Remove</em> and from the
+associated submenu select the <em>Elements</em>, or just click
 <em>"Remove elements"</em> button in the toolbar.
 
 \image html remove_elements_icon.png
index 8eee4e048699bc9827af342f78838fc78f7b4cfd..fe0da8e6114220dce3e51da19a9eb6d14019cd6f 100644 (file)
@@ -281,6 +281,24 @@ if res == 1: print "Elements removing is OK!"
 else:        print "KO Elements removing."
 \endcode
 
+<br>
+\anchor tui_removing_orphan_nodes
+<h3>Removing Orphan Nodes</h3>
+
+\code
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+
+# add orphan nodes
+mesh.AddNode(0,0,0)
+mesh.AddNode(1,1,1)
+# remove just created orphan nodes
+res = mesh.RemoveOrphanNodes()
+if res == 1: print "Removed %d nodes!" % res
+else:        print "KO nodes removing."
+\endcode
+
 <br>
 \anchor tui_renumbering_nodes_and_elements
 <h2>Renumbering Nodes and Elements</h2>
index 983b2f4865e36448eeb5b3546ed76dbe88b257ee..0038beee7e5a63fbf58fca2d8a170856a69106e1 100644 (file)
@@ -37,13 +37,38 @@ module SMESH
   {
     /*!
      * \brief Wrap a sequence of ids in a SMESH_IDSource
+     * \param IDsOfElements list of mesh elements identifiers
+     * \return new ID source object
      */
     SMESH_IDSource MakeIDSource(in long_array IDsOfElements);
 
+    /*!
+     * \brief Remove mesh elements specified by their identifiers.
+     * \param IDsOfElements list of mesh elements identifiers
+     * \return \c true if elements are correctly removed or \c false otherwise
+     */
     boolean RemoveElements(in long_array IDsOfElements);
 
+    /*!
+     * \brief Remove mesh nodes specified by their identifiers.
+     * \param IDsOfNodes list of mesh nodes identifiers
+     * \return \c true if nodes are correctly removed or \c false otherwise
+     */
     boolean RemoveNodes(in long_array IDsOfNodes);
+    
+    /*!
+     * \brief Remove all orphan nodes.
+     * \return number of removed nodes
+     */
+    long RemoveOrphanNodes();
 
+    /*!
+     * \brief Add new node.
+     * \param x X coordinate of new node
+     * \param y Y coordinate of new node
+     * \param z Z coordinate of new node
+     * \return integer identifier of new node
+     */
     long AddNode(in double x, in double y, in double z);
 
     /*!
index 97f2c3b6f2fa9d178d4ffc11fd45033c6bc4fed1..d3407f02e682226f2d4a5dcc8a76ed274f4ec9ce 100644 (file)
@@ -72,6 +72,7 @@ dist_salomeres_DATA = \
        mesh_quad.png \
        mesh_rem_element.png \
        mesh_rem_node.png \
+       mesh_rem_orphan_nodes.png \
        mesh_shading.png \
        mesh_shrink.png \
        mesh_skew.png \
diff --git a/resources/mesh_rem_orphan_nodes.png b/resources/mesh_rem_orphan_nodes.png
new file mode 100644 (file)
index 0000000..16df2e5
Binary files /dev/null and b/resources/mesh_rem_orphan_nodes.png differ
index 62d1da1f3178b79839b7bce945794fa4cdb06fb4..88f48eabdb45815ddbef412c64b7593c07ddd09a 100644 (file)
@@ -251,8 +251,8 @@ SMDS_MeshElement* SMESH_MeshEditor::AddElement(const vector<int> &       nodeIDs
 //           Modify a compute state of sub-meshes which become empty
 //=======================================================================
 
-bool SMESH_MeshEditor::Remove (const list< int >& theIDs,
-                               const bool         isNodes )
+int SMESH_MeshEditor::Remove (const list< int >& theIDs,
+                             const bool         isNodes )
 {
   myLastCreatedElems.Clear();
   myLastCreatedNodes.Clear();
@@ -260,6 +260,7 @@ bool SMESH_MeshEditor::Remove (const list< int >& theIDs,
   SMESHDS_Mesh* aMesh = GetMeshDS();
   set< SMESH_subMesh *> smmap;
 
+  int removed = 0;
   list<int>::const_iterator it = theIDs.begin();
   for ( ; it != theIDs.end(); it++ ) {
     const SMDS_MeshElement * elem;
@@ -296,6 +297,7 @@ bool SMESH_MeshEditor::Remove (const list< int >& theIDs,
       aMesh->RemoveNode( static_cast< const SMDS_MeshNode* >( elem ));
     else
       aMesh->RemoveElement( elem );
+    removed++;
   }
 
   // Notify sub-meshes about modification
@@ -309,7 +311,7 @@ bool SMESH_MeshEditor::Remove (const list< int >& theIDs,
   //   if ( SMESH_subMesh * sm = GetMesh()->GetSubMeshContaining( 1 ) )
   //     sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
 
-  return true;
+  return removed;
 }
 
 //=======================================================================
index d9f4b5d28a737e19894bb570146b6c9f0cb7f594..ee8703eccd185d2543a745659b96f3639eb9368c 100644 (file)
@@ -171,7 +171,7 @@ public:
                                const bool                isPoly,
                                const int                 ID = 0);
 
-  bool Remove (const std::list< int >& theElemIDs, const bool isNodes);
+  int Remove (const std::list< int >& theElemIDs, const bool isNodes);
   // Remove a node or an element.
   // Modify a compute state of sub-meshes which become empty
 
index fe6d90e4cda76118c4ba1ff4a874c5c903e3e697..d672484f3c31c96bd009bb45a0a6b17da58bce94 100644 (file)
 
     // actually, the following condition can't be met (added for insurance)
     if( selected.Extent() == 0 ||
-        selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 )
+        ( selected.Extent() > 1 && theCommandID != 122 && theCommandID != 125 ) )
       return;
 
     bool hasDuplicatedMeshNames = false;
@@ -2566,6 +2566,44 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
     updateObjBrowser();
     break;
   }
+  case 4044:                                     // REMOVE ORPHAN NODES
+    {
+      if(checkLock(aStudy)) break;
+      SALOME_ListIO selected;
+      if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
+       aSel->selectedObjects( selected );
+      if ( selected.Extent() == 1 ) {
+       Handle(SALOME_InteractiveObject) anIO = selected.First();
+       SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
+       if ( !aMesh->_is_nil() ) {
+         bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
+                                                   tr( "SMESH_WARNING" ),
+                                                   tr( "REMOVE_ORPHAN_NODES_QUESTION"),
+                                                   SUIT_MessageBox::Yes |
+                                                   SUIT_MessageBox::No,
+                                                   SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
+         if( confirm ) {
+           try {
+             SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
+             int removed = aMeshEditor->RemoveOrphanNodes();
+             SUIT_MessageBox::information(SMESHGUI::desktop(),
+                                          tr("SMESH_INFORMATION"),
+                                          tr("NB_NODES_REMOVED").arg(removed));
+             if ( removed > 0 ) {
+               SMESH::UpdateView();
+               SMESHGUI::Modified();
+             }
+           }
+           catch (const SALOME::SALOME_Exception& S_ex) {
+             SalomeApp_Tools::QtCatchCorbaException(S_ex);
+           } 
+           catch (...) {
+           }
+         }
+       }
+      }
+      break;
+    }
   case 4051:                                    // RENUMBERING NODES
     {
       if(checkLock(aStudy)) break;
@@ -2974,6 +3012,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction( 4032, "HEXA",            "ICON_DLG_HEXAS" );
   createSMESHAction( 4041, "REMOVE_NODES",    "ICON_DLG_REM_NODE" );
   createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
+  createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
   createSMESHAction( 4043, "CLEAR_MESH"    ,  "ICON_CLEAR_MESH" );
   createSMESHAction( 4051, "RENUM_NODES",     "ICON_DLG_RENUMBERING_NODES" );
   createSMESHAction( 4052, "RENUM_ELEMENTS",  "ICON_DLG_RENUMBERING_ELEMENTS" );
@@ -3144,6 +3183,8 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   createMenu( 4041, removeId, -1 );
   createMenu( 4042, removeId, -1 );
+  createMenu( 4044, removeId, -1 );
+  createMenu( separator(), removeId, -1 );
   createMenu( 4043, removeId, -1 );
 
   createMenu( 4051, renumId, -1 );
@@ -3243,6 +3284,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( separator(), addRemTb );
   createTool( 4041, addRemTb );
   createTool( 4042, addRemTb );
+  createTool( 4044, addRemTb );
   createTool( 4043, addRemTb );
   createTool( separator(), addRemTb );
   createTool( 4051, addRemTb );
index 22b3fd7e8d6efd7adaf059ca457f83ea7ab0ba3d..95a9c6881c456bffed61d6bdc455bf6af9d9b2a0 100644 (file)
             <source>ICON_DLG_REM_NODE</source>
             <translation>mesh_rem_node.png</translation>
         </message>
+        <message>
+            <source>ICON_DLG_REM_ORPHAN_NODES</source>
+            <translation>mesh_rem_orphan_nodes.png</translation>
+        </message>
         <message>
             <source>ICON_DLG_RENUMBERING_ELEMENTS</source>
             <translation>mesh_renumbering_elements.png</translation>
index c7ddce7073a2e95e54d530482bbde327e45f1c77..00d0f4ca9d4dffcbaed032eeed08456202325a95 100644 (file)
             <source>MEN_REMOVE_NODES</source>
             <translation>Nodes</translation>
         </message>
+        <message>
+            <source>MEN_REMOVE_ORPHAN_NODES</source>
+            <translation>Orphan Nodes</translation>
+        </message>
         <message>
             <source>MEN_RENAME</source>
             <translation>Rename</translation>
@@ -2457,6 +2461,10 @@ Consider saving your work before application crash</translation>
             <source>STB_REMOVE_NODES</source>
             <translation>Remove nodes</translation>
         </message>
+        <message>
+            <source>STB_REMOVE_ORPHAN_NODES</source>
+            <translation>Remove orphan nodes</translation>
+        </message>
         <message>
             <source>STB_RENAME</source>
             <translation>Rename</translation>
@@ -2971,6 +2979,10 @@ Consider saving your work before application crash</translation>
             <source>TOP_REMOVE_NODES</source>
             <translation>Remove nodes</translation>
         </message>
+        <message>
+            <source>TOP_REMOVE_ORPHAN_NODES</source>
+            <translation>Remove orphan nodes</translation>
+        </message>
         <message>
             <source>TOP_RENAME</source>
             <translation>Rename</translation>
@@ -3209,6 +3221,14 @@ Do you wish to re-compute the mesh totally to discard the modifications?
 Input value precision can be adjusted using
 '%1' parameter in Mesh module preferences.</translation>
         </message>
+        <message>
+            <source>REMOVE_ORPHAN_NODES_QUESTION</source>
+            <translation>Do you really want to remove all orphan nodes?</translation>
+        </message>
+        <message>
+            <source>NB_NODES_REMOVED</source>
+            <translation>Removed %1 node(s).</translation>
+        </message>
     </context>
     <context>
         <name>SMESHGUI</name>
index 640f511913866201ad847c5b973a403f2256a9d3..76831c29c39a349047114c6ede25c0f0e6a37cff 100644 (file)
@@ -1096,7 +1096,7 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
   static TStringSet sameMethods;
   if ( sameMethods.empty() ) {
     const char * names[] = {
-      "RemoveElements","RemoveNodes","AddNode","Add0DElement","AddEdge","AddFace","AddPolygonalFace",
+      "RemoveElements","RemoveNodes","RemoveOrphanNodes","AddNode","Add0DElement","AddEdge","AddFace","AddPolygonalFace",
       "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "MoveClosestNodeToPoint",
       "InverseDiag","DeleteDiag","Reorient","ReorientObject","TriToQuad","SplitQuad","SplitQuadObject",
       "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject",
index bde96521a47bca088cf764a9a4f17885df167d23..eefc4372c624c13ddf579221cc1df2078447c83b 100644 (file)
@@ -39,6 +39,7 @@
 #include "SMESH_subMesh_i.hxx"
 #include "SMESH_Group_i.hxx"
 #include "SMESH_PythonDump.hxx"
+#include "SMESH_ControlsDef.hxx"
 
 #include "utilities.h"
 #include "Utils_ExceptHandlers.hxx"
@@ -350,6 +351,37 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNo
  */
 //=============================================================================
 
+CORBA::Long SMESH_MeshEditor_i::RemoveOrphanNodes()
+{
+  initData();
+
+  ::SMESH_MeshEditor anEditor( myMesh );
+
+  // Update Python script
+  TPythonDump() << "nbRemoved = " << this << ".RemoveOrphanNodes()";
+
+  // Create filter to find all orphan nodes
+  SMESH::Controls::Filter::TIdSequence seq;
+  SMESH::Controls::PredicatePtr predicate( new SMESH::Controls::FreeNodes() );
+  SMESH::Controls::Filter::GetElementsId( GetMeshDS(), predicate, seq );
+
+  // remove orphan nodes (if there are any)
+  list< int > IdList;
+  for ( int i = 0; i < seq.size(); i++ )
+    IdList.push_back( seq[i] );
+
+  if ( IdList.size() )
+    myMesh->SetIsModified( true );
+
+  return anEditor.Remove( IdList, true );
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
 CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x,
                                         CORBA::Double y, CORBA::Double z)
 {
index 046573b17fd210f36dc418d0722502e78fe18f5f..f5bebdc0a9983bb74133a24cec7451d94853fec3 100644 (file)
@@ -56,6 +56,7 @@ public:
 
   CORBA::Boolean RemoveElements(const SMESH::long_array & IDsOfElements);
   CORBA::Boolean RemoveNodes(const SMESH::long_array & IDsOfNodes);
+  CORBA::Long    RemoveOrphanNodes();
 
   /*!
    * Methods for creation new elements.
index de8f32624a05f7ca09105fcbbca5c9b1a2282ceb..693b1c3a843704c65218c2163619bb200a043e49 100644 (file)
@@ -2160,6 +2160,12 @@ class Mesh:
     def RemoveNodes(self, IDsOfNodes):
         return self.editor.RemoveNodes(IDsOfNodes)
 
+    ## Removes all orphan (free) nodes from mesh
+    #  @return number of the removed nodes
+    #  @ingroup l2_modif_del
+    def RemoveOrphanNodes(self):
+        return self.editor.RemoveOrphanNodes()
+
     ## Add a node to the mesh by coordinates
     #  @return Id of the new node
     #  @ingroup l2_modif_add