\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
<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
/*!
* 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.
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);
/*!
//================================================================================
/*!
- * \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
{
{
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() );
}
}
}
// 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,
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() );
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
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" ),
#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;
//---------------------------------------------------------------------------------
/*!
QGroupBox* myGroupBox;
QLabel* myGroupLabel;
QComboBox* myGroupListCmBox;
+ QCheckBox* myDuplicateElemsChkBox;
SMESHGUI_IdValidator myIDValidator;
};
SMESHGUI_Add0DElemsOnAllNodesDlg* myDlg;
SMESHGUI_FilterDlg* myFilterDlg;
Handle(SALOME_InteractiveObject) myIO;
- //SUIT_SelectionFilter* myObjectFilter;
};
#endif
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;
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);
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);
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
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();
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
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
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
- QCheckBox* Reverse;
+ QCheckBox* ReverseOrDulicate;
SMESHGUI_SpinBox* DiameterSpinBox;
QString myHelpFileName;
<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>
<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>
*/
//=============================================================================
-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 <<" )";
//=============================================================================
//
-// \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.
//
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;
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() );
*/
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);
* \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);
/*!
# idSrc.UnRegister()
# @ingroup l1_auxiliary
def GetIDSource(self, ids, elemType = SMESH.ALL):
+ if isinstance( ids, int ):
+ ids = [ids]
return self.editor.MakeIDSource(ids, elemType)
## 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.
# 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.