Salome HOME
0020105: EDF 862 SMESH : Creation of the skin elements (2D) of a 3D Mesh
authorptv <ptv@opencascade.com>
Thu, 10 Sep 2009 06:59:27 +0000 (06:59 +0000)
committerptv <ptv@opencascade.com>
Thu, 10 Sep 2009 06:59:27 +0000 (06:59 +0000)
12 files changed:
idl/SMESH_MeshEditor.idl
resources/Makefile.am
resources/mesh_2d_from_3d.png [new file with mode: 0644]
src/SMESH/SMESH_MeshEditor.cxx
src/SMESH/SMESH_MeshEditor.hxx
src/SMESHGUI/Makefile.am
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESH_images.ts
src/SMESHGUI/SMESH_msg_en.ts
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.hxx
src/SMESH_SWIG/smeshDC.py

index ab8e27b35770c17a37f1e31185661468d41b7a08..b077a164d168f2e2102330831e219c6f21a267fa 100644 (file)
@@ -784,6 +784,13 @@ module SMESH
                                       in ListOfGroups theNodesNot,
                                       in GEOM::GEOM_Object theShape );
 
+    /*!
+     * \brief Generated skin mesh (containing 2D cells) from 3D mesh
+     * The created 2D mesh elements based on nodes of free faces of boundary volumes
+     * \return TRUE if operation has been completed successfully, FALSE otherwise
+     */
+    boolean Make2DMeshFrom3D();
+
   };
 };
 
index 2ebd83edff16cbd8faf46130d2563fa68c137103..3fb97d2ae91521f311c90b9aa5d283e72b7b810a 100644 (file)
@@ -165,6 +165,7 @@ dist_salomeres_DATA = \
        mesh_tree_mesh_partial.png \
        mesh_extractGroup.png \
        mesh_precompute.png \
+       mesh_2d_from_3d.png \
         mesh_free_faces.png
 
 # VSR: little trick to avoid putting if SMESHCatalog.xml to the distribution archive
diff --git a/resources/mesh_2d_from_3d.png b/resources/mesh_2d_from_3d.png
new file mode 100644 (file)
index 0000000..b0842d3
Binary files /dev/null and b/resources/mesh_2d_from_3d.png differ
index 45389c38a479694cffcf577da6f26e51a7ceeda0..31187db166df132c217b769b3557a2184aa96dad 100644 (file)
@@ -8776,9 +8776,6 @@ bool SMESH_MeshEditor::DoubleNodesInRegion( const TIDSortedElemSet& theElems,
                                             const TIDSortedElemSet& theNodesNot,
                                             const TopoDS_Shape&     theShape )
 {
-  SMESHDS_Mesh* aMesh = GetMeshDS();
-  if (!aMesh)
-    return false;
   if ( theShape.IsNull() )
     return false;
 
@@ -8813,3 +8810,46 @@ bool SMESH_MeshEditor::DoubleNodesInRegion( const TIDSortedElemSet& theElems,
   }
   return DoubleNodes( theElems, theNodesNot, anAffected );
 }
