IMP 22635: EDF 8345 - Creation of group based on groups

+ allow concatenating sub-meshes and groups
+ fix bugs in PythonDump
This commit is contained in:
eap 2015-03-03 15:03:38 +03:00
parent 066f625a46
commit bb40f7c1d3
29 changed files with 698 additions and 511 deletions

View File

@ -1,5 +1,4 @@
# Building a compound of meshes # Building a compound of meshes
# Note: it is a copy of 'SMESH_BuildCompound.py' from SMESH_SWIG
import salome import salome
salome.salome_init() salome.salome_init()
@ -69,11 +68,14 @@ Gsup2=Mesh_sup.Group(Fsup2, "Sup")
Ginf2=Mesh_sup.Group(Finf2, "Inf") Ginf2=Mesh_sup.Group(Finf2, "Inf")
## create compounds ## create compounds
# create a compound of two meshes with renaming groups with the same names and # create a compound of two meshes with renaming namesake groups and
# merging of elements with the given tolerance # merging of elements with the given tolerance
Compound1 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05) Compound1 = smesh.Concatenate([Mesh_inf, Mesh_sup], 0, 1, 1e-05,
smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems') name='Compound_with_RenamedGrps_and_MergeElems')
# create a compound of two meshes with uniting groups with the same names and # create a compound of two meshes with uniting namesake groups and
# creating groups of all elements # creating groups of all elements
Compound2 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True) Compound2 = smesh.Concatenate([Mesh_inf, Mesh_sup], 1, 0, 1e-05, True,
smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems') name='Compound_with_UniteGrps_and_GrpsOfAllElems')
if salome.sg.hasDesktop():
salome.sg.updateObjBrowser(1)

View File

@ -1,4 +1,4 @@
# Creating groups of entities from existing groups of superior dimensions # Creating groups of entities basing on nodes of other groups
import SMESH_mechanic import SMESH_mechanic
import SMESH import SMESH
@ -10,22 +10,17 @@ salome = SMESH_mechanic.salome
# Criterion : AREA > 100 # Criterion : AREA > 100
aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.) aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area > 100, Nb = ", len(anIds)
# create a group by adding elements with area > 100 # create a group by adding elements with area > 100
aSrcGroup1 = mesh.MakeGroupByIds("Area > 100", SMESH.FACE, anIds) aSrcGroup1 = mesh.GroupOnFilter(SMESH.FACE, "Area > 100", aFilter)
print "Criterion: Area > 100, Nb = ", aSrcGroup1.Size()
# Criterion : AREA < 30 # Criterion : AREA < 30
aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 30.) aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 30.)
anIds = mesh.GetIdsFromFilter(aFilter)
print "Criterion: Area < 30, Nb = ", len(anIds)
# create a group by adding elements with area < 30 # create a group by adding elements with area < 30
aSrcGroup2 = mesh.MakeGroupByIds("Area < 30", SMESH.FACE, anIds) aSrcGroup2 = mesh.GroupOnFilter(SMESH.FACE, "Area < 30", aFilter)
print "Criterion: Area < 30, Nb = ", aSrcGroup2.Size()
# Create group of edges using source groups of faces # Create group of edges using source groups of faces
aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], SMESH.EDGE, "Edges" ) aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], SMESH.EDGE, "Edges" )

BIN
doc/salome/gui/SMESH/images/buildcompound.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 21 KiB

BIN
doc/salome/gui/SMESH/images/image160.gif Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -65,7 +65,7 @@ the <a href="http://www.code-aster.org/outils/med/html/connectivites.html">
the element basing on elements of lower dimension is NOT supported. the element basing on elements of lower dimension is NOT supported.
\anchor mesh_entities \anchor mesh_entities
The mesh can include the following entities: The mesh can include the following entities (also referred as \a elements):
<ul> <ul>
<li>\b Node &mdash; an entity of a mesh defining a position in 3D <li>\b Node &mdash; an entity of a mesh defining a position in 3D
space with coordinates (x, y, z).</li> space with coordinates (x, y, z).</li>

View File

@ -1,13 +1,15 @@
/*! /*!
\page building_compounds_page Building Compounds \page building_compounds_page Building Compound Meshes
\n Compound Mesh is a combination of several meshes. All elements and \n Compound Mesh is a combination of several meshes. All elements and
groups present in input meshes are present in the compound groups present in input meshes are present in the compound
mesh. Neither geometry nor hypotheses of initial meshes are used by mesh. Neither geometry nor hypotheses of initial meshes are used by
the compound mesh. the compound mesh. No link between input meshes and a compound mesh is
supported, so that modification of an input mesh does not lead to
update of the compound mesh.
<em>To Build a compound:</em> <em>To Build a compound mesh:</em>
\par \par
From the \b Mesh menu select <b>Build Compound</b> or click <em>"Build From the \b Mesh menu select <b>Build Compound</b> or click <em>"Build
@ -24,23 +26,25 @@ The following dialog box will appear:
\par \par
<ul> <ul>
<li>\b Name - allows selecting the name of the resulting \b Compound mesh.</li> <li>\b Name - allows selecting the name of the resulting \b Compound mesh.</li>
<li>\b Meshes - allows selecting the meshes which will be <li><b>Meshes, sub-meshes, groups</b> - allows selecting the meshes,
concatenated. They can be chosen in the Object Browser while holding sub-meshes and groups which will be concatenated. They can be
\b Ctrl button.</li> chosen in the Object Browser while holding \b Ctrl button.</li>
<li><b>Processing identical groups</b> - allows selecting the method <li><b>Processing identical groups</b> - allows selecting the method
of processing the namesake groups existing in the united meshes. of processing the namesake groups existing in the input meshes.
\n They can be either</li> They can be either <ul>
<ul> <li>\b United - all elements of Group1 of Mesh_1 and Group1 of Mesh_2
<li>\b United - all elements of Group1 of Mesh_1 and Group1 of Mesh_2 become the elements of Group1 of the Compound_Mesh, or</li>
become the elements of Group1 of the Compound_Mesh, or</li> <li>\b Renamed - Group1 of Mesh_1 becomes Group1_1 and Group1 of Mesh_2
<li>\b Renamed - Group1 of Mesh_1 becomes Group1_1 and Group1 of Mesh_2 becomes Group1_2.</li>
becomes Group1_2.</li> </ul>
</ul> See \ref grouping_elements_page "Creating Groups" for more information
See \ref grouping_elements_page "Creating Groups" for more information about groups.</li>
about groups. <li><b>Create groups from input objects</b> check-box permits to
<li><b>Create common groups for initial meshes</b> check-box permits to
automatically create groups corresponding to every initial mesh. automatically create groups corresponding to every initial mesh.
</li>
\image html buildcompound_groups.png "Groups created from input meshes 'Box_large' and 'Box_small'"
<p></li>
<li>You can choose to additionally <li>You can choose to additionally
\ref merging_nodes_page "Merge coincident nodes" \ref merging_nodes_page "Merge coincident nodes"
\ref merging_elements_page "and elements" in the compound mesh, in \ref merging_elements_page "and elements" in the compound mesh, in

View File

@ -1,20 +1,37 @@
/*! /*!
\page group_of_underlying_elements_page Create Group of Underlying Elements \page group_of_underlying_elements_page Group Based on Nodes of Other Groups
To create groups of entities from existing groups of superior dimensions, in the \b Mesh menu select <b>Group of underlying entities</b>.<br> To create a standalone group of entities basing on nodes of existing
reference groups, in the \b Mesh menu select <b>Group of underlying entities</b>.
The following dialog box will appear: The following dialog box will appear:
\image html dimgroup_dlg.png \image html dimgroup_dlg.png
In this dialog box specify the name of the resulting group, types of entities and set of source groups. In this dialog box specify <ul>
<li> the resulting <b>Group name</b>, </li>
<li> the <b>Elements Type</b> of entities of the resulting group,</li>
<li> the criterion of inclusion of a mesh entity to the result group,
which is <b>Number of common nodes</b> of the entity and the
reference groups: <ul>
<li>\b All - include if all nodes are common;</li>
<li>\b Main - include if all corner nodes are common (meaningful for
a quadratic mesh) </li>
<li><b>At least one</b> - include if one or more node is common</li>
<li>\b Majority - include if half of nodes or more is common</li></ul>
</li>
<li> select reference groups,</li>
<li> <b>Include underlying entities only</b> option if activated
allows inclusion of an entity provided that it is based on nodes of
one element of a reference group.</li>
</ul>
In the figure below, there are two source Volume groups: In the figure below, there are two reference Volume groups:
\image html dimgroup_src.png \image html dimgroup_src.png
<center>Source groups</center> <center>Reference groups</center>
In this case the following results for Faces, Edges and Nodes are obtained: In this case the following results for Faces, Edges and Nodes are obtained:
@ -28,7 +45,7 @@ In this case the following results for Faces, Edges and Nodes are obtained:
<center>Nodes</center> <center>Nodes</center>
<b>See Also</b> a sample TUI Script of a <b>See Also</b> a sample TUI Script of a
\ref tui_create_dim_group "Creating groups of entities from existing groups of superior dimensions" \ref tui_create_dim_group "Creating groups basing on nodes of other groups"
operation. operation.
*/ */

View File

