Salome HOME
Merge branch 'V9_11_BR'
authorjfa <jfa@opencascade.com>
Wed, 19 Jul 2023 15:38:00 +0000 (16:38 +0100)
committerjfa <jfa@opencascade.com>
Wed, 19 Jul 2023 15:38:00 +0000 (16:38 +0100)
doc/examples/create_dual_mesh.py
src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx
src/SMESHGUI/SMESHGUI_HypothesesUtils.h
src/SMESHGUI/SMESHGUI_MeshOp.cxx
src/SMESHGUI/SMESHGUI_MeshOp.h
src/SMESH_SWIG/smesh_tools.py

index d65e9bd16f1273ab759c4a1f572f065ef538d4f8..97d827a9a7d78c1d2af027cc47e4662a4cef2ec0 100644 (file)
@@ -48,11 +48,17 @@ isDone = Mesh_1.Compute()
 if not isDone:
   raise Exception("Error when computing Mesh")
 
-# Creating Dual mesh
+# Creating Dual mesh with projection on shape
 dual_Mesh_1 = smesh.CreateDualMesh( Mesh_1, 'dual_Mesh_1', True)
 
 assert(dual_Mesh_1.NbPolyhedrons() > 0)
 assert(dual_Mesh_1.NbTetras() == 0)
 
+# Creating Dual mesh withour projection on shape
+dual_Mesh_2 = smesh.CreateDualMesh( Mesh_1, 'dual_Mesh_2', False)
+
+assert(dual_Mesh_2.NbPolyhedrons() > 0)
+assert(dual_Mesh_2.NbTetras() == 0)
+
 if salome.sg.hasDesktop():
   salome.sg.updateObjBrowser()
index eeabfd29dde084d5dd06f30bf2be637adc95ac9c..a86dddff212e3fb8e3f5af2b499c288982195080 100644 (file)
@@ -645,6 +645,7 @@ namespace SMESH
       try {
         CORBA::String_var error;
         res = aMesh->AddHypothesis(aShapeObject, aHyp, error.out());
+        UpdateViewer(aMesh);
         if (res > SMESH::HYP_OK) {
           wc.suspend();
           processHypothesisStatus(res, aHyp, true, error.in() );
@@ -676,6 +677,7 @@ namespace SMESH
         {
           CORBA::String_var error;
           res = aMesh->AddHypothesis( aShapeObject, aHyp, error.out() );
+          UpdateViewer(aMesh);
           if (res > SMESH::HYP_OK) {
             wc.suspend();
             processHypothesisStatus( res, aHyp, true, error.in() );
@@ -764,12 +766,7 @@ namespace SMESH
             processHypothesisStatus(res, anHyp, false);
             wc.resume();
           }
-          if ( _PTR(SObject) meshSO = SMESH::FindSObject(aMesh) )
-          {
-            if ( SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() ))
-              if( actor->GetVisibility() )
-                actor->Update();
-          }
+          UpdateViewer(aMesh);
         }
       } catch(const SALOME::SALOME_Exception& S_ex) {
         wc.suspend();
@@ -778,6 +775,16 @@ namespace SMESH
       }
     }
     return res < SMESH::HYP_UNKNOWN_FATAL;
+  } 
+
+  void UpdateViewer(SMESH::SMESH_Mesh_ptr theMesh)
+  {
+    if (_PTR(SObject) meshSO = SMESH::FindSObject(theMesh))
+    {
+      if (SMESH_Actor* actor = SMESH::FindActorByEntry(meshSO->GetID().c_str()))
+        if (actor->GetVisibility())
+          actor->Update();
+    }
   }
 
   SObjectList GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp)
index 8e98e28761fe1c34c1992e569998b076709b3ce9..20d7eccc6b7b94062d4d63ed78fab6dec7bbf211 100644 (file)
@@ -115,6 +115,8 @@ namespace SMESH
   bool RemoveHypothesisOrAlgorithmOnMesh( _PTR(SObject),
                                           SMESH::SMESH_Hypothesis_ptr );
 
+  SMESHGUI_EXPORT void UpdateViewer(SMESH::SMESH_Mesh_ptr);
+
   typedef std::vector<_PTR(SObject)> SObjectList;
   SMESHGUI_EXPORT
   SObjectList GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr );
index d1b4b6cce9c1629c51011bc471e8766608beafc4..95b51a474ac0d372bf6d7610f553a7838f08b165 100644 (file)
@@ -158,7 +158,7 @@ bool SMESHGUI_MeshOp::onApply()
     if (( myToCreate && !myIsMesh ) || myIsInvalidSubMesh )
       aResult = createSubMesh( aMess, anEntryList );
     else if ( !myToCreate )
-      aResult = editMeshOrSubMesh( aMess );
+      aResult = editMeshOrSubMesh( aMess, anEntryList );
     if ( aResult )
     {
       SMESHGUI::Modified();
@@ -2577,13 +2577,14 @@ int SMESHGUI_MeshOp::find( const SMESH::SMESH_Hypothesis_var& theHyp,
 //================================================================================
 /*!
  * \brief Edits mesh or sub-mesh
-  * \param theMess - Output parameter intended for returning error message
-  * \retval bool  - TRUE if mesh is edited successfully, FALSE otherwise
+  * \param theMess      - Output parameter intended for returning error message
+ *  \param theEntryList - List of entries of published objects
+  * \retval bool        - TRUE if mesh is edited successfully, FALSE otherwise
  *
  * Assigns new name hypotheses and algorithms to the mesh or sub-mesh
  */
 //================================================================================
-bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
+bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess, QStringList& theEntryList)
 {
   theMess = "";
 
@@ -2628,6 +2629,12 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
   if ( !isMesh && !aSubMeshVar->_is_nil() )
     aMesh = aSubMeshVar->GetFather();
 
+  _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh.in());
+  if (aMeshSO) {
+    SMESH::SetName(aMeshSO, myDlg->objectText(SMESHGUI_MeshDlg::Obj));
+    theEntryList.append(aMeshSO->GetID().c_str());
+  }
+
   // Assign new algorithms and hypotheses
   for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
   {
index cf55cf34616f03db042e34d85714b6e05cf27e8f..a4fbeb3ea7be79e5dd5ed62fb5bd86bc58f05dfe 100644 (file)
@@ -120,7 +120,7 @@ private:
 
   bool                           createMesh( QString&, QStringList& );
   bool                           createSubMesh( QString&, QStringList& );
-  bool                           editMeshOrSubMesh( QString& );
+  bool                           editMeshOrSubMesh( QString&, QStringList& );
   void                           createSubMeshOnInternalEdges( SMESH::SMESH_Mesh_ptr mesh,
                                                                GEOM::GEOM_Object_ptr mainShape );
   bool                           checkSubMeshConcurrency( SMESH::SMESH_Mesh_ptr    mesh,
index 19d9fb6fdc735ad532d1c164f6fb15167bd4afba..b964f55eabbac9e79592727ae2ea2fb3c13fc1cd 100644 (file)
@@ -195,7 +195,7 @@ def smesh_create_dual_mesh(mesh_ior, output_file, adapt_to_shape=True,
         id_grp_poly, nodes_added_on_tri = \
             __getIdsGrpDualFromOrig(mc_mesh_file, grp_name, mesh2d, -1)
 
-        if id_grp_poly is not None and grp_name[:4] == __prefix:
+        if id_grp_poly is not None and grp_name[:4] == __prefix and adapt_to_shape:
             # This group is on a specific geom face
             face_id = grp_name.split("_")[-1]
             face_id = int(face_id)