mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-31 11:40:32 +05:00
0020742: EDF 1270 SMESH : Delete Group with contents and remove Orphan Nodes
This commit is contained in:
parent
3cd9dd3663
commit
32a86c1f4a
BIN
doc/salome/gui/SMESH/images/remove_nodes_icon.png
Normal file
BIN
doc/salome/gui/SMESH/images/remove_nodes_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 720 B |
BIN
doc/salome/gui/SMESH/images/remove_orphan_nodes_icon.png
Normal file
BIN
doc/salome/gui/SMESH/images/remove_orphan_nodes_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 807 B |
BIN
doc/salome/gui/SMESH/images/removeorphannodes.png
Normal file
BIN
doc/salome/gui/SMESH/images/removeorphannodes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
@ -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>
|
||||
@ -18,11 +19,11 @@
|
||||
<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
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
|
||||
/*!
|
||||
|
@ -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 \
|
||||
|
BIN
resources/mesh_rem_orphan_nodes.png
Normal file
BIN
resources/mesh_rem_orphan_nodes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 807 B |
@ -251,7 +251,7 @@ 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,
|
||||
int SMESH_MeshEditor::Remove (const list< int >& theIDs,
|
||||
const bool isNodes )
|
||||
{
|
||||
myLastCreatedElems.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;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -205,6 +205,10 @@
|
||||
<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>
|
||||
|
@ -534,6 +534,10 @@
|
||||
<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>
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user