Salome HOME
22658: EDF 8542 SMESH: GHS3D computation randomly fails
authoreap <eap@opencascade.com>
Wed, 6 Aug 2014 12:21:18 +0000 (16:21 +0400)
committereap <eap@opencascade.com>
Wed, 6 Aug 2014 12:21:18 +0000 (16:21 +0400)
  Fix a SIGSEGV when bad elements are Viscous proxy faces

src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx
src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx

index b72f09c61b6ab870ca54868072cdfb2c81a3c954..bfec44fbabd8f091cc386407e679c67d6f518399 100644 (file)
@@ -3632,7 +3632,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   else if ( OSD_File( aLogFileName ).Size() > 0 )
   {
     // get problem description from the log file
-    _Ghs2smdsConvertor conv( aNodeByGhs3dId );
+    _Ghs2smdsConvertor conv( aNodeByGhs3dId, proxyMesh );
     storeErrorDescription( aLogFileName, conv );
   }
   else
@@ -3874,7 +3874,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   else if ( OSD_File( aLogFileName ).Size() > 0 )
   {
     // get problem description from the log file
-    _Ghs2smdsConvertor conv( aNodeByGhs3dId );
+    _Ghs2smdsConvertor conv( aNodeByGhs3dId, proxyMesh );
     storeErrorDescription( aLogFileName, conv );
   }
   else {
@@ -4507,8 +4507,9 @@ bool GHS3DPlugin_GHS3D::storeErrorDescription(const TCollection_AsciiString& log
  */
 //================================================================================
 
-_Ghs2smdsConvertor::_Ghs2smdsConvertor( const map <int,const SMDS_MeshNode*> & ghs2NodeMap)
-  :_ghs2NodeMap( & ghs2NodeMap ), _nodeByGhsId( 0 )
+_Ghs2smdsConvertor::_Ghs2smdsConvertor( const map <int,const SMDS_MeshNode*> & ghs2NodeMap,
+                                        SMESH_ProxyMesh::Ptr                   mesh)
+  :_ghs2NodeMap( & ghs2NodeMap ), _nodeByGhsId( 0 ), _mesh( mesh )
 {
 }
 
@@ -4518,8 +4519,9 @@ _Ghs2smdsConvertor::_Ghs2smdsConvertor( const map <int,const SMDS_MeshNode*> & g
  */
 //================================================================================
 
-_Ghs2smdsConvertor::_Ghs2smdsConvertor( const vector <const SMDS_MeshNode*> &  nodeByGhsId)
-  : _ghs2NodeMap( 0 ), _nodeByGhsId( &nodeByGhsId )
+_Ghs2smdsConvertor::_Ghs2smdsConvertor( const vector <const SMDS_MeshNode*> &  nodeByGhsId,
+                                        SMESH_ProxyMesh::Ptr                   mesh)
+  : _ghs2NodeMap( 0 ), _nodeByGhsId( &nodeByGhsId ), _mesh( mesh )
 {
 }
 
@@ -4552,13 +4554,13 @@ const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const vector<int>& ghsNod
 
   if ( nbNodes == 2 ) {
     const SMDS_MeshElement* edge= SMDS_Mesh::FindEdge( nodes[0], nodes[1] );
-    if ( !edge )
+    if ( !edge || edge->GetID() < 1 || _mesh->IsTemporary( edge ))
       edge = new SMDS_LinearEdge( nodes[0], nodes[1] );
     return edge;
   }
   if ( nbNodes == 3 ) {
     const SMDS_MeshElement* face = SMDS_Mesh::FindFace( nodes );
-    if ( !face )
+    if ( !face || face->GetID() < 1 || _mesh->IsTemporary( face ))
       face = new SMDS_FaceOfNodes( nodes[0], nodes[1], nodes[2] );
     return face;
   }
index 11cbdf7a9795149d1291754f5a30f8cd76666aa1..ba632a13c94003415561511fbfbeba34043f110d 100644 (file)
 #ifndef _GHS3DPlugin_GHS3D_HXX_
 #define _GHS3DPlugin_GHS3D_HXX_
 
-#include "SMESH_Algo.hxx"
-#include "SMESH_Gen.hxx"
-#include "SMESH_Gen_i.hxx"
+#include <SMESH_Algo.hxx>
+#include <SMESH_Gen.hxx>
+#include <SMESH_Gen_i.hxx>
+#include <SMESH_ProxyMesh.hxx>
 
 #include <map>
 #include <vector>
@@ -110,11 +111,14 @@ class _Ghs2smdsConvertor
 {
   const std::map <int,const SMDS_MeshNode*> * _ghs2NodeMap;
   const std::vector <const SMDS_MeshNode*> *  _nodeByGhsId;
+  SMESH_ProxyMesh::Ptr                        _mesh;
 
 public:
-  _Ghs2smdsConvertor( const std::map <int,const SMDS_MeshNode*> & ghs2NodeMap);
+  _Ghs2smdsConvertor( const std::map <int,const SMDS_MeshNode*> & ghs2NodeMap,
+                      SMESH_ProxyMesh::Ptr                        mesh);
 
-  _Ghs2smdsConvertor( const std::vector <const SMDS_MeshNode*> &  nodeByGhsId);
+  _Ghs2smdsConvertor( const std::vector <const SMDS_MeshNode*> &  nodeByGhsId,
+                      SMESH_ProxyMesh::Ptr                        mesh);
 
   const SMDS_MeshElement* getElement(const std::vector<int>& ghsNodes) const;
 };