<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:
\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>
<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
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>
{
/*!
* \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);
/*!
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 \
// 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();
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;
aMesh->RemoveNode( static_cast< const SMDS_MeshNode* >( elem ));
else
aMesh->RemoveElement( elem );
+ removed++;
}
// Notify sub-meshes about modification
// if ( SMESH_subMesh * sm = GetMesh()->GetSubMeshContaining( 1 ) )
// sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
- return true;
+ return removed;
}
//=======================================================================
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
// 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;
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;
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" );
createMenu( 4041, removeId, -1 );
createMenu( 4042, removeId, -1 );
+ createMenu( 4044, removeId, -1 );
+ createMenu( separator(), removeId, -1 );
createMenu( 4043, removeId, -1 );
createMenu( 4051, renumId, -1 );
createTool( separator(), addRemTb );
createTool( 4041, addRemTb );
createTool( 4042, addRemTb );
+ createTool( 4044, addRemTb );
createTool( 4043, addRemTb );
createTool( separator(), addRemTb );
createTool( 4051, addRemTb );
<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>
<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>
<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>
<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>
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>
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",
#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"
*/
//=============================================================================
+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)
{
CORBA::Boolean RemoveElements(const SMESH::long_array & IDsOfElements);
CORBA::Boolean RemoveNodes(const SMESH::long_array & IDsOfNodes);
+ CORBA::Long RemoveOrphanNodes();
/*!
* Methods for creation new elements.
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