Salome HOME
bos #32735 [CEA] Create 2D Mesh from 3D elements. cce/32735MeshOfFaces 17/head
authorcconopoima <cesar.conopoima@gmail.com>
Tue, 27 Jun 2023 17:59:34 +0000 (14:59 -0300)
committercconopoima <cesar.conopoima@gmail.com>
Thu, 10 Aug 2023 16:08:57 +0000 (17:08 +0100)
Adding test and icon to cmake. Adding the keyword MakeBoundaryOfEachElement to the 2smeshpy util class.

Add missing french translations of dialog box and operations results. Update copyright message of SMESHGUI_MakeFull2DFrom3DOp new class.

27 files changed:
doc/examples/tests.set
doc/examples/transforming_meshes_ex14.py [new file with mode: 0644]
doc/gui/images/2d_mesh_from_3d_elements.jpg [new file with mode: 0644]
doc/gui/images/2d_mesh_from_3d_elements_dlg.png [new file with mode: 0644]
doc/gui/images/2d_mesh_from_3d_elements_icon.png [new file with mode: 0644]
doc/gui/input/make_2dmesh_from_3d_elements.rst [new file with mode: 0644]
doc/gui/input/modifying_meshes.rst
doc/gui/input/tui_transforming_meshes.rst
idl/SMESH_MeshEditor.idl
resources/CMakeLists.txt
resources/mesh_2d_from_3d_elements.png [new file with mode: 0644]
src/SMESH/SMESH_MeshEditor.cxx
src/SMESH/SMESH_MeshEditor.hxx
src/SMESHGUI/CMakeLists.txt
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_Make2DFrom3DOp.cxx
src/SMESHGUI/SMESHGUI_Make2DFrom3DOp.h
src/SMESHGUI/SMESHGUI_MakeFull2DFrom3DOp.cxx [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_MakeFull2DFrom3DOp.h [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_Operations.h
src/SMESHGUI/SMESH_images.ts
src/SMESHGUI/SMESH_msg_en.ts
src/SMESHGUI/SMESH_msg_fr.ts
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.hxx
src/SMESH_SWIG/smeshBuilder.py

index 96acda0cb155da720363a6834524232518ef34bd..86d5e8787abbbd9e21434284a0b71a26b269897d 100644 (file)
@@ -196,6 +196,7 @@ SET(GOOD_TESTS
   transforming_meshes_ex11.py
   transforming_meshes_ex12.py
   transforming_meshes_ex13.py
+  transforming_meshes_ex14.py
   use_existing_faces.py
   viewing_meshes_ex02.py
   quad_medial_axis_algo.py
diff --git a/doc/examples/transforming_meshes_ex14.py b/doc/examples/transforming_meshes_ex14.py
new file mode 100644 (file)
index 0000000..38010b2
--- /dev/null
@@ -0,0 +1,47 @@
+# Create 2D mesh from 3D elements
+
+import salome
+salome.salome_init_without_session()
+
+import SMESH
+from salome.geom import geomBuilder
+from salome.smesh import smeshBuilder
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+
+box = geom_builder.MakeBoxDXDYDZ(100, 100, 100)
+
+gFaces = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType["FACE"])
+f1,f2 = gFaces[0],gFaces[1]
+geom_builder.addToStudy(box,"box")
+geom_builder.addToStudyInFather(box,f1,"face1")
+geom_builder.addToStudyInFather(box,f2,"face2")
+
+twoFaces = geom_builder.MakeCompound([f1,f2])
+
+## -----------
+##
+## Create 2D from 3D elements
+##
+## -----------
+
+init_mesh = smesh_builder.Mesh(box, "box")
+init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
+init_mesh.Compute()
+
+mesh_1 = smesh_builder.CopyMesh(init_mesh, "Mesh_1")
+#Return the number of created faces in the original mesh.
+nb, new_mesh, new_group = mesh_1.MakeBoundaryOfEachElement()
+
+if nb != 54: raise Exception("Error on MakeBoundaryOfEachElement call. The number of created elements does not match.")
+if new_mesh.GetId() != mesh_1.GetId(): raise Exception("The mesh created from MakeBoundaryElements should be the same of the call")
+if new_group: raise Exception("The group created from MakeBoundaryElements should be undefined")
+
+mesh_2 = smesh_builder.CopyMesh(init_mesh, "Mesh_2")
+
+#Return the number of created faces and a new_mesh and new_group 
+nb, new_mesh, new_group = mesh_2.MakeBoundaryOfEachElement("MyFacesElements", "Face_Mesh")
+if nb != 54: raise Exception("Error on MakeBoundaryOfEachElement call. The number of created elements does not match.")
+if new_mesh.GetId() == mesh_2.GetId(): raise Exception("The mesh created from MakeBoundaryElements should be the different of the call")
+if not new_group: raise Exception("The group created from MakeBoundaryElements should be defined")
diff --git a/doc/gui/images/2d_mesh_from_3d_elements.jpg b/doc/gui/images/2d_mesh_from_3d_elements.jpg
new file mode 100644 (file)
index 0000000..2edba32
Binary files /dev/null and b/doc/gui/images/2d_mesh_from_3d_elements.jpg differ
diff --git a/doc/gui/images/2d_mesh_from_3d_elements_dlg.png b/doc/gui/images/2d_mesh_from_3d_elements_dlg.png
new file mode 100644 (file)
index 0000000..77ed543
Binary files /dev/null and b/doc/gui/images/2d_mesh_from_3d_elements_dlg.png differ
diff --git a/doc/gui/images/2d_mesh_from_3d_elements_icon.png b/doc/gui/images/2d_mesh_from_3d_elements_icon.png
new file mode 100644 (file)
index 0000000..2cb269d
Binary files /dev/null and b/doc/gui/images/2d_mesh_from_3d_elements_icon.png differ
diff --git a/doc/gui/input/make_2dmesh_from_3d_elements.rst b/doc/gui/input/make_2dmesh_from_3d_elements.rst
new file mode 100644 (file)
index 0000000..25e2233
--- /dev/null
@@ -0,0 +1,45 @@
+.. _make_2dmesh_from_3d_elements_page:
+
+**************************
+Generate 2D mesh from 3D elements
+**************************
+
+This functionality allows to generate 2D mesh elements from the 3D elements in the mesh.
+
+.. image:: ../images/2d_mesh_from_3d_elements.jpg
+       :align: center
+
+.. centered::
+       2D mesh created from the 3D elements
+
+
+*To generate 2D elements:*
+
+.. |img| image:: ../images/2d_mesh_from_3d_elements_icon.png
+
+#. Select a mesh or group in the Object Browser or in the 3D Viewer
+#. From the **Modification** menu choose **Create 2D mesh from 3D** item, or click "Create 2D mesh from 3D" button |img| in the toolbar
+
+   The following dialog box will appear:
+
+       .. image:: ../images/2d_mesh_from_3d_elements_dlg.png   
+               :align: center
+
+       .. centered::
+                Create 2D mesh from 3D elements dialog box
+
+#. Click the **Apply** or **Apply and Close** button to perform the operation.
+
+In this dialog:
+
+* specify the **Target** mesh, where the boundary elements will be created.
+  
+       * **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 all elements of the selected mesh to the new mesh, else the new mesh will contain only 2D elements (old and created by this operation).
+* activate **Create group** checkbox to create a group to which all the 2D 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_elements` operation.  
+
+
index 60e5f84a019696225d8c650aba72a55b14785fac..36aeab909ab15a3ec76ab8c331cef43932e47ae5 100644 (file)
@@ -11,6 +11,7 @@ Salome provides a vast specter of mesh modification and transformation operation
 * :ref:`Remove <removing_nodes_and_elements_page>` any existing mesh elements and nodes.
 * :ref:`Convert linear mesh to quadratic <convert_to_from_quadratic_mesh_page>`, or vice versa.
 * :ref:`Generate boundary elements <make_2dmesh_from_3d_page>`.
+* :ref:`Generate 2D mesh from 3D elements <make_2dmesh_from_3d_elements_page>`.
 * :ref:`Translate <translation_page>` in the indicated direction the mesh or some of its elements.
 * :ref:`Rotate <rotation_page>` by the indicated axis and angle the mesh or some of its elements.
 * :ref:`Scale <scale_page>` the mesh or some of its elements.
@@ -80,6 +81,7 @@ Salome provides a vast specter of mesh modification and transformation operation
    pattern_mapping.rst
    convert_to_from_quadratic_mesh.rst
    make_2dmesh_from_3d.rst
+   make_2dmesh_from_3d_elements.rst
    generate_flat_elements.rst
    cut_mesh_by_plane.rst
 
index b1a09a1dcff4305031bcefb64a6c5007900d0f32..59a068c00f391ed93fd19ad08292afe175c4f000 100644 (file)
@@ -136,3 +136,13 @@ Reorient faces
     :language: python
 
 :download:`Download this script <../../examples/transforming_meshes_ex13.py>`
+
+.. _tui_make_2dmesh_from_3d_elements: 
+
+Create 2D mesh from 3D elements
+========================
+
+.. literalinclude:: ../../examples/transforming_meshes_ex14.py
+    :language: python
+
+:download:`Download this script <../../examples/transforming_meshes_ex14.py>`
\ No newline at end of file
index 55e06d6f6bed7c75a4d4a7d9459233a29a870c32..a832bde097246b2907158a3b2f97dce0a0f1cfb8 100644 (file)
@@ -1291,7 +1291,9 @@ module SMESH
      *  \param meshName - a name of a new mesh, which is a copy of the initial 
      *    mesh + created boundary elements; "" means not to create the new mesh
      *  \param toCopyAll - if true, the whole initial mesh will be copied into
-     *    the new mesh else only boundary elements will be copied into the new mesh
+     *    the new mesh else only the new elements will be copied into the new mesh
+     *  \param toCreateAllElements - if true, all the boundary elements of the mesh 
+     *    are computed. 
      *  \param groups - optional groups of 2D elements to make boundary around
      *  \param mesh - returns the mesh where elements were added to
      *  \param group - returns the created group, if any
@@ -1301,6 +1303,7 @@ module SMESH
                               in string          groupName,
                               in string          meshName,
                               in boolean         toCopyAll,
+                              in boolean         toCreateAllElements,
                               in ListOfIDSources groups,
                               out SMESH_Mesh     mesh,
                               out SMESH_Group    group) raises (SALOME::SALOME_Exception);
index feda6ed7e298f37bf36e2ba192aeb696de841cdb..87f576681dffc2b554c895a37d6f8897d22d0af1 100644 (file)
@@ -34,6 +34,7 @@ SET(SMESH_RESOURCES_FILES
   mesh_0D_elem.png
   mesh_0D_on_all_nodes.png
   mesh_2d_from_3d.png
+  mesh_2d_from_3d_elements.png
   mesh_add.png
   mesh_add_sub.png
   mesh_algo_hexa.png
diff --git a/resources/mesh_2d_from_3d_elements.png b/resources/mesh_2d_from_3d_elements.png
new file mode 100644 (file)
index 0000000..d347d2e
Binary files /dev/null and b/resources/mesh_2d_from_3d_elements.png differ
index 05b818c2fdf0ed679f60525e1ddd9d82a962cf18..a0db1ec7aa2122e6ffc198b4557f7f5aee060630 100644 (file)
@@ -12809,7 +12809,8 @@ int SMESH_MeshEditor::MakeBoundaryMesh(const TIDSortedElemSet& elements,
                                        bool                    toCopyElements/*=false*/,
                                        bool                    toCopyExistingBoundary/*=false*/,
                                        bool                    toAddExistingBondary/*= false*/,
-                                       bool                    aroundElements/*= false*/)
+                                       bool                    aroundElements/*= false*/,
+                                       bool                    toCreateAllElements/*= false*/)
 {
   SMDSAbs_ElementType missType = (dimension == BND_2DFROM3D) ? SMDSAbs_Face : SMDSAbs_Edge;
   SMDSAbs_ElementType elemType = (dimension == BND_1DFROM2D) ? SMDSAbs_Face : SMDSAbs_Volume;
@@ -12828,7 +12829,6 @@ int SMESH_MeshEditor::MakeBoundaryMesh(const TIDSortedElemSet& elements,
   SMESH_MeshEditor* presentEditor;
   SMESH_MeshEditor tgtEditor2( tgtEditor.GetMesh() );
   presentEditor = toAddExistingBondary ? &tgtEditor : &tgtEditor2;
-
   SMESH_MesherHelper helper( *myMesh );
   const TopAbs_ShapeEnum missShapeType = ( missType==SMDSAbs_Face ? TopAbs_FACE : TopAbs_EDGE );
   SMDS_VolumeTool vTool;
@@ -12866,8 +12866,9 @@ int SMESH_MeshEditor::MakeBoundaryMesh(const TIDSortedElemSet& elements,
       const SMDS_MeshElement* otherVol = 0;
       for ( int iface = 0, n = vTool.NbFaces(); iface < n; iface++ )
       {
-        if ( !vTool.IsFreeFace(iface, &otherVol) &&
-             ( !aroundElements || elements.count( otherVol )))
+        if ( !toCreateAllElements && 
+              !vTool.IsFreeFace(iface, &otherVol) &&
+                ( !aroundElements || elements.count( otherVol )))
           continue;
         freeFacets.push_back( iface );
       }
index 06c5106601ca2195d4cea36b294ef3b6a57bdf8b..81340ca5cf1274dfda8839b76c1a402e5b3cf833 100644 (file)
@@ -748,7 +748,8 @@ public:
                        bool                    toCopyElements = false,
                        bool                    toCopyExistingBondary = false,
                        bool                    toAddExistingBondary = false,
-                       bool                    aroundElements = false);
+                       bool                    aroundElements = false,
+                       bool                    toCreateAllElements= false);
 
  private:
 
index 5995cbc96a21baceb1e240fe4943f67cacaba4eb..a8c506e46e15cc190e3e785527afac9ac85f162c 100644 (file)
@@ -136,6 +136,7 @@ SET(_moc_HEADERS
   SMESHGUI_MakeNodeAtPointDlg.h
   SMESHGUI_MeshInfosBox.h
   SMESHGUI_Make2DFrom3DOp.h
+  SMESHGUI_MakeFull2DFrom3DOp.h
   SMESHGUI_FindElemByPointDlg.h
   SMESHGUI_MeshOrderDlg.h
   SMESHGUI_CopyMeshDlg.h
@@ -249,6 +250,7 @@ SET(_other_SOURCES
   SMESHGUI_FileInfoDlg.cxx
   SMESHGUI_MeshInfosBox.cxx
   SMESHGUI_Make2DFrom3DOp.cxx
+  SMESHGUI_MakeFull2DFrom3DOp.cxx
   SMESHGUI_FindElemByPointDlg.cxx
   SMESHGUI_MeshOrderDlg.cxx
   SMESHGUI_CopyMeshDlg.cxx
index 85ab20cc9dcfa684b42c0f95ce15756403f12e6a..78fba25d51422f3f28abafed94c188f20399c6a8 100644 (file)
@@ -65,6 +65,7 @@
 #include "SMESHGUI_MG_ADAPTDRIVER.h"
 #include "SMESHGUI_HomardAdaptDlg.h"
 #include "SMESHGUI_Make2DFrom3DOp.h"
+#include "SMESHGUI_MakeFull2DFrom3DOp.h"
 #include "SMESHGUI_MakeNodeAtPointDlg.h"
 #include "SMESHGUI_Measurements.h"
 #include "SMESHGUI_MergeDlg.h"
@@ -3058,6 +3059,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case SMESHOp::OpConvertMeshToQuadratic:
   case SMESHOp::OpCreateDualMesh:
   case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
+  case SMESHOp::OpCreate2DElements: // create full 2D mesh from 3D
   case SMESHOp::OpReorientFaces:
   case SMESHOp::OpCreateGeometryGroup:
     {
@@ -4285,6 +4287,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD",    "ICON_CONV_TO_QUAD" );
   createSMESHAction( SMESHOp::OpCreateDualMesh,         "CREATE_DUAL_MESH","ICON_CREATE_DUAL_MESH" );
   createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D",      "ICON_2D_FROM_3D" );
+  createSMESHAction( SMESHOp::OpCreate2DElements,    "2D_FROM_3D_ELEMENTS","ICON_2D_FROM_3D_ELEMENTS" );
 
   createSMESHAction( SMESHOp::OpReset,               "RESET" );
   createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
@@ -4535,6 +4538,7 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
   createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
+  createMenu( SMESHOp::OpCreate2DElements,       modifyId, -1 );
   createMenu( SMESHOp::OpExtrusion,              modifyId, -1 );
   createMenu( SMESHOp::OpExtrusionAlongAPath,    modifyId, -1 );
   createMenu( SMESHOp::OpRevolution,             modifyId, -1 );
@@ -4688,6 +4692,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
   createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
   createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
+  createTool( SMESHOp::OpCreate2DElements,       modifyTb );
   createTool( SMESHOp::OpExtrusion,              modifyTb );
   createTool( SMESHOp::OpExtrusionAlongAPath,    modifyTb );
   createTool( SMESHOp::OpRevolution,             modifyTb );
@@ -6044,6 +6049,9 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
   case SMESHOp::OpCreateDualMesh:
     op = new SMESHGUI_CreateDualMeshOp();
     break;
+  case SMESHOp::OpCreate2DElements:
+    op = new SMESHGUI_MakeFull2DFrom3DOp();
+    break;
   case SMESHOp::OpReorientFaces:
     op = new SMESHGUI_ReorientFacesOp();
     break;
index 8f5a47aabc93afd64e57891cabe2aadb48ce6ab1..94391a33a6b468e92d066126b9dd06f6a568219f 100644 (file)
@@ -73,17 +73,16 @@ SMESHGUI_Make2DFrom3DDlg::SMESHGUI_Make2DFrom3DDlg( QWidget* parent )
   setWindowTitle( tr("CAPTION") );
 
   // mode
-  QGroupBox* aModeGrp = new QGroupBox( tr( "MODE" ), mainFrame() );
-  QHBoxLayout* aModeGrpLayout = new QHBoxLayout( aModeGrp );
+  myModeGrp = new QGroupBox( tr( "MODE" ), mainFrame() );
+  QHBoxLayout* aModeGrpLayout = new QHBoxLayout( myModeGrp );
   aModeGrpLayout->setMargin( MARGIN );
   aModeGrpLayout->setSpacing( SPACING );
-  my2dFrom3dRB = new QRadioButton( tr( "2D_FROM_3D" ), aModeGrp );
-  my1dFrom2dRB = new QRadioButton( tr( "1D_FROM_2D" ), aModeGrp );
+  my2dFrom3dRB = new QRadioButton( tr( "2D_FROM_3D" ), myModeGrp );
+  my1dFrom2dRB = new QRadioButton( tr( "1D_FROM_2D" ), myModeGrp );
   //my1dFrom3dRB = new QRadioButton( tr( "1D_FROM_3D" ), aModeGrp );
   aModeGrpLayout->addWidget( my2dFrom3dRB );
   aModeGrpLayout->addWidget( my1dFrom2dRB );
   //aModeGrpLayout->addWidget( my1dFrom3dRB );
-
 //   // Groups of mesh faces
 //   setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
 //   createObject( tr( "Groups" ), mainFrame(), Groups );
@@ -116,7 +115,7 @@ SMESHGUI_Make2DFrom3DDlg::SMESHGUI_Make2DFrom3DDlg( QWidget* parent )
   QGridLayout* aDlgLay = new QGridLayout( mainFrame() );
   aDlgLay->setMargin( 0 );
   aDlgLay->setSpacing( SPACING );
-  aDlgLay->addWidget( aModeGrp,     0, 0, 1, 3 );
+  aDlgLay->addWidget( myModeGrp,     0, 0, 1, 3 );
   aDlgLay->addWidget( objectWg( MeshOrGroups,  Label ),   1, 0 );
   aDlgLay->addWidget( objectWg( MeshOrGroups,  Control ), 1, 1 );
   aDlgLay->addWidget( aTargetGrp,   2, 0, 1, 3 );
@@ -409,6 +408,7 @@ bool SMESHGUI_Make2DFrom3DOp::compute2DMesh( QStringList& theEntryList )
   SUIT_OverrideCursor wc;
 
   bool ok = false;
+  bool toCreateAllElements = false;
   try {
     SMESH::Bnd_Dimension mode = myDlg->mode();
     QString meshName          = myDlg->needNewMesh() ? myDlg->getNewMeshName() : QString();
@@ -453,6 +453,7 @@ bool SMESHGUI_Make2DFrom3DOp::compute2DMesh( QStringList& theEntryList )
                                                                groupName.toUtf8().constData(),
                                                                meshName.toUtf8().constData(),
                                                                copyAll,
+                                                               toCreateAllElements,
                                                                groups,
                                                                newMesh.out(),
                                                                newGrp.out() );
index e000284d9658ef0bee57ad100173b5a909166263..edaa3e3d1a6b7467c77798fb8adf15fe2dac12af 100644 (file)
@@ -33,6 +33,7 @@
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
 
 class QCheckBox;
+class QGroupBox;
 class QLineEdit;
 class QRadioButton;
 class SMESHGUI_Make2DFrom3DOp;
@@ -65,6 +66,9 @@ public:
 
   bool                 copySource() const;
 
+protected:
+  QGroupBox*    myModeGrp;
+
 private slots:
   void                 onTargetChanged();
   void                 onGroupChecked();
diff --git a/src/SMESHGUI/SMESHGUI_MakeFull2DFrom3DOp.cxx b/src/SMESHGUI/SMESHGUI_MakeFull2DFrom3DOp.cxx
new file mode 100644 (file)
index 0000000..0c6119a
--- /dev/null
@@ -0,0 +1,340 @@
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File   : SMESHGUI_MakeFull2DFrom3DOp.cxx
+// Author : Cesar Conopoima, Open CASCADE S.A.S. (cesar.conopoima@opencascade.com)
+
+#include "SMESHGUI_MakeFull2DFrom3DOp.h"
+
+#include "SMESHGUI.h"
+#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_MeshUtils.h"
+#include "SMESH_TypeFilter.hxx"
+#include "SMESH_LogicalFilter.hxx"
+#include "SMESHGUI_VTKUtils.h"
+#include "SMESH_Actor.h"
+
+// SALOME GUI includes
+#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_UpdateFlags.h>
+#include <SALOME_ListIO.hxx>
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_OverrideCursor.h>
+#include <SUIT_Session.h>
+#include <SVTK_ViewModel.h>
+//#include <SVTK_ViewWindow.h>
+#include <SalomeApp_Study.h>
+#include <SalomeApp_Tools.h>
+
+// IDL includes
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
+// Qt includes
+#include <QGroupBox>
+
+#include <Standard_ErrorHandler.hxx>
+
+/*!
+  \class SMESHGUI_Make2DFrom3DDlg
+  \brief Copy Mesh dialog box
+*/
+
+SMESHGUI_MakeFull2DFrom3DDlg::SMESHGUI_MakeFull2DFrom3DDlg( QWidget* parent )
+  : SMESHGUI_Make2DFrom3DDlg( parent )
+{
+  // title
+  setWindowTitle( tr("CAPTION") );
+  myModeGrp->setVisible(false);
+}
+
+SMESHGUI_MakeFull2DFrom3DDlg::~SMESHGUI_MakeFull2DFrom3DDlg()
+{
+}
+
+
+/*!
+  \class SMESHGUI_MakeFull2DFrom3DOp
+  \brief Copy Mesh operation class
+*/
+SMESHGUI_MakeFull2DFrom3DOp::SMESHGUI_MakeFull2DFrom3DOp()
+   : SMESHGUI_SelectionOp(),
+    myMeshFilter(SMESH::MESH),
+    myGroupFilter(SMESH::GROUP)
+{
+}
+
+SMESHGUI_MakeFull2DFrom3DOp::~SMESHGUI_MakeFull2DFrom3DOp()
+{
+}
+
+LightApp_Dialog* SMESHGUI_MakeFull2DFrom3DOp::dlg() const
+{
+  return myDlg;
+}
+
+void SMESHGUI_MakeFull2DFrom3DOp::startOperation()
+{
+  if( !myDlg )
+    myDlg = new SMESHGUI_MakeFull2DFrom3DDlg( desktop() );
+
+
+  myHelpFileName = "make_2dmesh_from_3d_elements.html";
+
+  SMESHGUI_SelectionOp::startOperation();
+
+  myDlg->setNewMeshName( SMESH::UniqueName( "Mesh_1" ) );
+  myDlg->setGroupName( SMESH::UniqueName( "Group" ) );
+  myDlg->show();
+
+  myDlg->activateObject( SMESHGUI_MakeFull2DFrom3DDlg::MeshOrGroups );
+  selectionDone();
+}
+
+void SMESHGUI_MakeFull2DFrom3DOp::selectionDone()
+{
+  myDlg->clearSelection( SMESHGUI_MakeFull2DFrom3DDlg::MeshOrGroups );
+  mySrcMesh = SMESH::SMESH_Mesh::_nil();
+
+  if ( !dlg() ) return;
+  if ( dlg()->isVisible() ) {
+    try {
+      QStringList names, ids;
+      LightApp_Dialog::TypesList types;
+      selected( names, types, ids );
+      for ( int i = 0; i < names.count(); ++i )
+        names[i] = names[i].trimmed();
+      myDlg->selectObject( names, types, ids );
+
+      // enable/desable "new mesh" button
+      bool isMesh = true;
+      for ( int i = 0; i < ids.count() && isMesh; ++i )
+      {
+        _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( ids[i].toUtf8().constData() );
+        mySrcMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( sobj );  
+      }
+      myDlg->setNewMeshEnabled( isMesh );
+    }
+    catch ( const SALOME::SALOME_Exception& S_ex ) {
+      SalomeApp_Tools::QtCatchCorbaException( S_ex );
+    }
+    catch ( ... ) {
+    }
+  }
+}
+
+SUIT_SelectionFilter* SMESHGUI_MakeFull2DFrom3DOp::createFilter( const int /*theId*/ ) const
+{
+  SMESHGUI_MakeFull2DFrom3DOp* me = (SMESHGUI_MakeFull2DFrom3DOp*) this;
+
+  QList<SUIT_SelectionFilter*> subFilters;
+  subFilters.append( & me->myMeshFilter );
+  subFilters.append( & me->myGroupFilter );
+
+  SUIT_SelectionFilter* f = new SMESH_LogicalFilter( subFilters, SMESH_LogicalFilter::LO_OR );
+  return f;
+}
+
+bool SMESHGUI_MakeFull2DFrom3DOp::isValid( QString& msg ) const
+{
+  if ( !dlg() ) return false;
+  
+  // check if a mesh is selected
+  if ( !myDlg->hasSelection( SMESHGUI_MakeFull2DFrom3DDlg::MeshOrGroups ))
+  {
+    msg = tr( "SMESH_ERR_NO_INPUT_MESH" );
+    return false;
+  }
+
+  QStringList entries;
+  dlg()->selectedObject( SMESHGUI_MakeFull2DFrom3DDlg::MeshOrGroups, entries );
+  const bool isMeshSelected = ( !mySrcMesh->_is_nil() );
+  if ( isMeshSelected )
+  {
+    // only one mesh is allowed
+    if ( entries.size() > 1 ) {
+      msg = tr( "SMESH_TOO_MANY_MESHES" );
+      return false;
+    }
+  }
+  else
+  {
+    // check if only groups are selected
+    for ( int i = 0; i < entries.count(); ++i )
+    {
+      SMESH::SMESH_GroupBase_var grp;
+      if ( _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entries[i].toUtf8().constData() ))
+        grp = SMESH::SObjectToInterface<SMESH::SMESH_GroupBase>( sobj );
+      if ( grp->_is_nil() ) {
+        msg = tr( "SMESH_NOT_ONLY_GROUPS" );
+        return false;
+      }
+    }
+  }
+  // check if the selected objects contains elements of required type
+  bool hasVolumes = false;
+  
+  for ( int i = 0; i < entries.count(); ++i )
+  {
+    SMESH::SMESH_IDSource_var idSource;
+    if ( _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entries[i].toUtf8().constData() ))
+      idSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( sobj );
+    if ( !idSource->_is_nil() ) {
+      SMESH::array_of_ElementType_var types = idSource->GetTypes();
+      for ( int j = 0; j < (int) types->length(); ++j )
+        if ( types[j] == SMESH::VOLUME )
+          hasVolumes = true;
+    }
+  }
+  if ( !hasVolumes ) {
+    msg = tr( "SMESH_ERR_NO_3D_ELEMENTS" );
+    return false;
+  } 
+
+  // check if new mesh name is specified
+  if ( myDlg->needNewMesh() && myDlg->getNewMeshName().isEmpty() ) {
+    msg = tr( "SMESH_ERR_MESH_NAME_NOT_SPECIFIED" );
+    return false;
+  }
+
+  // check if group name is specified
+  if ( myDlg->needGroup() && myDlg->getGroupName().isEmpty() ) {
+    msg = tr( "SMESH_ERR_GRP_NAME_NOT_SPECIFIED" );
+    return false;
+  }
+
+  return true;
+}
+
+bool SMESHGUI_MakeFull2DFrom3DOp::compute2DMesh( QStringList& theEntryList )
+{
+  SUIT_OverrideCursor wc;
+
+  bool ok = false;
+  try {
+    QString meshName          = myDlg->needNewMesh() ? myDlg->getNewMeshName() : QString();
+    QString groupName         = myDlg->needGroup()   ? myDlg->getGroupName()   : QString();
+    bool copyAll              = myDlg->copySource();
+
+    QStringList entries;
+    dlg()->selectedObject( SMESHGUI_MakeFull2DFrom3DDlg::MeshOrGroups, entries );
+    SMESH::ListOfIDSources_var groups = new SMESH::ListOfIDSources;
+    QString wrongGroups = "";
+
+    if ( mySrcMesh->_is_nil() ) // get selected groups, find groups of wrong type
+    {
+      int nbGroups = 0;      
+      groups->length( entries.count() );
+      for ( int i = 0; i < entries.count(); ++i )
+      {
+        _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entries[i].toUtf8().constData() );
+        SMESH::SMESH_IDSource_var grp = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( sobj );  
+        SMESH::array_of_ElementType_var types = grp->GetTypes();
+        if ( types->length() < 1 || types[0] != SMESH::VOLUME )
+        {
+          if ( !wrongGroups.isEmpty() )
+            wrongGroups += ", ";
+          wrongGroups += sobj->GetName().c_str();
+        }
+        else
+        {
+          groups[ nbGroups++ ] = grp;
+        }
+      }
+      groups->length( nbGroups );
+      mySrcMesh = groups[0]->GetMesh();
+    }
+
+    if ( !CORBA::is_nil( mySrcMesh ) ) {
+      SMESH::SMESH_MeshEditor_var aMeshEditor = mySrcMesh->GetMeshEditor();
+      SMESH::SMESH_Group_var newGrp;
+      SMESH::SMESH_Mesh_var newMesh;
+      CORBA::Long nbAdded = aMeshEditor->MakeBoundaryElements( SMESH::BND_2DFROM3D,
+                                                               groupName.toUtf8().constData(),
+                                                               meshName.toUtf8().constData(),
+                                                               copyAll,
+                                                               true,
+                                                               groups,
+                                                               newMesh.out(),
+                                                               newGrp.out() );
+      QString msg = tr("NB_ADDED").arg( nbAdded );
+      if ( !wrongGroups.isEmpty() )
+        msg += ".\n" + tr("WRONG_GROUPS").arg( wrongGroups );
+      SUIT_MessageBox::information( myDlg, tr("SMESH_INFORMATION"), msg);
+
+      if ( !newMesh->_is_nil() ) {
+        if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
+          theEntryList.append( aSObject->GetID().c_str() );
+      }
+      ok = true;
+
+      for ( int i = 0; i < entries.count(); ++i )
+        if ( SMESH_Actor* actor = SMESH::FindActorByEntry( entries[i].toUtf8().constData() ))
+        {
+          actor->SetEntityMode( actor->GetEntityMode() | SMESH_Actor::eFaces );
+          SMESH::Update( actor->getIO(), actor->GetVisibility() );
+        }
+      SMESH::RepaintCurrentView();
+    }
+  }
+  catch ( ... ) {
+  }
+  return ok;
+}
+
+bool SMESHGUI_MakeFull2DFrom3DOp::onApply()
+{
+  if ( SMESHGUI::isStudyLocked() )
+    return false;
+
+  QString msg;
+  if ( !isValid( msg ) ) {
+    dlg()->show();
+    if ( msg != "" )
+      SUIT_MessageBox::warning( myDlg, tr( "SMESH_ERROR" ), msg );
+    return false;
+  }
+
+  QStringList anEntryList;
+  bool res = false;
+  try {
+    res = compute2DMesh( anEntryList );
+  }
+  catch ( const SALOME::SALOME_Exception& S_ex ) {
+    SalomeApp_Tools::QtCatchCorbaException( S_ex );
+  }
+  catch ( ... ) {
+  }
+
+  if ( res ) {
+    SMESHGUI::Modified();
+    update( UF_ObjBrowser | UF_Model );
+    if( LightApp_Application* anApp =
+        dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+      anApp->browseObjects( anEntryList, isApplyAndClose() );
+    myDlg->setNewMeshName( SMESH::UniqueName( "Mesh_1" ) );
+    myDlg->setGroupName( SMESH::UniqueName( "Group" ) );
+  }
+  else {
+    SUIT_MessageBox::warning( myDlg, tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ) );
+  }
+
+  return res;
+}
diff --git a/src/SMESHGUI/SMESHGUI_MakeFull2DFrom3DOp.h b/src/SMESHGUI/SMESHGUI_MakeFull2DFrom3DOp.h
new file mode 100644 (file)
index 0000000..8660380
--- /dev/null
@@ -0,0 +1,77 @@
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File   : SMESHGUI_MakeFull2DFrom3DOp.h
+// Author : Cesar Conopoima, Open CASCADE S.A.S. (cesar.conopoima@opencascade.com)
+
+#ifndef SMESHGUI_MakeFull2DFrom3DOp_H
+#define SMESHGUI_MakeFull2DFrom3DOp_H
+
+// SMESH includes
+#include "SMESHGUI_Make2DFrom3DOp.h"
+
+/*!
+ * \brief Dialog for options of generating 2D mesh from 3D.
+ */
+
+class SMESHGUI_EXPORT SMESHGUI_MakeFull2DFrom3DDlg :  public SMESHGUI_Make2DFrom3DDlg
+{
+  Q_OBJECT
+
+public:
+  SMESHGUI_MakeFull2DFrom3DDlg( QWidget* );
+  virtual ~SMESHGUI_MakeFull2DFrom3DDlg();
+
+  friend class SMESHGUI_MakeFull2DFrom3DOp;
+};
+
+/*!
+ * \brief Operation to compute 2D mesh from 3D mesh
+ */
+
+class SMESHGUI_EXPORT SMESHGUI_MakeFull2DFrom3DOp : public SMESHGUI_SelectionOp
+{
+  Q_OBJECT
+
+public:
+  SMESHGUI_MakeFull2DFrom3DOp();
+  virtual ~SMESHGUI_MakeFull2DFrom3DOp();
+
+  virtual LightApp_Dialog*           dlg() const;
+
+protected:
+  virtual void                       startOperation();
+  virtual void                       selectionDone();
+  virtual SUIT_SelectionFilter*      createFilter( const int ) const;
+  bool                               isValid( QString& ) const;
+
+protected slots:
+  virtual bool                       onApply();
+
+private:
+  bool                               compute2DMesh( QStringList& );
+
+private:
+  SMESH::SMESH_Mesh_var              mySrcMesh;
+  QPointer<SMESHGUI_MakeFull2DFrom3DDlg> myDlg;
+
+  SMESH_TypeFilter                   myMeshFilter;
+  SMESH_TypeFilter                   myGroupFilter;
+};
+
+#endif // SMESHGUI_MakeFull2DFrom3DOp_H
index ca7d9202de05bf0f23571a052b71a483b9c39b34..d34cc799ae396c37953aa350432580342e989fb3 100644 (file)
@@ -188,6 +188,8 @@ namespace SMESHOp {
     OpSplitEdgeInteract      = 4517,   // MENU MODIFICATION - INTERACTIVE ADD NODE ON EDGE
     OpSplitFaceInteract      = 4518,   // MENU MODIFICATION - INTERACTIVE ADD NODE ON FACE
     OpCreateDualMesh         = 4519,   // MENU MODIFICATION - CREATE DUAL MESH
+    OpCreate2DElements       = 4520,   // MENU MODIFICATION - CREATE 2D MESH FROM 3D MESH
+
     // Adaptation ---------------------//--------------------------------
     OpMGAdapt                = 8020,   // MENU ADAPTATION - MG-ADAPT
     OpHomardAdapt            = 8021,   // MENU ADAPTATION - HOMARD-ADAPT
index 4bc52c55ee385e367523da58058ffb7419846b5a..57631362b625410a2eda42281c835d76808e92ca 100644 (file)
             <source>ICON_2D_FROM_3D</source>
             <translation>mesh_2d_from_3d.png</translation>
         </message>
+        <message>
+            <source>ICON_2D_FROM_3D_ELEMENTS</source>
+            <translation>mesh_2d_from_3d_elements.png</translation>
+        </message>
         <message>
             <source>ICON_SPLIT_TO_TETRA</source>
             <translation>split_into_tetra.png</translation>
index 0847804936bcb8b8cb0ce8560f131f6a46a9be50..48c73b054a70788b004922d6bb29d646e00d703e 100644 (file)
         <source>MEN_2D_FROM_3D</source>
         <translation>Create boundary elements</translation>
     </message>
+    <message>
+        <source>MEN_2D_FROM_3D_ELEMENTS</source>
+        <translation>Create 2D mesh from 3D elements</translation>
+    </message>
     <message>
         <source>MEN_MESH_ORDER</source>
         <translation>Change sub-mesh priority</translation>
@@ -3380,6 +3384,10 @@ Use Display Entity menu command to show them.
         <source>STB_2D_FROM_3D</source>
         <translation>Create boundary elements</translation>
     </message>
+    <message>
+        <source>STB_2D_FROM_3D_ELEMENTS</source>
+        <translation>Create 2D mesh from 3D elements</translation>
+    </message>
     <message>
         <source>STB_MESH_ORDER</source>
         <translation>Change sub-mesh priority</translation>
@@ -4108,6 +4116,10 @@ Use Display Entity menu command to show them.
         <source>TOP_2D_FROM_3D</source>
         <translation>Create boundary elements</translation>
     </message>
+    <message>
+        <source>TOP_2D_FROM_3D_ELEMENTS</source>
+        <translation>Create 2D mesh from 3D elements</translation>
+    </message>
     <message>
         <source>TOP_MESH_ORDER</source>
         <translation>Change sub-mesh priority</translation>
@@ -7904,6 +7916,17 @@ It is impossible to read point coordinates from file</translation>
         <translation>Generate</translation>
     </message>
 </context>
+<context>
+    <name>SMESHGUI_MakeFull2DFrom3DDlg</name>
+    <message>
+        <source>CAPTION</source>
+        <translation>Create 2D mesh from 3D elements</translation>
+    </message>
+    <message>
+        <source>2D_FROM_3D_ELEMENTS</source>
+        <translation>2D from 3D</translation>
+    </message>
+</context>    
 <context>
     <name>SMESHGUI_Make2DFrom3DDlg</name>
     <message>
@@ -7955,6 +7978,43 @@ It is impossible to read point coordinates from file</translation>
         <translation>Create group</translation>
     </message>
 </context>
+<context>
+    <name>SMESHGUI_MakeFull2DFrom3DOp</name>
+    <message>
+        <source>NB_ADDED</source>
+        <translation>%1 boundary elements have been added</translation>
+    </message>
+    <message>
+        <source>WRONG_GROUPS</source>
+        <translation>The following groups have not been processed
+as they are of improper type:
+%1</translation>
+    </message>
+    <message>
+        <source>SMESH_ERR_NO_INPUT_MESH</source>
+        <translation>Source mesh is not specified</translation>
+    </message>
+    <message>
+        <source>SMESH_TOO_MANY_MESHES</source>
+        <translation>Only one mesh can be processed at once</translation>
+    </message>
+    <message>
+        <source>SMESH_NOT_ONLY_GROUPS</source>
+        <translation>Can&apos;t process meshes and groups at once</translation>
+    </message>
+    <message>
+        <source>SMESH_ERR_NO_3D_ELEMENTS</source>
+        <translation>The source objects do not contain 3D elements</translation>
+    </message>
+    <message>
+        <source>SMESH_ERR_MESH_NAME_NOT_SPECIFIED</source>
+        <translation>New mesh name is not specified</translation>
+    </message>
+    <message>
+        <source>SMESH_ERR_GRP_NAME_NOT_SPECIFIED</source>
+        <translation>Group name is not specified</translation>
+    </message>
+</context>
 <context>
     <name>SMESHGUI_Make2DFrom3DOp</name>
     <message>
index 01a861c32ec098f18d2a2fb89cac8020195b3096..96818910a04de0586074711d967aa35f206645db 100644 (file)
         <source>MEN_2D_FROM_3D</source>
         <translation>Créer les éléments de frontière</translation>
     </message>
+    <message>
+        <source>MEN_2D_FROM_3D_ELEMENTS</source>
+        <translation>Créer les faces des éléments volumiques</translation>
+    </message>
     <message>
         <source>MEN_MESH_ORDER</source>
         <translation>Changer la priorité des sous-maillages</translation>
@@ -3379,6 +3383,10 @@ Utilisez le menu &quot;Visualiser une entité&quot; pour les afficher.
         <source>STB_2D_FROM_3D</source>
         <translation>Créer les éléments de frontière</translation>
     </message>
+    <message>
+        <source>STB_2D_FROM_3D_ELEMENTS</source>
+        <translation>Créer les faces des éléments volumiques</translation>
+    </message>
     <message>
         <source>STB_MESH_ORDER</source>
         <translation>Changer la priorité des sous-maillages</translation>
@@ -4107,6 +4115,10 @@ Utilisez le menu &quot;Visualiser une entité&quot; pour les afficher.
         <source>TOP_2D_FROM_3D</source>
         <translation>Créer les éléments de frontière</translation>
     </message>
+    <message>
+        <source>TOP_2D_FROM_3D_ELEMENTS</source>
+        <translation>Créer les faces des éléments volumiques</translation>
+    </message>
     <message>
         <source>TOP_MESH_ORDER</source>
         <translation>Changer la priorité des sous-maillages</translation>
@@ -7930,6 +7942,17 @@ Il y a trop peu de points dans le fichier </translation>
         <translation>Génerer</translation>
     </message>
 </context>
+<context>
+    <name>SMESHGUI_MakeFull2DFrom3DDlg</name>
+    <message>
+        <source>CAPTION</source>
+        <translation>Créer les faces des éléments volumiques</translation>
+    </message>
+    <message>
+        <source>2D_FROM_3D_ELEMENTS</source>
+        <translation>Faces des éléments volumiques</translation>
+    </message>
+</context> 
 <context>
     <name>SMESHGUI_Make2DFrom3DDlg</name>
     <message>
@@ -7981,6 +8004,43 @@ Il y a trop peu de points dans le fichier </translation>
         <translation>Créer un groupe</translation>
     </message>
 </context>
+<context>
+    <name>SMESHGUI_MakeFull2DFrom3DOp</name>
+    <message>
+        <source>NB_ADDED</source>
+        <translation>%1 faces ont été ajoutés</translation>
+    </message>
+    <message>
+    <source>WRONG_GROUPS</source>
+    <translation>Les groupes suivants n'ont pas été traités
+en raison de leurs types incompatibles:
+%1</translation>
+    </message>
+    <message>
+        <source>SMESH_ERR_NO_INPUT_MESH</source>
+        <translation>Aucun maillage, sous-maillage ou groupe source n'est indiqué</translation>
+    </message>
+    <message>
+        <source>SMESH_TOO_MANY_MESHES</source>
+        <translation>Un seul maillage à la fois peut être traité</translation>
+    </message>
+    <message>
+        <source>SMESH_NOT_ONLY_GROUPS</source>
+        <translation>Impossible de traiter à la fois des maillages et des groupes</translation>
+    </message>
+    <message>
+        <source>SMESH_ERR_NO_3D_ELEMENTS</source>
+        <translation>L'objet source ne contient pas d'éléments 3D</translation>
+    </message>
+    <message>
+        <source>SMESH_ERR_MESH_NAME_NOT_SPECIFIED</source>
+        <translation>Le nom du nouveau maillage n'est pas indiqué</translation>
+    </message>
+    <message>
+        <source>SMESH_ERR_GRP_NAME_NOT_SPECIFIED</source>
+        <translation>Le nom du groupe n'est pas indiqué</translation>
+    </message>
+</context>
 <context>
     <name>SMESHGUI_Make2DFrom3DOp</name>
     <message>
index f35798fffe9b2ce80556b68a2645c6616a4bfdc2..a45b96abf643367551b20be08bead4603a26131a 100644 (file)
@@ -765,7 +765,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
       meshID = aCommand->GetResultValue();
     else if ( method == "MakeBoundaryMesh")
       meshID = aCommand->GetResultValue(1);
-    else if ( method == "MakeBoundaryElements")
+    else if ( method == "MakeBoundaryElements" || method == "MakeBoundaryOfEachElement" )
       meshID = aCommand->GetResultValue(2);
 
     if ( method.Search("MakeGroups") != -1      ||
@@ -782,7 +782,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
       groups = aCommand->GetResultValue();
     else if ( method == "MakeBoundaryMesh" )
       groups = aCommand->GetResultValue(2);
-    else if ( method == "MakeBoundaryElements")
+    else if ( method == "MakeBoundaryElements" || method == "MakeBoundaryOfEachElement" )
       groups = aCommand->GetResultValue(3);
     else if ( method == "Create0DElementsOnAllNodes" &&
               aCommand->GetArg(2).Length() > 2 ) // group name != ''
@@ -1828,7 +1828,8 @@ _pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd, const _pyID& meshId):
   }
   else if ( theCreationCmd->GetMethod().Search("MakeMesh") != -1 ||
             theCreationCmd->GetMethod() == "MakeBoundaryMesh" ||
-            theCreationCmd->GetMethod() == "MakeBoundaryElements" )
+            theCreationCmd->GetMethod() == "MakeBoundaryElements" ||
+            theCreationCmd->GetMethod() == "MakeBoundaryOfEachElement" )
   {
     // this mesh depends on a source mesh
     // (theCreationCmd is already Process()ed by _pyMeshEditor)
@@ -2521,7 +2522,7 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
       "GetLastCreatedElems", "FaceGroupsSeparatedByEdges",
       "MirrorMakeMesh","MirrorObjectMakeMesh","TranslateMakeMesh","TranslateObjectMakeMesh",
       "Scale","ScaleMakeMesh","RotateMakeMesh","RotateObjectMakeMesh","MakeBoundaryMesh",
-      "MakeBoundaryElements", "SplitVolumesIntoTetra","SplitHexahedraIntoPrisms",
+      "MakeBoundaryElements", "MakeBoundaryOfEachElement", "SplitVolumesIntoTetra","SplitHexahedraIntoPrisms",
       "DoubleElements","DoubleNodes","DoubleNode","DoubleNodeGroup","DoubleNodeGroups",
       "DoubleNodeElem","DoubleNodeElemInRegion","DoubleNodeElemGroup","AffectedElemGroupsInRegion",
       "DoubleNodeElemGroupInRegion","DoubleNodeElemGroups","DoubleNodeElemGroupsInRegion",
index ce5b66d4547b027b037afa578e42f7c8fcef69bc..952c8e0ee905a1f522a14a73b1fe953cb1f8caef 100644 (file)
@@ -7306,6 +7306,7 @@ SMESH_MeshEditor_i::MakeBoundaryMesh(SMESH::SMESH_IDSource_ptr idSource,
  *    mesh + created boundary elements; "" means not to create the new mesh
  *  \param toCopyAll - if true, the whole initial mesh will be copied into
  *    the new mesh else only boundary elements will be copied into the new mesh
+ *  \param toCreateAllElements - if true all the dim element are created from the mesh
  *  \param groups - optional groups of elements to make boundary around
  *  \param mesh - returns the mesh where elements were added to
  *  \param group - returns the created group, if any
@@ -7317,6 +7318,7 @@ CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim,
                                                      const char* groupName,
                                                      const char* meshName,
                                                      CORBA::Boolean toCopyAll,
+                                                     CORBA::Boolean toCreateAllElements,
                                                      const SMESH::ListOfIDSources& groups,
                                                      SMESH::SMESH_Mesh_out mesh,
                                                      SMESH::SMESH_Group_out group)
@@ -7354,7 +7356,7 @@ CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim,
     // process groups belonging to another mesh
     SMESH::SMESH_Mesh_var    otherMesh = groupsOfOtherMesh[0]->GetMesh();
     SMESH::SMESH_MeshEditor_var editor = otherMesh->GetMeshEditor();
-    nbAdded += editor->MakeBoundaryElements( dim, groupName, meshName, toCopyAll,
+    nbAdded += editor->MakeBoundaryElements( dim, groupName, meshName, toCopyAll, toCreateAllElements,
                                              groupsOfOtherMesh, mesh, group );
   }
 
@@ -7381,6 +7383,7 @@ CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim,
   SMESH_Mesh*     srcMesh = ( toCopyMesh && !toCopyAll ) ? myMesh : tgtMesh;
   SMESHDS_Mesh* srcMeshDS = srcMesh->GetMeshDS();
 
+
   // group of boundary elements
   SMESH_Group* smesh_group = 0;
   SMDSAbs_ElementType elemType = (dim == SMESH::BND_2DFROM3D) ? SMDSAbs_Volume : SMDSAbs_Face;
@@ -7393,7 +7396,6 @@ CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim,
   }
 
   TIDSortedElemSet elements;
-
   if ( groups.length() > 0 )
   {
     for ( int i = 0; i < nbGroups; ++i )
@@ -7410,7 +7412,8 @@ CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim,
                                                  /*toCopyElements=*/false,
                                                  /*toCopyExistingBondary=*/srcMesh != tgtMesh,
                                                  /*toAddExistingBondary=*/true,
-                                                 /*aroundElements=*/true);
+                                                 /*aroundElements=*/true,
+                                                 /*toCreateAllElements=*/toCreateAllElements);
       }
     }
   }
@@ -7422,7 +7425,8 @@ CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim,
                                              tgtMesh,
                                              /*toCopyElements=*/false,
                                              /*toCopyExistingBondary=*/srcMesh != tgtMesh,
-                                             /*toAddExistingBondary=*/true);
+                                             /*toAddExistingBondary=*/true,
+                                             /*aroundElements=*/toCreateAllElements);
   }
   tgtMesh->GetMeshDS()->Modified();
 
@@ -7437,13 +7441,21 @@ CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim,
   if ( group_var->_is_nil() )
     pyDump << "_NoneGroup = "; // assignment to None is forbidden
   else
+
     pyDump << group_var << " = ";
-  pyDump << this << ".MakeBoundaryElements( "
-         << "SMESH." << dimName[int(dim)] << ", "
-         << "'" << groupName << "', "
-         << "'" << meshName<< "', "
-         << toCopyAll << ", "
-         << groups << ")";
+  
+  if ( toCreateAllElements )
+    pyDump << this << ".MakeBoundaryOfEachElement( ";
+  else
+  {
+    pyDump << this << ".MakeBoundaryElements( "
+           << "SMESH." << dimName[int(dim)] << ", ";
+  }
+
+  pyDump<< "'" << groupName << "', "
+        << "'" << meshName<< "', "
+        << toCopyAll << ", "
+        << groups << ")";
 
   mesh  = mesh_var._retn();
   group = group_var._retn();
index ccae6d0f02cfb2d9e0a1093f5d17404ec687082a..2b01a0d47059b8b64b89e989305c62c212e59d14 100644 (file)
@@ -837,6 +837,7 @@ public:
                                    const char* groupName,
                                    const char* meshName,
                                    CORBA::Boolean toCopyAll,
+                                   CORBA::Boolean toCreateAllElements,
                                    const SMESH::ListOfIDSources& groups,
                                    SMESH::SMESH_Mesh_out mesh,
                                    SMESH::SMESH_Group_out group);
index d31be247eee5a6df4eab05be22fa92679c6de404..13d5117b9d31b72c81ea5e70fe1b472f3ef16511 100644 (file)
@@ -5465,6 +5465,32 @@ class Mesh(metaclass = MeshMeta):
         if mesh: mesh = self.smeshpyD.Mesh(mesh)
         return mesh, group
 
+    def MakeBoundaryOfEachElement(self, groupName="", meshName="", toCopyAll=False, groups=[] ):
+        """
+        Create boundary elements around the whole mesh or groups of elements
+
+        Parameters:
+                groupName: a name of group to store all boundary elements in,
+                        "" means not to create the group
+                meshName: a name of a new mesh, which is a copy of the initial
+                        mesh + created boundary elements; "" means not to create the new mesh
+                toCopyAll: if True, the whole initial mesh will be copied into
+                        the new mesh else only boundary elements will be copied into the new mesh
+                groups: list of :class:`sub-meshes, groups or filters <SMESH.SMESH_IDSource>` of elements to make boundary around
+
+        Returns:
+                tuple( long, mesh, group )
+                       - long - number of added boundary elements
+                       - mesh - the :class:`Mesh` where elements were added to
+                       - group - the :class:`group <SMESH.SMESH_Group>` of boundary elements or None
+        """
+        dimension=SMESH.BND_2DFROM3D
+        toCreateAllElements = True # create all boundary elements in the mesh
+        nb, mesh, group = self.editor.MakeBoundaryElements( dimension,groupName,meshName,
+                                                           toCopyAll,toCreateAllElements,groups)
+        if mesh: mesh = self.smeshpyD.Mesh(mesh)
+        return nb, mesh, group
+    
     def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
                              toCopyAll=False, groups=[]):
         """
@@ -5488,9 +5514,9 @@ class Mesh(metaclass = MeshMeta):
                        - mesh - the :class:`Mesh` where elements were added to
                        - group - the :class:`group <SMESH.SMESH_Group>` of boundary elements or None
         """
-
+        toCreateAllElements = False # create only elements in the boundary of the solid
         nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
-                                                           toCopyAll,groups)
+                                                           toCopyAll,toCreateAllElements,groups)
         if mesh: mesh = self.smeshpyD.Mesh(mesh)
         return nb, mesh, group