IMP 23201: Harmonisation of "0D Element" and "0D Elements on Element Nodes"

This commit is contained in:
eap 2016-08-11 20:13:30 +03:00
parent 5c5e1f2368
commit 7c69e00bac
14 changed files with 93 additions and 54 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -81,7 +81,8 @@ created:
\image html add0delement.png
In this dialog box specify nodes which will form your 0D elements by
selecting them in the 3D viewer and click the \b Apply or
selecting them in the 3D viewer. Activate <b>Allow duplicate
elements</b> to get several 0D elements on a node. Click the \b Apply or
<b>Apply and Close</b> button. Your 0D elements will be created:
\image html add_0delement.png
@ -109,6 +110,8 @@ In this dialog
<li><b> Set Filter </b> button allows selecting elements or nodes
by filtering mesh elements or nodes with different criteria
(see \ref filtering_elements "Filter usage").</li>
<li>Activate <b>Allow duplicate elements</b> to get several 0D
elements on a node. </li>
<li> Switching on <b>Add to group</b> check-box allows specifying the
name of the group to which all created or found (existing) 0D elements will
be added. You can either select an existing group from a drop-down

View File

@ -136,8 +136,10 @@ module SMESH
/*!
* Create a 0D element on the given node.
* \param IdOfNode Node IDs for creation of element.
* \param DuplicateElements to add one more 0D element to a node or not
*/
long Add0DElement(in long IDOfNode) raises (SALOME::SALOME_Exception);
long Add0DElement(in long IDOfNode,
in boolean DuplicateElements) raises (SALOME::SALOME_Exception);
/*!
* Create a ball element on the given node.
@ -201,16 +203,17 @@ module SMESH
long AddPolyhedralVolumeByFaces (in long_array IdsOfFaces) raises (SALOME::SALOME_Exception);
/*!
* Create 0D elements on all nodes of the given object except those
* nodes on which a 0D element already exists.
* Create 0D elements on all nodes of the given object.
* \param theObject object on whose nodes 0D elements will be created.
* \param theGroupName optional name of a group to add 0D elements created
* and/or found on nodes of \a theObject.
* \param theDuplicateElements to add one more 0D element to a node or not
* \return an object (a new group or a temporary SMESH_IDSource) holding
* ids of new and/or found 0D elements.
*/
SMESH_IDSource Create0DElementsOnAllNodes(in SMESH_IDSource theObject,
in string theGroupName)
in string theGroupName,
in boolean theDuplicateElements)
raises (SALOME::SALOME_Exception);
/*!

View File

@ -474,27 +474,22 @@ int SMESH_MeshEditor::Remove (const list< int >& theIDs,
//================================================================================
/*!
* \brief Create 0D elements on all nodes of the given object except those
* nodes on which a 0D element already exists.
* \brief Create 0D elements on all nodes of the given object.
* \param elements - Elements on whose nodes to create 0D elements; if empty,
* the all mesh is treated
* \param all0DElems - returns all 0D elements found or created on nodes of \a elements
* \param duplicateElements - to add one more 0D element to a node or not
*/
//================================================================================
void SMESH_MeshEditor::Create0DElementsOnAllNodes( const TIDSortedElemSet& elements,
TIDSortedElemSet& all0DElems )
TIDSortedElemSet& all0DElems,
const bool duplicateElements )
{
SMDS_ElemIteratorPtr elemIt;
vector< const SMDS_MeshElement* > allNodes;
if ( elements.empty() )
{
allNodes.reserve( GetMeshDS()->NbNodes() );
elemIt = GetMeshDS()->elementsIterator( SMDSAbs_Node );
while ( elemIt->more() )
allNodes.push_back( elemIt->next() );
elemIt = elemSetIterator( allNodes );
}
else
{
@ -509,12 +504,13 @@ void SMESH_MeshEditor::Create0DElementsOnAllNodes( const TIDSortedElemSet& eleme
{
const SMDS_MeshNode* n = cast2Node( nodeIt->next() );
SMDS_ElemIteratorPtr it0D = n->GetInverseElementIterator( SMDSAbs_0DElement );
if ( it0D->more() )
all0DElems.insert( it0D->next() );
else {
if ( duplicateElements || !it0D->more() )
{
myLastCreatedElems.Append( GetMeshDS()->Add0DElement( n ));
all0DElems.insert( myLastCreatedElems.Last() );
}
while ( it0D->more() )
all0DElems.insert( it0D->next() );
}
}
}

View File

@ -129,9 +129,9 @@ public:
// Modify a compute state of sub-meshes which become empty
void Create0DElementsOnAllNodes( const TIDSortedElemSet& elements,
TIDSortedElemSet& all0DElems);
// Create 0D elements on all nodes of the given object except those
// nodes on which a 0D element already exists. \a all0DElems returns
TIDSortedElemSet& all0DElems,
const bool duplicateElements);
// Create 0D elements on all nodes of the given. \a all0DElems returns
// all 0D elements found or created on nodes of \a elements
bool InverseDiag (const SMDS_MeshElement * theTria1,

View File

@ -104,6 +104,8 @@ SMESHGUI_Add0DElemsOnAllNodesDlg::SMESHGUI_Add0DElemsOnAllNodesDlg()
myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), mainFrame() );
myDuplicateElemsChkBox = new QCheckBox( tr( "SMESH_DUPLICATE_0D" ), mainFrame() );
// List of groups
myGroupBox = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), mainFrame() );
@ -132,8 +134,9 @@ SMESHGUI_Add0DElemsOnAllNodesDlg::SMESHGUI_Add0DElemsOnAllNodesDlg()
aLay->addWidget( objectWg( 0, Btn ), 1, 1 );
aLay->addWidget( objectWg( 0, Control), 1, 2, 1, 2 );
aLay->addWidget( myFilterBtn, 1, 4 );
aLay->addWidget( myDuplicateElemsChkBox,2, 0 );
//
aLay->addWidget( myGroupBox, 2, 0, 1, 5 );
aLay->addWidget( myGroupBox, 3, 0, 1, 5 );
// Signals
@ -439,7 +442,8 @@ bool SMESHGUI_Add0DElemsOnAllNodesOp::onApply()
QString groupName = myDlg->myGroupListCmBox->currentText();
SMESH::SMESH_IDSource_var newObj =
editor->Create0DElementsOnAllNodes( meshObject, groupName.toLatin1().data() );
editor->Create0DElementsOnAllNodes( meshObject, groupName.toLatin1().data(),
myDlg->myDuplicateElemsChkBox->isChecked() );
int newNb0D = mesh->Nb0DElements() - prevNb0D;
SUIT_MessageBox::information( myDlg, tr( "SMESH_INFORMATION" ),

View File

@ -31,13 +31,14 @@
#include "SMESHGUI_Dialog.h"
#include "SMESHGUI_IdValidator.h"
class SMESHGUI_FilterDlg;
class SMESHGUI_Add0DElemsOnAllNodesOp;
class QButtonGroup;
class QPushButton;
class QCheckBox;
class QComboBox;
class QGroupBox;
class QLabel;
class QComboBox;
class QPushButton;
class SMESHGUI_Add0DElemsOnAllNodesOp;
class SMESHGUI_FilterDlg;
//---------------------------------------------------------------------------------
/*!
@ -72,6 +73,7 @@ signals:
QGroupBox* myGroupBox;
QLabel* myGroupLabel;
QComboBox* myGroupListCmBox;
QCheckBox* myDuplicateElemsChkBox;
SMESHGUI_IdValidator myIDValidator;
};
@ -106,7 +108,6 @@ class SMESHGUI_EXPORT SMESHGUI_Add0DElemsOnAllNodesOp : public SMESHGUI_Selectio
SMESHGUI_Add0DElemsOnAllNodesDlg* myDlg;
SMESHGUI_FilterDlg* myFilterDlg;
Handle(SALOME_InteractiveObject) myIO;
//SUIT_SelectionFilter* myObjectFilter;
};
#endif

View File

@ -413,7 +413,9 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theMo
LineEditC1A1->setValidator
(new SMESHGUI_IdValidator(this, ( myIsPoly || myNbNodes == 1 ) ? 1000 : myNbNodes));
Reverse = (myElementType == SMDSAbs_Face || myElementType == SMDSAbs_Volume ) ? new QCheckBox(tr("SMESH_REVERSE"), GroupC1) : 0;
ReverseOrDulicate = (myElementType == SMDSAbs_Face || myElementType == SMDSAbs_Volume ) ? new QCheckBox(tr("SMESH_REVERSE"), GroupC1) : 0;
if ( myElementType == SMDSAbs_0DElement )
ReverseOrDulicate = new QCheckBox(tr("SMESH_DUPLICATE_0D"), GroupC1);
DiameterSpinBox = ( myGeomType == SMDSEntity_Ball ) ? new SMESHGUI_SpinBox(GroupC1) : 0;
QLabel* diameterLabel = DiameterSpinBox ? new QLabel( tr("BALL_DIAMETER"),GroupC1) : 0;
@ -421,8 +423,8 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theMo
GroupC1Layout->addWidget(TextLabelC1A1, 0, 0);
GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1);
GroupC1Layout->addWidget(LineEditC1A1, 0, 2);
if ( Reverse ) {
GroupC1Layout->addWidget(Reverse, 1, 0, 1, 3);
if ( ReverseOrDulicate ) {
GroupC1Layout->addWidget(ReverseOrDulicate, 1, 0, 1, 3);
}
if ( DiameterSpinBox ) {
GroupC1Layout->addWidget(diameterLabel, 1, 0);
@ -524,8 +526,8 @@ void SMESHGUI_AddMeshElementDlg::Init()
connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), SLOT(onOpenView()));
connect(mySMESHGUI, SIGNAL(SignalCloseView()), SLOT(onCloseView()));
if (Reverse)
connect(Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)));
if (ReverseOrDulicate)
connect(ReverseOrDulicate, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)));
// set selection mode
SMESH::SetPointRepresentation(true);
@ -553,10 +555,10 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply()
SMESH::long_array_var anArrayOfIndices = new SMESH::long_array;
anArrayOfIndices->length(aListId.count());
const std::vector<int>& revIndex = SMDS_MeshCell::reverseSmdsOrder( myGeomType );
if ( Reverse && Reverse->isChecked() && !revIndex.empty() )
if ( ReverseOrDulicate && ReverseOrDulicate->isChecked() && (int)revIndex.size() == aListId.count() )
for (int i = 0; i < aListId.count(); i++)
anArrayOfIndices[i] = aListId[ revIndex[i] ].toInt();
else if ( Reverse && Reverse->isChecked() && revIndex.empty() ) // polygon
else if ( ReverseOrDulicate && ReverseOrDulicate->isChecked() && revIndex.empty() ) // polygon
for (int i = 0; i < aListId.count(); i++)
anArrayOfIndices[i] = aListId[ aListId.count()-1 - i ].toInt();
else
@ -598,16 +600,23 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply()
SMESH::long_array_var anIdList = new SMESH::long_array;
anIdList->length( 1 );
anIdList[0] = -1;
//const bool onlyNodesInMesh = ( myMesh->NbElements() == 0 );
int nbElemsBefore = 0;
switch (myElementType) {
case SMDSAbs_0DElement:
case SMDSAbs_0DElement: {
bool duplicateElements = ReverseOrDulicate->isChecked();
nbElemsBefore = myMesh->Nb0DElements();
anIdList->length( anArrayOfIndices->length() );
for ( size_t i = 0; i < anArrayOfIndices->length(); ++i )
anIdList[i] = aMeshEditor->Add0DElement(anArrayOfIndices[i]);
anIdList[i] = aMeshEditor->Add0DElement(anArrayOfIndices[i], duplicateElements);
CORBA::ULong nbAdded = myMesh->Nb0DElements() - nbElemsBefore;
if ( !duplicateElements && nbAdded < anArrayOfIndices->length() )
SUIT_MessageBox::information(SMESHGUI::desktop(),
tr("SMESH_INFORMATION"),
tr("NB_ADDED").arg( nbAdded ));
break;
}
case SMDSAbs_Ball:
if ( myGeomType == SMDSEntity_Ball ) {
nbElemsBefore = myMesh->NbBalls();
@ -672,8 +681,7 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply()
mySelectionMgr->setSelectedObjects( aList, false );
mySimulation->SetVisibility(false);
// if ( onlyNodesInMesh )
// myActor->SetRepresentation( SMESH_Actor::eEdge ); // wireframe
if ( nbElemsBefore == 0 )
{
// 1st element of the type has been added, update actor to show this entity
@ -908,7 +916,7 @@ void SMESHGUI_AddMeshElementDlg::displaySimulation()
for (int i = 0; i < aListId.count(); i++)
anIds.push_back(myActor->GetObject()->GetNodeVTKId(aListId[ i ].toInt()));
if (Reverse && Reverse->isChecked())
if (ReverseOrDulicate && ReverseOrDulicate->isChecked())
{
const std::vector<int>& i = SMDS_MeshCell::reverseSmdsOrder( myGeomType );
if ( i.empty() ) // polygon

View File

@ -111,7 +111,7 @@ private:
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QCheckBox* Reverse;
QCheckBox* ReverseOrDulicate;
SMESHGUI_SpinBox* DiameterSpinBox;
QString myHelpFileName;

View File

@ -1241,6 +1241,10 @@ Please enter correct values and try again</translation>
<source>SMESH_ADD_ELEM0D_TITLE</source>
<translation>Add 0D Element</translation>
</message>
<message>
<source>SMESH_DUPLICATE_0D</source>
<translation>Allow duplicate elements</translation>
</message>
<message>
<source>SMESH_ADD_BALL</source>
<translation>Add Ball Element</translation>
@ -4389,6 +4393,14 @@ It can&apos;t be deleted </translation>
<translation>Export Fields</translation>
</message>
</context>
<context>
<name>SMESHGUI_AddMeshElementDlg</name>
<message>
<source>NB_ADDED</source>
<translation>%1 elements have been added since 0D
elements already present on the selected nodes.</translation>
</message>
</context>
<context>
<name>SMESHGUI_Dialog</name>
<message>

View File

@ -903,14 +903,19 @@ CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x,CORBA::Double y, CORBA::
*/
//=============================================================================
CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode)
CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode,
CORBA::Boolean DuplicateElements)
throw (SALOME::SALOME_Exception)
{
SMESH_TRY;
initData();
const SMDS_MeshNode* aNode = getMeshDS()->FindNode(IDOfNode);
SMDS_MeshElement* elem = getMeshDS()->Add0DElement(aNode);
SMDS_ElemIteratorPtr it0D = aNode->GetInverseElementIterator( SMDSAbs_0DElement );
SMDS_MeshElement* elem = 0;
if ( DuplicateElements || !it0D->more() )
elem = getMeshDS()->Add0DElement(aNode);
// Update Python script
TPythonDump() << "elem0d = " << this << ".Add0DElement( " << IDOfNode <<" )";
@ -1243,11 +1248,11 @@ CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces (const SMESH::long_ar
//=============================================================================
//
// \brief Create 0D elements on all nodes of the given object except those
// nodes on which a 0D element already exists.
// \brief Create 0D elements on all nodes of the given object.
// \param theObject object on whose nodes 0D elements will be created.
// \param theGroupName optional name of a group to add 0D elements created
// and/or found on nodes of \a theObject.
// \param DuplicateElements to add one more 0D element to a node or not.
// \return an object (a new group or a temporary SMESH_IDSource) holding
// ids of new and/or found 0D elements.
//
@ -1255,7 +1260,8 @@ CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces (const SMESH::long_ar
SMESH::SMESH_IDSource_ptr
SMESH_MeshEditor_i::Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObject,
const char* theGroupName)
const char* theGroupName,
CORBA::Boolean theDuplicateElements)
throw (SALOME::SALOME_Exception)
{
SMESH_TRY;
@ -1266,7 +1272,7 @@ SMESH_MeshEditor_i::Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObje
TIDSortedElemSet elements, elems0D;
if ( idSourceToSet( theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
getEditor().Create0DElementsOnAllNodes( elements, elems0D );
getEditor().Create0DElementsOnAllNodes( elements, elems0D, theDuplicateElements );
SMESH::long_array_var newElems = new SMESH::long_array;
newElems->length( elems0D.size() );

View File

@ -108,7 +108,7 @@ public:
*/
CORBA::Long AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z)
throw (SALOME::SALOME_Exception);
CORBA::Long Add0DElement(CORBA::Long IDOfNode)
CORBA::Long Add0DElement(CORBA::Long IDOfNode, CORBA::Boolean DuplicateElements)
throw (SALOME::SALOME_Exception);
CORBA::Long AddBall(CORBA::Long IDOfNodem, CORBA::Double diameter)
throw (SALOME::SALOME_Exception);
@ -134,11 +134,13 @@ public:
* \param theObject object on whose nodes 0D elements will be created.
* \param theGroupName optional name of a group to add 0D elements created
* and/or found on nodes of \a theObject.
* \param theDuplicateElements to add one more 0D element to a node or not
* \return an object (a new group or a temporary SMESH_IDSource) holding
* ids of new and/or found 0D elements.
*/
SMESH::SMESH_IDSource_ptr Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObject,
const char* theGroupName)
const char* theGroupName,
CORBA::Boolean theDuplicateElements)
throw (SALOME::SALOME_Exception);
/*!

View File

@ -2264,6 +2264,8 @@ class Mesh:
# idSrc.UnRegister()
# @ingroup l1_auxiliary
def GetIDSource(self, ids, elemType = SMESH.ALL):
if isinstance( ids, int ):
ids = [ids]
return self.editor.MakeIDSource(ids, elemType)
@ -2828,10 +2830,11 @@ class Mesh:
## Creates a 0D element on a node with given number.
# @param IDOfNode the ID of node for creation of the element.
# @param DuplicateElements to add one more 0D element to a node or not
# @return the Id of the new 0D element
# @ingroup l2_modif_add
def Add0DElement(self, IDOfNode):
return self.editor.Add0DElement(IDOfNode)
def Add0DElement( self, IDOfNode, DuplicateElements=True ):
return self.editor.Add0DElement( IDOfNode, DuplicateElements )
## Create 0D elements on all nodes of the given elements except those
# nodes on which a 0D element already exists.
@ -2840,18 +2843,19 @@ class Mesh:
# of nodes IDs created by calling mesh.GetIDSource( nodes, SMESH.NODE )
# @param theGroupName optional name of a group to add 0D elements created
# and/or found on nodes of \a theObject.
# @param DuplicateElements to add one more 0D element to a node or not
# @return an object (a new group or a temporary SMESH_IDSource) holding
# IDs of new and/or found 0D elements. IDs of 0D elements
# can be retrieved from the returned object by calling GetIDs()
# @ingroup l2_modif_add
def Add0DElementsToAllNodes(self, theObject, theGroupName=""):
def Add0DElementsToAllNodes(self, theObject, theGroupName="", DuplicateElements=False):
unRegister = genObjUnRegister()
if isinstance( theObject, Mesh ):
theObject = theObject.GetMesh()
if isinstance( theObject, list ):
elif isinstance( theObject, list ):
theObject = self.GetIDSource( theObject, SMESH.ALL )
unRegister.set( theObject )
return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName )
return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName, DuplicateElements )
## Creates a ball element on a node with given ID.
# @param IDOfNode the ID of node for creation of the element.