@ -276,16 +276,16 @@ module SMESH
raises ( SALOME::SALOME_Exception ); raises ( SALOME::SALOME_Exception );
/*! /*!
* Concatenate the given meshes into one mesh. * Concatenate the given meshes or groups into one mesh.
* Union groups with the same name and type if * Union groups with the same name and type if
* theUniteIdenticalGroups flag is true. * theUniteIdenticalGroups flag is true.
* Merge coincident nodes and elements if * Merge coincident nodes and elements if
* theMergeNodesAndElements flag is true. * theMergeNodesAndElements flag is true.
*/ */
SMESH_Mesh Concatenate(in mesh_array theMeshesArray, SMESH_Mesh Concatenate(in ListOfIDSources theMeshesArray,
in boolean theUniteIdenticalGroups, in boolean theUniteIdenticalGroups,
in boolean theMergeNodesAndElements, in boolean theMergeNodesAndElements,
in double theMergeTolerance) in double theMergeTolerance)
raises ( SALOME::SALOME_Exception ); raises ( SALOME::SALOME_Exception );
/*! /*!
@ -296,10 +296,10 @@ module SMESH
* theMergeNodesAndElements flag is true. * theMergeNodesAndElements flag is true.
* Create the groups of all elements from initial meshes. * Create the groups of all elements from initial meshes.
*/ */
SMESH_Mesh ConcatenateWithGroups(in mesh_array theMeshesArray, SMESH_Mesh ConcatenateWithGroups(in ListOfIDSources theMeshesArray,
in boolean theUniteIdenticalGroups, in boolean theUniteIdenticalGroups,
in boolean theMergeNodesAndElements, in boolean theMergeNodesAndElements,
in double theMergeTolerance) in double theMergeTolerance)
raises ( SALOME::SALOME_Exception ); raises ( SALOME::SALOME_Exception );
/*! /*!

View File

@ -150,7 +150,8 @@ module SMESH
Geom_PENTA, Geom_PENTA,
Geom_HEXAGONAL_PRISM, Geom_HEXAGONAL_PRISM,
Geom_POLYHEDRA, Geom_POLYHEDRA,
Geom_BALL Geom_BALL,
Geom_LAST
}; };
/*! /*!
@ -252,6 +253,14 @@ module SMESH
long major, minor, release; //!< MED file version long major, minor, release; //!< MED file version
}; };
/*!
* Enumeration for CreateDimGroup()
*/
enum NB_COMMON_NODES_ENUM
{
ALL_NODES, MAIN, AT_LEAST_ONE, MAJORITY
};
/*! /*!
* Auxilary flags for advanced extrusion. * Auxilary flags for advanced extrusion.
* BOUNDARY: create or not boundary for result of extrusion * BOUNDARY: create or not boundary for result of extrusion
@ -497,14 +506,21 @@ module SMESH
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! /*!
* Create groups of entities from existing groups of superior dimensions * Create a group of entities basing on nodes of other groups.
* New group is created. System * \param [in] aListOfGroups - list of either groups, sub-meshes or filters.
* 1) extracts all nodes from each group, * \param [in] anElemType - a type of elements to include to the new group.
* 2) combines all elements of specified dimension laying on these nodes. * \param [in] name - a name of the new group.
* \param [in] nbCommonNodes - criterion of inclusion of an element to the new group.
* \param [in] underlyingOnly - if \c True, an element is included to the
* new group provided that it is based on nodes of an element of
* \a aListOfGroups
* \return SMESH_Group - the created group
*/ */
SMESH_Group CreateDimGroup( in ListOfGroups aListOfGroups, SMESH_Group CreateDimGroup( in ListOfIDSources aListOfGroups,
in ElementType anElemType, in ElementType anElemType,
in string name ) in string name,
in NB_COMMON_NODES_ENUM nbCommonNodes,
in boolean underlyingOnly )
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! /*!

View File

@ -131,7 +131,7 @@ SMESH_MeshEditor::SMESH_MeshEditor( SMESH_Mesh* theMesh )
*/ */
//================================================================================ //================================================================================
void SMESH_MeshEditor::CrearLastCreated() void SMESH_MeshEditor::ClearLastCreated()
{ {
myLastCreatedNodes.Clear(); myLastCreatedNodes.Clear();
myLastCreatedElems.Clear(); myLastCreatedElems.Clear();
@ -10338,7 +10338,7 @@ SMESH_MeshEditor::FindMatchingNodes(set<const SMDS_MeshElement*>& theSide1,
void SMESH_MeshEditor::DoubleElements( const TIDSortedElemSet& theElements ) void SMESH_MeshEditor::DoubleElements( const TIDSortedElemSet& theElements )
{ {
CrearLastCreated(); ClearLastCreated();
SMESHDS_Mesh* mesh = GetMeshDS(); SMESHDS_Mesh* mesh = GetMeshDS();
// get an element type and an iterator over elements // get an element type and an iterator over elements

View File

@ -70,7 +70,7 @@ public:
const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; } const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; } const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
void CrearLastCreated(); void ClearLastCreated();
SMESH_ComputeErrorPtr & GetError() { return myError; } SMESH_ComputeErrorPtr & GetError() { return myError; }
/*! /*!

View File

@ -98,7 +98,17 @@ bool SMESHDS_Group::Contains (const SMDS_MeshElement* elem)
bool SMESHDS_Group::Add (const int theID) bool SMESHDS_Group::Add (const int theID)
{ {
const SMDS_MeshElement* aElem = findInMesh (theID); return Add( findInMesh( theID ));
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool SMESHDS_Group::Add (const SMDS_MeshElement* aElem )
{
if (!aElem || myGroup.Contains(aElem)) if (!aElem || myGroup.Contains(aElem))
return false; return false;

View File

@ -60,6 +60,8 @@ class SMESHDS_EXPORT SMESHDS_Group : public SMESHDS_GroupBase
bool Add (const int theID); bool Add (const int theID);
bool Add (const SMDS_MeshElement* theElem );
bool Remove (const int theID); bool Remove (const int theID);
void Clear(); void Clear();

View File

@ -200,11 +200,11 @@ void SMESHGUI_BuildCompoundDlg::Init()
{ {
mySMESHGUI->SetActiveDialogBox((QDialog*)this); mySMESHGUI->SetActiveDialogBox((QDialog*)this);
myMesh = SMESH::SMESH_Mesh::_nil(); myMesh = SMESH::SMESH_IDSource::_nil();
myMeshFilter = new SMESH_TypeFilter (SMESH::MESH); myMeshFilter = new SMESH_TypeFilter (SMESH::IDSOURCE);
myMeshArray = new SMESH::mesh_array(); myMeshArray = new SMESH::ListOfIDSources();
// signals and slots connections // signals and slots connections
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
@ -289,7 +289,7 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
if (!isValid()) if (!isValid())
return false; return false;
SMESH::SMESH_Mesh_var aCompoundMesh; SMESH::SMESH_Mesh_var aMesh;
if (!myMesh->_is_nil()) if (!myMesh->_is_nil())
{ {
@ -300,22 +300,23 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
try { try {
SUIT_OverrideCursor aWaitCursor; SUIT_OverrideCursor aWaitCursor;
myMeshArray[0]->SetParameters( aParameters.join(":").toLatin1().constData() ); aMesh = myMeshArray[0]->GetMesh();
aMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen(); SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
// concatenate meshes // concatenate meshes
if(CheckBoxCommon->isChecked()) if(CheckBoxCommon->isChecked())
aCompoundMesh = aSMESHGen->ConcatenateWithGroups(myMeshArray, aMesh = aSMESHGen->ConcatenateWithGroups(myMeshArray,
!(ComboBoxUnion->currentIndex()), !(ComboBoxUnion->currentIndex()),
CheckBoxMerge->isChecked(), CheckBoxMerge->isChecked(),
SpinBoxTol->GetValue()); SpinBoxTol->GetValue());
else else
aCompoundMesh = aSMESHGen->Concatenate(myMeshArray, aMesh = aSMESHGen->Concatenate(myMeshArray,
!(ComboBoxUnion->currentIndex()), !(ComboBoxUnion->currentIndex()),
CheckBoxMerge->isChecked(), CheckBoxMerge->isChecked(),
SpinBoxTol->GetValue()); SpinBoxTol->GetValue());
_PTR(SObject) aSO = SMESH::FindSObject( aCompoundMesh ); _PTR(SObject) aSO = SMESH::FindSObject( aMesh );
if( aSO ) { if( aSO ) {
SMESH::SetName( aSO, LineEditName->text() ); SMESH::SetName( aSO, LineEditName->text() );
anEntryList.append( aSO->GetID().c_str() ); anEntryList.append( aSO->GetID().c_str() );
@ -332,7 +333,7 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
mySelectionMgr->clearSelected(); mySelectionMgr->clearSelected();
SMESH::UpdateView(); SMESH::UpdateView();
_PTR(SObject) aSO = SMESH::FindSObject(aCompoundMesh.in()); _PTR(SObject) aSO = SMESH::FindSObject(aMesh.in());
if ( SMESH_Actor* anActor = SMESH::CreateActor(aSO->GetStudy(), aSO->GetID().c_str()) ) { if ( SMESH_Actor* anActor = SMESH::CreateActor(aSO->GetStudy(), aSO->GetID().c_str()) ) {
SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor); SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor);
SMESH::UpdateView(); SMESH::UpdateView();
@ -412,12 +413,12 @@ void SMESHGUI_BuildCompoundDlg::SelectionIntoArgument()
for (int i = 0; nbSel != 0; i++, nbSel--) { for (int i = 0; nbSel != 0; i++, nbSel--) {
Handle(SALOME_InteractiveObject) IO = aList.First(); Handle(SALOME_InteractiveObject) IO = aList.First();
aList.RemoveFirst(); aList.RemoveFirst();
myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO); myMesh = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
myMeshArray[i] = myMesh; myMeshArray[i] = myMesh;
} }
} }
else { else {
myMesh = SMESH::SMESH_Mesh::_nil(); myMesh = SMESH::SMESH_IDSource::_nil();
aString = ""; aString = "";
} }

View File

@ -80,9 +80,9 @@ private:
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_IDSource_var myMesh;
SUIT_SelectionFilter* myMeshFilter; SUIT_SelectionFilter* myMeshFilter;
SMESH::mesh_array_var myMeshArray; SMESH::ListOfIDSources_var myMeshArray;
// Widgets // Widgets
QGroupBox* GroupConstructors; QGroupBox* GroupConstructors;

View File

@ -30,37 +30,34 @@
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_VTKUtils.h"
#include "SMESH_TypeFilter.hxx"
#include <SMESH_TypeFilter.hxx>
// SALOME GUI includes
#include <SUIT_ResourceMgr.h>
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#include <SUIT_MessageBox.h>
#include <LightApp_Application.h> #include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <QtxColorButton.h>
#include <SALOMEDSClient_SObject.hxx>
#include <SALOME_ListIO.hxx>
#include <SUIT_Desktop.h>
#include <SUIT_MessageBox.h>
#include <SUIT_OverrideCursor.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SVTK_Selection.h> #include <SVTK_Selection.h>
#include <SVTK_ViewWindow.h> #include <SVTK_ViewWindow.h>
#include <SALOME_ListIO.hxx>
// SALOME KERNEL includes
#include <SALOMEDSClient_SObject.hxx>
// Qt includes // Qt includes
#include <QHBoxLayout> #include <QButtonGroup>
#include <QVBoxLayout> #include <QCheckBox>
#include <QComboBox>
#include <QGridLayout> #include <QGridLayout>
#include <QPushButton>
#include <QGroupBox> #include <QGroupBox>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QKeyEvent>
#include <QListWidget> #include <QListWidget>
#include <QButtonGroup> #include <QPushButton>
#include <QComboBox> #include <QVBoxLayout>
#include <QtxColorButton.h>
#define SPACING 6 #define SPACING 6
#define MARGIN 11 #define MARGIN 11
@ -110,7 +107,7 @@ QWidget* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent )
aLay->setSpacing(SPACING); aLay->setSpacing(SPACING);
// ------------------------------------------------------ // ------------------------------------------------------
QGroupBox* aNameGrp = new QGroupBox(tr("NAME"), aMainGrp); QGroupBox* aNameGrp = new QGroupBox(tr("RESULT"), aMainGrp);
QHBoxLayout* aNameGrpLayout = new QHBoxLayout(aNameGrp); QHBoxLayout* aNameGrpLayout = new QHBoxLayout(aNameGrp);
aNameGrpLayout->setMargin(MARGIN); aNameGrpLayout->setMargin(MARGIN);
aNameGrpLayout->setSpacing(SPACING); aNameGrpLayout->setSpacing(SPACING);
@ -312,6 +309,7 @@ bool SMESHGUI_GroupOpDlg::isValid( const QList<SMESH::SMESH_GroupBase_var>& theL
*/ */
void SMESHGUI_GroupOpDlg::onOk() void SMESHGUI_GroupOpDlg::onOk()
{ {
SUIT_OverrideCursor oc;
setIsApplyAndClose( true ); setIsApplyAndClose( true );
if ( onApply() ) if ( onApply() )
reject(); reject();
@ -951,35 +949,55 @@ void SMESHGUI_CutGroupsDlg::onSelectionDone()
\param theModule module \param theModule module
*/ */
SMESHGUI_DimGroupDlg::SMESHGUI_DimGroupDlg( SMESHGUI* theModule ) SMESHGUI_DimGroupDlg::SMESHGUI_DimGroupDlg( SMESHGUI* theModule )
: SMESHGUI_GroupOpDlg( theModule ) : SMESHGUI_GroupOpDlg( theModule )
{ {
setWindowTitle( tr( "CREATE_GROUP_OF_UNDERLYING_ELEMS" ) ); setWindowTitle( tr( "CREATE_GROUP_OF_UNDERLYING_ELEMS" ) );
setHelpFileName( "group_of_underlying_elements_page.html" ); setHelpFileName( "group_of_underlying_elements_page.html" );
QGroupBox* anArgGrp = getArgGrp(); QGroupBox* anArgGrp = getArgGrp();
QLabel* aLbl = new QLabel( tr( "ELEMENTS_TYPE" ), anArgGrp ); QLabel* aTypeLbl = new QLabel( tr( "ELEMENTS_TYPE" ), anArgGrp );
myCombo = new QComboBox( anArgGrp ); myTypeCombo = new QComboBox( anArgGrp );
static QStringList anItems; QStringList anItems;
if ( anItems.isEmpty() )
{ {
anItems.append( tr( "NODE" ) ); anItems.append( tr( "MESH_NODE" ) );
anItems.append( tr( "EDGE" ) ); anItems.append( tr( "SMESH_EDGE" ) );
anItems.append( tr( "FACE" ) ); anItems.append( tr( "SMESH_FACE" ) );
anItems.append( tr( "VOLUME" ) ); anItems.append( tr( "SMESH_VOLUME" ) );
anItems.append( tr( "SMESH_ELEM0D" ) );
anItems.append( tr( "SMESH_BALL" ) );
} }
myCombo->addItems( anItems ); myTypeCombo->addItems( anItems );
myCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myTypeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
QLabel* aNbNoLbl = new QLabel( tr( "NUMBER_OF_COMMON_NODES" ), anArgGrp );
myNbNoCombo = new QComboBox( anArgGrp );
anItems.clear();
{
anItems.append( tr( "ALL" ) );
anItems.append( tr( "MAIN" ) );
anItems.append( tr( "AT_LEAST_ONE" ) );
anItems.append( tr( "MAJORITY" ) );
}
myNbNoCombo->addItems( anItems );
myNbNoCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myListWg = new QListWidget( anArgGrp ); myListWg = new QListWidget( anArgGrp );
myUnderlOnlyChk = new QCheckBox( tr("UNDERLYING_ENTITIES_ONLY"), anArgGrp );
myUnderlOnlyChk->setChecked( false );
// layout // layout
QGridLayout* aLay = new QGridLayout( anArgGrp ); QGridLayout* aLay = new QGridLayout( anArgGrp );
aLay->setSpacing( SPACING ); aLay->setSpacing( SPACING );
aLay->addWidget( aLbl, 0, 0 ); aLay->addWidget( aTypeLbl, 0, 0 );
aLay->addWidget( myCombo, 0, 1 ); aLay->addWidget( myTypeCombo, 0, 1 );
aLay->addWidget( myListWg, 1, 0, 1, 2 ); aLay->addWidget( aNbNoLbl, 1, 0 );
aLay->addWidget( myNbNoCombo, 1, 1 );
aLay->addWidget( myListWg, 2, 0, 1, 2 );
aLay->addWidget( myUnderlOnlyChk, 3, 0 );
} }
/*! /*!
@ -1007,7 +1025,7 @@ void SMESHGUI_DimGroupDlg::reset()
*/ */
SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const
{ {
return (SMESH::ElementType)( myCombo->currentIndex() + 1 ); return (SMESH::ElementType)( myTypeCombo->currentIndex() + 1 );
} }
/*! /*!
@ -1017,7 +1035,7 @@ SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const
*/ */
void SMESHGUI_DimGroupDlg::setElementType( const SMESH::ElementType& theElemType ) void SMESHGUI_DimGroupDlg::setElementType( const SMESH::ElementType& theElemType )
{ {
myCombo->setCurrentIndex( theElemType - 1 ); myTypeCombo->setCurrentIndex( theElemType - 1 );
} }
/*! /*!
@ -1047,10 +1065,19 @@ bool SMESHGUI_DimGroupDlg::onApply()
QStringList anEntryList; QStringList anEntryList;
try try
{ {
SMESH::ListOfGroups_var aList = convert( myGroups ); SMESH::ListOfIDSources_var aList = new SMESH::ListOfIDSources();
aList->length( myGroups.count() );
QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter = myGroups.begin();
for ( int i = 0; anIter != myGroups.end(); ++anIter, ++i )
aList[ i ] = SMESH::SMESH_IDSource::_narrow( *anIter );
SMESH::ElementType anElemType = getElementType(); SMESH::ElementType anElemType = getElementType();
SMESH::NB_COMMON_NODES_ENUM aNbCoNodes =
(SMESH::NB_COMMON_NODES_ENUM) myNbNoCombo->currentIndex();
SMESH::SMESH_Group_var aNewGrp = SMESH::SMESH_Group_var aNewGrp =
aMesh->CreateDimGroup( aList, anElemType, aName.toLatin1().constData() ); aMesh->CreateDimGroup( aList, anElemType, aName.toLatin1().constData(),
aNbCoNodes, myUnderlOnlyChk->isChecked() );
if ( !CORBA::is_nil( aNewGrp ) ) if ( !CORBA::is_nil( aNewGrp ) )
{ {
aNewGrp->SetColor( getColor() ); aNewGrp->SetColor( getColor() );
@ -1092,5 +1119,3 @@ void SMESHGUI_DimGroupDlg::onSelectionDone()
myListWg->clear(); myListWg->clear();
myListWg->addItems( aNames ); myListWg->addItems( aNames );
} }

View File

@ -37,14 +37,15 @@
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(SMESH_Group)
class QPushButton; class LightApp_SelectionMgr;
class QtxColorButton; class QCheckBox;
class QComboBox; class QComboBox;
class QListWidget;
class QGroupBox; class QGroupBox;
class QLineEdit; class QLineEdit;
class QListWidget;
class QPushButton;
class QtxColorButton;
class SMESHGUI; class SMESHGUI;
class LightApp_SelectionMgr;
class SVTK_Selector; class SVTK_Selector;
/* /*
@ -235,8 +236,11 @@ protected slots:
virtual void onSelectionDone(); virtual void onSelectionDone();
private: private:
QComboBox* myCombo; QComboBox* myTypeCombo;
QComboBox* myNbNoCombo;
QListWidget* myListWg; QListWidget* myListWg;
QCheckBox* myUnderlOnlyChk;
QList<SMESH::SMESH_GroupBase_var> myGroups; QList<SMESH::SMESH_GroupBase_var> myGroups;
}; };

View File

@ -1038,7 +1038,7 @@
</message> </message>
<message> <message>
<source>MEN_UNDERLYING_ELEMS</source> <source>MEN_UNDERLYING_ELEMS</source>
<translation>Group of underlying entities</translation> <translation>Group based on nodes of other groups</translation>
</message> </message>
<message> <message>
<source>MEN_UPDATE</source> <source>MEN_UPDATE</source>
@ -3398,7 +3398,7 @@ Use Display Entity menu command to show them.
</message> </message>
<message> <message>
<source>STB_UNDERLYING_ELEMS</source> <source>STB_UNDERLYING_ELEMS</source>
<translation>Create groups of entities from existing groups of superior dimensions</translation> <translation>Create groups of entities basing on nodes of other groups</translation>
</message> </message>
<message> <message>
<source>STB_UPDATE</source> <source>STB_UPDATE</source>
@ -4050,7 +4050,7 @@ Use Display Entity menu command to show them.
</message> </message>
<message> <message>
<source>TOP_UNDERLYING_ELEMS</source> <source>TOP_UNDERLYING_ELEMS</source>
<translation>Create groups of entities from existing groups of superior dimensions</translation> <translation>Create groups of entities basing on nodes of other groups</translation>
</message> </message>
<message> <message>
<source>TOP_UPDATE</source> <source>TOP_UPDATE</source>
@ -4714,7 +4714,7 @@ Please, create VTK viewer and try again</translation>
</message> </message>
<message> <message>
<source>CREATE_COMMON_GROUPS</source> <source>CREATE_COMMON_GROUPS</source>
<translation>Create common groups for initial meshes</translation> <translation>Create groups from input objects</translation>
</message> </message>
<message> <message>
<source>MERGE_NODES_AND_ELEMENTS</source> <source>MERGE_NODES_AND_ELEMENTS</source>
@ -4722,7 +4722,7 @@ Please, create VTK viewer and try again</translation>
</message> </message>
<message> <message>
<source>MESHES</source> <source>MESHES</source>
<translation>Meshes</translation> <translation>Meshes, sub-meshes, groups</translation>
</message> </message>
<message> <message>
<source>PROCESSING_IDENTICAL_GROUPS</source> <source>PROCESSING_IDENTICAL_GROUPS</source>
@ -5810,8 +5810,8 @@ Please specify non-empty name and try again</translation>
Please specify them and try again</translation> Please specify them and try again</translation>
</message> </message>
<message> <message>
<source>NAME</source> <source>RESULT</source>
<translation>Name</translation> <translation>Result</translation>
</message> </message>
<message> <message>
<source>OBJECT_1</source> <source>OBJECT_1</source>
@ -5823,7 +5823,7 @@ Please specify them and try again</translation>
</message> </message>
<message> <message>
<source>RESULT_NAME</source> <source>RESULT_NAME</source>
<translation>Result name</translation> <translation>Group name</translation>
</message> </message>
<message> <message>
<source>TOOL_OBJECT</source> <source>TOOL_OBJECT</source>
@ -5845,27 +5845,35 @@ Please specify them and try again</translation>
<name>SMESHGUI_DimGroupDlg</name> <name>SMESHGUI_DimGroupDlg</name>
<message> <message>
<source>CREATE_GROUP_OF_UNDERLYING_ELEMS</source> <source>CREATE_GROUP_OF_UNDERLYING_ELEMS</source>
<translation>Create group of underlying entities</translation> <translation>Group based on nodes of other groups</translation>
</message> </message>
<message> <message>
<source>ELEMENTS_TYPE</source> <source>ELEMENTS_TYPE</source>
<translation>Elements type</translation> <translation>Elements type</translation>
</message> </message>
<message> <message>
<source>NODE</source> <source>UNDERLYING_ENTITIES_ONLY</source>
<translation>Node</translation> <translation>Include underlying entities only</translation>
</message> </message>
<message> <message>
<source>EDGE</source> <source>NUMBER_OF_COMMON_NODES</source>
<translation>Edge</translation> <translation>Number of common nodes</translation>
</message> </message>
<message> <message>
<source>FACE</source> <source>ALL</source>
<translation>Face</translation> <translation>All</translation>
</message> </message>
<message> <message>
<source>VOLUME</source> <source>MAIN</source>
<translation>Volume</translation> <translation>Main</translation>
</message>
<message>
<source>AT_LEAST_ONE</source>
<translation>At least one</translation>
</message>
<message>
<source>MAJORITY</source>
<translation>Majority</translation>
</message> </message>
</context> </context>
<context> <context>

View File

@ -888,18 +888,22 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
if ( Type == "SMESH.FT_ElemGeomType" ) if ( Type == "SMESH.FT_ElemGeomType" )
{ {
// set SMESH.GeometryType instead of a numerical Threshold // set SMESH.GeometryType instead of a numerical Threshold
const int nbTypes = SMESH::Geom_BALL+1; const int nbTypes = SMESH::Geom_LAST;
const char* types[nbTypes] = { const char* types[nbTypes] = {
"Geom_POINT", "Geom_EDGE", "Geom_TRIANGLE", "Geom_QUADRANGLE", "Geom_POLYGON", "Geom_POINT", "Geom_EDGE", "Geom_TRIANGLE", "Geom_QUADRANGLE", "Geom_POLYGON",
"Geom_TETRA", "Geom_PYRAMID", "Geom_HEXA", "Geom_PENTA", "Geom_HEXAGONAL_PRISM", "Geom_TETRA", "Geom_PYRAMID", "Geom_HEXA", "Geom_PENTA", "Geom_HEXAGONAL_PRISM",
"Geom_POLYHEDRA", "Geom_BALL" }; "Geom_POLYHEDRA", "Geom_BALL" };
if ( -1 < iGeom && iGeom < nbTypes ) if ( -1 < iGeom && iGeom < nbTypes )
Threshold = SMESH + types[ iGeom ]; Threshold = SMESH + types[ iGeom ];
#ifdef _DEBUG_
// is types complete? (compilation failure mains that enum GeometryType changed)
int _assert[( sizeof(types) / sizeof(const char*) == nbTypes ) ? 1 : -1 ];
#endif
} }
if (Type == "SMESH.FT_EntityType") if (Type == "SMESH.FT_EntityType")
{ {
// set SMESH.EntityType instead of a numerical Threshold // set SMESH.EntityType instead of a numerical Threshold
const int nbTypes = SMESH::Entity_Ball+1; const int nbTypes = SMESH::Entity_Last;
const char* types[nbTypes] = { const char* types[nbTypes] = {
"Entity_Node", "Entity_0D", "Entity_Edge", "Entity_Quad_Edge", "Entity_Node", "Entity_0D", "Entity_Edge", "Entity_Quad_Edge",
"Entity_Triangle", "Entity_Quad_Triangle", "Entity_BiQuad_Triangle", "Entity_Triangle", "Entity_Quad_Triangle", "Entity_BiQuad_Triangle",
@ -911,6 +915,10 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
"Entity_Polyhedra", "Entity_Quad_Polyhedra", "Entity_Ball" }; "Entity_Polyhedra", "Entity_Quad_Polyhedra", "Entity_Ball" };
if ( -1 < iGeom && iGeom < nbTypes ) if ( -1 < iGeom && iGeom < nbTypes )
Threshold = SMESH + types[ iGeom ]; Threshold = SMESH + types[ iGeom ];
#ifdef _DEBUG_
// is types complete? (compilation failure mains that enum EntityType changed)
int _assert[( sizeof(types) / sizeof(const char*) == nbTypes ) ? 1 : -1 ];
#endif
} }
} }
if ( ThresholdID.Length() != 2 ) // neither '' nor "" if ( ThresholdID.Length() != 2 ) // neither '' nor ""

View File

@ -3790,7 +3790,7 @@ string_array* FilterLibrary_i::GetAllNames()
static const char** getFunctNames() static const char** getFunctNames()
{ {
static const char* functName[ SMESH::FT_Undefined + 1 ] = { static const char* functName[] = {
// IT's necessary to update this array according to enum FunctorType (SMESH_Filter.idl) // IT's necessary to update this array according to enum FunctorType (SMESH_Filter.idl)
// The order is IMPORTANT !!! // The order is IMPORTANT !!!
"FT_AspectRatio", "FT_AspectRatio",
@ -3840,6 +3840,13 @@ static const char** getFunctNames()
"FT_LogicalAND", "FT_LogicalAND",
"FT_LogicalOR", "FT_LogicalOR",
"FT_Undefined"}; "FT_Undefined"};
#ifdef _DEBUG_
// check if functName is complete, compilation failure mains that enum FunctorType changed
const int nbFunctors = sizeof(functName) / sizeof(const char*);
int _assert[( nbFunctors == SMESH::FT_Undefined + 1 ) ? 1 : -1 ];
#endif
return functName; return functName;
} }

View File

@ -2345,10 +2345,11 @@ SMESH_Gen_i::FindGeometryByMeshElement( SMESH::SMESH_Mesh_ptr theMesh,
*/ */
//================================================================================ //================================================================================
SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Concatenate(const SMESH::mesh_array& theMeshesArray, SMESH::SMESH_Mesh_ptr
CORBA::Boolean theUniteIdenticalGroups, SMESH_Gen_i::Concatenate(const SMESH::ListOfIDSources& theMeshesArray,
CORBA::Boolean theMergeNodesAndElements, CORBA::Boolean theUniteIdenticalGroups,
CORBA::Double theMergeTolerance) CORBA::Boolean theMergeNodesAndElements,
CORBA::Double theMergeTolerance)
throw ( SALOME::SALOME_Exception ) throw ( SALOME::SALOME_Exception )
{ {
return ConcatenateCommon(theMeshesArray, return ConcatenateCommon(theMeshesArray,
@ -2368,10 +2369,10 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Concatenate(const SMESH::mesh_array& theMeshe
//================================================================================ //================================================================================
SMESH::SMESH_Mesh_ptr SMESH::SMESH_Mesh_ptr
SMESH_Gen_i::ConcatenateWithGroups(const SMESH::mesh_array& theMeshesArray, SMESH_Gen_i::ConcatenateWithGroups(const SMESH::ListOfIDSources& theMeshesArray,
CORBA::Boolean theUniteIdenticalGroups, CORBA::Boolean theUniteIdenticalGroups,
CORBA::Boolean theMergeNodesAndElements, CORBA::Boolean theMergeNodesAndElements,
CORBA::Double theMergeTolerance) CORBA::Double theMergeTolerance)
throw ( SALOME::SALOME_Exception ) throw ( SALOME::SALOME_Exception )
{ {
return ConcatenateCommon(theMeshesArray, return ConcatenateCommon(theMeshesArray,
@ -2390,14 +2391,13 @@ SMESH_Gen_i::ConcatenateWithGroups(const SMESH::mesh_array& theMeshesArray,
//================================================================================ //================================================================================
SMESH::SMESH_Mesh_ptr SMESH::SMESH_Mesh_ptr
SMESH_Gen_i::ConcatenateCommon(const SMESH::mesh_array& theMeshesArray, SMESH_Gen_i::ConcatenateCommon(const SMESH::ListOfIDSources& theMeshesArray,
CORBA::Boolean theUniteIdenticalGroups, CORBA::Boolean theUniteIdenticalGroups,
CORBA::Boolean theMergeNodesAndElements, CORBA::Boolean theMergeNodesAndElements,
CORBA::Double theMergeTolerance, CORBA::Double theMergeTolerance,
CORBA::Boolean theCommonGroups) CORBA::Boolean theCommonGroups)
throw ( SALOME::SALOME_Exception ) throw ( SALOME::SALOME_Exception )
{ {
typedef map<int, int> TIDsMap;
typedef list<SMESH::SMESH_Group_var> TListOfNewGroups; typedef list<SMESH::SMESH_Group_var> TListOfNewGroups;
typedef map< pair<string, SMESH::ElementType>, TListOfNewGroups > TGroupsMap; typedef map< pair<string, SMESH::ElementType>, TListOfNewGroups > TGroupsMap;
@ -2407,304 +2407,262 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::mesh_array& theMeshesArray,
// create mesh // create mesh
SMESH::SMESH_Mesh_var aNewMesh = CreateEmptyMesh(); SMESH::SMESH_Mesh_var aNewMesh = CreateEmptyMesh();
SMESHDS_Mesh* aNewMeshDS = 0; if ( aNewMesh->_is_nil() )
if ( !aNewMesh->_is_nil() ) { return aNewMesh._retn();
SMESH_Mesh_i* aNewImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( aNewMesh ).in() );
if ( aNewImpl ) {
::SMESH_Mesh& aLocMesh = aNewImpl->GetImpl();
aNewMeshDS = aLocMesh.GetMeshDS();
TGroupsMap aGroupsMap; SMESH_Mesh_i* aNewImpl = SMESH::DownCast<SMESH_Mesh_i*>( aNewMesh );
TListOfNewGroups aListOfNewGroups; if ( !aNewImpl )
::SMESH_MeshEditor aNewEditor(&aLocMesh); return aNewMesh._retn();
SMESH::ListOfGroups_var aListOfGroups = new SMESH::ListOfGroups();
// loop on meshes ::SMESH_Mesh& aLocMesh = aNewImpl->GetImpl();
for ( int i = 0; i < theMeshesArray.length(); i++) { SMESHDS_Mesh* aNewMeshDS = aLocMesh.GetMeshDS();
SMESH::SMESH_Mesh_var anInitMesh = theMeshesArray[i];
if ( !anInitMesh->_is_nil() ) {
SMESH_Mesh_i* anInitImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( anInitMesh ).in() );
if ( anInitImpl ) {
::SMESH_Mesh& aInitLocMesh = anInitImpl->GetImpl();
aInitLocMesh.Load();
SMESHDS_Mesh* anInitMeshDS = aInitLocMesh.GetMeshDS();
TIDsMap nodesMap; TGroupsMap aGroupsMap;
TIDsMap elemsMap; TListOfNewGroups aListOfNewGroups;
::SMESH_MeshEditor aNewEditor(&aLocMesh);
SMESH::ListOfGroups_var aListOfGroups;
// loop on elements of mesh std::vector<const SMDS_MeshNode*> aNodesArray;
SMDS_ElemIteratorPtr itElems = anInitMeshDS->elementsIterator();
const SMDS_MeshElement* anElem = 0;
const SMDS_MeshElement* aNewElem = 0;
int anElemNbNodes = 0;
int anNbNodes = 0; // loop on sub-meshes
int anNbEdges = 0; for ( int i = 0; i < theMeshesArray.length(); i++)
int anNbFaces = 0; {
int anNbVolumes = 0; SMESH::SMESH_Mesh_var anInitMesh = theMeshesArray[i]->GetMesh();
int aNbBalls = 0; if ( anInitMesh->_is_nil() ) continue;
SMESH_Mesh_i* anInitImpl = SMESH::DownCast<SMESH_Mesh_i*>( anInitMesh );
if ( !anInitImpl ) continue;
anInitImpl->Load();
SMESH::long_array_var anIDsNodes = new SMESH::long_array(); ::SMESH_Mesh& aInitLocMesh = anInitImpl->GetImpl();
SMESH::long_array_var anIDsEdges = new SMESH::long_array(); SMESHDS_Mesh* anInitMeshDS = aInitLocMesh.GetMeshDS();
SMESH::long_array_var anIDsFaces = new SMESH::long_array();
SMESH::long_array_var anIDsVolumes = new SMESH::long_array();
SMESH::long_array_var anIDsBalls = new SMESH::long_array();
if( theCommonGroups ) { // remember nb of elements before filling in
anIDsNodes->length( anInitMeshDS->NbNodes() ); SMESH::long_array_var prevState = aNewMesh->GetNbElementsByType();
anIDsEdges->length( anInitMeshDS->NbEdges() );
anIDsFaces->length( anInitMeshDS->NbFaces() );
anIDsVolumes->length( anInitMeshDS->NbVolumes() );
anIDsBalls->length( anInitMeshDS->NbBalls() );
}
for ( int j = 0; itElems->more(); j++) { typedef std::map<const SMDS_MeshElement*, const SMDS_MeshElement*, TIDCompare > TEEMap;
anElem = itElems->next(); TEEMap elemsMap, nodesMap;
SMDSAbs_ElementType anElemType = anElem->GetType();
anElemNbNodes = anElem->NbNodes();
std::vector<const SMDS_MeshNode*> aNodesArray (anElemNbNodes);
// loop on nodes of element // loop on elements of a sub-mesh
const SMDS_MeshNode* aNode = 0; SMDS_ElemIteratorPtr itElems = anInitImpl->GetElements( theMeshesArray[i], SMESH::ALL );
const SMDS_MeshNode* aNewNode = 0; const SMDS_MeshElement* anElem;
SMDS_ElemIteratorPtr itNodes = anElem->nodesIterator(); const SMDS_MeshElement* aNewElem;
const SMDS_MeshNode* aNode;
const SMDS_MeshNode* aNewNode;
int anElemNbNodes;
for ( int k = 0; itNodes->more(); k++) { while ( itElems->more() )
aNode = static_cast<const SMDS_MeshNode*>(itNodes->next()); {
if ( nodesMap.find(aNode->GetID()) == nodesMap.end() ) { anElem = itElems->next();
aNewNode = aNewMeshDS->AddNode(aNode->X(), aNode->Y(), aNode->Z()); anElemNbNodes = anElem->NbNodes();
nodesMap.insert( make_pair(aNode->GetID(), aNewNode->GetID()) ); aNodesArray.resize( anElemNbNodes );
if( theCommonGroups )
anIDsNodes[anNbNodes++] = aNewNode->GetID();
}
else
aNewNode = aNewMeshDS->FindNode( nodesMap.find(aNode->GetID())->second );
aNodesArray[k] = aNewNode;
}//nodes loop
// creates a corresponding element on existent nodes in new mesh // loop on nodes of an element
switch ( anElem->GetEntityType() ) { SMDS_ElemIteratorPtr itNodes = anElem->nodesIterator();
case SMDSEntity_Polyhedra: for ( int k = 0; itNodes->more(); k++)
if ( const SMDS_VtkVolume* aVolume = {
dynamic_cast<const SMDS_VtkVolume*> (anElem)) aNode = static_cast<const SMDS_MeshNode*>( itNodes->next() );
{ TEEMap::iterator n2nnIt = nodesMap.find( aNode );
aNewElem = aNewMeshDS->AddPolyhedralVolume(aNodesArray, if ( n2nnIt == nodesMap.end() )
aVolume->GetQuantities()); {
elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID())); aNewNode = aNewMeshDS->AddNode(aNode->X(), aNode->Y(), aNode->Z());
if( theCommonGroups ) nodesMap.insert( make_pair( aNode, aNewNode ));
anIDsVolumes[anNbVolumes++] = aNewElem->GetID(); }
} else
break; {
case SMDSEntity_Ball: aNewNode = static_cast<const SMDS_MeshNode*>( n2nnIt->second );
if ( const SMDS_BallElement* aBall = }
dynamic_cast<const SMDS_BallElement*> (anElem)) aNodesArray[k] = aNewNode;
{ }
aNewElem = aNewEditor.AddElement(aNodesArray, SMDSAbs_Ball,
/*isPoly=*/false, /*id=*/0,
aBall->GetDiameter() );
elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID()));
if( theCommonGroups )
anIDsBalls[aNbBalls++] = aNewElem->GetID();
}
break;
default:
{
aNewElem = aNewEditor.AddElement(aNodesArray,
anElemType,
anElem->IsPoly());
elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID()));
if( theCommonGroups ) {
if( anElemType == SMDSAbs_Edge )
anIDsEdges[anNbEdges++] = aNewElem->GetID();
else if( anElemType == SMDSAbs_Face )
anIDsFaces[anNbFaces++] = aNewElem->GetID();
else if( anElemType == SMDSAbs_Volume )
anIDsVolumes[anNbVolumes++] = aNewElem->GetID();
}
}
}
} //elems loop
aNewEditor.CrearLastCreated(); // forget the history // creates a corresponding element on existent nodes in new mesh
aNewElem = 0;
switch ( anElem->GetEntityType() )
{
case SMDSEntity_Polyhedra:
if ( const SMDS_VtkVolume* aVolume =
dynamic_cast<const SMDS_VtkVolume*> (anElem))
{
aNewElem = aNewMeshDS->AddPolyhedralVolume( aNodesArray,
aVolume->GetQuantities() );
}
break;
case SMDSEntity_Ball:
if ( const SMDS_BallElement* aBall =
dynamic_cast<const SMDS_BallElement*> (anElem))
{
aNewElem = aNewEditor.AddElement( aNodesArray, SMDSAbs_Ball,
/*isPoly=*/false, /*id=*/0,
aBall->GetDiameter() );
}
break;
case SMDSEntity_Node:
break;
default:
aNewElem = aNewEditor.AddElement( aNodesArray, anElem->GetType(), anElem->IsPoly() );
}
if ( aNewElem )
elemsMap.insert( make_pair( anElem, aNewElem ));
// copy orphan nodes } //elems loop
SMDS_NodeIteratorPtr itNodes = anInitMeshDS->nodesIterator();
while ( itNodes->more() ) aNewEditor.ClearLastCreated(); // forget the history
// create groups of just added elements
SMESH::SMESH_Group_var aNewGroup;
SMESH::ElementType aGroupType;
if ( theCommonGroups )
{
SMESH::long_array_var curState = aNewMesh->GetNbElementsByType();
for( aGroupType = SMESH::NODE;
aGroupType < SMESH::NB_ELEMENT_TYPES;
aGroupType = (SMESH::ElementType)( aGroupType + 1 ))
{
if ( curState[ aGroupType ] <= prevState[ aGroupType ])
continue;
// make a group name
const char* typeNames[] = { "All","Nodes","Edges","Faces","Volumes","0DElems","Balls" };
{ // check of typeNames, compilation failure mains that NB_ELEMENT_TYPES changed:
const int nbNames = sizeof(typeNames) / sizeof(const char*);
int _assert[( nbNames == SMESH::NB_ELEMENT_TYPES ) ? 1 : -1 ];
}
string groupName = "Gr";
SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( myCurrentStudy, theMeshesArray[i] );
if ( aMeshSObj ) {
CORBA::String_var name = aMeshSObj->GetName();
groupName += name;
}
groupName += "_";
groupName += typeNames[ aGroupType ];
// make and fill a group
TEEMap & e2neMap = ( aGroupType == SMESH::NODE ) ? nodesMap : elemsMap;
aNewGroup = aNewImpl->CreateGroup( aGroupType, groupName.c_str() );
if ( SMESH_Group_i* grp_i = SMESH::DownCast<SMESH_Group_i*>( aNewGroup ))
{
if ( SMESHDS_Group* grpDS = dynamic_cast<SMESHDS_Group*>( grp_i->GetGroupDS() ))
{
TEEMap::iterator e2neIt = e2neMap.begin();
for ( ; e2neIt != e2neMap.end(); ++e2neIt )
{ {
const SMDS_MeshNode* aNode = itNodes->next(); aNewElem = e2neIt->second;
if ( aNode->NbInverseElements() == 0 ) if ( aNewElem->GetType() == grpDS->GetType() )
{ {
const SMDS_MeshNode* aNewNode = grpDS->Add( aNewElem );
aNewMeshDS->AddNode(aNode->X(), aNode->Y(), aNode->Z());
nodesMap.insert( make_pair(aNode->GetID(), aNewNode->GetID()) ); if ( prevState[ aGroupType ]++ >= curState[ aGroupType ] )
if( theCommonGroups ) break;
anIDsNodes[anNbNodes++] = aNewNode->GetID();
} }
} }
aListOfGroups = anInitImpl->GetGroups();
SMESH::SMESH_GroupBase_ptr aGroup;
// loop on groups of mesh
SMESH::long_array_var anInitIDs = new SMESH::long_array();
SMESH::long_array_var anNewIDs = new SMESH::long_array();
SMESH::SMESH_Group_var aNewGroup;
SMESH::ElementType aGroupType;
CORBA::String_var aGroupName;
if ( theCommonGroups ) {
for(aGroupType=SMESH::NODE;aGroupType<=SMESH::BALL;aGroupType=(SMESH::ElementType)(aGroupType+1)) {
string str = "Gr";
SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( myCurrentStudy, anInitMesh );
if(aMeshSObj)
str += aMeshSObj->GetName();
str += "_";
int anLen = 0;
switch(aGroupType) {
case SMESH::NODE:
str += "Nodes";
anIDsNodes->length(anNbNodes);
anLen = anNbNodes;
break;
case SMESH::EDGE:
str += "Edges";
anIDsEdges->length(anNbEdges);
anLen = anNbEdges;
break;
case SMESH::FACE:
str += "Faces";
anIDsFaces->length(anNbFaces);
anLen = anNbFaces;
break;
case SMESH::VOLUME:
str += "Volumes";
anIDsVolumes->length(anNbVolumes);
anLen = anNbVolumes;
break;
case SMESH::BALL:
str += "Balls";
anIDsBalls->length(aNbBalls);
anLen = aNbBalls;
break;
default:
break;
}
if(anLen) {
aGroupName = str.c_str();
// add a new group in the mesh
aNewGroup = aNewImpl->CreateGroup(aGroupType, aGroupName);
switch(aGroupType) {
case SMESH::NODE:
aNewGroup->Add( anIDsNodes );
break;
case SMESH::EDGE:
aNewGroup->Add( anIDsEdges );
break;
case SMESH::FACE:
aNewGroup->Add( anIDsFaces );
break;
case SMESH::VOLUME:
aNewGroup->Add( anIDsVolumes );
break;
case SMESH::BALL:
aNewGroup->Add( anIDsBalls );
break;
default:
break;
}
aListOfNewGroups.clear();
aListOfNewGroups.push_back(aNewGroup);
aGroupsMap.insert(make_pair( make_pair(aGroupName, aGroupType), aListOfNewGroups ));
}
}
}
// check that current group name and type don't have identical ones in union mesh
for (int iG = 0; iG < aListOfGroups->length(); iG++) {
aGroup = aListOfGroups[iG];
aListOfNewGroups.clear();
aGroupType = aGroup->GetType();
aGroupName = aGroup->GetName();
TGroupsMap::iterator anIter = aGroupsMap.find(make_pair(aGroupName, aGroupType));
// convert a list of IDs
anInitIDs = aGroup->GetListOfID();
anNewIDs->length(anInitIDs->length());
if ( aGroupType == SMESH::NODE )
for (int j = 0; j < anInitIDs->length(); j++) {
anNewIDs[j] = nodesMap.find(anInitIDs[j])->second;
}
else
for (int j = 0; j < anInitIDs->length(); j++) {
anNewIDs[j] = elemsMap.find(anInitIDs[j])->second;
}
// check that current group name and type don't have identical ones in union mesh
if ( anIter == aGroupsMap.end() ) {
// add a new group in the mesh
aNewGroup = aNewImpl->CreateGroup(aGroupType, aGroupName);
// add elements into new group
aNewGroup->Add( anNewIDs );
aListOfNewGroups.push_back(aNewGroup);
aGroupsMap.insert(make_pair( make_pair(aGroupName, aGroupType), aListOfNewGroups ));
}
else if ( theUniteIdenticalGroups ) {
// unite identical groups
TListOfNewGroups& aNewGroups = anIter->second;
aNewGroups.front()->Add( anNewIDs );
}
else {
// rename identical groups
aNewGroup = aNewImpl->CreateGroup(aGroupType, aGroupName);
aNewGroup->Add( anNewIDs );
TListOfNewGroups& aNewGroups = anIter->second;
string aNewGroupName;
if (aNewGroups.size() == 1) {
aNewGroupName = string(aGroupName) + "_1";
aNewGroups.front()->SetName(aNewGroupName.c_str());
}
char aGroupNum[128];
sprintf(aGroupNum, "%u", aNewGroups.size()+1);
aNewGroupName = string(aGroupName) + "_" + string(aGroupNum);
aNewGroup->SetName(aNewGroupName.c_str());
aNewGroups.push_back(aNewGroup);
}
}//groups loop
} }
} }
}//meshes loop aListOfNewGroups.clear();
aListOfNewGroups.push_back(aNewGroup);
if (theMergeNodesAndElements) { aGroupsMap.insert(make_pair( make_pair(groupName, aGroupType), aListOfNewGroups ));
// merge nodes
TIDSortedNodeSet aMeshNodes; // no input nodes
SMESH_MeshEditor::TListOfListOfNodes aGroupsOfNodes;
aNewEditor.FindCoincidentNodes( aMeshNodes, theMergeTolerance, aGroupsOfNodes );
aNewEditor.MergeNodes( aGroupsOfNodes );
// merge elements
aNewEditor.MergeEqualElements();
} }
} }
if ( SMESH_Mesh_i* anSrcImpl = SMESH::DownCast<SMESH_Mesh_i*>( theMeshesArray[i] ))
{
// copy orphan nodes
if ( anSrcImpl->NbNodes() > nodesMap.size() )
{
SMDS_ElemIteratorPtr itNodes = anInitImpl->GetElements( theMeshesArray[i], SMESH::NODE );
while ( itNodes->more() )
{
const SMDS_MeshNode* aNode = static_cast< const SMDS_MeshNode* >( itNodes->next() );
if ( aNode->NbInverseElements() == 0 )
{
aNewNode = aNewMeshDS->AddNode(aNode->X(), aNode->Y(), aNode->Z());
nodesMap.insert( make_pair( aNode, aNewNode ));
}
}
}
// copy groups
SMESH::SMESH_GroupBase_ptr aGroup;
CORBA::String_var aGroupName;
SMESH::long_array_var anNewIDs = new SMESH::long_array();
// loop on groups of a source mesh
aListOfGroups = anSrcImpl->GetGroups();
for (int iG = 0; iG < aListOfGroups->length(); iG++)
{
aGroup = aListOfGroups[iG];
aGroupType = aGroup->GetType();
aGroupName = aGroup->GetName();
// convert a list of IDs
anNewIDs->length( aGroup->Size() );
TEEMap & e2neMap = ( aGroupType == SMESH::NODE ) ? nodesMap : elemsMap;
SMDS_ElemIteratorPtr itGrElems = anSrcImpl->GetElements( aGroup, SMESH::ALL );
int iElem = 0;
while ( itGrElems->more() )
{
anElem = itGrElems->next();
TEEMap::iterator e2neIt = e2neMap.find( anElem );
if ( e2neIt != e2neMap.end() )
anNewIDs[ iElem++ ] = e2neIt->second->GetID();
}
anNewIDs->length( iElem );
// check a current group name and type don't have identical ones in final mesh
aListOfNewGroups.clear();
TGroupsMap::iterator anIter = aGroupsMap.find( make_pair( aGroupName, aGroupType ));
if ( anIter == aGroupsMap.end() ) {
// add a new group in the mesh
aNewGroup = aNewImpl->CreateGroup( aGroupType, aGroupName );
// add elements into new group
aNewGroup->Add( anNewIDs );
aListOfNewGroups.push_back(aNewGroup);
aGroupsMap.insert(make_pair( make_pair(aGroupName, aGroupType), aListOfNewGroups ));
}
else if ( theUniteIdenticalGroups ) {
// unite identical groups
TListOfNewGroups& aNewGroups = anIter->second;
aNewGroups.front()->Add( anNewIDs );
}
else {
// rename identical groups
aNewGroup = aNewImpl->CreateGroup(aGroupType, aGroupName);
aNewGroup->Add( anNewIDs );
TListOfNewGroups& aNewGroups = anIter->second;
string aNewGroupName;
if (aNewGroups.size() == 1) {
aNewGroupName = string(aGroupName) + "_1";
aNewGroups.front()->SetName(aNewGroupName.c_str());
}
char aGroupNum[128];
sprintf(aGroupNum, "%u", aNewGroups.size()+1);
aNewGroupName = string(aGroupName) + "_" + string(aGroupNum);
aNewGroup->SetName(aNewGroupName.c_str());
aNewGroups.push_back(aNewGroup);
}
} //groups loop
} // if an IDSource is a mesh
} //meshes loop
if (theMergeNodesAndElements) {
// merge nodes
TIDSortedNodeSet aMeshNodes; // no input nodes
SMESH_MeshEditor::TListOfListOfNodes aGroupsOfNodes;
aNewEditor.FindCoincidentNodes( aMeshNodes, theMergeTolerance, aGroupsOfNodes );
aNewEditor.MergeNodes( aGroupsOfNodes );
// merge elements
aNewEditor.MergeEqualElements();
} }
// Update Python script // Update Python script
aPythonDump << aNewMesh << " = " << this; aPythonDump << aNewMesh << " = " << this << "."
if( !theCommonGroups ) << ( theCommonGroups ? "ConcatenateWithGroups" : "Concatenate" )
aPythonDump << ".Concatenate("; << "([";
else
aPythonDump << ".ConcatenateWithGroups(";
aPythonDump << "[";
for ( int i = 0; i < theMeshesArray.length(); i++) { for ( int i = 0; i < theMeshesArray.length(); i++) {
if (i > 0) aPythonDump << ", "; if (i > 0) aPythonDump << ", ";
aPythonDump << theMeshesArray[i]; aPythonDump << theMeshesArray[i];
@ -2728,6 +2686,7 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::mesh_array& theMeshesArray,
if (aNewMeshDS) if (aNewMeshDS)
aNewMeshDS->Modified(); aNewMeshDS->Modified();
return aNewMesh._retn(); return aNewMesh._retn();
} }

View File

@ -356,26 +356,26 @@ public:
throw ( SALOME::SALOME_Exception ); throw ( SALOME::SALOME_Exception );
// Concatenate the given meshes into one mesh // Concatenate the given meshes into one mesh
SMESH::SMESH_Mesh_ptr ConcatenateCommon(const SMESH::mesh_array& theMeshesArray, SMESH::SMESH_Mesh_ptr ConcatenateCommon(const SMESH::ListOfIDSources& meshesArray,
CORBA::Boolean theUniteIdenticalGroups, CORBA::Boolean uniteIdenticalGroups,
CORBA::Boolean theMergeNodesAndElements, CORBA::Boolean mergeNodesAndElements,
CORBA::Double theMergeTolerance, CORBA::Double mergeTolerance,
CORBA::Boolean theCommonGroups) CORBA::Boolean commonGroups)
throw ( SALOME::SALOME_Exception ); throw ( SALOME::SALOME_Exception );
// Concatenate the given meshes into one mesh // Concatenate the given meshes into one mesh
SMESH::SMESH_Mesh_ptr Concatenate(const SMESH::mesh_array& theMeshesArray, SMESH::SMESH_Mesh_ptr Concatenate(const SMESH::ListOfIDSources& meshesArray,
CORBA::Boolean theUniteIdenticalGroups, CORBA::Boolean uniteIdenticalGroups,
CORBA::Boolean theMergeNodesAndElements, CORBA::Boolean mergeNodesAndElements,
CORBA::Double theMergeTolerance) CORBA::Double mergeTolerance)
throw ( SALOME::SALOME_Exception ); throw ( SALOME::SALOME_Exception );
// Concatenate the given meshes into one mesh // Concatenate the given meshes into one mesh
// Create the groups of all elements from initial meshes // Create the groups of all elements from initial meshes
SMESH::SMESH_Mesh_ptr ConcatenateWithGroups(const SMESH::mesh_array& theMeshesArray, SMESH::SMESH_Mesh_ptr ConcatenateWithGroups(const SMESH::ListOfIDSources& meshesArray,
CORBA::Boolean theUniteIdenticalGroups, CORBA::Boolean uniteIdenticalGroups,
CORBA::Boolean theMergeNodesAndElements, CORBA::Boolean mergeNodesAndElements,
CORBA::Double theMergeTolerance) CORBA::Double mergeTolerance)
throw ( SALOME::SALOME_Exception ); throw ( SALOME::SALOME_Exception );
// Get MED version of the file by its name // Get MED version of the file by its name

View File

@ -513,7 +513,7 @@ void SMESH_MeshEditor_i::initData(bool deleteSearchers)
TSearchersDeleter::Delete(); TSearchersDeleter::Delete();
} }
getEditor().GetError().reset(); getEditor().GetError().reset();
getEditor().CrearLastCreated(); getEditor().ClearLastCreated();
} }
//================================================================================ //================================================================================
@ -712,7 +712,7 @@ SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedElems()
void SMESH_MeshEditor_i::ClearLastCreated() throw (SALOME::SALOME_Exception) void SMESH_MeshEditor_i::ClearLastCreated() throw (SALOME::SALOME_Exception)
{ {
SMESH_TRY; SMESH_TRY;
getEditor().CrearLastCreated(); getEditor().ClearLastCreated();
SMESH_CATCH( SMESH::throwCorbaException ); SMESH_CATCH( SMESH::throwCorbaException );
} }

View File

@ -1568,25 +1568,52 @@ SMESH_Mesh_i::CutListOfGroups(const SMESH::ListOfGroups& theMainGroups,
return aResGrp._retn(); return aResGrp._retn();
} }
namespace // functions making checks according to SMESH::NB_COMMON_NODES_ENUM
{
bool isAllNodesCommon(int nbChecked, int nbCommon, int nbNodes, int nbCorners,
bool & toStopChecking )
{
toStopChecking = ( nbCommon < nbChecked );
return nbCommon == nbNodes;
}
bool isMainNodesCommon(int nbChecked, int nbCommon, int nbNodes, int nbCorners,
bool & toStopChecking )
{
toStopChecking = ( nbCommon < nbChecked || nbChecked >= nbCorners );
return nbCommon == nbCorners;
}
bool isAtLeastOneNodeCommon(int nbChecked, int nbCommon, int nbNodes, int nbCorners,
bool & toStopChecking )
{
return nbCommon > 0;
}
bool isMajorityOfNodesCommon(int nbChecked, int nbCommon, int nbNodes, int nbCorners,
bool & toStopChecking )
{
return nbCommon >= nbNodes / 2;
}
}
//============================================================================= //=============================================================================
/*! /*!
\brief Create groups of entities from existing groups of superior dimensions * Create a group of entities basing on nodes of other groups.
System * \param [in] theGroups - list of either groups, sub-meshes or filters.
1) extract all nodes from each group, * \param [in] anElemType - a type of elements to include to the new group.
2) combine all elements of specified dimension laying on these nodes. * \param [in] theName - a name of the new group.
\param theGroups list of source groups * \param [in] theNbCommonNodes - criterion of inclusion of an element to the new group.
\param theElemType dimension of elements * \param [in] theUnderlyingOnly - if \c True, an element is included to the
\param theName name of new group * new group provided that it is based on nodes of an element of \a aListOfGroups
\return pointer on new group * \return SMESH_Group - the created group
*
IMP 19939
*/ */
// IMP 19939, bug 22010, IMP 22635
//============================================================================= //=============================================================================
SMESH::SMESH_Group_ptr SMESH::SMESH_Group_ptr
SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfGroups& theGroups, SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfIDSources& theGroups,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
const char* theName ) const char* theName,
SMESH::NB_COMMON_NODES_ENUM theNbCommonNodes,
CORBA::Boolean theUnderlyingOnly)
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::SMESH_Group_var aResGrp; SMESH::SMESH_Group_var aResGrp;
@ -1602,6 +1629,17 @@ SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfGroups& theGroups,
SMDSAbs_ElementType anElemType = (SMDSAbs_ElementType)theElemType; SMDSAbs_ElementType anElemType = (SMDSAbs_ElementType)theElemType;
bool (*isToInclude)(int nbChecked, int nbCommon, int nbNodes, int nbCorners, bool & toStop);
SMESH_Comment nbCoNoStr( "SMESH.");
switch ( theNbCommonNodes ) {
case SMESH::ALL_NODES : isToInclude = isAllNodesCommon; nbCoNoStr<<"ALL_NODES" ;break;
case SMESH::MAIN : isToInclude = isMainNodesCommon; nbCoNoStr<<"MAIN" ;break;
case SMESH::AT_LEAST_ONE: isToInclude = isAtLeastOneNodeCommon; nbCoNoStr<<"AT_LEAST_ONE";break;
case SMESH::MAJORITY : isToInclude = isMajorityOfNodesCommon; nbCoNoStr<<"MAJORITY" ;break;
default: return aResGrp._retn();
}
int nbChecked, nbCommon, nbNodes, nbCorners;
// Create a group // Create a group
TPythonDump pyDump; TPythonDump pyDump;
@ -1614,14 +1652,19 @@ SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfGroups& theGroups,
SMESH::DownCast<SMESH_GroupBase_i*>( aResGrp )->GetGroupDS(); SMESH::DownCast<SMESH_GroupBase_i*>( aResGrp )->GetGroupDS();
SMDS_MeshGroup& resGroupCore = static_cast< SMESHDS_Group* >( groupBaseDS )->SMDSGroup(); SMDS_MeshGroup& resGroupCore = static_cast< SMESHDS_Group* >( groupBaseDS )->SMDSGroup();
vector<bool> isNodeInGroups;
for ( int g = 0, n = theGroups.length(); g < n; g++ ) // loop on theGroups for ( int g = 0, n = theGroups.length(); g < n; g++ ) // loop on theGroups
{ {
SMESH::SMESH_GroupBase_var aGrp = theGroups[ g ]; SMESH::SMESH_IDSource_var aGrp = theGroups[ g ];
if ( CORBA::is_nil( aGrp ) ) if ( CORBA::is_nil( aGrp ) )
continue; continue;
SMESH::SMESH_Mesh_var mesh = aGrp->GetMesh();
if ( mesh->_is_nil() || mesh->GetId() != this->GetId() )
continue;
groupBaseDS = SMESH::DownCast<SMESH_GroupBase_i*>( aGrp )->GetGroupDS(); SMDS_ElemIteratorPtr elIt = GetElements( aGrp, SMESH::ALL );
SMDS_ElemIteratorPtr elIt = groupBaseDS->GetElements(); if ( !elIt ) continue;
if ( theElemType == SMESH::NODE ) // get all nodes of elements if ( theElemType == SMESH::NODE ) // get all nodes of elements
{ {
@ -1632,30 +1675,93 @@ SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfGroups& theGroups,
resGroupCore.Add( nIt->next() ); resGroupCore.Add( nIt->next() );
} }
} }
else // get elements of theElemType based on nodes of every element of group // get elements of theElemType based on nodes of every element of group
else if ( theUnderlyingOnly )
{ {
while ( elIt->more() ) while ( elIt->more() )
{ {
const SMDS_MeshElement* el = elIt->next(); // an element of group const SMDS_MeshElement* el = elIt->next(); // an element of ref group
TIDSortedElemSet elNodes( el->begin_nodes(), el->end_nodes() ); TIDSortedElemSet elNodes( el->begin_nodes(), el->end_nodes() );
TIDSortedElemSet checkedElems; TIDSortedElemSet checkedElems;
SMDS_ElemIteratorPtr nIt = el->nodesIterator(); SMDS_NodeIteratorPtr nIt = el->nodeIterator();
while ( nIt->more() ) while ( nIt->more() )
{ {
const SMDS_MeshNode* n = static_cast<const SMDS_MeshNode*>( nIt->next() ); const SMDS_MeshNode* n = nIt->next();
SMDS_ElemIteratorPtr elOfTypeIt = n->GetInverseElementIterator( anElemType ); SMDS_ElemIteratorPtr elOfTypeIt = n->GetInverseElementIterator( anElemType );
// check nodes of elements of theElemType around el // check nodes of elements of theElemType around el
while ( elOfTypeIt->more() ) while ( elOfTypeIt->more() )
{ {
const SMDS_MeshElement* elOfType = elOfTypeIt->next(); const SMDS_MeshElement* elOfType = elOfTypeIt->next();
if ( !checkedElems.insert( elOfType ).second ) continue; if ( !checkedElems.insert( elOfType ).second ) continue;
nbNodes = elOfType->NbNodes();
nbCorners = elOfType->NbCornerNodes();
nbCommon = 0;
bool toStopChecking = false;
SMDS_ElemIteratorPtr nIt2 = elOfType->nodesIterator(); SMDS_ElemIteratorPtr nIt2 = elOfType->nodesIterator();
bool allNodesOK = true; for ( nbChecked = 1; nIt2->more() && !toStopChecking; ++nbChecked )
while ( nIt2->more() && allNodesOK ) if ( elNodes.count( nIt2->next() ) &&
allNodesOK = elNodes.count( nIt2->next() ); isToInclude( nbChecked, ++nbCommon, nbNodes, nbCorners, toStopChecking ))
if ( allNodesOK ) {
resGroupCore.Add( elOfType ); resGroupCore.Add( elOfType );
break;
}
}
}
}
}
// get all nodes of elements of groups
else
{
while ( elIt->more() )
{
const SMDS_MeshElement* el = elIt->next(); // an element of group
SMDS_NodeIteratorPtr nIt = el->nodeIterator();
while ( nIt->more() )
{
const SMDS_MeshNode* n = nIt->next();
if ( n->GetID() >= isNodeInGroups.size() )
isNodeInGroups.resize( n->GetID() + 1, false );
isNodeInGroups[ n->GetID() ] = true;
}
}
}
}
// Get elements of theElemType based on a certain number of nodes of elements of groups
if ( !theUnderlyingOnly && !isNodeInGroups.empty() )
{
const SMDS_MeshNode* n;
vector<bool> isElemChecked( aMeshDS->MaxElementID() + 1 );
const int isNodeInGroupsSize = isNodeInGroups.size();
for ( int iN = 0; iN < isNodeInGroupsSize; ++iN )
{
if ( !isNodeInGroups[ iN ] ||
!( n = aMeshDS->FindNode( iN )))
continue;
// check nodes of elements of theElemType around n
SMDS_ElemIteratorPtr elOfTypeIt = n->GetInverseElementIterator( anElemType );
while ( elOfTypeIt->more() )
{
const SMDS_MeshElement* elOfType = elOfTypeIt->next();
vector<bool>::reference isChecked = isElemChecked[ elOfType->GetID() ];
if ( isChecked )
continue;
isChecked = true;
nbNodes = elOfType->NbNodes();
nbCorners = elOfType->NbCornerNodes();
nbCommon = 0;
bool toStopChecking = false;
SMDS_ElemIteratorPtr nIt = elOfType->nodesIterator();
for ( nbChecked = 1; nIt->more() && !toStopChecking; ++nbChecked )
{
const int nID = nIt->next()->GetID();
if ( nID < isNodeInGroupsSize && isNodeInGroups[ nID ] &&
isToInclude( nbChecked, ++nbCommon, nbNodes, nbCorners, toStopChecking ))
{
resGroupCore.Add( elOfType );
break;
} }
} }
} }
@ -1665,7 +1771,8 @@ SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfGroups& theGroups,
// Update Python script // Update Python script
pyDump << aResGrp << " = " << SMESH::SMESH_Mesh_var( _this()) pyDump << aResGrp << " = " << SMESH::SMESH_Mesh_var( _this())
<< ".CreateDimGroup( " << ".CreateDimGroup( "
<< theGroups << ", " << theElemType << ", '" << theName << "' )"; << theGroups << ", " << theElemType << ", '" << theName << "', "
<< nbCoNoStr << ", " << theUnderlyingOnly << ")";
SMESH_CATCH( SMESH::throwCorbaException ); SMESH_CATCH( SMESH::throwCorbaException );
@ -5168,7 +5275,7 @@ namespace /* Iterators used in SMESH_Mesh_i::GetElements(SMESH::SMESH_IDSource_v
_elem = _mesh->FindNode( *_idPtr++ ); _elem = _mesh->FindNode( *_idPtr++ );
} }
else if ((_elem = _mesh->FindElement( *_idPtr++ )) && else if ((_elem = _mesh->FindElement( *_idPtr++ )) &&
_elem->GetType() != _type ) (_elem->GetType() != _type && _type != SMDSAbs_All ))
{ {
_elem = 0; _elem = 0;
} }
@ -5248,7 +5355,7 @@ SMDS_ElemIteratorPtr SMESH_Mesh_i::GetElements(SMESH::SMESH_IDSource_ptr theObje
if ( sm ) if ( sm )
{ {
elemIt = sm->GetElements(); elemIt = sm->GetElements();
if ( elemType != SMDSAbs_Node ) if ( elemType != SMDSAbs_Node && elemType != SMDSAbs_All )
{ {
typeOK = ( elemIt && elemIt->more() && elemIt->next()->GetType() == elemType ); typeOK = ( elemIt && elemIt->more() && elemIt->next()->GetType() == elemType );
elemIt = typeOK ? sm->GetElements() : SMDS_ElemIteratorPtr(); elemIt = typeOK ? sm->GetElements() : SMDS_ElemIteratorPtr();
@ -5258,15 +5365,19 @@ SMDS_ElemIteratorPtr SMESH_Mesh_i::GetElements(SMESH::SMESH_IDSource_ptr theObje
else if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( theObject )) else if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( theObject ))
{ {
SMESHDS_GroupBase* groupDS = group_i->GetGroupDS(); SMESHDS_GroupBase* groupDS = group_i->GetGroupDS();
if ( groupDS && ( groupDS->GetType() == elemType || elemType == SMDSAbs_Node )) if ( groupDS && ( elemType == groupDS->GetType() ||
elemType == SMDSAbs_Node ||
elemType == SMDSAbs_All ))
{ {
elemIt = groupDS->GetElements(); elemIt = groupDS->GetElements();
typeOK = ( groupDS->GetType() == elemType ); typeOK = ( groupDS->GetType() == elemType || elemType == SMDSAbs_All );
} }
} }
else if ( SMESH::Filter_i* filter_i = SMESH::DownCast<SMESH::Filter_i*>( theObject )) else if ( SMESH::Filter_i* filter_i = SMESH::DownCast<SMESH::Filter_i*>( theObject ))
{ {
if ( filter_i->GetElementType() == theType || elemType == SMDSAbs_Node ) if ( filter_i->GetElementType() == theType ||
elemType == SMDSAbs_Node ||
elemType == SMDSAbs_All)
{ {
SMESH::Predicate_i* pred_i = filter_i->GetPredicate_i(); SMESH::Predicate_i* pred_i = filter_i->GetPredicate_i();
if ( pred_i && pred_i->GetPredicate() ) if ( pred_i && pred_i->GetPredicate() )
@ -5274,7 +5385,7 @@ SMDS_ElemIteratorPtr SMESH_Mesh_i::GetElements(SMESH::SMESH_IDSource_ptr theObje
SMDSAbs_ElementType filterType = SMDSAbs_ElementType( filter_i->GetElementType() ); SMDSAbs_ElementType filterType = SMDSAbs_ElementType( filter_i->GetElementType() );
SMDS_ElemIteratorPtr allElemIt = meshDS->elementsIterator( filterType ); SMDS_ElemIteratorPtr allElemIt = meshDS->elementsIterator( filterType );
elemIt = SMDS_ElemIteratorPtr( new PredicateIterator( allElemIt, pred_i->GetPredicate() )); elemIt = SMDS_ElemIteratorPtr( new PredicateIterator( allElemIt, pred_i->GetPredicate() ));
typeOK = ( filterType == elemType ); typeOK = ( filterType == elemType || elemType == SMDSAbs_All );
} }
} }
} }
@ -5282,7 +5393,7 @@ SMDS_ElemIteratorPtr SMESH_Mesh_i::GetElements(SMESH::SMESH_IDSource_ptr theObje
{ {
SMESH::array_of_ElementType_var types = theObject->GetTypes(); SMESH::array_of_ElementType_var types = theObject->GetTypes();
const bool isNodes = ( types->length() == 1 && types[0] == SMESH::NODE ); const bool isNodes = ( types->length() == 1 && types[0] == SMESH::NODE );
if ( isNodes && elemType != SMDSAbs_Node ) if ( isNodes && elemType != SMDSAbs_Node && elemType != SMDSAbs_All )
return elemIt; return elemIt;
if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theObject )) if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theObject ))
{ {
@ -5295,7 +5406,7 @@ SMDS_ElemIteratorPtr SMESH_Mesh_i::GetElements(SMESH::SMESH_IDSource_ptr theObje
SMESH::long_array_var ids = theObject->GetIDs(); SMESH::long_array_var ids = theObject->GetIDs();
elemIt = SMDS_ElemIteratorPtr( new IDSourceIterator( meshDS, ids._retn(), elemType )); elemIt = SMDS_ElemIteratorPtr( new IDSourceIterator( meshDS, ids._retn(), elemType ));
} }
typeOK = ( isNodes == ( elemType == SMDSAbs_Node )); typeOK = ( isNodes == ( elemType == SMDSAbs_Node )) || ( elemType == SMDSAbs_All );
} }
if ( elemIt && elemIt->more() && !typeOK ) if ( elemIt && elemIt->more() && !typeOK )

View File

@ -160,9 +160,11 @@ public:
const char* theName ) const char* theName )
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
SMESH::SMESH_Group_ptr CreateDimGroup( const SMESH::ListOfGroups& theGroups, SMESH::SMESH_Group_ptr CreateDimGroup( const SMESH::ListOfIDSources& theGroups,
SMESH::ElementType theElemType, SMESH::ElementType theElemType,
const char* theName ) const char* theName,
SMESH::NB_COMMON_NODES_ENUM theNbCommonNodes,
CORBA::Boolean theUnderlyingOnly )
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);

View File

@ -604,7 +604,7 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
## Concatenate the given meshes into one mesh. All groups of input meshes will be ## Concatenate the given meshes into one mesh. All groups of input meshes will be
# present in the new mesh. # present in the new mesh.
# @param meshes the meshes to combine into one mesh # @param meshes the meshes, sub-meshes and groups to combine into one mesh
# @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
# @param mergeNodesAndElements if true, equal nodes and elements are merged # @param mergeNodesAndElements if true, equal nodes and elements are merged
# @param mergeTolerance tolerance for merging nodes # @param mergeTolerance tolerance for merging nodes
@ -738,7 +738,9 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
if not name: if not name:
name = "%s_%s"%(aThreshold.GetShapeType(), id(aThreshold)%10000) name = "%s_%s"%(aThreshold.GetShapeType(), id(aThreshold)%10000)
aCriterion.ThresholdID = self.geompyD.addToStudy( aThreshold, name ) aCriterion.ThresholdID = self.geompyD.addToStudy( aThreshold, name )
#raise RuntimeError, "Threshold shape must be published" # or a name of GEOM object
elif isinstance( aThreshold, str ):
aCriterion.ThresholdStr = aThreshold
else: else:
print "Error: The Threshold should be a shape." print "Error: The Threshold should be a shape."
return None return None
@ -1960,7 +1962,8 @@ class Mesh:
def RemoveGroupWithContents(self, group): def RemoveGroupWithContents(self, group):
self.mesh.RemoveGroupWithContents(group) self.mesh.RemoveGroupWithContents(group)
## Gets the list of groups existing in the mesh in the order of creation (starting from the oldest one) ## Gets the list of groups existing in the mesh in the order
# of creation (starting from the oldest one)
# @return a sequence of SMESH_GroupBase # @return a sequence of SMESH_GroupBase
# @ingroup l2_grps_create # @ingroup l2_grps_create
def GetGroups(self): def GetGroups(self):
@ -1982,7 +1985,7 @@ class Mesh:
names.append(group.GetName()) names.append(group.GetName())
return names return names
## Produces a union of two groups ## Produces a union of two groups.
# A new group is created. All mesh elements that are # A new group is created. All mesh elements that are
# present in the initial groups are added to the new one # present in the initial groups are added to the new one
# @return an instance of SMESH_Group # @return an instance of SMESH_Group
@ -1990,7 +1993,7 @@ class Mesh:
def UnionGroups(self, group1, group2, name): def UnionGroups(self, group1, group2, name):
return self.mesh.UnionGroups(group1, group2, name) return self.mesh.UnionGroups(group1, group2, name)
## Produces a union list of groups ## Produces a union list of groups.
# New group is created. All mesh elements that are present in # New group is created. All mesh elements that are present in
# initial groups are added to the new one # initial groups are added to the new one
# @return an instance of SMESH_Group # @return an instance of SMESH_Group
@ -1998,7 +2001,7 @@ class Mesh:
def UnionListOfGroups(self, groups, name): def UnionListOfGroups(self, groups, name):
return self.mesh.UnionListOfGroups(groups, name) return self.mesh.UnionListOfGroups(groups, name)
## Prodices an intersection of two groups ## Prodices an intersection of two groups.
# A new group is created. All mesh elements that are common # A new group is created. All mesh elements that are common
# for the two initial groups are added to the new one. # for the two initial groups are added to the new one.
# @return an instance of SMESH_Group # @return an instance of SMESH_Group
@ -2006,7 +2009,7 @@ class Mesh:
def IntersectGroups(self, group1, group2, name): def IntersectGroups(self, group1, group2, name):
return self.mesh.IntersectGroups(group1, group2, name) return self.mesh.IntersectGroups(group1, group2, name)
## Produces an intersection of groups ## Produces an intersection of groups.
# New group is created. All mesh elements that are present in all # New group is created. All mesh elements that are present in all
# initial groups simultaneously are added to the new one # initial groups simultaneously are added to the new one
# @return an instance of SMESH_Group # @return an instance of SMESH_Group
@ -2014,7 +2017,7 @@ class Mesh:
def IntersectListOfGroups(self, groups, name): def IntersectListOfGroups(self, groups, name):
return self.mesh.IntersectListOfGroups(groups, name) return self.mesh.IntersectListOfGroups(groups, name)
## Produces a cut of two groups ## Produces a cut of two groups.
# A new group is created. All mesh elements that are present in # A new group is created. All mesh elements that are present in
# the main group but are not present in the tool group are added to the new one # the main group but are not present in the tool group are added to the new one
# @return an instance of SMESH_Group # @return an instance of SMESH_Group
@ -2022,22 +2025,35 @@ class Mesh:
def CutGroups(self, main_group, tool_group, name): def CutGroups(self, main_group, tool_group, name):
return self.mesh.CutGroups(main_group, tool_group, name) return self.mesh.CutGroups(main_group, tool_group, name)
## Produces a cut of groups ## Produces a cut of groups.
# A new group is created. All mesh elements that are present in main groups # A new group is created. All mesh elements that are present in main groups
# but do not present in tool groups are added to the new one # but do not present in tool groups are added to the new one
# @return an instance of SMESH_Group # @return an instance of SMESH_Group
# @ingroup l2_grps_operon # @ingroup l2_grps_operon
def CutListOfGroups(self, main_groups, tool_groups, name): def CutListOfGroups(self, main_groups, tool_groups, name):
return self.mesh.CutListOfGroups(main_groups, tool_groups, name) return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
## Produces a group of elements of specified type using list of existing groups ##
# A new group is created. System # Create a standalone group of entities basing on nodes of other groups.
# 1) extracts all nodes on which groups elements are built # \param groups - list of groups, sub-meshes or filters, of any type.
# 2) combines all elements of specified dimension laying on these nodes # \param elemType - a type of elements to include to the new group.
# \param name - a name of the new group.
# \param nbCommonNodes - a criterion of inclusion of an element to the new group
# basing on number of element nodes common with reference \a groups.
# Meaning of possible values are:
# - SMESH.ALL_NODES - include if all nodes are common,
# - SMESH.MAIN - include if all corner nodes are common (meaningful for a quadratic mesh),
# - SMESH.AT_LEAST_ONE - include if one or more node is common,
# - SMEHS.MAJORITY - include if half of nodes or more are common.
# \param underlyingOnly - if \c True (default), an element is included to the
# new group provided that it is based on nodes of one element of \a groups.
# @return an instance of SMESH_Group # @return an instance of SMESH_Group
# @ingroup l2_grps_operon # @ingroup l2_grps_operon
def CreateDimGroup(self, groups, elem_type, name): def CreateDimGroup(self, groups, elemType, name,
return self.mesh.CreateDimGroup(groups, elem_type, name) nbCommonNodes = SMESH.ALL_NODES, underlyingOnly = True):
if isinstance( groups, SMESH._objref_SMESH_IDSource ):
groups = [groups]
return self.mesh.CreateDimGroup(groups, elemType, name, nbCommonNodes, underlyingOnly)
## Convert group on geom into standalone group ## Convert group on geom into standalone group