Salome HOME
52730: Activation of SMESH fails after GEOM group modification
authoreap <eap@opencascade.com>
Wed, 6 May 2015 11:30:51 +0000 (14:30 +0300)
committereap <eap@opencascade.com>
Wed, 6 May 2015 11:30:51 +0000 (14:30 +0300)
    Fix SMESH_Mesh_i::CheckGeomGroupModif()

52731: Exception at export of SEG3 groups
  Fix BUGs concerning Export:
1) Exception at export of the SEG3 group as a separate object.
2) Many formats available in the pop-up menu when several objects selected while only MED and CGNS formats support several meshes in one file.
3) Export of the mesh and its group to the same file results of storage of the group only. Object names are not kept.

src/DriverCGNS/DriverCGNS_Read.hxx
src/SMDS/SMDS_MeshInfo.hxx
src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx
src/SMESHGUI/SMESHGUI.cxx
src/SMESH_I/SMESH_Mesh_i.cxx

index 51d230a0ec2a84c7b6009a0f2b6d2008cfa394b0..6ae4b812a91f7c0b9f49d6756b9b2dfb2db891fc 100644 (file)
@@ -35,7 +35,7 @@
 
 /*!
  * \brief Driver reading a mesh from the CGNS file. The mesh to read is selected by 
- *  an index (counted form 0) set via SetMeshId()
+ *  an index (counted from 0) set via SetMeshId()
  */
 class MESHDriverCGNS_EXPORT DriverCGNS_Read : public Driver_SMESHDS_Mesh
 {
index 6196645c7aee159ad6884903936c5fd4a2403f8d..fa49ecd24b00f9874de49edd8c70a32318282cfe 100644 (file)
@@ -128,21 +128,21 @@ inline SMDS_MeshInfo::SMDS_MeshInfo():
   // 0 ------------------  - DON't USE 0!!!
   // 1            .  * .
   // 2         .       *
-  // 3      .     *
-  // 4   *  .  .
+  // 3      .  .  *
+  // 4   *  .
   // 5   *
   // 6   *  .
-  // 7      .  *
+  // 7      .
   // 8   *  .
-  // 9      .  *
+  // 9      .
   // 10  *
   // 11
   // 12  *
   // 13  *
   // 14
   // 15  *
-  // 16     
-  // 17     
+  // 16        *
+  // 17        *
   // 18     *
   // 19     *
   // 20  *   
@@ -158,7 +158,7 @@ inline SMDS_MeshInfo::SMDS_MeshInfo():
   myShift.resize(SMDSAbs_NbElementTypes, 0);
 
   myShift[ SMDSAbs_Face      ] = +15;// 3->18, 4->19, etc.
-  myShift[ SMDSAbs_Edge      ] = +5; // 2->7, 4->9
+  myShift[ SMDSAbs_Edge      ] = +14;// 2->16, 3->17
   myShift[ SMDSAbs_0DElement ] = +2; // 1->3
   myShift[ SMDSAbs_Ball      ] = +1; // 1->2
 
@@ -169,7 +169,7 @@ inline SMDS_MeshInfo::SMDS_MeshInfo():
   myNb[ index( SMDSAbs_Ball,1 )] = & myNbBalls;
 
   myNb[ index( SMDSAbs_Edge,2 )] = & myNbEdges;
-  myNb[ index( SMDSAbs_Edge,4 )] = & myNbQuadEdges;
+  myNb[ index( SMDSAbs_Edge,3 )] = & myNbQuadEdges;
 
   myNb[ index( SMDSAbs_Face,3 )] = & myNbTriangles;
   myNb[ index( SMDSAbs_Face,4 )] = & myNbQuadrangles;
index 73030e901a943a47e4012b9870bc435b4411c03d..49446080fa25794004ca7f9c81952eedf4b3d7e6 100644 (file)
@@ -1552,7 +1552,8 @@ void SMESH_Mesh::ExportSTL(const char *        file,
 //================================================================================
 
 void SMESH_Mesh::ExportCGNS(const char *        file,
-                            const SMESHDS_Mesh* meshDS)
+                            const SMESHDS_Mesh* meshDS,
+                            const char *        meshName)
 {
   int res = Driver_Mesh::DRS_FAIL;
 #ifdef WITH_CGNS
@@ -1560,6 +1561,8 @@ void SMESH_Mesh::ExportCGNS(const char *        file,
   myWriter.SetFile( file );
   myWriter.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
   myWriter.SetMeshName( SMESH_Comment("Mesh_") << meshDS->GetPersistentId());
+  if ( meshName && meshName[0] )
+    myWriter.SetMeshName( meshName );
   res = myWriter.Perform();
 #endif
   if ( res != Driver_Mesh::DRS_OK )
index d8ac1f2d576681457d197d07f460aa318a7d3a11..b6f001f277449eae344d7e6dbab7da862f03d920 100644 (file)
@@ -259,7 +259,8 @@ class SMESH_EXPORT SMESH_Mesh
                  const bool          isascii,
                  const SMESHDS_Mesh* meshPart = 0) throw(SALOME_Exception);
   void ExportCGNS(const char *        file,
-                  const SMESHDS_Mesh* mesh);
+                  const SMESHDS_Mesh* mesh,
+                  const char *        meshName = 0);
   void ExportGMF(const char *        file,
                  const SMESHDS_Mesh* mesh,
                  bool                withRequiredGroups = true );
index b781cba0087d0de6c640f63a28da683b8621b94f..5db6d9e10f3524814875f95bf975f2c5a7e454aa 100644 (file)
@@ -426,17 +426,16 @@ namespace
     const bool isMED = ( theCommandID == SMESHOp::OpExportMED || theCommandID == SMESHOp::OpPopupExportMED );
     const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV || theCommandID == SMESHOp::OpPopupExportUNV );
     const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL || theCommandID == SMESHOp::OpPopupExportSTL );
