From 35c05cab652a5167972b9588db81fc4a2a9361b5 Mon Sep 17 00:00:00 2001 From: ptv Date: Thu, 10 Sep 2009 06:59:27 +0000 Subject: [PATCH] 0020105: EDF 862 SMESH : Creation of the skin elements (2D) of a 3D Mesh --- idl/SMESH_MeshEditor.idl | 7 +++++ resources/Makefile.am | 1 + resources/mesh_2d_from_3d.png | Bin 0 -> 406 bytes src/SMESH/SMESH_MeshEditor.cxx | 46 +++++++++++++++++++++++++++-- src/SMESH/SMESH_MeshEditor.hxx | 7 +++++ src/SMESHGUI/Makefile.am | 7 +++-- src/SMESHGUI/SMESHGUI.cxx | 12 ++++++++ src/SMESHGUI/SMESH_images.ts | 4 +++ src/SMESHGUI/SMESH_msg_en.ts | 19 ++++++++++++ src/SMESH_I/SMESH_MeshEditor_i.cxx | 38 ++++++++++++++++++++++++ src/SMESH_I/SMESH_MeshEditor_i.hxx | 9 +++++- src/SMESH_SWIG/smeshDC.py | 6 ++++ 12 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 resources/mesh_2d_from_3d.png diff --git a/idl/SMESH_MeshEditor.idl b/idl/SMESH_MeshEditor.idl index ab8e27b35..b077a164d 100644 --- a/idl/SMESH_MeshEditor.idl +++ b/idl/SMESH_MeshEditor.idl @@ -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(); + }; }; diff --git a/resources/Makefile.am b/resources/Makefile.am index 2ebd83edf..3fb97d2ae 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -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 index 0000000000000000000000000000000000000000..b0842d3e73e58ae3f2e20c134107040d26ef2309 GIT binary patch literal 406 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85pG3gD_*9)I=GeAbW|YuPggaPEHOH!yof}vVo?EdAc};Se#xu z*)i*ogGk%{iSrgef5CW%rRiXAntI2MGj0+#&Cd&8b5=E7@)eBAaLv*>r;?GjYsSP` zN2ZzBNmSTWe6IgrZG0%|wC=@+$9Ak1YZ2(3ux9HbH-(lBK~hUh82(HP&p&kjpqXWm z)azR@@yoY)LBMpJf`v xm)@x6ULQ62x9*xS{;g>Y4>wBH&&#S|PAz#d@x!?pzkq?p;OXk;vd$@?2>>-xsBHiM literal 0 HcmV?d00001 diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 45389c38a..31187db16 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -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 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; +} diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx index f07279bef..71855ab0c 100644 --- a/src/SMESH/SMESH_MeshEditor.hxx +++ b/src/SMESH/SMESH_MeshEditor.hxx @@ -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: /*! diff --git a/src/SMESHGUI/Makefile.am b/src/SMESHGUI/Makefile.am index 94559f098..1b278b946 100644 --- a/src/SMESHGUI/Makefile.am +++ b/src/SMESHGUI/Makefile.am @@ -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) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 26e1de4db..2190c6a3c 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -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; diff --git a/src/SMESHGUI/SMESH_images.ts b/src/SMESHGUI/SMESH_images.ts index c2569ba1a..8b455dfe0 100644 --- a/src/SMESHGUI/SMESH_images.ts +++ b/src/SMESHGUI/SMESH_images.ts @@ -445,5 +445,9 @@ ICON_UNDERLYING_ELEMS mesh_extractGroup.png + + ICON_2D_FROM_3D + mesh_2d_from_3d.png + diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index ab6fe272b..7b4f62eb6 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -201,6 +201,10 @@ MEN_CONV_TO_QUAD Convert to/from quadratic + + MEN_2D_FROM_3D + Create 2D mesh from 3D + MEN_CREATE_GROUP Create Group @@ -2043,6 +2047,10 @@ Consider saving your work before application crash STB_CONV_TO_QUAD Convert to/from quadratic + + STB_2D_FROM_3D + Create 2D mesh from 3D + STB_CREATE_GROUP Create Group @@ -2537,6 +2545,10 @@ Consider saving your work before application crash TOP_CONV_TO_QUAD Convert to/from quadratic + + TOP_2D_FROM_3D + Create 2D mesh from 3D + TOP_CREATE_GROUP Create Group @@ -3375,6 +3387,13 @@ Please specify it and try again No valid mesh object selected + + SMESHGUI_Make2DFrom3DDlg + + CAPTION + Create 2D mesh from 3D + + SMESHGUI_CreatePatternDlg diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 103e8bce9..f4e1d4420 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -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; } diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx index 69a106b99..f9b7668b1 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.hxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx @@ -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(); } diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index 4b6d76364..3128c297b 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -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):