diff --git a/doc/salome/gui/SMESH/images/2d_from_3d_dlg.png b/doc/salome/gui/SMESH/images/2d_from_3d_dlg.png
index a03530978..4a839e89e 100644
Binary files a/doc/salome/gui/SMESH/images/2d_from_3d_dlg.png and b/doc/salome/gui/SMESH/images/2d_from_3d_dlg.png differ
diff --git a/doc/salome/gui/SMESH/input/make_2dmesh_from_3d.doc b/doc/salome/gui/SMESH/input/make_2dmesh_from_3d.doc
index e52078629..fe8f31b66 100644
--- a/doc/salome/gui/SMESH/input/make_2dmesh_from_3d.doc
+++ b/doc/salome/gui/SMESH/input/make_2dmesh_from_3d.doc
@@ -7,6 +7,7 @@ elements of a higher dimension.
To generate border elements:
+
Select a mesh in the Object Browser or in the 3D Viewer
From the Modification menu choose "Create boundary elements"
item, or click "Create boundary elements" button in the toolbar
@@ -26,31 +27,27 @@ of three types.
2D from 3D creates mesh faces on free facets of volume elements
1D from 2D creates mesh edges on free edges of mesh faces
-
1D from 3D creates mesh edges on all borders of free facets of volume elements
+
1D from 2D groups creates mesh edges on borders of groups of faces
Here a free facet means a facet shared by only one volume, a free edge
means an edge shared by only one mesh face.
In this dialog:
-
specify the Mesh, submesh or group, the boundary which of
-will be analyzed.
+
specify the 2D groups on borders of which the edges will be
+generated (if 1D from 2D groups is selected).
specify the Target mesh, where the boundary elements will
be created.
-
This mesh adds elements in the selected mesh or the mesh
- the selected submesh or group belongs to.
+
This mesh adds elements in the selected mesh.
New mesh adds elements to a new mesh. The new mesh appears
in the Object Browser with the name that you can change in the adjacent box.
-
activate Copy source mesh checkbox to copy 2D or 3D
- elements (depending on the operation type), which belong to the analyzed
-Mesh, submesh or group field, to the new mesh.
-
deactivate Copy missing elements only checkbox to copy
- boundary elements already present in the analyzed mesh to the
- new mesh.
-
activate Create group checkbox to create a group to which the
- missing boundary elements are added. The new group appears
+
activate Copy source mesh checkbox to copy all elements of
+the selected mesh to the new mesh, else the new mesh will contain only
+boundary elements (old and created by this operation).
+
activate Create group checkbox to create a group to which
+ all the boundary elements (old and new) are added. The new group appears
in the Object Browser with the name that you can change in the adjacent box.
See Also a sample TUI Script of a \ref tui_make_2dmesh_from_3d "Create boundary elements" operation.
diff --git a/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc b/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc
index 22f11886f..2f2f10d4c 100644
--- a/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc
+++ b/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc
@@ -426,162 +426,111 @@ if salome.sg.hasDesktop():
Create boundary elements
\code
-# The objective of these samples is to illustrate the following use cases:
-# 1) The mesh MESH1 with 3D cells has no or only a part of its skin (2D cells):
-# 1.1) Add the 2D skin (missing 2D cells) to MESH1 (what is done now by the algorithm).
-# 1.2) Create a new 3D Mesh MESH2 that consists of MESH1 and added 2D skin cells.
-# 1.3) Create a new 2D Mesh MESH3 that consists only of 2D skin cells.
-# 2) The mesh MESH1 with 3D cells has all its skin (2D cells):
-# Create a new 2D Mesh MESH3 that consists only of 2D skin cells.
-#
-# In all cases an option to create a group containing these 2D skin cells is available.
-
from smesh import *
+SetCurrentStudy(salome.myStudy)
-box = geompy.MakeBoxDXDYDZ(1,1,1)
+box = geompy.MakeBoxDXDYDZ(100, 100, 100)
+gFaces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])
+f1,f2 = gFaces[0],gFaces[1]
geompy.addToStudy(box,"box")
-boxFace = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])[0]
-geompy.addToStudyInFather(box,boxFace,"boxFace")
+geompy.addToStudyInFather(box,f1,"face1")
+geompy.addToStudyInFather(box,f2,"face2")
-MESH1 = Mesh(box,"MESH1")
-MESH1.AutomaticHexahedralization()
+twoFaces = geompy.MakeCompound([f1,f2])
-init_nb_edges = MESH1.NbEdges()
-init_nb_faces = MESH1.NbFaces()
-init_nb_volumes = MESH1.NbVolumes()
+## -----------
+##
+## 2D from 3D
+##
+## -----------
+dim = SMESH.BND_2DFROM3D
+
+init_mesh = Mesh(box, "box")
+init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
-# =========================================================================================
-# 1) The mesh MESH1 with 3D cells has no or only a part of its skin (2D cells)
-# =========================================================================================
# remove some faces
-all_faces = MESH1.GetElementsByType(SMESH.FACE)
-rm_faces = all_faces[:init_nb_faces/5] + all_faces[4*init_nb_faces/5:]
-MESH1.RemoveElements(rm_faces)
-assert(MESH1.NbFaces() == init_nb_faces-len(rm_faces))
+faces = init_mesh.GetElementsByType( SMESH.FACE )
+nb_faces = len( faces )
+rm_face = faces[ : nb_faces/2]
+init_mesh.RemoveElements( rm_face )
-# 1.1) Add the 2D skin (missing 2D cells) to MESH1
-# -------------------------------------------------
-# add missing faces
-# 1.1.1) to the whole mesh
-m,g = MESH1.MakeBoundaryMesh(MESH1)
-assert(init_nb_faces == MESH1.NbFaces())
-assert(init_nb_edges == MESH1.NbEdges())
-assert(m)
-assert(not g)
+# restore boundary in this mesh
+mesh = CopyMesh( init_mesh, "2D from 3D")
+groupName = "bnd 2D"
+nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
-# 1.1.2) to some elements
-MESH1.RemoveElements(rm_faces)
-MESH1.MakeBoundaryMesh([])
-assert(init_nb_faces != MESH1.NbFaces())
-volumes = MESH1.GetElementsByType(SMESH.VOLUME)
-for v in volumes:
- MESH1.MakeBoundaryMesh([v])
-assert(init_nb_faces == MESH1.NbFaces())
-assert(init_nb_edges == MESH1.NbEdges())
+# restore boundary (only) in other mesh
+meshName = "2D boundary of " + init_mesh.GetName()
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
-# 1.1.3) to a group of elements
-volGroup1 = MESH1.CreateEmptyGroup(SMESH.VOLUME, "volGroup1")
-volGroup1.Add( volumes[: init_nb_volumes/2])
-volGroup2 = MESH1.CreateEmptyGroup(SMESH.VOLUME, "volGroup2")
-volGroup1.Add( volumes[init_nb_volumes/2:])
-MESH1.RemoveElements(rm_faces)
-MESH1.MakeBoundaryMesh(volGroup1)
-MESH1.MakeBoundaryMesh(volGroup2)
-assert(init_nb_faces == MESH1.NbFaces())
-assert(init_nb_edges == MESH1.NbEdges())
-
-# 1.1.4) to a submesh.
-# The submesh has no volumes, so it is required to check if it passes without crash and does not create
-# missing faces
-faceSubmesh = MESH1.GetSubMesh( boxFace, "boxFace" )
-MESH1.RemoveElements(rm_faces)
-MESH1.MakeBoundaryMesh(faceSubmesh)
-assert(init_nb_faces != MESH1.NbFaces())
-
-# check group creation
-MESH1.RemoveElements(rm_faces)
-groupName = "added to mesh"
-m,group = MESH1.MakeBoundaryMesh(MESH1,groupName=groupName)
-assert(group)
-assert(group.GetName() == groupName)
-assert(group.Size() == len(rm_faces))
+# restore boundary in mesh copy
+meshName = init_mesh.GetName() + " + boundary"
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
-# 1.2) Create a new 3D Mesh MESH2 that consists of MESH1 and added 2D skin cells.
-# ------------------------------------------------------------------------------
-MESH1.RemoveElements(rm_faces)
-meshName = "MESH2"
-MESH2,group = MESH1.MakeBoundaryMesh(MESH1,meshName=meshName,toCopyElements=True)
-assert(MESH2)
-assert(MESH2.GetName() == meshName)
-assert(MESH2.NbVolumes() == MESH1.NbVolumes())
-assert(MESH2.NbFaces() == len(rm_faces))
+## -----------
+##
+## 1D from 2D
+##
+## -----------
+dim = SMESH.BND_1DFROM2D
-# check group creation
-MESH1.RemoveElements(rm_faces)
-MESH2,group = MESH1.MakeBoundaryMesh(MESH1,meshName="MESH2_0",
- groupName=groupName,toCopyElements=True)
-assert(group)
-assert(group.GetName() == groupName)
-assert(group.Size() == len(rm_faces))
-assert(group.GetMesh()._is_equivalent(MESH2.GetMesh()))
+init_mesh = Mesh(f1, "2D mesh")
+init_mesh.AutomaticHexahedralization()
-# 1.3) Create a new 2D Mesh MESH3 that consists only of 2D skin cells.
-# -----------------------------------------------------------------------
-MESH1.RemoveElements(rm_faces)
-meshName = "MESH3"
-MESH3,group = MESH1.MakeBoundaryMesh(MESH1,meshName=meshName,toCopyExistingBondary=True)
-assert(MESH3)
-assert(not group)
-assert(MESH3.GetName() == meshName)
-assert(MESH3.NbVolumes() == 0)
-assert(MESH3.NbFaces() == init_nb_faces)
+# remove some edges
+edges = init_mesh.GetElementsByType( SMESH.EDGE )
+nb_edges = len( edges )
+rm_edge = edges[ : nb_edges/2]
+init_mesh.RemoveElements( rm_edge )
-# check group creation
-MESH1.RemoveElements(rm_faces)
-MESH3,group = MESH1.MakeBoundaryMesh(MESH1,meshName=meshName,
- groupName=groupName, toCopyExistingBondary=True)
-assert(group)
-assert(group.GetName() == groupName)
-assert(group.Size() == len(rm_faces))
-assert(group.GetMesh()._is_equivalent(MESH3.GetMesh()))
-assert(MESH3.NbFaces() == init_nb_faces)
-# ==================================================================
-# 2) The mesh MESH1 with 3D cells has all its skin (2D cells)
-# Create a new 2D Mesh MESH3 that consists only of 2D skin cells.
-# ==================================================================
-MESH1.MakeBoundaryMesh(MESH1)
-MESH3,group = MESH1.MakeBoundaryMesh(MESH1,meshName=meshName,toCopyExistingBondary=True)
-assert(MESH3)
-assert(not group)
-assert(MESH3.NbVolumes() == 0)
-assert(MESH3.NbFaces() == init_nb_faces)
+# restore boundary edges in this mesh
+mesh = CopyMesh( init_mesh, "1D from 2D")
+groupName = "bnd 1D"
+nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
-# check group creation
-MESH3,group = MESH1.MakeBoundaryMesh(MESH1,meshName=meshName,
- groupName=groupName, toCopyExistingBondary=True)
-assert(group)
-assert(group.GetName() == groupName)
-assert(group.Size() == 0)
-assert(group.GetMesh()._is_equivalent(MESH3.GetMesh()))
-assert(MESH3.NbFaces() == init_nb_faces)
+# restore boundary edges (only) in other mesh
+meshName = "1D boundary of " + init_mesh.GetName()
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
-# ================
-# Make 1D from 2D
-# ================
+# restore boundary edges in mesh copy
+meshName = init_mesh.GetName() + " + boundary"
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
-MESH1.Clear()
-MESH1.Compute()
-MESH1.RemoveElements( MESH1.GetElementsByType(SMESH.EDGE))
-rm_faces = faceSubmesh.GetIDs()[:2] # to remove few adjacent faces
-nb_missing_edges = 2 + 2*len(rm_faces)
-MESH1.RemoveElements(rm_faces)
-mesh,group = MESH1.MakeBoundaryMesh(MESH1, BND_1DFROM2D)
-assert( MESH1.NbEdges() == nb_missing_edges )
+## ------------------
+##
+## 1D from 2D GROUPS
+##
+## ------------------
+dim = SMESH.BND_1DFROM3D
+init_mesh = Mesh(box, "box")
+init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
+# remove all edges
+rm_edges = init_mesh.GetElementsByType( SMESH.EDGE )
+init_mesh.RemoveElements( rm_edges )
+
+# make groups of faces
+fGroup1 = init_mesh.Group( f1, "f1" )
+fGroup2 = init_mesh.Group( f2, "f2" )
+
+# make 1D boundary around groups in this mesh
+mesh = CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True)
+groups = mesh.GetGroups()
+nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName,groups=groups)
+
+# make 1D boundary (only) in other mesh
+meshName = "boundary from groups of " + init_mesh.GetName()
+groups = init_mesh.GetGroups()
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,groups=groups)
+
+# make 1D boundary in mesh copy
+meshName = init_mesh.GetName() + " + boundary from groups"
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,
+ groups=groups, toCopyAll=True)
\endcode
*/
diff --git a/src/SMESHGUI/SMESHGUI_Make2DFrom3DOp.cxx b/src/SMESHGUI/SMESHGUI_Make2DFrom3DOp.cxx
index eb8a49ba0..b11f4bdf7 100644
--- a/src/SMESHGUI/SMESHGUI_Make2DFrom3DOp.cxx
+++ b/src/SMESHGUI/SMESHGUI_Make2DFrom3DOp.cxx
@@ -28,12 +28,15 @@
#include "SMESH_LogicalFilter.hxx"
// SALOME GUI includes
+#include
#include
-#include
-#include
+#include
#include
#include
#include
+#include
+#include
+#include
// IDL includes
#include
@@ -46,6 +49,7 @@
#include
#include
#include
+#include
#define SPACING 6
#define MARGIN 11
@@ -56,15 +60,11 @@
*/
SMESHGUI_Make2DFrom3DDlg::SMESHGUI_Make2DFrom3DDlg( QWidget* parent )
- : SMESHGUI_Dialog( parent, false, true, OK | Apply | Close | Help )
+ : SMESHGUI_Dialog( parent, false, true, OK | Apply | Close | Help )
{
// title
setWindowTitle( tr("CAPTION") );
- // mesh
- setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
- createObject( tr( "MESH" ), mainFrame(), Mesh );
-
// mode
QGroupBox* aModeGrp = new QGroupBox( tr( "MODE" ), mainFrame() );
QHBoxLayout* aModeGrpLayout = new QHBoxLayout( aModeGrp );
@@ -77,6 +77,12 @@ SMESHGUI_Make2DFrom3DDlg::SMESHGUI_Make2DFrom3DDlg( QWidget* parent )
aModeGrpLayout->addWidget( my1dFrom2dRB );
aModeGrpLayout->addWidget( my1dFrom3dRB );
+ // Groups of mesh faces
+ setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
+ createObject( tr( "Groups" ), mainFrame(), Groups );
+ setNameIndication( Groups, ListOfNames );
+ objectWg( Groups, Btn )->hide();
+
// target
QGroupBox* aTargetGrp = new QGroupBox( tr( "TARGET" ), mainFrame() );
QGridLayout* aTargetGrpLayout = new QGridLayout( aTargetGrp );
@@ -86,12 +92,10 @@ SMESHGUI_Make2DFrom3DDlg::SMESHGUI_Make2DFrom3DDlg( QWidget* parent )
myNewMeshRB = new QRadioButton( tr( "NEW_MESH" ), aTargetGrp );
myMeshName = new QLineEdit( aTargetGrp );
myCopyCheck = new QCheckBox( tr( "COPY_SRC" ), aTargetGrp );
- myMissingCheck = new QCheckBox( tr( "MISSING_ONLY" ), aTargetGrp );
aTargetGrpLayout->addWidget( myThisMeshRB, 0, 0 );
aTargetGrpLayout->addWidget( myNewMeshRB, 1, 0 );
aTargetGrpLayout->addWidget( myMeshName, 1, 1 );
aTargetGrpLayout->addWidget( myCopyCheck, 2, 0 );
- aTargetGrpLayout->addWidget( myMissingCheck, 2, 1 );
myGroupCheck = new QCheckBox( tr( "CREATE_GROUP" ), mainFrame() );
myGroupName = new QLineEdit( mainFrame() );
@@ -99,10 +103,9 @@ SMESHGUI_Make2DFrom3DDlg::SMESHGUI_Make2DFrom3DDlg( QWidget* parent )
QGridLayout* aDlgLay = new QGridLayout( mainFrame() );
aDlgLay->setMargin( 0 );
aDlgLay->setSpacing( SPACING );
- aDlgLay->addWidget( objectWg( Mesh, Label ), 0, 0 );
- aDlgLay->addWidget( objectWg( Mesh, Btn ), 0, 1 );
- aDlgLay->addWidget( objectWg( Mesh, Control ), 0, 2 );
- aDlgLay->addWidget( aModeGrp, 1, 0, 1, 3 );
+ aDlgLay->addWidget( aModeGrp, 0, 0, 1, 3 );
+ aDlgLay->addWidget( objectWg( Groups, Label ), 1, 0 );
+ aDlgLay->addWidget( objectWg( Groups, Control ), 1, 1 );
aDlgLay->addWidget( aTargetGrp, 2, 0, 1, 3 );
aDlgLay->addWidget( myGroupCheck, 3, 0 );
aDlgLay->addWidget( myGroupName, 3, 1, 1, 2 );
@@ -115,7 +118,6 @@ SMESHGUI_Make2DFrom3DDlg::SMESHGUI_Make2DFrom3DDlg( QWidget* parent )
// init dlg
my2dFrom3dRB->setChecked( true );
myThisMeshRB->setChecked( true );
- myMissingCheck->setChecked( true );
onTargetChanged();
onGroupChecked();
}
@@ -169,16 +171,10 @@ bool SMESHGUI_Make2DFrom3DDlg::copySource() const
return myCopyCheck->isChecked();
}
-bool SMESHGUI_Make2DFrom3DDlg::copyMissingOnly() const
-{
- return myMissingCheck->isChecked();
-}
-
void SMESHGUI_Make2DFrom3DDlg::onTargetChanged()
{
myMeshName->setEnabled( myNewMeshRB->isChecked() );
myCopyCheck->setEnabled( myNewMeshRB->isChecked() );
- myMissingCheck->setEnabled( myNewMeshRB->isChecked() );
}
void SMESHGUI_Make2DFrom3DDlg::onGroupChecked()
@@ -212,33 +208,61 @@ void SMESHGUI_Make2DFrom3DOp::startOperation()
if( !myDlg )
myDlg = new SMESHGUI_Make2DFrom3DDlg( desktop() );
- mySrc = SMESH::SMESH_IDSource::_nil();
-
myHelpFileName = "make_2dmesh_from_3d_page.html";
SMESHGUI_SelectionOp::startOperation();
- myDlg->activateObject( SMESHGUI_Make2DFrom3DDlg::Mesh );
myDlg->setNewMeshName( SMESH::UniqueName( "Mesh_1" ) );
myDlg->setGroupName( SMESH::UniqueName( "Group" ) );
myDlg->show();
- selectionDone();
+ connect( myDlg->my2dFrom3dRB, SIGNAL( toggled(bool) ), this, SLOT( onModeChanged() ) );
+ connect( myDlg->my1dFrom2dRB, SIGNAL( toggled(bool) ), this, SLOT( onModeChanged() ) );
+ connect( myDlg->my1dFrom3dRB, SIGNAL( toggled(bool) ), this, SLOT( onModeChanged() ) );
+
+ onModeChanged();
+}
+
+void SMESHGUI_Make2DFrom3DOp::onModeChanged()
+{
+ QRadioButton* b = dynamic_cast( sender());
+ if ( b && !b->isChecked() )
+ return;
+
+ // enable "2D groups" field
+ bool enableGroups = ( myDlg->mode() == SMESH::BND_1DFROM3D );
+ myDlg->setObjectEnabled( SMESHGUI_Make2DFrom3DDlg::Groups, enableGroups );
+ ((QToolButton*) myDlg->objectWg( SMESHGUI_Make2DFrom3DDlg::Groups,
+ SMESHGUI_Make2DFrom3DDlg::Btn ))->setChecked( enableGroups );
+
+ // install filter
+ int id = enableGroups ? SMESHGUI_Make2DFrom3DDlg::Groups : SMESHGUI_Make2DFrom3DDlg::Mesh;
+ onDeactivateObject( id );
+ onActivateObject( id );
}
void SMESHGUI_Make2DFrom3DOp::selectionDone()
{
+ mySrcMesh = SMESH::SMESH_Mesh::_nil();
+ myDlg->clearSelection( SMESHGUI_Make2DFrom3DDlg::Groups );
+
if ( !dlg() ) return;
+
if ( dlg()->isVisible() ) {
try {
QStringList names, ids;
LightApp_Dialog::TypesList types;
selected( names, types, ids );
- if ( names.count() == 1 )
- myDlg->selectObject( names, types, ids );
- else
- myDlg->clearSelection();
+ myDlg->selectObject( names, types, ids );
+
+ SALOME_ListIO sel; selectionMgr()->selectedObjects( sel, SVTK_Viewer::Type() );
+ if ( !sel.IsEmpty() )
+ {
+ SMESH::SMESH_IDSource_var IS = SMESH::IObjectToInterface(sel.First());
+ if(!CORBA::is_nil(IS))
+ mySrcMesh = IS->GetMesh();
+ }
}
catch ( const SALOME::SALOME_Exception& S_ex ) {
SalomeApp_Tools::QtCatchCorbaException( S_ex );
@@ -250,13 +274,8 @@ void SMESHGUI_Make2DFrom3DOp::selectionDone()
SUIT_SelectionFilter* SMESHGUI_Make2DFrom3DOp::createFilter( const int theId ) const
{
- SUIT_SelectionFilter* f = 0;
- if ( theId == SMESHGUI_Make2DFrom3DDlg::Mesh ) {
- QList filters;
- filters.append( new SMESH_TypeFilter( MESHorSUBMESH ) );
- filters.append( new SMESH_TypeFilter( GROUP ) );
- f = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
- }
+ MeshObjectType type = ( theId == SMESHGUI_Make2DFrom3DDlg::Groups ? GROUP_FACE : MESH );
+ SUIT_SelectionFilter* f = new SMESH_TypeFilter( type );
return f;
}
@@ -264,36 +283,43 @@ bool SMESHGUI_Make2DFrom3DOp::isValid( QString& msg ) const
{
if ( !dlg() ) return false;
- // check if any source data is selected
- QString entry = myDlg->selectedObject( SMESHGUI_Make2DFrom3DDlg::Mesh );
- SMESH::SMESH_IDSource_var obj;
- _PTR(SObject) sobj = SMESHGUI::activeStudy()->studyDS()->FindObjectID( entry.toLatin1().constData() );
- if ( sobj )
- obj = SMESH::SObjectToInterface( sobj );
-
- if ( obj->_is_nil() ) {
+ // check if a mesh is selected
+ if ( mySrcMesh->_is_nil() )
+ {
msg = tr( "SMESH_ERR_NO_INPUT_MESH" );
return false;
}
-
- // check if source contains elements of required type
+ // check if groups are selected
SMESH::Bnd_Dimension mode = myDlg->mode();
- SMESH::array_of_ElementType_var types = obj->GetTypes();
-
- bool has3d = false;
- bool has2d = false;
- for ( int i = 0; i < types->length(); i++ ) {
- if ( types[i] == SMESH::VOLUME ) has3d = true;
- else if ( types[i] == SMESH::FACE ) has2d = true;
+ if ( mode == SMESH::BND_1DFROM3D )
+ {
+ SMESH::SMESH_GroupBase_var grp;
+ QStringList entries;
+ dlg()->selectedObject( SMESHGUI_Make2DFrom3DDlg::Groups, entries );
+ if ( !entries.isEmpty() )
+ {
+ _PTR(SObject) sobj = SMESHGUI::activeStudy()->studyDS()->FindObjectID( entries[0].toLatin1().constData() );
+ if ( sobj )
+ grp = SMESH::SObjectToInterface( sobj );
+ }
+ if ( grp->_is_nil() ) {
+ msg = tr( "SMESH_ERR_NO_INPUT_GROUP" );
+ return false;
+ }
}
+ else
+ {
+ // check if mesh contains elements of required type
+ SMESH::Bnd_Dimension mode = myDlg->mode();
- if ( ( mode == SMESH::BND_2DFROM3D || mode == SMESH::BND_1DFROM3D ) && !has3d ) {
- msg = tr( "SMESH_ERR_NO_3D_ELEMENTS" );
- return false;
- }
- else if ( mode == SMESH::BND_1DFROM2D && !has2d ) {
- msg = tr( "SMESH_ERR_NO_2D_ELEMENTS" );
- return false;
+ if ( mode == SMESH::BND_2DFROM3D && mySrcMesh->NbVolumes() == 0 ) {
+ msg = tr( "SMESH_ERR_NO_3D_ELEMENTS" );
+ return false;
+ }
+ else if ( mode == SMESH::BND_1DFROM2D && mySrcMesh->NbFaces() == 0 ) {
+ msg = tr( "SMESH_ERR_NO_2D_ELEMENTS" );
+ return false;
+ }
}
// check if new mesh name is specified
@@ -317,41 +343,38 @@ bool SMESHGUI_Make2DFrom3DOp::compute2DMesh()
bool ok = false;
try {
- QString entry = myDlg->selectedObject( SMESHGUI_Make2DFrom3DDlg::Mesh );
- _PTR(SObject) sobj = SMESHGUI::activeStudy()->studyDS()->FindObjectID( entry.toLatin1().constData() );
- SMESH::SMESH_IDSource_var obj = SMESH::SObjectToInterface( sobj );
-
+ QStringList entries;
+ dlg()->selectedObject( SMESHGUI_Make2DFrom3DDlg::Groups, entries );
+ SMESH::ListOfIDSources_var groups = new SMESH::ListOfIDSources;
+ groups->length( entries.count() );
+ for ( int i = 0; i < entries.count(); ++i )
+ {
+ _PTR(SObject) sobj = SMESHGUI::activeStudy()->studyDS()->FindObjectID( entries[i].toLatin1().constData() );
+ SMESH::SMESH_IDSource_var grp = SMESH::SObjectToInterface( sobj );
+ groups[i] = grp;
+ }
SMESH::Bnd_Dimension mode = myDlg->mode();
QString meshName = myDlg->needNewMesh() ? myDlg->getNewMeshName() : QString();
QString groupName = myDlg->needGroup() ? myDlg->getGroupName() : QString();
- bool copySrc = myDlg->copySource();
- bool copyAll = !myDlg->copyMissingOnly();
+ bool copyAll = myDlg->copySource();
- SMESH::SMESH_Mesh_var srcMesh = SMESH::SMESH_Mesh::_narrow( obj );
- if ( CORBA::is_nil( srcMesh ) ) {
- SMESH::SMESH_subMesh_var subMesh = SMESH::SMESH_subMesh::_narrow( obj );
- if ( !CORBA::is_nil( subMesh ) )
- srcMesh = subMesh->GetFather();
- }
- if ( CORBA::is_nil( srcMesh ) ) {
- SMESH::SMESH_GroupBase_var grp = SMESH::SMESH_GroupBase::_narrow( obj );
- if ( !CORBA::is_nil( grp ) )
- srcMesh = grp->GetMesh();
- }
-
- if ( !CORBA::is_nil( srcMesh ) ) {
- SMESH::SMESH_MeshEditor_var aMeshEditor = srcMesh->GetMeshEditor();
+ if ( !CORBA::is_nil( mySrcMesh ) ) {
+ SMESH::SMESH_MeshEditor_var aMeshEditor = mySrcMesh->GetMeshEditor();
SMESH::SMESH_Group_var newGrp;
- SMESH::SMESH_Mesh_var mesh = aMeshEditor->MakeBoundaryMesh( obj.in(),
- mode,
- groupName.toLatin1().constData(),
- meshName.toLatin1().constData(),
- copySrc,
- copyAll,
- newGrp.out() );
- if ( !mesh->_is_nil() ) {
+ SMESH::SMESH_Mesh_var newMesh;
+ CORBA::Long nbAdded = aMeshEditor->MakeBoundaryElements( mode,
+ groupName.toLatin1().constData(),
+ meshName.toLatin1().constData(),
+ copyAll,
+ groups,
+ newMesh.out(),
+ newGrp.out() );
+ SUIT_MessageBox::information( myDlg,
+ tr("SMESH_INFORMATION"),
+ tr("NB_ADDED").arg( nbAdded ));
+ if ( !newMesh->_is_nil() ) {
#ifdef WITHGENERICOBJ
- mesh->UnRegister();
+ newMesh->UnRegister();
#endif
}
if ( !newGrp->_is_nil() ) {
diff --git a/src/SMESHGUI/SMESHGUI_Make2DFrom3DOp.h b/src/SMESHGUI/SMESHGUI_Make2DFrom3DOp.h
index 23bab5e61..69cc94655 100644
--- a/src/SMESHGUI/SMESHGUI_Make2DFrom3DOp.h
+++ b/src/SMESHGUI/SMESHGUI_Make2DFrom3DOp.h
@@ -29,10 +29,12 @@
#include
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QCheckBox;
class QLineEdit;
class QRadioButton;
+class SMESHGUI_Make2DFrom3DOp;
/*!
* \brief Dialog to show result mesh statistic
@@ -43,7 +45,7 @@ class SMESHGUI_EXPORT SMESHGUI_Make2DFrom3DDlg : public SMESHGUI_Dialog
Q_OBJECT
public:
- enum { Mesh };
+ enum { Mesh, Groups };
SMESHGUI_Make2DFrom3DDlg( QWidget* );
virtual ~SMESHGUI_Make2DFrom3DDlg();
@@ -59,7 +61,6 @@ public:
void setGroupName( const QString& );
bool copySource() const;
- bool copyMissingOnly() const;
private slots:
void onTargetChanged();
@@ -73,9 +74,10 @@ private:
QRadioButton* myNewMeshRB;
QLineEdit* myMeshName;
QCheckBox* myCopyCheck;
- QCheckBox* myMissingCheck;
QCheckBox* myGroupCheck;
QLineEdit* myGroupName;
+
+ friend class SMESHGUI_Make2DFrom3DOp;
};
/*!
@@ -100,12 +102,13 @@ protected:
protected slots:
virtual bool onApply();
+ void onModeChanged();
private:
bool compute2DMesh();
private:
- SMESH::SMESH_IDSource_var mySrc;
+ SMESH::SMESH_Mesh_var mySrcMesh;
QPointer myDlg;
};
diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts
index d615804e7..d6e8ce582 100644
--- a/src/SMESHGUI/SMESH_msg_en.ts
+++ b/src/SMESHGUI/SMESH_msg_en.ts
@@ -5589,8 +5589,8 @@ It is impossible to read point coordinates from file
Create boundary elements
- MESH
- Mesh, submesh or group
+ Groups
+ 2D groupsMODE
@@ -5602,7 +5602,7 @@ It is impossible to read point coordinates from file
1D_FROM_3D
- 1D from 3D
+ 1D from 2D groups1D_FROM_2D
@@ -5635,9 +5635,17 @@ It is impossible to read point coordinates from file
SMESHGUI_Make2DFrom3DOp
+
+ NB_ADDED
+ %1 boundary elements have been added
+ SMESH_ERR_NO_INPUT_MESH
- Source mesh, sub-mesh or group is not specified
+ Source mesh is not specified
+
+
+ SMESH_ERR_NO_INPUT_GROUP
+ 2D group is not specifiedSMESH_ERR_NO_3D_ELEMENTS