mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
myAction(theAction)
{
+ const bool isElems = ( myAction == MERGE_ELEMENTS );
setModal(false);
setAttribute(Qt::WA_DeleteOnClose, true);
- setWindowTitle(myAction == MERGE_ELEMENTS ? tr("SMESH_MERGE_ELEMENTS") : tr("SMESH_MERGE_NODES"));
+ setWindowTitle( isElems ? tr("SMESH_MERGE_ELEMENTS") : tr("SMESH_MERGE_NODES"));
myIdPreview = new SMESHGUI_IdPreview(SMESH::GetViewWindow( mySMESHGUI ));
GroupMeshLayout->setSpacing(SPACING);
GroupMeshLayout->setMargin(MARGIN);
- TextLabelName = new QLabel(tr("SMESH_NAME"), GroupMesh);
+ TextLabelName = new QLabel(tr("SMESH_NAMES"), GroupMesh);
SelectMeshButton = new QPushButton(GroupMesh);
SelectMeshButton->setIcon(IconSelect);
LineEditMesh = new QLineEdit(GroupMesh);
/***************************************************************/
// Controls for coincident elements detecting
- GroupCoincident = new QGroupBox(myAction == MERGE_ELEMENTS ?
- tr("COINCIDENT_ELEMENTS") :
- tr("COINCIDENT_NODES"),
- this);
+ GroupCoincident = new QGroupBox(tr(isElems ? "COINCIDENT_ELEMENTS" : "COINCIDENT_NODES"), this);
QGridLayout* aCoincidentLayout = new QGridLayout(GroupCoincident);
aCoincidentLayout->setSpacing(SPACING);
NodeSpecLayout->addWidget(SpinBoxTolerance, 0, 1 );
NodeSpecLayout->addWidget(SeparateCornersAndMedium, 1, 0, 1, 2 );
NodeSpecLayout->addWidget(AvoidMakingHoles, 2, 0, 1, 2 );
-
- /***************************************************************/
- // Exclude groups
-
- GroupExclude = new QGroupBox(tr("EXCLUDE_GROUPS"), this );
- GroupExclude->setCheckable( true );
- GroupExclude->setChecked( false );
- ListExclude = new QListWidget( GroupExclude );
- QVBoxLayout* GroupExcludeLayout = new QVBoxLayout(GroupExclude);
- GroupExcludeLayout->setSpacing(SPACING);
- GroupExcludeLayout->setMargin(MARGIN);
- GroupExcludeLayout->addWidget(ListExclude);
-
- /***************************************************************/
- // Nodes to keep
-
- GroupKeep = new QGroupBox(tr("KEEP_NODES"), this);
- SelectKeepNodesButton = new QPushButton( GroupKeep );
- SelectKeepNodesButton->setIcon( IconSelect );
- QLabel* selectLabel = new QLabel(tr("SELECT"));
- QRadioButton* idsButton = new QRadioButton(tr("SMESH_NODES"), GroupKeep);
- QRadioButton* groupButton = new QRadioButton(tr("GROUP_SUBMESH"), GroupKeep);
- KeepFromButGroup = new QButtonGroup( this );
- KeepFromButGroup->addButton( idsButton, 0 );
- KeepFromButGroup->addButton( groupButton, 1 );
- groupButton->setChecked( true );
- KeepList = new QListWidget( GroupKeep );
- KeepList->setSelectionMode(QAbstractItemView::ExtendedSelection);
- KeepList->setFlow(QListView::TopToBottom);
- AddKeepNodesButton = new QPushButton(tr("SMESH_BUT_ADD"), GroupKeep );
- RemoveKeepNodesButton = new QPushButton(tr("SMESH_BUT_REMOVE"), GroupKeep );
- QGridLayout* GroupKeepLayout = new QGridLayout(GroupKeep);
- GroupKeepLayout->setSpacing( SPACING );
- GroupKeepLayout->setMargin ( MARGIN );
- GroupKeepLayout->addWidget( SelectKeepNodesButton, 0, 0 );
- GroupKeepLayout->addWidget( selectLabel, 0, 1 );
- GroupKeepLayout->addWidget( idsButton, 0, 2 );
- GroupKeepLayout->addWidget( groupButton, 0, 3, 1, 2 );
- GroupKeepLayout->addWidget( KeepList, 1, 0, 3, 4 );
- GroupKeepLayout->addWidget( AddKeepNodesButton, 1, 4, 1, 1 );
- GroupKeepLayout->addWidget( RemoveKeepNodesButton, 2, 4, 1, 1 );
- GroupKeepLayout->setRowStretch(3, 5);
-
- // Costruction of the logical filter
- QList<SUIT_SelectionFilter*> aListOfFilters;
- aListOfFilters << new SMESH_TypeFilter (SMESH::SUBMESH)
- << new SMESH_TypeFilter (SMESH::GROUP);
- mySubMeshOrGroupFilter =
- new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR, /*takeOwnership=*/true);
}
else {
NodeSpecWidget = 0;
GroupExclude = 0;
ListExclude = 0;
KeepFromButGroup = 0;
- SelectKeepNodesButton = 0;
- AddKeepNodesButton = 0;
- RemoveKeepNodesButton = 0;
+ SelectKeepButton = 0;
+ AddKeepButton = 0;
+ RemoveKeepButton = 0;
KeepList = 0;
mySubMeshOrGroupFilter = 0;
}
+ /***************************************************************/
+ // Exclude groups
+
+ GroupExclude = new QGroupBox(tr("EXCLUDE_GROUPS"), this );
+ GroupExclude->setCheckable( true );
+ GroupExclude->setChecked( false );
+ ListExclude = new QListWidget( GroupExclude );
+ QVBoxLayout* GroupExcludeLayout = new QVBoxLayout(GroupExclude);
+ GroupExcludeLayout->setSpacing(SPACING);
+ GroupExcludeLayout->setMargin(MARGIN);
+ GroupExcludeLayout->addWidget(ListExclude);
+
+ /***************************************************************/
+ // Nodes/elements to keep
+
+ GroupKeep = new QGroupBox(tr( isElems ? "KEEP_ELEMENTS" : "KEEP_NODES"), this);
+ SelectKeepButton = new QPushButton( GroupKeep );
+ SelectKeepButton->setIcon( IconSelect );
+ QLabel* selectLabel = new QLabel(tr("SELECT"));
+ QRadioButton* idsButton = new QRadioButton(tr(isElems ? "SMESH_ELEMENTS" : "SMESH_NODES"),
+ GroupKeep);
+ QRadioButton* groupButton = new QRadioButton(tr("GROUP_SUBMESH"), GroupKeep);
+ KeepFromButGroup = new QButtonGroup( this );
+ KeepFromButGroup->addButton( idsButton, 0 );
+ KeepFromButGroup->addButton( groupButton, 1 );
+ groupButton->setChecked( true );
+ KeepList = new QListWidget( GroupKeep );
+ KeepList->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ KeepList->setFlow(QListView::TopToBottom);
+ AddKeepButton = new QPushButton(tr("SMESH_BUT_ADD"), GroupKeep );
+ RemoveKeepButton = new QPushButton(tr("SMESH_BUT_REMOVE"), GroupKeep );
+ QGridLayout* GroupKeepLayout = new QGridLayout(GroupKeep);
+ GroupKeepLayout->setSpacing( SPACING );
+ GroupKeepLayout->setMargin ( MARGIN );
+ GroupKeepLayout->addWidget( SelectKeepButton, 0, 0 );
+ GroupKeepLayout->addWidget( selectLabel, 0, 1 );
+ GroupKeepLayout->addWidget( idsButton, 0, 2 );
+ GroupKeepLayout->addWidget( groupButton, 0, 3, 1, 2 );
+ GroupKeepLayout->addWidget( KeepList, 1, 0, 3, 4 );
+ GroupKeepLayout->addWidget( AddKeepButton, 1, 4, 1, 1 );
+ GroupKeepLayout->addWidget( RemoveKeepButton, 2, 4, 1, 1 );
+ GroupKeepLayout->setRowStretch(3, 5);
+
+ // Costruction of the logical filter
+ QList<SUIT_SelectionFilter*> aListOfFilters;
+ aListOfFilters << new SMESH_TypeFilter (SMESH::SUBMESH)
+ << new SMESH_TypeFilter (SMESH::GROUP);
+ mySubMeshOrGroupFilter =
+ new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR, /*takeOwnership=*/true);
+
ListCoincident = new QListWidget(GroupCoincident);
ListCoincident->setSelectionMode(QListWidget::ExtendedSelection);
RemoveGroupButton = new QPushButton(tr("SMESH_BUT_REMOVE"), GroupCoincident);
SelectAllCB = new QCheckBox(tr("SELECT_ALL"), GroupCoincident);
- ShowIDs = new QCheckBox(myAction == MERGE_ELEMENTS ? tr("SHOW_ELEMS_IDS") : tr("SHOW_NODES_IDS"), GroupCoincident);
+ ShowIDs = new QCheckBox( isElems ? tr("SHOW_ELEMS_IDS") : tr("SHOW_NODES_IDS"), GroupCoincident);
aCoincidentLayout->addWidget(ListCoincident, 0, 0, 4, 2);
aCoincidentLayout->addWidget(DetectButton, 0, 2);
/***************************************************************/
// Controls for editing the selected group
- GroupEdit = new QGroupBox(myAction == MERGE_NODES ?
- tr("EDIT_SELECTED_NODE_GROUP") :
- tr("EDIT_SELECTED_ELEM_GROUP"), this);
+ GroupEdit = new QGroupBox( tr(isElems ? "EDIT_SELECTED_ELEM_GROUP" : "EDIT_SELECTED_NODE_GROUP"), this);
QGridLayout* GroupEditLayout = new QGridLayout(GroupEdit);
GroupEditLayout->setSpacing(SPACING);
GroupEditLayout->setMargin(MARGIN);
GroupButtonsLayout->addWidget(buttonHelp);
/***************************************************************/
- if (myAction == MERGE_NODES)
+ //if (myAction == MERGE_NODES)
{
QWidget* LeftWdg = new QWidget( this );
QVBoxLayout* LeftLayout = new QVBoxLayout(LeftWdg);
LeftLayout->setMargin(0);
LeftLayout->addWidget(TypeBox);
LeftLayout->addWidget(GroupMesh);
- LeftLayout->addWidget(NodeSpecWidget);
+ if ( !isElems )
+ LeftLayout->addWidget(NodeSpecWidget);
LeftLayout->addWidget(GroupCoincident);
LeftLayout->addStretch();
LeftLayout->addWidget(GroupButtons);
DlgLayout->addWidget( LeftWdg );
DlgLayout->addWidget( RightWdg );
}
- else
- {
- QVBoxLayout* DlgLayout = new QVBoxLayout(this);
- DlgLayout->setSpacing(SPACING);
- DlgLayout->setMargin(MARGIN);
- DlgLayout->addWidget(TypeBox);
- DlgLayout->addWidget(GroupMesh);
- DlgLayout->addWidget(GroupCoincident);
- DlgLayout->addWidget(GroupEdit);
- DlgLayout->addWidget(GroupButtons);
- }
+ // else
+ // {
+ // QVBoxLayout* DlgLayout = new QVBoxLayout(this);
+ // DlgLayout->setSpacing(SPACING);
+ // DlgLayout->setMargin(MARGIN);
+ // DlgLayout->addWidget(TypeBox);
+ // DlgLayout->addWidget(GroupMesh);
+ // DlgLayout->addWidget(GroupCoincident);
+ // DlgLayout->addWidget(GroupEdit);
+ // DlgLayout->addWidget(GroupButtons);
+ // }
GroupCoincident->hide();
GroupEdit->hide();
myEditCurrentArgument = (QWidget*)LineEditMesh;
myActor = 0;
- mySubMeshOrGroup = SMESH::SMESH_subMesh::_nil();
+ mySubMeshOrGroups = new SMESH::ListOfIDSources;
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
if ( KeepList )
{
- connect(SelectKeepNodesButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(KeepFromButGroup, SIGNAL (buttonClicked(int)), SLOT(onKeepNodeSourceChanged(int)));
- connect(AddKeepNodesButton, SIGNAL (clicked()), this, SLOT(onAddKeepNode()));
- connect(RemoveKeepNodesButton, SIGNAL (clicked()), this, SLOT(onRemoveKeepNode()));
- connect(KeepList, SIGNAL (itemSelectionChanged()), this, SLOT(onSelectKeepNode()));
+ connect(SelectKeepButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(KeepFromButGroup, SIGNAL (buttonClicked(int)), SLOT(onKeepSourceChanged(int)));
+ connect(AddKeepButton, SIGNAL (clicked()), this, SLOT(onAddKeep()));
+ connect(RemoveKeepButton, SIGNAL (clicked()), this, SLOT(onRemoveKeep()));
+ connect(KeepList, SIGNAL (itemSelectionChanged()), this, SLOT(onSelectKeep()));
}
connect(SelectMeshButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
connect(DetectButton, SIGNAL (clicked()), this, SLOT(onDetect()));
aGroupsOfElements->length(ListCoincident->count());
int anArrayNum = 0;
- for (int i = 0; i < ListCoincident->count(); i++) {
+ for (int i = 0; i < ListCoincident->count(); i++)
+ {
QStringList aListIds = ListCoincident->item(i)->text().split(" ", QString::SkipEmptyParts);
anIds->length(aListIds.count());
aGroupsOfElements[anArrayNum++] = anIds.inout();
}
- SMESH::ListOfIDSources_var nodesToKeep;
+ SMESH::ListOfIDSources_var toKeep;
SMESH::IDSource_wrap tmpIdSource;
- if ( myAction == MERGE_NODES )
+ //if ( myAction == MERGE_NODES )
{
- nodesToKeep = new SMESH::ListOfIDSources();
+ toKeep = new SMESH::ListOfIDSources();
int i, nb = KeepList->count();
- if ( isKeepNodesIDsSelection() )
+ if ( isKeepIDsSelection() )
{
SMESH::long_array_var anIdList = new SMESH::long_array();
anIdList->length(nb);
if ( nb > 0 )
{
tmpIdSource = aMeshEditor->MakeIDSource( anIdList, SMESH::NODE );
- nodesToKeep->length( 1 );
- nodesToKeep[0] = SMESH::SMESH_IDSource::_duplicate( tmpIdSource.in() );
+ toKeep->length( 1 );
+ toKeep[0] = SMESH::SMESH_IDSource::_duplicate( tmpIdSource.in() );
}
}
else
{
- nodesToKeep->length( nb );
+ toKeep->length( nb );
int nbObj = 0;
for (i = 0; i < nb; i++)
{
SMESH::SMESH_IDSource_var idSrc =
SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( anIO );
if ( !idSrc->_is_nil() )
- nodesToKeep[ nbObj++ ] = SMESH::SMESH_IDSource::_duplicate( idSrc );
+ toKeep[ nbObj++ ] = SMESH::SMESH_IDSource::_duplicate( idSrc );
}
- nodesToKeep->length( nbObj );
+ toKeep->length( nbObj );
}
KeepList->clear();
}
if( myAction == MERGE_NODES )
- aMeshEditor->MergeNodes( aGroupsOfElements.inout(), nodesToKeep, AvoidMakingHoles->isChecked() );
+ aMeshEditor->MergeNodes( aGroupsOfElements.inout(), toKeep, AvoidMakingHoles->isChecked() );
else
- aMeshEditor->MergeElements( aGroupsOfElements.inout() );
+ aMeshEditor->MergeElements( aGroupsOfElements.inout(), toKeep );
if ( myTypeId == TYPE_AUTO ) {
if ( myAction == MERGE_NODES )
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INFORMATION"),
tr("SMESH_MERGED_ELEMENTS").arg(QString::number(ListCoincident->count()).toLatin1().data()));
}
- if ( & nodesToKeep.in() )
- nodesToKeep->length(0); // release before tmpIdSource calls UnRegister()
+ if ( & toKeep.in() )
+ toKeep->length(0); // release before tmpIdSource calls UnRegister()
}
catch(...) {
myMesh->NbVolumesOfOrder( SMESH::ORDER_QUADRATIC ) > 0 ));
SeparateCornersAndMedium->setEnabled( has2ndOrder );
-
+ }
+ {
if ( myEditCurrentArgument != KeepList )
{
- AddKeepNodesButton->setEnabled( false );
- RemoveKeepNodesButton->setEnabled( false );
+ AddKeepButton->setEnabled( false );
+ RemoveKeepButton->setEnabled( false );
KeepList->clearSelection();
}
}
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 );
+ 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::_narrow( myGroups[i] );
+ }
+ }
switch (myAction) {
case MERGE_NODES :
- 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(),
+ aMeshEditor->FindCoincidentNodesOnPartBut(mySubMeshOrGroups.in(),
+ SpinBoxTolerance->GetValue(),
aGroupsArray.out(),
aExcludeGroups.in(),
SeparateCornersAndMedium->isEnabled() &&
SeparateCornersAndMedium->isChecked());
break;
case MERGE_ELEMENTS :
- aMeshEditor->FindEqualElements(src.in(), aGroupsArray.out());
+ aMeshEditor->FindEqualElements(mySubMeshOrGroups.in(),
+ aExcludeGroups.in(),
+ aGroupsArray.out());
break;
}
-
- for (int i = 0; i < (int)aGroupsArray->length(); i++) {
+
+ for ( CORBA::ULong i = 0; i < aGroupsArray->length(); i++)
+ {
SMESH::long_array& aGroup = aGroupsArray[i];
QStringList anIDs;
- for (int j = 0; j < (int)aGroup.length(); j++)
- anIDs.append(QString::number(aGroup[j]));
+ for ( CORBA::ULong j = 0; j < aGroup.length(); j++ )
+ anIDs.append( QString::number( aGroup[j] ));
- ListCoincident->addItem(anIDs.join(" "));
+ ListCoincident->addItem( anIDs.join(" "));
}
} catch(...) {
}
SelectAllCB->setChecked( false );
if ( myEditCurrentArgument == (QWidget*)KeepList && KeepList &&
- !isKeepNodesIDsSelection() )
+ !isKeepIDsSelection() )
{
// restore selection of nodes after selection of sub-meshes
mySelectionMgr->clearFilters();
myIdPreview->SetPointsLabeled(false);
if ( myEditCurrentArgument == (QWidget*)KeepList && KeepList &&
- !isKeepNodesIDsSelection() )
+ !isKeepIDsSelection() )
{
// restore selection of nodes after selection of sub-meshes
mySelectionMgr->clearFilters();
if (myTypeId == TYPE_MANUAL)
mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
}
- else if ( send == SelectKeepNodesButton && send )
+ else if ( send == SelectKeepButton && send )
{
myEditCurrentArgument = (QWidget*)KeepList;
- KeepList->setWrapping( isKeepNodesIDsSelection() );
- if ( isKeepNodesIDsSelection() )
+ KeepList->setWrapping( isKeepIDsSelection() );
+ if ( isKeepIDsSelection() )
{
- SMESH::SetPointRepresentation( true );
+ bool isElems = ( myAction == MERGE_ELEMENTS );
+ SMESH::SetPointRepresentation( !isElems );
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode( NodeSelection );
+ aViewWindow->SetSelectionMode( isElems ? CellSelection : NodeSelection );
}
else
{
ListCoincident->clear();
ListEdit->clear();
+ ListExclude->clear();
myActor = 0;
myMesh = SMESH::SMESH_Mesh::_nil();
QString aCurrentEntry = myEntry;
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
- if (nbSel != 1) {
+ if (nbSel == 0) {
myIdPreview->SetPointsLabeled(false);
SMESH::SetPointRepresentation(false);
mySelectionMgr->clearFilters();
if (myMesh->_is_nil())
return;
- LineEditMesh->setText(aString);
-
myActor = SMESH::FindActorByEntry(IO->getEntry());
if (!myActor)
myActor = SMESH::FindActorByObject(myMesh);
- if ( myActor && myTypeId == TYPE_MANUAL && mySelector->IsSelectionEnabled() ) {
- mySubMeshOrGroup = SMESH::SMESH_IDSource::_nil();
- mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
+ mySubMeshOrGroups->length( nbSel );
+ nbSel = 0;
+ bool isMeshSelected = false;
+ while ( !aList.IsEmpty() )
+ {
+ IO = aList.First();
+ aList.RemoveFirst();
+ SMESH::SMESH_IDSource_var idSrc = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+ if ( !idSrc->_is_nil() )
+ {
+ SMESH::SMESH_Mesh_var mesh = idSrc->GetMesh();
+ if ( !mesh->_is_equivalent( myMesh ))
+ {
+ nbSel = 0;
+ break;
+ }
+ mySubMeshOrGroups[ nbSel++ ] = idSrc;
+ if ( idSrc->_is_equivalent( myMesh ))
+ {
+ isMeshSelected = true;
+ mySubMeshOrGroups[ 0 ] = idSrc;
+ aString = SMESH::GetName( IO );
+ // break; -- to check if other selected belongs to myMesh
+ }
+ }
+ }
- if ((!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil() || //SUBMESH OR GROUP
- !SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO)->_is_nil()) &&
- !SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
- mySubMeshOrGroup = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+ if ( isMeshSelected && nbSel > 1 )
+ nbSel = 1;
+ mySubMeshOrGroups->length( nbSel );
- if (myAction == MERGE_NODES) {
- SMESH::SetPointRepresentation(true);
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(NodeSelection);
- }
- else
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(CellSelection);
+ if ( nbSel == 0 )
+ {
+ LineEditMesh->setText("");
+ return;
+ }
+
+ LineEditMesh->setText( aString );
+
+ if (myAction == MERGE_NODES) {
+ SMESH::SetPointRepresentation(true);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(NodeSelection);
}
+ else
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(CellSelection);
// process groups
- if ( myAction == MERGE_NODES && !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
- myGroups.clear();
- ListExclude->clear();
+ myGroups.clear();
+ if ( isMeshSelected )
+ {
SMESH::ListOfGroups_var aListOfGroups = myMesh->GetGroups();
GroupExclude->setEnabled( aListOfGroups->length() > 0 );
- for( int i = 0, n = aListOfGroups->length(); i < n; i++ ) {
+ 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
+ if ( !aGroup->_is_nil() ) {
+ if ( myAction == MERGE_ELEMENTS && aGroup->GetType() == SMESH::NODE )
+ continue;
QString aGroupName( aGroup->GetName() );
if ( !aGroupName.isEmpty() ) {
- myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup));
+ myGroups.append( aGroup );
QListWidgetItem* item = new QListWidgetItem( aGroupName );
item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
item->setCheckState( Qt::Unchecked );
else if (myEditCurrentArgument == (QWidget*)KeepList && KeepList)
{
- AddKeepNodesButton->setEnabled( false );
- RemoveKeepNodesButton->setEnabled( false );
- if ( isKeepNodesIDsSelection() )
+ AddKeepButton->setEnabled( false );
+ RemoveKeepButton->setEnabled( false );
+ if ( isKeepIDsSelection() )
{
if (!myMesh->_is_nil() && !myActor)
myActor = SMESH::FindActorByObject(myMesh);
KeepList->blockSignals(true);
foreach(anItem, listItemsToSel) anItem->setSelected(true);
KeepList->blockSignals(blocked);
- //onSelectKeepNode();
- AddKeepNodesButton->setEnabled( nbFound < aNbNodes );
- RemoveKeepNodesButton->setEnabled( nbFound > 0 );
+ //onSelectKeep();
+ AddKeepButton->setEnabled( nbFound < aNbNodes );
+ RemoveKeepButton->setEnabled( nbFound > 0 );
}
}
}
SALOME_ListIteratorOfListIO anIt (aList);
for ( ; anIt.More() && !hasNewSelected; anIt.Next())
if ( anIt.Value()->hasEntry() )
- hasNewSelected = isNewKeepNodesGroup( anIt.Value()->getEntry() );
+ hasNewSelected = isNewKeepGroup( anIt.Value()->getEntry() );
- AddKeepNodesButton->setEnabled( hasNewSelected );
- //RemoveKeepNodesButton->setEnabled( KeepList->selectedItems().count() );
+ AddKeepButton->setEnabled( hasNewSelected );
+ //RemoveKeepButton->setEnabled( KeepList->selectedItems().count() );
}
}
}
GroupCoincident->setEnabled(false);
GroupEdit->setEnabled(false);
GroupButtons->setEnabled(false);
- if (myAction == MERGE_NODES)
+ //if (myAction == MERGE_NODES)
{
GroupExclude->setEnabled(false);
GroupKeep->setEnabled(false);
GroupCoincident->setEnabled(true);
GroupEdit->setEnabled(true);
GroupButtons->setEnabled(true);
- if (myAction == MERGE_NODES)
+ //if (myAction == MERGE_NODES)
{
GroupExclude->setEnabled(false);
GroupKeep->setEnabled(false);
SMESH::UpdateView();
- // Costruction of the logical filter
- SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (SMESH::MESHorSUBMESH);
- SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (SMESH::GROUP);
-
- QList<SUIT_SelectionFilter*> aListOfFilters;
- if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
- if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
-
- myMeshOrSubMeshOrGroupFilter =
- new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR, true);
+ myMeshOrSubMeshOrGroupFilter = new SMESH_TypeFilter (SMESH::IDSOURCE);
if (myAction == MERGE_NODES) {
SMESH::SetPointRepresentation(true);
}
//=======================================================================
-//function : isKeepNodesIDsSelection
+//function : isKeepIDsSelection
//purpose : Return true of Nodes to keep are selected by IDs
//=======================================================================
-bool SMESHGUI_MergeDlg::isKeepNodesIDsSelection()
+bool SMESHGUI_MergeDlg::isKeepIDsSelection()
{
return KeepFromButGroup && KeepFromButGroup->checkedId() == 0;
}
//=======================================================================
-//function : isNewKeepNodesGroup
+//function : isNewKeepGroup
//purpose : Return true if an object with given entry is NOT present in KeepList
//=======================================================================
-bool SMESHGUI_MergeDlg::isNewKeepNodesGroup( const char* entry )
+bool SMESHGUI_MergeDlg::isNewKeepGroup( const char* entry )
{
- if ( !entry || isKeepNodesIDsSelection() )
+ if ( !entry || isKeepIDsSelection() )
return false;
for ( int i = 0; i < KeepList->count(); i++ )
}
//=======================================================================
-//function : onAddKeepNode
+//function : onAddKeep
//purpose : SLOT called when [Add] of Nodes To Keep group is pressed
//=======================================================================
-void SMESHGUI_MergeDlg::onAddKeepNode()
+void SMESHGUI_MergeDlg::onAddKeep()
{
if ( myIsBusy )
return;
myIsBusy = true;
- if ( isKeepNodesIDsSelection() )
+ if ( isKeepIDsSelection() )
{
//KeepList->clearSelection();
QString anIDs = "";
KeepList->blockSignals(true);
foreach(anItem, listItemsToSel) anItem->setSelected(true);
KeepList->blockSignals(blocked);
- //onSelectKeepNode();
+ //onSelectKeep();
}
- RemoveKeepNodesButton->setEnabled( aNbNodes > 0 );
+ RemoveKeepButton->setEnabled( aNbNodes > 0 );
}
else
{
SALOME_ListIteratorOfListIO anIt (aList);
for ( ; anIt.More(); anIt.Next()) {
Handle(SALOME_InteractiveObject) anIO = anIt.Value();
- if ( isNewKeepNodesGroup( anIO->getEntry() ))
+ if ( isNewKeepGroup( anIO->getEntry() ))
{
QListWidgetItem* anItem = new QListWidgetItem( anIO->getName() );
anItem->setData( Qt::UserRole, QString( anIO->getEntry() ));
KeepList->addItem(anItem);
}
}
- //RemoveKeepNodesButton->setEnabled( KeepList->selectedItems().count() );
+ //RemoveKeepButton->setEnabled( KeepList->selectedItems().count() );
}
- AddKeepNodesButton->setEnabled( false );
+ AddKeepButton->setEnabled( false );
myIsBusy = false;
}
//=======================================================================
-//function : onRemoveKeepNode
+//function : onRemoveKeep
//purpose : SLOT called when [Remove] of Nodes To Keep group is pressed
//=======================================================================
-void SMESHGUI_MergeDlg::onRemoveKeepNode()
+void SMESHGUI_MergeDlg::onRemoveKeep()
{
- // if ( isKeepNodesIDsSelection() )
+ // if ( isKeepIDsSelection() )
// {
// }
// else
QListWidgetItem* item;
foreach(item, selItems) delete item;
}
- if ( isKeepNodesIDsSelection() )
+ if ( isKeepIDsSelection() )
{
- AddKeepNodesButton->setEnabled( false );
+ AddKeepButton->setEnabled( false );
}
- RemoveKeepNodesButton->setEnabled( false );
+ RemoveKeepButton->setEnabled( false );
}
//=======================================================================
-//function : onSelectKeepNode
+//function : onSelectKeep
//purpose : SLOT called when selection in KeepList changes
//=======================================================================
-void SMESHGUI_MergeDlg::onSelectKeepNode()
+void SMESHGUI_MergeDlg::onSelectKeep()
{
if ( myIsBusy || !isEnabled() ) return;
myIsBusy = true;
- if ( isKeepNodesIDsSelection() )
+ if ( isKeepIDsSelection() )
{
if ( myActor )
{
aList.Append(myActor->getIO());
mySelectionMgr->setSelectedObjects(aList,false);
- AddKeepNodesButton->setEnabled( false );
- RemoveKeepNodesButton->setEnabled( aIndexes.Extent() > 0 );
+ AddKeepButton->setEnabled( false );
+ RemoveKeepButton->setEnabled( aIndexes.Extent() > 0 );
}
}
else
{
- RemoveKeepNodesButton->setEnabled( KeepList->selectedItems().count() );
+ RemoveKeepButton->setEnabled( KeepList->selectedItems().count() );
}
myIsBusy = false;
}
//=======================================================================
-//function : onKeepNodeSourceChanged
+//function : onKeepSourceChanged
//purpose : SLOT called when type of source of Nodes To Keep change from
// IDs to groups or vice versa
//=======================================================================
-void SMESHGUI_MergeDlg::onKeepNodeSourceChanged(int isGroup)
+void SMESHGUI_MergeDlg::onKeepSourceChanged(int isGroup)
{
KeepList->clear();
- SelectKeepNodesButton->click();
+ SelectKeepButton->click();
}
*/
//================================================================================
- void idSourceToNodeSet(SMESH::SMESH_IDSource_ptr theObject,
- const SMESHDS_Mesh* theMeshDS,
- TIDSortedNodeSet& theNodeSet)
+ void idSourceToNodeSet(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESHDS_Mesh* theMeshDS,
+ TIDSortedNodeSet& theNodeSet)
{
if ( CORBA::is_nil( theObject ) )
return;
- SMESH::array_of_ElementType_var types = theObject->GetTypes();
- SMESH::long_array_var aElementsId = theObject->GetIDs();
- if ( types->length() == 1 && types[0] == SMESH::NODE)
+ if ( SMESH::DownCast<SMESH_Mesh_i*>( theObject ))
{
- for ( CORBA::ULong i = 0; i < aElementsId->length(); i++ )
- if ( const SMDS_MeshNode * n = theMeshDS->FindNode( aElementsId[i] ))
- theNodeSet.insert( theNodeSet.end(), n);
- }
- else if ( SMESH::DownCast<SMESH_Mesh_i*>( theObject ))
- {
- SMDS_NodeIteratorPtr nIt = theMeshDS->nodesIterator();
- while ( nIt->more( ))
+ for ( SMDS_NodeIteratorPtr nIt = theMeshDS->nodesIterator(); nIt->more(); )
if ( const SMDS_MeshElement * elem = nIt->next() )
theNodeSet.insert( elem->begin_nodes(), elem->end_nodes());
}
else
{
- for ( CORBA::ULong i = 0; i < aElementsId->length(); i++ )
- if ( const SMDS_MeshElement * elem = theMeshDS->FindElement( aElementsId[i] ))
- theNodeSet.insert( elem->begin_nodes(), elem->end_nodes());
+ SMESH::array_of_ElementType_var types = theObject->GetTypes();
+ SMESH::long_array_var aElementsId = theObject->GetIDs();
+ if ( types->length() == 1 && types[0] == SMESH::NODE)
+ {
+ for ( CORBA::ULong i = 0; i < aElementsId->length(); i++ )
+ if ( const SMDS_MeshNode * n = theMeshDS->FindNode( aElementsId[i] ))
+ theNodeSet.insert( theNodeSet.end(), n);
+ }
+ else
+ {
+ for ( CORBA::ULong i = 0; i < aElementsId->length(); i++ )
+ if ( const SMDS_MeshElement * elem = theMeshDS->FindElement( aElementsId[i] ))
+ theNodeSet.insert( elem->begin_nodes(), elem->end_nodes());
+ }
}
}
//================================================================================
/*!
- * \brief Finds nodes coincident with Tolerance within Object excluding nodes within
+ * \brief Finds nodes coincident with Tolerance within Objects excluding nodes within
* ExceptSubMeshOrGroups
*/
//================================================================================
void SMESH_MeshEditor_i::
-FindCoincidentNodesOnPartBut(SMESH::SMESH_IDSource_ptr theObject,
+FindCoincidentNodesOnPartBut(const SMESH::ListOfIDSources& theObjects,
CORBA::Double theTolerance,
SMESH::array_of_long_array_out theGroupsOfNodes,
const SMESH::ListOfIDSources& theExceptSubMeshOrGroups,
initData();
TIDSortedNodeSet nodes;
- prepareIdSource( theObject );
- idSourceToNodeSet( theObject, getMeshDS(), nodes );
-
+ for ( CORBA::ULong i = 0; i < theObjects.length(); ++i )
+ {
+ prepareIdSource( theObjects[i] );
+ idSourceToNodeSet( theObjects[i], getMeshDS(), nodes );
+ }
for ( CORBA::ULong i = 0; i < theExceptSubMeshOrGroups.length(); ++i )
{
if ( SMDS_ElemIteratorPtr nodeIt = myMesh_i->GetElements( theExceptSubMeshOrGroups[i],
findCoincidentNodes( nodes, theTolerance, theGroupsOfNodes, theSeparateCornersAndMedium );
TPythonDump() << "coincident_nodes_on_part = " << this << ".FindCoincidentNodesOnPartBut( "
- << theObject<<", "
+ << theObjects <<", "
<< theTolerance << ", "
<< theExceptSubMeshOrGroups << ", "
<< theSeparateCornersAndMedium << " )";
//purpose :
//=======================================================================
-void SMESH_MeshEditor_i::FindEqualElements(SMESH::SMESH_IDSource_ptr theObject,
- SMESH::array_of_long_array_out GroupsOfElementsID)
+void SMESH_MeshEditor_i::FindEqualElements(const SMESH::ListOfIDSources& theObjects,
+ const SMESH::ListOfIDSources& theExceptObjects,
+ SMESH::array_of_long_array_out theGroupsOfElementsID)
throw (SALOME::SALOME_Exception)
{
SMESH_TRY;
initData();
- SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow(theObject);
- if ( !( !group->_is_nil() && group->GetType() == SMESH::NODE ))
+ theGroupsOfElementsID = new SMESH::array_of_long_array;
+
+ TIDSortedElemSet elems;
+ bool hasOkObject = false;
+ bool emptyIfIsMesh= ( theObjects.length() == 1 && theExceptObjects.length() == 0 );
+
+ for ( CORBA::ULong i = 0; i < theObjects.length(); ++i )
{
- TIDSortedElemSet elems;
- idSourceToSet( theObject, getMeshDS(), elems, SMDSAbs_All, /*emptyIfIsMesh=*/true);
+ SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow( theObjects[i] );
+ if ( !( !group->_is_nil() && group->GetType() == SMESH::NODE ))
+ if ( idSourceToSet( theObjects[i], getMeshDS(), elems, SMDSAbs_All, emptyIfIsMesh ))
+ hasOkObject = true;
+ }
+
+ if ( hasOkObject )
+ {
+ for ( CORBA::ULong i = 0; i < theExceptObjects.length(); ++i )
+ {
+ if ( SMDS_ElemIteratorPtr elemIt = myMesh_i->GetElements( theExceptObjects[i], SMESH::ALL ))
+ while ( elemIt->more() )
+ elems.erase( elemIt->next() );
+ }
::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
getEditor().FindEqualElements( elems, aListOfListOfElementsID );
- GroupsOfElementsID = new SMESH::array_of_long_array;
- GroupsOfElementsID->length( aListOfListOfElementsID.size() );
+ theGroupsOfElementsID->length( aListOfListOfElementsID.size() );
::SMESH_MeshEditor::TListOfListOfElementsID::iterator arraysIt =
aListOfListOfElementsID.begin();
for (CORBA::Long j = 0; arraysIt != aListOfListOfElementsID.end(); ++arraysIt, ++j)
{
- SMESH::long_array& aGroup = (*GroupsOfElementsID)[ j ];
+ SMESH::long_array& aGroup = (*theGroupsOfElementsID)[ j ];
list<int>& listOfIDs = *arraysIt;
aGroup.length( listOfIDs.size() );
list<int>::iterator idIt = listOfIDs.begin();
}
TPythonDump() << "equal_elements = " << this << ".FindEqualElements( "
- <<theObject<<" )";
+ << theObjects << ", "
+ << theExceptObjects << " )";
}
SMESH_CATCH( SMESH::throwCorbaException );
//purpose :
//=======================================================================
-void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID)
+void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& theGroupsOfElementsID,
+ const SMESH::ListOfIDSources& theElementsToKeep)
throw (SALOME::SALOME_Exception)
{
SMESH_TRY;
TPythonDump aTPythonDump;
aTPythonDump << this << ".MergeElements( [";
+ NCollection_Map< int > idsToKeep;
+ for ( CORBA::ULong i = 0; i < theElementsToKeep.length(); i++ )
+ {
+ if ( CORBA::is_nil( theElementsToKeep[i] ))
+ continue;
+ SMESH::array_of_ElementType_var elemTypes = theElementsToKeep[i]->GetTypes();
+ if ( elemTypes->length() == 1 && elemTypes[0] == SMESH::NODE )
+ continue;
+ SMESH::long_array_var elementsId = theElementsToKeep[i]->GetIDs();
+ for ( CORBA::ULong j = 0; j < elementsId->length(); ++j )
+ idsToKeep.Add( elementsId[ j ]);
+ }
+
::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
- for ( CORBA::ULong i = 0; i < GroupsOfElementsID.length(); i++ ) {
- const SMESH::long_array& anElemsIDGroup = GroupsOfElementsID[ i ];
+ for ( CORBA::ULong i = 0; i < theGroupsOfElementsID.length(); i++ )
+ {
+ const SMESH::long_array& anElemsIDGroup = theGroupsOfElementsID[ i ];
aListOfListOfElementsID.push_back( list< int >() );
list< int >& aListOfElemsID = aListOfListOfElementsID.back();
- for ( CORBA::ULong j = 0; j < anElemsIDGroup.length(); j++ ) {
+ for ( CORBA::ULong j = 0; j < anElemsIDGroup.length(); j++ )
+ {
CORBA::Long id = anElemsIDGroup[ j ];
- aListOfElemsID.push_back( id );
+ if ( idsToKeep.Contains( id )) aListOfElemsID.push_front( id );
+ else aListOfElemsID.push_back( id );
}
if ( aListOfElemsID.size() < 2 )
aListOfListOfElementsID.pop_back();
declareMeshModified( /*isReComputeSafe=*/true );
- aTPythonDump << "] )";
+ aTPythonDump << "], " << theElementsToKeep << " )";
SMESH_CATCH( SMESH::throwCorbaException );
}
}
if ( emptyIfIsMesh && SMESH::DownCast<SMESH_Mesh_i*>( theIDSource ))
{
- if ( error && getMeshDS()->GetMeshInfo().NbElements( theType ) == 0 )
+ if ( error && theMeshDS->GetMeshInfo().NbElements( theType ) == 0 )
*error = IDSource_EMPTY;
return true;
}
+ if ( getMeshDS() == theMeshDS ) // check if theIDSource belongs to myMesh
+ {
+ SMESH::SMESH_Mesh_var mesh = theIDSource->GetMesh();
+ SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+ if ( mesh_i && mesh_i != myMesh_i )
+ {
+ if ( error )
+ *error = IDSource_INVALID;
+ return false;
+ }
+ }
prepareIdSource( theIDSource );
SMESH::long_array_var anIDs = theIDSource->GetIDs();
if ( anIDs->length() == 0 )
Example: :ref:`tui_extrusion_along_path`
"""
+ if not IDsOfElements:
+ IDsOfElements = [ self.GetMesh() ]
n,e,f = [],IDsOfElements,IDsOfElements
gr,er = self.ExtrusionAlongPathObjects(n,e,f, PathMesh, PathShape,
NodeStart, HasAngles, Angles,
Parameters:
Tolerance: the value of tolerance
- SubMeshOrGroup: :class:`sub-mesh, group or filter <SMESH.SMESH_IDSource>` or node IDs
+ SubMeshOrGroup: list of :class:`sub-meshes, groups or filters <SMESH.SMESH_IDSource>` or of node IDs
exceptNodes: list of either SubMeshes, Groups or node IDs to exclude from search
SeparateCornerAndMediumNodes: if *True*, in quadratic mesh puts
corner and medium nodes in separate groups thus preventing
"""
unRegister = genObjUnRegister()
- if (isinstance( SubMeshOrGroup, Mesh )):
- SubMeshOrGroup = SubMeshOrGroup.GetMesh()
- if isinstance( SubMeshOrGroup, list ):
- SubMeshOrGroup = self.GetIDSource( SubMeshOrGroup, SMESH.NODE )
- unRegister.set( SubMeshOrGroup )
+ if not isinstance( SubMeshOrGroup, list ):
+ SubMeshOrGroup = [ SubMeshOrGroup ]
+ for i,obj in enumerate( SubMeshOrGroup ):
+ if isinstance( obj, Mesh ):
+ SubMeshOrGroup = [ obj.GetMesh() ]
+ break
+ if isinstance( obj, int ):
+ SubMeshOrGroup = self.GetIDSource( SubMeshOrGroup, SMESH.NODE )
+ unRegister.set( SubMeshOrGroup )
+ break
if not isinstance( exceptNodes, list ):
exceptNodes = [ exceptNodes ]
Parameters:
GroupsOfNodes: a list of groups of nodes IDs for merging.
E.g. [[1,12,13],[25,4]] means that nodes 12, 13 and 4 will be removed and replaced
- in all elements and groups by nodes 1 and 25 correspondingly
+ in all elements and mesh groups by nodes 1 and 25 correspondingly
NodesToKeep: nodes to keep in the mesh: a list of groups, sub-meshes or node IDs.
If *NodesToKeep* does not include a node to keep for some group to merge,
then the first node in the group is kept.
AvoidMakingHoles: prevent merging nodes which cause removal of elements becoming
invalid
"""
- # NodesToKeep are converted to SMESH.SMESH_IDSource in meshEditor.MergeNodes()
self.editor.MergeNodes( GroupsOfNodes, NodesToKeep, AvoidMakingHoles )
- def FindEqualElements (self, MeshOrSubMeshOrGroup=None):
+ def FindEqualElements (self, MeshOrSubMeshOrGroup=None, exceptElements=[]):
"""
Find the elements built on the same nodes.
Parameters:
- MeshOrSubMeshOrGroup: :class:`mesh, sub-mesh, group or filter <SMESH.SMESH_IDSource>`
+ MeshOrSubMeshOrGroup: :class:`mesh, sub-meshes, groups or filters <SMESH.SMESH_IDSource>` or element IDs to check for equal elements
+ exceptElements: list of either SubMeshes, Groups or elements IDs to exclude from search
+
Returns:
the list of groups of equal elements IDs (e.g. [[1,12,13],[4,25]])
"""
- if not MeshOrSubMeshOrGroup:
- MeshOrSubMeshOrGroup=self.mesh
+ unRegister = genObjUnRegister()
+ if MeshOrSubMeshOrGroup is None:
+ MeshOrSubMeshOrGroup = [ self.mesh ]
elif isinstance( MeshOrSubMeshOrGroup, Mesh ):
- MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
- return self.editor.FindEqualElements( MeshOrSubMeshOrGroup )
-
- def MergeElements(self, GroupsOfElementsID):
+ MeshOrSubMeshOrGroup = [ MeshOrSubMeshOrGroup.GetMesh() ]
+ elif not isinstance( MeshOrSubMeshOrGroup, list ):
+ MeshOrSubMeshOrGroup = [ MeshOrSubMeshOrGroup ]
+ if isinstance( MeshOrSubMeshOrGroup[0], int ):
+ MeshOrSubMeshOrGroup = [ self.GetIDSource( MeshOrSubMeshOrGroup, SMESH.ALL )]
+ unRegister.set( MeshOrSubMeshOrGroup )
+ for item in MeshOrSubMeshOrGroup:
+ if isinstance( item, Mesh ):
+ MeshOrSubMeshOrGroup = [ item.GetMesh() ]
+
+ if not isinstance( exceptElements, list ):
+ exceptElements = [ exceptElements ]
+ if exceptElements and isinstance( exceptElements[0], int ):
+ exceptElements = [ self.GetIDSource( exceptElements, SMESH.ALL )]
+ unRegister.set( exceptElements )
+
+ return self.editor.FindEqualElements( MeshOrSubMeshOrGroup, exceptElements )
+
+ def MergeElements(self, GroupsOfElementsID, ElementsToKeep=[]):
"""
Merge elements in each given group.
Parameters:
GroupsOfElementsID: a list of groups (lists) of elements IDs for merging
(e.g. [[1,12,13],[25,4]] means that elements 12, 13 and 4 will be removed and
- replaced in all groups by elements 1 and 25)
+ replaced in all mesh groups by elements 1 and 25)
+ ElementsToKeep: elements to keep in the mesh: a list of groups, sub-meshes or node IDs.
+ If *ElementsToKeep* does not include an element to keep for some group to merge,
+ then the first element in the group is kept.
"""
- self.editor.MergeElements(GroupsOfElementsID)
+ unRegister = genObjUnRegister()
+ if ElementsToKeep:
+ if not isinstance( ElementsToKeep, list ):
+ ElementsToKeep = [ ElementsToKeep ]
+ if isinstance( ElementsToKeep[0], int ):
+ ElementsToKeep = [ self.GetIDSource( ElementsToKeep, SMESH.ALL )]
+ unRegister.set( ElementsToKeep )
+
+ self.editor.MergeElements( GroupsOfElementsID, ElementsToKeep )
def MergeEqualElements(self):
"""