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
index 000000000..0818837ef
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
index 000000000..16df2e592
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
index 000000000..fdf839559
Binary files /dev/null and b/doc/salome/gui/SMESH/images/removeorphannodes.png differ
diff --git a/doc/salome/gui/SMESH/input/removing_nodes_and_elements.doc b/doc/salome/gui/SMESH/input/removing_nodes_and_elements.doc
index 6cd891573..2ba731240 100644
--- a/doc/salome/gui/SMESH/input/removing_nodes_and_elements.doc
+++ b/doc/salome/gui/SMESH/input/removing_nodes_and_elements.doc
@@ -6,6 +6,7 @@
\ref removing_nodes_anchor "Nodes"
+\ref removing_orphan_nodes_anchor "Orphan Nodes"
\ref removing_elements_anchor "Elements"
\ref clear_mesh_anchor "Clear Mesh Data"
@@ -18,11 +19,11 @@
Select your mesh in the Object Browser or in the 3D viewer.
-From the Modification menu choose Remove and from the associated
-submenu select the Remove nodes, or just click "Remove nodes"
+ From the Modification menu choose Remove and from the associated
+submenu select the Nodes , or just click "Remove nodes"
button in the toolbar.
-\image html image88.gif
+\image html remove_nodes_icon.png
"Remove nodes" button
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.
+
+\anchor removing_orphan_nodes_anchor
+Removing orphan nodes
+
+There is a quick way to remove all the orphan (free) nodes.
+
+To remove the orphan nodes:
+
+Select your mesh in the Object Browser or in the 3D viewer.
+
+From the Modification menu choose Remove and from the associated
+submenu select the Orphan Nodes , or just click "Remove orphan nodes"
+button in the toolbar.
+
+\image html remove_orphan_nodes_icon.png
+"Remove orphan nodes" button
+
+The following Warning message box will appear:
+
+\image html removeorphannodes.png
+
+Confirm removing nodes by pressing "Yes" button.
+
\anchor removing_elements_anchor
Removing elements
@@ -54,8 +78,8 @@ node of your mesh all adjacent elements will be also deleted.
Select your mesh in the Object Browser or in the 3D viewer.
-From the \b Modification menu choose \b Remove and from the
-associated submenu select the Remove elements, or just click
+ From the Modification menu choose Remove and from the
+associated submenu select the Elements , or just click
"Remove elements" button in the toolbar.
\image html remove_elements_icon.png
diff --git a/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc b/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc
index 8eee4e048..fe0da8e61 100644
--- a/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc
+++ b/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc
@@ -281,6 +281,24 @@ if res == 1: print "Elements removing is OK!"
else: print "KO Elements removing."
\endcode
+
+\anchor tui_removing_orphan_nodes
+Removing Orphan Nodes
+
+\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
+
\anchor tui_renumbering_nodes_and_elements
Renumbering Nodes and Elements
diff --git a/idl/SMESH_MeshEditor.idl b/idl/SMESH_MeshEditor.idl
index 983b2f486..0038beee7 100644
--- a/idl/SMESH_MeshEditor.idl
+++ b/idl/SMESH_MeshEditor.idl
@@ -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);
/*!
diff --git a/resources/Makefile.am b/resources/Makefile.am
index 97f2c3b6f..d3407f02e 100644
--- a/resources/Makefile.am
+++ b/resources/Makefile.am
@@ -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
index 000000000..16df2e592
Binary files /dev/null and b/resources/mesh_rem_orphan_nodes.png differ
diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx
index 62d1da1f3..88f48eabd 100644
--- a/src/SMESH/SMESH_MeshEditor.cxx
+++ b/src/SMESH/SMESH_MeshEditor.cxx
@@ -251,8 +251,8 @@ SMDS_MeshElement* SMESH_MeshEditor::AddElement(const vector & 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::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;
}
//=======================================================================
diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx
index d9f4b5d28..ee8703ecc 100644
--- a/src/SMESH/SMESH_MeshEditor.hxx
+++ b/src/SMESH/SMESH_MeshEditor.hxx
@@ -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
diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx
index fe6d90e4c..d672484f3 100644
--- a/src/SMESHGUI/SMESHGUI.cxx
+++ b/src/SMESHGUI/SMESHGUI.cxx
@@ -286,7 +286,7 @@
// 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 );
diff --git a/src/SMESHGUI/SMESH_images.ts b/src/SMESHGUI/SMESH_images.ts
index 22b3fd7e8..95a9c6881 100644
--- a/src/SMESHGUI/SMESH_images.ts
+++ b/src/SMESHGUI/SMESH_images.ts
@@ -205,6 +205,10 @@
ICON_DLG_REM_NODE
mesh_rem_node.png
+
+ ICON_DLG_REM_ORPHAN_NODES
+ mesh_rem_orphan_nodes.png
+
ICON_DLG_RENUMBERING_ELEMENTS
mesh_renumbering_elements.png
diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts
index c7ddce707..00d0f4ca9 100644
--- a/src/SMESHGUI/SMESH_msg_en.ts
+++ b/src/SMESHGUI/SMESH_msg_en.ts
@@ -534,6 +534,10 @@
MEN_REMOVE_NODES
Nodes
+
+ MEN_REMOVE_ORPHAN_NODES
+ Orphan Nodes
+
MEN_RENAME
Rename
@@ -2457,6 +2461,10 @@ Consider saving your work before application crash
STB_REMOVE_NODES
Remove nodes
+
+ STB_REMOVE_ORPHAN_NODES
+ Remove orphan nodes
+
STB_RENAME
Rename
@@ -2971,6 +2979,10 @@ Consider saving your work before application crash
TOP_REMOVE_NODES
Remove nodes
+
+ TOP_REMOVE_ORPHAN_NODES
+ Remove orphan nodes
+
TOP_RENAME
Rename
@@ -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.
+
+ REMOVE_ORPHAN_NODES_QUESTION
+ Do you really want to remove all orphan nodes?
+
+
+ NB_NODES_REMOVED
+ Removed %1 node(s).
+
SMESHGUI
diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx
index 640f51191..76831c29c 100644
--- a/src/SMESH_I/SMESH_2smeshpy.cxx
+++ b/src/SMESH_I/SMESH_2smeshpy.cxx
@@ -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",
diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx
index bde96521a..eefc4372c 100644
--- a/src/SMESH_I/SMESH_MeshEditor_i.cxx
+++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx
@@ -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)
{
diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx
index 046573b17..f5bebdc0a 100644
--- a/src/SMESH_I/SMESH_MeshEditor_i.hxx
+++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx
@@ -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.
diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py
index de8f32624..693b1c3a8 100644
--- a/src/SMESH_SWIG/smeshDC.py
+++ b/src/SMESH_SWIG/smeshDC.py
@@ -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