+
+/*!
+ * \brief Generated skin mesh (containing 2D cells) from 3D mesh
+ * The created 2D mesh elements based on nodes of free faces of boundary volumes
+ * \return TRUE if operation has been completed successfully, FALSE otherwise
+ */
+
+bool SMESH_MeshEditor::Make2DMeshFrom3D()
+{
+  // iterates on volume elements and detect all free faces on them
+  SMESHDS_Mesh* aMesh = GetMeshDS();
+  if (!aMesh)
+    return false;
+  bool res = false;
+  SMDS_VolumeIteratorPtr vIt = aMesh->volumesIterator();
+  while(vIt->more())
+  {
+    const SMDS_MeshVolume* volume = vIt->next();
+    SMDS_VolumeTool vTool( volume );
+    bool isPoly = volume->IsPoly();
+    for ( int iface = 0, n = vTool.NbFaces(); iface < n; iface++ )
+    {
+      if (!vTool.IsFreeFace(iface))
+        continue;
+      vector<const SMDS_MeshNode *> nodes;
+      int nbFaceNodes = vTool.NbFaceNodes(iface);
+      const SMDS_MeshNode** faceNodes = vTool.GetFaceNodes(iface);
+      if (vTool.IsFaceExternal(iface))
+        for (int inode = 0; inode < nbFaceNodes; inode++)
+          nodes.push_back(faceNodes[inode]);
+      else
+        for (int inode = nbFaceNodes - 1; inode >= 0; inode--)
+          nodes.push_back(faceNodes[inode]);
+
+      // add new face based on volume nodes
+      if (aMesh->FindFace( nodes ) )
+        continue; // face already exsist
+      myLastCreatedElems.Append( AddElement(nodes, SMDSAbs_Face, isPoly && iface == 1) );
+      res = true;
+    }
+  }
+  return res;
+}
index f07279bef4169059ebde9d7561f4d70387758c5c..71855ab0cb434b88669adbc8a142364968c70a2c 100644 (file)
@@ -610,6 +610,13 @@ public:
                             const TIDSortedElemSet& theNodesNot,
                             const TopoDS_Shape&     theShape );
 
+  /*!
+   * \brief Generated skin mesh (containing 2D cells) from 3D mesh
+   * The created 2D mesh elements based on nodes of free faces of boundary volumes
+   * \return TRUE if operation has been completed successfully, FALSE otherwise
+   */
+  bool Make2DMeshFrom3D();
+  
 private:
 
   /*!
index 94559f0989e455a833e3ba71584806e68ef411f0..1b278b946e70a226869b4b8072c4ce196139c810 100644 (file)
@@ -91,6 +91,7 @@ salomeinclude_HEADERS = \
        SMESHGUI_MeshEditPreview.h \
        SMESHGUI_IdValidator.h \
        SMESHGUI_MeshInfosBox.h \
+       SMESHGUI_Make2DFrom3DOp.h \
        SMESH_SMESHGUI.hxx
 
 # Libraries targets
@@ -159,7 +160,8 @@ dist_libSMESH_la_SOURCES = \
        SMESHGUI_MeshEditPreview.cxx \
        SMESHGUI_GroupOnShapeDlg.cxx \
        SMESHGUI_FileInfoDlg.cxx \
-       SMESHGUI_MeshInfosBox.cxx
+       SMESHGUI_MeshInfosBox.cxx \
+       SMESHGUI_Make2DFrom3DOp.cxx
 
 MOC_FILES = \
        SMESHGUI_moc.cxx \
@@ -212,7 +214,8 @@ MOC_FILES = \
        SMESHGUI_MakeNodeAtPointDlg_moc.cxx \
        SMESHGUI_GroupOnShapeDlg_moc.cxx \
        SMESHGUI_FileInfoDlg_moc.cxx \
-       SMESHGUI_MeshInfosBox_moc.cxx
+       SMESHGUI_MeshInfosBox_moc.cxx \
+       SMESHGUI_Make2DFrom3DOp_moc.cxx
 
 nodist_libSMESH_la_SOURCES= \
        $(MOC_FILES)
index 26e1de4dba9bfd21872ee9cbbb288c69c6ac6f1b..2190c6a3c127f7784200b172bcb9aff3117b73ae 100644 (file)
@@ -67,6 +67,7 @@
 #include "SMESHGUI_BuildCompoundDlg.h"
 #include "SMESHGUI_ComputeDlg.h"
 #include "SMESHGUI_FileInfoDlg.h"
+#include "SMESHGUI_Make2DFrom3DOp.h"
 
 #include "SMESHGUI_Utils.h"
 #include "SMESHGUI_MeshUtils.h"
@@ -1773,6 +1774,11 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
                               }*/
       break;
     }