-  #ifdef WITH_CGNS
+#ifdef WITH_CGNS
     const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS || theCommandID == SMESHOp::OpPopupExportCGNS );
-  #else
+#else
     const bool isCGNS= false;
-  #endif
+#endif
     const bool isSAUV= ( theCommandID == SMESHOp::OpExportSAUV || theCommandID == SMESHOp::OpPopupExportSAUV );
     const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF || theCommandID == SMESHOp::OpPopupExportGMF );
 
-    // actually, the following condition can't be met (added for insurance)
-    if( selected.Extent() == 0 ||
-        ( selected.Extent() > 1 && !isMED && !isSTL ))
+    const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
+    if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
       return;
 
     // get mesh object from selection and check duplication of their names
@@ -4383,9 +4382,9 @@ void SMESHGUI::initialize( CAM_Application* app )
 #ifdef WITH_CGNS
   createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
 #endif
-  createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, multiple_non_empty, anId );
-  createPopupItem( SMESHOp::OpPopupExportGMF,  OB, mesh_group, multiple_non_empty, anId );
-  createPopupItem( SMESHOp::OpPopupExportDAT,  OB, mesh_group, multiple_non_empty, anId );
+  createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, only_one_non_empty, anId );
+  createPopupItem( SMESHOp::OpPopupExportGMF,  OB, mesh_group, only_one_non_empty, anId );
+  createPopupItem( SMESHOp::OpPopupExportDAT,  OB, mesh_group, only_one_non_empty, anId );
   createPopupItem( SMESHOp::OpDelete,          OB, mesh_part + " " + hyp_alg );
   createPopupItem( SMESHOp::OpDeleteGroup,     OB, group );
   popupMgr()->insert( separator(), -1, 0 );
index 2389d03b53054ef70bfb428939750e5135d157f1..fda60d2691f046ddd4ba95fd97922b0fbc3c92b9 100644 (file)
@@ -2239,9 +2239,10 @@ void SMESH_Mesh_i::CheckGeomGroupModif()
           groupData.push_back
             ( make_pair( TIndexedShape( gog->GetID(),gog->GetShape()), gog->GetType()));
       }
-      // set new shape to mesh -> DS of submeshes and geom groups is deleted
+      // set new shape to mesh -> DS of sub-meshes and geom groups is deleted
+      _impl->ShapeToMesh( TopoDS_Shape() ); // IPAL52730
       _impl->ShapeToMesh( newShape );
-      
+
       // reassign hypotheses
       TShapeHypList::iterator indS_hyps = assignedHyps.begin();
       for ( ; indS_hyps != assignedHyps.end(); ++indS_hyps )
@@ -2258,7 +2259,7 @@ void SMESH_Mesh_i::CheckGeomGroupModif()
           continue;
         for ( hypIt = hyps.begin(); hypIt != hyps.end(); ++hypIt )
           _impl->AddHypothesis( geom._shape, (*hypIt)->GetID());
-        // care of submeshes
+        // care of sub-meshes
         SMESH_subMesh* newSubmesh = _impl->GetSubMesh( geom._shape );
         if ( newID != oldID ) {
           _mapSubMesh   [ newID ] = newSubmesh;
@@ -3577,8 +3578,16 @@ void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart,
 
   PrepareForWriting(file,overwrite);
 
+  std::string meshName("");
+  SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
+  SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( study, meshPart );
+  if ( !so->_is_nil() )
+  {
+    CORBA::String_var name = so->GetName();
+    meshName = name.in();
+  }
   SMESH_MeshPartDS partDS( meshPart );
-  _impl->ExportCGNS(file, &partDS);
+  _impl->ExportCGNS(file, &partDS, meshName.c_str() );
 
   TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportCGNS( "
                 << meshPart<< ", r'" << file << "', " << overwrite << ")";