+  case 418: // create 2D mesh from 3D
+    {
+      startOperation( 418 );
+      break;
+    }
   case 806:                                     // CREATE GEO GROUP
     {
       startOperation( 806 );
@@ -2768,6 +2774,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction(  415, "MAP",             "ICON_MAP" );
   createSMESHAction(  416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
   createSMESHAction(  417, "CONV_TO_QUAD",    "ICON_CONV_TO_QUAD" );
+  createSMESHAction(  418, "2D_FROM_3D",      "ICON_2D_FROM_3D" );
   createSMESHAction(  200, "RESET" );
   createSMESHAction(  201, "SCALAR_BAR_PROP" );
   createSMESHAction(  211, "WIRE",           "ICON_WIRE", 0, true );
@@ -2937,6 +2944,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( 414, modifyId, -1 );
   createMenu( 415, modifyId, -1 );
   createMenu( 417, modifyId, -1 );
+  createMenu( 418, modifyId, -1 );
 
   createMenu( 214, viewId, -1 );
 
@@ -3033,6 +3041,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( 414, modifyTb );
   createTool( 415, modifyTb );
   createTool( 417, modifyTb );
+  createTool( 418, modifyTb );
 
   createTool( 214, dispModeTb );
 
@@ -3900,6 +3909,9 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
     case 417: //convert to quadratic
       op = new SMESHGUI_ConvToQuadOp();
     break;
+    case 418: // create 2D mesh as boundary on 3D
+      op = new SMESHGUI_Make2DFrom3DOp();
+    break;
     case 4067: // make mesh pass through point
       op = new SMESHGUI_MakeNodeAtPointOp();
       break;
index c2569ba1aa7a1cb4472ff961812bd1471fa05c7a..8b455dfe0e7bebb9f8ad896a519dc0ac1607b098 100644 (file)
             <source>ICON_UNDERLYING_ELEMS</source>
             <translation>mesh_extractGroup.png</translation>
         </message>
+        <message>
+            <source>ICON_2D_FROM_3D</source>
+            <translation>mesh_2d_from_3d.png</translation>
+        </message>
     </context>
 </TS>
index ab6fe272be1b5667831db0d566c04fdd413d75d8..7b4f62eb6ab71b31799e9c3aa500757d04bf7cb8 100644 (file)
             <source>MEN_CONV_TO_QUAD</source>
             <translation>Convert to/from quadratic</translation>
         </message>
+        <message>
+            <source>MEN_2D_FROM_3D</source>
+            <translation>Create 2D mesh from 3D</translation>
+        </message>
         <message>
             <source>MEN_CREATE_GROUP</source>
             <translation>Create Group</translation>
@@ -2043,6 +2047,10 @@ Consider saving your work before application crash</translation>
             <source>STB_CONV_TO_QUAD</source>
             <translation>Convert to/from quadratic</translation>
         </message>
+        <message>
+            <source>STB_2D_FROM_3D</source>
+            <translation>Create 2D mesh from 3D</translation>
+        </message>
         <message>
             <source>STB_CREATE_GROUP</source>
             <translation>Create Group</translation>
@@ -2537,6 +2545,10 @@ Consider saving your work before application crash</translation>
             <source>TOP_CONV_TO_QUAD</source>
             <translation>Convert to/from quadratic</translation>
         </message>
+        <message>
+            <source>TOP_2D_FROM_3D</source>
+            <translation>Create 2D mesh from 3D</translation>
+        </message>
         <message>
             <source>TOP_CREATE_GROUP</source>
             <translation>Create Group</translation>
@@ -3375,6 +3387,13 @@ Please specify it and try again</translation>
             <translation>No valid mesh object selected</translation>
         </message>
     </context>
+    <context>
+        <name>SMESHGUI_Make2DFrom3DDlg</name>
+        <message>
+            <source>CAPTION</source>
+            <translation>Create 2D mesh from 3D</translation>
+        </message>
+    </context>
     <context>
         <name>SMESHGUI_CreatePatternDlg</name>
         <message>
index 103e8bce9235e8e7d4ad81b1c7945b1de472c1fc..f4e1d4420f4826a251f782476403eaa46240a8db 100644 (file)
@@ -4245,6 +4245,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodes( const SMESH::long_array& theElem
 
   storeResult( aMeshEditor) ;
 
+  // Update Python script
+  TPythonDump() << "isDone = " << this << ".DoubleNodes( " << theElems << ", "
+    << theNodesNot << ", " << theAffectedElems << " )";
   return aResult;
 }
 
@@ -4282,6 +4285,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesInRegion
 
   storeResult( aMeshEditor) ;
 
+  // Update Python script
+  TPythonDump() << "isDone = " << this << ".DoubleNodesInRegion( " << theElems << ", "
+    << theNodesNot << ", " << theShape << " )";
   return aResult;
 }
 
@@ -4332,6 +4338,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroup(
 
   storeResult( aMeshEditor) ;
 
+  // Update Python script
+  TPythonDump() << "isDone = " << this << ".DoubleNodeGroup( " << theElems << ", "
+    << theNodesNot << ", " << theAffectedElems << " )";
   return aResult;
 }
 
@@ -4371,6 +4380,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroupInRegion(
 
   storeResult( aMeshEditor) ;
 
+  // Update Python script
+  TPythonDump() << "isDone = " << this << ".DoubleNodeGroupInRegion( " << theElems << ", "
+    << theNodesNot << ", " << theShape << " )";
   return aResult;
 }
 
@@ -4423,6 +4435,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroups(
 
   storeResult( aMeshEditor) ;
 
+  // Update Python script
+  TPythonDump() << "isDone = " << this << ".DoubleNodeGroups( " << &theElems << ", "
+    << &theNodesNot << ", " << &theAffectedElems << " )";
   return aResult;
 }
 
@@ -4459,5 +4474,28 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroupsInRegion(
 
   storeResult( aMeshEditor) ;
 
+  // Update Python script
+  TPythonDump() << "isDone = " << this << ".DoubleNodeGroupsInRegion( " << &theElems << ", "
+    << &theNodesNot << ", " << theShape << " )";
+  return aResult;
+}
+
+//================================================================================
+/*!
+  \brief Generated skin mesh (containing 2D cells) from 3D mesh
+   The created 2D mesh elements based on nodes of free faces of boundary volumes
+  \return TRUE if operation has been completed successfully, FALSE otherwise
+*/
+//================================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::Make2DMeshFrom3D()
+{
+  initData();
+
+  ::SMESH_MeshEditor aMeshEditor( myMesh );
+  bool aResult = aMeshEditor.Make2DMeshFrom3D();
+  storeResult( aMeshEditor) ;
+  
+  TPythonDump() << "isDone = " << this << ".Make2DMeshFrom3D()";
   return aResult;
 }
index 69a106b99351c6bb500e5d68634ae4a72e0ee039..f9b7668b16119752110dd49e55eb995a9d42c886 100644 (file)
@@ -601,7 +601,14 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
                                            const SMESH::ListOfGroups& theNodesNot,
                                            GEOM::GEOM_Object_ptr      theShape );
 
-private: //!< private methods
+    /*!
+     * \brief Generated skin mesh (containing 2D cells) from 3D mesh
+     * The created 2D mesh elements based on nodes of free faces of boundary volumes
+     * \return TRUE if operation has been completed successfully, FALSE otherwise
+    */
+    CORBA::Boolean Make2DMeshFrom3D();
+
+ private: //!< private methods
 
   SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
 
index 4b6d763647618a05828e72fa70a220384441163d..3128c297b4245fdd2d66dcb6baa5e080553d2cd2 100644 (file)
@@ -2512,6 +2512,12 @@ class Mesh:
     def ConvertFromQuadratic(self):
         return self.editor.ConvertFromQuadratic()
 
+    ## Creates 2D mesh as skin on boundary faces of a 3D mesh
+    #  @return TRUE if operation has been completed successfully, FALSE otherwise
+    #  @ingroup l2_modif_edit
+    def  Make2DMeshFrom3D(self):
+        return self.editor. Make2DMeshFrom3D()
+        
     ## Renumber mesh nodes
     #  @ingroup l2_modif_renumber
     def RenumberNodes(self):